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

Fixed submission:
#!/usr/bin/env python3
#dp6 #Longest-Path

import sys
sys.setrecursionlimit(10000000)
def LI(): return list(map(int,sys.stdin.readline().split()))
def LIR(n): return [LI() for _ in range(n)]
def g():
    def dfs(x):
        #既に最長パスがわかっている頂点はそれを返す
        if dp[x] != None:
            return dp[x]
        #移動できる頂点がないとき0
        if len(Graph[x]) == 0:
            dp[x] = 0
            return 0
        else:
            res = 0
            #移動できる頂点の中で最大パスをもつものを探す
            for y in Graph[x]:
                res = max(res,dfs(y)+1)
            dp[x] = res
            return dp[x]

    n,m = LI()
    #dpで各頂点を始点とした最大パスを管理
    dp = [None for _ in range(n)]
    Graph = [[] for _ in range(n)]
    for _ in range(m):
        x,y = LI()
        Graph[x-1].append(y-1)
    #各頂点を始点として最大パスを探す
    for i in range(n):
        dfs(i)
    print(max(dp))
if __name__ == '__main__':
    g()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
#dp6 #Longest-Path

import sys
def LI(): return list(map(int,sys.stdin.readline().split()))
def LIR(n): return [LI() for _ in range(n)]
def g():
    def dfs(x):
        #既に最長パスがわかっている頂点はそれを返す
        if dp[x] != None:
            return dp[x]
        #移動できる頂点がないとき0
        if len(Graph[x]) == 0:
            dp[x] = 0
            return 0
        else:
            res = 0
            #移動できる頂点の中で最大パスをもつものを探す
            for y in Graph[x]:
                res = max(res,dfs(y)+1)
            dp[x] = res
            return dp[x]

    n,m = LI()
    #dpで各頂点を始点とした最大パスを管理
    dp = [None for _ in range(n)]
    Graph = [[] for _ in range(n)]
    for _ in range(m):
        x,y = LI()
        Graph[x-1].append(y-1)
    #各頂点を始点として最大パスを探す
    for i in range(n):
        dfs(i)
    print(max(dp))
if __name__ == '__main__':
    g()
Problem p03244 (python)

Fixed submission:
#!/usr/bin/env python3
#ABC111 C

from operator import itemgetter
import collections

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

s = [v[i] for i in range(n) if i % 2 == 0]
t = [v[i] for i in range(n) if i % 2 == 1]

sc = collections.Counter(s)
tc = collections.Counter(t)
sc = list(sc.items())
tc = list(tc.items())
ls = len(sc)
lt = len(tc)
sc.sort(key = itemgetter(1))
tc.sort(key = itemgetter(1))
if sc[-1][0] == tc[-1][0]:
    if ls == 1 and lt == 1:
        print(n - sc[-1][1])
    elif ls == 1 and lt != 1:
        print(n - sc[-1][1] - tc[-2][1])
    elif ls != 1 and lt == 1:
        print(n - sc[-2][1] - tc[-1][1])
    else:
        ma = max(sc[-2][1],tc[-2][1])
        print(n - sc[-1][1] - ma)
else:
    print(n - sc[-1][1] - tc[-1][1])

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
#ABC111 C

from operator import itemgetter
n = int(input())
v = list(map(int,input().split()))

s = []
t = []
for i in range(n):
    if i % 2 == 0:
        s.append(v[i])
    else:
        t.append(v[i])

ss = list(set(s))
tt = list(set(t))

sc = []
tc = []
for i in range(len(ss)):
    sc.append([ss[i],s.count(ss[i])])
    tc.append([tt[i],t.count(tt[i])])
sc.sort(key = itemgetter(1))
tc.sort(key = itemgetter(1))
if sc[-1][0] == tc[-1][0]:
    if len(sc) == 1 and len(tc) == 1:
        print(n - sc[-1][1])
    elif len(sc) == 1 and len(tc) != 1:
        print(n - sc[-1][1] - tc[-2][1])
    elif len(sc) != 1 and len(tc) == 1:
        print(n - sc[-2][1] - tc[-1][1])
    else:
        ma = max(sc[-2][1],tc[-2][1])
        print(n - sc[-1][1] - ma)
