Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import sys

N=int(sys.stdin.readline())
A=list(map(int,sys.stdin.readline().split()))
B=list(map(int,sys.stdin.readline().split()))

ANS=""
for i in range(1,30):
    k=2**i
    XA=sorted([A[t]%k for t in range(N)])
    XB=sorted([B[t]%k for t in range(N)])
    XB.append(k*2)
    XA.reverse()

    b0=0
    b1=0
    b2=0
    count=0

    for xa in XA:
        for j in range(b0,N+1):
            if k//2<=xa+XB[j]:
                b0=j
                break

        if b1<b0:
            b1=b0

        
        for j in range(b1,N+1):
            if xa+XB[j]>=k:
                b1=j
                break

        if b2<b1:
            b2=b1

        for j in range(b2,N+1):
            if k*3//2<=xa+XB[j]:
                b2=j
                break

        count+=(b1-b0+N-b2)%2

    ANS+=str(count%2)

print(int(ANS[::-1],2))

### FIXED CODE ###

import sys

N=int(sys.stdin.readline())
A=list(map(int,sys.stdin.readline().split()))
B=list(map(int,sys.stdin.readline().split()))

ANS=""
for i in range(1,30):
    k=2**i
    XA=sorted([a%k for a in A],reverse=True)
    XB=sorted([b%k for b in B])
    XB.append(k*2)

    b0=0
    b1=0
    b2=0
    count=0

    for xa in XA:
        for j in range(b0,N+1):
            if k//2<=xa+XB[j]:
                b0=j
                break

        if b1<b0:
            b1=b0

        
        for j in range(b1,N+1):
            if xa+XB[j]>=k:
                b1=j
                break

        if b2<b1:
            b2=b1

        for j in range(b2,N+1):
            if k*3//2<=xa+XB[j]:
                b2=j
                break

        count+=(b1-b0+N-b2)

    ANS+=str(count%2)

print(int(ANS[::-1],2))
### BUGGY CODE ###

R, C, K = map(int, input().split())
rcvs = [tuple(map(int, input().split())) for _ in range(K)]

rcvs.sort(key = lambda t: t[1] * 30000 + t[0])

dp = [[0] * (R+1) for _ in range(4)]
index = 0
for c in range(C+1):
    while index < K and rcvs[index][1] == c:
        x, _, v = rcvs[index]
        if dp[3][x] < dp[2][x] + v:
            dp[3][x] = dp[2][x] + v
        if dp[2][x] < dp[1][x] + v:
            dp[2][x] = dp[1][x] + v
        if dp[1][x] < dp[0][x] + v:
            dp[1][x] = dp[0][x] + v
        index += 1
        for r in range(x, R):
            dp[0][r+1] = max(dp[0][r], dp[1][r], dp[2][r], dp[3][r])
        #print(dp)   
    
print(max(max(row) for row in dp))


### FIXED CODE ###

R, C, K = map(int, input().split())
points_dict = dict()
for _ in range(K):
    r, c, v = map(int, input().split())
    points_dict[r * 30000 + c] = v

dp = [[[0] * (C+1) for _ in range(R+1)] for _ in range(4)] # dp[4][R+1][C+1]
index = 0
for i in range(1, R+1):
    for j in range(1, C+1):
        #移動
        for k in range(4):
            if dp[0][i][j] < dp[k][i-1][j]:
                dp[0][i][j] = dp[k][i-1][j]
            if dp[k][i][j] < dp[k][i][j-1]:
                dp[k][i][j] = dp[k][i][j-1]
        #あれば、拾うかどうか
        if i * 30000 + j in points_dict:
            v = points_dict[i * 30000 + j]
            for k in range(3, 0, -1):
                if dp[k][i][j] < dp[k-1][i][j] + v:
                    dp[k][i][j] = dp[k-1][i][j] + v
"""
for i in range(4):
    print(i)
    print(*dp[i], sep = '\n')
"""
print(max((dp[i][R][C] for i in range(4))))
### BUGGY CODE ###

import sys,math,collections,itertools
input = sys.stdin.readline

s = input().rstrip()[::-1]
DP=[0 for _ in range(13)]

