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

Fixed submission:
import math
n=int(input())
a=[int(x) for x in input().split()]
a_log=[]
if 0 not in a:
  for i in a:
    i_log=math.log10(i)
    a_log.append(i_log)
  
  if sum(a_log)>18:
    print("-1")
  else:
    for i in range(n-1):
  	  a[i+1]*=a[i]
    if a[n-1]>10**18:
      print("-1")
    else:
      print(a[n-1])
else:
  print("0")

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
a=[int(x) for x in input().split()]
a_log=[]
for i in a:
  if i == 0:
    i+=10**(-1000000)
  i_log=math.log10(i)
  a_log.append(i_log)
  
if sum(a_log)>18:
  print("-1")
else:
  for i in range(n-1):
  	a[i+1]*=a[i]
  if a[n-1]>10**18:
    print("-1")
  else:
    print(a[n-1])

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
a=[int(x) for x in input().split()]
a_log=[]
for i in a:
  i_log=math.log10(i)
  a_log.append(i_log)
  
if sum(a_log)>18:
  print("-1")
else:
  for i in range(n-1):
  	a[i+1]*=a[i]
  print(a[n-1])
Problem p02681 (python)

Fixed submission:
s = input()
t=input()
if t[:-1] == s:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import bisect
import heapq
import itertools
import math
import numpy as np
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]



#いまいるところ,
#listとnが与えられたときn回テレポートしたところを出力する
def now_place(li,n):
    now = 1
    for i in range(n):
        now = li[now-1]
    return now

#p回のテレポートでたどってきた道筋のルートを返す

def root(li,p):
    ans = []
    now = 1
    for j in range(p):
        ans.append(now_place(li,j+1))
    return ans



n,k = MI()
a = LI()
#訪れたところのメモがtown
town　= []
#訪れたかどうかを0と1で管理
visit=[0]*n
p = 1
while visit[p-1] == 0:
    town.append(p)
    visit[p-1] = 1
    p = a[p-1]
#香りだかい町がいつでてきたか→周期に入るまでのテレポート回数
#len(town[l:])は周期を表す
l = town.index(p)
if k <len(town):
    print(town[k])
else:
    print(town[l + (k-l)%(len(town[l:]))])
Problem p02713 (python)

Fixed submission:
import math
k = int(input())
ans = 0
for i in range(1,k+1):
  for j in range(1,k+1):
    g = math.gcd(i,j)
    for k in range(1,k+1):
      ans += math.gcd(g,k)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
k = int(input())
ans = 0
for i in range(1,k+1):
  for j in range(1,k+1):
    for k in range(1,k+1):
      ans += math.gcd(i,j,k)
print(ans)
Problem p02714 (python)

Fixed submission:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)
import bisect
import heapq
import itertools
import math
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

#bisect.bisect_left(list,key)はlistのなかでkey未満の数字がいくつあるかを返す
#つまりlist[i] < x となる i の個数
#bisect.bisect_right(list, key)はlistのなかでkey以下の数字がいくつあるかを返す
#つまりlist[i] <= x となる i の個数
#これを応用することで
#len(list) - bisect.bisect_left(list,key)はlistのなかでkey以上の数字がいくつあるかを返す
#len(list) - bisect.bisect_right(list,key)はlistのなかでkeyより大きい数字がいくつあるかを返す
#これらを使うときはあらかじめlistをソートしておくこと！
n = I()
s = input()
c = Counter(s)
ans = 0
for i in range(n):
    for k in range(i+1,n):
        if (i+k)%2 == 0:
            j = (i+k)//2
            if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
                ans+=1
ans_2 = c["R"]*c["G"]*c["B"]
print(ans_2-ans)

Buggy submission (verdict: Runtime Error):
n= int(input())
s = input()
ans = 0
li_r = []
li_g = []
li_b = []
for i in range(n):
  if li[i] == "R":
    li_r.append(i+1)
  elif li[i] == "G":
    li_g.append(i+1)
  elif li[i] == "B":
    li_b.append(i+1)
for i in li_r:
  for j in li_g:
    if 2*j - i in li_b:
      ans += len(li_b) -1
    else:
      ans += len(li_b)
