Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
s = input()
a = [-1 for i in range(len(s)+1)]
for i in range(len(s)-1):
    if s[i] == '>' and s[i+1] == "<":
        a[i+1] = 0
if s[0] == "<":
    a[0] = 0
if s[-1] == ">":
    a[-1] = 0
def plus(i):
    j = i - 1
    while s[j] == '>':
        a[j] = max(a[j+1] + 1, a[j])
        j -= 1
        if j < 0:
            break
    j = i
    while s[j] == '<':
        a[j+1] = max(a[j] + 1, a[j+1])
        j += 1
        if  j == len(a) - 1:
            break
for i in range(len(a)):
    if a[i] == 0:
        plus(i)
print(sum(a))


Fixed submission:
s = input()
a = [-1 for i in range(len(s)+1)]
for i in range(len(s)-1):
    if s[i] == '>' and s[i+1] == "<":
        a[i+1] = 0
if s[0] == "<":
    a[0] = 0
if s[-1] == ">":
    a[-1] = 0
def plus(i):
    j = i -1
    while j >= 0 and s[j] == '>':
        a[j] = max(a[j+1] + 1, a[j])
        j -= 1
    j = i
    if j == len(a) -1:
        return
    while s[j] == '<':
        a[j+1] = max(a[j] + 1, a[j+1])
        j += 1
        if  j == len(a) - 1:
            break
for i in range(len(a)):
    if a[i] == 0:
        plus(i)
print(sum(a))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
l = list(map(int, input().split()))
memo = [[0] for i in range(n)]
for j in range(n):
    c = Counter(l[j:])
    tmp = 0
    for i in range(1000):
        if c[i+1]:
            tmp  += c[i+1]
        memo[j].append(tmp)

ans = 0
for i in range(n):
    for j in range(i+1, n - 1):
        b = l[i]
        c = l[j]
        lo = abs(b - c)
        up = min(b + c, 1001)
        ans += memo[j+1][up-1] - memo[j+1][lo]
print(ans)


Fixed submission:
from collections import Counter
n = int(input())
l = list(map(int, input().split()))
memo = [[0] for i in range(n)]
for j in range(n):
    c = Counter(l[j:])
    tmp = 0
    for i in range(1000):
        if c[i+1]:
            tmp  += c[i+1]
        memo[j].append(tmp)

ans = 0
for i in range(n):
    for j in range(i+1, n - 1):
        b = l[i]
        c = l[j]
        lo = abs(b - c)
        up = min(b + c, 1001)
        ans += memo[j+1][up-1] - memo[j+1][lo]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
k = []
for _ in range(m):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))
    k.append((a, sum([2 ** (i-1) for i in c])))

C = 2 ** n
INF = 10 ** 6

dp = [[INF for _ in range(C)] for __ in range(m + 1)]
for i in range(m+1):
    dp[i][0] = 0

for i, ki in enumerate(k):
    for j in range(C):
        dp[i+1][j] = dp[i][j]
    for j in range(C):
        dp[i+1][j | ki[1]] = min(dp[i+1][j | ki[1]], dp[i][j] + ki[0])

ans = dp[m][C-1]
if ans == INF:
    print(-1)
else:
    print(ans)


Fixed submission:
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
k = []
for _ in range(m):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))
    k.append((a, sum([2 ** (i-1) for i in c])))

C = 2 ** n
INF = 10 ** 6

dp = [[INF for _ in range(C)] for __ in range(m + 1)]
for i in range(m+1):
    dp[i][0] = 0

for i, ki in enumerate(k):
    for j in range(C):
        dp[i+1][j] = dp[i][j]
    for j in range(C):
        dp[i+1][j | ki[1]] = min(dp[i+1][j | ki[1]], dp[i][j] + ki[0])

ans = dp[m][C-1]
if ans == INF:
    print(-1)
else:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
k = []
for _ in range(m):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))
    k.append((a, sum([2 ** (i-1) for i in c])))

C = 2 ** n
INF = 10 ** 6

dp = [[INF for _ in range(C)] for __ in range(m + 1)]
for i in range(m+1):
    dp[i][0] = 0

for i, ki in enumerate(k):
    for j in range(C):
        dp[i+1][j] = dp[i][j]
    for j in range(C):
        dp[i+1][j | k[i][1]] = min(dp[i+1][j | k[i][1]], dp[i][j] + k[i][0])

