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

Fixed submission:
from math import gcd
n, k = map(int, input().split())
a = list(map(int, input().split()))
if max(a) < k:
    print("IMPOSSIBLE")
    exit()
if k in a:
    print("POSSIBLE")
    exit()
a_gcd = a[0]
for i in range(1, n):
    a_gcd = gcd(a_gcd, a[i])

if k % a_gcd == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))
a1 = []
if max(a) < k:
    print("IMPOSSIBLE")
    exit()

for i in range(1, n):
    a1.append(abs(a[i-1]-a[i]))
a1 = sorted(a1)

for i in range(1, n-1):
    if a1[i] % a1[0] != 0:
        print("POSSIBLE")
        break
else:
    if k % a1[0] == 0 or a1[0] == 1:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
Problem p03814 (python)

Fixed submission:
s=list(map(str,input()))
#print(s)
for i in range(len(s)):
    if s[i]=='A':
        sa=i
        break

for i in range(len(s)-1,-1,-1):
    if s[i]=='Z':
        zg=i
        break

print(zg-sa+1)

Buggy submission (verdict: Runtime Error):
s=list(map(str,input()))
#print(s)
ans=0
for i in range(len(s)):
    if s[i]=='A':
        sa=i
    if s[i]=='Z':
        #print("VBHJ")
        ans=max(ans,i-sa+1)

print(ans)
Problem p03838 (python)

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

ans=abs(x)-abs(y)
#print(ans)
if ans==0:
    if x==y:
        print(ans)
    else:
        print(1)
elif ans<0:
   # print("SDFGH")
    if x<0 and y<0 :
        print(abs(ans)+2)
    elif 0<=x and 0<=y:
        print(abs(ans))
    else:
        print(abs(ans)+1)
else:
    if x<=0 and y<=0:
        print(abs(ans))
    elif 0<x and 0<y:
        print(abs(ans)+2)
    else: 
        
        print(abs(ans)+1)

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

ans=abs(x)-abs(y)

if ans==0:
    if x==y:
        print(ans)
    else:
        print(1)
elif ans<0:
    if x<0 and y<0 :
        print(ans+2)
    else:
        print(ans)
else:
    if x<=0 and y=<0:
        print(abs(ans))
    elif 0<x and 0<y:
        print(abs(ans)+2)
    else: 
        print(abs(ans)+1)
Problem p03845 (python)

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

ans=sum(t)

for i in range(m):
    print(ans-t[px[i][0]-1]+px[i][1])

Buggy submission (verdict: Runtime Error):
n=int(input())
t=list(map(int,input().split()))
m=int(input())
px=[list(map(int,input().split())) for _ in range(m)]

ans=sum(t)-t[0]-t[1]

for i in range(m):
    
    print(ans+sum(px[i]))
Problem p03999 (python)

Fixed submission:
s=str(input())
n=len(s)-1#間間なので-1
#print(s,n)
#print(xy)
bit=[]#1が＋入れる0がいれない
ans=0
c=0
count=[]
def bit_search(bit):
    #print("DFGHNM")
    count=[]#分けたやつを補完するやつ
    global ans
    c=0
    if len(bit)==n:#2**n文の組み合わせを調べる加圧10を交互に入れるためのif
        for i in range(n):
            if bit[i]==1:
                #print(int(s[c:i+1]))
                count.append(int(s[c:i+1]))
                c=i+1#ここの＋１大事
        #print(int(s[c:n+1]))
        count.append(int(s[c:n+1]))
        ans+=sum(count)
        #print(ans,sum(count),bit,c)
        return 
    else:
       #再起化することによって最初にbitの配列を作る必要性をなくした
        #print(bit)
        bit_search(bit+[0])
        bit_search(bit+[1])

bit_search(bit)
print(ans)

Buggy submission (verdict: Runtime Error):
s=str(input())
n=len(s)-1
#print(s,n)
#print(xy)
bit=[]#1が正直0が嘘
ans=0
def bit_search(bit):
    global ans
    count=[]
    c=0
    if len(bit)==n:#2**n文の組み合わせを調べる加圧10を交互に入れるためのif
        for i in range(n):
            if bit[i]==1:
                count.append(int(s[c:i]))
                c=i
        count.append(int(s[c:n]))
        ans+=sum(count)
    else:
       #再起化することによって最初にbitの配列を作る必要性をなくした
        bit_search(bit+[0])
        bit_search(bit+[1])
