Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    for _ in range(min(k,1000)):
        dp = [0] * (n + 1)
        for index, i in enumerate(a):
            dp[max(0, index - i)] += 1
            dp[min(n, index + i + 1)] -= 1
        a[0] = dp[0]
        for i in range(1, n):
            a[i] = a[i - 1] + dp[i]
    print(*a)


if __name__ == '__main__':
    resolve()


Fixed submission:
def resolve():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    for _ in range(min(k,100)):
        dp = [0] * (n + 1)
        for index, i in enumerate(a):
            dp[max(0, index - i)] += 1
            dp[min(n, index + i + 1)] -= 1
        a[0] = dp[0]
        for i in range(1, n):
            a[i] = a[i - 1] + dp[i]
    print(*a)


if __name__ == '__main__':
    resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    for _ in range(k):
        dp = [0] * (n + 1)
        for index, i in enumerate(a):
            dp[max(0, index - i)] += 1
            dp[min(n, index + i + 1)] -= 1
        a[0] = dp[0]
        for i in range(1, n):
            a[i] = a[i - 1] + dp[i]
    print(*a)


if __name__ == '__main__':
    resolve()


Fixed submission:
def resolve():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    for _ in range(min(k,100)):
        dp = [0] * (n + 1)
        for index, i in enumerate(a):
            dp[max(0, index - i)] += 1
            dp[min(n, index + i + 1)] -= 1
        a[0] = dp[0]
        for i in range(1, n):
            a[i] = a[i - 1] + dp[i]
    print(*a)


if __name__ == '__main__':
    resolve()
Buggy python submission (verdict: Runtime Error):
from functools import lru_cache


def PrimeFactorization(m):
    pf = {}
    i = 2
    while i ** 2 < n:
        while n % i == 0:
            pf[i] = pf.get(i, 0) + 1
            n //= i
        i += 1
    if n > 1:
        pf[n] = 1
    return pf