ans = dp[m][C-1]
if ans == INF:
    print(-1)
else:
    print(ans)


Fixed submission:
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
k = []
for _ in range(m):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))
    k.append((a, sum([2 ** (i-1) for i in c])))

C = 2 ** n
INF = 10 ** 6

dp = [[INF for _ in range(C)] for __ in range(m + 1)]
for i in range(m+1):
    dp[i][0] = 0

for i, ki in enumerate(k):
    for j in range(C):
        dp[i+1][j] = dp[i][j]
    for j in range(C):
        dp[i+1][j | ki[1]] = min(dp[i+1][j | ki[1]], dp[i][j] + ki[0])

ans = dp[m][C-1]
if ans == INF:
    print(-1)
else:
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
dp = [[0 for i in range(n+1)] for j in range(n+1)]
ans = 0
for i in range(n):
  for j in range(n):
    if i == j:
      break
    if s[i] == s[j]:
      t = dp[i][j]
      if j == i-t:
        dp[i+1][j+1]=1
      else:
        dp[i+1][j+1]=1+t
        ans = max(ans, 1+t)

print(ans)


Fixed submission:
n = int(input())
s = input()
dp = [[0 for i in range(n+1)] for j in range(n+1)]
ans = 0
for i in range(n):
  for j in range(n):
    if i == j:
      break
    if s[i] == s[j]:
      t = dp[i][j]
      if j == i-t:
        dp[i+1][j+1]=1
      else:
        dp[i+1][j+1]=1+t
        ans = max(ans, 1+t)

print(ans)
Buggy python submission (verdict: Runtime Error):
k, x = map(int, input().split())
print(' '.join([x for x in range(x - k + 1, x + k)]))


Fixed submission:
k, x = map(int, input().split())
print(' '.join([str(i) for i in range(x - k + 1, x + k)]))

Buggy python submission (verdict: Runtime Error):
k, x = map(int, input().split())
print(' '.join([x in range(x - k + 1, x + k)]))

Fixed submission:
k, x = map(int, input().split())
print(' '.join([str(i) for i in range(x - k + 1, x + k)]))
Buggy python submission (verdict: Runtime Error):
n = int(input())
d = {}
for _ in range(n):
  s = input()
  k = set(list(s))
  if k in d:
    d[k] += 1
  else:
    d[k] = 1
ans = 0
for k in d:
  n = d[k]
  ans += n * (n - 1) / 2
print(ans)

Fixed submission:
n = int(input())
d = {}
for _ in range(n):
  s = input()
  k = tuple(sorted(list(s)))
  if k in d:
    d[k] += 1
  else:
    d[k] = 1
ans = 0
for k in d:
  n = d[k]
  ans += n * (n - 1) // 2
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
s = s.replace("RL", "*")
i = 0
rls = []
n = 0
m = 0
for c in s:
  if c == "R":
    n += 1
  if c == "*":
    r = (n + 1) // 2
    l = n + 1 - r
    rls.append([l, r])
    n = 0
m = 0
i = 1
for c in reversed(s):
  if c == "L":
    m += 1
  if c == "*":
    l = (m + 1) // 2
    r = m + 1 - l
    rls[-i][0] += l
    rls[-i][1] += r
    i += 1
    m = 0
ans = []
i = 0
for c in s:
  if c == "*":
    ans = ans.extend(rls[i])
    i += 1
  else:
    ans.append(0)
print(" ".join([str(c) for c in ans]))


Fixed submission:
s = input()
s = s.replace("RL", "*")
i = 0
rls = []
n = 0
m = 0
for c in s:
  if c == "R":
    n += 1
  if c == "*":
    r = (n + 1) // 2
    l = n + 1 - r
    rls.append([l, r])
    n = 0
m = 0
i = 1
for c in reversed(s):
  if c == "L":
    m += 1
  if c == "*":
    l = (m + 1) // 2
    r = m + 1 - l
    rls[-i][0] += l
    rls[-i][1] += r
    i += 1
    m = 0
ans = []
i = 0
for c in s:
  if c == "*":
    ans.extend(rls[i])
    i += 1
  else:
    ans.append(0)
