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

Fixed submission:
def main():
    b = input()
    if(b=='A'):
        return print('T')
    if(b=='T'):
        return print('A')
    if(b=='C'):
        return print('G')
    if(b=='G'):
        return print('C')
main()

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(N-1):
    if S[i:i+2] == 'AC':
        counter[i+1] += counter[i] + 1
    else:
        counter[i+1] += counter[i]

for i in range(Q):
    print(counter[r[i]-1] - counter[l[i]-1])
Problem p03103 (python)

Fixed submission:
N,M = map(int, input().split())
A,B = [],[]
for i in range(N):
    A_next, B_next = map(int,input().split())
    A.append(A_next)
    B.append(B_next)
l = sorted(list(zip(A,B)), key=lambda x:x[0])
count = 0
value = 0
i = 0
while(count<M):
    if(M-count<l[i][1]):
        value = value + l[i][0]*(M-count)
        break
    else:
        value = value + l[i][0]*l[i][1]
        count = count + l[i][1]
        i = i + 1
print(value)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A,B = [],[]
for i in range(N):
    A_next, B_next = map(int,input().split())
    A.append(A_next)
    B.append(B_next)
shop = list(zip(A,B))
shop.sort(key=lambda x:x[0])
def count(i,M):
    if(M==0):
        return 0
    elif(shop[i][1]<=M):
        return count(i+1,M-shop[i][1])+shop[i][0]*shop[i][1]
    else:
        return M*shop[i][0]
a = count(0,M)
print(a)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A,B = [],[]
for i in range(N):
    A_next, B_next = map(int,input().split())
    A.append(A_next),B.append(B_next)
shop = list(zip(A,B))
shop.sort(key=lambda x:x[0])
def count(i,M):
    if(M==0):
        return 0
    elif(shop[i][1]<=M):
        return count(i+1,M-shop[i][1])+shop[i][0]*shop[i][1]
    else:
        return M*shop[i][0]
a = count(0,M)
print(a)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A,B = [],[]
for i in range(N):
    A_next, B_next = map(int,input().split())
    A.append(A_next),B.append(B_next)
shop = list(zip(A,B))
shop.sort(key=lambda x:x[0])
def count(i,M):
    if(M==0):
        return 0
    elif(shop[i][1]<=M):
        return count(i+1,M-shop[i][1])+shop[i][0]*shop[i][1]
    else:
        return M*shop[i][0]
count(0,M)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A,B = [],[]
for i in range(N):
    A_next, B_next = map(int,input().split())
    A.append(A_next),B.append(B_next)
shop = list(zip(A,B))
shop.sort(key=lambda x:x[0])
def count(i,M):
    if(M==0):
        return 0
    elif(shop[i][1]<=M):
        return count(i+1,M-shop[i][1])+shop[i][0]*shop[i][1]
    else:
        return M*shop[i][0]
count(0,M)
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)
    re1 = 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))
Problem p03125 (python)

Fixed submission:
A,B = map(int, input().split())
if(B%A == 0):
    print(A+B)
else:
    print(B-A)

Buggy submission (verdict: Runtime Error):
A,B = int(input().split())
if(B%A==0):
  print(A+B)
else:
  print(B-A)
Problem p03246 (python)

Fixed submission:
import collections
n = int(input())
v = [int(i) for i in input().split()]
v_even = [v[2*i] for i in range(int(n/2))]
v_odd = [v[2*i-1] for i in range(int(n/2))]
c_even = collections.Counter(v_even)
c_odd = collections.Counter(v_odd)
if(c_even.most_common()[0][0]!=c_odd.most_common()[0][0]):
    print(n - c_even.most_common()[0][1] - c_odd.most_common()[0][1])
elif(len(collections.Counter(v))==1):
    print(int(n/2))
else:
    if(c_even.most_common()[0][1]>c_odd.most_common()[0][1]):
        print(n-c_even.most_common()[0][1] - c_odd.most_common()[1][1])
    elif(c_even.most_common()[0][1]<c_odd.most_common()[0][1]):
        print(n - c_odd.most_common()[0][1] - c_even.most_common()[1][1])
    else:
        print(n - c_odd.most_common()[0][1] - max(c_odd.most_common()[1][1],c_even.most_common()[1][1]))

Buggy submission (verdict: Runtime Error):
import collections

