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

import sys
input = sys.stdin.readline
from heapq import heappush, heappop
def min_cost_flow_dijkstra(E, s, t, f):
    INF = 1 << 100
    NN = 2 * N + 6
    LN = NN.bit_length()
    G = [[] for _ in range(NN)]
    for a, b, cap, c in E:
        G[a].append([b, cap, c, len(G[b])])
        G[b].append([a, 0, -c, len(G[a])-1])
    prevv = [-1] * NN
    preve = [-1] * NN
    res = 0
    while f > 0:
        h = [0] * NN
        dist = [INF] * NN
        dist[s] = 0
        Q = []
        heappush(Q, s)
        while len(Q):
            x = heappop(Q)
            d, v = -(x>>LN), x % (1<<LN)
            if dist[v] < d: continue
            for i, (w, _cap, c, r) in enumerate(G[v]):
                if _cap > 0 and dist[w] > dist[v] + c + h[v] - h[w]:
                    dist[w] = dist[v] + c + h[v] - h[w]
                    prevv[w] = v
                    preve[w] = i
                    heappush(Q, (-dist[w] << LN) + w)
        if dist[t] == INF:
            return -1
        for v in range(N):
            h[v] += dist[v]
        
        d = f
        v = t
        while v != s:
            d = min(d, G[prevv[v]][preve[v]][1])
            v = prevv[v]
        f -= d
        res += d * dist[t]
        v = t
        while v != s:
            G[prevv[v]][preve[v]][1] -= d
            G[v][G[prevv[v]][preve[v]][3]][1] += d
            v = prevv[v]
    return res

E = []
N = int(input())
su = 0
inf = 1 << 31
for i in range(N):
    x, y, cnt = map(int, input().split())
    E.append((2*N+4, i, cnt, 0))
    E.append((i, 2*N, cnt, x + y + inf))
    E.append((i, 2*N+1, cnt, x - y + inf))
    E.append((i, 2*N+2, cnt, - x + y + inf))
    E.append((i, 2*N+3, cnt, - x - y + inf))
    su += cnt

for i in range(N):
    x, y, cnt = map(int, input().split())
    E.append((i+N, 2*N+5, cnt, 0))
    E.append((2*N, i+N, cnt, - x - y + inf))
    E.append((2*N+1, i+N, cnt, - x + y + inf))
    E.append((2*N+2, i+N, cnt, x - y + inf))
    E.append((2*N+3, i+N, cnt, x + y + inf))

print(su * inf * 2 - min_cost_flow_dijkstra(E, 2*N+4, 2*N+5, su))

### FIXED CODE ###

from networkx import*
N = int(input())
G = MultiDiGraph()
for i in range(N):
    x, y, c = map(int, input().split())
    G.add_node(i, demand = -c)
    G.add_weighted_edges_from([(i, -1, x + y)], capacity = c)
    G.add_weighted_edges_from([(i, -2, x - y)], capacity = c)
    G.add_weighted_edges_from([(i, -3, -x + y)], capacity = c)
    G.add_weighted_edges_from([(i, -4, -x - y)], capacity = c)
for i in range(N):
    x, y, c = map(int, input().split())
    G.add_node(N + i, demand = c)
    G.add_weighted_edges_from([(-1, N + i, -x - y)], capacity = c)
    G.add_weighted_edges_from([(-2, N + i, -x + y)], capacity = c)
    G.add_weighted_edges_from([(-3, N + i, x - y)], capacity = c)
    G.add_weighted_edges_from([(-4, N + i, x + y)], capacity = c)

print(-min_cost_flow_cost(G))
### BUGGY CODE ###

s = input()
n = len(s)
mod = 2019
arr = {0:1}

num = 0
for i in reversed(range(n)):
    num = (num + int(s[i])*(10**(n-i-1)))%mod
    # print(num)
    if num in arr:
        arr[num]+=1
    else:
        arr[num]=1
# print(arr)
ans = 0
for i in arr.values():
    ans += i*(i-1)//2

print(ans)


### FIXED CODE ###

from collections import defaultdict

s = input()
n = len(s)
mod = 2019
DP = [0 for i in range(n+2)]
DP[n+1] = 0

for i in reversed(range(n)):
    DP[i] = (DP[i+1] + int(s[i])*(pow(10,n-i-1,mod)))%mod
DP.pop(-1)

