Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
i = list(map(int, input().split()))
A = i[0]
B = i[1]
N = i[2]
a = []
for x in range(1, N+1):
  s = A * x // B
  t = A * (x // B)
  a.append(s-t)
b = max(a)
print(b)


Fixed submission:
i = list(map(int, input().split()))
A = i[0]
B = i[1]
N = i[2]
if N < B-1:
    print(A * N // B)
else:
    print(A * (B-1) // B)

Buggy python submission (verdict: Time Limit Exceeded):
i = list(map(int, input().split()))
A = i[0]
B = i[1]
N = i[2]
a = -10 ** 20
for x in range(1, N+1):
  s = A * x // B
  t = A * (x // B)
  if s - t > a:
    a = s - t
print(a)    


Fixed submission:
i = list(map(int, input().split()))
A = i[0]
B = i[1]
N = i[2]
if N < B-1:
    print(A * N // B)
else:
    print(A * (B-1) // B)

Buggy python submission (verdict: Time Limit Exceeded):
i = list(map(int, input().split()))
A = i[0]
B = i[1]
N = i[2]
a = -10 ** 20
for x in range(1, N+1):
  s = A * x // B
  t = A * (x // B)
  if s - t > a:
    a = s - t
print(a)    


Fixed submission:
i = list(map(int, input().split()))
A = i[0]
B = i[1]
N = i[2]
if N < B-1:
    print(A * N // B)
else:
    print(A * (B-1) // B)

Buggy python submission (verdict: Runtime Error):
i = list(map(int, input().split()))
A = i[0]
B = i[1]
N = i[2]
a = -10 ** 20
for x in range(1, N+1):
  s = A * x // B
  t = A * (X // B)
  if s -  t > a:
    a = s - t
print(a)    


Fixed submission:
i = list(map(int, input().split()))
A = i[0]
B = i[1]
N = i[2]
if N < B-1:
    print(A * N // B)
else:
    print(A * (B-1) // B)

Buggy python submission (verdict: Time Limit Exceeded):
i = list(map(int, input().split()))
A = i[0]
B = i[1]
N = i[2]
a = -10 ** 20
for x in range(1, N+1):
  s = A * x // B
  t_0 = x // B
  t = A * t_0
  u = s - t
  if u > a:
    a = u
print(a)    


Fixed submission:
i = list(map(int, input().split()))
A = i[0]
B = i[1]
N = i[2]
if N < B-1:
    print(A * N // B)
else:
    print(A * (B-1) // B)

Buggy python submission (verdict: Time Limit Exceeded):
i = list(map(int, input().split()))
A = i[0]
B = i[1]
N = i[2]
a = -10 ** 20
for x in range(1, N+1):
  s = A * x // B
  t_0 = x // B
  t = A * t_0
  u = s - t
  if u > a:
    a = u
print(a)    


Fixed submission:
i = list(map(int, input().split()))
A = i[0]
B = i[1]
N = i[2]
if N < B-1:
    print(A * N // B)
else:
    print(A * (B-1) // B)

Buggy python submission (verdict: Runtime Error):
i = list(map(int, input().split()))
A = i[0]
B = i[1]
N = i[2]
a = -10 ** 20
for x in range(1, N+1):
  s = A * x // B
  t_0 = x // B
  t = A * t
  u = s - t
  if u > a:
    a = u
print(a)    

Fixed submission:
i = list(map(int, input().split()))
A = i[0]
B = i[1]
N = i[2]
if N < B-1:
    print(A * N // B)
else:
    print(A * (B-1) // B)
Buggy python submission (verdict: Runtime Error):
b = input()
if b = 'A':
  print('T')
if b = 'T':
  print('A')
if b = 'G':
  print('C')
if b = 'C':
  print('G')

Fixed submission:
b = input()
if b == 'A':
  print('T')
if b == 'T':
  print('A')
if b == 'G':
  print('C')
if b == 'C':
  print('G')
Buggy python submission (verdict: Runtime Error):
s = list(map(int, input().split()))
N = i[0]
M = i[1]
C = i[2]
B = list(map(int, input().split()))
x = 0
for i in range(N):
  k = C
  A = list(map(int, input().split()))
  for j in range(M):
    k = k + A[j] * B[j]
  if k > 0:
    x = x + 1
  else:
    pass
print(x)  

Fixed submission:
s = list(map(int, input().split()))
N = s[0]
M = s[1]
C = s[2]
B = list(map(int, input().split()))
x = 0
for i in range(N):
  k = C
  A = list(map(int, input().split()))
  for j in range(M):
    k = k + A[j] * B[j]
  if k > 0:
    x = x + 1
  else:
    pass
print(x)
Buggy python submission (verdict: Runtime Error):
N = int(input())
s_a = [int(input()) for i in range(N)]
s_b = [0]
s = s_b + s_a
x = 0
y = 0
j = 0

for v in range(N + 1):
    c  = s.count(v)
    if c == 0:
        x = x + v
    if c == 2:
        y = y + v
    if c == 1:
        j = j + 1

if j == N + 1:
    print("Correct")
else:
    print(str(y) + " " + str(x))


Fixed submission:
i = list(map(int, input().split()))
A = i[0]
B = i[1]
C = i[2]
D = B // A

if D <= C:
  print(D)
else:
  print(C)
Buggy python submission (verdict: Runtime Error):
i = list(map(int, input().split()))

def kcd(A, B, K):
    cd_list = []
    for i in range(2, min(A, B) + 1):
        if A % i == 0 and B % i == 0:
            cd_list.insert(0,i)
    return cd_list[K - 1]

print(kcd(i[0],i[1],i[2]))
      


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

def kcd(A, B, K):
    cd_list = []
    for i in range(1, min(A, B) + 1):
        if A % i == 0 and B % i == 0:
            cd_list.insert(0,i)
    return cd_list[K - 1]

print(kcd(i[0],i[1],i[2]))
Buggy python submission (verdict: Runtime Error):
s = int(input())
a = [s]
i = 1

f = lambda n: n // 2 if n % 2 == 0 else 3 * n + 1

while true:
    a.append(f(a[i-1]))
    i += 1

    if a[-1] in a[:-1]:
        break

print(i)


Fixed submission:
s = int(input())
a = [s]
i = 1

f = lambda n: n // 2 if n % 2 == 0 else 3 * n + 1

while True:
    a.append(f(a[i-1]))
    i += 1

    if a[-1] in a[:-1]:
        break

print(i)
Buggy python submission (verdict: Runtime Error):
s = list(input())
K = int(input())
alphabet = "abcdefghijklmnopqrstuvwxyz"

for i in range(len(s)):
    if K >= 26 or s[i] >= alphabet[-K]:
        K -= ord("z") - ord(s[i]) + 1
        s[i] = "a"

if K > 0:
    K %= 26
    if (chr(ord(s[-1]) + K) <= "z"):
        s[-1] = chr(ord(s[-1]) + K)
    else:
        s[-1] = chr(ord("a") + K)

print("".join(s))

Fixed submission:
s = list(input())
s.insert(4, " ")
print("".join(s))

Buggy python submission (verdict: Runtime Error):
s = list(input())
K = int(input())
alphabet = "abcdefghijklmnopqrstuvwxyz"

# need = 0
# for i in range(len(s)):
#     need += ord("z") - ord(s[i]) + 1

for i in range(len(s)):
    if K >= 26 or s[i] >= alphabet[-K]:
        K -= ord("z") - ord(s[i]) + 1
        s[i] = "a"

if K > 0:
    K %= 26
    if (chr(ord(s[-1]) + K) <= "z"):
        s[-1] = chr(ord(s[-1]) + K)
    else:
        s[-1] = chr(ord("a") + K)

# if K > 0:
#     K %= 26
#     if (ord(s[-1]) + K <= ord("z")):
#         s[-1] = chr(ord(s[-1]) + K)
#     else:
#         s[-1] = chr(ord("a") + K - (ord("z" - ord(s[-1]))))

print("".join(s))

Fixed submission:
s = list(input())
s.insert(4, " ")
print("".join(s))

Buggy python submission (verdict: Runtime Error):
s = list(input())
K = int(input())
alphabet = "abcdefghijklmnopqrstuvwxyz"

# need = 0
# for i in range(len(s)):
#     need += ord("z") - ord(s[i]) + 1

for i in range(len(s)):
    if K >= 26 or s[i] >= alphabet[-K]:
        K -= ord("z") - ord(s[i]) + 1
        s[i] = "a"

if K > 0:
    K %= 26
    if (ord(s[-1]) + K <= ord("z")):
        s[-1] = chr(ord(s[-1]) + K)
    else:
        s[-1] = chr(ord("a") + K - (ord("z" - ord(s[-1]))))

print("".join(s))

Fixed submission:
s = list(input())
s.insert(4, " ")
print("".join(s))

Buggy python submission (verdict: Runtime Error):
s = list(input())
K = int(input())
alphabet = "abcdefghijklmnopqrstuvwxyz"

# need = 0
# for i in range(len(s)):
#     need += ord("z") - ord(s[i]) + 1

for i in range(len(s)):
    if K >= 26 or s[i] >= alphabet[-K]:
        K -= ord("z") - ord(s[i]) + 1
        s[i] = "a"

if K > 0:
    K %= 26
    if (ord(s[-1] + K <= ord("z"))):
        s[-1] = chr(ord(s[-1]) + K)
    else:
        s[-1] = chr(ord("a") + K - (ord("z" - ord(s[-1]))))

print("".join(s))

Fixed submission:
s = list(input())
s.insert(4, " ")
print("".join(s))
Buggy python submission (verdict: Runtime Error):
s = list(input())
K = int(input())
alphabet = "abcdefghijklmnopqrstuvwxyz"

for i in range(len(s)):
    if K > 26 or s[i] >= alphabet[-K]:
        K -= ord("z") - ord(s[i]) + 1
        s[i] = "a"

if K > 0:
    K %= 26
    s[-1] = chr(ord(s[-1]) + K)

print("".join(s))

Fixed submission:
s = list(input())
k = int(input())

for i in range(len(s)):
    if s[i] == "a": continue

    diff = ord("z") - ord(s[i]) + 1

    if diff <= k:
        k -= diff
        s[i] = "a"

if k > 0:
    k %= 26
    s[i] = chr(ord(s[i]) + k)

print("".join(s))

Buggy python submission (verdict: Runtime Error):
s = list(input())
K = int(input())
alphabet = "abcdefghijklmnopqrstuvwxyz"

for i in range(len(s)):
    if K >= 26 or s[i] >= alphabet[-K]:
        K -= ord("z") - ord(s[i]) + 1
        s[i] = "a"

if K > 0:
    K %= 26
    if (chr(ord(s[-1]) + K) <= "z"):
        s[-1] = chr(ord(s[-1]) + K)
    else:
        s[-1] = chr(ord("a") + K)

print("".join(s))

Fixed submission:
s = list(input())
k = int(input())

for i in range(len(s)):
    if s[i] == "a": continue

    diff = ord("z") - ord(s[i]) + 1

    if diff <= k:
        k -= diff
        s[i] = "a"

if k > 0:
    k %= 26
    s[i] = chr(ord(s[i]) + k)

print("".join(s))

Buggy python submission (verdict: Runtime Error):
s = list(input())
K = int(input())
alphabet = "abcdefghijklmnopqrstuvwxyz"

# need = 0
# for i in range(len(s)):
#     need += ord("z") - ord(s[i]) + 1

for i in range(len(s)):
    if K >= 26 or s[i] >= alphabet[-K]:
        K -= ord("z") - ord(s[i]) + 1
        s[i] = "a"

if K > 0:
    K %= 26
    s[-1] = chr(ord(s[-1]) + K)

print("".join(s))

Fixed submission:
s = list(input())
k = int(input())

for i in range(len(s)):
    if s[i] == "a": continue

    diff = ord("z") - ord(s[i]) + 1

    if diff <= k:
        k -= diff
        s[i] = "a"

if k > 0:
    k %= 26
    s[i] = chr(ord(s[i]) + k)

print("".join(s))

Buggy python submission (verdict: Runtime Error):
s = list(input())
K = int(input())
alphabet = "abcdefghijklmnopqrstuvwxyz"

need = 0
for i in range(len(s)):
    need += ord("z") - ord(s[i]) + 1

for i in range(len(s)):
    if K >= 26 or s[i] >= alphabet[-K]:
        K -= ord("z") - ord(s[i]) + 1
        s[i] = "a"

if K > 0:
    K %= 26
    s[-1] = chr(ord(s[-1]) + K)

print("".join(s))

Fixed submission:
s = list(input())
k = int(input())

for i in range(len(s)):
    if s[i] == "a": continue

    diff = ord("z") - ord(s[i]) + 1

    if diff <= k:
        k -= diff
        s[i] = "a"

if k > 0:
    k %= 26
    s[i] = chr(ord(s[i]) + k)

print("".join(s))

Buggy python submission (verdict: Runtime Error):
s = list(input())
K = int(input())
alphabet = "abcdefghijklmnopqrstuvwxyz"

for i in range(len(s)):
    if K > 26 or s[i] >= alphabet[-K]:
        K -= ord("z") - ord(s[i]) + 1
        s[i] = "a"

if K > 0:
    s[-1] = chr(ord(s[-1]) + K)

print("".join(s))

Fixed submission:
s = list(input())
k = int(input())

for i in range(len(s)):
    if s[i] == "a": continue

    diff = ord("z") - ord(s[i]) + 1

    if diff <= k:
        k -= diff
        s[i] = "a"

if k > 0:
    k %= 26
    s[i] = chr(ord(s[i]) + k)

print("".join(s))
Buggy python submission (verdict: Time Limit Exceeded):
S = input()

cs = {0: 1}

result = 0

n = 0
for i in range(len(S)):
    c = S[-i-1]
    n += int(c) * (10**i)
    m = n % 2019
    if m in cs:
        result += cs[m]
        cs[m] += 1
    else:
        cs[m] = 1

print(result)

Fixed submission:
S = input()

cs = {0: 1}

result = 0

n = 0
for i in range(len(S)):
    c = int(S[-i-1])
    n += c * pow(10, i, 2019)
    m = n % 2019
    if m in cs:
        result += cs[m]
        cs[m] += 1
    else:
        cs[m] = 1

print(result)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()

rs = [0] * 13

M = 10**9 + 7

if S[-1] == "?":
    rs[:10] = [1] * 10
else:
    rs[int(S[-1])] = 1

for i in range(1, len(S)):
    nrs = [0] * 13
    c = S[-i - 1]
    if c == "?":
        ns = range(10)
    else:
        ns = [int(c)]
    for n in ns:
        r = (10 ** i) * n % 13
        for j in range(13):
            jj = (j + r) % 13
            nrs[jj] = (nrs[jj] + rs[j]) % M
    rs = nrs

# print(rs)
print(rs[5])



Fixed submission:
S = input()

rs = [0] * 13

M = 10**9 + 7

if S[-1] == "?":
    rs[:10] = [1] * 10
else:
    rs[int(S[-1])] = 1

for i in range(1, len(S)):
    nrs = [0] * 13
    c = S[-i - 1]
    if c == "?":
        ns = range(10)
    else:
        ns = [int(c)]
    for n in ns:
        r = (10 ** (i % 6)) * n % 13
        for j in range(13):
            jj = (j + r) % 13
            nrs[jj] = (nrs[jj] + rs[j]) % M
    rs = nrs

# print(rs)
print(rs[5])
Buggy python submission (verdict: Time Limit Exceeded):
N, K = [int(_) for _ in input().split()]
AB = [[int(_) for _ in input().split()] for i in range(N - 1)]

from collections import defaultdict

v = defaultdict(set)

for a, b in AB:
    v[a].add(b)
    v[b].add(a)

r = [-1] * (N + 1)
M = 10**9+7

import sys
sys.setrecursionlimit(100001)

def check(n, b, p):
    r[n] = max(K - b - p, 0)
    #print("check:", n, r[n])
    b = 0
    for x in v[n]:
        if r[x] == -1:
            check(x, b, min(p + 1, 2))
            b += 1

check(1, 0, 0)

#print(r)

result = 1
for i in range(N):
    result = result * r[i + 1] % M

print(result)


Fixed submission:
N, K = [int(_) for _ in input().split()]
AB = [[int(_) for _ in input().split()] for i in range(N - 1)]

from collections import defaultdict

v = defaultdict(set)

for a, b in AB:
    v[a].add(b)
    v[b].add(a)

M = 10**9+7

import sys
sys.setrecursionlimit(100001)

result = 1

def check(n, b, p):
    global result
    result = result * max(K - b - p, 0) % M
    #print("check:", n, r[n])
    np = min(p + 1, 2)
    for b, x in enumerate(v[n]):
        v[x].remove(n)
        check(x, b, np)

check(1, 0, 0)

print(result)

Buggy python submission (verdict: Runtime Error):
N, K = [int(_) for _ in input().split()]
AB = [[int(_) for _ in input().split()] for i in range(N - 1)]

from collections import defaultdict

v = defaultdict(set)

for a, b in AB:
    v[a].add(b)
    v[b].add(a)

r = [0] * (N + 1)
M = 10**9+7

def check(n, b, p):
    r[n] = K - b - p
    #print("check:", n, r[n])
    b = 0
    for x in v[n]:
        if r[x] == 0:
            check(x, b, min(p + 1, 2))
            b += 1

check(1, 0, 0)

#print(r)

result = 1
for i in range(N):
    result = result * r[i + 1] % M

print(result)


Fixed submission:
N, K = [int(_) for _ in input().split()]
AB = [[int(_) for _ in input().split()] for i in range(N - 1)]

from collections import defaultdict

v = defaultdict(set)

for a, b in AB:
    v[a].add(b)
    v[b].add(a)

M = 10**9+7

import sys
sys.setrecursionlimit(100001)

result = 1

def check(n, b, p):
    global result
    result = result * max(K - b - p, 0) % M
    #print("check:", n, r[n])
    np = min(p + 1, 2)
    for b, x in enumerate(v[n]):
        v[x].remove(n)
        check(x, b, np)

check(1, 0, 0)

print(result)
Buggy python submission (verdict: Runtime Error):
N = int(input())
XY = [[int(_) for _ in input().split()] for i in range(N)]

dxy = [
    (XY[i][0] - XY[j][0], XY[i][1] - XY[j][1])
    for i in range(N)
    for j in range(i + 1, N)
]

from collections import Counter

cdxy = Counter(dxy)

m = max(cdxy.values())

#print(XY)
#print(dxy)
#print(cdxy)

result = N - m
print(result)


Fixed submission:
N = int(input())
XY = [tuple([int(_) for _ in input().split()]) for i in range(N)]

if N == 1:

    result = 1

else:

    XY.sort()

    dxy = [
        (XY[i][0] - XY[j][0], XY[i][1] - XY[j][1])
        for i in range(N)
        for j in range(i + 1, N)
    ]

    from collections import Counter

    cdxy = Counter(dxy)

    m = max(cdxy.values())

    #print(XY)
    #print(dxy)
    #print(cdxy)

    result = N - m

print(result)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(_) for _ in input().split()]

mxs = sorted(x for x in A if x < 0)
pxs = sorted(x for x in A if x >= 0)

if len(mxs) == 0:
    mxs = [pxs[0]]
    pxs = pxs[1:]

#print(mxs, pxs)

result = sum(pxs) - sum(mxs)
print(result)

if len(pxs) == 1:
    for y in mxs:
        print(pxs[0], y)
        pxs[0] -= y
else:
    for y in pxs[:-1]:
        print(mxs[0], y)
        mxs[0] -= y
    print(pxs[-1], mxs[0])
    pxs[-1] -= mxs[0]
    for y in mxs[1:]:
        print(pxs[-1], y)
        pxs[-1] -= y

#for i in range





Fixed submission:
N = int(input())
A = [int(_) for _ in input().split()]

mxs = sorted(x for x in A if x < 0)
pxs = sorted(x for x in A if x >= 0)

if len(mxs) == 0:
    mxs = [pxs[0]]
    pxs = pxs[1:]

if len(pxs) == 0:
    pxs = [mxs[-1]]
    mxs = mxs[:-1]

#print(mxs, pxs)

result = sum(pxs) - sum(mxs)
print(result)

if len(pxs) == 1:
    for y in mxs:
        print(pxs[0], y)
        pxs[0] -= y
else:
    for y in pxs[:-1]:
        print(mxs[0], y)
        mxs[0] -= y
    print(pxs[-1], mxs[0])
    pxs[-1] -= mxs[0]
    for y in mxs[1:]:
        print(pxs[-1], y)
        pxs[-1] -= y

#for i in range
Buggy python submission (verdict: Runtime Error):
N, M = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
BC = [tuple(int(_) for _ in input().split()) for i in range(M)]


A = sorted(A)
BC = sorted(BC, key=lambda x:-x[1])

#print(A, BC)

i = 0
for b, c in BC:
    if i > N:
        break
    for j in range(b):
        if i > N or A[i] >= c:
            break
        A[i] = c
        i += 1
    
#print(A, BC)

result = sum(A)

print(result)


Fixed submission:
N, M = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
BC = [tuple(int(_) for _ in input().split()) for i in range(M)]


A = sorted(A)
BC = sorted(BC, key=lambda x:-x[1])

#print(A, BC)

i = 0
for b, c in BC:
    if i > N:
        break
    for j in range(b):
        if i >= N or A[i] >= c:
            break
        A[i] = c
        i += 1
    
#print(A, BC)

result = sum(A)

print(result)
Buggy python submission (verdict: Time Limit Exceeded):
H, W = [int(_) for _ in input().split()]
A = [list(input()) for i in range(H)]


ps = []
pcount = 0
for y, row in enumerate(A):
    for x, c in enumerate(row):
        if c == "#":
            ps.append((x, y))
            pcount += 1


result = 0

#print(A)
#print(ps)

while pcount < H * W:
    nps = []
    def pset(x, y):
        global pcount
        if 0 <= y < len(A) and 0 <= x < len(A[y]) and A[y][x] == ".":
            A[y][x] = "#"
            nps.append((x, y))
            pcount += 1
    for x, y in ps:
        pset(x - 1, y)
        pset(x + 1, y)
        pset(x, y - 1)
        pset(x, y + 1)
    ps = nps
    result += 1
    #print(A)
    #print(ps)
    #print(result)

print(result)


Fixed submission:
H, W = [int(_) for _ in input().split()]
A = [list(input()) for i in range(H)]


ps = []
pcount = 0
for y, row in enumerate(A):
    for x, c in enumerate(row):
        if c == "#":
            ps.append((x, y))
            pcount += 1


result = 0

#print(A)
#print(ps)

while pcount < H * W:
    nps = []
    def pset(x, y):
        global pcount
        if 0 <= y < len(A) and 0 <= x < len(A[y]) and A[y][x] == ".":
            A[y][x] = "#"
            nps.append((x, y))
            pcount += 1
    for x, y in ps:
        pset(x - 1, y)
        pset(x + 1, y)
        pset(x, y - 1)
        pset(x, y + 1)
    ps = nps
    result += 1
    #print(A)
    #print(ps)
    #print(result)

print(result)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(_) for _ in input().split()]

ma = sorted(x for x in A if x < 0)
pa = sorted(x for x in A if x >= 0)

# print(ma, pa)

if len(ma) % 2 == 0:
    result = -sum(ma) + sum(pa)
else:
    x = min(-ma[-1], pa[0])
    result = -sum(ma) + sum(pa) - x * 2

print(result)
   

Fixed submission:
N = int(input())
A = [int(_) for _ in input().split()]

ma = sorted(x for x in A if x < 0)
pa = sorted(x for x in A if x >= 0)

# print(ma, pa)

if len(ma) % 2 == 0:
    result = -sum(ma) + sum(pa)
else:
    x = -ma[-1]
    if len(pa):
        x = min(x, pa[0])
    result = -sum(ma) + sum(pa) - x * 2

print(result)
Buggy python submission (verdict: Runtime Error):
N, K = [int(_) for _ in input().split()]

S = input()

xs = []

i = 0

while i < N :
    l = 0
    while i < N and S[i] == '1':
        i += 1
        l += 1
    xs.append(l)
    l = 0
    while i < N and S[i] == '0':
        i += 1
        l += 1
    xs.append(l)

xs += [0] * (K * 2)

#print(xs)

result = 0

l = (K * 2) + 1
result = r = sum(xs[0:l])
#print("*", result, r)

i = 0
while i + l + 1 < N:
    r = r - xs[i] - xs[i+1] + xs[i+l] + xs[i+l+1]
    result = max(result, r)
    #print(result, r)
    i += 2

print(result)


Fixed submission:
N, K = [int(_) for _ in input().split()]

S = input()

xs = []

i = 0

while i < N :
    l = 0
    while i < N and S[i] == '1':
        i += 1
        l += 1
    xs.append(l)
    l = 0
    while i < N and S[i] == '0':
        i += 1
        l += 1
    xs.append(l)

xs += [0] * (K * 2)

#print(xs)

result = 0

l = (K * 2) + 1
result = r = sum(xs[0:l])
#print("*", result, r)

i = 0
while i + l + 1 < len(xs):
    r = r - xs[i] - xs[i+1] + xs[i+l] + xs[i+l+1]
    result = max(result, r)
    #print(result, r)
    i += 2

print(result)
Buggy python submission (verdict: Runtime Error):
N, M, C = [int(_) for _ in input().split()]
B = [int(_) for _ in input().split()]
A = [[int(_) for _ in input().split()] for i in range(N)]

result = len(
    row
    for row in A
    if C + sum([x * y for x, y in zip(row, B)]) > 0
)

print(result)

Fixed submission:
N, M, C = [int(_) for _ in input().split()]
B = [int(_) for _ in input().split()]
A = [[int(_) for _ in input().split()] for i in range(N)]

result = 0

for row in A:
    t = C + sum([x * y for x, y in zip(row, B)])
    if t > 0:
        result += 1

print(result)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(_) for _ in input().split()]

from collections import defaultdict

xs = sorted(A, reverse=True)

cs = defaultdict(int)

for x in xs:
    cs[x] += 1

result = 0

for x in xs:
    if cs[x]:
        for i in range(31, 0, - 1):
            m = 2**i
            y = m - x
            if x == y:
                if cs[y] >= 2:
                    cs[y] -= 2
                    result += 1
                    break
            else:
                if cs[y] >= 1:
                    cs[x] -= 1
                    cs[y] -= 1
                    result += 1
                    break

#print(cs)
print(result)


Fixed submission:
N = int(input())
A = [int(_) for _ in input().split()]

xs = sorted(A, reverse=True)

cs = {}

for x in xs:
    cs[x] = cs.get(x, 0) + 1

result = 0

for x in xs:
    if cs[x]:
        for i in range(31, 0, - 1):
            m = 2**i
            y = m - x
            if y > x or y < 1:
                continue
            if y in cs:
                if x == y:
                    if cs[y] >= 2:
                        cs[y] -= 2
                        result += 1
                        break
                else:
                    if cs[y] >= 1:
                        cs[x] -= 1
                        cs[y] -= 1
                        result += 1
                        break

#print(cs)
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = [int(_) for _ in input().split()]

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

result = 1

a = 1

while True:
    b = M - (a * (N - 1))
    if b < 1:
        break
    # print(a, b)
    x = gcd(a, b)
    result = max(result, x)
    a += 1

print(result)

Fixed submission:
import math

N, M = [int(_) for _ in input().split()]


sr = int(math.sqrt(M))

result = 1

for i in range(sr, 0, -1):
    if M % i == 0:
        r = i
        if M >= N * r:
            result = max(r, result)
        r = M // i
        if i >= N:
            result = max(r, result)

print(result)