Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
S = input()

count = 0

for i  in range(n-2):
	for j in range(i+1, n-1):
		for k in range(j+1, n):
			if S[i] != S[j] and S[j] != S[k] and S[i] != S[k] and (j-i) != (k-j):
				count += 1

print(count)


Fixed submission:
n = int(input())
S_list = list(input())

rsum = 0
gsum = 0
bsum = 0

for s in S_list:
	if s == "R":
		rsum += 1
	elif s == "G":
		gsum += 1
	elif s == "B":
		bsum += 1

sum = rsum * gsum * bsum

for i in range(n-2):
	p = (n-i-1) // 2
	for j in range(1,p+1):
		if S_list[i] != S_list[i+j] and S_list[i+2*j]  != S_list[i+j] and S_list[i] != S_list[i+2*j]:
			sum -= 1

print(sum)
Buggy python submission (verdict: Runtime Error):
import queue

def push(n, dist, dist_list):
	if dist_list[n] > dist:
		dist_list[n] = dist
		q.put(n)



q = queue.Queue()
n, x, y = [int(i) for i in input().split()]
result = [0] * (n-1)

for p in range(n):
	dist_list = [111111] * n
	dist = 0
	q.put(p)
	dist_list[p] = dist 
	while not q.empty():
		p = q.get()
		dist = dist_list[p]
		if p+1 < n: push(p+1, dist+1, dist_list)
		if p-1 >= 0: push(p-1, dist+1, dist_list)
		if p == (x-1): push(y-1, dist+1, dist_list)
		if p == (y-1): push(x-1, dist+1, dist_list)
	
	for i in dist_list:
		if i != 0:
			result[i-1] += 1

