Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
p = [int(i) for i in input().split()]

a = [30000*i for i in range(n)]
b = [30000*(n-i) for i in range(n)]

for i,v in enumerate(p):
    a[v] += i

print(*a)
print(*b)

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

a = [30000*i for i in range(n)]
b = [30000*(n-i) for i in range(n)]

for i,v in enumerate(p):
    a[v-1] += i+1

print(*a)
print(*b)
Buggy python submission (verdict: Runtime Error):
n,x = [int(i) for i in input().split()]
a = [i for i in range(1,2*n)]

def swap(a,i,j):
    b = a[i]
    a[i] = a[j]
    a[j] = b

if x==1 or x==2*n -1:
    print("No")
else:
    print("Yes")
    if x==n:
        pass
    elif x>n:
        swap(a,n-1,x-1)
        swap(a,x,2*n-2)
        swap(a,x+1,0)
    else:
        swap(a,n-1,x-1)
        swap(a,x-2,0)
        swap(a,x-3,2*n-2)
    for i in a:
        print(i)

Fixed submission:
n,x = [int(i) for i in input().split()]
a = [i for i in range(1,2*n)]

def swap(a,i,j):
    b = a[i]
    a[i] = a[j]
    a[j] = b

if x==1 or x==2*n -1:
    print("No")
else:
    print("Yes")
    if x==n:
        pass
    elif x>n:
        swap(a,n-1,x-1)
        swap(a,n,2*n-2)
        swap(a,n+1,0)
    else:
        swap(a,n-1,x-1)
        swap(a,n-2,0)
        swap(a,n-3,2*n-2)
    for i in a:
        print(i)
Buggy python submission (verdict: Runtime Error):
a,b,c = [int(i) for i in input().split()]
if (a*b*c)%2==0:
    print(0)
else:
    ans = a*b
    ans = min(ans, b*c)
    ans = min(aans, c*a)
    print(ans)

Fixed submission:
a,b,c = [int(i) for i in input().split()]
if (a*b*c)%2==0:
    print(0)
else:
    ans = a*b
    ans = min(ans, b*c)
    ans = min(ans, c*a)
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#b faster
#m_i(k) = min(m_i(k-1), a_(i-k))
n,x =  [int(i) for i in input().split()]
a   =  [int(i) for i in input().split()]
m   =  a[::]
a.extend(a)

min_cost = 10**10

for k in range(n):
    cost = x * k
    for i in range(n,2*n):
        mini = min(m[i-n], a[i-k])
        m[i-n] = mini
        cost += mini
    min_cost = min(min_cost, cost)
print(min_cost)

Fixed submission:
#b faster
#m_i(k) = min(m_i(k-1), a_(i-k))
# http://agc004.contest.atcoder.jp/data/agc/004/editorial.pdf
n,x =  [int(i) for i in input().split()]
a   =  [int(i) for i in input().split()]
m   =  a[::]
a.extend(a)

min_cost = sum(a)

for k in range(n):
    #cost = x * k
    for i in range(n,2*n):
        m[i-n] = min(m[i-n], a[i-k])
        #cost += mini
    min_cost = min(min_cost, x*k + sum(m))
print(min_cost)

Buggy python submission (verdict: Time Limit Exceeded):
#b
n,x =  [int(i) for i in input().split()]
a   =  [int(i) for i in input().split()]
a.extend(a)

min_cost = 10**10
for k in range(n):
    cost = x * k
    for i in range(k,k+n):
        mini = min(a[i-k:i+1])
        cost += mini
    min_cost = min(min_cost, cost)
print(min_cost)

Fixed submission:
#b faster
#m_i(k) = min(m_i(k-1), a_(i-k))
# http://agc004.contest.atcoder.jp/data/agc/004/editorial.pdf
n,x =  [int(i) for i in input().split()]
a   =  [int(i) for i in input().split()]
m   =  a[::]
a.extend(a)

min_cost = sum(a)

for k in range(n):
    #cost = x * k
    for i in range(n,2*n):
        m[i-n] = min(m[i-n], a[i-k])
        #cost += mini
    min_cost = min(min_cost, x*k + sum(m))
print(min_cost)
Buggy python submission (verdict: Runtime Error):
n, x = [int(i) for i in input().split()]

