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

# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))
from copy import deepcopy
from operator import add
from itertools import accumulate
 
N, K = inpl()
A = sorted(inpl())
S = list(accumulate(A, add))
A = A[::-1]
DP = [False for _ in range(K)]
DP[0] = 1
OK = [False for _ in range(N)]
 
for i, a in enumerate(A):
    DP0 = deepcopy(DP)
    if a >= K:
        OK[i] = True
        continue
    for j, d in enumerate(DP0[-S[::-1][i]:], max(0, K-S[::-1][i])):
        if d:
            if j + a >= K:
                OK[i] = True
                break
            else:
                DP[j+a] = True
 
if sum(OK) == 0:
    print(N)
else:
    print(OK[::-1].index(True))

### FIXED CODE ###

# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))
 
N, K = inpl()
A = sorted(inpl())
S = []
s = 0
for a in A:
    s += a
    S.append(s)

A = A[::-1]
DP = [True]+[False for _ in range(K-1)]

OK = [False for _ in range(N)]
 
for i, a in enumerate(A):
    DP1 = [False] * K
    if a >= K:
        OK[i] = True
        continue
    for j, d in enumerate(DP[-S[::-1][i]:], max(0, K-S[::-1][i])):
        if d:
            DP1[j] = True
            if j + a >= K:
                OK[i] = True
                break
            else:
                DP1[j+a] = True
    DP = DP1 
if sum(OK) == 0:
    print(N)
else:
    print(OK[::-1].index(True))
### BUGGY CODE ###


def resolve():
    inp = input()
    result = inp

    while True:
        before = len(result)
        result = result.replace('01', '')
        result = result.replace('10', '')
        after = len(result)
        if before == after:
            break

    print(len(inp)-len(result))

resolve()

### FIXED CODE ###

def resolve():
    inp = input()

    c0 = inp.count('0')
    c1 = inp.count('1')

    print(min(c0, c1)*2)

resolve()
### BUGGY CODE ###

import time
import math
xyzk=list(map(int,input().split()))
abc=[[],[],[]]
maxlist=[]
for a in range(len(abc)):
    abc[a]=list(map(int,input().split()))

for a in range(xyzk[0]):
    for b in range(xyzk[1]):
        maxlist.append(abc[0][a]+abc[1][b])
maxlist.sort()
maxlist.reverse()
list2=[]

for a in range(min([xyzk[3],len(maxlist)])):
    for b in range(xyzk[2]):
        list2.append(maxlist[a]+abc[2][b])
list2.sort()
list2.reverse()
for a in range(xyzk[3]):
    print(list2[a])

### FIXED CODE ###

import math
xyzk = list(map(int,input().split()))
abc = [list(map(int,input().split())) for a in range(3)]
ab=[]
for a in abc[0]:
    for b in abc[1]:
        ab.append(a+b)
ab.sort()
ab.reverse()
abc[2].sort()
abc[2].reverse()
abc2=[]
for c in range(len(abc[2])):
    for a in range(min([math.ceil(xyzk[3]/(c+1)),len(ab)])):
        abc2.append(abc[2][c]+ab[a])
abc2.sort()
abc2.reverse()
for a in range(xyzk[3]):
    print(abc2[a])
### BUGGY CODE ###

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

if n == k:
  print(0)
  exit()
  
if n > k:
  if n%k == 0:
    print(0)
    exit()
  else:
    m = n
    while m > 0:
      m -= k
    if abs(m) < n%k:
      print(-m)
      exit()
    else:
      print(n%k)
      exit()

if n < k:
  if n > abs(n-k):
    print(abs(n-k))
    exit()
  else:
    print(n)
    exit()

### FIXED CODE ###

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

if n == k:
  print(0)
  exit()
  
if n > k:
  if n%k == 0:
    print(0)
    exit()
  else:
    if n%k > abs(n%k-k):
      print(abs(n%k-k))
    else:
      print(n%k)

if n < k:
  if n > abs(n-k):
    print(abs(n-k))
    exit()
  else:
    print(n)
    exit()
### BUGGY CODE ###

#!/usr/bin/python3
# -*- coding: utf-8 -*-

# import numpy as np
# from itertools import *
# from collections import *

# S = input().split()
# N = int(input().split())
# N, K = [int(x) for x in input().split()]

