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

Fixed submission:
S = input()
S2 = []
S3 = []
S4 = []
range1 = int((int(len(S))+1)/2)
range2 = int((int(len(S))-1)/2)
range3 = int((range2+1)/2)
range4 = int((int(len(S))+3)/2)
range5 = int((range4+1)/2)
isStrong = "Yes"
for i in S:
  S2.append(i)
  
for i in range(range2):
  S3.append(S2[i])
  
for i in range(range4-1,len(S)):
  S4.append(S2[i])
  
for i in range(range1):
  if S2[i]!=S2[-i-1]:
    isStrong = "No"

for i in range(range3):
  if S3[i]!=S3[-i-1]:
    isStrong = "No"

for i in range(range5-1):
  if S4[i]!=S4[-i-1]:
    isStrong = "No"
    
print(isStrong)

Buggy submission (verdict: Runtime Error):
S = input()
S2 = []
S3 = []
S4 = []
range1 = int((int(len(S))+1)/2)
range2 = int((int(len(S))-1)/2)
range3 = int((range2+1)/2)
range4 = int((int(len(S))+3)/2)
range5 = int((range4+1)/2)
isStrong = "Yes"
for i in S:
  S2.append(i)
  
for i in range(range2):
  S3.append(S2[i])
  
for i in range(range4-1,len(S)):
  S4.append(S2[i])
  
for i in range(range1):
  if S2[i]!=S2[-i-1]:
    isStrong = "No"

for i in range(range3):
  if S3[i]!=S3[-i-1]:
    isStrong = "No"

for i in range(range5):
  if S4[i]!=S4[-i-1]:
    isStrong = "No"
    
print(isStrong)
Problem p02922 (python)

Fixed submission:
a,b = map(int,input().split())
n = 1
c = 0
while n < b:
    n += a-1
    c += 1
print(c)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input(),split())
n = 1
c = 0
while n < b:
    n += a-1
    c += 1
print(c)
Problem p02885 (python)

Fixed submission:
A, B = map(int, input().split())
 
if A <= B*2:
  print(0)
else:
  print(A - B*2)

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

if A =< B*2:
  print(0)
else:
  print(A - B*2)
Problem p02887 (python)

Fixed submission:
N = int(input())
S = list(input())
 
list = []
 
for i in range(len(S)):
  if len(list) == 0:
    list.append(S[i])
  else:
    if list[-1] == S[i]:
      continue
    else:
      list.append(S[i])


print(len(list))

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

list = []
befor

for i in len(S):
  if len(list) == 0:
    list.append(S[i])
  else:
    if list[-1] == S[i]:
      continue
    else:
      list.append(S[i])
print(len(list))
Problem p02911 (python)

Fixed submission:
get = list(map(int, input().split()))

N = get[0]
K = get[1]
Q = get[2]

list = [0]*N

for i in range(Q):
  list[int(input()) - 1] += 1 

for i in range(N):
  if K - (Q - list[i]) > 0:
    print("Yes")
  else:
    print("No")

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

N = get[0]
K = get[1]
Q = get[2]

point = [K]*N

for i in range(Q):
  A = input()
  A = int(A)
  for j in range(Q):
    if (A - 1) != j:
      point[j] += -1

for i in range(Q):
  if point[i] > 0:
    print("Yes")
  else:
    print("No")
Problem p02927 (python)

Fixed submission:
A = list(map(int, input().split()))
 
M = A[0]
D = A[1]
count = 0
 
for i in range(4,M+1):
  for j in range(22,D+1):
    day = list(str(j))
    m10 = int(day[0])
    m1 = int(day[1])
    if m10 < 2:
      continue
    elif m1 < 2:
      continue
    
    if i == m10 * m1:
      count+=1
    
  
 
print(count)

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

N = A[0]
K = A[1]
count = 0
 
list = []
 
for i in range(N):
  for j in range(i,N):
    if B[i] > B[j]:
      count+=1


for sabun in range(1,K):
    count = count*sabun + count
    
count = count%(10**9 + 7)
print(count)

Buggy submission (verdict: Runtime Error):
A = list(map(int, input().split()))
B = list(map(int, input().split()))
 
N = A[0]
K = A[1]
count = 0
 
list = []

for i in range(N):
  for j in range(i,N):
    if B[i] > B[j]:
      count+=1

