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

Fixed submission:
N, M= (int(i) for i in input().split())
if (N<M):
    X = list(int(i) for i in input().split())
    X.sort()
    Y = [X[i] - X[i-1] for i in range(1, len(X))]
    Y.sort()
    print(sum(Y[0:M-N]))
else:
    print(0)


"""
N個のコマ：N-1個の閉経路が存在する
各座標の距離を求める(M-1個)
M：座標の数　N:駒の数
移動しなくても通っている座標の数: N
M - N
"""

Buggy submission (verdict: Runtime Error):
N, M= (int(i) for i in input().split())
if (N<M):
    X = list(int(i) for i in input().split())
    X.sort()
    Y = [X[i] - X[i-1] for i in range(1, len(X))].sort()
    print(sum(Y[0:M-N]))
else:
    print(0)


# -100 | -10 -3 0 2 9 | 17
# 0 | 90 97 100 102 109 | 117
#   90  7  3   2   7    6
# 90 7 7 6 3 2


"""
N個のコマ：N-1個の閉経路が存在する
各座標の距離を求める(M-1個)
M：座標の数　N:駒の数
移動しなくても通っている座標の数: N
M - N
"""

Buggy submission (verdict: Runtime Error):
N, M= (int(i) for i in input().split())
if (N<M)
    X = list(int(i) for i in input().split())
    X.sort()
    Y = [X[i] - X[i-1] for i in range(1, len(X))].sort()
    print(sum(Y[0:M-N]))
else:
    print(0)


# -100 | -10 -3 0 2 9 | 17
# 0 | 90 97 100 102 109 | 117
#   90  7  3   2   7    6
# 90 7 7 6 3 2


"""
N個のコマ：N-1個の閉経路が存在する
各座標の距離を求める(M-1個)
M：座標の数　N:駒の数
移動しなくても通っている座標の数: N
M - N
"""
Problem p02781 (python)

Fixed submission:
import math

def combinations_count(n, r):
  if n>=r:
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
  else:
    return 0

str_n=input()
k=int(input())
cnt=0
dig = len(str_n)

#最上位桁が最大以外の場合　かつ　0でない場合
cnt += (int(str_n[0])-1)*combinations_count(dig-1,k-1)*9**(k-1)
#最上位桁が0の場合
if dig-1>=k:
  cnt += combinations_count(dig-1,k)*9**k

#最上位桁が最大の場合
if k==1:
  cnt+=1
else:
  ##第２非ゼロ桁の探索
  for i in range(dig-1):
    if str_n[i+1] != '0':
      dig2 = i+1
      break
  else:
    print(cnt)
    exit()
  ##第２非ゼロ桁が最大以外の場合　かつ　0でない場合
  cnt += (int(str_n[dig2])-1)*combinations_count(dig-1-dig2,k-2)*9**(k-2)
  ##第２非ゼロ桁が0の場合
  if dig-1-dig2>=k-1:
    cnt += combinations_count(dig-1-dig2,k-1)*9**(k-1)
  ##第２非ゼロ桁が最大の場合
  if k==2:
    cnt+=1
  else:
    ##第３非ゼロ桁の探索
    for i in range(dig-1-dig2):
      if str_n[i+1+dig2] != '0':
        dig3 = i+1+dig2
        break
    else:
      print(cnt)
      exit()
    ##第３非ゼロ桁が0でない場合
    cnt += int(str_n[dig3])
    ##第３非ゼロ桁が0の場合
    cnt += combinations_count(dig-1-dig3,k-2)*9**(k-2)
print(cnt)

Buggy submission (verdict: Runtime Error):
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

str_n=input()
k=int(input())
cnt=0
dig = len(str_n)

#最上位桁が最大以外の場合　かつ　0でない場合
cnt += (int(str_n[0])-1)*combinations_count(dig-1,k-1)*9**(k-1)
#最上位桁が0の場合
if dig-1>=k:
  cnt += combinations_count(dig-1,k)*9**k

#最上位桁が最大の場合
if k==1:
  cnt+=1
else:
  ##第２非ゼロ桁の探索
  for i in range(dig-1):
    if str_n[i+1] != '0':
      dig2 = i+1
      break
  else:
    print(cnt)
    exit()
  ##第２非ゼロ桁が最大以外の場合　かつ　0でない場合
  cnt += (int(str_n[dig2])-1)*combinations_count(dig-1-dig2,k-2)*9**(k-2)
  ##第２非ゼロ桁が0の場合
  if dig-1-dig2>=k-1:
    cnt += combinations_count(dig-1-dig2,k-1)*9**(k-1)
  ##第２非ゼロ桁が最大の場合
  if k==2:
    cnt+=1
  else:
    ##第３非ゼロ桁の探索
    for i in range(dig-1-dig2):
      if str_n[i+1+dig2] != '0':
        dig3 = i+1+dig2
        break
    else:
      print(cnt)
      exit()
    ##第３非ゼロ桁が0でない場合
    cnt += int(str_n[dig3])
    ##第３非ゼロ桁が0の場合
    cnt += combinations_count(dig-1-dig3,k-2)*9**(k-2)
