Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import math

#要素の数を数えたい場合（key:数）
n=int(input())
li = list(map(int,input().split()))

dic={}
for i in li:
    if i not in dic:
        dic[i] = 1
    elif dic[i] >= 1:
        dic[i] += 1
        
#print(dic)

for i in range(n):
    cnt = 0
    for j in dic:
        cnt += dic[j]*(dic[j]-1)/2
    #print(math.floor(cnt))

for i in range(n):
    print(math.floor(cnt - dic[li[i]]+1))

Fixed submission:
import math

#要素の数を数えたい場合（key:数）
n=int(input())
li = list(map(int,input().split()))

dic={}
for i in li:
    if i not in dic:
        dic[i] = 1
    elif dic[i] >= 1:
        dic[i] += 1
        
#print(dic)


cnt = 0
for j in dic:
    cnt += dic[j]*(dic[j]-1)/2
    #print(math.floor(cnt))

for i in range(n):
    print(math.floor(cnt - dic[li[i]]+1))

Buggy python submission (verdict: Time Limit Exceeded):
import math

#要素の数を数えたい場合（key:数）
n=int(input())
li = list(map(int,input().split()))

dic={}
for i in li:
    if i not in dic:
        dic[i] = 1
    elif dic[i] >= 1:
        dic[i] += 1
        
#print(dic)

for i in range(n):
    cnt = 0
    dic[li[i]] -= 1
    for j in dic:
        cnt += dic[j]*(dic[j]-1)/2
    print(math.floor(cnt))
    dic[li[i]] += 1

Fixed submission:
import math

#要素の数を数えたい場合（key:数）
n=int(input())
li = list(map(int,input().split()))

dic={}
for i in li:
    if i not in dic:
        dic[i] = 1
    elif dic[i] >= 1:
        dic[i] += 1
        
#print(dic)


cnt = 0
for j in dic:
    cnt += dic[j]*(dic[j]-1)/2
    #print(math.floor(cnt))

for i in range(n):
    print(math.floor(cnt - dic[li[i]]+1))
Buggy python submission (verdict: Runtime Error):
import math

a=int(input())
li = list(map(int,input().split()))
cnt = li[0]
for i in li:
    cnt = math.gcd(cnt, i)
print(cnt)


Fixed submission:
import fractions

a=int(input())
li = list(map(int,input().split()))
cnt = li[0]
for i in li:
    cnt = fractions.gcd(cnt, i)
print(cnt)

Buggy python submission (verdict: Runtime Error):
import math

a=int(input())
li = list(map(int,input().split()))
cnt = li[0]
for i in li:
    cnt = math.gcd(cnt, i)
print(cnt)

Fixed submission:
import fractions

a=int(input())
li = list(map(int,input().split()))
cnt = li[0]
for i in li:
    cnt = fractions.gcd(cnt, i)
print(cnt)
Buggy python submission (verdict: Runtime Error):
r = input()
print(3 * a * a)

Fixed submission:
r = int(input())
print(3 * r * r)
Buggy python submission (verdict: Time Limit Exceeded):
h, w = map(int,input().split())
#alist = list(map(int, input().split()))

road=[]

for i in range(h):
    row=input()
    road.append(row)

ikel=0

for i in range(h):
    for j in range(w):
        if road[i][j]=='.':
            ikel+=1

maxrecord=0

for i in range(h):
    for j in range(w):
        turn=1
        ima=1
        now=[[i, j]]
        rlist=[]
        for hh in range(h):
            rlist.append([999]*w)
        rlist[i][j]=0
        while ima<ikel:
            #while turn<10:
            koho=[]
            for nw in now:
                koho.append([nw[0]-1, nw[1]])
                koho.append([nw[0]+1, nw[1]])
                koho.append([nw[0], nw[1]-1])
                koho.append([nw[0], nw[1]+1])
            #print(rlist)
            now=[]
            for kh in koho:
                if kh[0]>=0 and kh[1]>=0 and kh[0]<h and kh[1]<w:
                    #print(kh)
                    if road[kh[0]][kh[1]]=='.':
                        #print(kh, rlist[kh[0]][kh[1]])
                        if rlist[kh[0]][kh[1]]>turn:
                            #print(kh)
                            rlist[kh[0]][kh[1]]=turn
                            now.append([kh[0], kh[1]])
                            ima+=1
                            record=turn
            turn+=1
        #print('result', rlist)
        if record>maxrecord:
            maxrecord=record

