Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def main():
  ans = [-1, -1, -1]
  N, Y = map(int, input().split())
  for a in range(N+1):
    for b in range(N+1):
      for c in range(N+1):
        if 1000*a + 5000*b + 10000*c == Y and a + b + c == N:
          ans = [c, b, a]
  print(*ans)
if __name__ == "__main__":
  main()


Fixed submission:
def main():
  ans = [-1, -1, -1]
  N, Y = map(int, input().split())
  for i in range(N+1):
    for j in range(N+1-i):
      if 1000*i + 5000*j + 10000*(N-i-j) == Y:
        ans = [N-i-j, j, i]
  print(*ans)
if __name__ == "__main__":
  main()

Buggy python submission (verdict: Runtime Error):
def main():
  ans = [-1, -1, -1]
  N, Y = map(int, input().split())
  for a in range(N+1):
    for b in range(N+1):
      for c in range(N+1):
        if 1000*a + 5000*b + 10000*c == Y and a + b + c = N:
          ans = [a, b, c]
  print(*ans)
if __name__ == "__main__":
  main()
      


Fixed submission:
def main():
  ans = [-1, -1, -1]
  N, Y = map(int, input().split())
  for i in range(N+1):
    for j in range(N+1-i):
      if 1000*i + 5000*j + 10000*(N-i-j) == Y:
        ans = [N-i-j, j, i]
  print(*ans)
if __name__ == "__main__":
  main()
Buggy python submission (verdict: Runtime Error):
3 5
0 4 3 6 2 7 2 5 3 3
4 0 5 3 7 5 3 7 2 7
5 7 0 7 2 9 3 2 9 1
3 6 2 0 2 4 6 4 2 3
3 5 7 4 0 6 9 7 6 7
9 8 5 2 2 0 4 7 6 5
5 4 6 3 2 3 0 5 4 3
3 6 2 3 4 2 4 0 8 9
4 6 5 4 3 5 3 2 0 8
2 1 3 4 5 7 8 6 4 0
3 5 2 6 1
2 5 3 2 1
6 9 2 5 6

Fixed submission:
H, W = map(int, input().split())
cost = []
INF = 10**9
for i in range(10):
  cost.append(list(map(int, input().split())))
for i in range(10):
  cost[i][i] = INF
A = []
for i in range(H):
  A.append(list(map(int, input().split())))

d = [INF]*10
used = [False] *10
V = 10
def shortest_path(start = 1):#隣接行列の場合のダイクストラ法
  d[start] = 0
  while True:
    v = -1
    for u in range(V):
      if (not used[u]) and (v == -1 or d[u] < d[v]):v = u
    if v == -1:break
    used[v] = True
    for u in range(V):
      d[u] = min(d[u], d[v] + cost[u][v])
  
def main():
  shortest_path()
  ans = 0
  for i in range(H):
    for j in range(W):
      if A[i][j] != -1:
        ans += d[A[i][j]]
  print(ans)
if __name__ == "__main__":
  main()
Buggy python submission (verdict: Runtime Error):
def main():
  s = str(input())
  ans = s.replace('?', 'z')
  flag = False
  t = str(input())
  for i in range(len(s)-len(t)+1):
    temp_flag = True
    temp_ans = list(s)
    for j in range(len(t)):
      if s[i + j] == '?':
        temp_ans[i + j] = t[j]
        continue
      elif s[i+j] != t[j]:
        temp_flag = False
    if temp_flag:
      flag = True
      temp_ans = "".join(temp_ans)
      temp_ans = temp_ans.replace('?', 'a')
      ans = min(ans, temp_ans)
  if flag:
    print(ans)
  else:
    print("UNRESTORABLE")
    
if __name__ == "__main__":
  main()
  else:
    print("UNRESTORABLE")
    
if __name__ == "__main__":
  main()
      
        