count = count*K
  
count = count%(10**9 + 7)
print(count)
Problem p02945 (python)

Fixed submission:
a, b = map(int, input().split())
 
plus = a + b
 
minus = a - b
 
kakeru = a * b

list = [plus, minus, kakeru]

print(max(list))

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().splitf())
 
plus = a + b
 
minus = a - b
 
kakeru = a * b
 
 
if plus >= minus:
  if plus >= kakeru:
    print(plus)
elif minus >= kakeru:
  print(minus)
else:
  print(kakeru)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().splitf(' '))
 
plus = a + b
 
minus = a - b
 
kakeru = a * b
 
 
if plus >= minus:
  if plus >= kakeru:
    print(plus)
elif minus >= kakeru:
  print(minus)
else:
  print(kakeru)

Buggy submission (verdict: Runtime Error):
a, b = input().splitf(' ')

plus = a + b

minus = a - b

kakeru = a * b


if plus >= minus:
  if plus >= kakeru:
    print(plus)
elif minus >= kakeru:
  print(minus)
else:
  print(kakeru)
Problem p02946 (python)

Fixed submission:
a, b = map(int, input().split())

start = b-a+1
loop = (a*2) -1

for i in range(loop):
    print(start + i ,end=" ")

Buggy submission (verdict: Runtime Error):
K, X = map(int, input().split())
 
minus = K - 1
list = []
for i in Range(test):
  list.append(X - (K - i))
  
list.append(X)
 
for j in Range(plus):
  list.append(X + j)
  
for aaa in list:
  print(aaa + " ")

Buggy submission (verdict: Runtime Error):
K, X = map(int, input().split())
 
minus = K - 1
 
for i in Range(test):
  print(X - (K - i))

plus = minus + 1

for j in Range(plus):
  print(X + j)

Buggy submission (verdict: Runtime Error):
K, X = map(int, input().split())
 
test = K - 1
 
for i in Range(test):
  print(X - (K - i))


test = test + 1  

for j in Range(test):
  print(X + j)

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

max = K - 1

for i in Range(max):
  print(X - (K - i))

print(X)

for j in Range(max - 1):
  print(X + j + 1)
Problem p02696 (python)

Fixed submission:
import math
A, B, N=list(map(int, input().split()))
if B > N:
    X = N
else:
    X = B-1

Ans = math.floor(A*X/B) - A * math.floor(X/B)
print(Ans)

Buggy submission (verdict: Runtime Error):

A, B, N=list(map(int, input().split()))
if B > N:
    X = N
else:
    X = B-1

Ans = math.floor(A*X/B) - A * math.floor(X/B)
print(Ans)
Problem p02705 (python)

Fixed submission:
import math
r = float(input())
s = r * 2 * math.pi
print (s)

Buggy submission (verdict: Runtime Error):
N = int(input())
ListA = list(map(int,input().split()))
for x in range(1 , N + 1):
    print(ListA.count(x))
Problem p02700 (python)

Fixed submission:
A,B,C,D = map(int,input().split())

while C > 0 and A > 0:
    C -= B
    A -= D
    if C <= 0:
        print("Yes")
    elif A <= 0:
        print("No")
    else:
        pass

Buggy submission (verdict: Runtime Error):
while C > 0 and A > 0:
    C -= B
    A -= D
    if C <= 0:
        print("Yes")
    elif A <= 0:
        print("No")
    else:
        pass
Problem p02677 (python)

Fixed submission:
import math

def main():

    a,b,h,m = map(int,input().split())
    kakub = 6.0*m
    kakua = 30.0*h + (30.0*(m/60.0))
    maxx = max(kakua,kakub)
    minn = min(kakua,kakub)
    if (maxx - 180.0) > minn:
        aug = (360.0 - maxx) + minn
    elif (maxx - 180.0) < minn:
        aug = maxx - minn
    else:
        aug = 180.0
    
    if aug == 180.0:
        ans=a+b
        print(ans)
    
    else: 
        ans = (a**2.0) + (b**2.0) -( (2.0*a*b)*math.cos(math.radians(aug)) )
        print(math.sqrt(ans))



if __name__=='__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math

