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

Fixed submission:
from sys import stdin
s = stdin.readline()[:-1]

length = len(s)

dp = [[0 for i in range(13)]for j in range(100100)]

s = list(reversed(s))

dp[0][0]=1
ten = 1
mod = 1000000007


for i in range(length):
	if s[i] == '?':
		for num in range(10):
			d = num*ten
			for j in range(13):
				k = (j+d)%13
				dp[i+1][k] += dp[i][j]
				dp[i+1][k] %= mod
	else:
		num = int(s[i])
		d = num*ten
		for j in range(13):
			k = (j+d)%13
			dp[i+1][k] += dp[i][j]
			dp[i+1][k] %= mod
	ten *= 10
	ten %= 13

print(int(dp[length][5]%mod))

Buggy submission (verdict: Runtime Error):
import numpy as np
from sys import stdin
s = stdin.readline()[:-1]

length = len(s)

dp = [[0 for i in range(13)]for j in range(100100)]

s = list(reversed(s))

dp[0][0]=1
ten = 1
mod = 1000000007


for i in range(length):
	if s[i] == '?':
		for num in range(10):
			d = num*ten
			for j in range(13):
				k = (j+d)%13
				dp[i+1][k] += dp[i][j]
				dp[i+1][k] %= mod
	else:
		num = int(s[i])
		d = num*ten
		for j in range(13):
			k = (j+d)%13
			dp[i+1][k] += dp[i][j]
			dp[i+1][k] %= mod
	ten *= 10
	ten %= 13

print(int(dp[length][5]%mod))

Buggy submission (verdict: Runtime Error):
import numpy as np

s = input()

length = len(s)

dp = np.zeros((100100,13))

s = list(reversed(s))

dp[0][0]=1
ten = 1
mod = 1000000007


for i in range(length):
	if s[i] == '?':
		for num in range(10):
			d = num*ten
			for j in range(13):
				k = (j+d)%13
				dp[i+1][k] += dp[i][j]
				dp[i+1][k] %= mod
	else:
		num = int(s[i])
		d = num*ten
		for j in range(13):
			k = (j+d)%13
			dp[i+1][k] += dp[i][j]
			dp[i+1][k] %= mod
	ten *= 10
	ten %= 13

print(int(dp[length][5]%mod))

Buggy submission (verdict: Runtime Error):
import numpy as np

s = input()

length = len(s)

dp = np.zeros((100100,13))

s = list(reversed(s))

dp[0][0]=1
ten = 1
mod = 1000000007


for i in range(length):
	if s[i] == '?':
		for num in range(10):
			d = num*ten
			for j in range(13):
				k = (j+d)%13
				dp[i+1][k] += dp[i][j]
				dp[i+1][k] %= mod
	else:
		num = int(s[i])
		d = num*ten
		for j in range(13):
			k = (j+d)%13
			dp[i+1][k] += dp[i][j]
			dp[i+1][k] %= mod
	ten *= 10
	ten %= 13

print(int(dp[length][5]%mod))

Buggy submission (verdict: Runtime Error):
import numpy as np

s = input()

dp = np.zeros((100100,13))

s = list(reversed(s))

dp[0][0]=1
ten = 1
mod = 1000000007

length = len(s)

for i in range(length):
	if s[i] == '?':
		for num in range(10):
			for j in range(13):
				dp[i+1][(j+num*ten)%13] += dp[i][j]
				dp[i+1][(j+num*ten)%13] %= mod
	else:
		num = int(s[i])
		for j in range(13):
			dp[i+1][(j+num*ten)%13] += dp[i][j]
			dp[i+1][(j+num*ten)%13] %= mod
	ten *= 10
	ten %= 13

print(int(dp[length][5]%mod))
Problem p02972 (python)

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

cnt = [0]*200010

b = []

