Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
from bisect import insort_left
N = int(input())
#S = input()[:-1]
#N,M = map(int,input().split())
#S,T = map(str,input().split())
A = list(map(int,input().split()))
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
d = 0
for i in range(N-1):
    for j in range(i+1,N):
        s = A[i]+A[j]
        dex = insort_left(A,s)
        
        d = d + dex - j-1
print(d)

Fixed submission:
import sys
input=sys.stdin.readline
from bisect import bisect_left
N = int(input())
#S = input()[:-1]
#N,M = map(int,input().split())
#S,T = map(str,input().split())
A = list(map(int,input().split()))
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
d = 0
A.sort()
for i in range(N-2):
    for j in range(i+1,N-1):
        s = A[i]+A[j]
        dex = bisect_left(A,s)
        if dex > j:
          d += dex -j -1
print(d)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
N = int(input())
#S = input()[:-1]
#N,M = map(int,input().split())
#S,T = map(str,input().split())
A = list(map(int,input().split()))
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
def binary_search(S,key): 
    left  = 0
    right = N
    while left < right:
        mid = (left+right) // 2
        if S[mid] == key:
            return mid
        elif S[mid] > key:
            right = mid
        else:
            left = mid + 1
    return mid
d = 0
A.sort()
for i in range(N-1):
    for j in range(i+1,N):
        s = A[i]+A[j]
        dex = binary_search(A,s)
        while A[dex] >= s :
            dex -= 1
        d = d + dex - j
print(d)

Fixed submission:
import sys
input=sys.stdin.readline
from bisect import bisect_left
N = int(input())
#S = input()[:-1]
#N,M = map(int,input().split())
#S,T = map(str,input().split())
A = list(map(int,input().split()))
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
d = 0
A.sort()
for i in range(N-2):
    for j in range(i+1,N-1):
        s = A[i]+A[j]
        dex = bisect_left(A,s)
        if dex > j:
          d += dex -j -1
print(d)
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import insort_left
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
for i in range(M):
    A[-1] = A[-1]/2
    k = A[-1]
    A = A[:-1]
    insort_left(A,k)
s = 0
for i in range(N):
    s += int(A[i])
print(s)

Fixed submission:
import heapq
N,M = map(int,input().split())
A = list(map(lambda x:int(x)*(-1),input().split()))
heapq.heapify(A)
for _ in range(M):
    a = heapq.heappop(A)
    a /= 2
    heapq.heappush(A,a)
s = 0
for i in A:
    i = int(i*(-1))
    s += i
print(s)
Buggy python submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#from bisect import insort_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
#import heapq
#import numpy as np
#INF = float("inf")
N = int(input())
A = list(map(int,input().split()))
s = 0
for i in A:
    s += A**(-1)
print(s**(-1))

Fixed submission:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#from bisect import insort_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
#import heapq
#import numpy as np
#INF = float("inf")
N = int(input())
A = list(map(int,input().split()))
s = 0
for i in A:
    s += i**(-1)
