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

Fixed submission:
S = input()
max_l = 0
temp_l = 0

for s in S:
    if s == 'A' or s=='G' or s=='C' or s=='T':
        temp_l += 1
        max_l = max(max_l, temp_l)
    else:
        temp_l = 0

print(max_l)

Buggy submission (verdict: Runtime Error):
S = input()
max_l = 0
temp_l = 0

for s in S:
    if s == 'A' or s=='G' or s=='C' or s=='T':
        temp_l += 1
        
    else:
      	max_l = max(max_l, temp_l)
        temp_l = 0

print(max_l)
Problem p03087 (python)

Fixed submission:
# coding: utf-8

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

num = [0] * (N+1)

for i in range(N):
    #if S[i]=='A' and S[i+1]=='C':
    if S[i:i+2] =='AC':
        num[i + 1] = num[i] + 1
    else:
        num[i + 1] = num[i]

        

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

Buggy submission (verdict: Runtime Error):
# coding: utf-8

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


num = [0] * (N+1)
for i in range(N):
    if S[i]=='A' and S[i+1]=='C':
        num[i + 1] = num[i] + 1
    else:
        num[i + 1] = num[i]

        

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

Buggy submission (verdict: Runtime Error):
# coding: utf-8

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


num = [0] * (N+1)
i = 0
for i in range(N):
    if S[i]=='A' and S[i+1]=='C':
        num[i + 1] = num[i] + 1
    else:
        num[i + 1] = num[i]

        

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

Buggy submission (verdict: Runtime Error):
# coding: utf-8

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

## S中で、'AC'であるインデックスを求める
num = [0] * (N+1)
i = 0
for i in range(N):
    if S[i]=='A' and S[i+1]=='C':
        num[i + 1] = num[i] + 1
    else:
        num[i + 1] = num[i]

#print(num)

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

Buggy submission (verdict: Runtime Error):
# coding: utf-8

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

## S中で、'AC'であるインデックスを求める
index = [0] * N
i = 0
while i < len(S)-1:
    if S[i]=='A' and S[i+1]=='C':
        index[i] = 1
        i += 2
    else:
        i += 1
num = [sum(index[i]) for i in range(N)]

#print('\n')
#print(index)

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

Fixed submission:
strings = input().split('/')
s = list(map(int, strings))
flag = 1
if s[0] > 2019:
    flag = 0
elif s[0] == 2019:
    if s[1] > 4:
        flag = 0

ans_list = ['TBD', 'Heisei']
print(ans_list[flag])

Buggy submission (verdict: Runtime Error):
s = list(map(int, input().split('/')))
flag = 1
if s[0] > 2019:
    flag = 0
elif s[0] == 2019:
    if s[1] > 4:
        flag = 0

ans_list = ['TBD', 'Heisei']
print(ans[flag])
Problem p03110 (python)

Fixed submission:
rate = 380000
N = int(input())

total = 0
for i in range(N):
    x, u = input().split()
    val = float(x)
    if u=='BTC':
        val *= rate
    total += val
print(total)

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

total = 0
for i in range(N):
    x,u = input()
    val = int(x)
    if u=='BTC':
        val *= rate
    total += val
print(total)
Problem p03261 (python)

Fixed submission:
N = int(input())
W = [0] * N
for i in range(N):
    W[i] = input()
if len(set(W)) != N:
    print('No')
    exit()
for i in range(N - 1):
    w1 = W[i]
    w2 = W[i+1]
    if w1[-1] != w2[0]:
        print('No')
        exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
N = int(input())
W = []
for j in range(N):
  W.append(input())
  j += 1


i = 0
while i < N:
  m = W[i-1]
  n = W[i]
  if m[-1:] == n[:1]:
    i += 1
  else:
    print('No')
    exit()
else:
  W.sort()
  for k in range(N):
      m = W[i]
      n = W[i+1]
      if m == n:
        print('No')
        exit()
print('Yes')
Problem p03264 (python)

Fixed submission:
K = int(input())
if K % 2 == 0:
  print(int(K * K / 4))
else:
  print(int((K * K - 1) / 4))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
