TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: There is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step. He can climb up one or two steps at a time.  However, the treads of the a_1-th, a_2-th, a_3-th, \ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.  How many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps? Find the count modulo 1\ 000\ 000\ 007.

Submission attempts (in order):
N,M=map(int,input().split())
L=[0]*M
R=[0]*M
for i in range(M):
    L[i],R[i]=map(int,input().split())
def quick_sort(arr):
    left = []
    right = []
    if len(arr) <= 1:
        return arr

    
    # ref = random.choice(arr)
    ref = arr[0]
    ref_count = 0

    for ele in arr:
        if ele < ref:
            left.append(ele)
        elif ele > ref:
            right.append(ele)
        else:
            ref_count += 1
    left = quick_sort(left)
    right = quick_sort(right)
    return left + [ref] * ref_count + right
L=quick_sort(L)
R=quick_sort(R)
a=L[M-1]
b=R[0]
if a>b:
  print("0")
else:
  print(b-a+1)

n,m=map(int,input().split())
mod=10**9+7
A=[1]*(n+1)
for i in range(m):
  A[int(input())]=0
B=[1]*(n+1)
if A[1]==0:
  B[1]=0
for i in range(2,n+1):
  B[i]=A[i]*(B[i-1]+B[i-2])%mod
print(B[n])

Verdicts: Runtime Error

Accepted
Problem: There is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step. He can climb up one or two steps at a time.  However, the treads of the a_1-th, a_2-th, a_3-th, \ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.  How many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps? Find the count modulo 1\ 000\ 000\ 007.

Submission attempts (in order):
import sys
input = sys.stdin.readline
import math
def fibnatch(n):
  if n==0:
    return 1
  a=(pow(((1+math.sqrt(5))/2),n)-pow(((1-math.sqrt(5))/2),n))/math.sqrt(5)
  c=int(a)
  if n==1:
    return 1
  elif abs(c-a)>=abs(c-a+1):
    return (c+1)%1000000007
  else:
    return c%1000000007
L=list()
N,M=map(int,input().split())
a=1
for i in range(M):
  c=int(input())
  if i==0:
    L.append(c-a)
  else:
    L.append(c-a-1)
  a=c
if 0 in L[1:]:
  print(0)
  sys.exit()
L.append(N-c)
s=1
for i in range(len(L)):
  d=L[i]
  s=(s*fibnatch(d))%1000000007
print(s)

N,M=map(int,input().split())
L=[0]*N
c={}
mod=1000000007
for i in range(M):
  k=int(input())
  c[k]=0
for i in range(N):
  if i==0:
    L[i]=1
  elif i==1:
    if L[0]==0:
      L[i]=1
    else:
      L[i]=2
  else:
    L[i]=(L[i-1]+L[i-2])%mod
  if i+1 in c:
    L[i]=0
print(L[N-1])

Verdicts: Runtime Error

Accepted
Problem: There is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step. He can climb up one or two steps at a time.  However, the treads of the a_1-th, a_2-th, a_3-th, \ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.  How many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps? Find the count modulo 1\ 000\ 000\ 007.

Submission attempts (in order):
N, M = map(int, input().split())
MOD = 1000000007

broken = [0] * N
for i in range(M):
    broken[int(input())-1] = 1


dp = [0] * (N + 1)
dp[N-1] = dp[N] = 1
for i in reversed(range(N-1)):
    if broken[i]:
        dp[i] = 0
        continue
    dp[i] = dp[i+1] + dp[i+2]

print(dp[0] % MOD)


MOD = 10**9+7
N, M = map(int, input().split())
broken = {int(input()) for _ in range(M)}

dp = [0 for _ in range(N+2)]
dp[N+1] = 0
dp[N] = 1

for i in reversed(range(N)):
    if i not in broken:
        dp[i] = dp[i+1] + dp[i+2]
        dp[i] %= MOD

print(dp[0])


Verdicts: Wrong Answer

Accepted
Problem: There is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step. He can climb up one or two steps at a time.  However, the treads of the a_1-th, a_2-th, a_3-th, \ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.  How many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps? Find the count modulo 1\ 000\ 000\ 007.

Submission attempts (in order):
import sys
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
s=n-len(a)*2
S=[1,2]
for i in range(s):
    S.append((S[-1]+S[-2])%1000000007)
print(S)
step=[]
a=[0]+a+[n]
for i in range(len(a)-1):
    if i==0 and a[1]==1:
        step.append(1)
    elif i==0:
        step.append(S[a[i+1]-a[i]-2])
    elif i==len(a)-2 and a[-1]==n-1:
        step.append(1)
    elif i==len(a)-2:
        step.append(S[a[i+1]-a[i]-2])
    elif a[i+1]-a[i]==1:
        print(0)
        sys.exit()
    else:
        step.append(S[a[i+1]-a[i]-3])
print(step)
ans=1
for i in step:
    ans*=i
    ans%=1000000007
print(ans)






import sys
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
s=n-len(a)*2
S=[1,2]
for i in range(s):
    S.append((S[-1]+S[-2])%1000000007)

step=['00']+['1']*(n+1)
for i in range(m):
    step[a[i]+1]='0'
    step[a[i]+2]='0'
st=''.join(step)
#print(st)
st=st.split('00')
print(st)
ans=[]
if '0' in st:
    print(0)
    sys.exit()
else:
    for i in range(1,len(st)):
        ans.append(S[len(st[i])-1])
#print(ans)
p=1
for i in range(len(ans)):
    p*=ans[i]
print(p%1000000007)



import sys
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
s=n-len(a)*2
S=[1,2]
for i in range(s):
    S.append((S[-1]+S[-2])%1000000007)

step=['00']+['1']*(n+1)
for i in range(m):
    step[a[i]+1]='0'
    step[a[i]+2]='0'
st=''.join(step)
#print(st)
st=st.split('00')
#print(st)
ans=[]
if '0' in st:
    print(0)
    sys.exit()
else:
    for i in range(1,len(st)):
        ans.append(S[len(st[i])-1])
#print(ans)
p=1
for i in range(len(ans)):
    p*=ans[i]
print(p%1000000007)



n,m=map(int,input().split())
a=set([int(input()) for _ in range(m)])
dp=[1]+[0 for _ in range(n)]
mod=1000000007
for i in range(1,n+1):
    if i in a:
        dp[i]=0
    else:
        dp[i]=(dp[i-1]+dp[i-2])%mod
