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

Fixed submission:
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
a = set(a)
mod = 1000000007
dp = [0]*(N+1)
dp[0] = 1
for i in range(1, N+1):
    if i not in a:
        if i == 1:
            dp[i] = dp[i-1]
        else:
            dp[i] = (dp[i-1]+dp[i-2])%mod
print (dp[N])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
a = set(a)
mod = 1000000007
dp = [0]*(N+1)
dp[0] = 1
if a[0] != 1:
    dp[1] = 1
for i in range(2, N+1):
    if i not in a:
        dp[i] = (dp[i-1]+dp[i-2])%mod
print (dp[N])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
mod = 1000000007
dp = [0]*(N+1)
dp[0] = 1
if a[0] != 1:
    dp[1] = 1
for i in range(2, N+1):
    if i not in a:
        dp[i] = (dp[i-1]+dp[i-2])%mod
print (dp[N])
Problem p02771 (python)

Fixed submission:
ABC = [int(i) for i in input().split()]

if len(set(ABC)) == 2:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import collections

N = int(input())

S = [input() for i in range(N)]

result = collections.Counter(S)

result_max = sorted([i for i in result.keys() if result[i] == max(result.values())])

for r in result_max:
    print(r)
Problem p02762 (python)

Fixed submission:
n, m, k = [int(x) for x in input().split()]
fr = [i for i in range(n)]
dfr = [[] for i in range(n)]
bl = [[] for i in range(n)]
def deref(a):
    s = []
    while True:
        next = fr[a]
        if next == a:
            break
        s.append(a)
        a = next
    for i in s:
        fr[i] = a
    return a
def merge(a, b):
    ra, rb = deref(a), deref(b)
    fr[rb] = ra
for i in range(m):
    a, b = [int(x) - 1 for x in input().split()]
    dfr[a].append(b)
    dfr[b].append(a)
    a, b = min(a, b), max(a, b)
    merge(a, b)
for i in range(n):
    deref(i)
ss = [[] for i in range(n)]
for i in range(n):
    ss[fr[i]].append(i)
for i in range(k):
    c, d = [int(x) - 1 for x in input().split()]
    bl[c].append(d)
    bl[d].append(c)
for i in range(n):
    bl[i].sort()
r = []
for i in range(n):
    v = len(ss[fr[i]]) - len(dfr[i]) - 1
    v -= sum(fr[j] == fr[i] for j in bl[i])
    r.append(v)
print(' '.join(str(x) for x in r))

Buggy submission (verdict: Runtime Error):
, m, k = [int(x) for x in input().split()]
fr = [i for i in range(n)]
dfr = [[] for i in range(n)]
bl = [[] for i in range(n)]
def deref(a):
    s = []
    while True:
        next = fr[a]
        if next == a:
            break
        s.append(a)
        a = next
    for i in s:
        fr[i] = a
    return a

def merge(a, b):
    #print('merge(',a,b)                                                                
    ra, rb = deref(a), deref(b)
    fr[rb] = ra

for i in range(m):
    a, b = [int(x) - 1 for x in input().split()]
    dfr[a].append(b)
    dfr[b].append(a)
    a, b = min(a, b), max(a, b)
    merge(a, b)
for i in range(n):
    deref(i)
#print(dfr)                                                                             
#print(fr)                                                                              
ss = [[] for i in range(n)]
for i in range(n):
    ss[fr[i]].append(i)
for i in range(k):
    c, d = [int(x) - 1 for x in input().split()]
    bl[c].append(d)
    bl[d].append(c)
    for i in range(n):
    bl[i].sort()
r = []
for i in range(n):
    v = len(ss[fr[i]]) - len(dfr[i]) - 1
    v -= sum(fr[j] == fr[i] for j in bl[i])
    r.append(v)
print(' '.join(str(x) for x in r))
Problem p02759 (python)

Fixed submission:
n = int(input())
 
if n % 2 == 1:
  print(int((n+1)/2))
else:
  print(int(n/2))

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

print(round(n/2))
Problem p03775 (python)

Fixed submission:
n=int(input())
f=[]
for i in range(1,int(n**0.5)+1):
    if n%i==0:
        f.append(i)
        f.append(int(n/i))
if n==1:
    print('1')
