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

Fixed submission:
class City:
    def __init__(self,id,y):
        self.id = id
        self.year = y


def main():
    n,m = map(int,input().split())
    pre_lst = [[] for _ in range(n)]
    city_tags = [0 for _ in range(m)]

    for i in range(m):
        p,y = map(int,input().split())
        pre_lst[p-1].append(City(i,y))

    for pre_num,pre in enumerate(pre_lst):
        if len(pre) <= 0:
            continue
        pre.sort(key = lambda x:x.year)
        counter = 0
        for city in pre:
            city_tags[city.id] = str(pre_num+1).zfill(6) + str(counter+1).zfill(6)
            counter += 1
    for tag in city_tags:
        print(tag)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#「県ごとの市の「市番号(id)、誕生年(year)」リスト」と「市番号順の市の認識番号(tag)リスト」を用意する

class City:
    #市番号と誕生年を管理する
    def __init__(self,id,y):
        self.id = id
        self.year = y


def main():
    n,m = map(int,input().split())
    pre_lst = [[] for _ in range(n)]  #各県に含まれる市のリスト
    city_tags = [0 for _ in range(m)] #上記のリストから作った市の認識番号を格納するためのリスト

    for i in range(m):
        p,y = map(int,input().split())
        pre_lst[p-1].append(City(i,y))　#入力を受け取り、県ごとのリストを作る

    for pre_num,pre in enumerate(pre_lst):
        if len(pre) <= 0:
            continue
        pre.sort(key = lambda x:x.year) #各県ごとに誕生年順にソート

        counter = 0 #認識番号の右側、何番目に誕生した都市かを作るためのカウンター
        for city in pre:
            city_tags[city.id] = str(pre_num+1).zfill(6) + str(counter+1).zfill(6)
            counter += 1
    for tag in city_tags:
        print(tag)


if __name__ == '__main__':
    main()
Problem p03317 (python)

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

id = lst.index(1)

left = len(lst[0:id])
right = len(lst[id+1:])
mod = max(left%(k-1),right%(k-1))

total = left + right

counter = 0
while total > 0:
    counter += 1
    total -= k - 1

print(counter)

Buggy submission (verdict: Runtime Error):
#n=6 k=4
#
# 3 1 2 4 5 6


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

id_of_one = lst.index(1) #リスト内の最小値1のインデックスを取得

left = len(lst[0:id]) #1より左側にある数列の長さ
right = len(lst[id+1:]) #1より右側にある数列の長さ
total = left + right

amari = max(left%(k-1),right%(k-1))
total -= amari



counter = 0
while total > 0:
    counter += 1
    total -= k - 1

print(counter)

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

lst =  list(map(int,input().split()))

id_one = lst.index(1)
left_length = len(lst[0:id_one]-1)
right_length = len(lst[id_one:]-1)

counter = 0

if left_length > 0:
    left_length -= k
    counter += 1

while left_length > 0:
    counter += 1
    left_length -= k-1

if right_length > 0:
    counter += 1
    right_length -= k

while right_length > 0:
    counter += 1
    right_length -= k-1

print(counter)
Problem p02682 (python)

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

if k <= a:
    print(1 * k)
elif a < k and k <= (a + b):
    print(a)
else:
    print(a - ((k - (a + b)) * 1))

Buggy submission (verdict: Runtime Error):
a, b, c, k = map(int, input().split())

if k =< a:
  print(1 * k)
elif a < k and k <= (a+b):
  print(a)
else:
  print(a - ((k -(a+b)) * -1))
Problem p02723 (python)

Fixed submission:
s = input()
 
if s[2] == s[3] and s[4] == s[5]:
  print('Yes')
else:
  print('No')

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

if s[2] == s[3] and s[4] == s[5]:
  print('Yes')
