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

Fixed submission:
N=int(input())
s=0
for i in range(1,N+1):
  if i%2==0:
    s=s
  else:
    s+=1
c=s/N
print(c)

Buggy submission (verdict: Runtime Error):
def main():
  N=int(input())
  s=0
  for i in range(1,N+1):
    if i%2==0:
       s=s
    else:
       s=s+1
print(s/N)
main()

Buggy submission (verdict: Runtime Error):
def main():
  N=int(input())
  s=0
  for i in range(1,N+1):
    if i%2==0:
       s=s
    else:
       s=s+1
print(s/N)
Problem p02933 (python)

Fixed submission:
a=int(input())
s=input()
if 2800<=a<3200:
  print("red")
elif 3200<=a<5000:
  print(s)

Buggy submission (verdict: Runtime Error):
def main()
  a=int(input())
  s=input()
  if 3200<=a<5000:
    print(s)
  elif 2800<=a<3200:
    print("red")
main()
Problem p02935 (python)

Fixed submission:
N=int(input())
v=list(map(int,input().split()))
while len(v)>1:
  v=sorted(v)
  v_1=v.pop(0)
  v_2=v.pop(0)
  v.append((v_1+v_2)/2)
print(v[0])

Buggy submission (verdict: Runtime Error):
N=int(input())
v=list(map(int,input().split()))
while len(v)>1:
  v=v.sort()
  v1=v.pop(0)
  v2=v.pop(0)
  v.append((v1+v2)/2)
print(v[0])

Buggy submission (verdict: Runtime Error):
N=int(input())
v=list(map(int,input().split()))
while len(v)>1:
  v=v.sort()
  v1=v[0]
  del v[0]
  v2=v[0]
  del v[0]
  v.append((v1+v2)/2)
print(v)

Buggy submission (verdict: Runtime Error):
N=int(input())
v=list(map(int,input().split()))
s=v.sort()
s[0]=(s[0]+s[1])/2
for i in range(1,N):
  s[i]=(s[i]+s[i+1])/2
print(sum(s))
Problem p03036 (python)

Fixed submission:
def main():
  r,D,X_2000=map(int,input().split())
  x=[]
  x.append(X_2000)
  for i in range(1,11):
    x.append(r*x[i-1]-D)
    print(x[i])
main()

Buggy submission (verdict: Runtime Error):
def main():
  x=[]
  r,D,X=map(int,input().split())
  x.append(X)
  for i in range(1:11):
    x.append(r*x[i-1]-D)
    print(x[i])
main()

Buggy submission (verdict: Runtime Error):
def main():
  r,D,X_2000=map(int,input().split())
  x=[]
  x.append(X_2000)
  for i in range(1:11):
    x.append(r*x[i-1]-D)
    print(x[i])
main()

Buggy submission (verdict: Runtime Error):
def main():
  r,D,X_2000=map(int,input().split())
  x=[]
  x.append(X_2000)
  for i in range(1:11):
    x[i]=r*x[i-1]-D
    x.append(x[i])
    print(x[i])
main()
Problem p03072 (python)

Fixed submission:
N=int(input())
H=list(map(int,input().split()))
s=1
for i in range(1,N):
  if H[i]>=max(H[0:i]):
    s+=1
print(s)

Buggy submission (verdict: Runtime Error):
N=int(input())
H=list(map(int,input().split()))
s=0
for i in range(N):
  if H[i]>=max(H[0:i]):
    s+=1
print(s)
Problem p03073 (python)

Fixed submission:
S=input()
s=0
t=0
for i in range(len(S)):
  if i%2==0 and S[i]=="0":
    s+=1
  elif i%2!=0 and S[i]=="1":
    s+=1
for j in range(len(S)):
  if j%2==0 and S[j]=="1":
    t+=1
  elif j%2!=0 and S[j]=="0":
    t+=1
print(min(s,t))