else:
    print(len(str(f[-1])))

Buggy submission (verdict: Runtime Error):
n=int(input())
f=[]
for i in range(1,int(n**0.5)):
    if n%i==0:
        f.append(i)
        f.append(int(n/i))
print(len(str(f[-1])))
Problem p03291 (python)

Fixed submission:
import numpy as np


dp = np.zeros((2, 4), dtype=np.int64)
mod = 1e9+7
dp[0][0] = 1
for s in input():
    if s == '?':
        dp[1] = dp[0]*3
        dp[1][1:] += dp[0][:3]
        dp[1] = np.remainder(dp[1], mod)
    else:
        dp[1] = dp[0]
        if s == 'A':
            dp[1][1] += dp[0][0]
            dp[1][1] = np.remainder(dp[1][1], mod)
        elif s == 'B':
            dp[1][2] += dp[0][1]
            dp[1][2] = np.remainder(dp[1][2], mod)
        elif s == 'C':
            dp[1][3] += dp[0][2]
            dp[1][3] = np.remainder(dp[1][3], mod)
    dp[0] = dp[1]
print(dp[0][3])

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


S = input()
dp = np.zeros((int(1e5+1), 4), dtype=np.int64)
i = 0
mod = 1e9+7
dp[0][0] = 1
for s in S:
    if s == '?':
        dp[i+1] = dp[i]*3 % mod
        dp[i+1][1:] += dp[i][:3]
        dp[i+1] = np.remainder(dp[i+1], mod)
    else:
        dp[i+1] = dp[i]
        if s == 'A':
            dp[i+1][1] += dp[i][0]
            dp[i+1][1] = np.remainder(dp[i+1][1], mod)
        elif s == 'B':
            dp[i+1][2] += dp[i][1]
            dp[i+1][2] = np.remainder(dp[i+1][2], mod)
        elif s == 'C':
            dp[i+1][3] += dp[i][2]
            dp[i+1][3] = np.remainder(dp[i+1][3], mod)
    i += 1
print(dp[len(S)][3])
Problem p02881 (python)

Fixed submission:
import math
n=int(input())
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
if is_prime(n)==True:
    print(int(n-1))
else:
    N=int(math.sqrt(n))
    for i in reversed(range(N)):
        if n%(i+1)==0:
            print(int((n/(i+1))+i-1))
            break

Buggy submission (verdict: Runtime Error):
from sympy import isprime
import math
n=int(input())
if (isprime(n))==True:
    print(int(n-1))
else:
    N=int(math.sqrt(n))
    for i in reversed(range(N)):
        if n%(i+1)==0:
            print(int((n/(i+1))+i-1))
            break
Problem p02712 (python)

Fixed submission:
N = int(input())


c = 0
for i in range(1,N+1):
    if i % 15 == 0:
        continue
    elif i % 5 == 0:
        continue
    elif i % 3 == 0:
        continue
    else:
        c += i

print(c)

Buggy submission (verdict: Runtime Error):
N = input()


count = 0
for i in range(N):
    if N % 15 == 0:
        continue
    elif N % 3:
        continue
    elif N % 5:
        continue
    else:
        count += i
print(count)
Problem p02729 (python)

Fixed submission:
N,M = map(int, input().split())
print(int(N*(N-1)/2)+int(M*(M-1)/2))

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

from collections import Counter

c = Counter(L)
d = {}
sum = 0

for i in c:
    k = c[i]
    sum += k * (k-1) //2
for i in range(N):
    print(int(sum - c[L[i]] + 1))

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

from collections import Counter

c = Counter(L)
d = {}
sum = 0

for i in c:
    k = c(i)
    sum += k * (k-1) //2
for i in range(N):
    print(int(sum - c[L[i]] + 1))
Problem p02831 (python)

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

count = 1
while True:
    if count*A%B == 0:
        print(count*A)
        break
    else:
        count += 1

Buggy submission (verdict: Runtime Error):
import math

