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

Fixed submission:
import itertools
n, m, q = map(int, input().split())
a = [0] * q
b = [0] * q
c = [0] * q
d = [0] * q
for i in range(q):
    a[i], b[i], c[i], d[i] = map(int,input().split())
A_list = []
for p in itertools.combinations_with_replacement(range(1,m+1),n):
    A_list.append(p)
# print(A_list)

ans = 0
for v in A_list:
    cur_score = 0
    for i in range(q):
        if v[b[i]-1] - v[a[i]-1] == c[i]:
            cur_score += d[i]
    ans = max(ans,cur_score)
print(ans)

Buggy submission (verdict: Runtime Error):
n, m, q = map(int, input().split())
a = [0] * q
b = [0] * q
c = [0] * q
d = [0] * q
for i in range(q):
    a[i], b[i], c[i], d[i] = map(int,input().split())
A_list = []
for p in itertools.combinations_with_replacement(range(1,m+1),n):
    A_list.append(p)
# print(A_list)

ans = 0
for v in A_list:
    cur_score = 0
    for i in range(q):
        if v[b[i]-1] - v[a[i]-1] == c[i]:
            cur_score += d[i]
    ans = max(ans,cur_score)
print(ans)
Problem p02729 (python)

Fixed submission:
import math

N, M = map(int, input().split(' '))

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
cnt = 0

if N > 1:
    cnt += combinations_count(N, 2)
if M > 1:
    cnt += combinations_count(M, 2)

print(cnt)

Buggy submission (verdict: Runtime Error):
L = map(int, input())

l = L/3

l*l*l

print('{:.0f}'.format(l*l*l))
Problem p02754 (python)

Fixed submission:
N, A, B = map(int, input().split(' '))
 
blue = 0
if N!=0 and A!=0:    
    blue = A *int(N/(A+B))
    if N%(A+B) <= A:
        blue += N%(A+B)
    else:
        blue += A 
print(blue)

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().split(' '))
 
row = ''
for i in range(int(N/(A+B)) +1):
    row+='b' * A
    row+= 'r' * B
print(list(row[:N]).count('b'))

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

row = ''
for i in range(1000):
    row +='b' * A
    row+= 'r' * B

print(list(row[:N]).count('b'))
Problem p02777 (python)

Fixed submission:
S, T = map(str ,input().split(' '))
A, B = map(int ,input().split(' '))
U = input()

dct = {S:A, T:B}
dct[U] = dct[U] - 1
print(dct[S], dct[T])

Buggy submission (verdict: Runtime Error):
def expect(p):
    return (int(p)+1)/2

N, K = map(int ,input().split(' '))
P = list(map(expect ,input().split(' ')))

sum_list = [sum(P[0:K])]
S = [sum(P[0:i]) for i in range(len(P))]
E = []

for i in range(N-K):
    E.append(S[i+K]-S[i])

print('{:.12f}'.format(max(E)))
Problem p03127 (python)

Fixed submission:
N=int(input())
a=list(map(int,input().split()))
def u(x,y):
    if x%y==0:
        return y
    else:
        return u(y,x%y)
b=list(range(N))
b[0]=a[0]
for i in range(1,N):
    b[i]=u(b[i-1],a[i])
print(int(b[N-1]))

Buggy submission (verdict: Runtime Error):
N=int(input())
a=list(map(int,input().split()))
def u(x,y):
    if x%y==0:
        return y
    else:
        return u(y,x%y)
b=list(range(N-1))
for i in range(1,N):
    b[i]=u(b[i-1],a[i])
print(int(b[N-2]))

Buggy submission (verdict: Runtime Error):
N=int(input())
a=list(map(int,input().split()))
def u(x,y):
    if x%y==0:
        return y
    else:
        return u(y,x&y)
b=list(range(N-1))
for i in range(1,N):
    b[i-1]=u(a[i-1],a[i])
print(int(b[N-2]))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
N=input()
M=list(map(int,input().split()))
print(gcd(*M))
Problem p03135 (python)

Fixed submission:
T,X=map(int,input().split())
print(T/X)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
X=sorted(list(map(int,input().split())))
if N<M:
    D=sorted([X[i+1]-X[i] for i in range(M-1)])
    print(sum(D[i] for i in range(M-N)))
