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

#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
INF = 10**10
 
class ExtendedBellmanFord:
    def __init__(self, edge):
        self.f_edge = edge
        self.b_edge = [[] for _ in range(len(edge))]
        for src, es in enumerate(edge):
            for dst, cost in es:
                self.b_edge[dst].append((src, -cost))

    def bellman_ford(self, mask, start):
        dist = [INF] * n
        dist[start] = 0
        for _ in range(n):
            update = False
            for i, es in enumerate(self.f_edge):
                if not mask[i]:
                    continue
                for to, cost in es:
                    if not mask[to]:
                        continue
                    if dist[i] != INF and dist[i] + cost < dist[to]:
                        dist[to] = dist[i] + cost
                        update = True
            if not update:
                return dist
        else:
            # Minus loops detected
            return -INF

    def calc(self, start, end):
        visited = [False] * n
        visited[start] = True
        st = [start]
        while st:
            node = st.pop()
            for to, _ in self.f_edge[node]:
                if not visited[to]:
                    visited[to] = True
                    st.append(to)
        rvisited = [False] * n
        rvisited[end] = True
        st = [end]
        while st:
            node = st.pop()
            for to, _ in self.b_edge[node]:
                if not rvisited[to]:
                    rvisited[to] = True
                    st.append(to)
        mask = [forward and backward for forward, backward in zip(visited, rvisited)]
        dist = self.bellman_ford(mask, start)
        if dist == -INF:
            return -INF
        else:
            return dist[end]

if __name__ == "__main__":
    n, m, p = [int(item) for item in input().split()]
    edge = [[] for _ in range(n)]
    for i in range(m):
        a, b, c = [int(item) for item in input().split()]
        a -= 1; b -= 1; c -= p
        c *= -1
        edge[a].append((b, c))
    
    EBF = ExtendedBellmanFord(edge)
    ret = EBF.calc(0, n-1)
    if ret == -INF:
        print(-1)
    else:
        print(max(0, -ret))

### FIXED CODE ###

INF = 10**18
n, m, p = [int(item) for item in input().split()]
edge = [[] for _ in range(n)]
for i in range(m):
    a, b, c = [int(item) for item in input().split()]
    a -= 1; b -= 1; c -= p
    c *= -1
    edge[a].append((b, c))
 
dist = [INF] * n
dist[0] = 0
update = 1
terminal_update = 0
for _ in range(n * 2):
    update = 0
    for v, e in enumerate(edge):
        for t, cost in e:
            if dist[v] != INF and dist[v] + cost < dist[t]:
                dist[t] = dist[v] + cost
                update = 1
                if t == n-1:
                    terminal_update += 1
    if not update:
        print(max(0, -dist[n-1]))
        exit()
else:
    if terminal_update > 1:
        print(-1)
    else:
        print(max(0, -dist[n-1]))
### BUGGY CODE ###

n,m = map(int,input().split())
li1 = []
for i in range(m):
    a,b = map(int,input().split())
    li2 = []
    for j in range(a,b+1):
        li2.append(j)
    li1.append(set(li2))
for i in range(m):
    li1[0] = li1[0] & li1[i]
print(len(li1[0]))

### FIXED CODE ###

n,m = map(int,input().split())
li,lia = [],[]
for i in range(m):
    a,b = map(int,input().split())
    li.append(a)
    lia.append(b)
if min(lia)-max(li)+1 <= 0:
    print(0)
else:
    print(min(lia)-max(li)+1)
### BUGGY CODE ###

while True:
  print()

### FIXED CODE ###

ν=int(input())
τ=list(map(int,input().split()))
α=list(map(int,input().split()))

τ.append(0)
α.append(0)
ρ=1
μ=10**9+7

for ι in range(ν):
  ε=10**10
  if τ[ι]>τ[ι-1]:
    ε=min(1,ε)
    if α[ι]<τ[ι]:
      ε=0
  if α[ι]>α[ι+1]:
    ε=min(1,ε)
    if α[ι]>τ[ι]:
      ε=0
  if τ[ι]<τ[ι-1] or α[ι]<α[ι+1]:
    ε=0
  ε=min(ε,α[ι],τ[ι])
  ρ=(ρ*ε)%μ
