Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(x) for x in input().split()]
c = 1
for i in range(len(a)):
  c *= a[i]
if(c > 10 ** 18):
  print(-1)
else:
  print(c)

Fixed submission:
def funct(a):
  c = 1
  if(0 in a):	return 0
  for i in range(len(a)):
    c *= a[i]
    if(c > 10 ** 18):
      return -1
  return c
n = input()
a = [int(x) for x in input().split()]
print(funct(a))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a, b = map(int, input().split())
for i in range(a, b + 1):
	if(i % k == 0):
    	print('OK')
        exit()
print('NG')        

Fixed submission:
n = int(input())
a, b = map(int, input().split())
for i in range(a, b + 1, 1):
  if(i % n == 0):
    print('OK')
    exit()
print('NG')
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
 
c = 0
for i in range(K, N + 1 + 1):
    ma = ((N + N - (i - 1)) * i) / 2
    mi = ((0 + i - 1) * i) / 2
    c += int(ma - mi + 1)
 	c %= (10 ** 9 + 7)
print(c)

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

c = 0
for i in range(k, n + 2):
  c += ((n - i + 1) * i + 1) % (10 ** 9 + 7)

print(c % (10 ** 9 + 7))

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

K = [int(i) for i in range(k, n + 2)]
#print(K)
N = [int(i) for i in range(n + 1)]
#print(N)
c = 0
for i in K:
  #print(N[: i])
  mi = sum(N[: i])
  ma = sum(N[::-1][: i])
  c += (ma - mi + 1)
  c %= (10 ** 9 + 7)
print(c)  

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

c = 0
for i in range(k, n + 2):
  c += ((n - i + 1) * i + 1) % (10 ** 9 + 7)

print(c % (10 ** 9 + 7))

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

K = [int(i) for i in range(k, n + 2)]
#print(K)
N = [int(i) for i in range(n + 1)]
#print(N)
c = 0
for i in K:
  #print(N[: i])
  mi = sum(N[: i])
  ma = sum(N[::-1][: i])
  c += (ma - mi + 1)
print(c)  

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

c = 0
for i in range(k, n + 2):
  c += ((n - i + 1) * i + 1) % (10 ** 9 + 7)

print(c % (10 ** 9 + 7))
Buggy python submission (verdict: Runtime Error):

from collections import Counter
n = int(input())
s = input()
d = Counter(s)
f = [d[i] for i in d]
c = f[0] * f[1] * f[2]
 


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

Fixed submission:
import sys

n = int(sys.stdin.readline().rstrip())
s = sys.stdin.readline().rstrip()
r = []
b = []
g = []
for i, si in enumerate(s):
    if si == 'R':
        r.append(i + 1)
    elif si == 'G':
        g.append(i + 1)
    elif si == 'B':
        b.append(i + 1)
count = 0
for i in range(n):
    for j in range(i + 1, n):
        k = j + j - i
        if k < n and s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            count += 1
print(len(r) * len(g) * len(b) - count)

Buggy python submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
s = input()
d = Counter(s)
f = [d[i] for i in d]
c = f[0] * f[1] * f[2]

for j in range(n):
	for i in range(n):
		if(j-i < 0 or j+i >= n):
			break
		elif(s[j-i] != s[j] and s[j+i] != s[j] and s[j+i] != s[j-i]):	c -= 1
 
print(c)

Fixed submission:
import sys

n = int(sys.stdin.readline().rstrip())
s = sys.stdin.readline().rstrip()
r = []
b = []
g = []
for i, si in enumerate(s):
    if si == 'R':
        r.append(i + 1)
    elif si == 'G':
        g.append(i + 1)
    elif si == 'B':
        b.append(i + 1)
count = 0
for i in range(n):
    for j in range(i + 1, n):
        k = j + j - i
        if k < n and s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            count += 1
print(len(r) * len(g) * len(b) - count)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [int(x) for x in input().split()]
s = sum(a)
l = a // (4 * m)

a = sorted(a, reverse = True)
f = 0
for i in a:
  i < l:
    f = i
    break
if(f < m):
  print('No')
else:
  print('Yes')

Fixed submission:
N, M = map(int, input().split())
vote_nums = sorted([float(i) for i in input().split()], reverse=True)
 
border_rate = 1 / (4 * M)
target = vote_nums[:M]
 
for vote_num in target:
  if vote_num < border_rate * sum(vote_nums):
    print('No')
    exit()
 
print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
if(n % k == 0):
  print(0)
