Harryxun/stf_run huggingface dataset:
#from fractions import gcd
import functools
import math

n=int(input())

a=[]
for i in map(int,input().split()):
    a.append(i)
#print(a)
if n==2:
    print(max(a))
else:
    gcdv=0
    for i in range(n):
        acpy=list(a)
        del acpy[i]
        gcdx=functools.reduce(math.gcd,acpy)
        if gcdx>gcdv:
            gcdv=gcdx
    print(gcdv)

### FIXED CODE ###

def gcdf(a):
    a.sort()
#    print("a2:",a)
    a0=a[0]
    a=[int(x%a0) for x in a if x%a0 != 0]
#    print("a2:",a)
    if len(a)==0:
        return a0
    else:
        a.append(a0)
        a0=min(a)
        return gcdf(a) 

#n=8
#a=[746130, 1385670, 4849845, 881790, 3233230, 1939938, 570570, 510510]
#ans=[19]
#n=2
#a=[1000000000, 1000000000]
#n=5
#a=[15, 18, 24, 36, 81]
#n=3
#a=[7, 6, 8]
n=int(input())
a=[]
for i in map(int,input().split()):
    a.append(i)
if n==2:
    print(max(a))
elif n<2**10:
    gcdv=0
    for i in range(n):
        acpy=list(a)
        del acpy[i]
        gcdx=gcdf(acpy)
        if gcdx>gcdv:
            gcdv=gcdx
    print(gcdv)
else:
    m=int(n**(1/2))
    ns=int(n/m)
    rgcd=[]
    for mi in range(m):
        ms=ns*mi
        if mi==m-1:
            am=a[ms:n]
        else:
            am=a[ms:ms+ns]
        gcdm=gcdf(am)
        rgcd.append(gcdm)
    gcdv=0

    for mi in range(m):
        rgcd1=list(rgcd)
        del rgcd1[mi]
        gcdrg1=gcdf(rgcd1)
        ms=ns*mi
        if mi==m-1:
            am=a[ms:n]
        else:
            am=a[ms:ms+ns]
#        print(mi,gcdf(am),len(am),gcdf(rgcd1))
        for i in range(len(am)):
            acpy=list(am)
#            del acpy[i]
#            acpy.append(gcdrg1)
            acpy[i]=gcdrg1
            gcdx=gcdf(acpy)
            if gcdx>gcdv:
                gcdv=gcdx
    print(gcdv)
l = list(int(input(),16).split)

if l[0] < l[1]:
  print("<")
elif l[0] = l[1]:
  print ("=")
elif l[0] > l[1]:
  print(">")

### FIXED CODE ###

l = input().split()
l2 = [int(s, 16) for s in l]

if l2[0] < l2[1]:
  print("<")
elif l2[0] == l2[1]:
  print ("=")
elif l2[0] > l2[1]:
  print(">")