ans = 0
for i in range(1,N + 1):
  for j in range(1,N + 1):
    for k in range(1,N + 1):
      if ((i + j) % K == 0) and ((j + k) % K == 0) and ((k + i) % K == 0):
        ans += 1
print(ans)
Problem p03324 (python)

Fixed submission:
D, N = map(int, input().split())
if N == 100:
  print((100 ** D) * (101))
else:
  print((100 ** D) * N)

Buggy submission (verdict: Runtime Error):
D, N = map(int, input().split())
if N = 100:
  print((100 ** D) * (101))
else:
  print((100 ** D) * N)

Buggy submission (verdict: Runtime Error):
D, N = map(int, input().split())
if n = 100:
  print((100 ** D) * (N+1))
else:
  print((100 ** D) * N)
Problem p03337 (python)

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

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
print(max[a*b,a+b,a-b])
Problem p03377 (python)

Fixed submission:
A, B, X=map(int,input().split())
if A <= X <= A + B:
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
if A <= X <= A + B:
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
if A <= X <= A + B:
  print('YES')
else:
  print('No')
Problem p03407 (python)

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

Buggy submission (verdict: Runtime Error):
a, b, c = map(int,input(),split())
if a + b <= c:
  print('Yes')
else:
  print('No')
Problem p03101 (python)

Fixed submission:
import numpy as np
H,W = map(int,input().split())
h,w = map(int,input().split())
matrix = np.ones((H,W))
h_num = np.random.choice(H,h,replace=False)
w_num = np.random.choice(W,w,replace=False)

for _ in h_num:
  matrix[_,:] = 0
for _ in w_num:
  matrix[:,_] = 0

print(int(np.sum(matrix)))

Buggy submission (verdict: Runtime Error):
import numpy as np
N,M = map(int,input().split())
A_s = []
for _ in range(N):
  A_s.append(list(map(int,input().split())))
## Aiの順にsortする
A_s = sorted(A_s,key=lambda x:x[0])
money = 0
num = 0
pre_num = 0
for a_s in A_s:
  num += a_s[1]
  if num <= M:
    money += a_s[1] * a_s[0]
    pre_num += a_s[1]
  else:
    money += (M-pre_num) * a_s[0]
    break
  #print(money)
print(money)

Buggy submission (verdict: Runtime Error):
import numpy as np
A,B = map(int,input().split())
b = np.arange(A,B+1)
def bin2np(a):
  return list(map(int,list(bin(a)[2:])))
# 1番長い二進数の配列を知る
max_length = len(bin2np(b[-1]))
## ここから、足りない分だけ前に挿入していく
bin2list = []
for a in b:
  c = bin2np(a)
  for _ in range(max_length-len(c)):
    c.insert(0,0)
  #print(c)
  bin2list.append(c)
bin2list = np.array(bin2list)
bin2s = list(map(str,np.where(np.sum(bin2list,axis=0)==1,1,0)))
print(int("".join(bin2s),2))
Problem p03068 (python)

Fixed submission:
import copy 

n = int(input())
s = list(input())
k = int(input())

ans = s
for i in range(n):
    if ans[i] != s[k - 1]:
        ans[i] = '*'
print(''.join(ans))

Buggy submission (verdict: Runtime Error):
import copy 

n = int(input())
s = list(input())
k = int(input())

ans = s
for i in range(n):
    if ans[i] != s[k]:
        ans[i] = '*'
print(''.join(ans))
Problem p03136 (python)

Fixed submission:
Q = int(input())
N = list(map(int, input().split()))
max_N = max(N)

if max_N < sum(N)-max_N :
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N = list(input())
max_N = max(N)

if max_N < sum(N)-max_N :
  print("Yes")
else:
  print("No")
Problem p03111 (python)

Fixed submission:
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]

INF = 10 ** 9

def dfs(cur, a, b, c):
  if cur == N:
    return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

Buggy submission (verdict: Runtime Error):
N, A, B, C = map(int, input().split())
L = [int(input()) for i in range(N)]

INF = 10 ** 9

def dfs(cur, a, b, c):
  if cur == N:
    return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

