Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from math import gcd
from functools import reduce
# import itertools
from collections import defaultdict

a=int(input())

def ggcd(*numbers):
    return reduce(gcd, numbers)

sum=0

for x in range(1,a+1):
    for y in range(1,a+1):
        if x == 1 and y==1 : sum+=(1*a);continue
        for z in range(1,a+1):
            if x==y==z:
                sum+=x
            else:
                if(x == y or y==z):
                    sum += gcd(x, z)
                elif(x==z):
                    sum += gcd(x, y)
                else:
                    sum += ggcd(x, y,z)
                    

print(sum)


Fixed submission:
from math import gcd
from functools import reduce
# import itertools
from collections import defaultdict

a=int(input())

sum=0


for x in range(1,a+1):
    for y in range(1,a+1):
        for z in range(1,a+1):
            sum+=gcd(gcd(x,y),z)


print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
import sys


n,k= map(int,input().split())
v={}

min = sys.maxsize

if n == 0 :print(0);exit()
if n >= 10**18 :print(0);exit()

while True:
    diff = abs(n- k)

    if v.get(diff):
        break
    else:
        v[diff] = True
        n = diff

        if diff < min:
            min = diff



print(min)

Fixed submission:
import sys

n,k= map(int,input().split())
v={}

min = sys.maxsize

if n == 0 :print(0);exit()

if n > k :
    x = n%k
    if x == 0 or x > k: 
        print(x);exit()
    else:
        n=x
        v[x] = True

while True:
    diff = abs(n- k)

    if v.get(diff):
        break
    else:
        # print(diff)
        v[diff] = True
        n = diff

        if diff < min:
            min = diff



print(min)

Buggy python submission (verdict: Time Limit Exceeded):
import sys


n,k= map(int,input().split())
v={}

min = sys.maxsize

if n == 0 :print(0);exit()
if n >= 10**18 :print(0);exit()


while True:
    diff = abs(n- k)

    if v.get(diff):
        break
    else:
        v[diff] = True
        n = diff

        if diff < min:
            min = diff



print(min)

Fixed submission:
import sys

n,k= map(int,input().split())
v={}

min = sys.maxsize

if n == 0 :print(0);exit()

if n > k :
    x = n%k
    if x == 0 or x > k: 
        print(x);exit()
    else:
        n=x
        v[x] = True

while True:
    diff = abs(n- k)

    if v.get(diff):
        break
    else:
        # print(diff)
        v[diff] = True
        n = diff

        if diff < min:
            min = diff



print(min)
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
n = int(input())

for _ in range(n):
    i = list(input())

    if i[0] == '1': s=s[::-1]

    else:
        if i[2] == '1':  s=i[4] + s
        else: s+=i[4]

print(s)

Fixed submission:
from collections import deque
s=input()
n = int(input())

f=False
q= deque(s)

for _ in range(n):
    i = input()

    if i[0] == '1': f=False if f else True
    else:
        _,a,b =i.split()
        
        if f :
            if a == '1':q.append(b)
            else:q.appendleft(b)
        else:
            if a == '1':q.appendleft(b)
            else:q.append(b)

if f: q.reverse()

for i in q:print(i,end='')

Buggy python submission (verdict: Time Limit Exceeded):

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

for _ in range(n):
    i = list(input())

    if i[0] == '1': s=s[::-1]

    else:
        if i[2] == '1':  s=i[4] + s
        else: s+=i[4]

print(s)

Fixed submission:
from collections import deque
s=input()
n = int(input())

f=False
q= deque(s)

for _ in range(n):
    i = input()

    if i[0] == '1': f=False if f else True
    else:
        _,a,b =i.split()
        
        if f :
            if a == '1':q.append(b)
            else:q.appendleft(b)
        else:
            if a == '1':q.appendleft(b)
            else:q.append(b)

if f: q.reverse()

for i in q:print(i,end='')
Buggy python submission (verdict: Time Limit Exceeded):
n,a,b=map(int,input().split())

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = pow(10,9) + 7
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2,n + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

print(pow(2,n,p) - cmb(n, a, p) -cmb(n, b, p) -1)


Fixed submission:
n, a, b = map(int, input().split())
mod = 10 ** 9 + 7
 
 
def cmb(n, r, mod):
    r = min(r, n - r)
    x = 1
    y = 1
    for i in range(r):
        x = x * (n - i) % mod
        y = y * (i + 1) % mod
    y = pow(y, mod-2, mod)
    return x * y % mod
 

ans = pow(2, n, mod) - 1 - cmb(n, a, mod) - cmb(n, b, mod)
while ans < 0:
    ans += mod
