Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n,k,q = map(int,input().split())
score = [k for i in range(n)]
a_i = [int(input())-1 for i in range(q)]

for i in range(len(a_i)):
    for j in range(len(score)):
        if(a_i[i] == j):
            score[j] += 0
        else:
            score[j] -= 1
    
for i in score:
    if(i > 0):
        print('Yes')
    else:
        print('No')

Fixed submission:
import sys
n,k,q = map(int,input().split())
score = [k-q for i in range(n)]
a_i = [int(input())-1 for i in range(q)]


for i in range(len(a_i)):
    score[a_i[i]] += 1



for i in score:
    if(i > 0):
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Time Limit Exceeded):
n,k,q = map(int,input().split())
score = [k for i in range(n)]


a_i = []
for i in range(q):
    a_i.append(int(input())-1)


for i in range(len(a_i)):
    for j in range(len(score)):
        if(a_i[i] == j):
            pass
        else:
            score[j] -= 1
    

for i in range(len(score)):
    if(score[i] > 0):
        print('Yes')
    else:
        print('No')

Fixed submission:
import sys
n,k,q = map(int,input().split())
score = [k-q for i in range(n)]
a_i = [int(input())-1 for i in range(q)]


for i in range(len(a_i)):
    score[a_i[i]] += 1



for i in score:
    if(i > 0):
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Time Limit Exceeded):
n,k,q = map(int,input().split())
score = [k for i in range(n)]

for i in range(q):
    a_i = int(input())-1
    for j in range(len(score)):
        if(j == a_i):
            pass
        else:
            score[j] -= 1
    

for i in range(len(score)):
    if(score[i] > 0):
        print('Yes')
    else:
        print('No')

Fixed submission:
import sys
n,k,q = map(int,input().split())
score = [k-q for i in range(n)]
a_i = [int(input())-1 for i in range(q)]


for i in range(len(a_i)):
    score[a_i[i]] += 1



for i in score:
    if(i > 0):
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Time Limit Exceeded):
n,k,q = map(int,input().split())
score = [k for i in range(n)]

for i in range(q):
    a_i = int(input())-1
    for j in range(len(score)):
        if(j == a_i):
            pass
        else:
            score[j] -= 1
    

for i in range(len(score)):
    if(score[i] > 0):
        print('Yes')
    else:
        print('No')

Fixed submission:
import sys
n,k,q = map(int,input().split())
score = [k-q for i in range(n)]
a_i = [int(input())-1 for i in range(q)]


for i in range(len(a_i)):
    score[a_i[i]] += 1



for i in score:
    if(i > 0):
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin


n = int(stdin.readline().strip())
a_lst = [int(x) for x in stdin.readline().strip().split()]

min_diff = 2020202021

for i in range(len(a_lst)):
  left = sum(a_lst[:i])
  right = sum(a_lst[i:])
  if abs(left - right) < min_diff:
    min_diff = abs(left - right)
    
print(min_diff)

Fixed submission:
from sys import stdin


n = int(stdin.readline().strip())
a_lst = [int(x) for x in stdin.readline().strip().split()]

pos = len(a_lst) // 2
min_diff = 10000000000000000000

while(True):
  left = sum(a_lst[:pos])
  right = sum(a_lst[pos:])
  diff = right - left
  
  if min_diff > abs(diff): min_diff = abs(diff)
  else: break
  
  if diff > 0: pos += 1
  elif diff < 0: pos -= 1
    
print(min_diff)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
import numpy as np

n,k,q = [int(x) for x in stdin.readline().rstrip().split()]
a_lst = []
p_lst = np.array([k] * n)

for i in range(q):
  a_lst.append(int(stdin.readline().rstrip()))
  
for i, a in enumerate(a_lst):
  p_lst[:a-1] -= 1
  p_lst[a:] -= 1
  
for p in p_lst:
  if p <=0:
    print('No')
  else:
    print('Yes')

Fixed submission:
from sys import stdin
import numpy as np
 
