import numpy as np
import pandas as pd
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            X = np.array(
                [
                    [[81, 63, 63], [63, 49, 49], [63, 49, 49]],
                    [[4, 12, 8], [12, 36, 24], [8, 24, 16]],
                    [[25, 35, 25], [35, 49, 35], [25, 35, 25]],
                    [[25, 30, 10], [30, 36, 12], [10, 12, 4]],
                ]
            )
        elif test_case_id == 2:
            np.random.seed(42)
            X = np.random.rand(10, 5, 5)
        return X

    def generate_ans(data):
        _a = data
        Y = _a
        X = np.zeros([Y.shape[1], Y.shape[0]])
        for i, mat in enumerate(Y):
            diag = np.sqrt(np.diag(mat))
            X[:, i] += diag
        return X

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    np.testing.assert_allclose(result, ans)
    return 1

exec_context = r"""
import numpy as np
Y = test_input
[insert]
result = X
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(2):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)

X = pd.DataFrame(np.zeros([Y.shape[1], Y.shape[0]]))
for i, mat in enumerate(Y):
    diag = np.sqrt(np.diag(mat))
    X.iloc[:, i] = diag

import numpy as np
import pandas as pd
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            X = np.array([
                [[81, 63, 63], [63, 49, 49], [63, 49, 49]],
                [[4, 12, 8], [12, 36, 24], [8, 24, 16]],
                [[25, 35, 25], [35, 49, 35], [25, 35, 25]],
                [[25, 30, 10], [30, 36, 12], [10, 12, 4]],
            ])
        elif test_case_id == 2:
            np.random.seed(42)
            X = np.random.rand(10, 5, 5)
        return X

    def generate_ans(data):
        _a = data
        Y = _a
        X = np.zeros([Y.shape[1], Y.shape[0]])
        for i, mat in enumerate(Y):
            diag = np.sqrt(np.diag(mat))
            X[:, i] += diag
        return pd.DataFrame(X)

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    np.testing.assert_allclose(result.values, ans.values)
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
Y = test_input
[insert]
result = X
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(2):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


import numpy as np
a = np.array([9, 2, 7, 0])
number = 0

is_contained = ... # put solution in this variable

import numpy as np
import pandas as pd
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            a = np.array([9, 2, 7, 0])
            number = 0
        elif test_case_id == 2:
            a = np.array([1, 2, 3, 5])
            number = 4
        elif test_case_id == 3:
            a = np.array([1, 1, 1, 1])
            number = 1
        return a, number

    def generate_ans(data):
        _a = data
        a, number = _a
        is_contained = number in a
        return is_contained

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    assert result == ans
    return 1

exec_context = r"""
import numpy as np
a, number = test_input
[insert]
result = is_contained
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(3):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)

import pandas as pd
import numpy as np
s = pd.Series([9, 2, 7, 0])
number = 0

is_contained = ... # put solution in this variable

import pandas as pd
import numpy as np
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            s = pd.Series([9, 2, 7, 0])
            number = 0
        elif test_case_id == 2:
            s = pd.Series([1, 2, 3, 5])
            number = 4
        elif test_case_id == 3:
            s = pd.Series([1, 1, 1, 1])
            number = 1
        return s, number

    def generate_ans(data):
        _s = data
        s, number = _s
        is_contained = number in s.values
        return is_contained

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    assert result == ans
    return 1

exec_context = r"""
import pandas as pd
s, number = test_input
[insert]
result = is_contained
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(3):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


import numpy as np
A = np.array([1,1,2,3,3,3,4,5,6,7,8,8])
B = np.array([1,2,8])

C = ... # put solution in this variable

import numpy as np
import pandas as pd
import copy
import tokenize, io

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            A = np.array([1, 1, 2, 3, 3, 3, 4, 5, 6, 7, 8, 8])
            B = np.array([1, 2, 8])
        elif test_case_id == 2:
            np.random.seed(42)
            A = np.random.randint(0, 10, (20,))
            B = np.random.randint(0, 10, (3,))
        return A, B

    def generate_ans(data):
        _a = data
        A, B = _a
        C = A[~np.in1d(A, B)]
        return C

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    np.testing.assert_array_equal(result, ans)
    return 1

exec_context = r"""
import numpy as np
A, B = test_input
[insert]
result = C
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(2):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)

def test_string(solution: str):
    tokens = []
    for token in tokenize.tokenize(io.BytesIO(solution.encode("utf-8")).readline):
        tokens.append(token.string)
    assert "while" not in tokens and "for" not in tokens

import pandas as pd
import numpy as np
A = pd.Series([1,1,2,3,3,3,4,5,6,7,8,8])
B = pd.Series([1,2,8])

C = ... # put solution in this variable

import numpy as np
import pandas as pd
import copy
import tokenize, io

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            A = pd.Series([1, 1, 2, 3, 3, 3, 4, 5, 6, 7, 8, 8])
            B = pd.Series([1, 2, 8])
        elif test_case_id == 2:
            np.random.seed(42)
            A = pd.Series(np.random.randint(0, 10, (20,)))
            B = pd.Series(np.random.randint(0, 10, (3,)))
        return A, B

    def generate_ans(data):
        _a = data
        A, B = _a
        C = A[~A.isin(B)]
        return C

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    pd.testing.assert_series_equal(result, ans)
    return 1

exec_context = r"""
import pandas as pd
A, B = test_input
[insert]
result = C
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(2):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)

def test_string(solution: str):
    tokens = []
    for token in tokenize.tokenize(io.BytesIO(solution.encode("utf-8")).readline):
        tokens.append(token.string)
    assert "while" not in tokens and "for" not in tokens


import numpy as np
import pandas as pd
import copy
import tokenize, io

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            A = np.array([1, 1, 2, 3, 3, 3, 4, 5, 6, 7, 8, 8])
            B = np.array([1, 2, 8])
        elif test_case_id == 2:
            np.random.seed(42)
            A = np.random.randint(0, 10, (20,))
            B = np.random.randint(0, 10, (3,))
        return A, B

    def generate_ans(data):
        _a = data
        A, B = _a
        C = A[np.in1d(A, B)]
        return C

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    np.testing.assert_array_equal(result, ans)
    return 1

exec_context = r"""
import numpy as np
A, B = test_input
[insert]
result = C
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(2):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)

def test_string(solution: str):
    tokens = []
    for token in tokenize.tokenize(io.BytesIO(solution.encode("utf-8")).readline):
        tokens.append(token.string)
    assert "while" not in tokens and "for" not in tokens

import pandas as pd
import numpy as np
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            A = pd.Series([1, 1, 2, 3, 3, 3, 4, 5, 6, 7, 8, 8])
            B = pd.Series([1, 2, 8])
        elif test_case_id == 2:
            np.random.seed(42)
            A = pd.Series(np.random.randint(0, 10, (20,)))
            B = pd.Series(np.random.randint(0, 10, (3,)))
        return A, B

    def generate_ans(data):
        _a = data
        A, B = _a
        C = A[A.isin(B)]
        return C

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def test_execution(solution: str):
    exec_context = 'import pandas as pd\nimport numpy as np\nA, B = test_input\n' + solution + '\nresult = C'
    for i in range(2):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {'test_input': test_input}
        exec(exec_context, test_env)
        np.testing.assert_array_equal(test_env['result'], expected_result)


import numpy as np
A = np.array([1,1,2,3,3,3,4,5,6,7,8,8])
B = np.array([1,4,8])

C = ... # put solution in this variable

import numpy as np
import pandas as pd
import copy
import tokenize, io

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            A = np.array([1, 1, 2, 3, 3, 3, 4, 5, 6, 7, 8, 8])
            B = np.array([1, 4, 8])
        elif test_case_id == 2:
            np.random.seed(42)
            A = np.random.randint(0, 10, (20,))
            B = np.array([2, 2, 2])
        elif test_case_id == 3:
            np.random.seed(44)
            A = np.random.randint(0, 10, (20,))
            B = np.array([2, 3, 5])
        return A, B

    def generate_ans(data):
        _a = data
        A, B = _a
        C = A[np.logical_and(A > B[0], A < B[1]) | np.logical_and(A > B[1], A < B[2])]
        return C

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    np.testing.assert_array_equal(result, ans)
    return 1

