Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
lis = list(map(int,input().split()))
tmp = 0
for i,l in enumerate(lis):
    if i+k <= len(lis):
        if (sum(lis[i:i+k])+k)/2 > tmp:
            tmp = (sum(lis[i:i+k])+k)/2
#print(new_lis)
print(tmp)

Fixed submission:
n,k = map(int,input().split())
li = list(map(int,input().split()))
new_li = [0]
for l in li:
    new_li.append(new_li[-1]+(l+1)/2)
# print(new_li)
# [0, 1.0, 2.5, 4.0, 6.5, 9.5]
tmp_li = []
for i,n in enumerate(new_li):
    if i < k-1:
        continue
    tmp_li.append(new_li[i] - new_li[i-k])
    #print(i,i-k)
print(max(tmp_li))

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
lis = list(map(int,input().split()))
new_lis = []
for i,l in enumerate(lis):
    if i+k <= len(lis):
        new_lis.append((sum(lis[i:i+k])+k)/2)
#print(new_lis)
print(max(new_lis))

Fixed submission:
n,k = map(int,input().split())
li = list(map(int,input().split()))
new_li = [0]
for l in li:
    new_li.append(new_li[-1]+(l+1)/2)
# print(new_li)
# [0, 1.0, 2.5, 4.0, 6.5, 9.5]
tmp_li = []
for i,n in enumerate(new_li):
    if i < k-1:
        continue
    tmp_li.append(new_li[i] - new_li[i-k])
    #print(i,i-k)
print(max(tmp_li))

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
lis = list(map(int,input().split()))
new_lis = []
for i,l in enumerate(lis):
    if i+k <= len(lis):
        new_lis.append((sum(lis[i:i+k])+k)/2)
#print(new_lis)
print(max(new_lis))

Fixed submission:
n,k = map(int,input().split())
li = list(map(int,input().split()))
new_li = [0]
for l in li:
    new_li.append(new_li[-1]+(l+1)/2)
# print(new_li)
# [0, 1.0, 2.5, 4.0, 6.5, 9.5]
tmp_li = []
for i,n in enumerate(new_li):
    if i < k-1:
        continue
    tmp_li.append(new_li[i] - new_li[i-k])
    #print(i,i-k)
print(max(tmp_li))

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
lis = list(map(int,input().split()))
new_lis = [(l+1)/2 for l in lis]
ans = 0
for i in range(n-k+1):
    if sum(new_lis[i:i+k]) > ans:
        #print(new_lis[i:i+k])
        ans = sum(new_lis[i:i+k])
print(ans)

Fixed submission:
n,k = map(int,input().split())
li = list(map(int,input().split()))
new_li = [0]
for l in li:
    new_li.append(new_li[-1]+(l+1)/2)
# print(new_li)
# [0, 1.0, 2.5, 4.0, 6.5, 9.5]
tmp_li = []
for i,n in enumerate(new_li):
    if i < k-1:
        continue
    tmp_li.append(new_li[i] - new_li[i-k])
    #print(i,i-k)
print(max(tmp_li))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
n = int(input())
lis = list(map(int,input().split()))
count = 0
for i,l in enumerate(lis):
    if i == 0:
        count += 1
    else:
        rs_lis = sorted(lis[0:i])
        if rs_lis[0] >= l:
            count += 1
print(count)

Fixed submission:
import sys
n = int(input())
lis = list(map(int,input().split()))
count = 0
mi = 0
for i,l in enumerate(lis):
    if i == 0:
        mi = l
        count += 1
    else:
        if l < mi:
            mi = l
        if mi >= l:
            count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lis = list(map(int,input().split()))
count = 0
for i,l in enumerate(lis):
    if i == 0:
        count += 1
    elif l <= min(sorted(lis[0:i])):
        count += 1
print(count)


Fixed submission:
import sys
n = int(input())
lis = list(map(int,input().split()))
count = 0
mi = 0
for i,l in enumerate(lis):
    if i == 0:
        mi = l
        count += 1
    else:
        if l < mi:
            mi = l
        if mi >= l:
            count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lis = list(map(int,input().split()))
count = 0
for i,l in enumerate(lis):
    if i == 0:
        count += 1
    elif l <= min(lis[0:i]):
        count += 1
print(count)

