Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = [int(input()) for _ in range(n)]

for i in range(n):
    tmp = A[i]
    A[i] = 0
    print(max(A))
    A[i] = tmp

Fixed submission:
n = int(input())
A = [int(input()) for _ in range(n)]

First = max(A)
ind = A.index(First)
A[ind] = 0
Second = max(A)
A[ind] = First

for i in range(n):
    if A[i] == First:
        print(Second)
    else:
        print(First)
Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())

ans = 100100100100
for i in range(L, R+1):
    for j in range(L, i):
        ans = min(ans, (i*j)%2019)
    """
    if ans == 0:
        print(ans)
        exit()
    """
print(ans)

Fixed submission:
L, R = map(int, input().split())

ans = 100100100100
for i in range(L, R+1):
    for j in range(L, i):
        ans = min(ans, (i*j)%2019)
    if ans == 0:
        print(ans)
        exit()
print(ans)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
IN = [int(input()) for _ in range(m)]
a = [0 for _ in range(n+1)]
for i in IN:
    a[i] = 1

dp = [-1 for _ in range(n+1)]
dp[-1], dp[-2], dp[-3] = 0, 1, 2

for i in range(n-3, -1, -1):
    if a[i] == 1:
        dp[i] = 0
    else:
        dp[i] = dp[i+1] +dp[i+2]
print(dp[0]%1000000007)

Fixed submission:
n, m = map(int, input().split())
IN = [int(input()) for _ in range(m)]

# i段目が壊れているならa[i] = 1,そうでないならa[i] = 0
a = [0 for _ in range(n+1)]
for i in IN:
    a[i] = 1

# dp[i] := i段目から最上段にたどり着くまでの移動方法の数
# dp[i] = 0 (a[i] が 1)
# dp[i] = dp[i+1] + dp[i+2] (それ以外)
dp = [-1 for _ in range(n+1)]

dp[n] = 0
if a[n-1] == 1:
    dp[n-1] = 0
else:
    dp[n-1] = 1
if a[n-2] == 1:
    dp[n-2] = 0
elif dp[n-1] == 0:
    dp[n-2] = 1
else:
    dp[n-2] = 2

for i in range(n-3, -1, -1):
    if a[i] == 1:
        dp[i] = 0
    else:
        dp[i] = dp[i+1] +dp[i+2]

print(dp[0]%(10 ** 9 + 7))

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [0 for _ in range(n+1)]
for i in range(m):
    a[int(input())] = 1

dp = [-1 for _ in range(n+1)]
dp[-1], dp[-2], dp[-3] = 0, 1, 2

for i in range(n-3, -1, -1):
    if a[i] == 1:
        dp[i] = 0
    else:
        dp[i] = dp[i+1] +dp[i+2]
print(dp[0]%1000000007)


Fixed submission:
n, m = map(int, input().split())
IN = [int(input()) for _ in range(m)]

# i段目が壊れているならa[i] = 1,そうでないならa[i] = 0
a = [0 for _ in range(n+1)]
for i in IN:
    a[i] = 1

# dp[i] := i段目から最上段にたどり着くまでの移動方法の数
# dp[i] = 0 (a[i] が 1)
# dp[i] = dp[i+1] + dp[i+2] (それ以外)
dp = [-1 for _ in range(n+1)]

dp[n] = 0
if a[n-1] == 1:
    dp[n-1] = 0
else:
    dp[n-1] = 1
if a[n-2] == 1:
    dp[n-2] = 0
elif dp[n-1] == 0:
    dp[n-2] = 1
else:
    dp[n-2] = 2

for i in range(n-3, -1, -1):
    if a[i] == 1:
        dp[i] = 0
    else:
        dp[i] = dp[i+1] +dp[i+2]

print(dp[0]%(10 ** 9 + 7))

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [0 for _ in range(n+1)]
for i in range(m):
    a[int(input())] = 1

dp = [-1 for _ in range(n+1)]
dp[-1], dp[-2], dp[-3] = 0, 1, 2

for i in range(n-3, -1, -1):
    if a[i] == 1:
        dp[i] = 0
    else:
        dp[i] = dp[i+1] +dp[i+2]
print(dp[0]%1000000007)

Fixed submission:
n, m = map(int, input().split())
IN = [int(input()) for _ in range(m)]

# i段目が壊れているならa[i] = 1,そうでないならa[i] = 0
a = [0 for _ in range(n+1)]
for i in IN:
    a[i] = 1