from itertools import *

N = int(input())
A = [int(x) for x in input().split()]

number = list(combinations(range(1, N+1), 2))
height = list(combinations(A, 2))

count = 0

for n, h in zip(number, height):
    if n[1]-n[0] == sum(h):
        count += 1

print(count)

### FIXED CODE ###

#!/usr/bin/python3
# -*- coding: utf-8 -*-

# import numpy as np
# from itertools import *
# from collections import *
from collections import Counter

# S = input().split()
# N = int(input().split())
# N, K = [int(x) for x in input().split()]

N = int(input())
A = [int(x) for x in input().split()]

number = range(1, N+1)
numhei = [0] * N
for n in range(N):
    numhei[n] = number[n] + A[n]

c = Counter(numhei)
count = 0
for n in number:
    count += c[n - A[n-1]]

print(count)
### BUGGY CODE ###

import math

# 0以上整数x「未満」の素数をリストに格納して返す
def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0 # 1は素数ではない

    # エラトステネスのふるい
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]

def realprimes(y):
    Y = primes(y)
    t = int((y + 1) / 2)
    bestprime = []

    for prime in Y:
        if prime != 2:
            prime2 = (prime + 1)//2
            pw = 0
            for i in range(2,int(math.sqrt(prime2)) + 2):
                if prime2 == 2:
                    break
                elif prime2 % i == 0:
                    pw = 1
                    break
            if pw == 0:
                bestprime.append(prime)

    T = bestprime
    V = set(Y) & set(T)
    return list(V)
W = realprimes(10**5 - 1)
W.sort()

q = int(input())
s = []
for i in range(q):#h:高さ
    s.append([int(m) for m in input().split()])
p = 0
p2 = 0
c = 0
c2 = 0
for i in range(q):
    while p == 0:
        if s[i][0] + c > s[i][1]:
            cut1 = 0
            break
        if s[i][0] + c in W:
            cut1 = W.index(s[i][0] + c)
            p = 1
        else:
            c += 1
    p = 0
    c = 0
    while p2 == 0:
        if s[i][1] - c2 < s[i][0]:
            cut2 = -1
            break
        if s[i][1] - c2 in W:
            cut2 = W.index(s[i][1] - c2)
            p2 = 1
        else:
            c2 += 1
    p2 = 0
    c2 = 0
    print(cut2 - cut1 + 1)

### FIXED CODE ###

import math
import copy

# 0以上整数x「未満」の素数をリストに格納して返す
def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0 # 1は素数ではない

    # エラトステネスのふるい
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]

def realprimes(y):
    Y = primes(y)
    t = int((y + 1) / 2)
    bestprime = []

    for prime in Y:
        if prime != 2:
            prime2 = (prime + 1)//2
            pw = 0
            for i in range(2,int(math.sqrt(prime2)) + 2):
                if prime2 == 2:
                    break
                elif prime2 % i == 0:
                    pw = 1
                    break
            if pw == 0:
                bestprime.append(prime)

    T = bestprime
    V = set(Y) & set(T)
    return list(V)
W = realprimes(10**5 - 1)
W.sort()
W.append(10**5)
q = int(input())
s = []
for i in range(q):#h:高さ
    s.append([int(m) for m in input().split()])

j = 0
Z = []
for i in range(10 ** 5):
    if i < W[j]:
        Z.append(j)
    else:
        j += 1
        Z.append(j)

for i in range(q):
    if Z[s[i][0]] != Z[s[i][0] - 1]:
        print(Z[s[i][1]] - Z[s[i][0]] + 1)
    else:
        print(Z[s[i][1]] - Z[s[i][0]])
### BUGGY CODE ###

N,M=map(int,input().split())

A=list(map(int,input().split()))
A.sort()
dc=[]

for i in range(M):
    B,C=map(int,input().split())
    dc.append([B,C])

dc.sort(key=lambda x: x[1],reverse=True)
bf=False
i=0
for l in dc:
    B,C=l
    while B>0:
        if i<N and A[i]<C:
            A[i]=C
            B-=1
            i+=1
        elif i<N:
            bf=True
            i+=1
            break
    if bf:
        break

print(sum(A))


### FIXED CODE ###

N,M=map(int,input().split())

A=list(map(int,input().split()))
A.sort()
dc=[]

