Problem:
Bamboo Blossoms
The bamboos live for decades, and at the end of their lives,
  they flower to make their seeds.  Dr. ACM, a biologist, was fascinated
  by the bamboos in blossom in his travel to Tsukuba.  He liked
  the flower so much that he was tempted to make a garden where
  the bamboos bloom annually.  Dr. ACM started research of
  improving breed of the bamboos, and finally, he established
  a method to develop bamboo breeds with controlled lifetimes.
  With this method, he can develop bamboo breeds that flower
  after arbitrarily specified years.
Let us call bamboos that flower
k
years after sowing
  "
k
-year-bamboos."
k
years after being sowed,
k
-year-bamboos make
  their seeds and then die,
  hence their next generation flowers after another
k
years.
  In this way, if he sows seeds of
k
-year-bamboos, he can
  see bamboo blossoms every
k
years.  For example,
  assuming that he sows seeds of 15-year-bamboos,
  he can see bamboo blossoms every 15 years;
  15 years, 30 years, 45 years, and so on, after sowing.
Dr. ACM asked you for designing his garden.  His garden is partitioned
  into blocks, in each of which only a single breed of bamboo can grow.
  Dr. ACM requested you to decide which breeds of bamboos
  should he sow in the blocks in order to see bamboo blossoms
  in at least one block for as many years as possible.
You immediately suggested to sow seeds of one-year-bamboos in all blocks.
  Dr. ACM, however, said that it was difficult to develop a bamboo breed
  with short lifetime, and would like a plan using only those breeds with
  long lifetimes.  He also said that, although he could wait for some years
  until he would see the first bloom, he would like to see it in
  every following year.
  Then, you suggested a plan
  to sow seeds of 10-year-bamboos, for example, in different blocks each year,
  that is, to sow in a block this year and in another block next year, and so on,
  for 10 years.  Following this plan, he could see
  bamboo blossoms in one block every year except for the first 10 years.
  Dr. ACM objected again saying he had determined to sow in all
  blocks this year.
After all, you made up your mind to make a sowing plan where the bamboos
  bloom in at least one block for as many consecutive years as possible
  after the first
m
years (including this year)
  under the following conditions:
the plan should use only those bamboo breeds whose
      lifetimes are
m
years or longer, and
Dr. ACM should sow the seeds in all the blocks only this year.
Input
The input consists of at most 50 datasets, each in the following format.
m
n
An integer
m
(2 ≤
m
≤ 100) represents the lifetime
  (in years)
  of the bamboos with the shortest lifetime that Dr. ACM can use for
  gardening.
  An integer
n
(1 ≤
n
≤ 500,000) represents the number of blocks.
The end of the input is indicated by a line containing two zeros.
Output
No matter how good your plan is, a "dull-year" would
  eventually come, in which the bamboos do not flower in an
...(truncated)

Submitted solutions:

code_snippet: #include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll m, n;

	while (true) {
		cin >> m >> n;

		if (m == 0) {
			break;
		}

		ll x = min((ll)7400000, m * n * 10);

		//vector<ll> prime;
		vector<bool> is_prime(x + 1, true);
		ll count = 0;
		ll ans = 0;

		is_prime[0] = is_prime[1] = false;

		FOR(i, m, x + 1) {
			if (is_prime[i]) {
				//prime.push_back(i);

				count++;

				if (count == n + 1) {
					ans = i;
					break;
				}

				for (ll j = 2 * i; j <= x; j += i) {
					is_prime[j] = false;
				}
			}
		}

		cout << ans << endl;
	}
}
accuracy: 1
time_ms: 640
memory_kb: 4232
final_rank: 1

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

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

  const int L = 7368800;

  while(true) {
    ll M, N;
    cin >> M >> N;

    if(!M) { break; }

    bitset<L> dp;

    ll p = M;
    for(ll i = 0; i < N; i++) {
      while(dp[p]) { p++; }
      for(ll j = p; j < L; j += p) { dp[j] = true; }
    }

    while(dp[p]) { p++; }

    cout << p << "\n";
  }
}
accuracy: 1
time_ms: 860
memory_kb: 4192
final_rank: 2

code_snippet: #include<bits/stdc++.h>
#define FOR(i,s,t) for(int i = s; i<t ; i++)
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(), x.end()

using namespace std;

using VI = vector<int>;
using LL = long long;
using VL = vector<LL>;

