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

Fixed submission:
def how_many(n):
  ans = 0
  while n % 2 == 0:
    n /= 2
    ans += 1
  return ans

n = int(input())
line = map(int , input().split())
answer = min(map(how_many , line))
             
print(answer)

Buggy submission (verdict: Runtime Error):
n = int(input())
line = list(map(int,input().split()))
box = []
for j in line:
  for i in range(30):
    if j % 2**i != 0:
      box.append(i-1)
      break
print(min(box))

Buggy submission (verdict: Runtime Error):
n = int(input())
line = list(map(int,input().split()))
box = []
for j in line:
  for i in range(30):
    if j % 2**i != 0:
      box.append(i-1)
      break
print(max(box))

Buggy submission (verdict: Runtime Error):
n = int(input())
line = map(int,input().split())
box = []
for i in line:
  for j in range(1,10):
    if i % 2**j != 0:
      box.append(j - 1)
answer = min(box)
print(answer)

Buggy submission (verdict: Runtime Error):
n = int(input())
line = map(int,input().split())
box = []
for i in line:
  for j in range(1,9):
    if i % 2**j != 0:
      box.append(j - 1)
answer = min(box)
print(answer)
Problem p03495 (python)

Fixed submission:
import collections
n,k = map(int,input().split())
line = list(input().split())
c = collections.Counter(line)
answer = 0
if k > len(c):
  answer = 0
else:
  gap = len(c) - k
  sorted_c = list(sorted(c.items(),key = lambda x:x[1]))
  for i in range(gap):
    answer += int(sorted_c[i][1])
print(answer)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
setted_line = list(set(list(map(int,input().split()))))
origin_num = len(setted_line) 
pairs = {}
for i in range(len(setted_line)):
  count = line.count(setted_line[i])
  pairs[setted_line[i]] = count
sorted_pairs = sorted(pairs.items(), key = lambda x:x[1])
answer = 0
if origin_num <= k:
  answer = 0
else:
  gap = origin_num - k 
  for j in range(gap):
    answer += sorted_pairs[j][1]
print(answer)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
setted_line = list(set(map(int,input().split())))
origin_num = len(setted_line) 
pairs = {}
for i in range(len(setted_line)):
  count = line.count(setted_line[i])
  pairs[setted_line[i]] = count
sorted_pairs = sorted(pairs.items(), key = lambda x:x[1])
answer = 0
if origin_num <= k:
  answer = 0
else:
  gap = origin_num - k 
  for j in range(gap):
    answer += sorted_pairs[j][1]
print(answer)
Problem p03565 (python)

Fixed submission:
sn = list(input())
t = list(input())
ls = len(sn)
lt = len(t)
Flag = False  
reali = 0 #tの文が始まるときのi
if lt > ls:
  print("UNRESTORABLE")
  exit()
for i in range(ls-lt+1): #スライスを繰り返して当てはまるところを探す
  ss = sn[i:i+lt]
  count = 0
  for j in range(lt):
    if ss[j] == "?" or ss[j] == t[j]:
      count += 1
  if count == lt:
    reali = i
    Flag = True
for i in range(ls): #見つけたとこをtの文にしてそれ以外をaにする
  if i == reali:
    for j in range(lt):
      sn[i+j] = t[j]
  if sn[i] == "?":
    sn[i] = "a"
if Flag:
  for i in sn:
    print(i,end="")
else:
  print("UNRESTORABLE")

Buggy submission (verdict: Runtime Error):
sn = list(input())
t = list(input())
ls = len(sn)
lt = len(t)
Flag = False
reali = 0 #tの文が始まるときのi
for i in range(ls-lt+1): #スライスを繰り返して当てはまるところを探す
  ss = sn[i:i+lt]
  count = 0
  for j in range(lt):
    if ss[j] == "?" or ss[j] == t[j]:
      count += 1
  if count == lt:
    reali = i
    Flag = True
    break
for i in range(ls): #見つけたとこをtの文にしてそれ以外をaにする
  if i == reali:
    for j in range(lt):
      sn[i+j] = t[j]
  if sn[i] == "?":
    sn[i] = "a"
if Flag:
  for i in sn:
    print(i,end="")
else:
  print("UNRESTORABLE")