DP[0]=1
m = 10**9+7
mul = 1
for i in range(len(s)):
    dig = s[i]
    nextDP = [0 for _ in range(13)]
    if dig == '?':
        for j in range(10):
            for k in range(13):
                nextDP[(k+mul*j)%13] += DP[k]
                nextDP[(k+mul*j)%13]%=m
    else:
        j = int(dig)
        for k in range(13):
            nextDP[(k+mul*j)%13] += DP[k]
            nextDP[(k+mul*j)%13]%=m

    mul *= 10
    DP = nextDP

print(DP[5]%m)
        


### FIXED CODE ###

import sys,math,collections,itertools
input = sys.stdin.readline

s = input().rstrip()[::-1]
DP=[0 for _ in range(13)]

DP[0]=1
m = 10**9+7
mul = 1
for i in range(len(s)):
    dig = s[i]
    nextDP = [0 for _ in range(13)]
    if dig == '?':
        for j in range(10):
            for k in range(13):
                nextDP[(k+mul*j)%13] += DP[k]
                nextDP[(k+mul*j)%13]%=m
    else:
        j = int(dig)
        for k in range(13):
            nextDP[(k+mul*j)%13] += DP[k]
            nextDP[(k+mul*j)%13]%=m

    mul *= 10
    mul%=13
    DP = nextDP

print(DP[5]%m)
### BUGGY CODE ###

N, K, Q = list(map(int, input().split()))
A = []
for i in range(Q):
    A.append(int(input()))

for i in range(N):
    if K + A.count(i+1) - Q > 0:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

N, K, Q = list(map(int, input().split()))

scores = [K-Q] * N
for i in range(Q):
    scores[int(input()) - 1] += 1

for score in scores:
    if score > 0:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

s = input()
t = input()

# dp = np.zeros(shape=(len(s), len(t)), dtype=np.int64)
dp = [[0] * (len(t)+1) for i in range(len(s)+1)]

for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]+1)
        else:
            dp[i+1][j+1] = max(dp[i+1][j+1], max(dp[i][j+1], dp[i+1][j]))

# print(dp[len(s)][len(t)])


i = len(s)
j = len(t)
# print(type(i))
# print(type(j))
ans = ""
while (i > 0) and (j > 0):
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        ans += s[i-1]
        i -= 1
        j -= 1

print(ans[::-1])


### FIXED CODE ###

s = input()
t = input()

# dp = np.zeros(shape=(len(s), len(t)), dtype=np.int64)
dp = [[0] * (len(t)+1) for i in range(len(s)+1)]

for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]+1)
        else:
            dp[i+1][j+1] = max(dp[i+1][j+1], max(dp[i][j+1], dp[i+1][j]))

# print(dp[len(s)][len(t)])


i = len(s)
j = len(t)
# print(type(i))
# print(type(j))
ans = ""
while (i > 0) and (j > 0):
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        ans += s[i-1]
        i -= 1
        j -= 1

print(ans[::-1])
### BUGGY CODE ###

import sys
def f(j):
  if j==0:return 0
  if j<0: return 100000
  if dp[j]!=-1:return dp[j]
  f_k=[f(j-l-1)+abs(h[j]-h[j-l-1]) for l in range(k) if j-l-1>=0]
  dp[j]=min(f_k)
  return dp[j]
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[-1]*n
sys.setrecursionlimit(1000000000)
print(f(n-1))

### FIXED CODE ###

from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
from functools import lru_cache
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))
def inpl_str():
    '''
    一行に複数の文字
    '''
    return list(input().split())


n,k = inpl()
h = inpl()
dp = [INF] * (n)
dp[0] = 0
for i in range(min(n,k)):
    dp[i] = abs(h[i] - h[0])
for i in range(n - k):
    option=[dp[i+j]+abs(h[i+k]-h[i+j]) for j in range(k)]
    dp[i + k] = min(option)
print(dp[n - 1])
### BUGGY CODE ###

s=input()
n=len(s)
N=[0]*2020
x=0
for i in reversed(range(n)):
    x+=int(s[i])*(10**(n-i-1))
    x%=2019
    N[x%2019]+=1
ans=N[0]
for j in N:
    ans+=j*(j-1)//2
print(ans)

### FIXED CODE ###

from collections import defaultdict
s=input()
n=len(s)
N=defaultdict(int)
x=0
for i in reversed(range(n)):
    x+=int(s[i])*pow(10,(n-i-1),2019)
    x%=2019
    N[x]+=1
