Buggy python submission (verdict: Time Limit Exceeded):
def main():
  M=10**9+7
  n,k,*a=map(int,open(0).read().split())
  b=[1]+[0]*k
  for i in a:
    t,d=0,[]
    for w,v in zip([0]*-~i+b,b):
      t+=v-w
      t%=M
      d+=t,
    b=d
  print(t)
main()

Fixed submission:
def main():
  e,M=enumerate,10**9+7
  n,k,*a=map(int,open(0).read().split())
  dp=[[0]*(k+1)for _ in range(n+1)]
  dp[0][0]=1
  for i,(b,d,a)in e(zip(dp,dp[1:],a),1):
    t=0
    for j,v in e(b):
      t+=v
      if j>a:t-=b[~a+j]
      t%=M
      d[j]=t
  print(t)
main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
  e,M=enumerate,10**9+7
  n,k,*a=map(int,open(0).read().split())
  dp=[[0]*(k+1)for _ in range(n+1)]
  dp[0][0]=1
  for b,d,a in zip(dp,dp[1:],a):
    a+=1
    t=0
    for j,v in e(b[:a]):
      t+=v
      t%=M
      d[j]=t
    for j,(w,v)in e(zip(b,b[a:]),a):
      t+=v-w
      t%=M
      d[j]=t
  print(t)
main()

Fixed submission:
def main():
  e,M=enumerate,10**9+7
  n,k,*a=map(int,open(0).read().split())
  dp=[[0]*(k+1)for _ in range(n+1)]
  dp[0][0]=1
  for i,(b,d,a)in e(zip(dp,dp[1:],a),1):
    t=0
    for j,v in e(b):
      t+=v
      if j>a:t-=b[~a+j]
      t%=M
      d[j]=t
  print(t)
main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
  e,M=enumerate,10**9+7
  n,k,*a=map(int,open(0).read().split())
  dp=[[0]*(k+1)for _ in range(n+1)]
  dp[0][0]=1
  for i,(b,d,a)in e(zip(dp,dp[1:],a),1):
    t=0
    for j,v in e(b[:a+1]):
      t+=v
      t%=M
      d[j]=t
    for j,(w,v)in e(zip(b,b[a+1:]),a+1):
      t+=v-w
      t%=M
      d[j]=t
  print(t)
main()

Fixed submission:
def main():
  e,M=enumerate,10**9+7
  n,k,*a=map(int,open(0).read().split())
  dp=[[0]*(k+1)for _ in range(n+1)]
  dp[0][0]=1
  for i,(b,d,a)in e(zip(dp,dp[1:],a),1):
    t=0
    for j,v in e(b):
      t+=v
      if j>a:t-=b[~a+j]
      t%=M
      d[j]=t
  print(t)
main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
  e,M=enumerate,10**9+7
  n,k,*a=map(int,open(0).read().split())
  dp=[[0]*(k+1)for _ in range(n+1)]
  dp[0][0]=1
  for i,(b,d,a)in e(zip(dp,dp[1:],a),1):
    t=0
    for j,v in e(b[:a+1]):
      t+=v
      t%=M
      d[j]=t
    for j,(w,v)in e(zip(b,b[a+1:]),a+1):
      t+=v-w
      t%=M
      d[j]=t
  print(t)
main()

Fixed submission:
def main():
  e,M=enumerate,10**9+7
  n,k,*a=map(int,open(0).read().split())
  dp=[[0]*(k+1)for _ in range(n+1)]
  dp[0][0]=1
  for i,(b,d,a)in e(zip(dp,dp[1:],a),1):
    t=0
    for j,v in e(b):
      t+=v
      if j>a:t-=b[~a+j]
      t%=M
      d[j]=t
  print(t)
main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
  e,M=enumerate,10**9+7
  n,k,*a=map(int,open(0).read().split())
  dp=[[0]*(k+1)for _ in range(n+1)]
  dp[0][0]=1
  for i,(b,d,a)in e(zip(dp,dp[1:],a),1):
    t=0
    for j,v in e(b[:a+1]):
      t+=v
      t%=M
      d[j]=t
    for j,(w,v)in e(zip(b,b[a+1:]),a+1):
      t+=v-w
      t%=M
      d[j]=t
  print(t)
main()

Fixed submission:
def main():
  e,M=enumerate,10**9+7
  n,k,*a=map(int,open(0).read().split())
  dp=[[0]*(k+1)for _ in range(n+1)]
  dp[0][0]=1
  for i,(b,d,a)in e(zip(dp,dp[1:],a),1):
    t=0
    for j,v in e(b):
      t+=v
      if j>a:t-=b[~a+j]
      t%=M
      d[j]=t
  print(t)
main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
  e,M=enumerate,10**9+7
  n,k,*a=map(int,open(0).read().split())
  dp=[[0]*(k+1)for _ in range(n+1)]
  dp[0][0]=1
  for i,(b,d,a)in e(zip(dp,dp[1:],a),1):
    t=0
    for j,v in e(b):
      t+=v
      if j>a:t-=b[~a+j]
      t%=M
      d[j]=t
  print(t)
main()

Fixed submission:
def main():
  e,M=enumerate,10**9+7
  n,k,*a=map(int,open(0).read().split())
  dp=[[0]*(k+1)for _ in range(n+1)]
  dp[0][0]=1
  for i,(b,d,a)in e(zip(dp,dp[1:],a),1):
    t=0
    for j,v in e(b):
      t+=v
      if j>a:t-=b[~a+j]
      t%=M
      d[j]=t
  print(t)
main()

Buggy python submission (verdict: Time Limit Exceeded):
e,M=enumerate,10**9+7
n,k,*a=map(int,open(0).read().split())
dp=[[0]*(k+1)for _ in range(n+1)]
dp[0][0]=1
for i,(b,d,a)in e(zip(dp,dp[1:],a),1):
  t=0
  for j,v in e(b):
    t+=v
    if j>a:t-=b[~a+j]
    t%=M
    d[j]=t
print(t)

Fixed submission:
def main():
  e,M=enumerate,10**9+7
  n,k,*a=map(int,open(0).read().split())
  dp=[[0]*(k+1)for _ in range(n+1)]
  dp[0][0]=1
  for i,(b,d,a)in e(zip(dp,dp[1:],a),1):
    t=0
    for j,v in e(b):
      t+=v
      if j>a:t-=b[~a+j]
      t%=M
      d[j]=t
  print(t)
main()