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

Fixed submission:
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    T = input()
    result = []
    bef = ""
    for i in range(len(T)-1):
        if T[i] == "?":
            if bef == "P":
                result.append("D")
            elif T[i+1] == "?" or T[i+1] == "D":
                result.append("P")
            else:
                result.append("D")
        else:
            result.append(T[i])
        bef = result[-1]
    if T[-1] == "?":
        result.append("D")
    else:
        result.append(T[-1])
    print("".join(result))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    T = input()
    result = []
    for i in range(len(T)-1):
        if T[i] == "?":
            if result[i-1] == "P":
                result.append("D")
            elif T[i+1] == "?" or T[i+1] == "D":
                result.append("P")
            else:
                result.append("D")
        else:
            result.append(T[i])
    if T[-1] == "?":
        result.append("D")
    else:
        result.append(T[-1])
    print("".join(result))

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

Fixed submission:
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    N,M = map(int,input().split())
    shirube = [None]*(N+1)
    shirube[1] = (1,0)
    mmap = [[] for _ in range(N+1)]
    for _ in range(M):
        a,b = map(int,input().split())
        mmap[a].append(b)
        mmap[b].append(a)
    queue = deque()
    queue.appendleft((1,0))
    while queue:
        current_node, distance = queue.pop()
        for next_node in mmap[current_node]:
            new_distance = distance+1
            if shirube[next_node] is None:
                shirube[next_node] = (current_node, new_distance)
                queue.appendleft((next_node, new_distance))
            elif shirube[next_node][1] > new_distance:
                shirube[next_node] = (current_node, new_distance)
                queue.appendleft((next_node, new_distance))
    shirube = shirube[1::]
    if None in shirube:
        print("No")
        return
    print("Yes")
    for s in shirube[1::]:
        print(s[0])


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    N,M = map(int,input().split())
    shirube = [None]*(N+1)
    shirube[1] = (1,0)
    mmap = [[] for _ in range(N+1)]
    for _ in range(M):
        a,b = map(int,input().split())
        mmap[a].append(b)
        mmap[b].append(a)
    queue = deque()
    queue.appendleft((1,0))
    while queue:
        current_node, distance = queue.pop()
        for next_node in mmap[current_node]:
            new_distance = distance+1
            if shirube[next_node] is None:
                shirube[next_node] = (current_node, new_distance)
                queue.appendleft((next_node, new_distance))
            elif shirube[next_node][1] > new_distance:
                shirube[next_node] = (current_node, new_distance)
                queue.appendleft((next_node, new_distance))
    shirube = shirube[1::]
    if None in shirube:
        print("No")
        return
    print("Yes")
    for s in shirube[1::]:
        print(s[0])


if __name__ == '__main__':
    main()
ç
Problem p02683 (python)

Fixed submission:
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    N,M,X = map(int, input().split())
    ca = []
    res = sys.maxsize
    for _ in range(N):
        ca.append(list(map(int, input().split())))
    for i in range(2 ** N):
        tmp = [0]*M
        tmpres = 0
        for j in range(N):
            if ((i >> j) & 1):
                tca = ca[N-1-j]
                tmpres += tca[0]
                for k in range(M):
                    tmp[k] += tca[1+k]
        tassei = True
        for a in tmp:
            if a < X:
                tassei = False
                break
        if tassei:
            res = min(res,tmpres)
    if res != sys.maxsize:
        print(res)
    else:
        print(-1)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    N,M,X = map(int, input().split())
    ca = []
    res = sys.maxsize
    for _ in range(N):
        ca.append(list(map(int, input().split())))
    for i in range(2 ** N):
        tmp = [0]*M
        tmpres = 0
        for j in range(N):
            if ((i >> j) & 1):
                tca = ca[M-1-j]
                tmpres += tca[0]
                for k in range(M):
                    tmp[k] += tca[1+k]
        tassei = True
        for a in tmp:
            if a < X:
                tassei = False
                break
        if tassei:
            res = min(res,tmpres)
    if res != sys.maxsize:
        print(res)
    else:
        print(-1)


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