print(ρ)
### BUGGY CODE ###

n = int(input())
s = [input() for i in range(n)]
dic ={}
for key in s:
    if key not in dic:
        dic[key] = 1
    if key in dic:
        dic[key] += 1
res = sorted(list(filter(lambda key:dic[key]==max(dic.values()),list(dic))))
for key in res:
    print(key)

### FIXED CODE ###

n = int(input())
dic ={}
for i in range(n):
    key = input()
    if key not in dic:
        dic[key] = 1
    if key in dic:
        dic[key] += 1
max_v = max(dic.values())
res = sorted(list(filter(lambda key:dic[key]==max_v,list(dic))))
for key in res:
    print(key)
### BUGGY CODE ###

n,k = map(int, input().split())
lst = list(map(int, input().split()))
ans = []

for i in range(n-k+1):
    ans.append(sum(lst[i:i+k]))

print((max(ans)+k)/2)


### FIXED CODE ###

from itertools import accumulate


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

# 累積和
B = [0] + A
B = list(accumulate(B))

ans = []
for i in range(N-K+1):
    ans.append(B[i+K]-B[i])

print((max(ans)+K)/2)
### BUGGY CODE ###

from collections import deque

arr = []

for i in range(int(input())):
  command_line = input().split(" ")
  command = command_line[0]
  arg = ""
  if len(command_line) > 1: arg = command_line[1]

  if command == "insert":
    arr.insert(0, arg)
  if command == "delete":
    if arg in arr: arr.remove(arg)
  if command == "deleteFirst":
    arr.pop(0)
  if command == "deleteLast":
    arr.pop()

print(" ".join(arr))

### FIXED CODE ###

from collections import deque

q = deque()

for i in range(int(input())):
  command_line = input().split(" ")
  command = command_line[0]
  arg = ""
  if len(command_line) > 1: arg = command_line[1]

  if command == "insert":
    q.appendleft(arg)
  elif command == "delete":
    try:
      q.remove(arg)
    except ValueError:
      pass
  elif command == "deleteFirst":
    q.popleft()
  else:
    q.pop()

print(" ".join(q))
### BUGGY CODE ###

import numpy as np
n, q = map(int, input().split())
s = input()
L = np.array([0]*n)
for i in range(n-1):
    if(s[i:i+2] == 'AC'):
        L[i] = 1
for i in range(q):
    l, r = map(int, input().split())
    print(np.sum(L[l-1:r-1]))

### FIXED CODE ###

from itertools import accumulate
n, q = map(int, input().split())
s = input()
L = [0]*n
for i in range(1, n):
    if(s[i-1:i+1] == 'AC'):
        L[i] = 1
c = list(accumulate(L))
for i in range(q):
    l, r = map(int, input().split())
    print(c[r-1]-c[l-1])
### BUGGY CODE ###

import bisect
import sys
from itertools import accumulate
input = sys.stdin.readline
def hsnum(ls,x,n):
    num = 0
    for i in range(n):
        y = x-ls[i]
        num += n-bisect.bisect_left(ls,y)
    return num
n,m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
suma = [0]+list(accumulate(a))
lx = 0
rx = 10**10+2
error = 0
while lx < rx:
    mx = (lx+rx)//2
    if hsnum(a,mx,n) < m:
        rx = mx
    elif hsnum(a,mx,n) > m:
        if hsnum(a,mx+1,n) < m:
            error = hsnum(a,mx,n)-m
            lx = mx
            break
        lx = mx + 1
    else:
        lx = mx
        break
ans = 0
for i in range(n):
    rema = lx - a[i]
    j = bisect.bisect_left(a,rema)
    ans += (n-j)*a[i]+suma[n]-suma[j]
print(ans-error*lx)

### FIXED CODE ###