print(ans)

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

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = pow(10,9) + 7
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2,n + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

print(pow(2,n,p) - cmb(n, a, p) -cmb(n, b, p) -1)


Fixed submission:
n, a, b = map(int, input().split())
mod = 10 ** 9 + 7
 
 
def cmb(n, r, mod):
    r = min(r, n - r)
    x = 1
    y = 1
    for i in range(r):
        x = x * (n - i) % mod
        y = y * (i + 1) % mod
    y = pow(y, mod-2, mod)
    return x * y % mod
 

ans = pow(2, n, mod) - 1 - cmb(n, a, mod) - cmb(n, b, mod)
while ans < 0:
    ans += mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math

n,a,b=map(int,input().split())
d={}


def cc(n, r):
    if not d.get(n):
        d[n] = math.factorial(n)
    if not d.get(n-r):
        d[n-r] = math.factorial(n-r)
    if not d.get(r):
        d[r] = math.factorial(r)

    return d[n] // (d[n-r] * d[r])


x=10**9 +7
r=0
for i in range(1,n+1):
    if i == a or i == b:continue
    
    r+=cc(n,i)



print(r%x)

Fixed submission:
n, a, b = map(int, input().split())
mod = 10 ** 9 + 7
 
 
def cmb(n, r, mod):
    r = min(r, n - r)
    x = 1
    y = 1
    for i in range(r):
        x = x * (n - i) % mod
        y = y * (i + 1) % mod
    y = pow(y, mod-2, mod)
    return x * y % mod
 

ans = pow(2, n, mod) - 1 - cmb(n, a, mod) - cmb(n, b, mod)
while ans < 0:
    ans += mod
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10000000)
input=sys.stdin.readline
mod = 10 ** 9 + 7
 
def cmb(n, r):

    r = min(r, n - r)
    x = 1
    y = 1
    for i in range(r):
        x = x * (n - i) % mod
        y = y * (i + 1) % mod
    y = pow(y, mod-2, mod)
    return x * y % mod
 
n,k = map(int,input().split())
 
ans=0
k=min(k,n-1)
for i in range(k+1):
    ans += cmb(n,i) * cmb(n-1,i) %mod
 
print(ans%mod)
 


Fixed submission:
import sys
sys.setrecursionlimit(10000000)
input=sys.stdin.readline
mod = 10 ** 9 + 7

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

fac = [1]*(n+1)
inv = [1]*(n+1)
for i in range(1,n+1):
  fac[i] = (fac[i-1]*i) % mod  
inv[n] = pow(fac[n], mod-2, mod)
for i in range(n, 0, -1):
  inv[i-1] = (inv[i]*i) % mod
    
def cmb(n, r):
     
  if r < 1:
        return 1
  return (((fac[n] * inv[r])%mod) * inv[n-r]) % mod
 


ans=0
k=min(k,n-1)
for i in range(k+1):
    ans += cmb(n,i) * cmb(n-1,i) %mod

print(ans%mod)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a = [input() for i in range(n)]
b = sorted(list(set(a)))
d = {}
for i in b:
    t = a.count(i)
    d.setdefault(t,[])
    d[t].append(i)

for i in d[max(d.keys())]:
    print(i)


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

if len(set(b)) == 2:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a = [input() for i in range(n)]
b = sorted(list(set(a)))
d = {}
m = 0

for i in b:
    t = a.count(i)
    if m > 0 and t < m:
        continue

    d.setdefault(t,[])
    d[t].append(i)
    if t > m:
        m = t

for i in d[max(d.keys())]:
    print(i)

Fixed submission:
from collections import defaultdict

n=int(input())

d=defaultdict(int)


for i in range(n):
    d[input()] +=1

m =max(d.values())

for i,j in sorted(d.items()):
    if j == m :print(i)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a = [input() for i in range(n)]
b = sorted(list(set(a)))
d = {}
m = 0

for i in b:
    t = a.count(i)
    if m > 0 and t < m:
        continue

    d.setdefault(t,[])
    d[t].append(i)

for i in d[max(d.keys())]:
    print(i)

Fixed submission:
from collections import defaultdict

n=int(input())

d=defaultdict(int)


for i in range(n):
    d[input()] +=1

m =max(d.values())

for i,j in sorted(d.items()):
    if j == m :print(i)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a = [input() for i in range(n)]
b = sorted(list(set(a)))
d = {}
for i in b:
    t = a.count(i)
    d.setdefault(t,[])
    d[t].append(i)

for i in d[max(d.keys())]:
    print(i)