Fixed submission:
import sys
n = int(input())
lis = list(map(int,input().split()))
count = 0
mi = 0
for i,l in enumerate(lis):
    if i == 0:
        mi = l
        count += 1
    else:
        if l < mi:
            mi = l
        if mi >= l:
            count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
n = int(input())
lis = list(map(int, input().split()))
# print(li)
start_index = 0
has_found_number = 0
for i in range(1,n+1):
    if i in lis:
        lis = lis[lis.index(i):]
        has_found_number = i
        continue
    else:
        break
if has_found_number == 0:
    print(-1)
else:
    print(n-has_found_number)


Fixed submission:
n = int(input())
lis = list(map(int, input().split()))
search_target = 1
founded = 0
for li in lis:
    #search_target = 1
    if li == search_target:
        search_target += 1
        founded = li
        continue
    else:
        continue
if founded == 0:
    print(-1)
else:
    print(n-founded)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
n = int(input())
s = input()
se = set()
for i in range(0,n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            se.add(s[i]+s[j]+s[k])
print(len(se))

Fixed submission:
n = int(input())
s = input()
target = [str(i) for i in range(10)]
count = 0
for x in target:
    a = s.find(x)
    if a == -1:
        continue
    for y in target:
        b = s.find(y,a+1)
        if b == -1:
            continue
        for z in target:
            c = s.find(z,b+1)
            if c != -1:
                count +=1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
li = list(map(int,input().split()))
all_li = []
for i,l in enumerate(li):
    if i == 0:
        continue
    left = sum(li[:i])
    right = sum(li[i:])
    #print(i,left,right)
    all_li.append(abs(left-right))
print(min(all_li))

Fixed submission:
n = int(input())
li = list(map(int,input().split()))
s = sum(li)
sum_li = []
for i,l in enumerate(li):
    if i == 0:
        sum_li.append(l)
        continue
    sum_li.append(sum_li[-1]+l)
all_li = []
for ii,ss in enumerate(sum_li):
    if ii == len(sum_li)-1:
        break
    all_li.append(abs(s-2*ss))
#print(all_li)
print(min(all_li))
Buggy python submission (verdict: Runtime Error):
import math
a,b,x = map(int,input().split())
if x / a >= (a*b/2):
    print(math.degrees(math.atan((2*b/a)-2*x/(a**3))))
else:
    if a < b:
        print(math.degrees(math.atan(a*b*b/(2*x))))
    else:
        print(math.degrees(math.atan(2*x/(a*b*b))))


Fixed submission:
a,b = map(int, input().split())
if a <= 9 and b <= 9:
    print(a*b)
else:
    print('-1')
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
src = list(map(int, input().split()))
def waru(org_list):
    new = sorted(org_list, reverse=True)
    new[0] = new[0]//2
    return new
for _ in range(m):
    src = waru(src)
print(sum(src))

Fixed submission:
import heapq
import math
n, m = map(int, input().split())
src = list(map(int, input().split()))
new_src = []
for s in src:
    new_src.append(s*-1)
heapq.heapify(new_src)

def waru(heap):
    tmp = heapq.heappop(heap)
    heapq.heappush(heap, math.ceil(tmp / 2))
    return heap
for _ in range(m):
    new_src = waru(new_src)
print(sum(new_src)*-1)
Buggy python submission (verdict: Runtime Error):
from math import factorial
n = int(input())
src = [''.join(sorted(input())) for _ in range(n)]
dic = {}
for s in src:
    # 辞書にキーが存在しなければキー追加
    if s not in dic:
        dic[s] = 1
    else:
        dic[s] += 1
count = 0
# 辞書から値だけ取り出す
for d in dic.values():
    # dまでの値の組み合わせを合計する
    if d > 2:
        count += int(factorial(d) / factorial(2) / factorial(d - 2))
    elif d == 2:
        count += 1
print(count)

Fixed submission:
from math import factorial
n = int(input())
src = [''.join(sorted(input())) for _ in range(n)]
dic = {}
for s in src:
    # 辞書にキーが存在しなければキー追加
    if s not in dic:
        dic[s] = 1
    else:
        dic[s] += 1
count = 0
# 辞書から値だけ取り出す
for d in dic.values():
    # dまでの値の組み合わせを合計する
    if d > 2:
        count += factorial(d) // 2 // factorial(d - 2)
    elif d == 2:
        count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())
