Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02839 (python)

Fixed submission:
import time
t1 = time.time()
h,w = map(int,input().split())
grid = []
for i in range(h):
    grid.append(list(map(int,input().split())))
for i in range(h):
    lst = list(map(int,input().split()))
    for j in range(w):
        grid[i][j] = abs(grid[i][j]-lst[j])
lst = [[set() for _ in range(w)] for _ in range(h)]
lst[0][0].add(grid[0][0])
for j in range(1,w):
    for x in lst[0][j-1]:
        lst[0][j].add(abs(grid[0][j]-x))
        if (grid[0][j] + x) <= 6400:
            lst[0][j].add(grid[0][j]+x)
for i in range(1,h):
    for x in lst[i-1][0]:
        lst[i][0].add(abs(grid[i][0]-x))
        if grid[i][0] + x <= 6400:
            lst[i][0].add(grid[i][0]+x)
for i in range(1,h):
    for j in range(1,w):
        for x in lst[i][j-1]:
            lst[i][j].add(abs(grid[i][j]-x))
            if grid[i][j] + x <= 6400:
                lst[i][j].add(grid[i][j]+x)
        for x in lst[i-1][j]:
            lst[i][j].add(abs(grid[i][j]-x))
            if grid[i][j] + x <= 6400:
                lst[i][j].add(grid[i][j]+x)
        t = time.time()
        if t - t1 > 1.8:
            print(0)
            exit()
print(min(lst[h-1][w-1]))

Buggy submission (verdict: Runtime Error):
import time
t1 = time.time()
h,w = map(int,input().split())
grid = []
for i in range(h):
    grid.append(list(map(int,input().split())))
for i in range(h):
    lsti = list(map(int,input().split()))
    for j in range(w):
        grid[i][j] = abs(grid[i][j]-lst[j])
lst = [[set() for _ in range(w)] for _ in range(h)]
lst[0][0].add(grid[0][0])
for j in range(1,w):
    for x in lst[0][j-1]:
        lst[0][j].add(abs(grid[0][j]-x))
        if (grid[0][j] + x) <= 6400:
            lst[0][j].add(grid[0][j]+x)
for i in range(1,h):
    for x in lst[i-1][0]:
        lst[i][0].add(abs(grid[i][0]-x))
        if grid[i][0] + x <= 6400:
            lst[i][0].add(grid[i][0]+x)
for i in range(1,h):
    for j in range(1,w):
        for x in lst[i][j-1]:
            lst[i][j].add(abs(grid[i][j]-x))
            if grid[i][j] + x <= 6400:
                lst[i][j].add(grid[i][j]+x)
        for x in lst[i-1][j]:
            lst[i][j].add(abs(grid[i][j]-x))
            if grid[i][j] + x <= 6400:
                lst[i][j].add(grid[i][j]+x)
        t = time.time()
        if t - t1 > 1.8:
            print(0)
            exit()
print(min(lst[h-1][w-1]))
Problem p02842 (python)

Fixed submission:
n = int(input())
for i in range(n+1):
    if int(i*1.08) == n:
        print(i)
        exit()
print(":(")

Buggy submission (verdict: Runtime Error):
n = int(input())
for i in range(n):
    if int(i*1.08) = n:
        print(i)
        exit()
print(":(")
Problem p02885 (python)

Fixed submission:
a,b = map(int,input().split())
if a-2*b > 0:
    print(a-2*b)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
def warshall_floid(d):
    for k in range(1,n+1):
        for i in range(1,n+1):
            for j in range(1,n+1):
                d[i][j] = min(d[i][j],d[i][k]+d[k][j])
    return d

n,m,l = map(int,input().split())
d = [10**13]*(n+1) for i in range(n+1)]
for i in range(m):
    a,b,c = map(int,input().split())
    d[a][b] = c
    d[b][a] = c
for i in range(1,n+1):
    d[i][i] = 0
