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

Fixed submission:
import sys; sys.setrecursionlimit(1000000)

n = int(input())
a = list(map(int, input().split()))
t = [0] * (n + 1)
#t[i] = a0 + ... + a(i-1)
for i in range(n):
    t[i + 1] = t[i] + a[i]

'''
前処理O(N + log mod)でN以下の階乗および階乗の逆数を計算
-> O(1)でcomb(n, k)を計算できる
'''

mod = 10 ** 9 + 7
dp_F = [0] * (n * 2) 
dp_Finv = [0] * (n * 2)
dp_inv = [0] * (n * 2)
#dp_F[i] = i!

def factorial(n):
    if dp_F[n] > 0:
        return dp_F[n]
    elif n == 0:
        dp_F[0] = 1
        return 1
    else:
        dp_F[n] = n * factorial(n - 1) % mod
        return dp_F[n]

def inverse(n):
    #modでのnの逆数
    return pow(n, mod - 2, mod)

c = factorial(n)
def f(k):
    return ((c * inverse(k)) % mod)

ans = 0
for i in range(1, n):
    ans += t[i] * (f(n - i + 1) - f(i + 1))
    ans %= mod
ans += t[n] * sum([f(i) for i in range(1, n + 1)])
ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
t = [0] * (n + 1)
#t[i] = a0 + ... + a(i-1)
for i in range(n):
    t[i + 1] = t[i] + a[i]

'''
前処理O(N + log mod)でN以下の階乗および階乗の逆数を計算
-> O(1)でcomb(n, k)を計算できる
'''

mod = 10 ** 9 + 7
dp_F = [0] * (n * 2) 
dp_Finv = [0] * (n * 2)
dp_inv = [0] * (n * 2)
#dp_F[i] = i!

def factorial(n):
    if dp_F[n] > 0:
        return dp_F[n]
    elif n == 0:
        dp_F[0] = 1
        return 1
    else:
        dp_F[n] = n * factorial(n - 1) % mod
        return dp_F[n]

def inverse(n):
    #modでのnの逆数
    return pow(n, mod - 2, mod)

c = factorial(n)
def f(k):
    return ((c * inverse(k)) % mod)

ans = 0
for i in range(1, n):
    ans += t[i] * (f(n - i + 1) - f(i + 1))
    ans %= mod
ans += t[n] * sum([f(i) for i in range(1, n + 1)])
ans %= mod
print(ans)
Problem p03275 (python)

Fixed submission:
'''
☆長さnの数列Aの中央値がxであるとは
１．x以上の要素が (n + 1)// 2 個以上
２．そのようなxの中で最小
ということ。
'''

class BIT:
    def __init__(self, n):
        self.bit = [0] * (n+1)

    def sum(self, i):
        '''
        :param i: 
        :return: bit[i]までの和
        '''
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= i & -i
        return s

    def add(self, i, x):
        '''
        :param i:
        :param x:
        :return: bit[i]にxを加える
        '''

        while i < len(self.bit):
            self.bit[i] += x
            i += i & -i

'''
def median(L):
    n = len(L)
    L.sort()
    return L[n // 2]
'''

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

def ans_bigger(X):
    '''
    答えがX以上かどうかを判定
    つまり、区間[l. r]のうち中央値がX以上であるものが ((N+1) * N /2 + 1 ) //2 個以上かを判定
    [l, r]の中央値がX以上 =
    '''
    a_X = [1 if a[i] >= X else -1 for i in range(N)]#1, -1に変換
    cum = [N]
    for i in range(N):
        cum.append(cum[i] + a_X[i]) #累積和を取るが、BITを使うため全部0以上に（初項N）
    b = BIT(2 * N + 1)
    ans = 0
    for j in range(N + 1):
        ans += b.sum(cum[j])
        b.add(cum[j], 1)
    if ans >= ((N+1) * N /2 + 1 ) //2:
        return True
    else:
        return False