print(ans)
Problem p02718 (python)

Fixed submission:
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())

n,m = MI()
a = LI()
a.sort()
a.reverse()
ki = sum(a)/(4*m)
if a[m-1] < ki:
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
#import numpy as np
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import lru_cache, reduce
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())

n,m = MI()
a = LI()
a.sort()
a.reverse()
ki = sum(a)/(4*m)
if a[m-1] < ki:
    print("No")
else:
    print("Yes")
Problem p02783 (python)

Fixed submission:
h,a = map(int,input().split())
ans = 0
for k in range(100000000):
  h = h-a
  if h <=0:
    ans = k+1
    break
print(ans)

Buggy submission (verdict: Runtime Error):
h,a = map(int,inpit().split())
ans = 0
for k in range(100000000):
  h = h-a
  if h <=0:
    ans = k+1
    break
print(ans)
Problem p02812 (python)

Fixed submission:
n = int(input())
s = input()
cnt=0
for i in range(n-2):
  if s[i] == "A" and s[i+1] == "B" and s[i+2] == "C":
    cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
cnt=0
for i in range(n-2):
  if s[i] == "a" && s[i+1] == "b" && s[i+2] == "c":
    cnt+=1
print(cnt)
Problem p02850 (python)

Fixed submission:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)
import bisect
import heapq
import itertools
import math
import numpy as np
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

n = I()

#graph[i]には頂点iと繋がっている頂点を格納する
graph = [[] for _ in range(n+1)]
prev_col = [0]*(n+1)
a_b = []
k=0
for i in range(n-1):
    a,b = MI()
    a_b.append(str(a)+" "+str(b))
    graph[a].append(b)
    graph[b].append(a)
#check[i] == -1ならば未探索
check = [-1]*(n+1)
check[0] = 0
check[1] = 0
for i in range(n+1):
    k = max(len(graph[i]),k)
d = deque()
d.append(1)
ans = dict()
while d:
    v = d.popleft()
    check[v] = 1
    cnt = 0
    for i in graph[v]:
      if check[i] != -1:
        continue
      cnt = cnt+1
      if prev_col[v] == cnt:
        cnt = cnt + 1
      prev_col[i] = cnt
      ans[str(min(i,v))+" "+str(max(i,v))]=cnt
      d.append(i)
print(k)
for key in a_b:
    print(ans[key])

Buggy submission (verdict: Runtime Error):

from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

n = I()
#edge[i][j]には頂点iと頂点jをつなぐ辺の色を格納する
edge = [[0]*(n+1) for _ in range(n+1)]
#graph[i]には頂点iと繋がっている頂点を格納する
graph = [[] for _ in range(n+1)]
prev_col = [0]*(n+1)
k = 0
a_b = []
for i in range(n-1):
    a,b = MI()
    a_b.append([a,b])
    graph[a].append(b)
    graph[b].append(a)
#check[i] == -1ならば未探索
check = [-1]*(n+1)
check[0] = 0
check[1] = 0
d = deque()
d.append(1)
while d:
    v = d.popleft()
    check[v] = 1
    cnt = 0
    for i in graph[v]:
      if check[i] != -1:
        continue
      cnt = cnt+1
      if prev_col[v] == cnt:
        cnt = cnt + 1
      edge[i][v] = cnt
      edge[v][i] = cnt
      prev_col[i] = cnt
      d.append(i)
      check[i] = 0
      k = max(k,cnt)
print(k)
for i in range(n-1):
    color = edge[a_b[i][0]][a_b[i][1]]
    print(color)
Problem p02922 (python)

Fixed submission:
a,b = map(int,input().split())
if b == 1:
  print("0")
else:
  for i in range(100):
    if (i-1)*(a-1) + a >= b:
      print(i)
      break

Buggy submission (verdict: Runtime Error):
import.math
a,b = map(int,input().split())
if b == 1:
  print("0")
else:
  print(math.ceil(b/a))
Problem p02923 (python)

Fixed submission:
n = int(input())
li = list(map(int,input().split()))	
if n == 1:
  print("0")
