//* #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") //*/ #include // #include using namespace std; // using namespace atcoder; #define DEBUG(x) cerr<<#x<<": "< #define vl vector #define vii vector< vector > #define vll vector< vector > #define vs vector #define pii pair #define pis pair #define psi pair #define pll pair template pair operator+(const pair &s, const pair &t) { return pair(s.first + t.first, s.second + t.second); } template pair operator-(const pair &s, const pair &t) { return pair(s.first - t.first, s.second - t.second); } template ostream& operator<<(ostream& os, pair p) { os << "(" << p.first << ", " << p.second << ")"; return os; } #define X first #define Y second #define rep(i,n) for(int i=0;i<(int)(n);i++) #define rep1(i,n) for(int i=1;i<=(int)(n);i++) #define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--) #define rrep1(i,n) for(int i=(int)(n);i>0;i--) #define REP(i,a,b) for(int i=a;i bool chmax(T &a, const T &b) { if (a bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; } #define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end()); const ll inf = 1000000001; const ll INF = (ll)1e18 + 1; const long double pi = 3.1415926535897932384626433832795028841971L; #define Sp(p) cout<operator()(0, x); } // [x, y)の一様乱数 ll operator()(ll x, ll y) { uniform_int_distribution dist(x, y - 1); return dist(mt); } vl operator()(int n, ll x, ll y) { vl res(n); for (int i = 0; i < n; i++) res[i] = this->operator()(x, y); return res; } } rnd; const int n = 150; const int m = 1500; vii a(n, vi(n)); vector yx; int calc(int y, int x) { int res = 0; rep (i, yx.size()) { int y2 = yx[i].first, x2 = yx[i].second; if (y == y2 or x == x2) continue; if (a[y][x2] and a[y2][x]) res++; } return res; } signed main() { ll p, q; cin >> p >> q; cout << min(p, q) << endl; return 0; int cnt = 0; int mm = 11; rep (i, mm) { rep (j, mm) { int type = i * j % mm; int ni = i * mm, nj = j * mm; for (int k = 0; k < mm; k++) { a[ni + k][(nj + type + k) % mm + nj] = 1; yx.push_back(pii(ni + k, (nj + type + k) % mm + nj)); cnt++; if (cnt == m) break; } if (cnt == m) break; } if (cnt == m) break; } rep (i, n) { rep (j, n) { if (a[i][j] == 1) continue; a[i][j] = 1; yx.push_back(pii(i, j)); cnt++; if (cnt == m) break; } if (cnt == m) break; } sort(all(yx)); int out = 0; rep (i, yx.size()) { REP (j, i + 1, yx.size()) { if (yx[i].first < yx[j].first and yx[i].second < yx[j].second) { if (a[yx[i].first][yx[j].second] and a[yx[j].first][yx[i].second]) { // DEBUG(pii(a[yx[i].first][yx[j].second], a[yx[j].first][yx[i].second])); out++; } } } } int try_num = 0; while (out > 0) { if (try_num % 10000 == 0) DEBUG(out); int idx = rnd(yx.size()); int y = yx[idx].first, x = yx[idx].second; // int yb = y / mm, xb = x / mm; // int y2 = rnd(mm), x2 = rnd(mm); // y2 += yb * mm; x2 += xb * mm; int y2 = rnd(n), x2 = rnd(n); if (a[y2][x2] == 1) continue; assert(a[y][x] == 1); int now = calc(y, x); yx[idx] = pii(y2, x2); a[y2][x2] = 1; a[y][x] = 0; int nex = calc(y2, x2); if (nex <= now) { out = out - now + nex; } else { yx[idx] = pii(y, x); a[y2][x2] = 0; a[y][x] = 1; } try_num++; } cout << n << endl; int ans = 0; rep (i, n) { rep (j, n) { if (a[i][j] == 0) cout << '.'; else { cout << 'O'; ans++; } // cout << a[i][j]; } cout << endl; } rep (i0, n) { REP (i1, i0 + 1, n) { rep (j0, n) { REP (j1, j0 + 1, n) { int cnt = 0; cnt += a[i0][j0]; cnt += a[i1][j0]; cnt += a[i0][j1]; cnt += a[i1][j1]; if (cnt == 4) { DEBUG(pii(i0, j0)); DEBUG(pii(i1, j1)); } assert(cnt < 4); } } } } DEBUG(ans); }