cnt=0

short = n%x
long  = x

cnt += x*(2*(n//x)-1) + (n-x)

while(1):
    c = long % short
    a = long //short
    if c==0:
        break
    else:
        cnt += short * 2 * a
        long = short
        short = c

cnt += short * 2 * a -1
print(cnt)


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

cnt=0

short = min(x,n-x)
long  = max(x, n-x)
cnt += n
#cnt += x*(2*(n//x)-1) + (n-x)

while(1):
    c = long % short
    a = long //short
    if c==0:
        break
    else:
        cnt += short * 2 * a
        long = short
        short = c

cnt += short * (2 * a -1)
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n = input()
n = int(n)
a = input().split()
b = 1
for i in a:
    b *= int(i)
if (b > 1000000000000000000):
    print ("-1")
else:
    print (b)


Fixed submission:
n = input()
n = int(n)
a = input().split()
b = 1
if '0' in a:
    print ("0")
else:
    for i in a:
        b *= int(i)
        if (b > 1000000000000000000):
            print ("-1")
            break
    if (b <= 1000000000000000000):
        print (b)
Buggy python submission (verdict: Time Limit Exceeded):
x, k, d = map(int, input().split())
mind = 1000000000000000
c = 0
while k > 0:
    k -= 1
    if abs(x - d - 0) <= abs(x + d - 0):
        x -= d
    else:
        x += d
    if abs(x) == mind:
        break
    mind = min(mind, abs(x))

if k%2 == 0 or k == 0:
    print(abs(mind - 0))
else:
    mind = min(abs(mind + d - 0), abs(mind - d - 0))
    print(mind)
    

Fixed submission:
x, k, d = map(int, input().split())
x = abs(x)
if (x - k*d) >= 0:
    x -= k*d
else:
    k -= int(x/d)
    x -= int(x/d) * d
    if (k%2) != 0:
        x -= d 
print(abs(x))

Buggy python submission (verdict: Time Limit Exceeded):
x, k, d = map(int, input().split())
mind = 1000000000000000
c = 0
while k > 0:
    k -= 1
    if abs(x - d - 0) <= abs(x + d - 0):
        x -= d
    else:
        x += d
    if x == mind:
        break
    mind = min(mind, abs(x))

if k%2 == 0 or k == 0:
    print(abs(mind - 0))
else:
    mind = min(abs(mind + d - 0), abs(mind - d - 0))
    print(mind)
    

Fixed submission:
x, k, d = map(int, input().split())
x = abs(x)
if (x - k*d) >= 0:
    x -= k*d
else:
    k -= int(x/d)
    x -= int(x/d) * d
    if (k%2) != 0:
        x -= d 
print(abs(x))
Buggy python submission (verdict: Runtime Error):
import math

n = int(input())
ans = [gcd(i+1, gcd(j+1, k+1)) for i in range(n) for j in range(n) for k in range(n)]
print(sum(ans))

Fixed submission:
import math

n = int(input())
ans = [math.gcd(i+1, math.gcd(j+1, k+1)) for i in range(n) for j in range(n) for k in range(n)]
print(sum(ans))

Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
from collections import Counter

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

n = int(input())
ans = ["-".join([str(i+1), str(j+1), str(k+1)])  for i in range(n) for j in range(n) for k in range(n)]
counts = Counter(ans)
ans = [gcd(int(k.split("-")[0]), int(k.split("-")[1]), int(k.split("-")[2])) * v for k, v in counts.items()]
print(sum(ans))

Fixed submission:
import math

n = int(input())
ans = [math.gcd(i+1, math.gcd(j+1, k+1)) for i in range(n) for j in range(n) for k in range(n)]
print(sum(ans))
Buggy python submission (verdict: Runtime Error):
s, t = map(str, input().split())
out = [si+ti for si, ti in zip(s, t)]
print("".join(out))

Fixed submission:
n = input()
s, t = map(str, input().split())
out = [si+ti for si, ti in zip(s, t)]
print("".join(out))
Buggy python submission (verdict: Runtime Error):
x = [int(i) for i in input().split()]
x = sorted(x)
cost = 0
for i in range(1, 3):
    cost += abs(x[i] - x[i-1])
print(costs)

Fixed submission:
x = [int(i) for i in input().split()]
x = sorted(x)
cost = 0
for i in range(1, 3):
    cost += abs(x[i] - x[i-1])
print(cost)
Buggy python submission (verdict: Runtime Error):
#template
def inputlist(): return [int(j) for j in input().split()]
#template
N,K = inputlist()
A = inputlist()
left = -1
right = 10**9+1
while right - left > 1:
    mid = (left+right)//2
    count = 0
    for i in range(N):
        count += A[i]//mid
        if A[i] % mid == 0:
            count -=1
    if count > K:
        left = mid
    else:
        right = mid
print(right)

Fixed submission:
#template
def inputlist(): return [int(j) for j in input().split()]
#template
N,K = inputlist()
A = inputlist()
left = 0
right = 10**9+1
while right - left > 1:
    mid = (left+right)//2
    count = 0
    for i in range(N):
        count += A[i]//mid
        if A[i] % mid == 0:
            count -=1
    if count > K:
        left = mid
    else:
        right = mid
print(right)
Buggy python submission (verdict: Time Limit Exceeded):
#template
def inputlist(): return [int(j) for j in input().split()]
#template
A,B,C = inputlist()
K = int(input())
count = 0
while count < K:
    if A > B:
        B = 2*B
        count +=1
        continue
    if B > C:
        C = 2*C
        count +=1
        continue
    if A < B<C:
        print("Yes")
        exit()
if A < B < C:
    print("Yes")
else:
    print("No")

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

ans = 'No'
for i in range(k+1):
  if a < b*(2**i) < c*(2**(k-i)):
    ans = 'Yes'
    
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
ans = [0]*(N+1)
for x in range(1,80):
    for y in range(1,80):
        for z in range(1,80):
            tmp = x**2 + y**2 + z**2 +x*y + y*z + z*x
            if tmp > N:
                continue
            ans[tmp]+=1
for i in range(1,N+1):
    print(ans[i])


Fixed submission:
#template
def inputlist(): return [int(j) for j in input().split()]
#template
L,R,d = inputlist()
count = 0
for i in range(L,R+1):
    if i % d == 0:
        count +=1
print(count)
Buggy python submission (verdict: Runtime Error):
li = [int(i) for i in input().split()]
for i in range(5):
	if li[i] == 0:
    		print(i+1)
            exit()

Fixed submission:
#template
def inputlist(): return [int(j) for j in input().split()]
#template
li = inputlist()
for i in range(5):
    if li[i] == 0:
        print(i+1)
Buggy python submission (verdict: Time Limit Exceeded):
#template
def inputlist(): return [int(k) for k in input().split()]
#template
N = int(input())
S = list(input())
from collections import Counter
c = Counter(S)
ans = c['R']*c['B']*c['G']
for i in range(N-1):
    for j in range(i+1,N):
        if 2*j - i >= N:
            continue
        se = [S[i],S[j],S[2*j-i]]
        se = set(se)
        if len(se) == 3:
            ans -=1

print(ans)

Fixed submission:
#template
def inputlist(): return [int(k) for k in input().split()]
#template
N = int(input())
S = list(input())
from collections import Counter
c = Counter(S)
ans = c['R']*c['B']*c['G']
for i in range(N-1):
    for j in range(i+1,N):
        if 2*j - i >= N:
            continue
        se = [S[i],S[j],S[2*j-i]]
        se = set(se)
        if len(se) == 3:
            ans -=1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
count = 0
from collections import deque
q1 = deque()
q2 = deque()
for i in range(Q):
    li = input().split()
    if len(li) == 1:
        count +=1
        q11 = q1
        q22 = q2
        q1 = q22
        q2 = q11
        q1.reverse()
        q2.reverse()
    if len(li) == 3:
        if li[1] == '1':
            q1.appendleft(li[2])
        if li[1] == '2':
            q2.append(li[2])
s1 = ''.join(list(q1))
s2 = ''.join(list(q2))
if count % 2 == 1:
    K = reversed(list(S))
    S = ''.join(K)
print(s1+S+s2)

Fixed submission:
S = input()
Q = int(input())
count = 0
from collections import deque
q1 = deque()
q2 = deque()
for i in range(Q):
    li = input().split()
    if len(li) == 1:
        count +=1
        q11 = q1
        q22 = q2
        q1 = q22
        q2 = q11
    if len(li) == 3:
        if li[1] == '1':
            if count % 2 == 1:
                q1.append(li[2])
            if count % 2 == 0:
                q1.appendleft(li[2])
        if li[1] == '2':
            if count % 2 == 1:
                q2.appendleft(li[2])
            if count % 2 == 0:
                q2.append(li[2])
s1 = ''.join(list(q1))
s2 = ''.join(list(q2))
if count % 2 == 1:
    K = reversed(list(S))
    S = ''.join(K)
    s1 = ''.join(reversed(list(s1)))
    s2 = ''.join(reversed(list(s2)))
print(s1+S+s2)
Buggy python submission (verdict: Time Limit Exceeded):
mod = 10**9+7
n,a,b = [int(i) for i in input().split()]
k = min(n,2*(10**5))
def pow_k(x, n):
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2

    return (K * x - 1) % mod
def modinv(a, mod):
    return pow(a, mod-2, mod)
def combination_list(n, mod):
    lst = [1]
    for i in range(1, k+1):
        lst.append(lst[-1] * (n+1-i) % mod * modinv(i, mod) % mod)
    return lst
ans = pow_k(2,n)
cmb = combination_list(n,mod)
ans %= mod
ans -= cmb[a]
if ans < 0:
    ans += mod
ans -= cmb[b]
if ans <0:
    ans += mod
print(ans)

Fixed submission:
mod = 10**9+7
n,a,b = [int(i) for i in input().split()]
k = min(n,2*(10**5))
import sys
sys.setrecursionlimit(100000000)
def pow_k(a,n,mod):
    if n == 0:
        return 1
    if n % 2 ==0:
        return pow_k(a*a % mod,n//2,mod)
    else:
        return a * pow_k(a,n-1,mod) % mod
def modinv(a, mod):
    return pow(a, mod-2, mod)
def combination_list(n, mod):
    lst = [1]
    for i in range(1, k+1):
        lst.append(lst[-1] * (n+1-i) % mod * modinv(i, mod) % mod)
    return lst
ans = pow_k(2,n,mod)
cmb = combination_list(n,mod)
ans -=1
ans -= cmb[a]
if ans < 0:
    ans += mod
ans -= cmb[b]
if ans <0:
    ans += mod
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input() #alphabet hitotsu sakino moji
print(chr(ord(s) + 1)

Fixed submission:
s = input()
print(chr(ord(s) + 1))
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
X = int(input())
import sympy
from sympy import nextprime
print(nextprime(X))

Fixed submission:
import sys
input = sys.stdin.readline
import math
def get_primenumber(number):
    prime_list = []
    #2からnumberまでの数字をsearch_listに入れる
    search_list = list(range(2,number+1))
    while True:
      #search_listの先頭の値が√nの値を超えたら処理終了
      if search_list[0] > math.sqrt(number):
        #prime_listにsearch_listを結合
        prime_list.extend(search_list)
        break
      else:
        #search_listの先頭をprime_listに入れる
        head_num = search_list[0]
        prime_list.append(head_num)
        #search_listの先頭をpopする
        search_list.pop(0)
        #head_numの倍数を取り除く
        search_list = [num for num in search_list if num % head_num != 0]
    return prime_list
X = int(input())
K = 0
li = get_primenumber(100010)
for i in range(len(li)) :
    if li[i] >= X :
        K = li[i]
        break
print(K)
Buggy python submission (verdict: Time Limit Exceeded):
#template
def inputlist(): return [int(j) for j in input().split()]
#template
#issueから始める
N = int(input())
L = inputlist()
L.sort()
ans = 0
from bisect import bisect_left
for i in range(N-2):
    for j in range(i+1,N-1):
        lia = L[j+1:]
        indexa = bisect_left(lia,L[i]+L[j])
        ans += indexa
print(ans)


Fixed submission:
#template
def inputlist(): return [int(j) for j in input().split()]
from collections import Counter
#template
#issueから始める
N = int(input())
L = inputlist()
L.sort()
ans = 0
from bisect import bisect_left
for i in range(N-2):
    for j in range(i+1,N-1):
        lia = L[j+1:]
        indexa = bisect_left(lia,L[i]+L[j])
        ans += indexa
print(ans)
Buggy python submission (verdict: Runtime Error):
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])

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

    return arr
A,B = [int(i) for i in input().split()]
ans = 1
lia = factorization(A)
lib = factorization(B)
na = len(lia)
nb = len(lib)
a = [0] * na
b = [0] * nb
for i in range(na):
    a[i] = lia[i][0]
for i in range(nb):
    b[i] = lib[i][0]
M = max(a[-1],b[-1])
li = [0] * (M+10)
for i in range(na):
    li[a[i]] +=1
for i in range(nb):
    li[b[i]] +=1
for i in range(2,M+1):
    if li[i] == 2:
        ans+=1
print(ans)

Fixed submission:
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])

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

    return arr
