Problem p03014 (python)

Fixed submission:
inf = input().split()
H = int(inf[0])
W = int(inf[1])
sheet = [[] for i in range(H+2)]
score = [[] for i in range(H+2)]
m = 0
 
for h in range(H+2):
  if h==0 or h==H+1:
    a = [False]*(W+2)
    b = [(0,0)]*(W+2)
    sheet[h]=a
    score[h]=b
  else:
    line = input()
    a = []
    b = []
    a += [False]
    b += [(0,0)]
    for w in range(W):
      b+=[(0,0)]
      if line[w]=='.':
        a += [True]
      else:
        a += [False]
    a += [False]
    b += [(0,0)]
    sheet[h]=a
    score[h]=b
      
for h in range(1,H+1):
  for w in range(1,W+1):
    if sheet[h][w]:
      s = 0
      hs = 0
      ws = 0
      if sheet[h-1][w]:
        hs += score[h-1][w][0]
      else:
        i = h+1
        while sheet[i][w]:
          hs+=1
          i+=1
      if sheet[h][w-1]:
        ws += score[h][w-1][1]
      else:
        j = w+1
        while sheet[h][j]:
          ws+=1
          j+=1
      s = 1 + hs + ws
      score[h][w]=(hs, ws)
      if m < s:
        m = s
print(m)

Buggy submission (verdict: Runtime Error):
line = input().split()
N = int(line[0])
M = int(line[1])
broken = []
count = 0
step = []
def check(value):
  if count < M:
    return broken[count]==value
  else:
    return False

for i in range(M):
  a = int(input())
  broken += [a]
if check(1):
  step+=[0]
  count += 1
else:
  step +=[1]
if check(2):
  step += [0]
  count += 1
else:
  step += [1+step[0]]
for j in range(2, N):
  if check(j+1):
    step += [0]
    count += 1
  else:
    step += [step[j-2]+step[j-1]]
ans = step[N-1]%(10^9+7)
print(ans)

Buggy submission (verdict: Runtime Error):
inf = input().split()
H = int(inf[0])
W = int(inf[1])
sheet = [[] for i in range(H+2)]
score = [[] for i in range(H+2)]
m = 0
 
for h in range(H+2):
  if h==0 or h==H+1:
    a = [False]*(W+2)
    b = [(0,0)]*(W+2)
    sheet[h]=a
    score[h]=b
  else:
    line = input()
    a = []
    b = []
    a += [False]
    b += [(0,0)]
    for w in range(W):
      b+=[(0,0)]
      if line[w]=='.':
        a += [True]
      else:
        a += [False]
    a += [False]
    b += [(0,0)]
    sheet[h]=a
    sheet[w]=b
      
for h in range(1,H+1):
  for w in range(1,W+1):
    if sheet[h][w]:
      s = 0
      hs = 0
      ws = 0
      if sheet[h-1][w]:
        hs += score[h-1][w][0]
      else:
        i = h+1
        while sheet[i][w]:
          hs+=1
          i+=1
      if sheet[h][w-1]:
        ws += score[h][w-1][1]
      else:
        j = w+1
        while sheet[h][j]:
          ws+=1
          j+=1
      s = 1 + hs + ws
      score[h][w]=(hs, ws)
      if m < s:
        m = s
print(m)

Buggy submission (verdict: Runtime Error):
inf = input().split()
H = int(inf[0])
W = int(inf[1])
dic = {}
score = {}
m = 0

for h in range(H+2):
  if h==0 or h==H+1:
    for w in range(W+2):
      dic[(h,w)] = False
      score[(h,w)] = (0,0)
  else:
    line = input()
    dic[(h,0)] = False
    dic[(h,W+1)] = False
    score[(h,0)] = (0,0)
    score[(h, w+1)] = (0,0)
    for w in range(W):
      if line[w]=='.':
        dic[(h,w+1)] = True
      else:
        dic[(h,w+1)] = False
      
for h in range(1,H+1):
  for w in range(1,W+1):
    score[(h,w)]=(0,0)
    if dic[(h,w)]:
      s = 0
      hs = 0
      ws = 0
      if dic[(h-1,w)]:
        s += score[(h-1,w)][0]
        hs += score[(h-1,w)][0]
      else:
        i = h+1
        while dic[(i,w)]:
          score[(h,w)]+=1
          i+=1
      if dic[(h, w-1)]:
        s += score[(h, w-1)][1]
        ws += score[(h,w-1)][1]
      else:
        j = w+1
        while dic[(h,j)]:
          score[(h,w)]+=1
          j+=1
      if m < s:
        m = s
print(m)