d = warshall_floid(d)
for i in range(1,n+1):
    for j in range(1,n+1):
        if d[i][j] <= l:
            d[i][j] = 1
        else:
            d[i][j] = 10**13
d = warshall_floid(d)
q = int(input())
for i in range(q):
    s,t = map(int,input().split())
    if d[s][t] >= 10**13:
        print(-1)
    else:
        print(d[s][t]-1)
Problem p02889 (python)

Fixed submission:
def warshall_floid(d):
    for k in range(1,n+1):
        for i in range(1,n+1):
            for j in range(1,n+1):
                d[i][j] = min(d[i][j],d[i][k]+d[k][j])
    return d

n,m,l = map(int,input().split())
d = [[10**13]*(n+1) for i in range(n+1)]
for i in range(m):
    a,b,c = map(int,input().split())
    d[a][b] = c
    d[b][a] = c
for i in range(1,n+1):
    d[i][i] = 0
d = warshall_floid(d)
for i in range(1,n+1):
    for j in range(1,n+1):
        if d[i][j] <= l:
            d[i][j] = 1
        else:
            d[i][j] = 10**13
d = warshall_floid(d)
q = int(input())
for i in range(q):
    s,t = map(int,input().split())
    if d[s][t] >= 10**13:
        print(-1)
    else:
        print(d[s][t]-1)

Buggy submission (verdict: Runtime Error):
def warshall_floid(d):
    for k in range(1,n+1):
        for i in range(1,n+1):
            for j in range(1,n+1):
                d[i][j] = min(d[i][j],d[i][k]+d[k][j])
    return d

n,m,l = map(int,input().split())
d = [10**13]*(n+1) for i in range(n+1)]
for i in range(m):
    a,b,c = map(int,input().split())
    d[a][b] = c
    d[b][a] = c
for i in range(1,n+1):
    d[i][i] = 0
d = warshall_floid(d)
for i in range(1,n+1):
    for j in range(1,n+1):
        if d[i][j] <= l:
            d[i][j] = 1
        else:
            d[i][j] = 10**13
d = warshall_floid(d)
q = int(input())
for i in range(q):
    s,t = map(int,input().split())
    if d[s][t] >= 10**13:
        print(-1)
    else:
        print(d[s][t]-1)

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def warshall_floid(d):
    for k in range(1,n+1):
        for i in range(1,n+1):
            for j in range(1,n+1):
                d[i][j] = min(d[i][j],d[i][k]+d[k][j])
    return d
n,m,l = map(int,readline().split())
d = [[5*10**11]*(n+1) for i in range(n+1)]
for i in range(m):
    a,b,c = map(int,readline().split())
    d[a][b] = c
    d[b][a] = c
for i in range(1,n+1):
    d[i][i] = 0
d = warshall_floid(d)
for i in range(1,n+1):
    for j in range(1,n+1):
        if d[i][j] <= l:
            d[i][j] = 1
        else:
            d[i][j] = 5*10**11
d = warshall_floid(d)
q = int(input())
for i in range(q):
    s,t = map(int,readline().split())
    if d[s][t] >3*10**11:
        print(-1)
    else:
        print(d[s][t]-1)
Problem p02900 (python)

Fixed submission:
from fractions import gcd
import math
a,b = map(int,input().split())
n = gcd(a,b)
if n == 1:
    print(1)
    exit()
count = 1
for i in range(2,math.ceil(math.sqrt(n))+1):
    if n % i == 0:
        count += 1
        while n % i == 0:
            n //= i
if n > 1:
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
import math
a,b = map(int,input().split())
n = gcd(a,b)
integer = [i for i in range(2,n+1)]
prime = set()
while integer[0] <= math.sqrt(n):
    p = integer[0] 
    prime.add(p)
    integer = [i for i in integer if i % p != 0]
prime = prime | set(integer)
count = 1
for i in prime:
    if n == 1:
        break
    if n % i == 0:
        count += 1
        while n % i == 0:
            n //= i
print(count)
Problem p02937 (python)

