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

n = int(input())
ar = [input() for _ in range(n)]

d = {}

for a in ar:
    if a in d:
        d[a] += 1
    else:
        d[a] = 1

print("\n".join(sorted([k for k, v in d.items() if v == max(d.values())])))

### FIXED CODE ###

n = int(input())
ar = [input() for _ in range(n)]

d = {}

for a in ar:
    if a in d:
        d[a] += 1
    else:
        d[a] = 1

max_val = max(d.values())
print("\n".join(sorted([key for key in d if d[key] == max_val])))
### BUGGY CODE ###

S = input()
N = len(S)

children = [0] * N

for j in range(N): # 子供ごと

	if S[j] == 'R':
		pos_next = j + 1
		while S[pos_next] == 'R':
			pos_next += 1

		num_until_turn = pos_next - j

		if num_until_turn % 2 == 0:
			children[pos_next] += 1
		else:
			children[pos_next-1] += 1

	else:  # 'L'
		pos_next = j - 1
		while S[pos_next] == 'L':
			pos_next -= 1

		num_until_turn = pos_next - j

		if num_until_turn % 2 == 0:
			children[pos_next] += 1
		else:
			children[pos_next+1] += 1

print(*children)


### FIXED CODE ###

S = input()
N = len(S)

children = [0] * N

turn_position = list()

for i in range(N-1):
	if S[i]=='R' and S[i+1]=='L':
		turn_position.append(i)

for turn_i in range(len(turn_position) - 1):
	turn_pos = turn_position[turn_i]
	turn_pos_next = turn_position[turn_i + 1]

	children[turn_pos] += 1
	children[turn_pos+1] += 1

	for pos_i in range(turn_pos+2, turn_pos_next):
		if S[pos_i] == 'L':
			if (pos_i - turn_pos) % 2 == 0:
				children[turn_pos] += 1
			else:
				children[turn_pos+1] += 1
		else:
			if (turn_pos_next - pos_i) % 2 == 0:
				children[turn_pos_next] += 1
			else:
				children[turn_pos_next+1] += 1

turn_pos_first = turn_position[0]
for pos_i in range(0, turn_pos_first):
	if (turn_pos_first - pos_i) % 2 == 0:
		children[turn_pos_first] += 1
	else:
		children[turn_pos_first+1] += 1

turn_pos_last = turn_position[-1]
children[turn_pos_last] += 1
children[turn_pos_last+1] += 1
for pos_i in range(turn_pos_last+2, N):
	if (pos_i - turn_pos_last) % 2 == 0:
		children[turn_pos_last] += 1
	else:
		children[turn_pos_last+1] += 1

print(*children)
### BUGGY CODE ###

from collections import defaultdict
from heapq import heappop, heappush,heapify
import sys
input = sys.stdin.readline

N,M,S = map(int,input().split())
UVAB = [list(map(int,input().split())) for i in range(M)]
U,V,A,B = zip(*UVAB)
mc = max(A)* M
g = defaultdict(list)

for u,v,a,b in UVAB:
    for i in range(a,mc+1):
        g[u+N*i].append((v+N*(i-a),b))
        g[v+N*i].append((u+N*(i-a),b))
CD = [[0,0]] + [list(map(int,input().split())) for i in range(N)]
C,D = zip(*CD)
C = [min(c,mc) for c in C]

for i in range(1,N+1):
    for c in range(mc+1-C[i]):
        g[i+N*c].append((i+N*(c+C[i]),D[i]))

S = min(S,mc)
dq = [(0,S,1)]

ans = [[10**15 for j in range(mc+1)] for i in range(N+1)]
while dq:
    t, w, v = heappop(dq)
    if ans[v][w] < t:
        continue
    ans[v][w] = t
    for temp, nt in g[v+N*w]:
        nv = ((temp-1) % N)+1
        nw = (temp-1) // N
        if ans[nv][nw] > t + nt:
            heappush(dq,(t+nt,nw,nv))

for i in range(2,N+1):
    print(min(ans[i]))





### FIXED CODE ###

from collections import defaultdict
from heapq import heappop, heappush,heapify
import sys
input = sys.stdin.readline

N,M,S = map(int,input().split())
UVAB = [list(map(int,input().split())) for i in range(M)]
U,V,A,B = zip(*UVAB)