exec_context = r"""
import numpy as np
A, B = test_input
[insert]
result = C
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(3):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)

def test_string(solution: str):
    tokens = []
    for token in tokenize.tokenize(io.BytesIO(solution.encode("utf-8")).readline):
        tokens.append(token.string)
    assert "while" not in tokens and "for" not in tokens

import pandas as pd
import numpy as np
A = pd.Series([1,1,2,3,3,3,4,5,6,7,8,8])
B = pd.Series([1,4,8])

C = ... # put solution in this variable

import numpy as np
import pandas as pd
import copy
import tokenize, io

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            A = pd.Series([1, 1, 2, 3, 3, 3, 4, 5, 6, 7, 8, 8])
            B = pd.Series([1, 4, 8])
        elif test_case_id == 2:
            np.random.seed(42)
            A = pd.Series(np.random.randint(0, 10, (20,)))
            B = pd.Series([2, 2, 2])
        elif test_case_id == 3:
            np.random.seed(44)
            A = pd.Series(np.random.randint(0, 10, (20,)))
            B = pd.Series([2, 3, 5])
        return A, B

    def generate_ans(data):
        _a = data
        A, B = _a
        C = A[(A > B[0]) & (A < B[1]) | (A > B[1]) & (A < B[2])]
        return C

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    pd.testing.assert_series_equal(result, ans)
    return 1

exec_context = r"""
import pandas as pd
A, B = test_input
[insert]
result = C
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(3):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)

def test_string(solution: str):
    tokens = []
    for token in tokenize.tokenize(io.BytesIO(solution.encode("utf-8")).readline):
        tokens.append(token.string)
    assert "while" not in tokens and "for" not in tokens


import numpy as np
from scipy.stats import rankdata
example_a = [1,2,3,4,3,2,3,4]
def f(a = example_a):
    # return the solution in this function
    # result = f(a)
    ###

import numpy as np
import copy
from scipy.stats import rankdata

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            a = [1, 2, 3, 4, 3, 2, 3, 4]
        elif test_case_id == 2:
            np.random.seed(42)
            a = np.random.rand(np.random.randint(26, 30))
        return a

    def generate_ans(data):
        _a = data
        a = _a
        result = len(a) - rankdata(a).astype(int)
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    np.testing.assert_array_equal(result, ans)
    return 1

exec_context = r"""
import numpy as np
from scipy.stats import rankdata
a = test_input
def f(a):
[insert]
result = f(a)
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(2):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)

import pandas as pd
import numpy as np
from scipy.stats import rankdata
example_s = pd.Series([1,2,3,4,3,2,3,4])
def f(s = example_s):
    # return the solution in this function
    # result = f(s)
    ###

    result = len(s) - pd.Series(rankdata(s)).astype(int)

    return result

import pandas as pd
import numpy as np
from scipy.stats import rankdata

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            s = pd.Series([1, 2, 3, 4, 3, 2, 3, 4])
        elif test_case_id == 2:
            np.random.seed(42)
            s = pd.Series(np.random.rand(np.random.randint(26, 30)))
        return s

    def generate_ans(data):
        result = len(data) - pd.Series(rankdata(data)).astype(int)
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(test_input)
    return test_input, expected_result

def test_execution(solution: str):
    exec_context = """
import pandas as pd
from scipy.stats import rankdata
s = test_input
def f(s):
[insert]
result = f(s)
"""
    code = exec_context.replace("[insert]", solution)
    for i in range(2):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        np.testing.assert_array_equal(test_env["result"], expected_result)


from numpy import linalg as LA
import numpy as np
X = np.array([[1, -2, 3, 6],
              [4, 5, -6, 5],
              [-1, 2, 5, 5],
              [4, 5,10,-25],
              [5, -2,10,25]])

result = ... # put solution in this variable

l1 = np.abs(X).sum(axis = 1)
result = X / l1.reshape(-1, 1)

import numpy as np
import copy
import tokenize, io

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            X = np.array(
                [
                    [1, -2, 3, 6],
                    [4, 5, -6, 5],
                    [-1, 2, 5, 5],
                    [4, 5, 10, -25],
                    [5, -2, 10, 25],
                ]
            )
        elif test_case_id == 2:
            X = np.array(
                [
                    [-1, -2, 3, 6],
                    [4, -5, -6, 5],
                    [-1, 2, -5, 5],
                    [4, -5, 10, -25],
                    [5, -2, 10, -25],
                ]
            )
        return X

    def generate_ans(data):
        _a = data
        X = _a
        l1 = np.abs(X).sum(axis=1)
        result = X / l1.reshape(-1, 1)
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    assert np.allclose(result, ans)
    return 1

exec_context = r"""
from numpy import linalg as LA
import numpy as np
X = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(2):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)

def test_string(solution: str):
    tokens = []
    for token in tokenize.tokenize(io.BytesIO(solution.encode("utf-8")).readline):
        tokens.append(token.string)
    assert "while" not in tokens and "for" not in tokens

import pandas as pd
import numpy as np

data = {
    'A': [1, 4, -1, 4, 5],
    'B': [-2, 5, 2, 5, -2],
    'C': [3, -6, 5, 10, 10],
    'D': [6, 5, 5, -25, 25]
}
X = pd.DataFrame(data)

result = ... # put solution in this variable

import pandas as pd
import numpy as np
import copy
import tokenize, io

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            data = {
                'A': [1, 4, -1, 4, 5],
                'B': [-2, 5, 2, 5, -2],
                'C': [3, -6, 5, 10, 10],
                'D': [6, 5, 5, -25, 25]
            }
            X = pd.DataFrame(data)
        elif test_case_id == 2:
            data = {
                'A': [-1, 4, -1, 4, 5],
                'B': [-2, -5, 2, -5, -2],
                'C': [3, -6, -5, 10, 10],
                'D': [6, 5, 5, -25, -25]
            }
            X = pd.DataFrame(data)
        return X

    def generate_ans(data):
        X = data
        l1 = X.abs().sum(axis=1)
        result = X.div(l1, axis=0)
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    assert result.equals(ans)
    return 1

exec_context = r"""
import pandas as pd
import numpy as np
X = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(2):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)

def test_string(solution: str):
    tokens = []
    for token in tokenize.tokenize(io.BytesIO(solution.encode("utf-8")).readline):
        tokens.append(token.string)
    assert "while" not in tokens and "for" not in tokens


l2 = np.sqrt((X*X).sum(axis=-1))
result = X / l2.reshape(-1, 1)

import numpy as np
import copy
import tokenize, io

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            X = np.array(
                [
                    [1, -2, 3, 6],
                    [4, 5, -6, 5],
                    [-1, 2, 5, 5],
                    [4, 5, 10, -25],
                    [5, -2, 10, 25],
                ]
            )
        elif test_case_id == 2:
            X = np.array(
                [
                    [-1, -2, 3, 6],
                    [4, -5, -6, 5],
                    [-1, 2, -5, 5],
                    [4, -5, 10, -25],
                    [5, -2, 10, -25],
                ]
            )
        return X

    def generate_ans(data):
        _a = data
        X = _a
        l2 = np.sqrt((X * X).sum(axis=-1))
        result = X / l2.reshape(-1, 1)
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    assert np.allclose(result, ans)
    return 1

exec_context = r"""
from numpy import linalg as LA
import numpy as np
X = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(2):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)

def test_string(solution: str):
    tokens = []
    for token in tokenize.tokenize(io.BytesIO(solution.encode("utf-8")).readline):
        tokens.append(token.string)
    assert "while" not in tokens and "for" not in tokens

l2 = np.sqrt((X*X).sum(axis=1))
result = X.div(l2, axis=0)

