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

s=int(input())
cur=set([s])
i=1
while True:
  i=i+1
  if s%2==0:
    s=s//2
  else:
    s=3*s+1
  if s in cur:
    print(i)
  else:
    cur.add(s)

### FIXED CODE ###

s=int(input())
cur=set([s])
i=1
while True:
  i=i+1
  if s%2==0:
    s=s//2
  else:
    s=3*s+1
  if s in cur:
    print(i)
    break
  else:
    cur.add(s)
### BUGGY CODE ###

n,m=map(int,input().split())
g=[[] for i in range(n)]
ro=[0]*n
for i in range(n+m-1):
    a,b=map(int,input().split())
    g[a-1].append(b)
    ro[b-1]+=1
for i in range(n):
    if ro[i]==0:
        r=i
ans=[0]*n
q=[r]
while len(q)>0:
    u=q.pop()
    for v in g[u]:
        ans[v-1]=u+1
        q.append(v-1)
for i in ans:
    print(i)


### FIXED CODE ###

from collections import deque
n,m=map(int,input().split())
g=[[] for i in range(n)]
ro=[0]*n
for i in range(n+m-1):
    a,b=map(int,input().split())
    g[a-1].append(b)
    ro[b-1]+=1
for i in range(n):
    if ro[i]==0:
        r=i
ans=[0]*n
q=deque([r])
while len(q)>0:
    u=q.popleft()
    for v in g[u]:
        ro[v-1]-=1
        if ro[v-1]==0:
            ans[v-1]=u+1
            q.append(v-1)
for i in ans:
    print(i)
### BUGGY CODE ###

def readinput():
    n=int(input())
    x=input()
    return n,x

poptbl=[0]*(2*10**5+1)
def popcount(x):
    global poptbl
    if poptbl[x]!=0:
        return poptbl[x]
    
    poptbl[x]=bin(x).count('1')
    return poptbl[x]

ftbl=[0]*(2*10**5+1)
def f(x):
    global ftbl

    if ftbl[x]!=0:
        return ftbl[x]
    
    #print('f(x), x: {}'.format(x))
    if x==0:
        return 0
    else:
        ans=f(x%popcount(x))+1
        #print(ans)
        ftbl[x]=ans
        return ans    

def main():
    n=int(input())
    x=input()
    m=x.count('1')
    #print('m: {}'.format(m))
    xint=int(x,2)
    #print('xint: {}'.format(xint))
    if m!=1:
        xmodm1=xint%(m-1)
    else:
        xmodm1=1
    xmodp1=xint%(m+1)
    ans=[]
    b=2**(n-1)
    for i in range(n):
        if x[i]=='1':
            if m==1:
                ans.append(0)
            else:
                xx=( xmodm1 + (m-1) -b%(m-1) )%(m-1)
                ans.append(f(xx)+1)
        else:
            xx=( xmodp1 + b%(m+1) )%(m+1)
            ans.append(f(xx)+1)
        b=b//2
    return ans

if __name__=='__main__':
    #n,x=readinput()
    ans=main()
    for a in ans:
        print(a)



### FIXED CODE ###

def readinput():
    n=int(input())
    x=input()
    return n,x

poptbl=[0]*(2*10**5+1)
def popcount(x):
    global poptbl
    if poptbl[x]!=0:
        return poptbl[x]
    
    poptbl[x]=bin(x).count('1')
    return poptbl[x]

ftbl=[0]*(2*10**5+1)
def f(x):
    global ftbl

    if ftbl[x]!=0:
        return ftbl[x]
    
    #print('f(x), x: {}'.format(x))
    if x==0:
        return 0
    else:
        ans=f(x%popcount(x))+1
        #print(ans)
        ftbl[x]=ans
        return ans    

def main():
    n=int(input())
    x=input()
    m=x.count('1')
    #print('m: {}'.format(m))
    xint=int(x,2)
    #print('xint: {}'.format(xint))
    if m!=1:
        xmodm1=xint%(m-1)
    else:
        xmodm1=1
    xmodp1=xint%(m+1)
    pow2mod1=[0]*n
    pow2mod2=[0]*n
    pow2mod1[0]=1
    pow2mod2[0]=1
    for i in range(1,n):
        if m!=1:
            pow2mod1[i]=pow2mod1[i-1]*2 % (m-1)
        pow2mod2[i]=pow2mod2[i-1]*2 % (m+1)

    ans=[]
    #b=2**(n-1)
    for i in range(n):
        if x[i]=='1':
            if m==1:
                a=0
                ans.append(a)
            else:
                xx=( xmodm1 + (m-1) -pow2mod1[n-i-1] )%(m-1)
                #ans.append(f(xx)+1)
                a=f(xx)+1
                ans.append(a)
        else:
            xx=( xmodp1 + pow2mod2[n-i-1] )%(m+1)
            #ans.append(f(xx)+1)
            a=f(xx)+1
            ans.append(a)
        #b=b//2
        print(a)
    return ans

