Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
# import sys 
# import os
# path = os.path.join(os.getcwd(),'input.txt')
# input = open(path).readline

import numpy as np
S = input()
cand = np.zeros(2019,dtype=int)
rem = 0
order = 1
mod = 2019
for s in S[::-1]:
    rem += (int(s)*order)%mod
    rem %= mod
    cand[rem] +=1
    order *= 10
ans = cand[0]
cand = cand[cand>1]
for c in cand:
    ans += c*(c-1)/2
print(int(ans))

Fixed submission:
# import sys 
# import os
# path = os.path.join(os.getcwd(),'input.txt')
# input = open(path).readline

import numpy as np
S = input()
cand = np.zeros(2019,dtype=int)
rem = 0
order = 1
mod = 2019
for s in S[::-1]:
    rem += (int(s)*order)%mod
    rem %= mod
    cand[rem] +=1
    order *= 10
    order %=mod
ans = cand[0]
cand = cand[cand>1]
for c in cand:
    ans += c*(c-1)/2
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
# import sys 
# import os
# path = os.path.join(os.getcwd(),'input.txt')
# input = open(path).readline

import numpy as np
S = input()
cand = np.zeros(2019,dtype=int)
ans = 0
rem = 0
for i,s in enumerate(S[::-1]):
    rem += int(s)*(10**i)
    rem %= 2019
    cand[rem] +=1
ans = cand[0]
cand = cand[cand>1]
for c in cand:
    ans += c*(c-1)/2
print(int(ans))

Fixed submission:
# import sys 
# import os
# path = os.path.join(os.getcwd(),'input.txt')
# input = open(path).readline

import numpy as np
S = input()
cand = np.zeros(2019,dtype=int)
rem = 0
order = 1
mod = 2019
for s in S[::-1]:
    rem += (int(s)*order)%mod
    rem %= mod
    cand[rem] +=1
    order *= 10
    order %=mod
ans = cand[0]
cand = cand[cand>1]
for c in cand:
    ans += c*(c-1)/2
print(int(ans))

Buggy python submission (verdict: Runtime Error):
# import sys 
# import os
# import numpy as np
# path = os.path.join(os.getcwd(),'input.txt')
# input = open(path).readline

S = input()
cand = np.zeros(2019,dtype=int)
ans = 0
rem = 0
for i,s in enumerate(S[::-1]):
    rem += int(s)*(10**i)
    rem %= 2019
    cand[rem] +=1
ans = cand[0]
cand = cand[cand>1]
for c in cand:
    ans += c*(c-1)/2
print(int(ans))

Fixed submission:
# import sys 
# import os
# path = os.path.join(os.getcwd(),'input.txt')
# input = open(path).readline

import numpy as np
S = input()
cand = np.zeros(2019,dtype=int)
rem = 0
order = 1
mod = 2019
for s in S[::-1]:
    rem += (int(s)*order)%mod
    rem %= mod
    cand[rem] +=1
    order *= 10
    order %=mod
ans = cand[0]
cand = cand[cand>1]
for c in cand:
    ans += c*(c-1)/2
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
L = len(S)
S = int(S)
ans = 0
for i in range(L,3,-1):
    for j in range(i-4,-1,-1):
        if S%(10**i)%2019 == S%(10**j)%2019:
            ans += 1
print(ans)

Fixed submission:
# import sys 
# import os
# path = os.path.join(os.getcwd(),'input.txt')
# input = open(path).readline

import numpy as np
S = input()
cand = np.zeros(2019,dtype=int)
rem = 0
order = 1
mod = 2019
for s in S[::-1]:
    rem += (int(s)*order)%mod
    rem %= mod
    cand[rem] +=1
    order *= 10
    order %=mod
ans = cand[0]
cand = cand[cand>1]
for c in cand:
    ans += c*(c-1)/2
print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
from functools import lru_cache

K = int(input())
sum = 0

@lru_cache()
def gcd(x,y):
  r = x % y
  while r> 0:
    x = y
    y = r
    r = x%y
  return y
  
for a in range(K):
  for b in range(K):
    for c in range(K):
      sum += gcd(gcd(a+1,b+1),c+1)
print(sum)

Fixed submission:
from functools import lru_cache
@lru_cache()
def gcd(x,y):
    r = x%y
    if r == 0:
        return y
    return gcd(y,r)

K = int(input())
Sum = 0

for i in range(1,K+1):
    Sum += i
    for j in range(i+1,K+1):
        Sum += 6*gcd(i,j)
        for k in range(j+1,K+1):
            Sum += 6*gcd(gcd(i,j),k)