int era[7400000];
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	int N, M;

	while (cin >> M >> N, N || M) {
		fill(era, era + 7400000, 0);
		int ans = 0;
		for (int i = M; i < 7400000; i++) {
			if (era[i])continue;
			else {
				if (N > 0) {
					N--;
					era[i] = 1;
					for (int j = 2 * i; j < 7400000; j += i) {
						era[j] = 1;
					}
				}
				else {
					ans = i;
					goto X;
				}
			}
		}
	X:;
		cout << ans << endl;
	}
	

	return 0;
}
accuracy: 1
time_ms: 3770
memory_kb: 32280
final_rank: 14

code_snippet: #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
int main()
{
    ll m, n;
    while (std::cin >> m >> n,m)
    {
        std::vector<ll>vec(7400000, 0);
        ll x = m;
        for (ll i = 0; i <n ; i++)
        {
            while (vec[x])
            {
                x++;
            }
            for (ll j = x; j < vec.size(); j+=x)vec[j] = 1;
        }
        for (ll i = m; i < vec.size(); i++)
        {
            if (!vec[i])
            {
                std::cout << i << "\n";
                break;
            }
        }
    }
}
accuracy: 1
time_ms: 4930
memory_kb: 60880
final_rank: 17

code_snippet: #line 1 "2016C.cpp"
#include <bits/stdc++.h>
#line 1 "/home/ardririy/repos/cp-libs/libraries-cpp/input.hpp"


#line 6 "/home/ardririy/repos/cp-libs/libraries-cpp/input.hpp"
using namespace std;
vector<long long> i64_vec_IN(int n) {vector<long long> res(n); for(int i=0; i<n; i++) { cin >> res[i]; } return res; }
vector<string> str_vec_IN(int n) { vector<string> res(n); for(int i=0; i<n; i++) { cin >> res[i]; } return res; }
vector<vector<int>> graph_IN(int n, int m) { vector<vector<int>> g(n); int u, v; for(int i=0; i<m; i++) { cin >> u >> v; u--; v--; g[u].emplace_back(v); g[v].emplace_back(u); } return g; }
vector<vector<pair<int, long long>>> weighted_graph_IN(int n, int m) { vector<vector<pair<int, long long>>> g(n); int u, v; long long w; for(int i=0; i<m; i++) { cin >> u >> v >> w; u--; v--; g[u].push_back({v, w}); g[v].push_back({u, w}); } return g; }


#line 3 "2016C.cpp"

using namespace std;

// using namespace atcoder;

#ifdef ADRY
#include <dbg.h>
#else
// DO NOTHING
#define dbg(x)
#endif


#define all(v) v.begin(),v.end()
#define resort(v) sort(v.rbegin(),v.rend())
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 djks=priority_queue<P, vp, greater<P>>;

const int inf=1ll<<30;
#define mod10 (ll)1e9+7
#define mod99 (ll)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=(n)-1;i>=(a);--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 dx[] = {1, 0, -1, 0, -1, 1, -1, 1};
ll dy[] = {0, 1, 0, -1, -1, 1, 1, -1};

bitset<7368792> v;
const int k = 7368792;
int solve(){
    ll m, n; cin >> m >> n;
    if(m==0) return 1;
    rep(i,k) {
        v[i] = false;
    }
    ll left = n;
    rep(i,k) {
        if(v[i]) continue;
        ll cur = i+m;
        while(cur<k+m) {
            v[cur-m] = true;
            cur += i+m;
        }
        left--;
        if(left==0) break;
    }
    ll ans = 0;
    rep(i,k) {
        if(v[i]) ans++;
        else break;
    }
    cout << ans+m << '\n';
    return 0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(!solve());
}
accuracy: 1
time_ms: 1150
memory_kb: 4372
final_rank: 10

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

