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

Fixed submission:
n,m=map(int,input().split())
a=[1]*n
ans=set([1])
for i in range(m):
  x,y=map(int,input().split())
  if a[x-1]==0:continue
  else:
    a[x-1]-=1
    a[y-1]+=1
    if x in ans:
      ans.add(y)
      if a[x-1]==0:ans.remove(x)
print(len(ans))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[1]*n
ans=set([1])
for i in range(m):
  x,y=map(int,input().split())
  if a[x-1]==0:continue
  else:
    a[x-1]-=1
    a[y-1]+=1
    if x in ans:
      ans.add(y)
      if a[x-1]==0:ans.rempve(x)
print(len(ans))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
aru=1
a=[1]*n
ans=set([1])
for i in range(m):
  x,y=map(int,input().split())
  if a[x-1]==0:continue
  else:
    a[x-1]-=1
    a[y-1]+=1
    if aru==x:
      aru=y
      if a[x-1]!=0:
        ans.add(x)
      else:ans.remove(x)
print(len(ans))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
aru=1
a=[1]*n
ans=set()
for i in range(m):
  x,y=map(int,input().split())
  if a[x-1]==0:continue
  else:
    a[x-1]-=1
    a[y-1]+=1
    if aru==x:
      aru=y
      if a[x-1]!=0:
        ans.add(x)
      else:ans.remove(x)
print(len(ans))
Problem p02573 (python)

Fixed submission:
from networkx import*
_,*t=map(str.split,open(0))
print(max(1,1,*map(len,connected_components(Graph(t)))))

Buggy submission (verdict: Runtime Error):
from networkx import*
_,*t=map(str.split,open(0))
print(max(1,*map(len,connected_components(Graph(t)))))

Buggy submission (verdict: Runtime Error):
from networkx import*
n, m = map(int, input().split())
edges = [tuple(map(int, input().split())) for _ in range(m)]
G = Graph()
#G.add_nodes_from(range(1, n+1))
G.add_edges_from(edges)
ccs = connected_components(G)
ans = max(map(len, ccs))
print(ans)

Buggy submission (verdict: Runtime Error):
from networkx import*
#print(max(map(len,connected_components(Graph(map(str.split,[*open(0)][1:]))))))
#(n,m),*t=map(str.split,open(0));print(max(map(len,connected_components(Graph(t[:int(m)])))))
n, m = map(int, input().split())
edges = [tuple(map(int, input().split())) for _ in range(m)]
G = Graph(range(1, n+1))
G.add_edges_from(edges)
ccs = connected_components(G)
ans = max(map(len, ccs))
print(ans)

Buggy submission (verdict: Runtime Error):
from networkx import*
#print(max(map(len,connected_components(Graph(map(str.split,[*open(0)][1:]))))))
#(n,m),*t=map(str.split,open(0));print(max(map(len,connected_components(Graph(t[:int(m)])))))
n, m = map(int, input().split())
edges = [tuple(map(int, input().split())) for _ in range(m)]
G = Graph(edges)
ccs = connected_components(G)
ans = max(map(len, ccs))
print(ans)

Buggy submission (verdict: Runtime Error):
from networkx import*
f=lambda:tuple(map(int,input().split()))
n,m=f()
print(max(map(len,connected_components(DiGraph(f()for _ in range(m))))))

Buggy submission (verdict: Runtime Error):
from networkx import*
f=lambda:tuple(map(int,input().split()))
n,m=f()
print(max(map(len,connected_components(Graph(f()for _ in range(m))))))

Buggy submission (verdict: Runtime Error):
from networkx import*
f=lambda:map(int,input().split())
n,m=f()
print(max(map(len,connected_components(f()for _ in range(m)))))

Buggy submission (verdict: Runtime Error):
from networkx import*
(n,m),*t=map(str.split,open(0))
print(max(map(len,connected_components(Graph(t[:int(m)])))))

Buggy submission (verdict: Runtime Error):
from networkx import*
print(max(map(len,connected_components(Graph(map(str.split,[*open(0)][1:]))))))
Problem p02616 (python)

