Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
N, X, Y = [int(i) for i in input().split()]
X, Y = X-1, Y-1

dd = defaultdict(int)
for i in range(N):
    for j in range(N):
        ans = min(abs(j - i),
                  abs(X - i)+1+abs(j-Y),
                  abs(Y - i)+1+abs(j-X))
        dd[ans] += 1

for i in range(1, N):
    print(dd[i] // 2)


Fixed submission:
from collections import defaultdict
N, X, Y = [int(i) for i in input().split()]
X, Y = X-1, Y-1

dd = defaultdict(int)
for i in range(N):
    for j in range(N):
        ans = min(abs(j - i),
                  abs(X - i)+1+abs(j-Y),
                  abs(Y - i)+1+abs(j-X))
        dd[ans] += 1

for i in range(1, N):
    print(dd[i] // 2)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
reverseFlag = False


def getQuery():
    yield input().split()


for _ in range(q):
    for query in getQuery():
        if query[0] == "1":
            reverseFlag = not reverseFlag
        else:
            if query[1] == "1":
                s = (s + query[2]) if reverseFlag else (query[2] + s)
            else:
                s = (query[2] + s) if reverseFlag else (s + query[2])

if reverseFlag:
    s = s[::-1]

print(s)


Fixed submission:
from collections import deque

s = input()
q = int(input())
d = deque(s)
reverseFlag = False


def getQuery():
    yield input().split()


for _ in range(q):
    for query in getQuery():
        if query[0] == "1":
            reverseFlag = not reverseFlag
        else:
            if query[1] == "1":
                if reverseFlag:
                    d.append(query[2])
                else:
                    d.appendleft(query[2])
            else:
                if reverseFlag:
                    d.appendleft(query[2])
                else:
                    d.append(query[2])

ans = "".join(d)
if reverseFlag:
    ans = ans[::-1]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())


def getQuery():
    yield input().split()


for _ in range(q):
    for query in getQuery():
        if query[0] == "1":
            s = s[::-1]
        else:
            if query[1] == "1":
                s = query[2] + s
            else:
                s += query[2]

print(s)


Fixed submission:
from collections import deque

s = input()
q = int(input())
d = deque(s)
reverseFlag = False


def getQuery():
    yield input().split()


for _ in range(q):
    for query in getQuery():
        if query[0] == "1":
            reverseFlag = not reverseFlag
        else:
            if query[1] == "1":
                if reverseFlag:
                    d.append(query[2])
                else:
                    d.appendleft(query[2])
            else:
                if reverseFlag:
                    d.appendleft(query[2])
                else:
                    d.append(query[2])

ans = "".join(d)
if reverseFlag:
    ans = ans[::-1]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
AList = list(map(int, input().split()))

def getNum(a, b):
    while(True):
        a, b = max(a, b), min(a, b)
        if a == b:
            return a
        a -= b

leftGBC, rightGBC= [AList[0]], [AList[-1]]
for i in range(1, N):
    leftGBC.append(getNum(leftGBC[i - 1], AList[i]))
for i in range(1, N):
    rightGBC.append(getNum(rightGBC[i - 1], AList[N - i - 1]))

rightGBC.reverse()

ans = max(leftGBC[-2], rightGBC[1])
for i in range(0, N-2):
    ans = max(getNum(leftGBC[i], rightGBC[i + 2]), ans)

print(ans)



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

def getNum(a, b):
    while(True):
        if a == 0:
            return b
        a, b = max(a, b), min(a, b)
        a %= b

leftGBC, rightGBC= [AList[0]], [AList[-1]]
for i in range(1, N):
    leftGBC.append(getNum(leftGBC[i - 1], AList[i]))
for i in range(1, N):
    rightGBC.append(getNum(rightGBC[i - 1], AList[N - i - 1]))

rightGBC.reverse()

ans = max(leftGBC[-2], rightGBC[1])
for i in range(0, N-2):
    ans = max(getNum(leftGBC[i], rightGBC[i + 2]), ans)

print(ans)

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

def getNum(a, b):
    if a == b:
        return a
    while(True):
        a, b = max(a, b), min(a, b)
        a -= b
        if a == b:
            return a

ansList = []
for i in range(0, N-1):
    ansList.append(getNum(AList[i], AList[i+1]))

print(sorted(ansList, reverse=False)[1])


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

def getNum(a, b):
    while(True):
        if a == 0:
            return b
        a, b = max(a, b), min(a, b)
        a %= b

leftGBC, rightGBC= [AList[0]], [AList[-1]]
for i in range(1, N):
    leftGBC.append(getNum(leftGBC[i - 1], AList[i]))
for i in range(1, N):
    rightGBC.append(getNum(rightGBC[i - 1], AList[N - i - 1]))

rightGBC.reverse()

ans = max(leftGBC[-2], rightGBC[1])
for i in range(0, N-2):
    ans = max(getNum(leftGBC[i], rightGBC[i + 2]), ans)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
X, Y, Z, K = [int(i) for i in input().split()]
ABCList = [sorted([int(i) for i in input().split()], reverse=True) for _ in range(3)]

ABSum = sorted([i + j for i in ABCList[0] for j in ABCList[1]], reverse=True)[:K]
for ans in sorted([i + j for i in ABSum for j in ABCList[2]], reverse=True)[:K]:
    print(ans)


Fixed submission:
X, Y, Z, K = [int(i) for i in input().split()]
ABCList = [sorted([int(i) for i in input().split()], reverse=True) for _ in range(3)]

ansList = []
for i, A in enumerate(ABCList[0]):
    for j, B in enumerate(ABCList[1]):
        for k, C in enumerate(ABCList[2]):
            if (i + 1) * (j + 1) * (k + 1) <= K:
                ansList.append(A + B + C)
            else:
                break

for ans in sorted(ansList, reverse=True)[:K]:
    print(ans)
Buggy python submission (verdict: Runtime Error):
N, Q = [int(i) for i in input().split()]
S = input()
tdList = reversed([input().split() for _ in range(Q)])

l, r = 0, N - 1
lList, rList = [], []
n_lFlag, n_rFlag = False, False
for td in tdList:
    if td[0] == S[l] and td[1] == "L":
        l += 1
        n_lFlag = True
    elif td[0] == S[r] and td[1] == "R":
        r -= 1
        n_rFlag = True
    if n_lFlag and S[l - 1] == td[0] and td[1] == "R":
        l -= 1
    if n_rFlag and S[r + 1] == td[0] and td[1] == "L":
        r += 1
    if l == N - 1 or r == 0:
        break

ans = 0
if r >= l:
    ans = r - l + 1

print(ans)



Fixed submission:
N, Q = [int(i) for i in input().split()]
S = input()
tdList = reversed([input().split() for _ in range(Q)])

l, r = 0, N - 1
lList, rList = [], []
for td in tdList:
    if td[0] == S[l] and td[1] == "L":
        l += 1
    elif td[0] == S[r] and td[1] == "R":
        r -= 1
    if l != 0 and S[l - 1] == td[0] and td[1] == "R":
        l -= 1
    if r != N - 1 and S[r + 1] == td[0] and td[1] == "L":
        r += 1
    if l > N - 1 or r < 0:
        break

ans = 0
if r >= l:
    ans = r - l + 1

print(ans)

Buggy python submission (verdict: Runtime Error):
N, Q = [int(i) for i in input().split()]
S = input()
tdList = reversed([input().split() for _ in range(Q)])

l, r = 0, N - 1
lList, rList = [], []
n_lFlag, n_rFlag = False, False
for td in tdList:
    if td[0] == S[l] and td[1] == "L":
        l += 1
        n_lFlag = True
    elif td[0] == S[r] and td[1] == "R":
        r -= 1
        n_rFlag = True
    if n_lFlag and S[l - 1] == td[0] and td[1] == "R":
        l -= 1
    if n_rFlag and S[r + 1] == td[0] and td[1] == "L":
        r += 1
    if l == N - 1 or r == 0:
        break

ans = 0
if r >= l:
    ans = r - l + 1

print(ans)



Fixed submission:
N, Q = [int(i) for i in input().split()]
S = input()
tdList = reversed([input().split() for _ in range(Q)])

l, r = 0, N - 1
lList, rList = [], []
for td in tdList:
    if td[0] == S[l] and td[1] == "L":
        l += 1
    elif td[0] == S[r] and td[1] == "R":
        r -= 1
    if l != 0 and S[l - 1] == td[0] and td[1] == "R":
        l -= 1
    if r != N - 1 and S[r + 1] == td[0] and td[1] == "L":
        r += 1
    if l > N - 1 or r < 0:
        break

ans = 0
if r >= l:
    ans = r - l + 1

print(ans)

Buggy python submission (verdict: Runtime Error):
N, Q = [int(i) for i in input().split()]
S = input()
tdList = reversed([input().split() for _ in range(Q)])

l, r = 0, len(S) - 1
for td in tdList:
    if td[0] == S[l] and td[1] == "L":
        l += 1
    elif td[0] == S[r] and td[1] == "R":
        r -= 1

print(r - l + 1)


Fixed submission:
N, Q = [int(i) for i in input().split()]
S = input()
tdList = reversed([input().split() for _ in range(Q)])

l, r = 0, N - 1
lList, rList = [], []
for td in tdList:
    if td[0] == S[l] and td[1] == "L":
        l += 1
    elif td[0] == S[r] and td[1] == "R":
        r -= 1
    if l != 0 and S[l - 1] == td[0] and td[1] == "R":
        l -= 1
    if r != N - 1 and S[r + 1] == td[0] and td[1] == "L":
        r += 1
    if l > N - 1 or r < 0:
        break

ans = 0
if r >= l:
    ans = r - l + 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, X = [int(i) for i in input().split()]
sList = [int(i) for i in input().split()]
sList.sort(reverse=True)
mod = 10 ** 9 + 7

dp = [0 for _ in range(X + 1)]
dp[X] = 1
for i, s in enumerate(sList):
    new_dp = [0 for _ in range(X + 1)]
    for x in range(X + 1):
        new_dp[x] += dp[x] * (N - i - 1)
        new_dp[x] %= mod
        new_dp[x % s] += dp[x]
        new_dp[x % s] %= mod
    dp = new_dp

ans = 0
for i in range(len(dp)):
    ans += i * dp[i]
    ans %= mod

print(ans)

Fixed submission:
from collections import defaultdict as dd

N, X = [int(i) for i in input().split()]
sList = [int(i) for i in input().split()]
sList.sort(reverse=True)
mod = 10 ** 9 + 7

dp = dd(int)
dp[X] = 1
for i, s in enumerate(sList):
    new_dp = dd(int)
    for x in dp:
        new_dp[x] += dp[x] * (N - i - 1)
        new_dp[x] %= mod
        new_dp[x % s] += dp[x]
        new_dp[x % s] %= mod
    dp = new_dp

ans = 0
for x in dp:
    ans += x * dp[x]
    ans %= mod

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

def calc(a, b):
    while(a != b):
        largeNum = max(a, b)
        smallNum = min(a, b)
        largeNum -= smallNum
        a = largeNum
        b = smallNum
    return a

ans = 1
for i in range(0, N - 1):
    a = calc(A[i], A[i+1])
    A[i], A[i+1] = a, a
    if a == 1:
        break
else:
    ans = min(A)

print(ans)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
A.sort(reverse = True)

def calc(a, b):
    largeNum = max(a, b)
    smallNum = min(a, b)
    while(largeNum != 0 and smallNum != 0):
        largeNum %= smallNum
        x = largeNum
        largeNum = smallNum
        smallNum = x
    return max(smallNum, largeNum)

ans = 1
for i in range(0, N - 1):
    a = calc(A[i], A[i+1])
    A[i], A[i+1] = a, a
    if a == 1:
        break
else:
    ans = min(A)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = list(map(int, input().split()))
hList = list(map(int, input().split()))

dp = [float("inf")] * N
dp[0] = 0
for i in range(N):
    for j in range(1, K + 1):
        if j > i:
            break
        dp[i] = min(dp[i - j] + abs(hList[i] - hList[i - j]), dp[i])

print(dp[N - 1])


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

dp = [float("inf")] * N
dp[0] = 0
for i in range(N):
    for j in range(1, K + 1):
        if j > i:
            break
        dp[i] = min(dp[i - j] + abs(hList[i] - hList[i - j]), dp[i])

print(dp[N - 1])

Buggy python submission (verdict: Time Limit Exceeded):
N, K = [int(i) for i in input().split()]
hList = [int(i) for i in input().split()]

dp = [float("inf") for _ in range(N)]
dp[0] = 0
for i in range(N):
    for j in range(1, K + 1):
        if j > i:
            break
        dp[i] = min(dp[i - j] + abs(hList[i] - hList[i - j]), dp[i])

print(dp[N - 1])


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

dp = [float("inf")] * N
dp[0] = 0
for i in range(N):
    for j in range(1, K + 1):
        if j > i:
            break
        dp[i] = min(dp[i - j] + abs(hList[i] - hList[i - j]), dp[i])

print(dp[N - 1])
Buggy python submission (verdict: Runtime Error):
import numpy as np

N, W = map(int, input().split())

dp = np.ones([2, N * 10 ** 3 + 1], dtype=int) * float("inf")
dp[0][0], dp[1][0] = 0, 0
for i in range(N):
    index = i % 2
    w, v = map(int, input().split())
    for j in range(1, len(dp[0])):
        if j <= v:
            dp[index][j] = min(w, dp[index-1][j])
        else:
            dp[index][j] = min(w + dp[index-1][j-v], dp[index-1][j])

dp = np.minimum(dp[0], dp[1])
ans = 0
for i, w in enumerate(dp):
    if w <= W:
        ans = max(ans, i)
    else:
        break

print(ans)


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

dp = [[float("inf")] * (N * 10 ** 3 + 1) for _ in range(2)]
dp[0][0], dp[1][0] = 0, 0
for i in range(N):
    index = i % 2
    w, v = map(int, input().split())
    for j in range(1, len(dp[0])):
        if j <= v:
            dp[index][j] = min(w, dp[index-1][j])
        else:
            dp[index][j] = min(w + dp[index-1][j-v], dp[index-1][j])

ans = 0
for i, w in enumerate(dp[N % 2 - 1]):
    if w <= W:
        ans = max(ans, i)
    else:
        break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N, W = map(int, input().split())

dp = np.ones([2, N * 10 ** 3 + 1], dtype=int) * float("inf")
dp[0][0], dp[1][0] = 0, 0
for i in range(N):
    index = i % 2
    w, v = map(int, input().split())
    for j in range(1, len(dp[0])):
        if j <= v:
            dp[index][j] = min(w, dp[index-1][j])
        else:
            dp[index][j] = min(w + dp[index-1][j-v], dp[index-1][j])

dp = np.minimum(dp[0], dp[1])
ans = 0
for i, w in enumerate(dp):
    if w <= W:
        ans = max(ans, i)
    else:
        break

print(ans)

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

dp = [[float("inf")] * (N * 10 ** 3 + 1) for _ in range(2)]
dp[0][0], dp[1][0] = 0, 0
for i in range(N):
    index = i % 2
    w, v = map(int, input().split())
    for j in range(1, len(dp[0])):
        if j <= v:
            dp[index][j] = min(w, dp[index-1][j])
        else:
            dp[index][j] = min(w + dp[index-1][j-v], dp[index-1][j])

ans = 0
for i, w in enumerate(dp[N % 2 - 1]):
    if w <= W:
        ans = max(ans, i)
    else:
        break

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
N, M = [int(i) for i in input().split()]

ans = 1
for i in range(N, M):
    if M % i == 0:
        ans = M / i
        break

print(int(ans))

Fixed submission:
import math
N, M = [int(i) for i in input().split()]

ans = 1
sosu = True if M % 2 == 1 else False

if M % 2 == 1:
    sqrt = int(math.ceil(math.sqrt(M)))
    for i in range(3, sqrt, 2):
        if M % i == 0:
            sosu = False
            break

if sosu == False:
    for i in range(N, M):
        if M % i == 0:
            ans = M / i
            break


print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
import math
N, M = [int(i) for i in input().split()]

ans = 1
for i in range(1, math.ceil(M / N) + 1):
    if M % i == 0 and M / i >= N:
        ans = i

print(ans)

Fixed submission:
import math
N, M = [int(i) for i in input().split()]

ans = 1
sosu = True if M % 2 == 1 else False

if M % 2 == 1:
    sqrt = int(math.ceil(math.sqrt(M)))
    for i in range(3, sqrt, 2):
        if M % i == 0:
            sosu = False
            break

if sosu == False:
    for i in range(N, M):
        if M % i == 0:
            ans = M / i
            break


print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N, M = [int(i) for i in input().split()]
A = np.cumsum(np.array(input().split(), dtype=int))
ans = 0

for first in range(N):
    for last in range(first, N):
        if first == last:
            if A[first] % M == 0:
                ans += 1
        else:
            if (A[last] - A[first]) % M == 0:
                ans += 1

print(ans)

Fixed submission:
import numpy as np

N, M = [int(i) for i in input().split()]
A = np.cumsum(np.array(input().split(), dtype=int)) % M
ans = 0

remainder = {}
for i in A:
    if i in remainder:
        remainder[i] += 1
    else:
        remainder[i] = 1

for key in remainder:
    ans += remainder[key] * (remainder[key] - 1) / 2

ans += remainder[0] if 0 in remainder else 0
print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
NM = [int(i) for i in input().split()]
N, M = NM[0], NM[1]
abList = [[int(i) for i in input().split()] for _ in range(M)]

ans = 0

while(True):
    bridgeDic = {}
    for ab in abList:
        if ab != None:
            for i in range(ab[0], ab[1]):
                if i in bridgeDic:
                    bridgeDic[i] += 1
                else:
                    bridgeDic[i] = 1

    largeNum = 0
    largeKey = 0
    for i in bridgeDic:
        if bridgeDic[i] > largeNum:
            largeNum = bridgeDic[i]
            largeKey = i

    ans += 1
    M -= bridgeDic[largeKey]
    if M <= 0:
        break

    for i in range(len(abList)):
        if abList[i] != None and abList[i][0] <= largeKey < abList[i][1]:
            abList[i] = None

print(ans)

Fixed submission:
NM = [int(i) for i in input().split()]
N, M = NM[0], NM[1]
abList = sorted([[int(i) for i in input().split()] for _ in range(M)], key=lambda x: x[1])
bridge = 0
ans = 0

for ab in abList:
    if not ab[0] <= bridge < ab[1]:
        bridge = ab[1] - 1
        ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8

N = int(input())
S = input()
ans = N

for reader in range(N):
    changer = 0
    for i in range(N):
        if (reader < i and S[i] == "E")\
        or (reader > i and S[i] == "W"):
            changer += 1
    if changer < ans:
        ans = changer

print(ans)

Fixed submission:
N = int(input())
S = input()
ans = 0

for i in range(N):
    if S[i] == "E":
        ans += 1
min_ans = ans

for reader in range(1, N):
    minus = 0
    if S[reader] == "E":
        minus = 1
    if S[reader - 1] == "W":
        ans += 1
    elif S[reader - 1] == "E":
        ans -= 1
    if ans - minus < min_ans:
        min_ans = ans - minus
        count = reader

print(min_ans)
Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8

N = int(input())
A = [int(i) for i in input().split()]
ans = N

for i in range(N - 1):
    left = A[i]
    right = A[i]
    for j in range(i + 1, N):
        left ^= A[j]
        right += A[j]
        if left == right:
            ans += 1
        else:
            break

print(ans)


Fixed submission:
#coding:utf-8

N = int(input())
A = [int(i) for i in input().split()]
ans = 0
formula1 = 0
formula2 = 0
lastRight = 0

for left in range(N):
    rightOut = False
    if left > 0:
        formula1 ^= A[left - 1]
        formula2 -= A[left - 1]
    for right in range(lastRight, N):
        formula1 ^= A[right]
        formula2 += A[right]
        if formula1 != formula2:
            rightOut = True
            formula1 ^= A[right]
            formula2 -= A[right]
            break

    lastRight = max(left, right - rightOut) + 1
    ans += lastRight - left
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8

N = int(input())
A = [int(i) for i in input().split()]
ans = N
left = 0
right = 0

for i in range(N):
    left ^= A[i]
    right += A[i]
    for j in range(i + 1, N):
        left ^= A[j]
        right += A[j]
        if left == right:
            ans += 1
    left = 0
    right = 0

print(ans)

Fixed submission:
#coding:utf-8

N = int(input())
A = [int(i) for i in input().split()]
ans = 0
formula1 = 0
formula2 = 0
lastRight = 0

for left in range(N):
    rightOut = False
    if left > 0:
        formula1 ^= A[left - 1]
        formula2 -= A[left - 1]
    for right in range(lastRight, N):
        formula1 ^= A[right]
        formula2 += A[right]
        if formula1 != formula2:
            rightOut = True
            formula1 ^= A[right]
            formula2 -= A[right]
            break

    lastRight = max(left, right - rightOut) + 1
    ans += lastRight - left
print(ans)
Buggy python submission (verdict: Runtime Error):
"""
F
"""
N=int(input())
A=list(map(int,input().split()))

left=[0]*N
right=[0]*N

left[0]=A[0]
left[1]=A[1]
for i in range(2,N):
    left[i]=A[i]+left[i-2]
right[-1]=A[-1]
right[-2]=A[-2]
for i in range(N-3,-1,-1):
    right[i]=A[i]+right[i+2]

ans=0
if N%2==0:
    ans=max(right[0],left[-1])
    for i in range(N-2):
        if i%2==0:
            continue
        ans=max(ans,left[i]+right[i+2])
    num=9/0
else:
    P=[0]*N
    Q=[0]*N
    P[-2]=A[-2]
    Q[-2]=A[-1]
    for i in range(-4,-N-1,-1):
        if i%2==0:
            P[i]=A[i]+max(P[i+2],Q[i+2])
            Q[i]=A[i+1]+Q[i+2]

    data=[0]*N
    for i in range(N):
        data[i]=max(P[i],Q[i])
    
    qqq=0
    for i in range(N-2):
        if i%2==0:
            #使わない
            ans=max(ans,qqq+data[i+1])
            qqq+=A[i]
    ans=max(ans,qqq)
    
print(ans)

Fixed submission:
N=int(input())
A=[0]+list(map(int,input().split()))

dp=[[0]*(N+1) for i in range(3)]

dp[0][1]=-float("inf")
dp[2][1]=A[1]
dp[0][2]=0
dp[1][2]=max(A[1],A[2])
dp[2][2]=-float("inf")

for i in range(3,N+1):
    if i%2==1:
        for j in range(3):
            dp[j][i]=max(dp[j][i-2]+A[i],dp[j][i-1])
    else:
        for j in range(2):
            dp[j][i]=max(dp[j][i-2]+A[i],dp[j+1][i-1])
        dp[2][i]=dp[2][i-2]+A[i]

print(dp[1][N])
Buggy python submission (verdict: Runtime Error):
import sys

N,K,C=map(int,input().split())

S=list(input())
left=[0]*N
right=[0]*N

if S[0]=="o":
    left[0]=1
for i in range(1,C+1):
    left[i]=left[i-1]
    if S[i]=="o":
        left[i]=1
for i in range(C+1,N):
    if S[i]=="o":
        left[i]=max(left[i-1],left[i-C-1]+1)
    else:
        left[i]=left[i-1]

if S[-1]=="o":
    right[-1]=1
for i in range(N-2,N-C-2,-1):
    right[i]=right[i+1]
    if S[i]=="o":
        right[i]=1
for i in range(N-C-2,-1,-1):
    if S[i]=="o":
        right[i]=max(right[i+1],right[i+C+1]+1)
    else:
        right[i]=right[i+1]

data=[]
for i in range(N):
    if S[i]=="o":
        L=i-C-1
        R=i+C+1
        num=1
        if L>=0:
            num+=left[L]
        if R<N:
            num+=right[R]
        if num>K:
            sys.exit()
        if num==K:
            data.append(i)

for i in range(len(data)):
    if i==0:
        if data[i+1]-data[i]>C:
            print(data[i]+1)
    elif i==len(data)-1:
        if data[i]-data[i-1]>C:
            print(data[i]+1)
    else:
        if data[i+1]-data[i]>C and data[i]-data[i-1]>C:
            print(data[i]+1)
            

Fixed submission:
import sys

N,K,C=map(int,input().split())

S=list(input())
if C>=N-1:
    if K==1:
        if S.count("o")>=2:
            sys.exit()
        else:
            print(S.index("o")+1)
            sys.exit()
    else:
        sys.exit()
    
    
left=[0]*N
right=[0]*N

if S[0]=="o":
    left[0]=1
for i in range(1,C+1):
    left[i]=left[i-1]
    if S[i]=="o":
        left[i]=1
for i in range(C+1,N):
    if S[i]=="o":
        left[i]=max(left[i-1],left[i-C-1]+1)
    else:
        left[i]=left[i-1]

if S[-1]=="o":
    right[-1]=1
for i in range(N-2,N-C-2,-1):
    right[i]=right[i+1]
    if S[i]=="o":
        right[i]=1
for i in range(N-C-2,-1,-1):
    if S[i]=="o":
        right[i]=max(right[i+1],right[i+C+1]+1)
    else:
        right[i]=right[i+1]

data=[]
for i in range(N):
    if S[i]=="o":
        L=i-C-1
        R=i+C+1
        num=1
        if L>=0:
            num+=left[L]
        if R<N:
            num+=right[R]
        if num>K:
            sys.exit()
        if num==K:
            data.append(i)

for i in range(len(data)):
    if i==0:
        if data[i+1]-data[i]>C:
            print(data[i]+1)
    elif i==len(data)-1:
        if data[i]-data[i-1]>C:
            print(data[i]+1)
    else:
        if data[i+1]-data[i]>C and data[i]-data[i-1]>C:
            print(data[i]+1)