malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1000010;   long long N, S;   long long fa[maxn], q[maxn], d[maxn], head, tail, sz[maxn], son[maxn];   bool check(long long Mid) {     long long tN = N, now = 1, p = 1, res = 0;     while (tN) {       res += min(p, tN) * now;       if (res > S) return false;       tN -= min(p, tN);       p *= Mid;       now++;     }     return true;   }   int main() {     cin >> N >> S;     long long Mn = N + N - 1;     long long Mx = N * (N + 1) / 2;     if (S < Mn || S > Mx) return puts( NO ), 0;     long long L = 1, R = N - 1, Mid, res;     while (L <= R) {       Mid = (L + R) / 2;       if (check(Mid))         res = Mid, R = Mid - 1;       else         L = Mid + 1;     }     puts( YES );     for (int i = 1; i <= N; i++) sz[i] = 1;     long long Now = Mx, D = 2;     for (int i = N;; i--) {       if (Now == S) break;       if (sz[D] == sz[D - 1] * res) D++;       if (Now - S >= i - D) {         sz[D]++;         sz[i]--;         Now -= (i - D);       } else {         sz[i]--;         sz[i - (Now - S)]++;         Now = S;       }     }     head = tail = 1;     q[head] = 1;     d[1] = 1;     long long p = 1;     for (int i = 2; i <= N; i++) {       if (sz[i] == 0) break;       L = p + 1;       R = p + sz[i];       for (int j = L; j <= R; j++) {         while (d[q[head]] != i - 1 || son[q[head]] == res) {           head++;         }         fa[j] = q[head];         son[q[head]]++;         q[++tail] = j;         d[j] = i;       }       p = R;     }     for (int i = 2; i <= N; i++) printf( %lld  , fa[i]);   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1e9 + 7;   const int maxN = 2e6 + 5;   string s[maxN];   int type[maxN];   int n;   pair<int, int> rang[3];   int sum[maxN];   bool in_range(int x, int type) {     return x >= rang[type].first && x <= rang[type].second;   }   int conv(string s) {     if (s[0] ==  0 ) return inf;     int pow = 1;     int ans = 0;     for (int i = ((int)s.size() - 1); i >= (0); --i) {       if (s[i] <  0  || s[i] >  9 ) {         return inf;       }       ans += (s[i] -  0 ) * pow;       pow *= 10;     }     return ans;   }   vector<string> change[3];   vector<string> empty1, empty0, _0to1_;   bool used[maxN];   void print(vector<string> wek) {     for (auto w : wek) cout << w <<    ;     cout << endl;   }   int main() {     ios_base::sync_with_stdio(0);     cin >> n;     for (int i = (0); i <= ((n)-1); ++i) {       cin >> s[i] >> type[i];       sum[type[i]]++;     }     rang[1] = pair<int, int>(1, sum[1]);     rang[0] = pair<int, int>(sum[1] + 1, n);     for (int i = (0); i <= ((n)-1); ++i) {       int x = conv(s[i]);       bool b = (s[i][0] ==  0 );       if (x <= n && !b) {         if (!in_range(x, type[i])) {           if (type[i] == 0)             _0to1_.push_back(s[i]);           else             change[type[i]].push_back(s[i]);         }         used[x] = true;       } else {         change[type[i]].push_back(s[i]);       }     }     for (int i = (1); i <= (sum[1]); ++i) {       if (!used[i]) {         empty1.push_back(to_string(i));       }     }     for (int i = (sum[1] + 1); i <= (n); ++i) {       if (!used[i]) empty0.push_back(to_string(i));     }     for (int i = (0); i <= (1); ++i) {       vector<string> wek;       for (auto v : change[i])         if (conv(v) <= n) wek.push_back(v);       for (auto v : change[i])         if (conv(v) > n) wek.push_back(v);       change[i] = wek;     }     vector<string> result;     string tmp = to_string(n + 1);     string prev = tmp;     bool pom = false;     for (auto v : change[1]) {       if ((int)empty1.size() != 0) {         result.push_back( move   + v +     + empty1.back());         empty1.pop_back();         int x = conv(v);         if (x <= n && in_range(x, 0)) {           empty0.push_back(v);         }       } else {         if ((int)empty0.size() != 0) {           result.push_back( move   + _0to1_.back() +     + empty0.back());           empty0.pop_back();           result.push_back( move   + v +     + _0to1_.back());           _0to1_.pop_back();           int x = conv(v);           if (x <= n && in_range(x, 0)) {             empty0.push_back(v);           }         } else {           result.push_back( move   + v +     + prev);           result.push_back( move   + _0to1_.back() +     + v);           prev = _0to1_.back();           _0to1_.pop_back();           pom = true;         }       }     }     if (pom) {       result.push_back( move   + tmp +     + prev);     }     for (auto v : change[0]) {       result.push_back( move   + v +     + empty0.back());       empty0.pop_back();     }     cout << (int)result.size() << endl;     for (auto v : result) cout << v << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char a[1000005];   char c[1000005];   bool H(char a[], char c[], int i, int x) {     int d = 0;     for (int q = 0; q < i; q += x) {       int s = 0;       for (int o = 0; o < x; o++) {         if (a[o + q] > c[o])           return 1;         else if (a[o + q] == c[o])           s++;         else if (a[o + q] < c[o])           break;       }       if (s == x) d++;     }     if (d == i / x) return 1;     return 0;   }   int main() {     int x, i = 0;     cin >> x;     while (cin >> a[i]) {       i++;     }     bool K = 0;     for (int j; j < i; j++) {       if (a[j] !=  9 ) {         K = 1;         break;       }     }     if (i % x == 0 && K) {       bool A;       for (int j = 0; j < x; j++) {         c[j] = a[j];       }       A = H(a, c, i, x);       if (A) {         for (int j = x - 1; j >= 0; j--) {           if (c[j] ==  9 )             c[j] =  0 ;           else {             c[j] += 1;             break;           }         }       }       for (int j = 0; j < i / x; j++) {         for (int v = 0; v < x; v++) cout << c[v];       }     } else {       if (!K) i++;       while (i % x != 0) {         i++;       }       for (int j = 0; j < i / x; j++) {         cout <<  1 ;         for (int p = 0; p < x - 1; p++) {           cout <<  0 ;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s[5005];   int main() {     int i, j, k;     scanf( %s , s);     int len, n, m;     len = strlen(s);     int Q, D, ans;     ans = 0;     for (i = 0; i < len; i++) {       Q = 0;       D = 0;       for (j = i; j < len; j++) {         Q += s[j] ==  ( ;         Q -= s[j] ==  ) ;         D += s[j] ==  ? ;         if (Q == D) ans++;         if (D > Q) swap(Q, D);         if (Q + D < 0) break;       }     }     printf( %d , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e5 + 5;   vector<int> g[2 * N];   vector<pair<int, int> > mark[N];   int n, m;   long long val[N];   struct Bit {     long long c[N];     int lowbit(int x) { return x & -x; }     long long Sum(int x) {       long long res = 0;       while (x > 0) {         res += c[x];         x -= lowbit(x);       }       return res;     }     void Add(int x, int d) {       while (x <= n) {         c[x] += d;         x += lowbit(x);       }     }   } b;   void dfs(int u, int fa, int dep) {     for (auto it : mark[u]) {       b.Add(max(n - dep - it.first, 1), it.second);     }     val[u] = b.Sum(max(n - dep, 1));     for (auto v : g[u]) {       if (v == fa) continue;       dfs(v, u, dep + 1);     }     for (auto it : mark[u]) {       b.Add(max(n - dep - it.first, 1), -it.second);     }   }   int main() {     scanf( %d , &n);     for (int i = 1; i < n; i++) {       int x, y;       scanf( %d %d , &x, &y);       g[x].push_back(y);       g[y].push_back(x);     }     scanf( %d , &m);     for (int i = 1; i <= m; i++) {       int u, d, x;       scanf( %d %d %d , &u, &d, &x);       mark[u].push_back({d, x});     }     dfs(1, 0, 0);     for (int i = 1; i <= n; i++) {       printf( %lld  , val[i]);     }   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   using namespace std;   template <class T1, class T2>   inline void remin(T1& a, T2 b) {     a = min(a, (T1)b);   }   const int maxN = 1 << 18, maxTS = maxN * 2, INF = 1 << 30;   vector<int> G[maxN];   int A[maxN], pat[maxN], whole[maxN], ile[maxN], sz[maxN], res, bord;   void dfs0(int v, int fat) {     sz[v] = 1;     ile[v] = A[v] >= bord;     for (int u : G[v])       if (u != fat) {         dfs0(u, v);         sz[v] += sz[u];         ile[v] += ile[u];       }   }   void dfs(int v, int fat) {     int t[2] = {0, 0};     whole[v] = pat[v] = 1;     for (int u : G[v])       if (u != fat) {         dfs(u, v);         if (whole[u] != 0) {           if (whole[v] != 0) whole[v] += whole[u];           pat[v] += whole[u];           continue;         }         whole[v] = 0;         if (pat[u] >= t[0])           t[1] = t[0], t[0] = pat[u];         else if (pat[u] > t[1])           t[1] = pat[u];       }     if (A[v] >= bord) {       pat[v] += t[0];       int prop = pat[v] + t[1];       if (sz[1] - sz[v] == ile[1] - ile[v]) prop += sz[1] - sz[v];       res = max(res, prop);     } else       pat[v] = whole[v] = 0;   }   void solve() {     int n, k;     scanf( %d%d , &n, &k);     for (int i = (1); i < (n + 1); i++) scanf( %d , A + i);     for (int i = (1); i < (n); i++) {       int a, b;       scanf( %d%d , &a, &b);       G[a].push_back(b);       G[b].push_back(a);     }     int a = 1, b = INF;     while (b - a > 1) {       bord = (a + b) / 2;       res = 0;       dfs0(1, 0);       dfs(1, 0);       res >= k ? a = bord : b = bord;     }     printf( %d n , a);   }   int main() {     int t = 1;     for (int tid = (1); tid < (t + 1); tid++) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k;   vector<bool> is_important;   vector<vector<int> > graph;   vector<int> used;   vector<int> res;   bool dfs(int v) {     used[v] = 1;     bool f_p = is_important[v];     for (int u : graph[v]) {       if (used[u] == 0) {         f_p = dfs(u) || f_p;       } else if (used[u] == 1) {         cout << -1 << endl;         exit(0);       }     }     used[v] = 2;     res.push_back(v);     return f_p;   }   int main() {     cin >> n >> k;     is_important.assign(n, false);     used.assign(n, 0);     graph.resize(n);     for (int i = 0; i < k; i++) {       int x;       cin >> x;       is_important[x - 1] = true;     }     for (int i = 0; i < n; i++) {       int m;       cin >> m;       for (int j = 0; j < m; j++) {         int v;         cin >> v;         graph[i].push_back(v - 1);       }     }     for (int i = 0; i < n; i++) {       if (is_important[i] && used[i] == 0) dfs(i);     }     cout << res.size() << endl;     for (int i = 0; i < res.size(); i++) {       cout << res[i] + 1 <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }   int lcm(int a, int b) { return a * (b / gcd(a, b)); }   const int maxSize = 100000 + 5;   int main() {     int n, k;     cin >> n >> k;     vector<long long int> arr(n);     for (int i = 0; i < n; i++) {       cin >> arr[i];     }     vector<long long int> pwr;     long long int limit = 1e14;     long long int ans = 1;     pwr.push_back(1);     if (abs(k) > 1) {       while (ans * k <= limit) {         ans *= k;         pwr.push_back(ans);       }     } else if (k == -1) {       pwr.push_back(-1);     }     map<long long int, long long int> make_pair;     long long int sum = 0;     ans = 0;     for (int i = 0; i < n; i++) {       make_pair[sum]++;       sum += arr[i];       for (auto pw : pwr) {         if (make_pair.count(sum - pw) > 0) {           ans += make_pair[sum - pw];         }       }     }     cout << ans;   }
#include <bits/stdc++.h>   const int mod = 1000000007;   const int inf = 1000000009;   const long long int INF = 1000000000000000009;   const long long big = 1000000000000000;   const long double eps = 0.0000000001;   using namespace std;   queue<int> K;   vector<int> H;   vector<int> P[100005];   int S[100005], G[100005];   int k;   bool czy = true, jak = false, korzen = false;   map<int, int> M;   int L[100005];   int n;   void check(int u, int p) {     if (M[L[u]] && P[u].size() != M[L[u]]) jak = false;     M[L[u]] = P[u].size();     for (auto v : P[u])       if (v != p) {         L[v] = L[u] + 1;         check(v, u);       }   }   void czysc() {     for (int i = 1; i <= n; i++) {       L[i] = 0;       M[i] = 0;     }   }   void funkcja() {     while (K.size()) {       if (K.size() == 1) korzen = true;       while (K.size()) {         int u = K.front();         K.pop();         for (auto v : P[u]) {           if (!S[v]) {             S[v] = S[u];             H.push_back(v);           }           G[v]++;         }       }       int ile = -1, ile2 = -1, skad;       for (auto v : H) {         if (ile == -1) {           ile = G[v];           ile2 = P[v].size();           skad = v;         } else if (ile != G[v] || ile2 != P[v].size()) {           czy = false;           jak = true;           k = v;           check(S[v], 0);           czysc();           if (!jak) {             k = skad;             check(S[skad], 0);             czysc();           }           return;         }         K.push(v);         k = v;       }       H.clear();     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie();     cout.tie();     cin >> n;     if (n == 1) {       cout << 1;       return 0;     }     for (int i = 1; i < n; i++) {       int a, b;       cin >> a >> b;       P[a].push_back(b);       P[b].push_back(a);     }     for (int i = 1; i <= n; i++)       if (P[i].size() == 1) {         K.push(i);         S[i] = i;       }     funkcja();     if (!korzen) {       jak = true;       check(S[k], 0);       k = S[k];     }     jak = true;     check(k, 0);     if (jak)       cout << k;     else       cout << -1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename Arg1>   void debug_out(const char* name, Arg1&& arg1) {     cout << name <<   =   << arg1 <<   ]  <<   n ;   }   template <typename Arg1, typename... Args>   void debug_out(const char* names, Arg1&& arg1, Args&&... args) {     const char* comma = strchr(names + 1,  , );     cout.write(names, comma - names) <<   =   << arg1 <<  , ;     debug_out(comma + 1, args...);   }   mt19937_64 rang(       chrono::high_resolution_clock::now().time_since_epoch().count());   const long long mod = 1e9 + 7;   const long long N = 3e5, M = N;   void Solve_main() {     long long n, m, k;     cin >> n >> k >> m;     vector<long long> v(n), temp(n);     map<long long, long long> make_pair;     for (long long i = (0); i < (n); ++i) {       cin >> v[i];       temp[i] = v[i] % m;       make_pair[temp[i]]++;     }     long long mx = INT_MIN, modulo = -1;     for (auto it : make_pair) {       if (it.second > mx) {         modulo = it.first;         mx = it.second;       }     }     vector<long long> res;     for (long long i = (0); i < (n); ++i) {       if (temp[i] == modulo) {         res.emplace_back(v[i]);       }     }     if (((long long)(res).size()) < k) {       cout << ((0) ?  Yes  :  No ) <<   n ;       ;     } else {       cout << ((1) ?  Yes  :  No ) <<   n ;       ;       for (long long i = (0); i < (k); ++i) {         cout << res[i] <<    ;       }     }   }   int32_t main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     srand(chrono::high_resolution_clock::now().time_since_epoch().count());     long long tc = 1;     for (long long i = 0; i < tc; i++) {       Solve_main();     }     cerr <<  [time:  << 1.0 * clock() / CLOCKS_PER_SEC <<  s]  ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string itos(int x) {     stringstream ss;     ss << x;     return ss.str();   }   int n, m, d[300010], vis[300010];   pair<int, int> a[300010];   vector<int> e[300010], res;   int dfs(int now) {     if (vis[now]) return 0;     vis[now] = 1;     d[now] = (d[now] == 1);     for (auto x : e[now]) {       int y = (a[x].first == now ? a[x].second : a[x].first);       if (dfs(y)) {         res.push_back((x));         d[now] ^= 1;       }     }     return d[now] == 1;   }   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> m;     for (int i = 0; i < n; i++) cin >> d[i];     for (int i = 0, u, v; i < m;) {       cin >> u >> v;       a[++i] = make_pair((--u), (--v));       e[u].push_back((i)), e[v].push_back((i));     }     int cnt1, free;     cnt1 = count_if(d, d + 300010, [](int x) { return x == 1; }),     free = count_if(d, d + 300010, [](int x) { return x == -1; });     if (cnt1 % 2 && not free) {       cout << -1 << endl;       return 0;     }     if (cnt1 % 2) *find(d, d + 300010, -1) = 1;     dfs(0);     cout << res.size() << endl;     for (int i = 0; i < res.size(); i++)       cout << res[i] << (i + 1 == res.size() ?   n  :    );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 2000000000000000000LL;   const int inf = 0x3f3f3f3f;   const long double EPS = 1e-9;   string a, b;   inline void solve() {     vector<long long> mapa(26);     for (long long i = 0; i < a.size(); i++) {       mapa[a[i] -  a ]++;     }     for (int i = 0; i < b.size(); i++) {       vector<long long> mapb(26);       for (long long j = i; j < b.size(); j++) {         mapb[b[j] -  a ]++;         if (mapa == mapb) {           printf( YES n );           return;         }       }     }     printf( NO n );   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     int test, tc = 0;     cin >> test;     while (test--) {       cin >> a >> b;       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2e5 + 10;   vector<int> sol;   set<int> fac;   int main() {     ios_base::sync_with_stdio, cin.tie(0), cout.tie(0);     int n;     cin >> n;     while (n--) {       int a, b;       cin >> a >> b;       cout << a + b << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   void sll(long long &x) {     register char c = getchar();     x = 0;     int neg = 0;     for (; ((c < 48 || c > 57) && c !=  - ); c = getchar())       ;     if (c ==  - ) {       neg = 1;       c = getchar();     }     for (; c > 47 && c < 58; c = getchar()) {       x = (x << 1) + (x << 3) + c - 48;     }     if (neg) x = -x;   }   void wll(long long a) {     if (a < 0) {       putchar( - );       a = -a;     }     char snum[100];     int i = 0;     do {       snum[i++] = a % 10 + 48;       a = a / 10;     } while (a != 0);     --i;     while (i >= 0) putchar(snum[i--]);     putchar(  n );   }   void wi(int a) {     if (a < 0) {       putchar( - );       a = -a;     }     char snum[100];     int i = 0;     do {       snum[i++] = a % 10 + 48;       a = a / 10;     } while (a != 0);     --i;     while (i >= 0) putchar(snum[i--]);     putchar(  n );   }   void wl(long a) {     if (a < 0) {       putchar( - );       a = -a;     }     char snum[100];     int i = 0;     do {       snum[i++] = a % 10 + 48;       a = a / 10;     } while (a != 0);     --i;     while (i >= 0) putchar(snum[i--]);     putchar(  n );   }   void sl(long &x) {     register char c = getchar();     x = 0;     int neg = 0;     for (; ((c < 48 || c > 57) && c !=  - ); c = getchar())       ;     if (c ==  - ) {       neg = 1;       c = getchar();     }     for (; c > 47 && c < 58; c = getchar()) {       x = (x << 1) + (x << 3) + c - 48;     }     if (neg) x = -x;   }   void si(int &x) {     register char c = getchar();     x = 0;     int neg = 0;     for (; ((c < 48 || c > 57) && c !=  - ); c = getchar())       ;     if (c ==  - ) {       neg = 1;       c = getchar();     }     for (; c > 47 && c < 58; c = getchar()) {       x = (x << 1) + (x << 3) + c - 48;     }     if (neg) x = -x;   }   long long power(long long a, long long b, long long mod) {     long long ret = 1;     while (b) {       if (b & 1) ret = ret * a % mod;       a = a * a % mod;       b >>= 1;     }     return ret;   }   long long gcd(long long a, long long b) {     while (b) b ^= a ^= b ^= a %= b;     return a;   }   int main() {     long long t, i, j, k, l;     long long a, b, c, d;     sll(a);     sll(b);     sll(c);     sll(l);     t = (l + 1) * (l + 2) * (l + 3) / 6;     long long ans = 0;     for (i = 0; i <= l; i++) {       long long x = min(l - i, i + a - b - c);       if (x >= 0) {         x = ((x + 1) * (x + 2)) >> 1;         ans += x;       }       x = min(l - i, i + c - b - a);       if (x >= 0) {         x = ((x + 1) * (x + 2)) >> 1;         ans += x;       }       x = min(l - i, i + b - c - a);       if (x >= 0) {         x = ((x + 1) * (x + 2)) >> 1;         ans += x;       }     }     wll(t - ans);     return 0;   }
#include<bits/stdc++.h>   #define rep(i,n) for(int i=0 ; i<n ; i++)   #define ll long long    #define pb push_back   #define mp make_pair   #define all(x) x.begin(),x.end()   using namespace std;   const ll MX=1e6+2;   const ll MOD=1e9+7;      int main(){       int t;       cin>>t;       while(t--){           ll n;           cin>>n;           ll s=floor(log10(n))+1;           vector<ll> A;           rep(i,9){               ll a=i+1,b=i+1;               rep(j,s-1){                   b*=10;                   b+=a;               }               A.pb(b);           }           ll ans=0;           for(auto el:A){               if(el<=n)ans++;           }           ll an=9*(s-1)+ans;           cout<<an<<endl;       }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, k;     scanf( %d%d%d , &n, &m, &k);     bool hole[n + 1];     bool contain[n + 1];     memset(hole, false, sizeof hole);     memset(contain, false, sizeof contain);     int first;     while (m--) {       scanf( %d , &first);       hole[first] = true;     }     int u, v;     contain[1] = true;     while (k--) {       scanf( %d%d , &u, &v);       if (contain[u] && hole[u])         continue;       else if (contain[v] && hole[v])         continue;       else {         swap(contain[u], contain[v]);       }     }     for (int i = 1; i <= n; i++) {       if (contain[i]) {         return !printf( %d , i);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using i64 = long long;   using u64 = unsigned long long;   struct debug {     ~debug() { cerr << endl; }     template <class c>     debug& operator<<(c x) {       cerr << x;       return *this;     }     template <class c, class d>     debug& operator<<(pair<c, d> x) {       *this <<  (  << x.first <<  ,   << x.second <<  ) ;       return *this;     }     template <class c>     debug& operator<<(vector<c> x) {       *this <<  [ ;       int f = 0;       for (auto it : x) {         *this << (f ?  ,   :   );         *this << it;         f = 1;       }       *this <<  ] ;       return *this;     }   };   const int MOD = 998244353;   const int N = 5e5;   i64 add(i64 a, i64 b) {     if (a + b >= MOD)       return a + b - MOD;     else       return a + b;   }   i64 mul(i64 a, i64 b) {     i64 c = a * b;     if (c >= MOD) c %= MOD;     return c;   }   vector<i64> fact(N + 5);   vector<i64> inv_fact(N + 5);   i64 mod_inverse(i64 x) {     int p = MOD - 2;     i64 ret = 1;     while (p) {       if (p & 1) {         ret = mul(ret, x);       }       x = mul(x, x);       p /= 2;     }     return ret;   }   i64 nCr(int n, int r) {     if (r > n) return 0;     i64 ret = mul(fact[n], inv_fact[r]);     ret = mul(ret, inv_fact[n - r]);     return ret;   }   int main() {     fact[0] = 1;     inv_fact[0] = mod_inverse(1);     for (int i = 1; i <= N; i++) {       fact[i] = mul(fact[i - 1], i);       inv_fact[i] = mod_inverse(fact[i]);     }     int n, k;     scanf( %d%d , &n, &k);     i64 ans = 0;     for (int i = 1; i <= n; i++) {       ans = add(ans, nCr(n / i - 1, k - 1));     }     printf( %lld n , ans);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     double m, R;     cin >> m >> R;     double answer = (m * (m + 1) * (m + 2) / 3 - m) * 2;     answer += (sqrt(2.0) - 2) * ((m * m - m) + (m * m - m - (m - 1) * 2));     answer /= (m * m);     answer *= R;     cout << setprecision(7) << answer << endl;     return 0;   }