if __name__=='__main__':
    #n,x=readinput()
    ans=main()
    #for a in ans:
    #    print(a)
### BUGGY CODE ###

n,m=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
ans=0
for i in range(n-1):
    for j in range(m-1):
        ans=(ans+(x[i+1]-x[i])*(y[j+1]-y[j])*(i+1)*(n-1-i)*(j+1)*(m-1-j))%(10**9+7)
print(ans)

### FIXED CODE ###

n,m=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
X=0
Y=0
for i in range(n-1):X=(X+(x[i+1]-x[i])*(i+1)*(n-1-i))%(10**9+7)
for i in range(m-1):Y=(Y+(y[i+1]-y[i])*(i+1)*(m-1-i))%(10**9+7)
print(X*Y%(10**9+7))
### BUGGY CODE ###

A = "0"+input()[::-1]

# lis_num = [int(s) for s in A]

# print(lis_num)

# S = [0] * len(lis_num)
S = [0] * len(A)

for i in range(len(A) - 1):
    S[i + 1] = S[i] + int(A[i + 1]) * pow(10, i)
# print(S)

cnt = [0] * 2019

for i in S:
    cnt[i % 2019] += 1

ans = 0

for i in range(2019):
    ans += cnt[i] * (cnt[i] - 1) // 2

print(ans)


### FIXED CODE ###

def main():
    A = input()[::-1]
    A = "0" + A
    # lis_num = [int(s) for s in A]

    # print(lis_num)

    # S = [0] * len(lis_num)
    S = [0] * len(A)
    cnt = [0] * 2019
    cnt[0] = 1

    for i in range(len(A) - 1):
        S[i + 1] = (S[i] + int(A[i + 1]) * pow(10, i, 2019)) % 2019
        cnt[S[i + 1] % 2019] += 1

    # print(S)

    # for i in S:
    #     cnt[i % 2019] += 1

    ans = 0

    for i in cnt:
        ans += i * (i - 1) // 2

    print(ans)


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

n=int(input())
l = [] 

for i in range(n):
    s = input()
    if s not in l:
        l += [s]
    else:
        l.remove(s)
print(len(l))

### FIXED CODE ###

import collections
n=int(input())
l = [input() for i in range(n)]
c = collections.Counter(l)
ans = 0

for x,y in c.items():
    if y%2 != 0:
        ans += 1
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-

n = int(input())
s = input()


counter = 0

for p in range(n):
    for q in range(n - p):
        a = s[p]
        b = s[p + q]
        if a == b:
            continue
        nokori = s[p + q:]
        rgb_list = ['R', 'G', 'B']
        rgb_list.remove(a)
        for e in rgb_list:
            if e not in nokori:
                continue
        rgb_list.remove(b)
        c = rgb_list[0]
        counter += nokori.count(c)
        if q < len(nokori) and nokori[q] == c:
            counter -= 1
print(counter)

### FIXED CODE ###

# -*- coding: utf-8 -*-

n = int(input())
s = input()

r_cnt = s.count('R')
g_cnt = s.count('G')
b_cnt = s.count('B')

counter = r_cnt * g_cnt * b_cnt

for i in range(n):
    for p in range(n):
        j = i + p
        k = j + p
        if k >= n:
            break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            counter -= 1
print(counter)
### BUGGY CODE ###

from scipy.sparse import*
i=lambda:tuple(map(int,input().split()))
f=csgraph.dijkstra
n,m,l=i()
d=eval('[0]*-~n,'*-~n)
while m:a,b,c=i();d[a][b]=c;m-=1
d=f(f(d,0)<=l)
d[d>n]=0
for _ in'_'*i()[0]:print(d[i()]-1)

### FIXED CODE ###

