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

Fixed submission:
import numpy as np

N, M, X = map(int, input().split())
C = []
A = [[] for i in range(M)]
resC = []
resA = list(A)

NEW = 0

def update(base):
  #print(NEW,base)
  if base==None:
    return NEW
  return base + NEW

def check(num):
  return num>=X

def check2(*args):
  res = True
  for val in args:
    buf = (val >= X)
    res = res and buf
  return res

for i in range(N):
  buf = list(map(int, input().split()))
  C.append(buf[0])
  for j in range(M):
    A[j].append(buf[j+1])

for i in range(N):
  if i == 0:
    NEW = C[i]
    resC = [0, NEW]
    resA = [[0, A[j][i]] for j in range(M)]
  else:
    NEW = C[i]
    resC = resC + list(map(update, resC))
    for j in range(M):
      NEW = A[j][i]
      resA[j] = resA[j] + list(map(update, resA[j]))

res = list(map(check2, *resA))
#print(np.asarray(resC)[res]) 
if sum(res)==0:
  print(-1)
else:
  print(min(np.asarray(resC)[res]))

Buggy submission (verdict: Runtime Error):
import numpy as np

N, M, X = map(int, input().split())
C = []
A = [[] for i in range(M)]
resC = []
resA = list(A)

NEW = 0

def update(base):
  #print(NEW,base)
  if base==None:
    return NEW
  return base + NEW

def check(num):
  return num>=X

def check2(*args):
  res = True
  for val in args:
    buf = (val >= X)
    res = res and buf
  return res

for i in range(N):
  buf = list(map(int, input().split()))
  C.append(buf[0])
  for j in range(M):
    A[j].append(buf[j+1])

for i in range(N):
  if i == 0:
    NEW = C[i]
    resC = [0, NEW]
    resA = [[0, A[j][i]] for i in range(M)]
  else:
    NEW = C[i]
    resC = resC + list(map(update, resC))
    for j in range(M):
      NEW = A[j][i]
      resA[j] = resA[j] + list(map(update, resA[j]))

res = list(map(check2, *resA))
#print(np.asarray(resC)[res]) 
if sum(res)==0:
  print(-1)
else:
  print(min(np.asarray(resC)[res]))

Buggy submission (verdict: Runtime Error):
import numpy as np

N, M, X = map(int, input().split())
C = []
A = [[] for i in range(M)]
resC = []
resA = list(A)

NEW = 0

def update(base):
  #print(NEW,base)
  if base==None:
    return NEW
  return base + NEW

def check(num):
  return num>=X

def check2(*args):
  res = True
  for val in args:
    buf = (val >= X)
    res = res and buf
  return res

for i in range(N):
  buf = list(map(int, input().split()))
  C.append(buf[0])
  for j in range(M):
    A[j].append(buf[j+1])

for i in range(N):
  if i == 0:
    NEW = C[i]
    resC = [0, NEW]
    resA = [[0, A[j][i]] for i in range(M)]
  else:
    NEW = C[i]
    resC = resC + list(map(update, resC))
    for j in range(M):
      NEW = A[j][i]
      resA[j] = resA[j] + list(map(update, resA[j]))

res = list(map(check2, *resA))
#print(np.asarray(resC)[res]) 
if sum(res)==0:
  print(-1)
else:
  print(min(np.asarray(resC)[res]))
Problem p02697 (python)

Fixed submission:
N, M = map(int,input().split())
res = []
for i in range(M):
  if i%2==0:
    j = i//2
    #res.append(M-2*j)
    print("{} {}".format(1+j,M+1-j))
  else:
    j = i//2
    #res.append(M-1-2*j)
    print("{} {}".format(M+2+j,2*M+1-j))

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
for i in range(M):
  if i%2==0:
    j = i//2
    print("{} {}".format(1+j,M+1-j))
  else:
    j = i//2
    print("{} {}".format(M+2+i,2M+1-i))
Problem p02706 (python)

Fixed submission:
N = list(map(int, input().split()))[0]
A = list(map(int, input().split()))

sum = 0
for i in A:
  sum = sum + i
if sum > N:
  print(-1)
else:
  print(N-sum)

Buggy submission (verdict: Runtime Error):
N = map(int, input().split())[0]
A = map(int, input().split())
sum = 0
for i in A:
  sum += A