Fixed submission:
s = input()
t = input()
ss = s+s
NEXT = [[-1]*(len(s)+1) for _ in range(26)]
cur = [-1]*26
for i in range(len(ss)):
    char = ord(ss[i])-97
    if cur[char] < len(s):
        for j in range(cur[char],min(i,len(s))):
            NEXT[char][j+1] = i
            cur[char] = i
ans = 0
tmp = -1
for i in range(len(t)):
    char = ord(t[i])-97
    if NEXT[char][tmp+1] == -1:
        print(-1)
        exit()
    ans += NEXT[char][tmp+1]-tmp
    tmp = NEXT[char][tmp+1]
    if tmp >= len(s):
        tmp -= len(s)
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
ss = s+s
NEXT = [[-1]*(len(s)+1) for _ in range(26)]
cur = [-1]*26
for i in range(len(ss)):
    char = ord(ss[i])-97
    if cur[char] < len(s):
        for j in range(cur[char],min(i,len(s))):
            NEXT[char][j+1] = i
            cur[char] = i
ans = 0
tmp = -1
for i in range(len(t)):
    char = ord(t[i])-97
    if NEXT[char][tmp+1] == -1:
        print(-1)
        exit()
    ans += NEXT[char][tmp+1]-tmp
    tmp = NEXT[char][tmp+1]
    if tmp >= len(s)+1:
        tmp -= len(s)
print(ans)
Problem p02975 (python)

Fixed submission:
N = int(input())
a = list(map(int,input().split()))
if N % 3 != 0:
    if any(a):
        print('No')
    else:
        print('Yes')