print(maxrecord)

Fixed submission:
h, w = map(int,input().split())
#alist = list(map(int, input().split()))

road=[]

for i in range(h):
    row=input()
    road.append(row)

ikel=0

for i in range(h):
    for j in range(w):
        if road[i][j]=='.':
            ikel+=1

maxrecord=0

for i in range(h):
    for j in range(w):
        turn=1
        ima=1
        now=[[i, j]]
        rlist=[]
        for hh in range(h):
            rlist.append([999]*w)
        rlist[i][j]=0
        if road[i][j]=='.':
            while ima<ikel:
                koho=[]
                for nw in now:
                    if nw[0]>0:
                        koho.append([nw[0]-1, nw[1]])
                    if nw[0]<h-1:
                        koho.append([nw[0]+1, nw[1]])
                    if nw[1]>0:
                        koho.append([nw[0], nw[1]-1])
                    if nw[1]<w-1:
                        koho.append([nw[0], nw[1]+1])
                now=[]
                for kh in koho:
                    if road[kh[0]][kh[1]]=='.':
                        if rlist[kh[0]][kh[1]]>turn:
                            rlist[kh[0]][kh[1]]=turn
                            now.append([kh[0], kh[1]])
                            ima+=1
                            record=turn
                turn+=1
            if record>maxrecord:
                maxrecord=record

print(maxrecord)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
clist = list(map(int, input().split()))
clist=sorted(clist)
answer=0
kihon=2**(n-1)
tas=2**(n-2)
for i in range(n):
    answer+=clist[-i-1]*(kihon)
    kihon+=tas

answer=(answer*(2**n))%(10**9+7)
print(answer)

Fixed submission:
n=int(input())
clist = list(map(int, input().split()))
clist=sorted(clist)
answer=0
kihon=(2**(n-1))%(10**9+7)
tas=(2**(n-2))%(10**9+7)
for i in range(n):
    answer+=clist[-i-1]*(kihon)
    answer=answer%(10**9+7)
    kihon+=tas

answer=(answer*(2**n))%(10**9+7)
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
import math

n=int(input())
alist = [int(i) for i in input().split()]
alist=sorted(alist)

keta=math.floor(math.log2(max(alist[-1],1)))+1
zeros=[0]*keta
ones=[0]*keta

for al in alist:
    kaz2=bin(al)[2:]
    kaz2=(keta-len(kaz2))*'0'+kaz2
    #print(kaz2)
    for i in range(keta):
        if kaz2[i]=='1':
            ones[i]+=1
        else:
            zeros[i]+=1

answer=0
for i in range(keta):
    tas=ones[-i-1]*zeros[-i-1]
    tas*=((2**i)%(10**9+7))
    answer+=tas%(10**9+7)

print(answer%(10**9+7))

Fixed submission:
import math

n=int(input())
alist = [int(i) for i in input().split()]
alist=sorted(alist)

keta=math.floor(math.log(max(alist[-1],1), 2))+1
zeros=[0]*keta
ones=[0]*keta

for al in alist:
    kaz2=bin(al)[2:]
    kaz2=(keta-len(kaz2))*'0'+kaz2
    for i in range(keta):
        if kaz2[i]=='1':
            ones[i]+=1
        else:
            zeros[i]+=1

answer=0
for i in range(keta):
    tas=ones[-i-1]*zeros[-i-1]
    tas*=((2**i)%(10**9+7))
    answer+=tas%(10**9+7)

print(answer%(10**9+7))