print(cnt)
Problem p02915 (python)

Fixed submission:
print(int(input())**3)

Buggy submission (verdict: Runtime Error):
print(int(input)**3)
Problem p03295 (python)

Fixed submission:
import numpy as np
n,m = map(int,input().split())
a = np.zeros(m)
b = np.zeros(m)
for i in range(m):
    a[i] , b[i] = map(int ,input().split())

a -= 1
b -= 1 
cnt = 0

while(a.shape[0]):
    min_b = np.min(b)
    in_task = (a < min_b).astype(np.bool)
    cnt += 1
    tmp = np.logical_not(in_task)
    a = a[tmp]
    b = b[tmp]
    
print(cnt)

Buggy submission (verdict: Runtime Error):
import numpy as np
n,m = map(int,input().split())
a = np.zeros(m)
b = np.zeros(m)
for i in range(m):
    a[i] , b[i] = map(int ,input().split())

a -= 1
b -= 1 
cnt = 0

while(a.shape):
    min_b = np.min(b)
    in_task = (a < min_b).astype(np.bool)
    cnt += 1
    tmp = np.logical_not(in_task)
    a = a[tmp]
    b = b[tmp]
    
print(cnt)
Problem p03073 (python)

Fixed submission:
li = list(input())
sums = 0
leng = int(len(li))

for i in range(leng):
    now = i
    if (now + 1) >= leng:
        break
    if(li[now] == li[now + 1]):
        if(li[now + 1] == '0'):
            li[now + 1] = '1'
        else:
            li[now + 1] = '0'
        sums += 1
print(sums)

Buggy submission (verdict: Runtime Error):
li = list(map(input().split()))
sum = 0;
for i in li:
  if(li[i] != li[i + 1]):
    sum += 1
  if((i+1) >= len(li)):
    break;
print(sum)
Problem p02819 (python)

Fixed submission:
import sys
input = sys.stdin.readline
X=int(input().rstrip())
maxX=10**6

def resolve():
    check,table=sieve(maxX)

    for a in table:
        if a>=X:
            print(a)
            return

def sieve(n):#n以下の素数を返す, is_prime[i]:iが素数ならtrue、table[i]:小さい順に素数入る
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    table = [ i for i in range(1, n+1) if is_prime[i-1]]
    is_prime=[False]+is_prime ##[False]は勝手につけた、累積和をするときはこの影響で[0]+いらない
    return is_prime, table


import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """20"""
        output = """23"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """2"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """99992"""
        output = """100003"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

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


   
def resolve():
    
    input = sys.stdin.readline
    N,K=map(int,input().rstrip().split())
    R,S,P=map(int,input().rstrip().split())
    T=list(input().rstrip())

    ans=0
    flag=[0 for _ in range(N)]
    for i in range(N):
        if T[i]==T[i-K] and i>=K and flag[i-K]==True: #足さない条件、K個前が既に制約で足せなくなっていた時は、今回は足せるようになるのでflag管理
            continue
        if T[i]=="r":
            ans+=P
        if T[i]=="s":
            ans+=R
        if T[i]=="p":
            ans+=S
        flag[i]=True
    print(ans)

import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """5 2
8 7 6
rsrpr"""
        output = """27"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """7 1
100 10 1
ssssppr"""
        output = """211"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """30 5
325 234 123
rspsspspsrpspsppprpsprpssprpsr"""
        output = """4996"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()
Problem p02836 (python)

Fixed submission:

import sys
import math
def resolve():
    S=list(input().rstrip())
    c=0
    for i in range(math.floor(len(S)/2)):
        if(S[i]!=S[len(S)-i-1]):
            c+=1
    print(c)

from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """redcoder"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """vvvvvv"""
        output = """0"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """abcdabc"""
        output = """2"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

Buggy submission (verdict: Runtime Error):

import sys
import math
def resolve():
    S=input().rstrip()
    c=0
    for i in range((len(S)/2)):
        if(S[i]!=S[-i-1]):
            c+=1
    print(c)

from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """redcoder"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """vvvvvv"""
        output = """0"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """abcdabc"""
        output = """2"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()
Problem p03013 (python)

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

if M == 0:
    alist = set()
else:
    alist = set(int(input()) for _ in range(M))

dp = [0] * (N + 1)
dp[0] = 1
dp[1] = 1 if 1 not in alist else 0

