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

Fixed submission:
from itertools import permutations 

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

perm = list(permutations(range(1, N+1), N))
print(abs(perm.index(P) - perm.index(Q)))

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

perm = list(permutations(range(1, N+1), N))
print(abs(perm.index(P) - perm.index(Q)))

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

perm = list(permutations(range(1, N+1), N))
print(abs(perm.index(P) - perm.index(Q)))

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

perm = list(permutations(range(1, N+1), N))
print(abs(perm.index(P) - perm.index(Q)))

Buggy submission (verdict: Runtime Error):
import itertools
import math
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
L = list(map(list,list(itertools.permutations(list(i for i in range(1,N+1)),N))))
a = L.index(P)
b = L.index(Q)
print(abs(a-b))
Problem p02830 (python)

Fixed submission:
new_str, num, string = "", int(input()), input().split(" ")
for x in range(0, num):
    new_str += string[0][x] + string[1][x]
print(new_str)

Buggy submission (verdict: Runtime Error):
new_str, num, string = "", int(input()), input().split(" ")
for x in range(0, num):
    new_str += string[0][x] + string[1][x]
print(new_str)
Problem p02743 (python)

Fixed submission:
a, b, c = list(map(int, input().split(' ')))
sub = c-a-b
if sub > 0 and 4*a*b < sub*sub:#計算が成立するためには、c-a-b > 0が必要
        print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
a, b, c = list(map(int, input().split(' ')))
a_m = a%10**9
b_m = b%10**9
c_m = c%10**9
sub = (c_m - a_m - b_m)&mod10**9

if 4*a_m*b_m < sub*sub:
    print('Yes')
else:
    print('No')
Problem p02744 (python)

Fixed submission:
al=[chr(ord('a') + i) for i in range(26)]
def dfs(N, f):
    if len(f) == N:
        return f
    else:
        result = ""
        f_index = [al.index(i) for i in f]
        for i in range(max(f_index) +1 + 1):#追加できるのは(f+1) + 1
            result +=dfs(N,  f + al[i])
        return result

N = int(input())
ans = dfs(N, 'a')
for i in range(int(len(ans) / N)):
    print(ans[N*i : N * (i+1)])

Buggy submission (verdict: Runtime Error):
al=[chr(ord('a') + i) for i in range(26)]
def dfs2(N, f):
    if len(f) == N:
        return f
    else:
        result = ""
        f_index = [al.index(i) for i in f]
        for i in range(max(f_index) +1 + 1):#追加できるのは(f+1) + 1
            result +=dfs(N,  f + al[i])
        return result

N = int(input())
ans = dfs2(N, 'a')
for i in range(int(len(ans) / N)):
    print(ans[N*i : N * (i+1)])
Problem p02756 (python)

Fixed submission:
S = input()
Q = int(input())
front = ""
flag = 1
for i in range(Q):
    q =  [ i for i in input().split(' ')]
    if q[0] == '1':
        flag = flag * -1
    else:
        if flag == 1: 
            if q[1] == '1':
                front+=q[2]
            else:
                S += q[2]
        else:
            if q[1] == '1':
                S +=q[2]
            else:
                front+= q[2]
            
if flag ==1:
    print(front[::-1] + S)
else:
    print(S[::-1] + front)

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

for k in range(Q):
    q =  [ i for i in input().split(' ')]
    if q[0] == '1':
        if not len(S) == 1:
            head = S[0]
            tail = S[-1]
            S = tail + S[1:-1] + head
            print(S)
    else:
        if q[1] == '1':
            S = q[2] + S
            print(S)
        else:
            S = S + q[2]
            print(S)
print(S)
Problem p02765 (python)

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

if N < 10:
    ans = R + (100 * (10 - N))
    print(ans)
else:
    print(R)

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

if N < 10:
    ans = R + (100 * (10 - N))
    print(ans)
else:
    print(R)
Problem p02797 (python)

Fixed submission:
import collections
n,k,s = input().split()