for ans in result:
	print(ans//2)
		






Fixed submission:
S = input()
if S[2] == S[3] and S[4] == S[5]:
	print("Yes")
else:
	print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

count = [0 for _ in range(200000)]
line = [int(i) for i in input().split()]
index = []

for i in line:
	# if count[i] == 0:
		# index.append(i)
	count[i] += 1


for i in line:
	count[i] -= 1
	result = 0
	for j in range(200000):
		result += (count[j]*(count[j]-1))//2
	count[i] += 1
	print(result) 


Fixed submission:
N = int(input())

count = [0 for _ in range(200000)]
line = [int(i) for i in input().split()]
pattern = [0 for _ in range(200000)]
sum = 0
# index = []

for i in line:
	# if count[i] == 0:
		# index.append(i)
	count[i] += 1

for num in count:
	sum += (num*(num-1))//2



for i in line:
	if count[i] > 2:
		result = sum - (count[i]-1) 
	elif count[i] == 2:
		result = sum - 1
	elif count[i] == 1:
		result = sum
	print(result)

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

count = [0 for _ in range(200000)]
line = [int(i) for i in input().split()]
index = []

for i in line:
	if count[i] == 0:
		index.append(i)
	count[i] += 1


for i in line:
	count[i] -= 1
	result = 0
	for j in index:
		result += (count[j]*(count[j]-1))//2
	count[i] += 1
	print(result) 


Fixed submission:
N = int(input())

count = [0 for _ in range(200000)]
line = [int(i) for i in input().split()]
pattern = [0 for _ in range(200000)]
sum = 0
# index = []

for i in line:
	# if count[i] == 0:
		# index.append(i)
	count[i] += 1

for num in count:
	sum += (num*(num-1))//2



for i in line:
	if count[i] > 2:
		result = sum - (count[i]-1) 
	elif count[i] == 2:
		result = sum - 1
	elif count[i] == 1:
		result = sum
	print(result)
Buggy python submission (verdict: Time Limit Exceeded):
s_list = list(input())
q = int(input())
reverse = False

for _ in range(q):
	query= input().split()
	if int(query[0]) == 1:
		if reverse: reverse = False
		else: reverse = True
	elif int(query[0]) == 2:
		if int(query[1]) == 1:
			if reverse:
				s_list.append(query[2])
			else:
				s_list.insert(0, query[2])
		elif int(query[1]) == 2:
			if reverse:
				s_list.insert(0, query[2])
			else:	
				s_list.append(query[2])


if reverse:
	s_list.reverse()
for s in s_list:
  print(s, end ="")



Fixed submission:
from collections import deque

s_list = list(input())
d = deque(s_list)
q = int(input())
reverse = False

for _ in range(q):
	query= input().split()
	if int(query[0]) == 1:
		if reverse: reverse = False
		else: reverse = True
	elif int(query[0]) == 2:
		if int(query[1]) == 1:
			if reverse:
				d.append(query[2])
			else:
				d.appendleft(query[2])
		elif int(query[1]) == 2:
			if reverse:
				d.appendleft(query[2])
			else:	
				d.append(query[2])


if reverse:
	d.reverse()
for s in d:
  print(s, end ="")

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


for _ in range(q):
	query= input().split()
	if int(query[0]) == 1:
		s_list.reverse()
	elif int(query[0]) == 2:
		if int(query[1]) == 1:
			s_list.insert(0, query[2])
		elif int(query[1]) == 2:
			s_list.append(query[2])

for s in s_list:
  print(s, end ="")



Fixed submission:
from collections import deque

s_list = list(input())
d = deque(s_list)
q = int(input())
reverse = False

for _ in range(q):
	query= input().split()
	if int(query[0]) == 1:
		if reverse: reverse = False
		else: reverse = True
	elif int(query[0]) == 2:
		if int(query[1]) == 1:
			if reverse:
				d.append(query[2])
			else:
				d.appendleft(query[2])
		elif int(query[1]) == 2:
			if reverse:
				d.appendleft(query[2])
			else:	
				d.append(query[2])


if reverse:
	d.reverse()
for s in d:
  print(s, end ="")

Buggy python submission (verdict: Time Limit Exceeded):
string_list = list(input())
n = int(input())

for i in range(n):
  line = list(input().split())
  if int(line[0]) == 1:
    string_list.reverse()
  elif int(line[0]) == 2:
    if int(line[1]) == 1:
      string_list = [line[2]]+ string_list
    elif int(line[1]) == 2:
      string_list.append(line[2])
for s in string_list:
  print(s, end ="")


Fixed submission:
from collections import deque

s_list = list(input())
d = deque(s_list)
q = int(input())
reverse = False

for _ in range(q):
	query= input().split()
	if int(query[0]) == 1:
		if reverse: reverse = False
		else: reverse = True
	elif int(query[0]) == 2:
		if int(query[1]) == 1:
			if reverse:
				d.append(query[2])
			else:
				d.appendleft(query[2])
		elif int(query[1]) == 2:
			if reverse:
				d.appendleft(query[2])
			else:	
				d.append(query[2])


if reverse:
	d.reverse()
for s in d:
  print(s, end ="")
Buggy python submission (verdict: Runtime Error):
number = []
result = "No"

for i in range(3):
	for n in input().split():
		n = int(n)
		number.append(n)

bingo = [None for _ in range(9)]

N  = int(input())
for i in range(N):
	b = int(input())
	for j in range(9):
		if b == number[j]:
			bingo[j] = True


for i in range(3):
	if bingo[3*i] == bingo[3*i+1] and bingo[3*i+1] == bingo[3*i+2] and bingo[3*i] == True:
		result = "Yes"

for i in range(3):
	if bingo[i] == bingo[3+i] and bingo[3+i] == bingo[6+i] and bingo[i] == True:
		result = "Yes"

if bingo[0] == bingo[4] and bingo[4] == bingo[8] and bingo[0] == True:
	result = "Yes"

if bingo[2] == bingo[4] and bingo[4] == bingo[6] and bingo[2] == True:
	result = "Yes"

print(result)


Fixed submission:
N = int(input())
print((N+1)//2)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
tvote = 1
avote = 1

for i in range(n):
	t, a = [int(n) for n in input().split()]
	num = 1
	while True:
		tnow = num*t
		anow = num*a
		if tnow >= tvote and anow >= avote:
			tvote = tnow
			avote = anow
			break
		num += 1
	
print(tvote+avote)




Fixed submission:
n = int(input())
tvote = 1
avote = 1

for i in range(n):
	t, a = [int(n) for n in input().split()]
	k = (tvote-1)//t + 1
	tnow = t * k
	anow = a * k
	if avote > anow:
		k = (avote-1)//a + 1
		tnow = t * k
		anow = a * k
	tvote = tnow
	avote = anow
	
print(avote+tvote)
Buggy python submission (verdict: Runtime Error):
n, a = [int(i) for i in input().split()]
x = [int(i)-a for i in input().split()] 

max = max(x)

dp = [[0 for _ in range(2*n*max+1)] for _ in range(n+1)]

dp[0][n*max] = 1 

for i in range(1, n+1):
	for j in range(2*n*max+1):
		if j - x[i-1] < 0 or j - x[i-1] > 2*n*max:
			dp[i][j] = dp[i-1][j]
		else: 
			dp[i][j] = dp[i-1][j] + dp[i-1][j-x[i-1]]

print(dp[n][n*max]-1)







Fixed submission:
n, a = [int(i) for i in input().split()]

x = [int(i) for i in input().split()] 
y = [int(i)-a for i in x] 


max = max(x)

dp = [[0 for _ in range(2*n*max+1)] for _ in range(n+1)]

dp[0][n*max] = 1 

for i in range(1, n+1):
	for j in range(2*n*max+1):
		if j - y[i-1] < 0 or j - y[i-1] > 2*n*max:
			dp[i][j] = dp[i-1][j]
		else: 
			dp[i][j] = dp[i-1][j] + dp[i-1][j-y[i-1]]

result = dp[n][n*max]-1

print(result)

Buggy python submission (verdict: Runtime Error):
n, a = [int(i) for i in input().split()]
x = [int(i)-a for i in input().split()] 

max = max(x)

dp = [[0 for _ in range(2*n*max+1)] for _ in range(n+1)]

dp[0][n*max] = 1 

for i in range(1, n+1):
	for j in range(2*n*max+1):
		if j - x[i-1] < 0 or j - x[i-1] > 2*n*max:
			dp[i][j] = dp[i-1][j]
		else: 
			dp[i][j] = dp[i-1][j] + dp[i-1][j-x[i-1]]

print(dp[n][n*max]-1)







# # def function(i, j, x):
# 	print(0)
# 	if i == 0 and j == 0:
# 		return 1
# 	elif i == 0 and j == x[0]:
# 		return 1
# 	else:
# 		return function(i-1, j, x) + function(i-1, j-x[i], x)

Fixed submission:
n, a = [int(i) for i in input().split()]

x = [int(i) for i in input().split()] 
y = [int(i)-a for i in x] 


max = max(x)

dp = [[0 for _ in range(2*n*max+1)] for _ in range(n+1)]

dp[0][n*max] = 1 

for i in range(1, n+1):
	for j in range(2*n*max+1):
		if j - y[i-1] < 0 or j - y[i-1] > 2*n*max:
			dp[i][j] = dp[i-1][j]
		else: 
			dp[i][j] = dp[i-1][j] + dp[i-1][j-y[i-1]]

result = dp[n][n*max]-1

print(result)

Buggy python submission (verdict: Runtime Error):
n, a = [int(i) for i in input().split()]
x = [int(i)-a for i in input().split()] 

max = max(x)

dp = [[0 for _ in range(2*n*max)] for _ in range(n)]

dp[0][n*max+x[0]] = 1
dp[0][n*max] = 1 

for i in range(1, n):
	for j in range(2*n*max):
		if j - x[i] < 0 or j - x[i] >= 2*n*max:
			dp[i][j] = dp[i-1][j]
		else: 
			dp[i][j] = dp[i-1][j] + dp[i-1][j-x[i]]

print(dp[n-1][n*max]-1)







# # def function(i, j, x):
# 	print(0)
# 	if i == 0 and j == 0:
# 		return 1
# 	elif i == 0 and j == x[0]:
# 		return 1
# 	else:
# 		return function(i-1, j, x) + function(i-1, j-x[i], x)

Fixed submission:
n, a = [int(i) for i in input().split()]

x = [int(i) for i in input().split()] 
y = [int(i)-a for i in x] 


max = max(x)

dp = [[0 for _ in range(2*n*max+1)] for _ in range(n+1)]

dp[0][n*max] = 1 

for i in range(1, n+1):
	for j in range(2*n*max+1):
		if j - y[i-1] < 0 or j - y[i-1] > 2*n*max:
			dp[i][j] = dp[i-1][j]
		else: 
			dp[i][j] = dp[i-1][j] + dp[i-1][j-y[i-1]]

result = dp[n][n*max]-1

print(result)
Buggy python submission (verdict: Runtime Error):
#! /usr/bin/env python3

import math


if __name__ == "__main__":
    A, B = input().split()
    print(math.floor(Decimal(A) * Decimal(B)))

Fixed submission:
import math
from decimal import Decimal, getcontext


A, B = input().split()
print(math.floor(Decimal(A) * Decimal(B)))
Buggy python submission (verdict: Time Limit Exceeded):
from numba import jit


@jit
def solve(X, Y, Z):
    while X >= 0:
        if 2 * X + 4 * Z == Y:
            return True
        elif 2 * X + 4 * Z < Y:
            X -= 1
            Z += 1
    return False


def main():
    X, Y = map(int, input().split())
    Z = 0

    if solve(X, Y, Z):
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Fixed submission:
from numba import jit


@jit
def solve(X, Y, Z):
    while X >= 0:
        if 2 * X + 4 * Z == Y:
            return True
        elif 2 * X + 4 * Z < Y:
            X -= 1
            Z += 1
        else:
            return False
    return False


def main():
    X, Y = map(int, input().split())
    Z = 0

    if solve(X, Y, Z):
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    X, Y = map(int, input().split())
    Z = 0

    while X >= 0:
        if 2 * X + 4 * Z == Y:
            print("Yes")
            return
        elif 2 * X + 4 * Z < Y:
            X -= 1
            Z += 1
    print("No")


if __name__ == "__main__":
    main()


Fixed submission:
from numba import jit


@jit
def solve(X, Y, Z):
    while X >= 0:
        if 2 * X + 4 * Z == Y:
            return True
        elif 2 * X + 4 * Z < Y:
            X -= 1
            Z += 1
        else:
            return False
    return False


def main():
    X, Y = map(int, input().split())
    Z = 0

    if solve(X, Y, Z):
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    A = list(map(int, input().split()))

    for i in range(1, N + 1):
        print(A.count(i))


if __name__ == "__main__":
    main()


Fixed submission:
from collections import Counter


def main():
    N = int(input())
    A = list(map(int, input().split()))

    c = Counter(A)

    for i in range(1, N + 1):
        print(c[i])


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque


def main():
    S = list(input())
    D = deque(S)
    Q = int(input())
    T = [tuple(map(str, input().split())) for _ in range(Q)]

    for t in T:
        if t[0] == "1":
            D.reverse()
        else:
            if t[1] == "1":
                D.appendleft(t[2])
            else:
                D.append(t[2])

    print("".join(D))


if __name__ == "__main__":
    main()


Fixed submission:
from collections import deque


def main():
    S = list(input())
    D = deque(S)
    Q = int(input())
    T = [tuple(map(str, input().split())) for _ in range(Q)]
    r = False

    for t in T:
        if t[0] == "1" and r == False:
            r = True
        elif t[0] == "1" and r == True:
            r = False
        else:
            if t[1] == "1" and r == False:
                D.appendleft(t[2])
            elif t[1] == "1" and r == True:
                D.append(t[2])
            elif t[1] == "2" and r == False:
                D.append(t[2])
            elif t[1] == "2" and r == True:
                D.appendleft(t[2])

    if r == False:
        print("".join(D))
    else:
        D.reverse()
        print("".join(D))


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    N, M = map(int, input().split())
    P = {tuple(map(int, input().split())) for _ in range(M)}
    P = sorted(P)
    ans = [0 for _ in range(N)]

    if N > 1 and (1, 0) in P:
        print(-1)
        return

    if N > 1 and P[0][0] != 1:
        ans[0] = 1

    for i in range(len(P) - 1):
        if P[i][0] == P[i + 1][0]:
            print(-1)
            return

    for p in P:
        ans[p[0] - 1] = p[1]

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


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    N, M = map(int, input().split())
    P = {tuple(map(int, input().split())) for _ in range(M)}
    P = sorted(P)
    ans = [0 for _ in range(N)]

    if N == 1 and M == 0:
        print(0)
        return

    if N == 2 and M == 0:
        print(10)
        return

    if N == 3 and M == 0:
        print(100)
        return

    if N > 1 and (1, 0) in P:
        print(-1)
        return

    if N > 1 and P[0][0] != 1:
        ans[0] = 1

    for i in range(len(P) - 1):
        if P[i][0] == P[i + 1][0]:
            print(-1)
            return

    for p in P:
        ans[p[0] - 1] = p[1]

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


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    N, M = map(int, input().split())
    P = {tuple(map(int, input().split())) for _ in range(M)}
    P = sorted(P)
    ans = [0 for _ in range(N)]

    if N > 1 and (1, 0) in P:
        print(-1)
        return

    if N > 1 and P[0][0] != 1:
        print(-1)
        return

    for i in range(len(P) - 1):
        if P[i][0] == P[i + 1][0]:
            print(-1)
            return

    for p in P:
        ans[p[0] - 1] = p[1]

    ans = map(str, ans)
    print("".join(ans))


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    N, M = map(int, input().split())
    P = {tuple(map(int, input().split())) for _ in range(M)}
    P = sorted(P)
    ans = [0 for _ in range(N)]

    if N == 1 and M == 0:
        print(0)
        return

    if N == 2 and M == 0:
        print(10)
        return

    if N == 3 and M == 0:
        print(100)
        return

    if N > 1 and (1, 0) in P:
        print(-1)
        return

    if N > 1 and P[0][0] != 1:
        ans[0] = 1

    for i in range(len(P) - 1):
        if P[i][0] == P[i + 1][0]:
            print(-1)
            return

    for p in P:
        ans[p[0] - 1] = p[1]

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


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, K = map(int, input().split())
    P = [(v + 1) / 2 for v in map(int, input().split())]

    ans = 0
    for i in range(N - K + 1):
        ans = max(ans, sum(P[i : i + K]))

    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    N, K = map(int, input().split())
    P = [(v + 1) / 2 for v in map(int, input().split())]

    ans = tmp = sum(P[0:K])
    for i in range(N - K):
        tmp = tmp - P[i] + P[i + K]
        ans = max(ans, tmp)

    print(ans)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def sigma(n):
    a = 0
    for i in range(1, n + 1):
        a += i
    return a


def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))

    a = []
    for p in P:
        a.append(sigma(p) / p)

    ans = 0
    for i in range(N - K + 1):
        ans = max(ans, sum(a[i : i + K]))

    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    N, K = map(int, input().split())
    P = [(v + 1) / 2 for v in map(int, input().split())]

    ans = tmp = sum(P[0:K])
    for i in range(N - K):
        tmp = tmp - P[i] + P[i + K]
        ans = max(ans, tmp)

    print(ans)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    P = list(map(int, input().split()))

    ans = 1

    for i in range(1, N):
        tmp = min(P[:i])
        if P[i] <= tmp:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    N = int(input())
    P = list(map(int, input().split()))

    ans = 1
    tmp = P[0]
    for i in range(1, N):
        if P[i] == 1:
            print(ans + 1)
            return

        tmp = min(tmp, P[i])
        if P[i] <= tmp:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import math


