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

Fixed submission:
s = list(input())
i = len(set(s))
if i == 1:
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
qaws = ""
c = 0
while(N > len(qaws)):
  qaws = qaws + "B"*A
  qaws = qaws + "R"*B
  c += 1
print(qaws[:N].count("B"))
Problem p02754 (python)

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

Buggy submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
qaws = ""
while(N > len(qaws)):
  qaws += ("B"*A)
  qaws += ("R"*B)
print(qaws[:N].count("B"))

Buggy submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
qaws = ""
while(N > len(qaws)):
  qaws += ("B"*A)
  qaws += ("R"*B)
print(qaws[:N].count("B")

Buggy submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
qaws = ""
c = 0
while(N > len(qaws)):
  qaws = qaws + "B"*A
  qaws = qaws + "R"*B
  c += 1
print(qaws[:N].count("B"))

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

qaws = ""
c = 0
while(N >= c):
  qaws = qaws + "B"*A
  qaws = qaws + "R"*B
  c += 1
print(qaws[:N].count("B"))

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

qaws = ""
c = 0
while(N >= c):
  qaws = qaws + "B"*A
  qaws = qaws + "R"*B
  c += 1
print(qaws)
print(qaws[:N].count("B"))
Problem p02779 (python)

Fixed submission:
import collections
s = int(input())
a = list(map(str, input().split()))
n = {}
for i in a:
  n.setdefault(i, 0)
for i in a:
  n[i] += 1
x = 0
for i in n.values():
  if x <= i:
    x = i
if x == 1:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
p = list(map(int,input().split()))
ans = 0
for i in range(n-k+1):
    x = 0
    for j in p[i:i+k]:
        z = 0
        for a in range(1,j+1):
            z+=a*(1/j)
        x+=z
    ans = max(x,ans)
print(ans)
Problem p02879 (python)

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

if A >= 10 or B >= 10:
    print(-1)
else:
    print(A*B)

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

l = []
for i in range(1, 10):
    for j in range(1, 10):
        l.append(i * j)

if N in l:
    print('Yes')
else:
    print('No')
Problem p03317 (python)

Fixed submission:
import math

n,k = map(int,input().split())
a = list(map(int,input().split()))
print(math.ceil((n-k)/(k-1))+1)

Buggy submission (verdict: Runtime Error):
//#define _GLIBCXX_DEBUG
//#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin >> n >> k;
    int a[n]; for (int i = 0; i<n; i++) cin >> a[i];
    cout << (((n-k)+(k-2))/(k-1))+1 << "\n";
}

Buggy submission (verdict: Runtime Error):
//#define _GLIBCXX_DEBUG
//#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin >> n >> k;
    int a[n];
    cout << (((n-k)+(k-2))/(k-1))+1 << "\n";
}
Problem p03345 (python)

Fixed submission:
a,b,c,k = map(int,input().split())
ans = 0
if k==0 or k%2==0:
    ans = a-b
else:
    ans = b-a
if len(str(abs(ans)))==20:
    print("Unfair")
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
a,b,c,k = map(int,input().split())
ans = 0
if k==0 and k%2==0:
    ans = a-b
else:
    ans = b-a
if len(ans)==20:
    print("Unfair")
else:
    print(ans)
Problem p02625 (python)

Fixed submission:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def comb(a,b):
        return f[a]*inv[b]*inv[a-b]%mod
    n,m = LI()
    N = n+m
    f = [1]*(N+1)
    for i in range(1,N+1):
        f[i] = f[i-1]*i%mod
    inv = [None]*(N+1)
    inv[N] = pow(f[N],mod-2,mod)
    for i in range(N)[::-1]:
        inv[i] = inv[i+1]*(i+1)%mod
    ans = comb(m,n)*f[n]
    for i in range(1,n+1):
        if i&1:
            ans -= comb(n,i)*comb(m-i,n-i)*f[n-i]%mod
        else:
            ans += comb(n,i)*comb(m-i,n-i)*f[n-i]%mod
        ans %= mod
    print(ans*comb(m,n)*f[n]%mod)
    return