for i in reversed(range(n)):

	num = i + 1
	if cnt[num]%2 != a[num-1]:
		b.append(num)
		j = 1
		while j*j <= (num):
			if num%j==0 :
				cnt[j] += 1
				if num//j != j:
					cnt[num//j]+=1
			j = j +1


print(len(b))
b.sort()

for i in b:
	print(str(i)+' ',end='')

print()

Buggy submission (verdict: Runtime Error):
import sympy

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

cnt = [0]*200010

b = []

for i in reversed(range(n)):

	num = i + 1
	if cnt[num]%2 != a[num-1]:
		b.append(num)
		divs = sympy.divisors(num)

		for div in divs:
			cnt[div] += 1

print(len(b))
b.sort()

for i in b:
	print(str(i)+' ',end='')

print()
Problem p03044 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
N = int(input())

Graph = [[] for _ in range(N+10)]
dist  = [10000000000000]*(N+10)

for i in range(N-1):
	u,v,w = map(int,input().split())
	u-=1
	v-=1
	Graph[u].append((v,w))
	Graph[v].append((u,w))

dist[0] = 0

def func(fromE,now,length):
	if fromE != -1:
		dist[now] = dist[fromE]+length
	for i in range(len(Graph[now])):
		target = Graph[now][i][0]
		lengt  = Graph[now][i][1]

		if target == fromE:
			continue

		func(now,target,lengt)

func(-1,0,0)

for i in range(N):
	if dist[i]%2 == 0:
		print(0)
	else:
		print(1)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)
N = int(input())

Graph = [[] for _ in range(N)]
dist  = []*(N)

for i in range(N-1):
	u,v,w = map(int,input().split())
	u-=1
	v-=1
	Graph[u].append((v,w))
	Graph[v].append((u,w))


def func(fromE,now,length):
	dist[now] = length
	
	for i in range(len(Graph[now])):
		target = Graph[now][i][0]
		lengt  = Graph[now][i][1]

		if target == fromE:
			continue

		func(now,target,dist[now]+lengt)

func(-1,0,0)

for i in range(N):
	if dist[i]%2 == 0:
		print(0)
	else:
		print(1)

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

Graph = [[] for _ in range(N+10)]
dist  = [10000000000000]*(N+10)

for i in range(N-1):
	u,v,w = map(int,input().split())
	u-=1
	v-=1
	Graph[u].append((v,w))
	Graph[v].append((u,w))

dist[0] = 0

def func(fromE,now,length):
	if fromE != -1:
		dist[now] = dist[fromE]+length
	for i in range(len(Graph[now])):
		target = Graph[now][i][0]
		lengt  = Graph[now][i][1]

		if target == fromE:
			continue

		func(now,target,lengt)

func(-1,0,0)

for i in range(N):
	if dist[i]%2 == 0:
		print(0)
	else:
		print(1)

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

Graph = [[] for _ in range(N)]
dist  = [10000000000000]*(N)

for i in range(N-1):
	u,v,w = map(int,input().split())
	u-=1
	v-=1
	Graph[u].append((v,w))
	Graph[v].append((u,w))

dist[0] = 0

def func(fromE,now,length):
	if fromE != -1:
		dist[now] = dist[fromE]+length
	for i in range(len(Graph[now])):
		target = Graph[now][i][0]
		lengt  = Graph[now][i][1]

		if target == fromE:
			continue

		func(now,target,lengt)

func(-1,0,0)

for i in range(N):
	if dist[i]%2 == 0:
		print(0)
	else:
		print(1)
Problem p03074 (python)

Fixed submission:
from itertools import groupby

n,k = map(int,input().split())
s = input()


grouped = groupby (s)
res = []

if s[0] == '0':
	res.append((1,0))

for l,v in grouped:
	res.append( (l,len(list(v))) )

if s[len(s)-1] == '0':
	res.append((1,0))

#for d in res:
	#print(d)

if len(res) <= 2*k + 1:
	ans = 0;
	for d in res:
		ans += d[1];

	print(ans)
	exit()

now = 0
ans = 0
for i in range(2*k+1):
	now += res[i][1]

ans = max(ans,now)

for i in range(2*k+1,len(res),2):
	now -= res[i-2*k-1][1]
	now -= res[i-2*k][1]

	now += res[i][1]
	now += res[i+1][1]

	ans = max(ans,now)

print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import groupby

n,k = map(int,input().split())
s = input()

grouped = groupby(s)

res = []

if s[0] == '0':
	res.append((1,0))

for l,v in grouped:
	res.append( (l,len(list(v))) )

if s[len(s)-1] == '0':
	res.append((1,0))

now = 0
ans = 0
for i in range(2*k+1):
	now += res[i][1]

ans = max(ans,now)

for i in range(2*k+1,len(res),2):
	now -= res[i-2*k-1][1]
	now -= res[i-2*k][1]

	now += res[i][1]
	now += res[i+1][1]

	ans = max(ans,now)

print(ans)
Problem p03206 (python)

Fixed submission:
a = input()
if a == "25":
  print("Christmas")
elif a == "24":
  print("Christmas Eve")
