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

Fixed submission:
a,b=[i for i in input().split()]
if a < b:
    print("<")
elif a > b:
    print(">")
else:
    print("=")

Buggy submission (verdict: Runtime Error):
a,b=[int(i) for i in input().split()]
if a < b:
    print("<")
if a > b:
    print(">")
else:
    print("=")
Problem p03573 (python)

Fixed submission:
A = [int(i) for i in input().split()]
A.sort()
mid = A[1]
s = [i for i in A if i != mid]
print(s[0])

Buggy submission (verdict: Runtime Error):
A = [int(i) for i in input().split()
A.sort()
mid = A[1]
s = [i for i in A if i != mid]
print(s[0])
Problem p03761 (python)

Fixed submission:
N = int(input())
SS = []
for _ in range(N):
    SS.append(sorted(input()))
common = SS[0]
for s in SS:
    sc = s[:]
    z = []
    for c in common:
        if c in sc:
            sc.remove(c)
            z.append(c)
    common = z
print(''.join(common))

Buggy submission (verdict: Runtime Error):
N = int(input())
SS = []
for _ in range(N):
    SS.append(sorted(input()))
common = SS[0]
for s in SS:
    sc = s.copy()
    z = []
    for c in common:
        if c in sc:
            sc.remove(c)
            z.append(c)
    common = z
print(''.join(common))
Problem p02983 (python)

Fixed submission:
a = input().split()
a = [int(i) for i in a]
a = sorted(a)
if a[0] + 2019 <= a[1]:
    print(0)
else:
    b_1 = [i for i in range(a[0], a[1] + 1)]
    c = [i % 2019 for i in b_1]
    c = sorted(c)
    epoc = 2019
    for i in range(len(c)):
        for u in range(i):
            epoc1 = (c[i] * c[u]) % 2019
            if epoc1 < epoc:
                epoc = epoc1

    print(epoc)

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

a[0] = a[0] % 2019
a[1] = a[1] % 2019
yojyou_list=[]
if a[0] > a[1]:
    for i in range(a[0]-a[1]):
        yojyou_list.append((a[1] + i) % 2019)
else:
    for i in range(a[1] - a[0]):
        yojyou_list.append((a[0] + i) % 2019)


yojyou_list=sorted(yojyou_list)


print(yojyou_list[0] * yojyou_list[1])

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

a[0] = a[0] % 2019
a[1] = a[1] % 2019
yojyou_list=[]
if a[0] > a[1]:
    for i in range(a[0]-a[1]):
        yojyou_list.append((a[1] + i) % 2019)
else:
    for i in range(a[1] - a[0]):
        yojyou_list.append((a[0] + i) % 2019)


yojyou_list = list(set(yojyou_list))
yojyou_list=sorted(yojyou_list)

    
print((yojyou_list[0] * yojyou_list[1]) % 2019)
Problem p03262 (python)

Fixed submission:
import fractions as math
import sys
N, X = map(int, input().split())

dis_list = [abs(int(i) - X) for i in input().split()]
if len(dis_list) < 2:
    print(dis_list[0])
    sys.exit()


first_gc = math.gcd(dis_list[0], dis_list[1])

for i in range(len(dis_list)):
    first_gc = math.gcd(first_gc, dis_list[i])

print(first_gc)

Buggy submission (verdict: Runtime Error):
import math
import sys
N, X = map(int, input().split())

dis_list = [abs(int(i) - X) for i in input().split()]
if len(dis_list) < 2:
    print(dis_list[0])
    sys.exit()


first_gc = math.gcd(dis_list[0], dis_list[1])

for i in range(len(dis_list)):
    first_gc = math.gcd(first_gc, dis_list[i])

print(first_gc)
Problem p03061 (python)

Fixed submission:
def gcd_(a,b):
    if a<b:    a,b=b,a
    if b==0:    return a
    return gcd_(b,a%b)
  
def gcd(l):
    ans=l[0]
    for i in l:
        ans=gcd_(ans,i)
    return ans


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

gcd_list=[A[0]]
rev_gcd_list=[A[-1]]

for i in range(1,N):
    gcd_list.append(gcd([gcd_list[-1],A[i]]))
    rev_gcd_list.append(gcd([rev_gcd_list[-1],A[-i-1]]))
rev_gcd_list=rev_gcd_list[::-1]

ans=max(gcd_list[N-2],rev_gcd_list[1])
for i in range(1,N-1):
    ans=max(ans,gcd([gcd_list[i-1],rev_gcd_list[i+1]]))
print(ans)

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

gcd_list=[A[0]]
rev_gcd_list=[A[-1]]

for i in range(1,N):
    gcd_list.append(gcd([gcd_list[-1],A[i]]))
    rev_gcd_list.append(gcd([rev_gcd_list[-1],A[-i-1]]))
rev_gcd_list=rev_gcd_list[::-1]

ans=max(gcd_list[N-2],rev_gcd_list[1])
for i in range(1,N-1):
    ans=max(ans,gcd([gcd_list[i-1],rev_gcd_list[i+1]]))
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(N):
    ans=max(ans,gcd(a[:i]+a[i+1:]))
print(ans)
Problem p03238 (python)

Fixed submission:
i=int(input())

if(i==1):
    print("Hello World")
else:
    A=int(input())
    B=int(input())
    print(A+B)

Buggy submission (verdict: Runtime Error):
def cal(X,Y,H):

    for i in range(0,101): #C_x
        for j in range(0,101): #C_y
            temp=H[0]+abs(X[0]-i)+abs(Y[0]-j)
            for l in range(1,N):
                if(H[l]!=0):
                    s=H[l]+abs(X[l]-i)+abs(Y[l]-j)
                    if(temp==s):
                        temp=s
                    else:
                        break
                else:
                    if(temp-abs(X[l]-i)-abs(Y[l]-j)>0):
                        break
            else:    
                return print("{} {} {}".format(i,j,temp))

N=int(input())
X=[]
Y=[]
H=[]
for i in range(N):
    x,y,h=list(map(int,input().split()))
    X.append(x)
    Y.append(y)
    H.append(h)
cal(X,Y,H)
Problem p03240 (python)

Fixed submission:
import sys

x=[]
y=[]
h=[]
n=int(input())
for i in range(n):
    a,b,c=list(map(int,input().split()))
    x.append(a)
    y.append(b)
    h.append(c)

for cx in range(101):
    for cy in range(101):
        for i in range(n):
            if(h[i]==0):
                continue
            else:
                H=h[i]+abs(cx-x[i])+abs(cy-y[i])
                break
        for i in range(n):
            if(h[i]!=max(H-abs(cx-x[i])-abs(cy-y[i]),0)):
                    break
        else:
            print("{} {} {}".format(cx,cy,H))
            sys.exit(0)

Buggy submission (verdict: Runtime Error):
def cal(X,Y,H):

    zerolist=[]
    for i in range(0,101): #C_x
        for j in range(0,101): #C_y
            temp=H[0]+abs(X[0]-i)+abs(Y[0]-j)
            for l in range(1,N):
                if(H[l]<0):
                    zerolist.append(l)
                else:
                    s=H[l]+abs(X[l]-i)+abs(Y[l]-j)
                    if(temp==s):
                        temp=s
                    else:
                        break
            else:
                for k in zerolist:
                    if(temp-abs(X[k]-i)-abs(Y[k]-j)>0):
                        break
                else:
                    return print("{} {} {}".format(i,j,temp))

cal(X,Y,H)
Problem p03244 (python)

Fixed submission:
import numpy as np
N=int(input())
s=np.array(list(map(int,input().split())))

d_even=np.zeros(np.max(s)+1)
d_odd=np.zeros(np.max(s)+1)

for i in range(N//2):
    d_even[s[2*i]]+=1
    d_odd[s[2*i+1]]+=1
    
se=np.argsort(d_even)[::-1]
so=np.argsort(d_odd)[::-1]

e1=se[0]
e2=se[1]
o1=so[0]
o2=so[1]

if e1!=o1:
    ans=N-d_even[e1]-d_odd[o1]
else:
    ans=min(N-d_even[e1]-d_odd[o2],N-d_even[e2]-d_odd[o1])     
        
print(int(ans))

Buggy submission (verdict: Runtime Error):
import numpy as np
N=int(input())
s=np.array(list(map(int,input().split())))

d_even=np.zeros(10)
d_odd=np.zeros(10)

for i in range(N//2):
    d_even[s[2*i]]+=1
    d_odd[s[2*i+1]]+=1
    
se=np.argsort(d_even)[::-1]
so=np.argsort(d_odd)[::-1]

e1=se[0]
e2=se[1]
o1=so[0]
o2=so[1]

if e1!=o1:
    ans=N-d_even[e1]-d_odd[o1]
else:
    ans=min(N-d_even[e1]-d_odd[o2],N-d_even[e2]-d_odd[o1])     
        
print(int(ans))
Problem p03251 (python)

Fixed submission:
N,M,X,Y=list(map(int,input().split()))
x=list(map(int,input().split()))
y=list(map(int,input().split()))

a=max(x)+1
b=min(y)

def judge(a,b):
    if(a>b):
        return print("War")
    else:
        z=range(a,b+1)
        for i in z:
            if(i>X and i<=Y):
                return print("No War")
        else:
            return print("War")
        
judge(a,b)

Buggy submission (verdict: Runtime Error):
N,M,X,Y=list(map(int,input().split()))
x=list(map(int,input().split()))
y=list(map(int,input().split()))

a=x_max+1
b=y_min

def judge(a,b):
    if(a>b):
        return print("No War")
    else:
        z=range(a,b+1)
        for i in z:
            if(i>X and i<=Y):
                return print("No War")
        else:
            return print("War")
        
judge(a,b)
Problem p03282 (python)

Fixed submission:
S=input()
K=int(input())
f=0
if(K<=len(S)):
    for s in S[:K]:
        if s!="1":
            break
    else:
        print("1")
        f=1
if f==0:      
    for s in S:
        if(s!="1"):
            print(s)
            break

Buggy submission (verdict: Runtime Error):
S=input()
K=int(input())
if K<=len(S):
    for s in S[:K]:
        if s!="1":
            break
    else:
        print("1")
else:
	for s in S:
    	if s!="1" :
        	print(s)
        	break
Problem p03061 (python)

Fixed submission:
import fractions
from functools import reduce

n = int(input())

a = list(map(int,input().split()))
#
# a = [4,8,12,9,16]


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


gcd_l = [a[0]]
gcd_r = [a[-1]]
for i in range(1,n):
    gcd_l.append(fractions.gcd(gcd_l[i-1],a[i]))
    gcd_r.append(fractions.gcd(gcd_r[i-1],a[-i-1]))

gcd_r.reverse()

ans = max(gcd_r[1],gcd_l[-2])
for i in range(1,n-1):
    gcd = fractions.gcd(gcd_l[i-1],gcd_r[i+1])
    ans = max(ans,gcd)

print(ans)

Buggy submission (verdict: Runtime Error):
import fractions
from functools import reduce

n = int(input())

# a = list(map(int,input().split()))

a = [4,8,12,9,16]


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


gcd_l = [a[0]]
gcd_r = [a[-1]]
for i in range(1,n):
    gcd_l.append(fractions.gcd(gcd_l[i-1],a[i]))
    gcd_r.append(fractions.gcd(gcd_r[i-1],a[-i-1]))

gcd_r.reverse()

ans = max(gcd_l[1],gcd_r[-2])
for i in range(1,n-1):
    gcd = fractions.gcd(gcd_l[i-1],gcd_r[i+1])
    ans = max(ans,gcd)

print(ans)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
from random import randint
import time

n = int(input())

a = list(map(int,input().split()))


def gcd_list(numbers):
    return reduce(math.gcd, numbers)


gcd_l = [0]
gcd_r = []
for i in range(1,n+1):
    a_l = a[:i-1]
    a_r = a[i:]
    if a_l:
        gcd_l.append(gcd_list(a_l))
    if a_r:
        gcd_r.append(gcd_list(a_r))
gcd_r = gcd_r + [0]

ans = 0
for i in range(n):
    if gcd_l[i] == 0:
        gcd = gcd_r[i]
    if gcd_r[i] == 0:
        gcd = gcd_l[i]
    else:
        gcd = math.gcd(gcd_l[i],gcd_r[i])
    ans = max(gcd,ans)

print(ans)
Problem p03074 (python)

Fixed submission:
n,k = [int(i) for i in input().split()]
s = input()

if s[0] == "1":
    retu = "whiteblack"
else:
    retu = "blackwhite"


count = 0
pre_person = s[0]
groups = []
for i in range(n):
    person = s[i]

    if person != pre_person:
        groups.append(count)
        count = 0
        pre_person = person
    count += 1
groups.append(count)


maxscore1 = 0
if retu == "whiteblack":
    score1 = 0
    blackgroups = len(groups)//2
    if k < blackgroups:
        start_index = 1
        score1 = groups[start_index-1]
        for j in range(k):
            score1 += groups[start_index+2*j]
            if start_index + 2*j+1 < len(groups):
                score1 += groups[start_index+2*j+1]
        maxscore1 = max(score1, maxscore1)
        for i in range(blackgroups - k):
            score1 -= groups[start_index + 2*i - 1]
            score1 -= groups[start_index + 2*i]
            score1 += groups[start_index + 2*k +2*i]
            if start_index+2*k+1+2*i < len(groups):
                score1 += groups[start_index + 2 * k +1 + 2 * i]
            maxscore1 = max(score1, maxscore1)
    else:
        maxscore1 = n

else:
    score1 = 0
    blackgroups = len(groups) - len(groups)//2
    if k < blackgroups:
        start_index = 0
        score1 = 0
        for j in range(k):
            score1 += groups[start_index+2*j]
            if start_index + 2*j+1 < len(groups):
                score1 += groups[start_index+2*j+1]

        maxscore1 = max(score1, maxscore1)
        for i in range(blackgroups - k):
            if i >=1:
                score1 -= groups[start_index + 2*i - 1]
            score1 -= groups[start_index + 2*i]
            score1 += groups[start_index + 2*k +2*i]
            if start_index+2*k+1+2*i < len(groups):
                score1 += groups[start_index + 2 * k + 1 + 2 * i]

            maxscore1 = max(score1, maxscore1)
    else:
        maxscore1 = n

print(maxscore1)

Buggy submission (verdict: Runtime Error):
    n,k=map(int, input().split())
    s=input()
    
    ruiwa = [0]

    for i in range(1,len(s)):
        if s[i] != s[i-1]:
            ruiwa.append(i)
    ruiwa.append(n)

    if s[0] == "1":
        ans = ruiwa[1]
        if ((len(ruiwa) - 1) // 2) <= k:
            ans = n
        else:
            for i in range(((len(ruiwa)-1)//2)-k+1):
                ans = max(ans,ruiwa[min(2*k+1+2*i,len(ruiwa)-1)] - ruiwa[2*i])
    else:
        ans = 0
        if len(ruiwa) - 1 - (len(ruiwa) - 1) // 2 <= k:
            ans = n
        else:
            for i in range(len(ruiwa) - 1 - (len(ruiwa)-1)//2 - k + 1):
                ans = max(ans, ruiwa[min(2*k+2*i, len(ruiwa)-1)] - ruiwa[max(0,2*i-1)])

    print(ans)
Problem p03262 (python)

Fixed submission:
import fractions

n,x = [int(i) for i in input().split()]

lis = list(map(int,input().split()))
diffs = []
for i in range(n):
    diff = abs(lis[i]-x)
    diffs.append(diff)


if len(diffs) > 1:
    com = fractions.gcd(diffs[0],diffs[1])
    for i in range(len(diffs)-2):
        com = fractions.gcd(com, diffs[i+2])
else:
    com = diffs[0]

print(com)

Buggy submission (verdict: Runtime Error):
import math

n,x = [int(i) for i in input().split()]

lis = list(map(int,input().split()))
diffs = []
for i in range(n):
    diff = abs(lis[i]-x)
    diffs.append(diff)


if len(diffs) > 1:
    com = math.gcd(diffs[0],diffs[1])
    for i in range(len(diffs)-2):
        com = math.gcd(com, diffs[i+2])
else:
    com = diffs[0]

print(com)

Buggy submission (verdict: Runtime Error):
import math

n,x = [int(i) for i in input().split()]

lis = list(map(int,input().split()))
diffs = []
for i in range(n):
    diff = abs(lis[i]-x)
    diffs.append(diff)


if len(diffs) > 1:
    com = math.gcd(diffs[0],diffs[1])
    for i in range(len(diffs)-2):
        com = math.gcd(com, diffs[i+2])
else:
    com = diffs[0]

print(com)

Buggy submission (verdict: Runtime Error):
import math

n,x = [int(i) for i in input().split()]

lis = list(map(int,input().split()))
diffs = []
for i in range(n):
    diff = abs(lis[i]-x)
    if diff != 0:
        diffs.append(diff)


if len(diffs) > 1:
    com = math.gcd(diffs[0],diffs[1])
    for i in range(len(diffs)-2):
        com = math.gcd(com, diffs[i+2])
else:
    com = diffs[0]

print(com)

Buggy submission (verdict: Runtime Error):
import math

n,x = [int(i) for i in input().split()]

lis = list(map(int,input().split()))
diffs = []
for i in range(n):
    diff = abs(lis[i]-x)
    if diff != 0:
        diffs.append(diff)


if len(diffs) > 1:
    com = math.gcd(diffs[0],diffs[1])
    for i in range(n-2):
        com = math.gcd(com, diffs[i+2])
else:
    com = diffs[0]

print(com)

Buggy submission (verdict: Runtime Error):
import math

n,x = [int(i) for i in input().split()]

lis = list(map(int,input().split()))
diffs = []
for i in range(n):
    diff = abs(lis[i]-x)
    if diff != 0:
        diffs.append(diff)


if n > 1:
    com = math.gcd(diffs[0],diffs[1])
    for i in range(n-2):
        com = math.gcd(com, diffs[i+2])
else:
    com = diffs[0]

print(com)

Buggy submission (verdict: Runtime Error):
import math

n,x = [int(i) for i in input().split()]

lis = list(map(int,input().split()))
diffs = []
for i in range(n):
    diff = abs(lis[i]-x)
    diffs.append(diff)

if n > 1:
    com = math.gcd(diffs[0],diffs[1])
    for i in range(n-2):
        com = math.gcd(com, diffs[i+2])
else:
    com = diffs[0]

print(com)
Problem p03399 (python)

Fixed submission:
a, b, c, d = [int(input()) for i in range(4)]

print(min(a, b) + min(c, d))

Buggy submission (verdict: Runtime Error):
a,b,c,d = [int(i) for i in input()]

print(min(a,b)+min(c,d))
Problem p03407 (python)

Fixed submission:
a,b,c = [int(i) for i in input().split()]
if a + b >= c:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a = int(input())
blue = []
count = []
for i in range(a):
    x = input()
    if x in blue:
        count[blue.index(x)] += 1
    else:
        blue.append(x)
        count.append(1)
b = int(input())
for i in range(b):
    x = input()
    if x in blue:
        count[blue.index(x)] -= 1
    else:
        blue.append(x)
        count.append(-1)

count.sort()
count.reverse()
if count[0] < 0:
    print("0")
else:
    print (count[0])
Problem p03408 (python)

Fixed submission:
a = int(input())
blue = []
count = []
for i in range(a):
    x = input()
    if x in blue:
        count[blue.index(x)] += 1
    else:
        blue.append(x)
        count.append(1)
b = int(input())
for i in range(b):
    x = input()
    if x in blue:
        count[blue.index(x)] -= 1
    else:
        blue.append(x)
        count.append(-1)

count.sort()
count.reverse()
if count[0] < 0:
    print("0")
else:
    print (count[0])

Buggy submission (verdict: Runtime Error):
a = int(input())
blue = []
count = []
for i in range(a)
    x = input()
    if x in blue:
        count[blue.index(x)] += 1
    else:
        blue.append(x)
        count.append(1)
b = int(input())
for i in range(b)
    x = input()
    if x in blue:
        count[blue.index(x)] -= 1
    else:
        blue.append(x)
        count.append(-1)

count.sorted()
if count[0] < 0:
    print("0")
else:
    print (count[0])

Buggy submission (verdict: Runtime Error):
a = int(input())
blue = []
count = []
for i in range(a)
    x = input()
    if x in blue:
        count[blue.index(x)] += 1
    else:
        blue.append(x)
        count.append(1)
b = int(input())
for i in range(b)
    x = input()
    if x in blue:
        count[blue.index(x)] -= 1
    else:
        blue.append(x)
        count.append(-1)

blue.sorted()
if blue[0] < 0:
    print("0")
else:
    print(blue[0])

Buggy submission (verdict: Runtime Error):
a = int(input())
blue = []
count = []
for i in range(a)
    x = input()
    if x in blue:
        count[blue.index(x)] += 1
    else:
        blue.append(x)
        count.append(1)
b = int(input())
for i in range(b)
    x = input()
    if x in blue:
        count[blue.index(x)] -= 1
    else:
        blue.append(x)
        count.append(-1)

blue.sorted()
if blue[0] < 0:
    print("0")
else:
    print (blue[0])
Problem p03447 (python)

Fixed submission:
x = int(input())
y = int(input())
z = int(input())

res = (x-y) % z

print(res)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = []
for i in range(2):
    A.append([int(i)for i in input().split()])
ans = 0
for i in range(N):
    ans += A[0][i]
ans += A[1][N-1]
max = ans
for i in range (N-1):
    ans = ans + A[1][i-2] - A[0][i-1]
    if ans > max:
        max = ans

print(max)
Problem p03555 (python)

Fixed submission:
a = input()
b = input()
alist = list(a)
blist = list(b)
ans = "YES"
for i in range(3):
    if alist[i] == blist[2-i]:
        continue
    else:
        ans =("NO")
print(ans)

Buggy submission (verdict: Runtime Error):
c1 = input().split()
c2 = input().split()
c=[]
a =‘YES’
for k in range(3):
    c.append([c1[k]]+[c2[k]])
for j in range(3):
    if c[0][j] = c[1][3-j-1]:
        continue
    else: 
        a=‘NO’
        break
print(a)
Problem p03573 (python)

Fixed submission:
rng1 = -100
rng2 = 101
#print(input().split())
inp = [int(i) for i in input().split()]
#print(inp)
x, y, z = [inp[i] for i in range(len(inp))]
#print("x={},y={},z={}".format(x,y,z))

def dif1(x, y ,z):
    if not isinstance(x, int) or not isinstance(y, int) or not isinstance(z, int):
        return False
    elif x not in range(rng1, rng2) or y not in range(rng1, rng2)or z not in range(rng1, rng2):
        return False
    else:
        if y == z:
            return x
        if z == x:
            return y
        if x == y:
            return z
Ans = dif1(x,y,z)
print(Ans)

Buggy submission (verdict: Runtime Error):
HM = input().split()
H, M = [int(HM[i]) for i in range(len(HM))]

S = [input() for i in range(H)]
print(S)
#print(T[0][1])
#S2 = list([S[i] for i in range(H)] for j in range(M))
S2 = []
for i in range(H):
    S2.append(list(S[i]))
print(S2)

def minesweeper():
    for i in range(H):
        for j in range(M):
            if S[i][j] == ".":
                c = count(i, j)
                #print(c)
                S2[i][j] = c
    for i in range(H):
        for j in range(M-1):
            print(S2[i][j], end="")
        print(S2[i][M-1])
    return 0


def count(x,y):
    c = 0
    #print("x={}".format(x))
    if (x >= 1 and y >= 1):
        if S[x-1][y-1] == '#':
            c += 1
            #print('1')
    if (x >= 1):
        if S[x-1][y] == "#":
            c += 1
            #print('2')
    if x >= 1 and y <= M - 2:
        if S[x-1][y+1] == "#":
            c += 1
            #print("x={}".format(x))
            #print('3')
    if (y >= 1):
        if S[x][y-1] == "#":
            c += 1
            #print('4')
    if (y <= M - 2):
        if S[x][y+1] == "#":
            c += 1
            #print('5')
    if (x <= H-2 and y >= 1):
        if S[x+1][y-1] == "#":
            c += 1
            #print('6')
    if (x <= H-2):
        if S[x+1][y] == "#":
            c += 1
            #print('7')
    if (x <= H-2 and y <= M-2):
        if S[x+1][y+1] == "#":
            c += 1
            #print('8')
    return c

minesweeper()