A,B = [int(i) for i in input().split()]
if A == 1 and B==1:
    print(1)
else:
    ans = 1
    lia = factorization(A)
    lib = factorization(B)
    na = len(lia)
    nb = len(lib)
    a = [0] * na
    b = [0] * nb
    for i in range(na):
        a[i] = lia[i][0]
    for i in range(nb):
        b[i] = lib[i][0]
    a_ = set(a)
    b_ = set(b)
    if na >= nb:
        for i in range(nb):
            if b[i] in a_:
                ans+=1
        print(ans)
        exit()
    else:
        for i in range(na):
            if a[i] in b_:
                ans+=1
        print(ans)
        exit()
Buggy python submission (verdict: Time Limit Exceeded):
#template
def inputlist(): return [int(k) for k in input().split()]
#template
mod = 10**9+7
S = list(input())
n = len(S)
#桁dp
dp = [[0]*(13) for _ in range(n+1)]
if S[0] == '?':
    for i in range(10):
        dp[1][i] = 1
if S[0] != '?':
    dp[1][int(S[0])] = 1
for i in range(1,n):
    i+=1
    if S[i-1] == '?':
        for m in range(13):
            for j in range(10):
                dp[i][(10*m+j)%13] += dp[i-1][m]
                dp[i][(10*m+j)%13] %= mod
        continue
    if S[i-1] != '?':
        for m in range(13):
            dp[i][(10*m+int(S[i-1]))%13] += dp[i-1][m]
            dp[i][(10*m+int(S[i-1]))%13] %= mod
