Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02553 (python)

Fixed submission:
nums = [int(x) for x in input().split()]

sign = [0] * 4
for x in range(4):
    if nums[x] < 0:
        sign[x] = 1

result = min(nums[0:2]) * min(nums[2:])

if sum(sign) == 1 or sum(sign) == 0:
    result = max(nums[0:2]) * max(nums[2:])

if sum(sign) == 2:
    if (sign[0] == 1 and sign[1]) or (sign[2] == 1 and sign[3] == 1):
        if sign[0] == 1:
             result = max(nums[0:2]) * min(nums[2:])
        elif sign[2] == 1:
             result = min(nums[0:2]) * max(nums[2:])
    else:
        cur1 = nums[0] * nums[2]
        cur2 = nums[1] * nums[3]
        if abs(cur1) > abs(cur2):
            result = cur1
        else:
            result = cur2
print(result)

Buggy submission (verdict: Runtime Error):
nums = [int(x) for x in input().split()]

sign = [1] * 4
for x in range(4):
    if nums[x] < 0:
        sign[x] = 0

result = min(nums[0:2]) * min(nums[2:])

if sum(sign) == 1:
    result = max(a[0:2]) * max(a[2:])

if sum(sign) == 2:
    if (sign[0] == 1 and sign[1]) or (sign[2] == 1 and sign[3] == 1):
        if sign[0] == 1:
             result = max(nums[0:2]) * min(nums[2:])
        elif sign[2] == 0:
             result = min(nums[0:2]) * max(nums[2:])

print(result)
Problem p02601 (python)

Fixed submission:
A,B,C = [int(x) for x in input().split()]
K=int(input())
 
while(A>=B and K>0):
  B=B*2
  K-=1
 
while(B>=C and K>0):
  C=C*2
  K-=1

if B>A and C>B:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
A,B,C = [int(x) for x in input().split()]
K=input()

while(A>B):
  K-=1
  if K==0:
    print("No")
    exit()
  B=B*2

while(B>C):
  C=C*2
  if K==1:
    break
  K-=1
  if K==0:
    print("No")
    exit()

Buggy submission (verdict: Runtime Error):
A,B,C = [int(x) for x in input().split()]
K=input()

while(A>B):
  K-=1
  if K==0:
    print("No")
    exit()
  B=B*2

while(B>C):
  C=C*2
  if K==1:
    break
  K-=1
  if K==0:
    print("No")
    exit()

print("Yes")
Problem p02602 (python)

Fixed submission:
N,K=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]

for x in range(K,N):
  if a[x]>a[x-K]:
    print("Yes")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
N,K=[int(x) for x in input().split()]
A=[int(x) for x in input().split()]

for x in range(K,N):
  if a[x]>a[x-K]:
    print("Yes")
  else:
    print("No")
Problem p02606 (python)

Fixed submission:
L, R, d = [int(x) for x in input().split()]

count = 0

for x in range(L,R+1):
    if x % d == 0:
        count += 1

print(count)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())

rtn = int(math.sqrt(N))

used = [[0]*3]*N

count = [0] * N


if N <= 5:
    for x in range(N):
        print(count[x])
else:
    for n in range(6,N):
        #print(n)
        for x in range(1,rtn):
            #print(x)
            xx = x**2
            if xx <= n - 5:
                #print("xpath")
                for y in range(1,rtn):
                    #print(x,y)
                    xy = x*y
                    yy = y**2
                    ysum = xx+yy+xy
                    if ysum <= n-3:
                        #print("ypath")
                        for z in range(1,rtn):
                            #print(x,y,z)
                            zz = z**2
                            xz = x*z
                            yz = y*z
                            result = ysum+zz+xz+yz
                            if result > n:
                                break
                            if result == n:
                                count[n-1] += 1
                                #print("zpath")
                                used.append
    for x in range(N):
        print(count[x])

Buggy submission (verdict: Runtime Error):
import math

N = int(input())

rtn = int(math.sqrt(N)) + 1 

used = []

count = [0] * N


if N <= 5:
    for x in range(N):
        print(count(x))