Buggy submission (verdict: Runtime Error):
sn = list(input())
t = list(input())
ls = len(sn)
lt = len(t)
Flag = False
reali = 0
for i in range(ls-lt+1):
  ss = sn[i:i+lt]
  count = 0
  for j in range(lt):
    if ss[j] == "?" or ss[j] == t[j]:
      count += 1
  if count == lt:
    reali = i
    Flag = True
    break
for i in range(ls):
  if i == reali:
    for j in range(lt):
      sn[i+j] = t[j]
  if sn[i] == "?":
    sn[i] = "a"
if Flag:
  for i in sn:
    print(i,end="")
else:
  print("UNRESTORABLE")
Problem p03599 (python)

Fixed submission:
import math
a,b,c,d,e,f = map(int,input().split())
max_nodo = e/(e+100)
answer = {}
for i in range(31):
  for j in range(31):
    water = 100*a*i + 100*b*j
    max_sugar = water*e/100
    sugar_range = int(math.ceil(max_sugar/c))
    if water >= f:
      break
    for k in range(sugar_range):
      for l in range(sugar_range):
        sugar = c*k + d*l
        total = water + sugar
        nodo = sugar / total
        if total > f:
          break
        if sugar > max_sugar:
          break
        answer[nodo] = [total,sugar]
ans = max(answer.items(),key = lambda x:x[0])[1]

#print(answer)
print(str(ans[0]) + " " + str(ans[1]))

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d,e,f = map(int,input().split())
max_sugar = f*e*100/(100+e)
box = {}
for i in range(31):
  for j in range(31):
    water = 100*a*i + 100*b*j
    if water > f:
      break
    sugar_range = int(math.ceil(max_sugar/c))
    for k in range(sugar_range):
      for l in range(sugar_range):
        sugar = c*k + d*l
        if sugar > max_sugar:
          break
        amount = water + sugar
        if amount > f or amount == 0
          break
        conc = 100*sugar / amount
        if conc <= e*100/(100+e):
          box[conc] = [amount,sugar]
answer = max(box.items(),key = lambda x:x[0])[1]
print(str(answer[0]) + " " +str(answer[1]))

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d,e,f = map(int,input().split())
water_nodo = 100 /(100 + e)
water_max = f*water_nodo
a_max = math.ceil(water_max / (100*a))
b_max = math.ceil(water_max / (100*b))
water_gaps = []
for i in range(a_max):
  for j in range(b_max):
    water_gap = water_max - 100*a*i - 100*b*j
    if water_gap >= 0:
      water_gaps.append(water_gap)
sorted_water = sorted(water_gaps)
max_water = water_max - sorted_water[0]
sugar_max = max_water*e/100
c_max = math.ceil(sugar_max / c)
d_max = math.ceil(sugar_max / d)
sugar_gaps = []
for k in range(c_max):
  for l in range(d_max):
    sugar_gap = sugar_max - c*k - d*l
    if sugar_gap >= 0:
      sugar_gaps.append(sugar_gap)
sorted_sugar = sorted(sugar_gaps)
max_sugar = sugar_max - sorted_sugar[0]
print(str(int(max_water + max_sugar)) + " " + str(int(max_sugar)))

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d,e,f = map(int,input().split())
water_nodo = 100 /(100 + e)
water_max = f*water_nodo
a_max = math.ceil(water_max / (100*a))
b_max = math.ceil(water_max / (100*b))
water_gaps = []
for i in range(a_max):
  for j in range(b_max):
    water_gap = water_max - 100*a*i - 100*b*j
    if water_gap >= 0:
      water_gaps.append(water_gap)
sorted_water = sorted(water_gaps)
max_water = water_max - sorted_water[0]
sugar_max = max_water*e/100
c_max = math.ceil(sugar_max / c)
d_max = math.ceil(sugar_max / d)
sugar_gaps = []
for k in range(c_max):
  for l in range(d_max):
    sugar_gap = sugar_max - c*k - d*l
    if sugar_gap >= 0:
      sugar_gaps.append(sugar_gap)
sorted_sugar = sorted(sugar_gaps)
max_sugar = sugar_max - sorted_sugar[0]
print(str(int(max_water + max_sugar)) + " " + str(int(max_sugar)))
Problem p03807 (python)

Fixed submission:
n = int(input())
line = map(int,input().split())
odd = []
for i in line:
  if i % 2 == 1:
    odd.append(i)
if len(odd) % 2 == 0:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
5
1 2 3 4 5
Problem p02917 (python)

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

SUM = 0
A = [0]*N

