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

Fixed submission:
import math

def main():
    s = sum(list(map(int, input())))
    if s % 9==0:
        print('Yes')
    else:
        print('No')

if __name__=="__main__":
  main()

Buggy submission (verdict: Runtime Error):
import math

def sum_of_digits(n):
    s = 0
    l = len(str(n))
    for i in range(l):
        s += n%10
        n = int(n/10)
    return s

def main():
    s = int(input())
    s = sum_of_digits(s)
    if s != 0 and s % 9==0:
        print('Yes')
    else:
        print('No')

if __name__=="__main__":
  main()

Buggy submission (verdict: Runtime Error):
import math

def sum_of_digits(n):
    s = 0
    l = len(str(n))
    for i in range(l):
        s += n%10
        n = int(n/10)
    return s

def main():
    s = int(input())
    s = sum_of_digits(s)
    if s % 9==0:
        print('Yes')
    else:
        print('No')

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

Fixed submission:
n = int(input())
enemy = list(map(int, input().split()))
beat = list(map(int, input().split()))
ans = 0 
for i in range(n):
  #左を全力で倒す
  left = min([enemy[i], beat[i]])
  ans += left
  enemy[i] -= left
  beat[i] -= left
  
  right = min([enemy[i+1], beat[i]])
  ans += right
  enemy[i + 1] -= right
  beat[i] -= right
  
print(ans)

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

def hoge(index, index1):
	if(index == 0 and index1 == 0):
		return min([enemy[0], beat[0]])
	elif(index >= 0 and index1 - index == 1):
		return min([enemy[index1], beat[index] - hoge(index, index)])
	elif(index >= 1 and index1 == index):
		return min([enemy[index] - hoge(index - 1, index), beat[index] ])
	else:
		print(index, index1)
res = 0
for i in range(n):
	res += hoge(i, i) + hoge(i, i+1)
print(res)

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

def hoge(index, index1):
	if(index == 0 and index1 == 0):
		return min([enemy[0], beat[0]])
	elif(index >= 0 and index1 - index == 1):
		return min([enemy[index1], beat[index] - hoge(index, index)])
	elif(index >= 1 and index1 == index):
		return min([enemy[index] - hoge(index - 1, index), beat[index] ])
	else:
      print(index, index1)
res = 0
for i in range(n):
	res += hoge(i, i) + hoge(i, i+1)
print(res)

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

def hoge(index, index1):
	if(index == 0 and index1 == 0):
		return min([enemy[0], beat[0]])
	elif(index1 - index == 1):
		return min([enemy[index1], beat[index] - hoge(index, index)])
	else:
		return min([enemy[index] - hoge(index - 1, index), beat[index] ])
  
res = 0
for i in range(n):
	res += hoge(i, i) + hoge(i, i+1)
print(res)

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

def hoge(index, index1):
	if(index == 0 and index1 == 0):
		return min([enemy[0], beat[0]])
	elif(index1 - index == 1):
		return min([enemy[index1], beat[index] - hoge(index, index)])
	else:
		return min([enemy[index] - hoge(index - 1, index), beat[index] ])
  
res = 0
for i in range(n):
	print(i)  
	res += hoge(i, i) + hoge(i, i+1)
print(res)

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

def hoge(index, index1):
  if(index == 0 and index1 == 0):
  	return min([enemy[0], beat[0]])
  elif(index1 - index == 1):
    return min([enemy[index1], beat[index] - hoge(index, index)])
  else:
    return min([enemy[index] - hoge(index - 1, index), beat[index] ])
  
res = 0
for i in range(n):
	print(i)  
	res += hoge(i, i) + hoge(i, i+1)
print(res)
Problem p02989 (python)

Fixed submission:
n = int(input())
d = list(map(int,input().split()))
d.sort()
print(d[int(n / 2)] - d[int(n/2) -1])

Buggy submission (verdict: Runtime Error):
n = input()
d = list(map(int,input().split()))
d.sort()
print(d[int(n / 2)] - d[int(n/2) -1])

Buggy submission (verdict: Runtime Error):
n = input()
d = list(map(int,input().split()))
d.sort()
print(d[int(n / 2)] - d[int(n/2) -1 ])
Problem p03011 (python)

Fixed submission:
a = [int(_) for _ in input().split()] 
a.sort()
print(a[0] + a[1])

Buggy submission (verdict: Runtime Error):
s = map(int, input().split())
s.sort()
print(s[0] + s[1])
Problem p03012 (python)

