ZhenlongDai/ACPR huggingface dataset:
Problem: p02287
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
klist = list(map(int,input().split()))
plist = []
i = 0
k = 1
a = 2**i-1
while 1:
    if klist[a:a+2**i] != []:
        plist.append(klist[a:a + 2**i])
    else: break
    a += 2**i
    i += 1
print(plist)
print(len(plist))
for i in range(len(plist)):
    for j in range(len(plist[i])):
        try:
            if i==0:
                print("node "+str(k)+": key = "+str(plist[0][0])+
                      ", left key = "+str(plist[1][0])+
                      ", right key = "+str(plist[1][1])+",")
            else :
                l = int(j/2)
                print("node "+str(k)+": key = "+str(plist[i][j])+
                      ", parent key = "+str(plist[i-1][l])+", left key = "+
                      str(plist[i+1][2*j]),end="")
                try:
                    print(", right key = "+str(plist[i+1][2*j+1])+",")
                except:
                    print(",")
        except:
            l = int(j/2)
            print("node "+str(k)+": key = "+str(plist[i][j])+
                  ", parent key = "+str(plist[i-1][l])+",")
        k += 1


Failing test case input:
5
2 23 0 0 1

Expected output:
node 1: key = 2, left key = 23, right key = 0, 
node 2: key = 23, parent key = 2, left key = 0, right key = 1, 
node 3: key = 0, parent key = 2, 
node 4: key = 0, parent key = 23, 
node 5: key = 1, parent key = 23, 


Actual output:
[[2], [23, 0], [0, 1]]
3
node 1: key = 2, left key = 23, right key = 0,
node 2: key = 23, parent key = 2, left key = 0, right key = 1,
node 3: key = 0, parent key = 2,
node 4: key = 0, parent key = 23,
node 5: key = 1, parent key = 23,


Fixed submission (verdict: Accepted):
n = int(input())
klist = list(map(int,input().split()))
plist = []
i = 0
k = 1
a = 2**i-1
while 1:
    if klist[a:a+2**i] != []:
        plist.append(klist[a:a + 2**i])
    else: break
    a += 2**i
    i += 1
for i in range(len(plist)):
    for j in range(len(plist[i])):
        try:
            if i==0:
                print("node "+str(k)+": key = "+str(plist[0][0])+
                      ", left key = "+str(plist[1][0])+
                      ", right key = "+str(plist[1][1])+", ")
            else :
                l = int(j/2)
                print("node "+str(k)+": key = "+str(plist[i][j])+
                      ", parent key = "+str(plist[i-1][l])+", left key = "+
                      str(plist[i+1][2*j]),end="")
                try:
                    print(", right key = "+str(plist[i+1][2*j+1])+", ")
                except:
                    print(", ")
        except:
            l = int(j/2)
            print("node "+str(k)+": key = "+str(plist[i][j])+
                  ", parent key = "+str(plist[i-1][l])+", ")
        k += 1
Problem: p02287
Buggy submission (Python3, verdict: Wrong Answer):


def decode_heap(target_list):
    for i, key in enumerate(target_list):
        node_index = i + 1
        parent_index = int(node_index / 2) - 1
        parent = ""
        if not parent_index < 0:
            parent = " parent key = " + str(target_list[parent_index]) + ", "
            
        left_index = node_index * 2 - 1
        right_index = node_index * 2
        leaf = ""
        if left_index < len(target_list) and right_index < len(target_list):
            leaf = " left key = {}, right key = {}, ".format(target_list[left_index], target_list[right_index])

        print("node {}: key = {},{}{}".format(node_index, key, parent, leaf))

        
def main():
    n_nodes = int(input())
    target_list = [int(a) for a in input().split()]
    decode_heap(target_list)
    
if __name__ == "__main__":
    main()

Failing test case input:
5
-8 1 -1 3 -5

Expected output:
node 1: key = -8, left key = 1, right key = -1, 
node 2: key = 1, parent key = -8, left key = 3, right key = -5, 
node 3: key = -1, parent key = -8, 
node 4: key = 3, parent key = 1, 
node 5: key = -5, parent key = 1, 


Actual output:
node 1: key = -8, left key = 1, right key = -1, 
node 2: key = 1, parent key = -8,  left key = 3, right key = -5, 
node 3: key = -1, parent key = -8, 
node 4: key = 3, parent key = 1, 
node 5: key = -5, parent key = 1, 


Fixed submission (verdict: Accepted):


def decode_heap(target_list):
    for i, key in enumerate(target_list):
        node_index = i + 1
        parent_index = int(node_index / 2) - 1
        parent = ""
        if not parent_index < 0:
            parent = " parent key = " + str(target_list[parent_index]) + ","
            
        left_index = node_index * 2 - 1
        left = ""
        if left_index < len(target_list):
            left = " left key = {},".format(target_list[left_index])
            
        right_index = node_index * 2
        right = ""
        if right_index <  len(target_list):
            right = " right key = {},".format(target_list[right_index])

        print("node {}: key = {},{}{}{} ".format(node_index, key, parent, left, right))

        
def main():
    n_nodes = int(input())
    target_list = [int(a) for a in input().split()]
    decode_heap(target_list)
    
if __name__ == "__main__":
    main()
Problem: p02287
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
H = list(map(int, input().split(' ')))

for i in range(n):
    node = i+1
    key = H[i]
    parent = H[int(node/2)] if node != 1 else None
    left = H[node*2-1] if node*2 <= n else None
    right = H[node*2] if node*2+1 <= n else None
    print('node %d: key = %d,'%(node, key), end='')
    if parent != None: print(' parent key = %d,'%parent, end='')
    if left != None: print(' left key = %d,'%left, end='')
    if right != None: print(' right key = %d,'%right, end='')
    print('')


Failing test case input:
5
4 23 0 0 1

Expected output:
node 1: key = 4, left key = 23, right key = 0, 
node 2: key = 23, parent key = 4, left key = 0, right key = 1, 
node 3: key = 0, parent key = 4, 
node 4: key = 0, parent key = 23, 
node 5: key = 1, parent key = 23, 


Actual output:
node 1: key = 4, left key = 23, right key = 0,
node 2: key = 23, parent key = 23, left key = 0, right key = 1,
node 3: key = 0, parent key = 23,
node 4: key = 0, parent key = 0,
node 5: key = 1, parent key = 0,