else:
    for n in range(6,N):
        print(n)
        for x in range(1,rtn):
            #print(x)
            xx = x**2
            if xx <= n - 5:
                #print("xpath")
                for y in range(1,rtn):
                    #print(x,y)
                    xy = x*y
                    yy = y**2
                    ysum = xx+yy+xy
                    if ysum <= n-3:
                        #print("ypath")
                        for z in range(1,rtn):
                            #print(x,y,z)
                            zz = z**2
                            xz = x*z
                            yz = y*z
                            result = ysum+zz+xz+yz
                            if result > n:
                                break
                            if result == n:
                                count[n-1] += 1
                                #print("zpath")
    for x in range(N):
        print(count[x])
Problem p02612 (python)

Fixed submission:
x = int(input())

while 1:
    x = x - 1000
    if x <= 0:
        break

print(abs(x))

Buggy submission (verdict: Runtime Error):
N = int(input())
c = [0] * 4
for i in range(N):
    X = input()
    if X == "AC":
        c[0] += 1
    elif X == "WA":
        c[1] += 1
    elif X == "TLE":
        c[2] += 1
    else:
        c[3] += 1
print("""AC x {}
WA x {}
TLE x {}
RE x {}""".format(c[0],c[1],c[2],c[3]))
Problem p02621 (python)

Fixed submission:
a = input()
a = int(a)
print(a+a*a+a*a*a)

Buggy submission (verdict: Runtime Error):
nums=input()
nums=nums.split()
M,N,K = int(nums[0]),int(nums[1]),int(nums[2])

al=input()
al2=al.split()
for n in range(M):
    al2[n] = int(al2[n])

bl=input()
bl2=bl.split()
for n in range(N):
    bl2[n] = int(bl2[n])

count=0

ai=0
bi=0

while 1:
    if al2[ai] <= bl2[bi] and al2[ai] <= K:
        K = K-al2[ai]
        ai+=1
        count+=1
        

    elif al2[ai] > bl2[bi] and bl2[bi] <= K:
        K = K-bl2[bi]
        bi+=1
        count+=1
    else:
        break

print(count)
Problem p02630 (python)

Fixed submission:
'''
参考
https://drken1215.hatenablog.com/entry/2020/06/21/224900
'''
N = int(input())
A = list(map(int, input().split()))

INF = 10 ** 5
cnt = [0] * (INF+1)

Q = int(input())
BC = []

for _ in range(Q):
    BC.append(list(map(int, input().split())))

for a in A:
    cnt[a] += 1

total = sum(A)

for b, c in BC:
    total += (c-b) * cnt[b]
    cnt[c] += cnt[b]
    cnt[b] = 0
    print(total)

Buggy submission (verdict: Runtime Error):
'''
参考
https://drken1215.hatenablog.com/entry/2020/06/21/224900
'''
N = int(input())
A = list(map(int, input().split()))

INF = 10 ** 5
cnt = [0] * INF
total = 0

for a in A:
    cnt[a] += 1
    total += a

Q = int(input())
BC = []

for _ in range(Q):
    BC.append(list(map(int, input().split())))

for b, c in BC:
    cnt[c] += cnt[b]
    total += (c-b) * cnt[b]
    cnt[b] = 0
    print(total)

Buggy submission (verdict: Runtime Error):
'''
参考
https://drken1215.hatenablog.com/entry/2020/06/21/224900
'''
N = int(input())
A = list(map(int, input().split()))

INF = 10 ** 5
cnt = [0] * INF
total = 0

for a in A:
    cnt[a] += 1
    total += a

Q = int(input())

for _ in range(Q):
    B, C = map(int, input().split())
    cnt[C] += cnt[B]
    total += (C-B) * cnt[B]
    cnt[B] = 0
    print(total)
Problem p02641 (python)

Fixed submission:
X, N = map(int, input().split())
if N == 0:
    print(X)
    exit()
else:
    P = list(map(int, input().split()))

n_P = []

for i in range(1, 100):
    if i not in P:
        n_P.append(i)

n_P.append(0)
n_P.append(101)

n_P.sort()
INF = 10 ** 9
diff = INF
ans = INF

for p in n_P:
    if abs(X-p) < diff:
        diff = abs(X-p)
        ans = p

print(ans)

Buggy submission (verdict: Runtime Error):
X, N = map(int, input().split())
if N == 0:
    print(X)
    exit()
else:
    P = list(map(int, input().split()))

n_P = []

for i in range(1, 100):
    if i not in P:
        n_P.append(i)