# dp[i] := i段目から最上段にたどり着くまでの移動方法の数
# dp[i] = 0 (a[i] が 1)
# dp[i] = dp[i+1] + dp[i+2] (それ以外)
dp = [-1 for _ in range(n+1)]

dp[n] = 0
if a[n-1] == 1:
    dp[n-1] = 0
else:
    dp[n-1] = 1
if a[n-2] == 1:
    dp[n-2] = 0
elif dp[n-1] == 0:
    dp[n-2] = 1
else:
    dp[n-2] = 2

for i in range(n-3, -1, -1):
    if a[i] == 1:
        dp[i] = 0
    else:
        dp[i] = dp[i+1] +dp[i+2]

print(dp[0]%(10 ** 9 + 7))
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
gate = []
for i in range(m):
    gate.append(list(map(int, input().split())))

card = [0 for i in range(1, n+1)]

for l, r in gate:
    for i in range(l, r+1):
        card[i-1] += 1
print(card.count(m))

Fixed submission:
n, m = map(int, input().split())
L_max, R_min = map(int, input().split())
for i in range(m-1):
    L, R = map(int, input().split())
    L_max = max(L_max, L)
    R_min = min(R_min, R)

print(max(R_min - L_max + 1, 0))
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
lr = [tuple(map(int, input().split())) for _ in range(q)]

# table[i] = i文字目以下のsにACは部分文字列として何回現れるか
table = []
for i in range(n+1):
    table.append(s[:i].count('AC'))

for l, r in lr:
    print(table[r] - table[l])

Fixed submission:
n, q = map(int, input().split())
s = input()
lr = [tuple(map(int, input().split())) for _ in range(q)]

# table[i] = i文字目以下のsにACは部分文字列として何回現れるか
table = [None] * (n+1)
table[0] = 0
table[1] = 0
for i in range(2, n+1):
    if s[i-2:i] == 'AC':
        table[i] = table[i-1] + 1
    else:
        table[i] = table[i-1]

for l, r in lr:
    print(table[r] - table[l])
Buggy python submission (verdict: Runtime Error):
import heapq

n = int(input())
A = list(map(lambda x: int(x) * (-1), input().split()))

heapq.heapify(A)

while len(A) > 1:
    print(A)
    Amax1 = heapq.heappop(A) * (-1)
    Amax2 = heapq.heappop(A) * (-1)
    pushA = Amax1 % Amax2
    if pushA == 0:
        heapq.heappush(A, Amax2 * (-1))
    else:
        heapq.heappush(A, pushA * (-1))
        heapq.heappush(A, Amax2 * (-1))

print(A[0] * (-1))

Fixed submission:
import heapq

n = int(input())
A = list(map(lambda x: int(x) * (-1), input().split()))

heapq.heapify(A)

while len(A) > 1:
    Amax1 = heapq.heappop(A) * (-1)
    Amax2 = heapq.heappop(A) * (-1)
    pushA = Amax1 % Amax2
    if pushA == 0:
        heapq.heappush(A, Amax2 * (-1))
    else:
        heapq.heappush(A, pushA * (-1))
        heapq.heappush(A, Amax2 * (-1))

print(A[0] * (-1))
Buggy python submission (verdict: Runtime Error):
n = int(input())
XYH = list(tuple(map(int, input().split())) for _ in range(n))

for i in range(n):
    if XYH[i][2] == 0:
        del XYH[i]

for cx in range(0, 101):
    for cy in range(0, 101):

        x, y, h = XYH[0]
        H = abs(x-cx) + abs(y-cy) + h

        if all([H == abs(x-cx) + abs(y-cy) + h for x, y, h in XYH]):
            print(cx, cy, H)
            exit()

Fixed submission:
n = int(input())
XYH = list(tuple(map(int, input().split())) for _ in range(n))

# h != 0であるデータを取得
for x, y, h in XYH:
    if h != 0:
        x_, y_, h_ = x, y, h
        break

for cx in range(0, 101):
    for cy in range(0, 101):

        H = abs(x_ - cx) + abs(y_ - cy) + h_

        if all([max(H - abs(x - cx) - abs(y - cy), 0) == h for x, y, h in XYH]):
            print(cx, cy, H)
            exit()
Buggy python submission (verdict: Time Limit Exceeded):
N, X = map(int, input().split())
x = list(map(lambda i: abs(int(i) - X), input().split()))

