Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

s = np.array(list(input()), np.unicode)
sl = len(s)
t = np.array(list(input()), np.unicode)
tl = len(t)
equal = (s[:, None] == t[None, :])

dp = np.array([np.zeros(tl + 1, np.int32)])
for i in range(sl):
    tmp = dp[-1].copy()
    np.maximum(tmp[1:], tmp[:-1] + equal[i], out=tmp[1:])
    np.maximum.accumulate(tmp, out=tmp)
    dp = np.append(dp, [tmp], axis=0)

answer = ''
while sl > 0 and tl > 0:
    if s[sl - 1] == t[tl - 1]:
        sl -= 1
        tl -= 1
        answer += s[sl]
        continue

    if dp[sl - 1][tl] > dp[sl][tl - 1]:
        sl -= 1
    else:
        tl -= 1

print(answer[::-1])

Fixed submission:
import numpy as np

s = np.array(list(input()), np.unicode)
sl = len(s)
t = np.array(list(input()), np.unicode)
tl = len(t)
equal = (s[:, None] == t[None, :])

dp = [np.zeros(tl + 1, np.int32)]
for i in range(sl):
    tmp = dp[-1].copy()
    np.maximum(tmp[1:], tmp[:-1] + equal[i], out=tmp[1:])
    np.maximum.accumulate(tmp, out=tmp)
    dp.append(tmp)

answer = ''
while sl > 0 and tl > 0:
    if s[sl - 1] == t[tl - 1]:
        sl -= 1
        tl -= 1
        answer += s[sl]
        continue

    if dp[sl - 1][tl] > dp[sl][tl - 1]:
        sl -= 1
    else:
        tl -= 1

print(answer[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    s = input()
    sl = len(s)
    t = input()
    tl = len(t)

    dp = [[0] * (tl + 1) for _ in range(sl + 1)]

    for i in range(sl):
        for j in range(tl):
            if s[i] == t[j]:
                dp[i + 1][j + 1] = dp[i][j] + 1
            else:
                dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j])

    answer = ''
    while sl > 0 and tl > 0:
        if s[sl - 1] == t[tl - 1]:
            sl -= 1
            tl -= 1
            answer += s[sl]
            continue

        if dp[sl - 1][tl] > dp[sl][tl - 1]:
            sl -= 1
        else:
            tl -= 1

    print(answer[::-1])


if __name__ == '__main__':
    main()

Fixed submission:
import numpy as np

s = np.array(list(input()), np.unicode)
sl = len(s)
t = np.array(list(input()), np.unicode)
tl = len(t)
equal = (s[:, None] == t[None, :])

dp = [np.zeros(tl + 1, np.int32)]
for i in range(sl):
    tmp = dp[-1].copy()
    np.maximum(tmp[1:], tmp[:-1] + equal[i], out=tmp[1:])
    np.maximum.accumulate(tmp, out=tmp)
    dp.append(tmp)

answer = ''
while sl > 0 and tl > 0:
    if s[sl - 1] == t[tl - 1]:
        sl -= 1
        tl -= 1
        answer += s[sl]
        continue

    if dp[sl - 1][tl] > dp[sl][tl - 1]:
        sl -= 1
    else:
        tl -= 1

print(answer[::-1])
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N = input()
l = ['3', '5', '7']
d = len(N)
N = int(N)

if N - 357 < 0:
    print(0)
    exit()

#d-1桁以下の753数
aa = 0
for i in range(3, d):
    aa += 3 ** i - 3 * (2 ** i - 2) - 3

#N以下のd桁の753数
a = [i for i in itertools.combinations_with_replacement(l, d)]
b = [i for i in a if len(set(i)) == 3]
c = []
count = 0
for k in b:
    temp = [i for i in itertools.permutations(k)]
    temp = list(set(temp))
    for j in temp:
        if int(''.join(j)) <= N:
            count += 1

print(aa + count)

Fixed submission:
N = input()
l = ['3', '5', '7']
L = ['3', '5', '7']
temp = []
d = len(N)
N = int(N)


if N - 357 < 0:
    print(0)
    exit()