Fixed submission:
import numpy as np
n = int(input())
w = np.array(list(map(int, input().split())))
w_amount = w.cumsum()
w_reverse_amount = w[::-1].cumsum()[::-1]
res = abs(w_amount[0] - w_reverse_amount[1])
min_index = 0
for i in range(n-1):
  if(res >= abs(w_amount[i] - w_reverse_amount[i+1])):
    res = abs(w_amount[i] - w_reverse_amount[i+1])
print(res)

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
w = np.array(list(map(int, input().split())))
w_amount = w.cumsum()
w_reverse_amount = w[::-1].cumsum()[::-1]

res = abs(w_amount[0] - w_reverse_amount[0])
min_index = 0
for i in range(n):
  if(res => abs(w_amount[i] - w_reverse_amount[i])):
    res = abs(w_amount[i] - w_reverse_amount[i])
    min_index = i
print(i+1)
Problem p03041 (python)

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

Buggy submission (verdict: Runtime Error):
n, k = list(map(int, input().split()))
s = input()
s[k-1] = s[k-1].upper()
print(s)
Problem p03221 (python)

Fixed submission:
from collections import defaultdict
import heapq
n_pref, m_city = list(map(int, input().split()))
record = defaultdict(list)
cities = []
for i in range(m_city):
  pref, year = list(map(int, input().split()))
  cities.append({"pref": pref, "year": year})
  heapq.heappush(record[pref], year)
res = defaultdict(dict)
for key ,value in record.items():
  for i in range(1, len(value) + 1):
    res[key][heapq.heappop(value)] = i
for city in cities:
  print(format(city["pref"], '06d'), format(res[city["pref"]][city["year"]], '06d'), sep="")

Buggy submission (verdict: Runtime Error):
n,m = list(map(int, input().split()))
cities = defaultdict(list)
cities = [ list(map(int, input().split())) for _ in range(m)]
sorted = sorted(
  cities,
  key = lambda x: (x[0], x[1])
)
hoge = 0
first_code = 0
fuga = 0
second_code = 0
for city in sorted:
  if(hoge < city[0]):
    hoge = city[0]
    first_code += 1
    fuga = 0
    seconde_code = 0
  if(fuga < city[1]):
    fuga = city[1]
    seconde_code += 1    
  print(format(first_code, '06'), format(second_code, '06'),sep="")
Problem p03775 (python)