#define OVERRIDE(a,b,c,d,...) d
#define REP2(i,n) for (i32 i = 0; i < (i32)(n); ++i)
#define REP3(i,m,n) for (i32 i = (i32)(m); i < (i32)(n); ++i)
#define REP(...) OVERRIDE(__VA_ARGS__, REP3, REP2)(__VA_ARGS__)
#define PER2(i,n) for (i32 i = (i32)(n)-1; i >= 0; --i)
#define PER3(i,m,n) for (i32 i = (i32)(n)-1; i >= (i32)(m); --i)
#define PER(...) OVERRIDE(__VA_ARGS__, PER3, PER2)(__VA_ARGS__)
#define ALL(x) begin(x), end(x)
#define LEN(x) (i32)(x.size())
using namespace std;
using u32 = unsigned int;
using u64 = unsigned long long;
using i32 = signed int;
using i64 = signed long long;
using f64 = double;
using f80 = long double;
using pi = pair<i32, i32>;
using pl = pair<i64, i64>;
template <typename T>
using V = vector<T>;
template <typename T>
using VV = V<V<T>>;
template <typename T>
using VVV = V<V<V<T>>>;
template <typename T>
using VVVV = V<V<V<V<T>>>>;
template <typename T>
using PQR = priority_queue<T, V<T>, greater<T>>;
template <typename T>
bool chmin(T &x, const T &y) {
    if (x > y) {
        x = y;
        return true;
    }
    return false;
}
template <typename T>
bool chmax(T &x, const T &y) {
    if (x < y) {
        x = y;
        return true;
    }
    return false;
}
template <typename T>
i32 lob(const V<T> &arr, const T &v) {
    return (i32)(lower_bound(ALL(arr), v) - arr.begin());
}
template <typename T>
i32 upb(const V<T> &arr, const T &v) {
    return (i32)(upper_bound(ALL(arr), v) - arr.begin());
}
template <typename T>
V<i32> argsort(const V<T> &arr) {
    V<i32> ret(arr.size());
    iota(ALL(ret), 0);
    sort(ALL(ret), [&](i32 i, i32 j) -> bool {
        if (arr[i] == arr[j]) {
            return i < j;
        } else {
            return arr[i] < arr[j];
        }
    });
    return ret;
}
[[maybe_unused]] constexpr i32 INF = 1000000100;
[[maybe_unused]] constexpr i64 INF64 = 3000000000000000100;
struct SetUpIO {
    SetUpIO() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        cout << fixed << setprecision(15);
    }
} set_up_io;
void scan(char &x) { cin >> x; }
void scan(u32 &x) { cin >> x; }
void scan(u64 &x) { cin >> x; }
void scan(i32 &x) { cin >> x; }
void scan(i64 &x) { cin >> x; }
void scan(string &x) { cin >> x; }
template <typename T>
void scan(V<T> &x) {
    for (T &ele : x) {
        scan(ele);
    }
}
void read() {}
template <typename Head, typename... Tail>
void read(Head &head, Tail &...tail) {
    scan(head);
    read(tail...);
}
#define CHAR(...) char __VA_ARGS__; read(__VA_ARGS__);
#define U32(...) u32 __VA_ARGS__; read(__VA_ARGS__);
#define U64(...) u64 __VA_ARGS__; read(__VA_ARGS__);
#define I32(...) i32 __VA_ARGS__; read(__VA_ARGS__);
#define I64(...) i64 __VA_ARGS__; read(__VA_ARGS__);
#define STR(...) string __VA_ARGS__; read(__VA_ARGS__);
#define VEC(type,name,size) V<type> name(size); read(name);
#define VVEC(type,name,size1,size2) VV<type> name(size1, V<type>(size2)); read(name);
#define DBG(...) (void)0
constexpr i32 K = 7368800;
i32 arr[K];
i32 id = 0;
void solve(i32 m, i32 n) {
    ++id;
    i32 cur = m;
    REP(i, n) {
        while (arr[cur] == id) {
            ++cur;
        }
        i32 use = cur;
        for (i32 i = use; i < K; i += use) {
            arr[i] = id;
        }
    }
    while (arr[cur] == id) {
        ++cur;
    }
    cout << cur << endl;
}
int main() {
    while (true) {
        I32(m, n);
        if (m == 0) {
            break;
        }
        solve(m, n);
    }
}
accuracy: 1
time_ms: 4730
memory_kb: 32460
final_rank: 15

code_snippet: #ifdef LOCAL
#define _GLIBCXX_DEBUG
#pragma GCC optimize("O0")
#else
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif

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

// #include <atcoder/modint>
// using mint = atcoder::modint998244353;
// istream& operator>>(istream& in, mint& x) {
//     long long a;
//     in >> a;
//     x = a;
//     return in;
// }
// ostream& operator<<(ostream& out, const mint& x) {
//     return out << x.val();
// }