arr = defaultdict(int)
for dp in DP:
    arr[dp]+=1

ans = 0
for i in arr.values():
    ans += i*(i-1)//2
print(ans)
### BUGGY CODE ###

from collections import deque

S = input()

if len(S) < 5:
    print(0)
    exit()

check_str = deque()
first = 0
end = 4
check_str.append([first, end])

ans = deque()
while len(check_str) > 0:
    now_first, now_end = check_str.popleft()
    now_str = S[now_first:now_end+1]
    if int(now_str) % 2019 == 0 and [now_first, now_end] not in ans:
        ans.append([now_first, now_end])
    
    if len(now_str) > 5:
        check_str.append([now_first+1, now_end])

    if now_end < len(S)-1:
        check_str.append([now_first, now_end+1])

print(len(ans))

### FIXED CODE ###

S = input()
S_reverse = S[::-1]

dp = [0] * 2019
now_mod = 0
digit = 1

for i_s in S_reverse:
    now_mod = (now_mod + int(i_s)*digit) % 2019
    digit = (digit*10) % 2019
    dp[now_mod] += 1

ans = sum(x*(x-1)//2 for x in dp)
ans += dp[0]

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

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

X1, Y1 = map(int, input().split())

if X1 >= Y1:
  X = X1
  Y = Y1
  pass
else:
  X = Y1
  Y = X1
if X > 2 * Y:
  print(0)
  exit()
else:
  pass

cnt1 = 0

while X < 2 * Y:
  X = X - 1
  Y = Y - 2
  cnt1 += 1

if X != 2 *Y:
  print(0)
  exit()
else:
  pass

cnt2 = Y
ans = combinations_count((cnt1 + cnt2), cnt2) % (10 ** 9 + 7)
print(ans)

### FIXED CODE ###

import math
def cmb(n, r, mod):
    r = min(r, n - r)
    x = 1
    y = 1
    for i in range(r):
        x = x * (n - i) % mod
        y = y * (i + 1) % mod
    y = pow(y, mod-2, mod)
    return x * y % mod
"""
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
"""
X1, Y1 = map(int, input().split())

if X1 >= Y1:
  X = X1
  Y = Y1
  pass
else:
  X = Y1
  Y = X1
if X > 2 * Y:
  print(0)
  exit()
else:
  pass

m = (2 * X - Y) // 3
n = (2 * Y - X) // 3 

if (2 * X - Y) % 3 != 0 or (2 * Y - X) % 3 != 0:
  print(0)
  exit()
else:
  ans = cmb(m + n, n, 10 ** 9 + 7)
print(ans)
### BUGGY CODE ###

def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())
def LN(n):return [N() for i in range(n)]
def LL(n):return [L() for i in range(n)]
import sys
sys.setrecursionlimit(10**6)
n=N()
p=L()
size=(n+1)**2+1
ans=[0]*size
for i in range(1,n+1):
    for j in range(1,n+1):
        k=i*(n+1)+j
        ans[k]=min(i-1,j-1,n-i,n-j)
c=[1]*size
di=[-1,1,n+1,-n-1]
def f(k):
    for i in di:
        if k+i>=size:
            continue
        if ans[k]+c[k]<ans[k+i]:
            ans[k+i]-=1
            q.append(k+i)
t=0
for i in p:
    y=i%n
    if y==0:
        y=n
    x=(i+n-1)//n
    k=x*(n+1)+y
    c[k]=0
    t+=ans[k]
    q=[k]
    while q:
        k=q.pop()
        f(k)
print(t)

### FIXED CODE ###

def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())
def LN(n):return [N() for i in range(n)]
def LL(n):return [L() for i in range(n)]
import sys
sys.setrecursionlimit(10**6)
n=N()
p=L()
size=(n+1)**2+1
ans=[0]*size
for i in range(1,n+1):
    for j in range(1,n+1):
        k=i*(n+1)+j
        ans[k]=min(i-1,j-1,n-i,n-j)
c=[1]*size
di=[-1,1,n+1,-n-1]
def f(k,i):
    if k+i>=size:
        return
    if ans[k]+c[k]<ans[k+i]:
        ans[k+i]-=1
        q.append(k+i)