Buggy python submission (verdict: Runtime Error):
import math

n=int(input())
alist = [int(i) for i in input().split()]
alist=sorted(alist)

keta=math.floor(math.log2(alist[-1]))+1
#print(math.log2(alist[-1]), keta)
zeros=[0]*keta
ones=[0]*keta

for al in alist:
    kaz2=bin(al)[2:]
    kaz2=(keta-len(kaz2))*'0'+kaz2
    #print(kaz2)
    for i in range(keta):
        if kaz2[i]=='1':
            ones[i]+=1
        else:
            zeros[i]+=1

#print(ones)
#print(zeros)
answer=0
for i in range(keta):
    tas=ones[-i-1]*zeros[-i-1]
    tas*=((2**i)%(10**9+7))
    answer+=tas%(10**9+7)

print(answer%(10**9+7))

Fixed submission:
import math

n=int(input())
alist = [int(i) for i in input().split()]
alist=sorted(alist)

keta=math.floor(math.log(max(alist[-1],1), 2))+1
zeros=[0]*keta
ones=[0]*keta

for al in alist:
    kaz2=bin(al)[2:]
    kaz2=(keta-len(kaz2))*'0'+kaz2
    for i in range(keta):
        if kaz2[i]=='1':
            ones[i]+=1
        else:
            zeros[i]+=1

answer=0
for i in range(keta):
    tas=ones[-i-1]*zeros[-i-1]
    tas*=((2**i)%(10**9+7))
    answer+=tas%(10**9+7)

print(answer%(10**9+7))
Buggy python submission (verdict: Runtime Error):
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

import math

a, b = map(int, input().split())
c=math.gcd(a, b)
d=prime_factorize(c)
count=0
before=0
for i in range(len(d)):
    if d[i]!=before:
        count+=1
    before=d[i]

print(count+1)

Fixed submission:
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

import math

a, b = map(int, input().split())
c=gcd(a, b)
d=prime_factorize(c)
count=0
before=0
for i in range(len(d)):
    if d[i]!=before:
        count+=1
    before=d[i]

print(count+1)
Buggy python submission (verdict: Time Limit Exceeded):
import math

n=int(input())
s=input()
ng=len(s)
r=[]
g=[]
b=[]

for i in range(ng):
    if s[i]=='R':
        r.append(i)
    elif s[i]=='G':
        g.append(i)
    else:
        b.append(i)

kihon=math.factorial(n)%998244353
combo=0
list1=[]
list2=[]
list3=[]

deka=[]
tibi=[]

for i in range(n):
    moto=[r[i],g[i],b[i]]
    jun = sorted([r[i],g[i],b[i]])
    list1.append(jun[0])
    list2.append(jun[1])
    list3.append(jun[2])
    deka.append(moto.index(jun[2]))
    tibi.append(moto.index(jun[0]))

dekalist=[1]
tibilist=[1]
for i in range(n-1):
    next=max(1, dekalist[-1]-1)
    if i+next<n:
        while deka[i]==deka[i+next] and list3[i]>=list2[i+next]:
            next+=1
            if i+next==n:
                break
    dekalist.append(next)
    
    next2=max(1, tibilist[-1]-1)
    if i+next2<n:
        while tibi[n-1-i]==tibi[n-1-(i+next2)] and list1[n-1-i]<=list2[n-1-(i+next2)]:
            next2+=1
            if i+next2==n:
                break
    tibilist.append(next2)


for dl in dekalist:
    kihon*=dl
for tl in tibilist:
    kihon*=tl

print(kihon%998244353)

Fixed submission:
import math

n=int(input())
s=input()
ng=len(s)
r=[]
g=[]
b=[]

for i in range(ng):
    if s[i]=='R':
        r.append(i)
    elif s[i]=='G':
        g.append(i)
    else:
        b.append(i)

kihon=math.factorial(n)%998244353
combo=0
list1=[]
list2=[]
list3=[]

deka=[]
tibi=[]