Fixed submission:
def main():
  s = str(input())
  ans = s.replace('?', 'z')
  flag = False
  t = str(input())
  for i in range(len(s)-len(t)+1):
    temp_flag = True
    temp_ans = list(s)
    for j in range(len(t)):
      if s[i + j] == '?':
        temp_ans[i + j] = t[j]
        continue
      elif s[i+j] != t[j]:
        temp_flag = False
    if temp_flag:
      flag = True
      temp_ans = "".join(temp_ans)
      temp_ans = temp_ans.replace('?', 'a')
      ans = min(ans, temp_ans)
  if flag:
    print(ans)
  else:
    print("UNRESTORABLE")
    
if __name__ == "__main__":
  main()
Buggy python submission (verdict: Runtime Error):
a,b,c=map(str, input().split())
if b=="+":
  print(int(a)+int(b))
else:
  print(int(a)-int(b))


Fixed submission:
a,b,c=map(str, input().split())
if b=="+":
  print(int(a)+int(c))
else:
  print(int(a)-int(c))

Buggy python submission (verdict: Runtime Error):
a,b,c=map(str, input().split())
if b=="+":
  print(int(A)+int(B))
else:
  print(int(A)-int(B))

Fixed submission:
a,b,c=map(str, input().split())
if b=="+":
  print(int(a)+int(c))
else:
  print(int(a)-int(c))
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def solve(N: int):
    n = 0
    for c in range(1, N):
        a = 1
        # print("c",c)
        while a*a < N-c:
            # print("a",a)
            if (N-c) % a == 0:
                n += 2
            a += 1
        if a*a == N-c:
            n += 1
    print(n)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys


def solve(N: int):
    n = 0
    for c in range(1, N):
        if N % c == 0:
            n += N // c - 1
        else:
            n += N // c
    print(n)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
if A == 1 or B == 1:
  print(1)