print(" ".join([str(c) for c in ans]))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
s = s.replace("RL", "*")
i = 0
rls = []
n = 0
m = 0
for c in s:
  if c == "R":
    n += 1
  if c == "*":
    r = (n + 1) // 2
    l = n + 1 - r
    rls.append([l, r])
    n = 0
m = 0
i = 1
for c in reversed(s):
  if c == "L":
    m += 1
  if c == "*":
    l = (m + 1) // 2
    r = m + 1 - l
    rls[-i][0] += l
    rls[-i][1] += r
    i += 1
    m = 0
ans = []
i = 0
for c in s:
  if c == "*":
    ans = ans + rls[i]
    i += 1
  else:
    ans.append(0)
print(" ".join([str(c) for c in ans]))

Fixed submission:
s = input()
s = s.replace("RL", "*")
i = 0
rls = []
n = 0
m = 0
for c in s:
  if c == "R":
    n += 1
  if c == "*":
    r = (n + 1) // 2
    l = n + 1 - r
    rls.append([l, r])
    n = 0
m = 0
i = 1
for c in reversed(s):
  if c == "L":
    m += 1
  if c == "*":
    l = (m + 1) // 2
    r = m + 1 - l
    rls[-i][0] += l
    rls[-i][1] += r
    i += 1
    m = 0
ans = []
i = 0
for c in s:
  if c == "*":
    ans.extend(rls[i])
    i += 1
  else:
    ans.append(0)
print(" ".join([str(c) for c in ans]))
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
for i in range(max(a) + k +1):
  s = [x % i for x in a]
  if sum(s) % i == 0:
    print(i)
    break
    


Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))

# 約数列挙
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

ans = 1

for div in make_divisors(sum(a)):
    mod_div = []
    for ai in a:
        mod_div.append(ai % div)
    mod_div.sort()

    tmp_p = n * div - sum(mod_div)
    tmp_m = 0

    for i, x in enumerate(mod_div):
        tmp_m += x
        tmp_p -= div - x
        if tmp_m == tmp_p and tmp_m <= k:
            ans = max(div, ans)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n = int(input())
a = [int(input()) for _ in range(n)]
memo = []
ans = 0
for ai in a:
    if not memo or memo[-1] >= ai:
        memo.append(ai)
    else:
        for i in range(len(memo)):
            if memo[i] < ai:
                memo[i] = ai
                break
print(len(memo))


Fixed submission:
import sys
input = sys.stdin.readline
n = int(input())
a = [int(input()) for _ in range(n)]
memo = []
ans = 0

def reverse_binary_serch(target, query):
    l = 0
    r = len(target) - 1
    while True:
        if r - l < 2:
            if target[l] < query:
                return l
            else:
                return r
        i = (l + r) // 2
        if target[i] >= query:
            l = i
        else:
            r = i

for ai in a:
    if not memo or memo[-1] >= ai:
        memo.append(ai)
    else:
        index = reverse_binary_serch(memo, ai)
        memo[index] = ai

print(len(memo))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
d = {i+1 : [] for i  in range(n)}
for _ in range(m):
    u, v = map(int, input().split())
    d[u].append(v)
s, t = map(int, input().split())
q = set([s])
visited = set([s])
c = 1
def solve():
    global visited, c, q
    while True:
        for v in list(q):
            q.remove(v)
            es =set([e3 for e1 in d[v] for e2 in d[e1] for e3 in d[e2] if not e3 in visited])
            if t in es:
                return c
            else:
                visited |= es
                q |= es
        if not len(q):
            return -1
        c += 1
print(solve())


Fixed submission:
n, k = map(int, input().split())
N = 10 ** 9 + 7

def kai(a):
    res = 1
    for i in range(1, a+1):
        res = res * i
    return res

def cmb(n, r):
    return kai(n) // kai(r) // kai(n-r)
#
# for i in range(1, k + 1):
#     nao = cmb(k - 1, i - 1)
#     nak = cmb(n - k + 1,  i)
#     print(nao * nak % N)

ans = 0
for i in range(1, k+1):
    if i == 1:
        ans = cmb(k - 1, i - 1) * cmb(n - k + 1,  i)
    print(ans  % N)
    ans = ans * (k - i) // i * (n - k - i + 1) // (i + 1)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
N = 10 ** 9 + 7