def main():

    a,b,h,m = map(int,input().split())
    kakub = 6.0*m
    kakua = 30.0*h + (30.0*(m/60.0))
    maxx = max(kakua,kakub)
    minn = min(kakua,kakub)
    if (maxx - 180.0) > minn:
        aug = (360.0 - maxx) + minn
    elif (maxx - 180.0) < minn:
        aug = maxx - minn

    ans = (a**2.0) + (b**2.0) -( (2.0*a*b)*math.cos(math.radians(aug)) )
    print(math.sqrt(ans))



if __name__=='__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math

def main():

    a,b,h,m = map(int,input().split())
    kakub = 6.0*m
    kakua = 30.0*h + (30.0*(m/60.0))
    maxx = max(kakua,kakub)
    minn = min(kakua,kakub)
    if (maxx - 180.0) > minn:
        aug = (360.0 - maxx) + minn
    elif (maxx - 180.0) < minn:
        aug = maxx - minn

    ans = (a**2) + (b**2) -( (2*a*b)*math.cos(math.radians(aug)) )
    print(math.sqrt(ans))



if __name__=='__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math

def main():

    a,b,h,m = map(int,input().split())
    kakub = 6*m
    kakua = 30*h + (30*(m/60))
    maxx = max(kakua,kakub)
    minn = min(kakua,kakub)
    if (maxx - 180.0) > minn:
        aug = (360.0 - maxx) + minn
    elif (maxx - 180.0) < minn:
        aug = maxx - minn

    ans = (a**2) + (b**2) -( (2*a*b)*math.cos(math.radians(aug)) )
    print(math.sqrt(ans))



if __name__=='__main__':
    main()
Problem p02684 (python)

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))

l = [1]
for i in range(n):
    l.append(a[l[i] - 1])

p = l.index(l[n])

if k <= n:
    print(l[k])
else:
    x = (k - n + 1) % (n - p)
    if x == 0:
        print(l[n - 1])
    else:
        print(l[x + p - 1])

Buggy submission (verdict: Runtime Error):
def main():

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

    zzz=[]
    oioi=0
    flg=False

    for i in range(1,n+1):
        oioi = a[oioi]-1
        zzz.append(oioi)
        if oioi == 0:
            break
        if oioi in zzz:
            flg=True
            ppp=zzz.index(oioi)
            qqq=len(zzz)
            li=zzz
            del zzz[0:ppp+1]
            break


    
    if k>=qqq and flg:
        print(zzz[(k+ppp)%len(zzz)-1]+1)
    elif k<=qqq and flg:
        print(li[k-1]+1)
    else:    
        print(zzz[k%len(zzz)-1]+1)

    

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():

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

    zzz=[]
    oioi=0
    flg=True

    for i in range(n):
        oioi = a[oioi]-1
        
        if oioi == 0:
            zzz.append(oioi)
            break
        if oioi in zzz:
            flg=False
            ppp=zzz.index(oioi)
            del zzz[0:ppp+1]
            zzz.append(oioi)
            break
    
    if flg == False:
        print(zzz[(k+ppp)%len(zzz)-1]+1)
    else:
        print(zzz[k%len(zzz)-1]+1)

    
if __name__ == '__main__':
    main()
Problem p02732 (python)

Fixed submission:
n = int(input())
l = list(map(int, input().split()))

import collections
 
c = collections.Counter(l)
ans = 0

for i in c.values():
    ans += i * (i - 1) // 2
    
for i in l:
    print(ans - c[i] + 1)

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

import collections
 
c = collections.Counter(l)

for i in c.values():
    ans += i * (i - 1) // 2
    
for i in l:
    print(ans - c[i] - 1)

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

import collections
 
c = collections.Counter(l)

for i in c.values():
    ans += i * (i - 1) // 2
    
for i in l:
    print(ans - c[i] - 1)
Problem p02678 (python)

Fixed submission:
from collections import deque

N, M = map(int, input().split())
graph = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    graph[a].append(b)
    graph[b].append(a)
    
dist = [-1] * N
dist[0] = 0
    
queue = deque([0])

while queue:
    v = queue.popleft()
    for nv in graph[v]:
        if (dist[nv] != -1):
            continue
        dist[nv] = v
        queue.append(nv)
        
print("Yes")
for i in dist[1:]:
    print(i+1)

Buggy submission (verdict: Runtime Error):
from collections import deque