else:
    a.sort()
    a1 = set(a[:N//3])
    a2 = set(a[N//3:2*N//3])
    a3 = set(a[2*N//3:])
    if len(a1) == 1 and len(a2) == 1 and len(a3) == 1:
        if a1.pop()^a2.pop()^a3.pop() == 0:
            print('Yes')
        else:
            print('No')
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input()))
x = 0
for i in range(N):
    x ^=  a[i]
if x:
    print('No')
else:
    print('Yes')
Problem p03006 (python)

Fixed submission:
from collections import defaultdict
n = int(input())
li = []
for i in range(n):
    xi,yi = map(int,input().split())
    li.append((xi,yi))
if n == 1:
    print(1)
    exit()
dic = defaultdict(int)
for i in range(n):
    for j in range(n):
        if i != j:
            xi = li[i][0]
            yi = li[i][1]
            xj = li[j][0]
            yj = li[j][1]
            dic[(xi-xj,yi-yj)] += 1
print(n-max(dic.values()))

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
n = int(input())
li = []
for i in range(n):
    xi,yi = map(int,input().split())
    li.append((xi,yi))
if n == 1:
    print(1)
dic = defaultdict(int)
for i in range(n):
    for j in range(n):
        if i != j:
            xi = li[i][0]
            yi = li[i][1]
            xj = li[j][0]
            yj = li[j][1]
            dic[(xi-xj,yi-yj)] += 1
print(n-max(dic.values()))

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
n = int(input())
li = []
for i in range(n):
    xi,yi = map(int,input().split())
    li.append((xi,yi))
dic = defaultdict(int)
for i in range(n):
    for j in range(n):
        if i != j:
            xi = li[i][0]
            yi = li[i][1]
            xj = li[j][0]
            yj = li[j][1]
            dic[(xi-xj,yi-yj)] += 1
print(n-max(dic.values()))
Problem p03014 (python)

Fixed submission:
h,w = map(int,input().split())
ans = [[0]*(w+2) for _ in range(h+2)]
grid = []
grid.append(['#']*(w+2))
for _ in range(h):
    s = list(input())
    grid.append(['#'] + s + ['#'])
grid.append(['#']*(w+2))
for i in range(1,h+1):
    for j in range(0,w+2):
        if grid[i][j] == '#':
            if j >= 1:
                for k in range(j-start):
                    ans[i][start+k] += j-start
            start = j + 1
for j in range(1,w+1):
    for i in range(0,h+2):
        if grid[i][j] == '#':
            if i >= 1:
                for k in range(i-start):
                    ans[start+k][j] += i-start
            start = i + 1
print(max(list(map(lambda x:max(x),ans)))-1)

Buggy submission (verdict: Runtime Error):
import numpy as np
h,w = map(int,input().split())
ans = [[0]*(w+2) for _ in range(h+2)]
grid = []
grid.append(['#']*(w+2))
for _ in range(h):
    s = list(input())
    grid.append(['#'] + s + ['#'])
grid.append(['#']*(w+2))
for i in range(1,h+1):
    for j in range(0,w+2):
        if grid[i][j] == '#':
            if j >= 1:
                for k in range(j-start):
                    ans[i][start+k] += j-start
            start = j + 1
for j in range(1,w+1):
    for i in range(0,h+2):
        if grid[i][j] == '#':
            if i >= 1:
                for k in range(i-start):
                    ans[start+k][j] += i-start
            start = i + 1
print(np.amax(ans)-1)

Buggy submission (verdict: Runtime Error):
import numpy as np
h,w = map(int,input().split())
ans = [[0]*(w+2) for _ in range(h+2)]
grid = []
grid.append(['#']*(w+2))
for _ in range(h):
    s = list(input())
    grid.append(['#'] + s + ['#'])
grid.append(['#']*(w+2))
for i in range(1,h+1):
    for j in range(0,w+2):
        if grid[i][j] == '#':
            if j >= 1:
                for k in range(j-start):
                    ans[i][start+k] += j-start
            start = j + 1
for j in range(1,w+1):
    for i in range(0,h+2):
        if grid[i][j] == '#':
            if i >= 1:
                for k in range(i-start):
                    ans[start+k][j] += i-start
            start = i + 1
print(np.amax(ans)-1)

Buggy submission (verdict: Runtime Error):
for i in range(1,h+1):
    for j in range(0,w+2):
        if grid[i][j] == '#':
            if j >= 1:
                for k in range(j-start):
                    ans[i][starimport numpy as np
h,w = map(int,input().split())
ans = [[0]*(w+2) for _ in range(h+2)]
grid = []
grid.append(['#']*(w+2))
for _ in range(h):
    s = list(input())
    grid.append(['#'] + s + ['#'])
grid.append(['#']*(w+2))
print(grid)
for i in range(1,h+1):
    for j in range(0,w+2):
        if grid[i][j] == '#':
            if j >= 1:
                for k in range(j-start):
                    ans[i][start+k] += j-start
            start = j + 1
for j in range(1,w+1):
    for i in range(0,h+2):
        if grid[i][j] == '#':
            if i >= 1:
                for k in range(i-start):
                    ans[start+k][j] += i-start
            start = i + 1
print(np.amax(ans)-1)t+k] += j-start
            start = j + 1
Problem p03032 (python)

Fixed submission:
import heapq
from collections import deque
from copy import copy
n,k = map(int,input().split())
d = deque(list(map(int,input().split())))
maxvalue = 0
for i in range(k+1):
    for j in range(k-i+1):
        jewel = []
        x = copy(d)
        for _ in range(i):
            if x:
                jewel.append(x.popleft())
        for _ in range(j):
            if x:
                jewel.append(x.pop())
        heapq.heapify(jewel)
        for _ in range(k-i-j):
            if jewel:
                a = heapq.heappop(jewel)
                if a >= 0:
                    jewel.append(a)
                    break
        maxvalue = max(maxvalue,sum(jewel))
print(maxvalue)

Buggy submission (verdict: Runtime Error):
import heapq
from collections import deque
from copy import copy
n,k = map(int,input().split())
d = deque(list(map(int,input().split())))
maxvalue = 0
for i in range(k):
    for j in range(k-i+1):
        jewel = []
        x = copy(d)
        for _ in range(i):
            jewel.append(x.popleft())
        for _ in range(j):
            jewel.append(x.pop())
        heapq.heapify(jewel)
        for _ in range(k-i-j):
            if jewel:
                a = heapq.heappop(jewel)
                if a >= 0:
                    jewel.append(a)
                    break
        maxvalue = max(maxvalue,sum(jewel))
print(maxvalue)
Problem p03046 (python)

Fixed submission:
m,k = map(int,input().split())
if m == 1:
    if k == 0:
        print(0,0,1,1)
    else:
        print(-1)
elif 2**m <= k:
    print(-1)
else:
    remain = set(range(2**m))
    use = set()
    count = 0
    while k:
        if k & 1:
            remain.remove(2**count)
            use.add(2**count)
        k >>= 1
        count += 1
    ans = []
    remain = list(remain)
    use = list(use)
    for i in remain:
        ans.append(str(i))
    for i in use:
        ans.append(str(i))
    for i in remain[::-1]:
        ans.append(str(i))
    for i in use[::-1]:
        ans.append(str(i))
    print(" ".join(ans))

Buggy submission (verdict: Runtime Error):
m,k = map(int,input().split())
if m == 1:
    if k == 0:
        print(0,0,1,1)
    else:
        print(-1)
elif 2**m <= k:
    print(-1)
else:
    remain = set(range(2**m))
    use = set()
    count = 0
    while k:
        if k & 1:
            remain.remove(2**count)
            use.add(2**count)
        k >>= 1
        count += 1
ans = []
remain = list(remain)
use = list(use)
for i in remain:
    ans.append(str(i))
for i in use:
    ans.append(str(i))
for i in remain[::-1]:
    ans.append(str(i))
for i in use[::-1]:
    ans.append(str(i))
print(" ".join(ans))
Problem p03061 (python)

Fixed submission:
from fractions import gcd
n = int(input())
a = list(map(int,input().split()))
GCD= a[0]
dp = [set() for i in range(n)]
dp[1].add(a[0])
dp[1].add(a[1])
for i in range(1,n):
    x = a[i]
    for j in dp[i-1]:
            dp[i].add(gcd(j,x))
    if x % GCD != 0:
        dp[i].add(GCD)
        GCD = gcd(GCD,x)
print(max(dp[n-1]))

Buggy submission (verdict: Runtime Error):
from math import gcd
n = int(input())
a = list(map(int,input().split()))
left = []
right = []

left.append(a[0])
for i in range(1,n-1):
    left.append(gcd(left[-1],a[i]))
a = a[::-1]
right.append(a[0])
for i in range(1,n-1):
    right.append(gcd(right[-1],a[i]))
ans = 1
for i in range(n-1):
    ans = max(ans,gcd(left[i],right[n-i-3]))
ans = max(ans,left[n-2],right[n-2])
print(ans)
Problem p03240 (python)

Fixed submission:
n = int(input())
data = []
for i in range(n):
    xi,yi,hi = map(int,input().split())
    data.append((xi,yi,hi))
lst = [[] for _ in range(n)]
data.sort(key = lambda x:x[2],reverse = True)
x,y,h = data[0]
for i in range(101):
    for j in range(101):
        lst[0].append((i,j,h+abs(i-x)+abs(j-y)))
for i in range(1,n):
    xi,yi,hi = data[i]
    if hi > 0:
        for x,y,h in lst[i-1]:
            if abs(x-xi)+abs(y-yi)+hi == h:
                lst[i].append((x,y,h))
    else:
        for x,y,h in lst[i-1]:
            if abs(x-xi)+abs(y-yi) >= h:
                lst[i].append((x,y,h))
print(*lst[n-1][0])

Buggy submission (verdict: Runtime Error):
n = int(input())
data = []
for i in range(n):
    xi,yi,hi = map(int,input().split())
    data.append((xi,yi,hi))
lst = [[] for _ in range(n)]
data.sort(key = lambda x:x[2],reverse = True)
x,y,h = data[0]
for i in range(101):
    for j in range(101):
        lst[0].append((i,j,h+abs(i-x)+abs(j-y)))
for i in range(1,n):
    xi,yi,hi = data[i]
    if hi > 0:
        for x,y,h in lst[i-1]:
            if abs(x-xi)+abs(y-yi)+hi == h:
                lst[i].append((x,y,h))
    else:
        for x,y,h in lst[i-1]:
            if abs(x-xi)+abs(y-yi) >= h:
                lst[i+1].append((x,y,h))
print(*lst[n-1][0])

Buggy submission (verdict: Runtime Error):
n = int(input())
x,y,h = map(int,input().split())
if n == 1:
    print(x,y,h)
    exit()
lst = [[] for _ in range(n)]
for i in range(101):
    for j in range(101):
        lst[0].append((i,j,h+abs(i-x)+abs(j-y)))
for i in range(n-1):
    xi,yi,hi = map(int,input().split())
    for x,y,h in lst[i]:
        if abs(x-xi)+abs(y-yi)+hi == h:
            lst[i+1].append((x,y,h))
print(*lst[n-1][0])

Buggy submission (verdict: Runtime Error):
n = int(input())
x,y,h = map(int,input().split())
lst = [[] for _ in range(n)]
for i in range(101):
    for j in range(101):
        lst[0].append((i,j,h+abs(i-x)+abs(j-y)))
for i in range(n-1):
    xi,yi,hi = map(int,input().split())
    for x,y,h in lst[i]:
        if abs(x-xi)+abs(y-yi)+hi == h:
            lst[i+1].append((x,y,h))
print(*lst[n-1][0])
Problem p03263 (python)

Fixed submission:
h,w = map(int,input().split())
coins = []
ans = []
for i in range(h):
    coins.append(list(map(int,input().split())))
for i in range(h-1):
    for j in range(w):
        if coins[i][j] % 2 != 0:
            coins[i][j] -= 1
            coins[i+1][j] += 1
            ans.append((i+1,j+1,i+2,j+1))
for i in range(w-1):
    if coins[h-1][i] % 2 != 0:
        coins[h-1][i] -= 1
        coins[h-1][i+1] += 1
        ans.append((h,i+1,h,i+2))
print(len(ans))
for i in range(len(ans)):
    print(*ans[i])

Buggy submission (verdict: Runtime Error):
h,w = map(int,input().split())
grid = []
ans = []
for i in range(h):
    grid.append(list(map(int,input().split())))
cur = [0,0]
while cur[0] != h or (cur[1] != 0 and cur[1] != w-1):
    y,x = cur[0],cur[1]
    if y % 2 == 0:
        if x != w-1:
            if grid[y][x] % 2 == 1:
                grid[y][x] -= 1
                grid[y][x+1] += 1
                ans.append((y+1,x+1,y+1,x+2))
            cur[1] += 1
        else:
            if grid[y][x] % 2 == 1:
                grid[y][x] -= 1
                grid[y+1][x] += 1
                ans.append((y+1,x+1,y+2,x+1))
            cur[0] += 1
    else:
        if x != 0:
            if grid[y][x] % 2 == 1:
                grid[y][x] -= 1
                grid[y][x-1] += 1
                ans.append((y+1,x+1,y+1,x))
            cur[1] -= 1
        else:
            if grid[y][x] % 2 == 1:
                grid[y][x] -= 1
                grid[y+1][x] += 1
                ans.append((y+1,x+1,y+2,x+1))
            cur[0] += 1
for i in ans:
    print(i[0],i[1],i[2],i[3])
Problem p03598 (python)

Fixed submission:
n = int(input())
k = int(input())
x = list(map(int,input().split()))
ans = 0
for i in range(n):
    ans += min(abs(x[i]-k),x[i])
print(ans*2)

Buggy submission (verdict: Runtime Error):
n = int(input())
k = int(input())
x = map(int,input().split())
ans = 0
for i in range(n):
    ans += min(abs(x[i]-k),x[i])
print(ans*2)
Problem p03644 (python)

Fixed submission:
n = int(input())
for i in range(8):
    if int(2**(7-i)) <= n:
        print(int(2**(7-i)))
        exit()

Buggy submission (verdict: Runtime Error):
n = int(input())
for i in range(8):
    if int(2**(7-i)) <= n:
        print(2**(7-i)
        exit()
Problem p03838 (python)

Fixed submission:
x,y = map(int,input().split())
ans = 10000000000
for a,b,c in [(x,y,0),(x,-y,1),(-x,y,1),(-x,-y,2)]:
    if a <= b:
        ans = min(ans,b-a+c)
print(ans)

Buggy submission (verdict: Runtime Error):
x,y = map(int,input().split())
ans = 10000000000
for a,b,c in [(x,y,0)(x,-y,1)(-x,y,1)(-x,-y,2)]:
    if a < b:
        ans = min(ans,b-a+c)
print(ans)
Problem p02574 (python)

Fixed submission:
#素因数分解
def Prime_Factorization(N):
    if N<0:
        R=[[-1,1]]
    else:
        R=[]

    N=abs(N)
    k=2
    while k*k<=N:
        if N%k==0:
            C=0
            while N%k==0:
                C+=1
                N//=k
            R.append([k,C])
        k+=1

    if N!=1:
        R.append([N,1])
    if not R:
        R.append([N,1])

    return R
#================================================
from math import gcd
N=int(input())
A=list(map(int,input().split()))

#Pairwise?
P=set()
F=True
for a in A:
    K=Prime_Factorization(a)
    for (p,_) in K:
        if p in P and p!=1:
            F=False
            break
        else:
            P.add(p)

    if not F:
        break

if F:
    print("pairwise coprime")
    exit()

#Setwise?
g=A[0]
for a in A:
    g=gcd(g,a)

if g==1:
    print("setwise coprime")
else:
    print("not coprime")

Buggy submission (verdict: Runtime Error):
#素因数分解
def Prime_Factorization(N):
    if N<0:
        R=[[-1,1]]
    else:
        R=[]

    N=abs(N)
    k=2
    while k*k<=N:
        if N%k==0:
            C=0
            while N%k==0:
                C+=1
                N//=k
            R.append([k,C])
        k+=1

    if N!=1:
        R.append([N,1])
    if not R:
        R.append([N,1])

    return R
#================================================
from math import gcd
N=int(input())
A=list(map(int,input().split()))

#Pairwise?
P=set()
F=True
for a in A:
    K=Prime_Factorization(a)
    for (p,_) in K:
        if p in P:
            F=False
            break
        else:
            P.add(p)

    if not F:
        break

if F:
    print("pairwise coprime")
    exit()

#Setwise?
g=A[0]
for a in A:
    g=gcd(g,a)

if g==1:
    print(1/0)
    print("setwise coprime")
else:
    print("not coprime")

Buggy submission (verdict: Runtime Error):
#素因数分解
def Prime_Factorization(N):
    if N<0:
        R=[[-1,1]]
    else:
        R=[]

    N=abs(N)
    k=2
    while k*k<=N:
        if N%k==0:
            C=0
            while N%k==0:
                C+=1
                N//=k
            R.append([k,C])
        k+=1

    if N!=1:
        R.append([N,1])
    if not R:
        R.append([N,1])

    return R
#================================================
from math import gcd
N=int(input())
A=list(map(int,input().split()))

#Pairwise?
P=set()
F=True
for a in A:
    K=Prime_Factorization(a)
    for (p,_) in K:
        if p in P:
            F=False
            break
        else:
            P.add(p)

    if not F:
        break

if F:
    print(1/0)
    print("pairwise coprime")
    exit()

#Setwise?
g=A[0]
for a in A:
    g=gcd(g,a)
    if g==1:
        break

if g==1:
    print("setwise coprime")
else:
    print("not coprime")