MeanNearestNeighbors (MNN) - algorithm for balancing dataset - In progress #1

Image
One of the challenges in classification problems are unbalanced datasets. I was Data Science Intern when the company that I worked for, assigned me such an interesting challenge where the dataset was unbalanced.  However, I realized this type of problem like unbalanced dataset is а common thing in real life. I tried most of the algorithms (undersampling, oversampling) like SMOTE, NearMiss, CondensedNearestNeighbors, RandomUnderSampler, RandomOverSampler,  KMeansSMOTЕ and rest of them. Anyway, they didn't help me in that case, on the contrary, they worsened my model.  I was like: "but, but, you should have been helpful in creating the predictive model" So, I'm trying to create another algorithm based on undersampling concept when it comes to balancing datasets. I called it Mean Nearest Neighbors (MNN). What's the initial idea: It's simple. Actually, the algorithm is just a modification of the other undersampling algorithms. In the data where target labe...

Competitive Programming #28 : [Divisor Product]

Victor is playing with divisors of a number N. He is curious about the product of all these divisors. Given a number N, help him find the product of all the divisors of N (including N).
Since the products can be large, print the answer modulo (10^9 + 7).

Input : 
First line of input contains a single integer T denoting the number of test cases.
The only line of each test case contains an integer N.

Output : 
For each test case, print the required answer in a new line.

Constraints : 
1 <= T <= 200
1 <= N <= 10^9

Example :
Input : 

3
6
9
12
Output : 
36
27
1728

Explanation :
Case 1 : 

Divisors of 6 : 1, 2, 3, 6
Product = 1*2*3*6 = 36

Case 2 : 
Divisors of 9 : 1, 3, 9
Product = 1*3*9 = 27

Case 3 : 
Divisors of 12 : 1, 2, 3, 4, 6, 12
Product = 1*2*3*4*6*12 = 1728


Solution:
------------------------------------ 
 Since N takes large values, brute force won't work.
So let's do math 
Case 1:
Divisors of 6 : 1 ,2, 3, 6
Product = 1*2*3*6 = 36
Now . see carefuly , 1, 2, 3, 6
So we have here 1*6 = 2*3

In 4 divisors have 2 pairs of factors (1*6),(2*3)
And (1*6)*(2*3) = 6^2 = 36


Case 2:
Divisors of 9 : 1 ,3, 9
Product = 1*3*9 = 27
Now . see carefuly , 1, 3, 9
So we have here odd number of divisors

In 3 divisors have 1 pair of factors (1*9),
and one number that when we square him we get the 9 (3^2)
And (1*9)*(3) =  =27


Algorithm:
1.Find number of divisors of N number;
2. Power the number with number of pairs divisors (which product is N)
3. Check if number of divisors is odd , if is odd then product multiply with sqrt(N);