else:
  while(True):
    if(abs(n - k) < n):
      n = abs(n - k)
    else:
      print(n)
      break

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

print(min(n % k, k - n % k))
Buggy python submission (verdict: Time Limit Exceeded):
x = [1, 2, 3, 4, 5, 6, 7, 8, 9]
k = int(input())

for i in range(k):
  f = x.pop(0)
  if(f % 10 != 0):	x.append(10 * f + f % 10 - 1)
  x.append(10 * f + f % 10)
  if(f % 10 != 9):	x.append(10 * f + f % 10 + 1)
print(f)    

  
  

Fixed submission:
from collections import deque
x = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])
k = int(input())

for i in range(k):
  f = x.popleft()
  if(f % 10 != 0):	x.append(10 * f + f % 10 - 1)
  x.append(10 * f + f % 10)
  if(f % 10 != 9):	x.append(10 * f + f % 10 + 1)
print(f)
Buggy python submission (verdict: Runtime Error):
import sys
sys.stdin = open('input.txt', 'r') 
sys.stdout = open('output.txt', 'w')

n, k = map(int, input().split())
if(n >= 10):
	print(k)
else:
	print(k + 100 * (10 - n))	

Fixed submission:

n, k = map(int, input().split())
if(n >= 10):
	print(k)
else:
	print(k + 100 * (10 - n))
Buggy python submission (verdict: Runtime Error):
N = int(input())
num_list = list(map(int, input().split()))
 
a=0
for i in num_list:
  if i%2==0 and (i%3!=0 and i%5!=0):
  	print('DENIED')
    exit()
print('APPROVED')

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
app_fl = True
for Ai in [a for a in A if a % 2 == 0]:
    if Ai % 3 != 0 and Ai % 5 != 0:
        app_fl = False
        break
 

if app_fl is True:
    print("APPROVED")
else:
    print("DENIED")

Buggy python submission (verdict: Runtime Error):
N = int(input())
num_list = list(map(int, input().split()))
 
a=0
for i in num_list:
  if i%2==0 and (i%3!=0 and i%5!=0):
  	print('DENIED')
    exit()
 
print('APPROVED')

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
app_fl = True
for Ai in [a for a in A if a % 2 == 0]:
    if Ai % 3 != 0 and Ai % 5 != 0:
        app_fl = False
        break
 

if app_fl is True:
    print("APPROVED")
else:
    print("DENIED")
Buggy python submission (verdict: Runtime Error):
input()
a = [int(x) for x in iput().split()]
if(len(set(a)) < len(a)):
  print('YES')