x_min = min(x)

for i in range(x_min, 0, -1):
    cnt = 0
    for j in x:
        if j % i != 0:
            break
        else:
            cnt += 1
    if cnt == N:
        print(i)
        exit()

Fixed submission:
N, X = map(int, input().split())
x = list(map(lambda i: abs(int(i) - X), input().split()))

x_min = min(x)

for i in range(x_min, 0, -1):
    cnt = 0
    for j in x:
        if j % i != 0:
            break
        else:
            cnt += 1
    if cnt == N:
        print(i)
        exit()

Buggy python submission (verdict: Time Limit Exceeded):
N, X = map(int, input().split())
x = list(map(lambda i: abs(int(i) - X), input().split()))

x_min = min(x)

for i in range(x_min, 0, -1):
    if all([_ % i == 0 for _ in x]):
        print(i)
        break

Fixed submission:
N, X = map(int, input().split())
x = list(map(lambda i: abs(int(i) - X), input().split()))

x_min = min(x)

for i in range(x_min, 0, -1):
    cnt = 0
    for j in x:
        if j % i != 0:
            break
        else:
            cnt += 1
    if cnt == N:
        print(i)
        exit()
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
X = list(map(int, input().split()))

ans = float('inf')
for i in range(n-k+1):
    l, r = X[i:i+k][0], X[i:i+k][-1]
    if r < 0:
        ans = min(abs(l), ans)
    elif 0 < l:
        ans = min(abs(r), ans)
    else:
        ans = min(min(abs(l), abs(r))*2+max(abs(l), abs(r)), ans)
print(ans)

Fixed submission:
n, k = map(int, input().split())
A = list(map(int, input().split()))

ans = float('inf')
for L in range(n-k+1):
    R = L + k
    if A[L] < 0 and A[R-1] < 0:
        ans = min(ans, abs(A[L]))
    elif A[L] < 0 and 0 <= A[R-1]:
        ans = min(ans, min(abs(A[L]), abs(A[R-1]))*2 + max(abs(A[L]), abs(A[R-1])))
    else:
        ans = min(ans, abs(A[R-1]))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

S = []
for i in s:
    S.append(i)

ans = 100100100100
for i in range(n):
    cost = S[0:i].count('W') + s[i+1:n].count('E')
    ans = min(ans, cost)
print(ans)

Fixed submission:
n = int(input())
s = input()
S = []
for i in s:
    S.append(i)

w = [0,]
for i in range(1, n):
    if S[i-1] == 'W':
        w.append(w[i-1] + 1)
    else:
        w.append(w[i-1])

e = [0 for _ in range(n)]
for i in range(n-2, -1, -1):
    if S[i+1] == 'E':
        e[i] = e[i+1] + 1
    else:
        e[i] = e[i+1]

ans = 100100100100
for i in range(n):
    cost = w[i] + e[i]
    ans = min(ans, cost)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

S = []
for i in s:
    S.append(i)

test = ['W' for _ in range(n)]

ans = 100100100
# i番目の人がリーダーの時
for i in range(n):
    # iより西の人は東を向き、iより東の人は西を向くべき
    for j in range(i):
        test[j] = 'E'
    test[i] = S[i]

    # コストを算出
    cost = 0
    for k in range(n):
        if S[k] != test[k]:
            cost += 1
    # ansを更新
    ans = min(ans, cost)

print(ans)

Fixed submission:
n = int(input())
s = input()
S = []
for i in s:
    S.append(i)

w = [0,]
for i in range(1, n):
    if S[i-1] == 'W':
        w.append(w[i-1] + 1)
    else:
        w.append(w[i-1])

e = [0 for _ in range(n)]
for i in range(n-2, -1, -1):
    if S[i+1] == 'E':
        e[i] = e[i+1] + 1
    else:
        e[i] = e[i+1]

ans = 100100100100
for i in range(n):
    cost = w[i] + e[i]
    ans = min(ans, cost)
print(ans)
Buggy python submission (verdict: Runtime Error):
p(int, input().split())

if abs(a-c) <= d:
    print('Yes')
elif abs(a-b) <= d and abs(b-c) <= d:
    print('Yes')
else:
    print('No')

Fixed submission:
a, b, c, d = map(int, input().split())

if abs(a-c) <= d:
    print('Yes')
elif abs(a-b) <= d and abs(b-c) <= d:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
A, B, C, x, y = map(int, input().split())