Fixed submission:
MOD = 10**9+7
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if all(ai < 0 for ai in a):
    ans = 1
    if k & 1:
        for ai in a[-k:]:
            ans = ans * ai % MOD
    else:
        for ai in a[:k]:
            ans = ans * ai % MOD
elif n == k:
    ans = 1
    for ai in a:
        ans = ans * ai % MOD
else:
    ans = 1
    a.sort(key=abs, reverse=True)
    cneg = sum(ai < 0 for ai in a[:k])
    cpos = sum(ai >= 0 for ai in a[:k])
    if cneg & 1 == 0:
        for ai in a[:k]:
            ans = ans * ai % MOD
    else:
        left = []
        r = k
        for ai in a:
            if ai < 0 and cneg > 1:
                ans = ans * ai % MOD
                cneg -= 1
                r -= 1
            elif ai >= 0 and cpos > 1:
                ans = ans * ai % MOD
                cpos -= 1
                r -= 1
            else:
                left.append(ai)
        ngs = [ai for ai in left if ai < 0]
        pss = [ai for ai in left if ai >= 0]
        if r == 1:
            ans = ans * pss[0] % MOD
        else:
            t = -1001001001001001001001
            if len(ngs) >= 2:
                t = ngs[0] * ngs[1]
            if len(pss) >= 2:
                t = max(t, pss[0] * pss[1])
            ans = ans * t % MOD
print(ans)

Buggy submission (verdict: Runtime Error):
MOD = 10**9+7
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if all(ai < 0 for ai in a):
    ans = 1
    if k & 1:
        for ai in a[-k:]:
            ans = ans * ai % MOD
    else:
        for ai in a[:k]:
            ans = ans * ai % MOD
elif n == k:
    ans = 1
    for ai in a:
        ans = ans * ai % MOD
else:
    ans = 1
    a.sort(key=abs, reverse=True)
    cneg = sum(ai < 0 for ai in a[:k])
    if cneg & 1 == 0:
        for ai in a[:k]:
            ans = ans * ai % MOD
    else:
        left = []
        cnt = 0
        for i in range(len(a)):
            if cneg == 1:
                if i < k - 1 and a[i] >= 0:
                    ans = ans * ai % MOD
                    cnt += 1
                else:
                    left.append(a[i])
            else:
                ans = ans * a[i] % MOD
                cnt += 1
                if a[i] < 0:
                    cneg -= 1
        r = k - cnt
        if r == 1:
            ans = ans * [ai for ai in left if ai >= 0][0] % MOD
        else:
            ngs = [ai for ai in left if ai < 0]
            pss = [ai for ai in left if ai >= 0]
            t = -1001001001001001001001
            if len(ngs) >= 2:
                t = ngs[0] * ngs[1]
            if len(pss) >= 2:
                t = max(t, pss[0] * pss[1])
            ans = ans * t % MOD
print(ans)
Problem p02632 (python)

Fixed submission:
mod = 10**9 + 7

fact_range = 10**6 * 2
facts = [1] * (fact_range + 1)
for i in range(0, fact_range):
    facts[i+1] = facts[i] * (i + 1) % mod

ifacts = [1] * (fact_range + 1)
ifacts[fact_range] = pow(facts[fact_range], mod - 2, mod)
for i in range(fact_range, 0, -1):
    ifacts[i-1] = ifacts[i] * i % mod

def comb(n, k):
    if k < 0 or n < k:
        return 0
    else:
        return facts[n] * ifacts[n-k] % mod * ifacts[k] % mod

k = int(input())
s = len(input())
ans = 0
for a in range(k + 1):
    ans += pow(25, a, mod) * pow(26, k-a, mod) % mod * comb(s-1+a, a)
    ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
mod = 10**9 + 7

fact_range = 10**6
facts = [1] * (fact_range + 1)
for i in range(0, fact_range):
    facts[i+1] = facts[i] * (i + 1) % mod

ifacts = [1] * (fact_range + 1)
ifacts[fact_range] = pow(facts[fact_range], mod - 2, mod)
for i in range(fact_range, 0, -1):
    ifacts[i-1] = ifacts[i] * i % mod