def kai(a):
    res = 1
    for i in range(1, a+1):
        res = res * i
    return res

def cmb(n, r):
    return kai(n) // kai(r) // kai(n-r)

for i in range(1, k + 1):
    # print(i)
    sao = i - 1
    sak = i
    nao = cmb(k - 1, sao)
    nak = cmb(n - k + 1,  sak)
    # print(nao, nak)
    print(nao * nak % N)


Fixed submission:
n, k = map(int, input().split())
N = 10 ** 9 + 7

def kai(a):
    res = 1
    for i in range(1, a+1):
        res = res * i
    return res

def cmb(n, r):
    return kai(n) // kai(r) // kai(n-r)
#
# for i in range(1, k + 1):
#     nao = cmb(k - 1, i - 1)
#     nak = cmb(n - k + 1,  i)
#     print(nao * nak % N)

ans = 0
for i in range(1, k+1):
    if i == 1:
        ans = cmb(k - 1, i - 1) * cmb(n - k + 1,  i)
    print(ans  % N)
    ans = ans * (k - i) // i * (n - k - i + 1) // (i + 1)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
N = 10 ** 9 + 7

def kai(a):
    res = 1
    for i in range(1, a+1):
        res = res * i
    return res

def cmb(n, r):
    return kai(n) // kai(r) // kai(n-r)

for i in range(1, k + 1):
    # print(i)
    sao = i - 1
    sak = i
    nao = cmb(k - 1, sao)
    nak = cmb(n - k + 1,  sak)
    # print(nao, nak)
    print(nao * nak % N)


Fixed submission:
n, k = map(int, input().split())
N = 10 ** 9 + 7

def kai(a):
    res = 1
    for i in range(1, a+1):
        res = res * i
    return res

def cmb(n, r):
    return kai(n) // kai(r) // kai(n-r)
#
# for i in range(1, k + 1):
#     nao = cmb(k - 1, i - 1)
#     nak = cmb(n - k + 1,  i)
#     print(nao * nak % N)

ans = 0
for i in range(1, k+1):
    if i == 1:
        ans = cmb(k - 1, i - 1) * cmb(n - k + 1,  i)
    print(ans  % N)
    ans = ans * (k - i) // i * (n - k - i + 1) // (i + 1)
Buggy python submission (verdict: Runtime Error):
import math
a, b, c, d = map(int, input().split())
ans = b - a + 1
lcm = c * d // math.gcd(c, d)
def calc(d):
    global a, b
    c1 = (a - 1) // d
    c2 = b // d
    return c2 - c1
print(ans - calc(c) - calc(d) + calc(lcm))


Fixed submission:
a, b, c, d = map(int, input().split())
ans = b - a + 1

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

def calc(d):
    global a, b
    c1 = (a - 1) // d
    c2 = b // d
    return c2 - c1

lcm = c * d // gcd(c, d)
print(ans - calc(c) - calc(d) + calc(lcm))
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))
d = 0
i = 0
while True:
    if d > x:
        print(i)
        break
    if i == n + 1:
        print(i)
        break
    d += l[i]
    i += 1


Fixed submission:
n, x = map(int, input().split())
l = [0] + list(map(int, input().split()))
d = 0
i = 0
while True:
    if d > x:
        print(i - 1)
        break
    if i == n + 1:
        print(i)
        break
    i += 1
    d += l[i-1]

Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))
d = 0
i = 0
while True:
    if d > x:
        print(i)
        break
    d += l[i]
    i += 1


Fixed submission:
n, x = map(int, input().split())
l = [0] + list(map(int, input().split()))
d = 0
i = 0
while True:
    if d > x:
        print(i - 1)
        break
    if i == n + 1:
        print(i)
        break
    i += 1
    d += l[i-1]
Buggy python submission (verdict: Runtime Error):
n = int(input())
pos = [list(map(int, input().split())) for _ in range(n)]
d = {}
for x, y in pos:
  for nx, ny in pos:
    dx = nx - x
    dy = ny - y
    key = (dx, dy)
    if key == (0, 0):
      continue
    if key in d:
      d[key] += 1
    else:
      d[key] = 1
print(n - max([d[key] for key in d]))
    


Fixed submission:
n = int(input())
pos = [list(map(int, input().split())) for _ in range(n)]
d = {}
if n == 1:
  print(1)
