WeixiangYan/CodeTransOcean huggingface dataset:
Task: Chernick's Carmichael numbers


C++: #include <gmp.h>
#include <iostream>

using namespace std;

typedef unsigned long long int u64;

bool primality_pretest(u64 k) {     

    if (!(k %  3) || !(k %  5) || !(k %  7) || !(k % 11) ||
        !(k % 13) || !(k % 17) || !(k % 19) || !(k % 23)
    ) {
        return (k <= 23);
    }

    return true;
}

bool probprime(u64 k, mpz_t n) {
    mpz_set_ui(n, k);
    return mpz_probab_prime_p(n, 0);
}

bool is_chernick(int n, u64 m, mpz_t z) {

    if (!primality_pretest(6 * m + 1)) {
        return false;
    }

    if (!primality_pretest(12 * m + 1)) {
        return false;
    }

    u64 t = 9 * m;

    for (int i = 1; i <= n - 2; i++) {
        if (!primality_pretest((t << i) + 1)) {
            return false;
        }
    }

    if (!probprime(6 * m + 1, z)) {
        return false;
    }

    if (!probprime(12 * m + 1, z)) {
        return false;
    }

    for (int i = 1; i <= n - 2; i++) {
        if (!probprime((t << i) + 1, z)) {
            return false;
        }
    }

    return true;
}

int main() {

    mpz_t z;
    mpz_inits(z, NULL);

    for (int n = 3; n <= 10; n++) {

        
        u64 multiplier = (n > 4) ? (1 << (n - 4)) : 1;

        
        if (n > 5) {
            multiplier *= 5;
        }

        for (u64 k = 1; ; k++) {

            u64 m = k * multiplier;

            if (is_chernick(n, m, z)) {
                cout << "a(" << n << ") has m = " << m << endl;
                break;
            }
        }
    }

    return 0;
}
Task: Consecutive primes with ascending or descending differences


C++: #include <cstdint>
#include <iostream>
#include <vector>
#include <primesieve.hpp>

void print_diffs(const std::vector<uint64_t>& vec) {
    for (size_t i = 0, n = vec.size(); i != n; ++i) {
        if (i != 0)
            std::cout << " (" << vec[i] - vec[i - 1] << ") ";
        std::cout << vec[i];
    }
    std::cout << '\n';
}

int main() {
    std::cout.imbue(std::locale(""));
    std::vector<uint64_t> asc, desc;
    std::vector<std::vector<uint64_t>> max_asc, max_desc;
    size_t max_asc_len = 0, max_desc_len = 0;
    uint64_t prime;
    const uint64_t limit = 1000000;
    for (primesieve::iterator pi; (prime = pi.next_prime()) < limit; ) {
        size_t alen = asc.size();
        if (alen > 1 && prime - asc[alen - 1] <= asc[alen - 1] - asc[alen - 2])
            asc.erase(asc.begin(), asc.end() - 1);
        asc.push_back(prime);
        if (asc.size() >= max_asc_len) {
            if (asc.size() > max_asc_len) {
                max_asc_len = asc.size();
                max_asc.clear();
            }
            max_asc.push_back(asc);
        }
        size_t dlen = desc.size();
        if (dlen > 1 && prime - desc[dlen - 1] >= desc[dlen - 1] - desc[dlen - 2])
            desc.erase(desc.begin(), desc.end() - 1);
        desc.push_back(prime);
        if (desc.size() >= max_desc_len) {
            if (desc.size() > max_desc_len) {
                max_desc_len = desc.size();
                max_desc.clear();
            }
            max_desc.push_back(desc);
        }
    }
    std::cout << "Longest run(s) of ascending prime gaps up to " << limit << ":\n";
    for (const auto& v : max_asc)
        print_diffs(v);
    std::cout << "\nLongest run(s) of descending prime gaps up to " << limit << ":\n";
    for (const auto& v : max_desc)
        print_diffs(v);
    return 0;
}
Task: Honaker primes


C++: #include <iomanip>
#include <iostream>
#include <sstream>
#include <utility>

#include <primesieve.hpp>

uint64_t digit_sum(uint64_t n) {
    uint64_t sum = 0;
    for (; n > 0; n /= 10)
        sum += n % 10;
    return sum;
}