def comb(n, k):
    if k < 0 or n < k:
        return 0
    else:
        return facts[n] * ifacts[n-k] % mod * ifacts[k] % mod

k = int(input())
s = len(input())
ans = 0
for a in range(k + 1):
    ans += pow(25, a, mod) * pow(26, k-a, mod) % mod * comb(s-1+a, a)
    ans %= mod
print(ans)
Problem p02642 (python)

Fixed submission:
d = [0] * (10**6 + 1)
n = int(input())
for a in map(int, input().split()):
    d[a] += 1
ans = 0
for i in range(1, 10**6 + 1):
    if d[i] == 1:
        ans += 1
    if d[i] > 0:
        for j in range(i, 10**6 + 1, i):
            d[j] = 0
print(ans)

Buggy submission (verdict: Runtime Error):
d=[i:=0]*8**7
for j in[*open(0)][1].split():d[int(j)]+=1
while i<1e6:
 i+=1;j=i
 while j<1e6:j+=i;d[j]*=d[i]<1
print(d.count(1))

Buggy submission (verdict: Runtime Error):
d=[i:=0]*8**7
for j in[*open(0)][1].split():d[int(j)]+=1
while i<1e6:
 i+=1;j=i
 while j<1e6:j+=i;d[j]*=d[i]<1
print(d.count(1))
Problem p02733 (python)

Fixed submission:
x,*s=open(0)
h,w,k,*m=map(int,x.split())
for b in range(512):
 r=t=j=0;d=[0]*h
 while j<w:
  i=c=0
  while h-i:
   d[c]+=s[i][j]>'0';x=d[c]>k
   if(t<j)&x:r+=1;t=j;d=[0]*h;break
   r+=x*h*w;c+=b>>i&1;i+=1
  else:j+=1
 while b:r+=b&1;b>>=1
 m+=r,
print(min(m))

Buggy submission (verdict: Runtime Error):
x,*s=open(0)
h,w,k=map(int,x.split())
p=lambda b:b and(b&1)+p(b>>1)
g=lambda b,j,t,d,i=0,c=0:j==w and~p(b)or i==h and g(b,j+1,t,d)or d.__setitem__(c,d[c]+int(s[i][j]))or d[c]>k and(t<j and-1+g(b,j,j,[0]*h)or h*w)or g(b,j,t,d,i+1,c+(b>>i&1))
print(min(~g(b,0,0,[0]*h)for b in range(512)))
Problem p02758 (python)

Fixed submission:
# hmm...
from sys import setrecursionlimit
setrecursionlimit(10000000)

n = int(input())
xds = [tuple(map(int, input().split())) for _ in range(n)]
xds.sort()

xds.insert(0, (-1000000001, 2000000004))
n += 1

def make_blocks(i):
    x, d = xds[i]
    right = x + d
    res = []
    nexti = i + 1
    while(nexti < n):
        xn, dn = xds[nexti]
        if xn < right:
            l, lasti = make_blocks(nexti)
            res.append(l)
            nexti = lasti + 1
        else:
            return res, nexti - 1
    return res, n - 1

l, _ = make_blocks(0)

def count(l):
    ans = 1
    for ll in l:
        ans = ans * (1 + count(ll)) % 998244353
    return ans

print(count(l))

Buggy submission (verdict: Runtime Error):
n = int(input())
xds = [tuple(map(int, input().split())) for _ in range(n)]
xds.sort()

xds.insert(0, (-1000000001, 2000000004))
n += 1

def make_blocks(i):
    x, d = xds[i]
    right = x + d
    res = []
    nexti = i + 1
    while(nexti < n):
        xn, dn = xds[nexti]
        if xn < right:
            l, lasti = make_blocks(nexti)
            res.append(l)
            nexti = lasti + 1
        else:
            return res, nexti - 1
    return res, n - 1

l, _ = make_blocks(0)

def count(l):
    ans = 1
    for ll in l:
        ans = ans * (1 + count(ll)) % 998244353
    return ans

print(count(l))

Buggy submission (verdict: Runtime Error):
n = int(input())
xds = [tuple(map(int, input().split())) for _ in range(n)]
xds.sort()