elif a == "23":
  print("Christmas Eve Eve")
elif a == "22":
  print("Christmas Eve Eve Eve")

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
a,p=[1],[1] for i in range(N):
  a.append(a[i] * 2 + 3)
  p.append(p[i] * 2 + 1)
def f(N,X): #X<=0やX>a_Nを許容し解説本文から簡略化
  if N == 0:
    return 0 if X <= 0 else 1
  elif X <= 1 + a[N-1]:
    return f(N-1, X-1)
  else:
    return p[N-1] + 1 + f(N-1, X-2-a[N-1])
print(f(N, X))
Problem p03244 (python)

Fixed submission:
from collections import Counter

n = int(input())

e = []
o = []
for i, v in enumerate(input().split(' ')):
    if i % 2 == 0:
        e.append(int(v))
    else:
        o.append(int(v))

if len(set(e + o)) == 1:
    print(int(len(e + o) / 2))
    exit()

if Counter(o).most_common()[0][0] == Counter(e).most_common()[0][0]:
    ans = min(len(o) - Counter(o).most_common()[1][1] + len(e) - Counter(e).most_common()[0][1], len(o) - Counter(o).most_common()[0][1] + len(e) - Counter(e).most_common()[1][1])
    print(ans)
else:
    print(len(o) - Counter(o).most_common()[0][1] + len(e) - Counter(e).most_common()[0][1])

Buggy submission (verdict: Runtime Error):
import collections
n = int(input())
l = list(int(x) for x in input().split())
el = []
ol = []
for i in range(n):
  if i % 2 == 0:
    el.append(l[i])
  else:
    ol.append(l[i])
e1 = collections.Counter(el).most_common()[0][0]
e2 = collections.Counter(el).most_common()[1][0]
o1 = collections.Counter(ol).most_common()[0][0]
o2 = collections.Counter(ol).most_common()[1][0]
cnt1 = 0
cnt2 = 0
if e1 != o1:
  for i in range(n//2):
    if el[i] != e1:
      cnt1 += 1
    if ol[i] != o1:
      cnt1 += 1
  print(cnt1)
else:
  for i in range(n//2):
    if el[i] != e1:
      cnt1 += 1
    if ol[i] != o2:
      cnt1 += 1
    if el[i] != e2:
      cnt2 += 1
    if ol[i] != o1:
      cnt2 += 1
  print(min(cnt1,cnt2))
Problem p02921 (python)

Fixed submission:
S = list(input())
T = list(input())
ans = 0
for i in range(3):
  if S[i] == T[i]:
    ans += 1

print(ans)

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

l = len(H)
L = [0]
for i in range(l-1):
    if H[i] < H[i+1]:
        L.append(i)

L.append(l-1)

jump = [L[i+1] - L[i] - 1 for i in range(len(L)-1)]
print(max(jump))
Problem p02969 (python)

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

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for i in range(N)]
M = max(A)
c = A.count(M)
a = list(set(A))
a.sort(reverse=True)
 
for i in range(N):
  if A[i] != M:
    print(M)
  else:
    if c >= 2:
      print(M)
    else:
      print(a[1])
Problem p02971 (python)

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]
M = max(A)
c = A.count(M)
a = list(set(A))
a.sort(reverse=True)
 
for i in range(N):
  if A[i] != M:
    print(M)
  else:
    if c >= 2:
      print(M)
    else:
      print(a[1])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for i in range(N)]
M = max(A)
c = A.count(M)
a = list(set(A))
a.sort(reverse=True)

for i in range(N):
  if A[i] != M:
    print(M)
  elif:
    if c >= 2:
      print(M)
    elif:
      print(a[1])
Problem p03210 (python)

Fixed submission:
X = int(input())
if X == 7 or X == 5 or X == 3:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
s = input()
koho = []
for i in range(len(s)-2):
    S = int(s[i:i+3])
    sa = abs(S - 753)
    koho.append(sa)
print(min(koho))
Problem p03238 (python)

Fixed submission:
N = int(input())

if N == 1:
    print('Hello World')
else:
    A = int(input())
    B = int(input())
    print(A+B)

Buggy submission (verdict: Runtime Error):
N, T = map(int,input().split())
mincost = 1001
for i in range(1, N+1):
    c, t = map(int,input().split())
    if t <= T:
        cost = c
        if cost < mincost:
            mincost = cost

if mincost == 1001:
  print('TLE')
if mincost < 1001:
  print(mincost)

