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

Fixed submission:
import sys
input = sys.stdin.readline

MOD = 1000000007

def comb_mod(n, r, mod):
    if n < r:
        return 0
    elif n < 0 or r < 0:
        return 0
    else:
        fac = [1, 1]
        finv = [1, 1]
        inv = [0, 1]
        for i in range(2, n + 1):
            fac.append(fac[-1] * i % mod)
            inv.append(-inv[mod % i] * (mod // i) % mod)
            finv.append((finv[-1] * inv[-1]) % mod)

        return int(fac[n] * finv[r] * finv[n - r] % mod)

x, y = map(int, input().split())
m = int((x * 2 - y) / 3)
n = int(x - 2 * m)

if (x + y) % 3 != 0:
    print(0)
else:
    print(comb_mod(n + m, n, MOD))

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


class CmbMod:
    def __init__(self, n, p):
        """
        二項係数nCr(n個の区別できるものからr個のものを選ぶ組み合わせの数)をpで割った余りを求める
        """
        self.n = n
        self.p = p
        self.fact = [1, 1]
        self.factinv = [1, 1]
        self.inv = [0, 1]

    def cmb_mod(self, n, r):
        """
        二項係数nCr(mod p)をO(r)にて計算。nが大きいがrは小さい時に使用。
        """
        numer, denom = 1, 1
        for i in range(r):
            numer = (numer * (n - i)) % self.p
            denom = (denom * (i + 1)) % self.p
        return (numer * pow(denom, self.p - 2, self.p)) % self.p

    def prep(self):
        """
        二項係数nCr(mod p)をO(1)で求める為の前処理をO(N)にて実行。
        """
        for i in range(2, self.n + 1):
            self.fact.append((self.fact[-1] * i) % self.p)
            self.inv.append((-self.inv[self.p % i] * (self.p // i)) % self.p)
            self.factinv.append((self.factinv[-1] * self.inv[-1]) % self.p)

    def cmb_mod_with_prep(self, n, r):
        """
        二項係数nCr(mod p)をO(1)で求める。事前にprepを実行する事。
        """
        if (r < 0) or (n < r):
            return 0
        r = min(r, n - r)
        return self.fact[n] * self.factinv[r] * self.factinv[n - r] % self.p


def resolve():
    X, Y = map(int, input().split())
    if (X + Y) % 3:
        print(0)
        exit()

    cnt = (X + Y) // 3
    for i in range(cnt):
        if (i * 1 + (cnt - i) * 2 == X and i * 2 + (cnt - i) * 1 == Y) or (
                i * 1 + (cnt - i) * 2 == Y and i * 2 + (cnt - i) * 1 == X):
            left = i
            break

    cmb = CmbMod(cnt, mod)
    res = cmb.cmb_mod(cnt, left)
    print(res)


if __name__ == '__main__':
    resolve()

Buggy submission (verdict: Runtime Error):
from math import factorial
import sys
input = sys.stdin.readline

x, y = map(int, input().split())
mod = 10 * 9 + 7
m = (x * 2 - y) / 3
n = x - 2 * m
if (x + y) % 3:
    ans = 0
else:
    ans = factorial(m + n) / factorial(n) / factorial(m)% mod

print(int(ans))

Buggy submission (verdict: Runtime Error):
from scipy.special import comb

x, y = map(int, input().split())
mod = 10 * 9 + 7
m = (x * 2 - y) / 3
n = x - 2 * m
if (x + y) % 3:
    ans = 0
else:
    ans = comb(m + n, n, exact=True) % mod

print(ans)
Problem p02881 (python)

Fixed submission:
import math

n = int(input())
divisors = []
for i in range(1, int(n**0.5) +1):
    if n % i == 0:
        divisors.append(i)
        if i != n // i:
            divisors.append(n//i)

ans = math.pow(10, 12)
tmp = 0
for i in divisors:
    j = n / i
    tmp = i + j -2
    if tmp < ans:
        ans = tmp

print(int(ans))

Buggy submission (verdict: Runtime Error):
n = int(input())
divisors = []
for i in range(1, int(pow(n, 0.5)) + 1):
    if n % i == 0:
        if i != n // i:
            divisors.append([i, n // i])
        else:
            divisors.append([i])
divisors = sorted(divisors, key= lambda x:x[1])
res = divisors[0][0] - 1 + divisors[0][1] - 1
print(res)
Problem p02948 (python)

Fixed submission:
import sys
input = sys.stdin.readline
import heapq

n, m = map(int, input().split())
jobs = [[] for i in range(m)]
for i in range(n):
    a, b = map(int, input().split())
    if a > m:
        pass
    else:
        jobs[m - a].append(b)

if len(jobs) == 0:
    print(0)
    exit(0)

q = []
heapq.heapify(q)
ans = 0
for i in reversed(range(m)):
    for b in jobs[i]:
        heapq.heappush(q, -b)
    if len(q) != 0:
        ans += heapq.heappop(q) * -1

print(ans)

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

flg = False
n, m = map(int, input().split())
jobs = [[] for i in range(m)]
for i in range(n):
    a, b = map(int, input().split())
    if a > m and flg == False:
        jobs[m - a].append(b)
    else:
        flg = True
        jobs[m - a].append(b)

if flg == False:
    print(0)
    exit(0)

q = []
heapq.heapify(q)
ans = 0
for i in reversed(range(m)):
    for b in jobs[i]:
        heapq.heappush(q, -b)
    if len(q) != 0:
        ans += heapq.heappop(q) * -1

print(ans)
Problem p03018 (python)

Fixed submission:
s = input()
s = s.replace('BC', 'D')

ans = a = 0
for i in s:
    if i == "A":
        a += 1
    elif i == "D":
        ans += a
    else:
        a = 0
print(ans)

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

i = 0
res = 0
cnt = 0
while i != len(s) - 2:
    if s[i] == "A" and s[i + 1] == "A":
        cnt += 1
        i += 1
    elif s[i] == "A" and s[i + 1] == "B" and s[i + 2] == "C":
        res += cnt + 1
        s[i], s[i + 1], s[i + 2] = "B", "C", "A"
        cnt = 0
        i += 1
    else:
        cnt = 0
        i += 1
print(res)
Problem p03045 (python)

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

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

tree = [[] for _ in range(n)]
for _ in range(m):
    x, y, z = map(int, input().split())
    tree[x - 1].append(y - 1)
    tree[y - 1].append(x - 1)

visited = [False for _ in range(n)]


def dfs(v, p):
    for u in tree[v]:
        if u == p:
            continue
        elif visited[u]:
            continue
        else:
            visited[u] = True
            dfs(u, v)


res = 0
for i in range(n):
    if not visited[i]:
        visited[i] = True
        dfs(i, -1)
        res += 1

print(res)

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

tree = [[] for _ in range(n)]
for _ in range(m):
    x, y, z = map(int, input().split())
    tree[x - 1].append(y - 1)
    tree[y - 1].append(x - 1)

visited = [False for _ in range(n)]


def dfs(v, p):
    for u in tree[v]:
        if u == p:
            continue
        if visited[u]:
            continue
        else:
            visited[u] = True
            dfs(u, v)


res = 0
for i in range(n):
    if not visited[i]:
        dfs(i, -1)
        res += 1
print(res)
Problem p03053 (python)

Fixed submission:
from collections import deque

H, W = map(int, input().split())
grid = [input() for i in range(H)]

cnt = [[-1]*W for _ in range(H)]

que = deque()
for h in range(H):
    for w in range(W):
        if grid[h][w] == '#':
            que.append((h, w))
            cnt[h][w] = 0

ans = 0
while que:
    h, w = que.popleft()
    ans = cnt[h][w]
    for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
        next_h = h + dy
        next_w = w + dx
        if next_h < 0 or H <= next_h or next_w < 0 or W <= next_w:
            continue
        if cnt[next_h][next_w] == -1:
            cnt[next_h][next_w] = ans+1
            que.append((next_h, next_w))

print(int(ans))

Buggy submission (verdict: Runtime Error):
from subprocess import call
call (('pypy3', '-c', """
from collections import deque

H, W = map(int, input().split())
grid = [input() for i in range(H)]

cnt = [[-1]*W for _ in range(H)]

que = deque()
for h in range(H):
    for w in range(W):
        if grid[h][w] == '#':
            que.append((h, w))
            cnt[h][w] = 0

ans = 0
while que:
    h, w = que.popleft()
    ans = cnt[h][w]
    for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
        next_h = h + dy
        next_w = w + dx
        if next_h < 0 or H <= next_h or next_w < 0 or W <= next_w:
            continue
        if cnt[next_h][next_w] == -1:
            cnt[next_h][next_w] = ans+1
            que.append((next_h, next_w))

print(int(ans))
Problem p03464 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    k = int(input())
    A = list(map(int, input().split()))[::-1]

    if A[0] != 2:
        print(-1)
    else:
        prev_min, prev_max = 2, 3
        for i in range(1, k):
            a = A[i]
            if a > prev_max:
                print(-1)
                break
            else:
                if prev_min % a == 0:
                    now_min = prev_min
                else:
                    now_min = (prev_min // a + 1) * a
                if now_min > prev_max:
                    print(-1)
                    break
                diff = prev_max - now_min
                now_max = now_min + (diff // a + 1) * a - 1
                prev_min, prev_max = now_min, now_max
        else:
            print(prev_min, prev_max)


if __name__ == '__main__':
    resolve()

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    k = int(input())
    A = list(map(int, input().split()))[::-1]

    if A[0] != 2:
        print(-1)
    else:
        prev_min, prev_max = 2, 3
        for i in range(1, k):
            a = A[i]
            if a > prev_max:
                print(-1)
                break
            else:
                if prev_min % a == 0:
                    now_min = prev_min
                else:
                    now_min = (prev_min // a) * a + a
                now_max = now_min + a - 1
                prev_min, prev_max = now_min, now_max
        else:
            print(now_min, now_max)


if __name__ == '__main__':
    resolve()
Problem p03724 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())

    cnt = [0] * n
    for i in range(m):
        a, b = map(int, input().split())
        cnt[a - 1] += 1
        cnt[b - 1] += 1

    for i in cnt:
        if i % 2:
            print("NO")
            break
    else:
        print("YES")


if __name__ == '__main__':
    resolve()

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())

    cnt = [0] * n
    for i in range(n):
        a, b = map(int, input().split())
        cnt[a - 1] += 1
        cnt[b - 1] += 1

    for i in cnt:
        if i % 2:
            print("NO")
            break
    else:
        print("YES")


if __name__ == '__main__':
    resolve()
Problem p02793 (python)

Fixed submission:
#! /usr/bin/env python3
N = int(input())
A = [int(i) for i in input().split()]

def gcd(a, b):
    while b > 0:
        c = a % b
        a = b
        b = c
    return int(a)

def lcm(a, b):
    return a // gcd(a, b) * b

l = 1
for i in range(N):
    l = lcm(l, A[i])

ans = 0
MOD = int(1e9 + 7)
for a in A:
    ans += int(l // a)
    # ans %= MOD

print(ans % MOD)

Buggy submission (verdict: Runtime Error):
#! /usr/bin/env python3

N = int(input())
A = [int(i) for i in input().split()]

def gcd(a, b):
    return a if b == 0 else gcd(b, a % b)

def lcm(a, b):
    return a / gcd(a, b) * b

l = 1
for i in range(N):
    l = lcm(l, A[i])

ans = 0
MOD = int(1e9 + 7)
for i in range(N):
    ans += int(l // A[i])
    ans %= MOD

print(ans)
Problem p02829 (python)

Fixed submission:
A=int(input())
B=int(input())
if(A==1 and B==2):
  answer=3
elif(A==1 and B==3):
  answer=2
elif(A==2 and B==3):
  answer=1
elif(A==2 and B==1):
  answer=3
elif(A==3 and B==1):
  answer=2
elif(A==3 and B==2):
  answer=1
print(answer)

Buggy submission (verdict: Runtime Error):
A=int(input())
B=int(input())
if(A==1 and B==2):
	x=3
elif(A==2 and B==3):
	x=1
elif(A==3 and B==1):
	x=2
print(x)

Buggy submission (verdict: Runtime Error):
A=int(input())
B=int(input())
if(A==1 and B==2):
  answer=3
elif(A==2 and B==3):
  answer=1
elif(A==3 and B==1):
  answer=2
print(answer)

Buggy submission (verdict: Runtime Error):
A=int(input())
B=int(input())
if(A==1 and B==2):
  answer==3
elif(A==2 and B==3):
  answer==1
elif(A==3 and B==1):
  answer==2
print(answer)

Buggy submission (verdict: Runtime Error):
A=int(input())
B=int(input())
if(A==1 and B==2):
  answer=3
elif(A==2 and B==3):
  answer=1
elif(A==3 and B==1):
  answer=2
print(answer)

Buggy submission (verdict: Runtime Error):
A=input()
B=input()
if(A==1 and B==2):
  answer=3
elif(A==2 and B==3):
  answer=1
elif(A==3 and B==1):
  answer=2
print(answer)
Problem p02831 (python)

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

Buggy submission (verdict: Runtime Error):
import math
a,b = map(int,input().split())
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a, b))

Buggy submission (verdict: Runtime Error):
import fractions
A, B = map(int, input().split())
x = A * B // gcd(A, B)
print(x)

Buggy submission (verdict: Runtime Error):
import fractions
A=int(input())
B=int(input())
x = A * B // gcd(A, B)
print(x)

Buggy submission (verdict: Runtime Error):
import math
A=int(input())
B=int(input())
x = A * B // gcd(A, B)
print(x)

Buggy submission (verdict: Runtime Error):
import math
A=int(input())
B=int(input())
x = A * B / gcd(A, B)
print(x)
Problem p03075 (python)

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
List=[a,b,c,d,e]
for i in range(len(List)):
    for j in range(i+1,len(List)):
        if List[j]-List[i]>k:
            print(":(")
            exit()
print("Yay!")

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
List=[a,b,c,d,e]
for i in range(len(List)):
    for j in range(i+1,len(List)+1):
        if List[j]-List[i]>k:
            print(":(")
            exit()
print("Yay!")
Problem p02580 (python)

Fixed submission:
h,w,m = map(int,input().split())
hw = [[int(i) for i in input().split()] for j in range(m)]

tate = [0]*(w+1)
yoko = [0]*(h+1)

for i in range(m):
    yoko[hw[i][0]] += 1
    tate[hw[i][1]] += 1
    
ans = 0

t_max = -1


for i in range(1,w+1):
    if t_max < tate[i]:
        t_max = tate[i]
        t_max_idx = []
        t_max_idx.append(i)
    elif t_max == tate[i]:
        t_max_idx.append(i)

y_max = -1

for i in range(1,h+1):
    if y_max < yoko[i]:
        y_max = yoko[i]
        y_max_idx = []
        y_max_idx.append(i)
    elif y_max == yoko[i]:
        y_max_idx.append(i)
        
s_y = set(y_max_idx)
s_t = set(t_max_idx)

if len(y_max_idx)*len(t_max_idx) > m:
    print(t_max+y_max)
else:
    ans = 0
    for i in range(m):
        if hw[i][0] in s_y and hw[i][1] in s_t:
            ans += 1
    if ans < len(y_max_idx)*len(t_max_idx):
        print(t_max+y_max)
    else:
        print(t_max+y_max-1)

Buggy submission (verdict: Runtime Error):
h,w,m = map(int,input().split())
hw = [[int(i) for i in input().split()] for j in range(m)]

tate = [0]*(w+1)
yoko = [0]*(h+1)

for i in range(m):
    yoko[hw[i][0]] += 1
    tate[hw[i][1]] += 1
    
ans = 0

t_max = -1


for i in range(1,w+1):
    if t_max < tate[i]:
        t_max = tate[i]
        t_max_idx = []
        t_max_idx.append(i)
    elif t_max == tate[i]:
        t_max_idx.append(i)

y_max = -1

for i in range(1,h+1):
    if y_max < yoko[i]:
        y_max = yoko[i]
        y_max_idx = []
        y_max_idx.append(i)
    elif y_max == yoko[i]:
        y_max_idx.append(i)
        
#s_y = set(y_max_idx)
#s_t = set(t_max_idx)

if len(y_max_idx)*len(t_max_idx) > m:
    print(t_max+y_max)
else:
    ans = 0
    for i in range(m):
        if hw[i][0] in s_y and hw[i][1] in s_t:
            ans += 1
    if ans < len(y_max_idx)*len(t_max_idx):
        print(t_max+y_max)
    else:
        print(t_max+y_max-1)
Problem p02598 (python)

Fixed submission:
import heapq
n,k = map(int,input().split())
a = [int(i) for i in input().split()]

low = 0
high = 10**9

if k == 0:
    print(max(a))
    exit()

    
while low+1 < high:
    tmp = 0
    mid = (low + high) //2
    
    for i in range(n):
        tmp += ((a[i]+mid-1) // mid)-1
        
    if tmp <= k:
        high = mid
    else:
        low = mid
        
print(high)

Buggy submission (verdict: Runtime Error):
import heapq
n,k = map(int,input().split())
a = [int(i) for i in input().split()]

low = 1
high = 10**9

if n == 1:
    print((a[0]+k-1)//k)
    exit()

while low+1 < high:
    tmp = 0
    mid = (low + high) //2
    #print(mid)
    
    for i in range(n):
        tmp += ((a[i]+mid-1) // mid)-1
    
    if tmp <= k:
        high = mid
    else:
        low = mid
        
print(high)

Buggy submission (verdict: Runtime Error):
import heapq
n,k = map(int,input().split())
a = [int(i) for i in input().split()]

low = 1
high = 10**9

if n == 1:
    print((a[0]+k-1)//k)
    exit()

while low+1 < high:
    tmp = 0
    mid = (low + high) //2
    #print(mid)
    
    for i in range(n):
        tmp += ((a[i]+mid-1) // mid)-1
    print(tmp,mid)
    
    if tmp <= k:
        high = mid
    else:
        low = mid
        
print(high)
Problem p02862 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**9)
import time

t1 = time.time()

x,y = map(int,input().split())
kyori = x+y
if kyori % 3 !=0:
    print(0)
    exit()
    
mod = 10**9+7

nagasa = kyori // 3
dif = x - y

n_x = (nagasa + dif) // 2
n_y = nagasa - n_x

#print(nagasa,n_x,n_y)

if x != n_x * 2 + n_y * 1 or y != n_x * 1+ n_y*2:
    print(0)
    exit()

if n_x < 0 or n_y < 0:
    print(0)
    exit()
#H, W, A, B = map(int, raw_input().split())

def kj(n, x,y, mod):
    #if ( r<0 or r>n ):
     #   return 0
    #r = min(r, n-r)
    return g1[n] * g2[x] * g2[y] % mod

g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, kyori // 3 + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


a = kj(nagasa,n_x,n_y,mod)
print(a)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)
import time

t1 = time.time()

x,y = map(int,input().split())
kyori = x+y
if kyori % 3 !=0:
    print(0)
    exit()
    
mod = 10**9+7

nagasa = kyori // 3
dif = x - y

n_x = (nagasa + dif) // 2
n_y = nagasa - n_x

#print(nagasa,n_x,n_y)

if x != n_x * 2 + n_y * 1 or y != n_x * 1+ n_y*2:
    print(0)
    exit()

#H, W, A, B = map(int, raw_input().split())

def kj(n, x,y, mod):
    #if ( r<0 or r>n ):
     #   return 0
    #r = min(r, n-r)
    return g1[n] * g2[x] * g2[y] % mod

g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, kyori // 3 + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


a = kj(nagasa,n_x,n_y,mod)
print(a)
Problem p02863 (python)

Fixed submission:
n,t = map(int,input().split())
ab = [[int(i) for i in input().split()] for j in range(n)]

dp = [[0 for i in range(t)] for j in range(n+1)]
ab.sort()

ans = 0

for i in range(n):
    for j in range(t):
        #for k in range(2):
        #dp[i+1][j] = max(dp[i][j],dp[i-1][j])
        dp[i+1][j] = dp[i][j]
        #print(j,ab[i][0])
        if j >= ab[i][0]:
        #if dp[i][j] < dp[i][j-ab[i][0]] + ab[i][1]:
        #    dp[i+1][j] = dp[i][j-ab[i][0]] + ab[i][1]
            dp[i+1][j] = max(dp[i][j],dp[i][j-ab[i][0]] + ab[i][1])
        #print(dp)
    #print(h,dp)

#print(ab)
#print(dp)


max_num = [0]*n

for i in reversed(range(n)):
    #print(i)
    if i == 0:
        break
    if max_num[i] < ab[i][1]:
        max_num[i-1] = ab[i][1]
    else:
        max_num[i-1] = max_num[i]

#print(max_num)
#print(ab[2272:2336])
#exit()

ans = 0
for i in range(n-1):
    #print(i)
    if ans < dp[i+1][t-1]+max_num[i]:
        ans = dp[i+1][t-1]+max_num[i]
        #print(i,ans,max_num[i],max_num[i+1],max_num[i-1])
    #ans = max(ans,)
    #print(max(ab[i:][1]))
    #print()
        
print(ans)
#print())

Buggy submission (verdict: Runtime Error):
import copy
n,t = map(int,input().split())
ab = [[int(i) for i in input().split()] for j in range(n)]

dp = [[0 for i in range(t)] for j in range(n+1)]
li = [[[] for i in range(t)] for j in range(n+1)]

for i in range(n):
    for j in range(t):
        dp[i+1][j] = dp[i][j]
        li[i+1][j] = li[i][j]
        #print(j,ab[i][0])
        if j < ab[i][0]:
            continue
        if dp[i][j] < dp[i][j-ab[i][0]] + ab[i][1]:
            dp[i+1][j] = dp[i][j-ab[i][0]] + ab[i][1]
            li[i+1][j].append(i)
        #dp[i+1][j] = max(dp[i][j],dp[i][j-ab[i][0]] + ab[i][1])

abcopy = copy.deepcopy(ab)
abcopy.sort()

plus = 0
for i in range(n):
    if i in li:
        continue
    else:
        plus = abcopy[i][0]

print(dp[n][t]+plus)
Problem p02954 (python)

Fixed submission:
s = input()

ans = [0] * len(s)

cnt = 0

for i in range(len(s)):
    if s[i] == 'R':
        cnt += 1
    else:
        ans[i] += cnt // 2
        ans[i-1] += (cnt+1) // 2
        cnt = 0

ans.reverse()
#print(ans)
#exit()

s_list = list(reversed(s))
#s.reverse()

cnt = 0

for i in range(len(s_list)):
    if s_list[i] == 'L':
        s_list[i] = 'R'
    else:
        s_list[i] = 'L'

for i in range(len(s_list)):
    if s_list[i] == 'R':
        cnt += 1
    else:
        ans[i] += cnt // 2
        ans[i-1] += (cnt+1) // 2
        cnt = 0

ans.reverse()

print(*ans)

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

s = s.replace('RL','A')

r_num = 0
l_num = 0

l = []
r = []
print(s)
now = "l"
for i in range(len(s)):
    if i == len(s) - 1 and s[i] == 'L':
        l.append(l_num+1)
    if s[i] == 'A':
        if s[i-1] == 'R':
            r.append(r_num)
            r_num = 0
            if now == 'r':
                l.append(0)
            now = 'r'
        elif s[i-1] == 'L':
            l.append(l_num)
            l_num = 0
            if now == 'l':
                r.append(0)
            now = 'l'
        else:
            r_num = 0
            l_num = 0
            r.append(r_num)
            l.append(l_num)
    elif s[i] == 'R':
        if s[i-1] == 'L' and i != 0:
            #print(l_num,i)
            l.append(l_num)
            #now = 'r'
        r_num += 1
        l_num = 0
        
    else:
        now = 'l'
        l_num += 1
        r_num = 0

ans = []

for i in range(len(l)):
    for j in range(r[i]):
        ans.append(0)
    if max(r[i],l[i])%2 == 0:
        ans.append(r[i]+1)
        ans.append(l[i]+1)
    else:
        ans.append(l[i]+1)
        ans.append(r[i]+1)
    
    for k in range(l[i]):
        ans.append(0)

print(*ans,sep="")
Problem p02990 (python)

Fixed submission:
import sys
import numpy as np
from scipy.misc import comb
sys.setrecursionlimit(1000000)
 
n,k = map(int,input().split())

mod = 10**9+7
ans = 0

for i in range(1,k+1):
    print(comb(n-k+1, i, exact=True) * comb(k-1, i-1, exact=True) % mod)

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
from scipy.special import comb
sys.setrecursionlimit(1000000)
 
n,k = map(int,input().split())

mod = 10**9+7
ans = 0

for i in range(1,k+1):
    print(comb(n-k+1, i, exact=True) * comb(k-1, i-1, exact=True) % mod)