from scipy.sparse import*
s=csgraph.floyd_warshall
n,m,l,*t=map(int,open(0).read().split())
d=eval('[9e9]*-~n,'*-~n)
for a,b,c in zip(*[iter(t[:m*3])]*3):d[a][b]=d[b][a]=c
d=s(d)
d[d>l]=9e9
d[d<=l]=1
d=s(d)
d[d>9e9]=9e9
for s,t in zip(*[iter(t[m*3+1:])]*2):print(int(d[s,t]%9e9-1))
### BUGGY CODE ###

n = int(input())
l = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans *= l[i]
if ans > 1000000000000000000:
  ans = -1
print(ans)

### FIXED CODE ###

n = int(input())
l = list(map(int, input().split()))
ans = 1
if 0 in l:
    print(0)
else:
  for i in range(n):
      ans *= l[i]
      if ans > 1000000000000000000:
        ans = -1
        break
  print(ans)
### BUGGY CODE ###

n,x,y = map(int,input().split())
r = y-x+1
for k in range(1,n):
  ans = 0
  left=right=circle = 0
  for i in range(1,n+1):
    #left
    if i < x:
      if i + k <= x:#円に届かない
        left += 1
        continue
      elif r/2 == k- (x-i):
        left += 1
      elif r/2 > k - (x-i):
        left += 2
      if (x-i)+1 < k and k - (x-i)-1 - (n-y) <= 0:
        left += 1
  #right
    elif i >= y:
      if i + k <= n:
        right += 1
      if i == y:
        continue
      if r / 2 == k-(i-y):
        right += 1
      elif r / 2 > k-(i-y)>0:
      #if  k - (i- y)> 0 and (k-(i-y))< r//2:
        right += 2
  #circle
  if r /2 == k:
    circle = r//2
  elif r/2 > k:
    circle = r
  print(left+right+circle)
        

### FIXED CODE ###

n,x,y = map(int,input().split())
r = y-x+1
for k in range(1,n):
  ans = 0
  left=right=circle = 0
  for i in range(1,n+1):
    #left
    if i < x:
      if i + k <= x:#円に届かない
        left += 1
        continue
      elif r/2 == k- (x-i):
        left += 1
      elif r/2 > k - (x-i):
        left += 2
      if (x-i)+1 < k and k - (x-i)-1 - (n-y) <= 0:
        left += 1
  #right
    elif i >= y:
      if i + k <= n:
        right += 1
      if i == y:
        continue
      if r / 2 == k-(i-y):
        right += 1
      elif r / 2 > k-(i-y)>0:
      #if  k - (i- y)> 0 and (k-(i-y))< r//2:
        right += 2
  #circle
  if r /2 == k:
    circle = r//2
  elif r/2 > k:
    circle = r
  print(left+right+circle)
### BUGGY CODE ###

A = 0
B = 1
C = 2

table = {"A": A, "B": B, "C": C}

s = [table[c] for c in input()]

def count_abcs(i):
	count = 0
	while s[i] == A and s[i + 1] == B and s[i + 2] == C:
		count += 1
		i += 3
		if i >= imax:
			break
	return count

i = 0
imax = len(s) - 2
total = 0
while i < imax:
	count = count_abcs(i)
	if count >= 1:
		total += (count + 1) * count // 2
		for j in range(count):
			s[i + j * 2] = B
			s[i + j * 2 + 1] = C
			s[i + count * 2 + j] = A
		if i > 0:
			i -= 1
	else:
		i += 1

print(total)


### FIXED CODE ###

A = 0
B = 1
C = 2

table = {"A": A, "B": B, "C": C}

s = [table[c] for c in input()]
s.reverse()

total = 0
bc_count = 0
prev = None
for c in s:
	if c == A:
		if prev == C:
			bc_count = 0
		else:
			total += bc_count
	elif c == B:
		if prev == C:
			bc_count += 1
		else:
			bc_count = 0
	elif c == C:
		if prev == C:
			bc_count = 0
	prev = c

print(total)
### BUGGY CODE ###

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

a = list(set(A))
dup = [x for x in a if A.count(x) > 1]
m = len(a)
l = len(A) 
c_l = [(A.count(i)-1)*(A.count(i))/2 for i in a]
al = sum(c_l)

for k in A:
    if k not in dup:
        print(int(al))
    else :
        print(int(al-A.count(k)+1))

### FIXED CODE ###

from collections import Counter

N = int(input())
A = list(map(int,input().split()))
a = list(set(A))
cc = Counter(A)
dup = set([x for x in a if cc[x] > 1])
c_l = [(cc[i]-1)*(cc[i])/2 for i in a]
al = sum(c_l)