if sum > N:
  print(-1)
else:
  print(N-sum)
Problem p02713 (python)

Fixed submission:
def compute_gcm(x, y):
  if x == y:
    return x
  if x < y:
    s = x
    x = y
    y = s
  if x==1:
    return 1
  a = x%y
  if a == 0:
    return y
  return compute_gcm(y, a)

#print(compute_gcm(4,compute_gcm(2,2)))
k = int(input())
res = k**3-(k-1)**3
same1 = 0
same2 = 0
rate = [6,3,1]
for p in range(2,k+1):
  for q in range(p, k+1):
    same1 = int(p==q)
    gcm1 = compute_gcm(q,p)
    for r in range(q, k+1):
      same2 = int(q==r)
      gcm = compute_gcm(r,gcm1)
      res += gcm*rate[same1+same2]
      #print("p:{}, q:{}, r:{}, gcm:{}, rate:{}, sum:{}".format(p,q,r,gcm,rate[same1+same2],res))
print(res)

Buggy submission (verdict: Runtime Error):
function GCM(x, y):
  if x == y:
    return x
  if x < y:
    s = x
    x = y
    y = s
  
  a = x%y
  if a == 0:
    return y
  return GCM(y, a)

k = int(input())
res = 0
same1 = 0
same2 = 0
rate = [6,3,1]
for p in range(1,k+1):
  for q in range(p, k+1):
    same1 = int(p==q)
    gcm = GCM(q,p)
    for r in range(q, k+1):
      same2 = int(q==r)
      gcm = GCM(r,gcm)
      res += gcm*rate[same1+same2]
print(res)
Problem p02720 (python)

Fixed submission:
from collections import deque
 
K = int(input())
 
count = 0
Q = deque([1,2,3,4,5,6,7,8,9])
while count != K:
  a = Q.popleft()
  b = a%10
  if b != 0:
    Q.append(a*10 + b - 1)
  Q.append(a*10 + b)
  if b != 9:
    Q.append(a*10 + b + 1)
  count += 1
  #print(Q)
print(a)

Buggy submission (verdict: Runtime Error):
from collections import deque

K = int(input())

count = 0
ans = 0
Q = deque([1,2,3,4,5,6,7,8,9])
while count != K:
  a = Q.popleft()
  b = a%10
  if b != 0:
    Q.append(q*10 + b - 1)
  Q.append(q*10)
  if b != 9:
    Q.append(q*10 + b + 1)
  count += 1
  ans = q
print(q)
Problem p02747 (python)

Fixed submission:
s = "hi"
S = input()
flag = False
for i in range(5):
  if S==s:
    flag=True
    break
  s = s+"hi"
if flag:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
 input()