print(Sum)

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
sum = 0
def gcd(x,y):
  r = x % y
  while r> 0:
    x = y
    y = r
    r = x%y
  return y
  
for a in range(K):
  for b in range(K):
    for c in range(K):
      sum += gcd(gcd(a+1,b+1),c+1)
print(sum)

Fixed submission:
from functools import lru_cache
@lru_cache()
def gcd(x,y):
    r = x%y
    if r == 0:
        return y
    return gcd(y,r)

K = int(input())
Sum = 0

for i in range(1,K+1):
    Sum += i
    for j in range(i+1,K+1):
        Sum += 6*gcd(i,j)
        for k in range(j+1,K+1):
            Sum += 6*gcd(gcd(i,j),k)
print(Sum)
Buggy python submission (verdict: Time Limit Exceeded):
from functools import lru_cache
N,K = map(int,input().split())
mod = 10**9 + 7
counts = [0]*(K)
ans = 0 
for x in range(K,0,-1):
    y = K//x
    counts[x-1] = y**N%mod
    if y >= 2:
        for i in range(2,y+1):
            counts[x-1] -=counts[i*x-1]%mod 
            counts[x-1] %= mod
    ans +=x*counts[x-1]% mod
    ans%=mod  
print(ans)

Fixed submission:
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n, k = map(int, input().split())
    mod = 10 ** 9+ 7
    table = [0]*(k+1)
    ans= 0
    for i in range(k, 0, -1):
        table[i] = pow(k//i, n, mod)
        j = 2
        while i*j <= k:
            table[i] -= table[i*j]
            table[i] %= mod
            j += 1
        ans += i*table[i]
        ans %= mod
    print(ans)



if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import collections
def prime_factorize(n):
    a = []
    while n%2 == 0:
        a.append(2)
        n//=2
    f =3
    while f*f <= n:
        if n%f == 0:
            a.append(f)
            n//=f
        else:
            f +=2
    if n != 1:
        a.append(n)
    return a

# N-1の約数を数える
N = int(input())
factor = collections.Counter(prime_factorize(N-1))
K = 1
for i in list(factor.values()):
    K *= i+1
K -=1
for f in range(2, int(N**0.5)+1):
    n = N
    if n%f != 0:
        continue
    while n%f ==0:
        n//=f
    if n%f ==1 or n==1:
        K+=1
#最後は自分自身を加える。
K +=1
print(K)

Fixed submission:
x,y,z = map(int, input().split())
x,y,z = z,x,y
print(x,y,z)

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = list(map(int,input().split()))
shreshold = sum(A)/(4*M)
ret = [a for a in A if a >= shreshold]
if len(ret) < M:
    print('no')
else:
    print('yes')

Fixed submission:
x,y,z = map(int, input().split())
x,y,z = z,x,y
print(x,y,z)
Buggy python submission (verdict: Runtime Error):
k = int(input())
stack = list(range(1,10))
for i in range(k):
  num = stack.pop(0)
  if (m:=num%10) == 0:
    stack.append([num*10 + m,num*10+m+1])
  elif m == 9:
    stack.append([num*1 + m -1,num*10 + m])
  else:
    stack.append([num*10 + m -1,num*10 + m, num*10+ m + 1])
print(num)

Fixed submission:
import queue
K = int(input())
q = queue.Queue()
for i in range(1,10):
    q.put(i)

for i in range(K):
    x = q.get()
    a = x%10
    if a !=0:
        q.put(10*x +a -1)
    q.put(10*x +a )
    if a != 9:
        q.put(10*x +a +1)
print(x)

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
Que = list(range(1,10))
for i in range(K):
    x = Que.pop(0)
    a = x%10
    if a !=0:
        Que.append(10*x +a -1)
    Que.append(10*x +a )
    if a != 9:
        Que.append(10*x +a +1)
print(x)


Fixed submission:
import queue
K = int(input())
q = queue.Queue()
for i in range(1,10):
    q.put(i)

for i in range(K):
    x = q.get()
    a = x%10
    if a !=0:
        q.put(10*x +a -1)
    q.put(10*x +a )
    if a != 9:
        q.put(10*x +a +1)
print(x)
Buggy python submission (verdict: Runtime Error):
import sys
def yutori():
    N, K, C = map(int,sys.stdin.readline().split())
    S = [i for i in sys.stdin.readline()]
    l = [i+1 for i in range(N) if S[i] == 'o']
    Left = [0]*K
    Right = [0]*K
    count = 0
    for u in l:
        if Left[0] == 0:
            Left[count] = u
        if u > Left[count] + C:
            count +=1
            Left[count] = u
        continue

    count = 1
    for u in l[::-1]:
        if Right[-1] == 0:
            Right[-count] = u
        if u < Right[-count] - C:
            count +=1
            Right[-count] = u
        continue

    if Left[-1] == 0 or Right [0] == 0:
        return 
    for i in range(K):
        if Left[i] == Right[i]:
            print(Left[i])

yutori()


Fixed submission:
import sys
def yutori():
    N, K, C = map(int,sys.stdin.readline().split())
    S = [i for i in sys.stdin.readline()]
    l = [i+1 for i in range(N) if S[i] == 'o']
    Left = []
    Right = []
    for u in l:
        if Left == []:
            Left.append(u)
        if u > Left[-1] + C:
            Left.append(u)
        if len(Right) == K:
            break
        
    if len(Left) <K:
        exit()

    for u in l[::-1]:
        if Right== []:
            Right.append(u)
        if u < Right[-1] - C:
            Right.append(u)
        if len(Right) == K:
            break

    if len(Right) <K:
            exit()
    
    for i in range(K):
        if Left[i] == Right[-i-1]:
            print(Left[i])

yutori()
Buggy python submission (verdict: Runtime Error):
N, X, Y= map(int, input().split())
K = [0]*(N-1)
for i in range(1,N):
    for j in range(i+1, N+1):
        idx = min([j-i, abs(X-i)+ abs(j-Y)+1, abs(Y-i) + 1 + abs(X-j)])-1
        K[idx] +=1
for value in K:
    print(value)    

Fixed submission:
import sys

s = list(input())
if s[2] == s[3] and s[4] == s[5]:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0; i < n; i++)
#define repran(i, a,b) for (int i = a; i<b;i++)
#define repd(i, n) for (int i = n-1; i > -1; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;
using LP = pair<ll,ll>;
using P = pair<ll,int>;
ll mod = 998244353;

