Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = list(map(int, input().split()))

for i in range(m):
    a_max = max(a)
    a_max_i = a.index(a_max)
    new = int(a_max / 2) if not a_max == 0 else 0
    a[a_max_i] = new

print(int(sum(a)))

Fixed submission:
import heapq

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

for i in range(m):
    a_min = heapq.heappop(a)
    heapq.heappush(a, int(a_min / 2))

print(-1 * sum(a))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for _ in range(n)]

for i in range(n):
    print(max(a[:i] + a[i+1:]))

Fixed submission:
n = int(input())
a = [int(input()) for _ in range(n)]

a_r = sorted(a, reverse=True)
for i in range(n):
    if a[i] == a_r[0]:
        print(a_r[1])
    else:
        print(a_r[0])
Buggy python submission (verdict: Runtime Error):
a, b, c, d = input().split()
a = int(a)#体力
b = int(b)
c = int(c)#体力
d = int(d)

x = a//d +1
y = c//b

if y == 1:
  if x <= y:
  	print("No")
  print("No")
else:
  print("Yes")

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

if a > b:
  print('safe')
else:
  print('unsafe')

Buggy python submission (verdict: Runtime Error):
a, b, c, d = input().split()
a = int(a)#体力
b = int(b)
c = int(c)#体力
d = int(d)

x = a//d +1
y = c//b

if y == 1:
  if x <= y:
  	print("NO")
  print("No")
else:
  print("Yes")
print(x,y)

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

if a > b:
  print('safe')
else:
  print('unsafe')
Buggy python submission (verdict: Runtime Error):
input_line = input()
b = int(input_line)
a = (1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51)
a_list = list(a)
print(a_list[b])

Fixed submission:
input_line = input()
b = int(input_line)
a = (1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51)
a_list = list(a)
print(a_list[b-1])
Buggy python submission (verdict: Runtime Error):
S = input() 
if == ('hi' or 'hihi' or 'hihihihi' or 'hihihihihi'):
  print('Yes')
else:
  print('No')

Fixed submission:
S = input() 
if (S == 'hi' or S == 'hihi' or S == 'hihihi' or S == 'hihihihi' or S == 'hihihihihi'):
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
S = set(input())
def i():
  if S = [AAA]
  print('No')
  elif S = [BBB]
  print('No')
  else:
    print('Yes')
  return

def i()

Fixed submission:
input_line = input()
X = str(input_line)
if (X) == ('AAA'):
  print('No')
elif (X) == ('BBB'):
    print('No')
else:
	print('Yes')
Buggy python submission (verdict: Runtime Error):
N = int(input())
if N % ==1:
  print(int(N/2+1))
elif N %  ==0:
  print(int(N/2))

Fixed submission:
N = int(input())

if N % 2 == 1:
  print(int(N/2+1))
elif N % 2 == 0:
  print(int(N/2))
Buggy python submission (verdict: Runtime Error):
N, R = map(int, input().split())
def a(N,R):
     if N >= 10:
             print(R)
     else:
             print(R+(100*(10-N)))
     return
  
a()

Fixed submission:
N, R = map(int, input().split())
def a(N,R):
     if N >= 10:
             print(R)
     else:
             print(R+(100*(10-N)))
     return
  
a(N,R)

Buggy python submission (verdict: Runtime Error):
def a(N,R):
     if N >= 10:
             print(R)
     else:
             print(R+(100*(10-K)))
     return

  
a(N,R)

Fixed submission:
N, R = map(int, input().split())
def a(N,R):
     if N >= 10:
             print(R)
     else:
             print(R+(100*(10-N)))
     return
  
