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

Fixed submission:
N = int(input())
res = 'No'
for i in range(int(100/7)+1):
	for j in range(int(100/4)+1):
		a = i*7 + j*4
		if int(N) == a:
			res='Yes'
print(res)

Buggy submission (verdict: Runtime Error):
import sys
N = map(int, input().split())
N = N[0]
for i in range(int(100/7)+1):
	for j in range(int(100/4)+1):
		a = i*7 + j*4
		if int(N) == a:
			print('Yes')
			sys.exit();

print('No')

Buggy submission (verdict: Runtime Error):
import sys
N = map(int, '4'.split())
N = N[0]
for i in range(int(100/7)+1):
	for j in range(int(100/4)+1):
		a = i*7 + j*4
		if int(N) == a:
			print('Yes')
			sys.exit();

print('No')

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

for i in range(int(100/7)+1):
  for j in range(int(100/4)+1):
    if i*7 + j*4 == N:
      print('Yes')
      return
print('No')
Problem p02641 (python)

Fixed submission:
import sys

def saiki(l,r,lst):
  if (l - 1) not in lst:
      return (l - 1)
  
  if (r + 1) not in lst:
      return (r + 1)
  
  return saiki(l - 1, r + 1, lst)

def main():
  # Xはもっとも近い整数，Nは与えられるP
  X,N = map(int, input().split())

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

  if N == 0:
    print(X)
    sys.exit()

  if X not in arr:
    print(X)
    sys.exit()

  print(saiki(X,X,arr))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
# Xはもっとも近い整数，Nは与えられるP
X,N = map(int, input().split())

if N == 0:
  print(X)
  sys.exit()

arr = list(map(int, input().split()))
mainasu = X 
purasu = X 

def saiki():
  mainasu - 1
  purasu + 1
  if X in arr:
    if mainasu in arr:
      if purasu in arr:
        saiki()
      else:
        print(purasu)
    else:
      print(mainasu)
  else:
    print(X)

saiki()

Buggy submission (verdict: Runtime Error):
import sys
# Xはもっとも近い整数，Nは与えられるP
X,N = map(int, input().split())

if N == 0:
  print(X)
  sys.exit()

arr = list(map(int, input().split()))
mainasu = X 
purasu = X 

def saiki():
  mainasu = mainasu - 1
  purasu = purasu + 1
  if X in arr:
    if mainasu in arr:
      if purasu in arr:
        saiki()
      else:
        print(purasu)
    else:
      print(mainasu)
  else:
    print(X)

saiki()

Buggy submission (verdict: Runtime Error):
import sys
# Xはもっとも近い整数，Nは与えられるP
X,N = map(int, input().split())

if N == 0:
  print(X)
  sys.exit()

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

def saiki():
  mainasu = X - 1
  purasu = X + 1
  if X in arr:
    if mainasu in arr:
      if purasu in arr:
        saiki()
      else:
        print(purasu)
    else:
      print(mainasu)
  else:
    print(X)

saiki()
Problem p02700 (python)

Fixed submission:
a,b,c,d=map(int,input().split())
flag=True
while flag:
    c-=b
    if(c<=0):
        flag=False
        print("Yes")
        break
        
    a-=d
    if(a<=0):
        falg=False
        print("No")
        break

Buggy submission (verdict: Runtime Error):
a=int(input())#takahashi
b=int(input())
c=int(input())#aoki
d=int(input())
flag=True
while flag:
    c-=b
    if(c<=0):
        flag=False
        print("Yes")
        break
        
    a-=d
    if(a<=0):
        falg=False
        print("No")
        break
Problem p02663 (python)

Fixed submission:
h1, m1, h2, m2, k = map(int, input().split())

f = h1 * 60 + m1
t = h2 * 60 + m2

time = t - f - k
if time < 0:
  print(0)
else:
  print(time)

Buggy submission (verdict: Runtime Error):
h1, m1, h2, m2, k = map(int, input().split())
 
f = h1 * 60 + m1
t = h2 * 60 + m2
 
if time < 0:
  print(0)
else:
  print(time)

Buggy submission (verdict: Runtime Error):
h1, m1, h2, m2, k = map(int, input().split())

f = h1 * 60 + m1
t = h2 * 60 + m2

print(time)
if time < 0:
  print(0)
else:
  print(time)
Problem p02696 (python)

Fixed submission:
# -*- coding: utf-8 -*-
# x = p * b + q
# 0 <= q < b
# int(a * p + a * q / b) - a * int(p - q / b)
# = a * p + int(a * q / b) - a * p
# = int(a * q / b)