#Solve
if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
mem = defaultdict(lambda : None)
mem[(0,0,0)] = 0
def dp(a,b,s):
  if mem[(a,b,s)] is not None:
    return mem[(a,b,s)]
  x = a&1
  y = b&1
  xor = s&1
  res = float("inf")
  if x^y != xor:
    mem[(a,b,s)] = res
    return res
  else:
    res = 2*dp(a>>1,b>>1,s>>1)
    if a > 1:
      pants = 2*dp((a-1)>>1,(b+1)>>1,s>>1)+1
      if pants < res:
        res = pants
  mem[(a,b,s)] = res
  return res

n = int(input())
a = list(map(int, input().split()))
s = 0
for i in a[2:]:
  s ^= i
b = a[1]
a = a[0]
ans = dp(a,b,s)
if ans == float("inf"):
  ans = -1
print(ans)
Problem p02777 (python)

Fixed submission:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    s,t = LS()
    a,b = LI()
    u = S()
    d = defaultdict(lambda : 0)
    d[0] = a
    d[1] = b
    if s == u:
        d[0] -= 1
    else:
        d[1] -= 1
    print(d[0],d[1])
    return

#Solve
if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    s,t = input().split()
    a,b = LI()
    d = {}
    d[s] = a
    d[t] = b
    u = input()
    d[u] -= 1
    print(d[s],d[t])
    return

#Solve
if __name__ == "__main__":
    solve()
Problem p03135 (python)