for i in range(N-1):
    if i == 0:
        A[i] = B[i]

        if len(B) <= 1:
            A[i + 1] = B[i]
        else:
            if B[i] > B[i+1]:
                A[i+1] = B[i+1]
            else:
                A[i+1] = B[i]
        continue

    if i < N-2:
        if B[i] > B[i+1]:
            A[i+1] = B[i+1]
        else:
            A[i+1] = B[i]
    else:
        A[i+1] = B[i]

print(sum(A))

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

SUM = 0
A = [0]*N

for i in range(N-1):
    if i == 0:
        A[i] = B[i]
        if B[i] > B[i+1]:
            A[i+1] = B[i+1]
        else:
            A[i+1] = B[i]
        continue
        
    if i < N-2:
        if B[i] > B[i+1]:
            A[i+1] = B[i+1]
        else:
            A[i+1] = B[i]
    else:
        A[i+1] = B[i]


print(sum(A))
Problem p02971 (python)

Fixed submission:
# N = int(input())
# A = list(map(int, input().split()))
# 
# S = sorted(A)
# MAXS = max(A)
# 
# for i in range(N):
#     if A[i] == MAXS:
#         print(S[-2])
#     else:
#         print(S[-1])
# 


n = int(input())
a = list()
for i in range(n):
    a.append(int(input()))
c = a.index(max(a))
m = max(a)
a.sort()
d = a[-2]
for i in range(n):
    if i == c:
        print(d)
    else:
        print(m)

Buggy submission (verdict: Runtime Error):

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

# S = sorted(A)
# MAXS = max(A)
# two = S[-2]
# print("MAX {} two {}".format(MAXS,two))
# count = S.count(max(S))
#
# for i in range(N):
#     if A[i] == MAXS:
#         if count > 1:
#             print(MAXS)
#         else:
#             print(two)
#     else:
#         print(MAXS)

#


c = a.index(max(a))
m = max(a)
a.sort()
d = a[-2]
for i in range(n):
    if i == c:
        print(d)
    else:
        print(m)




# S = sorted(A)
# MAXS = max(A)
#
# for i in range(N):
#     if A[i] == MAXS:
#         print(S[-2])
#     else:
#         print(S[-1])


# #
# for i in range(N):
#
#     if i == 0:
#         print(max(A[1:]))
#
#     elif i == N-1:
#         print(max(A[:i]))
#
#     else:
#         low = max(A[0:i])
#         high = max(A[i+1:])
#
#         if high > low:
#             print(high)
#         else:
#             print(low)

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

S = sorted(A)
MAXS = max(A)

for i in range(N):
    if A[i] == MAXS:
        print(S[-2])
    else:
        print(S[-1])

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


S = sorted(A)
MAXS = max(A)

for i in range(N):
    if A[i] == MAXS:
        print(S[-2])
    else:
        print(S[-1])

Buggy submission (verdict: Runtime Error):

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

S = sorted(A)
MAXS = max(A)

for i in range(N):
    if A[i] == MAXS:
        print(S[-2])
    else:
        print(S[-1])

Buggy submission (verdict: Runtime Error):

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

# S = sorted(A)
# MAXS = max(A)
# two = S[-2]
# print("MAX {} two {}".format(MAXS,two))
# count = S.count(max(S))
#
# for i in range(N):
#     if A[i] == MAXS:
#         if count > 1:
#             print(MAXS)
#         else:
#             print(two)
#     else:
#         print(MAXS)

#

# 
# c = a.index(max(a))
# m = max(a)
# a.sort()
# d = a[-2]
# for i in range(n):
#     if i == c:
#         print(d)
#     else:
#         print(m)




S = sorted(A)
MAXS = max(A)

for i in range(N):
    if A[i] == MAXS:
        print(S[-2])
    else:
        print(S[-1])

Buggy submission (verdict: Runtime Error):

S = sorted(A)
MAXS = max(A)

for i in range(N):
    if A[i] == MAXS:
        print(S[-2])
    else:
        print(S[-1])
Problem p02993 (python)

Fixed submission:

S = input()

word = "p"
Judge = True

for i in range(len(S)):
    if word == S[i]:
        Judge = False
        break

    word = S[i]

if Judge:
    print("Good")
else:
    print("Bad")

Buggy submission (verdict: Runtime Error):
import fractions

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

A = ABCD[0]
B = ABCD[1]
C = ABCD[2]
D = ABCD[3]


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