def main():
  import bisect
  import sys
  from itertools import accumulate
  input = sys.stdin.readline
  def hsnum(x):
    num = 0
    for i in a:
      y = x-i
      num += n-bisect.bisect_left(a,y)
    return num
  n,m = map(int, input().split())
  a = list(map(int, input().split()))
  a.sort()
  suma = [0]+list(accumulate(a))
  lx = 0
  rx = 2*10**5+2
  error = 0
  while lx+1 < rx:
    mx = (lx+rx)//2
    if hsnum(mx) < m:
      rx = mx
    elif hsnum(mx) > m:
      lx = mx + 1
    else:
      lx = mx
      break
  if hsnum(lx)<m:
    lx -= 1
  error = hsnum(lx)-m
  ans = 0
  for i in a:
    rema = lx - i
    j = bisect.bisect_left(a,rema)
    ans += (n-j)*i-suma[j]
  ans += suma[n]*n
  print(ans-error*lx)
if __name__ == "__main__":
    main()
### BUGGY CODE ###

N = int(input())
HP = [tuple(map(int,input().split())) for _ in range(N)]
HP.sort(key=lambda x: sum(x))

INF = float('inf')
dp = [[INF]*(N+1) for _ in range(N+1)]
dp[0][0] = 0
maxj = 0
for i,(h,p) in enumerate(HP):
	for j in range(maxj,-1,-1):
		dp[i+1][j] = min(dp[i+1][j], dp[i][j])
		if dp[i][j] <= h:
			dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j] + p)
			if j == maxj:
				maxj += 1
print(maxj)

### FIXED CODE ###

N = int(input())
HP = [tuple(map(int,input().split())) for _ in range(N)]
HP.sort(key=lambda x: sum(x))

INF = float('inf')
dp = [0]
maxj = 0
for i,(h,p) in enumerate(HP):
	dp2 = [INF] * (maxj + 2)
	for j in range(maxj,-1,-1):
		dp2[j] = min(dp2[j], dp[j])
		if dp[j] <= h:
			dp2[j+1] = min(dp2[j+1], dp[j] + p)
			if j == maxj:
				maxj += 1
	dp = dp2
print(maxj)
### BUGGY CODE ###

n=int(input())
s=[""]*n
ans=[""]

for i in range(n):
  s[i]=input()
  
  
ind=list(set(s))
num=s.count(ind[0])

for i in range(len(ind)):
  if (s.count(ind[i])>num):
    ans=[ind[i]]
    num=s.count(ind[i])
  elif (s.count(ind[i])==num and ans!=[""]):
    ans.append(ind[i])
  elif (s.count(ind[i])==num and ans==[""]):
    ans=[ind[i]]
ans=sorted(ans)
for i in range(len(ans)):
  print(ans[i])

### FIXED CODE ###

n=int(input())
s=[""]*n
dic={}
for i in range(n):
  a=input()
  if (a in dic):
    dic[a]+=1
  else:
    dic[a]=1
#dic=sorted(dic.items(), key=lambda x:x[1], reverse=True)
v_max=max(dic.values())
keys=[k for k,v in dic.items() if v==v_max ]
keys=sorted(keys)
for i in range(len(keys)):
  print(keys[i])
### BUGGY CODE ###



n = int(input())
_MAX = 200

gcd_result = [ [ [ 0 for _ in range(_MAX+1)] for _ in range(_MAX+1)] for _ in range(_MAX+1) ]

ans = 0


from functools import lru_cache
from math import gcd

@lru_cache(maxsize=1000)
def calc(lst):
    p = 0
    for v in lst:
        if p == 0:
            p = v
        else:
            p = gcd(p, v)

    return p


for i in range(1, n+1):
    for j in range(1, n+1):
        for k in range(1, n+1):
            ls = [i, j, k]
            ans += calc(tuple(set(ls)))

print(ans)

### FIXED CODE ###

from math import gcd

k = int(input())


ans = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            ans += gcd(gcd(a, b), c)

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

# coding: utf-8