dq = collections.deque()
max_value = str(10**9)
if int(s) !=10**9:
    for i in range(int(k)):
        dq.append(s)
    for i in range(int(n)-int(k)):
        dq.append(max_value)
    ans = " ".join(list(dq))
    print(ans)
else:
    for i in range(int(k)):
        dq.append(s)
    for i in range(int(n)-int(k)):
        dq.append("1")
    ans = " ".join(list(dq))
    print(ans)

Buggy submission (verdict: Runtime Error):
import collections
n,k,s = input().split()

dq = collections.deque()
max_value = str(10**9)
if int(s) !=10**9:
    for i in range(int(k)):
        dq.append(s)
    for i in range(int(n)-int(k)):
        dq.append(max_value)
    ans = " ".join(list(dq))
    print(ans)
else:
    for i in range(int(k)):
        dq.append(s)
    for i in range(int(n)-int(k)):
        dq.append(1)
    ans = " ".join(list(dq))
    print(ans)
Problem p02845 (python)

Fixed submission:
n = input()
A=[int(j) for j in input().split()]

nums = [0,0,0]
ans = 1
for a in A:
  ans = (ans*nums.count(a))%(10**9 +7)
  for i in range(len(nums)):
        if nums[i] == a:
            nums[i] = a+1
            break
          
print(ans)

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

nums = [0,0,0]
ans = 1
for a in A:
  ans = (ans*nums.count(a))%(10**9 +7)
  nums[nums.index(a)] +=1
print(ans)

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

nums = [0,0,0]
ans = 1
for a in A:
  ans = (ans*nums.count(a))%(10**9 +7)
  nums[nums.index(a)] +=1
print(ans)
Problem p03493 (python)

Fixed submission:
s = input()
print(s.count('1'))

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

