Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
cnt = 0
for i in range(n):
  if a[i] <= b[i]:
    cnt += a[i]
    b[i] -= a[i]
    if b[i] >= a[i+1]:
      cnt += a[i+1]
      a[i+1]=0
    else:
      cnt += b[i]
      a[i+1] -= b[i]
  else:
    cnt += b[i]
print(cnt)

Fixed submission:
import math
X=int(input())
while True:
    for i in range(2,int(math.sqrt(X))+1):
      if X%i==0:
        X+=1
        break
    else:
      print(X)
      break

Buggy python submission (verdict: Runtime Error):
import math
X=int(input())
n=math.sqrt(X)
if X==2:
  print(X)
else:
  for i in range(2,n):
    if X%i==0:
      X+=1
  print(X)


Fixed submission:
import math
X=int(input())
while True:
    for i in range(2,int(math.sqrt(X))+1):
      if X%i==0:
        X+=1
        break
    else:
      print(X)
      break

Buggy python submission (verdict: Runtime Error):

X=int(input())
if X==2:
  print(X)
else:
  for i in range(2,X**(1/2)):
    if X%i==0:
      X+=1
  print(X)


Fixed submission:
import math
X=int(input())
while True:
    for i in range(2,int(math.sqrt(X))+1):
      if X%i==0:
        X+=1
        break
    else:
      print(X)
      break

Buggy python submission (verdict: Runtime Error):
from 
X=int(input())
if X==2:
  print(X)
else:
  for i in range(2,X**(1/2)):
    if X%i==0:
      X+=1
  print(X)

Fixed submission:
import math
X=int(input())
while True:
    for i in range(2,int(math.sqrt(X))+1):
      if X%i==0:
        X+=1
        break
    else:
      print(X)
      break

Buggy python submission (verdict: Runtime Error):
X=int(input())
y=0
if X==2:
  print(X)
else:
  for i in range(2,X/2):
    if X%i==0:
      X+=1
  print(X)

Fixed submission:
import math
X=int(input())
while True:
    for i in range(2,int(math.sqrt(X))+1):
      if X%i==0:
        X+=1
        break
    else:
      print(X)
      break

Buggy python submission (verdict: Runtime Error):
import math
X=int(input())
if X=2:
  print(X)
else:
  for i in range(math.sqrt(X)-1):
    if X%(2+i)==0:
      X+=1
    else:
      print(X)

Fixed submission:
import math
X=int(input())
while True:
    for i in range(2,int(math.sqrt(X))+1):
      if X%i==0:
        X+=1
        break
    else:
      print(X)
      break
Buggy python submission (verdict: Runtime Error):
a=input()
b=input()
l="123"
l.remove(a)
l.remove(b)
print(l)

Fixed submission:
a=int(input())
b=int(input())
c=[1,2,3]
c.remove(a)
c.remove(b)
print(c[0])
Buggy python submission (verdict: Runtime Error):
N=int(input())
S,T=input().split("")
P=""
for i in range(N):
  P=P+S[i]+T[i]
print(P)

Fixed submission:
n=int(input())
s,t=input().split(" ")
u=""
for i in range(n):
  u = u + s[i] + t[i]
print(u)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))

cnt = 0
num = 1

for i in range(n):
  if a[i] == num:
    num += 1
    cnt += 1

if cnt == 0:
  pirnt(-1)
else:
  print(n - cnt)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))

cnt = 0
num = 1

for i in range(n):
  if a[i] == num:
    num += 1
    cnt += 1

if cnt == 0:
  print(-1)
else:
  print(n - cnt)
Buggy python submission (verdict: Runtime Error):
a1,a2,a3=map(intinput().split())
if a1+a2+a3>=22:
  print("bust")
else:
  print("win")

Fixed submission:
a1,a2,a3=map(int,input().split())
if a1+a2+a3>=22:
  print("bust")
else:
  print("win")

Buggy python submission (verdict: Runtime Error):
a,b,c=map(int(input().split()))
if a+b+c>=22:
  print("bust")
else:
  print("win")