a(N,R)
Buggy python submission (verdict: Runtime Error):
H, A = map(int, input().split())
H, A = int(H. A)
def a(H,A):
  if H/B <= 0:
    print(H//A+1)
  else:
    print(H/A)
    return

a(H,B)

Fixed submission:
H, A =map(int, input().split())
if H%A == 0:
  print(int(H/A))
else:
  print(H//A+1)
Buggy python submission (verdict: Runtime Error):
list = [T,S]
	setup.strip','
list

Fixed submission:
A, B = input().split()
C = B + A
print(C)

Buggy python submission (verdict: Runtime Error):
list = []
	print(T,S)
	setup.strip','

list

Fixed submission:
A, B = input().split()
C = B + A
print(C)

Buggy python submission (verdict: Runtime Error):
list = []
	setup.strip','
	print(T,S)
list



Fixed submission:
A, B = input().split()
C = B + A
print(C)

Buggy python submission (verdict: Runtime Error):
input = S
input = T
a = list[S,T]:
  print(a)

Fixed submission:
A, B = input().split()
C = B + A
print(C)
Buggy python submission (verdict: Runtime Error):
n = int(input())
for _ in range(n):
  a, b = map(int, input().split())
  
if a + b ==  3:
  print(3)
elif a + b == 4:
  print(2)
elif a+b == 5:
  print(1)
 


Fixed submission:
a = int(input())
b = int(input())
  
if a + b ==  3:
  print(3)
elif a + b == 4:
  print(2)
elif a+b == 5:
  print(1)
Buggy python submission (verdict: Runtime Error):
if X>= 30:
    print('yes')
else:
    print('no')


Fixed submission:
X = int(input())
if X>= 30:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
N, D = map(int, input().split())
ans = 0
for i in range(N):
    X, Y = map(int, input().split())

    d = X*X + Y*Y <= D*D:
        ans += 1
    
print(ans)

Fixed submission:
N, D = map(int, input().split())
ans = 0
for i in range(N):
    X, Y = map(int, input().split())

    if X*X + Y*Y <= D*D:
        ans += 1
    
print(ans)

Buggy python submission (verdict: Runtime Error):
N, D = map(int, input().split())
ans = 0
for i in range(N):
    X, Y = map(int, input().split())

    if X*X + Y*T <= D*D:
        ans += 1
    
print(ans)

Fixed submission:
N, D = map(int, input().split())
ans = 0
for i in range(N):
    X, Y = map(int, input().split())

    if X*X + Y*Y <= D*D:
        ans += 1
    
print(ans)

Buggy python submission (verdict: Runtime Error):
N, D = map(int,input().split())
P = [list(map(int,input().split())) for i in range(M)]
ans = 0
for i in range(N):
    num = P[N]
    X , Y = num
    if X*X + Y*Y <= D*D:
        ans += 1
print(ans)


Fixed submission:
N, D = map(int, input().split())
ans = 0
for l in range(N):
    X , Y = map(int,input().split())
    if X*X + Y*Y <= D*D:
        ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
D = int(input())
ans = 0
for i in range(N):
    X = int(input())
    Y = int(input())
    if X*X + Y*Y <= D*D:
        ans += 1
print(ans)


Fixed submission:
N, D = map(int, input().split())
ans = 0
for l in range(N):
    X , Y = map(int,input().split())
    if X*X + Y*Y <= D*D:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
var=n;

cin>>n;

print(n*n*n)

Fixed submission:
n = int(input())

print(n*n*n)
Buggy python submission (verdict: Runtime Error):
import math


def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N, M = map(int, input().split())
if M < 2:
    Count = comb(N, 2)
elif N < 2:
    Count = comb(M, 2)
else:
    Count = comb(N, 2) + comb(M, 2)
print(Count)



Fixed submission:
import math


def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N, M = map(int, input().split())
if M < 2 and N < 2:
    Count = 0
elif M < 2:
    Count = comb(N, 2)
elif N < 2:
    Count = comb(M, 2)
else:
    Count = comb(N, 2) + comb(M, 2)
print(Count)

Buggy python submission (verdict: Runtime Error):
from scipy.special import comb
N, M = map(int, input().split())
if M < 2:
    Count = comb(N, 2, exact=True)
elif N < 2:
    Count = comb(M, 2, exact=True)
else:
    Count = comb(N, 2, exact=True) + comb(M, 2, exact=True)
print(Count)



Fixed submission:
import math


def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N, M = map(int, input().split())
if M < 2 and N < 2:
    Count = 0
elif M < 2:
    Count = comb(N, 2)
elif N < 2:
    Count = comb(M, 2)
else:
    Count = comb(N, 2) + comb(M, 2)
print(Count)

Buggy python submission (verdict: Runtime Error):
from scipy.special import comb
N, M = map(int, input().split())
if M < 2:
    Count = comb(N, 2, exact=True)
elif N < 2:
    Count = comb(M, 2, exact=True)
else:
    Count = comb(N, 2, exact=True) + comb(M, 2, exact=True)
print(Count)



Fixed submission:
import math


def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N, M = map(int, input().split())
if M < 2 and N < 2:
    Count = 0
elif M < 2:
    Count = comb(N, 2)
elif N < 2:
    Count = comb(M, 2)
else:
    Count = comb(N, 2) + comb(M, 2)
print(Count)
Buggy python submission (verdict: Time Limit Exceeded):
import math

n = int(input())
ans = 0
x = int(math.ceil(math.sqrt(n)))

for i in range(1, x+1):
    j=i
    while i*j<=n:
        if i*j == n and (i+j-2 < ans or ans == 0):
            ans = i+j-2
            break
        j+=1

print(ans)



Fixed submission:
import math

n = int(input())
ans = n-1
x = int(math.ceil(math.sqrt(n)))

for i in range(1, x+1):
    if n%i == 0:
        ans = int(min(ans, i+n/i-2))

print(ans)

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

l=1
f=False
while True:
    j=l+1
    for i in range(1,l+1):
        if n == i*(j-i):
            print(j-2)
            f=True
            break
    l+=1
    if f:
        break


Fixed submission:
import math

n = int(input())
ans = n-1
x = int(math.ceil(math.sqrt(n)))

for i in range(1, x+1):
    if n%i == 0:
        ans = int(min(ans, i+n/i-2))

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
v = input()
v = [int(x.strip()) for x in v.split(" ")]
n = v[0]
q = v[1]

p = [[0]*2]*(n-1)
for i in range(n-1):
    v=input()
    p[i] = [int(x.strip()) for x in v.split(" ")]

c = [0] * n

def func(s, y):
    c[s] += y
    for i in range(len(p)):
        if p[i][0] == s+1:
            func(p[i][1]-1,y)
    return

x = [[0]*2]*q
for i in range(q):
    v=input()
    x[i] = [int(a.strip()) for a in v.split(" ")]
    func(x[i][0]-1,x[i][1])

print(' '.join(map(str, c)))


Fixed submission:
import collections

n,q = map(int, input().split())
cnt = [0] * (n+1)
g = [[] for _ in range(n+1)]

for _ in range(n-1):    #隣接リストの生成
    a,b = map(int, input().split())
    g[a].append(b)
    g[b].append(a)

for _ in range(q):
    v,val = map(int, input().split())
    cnt[v] += val

q = collections.deque()
q.append(1)
checked = [0]*(n+1)

while q:
    v = q.pop()
    checked[v] = 1
    for u in g[v]:
        if checked[u] == 1:
            continue
        cnt[u] += cnt[v]
        q.append(u)
print(*cnt[1:])
Buggy python submission (verdict: Time Limit Exceeded):
l,r = map(int, input().split())
ans = 2019

for i in range(l, r):
    for j in range(i+1, r+1):
        a = (i * j) % 2019
        if ans > a:
            ans = a
        if a == 0:
            break

print(ans)


Fixed submission:
l,r = map(int, input().split())
ans = 2019

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

print(ans)
Buggy python submission (verdict: Runtime Error):
val = input()
val = [int(x.strip()) for x in val.split(" ")]
h = val[0]
w = val[1]

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

ans = "Yes"

for i in range(h):
    for j in range(w):
        d = 0
        if s[i][j] == ".":
            continue

        if i > 0:
            if s[i-1][j] == "#":
                d += 1

        if i < h-1:
            if s[i+1][j] == "#":
                d += 1

        if j > 0:
            if s[i][j-1] == "#":
                d += 1

        if j < h-1:
            if s[i][j+1] == "#":
                d += 1
        
        if d == 0:
            ans = "No"
            break
    if ans == "No":
        break

print(ans)


Fixed submission:
val = input()
val = [int(x.strip()) for x in val.split(" ")]
h = val[0]
w = val[1]

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

ans = "Yes"

for i in range(h):
    for j in range(w):
        d = 0
        if s[i][j] == ".":
            continue

        if i > 0:
            if s[i-1][j] == "#":
                d += 1

        if i < h-1:
            if s[i+1][j] == "#":
                d += 1

        if j > 0:
            if s[i][j-1] == "#":
                d += 1

        if j < w-1:
            if s[i][j+1] == "#":
                d += 1
        
        if d == 0:
            ans = "No"
            break
    if ans == "No":
        break

print(ans)
Buggy python submission (verdict: Runtime Error):
from sympy import *

n = int(input())
l = list()
a = 0
i = 0
while i < n:
    a = nextprime(a)
    if a % 5 != 1:
        continue 
    l.append(a)
    i += 1

print(l)

Fixed submission:
#from sympy import *

def prime(x):
    i = x
    while True:
        f = False
        j = 2
        while i > j:
            if i % j == 0:
                f = True
                break
            j += 1
        if f == False:
            break
        i += 1
    return i


n = int(input())
l = list()
a = 6
i = 0
while i < n:
    a = prime(a+1)
    if a % 5 != 1:
        continue 
    l.append(a)
    i += 1

print(' '.join(map(str, l)))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split()]

a.sort()

MAXN = 2 * 10 ** 5


def prime_factorization(n):
    pmax = int(n ** 0.5 // 1) + 1

    factors = {}
    for p in range(2, pmax + 1):
        while n % p == 0:
            factors[p] = factors.get(p, 0) + 1
            n //= p
    if n != 1:
        factors[n] = factors.get(n, 0) + 1

    return factors


divisors = [False for _ in range(MAXN + 1)]
answer = 0
apast = None
for i, ai in enumerate(a):
    if ai == apast:
        is_good = False
    elif i < n - 1 and ai == a[i + 1]:
        is_good = False
    else:
        is_good = not divisors[ai]

        m = 1
        while ai * m <= MAXN:
            divisors[m * ai] = True
            m += 1

        # factors = prime_factorization(ai)
        # factors[1] = 1
        # for p, m in factors.items():
        #     pm = 1
        #     for i in range(m):
        #         p *=
        #         if p ** (i + 1) in divisors:
        #             is_good = False
        #             break
        #     if not is_good:
        #         break

    if is_good:
        answer += 1

    apast = ai


print(answer)


Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]

a.sort()

MAXN = a[-1]


divisors = [False for _ in range(MAXN + 1)]
answer = 0
apast = None
for i, ai in enumerate(a):
    if ai == apast:
        is_good = False
    elif i < n - 1 and ai == a[i + 1]:
        is_good = False
        m = 1
        while m * ai <= MAXN:
            divisors[m * ai] = True
            m += 1
    else:
        is_good = not divisors[ai]

        m = 1
        while m * ai <= MAXN:
            divisors[m * ai] = True
            m += 1

    if is_good:
        answer += 1

    apast = ai


print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(i) for i in input().split()]