Buggy submission (verdict: Runtime Error):
N, A, B, C = map(int, input().split())
L = [int(input()) for i in range(N)]

INF = 10 ** 9


def dfs(cursor, a, b, c):  # cursor:カーソル a,b,c:現在の竹の長さ
    if cursor == N:  # cursorが最後まで行ったら終了する。
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) &gt; 0 else INF
    # abs(a - A) + abs(b - B) + abs(c - C) - 30 でなぜ30を減じているのかというと、
    # dfs(0,0,0)
    # dfs(0,0,0,0)で始まる以上、最初に選ばれるa,b,cを決定する際にもコストが10増加してしまうからである。
    # また、全探索を行う中で、a,b,cの初期値が0,0,0である以上、a,b,cのどれかが0のまま終了する場合が存在する。
    # この場合はa,b,cに竹が対応してないと言えるため、解にはならない、そこで三項演算子を利用して
    # その場合についてコストをINFとしている

    # 以下は4**Nで展開される再起処理となる。
    # カーソルの当たっている竹に対して、(A or B or Cに合成する) or (合成しない)の場合に分ける
    no_compound_pattern = dfs(cursor+1, a, b, c)
    compound_a_pattern = dfs(cursor+1, a + L[cursor], b, c)+10
    compound_b_pattern = dfs(cursor+1, a, b + L[cursor], c)+10
    compound_c_pattern = dfs(cursor+1, a, b, c + L[cursor])+10

    # 結果的に以下の値が返るのはそれぞれのパターンのコストが決定されてからなので
    # 以下のコードは最終的なコストの最小値
    return min(no_compound_pattern, compound_a_pattern, compound_b_pattern, compound_c_pattern)


print(dfs(0, 0, 0, 0))
Problem p03943 (python)

Fixed submission:
def read():
	return [int(i) for i in input().split(' ')]
L = read()
if(L[0] + L[1] == L[2] or L[0] + L[2] == L[1] or L[1] + L[2] == L[0]):
	print('Yes')
else:
	print('No')

Buggy submission (verdict: Runtime Error):
def read():
	return [int(i) for i in input().split(' ')]
L = read()
if(L[0] + L[1] == L[2] or L[0] + L[2] == L[1] or L[1] + L[2] == L[3]):
	print('Yes')
else:
	print('No')

Buggy submission (verdict: Runtime Error):
def read():
	return [int(i) for i in input().split(' ')]
L = read()
if(L[0] + L[1] == L[2] or L[0] + L[2] == L[1] or L[1] + L[2] == L[3]):
	print('Yes')
else:
	print('No')
Problem p03944 (python)

Fixed submission:
def read():
	return [int(i) for i in input().split(' ')]
W, H, N = read()
x = [0] * N
y = [0] * N
a = [0] * N
for i in range(N):
	x[i], y[i], a[i] = read()
new_x = [0] + x + [W]
new_y = [0] + y + [H]
for inx in range(N):
	if(a[inx] == 1):
		new_x = [num for num in new_x if num >= x[inx]] 
	elif(a[inx] == 2):
		new_x = [num for num in new_x if num <= x[inx]] 
	elif(a[inx] == 3):
		new_y = [num for num in new_y if num >= y[inx]] 
	else:
		new_y = [num for num in new_y if num <= y[inx]] 
if(not(new_x) or not(new_y)):
	print(0)
	exit()
area = (max(new_x) - min(new_x)) * (max(new_y) - min(new_y))
print(area)

Buggy submission (verdict: Runtime Error):
def read():
	return [int(i) for i in input().split(' ')]
W, H, N = read()
x = [0] * N
y = [0] * N
a = [0] * N
for i in range(N):
	x[i], y[i], a[i] = read()
new_x = [0] + x + [W]
new_y = [0] + y + [H]
for inx in range(N):
	if(a[inx] == 1):
		new_x = [num for num in new_x if num >= x[inx]] 
	elif(a[inx] == 2):
		new_x = [num for num in new_x if num <= x[inx]] 
	elif(a[inx] == 3):
		new_y = [num for num in new_y if num >= y[inx]] 
	else:
		new_y = [num for num in new_y if num <= y[inx]] 