Fixed submission:
a1,a2,a3=map(int,input().split())
if a1+a2+a3>=22:
  print("bust")
else:
  print("win")

Buggy python submission (verdict: Runtime Error):
a1,a2,a3=map(int(input().split()))
if a1+a2+a3>=22:
  print("bust")
else:
  print("win")

Fixed submission:
a1,a2,a3=map(int,input().split())
if a1+a2+a3>=22:
  print("bust")
else:
  print("win")
Buggy python submission (verdict: Runtime Error):
S = list(map(int,input().split()))
p=len(S)
t=0
for n in range(p):
  if S[n]!=S[p-n-1]:
    t+=1
print(t/2)


Fixed submission:
S = input()
p=len(S)
t=0
for n in range(p):
  if S[n]!=S[p-n-1]:
    t+=1
print(int(t/2))

Buggy python submission (verdict: Runtime Error):
S = input()
len(S)=p
t=0
for n in range(p):
  if S[n]!=S[p-n-1]:
    t+=1
print(t/2)

Fixed submission:
S = input()
p=len(S)
t=0
for n in range(p):
  if S[n]!=S[p-n-1]:
    t+=1
print(int(t/2))

Buggy python submission (verdict: Runtime Error):
S = list(map(int,input().split()))
len(S)=p
t=0
for n in range(p):
  if S[n]!=S[p-n-1]:
    t+=1
print(t/2)

Fixed submission:
S = input()
p=len(S)
t=0
for n in range(p):
  if S[n]!=S[p-n-1]:
    t+=1
print(int(t/2))

Buggy python submission (verdict: Runtime Error):
S = list(map(int,input().split()))
len(S)=p
t=0
for n in range(p):
  if S[n]=S[p-n-1]:
    continue
  else:
    t+=1
print(t/2)


Fixed submission:
S = input()
p=len(S)
t=0
for n in range(p):
  if S[n]!=S[p-n-1]:
    t+=1
print(int(t/2))

Buggy python submission (verdict: Runtime Error):
S = input()
len(S)=p
t=0
for n in range(p):
  if S[n]=S[p-n-1]:
    continue
  else:
    t+=1
print(t/2)

Fixed submission:
S = input()
p=len(S)
t=0
for n in range(p):
  if S[n]!=S[p-n-1]:
    t+=1
print(int(t/2))

Buggy python submission (verdict: Runtime Error):
S = input()
len(S)=p
t=0
for n in range(p):
  if S[n]=S[p-n-1]:
    continue
  else:
    t+=1
print(t)

Fixed submission:
S = input()
p=len(S)
t=0
for n in range(p):
  if S[n]!=S[p-n-1]:
    t+=1
print(int(t/2))

Buggy python submission (verdict: Runtime Error):
S = list(map(int,input().split()))
len(S)=int(p)
t=0
for n in range(p):
  if S[n]=S[p-n-1]:
    continue
  else:
    t+=1
print(t)

Fixed submission:
S = input()
p=len(S)
t=0
for n in range(p):
  if S[n]!=S[p-n-1]:
    t+=1
print(int(t/2))

Buggy python submission (verdict: Runtime Error):
S = list(map(int,input().split()))
len(S)=p
t=0
for n in range(p):
  if S[n]=S[p-n-1]:
    continue
  else:
    t+=1
print(t)

Fixed submission:
S = input()
p=len(S)
t=0
for n in range(p):
  if S[n]!=S[p-n-1]:
    t+=1
print(int(t/2))
Buggy python submission (verdict: Runtime Error):
N=int(input())
if n%2==0:
  print((n/2)-1)
else:
  print((n-1)/2)


Fixed submission:
n=int(input())
if n%2==0:
  print(int((n/2)-1))
else:
  print(int((n-1)/2))

Buggy python submission (verdict: Runtime Error):
n=int(input())
if n%2=0:
  print((n/2)-1)
else:
  print((n-1)/2)


Fixed submission:
n=int(input())
if n%2==0:
  print(int((n/2)-1))
else:
  print(int((n-1)/2))
Buggy python submission (verdict: Runtime Error):
a,b=input(int,input().split())
if a<=9 and b<=9:
  print(str(a*b))