for i in range(M):
    B,C=map(int,input().split())
    dc.append([B,C])

dc.sort(key=lambda x: x[1],reverse=True)
bf=False
i=0
for l in dc:
    B,C=l
    if bf:
        break
    while B>0:
        if i<N and A[i]<C:
            A[i]=C
            B-=1
            i+=1
        else:
            bf=True
            break


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

import sys

count=int(input())-1
input_list=[ int(i) for i in sys.stdin.readlines() ]

first=0
second=1
max_price_diff=input_list[second]-input_list[first]

for i in input_list[first:count]:
    for j in input_list[second:count+1]:
        if j-i > max_price_diff:
            max_price_diff=j-i
    second=second+1

print(max_price_diff)


### FIXED CODE ###

import sys

count=int(input())
input_list=[ int(i) for i in sys.stdin.readlines() ]

first=0
second=1
maxv=-1000000000
minv=input_list[first]

for i in input_list[second:]:
    if i-minv > maxv:
        maxv=i-minv
    if i < minv:
        minv=i

print(maxv)
### BUGGY CODE ###

# -*- coding: utf-8 -*-

"""
参考：https://img.atcoder.jp/abc070/editorial.pdf
・公式解が再帰だったのでやってみる
"""

import sys

# 再帰呼び出しの回数制限(デフォルト1000)
sys.setrecursionlimit(10 ** 9)

from heapq import heappop, heappush

N = int(input())
nodes = [[] for _ in range(N+1)]
for i in range(N-1):
    a, b, c = map(int, input().split())
    # nodes[出発ノード](到着ノード, コスト))
    nodes[a].append((b, c))
    # 無向グラフなのでこっちも入れる
    nodes[b].append((a, c))

memo = [0] * (N+1)
def dfs(cur, prev, dist):
    memo[cur] = dist
    for nxt, cost in nodes[cur]:
        if nxt == prev:
            continue
        dfs(nxt, cur, dist+cost)

Q, K = map(int, input().split())
dfs(K, -1, 0)

for i in range(Q):
    x, y = map(int, input().split())
    # 今回は全てKを経由するので、Kからの距離さえ分かれば全部出る
    print(memo[x] + memo[y])


### FIXED CODE ###

# -*- coding: utf-8 -*-

"""
・ダイクストラ(優先度付きキュー)
"""

from heapq import heappop, heappush

# 今回はダイクストラするので、データの持ち方は隣接リスト
N = int(input())
nodes = [[] for _ in range(N+1)]
for i in range(N-1):
    a, b, c = map(int, input().split())
    # nodes[出発ノード](到着ノード, コスト))
    nodes[a].append((b, c))
    nodes[b].append((a, c))

def dijkstra(nodes, start):
    # 最短距離メモ
    memo = [float('inf')] * (len(nodes))
    # 訪問済メモ
    visited = [False] * (len(nodes))
    # スタート位置
    que = [(0, start)]
    memo[start] = 0
    # キューが空になるまで
    while len(que) != 0:
        # startからの距離, 現在のノード
        dist, cur = heappop(que)
        # 訪問済にする
        visited[cur] = True
        # 出発ノードcurの到着ノードでループ
        for i in range(len(nodes[cur])):
            nxt, cost = nodes[cur][i]
            # 訪問済ではない時だけ
            if not visited[nxt]:
                memo[nxt] = min(memo[cur] + cost, memo[nxt])
                # 現在の移動距離をキューの優先度として、早い方から先に処理するようにする
                heappush(que, (memo[nxt], nxt))
    # ノードstartからの最短距離リストを返却
    return memo

Q, K = map(int, input().split())
# 引数：(ノードの隣接リスト, 出発ノード)
memo = dijkstra(nodes, K)

for i in range(Q):
    x, y = map(int, input().split())
    print(memo[x] + memo[y])
### BUGGY CODE ###

k = int(input())
def gcd(p,q):
  if(p % q == 0):
    return q
  return gcd(q, p % q)
res = 0
for i in range(1, k+1):
  for j in range(1, k+1):
    for p in range(1, k+1):
      res = res + gcd(i,gcd(j,p))
print(res)

### FIXED CODE ###

k = int(input())
def gcd(p,q):
  if(p % q == 0):
    return q
  return gcd(q, p % q)