else:
  print('NO')

Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]
if(n > len(set(a))):	print('NO')
else:	print('YES')
Buggy python submission (verdict: Runtime Error):
a, b = map(int(input().split())
print(b // a + (((b % a) // a) + 1))

Fixed submission:
from math import ceil
a, b = map(int, input().split())
print(ceil((b - 1) / (a - 1)))
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

import math


def g(nx, ny, nz):
    return nx ** 2 + ny ** 2 + nz ** 2 + nx * ny + ny * nz + nz * nx


def solve(n):
    
    counter = [0 for _ in range(n + 1)]
    
    for z in range(1, n):
        for y in range(1, z + 1):
            for x in range(1, y + 1):
                gn = g(x, y, z)
                if gn <= n:
                    counter[gn] += 3
    
    for x in range(int(math.sqrt(n) + 1)):
        nx = 6 * x ** 2
        if nx <= n:
            counter[nx] -= 2
    
    for i in range(1, n + 1):
        print(counter[i])


N = int(input())

solve(N)


Fixed submission:
# -*- coding: utf-8 -*-

import math


def g(nx, ny, nz):
    return nx ** 2 + ny ** 2 + nz ** 2 + nx * ny + ny * nz + nz * nx


def solve(n):
    # min_z = max(1, int(math.sqrt(n) / 3))
    max_z = max(1, int(math.sqrt(n - 2) - 1) if n > 2 else 1)
    # max_x = max(1, int(math.sqrt(n / 3) + 1))
    
    counter = [0 for _ in range(n + 1)]
    
    for z in range(1, max_z + 1):
        for y in range(1, max_z + 1):
            for x in range(1, max_z + 1):
                gn = g(x, y, z)
                if gn <= n:
                    counter[gn] += 1
    
    for i in range(1, n + 1):
        print(counter[i])


N = int(input())

solve(N)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

import math


def g(nx, ny, nz):
    return nx ** 2 + ny ** 2 + nz ** 2 + nx * ny + ny * nz + nz * nx


def is_int(fn):
    return float(int(fn)) == float(fn)


def solve(n):
    min_z = max(1, int(math.sqrt(n) / 3))
    max_z = max(1, int(math.sqrt(n - 2) - 1) if n > 2 else 1)
    max_x = max(1, int(math.sqrt(n / 3) + 1))
    
    counter = 0
    
    for z in range(max(1, min_z), max_z + 1):
        for y in range(1, z + 1):
            for x in range(1, min(y + 1, max_x)):
                if g(x, y, z) == n:
                    counter += 1
    
    counter *= 3
    
    if is_int(math.sqrt(n / 6)):
        counter -= 2
    
    print(counter, flush=True)


N = int(input())

for ni in range(1, N + 1):
    solve(ni)


Fixed submission:
# -*- coding: utf-8 -*-

import math


def g(nx, ny, nz):
    return nx ** 2 + ny ** 2 + nz ** 2 + nx * ny + ny * nz + nz * nx


def solve(n):
    # min_z = max(1, int(math.sqrt(n) / 3))
    max_z = max(1, int(math.sqrt(n - 2) - 1) if n > 2 else 1)
    # max_x = max(1, int(math.sqrt(n / 3) + 1))
    
    counter = [0 for _ in range(n + 1)]
    
    for z in range(1, max_z + 1):
        for y in range(1, max_z + 1):
            for x in range(1, max_z + 1):
                gn = g(x, y, z)
                if gn <= n:
                    counter[gn] += 1
    
    for i in range(1, n + 1):
        print(counter[i])


N = int(input())

solve(N)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

N = int(input())

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

A_sort = sorted(A, reverse=True)
sum_num = A_sort.pop(0)

i = 2
while i + 2 <= N:
    sum_num += A_sort.pop(0) * 2
    i += 2

if i + 1 <= N:
    sum_num += A_sort.pop(0)

print(sum_num)



Fixed submission:
# -*- coding: utf-8 -*-

N = int(input())

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

A_sort = sorted(A)
sum_num = A_sort.pop(-1)

i = 2
while i + 2 <= N:
    sum_num += A_sort.pop(-1) * 2
    i += 2

if i + 1 <= N:
    sum_num += A_sort.pop(-1)

print(sum_num)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**6)
INF = float("inf")

def main():
    N,M,L = map(int,input().split())
    ABC = [tuple(map(int,input().split())) for _ in range(M)]
    Q = int(input())
    ST = [tuple(map(int,input().split())) for _ in range(Q)]

    # 町の最短距離を求める
    A = [[INF for _ in range(N)] for _ in range(N)]
    for a,b,c in ABC:
        A[a-1][b-1] = c
        A[b-1][a-1] = c
    for k in range(N):
        for i in range(N):
            for j in range(N):
                A[i][j] = min(A[i][j], A[i][k]+A[k][j])
    
    # 求めた町の距離が L以下 に 1の辺をはる (給油なしでたどり着ける)
    B = [[INF for _ in range(N)] for _ in range(N)]
    for i in range(N):
        for j in range(N):
            if A[i][j] <= L:
                B[i][j] = 1
    # 最短距離を求める
    for k in range(N):
        for i in range(N):
            for j in range(N):
                B[i][j] = min(B[i][j], B[i][k]+B[k][j])
    
    for s,t in ST:
        if B[s-1][t-1] == INF:
            print(-1)
        else:
            print(B[s-1][t-1] - 1)

if __name__ == "__main__":
    main()

Fixed submission:
#!/usr/bin/env python

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**6)
inf = float("inf")

import numpy as np
import scipy.sparse.csgraph as csg

def main():
    N,M,L = map(int,input().split())
    ABC = [tuple(map(int,input().split())) for _ in range(M)]
    Q = int(input())
    ST = [tuple(map(int,input().split())) for _ in range(Q)]

    # 町の最短距離を求める
    A = np.array([[inf]*N]*N)
    for a,b,c in ABC:
        A[a-1][b-1] = c
        A[b-1][a-1] = c
    A = csg.floyd_warshall(A)
    
    # 求めた町の距離が L以下 に 1の辺をはる (給油なしでたどり着ける)
    B = np.array([[inf]*N]*N)
    for i in range(N):
        for j in range(N):
            if A[i][j] <= L:
                B[i][j] = 1
    # 最短距離を求める
    B = csg.floyd_warshall(B)
    
    for s,t in ST:
        if B[s-1][t-1] == inf:
            print(-1)
        else:
            print(int(B[s-1][t-1] - 1))

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