else:
  ans_li =[]
  ans_1 = 0
  for i in range(n-1):
    if li[i] >= li[i+1]:
       ans_1 = ans_1 + 1
    elif li[i]<li[i+1]:
      ans_li.append(ans_1)
      ans_1 = 0
    if i == n-2:
      ans_li.append(ans_1)
  print(max(ans_li))

Buggy submission (verdict: Runtime Error):
n = int(input())
li = list(map(int,input().split()))	
ans_li =[]
ans_1 = 0
for i in range(n-1):
  if li[i] >= li[i+1]:
     ans_1 = ans_1 + 1
  elif li[i]<li[i+1]:
    ans_li.append(ans_1)
    ans_1 = 0
  if i == n-2:
    ans_li.append(ans_1)
print(max(ans_li))

Buggy submission (verdict: Runtime Error):
n = int(input())
li = list(map(int,input().split()))	
ans_li =[]
ans_1 = 0
for i in range(n-1):
  if i == n-2:
    ans_li.append(ans_1)
    break
  elif li[i] >= li[i+1]:
     ans_1 += 1
  else:
    ans_li.append(ans_1)
print(max(ans_li))
Problem p02924 (python)

Fixed submission:
n = int(input())
print(((n-1)*n)//2)

Buggy submission (verdict: Runtime Error):
from decimal import Decimal

import math
n = int(input())
li = [list(map(int, input().split())) for _ in range(n)]
p = li[0]
d = li[0][0]**2 + li[0][1]**2
for i in range(1,n):
  if (p[0]+li[i][0])**2 + (p[1]+li[i][1])**2 > d:
    p = [p[0]+li[i][0],p[1]+li[i][1]]
    d = p[0]**2 + p[1]**2
distance = p[0]**2 + p[1]**2

print(math.sqrt(distance))
Problem p02927 (python)

Fixed submission:
m,d = map(int,input().split())
ans = 0
for i in range(1,m+1):
  for j in range(1,d+1):
    if j%10 >= 2 and j//10 >= 2 and (j%10) * (j//10) ==i:
      ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
li = list(map(int,input().split()))
mod = 10**9 +7
 
ans_1 = 0
ans_2 = 0
for i in range(n):
  for j in range(i+1,n):
    if li[i] > li[j]:
      ans_1+= 1
for i in range(n):
  for j in range(n):
    if li[i] > li[j]:
      ans_2 += 1
ans = k*ans_1%mod + 0.5*k%mod*(k-1)%mod*ans_2%mod
print(int(ans%mod))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
li = list(map(int,input().split()))
mod = 10**9 +7

ans_1 = 0
ans_2 = 0
for i in range(n-1):
  for j in range(i+1,n):
    if li[i] > li[j]:
      ans_1+= 1
for i in range(n):
  for j in range(n):
    if li[i] < li[j]:
      ans_2 += 1
ans = k*ans_1 + 0.5*k*(k-1)%mod*ans_2
print(ans_1)
print(ans_2)
print(ans%mod)
Problem p03035 (python)

Fixed submission:
a,b = map(int,input().split())
if a >=13:
  print(b)
elif 6<=a and a<=13:
  print(b//2)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
a.b = map(int,input().split)
if a >=13:
  print(b)
else if 6<=a and a<=13:
  print(b//2)
else:
  print(0)
Problem p03060 (python)

Fixed submission:
n = int(input())
v_li = list(map(int,input().split()))
c_li = list(map(int,input().split()))
ben = []
for i in range(n):
  b = v_li[i]-c_li[i]
  ben.append(b)
ben.sort()
ben.reverse()
ans = 0
for i in range(n):
  if ben[i] >0:
    ans+=ben[i]
  else:
    break
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
v_li = list(map(int,input().split()))
c_li = list(map(int,input().split()))
ben = []
for i in range(n):
  b = v_li[i]-c_li[i]
  ben.append(b)
ben.sort()
ben.reverse()
ans = 0
j = 0
while ben[j]>=0:
  ans+= ben[j]
  j +=1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
v_li = list(map(int,input().split()))
c_li = list(map(int,input().split()))
ben = []
for i in range(n):
  b = v_li[i]-c_li[i]
  ben.append(b)
ben.sort()
ben.reverse()
ans = 0
j = 0
while ben[j]>0:
  ans+= ben[j]
  j +=1
print(ans)
Problem p02731 (python)

Fixed submission:
num = int(input())

number = num / 3
print(number * number * number)

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

number = num / 3
print(number * number * number)a
Problem p02690 (python)

Fixed submission:
def cal(a,b):
    return a**5-b**5

def main():
    X = int(input())
    update = True
    for i in range(10**3):
        for j in range(10**3):
            if cal(i,j) == X:
                a,b = i,j
                update = False
                break
            if cal(i,-j) == X:
                a,b = i,-j
                update = False
                break
        if not update:
            break

    print(a,b)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    X = int(input())
    n_5,a = [(0,0)],1
    while a**5 <= X:
        n_5.append((a,a**5))
        n_5.append((-a,-a**5))
        a += 1
    n_5.sort()

    for a in range(len(n_5)):
        for b in range(len(n_5)):
            if n_5[a][1] - n_5[b][1] == X:
                a_ans,b_ans = n_5[a][0],n_5[b][0]
                break

    print(a_ans,b_ans)

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

Fixed submission:
def cal(A,B,x):
    return int((A*x)/B) - A*int(x/B)

def main():
    A,B,N = map(int,input().split())
    if N <= B-1:
        ans = cal(A,B,N)
    else:
        ans = cal(A,B,B-1)
    print(ans)

if __name__ == "__main__":
    main()

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

def cal(A,B,x):
    return int((A*x)/B) - A*int(x/B)

def main():
    A,B,N = map(int,input().split())
    if N <= B-1:
        ans = cal(A,B,N)
    else:
        a,b = A//gcd(A,B),B//gcd(A,B)
        if N % B == 0:
            ans = cal(A,B,b*d-1)
        else:
            ans = cal(A,B,N)
    print(ans)

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

Fixed submission:
H,N = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(N)]

DP = [0 for i in range(H+1)] #DP[h]=体力hのやつを倒す最小mp

min_mp = 10**9
for i in range(N):
    if min_mp > AB[i][1]:
        min_mp = AB[i][1]
        min_mp_i = i

for h in range(1,min(AB[min_mp_i][0],H)+1):
    #最小消費mpの技でオーバーキルの場合にDP[h]がout of rangeになる
    DP[h] = min_mp

for h in range(AB[min_mp_i][0]+1,H+1):
    DP[h] = min((DP[h - a] + b) for a,b in AB )
    #最小消費mpの技で初期化しないとh - a >= 0を満たすaの存在が怪しい

print(DP[H])

Buggy submission (verdict: Runtime Error):
H,N = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(N)]

DP = [0 for i in range(H+1)] #DP[h]=体力hのやつを倒す最小mp

min_mp = 10**9
for i in range(N):
    if min_mp > AB[i][1]:
        min_mp = AB[i][1]
        min_mp_i = i

for h in range(1,AB[min_mp_i][0]+1):
    DP[h] = min_mp

for h in range(AB[min_mp_i][0]+1,H+1):
    DP[h] = min((DP[h - a] + b) for a,b in AB )
    #最小消費mpの技で初期化しないとh - a >= 0を満たすaの存在が怪しい

print(DP[H])

Buggy submission (verdict: Runtime Error):
H,N = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(N)]