import pandas as pd
import numpy as np
import copy
import tokenize, io

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            X = pd.DataFrame({
                'A': [1, 4, -1, 4, 5],
                'B': [-2, 5, 2, 5, -2],
                'C': [3, -6, 5, 10, 10],
                'D': [6, 5, 5, -25, 25]
            })
        elif test_case_id == 2:
            X = pd.DataFrame({
                'A': [-1, 4, -1, 4, 5],
                'B': [-2, -5, 2, -5, -2],
                'C': [3, -6, -5, 10, 10],
                'D': [6, 5, 5, -25, -25]
            })
        return X

    def generate_ans(data):
        _a = data
        X = _a
        l2 = np.sqrt((X * X).sum(axis=1))
        result = X.div(l2, axis=0)
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    assert result.equals(ans)
    return 1

exec_context = r"""
import pandas as pd
import numpy as np
X = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(2):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)

def test_string(solution: str):
    tokens = []
    for token in tokenize.tokenize(io.BytesIO(solution.encode("utf-8")).readline):
        tokens.append(token.string)
    assert "while" not in tokens and "for" not in tokens


linf = np.abs(X).max(axis = 1)
result = X / linf.reshape(-1, 1)

import numpy as np
import copy
import tokenize, io

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            X = np.array(
                [
                    [1, -2, 3, 6],
                    [4, 5, -6, 5],
                    [-1, 2, 5, 5],
                    [4, 5, 10, -25],
                    [5, -2, 10, 25],
                ]
            )
        elif test_case_id == 2:
            X = np.array(
                [
                    [-1, -2, 3, 6],
                    [4, -5, -6, 5],
                    [-1, 2, -5, 5],
                    [4, -5, 10, -25],
                    [5, -2, 10, -25],
                ]
            )
        return X

    def generate_ans(data):
        _a = data
        X = _a
        linf = np.abs(X).max(axis=1)
        result = X / linf.reshape(-1, 1)
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    assert np.allclose(result, ans)
    return 1

exec_context = r"""
from numpy import linalg as LA
import numpy as np
X = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(2):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)

def test_string(solution: str):
    tokens = []
    for token in tokenize.tokenize(io.BytesIO(solution.encode("utf-8")).readline):
        tokens.append(token.string)
    assert "while" not in tokens and "for" not in tokens

linf = X.abs().max(axis=1)
result = X.div(linf, axis=0)

import pandas as pd
import numpy as np
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            data = {
                'A': [1, 4, -1, 4, 5],
                'B': [-2, 5, 2, 5, -2],
                'C': [3, -6, 5, 10, 10],
                'D': [6, 5, 5, -25, 25]
            }
        elif test_case_id == 2:
            data = {
                'A': [-1, 4, -1, 4, 5],
                'B': [-2, -5, 2, -5, -2],
                'C': [3, -6, -5, 10, 10],
                'D': [6, 5, 5, -25, -25]
            }
        return pd.DataFrame(data)

    def generate_ans(df):
        linf = df.abs().max(axis=1)
        result = df.div(linf, axis=0)
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(2):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert np.allclose(test_env["result"], expected_result)

exec_context = r"""
import pandas as pd
import numpy as np
X = test_input
[insert]
"""


import numpy as np
a = np.array([[1,2,8],
     [7,4,2],
     [9,1,7],
     [0,1,5],
     [6,4,3]])

result = ... # put solution in this variable

result = np.linalg.norm(a - a[:, None], axis = -1)

import numpy as np
import copy
import tokenize, io

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            a = np.array([[1, 2, 8], [7, 4, 2], [9, 1, 7], [0, 1, 5], [6, 4, 3]])
        elif test_case_id == 2:
            np.random.seed(42)
            a = np.random.rand(np.random.randint(5, 10), 3)
        return a

    def generate_ans(data):
        _a = data
        a = _a
        result = np.linalg.norm(a - a[:, None], axis=-1)
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    np.testing.assert_allclose(result, ans)
    return 1

exec_context = r"""
import numpy as np
a = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(2):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)

def test_string(solution: str):
    tokens = []
    for token in tokenize.tokenize(io.BytesIO(solution.encode("utf-8")).readline):
        tokens.append(token.string)
    assert "while" not in tokens and "for" not in tokens

import pandas as pd
import numpy as np
data = pd.DataFrame({ 'x': [1, 7, 9, 0, 6], 'y': [2, 4, 1, 1, 4], 'z': [8, 2, 7, 5, 3] })

result = ... # put solution in this variable

result = np.linalg.norm(data.to_numpy() - data.to_numpy()[:, None], axis = -1)

import pandas as pd
import numpy as np
import copy
import tokenize, io

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            data = pd.DataFrame({'x': [1, 7, 9, 0, 6], 'y': [2, 4, 1, 1, 4], 'z': [8, 2, 7, 5, 3]})
        elif test_case_id == 2:
            np.random.seed(42)
            data = pd.DataFrame(np.random.rand(np.random.randint(5, 10), 3), columns=['x', 'y', 'z'])
        return data

    def generate_ans(data):
        a = data.to_numpy()
        result = np.linalg.norm(a - a[:, None], axis=-1)
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    np.testing.assert_allclose(result, ans)
    return 1

exec_context = r"""
import pandas as pd
import numpy as np
data = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(2):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)

def test_string(solution: str):
    tokens = []
    for token in tokenize.tokenize(io.BytesIO(solution.encode("utf-8")).readline):
        tokens.append(token.string)
    assert "while" not in tokens and "for" not in tokens


import numpy as np
dim = np.random.randint(4, 8)
a = np.random.rand(np.random.randint(5, 10),dim)

result = ... # put solution in this variable

result = np.triu(np.linalg.norm(a - a[:, None], axis = -1))

import numpy as np
import copy
import tokenize, io

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            np.random.seed(42)
            dim = np.random.randint(4, 8)
            a = np.random.rand(np.random.randint(5, 10), dim)
        return dim, a

    def generate_ans(data):
        _a = data
        dim, a = _a
        result = np.triu(np.linalg.norm(a - a[:, None], axis=-1))
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    np.testing.assert_allclose(result, ans)
    return 1

exec_context = r"""
import numpy as np
dim, a = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)

def test_string(solution: str):
    tokens = []
    for token in tokenize.tokenize(io.BytesIO(solution.encode("utf-8")).readline):
        tokens.append(token.string)
    assert "while" not in tokens and "for" not in tokens

import pandas as pd
import numpy as np
dim = np.random.randint(4, 8)
data = np.random.rand(np.random.randint(5, 10), dim)
a = pd.DataFrame(data, columns=[chr(65+i) for i in range(dim)])

result = ... # put solution in this variable

result = np.triu(np.linalg.norm(a.values - a.values[:, None], axis = -1))

import pandas as pd
import numpy as np
import copy
import tokenize, io

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            np.random.seed(42)
            dim = np.random.randint(4, 8)
            data = np.random.rand(np.random.randint(5, 10), dim)
            a = pd.DataFrame(data, columns=[chr(65+i) for i in range(dim)])
        return a

    def generate_ans(data):
        _a = data
        result = np.triu(np.linalg.norm(_a.values - _a.values[:, None], axis=-1))
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    np.testing.assert_allclose(result, ans)
    return 1

exec_context = r"""
import pandas as pd
import numpy as np
a = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)

def test_string(solution: str):
    tokens = []
    for token in tokenize.tokenize(io.BytesIO(solution.encode("utf-8")).readline):
        tokens.append(token.string)
    assert "while" not in tokens and "for" not in tokens


import numpy as np
a = np.array([0, 0, 1, 1, 1, 2, 2, 0, 1, 3, 3, 3])

result = ... # put solution in this variable

selection = np.ones(len(a), dtype = bool)
selection[1:] = a[1:] != a[:-1]
selection &= a != 0
result = a[selection]

import numpy as np
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            a = np.array([0, 0, 1, 1, 1, 2, 2, 0, 1, 3, 3, 3])
        elif test_case_id == 2:
            np.random.seed(42)
            a = np.random.randint(0, 3, (20,))
        return a

    def generate_ans(data):
        _a = data
        a = _a
        selection = np.ones(len(a), dtype=bool)
        selection[1:] = a[1:] != a[:-1]
        selection &= a != 0
        result = a[selection]
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    np.testing.assert_array_equal(result, ans)
    return 1