if len(S)%2 == 0:
  for i in range(len(S)//2):
    if S[i*2:(i+1)*2]!="hi":
      print("No")
      exit()
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
S = input()
if len(S)%2 == 0:
  for i in range(len(S)//2):
    if S[i*2:(i+1)*2]!="hi":
      print("No")
      exsit()
  print("Yes")
else:
  print("No")
Problem p02786 (python)

Fixed submission:
H = int(input())
count = 0
ans = 0
while H>1:
  H = H//2
  ans += 2**count
  count += 1
ans += 2**count
print(ans)

Buggy submission (verdict: Runtime Error):
H = int(input())
count = 0
ans = 0
while H>1:
  H = H//2
  ans += 2**i
  count += 1
ans += 2**i
print(ans)

Buggy submission (verdict: Runtime Error):
H = int(input())
count = 0
ans = 0
while H>1:
  H = H//2
  ans += 2**i
  count += 1
ans += 2**i
print(ans)
Problem p02813 (python)

Fixed submission:
def func(x, y):
  if len(y)==1:
    dic.append(x*10+int(y))
  else:
    for j in range(len(y)):
      func(x*10+int(y[j]), y[:j]+y[j+1:])
dic = []
 
N = int(input())
func(0, "".join([str(i) for i in range(1,N+1)]))
 
A = int(input().replace(" ", ""))
B = int(input().replace(" ", ""))
ans = abs(dic.index(A)-dic.index(B))
print(ans)

Buggy submission (verdict: Runtime Error):
def func(x, y):
  if len(y)==1:
    dic.append(i*10+int(y))
  else:
    for j in range(len(y)):
      func(i*10+int(y[j]), y[:j]+y[j+1:])
dic = []

N = int(input())
func(0, "".join([i in range(1,N+1)]))

A = int(input().replace(" ", ""))
B = int(input().replace(" ", ""))
ans = abs(dic.index(A)-dic.index(B))
print(ans)
Problem p02823 (python)

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

dif = B-A
if dif%2 == 0:
  print(dif//2)
else:
  print(min(A-1, N-B)+1+((dif-1)//2))

Buggy submission (verdict: Runtime Error):
N, M, V, P = map(int, input().split())
A = list(map(int, input().split()))
Asorted = sorted(A)

n = len(Asorted)
start=0
end = n-P
Ap = A[-P]
total = V*M
while start < end -1:
  #print(start, end)
  i = (start+end-1)//2
  Ai = Asorted[i]
  if Ai + M < Ap:
    start = i+1
    continue
  limit = (Ai + M)*(n-P-i-1) - sum(Asorted[i+1:n-P]) + (i+P)*M
  if limit >= total:
    end = i+1
  else:
    start = i+1
print(n-start)

Buggy submission (verdict: Runtime Error):
import numpy as np

N, M, V, P = map(int, input().split())
A = list(map(int, input().split()))
if P == 1:
  Asorted = sorted(A)
else:
  Asorted = sorted(A)[:-(P-1)]

n = len(Asorted)
start=0
end = n
Ap = A[-1]
total = V*M
while start < end -1:
  #print(start, end)
  i = (start+end-1)//2
  Ai = Asorted[i]
  if i == n-1:
    start = n-1
    break
  limit = (Ai + M)*(n-i-1) - sum(Asorted[i+1:]) + (i+P)*M
  if limit >= total:
    end = i+1
  else:
    start = i+1
print(np.sum(np.asarray(A)>=Asorted[start]))

Buggy submission (verdict: Runtime Error):
import numpy as np

N, M, V, P = map(int, input().split())
A = list(map(int, input().split()))
Asorted = sorted(A)[:-(P-1)]

n = len(Asorted)
start=0
end = n
Ap = A[-1]
total = V*M
while start < end -1:
  #print(start, end)
  i = (start+end-1)//2
  Ai = Asorted[i]
  if i == n-1:
    start = n-1
    break
  limit = (Ai + M)*(n-i-1) - sum(Asorted[i+1:]) + (i+P)*M
  if limit >= total:
    end = i+1
  else:
    start = i+1
print(np.sum(np.asarray(A)>=Asorted[start]))

Buggy submission (verdict: Runtime Error):
import numpy as np

N, M, V, P = map(int, input().split())
A = list(map(int, input().split()))
Asorted = sorted(A)[:-(P-1)]

n = len(Asorted)
start=0
end = n
Ap = A[-1]
total = V*M
while start < end -1:
  #print(start, end)
  i = (start+end-1)//2
  Ai = Asorted[i]
  limit = (Ai + M)*(n-i-1) - sum(Asorted[i+1:]) + (i+P)*M
  if limit >= total:
    end = i+1
  else:
    start = i+1
print(np.sum(np.asarray(A)>=Asorted[start]))
Problem p02899 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans = [0 for i in range(N)]
for i in range(N):
  ans[A[i]-1] = i+1
print(*ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
ans = [0 for i in range(N)]
for i in range(N):
  ans[A[i]-1] = i+1
print(" ".join(ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
ans = [0 for i in range(N)]
for i in range(N):
  ans[A[i]-1] = i+1
print(ans.join(" "))
Problem p03494 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
 
ans = float("inf")
for i in range(N):
  a = A[i]
  ans_tmp = 0
  while a%2==0:
    a = a//2
    ans_tmp += 1
  ans = min(ans_tmp, ans)
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(input().split())

ans = float("inf")
for i in range(N):
  a = A[i]
  ans_tmp = 0
  while a%2==0:
    a = a//2
    ans_tmp += 1
  ans = min(ans_tmp, ans)
print(ans)
Problem p03496 (python)

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

mina = min(A)
mini = A.index(mina)
maxa = max(A)
maxi = A.index(maxa)

if mina >= 0:
  print(N-1)
  for i in range(N-1):
    print("{} {}".format(i+1, i+2))
elif maxa < 0:
  print(N-1)
  for i in range(N-1):
    print("{} {}".format(N-i, N-i-1))
else:
  if -mina < maxa:
    print(2*N-1)
    for i in range(N):
      print("{} {}".format(maxi+1, i+1))
    for i in range(N-1):
      print("{} {}".format(i+1, i+2))
  else:
    print(2*N-1)
    for i in range(N):
      print("{} {}".format(mini+1, i+1))
    for i in range(N-1):
      print("{} {}".format(N-i, N-i-1))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

mina = min(A)
mini = A.index(mina)
maxa = max(A)
maxi = A.index(mixa)

if mina >= 0:
  print(N-1)
  for i in range(N-1):
    print("{} {}".format(i+1, i+2))
elif maxa < 0:
  print(N-1)
  for i in range(N-1):
    print("{} {}".format(N-i, N-i-1))
else:
  if -mina < maxa:
    print(2*N-1)
    for i in range(N):
      print("{} {}".format(maxi+1, i+1))
    for i in range(N-1):
      print("{} {}".format(i+1, i+2))
  else:
    print(2*N-1)
    for i in range(N):
      print("{} {}".format(mini+1, i+1))
    for i in range(N-1):
      print("{} {}".format(N-i, N-i-1))
Problem p02678 (python)

Fixed submission:
from collections import deque
n,m = map(int,input().split())
g = [[] for _ in range(n)]
for _ in range(m):
    a,b = map(int, input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

q = deque([0])
d = [-1]*n
d[0] = 0
ans = [0]*n
print("Yes")

while q:
    p = q.popleft() # 先に入れた要素を取り出す
    for node in g[p]:
        if d[node] == -1:
            d[node] = d[p] + 1
            q.append(node) # リストへの追加
        else:
            if d[node] + 1 == d[p]:
                ans[p] = node + 1

for i in range(1,n):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter

def main():
    N,M = map(int, input().split())

    L = [[0]*N for _ in range(N)] # n*nの隣接行列の作成
    for _ in range(M): # 隣接行列の作成
        a,b = map(int, input().split())
        L[a-1][b-1] = 1
        L[b-1][a-1] = 1

    d = [0]*N # 訪問スタンプ
    p = [0]*N # パス

    def dfs(x):
        d[x] = 1
        print("a",p)
        for v in range(N):
            if L[x][v] == 0:
                continue
            if p[v] == 0 and d[v] == 0:
                p[v] = x+1
                print(p)
            elif p[v] != x and d[v]==0:
                print("No")
                exit()
            if d[v] == 0:
                dfs(v)

    for u in range(N):
        if d[u] == 0:
            dfs(u)
    print(p)


if __name__=="__main__":
    main()
Problem p02684 (python)

Fixed submission:
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter,deque

def main():
    n,k = map(int, input().split())
    a = list(map(int, input().split()))

    c = []
    mark = [-1]*n
    pos,l = 0,0
    while 1:
        if mark[pos] >= 0:
            l = mark[pos]
            break
        mark[pos] = len(c)
        c.append(pos)
        pos = a[pos] - 1
    if k <= l:
        print(c[k] + 1)
    else:
        k -= l
        print(c[l + k%(len(c) - l)] + 1)
if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter,deque

def main():
    n,k = map(int, input().split())
    a = list(map(int, input().split()))

    c = []
    mark = [-1]*n
    pos,l = 0,0
    while 1:
        if mark[pos] >= 0:
            l = mark[pos]
            break
        mark[pos] = len(c)
        c.append(pos)
        pos = a[pos] - 1
    if k <= l:
        print(c[k] + 1)
    else:
        k -= l
        print(c[l + k%(len(c) - 1)] + 1)
if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter,deque

def main():
    n,k = map(int, input().split())
    a = list(map(int, input().split()))

    c = []
    mark = [-1]*n
    pos,l = 0,0
    while 1:
        if mark[pos] >= 0:
            l = mark[pos]
            break
        mark[pos] = len(c)
        c.append(pos)
        pos = a[pos] - 1
    if k <= 1:
        print(c[k] + 1)
    else:
        k -= l
        print(c[l + k%(len(c) - 1)] + 1)
if __name__=="__main__":
    main()
Problem p02708 (python)

Fixed submission:
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter,deque

def main():
    n,k = map(int, input().split())
    ans = 0
    mn = mx = 0
    for i in range(n+1):
        j = n-i
        mn += i
        mx += j
        if i+1 >= k:
            ans += mx-mn+1
    print(ans%(10**9+7))

if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter,deque

def main():
    n,k = map(int, input().split())
    n += 1
    l = [i for i in range(n)]
    L = [0]
    for i in range(1,n):
        L.append(L[i-1] + l[i])
    ans = 0
    for i in range(k, n):
        mi = L[i-1]
        ma = L[-1] - L[len(L)-i-1]
        ans += (ma-mi+1)
    ans += 1
    print(ans)

if __name__=="__main__":
    main()
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter,deque

def main():
    n,k = map(int, input().split())
    n += 1
    l = [i for i in range(n)]
    L = [0]
    for i in range(1,n):
        L.append(L[i-1] + l[i])
    ans = 0
    for i in range(k, n):
        mi = L[i-1]
        ma = L[-1] - L[len(L)-i-1]
        ans += (ma-mi+1)
    ans += 1
    print(ans)

if __name__=="__main__":
    main()
Problem p02732 (python)

Fixed submission:
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

def main():
    n = i_input()
    a = i_list()

    k = [0]
    for i in range(2*10**5):
        k.append(k[i]+(i+1))
    t = a.copy()
    t.sort()

    s = 0

    m = [0]*n

    for i,n in itertools.groupby(t):
        l = len(list(n))
        s += k[l-1]
        if l > 1:
            m[i-1] = k[l-2] - k[l-1]

    for i in a:
        print(s + m[i-1])







if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

def main():
    n = i_input()
    a = i_list()

    k = [0]
    for i in range(2*10):
        k.append(k[i]+(i+1))
    t = a.copy()
    t.sort()

    s = 0

    m = [0]*n

    for i,n in itertools.groupby(t):
        l = len(list(n))
        s += k[l-1]
        if l > 1:
            m[i-1] = k[l-2] - k[l-1]

    for i in a:
        print(s + m[i-1])







if __name__=="__main__":
    main()
Problem p02900 (python)

Fixed submission:
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    a,b = i_map()

    def prime_decomposition(n):
        i = 2
        table = []
        while i * i <= n: # sqrt(n)で計算が済む
            while n % i == 0:
                n //= i
                table.append(i)
            i += 1
        if n > 1:
            table.append(n)
        return table

    a = set(prime_decomposition(a))
    b = set(prime_decomposition(b))
    print(len(a&b)+1)



if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    a,b = i_map()

    def make_divisors(n,m):
        lower_divisors , upper_divisors = [], []
        i = 1
        while i*i <= n:
            if n % i == 0 and m % i == 0:
                lower_divisors.append(i)
                if n%(n//i)==0 and m%(n//i)==0:
                    upper_divisors.append(n//i)
            i += 1
        return lower_divisors + upper_divisors[::-1]

    l = set(make_divisors(a,b))

    def primes(n):
        is_prime = [True] * (n + 1)
        is_prime[0], is_prime[1] = False, False
        for i in range(2, int(n**0.5) + 1):
            if not is_prime[i]:
                continue
            for j in range(i * 2, n + 1, i):
                is_prime[j] = False
        return [i for i in range(n + 1) if is_prime[i]]

    L = set(primes(a+b))
    L.add(1)
    print(len(L&l))










if __name__=="__main__":
    main()
Problem p03087 (python)

Fixed submission:
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter,deque

def main():
    n,q = map(int, input().split())
    s = input().rstrip()
    t = [0]*(n+1)
    for i in range(n):
        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])

if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter,deque

def main():
    n,q = map(int, input().split())
    s = input().rstrip()
    t = [0]*(n+1)
    for _ in range(n):
        if s[i:i+2] == "AC":
            t[i+1] = t[i] + 1

    for i in range(q):
        l,r = map(int, input().split())
        prin(t[r-1] - t[l-1])

if __name__=="__main__":
    main()