elif (A*B) % 2 == 0:
  print(A*B//2)
else:
  print(A*B//2+1)

Fixed submission:
A, B = map(int, input().split())
if A == 1 or B == 1:
  print(1)
elif (A*B) % 2 == 0:
  print(A*B//2)
else:
  print(A*B//2+1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = []
for _ in range(N):
  A.append(int(input()))

for i in range(N):
  A_ = A.copy()
  A_[i] = 0
  print(max(A_))

Fixed submission:
N = int(input())
max = 0
max2 = 0
n_max = 0
A = []
for _ in range(N):
  a = int(input())
  A.append(a)
  if a > max:
    max2 = max
    max = a
    n_max = 1
  elif a == max:
    n_max += 1
  elif a > max2:
    max2 = a

for a in A:
  if a == max:
    if n_max == 1:
      print(max2)
    else:
      print(max)
  else:
    print(max)
Buggy python submission (verdict: Runtime Error):
def Fib(n):
  a, b = 1, 1
  if n == 0:
  	return a
  elif n == 1:
    return b
  else:
    for i in range(n-2):
      a, b = b, a + b
    return b

mod = 1000000007
def mul(a, b):
  return ((a % mod) * (b % mod)) % mod

def power(x, y):
  if   y == 0     : return 1
  elif y == 1     : return x % mod
  elif y % 2 == 0 : return power(x, y/2)**2 % mod
  else            : return power(x, y/2)**2 * x % mod

def div(a, b):
  return mul(a, power(b, mod-2))
  
N, M = map(int, input().split())
a = int(input())
ret = mul(1, Fib(a))
pre_a = a

for i in range(M-1):
  a = int(input())
  if a - pre_a <= 1:
    ret = 0
    break
  else:
    num_step = a - pre_a - 1
    ret = mul(ret, Fib(num_step))
  pre_a = a
    
num_step = N - a
ret = mul(ret, Fib(num_step))
print(ret)


Fixed submission:
def Fib(n):
  a, b = 1, 1
  if n == 0:
  	return a
  elif n == 1:
    return b
  else:
    for i in range(n-2):
      a, b = b, a + b
    return b

mod = 1000000007
def mul(a, b):
  return ((a % mod) * (b % mod)) % mod


N, M = map(int, input().split())
if M != 0:
  a = int(input())
  ret = mul(1, Fib(a))
  pre_a = a

for i in range(M-1):
  a = int(input())
  if a - pre_a <= 1:
    ret = 0
    break
  else:
    num_step = a - pre_a - 1
    ret = mul(ret, Fib(num_step))
  pre_a = a
    
if M != 0:
  num_step = N - a
  ret = mul(ret, Fib(num_step))
else:
  ret = mul(1, Fib(N+1))
print(ret)
Buggy python submission (verdict: Runtime Error):
N = int(input())
R = []
for i in range(N):
  l = input().split()
  R.append((l[0], (-1)*int(l[1]), i))

R.sort()
for i in range(N):
  print(R[2]+1)

Fixed submission:
N = int(input())
R = []
for i in range(N):
  l = input().split()
  R.append((l[0], (-1)*int(l[1]), i))

R.sort()
for i in range(N):
  print(R[i][2]+1)
Buggy python submission (verdict: Runtime Error):
from bisect import bisect, bisect_left
N, Q = map(input().split(), int)
S = input()
ac = []
for i in range(N-1):
  if S[i:i+1] == "AC":
    ac.append(i)
for i in range(Q):
  l, r = map(input().split(), int)
  l -= 1
  r -= 1
  print(bisect_right(ac, r-1) - bisect_left(ac, l))
  

Fixed submission:
from bisect import bisect_right, bisect_left
N, Q = map(int, input().split())
S = input()
ac = []
for i in range(N-1):
  if S[i:i+2] == "AC":
    ac.append(i)
for i in range(Q):
  l, r = map(int, input().split())
  l -= 1
  r -= 1
  print(bisect_right(ac, r-1) - bisect_left(ac, l))
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
s = list(input())
q = int(input())

for _ in range(q):
    query = input()
    if query[0] == '1':
        s = s[::-1]
    else:
        _, f, c = query.split()
        if f == '1':
            s.insert(0, c)
        else:
            s.append(c)

print("".join(s))


Fixed submission:
# -*- coding: utf-8 -*-
from collections import deque


s = deque(list(input()))
q = int(input())

reverce = False
for _ in range(q):
    query = input()
    if query[0] == '1':
        reverce = not reverce
    else:
        _, f, c = query.split()
        if (f == '1' and not reverce) or (f == '2' and reverce):
            s.appendleft(c)
        else:
            s.append(c)

if reverce:
    s.reverse()

print("".join(s))

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
s = list(input())
q = int(input())

for _ in range(q):
    query = input()
    if query[0] == '1':
        s = s[::-1]
    else:
        _, f, c = query.split()
        if f == '1':
            s.insert(0, c)
        else:
            s.append(c)

print("".join(s))


Fixed submission:
# -*- coding: utf-8 -*-
from collections import deque


s = deque(list(input()))
q = int(input())

reverce = False
for _ in range(q):
    query = input()
    if query[0] == '1':
        reverce = not reverce
    else:
        _, f, c = query.split()
        if (f == '1' and not reverce) or (f == '2' and reverce):
            s.appendleft(c)
        else:
            s.append(c)

if reverce:
    s.reverse()

print("".join(s))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = int(input())
d = list(map(int, input().split()))

cnt = dict()
for k in d:
    if k in cnt:
        cnt[k] += 1
    else:
        cnt[k] = 1

mod = 998244353

keys = cnt.keys()
pre = -1
rst = 1

if cnt[0] != 1:
    print(0)
    exit(0)

for k in sorted(keys):
    if (pre + 1) != k:
        rst = 0
        break
    pre = k

    if k == 0:
        continue

    rst = (rst * (cnt[k-1] ** cnt[k])) % mod
    
print(rst)


Fixed submission:
# -*- coding: utf-8 -*-
n = int(input())
d = list(map(int, input().split()))

cnt = dict()
for k in d:
    if k in cnt:
        cnt[k] += 1
    else:
        cnt[k] = 1

mod = 998244353

keys = cnt.keys()
pre = -1
rst = 1

if d[0] != 0:
    print(0)
    exit(0)


if cnt[0] != 1:
    print(0)
    exit(0)


for k in sorted(keys):
    if (pre + 1) != k:
        rst = 0
        break
    pre = k

    if k == 0:
        continue

    rst = (rst * (cnt[k-1] ** cnt[k])) % mod
    
print(rst)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = set(table)
    return table


def common_divisor(x, y):
    xd = divisor(x)
    yd = divisor(y)
    return xd & yd


a, b = map(int, input().split())
cd = sorted(list(common_divisor(a, b)))

cnt = 1
div = {1}
for i in cd[1:]:
    i_d = divisor(i)
    if len(div & i_d) == 1:
        cnt += 1
    div |= i_d

print(cnt)


Fixed submission:
# -*- coding: utf-8 -*-
def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = set(table)
    return table


def common_divisor(x, y):
    xd = divisor(x)
    yd = divisor(y)
    return xd & yd


a, b = map(int, input().split())
cd = sorted(list(common_divisor(a, b)))

cnt = 1
div = {1}
for i in cd[1:]:
    i_d = divisor(i)
    if len(div & i_d) == 1:
        cnt += 1
    div |= i_d

print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
n = int(input())
s = input()

max_length = 0

for i in range(1, n-1):
    tmp_len = 0
    for c1, c2 in zip(s[0:n-i:], s[i::]):
        if c1 == c2:
            tmp_len += 1
        else:
            tmp_len = 0

        max_length = max(max_length, tmp_len)
        if tmp_len >= i:
            break

print(max_length)


Fixed submission:
# -*- coding: utf-8 -*-
n = int(input())
s = input()

max_length = 0

for i in range(1, n-1):
    tmp_len = 0
    for c1, c2 in zip(s[0:n-i:], s[i::]):
        if c1 == c2:
            tmp_len += 1
        else:
            tmp_len = 0

        max_length = max(max_length, tmp_len)
        if tmp_len >= i:
            break

print(max_length)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import numpy as np
from numpy.linalg import solve

n = int(input())
a = np.array(list(map(int, input().split())))
a = a*2

x = np.identity(n)
x[::][1:] += x[::][:n-1]
x = x.T
x[n-1][0] += 1

print(" ".join(solve(x, a).astype(np.int64).astype('str')))


Fixed submission:
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))

x = [0 for _ in range(n)]
_x = 0
for i, _a in enumerate(a):
    if i % 2 == 0:
        _x += _a
    else:
        _x -= _a

x[0] = _x

for i in range(1, n):
    x[i] = a[i-1] * 2 - x[i-1]

print(" ".join(map(str, x)))

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import numpy as np
from numpy.linalg import solve

n = int(input())
a = list(map(int, input().split()))
a = np.array([_a * 2 for _a in a])

x = np.zeros((n, n))
for i in range(n-1):
    x[i][i] = 1
    x[i][i+1] = 1
x[n-1][n-1] = 1
x[n-1][0] = 1

print(" ".join(solve(x, a).astype('int').astype('str')))


Fixed submission:
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))