a, b, n = map(int, input().split())

print(a * min(b - 1, n) //  b)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

a, b, n = map(int, input().split())

ans_list = []

for i in range(int(b / 2), n + 1):
  #print(int((a * i) / b), a * int(i / b), int((a * i) / b) - a * int(i / b))
  ans = int((a * i) / b) - a * int(i / b)
  ans_list.append(ans)
print(max(ans_list))
Problem p02713 (python)

Fixed submission:
import math
# from functools import reduce

# def gcd(*numbers):
#     return reduce(math.gcd, numbers)

k = int(input())

sum = 0
for p in range(k):
    for q in range(k):
        n = math.gcd(p + 1, q + 1)
        for r in range(k):
            sum += math.gcd(n, r + 1)
print(sum)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import math

k = int(input())

sum = 0
for p in range(k):
    for q in range(k):
        for r in range(k):
            sum += math.gcd(p + 1, q + 1, r + 1)
print(sum)
Problem p02760 (python)

Fixed submission:
a = []
a.extend(map(int, input().split()))
a.extend(map(int, input().split()))
a.extend(map(int, input().split()))
n = int(input())
b = []

for i in range(n):
  b.append(int(input()))

#print(a, b)

for i in range(len(b)):
  a = [0 if mas == b[i] else mas for mas in a]

if a[0] == 0 and a[1] == 0 and a[2] == 0\
   or a[3] == 0 and a[4] == 0 and a[5] == 0\
   or a[6] == 0 and a[7] == 0 and a[8] == 0\
   or a[0] == 0 and a[3] == 0 and a[6] == 0\
   or a[1] == 0 and a[4] == 0 and a[7] == 0\
   or a[2] == 0 and a[5] == 0 and a[8] == 0\
   or a[0] == 0 and a[4] == 0 and a[8] == 0\
   or a[2] == 0 and a[4] == 0 and a[6] == 0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 157b
a = []
b = []
check_list = [False] * 9
for _ in range(3);
  a.extend(list(map(int, input().split())))
n = int(input())
for _ in range(n);
  b.append(int(input()))

for _b in b:
  if _b in a:
    check_list[a.index(_b)] = True

if check_list[0] and check_list[1] and check_list[2]\
  or check_list[3] and check_list[4] and check_list[5]\
  or check_list[6] and check_list[7] and check_list[8]\
  or check_list[0] and check_list[3] and check_list[6]\
  or check_list[1] and check_list[4] and check_list[7]\
  or check_list[2] and check_list[5] and check_list[8]\
  or check_list[0] and check_list[4] and check_list[8]\
  or check_list[2] and check_list[4] and check_list[6]:
  print('Yes')
else:
  print('No')
Problem p02646 (python)

Fixed submission:
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())

if W>=V or abs(A-B)/abs(W-V) > T:
    print('NO')
else:
    print('YES')

Buggy submission (verdict: Runtime Error):
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())

if abs(A-B)/abs(W-V) > T:
    print('NO')
else:
    print('YES')
Problem p02664 (python)

Fixed submission:
import copy
T = list(input())
P = [0]*(len(T)+10)
P[0] = 0
if T[0] == '?':
    T[0] = 'D'
for i in range(len(T)):
    if T[i] == '?':
        if T[i-1] == 'D':
            T[i] = 'D'
            P[i+1] = P[i] + 1
        else:
            T[i] = 'D'
            P[i+1] = P[i] + 2
    else:
        if T[i] == 'D':
            if T[i-1] == 'D':
                P[i+1] += P[i]+1
            else:
                P[i+1] = P[i]+2
        else: 
            P[i+1] = P[i]   


print(''.join(T))

Buggy submission (verdict: Runtime Error):
T = list(input())

for i in reversed(range(len(T))):
    if T[i] == '?':
        if i == len(T)-1:
            T[i] = 'D'
        if T[i+1] == 'D':
            T[i] = 'P'
        else:
            T[i] = 'D'
    else:
        continue

print(''.join(T))
Problem p02678 (python)

Fixed submission:
from collections import deque

tmp = input().split()
N = int(tmp[0])
M = int(tmp[1])
ve = [deque() for _ in range(N)]
todo = deque()

s = 0
for m in range(M):
    S, T  = map(int,input().split())
    ve[S-1].append(T)
    ve[T-1].append(S)

visited = [False]*N
dist = [0]*N
todo.append(1)
   