else:
  print('No)
Problem p02759 (python)

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

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

if n % 2 == 0:
  print(int(n/2))
else:
  print(int((n/2)+1))
Problem p02847 (python)

Fixed submission:
s = input()

dict = {
    'SUN': 7,
    'MON': 6,
    'TUE': 5,
    'WED': 4,
    'THU': 3,
    'FRI': 2,
    'SAT': 1
}

print(dict[s])

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

dict = {
  'SUN':7
  'MON':6
  'TUE':5
  'WED':4
  'THU':3
  'FRI':2
  'SAT':1
}

print(dict[s])
Problem p03803 (python)

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

if a == 1:
  a += 13
if b == 1:
  b += 13

if a < b:
  ans = 'Bob'
elif a == b:
  ans = 'Draw'
else:
  ans = 'Alice'
print(ans)

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

if a < b:
  ans = 'Bob'
elif a == b:
  ans = 'Draw'
else:
  a > b:
    ans = 'Alice'
print(ans)
Problem p02629 (python)

Fixed submission:
n = int(input())

alp = 'abcdefghijklmnopqrstuvwxyz'

name = []

while n > 0:
    n -= 1
    name.append(alp[n % 26])
    n //= 26

name.reverse()

print(*name,sep='')

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

name = []

while n > 0:
    n -= 1
    name.append(alp[n % 26])
    n //= 26

name.reverse()

print(*name,sep='')
Problem p02659 (python)

Fixed submission:
from decimal import Decimal
a,b=input().split()
print(int(Decimal(a)*Decimal(b)))

Buggy submission (verdict: Runtime Error):
a, b = input().split()
a = int(a)
import math
b = math.floor(b*100)
ans = int(a*b/100)
print(ans)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
print(int(a*b))
Problem p02707 (python)

Fixed submission:
N = int(input())
a_list = list(map(int, input().split()))
a_list = [ (i+2, s) for i, s in enumerate(a_list) ]
a_list = sorted(a_list, key=lambda x: x[1])
count = 0
boss = 1
for a in a_list:
    if a[1] == boss:
        count += 1
    else:
        diff = a[1] - boss
        for _ in range(diff):
            print(count)
            count = 0
        boss = a[1]
        count += 1

for _ in range(N - a_list[-1][1]+1):
    print(count)
    count = 0

Buggy submission (verdict: Runtime Error):
 = int(input())
a_list = list(map(int, input().split()))
a_list = [ (i+2, s) for i, s in enumerate(a_list) ]
a_list = sorted(a_list, key=lambda x: x[1])
count = 0
boss = 1
for a in a_list:
    if a[1] == boss:
        count += 1
    else:
        diff = a[1] - boss
        for _ in range(diff):
            print(count)
            count = 0
        boss = a[1]
        count += 1

for _ in range(N - a_list[-1][1]+1):
    print(count)
    count = 0
Problem p02990 (python)

Fixed submission:
import math
def C(n,r):
  if n<0 or r<0 or n-r<0:
    return 0
  else:
    return math.factorial(n)//(math.factorial(r)*math.factorial(n-r))
 
n,k=map(int,input().split())
for i in range(1,k+1):
  print(C(n-k+1,i)*C(k-1,i-1)%(10**9+7))

Buggy submission (verdict: Runtime Error):
n, k = map(int,input().split())
from math import factorial
ans = []
if n == k:
    ans.append(1)
else:
    for i in range(1, k+1):
        if i >= n-k+1:
            c = 1
        else:
            c = factorial(n-k+1) // (factorial(n-k+1 - i) * factorial(i))
        if i > k-i:
            c2 = int(factorial(i) / (factorial(i-(k-i)) * factorial(k-i)))
        else:
            c2 = 1
        if c > 0:
            ans.append(c*c2)

mod = 10**9 + 7
for j in ans:
    print(j%mod)

Buggy submission (verdict: Runtime Error):
n, k = map(int,input().split())
from math import factorial
ans = []
if n == k:
    ans.append(1)
else:
    for i in range(1, k+1):
        c = int(factorial(n-k+1) / (factorial(n-k+1 - i) * factorial(i)))
        if i > k-i:
            c2 = int(factorial(i) / (factorial(i-(k-i)) * factorial(k-i)))
        else:
            c2 = 1
        if c > 0:
            ans.append(c*c2)

mod = 10**9 + 7
for j in ans:
    print(j%mod)

Buggy submission (verdict: Runtime Error):
n, k = map(int,input().split())
from math import factorial
ans = []
for i in range(1, k+1):
    c = factorial(n-k+1) // (factorial(n-k+1 - i) * factorial(i))
    if i > k-i:
        c2 = factorial(i) // (factorial(i-(k-i)) * factorial(k-i))
    else:
        c2 = 1
    if c == 0:
        break
    ans.append(c*c2)

mod = 10**9 + 7
for j in ans:
    print(j%mod)

Buggy submission (verdict: Runtime Error):
n, k = map(int,input().split())
from math import factorial
ans = []
for i in range(1, k+1):
    c = factorial(n-k+1) // (factorial(n-k+1 - i) * factorial(i))
    if c == 0:
        break
    ans.append(c)

mod = 10**9 + 7
for j in ans:
    print(j%mod)
Problem p03013 (python)

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

dp = [1] * (n+1)
dp[0] = 1
if 1 not in a_l:
    dp[1] = 1
else:
    dp[1] = 0
if n > 1:
    for i in a_l:
        dp[i] = 0
    if 2 not in a_l:
        dp[2] = dp[0] + dp[1]
    else:
        dp[2] = 0
    for i in range(2,n+1):
        if dp[i] != 0:
            dp[i] = (dp[i-1] + dp[i-2])%1000000007
print(dp[-1])

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

dp = [0] * (n+1)
dp[0] = 1
if 1 not in a_l:
    dp[1] = 1
else:
    dp[1] = 0
if 2 not in a_l:
    dp[2] = dp[0] + dp[1]
else:
    dp[2] = 0
for i in range(2,n+1):
    if i not in a_l:
        dp[i] = dp[i-1] + dp[i-2]
    else:
        dp[i] = 0
print(dp[-1]%1000000007)
Problem p02873 (python)

Fixed submission:
#!/usr/bin/python3
#coding: utf-8

S = input()
ret = 0

# 山を下る
i = 0
while i < len(S) and S[i] == ">":
    i += 1
    ret += i

# 山を登って降りる
n_up = 0
n_down = 0
while i < len(S):
    n_up = 0
    n_down = 0
    while i < len(S) and S[i] == "<":
        n_up += 1
        i += 1
        if i >= len(S):
            break
    while i < len(S) and S[i] == ">":
        n_down += 1
        i += 1
        if i >= len(S):
            break
    if n_up < n_down:
        n_up, n_down = n_down, n_up

    ret += ((n_up+1) * n_up) // 2
    ret += (n_down * (n_down-1)) // 2
    
print(ret)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/python3
#coding: utf-8

S = input()
ret = 0

# 山を下る
i = 0
while S[i] == ">":
    i += 1
    ret += i

# 山を登って降りる
n_up = 0
n_down = 0
while i < len(S):
    n_up = 0
    n_down = 0
    while i < len(S) and S[i] == "<":
        n_up += 1
        i += 1
        if i >= len(S):
            break
    while i < len(S) and S[i] == ">":
        n_down += 1
        i += 1
        if i >= len(S):
            break
    if n_up < n_down:
        n_up, n_down = n_down, n_up

    ret += ((n_up+1) * n_up) // 2
    ret += (n_down * (n_down-1)) // 2
    
print(ret)
Problem p02935 (python)

Fixed submission:
#coding: utf-8

N = int(input())
V = [int(v) for v in input().split()]

for i in range(N-1):
    V.sort()
    V.append((V[0]+V[1])/2)
    V = V[2:]

print (V[0])

Buggy submission (verdict: Runtime Error):
#include <math.h>

#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<double> V(N);
  for (size_t i = 0; i < N; i++) {
    cin >> V[i];
  }

  while (V.size() != 1) {
    sort(V.rbegin(), V.rend());
    int a = V.back();
    V.pop_back();
    int b = V.back();
    V.pop_back();
    V.push_back((double)(a + b) / (double)2.0);
  }

  printf("%lf\n", V[0]);

  return 0;
}