int main()
{
    int n, x, y;
    cin>> n >> x>>y;
    x--;y--;
    vector<int> table(n,0);
    rep(i, n) rep(j,i){
        int tmp = min(i-j, abs(x-i)+abs(y-j)+1);
        tmp = min(tmp,abs(x-j)+abs(y-i)+1);
        table[tmp]++;
    }
    repran(i, 1, n) cout << table[i] << endl;
}

Fixed submission:
N, X, Y= map(int, input().split())
K = [0]*(N-1)
for i in range(1,N):
    for j in range(i+1, N+1):
        idx = min([j-i, abs(X-i)+ abs(j-Y)+1, abs(Y-i) + 1 + abs(X-j)])-1
        K[idx] +=1
for value in K:
    print(value)
Buggy python submission (verdict: Runtime Error):
def main():
    import sys
    input = sys.stdin.buffer.readline
    n, m = map(int, input().split())
    print(int(n*(n-1)/2 + m(m-1)/2))


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    import sys
    input = sys.stdin.buffer.readline
    n, m = map(int, input().split())
    print(int(n*(n-1)/2 + m*(m-1)/2))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    import sys
    input = sys.stdin.buffer.readline
    s = input()
    n = len(s)
    s_l = s[:(n-1)/2]
    s_r = s[(n+3)/2:]
    if s == s[::-1] and s_l == s_l[::-1] and s_r == s_r[::-1]:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    import sys
    #input = sys.stdin.readline
    s = input()
    n = len(s)
    s_l = s[:int((n-1)/2)]
    s_r = s[int((n+1)/2):]
    if s == s[::-1] and s_l == s_l[::-1] and s_r == s_r[::-1]:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def dfs(n):
    adj = [chr(i+97) for i in range(26)]
    
    stack = ['a']
    while stack:
        node = stack.pop(0)
        if len(node) == n:
            print(node)
        else:
            limit = ord(max(node))%97+2
            for child in adj[:limit]:
                stack.append(node+child)
    return -1

def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n = int(input())
    dfs(n)


if __name__ == '__main__':
    main()

Fixed submission:
def dfs(s,n,adj):
    adj = 'abcdefghij'
    if len(s) == n:
        print(s)
    else:
        for child in adj[:len(set(s))+1]:
            dfs(s+child,n,adj)
    return -1

def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n = int(input())
    adj = 'abcdefghij'
    dfs('a',n,adj)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def dfs(n):
    adj = [chr(i+97) for i in range(26)]
    
    stack = ['a']
    combs = []
    while stack:
        node = stack.pop(0)
        if len(node) == n:
            combs.append(node)
        else:
            limit = ord(max(node))%97+2
            for child in adj[:limit]:
                cand = node+child
                stack.append(node+child)
    return combs

def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n = int(input())
    res = dfs(n)
    for ans in res:
        print(ans)