ans=N[0]
for j in N.values():
    ans+=j*(j-1)//2
print(ans)
### BUGGY CODE ###

S=input()
Q=int(input())
lis=[]
for _ in range(Q):
    lis.append(input().split())
ans=[S]
cnt=0
for i in lis:
    if(int(i[0]) == 1):
        cnt= (cnt+1) % 2
    elif((cnt== 0 and i[1]=='1') or (cnt == 1 and i[1]=='2')):
        ans.insert(0,i[2])
    else:
        ans.extend(i[2])
ans=''.join(ans)
print(ans[::-1]) if(cnt % 2 == 1) else print(ans)


### FIXED CODE ###

from collections import deque
S=input()
Q=int(input())
ans=deque(S)
cnt=0
for _ in range(Q):
    i=(input().split())
    if(int(i[0]) == 1):
        cnt= (cnt+1) % 2
    elif((cnt== 0 and i[1]=='1') or (cnt == 1 and i[1]=='2')):
        ans.appendleft(i[2])
    else:
        ans.append(i[2])
ans=''.join(ans)
print(ans[::-1]) if(cnt % 2 == 1) else print(ans)
### BUGGY CODE ###

import sys
# input処理を高速化する
input = sys.stdin.readline

def chmax(a, b):
    if a >= b:
        return a
    return b

def chmin(a, b):
    if a <= b:
        return a
    return b

def main():
    N = int(input())
    a = list(map(int, input().split()))

    # aiからajのX−Yの最大値
    # [左端,右端)=[l,r)からの遷移    
    # 左をとる[l+1,r)、右をとる[l,r−1)の2通り
    dp = [[0] * (N+2)  for _ in range(N+2)]
    dp[N+1][N+1] = 4999999995

    for len in range(1, N + 1):
        for i in range(N + 1 - len):
            j = i + len

            if (N - len) % 2 == 0:
                dp[i][j] = chmax(dp[i + 1][j] + a[i], dp[i][j - 1] + a[j - 1])
            else:
                dp[i][j] = chmin(dp[i + 1][j] - a[i], dp[i][j - 1] - a[j - 1])

    print(dp[0][N])
 


main()

### FIXED CODE ###

import sys
# input処理を高速化する
input = sys.stdin.readline

def chmax(a, b):
    if a >= b:
        return a
    return b

def chmin(a, b):
    if a <= b:
        return a
    return b

def main():
    N = int(input())
    a = list(map(int, input().split()))

    # aiからajのX−Yの最大値
    # [左端,右端)=[l,r)からの遷移    
    # 左をとる[l+1,r)、右をとる[l,r−1)の2通り
    dp = [[0] * (N+2)  for _ in range(N+2)]

    for len in range(1, N + 1):
        for i in range(N + 1 - len):
            j = i + len

            if (N - len) % 2 == 0:
                dp[i][j] = chmax(dp[i + 1][j] + a[i], dp[i][j - 1] + a[j - 1])
            else:
                dp[i][j] = chmin(dp[i + 1][j] - a[i], dp[i][j - 1] - a[j - 1])

    print(dp[0][N])

main()
### BUGGY CODE ###

n = int(input())
s = input()
l = [[0] * n for _ in range(n)]
ans = 0

for i in range(n)[::-1]:
    for j in range(n)[::-1]:
        if s[i] == s[j]:
            l[i][j] += 1
            
            if i < n-1 and j < n-1 and l[i+1][j+1] > 0:
                l[i][j] += l[i+1][j+1]
                
        now = min(l[i][j], i - j)
        ans = max(ans, now)

print(ans)

### FIXED CODE ###

n = int(input())
s = input()
l = [[0] * n for _ in range(n)]
ans = 0

for i in range(n)[::-1]:
    for j in range(n)[::-1]:
        if i >= j and s[i] == s[j]:
            l[i][j] += 1
            
            if i < n-1 and j < n-1 and l[i+1][j+1] > 0:
                l[i][j] += l[i+1][j+1]
                
        now = min(l[i][j], i - j)
        ans = max(ans, now)

print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import sys
# 12:55~
sys.setrecursionlimit(10**9)