bit_search(bit)
print(ans)
Problem p02608 (python)

Fixed submission:
n = int(input())
ans = [0 for _ in range(10001)]
for i in range(1, 100):
    for j in range(1, 100):
        for k in range(1, 100):
            summ = i**2 + j**2 + k**2 + i * j + j * k + k * i
            if summ < 10001:
                ans[summ] += 1

for i in range(1, n + 1):
    print(ans[i])
# print(ans[20])

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = [0 for _ in range(1001)]
for i in range(1, 40):
    for j in range(1, 40):
        for k in range(1, 40):
            summ = i**2 + j**2 + k**2 + i * j + j * k + k * i
            if summ < 1001:
                ans[summ] += 1

for i in range(1, n):
    print(ans[i])
Problem p02660 (python)

Fixed submission:
import math


# 素数の判定
def is_prime(n):
    if n == 1:
        return 0

    for k in range(2, int(math.sqrt(n)) + 1):
        chk = False
        while (n % k == 0):
            chk = True
            n /= k
            if k not in check:
                check[k] = 1
            else:
                check[k] += 1
        if chk:
            return n
    if n in check:
        return 0
    else:
        check[n] = 1
        return 1


check = {}
n = int(input())
if n == 1:
    print(0)
else:
    while (1):
        n = is_prime(n)
        if n == 0:
            break
    ans = 0
    for k, v in check.items():
        for i in range(1, 50):
            v -= i
            if v < 0:
                break
            else:
                ans += 1
    # print(check)
    print(ans)

Buggy submission (verdict: Runtime Error):
import math


# 素数の判定
def is_prime(n):
    if n == 1:
        return 0

    for k in range(2, int(math.sqrt(n)) + 1):
        chk = False
        while (n % k == 0):
            chk = True
            n /= k
            if k not in check:
                check[k] = 1
            else:
                check[k] += 1
        if chk:
            return n
    if n in check:
        return 0
    else:
        check[n] = 1
        return 1


check = {}
n = int(input())
if n == 1:
    print(0)
else:
    while (1):
        n = is_prime(n)
        if n == 0:
            break
    ans = 0
    for k, v in check.items():
        for i in range(1, 50):
            v -= i
            if v < 0:
                break
            else:
                ans += 1
# print(check)
print(ans)
Problem p02690 (python)

Fixed submission:
x = int(input())

for i in range(1000):
    for j in range(1000):
        if i**5 - j**5 == x:
            print(i,j)
            exit()
        elif i**5 - (-j)**5 == x:
            print(i,-j)
            exit()

Buggy submission (verdict: Runtime Error):
x = int(input())
det = 1001001001
for i in range(1000000):
    if abs(i**5 - x) < abs(det):
        det = i**5 - x
        a = i
    else:
        break

if det < 0:
    for i in range(-1, -1000000, -1):
        if i**5 == det:
            b = i
            break
elif det == 0:
    b = 0
else:
    for i in range(1000000):
        if i**5 == det:
            b = i
            break


print(a, b)
Problem p02900 (python)

Fixed submission:
# coding: utf-8
import sys
import math
import fractions
input = sys.stdin.readline


def is_prime(n):
    if n == 1:
        return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


a, b = map(int, input().split())
x = fractions.gcd(a, b)
check_list = []
i = 2
"""
while (1):
    flag = False
    if i > x:
        break
    while(x % i == 0):
        x /= i
        flag = True

    if flag == True:
        check_list.append(i)
    i += 1
"""
while x % 2 == 0:
    check_list.append(2)
    x //= 2
i = 3
while i * i <= x:
    if x % i == 0:
        check_list.append(i)
        x //= i
    else:
        i += 2
if x != 1:
    check_list.append(x)

print(len(set(check_list))+1)

# print(check_list)
"""
ans = 1
for check in check_list:
    if is_prime(check):
        ans += 1

print(ans)
"""

Buggy submission (verdict: Runtime Error):
# coding: utf-8
from fractions import gcd
import sys
input = sys.stdin.readline

x, y = map(int, input().split())
a = min(x, y)
b = max(x, y)

check = str(bin(a ^ b))
# print(check)
ans = 0

for i in range(1, len(bin(a)) - 2):
    print(i)
    if check[-i] == '1':
        ans += 1
if ans == 0:
    ans += 1
print(ans)
print(len(bin(a)))
Problem p02909 (python)