xds.insert(0, (-1000000001, 2000000004))
n += 1

def make_blocks(i):
    x, d = xds[i]
    right = x + d
    res = []
    nexti = i + 1
    while(nexti < n):
        xn, dn = xds[nexti]
        if xn < right:
            l, lasti = make_blocks(nexti)
            res.append(l)
            nexti = lasti + 1
        else:
            return res, nexti - 1
    return res, n - 1

l, _ = make_blocks(0)

def count(l):
    ans = 1
    for ll in l:
        ans = ans * (1 + count(ll)) % 998244353
    return ans

print(count(l))

Buggy submission (verdict: Runtime Error):
n = int(input())
xds = [tuple(map(int, input().split())) for _ in range(n)]
xds.sort()

xds.insert(0, (-1000000001, 2000000004))
n += 1

def make_blocks(i):
    x, d = xds[i]
    right = x + d
    res = []
    nexti = i + 1
    while(nexti < n):
        xn, dn = xds[nexti]
        if xn < right:
            l, lasti = make_blocks(nexti)
            res.append(l)
            nexti = lasti + 1
        else:
            return res, nexti - 1
    return res, n - 1

l, _ = make_blocks(0)

def count(l):
    ans = 1
    for ll in l:
        ans *= 1 + count(ll)
    return ans

print(count(l))
Problem p02882 (python)

Fixed submission:
from math import atan, pi
a, b, x = map(int, input().split())
if 2*x <= a**2*b:
    print(180 * atan(a * b ** 2 / (2 * x)) / pi)
else:
    print(180 * atan(2*(a**2*b-x)/a**3)/pi)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
f.sort(reverse=True)
costs = [(ai * fi, fi) for ai, fi in zip(a, f)]
costs.sort(reverse=True)
# l impossible, r ok
l, r = -1, costs[0][0]
while(r - l > 1):
    c = (l + r) // 2
    train = 0
    for cost, step in costs:
        if cost > c:
            train += (cost - c + step - 1) // step
    if train <= k:
        r = c
    else:
        l = c
print(r)
Problem p02898 (python)

Fixed submission:
n, k = map(int,input().split())
print(len(list(filter(lambda hi: hi >= k, map(int,input().split())))))

Buggy submission (verdict: Runtime Error):
n, k = map(int,input().split())
print(len([*filter(lambda hi: hi >= k, map(int,input().split()))]))
Problem p02985 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)

def iig(vn, en):
    res = [[] for _ in range(vn)]
    for _ in range(en):
        ai, bi = map(lambda x: int(x) - 1, input().split())
        res[ai].append(bi)
        res[bi].append(ai)
    return res

def sep_pc(graph, root=0):
    parent = [-1 for _ in range(n)]
    children = [None for _ in range(n)]
    def f(x, p):
        parent[x] = p
        children[x] = [y for y in graph[x] if y != p]
        for y in graph[x]:
            if y != p:
                f(y, x)
        return
    f(root, -1)
    return parent, children

def itree(n, root=0):
    return sep_pc(iig(n, n - 1), root)

mod = 10**9 + 7

fact_range = 10**5 + 3
facts = [1] * (fact_range + 1)
for i in range(0, fact_range):
    facts[i+1] = facts[i] * (i + 1) % mod

ifacts = [1] * (fact_range + 1)
ifacts[fact_range] = pow(facts[fact_range], mod - 2, mod)
for i in range(fact_range, 0, -1):
    ifacts[i-1] = ifacts[i] * i % mod

n, k = map(int, input().split())
p, c = itree(n)
def dfs(i=0, cur=k, avail=k-1):
    sz = len(c[i])
    if avail <= 0 and sz > 0 or sz > avail:
        return 0
    cur = cur * facts[avail] * ifacts[avail - sz] % mod
    for u in c[i]:
        cur = dfs(u, cur, k - 2)
    return cur
print(dfs())

Buggy submission (verdict: Runtime Error):
def iig(vn, en):
    res = [[] for _ in range(vn)]
    for _ in range(en):
        ai, bi = map(lambda x: int(x) - 1, input().split())
        res[ai].append(bi)
        res[bi].append(ai)
    return res