firstC = int((A-1)/C)
firstD = int((A-1)/D)
firstCD = int((A-1)/lcm(C,D))

# if A%lcm(C,D) ==0 and firstCD > 0:
#     firstCD -= 1

endC = int(B/C)
endD = int(B/D)
endCD = int(B/lcm(C,D))

End = B-endC-firstD + endCD
First = (A-1) - firstC - firstD + firstCD



thereC = endC - firstC
thereD = endD - firstD
thereCD = endCD - firstCD

NoP = thereC+thereD - thereCD

# print(thereC)
# print(thereD)
# print(thereCD)
# print(NoP)
print((B-A+1)-NoP)
# print(End-First)
Problem p02995 (python)

Fixed submission:
import fractions

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

A = ABCD[0]
B = ABCD[1]
C = ABCD[2]
D = ABCD[3]


# def lcm(x, y):
#     return (x * y) // fractions.gcd(x, y)


def floor(a, b):
  # return int((a - a%b)/b)
  return a//b
def gcd(a, b):
  while b != 0:
      a, b = b, a % b
  return a
def lcm(a, b):
  return floor((a * b), gcd(a, b))

firstC = floor((A-1),C)
firstD = floor((A-1),D)
firstCD = floor((A-1),lcm(C,D))

# if A%lcm(C,D) ==0 and firstCD > 0:
#     firstCD -= 1

endC = floor(B,C)
endD = floor(B,D)
endCD = floor(B,lcm(C,D))

End = B-endC-firstD + endCD
First = (A-1) - firstC - firstD + firstCD



thereC = endC - firstC
thereD = endD - firstD
thereCD = endCD - firstCD

NoP = thereC+thereD - thereCD

# print(thereC)
# print(thereD)
# print(thereCD)
# print(NoP)
print((B-A+1)-NoP)
# print(End-First)

Buggy submission (verdict: Runtime Error):
import fractions
import AtCoderUtils
Utils = AtCoderUtils.ACUtils()


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

A = ABCD[0]
B = ABCD[1]
C = ABCD[2]
D = ABCD[3]


# def lcm(x, y):
#     return (x * y) // fractions.gcd(x, y)


# def floor(a, b):
#   # return int((a - a%b)/b)
#   return a//b
# def gcd(a, b):
#   while b != 0:
#       a, b = b, a % b
#   return a
# def lcm(a, b):
#   return floor((a * b), gcd(a, b))

firstC = Utils.floor((A-1),C)
firstD = Utils.floor((A-1),D)
firstCD = Utils.floor((A-1),Utils.lcm(C,D))

# if A%lcm(C,D) ==0 and firstCD > 0:
#     firstCD -= 1

endC = Utils.floor(B,C)
endD = Utils.floor(B,D)
endCD = Utils.floor(B,Utils.lcm(C,D))

End = B-endC-firstD + endCD
First = (A-1) - firstC - firstD + firstCD



thereC = endC - firstC
thereD = endD - firstD
thereCD = endCD - firstCD

NoP = thereC+thereD - thereCD

# print(thereC)
# print(thereD)
# print(thereCD)
# print(NoP)
print((B-A+1)-NoP)
# print(End-First)

Buggy submission (verdict: Runtime Error):
import math

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

A = ABCD[0]
B = ABCD[1]
C = ABCD[2]
D = ABCD[3]


def lcm(x, y):
    return (x * y) // math.gcd(x, y)

AB = B-A
count = 0

firstC = int(A/C)
if A%C == 0:
    firstC -= 1
firstD = int(A/D)

if A%D == 0:
    firstD -= 1

firstCD = int(A/lcm(C,D))
if A%lcm(C,D) ==0:
    firstCD -= 1

endC = int(B/C)
endD = int(B/D)
endCD = int(B/lcm(C,D))

thereC = endC - firstC
thereD = endD - firstD
thereCD = endCD - firstCD

NoP = thereC+thereD - thereCD
#
# print(thereC)
# print(thereD)
# print(thereCD)
# print(NoP)

print(B-A+1-NoP)
Problem p02639 (python)

Fixed submission:
x = list(map(int, input().split()))
for i in range(5):
    if x[i] == 0:
        print(i+1)
        break

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    p = list(map(int, input().split()))

    p.sort()
    y = 0

    for i in range(n):
        if p[i] <= x:
            y = i
            if i != n-1 and x < p[i+1]:
                break 

    i = 0
    while 1 == 1:
        if 0 <= y - i and x - i != p[y - i]:
            print(x - i)
            break
        if y + i < n and x + i != p[y + i]:
            print(x + i)
            break
        i = i + 1