Fixed submission:
x=int(input())
h=(x//500)*1000
x%=500
h+=(x//5)*5
print(h)

Buggy submission (verdict: Runtime Error):
x=map(int,input().split())
h=x//500 * 1000
x%=500
h+=x//5
print(h)
Problem p02730 (python)

Fixed submission:
s=input()
a=s[:(len(s)-1)//2]
b=s[((len(s)+3)//2-1):]
if s==s[::-1] and a==a[::-1] and b==b[::-1]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s=input()
a=s[:(len(s)−1)//2]
b=s[(len(s)+3)//2-1:]
if s==s[::-1] and a==a[::-1] and b==b[::-1]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s=input()
if s==s[::-1] and s==s[:(len(s)−1)//2] and s==s[(len(s)+3)//2-1:]:
  print("Yes")
else:
  print("No")
Problem p02817 (python)

Fixed submission:
print("".join((input().split())[::-1]))

Buggy submission (verdict: Runtime Error):
s,t = input(),input()
print(t+s)
Problem p03071 (python)

Fixed submission:
def apply(a,b):
  if a>b:
    return (a, a-1, b)
  else:
    return (b, a, b-1)

if __name__ == '__main__':
  a,b = map(int,input().split())
  res = 0
  tmp, a, b = apply(a,b)
  res += tmp
  tmp, a, b = apply(a,b)
  res += tmp
  print(res)

Buggy submission (verdict: Runtime Error):
def apply(a,b):
  if a>b:
	return a, a-1, b
  else:
    return b, a, b-1

if __name__ == '__main__':
  a,b = map(int,input().split())
  res = 0
  tmp, a, b = apply(a,b)
  res += tmp
  tmp, a, b = apply(a,b)
  res += tmp
  print(res)
Problem p03294 (python)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
print(sum(a) - N)

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

def solve(N, a):
	m = reduce(lambda x, y: x*y, a) // reduce(math.gcd, a) - 1
	ans = 0
	for ai in a:
		ans += m % ai
	return ans

if __name__ == '__main__':
	N = int(input())
	a = list(map(int, input().split()))
	print(solve(N,a))
Problem p03316 (python)

Fixed submission:
N = int(input())
sn = 0
for s in str(N):
    sn += int(s)
if N % sn == 0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N = input()
ans = 0
for n in N:
  ans += int(n)
if int(N) % ans == 0:
  print("Yes")
else:s
  print("No")

Buggy submission (verdict: Runtime Error):
N = input()
ans = 0
for n in N:
  ans += int(n)
if N % ans == 0:
  print("Yes")
else:s
  print("No")
Problem p03409 (python)

Fixed submission:
from pprint import pprint
N = int(input())
reds = []
for i in range(N):
    reds.append(tuple(map(int, input().split(" "))))
blues = []
for i in range(N):
    blues.append(tuple(map(int, input().split(" "))))
reds.sort(key=lambda x: (x[1], x[0]), reverse=True)
blues.sort()
picked = [False for _ in range(N)]
ans = 0
for blue in blues:
    for i, red in enumerate(reds):
        if blue[0] > red[0] and blue[1] > red[1] and not picked[i]:
            ans += 1
            picked[i] = True
            break
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
reds = []
for i in range(N):
    reds.append(tuple(map(int, input().split(" "))))
blues = []
for i in range(N):
    blues.append(tuple(map(int, input().split(" "))))
reds.sort(key=lambda x: x.reverse(), reverse=True)
blues.sort()
picked = [False for _ in range(N)]
ans = 0
for blue in blues:
    for i, red in enumerate(reds):
        if blue[0] > red[0] and blue[1] > red[1] and not picked:
            ans += 1
            picked[i] = True
            break
print(ans)

Buggy submission (verdict: Runtime Error):
from pprint import pprint

def solve(datas):
    ans = 0
    reds = set()
    for p in datas:
        # pprint(reds)
        if p[0] == "r":
            reds.add(p)
        else:
            if len(reds) != 0:
                partner = max(filter(lambda x: x[1][1] < p[1][1], reds), key=lambda x: x[1][1])
                # pprint(filter(lambda x: x[1][1] < p[1][1], reds))
                reds.remove(partner)
                ans += 1
    return ans

if __name__ == '__main__':
    N = int(input())
    datas = []
    for i in range(N):
        a,b = list(map(lambda x: int(x), input().split(" ")))
        datas.append(("r", (a,b)))
    for i in range(N):
        c,d = list(map(lambda x: int(x), input().split(" ")))
        datas.append(("b", (c,d)))
    # pprint(datas)
    datas.sort(key=lambda x: x[1][0]) # x座標で昇順にソート
    ans = solve(datas)
    print(ans)
Problem p03497 (python)

Fixed submission:
from collections import defaultdict
n,k = map(int,input().split())
nums = input().split()
count_per_nums = defaultdict(int)
for n in nums:
  count_per_nums[n] += 1
count_per_nums = sorted(count_per_nums.items(), key=lambda x:x[1])
ans = 0
for i in range(len(count_per_nums)-k):
  ans += count_per_nums[i][1]
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
n,k = map(int,input().split())
nums = input().split()
count_per_num = defaultdict(int)
for n in nums:
  count_per_num[n] += 1
count_per_nums = sorted(count_per_nums, key=lambda x:x[1])
ans = 0
for i in range(len(count_per_nums)-k):
  ans += count_per_nums[i]
print(ans)
Problem p03573 (python)

Fixed submission:
a = list(map(lambda x: int(x), input().split(" ")))
b = list(set(a))
if a.count(b[0]) == 2:
  print(b[1])
else:
  print(b[0])

Buggy submission (verdict: Runtime Error):
a = list(map(lambda x: int(x), input().split(" ")))
b = list(set(a))
print(a-b)
Problem p03597 (python)

Fixed submission:
n = int(input())
a = int(input())
print(n**2-a)

Buggy submission (verdict: Runtime Error):
n,a = list(map(lambda x: int(x), input().split(" ")))
print(n**2-a)

Buggy submission (verdict: Runtime Error):
n,a = list(map(lambda x: int(x), input().split(" ")))
print(n**2-a)
Problem p03693 (python)

Fixed submission:
if int("".join(input().split(" ")))%4==0:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
if int(input().strip(" "))%4==0:
  print("YES")
else:
  print("NO")
Problem p03697 (python)

Fixed submission:
a,b = list(map(lambda x: int(x), input().split(" ")))
if a+b>=10:
  print("error")
else:
  print(a+b)

Buggy submission (verdict: Runtime Error):
s = list(map(lambda x: int(x), input().split(" "))).sum()
if s>=10:
  print("error")
else:
  print(s)
Problem p03729 (python)

Fixed submission:
s = str(input()).split(" ")
if s[0][-1] == s[1][0] and s[1][-1] == s[2][0]:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
s = str(input()).split(" "):
if s[0][0] == s[1][-1] and s[1][0] == s[2][-1]:
  print("YES")
else:
  print("NO")
Problem p03738 (python)

Fixed submission:
a = int(input())
b = int(input())
if a == b:
  print("EQUAL")
elif a > b:
  print("GREATER")
else:
  print("LESS")

Buggy submission (verdict: Runtime Error):
a = int(input())
b ^ int(input())
if a == b:
  print("EQUAL")
elif a > b:
  print("LESS")
else:
  print("GREATER")
Problem p03855 (python)

Fixed submission:
import copy

class UnionFind:
	def __init__(self, N):
		self._parent = [i for i in range(N)]

	def find(self, x):
		if self._parent[x] == x:
			return x
		else:
			return self.find(self._parent[x])

	def unite(self, a, b):
		ta = self.find(a)
		tb = self.find(b)
		if(ta != tb):
			self._parent[ta] = min(ta,tb)
			self._parent[tb] = self._parent[ta]
		
			
	def check(self, a, b):
		return self.find(a) == self.find(b)
		
if __name__ == '__main__':
	N,K,L = map(int, input().split())
	uf1 = UnionFind(N)
	for _ in range(K):
		p,q = map(int, input().split())
		uf1.unite(p-1,q-1)
	uf2 = UnionFind(N)
	for _ in range(L):
		s,r = map(int, input().split())
		uf2.unite(s-1,r-1)
	from collections import defaultdict
	d = defaultdict(int)
	for i in range(N):
		d[(uf1.find(i), uf2.find(i))] += 1
	ans = []
	for i in range(N):
		ans.append( str(d[(uf1.find(i), uf2.find(i))]) )
	print(' '.join(ans))

Buggy submission (verdict: Runtime Error):
import copy

class UnionFind:
	def __init__(self, N):
		self._parent = [i for i in range(N)]

	def find(self, x):
		if self._parent[x] == x:
			return x
		else:
			return self.find(self._parent[x])

	def unite(self, a, b):
		ta = self.find(a)
		tb = self.find(b)
		if(ta == tb):
			return
		self._parent[ta] = tb # make b as a parent of a
			
	def check(self, a, b):
		return self.find(a) == self.find(b)
		
if __name__ == '__main__':
	N,K,L = map(int, input().split())
	uf1 = UnionFind(N)
	for _ in range(K):
		p,q = map(int, input().split())
		uf1.unite(p-1,q-1)
	uf2 = UnionFind(N)
	for _ in range(L):
		s,r = map(int, input().split())
		uf2.unite(s-1,r-1)
	from collections import defaultdict
	d = defaultdict(int)
	for i in range(N):
		d[(uf1.find(i), uf2.find(i))] += 1
	ans = []
	for i in range(N):
		ans.append( str(d[(uf1.find(i), uf2.find(i))]) )
	print(' '.join(ans))

Buggy submission (verdict: Runtime Error):
import copy

class UnionFind:
	def __init__(self, N):
		self._parent = [i for i in range(N)]
		self._rank = [1 for i in range(N)]

	def find(self, x):
		if self._parent[x] == x:
			return x
		else:
			return self.find(self._parent[x])

	def unite(self, a, b):
		ta = self.find(a)
		tb = self.find(b)
		if(ta == tb):
			return
		
		if self._rank[ta] < self._rank[tb]:
			self._parent[ta] = tb # make b as a parent of a
		else:
			self._parent[tb] = ta # make a as a parent of b
			if(ta == tb) rank[ta] += 1
			
	def check(self, a, b):
		return self.find(a) == self.find(b)
		
if __name__ == '__main__':
	N,K,L = map(int, input().split())
	ans = [1 for _ in range(N+1)]
	uf = UnionFind(N+1)
	for _ in range(K):
		p,q = map(int, input().split())
		uf.unite(p,q)
	for _ in range(L):
		s,r = map(int, input().split())
		if uf.check(s,r):
			ans[s] += 1
			ans[r] += 1
	print(*ans[1::])
Problem p04029 (python)

Fixed submission:
n = int(input())
res= 0
for i in range(n):
	res += i+1
print(res)

Buggy submission (verdict: Runtime Error):
n = int(input())
res= 0
if i in range(n)
    res += i+1
print(res)
Problem p04030 (python)

Fixed submission:
inst = input()
buf = []
for s in inst:
  if s == "B":
    if len(buf) != 0:
      del buf[-1]
  else:
    buf.append(s)
print("".join(buf))

Buggy submission (verdict: Runtime Error):
inst = input()
buf = []
for s in inst:
  if s == "B":
    buf.pop()
  else:
    buf.append(s)
print(buf)
Problem p04044 (python)

Fixed submission:
n,l = list(map(int, input().split(" ")))
s = []
for i in range(n):
  s.append(input())
s.sort()
print("".join(s))

Buggy submission (verdict: Runtime Error):
n,l = list(map(int, input().split(" ")))
s = []
for i in range(n):
  s.append(input())
sort(s)
print("".join(s))
Problem p03000 (python)

Fixed submission:
N,X = map(int, input().split())
L = list(map(int, input().split()))
count = 1
D = 0

for i in range(N):
  D += L[i]
  if D <= X:
    count += 1
  else:
    break

print(count)

Buggy submission (verdict: Runtime Error):
N,X = map(int, input().split())
L = list(map(int, input().split()))
count = 0
D = 0
i = 0

while D < X+1:
  count += 1
  D += L[i]
  i += 1
  
if D <= X:
  count += 1
  
print(count)

Buggy submission (verdict: Runtime Error):
N,X = map(int, input().split())
L = list(map(int, input().split()))
count = 0
D = 0
i = 0

while D < X+1:
  count += 1
  D += L[i]
  i += 1
  
  
print(count)

Buggy submission (verdict: Runtime Error):
N,X = map(int, input().split())
L = list(map(int, input().split()))
count = 0
D = 0
i = 0

while D < X+1:
  D += L[i]
  i += 1
  count +=1
  
print(count)

Buggy submission (verdict: Runtime Error):
N,X = map(int, input().split())
L = list(map(int, input().split()))
i = 2
D = 0
count = 0

while D < X+1:
  D += L[i-1]
  i += 1
  count += 1

print(count)

Buggy submission (verdict: Runtime Error):
N,X = map(int, input().split())
L = list(map(int, input().split()))
i = 1
D = 0
count = 0

while D < X+1:
  D += L[i-1]
  i += 1
  count += 1

print(count)
Problem p02886 (python)

Fixed submission:
import sys
input = sys.stdin.readline
 
N = int(input())
d = list(map(int, input().split()))
P = 0
 
for i in range(N - 1):
    if d[i] == 0:
        continue
    for j in range(i + 1, N):
        if d[j] == 0:
            continue
        P += d[i] * d[j]
print(P)

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

N = int(input())
d = list(map(int, input().split()))
P = 0

for i in range(N - 1):
    if d[i] == 0:
        continue
    for j in range(i + 1, N):
        if d[j] == 0:
            continue
        P += d[i] * d[j
print(P)
Problem p02684 (python)

Fixed submission:
n, k = map(int, input().split())
a = list(map(int,input().split()))
timestamp = [0]*n
position = 1
period = 0
start=0
for i in range(n*2):
  if timestamp[position-1] != 0:
    start = timestamp[position-1]
    period = i-timestamp[position-1]
    break
  timestamp[position-1] =i
  position = a[position-1]
  

if k <=start:
  position = 1
  for i in range(k):
    position = a[position-1]
  print(position)
  
else:
  cycle = (k-start)%period
  for i in range(cycle):
    position = a[position-1]
  print(position)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int,input().split()))
timestamp = [0]*n
position = 1
period = 0
start=0
for i in range(n):
  if timestamp[position-1] != 0:
    start = timestamp[position-1]
    period = i-timestamp[position-1]
    break
  timestamp[position-1] =i
  position = a[position-1]
print(period,start)


if k <=start:
  position = 1
  for i in range(k-1):
    position = a[position-1]
  print(position)
  
else:
  cycle = (k-start)%period
  for i in range(cycle):
    position = a[position-1]
  print(position)
Problem p02687 (python)

Fixed submission:
a = input()
if (a[1] == 'B'):
  print('ARC')
else:
  print('ABC')

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
O = list(map(int, input().split()))
B = [[0 for i in range(N)] for j in range (N)]
 
for j in range(M):
  o_1, o_2 = map(int, input().split())
  B[o_1-1].append(o_2-1)
  B[o_2-1].append(o_1-1)
  
ans = 0
for k in range(N):
  flag =1
  for l in B[k]:
    if O[k] <= O[l]:
      flag = 0
      break
    else:
      continue
  if  flag ==1:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
O =  [0]*N
B = [[0 for i in range(N)] for j in range (N)]
a = list(map(int, input().split()))
for i in range(N):
  O[i] = a[i]
 
for j in range(M):
  o_1, o_2 = map(int, input().split())
  B[o_1-1][o_2-1] = 1
  B[o_2-1][o_1-1] = 1
 
ans = 0
for k in range(N):
  flag =1
  for l in range(N):
    if B[k][l] == 1 and O[k] <= O[l]:
      flag = 0
  if  flag ==1:
    ans += 1
print(ans)
Problem p02921 (python)

Fixed submission:
f = input()
r = input()
 
cnt = 0
for i in range(3):
  if f[i] == r[i]:
    cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
f = inout()
r = input()

cnt = 0
for i in range(3):
  if f[i] == r[i]:
    cnt += 1
print(cnt)
Problem p02910 (python)

Fixed submission:
s=input()
a=0
for i in range(0,len(s)):
  if i%2==0:
    if s[i]=='L':
      a=a-1
  else:
    if s[i]=='R':
      a=a-1
if a<0:
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
s=input()
for i in range(0:len(s)):
  if i%2==0:
    if s[i]=='L':
      print('No')
    else:
      print('Yes')
  else:
    if s[i]=='R':
      print('No')
    else:
      print('Yes')
Problem p03085 (python)

Fixed submission:

b = input()
if b == 'A':
    print('T')
elif b == 'T':
    print('A')
elif b == 'C':
    print('G')
else:
    print('C')

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

for i in range(q):
    count = 0
    l, r = map(int, input().split())
    # ss = s[l:r]
    for j in range(l-1,r):
        if s[j] == 'A':
            if j+1 < r:
                if s[j+1] == 'C':
                    count += 1
                j += 1
    print(count)

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

for i in range(q):
    count = 0
    l, r = map(int, input().split())
    for j in range(l-1,r):
        if s[j] == 'A':
            if j+1 < r:
                if s[j+1] == 'C':
                    count += 1
                j += 1
    print(count)

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

for i in range(q):
    count = 0
    l, r = map(int, input().split())
    for j in range(l-1,r):
        if s[j] == 'A':
            if j+1 < r:
                if s[j+1] == 'C':
                    count += 1
                j += 1
    print(count)
Problem p02641 (python)

Fixed submission:
ans=0
X,N=map(int,input().split())
p=list(map(int,input().split()))
for i in range(102):
    if i in p:
        p.remove(i)
    else:
        p.append(i)
for i in range(102-N):
    if abs(X-p[i])<abs(X-ans):
        ans=p[i]
print(ans)

Buggy submission (verdict: Runtime Error):

X,N=map(int,input().split())
p=list(map(int,input().split()))
for i in range(102):
    if i in p:
        p.remove(i)
    else:
        p.append(i)
for i in range(102-N):
    if abs(X-p[i])<abs(X-ans):
        ans=p[i]
print(ans)