exec_context = r"""
import numpy as np
a = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(2):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)

import pandas as pd
a = pd.Series([0, 0, 1, 1, 1, 2, 2, 0, 1, 3, 3, 3])

result = ... # put solution in this variable

import pandas as pd
import numpy as np
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            a = pd.Series([0, 0, 1, 1, 1, 2, 2, 0, 1, 3, 3, 3])
        elif test_case_id == 2:
            np.random.seed(42)
            a = pd.Series(np.random.randint(0, 3, (20,)))
        return a

    def generate_ans(data):
        _a = data
        a = _a
        selection = (a != 0) & (a != a.shift(1))
        result = a[selection]
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    pd.testing.assert_series_equal(result, ans)
    return 1

exec_context = r"""
import pandas as pd
a = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(2):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


import numpy as np
a = np.array([0, 0, 1, 1, 1, 2, 2, 0, 1, 3, 3, 3]).reshape(-1, 1)

result = ... # put solution in this variable

selection = np.ones((len(a), 1), dtype = bool)
selection[1:] = a[1:] != a[:-1]
selection &= a != 0
result = a[selection].reshape(-1, 1)

import numpy as np
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            a = np.array([0, 0, 1, 1, 1, 2, 2, 0, 1, 3, 3, 3]).reshape(-1, 1)
        elif test_case_id == 2:
            np.random.seed(42)
            a = np.random.randint(0, 3, (20,)).reshape(-1, 1)
        return a

    def generate_ans(data):
        _a = data
        a = _a
        selection = np.ones((len(a), 1), dtype=bool)
        selection[1:] = a[1:] != a[:-1]
        selection &= a != 0
        result = a[selection].reshape(-1, 1)
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    np.testing.assert_array_equal(result, ans)
    return 1

exec_context = r"""
import numpy as np
a = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(2):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)

import pandas as pd
a = pd.DataFrame([0, 0, 1, 1, 1, 2, 2, 0, 1, 3, 3, 3])

result = ... # put solution in this variable

import pandas as pd
import numpy as np
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            a = pd.DataFrame([0, 0, 1, 1, 1, 2, 2, 0, 1, 3, 3, 3])
        elif test_case_id == 2:
            np.random.seed(42)
            a = pd.DataFrame(np.random.randint(0, 3, (20,)))
        return a

    def generate_ans(data):
        _a = data
        a = _a
        selection = (a != 0) & (a.diff() != 0)
        result = a[selection.values].reset_index(drop=True)
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    pd.testing.assert_frame_equal(result, ans)
    return 1

exec_context = r"""
import pandas as pd
a = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(2):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


df = pd.DataFrame({'lat': lat.ravel(), 'lon': lon.ravel(), 'val': val.ravel()})

import numpy as np
import pandas as pd
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            lat = np.array([[10, 20, 30], [20, 11, 33], [21, 20, 10]])
            lon = np.array([[100, 102, 103], [105, 101, 102], [100, 102, 103]])
            val = np.array([[17, 2, 11], [86, 84, 1], [9, 5, 10]])
        elif test_case_id == 2:
            np.random.seed(42)
            lat = np.random.rand(5, 6)
            lon = np.random.rand(5, 6)
            val = np.random.rand(5, 6)
        return lat, lon, val

    def generate_ans(data):
        _a = data
        lat, lon, val = _a
        df = pd.DataFrame({"lat": lat.ravel(), "lon": lon.ravel(), "val": val.ravel()})
        return df

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    pd.testing.assert_frame_equal(result, ans, check_dtype=False)
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
lat, lon, val = test_input
[insert]
result = df
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(2):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)

import numpy as np
import pandas as pd
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            lat = pd.Series([10, 20, 30, 20, 11, 33, 21, 20, 10])
            lon = pd.Series([100, 102, 103, 105, 101, 102, 100, 102, 103])
            val = pd.Series([17, 2, 11, 86, 84, 1, 9, 5, 10])
        elif test_case_id == 2:
            np.random.seed(42)
            lat = pd.Series(np.random.rand(30))
            lon = pd.Series(np.random.rand(30))
            val = pd.Series(np.random.rand(30))
        return lat, lon, val

    def generate_ans(data):
        lat, lon, val = data
        df = pd.DataFrame({'lat': lat, 'lon': lon, 'val': val})
        return df

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    pd.testing.assert_frame_equal(result, ans, check_dtype=False)
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
lat, lon, val = test_input
[insert]
result = df
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(2):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


df = pd.DataFrame({'lat': lat.ravel(), 'lon': lon.ravel(), 'val': val.ravel()})
df['maximum'] = df.max(axis=1)

import numpy as np
import pandas as pd
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            lat = np.array([[10, 20, 30], [20, 11, 33], [21, 20, 10]])
            lon = np.array([[100, 102, 103], [105, 101, 102], [100, 102, 103]])
            val = np.array([[17, 2, 11], [86, 84, 1], [9, 5, 10]])
        elif test_case_id == 2:
            np.random.seed(42)
            lat = np.random.rand(5, 6)
            lon = np.random.rand(5, 6)
            val = np.random.rand(5, 6)
        return lat, lon, val

    def generate_ans(data):
        _a = data
        lat, lon, val = _a
        df = pd.DataFrame({"lat": lat.ravel(), "lon": lon.ravel(), "val": val.ravel()})
        df["maximum"] = df.max(axis=1)
        return df

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    pd.testing.assert_frame_equal(result, ans, check_dtype=False)
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
lat, lon, val = test_input
[insert]
result = df
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(2):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)

import numpy as np
import pandas as pd
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            lat = pd.Series([10, 20, 30, 20, 11, 33, 21, 20, 10])
            lon = pd.Series([100, 102, 103, 105, 101, 102, 100, 102, 103])
            val = pd.Series([17, 2, 11, 86, 84, 1, 9, 5, 10])
        elif test_case_id == 2:
            np.random.seed(42)
            lat = pd.Series(np.random.rand(30))
            lon = pd.Series(np.random.rand(30))
            val = pd.Series(np.random.rand(30))
        return lat, lon, val

    def generate_ans(data):
        lat, lon, val = data
        df = pd.DataFrame({'lat': lat, 'lon': lon, 'val': val})
        df['maximum'] = df.max(axis=1)
        return df

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    pd.testing.assert_frame_equal(result, ans, check_dtype=False)
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
lat, lon, val = test_input
[insert]
result = df
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(2):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


import numpy as np
a = np.array([[1,2,3,4],
       [2,3,4,5],
       [3,4,5,6],
       [4,5,6,7]])
size = (3, 3)

result = ... # put solution in this variable

def window(arr, shape=(3, 3)):
    ans = []
    # Find row and column window sizes
    r_win = np.floor(shape[0] / 2).astype(int)
    c_win = np.floor(shape[1] / 2).astype(int)
    x, y = arr.shape
    for i in range(x):
        xmin = max(0, i - r_win)
        xmax = min(x, i + r_win + 1)
        for j in range(y):
            ymin = max(0, j - c_win)
            ymax = min(y, j + c_win + 1)
            ans.append(arr[xmin:xmax, ymin:ymax])
    return ans

result = window(a, size)

import numpy as np
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            a = np.array([[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]])
            size = (3, 3)
        return a, size

    def generate_ans(data):
        _a = data
        a, size = _a

        def window(arr, shape=(3, 3)):
            ans = []
            r_win = np.floor(shape[0] / 2).astype(int)
            c_win = np.floor(shape[1] / 2).astype(int)
            x, y = arr.shape
            for i in range(x):
                xmin = max(0, i - r_win)
                xmax = min(x, i + r_win + 1)
                for j in range(y):
                    ymin = max(0, j - c_win)
                    ymax = min(y, j + c_win + 1)
                    ans.append(arr[xmin:xmax, ymin:ymax])
            return ans

        result = window(a, size)
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    for arr1, arr2 in zip(ans, result):
        np.testing.assert_allclose(arr1, arr2)
    return 1

