Harryxun/stf_run huggingface dataset:
# -*- coding: utf-8 -*-
"""
Created on Sat Apr  1 22:07:55 2017

@author: taichiNakamura
"""

N = int(input())
# スペース区切りの整数の入力
num = map(int, input().split())

import numpy as np
num = np.array(num)
num = np.sort(num)
sum = 0
for i in range(N):
    sum += num[3*N - 2 - i*2]
# 出力
print(sum)

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sat Apr  1 22:07:55 2017

@author: taichiNakamura
"""
import numpy as np
N = int(input())
# スペース区切りの整数の入力
num = list(map(int, input().split()))

num = np.array(num, dtype="int64")
num.sort()
sum = 0

for i in range(N):
    sum += num[3*N - 2 - i*2]
# 出力
print(sum)
import numpy as np
N, K = map(int, input().split())
pi = list(map(int, input().split()))
K_sum = []
for i in range(N-K+1):
    K_sum.append(sum(pi[i:i+K])) 
index = K_sum.index(max(K_sum))
array_max = (np.array(pi[index:index+K])-1) *0.5 + 1
print(array_max.sum())

### FIXED CODE ###

S, T = map(str,input().split())
A, B = map(int,input().split())
U = input()
if U == S:
    A -= 1
else:
    B -= 1
print(str(A) +' '+ str(B))
import sys

def bigsmall(x,y):
    return (x,y) if x>y else (y,x)

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

    if len(a) == 2:
        b,s = bigsmall(a[0],a[1])
        print(b-s)
        print(b,s)
        sys.exit()

    ops = []
    curr = 0
    b,s = bigsmall(a[0],a[-1])
    if a[1] <= 0:
        ops.append((b,s))
        curr = b - s
    else:
        ops.append((s,b))
        curr = s - b

    a.remove(len(a))
    a.append(-1) # to set answer > 0

    for i in range(1, len(a)-1):
        b,s = bigsmall(curr,a[i])

        if a[i+1] <= 0:
            ops.append((b,s))
            curr = b - s
        else:
            ops.append((s,b))
            curr = s - b

    print(curr)
    for x,y in ops:
        print(x,y)

if __name__=='__main__':
    main()

### FIXED CODE ###

import sys

def bigsmall(x,y):
    return (x,y) if x>y else (y,x)

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

    if len(a) == 2:
        b,s = bigsmall(a[0],a[1])
        print(b-s)
        print(b,s)
        sys.exit()

    ops = []
    curr = 0
    b,s = bigsmall(a[0],a[-1])
    if a[1] <= 0:
        ops.append((b,s))
        curr = b - s
    else:
        ops.append((s,b))
        curr = s - b

    del a[-1]
    a.append(-1) # to set answer > 0

    for i in range(1, len(a)-1):
        b,s = bigsmall(curr,a[i])

        if a[i+1] <= 0:
            ops.append((b,s))
            curr = b - s
        else:
            ops.append((s,b))
            curr = s - b

    print(curr)
    for x,y in ops:
        print(x,y)

if __name__=='__main__':
    main()
from fractions import gcd
A,B,C,D = map(int, input().split())
X = B//C - (A-1)//C
Y = B//D - (A-1)//D
lcm = round(C*D//math.gcd(C,D))
Z = B//lcm - (A-1)//lcm
print(B-A+1-X-Y+Z)

### FIXED CODE ###

from fractions import gcd
A,B,C,D = map(int, input().split())
X = B//C - (A-1)//C
Y = B//D - (A-1)//D
lcm = round(C*D//gcd(C,D))
Z = B//lcm - (A-1)//lcm
print(B-A+1-X-Y+Z)
N,K = map(int,input().split())
S = input()
if S[K-1] == 'A':
  S[K-1] = 'a'
elif S[K-1] == 'B':
  S[K-1] = 'b'
elif S[K-1] == 'C':
  S[K-1] = 'c'
print(S)

### FIXED CODE ###

N,K = map(int,input().split())
a = input()
res = ''
S = [el for el in a]
if S[K-1] == 'A':
  S[K-1] = 'a'
elif S[K-1] == 'B':
  S[K-1] = 'b'
elif S[K-1] == 'C':
  S[K-1] = 'c'
for el in S:
  res += el
print(res)
n,m=map(int, input().split())
road_num=[0]*n
for i in range(m):
  a,b=map(int, input().split())
  road_num[a]+=1
  road_num[b]+=1
for i in range(n):
  print(road_num[i])

### FIXED CODE ###

n,m=map(int, input().split())
road_num=[0]*n
for i in range(m):
  a,b=map(int, input().split())
  road_num[a-1]+=1
  road_num[b-1]+=1
for i in range(n):
  print(road_num[i])
A, B, C = map(int, raw_input().split())

if (C % A) % (B % A) == 0:
    print('YES')
else:
    print('NO')


### FIXED CODE ###

import sys

A, B, C = map(int, raw_input().split())

for i in range(1, 101):
    if C == 0 and (B * i % A) == 0 or \
            (C % A) == 0 and (B * i % A) == 0 or \
            (B * i % A) != 0 and (C % A) % (B * i % A) == 0:
        print('YES')
        sys.exit()

print('NO')
lst = map(int,input().split())

if lst[0] > lst[1]:
  print('Alice')
elif lst[0] < lst[1]:
  print('Bob')
else:
  print('Draw')



### FIXED CODE ###

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

if lst[1] != 1 and lst[0] > lst[1] :
    print('Alice')
elif lst[0] != 1 and lst[0] < lst[1]:
    print('Bob')
elif lst[1] == 1 and lst[0] != 1:
    print('Bob')
elif lst[0] == 1 and lst[1] != 1:
    print('Alice')
else:
  print('Draw')
from collections import Counter
 
def counter(list_1):
	return reduce(lambda a,b:a*b,map(lambda x:x+1,list_1))

N=input()
S=list(input())
answer=counter(s)
print(answer)

### FIXED CODE ###

from collections import Counter
from functools import reduce
 
def counter(list_1):
	return ((reduce(lambda a,b:a*b,map(lambda x:x+1,list_1))-1)%(10**9+7))
  
N=input()
S=input()
answer=counter(Counter(S).values())
print(answer)
from collections import deque

H, W = list(map(int,input().split()))
s = []
for i in range(H):  s.append(input())

dx = [0, 1, -1, 0]
dy = [1, 0, 0, -1]
           
def bfs(sx, sy):
    q = deque([])
    d = [[-1 for _ in range(W)] for _ in range(H)]
    q.append([sx, sy])
    d[sy][sx] = 0
    
    while(q):
        pop = q.popleft()
        x, y = pop[0], pop[1]
        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]
            if 0 <= nx and nx < W and ny >= 0 and ny < H:
                if s[ny][nx] != "#" and d[ny][nx] == -1:
                    q.append([nx, ny])
                    d[ny][nx] = d[y][x] + 1
    return d

def max_dim2(d):
    ret = 0
    for i in range(len(d)):
        for j in d[i]:
            ret = max(ret, j)
    return ret

ans = 0
for i in range(H):
    for j in range(W):
        if s[i][j] == ".":
            ret = bfs(i, j)
            temp = max_dim2(ret)
            ans = max(ans, temp)
print(ans)    

### FIXED CODE ###

from collections import deque

H, W = list(map(int,input().split()))
s = []
for i in range(H):  s.append(input())

dx = [0, 1, -1, 0]
dy = [1, 0, 0, -1]
           
def bfs(sx, sy):
    q = deque([])
    d = [[-1 for _ in range(W)] for _ in range(H)]
    q.append([sx, sy])
    d[sx][sy] = 0
    
    while(q):
        pop = q.popleft()
        x, y = pop[0], pop[1]
        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]
            if 0 <= nx and nx < H and ny >= 0 and ny < W:
                if s[nx][ny] != "#" and d[nx][ny] == -1:
                    q.append([nx, ny])
                    d[nx][ny] = d[x][y] + 1
    return d

def max_dim2(d):
    ret = 0
    for i in range(len(d)):
        for j in d[i]:
            ret = max(ret, j)
    return ret

ans = 0
for i in range(H):
    for j in range(W):
        if s[i][j] == ".":
            ret = bfs(i, j)
            temp = max_dim2(ret)
            ans = max(ans, temp)
print(ans)
a, b=map(int,imput().split())
if a < b:
 print('a < b')
elif a > b:
 print('a > b')
elif a == b:
 print('a == b')
else:
 pass

### FIXED CODE ###

a, b=map(int,input().split())
if a<b:
 print("a < b")
elif a>b:
 print("a > b")
elif a==b:
 print("a == b")
else:
 pass
N = int(input())
a = 1000-N%1000
if a = 1000:
  a = 0
print(a)

### FIXED CODE ###

N = int(input())
a = 1000-N%1000
if a == 1000:
  a = 0
print(a)
import re

N, K = map(int, input().split())
S = input().strip()

LL = re.finditer(r'L{1,}', S)
RR = re.finditer(r'R{1,}', S)

happy = 0
next_happy = []

for l in LL:
    happy += len(l[0]) - 1
    if l.regs[0][0] == 0 or l.regs[0][1] == N:
        next_happy.append(1)
    else:
        next_happy.append(2)

for r in RR:
    happy += len(r[0]) - 1
    if r.regs[0][0] == 0 or r.regs[0][1] == N:
        next_happy.append(1)
    else:
        next_happy.append(2)

happy += sum(sorted(next_happy, reverse=True)[:K])


print(happy)


### FIXED CODE ###

import re

N, K = map(int, input().split())
S = input().strip()

LL = re.finditer('L+', S)
RR = re.finditer('R+', S)

happy = 0
next_happy = []

for l in LL:
    happy += len(l.group(0)) - 1
    if l.regs[0][0] == 0 or l.regs[0][1] == N:
        next_happy.append(1)
    else:
        next_happy.append(2)

for r in RR:
    happy += len(r.group(0)) - 1
    if r.regs[0][0] == 0 or r.regs[0][1] == N:
        next_happy.append(1)
    else:
        next_happy.append(2)

happy += sum(sorted(next_happy, reverse=True)[:K])

if happy >= N:
    happy = N - 1

print(happy)
list = mat(int, input().split())
if list[0] * list[1] % 2 == 0:
  print('Even')
  else:
    print('Odd')

### FIXED CODE ###

list = list(map(int, input().split()))
if list[0] * list[1] % 2 == 0:
    print('Even')
else:
    print('Odd')
# -*- coding: utf-8 -*-
from pprint import pprint
import itertools

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

rui = [0]
tmp = 0
for a in an:
    rui.append(tmp+a)
    tmp += a

sum_list = [] 

for l in range(1,N+1):
    for r in range(l,N+1):
        tmp = rui[r] - rui[l-1]
        sum_list.append(tmp)

bin_list = [[0 for _ in range(32)] for _ in range(len(sum_list))]

for i,s in enumerate(sum_list):
    tmps = bin(s)[2:]
    for j, b in enumerate(reversed(tmps)):
        bin_list[i][j] = int(b)


### FIXED CODE ###

# -*- coding: utf-8 -*-
from pprint import pprint
import itertools

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

rui = [0]
tmp = 0
for a in an:
    rui.append(tmp+a)
    tmp += a

sum_list = [] 

for l in range(1,N+1):
    for r in range(l,N+1):
        tmp = rui[r] - rui[l-1]
        sum_list.append(tmp)

max_val = max(sum_list)
max_2pow = len(bin(max_val)[2:])
ans = 0
# print(ans,max_2pow)
while max_2pow > 0:
    tmp = ans + 2**(max_2pow-1)
    if sum([1 for v in sum_list if v & tmp == tmp]) >= K:
        ans += 2**(max_2pow-1)
    max_2pow -= 1

print(ans)
#a,b,c = map(int, input().split())

if (a >= b) and (a >= c):
    print(b*c/2)
if (b >= a) and (b >= c):
    print(a*c/2)
if (c >= a) and (c >= b):
    print(a*b/2)

### FIXED CODE ###

a,b,c = map(int, input().split())

if (a >= b) and (a >= c):
    print(int(b*c/2))
if (b >= a) and (b >= c):
    print(int(a*c/2))
if (c >= a) and (c >= b):
    print(int(a*b/2))
s = input()
t = input()
ans = 0
for i in range(3):
  if s[i] == t[i]:
    ans +=1
ptiny(ans)

### FIXED CODE ###

s = input()
t = input()
ans = 0
for i in range(3):
  if s[i] == t[i]:
    ans +=1
print(ans)
from collections import deque
d = deque(input())
flag = 0
for T_F_C in (input().split() for _ in range(int(input()))):
    if T_F_C[0] == '1':
        flag ^= 1
        continue
    _, f, c = T_F_C
    if (flag+int(f)) % 2:
	d.appendleft(c)
    else:
        d.append(c)
if flag:
    d = reversed(d)
print("".join(d))

### FIXED CODE ###

#!/usr/bin/env python3

def main():
    from itertools import chain
    S = input()
    Q = int(input())
    Queries = [input().split() for _ in range(Q)]
    H_T = H, T = [], []
    flag = 0
    for query in Queries:
        if len(query) == 1:
            flag ^= 1
            continue
        _, f, c = query
        H_T[(int(f) + flag - 1) % 2].append(c)
    t = ''.join(chain(reversed(H), S, T))
    if flag:
        t = reversed(t)
    print(''.join(t))


if __name__ == '__main__':
    main()
import math
n,k = map(int,input().split())
def com(x,y):
  return math.factorial(x)//math.factorial(x-y)*math.factorial(y)

for i in range(1,k-1):
  t = com(n-k+i,i)
  s = com(k+i-1,i-1)
  u = int(s*t(10**9+7))
  print(u)

### FIXED CODE ###

import math
 
def combination_count(n,k):
    if k > n or k < 0:
        return 0
    if n == 0 or k == 0:
        return 1
    
    s = math.factorial(n)
    t = math.factorial(k)
    u = math.factorial(n-k)
    
    return s//(t*u)
    
n,k = map(int,input().split())
 
mod = 10**9 + 7
 
for i in range(1,k+1):
    x = combination_count(n-k+1,i) * combination_count(k-1, i-1)
    print(x%mod)
N = int(input())
e = [[] for _ in range(N+1)]
for _ in range(N-1):
  u, v, w = map(int, input().split())
  e[u].append((v,w))
  e[v].append((u,w))

col = [-1 for _ in range(N+1)]
def dfs(x, c):
    col[x] = c
    for v, w in e[x]:
        if col[v] == -1:
            dfs(v, c+w%2)

dfs(1, 0)

for c in col[1:]:
    print(c)

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

N = int(input())
e = [[] for _ in range(N+1)]
for _ in range(N-1):
  u, v, w = map(int, input().split())
  e[u].append((v,w))
  e[v].append((u,w))

col = [-1 for _ in range(N+1)]
def dfs(x, c):
    col[x] = c
    for v, w in e[x]:
        if col[v] == -1:
            dfs(v, (c+w%2)%2)

dfs(1, 0)

for c in col[1:]:
    print(c)
S1,S2,S3 = list(map(str,input().split()))
s1.upper()
s2.upper()
s3.upper()
print(s1,s2,s3)

### FIXED CODE ###


s1, s2, s3 = input().split()
print(s1[0].upper() + s2[0].upper() + s3[0].upper())
r=input("r:")
PI=3.14
s1=(r**2)*PI
print(s1/PI)

### FIXED CODE ###

r=input()
print(r**2)
n, k = list(map(int, input().split(" ")))
x = list(map(int, input().split(" ")))

if((0 in x) == True):
    state = x.index(0)
    count = 1
else:
    x.append(0)
    x = sorted(x)
    state = x.index(0)
    count = 0

ans = int(1e9)
for left in range(k-count+1):
    right = k - count - left
    if(((state - left) >= 0) and ((state + right) <= (len(x)))):
        if(right > 0): tmp = -2 * x[state-left]
        else: tmp = -1 * x[state-left]
        tmp += x[state+right]
        if(ans > tmp): ans = tmp

print(ans)

### FIXED CODE ###

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

if((0 in x) == True):
    state = x.index(0)
    k -= 1
else:
    x.append(0)
    x = sorted(x)
    state = x.index(0)

ans = int(1e10)
for left in range(k+1):
    right = k - left
    if(((state - left) >= 0) and ((state + right) <= (len(x) - 1))):
        if(right > 0): tmp = -2 * x[state-left]
        else: tmp = -1 * x[state-left]
        tmp += x[state+right]
        if(ans > tmp): ans = tmp

        tmp = -1 * x[state-left]
        if(left > 0): tmp += 2 * x[state+right]
        else: tmp += x[state+right]
        if(ans > tmp): ans = tmp

print(ans)
i = 0
while 1:
   x,y = map(int, raw_input().split())
   i += 1
   if x == '0' and y == '0':
      break
   if x >= y:
      print '%s %s' % (y,x)
   else:
      print '%s %s' % (x,y)
   

### FIXED CODE ###

while True:
   x,y = map(int, raw_input().split())
   if x == 0 and y == 0:
      break
   if x >= y:
      print '%s %s' % (y, x)
   else:
      print '%s %s' % (x, y)
from math import *
a, b, c, d = map(int, input().split())
a -= 1
B = b - (b//c + b//d)+b//(c*d//gcd(c, d))
A = a - (a//c + a//d)+a//(c*d//gcd(c, d))

print(B - A)


### FIXED CODE ###

import fractions
a, b, c, d = map(int, input().split())
a -= 1
B = b - (b//c + b//d)+b//(c*d//fractions.gcd(c, d))
A = a - (a//c + a//d)+a//(c*d//fractions.gcd(c, d))

print(B - A)
import sys
import numpy as np

input = sys.stdin.readline

N,K = map(int, input().split())
h = [int(i) for i in input().split()]
dp = [float('inf')] * N
h = np.array(h)

dp[0] = 0
for i in range(1, N):
  tmp = i
  if tmp > K:
    tmp = K
  for j in range(1,tmp + 1):
      dp[i] = min(dp[i], dp[i - j] + abs(h[i - j] - h[i]))

print(dp[N-1])


### FIXED CODE ###

N,K = map(int, input().split())
h = list(map(int, input().split()))
dp = [float('inf')] * 10 ** 5

dp[0] = 0
for i in range(1, N):
  tmp = i
  if tmp > K:
    tmp = K
  for j in range(1,tmp + 1):
      dp[i] = min(dp[i], dp[i - j] + abs(h[i - j] - h[i]))

print(dp[N-1])
import sys

day = sys.stdin().read().strip()

days = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']

day_index = days.index(day)

print(7-day_index)

### FIXED CODE ###

import sys

day = sys.stdin.read().strip()

days = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']

day_index = days.index(day)

print(7-day_index)
import math

def isprime(number):
    for i in range(2, round(math.sqrt(number)) + 1):
        if number % i == 0:
            return False
    return True

A, B = map(int, input().split())
count = 1
N = math.gcd(A, B)

for i in range(2, N + 1):
    if N % i == 0:
        if isprime(i):
            count += 1
            print(str(i))
print(str(count))


### FIXED CODE ###

from fractions import gcd
def f(n):
    tmp = n
    cnt = 0
    i = 2
    while i <= n**0.5 + 1:
        if tmp < i:
            break
        if tmp % i == 0:
            cnt += 1
            while tmp % i == 0:
                tmp //= i
        i += 1
    if tmp != 1:
        cnt += 1
    return cnt

A, B = map(int, input().split())
g = gcd(A, B)
ans = f(g) + 1
print(ans)
num, bricks, count, smash = int(input()), [int(x) for x in input().split(" ")], 1, 0
for x in bricks:
    if count == x: count += 1
    else: smash += 1
print(smash if smash != len(bricks) else 0 if len(bricks) == 1 else -1)

### FIXED CODE ###

def gcd(a, b):
    return b if a == 0 else gcd(b%a, a)
num = [int(x) for x in input().split(" ")]
print(int(num[0]*num[1]/gcd(num[0], num[1])))
N,K=map(int,input().split())
L=list(map(int,input().split()))
R=list()
if K>=N:
  sums=0
  for i in range(N):
    sums+=L[i]
    sums%=K
    a=(sums-i-1)%K
    R.append(a)
    c[a]+=1
  ans=0
  c=[0]*K
  for i in range(N):
    s=(K-R[i])%K
    ans+=c[s]
  print(ans)
else:
  ans=0
  c=[0]*K
  sums=0
  for i in range(N):
    sums+=L[i]
    sums%=K
    a=(sums-i-1)%K
    R.append(a)
  for i in range(K-1):
    c[R[i]]+=1
  ans+=c[0]
  c[R[K-1]]+=1
  for i in range(N):
    if i<N-K:
      ans+=c[R[i]]-1
      c[R[i]]-=1
      c[R[i+K]]+=1
    else:
      ans+=c[R[i]]-1
      c[R[i]]-=1
  print(ans)

### FIXED CODE ###

N,K=map(int,input().split())
L=list(map(int,input().split()))
R=list()
if K>=N:
  sums=0
  c=dict()
  for i in range(N):
    sums+=L[i]
    sums%=K
    a=(sums-i-1)%K
    if a in c:
      c[a]+=1
    else:
      c[a]=1
  ans=0
  for i in c:
    ans+=(c[i]-1)*c[i]//2
  if 0 in c:
    print(ans+c[0])
  else:
    print(ans)
else:
  ans=0
  c=[0]*K
  sums=0
  for i in range(N):
    sums+=L[i]
    sums%=K
    a=(sums-i-1)%K
    R.append(a)
  for i in range(K-1):
    c[R[i]]+=1
  ans+=c[0]
  c[R[K-1]]+=1
  for i in range(N):
    if i<N-K:
      ans+=c[R[i]]-1
      c[R[i]]-=1
      c[R[i+K]]+=1
    else:
      ans+=c[R[i]]-1
      c[R[i]]-=1
  print(ans)
INF=100000000
def frog(i,h,dp):
    global INF
    if dp[i]!=INF:
        return dp[i]
    else:
        if i==1:
            dp[i]=0
            return dp[i]
        elif i==2:
            dp[i]=abs(h[1]-h[0])
            return dp[i]
        else:
            dp[i]=min(frog(i-2,h,dp)+abs(h[i-1]-h[i-3]),frog(i-1,h,dp)+abs(h[i-1]-h[i-2]))
            return dp[i]
sys.setrecursionlimit(INF)
N=int(input())
h=list(map(int,input().split()))
dp=[INF for i in range(N+1)]
print(frog(N,h,dp))


### FIXED CODE ###

import sys
INF=100000000
def frog(i,h,dp):
    global INF
    if dp[i]!=INF:
        return dp[i]
    else:
        if i==1:
            dp[i]=0
            return dp[i]
        elif i==2:
            dp[i]=abs(h[1]-h[0])
            return dp[i]
        else:
            dp[i]=min(frog(i-2,h,dp)+abs(h[i-1]-h[i-3]),frog(i-1,h,dp)+abs(h[i-1]-h[i-2]))
            return dp[i]
sys.setrecursionlimit(INF)
N=int(input())
h=list(map(int,input().split()))
dp=[INF for i in range(N+1)]
print(frog(N,h,dp))
n,m=map(int,input().split())
ans=0
n%=m
ans=(min(n,(m-n))
print(ans)


### FIXED CODE ###

n,m=map(int,input().split())
ans=0
n%=m
#print(n,m)
ans=min(n,(m-n))
print(ans)
# s = input()
# n = int(input())
# A = list(map(int, input().split()))
H, W = map(int, input().split())
S = []
vertical = []
horizontal = []

for _ in range(H):
    s = input()
    S.append(s)
    vertical.append([-1]*W)
    horizontal.append([-1]*W)

def search_vertical(i, j, current):
    if i == H-1 or S[i+1][j] == '#':
        vertical[i][j] = current
        return current
    vertical[i][j] = search_vertical(i+1, j, current+1)
    return vertical[i][j]

def search_horizontal(i, j, current):
    if j == W-1 or S[i][j+1] == '#':
        horizontal[i][j] = current
        return current
    horizontal[i][j] = search_horizontal(i, j+1, current+1)
    return horizontal[i][j]

res = -2
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            continue
        if vertical[i][j] == -1:
            search_vertical(i, j, 1)
        if horizontal[i][j] == -1:
            search_horizontal(i, j, 1)
        res = max(res, vertical[i][j] + horizontal[i][j] -1)

print(res)


### FIXED CODE ###


# s = input()
# n = int(input())
# A = list(map(int, input().split()))
H, W = map(int, input().split())
S = []
vertical = []
horizontal = []

for _ in range(H):
    s = input()
    S.append(s)
    vertical.append([-1]*W)
    horizontal.append([-1]*W)

def search_vertical(i, j, current):
    i2 = i

    while not (i2 == H-1 or S[i2+1][j] == '#'):
        i2 += 1
        current += 1

    for i3 in range(i, i2+1):
        vertical[i3][j] = current

def search_horizontal(i, j, current):
    j2 = j

    while  not (j2 == W-1 or S[i][j2+1] == '#'):
        j2 += 1
        current += 1

    for j3 in range(j, j2+1):
        horizontal[i][j3] = current


res = -2
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            continue
        if vertical[i][j] == -1:
            search_vertical(i, j, 1)
        if horizontal[i][j] == -1:
            search_horizontal(i, j, 1)
        res = max(res, vertical[i][j] + horizontal[i][j] -1)

# print(vertical)
print(res)
# coding: utf-8
import itertools
N = input()
ans = 0

for i in range(3, len(N)+1):
    for ptn in itertools.product((3,5,7), repeat=i):
        if (3 not in ptn) or (5 not in ptn) or (7 not in ptn):
            continue
        a = int("".join(list(map(str, ptn))))
        if a <= N:
            ans += 1
print(ans)

### FIXED CODE ###

# coding: utf-8
N = int(input())

def dfs(s):
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in "753") else 0
    for c in "753":
        ret += dfs(s + c)
    return ret

print(dfs("0"))
t = input()

l = [_ for i in range(len(t))]
r = [] * (len(t))
print(l)
for i in range(0, len(t)):
    print(i)
    if t[i] =="?":
        l[i] = "D"
    
    else:
        l[i] = t[i]

print("".join(l))

### FIXED CODE ###

t = input()

l = ["" for i in range(len(t))]
for i in range(0, len(t)):
    if t[i] =="?":
        l[i] = "D"
    
    else:
        l[i] = t[i]

print("".join(l))
n = input()
a = list(map(int, input().split()))
ans = float('inf')
for i in a:
    ans = min(ans, len(bin(i)) - bin(i).rfind('1') - 1)
print(round(ans))

# %% 	Coins
a, b, c, x = map(int, [input() for i in range(4)])
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i * 500 + j * 100 + k * 50 == x:
                ans += 1
print(ans)

### FIXED CODE ###

n = input()
a = list(map(int, input().split()))
ans = float('inf')
for i in a:
    ans = min(ans, len(bin(i)) - bin(i).rfind('1') - 1)
print(round(ans))
n=int(input())
h=list(map(int,input().split()))

ans=0
while sum(h)>0:
  for i in range(n):
    if i<n-1 and h[i]>0 and h[i+1]==0:
      ans+=1
    else:
      if i==N-1 and h[i]>0:
        ans+=1
    if h[i]>0:
      h[i]-=1
print(ans)      

### FIXED CODE ###

N=int(input())
h=list(map(int,input().split()))

ans=0
while sum(h)>0:
  for i in range(N):
    if i<N-1 and h[i]>0 and h[i+1]==0:
      ans+=1
    else:
      if i==N-1 and h[i]>0:
        ans+=1
    if h[i]>0:
      h[i]-=1
  #print(h)
print(ans)