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

Fixed submission:
def inp():
    ls=list(map(int,input().split()))
    return ls
x,n=map(int,input().split())
ls=inp()
ans=0
d=float('inf')
for i in range(102):
    if i in ls:
        continue
    tmp = abs(x - i)
    if tmp < d:
        d = tmp
        ans = i
print(ans)

Buggy submission (verdict: Runtime Error):
def inp():
    ls=set(map(int,input().split()))
    return ls
x,n=map(int,input().split())
if n==0:
    print(x)
    exit(0)
ls=inp()
ls.sort()
ans=0
d=float('inf')
for i in range(1, 102):
    if i in ls:
        continue
    tmp = abs(x - i)
    if tmp < d:
        d = tmp
        ans = i
print(ans)

Buggy submission (verdict: Runtime Error):
x,n=map(int,input().split())
ls=inp()
ls.sort()
if n==0:
    print(x)
    exit(0)
else:
    a=x-1
    b=x+1
    flag=False
    while(not flag):
        if a not in ls:
            print(a)
            exit(0)
        else:
            a-=1
        if b not in ls:
            print(b)
            exit(0)
        else:
            b+=1
Problem p02899 (python)

Fixed submission:
n=int(input())
ls=list(map(int,input().split()))
copy=[0]*n
for i in range(n):
    copy[ls[i]-1]=i+1
for i in copy:
       print(i,end=" ")