Buggy submission (verdict: Runtime Error):
S=input()
s=0
for i in range(len(S)):
  if S[i]==S[i+1]==S[i+2]==0:
    s+=1
    S[i+1]=1
  elif S[i]==S[i+1]==S[i+2]==1:
    s+=1
    S[i+1]==0
  elif S[i]==S[i+1] and S[i+1]!=S[i+2]:
    s+=1
    S[i]=S[i+2]
  elif S[i]!=S[i+1] and S[i+1]==S[i+2]:
    s+=1
    S[i+2]==S[i]
  else:
    s=s
print(s)
Problem p03107 (python)

Fixed submission:
S=input()
N=len(S)
a=S.count('0')
b=S.count('1')
t=min(a,b)
print(2*t)

Buggy submission (verdict: Runtime Error):
i

Buggy submission (verdict: Runtime Error):
S=list(input())
s=0 #取り除いたキューブの数
i=0 
while len(set(S))!=len(S):
  if S[i]==S{i+1]==0 or S{i]==S[i+1]==1:
    s=s
    i+=1
  else:
    s+=2
    del S[i:i+2]
    i=0
print(s)

Buggy submission (verdict: Runtime Error):
S=list(input())
N=len(S)
s=0 #取り除いたキューブの数
i=0 
while len(set(S))!=len(S):
  if S[i]==S{i+1]==0 or S{i]==S[i+1]==1:
    s=s
    i+=1
  else:
    s+=2
    i=0
print(s)

Buggy submission (verdict: Runtime Error):
S=list(input())
s=0
i=0
if S[i]==S[i+1]==0 or S[i]==S[i+1]==1:
  s=s
  i+=1
else:
  s+=2
  del S[i:i+2]
  i=0
print(s)

Buggy submission (verdict: Runtime Error):
S=list(int(input()))
s=0
i=0
if S[i]==S[i+1]==0 or S[i]==S[i+1]==1:
  s=s
  i+=1
else:
  s+=2
  del S[i:i+2]
  i=0
print(s)

Buggy submission (verdict: Runtime Error):
S=list(int(input()))
s=0
i=0
if S[i]==S{i+1]==0 or S[i]==S[i+1]==1:
  s=s
  i+=1
else:
  s+=2
  del S[i:i+2]
  i=0
print(s)

Buggy submission (verdict: Runtime Error):
S=list(input())
N=len(S)
def main():
  ans=0
  i=0
  while len(S)>0 and i<N-1:
    if (S[i]==0 and S[i+1]==1) or (S[i]==1 and S[i+1]==0):
      S=S.remove(S[i:i+2])
      ans+=1
      i=0
    else:
      ans=ans
      i+=1
  print(ans)
main()

Buggy submission (verdict: Runtime Error):
S=list(input())
N=len(S)
def main():
  ans=0
  i=0
  while len(S)>0 :
    if (S[i]==0 and S[i+1]==1) or (S[i]==1 and S[i+1]==0):
      S.remove(S[i:i+2])
      ans+=1
    else:
      ans=ans
      i+=1
  print(ans)
main()

Buggy submission (verdict: Runtime Error):
S=list(input())
N=len(S)
ans=0
i=0
while len(S)>0:
  if S[i]==0 and S[i+1]==1 or S[i]==1 and S[i+1]==0:
    S.remove(S[i:i+2])
    ans+=1
  else:
    ans=ans
    i+=1
print(ans)
Problem p03208 (python)

Fixed submission:
N,K=map(int,input().split())
h=list(int(input()) for i in range(N))
h=sorted(h)
t=[]
for i in range(N-K+1):
  s=h[i+K-1]-h[i]
  t.append(s)
print(min(t))

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
h=[int(input()) for i in range(N)]
h=sorted(h)
t=[]
for i in range(N-K+1):
  s=h[i+k-1]-h[i]
  t.append(s)
print(min(t))
Problem p03012 (python)