print(s**(-1))
Buggy python submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#N = int(input())
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = list(map(int,input().split()))
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
A,B,C,D = map(int,input().split())
import fractions
e = C * D
ans = 0
first = (((A-1) // 12)+1) * 12
last = (B // 12) * 12 
if last - first <= 0:
    for i in range(A,B+1):
        if i % C != 0 and i % D != 0:
            ans += 1
else:
    ans += (last-first) * (1-1/C) * (1-1/D)
    for i in range(A,first):
        if i % C != 0 and i % D != 0:
            ans += 1
    for j in range(last+1,B+1):
        if i % C != 0 and i % D != 0:
            ans += 1
print(int(ans))

Fixed submission:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
import fractions
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())[:-1]
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [list(input())[:-1] for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]

a,b,c,d=map(int,input().split())
e=fractions.gcd(c,d)
f=c*d//e
ans1=a-1
ans1-=(a-1)//c
ans1-=(a-1)//d
ans1+=(a-1)//f
ans2=b
ans2-=b//c
ans2-=b//d
ans2+=b//f
print(ans2-ans1)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#N = int(input())
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = list(map(int,input().split()))
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
from collections import defaultdict
d = defaultdict(int)
N,M = map(int,input().split())
A = list(map(int,input().split()))
A = sorted(A)
for i in range(M):
    b,c = map(int,input().split())
    d[c] += b
d = dict(d)
d = sorted(d.items(),key = lambda x:x[0],reverse = True)
n = len(d)
index = 0
for i in range(n):
    d[i] = list(d[i])
D = [0] * N
index = 0
for k in range(N):
    if d[index][1] != 0:
        d[index][1] -= 1
        D[k] = d[index][0]
    else:
        index += 1
        if index  == n:
            break
        else:
            d[index][1] -= 1
            D[k] = d[index][0]  
Max = 0
for X in range(N+1):
    s = 0
    for v in range(N):
        if v < X:
            s += D[v]
        else:
            s += A[v]
    Max = max(s,Max)
print(Max)


Fixed submission:
import sys
input=sys.stdin.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#N = int(input())
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = list(map(int,input().split()))
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
from collections import defaultdict
d = defaultdict(int)
N,M = map(int,input().split())
A = list(map(int,input().split()))
A = sorted(A)
for i in range(M):
    b,c = map(int,input().split())
    d[c] += b
d = dict(d)
d = sorted(d.items(),key = lambda x:x[0],reverse = True)
n = len(d)
index = 0
for i in range(n):
    d[i] = list(d[i])
D = [0] * N
index = 0
for k in range(N):
    if d[index][1] != 0:
        d[index][1] -= 1
        D[k] = d[index][0]
    else:
        index += 1
        if index  == n:
            break
        else:
            d[index][1] -= 1
            D[k] = d[index][0]  
Max = 0

for p in A:
    Max += p
for X in range(N):
    if A[X] < D[X]:
        Max += D[X] - A[X]
    else:
        break
print(Max)
Buggy python submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
S = list(input())[:-1]
a = 10*int(S[0])+int(S[1])
b = 10*int(S[2])+int(S[3])
    print("NA")
if (a > 12 or a == 0) and (b > 12 or b == 0):
    print("NA")
elif a > 12 or a == 0:
    print("YYMM")
elif b > 12 or b == 0:
    print("MMYY")
else:
    print("AMBIGUOUS")

Fixed submission:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
S = list(input())[:-1]
a = 10*int(S[0])+int(S[1])
b = 10*int(S[2])+int(S[3])
if (a > 12 or a == 0) and (b > 12 or b == 0):
    print("NA")
elif a > 12 or a == 0:
    print("YYMM")
elif b > 12 or b == 0:
    print("MMYY")
else:
    print("AMBIGUOUS")
Buggy python submission (verdict: Runtime Error):
N = int(input())
h = list(map(int,input().split()))
H = [0]*N
for i in range(1,N):
    if i == 1:
        H[i] = abs(h[1]-h[0])
    else:
        H[i] = H[i-1]+abs(h[i]-h[i-1]
        if H[i] > H[i-2]+abs(h[i]-h[i-2]):
            H[i] = H[i-2]+abs(h[i]-h[i-2])
print(H[N-1])

Fixed submission:
N = int(input())
h = list(map(int,input().split()))
H = [0]*N
for i in range(1,N):
    if i == 1:
        H[i] = abs(h[1]-h[0])
    else:
        H[i] = min(H[i-1]+abs(h[i]-h[i-1]),H[i-2]+abs(h[i]-h[i-2]))
print(H[N-1])

Buggy python submission (verdict: Runtime Error):
N = int(input())
h = list(map(int,input().split()))
H = [0]*N
for i in range(1,N):
    if i == 1:
        H[i] = abs(h[1]-h[0])
    else:
        H[i] = H[i-1]+abs(h[i]-h[i-1])
        if H[i] > H[i-2]+abs(h[i]-h[i-2]:
        	H[i] = H[i-2]+abs(h[i]-h[i-2]
print(H[N-1])

Fixed submission:
N = int(input())
h = list(map(int,input().split()))
H = [0]*N
for i in range(1,N):
    if i == 1:
        H[i] = abs(h[1]-h[0])
    else:
        H[i] = min(H[i-1]+abs(h[i]-h[i-1]),H[i-2]+abs(h[i]-h[i-2]))
print(H[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,(input().split()))
h = list(map(int,input().split()))
H = [0]*N
for i in range(1,N):
    if i == 1:
        H[i] = abs(h[1]-h[0])
    else:
        Min = 1000000000
        start = max((i-K),0)
        for j in range(start,i):
            if Min > H[j]+abs(h[i]-h[j]):
                Min = H[j]+abs(h[i]-h[j])
        H[i] = Min
print(H[N-1])

Fixed submission:
N,K = map(int,(input().split()))
h = list(map(int,input().split()))
H = [0]*N
for i in range(1,N):
    if i == 1:
        H[i] = abs(h[1]-h[0])
    else:
        Min = 1000000000
        start = max((i-K),0)
        for j in range(start,i):
            if Min > H[j]+abs(h[i]-h[j]):
                Min = H[j]+abs(h[i]-h[j])
        H[i] = Min
print(H[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
N,W = map(int,input().split())
dp = [0]*(W+1)
for _ in range(N):
    w,v = map(int,input().split())
    if w > W:
        continue
    else:
        for j in range(w,W+1)[::-1]:
            if dp[j] < dp[j-w]+v:
                dp[j] = dp[j-w]+v
print(dp[W])

Fixed submission:
N,W = map(int,input().split())
import copy
dp = [0]*(W+1)
for _ in range(N):
    dpc = copy.deepcopy(dp)
    w,v = map(int,input().split())
    if w > W:
        continue
    else:
        for j in range(w,W+1):
            if dpc[j] < dpc[j-w]+v:
                dp[j] = dpc[j-w]+v
print(dp[W])

Buggy python submission (verdict: Time Limit Exceeded):
N,W = map(int,input().split())
import copy
dp = [0]*(W+1)
for _ in range(N):
    dpc = copy.deepcopy(dp)
    w,v = map(int,input().split())
    if w > W:
        continue
    else:
        for j in range(w,W+1):
            if dpc[j] < dpc[j-w]+v:
                dp[j] = dpc[j-w]+v
print(dp[W])

Fixed submission:
N,W = map(int,input().split())
import copy
dp = [0]*(W+1)
for _ in range(N):
    dpc = copy.deepcopy(dp)
    w,v = map(int,input().split())
    if w > W:
        continue
    else:
        for j in range(w,W+1):
            if dpc[j] < dpc[j-w]+v:
                dp[j] = dpc[j-w]+v
print(dp[W])
Buggy python submission (verdict: Runtime Error):
import numpy as np
N,W = map(int,input().split())
dp = np.zeros(W+1,dtype = np.int64)
for _ in range(N):
    w,v = map(int,input().split())
    if w > W:
        continue
    else:
        np.maximum(dp[w:],dp[:-w]+v,out = dp[w:])
print(dp[W])

Fixed submission:
import numpy as np
N,W = map(int,input().split())
dp = np.full(N*1000+1,W+1)
dp[0] = 0
for _ in range(N):
    w,v = map(int,input().split())
    np.minimum(dp[v:],dp[:-v]+w,out = dp[v:])
print(np.where(dp<=W)[0][-1])
Buggy python submission (verdict: Runtime Error):
N = int(input())
c = 0
for  i in rrange(1,N+1):
  li = []
  if i < 10:
    continue
  else:
    k = i
    for j in range(2,int(i**(0.5)+1)):
      while k % j == 0:
        k = k/j
        li.append(j)
    if len(li) == 8:
      c += 1
print(c)

Fixed submission:
N = int(input())
c = 0
for  i in range(1,N+1):
  if i % 2 == 0:
    continue
  li = []
  if i < 10:
    continue
  else:
    k = i
    for j in range(2,int(i**(0.5)+3)):
      d = 1
      while k % j == 0:
        k = k/j
        d += 1
      if d != 1:
        li.append(d)
    ss = 1
    for x in li:
      ss *= x
    if ss == 8:
      #print(i)
      c += 1
    
print(c)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ax = 0
for aa in range(a+1):
    for bb in range(b+1):
    	for cc in range(c+1):
      		if aa * 500 + bb * 100 + cc * 50 == X:
        		ax += 1
print(ax)


Fixed submission:
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ax = 0
for aa in range(a+1):
  for bb in range(b+1):
    for cc in range(c+1):
      if aa * 500 + bb * 100 + cc * 50 == x:
        ax += 1
print(ax)

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ax = 0
for aa in range(a+1):
  for bb in range(b+1):
    for cc in range(c+1):
      if aa * 500 + bb * 100 + cc * 50 == X:
        ax += 1
print(ax)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ax = 0
for aa in range(a+1):
  for bb in range(b+1):
    for cc in range(c+1):
      if aa * 500 + bb * 100 + cc * 50 == x:
        ax += 1
print(ax)
Buggy python submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
s = 0
for i in range(1,N+1):
  j = i
  x0 = j // 10000
  j -= x * 10000
  x1 = j // 1000
  j -= x * 10000
  x2 = j // 100
  j -= x * 10000
  x3 = j // 10
  j -= x * 10000
  x4 = j
  if A <= x0 + x1 + x2 + x3 + x4 and B >= x0 + x1 + x2 + x3 + x4:
    s += i
print(s)

Fixed submission:
N,A,B = map(int,input().split())
s = 0
j = 0
for i in range(1,N+1):
  j = i
  x0 = j // 10000
  j -= x0 * 10000
  x1 = j // 1000
  j -= x1 * 1000
  x2 = j // 100
  j -= x2 * 100
  x3 = j // 10
  j -= x3 * 10
  x4 = j
  if (A <= x0 + x1 + x2 + x3 + x4 and B >= x0 + x1 + x2 + x3 + x4):
    s += i
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#from bisect import insort_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
#import heapq
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
from bisect import bisect_left
ans = 0
for i in range(N):
    a = A[i]
    indb = bisect_left(B,a+1)
    if indb == N:
        continue
    for j in range(indb,N):
        b = B[j]
        indc = bisect_left(C,b+1)
        ans += N-indc
print(ans)
  

Fixed submission:
import sys
input=sys.stdin.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#from bisect import insort_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
#import heapq
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
from bisect import bisect_left
ans = 0
for i in range(N):
    b = B[i]
    inda = bisect_left(A,b)
    indc = bisect_left(C,b+1)
    ans += (N-indc)*inda
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
import math
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#from bisect import insort_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
#import heapq
#import numpy as np
#INF = float("inf")
N = int(input())
A = [list(map(int,input().split())) for _ in range(N)]
flag = 1
s = 0
for i in range(N-1):
    if flag == 0:
        break
    for j in range(i+1,N):
        judge = 1
        if flag == 0:
            break
        a = A[i][j]
        s += a
        for k in range(N):
            if k == i or k == j:
                continue
            elif a > A[i][k] + A[k][j]:
                flag = 0
                break
            elif a == A[i][k] + A[k][j]:
                s -= a
                break
            else:
                continue
if flag == 0:
    print(-1)
else:
    print(s)

Fixed submission:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
import math
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#from bisect import insort_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
#import heapq
#import numpy as np
#INF = float("inf")
N = int(input())
A = [list(map(int,input().split())) for _ in range(N)]
flag = 1
s = 0
for i in range(N-1):
    if flag == 0:
        break
    for j in range(i+1,N):
        judge = 1
        if flag == 0:
            break
        a = A[i][j]
        s += a
        for k in range(N):
            if k == i or k == j:
                continue
            elif a > A[i][k] + A[k][j]:
                flag = 0
                break
            elif a == A[i][k] + A[k][j]:
                s -= a
                break
            else:
                continue
if flag == 0:
    print(-1)
else:
    print(s)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

def factorize(n: int) -> list:
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

pairwize = True
alls = None
wize = None

for i in range(N):
    f = factorize(A[i])
    fs = set(f)
    # print(fs)

    if i == 0:
        wize = fs
        alls = fs
    else:
        if alls & fs:
            pairwize = False
        alls = alls | fs
        wize = wize & fs

if pairwize:
    print("pairwise coprime")
else:
    if wize:
        print("not coprime")
    else:
        print("setwise coprime")


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
max_A = 10**6+1

dp = [0] * (max_A)
for i in range(N):
    dp[A[i]] += 1

pairwise = True

for i in range(2, max_A):
    cnt = 0
    # 素数の倍数がdp配列に存在するか。自分以外にあれば2以上になる
    for j in range(i, max_A, i):
        cnt += dp[j]
    if cnt > 1:
        pairwise = False

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

from math import gcd

g = 0
for i in range(N):
    g = gcd(g, A[i])
if g == 1:
    print("setwise coprime")
else:
    print("not coprime")
Buggy python submission (verdict: Time Limit Exceeded):
H, W, M = map(int, input().split())
S = [tuple(map(int, input().split())) for _ in range(M)]

Y = [0] * H
X = [0] * W

for i in range(M):
    y, x = S[i]
    y, x = y-1, x-1
    Y[y] += 1
    X[x] += 1

YM = max(Y)
XM = max(X)

YI = []
for i in range(H):
    if Y[i] == YM:
        YI.append(i)

XI = []
for i in range(W):
    if X[i] == XM:
        XI.append(i)

for y in YI:
    for x in XI:
        if (y+1, x+1) not in S:
            print(YM+XM)
            exit()
else:
    print(YM+XM-1)

Fixed submission:
H, W, M = map(int, input().split())
S = [tuple(map(int, input().split())) for _ in range(M)]
ss = set(S)

Y = [0] * H
X = [0] * W

for i in range(M):
    y, x = S[i]
    y, x = y-1, x-1
    Y[y] += 1
    X[x] += 1

YM = max(Y)
XM = max(X)

YI = []
for i in range(H):
    if Y[i] == YM:
        YI.append(i)

XI = []
for i in range(W):
    if X[i] == XM:
        XI.append(i)

for y in YI:
    for x in XI:
        if (y+1, x+1) not in ss:
            print(YM+XM)
            exit()
else:
    print(YM+XM-1)