# for k in A:
#     if k in dup:
#         print(int(al-cc[k]+1))
#     else :
#         print(int(al))
[print(int(al-cc[k]+1)) if k in dup else print(int(al)) for k in A]
### BUGGY CODE ###

N, A, B = (int(x) for x in input().split())
s = ""
while True:
    for i in range(A):
        if len(s) != N:
            s += "b"
        else:
            break

    for j in range(B):
        if len(s) != N:
            s += "r"
        else:
            break
    if len(s) == N:
        break

print(s[:N].count("b"))

### FIXED CODE ###

N, A, B = (int(x) for x in input().split())

a, b = divmod(N, (A + B))
if A <= b:
    print((a+1) * A)
else:
    print((a * A) + b)
### BUGGY CODE ###

k, s = map(int, input().split())
result = [i_1+i_2+i_3 for i_1 in range(k+1) for i_2 in range(k+1) for i_3 in range(k+1) if i_1+i_2+i_3==s]
print(len(result))

### FIXED CODE ###

k, s = map(int, input().split())
result = [i_1+i_2 for i_1 in range(k+1) for i_2 in range(k+1) if 0<=s-i_1-i_2<=k]
print(len(result))
### BUGGY CODE ###

# coding: utf-8
import sys
input = sys.stdin.readline

def f(n, wlimit):
    dp = [[-1] * (wlimit + 1) for _ in range(n + 1)]
    dp[0][0] = 0
    for i in range(1, n + 1):
        wi, vi = map(int, input().rstrip().split())
        for w in range(wlimit + 1):
            if dp[i - 1][w] >= 0:
                w_ = w + wi
                v_ = dp[i - 1][w] + vi
                if w_ <= wlimit:
                    if dp[i - 1][w_] < v_:
                        dp[i][w_] = v_
                if dp[i][w] < dp[i - 1][w]:
                    dp[i][w] = dp[i - 1][w]
    return(max(dp[i]))

n, w = map(int, input().rstrip().split()) # 1 <= n <= 100, 1 <= w <= 10^5

print(f(n, w))


### FIXED CODE ###

# coding: utf-8
import sys
input = sys.stdin.readline

def f(n, wlimit):
    dp = [-1] * (wlimit + 1)
    dp[0] = 0
    for i in range(1, n + 1):
        wi, vi = map(int, input().rstrip().split())
        dp_ = list(dp)
        for w in range(wlimit + 1):
            if dp[w] >= 0:
                w_ = w + wi
                v_ = dp[w] + vi
                if w_ <= wlimit and dp[w_] < v_:
                    dp_[w_] = v_
        dp = dp_
    return(max(dp))

n, w = map(int, input().rstrip().split()) # 1 <= n <= 100, 1 <= w <= 10^5

print(f(n, w))
### BUGGY CODE ###

import sys 
inpurt = sys.stdin.readline
N = int(input())
cnt = 0
texts = [sorted(list(input().rstrip())) for _ in range(N)]
for i in range(N):
  for j in range(i+1, N):
    if texts[i] == texts[j]:
      cnt += 1
print(cnt)

### FIXED CODE ###

import sys 
from collections import Counter
from math import factorial

def combinations_count(n, r):
  return factorial(n) // (factorial(n - r) * factorial(r))
 
def main():
  inpurt = sys.stdin.readline
  N = int(input())
  texts = [''.join(sorted(list(input().rstrip()))) for _ in range(N)]
  c = Counter(texts)
  cnt = 0
  for t in c.values():
    if t > 1:
      cnt += combinations_count(t, 2)
  print(cnt)
 
if __name__ == '__main__':
  main()
### BUGGY CODE ###


def count(P, idx, score, G, mn, cnt):
    # print(idx, score, mn, cnt)
    if score >= G and mn > cnt:
        return cnt
    if idx > len(P)-1:
        return mn
    for i in range(P[idx][0]+1):
        tmp = P[idx][1] if i == P[idx][0] else 0
        # print(idx, i)
        mn = count(P, idx+1, score+idx*100*i+tmp, G, mn, cnt+i)
    return mn

D,G = map(int, input().split())
P = [0]
for i in range(D):
    p,c = map(int, input().split())
    P.append([p,c])
print(count(P, 1, 0, G, 10**9, 0))


### FIXED CODE ###

from math import ceil
d,g = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(d)]