exec_context = r"""
import numpy as np
a, size = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)

import pandas as pd
import numpy as np
df = pd.DataFrame([[1,2,3,4], [2,3,4,5], [3,4,5,6], [4,5,6,7]])
size = (3, 3)

result = ... # put solution in this variable

import pandas as pd
import numpy as np
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            df = pd.DataFrame([[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]])
            size = (3, 3)
        return df, size

    def generate_ans(data):
        _df = data
        df, size = _df

        def window(dataframe, shape=(3, 3)):
            ans = []
            r_win = np.floor(shape[0] / 2).astype(int)
            c_win = np.floor(shape[1] / 2).astype(int)
            x, y = dataframe.shape
            for i in range(x):
                xmin = max(0, i - r_win)
                xmax = min(x, i + r_win + 1)
                for j in range(y):
                    ymin = max(0, j - c_win)
                    ymax = min(y, j + c_win + 1)
                    ans.append(dataframe.iloc[xmin:xmax, ymin:ymax])
            return ans

        result = window(df, size)
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    for df1, df2 in zip(ans, result):
        pd.testing.assert_frame_equal(df1, df2)
    return 1

exec_context = r"""
import pandas as pd
import numpy as np
df, size = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


import numpy as np
a = np.array([1 + 0j, 2 + 0j, np.inf + 0j])

result = ... # put solution in this variable

import numpy as np
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            a = np.array([1 + 0j, 2 + 0j, np.inf + 0j])
        return a

    def generate_ans(data):
        _a = data
        a = _a
        n = len(a)
        s = np.sum(a)
        result = np.real(s) / n + 1j * np.imag(s) / n
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    np.testing.assert_array_equal(result, ans)
    return 1

exec_context = r"""
import numpy as np
a = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)

import pandas as pd
import numpy as np
a = pd.Series([1 + 0j, 2 + 0j, np.inf + 0j])

result = ... # put solution in this variable

import pandas as pd
import numpy as np
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            a = pd.Series([1 + 0j, 2 + 0j, np.inf + 0j])
        return a

    def generate_ans(data):
        _a = data
        a = _a
        n = len(a)
        s = a.sum()
        result = np.real(s) / n + 1j * np.imag(s) / n
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    np.testing.assert_array_equal(result, ans)
    return 1

exec_context = r"""
import pandas as pd
import numpy as np
a = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


import numpy as np
a = np.random.rand(*np.random.randint(2, 10, (np.random.randint(2, 10))))

result = ... # put solution in this variable

import numpy as np
import pandas as pd
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            np.random.seed(42)
            a = np.random.rand(*np.random.randint(2, 10, 4))
        elif test_case_id == 2:
            np.random.seed(43)
            a = np.random.rand(*np.random.randint(2, 10, 6))
        return a

    def generate_ans(data):
        _a = data
        a = _a
        result = a[-1:, ...]
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    np.testing.assert_allclose(result, ans)
    return 1

exec_context = r"""
import numpy as np
a = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(2):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)

import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.rand(*np.random.randint(2, 10, (np.random.randint(2, 10)))))

result = ... # put solution in this variable

import pandas as pd
import numpy as np
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            np.random.seed(42)
            df = pd.DataFrame(np.random.rand(np.random.randint(2, 10), 4))
        elif test_case_id == 2:
            np.random.seed(43)
            df = pd.DataFrame(np.random.rand(np.random.randint(2, 10), 6))
        return df

    def generate_ans(data):
        _df = data
        df = _df
        result = df.iloc[-1:]
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    pd.testing.assert_frame_equal(result, ans)
    return 1

exec_context = r"""
import pandas as pd
import numpy as np
df = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(2):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


result = any(np.array_equal(c, x) for x in CNTS)

import pandas as pd
import numpy as np
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            c = pd.DataFrame({0: [75, 57, 57, 75], 1: [763, 763, 749, 749]})
            CNTS = [
                pd.DataFrame({0: [78, 63, 63, 78], 1: [1202, 1202, 1187, 1187]}),
                pd.DataFrame({0: [75, 57, 57, 75], 1: [763, 763, 749, 749]}),
                pd.DataFrame({0: [72, 58, 57, 57, 58, 72], 1: [742, 742, 741, 727, 726, 726]}),
                pd.DataFrame({0: [66, 51, 51, 66], 1: [194, 194, 179, 179]})
            ]
        elif test_case_id == 2:
            np.random.seed(42)
            c = pd.DataFrame(np.random.rand(3, 4))
            CNTS = [pd.DataFrame(np.random.rand(x, x + 2)) for x in range(3, 7)]
        elif test_case_id == 3:
            c = pd.DataFrame({0: [75, 57, 57, 75], 1: [763, 763, 749, 749]})
            CNTS = [
                pd.DataFrame({0: [75, 57, 57, 75], 1: [763, 763, 749, 749]}),
                pd.DataFrame({0: [72, 58, 57, 57, 58, 72], 1: [742, 742, 741, 727, 726, 726]}),
                pd.DataFrame({0: [66, 51, 51, 66], 1: [194, 194, 179, 179]})
            ]
        return c, CNTS

    def generate_ans(data):
        _a = data
        c, CNTS = _a
        result = any(c.equals(x) for x in CNTS)
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    assert result == ans
    return 1

exec_context = r"""
import pandas as pd
import numpy as np
c, CNTS = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(3):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


temp_c = c.copy()
temp_c[np.isnan(temp_c)] = 0
result = False
for arr in CNTS:
    temp = arr.copy()
    temp[np.isnan(temp)] = 0
    result |= np.array_equal(temp_c, temp) and (np.isnan(c) == np.isnan(arr)).all()

import numpy as np
import pandas as pd
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            c = pd.DataFrame({0: [75, 57, np.nan, 75], 1: [763, 763, 749, 749]})
            CNTS = [
                pd.DataFrame({0: [np.nan, 63, 63, 78], 1: [1202, 1202, 1187, 1187]}),
                pd.DataFrame({0: [75, 57, np.nan, 75], 1: [763, 763, 749, 749]}),
                pd.DataFrame({0: [72, 58, 57, 57, 58, 72], 1: [742, 742, 741, np.nan, 726, 726]}),
                pd.DataFrame({0: [np.nan, 51, 51, 66], 1: [194, 194, 179, 179]})
            ]
        elif test_case_id == 2:
            np.random.seed(42)
            c = pd.DataFrame(np.random.rand(3, 4))
            CNTS = [pd.DataFrame(np.random.rand(x, x + 2)) for x in range(3, 7)]
        elif test_case_id == 3:
            c = pd.DataFrame({0: [75, 57, np.nan, 75], 1: [763, 763, 749, 749]})
            CNTS = [
                pd.DataFrame({0: [np.nan, 63, 63, 78], 1: [1202, 1202, 1187, 1187]}),
                pd.DataFrame({0: [np.nan, 57, 20, 75], 1: [763, 763, 749, 749]}),
                pd.DataFrame({0: [72, 58, 57, 57, 58, 72], 1: [742, 742, 741, np.nan, 726, 726]}),
                pd.DataFrame({0: [np.nan, 51, 51, 66], 1: [194, 194, 179, 179]})
            ]
        return c, CNTS

    def generate_ans(data):
        _a = data
        c, CNTS = _a
        temp_c = c.fillna(0)
        result = False
        for df in CNTS:
            temp = df.fillna(0)
            result |= temp.equals(temp_c) and (c.isna().equals(df.isna()))
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    assert result == ans
    return 1

exec_context = r"""
import pandas as pd
c, CNTS = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(3):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


import numpy as np
from scipy import interpolate as intp
a = np.arange(0, 4, 1).reshape(2, 2)
a = a.repeat(2, axis=0).repeat(2, axis=1)
x_new = np.linspace(0, 2, 4)
y_new = np.linspace(0, 2, 4)

result = ... # put solution in this variable

import numpy as np
import copy
from scipy import interpolate as intp

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            a = np.arange(0, 4, 1).reshape(2, 2)
            a = a.repeat(2, axis=0).repeat(2, axis=1)
            x_new = np.linspace(0, 2, 4)
            y_new = np.linspace(0, 2, 4)
        return a, x_new, y_new

    def generate_ans(data):
        _a = data
        a, x_new, y_new = _a
        x = np.arange(4)
        y = np.arange(4)
        f = intp.interp2d(x, y, a)
        result = f(x_new, y_new)
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    assert np.allclose(result, ans)
    return 1