for i in range(n):
    moto=[r[i],g[i],b[i]]
    jun = sorted([r[i],g[i],b[i]])
    list1.append(jun[0])
    list2.append(jun[1])
    list3.append(jun[2])
    deka.append(moto.index(jun[2]))
    tibi.append(moto.index(jun[0]))

dekalist=[1]
tibilist=[1]
for i in range(n-1):
    next=max(1, dekalist[-1]-1)
    if i+next<n:
        while deka[i]==deka[i+next] and list3[i]>=list2[i+next]:
            next+=1
            if i+next==n:
                break
    dekalist.append(next)
    
    next2=max(1, tibilist[-1]-1)
    if i+next2<n:
        while tibi[n-1-i]==tibi[n-1-i-next2] and list1[n-1-i]<=list2[n-1-i-next2]:
            next2+=1
            if i+next2==n:
                break
    tibilist.append(next2)


for dl in dekalist:
    kihon=(kihon*dl)%998244353
for tl in tibilist:
    kihon=(kihon*tl)%998244353

print(kihon%998244353)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split()) 

alist=[]

for i in range(n):
    a, b = map(int, input().split()) 
    alist.append([a,b])

alist=sorted(alist)
#print(alist)

eternal=1
now=0
hoshu=0

koholist=[]
for i in range(m):
    j=i+1
    switch=1
    while switch==1 and eternal==1:
        if alist[now][0]<=j:
            koholist.append(alist[now][1])
            if now>=n-1:
                switch=0
                eternal=0
            else:
                now+=1
        else:
            switch=0
    if len(koholist)>0:
        saidai=max(koholist)
        koholist.remove(saidai)
        #print(saidai)
        hoshu+=saidai

print(hoshu)

Fixed submission:
import heapq

n, m = map(int, input().split()) 

alist=[]

for i in range(n):
    a, b = map(int, input().split()) 
    alist.append([a,b])

alist=sorted(alist)
#print(alist)

eternal=1
now=0
hoshu=0

koholist=[]
for i in range(m):
    j=i+1
    switch=1
    while switch==1 and eternal==1:
        if alist[now][0]<=j:
            heapq.heappush(koholist, -alist[now][1])
            if now>=n-1:
                switch=0
                eternal=0
            else:
                now+=1
        else:
            switch=0
    if len(koholist)>0:
        saidai=heapq.heappop(koholist)
        #print(saidai)
        hoshu+=saidai

print(-hoshu)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
import heapq

n=int(input())
a1=int(input())
alist=[a1]

for i in range(n-1):
    an=int(input())
    if an<=alist[0]:
        alist=[an]+alist
    else:
        index = bisect.bisect_left(alist, an)
        alist[index-1]=an

print(len(alist))

Fixed submission:
import bisect

n=int(input())
a1=int(input())
alist=[]
for al in range(n-1):
    alist.append(-2)
alist.append(a1)

for i in range(n-1):
    an=int(input())
    #print(alist,an)
    index = bisect.bisect_left(alist, an)
    alist[index-1]=an

#print(alist)
index = bisect.bisect_left(alist, -1)
#print(index)
print(len(alist)- index)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

n=int(input())
a1=int(input())
alist=[a1]

for i in range(n-1):
    an=int(input())
    #print(alist,an)
    index = bisect.bisect_left(alist, an)
    if index==0:
        alist.insert(index, an)
    else:
        alist[index-1]=an
    #print(index)

print(len(alist))

Fixed submission:
import bisect

n=int(input())
a1=int(input())
alist=[]
for al in range(n-1):
    alist.append(-2)
alist.append(a1)

for i in range(n-1):
    an=int(input())
    #print(alist,an)
    index = bisect.bisect_left(alist, an)
    alist[index-1]=an

#print(alist)
index = bisect.bisect_left(alist, -1)
#print(index)
print(len(alist)- index)
Buggy python submission (verdict: Runtime Error):
def survey(now, mlist, clist):
    for ml in mlist[now]:
        if clist[ml[0]]==2:
            clist[ml[0]]=(clist[now]+ml[1])%2
            _, _=survey(ml[0], mlist, clist)
    return mlist, clist