ans = float('INF')
inf = float('INF')
for i in range(2**d):
    tmp = 0
    cnt = 0
    for j in range(d):
        p,c = pc[j]
        if i & (1 << j):
            tmp += p * (j+1) * 100 + c
            cnt += p
    if g <= tmp and cnt < ans:
        ans = cnt
    if g > tmp:
        tmp_cnt = inf 
        tmp_ = 0
        gg = (g - tmp) / 100
        for j in range(d):
            p,c = pc[j]
            if i & (1 << j):
                continue
            if ceil(gg / (j+1)) < min(p,tmp_cnt):
                cc = ceil(gg / (j+1))
                tmp_ = cc * (j+1) * 100
                tmp_cnt = cc
            elif gg - c / 100 <= p * (j+1) and p < tmp_cnt:
                tmp_ = p * (j+1) * 100 + c
                tmp_cnt = p
        if g <= tmp + tmp_ and cnt + tmp_cnt < ans:
            ans = cnt + tmp_cnt

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

import sys
import math
from collections import defaultdict, deque
from copy import deepcopy
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    H, W, M = MI()
    Hlist = [[0, i] for i in range(H)]
    Wlist = [[0, i] for i in range(W)]
    Dlist = [[] for i in range(H)]
    H_max = -float('inf')
    W_max = -float('inf')
    
    for i in range(M):
        h, w = MI()
        Hlist[h-1][0]+=1
        Wlist[w-1][0]+=1
        Dlist[h-1].append(w-1)
        H_max = max(H_max, Hlist[h-1][0])
        W_max = max(W_max, Wlist[w-1][0])
    Hlist = [temp for temp in Hlist if temp[0] == H_max]
    Wlist = [temp for temp in Wlist if temp[0] == W_max]
    ans = -float('inf')
    for num1, index1 in Hlist:
        for num2, index2 in Wlist:
            if index2 in Dlist[index1]:
                ans = max(ans, num1+num2-1)
            else:
                ans = max(ans, num1+num2)
                break
        else:
            continue
        break
                
            
    print(ans)
            

if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
import math
from collections import defaultdict, deque
from copy import deepcopy
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    H, W, M = MI()
    Hlist = [[0, i] for i in range(H)]
    Wlist = [[0, i] for i in range(W)]
    Dlist = [set() for i in range(H)]
    H_max = -float('inf')
    W_max = -float('inf')
    
    for i in range(M):
        h, w = MI()
        Hlist[h-1][0]+=1
        Wlist[w-1][0]+=1
        Dlist[h-1] |= {w-1}
        H_max = max(H_max, Hlist[h-1][0])
        W_max = max(W_max, Wlist[w-1][0])
    Hlist = set([temp[1] for temp in Hlist if temp[0] == H_max])
    Wlist = set([temp[1] for temp in Wlist if temp[0] == W_max])
    ans = H_max+W_max-1

    for index1 in Hlist:
        for index2 in Wlist:
            if not index2 in Dlist[index1]:
                ans += 1
                break
        else:
            continue
        break
    print(ans)

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

N = int(input())

divList = []

n = N

while n != 1:
    if n % 2 == 0:
        n = n // 2
        divList.append(2)
        continue
    if n % 3 == 0:
        n = n // 3
        divList.append(3)
        continue

    newN = n
    isFind = False
    for i in range(6, n + 1, 6):
        if n % (i - 1) == 0:
            divList.append(i - 1)
            newN = newN // (i - 1)
            isFind = True
        if n % (i + 1) == 0:
            divList.append(i + 1)
            newN = newN // (i + 1)
            isFind = True

        if isFind == True:
            break

    if isFind == False:
        divList.append(n)
        newN = 1
    n = newN

    # print(divList)

# print(divList)

t = [([1], [1])]

for d in divList:
    newT = []
    for ab in t:
        a, b = ab[0], ab[1]
        a_add = a[:]
        a_add.append(d)
        b_add = b[:]
        b_add.append(d)

        newT.append((a, b_add))
        newT.append((a_add, b))
    t = newT

# print(t)

from functools import reduce

a1 = [(reduce(lambda a, b:a * b, ab[0]), reduce(lambda a, b:a * b, ab[1]))
      for ab in t]
# print(a1)


a2 = set([(len(str(ab[0])), len(str(ab[1]))) for ab in a1])

# print(a2)

a3 = [max(ab[0], ab[1]) for ab in a2]

# print(a3)