Fixed submission:
s = input()

if s == 'Sunny':
    print('Cloudy')
elif s == 'Cloudy':
    print('Rainy')
else:
    print('Sunny')

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)


def coupon(i, m, pay):
    if m == 0 or i == n:
        return sum(l[i:])
    for maisuu in range(1, 31):
        #print("{}に{}まい使う".format(i, maisuu))
        now = l[i] // (2 ** maisuu)
        pay = min(pay, coupon(
            i + 1, m - maisuu, pay) + now)
        if now == 0:
            break

    return pay


n, m = map(int, input().split())

l = [int(c) for c in input().split()]
l.sort()
l.reverse()
max_pay = sum(l)
# print(l)


print(coupon(0, m, max_pay))
Problem p03244 (python)

Fixed submission:
import sys
from collections import defaultdict
input = lambda: sys.stdin.readline().rstrip()
n = int(input())
tmp = list(map(int, input().split()))
# 偶奇で分けて辞書作る
odd = defaultdict(int)
even = defaultdict(int)
for i in range(n):
    if i % 2 == 0:
        odd[tmp[i]] += 1
    else:
        even[tmp[i]] += 1

# 降順ソート
odd = sorted(odd.items(), key=lambda x: -x[1])
even = sorted(even.items(), key=lambda x: -x[1])
# 各配列の最頻，二番目を取ってくる
o1 = odd[0]
e1 = even[0]
# 1種類しかない場合は適当に二番目を作成
if len(odd) != 1:
    o2 = odd[1]
else:
    o2 = (0, 0)
if len(even) != 1:
    e2 = even[1]
else:
    e2 = (0, 0)

# 最多文字が異なる
if o1[0] != e1[0]:
    print(n - (o1[1] + e1[1]))
# 最多文字が同じ
else:
    ans = min((n - (o2[1] + e1[1])), (n - (o1[1] + e2[1])))
    print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())


v = [int(c) for c in input().split()]
v1 = [0 for _ in range(10**5)]
v2 = [0 for _ in range(10**5)]
for i in range(n):
    if i % 2 == 0:
        v1[v[i]] += 1
    else:
        v2[v[i]] += 1

if v1.index(max(v1)) == v2.index(max(v2)):
    m1 = sorted(set(v1))[-2]
    m2 = sorted(set(v2))[-2]
    if m1 > m2:
        print(n-m1-max(v2))
    else:
        print(n-max(v1)-m2)
else:
    print(n-max(v1)-max(v2))
Problem p03486 (python)

Fixed submission:
s = [i for i in input().strip()]
t = [i for i in input().strip()]

s.sort()
t.sort(reverse=True)

#print(s)
#print(t)

if s < t:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s = [i for i in input().strip()]
t = [i for i in input().strip()]

s.sort()
t.sort(reverse=True)

#print(s)
#print(t)

for i in range(len(s)):
  if s[i] < t[i]:
    print("Yes")
    exit()
    
print("No")
Problem p03565 (python)

Fixed submission:
import copy

s = list(input())
t = list(input())
if len(s) < len(t):
    print("UNRESTORABLE")
    exit()

ans_list = []
for i in range(len(s) - len(t) + 1):
    tmps = s[i:i + len(t)]
    ok = True
    for j in range(len(tmps)):
        if t[j] == tmps[j] or tmps[j] == '?':
            pass
        else:
            ok = False
            break
    if ok == True:
        cp_s = copy.deepcopy(s)
        for k in range(len(t)):
            cp_s[k+i] = t[k]
        ans_list.append(cp_s)

if len(ans_list) == 0:
    print("UNRESTORABLE")
else:
    # ?をaに書き換え
    for i in range(len(ans_list)):
        for j in range(len(s)):
            if ans_list[i][j] == '?':
                ans_list[i][j] = 'a'
    ans_list.sort()
    for c in ans_list[0]:
        print(c, end="")
    print()

Buggy submission (verdict: Runtime Error):
s = list(input())
t = list(input())
len_t = len(t)

for i in range(len(s) - len(t) + 1):
    tmps = s[i:i + len(t)]
    ok = True
    for j in range(len(tmps)):
        if t[j] == tmps[j] or tmps[j] == '?':
            pass
        else:
            ok = False
            break
    if ok == True:
        for k in range(len(t)):
            s[k+i] = t[k]
        break

if ok == False:
    print("UNRESTORABLE")