DP = [0 for i in range(H+1)] #DP[h]=体力hのやつを倒す最小mp

for h in range(1,H+1):
    DP[h] = min((DP[h - a] + b) for a,b in AB )

print(DP[H])

Buggy submission (verdict: Runtime Error):
H,N = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(N)]

INF = 10**9
DP = [0 for i in range(H+1)] #DP[h]=体力hのやつを倒す最小mp
min_mp = INF

for i in range(N):
    if min_mp > AB[i][1]:
        min_mp = AB[i][1]
        min_mp_i = i #消費mpが最小の技の番号

for h in range(1,AB[min_mp_i][0]+1):
    DP[h] = AB[min_mp_i][1]

for h in range(AB[min_mp_i][0]+1,H+1):
    min = INF
    for i in range(N):
        if h - AB[i][0] >= 0:
        #これを満たすiの存在を保証するために消費mp最小の技でDPに初期設定を与えた
            if min > DP[h - AB[i][0]] + AB[i][1]:
                min = DP[h - AB[i][0]] + AB[i][1]
    DP[h] = min

print(DP[H])
Problem p02866 (python)

Fixed submission:
from collections import Counter

def cal(D,M):
    C = Counter(D)
    MC = C.most_common()
    MC.sort(key = lambda x:x[0])
    n = len(MC)
    #頂点1が根じゃないときも連結の仕方を変えずに見方を変えることで
    #頂点1を根にできる.
    #従ってD[i-1]は頂点iの深さと見なせる
    for i in range(n):
        if MC[i][0] != i:
            #深さiと深さi-1又は深さiと深さi+1を繋げない
            return 0
    if MC[0][1] != 1 or D[0] != 0:
        #1以外の根がある又は1が根になってない
        return 0

    output = 1
    for i in range(n-1):
        output *= pow(MC[i][1],MC[i+1][1],M)
        output %= M
    return output

