Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n=int(input())
mylist=[]
for i in range(n):
    s=input()
    mylist.append(s)
#print(mylist)
c=Counter(mylist)

max=sum(x==max(mylist) for x in mylist)
answer=[]
#print(max)
for word,i in c.most_common():
    #print(word,i)
    if i==max:
        answer.append(word)
    else:
        break

answer.sort()
for i in range(len(answer)):
    print(answer[i])

Fixed submission:
from collections import Counter
n=int(input())
mylist=[]
for i in range(n):
    s=input()
    mylist.append(s)
#print(mylist)
c=Counter(mylist)

#max=sum(x==max(mylist) for x in mylist)
answer=[]
flag=0
#print(max)
for word,i in c.most_common():
    #print(word,i)
    if flag==0:
        max=i
        flag+=1
        answer.append(word)
    else:
        if i==max:
            answer.append(word)
        else:
            break

answer.sort()
for i in range(len(answer)):
    print(answer[i])
Buggy python submission (verdict: Runtime Error):
a=int(input())
s=input()
if a>=3200:
    print(s)
else:
    print(red)

Fixed submission:
a=int(input())
s=input()
if a>=3200:
    print(s)
else:
    print("red")
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())

a = n

while a >= abs(a-k):
    a = abs(a-k)
    
print(a)
    

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

print(min(n%k, k - n%k))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))

vote = []

for j in range(N):
    all += A[j]

for i in range(N):
    if A[i] >= all // (4 * M):
        vote.append(A[i])

if len(vote) >= M:
    print("Yes")

else:
    print("No")

Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))

vote = []
all = 0

for j in range(N):
    all += A[j]

for i in range(N):
    if A[i] >= all / (4 * M):
        vote.append(A[i])

if len(vote) >= M:
    print("Yes")

else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
B = list(int,input().split())

answer = B[0] + B[N-2]

for i in range(N-2):
    answer += min(B[i],B[i+1])

print(answer)


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

answer = B[0] + B[N-2]

for i in range(N-2):
    answer += min(B[i],B[i+1])

print(answer)
Buggy python submission (verdict: Runtime Error):
N = int(input())
v = list(map(int,input().split()))

v.sorted(reverse=True)
x = 1
answer = 0
for i in range(N-1):
    x *= 2
    answer += (v[i]/x)

answer += v[N-1]/x
print(answer)


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

v.sort(reverse=True)
x = 1
answer = 0
for i in range(N-1):
    x *= 2
    answer += (v[i]/x)

answer += v[N-1]/x
print(answer)

Buggy python submission (verdict: Runtime Error):
N = int(input())
v = list(map(int,input().split()))

v.sorted(reverse=True)
x = 1
answer = 0
for i in range(N-1):
    x *= 2
    answer += (v[i]/x)

answer += v[N-1]/x
print(answer)


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

v.sort(reverse=True)
x = 1
answer = 0
for i in range(N-1):
    x *= 2
    answer += (v[i]/x)

answer += v[N-1]/x
print(answer)

Buggy python submission (verdict: Runtime Error):
N = int(input())
v = list(map(int,input().split()))

v.sorted(reverse=True)
x = 1
answer = 0
for i in range(n-1):
    x *= 2
    answer += (v[i]/x)

answer += v[N-1]/x
print(answer)


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

v.sort(reverse=True)
x = 1
answer = 0
for i in range(N-1):
    x *= 2
    answer += (v[i]/x)

answer += v[N-1]/x
print(answer)
Buggy python submission (verdict: Runtime Error):
s = input()
RRLRL

l = len(s)
n = 1
rl = []
for i in range(l-1):
    if s[i] == s[i+1] and i != l-2:
        n += 1
    elif s[i] == s[i+1] and i == l-2:
        n += 1
    else:
        rl.append(n)
        n = 1

rl.append(n)

ans = [0]*l
rl_length = len(rl)//2
position = rl[0]