else:
    for c in s:
        if c == '?':
            print('a', end="")
        else:
            print(c, end="")
    print()
Problem p03569 (python)

Fixed submission:
s = input()
sr = s[-1::-1]
left = 0
right = 0
ans = 0
while (1):
    if left + right >= len(s) - 1:
        break
    if s[left] != sr[right]:
        if s[left] == 'x':
            left += 1
        elif sr[right] == 'x':
            right += 1
        else:
            print(-1)
            exit()
        ans += 1
    elif s[left] == sr[right]:
        left += 1
        right += 1

print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
sr = s[-1::-1]
left = 0
right = 0
ans = 0
while (1):
    if left + right == len(s) - 1:
        break
    if s[left] != sr[right]:
        if s[left] == 'x':
            left += 1
        elif sr[right] == 'x':
            right += 1
        else:
            print(-1)
            exit()
        ans += 1
    elif s[left] == sr[right]:
        left += 1
        right += 1

print(ans)
Problem p03943 (python)

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

if a[0]+a[1] == a[2]:
  print('Yes')
else:
  print('No')

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

if a[0]+a[1] == a[2]:
  print('Yes')
else:
  print('No')
Problem p03377 (python)

Fixed submission:
A,B,X=map(int,input().split())
if A<=X<=A+B:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
A,B,X=map(int,input().split())
if A<=X<=A+B:
    print(YES)
else:
    print(NO)
Problem p02657 (python)

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

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
print(a*b)
Problem p03136 (python)

Fixed submission:
N = input()
N = int(N)
l = list(map(int,input().split()))
l.sort()
sum = 0
for i in range(N-1):
    sum += l[i]
    
if sum > l[N-1]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N = input()
N = int(N)
l = list(int(input().split))
l.sort()
sum = 0
for i in range(N-1):
    sum += l[i]
    
if sum >= l[N-1]:
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
N = input();
l = list(int(input().split))
l.sort()
sum = 0
for i in range(N-1):
    sum += l[i]
    
if sum >= l[N-1]:
    print('No')
else:
    print('Yes')
Problem p02755 (python)

Fixed submission:
import math
A ,B = list(map(int,input().split()))
 
def problem_koganemaru(A,B):  
  for price in range(10000):
    if math.floor(price*0.08) == A and math.floor(price*0.1) == B:
      return price
  return -1
 
print(problem_koganemaru(A,B))

Buggy submission (verdict: Runtime Error):
import math
A ,B = list(map(int,input().split()))

def problem_koganemaru(A,B):  
  for price in range(10000):
    if math.ceil(price*0.08) == A and math.ceil(price*0.1) == B:
      return price
  return -1

print(problem_koganemru(A,B))

Buggy submission (verdict: Runtime Error):
A ,B = list(map(int,input().split()))
def problem_koganemaru(A,B):  
  # x =  A / (0.08) 
  # y =  B / (0.10) 
  # print(x,y)
  # if x == y:
  #   return x
  # else:
  #   return -1
  for price in range(10000):
    if math.ceil(price*0.08) == A and math.ceil(price*0.1) == B:
      return price
  return -1
print(problem_koganemaru(A,B))
Problem p02972 (python)

Fixed submission:
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())))
ans_list = np.zeros(N).astype(int)
N_2 = N // 2
ans = 0
for i in range(N):
    tmp = N - i - 1
    # print(tmp)
    if i < N_2:
        ans_list[tmp] = A[tmp]
        if A[tmp] == 1:
            ans += 1
    else:
        add = (np.sum(ans_list[tmp::(tmp + 1)]) + A[tmp]) % 2
        ans_list[tmp] = add
        if add == 1:
            ans += 1

print(ans)
for i in range(N):
    if ans_list[i] == 1:
        if i == N - 1:
            print(i + 1, end="")
        else:
            print(i + 1, end=" ")

Buggy submission (verdict: Runtime Error):
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())))
div_list = [] * N
ans_list = np.zeros(N).astype(int)
N_2 = N // 2
for i in range(N):
    tmp = N - i - 1
    # print(tmp)
    if i < N_2:
        ans_list[tmp] = A[tmp]
    else:
        ans_list[tmp] = (np.sum(ans_list[tmp::i]) + A[tmp]) % 2

print(np.sum(ans_list))
for i in range(N):
    if ans_list[i] == 1:
        print(ans_list[i], end="")
Problem p02717 (python)