A,B = map(int, input().split())
print(A*B//math.gcd(A,B))

Buggy submission (verdict: Runtime Error):
import math

A,B = map(int, input().split())

print(A*B//math.gcd(A,B))

Buggy submission (verdict: Runtime Error):
import math

A,B = map(int, input().split())
print(A*B//math.gcd(A , B))
Problem p02835 (python)

Fixed submission:
A,B,C = map(int, input().split())
 
if A+B+C>=22:
      print("bust")
else:
      print("win")

Buggy submission (verdict: Runtime Error):
A,B,C = map(int, input().split())
 
if A+B+C>=22:
      print("bust")
else:
      prit("win")

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

if A+B+C>=22:
  print("bust")
else:
  prit("win")

Buggy submission (verdict: Runtime Error):
A,B,C = map(int, input())
if A+B+C >=22:
  print(bust)
else:
  print(win)
Problem p02860 (python)

Fixed submission:
N = int(input())
S = input()

if N % 2 != 0:
    print("No")
else:
    a = S[:N//2]
    b = S[N//2:]
    if a == b:
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()

if N % 2 != 0:
    print("No")
else:
    a = S[0;N/2]
    b = S[N/2;]
    if a == b:
        print("Yes")
    else:
        print("No")
Problem p03631 (python)

Fixed submission:
s = input()
a = len(s)
i = 0
for i in range(a):
    if s[i] == s[a - 1 - i]:
        b = 1
    else:
        b = 0
        break


if b == 1:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s = input()
a = len(s)
for i in s:
    if s[i] == s[a - 1 -i] :
        b = 1
    else:
        b = 0
        break


if b == 1:
    print('Yes')
else:
    print('No')
Problem p02729 (python)

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


def c2(x):
    return x * (x - 1) // 2


print(c2(n) + c2(m))

Buggy submission (verdict: Runtime Error):
def c2(x):
    return x * (x - 1) // 2
 
 
n = int(input())
a = list(map(lambda i: int(i) - 1, input().split()))
b = list(a.count(i) for i in range(n))
# c = list(c2(b[i]) for i in range(n))
# d = list(c2(b[i] - 1) for i in range(n))
c = list(c2(i) for i in b)
d = list(c2(i - 1) for i in b)
 
s = sum(c)
# for k in range(n):
#     i = a[k]
#     ans = s - c[i] + d[i]
#     print(ans)
for i in a:
    print(s - c[i] + d[i])
Problem p03011 (python)

Fixed submission:
from collections import defaultdict
from collections import deque
from string import ascii_uppercase
import sys, bisect, math
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

P = read_int()
P.sort()
def solve():
    return P[0] + P[1]

if __name__ == "__main__":
    print(solve())

Buggy submission (verdict: Runtime Error):
import sys
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
H, W = read_int()

range_W = range(W)
range_H = range(H)
# nomal
L = [[0 for _ in range_W] for _ in range_H]
R = [[0 for _ in range_W] for _ in range_H]
U = [[0 for _ in range_W] for _ in range_H]
D = [[0 for _ in range_W] for _ in range_H]
res = [[0 for _ in range_W] for _ in range_H]
grid = []

append = grid.append
for i in range_H:
    row = list(" ".join(input()).split())
    append(row)

def solve():
    ans = 0
    for i in range_H:
        for j in range_W:
            if grid[i][j] == ".":
                L[i][j] = 1 if j == 0 else L[i][j - 1] + 1
                U[i][j] = 1 if i == 0 else U[i - 1][j] + 1
                res[i][j] += L[i][j] + U[i][j]
                ans = max(res[i][j], ans)

            if grid[H - i - 1][W - j - 1] == ".":
                R[H - i - 1][W - j - 1] = 1 if j == 0 else R[H - i - 1][W - j] + 1
                D[H - i - 1][W - j - 1] = 1 if i == 0 else D[H - i][W - j - 1] + 1
                res[H - i - 1][W - j - 1] += R[H - i - 1][W - j - 1] + D[H - i - 1][W - j - 1]
                ans = max(res[H - i - 1][W - j - 1], ans)
    return ans - 3

if __name__ == "__main__":
    print(solve())

Buggy submission (verdict: Runtime Error):
import sys, math, heapq
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
H, W = read_int()


# nomal
L = [[0 for _ in range(W)] for _ in range(H)]
R = [[0 for _ in range(W)] for _ in range(H)]
U = [[0 for _ in range(W)] for _ in range(H)]
D = [[0 for _ in range(W)] for _ in range(H)]
res = [[0 for _ in range(W)] for _ in range(H)]
grid = []

append = grid.append
for i in range(H):
    row = list(" ".join(input()).split())
    append(row)

def solve():
    ans = 0
    for i in range(H):
        for j in range(W):
            if grid[i][j] == ".":
                L[i][j] = 1 if j == 0 else L[i][j - 1] + 1
                U[i][j] = 1 if i == 0 else U[i - 1][j] + 1
                res[i][j] += L[i][j] + U[i][j]
                ans = max(res[i][j], ans)
 
            if grid[H - i - 1][W - j - 1] == ".":
                R[H - i - 1][W - j - 1] = 1 if j == 0 else R[H - i - 1][W - j] + 1
                D[H - i - 1][W - j - 1] = 1 if i == 0 else D[H - i][W - j - 1] + 1
                res[H - i - 1][W - j - 1] += R[H - i - 1][W - j - 1] + D[H - i - 1][W - j - 1]
                ans = max(res[H - i - 1][W - j - 1], ans)
    return ans - 3

if __name__ == "__main__":
    print(solve())
Problem p03077 (python)

Fixed submission:
from collections import defaultdict
from string import ascii_uppercase
import sys, bisect
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N = read_int()[0]
cap = [read_int()[0] for _ in range(5)]

def solve():
    b_neck = cap[0]
    for i in range(5):
        if b_neck > cap[i]:
            b_neck = cap[i]
    in_neck = -(- N // b_neck)
    ans = 4 + in_neck
    return ans

if __name__ == "__main__":
    print(solve())

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
from string import ascii_uppercase
import sys, bisect
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

X, Y, Z, K = read_int()
A = read_int()
A.sort(reverse=True)
B = sorted(read_int())
C = sorted(read_int())

yz = []
res = []
def solve():
    for i in range(Y):
        for j in range(Z):
            yz.append(B[i] + C[j])
    yz.sort(reverse=True)
    for i in range(X):
        for j in range(min(K,len(yz))):
            res.append(A[i] + yz[j])
    res.sort(reverse=True)
    for i in range(K):
        print(res[i])


if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
from string import ascii_uppercase
import sys, bisect
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

X, Y, Z, K = read_int()
A = read_int()
A.sort(reverse=True)
B = sorted(read_int())
C = sorted(read_int())

yz = []
res = []
def solve():
    for i in range(Y):
        for j in range(Z):
            yz.append(B[i] + C[j])
    yz.sort(reverse=True)
    for i in range(X):
        for j in range(min(K,len(yz))):
            res.append(A[i] + yz[j])
    res.sort(reverse=True)
    for i in range(K):
        print(res[i])


if __name__ == "__main__":
    solve()
Problem p02897 (python)

Fixed submission:
N = int(input())
if (N==1):
  print(1.0)
elif(N%2==0):
  print((N//2)/N)
else:
  print(((N//2+1)/N))

Buggy submission (verdict: Runtime Error):
A, B = [int(s) for s in input().split()]
def gcd(x, y):
  while y != 0:
    x, y = y, x%y
  return x
def divisors(n):
  i = 1
  table = []
  while i * i <= n:
    if n%i == 0:
      table.append(i)
      table.append(n//i)
    i += 1
  table = list(set(table))
  return table

gcd_divisors = divisors(gcd(A, B))
N = len(gcd_divisors)
count = 0
for i in range(N):
  flg = False
  for j in range(N-1-i-1):
    if gcd(gcd_divisors[N-1-i], gcd_divisors[j]) != 1:
      flg = True
      break
  if flg == False:
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(s) for s in input().split()]
ans = sorted(range(len(A)), key=lambda k: A[k])
ans = [str(i+1) for i in ans]

print(' '.join(ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(s) for s in input().split()]
ans = sorted(range(len(A)), key=lambda k: A[k])
ans = [str(i+1) for i in ans]

print(' '.join(ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(s) for s in input().split()]
ans = sorted(range(len(A)), key=lambda k: A[k])
ans = [i+1 for i in ans]

print(' '.join(ans))
Problem p02915 (python)

Fixed submission:
N = int(input())
print(N*N*N)

Buggy submission (verdict: Runtime Error):
# run-length encoding, decoding
def rle_encode(data):
    encoding = ''
    prev_char = ''
    count = 1

    if not data: return ''

    for char in data:
        # If the prev and current characters
        # don't match...
        if char != prev_char:
            # ...then add the count and character
            # to our encoding
            if prev_char:
                encoding += str(count) + prev_char + ' '
            count = 1
            prev_char = char
        else:
            # Or increment our counter
            # if the characters do match
            count += 1
    else:
        # Finish off the encoding
        encoding += str(count) + prev_char + ' '
        return encoding

N, K = [int(s) for s in input().split()]
S = input()
S_rle = rle_encode(S).split()
total = 0
for i, bunch in enumerate(S_rle):
  total += int(list(bunch)[0]) - 1

if len(S_rle) >= 2*K+3:
  print(total+2*K)
elif len(S_rle) >= 2*K:
  print(total+2*K-1)
else:
  print(N-1)
Problem p02990 (python)

Fixed submission:
import math

MOD = 10 ** 9 + 7

def comb(n, r):
    if n - r < 0:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

for i in range(1, k+1):
    c = comb(n-k+1, i) % MOD
    d = comb(k-1, i-1) % MOD
    print((c * d) % MOD )

Buggy submission (verdict: Runtime Error):
import math

MOD = 10 ** 9 + 7

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

for i in range(1, k+1):
    c = comb(n-k+1, i) % MOD
    d = comb(k-1, i-1) % MOD
    print((c * d) % MOD )
Problem p02754 (python)

Fixed submission:
N, A, B = map(int, input().split())
ans = N // (A+B) * A
rem = N % (A+B)
ans += min(rem, A)
print(ans)

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
ans = N // (A+B) * A
rem = n % (A+B)
ans += min(rem, A)
print(ans)
Problem p02729 (python)

Fixed submission:
n,m = map(int,input().split())
a = int(n*(n-1)/2)
b = int(m*(m-1)/2)
print(a+b)

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
n,m = map(int,input().split())
ans = comb(n,2,exact=True)+comb(m,2,exact=True)

print(ans)
Problem p02754 (python)

Fixed submission:
n,a,b = map(int,input().split())
temp = n//(a+b)
ans = temp*a
temp2 = n%(a+b)
print(ans+min(temp2,a))

Buggy submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
if a>n:
  print(a)
ans = 0
else:
  temp = N//(a+b)
  ans = temp*a
  temp2 = N- temp
  if temp2 < a:
    print(ans+temp2)
  else:
    print(ans+a)
Problem p03250 (python)

Fixed submission:
a,b,c=  map(int,input().split())
temp= [a,b,c]
temp.sort()
temp1=int(str(temp[-1])+str(temp[-2]))
print(temp1+temp[0])

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
# print()
if len(S)>=10**5+5*10**4:
    print("No")
else:
    for i in range(len(S)):
        if S[i] != T[i]:
            S = S.translate(str.maketrans({S[i]:T[i],T[i]:S[i]}))
            # S=S.replace(S[i],T[i])
    if S==T:
        print("Yes")
    else:
        print("No")
Problem p03631 (python)

Fixed submission:
n=int(input())
a1 = n % 10
a2 = (n - a1) % 100
a3 = (n - a1 - a2) / 100
if a1 == a3:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = input()
a1 = n%10
a2 = (n-a1)%100
a3 = (n-a1-a2)/100
if a1==a3:
    print("Hello World")

Buggy submission (verdict: Runtime Error):
n = input()
a1 = n%10
a2 = (n-a1)%100
a3 = (n-a1-a2)/100
if a1==a2:
    print("Hello World")
Problem p02793 (python)

Fixed submission:
import fractions
 
n = int(input())
a = list(map(int, input().split()))
 
l = 1
for i in range(n):
	l = l // fractions.gcd(l, a[i])*a[i]
 
ans = 0
for i in range(n):
	ans += l//a[i]
print(ans%(10**9+7))

Buggy submission (verdict: Runtime Error):
import fractions
 
n = int(input())
a = list(map(int, input().split()))
 
num = a[0]
for i in range(1, n):
	num = (num * a[i]) // fractions.gcd(num, a[i])
 
ans = 0
for i in range(n):
	ans += (num//a[i]) % 1000000007
 	if ans > 1000000007:
      	ans = ans % 1000000007
print(ans)

Buggy submission (verdict: Runtime Error):
import math

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

def lcm(x, y):
	return (x * y) // math.gcd(x, y)

num = a[0]
for i in range(1, n):
	num = lcm(num, a[i])

ans = 0
for i in range(n):
	ans += (num//a[i]) % 1000000007
	if ans > 1000000007:
		ans = ans%1000000007

print(ans)
Problem p02829 (python)

Fixed submission:
a = int(input())
b = int(input())
list = [1, 2, 3]

list.remove(a)
list.remove(b)
print(list[0])

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())

if a != 1 and b != 1:
	print(1)
elif a != 2 and b != 2:
	print(2)
elif a != 3 and b != :
	print(3)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())

if a != 1 and b != 1:
	print(1)
elif a != 2 and b != 2:
	print(2)
elif a != 3 and b != :
	print(3)
Problem p03011 (python)

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

min1=P
min2=Q

min1=101
min2=101





Z1=P+Q
Z2=Q+R
Z3=P+R
Z4=Q+R
Z5=R+P
Z6=Q+R

min1=Z1
if(min1>Z2):
    min1=Z2
if(min1>Z3):
    min1=Z3
print(min1)

Buggy submission (verdict: Runtime Error):
P,Q,R=map(int,input().split())
result=0
min1=100
min2=100

if min1>P:
    min1=P
    flag="P"
if min1>Q:
    min1=Q
    flag="Q"
if min1>R:
    min1=R
    flag="R"
if(flag!="P"):
    if min2>P:
        min2=P
if(flag!="Q"):
    if min2>Q:
        min2=Q
if(flag!="R"):
    if min1>R:
        min2=R
print(min1+min2)
Problem p03107 (python)

Fixed submission:
S = input()
init_count = len(S)

tmp_i = 0
while len(S) > 1:
    no_01 = True
    before_s = None
    for i, s in enumerate(S[tmp_i:]):
        if i == 0:
            before_s = s
            continue
        if before_s != s:
            no_01 = False
            # print(S[:tmp_i + i-1], '(', S[tmp_i + i - 1], ' | ', S[tmp_i + i],  ')', S[tmp_i + i+1:])
            newS = S[:tmp_i + i-1] + S[tmp_i + i+1:]
            S = newS
            # print('newS: ', newS)
            tmp_i = tmp_i + i - 2
            if tmp_i < 0:
                tmp_i = 0
            # print(tmp_i)
            break
    if no_01:
        break
print(init_count - len(S))

Buggy submission (verdict: Runtime Error):
S = input()
init_count = len(S)

tmp_i = 0
while len(S) > 1:
    no_01 = True
    before_s = None
    for i, s in enumerate(S[tmp_i:]):
        if i == 0:
            before_s = s
            continue
        if before_s != s:
            no_01 = False
            print(S[:tmp_i + i-1], '(', S[tmp_i + i - 1], ' | ', S[tmp_i + i],  ')', S[tmp_i + i+1:])
            newS = S[:tmp_i + i-1] + S[tmp_i + i+1:]
            S = newS
            print('newS: ', newS)
            tmp_i = tmp_i + i - 2
            if tmp_i < 0:
                tmp_i = 0
            print(tmp_i)
            break
    if no_01:
        break
print(init_count - len(S))
Problem p03137 (python)

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

X = list(map(int, input().split()))
X.sort()

if N >= M:
    print(0)
    exit()
diffs = [X[i+1] - X[i] for i in range(M-1)]
diffs.sort()
print(sum(diffs[:M-N]))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())

X = list(map(int, input().split()))
X.sort()

if N >= M:
    print(0)
    exit()
diffs = [X[i+1] - X[i] for i in range(M-1)]
diffs.sort()
print(sum[diffs[:N-M]])
Problem p02793 (python)

Fixed submission:
import fractions
n = int(input())
a = list(map(int, input().split()))
ans = a[0]
p = 10**9+7
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
cnt=0
for i in range(n):
  cnt+=ans//a[i]
print(cnt%p)

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

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
  
k = lcm_list(a)
cnt=0
for i in range(n):
  cnt+=k//a[i]
print(cnt)