Buggy submission (verdict: Runtime Error):
N, T = map(int,input().split())
mincost = 1000
for i in range(1, N+1):
    c, t = map(int,input().split())
    if t <= T:
        cost = c
        if cost < mincost:
            mincost = cost

if mincost == 1000:
  print('TLE')
if mincost < 1000:
  print(mincost)

Buggy submission (verdict: Runtime Error):
N, T = map(int,input().split())
mintime = 1000
for i in range(1, N):
    c, t = map(int,input().split())
    if t <= T:
        time = t
        if time < mintime:
            mintime = time

print(mintime)
Problem p03243 (python)

Fixed submission:
N = int(input())
if N % 111 == 0:
  print(N)
for i in range(10):
  if N % 111 != 0 and N // 111 == i:
    print(111 * (i + 1) )

Buggy submission (verdict: Runtime Error):
N = int(input())
if N % 111 == 0:
  print(N)
for i in range(10):
  if N // 111 = i:
    print(111 * (i + 1) )
Problem p03292 (python)

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

print(a[2]-a[0])

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

if S == T:
    print('Yes')
l = len(S)
L = list(S)
for i in range(l):
    a = L[0]
    del L[0]
    L.append(a)
    s = ''.join(L)
    if s == T:
        print('Yes')
        break
else:
    print('No')

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

print(A[2]-A[0])
Problem p03293 (python)

Fixed submission:
S = input()
T = input()

if S == T:
    print('Yes')
else:
    l = len(S)
    L = list(S)
    for i in range(l):
        a = L[0]
        del L[0]
        L.append(a)
        s = ''.join(L)
        if s == T:
            print('Yes')
            break
    else:
        print('No')

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

if S == T:
    print(Yes)
l = len(S)
L = list(S)
for i in range(l):
    a = L[0]
    del L[0]
    L.append(a)
    s = ''.join(L)
    if s == T:
        print('Yes')
        break
else:
    print('No')
Problem p03416 (python)

Fixed submission:
A, B = map(int,input().split())
ans = 0
for i in range(A, B+1):
  str_i = str(i)
  if str_i[0] == str_i[4] and str_i[1] == str_i[3]:
    ans += 1
  else:
    continue

print(ans)

Buggy submission (verdict: Runtime Error):
A, B = map(int,input().split())
for i in range(A, B+1):
  str_i = str(i)
  if str_i[0] == str_i[4] and str_i[1] == str_i[2]:
    ans += 1
  else:
    continue

print(ans)
Problem p03493 (python)

Fixed submission:
print(input().count('1'))

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int, input().split()))
n=0
while all(a%2==0 for a in A):
    A=[a/2 for a in A]
    n+=1
print(n)
Problem p02898 (python)

Fixed submission:
n,k=map(int,input().split())
h=list(map(int,input().split()))
h=list(filter(lambda x:x >= k, h))
print(len(h))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
h=filter(lambda x => k, h)
print(len(h))
Problem p02924 (python)

