malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include<bits/stdc++.h>   using namespace std;   typedef long long ll;   typedef pair<int,int> PII;   const int maxn=111111,mod=998244353;   const double PI=3.141592653589793;   #define MP make_pair   #define PB push_back   #define lson o<<1,l,mid   #define rson o<<1|1,mid+1,r   #define FOR(i,a,b) for(int i=(a);i<=(b);i++)   #define ROF(i,a,b) for(int i=(a);i>=(b);i--)   #define MEM(x,v) memset(x,v,sizeof(x))   inline ll read(){    char ch=getchar();ll x=0,f=0;    while(ch< 0  || ch> 9 ) f|=ch== - ,ch=getchar();    while(ch>= 0  && ch<= 9 ) x=x*10+ch- 0 ,ch=getchar();    return f?-x:x;   }   inline int qpow(int a,int b){    int ans=1;    for(;b;b>>=1,a=1ll*a*a%mod) if(b&1) ans=1ll*ans*a%mod;    return ans;   }   int n,at,id[maxn],a[maxn],cnt,ans[maxn][2],al;   bool vis[maxn];   struct point{    int x,y,id;    point operator-(const point &p)const{return (point){x-p.x,y-p.y,id};}    double ang()const{return atan2(y,x);}    bool operator<(const point &p)const{     if(p.id==at) return false;     if(id==at) return true;     return ang()<p.ang();    }   }p[maxn],q[maxn];   inline void add(int x,int y){    ans[++al][0]=x;    ans[al][1]=y;    swap(a[x],a[y]);   }   void dfs(int x){    id[x]=cnt;    if(!id[a[x]]) dfs(a[x]);   }   int main(){    n=read();    FOR(i,1,n) p[i].x=read(),p[i].y=read(),a[i]=read(),p[i].id=i;    FOR(i,1,n) if(i!=a[i]){     if(!at || MP(p[i].x,p[i].y)<MP(p[at].x,p[at].y)) at=i;    }    if(!at) return puts( 0 ),0;    FOR(i,1,n) if(!id[i]) cnt++,dfs(i);    FOR(i,1,n) if(i!=at) p[i]=p[i]-p[at];    sort(p+1,p+n+1);    if(p[n].ang()-p[2].ang()>PI){     ROF(i,n,2) if(p[i].ang()-p[2].ang()<PI){      q[1]=p[1];      FOR(j,i+1,n) q[j-i+1]=p[j];      FOR(j,2,i) q[n-i+j]=p[j];      break;     }    }    else FOR(i,1,n) q[i]=p[i];    vis[id[q[2].id]]=true;    FOR(i,3,n) if(!vis[id[q[i].id]]){     add(q[i].id,q[i-1].id);     vis[id[q[i].id]]=true;    }    while(a[at]!=at) add(a[at],at);    printf( %d n ,al);    FOR(i,1,al) printf( %d %d n ,ans[i][0],ans[i][1]);   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1000000007;   const int inf = 1e9 + 10;   const long long INF = 1e18;   const long double EPS = 1e-10;   const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};   const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};   template <class T>   bool chmax(T &a, const T &b) {     if (a < b) {       a = b;       return 1;     }     return 0;   }   template <class T>   bool chmin(T &a, const T &b) {     if (a > b) {       a = b;       return 1;     }     return 0;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout << fixed << setprecision(25);     int t;     cin >> t;     while (t--) {       int n;       string s;       cin >> n >> s;       string ans =   ;       int idx = 0;       while (idx < n && s[idx] ==  0 ) {         ans += s[idx];         idx++;       }       s = s.substr(idx);       reverse(s.begin(), s.end());       n = s.size();       string ans2 =   ;       idx = 0;       while (idx < n && s[idx] ==  1 ) {         ans2 += s[idx];         idx++;       }       s = s.substr(idx);       n = s.size();       if (n) ans +=  0 ;       ans += ans2;       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int test;     cin >> test;     for (int t = 0; t < test; t++) {       int n;       cin >> n;       int k = 2;       while (n % (int)(pow(2, k) - 1) != 0) {         k++;       }       int ans = n / (pow(2, k) - 1);       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int Max = 1e5 + 5;   struct node {     int x, y;   } Node1[Max], Node2[Max];   int hash1[Max], hash2[Max];   bool cmp(const node a, const node b) {     if (a.y == b.y) return a.x < b.x;     return a.y < b.y;   }   int main() {     int n, m;     while (scanf( %d%d , &n, &m) != EOF) {       memset(hash1, 0, sizeof(hash1));       memset(hash2, 0, sizeof(hash2));       for (int i = 0; i < n; ++i) {         scanf( %d%d , &Node1[i].x, &Node1[i].y);         hash1[Node1[i].y]++;       }       for (int i = 0; i < m; ++i) {         scanf( %d%d , &Node2[i].x, &Node2[i].y);         hash2[Node2[i].y]++;       }       int coun = 0;       for (int i = 0; i <= 1000; ++i) {         if (hash1[i] > 0 && hash2[i] > 0)           coun += (max(hash1[i], hash2[i]) - abs(hash1[i] - hash2[i]));       }       sort(Node1, Node1 + n, cmp);       sort(Node2, Node2 + m, cmp);       int i = 0, j = 0, cou = 0;       while (i < n && j < m) {         if (Node1[i].y == Node2[j].y) {           if (Node1[i].x == Node2[j].x) {             cou++;             i++;             j++;           } else if (Node1[i].x < Node2[j].x)             i++;           else             j++;         } else if (Node1[i].y < Node2[j].y)           i++;         else           j++;       }       printf( %d %d n , coun, cou);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n, m;     cin >> n >> m;     string a, b;     cin >> a >> b;     if (a.size() - 1 > b.size()) {       cout <<  NO n ;       return 0;     }     if (a == b) {       cout <<  YES n ;       return 0;     }     int l = 0, r = m - 1;     while (a[l] == b[l] && l < min(n, m)) l++;     while (a.back() == b.back() && min(a.size(), b.size()) > l)       a.pop_back(), b.pop_back();     if (a.size() - l == 1 && a.back() ==  * ) {       cout <<  YES ;     } else {       cout <<  NO n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100010;   char str[MAXN];   int k1, k0, k2;   int main() {     scanf( %s , str);     int n = strlen(str);     k1 = k2 = k0 = 0;     for (int i = 0; i < n; i++) {       if (str[i] ==  0 ) k0++;       if (str[i] ==  1 ) k1++;       if (str[i] ==  ? ) k2++;     }     if (k2 + k0 >= (n - 2) / 2 + 2) cout <<  00  << endl;     if (k0 + k2 > (n - 2) / 2 && k1 + k2 > (n - 1) / 2) {       if (str[n - 1] ==  1  || (str[n - 1] ==  ?  && k0 + k2 - 1 > (n - 2) / 2))         cout <<  01  << endl;       if (str[n - 1] ==  0  || (str[n - 1] ==  ?  && k1 + k2 - 1 > (n - 1) / 2))         cout <<  10  << endl;     }     if (k2 + k1 >= (n - 1) / 2 + 2) cout <<  11  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   unsigned int dp[100010][400];   vector<int> nima[100010];   int a[100010], b[100010];   int n, m, s, e;   int main() {     while (cin >> n >> m >> s >> e) {       memset(dp, -1, sizeof(dp));       for (int i = 0; i < n; ++i) {         scanf( %d , &a[i]);       }       for (int i = 0; i < m; ++i) {         scanf( %d , &b[i]);         nima[b[i]].push_back(i + 1);       }       int ans = 0;       int cnt = s / e;       for (int i = 0; i < n; ++i) {         dp[i][0] = 0;         if (nima[a[i]].size())           dp[i][1] = nima[a[i]][0];         else           dp[i][1] = -1;         if (i == 0) continue;         for (int j = 1; j <= cnt; ++j) {           unsigned int now = -1;           int w = a[i];           int last = dp[i - 1][j - 1];           now =               upper_bound(nima[w].begin(), nima[w].end(), last) - nima[w].begin();           if (now == nima[w].size() || dp[i - 1][j - 1] == -1) {             now = -1;           } else {             now = nima[w][now];           }           dp[i][j] = min(dp[i - 1][j], now);         }       }       for (int i = 0; i < n; ++i)         for (int j = 0; j < cnt + 1; ++j) {           if (dp[i][j] != -1) {             if (i + dp[i][j] + 1 + j * e <= s) ans = max(ans, j);           }         }       cout << ans << endl;       return 0;     }   }
#include <bits/stdc++.h>   using namespace std;   struct compleks {     double x, y;   };   compleks operator*(compleks a, compleks b) {     compleks c;     c.x = a.x * b.x - a.y * b.y;     c.y = a.x * b.y + a.y * b.x;     return c;   }   compleks operator-(compleks a, compleks b) {     compleks c;     c.x = a.x - b.x, c.y = a.y - b.y;     return c;   }   compleks operator+(compleks a, compleks b) {     compleks c;     c.x = a.x + b.x, c.y = a.y + b.y;     return c;   }   int pos[65536 * 8];   void fft(compleks a[], int typ) {     for (int i = 0; i < 65536 * 8; i++)       if (pos[i] > i) swap(a[i], a[pos[i]]);     for (int p = 1; p < 65536 * 8; p <<= 1) {       int m = p + p;       compleks wx;       wx.x = cos(2 * 3.141592653589793 / m * typ),       wx.y = sin(2 * 3.141592653589793 / m * typ);       for (int i = 0; i < 65536 * 8; i += m) {         compleks w;         w.x = 1, w.y = 0;         for (int j = 0; j < p; j++, w = w * wx) {           compleks e = a[i + j], f = a[i + j + p] * w;           a[i + j] = e + f, a[i + j + p] = e - f;         }       }     }     if (typ == -1)       for (int i = 0; i < 65536 * 8; i++)         a[i].x /= 65536 * 8, a[i].y /= 65536 * 8;   }   void getpos() {     for (int i = 0; i < 65536 * 8; i++)       pos[i] = (pos[i >> 1] >> 1) | ((i & 1) << 16 + 3 - 1);   }   int a[65536 * 8];   int n;   int x;   int pre[65536 * 8];   int cnt[65536 * 8];   compleks c[65536 * 8], d[65536 * 8];   int main() {     cin >> n >> x;     cnt[0]++;     long long di = 0;     for (int i = 1; i <= n; i++)       scanf( %d , &a[i]), pre[i] = pre[i - 1] + (a[i] < x), di += cnt[pre[i]],                           cnt[pre[i]]++;     getpos();     for (int i = 0; i <= n; i++)       c[i].x = cnt[i], d[-i + 65536 * 8 / 2].x = cnt[i];     fft(c, 1);     fft(d, 1);     for (int i = 0; i < 65536 * 8; i++) c[i] = c[i] * d[i];     fft(c, -1);     for (int i = 0; i <= n; i++) {       long long ai = (long long)(c[i + 65536 * 8 / 2].x + 0.5);       if (i == 0) ai = di;       printf( %lld  , ai);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, deg[8012], ans1, ans2, ans3, cn = 0, mx[8012], X[8012];   bool w[8012][8012], vis[8012];   queue<int> q;   long long ans = 0;   int main() {     scanf( %d , &n);     m = n >> 2;     int i, j, k, v, x, y, o;     char ch;     for (i = 0, getchar(); i < n; ++i, getchar())       for (x = j = 0; j < m; ++j) {         ch = getchar();         v = (ch <=  9 ) ? (ch -  0 ) : (10 + ch -  A );         for (k = 3; ~k; --k, ++x)           if ((v >> k) & 1) {             w[i][x] = 1;             ++deg[x];           }       }     for (i = 0; i < n; i++)       if (!deg[i]) q.push(i);     while (!q.empty()) {       vis[x = q.front()] = 1;       q.pop();       ++cn;       bool *p = w[x];       for (y = 0; y < n; y++)         if (p[y]) {           p[y] = 0;           if (!(--deg[y])) q.push(y);         }     }     ans = 1ll * cn * (cn - 1) / 2 * (1 + 614 * n) +           1ll * cn * (n - cn) * (1 + 614 * n);     ans1 = (n - cn) * (n - cn - 1) / 2;     for (x = 0; x < n; ++x) X[x] = x;     for (x = 0; x < n; ++x)       if (!vis[x]) {         bool *p = w[x];         v = deg[x];         for (y = 0; y < n; ++y)           if (p[y])             mx[y] = max(mx[y], v - deg[y] + 1), o = X[y], X[y] = p[o] ? x : o;       }     for (x = 0; x < n; ++x) ans2 += max(mx[x], deg[X[x]]);     ans3 = (n - cn) * (n - cn - 1) - ans1 - ans2;     ans += ans1 + ans2 * 2 + ans3 * 3;     printf( %lld , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long i, n, m, k, x, z, c, a[500007], b[500007], ans, bad, total;   int main() {     cin >> n;     for (i = 1; i <= n; i++) cin >> a[i];     set<long long> st;     for (i = 1; i <= n; i++) {       st.insert(a[i]);       if (st.find(i) != st.end()) st.erase(i);       if (st.size() == 0) c++;     }     cout << c << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long int> primes;   void Sieve(long long int n) {     vector<bool> prime(n + 1, true);     for (long long int p = 2; p * p <= n; p++) {       if (prime[p] == true) {         for (long long int i = p * p; i <= n; i += p) prime[i] = false;       }     }     for (long long int p = 2; p <= n; p++)       if (prime[p]) primes.push_back(p);   }   vector<bool> vis;   long long int dia = 0;   long long int dfs(long long int x, vector<vector<long long int>>& vec) {     vis[x] = true;     priority_queue<long long int> pq;     for (auto it : vec[x]) {       if (vis[it] != true) pq.push(dfs(it, vec) + 1);     }     if (pq.size() == 0)       return 0;     else if (pq.size() == 1) {       long long int p = pq.top();       dia = max(dia, p);       return p;     } else {       long long int p = pq.top();       pq.pop();       long long int y = pq.top();       dia = max(dia, p + y);       return p;     }   }   int main() {     long long int t;     cin >> t;     while (t--) {       long long int n, a, b, da, db;       cin >> n;       cin >> a;       cin >> b;       cin >> da;       cin >> db;       vector<vector<long long int>> vec(n + 1);       for (long long int i = 0; i < n - 1; i++) {         long long int x, y;         cin >> x;         cin >> y;         vec[x].push_back(y);         vec[y].push_back(x);       }       vector<bool> visited(n + 1, 0);       queue<pair<long long int, long long int>> q;       q.push({a, 0});       long long int dis = 0;       while (!q.empty()) {         pair<long long int, long long int> p = q.front();         q.pop();         if (p.first == b) {           dis = p.second;           break;         }         for (auto it : vec[p.first]) {           if (!visited[it]) {             q.push({it, p.second + 1});             visited[it] = true;           }         }       }       vis = vector<bool>(n + 1, 0);       dfs(1, vec);       cout << (2 * da >= min(dia, db) || dis <= da ?  Alice  :  Bob ) <<   n ;       dia = 0;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int d;     cin >> d;     for (int i = 0; i < d; ++i) {       long long n;       cin >> n;       if (n * (n - 4) >= 0) {         cout <<  Y   << fixed << setprecision(9) << (n + sqrt(n * n - 4 * n)) / 2              <<     << n - (n + sqrt(n * n - 4 * n)) / 2;         cout <<   n ;       } else {         cout <<  N n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 10;   char s[N], t[N];   int vis[N], vs[N];   int main() {     cin >> s + 1 >> t + 1;     int j = 1;     int n = strlen(s + 1);     int m = strlen(t + 1);     for (int i = 1; i <= n && j <= m; ++i) {       if (s[i] == t[j]) {         vis[j] = i;         ++j;       }     }     j = m;     for (int i = n; i >= 1 && j >= 1; --i) {       if (s[i] == t[j]) {         vs[j] = i;         --j;       }     }     int ans = max(vis[1] - 1, n - vis[m]);     ans = max(ans, vs[1] - 1);     ans = max(ans, n - vs[m]);     for (int i = 1; i <= m; ++i) {       ans = max(ans, vs[i] - vis[i - 1] - 1);     }     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   long long modexpo(long long x, long long p) {     long long res = 1;     x = x % 1000000007;     while (p) {       if (p % 2) res = res * x;       p >>= 1;       x = x * x % 1000000007;       res %= 1000000007;     }     return res;   }   struct compare {     bool operator()(const pair<long long, long long> a,                     const pair<long long, long long> b) const {       return a.first < b.first;     }   };   void __solve__(long long testCase) {     long long x, y, ans = 2e18 + 7;     cin >> y >> x;     vector<long long> c(6);     for (long long &e : c) cin >> e;     for (long long i = 0; i < 3; i++)       for (long long j = 0; j < 3; j++) {         long long s = 0;         if (i == j) {           if (i == 0 && y == 0)             if (x > 0)               s += c[1] * x;             else               s += c[4] * -x;           if (i == 1 && x == 0)             if (y > 0)               s += c[5] * y;             else               s += c[2] * -y;           if (i == 2 && x == y)             if (x > 0)               s += c[0] * x;             else               s += c[3] * -x;           if (s) ans = min(ans, s);           continue;         } else if (i != 2 && j != 2) {           if (x > 0)             s += c[1] * x;           else             s += c[4] * -x;           if (y > 0)             s += c[5] * y;           else             s += c[2] * -y;         } else {           if (j == 0 || i == 0) {             if (y > 0)               s += c[0] * y;             else               s += c[3] * -y;             if (x - y > 0)               s += c[1] * (x - y);             else               s += c[4] * -(x - y);           } else {             if (x > 0)               s += c[0] * x;             else               s += c[3] * -x;             if (y - x > 0)               s += c[5] * (y - x);             else               s += c[2] * -(y - x);           }         }         ans = min(ans, s);       }     cout << ans <<   n ;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long testCase = 1;     cin >> testCase;     for (long long tc = 1; tc <= testCase; tc++) {       __solve__(tc);     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1 << 18;   const long long INF = 0x3f3f3f3f;   int n, k;   bool fav[MAXN];   long long dp[MAXN][18][2][2];   inline void get_max(long long &, long long);   int main() {     scanf( %d%d , &n, &k);     for (register int i = 1; i <= k; ++i) {       int tmp;       scanf( %d , &tmp);       fav[tmp - 1] = true;     }     for (int k = 0; k < (1 << n); ++k)       for (int t = 1; t <= n; ++t)         for (int a = 0; a <= 1; ++a)           for (int b = 0; b <= 1; ++b) dp[k][t][a][b] = -INF;     for (int i = 0; i < (1 << n - 1); ++i)       dp[i][1][fav[i << 1]][fav[i << 1 | 1]] =           dp[i][1][fav[i << 1 | 1]][fav[i << 1]] = fav[i << 1] | fav[i << 1 | 1];     for (int t = 2; t <= n; ++t)       for (int k = 0; k < (1 << n - t); ++k) {         for (register int a = 0; a <= 1; ++a)           for (register int b = 0; b <= 1; ++b)             for (register int c = 0; c <= 1; ++c)               for (register int d = 0; d <= 1; ++d) {                 get_max(dp[k][t][a][c],                         dp[k << 1][t - 1][a][b] + dp[k << 1 | 1][t - 1][c][d] +                             (a | c) + (b | d) + max(c | b, c | d));                 get_max(dp[k][t][a][b], dp[k << 1][t - 1][a][b] +                                             dp[k << 1 | 1][t - 1][c][d] +                                             (a | c) + (b | d) + (b | c));                 get_max(dp[k][t][a][d], dp[k << 1][t - 1][a][b] +                                             dp[k << 1 | 1][t - 1][c][d] +                                             (a | c) + (b | d) + (d | c));                 get_max(dp[k][t][c][a],                         dp[k << 1][t - 1][a][b] + dp[k << 1 | 1][t - 1][c][d] +                             (a | c) + (b | d) + max(a | b, a | d));                 get_max(dp[k][t][c][b], dp[k << 1][t - 1][a][b] +                                             dp[k << 1 | 1][t - 1][c][d] +                                             (a | c) + (b | d) + (a | b));                 get_max(dp[k][t][c][d], dp[k << 1][t - 1][a][b] +                                             dp[k << 1 | 1][t - 1][c][d] +                                             (a | c) + (b | d) + (a | d));               }       }     printf( %lld n , max(max(dp[0][n][0][0], dp[0][n][0][1] + 1),                          max(dp[0][n][1][0] + 1, dp[0][n][1][1] + 1)));     return 0;   }   inline void get_max(long long &a, long long b) { a = max(a, b); }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 3e5 + 7;   const int inf = 1e9;   char s[60][60];   char s1[60];   int l;   int n;   int num[60];   int check(char *s) {     for (int i = 0; i < l; ++i) {       int j;       for (j = 0; j < l; ++j) {         if (s1[j] != s[(j + i) % l]) break;       }       if (j >= l) return i;     }     return -1;   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; ++i) scanf( %s , s[i]);     l = strlen(s[0]);     int ans = inf;     for (int i = 0; i < l; ++i) {       int sum = 0;       for (int j = 0; j < l; ++j) s1[j] = s[0][(j + i) % l];       for (int j = 0; j < n; ++j) {         int t = check(s[j]);         if (t == -1) {           puts( -1 );           return 0;         }         sum += t;       }       ans = min(ans, sum);     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s[2][100];   int fun(char a, char b) {     if (a ==  8 ) {       if (b ==  [ )         return 1;       else if (b ==  ( )         return -1;       else         return 0;     }     if (a ==  [ ) {       if (b ==  8 )         return -1;       else if (b ==  ( )         return 1;       else         return 0;     }     if (a ==  ( ) {       if (b ==  [ )         return -1;       else if (b ==  8 )         return 1;       else         return 0;     }   }   int main() {     while (cin >> s[0] >> s[1]) {       int sum1 = 0, sum2 = 0;       for (int i = 0; s[0][i]; i += 2) sum1 += fun(s[0][i], s[1][i]);       if (sum1 > 0)         printf( TEAM 1 WINS n );       else if (sum1 < 0)         printf( TEAM 2 WINS n );       else         printf( TIE n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     char c1, c2;     cin >> c1 >> c2;     int n;     cin >> n;     if (n % 2 == 0) {       cout <<  undefined  << endl;     } else {       int n1, n2;       switch (c1) {         case  ^ :           n1 = 1;           break;         case  > :           n1 = 2;           break;         case  v :           n1 = 3;           break;         case  < :           n1 = 4;           break;       }       switch (c2) {         case  ^ :           n2 = 1;           break;         case  > :           n2 = 2;           break;         case  v :           n2 = 3;           break;         case  < :           n2 = 4;           break;       }       n %= 4;       if (n1 != 4) {         if (n2 - n1 == 1) {           if (n == 1)             cout <<  cw  << endl;           else             cout <<  ccw  << endl;         } else {           if (n == 1)             cout <<  ccw  << endl;           else             cout <<  cw  << endl;         }       } else {         if (n1 - n2 == 3) {           if (n == 1)             cout <<  cw  << endl;           else             cout <<  ccw  << endl;         } else {           if (n == 1)             cout <<  ccw  << endl;           else             cout <<  cw  << endl;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5;   const int MOD = 1000000007;   long long power(long long a, long long n, long long m) {     if (n == 0) return 1;     long long p = power(a, n / 2, m);     p = (p * p) % m;     if (n % 2) p = (p * a) % m;     return p;   }   int fact[N];   int ifact[N];   int main() {     fact[0] = 1;     for (int i = 1; i < N; i++) {       fact[i] = ((long long)i * fact[i - 1]) % MOD;     }     ifact[N - 1] = power(fact[N - 1], MOD - 2, MOD);     for (int i = N - 1; i >= 1; i--) {       ifact[i - 1] = ((long long)i * ifact[i]) % MOD;     }     int n;     scanf( %d , &n);     int ans = fact[2 * n - 1];     ans = ((long long)ans * ifact[n]) % MOD;     ans = ((long long)ans * ifact[n - 1]) % MOD;     ans = (2 * ans) % MOD;     ans = (ans - n + MOD) % MOD;     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long power(long long x, long long y) {     long long res = 1;     while (y > 0) {       if (y & 1) res = (res * x);       y = y >> 1;       x = (x * x);     }     return res;   }   long long summ(long long a) {     long long ans = 0;     while (a) {       ans += a % 10;       a = a / 10;     }     return ans;   }   long long digit(int n) {     int count = 0;     while (n) {       n = n / 10;       count++;     }     return count;   }   long long sum(long long a) {     long long ans = 0;     while (a) {       ans += (a % 10);       a = a / 10;     }     return ans;   }   int main() {     long long n;     cin >> n;     long long a = n;     long long b;     long long count = 0;     while (a) {       b = a % 10;       a = a / 10;       count++;     }     count--;     b--;     b = b * pow(10, count);     long long c = 0;     for (int i = 0; i < count; i++) {       c = (10 * c) + 9;     }     b = b + c;     c = n - b;     cout << sum(b) + sum(c);     return 0;   }