using ll = long long;
using u32 = unsigned int;
using u64 = unsigned long long;
using i128 = __int128;
using u128 = unsigned __int128;
using f128 = __float128;

template <class T>
constexpr T infty = 0;
template <>
constexpr int infty<int> = 1'000'000'000;
template <>
constexpr ll infty<ll> = ll(infty<int>) * infty<int> * 2;
template <>
constexpr u32 infty<u32> = infty<int>;
template <>
constexpr u64 infty<u64> = infty<ll>;
template <>
constexpr i128 infty<i128> = i128(infty<ll>) * infty<ll>;
template <>
constexpr double infty<double> = infty<ll>;
template <>
constexpr long double infty<long double> = infty<ll>;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
template <class T>
using vc = vector<T>;
template <class T>
using vvc = vector<vc<T>>;
using vvi = vvc<int>;
using vvl = vvc<ll>;
template <class T>
using vvvc = vector<vvc<T>>;
template <class T>
using vvvvc = vector<vvvc<T>>;
template <class T>
using vvvvvc = vector<vvvvc<T>>;
template <class T>
using pqg = std::priority_queue<T, vector<T>, greater<T>>;
template <class T, class U>
using umap = unordered_map<T, U>;

// template <typename K>
// using tree = __gnu_pbds::tree<K, __gnu_pbds::null_type, std::less<>,
//                               __gnu_pbds::rb_tree_tag,
//                               __gnu_pbds::tree_order_statistics_node_update>;

