Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

ans = 0

for i in range(n):
    for j in range(i+1,n):
        if s[j] != s[i]:
            for k in range(j+1,n):
                if (s[k] != s[j]) and (s[k] != s[i]):
                    if (j-i) != (k-j):
                        ans += 1
print(ans)

Fixed submission:
from itertools import permutations

n = int(input())
s = input()

out = 0
ans = s.count("R")*s.count("G")*s.count("B")

combi = list(permutations(["R","G","B"],3))

for i in range(1,n):
    for j in range(n-i*2):
        if (s[j], s[j+i], s[j+i*2]) in combi:
            ans -= 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

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

kcnt = []
c = Counter(a)
for j in c.values():
    kcnt.append(j*(j-1)//2)
for i in a:
    print(sum(kcnt)-(c[i]-1))


Fixed submission:
from collections import Counter

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

c = Counter(a)
total = sum([v*(v-1)//2 for v in c.values()])
for i in a:
    print(total-(c[i]-1))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
import copy

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

cnum = []
ans = 0

for k in range(1,n+1):
    cans = []
    dammy = copy.copy(a)
    del dammy[k-1]
    c = Counter(dammy)
    cnum = [c[i] for i in c if c[i] >=2]
    for j in cnum:
        cans.append(j*(j-1)//2)
    print(sum(cans))

Fixed submission:
from collections import Counter

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

c = Counter(a)
total = sum([v*(v-1)//2 for v in c.values()])
for i in a:
    print(total-(c[i]-1))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
import copy

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

from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

cnum = []
ans = 0

for k in range(1,n+1):
    cans = []
    dammy = copy.copy(a)
    del dammy[k-1]
    c = Counter(dammy)
    cnum = [c[i] for i in c if c[i] >=2]
    for j in cnum:
        cans.append(combinations_count(j, 2))
    print(sum(cans))


Fixed submission:
from collections import Counter

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

c = Counter(a)
total = sum([v*(v-1)//2 for v in c.values()])
for i in a:
    print(total-(c[i]-1))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())

for i in range(q):
    qu = input().split()
    if int(qu[0]) == 1:
        s = list(s)
        s.reverse()
        s = "".join(s)
    elif int(qu[0]) == 2:
        if int(qu[1]) == 1:
            s = qu[2] + s 
        elif int(qu[1]) == 2:
            s = s + qu[2]
print(s)

Fixed submission:
s = input()
q = int(input())

f1 = 1
f2 = 2
cnt = 0
st = ""
se = ""

for _ in range(q):
    q = input().split()
    if int(q[0]) == 1:
        cnt += 1
    elif int(q[0]) == 2:
        if cnt % 2 == 0:
            if int(q[1]) == 1:
                st = q[2] + st
            elif int(q[1]) == 2:
                se += q[2]
        else:
            if int(q[1]) == 1:
                se += q[2]
            elif int(q[1]) == 2:
                st = q[2] + st


ans = st + s + se
if cnt % 2 == 0:
    print(ans)
else:
    ans = list(ans)
    ans.reverse()
    ans = "".join(ans)
    print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np

a = [list(map(int,input().split())) for _ in range(3)]

n = int(input())

b = list([int(input()) for _ in range(n)])

c = [[0]*3]*3

for k in b:
    for i in range(3):
        for j in range(3):
            if k == a[i][j]:
                c[i][j]=1

c = np.array(c)

if (max(c.sum(axis=0))==3) or (max(c.sum(axis=1))==3) or \
    (sum([a[i,i] for i in range(3)])==3) or (a[2,0]+a[1,1]+a[0,2]==3):
    print("Yes")
else:
    print("No")


Fixed submission:
import numpy as np

a = [list(map(int,input().split())) for _ in range(3)]

n = int(input())

b = list([int(input()) for _ in range(n)])

c = np.zeros(9).reshape(3,3)

for k in b:
    for i in range(3):
        for j in range(3):
            if k == a[i][j]:
                c[i,j]=1

if (max(c.sum(axis=0))==3) or (max(c.sum(axis=1))==3) or \
    (sum([c[i,i] for i in range(3)])==3) or (c[2,0]+c[1,1]+c[0,2]==3):
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
import numpy as np

a = [list(map(int,input().split())) for _ in range(3)]

n = int(input())

b = list([int(input()) for _ in range(n)])

c = [[0]*3]*3

for k in b:
    for i in range(3):
        for j in range(3):
            if k == a[i][j]:
                c[i][j]=1

c = np.array(c)

if (max(c.sum(axis=0))==3) or (max(c.sum(axis=1))==3) or \
    (sum([a[i,i] for i in range(3)])==3) or (sum(a[2,0]+a[1,1]+a[0,2])==3):
    print("Yes")
else:
    print("No")

Fixed submission:
import numpy as np

a = [list(map(int,input().split())) for _ in range(3)]

n = int(input())

b = list([int(input()) for _ in range(n)])

c = np.zeros(9).reshape(3,3)

for k in b:
    for i in range(3):
        for j in range(3):
            if k == a[i][j]:
                c[i,j]=1

if (max(c.sum(axis=0))==3) or (max(c.sum(axis=1))==3) or \
    (sum([c[i,i] for i in range(3)])==3) or (c[2,0]+c[1,1]+c[0,2]==3):
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
import numpy as np

# a = [list(map(int,input().split())) for _ in range(3)]

# n = int(input())

# b = list([int(input()) for _ in range(n)])

c = [[0]*3]*3

for k in b:
#     print("k={}".format(k))
    for i in range(3):
        for j in range(3):
#             print("  a={}".format(a[i][j]))
            if k == a[i][j]:
                c[i][j]=1

c = np.array(c)

if (max(c.sum(axis=0))==3) or (max(c.sum(axis=1))==3) or \
    (sum([a[i,i] for i in range(3)])==3) or (sum(a[2,0]+a[1,1]+a[0,2])==3):
    print("Yes")
else:
    print("No")

Fixed submission:
import numpy as np

a = [list(map(int,input().split())) for _ in range(3)]

n = int(input())

b = list([int(input()) for _ in range(n)])

c = np.zeros(9).reshape(3,3)

for k in b:
    for i in range(3):
        for j in range(3):
            if k == a[i][j]:
                c[i,j]=1

if (max(c.sum(axis=0))==3) or (max(c.sum(axis=1))==3) or \
    (sum([c[i,i] for i in range(3)])==3) or (c[2,0]+c[1,1]+c[0,2]==3):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n, m = map(int,input().split())

a = [""]*3
rep = []
ans = 0

for i in range(m):
    s,c = input().split()
    if s in rep:
        if c != a[int(s)-1]:
            ans = -1
    rep.append(s)
    a[int(s)-1] = c

if ans == -1:
    print(ans)
else:
    if a[0] == "":
        if a[1] == "":
            print(int(a[2]))
        elif a[2]=="":
            a[2]="0"
            print("".join(a))
    else:
        if a[1] == "":
            a[1] = "0"
            print("".join(a))
        elif a[2]=="":
            a[2]="0"
            print("".join(a))
            

Fixed submission:
n, m = map(int,input().split())
sc = [list(map(int,input().split())) for _ in range(m)]

ans = -1

for i in range(1000):
    s_i = str(i)
    if len(s_i) == n and all(int(s_i[s-1])==c for s,c in sc):
        ans = i
        break

print(ans)

Buggy python submission (verdict: Runtime Error):
n, m = map(int,input().split())

a = [""]*3
rep = []
ans = 0

for i in range(m):
    s,c = input().split()
    if s in rep:
        if c != a[int(s)-1]:
            ans = -1
    rep.append(s)
    a[int(s)-1] = c

if ans == -1:
    print(ans)
else:
    if a[0] == "":
        if a[1] == "":
            print(int(a[2]))
        elif a[2]=="":
            a[2]="0"
            print("".join(a))
    else:
        if a[1] == "":
            print(0)
        elif a[2]=="":
            a[2]="0"
            print("".join(a))
            

Fixed submission:
n, m = map(int,input().split())
sc = [list(map(int,input().split())) for _ in range(m)]

ans = -1

for i in range(1000):
    s_i = str(i)
    if len(s_i) == n and all(int(s_i[s-1])==c for s,c in sc):
        ans = i
        break

print(ans)

Buggy python submission (verdict: Runtime Error):
n, m = map(int,input().split())

# sc = [list(map(int,input().split())) for _ in range(m)]

a = [""]*3
rep = []
ans = 0

for i in range(m):
    s,c = input().split()
    if s in rep:
        if c != a[int(s)-1]:
            ans = -1
    rep.append(s)
    a[int(s)-1] = c
    
print(a)

if ans == -1:
    print(ans)
else:
    if a[0] == "":
        if a[1] == "":
            print(int(a[2]))
        elif a[2]=="":
            a[2]="0"
            print("".join(a))
    else:
        if a[1] == "":
            print(0)
        elif a[2]=="":
            a[2]="0"
            print("".join(a))
            

Fixed submission:
n, m = map(int,input().split())
sc = [list(map(int,input().split())) for _ in range(m)]

ans = -1

for i in range(1000):
    s_i = str(i)
    if len(s_i) == n and all(int(s_i[s-1])==c for s,c in sc):
        ans = i
        break

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, a, b=map(int,input().split())

from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

def main():
    sum = 0
    for i in range(1,n+1):
        if (i==a) or (i==b):
            continue
        sum += combinations_count(n,i)

    print(sum)

main()

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

mod = 10**9+7

def combi(n,r):
    x, y = 1,1
    for i in range(n-r+1,n+1):
        x *= i
        x %= mod
        
    for j in range(1,r+1):
        y *= j
        y %= mod
    yinv = pow(y,mod-2,mod)
    
    return x*yinv%mod

def main():
    nca = combi(n,a)
    ncb = combi(n,b)
    ans = pow(2,n,mod)-1 - (nca + ncb)
        
    print(ans%mod)
    
main()
Buggy python submission (verdict: Runtime Error):
H = int(input())
dn = [0]*(H//2+1)
dn[0] = 1

for i in range(1,H//2+1):
    dn[i] = dn[i-1]*2
print(sum(dn))

Fixed submission:
h = int(input())
sumn = 0
i,k = 0,1
while k <= h:
    sumn+=k
    i+=1
    k = 2**i
    
print(sumn)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input())
print(a*b if a<=9 and b<=9 else -1)

Fixed submission:
a,b = map(int,input().split())
print(a*b if a<=9 and b<=9 else -1)
Buggy python submission (verdict: Time Limit Exceeded):
def division(n):
    a = [1]
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
def main():
    n = int(input())
    c = division(n)

    ans = 10**12
    for i in range(2**(len(c))):
        x,y = 1,1
        for j in range(len(c)):
            if i>>j&1:
                x *= c[j]
            else:
                y *= c[j]
        ans = min(ans,x+y-2)
    print(ans)
main()

Fixed submission:
n = int(input())
ans = 10**12
for a in range(1,10**6+1):
    if n%a==0:
        b=n//a
    ans = min(ans,a+b-2)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def division(n):
    a = [1]
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

n = int(input())
c = division(n)

ans = 10**12
for i in range(2**(len(c))):
    x,y = 1,1
    for j in range(len(c)):
        if i>>j&1:
            x *= c[j]
        else:
            y *= c[j]
    ans = min(ans,x+y-2)
print(ans)

Fixed submission:
n = int(input())
ans = 10**12
for a in range(1,10**6+1):
    if n%a==0:
        b=n//a
    ans = min(ans,a+b-2)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
L,R = map(int,input().split())
ans = R*R
for i in range(L,R+1):
    for j in range(i+1,R+1):
        ans = min(ans,(i*j)%2019)
print(ans)

Fixed submission:
L,R = map(int,input().split())
if R - L >= 2019:
    ans = 0
else:
    ans = R*R
    for i in range(L,R+1):
        for j in range(i+1,R+1):
            ans = min(ans,(i*j)%2019)
print(ans)
Buggy python submission (verdict: Runtime Error):
y,m,d = int(input().split("/"))
print("Heisei" if y<=2019 and m<=4 and d<=30 else "TBD")

Fixed submission:
s = input()
print("Heisei" if s<="2019/04/30" else "TBD")
Buggy python submission (verdict: Runtime Error):
import bisect
A,B,Q = map(int,input().split())
INF = float('inf')
S = [-INF]+[int(input()) for _ in range(A)]+[INF]
T = [-INF]+[int(input()) for _ in range(B)]+[INF]

ans = []
for q in range(Q):
    x = int(input())
    i = bisect.bisect_right(S,x)
    j = bisect.bisect_right(T,x)
    d = INF
    for s in [S[i-1],S[i]]:
        for t in [T[i-1],T[i]]:
            d1 = abs(x-s) + abs(s-t)
            d2 = abs(x-t) + abs(s-t)
            d = min(d,d1,d2)
    ans.append(d)
for i in ans:
    print(i)

Fixed submission:
import bisect
A,B,Q = map(int,input().split())
INF = float('inf')
S = [-INF]+[int(input()) for i in range(A)]+[INF]
T = [-INF]+[int(input()) for i in range(B)]+[INF]
for q in range(Q):
    x = int(input())
    i = bisect.bisect_right(S,x)
    j = bisect.bisect_right(T,x)
    d = INF
    for s in [S[i-1],S[i]]:
        for t in [T[j-1],T[j]]:
            d1 = abs(s-x)+abs(s-t)
            d2 = abs(t-x)+abs(s-t)
            d = min(d,d1,d2)
    print(d)

Buggy python submission (verdict: Runtime Error):
import bisect
A,B,Q = map(int,input().split())
INF = float('inf')
S = [-INF]+[int(input()) for _ in range(A)]+[INF]
T = [-INF]+[int(input()) for _ in range(B)]+[INF]

ans = []
for q in range(Q):
    x = int(input())
    i = bisect.bisect_right(S,x)
    j = bisect.bisect_right(T,x)
    d = INF
    for s in [S[i-1],S[i]]:
        for t in [T[i-1],T[i]]:
            d1 = abs(x-s) + abs(s-t)
            d2 = abs(x-t) + abs(s-t)
            d = min(d,d1,d2)
    ans.append(d)
print(*ans,sep="\n")

Fixed submission:
import bisect
A,B,Q = map(int,input().split())
INF = float('inf')
S = [-INF]+[int(input()) for i in range(A)]+[INF]
T = [-INF]+[int(input()) for i in range(B)]+[INF]
for q in range(Q):
    x = int(input())
    i = bisect.bisect_right(S,x)
    j = bisect.bisect_right(T,x)
    d = INF
    for s in [S[i-1],S[i]]:
        for t in [T[j-1],T[j]]:
            d1 = abs(s-x)+abs(s-t)
            d2 = abs(t-x)+abs(s-t)
            d = min(d,d1,d2)
    print(d)

Buggy python submission (verdict: Runtime Error):
import bisect
A,B,Q = map(int,input().split())
INF = float('inf')
S = [-INF]+[int(input()) for _ in range(A)]+[INF]
T = [-INF]+[int(input()) for _ in range(B)]+[INF]

ans = []
for q in range(Q):
    x = int(input())
    i = bisect.bisect_left(S,x)
    j = bisect.bisect_left(T,x)
    d = INF
    for s in [S[i-1],S[i]]:
        for t in [T[i-1],T[i]]:
            d1 = abs(x-s) + abs(s-t)
            d2 = abs(x-t) + abs(s-t)
            d = min(d,d1,d2)
    ans.append(d)
print(*ans,sep="\n")

Fixed submission:
import bisect
A,B,Q = map(int,input().split())
INF = float('inf')
S = [-INF]+[int(input()) for i in range(A)]+[INF]
T = [-INF]+[int(input()) for i in range(B)]+[INF]
for q in range(Q):
    x = int(input())
    i = bisect.bisect_right(S,x)
    j = bisect.bisect_right(T,x)
    d = INF
    for s in [S[i-1],S[i]]:
        for t in [T[j-1],T[j]]:
            d1 = abs(s-x)+abs(s-t)
            d2 = abs(t-x)+abs(s-t)
            d = min(d,d1,d2)
    print(d)
Buggy python submission (verdict: Runtime Error):
x,m = map(int, input().split())
x = sorted(list(map(int, input().split())))

if n >= m:print(0)
else:
    dist = [abs(x[i+1] - x[i]) for i in range(m-1)]
    dist = sorted(dist)
    print(sum(dist[:-(n-1)]))

Fixed submission:
n,m = map(int, input().split())
x = sorted(list(map(int, input().split())))

if n >= m:print(0)
else:
    dist = [abs(x[i+1] - x[i]) for i in range(m-1)]
    dist = sorted(dist)
    print(sum(dist[:m-n]))

Buggy python submission (verdict: Runtime Error):
x,m = map(int, input().split())
x = sorted(list(map(int, input().split())))

if n >= m:print(0)
else:
    dist = [abs(x[i+1] - x[i]) for i in range(m-1)]
    dist = sorted(dist)
    print(sum(dif[:-(n-1)]))

Fixed submission:
n,m = map(int, input().split())
x = sorted(list(map(int, input().split())))

if n >= m:print(0)
else:
    dist = [abs(x[i+1] - x[i]) for i in range(m-1)]
    dist = sorted(dist)
    print(sum(dist[:m-n]))

Buggy python submission (verdict: Runtime Error):
x,m = map(int, input().split())
x = sorted(list(map(int, input().split())))

if n >= m:print(0)
else:
    dist = [abs(x[i+1] - x[i]) for i in range(M-1)]
    dist = sorted(dist)
    print(sum(dif[:-(n-1)]))

Fixed submission:
n,m = map(int, input().split())
x = sorted(list(map(int, input().split())))

if n >= m:print(0)
else:
    dist = [abs(x[i+1] - x[i]) for i in range(m-1)]
    dist = sorted(dist)
    print(sum(dist[:m-n]))

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

Fixed submission:
n,m = map(int, input().split())
x = sorted(list(map(int, input().split())))

if n >= m:print(0)
else:
    dist = [abs(x[i+1] - x[i]) for i in range(m-1)]
    dist = sorted(dist)
    print(sum(dist[:m-n]))
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N,W = map(int,input().split())
    w,v = [],[]
    for _ in range(N):
        w_,v_ = map(int,input().split())
        w.append(w_)
        v.append(v_)

    dp = [[0]*(W+1) for _ in range(N+1)]

    for i in range(N):
        for j in range(W+1):
            if j-w[i]<0:
                dp[i+1][j] = dp[i][j]
            else:
                dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]]+v[i])

    print(dp[N][-1])
main()

Fixed submission:
import numpy as np
def main():
    N,W = map(int,input().split())
    w,v = [],[]
    for _ in range(N):
        w_,v_ = map(int,input().split())
        w.append(w_)
        v.append(v_)

    dp = np.zeros((N+1,W+1),dtype=np.int64)
    for i in range(N):
        tmp = np.zeros(W+1,dtype=int)
        tmp[w[i]:] = dp[i][:-w[i]] + v[i]
        dp[i+1] = np.maximum(dp[i],tmp)

    print(dp[N][W])
main()

Buggy python submission (verdict: Time Limit Exceeded):
N,W = map(int,input().split())
w,v = [],[]
for _ in range(N):
    w_,v_ = map(int,input().split())
    w.append(w_)
    v.append(v_)
    
dp = [[0]*(W+1) for _ in range(N+1)]

for i in range(N):
    for j in range(W+1):
        if j-w[i]<0:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]]+v[i])
    
print(dp[N][-1])

Fixed submission:
import numpy as np
def main():
    N,W = map(int,input().split())
    w,v = [],[]
    for _ in range(N):
        w_,v_ = map(int,input().split())
        w.append(w_)
        v.append(v_)

    dp = np.zeros((N+1,W+1),dtype=np.int64)
    for i in range(N):
        tmp = np.zeros(W+1,dtype=int)
        tmp[w[i]:] = dp[i][:-w[i]] + v[i]
        dp[i+1] = np.maximum(dp[i],tmp)

    print(dp[N][W])
main()
Buggy python submission (verdict: Time Limit Exceeded):
N,W = map(int,input().split())
w,v =[],[]

for _ in range(N):
    w_,v_ = map(int,input().split())
    w.append(w_)
    v.append(v_)

max_v = 100100
max_n = 110
dp =[[float("inf")]*(max_v) for _ in range(max_n)]
dp[0][0] = 0
for i in range(N):
    for j in range(max_v):
        dp[i+1][j] = dp[i][j]
        if j - v[i] >= 0:
            dp[i+1][j] = min(dp[i][j],dp[i][j-v[i]] + w[i])

res = 0
for sum_v in range(max_v):
    if dp[N][sum_v] <= W:
        res = sum_v
print(res)

Fixed submission:
# E.Knapsack2 → numpy spped up
import numpy as np
N,W = map(int,input().split())
w,v = [],[]
for _ in range(N):
    w_,v_ = map(int,input().split())
    w.append(w_)
    v.append(v_)
    
Vmax = max(v)*N
INF = 10**9
            
dp = np.ones((N+1,Vmax+1),dtype=np.int64)*INF
dp[0][0]=0

for i in range(N):
    tmp = np.ones(Vmax+1,dtype=int)*INF
    tmp[v[i]:] = dp[i][:-v[i]] + w[i]
    dp[i+1] = np.minimum(dp[i],tmp)

ans = 0   
for i in range(Vmax,-1,-1):
    if dp[N][i] <= W:
        ans = i
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9+10)

mod = 10**9+7

def dfs(x,y):
    if not(0<=x<H) or not(0<=y<W):
        return
    if  maze[x][y]=="#":
        return
    
    if x==H-1 and y==W-1:
        return
        
    dh = [1,0]
    dw = [0,1]
    
    for i,j in zip(dh,dw):
        if (0<=x+i<H) and (0<=y+j<W):
            if maze[x+i][y+j]!="#":
                dp[x+i][y+j] += 1
                dp[x+i][y+j] %= mod
        dfs(x+i,y+j)

H,W = map(int,input().split())
maze = [list(input()) for _ in range(H)]

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

dfs(0,0)
print(dp[H-1][W-1])

Fixed submission:
mod = 10**9+7
H,W = map(int,input().split())
maze = [list(input()) for _ in range(H)]
dp = [[0]*W for _ in range(H)]
dp[0][0]=1

for i in range(H):
    for j in range(W):
        if i+1<H and maze[i+1][j]==".":
            dp[i+1][j] += dp[i][j]%mod
        if j+1<W and maze[i][j+1]==".":
            dp[i][j+1] += dp[i][j]%mod
            
print(dp[H-1][W-1]%mod)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**9+10)