Fixed submission:
from collections import defaultdict

n=int(input())

d=defaultdict(int)


for i in range(n):
    d[input()] +=1

m =max(d.values())

for i,j in sorted(d.items()):
    if j == m :print(i)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p = list(map(int, input().split()))

d = []

for v in p:
    d.append((1+v)/2)

r=0

for i in range(n-k+1):
    r=max(r,sum(d[i:i+k]))


print(r)


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

d = []

for v in p:
    d.append((1+v)/2)

x=r=sum(d[:k])
# print(d)

for i in range(1,n-k+1):
    # r=max(r,sum(d[i:i+k]))
    x=x-d[i-1]+d[i+k-1]
    r=max(r,x)
    # print(r,i)

print(r)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())

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

r=1
for i in range(1,n):
    if a[i] <= min(a[:i]):r+=1

print(r)

Fixed submission:
n=int(input())

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

r=1
min=a[0]

for i in range(1,n):
    if a[i] > min:continue
    else:
        r+=1
        min=a[i] 
    

print(r)

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

r=1

for i,j in enumerate(a[1:],1):
    # print('aaaaa')
    # print(i,j)
    is_b=False
    for y in a[:i]:
        if y < j:
            is_b=True
            break
    if not is_b:
        r+=1

print(r)


Fixed submission:
n=int(input())

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

r=1
min=a[0]

for i in range(1,n):
    if a[i] > min:continue
    else:
        r+=1
        min=a[i] 
    

print(r)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import fractions

sys.setrecursionlimit(10000000)
input=sys.stdin.readline

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

def gcd(a, b):
    return a if b == 0 else gcd(b, a%b)

def lcm(a, b):
    return a // fractions.gcd(a, b) * b

mod = 10**9+7

x=a[0]

for i in a[1:]:
    x=lcm(x,i)
ans=0
for i in range(n):
    ans+= x//a[i]%mod

print(ans%mod)


Fixed submission:
import sys
import fractions

sys.setrecursionlimit(10000000)
input=sys.stdin.readline

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

def gcd(a, b):
    return a if b == 0 else gcd(b, a%b)

def lcm(a, b):
    return a // fractions.gcd(a, b) * b

mod = 10**9+7

x=a[0]

for i in a[1:]:
    x=lcm(x,i)
ans=0
for i in range(n):
    ans+= x//a[i]

print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10000000)
input=sys.stdin.readline

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

def gcd(a, b):
    return a if b == 0 else gcd(b, a%b)

def lcm(a, b):
    return a // gcd(a, b) * b

mod = 10**9+7

x=a[0]

for i in a[1:]:
    x=lcm(x,i)
ans=0
for i in range(n):
    ans+= x//a[i]%mod

print(ans%mod)


Fixed submission:
import sys
import fractions

sys.setrecursionlimit(10000000)
input=sys.stdin.readline

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

def gcd(a, b):
    return a if b == 0 else gcd(b, a%b)

def lcm(a, b):
    return a // fractions.gcd(a, b) * b

mod = 10**9+7

x=a[0]

for i in a[1:]:
    x=lcm(x,i)
ans=0
for i in range(n):
    ans+= x//a[i]

print(ans%mod)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = input()

print(b.count('ABC'))

Fixed submission:
k,x = map(int,input().split())

if 500*k >= x:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input().split())

aa = a - k
if aa < 0:
    bb = 0 if b+aa <0 else  b+aa
    aa=0

print (aa,bb)

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

a = a - k

if a < 0:
    b = 0 if b+a <0 else  b+a
    a=0
print (a,b)

Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input().split())

aa = a - k
if aa < 0:
    bb=b+aa
    aa=0

print (aa,bb)

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

a = a - k

if a < 0:
    b = 0 if b+a <0 else  b+a
    a=0
print (a,b)
Buggy python submission (verdict: Runtime Error):
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

n=int(input())

x=n
for i in range(n,10**5): 
   if is_prime(i):
       break


print (i) 



Fixed submission:
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

n=int(input())

x=n
for i in range(n,10**6): 
   if is_prime(i):
       break


print (i)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=list(input())

# d={'r':0,'s':0,'p':0}
d={}
ans=0
c=0
for i in t:

    if c >= k:
        x =d[c-k]
        if i =='r':
            if x == 'p':
                if t[c+k] == 's':
                    d[c]='s'
                else:
                    d[c]='r'
            else:
                ans += p ; d[c]='p'
        elif i == 's': 
            if x == 'r':
               if t[c+k] == 'p':
                    d[c]='p'
               else:
                    d[c]='s'
            else:
                ans += r;d[c]='r'
        elif i == 'p': 
            if x == 's':
               if t[c+k] == 'r':
                    d[c]='r'
               else:
                    d[c]='p'
            else:
                ans += s;d[c]='s'

    else:
        if i =='r':
            ans += p ; d[c]='p'
        elif i == 's': 
            ans += r;d[c]='r'
        elif i == 'p': 
            ans += s;d[c]='s'

    c+=1