while len(todo)>0:
    now = todo.popleft()   
    while len(ve[now-1])>0:
        sr = ve[now-1].pop()
        if  visited[sr-1]: continue
        dist[sr-1] = now
        visited[sr-1] = True
        todo.append(sr)

print('Yes')
[print(i) for i in dist[1:]]

Buggy submission (verdict: Runtime Error):
tmp = input().split()
N = int(tmp[0])
S = [0 for i in range(N)]
T = [0 for i in range(N)]

for n in range(N):
    tmp = input().split()
    S[n] = int(tmp[0])
    T[n] = int(tmp[1])


#total 
mod =  1000000007

dp[0] = 0

for i in range(N+1):
    
    out = 0
    for k in range(i):
        if S[k]*S[i]+T[k]*T[i] == 0:
            ++out
    dp[i+1] = dp[i]*2 - out 
    dp[i+1] = dp[i+1] %mod
print(dp[N])
Problem p02684 (python)

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

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

Visited = [-1]*N
now = 1
Order = [0]*N

loopcount = 1
Order[0] = 1
Visited[0] = 1
for i in range(1,N):
    nt = Map[now-1]
    Order[i] = nt
    loopcount += 1
    if Visited[nt-1] == -1:
        Visited[nt-1] = loopcount
    else:
        break
    now = nt
    

ns = Visited[nt-1]
period = loopcount - ns

if period == 0:
    period = loopcount
    ns = 0

Kmod = K - ns
if Kmod > 0:
    Kmod %= period

print(Order[ns+Kmod])

Buggy submission (verdict: Runtime Error):
tmp = input().split()
N = int(tmp[0])
K = int(tmp[1])

tmp = input().split()

Map = [0]*N
GroupFlag = [0]*N

for i in range(N):
    Map[i] = int(tmp[i])

for i in range(N):
    nexti = Map[i]
    GroupFlag[nexti-1] = 1
GroupFlag[0] = 1
NN = sum(GroupFlag)
K = K%NN
if K == 0:
    K = NN

rt = [0]*K

def trip(self, steps):
    ntown = Map[self-1]
    if steps == K:
        return ntown
    rt[steps]=trip(ntown,steps+1)


    
Ft = trip(1,0)
print(rt[K-1])

Buggy submission (verdict: Runtime Error):
tmp = input().split()
N = int(tmp[0])
K = int(tmp[1])

tmp = input().split()

Map = [0]*N
K = K%N
rt = [0]*K

for i in range(N):
    Map[i] = int(tmp[i])

def trip(self, steps):
    ntown = Map[self-1]
    if steps == K:
        return ntown
    rt[steps]=trip(ntown,steps+1)


    
Ft = trip(1,1)
print(rt[K-1])
Problem p02690 (python)

Fixed submission:
X = input().split()
X = int(X[0])
ans = [0]*2

for i in range(-200,200):
    for j in range(-200,200):
        x = i**5 - j**5

        if x == X:
            ans = (i,j)
            break

print(' '.join(map(str,ans)))

Buggy submission (verdict: Runtime Error):
X = input().split()
X = int(X[0])
ans = [0]*2

for i in range(200):
    A5 = X+i**5
    ans[0] = pow(A5,0.2)
    if ans[0].is_integer():
        ans[0] = int(ans[0])
        ans[1] = int(i)
        break
    A5 = X-i**5
    ans[0] = pow(A5,0.2)
    if ans[0].is_integer():
        ans[0] = int(ans[0])
        ans[1] = -int(i)
        break

print(' '.join(map(str,ans)))
Problem p02922 (python)

Fixed submission:
import math
A,B = map(int,input().split())

print(math.ceil((B-1)/(A-1)))

Buggy submission (verdict: Runtime Error):
import math
A,B = map(int,input().split())

print(math.ceil((B-1)/(A-1)))
Problem p02630 (python)

Fixed submission:
import collections
#入力
N = int(input())
n = 100001
Alist = list(map(int,input().split()))
Q = int(input())
Blist = []
Clist = []
for i in range(Q):
  B, C = map(int,input().split())
  Blist.append(B)
  Clist.append(C)

Adic = dict(collections.Counter(Alist))
numlist = [0]*n

for j in range(n):
  if j in Adic:
    numlist[j] = Adic[j]
sum = sum(Alist)
for k in range(Q):
  sum += (Clist[k]-Blist[k])*numlist[Blist[k]]
  numlist[Clist[k]] += numlist[Blist[k]] 
  numlist[Blist[k]] = 0

  print(sum)