else:
    print(n - sc[-1][1] - tc[-1][1])
Problem p03282 (python)

Fixed submission:
#!/usr/bin/env python3
import numpy as np
import math
import re

S = input()
K = input()

for i in range(int(K)):
    if(S[i] != '1'):
        print(S[i])
        exit()
print(S[i])

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import numpy as np
import math
import re

S = input()
K = input()

if S[0] == '1':
    print(S[1])
else:
    print(S[0])
Problem p03353 (python)

Fixed submission:
#!usr/bin/env python3
s = input()
K = int(input())

l = {s}
for n in range(1, K+1):
    for i in range(0, len(s)-n+1):
        l.add(s[i:i+n])
l = list(l)

l.sort()

print(l[K-1])

Buggy submission (verdict: Runtime Error):
    for i in range(1, n + 1):
        if a <= sum(list(map(int, list(str(i))))) <= b:
           ans += i
    print(ans)
Problem p03354 (python)

Fixed submission:
#!/usr/bin/env python3


n,m = map(int,input().split())
p = list(map(int,input().split()))
for i in range(n):
    p[i] -= 1

#連結成分に属するかどうかを見るときはUnion-Findを用いる
#根(属するクラス)を返す関数
def root(x):
    if par[x] == x:
        return x
    par[x] = root(par[x])
    return par[x]
#同じクラスに属するかどうかを返す関数
def same(x,y):
    return root(x) == root(y)
#木を結合する関数
def union(x,y):
    x = root(x)
    y = root(y)
    #高さの高いほうに低いほうを結合
    if rank[x] < rank[y]:
        par[x] = y#xの親(属するクラス)をyとする
    else:
        par[y] = x
        if rank[x] == rank[y]:#高さが同じ場合
            rank[x] += 1#高さは1つ増える
par = [i for i in range(n)]
rank = [0 for _ in range(n)]
for i in range(m):
    x,y = map(int,input().split())
    #swapできる頂点は同じ木にして同じ連結成分にする
    if not same(x-1,y-1):
        union(x-1,y-1)

ans = 0
for i in range(n):
    #p[i]とiが同じ連結成分ならばans+1
    if root(p[i]) == root(i):
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(10000000)
n,m = map(int,input().split())
p = list(map(int,input().split()))
xy = [list(map(int,input().split())) for _ in range(m)]

Graph = [[] for _ in range(n)]
for x,y in xy:
    Graph[x-1].append(y-1)
    Graph[y-1].append(x-1)

check = [False for _ in range(n)]
def dfs(g,start,c,goal):
    c[start] = True
    if start == goal:
        return True
    for u in g[start]:
        if c[u]:
            continue
        if dfs(g,u,c,goal):
            return True
ans = 0
for i in range(n):
    c = check.copy()
    if dfs(Graph,i,c,p.index(i+1)):
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(10000000)
n,m = map(int,input().split())
p = list(map(int,input().split()))
xy = [list(map(int,input().split())) for _ in range(m)]

Graph = [[] for _ in range(n)]
for x,y in xy:
    Graph[x-1].append(y-1)
    Graph[y-1].append(x-1)

check = [False for _ in range(n)]
def dfs(g,start,c,goal):
    c[start] = True
    if start == goal:
        return True
    for u in g[start]:
        if c[u]:
            continue
        if dfs(g,u,c,goal):
            return True
ans = 0
for i in range(n):
    c = check.copy()
    if dfs(Graph,i,c,p.index(i+1)):
        ans += 1
print(ans)
Problem p03437 (python)

Fixed submission:
#!/usr/bin/env python3
#APC1 A

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a,b = LI()
if a % b == 0:
  print(-1)
else:
  print(a)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
#APC1 A

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a,b = LI()
if a % b == 0:
  print(-1)
tmp = 1
while 1:
  if tmp % a == 0 and tmp % != 0:
    print(tmp)
    quit()
  tmp += 1
Problem p03523 (python)