def devision(num_list, count):
    new_num_list = []
    for num in num_list:
        if num%2 ==0:
            new_num_list.append(num//2)
        else:
            print(count)
            return
    count += 1
    return devision(new_num_list, count)

devision(num_list, 0)
Problem p03999 (python)

Fixed submission:
S = [int(i) for i in input()]

N = len(S)

tens = [10**i for i in range(N)]

tens.reverse()

twos = [1]
twos.extend(2**i for i in range(N-1))

sums = 0
all_comb = sum(twos)
for i in range(N):
    tmp = [x*y for x, y in zip(tens[i:], twos)]
    exp = S[i] * sum(tmp) / sum(twos)
    sums = sums + exp
    del twos[-1]
print(int(sums * all_comb))

Buggy submission (verdict: Runtime Error):
S = [int(i) for i in input()]

N = len(S)

tens = [10**i for i in range(N)]

tens.reverse()

twos = [1]
twos.extend(2**i for i in range(N-1))

sums = 0
all_comb = sum(twos)
for i in range(N):
    tmp = [x*y for x, y in zip(tens[i:], twos)]
    exp = S[i] * sum(tmp) / sum(twos)
    print(exp)
    sums = sums + exp
    del twos[-1]
print(sums * all_comb)

sum(map(mul, tens,twos))
Problem p03060 (python)

Fixed submission:
num = int(input())
lists = [list(map(int,input().split())) for i in range(2)]
nums = [lists[0][j] - lists[1][j] for j in range(num)]
x = 0
for i in nums:
  if i > 0:
    x += i
  else:
    continue
print(x)

Buggy submission (verdict: Runtime Error):
num = int(input())
lists = [list(map(int,input().split())) for i in range(2)]
nums = [lists[0][j] - lists[1][j] for j in range(num)]
print(sorted(nums,reverse=True)[0]+sorted(nums,reverse=True)[1])
Problem p03068 (python)

Fixed submission:
n = int(input())
list =list(input())
m = ""
j = int(input()) - 1
for i in range(n):
  if list[i] == list[j]:
    m += list[j]
  else:
    m += "*"
print(m)

Buggy submission (verdict: Runtime Error):
n = int(input())
list =list(input())
m = ""
j = int(input())
for i in range(n):
  if list[i] == list[j]:
    m += list[j]
  else:
    m += "*"
print(m)
Problem p03071 (python)

Fixed submission:
list = list(map(int, input().split()))
print(max([list[0]*2-1,list[0]+list[1],list[1]*2-1]))

Buggy submission (verdict: Runtime Error):
if int(input()) == 1:
    msg = "Hello World!"
else:
    a = [int(input()) for i in range(2)]
    msg = a[0]+a[1]
print(msg)

Buggy submission (verdict: Runtime Error):
list = list(map(input().split(), int))
print(max([list[0]*2-1,list[0]+list[1],list[1]*2-1]))
Problem p02760 (python)

Fixed submission:
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
N = int(input())
numbers = list()
for i in range(N):
    numbers.append(int(input()))

bingo = False
for a in A:
    if a not in numbers:
        break
else:
    bingo = True

for b in B:
    if b not in numbers:
        break
else:
    bingo = True

for c in C:
    if c not in numbers:
        break
else:
    bingo = True

columnA = [A[0],B[0],C[0]]
for i in columnA:
    if i not in numbers:
        break
else:
    bingo = True

columnB = [A[1],B[1],C[1]]
for i in columnB:
    if i not in numbers:
        break
else:
    bingo = True

columnC = [A[2],B[2],C[2]]
for i in columnC:
    if i not in numbers:
        break
else:
    bingo = True

diagA = [A[0],B[1],C[2]]
for i in diagA:
    if i not in numbers:
        break
else:
    bingo = True

diagB = [A[2],B[1],C[0]]
for i in diagB:
    if i not in numbers:
        break
else:
    bingo = True

print("Yes" if bingo else "No")

Buggy submission (verdict: Runtime Error):
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
N = int(input())
numbers = list()
for i in range(N):
    numbers.append(int(input()))

bingo = False
for a in A:
    if a not in numbers:
        break
else:
    bingo = True

for b in B:
    if b not in numbers:
        break
else:
    bingo = True

for c in C:
    if c not in numbers:
        break
else:
    bingo = True

columnA = [A[0],B[0],C[0]]
for i in columnA:
    if i not in numbers:
        break
else:
    bingo = True

columnB = [A[1],B[1],C[1]]
for i in columnB:
    if i not in numbers:
        break
else:
    bingo = True

columnC = [A[2],B[2],C[2]]
for i in columnB:
    if i not in numbers:
        break
else:
    bingo = True

diagA = [A[0],B[1],C[2]]
for i in diagA:
    if i not in numbers:
        break
else:
    bingo = True

diagB = [A[3],B[2],C[1]]
for i in diagB:
    if i not in numbers:
        break
else:
    bingo = True

print("Yes" if bingo else "No")
Problem p03262 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import fractions
from functools import reduce

N,X = map(int,input().split())

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

absList =[0] * len(toshiList)

for i in range(0,len(toshiList)):
    absList[i] = abs( toshiList[i] - X)

ans = reduce(fractions.gcd,absList)
    
print(ans)

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

N,X = map(int,input().split())

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

absList =[0] * len(toshiList)

for i in range(0,len(toshiList)):
    absList[i] = abs( toshiList[i] - X)

ans = reduce(math.gcd,absList)
    
print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from functools import reduce
import math

N,X = map(int,input().split())

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

absList =[0] * len(toshiList)

for i in range(0,len(toshiList)):
    absList[i] = abs( toshiList[i] - X)

ans = reduce(math.gcd,absList)
    
print(ans)

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

N,X = map(int,input().split())

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

absList =[0] * len(toshiList)

for i in range(0,len(toshiList)):
    absList[i] = abs( toshiList[i] -X)

ans = functools.reduce(math.gcd,absList)

    
print(ans)
Problem p02717 (python)

Fixed submission:

A = list(map(int,input().split()))
n = A[0]
A[0] = A[2]
A[2] = A[1]
A[1] = n
print(A[0], A[1], A[2])

Buggy submission (verdict: Runtime Error):
X,Y,Z = int(input().split())
n = X
X = Z
Z = Y
Y = n
print(X, Y, Z)

Buggy submission (verdict: Runtime Error):
a=list(map(int,input().split()))
print (f"{a[2]} {a[0]} {a[1]}")

Buggy submission (verdict: Runtime Error):
a=list(map(int,input().split()))
b= [a[2], a[0], a[1]]
print (f"{b[0]} {b[1]} {b[2]}")

Buggy submission (verdict: Runtime Error):
a=list(map(int,input().split()))
n=a[1]
a[1]=a[0]
a[0]=a[2]
a[2]=n
print (f"{a[0]} {a[1]} {a[2]}")

Buggy submission (verdict: Runtime Error):
a=list(map(int,input().split()))
n=a[1]
a[1]=a[0]
a[0]=a[2]
a[2]=n
print (f"{a[0]} {a[1]} {a[2]}")

Buggy submission (verdict: Runtime Error):
a=list(map(int,input().split()))
n=a[0]
a[0]=a[1]
a[1]=a[2]
a[2]=n
print (f"{a[0]} {a[1]} {a[2]}")

Buggy submission (verdict: Runtime Error):
a=list(map(int, input().split()))
n=a[0]
a[0]=a[2]
a[2]=a[1]
a[1]=n
for i in range (len(a)):
  print a[i],
Problem p02765 (python)

Fixed submission:
a = list(map(int, input().split()))
if a[0]< 10:
    print (a[1]+100*(10-a[0]))
else:
    print (a[1])

Buggy submission (verdict: Runtime Error):
a= list(map(int, input().split()))
if a[0]<10:
	print(a[1]-100*(10-a[0])
else:
	print(a[1])

Buggy submission (verdict: Runtime Error):
a= list(map(int, input().split()))
if a[0]<10:
  print(a[1]-100*(10-a[0])
else:
  print(a[1])
Problem p02866 (python)

Fixed submission:
from collections import Counter
n = int(input())
D = list(map(int, input().split()))
p = 998244353

def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p

count_dict = sorted(Counter(D).items(), key=lambda x:x[0])
count_list = list(dict(count_dict).values())

if len(count_list) == max(D) + 1 and not 0 in D[1:]:
    ans = 1
    for i in range(len(count_list)):
        if i == 0:
            if D[0] == 0:
                pass
            else:
                ans = 0
                break
        else:
            ans *= power_func(count_list[i - 1], count_list[i], p)
else:
    ans = 0

ans %= p
print(ans)

Buggy submission (verdict: Runtime Error):
def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p

count_dict = sorted(Counter(D).items(), key=lambda x:x[0])
count_list = list(dict(count_dict).values())

if len(count_list) == max(D) + 1 and not 0 in D[1:]:
    ans = 1
    for i in range(len(count_list)):
        if i == 0:
            if D[0] == 0:
                pass
            else:
                ans = 0
                break
        else:
            ans *= power_func(count_list[i - 1], count_list[i], p)
else:
    ans = 0

ans %= p
print(ans)
Problem p02885 (python)

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

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
print(max(a - 2 * b, 0)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
print(max(20-(a + b), 0)
Problem p03239 (python)

Fixed submission:
N, T = map(int, input().split())
m = 1001
for i in range(N):
    c,t = map(int,input().split())
    if t <= T: m = min(m,c)
print("TLE" if m == 1001 else m)

Buggy submission (verdict: Runtime Error):
N, T = map(int, input().split())
m=1001
for i in range(N):
    c,t=map(int,input().split())
    if t<=T:m=min(m,c)
print("TLE" if m==1001 else m
Problem p03290 (python)

Fixed submission:
import numpy as np
d, g = map(int, input().split())
p = []
c = []
for _ in range(d):
    _p, _c = map(int, input().split())
    p.append(_p)
    c.append(_c)

s = np.arange(1, d + 1) * 100
p = np.array(p)

ans_list = []

bool_list = [False] * d

state_list = []

def dfs(i, n, bool_list):
    bool_list = bool_list.copy()
    if i == n:
        state_list.append(bool_list)
    else:
        dfs(i + 1, n, bool_list)
        bool_list[i] = True
        dfs(i + 1, n, bool_list)

dfs(0, d, bool_list)

for state in state_list:
    if np.dot(s * p, state) + np.dot(c, state) >= g:
        ans_list.append(np.dot(p, state))
    else:
        score = max(s * np.array([not i for i in state]))
        for j in range(1, p[score//100 - 1] + 1):
            if np.dot(s * p, state) + np.dot(c, state) + score * j >= g:
                ans_list.append(np.dot(p, state) + j)

print(min(ans_list))

Buggy submission (verdict: Runtime Error):
d, g = map(int, input().split())
p = []
c = []
for _ in range(d):
    _p, _c = map(int, input().split())
    p.append(_p)
    c.append(_c)

res = 0
count = 0
ans_list = []

def dfs(i, p, c, res, count):
    if i == 0:
        if res >= g:
            ans_list.append(count)
    else:
        for j in reversed(range(p[i - 1] + 1)):
            _count = count + j
            _res = res + 100 * j * i
            if j == p[i - 1]:
                _res += c[i - 1]
            if res <= g:
                dfs(i - 1, p, c, _res, _count)
                break

dfs(d, p, c, res, count)
print(min(ans_list))

Buggy submission (verdict: Runtime Error):
p = []
c = []
d, g = map(int, input().split())
for _ in range(d):
    _p, _c = map(int, input().split())
    p.append(_p)
    c.append(_c)

ans_list = []

def dfs(i, p, c, res, count):
    if i == 0:
        if res >= g:
            ans_list.append(count)
    else:
        for j in range(p[i - 1] + 1):
            _count = count + j
            _res = res + 100 * j * i
            if j == p[i - 1]:
                _res += c[i - 1]
            dfs(i - 1, p, c, _res, _count)

dfs(d, p, c, res, count)
print(min(ans_list))

Buggy submission (verdict: Runtime Error):
d, g = map(int, input().split())
p = []
c = []
for _ in range(d):
    _p, _c = map(int, input().split())
    p.append(_p)
    c.append(_c)

ans_list = []

def dfs(i, p, c, res, count):
    if i == 0:
        if res >= g:
            ans_list.append(count)
    else:
        for j in range(p[i - 1] + 1):
            _count = count + j
            _res = res + 100 * j * i
            if j == p[i - 1]:
                _res += c[i - 1]
            dfs(i - 1, p, c, _res, _count)

dfs(d, p, c, res, count)
print(min(ans_list))
Problem p04045 (python)

Fixed submission:
N, K = map(int, input().split())
D = list(map(int, input().split()))
while True:
    l = [int(x) for x in str(N)]
    for e in l:
        if e in D:
            N += 1
            break
    else:
        break
print(N)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
D = list(map(int, input().split()))
D = list(set(D))
nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
for d in D:
    nums.remove(d)
l = [int(x) for x in str(N)]
ans = []
for i, e in enumerate(l):
    if e in D:
        for num in nums:
            if e < num:
                ans.append(str(num))
        else:
            for _ in range(i + 1, len(l)):
                ans.append(str(min(nums)))
            break
    else:
        ans.append(str(e))
print(int(''.join(ans)))
Problem p03076 (python)

Fixed submission:
#ABC123

a = [int(input()) for _ in range(5)]
b = [a[i] // 10 for i in range(5)]
c = [10] + sorted([a[i] % 10 for i in range(5) if a[i] % 10 != 0])

s = 10 * sum(b) + (len(c)-2) * 10 + min(c)

print(s)

Buggy submission (verdict: Runtime Error):
#ABC123

a = [int(input()) for _ in range(5)]
b = [a[i] // 10 for i in range(5)]
c = sorted([a[i] % 10 for i in range(5) if a[i] % 10 != 0])
s = 10 * sum(b) + c[0] + (len(c)-1) * 10


print(s)
Problem p03086 (python)

Fixed submission:
#ABC122

s = input()

d = ["A","T","G","C"]
l = []
count = 0
for i in range(len(s)):
    if s[i] not in d:
        l.append(count)
        count = 0
    else:
        count += 1
    #print(count)
l.append(count)
print(max(l))

Buggy submission (verdict: Runtime Error):
#ABC122

s = input()

d = ["A","T","G","C"]
l = []
count = 0
for i in range(len(s)):
    if s[i] not in d:
        l.append(count)
        count = 0
    else:
        count += 1
    #print(count)
print(max(l))
Problem p03761 (python)

Fixed submission:
n = int(input())
s = [input() for _ in range(n)]
t = ""
for i in set(s[0]):
    #print(i)
    if all(i in s[j] for j in range(n)):
        t += i * min(s[k].count(i) for k in range(len(s)))
    #print(t)
    
print(''.join(sorted(t)))

Buggy submission (verdict: Runtime Error):
n = int(input())
s = [input() for _ in range(n)]
l = []
for i in s[0]:
    #print(i)
    if all(i in s[j] for j in range(n)):
    #print(l)
    
print("".join(sorted(l)))
Problem p02765 (python)

Fixed submission:
N, R = map(int, input().split())
if N >= 10:
    print(R)
else:
    print(100*(10-N) + R)

Buggy submission (verdict: Runtime Error):
N = int(input())
R = int(input())
if N >= 10:
    print(R)
elif N <= 10:
    print(100*(10-N) + R)

Buggy submission (verdict: Runtime Error):
N = int(input())
R = int(input())
if N >= 10:
    print(R)
else:
    print(100*(10-N) + R)

Buggy submission (verdict: Runtime Error):
if N >= 10:
    print(R)
else:
    print(100*(10-K))
Problem p02885 (python)

Fixed submission:
a, b = map(int, input().split())
if a <= 2*b:
  print(0)
else:
  print(a-2*b)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a <= 2b:
  print("0")
else:
  print(a-2b)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a <= 2b:
  print(0)
else:
  print(a-2b)
Problem p02741 (python)

Fixed submission:
print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51][int(input())-1])

Buggy submission (verdict: Runtime Error):
 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51][int(input())-1])
Problem p02782 (python)

Fixed submission:
r1,c1,r2,c2=map(int,input().split())

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p=10**9+7
N=2*10**6+10
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

print((cmb(r2+1+c2+1,c2+1,p)-cmb(r1+c2+1,c2+1,p)-cmb(r2+1+c1,c1,p)+cmb(r1+c1,c1,p))%p)

Buggy submission (verdict: Runtime Error):
r1,c1,r2,c2=map(int,input().split())

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p=10**9+7
N=2*10**6
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

print((cmb(r2+1+c2+1,c2+1,p)-cmb(r1+c2+1,c2+1,p)-cmb(r2+1+c1,c1,p)+cmb(r1+c1,c1,p))%p)

Buggy submission (verdict: Runtime Error):
r1,c1,r2,c2=map(int,input().split())

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p=10**9+7
N=10**6
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

print((cmb(r2+1+c2+1,c2+1,p)-cmb(r1+c2+1,c2+1,p)-cmb(r2+1+c1,c1,p)+cmb(r1+c1,c1,p))%p)
Problem p02865 (python)

Fixed submission:
print((int(input())-1)//2)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
path=[[0 if i==j or i==max(j-1,0) else float("inf") for i in range(N)] for j in range(N)]
for _ in range(M):
  l,r,c=map(int,input().split())
  path[l-1][r-1]=c
print(path)
seen=[]
dist=[float("inf")]*N
dist[0]=0
v=-1
while v!=N-1:
  v=-1
  for i in range(N):
    if i not in seen and v==-1:
      v=i
    if i not in seen and dist[i]<dist[v]:
      v=i
  seen.append(v)
  for i in range(N):
    dist[i]=min(dist[v]+path[v][i],dist[i])
    
if dist[N-1]==float("inf"):
  print(-1)
else:
  print(dist[N-1])