Buggy submission (verdict: Runtime Error):
import collections
#入力
N = int(input())
n = 100000
Alist = list(map(int,input().split()))
Q = int(input())
Blist = []
Clist = []
for i in range(Q):
  B, C = map(int,input().split())
  Blist.append(B)
  Clist.append(C)

Adic = dict(collections.Counter(Alist))
numlist = [0]*n

for j in range(n):
  if j in Adic:
    numlist[j] = Adic[j]
sum = sum(Alist)
for k in range(Q):
  sum += (Clist[k]-Blist[k])*numlist[Blist[k]]
  numlist[Clist[k]] += numlist[Blist[k]] 
  numlist[Blist[k]] = 0

  print(sum)
Problem p02657 (python)

Fixed submission:
A, B =map(int,input().split())
print(A*B)

Buggy submission (verdict: Runtime Error):
A, B =map(int,input())
print(A*B)
Problem p02658 (python)

Fixed submission:
import sys
N = int(input())
A_list = list(map(int,input().split()))
border = 10**18

if 0 in A_list:
  print(0)
  sys.exit()
else:
  A_list.sort(reverse=True)
  pro = 1
  for i in range(N):
    pro *= A_list[i]
    if pro > 10**18:
      print('-1')
      sys.exit()
    else:
      pass

print(pro)

Buggy submission (verdict: Runtime Error):
import math
from decimal import Decimal
N = int(input())
A_list = list(map(str,input().split()))
B_list = []

if '0' in A_list:
  print('0')
  
else:
  for i in range(N):
    logA = Decimal(A_list[i]).log10()
    B_list.append(logA)
 
sum = 0
pro = 1
for j in range(N):
  sum += B_list[j]

if sum > 18:
  print('-1')
else:
  for k in range(N):
    pro *=Decimal(A_list[k])
  print(pro)
Problem p02683 (python)

Fixed submission:
import numpy as np
N, M, X = map(int,input().split())
l = []
li = np.array([])
for i in range(N):
  l.append(list(map(int,input().split())))

li = np.array(l)

skill_sum = []
for j in range(2**N):
  sum = np.zeros([M+1])
  for k in range(N):
    if ((j >> k) & 1):
        sum += li[k] 
  skill_sum.append(list(sum))      
pricelist = []
for l in range(2**N):
  cnt = 0
  for m in range(M):
    if skill_sum[l][m+1] >= X:
      cnt += 1
  if cnt ==  M:
    pricelist.append(int(skill_sum[l][0]))

if pricelist == []:
  print('-1')
else:
  print(min(pricelist))

Buggy submission (verdict: Runtime Error):
import numpy as np
N, M, X = map(int,input().split())
l = []
li = np.array([])
for i in range(N):
  l.append(list(map(int,input().split())))

li = np.array(l)

skill_sum = []
for j in range(2**N):
  sum = np.zeros([M+1])
  for k in range(N):
    if ((j >> k) & 1):
        sum += li[k] 
  skill_sum.append(list(sum))      
pricelist = []
for l in range(2**N):
  cnt = 0
  for m in range(M):
    if skill_sum[l][m+1] >= X:
      cnt += 1
  if cnt ==  M:
    pricelist.append(int(skill_sum[l][0]))
    
print(min(pricelist))
Problem p02705 (python)

Fixed submission:
import math
R=float(input())
L=2*math.pi*R
print(L)

Buggy submission (verdict: Runtime Error):
import math
R=float(import())
L=2*math.pi*R
Problem p02702 (python)

Fixed submission:
S = input()
counts =[0] * 2019
counts[0] = 1
num, d = 0,1

for s in S[::-1]:
  num += int(s) *d
  d *= 10
  num %= 2019
  d %= 2019
  counts[num] += 1

ans = 0
for count in counts:
  ans += count * (count - 1) //2
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()

N = len(S)

mod2019 = []
ans = 0

for _ in range(N+1):
  mod2019.append(0)


count = []
for _ in range(2019):
  count.append(0)



for i in range(1,N+1):
  Smod = mod2019[i-1] + int(S[N-i])*10**(i-1)
  mod2019.append(Smod%2019)
  count[Smod%2019] += 1


for i in range(2019):
  ans += ((count[i])*(count[i])-1))//2



print(ans)
Problem p02983 (python)

Fixed submission:
L, R  = map(int, input().split())

if (2019-(L%2019))+L <= R:
  print(0)

else:
  ans = 2019
  for i in range(L,R):
    for j in range(i+1,R+1):
      ans = min(ans,(i*j)%2019)
  print(ans)