Fixed submission:
#!usr/bin/env python3
from collections import defaultdict
import math
def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()
def IIR(n): return [II() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
mod = 1000000007

#A
t,x = LI()
print(t/x)
#B

#C

#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Buggy submission (verdict: Runtime Error):
#!usr/bin/env python3
from collections import defaultdict
import math
def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()
def IIR(n): return [II() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
mod = 1000000007

#A
"""
t,x = LI()
print(t/x)
"""

#B
"""
n= II()
a = LI()
m = max(a)
if m >= sum(a)-m:
    print("No")
else:
    print("Yes")
"""

#C
"""
n,m = LI()
x = LI()
x.sort()
l = [x[i+1]-x[i] for i in range(m-1)]
l.sort()
l = l[::-1]
ans = sum(l[max(n-1,0):])
print(ans)
"""

#D
n,k = LI()
a = LI()
l = 0
b = [0 for i in range(n)]
for i in range(n):
    b[i] = list(bin(a[i]))[2:]
    l = max(l,len(b[i]))
s = [0 for i in range(l)]
for i in range(n):
    for j in range(l-len(b[i])):
        b[i].insert(0,"0")
for i in range(n):
    for j in range(l):
        s[j] += 1-int(b[i][j])
ke = 1
ans = 0
i = l-1
while i >= 0:
    if s[i] <= n//2:
        ans += (n-s[i])*ke
        s.pop(i)
    else:
        ans += (n-s[i])*ke
        s[i] = [(2*s[i]-n)*ke,ke]
    i -= 1
    ke *= 2
s.sort(key = lambda x:x[0])
s = s[::-1]
d = 0
key = len(list(bin(k)))-2
key -= l
ke = 2**l
for i in range(key):
    d += ke
    ans += n*ke
    ke *= 2
w = len(s)
if w == 0:
    print(ans)
    quit()
b = ans
c = d
for i in range(w):
    q,p = s[i]
    if d+p <= k:
        d += p
        ans += q
import random
for j in range(10):
    a = b
    e = c
    l = [i for i in range(w)]
    for _ in range(w-1):
        i = random.randint(0,len(l)-1)
        i = l.pop(i)
        q,p = s[i]
        if e+p <= k:
            e += p
            a += q
    ans = max(ans,a)
print(ans)
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T
Problem p03834 (python)

Fixed submission:
s = input().split(",")
for i in range(len(s)):
    if i < len(s):
        print(s[i],end = " ")
    else:
        print(s[i])

Buggy submission (verdict: Runtime Error):
s = input(),split(" ")
print(s[0]," ",s[1]," ",s[2])
Problem p02580 (python)

Fixed submission:
from collections import Counter

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

    retu = Counter()
    gyo = Counter()

    ipt = [set() for _ in range(H)]

    for _ in range(M):
        a, b = map(int, input().split())
        retu[a-1] += 1
        gyo[b-1] += 1
        ipt[a-1].add(b-1)

    rm = retu.most_common()
    rmm = rm[0][1]
    gm = gyo.most_common()
    gmm = gm[0][1]

    for r in rm:
        if r[1] < rmm:
            break
        for g in gm:
            if g[1] < gmm:
                break

            if g[0] not in ipt[r[0]]:
                return rmm+gmm
    
    return rmm+gmm-1

print(solver())

Buggy submission (verdict: Runtime Error):
from collections import Counter

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

    retu = Counter()
    gyo = Counter()

    ipt = [[0]*W for _ in range(H)]

    for _ in range(M):
        a, b = map(int, input().split())
        retu[a-1] += 1
        gyo[b-1] += 1
        ipt[a-1][b-1] = 1

    rm = retu.most_common()
    rmm = rm[0][1]
    gm = gyo.most_common()
    gmm = gm[0][1]

    for r in rm:
        if r[1] < rmm:
            break
        for g in gm:
            if g[1] < gmm:
                break

            if ipt[r[1]][g[1]] == 0:
                return rmm+gmm
    
    return rmm+gmm-1

print(solver())
Problem p02881 (python)

Fixed submission:
N = int(input())

ress = []

for i in range(1, int(N**0.5)+1):
    if N % i == 0:
        ress.append(i+N//i)

print(min(ress)-2)

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

ress = []

for i in range(1, int(N**0.5)):
    if N % i == 0:
        ress.append(i+N//i)

print(min(ress)-2)
Problem p02948 (python)

Fixed submission:
import heapq
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

AB = sorted(AB, key=lambda x: x[0])

x = 0
res = 0

hq = []
heapq.heapify(hq)

for i in range(M):
    for j in range(x, N):
        if AB[j][0] > i+1:
            x = j
            break
        heapq.heappush(hq, AB[j][1]*-1)
    else:
        x = N
    
    if hq:
        res += heapq.heappop(hq)*-1

print(res)

Buggy submission (verdict: Runtime Error):
import heapq
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

AB = sorted(AB, key=lambda x: x[0])

x = 0
res = 0

hq = []
heapq.heapify(hq)

for i in range(M):
    for j in range(x, N):
        if AB[j][0] > i+1:
            x = j
            break
        heapq.heappush(hq, AB[j][1]*-1)
    else:
        x = N
    
    print(hq)
    if hq:
        res += heapq.heappop(hq)*-1

print(res)
Problem p02990 (python)

Fixed submission:
from math import factorial as f
N, K = map(int,input().split())

WARU = 10**9+7

def nCr(n, r):
    return f(n)//(f(r)*f(n-r))


for i in range(K):
    if i <= N-K:
        print((nCr(K-1, i) * nCr(N-K+1, i+1)) % WARU)
    else:
        print(0)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)
from math import factorial as f
N, K = map(int,input().split())

WARU = 10**9+7

def nCr(n, r):
    return f(n)//(f(r)*f(n-r))


for i in range(K):
    print((nCr(K-1, i) * nCr(N-K+1, i+1)) % WARU)

Buggy submission (verdict: Runtime Error):
from math import factorial as f
N, K = map(int,input().split())

WARU = 10**9+7

def nCr(n, r):
    return (f(n)%WARU) // ((f(r)*f(n-r))%WARU)


for i in range(K):
    print((nCr(K-1, i) * nCr(N-K+1, i+1))%WARU)

Buggy submission (verdict: Runtime Error):
from math import factorial as f
N, K = map(int,input().split())

WARU = 10**9+7

def nCr(n, r):
    return f(n)//(f(r)*f(n-r))


for i in range(K):
    print((nCr(K-1, i) * nCr(N-K+1, i+1)) % WARU)
Problem p03013 (python)

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

b = [0]*(N+2)
b[0] = 1

for i in range(M):
    b[int(input())] = -1

for i in range(N):
    if b[i] != -1:
        if b[i+1] != -1:
            b[i+1] += b[i]
        if b[i+2] != -1:
            b[i+2] += b[i]

print(b[N]%1000000007)

Buggy submission (verdict: Runtime Error):
N, M = list(map(int,input().split()))
a = [int(input()) for i in range(M)]

b = [0]*N

if 1 not in a:
    b[0] = 1

if 2 not in a:
    if b[0] == 1:
        b[1] = 2
    else:
        b[1] = 1

for i in range(2,N):
    if i+1 not in a:
        if b[i-2] != 0:
            b[i]+= b[i-2]
        if b[i-1] != 0:
            b[i]+= b[i-1]

print(b[N-1]%1000000007)

Buggy submission (verdict: Runtime Error):
N, M = list(map(int,input().split()))
a = [int(input()) for i in range(M)]

b = [0]*N

if 1 not in a:
    b[0] = 1

if 2 not in a:
    if b[0] == 1:
        b[1] = 2
    else:
        b[1] = 1

for i in range(2,N):
    if i+1 not in a:
        if b[i-2] != 0:
            b[i]+= b[i-2]
        if b[i-1] != 0:
            b[i]+= b[i-1]
print(b)
print(b[N-1]%1000000007)
Problem p03038 (python)

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

A = [-1]
A += list(map(int,input().split()))
A.sort()

BC = [[1,-1]]

for i in range(M):
    BC.append(list(map(int,input().split())))

BC = sorted(BC, key=lambda x: x[1])


x = 0

for i in range(N):
    if A[-1] > BC[-1][1]:
        x += A.pop()
        
    else:
        x += BC[-1][1]
        BC[-1][0] -= 1
        if BC[-1][0] == 0:
            BC.pop()

print(x)

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

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

BC = []

for i in range(M):
    BC.append(list(map(int,input().split())))

BC = sorted(BC, key=lambda x: x[1])

BC.reverse()

idx = N-1

for i in range(M):
    B, C = BC[i]

    while idx >= 0:
        if A[idx] < C:
            idx += 1
            break
        idx -= 1
    else:
        break

    if B >= idx:
        A = [C]*idx + A[idx:]
        break
    else:
        A = A[B:idx] + [C]*B + A[idx:]

print(sum(A))
Problem p03221 (python)

Fixed submission:
from operator import itemgetter
N, M = map(int, input().split())
iPY = [0]*M
res = [0]*M
for i in range(M):
    P, Y = map(int, input().split())
    iPY[i] = (i, P, Y)
iPY.sort(key=itemgetter(2))
iPY.sort(key=itemgetter(1))
j = 1
p = iPY[0][1]
for i, P, Y in iPY:
    if P != p:
        j = 1
        p = P
    res[i] = "{:06}{:06}".format(P, j)
    j += 1
for s in res:
    print(s)

Buggy submission (verdict: Runtime Error):
from operator import itemgetter
N, M = map(int, input().split())
iPY = [0]*M
res = [0]*M
for i in range(M):
    iPY[i] = (i, *map(int, input().split()))
iPY.sort(key=itemgetter(2))
iPY.sort(key=itemgetter(1))
j = 1
p = iPY[0][1]
for i, P, Y in iPY:
    if P != p:
        j = 1
        p = P
    res[i] = "{:06}{:06}".format(P, j)
    j += 1
for s in res:
    print(s)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ken = [[] for _ in range(N)]
shi = [tuple(map(int, input().split())) for _ in range(M)]
for s1, s2 in shi:
    ken[s1-1].append(s2)
for k in ken:
    k.sort()
for s1, s2 in shi:
    print("{:06}{:06}".format(s1, ken[s1-1].index(s2+1)))
Problem p03631 (python)

Fixed submission:
print("YNeos"[(s:=input())!=s[::-1]::2])

Buggy submission (verdict: Runtime Error):
print("YNeos"[s:=input()==s[::-1]]::2)
Problem p02689 (python)

Fixed submission:
#!/usr/bin/env python3
n, m = map(int, input().split())
*h, = map(int, input().split())
h = [0] + h
i = [0] + [1] * n

for j in range(m):
    a, b = map(int, input().split())
    if h[a] >= h[b]:
        i[b] = 0
    if h[a] <= h[b]:
        i[a] = 0
print(sum(i))

Buggy submission (verdict: Runtime Error):
a = 0
x = int(input())
for a in range(x):
    b = (x - a**5)**.2
    if type(b) in (int,float) and float.is_integer(float(b)):
        print(a, -int(b))
        exit()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
a = 1
x = int(input())
while True:
    bz = (x-a**5)**.2
    if float.is_integer(bz):
        print(a, -int(bz))
        exit()
    a += 1
Problem p02753 (python)

Fixed submission:
s = input()
if s == "AAA" or s == "BBB":
    print("No")
    exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
s, _, q = open(0)
g = ""
for q in q:
  p, f, c = q.split()
  if p == "1":
    g, s = s, g
  else:
    if f == "1":
      g += c
    else:
      s += c
print(g[::-1] + s)
Problem p02766 (python)

Fixed submission:
n, k = map(int, input().split())
ans = 0
while True:
    if n // (k ** ans) == 0:
        break
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
ans = 0
while True:
    if n // (k ** ans) == 0:
        break
    a += 1
print(ans)
Problem p02862 (python)

Fixed submission:
#!/usr/bin/env python3
X, Y = map(int, input().split())
if (X + Y) % 3:
    exit(print(0))
m = (2*X - Y) // 3
n = X - 2*m
if n < 0 or m < 0:
    exit(print(0))

## class
def egcd(a, b):
    if a == 0:
        return (b, 0, 1)
    else:
        g, y, x = egcd(b % a, a)
        return (g, x - (b // a) * y, y)

def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

def power(a, b, c):
    try:
        return pow(a, b, c)
    except (ValueError, TypeError) as e:
        if b < 0:
            return pow(modinv(a, c), -b, c)
        else:
            print(e)

class Factorial:
    def __init__(self, n, mod):
        self.f = f =[0] * (n + 1)
        f[0] = b = 1
        for i in range(1, n + 1):f[i] = b = b * i % mod
        self.inv = inv = [0] * (n + 1)
        inv[n] = b = power(self.f[n], -1, mod)
        for i in range(n,0,-1):inv[i-1] = b = b * i % mod
        self.mod = mod
    def factorial(self, i):
        return self.f[i]
    def ifactorial(self, i):
        return self.inv[i]
    def comb(self, n, k):
        if n >= k:return self.f[n] * self.inv[n - k] * self.inv[k] % self.mod
        else:return 0

def nCr(n, r, mod = None, limit = None):
    if mod and limit:
        return Factorial(limit, mod).comb(n, r)
    elif mod:
        r = min(r, n - r)
        a = 1
        for i in range(r):
            a = a * (n - i) * power(i + 1, mod - 2, mod) % mod
        return a
    else:
        from math import factorial as f
        return f(n) // (f(n - r) * f(r))

MOD = 10**9+7
print(nCr(m + n, n, MOD, 2*10**6))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
X, Y = map(int, input().split())
if (X + Y) % 3:
    exit(print(0))
m = (2*X - Y) // 3
n = X - 2*m
if n < 0 or m < 0:
    exit(print(0))

class Factorial:
    def __init__(self, n, mod):
        self.f = f =[0] * (n + 1)
        f[0] = b = 1
        for i in range(1, n + 1):f[i] = b = b * i % mod
        self.inv = inv = [0] * (n + 1)
        inv[n] = b = pow(self.f[n], -1, mod)
        for i in range(n,0,-1):inv[i-1] = b = b * i % mod
        self.mod = mod
    def factorial(self, i):
        return self.f[i]
    def ifactorial(self, i):
        return self.inv[i]
    def comb(self, n, k):
        if n >= k:return self.f[n] * self.inv[n - k] * self.inv[k] % self.mod
        else:return 0

def nCr(n, r, mod = None, limit = None):
    if mod and limit:
        return Factorial(limit, mod).comb(n, r)
    elif mod:
        r = min(r, n - r)
        a = 1
        for i in range(r):
            a = a * (n - i) * pow(i + 1, mod - 2, mod) % mod
        return a
    else:
        from math import factorial as f
        return f(n) // (f(n - r) * f(r))

MOD = 10**9+7
print(nCr(m + n, n, MOD, 2*10**6))
Problem p02933 (python)

Fixed submission:
print("red" if int(input()) < 3200 else input())

Buggy submission (verdict: Runtime Error):
print(red if int(input()) < 3200 else input())
Problem p02948 (python)

Fixed submission:
from heapq import*
(N, M), *t = [map(int, s.split()) for s in open(0)]
q = [0] * 10**5
v = [[] for _ in q]
for a, b in t:
    v[a - 1] += b,
z = 0
for i in v[:M]:
    for j in i:
        heappush(q, -j)
    z += -heappop(q)
print(z)

Buggy submission (verdict: Runtime Error):
from heapq import*
(N, M), *t = [map(int, s.split()) for s in open(0)]
v = [[] for _ in [0] * 10**5]
q = [0, 0]
for a, b in t:
    v[a - 1] += b,
z = 0
for i in v[:M]:
    for j in i:
        heappush(q, -j)
    z += -heappop(q)
print(z)

Buggy submission (verdict: Runtime Error):
from heapq import*
(N, M), *t = [map(int, s.split()) for s in open(0)]
v = [[] for _ in [0] * 10**5]
q = [0]
for a, b in t:
    v[a - 1] += b,
z = 0
for i in v[:M]:
    for j in i:
        heappush(q, -j)
    z += -heappop(q)
print(z)

Buggy submission (verdict: Runtime Error):
from heapq import*
(N, M), *t = [map(int, s.split()) for s in open(0)]
v = [[] for _ in [0] * 10**5]
q = []
for a, b in t:
    v[a - 1] += b,
z = 0
for i in v[:M]:
    for j in i:
        heappush(q, -j)
    z += -heappop(q)
print(z)
Problem p02954 (python)

Fixed submission:
from itertools import*
a = [len(list(l)) for _, l in groupby(input())]
for p, q in zip(a[::2], a[1::2]):
    print("0 "*~-p, -~p//2 + q//2, p//2 + -~q//2, "0 "*~-q, end="")

Buggy submission (verdict: Runtime Error):
from itertools import*
for p, q in zip(*[len(list(l)) for _, l in groupby(input())]*2):
    print("0 "*~-p, -~p//2 + q//2, p//2 + -~q//2, "0 "*~-q, end="")
Problem p02990 (python)

Fixed submission:
#!/usr/bin/env python3
from math import factorial as f
n, k = map(int, input().split())
mod = 10**9+7
for i in range(k):
    try:
        print(f(n - k + 1) * f(k - 1) // f(i + 1) // f(n - k - i) // f(i) // f(k - i - 1) % mod)
    except ValueError:
        print(0)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
from math import factorial as f
n, k = map(int, input().split())
mod = 10**9+7
for i in range(k):
    print(f(n - k + 1) * f(k - 1) // f(i + 1) // f(n - k - i) // f(i) // f(k - i - 1) % mod)
Problem p03013 (python)

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

mod = 10**9+7

dp = [0] * -~n
dp[0] = 1
dp[1] = 0 + (1 not in a)

for i in range(2, -~n):
    if i in a:
        continue
    dp[i] = (dp[i - 1] + dp[i - 2]) % mod

print(dp[n])

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
n, m = map(int, input().split())
a = eval("int(input()),"*m)
f = lambda j: j not in a

mod = 10**9+7

dp = [0] * -~n
dp[0] = 1
dp[1] = f(1)

for i in range(2, -~n):
    dp[i] += (dp[i - 1] + dp[i - 2]) * f(i) % mod

print(dp[n])