mod = 10**9+7

def dfs(x,y):
    if not(0<=x<H) or not(0<=y<W):
        return
    if  maze[x][y]=="#":
        return
    
    if x==H-1 and y==W-1:
        return
        
    dh = [1,0]
    dw = [0,1]
    
    for i,j in zip(dh,dw):
        if (0<=x+i<H) and (0<=y+j<W):
            if maze[x+i][y+j]!="#":
                dp[x+i][y+j] += 1
                dp[x+i][y+j] %= mod
        dfs(x+i,y+j)

H,W = map(int,input().split())
maze = [list(input()) for _ in range(H)]

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

dfs(0,0)
print(dp[H-1][W-1])

Fixed submission:
mod = 10**9+7
H,W = map(int,input().split())
maze = [list(input()) for _ in range(H)]
dp = [[0]*W for _ in range(H)]
dp[0][0]=1

for i in range(H):
    for j in range(W):
        if i+1<H and maze[i+1][j]==".":
            dp[i+1][j] += dp[i][j]%mod
        if j+1<W and maze[i][j+1]==".":
            dp[i][j+1] += dp[i][j]%mod
            
print(dp[H-1][W-1]%mod)
Buggy python submission (verdict: Runtime Error):
from itertools import product

n = input()

if int(n) < 100:
    print(0)