n_P.sort()
INF = 10 ** 9
diff = INF
ans = INF

for p in n_P:
    if abs(X-p) < diff:
        diff = abs(X-p)
        ans = p

if abs(X-ans) > abs(X-n_P[-1]+1):
    ans = n_P[-1] + 1
if abs(X-ans) > abs(X-n_P[0]-1):
    ans = n_P[0] - 1

print(ans)
Problem p02802 (python)

Fixed submission:
N, M = map(int, input().split())
ac = [0] * N
wa = [0] * N

for _ in range(M):
  p_str, s = map(str, input().split())
  p = int(p_str)
  if ac[p-1] == 1:
    continue
  if s == 'AC':
    ac[p-1] = 1
  if s == 'WA':
    wa[p-1] += 1

result = [x * y for (x, y) in zip(ac, wa)]
AC = sum(ac)
WA = sum(result)

print(AC, WA)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ac = []
wa = 0

for _ in range(M):
  p_str, s = map(str, input().split())
  p = int(p_str)
  if p in ac:
    continue
  if s == 'AC':
    ac.append(p)
    p.sort
  if s == 'WA':
    wa += 1

print(len(ac), wa)
Problem p02911 (python)

Fixed submission:
N, K, Q = map(int, input().split())
N_list = [0] * N

for _ in range(Q):
  A = int(input())
  A -= 1
  N_list[A] += 1

for n in N_list:
  if n + K - Q > 0:
    print('Yes')
  else:
    print('No')

Buggy submission (verdict: Runtime Error):
N, K, Q = map(int, input().split())
N_list = [0] * N

for _ in range(Q):
  A = int(input())
  A -= 1
  N_list[A] += 1

for i in N_list:
  if N_list[i] - Q + K > 0:
    print('Yes')
  else:
    print('No')
Problem p02953 (python)

Fixed submission:
N = int(input())
H = list(map(int, input().split()))
 
hmax = H[-1]
 
for h in reversed(H):
  if h <= hmax:
    hmax = h
    continue
  if h-1 <= hmax:
    hmax = h-1
    continue
  print('No')
  quit()

print('Yes')

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))

count = 0
flg = True

for i in range(len(H)):
  if i!=len(H) and H[i] > H[i+1]:
    H[i] -= 1
  if i!=0 and H[i-1] > H[i]:
    flg = False
    break

if flg==True:
  print('Yes')
else:
  print('No')
Problem p02639 (python)

Fixed submission:
from sys import stdin

seq = list(map(int, stdin.readline().split()))
for i in range(5):
  if seq[i]==0:
    print(i+1)
    break

Buggy submission (verdict: Runtime Error):
import os
from sys import stdin

seq = list(map(int, stdin.readline().split()))
for i in range(len(seq)):
    if seq[i]==0:
        print(i+1)
        return

Buggy submission (verdict: Runtime Error):
import os
from sys import stdin

seq = list(map(int, stdin.readline().split()))
for i in range(len(seq)):
  if seq[i]==0:
    print(i+1)
    return
Problem p02681 (python)

Fixed submission:
S = input()
T = input()

if ((len(S)+1) == len(T)) and S == T[:-1]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
S = input()
T = input()

if len(S)+1 == len(T):
  print('Yes')
else"
  print('No')
Problem p02732 (python)

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

# A_set = list(set(A))
# Ad = {a_set:A.count(a_set) for a_set in A_set}
Ad = {}
for i in A:
  if not i in Ad:
    Ad[i]=0
  Ad[i] += 1

score_sum = sum([x*(x-1)/2 for x in list(Ad.values())])

for a in A:
    print(int(score_sum - (Ad[a] - 1)))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
A_set = list(set(A))

Ad = {a_set:A.count(a_set) for a_set in A_set}