#d-1桁以下の753数
a = 0
for i in range(3, d):
    a += 3 ** i - 3 * (2 ** i - 2) - 3

#d桁の753数
for k in range(d - 1):
    for i in L:
        for j in l:
            temp.append(i + j)
    L.clear()
    L.extend(temp)
    temp.clear()
L = [i for i in L if '3' in i and '5' in i and '7' in i]

count = 0
for i in L:
    if int(i) <= N:
        count += 1
print(a + count)
Buggy python submission (verdict: Runtime Error):
N = float(input())
T, A = map(float, input().split())
H = list(map(float, input().split()))
l = [i for i in H abs(T - i * 0.006)]

print(min(l))

Fixed submission:
N = int(input())
T, A = map(float, input().split())
H = list(map(float, input().split()))
ans = [0] * N
for i in range(N):
  ans[i] = abs(T - H[i] * 0.006 - A)

print(ans.index(min(ans)) + 1)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())

while M % N != 0:
    N += 1

print(M // N)

Fixed submission:
from bisect import bisect_right
N, M = map(int, input().split())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


divisors = make_divisors(M)
print(divisors[bisect_right(divisors, M // N) - 1])
Buggy python submission (verdict: Runtime Error):
from collections import Counter

n = int(input())
v = list(map(str, input().split()))

f = Counter(v[::2]).most_common(2)
s = Counter(v[1::2]).most_common(2)

if f[0][0] != s[0][0]:
    print(n - f[0][1] - s[0][1])
else:
    if len(s) == 1 or len(b) == 1:
        print(n // 2)
    else:
        print(n - max(f[0][1] + s[1][1], f[1][1] + s[0][1]))


Fixed submission:
from collections import Counter

n = int(input())
v = list(map(str, input().split()))

f = Counter(v[::2]).most_common(2)
s = Counter(v[1::2]).most_common(2)

if f[0][0] != s[0][0]:
    print(n - f[0][1] - s[0][1])
else:
    if len(f) == 1 or len(s) == 1:
        print(n // 2)
    else:
        print(n - max(f[0][1] + s[1][1], f[1][1] + s[0][1]))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

n = int(input())
v = list(map(str, input().split()))

f = Counter(v[::2])
s = Counter(v[1::2])

ans = []

for i in f.keys():
    for j in s.keys():
        if i == j:
            continue
        else:
            ans.append(f[i] + s[j])

if ans:
    print(n - max(ans))
else:
    print(n // 2)

Fixed submission:
from collections import Counter

n = int(input())
v = list(map(str, input().split()))

f = Counter(v[::2]).most_common(2)
s = Counter(v[1::2]).most_common(2)

if f[0][0] != s[0][0]:
    print(n - f[0][1] - s[0][1])
else:
    if len(f) == 1 or len(s) == 1:
        print(n // 2)
    else:
        print(n - max(f[0][1] + s[1][1], f[1][1] + s[0][1]))

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

n = int(input())
v = list(map(str, input().split()))

f = collections.Counter([v[i] for i in range(n) if i % 2 == 0])
s = collections.Counter([v[i] for i in range(n) if i % 2 == 1])

ans = []

for i in f.keys():
    for j in s.keys():
        if i == j:
            continue
        else:
            ans.append(f[i] + s[j])

if ans:
    print(n - max(ans))
else:
    print(n // 2)


Fixed submission:
from collections import Counter

n = int(input())
v = list(map(str, input().split()))

f = Counter(v[::2]).most_common(2)
s = Counter(v[1::2]).most_common(2)

if f[0][0] != s[0][0]:
    print(n - f[0][1] - s[0][1])
else:
    if len(f) == 1 or len(s) == 1:
        print(n // 2)
    else:
        print(n - max(f[0][1] + s[1][1], f[1][1] + s[0][1]))

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

n = int(input())
v = list(map(str, input().split()))

f = collections.Counter([v[i] for i in range(n) if i % 2 == 0]).most_common()
s = collections.Counter([v[i] for i in range(n) if i % 2 == 1]).most_common()

ans = []

for i in f:
    for j in s:
        if i[0] == j[0]:
            pass
        else:
            ans.append(i[1] + j[1])

if ans:
    print(n - max(ans))
else:
    print(n // 2)


Fixed submission:
from collections import Counter

n = int(input())
v = list(map(str, input().split()))

f = Counter(v[::2]).most_common(2)
s = Counter(v[1::2]).most_common(2)

if f[0][0] != s[0][0]:
    print(n - f[0][1] - s[0][1])
else:
    if len(f) == 1 or len(s) == 1:
        print(n // 2)
    else:
        print(n - max(f[0][1] + s[1][1], f[1][1] + s[0][1]))
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

H, W = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(H)]

direction = True
here = 0
answer = []
for i in range(H):
    if direction:
        while here < W:
            if a[i][here] % 2 == 1:
                a[i][here] -= 1
                a[i][here + 1] += 1
                answer.append([i, here, i, here + 1])
                here += 1
            else:
                here += 1
            if here == W - 1:
                if i == H - 1:
                    break
                if a[i][here] % 2 == 1:
                    a[i][here] -= 1
                    a[i + 1][here] += 1
                    answer.append([i, here, i + 1, here])
                direction = False
                break
    else:
        while 0 < here:
            if a[i][here] % 2 == 1:
                a[i][here] -= 1
                a[i][here - 1] += 1
                answer.append([i, here, i, here - 1])
                here -= 1
            else:
                here -= 1
            if here == 0:
                if i == H - 1:
                    break
                if a[i][here] % 2 == 1:
                    a[i][here] -= 1
                    a[i + 1][here] += 1
                    answer.append([i, here, i + 1, here])
                direction = True
                break

print(len(answer))
for i in answer:
    print(' '.join(map(str, [j + 1 for j in i])))

Fixed submission:
import sys
input = sys.stdin.readline

H, W = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(H)]

direction = True
here = 0
answer = []
for i in range(H):
    if direction:
        while here < W:
            if here == W - 1:
                if i == H - 1:
                    break
                if a[i][here] % 2 == 1:
                    a[i][here] -= 1
                    a[i + 1][here] += 1
                    answer.append([i, here, i + 1, here])
                direction = False
                break
            if a[i][here] % 2 == 1:
                a[i][here] -= 1
                a[i][here + 1] += 1
                answer.append([i, here, i, here + 1])
                here += 1
            else:
                here += 1
    else:
        while -1 < here:
            if here == 0:
                if i == H - 1:
                    break
                if a[i][here] % 2 == 1:
                    a[i][here] -= 1
                    a[i + 1][here] += 1
                    answer.append([i, here, i + 1, here])
                direction = True
                break
            if a[i][here] % 2 == 1:
                a[i][here] -= 1
                a[i][here - 1] += 1
                answer.append([i, here, i, here - 1])
                here -= 1
            else:
                here -= 1

print(len(answer))
for i in answer:
    print(' '.join(map(str, [j + 1 for j in i])))
Buggy python submission (verdict: Runtime Error):
import numpy as np
import sys
buf = sys.stdin.buffer

N, M, Q = map(int, buf.readline().split())
city = np.zeros((N + 1, N + 1), dtype='int32')
L, R = np.array(buf.read((N + 2) * M).split(), dtype='int32').reshape(M, 2).T
p, q = np.array(buf.read((N + 2) * Q).split(), dtype='int32').reshape(Q, 2).T

np.add.at(city, (L, R), 1)
np.cumsum(city, axis=0, out=city)
np.cumsum(city, axis=1, out=city)

p -= 1
answer = city[q, q] - city[p, q] - city[q, p] + city[p, p]
print('\n'.join(answer.astype(str)))

Fixed submission:
import numpy as np
import sys
input = sys.stdin.readline

N, M, Q = map(int, input().split())
# city[L][R]
city = [[0] * (N + 1) for _ in range(N + 2)]

for _ in range(M):
    L, R = map(int, input().split())
    city[L][R] += 1

city = np.array(city).reshape(N + 2, N + 1)
np.cumsum(city, axis=0, out=city)
np.cumsum(city, axis=1, out=city)

for _ in range(Q):
    p, q = map(int, input().split())
    print(city[q][q] - city[q][p - 1] - city[p - 1][q] + city[p - 1][p - 1])
Buggy python submission (verdict: Runtime Error):
S = list(input())

if S[0] == 'A' and S[2:- 1].count('C') == 1:
    S.remove('A').remove('C')
    if ''.join(S).islower:
        print('AC')
    else:
        print('WA')
else:
    print('WA')

Fixed submission:
S = list(input())

if S[0] == 'A' and S[2:- 1].count('C') == 1:
    S.remove('A')
    S.remove('C')
    if ''.join(S).islower():
        print('AC')
    else:
        print('WA')
else:
    print('WA')
Buggy python submission (verdict: Runtime Error):
D, N = map(int, input().split())

print(N * 100 ** D)D, N = map(int, input().split())

if N != 100:
    print(N * 100 ** D)
else:
    print((N + 1) * 100 ** D)

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

if N != 100:
    print(N * 100 ** D)
else:
    print((N + 1) * 100 ** D)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
ans = [0] * N

ans[0] = S[1:].count('E')
ans[-1] = S[:-1].count('W')
for i in range(1, N):
    ans[i] = S[:i].count('W') + S[i + 1:].count('E')

print(min(ans))

Fixed submission:
N = int(input())
S = input()
E = [0] * N
W = [0] * N
ans = [0] * N

count = 0
for i in range(N):
    if S[i] == 'W':
        count += 1
        W[i] = count
    else:
        W[i] = count


count = 0
for i in reversed(range(N)):
    if S[i] == 'E':
        count += 1
        E[i] = count
    else:
        E[i] = count

ans[0] = E[1]
ans[-1] = W[-2]
for i in range(1, N - 1):
    ans[i] = W[i - 1] + E[i + 1]

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

for i in range(N - 1):
    temp = A[i]
    right = i + 1
    while temp + A[right] == temp ^ A[right]:
        temp += A[right]
        answer += 1
        right += 1
        if right == N:
            break

print(answer)

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

for i in range(N):
    if right < N - 1:
        while temp + A[right + 1] == temp ^ A[right + 1]:
            right += 1
            temp += A[right]
            if right == N - 1:
                break
    temp -= A[i]
    answer += right - i + 1

print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from itertools import product

read = sys.stdin.read
readline = sys.stdin.readline

N, *S = map(str, read().split())
N = int(N)
x = 0
answer = 0
for y in range(N):
    for i, j in product(range(N), repeat=2):
        if S[(i + x) % N][(j + y) % N] != S[(j + x) % N][(i + y) % N]:
            break
    else:
        answer += N

print(answer)


Fixed submission:
import sys
from itertools import product

read = sys.stdin.read
readline = sys.stdin.readline

N, *S = map(str, read().split())
N = int(N)
x = 0
answer = 0
for y in range(N):
    for i, j in product(range(N), repeat=2):
        if S[(i + x) % N][(j + y) % N] != S[(j + x) % N][(i + y) % N]:
            break
    else:
        answer += N

print(answer)

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

read = sys.stdin.read
readline = sys.stdin.readline

N, *S = map(str, read().split())
N = int(N)
x = 0
answer = 0
for y in range(N):
    for i, j in product(range(N), repeat=2):
        if S[(i + x) % N][(j + y) % N] != S[(j + x) % N][(i + y) % N]:
            break
    else:
        answer += N

print(answer)


Fixed submission:
import sys
from itertools import product

read = sys.stdin.read
readline = sys.stdin.readline

N, *S = map(str, read().split())
N = int(N)
x = 0
answer = 0
for y in range(N):
    for i, j in product(range(N), repeat=2):
        if S[(i + x) % N][(j + y) % N] != S[(j + x) % N][(i + y) % N]:
            break
    else:
        answer += N

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

for i in range(N):
    x = sorted(X)
    x.remove(X[i])
    print(x[-N // 2])

Fixed submission:
N = int(input())
X = list(map(int, input().split()))
x = sorted(X)
a = x[-(N // 2) - 1]
b = x[-(N // 2)]

for i in X:
    if i <= a:
        print(b)
    else:
        print(a)
Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np

read = sys.stdin

N, K = map(int, read.readline().split())
k = 2 * K
xyc = np.array(read.read().split(), np.str).reshape(-1, 3)
x = xyc[:, 0].astype(int)
y = xyc[:, 1].astype(int)
c = xyc[:, 2]

x = np.where(c == 'B', x - K, x)
x %= k
y %= k

# grid[[1,2],[1,2]]+=1 としてもgrid[1,2]=1であり重複は考慮されない。
# uniqueを使って(x,y)の重複をカウントする
xy, cnt = np.unique(x + y * 10000, return_counts=True)
x = xy % 10000
y = xy // 10000

grid = np.zeros((3 * K, 3 * K), np.int64)
grid[x, y] += cnt
grid[x + K, y + K] += cnt
grid[x + K, y] -= cnt
grid[x, y + K] -= cnt
np.cumsum(grid, axis=0, out=grid)
np.cumsum(grid, axis=1, out=grid)

p1 = grid[:K, :K] + grid[k:, k:] + grid[K:k, K:k] + grid[k:, :K] + grid[:K, k:]
p2 = grid[K:k, :K] + grid[K:k, k:] + grid[:K, K:k] + grid[k:, K:k]
print(max(p1.max(), p2.max()))


Fixed submission:
import sys
import numpy as np
from collections import Counter

read = sys.stdin

N, K = map(int, read.readline().split())
k = 2 * K
xyc = np.array(read.read().split(), np.str).reshape(-1, 3)
x = xyc[:, 0].astype(int)
y = xyc[:, 1].astype(int)
c = xyc[:, 2]

x = np.where(c == 'B', x - K, x)
x %= k
y %= k

'''
# grid[[1,2],[1,2]]+=1 としてもgrid[1,2]=1であり重複は考慮されない。
# uniqueを使って(x,y)の重複をカウントする
# return_countはver1.9からだった・・・ ダメじゃん
xy, cnt = np.unique(x + y * 10000, return_counts=True)
x = xy % 10000
y = xy // 10000
'''
xy = Counter(list(zip(x, y)))
cnt = np.array(list(xy.values()), np.int64)
xy = np.array(list(xy.keys()), np.int64)
x = xy[:, 0]
y = xy[:, 1]

grid = np.zeros((3 * K, 3 * K), np.int64)
grid[x, y] += cnt
grid[x + K, y + K] += cnt
grid[x + K, y] -= cnt
grid[x, y + K] -= cnt
np.cumsum(grid, axis=0, out=grid)
np.cumsum(grid, axis=1, out=grid)

p1 = grid[:K, :K] + grid[k:, k:] + grid[K:k, K:k] + grid[k:, :K] + grid[:K, k:]
p2 = grid[K:k, :K] + grid[K:k, k:] + grid[:K, K:k] + grid[k:, K:k]
print(max(p1.max(), p2.max()))
Buggy python submission (verdict: Time Limit Exceeded):
N, Y = map(int, input().split())
count = 0
yen = [0] * 3

for i in reversed(range(Y // 10000 + 1)):
    yen[0] = i
    for j in range(Y // 5000 + 1):
        yen[1] = j
        yen[2] = N - i - j
        if Y - 10000 * i - 5000 * j < 0:
            break
        elif Y - 10000 * i - 5000 * j == 1000 * yen[2]:
            print(' '.join(map(str, yen)))
            exit()
        else:
            continue
print('-1 -1 -1')

Fixed submission:
N, Y = map(int, input().split())
count = 0
yen = [0] * 3

for i in reversed(range(Y // 10000 + 1)):
    yen[0] = i
    for j in range(Y // 5000 + 1):
        yen[1] = j
        yen[2] = N - i - j
        if Y - 10000 * i - 5000 * j < 0 or yen[2] < 0:
            break
        elif Y - 10000 * i - 5000 * j == 1000 * yen[2]:
            print(' '.join(map(str, yen)))
            exit()
        else:
            continue
print('-1 -1 -1')
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from bisect import bisect_left, bisect_right
input = sys.stdin.readline


# エラトステネスのふるい
def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime_list = [2]
    limit = int(n**0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime_list + data
        prime_list.append(p)
        data = [e for e in data if e % p != 0]


prime = get_sieve_of_eratosthenes(10 ** 5)
p = set(prime)
Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    cnt = 0
    for i in prime[bisect_left(prime, l):bisect_right(prime, r)]:
        if (i + 1) // 2 in p:
            cnt += 1
    print(cnt)

Fixed submission:
import sys
from bisect import bisect_left, bisect_right
input = sys.stdin.readline


# エラトステネスのふるい
def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime_list = [2]
    limit = int(n**0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime_list + data
        prime_list.append(p)
        data = [e for e in data if e % p != 0]


prime = get_sieve_of_eratosthenes(10 ** 5)
p = set(prime)
prime = [i for i in prime if (i + 1) // 2 in p]
Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print(bisect_right(prime, r) - bisect_left(prime, l))
Buggy python submission (verdict: Runtime Error):
N = int(input())
F = [list(map(int, input().split())) for i in range(N)]
P = [list(map(int, input().split())) for i in range(N)]
l = [format(i, 'b').zfill(10) for i in range(1, 2 ** 10)]
ans = []

for i in l:
    c = [0] * 
    for j in range(10):
        if i[j] == '1':
            for k in range(N):
                if F[k][j] == 1:
                    c[k] += 1
                else:
                    continue
        else:
            continue
    temp = 0
    for j in range(N):
        temp += P[j][c[j]]
    ans.append(temp)

print(max(ans))

Fixed submission:
N = int(input())
F = [list(map(int, input().split())) for i in range(N)]
P = [list(map(int, input().split())) for i in range(N)]
l = [format(i, 'b').zfill(10) for i in range(1, 2 ** 10)]
ans = []

for i in l:
    c = [0] * N
    for j in range(10):
        if i[j] == '1':
            for k in range(N):
                if F[k][j] == 1:
                    c[k] += 1
                else:
                    continue
        else:
            continue
    temp = 0
    for j in range(N):
        temp += P[j][c[j]]
    ans.append(temp)

print(max(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ans = 0

for i in A:
    for j in range(N):
        if i < B[j]:
            for k in range(N):
                if B[j] < C[k]:
                    ans += N - k
                    break

print(ans)

Fixed submission:
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())))
B = np.array(list(map(int, input().split())))
C = np.array(list(map(int, input().split())))

A.sort()
B.sort()

a = np.searchsorted(A, B, side='left')

B = sorted(B * (-1))
C = sorted(C * (-1))

c = np.searchsorted(C, B, side='left')
c = np.fliplr([c])[0]


print((a * c).sum())
Buggy python submission (verdict: Runtime Error):
s = input()

l = 0
r = len(s) - 1
answer = 0

while l != r:
    if s[l] == s[r]:
        l += 1
        r -= 1
    elif s[l] == 'x':
        l += 1
        answer += 1
    elif s[r] == 'x':
        r -= 1
        answer += 1
    else:
        print(-1)
        exit()

print(answer)

Fixed submission:
s = input()

l = 0
r = len(s) - 1
answer = 0

while l < r:
    if s[l] == s[r]:
        l += 1
        r -= 1
    elif s[l] == 'x':
        l += 1
        answer += 1
    elif s[r] == 'x':
        r -= 1
        answer += 1
    else:
        print(-1)
        exit()

print(answer)

Buggy python submission (verdict: Runtime Error):
from collections import deque

s = deque(input())
answer = 0

if len(s) == 1:
    print(0)
    exit()

l = ''
r = ''

while l == '' or r == '':
    if s:
        if l == '':
            l = s.popleft()
        if r == '':
            r = s.pop()

    if l == r:
        l = ''
        r = ''
    elif l == 'x':
        answer += 1
        l = ''
    elif r == 'x':
        answer += 1
        r = ''
    elif r == '' or l == '':
        break
    else:
        print(-1)
        exit()

print(answer)

Fixed submission:
s = input()

l = 0
r = len(s) - 1
answer = 0

while l < r:
    if s[l] == s[r]:
        l += 1
        r -= 1
    elif s[l] == 'x':
        l += 1
        answer += 1
    elif s[r] == 'x':
        r -= 1
        answer += 1
    else:
        print(-1)
        exit()

print(answer)