Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
X, Y, Z, K = map(int, input().split(" "))
A, B, C = [list(map(int, input().split(" "))) for _ in range(3)]
# X, Y, Z, K = 1000, 1000, 1000, 3000
# A, B, C = [[i*j for j in range(1000)] for i in range(3)]

ab_cakes = []
for a in A:
    for b in B:
        ab_cakes.append(a+b)

ab_cakes = sorted(ab_cakes, reverse=True)[:K]

abc_cakes = []
for ab in ab_cakes:
    for c in C:
        abc_cakes.append(ab + c)

abc_cakes = sorted(abc_cakes, reverse=True)[:K]

for abc in abc_cakes:
    print(abc)

Fixed submission:
X, Y, Z, K = map(int, input().split(" "))
A, B, C = [list(map(int, input().split(" "))) for _ in range(3)]
# X, Y, Z, K = 1000, 1000, 1000, 3000
# A, B, C = [[i*j for j in range(1000)] for i in range(3)]

ab_cakes = []
for a in A:
    for b in B:
        ab_cakes.append(a+b)

ab_cakes = sorted(ab_cakes, reverse=True)[:K]

abc_cakes = []
for ab in ab_cakes:
    for c in C:
        abc_cakes.append(ab + c)

abc_cakes = sorted(abc_cakes, reverse=True)[:K]

for abc in abc_cakes:
    print(abc)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations, permutations

N, A, B, C = map(int, input().split(" "))
L = [int(input()) for _ in range(N)]

def f(a):
    s, l, x = a
    return (l-1)*10+abs(s-x)
    

min_num = 10**18
for l in permutations(L):
    # print(l)
    for j1, j2, j3 in combinations(range(N), 3):
        sum_num = sum(map(f, [(sum(l[j1:j2]), j2-j1, A), (sum(l[j2:j3]), j3-j2, B), (sum(l[j3:]), N-j3, C)]))
        # if sum_num < min_num:
            # print(l)
        min_num = min(min_num, sum_num)

print(min_num)

Fixed submission:
from itertools import product

N, *ABC = map(int, input().split(" "))
L = [int(input()) for _ in range(N)]