src = [''.join(sorted(input())) for _ in range(n)]
dic = {}
for s in src:
    # 辞書にキーが存在しなければキー追加
    if s not in dic:
        dic[s] = 0
    else:
        dic[s] += 1
count = 0
# 辞書から値だけ取り出す
for d in dic.values():
    count += len(list(itertools.combinations(range(d+1), 2)))
print(count)

Fixed submission:
from math import factorial
n = int(input())
src = [''.join(sorted(input())) for _ in range(n)]
dic = {}
for s in src:
    # 辞書にキーが存在しなければキー追加
    if s not in dic:
        dic[s] = 1
    else:
        dic[s] += 1
count = 0
# 辞書から値だけ取り出す
for d in dic.values():
    # dまでの値の組み合わせを合計する
    if d > 2:
        count += factorial(d) // 2 // factorial(d - 2)
    elif d == 2:
        count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import copy
n = int(input())
all_list = [int(input()) for _ in range(n)]
max_value = max(all_list)
for i in range(n):
    if all_list[i] == max_value:
        tmp = copy.copy(all_list)
        tmp.pop(i)
        print(max(tmp))
    else:
        print(max_value)

Fixed submission:
import copy
n = int(input())
all_list = [int(input()) for _ in range(n)]
max_value = max(all_list)
max_value_count = all_list.count(max_value)
for i in range(n):
    if all_list[i] == max_value:
        if max_value_count > 2:
            print(max_value)
        else:
            tmp = copy.copy(all_list)
            tmp.pop(i)
            print(max(tmp))
    else:
        print(max_value)

Buggy python submission (verdict: Time Limit Exceeded):
import copy

n = int(input())
all_list = [int(input()) for _ in range(n)]
for i in range(n):
    tmp = copy.copy(all_list)
    tmp.pop(i)
    print(max(tmp))