t=0
for i in p:
    y=i%n
    if y==0:
        y=n
    x=(i+n-1)//n
    k=x*(n+1)+y
    c[k]=0
    t+=ans[k]
    q=[k]
    while q:
        k=q.pop()
        f(k,1)
        f(k,-1)
        f(k,n+1)
        f(k,-n-1)
print(t)
### BUGGY CODE ###

from collections import deque

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

kotae = deque([])
lst = []
d = deque(a)
shugo = []
pattern = 0
while True:
    for kazu in d:
        if kazu in kotae:
            ind = list(kotae).index(kazu)
            for _ in range(len(kotae) - ind):
                kotae.pop()
        else:
            kotae.append(kazu)
    kotae_lst = list(kotae)
    if kotae_lst in shugo:
        break
    else:
        shugo.append(kotae_lst)
        lst.append(kotae_lst)
        pattern += 1

doko = k % pattern
ans = lst[doko-1]
if ans != []:
    print(' '.join(map(str, ans)))

### FIXED CODE ###

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

dic = {}
for i in range(n):
    if a[i] in dic:
        dic[a[i]].append(i)
    else:
        dic[a[i]] = [i]

zero = [-1 for i in range(n)]
for key, value in dic.items():
    num = len(value)
    for i in range(num-1):
        zero[value[i]] = value[i+1] - value[i] + 1
    zero[value[-1]] = n - value[-1] + value[0] + 1

lst = [zero]
while lst[-1][0] <+ n*k - 1:
    before = lst[-1]
    after = []
    for i in range(n):
        after.append(before[i] + before[(before[i]+i)%n])
    lst.append(after)
lst.pop()

i = 0
while lst != []:
    lsti = lst.pop()
    while True:
        if i + lsti[i%n] <= n*k - 1:
            i = i + lsti[i%n]
        else:
            break

i = i % n
nokori = a[i:]
lst = []
dic = {}
ko = 0
for i in range(len(nokori)):
    if nokori[i] not in dic:
        lst.append(nokori[i])
        dic[nokori[i]] = ko
        ko += 1
    else:
        lst = lst[:dic[nokori[i]]]
        dic = {}
        for j in range(len(lst)):
            dic[lst[j]] = j
        ko = len(lst)
print(*lst)
### BUGGY CODE ###

import itertools

N = int(input())

ans = {}
for v in itertools.combinations_with_replacement(range(1,(N//6)+1), 3):
    x,y,z = v
    count = 0
    if x == y == z:
        fn = 6 * (x**2)
        count = 1
    else:
        fn = x**2 + y**2 + z**2 + x*y + y*z + z*x
        count = 3
    if fn in ans.keys():
        ans[fn] += count
    else:
        ans[fn] = count

for i in range(1,N+1):
    if i in ans.keys():
        print(ans[i])
    else:
        print(0)


### FIXED CODE ###

N = int(input())
ans = [0 for _ in range(1,10101)]

for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            n = x*x + y*y + z*z + x*y + y*z + z*x
            if n < N+1:
                ans[n-1] += 1

print(*ans[:N],sep='\n')
### BUGGY CODE ###

import sys
N,Q = map(int,sys.stdin.readline().split())
S = sys.stdin.readline()
f_string = "AC"
for i in range(Q):
    l,r = map(int,sys.stdin.readline().split())
    temp = S[l-1:r]
    print(temp.count(f_string))

### FIXED CODE ###

n,q = map(int,input().split())
s = input()
ls = [0]*(n+1)
for i in range(len(s)):
    if s[i:i+2]=="AC":
        ls[i+1] += ls[i]+1
    else:
        ls[i+1] = ls[i]
for j in range(q):
    l,r = map(int,input().split())
    print(ls[r-1]-ls[l-1])
### BUGGY CODE ###

N = int(input())
light_rule = {n:int(input())-1 for n in range(N)}

light = ["1"]+["0"]*(N-1)
target = ["0"]+["1"]+["0"]*(N-2)
searched = {"".join(light):1}

flag = 0
num = 0
bottun = 0
for _ in range(N):
    if light == target:
        flag = 1
        break
    num += 1
    # print(bottun, light_rule[bottun])
    light[bottun] = "0"
    light[light_rule[bottun]] = "1"
    bottun = light_rule[bottun]
    # print(light)
    if searched.get("".join(light)):
        break
    else:
        searched["".join(light)] = 1
    
if flag:
    print(num)
else:
    print(-1)

### FIXED CODE ###

N = int(input())
light_rule = {n:int(input())-1 for n in range(N)}

light = ["1"]+["0"]*(N-1)

flag = 0
num = 0
bottun = 0
for _ in range(N):
    if light[1] == "1":
        flag = 1
        break
    num += 1
    # print(bottun, light_rule[bottun])
    light[bottun] = "0"
    light[light_rule[bottun]] = "1"
    bottun = light_rule[bottun]
    # print(light)
    
if flag:
    print(num)
else:
    print(-1)
### BUGGY CODE ###

def main():
    
    n,k=map(int,input().split())
    h=list(map(int,input().split()))

    dp=[9999999999]*n
    dp[0]=0
    dp[1]=abs(h[1]-h[0])

    for i in range(2,n):
        for j in range(1,k+1):
            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))

    print(dp[n-1])


if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    
    n,k=map(int,input().split())
    h=list(map(int,input().split()))
 
    # dp=[9999999999]*n
    # dp[0]=0
    # dp[1]=abs(h[1]-h[0])
 
    # for i in range(2,n):
    #     for j in range(1,k+1):
    #         if i-j>=0:
    #             dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
    #         else:
    #             break
 
    # print(dp[n-1])
 
 
    #part2
 
    dp=[9999999999]*n
    dp[0]=0
 
    for i in range(n):
        for j in range(1,k+1):
            if i+j<n:
                dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]))
            else:
                break
 
    print(dp[n-1])
 
 
 
 