Fixed submission (verdict: Accepted):
n = int(input())
H = list(map(int, input().split(' ')))

for i in range(n):
    node = i+1
    key = H[i]
    parent = H[int(node/2)-1] if node != 1 else None
    left = H[node*2-1] if node*2 <= n else None
    right = H[node*2] if node*2+1 <= n else None
    print('node %d: key = %d, '%(node, key), end='')
    if parent != None: print('parent key = %d, '%parent, end='')
    if left != None: print('left key = %d, '%left, end='')
    if right != None: print('right key = %d, '%right, end='')
    print('')
Problem: p02287
Buggy submission (Python3, verdict: Wrong Answer):


def decode_heap(target_list):
    for i, key in enumerate(target_list):
        node_index = i + 1
        parent_index = int(node_index / 2) - 1
        parent = ""
        if not parent_index < 0:
            parent = " parent key = " + str(target_list[parent_index]) + " "
            
        left_index = node_index * 2 - 1
        right_index = node_index * 2
        leaf = ""
        if left_index < len(target_list) and right_index < len(target_list):
            leaf = " left key ={}, right key = {}, ".format(target_list[left_index], target_list[right_index])

        print("node {}: key = {},{}{}".format(node_index, key, parent, leaf))

        
def main():
    n_nodes = int(input())
    target_list = [int(a) for a in input().split()]
    decode_heap(target_list)
    
if __name__ == "__main__":
    main()

Failing test case input:
5
7 8 1 2 3

Expected output:
node 1: key = 7, left key = 8, right key = 1,
node 2: key = 8, parent key = 7, left key = 2, right key = 3,
node 3: key = 1, parent key = 7,
node 4: key = 2, parent key = 8,
node 5: key = 3, parent key = 8,

Actual output:
node 1: key = 7, left key =8, right key = 1, 
node 2: key = 8, parent key = 7  left key =2, right key = 3, 
node 3: key = 1, parent key = 7 
node 4: key = 2, parent key = 8 
node 5: key = 3, parent key = 8 


Fixed submission (verdict: Accepted):


def decode_heap(target_list):
    for i, key in enumerate(target_list):
        node_index = i + 1
        parent_index = int(node_index / 2) - 1
        parent = ""
        if not parent_index < 0:
            parent = " parent key = " + str(target_list[parent_index]) + ","
            
        left_index = node_index * 2 - 1
        left = ""
        if left_index < len(target_list):
            left = " left key = {},".format(target_list[left_index])
            
        right_index = node_index * 2
        right = ""
        if right_index <  len(target_list):
            right = " right key = {},".format(target_list[right_index])

        print("node {}: key = {},{}{}{} ".format(node_index, key, parent, left, right))

        
def main():
    n_nodes = int(input())
    target_list = [int(a) for a in input().split()]
    decode_heap(target_list)
    
if __name__ == "__main__":
    main()
Problem: p02287
Buggy submission (Python3, verdict: Wrong Answer):


def decode_heap(target_list):
    for i, key in enumerate(target_list):
        node_index = i + 1
        parent_index = int(node_index / 2) - 1
        parent = ""
        if not parent_index < 0:
            parent = " parent key = " + str(target_list[parent_index]) + ", "
            
        left_index = node_index * 2 - 1
        right_index = node_index * 2
        leaf = ""
        if left_index < len(target_list) and right_index < len(target_list):
            leaf = " left key ={}, right key = {}, ".format(target_list[left_index], target_list[right_index])

        print("node {}: key = {},{}{}".format(node_index, key, parent, leaf))

        
def main():
    n_nodes = int(input())
    target_list = [int(a) for a in input().split()]
    decode_heap(target_list)
    
if __name__ == "__main__":
    main()

Failing test case input:
5
4 8 1 1 3

Expected output:
node 1: key = 4, left key = 8, right key = 1, 
node 2: key = 8, parent key = 4, left key = 1, right key = 3, 
node 3: key = 1, parent key = 4, 
node 4: key = 1, parent key = 8, 
node 5: key = 3, parent key = 8, 


Actual output:
node 1: key = 4, left key =8, right key = 1, 
node 2: key = 8, parent key = 4,  left key =1, right key = 3, 
node 3: key = 1, parent key = 4, 
node 4: key = 1, parent key = 8, 
node 5: key = 3, parent key = 8, 


Fixed submission (verdict: Accepted):


def decode_heap(target_list):
    for i, key in enumerate(target_list):
        node_index = i + 1
        parent_index = int(node_index / 2) - 1
        parent = ""
        if not parent_index < 0:
            parent = " parent key = " + str(target_list[parent_index]) + ","
            
        left_index = node_index * 2 - 1
        left = ""
        if left_index < len(target_list):
            left = " left key = {},".format(target_list[left_index])
            
        right_index = node_index * 2
        right = ""
        if right_index <  len(target_list):
            right = " right key = {},".format(target_list[right_index])

        print("node {}: key = {},{}{}{} ".format(node_index, key, parent, left, right))

        
def main():
    n_nodes = int(input())
    target_list = [int(a) for a in input().split()]
    decode_heap(target_list)
    
if __name__ == "__main__":
    main()
Problem: p03087
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, Q = map(int, input().split())
S = input()
AClst = [] 

for i in range(N-1):
  if S[i:i+2]=="AC":
    AClst.append(1)
  else:
    AClst.append(0)
AClst.append(0)

for q in range(Q):
  l, r = map(int, input().split())
  print(AClst[l:r].count(1))

Failing test case input:
8 3
ACACTACG
2 7
2 3
2 8

Expected output:
2
0
2


Actual output:
2
1
2


Fixed submission (verdict: Accepted):
N, Q = map(int, input().split())
S = input()
AClst = [0]
c = 0

for i in range(N-1):
  if S[i:i+2]=="AC":
    c += 1
  AClst.append(c)

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

Problem: p03087
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, Q = map(int, input().split())
S=list(input())
list=[]
for i in range(0, N-1):
    if S[i] == "A" and S[i+1] == "C":
        list.append(i)
count=0
for i in range(Q):
    l, r = map(int, input().split())
    for j in list:
        if l-1 <= j < r-1:
            count+=1
        else:
            count+=0
    print(count)

