malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   struct State {     int bk;     string fr;     int pos;     int cnt;   };   bool operator<(State lhs, State rhs) {     if (lhs.bk != rhs.bk) return lhs.bk < rhs.bk;     if (lhs.fr != rhs.fr) return lhs.fr < rhs.fr;     if (lhs.pos != rhs.pos) return lhs.pos < rhs.pos;     if (lhs.cnt != rhs.cnt) return lhs.cnt < rhs.cnt;     return false;   }   int main() {     int n;     cin >> n;     string s;     cin >> s;     vector<int> jump(s.size() + 1, 0);     for (int i = 0; i <= s.size(); i++) {       int to = 0;       for (int j = 0; j < i; j++) {         bool ok = true;         for (int k = 0; k < j; k++) {           ok &= (s[k] == s[i - j + k]);         }         if (i != s.size()) ok &= (s[j] != s[i]);         if (ok) to = j + 1 - (int)(i == s.size());       }       jump[i] = to;     }     set<string> subs;     for (int i = 0; i < s.size(); i++) {       for (int j = i + 1; j <= s.size(); j++) {         string ss;         for (int k = i; k < j; k++) {           ss += s[k];         }         subs.insert(ss);       }     }     set<string> lasts;     string ss;     for (int i = s.size() - 1; i >= 0; i--) {       ss = s[i] + ss;       lasts.insert(ss);     }     map<State, ll> dp;     dp[State{-1,   , 0, 0}] = 1;     for (int i = 0; i < n; i++) {       map<State, ll> next;       for (auto &e : dp) {         int bk = e.first.bk;         string str = e.first.fr;         int pos = e.first.pos;         int cnt = e.first.cnt;         if (str !=  @ ) {           str += s[pos];           if (subs.count(str)) {             if (lasts.count(str)) {               bk = i;             }           } else {             str =  @ ;           }         }         if (++pos == s.size()) {           pos = jump[pos];           cnt = true;         }         next[State{bk, str, pos, cnt}] += e.second;         bk = e.first.bk;         str = e.first.fr;         pos = e.first.pos;         cnt = e.first.cnt;         if (str !=  @ ) {           str += (s[pos] ==  0  ?  1  :  0 );           if (subs.count(str)) {             if (lasts.count(str)) {               bk = i;             }           } else {             str =  @ ;           }         }         pos = jump[pos];         next[State{bk, str, pos, cnt}] += e.second;       }       dp = next;     }     ll res = 0;     for (auto &e : dp) {       int bk = e.first.bk;       string strs = e.first.fr;       int pos = e.first.pos;       int cnt = e.first.cnt;       string str;       for (int i = 0; i < e.first.pos; i++) {         str += s[i];       }       for (int i = s.size() - e.first.bk - 1; i < s.size(); i++) {         str += s[i];       }       for (int i = 0; i <= (int)str.size() - (int)s.size(); i++) {         if (s == str.substr(i, s.size())) {           cnt = true;         }       }       if (cnt >= 1) {         res += e.second;       }     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using lli = long long int;   using pii = pair<int, int>;   using vi = vector<int>;   using vb = vector<bool>;   using vvi = vector<vector<int>>;   using vlli = vector<long long int>;   using vpii = vector<pair<int, int>>;   const int N = 200005;   const int blockSize = sqrt(N);   lli n, t, l, r, x, idx, L, R, res;   vlli a, ans, cnt(1000005);   vector<tuple<lli, lli, lli, lli>> q;   int get(int idx) { return idx / blockSize; }   void add(lli x) { res += x * (2 * (cnt[x]++) + 1); }   void del(lli x) { res += x * (-2 * (cnt[x]--) + 1); }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> t;     a.resize(n);     ans.resize(t);     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < t; i++) {       cin >> l >> r;       l--;       r--;       q.push_back(make_tuple(get(l), r, l, i));     }     sort((q).begin(), (q).end());     L = R = 0;     add(a[0]);     for (int i = 0; i < t; i++) {       tie(ignore, r, l, idx) = q[i];       while (L < l) del(a[L++]);       while (L > l) add(a[--L]);       while (R < r) add(a[++R]);       while (R > r) del(a[R--]);       ans[idx] = res;     }     for (int i = 0; i < t; i++) cout << ans[i] <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   long long bigmod(long long a, int p, long long int m) {     if (p == 0) return 1;     if (p & 1) {       return ((a % m) * (bigmod(a, p - 1, m))) % m;     } else {       long long tmp = bigmod(a, p / 2, m);       return (tmp * tmp) % m;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int n;     cin >> n;     pair<long long int, long long int> p[n];     for (long long int i = 0; i < n; i++) {       long long int x;       cin >> x;       p[i].first = -x;       p[i].second = i;     }     sort(p, p + n);     vector<long long int> v[n];     vector<pair<long long int, long long int> > p1;     for (long long int i = 0; i < n; i++) {       p1.push_back(make_pair(p[i].second, p[i].first));       sort(p1.begin(), p1.end());       for (long long int t = 0; t < p1.size(); t++) {         v[i].push_back(-p1[t].second);       }     }     long long int m;     cin >> m;     while (m--) {       long long int a;       cin >> a;       long long int b;       cin >> b;       cout << v[a - 1][b - 1];       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 3e-5;   double x, h, l;   int main() {     scanf( %lf , &x);     for (double h = 1; h <= 10 + eps; h++) {       if (h + eps < x) continue;       l = h / (sqrt((h * h) / (x * x) - 1)) * 2.0;       for (double q = 1; q <= 10 + eps; q++)         if (l - q < eps && q - l < eps) {           printf( %d %d , (int)q, (int)h);           return 0;         }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, a[10], b[10];     cin >> n >> m;     for (int i = 0; i < n; i++) {       cin >> a[i];     }     for (int i = 0; i < m; i++) {       cin >> b[i];     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (a[i] == b[j]) {           printf( %d , a[i]);           if (i != n - 1) printf(   );         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MID = 1e5;   const int MAX = 1e9;   int main() {     int n;     cin >> n;     if (n % 2) {       cout << n - 9 <<     << 9;     } else {       cout << n - 8 <<     << 8;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 7, M = 2e5 + 7;   int n, m, k, t;   vector<int> b;   struct Node {     int in, out;     long long h;     Node() {}     Node(int i, int o, long long _h) : in(i), out(o), h(_h) {}   } a[N];   bool operator<(const Node &a, const Node &b) {     if (a.out == b.out) return a.in < b.in;     return a.out < b.out;   }   long long fen[M];   void add(int i, long long v) {     for (; i <= (int)b.size(); i += i & -i) fen[i] = max(fen[i], v);   }   long long get(int i) {     long long res = 0;     for (; i > 0; i -= i & -i) res = max(res, fen[i]);     return res;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d%d%lld , &a[i].in, &a[i].out, &a[i].h);       b.push_back(a[i].in), b.push_back(a[i].out);     }     sort(a + 1, a + n + 1);     sort(b.begin(), b.end()),         b.resize((int)(unique(b.begin(), b.end()) - b.begin()));     for (int i = n; i > 0; i--) {       k = (lower_bound(b.begin(), b.end(), a[i].out) - b.begin()) + 1;       t = (lower_bound(b.begin(), b.end(), a[i].in) - b.begin()) + 1;       add(t, get(k - 1) + a[i].h);     }     printf( %lld , get((int)b.size()));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n;     cin >> n;     if (n % 3 == 0) {       cout << n / 3 * 2;     }     if (n % 3 > 0) {       cout << (n - 1) / 3 * 2 + 1;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n, m;     cin >> n >> m;     vector<long long> vect;     vect.assign(n, 0);     long long ans = 0;     for (int i = 0; i < n; i++) cin >> vect[i];     for (int i = 0; i < m; i++) {       int a, b;       cin >> a >> b;       ans += min(vect[a - 1], vect[b - 1]);     }     cout << ans << endl;     return;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     solve();   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline T bigmod(T p, T e, T M) {     T ret = 1;     for (; e > 0; e >>= 1) {       if (e & 1) ret = (ret * p) % M;       p = (p * p) % M;     }     return (T)ret;   }   template <class T>   inline T gcd(T a, T b) {     if (b == 0) return a;     return gcd(b, a % b);   }   template <class T>   inline T modinverse(T a, T M) {     return bigmod(a, M - 2, M);   }   template <class T>   inline T lcm(T a, T b) {     a = abs(a);     b = abs(b);     return (a / gcd(a, b)) * b;   }   template <class T, class X>   inline bool getbit(T a, X i) {     T t = 1;     return ((a & (t << i)) > 0);   }   template <class T, class X>   inline T setbit(T a, X i) {     T t = 1;     return (a | (t << i));   }   template <class T, class X>   inline T resetbit(T a, X i) {     T t = 1;     return (a & (~(t << i)));   }   inline long long power(long long a, long long b) {     long long multiply = 1;     for (int i = (1); i <= (b); i++) {       multiply *= a;     }     return multiply;   }   inline long long ABS(long long a) { return (a >= 0) ? a : -a; }   long long n, in, m;   map<long long, vector<long long> > mp;   pair<long long, long long> fact[200003];   int main() {     scanf( %lld , &n);     for (int i = (1); i <= (n); i++) {       scanf( %lld , &in);       mp[in].push_back(i);     }     for (int i = (1); i <= (n); i++) {       scanf( %lld , &in);       mp[in].push_back(i);     }     scanf( %lld , &m);     fact[0] = make_pair(1, 0);     long long ans = 1, cnt, temp;     for (long long i = (1); i <= (200000); i++) {       temp = i;       cnt = 0;       while (temp % 2 == 0) {         temp /= 2;         cnt++;       }       fact[i].first = (fact[i - 1].first * temp) % m;       fact[i].second = cnt + fact[i - 1].second;     }     vector<long long> v;     for (__typeof((mp).begin()) it = (mp).begin(); it != (mp).end(); it++) {       v = it->second;       if (v.size() == 1) continue;       sort(v.begin(), v.end());       ans *= fact[v.size()].first;       ans %= m;       cnt = 0;       for (int i = (1); i <= (v.size() - 1); i++) {         if (v[i] == v[i - 1]) cnt++;       }       ans *= bigmod(2LL, fact[v.size()].second - cnt, m);       ans %= m;     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int u, s;     node() { u = s = 0; }     bool operator<(const node &temp) const {       if (this->s < temp.s) return 1;       return 0;     }   };   node black[100005];   node white[100005];   vector<vector<node> > adj;   int main() {     int n;     scanf( %d , &n);     adj.resize(n);     bool allzero = true;     int w, b;     w = b = 0;     for (int i = 0; i < n; ++i) {       int c;       scanf( %d , &c);       if (c == 0) {         white[w].u = i;         scanf( %d , &white[w].s);         if (white[w].s) allzero = false;         ++w;       } else {         black[b].u = i;         scanf( %d , &black[b].s);         if (black[b].s) allzero = false;         ++b;       }     }     if (allzero) {       if (w < b) {         for (int i = 0; i < b; ++i)           cout << white[0].u + 1 <<     << black[i].u + 1 <<     << 0 << endl;         for (int i = 1; i < w; ++i)           cout << white[i].u + 1 <<     << black[i].u + 1 <<     << 0 << endl;       } else {         for (int i = 0; i < w; ++i)           cout << black[0].u + 1 <<     << white[i].u + 1 <<     << 0 << endl;         for (int i = 1; i < b; ++i)           cout << black[i].u + 1 <<     << white[i].u + 1 <<     << 0 << endl;       }       return 0;     }     sort(black, black + b);     sort(white, white + w);     for (int indb = 0, indw = 0; indb < b && indw < w;) {       if (white[indw].s < black[indb].s) {         black[indb].s -= white[indw].s;         adj[black[indb].u].push_back(white[indw]);         ++indw;       } else {         white[indw].s -= black[indb].s;         adj[white[indw].u].push_back(black[indb]);         ++indb;       }     }     for (int i = 0; i < n; ++i) {       for (int j = 0; j < adj[i].size(); ++j) {         printf( %d %d %d n , i + 1, adj[i][j].u + 1, adj[i][j].s);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<string> vs, vs2;   set<string> st;   map<string, int> mp, mp1;   long long i, j, k, x, y, m, n, a, b, c, d, e, f, g, h, l, o, p, q, t, u, v, w,       z, r, ln, neg, pos, sm, ar[500000 + 5], br[500000 + 5], fr[60], cnt;   string s, s1, s2, s3;   int main() {     while (getline(cin, s)) {       ln = s.size();       long long in = 0;       for (int i =  z ; i >=  a ; i--) {         for (j = in; j < ln; j++) {           if (i == (int)s[j]) {             in = max(in, j);             cout << s[j];           }         }       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e6 + 22;   const int INF = 1e9 + 2;   long long n, ans, mark[MAXN];   char str[MAXN];   int main() {     cin >> n;     cin >> str;     for (int i = 0; i < n; i++) {       if (mark[str[i]] == 0) {         mark[str[i]] = 1;         ans++;       }     }     if (n > 26)       cout << -1;     else       cout << n - ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using LL = long long;   using DD = long double;   using pii = pair<int, int>;   const LL INFLL = 0x7f7f7f7f7f7f7f7fLL;   const int INFint = 0x7f7f7f7f;   LL exactMatchingSubranges(vector<int> &cumulative, int match) {     LL rr = 0;     for (int i = 0; i < int((int((cumulative).size()))); ++i) {       int looking_for = match ^ cumulative[i];       int p = lower_bound((cumulative).begin(), (cumulative).end(), looking_for) -               cumulative.begin();       int q = upper_bound((cumulative).begin(), (cumulative).end(), looking_for) -               cumulative.begin();       rr += q - p;     }     return rr;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.precision(16);     int n, k;     cin >> n >> k;     vector<int> aa(n, 0);     for (int i = 0; i < int(n); ++i) cin >> aa[i];     vector<int> cumulative((int((aa).size())), 0);     cumulative[0] = aa[0];     int amax = 0;     for (int i = int(1); i < int((int((aa).size()))); ++i) {       cumulative[i] = cumulative[i - 1] ^ aa[i];       amax = max(amax, aa[i]);     }     cumulative.push_back(0);     sort((cumulative).begin(), (cumulative).end());     LL rr = exactMatchingSubranges(cumulative, k);     while (true) {       if ((k & 1) == 0) {         k |= 1;         rr += exactMatchingSubranges(cumulative, k);       }       k >>= 1;       amax >>= 1;       if (amax == 0) break;       for (int i = 0; i < int((int((cumulative).size()))); ++i)         cumulative[i] >>= 1;     }     cout << rr / 2 <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 5, maxm = 4e5 + 5;   int head[maxn], nume;   struct edge {     int v, w, c, next;   } e[maxm];   inline void init_edge() {     memset(head, -1, sizeof head);     nume = 0;   }   inline void add_edge(int u, int v, int w = 0, int c = 0) {     e[nume].v = v;     e[nume].w = w;     e[nume].c = c;     e[nume].next = head[u];     head[u] = nume++;   }   int dep[maxn], dp[maxn][20], numpow = 19;   void dfs(int u, int f) {     dep[u] = dep[f] + 1;     dp[u][0] = f;     for (int i = 1; i <= numpow; ++i) dp[u][i] = dp[dp[u][i - 1]][i - 1];     for (int i = head[u]; ~i; i = e[i].next) {       int v = e[i].v;       if (v == f) continue;       dfs(v, u);     }   }   int lca(int u, int v) {     if (dep[u] > dep[v]) swap(u, v);     if (dep[u] < dep[v]) {       int tmp = dep[v] - dep[u];       for (int i = 0; i <= numpow; ++i)         if (tmp & (1 << i)) v = dp[v][i];     }     if (u != v) {       for (int i = numpow; ~i; --i)         if (dp[u][i] != dp[v][i]) u = dp[u][i], v = dp[v][i];       u = v = dp[u][0];     }     return u;   }   int ff(int u, int num) {     for (int i = 0; (1 << i) <= num; i++) {       if (num & (1 << i)) u = dp[u][i];     }     return u;   }   int f[maxn];   int find(int x) {     if (x == f[x]) return x;     return f[x] = find(f[x]);   }   int he(int u, int v) {     u = find(u);     v = find(v);     if (u != v) f[u] = v;   }   queue<int> que;   int n, k, r, q;   int vis[maxn];   int main() {     scanf( %d%d%d , &n, &k, &r);     init_edge();     for (int i = 1; i < n; i++) {       int u, v;       scanf( %d%d , &u, &v);       add_edge(u, v);       add_edge(v, u);     }     memset(vis, -1, sizeof vis);     for (int i = 1; i <= r; i++) {       int u;       scanf( %d , &u);       vis[u] = 0;       que.push(u);     }     while (!que.empty()) {       int u = que.front();       que.pop();       for (int i = head[u]; ~i; i = e[i].next) {         int v = e[i].v;         if (vis[v] == -1) {           vis[v] = vis[u] + 1;           que.push(v);         }       }     }     for (int i = 1; i <= n; i++) f[i] = i;     for (int u = 1; u <= n; u++) {       for (int i = head[u]; ~i; i = e[i].next) {         int v = e[i].v;         if (vis[u] + vis[v] < k) {           he(u, v);         }       }     }     dfs(1, 0);     scanf( %d , &q);     while (q--) {       int u, v, Lca, U, V;       scanf( %d%d , &u, &v);       Lca = lca(u, v);       if (dep[u] + dep[v] - 2 * dep[Lca] <= k)         printf( YES n );       else {         if (dep[u] - dep[Lca] >= (k + 1) / 2)           U = ff(u, (k + 1) / 2);         else           U = ff(v, dep[u] + dep[v] - 2 * dep[Lca] - (k + 1) / 2);         if (dep[v] - dep[Lca] >= (k + 1) / 2)           V = ff(v, (k + 1) / 2);         else           V = ff(u, dep[u] + dep[v] - 2 * dep[Lca] - (k + 1) / 2);         if (find(U) == find(V) && vis[U] <= k / 2 && vis[V] <= k / 2)           printf( YES n );         else           printf( NO n );       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int k, n, w, q, cem = 0;     cin >> k >> n >> w;     for (int i = 1; i <= w; i++) {       cem = cem + i * k;     }     if (n <= cem) {       cout << cem - n;     } else       cout << 0;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int cnt_occur(string s, string t) {     int cnt = 0;     for (int i = 0; i < s.size(); ++i) {       if (s.substr(i, 3) == t) cnt++;     }     return cnt;   }   long max(int a, int b) { return a >= b ? a : b; }   void swap(int &a, int &b) {     int temp = a;     a = b;     b = temp;   }   int power(int x, unsigned int y) {     int temp;     if (y == 0) return 1;     temp = power(x, y / 2);     if (y % 2 == 0)       return temp * temp;     else       return x * temp * temp;   }   int gcd(int a, int b) {     if (b == 0) return a;     return gcd(b, a % b);   }   void soE(int n, bool f[]) {     for (int i = 0; i < n; ++i) f[i] = true;     f[0] = f[1] = false;     for (int p = 2; p * p <= n; p++) {       if (f[p] == true) {         for (int i = p * p; i <= n; i += p) f[i] = false;       }     }   }   int main() {     ios::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     int t;     cin >> t;     ;     while (t--) {       long long a;       cin >> a;       long long cnt = 0;       long long temp = a;       while (a) {         if (temp % 2 == 0) {           if (a % 2 == 0) {             if ((a / 2) % 2 != 0 or a == 4) {               cnt += a / 2;               if (a == 4) {                 a = a / 2;               } else                 a = a / 2 - 1;             } else {               cnt += 1;               a -= 2;             }           }         } else {           if (a == 5) {             cnt += 2;             break;           }           cnt += 1;           a = a - 1;           if (a == 0) break;           if ((a / 2) % 2 == 0)             a -= 1;           else             a = a / 2;         }       }       cout << cnt << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void RI() {}   template <typename... T>   void RI(int& head, T&... tail) {     scanf( %d , &head);     RI(tail...);   }   void RLL() {}   template <typename... T>   void RLL(long long& head, T&... tail) {     scanf( %lld , &head);     RLL(tail...);   }   void print() { putchar(  n ); }   template <typename T, typename... U>   void print(T head, U... tail) {     cout << head <<    ;     print(tail...);   }   const int MOD = 1000000007;   int main() {     int k, ans = 0;     RI(k);     for (int i = 0; i < (int)(k); i++) {       int r;       RI(r);       ans = max(ans, r - 25);     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int K, N, M, Q;   map<string, int> Basic, F[111];   string st, Comp_St[60];   vector<pair<string, int> > Comp[60];   int main() {     cin >> K >> N >> M >> Q;     for (int i = 1; i <= N; i++) {       cin >> st;       Basic[st] = i;     }     for (int i = 0, k; i < M; i++) {       cin >> st;       st = st.substr(0, st.size() - 1);       Comp_St[i] = st;       for (string stt; cin >> stt;) {         cin >> k;         Comp[i].push_back(make_pair(stt, k));         char ch;         scanf( %c , &ch);         if (ch !=  , ) break;       }     }     for (int i = 0, p; i < Q; i++) {       cin >> p >> st;       F[p][st]++;       for (int j = 0; j < M; j++) {         st = Comp_St[j];         bool flag = true;         for (int k = 0; k < Comp[j].size(); k++)           if (F[p][Comp[j][k].first] < Comp[j][k].second) flag = false;         if (flag) {           F[p][st]++;           for (int k = 0; k < Comp[j].size(); k++)             F[p][Comp[j][k].first] -= Comp[j][k].second;         }       }     }     for (int i = 1; i <= K; i++) {       int TOT = 0;       for (map<string, int>::iterator it = F[i].begin(); it != F[i].end(); it++)         if (it->second > 0) TOT++;       printf( %d n , TOT);       for (map<string, int>::iterator it = F[i].begin(); it != F[i].end(); it++)         if (it->second > 0) cout << it->first <<     << it->second << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct team {     string name;     int score;     int goals_for;     int goals_against;     int goal_diff() const { return goals_for - goals_against; }   };   bool operator<(const team &A, const team &B) {     if (A.score != B.score) return A.score > B.score;     if (A.goal_diff() != B.goal_diff()) return A.goal_diff() > B.goal_diff();     return A.goals_for > B.goals_for;   }   map<string, team> m;   int main(void) {     int n;     scanf( %d , &n);     for (int i = 0; i < n; ++i) {       static char buff[128];       scanf( %s , buff);       team T;       T.name = string(buff);       T.score = T.goals_against = T.goals_for = 0;       m[T.name] = T;     }     for (int i = 0; i < n * (n - 1) / 2; ++i) {       static char buff[128];       int ga, gb;       scanf( %s %d:%d , buff, &ga, &gb);       string s(buff);       int f = s.find( - );       team &a = m[s.substr(0, f)];       team &b = m[s.substr(f + 1)];       a.goals_for += ga;       a.goals_against += gb;       b.goals_for += gb;       b.goals_against += ga;       if (ga > gb)         a.score += 3;       else if (ga < gb)         b.score += 3;       else {         a.score += 1;         b.score += 1;       }     }     vector<team> teams;     for (map<string, team>::iterator it = m.begin(); it != m.end(); ++it)       teams.push_back(it->second);     sort(teams.begin(), teams.end());     vector<string> ret;     for (int i = 0; i < n / 2; ++i) ret.push_back(teams[i].name);     sort(ret.begin(), ret.end());     for (int i = 0; i < n / 2; ++i) printf( %s n , ret[i].c_str());     return 0;   }