min_num = 10**18
for i in range(4**N):
    abcz = [[] for _ in range(4)]
    for j in range(N):
        abcz[i//(4**j)%4].append(L[j])
    if [] in abcz[:3]:
        continue
    # print(abcz)
    m = 0
    for l, x in zip(abcz, ABC): 
        m += 10*(len(l)-1) + abs(sum(l)-x)
    # if m < min_num:
    #     print(abcz, m)
    min_num = min(min_num, m)

print(min_num)
Buggy python submission (verdict: Runtime Error):
BIG_NUM = 10**18

N, K = map(int, input().split(" "))
H = list(map(int, input().split(" ")))

l = [BIG_NUM]*(N+200)
l[0] = 0
for i in range(1, N):
    l[i] = min([
        l[i-j] + abs(H[i]-H[i-j]) for j in range(1, min(N, K, i)+1)
    ])

# print(l)
print(l[N-1])

Fixed submission:
BIG_NUM = 10**18

N = int(input())
H = list(map(int, input().split(" ")))

l = [BIG_NUM] * (N+10)
l[0] = 0

for i in range(1, N):
    l[i] = min(
        l[i-1] + abs(H[i] - H[i-1]),
        l[i-2] + abs(H[i] - H[i-2]),
    )

print(l[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split(" "))
WV = [list(map(int, input().split(" "))) for _ in range(N)]

dp = [[0 for _ in range(W+1)] for _ in range(N+1)]

for i, (w, v) in enumerate(WV):
    for j in range(W+1):
        if w <= j:
            dp[i+1][j] = max(
                dp[i][j-w] + v,
                dp[i][j]
            )
        else:
            dp[i+1][j] = dp[i][j]

print(dp[N][W])

Fixed submission:
N, W = map(int, input().split(" "))
WV = [list(map(int, input().split(" "))) for _ in range(N)]

dp = [[0 for _ in range(W+1)] for _ in range(N+1)]

for i, (w, v) in enumerate(WV):
    for j in range(W+1):
        if w <= j:
            dp[i+1][j] = max(
                dp[i][j-w] + v,
                dp[i][j]
            )
        else:
            dp[i+1][j] = dp[i][j]

print(dp[N][W])

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

sys.setrecursionlimit(10**8)

N, W = map(int, input().split(" "))
WV = [list(map(int, input().split(" "))) for _ in range(N)]

l = [[None for _ in range(W+1)] for _ in range(N+1)]
def dp(i, limit):
    if i == -1:
        return 0
    if l[i][limit] != None:
        return l[i][limit]
    w, v = WV[i]
    if w <= limit:
        l[i][limit] = max(
            dp(i-1, limit),
            dp(i-1, limit-w) + v
        )
    else:
        l[i][limit] = dp(i-1, limit)
    return l[i][limit]

print(dp(N-1, W))

Fixed submission:
N, W = map(int, input().split(" "))
WV = [list(map(int, input().split(" "))) for _ in range(N)]

dp = [[0 for _ in range(W+1)] for _ in range(N+1)]

for i, (w, v) in enumerate(WV):
    for j in range(W+1):
        if w <= j:
            dp[i+1][j] = max(
                dp[i][j-w] + v,
                dp[i][j]
            )
        else:
            dp[i+1][j] = dp[i][j]

print(dp[N][W])

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

sys.setrecursionlimit(10**8)

N, W = map(int, input().split(" "))
WV = [list(map(int, input().split(" "))) for _ in range(N)]

l = [[None for _ in range(W+1)] for _ in range(N+1)]
def dp(i, limit):
    if i == -1:
        return 0
    if l[i][limit] == None:
        w, v = WV[i]
        if w <= limit:
            l[i][limit] = max(
                dp(i-1, limit),
                dp(i-1, limit-w) + v
            )
        else:
            l[i][limit] = dp(i-1, limit)
    return l[i][limit]

print(dp(N-1, W))

Fixed submission:
N, W = map(int, input().split(" "))
WV = [list(map(int, input().split(" "))) for _ in range(N)]

dp = [[0 for _ in range(W+1)] for _ in range(N+1)]

for i, (w, v) in enumerate(WV):
    for j in range(W+1):
        if w <= j:
            dp[i+1][j] = max(
                dp[i][j-w] + v,
                dp[i][j]
            )
        else:
            dp[i+1][j] = dp[i][j]

print(dp[N][W])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

count = 0
for i in range(1, N+1):
	if set(str(i)) != {"3", "5", "7"}:
		continue
	count += 1
print(count)

Fixed submission:
from bisect import bisect_right
from itertools import product, chain

N = int(input())

# product("357", repeat=len(str(N)))
l = list(chain(*[[int("".join(m)) for m in product("357", repeat=i) if set(m) == {"3", "5", "7"}] for i in range(1, len(str(N))+1)]))
# print(l)
print(bisect_right(l, N))
Buggy python submission (verdict: Runtime Error):
i=lambda:map(int,input().split());i();t,a=i();c=[abs(t-0.006*b-a)for b in i()];print(c.index(min(c))+1)

Fixed submission:
x, y = map(int, input().split(" "))

print(x + y//2)
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]

l = []
for y in range(H):
    l += [(x, y) for x in list(range(W))[::-1 if y%2 else 1]]

p = []
for i, (x, y) in enumerate(l):
    if A[y][x] % 2 == 0:
        continue
    nx, ny = l[i+1]
    p.append((x+1, y+1, nx+1, ny+1))
    A[y][x] -= 1
    A[ny][nx] += 1

print(len(p))
[print(*p_i) for p_i in p]


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

l = []
for y in range(H):
    l += [(x, y) for x in list(range(W))[::-1 if y%2 else 1]]

p = []
for i, (x, y) in enumerate(l[:-1]):
    if A[y][x] % 2 == 0:
        continue
    nx, ny = l[i+1]
    p.append((x+1, y+1, nx+1, ny+1))
    A[y][x] -= 1
    A[ny][nx] += 1

print(len(p))
[print(*p_i[::-1]) for p_i in p]
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product

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

# print(len(list(filter(lambda x: 2*x%K==0, range(1, N+1))))**2)
l = []
for i in range(1, N+1):
	if (2*i)%K == 0:
		l.append(i)
count = 0
for a, b, c in product(l, repeat=3):
	if (a+b)%K == (b+c)%K == (c+a)%K == 0:
		count += 1
print(count)

Fixed submission:
from itertools import product

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

"""
i%K == 0 ならその数同士で条件に合う数列を作れる
i%K == K//2 ならその数同士で条件に合う数列を作れる(Kが偶数の場合)
これらは条件によって導ける
"""

count = (N//K)**3
if K%2 == 0:
	count += (N//K + (N%K >= K//2))**3
print(count)
Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())

for i in range(k):
    if s[k] != "1":
        print(s[k])
        exit()
print(1)

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

i = 0
while k > 1:
    if s[i] == "1":
        k -= 1
        i += 1
    else:
        break
print(s[i])
Buggy python submission (verdict: Runtime Error):
import statistics

n = int(input())
a = [int(n) for n in input().split(" ")]

sub_a = [a_n - i - 1 for i, a_n in enumerate(a)]
median = statistics.median(sub_a)
print(sum([abs(sub_a-median) for sub_a_n in sub_a]))

Fixed submission:
import statistics

n = int(input())
a = [int(n) for n in input().split(" ")]

sub_a = [a_n - i - 1 for i, a_n in enumerate(a)]
median = statistics.median(sub_a)
print(int(sum([abs(sub_a_n-median) for sub_a_n in sub_a])))
Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce

def count_two(n):
	two_count = 0
	while n != 0 and n % 2 == 0:
		two_count += 1
		n //= 2
	return two_count

n = int(input())
a = map(int, input().split())
a_product = reduce(lambda x, y: x*y, a)
print(count_two(a_product))

Fixed submission:
from functools import reduce

def count_two(n):
	two_count = 0
	while n != 0 and n % 2 == 0:
		two_count += 1
		n //= 2
	return two_count

n = int(input())
a = map(int, input().split())
a_two_count_sum = sum([count_two(ai) for ai in a])
print(a_two_count_sum)
Buggy python submission (verdict: Runtime Error):
def same_count(str_list):
    standard_str = min(str_list, key=lambda x: len(x))
    return [all([c in str_ for str_ in str_list]) for c in set(standard_str)].count(True)

n = int(input())
s = input()

print(max([same_count([s[:i], s[i:]]) for i in range(1,n-1)]))

Fixed submission:
def same_count(str_list):
    standard_str = min(str_list, key=lambda x: len(x))
    return [all([c in str_ for str_ in str_list]) for c in set(standard_str)].count(True)

n = int(input())
s = input()

print(max([same_count([s[:i+1], s[i+1:]]) for i in range(n)]+[0]))

Buggy python submission (verdict: Runtime Error):
def same_count(str_list):
    standard_str = min(str_list, key=lambda x: len(x))
    return [all([c in str_ for str_ in str_list]) for c in standard_str].count(True)

n = int(input())
s = input()

print(max([same_count([s[:i], s[i:]]) for i in range(1,n-1)]))

Fixed submission:
def same_count(str_list):
    standard_str = min(str_list, key=lambda x: len(x))
    return [all([c in str_ for str_ in str_list]) for c in set(standard_str)].count(True)

n = int(input())
s = input()

print(max([same_count([s[:i+1], s[i+1:]]) for i in range(n)]+[0]))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

min_num = 300000
for i in range(n):
    min_num = min(s[:i].count("W") + s[i+1:].count("E"), min_num)
print(min_num)

Fixed submission:
n = int(input())
s = input()

min_num = 300000
w_west = 0
e_east = s.count("E")
for s_i in s:
    if s_i == "E":
        e_east -= 1
    else:
        w_west += 1
    tmp = w_west + e_east - bool(s_i == "W")
    if tmp < min_num:
        min_num = tmp
print(min_num)

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

min_num = 300000
for i in range(n):
    min_num = min(s[:i].count("W") + s[i+1:].count("E"), min_num)
print(min_num)

Fixed submission:
n = int(input())
s = input()

min_num = 300000
w_west = 0
e_east = s.count("E")
for s_i in s:
    if s_i == "E":
        e_east -= 1
    else:
        w_west += 1
    tmp = w_west + e_east - bool(s_i == "W")
    if tmp < min_num:
        min_num = tmp
print(min_num)

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

min_num = 
for i in range(n):
    min_num = min(s[:i].count("W") + s[i+1:].count("E"), min_num)
print(min_num)

Fixed submission:
n = int(input())
s = input()

min_num = 300000
w_west = 0
e_east = s.count("E")
for s_i in s:
    if s_i == "E":
        e_east -= 1
    else:
        w_west += 1
    tmp = w_west + e_east - bool(s_i == "W")
    if tmp < min_num:
        min_num = tmp
print(min_num)
Buggy python submission (verdict: Time Limit Exceeded):
def n_gram(s, n):
	return [s[i:i+n] for i in range(len(s)-n+1)]

s = input()
k = int(input())

n_gram_set = set()
for i in range(1, len(s)+1):
	n_gram_set = n_gram_set | set(n_gram(s, i))

print(sorted(list(n_gram_set))[k-1])

Fixed submission:
def n_gram(s, n):
	return [s[i:i+n] for i in range(len(s)-n+1)]

s = input()
k = int(input())

subs = set()
for k_i in range(1, k+1):
	subs = subs | set(n_gram(s, k_i))
print(sorted(subs)[k-1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = list(map(int, input().split(" ")))

x_sorted = sorted(x)
samples = (x_sorted[n//2], x_sorted[n//2-1])
for x_i in x:
	print(samples[x_sorted.index(x_i)//(n//2)])

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

x_sorted = sorted(x)
for x_i in x:
	print((x_sorted[n//2-1], x_sorted[n//2])[x_i < x_sorted[n//2]])

Buggy python submission (verdict: Runtime Error):
n = int(input())
x = tuple(map(int, input().split(" ")))

for x_i in range(len(x)):
	x_dummy = :
	print(sorted(x_dummy.remove(x_i))[len(x)//2])

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

x_sorted = sorted(x)
for x_i in x:
	print((x_sorted[n//2-1], x_sorted[n//2])[x_i < x_sorted[n//2]])
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect
from math import factorial as f

def combi(n_k):
    n, k = n_k
    return f(n) // f(n-k) // f(k)

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

*else_A, max_A = sorted(A)

x = bisect(else_A, max_A//2)

print(*max([(max_A, else_A[y]) for y in [x-1, x] if 0 <= y < N-1], key=combi))



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

*else_A, max_A = sorted(A)

print(max_A, min(else_A, key=lambda a: abs(max_A/2 - a) ))
Buggy python submission (verdict: Runtime Error):
s = input()

print("Yes" if len(set(input()))==3 else "No")

Fixed submission:
print("YNeos"[len(set(input()))!=3::2])
Buggy python submission (verdict: Time Limit Exceeded):
a,b,k=map(int,input().split());
for i in range(a,b+1):
	if i<a+k or b-k<i:
		print(i)

Fixed submission:
a, b, k = [int(m) for m in input().split(" ")]

for i in range(a, min(a+k, b+1)):
    print(i)
for i in range(max(b+1-k, a+k), b+1):
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,k=map(int,input().split());
for i in range(a,b+1):
 if i<a+k or b-k<i:
  print(i)

Fixed submission:
a, b, k = [int(m) for m in input().split(" ")]

for i in range(a, min(a+k, b+1)):
    print(i)
for i in range(max(b+1-k, a+k), b+1):
    print(i)
Buggy python submission (verdict: Runtime Error):
abc = list(map(int, input().split(" ")))

only_num = get_only(abc, key=lambda x: x%2)
if only_num:
	abc.remove(only_num)
	abc = [only_num] + [abc_i+1 for abc_i in abc]
max_num = max(abc)
abc.remove(max_num)

print((max_num-abc[0] + max_num-abc[1])//2+bool(only_num))

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

count = 0
while True:
	abc.sort()

	if abc[0] == abc[1] == abc[2]:
		break
	elif abc[0] == abc[1]:
		abc[0] += 1
		abc[1] += 1	
		count += 1
	else:
		abc[0] += 2
		count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split());print("YNeos"[a+b<c::2])

Fixed submission:
a,b,c,d=[int(input())for i in range(4)];print([a,b][a>b]+[c,d][c>d])

Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split());print("YNeos"[a+b<c::2])


Fixed submission:
a,b,c,d=[int(input())for i in range(4)];print([a,b][a>b]+[c,d][c>d])
Buggy python submission (verdict: Runtime Error):
pair_count = 0
for cd_i in cd:
	can_ball_count = 0
	for ab_i in ab:
		if ab_i[0] < cd_i[0] and ab_i[1] < cd_i[1]:
			can_ball_count += 1
		else:
			break
	if 1 <= can_ball_count-pair_count:
		pair_count += 1

print(pair_count)

Fixed submission:
N = int(input())
AB = [list(map(int, input().split(" "))) for _ in range(N)]
CD = [list(map(int, input().split(" "))) for _ in range(N)]

CD.sort()
AB.sort(key=lambda x: (x[1], x[0]), reverse=True)

count = 0
for c, d in CD:
    for j, (a, b) in enumerate(AB):
        if a < c and b < d:
            count += 1
            AB.pop(j)
            break

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [input() for i in range(n)]

t = [s_i[0] for s_i in s if s_i[0] in "MARCH"]
count = 0
for t_i in t:
	for t_j in t:
		for t_k in t:
			if len(set((t_i, t_j, t_k))) == 3:
				count += 1

print(count//6)

Fixed submission:
n = int(input())
s = [input() for i in range(n)]

t = [[s_i[0] for s_i in s].count(c) for c in "MARCH"]

sum_num = 0
for i in range(5):
	t_dummy_i = list(tuple(t))
	i_num = t_dummy_i.pop(i)
	for j in range(4):
		t_dummy_j = list(tuple(t_dummy_i))
		j_num = t_dummy_j.pop(j)
		for k in range(3):
			sum_num += i_num * j_num * t_dummy_j[k]

print(sum_num//6)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(n) for n in input().split(" ")]

a.sort()

print(a[::-2] - a[-2::-2])

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

a.sort()

print(sum(a[::-2]) - sum(a[-2::-2]))
Buggy python submission (verdict: Runtime Error):
a, b, c, x = [int(input()) for i in range(4)]

can_count = 0

for i in range(a+1):
	coins_price_500 = i * 500
	for j in range(b+1):
		coins_price_100 = j * 100
		for k in range(c+1):
			coins_price_50 = k * 50
			if x == coins_price_500 * coins_price_100 * coins_price_50:
				can_count += 1

print(can_count)

Fixed submission:
n = int(input())
a = [tuple(map(int, input().split(" "))) for i in range(2)]

up_line, down_line = a

max_num = 0
for i in range(n):
	num = sum(up_line[:i+1]) + sum(down_line[i:])
	if max_num < num:
		max_num = num
print(max_num)
Buggy python submission (verdict: Runtime Error):
a, b = [int(input()) for i in range(2)]

if a % 2 == b % 2 == 1:
	print("Odd")
else:
	print("Even")

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

if a % 2 == b % 2 == 1:
	print("Odd")
else:
	print("Even")
Buggy python submission (verdict: Runtime Error):
# Relative rela
import sys

n = int(input())
txy_list = [[int(n) for n in input().split()] for i in range(n)]
times_list = [txy_list[i][0] - txy_list[i+1][0] for i in range(n-1)]

before_x, before_y = 0, 0
for i, txy in enumerate(txy_list):
	t, x, y = txy
	rela_x, rela_y = x - before_x, y - before_y
	remaining = times_list[i] - (abs(rela_x) + abs(rela_y))
	if 0 <= remaining and remaining % 2 == 0:
		before_x, before_y = x, y
	else:
		print("No")
		sys.exit()
print("Yes")

Fixed submission:
# Relative rela
import sys

n = int(input())
txy_list = [[int(n) for n in input().split()] for i in range(n)]
times_list = [txy_list[0][0]] + [txy_list[i+1][0] - txy_list[i][0] for i in range(n-1)]

before_x, before_y = 0, 0
for i, txy in enumerate(txy_list):
	t, x, y = txy
	rela_x, rela_y = x - before_x, y - before_y
	remaining = times_list[i] - (abs(rela_x) + abs(rela_y))
	if 0 <= remaining and remaining % 2 == 0:
		before_x, before_y = x, y
	else:
		print("No")
		sys.exit()
print("Yes")
Buggy python submission (verdict: Runtime Error):
n, a, b = [int(n) for n in input.split(" ")]

some_sum = 0
for i in range(1, n):
	if a <= sum([int(m) for m in str(i)]) <= b:
		some_sum += i

print(some_sum)

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

some_sum = 0
for i in range(1, n+1):
	digit_sum = sum([int(m) for m in str(i)])
	if a <= digit_sum and digit_sum <= b:
		some_sum += i

print(some_sum)
Buggy python submission (verdict: Runtime Error):
x, y = map(int, input().split(" "))

print(int(math.log(y/x, 2)) + 1) 

Fixed submission:
x, y = map(int, input().split(" "))

n = x
count = 0
while n <= y:
	n *= 2
	count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
ab=map(int,input()[::1]);print(~-sum(ab)//2+1)

Fixed submission:

ab=map(int,input().split());print((sum(ab)-1)//2+1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = tuple(map(int, input().split(" ")))

sum_num = 0
for a_i in set(a):
	a_count_a_i  = a.count(a_i)
	sum_num += a_count_a_i - a_i if a_i <= a_count_a_i else a_count_a_i
print(sum_num)

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

a_count = dict()
for a_i in a:
	if a_i not in a_count:
		a_count[a_i] = 0 
	a_count[a_i] += 1

sum_num = 0
for a_i in a_count:
	a_count_a_i = a_count[a_i]
	sum_num += a_count_a_i - a_i if a_i <= a_count_a_i else a_count_a_i
print(sum_num)
Buggy python submission (verdict: Runtime Error):
s=input();print("No"if int(s)%sum(map(int,s))else"Yes")

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

print(min(a*n, b))
Buggy python submission (verdict: Runtime Error):
n=int(input());print("No"if n%sum(map(int,str(s))) else"Yes")

Fixed submission:
n=int(input());print("Yes"if n%sum([int(m)for m in str(n)])==0 else"No")
Buggy python submission (verdict: Time Limit Exceeded):
print(max(filter(lambda x:x**(1/2)%1==0,range(1,int(input())+1))))

Fixed submission:
i=input;print(int(int(i())**0.5)**2)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
abc = [tuple(map(int, input().split(" "))) for i in range(3)]

a, b, c = [sorted(abc_i) for abc_i in abc]

sum_num = 0
for b_i in b:
	can_a_count = n
	for i, a_i in enumerate(a):
		if a_i >= b_i:
			can_a_count = i
			break

	can_c_count = n
	for i, c_i in enumerate(c[::-1]):
		if c_i <= b_i:
			can_c_count = i
			break
	
	sum_num += can_a_count * can_c_count

print(sum_num)

Fixed submission:
import bisect

n = int(input())
abc = [tuple(map(int, input().split(" "))) for i in range(3)]
# n = 100000
# abc = [tuple(range(n)) for i in range(3)]

a, b, c = [sorted(abc_i) for abc_i in abc]

print(sum(bisect.bisect_left(a, b_i) * (n-bisect.bisect(c, b_i)) for b_i in b))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
abc = [tuple(map(int, input().split(" "))) for i in range(3)]

abc_list = []
for x in abc:
    d = dict()
    for x_i in x:
        if x_i not in d:
            d[x_i] = 0
        d[x_i] += 1
    abc_list.append(sorted(d.items()))
a, b, c = abc_list

count = 0
for a_i in a:
    for b_i in b:
        for c_i in c:
            if a_i[0] < b_i[0] < c_i[0]:
                count += a_i[1] * b_i[1] * c_i[1]

print(count)

Fixed submission:
import bisect

n = int(input())
abc = [tuple(map(int, input().split(" "))) for i in range(3)]
# n = 100000
# abc = [tuple(range(n)) for i in range(3)]

a, b, c = [sorted(abc_i) for abc_i in abc]

print(sum(bisect.bisect_left(a, b_i) * (n-bisect.bisect(c, b_i)) for b_i in b))

Buggy python submission (verdict: Time Limit Exceeded):
def more_num_len(num, r_sorted_list, n):
    for i, m in enumerate(r_sorted_list):
        if m <= num:
            return i
    return n


n = int(input())
a, b, c = [list(map(int, input().split(" "))) for i in range(3)]

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

count = 0
for a_i in a:
    x = more_num_len(a_i, b, n)
    for b_i in b[:x]:
        y = more_num_len(b_i, c, n)
        count += y
print(count)

Fixed submission:
import bisect

n = int(input())
abc = [tuple(map(int, input().split(" "))) for i in range(3)]
# n = 100000
# abc = [tuple(range(n)) for i in range(3)]

a, b, c = [sorted(abc_i) for abc_i in abc]

print(sum(bisect.bisect_left(a, b_i) * (n-bisect.bisect(c, b_i)) for b_i in b))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a, b, c = [list(map(int, input().split(" "))) for i in range(3)]

a.sort()
b.sort()
c.sort()

count = 0
for a_i in a:
    for b_i in b:
        for c_i in c:
            if a_i < b_i < c_i:
                count += 1
print(count)

Fixed submission:
import bisect

n = int(input())
abc = [tuple(map(int, input().split(" "))) for i in range(3)]
# n = 100000
# abc = [tuple(range(n)) for i in range(3)]

a, b, c = [sorted(abc_i) for abc_i in abc]

print(sum(bisect.bisect_left(a, b_i) * (n-bisect.bisect(c, b_i)) for b_i in b))