K, X = input().split()
K = int(K)
X = int(X)
print(("Yes" if K * 500 >= X else "No")


### FIXED CODE ###

K, X = input().split()
K = int(K)
X = int(X)
print("Yes" if K * 500 >= X else "No")
n,m = map(input().split())

if n == m:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

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

if n == m:
    print('Yes')
else:
    print('No')
N = int(input())
A = int(input())
if(N % 500 =< A):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

N = int(input())
A = int(input())
if(N % 500 <= A):
    print('Yes')
else:
    print('No')
import io,sys
sys.setrecursionlimit(10**6)

def prime(n):
    nums = [True]*n
    primes = []
    for i in range(2,n):
        if nums[i]:
            primes.append(i)
            for j in range(2*i,n,i):
                nums[j] = False
    return primes

def main():
    from collections import Counter
    from collections import deque
    import bisect
    n = int(input())
    num = Counter([])

    primes = prime(int(n**0.5+1))+[n]
    primes = deque(primes)

    while n !=1:
        while True:
            p = primes.popleft()
            if n%p==0:
                num[p]+=1
                n = n//p
                primes.appendleft(p)
                break

    m = max(num.values())
    N = [i*(i+1)//2 for i in range(1,int((2*m)**0.5)+1)]
    ans = 0
    for i in num.values():
        k = bisect.bisect_right(N,i)
        ans+=k
    print(ans)
main()

### FIXED CODE ###

def prime(n):
    nums = [True]*n
    primes = []
    for i in range(2,n):
        if nums[i]:
            primes.append(i)
            for j in range(2*i,n,i):
                nums[j] = False
    return primes

def prime_fac(n):
    fac = {}
    primes = prime(int(n**0.5)+1)
    for p in primes:
        while n%p==0:
            fac[p] = fac.get(p,0)+1
            n//=p
    if n > 1:
        fac[n] = 1
    return fac

def main():
    n = int(input())
    fac = prime_fac(n)

    ans = 0
    for i in fac.values():
        ct = 1
        while i >= ct*(ct+1)//2:
            ct += 1
            ans+=1
    print(ans)
main()
n=int(input())
s=input()
if n%2!=0:
  print("No")
else:
  if s[:int(n//2)]==s[int(n//2):]:
    print("Yes")
  else:
    print("No")

### FIXED CODE ###

a=int(input())
print(a*a)
#

import sys
input=sys.stdin.readline

def main():
    X,N=map(int,input().split())
    p=list(map(int,input().split()))
    p.sort()
    ans=[]
    for i in range(max(X,100-X)):
        if not X+i in p:
            ans+=[X+i]
        if not X-i in p:
            ans+=[X-i]
        if len(ans)>0:
            break
    print(min(ans))
    
if __name__=="__main__":
    main()


### FIXED CODE ###

#

import sys
input=sys.stdin.readline

def main():
    X,N=map(int,input().split())
    p=list(map(int,input().split()))
    ans=[]
    for i in range(max(X,100-X)):
        if not X+i in p:
            ans+=[X+i]
        if not X-i in p:
            ans+=[X-i]
        if len(ans)>0:
            break
    if len(ans)==0:
        print(0)
    else:
        print(min(ans))
    
if __name__=="__main__":
    main()
import sys
N,K,Q =map(int,input().split())
F = {}
A = []
for l in sys.stdin:
    A.append(int(l))
for i in range(N):
    cnt = A.count(i+1)
    F[str('A'+ str(i+1))] = K - (Q - cnt)
    if F[str('A'+ str(i+1))] >= 1 :
        print("Yes")
    else:
        print("No")


### FIXED CODE ###

N=input()
if N == "Sunny" :
    print("Cloudy")
elif N == "Cloudy" :
    print("Rainy")
else:
    print("Sunny")
n = int(input())
if n == 1:
    print("Hello World")
elif n == 2:
    a, b = map(int, input().split())
    print(a + b)

### FIXED CODE ###

n = int(input())
if n == 1:
    print("Hello World")
elif n == 2:
    a = int(input())
    b = int(input())
    print(a + b)
#!python3.8
# -*- coding: utf-8 -*-
# abc171/abc171_a
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    a = i2s
    print('A' if a.isupper() else 'a')
    return

main()


### FIXED CODE ###

#!python3.8
# -*- coding: utf-8 -*-
# abc171/abc171_a
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    a = i2s()
    print('A' if a.isupper() else 'a')
    return

main()
x=[]
y=[]
for i in range(10**5//2+1):
	x.append([i,0])
	y.append([i,0])
n=int(input())
a=list(map(int,input().split()))
for i in range(n//2):
	x[a[i*2]][1]+=1
	y[a[i*2+1]][1]+=1
x.sort(key=lambda x:-x[1])
y.sort(key=lambda x:-x[1])
if x[0][0]!=y[0][0]:
	print(n-x[0][1]-y[0][1])
else:
	print(n-max(x[0][1]+y[1][1],
		x[1][1]+y[0][1]))

### FIXED CODE ###

x=[]
y=[]
n=int(input())
a=list(map(int,input().split()))
for i in range(10**5+1):
	x.append([i,0])
	y.append([i,0])
for i in range(n//2):
	x[a[i*2]][1]+=1
	y[a[i*2+1]][1]+=1
x.sort(key=lambda x:-x[1])
y.sort(key=lambda x:-x[1])
if x[0][0]!=y[0][0]:
	print(n-x[0][1]-y[0][1])
else:
	print(n-max(x[0][1]+y[1][1],
		x[1][1]+y[0][1]))
h,w,k=map(int,input().split())
g = [['#']*(w) for i in range(h)]
for i in range(h):
  g[i] = list(input())
a = [0] * (h)
for i in range(h):
  a[i] = [j for j in range(w) if g[i][j] == '#']
G=[[]*w for i in range(h)]
b=1
if g[0]==['.']*w:
  for i in range(h):
    if g[i]!=['.']*w:
      if len(a[i])==1:
        G[i]=[b]*w
        b=b+1
      else:
        for j in range(len(a[i])):
          if j==0:
            G[i]=[b]*(a[i][j+1])
            b=b+1
          elif j!=len(a[i])-1:
            for k in range(a[i][j+1]-a[i][j]):
              G[i].append(b)
            b=b+1
            
          else:
            for k in range(w-a[i][j]):
              G[i].append(b)
            b=b+1
            break
            
            
  for l in range(i-1):
    G[l]=G[i-1]
  for i in range(i+1,h):
    if (a[i])==0:
      G[i]==G[i-1]
    elif len(a[i])==1:
      G[i]=[b]*w
      b=b+1
    else:
      for j in range(len(a[i])):
        if j==0:
          G[i]=[b]*(a[i][j+1])
          b=b+1
        elif j==len(a[i])-1:
          for k in range(w-a[i][j]):
            G[i].append(b)
          b=b+1
        else:
          for k in range(a[i][j+1]-a[i][j]):
            G[i].append(b)
          b=b+1
      
else:
  for i in range(h):
    if (a[i])==0:
      G[i]==G[i-1]
    elif len(a[i])==1:
      G[i]=[b]*w
      b=b+1
    else:
      for j in range(len(a[i])):
        if j==0:
          G[i]=[b]*(a[i][j+1])
          b=b+1
        elif j==len(a[i])-1:
          for k in range(w-a[i][j]):
            G[i].append(b)
          b=b+1
        else:
          for k in range(a[i][j+1]-a[i][j]):
            G[i].append(b)
          b=b+1
for i in range(h):
  for j in range(w):
    print(G[i][j], end="　")
  print()
    

### FIXED CODE ###

h,w,k=map(int,input().split())
G=[["."]*w for i in range(h)]
for i in range(h):
  G[i]=list(input())
ans=[[0]*w for i in range(h)]
GG=[[0] for i in range(h)]
for i in range(h):
  for j in range(w):
    if G[i][j]=="#":
      GG[i].append(j)
  GG[i].append(w)
B=[0]
a=1
for i in range(h):
  if len(GG[i])==2:
    continue
  B.append(i)
  ans[i][GG[i][0]:GG[i][2]]=[a]*(GG[i][2]-GG[i][0])
  a=a+1
  for j in range(len(GG[i])-3):
    ans[i][GG[i][j+2]:GG[i][j+3]]=[a]*(GG[i][j+3]-GG[i][j+2])
    a=a+1
B.append(h)
for i in range(B[2]-B[0]):
  ans[i]=ans[B[1]]
for i in range(B[2],h):
  if i not in B:
    ans[i]=ans[i-1]
for i in range(h):
  for j in range(w):
    print(ans[i][j],end=" ")
  print()
s=[input() for _ in range(int(input()))]
t=[input() for _ in range(int(input()))]
l=list(set(n))
print(max(0,max(s.count(l[i])-t.count(l[i]) for i in range(len(l)))))n=[input() for _ in range(int(input()))]
m=[input() for _ in range(int(input()))]
l=list(set(n))
print(max(0,max(n.count(l[i])-m.count(l[i]) for i in range(len(l)))))

### FIXED CODE ###

N=int(input())
s=[input() for _ in range(N)]
M=int(input())
t=[input() for _ in range(M)]
def ans1(x):
    return s.count(x)-t.count(x)
ans2=0
ans_1=0
for S in s:
    if ans1(S)>0 and ans1(S)>ans2:
            ans2=ans1(S)
if ans2>=0:
    print(ans2)
else:
    print("0")
x = []
num_z = num_time/60
num_h = (num_time%60)/60
num_b = (num_time%60)%60
x.append(num_z)
x.append(num_h)
x.append(num_b)
x = map(str, x)
print ":".join(x)

### FIXED CODE ###

num_time = int(raw_input())
x = []
num_z = num_time/3600
num_h = (num_time%3600)/60
num_b = (num_time%3600)%60
x.append(num_z)
x.append(num_h)
x.append(num_b)
x = map(str, x)
print ":".join(x)
def resolve():
	s = input()
	k = int(input())
	if len(s) == 1:
		print(s)
		return

	for i in s:
		if int(i) == 1:
			continue
		print(i)
		return
	print(s[0])
resolve()

### FIXED CODE ###

def resolve():
	n = int(input())
	if n == 0:
		print("0")
		return
	out = []
	while n != 0:
		n, rem = divmod(n, -2)
		if rem < 0:
			n += 1
			rem -= -2
		out.append(rem)
	print("".join(map(str, out[::-1])))
resolve()
item = input()
if 7 in item:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

item = input()
if "7" in item:
  print("Yes")
else:
  print("No")
c=1
for i in range(int(input())):
  if i**2<=n:c=i**2
print(c)

### FIXED CODE ###

print(int(int(input())**.5)**2)
N, M = map(int, input().split())
ans = {}
flg = False
for _ in range(M):
    s, c = map(int, input().split())
    if s == 1 and c == 0:
        if N == 1:
            flg = True
            ans[s] = c
        else:
            print(-1)
            exit()
    else:
        if s in ans.keys():
            if c != ans[s]:
                print(-1)
                exit()
        else:
            ans[s] = c
if flg:
    print(0)
else:
    if N >= 2:
        num = ["1"] + ["0"]*(N-1)
        for k, v in ans.items():
            num[k-1] = str(v)
        print("".join(num))
    else:
        print(ans[1])


### FIXED CODE ###

N, M = map(int, input().split())
ans = {}
flg = False
for _ in range(M):
    s, c = map(int, input().split())
    if s == 1 and c == 0:
        if N == 1:
            flg = True
            ans[s] = c
        else:
            print(-1)
            exit()
    else:
        if s in ans.keys():
            if c != ans[s]:
                print(-1)
                exit()
        else:
            ans[s] = c
if flg:
    print(0)
else:
    if N >= 2:
        num = ["1"] + ["0"]*(N-1)
        for k, v in ans.items():
            num[k-1] = str(v)
        print("".join(num))
    else:
        if ans.keys():
            print(ans[1])
        else:
            print(0)
S, T = map(int, input().split())
A, B = map(int, input().split())
if input() == S:
  print(A-1, B)
else:
  print(A, B-1)

### FIXED CODE ###

S, T = input().split()
A, B = map(int, input().split())
if input() == S:
  print(A-1, B)
else:
  print(A, B-1)
A,B,N =map(int,input().split())
ans =0
for x in range(1,N+1):
  num = math.floor(A*x/B) - A * math.floor(x/B)
  if num > ans:
    ans = num

print(ans)

### FIXED CODE ###

import math

A,B,N = map(int,input().split())
if B>N:
  print( math.floor(A*N/B) - A * math.floor(N/B))
  exit()
print( math.floor(A*(B-1)/B) - A * math.floor((B-1)/B))
n=int(input())
a=[input().split()]
x=1
for i in range(n):
    x*=int(a[i])
if x>10**18:
    print("-1")
else:
    print(x)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
 
mul=1
if 0 in A:print("0")
else:
    for i in range(N):
        mul*=A[i]
        if mul>pow(10,18):
            print("-1")
            break
        elif i==N-1:print(mul)
import sys
from math import factorial
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
def main():
    n, k = list(map(int, input().split()))
    modulo = 1000_000_000 + 7

    def combinations_count(n, r):
        return factorial(n) // (factorial(n - r) * factorial(r))

    for i in range(1, k+1):
        if i > n//2 + 1:
            print(0)
            continue
        # i分割する方法
        a = combinations_count(k-1, i-1)
        # 赤のボールを分割する方法
        b = combinations_count(n-k+1, i)
        print(a*b%modulo)

main()

### FIXED CODE ###

from operator import mul
from functools import reduce


def cmb(n, r):
	if n < r:
		return 0
	r = min(n - r, r)
	if r == 0:
		return 1
	numer = reduce(mul, range(n, n - r, -1))
	denom = reduce(mul, range(1, r + 1))
	return numer // denom % INF


N, K = map(int, input().split())
INF = 10 ** 9 + 7

for i in range(1, K + 1):
	print(cmb(K - 1, i - 1) * cmb(N - K + 1, i) % INF)
N, K = input().split()
P = input().split()
P.sort(reverse=True)
sum = 0
for k in range(int(K)):
  p = int(P[k])
  sum += (p / 2) + 0.5
print(sum)


### FIXED CODE ###

S, T = input().split()
A, B = input().split()
U = input()

ans1 = int(A)
ans2 = int(B)
if S == U:
  ans1 = ans1 - 1
if T == U:
  ans2 = ans2 - 1

print(ans1, ans2)
n = int(input())
# bを奇数の数と仮定して
ｂ = 'math.ceil(n/2)'
#　奇数/全体ってやればいいのかな？
print(b/ｎ)

### FIXED CODE ###

import math
n = int(input())
print(math.ceil(n/2)/n)
from collections import defaultdict

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

d = defaultdict(lambda: 0)
for x in range(n):
	for y in range(n):
		d[(balls[x][0] - balls[y][0], balls[x][1] - balls[y][1])] += 1

del d[(0, 0)]
print(n - max(d.values()))

### FIXED CODE ###

from collections import defaultdict

n = int(input())
if n == 1:
	print(1)
else:
	balls = [list(map(int, input().split())) for _ in range(n)]

	d = defaultdict(lambda: 0)
	for x in range(n):
		for y in range(n):
			d[(balls[x][0] - balls[y][0], balls[x][1] - balls[y][1])] += 1

	del d[(0, 0)]
	print(n - max(d.values()))
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

H, W, K = map(int, input().split())
S = [input() for _ in range(H)]
mi = None

for i in range(2 ** (H - 1)):
    # div[j] is true if row j and row j + 1 is divided
    div = [(i & (1 << j)) > 0 for j in range(H - 1)]
    group = [0] * H
    for j in range(H - 1):
        group[j + 1] = group[j] + 1 if div[j] else group[j]
    count = Counter()
    ans = div.count(True)
    ok = True
    for j in range(W):
        tmp = Counter()
        for g in group:
            tmp[g] = 0
        for k in range(H):
            if S[k][j] == '1':
                tmp[group[k]] += 1
        if max(tmp.values()) > K:
            ok = False
        elif max((tmp + count).values()) <= K:
            count += tmp
        else:
            count = tmp
            ans += 1
    if ok and (mi is None or ans < mi):
        mi = ans

print(mi)


### FIXED CODE ###

import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

H, W, K = map(int, input().split())
S = [input() for _ in range(H)]
mi = None

def _max(iterable):
    ma = 0
    for i in iterable:
        ma = max(ma, i)
    return ma

for i in range(2 ** (H - 1)):
    # div[j] is true if row j and row j + 1 is divided
    div = [(i & (1 << j)) > 0 for j in range(H - 1)]
    group = [0] * H
    for j in range(H - 1):
        group[j + 1] = group[j] + 1 if div[j] else group[j]
    count = Counter()
    ans = div.count(True)
    ok = True
    for j in range(W):
        tmp = Counter()
        for k in range(H):
            if S[k][j] == '1':
                tmp[group[k]] += 1
        if _max(tmp.values()) > K:
            ok = False
        elif _max((tmp + count).values()) <= K:
            count += tmp
        else:
            count = tmp
            ans += 1
    if ok and (mi is None or ans < mi):
        mi = ans

print(mi)
from functools import reduce

def comb(n,k,p):
    if k==0:
        return 1
    A = reduce(lambda x,y:x*y%p ,[n-k+1+i for i in range(k)])
    B = reduce(lambda x,y:x*y%p ,[i+1 for i in range(k)])
    return A*pow(B,p-2,p)%p

n,K = map(int,input().split())
p = pow(10,9)+7
counter = 0

for k in range(K+1):
    counter += comb(n-1,n-k-1,p)*comb(n,k,p)

print(counter)

### FIXED CODE ###

n,k = map(int,input().split())
p = pow(10,9)+7
li = [1]*(n+2)

counter = 0
k = min(k,n-1)

for a in range(1,n+1):
    li[a] = a*li[a-1]%p

def comb(a,b):
    if b<1:
        return 1
    return li[a]*pow(li[b],p-2,p)*pow(li[a-b],p-2,p)


for i in range(k+1):
    counter += comb(n,i)*comb(n-1,i)%p
    #nCi*  (n-1)Cn-i-1


    #n人をn-iのぐるーぷに分ける

print(counter%p)
def isp(n):
    a = 1
    for i in range(2, (n + 1) // 2 + 2):
        if not n % i:
            a = 0
            break
    return a


for i in sys.stdin:
    n = int(i)
    if num == 2:
        print(1)
    elif num == 3:
        print(2)
    else:
        s = 2
        for x in range(2, num + 1):
            if isp(x):
                s += 1
        print(s)

### FIXED CODE ###

import sys

f = [1, 0, 0, 0, 1, 0] * (1000000 // 6 + 1)
f = [0, 0, 1, 1] + f[3:-2]

i = 5
while i < 1000:
    if f[i] == 1:
        j = i * i
        while j <= 1000000:
            f[j] = 0
            j += i + i
    i += 2

for n in sys.stdin:
    i = int(n)
    print(sum(f[:i + 1]))
from collections import deque

d = deque()

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

dct = {}
for _ in range(M):
    a, b = map(int,input().split())
    if not a in dct:
        dct[a] = set()
    if not b in dct:
        dct[b] = set()
    dct[a].add(b)
    dct[b].add(a)

#print(dct)
answers = [0]*(N+1)

stack = deque([1,])
lst = []
while len(stack):
    s = stack.popleft()
    lst.append(s)
    #print(dct[s])
    for i in dct[s]:
        if i in lst:
            continue
        if i in stack:
            continue
        stack.append(i)
        answers[i] = s

if answers.count(0) != 2:
    print("No")
else:
    print("Yes")
    for ans in answers[2:]:
        print(ans)

### FIXED CODE ###

N = input()
print(["p","p","h","b","h","h","p","h","p","h"][int(N[-1])]+"on")
S = list(input())
Q = int(input())
S_r = []
S_l = []

n = 0

for i in range(Q):
  q = list(input().split())
  if int(q[0]) == 1:
    n += 1
  else:
      if int(q[1]) == 1:
        S_l.append(q[2])
        S_r = S
        n += 1
        break
      else:
        S_r.append(q[2])
        S_l = S
        n += 1
        break

  if i == Q-1:
    if not S_r and not S_l
      print(''.join(S))
    elif not S_r
      print(''.join(S_l[::-1]), end="")
      print(''.join(S))
    elif not S_l
      print(''.join(S), end="")
      print(''.join(S_r))

for i in range(Q - n):
  q = list(input().split())
  if int(q[0]) == 1:
    temp = S_r[-1]
    S_r[-1] = S_l[-1]
    S_l[-1] = temp
  else:
    if int(q[1]) == 1:
      S_l.append(q[2])
    else:
      S_r.append(q[2])

print(''.join(S_l[::-1]), end="")
print(''.join(S_r))

### FIXED CODE ###

S = list(input())
S_r = []
Q = int(input())
R = True

for i in range(Q):
  q = list(input().split())
  if int(q[0]) == 1:
    R = not R
  else:
    if int(q[1]) == 1:
      if R:
        S_r.append(q[2])
      else:
        S.append(q[2])
    else:
      if R:
        S.append(q[2])
      else:
        S_r.append(q[2])

if not S_r:
  if R:
    print(''.join(S))
  else:
    print(''.join(S[::-1]))
else:
  if R:
    print(''.join(S_r[::-1]), end="")
    print(''.join(S))
  else:
    print(''.join(S[::-1]), end="")
    print(''.join(S_r))
a = int(input())
s =input()
if a < 3200:
    return 'red'
else:
    return s

### FIXED CODE ###

a = int(input())
s =input()
if a < 3200:
    print('red')
else:
    print(s)
N=int(input())
A=list(map(int,input().split()))
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result



for k in range(N):
    cnt=0
    L=A
    L.pop(k)
    aK=L
    lK=list(set(aK))
    for i in lK:
        if aK.count(i)>=2:
            cnt+=cmb(N-1,aK.count(i))
    print(cnt)
            
            
    

### FIXED CODE ###

import collections
n = int(input())
a = list(map(int,input().split()))
c = collections.Counter(a)
ans = sum(i*(i-1)//2 for i in c.values())
[print(ans-c[i]+1) for i in a]
min = 999999

A = 0
B = 0

def digitSum(n):
    s = str(n)
    array = list(map(int, list(s)))
    return sum(array)



for i in range(1, N/2):
    a = i
    b = N - i

    if min > digitSum(a) + digitSum(b):
        min = digitSum(a) + digitSum(b)   

print(min)

### FIXED CODE ###

N = int(input())
min = 999999

A = 0
B = 0

def digitSum(n):
    s = str(n)
    array = list(map(int, list(s)))
    return sum(array)

for i in range(1, N/2+1):
    a = i
    b = N - i

    if min > digitSum(a) + digitSum(b):
        min = digitSum(a) + digitSum(b)   

print(min)
#%%
n = int(input())
s = list(input())
r = s.count('R')
b = s.count('B')
if r > b:
    pirnt('Yes')
else:
    print('No')

### FIXED CODE ###

#%%
n = int(input())
s = list(input())
r = s.count('R')
b = s.count('B')
if r > b:
    print('Yes')
else:
    print('No')
n = int(input())
data = []
for i in range(n):
  d = int(input())
  data.append(d)
Data = sorted(data)
cnt = 0
tmp = -1
for i in Data:
  if(tmp < Data[i]):
    cnt += 1
    tmp = Data[i]
print(cnt)

### FIXED CODE ###

n = int(input())
data = []
for i in range(n):
  d = int(input())
  data.append(d)
Data = sorted(data)
cnt = 0
tmp = -1
for i in Data:
  if(tmp < i):
    cnt += 1
    tmp = i
print(cnt)