def main():
    N = int(input())
    D = list(map(int,input().split()))
    M = 998244353

    ans = cal(D,M)
    print(ans)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from collections import Counter

def cal(D,M):
    C = Counter(D)
    MC = C.most_common()
    MC = sort(key = lambda x:x[0])
    n = len(MC)
    #頂点1が根じゃないときも連結の仕方を変えずに見方を変えることで
    #頂点1を根にできる.
    #従ってD[i-1]は頂点iの深さと見なせる
    for i in range(n):
        if MC[i][0] != i:
            #深さiと深さi-1又は深さiと深さi+1を繋げない
            return 0
    if MC[0][1] != 1 or D[0] != 0:
        #1以外の根がある又は1が根になってない
        return 0

    output = 1
    for i in range(n-1):
        output *= pow(MC[i][1],MC[i+1][1],M)
        output %= M
    return output

def main():
    N = int(input())
    D = list(map(int,input().split()))
    M = 998244353

    ans = cal(D,M)
    print(ans)

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

Fixed submission:
from math import sqrt

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

def gcd(a,b):
    if a < b:
        a,b = b,a
    while a % b != 0:
        r = a % b
        a,b = b,r
    return b

def count_prime(n):
    #nを割り切る素数の個数
    if n == 1:
        return 0
    n_is_prime = True
    P = []
    for i in range(2,int(sqrt(n))+1):
        if n % i == 0:
            n_is_prime = False
            P.append(i)
            while n % i == 0:
                n //= i
    if n_is_prime:
        return 1
    elif n == 1:
        return len(P)
    else:
        #この時点で割り切れずに残ったnは未発見の素数
        return len(P)+1

g = gcd(A,B)
c_p = count_prime(g)
print(c_p+1)

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

def GCD(a,b):
    if a < b:
        a, b = b, a
    if a % b == 0:
        return b
    else:
        return GCD(b, a % b)

def primes(n):
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass

g = GCD(A,B)
P = primes(g)
Q = []
for p in P:
    if g % p == 0:
        Q.append(p)

n = len(Q)
print(n + 1)
Problem p02953 (python)

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

if N>1:
	flag=0
	for i in reversed(range(1,N)):
		if H[i-1]-H[i]>1:
			flag=1
		if H[i-1]-H[i]==1:
			H[i-1] -= 1
	if flag==0:
		print("Yes")
	else:
		print("No")
else:
	print("Yes")

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

if N>1:
	flag=0
	for i in reversed(range(N-1)):
		if H[i-1]-H[i}>1:
			flag=1
		if H[i-1]-H[i]==1:
			H[i-1] -= 1
	if flag==0:
		print("Yes")
	else:
		print("No")
else:
	print("Yes")
Problem p02969 (python)

Fixed submission:
r=int(input())
S=3*r*r
print(S)

Buggy submission (verdict: Runtime Error):
import math

line = list(map(int, input().split(" ")))
N = line[0]
D = line[1]

bord = math.ceil(N/(2*D+1))

