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

import sys
input = sys.stdin.readline

n = int(input())

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

c = [0] * (10**6+1)
for i in a:
    c[i] += 1

uni = []

for i in a:
    if c[i] == 1:
        uni.append(i)

b = [0 for _ in range(10**6+1)]

for i in a:
    for j in range(i*2, 10**6+1, i):
        b[j] = 1

cnt = 0
for i in uni:
    if b[i] == 0:
        cnt += 1

print(cnt)

### FIXED CODE ###

n = int(input())

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

c = [0] * (10**6+1)
for i in a:
    c[i] += 1

uni = []
a = list(set(a))

for i in a:
    if c[i] == 1:
        uni.append(i)

b = [0 for _ in range(10**6+1)]

for i in a:
    for j in range(i*2, 10**6+1, i):
        b[j] = 1

cnt = 0
for i in uni:
    if b[i] == 0:
        cnt += 1

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

S = [0 for i in range(300000)]
A = [-1, 1]
for i in range(1, int(300000 / 7) + 1):
    d = 7 * i
    for a in A:
        da = d + a
        if da < 300000 and S[da] == 0:
            S[da] = 1
            for j in range(2, int(300000 / 2)):
                if da * j >= 300000:break
                S[da * j] = -1

while 1:
    n = int(input())
    if n == 1:break
    res = [str(n) + ':']
    for i in range(2, n+1):
        if S[i] == 1 and n % i == 0:
            res.append(str(i))

    print(' '.join(res))

### FIXED CODE ###

S = [0 for i in range(300000)]
S2 = []
A = [-1, 1]
for i in range(1, int(300000 / 7) + 1):
    d = 7 * i
    for a in A:
        da = d + a
        if da < 300000 and S[da] == 0:
            S2.append(da)
            for j in range(2, int(300000 / 2)):
                if da * j >= 300000:break
                S[da * j] = -1
while 1:
    n = int(input())
    if n == 1:break
    print(str(n) + ':',' '.join([str(x) for x in S2 if n % x == 0 and x <= n]))
### BUGGY CODE ###

from collections import Counter

# ex. 1817181712114
S = input()

# 0桁目まで(=空文字列)のMODを0と考える
# 1桁目を含む数が2019の倍数の時に都合が良くなる
X = [0]

# 4,14,114,2114,12114,...と下からのmod2019を計算
for i in range(-1, -len(S) - 1, -1):
    temp = int(S[i:])
    X.append(temp % 2019)
# print(X)

C = Counter(X)
# print(C)

ans = 0
# v_C_2を計算
for v in C.values():
    ans += v * (v - 1) // 2

print(ans)


### FIXED CODE ###

from collections import Counter

# forを逆から回して下から素直にmodを取るとTLEだった
# 累積和的な計算で高速化、やりやすくするためにreverse
S = input()[::-1]
# ex. 1817181712114 → 4112171817181
# print(S)

# 0桁目までのMODを0とすることで、
# 1桁目を含む数が2019の倍数の時に都合が良くなる
X = [0]

# 4,14,114,2114,12114,...のmod2019を計算

for i, s in enumerate(S):
    X.append((X[-1] + int(s) * pow(10, i, 2019)) % 2019)
# print(X)


C = Counter(X)
# print(C)

ans = 0
# Xが同じになったところを2つ選べば題意を満たす
# v_C_2の計算
for v in C.values():
    ans += v * (v - 1) // 2

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

S = input()

s = list(S)

s.reverse()



lis = [0] * 13
lis[0] = 1

for i in range(len(S)):

    nlis = [0] * 13

    if s[i] == "?":

        for j in range(10):

            for k in range(13):

                nlis[ (k + (j * (10**i))) % 13] += lis[k]

    else:

        now = int(s[i])

        for k in range(13):

            nlis[ (k + (now * (10 ** i))) % 13 ] += lis[k]


    for j in range(len(nlis)):
      lis[j] = nlis[j]


print (lis[5] % (10**9 + 7))


### FIXED CODE ###


S = input()

s = list(S)

s.reverse()

#print (s)

lis = [0] * 13
lis[0] = 1
keta = 1

for i in range(len(S)):

    nlis = [0] * 13



    for j in range(10):

        for k in range(13):

            if s[i]== "?" or j == int(s[i]):
                nlis[ (k + (j * keta)) % 13] += lis[k]

    keta *= 10
    keta = keta % 13
    for j in range(13):
        lis[j] = nlis[j] % (10**9 + 7)