for i in range(rl_length):
    ans[position-1] += -(-rl[i*2]//2) + rl[i*2+1]//2
    ans[position] += rl[i*2]//2 - (-rl[i*2+1]//2)
    if i != rl_length - 1:
        position += (rl[i*2+1] + rl[i*2+2])

for i in range(l):
    if i == l-1:
        print(ans[l-1])
    else:
        print(ans[i],end=" ")


Fixed submission:
s = input()

l = len(s)
n = 1
rl = []
for i in range(l-1):
    if s[i] == s[i+1] and i != l-2:
        n += 1
    elif s[i] == s[i+1] and i == l-2:
        n += 1
    else:
        rl.append(n)
        n = 1

rl.append(n)

ans = [0]*l
rl_length = len(rl)//2
position = rl[0]

for i in range(rl_length):
    ans[position-1] += -(-rl[i*2]//2) + rl[i*2+1]//2
    ans[position] += rl[i*2]//2 - (-rl[i*2+1]//2)
    if i != rl_length - 1:
        position += (rl[i*2+1] + rl[i*2+2])

for i in range(l):
    if i == l-1:
        print(ans[l-1])
    else:
        print(ans[i],end=" ")
Buggy python submission (verdict: Runtime Error):
s = [int(x) if x!='?' else -1 for x in input()]

mod = 1000000007
length = len(s)
ans = list([0]*13 for i in range(length+1))
ans[0][0] = 1

mod_x10 = [0]*13
for i in range(13):
    mod_x10[i] = i * 10 % 13 - 1

for i in range(length):
    for j in range(13):
        x = mod_x10[j]
        if s[i] == -1:
            for k in range(10):
                x = (x + 1) % 13
                ans[i+1][x] += ans[i][j] % mod
        else:
            x = (x + int(s[i]) + 1) % 13
            ans[i+1][x] += ans[i][j] % mod

print('a')
print(ans[length][5] % mod)


Fixed submission:
a,b = map(int,input().split())

if (a + b) % 2 == 0:
    print((a+b)//2)
else:
    print('IMPOSSIBLE')

Buggy python submission (verdict: Runtime Error):
s = [int(x) if x!='?' else -1 for x in input()]

mod = 1000000007
length = len(s)
ans = list([0]*13 for i in range(length+1))
ans[0][0] = 1

mod_x10 = [0]*13
for i in range(13):
    mod_x10[i] = i * 10 % 13 - 1

for i in range(length):
    for j in range(13):
        x = mod_x10[j]
        if s[i] == -1:
            for k in range(10):
                x = (x + 1) % 13
                ans[i+1][x] += ans[i][j] % mod
        else:
            x = (x + int(s[i]) + 1) % 13
            ans[i+1][x] += ans[i][j] % mod

print(ans[length][5] % mod)
print('a')


Fixed submission:
a,b = map(int,input().split())

if (a + b) % 2 == 0:
    print((a+b)//2)
else:
    print('IMPOSSIBLE')

Buggy python submission (verdict: Runtime Error):
s = input()

mod = 1000000007
length = len(s)
ans = list([0]*13 for i in range(length+1))
ans[0][0] = 1

for i in range(length):
    for j in range(13):
        x = j*10 % 13 - 1
        if s[i] == '?':
            for k in range(10):
                x = (x + 1) % 13
                ans[i+1][x] += ans[i][j]
        else:
            x = (x + int(s[i]) + 1) % 13
            ans[i+1][x] += ans[i][j]

print(ans[length][5] % mod)


Fixed submission:
a,b = map(int,input().split())

if (a + b) % 2 == 0:
    print((a+b)//2)
else:
    print('IMPOSSIBLE')

Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())

if (a + b) % 2 == 0:
    print((a+b)/2)
else:
    print(IMPOSSIBLE)


Fixed submission:
a,b = map(int,input().split())

if (a + b) % 2 == 0:
    print((a+b)//2)
else:
    print('IMPOSSIBLE')
Buggy python submission (verdict: Runtime Error):
import bisect

N = int(input())
A = [int(input()) for i in range(N)]

ans = 1
X = [-A[0]]
for i in range(1,N):
    if -X[ans-1] >= A[i]:
        X.append(-A[i])
        ans += 1
    else:
        pos = bisect.bisect_left(X,-A[i])
        X[pos] = -A[i]

print(ans)


Fixed submission:
r = int(input())
print(3*r**2)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for i in range(N)]

for i in range(N):
    max = 0
    for j in range(N):
        if i != j and A[j] > max:
            max = A[j]
    print(max)


Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]

No1 = 0
No2 = 0
for i in range(N):
    if A[i] > No1:
        No2 = No1
        No1 = A[i]
    elif A[i] > No2:
        No2 = A[i]

for i in range(N):
    if A[i] == No1:
        print(No2)
    else:
        print(No1)
Buggy python submission (verdict: Runtime Error):
N = int(input())
5
A = list(map(int,input().split()))
0 0 0 0 0

for i in range(N-1,0,-1):
    A[i] = sum(A[i::i+1]) % 2

s = sum(A[0:N])
print(s)

n = 1
for i in range(N):
    if s == 0:
        print('')
        break
    if A[i] == 1:
        if n == s:
            print(i+1)
            break
        else:
            print(i+1,end=' ')
            n += 1


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

for i in range(N-1,-1,-1):
    A[i] = sum(A[i::i+1]) % 2

s = sum(A[0:N])
print(s)

n = 1
for i in range(N):
    if A[i] == 1:
        if n == s:
            print(i+1)
            break
        else:
            print(i+1,end=' ')
            n += 1

Buggy python submission (verdict: Runtime Error):
N = int(input())
5
A = list(map(int,input().split()))
0 0 0 0 0

for i in range(N-1,0,-1):
    A[i] = sum(A[i::i+1]) % 2

s = sum(A[0:N])
print(s)

n = 1
for i in range(N):
    if s == 0:
        print('')
    if A[i] == 1:
        if n == s:
            print(i+1)
            break
        else:
            print(i+1,end=' ')
            n += 1


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

for i in range(N-1,-1,-1):
    A[i] = sum(A[i::i+1]) % 2

s = sum(A[0:N])
print(s)

n = 1
for i in range(N):
    if A[i] == 1:
        if n == s:
            print(i+1)
            break
        else:
            print(i+1,end=' ')
            n += 1

Buggy python submission (verdict: Runtime Error):
N = int(input())
5
A = list(map(int,input().split()))
1 0 0 1 0

for i in range(N,1,-1):
    A[i-1] = sum(A[i-1::i]) % 2

print(sum(A[0:N]))

n = 1
for i in range(N):
    if A[i] == 1:
        if n == sum(A[0:N]):
            print(i+1)
        else:
            print(i,end=' ')
            n += 1


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

for i in range(N-1,-1,-1):
    A[i] = sum(A[i::i+1]) % 2

s = sum(A[0:N])
print(s)

n = 1
for i in range(N):
    if A[i] == 1:
        if n == s:
            print(i+1)
            break
        else:
            print(i+1,end=' ')
            n += 1
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for i in range(N)]

ans = 1
X = [-1]
for i in range(N):
    for j in range(ans):
        if X[j] < A[i]:
            X[j] = A[i]
            break
        elif j == ans - 1:
            X.append(A[i])
            ans += 1

print(ans)


Fixed submission:
import bisect

N = int(input())
A = [int(input()) for i in range(N)]

ans = 1
X = [-A[0]]
for i in range(1,N):
    if -X[ans-1] >= A[i]:
        X.append(-A[i])
        ans += 1
    else:
        pos = bisect.bisect_right(X,-A[i])
        X[pos] = -A[i]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for i in range(N)]

ans = 1
X = [-1]
for i in range(N):
    for j in range(ans):
        if X[j] < A[i]:
            X[j] = A[i]
            break
        elif j == ans - 1:
            X.append(X[ans-1])
            for k in range(ans-1,0,-1):
                X[k] = X[k-1]
            ans += 1
            X[0] = A[i]

print(ans)


Fixed submission:
import bisect

N = int(input())
A = [int(input()) for i in range(N)]

ans = 1
X = [-A[0]]
for i in range(1,N):
    if -X[ans-1] >= A[i]:
        X.append(-A[i])
        ans += 1
    else:
        pos = bisect.bisect_right(X,-A[i])
        X[pos] = -A[i]

print(ans)
Buggy python submission (verdict: Runtime Error):
import math
N,D = map(int,input().split())
3 2
X = [list(map(int,input().split())) for i in range(N)]
1 2
5 5
-2 8

ans = 0
for j in range(N):
    for i in range(j):
        distant2 = 0
        for k in range(D):
            distant2 += (X[j][k]-X[i][k])**2
        if math.sqrt(distant2) % 1 == 0:
            ans += 1

print(ans)


Fixed submission:
import math
N,D = map(int,input().split())
X = [list(map(int,input().split())) for i in range(N)]

ans = 0
for j in range(N):
    for i in range(j):
        distant2 = 0
        for k in range(D):
            distant2 += (X[j][k]-X[i][k])**2
        if math.sqrt(distant2) % 1 == 0:
            ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())