n=int(input())
mlist=[]
clist=[]
for i in range(n):
    mlist.append([])
    clist.append(2)

for i in range(n-1):
    u, v, m = map(int, input().split())
    u-=1
    v-=1
    mlist[u].append([v, m%2])
    mlist[v].append([u, m%2])

#print(mlist)
clist[0]=0
now=0
mlist, clist = survey(now, mlist, clist)
for cl in clist:
    print(cl)

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

def survey(now, mlist, clist):
    for ml in mlist[now]:
        if clist[ml[0]]==2:
            clist[ml[0]]=(clist[now]+ml[1])%2
            _, _=survey(ml[0], mlist, clist)
    return mlist, clist

n=int(input())
mlist=[]
clist=[]
for i in range(n):
    mlist.append([])
    clist.append(2)

for i in range(n-1):
    u, v, m = map(int, input().split())
    u-=1
    v-=1
    mlist[u].append([v, m%2])
    mlist[v].append([u, m%2])

clist[0]=0
now=0
mlist, clist = survey(now, mlist, clist)
for cl in clist:
    print(cl)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!

n=int(input())

#normal, start_b, end_a, both

kosu=0
tokushu=[0,0,0,0]

for i in range(n):
    line=input()
    switch=0
    for l in range(len(line)):
        if switch==1:
            if line[l]=='B':
                kosu+=1
            else:
                switch=0
        if line[l]=='A':
            switch=1

    if line[0]=='B':
        if line[-1]=='A':
            tokushu[3]+=1
        else:
            tokushu[1]+=1
    else:
        if line[-1]=='A':
            tokushu[2]+=1
        else:
            tokushu[0]+=1

#print(kosu)
#print(tokushu)
kosu=0
tokushu=[1,1,2,3]
"""
if tokushu[3]>=1:
    mazu=tokushu[3]-1

else:
    mazu=0
"""
if tokushu[3]>=1:
    if tokushu[1]==0 and tokushu[2]==0:
        mazu=tokushu[3]-1
    else:
        mazu=tokushu[3]-1
        sukunai=min(tokushu[1],tokushu[2])
        mazu+=(sukunai+1)
else:
    mazu=min(tokushu[1], tokushu[2])

print(kosu+mazu)


Fixed submission:
line=input().split(" ")
n=int(line[0])
k=int(line[1])
print(n-k+1)
Buggy python submission (verdict: Time Limit Exceeded):
import math

line=input().split(" ")
n=int(line[3])
r=int(line[0])
g=int(line[1])
b=int(line[2])
nline=sorted([r,g,b])
x=int(nline[2])
y=int(nline[1])
z=int(nline[0])


answers=0
#print(x,y,z,n)


for i in range(math.ceil(n/x)+1):
    a=i
    for j in range(math.ceil(n/y)+1):
        b=j
        c=(n-a*x-b*y)/z
        if c>=0 and (n-a*x-b*y)%z==0:
            answers+=1
            #print(a,b,c)

print(answers)

Fixed submission:
# coding: utf-8
# Your code here!
import math

line=input().split(" ")
n=int(line[3])
r=int(line[0])
g=int(line[1])
b=int(line[2])
nline=sorted([r,g,b])
x=int(nline[2])
y=int(nline[1])
z=int(nline[0])

answers=0
#print(x,y,z,n)


for i in range(math.ceil(n/x)+1):
    a=i
    if z!=1:
        for j in range(math.ceil((n-a*x)/y)+1):
            b=j
            c=(n-a*x-b*y)/z
            if c>=0 and (n-a*x-b*y)%z==0:
                answers+=1
                #print(a,b,c)
    else:
        if n-a*x>=0:
            if n-a*x==0:
                answers+=1
                #print('a', 1)
            elif (n-a*x)%y!=0:
                answers+=math.ceil((n-a*x)/y)
                #print('b', math.ceil((n-a*x)/y))
            else:
                answers+=(math.ceil((n-a*x)/y)+1)
                #print('c', math.ceil((n-a*x)/y)+1)
            