Buggy submission (verdict: Runtime Error):
#include <math.h>

#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<double> V(N);
  for (size_t i = 0; i < N; i++) {
    cin >> V[i];
  }

  while (V.size() != 1) {
    sort(V.rbegin(), V.rend());
    int a = V.back();
    V.pop_back();
    int b = V.back();
    V.pop_back();
    V.push_back((double)(a + b) / (double)2.0);
  }

  printf("%lf\n", V[0]);

  return 0;
}

Buggy submission (verdict: Runtime Error):
#include <math.h>

#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<long double> V(N);
  for (size_t i = 0; i < N; i++) {
    cin >> V[i];
  }

  while (V.size() != 1) {
    sort(V.rbegin(), V.rend());
    int a = V.back();
    V.pop_back();
    int b = V.back();
    V.pop_back();
    V.push_back((long double)(a + b) / (long double)2.0);
  }

  printf("%lf\n", V[0]);

  return 0;
}
Problem p02699 (python)

Fixed submission:
S, W = map(int, input().split())

if S <= W:
    print("unsafe")
else:
    print("safe")

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

if S < W:
    print("unsafe")
else:
    print("safe")
Problem p02701 (python)

Fixed submission:
import collections

N = int(input())
S = []

for i in range(N):
    S.append(input())