def solve():
    n = int(input())
    v = [int(i) for i in input().split()]
    v_odd = [j for i,j in enumerate(v) if i%2==1]
    v_even = [j for i,j in enumerate(v) if i%2==0]

    v_count = collections.Counter(v)
    #すべて同じ数字
    if(len(v_count)==1):
        return print(int(n/2))
    #異なる数字の時
    elif(len(v_count)!=1):
        
        
        v_odd_max = collections.Counter(v_odd).most_common()[0]
        v_even_max = collections.Counter(v_even).most_common()[0]
        if(v_odd_max[0] != v_even_max[0]):
            return print(int(n/2-v_odd_max[1])+int(n/2-v_even_max[1]))
        else:
            a = v_even.most_common()[1]
            return print(int(n/2-v_odd_max[1])+int(n/2-a[1]))
solve()
Problem p03478 (python)

Fixed submission:
N,A,B = map(int, input().split())

total = 0
for i in range(1,N+1):
    
    flag = True
    res = 0
    j = i
    while(flag):
        res = res + j%10
        j = int(j/10)
        if(j==0):
            flag = False
    if(A<=res & res<=B):
        total = total + i
print(total)

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

total = 0
for i in range(1,N+1):
    
    flag = True
    res = 0
    j = i
    while(flag):
        res = res + j%10
        j = int(j/10)
        if(j==0):
            flag = False
    if(A<=res & res<=B):
        total = total + i
print(total)
Problem p03068 (python)

Fixed submission:
n=int(input())
s=input()
k=int(input())
t=s[k-1]
c=''
for i in range(0,n):
    if s[i] != t:
        c += '*'
    else: c += s[i]

print(c)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
k=int(input())
t=s[k]
c=''
for i in range(0,n):
    if s[i] != t:
        c += '*'
    else: c += s[i]

print(c)
Problem p03323 (python)

Fixed submission:
A, B = map(int, input().split())

if A<9 and B<9:
 print("Yay!")
else:
 print(":(")

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

if A<9 and B<9:
 print("Yay!")
else:
 print(":(")

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

if A<9 and B<9:
 print("Yay!")
else:
 print(":(")

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

if A<9 and B<9:
 print("Yay!")
else:
 print(":(")
Problem p03074 (python)

Fixed submission:
# coding: utf-8

import sys

n, k = [int(x) for x in input().split()]
ss = [int(x) for x in input()]

zero_array = []
one_array = []
curr_num = ss[0]
flag = 0

if curr_num == 0:
    zero_array.append(0)
else:
    one_array.append(0)
    flag = 1

for i in ss:
    if curr_num == i:
        if i == 0:
            zero_array[-1] += 1
        else:
            one_array[-1] += 1
    else:
        curr_num = i
        if i == 0:
            zero_array.append(1)
        else:
            one_array.append(1)

# print("zero_array", zero_array)
# print("one_array", one_array)
# print("flag", flag)

if k >= len(zero_array):
    print(sum(zero_array) + sum(one_array))
    sys.exit()
else:
    t = 0
    tmp = sum(zero_array[t: t+k]) + sum(one_array[t: t+k+flag])
    max_count = tmp
    # print("outer_tmp", tmp)
    # print()
    while t + k + flag <= len(one_array) and t + k < len(zero_array):
        # print("t", t)
        tmp += zero_array[t+k] - zero_array[t]
        if t+k+flag < len(one_array):
            tmp += one_array[t+k+flag]
            if not (t == 0 and flag == 0):
                if t == 0:
                    pass
                    # print("yeh")
                tmp -= one_array[t+flag-1]
        elif not (t == 0 and flag == 0):
            tmp -= one_array[t+flag-1]
        # print("tmp", tmp)
        if tmp > max_count:
            max_count = tmp
            # print(t, max_count)
        t += 1

    print(max_count)
# print(zero_array)
# print(one_array)

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

import sys

n, k = [int(x) for x in input().split()]
ss = [int(x) for x in input()]

zero_array = []
one_array = []
curr_num = ss[0]
flag = 0

if curr_num == 0:
    zero_array.append(0)
else:
    one_array.append(0)
    flag = 1

for i in ss:
    if curr_num == i:
        if i == 0:
            zero_array[-1] += 1
        else:
            one_array[-1] += 1
    else:
        curr_num = i
        if i == 0:
            zero_array.append(1)
        else:
            one_array.append(1)

if k >= len(zero_array):
    print(sum(zero_array) + sum(one_array))
    sys.exit()
else:
    t = 0
    tmp = sum(zero_array[t: t+k]) + sum(one_array[t: t+k+flag])
    max_count = tmp
    while t + k + flag <= len(one_array):
        if t+k+flag < len(one_array):
            tmp += zero_array[t+k] - zero_array[t] + one_array[t+k+flag] - one_array[t+flag-1]
        else:
            tmp += zero_array[t + k] - zero_array[t] - one_array[t + flag - 1]
        if tmp > max_count:
            max_count = tmp
            # print(t, max_count)
        t += 1

    print(max_count)