def sep_pc(graph, root=0):
    parent = [-1 for _ in range(n)]
    children = [None for _ in range(n)]
    def f(x, p):
        parent[x] = p
        children[x] = [y for y in graph[x] if y != p]
        for y in graph[x]:
            if y != p:
                f(y, x)
        return
    f(root, -1)
    return parent, children

def itree(n, root=0):
    return sep_pc(iig(n, n - 1), root)

mod = 10**9 + 7

fact_range = 10**5 + 3
facts = [1] * (fact_range + 1)
for i in range(0, fact_range):
    facts[i+1] = facts[i] * (i + 1) % mod

ifacts = [1] * (fact_range + 1)
ifacts[fact_range] = pow(facts[fact_range], mod - 2, mod)
for i in range(fact_range, 0, -1):
    ifacts[i-1] = ifacts[i] * i % mod

n, k = map(int, input().split())
p, c = itree(n)
def dfs(i=0, cur=k, avail=k-1):
    sz = len(c[i])
    if avail <= 0 and sz > 0 or sz > avail:
        return 0
    cur = cur * facts[avail] * ifacts[avail - sz] % mod
    for u in c[i]:
        cur = dfs(u, cur, k - 2)
    return cur
print(dfs())
Problem p03044 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
n = int(input())
to = [[] for _ in range(n)]
for _ in range(n - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    to[u].append((v, w))
    to[v].append((u, w))
ans = [-1] * n
def dfs(u=0, c=0, parent=-1):
    ans[u] = c
    for v, w in to[u]:
        if v == parent:
            continue
        dfs(v, (c + w) & 1, u)

dfs()
print(*ans, sep='\n')

Buggy submission (verdict: Runtime Error):
n = int(input())
to = [[] for _ in range(n)]
for _ in range(n - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    to[u].append((v, w))
    to[v].append((u, w))
ans = [-1] * n
def dfs(u=0, c=0, parent=-1):
    ans[u] = c
    for v, w in to[u]:
        if v == parent:
            continue
        dfs(v, (c + w) & 1, u)

dfs()
print(*ans, sep='\n')
Problem p03249 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
n = int(input())
d = [int(input()) for _ in range(n)]
r = {v: i for i, v in enumerate(d)}
sz = [1] * n
dsorted = sorted(((di, i) for i, di in enumerate(d)), reverse=True)
ans = []
to = [[] for _ in range(n)]
for di, i in dsorted[:n-1]:
    nd = di + (sz[i] - 1) - (n - 2 - (sz[i] - 1))
    if not nd in r:
        print(-1)
        exit()
    p = r[nd]
    to[p].append(i)
    sz[p] += sz[i]
    ans.append((i+1, p+1))

root = dsorted[-1][1]
def dfs(u, cur=0):
    rv = cur
    for v in to[u]:
        rv += dfs(v, cur + 1)
    return rv

if dfs(root) != d[root]:
    print(-1)
    exit()

for u, v in ans:
    print(u, v)

Buggy submission (verdict: Runtime Error):
n = int(input())
d = [int(input()) for _ in range(n)]
r = {v: i for i, v in enumerate(d)}
sz = [1] * n
dsorted = sorted(((di, i) for i, di in enumerate(d)), reverse=True)
ans = []
to = [[] for _ in range(n)]
for di, i in dsorted[:n-1]:
    nd = di + (sz[i] - 1) - (n - 2 - (sz[i] - 1))
    if not nd in r:
        print(-1)
        exit()
    p = r[nd]
    to[p].append(i)
    sz[p] += sz[i]
    ans.append((i+1, p+1))

root = dsorted[-1][1]
def dfs(u, cur=0):
    rv = cur
    for v in to[u]:
        rv += dfs(v, cur + 1)
    return rv

if dfs(root) != d[root]:
    print(-1)
    exit()

for u, v in ans:
    print(u, v)
Problem p03547 (python)

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

if a < b:
  print('<')
elif a>b:
  print('>')
else:
  print('=')

Buggy submission (verdict: Runtime Error):
a, b = input().split()
if a < b:
    print('<')
elsif a > b:
 	print('>')
else:
  	print('=')

Buggy submission (verdict: Runtime Error):
a, b = input().split()
if a < b :
  print('<')
elsif a > b:
  print('>')
else :
  print('=')

Buggy submission (verdict: Runtime Error):
a, b = input().split()

if ( a < b) :
    print('<')
elsif (a > b):
    print('>')
else :
    print('=')

Buggy submission (verdict: Runtime Error):
a,b=input().split()
if (a<b):
    print("<")
elsif (a>b):
    print(">")
else:
    print("=")

Buggy submission (verdict: Runtime Error):
a,b=input().split()
if (a<b):
  print("<")
elsif (a>b):
  print(">")
else:
  print("=")
Problem p03555 (python)

Fixed submission:
s=input()
t=input()
t=t[::-1]
if s==t:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
s.reverse()

if s==t :
  print("YES")
else:
  print("NO")
Problem p02574 (python)

Fixed submission:
import math

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

dp=[0 for _ in range(1000001)]

for d in a:
  dp[d]+=1
  
ch1=0
for i in  range(2,1000001):
  ch=0
  x=i
  while x<=1000000:
    ch+=dp[x]
    x+=i
  if ch>1:
    ch1+=1
    
if ch1==0:
  print('pairwise coprime')
  
else:
  g=a[0]
  for h in range(1,n):
    g=math.gcd(g,a[h])
    
  if g==1:
    print('setwise coprime')
    
  else:
    print('not coprime')

Buggy submission (verdict: Runtime Error):
import math
import copy

n=int(input())
a=list(map(int,input().split()))
ch5=0
for  M in a:
  if M==1:
    ch5+=1
    a.remove(M)
if ch5>0:
  a.append(1)
B=copy.deepcopy(a)


dp=[0 for _ in range(1000000+1)]

sosuu = [2]
A = 1000
for L in range(3, A, 2): # 2 以外の素数は奇数なので
    for L2 in sosuu:
        if L % L2 == 0:
            break # 素数でないことがわかったらそれ以上ループする必要はない
    else: # break で抜けることがなかったら L は素数（Python 特有の制御構文）
        sosuu.append(L)
        

if len(a)>80000:
  g=a[0]
  for h in range(1,n):
    g=math.gcd(g,a[h])
    
  if g==1:
    print('setwise coprime')
    
  else:
    print('not coprime')
  
  

else:
  ch1=0
  ch3=0
  for w in sosuu:
    ch2=0
    for q in range(n):
      if B[q]%w==0:
        ch2+=1
        S=B[q]
        while S%w==0:
          S=S//w
        B[q]=S
    if ch2>1:
      ch3+=1
  d={}
  ch4=0
  for u in B:
      if u>1000:
        if u not in d:
          d[u]=0
        else:
          ch4+=1
  if ch3==0 and ch4==0:
    print('pairwise coprime')
    
      
  
  
    
  else:
    g=a[0]
    for h in range(1,n):
      g=math.gcd(g,a[h])
    
    if g==1:
      print('setwise coprime')
    
    else:
      print('not coprime')

Buggy submission (verdict: Runtime Error):
import math
import copy

n=int(input())
a=list(map(int,input().split()))
ch5=0
if M in a:
  if M==1:
    ch5+=1
    a.remove(M)
if ch5>0:
  a.append(1)
B=copy.deepcopy(a)


dp=[0 for _ in range(1000000+1)]

sosuu = [2]
A = 1000
for L in range(3, A, 2): # 2 以外の素数は奇数なので
    for L2 in sosuu:
        if L % L2 == 0:
            break # 素数でないことがわかったらそれ以上ループする必要はない
    else: # break で抜けることがなかったら L は素数（Python 特有の制御構文）
        sosuu.append(L)
        

if len(a)>80000:
  g=a[0]
  for h in range(1,n):
    g=math.gcd(g,a[h])
    
  if g==1:
    print('setwise coprime')
    
  else:
    print('not coprime')
  
  

else:
  ch1=0
  ch3=0
  for w in sosuu:
    ch2=0
    for q in range(n):
      if B[q]%w==0:
        ch2+=1
        S=B[q]
        while S%w==0:
          S=S//w
        B[q]=S
    if ch2>1:
      ch3+=1
  d={}
  ch4=0
  for u in B:
      if u>1000:
        if u not in d:
          d[u]=0
        else:
          ch4+=1
  if ch3==0 and ch4==0:
    print('pairwise coprime')
    
      
  
  
    
  else:
    g=a[0]
    for h in range(1,n):
      g=math.gcd(g,a[h])
    
    if g==1:
      print('setwise coprime')
    
    else:
      print('not coprime')
Problem p02576 (python)

Fixed submission:
n,x,t=map(int,input().split())

if n%x==0:
  print(t*(n//x))
  
else:
  print(t*(n//x+1))

Buggy submission (verdict: Runtime Error):
n,x,t=map(int,input().split())

if n%x==0:
  print(t*(n//x))
  
esle:
  print(t*(n//x+1))
Problem p02618 (python)

Fixed submission:
d=int(input())
a=[]
for x in range(d+1):
  b=list(map(int,input().split()))
  a.append(b)

import random
for n in range(d):
  print(random.randint(1,26))

Buggy submission (verdict: Runtime Error):
d=int(input())
a=[]
for x in range(d+1):
  b=list(map(int,input().split()))
  a.append(b)

for n in range(d):
  print(random.randint(1:27))
Problem p02640 (python)

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

if y%2 ==1:
  print("No")
elif 2*x > y:
  print("No")
elif 4*x < y:
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
n,d=map(int,input().split())
ans=0
for _ in range(n):
  a,b=map(int,input().split())
  if (a*a+b*b) <= d*d:
    ans+=1
    
print(ans)
Problem p02641 (python)

Fixed submission:
x,n=map(int,input().split())

if n==0:
  print(x)
  
else:
  a=list(map(int,input().split()))

  for i in range(100):
    if x-i not in a:
      ans=x-i
      break
    elif x+i not in a:
      ans=x+i
      break
    
  print(ans)

Buggy submission (verdict: Runtime Error):
x,n=map(int,input().split())
try:
  a=list(map(int,input().split()))
except:
  rr=0
  





if n==0:
  print(x)
  
a=sorted(a)

if x<a[0]:
  print(x)
if x>a[-1]:
  print(x)
  
b=list(range((a[0]),(a[-1]+1)))

for n in range(n):
  b.remove(a[n])
  
f=len(b)


d=abs(x-int(b[0]))
ans=b[0]

for n in range(f):
  c=abs(x-int(b[n]))
  if d>c:
    ans=b[n]
    d=c
  
print(ans)
Problem p02658 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a.sort()

ans=1
for i in a:
  ans=ans*i
  if ans>(10**18):
    ans=-1
    break
    
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))

ans=1
for i in a:
  ans=ans*i
  if str(ans)>18:
    ans=-1
    break
    
print(ans)
Problem p02756 (python)

Fixed submission:
s=input()
q=int(input())
h=0
m=''
u=''
for _  in range(q):
  d=input()
  if '2' in d:
    a,b,c=map(str,d.split())
    if b=='1':
      if h%2==0:
        m+=c
      else:
        u+=c
        
    else:
      if h%2==0:
        u+=c
      else:
        m+=c
        
  else:
    h+=1
    
M=list(m)
G=list(reversed(M))
GG=''.join(G)
s=GG+s+u
if h%2==0:
  print(s)
else:
  f=list(s)
  g=list(reversed(f))
  print(''.join(g))

Buggy submission (verdict: Runtime Error):
s=input()
q=int(input())
h=0
m=''
u=''
for _  in range(q):
  d=input()
  if '2' in d:
    a,b,c=map(str,d.split())
    if b=='1':
      if h%2==0:
        u+=c
      else:
        m+=c
        
    else:
      if h%2==0:
        m+=c
      else:
        u+=c
        
  else:
    h+=1
    
M=list(m)
G=list(reversed(M))
s=G+s+u
if h%2==0:
  print(s)
else:
  f=list(s)
  g=list(reversed(f))
  print(''.join(g))