c = collections.Counter(S)

print(len(c))

Buggy submission (verdict: Runtime Error):
import collections

N = int(input())
S = []

for i in range(N):
    S.append(input())

c = collections.counter(S)

print(len(c))
Problem p02829 (python)

Fixed submission:
A = int(input())
B = int(input())

MON = 6
ANS = 6-A-B
print(ANS)

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

MON = 6
ANS =6-A-B
print(ANS)
Problem p02580 (python)

Fixed submission:
# -*- coding: utf-8 -*-

H,W,M = map(int, input().split())

count_H = [0 for _ in range(H)]
count_W = [0 for _ in range(W)]
bomb = set()

for _ in range(M):
  h,w = map(int, input().split())
  bomb.add((h-1,w-1))
  count_H[h-1] += 1
  count_W[w-1] += 1

def argmax(L):
  indices = []
  maximum = -1
  for i in range(len(L)):
    if L[i] > maximum:
      indices = [i]
      maximum = L[i]
    elif L[i] == maximum:
      indices.append(i)
  return indices,maximum

indices_H,max_H = argmax(count_H)
indices_W,max_W = argmax(count_W)

answer = max_H + max_W - 1
flg = -1
for h in indices_H:
  for w in indices_W:
    if (h,w) not in bomb:
      answer = max_H + max_W
      flg = 0
      break
  if flg == 0:
    break

print(answer)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

H,W,M = map(int, input().split())

count_H = [0 for _ in range(H)]
count_W = [0 for _ in range(W)]
bomb = set()

for _ in range(M):
  h,w = map(int, input().split())
  bomb.add((h-1,w-1))
  count_H[h-1] += 1
  count_W[w-1] += 1

def argmax(L):
  indeices = []
  maximum = 0
  for i in range(len(L)):
    if L[i]>maximum:
      indices = [i]
      maximum = L[i]
    elif L[i]==maximum:
      indices.append(i)
  return indices, maximum

indices_H, max_H = argmax(count_H)
indices_W, max_W = argmax(count_W)

answer = max_H + max_W - 1
flg = -1
for h in indices_H:
  for w in indices_W:
    if (h,w) not in bomb:
      answer = max_H + max_W
      flg = 0
      break
  if flg == 0:
    break

print(answer)
Problem p02829 (python)

Fixed submission:

A=int(input())
B=int(input())

if (A==1) and (B==2):
    print(3)
elif (A==1) and (B==3):
    print(2)
elif (A==2) and (B==1):
    print(3)
elif (A==2) and (B==3):
    print(1)
elif (A==3) and (B==1):
    print(2)
elif (A==3) and (B==2):
    print(1)

Buggy submission (verdict: Runtime Error):
a, b=(int(i) for i in input().split())

import fractions

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

print(lcm(a, b))
# 12
Problem p02831 (python)

Fixed submission:
a, b=(int(i) for i in input().split())

import fractions

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

print(lcm(a, b))

Buggy submission (verdict: Runtime Error):

a, b=(int(i) for i in input().split())

import math

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

print(lcm(a, b))
Problem p02847 (python)

Fixed submission:
S=input()
if (S=="SUN"):
    print(7)
elif (S=="MON"):
    print(6)
elif (S=="TUE"):
    print(5)
elif (S=="WED"):
    print(4)
elif (S=="THU"):
    print(3)
elif (S=="FRI"):
    print(2)