Fixed submission:
import math
n = int(input())
print(math.floor(((n-1)*(n-1+1))//2))

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = [0] * n
for i in range(1,n):
  ans[i - 1] = i   
print(sum(ans))

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = [0] * n
for i in range(1,n):
  ans[i] = i
   
print(sum(ans))
Problem p02995 (python)

Fixed submission:
import sys
import math
from fractions import gcd

a,b,c,d = (int(i) for i in input().split())

c1 = b // c - (a - 1) // c
d1 = b // d - (a - 1) // d
cd = (c * d) //gcd(c,d)
cd1 = b // cd - (a - 1) // cd



print((b - a + 1) - c1 - d1 + cd1)

Buggy submission (verdict: Runtime Error):
import sys
import math
from fractions import gcd

a,b,c,d = (int(i) for i in input().split())

c1 = b // c - (a - 1) // c
d1 = b // d - (a - 1) // d
cd = (c * d) //math.gcd(c,d)
cd1 = b // cd - (a - 1) // cd



print((b - a + 1) - c1 - d1 + cd1)

Buggy submission (verdict: Runtime Error):
import sys
import math

a,b,c,d = (int(i) for i in input().split())

c1 = b // c - (a - 1) // c
d1 = b // d - (a - 1) // d
cd = (c * d) //math.gcd(c,d)
cd1 = b // cd - (a - 1) // cd


print((b - a + 1) - c1 - d1 + cd1)
Problem p03282 (python)

Fixed submission:
import sys
 
s=input()
k=int(input())
 
for i in range(len(s)):
  if s[i] != '1':
    print(s[i])
    break
  elif i == k - 1:
    print(1)
    break

Buggy submission (verdict: Runtime Error):
import sys

s=int(input())
k=int(input())

for i in range(len(s)):
  if s[i] != '1':
    print(s[i])
    break
  elif i == k - 1:
    break
Problem p03325 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
 
ans = 0
e = [i for i in a if i % 2 == 0]
for i in e:
  sum = 0
  while True:
    i = i / 2
    sum += 1
    if i % 2 != 0:
      break
  ans += sum
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
 
ans = 0
while True:
  e = [i for i in a if i % 2 == 0]
  #print(e)
  if len(e) != 0:
    e_max = max(e)
    a = [i / 2 if i == e_max else i * 3 for i in e]
    ans += 1
  else:
    break
print(ans)

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

ans = 0
while True:
  e_max = max([i for i in a if i % 2 == 0])
  if len(e_max) != 0:
    a = [i / 2 if i == e_max else i * 3 for i in a]
    ans += 1
print(ans)
Problem p03361 (python)

Fixed submission:
import sys
h,w = map(int,input().split())
s = ['']*h
for i in range(h):
  s[i] = input()
 
black = False
for i in range(h):
  for j in range(w):
    if s[i][j] == '#':
      if j != w - 1:
        if s[i][j + 1] == '#':
          continue
      if  j != 0:
        if s[i][j - 1] == '#':
          continue
      if i != h - 1:
        if s[i + 1][j] == '#':
          continue
      if i != 0:
        if s[i - 1][j] == '#':
          continue
      print('No')
      sys.exit()       
print('Yes')

Buggy submission (verdict: Runtime Error):
import sys
h,w = map(int,input().split())
s = ['']*w
for i in range(h):
  s[i] = input()
 
for i in range(h):
  for j in range(w):
    if s[i][j] == '#':
      if j != w - 1:
        if s[i][j + 1] == '#':
          continue
      elif  j != 0:
        if s[i][j - 1] == '#':
          continue
      elif i != h - 1:
        if s[i + 1][j] == '#':
          continue
      elif i != 0:
        if s[i - 1][j] == '#':
          continue
      else:
        print('No')
        sys.exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
import sys
h,w = map(int,input().split())
s = ['']*w
for i in range(h):
  s[i] = input()

for i in range(h):
  for j in range(w):
    if s[i][j] == '#':
      if j != w and s[i][j + 1] == '#':
        continue
      elif  j != 0 and s[i][j - 1] == '#':
        continue
      elif i != h and s[i + 1][j] == '#':
        continue
      elif i != 0 and s[i - 1][j] == '#':
        continue
      else:
        print('No')
        sys.exit()
print('Yes')
Problem p03379 (python)

Fixed submission:

n = int(input())
x = list(map(int,input().split()))
sort_x = sorted(x)

mid_1 = sort_x[n//2-1]
mid_2 = sort_x[n//2]

for i in range(n):
  
  if x[i] <= mid_1:
    print(mid_2)
  else:
    print(mid_1)

Buggy submission (verdict: Runtime Error):
import statistics
import math

n = int(input())
x = list(map(int,input().split()))

for i in range(n):
  tmp = x
  print(statistics.median(x.pop(i)))
Problem p03274 (python)

Fixed submission:
N, K, *x = map(int, open(0).read().split())
ans = 1e9
for i in range(N - K + 1):
    l = x[i]
    r = x[i + K - 1]
    ans = min(ans, abs(l) + (r - l), abs(r) + (r - l))
    
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n,k=list(map(int,input().split()))
c=list(map(int,input().split()))
m=math.inf
for i in range(n-k+1):
        l=c[i]
        r=c[i+k-1]
        m=min(m,abs(l)+abs(r-l),abs(r)+abs(r-l))

print(m)
Problem p03325 (python)

Fixed submission:

def judge(a):
    ans=0
    while a%2==0:
        a/=2
        ans+=1
    return ans

if __name__ == '__main__':
    N=int(input())
    A=list(map(int,input().split()))
    count=0
    for a in A:
        count+=judge(a)

    print(count)

Buggy submission (verdict: Runtime Error):
from sympy import factorint

def judge(a):
    primes=factorint(a)
    if 2 in primes.keys():
        return primes[2]
    else:
        return 0

if __name__ == '__main__':
    N=int(input())
    A=list(map(int,input().split()))
    count=0
    for a in A:
        count+=judge(a)

    print(count)
Problem p03476 (python)

Fixed submission:
import sys
input=sys.stdin.readline

def Eratosthenes():
    num=[True for i in range(100001)]
    num[0]=False
    num[1]=False
    for i in range(2,100001):
        if num[i]:
            for j in range(2*i,100001,i):
                num[j]=False
    return num

if __name__ == '__main__':
    Q=int(input())
    Queries=[list(map(int,input().split())) for i in range(Q)]
    p_list=Eratosthenes()
    dp=[0 for _ in range(100001)]
    for i in range(3,100000):
        if p_list[i] and p_list[(i+1)//2]:
            dp[i+1]=dp[i]+1
        else:
            dp[i+1] = dp[i]
    for l,r in Queries:
        print(dp[r+1]-dp[l])

Buggy submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline

def is_prime(n):
    for i in range(2,int(n**0.5)+1):
        if n%i==0:
            return False
    return True

def make(n):
    ans=[]
    for i in range(2,n+1):
        if is_prime(i):
            ans.append(i)
    return ans

if __name__ == '__main__':
    Q=int(input())
    Queries=[list(map(int,input().split())) for i in range(Q)]
    upper=max(Queries,key=lambda x:x[1])
    p_list=make(upper)

    for l,r in Queries:
        count=0
        for i in range(l,r+1,2):
            if i in p_list:
                if (i+1)//2 in p_list:
                    count+=1
        print(count)
Problem p03608 (python)

Fixed submission:
from itertools import permutations
def warshal_floyd(weights,N):
    d=weights
    for i in range(N):
        d[i][i]=0
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j]=min(d[i][j],d[i][k]+d[k][j])
    return d

if __name__ == '__main__':
    N,M,R=list(map(int,input().split()))
    cities=[r-1 for r in list(map(int,input().split()))]
    weights=[[1e10 for i in range(N)] for j in range(N)]
    for i in range(M):
        a,b,c=list(map(int,input().split()))
        a-=1
        b-=1
        weights[a][b]=c
        weights[b][a]=c

    d=warshal_floyd(weights,N)
    mini_count=1e12
    for c in permutations(cities):
        count=sum(d[i][j] for i,j in zip(c,c[1:]))
        mini_count=min(mini_count,count)
    print(mini_count)

Buggy submission (verdict: Runtime Error):
from scipy.sparse.csgraph import floyd_warshall

def warshal_floyd(weights,N):
    d=[[weights[(i,j)] for i in range(N)] for j in range(N)]
    for i in range(N):
        d[i][i]=0
    for i in range(N):
        for j in range(N):
            for k in range(N):
                d[i][j]=min(d[i][j],d[i][k]+d[k][j])
    return d

def make_iteration(R,cities):
    S=[[c] for c in cities]
    iteration=[]
    while len(S)>0:
        v=S.pop()
        if len(v)!=len(set(v)):
            continue
        if len(v)==R:
            iteration.append(v)
        else:
            for c in cities:
                S.append(v+[c])
    return iteration

if __name__ == '__main__':
    N,M,R=list(map(int,input().split()))
    cities=list(map(int,input().split()))
    weights={(i,j):10**7 for i in range(N) for j in range(N)}
    #graph=[[10*7 for i in range(N)] for j in range(N)]
    for i in range(M):
        a,b,c=list(map(int,input().split()))
        a-=1
        b-=1
        weights[(a,b)]=min(weights[(a,b)],c)
        weights[(b,a)]=min(weights[(b,a)],c)
    d=warshal_floyd(weights,N)
    #d=floyd_warshall(weights)

    iteration=make_iteration(R,cities)
    mini_count=1e12
    for i in iteration:
        count=0
        for r in range(R-1):
            count+=d[i[r]-1][i[r+1]-1]
        mini_count=min(mini_count,count)
    print(mini_count)
Problem p04030 (python)

Fixed submission:

if __name__ == '__main__':
    INPUT=input()
    ans=[]
    for i in INPUT:
        if i=="0":
            ans.append("0")
        elif i=="1":
            ans.append("1")
        else:
            if len(ans)>0:
                ans.pop()
    print("".join(ans))

Buggy submission (verdict: Runtime Error):

if __name__ == '__main__':
    INPUT=input()
    ans=[]
    for i in INPUT:
        if i=="0":
            ans.append("0")
        elif i=="1":
            ans.append("1")
        else:
            ans.pop()
    print("".join(ans))