else:
  print(-1)

Fixed submission:
a,b=map(int,input().split())
if a<=9 and b<=9:
  print(a*b)
else:
  print(-1)

Buggy python submission (verdict: Runtime Error):
a,b=input(int,input().split())
if a<10 and b<10:
  print(str(a*b))
else:
  print(-1)

Fixed submission:
a,b=map(int,input().split())
if a<=9 and b<=9:
  print(a*b)
else:
  print(-1)

Buggy python submission (verdict: Runtime Error):
a,b=input(int,input().split())
if a<10 and b<10:
  print(str(a*b))
else:
  print("-1")

Fixed submission:
a,b=map(int,input().split())
if a<=9 and b<=9:
  print(a*b)
else:
  print(-1)

Buggy python submission (verdict: Runtime Error):
a,b=input(int,input().split())
if a<10 and b<10:
  print(int(a*b))
else:
  print("-1")

Fixed submission:
a,b=map(int,input().split())
if a<=9 and b<=9:
  print(a*b)
else:
  print(-1)

Buggy python submission (verdict: Runtime Error):
a,b=input(int,input().split())
if a<10 and b<10:
  print(a*b)
else:
  print("-1")

Fixed submission:
a,b=map(int,input().split())
if a<=9 and b<=9:
  print(a*b)
else:
  print(-1)

Buggy python submission (verdict: Runtime Error):
a,b=input(int,input().split())
if a<10,b<10:
  print(a*b)
else:
  print("-1")

Fixed submission:
a,b=map(int,input().split())
if a<=9 and b<=9:
  print(a*b)
else:
  print(-1)

Buggy python submission (verdict: Runtime Error):
a,b=input(int,inupt.split())
if a<10,b<10:
  print(a*b)
else:
  print("-1")

Fixed submission:
a,b=map(int,input().split())
if a<=9 and b<=9:
  print(a*b)
else:
  print(-1)
Buggy python submission (verdict: Runtime Error):
n=int(input())
for a in range(1,10):
  for b in  range(1,10):
    if n=a*b:
      print("Yes")
      exit()
else:
  print("No")

Fixed submission:
n=int(input())
for a in range(1,10):
  for b in range(1,10):
    if n==a*b:
      print("Yes")
      exit()
    
print("No")

Buggy python submission (verdict: Runtime Error):
n=int(input())
for a in range(1,10):
  for b in range(1,10):
    if n==a*b:
    break
    print("Yes")
    else:
    print("No")

Fixed submission:
n=int(input())
for a in range(1,10):
  for b in range(1,10):
    if n==a*b:
      print("Yes")
      exit()
    
print("No")

Buggy python submission (verdict: Runtime Error):
n=int(input())
for a in range(1,10):
  for b in range(1,10):
  if n==a*b:
    break
    print("Yes")
  else:
    print("No")

Fixed submission:
n=int(input())
for a in range(1,10):
  for b in range(1,10):
    if n==a*b:
      print("Yes")
      exit()
    
print("No")

Buggy python submission (verdict: Runtime Error):
n=int(input())
for a in range(1,10):
  for b in range(1,10):
  if N==a*b:
    break
    print("Yes")
  else:
    print("No")

Fixed submission:
n=int(input())
for a in range(1,10):
  for b in range(1,10):
    if n==a*b:
      print("Yes")
      exit()
    
print("No")

Buggy python submission (verdict: Runtime Error):
int(input()) = N
for a in range(1,10):
  for b in range(1,10):
  if N==a*b:
    break
    print("Yes")
  else:
    print("No")

Fixed submission:
n=int(input())
for a in range(1,10):
  for b in range(1,10):
    if n==a*b:
      print("Yes")
      exit()
    
print("No")

Buggy python submission (verdict: Runtime Error):
int(input()) = N
for a in range(1,10):
  for b in range(a,10):
  if N==a*b:
    print("Yes")
  else:
    print("No")

Fixed submission:
n=int(input())
for a in range(1,10):
  for b in range(1,10):
    if n==a*b:
      print("Yes")
      exit()
    