n,k,q = [int(x) for x in stdin.readline().rstrip().split()]
p_lst = [k] * n
p_t_lst = [0] * n

for i in range(q):
  a = int(stdin.readline().rstrip())
  p_t_lst[a-1] += 1

p_lst = np.array(p_lst) + np.array(p_t_lst) - q

for p in p_lst:
  if p <= 0:
    print('No')
  else:
    print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
import numpy as np
 
n,m = [int(x) for x in stdin.readline().rstrip().split()]
a_lst = np.array([int(x) for x in stdin.readline().rstrip().split()])

for i in range(m):
  a_lst[np.argmax(a_lst)] = a_lst[np.argmax(a_lst)] // 2
  
print(np.sum(a_lst))

Fixed submission:
from sys import stdin
import heapq

n,m = [int(x) for x in stdin.readline().rstrip().split()]
a_lst = [int(x) * (-1) for x in stdin.readline().rstrip().split()]
heapq.heapify(a_lst)

for i in range(m):
  tmp = heapq.heappop(a_lst)
  tmp = (-1) * ((-1*tmp)//2)
  heapq.heappush(a_lst, tmp)
  
print(-sum(a_lst))
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

n = int(stdin.readline().rstrip())
print(sum(range(n)))

Fixed submission:
from sys import stdin

n = int(stdin.readline().rstrip())
print(((n-1)*n)//2)
Buggy python submission (verdict: Runtime Error):
from sys import stdin

N = int(stdin.readline().rstrip())
h_lst = [int(x) for x in stdin.readline().rstrip().split()][::-1]

if len(h_lst) == 1:
  print("Yes")
else:
  f = "Yes"
  prev = h_lst[0]
  for i in h_lst[1:]:
    if prev - i >= 0:
      prev = i
    elif prev - i == -1:
      prev = i - 1
    else:
      f = "No"
      break

print(f)

Fixed submission:
from sys import stdin

N = int(stdin.readline().rstrip())
h_lst = [int(x) for x in stdin.readline().rstrip().split()][::-1]

if len(h_lst) < 1:
  print("Yes")
else:
  f = "Yes"
  prev = h_lst[0]
  for i in h_lst[1:]:
    if prev - i >= 0:
      prev = i
    elif prev - i == -1:
      prev = i - 1
    else:
      f = "No"
      break

print(f)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

n, k = [int(x) for x in stdin.readline().strip().split()]
h_lst = [int(x) for x in stdin.readline().strip().split()]
min_cost_lst = [0] + [10**12] * (n-1)

for i in range(n):
  min_cost_i = min_cost_lst[i]
  h_lst_i = h_lst[i]
  for j in range(1, k+1):
    if i + j < n and min_cost_i < min_cost_lst[i+j]:
      min_cost_lst[i + j] = min(min_cost_lst[i + j], min_cost_i + abs(h_lst[i+j] - h_lst_i))

print(min_cost_lst[-1])

Fixed submission:
import numpy as np

def main():
  N, K = map(int, input().split())
  h = list(map(int, input().split()))

  INF = 10**10

  dp = [INF]*N
  dp[0] = 0

  dp = np.array(dp)
  h = np.array(h)

  for i in range(N):
    T = min(N,i+K+1)
    dp[i+1:T] = np.minimum(dp[i+1:T], dp[i] + abs(h[i+1:T]-h[i]))

  print(dp[N-1])
  
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

n, k = [int(x) for x in stdin.readline().strip().split()]
h_lst = [int(x) for x in stdin.readline().strip().split()]
min_cost_lst = [0] + [10**10] * (n-1)

for i in range(n):
  for j in range(1, k+1):
    if i + j < n and min_cost_lst[i] < min_cost_lst[i+j]:
      min_cost_lst[i + j] = min(min_cost_lst[i + j], min_cost_lst[i] + abs(h_lst[i+j] - h_lst[i]))

print(min_cost_lst[-1])

Fixed submission:
import numpy as np

def main():
  N, K = map(int, input().split())
  h = list(map(int, input().split()))

  INF = 10**10

  dp = [INF]*N
  dp[0] = 0

  dp = np.array(dp)
  h = np.array(h)

  for i in range(N):
    T = min(N,i+K+1)
    dp[i+1:T] = np.minimum(dp[i+1:T], dp[i] + abs(h[i+1:T]-h[i]))

  print(dp[N-1])
  
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

n, k = [int(x) for x in stdin.readline().strip().split()]
h_lst = [int(x) for x in stdin.readline().strip().split()]
min_cost_lst = [0] + [10**10] * (n-1)

for i in range(n):
  for j in range(1, k+1):
    if i + j < n:
      min_cost_lst[i + j] = min(min_cost_lst[i + j], min_cost_lst[i] + abs(h_lst[i+j] - h_lst[i]))

print(min_cost_lst[-1])

Fixed submission:
import numpy as np

def main():
  N, K = map(int, input().split())
  h = list(map(int, input().split()))

  INF = 10**10

  dp = [INF]*N
  dp[0] = 0

  dp = np.array(dp)
  h = np.array(h)

  for i in range(N):
    T = min(N,i+K+1)
    dp[i+1:T] = np.minimum(dp[i+1:T], dp[i] + abs(h[i+1:T]-h[i]))

  print(dp[N-1])
  
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
from sys import stdin

def gcd(a, b):
	while b: a, b = b, a % b
	return a

N, X = [int(x) for x in stdin.readline().rstrip().split()]
x_lst = sorted(set([abs(int(x)-X) for x in stdin.readline().rstrip().split()]))

if len(x_lst) == 1:
  print(x_lst[0])
else:
  prev_x = x_lst[0]
  for x in x_lst[1:]:
    prev_x = gcd(prev_x, x)
    if prev_x == 1: break
  print(prev_x)

Fixed submission:
from sys import stdin

A,B = [int(x) for x in stdin.readline().rstrip().split()]

if(A*B % 2 == 0): print('No')
else: print('Yes')
Buggy python submission (verdict: Runtime Error):
import bisect

n, m, k = map(int, input().split())
a, b = [0], [0]
for i, (a_, b_) in enumerate(zip(input().split(), input().split())):
    a.append(a[i] + int(a_))
    b.append(b[i] + int(b_))

res = 0
a_ = 0
for i in range(n+1):
    if a[i] > k:
        break
    j = bisect.bisect(b, k-a[i]) - 1
    res = max(res, i+j)

print(res)


Fixed submission:
import bisect

n, m, k = map(int, input().split())
a = [0] + [int(x) for x in input().split()]
b = [0]
for x in input().split():
    b.append(b[-1] + int(x))

res = 0
a_ = 0
for i in range(n+1):
    a_ += a[i]
    if a_ > k:
        break
    b_max = k - a_
    b_num = bisect.bisect(b, b_max) - 1
    res = max(res, i + b_num)

print(res)
Buggy python submission (verdict: Time Limit Exceeded):
import functools
n = int(input())
arr = [int(a) for a in input().split()]
m = 10 ** 18

ans = functools.reduce(lambda a, b: a*b, arr)
if ans <= m:
    print(ans)
else:
    print(-1)



Fixed submission:
import functools
n = int(input())
arr = [int(a) for a in input().split()]
m = 10 ** 18

ans = 1
if 0 in arr:
    print(0)
else:
    for a in arr:
        ans *= a
        if ans > m:
            print(-1)
            break
    else:
        print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())

# 素因数分解
def prime_factorization(n):
    prime = {}
    tmp = n
    for i in range(2, int(n**0.5)+1):
        if tmp % i == 0:
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            if i in prime:
                prime[i] += cnt
            else:
                prime[i] = cnt
    if tmp != 1:
        if tmp in prime:
            prime[tmp] += 1
        else:
            prime[tmp] = 1
    return prime

if x == 1:
    print(0, -1)
else:
    p = prime_factorization(x)
    m = min(p.keys())
    a = 0
    while True:
        b = a - m
        if a ** 5 - b ** 5 == x:
            print(a, b)
            break
        if a > 0:
            a = -a
        else:
            a = -a + 1


Fixed submission:
x = int(input())

for a in range(-200, 200):
    for b in range(-200, 200):
        if a**5 - b**5 == x:
            print(a, b)
            exit()

Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())