Failing test case input:
8 3
ACACTACG
3 7
8 1
1 6

Expected output:
2
-3
2


Actual output:
2
2
4


Fixed submission (verdict: Accepted):
N, Q = map(int, input().split())
S = input()

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

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

Problem: p03087
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,q = map(int,input().split())
s = list(input())
base = [0]*n
count = 0

for i in range(n-1):
  if (s[i] == "A") and (s[i+1] == "C"):
    count = count + 1
    base[i] = count
  else:
    base[i] = count

base[n-1] = base[n-2]

for i in range(q):
  l,r = map(int,input().split())
  ans = base[r-1] - base[l-1]
  
  if s[r-1] == "A":
    ans = ans - 1
  
  if s[l-1] == "A":
    ans = ans + 1
    
  print(ans)

Failing test case input:
8 3
GCATCACA
3 2
2 3
2 8

Expected output:
0
0
1


Actual output:
1
-1
0


Fixed submission (verdict: Accepted):
n,q = map(int,input().split())
s = list(input())
base = [0]*n
count = 0

for i in range(1,n):
  if (s[i-1] == "A") and (s[i] == "C"):
    count = count + 1
    base[i] = count
  else:
    base[i] = count

for i in range(q):
  l,r = map(int,input().split())
  ans = base[r-1] - base[l-1]
 
    
  print(ans)
Problem: p03087
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from itertools import accumulate

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

s = input()

problems = [list(map(int, input().split())) for _ in range(q)]


def count(total, i):
    return total + 1 if s[i-1] + s[i] == 'AC' else total


cumsum = [0] + list(accumulate(range(1, n), count))

for l, r in problems:
    print(cumsum[r-1] - cumsum[l-1])



Failing test case input:
8 3
GCATCACA
3 7
2 3
1 8

Expected output:
1
0
1


Actual output:
1
0
2


Fixed submission (verdict: Accepted):
from itertools import accumulate

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

s = input()

problems = [list(map(int, input().split())) for _ in range(q)]


def count(total, i):
    return total + 1 if s[i:i+2] == 'AC' else total


cumsum = list(accumulate([0] + list(range(n)), count))

for l, r in problems:
    print(cumsum[r-1] - cumsum[l-1])

Problem: p03087
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, q = [int(i) for i in input().split()]
s = input()
l_list = []
r_list = []
for i in range(q):
    l, r = [int(i) for i in input().split()]
    l_list.append(l)
    r_list.append(r)

ac_map = [0 for i in range(n+1)]
for i in range(1, n+1):
    if s[i-1:i+1] == "AC":
        ac_map[i] = ac_map[i-1] +1
    else:
        ac_map[i] = ac_map[i-1]
print(ac_map)
for i in range(q):
    ans = ac_map[r_list[i]-1] - ac_map[l_list[i]-1]
    print(ans)

Failing test case input:
8 3
ACACTACG
3 7
4 3
1 2

Expected output:
2
-1
1


Actual output:
[0, 1, 1, 2, 2, 2, 3, 3, 3]
2
-1
1


Fixed submission (verdict: Accepted):
n, q = [int(i) for i in input().split()]
s = input()
l_list = []
r_list = []
for i in range(q):
    l, r = [int(i) for i in input().split()]
    l_list.append(l)
    r_list.append(r)

ac_map = [0 for i in range(n+1)]
for i in range(1, n+1):
    if s[i-1:i+1] == "AC":
        ac_map[i] = ac_map[i-1] +1
    else:
        ac_map[i] = ac_map[i-1]
for i in range(q):
    ans = ac_map[r_list[i]-1] - ac_map[l_list[i]-1]
    print(ans)

Problem: p03087
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,Q = [int(i) for i in input().split()]
S=input()
lr = [[int(j)-1 for j in input().split()] for i in range(Q)]

imos = [0 for i in range(N)]
for i in range(N-1):
    if S[i]=='A' and S[i+1]=='C':
        imos[i]=1
for i in range(N-1):
    imos[i+1]+=imos[i]
for l,r in lr:
    res = imos[r]
    if l>0:
        res-=imos[l-1]
    if S[r]=='A':
        res-=1
    print(res)


Failing test case input:
8 3
GCATCACA
3 7
2 3
2 8

Expected output:
1
0
1


Actual output:
1
-1
0


Fixed submission (verdict: Accepted):
N,Q = [int(i) for i in input().split()]
S=input()
lr = [[int(j)-1 for j in input().split()] for i in range(Q)]

imos = [0 for i in range(N)]
for i in range(N-1):
    if S[i]=='A' and S[i+1]=='C':
        imos[i]=1
for i in range(N-1):
    imos[i+1]+=imos[i]
for l,r in lr:
    res = imos[r]
    if l>0:
        res-=imos[l-1]
    if S[r]=='A' and r<N-1 and S[r+1]=='C':
        res-=1
    print(res)
Problem: p03087
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, Q = map(int, input().split())
S = input()
S_list = list(S)
count_list = [0]*N
print(S_list)

for i in range(1, N):
    count_list[i] += count_list[i-1] 
    if S_list[i-1] == "A" and S_list[i] == "C":
        count_list[i] += 1
        
print(count_list)

for i in range(Q):
    start, end = map(int, input().split())
    count = count_list[end-1] - count_list[start-1]
    print(count)

Failing test case input:
8 3
ACACTACG
3 7
2 4
2 6

Expected output:
2
1
1


Actual output:
['A', 'C', 'A', 'C', 'T', 'A', 'C', 'G']
[0, 1, 1, 2, 2, 2, 3, 3]
2
1
1


Fixed submission (verdict: Accepted):
N, Q = map(int, input().split())
S = input()
S_list = list(S)
count_list = [0]*N

for i in range(1, N):
    count_list[i] += count_list[i-1] 
    if S_list[i-1] == "A" and S_list[i] == "C":
        count_list[i] += 1

for i in range(Q):
    start, end = map(int, input().split())
    count = count_list[end-1] - count_list[start-1]
    print(count)

Problem: p03087
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,Q=[int(i) for i in input().split()]
S=input()

c=[0]
t = 0
for i in range(1,N):
   t += 1 if  (S[i-1]=='A' and S[i] == 'C') else 0
   c.append(t)
c.append(t)

for _ in range(Q):
    l,r=[int(x)-1 for x in input().split()]
    print(c[r]-c[l+1])