exec_context = r"""
import numpy as np
from scipy import interpolate as intp
a, x_new, y_new = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)

import pandas as pd
import numpy as np
from scipy import interpolate as intp
df = pd.DataFrame({'A': [0, 1], 'B': [2, 3]})
df = df.loc[df.index.repeat(2)].reset_index(drop=True)
x_new = np.linspace(0, 1, 4)

result = ... # put solution in this variable

result = pd.DataFrame()
for col in df.columns:
    f = intp.interp1d(np.arange(len(df)), df[col])
    result[col] = f(x_new)

import pandas as pd
import numpy as np
import copy
from scipy import interpolate as intp

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            df = pd.DataFrame({'A': [0, 1], 'B': [2, 3]})
            df = df.loc[df.index.repeat(2)].reset_index(drop=True)
            x_new = np.linspace(0, 1, 4)
        return df, x_new

    def generate_ans(data):
        _df, x_new = data
        result = pd.DataFrame()
        for col in _df.columns:
            f = intp.interp1d(np.arange(len(_df)), _df[col])
            result[col] = f(x_new)
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    assert np.allclose(result, ans)
    return 1

exec_context = r"""
import pandas as pd
import numpy as np
from scipy import interpolate as intp
df, x_new = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


import pandas as pd
import numpy as np
data = {'D':[2015,2015,2015,2015,2016,2016,2016,2017,2017,2017], 'Q':np.arange(10)}
name= 'Q_cum'

df = ... # put solution in this variable

df = pd.DataFrame(data)
df[name] = df.groupby('D').cumsum()

import numpy as np
import pandas as pd
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            data = {
                "D": [2015, 2015, 2015, 2015, 2016, 2016, 2016, 2017, 2017, 2017],
                "Q": np.arange(10),
            }
            name = "Q_cum"
        elif test_case_id == 2:
            data = {
                "D": [1995, 1995, 1996, 1996, 1997, 1999, 1999, 1999, 2017, 2017],
                "Q": 2 * np.arange(10),
            }
            name = "Q_cum"
        return data, name

    def generate_ans(data):
        _a = data
        data, name = _a
        df = pd.DataFrame(data)
        df[name] = df.groupby("D").cumsum()
        return df

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    pd.testing.assert_frame_equal(result, ans, check_dtype=False)
    return 1

exec_context = r"""
import pandas as pd
import numpy as np
data, name = test_input
[insert]
result = df
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(2):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)

df = pd.DataFrame(data)
df[name] = df.groupby('D')['Q'].cumsum()


import numpy as np
a = np.matrix([[3, 4, 3, 1],[1,3,2,6],[2,4,1,5],[3,3,5,2]])
U, i, V = np.linalg.svd(a,full_matrices=True)

i = ... # put solution in this variable

import numpy as np
import pandas as pd
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            a = np.matrix([[3, 4, 3, 1], [1, 3, 2, 6], [2, 4, 1, 5], [3, 3, 5, 2]])
        return a

    def generate_ans(data):
        _a = data
        a = _a
        U, i, V = np.linalg.svd(a, full_matrices=True)
        i = np.diag(i)
        return i

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    np.testing.assert_allclose(result, ans)
    return 1

exec_context = r"""
import numpy as np
a = test_input
U, i, V = np.linalg.svd(a,full_matrices=True)
[insert]
result = i
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)

import numpy as np
import pandas as pd
a = pd.DataFrame([[3, 4, 3, 1],[1,3,2,6],[2,4,1,5],[3,3,5,2]])
U, i, V = np.linalg.svd(a,full_matrices=True)

i = ... # put solution in this variable

import numpy as np
import pandas as pd
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            a = pd.DataFrame([[3, 4, 3, 1], [1, 3, 2, 6], [2, 4, 1, 5], [3, 3, 5, 2]])
        return a

    def generate_ans(data):
        _a = data
        a = _a
        U, i, V = np.linalg.svd(a, full_matrices=True)
        i = pd.DataFrame(np.diag(i))
        return i

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    pd.testing.assert_frame_equal(result, ans)
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
a = test_input
U, i, V = np.linalg.svd(a,full_matrices=True)
[insert]
result = i
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


import numpy as np
import pandas as pd
start = "23-FEB-2015 23:09:19.445506"
end = "24-FEB-2015 01:09:22.404973"
n = 50

result = ... # put solution in this variable

result = pd.DatetimeIndex(np.linspace(pd.Timestamp(start).value, pd.Timestamp(end).value, num = n, dtype=np.int64))

import numpy as np
import pandas as pd
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            start = "23-FEB-2015 23:09:19.445506"
            end = "24-FEB-2015 01:09:22.404973"
            n = 50
        return start, end, n

    def generate_ans(data):
        _a = data
        start, end, n = _a
        result = pd.DatetimeIndex(
            np.linspace(
                pd.Timestamp(start).value,
                pd.Timestamp(end).value,
                num=n,
                dtype=np.int64,
            )
        )
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    if type(result) == list:
        result = pd.DatetimeIndex(result)
    result = np.array(result).astype(float)
    ans = np.array(ans).astype(float)
    assert np.allclose(result, ans)
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
start, end, n = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


import numpy as np
x = np.array([0, 1, 1, 1, 3, 1, 5, 5, 5])
y = np.array([0, 2, 3, 4, 2, 4, 3, 4, 5])
a = 1
b = 4

result = ... # put solution in this variable

import numpy as np
import pandas as pd
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            x = np.array([0, 1, 1, 1, 3, 1, 5, 5, 5])
            y = np.array([0, 2, 3, 4, 2, 4, 3, 4, 5])
            a = 1
            b = 4
        elif test_case_id == 2:
            np.random.seed(42)
            x = np.random.randint(2, 7, (8,))
            y = np.random.randint(2, 7, (8,))
            a = np.random.randint(2, 7)
            b = np.random.randint(2, 7)
        return x, y, a, b

    def generate_ans(data):
        _a = data
        x, y, a, b = _a
        result = ((x == a) & (y == b)).argmax()
        if x[result] != a or y[result] != b:
            result = -1
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    np.testing.assert_array_equal(result, ans)
    return 1

exec_context = r"""
import numpy as np
x, y, a, b = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(2):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)

import pandas as pd
import numpy as np
x = pd.Series([0, 1, 1, 1, 3, 1, 5, 5, 5])
y = pd.Series([0, 2, 3, 4, 2, 4, 3, 4, 5])
a = 1
b = 4

result = ... # put solution in this variable

import pandas as pd
import numpy as np
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            x = pd.Series([0, 1, 1, 1, 3, 1, 5, 5, 5])
            y = pd.Series([0, 2, 3, 4, 2, 4, 3, 4, 5])
            a = 1
            b = 4
        elif test_case_id == 2:
            np.random.seed(42)
            x = pd.Series(np.random.randint(2, 7, (8,)))
            y = pd.Series(np.random.randint(2, 7, (8,)))
            a = np.random.randint(2, 7)
            b = np.random.randint(2, 7)
        return x, y, a, b

    def generate_ans(data):
        _a = data
        x, y, a, b = _a
        result = ((x == a) & (y == b)).idxmax()
        if x[result] != a or y[result] != b:
            result = -1
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    np.testing.assert_array_equal(result, ans)
    return 1

exec_context = r"""
import pandas as pd
x, y, a, b = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(2):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


idx_list = ((x == a) & (y == b))
result = idx_list.nonzero()[0]