#print (lis)
print (lis[5] % (10**9 + 7))
### BUGGY CODE ###

s = input()

data = []
toInt = {'A':1, 'B':2, 'C':2}
i = 0
while i < len(s)-1:
    # BC=>0
    if s[i] == 'B' and s[i+1] == 'C':
        data.append(0)
        i += 1
    else:
        data.append(toInt[s[i]])
    i+=1

if i < len(s):
    data.append(toInt[s[i]])


def getScore(s):
    total = 0
    minus = 0
    start = 0
    while 0 in arr[start:]:
        total += arr.index(0, start)
        total -= minus
        minus += 1
        start = arr.index(0, start) + 1

    return total


# Calculate score
total = 0
start = 0 
while start < len(data):
    end = start
    while end < len(data) and not data[end] == 2:
        end += 1
    arr= data[start:end]
    total += getScore(arr)
    start = end + 1
    
print(total)

### FIXED CODE ###

s = input()
total = 0
i = 0
inRange = False
range_start = 0
range_minus = 0
range_cnt = 0

while i < len(s)-1:
    # BC=>0
    if s[i] == 'B' and s[i+1] == 'C':
        if inRange:
            total += (range_cnt - range_minus)
            range_cnt += 1
            range_minus += 1
        i += 1
    elif s[i] == 'A':
        inRange = True
        range_cnt += 1
    else:
        inRange = False
        range_start = 0
        range_minus = 0
        range_cnt = 0
    i+=1
    
print(total)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
 
MAXN = 1005
MAXV = MAXN*(MAXN-1)//2
 
to = [[] for _ in range(MAXV)]
id = [[[] for _ in range(MAXN)] for _ in range(MAXN)]
 
def toId(i, j):
    if i > j:
        i, j = j, i
    return id[i][j]
visited = [False] * MAXV
calculated = [False] * MAXV
dp = [1] * MAXV
 
def dfs(v):
    if visited[v]:
        if not calculated[v]:
            return -1
        return dp[v]
    visited[v] = True
    dp[v] = 1
 
    for u in to[v]:
        res = dfs(u)
        if res == -1: return -1
        dp[v] = max(dp[v], res+1)
    calculated[v] = True
    return dp[v]
 
def main():
    n = int(input())
    a = [[int(i) for i in readline().split()] for _ in range(n)]
    
    for i in range(n):
        for j in range(n-1):
            a[i][j] -= 1
    V = 0
    for i in range(n):
        for j in range(n):
            if i < j:
                id[i][j] = V
                V += 1
    
    for i in range(n):
        for j in range(n-1):
            a[i][j] = toId(i, a[i][j])
        for j in range(n-2):
            to[a[i][j+1]].append(a[i][j])
    
    ans = 0
    
    for i in range(V):
        res = dfs(i)
        if res == -1:
            print('-1')
            return
        ans = max(ans, res)
    print(ans)
    return
  
if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
 
MAXN = 1005
MAXV = MAXN*(MAXN-1)//2
 
to = [[] for _ in range(MAXV)]
id = [[[] for _ in range(MAXN)] for _ in range(MAXN)]
 
def toId(i, j):
    if i > j:
        i, j = j, i
    return id[i][j]
visited = [False] * MAXV
calculated = [False] * MAXV
dp = [1] * MAXV
 
def dfs(v):
    if visited[v]:
        if not calculated[v]:
            return -1
        return dp[v]
    visited[v] = True
    dp[v] = 1
 
    for u in to[v]:
        res = dfs(u)
        if res == -1: return -1
        dp[v] = max(dp[v], res+1)
    calculated[v] = True
    return dp[v]
 
def main():
    n = int(input())
    a = [[int(i) for i in readline().split()] for _ in range(n)]
    
    for i in range(n):
        for j in range(n-1):
            a[i][j] -= 1
    V = 0
    for i in range(n):
        for j in range(n):
            if i < j:
                id[i][j] = V
                V += 1
    
    for i in range(n):
        for j in range(n-1):
            a[i][j] = toId(i, a[i][j])
        for j in range(n-2):
            to[a[i][j+1]].append(a[i][j])
    
    ans = 0
    
    for i in range(V):
        res = dfs(i)
        if res == -1:
            print('-1')
            return
        ans = max(ans, res)
    print(ans)
    return
  