class honaker_prime_generator {
public:
    std::pair<uint64_t, uint64_t> next();

private:
    primesieve::iterator pi_;
    uint64_t index_ = 0;
};

std::pair<uint64_t, uint64_t> honaker_prime_generator::next() {
    for (;;) {
        uint64_t prime = pi_.next_prime();
        ++index_;
        if (digit_sum(index_) == digit_sum(prime))
            return std::make_pair(index_, prime);
    }
}

std::ostream& operator<<(std::ostream& os,
                         const std::pair<uint64_t, uint64_t>& p) {
    std::ostringstream str;
    str << '(' << p.first << ", " << p.second << ')';
    return os << str.str();
}

int main() {
    honaker_prime_generator hpg;
    std::cout << "First 50 Honaker primes (index, prime):\n";
    int i = 1;
    for (; i <= 50; ++i)
        std::cout << std::setw(11) << hpg.next() << (i % 5 == 0 ? '\n' : ' ');
    for (; i < 10000; ++i)
        hpg.next();
    std::cout << "\nTen thousandth: " << hpg.next() << '\n';
}
Task: Ormiston triples


C++: #include <array>
#include <iostream>

#include <primesieve.hpp>

class ormiston_triple_generator {
public:
    ormiston_triple_generator() {
        for (int i = 0; i < 2; ++i) {
            primes_[i] = pi_.next_prime();
            digits_[i] = get_digits(primes_[i]);
        }
    }
    std::array<uint64_t, 3> next_triple() {
        for (;;) {
            uint64_t prime = pi_.next_prime();
            auto digits = get_digits(prime);
            bool is_triple = digits == digits_[0] && digits == digits_[1];
            uint64_t prime0 = primes_[0];
            primes_[0] = primes_[1];
            primes_[1] = prime;
            digits_[0] = digits_[1];
            digits_[1] = digits;
            if (is_triple)
                return {prime0, primes_[0], primes_[1]};
        }
    }

private:
    static std::array<int, 10> get_digits(uint64_t n) {
        std::array<int, 10> result = {};
        for (; n > 0; n /= 10)
            ++result[n % 10];
        return result;
    }
    primesieve::iterator pi_;
    std::array<uint64_t, 2> primes_;
    std::array<std::array<int, 10>, 2> digits_;
};

int main() {
    ormiston_triple_generator generator;
    int count = 0;
    std::cout << "Smallest members of first 25 Ormiston triples:\n";
    for (; count < 25; ++count) {
        auto primes = generator.next_triple();
        std::cout << primes[0] << ((count + 1) % 5 == 0 ? '\n' : ' ');
    }
    std::cout << '\n';
    for (uint64_t limit = 1000000000; limit <= 10000000000; ++count) {
        auto primes = generator.next_triple();
        if (primes[2] > limit) {
            std::cout << "Number of Ormiston triples < " << limit << ": "
                      << count << '\n';
            limit *= 10;
        }
    }
}
Task: Metallic ratios


C++: #include <boost/multiprecision/cpp_dec_float.hpp>
#include <iostream>

const char* names[] = { "Platinum", "Golden", "Silver", "Bronze", "Copper", "Nickel", "Aluminium", "Iron", "Tin", "Lead" };

template<const uint N>
void lucas(ulong b) {
    std::cout << "Lucas sequence for " << names[b] << " ratio, where b = " << b << ":\nFirst " << N << " elements: ";
    auto x0 = 1L, x1 = 1L;
    std::cout << x0 << ", " << x1;
    for (auto i = 1u; i <= N - 1 - 1; i++) {
        auto x2 = b * x1 + x0;
        std::cout << ", " << x2;
        x0 = x1;
        x1 = x2;
    }
    std::cout << std::endl;
}

template<const ushort P>
void metallic(ulong b) {
    using namespace boost::multiprecision;
    using bfloat = number<cpp_dec_float<P+1>>;
    bfloat x0(1), x1(1);
    auto prev = bfloat(1).str(P+1);
    for (auto i = 0u;;) {
        i++;
        bfloat x2(b * x1 + x0);
        auto thiz = bfloat(x2 / x1).str(P+1);
        if (prev == thiz) {
            std::cout << "Value after " << i << " iteration" << (i == 1 ? ": " : "s: ") << thiz << std::endl << std::endl;
            break;
        }
        prev = thiz;
        x0 = x1;
        x1 = x2;
    }
}