print("No")

Buggy python submission (verdict: Runtime Error):
int(input()) = N
for a in range(1,10):
  for b in range(1,10):
  if N==a*b:
    print("Yes")
  else:
    print("No")

Fixed submission:
n=int(input())
for a in range(1,10):
  for b in range(1,10):
    if n==a*b:
      print("Yes")
      exit()
    
print("No")

Buggy python submission (verdict: Runtime Error):
input() = N
for i in range(10):
  if N==i**2:
    print("Yes")
  else:
    print("No")

Fixed submission:
n=int(input())
for a in range(1,10):
  for b in range(1,10):
    if n==a*b:
      print("Yes")
      exit()
    
print("No")
Buggy python submission (verdict: Runtime Error):
n=input()
arr=list(map(int,input().split()))
s=0
for i in range(0,n-1):
  for j in range(i+1,n):
    s+=arr[i]*arr[j]
print(s)

Fixed submission:
n=int(input())
arr=list(map(int,input().split()))
s=0
for i in range(0,n-1):
  for j in range(i+1,n):
    s+=arr[i]*arr[j]
print(s)
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
x=0
for i in range(0,n-1):
  if s[i]=s[i+1]:
    x+=1
print(n-x)

Fixed submission:
n=int(input())
s=input()
x=0
for i in range(0,n-1):
  if s[i]==s[i+1]:
    x+=1
print(n-x)

Buggy python submission (verdict: Runtime Error):
n=int(input())
s=list(map(int,input().split()))
x=0
for i in range(0,n-1):
  if s[i]=s[i+1]:
    x+=1
print(n-x)

Fixed submission:
n=int(input())
s=input()
x=0
for i in range(0,n-1):
  if s[i]==s[i+1]:
    x+=1