def main():
	H, W = (int(x) for x in input().split())
	S = [[] for x in range(H)]

	for i in range(H):
		S[i] = [x for x in input()]

	# 隣接行列の作成
	inf = 1000000

	nodes = []
	for i in range(H):
		for j in range(W):
			if S[i][j] == ".":
				nodes.append([i, j])
	
	g = [[inf for j in range(len(nodes))] for i in range(len(nodes))]
	for i in range(len(nodes)):
		for j in range(len(nodes)):
			if   nodes[i][0] == nodes[j][0] and nodes[i][1] == nodes[j][1]:
				g[i][j] = 0
			elif abs(nodes[i][0]-nodes[j][0]) + abs(nodes[i][1]-nodes[j][1]) == 1:
				g[i][j] = 1

	max = 0
	for k in range(len(g[0])):
		for i in range(len(g[0])):
			for j in range(len(g[0])):
				g[i][j] = min(g[i][j], g[i][k] + g[k][j])

	for i in range(len(g[0])):
		for j in range(len(g[0])):
			if max < g[i][j]:
				max = g[i][j]
                
	print(max)

if __name__ == "__main__":
	main()

### FIXED CODE ###

# coding: utf-8

import queue

def main():
	H, W = (int(x) for x in input().split())
	S = [[] for x in range(H)]

	for i in range(H):
		S[i] = [x for x in input()]

	max_d = [[-1 for x in range(W)] for y in range(H)]
	for i in range(H):
		for j in range(W):
			if S[i][j] == "#":
				continue
			d = [[-1 for x in range(W)] for y in range(H)]
			q = queue.Queue()
			q.put([i, j])
			d[i][j] = 0
			while not q.empty():
				n = q.get()
				for y, x in [[-1, 0], [1, 0], [0, -1], [0, 1]]:
					if (n[0] == 0   and y == -1) or\
					   (n[0] == H-1 and y ==  1) or\
					   (n[1] == 0   and x == -1) or\
					   (n[1] == W-1 and x ==  1) or\
					   S[n[0]+y][n[1]+x] == "#"  or\
					   d[n[0]+y][n[1]+x] != -1:
						continue
					d[n[0]+y][n[1]+x] = d[n[0]][n[1]] + 1
					q.put([n[0]+y, n[1]+x])
			for y in range(H):
				for x in range(W):
					if max_d[i][j] < d[y][x]:
						max_d[i][j] = d[y][x]

	max = 0
	for i in range(H):
		for j in range(W):
			if max < max_d[i][j]:
				max = max_d[i][j]

	print(str(max))

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

Q = int(input())

import heapq
import sys
input = sys.stdin.readline

INF = 10**18
L = []
R = []
heapq.heappush(L,INF)
heapq.heappush(R,INF)
L_size = 0
R_size = 0
sum_b = 0
sum_L = 0
sum_R = 0

def f1(a,b):
  global sum_b,L_size,R_size,sum_L,sum_R
  sum_b += b
  L_max = -heapq.heappop(L)
  R_min = heapq.heappop(R)
  sum_L -= L_max
  sum_R -= R_min
  X = sorted([L_max,a,R_min])
  if L_size == R_size:
    heapq.heappush(L,-X[0])
    heapq.heappush(L,-X[1])
    heapq.heappush(R,X[2])
    L_size += 1
    sum_L += X[0] + X[1]
    sum_R += X[2]
  else:
    heapq.heappush(L,-X[0])
    heapq.heappush(R,X[1])
    heapq.heappush(R,X[2])
    R_size += 1
    sum_L += X[0]
    sum_R += X[1] + X[2]
  return

def f2():
  min_value = sum_b
  min_x = -heapq.nsmallest(1,L)[0]
  if L_size == R_size:
    min_value += sum_R - sum_L
  else:
    min_value += sum_R - sum_L + min_x
  print(min_x,min_value)

for _ in range(Q):
  row = [int(x) for x in input().split()]
  if row[0] == 1:
    f1(row[1],row[2])
  else:
    f2()


### FIXED CODE ###

Q = int(input())

import heapq
import sys
input = sys.stdin.readline