m = 1
for i in a:
    m *= i

if m > 10 ** 18:
    print(-1)
else:
    print(m)


Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]

a.sort(reverse=True)


if a[-1] == 0:
    print(0)
else:
    m = 1

    for i in a:
        m *= i
        if m > 10 ** 18:
            break

    if m > 10 ** 18:
        print(-1)
    else:
        print(m)
Buggy python submission (verdict: Runtime Error):
MOD = 1000000007

n = int(input())

# la = []
# lb = []
# for _ in range(n):
#     a, b = map(int, input().split())
#     la.append(a)
#     lb.append(b)


def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


def normalize(a, b):
    g = gcd(abs(a), abs(b))
    a //= g
    b //= g

    if a < 0:
        a *= -1
        b *= -1

    if a != 0 and b == 0:
        a, b = 1, 0
    if a == 0 and b != 0:
        a, b = 0, 1

    return a, b


dv = {}
for _ in range(n):
    a, b = map(int, input().split())
    a, b = normalize(a, b)
    dv[(a, b)] = dv.get((a, b), 0) + 1


counted = {k: False for k in dv.keys()}
nc = 1
for k, v in dv.items():
    if not counted[k]:
        a0, b0 = k
        a1, b1 = normalize(b0, -a0)
        w = dv.get((a1, b1), 0)

        nc *= 1 + (2 ** v - 1) + (2 ** w - 1)
        nc %= MOD

        counted[(a0, b0)] = True
        counted[(a1, b1)] = True