Failing test case input:
8 3
ACACTACG
3 7
2 3
1 2

Expected output:
2
0
1


Actual output:
1
0
0


Fixed submission (verdict: Accepted):
N,Q=[int(i) for i in input().split()]
S=input()

c=[0]
t = 0
for i in range(1,N):
   t += 1 if  (S[i-1]=='A' and S[i] == 'C') else 0
   c.append(t)

for _ in range(Q):
    l,r=[int(x)-1 for x in input().split()]
    print(c[r]-c[l])

Problem: p03087
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N, Q = map(int,input().split())
S = input()
cnt = [0]
for i in range(len(S)-1):
    cnt.append(cnt[-1])
    if S[i] == 'A' and S[i+1] == 'C':
        cnt[-1] += 1
cnt = [0] + cnt
print(cnt)

for _ in range(Q):
    l, r = map(int,input().split())
    ans = cnt[r] - cnt[l-1]
    if 2 <= l and (S[l-2] == 'A' and S[l-1] == 'C'):
        ans -= 1
    print(ans)

Failing test case input:
8 3
@CBCTACG
6 7
2 3
1 6

Expected output:
1
0
0


Actual output:
[0, 0, 0, 0, 0, 0, 0, 1, 1]
1
0
0


Fixed submission (verdict: Accepted):
N, Q = map(int,input().split())
S = input()
cnt = [0]
for i in range(len(S)-1):
    cnt.append(cnt[-1])
    if S[i] == 'A' and S[i+1] == 'C':
        cnt[-1] += 1
cnt = [0] + cnt

for _ in range(Q):
    l, r = map(int,input().split())
    ans = cnt[r] - cnt[l-1]
    if 2 <= l and (S[l-2] == 'A' and S[l-1] == 'C'):
        ans -= 1
    print(ans)
Problem: p03087
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

x = input().split()
n = int(x[0]) 
q = int(x[1]) 
s = input()

def ind_Multi(a,b): 
    global n
    global s 
    index_L = []
    for i in range(a,b):
        if s[i] == "A":
            index_L.append(i)
    return index_L

            
        
t = [0] * n
if s[0] == "A":
    t[0] = 1
    
for i in range(0,n-1):
    if s[i:i+2] == "AC":
        
        if (i == 0) :
            t[i] =  + 1
        else:
            t[i] = t[i-1] + 1
    else :
        if i == 0:
            t[i] = 0
        else:
            t[i] = t[i-1]



def sc():
    global t
    global s
    global n
    global q
    global idbox
    maxx = 0
    count = 0
    com = [int(s)-1 for s in input().split()]
    print(com)
    idbox = ind_Multi(com[0],com[1])
    print(t[com[1]-1] - t[com[0]-1])
        
    

    

for i in range(q):
    
    sc()


Failing test case input:
8 2
ACACTACG
3 7
4 3
1 2

Expected output:
2
-1


Actual output:
[2, 6]
2
[3, 2]
-1


Fixed submission (verdict: Accepted):

x = input().split()
n = int(x[0]) 
q = int(x[1]) 
s = input()

        
t = [0] * n
if s[0] == "A":
    t[0] = 1
    
for i in range(0,n-1):
    if s[i:i+2] == "AC":
        
        if (i == 0) :
            t[i] =  + 1
        else:
            t[i] = t[i-1] + 1
    else :
        if i == 0:
            t[i] = 0
        else:
            t[i] = t[i-1]



def sc():
    global t
    global s
    global n
    global q
    global idbox
    maxx = 0
    count = 0
    com = [int(s)-1 for s in input().split()]
    
    
    print(t[com[1]-1] - t[com[0]-1])
        
    

    

for i in range(q):
    
    sc()

Problem: p03087
Buggy submission (Python (3.8.2), verdict: Wrong Answer):



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

l = [0]*N 
ans = 0

for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        l[i] = 1
print(l)

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

Failing test case input:
8 3
ACACTACG
4 3
2 6
1 8

Expected output:
-1
1
3


Actual output:
[1, 0, 1, 0, 0, 1, 0, 0]
0
1
3


Fixed submission (verdict: Accepted):



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

t = [0]*(N+1) 

for i in range(N-1):
    if S[i:i+2] == "AC":
        t[i+1] = t[i] + 1
    else:
        t[i+1] = t[i]

for i in range(Q):
    l,r  = map(int,input().split())
    print(t[r-1]-t[l-1])
Problem: p03087
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
input = sys.stdin.readline

def main():
    N, Q = map(int, input().split())
    S = list(input().rstrip())

    dec_a = [0] * (N)
    for x in range(1, N):
        if S[x] == 'C' and S[x-1] == 'A':
            S[x-1] = 'a'
        dec_a[x] = S[:x+1].count('a')


    L = [0] * Q
    R = [0] * Q
    for i in range(Q):
        L[i], R[i] = map(int, input().split())

    print(dec_a)
    for j in range(Q):
        print(dec_a[R[j]-1] - dec_a[L[j]-1])

main()

Failing test case input:
8 3
ACACTACG
3 7
2 3
1 2

Expected output:
2
0
1


Actual output:
[0, 1, 1, 2, 2, 2, 3, 3]
2
0
1


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline

def main():
    N, Q = map(int, input().split())
    S = input().rstrip()

    cnt_ac = 0
    arr_ac = [0] * (N)
    for x in range(0, N-1):
        if S[x:x+2] == 'AC':
            cnt_ac += 1
        arr_ac[x+1] = cnt_ac

    for i in range(Q):
        L, R = map(int, input().split())
        print(arr_ac[R-1] - arr_ac[L-1])


main()

Problem: p03087
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,q = map(int,input().split())
S = input()
tb = [0 for i in range(n)]
for i in range(n):
    if i==0 or S[i]!='C':
        tb[i] = tb[i-1]
        continue
    print(S[i])
    if S[i-1]=='A':
        tb[i] = tb[i-1]+1
for i in range(q):
    l,r = map(int,input().split())
    print(tb[r-1]-tb[l-1])


Failing test case input:
8 3
ACACTACG
3 7
8 5
1 6

Expected output:
2
-1
2


Actual output:
C
C
C
2
-1
2