import sys

input = sys.stdin.buffer.readline

A,B = map(int,input().split())

divA,divB = set(),set()
for i in range(1,int(A**.5+1)):
    if A%i == 0:
        divA.add(i)
        divA.add(A//i)
for i in range(1,int(B**.5+1)):
    if B%i == 0:
        divB.add(i)
        divB.add(B//i)

C = list(divA & divB)
C.sort()

N = 10**6+1
primes = []
is_prime = [True]*N
for i in range(2,N):
    if is_prime[i]:
        primes.append(i)
        j = 2
        while i*j < N:
            is_prime[i*j] = False
            j += 1

ans = 0
for c in C:
    if is_prime[c]:
        ans += 1

print(ans)

Fixed submission:
#!/usr/bin/env python3

import sys

input = sys.stdin.buffer.readline

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

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

def prime_factorize(n):
    pf={}
    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            pf[i] = pf.get(i, 0) + 1
            n //= i
    if n > 1: pf[n] = 1
    return pf

A,B = map(int,input().split())

pf = prime_factorize(gcd(A,B))
print(len(pf) + 1)
Buggy python submission (verdict: Time Limit Exceeded):
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
S = input().rstrip()
mod = 10**9+7

# dp[i][j] : 上から i 桁までの数字で, 13で割ったあまりが j になる場合の数
dp = [[0 for _ in range(13)] for _ in range(len(S))]

# 初期化
if S[0] == "?":
    for i in range(10):
        dp[0][i] += 1
else:
    dp[0][int(S[0])] = 1

# dp更新
for i in range(1,len(S)):
    if S[i] == "?":
        for j in range(13):
            for k in range(10):
                dp[i][(j*10 + k) % 13] += dp[i-1][j]
                dp[i][(j*10 + k) % 13] %= mod
    else:
        for j in range(13):
            dp[i][(j*10 + int(S[i])) % 13] += dp[i-1][j]
            dp[i][(j*10 + int(S[i])) % 13] %= mod

print(dp[-1][5])

Fixed submission:
# PyPy3 (2.4.0)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
S = input().rstrip()
mod = 10**9+7

# dp[i][j] : 上から i 桁までの数字で, 13で割ったあまりが j になる場合の数
dp = [[0 for _ in range(13)] for _ in range(len(S))]

# 初期化
if S[0] == "?":
    for i in range(10):
        dp[0][i] += 1
else:
    dp[0][int(S[0])] = 1

# dp更新
for i in range(1,len(S)):
    if S[i] == "?":
        for j in range(13):
            for k in range(10):
                dp[i][(j*10 + k) % 13] += dp[i-1][j]
                dp[i][(j*10 + k) % 13] %= mod
    else:
        for j in range(13):
            dp[i][(j*10 + int(S[i])) % 13] += dp[i-1][j]
            dp[i][(j*10 + int(S[i])) % 13] %= mod

print(dp[-1][5])
Buggy python submission (verdict: Runtime Error):
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())
A = [int(input()) for _ in range(N)]

from collections import deque
from bisect import bisect_left

D = deque([])

for a in A:
    i = bisect_left(D,a)
    if i==0:
        D.appendleft(a)
    else:
        D[i-1] = a
    print(i,D)

print(len(D))

Fixed submission:
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())
A = [int(input()) for _ in range(N)]

from collections import deque
from bisect import bisect_left

D = deque([])

for a in A:
    i = bisect_left(D,a)
    if i==0:
        D.appendleft(a)
    else:
        D[i-1] = a

print(len(D))
Buggy python submission (verdict: Time Limit Exceeded):
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,M = map(int,input().split())
S = list(map(int,input().split()))
T = list(map(int,input().split()))
mod = 10**9+7

# dp[i][j] : Sの左からi文字目までと Tの左からj文字目まででの 共通部分文字列の数
dp = [[0 for _ in range(M+1)] for _ in range(N+1)]
dp[0][0] = 1

for i in range(N+1):
    for j in range(M+1):
        if 0<=i-1 and 0<=j-1 and S[i-1]==T[j-1]:
            dp[i][j] += dp[i-1][j-1]
        if 0<=i-1:
            dp[i][j] += dp[i-1][j]
        if 0<=j-1:
            dp[i][j] += dp[i][j-1]
        # 重複カウント部分を減算する
        if 0<=i-1 and 0<=j-1:
            dp[i][j] -= dp[i-1][j-1]
        dp[i][j] %= mod

print(dp[N][M])