nc -= 1
print(nc)


Fixed submission:
MOD = 1000000007


def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


def normalize(a, b):
    if a == 0 and b == 0:
        return 0, 0
    elif a != 0 and b == 0:
        return 1, 0
    elif a == 0 and b != 0:
        return 0, 1
    else:
        g = gcd(abs(a), abs(b))
        a //= g
        b //= g
        if a < 0:
            a *= -1
            b *= -1
        return a, b


def rotate(a, b):
    if b > 0:
        return b, -a
    else:
        return -b, a


n = int(input())
dv = {}
for _ in range(n):
    a, b = map(int, input().split())
    a, b = normalize(a, b)
    dv[(a, b)] = dv.get((a, b), 0) + 1


counted = {k: False for k in dv.keys()}
nc = 1
for k, v in dv.items():
    if not counted[k]:
        if k != (0, 0):
            a0, b0 = k
            a1, b1 = rotate(a0, b0)
            w = dv.get((a1, b1), 0)

            nc *= 1 + (pow(2, v, MOD) - 1) + (pow(2, w, MOD)- 1)
            nc %= MOD

            # counted[(a0, b0)] = True
            counted[(a1, b1)] = True


nc += dv.get((0, 0), 0)

nc -= 1
nc %= MOD
print(nc)
Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce

MOD = 10 ** 9 + 7

_ = int(input())
la = list(map(int, input().split()))


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


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


def addmod(a, b):
    return (a + b) % MOD


l = reduce(lcm, la)
answer = reduce(addmod, (l // a for a in la))
print(answer)


Fixed submission:
from functools import reduce
from math import gcd

MOD = 10 ** 9 + 7

_ = int(input())
la = list(map(int, input().split()))


def inv(a):
    return pow(a, MOD - 2, MOD)


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


def addmod(a, b):
    return (a + b) % MOD


l = reduce(lcm, la) % MOD
answer = reduce(addmod, (l * inv(a) for a in la), 0)
print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
MOD = 10 ** 9 + 7

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


def prime_factorization(n):
    pmax = int(n ** 0.5 // 1) + 1

    factors = {}
    for p in range(2, pmax + 1):
        while n % p == 0:
            factors[p] = factors.get(p, 0) + 1
            n //= p
    if n != 1:
        factors[n] = factors.get(n, 0) + 1

    return factors

lf = [prime_factorization(a) for a in la]


lcm_factors = {}

for factors in lf:
    for p, m in factors.items():
        lcm_factors[p] = max(lcm_factors.get(p, 0), m)

s = 0
for factors in lf:
    b = 1
    for p, m in lcm_factors.items():
        b *= p ** (m - factors.get(p, 0))
        b %= MOD
    s += b
    s %= MOD

print(s)


Fixed submission:
from functools import reduce
from math import gcd

MOD = 10 ** 9 + 7

_ = int(input())
la = list(map(int, input().split()))


def inv(a):
    return pow(a, MOD - 2, MOD)


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


def addmod(a, b):
    return (a + b) % MOD


l = reduce(lcm, la) % MOD
answer = reduce(addmod, (l * inv(a) for a in la), 0)
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product

h, w = map(int, input().split())
maze = [input() for _ in range(h)]


def neighbors(ih, iw):
    for ih1, iw1 in (
        (ih - 1, iw),
        (ih + 1, iw),
        (ih, iw - 1),
        (ih, iw + 1),
    ):
        if 0 <= ih1 < h and 0 <= iw1 < w and maze[ih1][iw1] == '.':
            yield (ih1, iw1)



def len_maze(ih, iw):
    # BFS
    if maze[ih][iw] == '#':
        return 0

    stepped = [[False] * w for _ in range(h)]
    q0 = [(ih, iw)]
    l = -1
    while q0:
        q1 = []
        for ih0, iw0 in q0:
            stepped[ih0][iw0] = True
            for ih1, iw1 in neighbors(ih0, iw0):
                if not stepped[ih1][iw1]:
                    q1.append((ih1, iw1))
        q0 = q1
        l += 1

    return l


answer = max(len_maze(ih, iw) for ih, iw in product(range(h), range(w)))
print(answer)


Fixed submission:
from itertools import product

h, w = map(int, input().split())
maze = [input() for _ in range(h)]


def neighbors(ih, iw):
    for ih1, iw1 in (
        (ih - 1, iw),
        (ih + 1, iw),
        (ih, iw - 1),
        (ih, iw + 1),
    ):
        if 0 <= ih1 < h and 0 <= iw1 < w and maze[ih1][iw1] == '.':
            yield (ih1, iw1)



def len_maze(ih, iw):
    # BFS
    if maze[ih][iw] == '#':
        return 0

    stepped = [[False] * w for _ in range(h)]
    q0 = [(ih, iw)]
    l = -1
    while q0:
        q1 = set()
        for ih0, iw0 in q0:
            stepped[ih0][iw0] = True
            for ih1, iw1 in neighbors(ih0, iw0):
                if not stepped[ih1][iw1]:
                    q1.add((ih1, iw1))
        q0 = list(q1)
        l += 1

    return l


answer = max(len_maze(ih, iw) for ih, iw in product(range(h), range(w)))
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product

h, w = map(int, input().split())
iswall = []
for _ in range(h):
    s = input()
    iswall.append([int(c == '#') for c in s])


def getll():
    ls = [[None] * w for _ in range(h)]
    for ih in range(h):
        l = 0
        for iw in range(w):
            if not iswall[ih][iw]:
                l += 1
            else:
                l = 0
            ls[ih][iw] = l
    return ls


def getlr():
    ls = [[None] * w for _ in range(h)]
    for ih in range(h):
        l = 0
        for iw in range(w - 1, -1, -1):
            if not iswall[ih][iw]:
                l += 1
            else:
                l = 0
            ls[ih][iw] = l
    return ls


def getlu():
    ls = [[None] * w for _ in range(h)]
    for iw in range(w):
        l = 0
        for ih in range(h):
            if not iswall[ih][iw]:
                l += 1
            else:
                l = 0
            ls[ih][iw] = l
    return ls


def getld():
    ls = [[None] * w for _ in range(h)]
    for iw in range(w):
        l = 0
        for ih in range(h - 1, -1, -1):
            if not iswall[ih][iw]:
                l += 1
            else:
                l = 0
            ls[ih][iw] = l
    return ls


ll = getll()
lr = getlr()
lu = getlu()
ld = getld()

m = 0
for ih, iw in product(range(h), range(w)):
    light = ll[ih][iw] + lr[ih][iw] + lu[ih][iw] + ld[ih][iw] - 3
    m = max(m, light)

print(m)



Fixed submission:
from itertools import product
import numpy as np

h, w = map(int, input().split())
notwall = []
for _ in range(h):
    s = input()
    notwall.append([int(c == '.') for c in s])

notwall = np.array(notwall)


def getll():
    ls = np.zeros((h, w + 1), dtype=int)

    for i in range(w):
        ls[:, i + 1] = (ls[:, i] + 1) * notwall[:, i]

    ls = ls[:, 1:]
    return ls


def getlr():
    ls = np.zeros((h, w + 1), dtype=int)

    for i in range(w - 1, -1, -1):
        ls[:, i] = (ls[:, i + 1] + 1) * notwall[:, i]

    ls = ls[:, :-1]
    return ls


def getlu():
    ls = np.zeros((h + 1, w), dtype=int)

    for i in range(h):
        ls[i + 1, :] = (ls[i, :] + 1) * notwall[i, :]

    ls = ls[1:, :]
    return ls


def getld():
    ls = np.zeros((h + 1, w), dtype=int)

    for i in range(h - 1, -1, -1):
        ls[i, :] = (ls[i + 1, :] + 1) * notwall[i, :]

    ls = ls[:-1, :]
    return ls


ll = getll()
lr = getlr()
lu = getlu()
ld = getld()

m = max([0, np.max(ll + lr + lu + ld) - 3])

print(m)