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

Fixed submission:
kazu = int(input())
nums = list(map(int, input().split()))
count = 0
flg = True
while flg:
  for i in range(kazu):
    if nums[i] % 2 == 1:
      flg = False
      break
    else:
      nums[i] /= 2
  count += 1
count -= 1
print(count)

Buggy submission (verdict: Runtime Error):
kazu = int(input())
nums = list(map(int, input().split()))
count = 0
flg = True
while flg:
  for i in range(kazu):
    if nums[i] % 2 == 1:
      flg = False
      break
    else:
      nums[i] /= 2
    finally:
      count += 1
print(count)

Buggy submission (verdict: Runtime Error):
kazu = input()
nums = list(map(int, input().split()))
count = 0
flg = True
while flg:
  for i in range(kazu):
    if nums[i] % 2 == 1:
      flg = False
      break
    else:
      nums[i] /= 2
      count += 1
print(count)

Buggy submission (verdict: Runtime Error):
input()
nums = lint(map(int, input().split()))
count = 0
flg = True
while flg:
  for i, n in enumerate(nums):
    if n % 2 == 1:
      flg = False
      break
    else:
      nums[i] = n / 2
      count += 1
print(count)

Buggy submission (verdict: Runtime Error):
input()
nums = map(int, input().split())
count = 0
flg = True
while flg:
  for i, n in enumerate(nums):
    if n % 2 == 1:
      flg = False
      break
    else:
      nums[i] = n / 2
      count += 1
print(count)

Buggy submission (verdict: Runtime Error):
input()
nums = map(int, input().split())
count = 0
flg = True
while Flg:
  for i, n in enumerate(nums):
    if n % 2 == 1:
      flg = False
      break
    else:
      nums[i] = n / 2
      count += 1
print(count)

Buggy submission (verdict: Runtime Error):
input()
nums = map(int, input().split())
count = 0
while True:
  for i, n in enumerate(nums):
    if n % 2 == 1:
      break
    else:
      nums[i] = n / 2
      count += 1
print(count)

Buggy submission (verdict: Runtime Error):
nums = map(int, input().split())
count = 0
while True:
  for i, n in enumerate(nums):
    if n % 2 == 1:
      break
    else:
      nums[i] = n / 2
      count += 1
print(count)
Problem p02789 (python)

Fixed submission:
num1, num2 = [int(i) for i in input().split()]
if num1 == num2:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
num1, num2 = [int(i) for i in input().split()]
if num1 == num2
    print('Yes')
else
    print('No')

Buggy submission (verdict: Runtime Error):
import sys

num1, num2 = [int(i) for i in input().split()]
if (num1 = num2){
    print('Yes')
}else{
    print('No')
}
Problem p03573 (python)

Fixed submission:
A = input().split()

if A[0] == A[1]:
    print(A[2])
elif A[0] == A[2]:
    print(A[1])
else:
    print(A[0])

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())

if A == B:
    print(C)
elif A == C:
    print(B)
else:
    print(A)
Problem p02995 (python)

Fixed submission:
import os, sys, re, math

A,B,C,D = [int(s) for s in input().split(' ')]

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

lcm = C * D // gcd(C, D)

ret = B // C - (A-1) // C
ret += B // D - (A-1) // D
ret -= B // lcm - (A-1) // lcm
print(B-A+1-ret)

Buggy submission (verdict: Runtime Error):
import os, sys, re, math

A,B,C,D = [int(s) for s in input().split(' ')]

lcm = C * D // math.gcd(C, D)

ret = B // C - (A-1) // C
ret += B // D - (A-1) // D
ret -= B // lcm - (A-1) // lcm
print(B-A+1-ret)

Buggy submission (verdict: Runtime Error):
import os, sys, re, math

A,B,C,D = [int(s) for s in input().split(' ')]

lcm = C * D // math.gcd(C, D)