int main() {
    for (auto b = 0L; b < 10L; b++) {
        lucas<15>(b);
        metallic<32>(b);
    }
    std::cout << "Golden ratio, where b = 1:" << std::endl;
    metallic<256>(1);

    return 0;
}
Task: Riordan numbers


C++: #include <iomanip>
#include <iostream>

#include <gmpxx.h>

using big_int = mpz_class;

class riordan_number_generator {
public:
    big_int next();

private:
    big_int a0_ = 1;
    big_int a1_ = 0;
    int n_ = 0;
};

big_int riordan_number_generator::next() {
    int n = n_++;
    if (n == 0)
        return a0_;
    if (n == 1)
        return a1_;
    big_int a = (n - 1) * (2 * a1_ + 3 * a0_) / (n + 1);
    a0_ = a1_;
    a1_ = a;
    return a;
}

std::string to_string(const big_int& num, size_t n) {
    std::string str = num.get_str();
    size_t len = str.size();
    if (len > n)
        str = str.substr(0, n / 2) + "..." + str.substr(len - n / 2);
    return str;
}

int main() {
    riordan_number_generator rng;
    std::cout << "First 32 Riordan numbers:\n";
    int i = 1;
    for (; i <= 32; ++i) {
        std::cout << std::setw(14) << rng.next()
                  << (i % 4 == 0 ? '\n' : ' ');
    }
    for (; i < 1000; ++i)
        rng.next();
    auto num = rng.next();
    ++i;
    std::cout << "\nThe 1000th is " << to_string(num, 40) << " ("
              << num.get_str().size() << " digits).\n";
    for (; i < 10000; ++i)
        rng.next();
    num = rng.next();
    std::cout << "The 10000th is " << to_string(num, 40) << " ("
              << num.get_str().size() << " digits).\n";
}
Task: Iterators


C++: #include <iostream>
#include <list>
#include <string>
#include <vector>

using namespace std;




void PrintContainer(forward_iterator auto start, forward_iterator auto sentinel)
{
  for(auto it = start; it != sentinel; ++it)
  {
    cout << *it << " "; 
  }
  cout << "\n";
}


void FirstFourthFifth(input_iterator auto it)
{
  cout << *it;
  advance(it, 3);
  cout << ", " << *it;
  advance(it, 1);
  cout << ", " << *it;
  cout << "\n";
}

int main()
{
  
  vector<string> days{"Sunday", "Monday", "Tuesday", "Wednesday",
   "Thursday", "Friday", "Saturday"};
  list<string> colors{"Red", "Orange", "Yellow", "Green", "Blue", "Purple"};

  cout << "All elements:\n";
  PrintContainer(days.begin(), days.end());
  PrintContainer(colors.begin(), colors.end());
  
  cout << "\nFirst, fourth, and fifth elements:\n";
  FirstFourthFifth(days.begin());
  FirstFourthFifth(colors.begin());

  cout << "\nReverse first, fourth, and fifth elements:\n";
  FirstFourthFifth(days.rbegin());
  FirstFourthFifth(colors.rbegin());
}
Task: Erdös-Selfridge categorization of primes


C++: #include <algorithm>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <map>
#include <vector>

#include <primesieve.hpp>

class erdos_selfridge {
public:
    explicit erdos_selfridge(int limit);
    uint64_t get_prime(int index) const { return primes_[index].first; }
    int get_category(int index);

private:
    std::vector<std::pair<uint64_t, int>> primes_;
    size_t get_index(uint64_t prime) const;
};

erdos_selfridge::erdos_selfridge(int limit) {
    primesieve::iterator iter;
    for (int i = 0; i < limit; ++i)
        primes_.emplace_back(iter.next_prime(), 0);
}

int erdos_selfridge::get_category(int index) {
    auto& pair = primes_[index];
    if (pair.second != 0)
        return pair.second;
    int max_category = 0;
    uint64_t n = pair.first + 1;
    for (int i = 0; n > 1; ++i) {
        uint64_t p = primes_[i].first;
        if (p * p > n)
            break;
        int count = 0;
        for (; n % p == 0; ++count)
            n /= p;
        if (count != 0) {
            int category = (p <= 3) ? 1 : 1 + get_category(i);
            max_category = std::max(max_category, category);
        }
    }
    if (n > 1) {
        int category = (n <= 3) ? 1 : 1 + get_category(get_index(n));
        max_category = std::max(max_category, category);
    }
    pair.second = max_category;
    return max_category;
}