N, M = map(int, input().split())
graph = [[] for i in range(M)]
for i in range(M):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    graph[a].append(b)
    graph[b].append(a)
    
dist = [-1] * N
dist[0] = 0
    
queue = deque([0])

while queue:
    v = queue.popleft()
    for nv in graph[v]:
        if (dist[nv] != -1):
            continue
        dist[nv] = v
        queue.append(nv)

print("Yes")
for i in dist[1:]:
    print(i+1)
Problem p02787 (python)

Fixed submission:
H, N = map(int, input().split())
A, B = [], []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
    
A, B = zip(*sorted(zip(A, B)))

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

for dmg in range(1, 10000 + 1):
    dp[1][dmg] = -(-dmg // A[0]) * B[0]

for index in range(1, N + 1):
    a, b = A[index-1], B[index-1]
    for dmg in range(1, 10000 + 1):
        ahead = dp[index-1][dmg] #前回
        if dmg - a < 0:
            only = -(-dmg // a) * b
        else:
            only = dp[index][dmg - a] + b #自分だけ
        dp[index][dmg] = min(ahead, only)
print(min(dp[N][H:]))

Buggy submission (verdict: Runtime Error):
H, N = map(int, input().split())
A, B = [], []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
    
A, B = zip(*sorted(zip(A, B)))

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

for dmg in range(1, H + 1):
    dp[1][dmg] = -(-dmg // A[0]) * B[0]

for index in range(1, N + 1):
    a, b = A[index-1], B[index-1]
    for dmg in range(1, H + 1):
        ahead = dp[index-1][dmg] #前回
        only = dp[index][dmg - a] + b #自分だけ
        dp[index][dmg] = min(ahead, only)
print(dp[N][H])
Problem p03061 (python)

Fixed submission:
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a


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

# 累積最大公約数的な
head = []
tail = []
head.append(A[0])
tail.append(A[-1])
for i, j in zip(A[1:], A[N-2::-1]):
    head.append(gcd(head[-1], i))
    tail.append(gcd(tail[-1], j))
ans = 0
for i in range(len(head)-2):
    tmp = gcd(head[i], tail[len(tail)-1-2-i])
    if ans < tmp:
        ans = tmp
print(max(head[-1], head[-2], tail[-2], ans))

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

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

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

max_ans = 0
for i in range(len(A)):
    tmp = A[:i] + A[1+i:]
    ans = gcd_list(tmp)
    if max_ans < ans:
        max_ans = ans
print(max_ans)
Problem p03076 (python)

Fixed submission:
AE = []
for i in range(5):
    AE.append(int(input()))

ans = 0
mini = []
for i in AE:
    if(i%10 == 0):
        ans += i
    else:
        ans += (i//10 + 1)*10
        mini.append(i%10)
if(mini != []):
    print(ans + min(mini) - 10)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
AE = []
for i in range(5):
    AE.append(int(input()))

ans = 0
mini = []
for i in AE:
    if(i%10 == 0):
        ans += i
    else:
        ans += (i//10 + 1)*10
        mini.append(i%10)
print(ans + min(mini) - 10)
Problem p03280 (python)

Fixed submission:
ab = input().split()
print((int(ab[0])-1)*(int(ab[1])-1))

Buggy submission (verdict: Runtime Error):
ab = raw_input().split()
print((int(ab[0])-1)*(int(ab[1])-1))

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
print((A-1)*(B-1))
Problem p03281 (python)

Fixed submission:
N = int(input())
countans = 1
if(N < 105):
  print(0)
elif(N < 107):
    print(1)
else:
    for i in range(107, N+1, 2):
        count = 1
        for j in range(1, int(N/2)):
            if(i%j == 0):
                count += 1
        if(count == 8):
            countans += 1
    print(countans)

Buggy submission (verdict: Runtime Error):
N = int(input())
if(N >= 105):
  print(!)
else:
  print(0)
Problem p03302 (python)

Fixed submission:
a = input()
b = a.split()

if(int(b[0]) + int(b[1]) == 15):
    print('+')
elif(int(b[0]) * int(b[1]) == 15):
    print('*')
else:
    print('x')

Buggy submission (verdict: Runtime Error):
a = input()
b = a.split()

if(b[0] + b[1] == 15):
    print('+')
elif(b[0] * b[1] == 15):
    print('*')
else:
    print('x')
Problem p03303 (python)

Fixed submission:
S = input()
w = input()
w = int(w)
ans = ''

for i in range(0, len(S), w):
    lit = S[i:i+w]
    ans = ans + lit[0]

print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
w = input()
ans = ''

for i in range(0, len(S), w):
    lit = S[i:i+w]
    ans = ans + lit[0]

print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
w = input()
ans = ''

for i in range(0, len(S), w):
    lit = S[i:i+w]
    ans = ans + lit[0]

print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
w = input()
ans = ''

for i in range(0, w, len(S)):
    lit = S[i:i+w]
    ans = ans + lit[0]
Problem p02969 (python)

Fixed submission:
r = int(input())
print(3*(r**2))

Buggy submission (verdict: Runtime Error):
r = int(input())
print(3*(a**2))

Buggy submission (verdict: Runtime Error):
r = int(input())
print(3*a**2)
Problem p02983 (python)

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

for i in range(L, R) :
	for j in range(i + 1, R + 1) :
		if((i * j) % 2019 < mod) :
			mod = (i * j) % 2019
			x = ((i * j) // 2019) * 2019 + 2019
			if(x > i * R) :
				break
			else :
				pass
		elif(mod == 0) :
			break
		else :
			pass
	if(mod == 0) :
		break
	else :
		pass
	
print(mod)

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

@functools.lru_cache(maxsize = None)
for i in range(L, R) :
	for j in range(i + 1, R + 1) :
		if((i * j) % 2019 < mod) :
			mod = (i * j) % 2019
		else :
			pass
	if(mod == 0) :
		break
	else :
		pass
	
print(mod)

Buggy submission (verdict: Runtime Error):
import functools

L, R = map(int, input().split())
mod = 2019

@functools.lru_cache(maxsize = None)
for i in range(L, R) :
	for j in range(i + 1, R + 1) :
		if((i * j) % 2019 < mod) :
			mod = (i * j) % 2019
		else :
			pass
	if(mod == 0) :
		break
	else :
		pass
	
print(mod)
Problem p03423 (python)

Fixed submission:
print (lambda x:x/3)(input())

Buggy submission (verdict: Runtime Error):
print (lambda x:x/3)(input())
Problem p03480 (python)

Fixed submission:
import sys
l = list(raw_input())
if (not "0" in l) or (not "1" in l):
    print len(l)
    sys.exit()

s = l[0]
f = False
mx = 0
x = 0
for i, n in enumerate(l):
    if not n == s:
        mx = max(mx, min(i, len(l)-x))
        x = i
        s = n
mx = max(mx, min(i, len(l)-x))
print mx

Buggy submission (verdict: Runtime Error):
mx = max(mx, min(i, len(l)-x))
Problem p03496 (python)

Fixed submission:
n = input()
num = map(int, raw_input().split())
ma = max(num)
mi = min(num)
l = list()
if ma*mi < 0:
    if ma > abs(mi):
        index = num.index(ma)
    else:
        index = num.index(mi)
    for i in xrange(n):
        l.append("%d %d" % (index+1, i+1))
    b = num[index]
else:
    b = 0
    for i in num:
        if i:
            b = i
            break

if b == 0:
    pass
elif b < 0:
    for i in xrange(n-1, 0, -1):
        l.append("%d %d" % (i+1, i))
else:
    for i in xrange(0, n-1):
        l.append("%d %d" % (i+1, i+2))

print len(l)
for i in l:
    print i

Buggy submission (verdict: Runtime Error):
import random
import copy
n = input()
ori = map(int, raw_input().split())
num = copy.deepcopy(ori)
while not sorted(num) == num:
    l = list()
    for i in xrange(n*2):
        if sorted(num) == num:
            break
        a = random.randint(0, n-1)
        b = random.randint(0, n-1)
        num[b] += num[a]
        l.append("%d %d" % ((a+1), (b+1)))
    else:
        num = copy.deepcopy(ori)

print len(l)
for i in l:
    print i
print num

Buggy submission (verdict: Runtime Error):
import random
import copy
n = input()
ori = map(int, raw_input().split())
num = copy.deepcopy(ori)
while not sorted(num) == num:
    l = list()
    for i in xrange(n*2):
        if sorted(num) == num:
            break
        a = random.randint(0, n-1)
        b = random.randint(0, n-1)
        num[a] += num[b]
        l.append("%d %d" % ((a+1), (b+1)))
    else:
        num = copy.deepcopy(ori)

print len(l)
for i in l:
    print i

Buggy submission (verdict: Runtime Error):
import random
import copy
n = input()
ori = map(int, raw_input().split())
num = copy.deepcopy(ori)
while not sorted(num) == num:
    l = list()
    for i in xrange(n*2):
        if sorted(num) == num:
            break
        a = random.randint(0, n-1)
        b = random.randint(0, n-1)
        num[a] += num[b]
        l.append("%d %d" % ((a+1), (b+1)))
    else:
        num = copy.deepcopy(ori)

print len(l)
for i in l:
    print i
print num

Buggy submission (verdict: Runtime Error):
import random
n = input()
num = map(int, raw_input().split())
while not sorted(num) == num:
    l = list()
    for i in xrange(n*2):
        if sorted(num) == num:
            break
        a = random.randint(0, n-1)
        b = random.randint(0, n-1)
        num[a] += num[b]
        l.append("%d %d" % ((a+1), (b+1)))

print len(l)
for i in l:
    print i
Problem p03574 (python)

Fixed submission:
h, w = map(int, raw_input().split())
table = list()
table.append([0]*(w+2))
for _ in xrange(h):
    table.append([0]+list(map(lambda c:0 if c == "." else c, list(raw_input())))+[0])
table.append([0]*(w+2))

xy = [0, 1, 0, -1, 1, 1, -1, -1, 0]
for i in xrange(1, h+1):
    for j in xrange(1, w+1):
        if table[i][j] == "#":
            for k in xrange(8):
                if type(table[i+xy[k]][j+xy[k+1]]) == type(int()):
                    table[i+xy[k]][j+xy[k+1]] += 1


for i in xrange(1, h+1):
    print "".join(map(str, table[i][1:-1]))

Buggy submission (verdict: Runtime Error):
h, w = map(int, raw_input().split())
table = list()
table.append([0]*(w+2))
for _ in xrange(h):
    table.append([0]+list(map(lambda c:0 if c == "." else c, list(raw_input())))+[0])
table.append([0]*(w+2))

xy = [0, 1, 0, -1, 1, 1, -1, -1, 0]
for i in xrange(1, h+1):
    for j in xrange(1, w+1):
        if table[i][j] == "#":
            for k in xrange(8):
                table[i+xy[k]][j+xy[k+1]] += 1


for i in xrange(1, h+1):
    print "".join(map(str, table[i][1:-1]))
Problem p02664 (python)

Fixed submission:
str = input()
str = list(str)


for index, value in enumerate(str):
    if (value == '?' and index == len(str) - 1):
        str[index] = 'D'

    elif (value == '?' and index != 0 and str[index - 1] == 'P'):
        str[index] = 'D'

    elif (value == '?' and str[index + 1] == '?'):
        str[index] = 'P'
        str[index + 1] = 'D'
    elif (value == '?'):
    	str[index] = 'D'


print(''.join(str))

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


for index, value in enumerate(str):
    if (value == '?' and index == len(str) - 1):
        str[index] = 'D'

    elif (value == '?' and index != 0 and str[index -] == 'P'):
        str[index] = 'D'

    elif (value == '?' and str[index + 1] == '?'):
        str[index] = 'P'
        str[index + 1] = 'D'
    elif (value == '?'):
    	str[index] = 'D'


print(''.join(str))

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


for index, value in enumerate(str):
    if (value == '?' and index == len(str) - 1):
        str[index] = 'D'

    elif (value == '?' and index != 0 and str[index -] == 'P'):
        str[index] = 'D'

    elif (value == '?' and str[index + 1] == '?'):
        str[index] = 'P'
        str[index + 1] = 'D'
    elif (value == '?'):
    	str[index] = 'D'


print(''.join(str))
Problem p02663 (python)

Fixed submission:

h1, m1, h2, m2, k = map(int, input().split(" "))

start = h1*60+m1
end = h2*60+m2
total = end - start - k

print(total)

Buggy submission (verdict: Runtime Error):

h1, m1, h2, m2, k = map(int, input().split(" "))
A = list(map(int, input().split(" ")))

start = h1*60+m1
end = h2*60+m2
total = end - start - k

print(k)