INF = 10**18
L = []
R = []
heapq.heappush(L,INF)
heapq.heappush(R,INF)
L_size = 0
R_size = 0
sum_b = 0
sum_L = 0
sum_R = 0

def f1(a,b):
  global sum_b,L_size,R_size,sum_L,sum_R
  sum_b += b
  L_max = -heapq.heappop(L)
  R_min = heapq.heappop(R)
  sum_L -= L_max
  sum_R -= R_min
  X = sorted([L_max,a,R_min])
  if L_size == R_size:
    heapq.heappush(L,-X[0])
    heapq.heappush(L,-X[1])
    heapq.heappush(R,X[2])
    L_size += 1
    sum_L += X[0] + X[1]
    sum_R += X[2]
  else:
    heapq.heappush(L,-X[0])
    heapq.heappush(R,X[1])
    heapq.heappush(R,X[2])
    R_size += 1
    sum_L += X[0]
    sum_R += X[1] + X[2]
  return

def f2():
  min_value = sum_b
  min_x = -L[0]
  if L_size == R_size:
    min_value += sum_R - sum_L
  else:
    min_value += sum_R - sum_L + min_x
  print(min_x,min_value)

QUERY = [[int(x) for x in input().split()] for _ in range(Q)]
for q in QUERY:
  if q[0]&1:
    f1(q[1],q[2])
  else:
    f2()
### BUGGY CODE ###

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

ans = 0
for i in range(n):
  for j in range(A[i] + 1, n - i):
    if A[i] + A[i + j] == j:
      ans += 1

print(ans)

### FIXED CODE ###

from collections import Counter

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

L = [i + a for i, a in enumerate(A)]
R = [i - a for i, a in enumerate(A)]

cL = Counter(L)
cR = Counter(R)

ans = 0
for i in cL.keys():
  ans += cL[i] * cR[i]

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

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

ans = abs(a[0]-sum(a[1:]))
x = 0
for i in range(n-1):
    x +=a[i]
    y = sum(a) - x
    ans = min(ans,abs(x-y))
    
print(ans)

### FIXED CODE ###

n = int(input())

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

ans = 10000000000000000000
x = 0
for i in range(n):
    x += a[i]
    if i  < n-1:
        ans = min(ans,abs(total-2*x))

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

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


##Miss 1
# from itertools import combinations

# comb = list(combinations([i for i in range(N)],2))

# cnt=0
# for i in comb:
#     if Agents[i[0]] + Agents[i[1]] == abs(i[0] - i[1]):
#         print(i[0],i[1])
#         cnt+=1

# print(cnt)

# Miss 2
# for i in range(0,N):
#     k=Agents[i]-(i+1)
#     if k<i:
#         k=i+1
#     for j in range(k,N):
#         if Agents[i]+Agents[j]==abs(i-j):
#             # print(i,j,Agents[i],Agents[j])
#             cnt+=1


L={}
for i in range(N):
    L['{}'.format(i+1)]=i+1 + Agents[i]
R={}
for j in range(N):
    R['{}'.format(j+1)]=j+1 - Agents[j]
cnt=0

for key,value in L.items():
    for key2,value2 in R.items():
        if int(key) < int(key2) and value == value2:
            cnt+=1


print(cnt)


### FIXED CODE ###

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


##Miss 1
# from itertools import combinations

# comb = list(combinations([i for i in range(N)],2))

# cnt=0
# for i in comb:
#     if Agents[i[0]] + Agents[i[1]] == abs(i[0] - i[1]):
#         print(i[0],i[1])
#         cnt+=1

# print(cnt)

# Miss 2
# for i in range(0,N):
#     k=Agents[i]-(i+1)
#     if k<i:
#         k=i+1
#     for j in range(k,N):
#         if Agents[i]+Agents[j]==abs(i-j):
#             # print(i,j,Agents[i],Agents[j])
#             cnt+=1


L={}
for i in range(N):
    s = i+1 + Agents[i] 
    if s in L:
        L[s]+=1
    else:
        L[s]=1

