malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int NN = 5050;   const int MM = 27272;   int a[MM], b[MM];   vector<int> adj[NN];   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; i++) {       scanf( %d%d , a + i, b + i);       adj[a[i]].push_back(b[i]);     }     int mx = 0;     for (int i = 1; i <= n; i++) {       mx = max(mx, (int)adj[i].size());       sort(adj[i].begin(), adj[i].end());     }     for (int i = 1; i <= n; i++) {       int ans = 0;       for (int j = 1; j <= n; j++)         if (!adj[j].empty()) {           int it = lower_bound(adj[j].begin(), adj[j].end(), j) - adj[j].begin();           if (it == adj[j].size()) it = 0;           int ed = adj[j][it];           if (ed < j) ed += n;           if (j < i) ed += n;           int sz = adj[j].size();           ans = max(ans, (sz - 1) * n + ed - i);         }       cout << ans <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long f(long long x) {     long long ans = x;     while (ans) {       x *= 10;       x += (ans % 10);       ans /= 10;     }     return x;   }   int main() {     long long k, p;     cin >> k;     cin >> p;     long long sum = 0;     for (long long i = 1; i <= k; i++) sum += f(i);     sum %= p;     cout << sum << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;      using ll = long long;   using ld = long double;      int a[25][50005];      const int MOD = 998244353;      int add(int a, int b){       a += b;       if(a >= MOD) a -= MOD;       return a;   }      int mul(int a, int b){       return (1LL*a*b)%MOD;      }      int pw(int a, int b){       if(b == 0) return 1;       int res = pw(a, b/2);       res = mul(res, res);       if(b%2) res = mul(res, a);       return res;   }      int main(){       ios_base::sync_with_stdio(false), cin.tie(0);       cout.precision(10);       cout << fixed;          int n, m;       cin >> n >> m;       for(int i=1; i<=n; i++){           for(int j=1; j<=m; j++){               cin >> a[i][j];               a[i][j]--;           }       }       int res = 0;       for(int j=1; j<=m; j++){           vector <int> vec;           for(int i=1; i<=n; i++){               vec.push_back(a[i][j]);           }           sort(vec.begin(), vec.end());           int ways = 1;           for(int g=0; g<vec.size(); g++){               ways = mul(ways, vec[g] - g);           }           if(ways == 0) continue;           res = add(res, ways);       }       int fact = 1;       for(int i=1; i<=n; i++) fact = mul(fact, i);       int p = add(mul(fact, m), MOD - res);       p = mul(p, pw(fact, MOD-2));       cout << p;       return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, x, cnt;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(0);     cin >> n >> x;     for (int i = 1; i <= n; i++) {       if (x % i == 0 && x / i <= n) {         cnt++;       }     }     cout << cnt;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int num;     cin >> num;     if (num <= 9) {       cout << num << endl;     } else if (10 < num && num <= 189) {       num = num - 9;       int tmp = num / 2;       tmp = 9 + tmp + num % 2;       if (num % 2)         cout << tmp / 10 << endl;       else         cout << tmp % 10 << endl;     } else if (190 <= num) {       num = num - 189;       int tmp = num / 3;       if (num % 3 != 0)         tmp = 100 + tmp;       else         tmp = 99 + tmp;       if (num % 3 == 0) {         cout << tmp % 10 << endl;       } else if (num % 3 == 1) {         cout << tmp / 100 << endl;       } else {         tmp = tmp / 10;         tmp = tmp % 10;         cout << tmp << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a, b, ans1 = 0, ans2 = 0;     cin >> n;     vector<int> c(n);     for (int i = 0; i < n; i++) cin >> c[i];     cin >> a >> b;     if (a > b) swap(a, b);     a--;     b--;     for (int i = a; i < b; i++) {       ans1 += c[i];     }     for (int i = 0; i < a; i++) {       ans2 += c[i];     }     for (int i = b; i < n; i++) {       ans2 += c[i];     }     cout << min(ans1, ans2);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e3 + 5;   const int MOD = 1e9 + 7;   vector<int> g[N + N];   int mat[N][N], p[N + N], sub[N + N], vis[N + N];   int ans[N + N], instack[N + N], go = true, ct = 0;   vector<pair<int, int>> extime;   void putNumbers(int node) {     vis[node] = 1;     instack[node] = true;     ct++;     for (auto it : g[node]) {       if (!vis[it]) {         putNumbers(it);       } else if (instack[it])         go = false;     }     instack[node] = false;     extime.push_back({ct, node});     ct++;   }   void getAns(int node) {     vis[node] = 1;     ans[node] = max(ans[node], 1);     for (auto it : g[node])       if (!vis[it]) {         ans[it] = max(ans[it], ans[node] + 1);       }   }   int root(int u) {     while (p[u] != u) {       p[u] = p[p[u]];       u = p[u];     }     return u;   }   void merge(int uu, int vv) {     int u = root(uu), v = root(vv);     if (u == v) return;     if (sub[u] < sub[v]) swap(u, v);     p[v] = u;     sub[u] += sub[v];   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int n, m, i, j;     cin >> n >> m;     for (i = 1; i <= n + m; i++) {       p[i] = i;       sub[i] = 1;     }     for (i = 1; i <= n; i++) {       string s;       cin >> s;       for (j = 0; j < m; j++) {         if (s[j] ==  < )           mat[i][j + 1] = -1;         else if (s[j] ==  = ) {           merge(i, n + j + 1);           mat[i][j + 1] = 0;         } else           mat[i][j + 1] = 1;       }     }     for (i = 1; i <= n; i++)       for (j = 1; j <= m; j++) {         int u = root(i), v = root(n + j);         if (mat[i][j] < 0) {           if (u == v) {             cout <<  No n ;             return 0;           }           g[u].push_back(v);         }         if (mat[i][j] > 0) {           if (u == v) {             cout <<  No n ;             return 0;           }           g[v].push_back(u);         }       }     for (i = 1; i <= n + m; i++)       if (!vis[i] && p[i] == i) {         putNumbers(i);         if (!go) {           cout <<  No n ;           return 0;         }       }     sort(extime.begin(), extime.end());     reverse(extime.begin(), extime.end());     memset(vis, 0, sizeof(vis));     for (auto it : extime)       if (!vis[it.second]) {         getAns(it.second);       }     cout <<  Yes n ;     for (i = 1; i <= n + m; i++) {       cout << ans[root(i)] <<    ;       if (i == n) cout <<   n ;     }     cout <<   n ;     return 0;   }
#include<iostream>   #include<string>   #include<cstring>   #include<cmath>   #include<algorithm>   #include<queue>   #include<iomanip>   #include<map>   #include<cstdio>   #include<stack>   #include<set>   using namespace std;   #define endl    n    #define IOS ios::sync_with_stdio(false),cin.tie(0), cout.tie(0)   typedef long long ll;   typedef unsigned long long ull;   typedef pair<int, int> pii;   typedef pair<long, long>pll;   const int inf = 0x3f3f3f3f;   const ll lnf = 0x3f3f3f3f3f3f3f3f;   const double pi = acos(-1.0);   int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }   ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }   #define re(i,a,b) for(int i = a;i <= b;i++)   #define rre(i,a) for(int i = 0;i < a;i++)   #define prre(i,a) for(int i = a;i >= 0;i--)   #define pre(i,a) for(int i = a;i > 0;i--)   #define bug system( pause )   const double eps = 1e-6;   const int N = 1e6 + 10;   const int M = 2e6 + 10;   const int mod = 1e9 + 7;      int n, t, x;   map<pii, int>mp;   int ask(int l, int r)   {    if (mp.count(make_pair(l, r)))return mp[make_pair(l, r)];    cout <<  ?   << l <<     << r << endl;    cout.flush();    int sum;    cin >> sum;    int num = r - l + 1 - sum;    mp[make_pair(l, r)] = num;    return num;   }      int query(int l, int r, int k)   {    if (l == r)return l;    int mid = (l + r) >> 1;    int v = ask(l, mid);    if (v < k)return query(mid + 1, r, k - v);    else return query(l, mid, k);   }      void update(int l, int r, int pos)   {    if (mp.count(make_pair(l, r)))mp[make_pair(l, r)]--;    if (l == r)return;    int mid = (l + r) >> 1;    if (pos <= mid)update(l, mid, pos);    if (pos > mid)update(mid + 1, r, pos);   }      int main()   {    cin >> n >> t;    for (int i = 1; i <= t; i++)    {     cin >> x;     int pos = query(1, n, x);     update(1, n, pos);     cout <<  !   << pos << endl;     cout.flush();    }    return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2e5 + 5;   const int LOGN = 31;   int fwt[MAXN];   int P[MAXN] = {0};   int n;   void update(int v, int d) {     v++;     for (; v <= n; v += v & -v) fwt[v] += d;   }   int query(int v) {     int sum = 0;     for (; v > 0; v -= v & -v) sum += fwt[v];     return sum;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n;     for (int j = 0; j < 2; j++) {       memset(fwt, 0, sizeof(fwt));       for (int i = 0; i < n; i++) {         int v;         cin >> v;         P[i] += v - query(v);         update(v, 1);       }     }     int c = 0;     for (int i = n - 1; i >= 0; i--) {       int mod = n - i;       if (P[i] >= mod) {         P[i] -= mod;         if (i) P[i - 1]++;       }     }     memset(fwt, 0, sizeof(fwt));     for (int i = 0; i < n; i++) update(i, 1);     for (int i = 0; i < n; i++) {       int sum = 0;       int pos = 0;       for (int j = LOGN; j >= 0; j--) {         if (pos + (1LL << j) < n && sum + fwt[pos + (1LL << j)] < P[i] + 1) {           sum += fwt[pos + (1LL << j)];           pos += (1LL << j);         }       }       cout << (pos) <<    ;       update(pos, -1);     }     cout <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int count = 0, size;     cin >> size;     char c;     vector<char> num;     for (int i = 0; i < size; i++) {       cin >> c;       num.push_back(c);     }     for (int i = 0; i < num.size(); i++) {       if (num[i] ==  8 ) count++;       if ((size / 11) < count) count = (size / 11);     }     cout << count << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 3000;   vector<int> E[MAXN];   long long dp[MAXN][MAXN];   int P[MAXN][MAXN];   int T[MAXN][MAXN];   int n;   bool cmp(int a, int b) { return dp[a] > dp[b]; }   void dfs(int x, int p, int r) {     P[r][x] = p;     int d = 1;     for (int i = 0; i < E[x].size(); ++i) {       int v = E[x][i];       if (v != p) {         dfs(v, x, r);         d += T[r][v];       }     }     T[r][x] = d;   }   long long dp_get(int u, int v) {     if (u == v || dp[u][v] != 0) return dp[u][v];     long long d =         max(dp_get(u, P[u][v]), dp_get(v, P[v][u])) + T[u][v] * 1LL * T[v][u];     dp[u][v] = d;     dp[v][u] = d;     return d;   }   void solve() {     scanf( %d , &n);     for (int i = 1; i < n; ++i) {       int x, y;       scanf( %d%d , &x, &y);       --x, --y;       E[x].push_back(y);       E[y].push_back(x);     }     for (int i = 0; i < n; ++i) dfs(i, -1, i);     long long bestres = 0;     for (int i = 0; i < n; ++i)       for (int j = 0; j < i; ++j) bestres = max(bestres, dp_get(i, j));     printf( %I64d n , bestres);   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   class ReverseBit {    public:     ReverseBit(int size) : bit_(size + 1, 0) {}     void Add(int pos, int num);     int GetMax(int pos) const;       private:     static int Lsb(int num) { return num & -num; }     vector<int> bit_;   };   void ReverseBit::Add(int pos, int num) {     pos = bit_.size() - pos;     while (pos < (int)bit_.size()) {       bit_[pos] = max(bit_[pos], num);       pos += Lsb(pos);     }   }   int ReverseBit::GetMax(int pos) const {     pos = bit_.size() - pos;     int res = 0;     while (pos > 0) {       res = max(res, bit_[pos]);       pos -= Lsb(pos);     }     return res;   }   struct Receipt {     int sum;     int time;   };   int main() {     int n;     cin >> n;     vector<Receipt> last_receipts(n);     for (auto &r : last_receipts) {       cin >> r.sum;       r.time = 0;     }     int updates;     cin >> updates;     ReverseBit bit(updates + 2);     for (int i = 1; i <= updates; i += 1) {       int type;       cin >> type;       if (type == 1) {         int id, sum;         cin >> id >> sum;         last_receipts[id - 1] = Receipt{.sum = sum, .time = i};       } else {         int sum;         cin >> sum;         bit.Add(i, sum);       }     }     for (const auto &r : last_receipts) {       cout << max(r.sum, bit.GetMax(r.time + 1)) <<    ;     }     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s[1000010];   int main() {     int k;     cin >> k;     scanf( %s , s);     int n = strlen(s);     int a[n + 1];     a[0] = 0;     for (int i = 1; i < n + 1; i++) {       a[i] = a[i - 1] + ((s[i - 1] ==  1 ) ? 1 : 0);     }     long long int ans = 0;     for (int i = 1; i < n + 1; i++) {       int ss = a[i - 1] + k;       if (a[n] < ss) continue;       int g = lower_bound(a + i, a + n + 1, ss) - a;       int h = upper_bound(a + i, a + n + 1, ss) - a;       ans += (h - g);     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long maxx = 1e6 + 7;   const long long maxn = 1e6 + 7;   const long long mod = 998244353;   const long long maxs = 500000 + 7;   const long long maxm = 400000 + 7;   const long long maxk = 1008 + 7;   const long long maxw = 100 + 7;   const long long maxh = 100 + 7;   const double pi = 3.1415926;   const long long ten = 10;   const long long ooi = 1000000;   const long long ool = 1e18 + 7;   const long double eps = 1e-8;   const int apsz = 26;   long long n;   void init() { cin >> n; }   void solve() {     vector<long long> a(n, 0);     vector<long long> b(n, 0);     vector<long long> pos(n);     for (long long i = (0); i < (n); i++) cin >> a[i];     for (long long i = (0); i < (n); i++) cin >> b[i];     sort(b.begin(), b.end());     for (long long i = (0); i < (n); i++) {       long long ans = 0;       long long lt = i;       long long rt = n - i - 1;       ans = (lt + 1) * (rt + 1);       ans *= a[i];       pos[i] = ans;     }     sort(pos.begin(), pos.end(), greater<long long>());     long long ans = 0;     long long p1 = 0;     while (p1 < n) {       pos[p1] %= mod;       ans += (b[p1] * pos[p1]) % mod;       ans %= mod;       p1++;     }     cout << ans << endl;   }   int main(void) {     ios::sync_with_stdio(false);     cout.tie(0);     cin.tie(0);     init();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string int_to_string(int a) {     stringstream ss;     ss << a;     return ss.str();   }   string double_to_string(double a) {     stringstream ss;     ss << a;     return ss.str();   }   string float_to_string(float a) {     stringstream ss;     ss << a;     return ss.str();   }   string long_to_string(long a) {     stringstream ss;     ss << a;     return ss.str();   }   string long_long_to_string(long long a) {     stringstream ss;     ss << a;     return ss.str();   }   int string_to_int(string s) { return atoi(s.c_str()); }   float string_to_float(string s) { return atof(s.c_str()); }   long string_to_long(string s) { return atol(s.c_str()); }   long long string_to_long_long(string s) { return atoll(s.c_str()); }   int main() {     long long n, c = 0;     cin >> n;     for (long long i = 1; i <= n; i *= 10) c += (n - (i - 1));     cout << c;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e6 + 1, INF = 1e9 + 1;   int n, q, a, b, p, t;   pair<long double, long double> st[N], lf, rg;   pair<long double, long double> merge(pair<long double, long double> a,                                        pair<long double, long double> b) {     long double l1 = a.first, r1 = a.second, l2 = b.first, r2 = b.second;     if (a.first < 0 and a.second < 0) return b;     if (b.first < 0 and b.second < 0) return a;     return pair<long double, long double>(         l1 * l2 / (1 - r1 * (1 - l2)),         r2 + r1 * l2 * (1 - r2) / (1 - (r1 * (1 - l2))));   }   pair<long double, long double> query(int l, int r) {     lf = rg = pair<long double, long double>(-1, -1);     l += n - 1, r += n;     while (l < r) {       if (l & 1) lf = merge(lf, st[l++]);       if (r & 1) rg = merge(st[--r], rg);       l /= 2, r /= 2;     }     return merge(lf, rg);   }   void update(int k, long double v) {     k += n - 1;     st[k] = pair<long double, long double>(v, v);     while (k) k /= 2, st[k] = merge(st[2 * k], st[2 * k + 1]);   }   int main() {     scanf( %d%d , &n, &q);     for (int i = n; i < 2 * n; ++i) {       scanf( %d%d , &a, &b);       st[i] = pair<long double, long double>(1.0 * a / b, 1.0 * a / b);     }     for (int i = n - 1; i >= 0; --i) st[i] = merge(st[2 * i], st[2 * i + 1]);     for (int i = 0; i < q; ++i) {       scanf( %d , &t);       if (t == 1) {         scanf( %d%d%d , &p, &a, &b);         update(p, 1.0L * a / b);       } else {         scanf( %d%d , &a, &b);         printf( %lf n , (double)query(a, b).first);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     register int num = 0;     register char ch = getchar();     while (ch >  9  || ch <  0 ) ch = getchar();     while (ch <=  9  && ch >=  0 ) num = num * 10 + ch -  0 , ch = getchar();     return num;   }   int num[10];   inline void write(int x) {     register int cnt = 0;     if (!x) {       printf( 0 );       return;     }     while (x) num[++cnt] = x % 10, x /= 10;     while (cnt) putchar(num[cnt--] +  0 );   }   struct node {     int next, to, w;   } e[300020 * 2];   int n, m;   int head[300020], cnt;   int sz[300020], fa[300020], tag[300020], a[300020], tot, flag;   long long dth[300020], ans, mx[300020], dis[300020];   inline void adde(int x, int y, int w) {     e[++cnt].to = y;     e[cnt].next = head[x];     e[cnt].w = w;     head[x] = cnt;   }   void dfs(int x) {     for (int i = head[x]; i; i = e[i].next) {       if (e[i].to == fa[x]) continue;       dth[e[i].to] = dth[x] + e[i].w;       fa[e[i].to] = x;       dfs(e[i].to);     }   }   void dfs2(int x) {     sz[x] = 1;     for (int i = head[x]; i; i = e[i].next) {       if (e[i].to == fa[x] || tag[e[i].to]) continue;       dis[x] = max(dis[x], dis[e[i].to] + e[i].w);       dfs2(e[i].to);       sz[x] += sz[e[i].to];     }   }   void init() {     dfs(1);     int x = n;     while (x) tag[x] = 1, a[++tot] = x, x = fa[x];     for (register int i = 1; i <= tot + 1; i++) mx[i] = -1e16;     for (register int i = tot; i >= 1; i--) {       int x = a[i];       dfs2(x);       if (sz[x] > 1) mx[i] = max(mx[i + 1], dis[x] + dth[x]);       if (i < tot) {         ans = max(ans, dth[n] + dis[x] - dth[x] + mx[i + 1]);         if (sz[x] > 1)           ans = max(ans, dth[n] + dis[x] - dth[x] + dth[a[i + 1]]);         else if (i < tot - 1)           ans = max(ans, dth[n] + dis[x] - dth[x] + dth[a[i + 2]]);       }       if (sz[x] > 2) flag = 1;     }   }   int main() {     scanf( %d %d , &n, &m);     for (register int i = 1; i <= n - 1; i++) {       int x, y, w;       scanf( %d %d %d , &x, &y, &w);       adde(x, y, w), adde(y, x, w);     }     init();     while (m--) {       int l = read();       long long cur = min(dth[n], ans + l);       if (flag) cur = max(cur, dth[n]);       printf( %I64d n , cur);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = (int)7 + (int)1e9;   const int N = 1000005;   const double PI = 4 * atan(1);   const double eps = 1e-10;   const long long oo = 1e10;   const int K = 26;   struct query {     int a, t, x;     query() { a = -1, t = -1, x = -1; }     query(int _a, int _t, int _x) {       a = (_a);       t = (_t);       x = (_x);     }   };   int n;   unordered_map<int, int> ma;   vector<query> qu;   set<int> ss;   set<int> t[N];   unordered_map<int, int> maa[N];   int mx = 1;   int mt = 0;   int sz[N];   vector<int> tree[N];   void update(int val, int pos, int upd) {     for (; pos <= sz[val]; pos += (pos) & (-pos)) {       tree[val][pos] += upd;     }   }   int get(int val, int pos) {     int to = 0;     for (; pos; pos -= (pos) & (-pos)) {       to += tree[val][pos];     }     return to;   }   void ins(int x, int t) { update(x, t, 1); }   void rem(int x, int t) { update(x, t, -1); }   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cin >> n;     for (int i = 0; i < n; i++) {       int x, y, w;       cin >> x >> y >> w;       qu.push_back(query(x, y, w));       ss.insert(w);     }     for (int u : ss) {       ma[u] = mx++;     }     for (query& q : qu) {       q.x = ma[q.x];       t[q.x].insert(q.t);     }     for (int i = 1; i <= mx; i++) {       if (t[i].size() == 0) continue;       mt = 1;       for (int u : t[i]) {         maa[i][u] = mt++;       }       sz[i] = mt;       tree[i].resize(sz[i] + 1);     }     for (query& q : qu) {       q.t = maa[q.x][q.t];     }     for (query q : qu) {       if (q.a == 1) {         ins(q.x, q.t);       } else if (q.a == 2) {         rem(q.x, q.t);       } else {         cout << get(q.x, q.t) << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool comp(pair<int, int> a, pair<int, int> b) {     return (a.first == b.first) ? a.second < b.second : a.first < b.first;   }   long long int modInverse(long long int a) {     long long int m = 1000000007;     long long int y = 0, x = 1;     while (a > 1) {       long long int q = a / m;       long long int t = m;       m = a % m, a = t;       t = y;       y = x - q * y;       x = t;     }     if (x < 0) x += 1000000007;     return x;   }   long long int binpow(long long int a, long long int p) {     if (p == 0) return 1;     long long int ret = binpow(a, p / 2);     ret *= ret;     ret %= 1000000007;     if (p % 2) {       ret *= a;       ret %= 1000000007;     }     return ret;   }   int f[54][54][54][54];   char a[100], b[100];   int n;   bool check(int x, int y) { return (a[x] == a[y] || b[x] == b[y]); }   int dfs(int i, int j, int l, int r) {     if (f[i][j][l][r]) return 0;     if (i == 3) return check(j, r) && check(l, r);     if (check(l, r))       if (dfs(i - 1, i - 3, j, r)) return 1;     if (check(i - 3, r))       if (dfs(i - 1, r, j, l)) return 1;     f[i][j][l][r] = 1;     return 0;   }   void solve() {     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i] >> b[i];     if (n == 1 || dfs(n, n - 2, n - 1, n))       cout <<  YES ;     else       cout <<  NO ;     return;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     int t = 1;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e5 + 2;   long long fact[N];   void factorial() {     fact[0] = fact[1] = 1;     for (long long i = 2; i < N; i++) fact[i] = (fact[i - 1] * i) % 1000000007;   }   long long power(long long a, long long b, long long mod) {     long long x = 1, y = a;     while (b > 0) {       if (b % 2) {         x = (x * y) % mod;       }       y = (y * y) % mod;       b /= 2;     }     return x % mod;   }   long long modular_inverse(long long n, long long mod) {     return power(n, mod - 2, mod);   }   long long nCr(long long n, long long k, long long mod) {     if (k > n)       return 0;     else if (n == k)       return 1;     return (fact[n] * ((modular_inverse(fact[k], 1000000007) *                         modular_inverse(fact[n - k], 1000000007)) %                        mod)) %            mod;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     string s;     cin >> s;     long long int n = s.size(), temp = 0, p = 1, ans = 0;     for (long long int i = 0; i < n; i++) {       temp += s[i] -  0 ;     }     for (long long int i = n - 1; i >= 0; i--) {       temp -= s[i] -  0 ;       ans = (ans + (((p * (n - i)) % 1000000007) * (temp)) % 1000000007) %             1000000007;       ans = (ans + (((((i * (i + 1) / 2) % 1000000007) * p) % 1000000007) *                     (s[i] -  0 )) %                        1000000007) %             1000000007;       p *= 10;       p %= 1000000007;     }     cout << ans;     return 0;   }