else:
    print(0)
Problem p02951 (python)

Fixed submission:
a, b, c = map(int,input().split())
print(max(0, (c - (a - b))))

Buggy submission (verdict: Runtime Error):
n = int(input())
count = 0
for i in range(n):
  if len(i) % 2 == 1:
    count += 1
    
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
count = 0
for i in range(n):
  if len(i) % 2 == 1:
    count += 1
    
print(count)
Problem p03207 (python)

Fixed submission:
l = [int(input()) for _ in range(int(input()))]
print(sum(l) - max(l)//2)

Buggy submission (verdict: Runtime Error):
n = int(input())
p = [input() for i in range(n)]
print(sum(p) - int(max(p)/2))

Buggy submission (verdict: Runtime Error):
n = int(input())
p = [input() for i in range(n)]
print(sum(p) - max(p)/2)
Problem p03250 (python)

Fixed submission:
A, B, C = sorted(map(int, input().split()))
print(10*C+A+B)

Buggy submission (verdict: Runtime Error):
A, B, C = sorted(map(input().split()))
print(10*C+A+B)
Problem p03803 (python)

Fixed submission:
a, b = map(lambda x:(int(x) + 13) % 15, input().split())
if a > b: print("Alice")
elif a < b: print("Bob")
else: print("Draw")

Buggy submission (verdict: Runtime Error):
a, b = map(lambda x:(int(x) + 13) % 15, input().split())
if a > b: print("Alice")
  if a < b: print("Bob")
    else: print("Draw")
Problem p03834 (python)

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

Buggy submission (verdict: Runtime Error):
a, b, c = input().split()
print(a, b, c)
Problem p02771 (python)

Fixed submission:
a,b,c=map(int,input().split())
if a==b==c:
    print("No")
elif a == b or b==c or c==a:
    print("Yes")
else:
    print("No")

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

a=list(map(int,input().split()))
b=0
for i in range(len(a)-1):
    if a[i]//2==0:
        if a[i]//3==0 or a[i]//5==0:
            b=b+1
    else:
        b=b+1

if b==n:
    print("APPROVED")
else:
    print("DENIED")

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if a==b==c:
    print("No")
elif　a==b or b==c:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
A=map(int,input().split())
if A[0]=A[1]=A[2]:
    print("No")
elif　A[0]=A[1] orA[1]=A[2]:
    print("Yes")
else:
    print("No")
Problem p02711 (python)

Fixed submission:
s = input()
res = False
for c in s:
  if c == '7':
    res = True
    break
if res:
  print('Yes')
else:
  print('No')

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

num_rgb = {'R':0, 'G':0, 'B':0}
num_list = []
for i in range(n):
    num_rgb[s[i]] += 1
    num_list.append(num_rgb.copy())

total = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        if s[i] == s[j]:
            continue
        target = ''
        if not (s[i] == 'R' or s[j] == 'R'):
            target = 'R'
        elif not (s[i] == 'G' or s[j] == 'G'):
            target = 'G'
        elif not (s[i] == 'B' or s[j] == 'B'):
            target = 'B'
        num = num_list[n-1][target]-num_list[j][target]
        if 2*j-i < n and s[j+j-i] == target:
            num -= 1
        total += num
print(total)
Problem p02948 (python)

Fixed submission:
import heapq
n,m = map(int, input().split())
job_list = []
for i in range(n):
    a,b = map(int, input().split())
    job_list.append((a,b))
job_list.sort(key=lambda x:x[0])
# print(job_list)

hq = []
max_income = 0
j = 0
for i in range(1,m+1):
    while j < n and job_list[j][0] <= i:
        heapq.heappush(hq, (-job_list[j][1],job_list[j][0]))
        j += 1
    if len(hq) < 1:
        continue
    b_i, a_i = heapq.heappop(hq)
    max_income += -b_i

print(max_income)

Buggy submission (verdict: Runtime Error):
import heapq
n,m = map(int, input().split())
job = {}
for i in range(n):
    a,b = map(int, input().split())
    if a not in job.keys():
        job[a] = [(-b,a)]
    else:
        job[a].append((-b,a))

hq = []

max_income = 0
for i in range(1,m+1):
    if i in job.keys():
        for j in job[i]:
            heapq.heappush(hq,(j))
    b_i, a_i = heapq.heappop(hq)
    max_income += -b_i

print(max_income)
Problem p03041 (python)

Fixed submission:
N,K=map(int,input().split())
S = input()
list = [b.lower() if a+1==K else b for (a,b) in enumerate(S)]
moji = ''.join(list)
print(moji)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
S = input()
S[K] = S[K].lower()
print(S)
Problem p03107 (python)

Fixed submission:
a = input()
s = [int(i) for i in a]
count = 0
ans = 0
while True:
    if (len(s) == count+1) or len(s) == 0:
        break
    if (s[count] == 0 and s[count+1] == 1) or (s[count] == 1 and s[count+1] == 0):
        ans += 1
        s.pop(count)
        s.pop(count)
        if count != 0:
            count -= 1
    else:
        count += 1
print(ans*2)

Buggy submission (verdict: Runtime Error):
a = input()
s = [int(i) for i in a]
count = 0
ans = 0
while True:
    if (len(s) == count+1) or len(s) == 0:
        break
    if (s[count] == 0 and s[count+1] == 1) or (s[count] == 1 and s[count+1] == 0):
        ans += 1
        s.pop(count)
        s.pop(count)
        count -= 1
    else:
        count += 1
print(ans*2)
Problem p03137 (python)

Fixed submission:
n,m = map(int,input().split())
x = list(map(int,input().split()))
dist = []
x.sort()
if n > m:
    print(0)
else:
    for i in range(m-1):
        dist.append(x[i+1] -x[i])
    dist.sort()
    print(sum(dist[:m-n]))

Buggy submission (verdict: Runtime Error):
import heapq
n,m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
x_range = []
cut = [0]
count = 0
for i in range(m-1):
    x_range.append(abs(x[i]-x[i+1]))
h = heapq.nlargest(n-1,x_range)


for i in h:
    cut.append(x_range.index(i)+1)
cut.append(len(x))

if n>=m:
    print(0)
else:
    for i in range(len(cut)-1):
        sum_range = x[cut[i]:cut[i+1]]
        count += abs(sum_range[0]-sum_range[len(sum_range)-1])
print(count)

Buggy submission (verdict: Runtime Error):
import heapq
n,m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
x_range = []
cut = [0]
count = 0
for i in range(m-1):
    x_range.append(abs(x[i]-x[i+1]))
h = heapq.nlargest(n-1,x_range)


for i in h:
    cut.append(x_range.index(i)+1)
cut.append(len(x))


for i in range(len(cut)-1):
    sum_range = x[cut[i]:cut[i+1]]
    print(1)
    count += abs(sum_range[0]-sum_range[len(sum_range)-1])
#print(count)

Buggy submission (verdict: Runtime Error):
import heapq
n,m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
x_range = []
cut = [0]
count = 0
for i in range(m-1):
    x_range.append(abs(x[i]-x[i+1]))
h = heapq.nlargest(n-1,x_range)
for i in h:
    cut.append(x_range.index(i)+1)
cut.append(len(x))
for i in range(len(cut)-1):
    sum_range = x[cut[i]:cut[i+1]]
    count += abs(sum_range[0]-sum_range[len(sum_range)-1])
print(count)
Problem p02699 (python)

Fixed submission:
b,c=[int(x) for x in input().split()]
if c>=b:
    print("unsafe")
else:
    print("safe")

Buggy submission (verdict: Runtime Error):
a=int(input())
b,c=[int(x) for x in input().split()]
s=input()
print(a+b+c, s)
Problem p02754 (python)

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

C = N // (A + B)
D = N % (A + B)

ans = A * C + min(A, D)
print(ans)

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
 
rep = "b" * A + "r" * B
C = N // (A + B)
D = N % (A + B)
 
ans = A * C + min(A, D)
print(ans)

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

rep = "b" * A + "r" * B
C = N // (A + B)
D = N % (A + B)

ans = A * C + min(A, D)
print(ans)

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

rep = "b" * A + "r" * B
C = N // (A + B)
D = N % (A + B)

if D == 0:
    ans = A * C
else:
    ans = A * C + rep[:D].count("b")
print(ans)

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

rep = "b" * A + "r" * B
C = N // (A + B)
D = N % (A + B)

ans = A * C + rep[:D].count("b")
print(ans)
Problem p02847 (python)

Fixed submission:
S = input()

days = ["SUN","MON","TUE","WED","THU","FRI","SAT"]

for i in range(7):
    if days[i] == S:
        print(7 - i)
        break

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

graph = [[] for i in range(N)]

for i in range(N -1):
    a, b = map(int, input().split())
    graph[a-1].append((b, i))
    graph[b-1].append((a, i))

print(graph)
ans = [0] * (N -1)


def dfs(past, now, color):
    new_color = 1
    for future, edge in graph[now - 1]:
        if future == past:
            pass
        else:
            if new_color == color:
                new_color += 1
            ans[edge] = new_color
            dfs(now, future, new_color)
            new_color += 1

dfs(-1, 1, -1)

print(max(ans))
for i in ans:
    print(i)
Problem p02873 (python)

Fixed submission:
S = input()

a = [-1] * (len(S) + 1)

# find zero positions
if S[0] == "<":
    a[0] = 0

if S[-1] == ">":
    a[-1] = 0

for i in range(len(S)):
    if S[i:i+2] == "><":
        a[i + 1] = 0

for i in range(len(S)):
    if S[i] == "<":
        a[i + 1] = a[i] + 1

for i in reversed(range(len(S))):
    if S[i] == ">" and a[i + 1] >= 0:
        a[i] = max(a[i], a[i + 1] + 1)

print(sum(a))

Buggy submission (verdict: Runtime Error):
import re

S = input()

a = [-1] * (len(S) + 1)

zero_pos = []
if S[0] == "<":
    zero_pos.append(0)
    a[0] = 0
if S[-1] == ">":
    zero_pos.append(len(S) + 1)
    a[-1] = 0
for i in range(len(S)):
    if S[i:i+2] == "><":
        zero_pos.append(i + 1)
        a[i + 1] = 0

for j in zero_pos:
    if j == len(S):
        a[j + 1] = 1
    elif j > len(S):
        continue
    elif j == len(S) - 1:
        a[-1] = 1
    elif j == 0:
        v = 0
        while S[j + 1] == "<":
            a[j + 1] = v + 1
            j += 1
            v += 1
    else:
        v = 0
        while S[j + 1] == "<":
            a[j + 1] = v + 1
            j += 1
            v += 1
        a[j + 1] = v + 1

for k in zero_pos:
    if k == 0:
        continue
    elif k == len(S) + 1:
        v = 0
        while S[k - 2] == ">":
            a[k - 2] = v + 1
            k -= 1
            v += 1
    else:
        v = 0
        while a[k - 1] == -1:
            a[k - 1] = v + 1
            k -= 1
            v += 1

sum = 0
for m in a:
    sum += int(m)
print(sum)
Problem p02881 (python)

Fixed submission:
a = int(input())

dif = a
half = int(a / 2)
for i in range(1,half+1):
	if i <= a / i:
		if a % i == 0:
			div1 = int(i)
			div2 = int(a / i)
			continue
	else:
		break
print(div1 + div2 -2)

Buggy submission (verdict: Runtime Error):
import math
a,b,x = map(int, input().split())

if x >= (a * a * b) / 2:
	c = 2 * b - (2 * x) / (a * a)
	angle = math.degrees(math.atan(c / a))
else:
	d = x / (a * b)
	angle = math.degrees(math.atan(b / d))
print(angle)
Problem p02915 (python)

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

Buggy submission (verdict: Runtime Error):
n = input()
print(n*n*n)
Problem p02785 (python)

Fixed submission:
m, n = map(int, input().split())
li = list(map(int, input().split()))
if n >= m:
  print(0)
elif n == 0:
  print(sum(li))
else:
  print(sum(sorted(li)[:-n]))

Buggy submission (verdict: Runtime Error):
import math
m, n = map(int, input().split())
li = input().split()
res=[]
for i in li:
    res.append(int(i))

res.sort(reverse=True)

while n != 0:
    res.pop(0)
    n -= 1

print(sum(res))
Problem p02935 (python)

Fixed submission:
N=int(input())
v = list(map(float,input().split(' ')))
v.sort()

ans = v[0]
for i in range(N-1):
   ans = (ans+v[i+1])/2

print(ans)

Buggy submission (verdict: Runtime Error):
// Last Change: 08/18/2019 21:25:06.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  ll N;
  cin >> N;
  vector<double> v(N);
  for (auto &&e : v) {
    cin >> e;
  }
  sort(v.begin(), v.end());
  double ans = v[0];
  for (ll i = 1; i < N; ++i) {
    ans = (ans + v[i]) / 2;
  }
  cout << ans << endl;
}
Problem p03013 (python)