R={}
for j in range(N):
    s= j+1 - Agents[j]
    if s in R:
        R[s]+=1
    else:
        R[s]=1
cnt=0

for key,value in L.items():
    cnt += R.get(key,0) * value
# for key,value in L.items():
#     for key2,value2 in R.items():
#         if int(key) < int(key2) and value == value2:
#             cnt+=1


print(cnt)
### BUGGY CODE ###

n = input().split()
N = int(n[0])
K = int(n[1])

lista = []
listb = [1]
C = 1
A = list(map(int, input().split()))
                 
for i in range(200002):
    C = A[C-1]
    if C not in listb:
        listb.append(C)
    else:
        D = listb.index(C)
        listb.append(C)
        break

L = len(listb) -1

if K <= N:
    print(listb[K])
else:
    if L-D == 1 or L-D == 0:
        print(C)
    else:
        M = (K-D) % (L-D)
        print(listb[D+M])

### FIXED CODE ###

n = input().split()
N = int(n[0])
K = int(n[1])

listb = [1]
listc = [0]*N
C = 1
A = list(map(int, input().split()))
                 
for i in range(N):
    C = A[C-1]
    if listc[C-1] == 0:
        listb.append(C)
        listc[C-1] = 1
    else:
        D = listb.index(C)
        listb.append(C)
        break

L = len(listb) -1

if K <= N:
    print(listb[K])
else:
    if L-D == 1 or L-D == 0:
        print(C)
    else:
        M = (K-D) % (L-D)
        print(listb[(D+M)%L])
### BUGGY CODE ###

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

for i in range(2**n):
    if k ** (i - 1) - 1 < n <= k ** i - 1:
        print(i)
        exit()


### FIXED CODE ###

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

for i in range(2**31):
    if n <= k ** i - 1:
        print(i)
        exit()
### BUGGY CODE ###

from collections import deque
H, W = map(int, input().split())
grid = []
for _ in range(H):
    grid.append([s for s in input()])

def dfs(h, w):
    done = [[0 for _ in range(W)] for _ in range (H)]
    cnt = 0
    if grid[h][w] == "#":
        return cnt
    q = deque([(h, w, "No")])
    cnt += 1
    while q:
        h, w, direct = q.pop()
        for i, j in [(0, 1), (1, 0), (0, -1), (-1, 0)]:
            if 0 <= h + i < H and 0 <= w + j < W and grid[h + i][w + j] == "." and done[h + i][w + j] == 0:
                if direct == "No" or direct == (i, j):
                    cnt += 1
                    q.append((h + i, w + j, (i, j)))
                    done[h + i][w + j] = 1
    return cnt 
    
ans = 0
for h in range(H):
    for w in range(W):
        ans = max(ans, dfs(h, w))
print(ans)

### FIXED CODE ###

H, W = map(int, input().split())
grid = []
for _ in range(H):
    grid.append([s for s in input()])
    
left = [[0 for _ in range(W)] for _ in range(H)]
right = [[0 for _ in range(W)] for _ in range(H)]
up = [[0 for _ in range(W)] for _ in range(H)]
down = [[0 for _ in range(W)] for _ in range(H)]

for h in range(H):
    for w in range(W):
        if grid[h][w] == ".":
            if w == 0:
                left[h][w] = 1
            else:
                left[h][w] += left[h][w - 1] + 1

for h in range(H):
    for w in range(W)[::-1]:
        if grid[h][w] == ".":
            if w == W - 1:
                right[h][w] = 1
            else:
                right[h][w] += right[h][w + 1] + 1
            
for w in range(W):
    for h in range(H):
        if grid[h][w] == ".":
            if h == 0:
                up[h][w] = 1
            else:
                up[h][w] += up[h - 1][w] + 1
                
for w in range(W):
    for h in range(H)[::-1]:
        if grid[h][w] == ".":
            if h == H - 1:
                down[h][w] = 1
            else:
                down[h][w] += down[h + 1][w] + 1
                