# print(zero_array)
# print(one_array)
Problem p03340 (python)

Fixed submission:
# coding: utf-8

n = int(input())
a = [int(x) for x in input().split()]

count = 0
xor_result = 0
sum_result = 0
r = 0

for l in range(0, n):
    while r < n:
        x = a[r]
        if sum_result & x != 0:
            break
        xor_result ^= x
        sum_result += x
        r += 1
    count += r - l
    xor_result ^= a[l]
    sum_result -= a[l]

print(count)

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

n = int(input())
a = [int(x) for x in input().split()]

count = 0

for i in range(0, n):
    if not result_bool:
        result_bool = True
        continue
    for j in range(i, n):
        xor_result = 0
        sum_result = 0
        result_bool = True
        for x in a[i:j+1]:
            if sum_result & x != 0:
                result_bool = False
                break
            xor_result ^= x
            sum_result += x
        if not result_bool:
            break
        if xor_result == sum_result and result_bool:
            count += 1

print(count)
Problem p03276 (python)

Fixed submission:
n, k = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]

plus = [0]
minus = []
zeroExist = 0

for i in range(n):
    if x[i] > 0:
        plus.append(x[i])
    elif x[i] == 0:
        zeroExist = 1
    else:
        minus.append(-x[i])
minus.append(0)
minus = list(reversed(minus))

if zeroExist == 1:
    k -= 1

cost = 10**9
for i in range(k + 1):
    if i < len(plus) and k - i < len(minus):
        # print("i:{} k-i:{}".format(i, k-i))
        if i == 0 or i == k:
            cost = min(cost, plus[i] + minus[k - i])
        else:
            cost = min(cost, plus[i] + minus[k - i]
                       + min(plus[i], minus[k - i]))
            # print("{}:{}".format(i, cost))
print(cost)

Buggy submission (verdict: Runtime Error):
import math

n, k = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]

plus = [0]
minus = []
zeroExist = 0

for i in range(n):
    if x[i] > 0:
        plus.append(x[i])
    elif x[i] == 0:
        zeroExist = 1
    else:
        minus.append(-x[i])
minus.append(0)
minus = list(reversed(minus))

# for i in range(1, len(minus)):
# minus[i] += minus[i-1]

# print(plus)
# print(minus)

if zeroExist == 1:
    k -= 1

cost = math.inf
for i in range(k+1):
    if i < len(plus) and k - i < len(minus):
        #print(i)
        if i == 0 or i == k:
            cost = min(cost, plus[i] + minus[k - i])
        else:
            cost = min(cost, plus[i] + minus[k - i]
                       + min(plus[i], minus[k-i]))
        #print("{}:{}".format(i, cost))
print(cost)
Problem p03403 (python)

Fixed submission:
if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    A = list([0])
    A.extend(a)
    A.append(0)

    sum = 0
    for i in range(1, n+2):
        sum += abs(A[i]-A[i-1])
    for i in range(1, n+1):
        print(sum-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1]))

Buggy submission (verdict: Runtime Error):
if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    A = list([0])
    A.append(a)
    A.append(0)
    
    sum = 0
    for i in range(n):
        root = list(A[:])
        del root[i+1]
        for j in range(1, n+1):
            sum += abs(root[j]-root[j-1])
        print(sum)
        sum = 0

Buggy submission (verdict: Runtime Error):
if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    A = list([0])
    A.append(a)
    A.append(0)
    
    sum = 0
    for i in range(n):
        root = list(A[:])
        del root[i+1]
        for j in range(1, n+1):
            sum += abs(root[j]-root[j-1])
        print(sum)
        sum = 0
Problem p03651 (python)

Fixed submission:
# import math
# import fractions
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a = sorted(a)

div = a[0]
for i in range(1, n):
    div = gcd(div, a[i])

if k % div == 0 and k <= a[-1]:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
# import math
import fractions
n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a = sorted(a)
if n == 1:
    if a[0] == k:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
div = fractions.gcd(a[0], a[1])
for i in range(n):
    if a[i] == k:
        print("POSSIBLE")
        exit()
    elif i >= 2:
        div = fractions.gcd(a[i], a[i-1])
if k % div == 0 and k <= a[-1]:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
"""
b = []
for i in range(len(a)):
    if a[i] == k:
        print("POSSIBLE")
        exit()
    elif a[i] > k:
      b.append(a[i] - k)
      del(a[i])
print(a)
print(b)
"""

Buggy submission (verdict: Runtime Error):
# import math
import fractions
n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a = sorted(a)
div = fractions.gcd(a[0], a[1])
for i in range(2, n):
    div = fractions.gcd(a[i], a[i-1])