if __name__ == '__main__':
    main()
### BUGGY CODE ###

from sys import stdin, setrecursionlimit
from collections import Counter, deque, defaultdict
import heapq
from math import floor, ceil
from bisect import bisect_left
from itertools import combinations
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

dh = [0, 0, 1, -1]
dw = [1, -1, 0, 0]

def main():
    from builtins import int, map
    H, W = map(int, input().split())
    Ch, Cw = map(int, input().split())
    Dh, Dw = map(int, input().split())
    Ch, Cw, Dh, Dw = Ch - 1, Cw - 1, Dh - 1, Dw - 1
    S = [list(input()) for _ in range(H)]

    dist = defaultdict(lambda: float("inf"))
    dist[Ch, Cw] = 0
    queue = deque([(Ch, Cw)])

    while queue:
        (h, w) = queue.popleft()

        for i in range(4):
            dhi, dwi = dh[i], dw[i]
            nh, nw = h + dhi, w + dwi
            if 0 <= nh < H and 0 <= nw < W and S[nh][nw] == '.':
                if dist[h, w] < dist[nh, nw] :
                    dist[nh, nw] = dist[h, w]
                    queue.appendleft((nh, nw))
        
        # 5x5-grid
        for ddh in range(-2, 3):
            for ddw in range(-2, 3):
                if abs(ddh) + abs(ddw) <= 1:
                    continue
                nh, nw = h + ddh, w + ddw
                if 0 <= nh < H and 0 <= nw < W and S[nh][nw] == '.':
                    if dist[nh, nw] > dist[h, w] + 1:
                        dist[nh, nw] = dist[h, w] + 1
                        queue.append((nh, nw))

    if dist[Dh, Dw] == float("inf"):
        print(-1)
    else:
        print(dist[Dh, Dw])

if __name__ == '__main__':
    main()


### FIXED CODE ###

from collections import deque
INF = int(1e10)

def main():
    from builtins import int, map
    H, W = map(int, input().split())
    Ch, Cw = map(lambda x: int(x) - 1, input().split())
    Dh, Dw = map(lambda x: int(x) - 1, input().split())
    S = [input() for _ in range(H)]

    # dist = defaultdict(lambda: float("inf"))
    dist = [[float("inf")] * W for _ in range(H)]
    queue = deque([(Ch, Cw, 0)])

    while queue:
        (h, w, d) = queue.popleft()

        if dist[h][w] == float("inf") or dist[h][w] > d:
            dist[h][w] = d
            
            # 5x5-grid
            for ddh in range(-2, 3):
                for ddw in range(-2, 3):
                    nh, nw = h + ddh, w + ddw
                    if 0 <= nh < H and 0 <= nw < W and S[nh][nw] == '.':
                        # cost-0 move
                        if abs(ddh) + abs(ddw) <= 1:
                            queue.appendleft((nh, nw, d))
                        # cost-1 move
                        else:
                            queue.append((nh, nw, d + 1))

    if dist[Dh][Dw] == float("inf"):
        print(-1)
    else:
        print(dist[Dh][Dw])

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

import itertools
n = int(input())
a = list(map(int,input().split()))
suml = list(itertools.combinations(a,2))
d=[i+j for i,j in suml]
cnt=0
co=0
for i in range(n-1):
    for j in range(i+1,n):
        if j-i==d[co]:
            cnt+=1
        co+=1
print(cnt)

### FIXED CODE ###

from collections import Counter
n = int(input())
a = list(map(int,input().split()))
L = [0]*n
R = [0]*n
cnt=0
for i in range(n):
    L[i] = i+a[i]
    R[i] = i-a[i]
z1=Counter(L)
z2=Counter(R)
cnt=0
for k1,v1 in z1.items():
    v2 = z2[k1]
    cnt += v1*v2
print(cnt)
### BUGGY CODE ###

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

s = sum(a)
b = []
c = []
t = 0


for i in a:
    b.append(t)
    t += i
    c.append(s-t)
    
ans = 0
for i in range(n):
    for j in range(i, n):
        if b[i] + c[j] == s:
            ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = 0
l = {0:1}
s = 0