ans = -10000
for h in range(H):
    for w in range(W):
        ans = max(ans, up[h][w] + down[h][w] + right[h][w] + left[h][w] - 3)
print(ans)
### BUGGY CODE ###

n, m = map(int, input().split())
s = []
e = []
for i in range(m):
    x, y = map(int, input().split())
    if x == 1:
        s.append(y)
    elif y == n:
        e.append(x)
s.sort()
e.sort()
flag = False
for i in s:
    for j in e:
        if i < j:
            break
        if i == j:
            flag = True
            break
if flag:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

### FIXED CODE ###

n, m = map(int, input().split())
s = [0 for i in range(n)]
e = [0 for i in range(n)]
for i in range(m):
    x, y = map(int, input().split())
    if x == 1:
        s[y] = 1
    elif y == n:
        e[x] = 1
flag = False
for i in range(n):
    if s[i] == 1 and e[i] == 1:
        flag = True
        break
if flag:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
### BUGGY CODE ###

#!/usr/bin/env python
N = int(input())
S = input()

min = N
tmp = 0
if S.count('#') == N or S.count('.') == N:
    print(0)
else:
    for n in range(N):
        tmp = S[:n].count('#') + S[n:].count('.')
        if tmp < min:
            min = tmp
    print(min)

### FIXED CODE ###

#!/usr/bin/env python
N = int(input())
S = input()

if S.count('#') == N or S.count('.') == N:
    print(0)
else:
    l = 0
    r = S.count('.')
    min = l+r
    for n in range(1,N+1):
        if S[n-1] == '#':
            l += 1
        else:
            r -= 1
        if l+r < min:
            min = l+r
    print(min)
### BUGGY CODE ###

from math import gcd


def create_sieve(n):
    sieve = [0] * (n + 1)

    for i in range(2, n + 1):
        if sieve[i] == 0:
            j = i ** 2
            while j <= n:
                sieve[j] = i
                j += i

    return sieve


def fast_factorization(n, sieve):
    from collections import Counter
    arr = Counter()
    while n > 1:
        p = sieve[n]
        if p == 0:
            arr[n] += 1
            break
        else:
            arr[p] += 1
            n //= p
    return arr


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

# setwise
tmp = 0
for a in A:
    tmp = gcd(tmp, a)
isSetwise = (tmp == 1)


# pairwise
M = 10 ** 6
sieve = create_sieve(M)
done = set()
isPairwise = True
for a in A:
    arr = fast_factorization(a, sieve)
    for p in arr.keys():
        if p in done:
            isPairwise = False
        else:
            done.add(p)

# check
if isPairwise:
    ans = 'pairwise coprime'
elif isSetwise:
    ans = 'setwise coprime'
else:
    ans = 'not coprime'
print(ans)


### FIXED CODE ###

from math import gcd


# def sieve(n):
#     is_prime = [1 for _ in range(n + 1)]
#     is_prime[0] = 0
#     is_prime[1] = 0

#     for i in range(2, n + 1):
#         if is_prime[i]:
#             j = i + i
#             while j <= n:
#                 is_prime[j] = 0
#                 j += i

#     return is_prime


def factorization(n):
    from collections import Counter
    arr = Counter()
    temp = n
    for i in range(2, int(-(-n**0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr[i] = cnt

    if temp != 1:
        arr[temp] = 1

    if len(arr.keys()) == 0 and n != 1:
        arr[n] = 1

    return arr


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

# setwise
tmp = 0
for a in A:
    tmp = gcd(tmp, a)
isSetwise = (tmp == 1)


# pairwise
M = 10 ** 6
sieve = [0] * (M + 1)
for a in A:
    if sieve[a] == 1:
        isPairwise = False
        break
    else:
        arr = factorization(a)
        for p in arr.keys():
            np = p
            while np <= M:
                sieve[np] = 1
                np += p
else:
    isPairwise = True

# check
if isPairwise:
    ans = 'pairwise coprime'
elif isSetwise:
    ans = 'setwise coprime'
else:
    ans = 'not coprime'
print(ans)