x = [0 for _ in range(n)]
_x = 0
for i, _a in enumerate(a):
    if i % 2 == 0:
        _x += _a
    else:
        _x -= _a

x[0] = _x

for i in range(1, n):
    x[i] = a[i-1] * 2 - x[i-1]

print(" ".join(map(str, x)))

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from numpy.linalg import solve

n = int(input())
a = list(map(int, input().split()))
a = [_a * 2 for _a in a]

x = [[0]*n for _ in range(n)]
for i in range(n-1):
    x[i][i] = 1
    x[i][i+1] = 1
x[n-1][n-1] = 1
x[n-1][0] = 1

print(" ".join(map(str, map(int, list(solve(x, a))))))


Fixed submission:
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))

x = [0 for _ in range(n)]
_x = 0
for i, _a in enumerate(a):
    if i % 2 == 0:
        _x += _a
    else:
        _x -= _a

x[0] = _x

for i in range(1, n):
    x[i] = a[i-1] * 2 - x[i-1]

print(" ".join(map(str, x)))

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
from numpy.linalg import solve

n = int(input())
a = list(map(int, input().split()))
a = [_a * 2 for _a in a]

x = [[0]*n for _ in range(n)]
for i in range(n-1):
    x[i][i] = 1
    x[i][i+1] = 1