l = min(a)
r = max(a) + 1
#区間[l, r)を2分探索
while r > l + 1:
    if ans_bigger((l + r) // 2):
        l = (l + r) // 2
    else:
        r = (l + r) // 2
print(l)

Buggy submission (verdict: Runtime Error):
def median(L):
    n = len(L)
    L.sort()
    return L[n // 2]

N = int(input())
a = list(map(int, input().split()))
med_list= []
for i in range(N):
    for j in range(i + 1, N + 1):
        med_list.append(median(a[i:j]))

b = []
for i in range(N):
    b += [a[i]] * ((i) * (N - i))
print(median(b))
Problem p03291 (python)

Fixed submission:
T = input()
N = len(T)
mod = 10**9 + 7

def func(X, Y):
    if Y == 0:
        return X
    else:
        return ((3* X + Y) * pow(3, Y - 1, mod)) % mod

A_left = 0
q_left = 0
q_right = T[1:].count('?')
C_right = T[1:].count('C')
ans = 0
for i in range(1, N-1, 1):
    if T[i-1] == 'A':
        A_left += 1
    if T[i-1] =='?':
        q_left += 1
    if T[i] == '?':
        q_right -= 1
    if T[i] == 'C':
        C_right -= 1
    if T[i] == 'B' or T[i] == '?':
        ans += func(A_left, q_left) * func(C_right, q_right)
        ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
T = input()
N = len(T)
mod = 10**9 + 7
A_left = 0
q_left = 0
q_right = T[1:].count('?')
C_right = T[1:].count('C')
ans = 0
for i in range(1, N-1, 1):
    if T[i-1] == 'A':
        A_left += 1
    if T[i-1] =='?':
        q_left += 1
    if T[i] == '?':
        q_right -= 1
    if T[i] == 'C':
        C_right -= 1
    if T[i] == 'B' or T[i] == '?':
        ans += int((A_left * (3 ** q_left) + q_left * (3 ** (q_left - 1))) * (C_right * (3 ** q_right) + q_right * (3 ** (q_right - 1))))
        ans %= mod
print(ans)
Problem p03317 (python)

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
def kiriage(a, b): #切り上げ
    return (a + b - 1) // b

print(kiriage(N - 1, K - 1))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
def kiriage(a, b): #切り上げ
    return (a + b - 1) // b

print(kiriage((N - 1, K - 1)))
Problem p03426 (python)

Fixed submission:
import numpy as np
H, W, D = map(int, input().split())
grid = np.array([[0, 0]] * (H * W))
for i in range(H):
    Ai = list(map(int, input().split()))
    for j in range(W):
        grid[Ai[j] - 1] = [i, j]
Q = int(input())
tasks = [list(map(int, input().split())) for _ in range(Q)]

accum = [0] * (H*W)
for i in range(H * W):
    if i >= D:
        accum[i] = accum[i - D] + abs(grid[i][0] - grid[i - D][0]) + abs(grid[i][1] - grid[i - D][1])

for q in range(Q):
    Li, Ri = tasks[q]
    print(accum[Ri - 1] - accum[Li - 1])

Buggy submission (verdict: Runtime Error):
import numpy as np
H, W, D = map(int, input().split())
grid = np.array([[0, 0]] * (H * W))
for i in range(H):
    Ai = list(map(int, input().split()))
    for j in range(W):
        grid[Ai[j] - 1] = [i, j]
Q = int(input())
tasks = [list(map(int, input().split())) for _ in range(Q)]

accum = [[]] * D
for i in range(D):
    diff = (abs(np.diff(grid[i::D, 0])) + abs(np.diff(grid[i::D, 1])))
    accum[i] = [0] + list(np.cumsum(diff))

for q in range(Q):
    Li, Ri = tasks[q]
    res = (Li - 1) % D
    x = (Li - 1) // D
    y = (Ri - 1)// D
    print(accum[res][y] - accum[res][x])
Problem p03011 (python)

Fixed submission:
from sys import stdin
l = stdin.readline().rstrip().split()
l.sort()
saitan = int(l[0]) + int(l[1])
print(saitan)

Buggy submission (verdict: Runtime Error):
from sys import stdin
l = int(stdin.readline().rstrip().split())
l.sort()
saitan = l[0] + l[1]
print(saitan)
Problem p03208 (python)

Fixed submission:
#coding:utf-8
n,k=map(int, input().split())
h=[int(input()) for i in range(n)]
h.sort()
print(min(h[i+k-1] - h[i] for i in range(n-k+1)))

Buggy submission (verdict: Runtime Error):
#coding:utf-8
n,k=int(input().split())
h=[int(input()) for i in range(n)]
h.sort()
print(min(h[i+k-1]-h[i] for i in range(n-k+1)))
Problem p03209 (python)

Fixed submission:
#coding:utf-8
n,x=map(int, input().split())

a,p=[1],[1]
for i in range(n):
	a.append(a[i]*2+3)
	p.append(p[i]*2+1)

def f(n,x):
	if n==0:
		return 0 if x<=0 else 1
	elif x<=1+a[n-1]:
		return f(n-1,x-1)
	else:
		return p[n-1]+1+f(n-1,x-2-a[n-1])

print(f(n,x))

Buggy submission (verdict: Runtime Error):
#coding:utf-8
n,x=map(int, input().split())

a,p=[1],[1]
for i in range(n):
	a.append(a[i]*2+3)
	p.append(p[i]*2+1)

def f(n,x):
	if n==0:
		return0 if x<=0 else 1
	elif x<=1+a[n-1]:
		return f(n-1,x-1)
	else:
		return p[n-1]+1+f(n-1,x-2-a[n-1])

print(f(n,x))
Problem p03012 (python)

Fixed submission:
import numpy

n = int(input())

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

right=numpy.cumsum(test)
left=numpy.cumsum(test[::-1])[::-1]

diff = []

for i in range(n-1):
    diff.append(abs(right[i]-left[i+1]))
print(min(diff))

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

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

right=numpy.cumsum(test)
left=numpy.cumsum(test[::-1])[::-1]

diff = []

for i in range(n-1):
    diff.append(abs(right[i]-left[i+1]))
    #print(right[i]-left[i+1])
print(min(diff))

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

test = list(map(int, input().split()))
answer = []

for i in range(n-1):
    right = sum(test[:i+1])
    left = sum(test[i+1:])
    answer.append(abs(right-left))
print(min(answer))
Problem p03038 (python)

Fixed submission:
n, m = [int(i) for i in input().split(" ")]
a = [int(i) for i in input().split(" ")]
a = sorted(a)
q = []

for j in range(0, m):
    q.append([int(i) for i in input().split(" ")])

q = sorted(q, key=lambda k: k[1], reverse=True)

p = 0

for t in q:
    b, c = t
    pi = 0
    for i in range(b):
        if p + i < n and a[p + i] < c:
            a[p + i] = c
            pi += 1
        else:
            break
    p += pi

print(sum(a))

Buggy submission (verdict: Runtime Error):
n, m = [int(i) for i in input().split(" ")]
a = [int(i) for i in input().split(" ")]
a = sorted(a)
q = []

for j in range(0, m):
    q.append([int(i) for i in input().split(" ")])

q = sorted(q, key=lambda k: k[1], reverse=True)

p = 0

for t in q:
    b, c = t
    pi = 0
    for i in range(b):
        if a[p + i] < c:
            a[p + i] = c
            pi += 1
        else:
            break
    p += pi

print(sum(a))
Problem p03253 (python)

Fixed submission:
from operator import mul
from functools import reduce

def comb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n, m= [int(i) for i in input().split(" ")]

c = []
i = 2
mt = m

while i * i <= mt:
    ci = 0
    while mt % i == 0:
        mt = mt // i
        ci += 1
    if ci > 0:
        c.append(ci)
    i += 1
if mt > 1:
    c.append(1)
    
p = 1
for j in range(0, len(c)):
    p *= comb(n - 1 + c[j], c[j])

print(p % (10**9 + 7))

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

n, m= [int(i) for i in input().split(" ")]

c = []
i = 2
mt = m

while i * i <= mt:
    ci = 0
    while mt % i == 0:
        mt = mt // i
        ci += 1
    if ci > 0:
        c.append(ci)
    i += 1
if mt > 1:
    c.append(1)
    
p = 1
for j in range(0, len(c)):
    p *= comb(n - 1 + c[j], c[j], exact=True)

print(p % (10**9 + 7))
Problem p03011 (python)

Fixed submission:
import sys

a = []


P, Q, R=map(int, input().split())
a.append(P)
a.append(Q)
a.append(R)
max = 0
for i in a:
    if max < i:
        max = i

print(sum(a)-max)

Buggy submission (verdict: Runtime Error):
import sys

argv = sys.argv
a = []

P = int(argv[0])
Q = int(argv[1])
R = int(argv[2])

a.append(P)
a.append(Q)
a.append(R)
max = 0
for i in a:
    if max < i:
        max = i

print(sum(a)-max)

Buggy submission (verdict: Runtime Error):
import sys

argv = sys.argv
a = []

P = int(argv[1])
Q = int(argv[2])
R = int(argv[3])

a.append(P)
a.append(Q)
a.append(R)
max = 0
for i in a:
    if max < i:
        max = i

print(sum(a)-max)
Problem p03077 (python)

Fixed submission:
import math

n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

min_ = min([a,b,c,d,e])
num = math.ceil(n/min_) + 4
print(num)

Buggy submission (verdict: Runtime Error):
import math

n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

L = [n,0,0,0,0]
num = 0
while True:
  if L[0] > a:
    L[0] -= a
    a_ = a
  else:
    a_ = L[0]
    L[0] = 0
  if L[1] > b:
    L[1] -= b
    b_ = b
  else:
    b_ = L[1]
    L[1] = 0
  if L[2] > c:
    L[2] -= c
    c_ = c
  else:
    c_ = L[2]
    L[2] = 0
  if L[3] > d:
    L[3] -= d
    d_ = d
  else:
    d_ = L[3]
    L[3] = 0
  if L[4] > e:
    L[e] -= e
    e_ = e
  else:
    e_ = L[4]
    L[4] = 0
  L[1] += a_
  L[2] += b_
  L[3] += c_
  L[4] += d_
  num += 1
  if sum(L) == 0:
    break
print(num)
Problem p03011 (python)

Fixed submission:
A,B,C =map(int,input().split())
print(min(A+B,A+C,B+C))

Buggy submission (verdict: Runtime Error):
1. A,B,C =map(int,input().split())
2. print(max(A+B,A+C,B+C))
Problem p03041 (python)

Fixed submission:
a=input().split()
a=list(map(int,a))
pos = a[1]-1
pal=input()
pal=list(pal)
pal[pos]=pal[pos].lower()
i=1
while i<a[0]:
  pal[0]=pal[0]+pal[i]
  i+=1
print (pal[0])

Buggy submission (verdict: Runtime Error):
a=input()
i=0
n=[]
while i<len(a):
  n.append(a[i])
  i+=1
pd=n[0]+n[1]
sd=n[2]+n[3]
pd=int(pd)
sd=int(sd)
if sd==0 and pd==0:
  print('NA')
elif pd>12:
  if sd>=1 and sd<=12:
    print('YYMM')
  elif sd>12:
    print('NA')
  elif sd<1:
    print('NA')
elif pd==0:
  if sd>12:
    print('NA')
  if sd>0 and sd<=12:
    print('YYMM')
elif pd<=12:
  if sd>12:
    print ('MMYY')
  elif sd==0:
    print('MMYY')
  elif sd<=12 and sd!=0:
    print('AMBIGUOUS')
Problem p03013 (python)

Fixed submission:
# -*- coding: utf-8 -*-
MOD = 1000000007
N, M = map(int, input().split())
a = []
for _ in range(M):
    a.append(int(input()))

# 0-num段目までのパターン数を取得する
# numは連続した階段の一番高いところが何段目かを意味する


def getPatternNum(num):
    pattern = [0] * num
    for i in range(num):
        if i == 0 or i == 1:
            pattern[i] = 1
            continue
        pattern[i] = (pattern[i - 2] + pattern[i - 1]) % MOD
    return pattern


def solve():
    # 階段の連続してる数のリスト

    if M > 0:
        stepsList = [0] * (M + 1)
        maxSteps = 0
        stepsList[0] = a[0]
        for j in range(1, M):
            stepsList[j] = a[j] - a[j - 1] - 1
            if stepsList[j] == 0:
                return 0
        stepsList[M] = N - a[M - 1]
    else:
        stepsList = [N + 1]

    # 連続数が一番大きいところの一番上の段を引数でわたす
    pattern = getPatternNum(max(stepsList) + 1)

    # こわれてるところ以外のパターンを掛ける
    for k in range(len(stepsList)):
        if k == 0:
            # 連続段数が３なら一番上の段は０段目から数えて２段目になるため１引く
            total = pattern[stepsList[k] - 1]

        else:
            total = (total * (pattern[stepsList[k] - 1])) % MOD

    return total


print(solve())

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
MOD = 1000000007
N, M = map(int, input().split())
a = []
for _ in range(M):
    a.append(int(input()))


def getPatternNum(num):
    pattern = [0] * num
    for i in range(num):
        if i == 0 or i == 1:
            pattern[i] = 1
            continue
        pattern[i] = pattern[i - 2] + pattern[i - 1]
    return pattern


def solve():
    # 階段の連続してる数のリスト
    stepsList = [0] * (M + 1)
    maxSteps = 0
    stepsList[0] = a[0] - 1
    for j in range(1, M):
        stepsList[j] = a[j] - a[j - 1] - 1
        if stepsList[j] == 0:
            return 0
    stepsList[M] = N - a[M - 1] - 1
    pattern = getPatternNum(max(stepsList) + 1)
    # こわれてるところ以外のパターンを掛ける
    for k in range(len(stepsList)):
        if k == 0:
            total = pattern[stepsList[k]]

        else:
            total = total * (pattern[stepsList[k]]) % MOD

    return total


ans = solve()
print(ans)
Problem p03041 (python)

Fixed submission:
n,k= list(map(int, input().split()))
s = input()
s = s[:n]
k -= 1


print(s[:k] + s[k].lower() + s[k+1:])

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


s = s[:n+1]
print( s[:k] + s[k].lower() + s[k+1:-1])

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

abc = "ABCAB" * 10

abc = abc[:n+1]
print( abc[:k] + abc[k].lower() + abc[k+1:-1])
Problem p03042 (python)

Fixed submission:
import sys

s = input()
s = s[:4]
a = s[:2]
b = s[2:]

	
if 0 <  int(a) <= 12 and 0 <  int(b) <= 12:

	print("AMBIGUOUS")
	sys.exit()


if int(a) >= 0 and 0 < int(b) <= 12:

	print("YYMM")
	sys.exit()
#１~12で0より上なら
if 0 < int(a) <= 12 and int(b) >= 0:

	print("MMYY")
	sys.exit()

print("NA")

Buggy submission (verdict: Runtime Error):
import sys

s = input()
s = s[:4]
a = s[:2]
b = s[2:]

if (int(a) > 12 and int(b) > 12) or  int(b) == 0  or int(a) == 0:
	
	print("NA")
	sys.exit()
	
if 0 <  int(a) <= 12 and 0 <  int(b) <= 12:

	
if int(a) > 12 and 0 < int(b) <= 12:

	print("YYMM")
	sys.exit()

if 0 < int(a) <= 12 and int(b) > 12:

	print("MMYY")
	sys.exit()

print("AMBIGUOUS")
Problem p03072 (python)

Fixed submission:
n = int(input())
h_list = list(map(int, input().split()))
h_list = h_list[:n]
count = 0
last_h = 0
for index,h in enumerate(h_list):
	if last_h <= h:
		count += 1
	
	if last_h <= h:
		last_h = h

print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
h_list = [int(input()) for h in range(n)]

count = 0
last_h = 0
for index,h in enumerate(h_list):
	if last_h <= h:
		count += 1
	
	if last_h < h:
		last_h = h

print(count)
Problem p03013 (python)

Fixed submission:
import sys
sys.setrecursionlimit(100000000)

def dfs(x):
  if x == N:
    return 1
  if x > N:
    return 0
  if memo[x] >= 0:
    return memo[x]
  memo[x] = dfs(x+1) + dfs(x+2)
  return memo[x]

N, M = map(lambda x: int(x), input().split())
a = [int(input()) for i in range(M)]
#print(N)
#print(M)
#print(a)
memo = [-1]*(N+1)
for ai in a:
  memo[ai] = 0
count = dfs(0)
print(count%1000000007)

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10000)

def dfs(x):
  if x == N:
    return 1
  if x > N or x in a:
    return 0
  if memo.get(x):
    return memo[x]
  memo[x] = dfs(x+1) + dfs(x+2)
  return memo[x]

N, M = map(lambda x: int(x), input().split())
a = [int(input()) for i in range(M)]
#print(N)
#print(M)
#print(a)
memo = {}
count = dfs(0)
print(count%1000000007)

Buggy submission (verdict: Runtime Error):
def dfs(x):
  if x == N:
    return 1
  if x > N or x in a:
    return 0
  if memo.get(x):
    return memo[x]
  memo[x] = dfs(x+1) + dfs(x+2)
  return memo[x]

N, M = map(lambda x: int(x), input().split())
a = [int(input()) for i in range(M)]
#print(N)
#print(M)
#print(a)
memo = {}
count = dfs(0)
print(count%1000000007)
Problem p03042 (python)

Fixed submission:
s = str(input())
if s[0] == "0" and s[1] == "0" and int(s[2]+s[3]) > 12:
    print("NA")
elif s[2] == "0" and s[3] == "0" and int(s[0]+s[1]) > 12:
    print("NA")
elif s == "0000":
    print("NA")
elif int(s[0]+s[1]) > 12 and int(s[2]+s[3]) > 12:
    print("NA")
elif s[0] == "0" and s[1] == "0":
    print("YYMM")
elif s[2] == "0" and s[3] == "0":
    print("MMYY")
elif int(s[0]+s[1]) > 12 and int(s[2]+s[3]) <= 12:
    print("YYMM")
elif int(s[2]+s[3]) > 12 and int(s[0]+s[1]) <= 12:
    print("MMYY")
else:
    print("AMBIGUOUS")

Buggy submission (verdict: Runtime Error):
s = str(input())
if s[0] == "0" and s[1] == "0" and int(s[2]+s[3]) > 12:
    print("NA")
elif s[2] == "0" and s[3] == "0" and int(s[0]+s[1]) > 12:
    print("NA")
elif s = "0000":
    print("NA")
elif int(s[0]+s[1]) > 12 and int(s[2]+s[3]) > 12:
    print("NA")
elif s[0] == "0" and s[1] == "0":
    print("YYMM")
elif s[2] == "0" and s[3] == "0":
    print("MMYY")
elif int(s[0]+s[1]) > 12 and int(s[2]+s[3]) <= 12:
    print("YYMM")
elif int(s[2]+s[3]) > 12 and int(s[0]+s[1]) <= 12:
    print("MMYY")
else:
    print("AMBIGUOUS")
Problem p03107 (python)

Fixed submission:
S = list(map(int,input()))
num1 = 0
num0 = 0

for i in range(len(S)):
    if S[i]:
        num1 += 1
    else:
        num0 += 1

print(min(num1,num0)*2)

Buggy submission (verdict: Runtime Error):
import sys

S = list(map(int,input()))
init = int(len(S))
ans = []

def cube(S):
    if not any(S) or all(S):
        print(int((init-len(S))))
        sys.exit()
    for i in range(len(S)-1):
        if S[i] != S[i+1]:
            cube(S[0:i]+S[i+2:])
cube(S)

Buggy submission (verdict: Runtime Error):
S = list(map(int,input()))
init = int(len(S))
ans = []

def cube(S,ans):
    if not any(S) or all(S):
        ans.append(int((init-len(S))))
    for i in range(len(S)-1):
        if S[i] != S[i+1]:
            cube(S[0:i]+S[i+2:],ans)
cube(S,ans)
ans.sort()
print(ans[-1])
Problem p03072 (python)

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

cnt = 0
for i in range(len(H)):
    if (max(H[0:i+1]) == H[i]):
        cnt += 1

print(cnt)

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

cnt = 0
for i in range(len(H)):
    if (max(H[0:i]) == H[i]):
        cnt += 1

print(cnt)

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

H=list(map(int , input().split()))
cnt = 0
for i in range(len(H)):
  if max(H[0:i])==H[i]:
    cnt +=1
    
print(cnt)

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

H=list(map(int , input().split()))
cnt = 0
for i in range(len(H)):
  if max(H[0:i]==H[i]):
    cnt +=1
    
print(cnt)
Problem p03038 (python)

Fixed submission:
import numpy as np

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

As = sorted(list(map(int,input().split())))
BCs = []

for i in range(M):
	inputs = list(map(int,input().split()))
	BCs.append(inputs)
BCs = sorted(BCs, reverse = True, key=lambda x: x[1])

index = 0
for bc in BCs:
	b = bc[0]
	c = bc[1]

	for n in range(b):
		try:
			if As[index] < c:
				As[index] = c
				index += 1
			else:
				break
		except:
			break
print(sum(As))

Buggy submission (verdict: Runtime Error):
import numpy as np

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

As = sorted(list(map(int,input().split())))
BCs = []

for i in range(M):
	inputs = list(map(int,input().split()))
	BCs.append(inputs)
BCs = sorted(BCs, reverse = True, key=lambda x: x[1])

index = 0
for bc in BCs:
	b = bc[0]
	c = bc[1]

	for n in range(b):
		if As[index] < c:
			As[index] = c
			index += 1
print(sum(As))
Problem p03012 (python)

Fixed submission:
N = int(input())
res = []
arr = list(map(int,input().split()))
for i in range(N-1):
    res.append(abs(sum(arr[:i+1])-sum(arr[i+1:])))
print(min(res))

Buggy submission (verdict: Runtime Error):
N = int(input())
arr = list(map(int,input().split()))
res = []
for i in range(N-1):
    res.append(abs(sum(arr[:i+1])-arr(W[i+1:])))
print(min(res))
Problem p03041 (python)

Fixed submission:
N=input("")
N=N.split(" ")
K=int(N[1])
N=N[0]
s=str(input(""))
print(s[0:K-1]+s[K-1].lower()+s[K:])

Buggy submission (verdict: Runtime Error):
N=int(input(""))
K=int(input(""))
s=str(input(""))
print(s[0:K-1]+s[K-1].lower()+s[K:])

Buggy submission (verdict: Runtime Error):
N=int(input(""))
K=int(input(""))
s=str(input(""))
print(s[0:K-1]+s[K-1].lower()+s[K:])