Fixed submission:
n,m = map(int,input().split())
ans = [1]*n

if n == 1:
    print(1)
else:
    for i in range(m):
        a = int(input())
        ans[a-1] = 0

    if ans[0] != 0 and ans[1] != 0:
        ans[0] = 1
        ans[1] = 2

    for i in range(2,n):
        if ans[i] != 0:
            ans[i] = (ans[i-1] + ans[i-2])%1000000007
        
    print(ans[n-1])

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
ans = [1]*n

for i in range(m):
    a = int(input())
    ans[a-1] = 0

if ans[0] != 0 and ans[1] != 0:
    ans[0] = 1
    ans[1] = 2

for i in range(2,n):
    if ans[i] != 0:
        ans[i] = (ans[i-1] + ans[i-2])%1000000007
        
print(ans[n-1])
Problem p03804 (python)

Fixed submission:
n,m = map(int,input().split())
a = []
b = []
for i in range(n):
    ai = list(input())
    a.append(ai)
for i in range(m):
    bi = list(input())
    b.append(bi)

hidariue = b[0][0]
hasikouho = []
for i in range(n-m+1):
    for j in range(n-m+1):
        if a[i][j] == hidariue:
            hasikouho.append([i,j])

x = []

for v in hasikouho:
    ans = "Yes"
    i = int(v[0])
    j = int(v[1])
    for p in range(m):
        if ans == "Yes":
            for q in range(m):
                if a[i+p][j+q] != b[p][q]:
                    ans = "No"
                    break
        else:
            break
    x.append(ans)

