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

Fixed submission:
N = int(input())
if N == 1:
    print('Hello World')
elif N == 2:
    A = int(input())
    B = int(input())
    print(A+B)

Buggy submission (verdict: Runtime Error):
import math

[N, M] = list(map(int, input().split()))
num = math.ceil(M / N)
if N > 1:
    num = min(num, int(math.sqrt(M+1)))
for i in range(num+1)[::-1]:
    if M % i == 0:
        print(i)
        break

Buggy submission (verdict: Runtime Error):
import math

[N, M] = list(map(int, input().split()))
num = math.ceil(M / N)
if N ==1:
    print(M)
for i in range(num+1)[::-1]:
    if M % i == 0:
        print(i)
        break
Problem p03262 (python)

Fixed submission:
import fractions
from functools import reduce
import numpy as np

[n, x] = list(map(int, input().split()))
xn = list(map(int, input().split()))

xn += [x]
xn = np.abs(np.diff(xn))
print(reduce(fractions.gcd, xn))

Buggy submission (verdict: Runtime Error):
import fractions.

[n, x] = list(map(int, input().split()))
xn = list(map(int, input().split()))

xn = sorted(xn + [x])
gcd = xn[1] - xn[0]
b = xn[1]
for a in xn[2:]:
    gcd = fractions..gcd(b - a, gcd)
    b = a
print(gcd)

Buggy submission (verdict: Runtime Error):
import math

[n, x] = list(map(int, input().split()))
xn = list(map(int, input().split()))

xn = sorted(xn + [x])
gcd = xn[1] - xn[0]
b = xn[1]
for a in xn[2:]:
    gcd = math.gcd(b - a, gcd)
    b = a
print(gcd)
Problem p03573 (python)

Fixed submission:
def main(argv):
    for i in range(len(argv)):
        check = sum(argv[i] == argv[j] for j in range(len(argv)))
        if check != len(argv)-1:
            return argv[i]


argv = list(map(int, input().split()))
print(main(argv))

Buggy submission (verdict: Runtime Error):
def check(t):
    return 1 if t is '#' else 0
    
def main(H, W, S):
    for i in range(H):
        for j in range(W):
            if S[i][j] is '.':
                S[i][j] = check(S[i][max(j-1, 0)]) + check(S[i][min(j+1, W-1)]) + check(S[max(i-1, 0)][j]) + check(S[min(i+1, H-1)][j])
    return S


H, W = map(int, input().split())
S = [input().split() for i in H]
print(main(H, W, S))

Buggy submission (verdict: Runtime Error):
def main(argv):
    for v in argv:
        print(v)

main()
Problem p03145 (python)

Fixed submission:
a,b,c = map(int, input().split())
print(int(a*b*0.5))

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

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

Buggy submission (verdict: Runtime Error):
a,b = map(int, input().split())
input()
print(int(a+b/2))
Problem p02767 (python)

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

res=0
for i in Xs:
    res = res + (i-round(sum(Xs)/N))**2

print(res)

Buggy submission (verdict: Runtime Error):
import sys
Row=int(input())
 

X = map(int, input().strip())
 
res = float('inf')
for i in range(1, 101):
  cur_res = 0
  for j in X:
    cur_res = cur_res + (j-i)^2
  if cur_res < res:
    res = cur_res
 
print(res)

Buggy submission (verdict: Runtime Error):
import sys
lines = sys.stdin.readlines()
 
N, X = lines.strip("\n")
X = map(int, X.strip())
 
res = float('inf')
for i in range(1, 101):
  cur_res = 0
  for j in X:
    cur_res = cur_res + (j-i)^2
  if cur_res < res:
    res = cur_res
 
print(res)

Buggy submission (verdict: Runtime Error):
import sys
lines = sys.stdin.readlines()
 
N, X = lines.strip("\n")
X = map(int, X.strip(" "))
 
res = float('inf')
for i in range(1, 101):
  cur_res = 0
  for j in X:
    cur_res = cur_res + (j-i)^2
  if cur_res < res:
    res = cur_res
 
print(res)

Buggy submission (verdict: Runtime Error):
import sys
lines = sys.stdin.readlines()
 