Fixed submission:
num = int(input())
weight_list = [int(i) for i in input().split(" ")]
ans_condinate = []
for i in range(num):
    ans_condinate.append(abs(sum(weight_list[:i + 1]) - sum(weight_list[i + 1:])))
print(min(ans_condinate))

Buggy submission (verdict: Runtime Error):
num = int(input())
weight_list = [int(i) for i in input().split(" ")]
ans_condinate = []
for i in range(num):
    ans_condinate.append(abs(sum(weight_list[:i + 1]) - sum(weight_list[i + 1:])))
print(min(ans_condinate))
a
Problem p03013 (python)

Fixed submission:
from math import floor  
stairs_num, broken_num = tuple(int(i) for i in input().split(" "))
broken_list = []
for i in range(broken_num):
    broken_list.append(int(input()))
trance_num_list = []
if len(broken_list) >= 1 and broken_list[0] == 1:
    trance_num_list.append(0)
else:
    trance_num_list.append(1)
if (len(broken_list) >= 1 and broken_list[0] == 2) or \
 (len(broken_list) >= 2 and broken_list[1] == 2):
    trance_num_list.append(0)
else:
    if trance_num_list[0] == 0:
        trance_num_list.append(1)
    else:
        trance_num_list.append(2)
if stairs_num > 2:
    a = len(broken_list)
    for i in range(stairs_num - 2):
        key = 0
        left = 0
        right = a
        while left < right:
            midle = floor((left + right) / 2)
            if broken_list[midle] < i + 3:
                left = midle + 1
            elif broken_list[midle] == i + 3:
                key = 1
                break
            else:
                right = midle
        if key:
            trance_num_list.append(0)
        else:
            trance_num_list.\
             append((trance_num_list[-1] + trance_num_list[-2]) % 1000000007)
print(trance_num_list[stairs_num - 1])

Buggy submission (verdict: Runtime Error):
from math import floor  
stairs_num, broken_num = tuple(int(i) for i in input().split(" "))
broken_list = []
for i in range(broken_num):
    broken_list.append(int(input()))
trance_num_list = []
if len(broken_list) >= 1 and broken_list[0] == 1:
    trance_num_list.append(0)
else:
    trance_num_list.append(1)
if (len(broken_list) >= 1 and broken_list[0] == 2) or \
 (len(broken_list) >= 2 and broken_list[1] == 2):
    trance_num_list.append(0)
else:
    if trance_num_list[0] == 0:
        trance_num_list.append(1)
    else:
        trance_num_list.append(2)
if stairs_num > 2:
    a = len(broken_list)
    for i in range(stairs_num - 2):
        key = 0
        left = 0
        right = a
        while left < right:
            midle = floor(left + right)
            if broken_list[midle] < i + 3:
                left = midle + 1
            elif broken_list[midle] == i + 3:
                key = 1
                break
            else:
                right = midle - 1
        if key:
            trance_num_list.append(0)
        else:
            trance_num_list.\
             append((trance_num_list[-1] + trance_num_list[-2]) % 1000000007)
print(trance_num_list[stairs_num - 1])
Problem p03038 (python)

Fixed submission:
def index_1_sumall(list):
    return list[1]


n, m = tuple(int(i) for i in input().split(" "))
num_list = [int(i) for i in input().split(" ")]
num_list.sort()
change_list = []
ans_list = []
for j in range(m):
    change_list.append([int(i) for i in input().split(" ")])
change_list.sort(key=index_1_sumall, reverse=1)
break_is = 0
for i in change_list:
    for j in range(i[0]):
        try:
            if i[1] > num_list[0]:
                num_list.pop(0)
                ans_list.append(i[1])
            else:
                break_is = 1
                break
        except IndexError:
            break_is = 1
            break
    if break_is:
        break
num_list.append(0)
print(sum(num_list) + sum(ans_list))

Buggy submission (verdict: Runtime Error):
def index_1_sumall(list):
    return list[1]