if "Yes" in x:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = []
b = []
for i in range(n):
    ai = list(input())
    a.append(ai)
for i in range(m):
    bi = list(input())
    b.append(bi)

hidariue = b[0][0]
hasikouho = []
for i in range(n-m+1):
    for j in range(n-m+1):
        if a[i][j] == hidariue:
            hasikouho.append(str(i)+":"+str(j))

x = []

for v in hasikouho:
    ans = "Yes"
    i = int(v[0])
    j = int(v[2])
    for p in range(m):
        if ans == "Yes":
            for q in range(m):
                if a[i+p][j+q] != b[p][q]:
                    ans = "No"
                    break
        else:
            break
    x.append(ans)

if "Yes" in x:
    print("Yes")
else:
    print("No")
Problem p03038 (python)

Fixed submission:
import bisect

N, M = [int(i) for i in input().split()]
alist = [int(i) for i in input().split()]
alist.sort()
inputs = [[int(i) for i in input().split()] for j in range(M)]
inputs.sort(key=lambda x:x[1], reverse=True)

for i in range(N):
    if len(inputs) == 0:
        break
    if inputs[0][1] > alist[i]:
        alist[i] = inputs[0][1]
        inputs[0][0] -= 1
        if inputs[0][0] == 0:
            inputs.pop(0)
    else:
        break