Fixed submission:
#!/usr/bin/env python3
#CODE FESTIVAL 2017 Final A

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
lst = ['A','K','I','H','B','R']
for i in range(len(s)):
    if s[i] not in lst:
        print('NO')
        quit()
a = s.count('A')
t = ''
for i in range(len(s)):
    if s[i] != 'A':
        t += s[i]
if 'KIHBR' not in t or a > 4 or 'KIH' not in s:
    print('NO')
    quit()
if t.count('K') != 1 or t.count('I') != 1 or t.count('H') != 1 or t.count('B') != 1 or t.count('R') != 1:
    print('NO')
    quit()
for i in range(len(s)):
    if s[i] == 'K':
        if s[:i].count('A') > 1:
            print('NO')
            quit()
    if s[i] == 'H':
        for j in range(i+1,len(s)):
            if s[j] == 'B':
                if s[i:j].count('A') > 1:
                    print('NO')
                    quit()
    if s[i] == 'B':
        for j in range(i+1,len(s)):
            if s[j] == 'R':
                if s[i:j].count('A') > 1:
                    print('NO')
                    quit()
    if s[i] == 'R':
        if s[i:].count('A') > 1:
            print('NO')
            quit()
print('YES')

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
#CODE FESTIVAL 2017 Final A

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
lst = ['A','K','I','H','B','R']
for i in range(len(s)):
    if s[i] not in lst:
        print('NO')
        quit()
a = s.count('A')
t = ''
for i in range(len(s)):
    if s[i] != 'A':
        t += s[i]
if 'KIHBR' not in t or a > 4 or 'KIH' not in s:
    print('NO')
    quit()
if t.count('K') != 1 or t.count('I') != 1 or t.count('H') != 1 or t.count('B') != 1 or t.count('R') != 1:
    print('NO')
    quit()
a = 0
for i in range(len(s)):
    if s[i] == 'K':
        if s[:i].count('A') > 1:
            print('NO')
            quit()
    if s[i] == 'H':
        for j in range(i+1.len(s)):
            if s[j] == 'B':
                if s[i:j].count('A') > 1:
                    print('NO')
                    quit()
    if s[i] == 'B':
        for j in range(i+1,len(s)):
            if s[j] == 'R':
                if s[i:j].count('A') > 1:
                    print('NO')
                    quit()
    if s[i] == 'R':
        if s[i:].count('A') > 1:
            print('NO')
            quit()
print('YES')
Problem p03599 (python)

Fixed submission:
#!/usr/bin/env python3
#ABC74 C

a,b,c,d,e,f = map(int,input().split())

s = f//(100*a)
t = f//(100*b)
u = f//c
v = f//d

concentration = 0
solution = 0
suger = 0
for A in range(s+1):
    for B in range(t+1):
        for C in range(u+1):
            for D in range(v+1):
                if 100*a*A + 100*b*B + c*C + d*D <= f:
                    if (a*A+b*B)*e >= (c*C + d*D):
                        if 100*a*A + 100*b*B + c*C + d*D != 0:
                            if concentration < (c*C + d*D)/(100*a*A + 100*b*B + c*C + d*D):
                                concentration = (c*C + d*D)/(100*a*A + 100*b*B + c*C + d*D)
                                solution = 100*a*A + 100*b*B + c*C + d*D
                                suger = c*C + d*D
if solution == 0:
    solution = 100*a
print(solution,suger)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a, b, c, d, e, f = LI()

x = f // (100*a)
y = f // (100*b)

max_ = 0
max__ = 1
for i in range(x + 1):
    for j in range(y + 1):
        if i == 0 and j == 0:
            continue
        E = min((a*i + b*j)*e, f-(100*a*i + 100*b*j))
        E -= min(E % c, E % d)
        if max_ * (a*i + b*j) < E * max__:
            max_ = E
            max__ = a*i + b*j
            ans1 = (a*i + b*j) * 100 + E
            ans2 = E
print(ans1, ans2)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a, b, c, d, e, f = LI()

x = f // 100*a
y = f // 100*b

max_ = 0
for i in range(x + 1):
    for j in range(y + 1):
        if i == 0 and j == 0:
            continue
        E = min((i + j)*e, f-(100*i + 100*j))
        E -= min(E % c, E % d)
        if max_ < E / (i+j):
            max_ = E / (i+j)
            ans1 = (i + j) * 100 + E
            ans2 = E