elif (S=="SAT"):
    print(1)

Buggy submission (verdict: Runtime Error):
N, K=(int(i) for i in input().split())
A=[int(i) for i in input().split()]

import numpy as np
from scipy.ndimage.interpolation import shift

res=[0]*(N+1)
res[1] = A[0]
for i in range(0,len(A)):
    res[i+1] = (res[i] + A[i])%K

array=np.array(res)
ans=0

for i in range(1,N):
    ans+=((array-shift(array,i,cval=0))%K==i).sum()
print(ans)
Problem p02571 (python)

Fixed submission:
s = input()
t = input()
l = []
for i in range(len(s)-len(t)+1):
    s2 = s[i:]
    cnt = 0
    for j in range(len(t)):
        if s2[j] == t[j]:
            cnt += 1
    l.append(cnt)
print(len(t)-max(l))

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
l = []
for i in range(len(t)):
    for j in range(i+1,len(t)+1):
        if t[i:j] in s[i:]:
            l.append(t[i:j])
l2 = []
for j in l:
    l2.append(len(j))
            
print(len(t) - max(l2))
Problem p02577 (python)

Fixed submission:
n = int(input())

if n%9 ==0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for i in range(n)]
res = 0
temp_max = 0
for x in a:
    if temp_max > x:
        res += temp_max - x
    temp_max = max(temp_max,x)

print(res)

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

if n/9 == n//9:
    print("Yes")
else:
    print("No")
Problem p02578 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
res = 0
temp_max = 0
for x in a:
    if temp_max > x:
        res += temp_max - x
    temp_max = max(temp_max,x)

print(res)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for i in range(n)]
res = 0
temp_max = 0
for x in a:
    if temp_max > x:
        res += temp_max - x
    temp_max = max(temp_max,x)

print(res)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for i in range(n)]
res = 0
for i in range(n-1):
    res += max(0,max(a[:-(i+1)])-a[-(i+1)])
print(res)
Problem p02627 (python)

Fixed submission:
a = input()
if a.isupper():
  print("A")
else:
  print("a")

Buggy submission (verdict: Runtime Error):
a = input()
if a.str.isupper():
  print("A")
else:
  print("a")
Problem p02836 (python)

Fixed submission:
s = input()
s_r = s[::-1]
cnt = 0
for i in range(len(s)):
    if s[i] != s_r[i]:
        cnt += 1