Problem p02641 (python)

Fixed submission:
x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    p = list(map(int, input().split()))

    p.sort()
    y = 0

    for i in range(n):
        if p[i] <= x:
            y = i
            if i != n-1 and x < p[i+1]:
                break 

    i = 0
    while 1 == 1:
        if y - i < 0:
            print(p[0] - 1)
            break
        elif x - i != p[y - i]:
            print(x - i)
            break
        if n <= y + i:
            print(p[n - 1] + 1)
            break
        elif x + i != p[y + i]:
            print(x + i)
            break
        i = i + 1

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    p = list(map(int, input().split()))

    p.sort()
    y = 0

    for i in range(n):
        if p[i] <= x:
            y = i
            if i != n-1 and x < p[i+1]:
                break 

    i = 0
    while 1 == 1:
        if 0 <= y - i and x - i != p[y - i]:
            print(x - i)
            break
        if x + i != p[y + i]:
            print(x + i)
            break
        i = i + 1

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    p = list(map(int, input().split()))

    p.sort()
    y = 0

    for i in range(n):
        if p[i] <= x:
            y = i
            if i != n-1 and x < p[i+1]:
                break 

    i = 0
    while 1 == 1:
        if x - i != p[y - i]:
            print(x - i)
            break
        if x + i != p[y + i]:
            print(x + i)
            break
        i = i + 1

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    p = list(map(int, input().split()))

    p.sort()
    y = 0

    for i in range(n):
        if p[i] <= x:
            y = i
            if i != n-1 and x < p[i+1]:
                break 

    i = 0
    while 1 == 1:
        if x - i != p[y - i]:
            print(x - i)
            break
        if x + i != p[y + i]:
            print(x + i)
            break
        i =+ 1
Problem p02683 (python)

Fixed submission:
n, m, x = map(int, input().split())
l = [list(map(int, input().split())) for i in range(n)]

mincost = 0
for i in range(n):
    mincost += l[i][0]

s = []
for i in range(m+1):
    s.append(0)

flag = 0

for i in range(2 ** n):
    cost = 0
    for j in range(n):
        if ((i >> j) & 1):
            cost += l[j][0]
            for k in range(1, m+1):
                s[k] += l[j][k]
    b = 1
    for k in range(1, m+1):
        if s[k] < x:
            b = 0 
    if b == 1:
        flag = 1
        mincost = min(cost, mincost)
    for i in range(m+1):
        s[i] = 0

if flag == 1:
    print(mincost)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
n, m, x = map(int, input().split())
l = [list(map(int, input().split())) for i in range(n)]

mincost = 0
for i in range(m):
    mincost += l[i][0]

s = []
for i in range(m):
    s.append(0)

flag = 0

for i in range(2 ** n):
    cost = 0
    for j in range(n):
        if ((i >> j) & 1):
            cost += l[j][0]
            for k in range(1, m):
                s[k] += l[j][k]
    b = 1
    for k in range(1, m):
        if s[k] < x:
            b = 0 
    if b == 1:
        flag = 1
        mincost = min(cost, mincost)
    for i in range(m):
        s[i] = 0

if flag == 1:
    print(mincost)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
n, m, x = map(int, input().split())
l = [list(map(int, input().split())) for i in range(n)]

mincost = 0
for i in range(m):
    mincost += l[i][0]

s = []
for i in range(m):
    s.append(0)

flag = 0

for i in range(2 ** n):
    cost = 0
    for j in range(n):
        if ((i >> j) & 1):
            cost += l[j][0]
            for k in range(m):
                s[k] += l[j][k]
    b = 1
    for k in range(m):
        if s[k] < x:
            b = 0 
    if b == 1:
        flag = 1
        mincost = min(cost, mincost)
    for i in range(m):
        s[i] = 0

if flag == 1:
    print(mincost)
else:
    print(-1)
Problem p02700 (python)

Fixed submission:
a, b, c, d = map(int, input().split())

for i in range(1000):
    c = c - b
    if c <= 0:
        print('Yes')
        break
    a = a - d
    if a <= 0:
        print('No')
        break

Buggy submission (verdict: Runtime Error):
46 4 40 5
Problem p02612 (python)