n, m = tuple(int(i) for i in input().split(" "))
num_list = [int(i) for i in input().split(" ")]
num_list.sort()
change_list = []
ans_list = []
for j in range(m):
    change_list.append([int(i) for i in input().split(" ")])
change_list.sort(key=index_1_sumall, reverse=1)
break_is = 0
for i in change_list:
    for j in range(i[0]):
        try:
            if i[1] > num_list[0]:
            num_list.pop(0)
            ans_list.append(i[1])
            else:
                break_is = 1
                break
        except IndexError:
            break_is = 1
            break
    if break_is:
        break
num_list.append(0)
print(sum(num_list) + sum(ans_list))

Buggy submission (verdict: Runtime Error):
def index_1_sumall(list):
    return list[1]


n, m = tuple(int(i) for i in input().split(" "))
num_list = [int(i) for i in input().split(" ")]
num_list.sort()
change_list = []
ans_list = []
for j in range(m):
    change_list.append([int(i) for i in input().split(" ")])
change_list.sort(key=index_1_sumall, reverse=1)
break_is = 0
for i in change_list:
    for j in range(i[0]):
        if i[1] > num_list[0]:
            num_list.pop(0)
            ans_list.append(i[1])
        else:
            break_is = 1
            break
    if break_is:
        break
num_list.append(0)
print(sum(num_list) + sum(ans_list))
Problem p02578 (python)

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

s = 0
now = As[0]
for a in As:
    if a<now:
        s += now - a
    else:
        now = a
        
print(s)

Buggy submission (verdict: Runtime Error):
s = 0
now = As[0]
for a in As:
    if a<now:
        s += now - a
    else:
        now = a
        
print(s)
Problem p02891 (python)

Fixed submission:
S = input()
K = int(input())

s_list = list(S)

modified = "mdf"

