We are given a certain number ```n``` and we do the product partitions of it.
```[59, 3, 2, 2, 2]``` is a product partition of ```1416``` because:
```
59 * 3 * 2 * 2 * 2 = 1416
```
We form a score, ```sc``` for each partition in the following way:
- if ```d1, d2, ...., dk``` are the prime factors of ```n```, and ```f1, f2, ...., fk```, the corresponding frequencies for each factor, we calculate:



Suposse that we have that ```n = 1416``` 
The product partitions of this number with a corresponding special score are as follows:
```
Product Partition           Score(sc)
[59, 3, 2, 2, 2]             350    # equals to: (59^1 + 3^1 + 2^3) * 5
[177, 2, 2, 2]               740    # equals to: (177^1 + 2^3) * 4
[118, 3, 2, 2]               500
[59, 6, 2, 2]                276
[354, 2, 2]                 1074
[59, 4, 3, 2]                272
[236, 3, 2]                  723
[177, 4, 2]                  549
[118, 6, 2]                  378
[59, 12, 2]                  219
[708, 2]                    1420  <---- maximum value
[118, 4, 3]                  375
[59, 8, 3]                   210
[472, 3]                     950
[59, 6, 4]                   207
[354, 4]                     716
[236, 6]                     484
[177, 8]                     370
[118, 12]                    260
[59, 24]                     166  <---- minimum value
```
So we need a function that may give us the product partition with maximum or minimum score.

The function ```find_spec_prod_part()``` will receive two arguments:

- an integer ```n, n > 0```
- a command as a string, one of the following ones: ```'max' or 'min'```

The function should output a list with two elements: the found product partition (as a list sorted in descendin order) with its corresponding score.
```
find_spec_prod_part(n, com) ---> [prod_partition, score]
```
Let'see some cases:
```python
find_spec_prod_part(1416, 'max') == [[708, 2], 1420]

find_spec_prod_part(1416, 'min') == [[59, 24], 166]
```

The function should reject prime numbers:
```python
find_spec_prod_part(10007 , 'max') == "It is a prime number"
```
Enjoy it!

Hint: In this kata, optimization is one of the purposes or tags. The algorithm to produce the product partition is a key factor in terms of speed. Your code will be tested for an ```n``` value up to ```500000```.

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

def _disabled_input(*args, **kwargs):
    raise RuntimeError("input() is disabled in callable mode")
builtins.input = _disabled_input

ns = {"__name__": "__judge__"}  # prevent if __name__ == "__main__" blocks
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = 'import math\nfrom collections import Counter\nfrom itertools import permutations\n\ndef find_spec_prod_part(n, com):\n    # your code here\n    temp_partition = []    \n    factors = primeFactors(n)\n    counter = Counter(factors)\n    max_score = calculateScore(counter)\n    min_score = max_score\n    partition_min = factors\n    partition_max = factors\n    \n    x = len(factors)\n    \n    if len(factors) == 1:\n        return "It is a prime number"\n    \n    perms = list(set(list(permutations(factors))))\n    \n    \n    divs = list(accel_asc(len(factors)))     \n    \n\n    for div in divs:\n        if len(div) == 1 or len(div) == len(factors):\n            continue\n        for perm in perms:\n            temp_partition = []\n            start = 0\n            product = 1\n            seq = []\n\n            for i in div:\n                seq = perm[start:(start+i)]\n                for j in seq:\n                    product *= j\n                temp_partition.append(product)\n                start = start+i\n                product = 1\n\n            counter = Counter(temp_partition)\n            score = calculateScore(counter)\n            \n            if score > max_score:\n                max_score = score\n                partition_max = temp_partition\n                \n            if score < min_score:\n                min_score = score\n                partition_min = temp_partition\n                \n            \n    if com == \'max\':\n        partition_max.sort(reverse = True)\n        return [partition_max, max_score]\n    if com == \'min\':\n        partition_min.sort(reverse = True)\n        return [partition_min, min_score]\n\n\ndef calculateScore(count):\n    score = 0\n    coef = 0\n    for key in count:\n        score += key**count[key]\n        coef += count[key]\n    score = score * coef\n    return score\n\n# A function to print all prime factors of  \n# a given number n \ndef primeFactors(n): \n    prime_factors = []  \n    # Print the number of two\'s that divide n \n    while n % 2 == 0: \n        prime_factors.append(2), \n        n = n / 2\n          \n    # n must be odd at this point \n    # so a skip of 2 ( i = i + 2) can be used \n    for i in range(3, int(math.sqrt(n))+1, 2): \n          \n        # while i divides n, print i ad divide n \n        while n % i == 0: \n            prime_factors.append(i), \n            n = n / i \n    if n != 1:\n        prime_factors.append(int(n))\n\n    return prime_factors\n\ndef accel_asc(n):\n    a = [0 for i in range(n + 1)]\n    k = 1\n    y = n - 1\n    while k != 0:\n        x = a[k - 1] + 1\n        k -= 1\n        while 2 * x <= y:\n            a[k] = x\n            y -= x\n            k += 1\n        l = k + 1\n        while x <= y:\n            a[k] = x\n            a[l] = y\n            yield a[:k + 2]\n            x += 1\n            y -= 1\n        a[k] = x + y\n        y = x + y - 1\n        yield a[:k + 1]'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

_target = None
_fn_name = 'find_spec_prod_part'
if _fn_name:
    if "Solution" in ns:
        try:
            _obj = ns["Solution"]()
            if hasattr(_obj, _fn_name):
                _target = getattr(_obj, _fn_name)
        except Exception:
            _target = None
    if _target is None and _fn_name in ns and callable(ns[_fn_name]):
        _target = ns[_fn_name]
# Fallback: if there's exactly one user-defined function, use it
if _target is None:
    _cands = [v for k, v in ns.items() if callable(v) and getattr(v, "__module__", "") in ("__judge__", "__main__")]
    _user_funcs = [c for c in _cands if getattr(c, "__name__", "").startswith("_") is False]
    if len(_user_funcs) == 1:
        _target = _user_funcs[0]
if _target is None:
    raise RuntimeError(f"Could not resolve callable '{_fn_name}'")

_raw = sys.stdin.read().strip()
if _raw:
    _parsed = json.loads(_raw)
    if isinstance(_parsed, dict):
        _kwargs = _parsed.get("kwargs", {})
        _args = _parsed.get("args", [])
    else:
        _args, _kwargs = _parsed, {}
else:
    _args, _kwargs = [], {}
if not isinstance(_args, (list, tuple)):
    _args = [_args]
_res = _target(*_args, **_kwargs)
try:
    sys.stdout.write(repr(_res) + "\n")
except Exception:
    pass

```

Measured memory_bytes: 23834