#define vv(type, name, h, ...) \
    vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...)     \
    vector<vector<vector<type>>> name( \
        h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
#define vvvv(type, name, a, b, c, ...)         \
    vector<vector<vector<vector<type>>>> name( \
        a, vector<vector<vector<type>>>(       \
               b, vector<vector<type>>(c, vector<type>(__VA_ARGS__))))

// FOR(a) :=  for (ll _ = 0; _ < (ll)a; ++_)
// FOR(i, a) := for (ll i = 0; i < (ll)a; ++i)
// FOR(i, a, b) := for (ll i = a; i < (ll)b; ++i)
// FOR(i, a, b, c) := for (ll i = a; i < (ll)b; i += (c))
// FOR_R(a) := for (ll i = (a) - 1; i >= 0; --i)
// FOR_R(i, a) := for (ll i = (a) - 1; i >= 0; --i)
// FOR_R(i, a, b) := for (ll i = (b) - 1; i >= (ll)a; --i)
#define FOR1(a) for (ll _ = 0; _ < (ll)a; ++_)
#define FOR2(i, a) for (ll i = 0; i < (ll)a; ++i)
#define FOR3(i, a, b) for (ll i = a; i < (ll)b; ++i)
#define FOR4(i, a, b, c) for (ll i = a; i < (ll)b; i += (c))
#define FOR1_R(a) for (ll i = (a) - 1; i >= 0; --i)
#define FOR2_R(i, a) for (ll i = (a) - 1; i >= 0; --i)
#define FOR3_R(i, a, b) for (ll i = (b) - 1; i >= (ll)a; --i)
#define overload4(a, b, c, d, e, ...) e
#define overload3(a, b, c, d, ...) d
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FOR_R(...) overload3(__VA_ARGS__, FOR3_R, FOR2_R, FOR1_R)(__VA_ARGS__)

#define FOR_subset(t, s) \
    for (int t = (s); t >= 0; t = (t == 0 ? -1 : (t - 1) & (s)))
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(u32 x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
int popcnt(u64 x) { return __builtin_popcountll(x); }
int popcnt_mod_2(int x) { return __builtin_parity(x); }
int popcnt_mod_2(u32 x) { return __builtin_parity(x); }
int popcnt_mod_2(ll x) { return __builtin_parityll(x); }
int popcnt_mod_2(u64 x) { return __builtin_parityll(x); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 1, 2)
int topbit(int x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(u32 x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(ll x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
int topbit(u64 x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 0, 2)
int lowbit(int x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(u32 x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(ll x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }
int lowbit(u64 x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }

template <typename T>
T floor(T a, T b) {
    return a / b - (a % b && (a ^ b) < 0);
}
template <typename T>
T ceil(T x, T y) {
    return floor(x + y - 1, y);
}
template <typename T>
T bmod(T x, T y) {
    return x - y * floor(x, y);
}
template <typename T>
pair<T, T> divmod(T x, T y) {
    T q = floor(x, y);
    return {q, x - q * y};
}

template <typename T, typename U>
T POW(U x_, int n) {
    T x = x_;
    T ret = 1;
    while (n > 0) {
        if (n & 1) ret *= x;
        x *= x;
        n >>= 1;
    }
    return ret;
}

template <typename T, typename U>
T SUM(const vector<U> &A) {
    T sm = 0;
    for (auto &&a : A) sm += a;
    return sm;
}

#define LB(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define UB(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define UNIQUE(x) \
    sort(all(x)), x.erase(unique(all(x)), x.end()), x.shrink_to_fit()

template <class T, class S>
inline bool chmax(T &a, const S &b) {
    return (a < b ? a = b, 1 : 0);
}
template <class T, class S>
inline bool chmin(T &a, const S &b) {
    return (a > b ? a = b, 1 : 0);
}

// ? は -1
vc<int> s_to_vi(const string &S, char first_char) {
    vc<int> A(S.size());
    FOR(i, S.size()) { A[i] = (S[i] != '?' ? S[i] - first_char : -1); }
    return A;
}

template <typename T, typename U>
vector<T> cumsum(vector<U> &A, int off = 1) {
    int N = A.size();
    vector<T> B(N + 1);
    FOR(i, N) { B[i + 1] = B[i] + A[i]; }
    if (off == 0) B.erase(B.begin());
    return B;
}

template <typename T>
vector<int> argsort(const vector<T> &A) {
    vector<int> ids(A.size());
    iota(all(ids), 0);
    sort(all(ids),
         [&](int i, int j) { return (A[i] == A[j] ? i < j : A[i] < A[j]); });
    return ids;
}

// A[I[0]], A[I[1]], ...
template <typename T>
vc<T> rearrange(const vc<T> &A, const vc<int> &I) {
    vc<T> B(I.size());
    FOR(i, I.size()) B[i] = A[I[i]];
    return B;
}

template<class... T>
constexpr auto min(T... a){
    return min(initializer_list<common_type_t<T...>>{a...});
}
template<class... T>
constexpr auto max(T... a){
    return max(initializer_list<common_type_t<T...>>{a...});
}

void print(){
    cout << '\n';
}
template<class T>
void print(const T& a){
    cout << a << '\n';
}
template<class T, class... Ts>
void print(const T& a, const Ts&... b){
    cout << a;
    (cout << ... << (cout << ' ', b));
    cout << '\n';
}
template<class T>
void print(vector<T> &a){
    for (int i = 0; i < (int)a.size(); ++i) {
        cout << a[i] << " \n"[i == (int)a.size() - 1];
    }
}
template<class T>
void print(vector<T> &&a){
    for (int i = 0; i < (int)a.size(); ++i) {
        cout << a[i] << " \n"[i == (int)a.size() - 1];
    }
}
template<class T>
void print(vector<vector<T>> &a){
    for (int i = 0; i < (int)a.size(); ++i) {
        for (int j = 0; j < (int)a[i].size(); ++j) {
            cout << a[i][j] << " \n"[j == (int)a[i].size() - 1];
        }
    }
}
template<class T>
void print(vector<vector<T>> &&a){
    for (int i = 0; i < (int)a.size(); ++i) {
        for (int j = 0; j < (int)a[i].size(); ++j) {
            cout << a[i][j] << " \n"[j == (int)a[i].size() - 1];
        }
    }
}
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

#ifdef LOCAL
// https://zenn.dev/sassan/articles/19db660e4da0a4
#include "/Library/cpp-dump/dump.hpp"
#define dump(...) cpp_dump(__VA_ARGS__)
// CPP_DUMP_DEFINE_EXPORT_OBJECT(mint, val());
#else
#define dump(...)
#define CPP_DUMP_SET_OPTION(...)
#define CPP_DUMP_DEFINE_EXPORT_OBJECT(...)
#define CPP_DUMP_DEFINE_EXPORT_ENUM(...)
#define CPP_DUMP_DEFINE_DANGEROUS_EXPORT_OBJECT(...)
#endif


//----------------------------------------------------------------
constexpr ll MAXA = 8000000;

void solve() {
    ll m, n;
    cin >> m >> n;
    dump(m, n);
    if (m == 0 && n == 0) {
        exit(0);
    }
    vc<bool> ans(MAXA, false);
    while (n > 0) {
        ll k = m;
        while (k < MAXA) {
            ans[k] = true;
            k += m;
        }
        while (ans[m]) ++m;
        --n;
    }
    print(m);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(20);
    CPP_DUMP_SET_OPTION(max_line_width, 80);
    CPP_DUMP_SET_OPTION(log_label_func, cpp_dump::log_label::filename());
    CPP_DUMP_SET_OPTION(enable_asterisk, true);
    while (true) {
        solve();
    }
    return 0;
}
accuracy: 1
time_ms: 1080
memory_kb: 4580
final_rank: 7

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

bool solve(){
    int m,n;cin>>m>>n;
    if(m==0)return 0;
    const int sz =1e7;
    vector<bool> isok(sz);
    int i=m;
    for(int t=0;t<n;t++){
        for(int j=i;j<sz;j+=i)isok[j]=true;
        while(i<sz&&isok[i])i++;
    }
    cout<<i<<endl;
    return 1;
}
int main(){
    //m,m+1,m+2...が最適？
    //No
    //配列を用意して貪欲
    while(solve());
    return 0;
}
accuracy: 1
time_ms: 1460
memory_kb: 4816
final_rank: 12

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;

void init() {}

ll m, n;
void input() { cin >> m >> n; }
void solve() {
    vector<char> ok(8000000, 0);
    int i;
    for(i = m; 1; i++) {
        if(ok[i] == 0) {
            if(n) {
                n--;
                for(int j = i; j < ok.size(); j += i) {
                    ok[j] = true;
                }
            } else {
                break;
            }
        }
    }
    cout << i << endl;
}

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

    // init();
    while(1) {
        input();
        if(m == 0)
            break;
        solve();
    }

    return 0;
}
accuracy: 1
time_ms: 1240
memory_kb: 11204
final_rank: 13

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 < (ll)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;

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;
    }
};





int solve() {
	ll m, n; cin >> m >> n;
	if (m == 0 && n == 0) return 1;

	vector<bool> a(1e7, false);
	loop(i, m, 7368791) {
		if (n == 0) break;
		if (a[i]) continue;
		n--;
		for (int j = i; j < a.size(); j += i) {
			a[j] = true;
		}
	}

	ll ans = 0;
	loop(i, m, 7368791) {
		if (!a[i]) break;
		ans++;
	}

	cout << ans + m << "\n";

	return 0;
}

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

	while (!solve()) { }

	return 0;
}
accuracy: 1
time_ms: 1100
memory_kb: 4696
final_rank: 8

code_snippet: #include <bits/stdc++.h>
#include <unordered_map>
#include <stdlib.h>
using namespace std;
#define rep(i, a, n) for(ll i = a; i < n; i++)
#define rrep(i, a, n) for(ll i = a; i >= n; i--)
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) (x).begin(), (x).end()
//constexpr ll MOD = 1000000007;
constexpr ll MOD = 998244353;
constexpr int IINF = 1001001001;
constexpr ll INF = 1LL<<60;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

ll gcd(ll a, ll b){
    if(a%b == 0){
      return b;
    }else{
      return gcd(b, a%b);
    }
}

ll lcm(ll a, ll b){
    return a*b / gcd(a, b);
}

ll powMod(ll x, ll n) {
    if (n == 0) return 1 % MOD;
    ll val = powMod(x, n / 2);
    val *= val;
    val %= MOD;
    if (n % 2 == 1) val *= x;
    return val % MOD;
}
int main() {
    while(true){
        ll m, n; cin >> m >> n;
        if(m*n == 0) break;
        vector<ll> ok(7368792,0);
        rep(i,m,7368792){
            if(ok[i] == 0){
                if(n == 0){
                    cout << i << endl;
                    break;
                }
                for(ll j = i; j < 7368792; j += i) ok[j] = 1;
                n--;
            }
        }
    }
    return 0;
}
accuracy: 1
time_ms: 6990
memory_kb: 60980
final_rank: 20

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

#define rep(i,n) for(ll i=0;i<n;++i)
#define all(a) (a).begin(),(a).end()
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
template<class T> T div_floor(T a, T b) { return a / b - ((a ^ b) < 0 && a % b); }
template<class T> T div_ceil(T a, T b) { return a / b + ((a ^ b) > 0 && a % b); }
template <typename T, typename U> inline bool chmin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template <typename T, typename U> inline bool chmax(T &x, U y) { return (x < y) ? (x = y, true) : false; }

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &a){
	if (a.empty()) return os;
	os << a.front();
	for (auto e : a | views::drop(1)){
		os << ' ' << e;
	}
	return os;
}
void dump(auto... vs) {
	((cout << vs << ' '), ...) << endl;
}


void solve(ll N,ll M) {
	ll L=8e6;
	vector<bool> B(L,false);
	ll now=M;
	rep(_,N){
		while (B[now])now++;
		for (ll j=now;j<L;j+=now){
			B[j]=true;
		}
	}
	while (B[now])now++;
	cout<<now<<endl;
    return;
}


int main() {
    while (true){
		ll N,M;
		cin>>M>>N;
		if (N==0)break;
        solve(N,M);
    }
    return 0;
}
accuracy: 1
time_ms: 1120
memory_kb: 4556
final_rank: 9

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

void solve(int m, int n) {
    int mx = 8e6;
    vector<bool> ok(mx, false);

    for (int i=m; i<=mx; ++i) {
        if (n == 0) break;
        if (ok[i]) continue;
        --n;
        for (int j=1; j<=mx; ++j) {
            if (i*j >= mx) break;
            ok[i*j] = true;
        }
    }

    for (int i=m; i<=mx; ++i) {
        if (!ok[i]) {
            cout << i << endl;
            return ;
        }
    }
}

signed main() {
    while(true) {
        int n, m;
        cin >> n >> m;
        if (n == 0 && m == 0) break;
        solve(n, m);
    }
}

/*
memo

1
A
4
A A B B
5
L M N L N
6
K K K K K K
6
X X X Y Z X
10
A A A B A C A C C B
10
U U U U U V V W W W
0


*/
accuracy: 1
time_ms: 1180
memory_kb: 4560
final_rank: 11

code_snippet: #include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>
using namespace std;
using ll = long long;
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 (b<a) {a=b; return true;} return false;}
constexpr int INTINF = 1000001000;
constexpr int INTMAX = 2147483647;
constexpr ll LLMAX = 9223372036854775807;
constexpr ll LLINF = 4450000000011100000;