print(cnt//2)

Buggy submission (verdict: Runtime Error):
s = int(input())
s_r = s[::-1]
cnt = 0
for i in range(len(s)):
    if s[i] != s_r[i]:
        cnt += 1
print(cnt//2)
Problem p03307 (python)

Fixed submission:
import math

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

print(lcm_base(2,int(input())))

Buggy submission (verdict: Runtime Error):
def lcm_base(x,y):
    return (x * y) // math.gcd(x,y)

def n_lcm(*numbers):
    print(reduce(lcm_base,numbers,1))
    
n_lcm(2,int(input()))
Problem p03803 (python)

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

a = 14 if a == 1 else a
b = 14 if b == 1 else b

if a > b:
    print("Alice")
elif a < b:
    print("Bob")
else:
    print("Draw")

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

a = 14 if a == 1 else a
b = 14 if b == 1 else b

if a > b:
    print("Alice")
elif a < b:
    print("Bob")
else:
    print("Draw")
Problem p02623 (python)

Fixed submission:
import numpy as np
N, M, K = map(int, input().split())
A = np.cumsum([0] + list(map(int, input().split())))
B = np.cumsum([0] + list(map(int, input().split())))
ans = 0
j = M
for i in range(N+1):
  if A[i] > K:
    break
  while A[i] + B[j] > K:
    j -= 1
  ans = max(ans,i+j)
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N, M, K = map(int, input().split())
A = [0] + list(map(int, input().split()))
B = [0] + list(map(int, input().split()))

csA = np.cumsum(A)
csB = np.cumsum(B)

if csA[-1] + csB[-1] <= K:
    print(N+M)

else:
    
    ans = 0
               
    for i in range(N+1):
        wa = csA[i]
        numA = i
        if wa <= K:
            for j in range(M+1):
                numB = j
                wa += csB[j]
                if wa > K:
                    if numA + numB - 1 > ans:
                        ans = numA + numB - 1
                    break
                else:
                    wa = csA[i]
        else:
            break

    print(ans)
Problem p02688 (python)

Fixed submission:
N, K = map(int, input().rstrip().split())
sunuke = [int(i) for i in range(1,N + 1)]
d = []
A = []

for i in range(K):
  d.append(int(input()))
  A.append(list(map(int, input().split())))

for k in range(K):
  for i in range(d[k]):
    if A[k][i] in sunuke:
      sunuke.remove(A[k][i])
  
    
print(len(sunuke))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().rstrip().split())
sunuke = [int(i) for i in range(1,N + 1)]
d = []
A = []

for i in range(K):
  d.append(int(input()))
  A.append(list(map(int, input().split())))

for k in range(K):
  for i in range(d[k]):
    for j in A[i]:
      if j in sunuke:
        sunuke.remove(j)
    
print(len(sunuke))
Problem p02754 (python)

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

a = N//(A + B)
b = N%(A + B)

if A <= b:
  print(a*A + A)
else:
  print(a*A + b)

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

balls = ("b"*A + "r"*B)*p

if "r" in balls:
  print(len(balls[0:N].replace("r","")))
else:
  print(len(balls[0:N]))

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

balls = ("b"*A + "r"*B)*p
print(len(balls[0:N].replace("r","")))

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

balls = ("b"*A + "r"*B)*p

print(len(balls[0:N].replace("r","")))

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

balls = ""

while len(balls) < N:
  balls += "b"*A + "r"*B

print(len(balls[0:N].replace("r","")))
Problem p02793 (python)

Fixed submission:
import math


def main():
    MOD = 10 ** 9 + 7
    N = int(input())
    A = list(map(int, input().split(' ')))
    # 答えは sum(lcm(A) / A)
    L = 1
    for a in A:
        L = L * a // math.gcd(L, a)
    ans = 0
    for a in A:
        ans += L * pow(a, MOD - 2, MOD)
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def get_primes(n=10**6):
    primes = [2]
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if n <= p ** 2:
            return primes + data
        primes.append(p)
        data = [d for d in data if d % p != 0]


def main():
    MOD = 10 ** 9 + 7
    N = int(input())
    A = list(map(int, input().split(' ')))
    # 答えは sum(lcm(A) / A)
    primes = get_primes(max(max(A), 2))
    lcm_pf = [0] * len(primes)
    a_pf = [[0] * len(primes) for _ in range(N)]
    # lcm(A) の素因数分解表示を計算
    for i, a in enumerate(A):
        for j, p in enumerate(primes):
            while a % p == 0:
                a_pf[i][j] += 1
                a //= p
            if a == 1:
                break
        for j in range(len(primes)):
            lcm_pf[j] = max(lcm_pf[j], a_pf[i][j])
    # sum(lcm(A) / A) を計算
    ans = 0
    for i in range(N):
        v = 1
        for j, p in enumerate(primes):
            e = lcm_pf[j] - a_pf[i][j]
            v *= p ** e
            v %= MOD
        ans += v
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def get_primes(n=10**6):
    primes = [2]
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if n <= p ** 2:
            return primes + data
        primes.append(p)
        data = [d for d in data if d % p != 0]


def main():
    MOD = 10 ** 9 + 7
    N = int(input())
    A = list(map(int, input().split(' ')))
    # 答えは sum(lcm(A) / A)
    primes = get_primes(max(A))
    lcm_pf = [0] * len(primes)
    a_pf = [[0] * len(primes) for _ in range(N)]
    # lcm(A) の素因数分解表示を計算
    for i, a in enumerate(A):
        for j, p in enumerate(primes):
            while a % p == 0:
                a_pf[i][j] += 1
                a //= p
            if a == 1:
                break
        for j in range(len(primes)):
            lcm_pf[j] = max(lcm_pf[j], a_pf[i][j])
    # sum(lcm(A) / A) を計算
    ans = 0
    for i in range(N):
        v = 1
        for j, p in enumerate(primes):
            e = lcm_pf[j] - a_pf[i][j]
            v *= p ** e
            v %= MOD
        ans += v
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()