def main():
    A, B = map(int, input().split())

    print(A * B // math.gcd(A, B))


if __name__ == "__main__":
    main()


Fixed submission:
import fractions


def main():
    A, B = map(int, input().split())

    print(A * B // fractions.gcd(A, B))


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import itertools


def main():
    _ = int(input())
    L = list(map(int, input().split()))

    comb = itertools.combinations(L, 3)

    ans = 0
    dp = []
    for v in comb:
        if dp.__contains__(sum(v)):
            ans += 1
        elif v[0] < v[1] + v[2] and v[1] < v[2] + v[0] and v[2] < v[0] + v[1]:
            ans += 1
            dp.append(sum(v))

    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
import bisect


def main():
    N = int(input())
    L = list(map(int, input().split()))
    L.sort()

    ans = 0
    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            index = bisect.bisect_left(L, L[i] + L[j]) - j - 1
            ans += index

    print(ans)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import itertools


def main():
    _ = int(input())
    L = list(map(int, input().split()))

    comb = itertools.combinations(L, 3)

    ans = 0
    for v in comb:
        if not v[0] < v[1] + v[2]:
            continue
        elif not v[1] < v[2] + v[0]:
            continue
        elif not v[2] < v[0] + v[1]:
            continue
        else:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
import bisect


def main():
    N = int(input())
    L = list(map(int, input().split()))
    L.sort()

    ans = 0
    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            index = bisect.bisect_left(L, L[i] + L[j]) - j - 1
            ans += index

    print(ans)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import itertools


def main():
    _ = int(input())
    L = list(map(int, input().split()))

    comb = itertools.combinations(L, 3)

    ans = 0
    for v in comb:
        if v[0] < v[1] + v[2] and v[1] < v[2] + v[0] and v[2] < v[0] + v[1]:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
import bisect


def main():
    N = int(input())
    L = list(map(int, input().split()))
    L.sort()

    ans = 0
    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            index = bisect.bisect_left(L, L[i] + L[j]) - j - 1
            ans += index

    print(ans)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    S = input()
    K = int(input())
    ans = 0

    if S[0] is S[-1]:
        length = len(S)
    else:
        length = len(S) - 1

    i = 0
    while i < length:
        if S[i] is S[i + 1]:
            ans += 1
            i += 1
        i += 1

    print(ans * K)


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    S = input()
    K = int(input())
    ans = 0

    if len(set(S)) is 1:
        print(len(S) * K // 2)
        return

    i = 0
    cnt = [1]
    while i < len(S) - 1:
        if S[i] is S[i + 1]:
            cnt[-1] += 1
        else:
            cnt.append(1)
        i += 1

    for v in cnt:
        ans += (v // 2) * K

    if S[0] is S[-1]:
        if cnt[0] % 2 == cnt[-1] % 2 == 1:
            ans += K - 1

    print(ans)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    A = list(map(int, input().split()))

    for v in range(1, N + 1):
        print(A.index(v) + 1, end=" ")

    print()


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans_list = [None for _ in range(N)]

    for i in range(N):
        ans_list[A[i] - 1] = i

    for v in ans_list:
        print(v + 1, end=" ")

    print()


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, K, Q = map(int, input().split())
    A = [int(input()) for _ in range(Q)]

    points = [K for _ in range(N)]

    for i in A:
        points = list(map(lambda x: x - 1, points))
        points[i - 1] += 1

    for i in points:
        if i <= 0:
            print("No")
        else:
            print("Yes")


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    N, K, Q = map(int, input().split())
    A = [int(input()) for _ in range(Q)]

    points = [K for _ in range(N)]
    points = list(map(lambda x: x - Q, points))

    for i in A:
        points[i - 1] += 1

    for i in points:
        if i <= 0:
            print("No")
        else:
            print("Yes")


if __name__ == "__main__":
    main()