print(sum(alist))

Buggy submission (verdict: Runtime Error):
import bisect

N, M = [int(i) for i in input().split()]
alist = [int(i) for i in input().split()]
alist.sort()
inputs = [[int(i) for i in input().split()] for j in range(M)]
inputs.sort(key=lambda x:x[1], reverse=True)

for i in range(N):
    if inputs[0][1] > alist[i]:
        alist[i] = inputs[0][1]
        inputs[0][0] -= 1
        if inputs[0][0] == 0:
            inputs.pop(0)
    else:
        break
print(sum(alist))
Problem p02881 (python)

Fixed submission:
import math

N = int(input())
 
mi = 10**100

for a in range(1, int(math.sqrt(N))+1, 1):
  if N % a == 0:  
    b = N//a
    if mi > a+b-2:
      mi = a+b -2
print(mi)

Buggy submission (verdict: Runtime Error):
N = int(input())
 
mi = 10**10
 
for a in range(int(math.sqrt(N)), N+1, 1):
  N % a == 0:
    b = N//a
    if mi > a+b-2:
      mi = a+b-2
print(mi)

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

mi = 10**10

for a in range(N):
  for b in range(a):
    if a*b = N:
      if mi < a*b-2:
        mi == a*b-2
print(mi)
Problem p03075 (python)