@lru_cache(maxsize=100000)
def f(x):
    return int((-1 + (1 + 8 * x) ** 0.5) // 2 + 0.001)


def resolve():
    n = int(input())
    d = PrimeFactorization(n)
    ans = 0
    for v in d.values():
        ans += f(v)
    print(ans)


if __name__ == '__main__':
    resolve()


Fixed submission:
from functools import lru_cache


def PrimeFactorization(m):
    pf = {}
    for i in range(2, int(m ** 0.5) + 1):
        while m % i == 0:
            pf[i] = pf.get(i, 0) + 1
            m //= i
    if m > 1:
        pf[m] = 1
    return pf


@lru_cache(maxsize=100000)
def f(x):
    return int((-1 + (1 + 8 * x) ** 0.5) // 2 + 0.001)


def resolve():
    n = int(input())
    d = PrimeFactorization(n)
    ans = 0
    for v in d.values():
        ans += f(v)
    print(ans)


if __name__ == '__main__':
    resolve()
Buggy python submission (verdict: Time Limit Exceeded):
def cmb(a, b, m=998244353):
    if (b > a - b):
        return cmb(a, a - b, m)
    c = d = 1
    for i in range(b):
        c *= (a - i)
        d *= (b - i)
        c %= m
        d %= m
    return c * pow(d, m - 2, m) % m


def resolve():
    n, m, k = map(int, input().split())
    mod = 998244353
    ans = 0
    for i in range(k + 1):
        ans += cmb(n - 1, i) * pow(m - 1, n - i - 1, mod)
    ans %= mod
    ans *= m
    ans %= mod
    print(ans)


if __name__ == '__main__':
    resolve()


Fixed submission:
class Combination:

    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * \
                modinv[self.mod % i] % self.mod
        return modinv


def resolve():
    n, m, k = map(int, input().split())
    mod = 998244353
    c = Combination(n, mod)
    ans = 0
    for i in range(k + 1):
        ans += c(n - 1, i) * pow(m - 1, n - i - 1, mod)
    ans %= mod
    ans *= m
    ans %= mod
    print(ans)


if __name__ == '__main__':
    resolve()
Buggy python submission (verdict: Runtime Error):
def resolve():
    n, m, q = map(int, input().split())
    queue = []
    for i in range(q):
        queue.append(list(map(int, input().split())))
    ans = 0
    import itertools
    l = list(itertools.combinations(range(1, n + m), m))
    for i in l:
        a = [x - y for y, x in enumerate(i)]
        x = 0
        for j in queue:
            if a[j[1] - 1] - a[j[0] - 1] == j[2]:
                x += j[3]
        ans = max(ans, x)
    print(ans)


if __name__ == '__main__':
    resolve()


Fixed submission:
def resolve():
    n, m, q = map(int, input().split())
    queue = []
    for i in range(q):
        queue.append(list(map(int, input().split())))
    ans = 0
    import itertools
    l = itertools.combinations(range(1, n + m), n)
    for i in l:
        a = [x - y for y, x in enumerate(i)]
        x = 0
        for j in queue:
            if a[j[1] - 1] - a[j[0] - 1] == j[2]:
                x += j[3]
        ans = max(ans, x)
    print(ans)


if __name__ == '__main__':
    resolve()

Buggy python submission (verdict: Runtime Error):
def resolve():
    n, m, q = map(int, input().split())
    queue = []
    for i in range(q):
        queue.append(list(map(int, input().split())))
    ans = 0
    import itertools
    l = list(itertools.combinations(range(1, n + m), m))
    for i in l:
        a = [x - y for y, x in enumerate(i)]
        x = 0
        for j in queue:
            if a[j[1] - 1] - a[j[0] - 1] == j[2]:
                x += j[3]
        ans = max(ans, x)
    print(ans)


if __name__ == '__main__':
    resolve()


Fixed submission:
def resolve():
    n, m, q = map(int, input().split())
    queue = []
    for i in range(q):
        queue.append(list(map(int, input().split())))
    ans = 0
    import itertools
    l = itertools.combinations(range(1, n + m), n)
    for i in l:
        a = [x - y for y, x in enumerate(i)]
        x = 0
        for j in queue:
            if a[j[1] - 1] - a[j[0] - 1] == j[2]:
                x += j[3]
        ans = max(ans, x)
    print(ans)


if __name__ == '__main__':
    resolve()
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    from collections import defaultdict
    s = input()
    n = len(s)
    d = defaultdict(int)
    d[0] += 1
    for i in range(1, n + 1):
        d[int(s[-i:]) % 2019] += 1

    def calc(x): return x * (x - 1) // 2
    ans = 0
    for v in d.values():
        ans += calc(v)
    print(ans)


if __name__ == '__main__':
    resolve()


Fixed submission:
def resolve():
    from collections import defaultdict
    s = input()
    n = len(s)
    d = defaultdict(int)
    d[0] += 1
    j = 0
    for i in range(1, n + 1):
        j += int(s[-i]) * pow(10, i - 1, 2019)
        j %= 2019
        d[j] += 1

    def calc(x): return x * (x - 1) // 2
    ans = 0
    for v in d.values():
        ans += calc(v)
    print(ans)


if __name__ == '__main__':
    resolve()
Buggy python submission (verdict: Runtime Error):
print("YNeos"[len(set(input())>1)::2])

Fixed submission:
print("YNeos"[len(set(input()))<2::2])
Buggy python submission (verdict: Runtime Error):
n,a,b=map(int,input().split());a+b=c;print(n//c+n%c)

Fixed submission:
n,a,b=map(int,input().split());c=a+b;print((n//c)*a+min(n%c,a))

Buggy python submission (verdict: Runtime Error):
n,a,b=map(int,input().split());a+b=c;print(n//c+max(n%c-a,0))

Fixed submission:
n,a,b=map(int,input().split());c=a+b;print((n//c)*a+min(n%c,a))
Buggy python submission (verdict: Runtime Error):
def resolve():
    n, m = map(int, input().split())
    d = {}
    for i in range(m):
        a, b = map(int, input().split())
        if a in d and b != d[a]:
            print(-1)
            return
        d[a] = b
    if n > 1 and d[min(d)] == 0:
        print(-1)
        return
    ans = ""
    for i in range(n):
        ans += str(d[i + 1]) if i + 1 in d else "0"
    print(int(ans))


if __name__ == '__main__':
    resolve()


Fixed submission:
def resolve():
    n, m = map(int, input().split())
    ans = [-1] * n
    for _ in range(m):
        s, c = map(int, input().split())
        if ans[s - 1] not in (-1, c):
            print(-1)
            return
        ans[s - 1] = c
    if ans[0] == 0 and n != 1:
        print(-1)
        return
    if ans[0] == -1 and n != 1:
        ans[0] = 1
    print("".join([str(x) if x > 0 else "0" for x in ans]))


if __name__ == '__main__':
    resolve()
Buggy python submission (verdict: Time Limit Exceeded):
def framod(n, mod, a=1):
    for i in range(1, n + 1):
        a = a * i % mod
    return a


def power(n, r, mod):
    if r == 0:
        return 1
    if r % 2 == 0:
        return power(n * n % mod, r // 2, mod) % mod
    if r % 2 == 1:
        return n * power(n, r - 1, mod) % mod


def cmb(n, k, mod=10**9+7):
    a = framod(n, mod)
    b = framod(k, mod)
    c = framod(n - k, mod)
    return (a * power(b, mod - 2, mod) * power(c, mod - 2, mod)) % mod


def modpow(n, m, p):
    if p == 0:
        return 1
    if p % 2 == 0:
        return (modpow(n, m, p//2)**2) % m
    return (modpow(n, m, p-1)*n) % m


def resolve():
    n, a, b = map(int, input().split())
    mod = 10 ** 9 + 7
    ans = modpow(2, mod, n) - 1
    ans -= cmb(n, a)
    ans -= cmb(n, b)
    print(ans % mod)


if __name__ == '__main__':
    resolve()


Fixed submission:
def comb(a, b, p=10 ** 9 + 7):
    if (b > a - b):
        return comb(a, a - b, p)
    c = d = 1
    for i in range(b):
        c *= (a - i)
        d *= (b - i)
        c %= p
        d %= p
    return c * modpow(d, p - 2, p) % p


def modpow(n, p, m=10 ** 9 + 7):
    if p == 0:
        return 1
    if p % 2 == 0:
        return (modpow(n, p // 2, m) ** 2) % m
    return (modpow(n, p - 1, m) * n) % m


def resolve():
    n, a, b = map(int, input().split())
    mod = 10 ** 9 + 7
    ans = modpow(2, n) - 1
    ans -= comb(n, a)
    ans -= comb(n, b)
    print(ans % mod)


if __name__ == '__main__':
    resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def framod(n, mod, a=1):
    for i in range(1, n + 1):
        a = a * i % mod
    return a


def power(n, r, mod):
    if r == 0:
        return 1
    if r % 2 == 0:
        return power(n * n % mod, r // 2, mod) % mod
    if r % 2 == 1:
        return n * power(n, r - 1, mod) % mod


def cmb(n, k, mod=10**9+7):
    a = framod(n, mod)
    b = framod(k, mod)
    c = framod(n - k, mod)
    return (a * power(b, mod - 2, mod) * power(c, mod - 2, mod)) % mod


def modpow(n, m, p):
    if p == 0:
        return 1
    if p % 2 == 0:
        return (modpow(n, m, p//2)**2) % m
    return (modpow(n, m, p-1)*n) % m


def resolve():
    n, a, b = map(int, input().split())
    mod = 10 ** 9 + 7
    n %= mod
    ans = modpow(2, mod, n) - 1
    ans -= cmb(n, a)
    ans -= cmb(n, b)
    print(ans)


if __name__ == '__main__':
    resolve()


Fixed submission:
def comb(a, b, p=10 ** 9 + 7):
    if (b > a - b):
        return comb(a, a - b, p)
    c = d = 1
    for i in range(b):
        c *= (a - i)
        d *= (b - i)
        c %= p
        d %= p
    return c * modpow(d, p - 2, p) % p


def modpow(n, p, m=10 ** 9 + 7):
    if p == 0:
        return 1
    if p % 2 == 0:
        return (modpow(n, p // 2, m) ** 2) % m
    return (modpow(n, p - 1, m) * n) % m


def resolve():
    n, a, b = map(int, input().split())
    mod = 10 ** 9 + 7
    ans = modpow(2, n) - 1
    ans -= comb(n, a)
    ans -= comb(n, b)
    print(ans % mod)


if __name__ == '__main__':
    resolve()
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    h, n = map(int, input().split())
    w = []
    v = []
    for i in range(n):
        a, b = map(int, input().split())
        w.append(a)
        v.append(b)
    dp = [[0 for i in range(h + 1)] for j in range(n + 1)]
    for i in range(1, h + 1):
        dp[0][i] = float("inf")
    for i in range(n):
        for j in range(h + 1):
            if j >= w[i]:
                dp[i + 1][j] = min(dp[i + 1][j - w[i]] + v[i], dp[i][j])
            else:
                dp[i + 1][j] = min(dp[i][j], v[i])
    print(dp[n][h])


if __name__ == '__main__':
    resolve()


Fixed submission:
def resolve():
    h, n = map(int, input().split())
    w = []
    v = []
    for i in range(n):
        a, b = map(int, input().split())
        w.append(a)
        v.append(b)
    dp = [[0 for i in range(h + 1)] for j in range(n + 1)]
    for i in range(1, h + 1):
        dp[0][i] = float("inf")
    for i in range(n):
        for j in range(h + 1):
            if j >= w[i]:
                dp[i + 1][j] = min(dp[i + 1][j - w[i]] + v[i], dp[i][j])
            else:
                dp[i + 1][j] = min(dp[i][j], v[i])
    # print(dp[n])
    print(dp[n][h])


if __name__ == '__main__':
    resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    h, n = map(int, input().split())
    w = []
    v = []
    for i in range(n):
        a, b = map(int, input().split())
        w.append(a)
        v.append(b)
    dp = [[0 for i in range(h + 1)] for j in range(n + 1)]
    for i in range(1, h + 1):
        # dp[0][i] = v[0] * ((w[0]+i-1)//w[0])
        dp[0][i] = float("inf")
    for i in range(n):
        # print(dp[i])
        # print(dp[i][::-1][::w[i]]+[0])
        for j in range(h + 1):
            if j >= w[i]:
                dp[i + 1][j] = min([x + y * v[i]
                                    for y, x in enumerate(dp[i][:j+1][::-1][::w[i]]+[0])])
            else:
                dp[i + 1][j] = min(dp[i][j], v[i])
    # print(dp[n])
    print(dp[n][h])


if __name__ == '__main__':
    resolve()


Fixed submission:
def resolve():
    h, n = map(int, input().split())
    w = []
    v = []
    for i in range(n):
        a, b = map(int, input().split())
        w.append(a)
        v.append(b)
    dp = [[0 for i in range(h + 1)] for j in range(n + 1)]
    for i in range(1, h + 1):
        dp[0][i] = float("inf")
    for i in range(n):
        for j in range(h + 1):
            if j >= w[i]:
                dp[i + 1][j] = min(dp[i + 1][j - w[i]] + v[i], dp[i][j])
            else:
                dp[i + 1][j] = min(dp[i][j], v[i])
    # print(dp[n])
    print(dp[n][h])


if __name__ == '__main__':
    resolve()
Buggy python submission (verdict: Runtime Error):
def miller_rabin(n, k=100):
    import random
    if n == 2:
        return True
    if n == 1 or n & 1 == 0:
        return False
    d = (n - 1) >> 1
    while d & 1 == 0:
        d >>= 1
    for _ in range(k):
        a = random.randint(1, n - 1)
        t = d
        y = pow(a, t, n)
        while t != n - 1 and y != 1 and y != n - 1:
            y = (y * y) % n
            t <<= 1
        if y != n - 1 and t & 1 == 0:
            return False
    return True
def main():
  x=int(input())
  for i in range(x,1000000):
    if miller_rabin(i):
      print(i)
      return
main()

Fixed submission:
print("".join(input().split()[::-1]))
Buggy python submission (verdict: Runtime Error):
def miller_rabin(n, k=-1):
    import random
    if n == 2:
        return True
    if n == 1 or n & 1 == 0:
        return False
    if k < 1:
        k = min(n - 1, 100)
    d = (n - 1) >> 1
    while d & 1 == 0:
        d >>= 1
    for a in random.sample(range(n), k):
        t = d
        y = pow(a, t, n)
        while t != n - 1 and y != 1 and y != n - 1:
            y = (y * y) % n
            t <<= 1
        if y != n - 1 and t & 1 == 0:
            return False
    return True
def main():
  x=int(input())
  for i in range(n+1,1000000):
    if miller_rabin(i):
      print(i)
      return
main()

Fixed submission:
def is_prime(n):
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return False
    return True
n=int(input())
while not is_prime(n):
  n+=1
print(n)

Buggy python submission (verdict: Runtime Error):
def get_sieve_of_eratosthenes(n):
    prime = [2]
    limit = int(n ** 0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
print(get_sieve_of_eratosthenes(int(input())[-1])

Fixed submission:
def is_prime(n):
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return False
    return True
n=int(input())
while not is_prime(n):
  n+=1
print(n)
Buggy python submission (verdict: Runtime Error):
n,k=map(int, input().split())
r,s,p=map(int, input().split())
t=input()
ans=0
for i in range(k):
  u=s[i::k]
  u=u.replace("rr", "rx")
  u=u.replace("pp", "px")
  u=u.replace("ss", "sx")
  ans+=u.count("s")*r
  ans+=u.count("p")*s
  ans+=u.count("r")*p
print(ans)

Fixed submission:
n,k=map(int, input().split())
r,s,p=map(int, input().split())
t=input()
ans=0
for i in range(k):
  u=t[i::k]
  u=u.replace("rr", "rx")
  u=u.replace("pp", "px")
  u=u.replace("ss", "sx")
  ans+=u.count("s")*r
  ans+=u.count("p")*s
  ans+=u.count("r")*p
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split());print(6-a-b)

Fixed submission:
print(6-int(input())-int(input()))
Buggy python submission (verdict: Runtime Error):
_,a _,b=map(int,open(0).read().split());print(1*(a+1==b))

Fixed submission:
_,a,_,b=map(int,open(0).read().split());print(1*(a+1!=b))
Buggy python submission (verdict: Runtime Error):
n=int(input())
d=list(map(int,input().split()))
s=sum(d)
print(sum([x*(d-x) for x in d])//2)

Fixed submission:
from itertools import combinations
_=input()
d=list(map(int,input().split()))
print(sum([i*j for (i,j) in combinations(d,2)]))
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n,m=map(int,input().split())
l=[[] for _ in range(m)]
for _ in range(n):
  a,b=map(int,input().split())
  if a<=m:
    l[a-1].append(b)
ans=0
w=[]
for i in range(m):
  for j in l[i]:
    bisect.insort_right(w,j)
  if w!=[]:
    ans+=w.pop(-1)
print(ans)

Fixed submission:
import heapq
n,m=map(int,input().split())
l=[[] for _ in range(m)]
for _ in range(n):
  a,b=map(int,input().split())
  if a<=m:
    l[a-1].append(b)
ans=0
w=[]
for i in range(m):
  for j in l[i]:
    heapq.heappush(w,-j)
  if w!=[]:
    ans-=heapq.heappop(w)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n,m=map(int,input().split())
l=[[] for _ in range(m)]
for _ in range(n):
  a,b=map(int,input().split())
  if a<=m:
    l[a-1].append(b)
ans=0
w=[]
for i in range(m):
  for j in l[i]:
    bisect.insort_right(w,j)
  if w!=[]:
    ans+=w.pop(-1)
print(ans)

Fixed submission:
import heapq
n,m=map(int,input().split())
l=[[] for _ in range(m)]
for _ in range(n):
  a,b=map(int,input().split())
  if a<=m:
    l[a-1].append(b)
ans=0
w=[]
for i in range(m):
  for j in l[i]:
    heapq.heappush(w,-j)
  if w!=[]:
    ans-=heapq.heappop(w)
print(ans)
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))
countBound = 0
coordinate = 0
# print(l)

while countBound <= n + 1:
    coordinate += l[countBound]
    countBound += 1
    if coordinate > x:
        break
    else:
        continue

print(countBound)


Fixed submission:
def bound(n, x, l):
    coordinate = 0
    for i in range(n):
        coordinate += l[i]
        if x < coordinate:
            return i
        else:
            continue
    return n


n, x = map(int, input().split())
l = list(map(int, input().split()))
countbound = bound(n, x, l)
print(countbound+1)

Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))
countBound = 0
coordinate = 0
# print(l)

while countBound <= n + 1:
    coordinate += l[countBound]
    countBound += 1
    if coordinate > x:
        break
    else:
        continue

print(countBound)


Fixed submission:
def bound(n, x, l):
    coordinate = 0
    for i in range(n):
        coordinate += l[i]
        if x < coordinate:
            return i
        else:
            continue
    return n


n, x = map(int, input().split())
l = list(map(int, input().split()))
countbound = bound(n, x, l)
print(countbound+1)
Buggy python submission (verdict: Runtime Error):
w, h, x, y = map(int, input().split())
print((x * y) / 2, 1 if [x, y]=[w / 2, h / 2] else 0)

Fixed submission:
w, h, x, y = map(int, input().split())
print((w * h) / 2, 1 if [x * 2, y * 2] == [w, h] else 0)
Buggy python submission (verdict: Runtime Error):
import re;print(len(max(re.findall(r"[ACGT]+",input()),key=len)))

Fixed submission:
import re;print(max(map(len,re.split("[^ACGT]+",input()))))
Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input()
a=[s[i:i+2]=="AC" for i in range(n-1)]
for i in range(q):
  l,r=map(int,input().split())
  print(sum([x for x in a[l-1:r-1]]))

Fixed submission:
n,q=map(int,input().split())
s=input()
a=[0 for _ in range(n)]
for i in range(n-1):
  a[i+1]=a[i]+(1 if s[i:i+2]=="AC" else 0)
for i in range(q):
  l,r=map(int,input().split())
  print(a[r-1]-a[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input()
a=[i for i in range(n-1) if s[i:i+2]=="AC"]
for i in range(q):
  l,r=map(int,input().split())
  print(len([x for x in a if l-1<=x<r-1]))

Fixed submission:
n,q=map(int,input().split())
s=input()
a=[0 for _ in range(n)]
for i in range(n-1):
  a[i+1]=a[i]+(1 if s[i:i+2]=="AC" else 0)
for i in range(q):
  l,r=map(int,input().split())
  print(a[r-1]-a[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
ans = 0
while "0" in s and "1" in s:
  ans += s.count("10")
  s = s.replace("10", "")
  ans += s.count("01")
  s = s.replace("01", "")
print(ans*2)


Fixed submission:
s=input();print(min(s.count("0"),s.count("1"))*2)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
ans = 0
while "0" in s and "1" in s:
  ans += s.count("10")
  s = s.replace("10", "")
  ans += s.count("01")
  s = s.replace("01", "")
print(ans*2)


Fixed submission:
s=input();print(min(s.count("0"),s.count("1"))*2)
Buggy python submission (verdict: Runtime Error):
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def gcdl(l):
    from functools import reduce
    reduce(lambda x, y: gcd(x, y), a)
n=input()
print(gcdl(list(map(int,input().split()))))

Fixed submission:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def gcdl(l):
    from functools import reduce
    return reduce(lambda x, y: gcd(x, y), l)
n=input()
print(gcdl(list(map(int,input().split()))))
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [0] * n
    dp[0] = 0
    dp[1] = abs(h[1] - h[0])
    for i in range(2, n):
        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1])
        for j in range(2, min(i + 1, k + 1)):
            dp[i] = min(dp[i - j] + abs(h[i] - h[i - j]), dp[i])
    print(dp[n - 1])


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [0] * n
    dp[0] = 0
    dp[1] = abs(h[1] - h[0])
    for i in range(2, n):
        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1])
        for j in range(2, min(i + 1, k + 1)):
            dp[i] = min(dp[i - j] + abs(h[i] - h[i - j]), dp[i])
    print(dp[n - 1])


if __name__ == '__main__':
    main()