N, X = lines.strip("\n")
X = map(int, X.strip(" "))
 
res = float('inf')
for i in Range(1, 101):
  cur_res = 0
  for j in X:
    cur_res = cur_res + (j-i)^2
  if cur_res < res:
    res = cur_res
 
print(cur_res)

Buggy submission (verdict: Runtime Error):
import sys
lines = sys.stdin.readlines()

N, X = lines.strip("\n")
X = X.strip(" ")

res = float('inf')
for i in Range(1, 101):
  cur_res = 0
  for j in X:
    cur_res = cur_res + (j-i)^2
  if cur_res < res:
    res = cur_res

print(cur_res)
Problem p02765 (python)

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

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
md = []
while N != 0:
  md.append(N%K)
  N /= K
print(len(md)+1)

Buggy submission (verdict: Runtime Error):
N, R = map(int, input().spit())
if N < 10:
  print(R+100*(10-N))
else:
  print(R)

Buggy submission (verdict: Runtime Error):
N, R = map(int, input().spit())
if R < 10:
  print(R+100*(10-N))
else:
  print(R)
Problem p02765 (python)

Fixed submission:
i = input().split()

N = int(i[0])
R = int(i[1])

IR = 0

if N >= 10 :
    IR = R
else :
    IR = R + 100 * (10 - N)

print(IR)

Buggy submission (verdict: Runtime Error):
i = input().split()

N = int(i[0])
K = int(i[1])

result = ''
tmp = N
while tmp >= K:
    idx = str(tmp % K)
    result = idx + result
    tmp = int(tmp / K)
idx = str(tmp % K)
result = idx + result

print(result)
Problem p02772 (python)

Fixed submission:
import sys

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

for x in A:
    if (x % 2 == 0) and (x % 3 != 0) and (x % 5 != 0):
        print('DENIED')
        sys.exit()

print ('APPROVED')

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

isApprove = True

for x in A:
    if x % 2 == 0:
        if (x % 3 != 0) or (x % 5 != 0):
            isApprove = True
            print('DENIED')
            return 

print ('APPROVED')
Problem p02765 (python)

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

Buggy submission (verdict: Runtime Error):
n,r=(int,input().split())
print(r if n>=10 else r+(100*(10-n)))
Problem p02802 (python)

Fixed submission:
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, p: "List[int]", S: "List[str]"):
    A = [False] * (N+1)
    W = [0] * (N+1)
    wans = 0
    for _p, _s in zip(p, S):
        if A[_p]:
            continue
        if _s == 'WA':
            W[_p] += 1
        else:
            A[_p] = True
            wans += W[_p]
    ans = sum(A)
    print(ans, wans)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    p = [int()] * (M)  # type: "List[int]"
    S = [str()] * (M)  # type: "List[str]"
    for i in range(M):
        p[i] = int(next(tokens))
        S[i] = next(tokens)
    solve(N, M, p, S)

if __name__ == '__main__':
    main()

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


def solve(N: int, M: int, p: "List[int]", S: "List[str]"):
    d = dict([(i, []) for i in set(p)])
    for _p, _s in zip(p, S):
        d[_p].append(_s)
    # print(d)
    A = 0
    W = 0
    for v in d.values():
        _a = v.index('AC')
        # print(_a)
        A += 1
        W += _a
    print(A, W)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    p = [int()] * (M)  # type: "List[int]"
    S = [str()] * (M)  # type: "List[str]"
    for i in range(M):
        p[i] = int(next(tokens))
        S[i] = next(tokens)
    solve(N, M, p, S)

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

Fixed submission:
import math
a, b, x = list(map(int, input().split()))
s = 0.5 * a * b
if x/a <= s:
    h = 2 * x / a / b
    ans = math.degrees(math.atan2(b, h))
else:
    h = 2 * (b - x / a / a)
    ans = math.degrees(math.atan2(h, a))

print(ans)

Buggy submission (verdict: Runtime Error):
a, b, x = list(map(int, input().split()))
import math
if x/a <= s:
    h = 2 * x / a / b
    ans = math.degrees(math.atan2(b, h))
else:
    h = 2 * (b - x / a / a)
    ans = math.degrees(math.atan2(h, a))

print(ans)
Problem p02888 (python)

