Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

n,q = map(int, input().split())
s = input()
lr = []
for i in range(q):
    tmp = list(int(i) for i in input().split())
    tmp[0] -= 1
    tmp[1] -= 1
    lr.append((tmp))
t = list(s)
acs = []
while not s.find('AC') == -1:
    id = s.find('AC')
    acs.append(id + len(acs) * 2)
    t.pop(id)
    t.pop(id)
    s = ''.join(t)

for i in range(q):
    l = lr[i][0]
    r = lr[i][1]
    li = bisect.bisect_left(acs,l)
    ri = bisect.bisect_right(acs,r)
    if ri > 0:
        if acs[ri-1] == r:
            ri -= 1
    print(ri-li)    


Fixed submission:
N, Q = map(int, input().split())
S = input()
L,R = [], []
for i in range(Q):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

AC = [0] * N

for i in range(1,N):
    if S[i - 1] == 'A' and S[i] == 'C':
        AC[i] = AC[i - 1] + 1
    else:
        AC[i] = AC[i - 1]

for l, r in zip(L, R):
    print(AC[r-1]-AC[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n, q = (int(i) for i in input().split())
s = input()
l,r = [],[]
for i in range(q):
    tmp = [int(i) for i in input().split()]
    l.append(tmp[0]-1)
    r.append(tmp[1]-1)
# AC_index = []
# while 'AC' in s:
#     index = s.index('AC')
#     AC_index.append(index + len(AC_index) * 2)
#     if index < (len(s) - 1):
#         s = s[:index] + s[index + 2:]
#     else:
#         s = s[:index]

# for i in range(q):
#     left_index = bisect.bisect_left(AC_index, l[i])
#     right_index = bisect.bisect_right(AC_index, r[i])
#     if AC_index[right_index - 1] == r[i]:
#         right_index -= 1
        
#     print(right_index-left_index)
for i in range(q):
    tmp = s[l[i]:r[i] + 1]
    tmp = tmp.replace('AC', '00')
    print(tmp.count('0')//2)

Fixed submission:
N, Q = map(int, input().split())
S = input()
L,R = [], []
for i in range(Q):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

AC = [0] * N

for i in range(1,N):
    if S[i - 1] == 'A' and S[i] == 'C':
        AC[i] = AC[i - 1] + 1
    else:
        AC[i] = AC[i - 1]

for l, r in zip(L, R):
    print(AC[r-1]-AC[l-1])

Buggy python submission (verdict: Runtime Error):
import bisect
n, q = (int(i) for i in input().split())
s = input()
l,r = [],[]
for i in range(q):
    tmp = [int(i) for i in input().split()]
    l.append(tmp[0]-1)
    r.append(tmp[1]-1)
AC_index = []
while 'AC' in s:
    index = s.index('AC')
    AC_index.append(index + len(AC_index) * 2)
    if index < (len(s) - 1):
        s = s[:index] + s[index + 2:]
    else:
        s = s[:index]

for i in range(q):
    left_index = bisect.bisect_left(AC_index, l[i])
    right_index = bisect.bisect_right(AC_index, r[i])
    if AC_index[right_index - 1] == r[i]:
        right_index -= 1
        
    print(right_index-left_index)

Fixed submission:
N, Q = map(int, input().split())
S = input()
L,R = [], []
for i in range(Q):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

AC = [0] * N

for i in range(1,N):
    if S[i - 1] == 'A' and S[i] == 'C':
        AC[i] = AC[i - 1] + 1
    else:
        AC[i] = AC[i - 1]

for l, r in zip(L, R):
    print(AC[r-1]-AC[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
count = 0
for i in range(1,2 ** n):
    s_i = bin(i)[2:].zfill(n)
    tmp = []
    for j in range(n):
        if s_i[j] == '1':
            tmp.append(s[j])
            if s_i[j] in tmp:
                break
    if len(tmp) == len(set(tmp)):
        count += 1

print(count%(10**9 + 7))

Fixed submission:
n = int(input())
s = input()
t = list(set(s))
alpha = {}
for i in range(len(t)):
    alpha[t[i]] = s.count(t[i])

count = 1
for k, v in alpha.items():
    count *= (v + 1)
count -= 1
print(count%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
count = 0
for i in range(1,2 ** n):
    s_i = bin(i)[2:].zfill(n)
    tmp = []
    for j in range(n):
        if s_i[j] == '1':
            tmp.append(s[j])
    if len(tmp) == len(set(tmp)):
        count += 1

print(count)

Fixed submission:
n = int(input())
s = input()
t = list(set(s))
alpha = {}
for i in range(len(t)):
    alpha[t[i]] = s.count(t[i])

count = 1
for k, v in alpha.items():
    count *= (v + 1)
count -= 1
print(count%(10**9+7))
Buggy python submission (verdict: Runtime Error):
N, M, C = map(int, input().split())
b = [(int(i) for i in input().split())]
a = []
for i in range(N):
    a.append([int(i) for i in input().split()])

count = 0
for i in range(N):
    tmp = 0
    for j in range(M):
        tmp += b[j] * a[i][j]
    if tmp + C > 0:
        count += 1

print(count)

Fixed submission:
N, M, C = map(int, input().split())
b = [int(i) for i in input().split()]
a = []
for i in range(N):
    a.append([int(i) for i in input().split()])

count = 0
for i in range(N):
    tmp = 0
    for j in range(M):
        tmp += b[j] * a[i][j]
    if tmp + C > 0:
        count += 1

print(count)

Buggy python submission (verdict: Runtime Error):
N, M, C = map(int, input().split())
b = [map(int, input().split())]
a = []
for i in range(N):
    a.append([int(i) for i in input().split()])

count = 0
for i in range(N):
    tmp = 0
    for j in range(M):
        tmp += b[j] * a[i][j]
    if tmp + C > 0:
        count += 1

print(count)

Fixed submission:
N, M, C = map(int, input().split())
b = [int(i) for i in input().split()]
a = []
for i in range(N):
    a.append([int(i) for i in input().split()])

count = 0
for i in range(N):
    tmp = 0
    for j in range(M):
        tmp += b[j] * a[i][j]
    if tmp + C > 0:
        count += 1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
t = input()
s = [c for c in t]
Removable = True
count = 0
while True and len(s)>1:
    tmp = len(s)
    for i in range(len(s)-1):
        if int(s[i])+int(s[i+1]) == 1:
            count += 2
            s.pop(i)
            s.pop(i)
            break
    if tmp == len(s):
        break
print(count)
            

Fixed submission:
t = input()
s = [int(c) for c in t]
print(2 * min(len(s)-sum(s), sum(s)))
Buggy python submission (verdict: Runtime Error):
#include <iostream>
using namespace std;
int main(void){
	int a,b;
	cin >> a >> b;
	if (b%a==0) {
		cout << a+b << endl;
	}else {
		cout << b-a << endl;
	}
	return 0;
}

Fixed submission:
a,b = (int(i) for i in input().split())
if b%a==0:
    print(a+b)
else:
    print(b-a)
Buggy python submission (verdict: Runtime Error):
n,m = (int(i) for i in input().split())
x = list(int(i) for i in input().split())
x = sorted(x)
if m>1:
    res = x[-1]-x[0]
    dif = []
    for i in range(m-1):
        dif.append(abs(x[i+1]-x[i]))
        
    dif = sorted(dif,reverse = True)
    for i in range(n-1):
        res -= dif[i]
else:
    res = 0
print(res)


Fixed submission:
n,m = (int(i) for i in input().split())
x = list(int(i) for i in input().split())
x = sorted(x)
if m>1:
    res = x[-1]-x[0]
    dif = []
    for i in range(m-1):
        dif.append(abs(x[i+1]-x[i]))
        
    dif = sorted(dif,reverse = True)
    if n<m:
        for i in range(n-1):
            res -= dif[i]
    else:
        res = 0
else:
    res = 0
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
h = list(int(i) for i in input().split())
count = 0
while not all(i==0 for i in h):
    if 0 in h:
        zero_index = [i for i,x in enumerate(h) if x==0]
        for i in range(len(zero_index)):
            if i==0:
                if not all(h[j]==0 for j in range(zero_index[i])):
                    for j in range(zero_index[i]):
                        h[j] -= 1
                    count += 1
            elif i==len(zero_index)-1 and not zero_index[i]==n-1:
                if not all(h[j]==0 for j in range(zero_index[i]+1,n)):
                    for j in range(zero_index[i]+1,n):
                        h[j] -= 1
                    count += 1
            else:
                if not all(h[j]==0 for j in range(zero_index[i-1]+1,zero_index[i])):
                    for j in range(zero_index[i-1]+1, zero_index[i]):
                        h[j] -= 1
                    count += 1
    else:
        for i in range(n):
            h[i] -=1
        count += 1
print(count)

Fixed submission:
n = int(input())
h = list(int(i) for i in input().split())
count = 0
while not all(height==0 for height in h):
    index = [i for i,x in enumerate(h) if not x==0]
    for i in range(len(index)):
        h[index[i]] -= 1
        if not i==0:
            if index[i]-index[i-1]>1:
                count += 1
    count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = (int(i) for i in input().split())
h = list(int(i) for i in input().split())
dp = list(0 for i in range(n))
num = list(range(n))
num = sorted(num, reverse=True)
for i in num:
    if i==n-1:
         dp[i]=0
    elif i==n-2:
         dp[i]=abs(h[n-1]-h[n-2])
    elif i>n-k-1:
        for j in range(i+1,n):
            if j==i+1:
                dp[i] = abs(h[j]-h[i])+dp[j]
            else:
                dp[i] = min(dp[i],abs(h[j]-h[i])+dp[j])
    else:
        for j in range(i+1,i+k+1):
            if j==i+1:
                dp[i] = abs(h[j]-h[i])+dp[j]
            else:
                dp[i] = min(dp[i],abs(h[j]-h[i])+dp[j])              
print(dp[0])

Fixed submission:
N, K = map(int, input().split())
H = list(map(int, input().split()))

H = [0] + H
dp = [0] * (N+1)

for i in range(2, N+1):
    dp[i] = dp[i-1] + abs(H[i]-H[i-1])
    for k in range(2, K+1):
        if i-k >= 1:
            dp[i] = min(dp[i], dp[i-k]+abs(H[i]-H[i-k]))

res = dp[N]
print(res)
Buggy python submission (verdict: Runtime Error):
d = int(input())
if d==25:
    print(Christmas)
if d==24:
    print(Christmas Eve)
if d==23:
    print(Christmas Eve Eve)
if d==22:
    print(Christmas Eve Eve Eve)


Fixed submission:
d = int(input())
if d==25:
    print("Christmas")
if d==24:
    print("Christmas Eve")
if d==23:
    print("Christmas Eve Eve")
if d==22:
    print("Christmas Eve Eve Eve")
Buggy python submission (verdict: Time Limit Exceeded):
n,x=(int(i) for i in input().split())

def makeBurger(s):
    return "B"+s+"P"+s+"B"
s = "P"
if(n>0):
    for i in range(n):
        s = makeBurger(s)
count = 0
for i in range(x):
    if s[i]=='P':
        count += 1
print(count)

Fixed submission:
n , x = map(int, input().split())
# ABCの長さ
a = [1]
for i in range(n):
    a.append(a[i] * 2 + 3)

# パティの枚数
p = [1]
for i in range(n):
    p.append(p[i] * 2 + 1)

def f(n, x):
    if n == 0:
        return 0 if x <= 0 else 1
    elif x == 1:
        return 0
    elif 1 <  x <=  1 + a[n - 1]:
        return f(n - 1, x - 1)
    elif x == 2 + a[n-1]:
        return p[n-1] + 1
    elif 2 + a[n - 1] < x <= 2 + 2 * a[n - 1]:
        return f(n - 1, x - 2 - a[n - 1]) + p[n-1] + 1
    elif x == 3 + 2 * a[n - 1]:
        return 2 * p[n-1] + 1

print(f(n, x))

Buggy python submission (verdict: Runtime Error):
n,x=(int(i) for i in input().split())

def makeBurger(s):
    return "B"+s+"P"+s+"B"
s = "P"
for i in range(n):
    s = makeBurger(s)
count = 0
for i in range(x):
    if s[i]=='P':
        count += 1
print(count)

Fixed submission:
n , x = map(int, input().split())
# ABCの長さ
a = [1]
for i in range(n):
    a.append(a[i] * 2 + 3)

# パティの枚数
p = [1]
for i in range(n):
    p.append(p[i] * 2 + 1)

def f(n, x):
    if n == 0:
        return 0 if x <= 0 else 1
    elif x == 1:
        return 0
    elif 1 <  x <=  1 + a[n - 1]:
        return f(n - 1, x - 1)
    elif x == 2 + a[n-1]:
        return p[n-1] + 1
    elif 2 + a[n - 1] < x <= 2 + 2 * a[n - 1]:
        return f(n - 1, x - 2 - a[n - 1]) + p[n-1] + 1
    elif x == 3 + 2 * a[n - 1]:
        return 2 * p[n-1] + 1

print(f(n, x))
Buggy python submission (verdict: Runtime Error):
s = input()
for i in range(len(s)):
  s = input()
dif = list(1000 for i in range(len(s)-2))
for i in range(len(s)-2):
    tmp = s[i:i+3]
    dif[i] = abs(int(tmp)-753)
print(min(dif))
    

Fixed submission:
s = input()
dif = list(1000 for i in range(len(s)-2))
for i in range(len(s)-2):
    tmp = s[i:i+3]
    dif[i] = abs(int(tmp)-753)
print(min(dif))
Buggy python submission (verdict: Runtime Error):
n,m = (int(i) for i in input().split())
res = list([] for i in range(n))
p,y = [],[]
for i in range(m):
    tmp = list(int(i) for i in input().split())
    p.append(tmp[0])
    y.append(tmp[1])
    res[tmp[0]-1].append(tmp[1])

for i in range(n):
    res[i] = sorted(res[i])

for i in range(n):
    print("{0:06d}{1:06d}".format(p[i], res[p[i]-1].index(y[i])+1))


Fixed submission:
N,M = map(int,input().split())
src = [tuple(map(int,input().split())) for i in range(M)]

cs = [[] for i in range(N+1)]
for i,(p,y) in enumerate(src):
    cs[p].append((y,i))
for cc in cs:
    cc.sort()

ans = [None] * M
for p in range(len(cs)):
    for i,(_,j) in enumerate(cs[p]):
        s = str(p).zfill(6) + str(i+1).zfill(6)
        ans[j] = s
print(*ans, sep='\n')

Buggy python submission (verdict: Time Limit Exceeded):
n,m = (int(i) for i in input().split())
p,y =[],[]
for i in range(m):
    tmp = list(int(i) for i in input().split())
    p.append(tmp[0])
    y.append(tmp[1])

dict = {}
for i in range(m):
    if not p[i] in dict.keys():
        dict[p[i]] = [(y[i],i)]
    else:
        dict[p[i]].append((y[i],i))

for k,v in dict.items():
  dict[k] = sorted(v)

for i in range(m):
  for k,v in dict.items():
    for j in range(len(v)):
        if i == v[j][1]:
            id = '0'*(6-len(str(k)))+str(k)
            id = id + '0'*(6-len(str(j)))+str(j+1)
            print(id)


Fixed submission:
N,M = map(int,input().split())
src = [tuple(map(int,input().split())) for i in range(M)]

cs = [[] for i in range(N+1)]
for i,(p,y) in enumerate(src):
    cs[p].append((y,i))
for cc in cs:
    cc.sort()

ans = [None] * M
for p in range(len(cs)):
    for i,(_,j) in enumerate(cs[p]):
        s = str(p).zfill(6) + str(i+1).zfill(6)
        ans[j] = s
print(*ans, sep='\n')

Buggy python submission (verdict: Time Limit Exceeded):
n,m = (int(i) for i in input().split())
p = list(0 for i in range(m))
y = list(0 for i in range(m))
for i in range(m):
    p[i], y[i] = (int(i) for i in input().split())

sum = 0
y_tmp = list([] for i in range(n))
y_sort = list([] for i in range(n))

for i in range(m):
    y_tmp[p[i]-1].append(y[i])
    sum+=1
    if sum == m:
        break

for i in range(n):
    y_sort[i] = sorted(y_tmp[i])


for i in range(m):
    print("{0:06d}{1:06d}".format(p[i], y_sort[p[i]-1].index(y[i])+1))

Fixed submission:
N,M = map(int,input().split())
src = [tuple(map(int,input().split())) for i in range(M)]

cs = [[] for i in range(N+1)]
for i,(p,y) in enumerate(src):
    cs[p].append((y,i))
for cc in cs:
    cc.sort()

ans = [None] * M
for p in range(len(cs)):
    for i,(_,j) in enumerate(cs[p]):
        s = str(p).zfill(6) + str(i+1).zfill(6)
        ans[j] = s
print(*ans, sep='\n')
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = int(input())
b = int(input())
if N == 1:
    print("Hello World")
else:
    print(a+b)

Fixed submission:
N = int(input())
if N == 1:
    print("Hello World")
else:
    a = int(input())
    b = int(input())
    print(a+b)

Buggy python submission (verdict: Runtime Error):
int N = int(input())
int a = int(input())
int b = int(input())
if N == 1:
    print("Hello World")
else:
    print(a+b)

Fixed submission:
N = int(input())
if N == 1:
    print("Hello World")
else:
    a = int(input())
    b = int(input())
    print(a+b)

Buggy python submission (verdict: Runtime Error):
int N = int(input())
int a = int(input())
int b = int(input())
print(N==1 ? "hello World" : a+b)

Fixed submission:
N = int(input())
if N == 1:
    print("Hello World")
else:
    a = int(input())
    b = int(input())
    print(a+b)
Buggy python submission (verdict: Time Limit Exceeded):
N , K = (int(i) for i in input().split())
a = 0
b = 0
c = 0
count = 0
for i in range(N):
    a = i+1
    for j in range(N):
        b = j + 1
        for k in range(N):
            c = k + 1
            if (a+b)%K==0 and (b+c)%K==0 and (c+a)%K==0:
                count += 1
print(count)

Fixed submission:
N, K = map(int, input().split())
res = 0
res += (N // K)** 3
if K % 2 == 0:
    res += ((N-K//2)//K + 1) ** 3

print(res)
Buggy python submission (verdict: Runtime Error):
n,k = (int(i) for i in input().split())
x = list(int(i) for i in input().split())
px=[]
mx=[]
for i in range(n):
    if x[i]>=0:
        px = x[i:]
        mx = x[:i]
        break
res = 1000000000
p = len(px)
m = len(mx)
if p>0 and m>0:
    for i in range(1,min(m,k)+1):
        if p>=k-i:
            res = min(res,2*abs(mx[-i])+px[k-i-1])
    for j in range(1,min(p,k)+1):
        if m>=k-j:
            res = min(res,2*px[j-1]+abs(mx[-k+j]))
elif p>0:
    res = px[k-1]
else:
    res = abs(mx[-k])
print(res)

Fixed submission:
n,k = (int(i) for i in input().split())
x = list(int(i) for i in input().split())
res = 1000000000
for i in range(n-k+1):
    xl = x[i]
    xr = x[i+k-1]
    tmp = min(abs(xl)+abs(xr-xl), abs(xr)+abs(xr-xl))
    res = min(res,tmp)
print(res)
Buggy python submission (verdict: Runtime Error):
s = str(input())
k = int(input())
c = 0
for i in range(len(s)):
    if s[i] == "1":
        c += 1
    else:
        continue
if c >= k:
    print(1)
    break
for i in range(len(s)):
    if s[i] != "1":
        print(s[i])
        break


Fixed submission:
s = str(input())
k = int(input())
c = 0
for i in range(len(s)):
    if s[i] == "1":
        c += 1
    else:
        break

if c >= k:
    print("1")
else:
    for i in range(len(s)):
        if s[i] != "1":
            print(s[i])
            break
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = (int(i) for i in input().split())
print(sum(a)-len(a))

Fixed submission:
n = int(input())
a = list(int(i) for i in input().split())
print(sum(a)-len(a))
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(int(i) for i in input().split())
a.sort(reverse = True)
print(a[0]-a[-1])

Fixed submission:
N = int(input())
if N % 2 == 0:
    print(N)
else:
    print(2*N)

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(int(i) for i in input().split())
a.sort(reverse = True)
print(a[0]-a[-1])

Fixed submission:
N = int(input())
if N % 2 == 0:
    print(N)
else:
    print(2*N)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(int(i) for i in input().split())
for i in range(N):
  a[i] = a[i]-i
a.sort()
if N%2==0:
  b=int((a[int(N/2)]+a[int(N/2+1)])/2)
else:
  b=a[int((N+1)/2)]
sum_1=0
sum_2=0
sum_3=0
for i in range(N):
  sum_1 += abs(a[i]-b)
b-=1
for i in range(N):
  sum_2 += abs(a[i]-b)
b+=2
for i in range(N):
  sum_3 += abs(a[i]-b)
print(min(sum_1,sum_2,sum_3))


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A = [x - i - 1 for i, x in enumerate(A)]
A.sort()
mid = A[N // 2]
res1 = 0
for a in A:
    res1 += abs(a - mid)

mid += 1
res2 = 0
for a in A:
    res2 += abs(a - mid)


print(min(res1, res2))

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(int(i) for i in input().split())
for i in range(N):
  a[i] = a[i]-i
a.sort()
if N%2==0:
  b=int((a[int(N/2)]+a[int(N/2+1)])/2)
else:
  b=a[int((N+1)/2)]
sum_1=0
sum_2=0
for i in range(N):
  sum_1 += abs(a[i]-b)
b-=1
for i in range(N):
  sum_2 += abs(a[i]-b)
print(min(sum_1,sum_2))


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A = [x - i - 1 for i, x in enumerate(A)]
A.sort()
mid = A[N // 2]
res1 = 0
for a in A:
    res1 += abs(a - mid)

mid += 1
res2 = 0
for a in A:
    res2 += abs(a - mid)


print(min(res1, res2))
Buggy python submission (verdict: Runtime Error):
w,h = (int(i) for i in input().split())
s = []
for i in range(h):
    s.append(input())

isPaintable = True
for y in range(h):
    for x in range(w):
        if s[x][y]=="#":
            if x-1>=0 and s[x-1][y]=="#":
                continue
            elif y-1>=0 and s[x][y-1]=="#":
                continue
            elif x+1<w and s[x+1][y]=="#":
                continue
            elif y+1<h and s[x][y+1]=="#":
                continue
            isPaintable=False
if isPaintable:
    print("Yes")
else:
    print("No")

Fixed submission:
h,w = (int(i) for i in input().split())
s = []
for i in range(h):
    s.append(input())

isPaintable = True
for y in range(h):
    for x in range(w):
        if s[y][x]=="#":
            if x-1>=0 and s[y][x-1]=="#":
                continue
            elif y-1>=0 and s[y-1][x]=="#":
                continue
            elif x+1<w and s[y][x+1]=="#":
                continue
            elif y+1<h and s[y+1][x]=="#":
                continue
            isPaintable=False
if isPaintable:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
h,w = (int(i) for i in input().split())
s = []
for i in range(h):
    s.append(input())

isPaintable = True
for y in range(h):
    for x in range(w):
        if s[x][y]=="#":
            if x-1>=0 and s[x-1][y]=="#":
                continue
            elif y-1>=0 and s[x][y-1]=="#":
                continue
            elif x+1<w and s[x+1][y]=="#":
                continue
            elif y+1<h and s[x][y+1]=="#":
                continue
            isPaintable=False
if isPaintable:
    print("Yes")
else:
    print("No")

Fixed submission:
h,w = (int(i) for i in input().split())
s = []
for i in range(h):
    s.append(input())

isPaintable = True
for y in range(h):
    for x in range(w):
        if s[y][x]=="#":
            if x-1>=0 and s[y][x-1]=="#":
                continue
            elif y-1>=0 and s[y-1][x]=="#":
                continue
            elif x+1<w and s[y][x+1]=="#":
                continue
            elif y+1<h and s[y+1][x]=="#":
                continue
            isPaintable=False
if isPaintable:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):

n = int(input())
a = list(int(i) for i in input().split())
sa = [0] * (n+1)
num_cnt = {}    
# 累積和
for i in range(n):
    sa[i + 1] = sa[i] + a[i]

for num in sa:
    if num in num_cnt:
        num_cnt[num] += 1
    else:
        num_cnt[num] = 1

for cnt in num_cnt.values():
    res += cnt*(cnt-1)//2

print(res)


Fixed submission:

n = int(input())
a = list(int(i) for i in input().split())
sa = [0] * (n+1)
num_cnt = {}    
# 累積和
for i in range(n):
    sa[i + 1] = sa[i] + a[i]

for num in sa:
    if num in num_cnt:
        num_cnt[num] += 1
    else:
        num_cnt[num] = 1


res = 0
for cnt in num_cnt.values():
    res += cnt*(cnt-1)//2

print(res)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(int(i) for i in input().split())
sa = [0] * (n+1)
num_cnt = {}    
# 累積和
for i in range(n):
    sa[i+1] = sa[i] + a[i]

nums = list(set(sa))
for num in nums:
    num_cnt[num] = sa.count(num)
res = 0
for cnt in num_cnt.values():
    res += cnt*(cnt-1)//2

print(res)

Fixed submission:

n = int(input())
a = list(int(i) for i in input().split())
sa = [0] * (n+1)
num_cnt = {}    
# 累積和
for i in range(n):
    sa[i + 1] = sa[i] + a[i]

for num in sa:
    if num in num_cnt:
        num_cnt[num] += 1
    else:
        num_cnt[num] = 1


res = 0
for cnt in num_cnt.values():
    res += cnt*(cnt-1)//2

print(res)