res = 0
for i in range(1, k+1):
  for j in range(1, k+1):
    for p in range(1, k+1):
      res = res + gcd(i,gcd(j,p))
print(res)
### BUGGY CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
s = {}
for i in range(n):
    if a[i] in s.keys():
        s[a[i]] = s[a[i]] + 1
    else:
        s[a[i]] = 1
cnt = 0
while len(s) > k:
    cnt = cnt + min(s.values())
    s.pop(min(s, key=s.get))
print(cnt)

### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
b = [0]*n
for i in range(n):
    b[a[i]-1] += 1
c = [i for i in b if i != 0]
c.sort()
if len(c) - k > 0:
    print(sum((c[0:len(c)-k])))
else:
    print(0)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc073/tasks/abc073_d
"""
from itertools import permutations


def warshallFloyd(V, dp):
    for k in range(V):
        for i in range(V):
            for j in range(V):
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])


def main():
    N, M, R = [int(x) for x in input().split()]
    destinations = [int(x) for x in input().split()]
    dp = [[float('inf')]*(N+1) for _ in range(N+1)]
    for i in range(N+1):
        dp[i][i] = 0
    for _ in range(M):
        f, t, d = [int(x) for x in input().split()]
        dp[f][t] = d
        dp[t][f] = d

    warshallFloyd(N+1, dp)
    # for d in dp:
    #     print(d)
    # print('='*32)

    minimum_cost = float('inf')
    for route in permutations(destinations, len(destinations)):
        cost = 0
        while len(route) > 1:
            f, t = route[0], route[1]
            cost += dp[f][t]
            route = route[1:]
        if cost < minimum_cost:
            minimum_cost = cost
    print(minimum_cost)


if __name__ == '__main__':
    main()
    


### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc073/tasks/abc073_d
"""
from itertools import permutations


def warshallFloyd(V, dp):
    for k in range(V):
        for i in range(V):
            for j in range(V):
                # dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])
                new_dist = dp[i][k] + dp[k][j]
                if dp[i][j] > new_dist:
                    dp[i][j] = new_dist


def main():
    N, M, R = [int(x) for x in input().split()]
    destinations = [int(x) for x in input().split()]
    dp = [[float('inf')]*(N+1) for _ in range(N+1)]
    for i in range(N+1):
        dp[i][i] = 0
    for _ in range(M):
        f, t, d = [int(x) for x in input().split()]
        dp[f][t] = dp[t][f] = d

    warshallFloyd(N+1, dp)

    minimum_cost = float('inf')
    for route in permutations(destinations, len(destinations)):
        cost = 0
        while len(route) > 1:
            f, t = route[0], route[1]
            cost += dp[f][t]
            if cost > minimum_cost:
                break
            route = route[1:]
        if cost < minimum_cost:
            minimum_cost = cost
    print(minimum_cost)


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

n = int(input())
Data = list(map(int,input().split()))
Ans = []
if len(Data) % 2 == 0:
    m = len(Data) // 2
    for i in range(m):
        Ans.insert(0,Data[2*i+1])
    for i in range(m):
        Ans.append(Data[2*i])
else:
    m = len(Data) // 2
    for i in range(m+1):
        Ans.insert(0,Data[2*i])
    for i in range(m):
        Ans.append(Data[2*i+1])

for a in Ans:
    print(a,end=' ')


### FIXED CODE ###

n = int(input())
m = n // 2
Data = list(map(int,input().split()))
Ans = []
if n % 2 == 0:
    for i in range(m):
        Ans.append(Data[n-1-i*2])
    for i in range(m):
        Ans.append(Data[2*i])
else:
    for i in range(m+1):
        Ans.append(Data[n-1-i*2])
    for i in range(m):
        Ans.append(Data[2*i+1])

for a in Ans:
    print(a,end=' ')
### BUGGY CODE ###

from collections import deque
h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
work = [[[] for j in range(w)] for i in range(h)]
result = 0
for i in range(h):
    for j in range(w):
        append = work[i][j].append
        if i<h-1 and s[i+1][j] == ".":
            append([i+1,j])
        if i>0 and s[i-1][j] == ".":
            append([i-1,j])
        if j<w-1 and s[i][j+1] == ".":
            append([i,j+1])
        if j>0 and s[i][j-1] == ".":
            append([i,j-1])