dp[n][5] %= mod
print(dp[n][5])

Fixed submission:
#template
def inputlist(): return [int(k) for k in input().split()]
#template
mod = 10**9+7
S = list(input())
n = len(S)
#桁dp
dp = [[0]*(13) for _ in range(n+1)]
if S[0] == '?':
    for i in range(10):
        dp[1][i] = 1
if S[0] != '?':
    dp[1][int(S[0])] = 1
for i in range(1,n):
    i+=1
    if S[i-1] == '?':
        for m in range(13):
            for j in range(10):
                dp[i][(10*m+j)%13] += dp[i-1][m]
                dp[i][(10*m+j)%13] %= mod
        continue
    if S[i-1] != '?':
        for m in range(13):
            dp[i][(10*m+int(S[i-1]))%13] += dp[i-1][m]
            dp[i][(10*m+int(S[i-1]))%13] %= mod
dp[n][5] %= mod
print(dp[n][5])
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]
for i in range(N):
    A[i] *= 2
import numpy as np
mat = [[0] * N for _ in range(N)]
for i in range(N):
    j = i + 1
    if j == N:
        j = 0
    mat[i][i] = 1
    mat[i][j] = 1
AB = np.array(mat)
inv_A = np.linalg.inv(AB)
ans = list(np.dot(inv_A,A))
for i in range(N):
    ans[i] = int(ans[i])
