<commit_before># -*- coding: utf-8 -*-

def sahovnica(S):
    n = len(S)
    st = (0, 1, 2, 4, 5, 8, 9, 10)
    z = {i: [j for j in st if (i & j) == 0] for i in st}
    c = lambda r, j: sum(r[i] * ((j >> i) & 1) for i in range(4))
    v = {(0, j): c(S[0], j) for j in st}
    for i in range(1, n):
        for j in st:
            v[i, j] = max(v[i-1, k] for k in z[j]) + c(S[i], j)
    return max(v[n-1, j] for j in st)

def magma(M, op, s, a):
    n = len(s)
    v = {(i, i+1, x): None for i, x in enumerate(s)}
    for j in range(2, n+1):
        for i in range(n-j+1):
            for y in M:
                for z in M:
                    x = op(y, z)
                    try:
                        v[i, i+j, x] = next(k for k in range(i+1, i+j)
                                            if (i, k, y) in v
                                            and (k, i+j, z) in v)
                    except StopIteration:
                        pass
    return (0, n, a) in v<commit_msg>Dodano vračanje celotnih rešitev<commit_after># -*- coding: utf-8 -*-

def sahovnica(S):
    """
    Izbira nesosednjih polj šahovnice velikosti n × 4 z največjo vsoto.

    Časovna zahtevnost: O(n)
    """
    n = len(S)
    st = (0, 1, 2, 4, 5, 8, 9, 10)
    z = {i: [j for j in st if (i & j) == 0] for i in st}
    c = lambda r, j: sum(r[i] * ((j >> i) & 1) for i in range(4))
    v = {(0, j): (c(S[0], j), None) for j in st}
    for i in range(1, n):
        for j in st:
            s, p = max((v[i-1, k][0], k) for k in z[j])
            v[i, j] = (s + c(S[i], j), p)
    s, p = max((v[n-1, j][0], j) for j in st)
    res = []
    for i in reversed(range(n)):
        for j in reversed(range(4)):
            if (p & (1 << j)) != 0:
                res.append((i, j))
        p = v[i, p][1]
    return s, list(reversed(res))

def magma(M, op, s, a):
    """
    Za niz s elementov magme M z operacijo op postavi oklepaje tako,
    da je vrednost dobljenega niza enaka a.

    Časovna zahtevnost: O(n^3 |M|^2) + O(n^2 |M|^2) klicev funkcije op
    """
    assert a in M
    n = len(s)
    v = {(i, i+1, x): None for i, x in enumerate(s)}
    for j in range(2, n+1):
        for i in range(n-j+1):
            for y in M:
                for z in M:
                    x = op(y, z)
                    try:
                        v[i, i+j, x] = (next(k for k in range(i+1, i+j)
                                             if (i, k, y) in v
                                             and (k, i+j, z) in v), y, z)
                    except StopIteration:
                        pass
    if (0, n, a) not in v:
        return False
    def split(i, j, x):
        """
        Rekurzivno razdeli podniz s[i:j]
        glede na izračunane pozicije oklepajev.

        Časovna zahtevnost: O(j-i)
        """
        if j - i == 1:
            return s[i]
        h, y, z = v[i, j, x]
        return (split(i, h, y), split(h, j, z))
    return split(0, n, a)
{'fraction_non_alphanumeric': 0.15887533875338752, 'fraction_numerical': 0.020663956639566397, 'mean_word_length': 1.2873741285824942, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '602660', 'n_tokens_mistral': 1217, 'n_tokens_neox': 1170, 'n_words': 414}