size_t erdos_selfridge::get_index(uint64_t prime) const {
    auto it = std::lower_bound(primes_.begin(), primes_.end(), prime,
                               [](const std::pair<uint64_t, int>& p,
                                  uint64_t n) { return p.first < n; });
    assert(it != primes_.end());
    assert(it->first == prime);
    return std::distance(primes_.begin(), it);
}

auto get_primes_by_category(erdos_selfridge& es, int limit) {
    std::map<int, std::vector<uint64_t>> primes_by_category;
    for (int i = 0; i < limit; ++i) {
        uint64_t prime = es.get_prime(i);
        int category = es.get_category(i);
        primes_by_category[category].push_back(prime);
    }
    return primes_by_category;
}

int main() {
    const int limit1 = 200, limit2 = 1000000;

    erdos_selfridge es(limit2);

    std::cout << "First 200 primes:\n";
    for (const auto& p : get_primes_by_category(es, limit1)) {
        std::cout << "Category " << p.first << ":\n";
        for (size_t i = 0, n = p.second.size(); i != n; ++i) {
            std::cout << std::setw(4) << p.second[i]
                      << ((i + 1) % 15 == 0 ? '\n' : ' ');
        }
        std::cout << "\n\n";
    }

    std::cout << "First 1,000,000 primes:\n";
    for (const auto& p : get_primes_by_category(es, limit2)) {
        const auto& v = p.second;
        std::cout << "Category " << std::setw(2) << p.first << ": "
                  << "first = " << std::setw(7) << v.front()
                  << "  last = " << std::setw(8) << v.back()
                  << "  count = " << v.size() << '\n';
    }
}
Task: Equal prime and composite sums


C++: #include <primesieve.hpp>

#include <chrono>
#include <iomanip>
#include <iostream>
#include <locale>

class composite_iterator {
public:
    composite_iterator();
    uint64_t next_composite();

private:
    uint64_t composite;
    uint64_t prime;
    primesieve::iterator pi;
};

composite_iterator::composite_iterator() {
    composite = prime = pi.next_prime();
    for (; composite == prime; ++composite)
        prime = pi.next_prime();
}

uint64_t composite_iterator::next_composite() {
    uint64_t result = composite;
    while (++composite == prime)
        prime = pi.next_prime();
    return result;
}

int main() {
    std::cout.imbue(std::locale(""));
    auto start = std::chrono::high_resolution_clock::now();
    composite_iterator ci;
    primesieve::iterator pi;
    uint64_t prime_sum = pi.next_prime();
    uint64_t composite_sum = ci.next_composite();
    uint64_t prime_index = 1, composite_index = 1;
    std::cout << "Sum                   | Prime Index  | Composite Index\n";
    std::cout << "------------------------------------------------------\n";
    for (int count = 0; count < 11;) {
        if (prime_sum == composite_sum) {
            std::cout << std::right << std::setw(21) << prime_sum << " | "
                      << std::setw(12) << prime_index << " | " << std::setw(15)
                      << composite_index << '\n';
            composite_sum += ci.next_composite();
            prime_sum += pi.next_prime();
            ++prime_index;
            ++composite_index;
            ++count;
        } else if (prime_sum < composite_sum) {
            prime_sum += pi.next_prime();
            ++prime_index;
        } else {
            composite_sum += ci.next_composite();
            ++composite_index;
        }
    }
    auto end = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> duration(end - start);
    std::cout << "\nElapsed time: " << duration.count() << " seconds\n";
}
Task: Monads_Writer monad


C++: #include <cmath>
#include <iostream>
#include <string>

using namespace std;


struct LoggingMonad
{
    double Value;
    string Log;
};


auto operator>>(const LoggingMonad& monad, auto f)
{
    auto result = f(monad.Value);
    return LoggingMonad{result.Value, monad.Log + "\n" + result.Log};
}


auto Root = [](double x){ return sqrt(x); };
auto AddOne = [](double x){ return x + 1; };
auto Half = [](double x){ return x / 2.0; };