area = (max(new_x) - min(new_x)) * (max(new_y) - min(new_y))
print(area)
Problem p03957 (python)

Fixed submission:
import re
s = input()
pattern = re.compile(r'C.*F')
match = pattern.search(s)
if match:
	print('Yes')
else:
	print('No')

Buggy submission (verdict: Runtime Error):
def read():
	return [int(i) for i in input().split(" ")]
N = int(input())
T = read()
A = read()
L = [0] * N
unknowL = [0] * N
tempT, tempA = 0, 0
for i in range(N):
	if(T[i] > tempT):
		tempT = L[i] = T[i]
	else:
		unknowL[i] = T[i]
for i in range(N-1, -1, -1):
	if(A[i] > tempA):
		if(L[i] != 0 and L[i] != A[i]):
			print(0)
			exit()
		tempA = L[i] = A[i]
		unknowL[i] = 0
	else:
		unknowL[i] = min(unknowL[i], A[i])
P = 1 
for i in unknowL:
	if(i != 0):
		P *= i	
print(P % (10**9 +7))
Problem p03959 (python)

Fixed submission:
def read():
	return [int(i) for i in input().split(" ")]
N = int(input())
T = read()
A = read()
t = [(i != j, i) for i, j in zip(T, [None] + T)]
a = [(i != j, i) for i, j in zip(A, (A + [None])[1:])]
P = 1
for p, q in zip(t, a):
	if(p[0]):
		if(q[0]):
			if(p[1] != q[1]):
				print(0)
				exit()
		else:
			if(q[1] < p[1]):
				print(0)
				exit()
	elif(q[0]):
		if(p[1] < q[1]):
			print(0)
			exit()
	else:
		P = P * min(p[1], q[1]) % (10 ** 9 + 7)
print(P)

Buggy submission (verdict: Runtime Error):
def read():
	return [int(i) for i in input().split(" ")]
N = int(input())
T = read()
A = read()
t = [(i != j, i) for i, j in zip(T, [None] + T)]
a = [(i != j, i) for i, j in zip(A, (A + [None])[1:])]
P = 1
for p, q in zip(t, a):
	if(p[0]):
		if(q[0]):
			if(p[1] != q[1]):
				print(0)
				exit()
		else:
			if(q[1] < p[1]):
				print(0)
				exit()
	elif(q[0]):
		if(p[1] < q[1]):
			print(0)
			exit()
	else:
		P = P * min(p[1], q[1]) % (10 ** 9 + 7))
print(P)

Buggy submission (verdict: Runtime Error):
def read():
	return [int(i) for i in input().split(" ")]
N = int(input())
T = read()
A = read()
t = [(i != j, i) for i, j in zip(T, [None] + T)]
a = [(i != j, i) for i, j in zip(A, (A + [None])[1:])]
P = 1
for p, q in zip(t, a):
	if(p[0]):
		if(q[0]):
			if(p[1] != q[1]):
				print(0)
				exit()
		elif(q[1] < p[1]):
			print(0)
			exit()
	elif(q[0]):
		if(p[1] < q[1]):
			print(0)
			exit()
	else:
		P *= min(p[1], q[1])