'''
from itertools import combinations 
N = 14
M = N*(N-1)//2
S = 0
UVAB = [[x,y,50,10**9] for x,y in combinations(range(1,N+1),2)] 
U,V,A,B = zip(*UVAB)
'''

mc = max(A)* M
g = defaultdict(list)

for u,v,a,b in UVAB:
    for i in range(a,mc+1):
        g[(u,i)].append(((v,i-a),b))
        g[(v,i)].append(((u,i-a),b))

CD = [[0,0]] + [list(map(int,input().split())) for i in range(N)]
#CD = [[0,0]] + [[10**9,10**9] for i in range(N)]
C,D = zip(*CD)
C = [min(c,mc) for c in C]

for i in range(1,N+1):
    for c in range(mc+1-C[i]):
        g[(i,c)].append(((i,c+C[i]),D[i]))

S = min(S,mc)
dq = [(0,S,1)]

ans = [[10**15 for j in range(mc+1)] for i in range(N+1)]
while dq:
    t, w, v = heappop(dq)
    if ans[v][w] <= t:
        continue
    for i in range(w+1):
        ans[v][i] = min(t, ans[v][i])
    for (nv,nw), nt in g[(v,w)]:
        if ans[nv][nw] > t + nt:
            heappush(dq,(t+nt,nw,nv))

for i in range(2,N+1):
    print(min(ans[i]))
### BUGGY CODE ###

S = input()
dp = [[0 for i in range(4)] for i in range(len(S)+1)]
MOD = 10**9+7
dp[0][3] = 1
for i in range(len(S)):
    x = S[i]
    if x == '?': k = 3
    else: k = 1
    for _ in range(k):
        dp[i+1][0] += dp[i][0] 
        dp[i+1][1] += dp[i][1] 
        dp[i+1][2] += dp[i][2] 
        dp[i+1][3] += dp[i][3] 
    if x == 'A':
        dp[i+1][0] +=  dp[i][3]
    elif x == 'B':
        dp[i+1][1] +=  dp[i][0]
    elif x == 'C':
        dp[i+1][2] += dp[i][1]
    else:
        dp[i+1][0] += dp[i][3]
        dp[i+1][1] += dp[i][0]
        dp[i+1][2] += dp[i][1]
    for j in range(3):
        if dp[i][j] > MOD: dp[i][j] %= MOD
print(dp[len(S)][2]%MOD)



### FIXED CODE ###

S = input()
dp = [[0 for i in range(4)] for i in range(len(S)+1)]
MOD = 10**9+7
dp[0][3] = 1
for i in range(len(S)):
    if S[i] == '?': k = 3
    else: k = 1
    for _ in range(k):
        dp[i+1][0] += dp[i][0] 
        dp[i+1][1] += dp[i][1] 
        dp[i+1][2] += dp[i][2] 
        dp[i+1][3] += dp[i][3] 
    if S[i] == 'A':
        dp[i+1][0] +=  dp[i][3]
    elif S[i] == 'B':
        dp[i+1][1] +=  dp[i][0]
    elif S[i] == 'C':
        dp[i+1][2] += dp[i][1]
    else:
        dp[i+1][0] += dp[i][3]
        dp[i+1][1] += dp[i][0]
        dp[i+1][2] += dp[i][1]
    for j in range(4):
        if dp[1+i][j] > MOD: dp[i+1][j] %= MOD
print(dp[len(S)][2]%MOD)
### BUGGY CODE ###

N = int(input())
S = list(input())

ans = float("inf")
for i in range(N):
    if i == 0:
        count = S[1:].count("E")
    elif i < N:
        count = S[:i].count("W") + S[i+1:].count("E")
    else:
        count = S[:N-1].count("W")
    if ans > count:
        ans = count

print(ans)

### FIXED CODE ###

N = int(input())
S = list(input())

left = [0 for i in range(N)]
right = [0 for i in range(N)]
for i in range(1, N):
    if S[i-1] == "W":
        left[i] = left[i-1] + 1
    else:
        left[i] = left[i-1]
for i in range(N-1):
    if S[(N-1)-i] == "E":
        right[(N-2)-i] = right[(N-1)-i] + 1
    else:
        right[(N-2)-i] = right[(N-1)-i]