auto MakeWriter = [](auto f, string message)
{
    return [=](double x){return LoggingMonad(f(x), message);};
};


auto writerRoot = MakeWriter(Root, "Taking square root");
auto writerAddOne = MakeWriter(AddOne, "Adding 1");
auto writerHalf = MakeWriter(Half, "Dividing by 2");


int main()
{
    
    auto result = LoggingMonad{5, "Starting with 5"} >> writerRoot >> writerAddOne >> writerHalf;
    cout << result.Log << "\nResult: " << result.Value;
}
Task: Word ladder


C++: #include <algorithm>
#include <fstream>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using word_map = std::map<size_t, std::vector<std::string>>;


bool one_away(const std::string& s1, const std::string& s2) {
    if (s1.size() != s2.size())
        return false;
    bool result = false;
    for (size_t i = 0, n = s1.size(); i != n; ++i) {
        if (s1[i] != s2[i]) {
            if (result)
                return false;
            result = true;
        }
    }
    return result;
}


template <typename iterator_type, typename separator_type>
std::string join(iterator_type begin, iterator_type end,
                 separator_type separator) {
    std::string result;
    if (begin != end) {
        result += *begin++;
        for (; begin != end; ++begin) {
            result += separator;
            result += *begin;
        }
    }
    return result;
}




bool word_ladder(const word_map& words, const std::string& from,
                 const std::string& to) {
    auto w = words.find(from.size());
    if (w != words.end()) {
        auto poss = w->second;
        std::vector<std::vector<std::string>> queue{{from}};
        while (!queue.empty()) {
            auto curr = queue.front();
            queue.erase(queue.begin());
            for (auto i = poss.begin(); i != poss.end();) {
                if (!one_away(*i, curr.back())) {
                    ++i;
                    continue;
                }
                if (to == *i) {
                    curr.push_back(to);
                    std::cout << join(curr.begin(), curr.end(), " -> ") << '\n';
                    return true;
                }
                std::vector<std::string> temp(curr);
                temp.push_back(*i);
                queue.push_back(std::move(temp));
                i = poss.erase(i);
            }
        }
    }
    std::cout << from << " into " << to << " cannot be done.\n";
    return false;
}

int main() {
    word_map words;
    std::ifstream in("unixdict.txt");
    if (!in) {
        std::cerr << "Cannot open file unixdict.txt.\n";
        return EXIT_FAILURE;
    }
    std::string word;
    while (getline(in, word))
        words[word.size()].push_back(word);
    word_ladder(words, "boy", "man");
    word_ladder(words, "girl", "lady");
    word_ladder(words, "john", "jane");
    word_ladder(words, "child", "adult");
    word_ladder(words, "cat", "dog");
    word_ladder(words, "lead", "gold");
    word_ladder(words, "white", "black");
    word_ladder(words, "bubble", "tickle");
    return EXIT_SUCCESS;
}
Task: Doomsday rule


C++: #include <iostream>
#include <cstdint>

struct Date {
    std::uint16_t year;
    std::uint8_t month;
    std::uint8_t day;
};

constexpr bool leap(int year)  {
    return year%4==0 && (year%100!=0 || year%400==0);
}

const std::string& weekday(const Date& date) {
    static const std::uint8_t leapdoom[] = {4,1,7,2,4,6,4,1,5,3,7,5};
    static const std::uint8_t normdoom[] = {3,7,7,4,2,6,4,1,5,3,7,5};
    
    static const std::string days[] = {
        "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
        "Friday", "Saturday"
    };
    
    unsigned const c = date.year/100, r = date.year%100;
    unsigned const s = r/12, t = r%12;
    
    unsigned const c_anchor = (5 * (c%4) + 2) % 7;
    unsigned const doom = (s + t + t/4 + c_anchor) % 7;
    unsigned const anchor = (leap(date.year) ? leapdoom : normdoom)[date.month-1];
    return days[(doom+date.day-anchor+7)%7];
}

