Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a

Fixed submission:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=998244353
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,m,k=map(int,input().split())

# MOD combination
def cmb(n, r, mod=998244353):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

N = 10**5*2+100
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ans=m*pow(m-1,n-1,mod)
ans%=mod
# print(ans)
for i in range(k):
    tmp=cmb(n-1,i+1)*m*pow(m-1,n-(i+2),mod)
    # print(cmb(n-1,i+1),m,pow(m-1,n-(i+1),mod))
    # print(tmp)
    tmp%=mod
    ans+=tmp
    ans%=mod
    # print(ans,tmp)
print(ans)
Buggy python submission (verdict: Runtime Error):
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,m=map(int,input().split())
if n%2==1:
    half=n//2
    if i%2==0:
            print(*[half-i//2,half+i//2+1])
        else:
            print(*[1+i//2,n-1+i//2])
    quit()
else:
    half=n//2
    for i in range(m-1):
        print(*[half-i,half+i+1])
    if n==4:
        print(*[2,3])
    else:
        print(*[1,n-1])

Fixed submission:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,m=map(int,input().split())
half=n//2
lst=[]
tmp=0
if n%2==0:
    tmp=1
for i in range(m):
    if i%2==1:
        lst.append([half-i//2,half+i//2+2])
    else:
        lst.append([1+i//2,n-i//2])

for i in range(m):
    print(*lst[i])

# dic=defaultdict(int)
# for i in range(m):
#     tmp=lst[i]
#     dic[tmp[1]-tmp[0]]+=1
#     dic[n-tmp[1]+tmp[0]]+=1
# print(dic)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

s=input()
len_s=len(s)
dic=defaultdict(int)
ans=0
for i in range(len_s):
    if 2019-int(s[i]) in dic:
        ans+=dic[2019-int(s[i])]
    newdic=defaultdict(int)
    for j in dic.keys():
        newdic[(j*10+int(s[i])*10)%2019]+=dic[j]
    dic=newdic
    dic[int(s[i])*10]+=1
    # print(dic)
print(ans)

Fixed submission:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

s=input()
len_s=len(s)
lst=[0]
dic=defaultdict(int)
dic[0]=1
ten=1
for i in range(len_s):
    lst.append((lst[i]+int(s[-i-1])*pow(10,i,2019))%2019)
    # ten=ten*10%2019
    dic[lst[-1]]+=1
# print(lst)
# print(dic)
ans=0
for i in dic.values():
    ans+=i*(i-1)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,m,s=map(int,input().split())
uvab=[list(map(int,input().split())) for i in range(m)]
cd=[list(map(int,input().split())) for i in range(n)]

def dijkstra(s,n):
    hq = [(0, s)]
    heapq.heapify(hq) # リストを優先度付きキューに変換
    cost = [float('inf')] * n # 行ったことのないところはinf
    cost[s] = 0 # 開始地点は0
    while hq:
        c, v = heapq.heappop(hq)
        if c > cost[v]: # コストが現在のコストよりも高ければスルー
            continue
        for d, u in e[v]:
            tmp = d + cost[v]
            if tmp < cost[u]:
                cost[u] = tmp
                heapq.heappush(hq, (tmp, u))
    return cost


e = [[] for _ in range(1000*(n+1))]
for i in range(n):
    c,d=cd[i]
    for j in range(250):
        e[1000*i+j].append((d,1000*i+min(j+c,250)))
    
for i in range(m):
    u,v,a,b=uvab[i]
    u,v = u-1, v-1
    for j in range(250):
        if j-a>=0:
            e[1000*v+j].append((b,1000*u+j-a))
            e[1000*u+j].append((b,1000*v+j-a))
# print(e)
lst=dijkstra(s,1000*(n+1))
# print(lst)
for i in range(1,n):
    ans=float('inf')
    for j in range(250):
        ans=min(ans,lst[1000*i+j])
    print(ans)

Fixed submission:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,m,s=map(int,input().split())
uvab=[list(map(int,input().split())) for i in range(m)]
cd=[list(map(int,input().split())) for i in range(n)]

def dijkstra(s,n):
    hq = [(0, s)]
    heapq.heapify(hq) # リストを優先度付きキューに変換
    cost = [float('inf')] * n # 行ったことのないところはinf
    cost[s] = 0 # 開始地点は0
    while hq:
        c, v = heapq.heappop(hq)
        if c > cost[v]: # コストが現在のコストよりも高ければスルー
            continue
        for d, u in e[v]:
            tmp = d + cost[v]
            if tmp < cost[u]:
                cost[u] = tmp
                heapq.heappush(hq, (tmp, u))
    return cost


e = [[] for _ in range(10000*(n+1))]
for i in range(n):
    c,d=cd[i]
    for j in range(2500):
        e[10000*i+j].append((d,10000*i+min(j+c,2500)))
    
for i in range(m):
    u,v,a,b=uvab[i]
    u,v = u-1, v-1
    for j in range(2500):
        if j-a>=0:
            e[10000*v+j].append((b,10000*u+j-a))
            e[10000*u+j].append((b,10000*v+j-a))
# print(e)
s=min(2499,s)
# print(s)
lst=dijkstra(s,10000*(n+1))
# print(lst)
for i in range(1,n):
    ans=float('inf')
    for j in range(2500):
        ans=min(ans,lst[10000*i+j])
    print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
from collections import *
import heapq
import math
from math import gcd
import bisect
import copy
from itertools import permutations,accumulate,combinations,product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
s=input()
dic={}
for i in range(n):
    if not s[i] in dic:
        dic[s[i]]=[i]
    else:
        dic[s[i]].append(i)
# print(dic)
se=set(dic["B"])
# print(se)
ans=len(dic["R"])*len(dic["G"])*len(dic["B"])
for i in range(len(dic["R"])):
    for j in range(len(dic["G"])):
        l,r=min(dic["R"][i],dic["G"][j]),max(dic["R"][i],dic["G"][j])
        if r+(r-l) in se:
            ans-=1
        if l-(r-l) in se:
            ans-=1
        if (r-l)%2==0 and l+(r-l)//2 in se:
            ans-=1
print(ans)

Fixed submission:
import sys
from collections import *
import heapq
import math
from math import gcd
import bisect
import copy
from itertools import permutations,accumulate,combinations,product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
s=input()
dic={"R":[],"G":[],"B":[]}
for i in range(n):
    if not s[i] in dic:
        dic[s[i]]=[i]
    else:
        dic[s[i]].append(i)
# print(dic)
se=set(dic["B"])
# print(se)
ans=len(dic["R"])*len(dic["G"])*len(dic["B"])
for i in range(len(dic["R"])):
    for j in range(len(dic["G"])):
        l,r=min(dic["R"][i],dic["G"][j]),max(dic["R"][i],dic["G"][j])
        if r+(r-l) in se:
            ans-=1
        if l-(r-l) in se:
            ans-=1
        if (r-l)%2==0 and l+(r-l)//2 in se:
            ans-=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

a,b=map(int,input().split())
ans=1
while ans*8//100!=a or ans//10!=b:
    ans+=1
print(ans)

Fixed submission:
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7

a,b=map(int,input().split())

for i in range(100000):
    tmp=int(i*0.08)
    tmp2=int(i*0.1)
    if a==tmp and b==tmp2:
        print(i)
        break
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
# スペース区切りの整数の入力
b, c = map(int, input().split())
# 文字列の入力
s = input()
# 出力
print("{} {}".format(a+b+c, s))
import fractions
fractions.gcd(a,b)


Fixed submission:
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7

h,a=map(int,input().split())
print((h+a-1)//a)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7

h,n=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]
dp=[[float('inf')]*(h+1) for i in range(n+1)]
dp[0][0]=0
# print(dp)
for i in range(n):
    for j in range(h+1):
        dp[i+1][j]=min(dp[i][j],dp[i+1][j])
        tmp=j+ab[i][0]
        if j+ab[i][0]>h:
            tmp=h
        # print(min(dp[i][j]+ab[i][1],dp[i+1][tmp]))
        dp[i+1][tmp]=min(dp[i+1][j]+ab[i][1],dp[i+1][tmp])
        # print(dp[i+1][tmp])
# print(dp)
print(dp[-1][-1])

Fixed submission:
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7

h,n=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]
dp=[[float('inf')]*(h+1) for i in range(n+1)]
dp[0][0]=0
# print(dp)
for i in range(n):
    for j in range(h+1):
        dp[i+1][j]=min(dp[i][j],dp[i+1][j])
        tmp=j+ab[i][0]
        if j+ab[i][0]>h:
            tmp=h
        # print(min(dp[i][j]+ab[i][1],dp[i+1][tmp]))
        dp[i+1][tmp]=min(dp[i+1][j]+ab[i][1],dp[i+1][tmp])
        # print(dp[i+1][tmp])
# print(dp)
print(dp[-1][-1])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7

n,d,a=map(int,input().split())
xh=[list(map(int,input().split())) for i in range(n)]
xh.sort()

x=[xh[i][0] for i in range(n)]
lst=[]
for i in range(n):
    lst.append([i,bisect.bisect(x,x[i]+2*d)])
# print(lst)

ans=0
for i in range(n):
    if xh[i][1]>0:
        cnt=math.ceil(xh[i][1]/a)
        ans+=cnt
        for j in range(lst[i][0],lst[i][1]):
            xh[j][1]-=cnt*a
        # print(cnt,ans)
        # print(xh)
print(ans)

Fixed submission:
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7

n,d,a=map(int,input().split())
xh=[list(map(int,input().split())) for i in range(n)]
xh.sort()
r,tama=[],[0]

for i in range(n):
    x,h=xh[i]
    tmpr=bisect.bisect_left(r,x)
    h-=(tama[-1]-tama[tmpr])*a
    tmp=0
    if h>0:
        tmp=math.ceil(h/a)
    tama.append(tmp)
    tama[i+1]+=tama[i]
    r.append(x+2*d)

print(tama[-1])
# print(r)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7

n,d,a=map(int,input().split())
xh=[list(map(int,input().split())) for i in range(n)]
xh.sort()
ans=0
while xh:
    tmp=xh.pop()
    # print(tmp)
    if tmp[1]<=0:
        continue
    zahyo=tmp[0]-d*2
    kaisu=math.ceil(tmp[1]/a)
    ans+=kaisu
    # print(zahyo,kaisu)
    for i in range(len(xh)):
        if xh[-1-i][0]>=zahyo:
            xh[-1-i][1]-=kaisu*a
        else:
            break
print(ans)

Fixed submission:
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7

n,d,a=map(int,input().split())
xh=[list(map(int,input().split())) for i in range(n)]
xh.sort()
r,tama=[],[0]

for i in range(n):
    x,h=xh[i]
    tmpr=bisect.bisect_left(r,x)
    h-=(tama[-1]-tama[tmpr])*a
    tmp=0
    if h>0:
        tmp=math.ceil(h/a)
    tama.append(tmp)
    tama[i+1]+=tama[i]
    r.append(x+2*d)

print(tama[-1])
# print(r)
Buggy python submission (verdict: Runtime Error):
import sys
import fractions
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7


ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])

cnt=0
b=[ans//a[i] for i in range(n)]
print(sum(b)%mod)

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]
n,m=map(int,input().split())
if n==m:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
import sys
import fractions
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7


ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])

cnt=0
b=[ans//a[i] for i in range(n)]
print(sum(b)%mod)


Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]
n,m=map(int,input().split())
if n==m:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import sys
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7
n=int(input())
xl=[list(map(int,input().split())) for i in range(n)]
ans=0
xl.sort()
if xl[0][0]+xl[0][1]>xl[1][0]-xl[1][1]:
    xl[1][0]=-1
    ans+=1

for i in range(1,n-1):
    if xl[i][0]==-1:
        continue
    else:
        if xl[i][0]+xl[i][1]>xl[i+1][0]-xl[i+1][1]:
            ans+=1
            xl[i+1][0]=-1
# print(xl)
print(n-ans)

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7
n=int(input())
xl=[list(map(int,input().split())) for i in range(n)]
from collections import deque
# for i in range(n):
#     right.append(xl[i][0]+xl[i][1])
#     left.append(xl[i][0]-xl[i][1])
ans=0
xl.sort()
# right.sort()
# left.sort()
d=deque(xl)
while d:
    tmp=d.popleft()
    while d:
        if tmp[0]+tmp[1]>d[0][0]-d[0][1]:
            ans+=1
            if tmp[0]+tmp[1]>d[0][0]+d[0][1]:
                # d.popleft()
                break
            elif tmp[0]-tmp[1]>d[0][0]-d[0][1]:
                d.popleft()
            else:
                d.popleft()
        else:
            break
if n==1:
    print(1)
    quit()

print(n-ans)
Buggy python submission (verdict: Runtime Error):
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
# from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
xy=[list(map(int,input().split())) for i in range(n)]

mi,ma=0,2000
com=list(combinations(range(n),2))

while ma-mi>10**(-9):
    half=(ma+mi)/2
    # print(ma,mi,half)
    lst=[]
    flag=1
    for co in com:
        a,b=co
        ax,ay=xy[a]
        bx,by=xy[b]
        kyori=((ax-bx)**2+(ay-by)**2)**0.5
        if kyori/2>half:
            mi=half
            break
        else:
            h=((kyori/2)**2-half**2)**0.5
            tyuuten=((ax+bx)/2,(ay+by)/2)
            tmp=h/2/kyori
            lst.append((tyuuten[0]+(ay-by)*tmp,tyuuten[1]-(ax-bx)*tmp))
            lst.append((tyuuten[0]-(ay-by)*tmp,tyuuten[1]+(ax-bx)*tmp))
            # print(((lst[-1][0]-ax)**2+(lst[-1][1]-ay)**2)**0.5,half)
    else:
        for co in lst:
            bx,by=co
            for i in range(n):
                ax,ay=xy[i]
                if (ax-bx)**2+(ay-by)**2+0.00000001>half**2:
                    break
            else:
                ma=half
                break
        else:
            mi=half
print(ma)

Fixed submission:
import math
N=int(input())
x=[0 for i in range(N)]
y=[0 for i in range(N)]
p=[]
for i in range(N):
    x[i],y[i]=map(int,input().split())
    p.append((x[i],y[i]))
def dist(p,q):
    a,b=p
    c,d=q
    return math.sqrt((a-c)**2+(b-d)**2)
def check(R):
    Q=[]
    for i in range(N):
        for j in range(i+1,N):
            d=dist(p[i],p[j])/2
            if R<d:
                return False
            h=math.sqrt(R*R-d*d)
            #print(d,h,R)
            nx,ny=(x[j]-x[i],y[j]-y[i])
            nr=math.sqrt(nx**2+ny**2)
            dx,dy=h*nx/nr,h*ny/nr
            mx,my=(x[i]+x[j])/2,(y[i]+y[j])/2
            #print(mx,my)
            #print(dx,dy)
            Q.append((mx+dy,my-dx))
            Q.append((mx-dy,my+dx))
    #print(Q,R)
    for pa in Q:
        flag=1
        for i in range(N):
            #print(pa,i,dist(pa,p[i]),R)
            if dist(pa,p[i])>R+9e-7:
                flag=0
                break
        if flag==1:
            return True
    return False

low=0
high=2000
for line in range(50):
    mid=(low+high)/2
    if check(mid):
        high=mid
    else:
        low=mid
print(mid)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))
keta=[0]*60
for i in range(n):
    for j in range(60):
        if (a[i]>>j)&1==1:
            keta[j]+=1

s=sum(a)
ans=0
for i in range(n):
    s-=a[i]
    j=0
    tmp2=a[i]
    while tmp2!=0:
        if tmp2%2==1:
            keta[j]-=1
            ans+=(2**j)*((n-(i+1)-keta[j]*2))
        j+=1
        tmp2=tmp2//2
    ans+=s
    ans%=mod
    # print(ans,s)
    # print(keta)
print(ans%mod)

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))
keta=[0]*60
lis=[]
for i in range(n):
    tmp=[]
    for j in range(60):
        if (a[i]>>j)&1==1:
            keta[j]+=1
            tmp.append(j)
    lis.append(tmp)