Fixed submission:
anntena_list = []
 
for i in range(5):
    anntena_list.append(int(input()))
    
m = int(input())
    
flag = False
for i in range(4):
  for j in range(3-i):
    if anntena_list[4-i] - anntena_list[j]  > m:
      flag = True
      
if flag:
  print(':(')
else:
  print('Yay!')

Buggy submission (verdict: Runtime Error):
X, Y, Z, K = list(map(int, input().split(' ')))

A = list(map(int, input().split(' ')))
B = list(map(int, input().split(' ')))
C = list(map(int, input().split(' ')))


A.sort()
A.reverse()
B.sort()
B.reverse()
C.sort()
C.reverse()

cal = []

def a(X,K):
  if X > K:
  	return K
  else:
    return X
  
for i in range(a(X,K-1000)):
  for j in range(a(Y,K-1000)):
    for k in range(a(Z,K-1000)):
      cal.append(A[i]+B[j]+C[k])

cal.sort()
cal.reverse()

for i in range(K):
  print(cal[i])
Problem p03327 (python)

Fixed submission:
n = int(input())
if n < 1000:
  print("ABC")
else:
  print("ABD")

Buggy submission (verdict: Runtime Error):
n = input()
if n < 1000:
  print("ABC")
else:
  print("ABD")
Problem p02707 (python)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
P=[0]*N
for i in range(N-1):
    P[A[i]-1]+=1
for i in range(N):
    print(P[i])

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
for i in range(N):
    print(A.count(i+1)
Problem p02754 (python)

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

Buggy submission (verdict: Runtime Error):
N,A,B=map(int,input().split())
S="b"*A+"r"*B
ans=(N//(A+B))*A+S[:N%(A+B)].count("b")
print(ans)
Problem p02831 (python)

Fixed submission:
from fractions import gcd
A,B=map(int,input().split())
print((A*B)//gcd(A,B))

Buggy submission (verdict: Runtime Error):
import math
A,B=map(int,input().split())
print((A*B)//math.gcd(A,B))
Problem p02793 (python)

Fixed submission:
import sys
from fractions import gcd
sys.setrecursionlimit(10**5)
def input():
    return sys.stdin.readline()[:-1]

N = int(input())
l = list(map(int, input().split()))

u = 10**9+7

lcm = 1
s = 0
for i in range(N):
    k = l[i]
    g = gcd(k,lcm)
    t = k//g
    lcm = lcm*t
    s = s*t + lcm//k
print(s%u)

Buggy submission (verdict: Runtime Error):
import sys,fractions
sys.setrecursionlimit(10**5)
def input():
    return sys.stdin.readline()[:-1]

N = int(input())
l = list(map(int, input().split()))

u = 10**9+7

from functools import reduce

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

G = l[0]
for i in range(1,N):
    G = fractions.gcd(G,l[i])
    if G==1:
        break
gcd = G
L = [l[i]//gcd for i in range(N)]
lcm = lcm_list(L)

# print(lcm,gcd,'aaa')
ANS = 0
for i in range(N):
    elm = L[i]
    ANS += (lcm/elm)
    ANS %= u
print(ANS)
Problem p02881 (python)

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]


N = int(input())
cnt = 0
n = N//2+1
k = int(N**0.5)+1
b = 0
for i in range(k,1,-1):
    if N%i==0:
        b = N//i
        a = i
        print(a+b-2)
        exit()
else:
    print(N-1)

Buggy submission (verdict: Runtime Error):
import sys,math
def input():
    return sys.stdin.readline()[:-1]


a,b,x = map(int,input().split(' '))

t = x/(a**2)
half = b/2
if t<half:
    a_2 = x/b
    b_2 = b
else:
    a_2 = a
    b_2 = (b-t)*2
c = (a_2**2+b_2**2)**0.5
cos1 = ((a_2**2)+(c**2)-(b_2**2))/(2*a_2*c)
print(math.degrees(math.acos(cos1)))