print(P % (10 ** 9 + 7)

Buggy submission (verdict: Runtime Error):
def read():
	return [int(i) for i in input().split(" ")]
N = int(input())
T = read()
A = read()
tempT, tempA = 0, 0
for i in range(N):
	if(T[i] > tempT):
		tempT = L[i] = T[i]
		L.append(tempT)
		unknowL.append(0)
	else:
		unknowL.append(T[i])
		L.append(0)
for i in range(N):
	val = A.pop()
	if(A[i] > tempA):
		if(L[i] != 0 and L[i] != val):
			print(0)
			exit()
		tempA = L[i] = val 
		unknowL[i] = 0
	else:
		unknowL[i] = min(unknowL[i], val)
P = 1 
for i in unknowL:
	if(i != 0):
		P *= i	
print(P % (10**9 +7))

Buggy submission (verdict: Runtime Error):
def read():
	return [int(i) for i in input().split(" ")]
N = int(input())
T = read()
A = read()
tempT, tempA = 0, 0
for i in range(N):
	if(T[i] > tempT):
		tempT = L[i] = T[i]
		L.append(tempT)
		unknowL.append(0)
	else:
		unknowL.append(T[i])
		L.append(0)
for i in range(N-1, -1, -1):
	if(A[i] > tempA):
		if(L[i] != 0 and L[i] != A[i]):
			print(0)
			exit()
		tempA = L[i] = A[i]
		unknowL[i] = 0
	else:
		unknowL[i] = min(unknowL[i], A[i])
P = 1 
for i in unknowL:
	if(i != 0):
		P *= i	
print(P % (10**9 +7))
Problem p03993 (python)

Fixed submission:
#B-Friendly Rabbits
num = int(input())
str = input()
Li = list(map(int,str.split(' ')))
CoupleNum = 0
for pointer in range(len(Li)):
	ai = Li[pointer]
	if (ai > pointer+1):
		if (Li[ai-1]==pointer+1):
			CoupleNum += 1
print(CoupleNum)

Buggy submission (verdict: Runtime Error):
num = int(input())
str = input()
Li = list(map(int,str.split(' ')))
CoupleNum = 0
for pointer in range(len(Li):
     ai = Li[pointer]
     if (ai > pointer+1):
         if (Li[ai-1]=pointer+1):
             CoupleNum++
print(CoupleNum)
Problem p03994 (python)

Fixed submission:
#C-Next Letter
str = input()
K = int(input())
tempK = K
result = ""
for i in range(len(str)-1):
	changeNum = 122-ord(str[i])+1
	if (changeNum <= tempK and str[i] != "a"):
		result += "a"
		tempK -= changeNum
	else:
		result += str[i]
tempK %= 26
if (tempK > 0):
	changeNum = ord(str[-1]) + tempK
	if (changeNum > 122):
		changeNum = changeNum -122 + 97 -1
	else:
		changeNum = changeNum
	result += chr(changeNum)
else:
	result += str[-1]
print(result)

Buggy submission (verdict: Runtime Error):
#C-Next Letter
str = input()
K = int(input())
tempK = K
result = ""
for i in range(len(str)-1):
	changeNum = 122-ord(str[i])+1
	if (changeNum <= tempK):
		result += "a"
		tempK -= changeNum
		if (tempK == 0):
			result += str[i+:]
			print(result)
			break
	else:
		result += str[i]
tempK %= 26
if (tempK > 0):
	changeNum = ord(str[-1]) + tempK
	if (changeNum > 122):
		changeNum = changeNum -122 + 97 -1
	else:
		changeNum = changeNum
	result += chr(changeNum)
else:
	result += str[-1]
print(result)
Problem p03996 (python)

Fixed submission:
def reads(offset = 0):
	return [int(i) - offset for i in input().split(' ')]
def Judge(vector):
	length = len(vector)-1
	for i in range(length):
		if(vector[i] > vector[i+1]):		
			return 0
	return 1
(N, M) = reads()
Q = int(input())
A = reads(1)
pos = [-1] * M
pat = []
freq = [0] * (M+1)
freq[0] = N
found = set()
counter = 0
for i in A[::-1]:
	if (i not in found):
		pat.append(i)
		found.add(i)
		pos[i] = counter
		counter += 1
		if(counter == M):
			break
for i in range(M):
	if (pos[i] == -1):
		pat.append(i)	
for i in A[::-1]:
	temp = pos[i]
	if (freq[temp] > 0):
		freq[temp] -= 1
		freq[temp+1] += 1
start = M
for i in range(M):
	if (freq[i] != 0):
		start = i
		break
print("Yes") if Judge(pat[start:]) else print("No")

Buggy submission (verdict: Runtime Error):
def reads(offset = 0):
	return [int(i) - offset for i in input().split(' ')]
def Judge(vector):
	length = len(vector)-1
	for i in range(length):
		if(vector[i] > vector[i+1]):		
			return 0
	return 1
(N, M) = reads()
Q = int(input())
A = reads(1)
pos = [-1] * M
pat = []
freq = [0] * (M+1)
freq[0] = N
found = set()
for i in A[::-1]:
	if (i not in found):
		pat.append(i)
		found.add(i)
		pos[i] = counter
for i in range(M):
	if (pos[i] == -1):
		pat.append(i)		
for i in A[::-1]:
	temp = pos[i]
	if (freq[temp] > 0):
		freq[temp] -= 1
		freq[temp+1] += 1
for i in range(M+1):
	if (freq[i] != 0):
		start = i
		break
print("Yes") if Judge(pat[start:]) else print("No")

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
def ReadInput():
	return [int(a) for a in input().split(' ')]
(N, M) = ReadInput()
Q = int(input())
Array = ReadInput()
def ifEqual(x):
	temp = None
	for i in x:
		if (temp == None):	
			temp = x[i]
			continue
		elif (x[i] != temp):
			print('ifEqual is 0')
			return 0
	return temp
def check(Array, N, M, *args):
	Count = defaultdict(int)
	Array.reverse()
	if ("reverse") not in args:
		for i in Array:
			if (i == 1 or Count[i] < Count[i-1]):
				Count[i] += 1
			else:	
				return 0
		Count.pop(N)
		if(ifEqual(Count)):
			return 1
		else:
			return 0
	else:
		for i in Array:
			if (i == N or Count[i] < Count[i+1]):
				Count[i] += 1
			else:
				return 0
		Count.pop(1)
		if(ifEqual(Count) >= M):
			return 1
		else
			return 0
if (check(Array, N, M) or check(Array, N, M, "reverse")):
	print("Yes")
else:
	print("No")
Problem p03087 (python)

Fixed submission:
N,Q=map(int,input().split())
S=input()
l=[0]*Q
r=[0]*Q
for i in range(Q):
  l[i],r[i]=map(int,input().split())
counter=[0]*N
for i in range(N-1):
  if S[i]=="A":
    counter[i]=counter[i-1]+(S[i+1]=="C")
  else:counter[i]=counter[i-1]
for j in range(Q):
  print(counter[r[j]-2]-counter[l[j]-2])

Buggy submission (verdict: Runtime Error):
N,Q=map(int,input().split())
S=input()
l=[0]*Q
r=[0]*Q
for i in range(Q):
  l[i],r[i]=map(int,input().split())
counter=[0]*N
for i in range(len(S)-1):
  if S[i]=="A":
    counter[i]+=counter[i-1]+(S[i+1]=="C")
  else:counter[i]=counter[i-1]
for j in range(Q):
  print(counter[r[j-1]]-counter[l[j-1]])

Buggy submission (verdict: Runtime Error):
N,Q=map(int,input().split())
S=input()
l=[0]*Q
r=[0]*Q
for i in range(Q):
  l[i],r[i]=map(int,input().split())
answer=[0]*Q
counter=[1 if (i!=len(S))and(S[i]=="A")and(S[i+1]=="C") else 0 for i in range(len(S))]
for j in range(Q):
  answer[j]=sum(counter[l[j]-1:r[j]-1])
for i in range(Q):
  print(answer[i])
Problem p03105 (python)

Fixed submission:
a=list(map(int,input().split()))
A=a[0]
B=a[1]
C=a[2]
if B>=A*C:
  answer=C
else:
  answer=B//A
print(answer)

Buggy submission (verdict: Runtime Error):
A,B,K=list(map(int,input().split()))
count=0
z=[A,B]
for i in range(max(z),0,-1):
  if (A%i==0)and(B%i==0):
    count+=1
    if count==K:
      ans=i
      break
print(ans)

Buggy submission (verdict: Runtime Error):
A,B,K=list(map(int,input().split()))
count=0
z=[A,B]
for i in range(1,max(z)+1):
  if (A%i==0)and(B%i==0):
    count+=1
    if count==K:
      ans=count
      break
print(ans)
Problem p03106 (python)

Fixed submission:
A,B,K=list(map(int,input().split()))
count=0
z=[A,B]
for i in range(max(z),0,-1):
  if (A%i==0)and(B%i==0):
    count+=1
    if count==K:
      ans=i
      break
print(ans)

Buggy submission (verdict: Runtime Error):
A,B,K=list(map(int,input().split()))
count=0
z=[A,B]
for i in range(max(z)):
  if (A%i==0)and(B%i==0):
    count+=1
    if count==K:
      ans=count
      break
print(ans)

Buggy submission (verdict: Runtime Error):
A,B,K=list(map(int,input().split()))
count=0
for i in max(A,B):
  if (A%i==0)and(B%i==0):
    count+=1
    if count==K:
      ans=count
      break
print(ans)
Problem p03210 (python)

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

Buggy submission (verdict: Runtime Error):
X=int(input())
print("YES" if X==3or5or7 else "NO")
Problem p03260 (python)

Fixed submission:
A,B=map(int,input().split())
print("Yes" if (A*B)%2==1 else "No")

Buggy submission (verdict: Runtime Error):
A,B=int(input().split())
print("Yes" if (A*B)%1==0 else "No")
Problem p03264 (python)

Fixed submission:
K=int(input())
if K%2==0:
  print((K//2)**2)
else:
  print(K//2*(K//2+1))

Buggy submission (verdict: Runtime Error):
K=int(input())
if K%2==0:
  print((K//2)**2)
else:
  print(K//2*(k//2+1))
Problem p03292 (python)

Fixed submission:
cost_list=list(map(int,input().split()))
cost_list.sort(reverse=True)
sum=0
for i in range(len(cost_list)-1):
  sum+=(cost_list[i]-cost_list[i+1])
print(sum)

Buggy submission (verdict: Runtime Error):
*cost_list=map(int,input().split())
cost_list.sort(reverse=True)
sum=0
for i in range(len(cost_list)-1):
  sum+=(cost_list[i]-cost_list[i+1])
print(sum)

Buggy submission (verdict: Runtime Error):
cost_list=list(map(int,input().split())
cost_list.sort(reverse=True)
sum=0
for i in range(len(cost_list)-1):
  sum+=(cost_list[i]-cost_list[i+1])
print(sum)

Buggy submission (verdict: Runtime Error):
cost_list=list(map(int,input().split())
cost_list.sort(reverse=True)
sum=0
for i in range(len(cost_list)-1):
  sum+=cost_list[i]-cost_list[i+1]
print(sum)
Problem p03385 (python)

Fixed submission:
print("Yes" if len(set(input()))==3 else "No")

Buggy submission (verdict: Runtime Error):
print("Yes" if len(set(input())))==3 else "No")
Problem p03456 (python)

Fixed submission:
a,b=input().split()
z=int(a+b)
print("Yes" if z**.5==int(z**.5) else "No")

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
print("Yes" if (10a+b)**.5==int((10a+b)**.5) else "No")
Problem p03493 (python)

Fixed submission:
S=input()
print(S.count("1"))

Buggy submission (verdict: Runtime Error):
a=int(input())
b=list(map(int,input().split()))
counter=0
exist_odd=False
while True:
  count=0
  while count<=a-1:
    if b[count]%2==1:
      exist_odd=True
      break
    else:
      b[count]=b[count]//2
      count+=1
  if exist_odd:
    break
  else:
    counter+=1
print(counter)
Problem p03494 (python)

Fixed submission:
##いろいろやってみよう
import functools
def mod(a,b):
  c=a%b
  return c
N=int(input())
*A,=map(int,input().split())
count=0
for j in range(len(bin(max(A)))-2):
  if 1 in map(functools.partial(mod,b=2),A):
    break
  else:
    A=[A[i]//2 for i in range(N)]
    count+=1
print(count)

Buggy submission (verdict: Runtime Error):
##いろいろやってみよう
import functools
def mod(a,b):
  c=a%b
  return c
N=int(input())
*A,=map(mod,input().split())
count=0
for j in range(len(bin(max(A)))-2):
  if 1 in map(functools.partial(mod,b=2),A)):
    break
  else:
    A=[A[i]//2 for i in range(N)]
    count+=1
print(count)