x[n-1][n-1] = 1
x[n-1][0] = 1

print(" ".join(map(str, map(int, list(solve(x, a))))))


Fixed submission:
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))

x = [0 for _ in range(n)]
_x = 0
for i, _a in enumerate(a):
    if i % 2 == 0:
        _x += _a
    else:
        _x -= _a

x[0] = _x

for i in range(1, n):
    x[i] = a[i-1] * 2 - x[i-1]

print(" ".join(map(str, x)))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


n, k = map(int, input().split())
red_n = n - k + 1

const = 1000000007

for i in range(1, k+1, 1):
    cnt = cmb(red_n, i) * cmb(k-1, i-1)
    print(cnt % const)


Fixed submission:
# -*- coding: utf-8 -*-
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r < 0: return 0
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


n, k = map(int, input().split())
red_n = n - k + 1

const = 1000000007

for i in range(1, k+1, 1):
    cnt = cmb(red_n, i) * cmb(k-1, i-1)
    print(cnt % const)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
def store_lamp(g, j, v):
    while j >= 0:
        if g[j] is not None:
            break
        g[j] = v
        j -= 1


def store_lamp_h(g, i, j, v):
    while i >= 0:
        if g[i][j] is not None:
            break
        g[i][j] = v
        i -= 1

h, w = map(int, input().split())
s = []

hg = [[None] * w for _ in range(h)]
wg = [[None] * w for _ in range(h)]

for _ in range(h):
    s.append(input())

for i in range(h):
    pre = 0
    for j in range(w):
        if s[i][j] == '#':
            hg[i][j] = 0
            if pre != 0:
                store_lamp(hg[i], j-1, pre)
            pre = 0
        else:
            pre += 1

    if pre != 0:
        store_lamp(hg[i], w-1, pre)

for j in range(w):
    pre = 0
    for i in range(h):
        if s[i][j] == '#':
            wg[i][j] = 0
            if pre != 0:
                store_lamp_h(wg, i-1, j, pre)
            pre = 0
        else:
            pre += 1

    if pre != 0:
        store_lamp_h(wg, h-1, j, pre)

l = 0
for hh, wh in zip(hg, wg):
    for hw, ww in zip(hh, wh):
        l = max(l, hw+ww)

print(l-1)


Fixed submission:
# -*- coding: utf-8 -*-
def store_lamp(g, j, v):
    while j >= 0:
        if g[j] is not None:
            break
        g[j] = v
        j -= 1


def store_lamp_h(g, i, j, v):
    while i >= 0:
        if g[i][j] is not None:
            break
        g[i][j] = v
        i -= 1

h, w = map(int, input().split())
s = []

hg = [[None] * w for _ in range(h)]
wg = [[None] * w for _ in range(h)]

for _ in range(h):
    s.append(input())

for i in range(h):
    pre = 0
    for j in range(w):
        if s[i][j] == '#':
            hg[i][j] = 0
            if pre != 0:
                store_lamp(hg[i], j-1, pre)
            pre = 0
        else:
            pre += 1

    if pre != 0:
        store_lamp(hg[i], w-1, pre)

for j in range(w):
    pre = 0
    for i in range(h):
        if s[i][j] == '#':
            wg[i][j] = 0
            if pre != 0:
                store_lamp_h(wg, i-1, j, pre)
            pre = 0
        else:
            pre += 1

    if pre != 0:
        store_lamp_h(wg, h-1, j, pre)

l = 0
for hh, wh in zip(hg, wg):
    for hw, ww in zip(hh, wh):
        l = max(l, hw+ww)

print(l-1)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math
n, k = map(int, input().split())

prop = 0.0
_prop = 0.0

if n >= k:
    _prop = (n - k) / n

end = min(n, k) + 1
for i in range(1, end):
    dest = k / i
    coin = math.ceil(math.log2(dest))
    __prop = (1 / n) * (1 / pow(2, coin))
    prop += __prop

print(prop + _prop)


Fixed submission:
# -*- coding: utf-8 -*-
import math
n, k = map(int, input().split())

prop = 0.0
_prop = 0.0

if n >= k:
    _prop = (n - k) / n