else:
  for x, y in pos:
    for nx, ny in pos:
      dx = nx - x
      dy = ny - y
      key = (dx, dy)
      if key == (0, 0):
        continue
      if key in d:
        d[key] += 1
      else:
        d[key] = 1
  print(n - max([d[key] for key in d]))
Buggy python submission (verdict: Runtime Error):
n = int(input())
ws = list(map(int, input().split()))
print(min([abs(sum(ws[:i+1]) - sum(ws[i+1:])) for i in range(len(ws - 1))])

Fixed submission:
n = int(input())
ws = list(map(int, input().split()))
print(min([abs(sum(ws[:i+1]) - sum(ws[i+1:])) for i in range(len(ws) - 1)]))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
ans = 0

while True:
    c = s.count("ABC")
    ans += c
    if c == 0:
        print(ans)
        break
    s = s.replace("ABC", "BCA")


Fixed submission:
s = input()
s2 = s.replace("BC", 'D')
ans = 0
na = 0
for c in s2:
  if na:
    if c == "D":
      ans += na
    elif c != "A":
      na = 0
  if c == 'A':
    na += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
ans = 0

while True:
    c = s.count("ABC")
    ans += c
    if c == 0:
        print(ans)
        break
    s = s.replace("ABC", "BCA")


Fixed submission:
s = input()
s2 = s.replace("BC", 'D')
ans = 0
na = 0
for c in s2:
  if na:
    if c == "D":
      ans += na
    elif c != "A":
      na = 0
  if c == 'A':
    na += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
l = 1
r = n
for i in range(m):
  li, ri = map(int, input().split())
  l = max(l, li)
  r = min(r, ri)
print(max(l - r + 1), 0)

Fixed submission:
n, m = map(int, input().split())
l = 1
r = n
for i in range(m):
  li, ri = map(int, input().split())
  l = max(l, li)
  r = min(r, ri)
print(max(r - l + 1, 0))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))
p = [list(map(int, input().split())) for i in range(m)]
cand = sorted(a)
ps =  sorted(p, key = lambda x : x[1], reverse = True)
i = 0
ans = 0
def calc():
    global i
    for b, c in ps:
        for d in range(b):
            if cand[i + d] < c:
                cand[i + d] = c
            else:
                return sum(cand)
        i += b
    return sum(cand)
print(calc())


Fixed submission:
n, m = map(int, input().split())
a = list(map(int, input().split()))
p = [list(map(int, input().split())) for i in range(m)]
cand = sorted(a)
ps =  sorted(p, key = lambda x : x[1], reverse = True)
i = 0
ans = 0
def calc():
    global i
    for b, c in ps:
        for d in range(b):
            if i + d == len(cand):
                return sum(cand)
            if cand[i + d] < c:
                cand[i + d] = c
            else:
                return sum(cand)
        i += b
    return sum(cand)
print(calc())

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = list(map(int, input().split()))
p = [list(map(int, input().split())) for i in range(m)]
cand = sorted(a)
ps = [c for b, c in sorted(p, key = lambda x : x[1], reverse = True) for _ in range(b)]
ans = 0
for candi, psi in zip(cand, ps):
    ans += max(candi, psi)
ans += sum(cand[len(ps):])
print(ans)


Fixed submission:
n, m = map(int, input().split())
a = list(map(int, input().split()))
p = [list(map(int, input().split())) for i in range(m)]
cand = sorted(a)
ps =  sorted(p, key = lambda x : x[1], reverse = True)
i = 0
ans = 0
def calc():
    global i
    for b, c in ps:
        for d in range(b):
            if i + d == len(cand):
                return sum(cand)
            if cand[i + d] < c:
                cand[i + d] = c
            else:
                return sum(cand)
        i += b
    return sum(cand)
print(calc())
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
temp = []
temp2 = []
c = 0
pitem = ''
s2 = s + 'a'
for item in s2:
    if pitem == '' or item == pitem:
        c += 1
        pitem = item
    if item != pitem:
        temp.append(c)
        temp2.append(pitem)
        c = 1
        pitem = item
        continue

# print(temp)
# print(temp2)

ck = [0]
cs = [0]
c = 0
for i in range(len(temp2)):
    if temp2[i] == '#':
        c += temp[i]
    cs.append(c)