print(dp[-1])

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: There is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step. He can climb up one or two steps at a time.  However, the treads of the a_1-th, a_2-th, a_3-th, \ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.  How many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps? Find the count modulo 1\ 000\ 000\ 007.

Submission attempts (in order):
# -*- coding: utf-8 -*-
def main():
    N,M = map(int,input().split())
    A = [int(input()) for i in range(M)]
    MOD = 1000000007
    ans = []
    ans.append(0) if 1 in A else ans.append(1)
    ans.append(0) if 2 in A else ans.append(1)
    for i in range(2,N):
        ans.append(0)
        if i+1 in A:
            continue
        ans[i] += (ans[i-1] + ans[i-2])
    print(ans[N-1] % MOD)
if __name__ == '__main__':
    main()

# -*- coding: utf-8 -*-
def main():
    N,M = map(int,input().split())
    A = set([int(input()) for _ in range(M)])
    MOD = 1000000007
    ans = [1]
    ans.append(0) if 1 in A else ans.append(1)
    for i in range(2,N+1):
        ans.append(0)
        if i in A:
            continue
        ans[i] += (ans[i-1] + ans[i-2])
    print(ans[N] % MOD)
if __name__ == '__main__':
    main()

Verdicts: Wrong Answer

Accepted
Problem: There is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step. He can climb up one or two steps at a time.  However, the treads of the a_1-th, a_2-th, a_3-th, \ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.  How many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps? Find the count modulo 1\ 000\ 000\ 007.

Submission attempts (in order):
N , M = map(int ,input().split())
mod = 10 ** 9 + 7
A = []
for i in range(M):
    A.append(int(input()))
    if A[i] - 1 == A[i - 1] and i > 0:
        print("0")
        exit()
dp = [0] * (N + 1)
dp[0] = 1
idx = 0
crash = A[idx]
for i in range(1 , N + 1):
    if i == crash:
        idx += 1
        crash = A[idx]
        continue
    else:
        if i == 1:
            dp[1] = 1
        else:
            dp[i] = dp[i - 1] + dp[i - 2]
            dp[i] %= mod
print(dp[-1])


N , M = map(int ,input().split())
mod = 10 ** 9 + 7
A = []
crash = 0
idx = 0
for i in range(M):
    A.append(int(input()))
    if i == 0:
        crash = A[0]
    if A[i] - 1 == A[i - 1] and i > 0:
        print("0")
        exit()
dp = [0] * (N + 1)
dp[0] = 1

for i in range(1 , N + 1):
    if i == crash:
        idx += 1
        if idx < M:
            crash = A[idx]
    else:
        if i == 1:
            dp[1] = 1
        else:
            dp[i] = dp[i - 1] + dp[i - 2]
            dp[i] %= mod
print(dp[-1])


Verdicts: Runtime Error

Accepted
Problem: There is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step. He can climb up one or two steps at a time.  However, the treads of the a_1-th, a_2-th, a_3-th, \ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.  How many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps? Find the count modulo 1\ 000\ 000\ 007.

Submission attempts (in order):
Num = 10 ** 9 + 7
N, M = map(int, input().split())
if M != 0
  danger = int(input())
count = 1
l = [1, 1]
for i in range(1, N):
  if i == danger:
    l[1] = 0
    if count < M:
      danger = int(input())
      count += 1
  l = [l[1] % Num, l[0] + l[1]]
  if l == [0, 0]:
    break
if N == danger:
  l[1] = 0
print(l[1] % Num)

Num = 10 ** 9 + 7
N, M = map(int, input().split())
danger = -1
if M != 0:
  danger = int(input())
count = 1
l = [1, 1]
for i in range(1, N):
  if i == danger:
    l[1] = 0
    if count < M:
      danger = int(input())
      count += 1
  l = [l[1] % Num, l[0] + l[1]]
  if l == [0, 0]:
    break
if N == danger:
  l[1] = 0
print(l[1] % Num)

Verdicts: Runtime Error

Accepted
Problem: There is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step. He can climb up one or two steps at a time.  However, the treads of the a_1-th, a_2-th, a_3-th, \ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.  How many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps? Find the count modulo 1\ 000\ 000\ 007.

Submission attempts (in order):
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r)*math.factorial(r))