print(min(a3))


### FIXED CODE ###

N = int(input())


def countDigits(n):
    return len(str(n))


ans = countDigits(N)
A = 1
while A * A <= N:
    if(N % A != 0):
        A += 1
        continue
    B = N // A

    cur = max(countDigits(A), countDigits(B))
    if (ans > cur):
        ans = cur
    A += 1
print(ans)
### BUGGY CODE ###

def examD():
    N = I()
    a = LI();  b = LI()
    cura = [0]*N; curb = [0]*N
    ansC = [0]*29
    for i in range(29):
        T = (2 ** i)
        for j in range(N):
            curb[j] = b[j]%(2**(i+1))
        curb.sort()
        for j in range(N):
            cura[j] = a[j]%(2**(i+1))
            loc1 = T - cura[j]
            loc3 = 2 * T - cura[j]
            loc2 = 3 * T - cura[j]
            cur = (bisect.bisect_left(curb, loc1)-bisect.bisect_left(curb, loc2)\
                + bisect.bisect_left(curb, loc3))+N
            ansC[i] = (ansC[i]+cur)%2
#    print(ansC)
    ans = 0
    for i in range(29):
        ans += ansC[i]*(2**i)
    print(ans)



import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD()


### FIXED CODE ###

def examD():
    N = I()
    a = LI();  b = LI()
    cura = [0]*N; curb=[0]*N
    ans = 0
    for i in range(28,-1,-1):
        T = (2 ** i)
        for j in range(N):
            cura[j] = a[j]%(2**(i+1))
            curb[j] = b[j]%(2**(i+1))
        curb.sort()
        cura.sort(reverse=1)
        f, l1, r1, l2 = 0, 0, 0, 0
        for x in cura:
            while l1 < N and x + curb[l1] < T:
                l1 += 1
            while r1 < N and x + curb[r1] < 2 * T:
                r1 += 1
            while l2 < N and x + curb[l2] < 3 * T:
                l2 += 1
            f += N - l2 + r1 - l1
        ans += T * (f & 1)
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD()
### BUGGY CODE ###

import math
from functools import reduce
 
k = int(input())
ans = 0
 
def gcd(numbers):
    return reduce(math.gcd, numbers)
 
for i in range(k):
  for j in range(k):
    for l in range(k):
      ans += gcd([i+1, j+1, l+1])
      
print(ans)

### FIXED CODE ###

from math import gcd
k = int(input()) + 1
ans = 0
for i in range(1,k):
  for j in range(1,k):
    for l in range(1,k):
      ans += gcd(gcd(i, j),l)
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n = int(input())
a = [int(i) for i in input().split()]
result = []
[print(a.count(i+1)) for i in range(n)]


### FIXED CODE ###

import sys
import collections
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)
for i in range(n):
    print(c[i+1])
### BUGGY CODE ###

n = int(input())
ls = []
for i in range(n):
  ls.append(int(input()) - 1)
count = 0
if (1 not in ls):
  count = -1
else:
  used = []
  x = 0
  count = 0
  while (x != 1):
    used.append(x)
    x = ls[x]
    count += 1
    if (x in used):
      count = -1
      break
print(count)


### FIXED CODE ###

n = int(input())
ls = []
for i in range(n):
  ls.append([int(input())-1,False])
count = 0
x = 0
while (x != 1):
  if ls[x][1]:
    count = -1
    break
  else:
    count += 1
    ls[x][1] = True
    x = ls[x][0]
print(count)
### BUGGY CODE ###

import numpy as np

S = input()
N = int(S)

A = np.zeros([N])
A_temp = np.zeros([N])

for i in range(0, N, 1):
    A[i] = int(input())

max = 0

index_max = np.argmax(A)

for i in range(0, N, 1):
    A_temp = np.copy(A)
    if index_max != i:
        print(int(A_temp[index_max]))
    else:
        A_temp[i] = 0
        print(int(np.amax(A_temp)))


### FIXED CODE ###

import numpy as np

S = input()
N = int(S)

A = np.zeros([N])
A_temp = np.zeros([N])

for i in range(0, N, 1):
    A[i] = int(input())

max = 0

index_max = np.argmax(A)
A_temp = np.copy(A)
A_temp[index_max] = 0
index_max_second = np.argmax(A_temp)

result = np.full(N, A[index_max])
result[index_max] = A[index_max_second]

for i in range(0, N, 1):
    print(int(result[i]))