import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
def LI_vecs(M):
    dim = M.shape[0]
    LI=[M[0]]
    for i in range(dim):
        tmp=[]
        for r in LI:
            tmp.append(r)
        tmp.append(M[i])                #set tmp=LI+[M[i]]
        if np.linalg.matrix_rank(tmp)>len(LI):    #test if M[i] is linearly independent from all (row) vectors in LI
            LI.append(M[i])             #note that matrix_rank does not need to take in a square matrix
    return LI                           #return set of linearly independent (row) vectors
result = LI_vecs(a)
#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, size = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
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 j in range(y):
        ymin = max(0, j - c_win)
        ymax = min(y, j + c_win + 1)
        for i in range(x):
            xmin = max(0, i - r_win)
            xmax = min(x, i + r_win + 1)

            ans.append(arr[xmin:xmax, ymin:ymax])
    return ans
result = window(a, size)
#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
grades = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
def ecdf_result(x):
    xs = np.sort(x)
    ys = np.arange(1, len(xs)+1)/float(len(xs))
    return ys
result = ecdf_result(grades)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, shape = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.pad(a, ((0, shape[0]-a.shape[0]), (0, shape[1]-a.shape[1])), 'constant')

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
interval = (a.mean()-2*a.std(), a.mean()+2*a.std())
result = ~np.logical_and(a>interval[0], a<interval[1])

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.unravel_index(a.argmax(), a.shape)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, m = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = (((a[:,None] & (1 << np.arange(m))[::-1])) > 0).astype(int)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, b = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
sort_indices = np.argsort(a, axis=0)
static_indices = np.indices(a.shape)
c = b[sort_indices, static_indices[1], static_indices[2]]

#print(c)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(c, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
A, NA = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
AVG = np.mean(NA.astype(float), axis = 0)

#print(AVG)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(AVG, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, b, c = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.mean([a, b, c], axis=0)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
idx = np.unravel_index(a.argmax(), a.shape)
a[idx] = a.min()
result = np.unravel_index(a.argmax(), a.shape)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, low, high = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
high = min(high, a.shape[1])
result = a[:, low:high]

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np

min, max, n = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))

import scipy.stats
result = scipy.stats.loguniform.rvs(a = min, b = max, size = n)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
A, n = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.linalg.matrix_power(A, n)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, zero_rows, zero_cols = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
a[zero_rows, :] = 0
a[:, zero_cols] = 0

#print(a)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(a, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, pos, element = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
pos = np.array(pos) - np.arange(len(element))
a = np.insert(a, pos, element, axis=0)

#print(a)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(a, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, accmap = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
add = np.max(accmap)
mask = accmap < 0
accmap[mask] += add+1
result = np.bincount(accmap, weights = a)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
a = a.reshape(-1, 3)

#print(a)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(a, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
import pandas as pd
start, end, n = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = pd.DatetimeIndex(np.linspace(pd.Timestamp(start).value, pd.Timestamp(end).value, num = n, dtype=np.int64))

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
c, CNTS = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = any(np.array_equal(c, x) for x in CNTS)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, row, multiply_number = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
a[row-1, :] *= multiply_number
result = np.cumsum(a[row-1, :])

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
dims, a, index = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.ravel_multi_index(index, dims=dims, order='F')

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, N = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.argsort(a)[::-1][:N]

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
def f(a):
    result = (a.mean()-3*a.std(), a.mean()+3*a.std())

    return result

result = f(a)
with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
X = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = X.T[:, :, None] * X.T[:, None]

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
X = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = []
for value in X.T.flat:
    result.append(value)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, col, multiply_number = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
a[:, col-1] *= multiply_number
result = np.cumsum(a[:, col-1])

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
A, NA = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
for i in range(len(NA)):
    NA[i] = NA[i].replace('np.', '')
AVG = np.mean(NA.astype(float), axis = 0)