Fixed submission:
# -*- coding: utf-8 -*-
# 整数の入力
# a = int(input())
# スペース区切りの整数の入力
# b, c = map(int, input().split())
# 文字列の入力
# s = input()
# 出力
# print("{} {}".format(a+b+c, s))
# print(f'{a+b+c} {s}')
a,b,c = map(int, input().split())
a,b = b,a
a,c = c,a
print("{} {} {}".format(a,b,c))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
# スペース区切りの整数の入力
b, c = map(int, input().split())
# 文字列の入力
s = input()
# 出力
# print("{} {}".format(a+b+c, s))
print(f'{a+b+c} {s}')
Problem p02748 (python)

Fixed submission:
from sys import stdin
input = lambda: stdin.readline().rstrip()
na, nb, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
min_a = min_b = 10**9
for i in range(na):
    min_a = min(min_a, a[i])
for i in range(nb):
    min_b = min(min_b, b[i])
ans = min_a + min_b
for i in range(m):
    x, y, c = map(int, input().split())
    x -= 1
    y -= 1
    ans = min(ans, a[x] + b[y] - c)
print(ans)

Buggy submission (verdict: Runtime Error):
from sys import stdin
from numpy import array
input = lambda: stdin.readline().rstrip()
na, nb, m = map(int, input().split())
a = array(list(map(int, input().split())))
b = array(list(map(int, input().split())))
ans = min(a) + min(b)
for i in range(m):
    x, y, c = map(int, input().split())
    x -= 1
    y -= 1
    ans = min(ans, a[x] + b[y] - c)
print(ans)
Problem p02765 (python)

Fixed submission:
N, R = input().split()
N = int(N)
R = int(R)
if N>=10 :
  x = R
else:
  x = R + 100*(10-N)
print(x)

Buggy submission (verdict: Runtime Error):
N, R = input().split()
if N>=10 :
  x = R
else:
  x = R - 100*(10-N)
print(x)
Problem p02767 (python)

Fixed submission:
import numpy as np
n = input()
x = input().split()
n = int(n)
x = list(map(int,x))
x = np.array(x)
maxed = np.max(x)
cand = []

for p in range(1,maxed+1):
    xp = (x - p) ** 2
    cand.append(np.sum(xp))
y = np.min(cand)
print(y)

Buggy submission (verdict: Runtime Error):
import numpy as np
n = input()
x = input().split()
n = int(n)
x = list(map(int,x))
x = np.array(x)
maxed = np.max(x)
cand = []

for p in range(1,maxed):
    xp = (x - p) ** 2
    cand.append(np.sum(xp))
y = np.min(cand)
print(y)
Problem p02534 (python)

Fixed submission:
k=int(input())
print(k*"ACL")

Buggy submission (verdict: Runtime Error):
k=input()
print(k*"ACL")
Problem p02553 (python)

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

n = [a*c, a*d, b*c, b*d]
print(max(n))

Buggy submission (verdict: Runtime Error):
n = int(input())

x = n*(n-1)*2*(10**(n-2))

print(x%(10**9 + 7))
Problem p02554 (python)

Fixed submission:
n = int(input())

x = 10**n - 2*(9**n) + 8**n
print(x%(10**9+7))

Buggy submission (verdict: Runtime Error):
n = int(input())
x = n*(n-1)*2(10**(n-2))

print(x%(10**9 + 7))
Problem p02556 (python)

Fixed submission:
n = int(input())
u = [list(map(int, input().split())) for i in range(n)]
z = [u[i][0] + u[i][1] for i in range(n)]
w = [u[i][0] - u[i][1] for i in range(n)]
d = [max(z)-min(z), max(w)-min(w)]

print(max(d))

Buggy submission (verdict: Runtime Error):
n = int(input())
u = [list(map(int, input().split())) for i in range(n)]
z = [u[i][0] + u[i][1] for i in range(n)]
w = [w[i][0] - w[i][1] for i in range(n)]
d = [max(z)-min(z), max(w)-min(w)]

print(max(d))

Buggy submission (verdict: Runtime Error):
n = int(input())
z = [[map(int, input().split())] for i in range(n)]
m = 0
d = 0
for i in range(n-1):
  for j in range(i+1, n):
    d = 0
    d += max(z[i][0] - z[j][0], z[j][0] - z[i][0])
    d += max(z[i][1] - z[j][1], z[j][1] - z[i][1])
    if d>m:
      m = d