MOD = 10**9 + 7
for i in range(2, N + 1):
    if i in alist:
        continue
    dp[i] = (dp[i - 1] + dp[i - 2]) % MOD

print(dp[N])

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

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

all_patterns = 1
start, end = None, None
for m_i in range(M + 1):
    if m_i < M:
        a_i = int(input())
    if m_i == 0:
        start = 0
        end = a_i - 1
        next_start = a_i + 1
    elif m_i == M:
        start = copy(next_start)
        end = N
    else:
        start = copy(next_start)
        end = a_i - 1
        next_start = a_i + 1
    passdiff = end - start
    num_2 = passdiff // 2
    residue = passdiff % 2

    tmp_patterns_for_range = 0
    for num2to1 in range(num_2 + 1):
        add_n_1 = num2to1 * 2
        tmp_num2 = num_2 - num2to1
        tmp_n_pattern = \
            factorial(tmp_num2 + add_n_1 + residue) \
            // factorial(tmp_num2) \
            // factorial(add_n_1 + residue)
        tmp_patterns_for_range += tmp_n_pattern
    all_patterns *= tmp_patterns_for_range

print(all_patterns % 1000000007)
Problem p03127 (python)

Fixed submission:
from fractions import gcd 

n = int(input())
a_set = set(map(int, input().split()))
max_a = max(a_set)
min_sub = max_a

for val in a_set:
    min_sub = min(gcd(max_a, val), min_sub)
    if min_sub == 1:
        print(1)
        exit()
print(min_sub)

Buggy submission (verdict: Runtime Error):
from fractions import gcd 

n = int(input())
a_set = set(map(int, input().split()))
max_a = max(a_set)
min_sub = max_a


if len(a_set) == 1:
    print(a_list[0])
    exit()
elif 1 in a_set:
    print(1)
    exit()
else:
    for val in a_set:
        min_sub = min(gcd(max_a, val), min_sub)
        if min_sub == 1:
            print(1)
            exit()
print(min_sub)
Problem p02771 (python)

Fixed submission:
import sys

A, B, C = map(int, input().split())

ans = 'Yes'

a = [A, B, C]

if len(set(a)) == 2:
  print('Yes')
else:
  print('No')

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

count = 1
li = []

for index, a in enumerate(A):
  for b in range(count, len(A)):
    li.append(a * A[b])

  count += 1

li.sort()

print(li[K-1])
Problem p03329 (python)

Fixed submission:
N = int(input())

dp = [10000] * (N+1)

dp[0] = 0

for n in range(N+1):
  count = 1
  while(True):
    if count > N:
      break

    if n - count < 0:
      break

    dp[n] = min(dp[n], dp[n-count]+1)
    count *= 6

  count = 1
  while(True):
    if count > N:
      break

    if n - count < 0:
      break

    dp[n] = min(dp[n], dp[n-count]+1)
    count *= 9

print(dp[N])

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

dp = [100000] * (10**5)
dp[0] = 0

for n in range(N):
  count = 1
  while(True):
    if count > N:
      break

    dp[n+count] = min(dp[n+count], dp[n]+1)
    count *= 6

  count = 1
  while(True):
    if count > N:
      break

    dp[n+count] = min(dp[n+count], dp[n]+1)
    count *= 9

print(dp[N])
Problem p03785 (python)

Fixed submission:
N,C,K = map(int,input().split())
li = []
for t in range(N):
  li.append(int(input()))

count = 0
ans = 0

newLi = sorted(li)

while(len(newLi)):
  for c in range(C - 1):
    if len(newLi) < 2:
      break
    
    if newLi[1] <= newLi[0] + K:
      newLi.pop(1)
    else:
      break

  newLi.pop(0)
  ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
N,C,K = map(int,input().split())
li = []
for t in range(N):
  li.append(int(input()))

count = 0
ans = 0

newLi = sorted(li)

while(len(newLi)):
  for c in range(C - 1):
    if len(newLi) < 2:
	  break
    
    if newLi[1] <= newLi[0] + K:
      newLi.pop(1)
    else:
      break

  newLi.pop(0)
  ans += 1

print(ans)
Problem p03745 (python)

Fixed submission:
_ = input()
A = map(int, input().split())
prev = next(A)
up = None
count = 1
for i in A:
    if prev < i:
        if up is None:
            up = True
        elif not up:
            count += 1
            up = None
    elif prev > i:
        if up is None:
            up = False
        elif up:
            count += 1
            up = None
    prev = i
print(count)

Buggy submission (verdict: Runtime Error):
from otsutil.funcs import parg
_ = input()
A = map(int, input().split())
prev = next(A)
up = None
count = 1
for i in A:
    if prev < i:
        if up is None:
            up = True
        elif not up:
            count += 1
            up = None
    else:
        if up is None:
            up = False
        elif up:
            count += 1
            up = None
    prev = i
