inlineintrd(){ int x = 0; bool f = 0; char c = getchar(); for (; !isdigit(c); c = getchar()) f |= (c == '-'); for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48); return f ? -x : x; }
vector<int> a;
intmain(){ int n = (rd() << 1); for (int i = 1; i <= n; ++i) a.push_back(rd()); sort(a.begin(), a.end()); int ans = 0; for (int i = 0; i < n; i += 2) ans += a[i]; printf("%d\n", ans); return0; }
inline ll rd(){ ll x = 0; bool f = 0; char c = getchar(); for (; !isdigit(c); c = getchar()) f |= (c == '-'); for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48); return f ? -x : x; }
inline ll f(ll a, ll b){ return b ? 2 * (a / b) * b + f(b, a % b) : -a; }
intmain(){ ll n = rd(), x = rd(); printf("%lld\n", n + f(x, n - x)); return0; }
inlineintrd(){ int x = 0; bool f = 0; char c = getchar(); for (; !isdigit(c); c = getchar()) f |= (c == '-'); for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48); return f ? -x : x; }
#define N 2007 #define fr first #define sc second #define mp make_pair #define pb push_back #define pii pair<int, int>
vector<pii> r; vector<int> e[N];
int dep[N];
voiddfs(int u){ for (auto v : e[u]) if (dep[v] < 0) {dep[v] = dep[u] + 1; dfs(v);} }
intmain(){ int n = rd(), k = rd(); for (int i = 1, u, v; i < n; ++i) { u = rd(); v = rd(); e[u].pb(v); e[v].pb(u); if (k & 1) r.pb(mp(u, v)); } int ans = 0; if (k & 1) { for (auto [u, v] : r) { memset(dep, -1, sizeof(dep)); dep[u] = 0; dep[v] = 0; dfs(u); dfs(v); int tmpans = 0; for (int j = 1; j <= n; ++j) tmpans += (dep[j] <= k / 2); ans = max(ans, tmpans); } } else { for (int i = 1; i <= n; ++i) { memset(dep, -1, sizeof(dep)); dep[i] = 0; dfs(i); int tmpans = 0; for (int j = 1; j <= n; ++j) tmpans += (dep[j] <= k / 2); ans = max(ans, tmpans); } } printf("%d\n", n - ans); return0; }
inlineintrd(){ int x = 0; bool f = 0; char c = getchar(); for (; !isdigit(c); c = getchar()) f |= (c == '-'); for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48); return f ? -x : x; }
inlineintrd(){ int x = 0; bool f = 0; char c = getchar(); for (; !isdigit(c); c = getchar()) f |= (c == '-'); for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48); return f ? -x : x; }
#define A 4007 #define G 2001 #define M 8007 #define N 200007 #define mod 1000000007 #define inv2 500000004
int f[A][A], fac[M], ifac[M], x[N], y[N];
inlineintfpow(int x, int t = mod - 2){ int res = 1; for (; t; t >>= 1, x = 1ll * x * x % mod) if (t & 1) res = 1ll * res * x % mod; return res; }
inlineintmo(int x){ for (; x < 0; x += mod); for (; x >= mod; x -= mod); return x; }
inlineintC(int n, int m){ if (n < m) return0; return1ll * fac[n] * ifac[m] % mod * ifac[n - m] % mod; }
intmain(){
fac[0] = ifac[0] = 1; for (int i = 1; i < M; ++i) fac[i] = 1ll * fac[i - 1] * i % mod; ifac[M - 1] = fpow(fac[M - 1]); for (int i = M - 2; i; --i) ifac[i] = 1ll * ifac[i + 1] * (i + 1) % mod;
int n = rd(); for (int i = 1; i <= n; ++i) { x[i] = rd(); y[i] = rd(); ++f[-x[i] + G][-y[i] + G]; } for (int i = 1; i < A; ++i) for (int j = 1; j < A; ++j) f[i][j] = mo(f[i][j] + f[i - 1][j] + f[i][j - 1]); int ans = 0; for (int i = 1; i <= n; ++i) ans = mo(ans + f[x[i] + G][y[i] + G] - C(2 * (x[i] + y[i]), 2 * x[i])); printf("%lld\n", 1ll * ans * inv2 % mod); return0; }
inlineintrd(){ int x = 0; bool f = 0; char c = getchar(); for (; !isdigit(c); c = getchar()) f |= (c == '-'); for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48); return f ? -x : x; }
#define N 500007 #define ls (rt << 1) #define rs (rt << 1 | 1) #define mid ((l + r) >> 1)
voidupd(int rt, int l, int r, int k, int v){ if (l == r) { mn[rt] = v; return; } if (k <= mid) upd(ls, l, mid, k, v); else upd(rs, mid + 1, r, k, v); pushup(rt); }
intqmn(int rt, int l, int r, int L, int R){ if (L <= l && r <= R) return mn[rt]; int ans = 1e9; if (L <= mid) ans = min(ans, qmn(ls, l, mid, L, R)); if (R > mid) ans = min(ans, qmn(rs, mid + 1, r, L, R)); return ans; }
intmain(){ int n = rd(), k = rd(); memset(mn, 0x3f, sizeof(mn)); for (int i = 1; i <= n; ++i) q[p[i] = rd()] = i; for (int i = n; i; --i) { int j = qmn(1, 1, n, q[i], min(n, q[i] + k - 1)); if (j <= n) {e[q[i]].pb(q[j]); ++deg[q[j]];} j = qmn(1, 1, n, max(1, q[i] - k + 1), q[i]); if (j <= n) {e[q[i]].pb(q[j]); ++deg[q[j]];} upd(1, 1, n, q[i], i); } for (int i = 1; i <= n; ++i) if (!deg[i]) que.push(i); for (int i = 1; i <= n; ++i) { int u = q[i] = que.top(); que.pop(); for (auto v : e[u]) if (!(--deg[v])) que.push(v); } for (int i = 1; i <= n; ++i) p[q[i]] = i; for (int i = 1; i <= n; ++i) printf("%d\n", p[i]); return0; }