ans = left[0] + right[0]
for i in range(1, N):
    count = left[i] + right[i]
    if ans > count:
        ans = count
print(ans)
### BUGGY CODE ###

a, b, k = list(map(int, input().split()))
arr = [i for i in range(a, b+1)]
result = arr[:k] + arr[len(arr)-k:]
for i in sorted(set(result)):
  print(i)

### FIXED CODE ###

a, b, k = list(map(int, input().split()))
list_a = [i for i in range(a, min(a+k, b))]
list_b = [i for i in range(max(a, b+1-k), b+1)]
for i in sorted(set(list_a+list_b)):
  print(i)
### BUGGY CODE ###

def mips():
    return map(int,input().split())
def chmin(DP,b,i):
    if (DP[i]> b):
        DP[i] = b
        return True
    return False
N,K = map(int,input().split())
H = [i for i in mips()]
dp = [10**10 for i in range(N)]
dp[0] = 0
for i in range(1,N):
    chmin(dp,dp[i-1]+abs(H[i]-H[i-1]),i)
    for k in range(1,K+1):
        if i-k < 0:
            break
        chmin(dp,dp[i-k]+abs(H[i]-H[i-k]),i)
print(dp[-1])

### FIXED CODE ###

def mips():
    return map(int,input().split())
def chmin(DP,b,i):
    if (DP[i]> b):
        DP[i] = b
        return True
    return False
N,K = mips()
H = [i for i in mips()]
dp = [10**10 for i in range(N)]
dp[0] = 0
for i in range(1,N):
    for k in range(1,K+1):
        if i-k < 0:
            break
        chmin(dp,dp[i-k]+abs(H[i]-H[i-k]),i)
print(dp[-1])
### BUGGY CODE ###

n,m,qu = map(int,input().split())
l = [0 for _ in range(m)]
r = [0 for _ in range(m)]
p = [0 for _ in range(qu)]
q = [0 for _ in range(qu)]

for i in range(m):
  l[i],r[i] = map(int,input().split())

for i in range(qu):
  p[i],q[i] = map(int,input().split())

for i in range(qu):
  honsu=0
  for j in range(m):
    if l[j]>=p[i] and r[j]<=q[i]:
      honsu+=1
  print(honsu)

### FIXED CODE ###

n,m,qu = map(int,input().split())
lr = [[0]*(n+1) for _ in range(n+1)]

for i in range(m):
  l,r = map(int,input().split())
  lr[l][r]+=1

for i in range(1,n+1):
  for j in range(i,n+1):
    lr[i][j]+=lr[i][j-1]
  
for i in range(1,n+1):
  for j in range(i):
    lr[i-j-1][i]+=lr[i-j][i]
    
for i in range(qu):
  p,q = map(int,input().split())
  print(lr[p][q])
### BUGGY CODE ###

def main():

    import heapq

    n, m = map(int, input().split())
    a = list(map(int, input().split()))

    heapq.heapify(a) # in-place

    for _ in range(m):
        temp = []
        b, c = map(int, input().split())
        for i in range(b):
            temp.append(heapq.heappop(a))
            if c > temp[-1]:
                temp[-1] = c
            else:
                break
        
        for j in temp:
            heapq.heappush(a, j)

    print(sum(a))

if __name__ == '__main__':
    main()

### FIXED CODE ###

n, m = map(int, input().split())
a = list(map(int, input().split()))

bc = []

for _ in range(m):
    b, c = map(int, input().split())
    bc.append((b, c))

bc = sorted(bc, key=lambda x: x[1], reverse=True)

cnt = 0

for b, c in bc:
    cnt += b
    a += [c] * b
    if cnt >= n:
        break

print(sum(sorted(a,reverse=True)[:n]))
### BUGGY CODE ###

n=int(input())
s=input()
L=len(s)
ans=0
N=[0]*n
r=0
g=0
b=0
for i in reversed(range(L)):
    if s[i]=='R':
        r+=1
        N[i]=r
    elif s[i]=='G':
        g+=1
        N[i]=g
    else:
        b+=1
        N[i]=b

for i in range(L-2):
    x=s[i]
    for j in range(i+1,L-1):
        if s[j]!=x:
            y=s[j]
            for k in range(j+1,L):
                if s[k]!=x and s[k]!=y:
                    ans+=N[k]
                    if k<=j+j-i and j+j-i<=L-1:
                        if s[j+j-i]==s[k]:
                            ans-=1
                    break