Fixed submission:
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,M = map(int,input().split())
S = list(map(int,input().split()))
T = list(map(int,input().split()))
mod = 10**9+7

# dp[i][j] : Sの左からi文字目までと Tの左からj文字目まででの 共通部分文字列の数
dp = [[0 for _ in range(M+1)] for _ in range(N+1)]
dp[0][0] = 1

for i in range(N+1):
    for j in range(M+1):
        if 0<=i-1 and 0<=j-1 and S[i-1]==T[j-1]:
            dp[i][j] += dp[i-1][j-1]
        if 0<=i-1:
            dp[i][j] += dp[i-1][j]
        if 0<=j-1:
            dp[i][j] += dp[i][j-1]
        # 重複カウント部分を減算する
        if 0<=i-1 and 0<=j-1:
            dp[i][j] -= dp[i-1][j-1]
        dp[i][j] %= mod

print(dp[N][M])
Buggy python submission (verdict: Time Limit Exceeded):
# python 3.4.3
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,M = map(int,input().split())
A = list(int(input()) for _ in range(M))

mod = 10**9+7

# dp[i] : i番目の階段までの場合の数
dp = [0]*(N+1) 
dp[0] = 1
dp[1] = 1 if 1 not in A else 0 

for i in range(2,N+1):
    if i not in A:
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= mod

print(dp[N])


Fixed submission:
# python 3.4.3
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,M = map(int,input().split())
A = list(int(input()) for _ in range(M))

mod = 10**9+7

# 床が壊れてる階段を高速に判別できるように
B = [True]*(N+1)
for a in A:
    B[a] = False

# dp[i] : i番目の階段までの場合の数
dp = [0]*(N+1) 
dp[0] = 1
dp[1] = 1 if 1 not in A else 0 

for i in range(2,N+1):
    if B[i]:
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= mod

print(dp[N])
Buggy python submission (verdict: Time Limit Exceeded):
# python 3.4.3
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
H,W = map(int,input().split())
S = [input().rstrip() for _ in range(H)]

LR = [[0 for _ in range(W)] for _ in range(H)]
UD = [[0 for _ in range(W)] for _ in range(H)]

# 横方向
for h in range(H):
    cnt = 0
    for w in range(W):
        if S[h][w] == "#":
            cnt = 0
        else:
            cnt += 1
        LR[h][w] = cnt
for h in range(H):
    cnt = 0
    for w in range(W):
        if LR[h][W-1-w] == 0:
            cnt = 0
        else:
            if cnt==0:
                cnt = LR[h][W-1-w]
            else:
                LR[h][W-1-w] = cnt

# 縦方向
for w in range(W):
    cnt = 0
    for h in range(H):
        if S[h][w] == "#":
            cnt = 0
        else:
            cnt += 1
        UD[h][w] = cnt
for w in range(W):
    cnt = 0
    for h in range(H):
        if UD[H-1-h][w] == 0:
            cnt = 0
        else:
            if cnt==0:
                cnt = UD[H-1-h][w]
            else:
                UD[H-1-h][w] = cnt

ans = 0
for h in range(H):
    for w in range(W):
        ans = max(ans, LR[h][w] + UD[h][w] - 1)

print(ans)

Fixed submission:
# python 3.4.3
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
H,W = map(int,input().split())
S = [input().rstrip() for _ in range(H)]

LR = [[0 for _ in range(W)] for _ in range(H)]
UD = [[0 for _ in range(W)] for _ in range(H)]

# 横方向
for h in range(H):
    cnt = 0
    for w in range(W):
        if S[h][w] == "#":
            cnt = 0
        else:
            cnt += 1
        LR[h][w] = cnt
for h in range(H):
    cnt = 0
    for w in range(W):
        if LR[h][W-1-w] == 0:
            cnt = 0
        else:
            if cnt==0:
                cnt = LR[h][W-1-w]
            else:
                LR[h][W-1-w] = cnt

# 縦方向
for w in range(W):
    cnt = 0
    for h in range(H):
        if S[h][w] == "#":
            cnt = 0
        else:
            cnt += 1
        UD[h][w] = cnt
for w in range(W):
    cnt = 0
    for h in range(H):
        if UD[H-1-h][w] == 0:
            cnt = 0
        else:
            if cnt==0:
                cnt = UD[H-1-h][w]
            else:
                UD[H-1-h][w] = cnt

ans = 0
for h in range(H):
    for w in range(W):
        ans = max(ans, LR[h][w] + UD[h][w] - 1)

print(ans)