s=sum(a)
ans=0
for i in range(n):
    s-=a[i]
    j=0

    for j in range(len(lis[i])):
        tmp2=lis[i][j]
        keta[tmp2]-=1
        ans+=(2**tmp2)*((n-(i+1)-keta[tmp2]*2))
    ans+=s
    ans%=mod
print(ans%mod)
Buggy python submission (verdict: Runtime Error):
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,k=map(int,input().split())
a=list(map(int,input().split()))
# amari=[a[i]%k for i in range(n)]
rui=ruiseki(a)
# print(a)
# print(amari)
# print(rui)
dic=defaultdict(int)
ans=0
for i in range(n+1):
    if i>=k:
        dic[(rui[i-k]-(i-k))%k]-=1
    ans+=dic[(rui[i]-i)%k]
    dic[(rui[i]-i)%k]+=1
    # print(dic)
print(ans)

Fixed submission:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product

def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,k=map(int,input().split())
a=list(map(int,input().split()))
# amari=[a[i]%k for i in range(n)]
rui=ruiseki(a)
# print(a)
# print(amari)
# print(rui)
dic=defaultdict(int)
ans=0
for i in range(n+1):
    if i>=k:
        dic[(rui[i-k]-(i-k))%k]-=1
    ans+=dic[(rui[i]-i)%k]
    dic[(rui[i]-i)%k]+=1
    # print(dic)
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
def input():
    return sys.stdin.readline()[:-1]
n,m=map(int,input().split())
s=input()
co=[[0,0] for i in range(n)]
tmp=0
for i in range(m):
    if s[i+1]=="0":
        tmp=i+1
# print(tmp)
li=[]
for i in range(n+1):
    li.append(tmp)
    a=i+1+m
    if a>n:
        a=n
    if s[a]=="0":
        tmp=a
# print(li)
i=0
while(li[i]!=i):
    print(li[i]-i)
    i=li[i]
    if i==n:
        quit()
print(-1)

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]

n,m=map(int,input().split())
s=input()
if m>n:
    m=n
tmp=-1
for i in range(m):
    if s[-i-2]=="0":
        tmp=-i-2
# print(tmp)
li=[]
for i in range(n):
    li.append(tmp)
    a=-i-2-m
    if a<-1-n:
        a=-1-n
    if s[a]=="0":
        tmp=a
ans=[]
i=-1
li.reverse()

while(i!=-n-1):

    if li[i]==i:
        print(-1)
        quit()
    ans.append(i-li[i])
    i=li[i]

ans.reverse()


for i in range(len(ans)):
    print(ans[i])