print(count)
Problem p02831 (python)

Fixed submission:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B = MAP()

print(int(A * B / gcd(A, B)))

Buggy submission (verdict: Runtime Error):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B = MAP()

print(int(A * B / gcd(A, B)))

Buggy submission (verdict: Runtime Error):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B = MAP()

print(int(A * B / gcd(A, B)))
Problem p02836 (python)

Fixed submission:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()

count = 0
if len(S)%2==0:
	a = int(len(S)/2-1)
	for i in range(a+1):
		if S[a+1+i] != S[a-i]:
			count += 1
else:
	a = int(len(S)//2)
	for i in range(a):
		if S[a+1+i] != S[a-1-i]:
			count += 1

print(count)

Buggy submission (verdict: Runtime Error):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()


if len(S)%2 != 0:
	s = S[0:int(len(S)/2-1)]+S[int(len(S)/2-1)+1:]

a = len(s)//2
count = 0
for i in range(a):
	if s[a-i-1]!=s[a+i]:
		count += 1

print(count)

Buggy submission (verdict: Runtime Error):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()

count = 0
if len(S)%2==0:
	a = int(len(S)/2-1)
	for i in range(a+1):
		if S[a+1+i] != S[a-i]:
			count += 1
else:
	a = int(len(S)//2)
	for i in range(a+1):
		if S[a+1+i] != S[a-1-i]:
			count += 1

print(count)
Problem p03041 (python)

Fixed submission:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N, K = MAP()
S = input()
 
if S[K - 1] == "A":
  S = S[0:K - 1] + "a" + S[K:]
if S[K - 1] == "B":
  S = S[0:K - 1] + "b" + S[K:]
if S[K - 1] == "C":
  S = S[0:K - 1] + "c" + S[K:]

print(S)

Buggy submission (verdict: Runtime Error):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
S = input()

if S[K - 1] == "A":
  S[K - 1] = "a"
if S[K - 1] == "B":
  S[K - 1] = "b"
if S[K - 1] == "C":
  S[K - 1] = "c"

print(S)
Problem p02847 (python)

Fixed submission:
week = ['MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN']
S = input()

print(6 - week.index(S)) if week.index(S) != 6 else print(7)

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

A, B, X = [int(s) for s in input().split()]
right = 10 ** 9
left = 1

if A + B > X:
    print(0)
    exit()

if A * right + B * 10 <= X:
    print(right)
    exit()

while (left < right):
    middle = (left + right) // 2 + 1
    if A * middle + B * int((math.log(middle * 10, 10))) < X:
        left = middle 
    else:
        right = middle - 1

print(right)
Problem p02912 (python)

Fixed submission:
import heapq
 
N, M = [int(s) for s in input().split()]
A = [int(s) for s in input().split()]
 
hpq = list(map(lambda x: -1 * x, A))
heapq.heapify(hpq)
for i in range(M):
    x = heapq.heappop(hpq)
    heapq.heappush(hpq, x / 2)

print(sum(map(lambda x: int(-1 * x), hpq)))

Buggy submission (verdict: Runtime Error):
import heapq

N, M = [int(s) for s in input().split()]
A = [int(s) for s in input().split()]

hpq = list(map(lambda x: -1 * x, A))
for i in range(M):
    heapq.heapify(hpq)
    x = heapq.heappop(hpq)
    heapq.heappush(hpq, x / 2)

sum(map(lambda x: int(-1 * x), hpq)
Problem p02990 (python)

Fixed submission:
MOD = 10**9 + 7
 
N,K = [int(s) for s in input().split()]
 
comb = [[1]]
for i in range(N + 1):
    comb.append([1])
    for j in range(i):
        comb[-1].append((comb[-2][j] + comb[-2][j + 1]) % MOD)
    comb[-1].append(1)
    
def combi(n,k):
  return comb[n][k] if n >= k else 1

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

Buggy submission (verdict: Runtime Error):
MOD = 10**9 + 7
 
N,K = [int(s) for s in input().split()]
 
comb = [[1]]
for i in range(N + 1):
    comb.append([1])
    for j in range(i):
        comb[-1].append((comb[-2][j] + comb[-2][j + 1]))
    comb[-1].append(1)
 
 
for i in range(1,K+1):
  print(comb[N-i+1][i] * comb[K-1][i]) if i != K else print(comb[N-i+1][i])

Buggy submission (verdict: Runtime Error):
MOD = 10**9 + 7

N,K = [int(s) for s in input().split()]

comb = [[1]]
for i in range(N + 1):
    comb.append([1])
    for j in range(i):
        comb[-1].append((comb[-2][j] + comb[-2][j + 1]))
    comb[-1].append(1)


for i in range(1,K+1):
	print(comb[N-i+1][k] * comb[K-1][i])