if __name__ == "__main__":
    main()
### BUGGY CODE ###

N=int(input())
H=list(map(int, input().split(" ")))
ans=0
for i in range(N-1):
    j=i
    cnt=0
    while H[j]>=H[j+1]:
        j+=1
        cnt+=1
        if ans<cnt:
            ans=cnt
        if j+1==N:
            break
print(ans)


### FIXED CODE ###

N=int(input())
H=list(map(int, input().split(" ")))
ans=0
buf=[0 for _ in range(N-1)]
for i in range(N-1):
    if H[i]>=H[i+1]:
        buf[i]=1
cnt=0
for i in range(N-1):
    if buf[i]==1:
        cnt+=1
    else:
        cnt=0
    if cnt>ans:
        ans=cnt
print(ans)
### BUGGY CODE ###

from collections import defaultdict
from scipy.sparse.csgraph import shortest_path
from scipy.sparse.csgraph import dijkstra
import numpy as np
N, X, Y = map(int, input().split())
edges = [[0 for _ in range(N)] for _ in range(N)]
for i in range(N-1):
    edges[i][i + 1] = 1
    edges[i + 1][i] = 1
X -= 1
Y -= 1
edges[X][Y] = 1
edges[Y][X] = 1
res = dijkstra(np.array(edges), directed=False)
ans = defaultdict(int)
for i in range(N-1):
    for j in range(i+1, N):
        ans[int(res[i][j])] += 1
for k in range(1, N):
    print(ans[k])

### FIXED CODE ###

from collections import defaultdict
N, X, Y = map(int, input().split())
d = [[0 for _ in range(N)] for _ in range(N)]
for i in range(N-1):
    for j in range(i+1, N):
        d[i][j] = d[i][j-1] + 1
X -= 1
Y -= 1
for i in range(N-1):
    for j in range(i + 1, N):
        diff = abs(X - i) + abs(Y - j) + 1
        if diff < d[i][j]:
            d[i][j] = diff
#print(d)
ans = defaultdict(int)
for i in range(N-1):
    for j in range(i + 1, N):
        ans[d[i][j]] += 1
for k in range(1, N):
    print(ans[k])
### BUGGY CODE ###

import math
import copy
import collections

def comb(n, r):
    if n < r:
        return 0
    return math.factorial(n) // (math.factorial(r) * (math.factorial(n - r)))

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

counter = collections.Counter(A)
dic = {c: comb(counter[c], 2) for c in counter.keys()}

for i in range(N):
    i_comb = comb(counter[A[i]]-1, 2)
    new_dict = copy.deepcopy(dic)
    new_dict[A[i]] = i_comb
    print(sum(new_dict.values()))


### FIXED CODE ###

import math
import collections

def comb(n, r):
    if n < r:
        return 0
    return math.factorial(n) // (math.factorial(r) * (math.factorial(n - r)))

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