for i in a:
    s += i
    if s in l:
        ans += l[s]
        l[s] += 1
    else:
        l[s] = 1

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

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
# print([a-1 for a in A])
L = [-1 for i in range(N)]
visited = []
now = 0
loopstarts = None
looplength = None
for i in range(N):
    if now in visited:
        break
    else:
        L[now] = i
        visited.append(now)
        now = A[now]-1
# print(visited, L, now)
loopstarts = visited.index(now)
looplength = len(visited)-loopstarts
# print(loopstarts)
# print(looplength)
if K < loopstarts:
    print(visited[K]+1)
else:
    print(visited[loopstarts+(K-loopstarts)%looplength]+1)

### FIXED CODE ###

from time import time
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
L = [-1 for i in range(N)]

visited = []
now = 0
loopstarts = None
looplength = None
t0 = time()

for i in range(N):
    if L[now] != -1:
        break
    else:
        L[now] = i
        visited.append(now)
        now = A[now]-1

loopstarts = visited.index(now)
looplength = len(visited)-loopstarts

if K < loopstarts:
    print(visited[K]+1)
else:
    print(visited[loopstarts+(K-loopstarts)%looplength]+1)
# print(time()-t0)
### BUGGY CODE ###

a, b, n = map(int, input().split())
ans = -float('inf')
for i in range(n, 0, -1):
    f1 = (a*i)//b
    f2 = i//b
    tmp = f1-(a*f2)
    if ans < tmp:
        ans = tmp
print(ans)

### FIXED CODE ###

import math
a, b, n = map(int, input().split())
ans = -float('inf')
n = min(b-1, n)
f1 = math.floor(a*n/b)
f2 = math.floor(n/b)
ans = f1-(a*f2)
print(ans)
### BUGGY CODE ###

k,s=map(int,input().split())
ans=0
for i in range(k+1):
  for j in range(k+1):
    for l in range(k+1):
      if i+j+l==s:
        ans += 1
print(ans)

### FIXED CODE ###

k,s=map(int,input().split())
from math import factorial
def c(n,r):
  return factorial(n)//factorial(n-r)//factorial(r)
ans=0
for x in range(k+1):
  for y in range(k+1):
    if 0<=s-x-y<=k:
      ans += 1
print(ans)
### BUGGY CODE ###

N = int(input()) # 奇数
inputs = [int(i) for i in input().split()]