Fixed submission (verdict: Accepted):
n,q = map(int,input().split())
S = input()
tb = [0 for i in range(n)]
for i in range(1,n):
    if S[i]=='C' and S[i-1]=='A':
        tb[i] = tb[i-1]+1
    else:
        tb[i] = tb[i-1]
for i in range(q):
    l,r = map(int,input().split())
    print(tb[r-1]-tb[l-1])

Problem: p03087
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from itertools import accumulate

n, q = map(int, input().split())
s = list(input())

z = []
for i in range(n-1):
    if s[i] + s[i+1] == 'AC':
        z.append(1)
    else:
        z.append(0)
print(z)

z = [0] + list(accumulate(z))
print(z)

for j in range(q):
    l, r =  map(int, input().split())
    print(z[r-1] - z[l-1])


Failing test case input:
8 2
ACACTACG
3 2
1 5
1 2

Expected output:
0
2


Actual output:
[1, 0, 1, 0, 0, 1, 0]
[0, 1, 1, 2, 2, 2, 3, 3]
0
2


Fixed submission (verdict: Accepted):
from itertools import accumulate

n, q = map(int, input().split())
s = list(input())

z = []
for i in range(n-1):
    if s[i] + s[i+1] == 'AC':
        z.append(1)
    else:
        z.append(0)


z = [0] + list(accumulate(z))


for j in range(q):
    l, r =  map(int, input().split())
    print(z[r-1] - z[l-1])
Problem: p03087
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, q = map(int, input().split())
s = input()

ac = [0 for i in range(n)]
for i in range(1, n):
    if s[i - 1] == 'A' and s[i] == 'C':
        ac[i] = 1

for i in range(n - 1):
    ac[i + 1] += ac[i]
print(ac)
for i in range(q):
    l, r = map(int, input().split())
    l -= 1
    r -= 1
    ret = ac[r] - ac[l]
    print(ret)


Failing test case input:
8 3
ACACTACG
3 7
2 3
1 8

Expected output:
2
0
3

Actual output:
[0, 1, 1, 2, 2, 2, 3, 3]
2
0
3


Fixed submission (verdict: Accepted):
n, q = map(int, input().split())
s = input()

ac = [0 for i in range(n)]
for i in range(1, n):
    if s[i - 1] == 'A' and s[i] == 'C':
        ac[i] = 1

for i in range(n - 1):
    ac[i + 1] += ac[i]
for i in range(q):
    l, r = map(int, input().split())
    l -= 1
    r -= 1
    ret = ac[r] - ac[l]
    print(ret)

Problem: p03087
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,q=map(int,input().split())
s=input()
V=[0]*n
X=[]
for i in range(q):
    l,r=map(int,input().split())
    X.append([l,r])

for i in range(n-1):
    if s[i:i+2]=='AC':
        V[i]+=1

for i in range(q):
    ans=sum(V[X[i][0]-1:X[i][1]])
    if V[X[i][1]-1]==1:
        ans-=1
print(ans)

Failing test case input:
8 3
ACACTACG
1 7
1 4
2 8

Expected output:
3
2
2


Actual output:
2


Fixed submission (verdict: Accepted):
n,q=map(int,input().split())
s=input()+'Z'
A=[0]*(n+1)
cnt=0
for i in range(n):
    A[i]=cnt
    if s[i]=='A' and s[i+1]=='C':
        cnt+=1
ANS=[]
for i in range(q):
    l,r=map(int,input().split())
    ANS.append(A[r-1]-A[l-1])
for ans in ANS:
    print(ans)

Problem: p03087
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N,Q=list(map(int, input().split()))
S=input()


dp=[[False, 0] for _ in range(N+1)]
for i in range(1,N+1):
    if S[i-1]=='A':
        dp[i][0]=True
        dp[i][1]=dp[i-1][1]
    elif S[i-1]=='C':
        dp[i][1]=dp[i-1][1]+int(dp[i-1][0])
    else:
        dp[i][1]=dp[i-1][1]
print(dp)


for i in range(Q):
    l,r=list(map(int, input().split()))
    l-=1
    print(dp[r][1]-dp[l][1]-int(dp[l][0]*(1-dp[l+1][0])))

Failing test case input:
8 3
ACBCTADG
6 1
2 3
1 6

Expected output:
-1
0
1


Actual output:
[[False, 0], [True, 0], [False, 1], [False, 1], [False, 1], [False, 1], [True, 1], [False, 1], [False, 1]]
-1
0
1


Fixed submission (verdict: Accepted):
N,Q=list(map(int, input().split()))
S=input()

dp=[[0]*2 for _ in range(N)]
if S[0]=='A':
    dp[0][1]=1

for i in range(1,N):
    if S[i]=='C':
        dp[i][0]=dp[i-1][0]+dp[i-1][1]
    elif S[i]=='A':
        dp[i][0]=dp[i-1][0]
        dp[i][1]=1
    else:
        dp[i][0]=dp[i-1][0]


for i in range(Q):
    l,r=list(map(int, input().split()))
    if l==1:
        print(dp[r-1][0]) 
    elif S[l-2]=='A' and S[l-1]=='C':
        print(dp[r-1][0]-dp[l-2][0]-1)
    else:
        print(dp[r-1][0]-dp[l-2][0])
Problem: p03087
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N,Q=list(map(int, input().split()))
S=input()


dp=[[False, 0] for _ in range(N+1)]
for i in range(1,N+1):
    if S[i-1]=='A':
        dp[i][0]=True
        dp[i][1]=dp[i-1][1]
    elif S[i-1]=='C':
        dp[i][1]=dp[i-1][1]+int(dp[i-1][0])
    else:
        dp[i][1]=dp[i-1][1]



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

Failing test case input:
8 3
GAATCCCA
3 7
3 3
2 8

Expected output:
0
0
0


Actual output:
-1
-1
0


Fixed submission (verdict: Accepted):
N,Q=list(map(int, input().split()))
S=input()

dp=[[0]*2 for _ in range(N)]
if S[0]=='A':
    dp[0][1]=1

for i in range(1,N):
    if S[i]=='C':
        dp[i][0]=dp[i-1][0]+dp[i-1][1]
    elif S[i]=='A':
        dp[i][0]=dp[i-1][0]
        dp[i][1]=1
    else:
        dp[i][0]=dp[i-1][0]