print(bord)
Problem p03074 (python)

Fixed submission:
def burst(S):
    S += "_" #dummyを追加
    st,sp,ep = S[0],0,0
    S0,S1 = [],[]
    for i in range(1,len(S)):
        if st == S[i]:
            ep += 1
        else:
            if st == "0":
                S0.append((sp,ep))
            else:
                S1.append((sp,ep))
            st,sp,ep = S[i],i,i

    return [S0,S1]

def connect(S0,S1,K,len_S):
    if len(S0) == 0 or len(S1) == 0:
        return len_S
    else:
        if S1[0][0] != 0:
            S1 = [(0,0)] + S1
        if S1[len(S1)-1][1] != len_S-1:
            S1.append((len_S-1,len_S-1))
        if len(S1)-1 <= K:
            return len_S
        else:
            output = 0
            for i in range(len(S1)-K):
                output = max(output,S1[i+K][1]-S1[i][0]+1)
            return output

def main():
    N,K = map(int,input().split())
    S = input()

    T = burst(S)
    S0,S1 = T[0],T[1]
    print(connect(S0,S1,K,N))

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def burst(S,k):
    S = "_" + S + "_"
    OP = []
    pt_l,pt_r = None,None
    for i in range(len(S)):
        if S[i] == k:
            if pt_l == None:
                pt_l = i-1
        elif pt_l != None:
            pt_r = i-2
            OP.append((pt_l,pt_r))
            pt_l,pt_r = None,None
    return OP

def merge(burst,k):
    if len(burst) <= k + 1:
        return burst[0][1] - burst[0][0] + 1
    else:
        output = 0
        for i in range(len(burst)-k):
            tmp = burst[k+i][1] - burst[i][0] + 1
            output = max(output,tmp)
        return output

N,K = map(int,input().split())
S = input()

burst1 = burst(S,"1")

if burst1[0][0] != 0:
    burst1 = [(0,0)] + burst1
if burst1[len(burst1)-1][1] != N-1:
    burst1 = burst1 + [(N-1,N-1)]

ans = merge(burst1,K)
print(ans)
Problem p03087 (python)

Fixed submission:
N,Q = map(int,input().split())
S = list(input())
S = ["_"]+S
LR = [tuple(map(int,input().split())) for _ in range(Q)]

C = [0 for _ in range(N+1)]
#C[i]:i文字目までで"AC"が出てくる回数
for i in range(1,N):
    if S[i] == "A" and S[i+1] == "C":
        C[i+1] += 1

for i in range(N):
    C[i+1] += C[i]


for l,r in LR:
    print(C[r]-C[l])

Buggy submission (verdict: Runtime Error):
N,Q = map(int,input().split())
S = list(input())
LR = [tuple(map(int,input().split())) for _ in range(Q)]

C = [0 for _ in range(N+1)]
#C[i]:i文字目までで"AC"が出てくる回数
for i in range(N):
    if S[i] == "A" and S[i+1] == "C":
        C[i+2] += 1

for i in range(N):
    C[i+1] += C[i]

for l,r in LR:
    print(C[r]-C[l])
Problem p03238 (python)

Fixed submission:
#python Programming_Education.py

n = int(input())

if n==1:
	print("Hello World")
else:
	a = int(input())
	b = int(input())

	print(a+b)

Buggy submission (verdict: Runtime Error):
#python D-Partition.py
"""
入力フォーマット
N M

出力:a_1+...+a_N=Mを満たす数列aについてmax(GCD(a_1,...,a_N))
"""
import math
line = list(map(int, input().split(" ")))
N = int(line[0])
M = int(line[1])

#TLE(実行時間制限超過)のコード
"""
for i in range(math.floor(M/N),0,-1):
	tmp = M-i*(N-1)
	if tmp%i==0:
		print(i)
		break
"""

#TLEを何とかしたコード（ポイント：素数判定と同じ要領で探索範囲をO(sqrt(M))にした
for i in range(sqrt(M)):
	tmp = M-(math.floor(M/N)-i)*(N-1)
	if tmp%(math.floor(M/N)-i)==0:
		print((math.floor(M/N)-i))
		break