else:
    ans = 0

    for i in range(3,len(n)+1):
        s = list(product("753",repeat=i))
        for combi in s:
            n_s = "".join(combi)
            if int(n_s) > int(n):
                continue
            if ("7" in combi) and ("5" in combi) and ("3" in combi):
                ans += 1
    
	print(ans)


Fixed submission:
from itertools import product

n = input()

if int(n) < 100:
    print(0)

else:
    ans = 0

    for i in range(3,len(n)+1):
        s = list(product("753",repeat=i))
        for combi in s:
            n_s = "".join(combi)
            if int(n_s) > int(n):
                continue
            if ("7" in combi) and ("5" in combi) and ("3" in combi):
                ans += 1
    
    print(ans)

Buggy python submission (verdict: Runtime Error):
from itertools import product

n = input()

if int(n) < 100:
    print(0)

else:
    ans = 0

    for i in range(3,len(n)+1):
        s = list(product("753",repeat=i))
        for combi in s:
            n_s = "".join(combi)
            if int(n_s) > int(n):
                continue
            if ("7" in combi) and ("5" in combi) and ("3" in combi):
                ans += 1
    
print(ans)


Fixed submission:
from itertools import product

n = input()

if int(n) < 100:
    print(0)

else:
    ans = 0

    for i in range(3,len(n)+1):
        s = list(product("753",repeat=i))
        for combi in s:
            n_s = "".join(combi)
            if int(n_s) > int(n):
                continue
            if ("7" in combi) and ("5" in combi) and ("3" in combi):
                ans += 1
    
    print(ans)