Problem:
You are given an H × W grid.   The squares in the grid are described by H strings, S_1,...,S_H.   The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W).   `.` stands for an empty square, and `#` stands for a square containing a bomb.  Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square.   (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.)   He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square.  Print the strings after the process.

Incorrect submission (verdict: Wrong Answer):
h,w = map(int,input().split())
s = []

for i in range(h):
    a =list(input())
    s.append(a)

print(s)

for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            c = 0
            if  i-1 >= 0 and i-1 <= h-1 and j-1 >= 0 and j-1 <= w-1:
               if s[i-1][j-1] == '#':
                 c += 1
            if  i >= 0 and i <= h-1 and j-1 >= 0 and j-1 <= w-1:
                if s[i][j-1] == '#':
                     c += 1
            if   i+11 >= 0 and i+1 <= h-1 and j-1 >= 0 and j-1 <= w-1:
                if s[i+1][j-1] == '#':
                    
                    c += 1
            if i-1 >= 0 and i-1 <= h-1 and j >= 0 and j <= w-1:
                if s[i-1][j] == '#' :
                    c += 1
            if   i >= 0 and i <= h-1 and j >= 0 and j <= w-1:
                if s[i][j] == '#':
                    c += 1
            if  i+1 >= 0 and i+1 <= h-1 and j >= 0 and j <= w-1:
                if s[i+1][j] == '#':
                    c += 1
            if i-1 >= 0 and i-1 <= h-1 and j+1 >= 0 and j+1 <= w-1:
                if s[i-1][j+1] == '#' :
                    c += 1
            if   i >= 0 and i <= h-1 and j+1 >= 0 and j+1 <= w-1:
                if s[i][j+1] == '#':
                    c += 1
            if  i+1 >= 0 and i+1 <= h-1 and j+1 >= 0 and j+1 <= w-1:
                if s[i+1][j+1] == '#':
                    c += 1
            s[i][j] = str(c)

for i in range(h):
    k = ''
    for j in range(w):
       
        k += s[i][j]
    print(k)

Fixed, accepted submission:
h,w = map(int,input().split())
s = []

for i in range(h):
    a =list(input())
    s.append(a)

#print(s)

for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            c = 0
            if  i-1 >= 0 and i-1 <= h-1 and j-1 >= 0 and j-1 <= w-1:
               if s[i-1][j-1] == '#':
                 c += 1
            if  i >= 0 and i <= h-1 and j-1 >= 0 and j-1 <= w-1:
                if s[i][j-1] == '#':
                     c += 1
            if   i+11 >= 0 and i+1 <= h-1 and j-1 >= 0 and j-1 <= w-1:
                if s[i+1][j-1] == '#':
                    
                    c += 1
            if i-1 >= 0 and i-1 <= h-1 and j >= 0 and j <= w-1:
                if s[i-1][j] == '#' :
                    c += 1
            if   i >= 0 and i <= h-1 and j >= 0 and j <= w-1:
                if s[i][j] == '#':
                    c += 1
            if  i+1 >= 0 and i+1 <= h-1 and j >= 0 and j <= w-1:
                if s[i+1][j] == '#':
                    c += 1
            if i-1 >= 0 and i-1 <= h-1 and j+1 >= 0 and j+1 <= w-1:
                if s[i-1][j+1] == '#' :
                    c += 1
            if   i >= 0 and i <= h-1 and j+1 >= 0 and j+1 <= w-1:
                if s[i][j+1] == '#':
                    c += 1
            if  i+1 >= 0 and i+1 <= h-1 and j+1 >= 0 and j+1 <= w-1:
                if s[i+1][j+1] == '#':
                    c += 1
            s[i][j] = str(c)

for i in range(h):
    k = ''
    for j in range(w):
       
        k += s[i][j]
    print(k)