counter = collections.Counter(A)
dic = {c: comb(counter[c], 2) for c in counter.keys()}
sum_dic = sum(dic.values())

for i in A:
    print(sum_dic - (counter[i] - 1))
### BUGGY CODE ###

N,Q = list(map(int, input().split()))
S=list(str(input()))
ACs=[]
for i in range(len(S)-1):
    if S[i]=='A' and S[i+1]=='C':
        ACs.append(i)
ACs=set(ACs)
for q in range(Q):
    l,r = list(map(int, input().split()))
    lr=set(range(l-1,r-1))
    print(len(lr&ACs))

### FIXED CODE ###

N, Q = list(map(int, input().split()))
S = list(str(input()))
questions = [tuple(map(int, input().split())) for _ in range(Q)]
ACs = [0] * N

for i in range(len(S)-1):
    if S[i] == 'A' and S[i + 1] == 'C':
        ACs[i + 1] = ACs[i] + 1
    else:
        ACs[i + 1] = ACs[i]

for q in questions:
    print(ACs[q[1]-1] - ACs[q[0]-1])
### BUGGY CODE ###

N, Q = map(int,input().split())
S = str(input())
for i in range(Q):
    l, r = map(int,input().split())
    p = l-1
    S_tmp = S[p:r]
    print(S_tmp.count("AC"))

### FIXED CODE ###

N, Q = map(int,input().split())
S = str(input())
count = 0
li = [0]
for i in range(N-1):
    if S[i:i+2] == "AC":
        count += 1
    li.append(count)
for i in range(Q):
    l,r = map(int,input().split())
    print(li[r-1]-li[l-1])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(4100000)

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

to = [[] for i in range(N)]
block = [[] for i in range(N)]
sets = []

is_visited = [False] * N
graph_g = [None] * N
graph_cnt = -1

def dfs(s, g):
    global graph_cnt
    if is_visited[s]:
        return graph_g[s]

    is_visited[s] = True
    if g == None:
        graph_cnt += 1
        graph_g[s] = graph_cnt
    else:
        graph_g[s] = g

    for edge in to[s]:
        dfs(edge, graph_cnt)


for i in range(M):
    A, B = map(int, input().split())
    to[A-1].append(B-1)
    to[B-1].append(A-1)

for i in range(K):
    C, D = map(int, input().split())
    block[C-1].append(D-1)
    block[D-1].append(C-1)

for i in range(N):
    if is_visited[i]:
        continue
    dfs(i, None)

group_to_idx = [set() for i in range(graph_cnt+1)]
if len(group_to_idx) != 0:
    for i in range(N):
        group_to_idx[graph_g[i]].add(i)

ret = []
for i in range(N):
    cand = len(group_to_idx[graph_g[i]])
    fri = len(to[i])
    tmp_block = len(group_to_idx[graph_g[i]] & set(block[i]))

    tmp_ret = cand - fri - tmp_block - 1
    ret.append(tmp_ret)

print(*ret)

### FIXED CODE ###

import sys
sys.setrecursionlimit(4100000)

from collections import Counter

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

to = [[] for i in range(N)]
block = [[] for i in range(N)]
sets = []

is_visited = [False] * N
graph_g = [None] * N
graph_cnt = -1

def dfs(s, g):
    global graph_cnt
    if is_visited[s]:
        return 0

    is_visited[s] = True
    if g == None:
        graph_cnt += 1
        graph_g[s] = graph_cnt
    else:
        graph_g[s] = g

    for edge in to[s]:
        if graph_g[edge] == None:
            dfs(edge, graph_cnt)


for i in range(M):
    A, B = map(int, input().split())
    to[A-1].append(B-1)
    to[B-1].append(A-1)

for i in range(N):
    if is_visited[i]:
        continue
    dfs(i, None)

for i in range(K):
    C, D = map(int, input().split())
    if graph_g[C-1] == graph_g[D-1]:
        block[C-1].append(D-1)
        block[D-1].append(C-1)

ct = Counter(graph_g)

ret = []
for i in range(N):
    cand = ct[graph_g[i]]
    fri = len(to[i])
    tmp_block = len(block[i])

    tmp_ret = cand - fri - tmp_block - 1
    ret.append(tmp_ret)

print(*ret)
### BUGGY CODE ###