if k % div == 0 and k <= a[-1]:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
"""
b = []
for i in range(len(a)):
    if a[i] == k:
        print("POSSIBLE")
        exit()
    elif a[i] > k:
      b.append(a[i] - k)
      del(a[i])
print(a)
print(b)
"""
Problem p03844 (python)

Fixed submission:
a, op, b = [i for i in input().split()]
if op == "+":
    print(int(a) + int(b))
else:
    print(int(a) - int(b))

Buggy submission (verdict: Runtime Error):
a, op, b = [int(i) for i in input().split()]
if op == "+":
    print(int(a) + int(b))
else:
    print(int(a) - int(b))
Problem p03944 (python)

Fixed submission:
w, h, n = [int(i) for i in input().split()]
table = [[0 for _ in range(w)] for _ in range(h)]

for _ in range(n):
    x, y, a = [int(i) for i in input().split()]
    if a == 1:
        table[0][0] += 1
        if x < w:
            table[0][x] -= 1
    elif a == 2:
        if x < w:
            table[0][x] += 1
    elif a == 3:
        table[0][0] += 1
        if y < h:
            table[y][0] -= 1
    elif a == 4:
        if y < h:
            table[y][0] += 1

for i in range(len(table)):
    for j in range(1, len(table[i])):
        table[i][j] += table[i][j-1]
for i in range(1, len(table)):
    for j in range(len(table[i])):
        table[i][j] += table[i-1][j]
count = 0
for i in range(len(table)):
    for j in range(len(table[i])):
        if table[i][j] == 0:
            count += 1
print(count)

Buggy submission (verdict: Runtime Error):
w, h, n = [int(i) for i in input().split()]
table = [[0 for _ in range(w)] for _ in range(h)]

for _ in range(n):
    x, y, a = [int(i) for i in input().split()]
    if a == 1:
        table[0][0] += 1
        if x < w:
            table[0][x] -= 1
    elif a == 2:
        table[0][x] += 1
    elif a == 3:
        table[0][0] += 1
        if y < h:
            table[y][0] -= 1
    elif a == 4:
        table[y][0] += 1

for i in range(len(table)):
    for j in range(1, len(table[i])):
        table[i][j] += table[i][j-1]
for i in range(1, len(table)):
    for j in range(len(table[i])):
        table[i][j] += table[i-1][j]
count = 0
for i in range(len(table)):
    for j in range(len(table[i])):
        if table[i][j] == 0:
            count += 1
print(count)

Buggy submission (verdict: Runtime Error):
w, h, n = [int(i) for i in input().split()]
table = [[0 for _ in range(w)] for _ in range(h)]

for _ in range(n):
    x, y, a = [int(i) for i in input().split()]
    if a == 1:
        table[0][0] += 1
        table[0][x] -= 1
    elif a == 2:
        table[0][x] += 1
    elif a == 3:
        table[0][0] += 1
        table[y][0] -= 1
    elif a == 4:
        table[y][0] += 1

for i in range(len(table)):
    for j in range(1, len(table[i])):
        table[i][j] += table[i][j-1]
for i in range(1, len(table)):
    for j in range(len(table[i])):
        table[i][j] += table[i-1][j]
count = 0
for i in range(len(table)):
    for j in range(len(table[i])):
        if table[i][j] == 0:
            count += 1
print(count)
Problem p03964 (python)

Fixed submission:
import math