score_sum = sum([x*(x-1)/2 for x in list(Ad.values())]

for a in A:
    print(int(score_sum - (Ad[a] - 1)))
Problem p02684 (python)

Fixed submission:
N,K = map(int,input().split())
A = list(map(int,input().split()))

town = [0 for i in range(N+1)]

def next(A,now):
    return(A[now-1])

now = 1
i = 0
while True:
    if town[now] != 0:
        roop_start = town[now]
        roop_end = i
        break
    town[now] = i+1
    now = next(A,now)
    i += 1

roop = roop_end - roop_start + 1
teleport = min(roop_start + (K - roop_start)%roop,K)

now = 1
for i in range(teleport):
    now = next(A,now)

print(now)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict

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

dict = defaultdict(lambda: 0)
dict[1] = 1
next = A[0]

for k in range(1,K+1):
    if dict[next] !=0:
        roop_start = dict[next]
        roop_end = k
        break
    dict[next] = k+1
    next = A[next-1]

roop = roop_end - roop_start + 1
teleport = roop_start + (K - roop_start)%roop

next = 1
for i in range(teleport):
    next = A[next-1]

print(next)
Problem p02615 (python)

Fixed submission:
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    A = sorted(A, reverse=True)
    if N==2:
        print(A[0])
        return

    i = 0
    while(pow(2,i)<N): i+=1
    # print(A)

    rem = N-2**(i-1)
    if rem%2 == 1: od = 1
    else: od = 0
    # print(A[:2**(i-2)])
    ans = sum(A[:2**(i-2)])*2 - A[0]
    # print(ans)
    # print(A[2**(i-2):2**(i-2)+rem//2])
    ans+= sum(A[2**(i-2):2**(i-2)+rem//2])*2
    # print(ans)

    if od:
        ans+= A[2**(i-2)+rem//2]
    print(ans)

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    A = sorted(A, reverse=True)

    i = 0
    while(pow(2,i)<N): i+=1
    # print(A)

    rem = N-2**(i-1)
    if rem%2 == 1: od = 1
    else: od = 0
    # print(A[:2**(i-2)])
    ans = sum(A[:2**(i-2)])*2 - A[0]
    # print(ans)
    # print(A[2**(i-2):2**(i-2)+rem//2])
    ans+= sum(A[2**(i-2):2**(i-2)+rem//2])*2
    # print(ans)

    if od:
        ans+= A[2**(i-2)+rem//2]
    print(ans)

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()
Problem p02664 (python)

Fixed submission:
#!/usr/bin/env python3
import sys


def solve(T: str):
    a = ""
    # prev = ""
    for i in range(len(T)):
        t = T[i]
        if t == "?":
            t="D"
        a+=t
        # prev = t
    print(a)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    T = next(tokens)  # type: str
    solve(T)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys


def solve(T: str):
    a = ""
    prev = ""
    for i in range(len(T)):
        t = T[i]
        if t == "?":
            if prev =="P":
                t="D"
            elif prev == "D":
                t="P"
            else:
                if T[i+1] == "D":
                    t="P"
                else:
                    t="D"
        a+=t
        prev = t
    print(a)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    T = next(tokens)  # type: str
    solve(T)

if __name__ == '__main__':
    main()
Problem p02838 (python)

Fixed submission:
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]"):
    A = [format(a, "b")[::-1] for a in A]
    a_sum = [int()]*60

    for a in A:
        for i, r_a in enumerate(a):
            if r_a == "1":
                a_sum[i] += 1

    a_sum = [a_s_*(2**i)%MOD for i, a_s_ in zip(range(60), a_sum)]
    a_acc_sum = [_ for _ in a_sum]
    
    for x in range(1,60):
        a_acc_sum[x] = a_acc_sum[x-1] + a_acc_sum[x] 
    
    ans = 0
    for a in A:
        for i, r_a in enumerate(a):
            if r_a == "0":
                ans += a_sum[i]
        
        ans += a_acc_sum[59] - a_acc_sum[i]

        # for ic in range(i+1,60):
            # ans+=a_sum[ic]
            # ans%=MOD

    print(ans%MOD)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]"):
    a_sum = [int()]*60

    for a in A:
        for i, r_a in enumerate(format(a, "b")[::-1]):
            if r_a == "1":
                a_sum[i] += 1

    a_sum = [a_s_*(2**i)%MOD for i, a_s_ in zip(range(60), a_sum)]
    a_acc_sum = a_sum.copy()
    for x in range(1,60):
        a_acc_sum[x] = a_acc_sum[x-1] + a_acc_sum[x] 
    
    ans = 0
    for a in A:
        for i, r_a in enumerate(format(a, "b")[::-1]):
            if r_a == "0":
                ans += a_sum[i]
        
        ans += a_acc_sum[59] - a_acc_sum[i]

        # for ic in range(i+1,60):
            # ans+=a_sum[ic]
            # ans%=MOD

    print(ans%MOD)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()
Problem p02888 (python)

Fixed submission:
#!/usr/bin/env python3
import sys
# import numpy as np
import bisect

def solve(N: int, L: "List[int]"):
    L = sorted(L)
    ct = 0
    for a in range(len(L)-2):
        a_ = L[a]
        for b in range(a+1, len(L)-1):
            b_in = bisect.bisect_left(L,a_+L[b]) - b -1
            if b_in > 0:
                ct+=b_in

            # print("L :{} a+Lb :{}  b_in:{}".format(L[b+1:],a_+L[b],ct))
        # ct += sum([bisect.bisect_left(L[b+1:],a_+L[b]) for b in range(a+1, len(L)-1)])
    print(ct)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    L = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, L)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
import numpy as np

def solve(N: int, L: "List[int]"):
    L = np.array(sorted(L))
    ct = 0
    for a in range(len(L)-2):
        for b in range(a, len(L)-1):
            ct+=((L[b] < L) & (L < L[a+b])).sum() 
    print(ct)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    L = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, L)

if __name__ == '__main__':
    main()
Problem p02945 (python)

Fixed submission:
import numpy as np
a = [int(i) for i in input().split()] 

print(np.array([a[0]+a[1],a[0]-a[1],a[0]*a[1]]).max())

Buggy submission (verdict: Runtime Error):
a = [int(i) for i in input().split()] 

return np.array([a[0]+a[1],a[0]^a[1],a[0]*a[1]]).max()
Problem p03014 (python)

Fixed submission:
import sys

def solve(H: int, W: int, S: "List[int]"):
    # print(S)

    hcnts = [[0]*W for _ in range(H)]
    for h in range(H):
        hcnts[h][0] = S[h][0]
        for t in range(1,W):
            hcnts[h][t] = (S[h][t]+hcnts[h][t-1])*S[h][t]
    for h in range(H):
        for t in range(W-2,-1,-1):
            hcnts[h][t] = max(hcnts[h][t],hcnts[h][t+1])*bool(hcnts[h][t])

    wcnts = [[0]*W for _ in range(H)]
    for h in range(W):
        wcnts[0][h] = S[0][h]
        for t in range(1,H):
            wcnts[t][h] = (S[t][h]+wcnts[t-1][h])*S[t][h]
    for h in range(W):
        for t in range(H-2,-1,-1):
            wcnts[t][h] = max(wcnts[t][h],wcnts[t+1][h])*bool(wcnts[t][h])
    # print(hcnts)
    # print(wcnts)
    a = [hcnts[h][w]+wcnts[h][w]-1 for h in range(H) for w in range(W)]
    print(max(a))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    S = [[ int(_.replace(".", "1").replace("#", "0")) for _ in next(tokens)] for _ in range(H)]  # type: "List[str]"
    solve(H, W, S)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
import numpy as np

def solve(H: int, W: int, S: "List[str]"):
    S = np.array(S)
    sh = np.zeros((H, W),dtype=np.int)
    sw = np.zeros((W, H),dtype=np.int)

    for i, a in enumerate(S):
        left = np.arange(1, len(a)+1)
        left[a==0] = 0
        left = np.maximum.accumulate(left)
        a_ = a[::-1]
        right = np.arange(1,len(a)+1)
        right[a_==0] = 0
        right = np.maximum.accumulate(right)
        right = len(a)+1 - right[::-1]
        k = ((right-left) - 1)
        k[a==1] =0
        sh[i] = k

    for i, a in enumerate(S.T):
        left = np.arange(1, len(a)+1)
        left[a==0] = 0
        left = np.maximum.accumulate(left)
        
        right = np.arange(1,len(a)+1)
        right[a[::-1]==0] = 0
        right = np.maximum.accumulate(right)
        right = len(a)+1 - right[::-1]
        k = ((right-left) - 1)
        k[a==1] =0
        sw[i] = k

    print(np.max(sw+sh.T)-1)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    S = [[ int(_.replace(".", "0").replace("#", "1")) for _ in next(tokens)] for _ in range(H)]  # type: "List[str]"
    solve(H, W, S)

if __name__ == '__main__':
    main()