for i in range(h):
    for j in range(w):
        if s[i][j] != ".":
            continue
        q = deque([[i, j]])
        temp = [[i, j]]
        popleft = q.popleft
        append = q.append
        tempappend = temp.append
        d = -1
        count = 1
        counter = 0
        for k in range(h*w):
            x, y = popleft()
            count -= 1
            for el in work[x][y]:
                if el not in temp:
                    counter += 1
                    append(el)
                    tempappend(el)
            if count == 0:
                d += 1
                count = counter
                counter = 0
            if len(q) == 0:
                break
        result = result if result>d else d
print(result)

### FIXED CODE ###

from collections import deque
h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
work = [[[] for j in range(w)] for i in range(h)]
result = 0
for i in range(h):
    for j in range(w):
        append = work[i][j].append
        if i<h-1 and s[i+1][j] == ".":
            append([i+1,j])
        if i>0 and s[i-1][j] == ".":
            append([i-1,j])
        if j<w-1 and s[i][j+1] == ".":
            append([i,j+1])
        if j>0 and s[i][j-1] == ".":
            append([i,j-1])
q = deque()
popleft = q.popleft
append = q.append
for i in range(h):
    for j in range(w):
        if s[i][j] != ".":
            continue
        q.clear()
        q.append([i, j])
        temp = [[i, j]]
        tempappend = temp.append
        d = -1
        count = 1
        counter = 0
        for k in range(w*h):
            x, y = popleft()
            count -= 1
            for el in work[x][y]:
                if el not in temp:
                    counter += 1
                    append(el)
                    tempappend(el)
            if count == 0:
                d += 1
                count = counter
                counter = 0
            if len(q) == 0:
                break
        result = result if result>d else d
    if result == h+w-2:
        break
print(result)
### BUGGY CODE ###

def diameter(N, E):#diamete of a tree
    V = [-1]*N
    V[0] = 0
    q = [0]
    while q:
        v = q.pop(0)
        ev = V[v]
        for w in E[v]:
            if V[w] == -1:
                V[w] = ev + 1
                q.append(w)
    s = V.index( max(V))
    p = [s]
    W = [-1]*N
    W[s] = 0
    while p:
        v = p.pop(0)
        ev = W[v]
        for w in E[v]:
            if W[w] == -1:
                W[w] = ev + 1
                p.append(w)
    return max(W)

N = int( input())
E = [ [] for _ in range(N)]
for _ in range(N-1):
    a, b = map( int, input().split())
    a, b = a-1, b-1
    E[a].append(b)
    E[b].append(a)
ans = "First"
if diameter(N, E)%3 == 1:
    ans = "Second"
print( ans)

### FIXED CODE ###

from collections import deque
def diameter(N, E):#diamete of a tree
    V = [-1]*N
    V[0] = 0
    q = deque([0])
    s = 0
    while q:
        v = q.popleft()
        for w in E[v]:
            if V[w] == -1:
                s = w
                V[w] = V[v] + 1
                q.append(w)
    # s = V.index( max(V))
    p = deque([s])
    W = [-1]*N
    W[s] = 0
    while p:
        v = p.popleft()
        for w in E[v]:
            if W[w] == -1:
                W[w] = W[v] + 1
                p.append(w)
    return max(W)

N = int( input())
E = [ [] for _ in range(N)]
for _ in range(N-1):
    a, b = map( int, input().split())
    a, b = a-1, b-1
    E[a].append(b)
    E[b].append(a)
ans = "First"
if diameter(N, E)%3 == 1:
    ans = "Second"
print( ans)
### BUGGY CODE ###

N, M = map(int,input().split())
A = sorted(map(int,input().split()))
BC = [list(map(int,input().split())) for _ in range(M)]

for B, C in BC:
  B -= 1
  while A[B] > C and B >= 0:
    B -= 1
  if B == 0:
    A = [C] + A[1:]
  else:
    A = [C]*len(A[:B+1]) + A[B+1:]
  A.sort()
print(sum(A))

### FIXED CODE ###

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

for B, C in BC:
  A.extend([C]*B)
  if len(A) > N*2:
    break
A.sort(reverse = True)
print(sum(A[:N]))
### BUGGY CODE ###