n = int(input())
vote = [0, 0]
# 最初の得票は、最小値を目指すので
# 単純に入力比をそのまま使用
# 各入力に対し、vote[0]<=t*k, vote[1]<=a*kとなる
# 最小のt*k,a*kでvoteを更新
vote = [1, 1]
for i in range(n):
    t, a = [int(i) for i in input().split()]
    if vote[0] % t == 0:
        k = vote[0] // t
    else:
        k = vote[0] // t + 1
    if vote[1] % a == 0:
        k = max(k, vote[1] // a)
    else:
        k = max(k, vote[1] // a + 1)
    # k = max(math.ceil(vote[0] / t), math.ceil(vote[1] / a))
    vote = [t * k, a * k]
    # a / b + (a % b == 0 ? 0: 1)
    # print("i:{} vote:{}".format(i, vote))
print(vote[0] + vote[1])

Buggy submission (verdict: Runtime Error):
import math

n = int(input())
vote = [0, 0]
# 最初の得票は、最小値を目指すので
# 単純に入力比をそのまま使用
# 各入力に対し、vote[0]<=t*k, vote[1]<=a*kとなる
# 最小のt*k,a*kでvoteを更新
vote = [1, 1]
for i in range(n):
    t, a = [int(i) for i in input().split()]
    k = max(math.ceil(vote[0] / t), math.ceil(vote[1] / a))
    vote = [t * k, a * k]
    if sum(vote) > 10**10:
        t[1000000000] = 1
    # print("i:{} vote:{}".format(i, vote))
print(vote[0] + vote[1])
Problem p04030 (python)

Fixed submission:
def listToString(_list, split=""):
    maped_list = map(str, _list)  # mapで要素すべてを文字列に
    mojiretu = split.join(maped_list)
    return mojiretu


s = input()
out = []
for i in range(len(s)):
    if s[i] == "0":
        out.append("0")
    elif s[i] == "1":
        out.append("1")
    else:
        if len(out) > 0:
            out.pop()
print(listToString(out))

Buggy submission (verdict: Runtime Error):
def listToString(_list, split=""):
    maped_list = map(str, _list)  # mapで要素すべてを文字列に
    mojiretu = split.join(maped_list)
    return mojiretu


s = input()
out = []
for i in range(len(s)):
    if s[i] == "0":
        out.append("0")
    elif s[i] == "1":
        out.append("1")
    else:
        out.pop()
print(listToString(out))
Problem p03105 (python)

Fixed submission:
a , b, c = map(int, input().split())
d =  b // a 
if d > c:
  print(c)
else:
  print(d)

Buggy submission (verdict: Runtime Error):
a , b, c = map(int, input().split())
d =  b // a 
if d > c:
  return c
else:
  return d
Problem p03106 (python)

Fixed submission:
a , b, c = map(int, input().split())
X = []
for i in range(min([a,b])):
  if a % (i+1) == 0 and b % (i+1) == 0:
    X.append((i+1))
print(X[-c])

Buggy submission (verdict: Runtime Error):
a , b, c = map(int, input().split())
X = []
for i in range(min([a,b])):
  if a % i == 0 and b % i == 0:
    X.append(i)
print(X[-c])

Buggy submission (verdict: Runtime Error):
a , b, c = map(int, input().split())
X = []
for i in range(max(a,b)):
  if a % i == 0 and b % i == 0:
    X.append(i)
print(X[-c])

Buggy submission (verdict: Runtime Error):
a , b, c = map(int, input().split())
X = []
for i in range(max(a,b)):
  if a % i == 0 and b % i == 0:
    X.append(i)
print(X[c])
Problem p03067 (python)

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

Buggy submission (verdict: Runtime Error):
N=int(input())
S=input()
S=S+'#'
sc=0
tc=0
ans=0
for i in range(N+1):
    if(tc!=0 and S[i]=='#'):
        if(sc>tc):
            ans+=tc
            sc+=tc
        else:
            ans+=sc
            sc=0
        tc=0

    if(sc!=0 and S[i]=='.'):
        tc+=1
    elif(tc==0 and S[i]=='#'):
        sc+=1
print(str(ans))
Problem p03085 (python)

Fixed submission:
b = input()
if b=="A":
  print("T")
elif b=="T":
  print("A")
elif b=="G":
  print("C")
else:
  print("G")

Buggy submission (verdict: Runtime Error):
N, M = list(map(int, input().split()))
S = input()
a = []
for i in range(M):
    a.append(list(map(int, input().split())))
for i in range(M):
  print(S[a[i][0]-1:a[i][1]].count('AC'))
Problem p03086 (python)

Fixed submission:
b = input()
l = len(b)
ans = []
kotae = 1
c = []
for i in range(l):
  if b[i]=="A" or b[i]=="T" or b[i]=="G" or b[i]=="C":
    ans.append(i)
l2 = len(ans)
if l2==1:
  c.append(1)
for i in range(l2-1):
  if (ans[i+1]-ans[i])==1 and i==l2-2:
    kotae+=1
    c.append(kotae)
  elif (ans[i+1]-ans[i])==1:
    kotae+=1
  else:
    c.append(kotae)
    kotae=1
if ans==[]:
  print(0)
else:print(max(c))

Buggy submission (verdict: Runtime Error):
b = input()
l = len(b)
ans = []
kotae = 1
c = []
for i in range(l):
  if b[i]=="A" or b[i]=="T" or b[i]=="G" or b[i]=="C":
    ans.append(i)
l2 = len(ans)
for i in range(l2-1):
  if (ans[i+1]-ans[i])==1 and i==l2-2:
    kotae+=1
    c.append(kotae)
  elif (ans[i+1]-ans[i])==1:
    kotae+=1
  else:
    c.append(kotae)
    kotae=1
if ans==[]:
  print(0)
else:print(max(c))