print(n-x)
Buggy python submission (verdict: Time Limit Exceeded):
a,b=map(int,input().split())
x=[1]
y=[1]
for i in range(2,a//2+1):
  if a%i==0:
    x.append(i)
    while a%i==0:
      a=a//i
    if a==1:
      break
for i in range(2,b//2+1):
  if b%i==0:
    y.append(i)
    while b%i==0:
      b=b//i
    if b==1:
      break
print(len(set(x)&set(y)))

Fixed submission:
import fractions
a,b=map(int,input().split())
k=fractions.gcd(a,b)
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    
    return arr

 
print(len(factorization(k))+1)

Buggy python submission (verdict: Time Limit Exceeded):
a,b=map(int,input().split())
x=[1]
y=[1]
for i in range(2,a//2+1):
  if a%i==0:
    x.append(i)
    while a%i==0:
      a=a//i
  if b%i==0:
    y.append(i)
    while b%i==0:
      b=b//i
print(len(set(x)&set(y)))

Fixed submission:
import fractions
a,b=map(int,input().split())
k=fractions.gcd(a,b)
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    
    return arr

 
print(len(factorization(k))+1)
Buggy python submission (verdict: Runtime Error):
s=input()
if s="Sunny":
  print("Cloudy")
if s="Cloudy":
  print("Rainy")
if s="Rainy":
  print("Sunny")

Fixed submission:
s=input()
if s=="Sunny":
  print("Cloudy")
if s=="Cloudy":
  print("Rainy")
if s=="Rainy":
  print("Sunny")
Buggy python submission (verdict: Runtime Error):
s=list(input())
l=len(s)
for i  in range(0,l):
  if i%2==0:
    if s[i]=="R":
      print("No")
      exit()
  if i%2==1:
    if s[i]=="L":
      pirnt("No")
      exit()
print("Yes")

Fixed submission:
s=list(input())
l=len(s)
for i  in range(0,l):
  if i%2==0:
    if s[i]=="L":
      print("No")
      exit()
  elif i%2==1:
    if s[i]=="R":
      print("No")
      exit()
  else:
    pass
print("Yes")
Buggy python submission (verdict: Runtime Error):
n=int(input())
pirnt(n**3)

Fixed submission:
n=int(input())
print(n**3)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
x=0
for i in range(0,n-1):
  if a[i]=a[i+1]:
    x+=int(c[int(a[i])-1])
y=sum(b)
print(x+y)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
x=0
for i in range(0,n-1):
  if a[i]+1==a[i+1]:
    x+=c[a[i]-1]
y=sum(b)
print(x+y)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
x=0
for i in range(0,n-1):
  if a[i]=a[i+1]:
    x+=c[a[i]-1]
y=sum(b)
print(x+y)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
x=0
for i in range(0,n-1):
  if a[i]+1==a[i+1]:
    x+=c[a[i]-1]
y=sum(b)
print(x+y)
Buggy python submission (verdict: Runtime Error):
n=int(input())
b=list(map(int,input().split()))
x=sum(b)+b[0]
y=0
for i in range(0,n-1):
  if b[i]>b[i+1]:
    y+=b[i+1]-b[i]
print(int(x+y))


Fixed submission:
n=int(input())
b=list(map(int,input().split()))
x=sum(b)+b[0]
y=0
for i in range(0,n-2):
  if b[i]>b[i+1]:
    y+=(b[i+1]-b[i])
print(x+y)

Buggy python submission (verdict: Runtime Error):
n=int(input())
b=list(map(int,input().split()))
x=sum(b)+b[0]
y=0
for i in range(0,n-1):
  if b[i]>b[i+1]:
    y+=(b[i+1]-b[i])
print(x+y)

Fixed submission:
n=int(input())
b=list(map(int,input().split()))
x=sum(b)+b[0]
y=0
for i in range(0,n-2):
  if b[i]>b[i+1]:
    y+=(b[i+1]-b[i])
print(x+y)

Buggy python submission (verdict: Runtime Error):
n=int(input())
b=list(map(int,input().split()))
x=sum(b)+b[0]
y=0
for i in range(0,n-1):
  if b[i]>b[i+1]:
    y+=b[i+1]-b[i]
print(x+y)
  

Fixed submission:
n=int(input())
b=list(map(int,input().split()))
x=sum(b)+b[0]
y=0
for i in range(0,n-2):
  if b[i]>b[i+1]:
    y+=(b[i+1]-b[i])
print(x+y)
Buggy python submission (verdict: Runtime Error):
s=list(map(input().split()))
t=list(map(input().split()))
x=0
for i in range(0,2):
  if s[i]==t[i]:
    x+=1
print(x)


Fixed submission:
s=list(input())
t=list(input())
x=0
for i in range(0,3):
  if s[i]==t[i]:
    x+=1
print(x)

Buggy python submission (verdict: Runtime Error):
s=list(map(input().split()))
t=list(map(input().split()))
x=0
for i in range(0,2):
  if s[i]=t[i]:
    x+=1
print(x)

Fixed submission:
s=list(input())
t=list(input())
x=0
for i in range(0,3):
  if s[i]==t[i]:
    x+=1
print(x)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
print(math.ceil((b-1)/(a-1)))


Fixed submission:
import math
a,b=map(int,input().split())
c=a-1
d=b-1
print(math.ceil(d/c))

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
print(math.ceil(b-1/a-1))

Fixed submission:
import math
a,b=map(int,input().split())
c=a-1
d=b-1
print(math.ceil(d/c))

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
x=0
for i:
  if (a-1)*i+1<b:
    x+=1
  else:
    exit()
print(x)

Fixed submission:
import math
a,b=map(int,input().split())
c=a-1
d=b-1
print(math.ceil(d/c))
Buggy python submission (verdict: Runtime Error):
n=int(input())
p=list(map(int,input().split()))
cnt=0
for i in range(n):
  if p[i]=i+1:
    cnt += 1
if cnt < n-2:
  print("No")
else:
  print("Yes")

Fixed submission:
n=int(input())
P=list(map(int,input().split()))
t=len(P)
m=0
for i in range(t):
  if P[i]!=i+1:
    m+=1
if m<=2:
  print("YES")
else:
  print("NO")

Buggy python submission (verdict: Runtime Error):
n=int(input())
P=list(map(int,input().split()))
t=len(P)
m=0
for i in range(t):
  if P[i]!=P.index(i+1)+1:
    m+=1
if m=2:
  print("YES")
else:
  print("NO")

Fixed submission:
n=int(input())
P=list(map(int,input().split()))
t=len(P)
m=0
for i in range(t):
  if P[i]!=i+1:
    m+=1
if m<=2:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
m=0
t=len(B)
for i in range(t)
if a[i]>=b[i]:
  m+=b[i]
  if a[i]-b[i]>=b[i+1]:
    m+=b[i+1]
    b[i+1]=0
  else:
    m+=a[i]-b[i]
    b[i+1]-=a[i]-b[i]
else:
  m+=a[i]
  

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
cnt = 0
for i in range(n):
  if a[i] <= b[i]:
    cnt += a[i]
    b[i] -= a[i]
    if b[i] >= a[i+1]:
      cnt += a[i+1]
      a[i+1]=0
    else:
      cnt += b[i]
      a[i+1] -= b[i]
  else:
    cnt += b[i]
print(cnt)
Buggy python submission (verdict: Runtime Error):
a=input()
print(3*(a**2))

Fixed submission:
r=int(input())
print(3*r*r)
Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
w, v = [0] * N, [0] * N
for i in range(N):
	w[i], v[i] = map(int, input().split())
dp = [[0] * (W + 1) for _ in range(N + 1)]
for i in range(N):
  for j in range(W+1):
    if j>=w[i]:
      dp[i+1][j]=max(dp[i][j] ,dp[i][j-w[i]] +v[i] )
    else:
      dp[i+1][j]=dp[i][j]
print(dp[N][W])

Fixed submission:
N, W = map(int, input().split())
w, v = [0] * N, [0] * N
for i in range(N):
	w[i], v[i] = map(int, input().split())
dp = [[0] * (W + 1) for _ in range(N + 1)]
for i in range(N):
  for j in range(W+1):
    if j>=w[i]:
      dp[i+1][j]=max(dp[i][j] ,dp[i][j-w[i]] +v[i] )
    else:
      dp[i+1][j]=dp[i][j]
print(dp[N][W])
Buggy python submission (verdict: Runtime Error):
import sys
import os
f = open('input.txt', 'r')
sys.stdin = f
m = 10**9+7
def nCr(n,r):
  if r*2>n:
      return nCr(n,n-r)
  else:
      a = b = 1
      for i in range(r):
          a = a * (n - i) % m
          b = b * (r - i) % m
      return (a * pow(b,m-2,m)) % m

H,W=map(int,input().split())

grid=[]

for i in range(H):
    a= list(input())
    grid.append(a)

wall=[]
for i in range(H):
    for j in range(W):
        if grid[i][j]=="#":
            wall.append([i,j])

ans = nCr((H+W-2),(H-1))

for i in range(len(wall)):
    x = wall[i][0] + wall[i][1]
    y = (H-wall[i][0]) + (W-wall[i][1])
    ans -= nCr(x-1,wall[i][0]-1) * nCr(y-1,(H-wall[i][0])-1)

print(ans)

Fixed submission:
H,W=map(int,input().split())

grid=[]

m=10**9+7

for i in range(H):
    a= list(input())
    grid.append(a)

dp=[ [0]*(W+3) for _ in range(H+3)]

for i in reversed(range(H)):
    for j in reversed(range(W)):
        dp[i][j] = dp[i+1][j] + dp[i][j+1]
        dp[H-1][W-1]=1
        if grid[i][j]=="#":
            dp[i][j]=0
print(dp[0][0]%m)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))

m=10**9+7

dp=[ [0]*(k+1) for _  in range(n+1) ]
dp[0][0]=1

dp_sum=[ [0]*(k+1) for _  in range(n+1) ]

for i in range(n):
    for j in range(k+1):
        if j==0:
            dp_sum[i][j]=1
        else:
            dp_sum[i][j]= dp_sum[i][j-1]+dp[i][j]
        if j-a[i]>0:
            dp[i+1][j]= dp_sum[i][j] - dp_sum[i][j-a[i]-1]
        else:
            dp[i+1][j]= dp_sum[i][j]

print(dp[n][k]%m)

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))