import numpy as np
import pandas as pd
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            x = np.array([0, 1, 1, 1, 3, 1, 5, 5, 5])
            y = np.array([0, 2, 3, 4, 2, 4, 3, 4, 5])
            a = 1
            b = 4
        elif test_case_id == 2:
            np.random.seed(42)
            x = np.random.randint(2, 7, (8,))
            y = np.random.randint(2, 7, (8,))
            a = np.random.randint(2, 7)
            b = np.random.randint(2, 7)
        elif test_case_id == 3:
            x = np.array([0, 1, 1, 1, 3, 1, 5, 5, 5])
            y = np.array([0, 2, 3, 4, 2, 4, 3, 4, 5])
            a = 2
            b = 4
        return x, y, a, b

    def generate_ans(data):
        _a = data
        x, y, a, b = _a
        idx_list = (x == a) & (y == b)
        result = idx_list.nonzero()[0]
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    np.testing.assert_array_equal(result, ans)
    return 1

exec_context = r"""
import numpy as np
x, y, a, b = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(3):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)

import pandas as pd
x = pd.Series([0, 1, 1, 1, 3, 1, 5, 5, 5])
y = pd.Series([0, 2, 3, 4, 2, 4, 3, 4, 5])
a = 1
b = 4

result = ... # put solution in this variable

idx_list = ((x == a) & (y == b))
result = idx_list[idx_list].index.tolist()

import numpy as np
import pandas as pd
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            x = pd.Series([0, 1, 1, 1, 3, 1, 5, 5, 5])
            y = pd.Series([0, 2, 3, 4, 2, 4, 3, 4, 5])
            a = 1
            b = 4
        elif test_case_id == 2:
            np.random.seed(42)
            x = pd.Series(np.random.randint(2, 7, (8,)))
            y = pd.Series(np.random.randint(2, 7, (8,)))
            a = np.random.randint(2, 7)
            b = np.random.randint(2, 7)
        elif test_case_id == 3:
            x = pd.Series([0, 1, 1, 1, 3, 1, 5, 5, 5])
            y = pd.Series([0, 2, 3, 4, 2, 4, 3, 4, 5])
            a = 2
            b = 4
        return x, y, a, b

    def generate_ans(data):
        _a = data
        x, y, a, b = _a
        idx_list = (x == a) & (y == b)
        result = idx_list[idx_list].index.tolist()
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    assert result == ans
    return 1

exec_context = r"""
import pandas as pd
x, y, a, b = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(3):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


import numpy as np
x = [-1, 2, 5, 100]
y = [123, 456, 789, 1255]

result = ... # put solution in this variable

import numpy as np
import pandas as pd
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            x = [-1, 2, 5, 100]
            y = [123, 456, 789, 1255]
        elif test_case_id == 2:
            np.random.seed(42)
            x = (np.random.rand(100) - 0.5) * 10
            y = (np.random.rand(100) - 0.5) * 10
        return x, y

    def generate_ans(data):
        _a = data
        x, y = _a
        result = np.polyfit(x, y, 2)
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    np.testing.assert_allclose(result, ans)
    return 1

exec_context = r"""
import numpy as np
x, y = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(2):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)

import numpy as np
import pandas as pd
data = pd.DataFrame({'x': [-1, 2, 5, 100], 'y': [123, 456, 789, 1255]})

result = ... # put solution in this variable

import numpy as np
import pandas as pd
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            data = pd.DataFrame({'x': [-1, 2, 5, 100], 'y': [123, 456, 789, 1255]})
        elif test_case_id == 2:
            np.random.seed(42)
            x = (np.random.rand(100) - 0.5) * 10
            y = (np.random.rand(100) - 0.5) * 10
            data = pd.DataFrame({'x': x, 'y': y})
        return data

    def generate_ans(data):
        result = np.polyfit(data['x'], data['y'], 2)
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    np.testing.assert_allclose(result, ans)
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
data = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(2):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


import numpy as np
import pandas as pd
a = np.arange(4)
df = pd.DataFrame(np.repeat([1, 2, 3, 4], 4).reshape(4, -1))

df = ... # put solution in this variable

import numpy as np
import pandas as pd
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            a = np.arange(4)
            df = pd.DataFrame(
                np.repeat([1, 2, 3, 4], 4).reshape(4, -1), columns=["a", "b", "c", "d"]
            )
        elif test_case_id == 2:
            np.random.seed(42)
            a = np.random.randint(0, 10, (4,))
            df = pd.DataFrame(
                np.repeat([1, 2, 3, 4], 4).reshape(4, -1), columns=["a", "b", "c", "d"]
            )
        return a, df

    def generate_ans(data):
        _a = data
        a, df = _a
        df = pd.DataFrame(df.values - a[:, None], df.index, df.columns)
        return df

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    pd.testing.assert_frame_equal(result, ans, check_dtype=False)
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
a, df = test_input
[insert]
result = df
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(2):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


import numpy as np
from sklearn.preprocessing import MinMaxScaler
a = np.array([[-1, 2], [-0.5, 6]])

result = ... # put solution in this variable

import numpy as np
import copy
from sklearn.preprocessing import MinMaxScaler

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            a = np.array([[-1, 2], [-0.5, 6]])
        elif test_case_id == 2:
            np.random.seed(42)
            a = np.random.rand(10, 10)
        return a

    def generate_ans(data):
        _a = data
        a = _a
        scaler = MinMaxScaler()
        a_one_column = a.reshape(-1, 1)
        result_one_column = scaler.fit_transform(a_one_column)
        result = result_one_column.reshape(a.shape)
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    np.testing.assert_allclose(result, ans)
    return 1

exec_context = r"""
import numpy as np
from sklearn.preprocessing import MinMaxScaler
a = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(2):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)

import pandas as pd
import numpy as np
from sklearn.preprocessing import MinMaxScaler
df = pd.DataFrame({'A': [-1, -0.5], 'B': [2, 6]})

result = ... # put solution in this variable

import pandas as pd
import numpy as np
from sklearn.preprocessing import MinMaxScaler

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            df = pd.DataFrame({'A': [-1, -0.5], 'B': [2, 6]})
        elif test_case_id == 2:
            np.random.seed(42)
            data = np.random.rand(10, 10)
            df = pd.DataFrame(data)
        return df

    def generate_ans(data):
        df = data
        scaler = MinMaxScaler()
        df_one_column = df.values.reshape(-1, 1)
        result_one_column = scaler.fit_transform(df_one_column)
        result = pd.DataFrame(result_one_column.reshape(df.shape), columns=df.columns)
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(test_input.copy())
    return test_input, expected_result

def test_execution(solution: str):
    exec_context = r"""
import pandas as pd
import numpy as np
from sklearn.preprocessing import MinMaxScaler
df = test_input
[insert]
"""
    for i in range(2):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {'test_input': test_input}
        code = exec_context.replace('[insert]', solution)
        exec(code, test_env)
        pd.testing.assert_frame_equal(test_env['result'], expected_result)


import numpy as np
n = 10
m = 4
tag = np.random.rand(n, m)
s1 = np.sum(tag, axis=1)
s2 = np.sum(tag[:, ::-1], axis=1)

import numpy as np
n = 20
m = 10
tag = np.random.rand(n, m)
s1 = np.sum(tag, axis=1)
s2 = np.sum(tag[:, ::-1], axis=1)

result = ... # put solution in this variable

import numpy as np
import pandas as pd
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            np.random.seed(42)
            tag = np.random.rand(20, 10)
            s1 = np.sum(tag, axis=1)
            s2 = np.sum(tag[:, ::-1], axis=1)
        elif test_case_id == 2:
            np.random.seed(45)
            s1 = np.random.rand(6, 1)
            s2 = np.random.rand(6, 1)
        return s1, s2

    def generate_ans(data):
        _a = data
        s1, s2 = _a
        result = (~np.isclose(s1, s2)).sum()
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    assert np.allclose(result, ans)
    return 1