ret = B // C - (A-1) // C
ret += B // D - (A-1) // D
ret -= B // lcm - (A-1) // lcm
print(B-A+1-ret)
Problem p02996 (python)

Fixed submission:
import os, sys, re, math

N = int(input())

#memo = [0 for _ in range(int(2*1e5)+1)]
memo = {}

for _ in range(N):
	A,B = [int(s) for s in input().split(' ')]
	if B in memo:
		memo[B] += A
	else:
		memo[B] = A

s = 0
flg = True
key = list(memo.keys())
key = sorted(key)
for i in range(len(key)):
	s += memo[key[i]]
	if s > key[i]:
		flg = False
		break
if flg:
	print('Yes')
else:
	print('No')

Buggy submission (verdict: Runtime Error):
import os, sys, re, math

N = int(input())

#memo = [0 for _ in range(int(2*1e5)+1)]
memo = [0 for _ in range(2*int(1e5)+100)]

for _ in range(N):
	A,B = [int(s) for s in input().split(' ')]
	memo[B] += A

s = 0
flg = True
for i in range(len(memo)):
	s += memo[i]
	if s > i:
		flg = False
		break
if flg:
	print('Yes')
else:
	print('No')
Problem p03044 (python)

Fixed submission:
import os, sys, re, math, queue

N = int(input())

nodes = {}
colors = [-1 for _ in range(N+1)]
for _ in range(N-1):
    s = input().split(' ')
    u,v,w = int(s[0]), int(s[1]), int(s[2])
    if u not in nodes:
        nodes[u] = [(v,w)]
    else:
        nodes[u].append((v,w))

    if v not in nodes:
        nodes[v] = [(u,w)]
    else:
        nodes[v].append((u,w))

q = queue.Queue()
f = list(nodes.keys())[0]
q.put((f,0))

while not q.empty():
    cur = q.get()
    colors[cur[0]] = cur[1]
    next = nodes[cur[0]]
    for n in next:
        if colors[n[0]] == -1:
            if n[1] % 2 == 0:
                q.put((n[0], cur[1]))
            else:
                q.put((n[0], (cur[1]+1) % 2))

for i in range(N):
    print(colors[i+1])

Buggy submission (verdict: Runtime Error):
import os, sys, re, math, queue

N = int(input())
colors = [-1 for _ in range(N+1)]
nodes = {}

for _ in range(N-1):
	u,v,w = list(map(int,input().split(' ')))
	if u in nodes:
		nodes[u].append((v,w % 2))
	else:
		nodes[u] = [(v,w % 2)]

	if v in nodes:		
		nodes[v].append((u,w % 2))
	else:
		nodes[v] = [(u,w % 2)]

q = queue.Queue()
fst = list(nodes.keys())[0]
q.put((fst,0))

