Problem:
Problem B:
Monday-Saturday Prime Factors
Chief Judge's log, stardate 48642.5.
We have decided to make a problem from elementary number theory.
The problem looks like finding all prime factors of a positive integer,
but it is not.
A positive integer whose remainder divided by 7 is either 1 or 6 is called
a 7
N
+{1,6} number.
But as it is hard to pronounce,
we shall call it a
Monday-Saturday number
.
For Monday-Saturday numbers
a
and
b
,
we say
a
is a Monday-Saturday divisor of
b
if there exists a Monday-Saturday number
x
such that
a
x
=
b
.
It is easy to show that
for any Monday-Saturday numbers
a
and
b
,
it holds that
a
is
a Monday-Saturday divisor of
b
if and only if
a
is a divisor of
b
in the usual sense.
We call a Monday-Saturday number a
Monday-Saturday prime
if it is greater than 1 and has no Monday-Saturday divisors
other than itself and 1.
A Monday-Saturday number which is a prime in the usual sense
is a Monday-Saturday prime
but the converse does not always hold.
For example, 27 is a Monday-Saturday prime
although it is not a prime in the usual sense.
We call a Monday-Saturday prime
which is a Monday-Saturday divisor of a Monday-Saturday number
a
a
Monday-Saturday prime factor
of
a
.
For example, 27 is one of the Monday-Saturday prime factors of 216,
since 27 is a Monday-Saturday prime
and 216 = 27 × 8 holds.
Any Monday-Saturday number greater than 1
can be expressed as a product of one or more Monday-Saturday primes.
The expression is not always unique
even if differences in order are ignored.
For example,
216 = 6 × 6 × 6 = 8 × 27
holds.
Our contestants should write a program that outputs
all Monday-Saturday prime factors
of each input Monday-Saturday number.
Input
The input is a sequence of lines each of which contains a single
Monday-Saturday number.
Each Monday-Saturday number is greater than 1
and less than 300000 (three hundred thousand).
The end of the input is indicated by a line
containing a single digit 1.
Output
For each input Monday-Saturday number,
it should be printed, followed by a colon `:'
and the list of its Monday-Saturday prime factors on a single line.
Monday-Saturday prime factors should be listed in ascending order
and each should be preceded by a space.
All the Monday-Saturday prime factors should be printed only once
even if they divide the input Monday-Saturday number more than once.
Sample Input
205920
262144
262200
279936
299998
1
Output for the Sample Input
205920: 6 8 13 15 20 22 55 99
262144: 8
262200: 6 8 15 20 50 57 69 76 92 190 230 475 575 874 2185
279936: 6 8 27
299998: 299998

Submitted solutions:

code_snippet: #include <bits/stdc++.h>

using namespace std;

int next(int i) {
  return i%7 == 1 ? i+5 : i+2;
}

bool isprime(int x) {
  for(int i=6; i<x; i=next(i)) {
    if(x%i == 0) return false;
  }
  return true;
}

int main() {
  int n;
  while(scanf("%d",&n), n!=1){
    printf("%d:", n);
    for(int i=6; i<=n; i=next(i)){
      if(n%i == 0 && isprime(i)) {
        printf(" %d", i);
      }
    }
    printf("\n");
  }
  return 0;
}
accuracy: 1
time_ms: 200
memory_kb: 3476
final_rank: 8

code_snippet: #ifndef ONLINE_JUDGE
#define _GLIBCXX_DEBUG
#endif

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
//https://boostjp.github.io/tips/multiprec-int.html

#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define YN {cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}// if(a==b)YN;
#define NO2 cout<<-1<<endl

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i=int(n)-1; i>=0; --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

int main() {
    int MX = 300010;
    vector<bool> p(MX, true);
    vector<int> primes;
    for (int i=1; i<MX; i++) {
        
        //(6,13,20, ...)
        int tmp = 7*i-1;
        if (tmp >= MX) break;
        if (p[tmp]) {
            primes.emplace_back(tmp);
            for (int k=2; k*tmp<MX; k++) {
                p[k*tmp] = false;
            }
        }

        //(8,15,22, ...)
        tmp = 7*i+1;
        if (tmp >= MX) break;
        if (p[tmp]) {
            primes.emplace_back(tmp);
            for (int k=2; k*tmp<MX; k++) {
                p[k*tmp] = false;
            }
        }
    }

    while(true) {
        int N;
        cin >> N;
        if (N == 1) return 0;
        cout << N << ':';

        bool flag = false;
        for (int pr:primes) {
            if (N%pr == 0) {
                flag = true;
                cout << ' ' << pr;
            }
        }
        cout << endl;
    }
}
accuracy: 1
time_ms: 490
memory_kb: 3712
final_rank: 16

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using a2 = array<ll, 2>;
using a3 = array<ll, 3>;

template <typename A> void chmin(A &l, const A &r) {
    if(r < l)
        l = r;
}
template <typename A> void chmax(A &l, const A &r) {
    if(l < r)
        l = r;
}

ll mod = 998244353;

vector<ll> prime;
void init() {
    for(int i = 7; i < 400000; i+=7) {
        ll a;
        bool ok;

        a = i - 1;
        ok = true;
        for(auto &x : prime) {
            if(x*x>a)
            break;
            if(a % x == 0) {
                ok = false;
                break;
            }
        }
        if(ok) {
            prime.push_back(a);
        }

        a = i + 1;
        ok = true;
        for(auto &x : prime) {
            if(x*x>a)
            break;
            if(a % x == 0) {
                ok = false;
                break;
            }
        }
        if(ok) {
            prime.push_back(a);
        }
    }
}

ll n;
void input() { cin >> n; }
void solve() {
    cout << n << ":";
    for(auto &x : prime) {
        if(n % x == 0)
            cout << ' ' << x;
    }
    cout << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    init();
    while(1) {
        input();
        if(n == 1)
            break;
        solve();
    }

    return 0;
}
accuracy: 1
time_ms: 350
memory_kb: 3608
final_rank: 13

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;

void solve(int n) {
    vector<bool> is_prime(n + 1, true);
    is_prime[0] = false;
    is_prime[1] = false;
    for (int i = 2; i <= n; i++) {
        if (i % 7 == 1 || i % 7 == 6) {
            for (int j = 2 * i; j <= n; j += i) {
                is_prime[j] = false;
            }
        } else {
            is_prime[i] = false;
        }
    }

    vector<int> vec;
    for (int i = 0; i <= n; i++) {
        if (is_prime[i]) {
            vec.push_back(i);
        }
    }

    vector<int> ans;
    int N = n;
    for (auto x : vec) {
        if (N % x == 0) {
            ans.push_back(x);
        }
    }

    cout << n << ":";
    for (int an : ans) {
        cout << " " << an;
    }
    cout << endl;
}

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 1) {
            break;
        }

        solve(n);
    }
}
accuracy: 1
time_ms: 1000
memory_kb: 3864
final_rank: 17

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;

void solve(int n) {
    vector<bool> is_prime(n + 1, true);
    is_prime[0] = false;
    is_prime[1] = false;
    for (int i = 2; i <= n; i++) {
        if (i % 7 == 1 || i % 7 == 6) {
            for (int j = 2 * i; j <= n; j += i) {
                is_prime[j] = false;
            }
        } else {
            is_prime[i] = false;
        }
    }

    vector<int> vec;
    for (int i = 0; i < n + 1; i++) {
        if (is_prime[i]) {
            vec.push_back(i);
        }
    }
    ranges::sort(vec);

    vector<int> ans;
    int N = n;
    for (auto x : vec) {
        if (x == 1) {
            continue;
        }
        if (N % x == 0) {
            ans.push_back(x);
        }
    }

    cout << n << ":";
    for (int i = 0; i < ans.size(); i++) {
        cout << " " << ans[i];
    }
    cout << endl;
}

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 1) {
            break;
        }

        solve(n);
    }
}
accuracy: 1
time_ms: 1120
memory_kb: 3860
final_rank: 18

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
using PP = pair<int, P>;
using PLL = pair<ll, ll>;
using PPLL = pair<ll, PLL>;
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define rrep(i, n) for(ll i = n - 1; i >= 0; --i)
#define loop(i, a, b) for(ll i = a; i <= b; ++i)
#define all(v) v.begin(), v.end()
#define nC2(n) n * (n - 1) / 2
constexpr ll INF = 9009009009009009009LL;
constexpr int INF32 = 2002002002;
constexpr ll MOD = 998244353;
constexpr ll MOD107 = 1000000007;

// Linear Algebra ////////////////////////////////////////////////
const double Rad2Deg = 180.0 / M_PI;
const double Deg2Rad = M_PI / 180.0;
//////////////////////////////////////////////////////////////////

int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};

template <class T>
inline bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template <typename Container,
          typename = std::enable_if_t<
              !std::is_same_v<Container, std::string> &&
              std::is_convertible_v<decltype(std::declval<Container>().begin()),
                                    typename Container::iterator>>>
ostream &operator<<(ostream &os, const Container &container) {
    auto it = container.begin();
    auto end = container.end();

    if (it != end) {
        os << *it;
        ++it;
    }
	for (; it != end; ++it) {
		os << " " << *it;
	}
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    for (size_t i = 0; i < v.size(); ++i) {
        os << v[i];
        if (i != v.size() - 1) os << " ";
    }
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, const vector<vector<T>>& vv) {
	for (size_t i = 0; i < vv.size(); ++i) {
		os << vv[i];
		if (i != vv.size() - 1) os << "\n";
    }
    return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
	assert(v.size() > 0);
	for (size_t i = 0; i < v.size(); ++i) is >> v[i];
	return is;
}
template <typename T>
istream& operator>>(istream& is, vector<vector<T>>& vv) {
	assert(vv.size() > 0);
	for (size_t i = 0; i < vv.size(); ++i) is >> vv[i];
	return is;
}

struct phash {
	template<class T1, class T2>
    inline size_t operator()(const pair<T1, T2> & p) const {
        auto h1 = hash<T1>()(p.first);
        auto h2 = hash<T2>()(p.second);

		size_t seed = h1 + h2; 
		h1 = ((h1 >> 16) ^ h1) * 0x45d9f3b;
        h1 = ((h1 >> 16) ^ h1) * 0x45d9f3b;
        h1 = (h1 >> 16) ^ h1;
        seed ^= h1 + 0x9e3779b9 + (seed << 6) + (seed >> 2);
		h2 = ((h2 >> 16) ^ h2) * 0x45d9f3b;
        h2 = ((h2 >> 16) ^ h2) * 0x45d9f3b;
        h2 = (h2 >> 16) ^ h2;
        seed ^= h2 + 0x9e3779b9 + (seed << 6) + (seed >> 2);
        return seed;
    }
};



/**
 * @brief エラトステネスの篩 O(N log log N)
 * @param n 素数を求める範囲
 * @return vector<bool> xが素数かどうか
 */
vector<bool> sieve(const ll n) {
	vector<bool> is_prime(n + 1, true);
	is_prime[0] = is_prime[1] = false;
	for (ll i = 2; i * i <= n; ++i) {
		if (!is_prime[i]) continue;
		for (ll j = i * i; j <= n; j += i) is_prime[j] = false;
	}
	return is_prime;
}

/**
 * @brief エラトステネスの篩 O(N log log N)
 * @param n 素数を求める範囲
 * @return vector<ll> 素数のリスト
 */
vector<ll> primes(const ll n) {
	vector<bool> is_prime(n + 1, true);
	vector<ll> res;
	is_prime[0] = is_prime[1] = false;
	for (ll i = 2; i <= n; ++i) {
		if (!is_prime[i]) continue;
		if (i % 7 != 1 && i % 7 != 6) continue;
		res.push_back(i);
		for (ll j = i * i; j <= n; j += i) is_prime[j] = false;
	}
	return res;
}

/**
 * @brief 素因数分解 O(√N)
 * @param n 素因数分解する数
 * @return vector<pair<ll, ll>> 素因数とその指数のリスト
 */
vector<pair<ll, ll>> prime_factorization(ll n) {
	vector<pair<ll, ll>> res;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i != 0) continue;
		if (i % 7 != 1 && i % 7 != 6) continue;
		ll ex = 0;
		while (n % i == 0) {
			++ex;
			n /= i;
		}
		res.push_back({i, ex});
	}
	if (n != 1) res.push_back({n, 1});
	return res;
}

vll prime;
int solve() {
	ll n; cin >> n;
	if (n == 1) return 1;

	vll res;
	rep(i, prime.size()) {
		if (n % prime[i] == 0) res.push_back(prime[i]);
	}

	cout << n << ":";
	for (auto v : res) {
		cout << " " << v;
	}
	cout << "\n";

	return 0;
}

int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	prime = primes(3 * 1e5);
	while (!solve()) { }

	return 0;
}
accuracy: 1
time_ms: 90
memory_kb: 3968
final_rank: 7

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) sort(ALL(v)), (v).erase(unique(ALL(v)), (v).end())
#define SZ(v) (int)v.size()
#define MIN(v) *min_element(ALL(v))
#define MAX(v) *max_element(ALL(v))
#define LB(v, x) int(lower_bound(ALL(v), (x)) - (v).begin())
#define UB(v, x) int(upper_bound(ALL(v), (x)) - (v).begin())

using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long;
using i128 = __int128_t;
using u128 = __uint128_t;
const int inf = 0x3fffffff;
const ll INF = 0x1fffffffffffffff;

template <typename T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T, typename U> T ceil(T x, U y) {
    assert(y != 0);
    if (y < 0)
        x = -x, y = -y;
    return (x > 0 ? (x + y - 1) / y : x / y);
}
template <typename T, typename U> T floor(T x, U y) {
    assert(y != 0);
    if (y < 0)
        x = -x, y = -y;
    return (x > 0 ? x / y : (x - y + 1) / y);
}
template <typename T> int popcnt(T x) {
    return __builtin_popcountll(x);
}
template <typename T> int topbit(T x) {
    return (x == 0 ? -1 : 63 - __builtin_clzll(x));
}
template <typename T> int lowbit(T x) {
    return (x == 0 ? -1 : __builtin_ctzll(x));
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "P(" << p.first << ", " << p.second << ")";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end())
            os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const set<T> &set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end())
            os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#ifdef LOCAL
#define show(...) _show(0, #__VA_ARGS__, __VA_ARGS__)
#else
#define show(...) true
#endif
template <typename T> void _show(int i, T name) {
    cerr << '\n';
}
template <typename T1, typename T2, typename... T3>
void _show(int i, const T1 &a, const T2 &b, const T3 &...c) {
    for (; a[i] != ',' && a[i] != '\0'; i++)
        cerr << a[i];
    cerr << ":" << b << " ";
    _show(i + 1, a, c...);
}

#include <unistd.h>

namespace fastio {
static constexpr uint32_t SZ = 1 << 17;
char ibuf[SZ];
char obuf[SZ];
char out[100];
// pointer of ibuf, obuf


uint32_t pil = 0, pir = 0, por = 0;

struct Pre {
    char num[10000][4];
    constexpr Pre() : num() {
        for (int i = 0; i < 10000; i++) {
            int n = i;
            for (int j = 3; j >= 0; j--) {
                num[i][j] = n % 10 | '0';
                n /= 10;
            }
        }
    }
} constexpr pre;

inline void load() {
    memmove(ibuf, ibuf + pil, pir - pil);
    pir = pir - pil + fread(ibuf + pir - pil, 1, SZ - pir + pil, stdin);
    pil = 0;
    if (pir < SZ)
        ibuf[pir++] = '\n';
}

inline void flush() {
    fwrite(obuf, 1, por, stdout);
    por = 0;
}

void rd(char &c) {
    do {
        if (pil + 1 > pir)
            load();
        c = ibuf[pil++];
    } while (isspace(c));
}

void rd(string &x) {
    x.clear();
    char c;
    do {
        if (pil + 1 > pir)
            load();
        c = ibuf[pil++];
    } while (isspace(c));
    do {
        x += c;
        if (pil == pir)
            load();
        c = ibuf[pil++];
    } while (!isspace(c));
}

template <typename T> void rd_real(T &x) {
    string s;
    rd(s);
    x = stod(s);
}

template <typename T> void rd_integer(T &x) {
    if (pil + 100 > pir)
        load();
    char c;
    do
        c = ibuf[pil++];
    while (c < '-');
    bool minus = 0;
    if constexpr (is_signed<T>::value || is_same_v<T, i128>) {
        if (c == '-') {
            minus = 1, c = ibuf[pil++];
        }
    }
    x = 0;
    while ('0' <= c) {
        x = x * 10 + (c & 15), c = ibuf[pil++];
    }
    if constexpr (is_signed<T>::value || is_same_v<T, i128>) {
        if (minus)
            x = -x;
    }
}

void rd(int &x) {
    rd_integer(x);
}
void rd(ll &x) {
    rd_integer(x);
}
void rd(i128 &x) {
    rd_integer(x);
}
void rd(uint &x) {
    rd_integer(x);
}
void rd(ull &x) {
    rd_integer(x);
}
void rd(u128 &x) {
    rd_integer(x);
}
void rd(double &x) {
    rd_real(x);
}
void rd(long double &x) {
    rd_real(x);
}

template <class T, class U> void rd(pair<T, U> &p) {
    return rd(p.first), rd(p.second);
}
template <size_t N = 0, typename T> void rd_tuple(T &t) {
    if constexpr (N < std::tuple_size<T>::value) {
        auto &x = std::get<N>(t);
        rd(x);
        rd_tuple<N + 1>(t);
    }
}
template <class... T> void rd(tuple<T...> &tpl) {
    rd_tuple(tpl);
}

template <size_t N = 0, typename T> void rd(array<T, N> &x) {
    for (auto &d : x)
        rd(d);
}
template <class T> void rd(vector<T> &x) {
    for (auto &d : x)
        rd(d);
}

void read() {}
template <class H, class... T> void read(H &h, T &...t) {
    rd(h), read(t...);
}

void wt(const char c) {
    if (por == SZ)
        flush();
    obuf[por++] = c;
}
void wt(const string s) {
    for (char c : s)
        wt(c);
}
void wt(const char *s) {
    size_t len = strlen(s);
    for (size_t i = 0; i < len; i++)
        wt(s[i]);
}

template <typename T> void wt_integer(T x) {
    if (por > SZ - 100)
        flush();
    if (x < 0) {
        obuf[por++] = '-', x = -x;
    }
    int outi;
    for (outi = 96; x >= 10000; outi -= 4) {
        memcpy(out + outi, pre.num[x % 10000], 4);
        x /= 10000;
    }
    if (x >= 1000) {
        memcpy(obuf + por, pre.num[x], 4);
        por += 4;
    } else if (x >= 100) {
        memcpy(obuf + por, pre.num[x] + 1, 3);
        por += 3;
    } else if (x >= 10) {
        int q = (x * 103) >> 10;
        obuf[por] = q | '0';
        obuf[por + 1] = (x - q * 10) | '0';
        por += 2;
    } else
        obuf[por++] = x | '0';
    memcpy(obuf + por, out + outi + 4, 96 - outi);
    por += 96 - outi;
}

template <typename T> void wt_real(T x) {
    ostringstream oss;
    oss << fixed << setprecision(15) << double(x);
    string s = oss.str();
    wt(s);
}

void wt(int x) {
    wt_integer(x);
}
void wt(ll x) {
    wt_integer(x);
}
void wt(i128 x) {
    wt_integer(x);
}
void wt(uint x) {
    wt_integer(x);
}
void wt(ull x) {
    wt_integer(x);
}
void wt(u128 x) {
    wt_integer(x);
}
void wt(double x) {
    wt_real(x);
}
void wt(long double x) {
    wt_real(x);
}

template <class T, class U> void wt(const pair<T, U> val) {
    wt(val.first);
    wt(' ');
    wt(val.second);
}
template <size_t N = 0, typename T> void wt_tuple(const T t) {
    if constexpr (N < std::tuple_size<T>::value) {
        if constexpr (N > 0) {
            wt(' ');
        }
        const auto x = std::get<N>(t);
        wt(x);
        wt_tuple<N + 1>(t);
    }
}
template <class... T> void wt(tuple<T...> tpl) {
    wt_tuple(tpl);
}
template <class T, size_t S> void wt(const array<T, S> val) {
    auto n = val.size();
    for (size_t i = 0; i < n; i++) {
        if (i)
            wt(' ');
        wt(val[i]);
    }
}
template <class T> void wt(const vector<T> val) {
    auto n = val.size();
    for (size_t i = 0; i < n; i++) {
        if (i)
            wt(' ');
        wt(val[i]);
    }
}

void print() {
    wt('\n');
}
template <class Head, class... Tail> void print(Head &&head, Tail &&...tail) {
    wt(head);
    if (sizeof...(Tail))
        wt(' ');
    print(forward<Tail>(tail)...);
}
void __attribute__((destructor)) _d() {
    flush();
}
} // namespace fastio


using fastio::flush;
using fastio::print;
using fastio::read;

inline void first(bool i = true) {
    print(i ? "first" : "second");
}
inline void Alice(bool i = true) {
    print(i ? "Alice" : "Bob");
}
inline void Takahashi(bool i = true) {
    print(i ? "Takahashi" : "Aoki");
}
inline void yes(bool i = true) {
    print(i ? "yes" : "no");
}
inline void Yes(bool i = true) {
    print(i ? "Yes" : "No");
}
inline void No() {
    print("No");
}
inline void YES(bool i = true) {
    print(i ? "YES" : "NO");
}
inline void NO() {
    print("NO");
}
inline void Yay(bool i = true) {
    print(i ? "Yay!" : ":(");
}
inline void Possible(bool i = true) {
    print(i ? "Possible" : "Impossible");
}
inline void POSSIBLE(bool i = true) {
    print(i ? "POSSIBLE" : "IMPOSSIBLE");
}

/**
 * @brief Fast IO
 */

int main() {
    int MAXS = 300001;
    vector<bool> B(MAXS,true);
    vector<int> Prime;
    rep(i,2,MAXS) {
        if (i % 7 != 1 && i % 7 != 6) continue;
        if (B[i]) {
            Prime.push_back(i);
            rep(j,2,MAXS) {
                if ((ll)i * (ll)j >= (ll)MAXS) break;
                if (j % 7 != 1 && j % 7 != 6) continue;
                B[i*j]=false;
            }
        }
    }
while(1) {
    int _;
    cin >> _;
    int N = _;
    if (N == 1) return 0;
    vector<int> ANS;
    for (int P : Prime) {
        if (P > N) break;
        if (N % P == 0) {
            ANS.push_back(P);
        }
    }
    cout << _ << ':';
    for (int X : ANS) cout << ' ' << X;
    cout << endl;
}
}
accuracy: 1
time_ms: 40
memory_kb: 3652
final_rank: 1

code_snippet: #include <iostream>
#include<string.h>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include<math.h>


using namespace std;





int main()
{
	int check[300010];
	int n;
	int i, j;


	for (i = 1; i < 300010; i++) {
		check[i] = 0;
	}
	for (i = 1; i * 7 + 6 <= 300010; i++) {
		if (check[7 * i + 1] == 0) {
			check[7 * i + 1] = 1;
			for (j = 2 * (7 * i + 1); j < 300010; j += 7 * i + 1) {
				check[j] = 2;
			}
		}
		if (check[7 * i - 1] == 0) {
			check[7 * i - 1] = 1;
				for (j = 2 * (7 * i - 1); j  < 300010; j+= 7 * i - 1) {
					check[j] = 2;
			}
		}

	}

		while (1) {
			cin >> n;
			if (n == 1) {
				return 0;
			}
			cout << n << ":";
			for (i = 1; 7 *i < 300010; i++) {
				if (check[7 * i - 1] == 1 && n % (7 * i - 1 ) == 0) {

					cout << ' ' << 7 * i - 1;

				}
				if (check[7 * i + 1] == 1 && n % (7 * i + 1) == 0) {

					cout << ' ' << 7 * i + 1;

				}
			}
			cout << endl;

		}

}
accuracy: 1
time_ms: 310
memory_kb: 4256
final_rank: 12

code_snippet: #include <iostream>
#include<string.h>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include<math.h>


using namespace std;

void setting(int*, int);
void output(int*, int,int);



int main(){
	int check[300010];
	int n;
	int i;


	for (i = 1; i < 300010; i++) {
		check[i] = 0;
	}
	for (i = 1; i * 7 + 6 <= 300010; i++) {
		setting(check, 7 * i + 1);
		setting(check, 7 * i - 1);

	}

	while (1) {
		cin >> n;
		if (n == 1) {
			return 0;
		}
		cout << n << ":";
		for (i = 1; 7 * i < 300010; i++) {
			output(check, 7 * i - 1, n);
			output(check, 7 * i + 1, n);
		}
		cout << endl;

	}

}

void setting(int* x, int y) {
		if (x[y] == 0) {
			x[y] = 1;
			for (int j = 2 * (y); j < 300010; j += y) {
				x[j] = 2;
			}
		}
	}

void output(int* x, int y,int n) {
	if (x[y] == 1 && n % y == 0) {

		cout << ' ' <<y;

	}
}
accuracy: 1
time_ms: 320
memory_kb: 4212
final_rank: 14

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = (int)1e9 + 1001010;
const ll llINF = (long long)4e18 + 22000020;
const string endn = "\n";
template <class T> inline auto vector2(size_t i, size_t j, const T &init = T()) {return vector(i, vector<T>(j, init));}
const string ELEM_SEPARATION = " ", VEC_SEPARATION = endn;
template<class T> istream& operator >>(istream &i, vector<T> &A) {for(auto &I : A) {i >> I;} return i;}
template<class T> ostream& operator <<(ostream &o, const vector<T> &A) {int i=A.size(); for(const auto &I : A){o << I << (--i ? ELEM_SEPARATION : "");} return o;}
template<class T> ostream& operator <<(ostream &o, const vector<vector<T>> &A) {int i=A.size(); for(const auto &I : A){o << I << (--i ? VEC_SEPARATION : "");} return o;}
template<class T> vector<T>& operator ++(vector<T> &A, int n) {for(auto &I : A) {I++;} return A;}
template<class T> vector<T>& operator --(vector<T> &A, int n) {for(auto &I : A) {I--;} return A;}
template<class T, class U> bool chmax(T &a, const U &b) {return ((a < b) ? (a = b, true) : false);}
template<class T, class U> bool chmin(T &a, const U &b) {return ((a > b) ? (a = b, true) : false);}
ll floor(ll a, ll b){if (b < 0) a = -a, b = -b; if(a >= 0) return a / b; else return (a + 1) / b - 1;}
ll ceil(ll a, ll b){if (b < 0) a = -a, b = -b; if(a > 0) return (a - 1) / b + 1; else return a / b;}
ll bit(unsigned long long val, unsigned long long digit){return (val >> digit) & 1;}
#ifdef DEBUG
#include <debug_slephy.cpp>
#else
#define debug(...)
#endif
// ================================== ここまでテンプレ ==================================

vector<ll> sprimes;
const ll MAX = 3e5 + 10;

void solve(){
    ll n; cin >> n;
    if(n == 1) exit(0);
    vector<ll> ans;
    for(auto pr : sprimes){
        if(pr > n) break;
        if(n % pr == 0) ans.emplace_back(pr);
    }

    sort(ans.begin(), ans.end());
    cout << n << ": " << ans << endl;
}

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    vector<ll> is_sprime(MAX, true);
    for(int i = 6; i < MAX; i++){
        if(!is_sprime[i]) continue;
        if(i % 7 == 1 || i % 7 == 6){
            sprimes.emplace_back(i);
            for(int j = 2*i; j < MAX; j+=i){
                is_sprime[j] = false;
            }
        }
    }
    debug(sprimes);
    debug(sprimes.size());
    while(true) solve();
}
accuracy: 1
time_ms: 130
memory_kb: 5924
final_rank: 10

code_snippet: #include<bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;

#define all(v) v.begin(),v.end()
using ll = long long;
using ull = unsigned long long;
using vll=vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,ll>;
using vp=vector<pair<ll, ll>>;
//using mint=modint1000000007;
//using mint=modint998244353;

const ll INF=1ll<<60;
ll mod10=1e9+7;
ll mod99=998244353;
const double PI = acos(-1);

#define rep(i,n) for (ll i=0;i<n;++i)
#define per(i,n) for(ll i=n-1;i>=0;--i)
#define rep2(i,a,n) for (ll i=a;i<n;++i)
#define per2(i,a,n) for (ll i=a;i>=n;--i)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

ll N=500000;
vll pri(N,1);
vll num(N,0);


bool solve(){
    ll N;cin>>N;
    if(N==1) return 0;
    vll ans;
    rep2(i,1,N+1){
        if(i*i>N) break;
        if(N%i) continue;
        if(pri[i]==1) ans.push_back(i);
        if(i*i!=N&&pri[N/i]==1) ans.push_back(N/i);
    }
    sort(all(ans));
    cout<<N<<": ";
    rep(i,ans.size()) cout<<ans[i]<<" \n"[i==ans.size()-1];

    return 1;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    rep2(i,1,N){
        num[i]=(i%7==1||i%7==6);
    }

    pri[0]=pri[1]=0;
    rep2(i,2,N){
        if(num[i]==0) pri[i]=0;
        rep2(j,2,i+1){
            if(j*j>i) break;
            if(i%j) continue;
           
            if(pri[j]==1||pri[i/j]==1) pri[i]=0;
        }
    }

   
    while(solve());
}
accuracy: 1
time_ms: 1420
memory_kb: 10628
final_rank: 20

code_snippet: #include <bits/stdc++.h>
using namespace std;

#define rep(i,k,n) for (int i = k; i < (n); ++i)
const long long MOD1 = 1000000007;
const long long MOD2 = 998244353;
typedef long long ll;
typedef pair<ll, ll> P;
const long long INF = 1e17;

int main(){
    vector<int> monsat_num;
    for(int i=2;i<=300001;i++){
        if(i%7==1||i%7==6){
            monsat_num.push_back(i);
        }
    }
    vector<int> monsat_prime;
    for(int i=0;i<monsat_num.size();i++){
        int j = 0;
        bool prime = true;
        while(monsat_num[j]*monsat_num[j]<=monsat_num[i]){
            if(monsat_num[i]%monsat_num[j]==0){
                prime = false;
                break;
            }
            j++;
        }

        if(prime){
            monsat_prime.push_back(monsat_num[i]);
        }

    }

    while(true){
        int n;
        cin >> n;
        if(n==1){
            break;
        }
        cout << n << ':';
        for(int i=0;i<monsat_prime.size();i++){
            if(n%monsat_prime[i]==0){
                cout << ' ' << monsat_prime[i];
            }
        }
        cout << endl;
    }
    return 0;
}
accuracy: 1
time_ms: 80
memory_kb: 3644
final_rank: 6

code_snippet: #include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<long long, long long>>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long long>>;
using vvc = vector<vector<char>>;
using vvvi = vector<vector<vector<int>>>;
using pii = pair<int, int>;
using vvb = vector<vector<bool>>;
using Graph = vector<vector<ll>>;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 998422353;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep3(i, m, n) for (int i = (m); i < (int)(n); i++)
#define rrep(i, m, n) for (int i = (m); i >= (int)(n); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

vi dx4 = {1, 0, -1, 0}, dy4 = {0, 1, 0, -1};
vi dx8 = {1, 1, 1, 0, 0, -1, -1, -1}, dy8 = {1, 0, -1, 1, -1, 1, 0, -1};

bool isprime(long long n)
{
    if (n <= 1)
        return false;
    for (long long p = 6; p * p <= n; p += 7)
    {
        if (n % p == 0)
            return false;
    }
    for (long long p = 8; p * p <= n; p += 7)
    {
        if (n % p == 0)
            return false;
    }
    return true;
}

int main()
{
    vi prime;
    for (int i = 6; i <= 300000; i += 7)
    {
        if (isprime(i))
        {
            prime.emplace_back(i);
        }
    }
    for (int i = 8; i <= 300000; i += 7)
    {
        if (isprime(i))
        {
            prime.emplace_back(i);
        }
    }
    sort(all(prime));
    while (1)
    {
        // 宣言・入力の受け取り
        int n;
        cin >> n;
        // 終了条件
        if (n == 1)
        {
            break;
        }
        // 宣言・入力の受け取り

        // solve
        cout << n << ":";
        for (auto x : prime)
        {
            if (n % x == 0)
            {
                cout << ' ' << x;
            }
            if (x > n)
            {
                break;
            }
        }
        cout << '\n';
        // 出力
    }
    return 0;
}
accuracy: 1
time_ms: 70
memory_kb: 3300
final_rank: 2

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0;i < n;i++)

#define int ll
#define double long double
#define IMAX ((1 << 31) - 1)
#define LMAX ((1LL << 63) - 1)

#define MOD 998244353
#define MAX 300005


vector<int> nums;
vector<set<int>> sp;
void init()
{
    for(int i = 1;i < MAX + 5;i += 7)
    {
        nums.push_back(i);
        nums.push_back(i + 5);
    }
    sp.resize(MAX + 10);

//    cout << nums[0] << endl;
    for(int i = 1;i < nums.size(); i++)
    {
        if(sp[nums[i]].size() != 0) continue;
        sp.at(nums[i]).insert(nums[i]);
        for(int j = 1; nums[i] * nums[j] < MAX; j++)
        {
            sp.at(nums[i] * nums[j]).insert(nums[i]);
        }
    }

}
void main_()
{
    int n;
    cin >> n;
    if(n == 1) exit(0);
    set<int> st;

    cout << n << ":";
    for(int i : sp.at(n))
    {
        cout << " " << i;
    }
    cout << endl;
}
signed main()
{
    init();

    while(1) main_();
}
accuracy: 1
time_ms: 10
memory_kb: 26388
final_rank: 19

code_snippet: #include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

vector<int> GeneratePrimes(const int max) {
	vector<int> primes;
	vector<bool> isnt_prime(max, false);

	for (int i = 7; i <= max; i += 7) {
		for (int j = i - 1; j <= i + 1 && j <= max; j += 2) {
			if (isnt_prime[j]) continue;
			primes.push_back(j);
			for (int k = j; k <= max; k += j) {
				isnt_prime[k] = true;
			}
		}
	}

	return primes;
}

int main() {
	const int max = 300000 - 1;
	vector<int> primes = GeneratePrimes(max);

	while (true) {
		int n;
		cin >> n;
		if (n == 1) break;

		cout << n << ":";

		for (int p : primes) {
			if (n % p == 0) cout << " " << p;
		}

		cout << endl;
	}

	return 0;
}
accuracy: 1
time_ms: 70
memory_kb: 3512
final_rank: 3

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, a, b) for(ll i = a; i < b; ++i)
#define rrep(i, a, b) for(ll i = a; i >= b; --i)
constexpr ll inf = 4e18;
struct SetupIO {
    SetupIO() {
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout << fixed << setprecision(30);
    }
} setup_io;
int main(void) {
    constexpr int MAX = 3e5;
    vector<bool> prime(MAX + 1, true);
    prime[1] = false;
    for(int i = 0; i * 7 <= MAX; ++i) {
        {
            int x = i * 7 + 1;
            if(x <= MAX) {
                if(prime[x]) {
                    for(int j = x * 2; j <= MAX; j += x) {
                        prime[j] = false;
                    }
                }
            }
        }
        {
            int x = i * 7 + 6;
            if(x <= MAX) {
                if(prime[x]) {
                    for(int j = x * 2; j <= MAX; j += x) {
                        prime[j] = false;
                    }
                }
            }
        }
    }
    while(1) {
        int n;
        cin >> n;
        if(n == 1) break;
        cout << n << ':';
        for(int i = 0; i * 7 <= MAX; ++i) {
            {
                int x = i * 7 + 1;
                if(x <= MAX) {
                    if(prime[x]) {
                        if(n % x == 0) {
                            cout << ' ' << x;
                        }
                    }
                }
            }
            {
                int x = i * 7 + 6;
                if(x <= MAX) {
                    if(prime[x]) {
                        if(n % x == 0) {
                            cout << ' ' << x;
                        }
                    }
                }
            }
        }
        cout << '\n';
    }
}
accuracy: 1
time_ms: 390
memory_kb: 3356
final_rank: 15

code_snippet: #include <bits/stdc++.h>

constexpr int N = 300005;
bool is_prime[N];

std::vector<int> divisor(int n) {
    std::vector<int> res;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i * i != n) {
                res.push_back(n / i);
            }
        }
    }
    return res;
}

void init() {
    std::fill(is_prime, is_prime + N, true);
    is_prime[0] = is_prime[1] = false;
    std::vector<int> prime;
    for (int i = 2; i < N; i++) {
        if (i % 7 != 1 && i % 7 != 6) {
            is_prime[i] = false;
        }
    }

    for (int i = 2; i < N; i++) {
        if (!is_prime[i]) continue;
        for (auto div: divisor(i)) {
            if (div == 1 || div == i) continue;
            if (is_prime[div]) is_prime[i] = false;
        }
    }
}

int solve() {
    int n;
    std::cin >> n;
    if (n == 1) return 1;

    std::vector<int> ans;
    for (auto div: divisor(n)) {
        if (is_prime[div]) {
            ans.push_back(div);
        }
    }
    std::sort(ans.begin(), ans.end());
    std::cout << n << ":";
    for (auto v: ans) {
        std::cout << ' ' << v;
    }
    std::cout << std::endl;

    return 0;
}

int main() {
    init();
    while (!solve());
}
accuracy: 1
time_ms: 70
memory_kb: 3768
final_rank: 5

code_snippet: // (⁠◕⁠ᴗ⁠◕⁠✿⁠)

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define srep(i, s, n) for (ll i = s; i < (n); i++)
#define len(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
using namespace std;
template<typename T> using vc = vector<T>;
template<typename T> using vv = vc<vc<T>>;
template<typename T> using vvv = vv<vc<T>>;
using vi = vc<int>;using vvi = vv<int>; using vvvi = vv<vi>;
using ll = long long;using vl = vc<ll>;using vvl = vv<ll>; using vvvl = vv<vl>;
using ld = long double; using vld = vc<ld>; using vvld = vc<vld>; using vvvld = vc<vvld>;
using uint = unsigned int;
using ull = unsigned long long;
const ld pi = 3.141592653589793;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
// const ll mod = 1000000007;
const ll mod = 998244353;
inline bool inside(ll y, ll x, ll H, ll W) {return 0 <= (y) and (y) < (H) and 0 <= (x) and (x) < (W); }

#define debug(var)  do{std::cout << #var << " : \n";view(var);}while(0)
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vc<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vv<T>& vv){ for(const auto& v : vv){ view(v); } }

vc<bool> eratosthenes(int t){
    vc<bool> is_prime(t + 1, true);
    is_prime[0] = false, is_prime[1] = false;
    for (int i = 0; i <= t; i++){
        if ((i % 7 == 1 || i % 7 == 6) && is_prime[i]){
            for (int q = i * 2; q <= t; q += i){
                is_prime[q] = false;
            }
        }else is_prime[i] = false;
    }
    return is_prime;
}

auto is_prime = eratosthenes(300300);

vi solve(int N){
   vi ans = {N};
    rep(i, N + 1) if (is_prime[i] && N % i == 0) ans.push_back(i);
    return ans;
}

int main(){
    vc<vi> ans;
    while (true){
        int N; cin >> N;
        if (N == 1) break;
        ans.push_back(solve(N));
    }
    for (auto x : ans){
        cout << x[0] << ":";
        srep(i, 1, len(x)) cout << " " << x[i];
        cout << endl;
    }
}
accuracy: 1
time_ms: 350
memory_kb: 3336
final_rank: 11

code_snippet: #include <iostream>
#include <vector>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    vector<int> lists;
    bool checked[300001] = {};
    for (int i = 2; i <= 300000; i++) {
        if (checked[i])
            continue;
        if (i % 7 == 1 || i % 7 == 6) {
            lists.push_back(i);
            for (int j = i; j <= 300000; j += i) {
                checked[j] = true;
            }
        }
    }

    while (true) {
        int n;
        cin >> n;
        if (n == 1)
            break;
        cout << n << ':';
        for (auto p : lists) {
            if (n % p == 0) {
                cout << " " << p;
            }
        }
        cout << "\n";
    }
    return 0;
}
accuracy: 1
time_ms: 70
memory_kb: 3700
final_rank: 4

code_snippet: #include <bitset>
#include <iostream>
#include <vector>
using namespace std;
#define int long long
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
bitset<300000 + 1> checked;
vector<int> lists;
vector<int> ans;
// Precomputed results of modulus operation for 7.
int mod7[7] = {0, 1, 2, 3, 4, 5, 6};
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  rep2(i, 2, 300000 + 1) {
    if (checked[i])
      continue;
    // Use lookup table to replace modulus operation.
    if (mod7[i % 7] == 1 || mod7[i % 7] == 6) {
      lists.push_back(i);
      int k = 1;
      while (i * k <= 300000) {
        checked[i * k] = true;
        k++;
      }
    }
  }
  // Reserve space for "ans" vector in advance.
  ans.reserve(lists.size());
  while (true) {
    int n;
    cin >> n;
    if (n == 1)
      break;
    for (auto p : lists) {
      if (n % p == 0) {
        ans.push_back(p);
      }
    }
    cout << n << ':';
    for (auto num : ans) { cout << " " << num; }
    cout << endl;
    ans.clear();
  }
}
accuracy: 1
time_ms: 240
memory_kb: 3604
final_rank: 9