class Bit:
  def __init__(self,n):
    self.bl = n.bit_length()
    self.size = n
    self.tree = [0]*(n+1)
 
  def sum(self,i):
    s = 0
    while i > 0:
      s += self.tree[i]
      i -= i & -i
    return s

  def add(self,i,x):
    while i <= self.size:
      self.tree[i] += x
      i += i & -i

import sys
input = sys.stdin.readline
from collections import defaultdict
n,q = map(int,input().split())
a = list(map(int,input().split()))
lr = [tuple(map(int,input().split()))+(i,) for i in range(q)]
ans = [0]*q
lr.sort(key = lambda x:x[1])
bit = Bit(n+2)
dc = defaultdict(int)
cnt = 0
for L,R,p in lr:
  L -= 1
  for i in range(cnt,R):
    if dc[a[i]]:
      l = dc[a[i]]-1
      r = i
      bit.add(l+2,1)
      bit.add(r+2,-1)
    else:
      bit.add(1,1)
      bit.add(i+2,-1)
    dc[a[i]] = i+1
  ans[p] = bit.sum(L+1)
  cnt = R
print(*ans,sep="\n")

### FIXED CODE ###

class Bit:
  def __init__(self,n):
    self.bl = n.bit_length()
    self.size = n
    self.tree = [0]*(n+1)
 
  def sum(self,i):
    s = 0
    while i > 0:
      s += self.tree[i]
      i -= i & -i
    return s

  def add(self,i,x):
    while i <= self.size:
      self.tree[i] += x
      i += i & -i

import sys
input = sys.stdin.readline
from collections import defaultdict
n,q = map(int,input().split())
a = list(map(int,input().split()))
lr = [tuple(map(int,input().split()))+(i,) for i in range(q)]
ans = [0]*q
lr.sort(key = lambda x:x[1])
bit = Bit(n+2)
dc = defaultdict(int)
cnt = 0
for L,R,p in lr:
  L -= 1
  for i in range(cnt,R):
    if dc[a[i]]:
      l = dc[a[i]]-1
      r = i
      bit.add(l+2,1)
      bit.add(r+2,-1)
    else:
      bit.add(1,1)
      bit.add(i+2,-1)
    dc[a[i]] = i+1
  ans[p] = bit.sum(L+1)
  cnt = R
print(*ans,sep="\n")
### BUGGY CODE ###

import numpy as np

H,W = map(int,input().split())
grid = np.zeros((H+2,W+2), dtype=bool)
grid[1:-1, 1:-1] = tuple(tuple(map(lambda c: c != '#', input())) for _ in range(H))
grid = grid.tolist()

scores = [[0]*(W+2) for _ in range(H+2)]

for i in range(1, H+1):
    s = 0
    for j in range(1,W+1):
        if grid[i][j]:
            scores[i][j] += s
            s += 1
        else:
            s = 0

for i in range(1, H+1):
    s = 0
    for j in reversed(range(1,W+1)):
        if grid[i][j]:
            scores[i][j] += s
            s += 1
        else:
            s = 0

for j in range(1, W+1):
    s = 0
    for i in range(1,H+1):
        if grid[i][j]:
            scores[i][j] += s
            s += 1
        else:
            s = 0

for j in range(1, W+1):
    s = 0
    for i in reversed(range(1,H+1)):
        if grid[i][j]:
            scores[i][j] += s
            s += 1
        else:
            s = 0


print(np.array(scores).max()+1)

### FIXED CODE ###

from itertools import chain

H,W = map(int,input().split())
grid = tuple(tuple(map(lambda c: c != '#', input())) for _ in range(H))

scores = [[0]*W for _ in range(H)]

for i in range(H):
    s = 0
    for j in range(W):
        if grid[i][j]:
            scores[i][j] += s
            s += 1
        else:
            s = 0

for i in range(H):
    s = 0
    for j in reversed(range(W)):
        if grid[i][j]:
            scores[i][j] += s
            s += 1
        else:
            s = 0

for j in range(W):
    s = 0
    for i in range(H):
        if grid[i][j]:
            scores[i][j] += s
            s += 1
        else:
            s = 0

for j in range(W):
    s = 0
    for i in reversed(range(H)):
        if grid[i][j]:
            scores[i][j] += s
            s += 1
        else:
            s = 0


print(1 + max(chain.from_iterable(scores)))