Fixed submission:
import bisect
import sys
input = sys.stdin.readline
N = int(input())
ls = list(map(int, input().split()))
ls.sort()

ans = 0
for i in range(N-2):
  a = ls[i]
  for j in range(i+1, N-1):
    b = ls[j]
    pos = bisect.bisect_left(ls, a+b)
    ans += pos - j - 1
print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
import heapq
import sys
readline = sys.stdin.readline
# readlines = sys.stdin.readlines
N = int(readline())
#ls = list(map(int, readline().split()))
ls = list(map(lambda x: int(x) * (-1), readline().split()))
#ls *= 100
#N *= 100
heapq.heapify(ls)
ans = 0
# n_comb = N * (N-1) * (N-2) / 6
 
import copy
copy_ls = copy.deepcopy(ls)
for i in range(N):
    max1 = -(heapq.heappop(ls))
    copy_ls1 = copy.deepcopy(ls)
    #print(ls)
    for j in range(N-i-1):
      # print(j, ls)
      max2 = -(heapq.heappop(ls))
      for _ in range(N-i-j-2):
        max3 = -(heapq.heappop(ls))
        if (max1 < max2 + max3):
          #print(max1, max2, max3)
          ans += 1
        else:
          # print('break')
          ls = copy.deepcopy(copy_ls1)
          heapq.heappop(ls)
          copy_ls1 = copy.deepcopy(ls)
          break
      ls = copy.deepcopy(copy_ls1)
      heapq.heappop(ls)
      copy_ls1 = copy.deepcopy(ls)
    
    # print('loop end')    
    ls = copy.deepcopy(copy_ls)
Problem p02924 (python)

Fixed submission:
N = int(input())
print(sum(range(1, N)))