Buggy submission (verdict: Runtime Error):
L, R  = map(int, input().split())

if (2019-(L%2019))+L <= R:
  print(0)

else:
  print(L * (L+1))%2019
Problem p03087 (python)

Fixed submission:
N, Q  = map(int, input().split())
S = list(input())
Lsub = [0]
Rsub = [0]
L = 0
R = 0


for k in range(1,N):
  if S[k-1] == "A" and S[k] == "C":
    L += 1
  Lsub.append(L)

for j in range(0,N-1)[::-1]:
  if S[j] == "A" and S[j+1] == "C":
    R += 1
  Rsub.append(R)


for i in range(Q):
  L, R = map(int, input().split())
  print(Rsub[N-1] - Lsub[L-1] - Rsub[N-R])

Buggy submission (verdict: Runtime Error):
N, Q  = map(int, input().split())
S = list(input())
Lsub = [0] * N
Rsub = [0] * N
L = 0
R = 0


for k in range(1,N):
  if SS[k-1] == "A" and SS[k] == "C":
    L += 1
  Lsub[k] = L

for j in (0,N-1)[::-1]:
  if SS[j] == "A" and SS[j+1] == "C":
    R += 1
  Rsub[j] = R


for i in range(Q):
  L, R = map(int, input().split())
  print(Rsub[0] - Lsub[L-1] - Rsub[R-1])

Buggy submission (verdict: Runtime Error):
N, Q  = map(int, input().split())
S = list(input())
Lsub = [0] * N
Rsub = [0] * N
L = 0
R = 0


for k in range(1,N):
  if SS[k-1] == "A" and SS[k] == "C":
    L += 1
  Lsub[k] = L

for j in reversed(range(0,N-1)):
  if SS[j] == "A" and SS[j+1] == "C":
    R += 1
  Rsub[j] = R
  

for i in range(Q):
  L, R = map(int, input().split())
  print(Rsub[0] - Lsub[L-1] - Rsub[R-1])

Buggy submission (verdict: Runtime Error):
N, Q  = map(int, input().split())
S = list(input())
Lsub = [0]*N
Rsub = [0]*N
L = 0
R = 0


for j in range(1,N):
  if SS[j-1] == "A" and SS[j] == "C":
    L += 1
  Lsub[j] = L

for j in reversed(range(0,N-1)):
  if SS[j] == "A" and SS[j+1] == "C":
    R += 1
  Rsub[j] = R



ans = [0] * Q

for i in range(Q):
  L, R = map(int, input().split())
  ans[i] = Rsub[0] - Lsub[L-1] - Rsub[R-1]


for i in range(Q):
  print(ans[i])

Buggy submission (verdict: Runtime Error):
N, Q  = map(int, input().split())
S = list(input())
Lsub = [0]*N
Rsub = [0]*N
L = 0
R = 0


for j in range(1,N):
  if SS[j-1] == "A" and SS[j] == "C":
    L += 1
  Lsub[j] = L

for j in reversed(range(0,N-1)):
  if SS[j] == "A" and SS[j+1] == "C":
    R += 1
  Rsub[j] = R



ans = [0] * Q

for i in range(Q):
  L, R = map(int, input().split())
  ans[i] = Rsub[0] - Lsub[L-1] - Rsub[R-1]


for i in range(Q):
  print(ans[i])
Problem p03138 (python)

Fixed submission:
import math

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

B = [[0] * 2 for _ in range(40)]

for i in range(N):
  Ai = A[i]
  for j in range(40):
    if Ai % 2 == 0:
      B[j][0] += 1
    else :
      B[j][1] += 1
    Ai = Ai // 2
    #print(B)

Xmax = 0
if K != 0:

  Kd = int(math.log2(K))+1

  for i in range(Kd-1,-1,-1):
    if B[i][0] > B[i][1]:
      Xmax += 2**i
      if Xmax > K:
        Xmax -= 2**i
    
ans = 0
for i in range(N):
  ans += Xmax ^ A[i]

print(ans)

Buggy submission (verdict: Runtime Error):
import math

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

B = [[0] * 2 for _ in range(40)]

for i in range(N):
  Ai = A[i]
  for j in range(40):
    if Ai % 2 == 0:
      B[j][0] += 1
    else :
      B[j][1] += 1
    Ai = Ai // 2
    #print(B)

Xmax = 0
if K != 0:

  Kd = int(math.log2(K))+1

  for i in range(Kd-1,-1,-1):
    if B[i][0] > B[i][1]:
      Xmax += 2**i
      if Xmax > K:
        Xmax -= 2**i
    