# 素因数分解
def prime_factorization(n):
    prime = {}
    tmp = n
    for i in range(2, int(n**0.5)+1):
        if tmp % i == 0:
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            if i in prime:
                prime[i] += cnt
            else:
                prime[i] = cnt
    if tmp != 1:
        if tmp in prime:
            prime[tmp] += 1
        else:
            prime[tmp] = 1
    return prime

if x == 1:
    print(0, -1)
else:
    p = prime_factorization(x)
    m = min(p.keys())
    a = 0
    while True:
        b = a - m
        if a ** 5 - b ** 5 == x:
            print(a, b)
            break
        a += 1


Fixed submission:
x = int(input())

for a in range(-200, 200):
    for b in range(-200, 200):
        if a**5 - b**5 == x:
            print(a, b)
            exit()
Buggy python submission (verdict: Runtime Error):
print((int(input)+1)//2)

Fixed submission:
print((int(input())+1)//2)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = set(input().split())

print('YES' if len(s) == n else 'NO')

Fixed submission:
n = int(input())
a = set(input().split())

print('YES' if len(a) == n else 'NO')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

set_ = set()

for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            set_.add(''.join([s[i], s[j], s[k]]))

print(len(set_))

Fixed submission:
n = int(input())
s = input()

cnt = 0
for x in range(10):
    x_ = str(x)
    for i in range(n-2):
        if s[i] == x_:
            break
    else:
        continue
    for y in range(10):
        y_ = str(y)
        for j in range(i+1, n-1):
            if s[j] == y_:
                break
        else:
            continue
        for z in range(10):
            z_ = str(z)
            for k in range(j+1, n):
                if s[k] == z_:
                    cnt += 1
                    break

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

n = int(input())
s = input()

comb = combinations(s, 3)
set_ = set()

for x in comb:
    set_.add(x)

print(len(set_))

Fixed submission:
n = int(input())
s = input()

cnt = 0
for x in range(10):
    x_ = str(x)
    for i in range(n-2):
        if s[i] == x_:
            break
    else:
        continue
    for y in range(10):
        y_ = str(y)
        for j in range(i+1, n-1):
            if s[j] == y_:
                break
        else:
            continue
        for z in range(10):
            z_ = str(z)
            for k in range(j+1, n):
                if s[k] == z_:
                    cnt += 1
                    break

print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
from  itertools import combinations

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

res = 0
for a, b, c in combinations(l, 3):
    if all([a<b+c, b<c+a, c<a+b]):
        res += 1

print(res)

Fixed submission:
import bisect

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

res = (n * (n-1) * (n-2)) // 6
for i in range(n-2):
    a = l[i]
    for j in range(i+1, n-1):
        b = l[j]
        res -= n - bisect.bisect_left(l, a+b)

print(res)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = [int(x) for x in input().split() ]

while m > 0:
    a.sort(reverse=True)
    tmp = a[0] // 2
    for i in range(n):
        if a[i] > tmp and m > 0:
            a[i] //= 2
            m -= 1
        else:
            break

print(sum(a))

Fixed submission:
import heapq

n, m = map(int, input().split())
a = [int(i) * (-1) for i in input().split()]
heapq.heapify(a)

for i in range(m):
    tmp = (heapq.heappop(a) * (-1)) // 2
    heapq.heappush(a, tmp * (-1))

print(sum(a) * (-1))

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

n, m = map(int, input().split())
a = map(int, input().split())
a = map(lambda x: -x, a)
heapq.heapify(a)

for i in range(m):
    tmp = -heapq.heappop(a) // 2
    heapq.heappush(a, -tmp)

print(-sum(a))


Fixed submission:
import heapq

n, m = map(int, input().split())
a = [int(i) * (-1) for i in input().split()]
heapq.heapify(a)

for i in range(m):
    tmp = (heapq.heappop(a) * (-1)) // 2
    heapq.heappush(a, tmp * (-1))

print(sum(a) * (-1))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n, m = map(int, input().split())
a = sorted([int(i) for i in input().split()])

for i in range(m):
    tmp = a.pop() // 2
    idx = bisect.bisect_left(a, tmp)
    a.insert(idx, tmp)

print(sum(a))

Fixed submission:
import heapq

n, m = map(int, input().split())
a = [int(i) * (-1) for i in input().split()]
heapq.heapify(a)

for i in range(m):
    tmp = (heapq.heappop(a) * (-1)) // 2
    heapq.heappush(a, tmp * (-1))

print(sum(a) * (-1))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n, m = map(int, input().split())
a = sorted([int(i) for i in input().split()])

for i in range(m):
    tmp = a.pop() // 2
    idx = bisect.bisect_left(a, tmp)
    a.insert(idx, tmp)

print(sum(a))

Fixed submission:
import heapq

n, m = map(int, input().split())
a = [int(i) * (-1) for i in input().split()]
heapq.heapify(a)

for i in range(m):
    tmp = (heapq.heappop(a) * (-1)) // 2
    heapq.heappush(a, tmp * (-1))

print(sum(a) * (-1))
Buggy python submission (verdict: Runtime Error):
import math

def combinations(p, q):
    return math.factorial(p) // (math.factorial(p - q) * math.factorial(q))

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

if n == k:
    print(1)
    for i in range(k-1):
        print(0)
elif k == 1:
    print(combinations(n-k+1, 1) % 1000000007)
else:
    for i in range(k-1):
        print((combinations(n-k+1, i+1) * (i+1)) % 1000000007)
    else:
        print((combinations(n-k+1, k)) % 1000000007)

Fixed submission:
import math

def combinations(p, q):
    return math.factorial(p) // (math.factorial(p - q) * math.factorial(q))

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

if n == k:
    print(1)
    for i in range(k-1):
        print(0)
elif k == 1:
    print(combinations(n-k+1, 1) % 1000000007)
else:
    for i in range(k-1):
        if i + 1 > n-k+1:
            print(0)
        else:
            print((combinations(n-k+1, i+1) * combinations(k-1, i)) % 1000000007)
    else:
        if k > n-k+1:
            print(0)
        else:
            print((combinations(n-k+1, k)) % 1000000007)

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

def combinations(p, q):
    return math.factorial(p) // (math.factorial(p - q) * math.factorial(q))

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

if k == 1:
    print(combinations(n-k+1, 1) % 1000000007)
else:
    for i in range(k-1):
        print((combinations(n-k+1, i+1) * (i+1)) % 1000000007)
    else:
        print((combinations(n-k+1, k)) % 1000000007)

Fixed submission:
import math

def combinations(p, q):
    return math.factorial(p) // (math.factorial(p - q) * math.factorial(q))

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

if n == k:
    print(1)
    for i in range(k-1):
        print(0)
elif k == 1:
    print(combinations(n-k+1, 1) % 1000000007)
else:
    for i in range(k-1):
        if i + 1 > n-k+1:
            print(0)
        else:
            print((combinations(n-k+1, i+1) * combinations(k-1, i)) % 1000000007)
    else:
        if k > n-k+1:
            print(0)
        else:
            print((combinations(n-k+1, k)) % 1000000007)

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

def combinations(p, q):
    return math.factorial(p) // (math.factorial(p - q) * math.factorial(q))

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

for i in range(k-1):
    print((combinations(n-k+1, i+1) * (i+1)) % 1000000007)
else:
    print((combinations(n-k+1, k)) % 1000000007)

Fixed submission:
import math

def combinations(p, q):
    return math.factorial(p) // (math.factorial(p - q) * math.factorial(q))

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

if n == k:
    print(1)
    for i in range(k-1):
        print(0)
elif k == 1:
    print(combinations(n-k+1, 1) % 1000000007)
else:
    for i in range(k-1):
        if i + 1 > n-k+1:
            print(0)
        else:
            print((combinations(n-k+1, i+1) * combinations(k-1, i)) % 1000000007)
    else:
        if k > n-k+1:
            print(0)
        else:
            print((combinations(n-k+1, k)) % 1000000007)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
list_ = [tuple(map(int, input().split())) for i in range(n)]
list_.sort()

ab = []
for i in range(len(list_)-1):
    x_1, y_1 = list_[i]
    
    for j in range(i+1, len(list_)):
        x_2, y_2 = list_[j]
        a = x_2 - x_1
        b = y_2 - y_1
        ab.append((a, b))

p, q = Counter(ab).most_common()[0][0]

res = 0
while len(list_):
    res += 1
    x, y = list_.pop(0)
    while True:
        if (x+p, y+q) in list_:
            list_.remove((x+p, y+q))
            x, y = x+p, y+q
        else:
            break

print(res)            

Fixed submission:
from collections import Counter
n = int(input())
list_ = [tuple(map(int, input().split())) for i in range(n)]
list_.sort()

if n == 1:
    print(1)
else:
    ab = []
    for i in range(len(list_)-1):
        x_1, y_1 = list_[i]
        
        for j in range(i+1, len(list_)):
            x_2, y_2 = list_[j]
            a = x_2 - x_1
            b = y_2 - y_1
            ab.append((a, b))

    p, q = Counter(ab).most_common()[0][0]

    res = 0
    while len(list_):
        res += 1
        x, y = list_.pop(0)
        while True:
            if (x+p, y+q) in list_:
                list_.remove((x+p, y+q))
                x, y = x+p, y+q
            else:
                break

    print(res)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = [int(i) for i in input().split()]
list_ = []
for i in range(m):
    b, c = map(int, input().split())
    list_ += [c] * b

a.sort()
list_.sort(reverse=True)

res = sum(a)
for i in range(min(len(a), len(list_))):
    if a[i] >= list_[i]:
        break
    else:
        res += list_[i] - a[i]

print(res)

Fixed submission:
n, m = map(int, input().split())
a = [(int(i), 1) for i in input().split()]
for i in range(m):
    b, c = map(int, input().split())
    a += [(c, b)]

a.sort(reverse=True)

ans = 0
i = 0
j = 0
while True:
    ans += a[i][0] * min(a[i][1], n-j)
    j += a[i][1]
    i += 1
    if j >= n:
        print(ans)
        break

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = [int(i) for i in input().split()]
for i in range(m):
    b, c = map(int, input().split())
    a += [c] * b

a.sort(reverse=True)

print(sum(a[:n]))

Fixed submission:
n, m = map(int, input().split())
a = [(int(i), 1) for i in input().split()]
for i in range(m):
    b, c = map(int, input().split())
    a += [(c, b)]

a.sort(reverse=True)

ans = 0
i = 0
j = 0
while True:
    ans += a[i][0] * min(a[i][1], n-j)
    j += a[i][1]
    i += 1
    if j >= n:
        print(ans)
        break
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
lr = [tuple(map(int, input().split())) for i in range(q)]

for i in range(q):
    l, r = lr[i]
    ans = s[l-1:r].count('AC')
    print(ans)

Fixed submission:
n, q = map(int, input().split())
s = input()
lr = [tuple(map(int, input().split())) for i in range(q)]
arr = [0]

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

for i in range(q):
    l, r = lr[i]
    ans = arr[r-1] - arr[l-1]
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = len(s)

while True:
    if s.count('01') == 0 and s.count('10') == 0:
        break
    s = s.replace('01', '').replace('10', '')

_n = len(s)

print(n - _n)

Fixed submission:
s = input()
set_ = set(['0', '1'])
arr = ['*']
for i in s:
    arr.append(i)
    if set(arr[-2:]) == set_:
        arr.pop()
        arr.pop()

ans = len(s) - len(arr) + 1
print(ans)