Red = N-K
Blue = K
mod = 1000000007

ans = 1
for i in range(Blue):
    if Red < i:
            ans = 0
    elif i != 0:
        ans = (ans * (Red + 1 - i) * (Blue - i) // ((i + 1) * i))
    else:
        ans = (ans * (Red + 1 - i) // (i + 1))
    print(int(ans) % mod)


Fixed submission:
S = input()

count = 0
if S[0] == S[1] and S[2] == S[3]:
    count += 1

if S[0] == S[2] and S[1] == S[3]:
    count += 1

if S[0] == S[3] and S[1] == S[2]:
    count += 1

if count == 1:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
p = map(int,input().split())

large_small = -1
ans = 2
for i in range(n-1):
    if p[i] > p[i+1]:
        if large_small == 1:
            ans += 1
        large_small = 1
    elif p[i] < p[i+1]:
        if large_small == -1:
            ans += 1
        large_small = -1
    else:
        large_small = 0

print(ans)


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

large_small = 2
ans = 0
for i in range(n-1):
    if p[i] > p[i+1]:
        if large_small == 1:
            ans += 1
        large_small = 1
    elif p[i] < p[i+1]:
        if large_small == -1:
            ans += 1
        large_small = -1
    else:
        large_small = 0

print(ans)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())

Red = N-K
Blue = K
mod = 1000000007

ans = 1
for i in range(Blue):
    if Red < i:
            ans = 0
    elif i != 0:
        ans = ans * (Red + 1 - i) * (Blue - i) / ((i + 1) * i)
    else:
        ans = ans * (Red + 1 - i) / (i + 1)
    print(int(ans) % mod)


Fixed submission:
N,K = map(int,input().split())

Red = N-K
Blue = K
mod = 1000000007

ans = 1
for i in range(Blue):
    if Red < i:
            ans = 0
    elif i != 0:
        ans = (ans * (Red + 1 - i) * (Blue - i) // ((i + 1) * i))
    else:
        ans = (ans * (Red + 1 - i) // (i + 1))
    print(int(ans) % mod)

Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())

Red = N-K
Blue = K
mod = 1000000007

ans = 1
for i in range(Blue):
    if Red < i:
            ans = 0
    elif i != 0:
        ans = ans * (Red + 1 - i) * (Blue - i) / ((i + 1) * i)
    else:
        ans = ans * (Red + 1 - i) / (i + 1)
    print(int(ans) % mod)


Fixed submission:
N,K = map(int,input().split())

Red = N-K
Blue = K
mod = 1000000007

ans = 1
for i in range(Blue):
    if Red < i:
            ans = 0
    elif i != 0:
        ans = (ans * (Red + 1 - i) * (Blue - i) // ((i + 1) * i))
    else:
        ans = (ans * (Red + 1 - i) // (i + 1))
    print(int(ans) % mod)
Buggy python submission (verdict: Runtime Error):
from fractions import gcd
A,B,C,D = map(int,input().split())

C_mod0 = B//C - (A-1)//C
D_mod0 = B//D - (A-1)//D
CD_mod0 = B*math.gcd(C,D)//(C*D) -(A-1)*math.gcd(C,D)//(C*D)
Total = B - A + 1
ans = Total - C_mod0 - D_mod0 + CD_mod0

print(ans)


Fixed submission:
A,B,C,D = map(int,input().split())

C_mod0 = B//C - (A-1)//C
D_mod0 = B//D - (A-1)//D
i = D
j = C % D
while j > 0:
    k = j
    j = i % j
    i = k

CD_mod0 = B*i // (C*D) - (A-1)*i // (C*D)
Total = B - A + 1
ans = Total - C_mod0 - D_mod0 + CD_mod0

print(ans)

Buggy python submission (verdict: Runtime Error):
import math
A,B,C,D = map(int,input().split())

C_mod0 = B//C - (A-1)//C
D_mod0 = B//D - (A-1)//D
CD_mod0 = B*math.gcd(C,D)//(C*D) -(A-1)*math.gcd(C,D)//(C*D)
Total = B - A + 1
ans = Total - C_mod0 - D_mod0 + CD_mod0

print(ans)


Fixed submission:
A,B,C,D = map(int,input().split())

C_mod0 = B//C - (A-1)//C
D_mod0 = B//D - (A-1)//D
i = D
j = C % D
while j > 0:
    k = j
    j = i % j
    i = k

CD_mod0 = B*i // (C*D) - (A-1)*i // (C*D)
Total = B - A + 1
ans = Total - C_mod0 - D_mod0 + CD_mod0

print(ans)

Buggy python submission (verdict: Runtime Error):
import math
A,B,C,D = map(int,input().split())

C_mod0 = B//C - (A-1)//C
D_mod0 = B//D - (A-1)//D
CD_mod0 = B*math.gcd(C,D)//(C*D) -(A-1)*math.gcd(C,D)//(C*D)
Total = B - A + 1
ans = Total - C_mod0 - D_mod0 + CD_mod0
print(ans)


Fixed submission:
A,B,C,D = map(int,input().split())

C_mod0 = B//C - (A-1)//C
D_mod0 = B//D - (A-1)//D
i = D
j = C % D
while j > 0:
    k = j
    j = i % j
    i = k

CD_mod0 = B*i // (C*D) - (A-1)*i // (C*D)
Total = B - A + 1
ans = Total - C_mod0 - D_mod0 + CD_mod0

print(ans)

Buggy python submission (verdict: Runtime Error):
import math
A,B,C,D = map(int,input().split())

C_mod0 = B//C - (A-1)//C
D_mod0 = B//D - (A-1)//D
CD_mod0 = B*math.gcd(C,D)//(C*D) -(A-1)*math.gcd(C,D)//(C*D)
Total = B - A + 1
ans = Total - C_mod0 - D_mod0 + CD_mod0
print(ans)


Fixed submission:
A,B,C,D = map(int,input().split())

C_mod0 = B//C - (A-1)//C
D_mod0 = B//D - (A-1)//D
i = D
j = C % D
while j > 0:
    k = j
    j = i % j
    i = k

CD_mod0 = B*i // (C*D) - (A-1)*i // (C*D)
Total = B - A + 1
ans = Total - C_mod0 - D_mod0 + CD_mod0

print(ans)
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
a = list(map(int,input().split()))

right_gcd = [0]*(n)
left_gcd = [0]*(n)
right_gcd[n-1] = a[n-1]
left_gcd[0] = a[0]

for i in range(n-1,0,-1):
    right_gcd[i-1] = math.gcd(right_gcd[i],a[i-1])

for i in range(n-1):
    left_gcd[i+1] = math.gcd(left_gcd[i],a[i+1])

gcd = [0]*n
for i in range(n):
    if i == 0:
        gcd[i] = right_gcd[1]
    elif i == n-1:
        gcd[i] = left_gcd[n-2]
    else:
        gcd[i] = math.gcd(left_gcd[i-1],right_gcd[i+1])

print(max(gcd))


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

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

right_gcd = [0]*(n)
left_gcd = [0]*(n)
right_gcd[n-1] = a[n-1]
left_gcd[0] = a[0]

for i in range(n-1,0,-1):
    right_gcd[i-1] = gcd(right_gcd[i],a[i-1])

for i in range(n-1):
    left_gcd[i+1] = gcd(left_gcd[i],a[i+1])

except_gcd = [0]*n
for i in range(n):
    if i == 0:
        except_gcd[i] = right_gcd[1]
    elif i == n-1:
        except_gcd[i] = left_gcd[n-2]
    else:
        except_gcd[i] = gcd(left_gcd[i-1],right_gcd[i+1])

print(max(except_gcd))

Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
a = list(map(int,input().split()))

right_gcd = [0]*(n)
left_gcd = [0]*(n)
right_gcd[n-1] = a[n-1]
left_gcd[0] = a[0]

for i in range(n-1,0,-1):
    right_gcd[i-1] = math.gcd(right_gcd[i],a[i-1])

for i in range(n-1):
    left_gcd[i+1] = math.gcd(left_gcd[i],a[i+1])

gcd = [0]*n
for i in range(n):
    if i == 0:
        gcd[i] = right_gcd[1]
    elif i == n-1:
        gcd[i] = left_gcd[n-2]
    else:
        gcd[i] = math.gcd(left_gcd[i-1],right_gcd[i+1])

print(max(gcd))


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

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

right_gcd = [0]*(n)
left_gcd = [0]*(n)
right_gcd[n-1] = a[n-1]
left_gcd[0] = a[0]

for i in range(n-1,0,-1):
    right_gcd[i-1] = gcd(right_gcd[i],a[i-1])

for i in range(n-1):
    left_gcd[i+1] = gcd(left_gcd[i],a[i+1])

except_gcd = [0]*n
for i in range(n):
    if i == 0:
        except_gcd[i] = right_gcd[1]
    elif i == n-1:
        except_gcd[i] = left_gcd[n-2]
    else:
        except_gcd[i] = gcd(left_gcd[i-1],right_gcd[i+1])

print(max(except_gcd))
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
s = input()


if s[0] == '1':
    length_01 = [0]
else:
    length_01 = [0,0]

for i in range(n-1):
    if s[i] != s[i+1]:
        length_01.append(i+1)

if s[n-1] == '0':
    length_01.append(n-1)

num_0 = int((len(length_01)+1)/2)
if num_0 - 1 >= k:
    answer = 0
    for i in range(num_0):
        if answer < length_01[2*(i+k)] - length_01[2*i] + 1:
            answer = length_01[2*(i+k)] - length_01[2*i] + 1
else:
    answer = n

print(answer)


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

if s[0] == '1':
    length_01 = [0]
else:
    length_01 = [0,0]

for i in range(n-1):
    if s[i] != s[i+1]:
        length_01.append(i+1)

if s[n-1] == '1':
    length_01.append(n)
else:
    length_01.append(n)
    length_01.append(n)

num_0 = int(len(length_01)/2)
if num_0 - k >= 1:
    answer = 0
    for i in range(num_0 - k):
        if answer < length_01[2*(i+k)+1] - length_01[2*i]:
            answer = length_01[2*(i+k)+1] - length_01[2*i]
else:
    answer = n

print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
s = input()

if s[0] == '1':
    length_01 = []
else:
    length_01 = [0]

a = 1
for i in range(n-1):
    if s[i] == s[i+1]:
        a += 1
    else:
        length_01.append(a)
        a = 1

length_01.append(a)
if s[n-1] == '0':
    length_01.append(0)

num_0 = int((len(length_01)+1)/2)
if num_0 - 1 >= k:
    answer = 0
    for i in range(num_0):
        if answer < sum(length_01[2*i:2*(i+k)+1]):
            answer = sum(length_01[2*i:2*(i+k)+1])
else:
    answer = len(s)

print(answer)


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

if s[0] == '1':
    length_01 = [0]
else:
    length_01 = [0,0]

for i in range(n-1):
    if s[i] != s[i+1]:
        length_01.append(i+1)

if s[n-1] == '1':
    length_01.append(n)
else:
    length_01.append(n)
    length_01.append(n)

num_0 = int(len(length_01)/2)
if num_0 - k >= 1:
    answer = 0
    for i in range(num_0 - k):
        if answer < length_01[2*(i+k)+1] - length_01[2*i]:
            answer = length_01[2*(i+k)+1] - length_01[2*i]
else:
    answer = n

print(answer)
Buggy python submission (verdict: Runtime Error):
n,q = map(int,input().split())
s = input()
lr = list(list(map(int,input().split())) for i in range(q))

x = [0]*(n-1)
for i in range(n):
    if s[i] == 'A' and s[i+1] == 'C':
        x[i] = 1

for i in range(q):
    print(sum(x[(lr[i][0]-1):(lr[i][1]-1)]))


Fixed submission:
n,q = map(int,input().split())
s = input()
lr = list(list(map(int,input().split())) for i in range(q))

x = [0]*(n)
for i in range(n-1):
    if s[i] == 'A':
        if s[i+1] == 'C':
            x[i+1] = x[i] + 1
        else:
            x[i+1] = x[i]
    else:
        x[i+1] = x[i]

for i in range(q):
    print(x[lr[i][1]-1]-x[lr[i][0]-1])

Buggy python submission (verdict: Runtime Error):
n,q = map(int,input().split())
8 3
s = input()
ACACTACG
lr = list(list(map(int,input().split())) for i in range(q))
3 7
2 3
1 8

x = [0]*(n-1)
for i in range(n):
    if s[i] == 'A' and s[i+1] == 'C':
        x[i] = 1

for i in range(q):
    print(sum(x[(lr[i][0]-1):(lr[i][1]-1)]))


Fixed submission:
n,q = map(int,input().split())
s = input()
lr = list(list(map(int,input().split())) for i in range(q))

x = [0]*(n)
for i in range(n-1):
    if s[i] == 'A':
        if s[i+1] == 'C':
            x[i+1] = x[i] + 1
        else:
            x[i+1] = x[i]
    else:
        x[i+1] = x[i]

for i in range(q):
    print(x[lr[i][1]-1]-x[lr[i][0]-1])

Buggy python submission (verdict: Runtime Error):
n,q = map(int,input().split())
s = input()
lr = list(list(map(int,input().split())) for i in range(q))

x = [0]*(n-1)
for i in range(n):
    if s[i] == 'A' and s[i+1] == 'C':
        x[i] = 1

for i in range(q):
    print(sum((x[(lr[i][0]-1):(lr[i][1]-1)])))


Fixed submission:
n,q = map(int,input().split())
s = input()
lr = list(list(map(int,input().split())) for i in range(q))

x = [0]*(n)
for i in range(n-1):
    if s[i] == 'A':
        if s[i+1] == 'C':
            x[i+1] = x[i] + 1
        else:
            x[i+1] = x[i]
    else:
        x[i+1] = x[i]

for i in range(q):
    print(x[lr[i][1]-1]-x[lr[i][0]-1])