Buggy submission (verdict: Runtime Error):
N = int(input())
print(sum(range(1, N))
Problem p03408 (python)

Fixed submission:
# B - Two Colors Card Game
from collections import Counter
n = int(input())
n_dict = {}
for _ in range(n):
    ns = str(input().split())
    if ns not in n_dict.keys():
        n_dict[ns] = 1
    else:
        n_dict[ns] += 1

m = int(input())
m_dict = {}
for _ in range(m):
    ms = str(input().split())
    if ms not in m_dict.keys():
        m_dict[ms] = 1
    else:
        m_dict[ms] += 1

delta = dict(Counter(n_dict) - Counter(m_dict))
if len(delta)>0:
  ans = max(delta.values())
else:
  ans = 0
print(ans)

Buggy submission (verdict: Runtime Error):
# B - Two Colors Card Game
from collections import Counter
n = int(input())
n_dict = {}
for _ in range(n):
    ns = str(input())
    if ns not in n_dict.keys():
        n_dict[ns] = 1
    else:
        n_dict[ns] += 1

m = int(input()
m_dict = {}
for _ in range(n):
    ms = str(input())
    if ms not in m_dict.keys():
        n_dict[ms] = 1
    else:
        n_dict[ms] += 1

delta = dict(Counter(n_dict) - Counter(m_dict))
ans = max(delta.values())
print(ans)
Problem p03698 (python)

Fixed submission:
s = str(input())
if len(s)==len(set(s)):
    ans = "yes"
else:
    ans = "no"
print(ans)

Buggy submission (verdict: Runtime Error):
s = str(input())
if len(s)==(len(set(s)):
    ans = "yes"
else:
    ans = "no"
print(ans)
Problem p02765 (python)

Fixed submission:
n, r = map(int, input().split(' '))
if n < 10:
  ans = r + 100 * (10-n)
else:
  ans = r
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
res = 0
while n >= k:
  res += 1
  n //= k
print(res+1)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
res = 0
while n >= k:
  res += 1
  n //= k
print(res+1)
Problem p02767 (python)

Fixed submission:
N=int(input())
people=[]
cost=[]
 
people=list(map(int,input().split()))

for p in range(101):
    cost.append(0)
    for person in people:
      cost[-1]+=(person-(p+1))**2

print(min(cost))

Buggy submission (verdict: Runtime Error):
N=int(input())
people=[]
cost=[]

for i in range(N):
  people.append(int(input())
                
for p in range(len(people)):
  cost.append(0)
  for person in people:
    cost[-1]+=(person-p)**2
                
print(min(cost))
Problem p02765 (python)

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

Buggy submission (verdict: Runtime Error):
import string
numbers = "0123456789"
alphabets = string.ascii_letters # a-z+A-Zをロード
characters = numbers + alphabets
NK=list(map(int,input().split()))
n=NK[0]
k=NK[1]
result = ''
while n>=k:
    idx=n%k
    result=characters[idx]+result
    n=int(n/k)
    idx=n%k
    result=characters[idx]+result
result=str(result)
print(len(result))
Problem p03719 (python)

Fixed submission:
[a,b,c]=list(map(int,input().split()))
if a<=c<=b:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
[a,b,c]=list(map(int,input().split())
if a<b<c
  print("true")

Buggy submission (verdict: Runtime Error):
[a,b,c]=list(map(int,input().split())
if a<b<c
  print:{"true"}

Buggy submission (verdict: Runtime Error):
[a,b,c]=list(map(int,input().split()))
if a<b<c
  print:{"true"}
Problem p03000 (python)

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

N = INPUT[0]
X = INPUT[1]

L = list(map(int, input().split()))
count = 0

vvv = 0
i = 0
while(vvv <= X):
    count += 1
    if(i >= N):
        break
    vvv += L[i]
    i += 1

print(count)

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

N = INPUT[0]
X = INPUT[1]

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

count = 0

i = 0
value = 0
while(i <= N):
    if(value <= X):
        count += 1
        value += L[i]
    i += 1
print(count)
Problem p02765 (python)

Fixed submission:
n,r = map(int,input().split())
if n < 10:
    print(int(r + 100*(10-n)))
else:
    print(r)

Buggy submission (verdict: Runtime Error):
def nCrModpDP(n, r, p): 
    C = [0] * (n + 1); 
    C[0] = 1;  
    for i in range(1, (n + 1)): 
        j = min(i, r);  
        while(j > 0): 
            C[j] = (C[j] + C[j - 1]) % p; 
            j -= 1; 
    return C[r]; 
def nCrModpLucas(n, r, p): 
    if (r == 0): 
        return 1; 
    ni = int(n % p); 
    ri = int(r % p); 
    return (nCrModpLucas(int(n / p), int(r / p), p) * 
            nCrModpDP(ni, ri, p)) % p; # Remaining digits 
p = int(10**9+7)
n,a,b= map(int,input().split())
if a>n/2:
    a=n-a
if b>n/2:
    b=n-b
nca = nCrModpLucas(n,a,p)
ncb = nCrModpLucas(n,b,p)
print(int(2**n - 1 - nca - ncb)%(10**9+7))
Problem p03557 (python)

Fixed submission:
import bisect

N = int(input(), 10)

heads = list(sorted(map(int,input().split())))
bodies = list(map(int,input().split()))
legs = list(sorted(map(int,input().split())))


cnt = 0
for body in bodies:
    #  頭は、体より小さくなければならない
    head_cnt = bisect.bisect_left(heads, body)
    #  足は、体より大きくなければならない
    leg_cnt = N - bisect.bisect_right(legs, body)

    cnt += head_cnt * leg_cnt # 組み合わせの掛け算

print(cnt)

Buggy submission (verdict: Runtime Error):
import bisect

_ = input()

heads = list(sorted(map(int,input().split())))
bodies = list(map(int,input().split()))
legs = list(sorted(map(int,input().split())))


cnt = 0
for body in bodies:
    #  頭は、体より小さくなければならない
    head_idx = bisect.bisect_left(sorted_heads, body)
    head_cnt = len(sorted_heads[:head_idx])

    #  足は、体より大きくなければならない
    leg_idx = bisect.bisect_right(sorted_legs, body)
    leg_cnt = len(sorted_legs[leg_idx:])

    cnt += head_cnt * leg_cnt # 組み合わせの掛け算

print(cnt)
Problem p02765 (python)

Fixed submission:
a, b = map(int, input().split())
if(a <= 10):
    b = 100 * (10 - a) + b
# 出力
print("{}".format(b))

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if(a <= 10):
    b = 100 * (10 - a) + b
# 出力
print("{}".form

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if(a <= 10):
    b = 100 * (10 - a) + b
# 出力
print("{}
Problem p02765 (python)

Fixed submission:
from sys import stdin

N, R = [int(x) for x in stdin.read().rstrip().split()]

def main(N, R):
  innerRate = 0
  if N >= 10:
    innerRate = R
  else:
    innerRate = R + 100 * (10 - N)
  return innerRate

print(main(N, R))

Buggy submission (verdict: Runtime Error):
from sys import stdin
from math import factorial


def comb(n, x):
    return factorial(n) // (factorial(x) * factorial(n - x))


def main():
    N, A, B = [int(x) for x in stdin.readline().rstrip().split()]
    result = sum([comb(N, i) for i in range(1, N + 1) if i != A and i != B])
    print(int(result % (1e9+7)))


if __name__ == "__main__":
    main()
Problem p02767 (python)

Fixed submission:
from sys import stdin


def calc_cost(p, x):
    return (x - p)**2


def min_cost(n, data):
    cost = 1000000
    for p in range(1, 100 + 1):
        tmp_cost = sum([calc_cost(p, x) for x in data])
        if tmp_cost < cost:
            cost = tmp_cost
    return cost


def main():
    N = [int(x) for x in stdin.readline().rstrip()]
    CORP = [int(x) for x in stdin.readline().rstrip().split()]
    cost = min_cost(N, CORP)
    print(cost)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from sys import stdin


def calc_cost(p, x):
    return (x - p)**2


def min_cost(n, data):
    cost = 1_000_000
    for p in range(1, 100 + 1):
        tmp_cost = sum([calc_cost(p, x) for x in data])
        if tmp_cost < cost:
            cost = tmp_cost
    return cost


def main():
    N = [int(x) for x in stdin.readline().rstrip()]
    CORP = [int(x) for x in stdin.readline().rstrip().split()]
    cost = min_cost(N, CORP)
    print(cost)


main()

Buggy submission (verdict: Runtime Error):
from sys import stdin


def calc_cost(p, x):
    return (x - p)**2


def min_cost(n, data):
    cost = 1_000_000
    for p in range(1, 100 + 1):
        tmp_cost = sum([calc_cost(p, x) for x in data])
        if tmp_cost < cost:
            cost = tmp_cost
    return cost


def main():
    N = [int(x) for x in stdin.readline().rstrip()]
    CORP = [int(x) for x in stdin.readline().rstrip().split()]
    cost = min_cost(N, CORP)
    print(cost)


if __name__ == "__main__":
    main()
Problem p02768 (python)

Fixed submission:
from functools import reduce

def cmb(n, r, mod):
    r = min(r, n-r)
    if r == 0: return 1
    num = reduce(lambda x, y: x * y % mod, range(n, n-r, -1))
    den = reduce(lambda x, y: x * y % mod, range(1, r+1))
    return num * pow(den, mod-2, mod) % mod

n, a, b = map(int, input().split())
mod = 10**9 + 7

temp = pow(2, n, mod) - 1 - cmb(n, a, mod) - cmb(n, b, mod)
ans = temp % mod

print(ans)

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

def cmb(n, r, mod):
    r = min(r, n-r)
    num = reduce(lambda x, y: x * y % mod, range(n, n-r, -1))
    den = reduce(lambda x, y: x * y % mod, range(1, r+1))
    return num * pow(den, mod-2, mod) % mod

n, a, b = map(int, input().split())
mod = 10**9 + 7

temp = pow(2, n, mod) - 1 - cmb(n, a, mod) - cmb(n, b, mod)
ans = temp % mod

print(ans)
Problem p02765 (python)

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

Buggy submission (verdict: Runtime Error):
N, p = map(int,input().split())
if N < 10:
    K = 100 * (10 - N)
    print(p + K)
else:
    print(P)
Problem p02866 (python)

Fixed submission:
from sys import stdin
import collections
def main():
    n = int(stdin.readline().rstrip())
    D = [int(i) for i in input().split()]
    hash = collections.Counter(D)
    count = hash[0]
    if(count != 1 or D[0] != 0):
        print(0)
        return
    for i in range(1, max(D)+1):
        count *= hash[i-1] ** hash[i]
    print(count%998244353)
    
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from sys import stdin
from collections import defaultdict

def main():
    n = int(stdin.readline().rstrip())
    D = [int(i) for i in input().split()]
    hash = defaultdict(int)
    for i in D:
        hash[i] += 1
    count = hash[0]
    for i in range(1, n):
        count *= hash[i-1] ** hash[i]
    print(count/998244353)
    
if __name__ == '__main__':
    main()
Problem p02957 (python)

Fixed submission:
from sys import stdin

A, B = [int(x) for x in stdin.readline().rstrip().split()]

if (A + B) % 2 == 0:
    print((A + B) // 2)
else:
    print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
from sys import stdin

n = int(stdin.readline().rstrip())
xs = [int(x) for x in stdin.readline().rstrip().split()]
ys = [int(x) for x in stdin.readline().rstrip().split()]

count = 0

for i in range(n):
   r = min(xs[i], ys[i])
   xs[i] -= r
   ys[i] -= r
   count += r
   r = min(xs[i+1], ys[i])
   xs[i+1] -= r
   count += r
   
print(count)
Problem p02960 (python)

Fixed submission:
from sys import stdin

def main():
    s = [int(x) if x != "?" else "?" for x in stdin.readline().rstrip()]

    dp = [1] + [0]*12
    mod = 10 ** 9 + 7

    for i in (range(0,len(s))):
        next_dp = [0]*13
        if s[i] == "?":
            for k in range(0, 10):
                for j in range(0, 13):
                    next_dp[(j*10+k)%13] += dp[j]
                    next_dp[(j*10+k)%13] %= mod

        else:
            k = s[i]
            for j in range(0, 13):
                    next_dp[(j*10+k)%13] += dp[j]
                    next_dp[(j*10+k)%13] %= mod

    #    mul = mul * 10 % 13
        dp = next_dp

    print(dp[5])

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from sys import stdin

def main():
    s = [int(x) if x != "?" else "?" for x in stdin.readline().rstrip()]

    dp = [1] + [0]*12
    mul = 1
    mod = 10 ** 9 + 7
    s.reverse()

    for i in (range(0,len(s))):
        next_dp = [0]*13
        if s[i] == "?":
            for k in range(0, 10):
                for j in range(0, 13):
                    next_dp[(k*mul+j)%13] += dp[j]
                    next_dp[(k*mul+j)%13] %= mod

        else:
            k = s[i]
            for j in range(0, 13):
                    next_dp[k*mul+j)%13] += dp[j]
                    next_dp[k*mul+j)%13] %= mod

        mul = mul * 10 % 13
        dp = next_dp

    print(dp[5])

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

Fixed submission:
from sys import stdin

def main():
    n = int(stdin.readline().rstrip())
    xs = [int(stdin.readline().rstrip()) for _ in range(n)]

    max_1, max_2 = sorted(xs)[-1], sorted(xs)[-2]

    for i in range(n):
        if xs[i] == max_1:
            print(max_2)
        else:
            print(max_1)
            
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from sys import stdin

def main():
    n = int(stdin.readline().rstrip())
    xs = [int(stdin.readline().rstrip()) for _ in range(n)]

    for i in range(n):
        print(max(xs[0:i]+xs[i+1:])

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

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

Buggy submission (verdict: Runtime Error):
n = int(input())
lines = [i for i in range(24, n+1) if i % 2 != 0]

ans = 0
for i in lines:
    cnt = 0
    for j in range(1, i+1):
        if i % j == 0:
            cnt += 1
        if cnt == 8:
            ans += 1
print(ans)

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

ans = 0
for i in range(1, n+1):
    cnt = 0
    for j in range(1, i+1):
        if i % 2 != 0 and i % j == 0:
            cnt += 1
            if cnt == 8:
                ans += 1
print(ans)
Problem p03386 (python)

Fixed submission:
a, b, k = map(int, input().split())
L = range(a, b+1)
for l in sorted(set(L[:k])|set(L[-k:])):
    print(l)

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
l = list(range(a, b+1))
x = sorted(set(l[:k] + l[-k:]), key=l.index)
print('\n'.join(map(str, x)))