print(ans1, ans2)
Problem p03674 (python)

Fixed submission:
#!/usr/bin/env python3
#ABC66 D

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def f(a, b):
    if b == 0: 
        return 1
    if b % 2 == 0:
        d = f(a, b // 2)
        return d * d % mod
    if b % 2 == 1:
        return (a * f(a, b - 1)) % mod


def comb(n,r):
    if n - r < 0:
        return 0
    return fact[n] * invfact[r] * invfact[n-r] % mod

n = I()
a = LI()
cnt = [0]*(n+1)
for i in range(n+1):
    if cnt[a[i]]:
        a = cnt[a[i]]
        b = i+1
        break
    else:
        cnt[a[i]] = i+1

fact = [1]*(n+2)
invfact = [1]*(n+2)
for i in range(1,n+2):
    fact[i] = i*fact[i-1] % mod
    invfact[i] = invfact[i-1] * f(i,mod-2) % mod

for i in range(n+1):
    res = 0
    res = (res + comb(n+1,i+1)) % mod
    res = (res - comb((a-1)+(n+1-b),i)) % mod
    print(res)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
#ABC66 D

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def comb(n,r):
    if n - r < 0:
        return 0
    return fact[n]*pow(fact[r],mod-2,mod)*pow(fact[n-r],mod-2,mod) % mod
n = I()
a = LI()
f = defaultdict(lambda : 0)
for i in range(n):
    if f[a[i]] == 0:
        f[a[i]] += 1
    else:
        x = a[i]
        break
fact = [0]*(n+2)
fact[0] = 1
for i in range(1,n+2):
    fact[i] = i*fact[i-1]

lst = []
for i in range(n+1):
    if a[i] == x:
        lst.append(i+1)
a,b = lst[0],lst[1]
for i in range(n+1):
    res = 0
    res = (res + comb(n+1,i+1)) % mod
    res = (res - comb((a-1)+(n+1-b),i)) % mod
    print(res)
Problem p03845 (python)

Fixed submission:
#!/usr/bin/env python3

N = int(input())
T = list(map(int,input().split()))
t = sum(T)
M = int(input())
P = []
X = []
for i in range(M):
    p,x = map(int,input().split())
    P.append(p)
    X.append(x)

for i in range(M):
    s = t - T[P[i]-1] + X[i]
    print(s)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

n = int(input())
t = list(map(int,input().split()))
m = int(input())
px = [list(map(int,input().split())) for _ in range(m)]

for p,x in px:
    T = t.copy()
    T[p-1] = x
    print(sum(T))
Problem p03846 (python)

Fixed submission:
#!/usr/bin/env python3
#ABC50 C

from collections import Counter
from operator import itemgetter

n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7

c = Counter(a)
c = list(c.items())
ccc = sorted(c,key = itemgetter(0))
if n % 2 == 1:
    k = 0
    for i,j in ccc:
        if j == 2 and i == 2*k:
            k += 1
            continue
        if j == 1 and i == 0:
            k += 1
            continue
        else:
            print(0)
            quit()
if n % 2 == 0:
    k = 0
    for i,j in ccc:
        if j == 2 and i == 2*k+1:
            k += 1
            continue
        else:
            print(0)
            quit()
print(2**(n//2) % mod)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
#ABC50 C

from collections import Counter
from operator import itemgetter

n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7

c = Counter(a)
c = list(c.items())
cc = sorted(c,key = itemgetter(1))
ccc = sorted(c,key = itemgetter(0))
if n % 2 == 1:
    if cc[1][1] != 2:
        print(0)
        quit()
    if cc[0][0] != 0:
        print(0)
        quit()
if n % 2 == 0:
    k = 0
    for i,j in ccc:
        if j == 2 and i % 2 == 1 and i == 2*k+1:
            k += 1
            continue
        else:
            print(0)
            quit()
print(2**(n//2))
Problem p03862 (python)

Fixed submission:
#!/usr/bin/env python3
#ABC48 C

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

b = a.copy()
if a[0] > x:
    b[0] = x
for i in range(n-1):
    if b[i] + b[i+1] > x:
        b[i+1] -= (b[i]+b[i+1] - x)
        if b[i+1] < 0:
            b[i] -= abs(b[i+1])
            b[i+1] += abs(b[i+1])
ans = 0
for i in range(n):
    ans += abs(b[i] - a[i])
print(ans)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
#ABC48 C

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

b = a.copy()
if a[0] > x:
    b[0] = x
for i in range(n-1):
    if b[i] + b[i+1] > x:
        b[i+1] -= (b[i]+b[i+1] - x)
        if b[i+1] < 0:
            b[i] -= abs(b[i+1])
            b[i+1] += abs(b[i+1])
ans = 0
for i in range(n):
    ans += abs(b[i] - a[i])
print(ans)
Problem p04013 (python)

Fixed submission:
#復習用
N, A = map(int, input().split())
X = list(map(lambda x: int(x) - A, input().split()))
maxn = max(max(X), A)
 
dp = [[0 for _ in range(2 * N * maxn + 1)] for _ in range(N + 1)]
dp[0][N * maxn] = 1
for i in range(N):
    for k in range(2 * N * maxn + 1):
        dp[i + 1][k] = dp[i][k]
        if 0 <= k - X[i] < 2 * N * maxn:
            dp[i + 1][k] += dp[i][k - X[i]] 
print(dp[N][N * maxn] - 1)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n, a = LI()
x = LI()

dp = [[[0] * (250+1) for _ in range(n+1)] for _ in range(n+1)]
dp[0][0][0] = 1
for i in range(n+1):
    xi = x[i-1]
    for j in range(250+1):
        for k in range(i):
            dp[i][k][j] = dp[i-1][k][j]
    for j in range(xi, 250+1):
        for k in range(1, i+1):
            dp[i][k][j] += dp[i-1][k-1][j-xi]
ans = 0
for i in range(1, n+1):
    ans += dp[-1][i][i*a]
print(ans)
Problem p02574 (python)

Fixed submission:
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
a=list(map(int,input().split()))
pc="pairwise coprime"
sc="setwise coprime"
nc="not coprime"

tmp=a[0]
for i in range(n):
    tmp=math.gcd(tmp,a[i])
if tmp!=1:
    print(nc)
    exit()

a.sort()

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

def factorize(N,prime_list):  # prime_listに素数のリストをぶち込め！
    lst = []
    for p in prime_list:
        if p * p > N:
            break
        while N % p == 0:
            N //= p
            lst.append(p)
    if N > 1:
        lst.append(N)
    return lst

plst=primes(1000000)
dic={}
for i in range(n):
    fac=factorize(a[i],plst)
    for j in fac:
        if j in dic:
            print(sc)
            exit()
    for j in fac:
        dic[j]=1
print(pc)

Buggy submission (verdict: Runtime Error):
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
a=list(map(int,input().split()))
pc="pairwise coprime"
sc="setwise coprime"
nc="not coprime"
a.sort()
tmp=a[0]

for i in range(n):
    tmp=math.gcd(tmp,a[i])
if tmp!=1:
    print(nc)
    exit()

dic=defaultdict(int)
for i in range(n):dic[a[i]]+=1

ans=0
for i in range(a[-1]):
    now=i+1
    cnt=0
    # print(i)
    while now<=a[-1]:
        cnt+=dic[a[i]]
        now+=i+1
    if cnt>1:
        ans=i+1

if ans!=1:
    print(sc)
else:
    print(pc)
# print(ans)
Problem p02606 (python)

Fixed submission:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

l,r,d=map(int,input().split())
print(r//d-(l-1)//d)

Buggy submission (verdict: Runtime Error):
def collatx(i):
    cnt=0
    while i!=1:
        cnt+=1
        if i%2==0:
            i//=2
        else:
            i*=3
            i+=1
    return cnt

def main():
    n=int(input())
    acc=0
    for i in range(1,n+1):
        acc+=collatx(i)
        acc%=1000000007
    print(acc)

if __name__ == "__main__":
    main()