c = 0

for i in range(len(temp2))[::-1]:
    if temp2[i] == '.':
        c +=  temp[i]
    ck.insert(0, c)
ck.insert(0, 0)

cost = [cs[i] + ck[i+1] for i in range(len(temp2)+1)]

print(min(cost))


Fixed submission:
n = int(input())
s = input()
temp = []
c = 0
pitem = ''
s2 = '.' + s + 'a'
for item in s2:
    if pitem == '' or item == pitem:
        c += 1
        pitem = item
    if item != pitem:
        temp.append(c)
        c = 1
        pitem = item
        continue

# print(temp)
# print(temp2)

t = s2.count('.')
c = 0
c2 = 0
cs = []
for i in range(len(temp)):
    c2 += temp[i]
    if i % 2 == 1:
        c += temp[i]
    cs.append(c + t - (c2 - c))
print(min(cs))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ck = [0]
cs = [0]
c = 0
for item in s:
    if item != '.':
        c += 1
    cs.append(c)
c = 0
for item in s[::-1]:
    if item != '#':
        c +=  1
    ck.insert(0, c)
ck.insert(0, 0)

temp = [cs[i] + ck[i+1] for i in range(len(s)+1)]

print(min(temp))


Fixed submission:
n = int(input())
s = input()
temp = []
c = 0
pitem = ''
s2 = '.' + s + 'a'
for item in s2:
    if pitem == '' or item == pitem:
        c += 1
        pitem = item
    if item != pitem:
        temp.append(c)
        c = 1
        pitem = item
        continue

# print(temp)
# print(temp2)

t = s2.count('.')
c = 0
c2 = 0
cs = []
for i in range(len(temp)):
    c2 += temp[i]
    if i % 2 == 1:
        c += temp[i]
    cs.append(c + t - (c2 - c))
print(min(cs))
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

ps = [n, 0, 0, 0, 0, 0]
ts = [a, b, c, d, e]
t = 0

def move(ps, t):
    if ps[len(ps)-1] == n:
        return print(t)
    ds = [0, 0, 0, 0, 0, 0]
    for i in range(len(ps) - 1):
        if ps[i] > 0:
            diff = min(ts[i], ps[i])
            ds[i] -= diff
            ds[i + 1] += diff
    move([ps[j] + ds[j]  for j in range(len(ds))], t +1)

move(ps, t)


Fixed submission:
n = int(input())
a = [int(input()) for i in range(5)]
ma = min(a)
s = n // ma
if n % ma:
  s += 1
print(4 + s)
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()

dp = [[0 for column in range(n)] for row in range(n)]
for i in range(n):
    dp[i][0] = 0
    for j in range(i + 1, n):
        if s[j-1] == 'A' and s[j] == 'C':
            dp[i][j] = dp[i][j-1] + 1
        else:
            dp[i][j] = dp[i][j-1]

for _ in range(q):
    i, j =  map(int, input().split())
    print(dp[i-1][j-1])

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

dp = [0 for column in range(n)]

for j in range(1, n):
    if s[j-1] == 'A' and s[j] == 'C':
        dp[j] = dp[j-1] + 1
    else:
        dp[j] = dp[j-1]

for _ in range(q):
    i, j =  map(int, input().split())
    print(dp[j-1] - dp[i-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
for _ in range(q):
  l, r = [int(x) for x in input().split()]
  l -= 1
  print(s[l:r].count('AC'))


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

dp = [0 for column in range(n)]

for j in range(1, n):
    if s[j-1] == 'A' and s[j] == 'C':
        dp[j] = dp[j-1] + 1
    else:
        dp[j] = dp[j-1]

for _ in range(q):
    i, j =  map(int, input().split())
    print(dp[j-1] - dp[i-1])

Buggy python submission (verdict: Runtime Error):
n, q = map(input().split())
s = input()
for _ in range(q):
  l, r = map(input().split())
  print(s[l:r].count('AC'))

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

dp = [0 for column in range(n)]

for j in range(1, n):
    if s[j-1] == 'A' and s[j] == 'C':
        dp[j] = dp[j-1] + 1
    else:
        dp[j] = dp[j-1]

for _ in range(q):
    i, j =  map(int, input().split())
    print(dp[j-1] - dp[i-1])