malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long inf = 1e18 + 1e17;   const long long mod = 1e9 + 7;   long long modInverse(long long a, long long m) {     long long m0 = m;     long long y = 0, x = 1;     if (m == 1) return 0;     while (a > 1) {       long long q = a / m;       long long t = m;       m = a % m, a = t;       t = y;       y = x - q * y;       x = t;     }     if (x < 0) x += m0;     return x;   }   long long powm(long long a, long long b) {     a = a % mod;     long long res = 1;     while (b) {       if (b & 1) res = (res * a) % mod;       a = (a * a) % mod;       b >>= 1;     }     return (res % mod);   }   const long long N = 3e5 + 6;   struct st {     long long a, b, c, d;   };   bool comp(st x, st y) { return x.a < y.a; }   long long arr[N][2];   long long n, m;   vector<pair<long long, long long> > graph[N];   bool vis[N];   long long ans = 0;   void dijk(long long pos, long long par, long long f) {     for (pair<long long, long long> i : graph[pos])       if (i.first != par) {         arr[i.first][f] = arr[pos][f] + i.second;         dijk(i.first, pos, f);       }   }   void sol() {     vector<st> v;     multiset<long long> s;     for (long long i = 0; i < n; i++) {       v.push_back({arr[i][0] - arr[i][1], arr[i][0], arr[i][1], i});       s.insert(arr[i][1]);     }     sort(v.begin(), v.end(), comp);     for (long long i = 0; i < n - 1; i++) {       s.erase(s.find(v[i].c));       vector<long long> va;       for (pair<long long, long long> j : graph[v[i].d]) {         if (s.find(arr[j.first][1]) != s.end()) {           s.erase(s.find(arr[j.first][1]));           va.push_back(arr[j.first][1]);         }       }       if (s.size() != 0) ans = max(v[i].b + (*s.rbegin()), ans);       for (long long j : va) s.insert(j);     }   }   void solve() {     cin >> n >> m;     for (long long i = 0; i < n; i++) {       arr[i][0] = inf;       arr[i][1] = inf;     }     for (long long i = 0; i < n - 1; i++) {       long long aa, bb, cc;       cin >> aa >> bb >> cc;       aa--;       bb--;       graph[aa].push_back(make_pair(bb, cc));       graph[bb].push_back(make_pair(aa, cc));     }     memset(vis, 0, sizeof(vis));     arr[0][0] = 0;     arr[n - 1][1] = 0;     dijk(0, -1, 0);     dijk(n - 1, -1, 1);     sol();     for (long long i = 0; i < m; i++) {       long long x;       cin >> x;       cout << (min(arr[0][1], ans + x)) <<   n ;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long t = 1;     for (long long i = 1; i <= t; i++) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1000000;   double ans, T, sumb, sumc;   int n, nb, nc;   struct node {     double x, y;     bool operator<(const node &a) const { return y < a.y; }   } a[N], b[N], c[N];   int main() {     scanf( %d%lf , &n, &T);     for (int i = 1; i <= n; i++) scanf( %lf , &a[i].x);     for (int i = 1; i <= n; i++) scanf( %lf , &a[i].y);     sort(a + 1, a + 1 + n);     for (int i = 1; i <= n; i++)       if (a[i].y < T)         b[++nb] = (node){a[i].x, T - a[i].y}, sumb = sumb + b[nb].x * b[nb].y;       else if (a[i].y == T)         ans = ans + a[i].x;       else if (a[i].y > T)         c[++nc] = (node){a[i].x, a[i].y - T}, sumc = sumc + c[nc].x * c[nc].y;     for (int i = 1; i < nb / 2; i++) swap(b[i], b[nb - i + 1]);     double x = min(sumb, sumc);     for (int i = 1; i <= nb; i++)       if (x > 1e-12) {         double y = min(b[i].x, x / b[i].y);         ans += y;         x -= y * b[i].y;       }     x = min(sumb, sumc);     for (int i = 1; i <= nc; i++)       if (x > 1e-12) {         double y = min(c[i].x, x / c[i].y);         ans += y;         x -= y * c[i].y;       }     printf( %.12lf n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a, b, c, d, e, k[30];   string s;   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     cin >> a >> s;     for (b = 1; b < a; b++) {       if (s[b] < s[b - 1]) {         cout <<  YES  << endl;         cout << b <<     << b + 1;         return 0;       }     }     cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e3 + 3, M = 3e4 + 4, inf = 2e9 + 1;   int m, n, s, t, cur, tim, mn;   int low[N], dfn[N], vis[N], cst[M];   vector<pair<int, int> > vt[N];   vector<int> pat, rut, ans;   bool dfs(int u) {     vis[u] = 1;     if (u == t) return 1;     for (int i = 0; i < vt[u].size(); i++) {       int v = vt[u][i].first;       int id = vt[u][i].second;       if (!vis[v] && dfs(v)) {         pat.push_back(id);         return 1;       }     }     return 0;   }   bool tarjan(int u, int p = -1) {     vis[u] = 1;     bool cap = u == t;     low[u] = dfn[u] = ++tim;     for (int i = 0; i < vt[u].size(); i++) {       int v = vt[u][i].first;       int id = vt[u][i].second;       if (id == cur || id == p) continue;       if (vis[v])         low[u] = min(low[u], dfn[v]);       else {         bool flag = tarjan(v, id);         cap = flag || cap;         low[u] = min(low[u], low[v]);         if (flag && low[v] == dfn[v]) rut.push_back(id);       }     }     return cap;   }   int main() {     scanf( %d%d%d%d , &n, &m, &s, &t);     for (int i = 1; i < m + 1; i++) {       int u, v, w;       scanf( %d%d%d , &u, &v, &w);       vt[u].push_back(make_pair(v, i));       vt[v].push_back(make_pair(u, i));       cst[i] = w;     }     if (!dfs(s)) {       puts( 0 n0 n );       return 0;     }     mn = inf;     for (int i = 0; i < pat.size(); i++) {       cur = pat[i];       tim = 0;       memset(vis, 0, sizeof(vis));       rut.clear();       if (!tarjan(s))         if (mn > cst[cur]) {           mn = cst[cur];           ans.clear();           ans.push_back(cur);         }       for (int j = 0; j < rut.size(); j++) {         int sec = rut[j];         if (mn > cst[sec] + cst[cur]) {           mn = cst[sec] + cst[cur];           ans.clear();           ans.push_back(cur);           ans.push_back(sec);         }       }     }     if (mn == inf) {       puts( -1 );       return 0;     }     int len = ans.size();     printf( %d n%d n%d , mn, len, ans[0]);     if (len > 1)       printf(  %d n , ans[1]);     else       puts(  );   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k, l, c, d, p, nl, nd, np, min = 0, totl, totp, res;     cin >> n >> k >> l >> c >> d >> p >> nl >> np;     nd = d * c;     totl = (k * l) / nl;     totp = p / np;     if (totl <= nd && totl <= totp)       min = totl;     else if (nd <= totl && nd <= totp)       min = nd;     else if (totp <= totl && totp <= nd)       min = totp;     res = min / n;     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void __print(int x) { cerr << x; }   void __print(long long x) { cerr << x; }   void __print(unsigned long long x) { cerr << x; }   void __print(long double x) { cerr << x; }   void __print(char x) { cerr << x; }   void __print(const char *x) { cerr << x; }   void __print(const string &x) { cerr << x; }   void __print(bool x) { cerr << (x ?  true  :  false ); }   template <typename T, typename V>   void __print(const pair<T, V> &x) {     cerr <<  { ;     __print(x.first);     cerr <<  ,  ;     __print(x.second);     cerr <<  } ;   }   template <typename T>   void __print(const T &x) {     int f = 0;     cerr <<  { ;     for (auto &i : x) {       cerr << (f++ ?  ,   :   );       __print(i);     }     cerr <<  } ;   }   void _print() { cerr <<  ] n ; }   template <typename T, typename... V>   void _print(T t, V... v) {     __print(t);     if (sizeof...(v)) {       cerr <<  ,  ;     }     _print(v...);   }   string go(long long i, long long n, long long dist, string nw, long long k,             string ori) {     ;     if (dist > k) {       return   ;     }     if (nw.substr(0, i) < ori.substr(0, i)) {       return   ;     }     if (i >= n) {       return nw;     }     for (char val =  0 ; val <=  9 ; ++val) {       nw[i] = val;       bool found = false;       for (long long j = 0; j < i; ++j) {         if (nw[j] == val) {           found = true;           break;         }       }       string chk = go(i + 1, n, dist + (found == false), nw, k, ori);       if ((long long)chk.size()) {         return chk;       }     }     return   ;   }   void solve() {     long long n, k;     cin >> n >> k;     string s = to_string(n);     long long dist = 0;     map<char, long long> g;     for (auto ch : s) {       g[ch]++;     }     string ans =         go(0, (long long)s.size(), 0, string((long long)s.size(),  0 ), k, s);     cout << ans <<   n ;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long t = 1;     cin >> t;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> a;   int64_t func(int64_t c) {     int64_t cost = 0, pc = 1;     for (int ai : a) {       long long diff = ai - pc;       cost += abs(diff);       if (pc > LLONG_MAX / c) return LLONG_MAX;       pc *= c;     }     return cost;   }   int main(void) {     int n;     cin >> n;     int64_t ans = 0;     a.resize(n);     for (int& ai : a) {       cin >> ai;       ans += abs(ai - 1);     }     sort(a.begin(), a.end());     int64_t l = 2, r = 1e5;     while (r - l > 3) {       int64_t m1 = l + (r - l) / 3;       int64_t m2 = r - (r - l) / 3;       int64_t c1 = func(m1);       int64_t c2 = func(m2);       ans = min(ans, c1);       ans = min(ans, c2);       if (c1 > c2)         l = m1;       else         r = m2;     }     for (int64_t i = l; i <= r; i++) ans = min(ans, func(i));     cout << ans <<   n ;   }
#include <iostream>      using namespace std;      const int N = 210;       int a[N];    int main()   {    int t,i,j,k,n,s1=0,s0=0;     cin >> t;     while(t--)    {        cin>>n;        s1=0;s0=0;        for(i=0;i<2*n;i++)            cin>>a[i];        for(i=0;i<2*n;i++)            {                if(a[i]%2==1)s1++;                else s0++;            }            if(s1==s0)puts( Yes n );            else puts( No n );                }    return 0;    }
#include <bits/stdc++.h>   using namespace std;   const long long mxn = 1e5 + 7;   int main() {     int n, a[mxn], q, l[mxn], r[mxn], x;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     for (int i = 1; i <= n; i++) {       if (i == 1) {         l[i] = 1;         r[i] = a[i];       } else {         l[i] = r[i - 1] + 1;         r[i] = a[i] + r[i - 1];       }     }     cin >> q;     for (int i = 1; i <= q; i++) {       int l1 = 0, r1 = n, x;       cin >> x;       while (r1 - l1 > 1) {         int m = (l1 + r1) >> 1;         if (r[m] >= x)           r1 = m;         else           l1 = m;       }       cout << r1 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int xs[2123], ys[2123], bs[2123];   long long fat[2123], prefix[2123][2123];   long long fatinv[2123];   long long sum(int row1, int row2, int col1, int col2) {     if (row1 > row2 || col1 > col2) return 0ll;     row2 = min(row2, 2000);     col2 = min(col2, 2000);     --row1, --col1;     if (row1 < 0) row1 = 0;     if (col1 < 0) col1 = 0;     if (row2 <= row1 or col2 <= col1) return 0ll;     return prefix[row2][col2] - prefix[row2][col1] - prefix[row1][col2] +            prefix[row1][col1];   }   long long sumR(int i, int r) {     return sum(xs[i] - r, xs[i] + r, ys[i] - r, ys[i] + r);   }   long long fastexp(long long a, long long b, long long m) {     long long r = 1;     for (a %= m; b; b >>= 1, a = (a * a) % m)       if (b & 1) r = (r * a) % m;     return r;   }   long long comb(int n, int k) {     if (n < k) return 0ll;     return (((fat[n] * fatinv[k]) % 1000000007) * fatinv[n - k]) % 1000000007;   }   int main() {     fat[0] = 1;     for (int i = 1; i < 2123; ++i) fat[i] = (fat[i - 1] * i) % 1000000007;     int n, m, r;     cin >> n >> m >> r;     for (int i = 0; i < 2123; ++i)       fatinv[i] = fastexp(fat[i], 1000000007 - 2, 1000000007);     for (int i = 0; i < n; ++i) {       cin >> xs[i] >> ys[i] >> bs[i];       prefix[xs[i]][ys[i]] = 1;     }     for (int i = 1; i < 2123; ++i) {       for (int j = 1; j < 2123; ++j) {         prefix[i][j] +=             prefix[i - 1][j] + prefix[i][j - 1] - prefix[i - 1][j - 1];       }     }     long long resp = 0ll;     for (int i = 0; i < n; ++i) {       for (int j = 0; j < n; ++j) {         int row1 = xs[i] - r;         int row2 = xs[i] + r;         int col1 = ys[i] - r;         int col2 = ys[i] + r;         row1 = max(row1, xs[j] - r);         row2 = min(row2, xs[j] + r);         col1 = max(col1, ys[j] - r);         col2 = min(col2, ys[j] + r);         long long s = sum(row1, row2, col1, col2);         long long si = sumR(i, r);         long long sj = sumR(j, r);         long long diff = si + sj - s;         long long count = (((comb(n, m) - comb(n - si, m) - comb(n - sj, m) +                              comb(n - diff, m)) %                             1000000007) *                            bs[i]) %                           1000000007;         resp = (resp + (count * bs[j]) % 1000000007) % 1000000007;       }     }     if (resp < 0) resp += 1000000007;     cout << resp <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[10], flag[200];   int main() {     int sum = 0;     for (int i = 1; i <= 5; i++) {       cin >> a[i];       sum += a[i];       flag[a[i]]++;     }     int ans = sum;     for (int i = 1; i <= 5; i++) {       if (flag[a[i]] > 1 && flag[a[i]] < 4)         ans = min(ans, sum - flag[a[i]] * a[i]);       else if (flag[a[i]] > 3) {         ans = min(ans, sum - 3 * a[i]);       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   namespace p316GGoodSubstrings {   template <size_t MAXLEN, size_t ALPHABET>   struct SuffixAutomaton {     struct Node {       Node *child[ALPHABET], *suff, *next;       int len, cnt;     };     Node pool[2 * MAXLEN], *root, *nextnode, *last, *first[MAXLEN + 1];     Node* makenode(int length) {       memset(nextnode, 0, sizeof(Node));       nextnode->len = length;       return nextnode++;     }     void init() {       nextnode = pool;       last = root = makenode(0);       memset(first, 0, sizeof(first));     }     void extend(int ch) {       Node *p = last, *cur = makenode(p->len + 1);       cur->cnt = 1;       for (; p != NULL && p->child[ch] == NULL; p = p->suff) p->child[ch] = cur;       if (p == NULL)         cur->suff = root;       else {         Node* q = p->child[ch];         if (p->len + 1 == q->len)           cur->suff = q;         else {           Node* copy = makenode(p->len + 1);           memcpy(copy->child, q->child, sizeof(q->child));           copy->suff = q->suff;           q->suff = cur->suff = copy;           for (; p != NULL && p->child[ch] == q; p = p->suff) p->child[ch] = copy;         }       }       last = cur;     }     void go() {       for (Node* i = pool; i < nextnode; i++) {         i->next = first[i->len];         first[i->len] = i;       }       for (int len = MAXLEN; len > 0; len--)         for (Node* i = first[len]; i != NULL; i = i->next) i->suff->cnt += i->cnt;     }   };   struct TNode {     TNode* ch[26];     bool bad;     TNode() : bad(false) { memset(ch, 0, sizeof(ch)); }   };   SuffixAutomaton<55555, 26> sam;   TNode* root;   char str[55555];   int l, r, res = 0;   void go(TNode* at, SuffixAutomaton<55555, 26>::Node* cur) {     int cnt = cur ? cur->cnt : 0;     if (cnt < l || cnt > r) at->bad = true;     for (int c = 0; c < 26; c++)       if (at->ch[c] != NULL)         go(at->ch[c], cur && cur->child[c] ? cur->child[c] : NULL);   }   void dfs(TNode* at) {     if (!at->bad) res++;     for (int c = 0; c < 26; c++)       if (at->ch[c]) dfs(at->ch[c]);   }   void solve(int test_num) {     root = new TNode();     scanf( %s , str);     int len = strlen(str);     for (int i = 0; i < len; i++) {       TNode* at = root;       for (int j = i, c; j < len; j++) {         c = str[j] -  a ;         if (at->ch[c] == NULL) at->ch[c] = new TNode();         at = at->ch[c];       }     }     int cnt;     scanf( %d , &cnt);     for (int q = 0; q < cnt; q++) {       scanf( %s %d %d , str, &l, &r);       sam.init();       for (int i = 0; str[i] >    ; i++) sam.extend(str[i] -  a );       sam.go();       go(root, sam.root);     }     dfs(root);     if (!root->bad) res--;     cout << res << endl;   }   void solve() { solve(1); }   }  // namespace p316GGoodSubstrings   int main() {     p316GGoodSubstrings::solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const long long LINF = 0x3f3f3f3f3f3f3f3f;   const int mod = 1e9 + 7;   const double PI = acos(-1.0);   const double eps = 1e-10;   const int N = 3e5 + 5;   int n, m, d[N];   vector<pair<int, int> > g[N];   vector<int> vec;   bool vis[N];   void dfs(int u) {     vis[u] = true;     for (auto &e : g[u]) {       int &v = e.first;       if (vis[v]) continue;       dfs(v);       if (d[v] == 1) {         if (~d[u]) d[u] ^= 1;         d[v] = 0, vec.push_back(e.second);       }     }   }   int main() {     scanf( %d %d , &n, &m);     int s = 1;     for (int i = 1; i <= n; i++) {       scanf( %d , d + i);       if (d[i] == -1) s = i;     }     for (int i = 1, u, v; i <= m; i++) {       scanf( %d %d , &u, &v);       g[u].push_back(pair<int, int>(v, i));       g[v].push_back(pair<int, int>(u, i));     }     dfs(s);     if (~d[s] && d[s]) {       puts( -1 );       return 0;     }     printf( %d n , vec.size());     for (int id : vec) printf( %d n , id);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   T sqr(T x) {     return x * x;   }   long double pi = 3.1415926535897932384626433832795;   const int N = 5e5 + 10, lg = 20;   int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }   int main() {     long long a, b, c;     cin >> a >> b >> c;     if (c == 0) {       if (a != b)         cout <<  NO ;       else         cout <<  YES ;       return 0;     }     if (a == b || ((a > b && c < 0) && (a - b) % (-c) == 0) ||         ((a < b && c > 0) && (b - a) % c == 0))       cout <<  YES ;     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int check(vector<long long> &a, long long q) {     multiset<long long> s;     for (int j = 0; j < n; ++j) {       if (q + a[j] >= 0) {         q += a[j];         s.insert(a[j]);       } else if (a[j] > (*s.begin())) {         q += (a[j] - (*s.begin()));         s.erase(s.begin());         s.insert(a[j]);       }     }     return s.size();   }   int main() {     ios::sync_with_stdio(false);     cin >> n >> m;     vector<pair<long long, int> > b(m);     vector<int> out(m);     vector<long long> a(n);     for (int i = 0; i < n; ++i) {       cin >> a[i];     }     for (int i = 0; i < m; ++i) {       cin >> b[i].first;       b[i].second = i;     }     sort(b.begin(), b.end());     int pre = -1, li = 0;     for (int i = 0; i <= n && pre != m - 1; ++i) {       int l = pre + 1, h = m - 1;       while (l < h) {         int md = (h + l) >> 1;         if (check(a, b[md].first) >= i) {           h = md;         } else {           l = md + 1;         }       }       if (check(a, b[l].first) != i) {         continue;       }       for (int j = pre + 1; j < l; ++j) {         out[b[j].second] = n - li;       }       li = i;       out[b[l].second] = n - i;       pre = l;     }     while (pre != m) {       out[b[pre++].second] = n - li;     }     for (int i = 0; i < m; ++i) {       cout << out[i] <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool life[1000005];   int main() {     long long a, b;     int l, r, mid;     int ans, cnt = 0;     scanf( %lld%lld , &a, &b);     l = 0;     r = 1000000007;     while (l != r) {       mid = (r + l + 1) / 2;       if (((mid + 1LL) * mid) / 2 > a + b)         r = mid - 1;       else         l = mid;     }     ans = l;     for (int i = l; i > 0; i--) {       if (a >= i) {         a -= i;         life[i] = 1;         cnt++;       }     }     printf( %d n , cnt);     if (cnt) {       for (int i = 1; i <= l; i++) {         if (life[i]) printf( %d  , i);       }       printf(  n );     }     printf( %d n , ans - cnt);     if (ans - cnt) {       for (int i = 1; i <= l; i++) {         if (!life[i]) printf( %d  , i);       }       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int addingval[100];   long long int lastOcc[100];   long long int wt[100];   long long int cum[100005];   map<long long int, long long int> mp[100];   int main() {     for (int i = 0; i < 26; ++i) cin >> wt[i];     string s;     cin >> s;     int sz = s.size();     s =  $  + s;     long long int cnt = 0;     for (int i = 1; i <= sz; ++i) {       char c = s[i] -  a ;       cum[i] = cum[i - 1] + wt[c];       cnt += mp[c][cum[i - 1]];       mp[c][cum[i]]++;     }     cout << cnt;   }
#include <bits/stdc++.h>   using namespace std;   int a[26][26];   int main() {     int n;     cin >> n;     memset(a, 0, sizeof(a));     char ch[20];     int len;     for (int i = 1; i <= n; i++) {       scanf(  %s , ch);       for (len = 0; ch[len]; len++)         ;       for (int j = 0; j < 26; j++)         if (a[j][ch[0] -  a ]) {           a[j][ch[len - 1] -  a ] =               max(a[j][ch[len - 1] -  a ], a[j][ch[0] -  a ] + len);         }       a[ch[0] -  a ][ch[len - 1] -  a ] =           max(a[ch[0] -  a ][ch[len - 1] -  a ], len);     }     int ans = 0;     for (int i = 0; i < 26; i++) ans = max(ans, a[i][i]);     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1 << 20;   int bio[MAX];   vector<int> V[MAX];   int a[MAX], b[MAX];   int deg[MAX];   void dfs(int x) {     if (bio[x]++) return;     for (auto it : V[x]) dfs(it);   }   int main() {     int n, m;     scanf( %d%d , &n, &m);     int usebe = 0;     for (int i = 0; i < m; i++) {       scanf( %d%d , &a[i], &b[i]);       a[i]--;       b[i]--;       V[a[i]].push_back(b[i]);       V[b[i]].push_back(a[i]);       if (a[i] == b[i])         usebe++;       else {         deg[a[i]]++;         deg[b[i]]++;       }     }     for (int i = 0; i < n; i++) {       if (V[i].size()) {         dfs(i);         break;       }     }     for (int i = 0; i < n; i++)       if (!bio[i] && V[i].size()) {         printf( 0 n );         return 0;       }     long long rje = 0;     rje += (long long)usebe * (usebe - 1) / 2;     rje += (long long)usebe * (m - usebe);     for (int i = 0; i < n; i++) rje += (long long)deg[i] * (deg[i] - 1) / 2;     printf( %lld n , rje);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5;   int n, m;   int fir[N + 10][2], nex[N + 10][2], tot[2], en[N + 10][2];   int tag[N + 10][2], vis[N + 10];   void addEdge(int x, int y, int p) {     tot[p]++;     nex[tot[p]][p] = fir[x][p];     fir[x][p] = tot[p];     en[tot[p]][p] = y;   }   void dfs1(int x) {     vis[x] = 1;     for (int tmp = fir[x][0]; tmp > 0; tmp = nex[tmp][0]) {       int y = en[tmp][0];       if (vis[y] == 0) {         dfs1(y);       } else if (vis[y] == 1) {         puts( -1 );         exit(0);       }     }     vis[x] = 2;   }   void dfs2(int x, int p) {     if (tag[x][p] == 1) {       return;     }     tag[x][p] = 1;     for (int tmp = fir[x][p]; tmp > 0; tmp = nex[tmp][p]) {       int y = en[tmp][p];       if (tag[y][p] == 0) {         dfs2(y, p);       }     }   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; i++) {       int x, y;       scanf( %d%d , &x, &y);       addEdge(x, y, 0);       addEdge(y, x, 1);     }     for (int i = 1; i <= n; i++)       if (vis[i] == 0) {         dfs1(i);       }     string ans =   ;     int cnta = 0;     for (int i = 1; i <= n; i++) {       if (tag[i][0] == 0 && tag[i][1] == 0) {         ans +=  A ;         cnta++;       } else {         ans +=  E ;       }       dfs2(i, 0);       dfs2(i, 1);     }     printf( %d n , cnta);     printf( %s n , ans.c_str());     return 0;   }