while not q.empty():
	pos, color = q.get()
	colors[pos] = color
	for cand in nodes[pos]:
		if colors[cand[0]] == -1:
			q.put((cand[0], (color+cand[1]) % 2)

for i in range(N):
	print(colors[i+1])
Problem p03047 (python)

Fixed submission:
import os, sys, re, math

n,k = input().split(' ')
print(int(n)-int(k)+1)

Buggy submission (verdict: Runtime Error):
import os, sys, re, math

n,k = input().split(',')
print(int(n)-int(k)+1)
Problem p03059 (python)

Fixed submission:
import os, sys, re, math

a,b,t = [s for s in input().split(' ')]
A = int(a)
B = int(b)
T = int(t) + 0.5
t = A
ret = 0
while  t < T:
  ret += B
  t += A

print(ret)

Buggy submission (verdict: Runtime Error):
import os, sys, re, math

inary = [int(s) for s in raw_input().split(' ')]

t = inary[0]
ret = 0
while t < inary[2]:
  ret += inary[1]
  t += inary[0]

print(ret)
Problem p03061 (python)

Fixed submission:
import os, sys, re, math, fractions

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

memo_L = [1] * N
memo_R = [1] * N

for i in range(N):
    if i == 0:
        memo_L[i] = A[i]
        memo_R[i] = A[N-1]
    elif i == N - 1:
        memo_L[i] = fractions.gcd(A[i], memo_L[i-1])
        memo_R[i] = fractions.gcd(A[0], memo_R[i-1])
    else:
        memo_L[i] = fractions.gcd(A[i], memo_L[i-1])
        memo_R[i] = fractions.gcd(A[N-1-i], memo_R[i-1])

memo_R.reverse()

ret = 1
for j in range(N):
    if j == 0:
        ret = max(ret, memo_R[1])
    elif j == N-1:
        ret = max(ret, memo_L[j-1])
    else:
        common_gcd = fractions.gcd(memo_L[j-1], memo_R[j+1])
        ret = max(ret, common_gcd)

print(ret)

Buggy submission (verdict: Runtime Error):
import os, sys, re, math

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

def common_gcd(ex_idx):
    ret = 0
    for i in range(N):
        if i != ex_idx:
            if ret == 0:
                ret = A[i]
            else:
                ret = math.gcd(ret, A[i])
    return ret

ret = 1
for j in range(N):
    ret = max(ret, common_gcd(j))

print(ret)
Problem p03274 (python)

Fixed submission:
import os, sys, re, math

N,K = map(int,input().split(' '))

candle = list(map(int,input().split(' ')))
ret = float('inf')

for i in range(N-K+1):
    s = candle[i]
    e = candle[i+K-1]
    if e < 0:
        ret = min(-s, ret)
    elif s > 0:
        ret = min(e, ret)
    else:
        ret = min(-s*2+e, -s+e*2, ret)

print(ret)

Buggy submission (verdict: Runtime Error):
import os, sys, re, math

N,K = map(int,input().split(' '))

candle = list(map(int,input().split(' ')))
ret = math.inf

for i in range(N-K+1):
    s = candle[i]
    e = candle[i+K-1]
    if e < 0:
        ret = min(-s, ret)
    elif s > 0:
        ret = min(e, ret)
    else:
        ret = min(-s*2+e, -s+e*2, ret)

print(ret)

Buggy submission (verdict: Runtime Error):
import os, sys, re, math

N,K = map(int,input().split(' '))

candle = list(map(int,input().split(' ')))
ret = math.inf

for i in range(N-K+1):
    s = candle[i]
    e = candle[i+K-1]
    if e < 0:
        ret = min(-s, ret)
    elif s > 0:
        ret = min(e, ret)
    else:
        ret = min(-s*2+e, -s+e*2, ret)

print(ret)
Problem p03282 (python)

Fixed submission:
import os, sys, re, math

def oneidx(S):
    idx = -1
    for s in S:
        if s == '1':
            idx += 1
        else:
            break
    return idx

S = input()
N = int(input()) - 1
idx = oneidx(S)

if idx >= N:
    print('1')
else:
    print(S[idx+1])

Buggy submission (verdict: Runtime Error):
import os, sys, re, math

def oneidx(S):
    idx = -1
    for s in S:
        if s == '1':
            idx += 1
        else:
            break
    return idx

S = input()
N = int(input())
idx = oneidx(S)

if idx >= N:
    print(N)
else:
    print(S[idx+1])
Problem p02791 (python)

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

q = p[0]
p = p[1:]

m = 1

if n > 1:
    for pi in p:
        if q > pi:
            m += 1
            q = pi

print(m)

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

if n > 1:
    for i, pi in enumerate(p):
        if pi <= i:
            continue
        elif all([pj >= pi for pj in p[:i]]):
            m += 1
        else:
            continue

print(m)

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

if len(pi) > 1:
    for i, pi in enumerate(p):
        if pi <= i:
            continue
        elif all([pj >= pi for pj in p[:i]]):
            m += 1
        else:
            continue

print(m)
Problem p02789 (python)

Fixed submission:
def read_ints(row):
    return list(map(int, row().split()))
  
import sys
 
row =sys.stdin.readline
N,M = read_ints(row)
print("Yes" if N == M else "No")

Buggy submission (verdict: Runtime Error):
def read_ints(row):
    return list(map(int, row().split()))
  
row = stdin.readline
N,M = read_ints(row)
print(N == M)
Problem p02801 (python)

Fixed submission:
import sys

row = sys.stdin.readline
# row = open('input.txt', 'r').readline
def read_string(row):
    return row().rstrip()
  
inp = read_string(row)
print(chr(ord(inp) + 1))

Buggy submission (verdict: Runtime Error):
import sys
# row = sys.stdin.readline
row = open('input.txt', 'r').readline
def read_string(row):
    return row().rstrip()
  
inp = read_string(row)
print(chr(ord(inp) + 1))
Problem p02812 (python)

Fixed submission:
import sys
row = sys.stdin.readline
def read_int(row):
    return int(row().rstrip())

def read_string(row):
    return row().rstrip()
  
N = read_int(row)
S = read_string(row)

cnt = 0
for i in range(0, len(S) -2):
    if S[i] == "A" and S[i+1] == "B" and S[i+2] == "C":
        cnt +=1
print(cnt)

Buggy submission (verdict: Runtime Error):
import sys
row = sys.stdin.readline
 
 
def read_int(row):
    return int(row().rstrip())
 
def read_string(row):
    return row().rstrip()
  
N = read_int(row)
S = read_string(row)
 
cnt = 0
for i in range(0, len(S) -3):
    if S[i] == "A" and S[i+1] == "B" and S[i+2] == "C":
        cnt +=1
print(cnt)
import sys
row = sys.stdin.readline


def read_int(row):
    return int(row().rstrip())

def read_string(row):
    return row().rstrip()
  
N = read_int(row)
S = read_string(row)

cnt = 0
for i in range(0, len(S) -2):
    if S[i] == "A" and S[i+1] == "B" and S[i+2] == "C":
        cnt +=1
print(cnt)
提出情報
提出日時
Problem p02818 (python)

Fixed submission:
import sys
row = sys.stdin.readline
 
def read_ints(row):
    return list(map(int, row().split()))
  
A ,B ,K = read_ints(row)
 
print(max(0, A - K),max(0, B-max(0,(K-A))))

Buggy submission (verdict: Runtime Error):
import sys
row = sys.stdin.readline
 
def read_ints(row):
    return list(map(int, row().split()))
  
A ,B ,K = read_ints(row)
 
result_A = 0 if A <= K else A-K
result_B = max(B -(K-A)) if A <= K else B
print(result_A,result_B)
Problem p02993 (python)

Fixed submission:
import sys
row = sys.stdin.readline
 
ls = list(row())
s = sum([1 for i in range(1, len(ls)) if ls[i-1] != ls[i]])
print("Good" if s+1 == len(ls) else "Bad")

Buggy submission (verdict: Runtime Error):
import sys
row = sys.stdin.readline
 
ls = list(row())
s = sum([1 for i in range(1, len(ls) + 1) if ls[i-1] == ls[i]])
print("Good" if s+1 == len(ls) else "Bad")

Buggy submission (verdict: Runtime Error):
import sys
row = sys.stdin.readline
 
ls = list(row())
s = sum([1 for i in range(1, len(ls) + 1) if ls[i-1] == ls[i]])
print("Good" if s == len(ls) else "Bad")
Problem p02789 (python)

Fixed submission:
x,y = input().split()
if x == y:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
x,y = input()
if x == y:
  print("Yes")
else:
  print("No")
Problem p03266 (python)

Fixed submission:
n,k = map(int,input().split())
if k % 2 ==1:
    a = n // k 
    print(a ** 3)
else:
    a = n // k
    if (a * k + k // 2) > n:
        print(2 * (a ** 3))
    else:
        print((a + 1) ** 3 + a ** 3)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
if K % 2 == 0:
    a = N // K 
    b = N // (k / 2) - a 
    print(a**3 + b ** 3)
else:
    a = N // K
    print(a**3)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
if K % 2 == 0:
    a = N // K 
    b = N // (k / 2) - a 
    print(a**3 + b ** 3)
else:
    a = N // K
    print(a**3)
Problem p03282 (python)

Fixed submission:
S = input()
K = int(input())


if S[0] != "1":
    print(S[0])
else:
    i = 0
    count = 0
    while i < len(S) and S[i] == "1":
        count += 1
        i += 1
    if K <= count:
        print(1)
    else:
        print(S[i])

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
if S[0] != "1":
    print(S[0])
else:
    i = 0
    count = 0
    for i in range(len(S)):
        if S[i] == "1":
            count += 1
            i += 1
    if K <= count:
        print(1)
    else:
        print(S[i])

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
if S[0] != "1":
    print(S[0])
else:
    i = 0
    count = 0
    while S[i] == "1":
        count += 1
        i += 1
    if K <= count:
        print(1)
    else:
        print(S[i])

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
if S[0] != "1":
    print(S[0])
else:
    i = 0
    count = 0
    while S[i] == "1":
        count += 1
        i += 1
    if K <= count:
        print(1)
    else:
        print(S[i])
Problem p03456 (python)

Fixed submission:
a, b = input().split()
c = int(a + b)
c = c ** 0.5
if isinstance(c,int) or c.is_integer():
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a, b = list(input().split())
c = int(a + b)
d = c ** 0.5
if isinstance(d,int):
  print(YES)
else:
  print(No)
Problem p02789 (python)

Fixed submission:
import sys
import os

#fname = "..\problems\problem1.txt"
#f = open(fname, 'r')
#sys.stdin = f

(N, M) = map(int, input().split())

if N == M:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
sta = list(map(int, input().split()))
sta2 = []

count_i = 0
for i in sta:
    sta2.append(i)
    if i <= min(sta2):
        count_i += 1

print(count_i)
Problem p02802 (python)

Fixed submission:
n, m = [int(x) for x in input().split()]
nac = 0
nwa = 0
past = {}
for i in range(m):
    p, s = [x for x in input().split()]
    d = p + s
    if (p + 'AC') in past:
        next
    else:
        if s == 'WA':
            past[d] = 1 if d not in past else past[d] + 1
        else:
            past[d] = 1
            nac += 1
            nwa += 0 if (p + 'WA') not in past else past[p + 'WA']
print(nac, nwa)

Buggy submission (verdict: Runtime Error):
n, m = [int(x) for x in input().split()]
nac = 0
nwa = 0
past_ac = {}
for i in range(m):
    p, s = [x for x in input().split()]
    d = p + s
    if (p + 'AC') in past_ac:
        next
    else:
        if s == 'WA':
            past_ac[d] = 1 if d not in past_ac else past_ac[d] + 1
        else:
            past_ac[d] = 1
            nac += 1
            nwa += past_ac[p + 'WA']
print(nac, nwa)
Problem p02995 (python)

Fixed submission:
import fractions
A, B, C, D = (int(x) for x in input().split())
x = (B // C) - ((A - 1) // C)
x += (B // D) - ((A - 1) // D)
lcm = (C * D) // fractions.gcd(C, D)
x -= (B // lcm) - ((A - 1) // lcm)
print((B - A + 1) - x)

Buggy submission (verdict: Runtime Error):
import math
A, B, C, D = (int(x) for x in input().split())
x = (B // C) - (A // C)
x += (B // D) - (A // D)
lcm = (C * D) // math.gcd(C, D)
x -= (B // lcm) - (A // lcm)
print((B - A + 1) - x)
Problem p02996 (python)

Fixed submission:
N = int(input())
A = [0] * N
B = [0] * N
AB = [0] * N
BA = [0] * N
for i in range(N):
    A[i], B[i] = [int(x) for x in input().split()]
    BA[i] = [B[i], A[i]]
list.sort(BA)
t = 0
fail = 0
for n in range(N):
    t += BA[n][1]
    if t > BA[n][0]:
        fail = 1
        break
if fail:
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [0] * N
B = [0] * N
AB = [0] * N
BA = [0] * N
need = {}
for i in range(N):
    A[i], B[i] = [int(x) for x in input().split()]
    need[B[i]] = A[i]
    BA[i] = [B[i], A[i]]
list.sort(BA)
t = 0
fail = 0
for n in range(N):å
    t += BA[n][1]
    if t > BA[n][0]:
        fail = 1
        break
if fail:
    print('No')
else:
    print('Yes')
Problem p03037 (python)

Fixed submission:
N, M = (int(x) for x in input().split())
Lmax = -1
Rmin = N + 1
for i in range(M):
    L, R = (int(x) for x in input().split())
    if Lmax < L:
        Lmax = L
    if Rmin > R:
        Rmin = R
if (Rmin - Lmax) >= 0:
    print(Rmin - Lmax + 1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
N, M = (int(x) for x in input().split())
A = [int(x) for x in input().split()]
B = [0] * M
C = [0] * M
Bsum = 0
for i in range(M):
    B[i], C[i] = (int(x) for x in input().split())
    Bsum += B[i]
Problem p03059 (python)

Fixed submission:
A, B, T = (int(x) for x in input().split())
 
print((T//A)*B)

Buggy submission (verdict: Runtime Error):
A, B, T = int(x) for x in input().split()

print((T//A)*B)
Problem p03076 (python)

Fixed submission:
import math
A = [0] * 5
A[0] = int(input())
A[1] = int(input())
A[2] = int(input())
A[3] = int(input())
A[4] = int(input())
ans = 0
min1 = 10
for i in range(0,5):
    m = A[i] % 10
    if ((m > 0) and (m < min1)):
        min1 = m        
    ans += math.ceil(A[i] / 10) * 10
print(ans - (10 - min1))

Buggy submission (verdict: Runtime Error):
A = [0] * 5
A[0] = int(input())
A[1] = int(input())
A[2] = int(input())
A[3] = int(input())
A[4] = int(input())
ans = 0
min1 = 10
for i in range(0,5):
    m = A[i] % 10
    if ((m > 0) and (m < min1)):
        min1 = m        
    ans += math.ceil(A[i] / 10) * 10
print(ans - (10 - min1))
Problem p03086 (python)

Fixed submission:
s = input()
z = ''
ans = 0
for i in range(len(s)):
    if s[i] in 'ACGT':
        ans = max(ans, 1)
        for j in range(i+1, len(s)):
            if s[j] in 'ACGT':
                ans = max(ans, j-i+1)
            else:
                break
    else:
        continue
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
z = ''
ans = ''
for i in range(len(s)):
  if s[i] in 'ACGT':
    z = s[i]
	for j in range(i+1, len(s)):
      if s[j] in 'ACGT':
        z += s[j]
      else:
        if len(s) > len(ans):
          ans = s
        z = ''
  else:
    continue
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
max = 0
for i in range(len(S)):
    if S[i] in 'ACGT':
        for j in range(i+1, len(S)):
            if not S[j] in 'ACGT':
                break
        max = (j - i) if max < (j - i) else max 
print(max)

Buggy submission (verdict: Runtime Error):
S = input()
max = 0
for i in range(len(S)):
    if S[i] in 'ACGT':
        for j in range(i+1, len(S)):
            if S[j] not in 'ACGT':
                break
        max = (j - i) if max < (j - i) else max 
print(max)

Buggy submission (verdict: Runtime Error):
S = input()
max = 0
for i in range(len(S)):
    if S[i] in 'ACGT':
        for j in range(i+1, len(S)):
            if S[j] not in ['A', 'C', 'G', 'T']:
                break
        max = (j - i) if max < (j - i) else max 
print(max)
Problem p03087 (python)

Fixed submission:
N, Q = (int(x) for x in input().split())
S = input()

a_loc = [0] * (N + 1)
for i in range(N):
    a_loc[i+1] = a_loc[i] + (1 if S[i:i+2] == 'AC' else 0)

ans = [0] * Q
for i in range(Q):
    l, r = (int(x) for x in input().split())
    ans[i] = a_loc[r-1] - a_loc[l-1]
    
for i in range(Q):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
N, Q = (int(x) for x in input().split())
S = input()
lr = [[0 for x in range(2)] for y in range(Q)]
for i in range(Q):
    lr[i] = [int(x) for x in input().split()]

a_loc = set()
for i in range(len(S)):
    if (S[i] == 'A') and (S[i+1] == 'C'):
        a_loc.add(i)
ans = [0] * Q

for i in range(Q):
    l,r = (lr[i][0], lr[i][1])
    num = 0
    for j in range(l-1, r-1):
        if j in a_loc:
            num += 1
    ans[i] = num

for i in range(Q):
    print(ans[i])
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 = int(input())
if N == 1:
	print("Hello World")
else:
	A = int(input())
    B = int(input())
    print(A+B)
Problem p03284 (python)

Fixed submission:
n, k = map(int, input().split())
print(0 if n % k == 0 else 1)

Buggy submission (verdict: Runtime Error):
n = int(input())
x = 0
for i in range(0, n+1, 4):
    if (n - i) % 7 == 0:
        x = 1
print(('No','Yes')[x])
Problem p03292 (python)

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

Buggy submission (verdict: Runtime Error):
a=map(int,input().split())
print(max(a)-min(a))
Problem p03323 (python)

Fixed submission:
a=max(list(map(int,input().split())));print(':('if a>8 else'Yay!')

Buggy submission (verdict: Runtime Error):
a=max(list(map(int,input().split()));print(':('if a>8 else'Yay!')

Buggy submission (verdict: Runtime Error):
a=max(list(map(int,input().split()))
print(':('if a>8else'Yay!')
Problem p03377 (python)

Fixed submission:
A, B, X = (int(x) for x in input().split())
if (A <= X) and ((A + B) >= X):
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
A, B, X = int(x) for x in input().split()
if (A <= X) and ((A + B) >= X):
  print("YES")
else:
  print("NO")
Problem p03469 (python)

Fixed submission:
S=input()
print(S[0:3]+'8'+S[4:])

Buggy submission (verdict: Runtime Error):
S=input()
S[3]='8'
print(S)
Problem p02861 (python)

Fixed submission:
import math

n=int(input())
listx=[]
listy=[]

for i in range(n):
  x,y = map(int,input().split())
  listx.append(x)
  listy.append(y)

#print(listx)
#print(listy)
listl=[]
if n==2:
	ans=((listx[1]-listx[0])**2+(listy[1]-listy[0])**2)**0.5



else:
	for i in range(n-1):
		for j in range(i+1,n):
			l=((listx[i]-listx[j])**2+(listy[i]-listy[j])**2)**0.5
			listl.append(l)
	ll=sum(listl)	
	ans=2*ll/n

print(ans)

Buggy submission (verdict: Runtime Error):
import math

n=int(input())
listx=[]
listy=[]

for i in range(n):
  x,y = map(int,input().split())
  listx.append(x)
  listy.append(y)

%print(listx)
%print(listy)
listl=[]
if n==2:
	ans=((listx[1]-listx[0])**2+(listy[1]-listy[0])**2)**0.5



else:
	for i in range(n-1):
		for j in range(i+1,n):
			l=((listx[i]-listx[j])**2+(listy[i]-listy[j])**2)**0.5
			listl.append(l)
	ll=sum(listl)	
	ans=2*ll/n

print(ans)