print(m)
Problem p02576 (python)

Fixed submission:
N,X,T = map(int, input().split())
t = 0
while(N>0):
  t += 1
  N -= X

print(T*t)

Buggy submission (verdict: Runtime Error):
N,X,T = int(input().split())
t = 0
while(N>0):
  t += 1
  N -= X

print(T*t)
Problem p02613 (python)

Fixed submission:
n = int(input())
s = [input() for i in range(n)]
 
print("AC x " +  str(s.count('AC')))
print("WA x " +  str(s.count('WA')))
print("TLE x " +  str(s.count('TLE')))
print("RE x " +  str(s.count('RE')))

Buggy submission (verdict: Runtime Error):
n = int(input())
s = [int(input()) for i in range(n)]
 
print("AC x " +  str(s.count('AC')))
print("WA x " +  str(s.count('WA')))
print("TLE x " +  str(s.count('TLE')))
print("RE x " +  str(s.count('RE')))

Buggy submission (verdict: Runtime Error):
n = int(input())
s = [int(input()) for i in range(n)]

print("AC x " +  str(l.count('AC')))
print("WA x " +  str(l.count('WA')))
print("TLE x " +  str(l.count('TLE')))
print("RE x " +  str(l.count('RE')))
Problem p02628 (python)

Fixed submission:
N, K = map(int, input().split())
p = list(map(int, input().split()))
p.sort()

print(sum(p[0:K]))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
p = list(map(int, input().split()))
p.sort()

print(sum(p[0:K])
Problem p02664 (python)

Fixed submission:
t = input()
s = t.replace('?', 'D')
print(s)

Buggy submission (verdict: Runtime Error):
import numpy as np
t = input()
a = [x for i in range(len(t)) if t[i]=='?' x=D else x=t[i]]
print(a)

Buggy submission (verdict: Runtime Error):
t = input()
s = t.replace('?', 'D')
n = 0
for i in range(0, len(s)):
	if s[i:i+1]=='P' and s[i+1:i+2]=='D':
		n+=1
	else if s[i:i+1]:
		n+=1
print(n)
Problem p02536 (python)

Fixed submission:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.par = [-1] * n

    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.par[x] > self.par[y]:
            x, y = y, x

        self.par[x] += self.par[y]
        self.par[y] = x

    def size(self, x):
        return -self.par[self.find(x)]


n, k = map(int, input().split())
uf = UnionFind(n)
for _ in range(k):
    a, b = map(int, input().split())
    uf.unite(a - 1, b - 1)

cnt = 0
for x in uf.par:
    if x < 0:
        cnt += 1
print(cnt - 1)

Buggy submission (verdict: Runtime Error):
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.par = [-1] * n

    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.par[x] > self.par[y]:
            x, y = y, x

        self.par[x] += self.par[y]
        self.par[y] = x

    def size(self, x):
        return -self.par[self.find(x)]

n, k = map(int, input().split())
uf = UnionFind(n)
for _ in range(k):
    a, b = map(int, input().split())
    uf.unite(a, b)

cnt = 0
for x in uf.par:
    if x < 0:
        cnt += 1
print(n - cnt)
Problem p02574 (python)

Fixed submission:
from math import gcd
n = int(input())
s = list(map(int, input().split()))
s.sort()
dp = [0] * ((10 ** 6) + 100)

for ss in s:
    dp[ss] += 1

A = max(s)
pairwise = True

for i in range(2, A + 1):
    cnt = 0
    for j in range(i, A + 1, i):
        cnt += dp[j]
    if cnt > 1:
        pairwise = False

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

res = s[0]
for ss in s:
    res = gcd(res, ss)
print("setwise coprime" if res == 1 else "not coprime")

Buggy submission (verdict: Runtime Error):
from math import gcd
n = int(input())
s = list(map(int, input().split()))
s.sort()
dp = [0] * ((10 ** 6) + 100)

res = s[0]
for ss in s:
    dp[ss] += 1
    lf res != 1:
      continue
    else:
      res = gcd(res, ss)

A = max(s)
pairwise = True
setwise = (res == 1)

for i in range(2, A + 1):
    cnt = 0
    for j in range(i, A + 1, i):
        cnt += dp[j]
    if cnt > 1:
        pairwise = False
        break

if pairwise:
    print("pairwise coprime")
elif setwise:
    print("setwise coprime")
else:
    print("not coprime")