Buggy submission (verdict: Runtime Error):
n=int(input())
ls=list(map(int,input().split()))
copy=[0]*n
for i in range(n):
  copy[ls[i]-1=i+1
for i in copy:
       print(i,end=" ")
Problem p02660 (python)

Fixed submission:
# Contest No.: ABC169
# Problem No.: D
# Solver:      JEMINI
# Date:        20200531

import sys
import heapq

def main():
    temp = [True] * (10 ** 6 + 10)
    temp[0] = False
    temp[1] = False
    for i in range(2, 10 ** 6 + 10):
        if temp[i]:
            cnt = 2 * i
            while cnt < 10 ** 6 + 10:
                temp[cnt] = False
                cnt += i
    prime = []
    for i in range(10 ** 6 + 10):
        if temp[i]:
            prime.append(i)
 
    n = int(input())
    ans = 0
    tempN = n
    for i in prime:
        if i > tempN:
            break
        if tempN % i:
            continue
        div = 0
        while tempN % i == 0:
            tempN = tempN // i
            div += 1
        tempAns = int((div * 2) ** 0.5)
        if tempAns * (tempAns + 1) // 2 > div:
            tempAns -= 1
        #print(tempAns)
        ans += tempAns
    if tempN > 1:
        ans += 1
    print(ans)
    return
 
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    temp = [True] * (10 ** 12)
    temp[0] = False
    temp[1] = False
    for i in range(2, 10 ** 12):
        if temp[i]:
            cnt = 2 * i
            while cnt < 10 ** 12:
                temp[cnt] = False
                cnt += i
    prime = []
    for i in range(10 ** 12):
        if temp[i]:
            prime.append(i)

    n = int(input())
    ans = 0
    for i in prime:
        if i > n ** 0.5 + 1:
            break
        if n % i:
            continue
        div = 0
        tempN = n
        while True:
            cnt = 1
            while tempN % (i ** (2 * cnt)) == 0:
                cnt += 1
            if tempN % (i ** cnt):
                break
            div += cnt
            tempN = tempN // (i ** cnt)
        #print(div)
        if div > 2:
            div = int((div * 2) ** 0.5)
        else:
            div = 1
        #print(i, div, tempN)
        ans += div

    print(ans)
    return

if __name__ == "__main__":
    main()
Problem p03101 (python)

Fixed submission:
a,b = map(int,input().split())
c,d=map(int,input().split())
print((c-a)*(d-b))

Buggy submission (verdict: Runtime Error):
a,b = map(int,input.split())
c,d=map(int,input.split())
print((c-a)*(d-b))
Problem p03102 (python)

Fixed submission:
def judge(A, B, C, M):
	result = C
	for i in range(M):
		result += A[i] * B[i]

	return result > 0

def main():
	N, M, C = map(int, input().split())
	B = [int(x) for x in input().split()]
	count = 0

	for i in range(N):
		A = [int(x) for x in input().split()]

		if judge(A, B, C, M):
			count += 1

	print(count)



if __name__ == '__main__':
	main()

Buggy submission (verdict: Runtime Error):
def judge(A, B, C, M):
	result = C
	for i in range(M):
		result += A[i] * B[i]

	return result > 0

def main():
	N, M, C = map(int, input().split())
	B = map(int, input().split())
	count = 0

	for i in range(N):
		A = map(int, input().split())

		if judge(A, B, C, M):
			count += 1

	print(count)



if __name__ == '__main__':
	main()

Buggy submission (verdict: Runtime Error):
def judge(A, B, C, M):
	result = C
	for i in range(M):
		result += A[i] * B[i]

	return result > 0

def main():
	N, M, C = map(int, input().split())
	B = map(int, input().split())
	count = 0

	for i in N:
		A = map(int, input().split())

		if judge(A, B, C, M):
			count += 1

	print(count)



if __name__ == '__main__':
	main()

Buggy submission (verdict: Runtime Error):
vdef judge(A, B, C, M):
	result = C
	for i in range(M):
		result += A[i] * B[i]

	return result > 0

def main():
	N, M, C = map(int, input().split())
	B = map(int, input().split())
	count = 0

	for i in N:
		A = map(int, input().split())

		if judge(A, B, C, M):
			count += 1

	print(count)



if __name__ == '__main__':
	main()

Buggy submission (verdict: Runtime Error):
vdef judge(A, B, C, M):
	result = C
	for i in range(M):
		result += A[i] * A[j]

	return result > 0

def main():
	N, M, C = map(int, input().split())
	B = map(int, input().split())
	count = 0

	for i in N:
		A = map(int, input().split())

		if judge(A, B, C, M):
			count += 1

	print(count)



if __name__ == '__main__':
	main()

Buggy submission (verdict: Runtime Error):
vdef judge():
	result = C
	for i in range(M):
		result += A[i] * A[j]

	return result > 0

def main():
	N, M, C = map(int, input().split())
	B = map(int, input().split())
	count = 0

	for i in N:
		A = map(int, input().split())

		if judge(A, B, C, M):
			count += 1

	print(count)



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

Fixed submission:
def hoge(t, i):
	global data
	C, S, F = int(data[i][0]), int(data[i][1]), int(data[i][2])
	if S > t:
		t = S
	if t % F != 0:
		t += F - t % F
	return t + C

if __name__ == '__main__':
	N = int(input())
	data = list()

	for i in range(N - 1):
		l = input().split()
		data.append(l)

	for i in range(N - 1):
		t = 0
		for j in range(i, N - 1):
			t = hoge(t,j)
		print(t)
	print(0)

Buggy submission (verdict: Runtime Error):
def hoge(t, i):
	global data
	if lists[i][1] > t:
		t = lists[i][1]
	C, S, F = lists[i][0], lists[i][1], lists[i][2]

	return (t // F + 1) * F + C

if __name__ == '__main__':
	N = int(input())
	data = list()

	for i in range(N - 1):
		l = input().split()
		list.append(l)

	for i in range(N):
		t = 0
		for j in range(N-i):
			t = hoge(t,j)
		print(t)
Problem p02602 (python)

Fixed submission:
# 入力
N,K = list(map(int, input().split()))
A_list = list(map(int, input().split()))

for i in range(N-K):
    if((A_list[i+K] - A_list[i]) > 0):
        print('Yes')
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
# 入力
N,K = list(map(int, input().split()))
A_list = list(map(int, input().split()))

for i in range(N-K):
    score1 = A_list[i] * A_list[i+1] * A_list[i+2]
    score2 = A_list[i+1] * A_list[i+2] * A_list[i+3]
    if((score1 - score2) > 0):
        print('Yes')
    else:
        print('No')
Problem p04044 (python)

Fixed submission:
# 入力
N,L = list(map(int, input().split()))
S = []
for _ in range(N):
    S += [str(input())]

# 出力
print(''.join(sorted(S)))

Buggy submission (verdict: Runtime Error):
# 入力
N,L = list(map(int, input().split()))
S = []
for _ in range(N):
    S.add(str(input()))

# 出力
print(''.join(sorted(S)))
Problem p02658 (python)

Fixed submission:
import sys
n = int(input())
l = list(map(int,input().split()))
if 0 in l:
  print(0)
  sys.exit()
flag = True
anz = 1
for i in l:
  anz *= i
  if anz > 1000000000000000000:
    flag = False 
    break
print (anz if flag else -1)

Buggy submission (verdict: Runtime Error):
import sys
n = int(input())
l = list(map(int,input().split()))
if 0 in l:
  print(0)
  sys.exit()
else:
flag = True
anz = 1
for i in l:
  anz *= i
  if anz > 1000000000000000000:
    flag = False 
    break
print (anz if flag else -1)

Buggy submission (verdict: Runtime Error):
n int(input())
l = list(map(int,input().split()))
if 0 in l:
  print(0)
  continue
flag = True
anz = 1
for i in l:
  anz *= i
  if anz > 1000000000000000000:
    flag = False 
    break
print (anz if flag else -1)
Problem p02690 (python)

Fixed submission:
import sys
x=int(input())
div=[]
for i in range(1,int(x**0.5)+1):
  if x%i==0:
    div.append(i)
    if i != x // i:
      div.append(x//i)
div.sort()
div.reverse()
for i in div:
  for j in range(-10,1000):
    a=i-i+j
    b=-i+j
    other=(a**4)+(a**3)*b+(a**2)*(b**2)+a*(b**3)+(b**4)
    if i*other==x:
      print(a,b)
      sys.exit()

Buggy submission (verdict: Runtime Error):
import sys
x=int(input())
div=[]
for i in range(1,int(x**0.5)+1):
  if x%i==0:
    div.append(i)
    if i != n // i:
      div.append(n//i)
div.sort()
div.reverse()
for i in div:
  for j in range(100000):
    a=i+j
    b=j
    other=(a**4)+(a**3)*b+(a**2)*(b**2)+a*(b**3)+(b**4)
    if i*other>x:
      break
    if i*other==x:
      print(a," ",b)
      sys.exit()
Problem p02700 (python)

Fixed submission:
import sys

inp=input().split(" ")
thp=int(inp[0])
tat=int(inp[1])
ahp=int(inp[2])
aat=int(inp[3])

for i in range(100):
  ahp-=tat
  if ahp<=0:
    print("Yes")
    sys.exit()
  thp-=aat
  if thp<=0:
    print("No")
    sys.exit()

Buggy submission (verdict: Runtime Error):
import sys

inp=input().split(" ")
thp=int(inp[0])
tat=int(inp[1])
ahp=int(inp[2])
aat=int(inp[3])

for i in range(100);
  ahp-=tat
  if ahp<=0;
    print("Yes")
    sys.exit()
  thp-=aat
  if thp<=0;
    print("Yes")
    sys.exit()
Problem p02718 (python)

Fixed submission:
import sys
 
nm=input().split()
a=input().split()
n=int(nm[0])
m=int(nm[1])
lista=[]
for i in a:
  lista.append(int(i))
count=0
suma=sum(lista)
thre=suma/4/m
for i in lista:
  if i >= thre:
    count+=1
  if count >= m:
    print('Yes')
    sys.exit()
print('No')

Buggy submission (verdict: Runtime Error):
import sys

nm=input().split()
a=input()
n=int(nm[0])
m=int(nm[1])
lista=[]
for i in a:
  lista.append(int(i))
count=0
suma=sum(lista)
thre=suma/4/m
for i in lista:
  if i >= thre:
    count+=1
  if count >= m:
    print('Yes')
    sys.exit()
print('No')
Problem p02606 (python)

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

a = sum(1 if d <= n and n % d == 0 else 0 for n in range(l, r+1))
print(a)

Buggy submission (verdict: Runtime Error):
from numba import njit

@njit('i8(i8)', cache=True)
def popcount(n):
    a = 0
    while n != 0:
        a += n & 1
        n >>= 1
    return a

@njit('i8(i8)', cache=True)
def fun(n):
    ops = 0
    while n:
        bits = popcount(n)
        n %= bits
        ops += 1
    return ops

def funwrap(n, pc):
    if n == 0:
        return 0
    return 1 + fun(n % pc)

n = int(input())
xs = list(map(int, input()))

from functools import reduce
sm = reduce(lambda x,y: x*2+y, xs)
pc = xs.count(1)

for i in range(n):
    df = 1 if xs[i] ^ 1 == 1 else -1

    dn = 1 << (n - (i + 1))
    smi = sm + dn * df
    pci = pc + df

    print(funwrap(smi, pci))
Problem p02618 (python)

Fixed submission:
d = int(input())
cs = list(map(int, input().split()))
sm = [list(map(int, input().split())) for _ in range(d)]

import random
for _ in range(d):
    t = random.choice(range(26)) + 1
    print(t)

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

d = int(input())
cs = list(map(int, input().split()))
cs = np.array(cs, dtype=np.int64)
sm = [list(map(int, input().split())) for _ in range(d)]
sm = np.array(sm, dtype=np.int64)

@njit('i8(i8[:], i8)', cache=True)
def total_satisfaction(ts, d):
    ls = np.zeros(26)
    s = 0
    for i in range(d):
        t = ts[i]
        t -= 1
        s += sm[i][t]
        ls[t] = i + 1

        dis = 0
        for j in range(26):
            dis += cs[j] * ((i+1) - ls[j])
        s -= dis
    return s

ts = []
for i in range(d):
    mx = -1e10
    mxt = None
    for t in range(1, d+1):
        tt = np.array(ts + [t], dtype=np.int64)
        s = total_satisfaction(tt, i + 1)
        if s > mx:
            mx = s
            mxt = t
    ts.append(mxt)

    print(mxt)

Buggy submission (verdict: Runtime Error):
d = int(input())
cs = list(map(int, input().split()))
sm = [list(map(int, input().split())) for _ in range(d)]

def total_satisfaction(ts, d):
    ls = [0] * 26
    s = 0
    for i in range(d):
        t = ts[i]
        t -= 1
        s += sm[i][t]
        ls[t] = i + 1

        dis = 0
        for j in range(26):
            dis += cs[j] * ((i+1) - ls[j])
        s -= dis
    return s

ts = []
for i in range(d):
    mx = -1e10
    mxt = None
    for t in range(1, d+1):
        s = total_satisfaction(ts + [t], i + 1)
        if s > mx:
            mx = s
            mxt = t
    ts.append(mxt)

    print(mxt)
Problem p02945 (python)

Fixed submission:
a,b = map(int, raw_input().split())
print max(a+b,a-b,a*b)

Buggy submission (verdict: Runtime Error):
"\C-n":history-search-forward
"\C-p":history-search-backward
Problem p02576 (python)

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

n = math.ceil(n/x)
print(n*t)

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

n = math.ceil(n/x)
print(n*t)

Buggy submission (verdict: Runtime Error):
n,x,t = input().split()

n = n//x
print(n*t)
Problem p02969 (python)

Fixed submission:
n=int(input())

n=n*n*3
print(n)

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

ans=[]
for i in range(n-1,n//2-1,-1):
  if li[i]==1:
    ans.append(i+1)

for i in range(n//2,0,-1):
  count=0
  for j in ans:
    if j%i==0:
      count+=1
  if count%2==0:
    ans.append(i)
ans.reverse()
print(len(ans))
L=[str(a) for a in ans]
L=" ".join(L)
if len(L)!=0:
  print(L)
Problem p02972 (python)

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

ans=[]
li2=[0 for _ in range(n)]
for i in range(n,0,-1):
  count=0
  for j in range(i*2,n+1,i):
    if li2[j-1]==1:
      count+=1
  if count%2!=li[i-1]:
    li2[i-1]=1
    ans.append(i)

ans.reverse()
print(len(ans))
L=[str(a) for a in ans]
L=" ".join(L)
if len(L)!=0:
  print(L)

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

ans=[]
for i in range(n,n//2,-1):
  if li[i]==1:
    ans.append(i+1)

for i in range(n//2,0,-1):
  count=0
  for j in ans:
    if j%i==0:
      count+=1
  count+=li[i-1]
  if count%2==1:
    ans.append(i)
ans.reverse()
print(len(ans))
L=[str(a) for a in ans]
L=" ".join(L)
if len(L)!=0:
  print(L)
Problem p02988 (python)

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

count=0
for i in range(n-2):
  a=li[i]
  b=li[i+1]
  c=li[i+2]
  if (a<b and (b<c or b==c)) or (c<b and (b<a or b==a)):
    count+=1
print(count)

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

count=0
for i in range(1,len(n)-1):
  if (n[i-1]<n[i] and n[i]<n[i+1]) or (n[i-1]>n[i] and n[i]>n[i+1]):
    count+=1
print(count)
Problem p02993 (python)

Fixed submission:
n=int(input())
a=n//1000
b=(n//100)%10
c=(n//10)%10
d=n%10
 
if a==b:
  print('Bad')
elif b==c:
  print('Bad')
elif c==d:
  print('Bad')
else:
  print('Good')

Buggy submission (verdict: Runtime Error):
s=input()
if s[0]==s[1] || s[2]==s[1] || s[2]==s[3]:
  print('Good')
else:
  print('Bad')

Buggy submission (verdict: Runtime Error):
n=int(input())
a=n//1000
b=(n//100)%10
c=(n//10)%10
d=n%10
 
if a==b:
  print(Bad)
elif b==c:
  print(Bad)
elif c==d:
  print(Bad)
else:
  print(Good)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=n//1000
b=(n//100)%10
c=(n//10)%10
d=n%10

if a==b:
  print(Bad)
else if b==c:
  print(Bad)
else if c==d:
  print(Bad)
else:
  print(Good)
Problem p02991 (python)

Fixed submission:
from collections import deque


def main():
    N, M = map(int, input().split())
    edges = [[] for _ in range(3 * N)]

    for _ in range(M):
        u, v = map(lambda x: int(x) - 1, input().split())
        edges[3 * u].append(3 * v + 1)
        edges[3 * u + 1].append(3 * v + 2)
        edges[3 * u + 2].append(3 * v)

    S, T = map(lambda x: (int(x) - 1) * 3, input().split())
    q = deque([(S, 0)])
    nodes = [-1] * (3 * N)

    while q:
        cv, count = q.popleft()

        if cv == T:
            nodes[cv] = count if nodes[cv] == -1 else min(nodes[cv], count)
        else:
            if nodes[cv] == -1 or count < nodes[cv]:
                nodes[cv] = count
                for u in edges[cv]:
                    q.append((u, count + 1))

    print(nodes[T] // 3 if nodes[cv] != -1 else -1)


if __name__ == '__main__':
    main()

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


def main():
    N, M = map(int, input().split())
    edges = [[] for _ in range(N)]

    for _ in range(M):
        u, v = map(int, input().split())
        edges[u - 1].append(v - 1)

    converted_edges = [[] for _ in range(N)]
    for v, v_edge in enumerate(edges):
        three_steps_nodes = []
        for w in edges[v]:
            for x in edges[w]:
                for y in edges[x]:
                    three_steps_nodes.append(y)
        converted_edges[v] = three_steps_nodes.copy()

    S, T = map(lambda x: int(x) - 1, input().split())
    q = deque([(S, 0)])

    nodes = [-1] * N

    while q:
        cv, count = q.popleft()
        if cv == T:
            if nodes[cv] == -1:
                nodes[cv] = count
            else:
                nodes[cv] = min(nodes[cv], count)
        else:
            if nodes[cv] == -1 or count < nodes[cv]:
                nodes[cv] = count
                for u in converted_edges[cv]:
                    q.append((u, count + 1))

    print(nodes[T])


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

Fixed submission:
import sys
sys.setrecursionlimit(10**9)


def rec(edges, nodes, cp, cdistance, visited):
    if not visited[cp]:
        visited[cp] = True
        nodes[cp] = (cdistance % 2 == 0)
        if edges[cp]:
            for v, w in edges[cp]:
                rec(edges, nodes, v, cdistance + w, visited)


def main():
    N = int(input())
    nodes = [False] * N
    visited = [False] * N
    edges = [[] for _ in range(N)]

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

    rec(edges, nodes, 0, 0, visited)

    for n in nodes:
        print(0 if n else 1)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def rec(edges, nodes, cp, cdistance, visited):
    if not visited[cp]:
        visited[cp] = True
        nodes[cp] = (cdistance % 2 == 0)
        if edges[cp]:
            for v, w in edges[cp]:
                rec(edges, nodes, v, cdistance + w, visited)


def main():
    N = int(input())
    nodes = [False] * N
    visited = [False] * N
    edges = [[] for _ in range(N)]

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

    rec(edges, nodes, 0, 0, visited)

    for n in nodes:
        print(0 if n else 1)


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

Fixed submission:
#!/snap/bin/pypy3
def gcd(a, b):
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)


def main():
    N = int(input())
    nums = list(map(int, input().split()))

    L = [0 for _ in range(N + 1)]
    R = [0 for _ in range(N + 1)]

    for i, num in enumerate(nums):
        L[i + 1] = gcd(L[i], num)

    for i in range(N - 2, -1, -1):
        R[i] = gcd(R[i + 1], nums[i + 1])

    print(max(gcd(L[i], R[i]) for i in range(N)))


if __name__ == '__main__':
    main()

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


def main():
    N = int(input())
    nums = list(map(int, input().split()))

    L = [0 for _ in range(N + 1)]
    R = [0 for _ in range(N + 1)]

    for i, num in enumerate(nums):
        L[i + 1] = gcd(L[i], num)

    for i in range(N - 2, -1, -1):
        R[i] = gcd(R[i + 1], nums[i + 1])

    print(max(gcd(L[i], R[i]) for i in range(N)))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/python3

import numpy as np

N = int(input())
nums = np.array(list(map(int, input().split())))

sorted_num = np.sort((nums))

res = 1
for i in range(sorted_num[1], 0, -1):
    nums_div_i = np.remainder(nums, i)

    nums_div_i = nums_div_i > 0
    d = np.sum(np.ones(N) * nums_div_i)
    if d == 1 or d == 0:
        res = i
        break

print(res)
Problem p03079 (python)

Fixed submission:
a, b, c = map(int, input().split())
res = "Yes" if a == b == c else "No"
print(res)

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
s = list(input())
del s[-1]
sSet = set(s) 

death = 0

for i in range(Q):
	t, d = input().split()

	if t in sSet:
		tmpS = s.copy()
		for index, golems in enumerate(tmpS):
			if t in golems:
				if d == 'L' and index == 0: 
					s[index] = ""
					death += len(golems) 
				elif d == 'L':
					s[index-1] = tmpS[index-1] + golems
					s[index] = ""
				elif d == 'R' and index == N - 1:
					s[index] = ""
					death += len(golems)
				else:
					s[index+1] = tmpS[index+1] + golems
					s[index] = ""


print(len(s) - death)
Problem p03087 (python)

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

t = [0] * (N + 1) 

for i in range(N):
	t[i+1] = t[i] + (1 if S[i:i+2] == "AC" else 0)

for i in range(Q):
	l, r = map(int, input().split())
	print(t[r-1] - t[l-1])

Buggy submission (verdict: Runtime Error):
S = input() 
data = [ tuple(map(int, input().split())) for _ in range(Q) ] 

counter = [0 for _ in range(Q)]
index = -1
while True:
	index = S.find("AC", index+1)

	if index == -1:
		break
	
	for i, (l, r ) in enumerate(data):
		if l-1 <= index < r-1:
			counter[i] += 1

for res in counter:
	print(res)
Problem p03106 (python)

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

divisorA = [ i for i in range(1,a+1 ) if a % i == 0 ]
divisorB = [ i for i in range(1,b+1 ) if b % i == 0 ]

divisor = []

for elemA in divisorA:
	divisor += filter(lambda elem: elem == elemA, divisorB)	

divisor = sorted(divisor)
divisor = divisor[::-1]
# print(divisor)

print( divisor[k-1] )

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

if a==1 or b==1 or k==1:
	print(1)
	exit()

divisorA = [ i for i in range(1,a ) if a % i == 0 ]
divisorB = [ i for i in range(1,b ) if b % i == 0 ]

divisor = set(divisorA + divisorB)

divisor = sorted(divisor &  set(divisorA) )

print( divisor[k-1] )
Problem p03164 (python)

Fixed submission:
#!/usr/bin/python3

import numpy as np

def main():
    N, W = map(int, input().split())

    dp = np.full((N+1, N * (10**3) +1), np.inf)
    dp[0][0] = 0

    for i in range(N):
        weight, value = map(int, input().split())

        dp[i+1][:value] = dp[i][:value]
        dp[i+1][value:] = np.minimum(dp[i][value:], dp[i][:-value] + weight)


    res = 0
    for i, weight in enumerate(dp[N]):
        if weight <= W: res = i

    print(res)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/python3

import numpy as np

def main():
    N, W = map(int, input().split())

    dp = np.zeros((N+1, W+1), dtype='uint16')

    for i in range(N):
        weight, value = map(int, input().split())

        dp[i+1][:weight] = dp[i][:weight]
        dp[i+1][weight:] = np.maximum(dp[i][weight:], dp[i][:-weight] + value)

    print(dp[-1][-1])

if __name__ == '__main__':
    main()