end = min(n, k) + 1
for i in range(1, end):
    dest = k / i
    coin = math.ceil(math.log2(dest))
    __prop = (1 / n) * (1 / pow(2, coin))
    prop += __prop

print(prop + _prop)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
r, g, b, n = map(int, input().split())

result = 0
for i in range(n+1):
    r_sp = i*r
    if r_sp > n:
        break
    for j in range(n+1):
        g_sp = j*g
        if g_sp > n:
            break

        rg = r_sp + g_sp
        if rg > n:
            break

        if (n-rg) % b == 0:
            result += 1

print(result)


Fixed submission:
# -*- coding: utf-8 -*-
r, g, b, n = map(int, input().split())

result = 0
for i in range(n+1):
    r_sp = i*r
    if r_sp > n:
        break
    for j in range(n+1):
        g_sp = j*g
        if g_sp > n:
            break

        rg = r_sp + g_sp
        if rg > n:
            break

        if (n-rg) % b == 0:
            result += 1

print(result)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
s = input()

hsc = []
pre = s[0]
cnt = 0
for c in s:
    if c == pre:
        cnt += 1
    else:
        if pre == '0':
            hsc.append(-cnt)
        else:
            hsc.append(cnt)
        pre = c
        cnt = 1
if pre == '0':
    hsc.append(-cnt)
else:
    hsc.append(cnt)

max_hsc = []

for i, c in enumerate(hsc):
    cnt = 0
    _k = 0
    for _c in hsc[i:]:
        if _c < 0:
            _k += 1
        if _k > k:
            break
        cnt += abs(_c)
    max_hsc.append(cnt)

print(max(max_hsc))


Fixed submission:
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
s = input()

hsc = []
if s[0] == '0':
    hsc.append(0)
pre = s[0]
cnt = 0
for c in s:
    if c == pre:
        cnt += 1
    else:
        hsc.append(cnt)
        pre = c
        cnt = 1
hsc.append(cnt)

_max = sum(hsc[0:2*k+1])
tmp = _max
r = 2 * k + 1
for i in range(2, n, 2):
    l_sum = sum(hsc[i-2:i])
    r_sum = sum(hsc[r:r+2])
    r += 2
    tmp -= l_sum
    tmp += r_sum
    _max = max(_max, tmp)

print(_max)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

abc = []

for i, _a in enumerate(a):
    for j, _b in enumerate(b):
        if (i+1) * (j+1) > k:
            break
        for l, _c in enumerate(c):
            if (i+1) * (j+1) * (l+1) > k:
                break
            abc.append(_a + _b + _c)

for x in abc.sort(reverse=True)[:k]:
    print(x)


Fixed submission:
# -*- coding: utf-8 -*-
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

bc = [i + j for i in b for j in c]
bc.sort(reverse=True)

abc = [i + j for i in a for j in bc[:min(k, len(bc))]]
abc.sort(reverse=True)

for i in range(k):
    print(abc[i])

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

bc = [i + j for i in b for j in c]
bc.sort(reverse=True)

abc = [i + j for i in a for j in bc[:min(k, len(bc))]]
abc.sort(reverse=True)

for i in range(k):
    print(abc[i])


Fixed submission:
# -*- coding: utf-8 -*-
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

bc = [i + j for i in b for j in c]
bc.sort(reverse=True)

abc = [i + j for i in a for j in bc[:min(k, len(bc))]]
abc.sort(reverse=True)

for i in range(k):
    print(abc[i])
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
n, q = map(int, input().split())
s = input()
lr = [tuple(map(int, input().split())) for _ in range(q)]

for l, r in lr:
    print(s[l-1:r].count('AC'))


Fixed submission:
# -*- coding: utf-8 -*-
n, q = map(int, input().split())
s = input()
lr = [tuple(map(int, input().split())) for _ in range(q)]

cnt = [0 for _ in range(n)]
for i in range(1, n):
    cnt[i] = cnt[i-1]
    cnt[i] += 1 if s[i-1:i+1] == "AC" else 0

for l, r in lr:
    print(cnt[r-1] - cnt[l-1])