print(ans)

Fixed submission:
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=list(input())

# d={'r':0,'s':0,'p':0}
d={}
ans=0
c=0
for i in t:

    if c >= k:
        x =d[c-k]
        y = c+k
        if i =='r':
            if x == 'p':
                if  y < n and t[y] == 's':
                    d[c]='s'
                else:
                    d[c]='r'
            else:
                ans += p ; d[c]='p'
        elif i == 's': 
            if x == 'r':
               if y < n and t[y] == 'p' :
                    d[c]='p'
               else:
                    d[c]='s'
            else:
                ans += r;d[c]='r'
        elif i == 'p': 
            if x == 's':
               if  y < n and t[y] == 'r':
                    d[c]='r'
               else:
                    d[c]='p'
            else:
                ans += s;d[c]='s'

    else:
        if i =='r':
            ans += p ; d[c]='p'
        elif i == 's': 
            ans += r;d[c]='r'
        elif i == 'p': 
            ans += s;d[c]='s'

    c+=1


print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# import numpy as np
n=int(input())
# a=np.array(list(map(int,input().split())))
a=list(map(int,input().split()))

ans=0
mod=10**9+7
for i in range(60):
    x=0
    for j in range(n):
        if (a[j] >>i&1) :x+=1

    now = x*(n-x) % mod

    for j in range(i):
        now = now*2 % mod
    ans += now
    ans %= mod

print(ans)

Fixed submission:
# import numpy as np
n=int(input())
# a=np.array(list(map(int,input().split())))
a=list(map(int,input().split()))

ans=0
mod=10**9+7
for i in range(60):
    x=0
    for j in range(n):
        if (a[j] >>i&1) :x+=1

    now = x*(n-x) % mod

    for j in range(i):
        now = now*2 % mod
    ans += now
    ans %= mod

print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np
n=int(input())
a=np.array(list(map(int,input().split())))

ans=0
mod=10**9+7
for i in range(60):
    x=0
    for j in range(n):
        if (a[j] >>i&1) :x+=1

    now = x*(n-x) % mod

    for j in range(i):
        now = now*2 % mod
    ans += now
    ans %= mod

print(ans)

Fixed submission:
# import numpy as np
n=int(input())
# a=np.array(list(map(int,input().split())))
a=list(map(int,input().split()))

ans=0
mod=10**9+7
for i in range(60):
    x=0
    for j in range(n):
        if (a[j] >>i&1) :x+=1

    now = x*(n-x) % mod

    for j in range(i):
        now = now*2 % mod
    ans += now
    ans %= mod

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n=int(input())
a=np.array(list(map(int,input().split())))

ans=0
mod=10**9+7
for i in range(60):
    x=0
    for j in range(n):
        if (a[j] >>i&1) :x+=1

    now = x*(n-x) % mod

    for j in range(i):
        now = now*2 % mod
    ans += now
    ans %= mod

print(ans)

Fixed submission:
# import numpy as np
n=int(input())
# a=np.array(list(map(int,input().split())))
a=list(map(int,input().split()))

ans=0
mod=10**9+7
for i in range(60):
    x=0
    for j in range(n):
        if (a[j] >>i&1) :x+=1

    now = x*(n-x) % mod

    for j in range(i):
        now = now*2 % mod
    ans += now
    ans %= mod

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n=int(input())
a=np.array(list(map(int,input().split())))

ans=0
mod=10**9+7
for i in range(60):
    x=0
    for j in range(n):
        if (a[j] >>i&1) :x+=1

    now = x*(n-x)

    for j in range(i):
        now = now*2
    ans += now
    ans %= mod

print(ans)

Fixed submission:
# import numpy as np
n=int(input())
# a=np.array(list(map(int,input().split())))
a=list(map(int,input().split()))

ans=0
mod=10**9+7
for i in range(60):
    x=0
    for j in range(n):
        if (a[j] >>i&1) :x+=1

    now = x*(n-x) % mod

    for j in range(i):
        now = now*2 % mod
    ans += now
    ans %= mod

print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())

g =[[] for _ in range(n)]
ans=[0] * (n-1)