N,M = map(int,input().split())
uv = [list(map(int,input().split())) for _ in range(M)]
S,T = map(int,input().split())

S -= 1
T -= 1
#%%
adj_list = [[] for _ in range(N)]
for u,v in uv:
    adj_list[u-1].append(v-1)

INF = 10**9+7
dist = [[INF]*3 for _ in range(N)]
dist[S][2] = 0

stack = [[S,0]]
while stack:
    v,count = stack.pop()
    nxt_v = adj_list[v]
    cnt = count%3
    for nv in nxt_v:
        if dist[nv][cnt]>(count+1)//3:
            dist[nv][cnt] = (count+1)//3
            stack.append([nv,count+1])
            
            
if dist[T][2]==INF:
    ans = -1
else:
    ans = dist[T][2]
print(ans)
            
        


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
from queue import Queue
# 12:55~
sys.setrecursionlimit(10**9)

N,M = map(int,input().split())
uv = [list(map(int,input().split())) for _ in range(M)]
S,T = map(int,input().split())

S -= 1
T -= 1
#%%
adj_list = [[[] for _ in range(3)] for _ in range(N)]
for u,v in uv:
    for i in range(3):
        adj_list[u-1][i].append([v-1,(i+1)%3])


INF = 10**9+7
dist = [[INF]*3 for _ in range(N)]
dist[S][0] = 0

stack = Queue()
stack.put([S,0])
while not stack.empty():
    v,c = stack.get()
    nxt_v = adj_list[v][c]
    for nv,nc in nxt_v:
        if dist[nv][nc]==INF:
            dist[nv][nc] = dist[v][c] + 1
            stack.put([nv,nc])
            
            
if dist[T][0]==INF:
    ans = -1
else:
    ans = dist[T][0]//3
print(ans)
### BUGGY CODE ###

l=list(input() for i in range(3))
tn =0
while len(l[tn])>0:
    if l[tn][0]=="a":
        l[tn]=l[tn][1:]
        tn=0
    elif l[tn][0]=="b":
        l[tn]=l[tn][1:]
        tn=1
    elif l[tn][0]=="c":
        l[tn]=l[tn][1:]
        tn=2
if tn==0:
    print("A")
elif tn==1:
    print("B")
elif tn==2:
    print("C")


### FIXED CODE ###