print(ans)

### FIXED CODE ###

n=int(input())
s=input()
L=len(s)
ans=0

r=s.count('R')
b=s.count('B')
g=s.count('G')

for i in range(L-2):
    for j in range(i+1,L-1):
        if s[j]!=s[i]:
            if j+j-i<=L-1:
                if s[j+j-i]!=s[i] and s[j+j-i]!=s[j]:
                    ans+=1
print(r*b*g-ans)
### BUGGY CODE ###

import numpy as np

MOD = 10 ** 9 + 7
N=int(input())
A = [[int(x) for x in input().split()] for _ in range(N)]

dp = np.zeros(1<<N, dtype=np.uint32)
dp[0] = 1

for A_row in A:
    prev = dp.copy()
    dp = np.zeros_like(prev)
    for n,a in enumerate(A_row):
        if not a:
            continue
        x = 1 << n
        dp[x:] += prev[:-x]
        dp[dp>MOD] -= MOD

answer = dp[-1]
print(answer)


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

MOD = 10 ** 9 + 7
N = int(input())
A = [[int(x) for x in input().split()] for _ in range(N)]

bit_count = [0]
for _ in range(N):
    bit_count += [x+1 for x in bit_count]
    
dp = [0] * (1<<N)
dp[0] = 1

for i in range((1<<N)-1):
    k = bit_count[i]
    for c in range(N):
        if A[k][c]:
            dp[(1<<c)^i] += dp[i]

answer = dp[-1] % MOD
print(answer)
### BUGGY CODE ###

def calc():
  H,W,M = map(int, input().split())
  s = []
  hcount = [0]*H
  wcount = [0]*W
  for m in range(M):
    h,w = map(int, input().split())
    h = h - 1
    w = w - 1
    hcount[h] = hcount[h] + 1
    wcount[w] = wcount[w] + 1
    s.append([h,w])
  hmax = max(hcount)
  wmax = max(wcount)
  for h in range(H):
    for w in range(W):
      if hcount[h] != hmax or wcount[w] != wmax or [h,w] in s:
        continue
      else:
        return hmax + wmax
  return hmax + wmax - 1

if __name__ == '__main__':
    print(calc())

### FIXED CODE ###

def calc():
  H,W,M = map(int, input().split())
  s = []
  hcount = [0]*H
  wcount = [0]*W
  for m in range(M):
    h,w = map(int, input().split())
    h = h - 1
    w = w - 1
    hcount[h] = hcount[h] + 1
    wcount[w] = wcount[w] + 1
    s.append((h,w))
  hmax = max(hcount)
  wmax = max(wcount)
  hmode = [h for h, x in enumerate(hcount) if x == hmax]
  wmode = [w for w, y in enumerate(wcount) if y == wmax]
  s = tuple(s)
  S = set(s)
  for h in hmode:
    for w in wmode:
      if ((h,w) not in S):
        return hmax + wmax
  return hmax + wmax - 1
  
if __name__ == '__main__':
    print(calc())
### BUGGY CODE ###

def resolve():
    N = int(input())
    arr = tuple(map(int, input().split()))
    counter = 0
    for i,num in enumerate(arr):
        for j in range(i):
            if num > arr[j]:
                counter +=1
                break
    print(N-counter)

if __name__ == "__main__":
    resolve()

### FIXED CODE ###

def resolve():
    N = int(input())
    arr = tuple(map(int, input().split()))
    tmp = arr[0]
    counter = 0
    for i in arr:
        if i<=tmp:
            tmp=i
            counter += 1
    print(counter)

if __name__ == "__main__":
    resolve()
### BUGGY CODE ###

MOD = 10 ** 9 + 7
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000000)