if __name__ == '__main__':
    main()

Fixed submission:
def dfs(s,n,adj):
    adj = 'abcdefghij'
    if len(s) == n:
        print(s)
    else:
        for child in adj[:len(set(s))+1]:
            dfs(s+child,n,adj)
    return -1

def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n = int(input())
    adj = 'abcdefghij'
    dfs('a',n,adj)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().rstrip()
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(mi())

def main():
    mod = 10**9+7
    n = ii()
    a = li()
    bi = [0]*60
    for x in a:
        for i in range(60):
            if (x>>i)&1:
                bi[i]+= 1
    ans = 0
    for i in range(60):
        tmp = bi[i]*(n-bi[i])*(1<<i)
        tmp %= mod
        ans += tmp
        ans %= mod

    print(ans)



if __name__ == '__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(mi())

def main():
    mod = 10**9+7
    n = ii()
    a = li()
    bi = [0]*60
    for x in a:
        for i in range(60):
            if (x>>i)&1:
                bi[i]+= 1
    ans = 0
    for i in range(60):
        tmp = bi[i]*(n-bi[i])*(1<<i)
        tmp %= mod
        ans += tmp
        ans %= mod

    print(ans)



if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):

    
def main():
    import sys
    sys.setrecursionlimit(10**6)
    def input(): return sys.stdin.readline().rstrip()

                
    def dfs(upper, lower, left, right):
        # 走査
        cntrow = [0]*(h)
        for i in range(upper, lower):
            for j in range(left, right):
                if g[i][j] == '#':
                    tmp = ans[i][j]
                    cntrow[i] += 1
        
        if sum(cntrow) == 1:
            for i in range(upper, lower):
                for j in range(left, right):
                    ans[i][j] = tmp
            return ans
        
        for i in range(upper, lower):
            if sum(cntrow[:i]) > 0 and sum(cntrow[i:]) > 0:
                dfs(upper, i, left, right)
                dfs(i, lower, left, right)
                break
        
        cnt = 0
        for i in range(upper, lower):
            if cntrow[i] > 1:
                tmp = i
                cnt += 1
        if cnt == 1:
            for j in range(left, right):
                if g[tmp][j] == '#':
                    dfs(upper, lower, left, j+1)
                    dfs(upper, lower, j+1, right)
                    break
        

    h, w, k = map(int, input().split())
    g = ['']*h
    ans = [[0]*w for _ in range(h)]
    cnt = 1
    for i in range(h):
        g[i] = input()
        for j in range(w):
            if g[i][j] == '#':
                ans[i][j] = cnt
                cnt += 1
    dfs(0, h, 0, w)
    for i in range(h):
        print(*ans[i])

        
        
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    import sys
    import numpy as np
    sys.setrecursionlimit(10**6)

    def input(): return sys.stdin.readline().rstrip()
        
    def dfs(upper, lower, left, right, cnt):
        
        if cnt == 1:
            ans[upper:lower, left:right] = np.max(ans[upper:lower, left:right])
            return

        elif cnt != max(cntrow[upper:lower]):
            for i in range(upper, lower):
                if cntrow[i]:
                    ncnt = sum(cntrow[upper:i+1])
                    dfs(upper, i+1, left, right, ncnt)
                    dfs(i+1, lower, left, right, cnt-ncnt)
                    break
            
        else:
            idx = cntrow[upper:lower].index(cnt)+upper
            for j in range(left, right):
                if g[idx][j] == '#':
                    dfs(upper, lower, left, j+1, 1)
                    cntrow[idx] -=1
                    dfs(upper, lower, j+1, right, cnt-1)
                    break

      
    h, w, k = map(int, input().split())
    g = ['']*h
    ans = np.zeros(shape=(h, w), dtype=int)
    cnt = 1
    cntrow = [0]*h
    for i in range(h):
        g[i] = input()
        for j in range(w):
            if g[i][j] == '#':
                ans[i, j] = cnt
                cntrow[i] += 1
                cnt += 1
    dfs(0, h, 0, w, k)
    for i in range(h):
        print(*ans[i])

        
        
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0; i < n; i++)
typedef long long ll;
#define repran(i, a,b) for (int i = a; i<b;i++)
#define repd(i, n) for (int i = n-1; i > -1; i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using LP = pair<ll,ll>;
using P = pair<int,ll>;
int n;
ll inf = 1e18;