print(*ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[sum(a)-2*sum(a[1:n-1:2])]
for i in range(1,n):
  b.append(2*a[i-1]-b[-1])
print(*b)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]
for i in range(N):
    A[i] *= 2
import numpy as np
mat = [[0] * N for _ in range(N)]
for i in range(N):
    j = i + 1
    if j == N:
        j = 0
    mat[i][i] = 1
    mat[i][j] = 1
AB = np.array(mat)
inv_A = np.linalg.inv(AB)
ans = list(np.dot(inv_A,A))
for i in range(N):
    ans[i] = int(ans[i])
print(*ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[sum(a)-2*sum(a[1:n-1:2])]
for i in range(1,n):
  b.append(2*a[i-1]-b[-1])
print(*b)
Buggy python submission (verdict: Time Limit Exceeded):
H,W = [int(i) for i in input().split()]
room = ['0'] * H
ans = -1
for i in range(H):
    room[i] = list(input())
L = [[0] * W for _ in range(H)]
R = [[0] * W for _ in range(H)]
U = [[0] * W for _ in range(H)]
B = [[0] * W for _ in range(H)]
for i in range(W):
    if room[0][i] == '.':
        U[0][i] = 1
        if i == 0:
            L[0][i] = 1
        else:
            L[0][i] = L[0][i-1] +1
for i in range(H):
    if room[i][0] == '.':
        L[i][0] = 1
        if i == 0:
            U[i][0] = 1
        else:
            U[i][0] = U[i-1][0] +1
for x in range(1,H):
    for y in range(1,W):
        if room[x][y] == '.':
            U[x][y] = U[x-1][y]+1
            L[x][y] = L[x][y-1]+1
Ha = [int(i) for i in range(H)]
Wa = [int(i) for i in range(W)]
for i in Wa[::-1]:
    if room[H-1][i] == '.':
        B[H-1][i] = 1
        if i == W-1:
            R[H-1][i] = 1
        else:
            R[H-1][i] = R[H-1][i+1] +1
for i in Ha[::-1]:
    if room[i][W-1] == '.':
        R[i][W-1] = 1
        if i == H-1:
            B[i][W-1] = 1
        else:
            B[i][W-1] = B[i+1][W-1] +1
Haa = [int(i) for i in range(H-1)]
Waa = [int(i) for i in range(W-1)]
for x in Haa[::-1]:
    for y in Waa[::-1]:
        if room[x][y] == '.':
            R[x][y] = R[x][y+1]+1
            B[x][y] = B[x+1][y]+1
for x in range(H):
    for y in range(W):
        if room[x][y] == '.':
            ansa = U[x][y]+R[x][y]+B[x][y]+L[x][y]-3
            ans = max(ans,ansa)
print(ans)

Fixed submission:
H,W = [int(i) for i in input().split()]
room = ['0'] * H
ans = -1
for i in range(H):
    room[i] = list(input())
L = [[0] * W for _ in range(H)]
R = [[0] * W for _ in range(H)]
U = [[0] * W for _ in range(H)]
B = [[0] * W for _ in range(H)]
for i in range(W):
    if room[0][i] == '.':
        U[0][i] = 1
        if i == 0:
            L[0][i] = 1
        else:
            L[0][i] = L[0][i-1] +1
for i in range(H):
    if room[i][0] == '.':
        L[i][0] = 1
        if i == 0:
            U[i][0] = 1
        else:
            U[i][0] = U[i-1][0] +1
for x in range(1,H):
    for y in range(1,W):
        if room[x][y] == '.':
            U[x][y] = U[x-1][y]+1
            L[x][y] = L[x][y-1]+1
Ha = [int(i) for i in range(H)]
Wa = [int(i) for i in range(W)]
for i in Wa[::-1]:
    if room[H-1][i] == '.':
        B[H-1][i] = 1
        if i == W-1:
            R[H-1][i] = 1
        else:
            R[H-1][i] = R[H-1][i+1] +1
for i in Ha[::-1]:
    if room[i][W-1] == '.':
        R[i][W-1] = 1
        if i == H-1:
            B[i][W-1] = 1
        else:
            B[i][W-1] = B[i+1][W-1] +1
Haa = [int(i) for i in range(H-1)]
Waa = [int(i) for i in range(W-1)]
for x in Haa[::-1]:
    for y in Waa[::-1]:
        if room[x][y] == '.':
            R[x][y] = R[x][y+1]+1
            B[x][y] = B[x+1][y]+1
for x in range(H):
    for y in range(W):
        if room[x][y] == '.':
            ansa = U[x][y]+R[x][y]+B[x][y]+L[x][y]-3
            ans = max(ans,ansa)
print(ans)