ans = 0
for i in range(N):
  ans += Xmax ^ A[i]

print(ans)
Problem p03486 (python)

Fixed submission:
s = input()
s_asc = ''.join(sorted(s))
t = input()
t_desc = ''.join(sorted(t, reverse=True))

if s_asc < t_desc:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s = input()
s_asc = ''.join(sorted(s))
t = input8)
t_desc = ''.join(sorted(t, reverse=True))

if s_asc < t_desc:
    print('Yes')
else:
    print('No')
Problem p02657 (python)

Fixed submission:
A, B = map(int, input().split())
print(A * B)

Buggy submission (verdict: Runtime Error):
A, B = input().split()
print(A * B)
Problem p02658 (python)

Fixed submission:
def main():
  n = input()
  a = tuple(map(int, input().split()))

  if 0 in a:
    print(0)
    return
  
  ans = a[0]
  a2 = a[1:]
  for i in a2:
    ans = ans * i
    if ans > 1000000000000000000:
      print(-1)
      return

  print(ans)

main()

Buggy submission (verdict: Runtime Error):
a = ()
n = input()
a = map(int, input().split())

ans = a[0]
a2 = a[1:]
for i in a2:
  ans = ans * i

if ans > 10e+18:
  ans = -1

print(ans)
Problem p02641 (python)

Fixed submission:
X, N = map(int, input().split(" "))
if N == 0:
  print(X)
  exit()
else:
  p = list(map(int, input().split(" ")))
  c = 0
  for i in range(200):
    if i+1 not in p:
      if abs(X-(i+1)) < abs(X-c):
        c = i+1
      else:
        print(c)
        exit()

Buggy submission (verdict: Runtime Error):
XX, N = map(int, input().split(" "))
if N == 0:
  print(X)
  exit()
else:
  p = list(map(int, input().split(" ")))
  c = -1
  for i in range(100):
    if i+1 not in p:
      if abs(X-(i+1)) < abs(X-c):
        c = i+1
      else:
        print(c)
        exit()
Problem p03574 (python)

Fixed submission:
H, W = map(int,input().split(' '))
S = []
for i in range(H):
  S.append(input())
for j in range(H):
  answer = list(S[j])
  for k in range(W):
    cnt = 0
    if S[j][k] == '#':
      pass
    if S[j][k] == '.':
      if j-1 >= 0:
        if k-1 >= 0:
          if S[j-1][k-1] == '#':
            cnt += 1
        if S[j-1][k] == '#':
          cnt += 1
        if k+1 <= W-1:
          if S[j-1][k+1] == '#':
            cnt += 1
      if k-1 >= 0:
        if S[j][k-1] == '#':
          cnt += 1
      if k+1 <= W-1:
        if S[j][k+1] == '#':
          cnt += 1
      if j+1 <= H-1:
        if k-1 >= 0:
          if S[j+1][k-1] == '#':
            cnt += 1
        if S[j+1][k] == '#':
          cnt += 1
        if k+1 <= W-1:
          if S[j+1][k+1] == '#':
            cnt += 1
      answer[k] = str(cnt)
  print(''.join(answer))

Buggy submission (verdict: Runtime Error):
H, W = map(int,input().split(' '))
S = []
for i in range(H):
  S[i] = input()
for j in range(H):
  cnt = 0
  for k in range(W):
    if S[j][k] == '.'
      if S[j-1][k-1] == '#':
        cnt += 1
      if S[j-1][k] == '#':
        cnt += 1
      if S[j-1][k+1] == '#':
        cnt += 1
      if S[j][k-1] == '#':
        cnt += 1
      if S[j][k+1] == '#':
        cnt += 1
      if S[j+1][k-1] == '#':
        cnt += 1
      if S[j+1][k] == '#':
        cnt += 1
      if S[j][k+1] == '#':
        cnt += 1
      S[j][k].replace(cnt)
Problem p02628 (python)

Fixed submission:
N,K = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
count = 0
if len(p) >= K:
    for i in range(K):
        count = count + p[i]
else:
    for i in p:
        count = count + i
        
print(count)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
if len(p) >= 3:
    print(p[0]+p[1]+p[2])
else if len(p) == 2:
    print(p[0] + p[1])
else:
    print(p[0])

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

print(p[0]+p[1]+p[2])

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
p = list(map(int,input().split()))
sorted(p)
print(p[0]+p[1]+p[2])