for i in range(Q):
    l,r=list(map(int, input().split()))
    if l==1:
        print(dp[r-1][0]) 
    elif S[l-2]=='A' and S[l-1]=='C':
        print(dp[r-1][0]-dp[l-2][0]-1)
    else:
        print(dp[r-1][0]-dp[l-2][0])

Problem: p03087
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, Q = map(int, input().split())
S = str(input())

count = [0]*(N)
for i in range(1, N):
    if S[i]=='C' and S[i-1]=='A':
        count[i] = count[i-1] + 1
    else:
        count[i] = count[i-1]
print(count)
LR = [list(map(int, input().split())) for _ in range(Q)]
for l, r in LR:
    print(count[r-1]-count[l-1])

Failing test case input:
8 3
ACACTACG
1 7
8 5
1 5

Expected output:
3
-1
2


Actual output:
[0, 1, 1, 2, 2, 2, 3, 3]
3
-1
2


Fixed submission (verdict: Accepted):
N, Q = map(int, input().split())
S = str(input())
LR = [list(map(int, input().split())) for _ in range(Q)]

count = [0]*(N)
for i in range(1, N):
    if S[i]=='C' and S[i-1]=='A':
        count[i] = count[i-1] + 1
    else:
        count[i] = count[i-1]
for l, r in LR:
    print(count[r-1]-count[l-1])

Problem: p03087
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, Q = map(int, input().split())
S = input()
flag = True
R = [0]*N
a = 0
for i in range(N):
    s = S[i]
    if s == "A":
        flag = True
    elif s == "C" and flag:
        a += 1
        flag = False
    else:
        flag = False
    R[i] = a
print(R)
for i in range(Q):
    l, r = map(int, input().split())
    print(R[r-1] - R[l-1])


Failing test case input:
8 3
GCBTCACA
3 6
8 3
2 1

Expected output:
0
-1
0


Actual output:
[0, 0, 0, 0, 0, 0, 1, 1]
0
-1
0


Fixed submission (verdict: Accepted):
N, Q = map(int, input().split())
S = input()
flag = True
R = [0]*N
a = 0
for i in range(N):
    s = S[i]
    if s == "A":
        flag = True
    elif s == "C" and flag:
        a += 1
        flag = False
    else:
        flag = False
    R[i] = a
for i in range(Q):
    l, r = map(int, input().split())
    print(R[r-1] - R[l-1])
Problem: p02660
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math


def is_prime(n):
    for i in range(2, int(math.sqrt(n))+1):
        if n%i == 0:
            return False
    return True

def getPrimeExp(n):
    n_sqrt = int(math.sqrt(n))
    array = [True]*(n_sqrt+1)
    result = []
    for i in range(2, n_sqrt+1):
        if array[i]:
            array[i] = False
            result.append(i)
            for j in range(2, n_sqrt+1):
                ij = i**j
                if ij <= n_sqrt and array[ij]:
                    result.append(ij)
                    array[ij] = False
                elif ij > n:
                    break
            for j in range(i*2, n_sqrt+1, i):
                array[j] = False

            
            
            
            
            
    return sorted(result)

N = int(input())
if N == 1:
    print(0)
elif is_prime(N) and N != 1:
    print(1)
else:
    cnt = 0
    primeExp = getPrimeExp(N) 
    n = N
    
    for z in primeExp:
        if n%z == 0:
            n = int(n/z)
            cnt += 1
    print(cnt)

Failing test case input:
4967510134

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
import math


def is_prime(n):
    for i in range(2, int(math.sqrt(n))+1):
        if n%i == 0:
            return False
    return True      


def getPrime(n):
    n_sqrt = int(math.sqrt(n))
    array = [True]*(n_sqrt+1)
    result = []
    for i in range(2, n_sqrt+1):
        if array[i]:
            array[i] = False
            result.append(i)
            for j in range(i*2, n_sqrt+1, i):
                array[j] = False
    return result

N = int(input())
n = N
prime = getPrime(n)
prime_exp = []

for p in prime:
    cnt = 0
    while n%p == 0:
        n = int(n/p)
        
        cnt += 1
    if cnt != 0:
        prime_exp.append([p, cnt])
if is_prime(n) and n != 1:
    prime_exp.append([n, 1])
ans = 0
for pe in prime_exp:
    ans += int((-1+math.sqrt(1+8*pe[1]))/2)