N = int(input())
G = [[] for _ in range(N)]
for _ in range(N - 1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

factorial = [1,1]
inv_factorial = [1,1]
inv = [1,1]
for i in range(2,N + 1):
    factorial.append(factorial[-1]*i)
    inv.append(MOD - inv[MOD%i]*(MOD//i)%MOD)
    inv_factorial.append(inv_factorial[-1]*inv[-1]%MOD)

deg = [0] * N
parent = [0] * N
dp = [0] * N
ans = [0] * N
cnt_leaf = [0] * N

def dfs(v,p = -1):
    deg[v] = len(G[v])
    dp[v] = [0] * deg[v]
    res = 1
    cnt = 0
    for i,e in enumerate(G[v]):
        if e == p:
            parent[v] = i
            continue
        a,b = dfs(e,v)
        dp[v][i] = a*inv_factorial[b]%MOD
        cnt += b
        res *= dp[v][i]
        res %= MOD
    res *= factorial[cnt]%MOD
    cnt_leaf[v] = cnt
    return res,cnt + 1

def bfs(v,res_p = 0,p = - 1):
    if p != -1:
        dp[v][parent[v]] = res_p
    dpl = [1] * (deg[v] + 1)
    for i,x in enumerate(dp[v]):
        dpl[i + 1] = dpl[i]*x%MOD
    dpr = [1] * (deg[v] + 1)
    for i in range(deg[v] - 1,-1,-1):
        dpr[i] = dpr[i + 1]*dp[v][i]%MOD
    
    ans[v] = dpr[0]*factorial[N - 1]%MOD
    for i,e in enumerate(G[v]):
        if e == p:
            continue
        bfs(e,dpl[i]*dpr[i + 1]*inv[N - cnt_leaf[e] - 1]%MOD,v)
    
dfs(0)
bfs(0)
print('\n'.join(map(str,ans)))


### FIXED CODE ###

MOD = 10 ** 9 + 7
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000000)

N = int(input())
G = [[] for _ in range(N)]
for _ in range(N - 1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

factorial = [1]
for i in range(1, N + 1):
    factorial.append(factorial[-1] * i % MOD)

inv_factorial = [-1] * (N + 1)
inv_factorial[-1] = pow(factorial[-1], MOD-2, MOD)
for i in reversed(range(N)):
    inv_factorial[i] = inv_factorial[i + 1] * (i + 1) % MOD

deg = [0] * N
parent = [0] * N
dp = [0] * N
ans = [0] * N
cnt_leaf = [0] * N

def dfs(v,p = -1):
    deg[v] = len(G[v])
    dp[v] = [0] * deg[v]
    res = 1
    cnt = 0
    for i,e in enumerate(G[v]):
        if e == p:
            parent[v] = i
            continue
        a,b = dfs(e,v)
        dp[v][i] = a*inv_factorial[b]%MOD
        cnt += b
        res *= dp[v][i]
        res %= MOD
    res *= factorial[cnt]%MOD
    cnt_leaf[v] = cnt
    return res,cnt + 1

def bfs(v,res_p = 0,p = - 1):
    if p != -1:
        dp[v][parent[v]] = res_p
    dpl = [1] * (deg[v] + 1)
    for i,x in enumerate(dp[v]):
        dpl[i + 1] = dpl[i]*x%MOD
    dpr = [1] * (deg[v] + 1)
    for i in range(deg[v] - 1,-1,-1):
        dpr[i] = dpr[i + 1]*dp[v][i]%MOD
    
    ans[v] = dpr[0]*factorial[N - 1]%MOD
    for i,e in enumerate(G[v]):
        if e == p:
            continue
        bfs(e,dpl[i]*dpr[i + 1]*pow(N - cnt_leaf[e] - 1,MOD - 2,MOD)%MOD,v)
    
dfs(0)
bfs(0)
print('\n'.join(map(str,ans)))
### BUGGY CODE ###

def main():
    N, K = map(int, input().split())
    value_diff_abs = 0

    if N == 0 :
        print("0")
    elif K == 1 and N != 0 :
        print("0")
    elif K == 2 and N % 2 == 0 and N != 0 :
        print("0")
    elif K == 2 and N % 2 != 0 and N != 0 :
        print ("1")
    else :
        for i in range(0 , N + 1) :
            value_diff_abs = N
            N = abs(N - K)
            if value_diff_abs < N :
                print(str(value_diff_abs))
                break


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    N, K = map(int, input().split())
    value_diff_abs = 0

    if N == 0 or N == K :
        print("0")
    elif N > K :
        ans = N % K
        #print(ans)
        N = ans
        for i in range(0 , N + 1) :
            value_diff_abs = N
            N = abs(N - K)
            #print(str(value_diff_abs))
            if value_diff_abs < N :
                print(str(value_diff_abs))
                break
            elif value_diff_abs == N :
                print(str(value_diff_abs))
                break
    else :
        for i in range(0 , N + 1) :
            value_diff_abs = N
            N = abs(N - K)
            if value_diff_abs < N :
                print(str(value_diff_abs))
                break
            elif value_diff_abs == N :
                print(str(value_diff_abs))
                break


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

string=input()
length=len(string)
mod=[1]+[0]*2018
s=0
for i in range(length):
  s=(s+int(string[-1-i])*pow(10,i))%2019
  mod[s]+=1
answer=0
for i in mod:
  answer+=i*(i-1)//2
print(answer)

### FIXED CODE ###

string=input()
length=len(string)
mod=[1]+[0]*2018
s=0
for i in range(length):
  s=(s+int(string[-1-i])*pow(10,i,2019))%2019
  mod[s]+=1
print(sum([i*(i-1)//2 for i in mod]))
### BUGGY CODE ###

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

for i in range(M):
        B, C = map(int, input().split())
        if C <= A[0]:
                pass
        else:
                idx = 0
                for k in range(N):
                        if A[k] < C:
                                idx = k
                        else:
                                break


                if idx + 1 <= B:
                        for l in range(idx+1):
                                A[l] = C
                else:
                        A = A[B:idx+1] + [C for i in range(B)] + A[idx+1:]

        

print(sum(A))

### FIXED CODE ###

from collections import deque

N, M = map(int, input().split())
A = list(map(int, input().split()))
A = [[1, A[i]] for i in range(N)]
A = deque(A)

BC = [list(map(int, input().split())) for i in range(M)]
A.extend(BC)
A = list(A)
A.sort(key=lambda x: x[1], reverse=1)


sum = 0
k = 0
for b, c in A:
        if k + b <= N:
                sum += b * c
                k += b
        elif k <= N:
                sum += (N - k) * c
                break

print(sum)
### BUGGY CODE ###

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

sum = 0
mod = 10 ** 9 + 7
for i in range(N):
    for j in range(N - i - 1):
        sum += A[i] * A[N -1 - j]

print(sum % mod)

### FIXED CODE ###

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

mod = 10 ** 9 + 7
sum = sum(A) **  2

squ = 0
for i in range(N):
    squ +=  A[i] ** 2

answer = int(((sum - squ)  //  2 ) % mod)
print(answer)
### BUGGY CODE ###

import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def precompute(S):
    H, W = S.shape
    V = np.zeros((H + 1, W + 1), np.int32)
    V[1:, 1:] = np.cumsum(S, axis=0).cumsum(axis=1)
    Ex = np.zeros((H, W + 1), np.int32)
    Ex[1:, 1:] = np.cumsum(S[:-1] & S[1:], axis=0).cumsum(axis=1)
    Ey = np.zeros((H + 1, W), np.int32)
    Ey[1:, 1:] = np.cumsum(S[:, :-1] & S[:, 1:], axis=0).cumsum(axis=1)
    return V, Ex, Ey

def main(V, Ex, Ey, query):
    for i in range(len(query) // 4):
        a, b, c, d = query[4 * i:4 * i + 4]
        v = V[c, d] + V[a - 1, b - 1] - V[a - 1, d] - V[c, b - 1]
        e1 = Ex[c - 1, d] + Ex[a - 1, b - 1] - Ex[a - 1, d] - Ex[c - 1, b - 1]
        e2 = Ey[c, d - 1] + Ey[a - 1, b - 1] - Ey[a - 1, d - 1] - Ey[c, b - 1]
        print(v - e1 - e2)

if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    i4 = numba.from_dtype(np.int64)
    signature = (i4[:, :], i4[:, :], i4[:, :], i4[:])

    cc = CC('my_module')
    cc.export('main', signature)(main)
    cc.compile()

H, W, Q = map(int, readline().split())
S = []
for _ in range(H):
    S.append(list(readline().rstrip()))
query = np.array(read().split(), np.int32)

S = (np.concatenate(S) - ord('0')).reshape(H, W)
V, Ex, Ey = precompute(S)

main(V, Ex, Ey, query)

### FIXED CODE ###

import sys
input = sys.stdin.readline

import numpy as np

N,M,Q = map(int,sys.stdin.readline().split())
rows = sys.stdin.readlines()
S = np.zeros((N+2,M+2),dtype='U1')
S[1:-1,1:-1] = np.array([list(row) for row in rows[:N]],dtype='U1')[:,:M]
query = np.array([row.split() for row in rows[N:]],dtype=np.int32)

count_one = (S=='1').cumsum(axis=0).cumsum(axis=1)

# 左上ごとに
count_edge_x = ((S[:-1]=='1')&(S[1:]=='1')).cumsum(axis=0).cumsum(axis=1)
count_edge_y = ((S[:,:-1]=='1')&(S[:,1:]=='1')).cumsum(axis=0).cumsum(axis=1)

x1,y1,x2,y2 = query.T

answer = count_one[x2,y2] - count_one[x2,y1-1] - count_one[x1-1,y2] + count_one[x1-1,y1-1]

answer -= count_edge_x[x2-1,y2] - count_edge_x[x2-1,y1-1] - count_edge_x[x1-1,y2] + count_edge_x[x1-1,y1-1]
answer -= count_edge_y[x2,y2-1] - count_edge_y[x1-1,y2-1] - count_edge_y[x2,y1-1] + count_edge_y[x1-1,y1-1]

print('\n'.join(answer.astype(str)))
### BUGGY CODE ###

N, Q = map(int, input().split())
l=[None]*N
l[0]=[1,1,0]
for i in range(1,N):
    a,b=map(int,input().split())
    l[i]=[b,a,0]
l.sort()
for i in range(Q):
    p,x=map(int,input().split())
    l[p-1][2]+=x
print(l[0][2],end=" ")
for i in range(1,N):
    l[i][2]+=l[l[i][1]-1][2]
    print(l[i][2],end=" ")

### FIXED CODE ###

N,Q=map(int,input().split())
l=[[1,0,0]]
for i in range(1,N):
    a,b=map(int,input().split())
    l.append([b,a,0])
l.sort()
for i in range(Q):
    p,x=map(int,input().split())
    l[p-1][2]+=x
t=[l[0][2]]
for i in range(1,N):
    t.append(t[l[i][1]-1]+l[i][2])
print(*t)
### BUGGY CODE ###


import numpy as np
nl = lambda: list(map(int, input().split()))
s = lambda: input()

H, W = nl()
grid = []
for i in range(H):
    grid.append(s())

yokos = np.zeros((H, W), dtype=np.uint64)
for row in range(H):
    count = 0
    prev = 0
    for col in range(W):
        if grid[row][col] == '.':
            count += 1
        else:
            yokos[row, prev:col] = count
            prev = col+1
            count = 0
    if count > 0:
        yokos[row, prev:W] = count

tates = np.zeros((H, W), dtype=np.uint64)
for col in range(W):
    count = 0
    prev = 0
    for row in range(H):
        if grid[row][col] == '.':
            count += 1
        else:
            tates[prev:row, col] = count
            prev = row+1
            count = 0
    if count > 0:
        tates[prev:H, col] = count

res = 0
for row in range(H):
    for col in range(W):
        res = max(res, yokos[row, col] + tates[row, col] - 1)

print(int(res))




### FIXED CODE ###

nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

H, W = nl()
grid = []
for i in range(H):
    grid.append(s())

ups = [[0]*W for j in range(H)]
downs = [[0]*W for j in range(H)]
lefts = [[0]*W for j in range(H)]
rights = [[0]*W for j in range(H)]

for col in range(W):
    p = 0
    for row in range(H):
        if grid[row][col] == '#':
            p = 0
        else:
            p += 1
        ups[row][col] = p

    p = 0
    for row in range(H-1, -1, -1):
        if grid[row][col] == '#':
            p = 0
        else:
            p += 1
        downs[row][col] = p

for row in range(H):
    p = 0
    for col in range(W):
        if grid[row][col] == '#':
            p = 0
        else:
            p += 1
        lefts[row][col] = p

    p = 0
    for col in range(W-1, -1, -1):
        if grid[row][col] == '#':
            p = 0
        else:
            p += 1
        rights[row][col] = p

res = 0
for row in range(H):
    for col in range(W):
        res = max(res, ups[row][col] + downs[row][col] + lefts[row][col] + rights[row][col] -3)
print(res)