int main(void) {
    const std::string months[] = {"",
        "January", "February", "March", "April", "May", "June",
        "July", "August", "September", "October", "November", "December"
    };
    
    const Date dates[] = {
        {1800,1,6}, {1875,3,29}, {1915,12,7}, {1970,12,23}, {2043,5,14},
        {2077,2,12}, {2101,4,2}
    };
    
    for (const Date& d : dates) {
        std::cout << months[d.month] << " " << (int)d.day << ", " << d.year;
        std::cout << (d.year > 2021 ? " will be " : " was ");
        std::cout << "on a " << weekday(d) << std::endl;
    }
    
    return 0;
}
Task: Generate random chess position


C++: #include <ctime>
#include <iostream>
#include <string>
#include <algorithm>

class chessBoard {
public:
    void generateRNDBoard( int brds ) {
        int a, b, i; char c;
        for( int cc = 0; cc < brds; cc++ ) {
            memset( brd, 0, 64 );
            std::string pieces = "PPPPPPPPNNBBRRQKppppppppnnbbrrqk";
            random_shuffle( pieces.begin(), pieces.end() );

            while( pieces.length() ) {
                i = rand() % pieces.length(); c = pieces.at( i );
                while( true ) {
                    a = rand() % 8; b = rand() % 8;
                    if( brd[a][b] == 0 ) {
                        if( c == 'P' && !b || c == 'p' && b == 7 || 
                          ( ( c == 'K' || c == 'k' ) && search( c == 'k' ? 'K' : 'k', a, b ) ) ) continue;
                        break;
                    }
                }
                brd[a][b] = c;
                pieces = pieces.substr( 0, i ) + pieces.substr( i + 1 );
            }
            print();
        }
    }
private:
    bool search( char c, int a, int b ) {
        for( int y = -1; y < 2; y++ ) {
            for( int x = -1; x < 2; x++ ) {
                if( !x && !y ) continue;
                if( a + x > -1 && a + x < 8 && b + y >-1 && b + y < 8 ) {
                    if( brd[a + x][b + y] == c ) return true;
                }
            }
        }
        return false;
    }
    void print() {
        int e = 0;
        for( int y = 0; y < 8; y++ ) {
            for( int x = 0; x < 8; x++ ) {
                if( brd[x][y] == 0 ) e++;
                else {
                    if( e > 0 ) { std::cout << e; e = 0; }
                    std::cout << brd[x][y];
                }
            }
            if( e > 0 ) { std::cout << e; e = 0; } 
            if( y < 7 ) std::cout << "/";
        }
        std::cout << " w - - 0 1\n\n";

        for( int y = 0; y < 8; y++ ) {
            for( int x = 0; x < 8; x++ ) {
                if( brd[x][y] == 0 ) std::cout << ".";
                else std::cout << brd[x][y];
            }
            std::cout << "\n";
        }

        std::cout << "\n\n";
    }
    char brd[8][8];
};
int main( int argc, char* argv[] ) {
    srand( ( unsigned )time( 0 ) );
    chessBoard c;
    c.generateRNDBoard( 2 );
    return 0;
}
Task: Arithmetic derivative


C++: #include <iomanip>
#include <iostream>

#include <boost/multiprecision/cpp_int.hpp>

template <typename IntegerType>
IntegerType arithmetic_derivative(IntegerType n) {
    bool negative = n < 0;
    if (negative)
        n = -n;
    if (n < 2)
        return 0;
    IntegerType sum = 0, count = 0, m = n;
    while ((m & 1) == 0) {
        m >>= 1;
        count += n;
    }
    if (count > 0)
        sum += count / 2;
    for (IntegerType p = 3, sq = 9; sq <= m; p += 2) {
        count = 0;
        while (m % p == 0) {
            m /= p;
            count += n;
        }
        if (count > 0)
            sum += count / p;
        sq += (p + 1) << 2;
    }
    if (m > 1)
        sum += n / m;
    if (negative)
        sum = -sum;
    return sum;
}

int main() {
    using boost::multiprecision::int128_t;

    for (int n = -99, i = 0; n <= 100; ++n, ++i) {
        std::cout << std::setw(4) << arithmetic_derivative(n)
                  << ((i + 1) % 10 == 0 ? '\n' : ' ');
    }

    int128_t p = 10;
    std::cout << '\n';
    for (int i = 0; i < 20; ++i, p *= 10) {
        std::cout << "D(10^" << std::setw(2) << i + 1
                  << ") / 7 = " << arithmetic_derivative(p) / 7 << '\n';
    }
}