Fixed submission:
n=eval(input())
f=(n//1000)
o=n/1000
if o==f:
  print(0)
else:
  p=(f+1)*1000-n
  print(p)

Buggy submission (verdict: Runtime Error):
n=eval(input())
t=(n//1000)+1
f=1000*t-n
pring(f)
Problem p02612 (python)

Fixed submission:
import math
n = int(input()) 
maisu = math.floor( (n+1000-1)/1000 )
val = maisu*1000 - n
 
print(val)

Buggy submission (verdict: Runtime Error):
n = int(input()) 
maisu = math.floor( (n+1000-1)/1000 )
val = maisu*1000 - n
 
print(val)

Buggy submission (verdict: Runtime Error):
n = int(input()) 
maisu = math.floor( (n+1000-1)/1000 )
val = maisu*1000 - n

print val
Problem p03328 (python)

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

a = int(l[0])
b = int(l[1])

n = b - a

h = n * (n + 1) // 2

print(h-b)

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

a = int(l[0])
b = int(l[1])

n = b - a

h = n * (n + 1) // 2

print(h-b)
Problem p03347 (python)

Fixed submission:
def main():

    N = int(input())
    a = int(input())
    A = [a]

    if a != 0:
        return -1

    else:
        for i in range(N-1):
            a_ = int(input())
            if a_ > a + 1:
                return -1

            else:
                a =  a_
                A.append(a)
            
        count = 0
        for i in range(N-1):
            a = A[N-1-i]
        
            if a == 0:
                continue
            elif a == A[N-2-i] + 1:
                count += 1
            else:
                count += a
                
        return count

print(main())

Buggy submission (verdict: Runtime Error):
line = input()

N = int(line)
A = np.array([0]*N)

for i in range(N):
    line = input()
    A[i] = int(line)

    
def IsNotPossible(A):
    for i in range(N): 
        ai = A[i]

        if ai > i:
            return 1

        for j in range(ai):
            if A[i-1-j] < ai-1-j:
                return 1

    return 0

if IsNotPossible(A):
    print(-1)
    
else:
    count = 0
    for i in range(N-1):
        a = A[N-1-i]
        
        if a == 0:
            continue
        elif a == A[N-2-i] + 1:
            count += 1
        else:
            count += a
            
    print(count)
Problem p03339 (python)

Fixed submission:
N=int(input())
S=input()
cnt=S.count("E")
m=cnt
for i in S:
    if i=="E":
        cnt-=1
    else:
        cnt+=1
    m=min(m,cnt)
print(m)

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

sum_W = [0] * (N+1)
sum_E = [0] * (N+1)

for i in range(N):
    if S[i] == "W":
        sum_W[i+1] = sum_W[i] + 1
        sum_E[i+1] = sum_E[i]
    else:
        sum_W[i+1] = sum_W[i]
        sum_E[i+1] = sum_E[i] + 1

answers = []
for i in range(N):
    answer = sum_W[i] + (sum_E[N+1] - sum_E[i+1])
    answers.append(answer)

print(min(answers))
Problem p02613 (python)

Fixed submission:
loop = int(input())
ac = 0
wa = 0
tle =0
re = 0

for _ in range(loop):
  judge = input()
  if judge == 'AC':
    ac += 1
  elif judge == 'WA':
    wa += 1
  elif judge == 'TLE':
  	tle += 1
  elif judge == 'RE':
    re += 1
    
print('AC x {}'.format(ac))
print('WA x {}'.format(wa))
print('TLE x {}'.format(tle))
print('RE x {}'.format(re))

Buggy submission (verdict: Runtime Error):
loop = int(input())
ac = 0
wa = 0
tle =0
re = 0

for _ in range(loop):
  judge = input()
  if judge == 'AC':
    ac += 1
  elif judge == 'WA':
    wa += 1
  elif judge == 'TLE':
  	tle += 1
  elif judge == 'RE':
    
print('AC × {}'.format(ac))
print('WA × {}'.format(wa))
print('TLE × {}'.format(tle))
print('RE × {}'.format(re))
Problem p02628 (python)

Fixed submission:
a,b = map(int,input().split())
listA = list(map(int,input().split()))
listA.sort()
all = 0

for i in range(b):
  all = all + listA[i]

print(all)

Buggy submission (verdict: Runtime Error):
a,b = input()
listA = list(map(int,input().split()))
listA.sort()
all = 0

for i in range(b):
  all = all + list[i]

print(all)