if x > y:
    ans = min(A+B, 2*C) * y
    ans += min(A, 2*C) * (x-y)
elif x < y:
    ans = min(A+B, 2*C) * x
    ans += min(B, 2*C) * (y-x)
else:
    ans += min(A+B, 2*C) * x
print(ans)

Fixed submission:
A, B, C, x, y = map(int, input().split())

if x > y:
    ans = min(A+B, 2*C) * y
    ans += min(A, 2*C) * (x-y)
elif x < y:
    ans = min(A+B, 2*C) * x
    ans += min(B, 2*C) * (y-x)
else:
    ans = min(A+B, 2*C) * x
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = map(int, input().split())

for i in range(a, b+1):
    if a <= i <= a + k - 1 or b - k + 1 <= i <= b:
        print(i)

Fixed submission:
a, b, k = map(int, input().split())

for i in range(a, b+1):
    if a <= i <= a + k - 1 or b - k + 1 <= i <= b:
        print(i)
Buggy python submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())

print(max(min(b, d) - max(a, c), 0)

Fixed submission:
a, b, c, d = map(int, input().split())

print(max(0, min(b, d) - max(a, c)))
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

n = int(input())
S = [int(input()) for _ in range(n)]

ans = 0
for i in range(1, n + 1):
    for tpl in combinations(S, i):
        s = sum(tpl)
        if s % 10 != 0:
            ans = max(ans, s)
print(ans)

Fixed submission:
n = int(input())
s = [int(input()) for _ in range(n)]

ans = sum(s)
if ans % 10 != 0:
    print(ans)
else:
    if all([i % 10 == 0 for i in s]):
        print(0)
    else:
        print(ans - min([i for i in s if i % 10 != 0]))

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

n = int(input())
S = [int(input()) for _ in range(n)]

ans = 0
for i in range(1, n + 1):
    for tpl in combinations(S, i):
        s = sum(tpl)
        if s % 10 != 0:
            ans = max(ans, s)
print(ans)

Fixed submission:
n = int(input())
s = [int(input()) for _ in range(n)]

ans = sum(s)
if ans % 10 != 0:
    print(ans)
else:
    if all([i % 10 == 0 for i in s]):
        print(0)
    else:
        print(ans - min([i for i in s if i % 10 != 0]))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
query = [tuple(map(int, input().split())) for _ in range(n)]

x, y = 1, 1
for t, a in query:
    T, A = t, a
    while not (T >= x and A >= y):
        T += t
        A += a
    x = T
    y = A
print(x + y)

Fixed submission:
n = int(input())
query = [tuple(map(int, input().split())) for _ in range(n)]

x, y = 1, 1
for t, a in query:
    if t >= x and a >= y:
        x = t
        y = a
    else:
        if t < x and a < y:
            x = t * max((x + t - 1) // t, (y + a - 1) // a)
            y = a * max((x + t - 1) // t, (y + a - 1) // a)
        elif t < x:
            x = t * ((x + t - 1) // t)
            y = a * ((x + t - 1) // t)
        else:
            x = t * ((y + a - 1) // a)
            y = a * ((y + a - 1) // a)
print(x + y)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
l = []
for i in range(N):
  l.append(int(input()))
  
cnts = [0] * 300001
for i in range(N):
  tmp = 0
  for j in range(max(l[i]-K, 0), min(l[i]+K+1, 300000)):
    tmp = max(tmp, cnts[j])
  cnts[l[i]] = tmp+1
print(max(cnts))


Fixed submission:
N, K = map(int, input().split())
l = []
for i in range(N):
  l.append(int(input()))
  
cnts = [1] * N
for i in range(N):
  for j in range(max(0, i-200), i):
    if abs(l[i]-l[j]) <= K:
      cnts[i] = max(cnts[i], cnts[j]+1)
print(max(cnts))

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
l = []
for i in range(N):
  l.append(int(input()))
  
cnts = [0] * 300001
for i in range(N):
  left, right = max(l[i]-K, 0), min(l[i]+K+1, 300000)
  cnts[l[i]] = max(cnts[left:right])+1
print(max(cnts))

Fixed submission:
N, K = map(int, input().split())
l = []
for i in range(N):
  l.append(int(input()))
  
cnts = [1] * N
for i in range(N):
  for j in range(max(0, i-200), i):
    if abs(l[i]-l[j]) <= K:
      cnts[i] = max(cnts[i], cnts[j]+1)
print(max(cnts))

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
l = []
for i in range(N):
  l.append(int(input()))
  
cnts = [0] * 20
for i in range(N-1):
  tmp = 0
  for j in range(max(l[i]-3, 0), min(l[i]+4, 300000)):
    tmp = max(tmp, cnts[j])
  cnts[l[i]] = tmp+1
print(max(cnts))

Fixed submission:
N, K = map(int, input().split())
l = []
for i in range(N):
  l.append(int(input()))
  
cnts = [1] * N
for i in range(N):
  for j in range(max(0, i-200), i):
    if abs(l[i]-l[j]) <= K:
      cnts[i] = max(cnts[i], cnts[j]+1)
print(max(cnts))
Buggy python submission (verdict: Time Limit Exceeded):
import math
N = int(input())

def factorization(n):
  a = 1
  temp = n
  for i in range(2, int(math.sqrt(n))+1):
    if temp%i == 0:
      cnt = 1
      while temp%i==0:
        cnt += 1
        temp //= i
      a *= cnt
  if temp != 1:
    a *= 2
  return a

if N <= 4*(10**5):
  ans = 0
  for i in range(1, N):
    ans += factorization(i)
elif 4*(10**5) < N <= 6*(10**5):
  ans = 5221424
  for i in range(4*(10**5), N):
    ans += factorization(i)
elif 6*(10**5) < N <= 8*(10**5):
  ans = 8075420
  for i in range(6*(10**5), N):
    ans += factorization(i)
elif 8*(10**5) < N <= 9*(10**5):
  ans = 10997400
  for i in range(8*(10**5), N):
    ans += factorization(i)
else:
  ans = 12478098
  for i in range(9*(10**5), N):
    ans += factorization(i)
print(ans)

Fixed submission:
import math
N = int(input())

def factorization(n):
  a = 1
  temp = n
  for i in range(2, int(math.sqrt(n))+1):
    if temp%i == 0:
      cnt = 1
      while temp%i==0:
        cnt += 1
        temp //= i
      a *= cnt
  if temp != 1:
    a *= 2
  return a

if N <= 4*(10**5):
  ans = 0
  for i in range(1, N):
    ans += factorization(i)
elif 4*(10**5) < N <= 6*(10**5):
  ans = 5221424
  for i in range(4*(10**5), N):
    ans += factorization(i)
elif 6*(10**5) < N <= 8*(10**5):
  ans = 8075420
  for i in range(6*(10**5), N):
    ans += factorization(i)
elif 8*(10**5) < N <= 9*(10**5):
  ans = 10997400
  for i in range(8*(10**5), N):
    ans += factorization(i)
else:
  ans = 12478098
  for i in range(9*(10**5), N):
    ans += factorization(i)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = []
for i in range(N):
  l.append(list(map(int, input().split())))
  
ans = 0
for i in range(N-1):
  for j in range(i+1, N):
    n = abs(l[i][0]-l[j][0]) + abs(l[i][1]-l[j][1])
    ans = max(ans, n)
print(ans)

Fixed submission:
N = int(input())
L1, L2 = [], []
for i in range(N):
  l = list(map(int, input().split()))
  L1.append(l[0]-l[1])
  L2.append(l[0]+l[1])
  
ans = max(max(L1)-min(L1), max(L2)-min(L2))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
l = []
for i in range(N):
  l.append(list(map(int, input().split())))
  
ans = 0
for i in range(N-1):
  for j in range(i+1, N):
    a, b = np.array(l[i]), np.array(l[j])
    n = int(np.linalg.norm(a-b, ord=1))
    ans = max(ans, n)
print(ans)

Fixed submission:
N = int(input())
L1, L2 = [], []
for i in range(N):
  l = list(map(int, input().split()))
  L1.append(l[0]-l[1])
  L2.append(l[0]+l[1])
  
ans = max(max(L1)-min(L1), max(L2)-min(L2))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

ans = 0
for i in range(N-1):
  s = 0
  for j in range(i+1, N):
    s += A[j]
    s %= (10**9)+7
  tmp = A[i]*s
  tmp %= (10**9)+7
  ans += tmp
  ans %= (10**9)+7
print(ans)

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

left = A[0]
left %= (10**9)+7
right = sum(A) - A[0]
right %= (10**9)+7
ans = 0
for i in range(1, N):
  tmp = left * right
  tmp %= (10**9)+7
  ans += tmp
  ans %= (10**9)+7
  left = A[i]
  right -= A[i]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

ans = 0
for i in range(N-1):
  s = 0
  for j in range(i+1, N):
    s += A[j]
    s %= (10**9)+7
  tmp = (A[i]*s) % ((10**9)+7)
  ans += tmp
  ans %= (10**9)+7
print(ans)

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

left = A[0]
left %= (10**9)+7
right = sum(A) - A[0]
right %= (10**9)+7
ans = 0
for i in range(1, N):
  tmp = left * right
  tmp %= (10**9)+7
  ans += tmp
  ans %= (10**9)+7
  left = A[i]
  right -= A[i]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

ans = 0
for i in range(N-1):
  for j in range(i+1, N):
    tmp = A[i] * A[j]
    tmp %= (10**9)+7
    ans += tmp
    ans %= (10**9)+7
print(ans)

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

left = A[0]
left %= (10**9)+7
right = sum(A) - A[0]
right %= (10**9)+7
ans = 0
for i in range(1, N):
  tmp = left * right
  tmp %= (10**9)+7
  ans += tmp
  ans %= (10**9)+7
  left = A[i]
  right -= A[i]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
N = int(input())
A = list(map(int, input().split()))
a = []

def gcd_list(numbers):
  return reduce(math.gcd, numbers)

def prime_factorize(n):
  global a
  tmp = []
  while n % 2 == 0:
    if 2 not in a:
      tmp.append(2)
      n //= 2
    else:
      return False
  f = 3
  while f * f <= n:
    if n % f == 0:
      if f not in a:
        tmp.append(f)
        n //= f
      else:
        return False
    else:
      f += 2
  if n != 1:
    if n not in a:
      tmp.append(n)
    else:
      return False
  a = list(set(a+tmp))
  return True

flag = True
for i in range(N):
  ans = prime_factorize(A[i])
  if not ans:
    flag = False
    break
if flag:
  print('pairwise coprime')
elif gcd_list(A) == 1:
  print('setwise coprime')
else:
  print('not coprime')

Fixed submission:
import math
from functools import reduce
N = int(input())
A = list(map(int, input().split()))
a = set()

def gcd_list(numbers):
  return reduce(math.gcd, numbers)

def prime_factorize(n):
  global a
  tmp = []
  while n % 2 == 0:
    if 2 not in a:
      tmp.append(2)
      n //= 2
    else:
      return False
  f = 3
  while f * f <= n:
    if n % f == 0:
      if f not in a:
        tmp.append(f)
        n //= f
      else:
        return False
    else:
      f += 2
  if n != 1:
    if n not in a:
      tmp.append(n)
    else:
      return False
  a |= set(tmp)
  return True

flag = True
for i in range(N):
  ans = prime_factorize(A[i])
  if not ans:
    flag = False
    break
if flag:
  print('pairwise coprime')
elif gcd_list(A) == 1:
  print('setwise coprime')
else:
  print('not coprime')

Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
N = int(input())
A = list(map(int, input().split()))

def gcd_list(numbers):
  return reduce(math.gcd, numbers)

flag = False
for i in range(N-1):
  for j in range(i+1, N):
    if math.gcd(A[i], A[j]) != 1:
      flag = True
      break
  if flag:
    break
if not flag:
  print('pairwise coprime')
  exit()

b = gcd_list(A)
if b == 1:
  print('setwise coprime')
else:
  print('not coprime')

Fixed submission:
import math
from functools import reduce
N = int(input())
A = list(map(int, input().split()))
a = set()

def gcd_list(numbers):
  return reduce(math.gcd, numbers)

def prime_factorize(n):
  global a
  tmp = []
  while n % 2 == 0:
    if 2 not in a:
      tmp.append(2)
      n //= 2
    else:
      return False
  f = 3
  while f * f <= n:
    if n % f == 0:
      if f not in a:
        tmp.append(f)
        n //= f
      else:
        return False
    else:
      f += 2
  if n != 1:
    if n not in a:
      tmp.append(n)
    else:
      return False
  a |= set(tmp)
  return True

flag = True
for i in range(N):
  ans = prime_factorize(A[i])
  if not ans:
    flag = False
    break
if flag:
  print('pairwise coprime')
elif gcd_list(A) == 1:
  print('setwise coprime')
else:
  print('not coprime')