Fixed submission:
import math
n = int(input())
res = 10**10
for i in range(1, int(math.sqrt(n) + 1)):
  if(n % i == 0):
    tmp = max([len(str(i)), len(str(n//i))])
    if(res > tmp):
      res = tmp
print(res)

Buggy submission (verdict: Runtime Error):
n = int(input())
res = 0
for i in int(sqrt(n) + 1):
  if(n % i == 0):
    tmp = max([len(i), len(n*i)])
    if(res > tmp):
      res = tmp
print(res)
Problem p03804 (python)

Fixed submission:
import numpy as np
n,m = list(map(int, input().split()))
tmp_a = [list(input()) for _ in range(n)]
tmp_b = [list(input()) for _ in range(m)]

a = np.array(tmp_a)
b = np.array(tmp_b)

for a_i in range(n - m + 1):
	for a_j in range(n - m + 1):
		if((a[a_i:a_i + m, a_j:a_j + m] == b).all()):
			print("Yes")
			exit()
print("No")

Buggy submission (verdict: Runtime Error):
import numpy as np
n,m = list(map(int, input().split()))
tmp_a = [list(input()) for _ in range(n)]
tmp_b = [list(input()) for _ in range(m)]

a = np.array(tmp_a)
b = np.array(tmp_b)

for a_i in range(n - m + 1):
	for a_j in range(n - m + 1):
		if((a[a_i:a_i + m, a_j:a_j + m] == b).all()):
			print("Yes")
			exit()
print("No")

Buggy submission (verdict: Runtime Error):
import numpy as np
n,m = list(map(int, input().split()))
tmp_a = [list(input()) for _ in range(n)]
tmp_b = [list(input()) for _ in range(m)]

a = np.array(tmp_a)
b = np.array(tmp_b)

for a_i in range(n - m + 1):
    for a_j in range(n - m + 1):
        if((a[a_i:a_i + m, a_j:a_j + m] == b).all()):
            print("Yes")
            exit()
print("No")

Buggy submission (verdict: Runtime Error):
import numpy as np
n,m = list(map(int, input().split()))
tmp_a = [list(input()) for _ in range(n)]
tmp_b = [list(input()) for _ in range(m)]

a = np.array(tmp_a)
b = np.array(tmp_b)

for a_i in range(n - m + 1):
    for a_j in range(n - m + 1):
        if((a[a_i:a_i + m, a_j:a_j + m] == b).all()):
          print("Yes")
          exit()
print("No")

Buggy submission (verdict: Runtime Error):
import numpy as np
n,m = list(map(int, input().split()))
tmp_a = [list(input()) for _ in range(n)]
tmp_b = [list(input()) for _ in range(m)]

a = np.array(tmp_a)
b = np.array(tmp_b)

for a_i in range(n - m + 1):
  for a_j in range(n - m + 1):
      if((a[a_i:a_i + m, a_j:a_j + m] == b).all()):
        print("Yes")
        exit()
print("No")
Problem p03834 (python)

Fixed submission:
s = input().replace(",", " ")
print(s)

Buggy submission (verdict: Runtime Error):
s = input().relace(",", " ")
print(s)
Problem p02777 (python)

Fixed submission:
s, t = input().split()
a, b = map(int, input().split())
u = input()
 
if s == u:
  print(a-1, b)
else:
  print(a, b-1)

Buggy submission (verdict: Runtime Error):
s, t = input().split()
a, b = map(int, input())
u = input()

if s == u:
  print(a-1, b)
else:
  print(a, b-1)
Problem p02627 (python)

Fixed submission:
print("aA"[input().isupper()])

Buggy submission (verdict: Runtime Error):
print("Aa"[isupper(input()[0])])
Problem p02948 (python)

Fixed submission:
n, m = map(int, input().split())
jobs = [[] for _ in range(m+1)]
for i in range(n):
    a, b = map(int, input().split())
    if a > m: continue
    jobs[m-a].append(-b)
import heapq
q = []
heapq.heapify(q)
ans = 0
for i in reversed(range(m)):
    [heapq.heappush(q, job) for job in jobs[i]]
    if q: ans -= heapq.heappop(q)
print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
ab = [map(int, input().split()) for _ in range(n)]
#i件目までのアルバイトでj日目までに得られる最大値
dp = [[0]*(m+1) for _ in range(n+1)]
for i in range(n):
    a, b = ab[i]#a日後に報酬bを得られる
    num = m+1-a
    for j in range(num):
        if j-1 >= 0:
            dp[i+1][j] = max(dp[i][j], dp[i][j-1]+b)
        else:
            dp[i+1][j] = max(dp[i][j], b)
    for j in range(a):
        dp[i+1][j+num] = dp[i+1][j+num-1]

print(max(dp[-1]))
Problem p02594 (python)

Fixed submission:
T = int(input())
if T >= 30:
    print("Yes")
else:
    print("No")

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

if T >= 30:
    print("Yes")
else:
    print("No")
Problem p02595 (python)

Fixed submission:
import math

N,D=(int(x) for x in input().split())

X=Y=p=count=0

for i in range(N):
  X,Y=(int(x) for x in input().split())
  p =math.sqrt(X**2+Y**2)
  if p <= D:
    count += 1
    
print(count)

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

X=Y=p=count=0

for index in range(N):
  X,Y = map(int,input().split)
  p = sqrt(X**2 + Y**2)
  if p <= D:
    count += 1
    
print(count)
Problem p02577 (python)

Fixed submission:
import sys
cin = sys.stdin.readline
n = list(cin())
ans = 0

n.pop(-1)
for i in n:
    ans += int(i)
if ans % 9 == 0:
    print('Yes')
else:
    print("No")

Buggy submission (verdict: Runtime Error):

import sys
import math
cin = sys.stdin.readline
n, x, t = map(int, cin().split())

count = math.ceil(n / x)
print(count * t)
Problem p02595 (python)

Fixed submission:
N, D = map(int, input().split())
count = 0
for i in range(N):
    a, b = map(int, input().split())
    if (a**2 + b**2) <= D**2:
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
N, D = map(int, input().split())
count = 0
print(D)
print(index)
for i in range(N):
    a, b = map(int, input().split())
    if (a**2 + b**2) <= D**2:
        count += 1
print(count)
Problem p03127 (python)

Fixed submission:
n = int(input())
a_li = list(set(int(x) for x in input().split()))

while 1:
    res = a_li[-1]
    a_li.sort(reverse = True)
    cou = 0
    for i in a_li[:-1]:
        a_li[cou] = i % a_li[-1]
        cou += 1
    a_li = list(set(a_li))
    try:
        a_li.remove(0)
    except:
        pass
    if len(a_li) == 0:
        print(res)
        break
    if len(a_li) == 1:
        print(a_li[0])
        break

Buggy submission (verdict: Runtime Error):
n = int(input())
a_li = list(set(int(x) for x in input().split()))

while 1:
    res = a_li[-1]
    a_li.sort(reverse = True)
    cou = 0
    for i in a_li[:-1]:
        a_li[cou] = i % a_li[-1]
        cou += 1
        print(a_li)
    a_li = list(set(a_li))
    try:
        a_li.remove(0)
    except:
        pass
    print(a_li)
    if len(a_li) == 0:
        print(res)
        break
    if len(a_li) == 1:
        print(a_li[0])
        break
Problem p03221 (python)

Fixed submission:
N,M = (int(x) for x in input().split())

p_y_list = [0]*M
y_count = [1]*(N+1)

for i in range(M):
    p,y = (int(x) for x in input().split())
    p_y_list[i] = [p,y,i]
p_y_list.sort(key = lambda x:x[1])

for i in p_y_list:
    i[1] = y_count[i[0]]
    y_count[i[0]] += 1

p_y_list.sort(key = lambda x:x[2])
for i in p_y_list:
    print(str(i[0]).rjust(6,"0") + str(i[1]).rjust(6,"0"))

Buggy submission (verdict: Runtime Error):
N,M = (int(x) for x in input().split())

p_y_list = [0]*N
y_count = [1]*(M+1)

for i in range(N):
    p,y = (int(x) for x in input().split())
    p_y_list[i] = [p,y,i]
p_y_list.sort(key = lambda x:x[1])

for i in p_y_list:
    i[1] = y_count[i[0]]
    y_count[i[0]] += 1

p_y_list.sort(key = lambda x:x[2])
for i in p_y_list:
    print(str(i[0]).rjust(6,"0") + str(i[1]).rjust(6,"0"))

Buggy submission (verdict: Runtime Error):
N,M = (int(x) for x in input().split())

p_y_list = [0]*M
y_count = [1]*(M+1)

for i in range(M):
    p,y = (int(x) for x in input().split())
    p_y_list[i] = [p,y,i]
p_y_list.sort(key = lambda x:x[1])

for i in p_y_list:
    i[1] = y_count[i[0]]
    y_count[i[0]] += 1

p_y_list.sort(key = lambda x:x[2])
for i in p_y_list:
    print(str(i[0]).rjust(6,"0") + str(i[1]).rjust(6,"0"))

Buggy submission (verdict: Runtime Error):
N,M = (int(x) for x in input().split())

p_y_list = []
y_count = [1]*(M+1)

for i in range(M):
    p,y = (int(x) for x in input().split())
    p_y_list[i] = [p,y,i]
p_y_list.sort(key = lambda x:x[1])

for i in p_y_list:
    i[1] = y_count[i[0]]
    y_count[i[0]] += 1

p_y_list.sort(key = lambda x:x[2])
for i in p_y_id_list:
    print(str(i[0]).rjust(6,"0") + str(i[1]).rjust(6,"0"))

Buggy submission (verdict: Runtime Error):
N,M = (int(x) for x in input().split())

p_y_list = []
y_count = [1]*(M+1)

for i in range(M):
    p_y_list.append([int(x) for x in input().split()])
    p_y_list[i].append(i)
p_y_list.sort(key = lambda x:x[1])

for i in p_y_list:
    i[1] = y_count[i[0]]
    y_count[i[0]] += 1

p_y_list.sort(key = lambda x:x[2])
for i in p_y_id_list:
    print(str(i[0]).rjust(6,"0") + str(i[1]).rjust(6,"0"))

Buggy submission (verdict: Runtime Error):
N,M = (int(x) for x in input().split())

p_y_list = []
y_count = [1]*(M+1)
for i in range(M):
    p_y_list.append([int(x) for x in input().split()])
    p_y_list[i].append(i)
p_y_list.sort(key = lambda x:x[1])
p_y_id_list = []
for i in p_y_list:
    p_y_id_list.append([i[0],y_count[i[0]],i[2]])
    y_count[i[0]] += 1
p_y_id_list.sort(key = lambda x:x[2])
for i in p_y_id_list:
    print(str(i[0]).rjust(6,"0") + str(i[1]).rjust(6,"0"))
Problem p03250 (python)

Fixed submission:
n = [int(x) for x in input().split()]
n.sort()
print(10*n[2]+n[1]+n[0])

Buggy submission (verdict: Runtime Error):
n = [int(x) for x in input().split()].sort()
print(10*n[2]+n[1]+n[0])
Problem p03272 (python)

Fixed submission:
n,i = (int(x) for x in input().split())
print(n - i + 1 )

Buggy submission (verdict: Runtime Error):
h,w = map(int,input().split())
map_ = list()
for i in range(h):
    map_.append(list(input()))
flag = True
while flag:

    flag = False

    for ii in range(len(map_)):
        if set(map_[ii]) == {"."}:
            del map_[ii]
            flag = True
            break

    map_t = [list(x) for x in zip(*map_)]

    for ii in range(len(map_t)):
        if set(map_t[ii]) == {"."}:
            del map_t[ii]
            flag = True
            break

    map_ = [list(x) for x in zip(*map_t)]


for iiii in map_:
    print(*iiii,sep="")
Problem p02682 (python)

Fixed submission:
a, b, c, n = map(int, input().split())
if a >= n:
    print(n)
elif n > a and a + b >= n:
    print(a)
else:
    print(a + a - n + b)

Buggy submission (verdict: Runtime Error):
a, b, c, n = map(int, input().split())
if a >= n:
    print(n)
elif n > a and a + b >= n:
    print(a)
else:
    print(2a - n + b)

Buggy submission (verdict: Runtime Error):
a, b, c, n = map(int, input().split())
if a >= n:
    print(n)
elif n > a and a + b >= n:
    print(a)
else
    print(a - (n - a))
Problem p02688 (python)

Fixed submission:
n, k = map(int, input().split())
snk = [-1] * (n+1)
ans = 0
for j in range(k):
	d = int(input())
	lis = list(input().split())
	for i in range(d):
		y = int(lis[i])
		snk[y] = 0
for j in range(n):
    if snk[j+1] == -1:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
snk = [-1] * (n + 1)
for j in range(k):
	d = input()
	list = map(int, input().split())
    for i in range(d):
        snk[list[i]] = 0
for j in range(n):
    if snk[j] == -1:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
snk = [-1] * (n + 1)
for j in range(k):
	d = input()
	list = map(int, input().split())
    for i in range(d):
        snk[list[i]] = 0
for j in range(n):
    if snk[j + 1] == -1:
        ans += 1
print(ans)
Problem p02701 (python)

Fixed submission:

a = int(input())
l = [input() for i in range(a)]
print(len(set(l)))

Buggy submission (verdict: Runtime Error):
a = p.strip()
l = a.split()
m = l.pop(0)
print(len(set(l)))

Buggy submission (verdict: Runtime Error):
a = p.strip()
l = a.split()
m = l.pop(0)
print(len(set(l))

Buggy submission (verdict: Runtime Error):
p = input()
a = p.strip()
l = a.split()
m = l.pop(0)
print(len(set(l))

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

m_l = set()
for i in range(1 , n + 1):
    m_l.add(l[i])
print(len(m_l))

Buggy submission (verdict: Runtime Error):
a = input().strip()
l = a.split()
n = int(l[0])
m_l = set()
for i in range(1 , n + 1):
    m_l.add(l[i])
print(len(set(m_l)))

Buggy submission (verdict: Runtime Error):
a = input().strip()
l = a.split()
n = int(l[0])
m_l = []
for i in range(1 , n + 1):
    m_l.append(l[i])
print(len(list(set(m_l))))
Problem p03803 (python)

Fixed submission:
a, b = map(int, input().split())
if a == b:
    print("Draw")
elif a == 1:
    print("Alice")
elif b == 1:
    print("Bob")
elif a > b:
    print("Alice")
elif a < b:
    print("Bob")

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split()))
if A == B:
    print("Draw")
elif A == 1 and B != 1:
    print("Alice")
elif B == 1 and A != 1:
    print("Bod")
elif A > B:
    print("Alice")
else:
    print("Bob")
Problem p02577 (python)

Fixed submission:
import math

N=int(input())
if N%9==0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):

from enum import Enum
from queue import Queue
import collections

import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

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

if sum(n)%9==0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):

from enum import Enum
from queue import Queue
import collections

import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

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

if sum(n)%9==0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):

from enum import Enum
from queue import Queue
import collections

import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

N=int(input())
if N/9==0:
    print('Yes')
else:
    print('No')
Problem p02578 (python)

Fixed submission:
import math

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

ans=0
for i in range(N-1):
    tmp = A[i]-A[i+1]
    if tmp >=0:
        ans = ans + tmp
        A[i+1] = A[i]

print(ans)

Buggy submission (verdict: Runtime Error):
import math

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

ans=0
for i in range(N-1):
    tmp = A[i]-A[i+1]
    if tmp <=0:
        ans = ans + tmp
        A[i+1] = A[i]

Print(ans)
Problem p02594 (python)

Fixed submission:
X = int(input())

if X>=30:
    print('Yes')
else:
    print('No')

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

if X>=30:
    print('Yes')
else:
    print('No')
Problem p02597 (python)

Fixed submission:
N = int(input())
s = str(input())

a = 0
b = 0

for i in range(N):
    if s[i] == 'R':
        a = a + 1
ans = max(a,b)
for i in range(N):
    if s[i] == 'R':
        a = a - 1
    else:
        b = b + 1
    now = max(a,b)
    ans = min(ans, now)
print(ans)

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

a = 0
b = 0

for i in range(N):
    if s[i] == 'R':
        a = a + 1
ans = max(a,b)
for i in range(N):
    if s[i] == 'R':
        a = a - 1
    else:
        b = b + 1
    now = max(a,b)
    ans = min(ans, now)
print(ans)
Problem p02881 (python)

Fixed submission:
from enum import Enum
from queue import Queue

import numpy as np

import collections
import bisect
import sys
import math

from scipy.sparse.csgraph import floyd_warshall

BIG_NUM = 200000000000
MOD = 1000000007
EPS = 0.000000001

N = int(input())
ans = N

for i in range(1,int(np.sqrt(N))+1):
    if N % i == 0:
        j = N//i
        ans = min(ans, i+j-2)

print(ans)

Buggy submission (verdict: Runtime Error):
from enum import Enum
from queue import Queue

import numpy as np

import collections
import bisect
import sys
import math

from scipy.sparse.csgraph import floyd_warshall

BIG_NUM = 200000000000
MOD = 1000000007
EPS = 0.000000001

N = int(input())
ans = BIG_NUM

for i in range(0,int(np.sqrt(N))):
    if N % i == 0:
        j = N//i
        ans = min(ans, i+j-2)

print(ans)
Problem p02578 (python)

Fixed submission:
num = int(input())
item = input().split()
res = 0

for i in range(num):
  if i == 0:
    continue
  b = int(item[i - 1])
  t = int(item[i])
  
  if b > t:
    res += (b - t)
    item[i] = b
    
      
print(res)

Buggy submission (verdict: Runtime Error):
item = input().split()
fumidai_sum = 0

for i in range(int(item[0])):
  b = int(item[i])
  t = int(item[i + 1])
  
  if b > t:
    fumidai_sum += (b - t)
      
print(fumidai_sum)
Problem p02699 (python)

Fixed submission:
# -*- coding: utf-8 -*-
s, w = map(int,input().split())
if s-w > 0:
  print('safe')
else:
  print('unsafe')

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
 
s = input()
counter = 0

for i in range(len(s) - 4):
  for j in range(4, len(s) + 1):
      if int(float(s[i:j])) % 2019 == 0:
        counter += 1
        
print(counter)
Problem p02987 (python)

Fixed submission:
S = sorted(input())
if len(set(S)) == 2 and S[0] == S[1] and S[1] != S[2] and S[2] == S[3]:
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
import math
n,k=input().split()
n=int(n)
k=int(k)
for i in range(1,k+1):
    x=math.factorial(n-k+1)/(math.factorial(n-k+1-i)*math.factorial(i))
    y=math.factorial(k-1)/(math.factorial(k-i)*math.factorial(i-1))
    ans=x*y%(10**9+7)
    print(int(ans))

Buggy submission (verdict: Runtime Error):
n=int(input())
p=[int(i) for i in input().split()]
ans=0
for x in range(1,n-1):
    a=p[x-1]
    b=p[x]
    c=p[x+1]
    if a<b<c or c<b<a:
        ans+=1
print(ans)