This documentation is automatically generated by online-judge-tools/verification-helper
#define PROBLEM "https://judge.yosupo.jp/problem/aplusb"
#include "../../../src/template/template.hpp"
#include "../../../src/random/random_number_generator.hpp"
#include "../../../src/graph/graph_template.hpp"
#include "../../../src/graph/bfs01.hpp"
#include "../../../src/graph/dijkstra.hpp"
void undirected() {
int n = rng(1, 200000), m = rng(1, (int)min(200000ll, 1ll * n * (n - 1) / 2));
auto [u, v, w] = rng.weighted_graph(n, m, 0, 1, false);
int weight = rng(1, 1000);
Graph<int> g(n);
rep(i, 0, m) {
g.add_edge(u[i], v[i], weight * w[i]);
}
vector<pair<int, int>> ans = dijkstra(g, 0), res = bfs01(g, 0);
rep(i, 0, n) {
assert(ans[i].first == res[i].first);
}
}
void directed() {
int n = rng(1, 200000), m = rng(1, (int)min(200000ll, 1ll * n * (n - 1) / 2));
auto [u, v, w] = rng.weighted_graph(n, m, 0, 1, false);
int weight = rng(1, 1000);
Graph<int> g(n);
rep(i, 0, m) {
g.add_directed_edge(u[i], v[i], weight * w[i]);
}
vector<pair<int, int>> ans = dijkstra(g, 0), res = bfs01(g, 0);
rep(i, 0, n) {
assert(ans[i].first == res[i].first);
}
}
int main(void) {
int test_num = 50;
rep(i, 0, test_num) {
undirected();
}
rep(i, 0, test_num) {
directed();
}
int a, b;
cin >> a >> b;
cout << a + b << '\n';
}
#line 1 "verify/unit_test/graph/bfs01.test.cpp"
#define PROBLEM "https://judge.yosupo.jp/problem/aplusb"
#line 2 "src/template/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<long long, long long>;
#define rep(i, a, b) for(long long i = (a); i < (b); ++i)
#define rrep(i, a, b) for(long long i = (a); i >= (b); --i)
constexpr long long inf = 4e18;
struct SetupIO {
SetupIO() {
ios::sync_with_stdio(0);
cin.tie(0);
cout << fixed << setprecision(30);
}
} setup_io;
#line 3 "src/random/random_number_generator.hpp"
struct RandomNumberGenerator {
RandomNumberGenerator()
: mt(chrono::steady_clock::now().time_since_epoch().count()) {}
template <typename T>
inline T operator()(const T lower, const T upper) {
static_assert(is_integral_v<T> or is_floating_point_v<T>);
assert(lower <= upper);
if constexpr(is_integral_v<T>) {
uniform_int_distribution<T> dist(lower, upper);
return dist(mt);
} else if constexpr(is_floating_point_v<T>) {
uniform_real_distribution<T> dist(lower, upper);
return dist(mt);
}
}
template <typename T>
inline vector<T> vec(const int n, const T lower, const T upper, const bool dup = true) {
static_assert(is_integral_v<T> or is_floating_point_v<T>);
assert(0 <= n and n <= (int)1e8);
assert(lower <= upper);
if(n == 0) return {};
vector<T> res(n);
if(dup or is_floating_point_v<T>) {
for(int i = 0; i < n; ++i) res[i] = this->operator()(lower, upper);
} else {
assert(upper - lower + 1 >= n);
if(upper - lower + 1 >= 2 * n) {
set<T> used;
while((int)used.size() < n) {
const T a = this->operator()(lower, upper);
used.insert(a);
}
int i = 0;
for(const T a : used) {
res[i] = a;
++i;
}
} else {
const vector<int> p = perm(upper - lower + 1, false);
for(int i = 0; i < n; ++i) {
res[i] = p[i] + lower;
}
}
}
return res;
}
inline vector<int> perm(const int n, const bool one = true) {
assert(0 <= n and n <= (int)1e8);
vector<int> res(n);
for(int i = 0; i < n; ++i) res[i] = i + one;
for(int i = n - 1; i > 0; --i) {
swap(res[i], res[this->operator()(0, i)]);
}
return res;
}
inline pair<vector<int>, vector<int>> tree(const int n, const bool one = true) {
assert(0 <= n and n <= (int)1e8);
if(n <= 1) return {{}, {}};
if(n == 2) return {{0 + one}, {1 + one}};
vector<int> u(n - 1), v(n - 1);
const vector<int> pruefer = vec(n - 2, 0, n - 1);
set<int> st;
vector<int> cnt(n);
for(int i = 0; i < n; ++i) st.insert(i);
auto add = [&](const int x) -> void {
if(x > n) return;
if(cnt[x] == 0) st.erase(x);
++cnt[x];
};
auto del = [&](const int x) -> void {
if(x > n) return;
--cnt[x];
if(cnt[x] == 0) st.insert(x);
};
for(int i = 0; i < n - 2; ++i) add(pruefer[i]);
for(int i = 0; i < n - 2; ++i) {
const int a = *st.begin();
const int b = pruefer[i];
u[i] = a + one;
v[i] = b + one;
del(b);
add(a);
}
const int a = *st.begin();
add(a);
const int b = *st.begin();
u[n - 2] = a + one;
v[n - 2] = b + one;
return {u, v};
}
template <typename T>
inline tuple<vector<int>, vector<int>, vector<T>> weighted_tree(const int n, const T lower, const T upper, const bool one = true) {
static_assert(is_integral_v<T> or is_floating_point_v<T>);
assert(0 <= n and n <= (int)1e8);
assert(lower <= upper);
if(n == 0) return {{}, {}, {}};
const auto [u, v] = tree(n, one);
const vector<T> w = vec(n - 1, lower, upper, true);
return {u, v, w};
}
inline pair<vector<int>, vector<int>> graph(const int n, const int m, const bool one = true) {
assert(0 <= n and n <= (int)1e8);
assert(0 <= m and m <= (int)min((ll)1e8, 1ll * n * (n - 1) / 2));
vector<int> u, v;
u.reserve(m);
v.reserve(m);
if(1ll * n * (n - 1) / 2 >= 2e6) {
set<pair<int, int>> edge;
while((int)edge.size() < m) {
const int a = this->operator()(0, n - 1);
const int b = this->operator()(0, n - 1);
if(a >= b) continue;
edge.insert({a, b});
}
for(const auto& [a, b] : edge) {
u.push_back(a + one);
v.push_back(b + one);
}
} else {
vector<pair<int, int>> edge;
edge.reserve(n * (n - 1) / 2);
for(int i = 0; i < n; ++i) {
for(int j = i + 1; j < n; ++j) {
edge.push_back({i, j});
}
}
const vector<int> p = perm(n * (n - 1) / 2, false);
for(int i = 0; i < m; ++i) {
u.push_back(edge[p[i]].first + one);
v.push_back(edge[p[i]].second + one);
}
}
return {u, v};
}
template <typename T>
inline tuple<vector<int>, vector<int>, vector<T>> weighted_graph(const int n, const int m, const T lower, const T upper, const bool one = true) {
static_assert(is_integral_v<T> or is_floating_point_v<T>);
assert(0 <= n and n <= (int)1e8);
assert(0 <= m and m <= (int)min((ll)1e8, 1ll * n * (n - 1) / 2));
assert(lower <= upper);
const auto [u, v] = graph(n, m, one);
const vector<T> w = vec(m, lower, upper, true);
return {u, v, w};
}
inline pair<vector<int>, vector<int>> connected_graph(const int n, const int m, const bool one = true) {
assert(0 <= n and n <= (int)1e8);
assert(max(n - 1, 0) <= m and m <= (int)min((ll)1e8, 1ll * n * (n - 1) / 2));
if(n <= 1) return {{}, {}};
vector<int> u, v;
u.reserve(m);
v.reserve(m);
auto [ut, vt] = tree(n, false);
if(1ll * n * (n - 1) / 2 >= 2e6) {
set<pair<int, int>> edge;
for(int i = 0; i < n - 1; ++i) {
edge.insert({min(ut[i], vt[i]), max(ut[i], vt[i])});
}
while((int)edge.size() < m) {
const int a = this->operator()(0, n - 1);
const int b = this->operator()(0, n - 1);
if(a >= b) continue;
edge.insert({a, b});
}
for(const auto& [a, b] : edge) {
u.push_back(a + one);
v.push_back(b + one);
}
} else {
set<pair<int, int>> used;
for(int i = 0; i < n - 1; ++i) {
u.push_back(ut[i] + one);
v.push_back(vt[i] + one);
used.insert({min(ut[i], vt[i]), max(ut[i], vt[i])});
}
vector<pair<int, int>> edge;
edge.reserve(n * (n - 1) / 2 - (n - 1));
for(int i = 0; i < n; ++i) {
for(int j = i + 1; j < n; ++j) {
if(used.find({i, j}) == used.end()) edge.push_back({i, j});
}
}
const vector<int> p = perm(n * (n - 1) / 2 - (n - 1), false);
for(int i = 0; i < m - (n - 1); ++i) {
u.push_back(edge[p[i]].first + one);
v.push_back(edge[p[i]].second + one);
}
}
return {u, v};
}
template <typename T>
inline tuple<vector<int>, vector<int>, vector<T>> weighted_connected_graph(const int n, const int m, const T lower, const T upper, const bool one = true) {
static_assert(is_integral_v<T> or is_floating_point_v<T>);
assert(0 <= n and n <= (int)1e8);
assert(max(n - 1, 0) <= m and m <= (int)min((ll)1e8, 1ll * n * (n - 1) / 2));
assert(lower <= upper);
const auto [u, v] = connected_graph(n, m, one);
const vector<T> w = vec(m, lower, upper, true);
return {u, v, w};
}
inline string parenthesis(const int n) {
assert(0 <= n and n <= 1e8);
string res = "";
int N = n, M = n;
for(int i = 0; i < 2 * n; ++i) {
if(this->operator()(0.0l, 1.0l) > 1.0l * (N - M) * (N + 1) / ((N - M + 1) * (N + M))) {
res += "(";
--M;
} else {
res += ")";
--N;
}
}
return res;
}
private:
mt19937_64 mt;
} rng;
#line 3 "src/graph/graph_template.hpp"
template <typename T>
struct Edge {
int from, to;
T cost;
int idx;
Edge()
: from(-1), to(-1), cost(-1), idx(-1) {}
Edge(const int from, const int to, const T& cost = 1, const int idx = -1)
: from(from), to(to), cost(cost), idx(idx) {}
operator int() const {
return to;
}
};
template <typename T>
struct Graph {
Graph(const int N)
: n(N), es(0), g(N) {}
int size() const {
return n;
}
int edge_size() const {
return es;
}
void add_edge(const int from, const int to, const T& cost = 1) {
assert(0 <= from and from < n);
assert(0 <= to and to < n);
g[from].emplace_back(from, to, cost, es);
g[to].emplace_back(to, from, cost, es++);
}
void add_directed_edge(const int from, const int to, const T& cost = 1) {
assert(0 <= from and from < n);
assert(0 <= to and to < n);
g[from].emplace_back(from, to, cost, es++);
}
inline vector<Edge<T>>& operator[](const int& k) {
assert(0 <= k and k < n);
return g[k];
}
inline const vector<Edge<T>>& operator[](const int& k) const {
assert(0 <= k and k < n);
return g[k];
}
private:
int n, es;
vector<vector<Edge<T>>> g;
};
template <typename T>
using Edges = vector<Edge<T>>;
#line 4 "src/graph/bfs01.hpp"
template <typename T>
vector<pair<T, int>> bfs01(const Graph<T>& g, const int s = 0) {
const int n = g.size();
assert(0 <= s and s < n);
vector<pair<T, int>> d(n, {numeric_limits<T>::max(), -1});
vector<int> visited(n);
deque<int> deq;
d[s] = {0, -1};
deq.emplace_back(s);
while(!deq.empty()) {
const int cur = deq.front();
deq.pop_front();
if(visited[cur]) continue;
visited[cur] = 1;
for(const Edge<T>& e : g[cur]) {
if(d[e.to].first != numeric_limits<T>::max() and d[e.to].first <= d[cur].first + e.cost) continue;
d[e.to] = {d[cur].first + e.cost, cur};
if(e.cost == 0) {
deq.emplace_front(e.to);
} else {
deq.emplace_back(e.to);
}
}
}
return d;
}
#line 4 "src/graph/dijkstra.hpp"
template <typename T>
vector<pair<T, int>> dijkstra(const Graph<T>& g, const int s = 0) {
const int n = g.size();
assert(0 <= s and s < n);
vector<pair<T, int>> d(n, {numeric_limits<T>::max(), -1});
priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> pq;
d[s] = {0, -1};
pq.emplace(0, s);
while(!pq.empty()) {
const auto [dist, cur] = pq.top();
pq.pop();
if(d[cur].first < dist) continue;
for(const Edge<T>& e : g[cur]) {
if(d[e.to].first > d[cur].first + e.cost) {
d[e.to] = {d[cur].first + e.cost, cur};
pq.emplace(d[e.to].first, e.to);
}
}
}
return d;
}
#line 7 "verify/unit_test/graph/bfs01.test.cpp"
void undirected() {
int n = rng(1, 200000), m = rng(1, (int)min(200000ll, 1ll * n * (n - 1) / 2));
auto [u, v, w] = rng.weighted_graph(n, m, 0, 1, false);
int weight = rng(1, 1000);
Graph<int> g(n);
rep(i, 0, m) {
g.add_edge(u[i], v[i], weight * w[i]);
}
vector<pair<int, int>> ans = dijkstra(g, 0), res = bfs01(g, 0);
rep(i, 0, n) {
assert(ans[i].first == res[i].first);
}
}
void directed() {
int n = rng(1, 200000), m = rng(1, (int)min(200000ll, 1ll * n * (n - 1) / 2));
auto [u, v, w] = rng.weighted_graph(n, m, 0, 1, false);
int weight = rng(1, 1000);
Graph<int> g(n);
rep(i, 0, m) {
g.add_directed_edge(u[i], v[i], weight * w[i]);
}
vector<pair<int, int>> ans = dijkstra(g, 0), res = bfs01(g, 0);
rep(i, 0, n) {
assert(ans[i].first == res[i].first);
}
}
int main(void) {
int test_num = 50;
rep(i, 0, test_num) {
undirected();
}
rep(i, 0, test_num) {
directed();
}
int a, b;
cin >> a >> b;
cout << a + b << '\n';
}