int main()
{
    int n ,q;
    cin >> n >> q;
    vector<vector<int>> G(n, vector<int>());
    rep(i, n-1){
        int a, b;
        cin >> a >> b;
        --a;--b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<ll> ans(n, 0);
    vector<ll> acc(n, 0);
    rep(i, q){
        int p; ll x;
        cin >> p >>x;
        --p;
        acc[p] += x;
    }
    //dfs
    deque<P> deq;
    deq.emplace_back(0, acc[0]);
    ans[0] = acc[0];
    vector<int> parent(n, -1);
    while(!deq.empty()){
        P now = deq.back();deq.pop_back();
        int node = now.first;
        ll cost = now.second;
        for (int child : G[node]){
            if(child == parent[node]) continue;
            parent[child] = node;
            ans[child] = ans[node]+acc[child];
            deq.emplace_back(child, acc[child]);
        }

    }
    rep(i, n) cout << ans[i] << endl;

}

Fixed submission:
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    n, q = map(int, input().split())
    adj = [[] for _ in range(n)]
    for _ in range(n-1):
        a, b = map(lambda x: int(x)-1, input().split())
        adj[a].append(b)
        adj[b].append(a)
    ans = [0]*n
    for _ in range(q):
        p, x = map(int, input().split())
        p -=1
        ans[p] += x
    
    from collections import deque
    que = deque([0])
    parent = [-1]*n
    while que:
        node = que.pop()
        for v in adj[node]:
            if v == parent[node]:
                continue
            parent[v] = node
            que.append(v)
            ans[v] += ans[node]
    for a in ans:
        print(a)

        

    
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    n = int(input())
    x, y = [0]*n, [0]*n
    for i in range(n):
        x[i], y[i] = map(int, input().split())
    from collections import defaultdict
    xy = defaultdict(int)
    for i in range(n):
        for j in range(n):
            if i == j: continue
            xy[(x[i]-x[j], y[i]-y[j])] += 1
    p, q = max(xy, key=lambda x: xy[x])
    ans = n
    for i in range(n):
        for j in range(n):
            if i == j: continue
            if x[i]-x[j] == p and y[i]-y[j] == q:
                ans -= 1
    print(ans)
    

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    n = int(input())
    x, y = [0]*n, [0]*n
    for i in range(n):
        x[i], y[i] = map(int, input().split())
    from collections import defaultdict
    xy = defaultdict(int)
    for i in range(n):
        for j in range(n):
            if i == j: continue
            xy[(x[i]-x[j], y[i]-y[j])] += 1
    if xy == {}:
        print(1)
        return
    p, q = max(xy, key=lambda x: xy[x])
    ans = n
    for i in range(n):
        for j in range(n):
            if i == j: continue
            if x[i]-x[j] == p and y[i]-y[j] == q:
                ans -= 1
    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys


    def input(): return sys.stdin.readline().rstrip()

    h, w = map(int, input().split())
    g = [[] for _ in range(h)]
    for i in range(h):
        g[i] = input()
    
    L = [[0]*w for _ in range(h)]
    R = [[0]*w for _ in range(h)]
    U = [[0]*w for _ in range(h)]
    D = [[0]*w for _ in range(h)]
    for i in range(h):
        for j in range(w):
            if g[i][j] == '#':
                continue
            if i == 0:
                U[i][j] = 1
            else:
                U[i][j] = U[i-1][j]+1
            if j == 0:
                L[i][j] = 1
            else:
                L[i][j] = L[i][j-1]+1
    
    for i in range(h-1, -1, -1):
        for j in range(w-1, -1, -1):
            if g[i][j] == '#':
                continue
            if j == w-1:
                R[i][j] = 1
            else:
                R[i][j] = R[i][j+1]+1
            if i == h-1:
                D[i][j] = 1
            else:
                D[i][j] = D[i+1][j]+1
    
    ans = 0
    for i in range(h):
        for j in range(w):
            tmp = L[i][j]+U[i][j]+D[i][j]+R[i][j]-3
            ans = max(tmp, ans)
    print(ans)
            
                


            

    
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    import sys
    import numpy as np

    def input(): return sys.stdin.readline().rstrip()

    h, w = map(int, input().split())
    g = np.zeros((h, w), dtype=int)
    for i in range(h):
        g[i] = [int(s == '.') for s in input()]
    
    L = g.copy()
    R = g.copy()
    U = g.copy()
    D = g.copy()
    
    for i in range(1,h):
        U[i] = (U[i-1]+1)*g[i]
        D[~i] = (D[~i+1]+1)*g[~i]
    for j in range(1, w):
        L[:, j] = (L[:, j-1]+1)*g[:,j]
        R[:, ~j] = (R[:, ~j+1]+1)*g[:, ~j]
     
    ans = np.max(L+R+U+D-3)
    print(ans)
            
                
if __name__ == '__main__':
    main()