constexpr int MX = 7368791; 

void solve(int M, int N) {
  vector<bool> can_make_tokyo(MX+1, false);

  int idx =  M;

  for (int h=0; h<N; h++) {
    for (int i=idx; i<=MX; i++) {
      if (!can_make_tokyo[i]) {
        for (int j=idx; j<=MX; j+= i) {
          can_make_tokyo[j] = true;
        }
        while (can_make_tokyo[i]) i++;
        idx = i;
        break;
      }
    }
  }
  cout << idx << endl;
}

int main() {
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  while(true) {
    int m, n;
    cin >> m >> n;
    if (m == 0 && n == 0) break;
    solve(m,n);
  }
  return 0;
}
accuracy: 1
time_ms: 1040
memory_kb: 4448
final_rank: 5

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 lll = __int128;
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; }

bool solve(){
    ll M,N;cin>>M>>N;
    if(M==0&&N==0) return 1;
    ll K=7500000;
    vll A(K);
    ll now=M;
    rep(_,N){
        for(int i=now;i<K;i+=now){
            A[i]=1;
        }
        while(A[now]==1) now++;
    }
    cout<<now<<endl;
    return 0;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
     while(!solve());
}
accuracy: 1
time_ms: 4960
memory_kb: 61812
final_rank: 18

