Problem p02742 (python)

Fixed submission:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
from fractions import gcd
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    # # 到達していないところはFalseにしとこう
    # h,w = readInts()
    # Field = [[0] * w for _ in range(h)]
    # d = deque()
    # # 最初左上にいるらしい
    # # 移動方向 diagonaaaaaaal!
    # dx = [-1,-1,1,1]
    # dy = [-1,1,-1,1]
    # # dfsしたい
    # d.append([0,0]) # 初期値を入れる
    # cnt = 0
    # while d:
    #     x,y = d.pop()
    #     Field[y][x] = 1
    #     #cnt += 1
    #     for i in range(4):
    #         nx = x + dx[i]
    #         ny = y + dy[i]
    #         if nx < 0 or w <= nx or ny < 0 or h <= ny:
    #             continue
    #         if Field[ny][nx] == 0:
    #             continue
    #         # 探索済みならいかない
    #         d.append([nx,ny])
    # for x in range(w):
    #     for y in range(h):
    #         if Field[y][x] == 1:
    #             cnt += 1
    # print(cnt)
    h,w = readInts()
    mul = h * w # multiplication
    if h == 1 or w == 1:
        print(1)
    elif mul % 2 == 0:
        print(mul // 2)
    else:
        print((mul+1)//2)
if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
from fractions import gcd
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    # 到達していないところはFalseにしとこう
    h,w = readInts()
    Field = [[0] * w for _ in range(h)]
    d = deque()
    # 最初左上にいるらしい
    # 移動方向 diagonaaaaaaal!
    dx = [-1,-1,1,1]
    dy = [-1,1,-1,1]
    # dfsしたい
    d.append([0,0]) # 初期値を入れる
    cnt = 0
    while d:
        x,y = d.pop()
        Field[y][x] = 1
        #cnt += 1
        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]
            if nx < 0 or w <= nx or ny < 0 or h <= ny:
                continue
            if Field[ny][nx] == 0:
                continue
            # 探索済みならいかない
            d.append([nx,ny])
    for x in range(w):
        for y in range(h):
            if Field[y][x] == 1:
                cnt += 1
    print(cnt)
if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
from fractions import gcd
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    # 到達していないところはFalseにしとこう
    h,w = readInts()
    Field = [[0] * w for _ in range(h)]
    d = deque()
    # 最初左上にいるらしい
    # 移動方向 diagonaaaaaaal!
    dx = [-1,-1,1,1]
    dy = [-1,1,-1,1]
    # dfsしたい
    d.append([0,0]) # 初期値を入れる
    cnt = 0
    while d:
        x,y = d.pop()
        Field[y][x] = 1
        #cnt += 1
        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]
            if nx < 0 or w <= nx or ny < 0 or h <= ny:
                continue
            if Field[ny][nx] == 0:
                continue
            # 探索済みならいかない
            d.append([nx,ny])
    for x in range(w):
        for y in range(h):
            if Field[y][x] == 1:
                cnt += 1
    print(cnt)
if __name__ == '__main__':
  main()