double_inputs = list(map(lambda x: x * 2, inputs))
for i in range(N):
    total = sum(inputs)
    for j in range((N - 1) // 2):
        total -= double_inputs[(i+1+2*j)%N]
    print(total)

### FIXED CODE ###

N = int(input()) # 奇数
inputs = [int(i) for i in input().split()]

double_inputs = list(map(lambda x: x * 2, inputs))
ans = [0 for _ in range(N)]
for i in range(N):
    if i == 0:
        ans[i] = sum(inputs) - sum(double_inputs[1::2])
    elif i == N - 1:
        ans[i] = double_inputs[-1] - ans[0]
    else:
        ans[i] = double_inputs[i-1] - ans[i-1]

print(' ' .join(map(str, ans)))
### BUGGY CODE ###

a,b,c,d = map(int, input().split())
cnt = 0

for i in range(a,b+1):
  if i % c == 0 or i % d == 0:
    continue
  cnt +=1

print(cnt)

### FIXED CODE ###

import fractions
a,b,c,d = map(int, input().split())
bcBaisu = b // c
bdBaisu = b // d
acBaisu = (a -1) // c
adBaisu = (a-1) // d
cdlcm =  c * d // fractions.gcd(c, d)
bcdLcm = b // cdlcm
acdLcm = (a-1) // cdlcm

karib = b - (bcBaisu + bdBaisu -bcdLcm)
karia = a - 1 - (acBaisu + adBaisu - acdLcm)

print(int(karib - karia))
### BUGGY CODE ###

s = input()

a = ''
for i in range(len(s)):
    if s[i]!='x':
        a+=s[i]

b = ''
for i in range(len(a)):
    b+=a[-1-i]

if a!=b:
    print(-1)
else:
    ss = ''
    for i in range(len(s)):
        ss += s[-1-i]
    i = 0
    ans = 0
    while s!=ss:
        if i>=len(s):
            ans += len(ss)-i
            break
        elif i>= len(ss):
            ans += len(s)-i
            break
        if s[i]!=ss[i]:
            if s[i]=='x':
                ss = ss[:i]+'x'+ss[i:]
            else:
                s = s[:i]+'x'+s[i:]
            ans += 1
        i+=1
    print(ans//2)



### FIXED CODE ###

s = input()

a = ''
for i in range(len(s)):
    if s[i]!='x':
        a+=s[i]

b = ''
for i in range(len(a)):
    b+=a[-1-i]

if a!=b:
    print(-1)
else:
    ss = ''
    for i in range(len(s)):
        ss += s[-1-i]
    i = 0
    j=0
    ans = 0
    while True:
        if i>=len(s):
            ans += len(ss)-j
            break
        elif j>=len(ss):
            ans += len(s)-i
            break
        if s[i]!=ss[j]:
            if s[i]=='x':
                i+=1
            else:
                j+=1
            ans += 1
        else:
            i+=1
            j+=1
    print(ans//2)
### BUGGY CODE ###

num = int(input())
words = []
answer = 0

for i in range(num):
  words.append(sorted(list(input())))
words.sort(key=lambda x:x[0])
for i in range(num):
  q = 0
  for j in range(num -i - 1):
    p = 0
    out = 0
    if q >0 and words[i][0] != words[j + 1 + i][0]:
      break
    if words[i] == words[j + 1 + i]:
      answer += 1
      q += 1
    
    
print(answer)


### FIXED CODE ###

import math
num = int(input())
words = {}

for i in range(num):
  a = str(sorted(list(input())))
  
  if a in words:
    words[a] += 1
  else:
  	words[a] = 1

points = list(words.values())
sum = 0
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
for i in range(len(points)):
  if points[i] > 1:
  	sum += combinations_count(points[i], 2)
print(sum)
### BUGGY CODE ###

def aoki_fun(x, k):
    return x-k if x-k >= 0 else k-x


N, K = map(int, input().split())
min_N = N
while(1):
    N = aoki_fun(N, K)
    if N < min_N:
        min_N = N

    else:
        break
print(min_N)


### FIXED CODE ###

N,K=map(int, input().split())
tmp=N%K
print(min(tmp,K-tmp))
### BUGGY CODE ###

from collections import Counter

N,M = map(int,input().split())
A = sorted(list(map(int,input().split())),reverse=True)
B = sorted(list(map(int,input().split())),reverse=True)
mod = pow(10,9)+7

n,m = 0,0
ans = 1

def istwo(L):
    if len(list(filter(lambda x:x>1,Counter(L).values())))>0:
        return True
    else:
        return False

if istwo(A) or istwo(B):
    print(0)
else:
    for i in range(1,(N*M)+1)[::-1]:
        if n<N and i<=A[n]:n+=1
        if m<M and i<=B[m]:m+=1
        if i in A and i in B:
            ans = ans%mod
        elif i in A:
            ans = (ans*(m))%mod
        elif i in B:
            ans = (ans*(n))%mod
        else:
            ans = (ans*(n*m-(N*M-i)))%mod
        #print(i,n,m,ans)
    print(ans)

### FIXED CODE ###

from collections import Counter

N,M = map(int,input().split())
A = sorted(list(map(int,input().split())),reverse=True)
B = sorted(list(map(int,input().split())),reverse=True)
mod = pow(10,9)+7

n,m = 0,0
ans = 1

def istwo(L):
    if len(list(filter(lambda x:x>1,Counter(L).values())))>0:
        return True
    else:
        return False

if istwo(A) or istwo(B):
    print(0)
else:
    for i in range(1,(N*M)+1)[::-1]:
        if n<N and i<=A[n]:n+=1
        if m<M and i<=B[m]:m+=1
        if n>0 and m>0 and i == A[n-1] and i == B[m-1]:
            ans = ans%mod
        elif n>0 and i == A[n-1]:
            ans = (ans*(m))%mod
        elif m>0 and i == B[m-1]:
            ans = (ans*(n))%mod
        else:
            ans = (ans*(n*m-(N*M-i)))%mod
        #print(i,n,A[n-1],m,B[m-1],ans)
    print(ans)
### BUGGY CODE ###


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():
    h,w=map(int,input().split())
    s=[input() for _ in range(h)]

    u=UnionFind(h*w)

    for i in range(h):
        for j in range(w):
            if j !=0:
                if s[i][j-1] != s[i][j]:
                    u.union(i*w+j-1,i*w+j)
            if i !=0:
                if s[i-1][j] != s[i][j]:
                    u.union((i-1)*w+j,i*w+j)
    res = 0
    gd=u.all_group_members()
    for ld in gd.values():
        black = 0
        white = 0
        for sd in ld:
            if s[sd//w][sd%w]=="#":
                black += 1
            else:
                white += 1
        res += black * white

    print(res)

main()

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)

h,w=map(int,input().split())
s=[input() for _ in range(h)]
flag = [[0]*w for _ in range(h)]

def dfs(th,tw):
    global flag,h,w,s
    flag[th][tw] = True
    tblack = 0
    twhite = 0
    if s[th][tw] == "#":
        tblack += 1
    else:
        twhite += 1 
    for x,y in ([0,1],[0,-1],[1,0],[-1,0]):
        nth = th + x
        ntw = tw + y
        if nth >= 0 and nth < h and ntw >= 0 and ntw < w:
            if not flag[nth][ntw] and s[th][tw] != s[nth][ntw]:
                ttb,ttw = dfs(nth,ntw)
                tblack += ttb
                twhite += ttw
    return [tblack,twhite]
                
def main():
    global flag,h,w,s
    res = 0
    for i in range(h):
        for j in range(w):
            if not flag[i][j]:
                black,white = dfs(i,j)
                res += black * white 

    return res
print(main())
### BUGGY CODE ###

import sys
mod=10**9+7 ; inf=float("inf")
from math import sqrt, ceil
from collections import deque, Counter, defaultdict #すべてのkeyが用意されてる defaultdict(int)で初期化
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP,Decimal  #変換後の末尾桁を0や0.01で指定
  #Decimal((str(0.5)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
from functools import lru_cache
from bisect import bisect_left as bileft, bisect_right as biright
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########

n=int(input())

A=list(map(int,input().split()))
from math import sqrt
def eratosu(n):
  if not isinstance(n,int):
    raise TypeError("nがint型になってねえぞ")
  if n<2:
    raise ValueError('nが2よりちっちぇえぞ')
  prime = []
  limit = sqrt(n)
  data = [i+1 for i in range(1, n)]  #2,3,4,...,n
  while True:
    p = data[0]
    if limit <= p:
        return prime + data
    prime.append(p)
    data = [e  for e in data if e % p != 0]
PRIME=eratosu(10**6)
@lru_cache(maxsize=10**10)
def bunkai(n):
    if n==1:return []
    ans=[]
    temp=n
    #そんな早くしなくてよかったり、何回もするわけじゃないなら、
    #for i in range(2,int(sqrt(n))+1): とかで
    primelist= PRIME
    for i in primelist:
        if i>sqrt(n):break
        if temp % i ==0:
            ji=0
            while temp%i==0:
                ji+=1
                temp//=i
            ans.append([i,ji])
    if ans==[]:return([[n,1]])  #素数のとき
    if temp!=1:
        ans.append([temp,1])  #4*5882353とか
    return ans

flag=1
seen=[0]*(10**6)
#print(bunkai(3))
for i in A:
    for l in bunkai(i):
        now=l[0] 
        if seen[now]!=0:
            flag=0
        seen[now]+=1
if flag:
    print("pairwise coprime")
elif max(seen)!=n:
    print("setwise coprime")
else:
    print("not coprime")



### FIXED CODE ###

n=int(input())
A=list(map(int,input().split()))
def Dlist(BIG):
    D=[1]*(BIG+1)
    for p in range(2,BIG+1):
        if D[p]!=1:
            continue
        for i in range(p,BIG+1,p):
            if D[i]==1:
                D[i]=p
    return D

D=Dlist(max(A))
def SOINSU(num,D): #素因数だけ列挙(setしただけ)
    now=num ; ans=set()
    while now>1:
        ans.add(D[now])
        now//=D[now]
    return ans

seen=[0]*(10**6+10)
flag=1
for num in A:
    for i in SOINSU(num,D):
        if seen[i]!=0: flag=0
        seen[i]+=1
if flag:
    print("pairwise coprime")
elif max(seen)!=n:
    print("setwise coprime")
else:
    print("not coprime")