print(answers)
Buggy python submission (verdict: Runtime Error):
import math

list=input().split(" ")
n=int(list[0])
k=int(list[1])
s=input()

list2=[]
renzoku=0

if s[0]=='0':
    list2.append(0)

for x in range(n-1):
    renzoku+=1
    if int(s[x])!=int(s[x+1]):
        list2.append(renzoku)
        renzoku=0

list2.append(renzoku+1)

#print(list2)

kaisu=math.ceil(len(list2)/2)-k
max=0
if kaisu==0:
    gokei=len(s)

for y in range(kaisu):
    #print(list2[y*2:y*2+(2*k+1)])
    gokei=sum(list2[y*2:y*2+(2*k+1)])
    if gokei>max:
        max=gokei
print(gokei)

Fixed submission:
import math

list=input().split(" ")
n=int(list[0])
k=int(list[1])
s=input()

list2=[]
renzoku=0

if s[0]=='0':
    list2.append(0)

for x in range(n-1):
    renzoku+=1
    if int(s[x])!=int(s[x+1]):
        list2.append(renzoku)
        renzoku=0

list2.append(renzoku+1)
if len(list2)%2==0:
    list2.append(0)

#print(list2)

kaisu=math.ceil(len(list2)/2)-k
max=0
if kaisu<=0:
    max=len(s)

for y in range(kaisu):
    #print(list2[y*2:y*2+(2*k+1)])
    if y==0:
        gokei=sum(list2[y*2:y*2+(2*k+1)])
    else:
        gokei-=(list2[y*2-2]+list2[y*2-1])
        gokei+=(list2[y*2+k*2-1]+list2[y*2+k*2])
    if gokei>max:
        max=gokei
print(max)
Buggy python submission (verdict: Runtime Error):
list=input().split(" ")
x=int(list[0])
y=int(list[1])
z=int(list[2])
k=int(list[3])

kari=input().split(" ")
alist=[]
for ax in range(x):
    alist.append(int(kari[ax]))
alist=sorted(alist)

kari=input().split(" ")
blist=[]
for by in range(y):
    blist.append(int(kari[by]))
blist=sorted(blist)

kari=input().split(" ")
clist=[]
for cz in range(z):
    clist.append(int(kari[cz]))
clist=sorted(clist)

nowx=0
nowy=0
nowz=0


ngo=[]

for a in range(min(x,10)):
    for b in range(min(y,10)):
        for c in range(min(z,10)):
            ngo.append(alist[x-a-1]+blist[y-b-1]+clist[z-c-1])
            
            
for a in range(max(x-10,0)):
    for b in range(min(y,10)):
        for c in range(min(z,10)):
            ngo.append(alist[x-a-1+max(x-10)]+blist[y-b-1]+clist[z-c-1])

for a in range(min(x, 10)):
    for b in range(max(y-10,0)):
        for c in range(min(z,10)):
            ngo.append(alist[x-a-1]+blist[y-b-1+max(y-10)]+clist[z-c-1])

for a in range(min(x, 10)):
    for b in range(min(y,10)):
        for c in range(max(z-10, 0)):
            ngo.append(alist[x-a-1]+blist[y-b-1]+clist[z-c-1+max(z-10)])

ngo=sorted(ngo, reverse=True)

for d in range(k):
    print(ngo[d])

Fixed submission:
x, y, z, k = map(int, input().split())
alist = list(map(int, input().split()))
blist = list(map(int, input().split()))
clist = list(map(int, input().split()))

bclist=[]

for i in range(y):
    now=blist[i]
    for j in range(z):
        bclist.append(now+clist[j])

bclist=sorted(bclist)
bclist2=bclist[-k:]
#print(bclist2)