Fixed submission:
import copy
n = int(input())
all_list = [int(input()) for _ in range(n)]
max_value = max(all_list)
max_value_count = all_list.count(max_value)
for i in range(n):
    if all_list[i] == max_value:
        if max_value_count > 2:
            print(max_value)
        else:
            tmp = copy.copy(all_list)
            tmp.pop(i)
            print(max(tmp))
    else:
        print(max_value)
Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d = map(int,input().split())
lcm = c * d // math.gcd(c, d)
x = b//c - (a-1)//c
y = b//d - (a-1)//d
warikireru = x+y - (b//lcm - (a-1)//lcm)
print(b-a+1-warikireru)

Fixed submission:
import fractions
a,b,c,d = map(int,input().split())
lcm = c * d // fractions.gcd(c, d)
x = b//c - (a-1)//c
y = b//d - (a-1)//d
warikireru = x+y - (b//lcm - (a-1)//lcm)
print(b-a+1-warikireru)

Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d = map(int,input().split())
lcm = c * d // math.gcd(c, d)
x = b//c - (a-1)//c
y = b//d - (a-1)//d
warikireru = x+y - (b//lcm - (a-1)//lcm)
print(b-a+1-warikireru)

Fixed submission:
import fractions
a,b,c,d = map(int,input().split())
lcm = c * d // fractions.gcd(c, d)
x = b//c - (a-1)//c
y = b//d - (a-1)//d
warikireru = x+y - (b//lcm - (a-1)//lcm)
print(b-a+1-warikireru)
Buggy python submission (verdict: Time Limit Exceeded):
r,g,b,n = map(int,input().split())
count = 0
for i in range(n+1):
    for j in range(n+1):
        all_sum = n
        all_sum  -= i*r
        all_sum  -= j*g
        if all_sum < 0:
            continue
        if all_sum %b == 0 and i+j+(all_sum//b) != 0:
            count += 1
            #print(i,j,all_sum,b)
print(count) 

Fixed submission:
r,g,b,n = map(int,input().split())
count = 0
for i in range(n+1):
    for j in range(n+1):
        all_sum = n
        all_sum  -= i*r
        all_sum  -= j*g
        if all_sum < 0:
            continue
        if all_sum %b == 0 and i+j+(all_sum//b) != 0:
            count += 1
            #print(i,j,all_sum,b)
print(count)
Buggy python submission (verdict: Runtime Error):
import math
src = [input() for _ in range(5)]
k_li = []
v_li = []
sum = 0
for s in src:
    if int(s[-1]) != 0:
        k_li.append(int(s[-1]))
        v_li.append(int(s))
    else:
        sum += int(s)
m = min(k_li)
flag = False
if len(k_li)>0:
    for k,v in zip(k_li,v_li):
        if k == m and flag == False:
            sum += v
            flag = True
        else:
            sum += math.ceil(v/10)*10
print(sum)

Fixed submission:
import math
src = [input() for _ in range(5)]
k_li = []
v_li = []
sum = 0
for s in src:
    if int(s[-1]) != 0:
        k_li.append(int(s[-1]))
        v_li.append(int(s))
    else:
        sum += int(s)
flag = False
if len(k_li)>0:
    m = min(k_li)
    for k,v in zip(k_li,v_li):
        if k == m and flag == False:
            sum += v
            flag = True
        else:
            sum += math.ceil(v/10)*10
print(sum)

Buggy python submission (verdict: Runtime Error):
import math
src = [input() for _ in range(5)]
k_li = []
v_li = []
sum = 0
for s in src:
    if int(s[-1]) != 0:
        k_li.append(int(s[-1]))
        v_li.append(int(s))
    else:
        sum += int(s)
m = min(k_li)
flag = False
for k,v in zip(k_li,v_li):
    if k == m and flag == False:
        sum += v
        flag = True
    else:
        sum += math.ceil(v/10)*10
print(sum)

Fixed submission:
import math
src = [input() for _ in range(5)]
k_li = []
v_li = []
sum = 0
for s in src:
    if int(s[-1]) != 0:
        k_li.append(int(s[-1]))
        v_li.append(int(s))
    else:
        sum += int(s)
flag = False
if len(k_li)>0:
    m = min(k_li)
    for k,v in zip(k_li,v_li):
        if k == m and flag == False:
            sum += v
            flag = True
        else:
            sum += math.ceil(v/10)*10
print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
import math
n = int(input())
li = list(map(int,input().split()))

if len(list(set(li))) == 1:
    print(li[0])
else:
    all_li = []
    while len(li)>1:
        all_li = []
        for i,l in enumerate(li):
            if i == 0:
                continue
            else:
                all_li.append(fractions.gcd(l,li[i-1]))
        li = all_li
        #print(li,len(li))
    print(all_li[0])

Fixed submission:
import fractions
import math
n = int(input())
li = list(map(int,input().split()))

if len(list(set(li))) == 1:
    print(li[0])
else:
    if len(li) == 1:
        print(li[0])
        exit()
    tmp_gcd = fractions.gcd(li[0],li[1])
    if len(li)>2:
        for i,l in enumerate(li):
            if i == 0 or i == 1:
                continue
            gc = fractions.gcd(tmp_gcd,l)
            tmp_gcd = gc
    print(tmp_gcd)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
import math
n = int(input())
li = list(map(int,input().split()))

if len(list(set(li))) == 1:
    print(li[0])
else:
    all_li = []
    while len(li)>1:
        all_li = []
        for i,l in enumerate(li):
            if i == 0:
                continue
            else:
                all_li.append(fractions.gcd(l,li[i-1]))
        li = all_li
        #print(li,len(li))
    print(all_li[0])

Fixed submission:
import fractions
import math
n = int(input())
li = list(map(int,input().split()))

if len(list(set(li))) == 1:
    print(li[0])
else:
    if len(li) == 1:
        print(li[0])
        exit()
    tmp_gcd = fractions.gcd(li[0],li[1])
    if len(li)>2:
        for i,l in enumerate(li):
            if i == 0 or i == 1:
                continue
            gc = fractions.gcd(tmp_gcd,l)
            tmp_gcd = gc
    print(tmp_gcd)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
count = 0
for i in range(1,n+1):
    s = list(str(i))
    se = sorted(list(set(s)))
    #print(se)
    if se == ['3','5','7']:
        #print(i)
        count += 1
print(count)

Fixed submission:
import itertools

n = int(input())
count = 0
for i in range(3,10):
    li = list(itertools.product(range(3), repeat=i))
    #print(li)
    for l in li:
        st = ''
        for ll in l:
            if ll == 0:
                st += '3'
            elif ll == 1:
                st += '5'
            else:
                st += '7'
        if len(set(list(st))) == 3 and int(st)<=n:
            count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
n = input()
li = list(n)
same = li[0]*len(li)
if int(n) <= int(same):
    print(same)
else:
    print(str(int(li[0]+1))*len(li))

Fixed submission:
n = input()
li = list(n)
same = li[0]*len(li)
if int(n) <= int(same):
    print(same)
else:
    print(str(int(li[0])+1)*len(li))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

n = int(input())
li = list(map(int,input().split()))
a = [l for i,l in enumerate(li) if i % 2 == 0]
b = [l for i,l in enumerate(li) if i % 2 == 1]
se_a = list(set(a))
se_b = list(set(b))
all_lis = []
for aa in se_a:
    tmp_cnt = len(a) - Counter(a)[aa]
    #print(tmp_cnt,len(a),Counter(a)[aa])
    tmp_list = []
    for bb in se_b:
        if aa == bb:
            continue
        tmp_list.append(tmp_cnt+len(b) - Counter(b)[bb])
    #print(tmp_list)
    all_lis += tmp_list
if all_lis:
    print(min(all_lis))
else:
    print(len(a))

Fixed submission:
from collections import Counter
n = int(input())
li = list(map(int,input().split()))
a = [l for i,l in enumerate(li) if i % 2 == 0]
b = [l for i,l in enumerate(li) if i % 2 == 1]
se_a = list(set(a))
se_b = list(set(b))
if Counter(a).most_common()[0][0] != Counter(b).most_common()[0][0]:
    a_change = len(a) - Counter(a).most_common()[0][1]
    b_change = len(b) - Counter(b).most_common()[0][1]
    print(a_change+b_change)
else:
    if len(se_a) == 1 and len(se_b) == 1:
        print(len(a))
    else:
        x = len(a) - Counter(a).most_common()[0][1] + len(b) - Counter(b).most_common()[1][1]
        y = len(a) - Counter(a).most_common()[1][1] + len(b) - Counter(b).most_common()[0][1]
        print(min(x,y))
Buggy python submission (verdict: Runtime Error):
n = int(input())
if n == 0:
    print(0)
    exit()
flag = True
ans_str = ''
while True:
    if n // (-2) == 0:
        ans_str = '1' + ans_str
        print(int(ans_str))
        exit()
    else:
        ans_str = n%(-2) + ans_str

Fixed submission:
n = int(input())
if n == 0:
    print(0)
    exit()
flag = True
ans_str = ''
while True:
    if n == 1:
        ans_str = '1' + ans_str
        print(int(ans_str))
        exit()
    if n < 0 and (-n)%2 == 1:
        ans_str = '1' + ans_str
        n = -(n-1)//2
    elif n < 0 and (-n)%2 == 0:
        ans_str = '0' + ans_str
        n = -n//2
    elif n > 0 and n%2 ==1:
        ans_str = '1' + ans_str
        n = -(n//2)
    elif n > 0 and n%2 ==0:
        ans_str = '0' + ans_str
        n = -(n//2)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s_li = list(input())
all_li = [[0,0]]
for s in s_li:
    if s == 'W':
        all_li.append([all_li[-1][0]+1,all_li[-1][1]])
    else:
        all_li.append([all_li[-1][0],all_li[-1][1]+1])
#print(all_li)
ans = float('inf')
for i,a in enumerate(all_li):
    if i == 0:
        continue
    tmp_count = 0
    hidari = all_li[:i]
    if len(hidari)>0:
        tmp_count += hidari[-1][0]
    migi = all_li[i+1:]
    if len(migi)>0:
        tmp_count += (migi[-1][1]-a[1])
    if tmp_count < ans:
        ans = tmp_count
    #print(i,a,tmp_count)
print(ans)

Fixed submission:
n = int(input())
s_li = list(input())
all_li = [[0,0]]
for s in s_li:
    if s == 'W':
        all_li.append([all_li[-1][0]+1,all_li[-1][1]])
    else:
        all_li.append([all_li[-1][0],all_li[-1][1]+1])
#print(all_li)
ans = float('inf')
for i,a in enumerate(all_li):
    if i == 0:
        continue
    tmp_count = 0
    if i-1>0:
        tmp_count += all_li[i-1][0]
    tmp_count += (all_li[-1][1]-a[1])
    if tmp_count < ans:
        ans = tmp_count
    #print(i,a,tmp_count)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s_li = list(input())
all_li = [[0,0]]
for s in s_li:
    if s == 'W':
        all_li.append([all_li[-1][0]+1,all_li[-1][1]])
    else:
        all_li.append([all_li[-1][0],all_li[-1][1]+1])
#print(all_li)
ans = float('inf')
for i,a in enumerate(all_li):
    if i == 0:
        continue
    tmp_count = 0
    hidari = all_li[:i]
    if len(hidari)>0:
        tmp_count += hidari[-1][0]
    migi = all_li[i+1:]
    if len(migi)>0:
        tmp_count += (migi[-1][1]-a[1])
    if tmp_count < ans:
        ans = tmp_count
    #print(i,a,tmp_count)
print(ans)

Fixed submission:
n = int(input())
s_li = list(input())
all_li = [[0,0]]
for s in s_li:
    if s == 'W':
        all_li.append([all_li[-1][0]+1,all_li[-1][1]])
    else:
        all_li.append([all_li[-1][0],all_li[-1][1]+1])
#print(all_li)
ans = float('inf')
for i,a in enumerate(all_li):
    if i == 0:
        continue
    tmp_count = 0
    if i-1>0:
        tmp_count += all_li[i-1][0]
    tmp_count += (all_li[-1][1]-a[1])
    if tmp_count < ans:
        ans = tmp_count
    #print(i,a,tmp_count)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,k = map(int,input().split())
for i in range(k):
    x = b+c
    y = a+c
    z = a+b
    a,b,c = x,y,z
if a-b > 10*18:
    print('Unfair')
else:
    print(a-b)

Fixed submission:
a,b,c,k = map(int,input().split())
if k %2 == 1:
    print(b-a)
else:
    print(a-b)
Buggy python submission (verdict: Runtime Error):
import sys
h,w = map(int,input().split())
matrix = [[0]*(h+2) for _ in range(w+2)]
for hi in range(h):
    all_inp = input()
    for i,a in enumerate(all_inp):
        matrix[hi+1][i+1]= 0 if a == '.' else 1
#print(matrix)
for ri,row in enumerate(matrix):
    for ci,column in enumerate(row):
        if column == 1:
            if row[ci-1] == 0 and row[ci+1] == 0 and matrix[ri-1][ci] == 0 and matrix[ri+1][ci] == 0:
                print('No')
                sys.exit()
print('Yes')

Fixed submission:
import sys
h,w = map(int,input().split())
matrix = [[0]*(w+2) for _ in range(h+2)]
for hi in range(h):
    all_inp = input()
    for i,a in enumerate(all_inp):
        matrix[hi+1][i+1]= 1 if a == '#' else 0
#print(matrix)
for ri,row in enumerate(matrix):
    for ci,column in enumerate(row):
        if column == 1:
            if row[ci-1] == 0 and row[ci+1] == 0 and matrix[ri-1][ci] == 0 and matrix[ri+1][ci] == 0:
                print('No')
                sys.exit()
print('Yes')

Buggy python submission (verdict: Runtime Error):
import sys
h,w = map(int,input().split())
matrix = [[0]*(h+2) for _ in range(w+2)]
for hi in range(h):
    all_inp = input()
    for i,a in enumerate(all_inp):
        matrix[hi+1][i+1]= 0 if a == '.' else 1
print(matrix)
for ri,row in enumerate(matrix):
    for ci,column in enumerate(row):
        if column == 1:
            if row[ci-1] == 0 and row[ci+1] == 0 and matrix[ri-1][ci] == 0 and matrix[ri+1][ci] == 0:
                print('No')
                sys.exit()
print('Yes')

Fixed submission:
import sys
h,w = map(int,input().split())
matrix = [[0]*(w+2) for _ in range(h+2)]
for hi in range(h):
    all_inp = input()
    for i,a in enumerate(all_inp):
        matrix[hi+1][i+1]= 1 if a == '#' else 0
#print(matrix)
for ri,row in enumerate(matrix):
    for ci,column in enumerate(row):
        if column == 1:
            if row[ci-1] == 0 and row[ci+1] == 0 and matrix[ri-1][ci] == 0 and matrix[ri+1][ci] == 0:
                print('No')
                sys.exit()
print('Yes')