m=10**9+7

dp=[ [0]*(k+1) for _  in range(n+1) ]
dp[0][0]=1

dp_sum=[ [0]*(k+1) for _  in range(n+1) ]

for i in range(n):
    for j in range(k+1):
        if j==0:
            dp_sum[i][j]=1
        else:
            dp_sum[i][j]= (dp_sum[i][j-1]+dp[i][j])%m
        if j-a[i]>0:
            dp[i+1][j]= (dp_sum[i][j] - dp_sum[i][j-a[i]-1])%m
        else:
            dp[i+1][j]= (dp_sum[i][j])%m

print(dp[n][k]%m)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))

m=10**9+7

dp=[ [0]*(k+1) for _  in range(n+1) ]
dp[0][0]=1

for i in range(n):
    for j in range(k+1):
        if j-a[i]>=0:
            dp[i+1][j]=sum( dp[i][j-a[i]:j+1 ])
        else:
            dp[i+1][j]=sum( dp[i][0:j+1 ])

print(dp[n][k]%m)

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))

m=10**9+7

dp=[ [0]*(k+1) for _  in range(n+1) ]
dp[0][0]=1

dp_sum=[ [0]*(k+1) for _  in range(n+1) ]

for i in range(n):
    for j in range(k+1):
        if j==0:
            dp_sum[i][j]=1
        else:
            dp_sum[i][j]= (dp_sum[i][j-1]+dp[i][j])%m
        if j-a[i]>0:
            dp[i+1][j]= (dp_sum[i][j] - dp_sum[i][j-a[i]-1])%m
        else:
            dp[i+1][j]= (dp_sum[i][j])%m