ng=len(bclist2)
abclist=[]

for i in range(ng):
    now=bclist2[i]
    for j in range(x):
        abclist.append(now+alist[j])

abclist=sorted(abclist)
for i in range(k):
    print(abclist[-1-i])
Buggy python submission (verdict: Time Limit Exceeded):
saisholist=input().split(' ')
n=int(saisholist[0])
q=int(saisholist[1])
s=input()
record=0
swit=0
countac=0
atgc=['A', 'T', 'G', 'C']
for i in range(q):
    toilist=input().split(' ')
    to1=int(toilist[0])
    to2=int(toilist[1])
    for ii in range(to1-1, to2):
        #print(s[to1-1:to2])
        if s[ii]=='A':
            swit=1
        elif swit==1:
            if s[ii]=='C':
                countac+=1
            swit=0
    print(countac)
    countac=0

Fixed submission:
import bisect

n, q = map(int, input().split())
s=input()
sng=len(s)
aclist=[]
for i in range(sng-1):
    if s[i]=='A' and s[i+1]=='C':
        aclist.append(i+1)

#print(aclist)
for i in range(q):
    l, r = map(int, input().split())
    ll=bisect.bisect_left(aclist, l)
    rr=bisect.bisect_right(aclist, r-1)
    print(rr-ll)
Buggy python submission (verdict: Time Limit Exceeded):
def yabai(a):
    al=''
    a2=a
    if a2%4==0 or a2%4==3:
        al='00'
    elif a2%4==2:
        al='11'
    else:
        al='01'
    
    kaisu_a=0
    while a2!=0:
        if a2%2==0:
            #pass
            a2=a2/2
            #al='0'+al
        else:
            #pass
            a2=(a2-1)/2
            #al='1'+al
        kaisu_a+=1
    #print(kaisu_a)
    #print('1!')
    for a_i in range(kaisu_a-2):
        #print(2**(a_i+2))
        #print(a%(2**(a_i+2)))
        amari=a%(2**(a_i+3))
        if amari>=2**(a_i+2) and amari%2==0:
            al='1'+al
        else:
            al='0'+al
    #print(al)
    return al

def main():
    list=input().split(' ')
    a=int(list[0])
    b=int(list[1])
    if 1==2:
        print(a)
    else:
        newa=yabai(a-1)
        #print(newa)
        newb=yabai(b)
        for sa in range(len(newb)-len(newa)):
            newa='0'+newa
        #print(newb)
        answer=0
        for i in range(len(newa)):
            if (newa[i]=='0' and newb[i]=='1') or (newa[i]=='1' and newb[i]=='0'):
                answer+=(2**(len(newa)-i-1))
        print(answer)

main()

Fixed submission:
def yabai(a):
    al=''
    a2=a
    amarin=a2%4
    if amarin==0 or amarin==3:
        al='00'
    elif amarin%4==2:
        al='11'
    else:
        al='01'
    
    kaisu_a=0
    while a2>0:
        if a2%2==0:
            #pass
            a2=a2/2
            #al='0'+al
        else:
            #pass
            a2=(a2-1)/2
            #al='1'+al
        kaisu_a+=1
    #print(kaisu_a)
    #print('1!')
    for a_i in range(kaisu_a-2):
        amari=a%(2**(a_i+3))
        if amari>=2**(a_i+2) and amari%2==0:
            al='1'+al
        else:
            al='0'+al
    #print(al)
    return al

def main():
    list=input().split(' ')
    a=int(list[0])
    b=int(list[1])
    newa=yabai(a-1)
    #print(newa)
    newb=yabai(b)
    for sa in range(len(newb)-len(newa)):
        newa='0'+newa
    #print(newb)
    answer=0
    #print(newa, newb)
    for i in range(len(newa)):
        if (newa[i]=='0' and newb[i]=='1') or (newa[i]=='1' and newb[i]=='0'):
            answer+=(2**(len(newa)-i-1))
    print(answer)

main()