a, b, h=map(int, list(input() for i in range(3)))
print((a+b)*h//2)
### BUGGY CODE ###

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

D = dict.fromkeys(P, 0)
for key in D.keys():
    D[key] = sum([j for j in range(1, key + 1)]) / key
C = [D[p] for p in P]
T = [sum(C[i: i + k]) for i in range(0, n - k + 1)]

print(max(T))

### FIXED CODE ###

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

C = [(1 + p) / 2 for p in P]

ans = tmp = sum(C[: k])
for i in range(k, n):
    tmp += (C[i] - C[i - k])
    ans = max(tmp, ans)

print(ans)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
INF = float("inf")


def z_algorithm(S):
    """Zアルゴリズム
    https://snuke.hatenablog.com/entry/2014/12/03/214243 の二番目のコード
    """
    N = len(S)
    Z = [0]*N

    c = 0
    for i in range(1, N):
        if i+Z[i-c] < c+Z[c]:
            Z[i] = Z[i-c]
        else:
            j = max(0, c+Z[c]-i)
            while i+j < N and S[j] == S[i+j]:
                j += 1
            Z[i] = j
            c = i
    Z[0] = len(S)
    return Z


def solve(N: int, S: str):

    ans = 0
    for i in range(N-1):        # N
        z = z_algorithm(S[i:])  # N
        for j, zz in enumerate(z):  # N
            ans = max(min(j, zz), ans)
    print(ans)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
INF = float("inf")


def z_algorithm(S):
    """Zアルゴリズム
    https://snuke.hatenablog.com/entry/2014/12/03/214243 の二番目のコード
    """
    N = len(S)
    Z = [0]*N

    c = 0
    for i in range(1, N):
        if i+Z[i-c] < c+Z[c]:
            Z[i] = Z[i-c]
        else:
            j = max(0, c+Z[c]-i)
            while i+j < N and S[j] == S[i+j]:
                j += 1
            Z[i] = j
            c = i
    Z[0] = len(S)
    return Z


def solve(N: int, S: str):

    ans = 0
    for i in range(N-1):        # N
        z = z_algorithm(S[i:])  # N
        for j, zz in enumerate(z):  # N
            ans = max(min(j, zz), ans)
    print(ans)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

k = int(input())
n = 7
cnt = 1
while 1:
    if n % k == 0:
        print(cnt)
        exit()
    elif n % k != 0 and cnt < k +1:
        cnt += 1
        n = (n*10 + 7) % k
    elif (n % k != 0 and cnt > k + 1):
        print(-1)
        exit()


### FIXED CODE ###

k = int(input())

def cal(k):
    n = 7
    for i in range(1,10000000):
        if n % k == 0:
            return i
        else:
            n = (n *10 + 7) % k
    return -1

print(cal(k))
### BUGGY CODE ###

N, M = map(int, input().split(" "))
A = list(map(int, input().split(" ")))

for _ in range(M):
  i = A.index(max(A))
  A[i] = A[i] // 2

print(sum(A))

### FIXED CODE ###

import heapq
N, M = map(int, input().split(" "))
A = list(map(lambda x: -int(x), input().split(" ")))

heapq.heapify(A)

for _ in range(M):
  a = -heapq.heappop(A)
  a = a // 2
  heapq.heappush(A, -a)

print(-sum(A))
### BUGGY CODE ###

N=int(input())
str=input()

cnt=0
for i in range(N):
    if str[i] == 'R':
        for j in range(i+1,N):
            if str[j] == 'G':
                for k in range(j+1,N):
                    if str[k] == 'B':
                        if j-i != k-j:
                            cnt+=1

for i in range(N):
    if str[i] == 'R':
        for j in range(i+1,N):
            if str[j] == 'B':
                for k in range(j+1,N):
                    if str[k] == 'G':
                        if j-i != k-j:
                            cnt+=1

for i in range(N):
    if str[i] == 'G':
        for j in range(i+1,N):
            if str[j] == 'R':
                for k in range(j+1,N):
                    if str[k] == 'B':
                        if j-i != k-j:
                            cnt+=1

for i in range(N):
    if str[i] == 'G':
        for j in range(i+1,N):
            if str[j] == 'B':
                for k in range(j+1,N):
                    if str[k] == 'R':
                        if j-i != k-j:
                            cnt+=1

for i in range(N):
    if str[i] == 'B':
        for j in range(i+1,N):
            if str[j] == 'G':
                for k in range(j+1,N):
                    if str[k] == 'R':
                        if j-i != k-j:
                            cnt+=1

for i in range(N):
    if str[i] == 'B':
        for j in range(i+1,N):
            if str[j] == 'R':
                for k in range(j+1,N):
                    if str[k] == 'G':
                        if j-i != k-j:
                            cnt+=1

print(cnt)

### FIXED CODE ###

m=int(input())
N=input()
cnt=N.count('R')*N.count('G')*N.count('B')
#print(cnt)
for i in range(m-2):
  #print(i,'*',int((m+i)/2))
  for j in range(i+1,int((m+i-1)/2)+1):
    k=2*j-i
    #print(i,j,k)
    if N[k] != N[j] and N[j] != N[i] and N[i] != N[k]:
      #print(i,j,k)
      cnt-=1
print(cnt)
### BUGGY CODE ###

n=int(input())
x=list(map(int,input().split()))
ans=1
if x.count(0)>1:
   print(0)
for i in x:
  ans=ans*i
  if ans>10**18:
    ans=-1
print(ans)

### FIXED CODE ###

n=int(input())
x=list(map(int,input().split()))
ans=1
for i in x:
  if i==0:
    print(0)
    exit()

for i in x:
    ans=ans*i
    if ans>10**18:
      ans=-1
      break
print(ans)
### BUGGY CODE ###

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

b = []
for i in range(len(a)):
    b.append(a[i] - (i+1))

while True:
    p_num = []
    n_num = []
    z_num = []
    for i in range(len(b)):
        if b[i] > 0:
            p_num.append(b[i])
        elif b[i] < 0:
            n_num.append(b[i])
        else:
            z_num.append(b[i])

    if len(p_num) > len(n_num) + len(z_num):
        for i in range(len(b)):
            b[i] = b[i] - 1
    elif len(n_num) > len(p_num) + len(z_num):
        for i in range(len(b)):
            b[i] = b[i] + 1
    else:
        break

ans = 0
for i in range(len(b)):
    ans += abs(b[i])

print(ans)


### FIXED CODE ###

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

b = []
for i in range(len(a)):
    b.append(a[i] - (i+1))

p_num = []
n_num = []
z_num = []

for i in range(len(b)):
    if b[i] > 0:
        p_num.append(b[i])
    elif b[i] < 0:
        n_num.append(b[i])
    else:
        z_num.append(b[i])

p_num.sort()
n_num.sort()
n_num.reverse()

if len(p_num) > len(n_num) + len(z_num):
    count_n = len(n_num) + len(z_num)
    count_p = len(p_num)
    index = -1
    while  count_p > count_n:
        count_p -= 1
        count_n += 1
        index += 1
    for i in range(len(b)):
        b[i] = b[i] - p_num[index]

elif len(n_num) > len(p_num) + len(z_num):
    count_n = len(n_num)
    count_p = len(p_num) + len(z_num)
    index = -1
    while  count_n > count_p:
        count_n -= 1
        count_p += 1
        index += 1
    for i in range(len(b)):
        b[i] = b[i] - n_num[index]

ans = 0
for i in range(len(b)):
    ans += abs(b[i])

print(ans)
### BUGGY CODE ###

h, w = map(int, input().split())

ss = [[] for i in range(h)]

for i in range(h):
  ss[i] = list(str(input()))

s_h_l = [[0]*w for i in range(h)]
for i in range(h):
  light = 0
  for j in range(w):
    s_h_l[i][j] = light
    if ss[i][j] == '.':
      light += 1
    else:
      light = 0
      s_h_l[i][j] = 0
      
s_h_r = [[0]*w for i in range(h)]
for i in range(h):
  light = 0
  for j in reversed(range(w)):
    s_h_r[i][j] = light
    if ss[i][j] == '.':
      light += 1
    else:
      light = 0
      s_h_r[i][j] = 0

s_w_u = [[0]*w for i in range(h)]
for i in range(w):
  light = 0
  for j in range(h):
    s_w_u[j][i] = light
    if ss[j][i] == '.':
      light += 1
    else:
      light = 0
      s_w_u[j][i] = 0
      
s_w_d = [[0]*w for i in range(h)]
for i in range(w):
  light = 0
  for j in reversed(range(h)):
    s_w_d[j][i] = light
    if ss[j][i] == '.':
      light += 1
    else:
      light = 0
      s_w_d[j][i] = 0   

ans = 0
for i in range(h):
  for j in range(w):
    ans = max(ans, s_h_r[i][j]+s_h_l[i][j]+s_w_u[i][j]+s_w_d[i][j]+1)
print(ans)

### FIXED CODE ###

h, w = map(int, input().split())

ss = [[] for i in range(h)]

for i in range(h):
  ss[i] = list(str(input()))

s_h_l = [[0]*w for i in range(h)]
for i in range(h):
  light = 0
  for j in range(w):
    s_h_l[i][j] = light
    if ss[i][j] == '.':
      light += 1
    else:
      light = 0
      s_h_l[i][j] = 0
      
s_h_r = [[0]*w for i in range(h)]
for i in range(h):
  light = 0
  for j in reversed(range(w)):
    s_h_r[i][j] = light
    if ss[i][j] == '.':
      light += 1
    else:
      light = 0
      s_h_r[i][j] = 0

s_w_u = [[0]*w for i in range(h)]
for i in range(w):
  light = 0
  for j in range(h):
    s_w_u[j][i] = light
    if ss[j][i] == '.':
      light += 1
    else:
      light = 0
      s_w_u[j][i] = 0
      
s_w_d = [[0]*w for i in range(h)]
for i in range(w):
  light = 0
  for j in reversed(range(h)):
    s_w_d[j][i] = light
    if ss[j][i] == '.':
      light += 1
    else:
      light = 0
      s_w_d[j][i] = 0   

ans = 0
for i in range(h):
  for j in range(w):
    ans = max(ans, s_h_r[i][j]+s_h_l[i][j]+s_w_u[i][j]+s_w_d[i][j]+1)
print(ans)