n,m=map(int(i) ,input().split())
a1=[int(input()) for i in range(m)]
a1.append(n+1)
c1=1
a2=0
for i in a1:
    a3=i-1-a2
    c2=0
    for j in range(a3//2+1):
        c2+=combinations_count(a3-j,j)
    c1=(c1*c2)%(1000000007)
    a2=i+1
    if c1==0:
        break



print(c1)






n,m=input().split()
n,m=int(n),int(m)
ax=[int(input()) for i in range(m)]
bx=[1,1]
if ax[0]==1:
    bx[1]=0
for i in range(2,n+1):
    if i in ax:
        bx.append(0)
    else:
        bx.append((bx[i-2]+bx[i-1])%1000000007)
print(bx)






n,m=input().split()
n,m=int(n),int(m)
ax=[1]*(n+1)
for i in range(m):
    ax[int(input())]=0
bx=[1,1]
for i in range(2,n+1):
    if ax[i-1]==1:
        f1=bx[i-1]
    else:
        f1=0
    if ax[i-2]==1:
        f2=bx[i-2]
    else:
        f2=0
    bx.append((f1+f2)%(10**9+7))

print(bx[n])


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: There is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step. He can climb up one or two steps at a time.  However, the treads of the a_1-th, a_2-th, a_3-th, \ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.  How many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps? Find the count modulo 1\ 000\ 000\ 007.

Submission attempts (in order):
N,M = map(int, input().split())
A = [int(input()) for a in range(M)]
A = set(A)
	
DP = [0] * (N + 1)	
DP[0] = 1

mod = (10 ** 9) + 7

for i in range(1,N+1):
	if i in A:
		DP[i] = 0
	else:
		DP[i] = DP[i-1] + DP[i-2]

print(DP[n] % (mod))

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

def recur(step):
  if step == N:
    return 1　
  
  elif step in A or step > N:
    return 0
  
  else:
    ret1 = recur(step + 1) 
    ret2 = recur(step + 2) 
    return (ret1 + ret2) / (10 ** 9 + 7) 
    
print(recur(0))
    

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

def recur(step):
  if step == N:
    return 1　
  
  elif step in A or step > N:
    return 0
  
  else:
    ret1 = recur(step + 1) 
    ret2 = recur(step + 2) 
    return (ret1 + ret2) % (10 ** 9 + 7) 
    
print(recur(0))
    

N,M = map(int, input().split())
A = [int(input()) for a in range(M)]
A = set(A)
	
DP = [0] * (N + 1)	
DP[0] = 1

mod = (10 ** 9) + 7

for i in range(1,N+1):
	if i in A:
		DP[i] = 0
	else:
		DP[i] = DP[i-1] + DP[i-2]

print(DP[N] % (mod))

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: There is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step. He can climb up one or two steps at a time.  However, the treads of the a_1-th, a_2-th, a_3-th, \ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.  How many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps? Find the count modulo 1\ 000\ 000\ 007.

Submission attempts (in order):
from scipy.misc import comb as combination

N,M = map(int, input().split())
a = [int(input()) for _ in range(M)]
a.append(N+1)

if M != 1:
  for i in range(M-1):
    if a[i+1] - a[i] == 1:
      print(0)
      exit()

route = []
begin = 0
for i in range(M+1):
  stair = a[i]-1
  space = stair - begin
  flag = stair%2
  if flag == 0:
    comb = [j for j in range(0, space+1, 2)]
  else:
    comb = [j+1 for j in range(0, space+1, 2)]
  total = [combination((space-tmp)//2+tmp, tmp, exact=True) for tmp in comb]
  route.append(sum(total))
  begin = stair+2
ans = 1
for i in route:
	ans *= i  
print(ans%1000000007)

N,M = map(int, input().split())
a = [int(input()) for _ in range(M)]
dp = [0]*n
dp[0] = 1
dp[1] =0 if 2 in a else 1
for i in range(2, N+1):
  dp[i] = (dp[i-1] + dp[i-2])%(10**9+7) if i not in a else 0
print(dp[n])

from scipy.misc import comb as combination

N,M = map(int, input().split())
a = [int(input()) for _ in range(M)]
a.append(N+1)

route = []
start = 0
for i in range(M+1):
  stair = a[i]-1
  space = stair - start
  flag = stair%2
  if flag == 0:
    comb = [j for j in range(0, space+1, 2)]
  else:
    comb = [j+1 for j in range(0, space+1, 2)]
  total = [combination((space-tmp)//2+tmp, tmp, exact=True) for tmp in comb]
  route.append(sum(total))
  start = stair+2
ans = 1
for i in route:
	ans *= i  
print(ans%1000000007)

N,M = map(int, input().split())
a = set([int(input()) for _ in range(M)])
dp = [0]*(N+1)
dp[0] = 1
dp[1] =0 if 1 in a else 1
for i in range(2, N+1):
  dp[i] = (dp[i-1] + dp[i-2])%(10**9+7) if i not in a else 0
print(dp[N])

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: There is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step. He can climb up one or two steps at a time.  However, the treads of the a_1-th, a_2-th, a_3-th, \ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.  How many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps? Find the count modulo 1\ 000\ 000\ 007.

Submission attempts (in order):
def fb(num):
    
    a, b = 1, 0
    for _ in range(num):
        a, b = a + b, a
    return b

import functools
import operator

import sys
n, m = map(int, input().split())
a = sorted(list(set(map(int, sys.stdin.readlines()))))
m = len(a)

s = 0
e = n
xs = [0] * (m + 1)
for i, j in enumerate(a):
  xs[i] = fb(j - s - 1)
  s = j + 1
xs[m] = fb(n - s)
if 0 in xs:
  print(0)
else:
  result = functools.reduce(operator.mul, xs)
  print(result % 1000000007)


def fb(num):
    
    a, b = 1, 0
    for _ in range(num):
        a, b = a + b, a
    return b

import functools
import operator

import sys
n, m = map(int, input().split())
a = sorted(list(set(map(int, sys.stdin.readlines()))))
m = len(a)

s = 0
e = n
xs = [0] * (m + 1)
for i, j in enumerate(a):
  xs[i] = fb(j - s)
  s = j + 1
xs[m] = fb(n - s + 1)
if 0 in xs:
  print(0)
else:
  result = functools.reduce(operator.mul, xs)
  print(result % 1000000007)


Verdicts: Wrong Answer

Accepted
Problem: There is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step. He can climb up one or two steps at a time.  However, the treads of the a_1-th, a_2-th, a_3-th, \ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.  How many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps? Find the count modulo 1\ 000\ 000\ 007.

Submission attempts (in order):
mod=1000000007
N,M=map(int,input().split())
A=[]
for m in range(M):
    A.append(int(input()))

def check(A):
    for m in range(M-1):
        if A[m+1]-A[m]==1:
            return False
    return True

def fibo(n):
    if n==0 or n==1:
        return 1
    else:
        L=[1,1]
        for i in range(2,n+1):
            L=[L[-1]]+[sum(L)]
        return L[-1]

def main(A,N):
    if check(A)==False:
        return 0
    else:
        A=[0]+A+[N+1]
        B=[A[n+1]-A[n]-2 for n in range(M+1)]
        x=1
        for b in B:
            x*=fibo(b)
        return x%mod

print(main(A,N))

mod=1000000007
N,M=map(int,input().split())
A=[]
for m in range(M):
    A.append(int(input()))

def check(A):
    for m in range(M-1):
        if A[m+1]-A[m]==1:
            return False
    return True

def fibo(n):
    if n==0 or n==1:
        return 1
    else:
        L=[1,1]
        for i in range(2,n+1):
            L=[L[-1]]+[sum(L)]
        return L[-1]

def main(A,N):
    if check(A)==False:
        return 0
    else:
        A=[0]+A+[N+1]
        B=[max(A[n+1]-A[n]-2,0) for n in range(M+1)]
        x=1
        for b in B:
            x*=fibo(b)
        return x%mod

print(main(A,N))

mod=10**9+7
N,M=map(int,input().split())
A=[int(input()) for m in range(M)]
L=[1 for n in range(N+1)]
for a in A:
    L[a]=0
Block=[0,1]
for n in range(1,N+1):
    if L[n]:
        Block=Block[1:]+[sum(Block)%mod]
    else:
        Block=Block[1:]+[0]
print(Block[-1])

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step. He can climb up one or two steps at a time.  However, the treads of the a_1-th, a_2-th, a_3-th, \ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.  How many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps? Find the count modulo 1\ 000\ 000\ 007.

Submission attempts (in order):
N, M = map(int, input().split())

A = [int(input()) for i in range(M)]

for i in range(1, len(A)):
    if A[i]-A[i-1]==1:
        print(0)
        exit()

ans = 0

m = []
now = 0
rlt = 0
for a in A:
    n = a-now
    if n==1 or n==2: s = 1
    else: s = int((float(1)/2)*(pow(n-2,2)-n+2+4))

    m.append(s)
    now = a

n = N-now
if n==1 or n==2: s = 1
else: s = int((float(1)/2)*(pow(n-2,2)-n+2+4))
print('n:{}, s:{}'.format(n, s))
m.append(s)

ans = 1

for i in m:
    ans *= i

print(ans%1000000007)



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

oks = [True]*(N+1)

for i in range(M):
    a = int(input())
    oks[a] = False

dp = [0]*(N+1)

dp[0]=1
if oks[1]==True: dp[1] = 1

for i in range(2, N+1):
    if oks[i]==True:
        dp[i] = (dp[i-1] + dp[i-2]) % (1e9+7)

print(int(dp[N]))


Verdicts: Wrong Answer

Accepted
Problem: There is a grid with H horizontal rows and W vertical columns, and there are obstacles on some of the squares.  Snuke is going to choose one of the squares not occupied by an obstacle and place a lamp on it. The lamp placed on the square will emit straight beams of light in four cardinal directions: up, down, left, and right. In each direction, the beam will continue traveling until it hits a square occupied by an obstacle or it hits the border of the grid. It will light all the squares on the way, including the square on which the lamp is placed, but not the square occupied by an obstacle.  Snuke wants to maximize the number of squares lighted by the lamp.  You are given H strings S_i (1 \leq i \leq H), each of length W. If the j-th character (1 \leq j \leq W) of S_i is `#`, there is an obstacle on the square at the i-th row from the top and the j-th column from the left; if that character is `.`, there is no obstacle on that square.  Find the maximum possible number of squares lighted by the lamp.

Submission attempts (in order):
h,w=map(int,input().split())
s=[]
for i in range(h):
    s.append(list(input()))

tate=[[-1 for _ in range(w)] for _ in range(h)]
yoko=[[-1 for _ in range(w)] for _ in range(h)]

def search(i,j):
    ansij=1

    if(yoko[i][j] == -1):
        xl=j
        while(0<xl and s[i][xl-1]=='.'):
            ansij+=1
            xl-=1
        xr=j
        while(xr<w-1 and s[i][xr+1]=='.'):
            ansij+=1
            xr+=1

        for k in range(xl,xr+1):
            yoko[i][k]=xr-xl+1
    else:
        ansij+=yoko[i][j]

    if(tate[i][j] == -1):
        yu=i
        while(0<yu and s[yu-1][j]=='.'):
            ansij+=1
            yu-=1
        yd=i
        while(yd<h-1 and s[yd+1][j]=='.'):
            ansij+=1
            yd+=1

        for k in range(yu,yd+1):
            tate[k][j]=yd-yu+1
    else:
        ansij+=tate[i][j]

    return ansij

ans=0
for i in range(h):
    for j in range(w):
        if(s[i][j]=='.'):
            ansij=search(i, j)
            if(ans<ansij):

                ans=ansij

# print("tate")

#     print(tate[i])
#
# print("yoko")

#     print(yoko[i])

print(ans)


import numpy as np
h,w=map(int,input().split())
s=[]
for _ in range(h):
    si=input()
    si=si.replace('.', '1')
    si=si.replace('#', '0')
    s.append(list(map(int,si)))
s=np.array(s)

left=np.zeros((h,w))
right=np.zeros((h,w))
up=np.zeros((h,w))
down=np.zeros((h,w))

for i in range(w):
    if(i==0):
        left[:,i]=s[:,i]
        right[:,w-i-1]=s[:,w-i-1]
    else:
        left[:,i]=(left[:,i-1]+1)*s[:,i]
        right[:,w-i-1]=(right[:,w-i]+1)*s[:,w-i-1]

for i in range(h):
    if(i==0):
        down[i,:]=s[i,:]
        up[h-i-1,:]=s[h-i-1,:]
    else:
        down[i,:]=(down[i-1,:]+1)*s[i,:]
        up[h-i-1,:]=(up[h-i,:]+1)*s[h-i-1,:]

ans=left+right+up+down-3
print(int(np.max(ans)))


Verdicts: Wrong Answer

Accepted
Problem: There is a grid with H horizontal rows and W vertical columns, and there are obstacles on some of the squares.  Snuke is going to choose one of the squares not occupied by an obstacle and place a lamp on it. The lamp placed on the square will emit straight beams of light in four cardinal directions: up, down, left, and right. In each direction, the beam will continue traveling until it hits a square occupied by an obstacle or it hits the border of the grid. It will light all the squares on the way, including the square on which the lamp is placed, but not the square occupied by an obstacle.  Snuke wants to maximize the number of squares lighted by the lamp.  You are given H strings S_i (1 \leq i \leq H), each of length W. If the j-th character (1 \leq j \leq W) of S_i is `#`, there is an obstacle on the square at the i-th row from the top and the j-th column from the left; if that character is `.`, there is no obstacle on that square.  Find the maximum possible number of squares lighted by the lamp.

Submission attempts (in order):
import numpy as np

h,w=map(int,input().split())
s=[input() for i in range(h)]

l=[[0 for i in range(w)] for j in range(h)]
r=[[0 for i in range(w)] for j in range(h)]
d=[[0 for i in range(w)] for j in range(h)]
u=[[0 for i in range(w)] for j in range(h)]

for i in range(h):
    for j in range(w):
        if s[i][j]==".":
            if j == o:
                l[i][j]=1
            else:
                l[i][j]=l[i][j-1]+1

for i in range(h):
    for i in range(h-1,-1,-1):
        if s[i][j]==".":
            if j == w-1:
                r[i][j]=1
            else:
                r[i][j]=r[i][j+1]+1

for j in range(w):
    for i in range(h-1,-1,-1):
        if s[i][j]==".":
            if i == h-1:
                d[i][j]=1
            else:
                d[i][j]=d[i+1][j]+1

for j in range(w):
    for i in range(h):
        if s[i][j]=".":
            if i == 0:
                u[i][j]=1
            else:
                i[i][j]=u[i-1][j]+1

ans=0
x=[[0 for i in range(w)] for j in range(h)]
for i in range(h):
    for j in range(w):
        x[i][j] = l[i][j]+r[i][j]+u[i][j]+d[i][j]-3
    ans=max(ans,max(x[i]))

print(ans)

import numpy as np

h,w=map(int,input().split())
s=[]
for i in range(h):
    s.append(list(input()))
grid=(np.array(s) ==".") *1

l=np.zeros((h,w),dtype=int)
r=np.zeros((h,w),dtype=int)
u=np.zeros((h,w),dtype=int)
d=np.zeros((h,w),dtype=int)

for j in range(w):
    if j == 0:
        l[:,j] = grid[:,j]
    else:
        l[:,j] = (l[:,j-1]+1) * grid[:,j]
for j in range(w-1,-1,-1):
    if j == (w-1):
        r[:,j] = grid[:,j]
    else:
        r[:,j] = (r[:,j+1] +1)*grid[:,j]

for i in range(h):
    if i == 0:
        u[i,:]=grid[i,:]
    else:
        u[i,:]=(u[i-1,:]+1)*grid[i,:]
for i in range(h-1,-1,-1):
    if i==(h-1):
        d[i,:]=grid[i,:]
    else:
        d[i,:]=(d[i+1,:]+1)*grid[i,:]


ans=np.max(l+r+u+d-3)
print(ans)

Verdicts: Runtime Error

Accepted
Problem: There is a grid with H horizontal rows and W vertical columns, and there are obstacles on some of the squares.  Snuke is going to choose one of the squares not occupied by an obstacle and place a lamp on it. The lamp placed on the square will emit straight beams of light in four cardinal directions: up, down, left, and right. In each direction, the beam will continue traveling until it hits a square occupied by an obstacle or it hits the border of the grid. It will light all the squares on the way, including the square on which the lamp is placed, but not the square occupied by an obstacle.  Snuke wants to maximize the number of squares lighted by the lamp.  You are given H strings S_i (1 \leq i \leq H), each of length W. If the j-th character (1 \leq j \leq W) of S_i is `#`, there is an obstacle on the square at the i-th row from the top and the j-th column from the left; if that character is `.`, there is no obstacle on that square.  Find the maximum possible number of squares lighted by the lamp.

Submission attempts (in order):
import numpy as np
H,W = mmap(int, input().split())
S = [[] for i in range(H)]
for i in range(H):
  S[i] = list(input())
S = np.array(S)
S = np.where(S=="#",0,1)

l = np.zeros((H,W))
l[:,-1] = S[:,-1]
r = np.zeros((H,W))
r[:,0] = S[:,0]
u = np.zeros((H,W))
u[-1] = S[-1]
d = np.zeros((H,W))
d[0] = S[0]

for i in range(W-2,-1,-1):
  l[:,i] = (l[:,i+1]+1)*S[:,i]
for i in range(1,W):
  r[:,i] = (r[:,i-1]+1)*S[:,i]
for i in range(H-2,-1,-1):
  u[i] = (u[i+1]+1)*S[i]
for i in range(1,H):
  d[i] = (d[i-1]+1)*S[i]

print(int(np.max(l+r+u+d-3)))


import numpy as np
H,W = mmap(int, input().split())
S = [[] for i in range(H)]
for i in range(H):
  S[i] = [input().split()]
S = np.array(S)
S = np.where(S=="#",0,1)

l = np.zeros((H,W))
l[:,-1] = S[:,-1]
r = np.zeros((H,W))
r[:,0] = S[:,0]
u = np.zeros((H,W))
u[-1] = S[-1]
d = np.zeros((H,W))
d[0] = S[0]

for i in range(W-2,-1,-1):
  l[:,i] = (l[:,i+1]+1)*S[:,i]
for i in range(1,W):
  r[:,i] = (r[:,i-1]+1)*S[:,i]
for i in range(H-2,-1,-1):
  u[i] = (u[i+1]+1)*S[i]
for i in range(1,H):
  d[i] = (d[i-1]+1)*S[i]

print(int(np.max(l+r+u+d-3)))

import numpy as np
H,W = map(int, input().split())
S = [[] for i in range(H)]
for i in range(H):
  S[i] = list(input())
S = np.array(S)
S = np.where(S=="#",0,1)

l = np.zeros((H,W))
l[:,-1] = S[:,-1]
r = np.zeros((H,W))
r[:,0] = S[:,0]
u = np.zeros((H,W))
u[-1] = S[-1]
d = np.zeros((H,W))
d[0] = S[0]

for i in range(W-2,-1,-1):
  l[:,i] = (l[:,i+1]+1)*S[:,i]
for i in range(1,W):
  r[:,i] = (r[:,i-1]+1)*S[:,i]
for i in range(H-2,-1,-1):
  u[i] = (u[i+1]+1)*S[i]
for i in range(1,H):
  d[i] = (d[i-1]+1)*S[i]

print(int(np.max(l+r+u+d-3)))


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: There is a grid with H horizontal rows and W vertical columns, and there are obstacles on some of the squares.  Snuke is going to choose one of the squares not occupied by an obstacle and place a lamp on it. The lamp placed on the square will emit straight beams of light in four cardinal directions: up, down, left, and right. In each direction, the beam will continue traveling until it hits a square occupied by an obstacle or it hits the border of the grid. It will light all the squares on the way, including the square on which the lamp is placed, but not the square occupied by an obstacle.  Snuke wants to maximize the number of squares lighted by the lamp.  You are given H strings S_i (1 \leq i \leq H), each of length W. If the j-th character (1 \leq j \leq W) of S_i is `#`, there is an obstacle on the square at the i-th row from the top and the j-th column from the left; if that character is `.`, there is no obstacle on that square.  Find the maximum possible number of squares lighted by the lamp.

Submission attempts (in order):
H, W =  map(int, input().split())

S = []
for _ in range(H):
    tmp = list(input())
    S.append(tmp)
    
import numpy as np

def count_light(Gs, h, w):
    Gc = np.empty((h,w))
    for i, gs in enumerate(Gs):
        count = 0
        for j, s in enumerate(gs):
            if s == '#':
                count = 0
                Gc[i][j] = 0
            else:
                count += 1
                Gc[i][j] = count

    return Gc

Gs1 = np.asarray(S)
Gn1 = count_light(Gs1, H, W)

Gs2 = np.rot90(Gs, k=1)
Gn2 = count_light(Gs2, W, H)

Gs3 = np.rot90(Gs2, k=1)
Gn3 = count_light(Gs3, H, W)

Gs4 = np.rot90(Gs3, k=1)
Gn4 = count_light(Gs4, W, H)

Gn2 = np.rot90(Gn2, k=-1)
Gn3 = np.rot90(Gn3, k=-2)
Gn4 = np.rot90(Gn4, k=-3)

Gsum = Gn1+Gn2+Gn3+Gn4
ans = int(np.max(Gsum)-3)
print(ans)


H, W =  map(int, input().split())

S = []
for _ in range(H):
    tmp = list(input())
    S.append(tmp)
    
import numpy as np

def count_light(Gs, h, w):
    Gc = np.empty((h,w))
    for i in range(w):
        if i == 0:
            Gc[:, i] = Gs[:, i]
        else:
            Gc[:, i] = (Gc[:, i-1] + 1) * Gs[:, i]

    return Gc

Gs1 = np.asarray(S) == "."
Gn1 = count_light(Gs1, H, W)

Gs2 = np.rot90(Gs1, k=1)
Gn2 = count_light(Gs2, W, H)

Gs3 = np.rot90(Gs2, k=1)
Gn3 = count_light(Gs3, H, W)

Gs4 = np.rot90(Gs3, k=1)
Gn4 = count_light(Gs4, W, H)

Gn2 = np.rot90(Gn2, k=-1)
Gn3 = np.rot90(Gn3, k=-2)
Gn4 = np.rot90(Gn4, k=-3)

Gsum = Gn1+Gn2+Gn3+Gn4
ans = int(np.max(Gsum)-3)
print(ans)


Verdicts: Runtime Error

Accepted
Problem: There is a grid with H horizontal rows and W vertical columns, and there are obstacles on some of the squares.  Snuke is going to choose one of the squares not occupied by an obstacle and place a lamp on it. The lamp placed on the square will emit straight beams of light in four cardinal directions: up, down, left, and right. In each direction, the beam will continue traveling until it hits a square occupied by an obstacle or it hits the border of the grid. It will light all the squares on the way, including the square on which the lamp is placed, but not the square occupied by an obstacle.  Snuke wants to maximize the number of squares lighted by the lamp.  You are given H strings S_i (1 \leq i \leq H), each of length W. If the j-th character (1 \leq j \leq W) of S_i is `#`, there is an obstacle on the square at the i-th row from the top and the j-th column from the left; if that character is `.`, there is no obstacle on that square.  Find the maximum possible number of squares lighted by the lamp.

Submission attempts (in order):
H, W = map(int, input().split())
grid = [input() for i in range(H)]
count = [[[0, 0] for j in range(W)] for i in range(H)]
for i in range(H):
    row = '#' + grid[i] + '#'
    left = 0
    while True:
        right = row.find('
        if right == -1:
            break
        for j in range(left, right-1):
            count[i][j][0] = right - left - 1
        left = right
columns = list(zip(*grid))
for j in range(W):
    column = '#' + ''.join(columns[j]) + '#'
    left = 0
    while True:
        right = column.find('
        if right == -1:
            break
        for i in range(left, right-1):
            count[i][j][1] = right - left - 1
        left = right
print(max(sum(count[i][j]) for i in range(H) for j in range(W)) - 1)


import numpy as np

H, W = map(int, input().split())
grid = np.array([list(input()) for i in range(H)]) == '.'
L = np.zeros((H, W), dtype=int)
R = np.zeros((H, W), dtype=int)
U = np.zeros((H, W), dtype=int)
D = np.zeros((H, W), dtype=int)
for i in range(1, H):
    U[i] = (U[i-1] + 1) * grid[i-1]
for i in reversed(range(H-1)):
    D[i] = (D[i+1] + 1) * grid[i+1]
for i in range(1, W):
    L[:, i] = (L[:, i-1] + 1) * grid[:, i-1]
for i in reversed(range(W-1)):
    R[:, i] = (R[:, i+1] + 1) * grid[:, i+1]
print(((U + D + L + R) * grid).max() + 1)


Verdicts: Time Limit Exceeded

Accepted
Problem: There is a grid with H horizontal rows and W vertical columns, and there are obstacles on some of the squares.  Snuke is going to choose one of the squares not occupied by an obstacle and place a lamp on it. The lamp placed on the square will emit straight beams of light in four cardinal directions: up, down, left, and right. In each direction, the beam will continue traveling until it hits a square occupied by an obstacle or it hits the border of the grid. It will light all the squares on the way, including the square on which the lamp is placed, but not the square occupied by an obstacle.  Snuke wants to maximize the number of squares lighted by the lamp.  You are given H strings S_i (1 \leq i \leq H), each of length W. If the j-th character (1 \leq j \leq W) of S_i is `#`, there is an obstacle on the square at the i-th row from the top and the j-th column from the left; if that character is `.`, there is no obstacle on that square.  Find the maximum possible number of squares lighted by the lamp.

Submission attempts (in order):
import sys
input = sys.stdin.readline
import numpy as np

H, W = map(int, input().split())
S = np.array([list(input()) for _ in range(H)]) == '.'
ups = np.zeros((H,W), dtype=int)
downs = np.zeros((H,W), dtype=int)
lefts = np.zeros((H,W), dtype=int)
rights = np.zeros((H,W), dtype=int)

for h in range(H):
    ups[h] = (ups[h-1] + 1) * S[h-1]
    downs[H-h-1] = (downs[H-h-1] + 1) * S[H-h-1]
for w in range(W):
    lefts[:, w] = (lefts[:, w-1] + 1) * S[w-1]
    rights[:, W-w-1] = (rights[:, W-w-1] + 1) * S[W-w-1]
print(np.amax((ups+downs+lefts+rights)*S)+1)


import sys
input = sys.stdin.readline
import numpy as np

H, W = map(int, input().split())
S = np.array([list(input().rstrip()) for _ in range(H)]) == '.'
ups = np.zeros((H,W), dtype=int)
downs = np.zeros((H,W), dtype=int)
lefts = np.zeros((H,W), dtype=int)
rights = np.zeros((H,W), dtype=int)

for h in range(1, H):
    ups[h] = (ups[h-1] + 1) * S[h-1]
    downs[H-h-1] = (downs[H-h] + 1) * S[H-h]
for w in range(1, W):
    lefts[:, w] = (lefts[:, w-1] + 1) * S[:, w-1]
    rights[:, W-w-1] = (rights[:, W-w] + 1) * S[:, W-w]
print(np.amax((ups+downs+lefts+rights)*S)+1)


Verdicts: Runtime Error

Accepted
Problem: There is a grid with H horizontal rows and W vertical columns, and there are obstacles on some of the squares.  Snuke is going to choose one of the squares not occupied by an obstacle and place a lamp on it. The lamp placed on the square will emit straight beams of light in four cardinal directions: up, down, left, and right. In each direction, the beam will continue traveling until it hits a square occupied by an obstacle or it hits the border of the grid. It will light all the squares on the way, including the square on which the lamp is placed, but not the square occupied by an obstacle.  Snuke wants to maximize the number of squares lighted by the lamp.  You are given H strings S_i (1 \leq i \leq H), each of length W. If the j-th character (1 \leq j \leq W) of S_i is `#`, there is an obstacle on the square at the i-th row from the top and the j-th column from the left; if that character is `.`, there is no obstacle on that square.  Find the maximum possible number of squares lighted by the lamp.

Submission attempts (in order):
import numpy as np

H, W = map(int, input().split())
S = np.array([list(input() for _ in range(H))]) == '.'

D = np.zeros((H, W), dtype=int)
U = np.zeros((H, W), dtype=int)
L = np.zeros((H, W), dtype=int)
R = np.zeros((H, W), dtype=int)

for h in range(H):
    U[h] = (U[h - 1] + 1) * S[h]
    D[-h - 1] = (D[-h] + 1) * S[-h - 1]
for w in range(W):
    L[:, w] = (L[:, w - 1] + 1) * S[:, w]
    R[:, -w - 1] = (R[:, -w] + 1) * S[: -w - 1]#print(L)
print(np.max(U + D + L + R) - 3)

import numpy as np

H, W = map(int, input().split())
S = np.array([list(input()) for _ in range(H)]) == '.'

D = np.zeros((H, W), dtype=int)
U = np.zeros((H, W), dtype=int)
L = np.zeros((H, W), dtype=int)
R = np.zeros((H, W), dtype=int)

for h in range(H):
    U[h] = (U[h - 1] + 1) * S[h]
    D[-h - 1] = (D[-h] + 1) * S[-h - 1]
for w in range(W):
    L[:, w] = (L[:, w - 1] + 1) * S[:, w]
    R[:, -w - 1] = (R[:, -w] + 1) * S[:, -w - 1]
print(np.max(U + D + L + R) - 3)

Verdicts: Runtime Error

Accepted
Problem: There is a grid with H horizontal rows and W vertical columns, and there are obstacles on some of the squares.  Snuke is going to choose one of the squares not occupied by an obstacle and place a lamp on it. The lamp placed on the square will emit straight beams of light in four cardinal directions: up, down, left, and right. In each direction, the beam will continue traveling until it hits a square occupied by an obstacle or it hits the border of the grid. It will light all the squares on the way, including the square on which the lamp is placed, but not the square occupied by an obstacle.  Snuke wants to maximize the number of squares lighted by the lamp.  You are given H strings S_i (1 \leq i \leq H), each of length W. If the j-th character (1 \leq j \leq W) of S_i is `#`, there is an obstacle on the square at the i-th row from the top and the j-th column from the left; if that character is `.`, there is no obstacle on that square.  Find the maximum possible number of squares lighted by the lamp.

Submission attempts (in order):
# solution

import numpy as np
n,m = map(int,input().split())
ar = np.array([list(input()) for _ in range(h)]) == '.'
l = np.zeros((n,m),dtype=int)
r = np.zeros((n,m),dtype=int)
u = np.zeros((n,m),dtype=int)
d = np.zeros((n,m),dtype=int)

for i in range(n):
  u[i] = (u[i-1]+1)*ar[i]
  d[-i-1] = (d[-i]+1)*ar[-i-1]
  
for j in range(m):
  l[:,j] = (l[:,j-1]+1)*ar[:,j]
  r[:,-j-1] = (r[:,-j]+1)*ar[:,-j-1]
print(np.max(u+d+l+r)-3)

import numpy as np
h,w = map(int,input().split())
ar = np.array([list(input()) for _ in range(h)]) == '.'
#print(ar)
l = np.zeros((h,w),dtype=int)
r = np.zeros((h,w),dtype=int)
u = np.zeros((h,w),dtype=int)
d = np.zeros((h,w),dtype=int)

for i in range(h):
  u[i] = (u[i-1]+1)*ar[i]
  #print(u)
  d[-i-1] = (d[-i]+1)*ar[-i-1]
  #print(d)
  
for j in range(w):
  l[:,j] = (l[:,j-1]+1)*ar[:,j]
  #print(l)
  r[:,-j-1] = (r[:,-j]+1)*ar[:,-j-1]
  #print(r)
print(np.max(u+d+l+r)-3)

Verdicts: Runtime Error

Accepted
Problem: There is a grid with H horizontal rows and W vertical columns, and there are obstacles on some of the squares.  Snuke is going to choose one of the squares not occupied by an obstacle and place a lamp on it. The lamp placed on the square will emit straight beams of light in four cardinal directions: up, down, left, and right. In each direction, the beam will continue traveling until it hits a square occupied by an obstacle or it hits the border of the grid. It will light all the squares on the way, including the square on which the lamp is placed, but not the square occupied by an obstacle.  Snuke wants to maximize the number of squares lighted by the lamp.  You are given H strings S_i (1 \leq i \leq H), each of length W. If the j-th character (1 \leq j \leq W) of S_i is `#`, there is an obstacle on the square at the i-th row from the top and the j-th column from the left; if that character is `.`, there is no obstacle on that square.  Find the maximum possible number of squares lighted by the lamp.

Submission attempts (in order):
import numpy as np
import sys

H, W = list(map(int, sys.stdin.readline().split()))
S = np.array([list(sys.stdin.readline().rstrip()) for _ in range(H)]) == '.'
ups = np.zeros((H, W), dtype=int)
downs = np.zeros((H, W), dtype=int)
rights = np.zeros((H, W), dtype=int)
lefts = np.zeros((H, W), dtype=int)

for h in range(1, H):
    ups[h] = (ups[h - 1] + 1) * S[h - 1]
    downs[H - h] = (downs[H - h + 1] + 1) * S[H - h + 1]
for w in range(1, W):
    lefts[:, w] = (lefts[:, w - 1] + 1) * S[:, w - 1]
    rights[:, W - w] = (rights[:, W - w + 1] + 1) * S[:, W - w + 1]
print(((ups + downs + lefts + rights) * S).max() + 1)


import numpy as np
import sys

H, W = list(map(int, sys.stdin.readline().split()))
S = np.array([list(sys.stdin.readline().rstrip()) for _ in range(H)]) == '.'
uds = np.zeros((H, W), dtype=int)
lrs = np.zeros((H, W), dtype=int)

for h in range(1, H):
    uds[h] = (uds[h - 1] + 1) * S[h - 1]
    uds[H - h - 1] = (uds[H - h] + 1) * S[H - h]
for w in range(1, W):
    lrs[:, w] = (lrs[:, w - 1] + 1) * S[:, w - 1]
    lrs[:, W - w - 1] = (lrs[:, W - w] + 1) * S[:, W - w]
print(((uds + lrs) * S).max() + 1)


import numpy as np
import sys

H, W = list(map(int, sys.stdin.readline().split()))
S = np.array([list(sys.stdin.readline().rstrip()) for _ in range(H)]) == '.'
ups = np.zeros((H, W), dtype=int)
downs = np.zeros((H, W), dtype=int)
rights = np.zeros((H, W), dtype=int)
lefts = np.zeros((H, W), dtype=int)

for h in range(1, H):
    ups[h] = (ups[h - 1] + 1) * S[h - 1]
    downs[H - h - 1] = (downs[H - h] + 1) * S[H - h]
for w in range(1, W):
    lefts[:, w] = (lefts[:, w - 1] + 1) * S[:, w - 1]
    rights[:, W - w - 1] = (rights[:, W - w] + 1) * S[:, W - w]
print(((ups + downs + lefts + rights) * S).max() + 1)


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: There is a grid with H horizontal rows and W vertical columns, and there are obstacles on some of the squares.  Snuke is going to choose one of the squares not occupied by an obstacle and place a lamp on it. The lamp placed on the square will emit straight beams of light in four cardinal directions: up, down, left, and right. In each direction, the beam will continue traveling until it hits a square occupied by an obstacle or it hits the border of the grid. It will light all the squares on the way, including the square on which the lamp is placed, but not the square occupied by an obstacle.  Snuke wants to maximize the number of squares lighted by the lamp.  You are given H strings S_i (1 \leq i \leq H), each of length W. If the j-th character (1 \leq j \leq W) of S_i is `#`, there is an obstacle on the square at the i-th row from the top and the j-th column from the left; if that character is `.`, there is no obstacle on that square.  Find the maximum possible number of squares lighted by the lamp.

Submission attempts (in order):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

H,W = map(int, readline().split())
grid = np.frombuffer(read(), 'S1').reshape(H,-1)[:,:W]

print(grid)


X,Y = np.where(grid == b'#')

A = np.ones((H,W), np.int32)
B = np.ones((H,W), np.int32)

A[X,Y] = 0
B[X,Y] = 0

for w in range(W-1):
	A[:,w+1] += A[:,w] * (A[:,w+1] != 0)
for w in range(W-2,-1,-1):
	A[:,w] = np.maximum(A[:,w], A[:,w+1]) * (A[:,w] != 0)


for h in range(H-1):
	B[h+1,:] += B[h,:] * (B[h+1,:] != 0)
for h in range(H-2,-1,-1):
	B[h,:] = np.maximum(B[h,:], B[h+1,:]) * (B[h,:] != 0)

C = A+B

print(np.max(C)-1)


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

import numpy as np

H,W = map(int, readline().split())
grid = np.frombuffer(read(), 'S1').reshape(H,-1)[:,:W]

X,Y = np.where(grid == b'#')

A = np.ones((H,W), np.int32)
B = np.ones((H,W), np.int32)

A[X,Y] = 0
B[X,Y] = 0

for w in range(W-1):
	A[:,w+1] += A[:,w] * (A[:,w+1] != 0)
for w in range(W-2,-1,-1):
	A[:,w] = np.maximum(A[:,w], A[:,w+1]) * (A[:,w] != 0)


for h in range(H-1):
	B[h+1,:] += B[h,:] * (B[h+1,:] != 0)
for h in range(H-2,-1,-1):
	B[h,:] = np.maximum(B[h,:], B[h+1,:]) * (B[h,:] != 0)

C = A+B

print(np.max(C)-1)


Verdicts: Wrong Answer

Accepted
Problem: There is a grid with H horizontal rows and W vertical columns, and there are obstacles on some of the squares.  Snuke is going to choose one of the squares not occupied by an obstacle and place a lamp on it. The lamp placed on the square will emit straight beams of light in four cardinal directions: up, down, left, and right. In each direction, the beam will continue traveling until it hits a square occupied by an obstacle or it hits the border of the grid. It will light all the squares on the way, including the square on which the lamp is placed, but not the square occupied by an obstacle.  Snuke wants to maximize the number of squares lighted by the lamp.  You are given H strings S_i (1 \leq i \leq H), each of length W. If the j-th character (1 \leq j \leq W) of S_i is `#`, there is an obstacle on the square at the i-th row from the top and the j-th column from the left; if that character is `.`, there is no obstacle on that square.  Find the maximum possible number of squares lighted by the lamp.

Submission attempts (in order):
import numpy as np
 
def convert(L):
    dp = np.zeros((L.shape[0],L.shape[1]), dtype='int')
    for i in range(L.shape[0]):
        l=L[i]
        for j in range(L.shape[1]):
            if l[j]:
                if j == 0:
                    dp[i][j] = 1
                else:
                    dp[i][j] = dp[i][j-1] + 1
            else:
                dp[i][j] = 0
    return dp
H,W=map(int,input().split())
L= np.zeros((H,W),dtype='bool')
for i in range(H):
    L[i]=list(map(lambda x: False if x=="#" else True,list(input()) ))
 
ans = convert(L) #+ np.fliplr(convert(np.fliplr(L))) + convert(L.T).T + np.flipud(convert(np.flipud(L).T).T) - 3
print(np.max(ans))

import numpy as np

H,W = map(int,input().split())
temp = np.array([list(input()) for _ in range(H)])

map = np.zeros((H+2,W+2),dtype=np.int32)
map[1:-1,1:-1][temp == '.'] = 1


def F():
  x = map.copy()
  for row in range(1,H+1):
    zero_idx = np.nonzero(x[row]==0)[0]
    x[row, zero_idx[1:]] = 1-np.diff(zero_idx) 
  x = x.cumsum(axis = 1)
  return x


def G():
  x = map.T.copy()
  for row in range(1,W+1):
    zero_idx = np.nonzero(x[row]==0)[0]
    x[row, zero_idx[1:]] = 1-np.diff(zero_idx) 
  x = x.cumsum(axis = 1)
  return x.T

answer = np.zeros_like(map)

answer += F()

map = map[:,::-1]
answer += F()[:,::-1]
map = map[:,::-1]


answer += G()

map = map[::-1,:]
answer += G()[::-1,:]

answer = np.max(answer) - 3
print(answer)

Verdicts: Wrong Answer

Accepted