print(dp[n][k]%m)
Buggy python submission (verdict: Runtime Error):
N = int(input())
ans = 3 ** N
num = 1

for i in range(N):
    A = int(input())
    num *= (2-(A%2))

print(ans-num)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans = 3**N
num = 1
for i in A:
    if i%2 == 0:
        num *= 2
print( ans-num )
Buggy python submission (verdict: Time Limit Exceeded):
x,k,d=input().split()
x=int(x)
k=int(k)
d=int(d)
if(abs(x)>k*d):
    print(abs(x)-k*d)
else:
    for i in range(k):
        x=abs(x)-d
        if(x<1):
            break
    k=k-i-1
    if(k==0):
        print(abs(x))
    elif(k%2==0):
        print(abs(x))
    else:
        print(abs(x+d))
        

Fixed submission:
x,k,d=input().split()
x=int(x)
k=int(k)
d=int(d)
if(abs(x)>k*d):
    print(abs(x)-k*d)
else:
    i=abs(x)//d
    a=abs(x)%d
    k=k-i
    if(k==0):
        print(a)
    elif(k%2==0):
        print(a)
    else:
        print(abs(a-d))
Buggy python submission (verdict: Runtime Error):
def main(n, m, p_s):
    st = [False for _ in range(n)]
    ac, wa = 0, 0

    for p, s in p_s:
        if st[p - 1]:
            continue

        if s == "AC":
            ac += 1
            st[p - 1] = True
        if s == "WA":
            wa += 1

    print(ac, wa)


if __name__ == "__main__":
    n, m = map(int, input().split())
    p_s = [list(map(int, input().split())) for _ in range(m)]

    main(n, m, p_s)


Fixed submission:
def main(n: int, m: int, p_s: list):
    bool_ac = [False for _ in range(n)]
    count_wa = [0 for _ in range(n)]
    ac, wa = 0, 0

    for p, s in p_s:
        p = int(p)

        if bool_ac[p - 1]:
            continue

        if s == "AC":
            bool_ac[p - 1] = True
            wa += count_wa[p - 1]
            ac += 1
        elif s == "WA":
            count_wa[p - 1] += 1

    print(ac, wa)


if __name__ == "__main__":
    n, m = map(int, input().split())
    p_s = [input().split() for _ in range(m)]

    main(n, m, p_s)