print(ans)
Problem: p02660
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
from collections import Counter
n = int(input())
ans = 0
def primes(n):
    is_p = [True]*(n + 1)
    is_p[0] = False
    is_p[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_p[i]:
            continue
        for j in range(i*2, n+1, i):
            is_p[j] = False
    return [i for i in range(n+1) if is_p[i]]

p = primes(10**6)

dp = []
cl = []
n1 = n
for i in p:
    if n%i == 0:
        cl.append(i)
    while n%i == 0:
        n = n/i
        dp.append(i)
    if n == 1:
        break
    if n == n1:
        ans = 1

c = Counter(dp)


for i in cl:
    cnt = 1
    while c[i] >= cnt:
        c[i] -= cnt
        ans += 1
        cnt += 1
        
print(ans)


Failing test case input:
1130063570614

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
from collections import Counter
n = int(input())
ans = 0

dp = []
cl = []
n1 = n
if n == 1:
    ans = 0
else:
    for i in range(2, int(n**0.5)+1):
        if n%i == 0:
            cl.append(i)
            while n%i == 0:
                n = n/i
                dp.append(i)
        if n == 1:
            break
    if n != 1:
        ans = 1

c = Counter(dp)

for i in cl:
    cnt = 1
    while c[i] >= cnt:
        c[i] -= cnt
        ans += 1
        cnt += 1
        
print(ans)

Problem: p02660
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math


def prime(num):
	array=[]
	tmp=int(math.sqrt(n))+1
	for i in range(2,tmp):
		while num % i == 0:
			num/=i
			array.append(i)
	
	
	if array==[]:
		return [num]
	else:
		if n>1:
			array.append(int(n))
		return array

n=int(input())
P=prime(n)
P=sorted(P)


if 1 in P:
	print(0)
else:
	ans=0
	tmp=0
	for i in range(0,len(P)):
		if i==0:
			tmp=P[i] 
		elif P[i]==P[i-1]:
			tmp*=P[i]
		else:
			tmp=P[i]

		if n%tmp==0:
			n/=tmp
			ans+=1
	print(ans)

Failing test case input:
61026366052

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
import math

def prime(num):
	array=[]
	tmp=int(math.sqrt(n))+1
	for i in range(2,tmp):
		while num % i == 0:
			num/=i
			array.append(i)
	
	
	if array==[]:
		return [num]
	else:
		if num>1:
			array.append(int(num))
		return array

n=int(input())
P=prime(n)
P=sorted(P)
num=n
if 1 in P:
	print(0)
else:
	ans=0
	tmp=0
	for i in range(0,len(P)):
		if i==0:
			tmp=P[i] 
		elif P[i]==P[i-1]:
			tmp*=P[i]
		else:
			tmp=P[i]
			num=n
		if num%tmp==0:
			num/=tmp
			ans+=1
			
	print(ans)
Problem: p02660
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
a={}
temp=n
for i in range(2,int(n**0.5)+1):
    if temp % i ==0:
        count=0
        while temp % (i**(count+1)) ==0:
            count+=1
        temp= temp/(i**count)
        a[i]=count

sum=0
for i in a:
    jisu= a[i]
    temp= int((2*jisu)**0.5)-1
    if temp*(temp+1) > 2*jisu:
        sum+= temp-1
    elif (temp+1)*(temp+2) > 2*jisu:
        sum+= temp
    elif (temp+2)*(temp+3)> 2*jisu:
        sum+= temp+1
print(sum)   
        

Failing test case input:
2526532339

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
n=int(input())
a={}
temp=n
for i in range(2,int(n**0.5)+1):
    if temp % i ==0:
        count=0
        while temp % (i**(count+1)) ==0:
            count+=1
        temp= temp/(i**count)
        a[i]=count
if temp !=1:
    a[temp]=1

sum=0
for i in a:
  jisu= a[i]
  temp=1
  while temp*(temp+1)/2<= jisu:
          temp+=1
  sum+= temp-1
print(sum)

Problem: p02660
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
N_prime = []

n = N
i = 2
while i <= N**0.5:
    if n%i != 0:
        i += 1
        continue
    
    N_prime.append(i)
    n = n/i
    if n == 1:
        break

if N_prime == []:
    N_prime.append(N)
elif n != 1:
    N_prime.append(int(n))

ct = []
for i in N_prime:
    if i not in ct:
        ct.append(i)
        temp_i = 1
        continue
    temp_i *= i
    if temp_i not in ct:
        ct.append(temp_i)
        temp_i = i
        continue

print(len(ct))

Failing test case input:
153897766656

Expected output:
5


Actual output:
6


Fixed submission (verdict: Accepted):
N = int(input())
N_prime = []

n = N
i = 2
while i <= N**0.5:
    if n%i != 0:
        i += 1
        continue
    
    N_prime.append(i)
    n = n/i
    if n == 1:
        break

if N_prime == [] and N != 1:
    N_prime.append(N)
elif n != 1:
    N_prime.append(int(n))

ct = []
for i in N_prime:
    if i not in ct:
        ct.append(i)
        temp_i = 1
        continue
    temp_i *= i
    if temp_i not in ct:
        ct.append(temp_i)
        temp_i = 1
        continue

print(len(ct))
Problem: p02660
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math
def check(n):
    count = 0
    end = int(math.sqrt(n)+1)
    for i in range(2,end):
        if n%i==0:
            count += 1
            n/=i
        if n%i==0:
            l = 2
            count2 = 0
            while n%i==0:
                n/=i
                count2+=1
                if count2==l:
                    count+=1
                    count2=0
                    l+=1
    if n==1:
        return 0
    if count==0:
        return 1
    else:
        return count   
n = int(input())
ans = check(n)
print(ans)

Failing test case input:
55993645324

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
import math
def check(n):
    count = 0
    end = int(math.sqrt(n)+1)
    for i in range(2,end):
        if n%i==0:
            count += 1
            n/=i
        if n%i==0:
            l = 2
            count2 = 0
            while n%i==0:
                n/=i
                count2+=1
                if count2==l:
                    count+=1
                    count2=0
                    l+=1
        if n==1:
            return count
    if n==1:
        return 0
    if count==0:
        return 1
    else:
        return count+1   
n = int(input())
ans = check(n)
print(ans)

Problem: p02660
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math



def is_prime(n):
    if n == 1:
        return 0

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            if k not in check:
                check[k] = 0
                return n / k
            else:
                continue
    if n in check:
        return 0
    else:
        return 1


check = {}
n = int(input())
if n == 1:
    print(0)
else:
    ans = 0
    while (1):
        n = is_prime(n)
        if n == 0:
            break
        else:
            ans += 1
    print(ans)


Failing test case input:
233433753956

Expected output:
5


Actual output:
6


Fixed submission (verdict: Accepted):
import math



def is_prime(n):
    if n == 1:
        return 0

    for k in range(2, int(math.sqrt(n)) + 1):
        chk = False
        while (n % k == 0):
            chk = True
            n /= k
            if k not in check:
                check[k] = 1
            else:
                check[k] += 1
        if chk:
            return n
    if n in check:
        return 0
    else:
        check[n] = 1
        return 1


check = {}
n = int(input())
if n == 1:
    print(0)
else:
    while (1):
        n = is_prime(n)
        if n == 0:
            break
    ans = 0
    for k, v in check.items():
        for i in range(1, 50):
            v -= i
            if v < 0:
                break
            else:
                ans += 1
    
    print(ans)
Problem: p02660
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math

def prime(num):
	array=[]
	tmp=int(math.sqrt(n))+1
	for i in range(2,tmp):
		while num % i == 0:
			num/=i
			array.append(i)
	
	if array==[]:
		return [num]
	else:
		return array

n=int(input())
P=prime(n)
num=n
tmp=P[0]

if 1 in P:
	print(0)
else:	
	ans=1
	for i in range(1,len(P)):
		if P[i]==P[i-1]:
			tmp*=P[i]
		else:
			tmp=P[i]

		if num%tmp==0:
			num/=tmp
			ans+=1

	print(ans)

Failing test case input:
1130063570614

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
import math

def prime(num):
	array=[]
	tmp=int(math.sqrt(n))+1
	for i in range(2,tmp):
		while num % i == 0:
			num/=i
			array.append(i)
	
	
	if array==[]:
		return [num]
	else:
		if num>1:
			array.append(int(num))
		return array

n=int(input())
P=prime(n)
P=sorted(P)
num=n
if 1 in P:
	print(0)
else:
	ans=0
	tmp=0
	for i in range(0,len(P)):
		if i==0:
			tmp=P[i] 
		elif P[i]==P[i-1]:
			tmp*=P[i]
		else:
			tmp=P[i]
			num=n
		if num%tmp==0:
			num/=tmp
			ans+=1
			
	print(ans)

Problem: p02660
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def resolve():
	answer = 0
	N = int(input())
	if N==1:
		print(answer)
	else:
		
		for p in range(2, int(N**0.5)+2):
			e = 0
			while (N % p == 0):
				N /= p
				e += 1
			
			if e>0:
				
				for i in range(1, e+1):
					if e >= i:
						e -= i
						answer += 1
		
		if answer==0:
			answer = 1
		print(answer)
        
resolve()

Failing test case input:
108524550542

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
def resolve():
	answer = 0
	N = int(input())
	if N==1:
		print(answer)
	else:
		
		for p in range(2, int(N**0.5)+2):
			e = 0
			while (N % p == 0):
				N /= p
				e += 1
			
			if e>0:
				
				for i in range(1, e+1):
					if e >= i:
						e -= i
						answer += 1
		
		if N!=1:
			answer += 1
		print(answer)
        
resolve()
Problem: p02660
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math
n = int(input())
N = n

if(n == 1):
    print(0)
    exit()

yakusu = []
multi = []

i = 2
while(i <= int(math.sqrt(N))):
    
    if(n % i == 0):
        if(i in yakusu):
            multi[yakusu.index(i)] += 1
        else:
            yakusu.append(i)
            multi.append(1)
        n = int(n / i)
        continue
    
    if(n == 1):
        break
    
    i += 1

if(len(yakusu) == 0):
    yakusu.append(n)
    multi.append(1)
    
ans = 0

for j in range(len(multi)):
    h = (-1 + int(math.sqrt(1 + 8 * multi[j]))) / 2
    ans += int(h)

print(ans)

Failing test case input:
918292

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import math

n = int(input())
N = n

if(n == 1):
    print(0)
    exit()

yakusu = []
multi = []

i = 2

while(i <= math.ceil(math.sqrt(N))):
    
    if(n % i == 0):
        if(i in yakusu):
            multi[yakusu.index(i)] += 1
        else:
            yakusu.append(i)
            multi.append(1)
        n = int(n / i)
        continue
    
    if(n == 1):
        break
    
    i += 1
    
else:
    yakusu.append(n)
    multi.append(1)

if(len(yakusu) == 0):
    print(1)
    exit()
    



ans = 0

for j in range(len(multi)):
    h = (-1 + int(math.sqrt(1 + 8 * multi[j]))) / 2
    ans += int(h)

print(ans)

Problem: p02660
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n = int(input())

def divGame(N=n):
  if N == 1:
    return 0
  if N == 2:
    return 1
  
  factors = []
  
  count = 0
  while N % 2 == 0:
    N /= 2
    count += 1
  if count != 0:
    factors.append(count)

  for i in range(3, int(N**0.5 + 1), 2):
    count = 0
    while N % i == 0:
      N /= i
      count += 1
    if count != 0:
      factors.append(count)
  if N != 1:
    factors.append(1)

  factors.sort()

  answer = 0
  accum = 1
  count = 1
  for i in range(len(factors)):
    while factors[i] > accum:
      count += 1
      accum += count
    answer += count

  return answer

print(divGame())

Failing test case input:
3688232787

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
n = int(input())

def divGame(N=n):
  if N == 1:
    return 0
  if N == 2:
    return 1
  
  factors = []

  for i in range(2, int(N**0.5 + 1)):
    count = 0
    while N % i == 0:
      N /= i
      count += 1
    if count != 0:
      factors.append(count)
  if N != 1:
    factors.append(1)

  factors.sort()

  answer = 0
  accum = 1
  count = 1
  for i in range(len(factors)):
    while factors[i] >= accum:
      count += 1
      accum += count
    answer += count - 1

  return answer

print(divGame())
Problem: p02660
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):