def dfs(v,c=-1,p=-1):
    k=1

    for u,ei in g[v]:
        if u == p: continue
        if k == c: k+=1

        ans[ei] = k
        k+=1
        dfs(u,ans[ei],v)

for i in range(n-1):
    a,b=map(int,input().split())
    a-=1
    b-=1
    g[a].append((b,i))
    g[b].append((a,i))

dfs(0)
mx=0

for i in range(n):
    mx = max(mx,int(len(g[i])))

print(mx)
for i in ans:print(i)

Fixed submission:
import sys
sys.setrecursionlimit(100000)

n=int(input())

g =[[] for _ in range(n)]
ans=[0] * (n-1)

def dfs(v,c=-1,p=-1):
    k=1

    for u,ei in g[v]:
        if u == p: continue
        if k == c: k+=1

        ans[ei] = k
        k+=1
        dfs(u,ans[ei],v)

for i in range(n-1):
    a,b=map(int,input().split())
    a-=1
    b-=1
    g[a].append((b,i))
    g[b].append((a,i))

dfs(0)
mx=0

for i in range(n):
    mx = max(mx,int(len(g[i])))

print(mx)
for i in ans:print(i)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())

l=list(map(int,input().split()))

for i in range(m):
    j= l.index(max(l))
    l[j] = l[j]//2


print(sum(l))


Fixed submission:
import heapq

n, m = map(int, input().split())
a = list(map(lambda x: -int(x) ,input().split()))
heapq.heapify(a)

for _ in range(m):
    tmp = -heapq.heappop(a)
    tmp //= 2
    heapq.heappush(a,-tmp)
print(-sum(a))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

b=[0]*n

for i in range(n-1,-1,-1):
    for j in range(i,n):
        if not sum(b[i+1:n:i+1]) %2 and a[j]==1:
            b[i] = 1 

print(sum(b))
print(" ".join([str(i)  for i in b if i== 1]))


Fixed submission:
import sys
sys.setrecursionlimit(10000000)
input=sys.stdin.readline

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

b=[0]*n

for i in range(n-1,-1,-1):
    if sum(b[i:n:i+1]) %2 and a[i] == 0:
        b[i] = 1 
    elif not sum(b[i:n:i+1]) %2 and a[i] == 1:
        b[i] = 1 


print(sum(b))
print(" ".join([str(k+1)  for k,v in enumerate(b)  if v== 1]))
Buggy python submission (verdict: Runtime Error):
l,r = map(int,input().split())

for i in range(l,r+1):
    for j in range(i+1,r+1):
        ans = min(ans,(i%2019*j%2019)%2019)
print(ans)

Fixed submission:
l,r = map(int,input().split())
if r-l>=2019:
    print(0)
    exit()
ans = 2019
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):
l,r = map(int,input().split())

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:
    print(0)
    exit()
ans = 2019
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: Time Limit Exceeded):
h,w = map(int,input().split())

s = [input() for _ in range(h)]
cnt = [[0] * w for _ in range(h)]

for i in range(h):
    done=[0] * w

    for j in range(w):
        if s[i][j] == '#': continue
        if done[j] :continue

        l = 0
        while j+l < w:
            if s[i][j+l] == '#': break
            l+=1

        for k in range(l):
            cnt[i][j+k] +=l
            done[j+k] = 1

for j in range(w):
    done=[0] * h

    for i in range(h):
        if s[i][j] == '#': continue
        if done[i] :continue

        l = 0
        while i+l < h:
            if s[i+l][j] == '#': break
            l+=1

        for k in range(l):
            cnt[i+k][j] +=l
            done[i+k] = 1

ans=0

for i in range(h):
    for j in range(w):
        ans = max(ans,cnt[i][j]-1)

print(ans)

Fixed submission:
h,w = map(int,input().split())

s = [input() for _ in range(h)]
cnt = [[0] * w for _ in range(h)]

for i in range(h):
    done=[0] * w

    for j in range(w):
        if s[i][j] == '#': continue
        if done[j] :continue

        l = 0
        while j+l < w:
            if s[i][j+l] == '#': break
            l+=1

        for k in range(l):
            cnt[i][j+k] +=l
            done[j+k] = 1

for j in range(w):
    done=[0] * h

    for i in range(h):
        if s[i][j] == '#': continue
        if done[i] :continue

        l = 0
        while i+l < h:
            if s[i+l][j] == '#': break
            l+=1

        for k in range(l):
            cnt[i+k][j] +=l
            done[i+k] = 1

ans=0

for i in range(h):
    for j in range(w):
        ans = max(ans,cnt[i][j]-1)

print(ans)