code_snippet: # include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double pi = acos(-1);
template<class T>constexpr T inf() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T hinf() { return inf<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); }
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); }
template<class T> bool chmin(T& a,T b) { if(a > b){a = b; return true;} return false; }
template<class T> bool chmax(T& a,T b) { if(a < b){a = b; return true;} return false; }
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(ll n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(ll n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
ll gcd(ll a, ll b) { if (b == 0)return a; return gcd(b, a%b); };
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g*b; };
ll MOD(ll x, ll m){return (x%m+m)%m; }
ll FLOOR(ll x, ll m) {ll r = (x%m+m)%m; return (x-r)/m; }
template<class T> using dijk = priority_queue<T, vector<T>, greater<T>>;
# define all(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(all((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(all((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(all((rprpr)),(rprpr).begin(),TU<char>)
# define rep(i,upupu)         for(ll i = 0, i##_len = (upupu);(i) < (i##_len);(i)++)
# define reps(i,opopo)        for(ll i = 1, i##_len = (opopo);(i) <= (i##_len);(i)++)
# define len(x)                ((ll)(x).size())
# define bit(n)               (1LL << (n))
# define pb push_back
# define eb emplace_back
# define exists(c, e)         ((c).find(e) != (c).end())

struct INIT{
	INIT(){
		std::ios::sync_with_stdio(false);
		std::cin.tie(0);
		cout << fixed << setprecision(20);
	}
}INIT;

namespace mmrz {
	void solve();
}

int main(){
	mmrz::solve();
}
#define debug(...) (static_cast<void>(0))

using namespace mmrz;

using ll = long long;


bool SOLVE(){
	ll M,N;cin>>M>>N;
	if(N==0&&M==0) return 0;
	ll K=7568791;
	vector<bool> vis(K+1);
	int fir = M;
	for(;N > 0;N--){
		while(vis[fir])fir++;
		for(int i = fir;i <= K;i += fir){
			vis[i] = true;
		}
	}
	while(vis[fir])fir++;
	cout << fir << '\n';
	
	return 1;

}

void mmrz::solve(){
	while(SOLVE());
}
accuracy: 1
time_ms: 1070
memory_kb: 4448
final_rank: 6

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

using namespace std;
using ll = long long;

constexpr bool DEBUG = false;
constexpr ll INF     = 2e18;

constexpr int MAX_SIZ = 7368791;

int solve(int N, int M) {
    int cnt = 0;
    vector<bool> ok(MAX_SIZ + 1, false);
    for (int y = M; y <= MAX_SIZ; y++) {
        if (ok[y]) {
            continue;
        }

        // すでにN区画に花を植えているなら、その年が答え
        if (cnt >= N) {
            return y;
        }

        // y年竹を植える
        cnt++;
        for (int ny = y; ny <= MAX_SIZ; ny += y) {
            ok[ny] = true;
        }
    }
    return -1;
}

int main() {
    while (true) {
        int M, N;
        cin >> M >> N;
        if (N == 0) {
            break;
        }
        cout << solve(N, M) << endl;
    }
}
accuracy: 1
time_ms: 1030
memory_kb: 4428
final_rank: 4

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

int main(){
    int m,n;
    while(true){
        cin>>m>>n;
        if(m==0&&n==0)break;
        int sz=7700000;
        
        vector<bool> check(sz,false);
        
        int cnt=0;
        
        for(int i=m;i<sz;i++){
            if(!check[i]){
                for(int j=i;j<sz;j+=i){
                    check[j]=true;
                }
                cnt++;
            }
            if(cnt==n)break;
        }
        for(int i=m;i<sz;i++){
            if(!check[i]){
                cout<<i<<"\n";
                break;
            }
        }
        
        
    }
}
accuracy: 1
time_ms: 940
memory_kb: 4308
final_rank: 3

code_snippet: #include <iostream>
#include <string.h>
using namespace std;

int memo[20000000];
const int max1=8000000;
void f(int m,int n){
	memset(memo,0,sizeof(memo));
	int ans=m+1;
	for(int i=m;i<max1;i++){
		if(memo[i]==0){
			if(n==0){
				ans=i;
				break;
			}else{
				n--;
				for(int j=i*2;j<max1;j+=i){
					memo[j]=1;
				}
			}
		}
	}
	cout<<ans<<endl;
}

int main() {
	int m,n;
	while(true){
		cin>>m>>n;
		if(m+n==0)break;
		f(m,n);
	}
	
	return 0;
}
accuracy: 1
time_ms: 4260
memory_kb: 81480
final_rank: 19

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

const int MAX = 7500000;
vector<int> seen(MAX,-1);
int t = 0;

int solve(){
	int M; cin >> M;
	int N; cin >> N;
	if(M == 0){
		return 0;
	}
	int cnt = 0;
	int now = M;
	while(cnt < N){
		if(seen[now] == t){
			now++;
			continue;
		}
		for(int i = now; i < MAX; i += now){
			seen[i] = t;
		}
		cnt++;
		now++;
	}
	while(seen[now] == t)now++;
	cout << now << endl;
	t++;
	return 1;
}

int main(){
	while(1){
		if(!solve())break;
	}
}
accuracy: 1
time_ms: 4860
memory_kb: 32700
final_rank: 16