import sys
import heapq

def main():
    temp = [True] * (10 ** 6)
    temp[0] = False
    temp[1] = False
    for i in range(2, 10 ** 6):
        if temp[i]:
            cnt = 2 * i
            while cnt < 10 ** 6:
                temp[cnt] = False
                cnt += i
    prime = []
    for i in range(10 ** 6):
        if temp[i]:
            prime.append(i)

    n = int(input())
    if n == 1:
        print(0)
        return
    ans = 0
    tempN = n
    for i in prime:
        if i > tempN:
            break
        if tempN % i:
            continue
        div = 0
        while True:
            cnt = 1
            temp = 2
            while tempN % (i ** (div + 2 * temp)) == 0:
                cnt += 1
                temp *= 2
            if tempN % (i ** (div + cnt)):
                break
            div += cnt
        tempN = tempN 
        
        if div > 2:
            div = int((div * 2) ** 0.5)
        else:
            div = 1
        
        ans += div
    if tempN > 1:
        ans += 1
    print(max(ans, 1))
    return

if __name__ == "__main__":
    main()

Failing test case input:
2860683

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):





import sys
import heapq

def main():
    temp = [True] * (10 ** 6 + 10)
    temp[0] = False
    temp[1] = False
    for i in range(2, 10 ** 6 + 10):
        if temp[i]:
            cnt = 2 * i
            while cnt < 10 ** 6 + 10:
                temp[cnt] = False
                cnt += i
    prime = []
    for i in range(10 ** 6 + 10):
        if temp[i]:
            prime.append(i)
 
    n = int(input())
    ans = 0
    tempN = n
    for i in prime:
        if i > tempN:
            break
        if tempN % i:
            continue
        div = 0
        while tempN % i == 0:
            tempN = tempN 
            div += 1
        tempAns = int((div * 2) ** 0.5)
        if tempAns * (tempAns + 1) 
            tempAns -= 1
        
        ans += tempAns
    if tempN > 1:
        ans += 1
    print(ans)
    return
 
if __name__ == "__main__":
    main()