#print(AVG)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(AVG, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.isclose(a, a[0], atol=0).all()

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
data, bin_size = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
new_data = data[:, ::-1]
bin_data_mean = new_data[:,:(data.shape[1] // bin_size) * bin_size].reshape(data.shape[0], -1, bin_size).mean(axis=-1)[:,::-1]

#print(bin_data_mean)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(bin_data_mean, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, index = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
uni = np.unique(index)
result = np.zeros(np.amax(index)+1)
for i in uni:
    result[i] = np.max(a[index==i])

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
n = 20
m = 10
tag = np.random.rand(n, m)
s1, s2 = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = (~np.isclose(s1,s2)).sum()

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
import scipy.stats
a, b = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
_, p_value = scipy.stats.ttest_ind(a, b,  equal_var = False, nan_policy = 'omit')

#print(p_value)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(p_value, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.argsort(a)[::-1][:len(a)]

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
A, B = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
C = A[np.in1d(A,B)]

#print(C)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(C, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
n = len(a)
s = np.sum(a)
result = np.real(s) / n + 1j * np.imag(s) / n

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
import pandas as pd
names, times, df = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = df.values.reshape(15, 5, 4).transpose(2, 0, 1)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
mask = (a.min(axis=1,keepdims=1) == a)

#print(mask)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(mask, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
dims, a, index = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.ravel_multi_index(index, dims=dims, order='C')

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, shift = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
def solution(xs, n):
    e = np.empty_like(xs)
    if n >= 0:
        e[:n] = np.nan
        e[n:] = xs[:-n]
    else:
        e[n:] = np.nan
        e[:n] = xs[-n:]
    return e
result = solution(a, shift)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
temp = a - a.min()
b = np.zeros((a.size, temp.max()+1))
b[np.arange(a.size), temp]=1

#print(b)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(b, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
post, distance = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.corrcoef(post, distance)[0][1]

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
def f(a):
    result = np.isclose(a, a[0], atol=0).all()

    return result

result = f(a)
with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, row, divide_number = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
a[row-1, :] /= divide_number
result = np.multiply.reduce(a[row-1, :])

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, pos, element = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
a = np.insert(a, pos, element, axis = 0)

#print(a)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(a, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, b = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
sort_indices = np.argsort(a, axis=0)
static_indices = np.indices(a.shape)
c = b[sort_indices, static_indices[1], static_indices[2]]

#print(c)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(c, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
x, y = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
from scipy.integrate import simpson
z = np.cos(x[:,None])**4 + np.sin(y)**2
result = simpson(simpson(z, y), x)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, patch_size = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
x = a[:a.shape[0] // patch_size * patch_size, :a.shape[1] // patch_size * patch_size]
result = x.reshape(x.shape[0]//patch_size, patch_size, x.shape[1]// patch_size, patch_size).swapaxes(1, 2).transpose(1, 0, 2, 3).reshape(-1, patch_size, patch_size)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
result = np.array([[], [], []])

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
from numpy import linalg as LA
import numpy as np
X = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
l1 = np.abs(X).sum(axis = 1)
result = X / l1.reshape(-1, 1)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
A, B = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
C = A[~np.in1d(A,B)]

#print(C)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(C, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
dim = min(a.shape)
b = a[:dim,:dim]
result = np.vstack((np.diag(b), np.diag(np.fliplr(b))))

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
x, y, a, b = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
idx_list = ((x == a) & (y == b))
result = idx_list.nonzero()[0]

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import torch
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
a_pt = torch.Tensor(a)

#print(a_pt)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(a_pt, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.argwhere(a == np.min(a))

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
X = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = []
for value in X.flat:
    result.append(value)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
import pandas as pd
A, a, b, c = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
B = np.empty(len(A))
for k in range(0, len(B)):
    if k == 0:
        B[k] = a*A[k]
    elif k == 1:
        B[k] = a*A[k] + b*B[k-1]
    else:
        B[k] = a*A[k] + b*B[k-1] + c*B[k-2]

#print(B)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(B, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, m = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = (((a[:,None] & (1 << np.arange(m))[::-1])) > 0).astype(int)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
from sklearn.preprocessing import MinMaxScaler
arr = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
from sklearn.preprocessing import minmax_scale
result = minmax_scale(arr.T).T

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
x, y = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
def f(x, y):
    from scipy.integrate import simpson
    z = np.cos(x[:,None])**4 + np.sin(y)**2
    result = simpson(simpson(z, y), x)

    return result

result = f(x, y)
with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
degree = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))

result = np.cos(np.deg2rad(degree))

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, m = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
res = np.array([0])
for i in a:
    res = res ^ i
result = (((res[:,None] & (1 << np.arange(m))[::-1])) > 0).astype(int)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np

numerator, denominator = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
if denominator == 0:
    result = (np.nan, np.nan)
else:
    gcd = np.gcd(numerator, denominator)
    result = (numerator//gcd, denominator//gcd)
#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
from sklearn.preprocessing import MinMaxScaler
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
scaler = MinMaxScaler()
result = np.zeros_like(a)
for i, arr in enumerate(a):
    a_one_column = arr.reshape(-1, 1)
    result_one_column = scaler.fit_transform(a_one_column)
    result[i, :, :] = result_one_column.reshape(arr.shape)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, b = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
index = np.argsort(a.sum(axis = (1, 2)))
result = b[index, :, :]

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
import scipy.stats
amean, avar, anobs, bmean, bvar, bnobs = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
_, p_value = scipy.stats.ttest_ind_from_stats(amean, np.sqrt(avar), anobs, bmean, np.sqrt(bvar), bnobs, equal_var=False)

#print(p_value)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(p_value, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
mask = (a.max(axis=1,keepdims=1) == a)

#print(mask)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(mask, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, size = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
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)
#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
mystr = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.array(list(mystr), dtype = int)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
X = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
def f(X):
    result = []
    for value in X.flat:
        result.append(value)

    return result

result = f(X)
with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, h, w = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
n, nrows, ncols = a.shape
result = a.reshape(h//nrows, -1, nrows, ncols).swapaxes(1,2).reshape(h, w)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
probabilit, lista_elegir, samples = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
np.random.seed(42)
temp = np.array(lista_elegir)
result = temp[np.random.choice(len(lista_elegir),samples,p=probabilit)]

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np

a,permutation = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
c = np.empty_like(permutation)
c[permutation] = np.arange(len(permutation))
result = a[c, :, :]

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
string = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
a = np.array(np.matrix(string.replace(',', ';')))

#print(a)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(a, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, zero_rows, zero_cols = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
a[zero_rows, :] = 0
a[:, zero_cols] = 0

#print(a)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(a, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
A, length = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.pad(A, (0, length-A.shape[0]), 'constant')

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
A, B = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.tensordot(A,B,axes=((2),(0)))

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, pos, element = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
a = np.insert(a, pos, element)

#print(a)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(a, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
size, one_ratio = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
nums = np.ones(size)
nums[:int(size*(1-one_ratio))] = 0
np.random.shuffle(nums)
#print(nums)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(nums, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
dim, a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.linalg.norm(a - a[:, None], axis = -1)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
z = np.any(np.isnan(a), axis = 0)
a = a[:, ~z]

#print(a)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(a, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = a.reshape(a.shape[0]//2, 2, a.shape[1]//2, 2).swapaxes(1, 2).reshape(-1, 2, 2)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import tensorflow as tf
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
a_tf = tf.convert_to_tensor(a)

#print(a_tf)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(a_tf, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
x, y, a, b = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = ((x == a) & (y == b)).argmax()
if x[result] != a or y[result] != b:
    result = -1

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
def f(a):
    n = len(a)
    s = np.sum(a)
    result = np.real(s) / n + 1j * np.imag(s) / n

    return result

result = f(a)
with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
A, ncol = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
B = np.reshape(A, (-1, ncol))

#print(B)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(B, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
x, x_min, x_max, N = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
from scipy.special import comb

def smoothclamp(x, x_min=0, x_max=1, N=1):
    if x < x_min:
        return x_min
    if x > x_max:
        return x_max
    x = np.clip((x - x_min) / (x_max - x_min), 0, 1)

    result = 0
    for n in range(0, N + 1):
        result += comb(N + n, n) * comb(2 * N + 1, N - n) * (-x) ** n

    result *= x ** (N + 1)
    return result

result = smoothclamp(x, N=N)
#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
im = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
mask = im == 0
rows = np.flatnonzero((~mask).sum(axis=1))
cols = np.flatnonzero((~mask).sum(axis=0))
if rows.shape[0] == 0:
    result = np.array([])
else:
    result = im[rows.min():rows.max()+1, cols.min():cols.max()+1]

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, permutation = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
c = np.empty_like(permutation)
c[permutation] = np.arange(len(permutation))
a = a[:, c]

#print(a)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(a, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
data, bin_size = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
bin_data_max = data[:(data.size // bin_size) * bin_size].reshape(-1, bin_size).max(axis=1)

#print(bin_data_max)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(bin_data_max, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
c, CNTS = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
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()

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, low_index, high_index = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
def fill_crop(img, pos, crop):
    img_shape, pos, crop_shape = np.array(img.shape), np.array(pos), np.array(crop.shape),
    end = pos+crop_shape
    # Calculate crop slice positions
    crop_low = np.clip(0 - pos, a_min=0, a_max=crop_shape)
    crop_high = crop_shape - np.clip(end-img_shape, a_min=0, a_max=crop_shape)
    crop_slices = (slice(low, high) for low, high in zip(crop_low, crop_high))
    # Calculate img slice positions
    pos = np.clip(pos, a_min=0, a_max=img_shape)
    end = np.clip(end, a_min=0, a_max=img_shape)
    img_slices = (slice(low, high) for low, high in zip(pos, end))
    crop[tuple(crop_slices)] = img[tuple(img_slices)]
    return crop
result = fill_crop(a, [low_index, low_index], np.zeros((high_index-low_index, high_index-low_index)))

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, b = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.correlate(a, np.hstack((b[1:], b)), mode='valid')

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.unravel_index(a.argmin(), a.shape)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
A, ncol = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
col = ( A.shape[0] // ncol) * ncol
B = A[len(A)-col:][::-1]
B = np.reshape(B, (-1, ncol))

#print(B)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(B, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
b = np.zeros((a.size, a.max()+1))
b[np.arange(a.size), a]=1

#print(b)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(b, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
z = np.any(np.isnan(a), axis = 1)
a = a[~z, :]

#print(a)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(a, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
import pandas as pd
data, df = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.where((df.a<= 4)&(df.a>1), df.b,np.nan)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, shift = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
def solution(xs, n):
    e = np.empty_like(xs)
    if n >= 0:
        e[:,:n] = np.nan
        e[:,n:] = xs[:,:-n]
    else:
        e[:,n:] = np.nan
        e[:,:n] = xs[:,-n:]
    return e
result = solution(a, shift)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
x = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = [x[i, row] for i, row in enumerate(~np.isnan(x))]

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
a = np.delete(a, 2, axis = 1)

#print(a)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(a, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, low, high = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = a[:, low:high]

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
data, bin_size = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
bin_data_mean = data[:(data.size // bin_size) * bin_size].reshape(-1, bin_size).mean(axis=1)

#print(bin_data_mean)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(bin_data_mean, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np

min, max, n = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))

import scipy.stats
result = scipy.stats.loguniform.rvs(a = np.exp(min), b = np.exp(max), size = n)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, b = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
arr = np.take_along_axis(a, b[..., np.newaxis], axis=-1)[..., 0]
result = np.sum(a) - np.sum(arr)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
A, B = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
dims = np.maximum(B.max(0),A.max(0))+1
output = A[~np.in1d(np.ravel_multi_index(A.T,dims),np.ravel_multi_index(B.T,dims))]

#print(output)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(output, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
x_dists, y_dists = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
dists = np.vstack(([x_dists.T], [y_dists.T])).T

#print(dists)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(dists, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, power = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
a = a ** power

#print(a)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(a, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
Y = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
X = np.zeros([Y.shape[1], Y.shape[0]])
for i, mat in enumerate(Y):
    diag = np.sqrt(np.diag(mat))
    X[:, i] += diag

#print(X)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(X, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
numerator, denominator = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
def f(numerator, denominator):
    gcd = np.gcd(numerator, denominator)
    result = (numerator//gcd, denominator//gcd)

    return result

result = f(numerator, denominator)
with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
grades, eval = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
def ecdf_result(x):
    xs = np.sort(x)
    ys = np.arange(1, len(xs)+1)/float(len(xs))
    return xs, ys
resultx, resulty = ecdf_result(grades)
result = np.zeros_like(eval, dtype=float)
for i, element in enumerate(eval):
    if element < resultx[0]:
        result[i] = 0
    elif element >= resultx[-1]:
        result[i] = 1
    else:
        result[i] = resulty[(resultx > element).argmax()-1]
#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
import pandas as pd
lat, lon, val = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
def f(lat, lon,val):
    df = pd.DataFrame({'lat': lat.ravel(), 'lon': lon.ravel(), 'val': val.ravel()})

    return df
result = f(lat, lon, val)
with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
number = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
deg = np.sin(np.deg2rad(number))
rad = np.sin(number)
result = int(rad > deg)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
import pandas as pd
df, target, choices = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
conds = df.a.str.contains(target, na=False)
result = np.select([conds], choices, default = np.nan)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
a[1, :] = 0
a[:, 0] = 0

#print(a)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(a, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
im = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
mask = im == 0
rows = np.flatnonzero((mask).sum(axis=1))
cols = np.flatnonzero((mask).sum(axis=0))

if rows.shape[0] == 0:
    result = np.array([])
else:
    result = im[rows.min():rows.max()+1, cols.min():cols.max()+1]

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, b = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.take_along_axis(a, b[..., np.newaxis], axis=-1)[..., 0]

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import pandas as pd
import numpy as np
data, name = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
df = pd.DataFrame(data)
df[name] = df.groupby('D').cumsum()

#print(df)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(df, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
from sklearn.preprocessing import MinMaxScaler
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
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)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
x, y = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
x_new = np.array(x)
y_new = np.array(y)
z = x_new + y_new

#print(z)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(z, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
from scipy import interpolate as intp
a, x_new, y_new = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
x = np.arange(4)
y = np.arange(4)
f = intp.interp2d(x, y, a)
result = f(x_new, y_new)
#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, shape = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
def to_shape(a, shape):
    y_, x_ = shape
    y, x = a.shape
    y_pad = (y_-y)
    x_pad = (x_-x)
    return np.pad(a,((y_pad//2, y_pad//2 + y_pad%2),
                        (x_pad//2, x_pad//2 + x_pad%2)),
                    mode = 'constant')
result = to_shape(a, shape)
#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
from numpy import linalg as LA
import numpy as np
X = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
linf = np.abs(X).max(axis = 1)
result = X / linf.reshape(-1, 1)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
A = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
B = np.argwhere(A)
(ystart, xstart), (ystop, xstop) = B.min(0), B.max(0) + 1
result = A[ystart:ystop, xstart:xstop]

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
arr, n1, n2 = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
for a, t1, t2 in zip(arr, n1, n2):
    temp = a.copy()
    a[np.where(temp < t1)] = 0
    a[np.where(temp >= t2)] = 30
    a[np.logical_and(temp >= t1, temp < t2)] += 5

#print(arr)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(arr, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result =np.isclose(a, a[:, 0].reshape(-1, 1), atol=0).all()

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
from scipy.stats import rankdata
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
def f(a):
    result = len(a) - rankdata(a).astype(int)

    return result
result = f(a)
with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
import pandas as pd
A, a, b = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
B = np.empty(len(A))
for k in range(0, len(B)):
    if k == 0:
        B[k] = a*A[k]
    else:
        B[k] = a*A[k] + b*B[k-1]

#print(B)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(B, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
temp = (a - a.min()).ravel()
b = np.zeros((a.size, temp.max()+1))
b[np.arange(a.size), temp]=1

#print(b)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(b, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
A, B = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
dims = np.maximum(B.max(0),A.max(0))+1
result = A[~np.in1d(np.ravel_multi_index(A.T,dims),np.ravel_multi_index(B.T,dims))]
output = np.append(result, B[~np.in1d(np.ravel_multi_index(B.T,dims),np.ravel_multi_index(A.T,dims))], axis = 0)

#print(output)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(output, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = (a.mean()-2*a.std(), a.mean()+2*a.std())

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
import scipy.stats
a, b = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
_, p_value = scipy.stats.ttest_ind(a, b,  equal_var = False)

#print(p_value)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(p_value, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.array(a)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = a.shape[1]

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
import pandas as pd
index, columns = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
dtype = [('a','int32'), ('b','float32'), ('c','float32')]
values = np.zeros(2, dtype=dtype)
df = pd.DataFrame(values, index=index)

#print(df)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(df, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
x, y = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.polyfit(x, y, 2)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, accmap = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.bincount(accmap, weights = a)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import tensorflow as tf
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
a_np = a.numpy()

#print(a_np)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(a_np, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.vstack((np.diag(a), np.diag(np.fliplr(a))))

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = a[-1:,...]

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
DataArray, percentile = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
mdata = np.ma.masked_where(DataArray < 0, DataArray)
mdata = np.ma.filled(mdata, np.nan)
prob = np.nanpercentile(mdata, percentile)

#print(prob)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(prob, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import torch
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
a_np = a.numpy()

#print(a_np)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(a_np, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.diag(np.fliplr(a))

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, p = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.percentile(a, p)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, pos, element = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
def f(a, pos=2, element = 66):
    a = np.insert(a, pos, element)

    return a

result = f(a, pos, element)
with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
im = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
mask = im == 0
rows = np.flatnonzero((~mask).sum(axis=1))
cols = np.flatnonzero((~mask).sum(axis=0))
if rows.shape[0] == 0:
    result = np.array([])
else:
    result = im[rows.min():rows.max()+1, cols.min():cols.max()+1]

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
arr, shape = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
def f(arr, shape=(93,13)):
    result = np.pad(arr, ((0, shape[0]-arr.shape[0]), (0, shape[1]-arr.shape[1])), 'constant')

    return result

result = f(arr, shape)
with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = True
for arr in a:
    if any(np.isnan(arr)) == False:
        result = False
        break

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
np.random.seed(0)
r_old = np.random.randint(3, size=(100, 2000)) - 1
np.random.seed(0)
r_new = np.random.randint(3, size=(100, 2000)) - 1
#print(r_old, r_new)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump([r_old, r_new], file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
import pandas as pd
a, df = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
df = pd.DataFrame(df.values - a[:, None], df.index, df.columns)

#print(df)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(df, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
A, nrow = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
B = np.reshape(A, (nrow, -1))

#print(B)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(B, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
pairs, array_of_arrays = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))

import copy
result = copy.deepcopy(array_of_arrays)
#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
result = np.array([])

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
grades, threshold = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
def ecdf_result(x):
    xs = np.sort(x)
    ys = np.arange(1, len(xs)+1)/float(len(xs))
    return xs, ys
resultx, resulty = ecdf_result(grades)
t = (resulty > threshold).argmax()
low = resultx[0]
high = resultx[t]
#print(low, high)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump([low, high], file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
A, B = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
C = A[np.logical_and(A > B[0], A < B[1]) | np.logical_and(A > B[1], A < B[2])]

#print(C)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(C, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
a = np.delete(a, 2, axis = 0)

#print(a)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(a, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
X = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = []
for value in X.flat:
    result.append(value)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
dim, a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.triu(np.linalg.norm(a - a[:, None], axis = -1))

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
x = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
x = x[~np.isnan(x)]

#print(x)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(x, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, patch_size = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
x = a[:a.shape[0] // patch_size * patch_size, :a.shape[1] // patch_size * patch_size]
result = x.reshape(x.shape[0]//patch_size, patch_size, x.shape[1]// patch_size, patch_size).swapaxes(1, 2). reshape(-1, patch_size, patch_size)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, b = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
sort_indices = np.argsort(a, axis=0)[::-1, :, :]
static_indices = np.indices(a.shape)
c = b[sort_indices, static_indices[1], static_indices[2]]

#print(c)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(c, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
n = 20
m = 10
tag = np.random.rand(n, m)
s1, s2 = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = (~np.isclose(s1,s2, equal_nan=True)).sum()

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, b = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.take_along_axis(a, b[..., np.newaxis], axis=-1)[..., 0]

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
x_dists, y_dists = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
dists = np.vstack(([x_dists.T], [y_dists.T])).T

#print(dists)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(dists, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
x = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = x[x >=0]

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
Z = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = Z[..., -1:]

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np

numerator, denominator = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
gcd = np.gcd(numerator, denominator)
result = (numerator//gcd, denominator//gcd)
#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
import pandas as pd
lat, lon, val = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
df = pd.DataFrame({'lat': lat.ravel(), 'lon': lon.ravel(), 'val': val.ravel()})
df['maximum'] = df.max(axis=1)

#print(df)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(df, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
A, NA = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
AVG = np.mean(NA.astype(float), axis = 0)

#print(AVG)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(AVG, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
b = np.zeros((a.size, a.max()+1))
b[np.arange(a.size), a]=1

#print(b)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(b, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, b = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
arr = np.take_along_axis(a, b[..., np.newaxis], axis=-1)[..., 0]
result = np.sum(arr)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, low, high = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = a[low:high, :]

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
data, bin_size = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
new_data = data[:, ::-1]
bin_data_mean = new_data[:,:(data.shape[1] // bin_size) * bin_size].reshape(data.shape[0], -1, bin_size).mean(axis=-1)

#print(bin_data_mean)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(bin_data_mean, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
import pandas as pd
lat, lon, val = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
df = pd.DataFrame({'lat': lat.ravel(), 'lon': lon.ravel(), 'val': val.ravel()})

#print(df)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(df, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.lib.stride_tricks.sliding_window_view(a, window_shape=(2,2)).reshape(-1, 2, 2)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = a.argmin()

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, index = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
add = np.max(index)
mask =index < 0
index[mask] += add+1
uni = np.unique(index)
result = np.zeros(np.amax(index)+1)
for i in uni:
    result[i] = np.min(a[index==i])

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, second, third = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = a[:, np.array(second).reshape(-1,1), third]

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, shift = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
def solution(xs, shift):
    e = np.empty_like(xs)
    for i, n in enumerate(shift):
        if n >= 0:
            e[i,:n] = np.nan
            e[i,n:] = xs[i,:-n]
        else:
            e[i,n:] = np.nan
            e[i,:n] = xs[i,-n:]
    return e
result = solution(a, shift)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
arr = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = arr.copy()
arr[np.where(result < -10)] = 0
arr[np.where(result >= 15)] = 30
arr[np.logical_and(result >= -10, result < 15)] += 5

#print(arr)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(arr, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = a.argmax()

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
temp = np.array([0, 2])
a = np.delete(a, temp, axis = 1)

#print(a)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(a, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
x, x_min, x_max = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
def smoothclamp(x):
    return np.where(x < x_min, x_min, np.where(x > x_max, x_max, 3*x**2 - 2*x**3))

result = smoothclamp(x)
#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
from scipy.stats import rankdata
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = len(a) - rankdata(a).astype(int)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
x, y, degree = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.polyfit(x, y, degree)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
vals, idx = np.unique(a, return_inverse=True)
b = np.zeros((a.size, vals.size))
b[np.arange(a.size), idx] = 1
#print(b)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(b, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
selection = np.ones((len(a), 1), dtype = bool)
selection[1:] = a[1:] != a[:-1]
selection &= a != 0
result = a[selection].reshape(-1, 1)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
from scipy.stats import rankdata
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = len(a) - rankdata(a, method = 'ordinal').astype(int)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.unravel_index(a.argmax(), a.shape)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, number = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
is_contained = number in a

#print(is_contained)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(is_contained, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
arr = np.zeros((20,10,10,2))

#print(arr)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(arr, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
from numpy import linalg as LA
import numpy as np
X = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
l2 = np.sqrt((X*X).sum(axis=-1))
result = X / l2.reshape(-1, 1)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
def f(a):
    result = a.argmax()

    return result

result = f(a)
with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, del_col = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
mask = (del_col <= a.shape[1])
del_col = del_col[mask] - 1
result = np.delete(a, del_col, axis=1)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.einsum('ii->i', a)
save = result.copy()
a[...] = 0
result[...] = save

#print(a)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(a, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
data, bin_size = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
new_data = data[::-1]
bin_data_mean = new_data[:(data.size // bin_size) * bin_size].reshape(-1, bin_size).mean(axis=1)

#print(bin_data_mean)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(bin_data_mean, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
x = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = x[x.imag !=0]

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))

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

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = (a.mean()-3*a.std(), a.mean()+3*a.std())

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, power = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
def f(a, power):
    result = a ** power

    return result

result = f(a, power)
with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, shape, element = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.pad(a, ((0, shape[0]-a.shape[0]), (0, shape[1]-a.shape[1])), 'constant', constant_values=element)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a, b, c = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.max([a, b, c], axis=0)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
A, ncol = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
col = ( A.shape[0] // ncol) * ncol
B = A[:col]
B= np.reshape(B, (-1, ncol))

#print(B)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(B, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
import pandas as pd
names, times, df = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = df.values.reshape(15, 5, 4).transpose(0, 2, 1)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
degree = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.sin(np.deg2rad(degree))

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.linalg.norm(a - a[:, None], axis = -1)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.unravel_index(a.argmax(), a.shape, order = 'F')

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
data, bin_size = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
bin_data_mean = data[:,:(data.shape[1] // bin_size) * bin_size].reshape(data.shape[0], -1, bin_size).mean(axis=-1)

#print(bin_data_mean)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(bin_data_mean, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = a.shape

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
value = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.degrees(np.arcsin(value))

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.diag(np.fliplr(a))

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
A, length = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
if length > A.shape[0]:
    result = np.pad(A, (0, length-A.shape[0]), 'constant')
else:
    result = A.copy()
    result[length:] = 0

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
x = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
x[np.isnan(x)] = np.inf

#print(x)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(x, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np

min, max, n = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
def f(min=1, max=np.e, n=10000):
    import scipy.stats
    result = scipy.stats.loguniform.rvs(a = min, b = max, size = n)

    return result

result = f(min, max, n)
with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
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)
#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = np.argsort(a)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
result = a.reshape(a.shape[0]//2, 2, a.shape[1]//2, 2).swapaxes(1, 2).transpose(1, 0, 2, 3).reshape(-1, 2, 2)

#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
U, i, V = np.linalg.svd(a,full_matrices=True)

i = np.diag(i)

#print(i)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(i, file)


import pickle

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()
import numpy as np
a = pickle.load(open(f"input/input{args.test_case}.pkl", "rb"))
def LI_vecs(M):
    dim = M.shape[0]
    LI=[M[0]]
    for i in range(dim):
        tmp=[]
        for r in LI:
            tmp.append(r)
        tmp.append(M[i])                #set tmp=LI+[M[i]]
        if np.linalg.matrix_rank(tmp)>len(LI):    #test if M[i] is linearly independent from all (row) vectors in LI
            LI.append(M[i])             #note that matrix_rank does not need to take in a square matrix
    return LI                           #return set of linearly independent (row) vectors
result = LI_vecs(a)
#print(result)

with open('result/result_{}.pkl'.format(args.test_case), 'wb') as file:
    pickle.dump(result, file)