S=list(input())
s=len(S)
#while any((S[i]== '0' and S[i+1]=='1') or (S[i]== '1' and S[i+1]=='0')for i in range(len(S)-1)

while any((S[i]== '0' and S[i+1]=='1') or (S[i]== '1' and S[i+1]=='0')for i in range(len(S)-1)):
    for j in range(len(S)-1):
        if j+1<len(S) and ((S[j]== '0' and S[j+1]=='1') or (S[j]== '1' and S[j+1]=='0')):
            S.pop(j)
            S.pop(j)

print(s-len(S))

### FIXED CODE ###

S=input()
print(min(S.count('0'),S.count('1'))*2)
### BUGGY CODE ###

class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N
        self.count = 0
        self._size = [1]*N
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_sama(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb:
            return
        if self.rank[ra] < self.rank[rb]:
            self.parent[ra] = rb
            self._size[rb] += self._size[ra]
        else:
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]:
                self.rank[ra] += 1
            self._size[ra] += self._size[rb]
        self.count += 1
    def print_info(self):
        print("parent", self.parent)
        print("rank", self.rank)
        print("count", self.count)
        print("size", self._size)
    def size(self,a):
        return self._size[self.root(a)]

import sys
input = sys.stdin.readline
ans = 0
N,M = map(int,input().split())
UF = UnionFind(N)
for i in range(M):
    A,B = map(int,input().split())
    A -= 1
    B -= 1
    UF.unite(A,B)

for i in range(N):
    for j in range(i+1,N):
        if not UF.is_sama(i,j):
            ans += 1
            UF.unite(i,j)
print(ans)


### FIXED CODE ###

import sys
from collections import deque
input = sys.stdin.readline

N,M = map(int,input().split())
table = [[] for i in range(N)]
Q = deque()
visited = [0]*N
ans = 0
for i in range(M):
    A,B = map(int,input().split())
    A -= 1
    B -= 1
    table[A].append(B)
    table[B].append(A)

for x in range(N):
    if visited[x] == 0:
        ans += 1
        Q.append(x)
        while Q:
            x = Q.popleft()
            for y in table[x]:
                if visited[y]==0:
                    Q.append(y)
                    visited[y] = 1

print(ans-1)
### BUGGY CODE ###

import sys
import io, os
input = sys.stdin.buffer.readline
#input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

import math
N = 10**6+50

def main():

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

    spf = [-1]*(N+1)
    for i in range(N+1):
        spf[i] = i
    for i in range(2, int(math.sqrt(N))+1):
        if spf[i] == i:
            for j in range(i*2, N+1, i):
                if spf[j] == j:
                    spf[j] = i

    S = set()
    flag = False
    for i, a in enumerate(A):
        s = set()
        while a != 1:
            p = spf[a]
            if p in S:
                #print('setwise coprime')
                #exit()
                flag = True
            s.add(p)
            a //= p
        S = S | s
        if i == 0:
            T = s
        else:
            T = T & s

    #print(S)
    #print(T)
    if len(T) != 0:
        print('not coprime')
    elif flag:
        print('setwise coprime')
    else:
        print('pairwise coprime')

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import io, os
input = sys.stdin.buffer.readline
#input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

import math
N = 10**6+50

def main():

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

    spf = [-1]*(N+1)
    for i in range(N+1):
        spf[i] = i
    for i in range(2, int(math.sqrt(N))+1):
        if spf[i] == i:
            for j in range(i*2, N+1, i):
                if spf[j] == j:
                    spf[j] = i

    S = [0]*N
    for a in A:
        s = set()
        while a != 1:
            p = spf[a]
            if p not in s:
                S[p] += 1
            s.add(p)
            a //= p
        #print(S[0:10])


    #print(S[0:10])
    flag = False
    for i in range(len(S)):
        if S[i] == n:
            print('not coprime')
            exit()
        elif S[i] >= 2:
            flag = True
        else:
            pass
    if flag:
        print('setwise coprime')
    else:
        print('pairwise coprime')

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

n = int(input())
a = [int(input()) for i in range(n)]
a_first = sorted(a)[-1]
a_second = sorted(a)[-2]
for i in range(n):
    if i != a.index(a_first):
        print(a_first)
    else:
        print(a_second)

### FIXED CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
a_first = sorted(a)[-1]
a_second = sorted(a)[-2]
for i in a:
    print(a_second if i == a_first else a_first)