exec_context = r"""
import numpy as np
n = 20
m = 10
tag = np.random.rand(n, m)
s1, s2 = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(2):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)

import pandas as pd
import numpy as np
n = 10
m = 4
tag = pd.DataFrame(np.random.rand(n, m))
s1 = tag.sum(axis=1)
s2 = tag.iloc[:, ::-1].sum(axis=1)

import numpy as np
import pandas as pd
n = 20
m = 10
tag = pd.DataFrame(np.random.rand(n, m))
s1 = tag.sum(axis=1)
s2 = tag.iloc[:, ::-1].sum(axis=1)

result = ... # put solution in this variable

import numpy as np
import pandas as pd
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            np.random.seed(42)
            tag = pd.DataFrame(np.random.rand(20, 10))
            s1 = tag.sum(axis=1)
            s2 = tag.iloc[:, ::-1].sum(axis=1)
        elif test_case_id == 2:
            np.random.seed(45)
            s1 = pd.Series(np.random.rand(6))
            s2 = pd.Series(np.random.rand(6))
        return s1, s2

    def generate_ans(data):
        _a = data
        s1, s2 = _a
        result = (~s1.isin(s2)).sum()
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    assert np.allclose(result, ans)
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
n = 20
m = 10
tag = pd.DataFrame(np.random.rand(n, m))
s1, s2 = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(2):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


import numpy as np
a = [np.array([1,2,3]),np.array([1,2,3]),np.array([1,2,3])]

result = ... # put solution in this variable

import numpy as np
import pandas as pd
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            a = [np.array([1, 2, 3]), np.array([1, 2, 3]), np.array([1, 2, 3])]
        elif test_case_id == 2:
            a = [np.array([1, 2, 4]), np.array([1, 2, 3]), np.array([1, 2, 3])]
        elif test_case_id == 3:
            a = [np.array([1, 2, 3]), np.array([1, 2, 4]), np.array([1, 2, 3])]
        elif test_case_id == 4:
            a = [
                np.array([1, 2, 3]),
                np.array([1, 2, 3]),
                np.array([1, 2, 3]),
                np.array([1, 2, 3]),
            ]
        elif test_case_id == 5:
            a = [
                np.array([1, 2, 3]),
                np.array([1, 2, 3]),
                np.array([1, 2, 3]),
                np.array([1, 2, 4]),
            ]
        return a

    def generate_ans(data):
        _a = data
        a = _a

        def all_equal(iterator):
            try:
                iterator = iter(iterator)
                first = next(iterator)
                return all(np.array_equal(first, rest) for rest in iterator)
            except StopIteration:
                return True

        result = all_equal(a)
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    np.testing.assert_array_equal(result, ans)
    return 1

exec_context = r"""
import numpy as np
a = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(5):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)

import pandas as pd
import numpy as np
a = [pd.Series([1,2,3]),pd.Series([1,2,3]),pd.Series([1,2,3])]

result = ... # put solution in this variable

import pandas as pd
import numpy as np
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            a = [pd.Series([1, 2, 3]), pd.Series([1, 2, 3]), pd.Series([1, 2, 3])]
        elif test_case_id == 2:
            a = [pd.Series([1, 2, 4]), pd.Series([1, 2, 3]), pd.Series([1, 2, 3])]
        elif test_case_id == 3:
            a = [pd.Series([1, 2, 3]), pd.Series([1, 2, 4]), pd.Series([1, 2, 3])]
        elif test_case_id == 4:
            a = [
                pd.Series([1, 2, 3]),
                pd.Series([1, 2, 3]),
                pd.Series([1, 2, 3]),
                pd.Series([1, 2, 3]),
            ]
        elif test_case_id == 5:
            a = [
                pd.Series([1, 2, 3]),
                pd.Series([1, 2, 3]),
                pd.Series([1, 2, 3]),
                pd.Series([1, 2, 4]),
            ]
        return a

    def generate_ans(data):
        _a = data
        a = _a

        def all_equal(iterator):
            try:
                iterator = iter(iterator)
                first = next(iterator)
                return all(first.equals(rest) for rest in iterator)
            except StopIteration:
                return True

        result = all_equal(a)
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    np.testing.assert_array_equal(result, ans)
    return 1

exec_context = r"""
import pandas as pd
a = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(5):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


arrays = [np.array([1, 2, np.nan]), np.array([4, 5, 6]), np.array([np.nan, 8, 9])]

import numpy as np
a = [np.array([np.nan,2,3]),np.array([1,np.nan,3]),np.array([1,2,np.nan])]

result = ... # put solution in this variable

import numpy as np
import pandas as pd
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            a = [
                np.array([np.nan, 2, 3]),
                np.array([1, np.nan, 3]),
                np.array([1, 2, np.nan]),
            ]
        elif test_case_id == 2:
            a = [
                np.array([np.nan, 2, 3]),
                np.array([1, np.nan, 3]),
                np.array([1, 2, 3]),
            ]
        elif test_case_id == 3:
            a = [np.array([10, 2, 3]), np.array([1, 9, 3]), np.array([1, 6, 3])]
        elif test_case_id == 4:
            a = [np.array([10, 4, 3]), np.array([1, np.nan, 3]), np.array([8, 6, 3])]
        elif test_case_id == 5:
            a = [
                np.array([np.nan, np.nan]),
                np.array([np.nan, np.nan]),
                np.array([np.nan, np.nan]),
            ]
        return a

    def generate_ans(data):
        _a = data
        a = _a
        result = True
        for arr in a:
            if any(np.isnan(arr)) == False:
                result = False
                break
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    np.testing.assert_array_equal(result, ans)
    return 1

exec_context = r"""
import numpy as np
a = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(5):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)

series_list = [pd.Series([1, 2, np.nan]), pd.Series([4, np.nan, 6])]

import numpy as np
import pandas as pd
a = [pd.Series([np.nan,2,3]),pd.Series([1,np.nan,3]),pd.Series([1,2,np.nan])]

result = ... # put solution in this variable

import numpy as np
import pandas as pd
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            a = [
                pd.Series([np.nan, 2, 3]),
                pd.Series([1, np.nan, 3]),
                pd.Series([1, 2, np.nan]),
            ]
        elif test_case_id == 2:
            a = [
                pd.Series([np.nan, 2, 3]),
                pd.Series([1, np.nan, 3]),
                pd.Series([1, 2, 3]),
            ]
        elif test_case_id == 3:
            a = [pd.Series([10, 2, 3]), pd.Series([1, 9, 3]), pd.Series([1, 6, 3])]
        elif test_case_id == 4:
            a = [pd.Series([10, 4, 3]), pd.Series([1, np.nan, 3]), pd.Series([8, 6, 3])]
        elif test_case_id == 5:
            a = [
                pd.Series([np.nan, np.nan]),
                pd.Series([np.nan, np.nan]),
                pd.Series([np.nan, np.nan]),
            ]
        return a

    def generate_ans(data):
        _a = data
        a = _a
        result = True
        for arr in a:
            if arr.isna().any() == False:
                result = False
                break
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    np.testing.assert_array_equal(result, ans)
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
a = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(5):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


import numpy as np
a = np.ones((41, 13))
shape = (93, 13)

result = ... # put solution in this variable

result = np.pad(a, ((0, shape[0]-a.shape[0]), (0, shape[1]-a.shape[1])), 'constant')

import numpy as np
import pandas as pd
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            a = np.ones((41, 13))
            shape = (93, 13)
        return a, shape

    def generate_ans(data):
        _a = data
        a, shape = _a
        result = np.pad(
            a, ((0, shape[0] - a.shape[0]), (0, shape[1] - a.shape[1])), "constant"
        )
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    np.testing.assert_array_equal(result, ans)
    return 1

exec_context = r"""
import numpy as np
a, shape = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)

import pandas as pd
import numpy as np
df = pd.DataFrame({'A': pd.Series(np.ones(41))})
length = 93

result = ... # put solution in this variable

import numpy as np
import pandas as pd
import copy

def generate_test_case(test_case_id):
    def define_test_input(test_case_id):
        if test_case_id == 1:
            df = pd.DataFrame({'A': pd.Series(np.ones(41))})
            length = 93
        return df, length

    def generate_ans(data):
        _df, length = data
        result = _df.reindex(range(length)).fillna(0)
        return result

    test_input = define_test_input(test_case_id)
    expected_result = generate_ans(copy.deepcopy(test_input))
    return test_input, expected_result

def exec_test(result, ans):
    pd.testing.assert_frame_equal(result, ans)
    return 1

exec_context = r"""
import pandas as pd
import numpy as np
df, length = test_input
[insert]
"""

def test_execution(solution: str):
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)