def solve():
    # その単語に1種類の文字しかなければ、合計の文字数を2で割捨てした数
    if len(set(s_list)) == 1:
        return (len(s_list)*K)//2
    
    cnt = 1
    cnt_list = []
    for i in range(len(s_list)-1):
        if s_list[i] == s_list[i+1]:
            cnt += 1
        else:
            cnt_list.append(cnt)
            cnt = 1
    
    # 最後の対応
    # cnt = 1の時、最後は1文字だけ
    # cnt >= 2の時、最後は同じ文字が続いてる
    cnt_list.append(cnt)
    
    # 最初と最後が同じ時は最初と最後を足したやつを作る必要。
    head = cnt_list[0]
    tail = cnt_list[-1]
    body = cnt_list[1:-1]
    
    def body_change_cnt(body):
        cnt = 0
        for b in body:
            cnt += b//2
        return cnt
    
    if s_list[0] == s_list[-1]:
        head_tail = cnt_list[0] + cnt_list[-1]
        return head//2 + tail//2 + body_change_cnt(body)*K + (head_tail//2)*(K-1)
    else:
        return (head//2 + tail//2 + body_change_cnt(body)) * K

result = solve()

print(result)

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

s_list = list(S)

modified = "mdf"

def solve():
    # その単語に1種類の文字しかなければ、合計の文字数を2で割捨てした数
    if len(set(s_list)) == 1:
        return (len(s_list * K))//2
    
    cnt = 1
    cnt_list = []
    for i in range(len(S)-1):
        if s_list[i] == s_list[i+1]:
            cnt += 1
        else:
            cnt_list.append(cnt)
            cnt = 1
    
    # 最後の対応
    # cnt = 1の時、最後は1文字だけ
    # cnt >= 2の時、最後は同じ文字が続いてる
    cnt_list.append(cnt)
    
    # 最初と最後が同じ時は最初と最後を足したやつを作る必要。
    head = cnt_list[0]
    tail = cnt_list[-1]
    body = cnt_list[1:-1]
    
    if s_list[0] == s_list[-1]:
        head_tail = cnt_list[0] + cnt_list[-1]
        return head//2 + tail//2 + (sum(body)//2)*K + (head_tail//2)*(K-1)
    else:
        return (head//2 + tail//2 + sum(body)//2) * K

result = solve()

print(result)
Problem p03013 (python)

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

# memo = [-1 for _ in range(n)]
step_now = 0
step_1   = 0
step_2   = 0
DIV_NUM = 1000000007
if 1 in a_list:
    a_list.pop(0)
    step_now = 0
else:
    step_now = 1
for i in range(1, n):
    if i == 1:
        step_1 = step_now
        if i+1 in a_list:
            a_list.pop(0)
            step_now = 0
        else:
#             memo[i] = (memo[0] + 1) % DIV_NUM
            step_now = step_1 + 1
    else:
        step_2 = step_1
        step_1 = step_now
        if i+1 in a_list:
            a_list.pop(0)
            step_now = 0
        else:
#             memo[i] = (memo[i-1] + memo[i-2]) % DIV_NUM
            step_now = (step_1 + step_2) % DIV_NUM
    if step_now ==  step_1 == step_2 == 0:
        break

print(step_now)

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

# memo = [-1 for _ in range(n)]
step_now = 0
step_1   = 0
step_2   = 0
DIV_NUM = 1000000007
if 1 in a_list:
    a_list = a_list.pop(0)
    step_now = 0
else:
    step_now = 1
for i in range(1, n):
    if i == 1:
        step_1 = step_now
        if i+1 in a_list:
            a_list = a_list.pop(0)
            step_now = 0
        else:
#             memo[i] = (memo[0] + 1) % DIV_NUM
            step_now = step_1 + 1
    else:
        step_2 = step_1
        step_1 = step_now
        if i+1 in a_list:
            a_list = a_list.pop(0)
            step_now = 0
        else:
#             memo[i] = (memo[i-1] + memo[i-2]) % DIV_NUM
            step_now = (step_1 + step_2) % DIV_NUM
    if step_now ==  step_1 == step_2 == 0:
        break

print(step_now)

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

# memo = [-1 for _ in range(n)]
step_now = 0
step_1   = 0
step_2   = 0
DIV_NUM = 1000000007
if 1 in a_list:
    a_list = alist.pop(0)
    step_now = 0
else:
    step_now = 1
for i in range(1, n):
    if i == 1:
        step_1 = step_now
        if i+1 in a_list:
            a_list = alist.pop(0)
            step_now = 0
        else:
#             memo[i] = (memo[0] + 1) % DIV_NUM
            step_now = step_1 + 1
    else:
        step_2 = step_1
        step_1 = step_now
        if i+1 in a_list:
            a_list = alist.pop(0)
            step_now = 0
        else:
#             memo[i] = (memo[i-1] + memo[i-2]) % DIV_NUM
            step_now = (step_1 + step_2) % DIV_NUM
    if step_now ==  step_1 == step_2 == 0:
        break

print(step_now)
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())

print(4 + math.ceil(N/min(A,B,C,D,E)))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

print(4 + math.ceil(N/min(A,B,C,D,E)))
Problem p02711 (python)

Fixed submission:
N=str(input())
print("Yes" if N[0]=="7" or N[1]=="7" or N[2]=="7" else "No")

Buggy submission (verdict: Runtime Error):
N=int(input())
print("Yes" if N[0]==7 or N[1]==7 or N[2]==7 else "No")
Problem p02859 (python)

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

Buggy submission (verdict: Runtime Error):
a=int(input())
S=input()
if a%2 != 0:
  print("No")
else:
  b=0
  while	b<=a//2-1:
        S[b]==S[a//2+b]
        b=b+1
  if b==a//2:
    print("Yes")
  else:
    print("No")
Problem p02625 (python)

Fixed submission:
MOD=10**9+7
N, M = map(int, input().split())

FCT = [1]
for i in range(1, M+1):
    FCT.append((FCT[-1] * i)%MOD)

def pmu(n, r, mod=MOD):
    return (FCT[n] * pow(FCT[n-r], mod-2, mod)) % mod

def cmb(n, r, mod=MOD):
    return (pmu(n, r) * pow(FCT[r], mod-2, mod)) % mod

def solve():
    # {the num of case B when A=range(1,N+1)} x {permutation of A}
    # use inclusion-exclusion principle against former
    ans = 0
    for i in range(N+1):
        cp = (cmb(N, i) * pmu(M-i, N-i))%MOD
        ans = (ans + (1 if i%2==0 else -1) * cp) % MOD
    return (ans * pmu(M, N)) % MOD

if __name__ == "__main__":
    print(solve())

Buggy submission (verdict: Runtime Error):
import sys
from functools import lru_cache
sys.setrecursionlimit(10**7)
MOD=10**9+7
N, M = map(int, input().split())

@lru_cache(maxsize=None)
def fct(n, mod=MOD):
    return (n * fct(n-1)) % MOD if n != 0 else 1

@lru_cache(maxsize=None)
def pmu(n, r, mod=MOD):
    return (fct(n) * pow(fct(n-r), mod-2, mod)) % mod

@lru_cache(maxsize=None)
def cmb(n, r, mod=MOD):
    return (pmu(n, r) * pow(fct(r), mod-2, mod)) % mod

def solve():
    # {the num of case B when A=range(1,N+1)} x {permutation of A}
    # use inclusion-exclusion principle against former
    ans = 0
    for i in range(N+1):
        cp = cmb(N, i) * pmu(M-i, N-i)
        ans = (ans + (1 if i%2==0 else -1) * cp) % MOD
    return (ans * pmu(M, N)) % MOD

if __name__ == "__main__":
    print(solve())

Buggy submission (verdict: Runtime Error):
import sys
from functools import lru_cache
sys.setrecursionlimit(10**7)
MOD=10**9+7
N, M = map(int, input().split())

@lru_cache(maxsize=None)
def fct(n, mod=MOD):
    return (n * fct(n-1)) % MOD if n != 0 else 1

# @lru_cache(maxsize=None)
def pmu(n, r, mod=MOD):
    return (fct(n) * pow(fct(n-r), mod-2, mod)) % mod

# @lru_cache(maxsize=None)
def cmb(n, r, mod=MOD):
    return (pmu(n, r) * pow(fct(r), mod-2, mod)) % mod

def solve():
    # {the num of case B when A=range(1,N+1)} x {permutation of A}
    # use inclusion-exclusion principle against former
    ans = 0
    for i in range(N+1):
        cp = cmb(N, i) * pmu(M-i, N-i)
        ans = (ans + (1 if i%2==0 else -1) * cp) % MOD
    return (ans * pmu(M, N)) % MOD

if __name__ == "__main__":
    print(solve())
Problem p02851 (python)

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * (N+1)
for i, a in enumerate(A):
    B[i+1] = B[i] + a%K
for i in range(N+1):
    B[i] -= i
    B[i] %= K
ans = 0
# compress
C = B[::]
C.sort()
I = dict()
itmp = 0
I[C[0]] = 0
for i in range(1, N+1):
    if C[i] != C[i-1]:
        itmp += 1
        I[C[i]] = itmp

tbl = [0] * (N+1)
for i in range(min(K,N+1)):
    tbl[I[B[i]]] += 1
    ans += tbl[I[B[i]]] - 1
for i in range(K, N+1):
    tbl[I[B[i-K]]] -= 1
    tbl[I[B[i]]] += 1
    ans += tbl[I[B[i]]] - 1
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * (N+1)
for i, a in enumerate(A):
    B[i+1] = B[i] + a%K
for i in range(N+1):
    B[i] -= i
    B[i] %= K
ans = 0
# compress
C = B.copy()
C.sort()
I = dict()
itmp = 0
I[C[0]] = 0
for i in range(1, N+1):
    if C[i] != C[i-1]:
        itmp += 1
        I[C[i]] = itmp

tbl = [0] * (N+1)
for i in range(min(K,N+1)):
    tbl[I[B[i]]] += 1
    ans += tbl[I[B[i]]] - 1
for i in range(K, N+1):
    tbl[I[B[i-K]]] -= 1
    tbl[I[B[i]]] += 1
    ans += tbl[I[B[i]]] - 1
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * (N+1)
for i, a in enumerate(A):
    B[i+1] = B[i] + a%K
for i in range(N+1):
    B[i] -= i
    B[i] %= K
ans = 0
tbl = [0] * K
for i in range(min(K,N+1)):
    tbl[B[i]] += 1
    ans += tbl[B[i]] - 1
for i in range(K, N+1):
    tbl[B[i-K]] -= 1
    tbl[B[i]] += 1
    ans += tbl[B[i]] - 1
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * (N+1)
for i, a in enumerate(A):
    B[i+1] = B[i] + a%K
for i in range(N+1):
    B[i] -= i
    B[i] %= K
ans = 0
tbl = [0] * K
for i in range(K):
    tbl[B[i]] += 1
    ans += tbl[B[i]] - 1
for i in range(K, N+1):
    tbl[B[i-K]] -= 1
    tbl[B[i]] += 1
    ans += tbl[B[i]] - 1
print(ans)
Problem p02987 (python)

Fixed submission:
S = input()

print('Yes' if all(S.count(s) == 2 for s in S) else 'No')

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

print('Yes' if all(S.count(s) == 2 for s in input()) else 'No')
Problem p03013 (python)

Fixed submission:
import sys
N, M = map(int, input().split())
MOD = 10 ** 9 + 7

NG = [False for _ in range(N+1)]
for _ in range(M):
    NG[int(input())] = True

dp = [None for _ in range(N+1)]
dp[0] = 1
dp[1] = 0 if NG[1] else 1
for i in range(2, N+1):
    if NG[i]:
        dp[i] = 0
    else:
        dp[i] = (dp[i-2] + dp[i-1]) % MOD

print(dp[-1])

Buggy submission (verdict: Runtime Error):
import sys
from bisect import bisect_left
N, M = map(int, input().split())
MOD = 10 ** 9 + 7
NMAX = 10 ** 5

A = []
for _ in range(M):
    A.append(int(input()))

dp = [None for _ in range(N+1)]
dp[0] = 1
dp[1] = 0 if A[0] == 1 else 1
for i in range(2, N+1):
    if i in A:
        dp[i] = 0
    else:
        dp[i] = (dp[i-2] + dp[i-1]) % MOD

print(dp[-1])

Buggy submission (verdict: Runtime Error):
import sys
N, M = map(int, input().split())
MOD = 10 ** 9 + 7
NMAX = 10 ** 5
sys.setrecursionlimit(10 ** 6)

memo = [None for _ in range(NMAX+1)]
def fibo(n):
    if memo[n]:
        return memo[n]
    if n == 0:
        return 0
    elif n < 3:
        return 1
    else:
        return fibo(n-1) + fibo(n-2)

nc = 1
b = 0
for i in range(M):
    a = int(input())
    nc = (nc * fibo(a - b)) % MOD
    b = a + 1

nc = (nc * fibo(N + 1 - b)) % MOD

print(nc)

Buggy submission (verdict: Runtime Error):
import sys
N, M = map(int, input().split())
MOD = 10 ** 9 + 7
NMAX = 10 ** 5
sys.setrecursionlimit(NMAX+1)

memo = [None for _ in range(NMAX+1)]
def fibo(n):
    if memo[n]:
        return memo[n]
    if n == 0:
        return 0
    elif n < 3:
        return 1
    else:
        return fibo(n-1) + fibo(n-2)

nc = 1
b = 0
for i in range(M):
    a = int(input())
    nc = (nc * fibo(a - b)) % MOD
    b = a + 1

nc = (nc * fibo(N + 1 - b)) % MOD

print(nc)