malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   vector<int> v[2005];   int vi[2005];   void dfs(int cu) {     int j, l = v[cu].size();     vi[cu] = 1;     for (j = 0; j < l; j++) {       if (!vi[v[cu][j]]) dfs(v[cu][j]);     }   }   int main() {     int n, m, k, cn = 0, i, j;     scanf( %d%d , &n, &m);     scanf( %d , &k);     long long an = 1;     for (i = 1; i + k - 1 <= n; i++) {       for (j = i; j < i + k / 2; j++) {         v[j].push_back(2 * i + k - 1 - j);         v[2 * i + k - 1 - j].push_back(j);       }     }     for (i = 1; i < n + 1; i++) {       if (!vi[i]) dfs(i), cn++;     }     for (i = 0; i < cn; i++) an = (an * m) % 1000000007LL;     printf( %lld , an);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int x11, x12, x13, x21, x22, x23, x31, x32, x33;     cin >> x11 >> x12 >> x13 >> x21 >> x22 >> x23 >> x31 >> x32 >> x33;     int sum = (x12 + x13 + x21 + x23 + x31 + x32) / 2;     x11 = sum - x12 - x13;     x22 = sum - x21 - x23;     x33 = sum - x31 - x32;     cout << x11 <<     << x12 <<     << x13 << endl;     cout << x21 <<     << x22 <<     << x23 << endl;     cout << x31 <<     << x32 <<     << x33 << endl;   }
#include <bits/stdc++.h>   using namespace std;   int n, q;   vector<pair<int, int> > L, R;   int whereL[30013], whereR[30013];   long long cost[30013][2];   long long dp[30013];   const long long INF = -3.1e16;   inline long long match(int a, int b) {     if (a <= 0 || b <= 0 || a > n || b > n) return INF;     return (long long)L[a].first * R[b].first;   }   inline void update(int i) {     if (i <= 0 || i > n) return;     cost[i][0] = match(i, i + 1) + match(i + 1, i);     cost[i][1] = max(match(i, i + 1) + match(i + 1, i + 2) + match(i + 2, i),                      match(i, i + 2) + match(i + 1, i) + match(i + 2, i + 1));   }   int main() {     scanf( %d%d , &n, &q);     for (int i = 0; i <= n; i++) {       L.push_back(make_pair(0, i));       R.push_back(make_pair(0, i));     }     for (int i = 1; i <= n; i++) scanf( %d , &L[i].first);     for (int i = 1; i <= n; i++) scanf( %d , &R[i].first);     sort(L.begin(), L.end());     sort(R.begin(), R.end());     for (int i = 1; i <= n; i++) {       whereL[L[i].second] = i;       whereR[R[i].second] = i;     }     for (int i = 1; i <= n; i++) update(i);     for (int Q = 0; Q < q; Q++) {       int a, b;       scanf( %d%d , &a, &b);       swap(R[whereR[a]].second, R[whereR[b]].second);       swap(whereR[a], whereR[b]);       for (int i = -2; i <= 0; i++) {         update(whereL[a] + i);         update(whereR[a] + i);         update(whereL[b] + i);         update(whereR[b] + i);       }       dp[n + 1] = 0;       for (int i = n; i; i--) {         dp[i] = max(dp[i + 2] + cost[i][0], dp[i + 3] + cost[i][1]);         if (L[i].second != R[i].second)           dp[i] = max(dp[i], (long long)L[i].first * R[i].first + dp[i + 1]);       }       printf( %I64d n , dp[1]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 5e6 + 10;   const int MAX = 1e5 + 10;   const double eps = 1e-6;   priority_queue<int> q, Q;   long long s[MAX];   int main() {     long long n, k;     cin >> n >> k;     int cnt = 0;     while (n > 0) {       long long b = 1;       int a = 0;       while (b * 2 <= n) b *= 2, a++;       cnt++;       q.push(a);       Q.push(a);       n -= b;     }     if (cnt > k) {       cout <<  No  << endl;       return 0;     }     int temp = cnt;     while (temp < k) {       int a = Q.top();       Q.pop();       a--;       Q.push(a);       Q.push(a);       temp++;     }     temp = Q.top();     while (cnt < k) {       int a = q.top();       if (temp == a) break;       q.pop();       a--;       q.push(a);       q.push(a);       cnt++;     }     temp = 0;     while (q.size()) {       s[temp++] = q.top();       q.pop();     }     while (cnt < k) {       s[cnt - 1] = s[cnt - 1] - 1;       s[cnt] = s[cnt - 1];       cnt++;     }     cout <<  Yes  << endl;     for (int i = 0; i < cnt; i++) {       if (i == 0)         cout << s[i];       else         cout <<     << s[i];     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:16777216 )   using namespace std;   int a, b, c, d, i, j, n, m, k;   int cnt[6];   map<string, int> q;   const int di[] = {0, 1, -1, 2, -2, 3, -3, 4, -4};   const char *name[] = { S ,  M ,  L ,  XL ,  XXL };   int main() {     for (int _n((5) - 1), i(0); i <= _n; i++) scanf( %d , &cnt[i]);     q[ S ] = 0;     q[ M ] = 1;     q[ L ] = 2;     q[ XL ] = 3;     q[ XXL ] = 4;     scanf( %d , &n);     for (int _n((n)-1), i(0); i <= _n; i++) {       string s;       cin >> s;       a = q[s];       for (int _n((9) - 1), j(0); j <= _n; j++) {         if (a + di[j] >= 0 && a + di[j] < 5 && cnt[a + di[j]]) {           printf( %s n , name[a + di[j]]);           --cnt[a + di[j]];           break;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1e9 + 7, MAXN = 1e5 + 10;   int n, l, r, a[MAXN], b[MAXN];   vector<int> aa, bb;   int main() {     ios_base::sync_with_stdio(0);     cin >> n >> l >> r;     for (int i = 1; i <= n; ++i) {       cin >> a[i];       if (l <= i && i <= r) aa.push_back(a[i]);     }     for (int i = 1; i <= n; ++i) {       cin >> b[i];       if (l <= i && i <= r) bb.push_back(b[i]);     }     for (int i = 1; i < l; ++i)       if (a[i] != b[i]) {         cout <<  LIE ;         return 0;       }     for (int i = r + 1; i <= n; ++i)       if (a[i] != b[i]) {         cout <<  LIE ;         return 0;       }     sort(aa.begin(), aa.end());     sort(bb.begin(), bb.end());     if (aa == bb)       cout <<  TRUTH ;     else       cout <<  LIE ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int s[1509][1509];   long long int dp[1509][1509];   int main() {     int m, n, i, j;     cin >> n >> m;     for (i = 1; i <= n; i++)       for (j = 1; j <= m; j++) scanf( %d , &s[i][j]);     for (i = 1; i <= n; i++)       for (j = 2; j <= m; j++) s[i][j] += s[i][j - 1];     for (i = 0; i <= n + 4; i++)       for (j = 0; j <= m + 4; j++) dp[i][j] = -(long long)(1 << 30);     i = 1;     for (j = 1; j <= m; j++) dp[1][j] = s[1][j];     for (i = 2; i <= n; i++) {       if ((i & 1) == 0) {         long long cm = -(long long)(1 << 30);         for (j = m; j > 0; j--) {           dp[i][j] = cm + s[i][j];           if (cm < dp[i - 1][j]) cm = dp[i - 1][j];         }       } else {         long long cm = -(long long)(1 << 30);         for (j = 1; j <= m; j++) {           dp[i][j] = cm + s[i][j];           if (cm < dp[i - 1][j]) cm = dp[i - 1][j];         }       }     }     cout << *max_element(dp[n] + 1, dp[n] + m + 1);   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 200000 + 10;   const int ALPHA = 30;   const int NUM = 12;   int T;   char a[MAX];   struct Node {     Node *ch[ALPHA], *p;     int cc[NUM];     int len;     Node() {       memset(ch, 0, sizeof ch);       p = 0;       len = 0;       memset(cc, 0, sizeof cc);     }   }* Root = new Node;   int L[NUM], R[NUM];   vector<Node*> all;   int cmp(Node* a, Node* b) { return a->len < b->len; }   void add(Node* v, int id, int len) {     if (v->ch[id] && v->ch[id]->len == len) return;     Node* u = new Node;     all.push_back(u);     u->len = len;     for (; v && !v->ch[id]; v = v->p) v->ch[id] = u;     if (!v)       u->p = Root;     else {       Node* nu = v->ch[id];       if (nu->len == v->len + 1)         u->p = nu;       else {         Node* nnu = new Node;         all.push_back(nnu);         *nnu = *nu;         memset(nnu->cc, 0, sizeof nnu->cc);         u->p = nnu;         nu->p = nnu;         nnu->len = v->len + 1;         for (; v && v->ch[id] == nu; v = v->p) v->ch[id] = nnu;       }     }     return;   }   void init(char* a, int n, int l, int r, int lab) {     L[lab] = l;     R[lab] = r;     int i;     Node* now = Root;     for ((i) = (1); (i) <= (n); ++(i)) {       int id = a[i] -  a ;       add(now, id, i);       now = now->ch[id];       ++now->cc[lab];     }   }   int main() {     int i, first, second;     scanf( %s , a + 1);     init(a, strlen(a + 1), 1, strlen(a + 1), 0);     scanf( %d , &T);     for ((i) = (1); (i) <= (T); ++(i)) {       scanf( %s%d%d , a + 1, &first, &second);       init(a, strlen(a + 1), first, second, i);     }     int j;     long long ans = 0;     sort(all.begin(), all.end(), cmp);     for (i = (int)all.size() - 1; i >= 0; --i) {       int flag = 1;       for ((j) = (0); (j) <= (T); ++(j)) {         all[i]->p->cc[j] += all[i]->cc[j];         flag = flag && (all[i]->cc[j] <= R[j] && all[i]->cc[j] >= L[j]);       }       if (flag) ans += all[i]->len - all[i]->p->len;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long dp[1000006][2];   long long pre[1000006][2];   void chkMinLog(long long& goal, long long t1, bool t2, bool curr) {     if (dp[t1][t2] > goal) {       dp[t1][t2] = goal;       pre[t1][t2] = curr;     }   }   void solve() {     long long n;     cin >> n;     vector<long long> a(n + 2);     for (long long i = (1); i <= (n); i++) cin >> a[i];     for (long long i = (1); i <= (n); i++)       for (long long j = (0); j <= (1); j++) dp[i][j] = 1e18;     a[0] = n + 1;     dp[0][0] = dp[0][1] = -n - 1;     for (long long i = (0); i <= (n - 1); i++)       for (long long isPos = (0); isPos <= (1); isPos++) {         long long sv = (isPos ? 1 : -1) * a[i], v = dp[i][isPos];         if (-a[i + 1] > v) chkMinLog(sv, i + 1, false, isPos);         if (a[i + 1] > v) chkMinLog(sv, i + 1, true, isPos);         if (-a[i + 1] > sv) chkMinLog(v, i + 1, false, isPos);         if (a[i + 1] > sv) chkMinLog(v, i + 1, true, isPos);       }     if (dp[n][0] <= n || dp[n][1] <= n) {       cout <<  YES  << endl;       long long ti = n, ts = 0;       if (dp[n][1] <= n) ts = 1;       while (ti >= 1) {         if (ts == 0) a[ti] = -a[ti];         ts = pre[ti][ts], ti--;       }       for (long long i = (1); i <= (n); i++) cout << a[i] <<    ;       cout << endl;     } else {       cout <<  NO  << endl;     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long T = 1;     cin >> T;     while (T--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 0x3f3f3f3f;   const int N = 5e5 + 10;   int a[8008];   int n, ans = 0;   string s, ss, sss;   map<string, int> mp;   void str() {     cin >> ss;     int sum = 0;     string x =   ;     for (int i = 0; i < ss.length(); i++) {       if (ss[i] ==  & )         sum--;       else if (ss[i] ==  * )         sum++;       else         x += ss[i];     }     ans = mp[x];     if (ans > 0)       ans += sum;     else       ans = 0;   }   int main() {     mp[ void ] = 1;     cin >> n;     while (n--) {       cin >> s;       ans = 0;       if (s ==  typedef ) {         str();         cin >> sss;         mp[sss] = ans;       } else {         str();         ans--;         if (ans < 0)           cout <<  errtype  << endl;         else {           cout <<  void ;           for (int i = 0; i < ans; i++) cout <<  * ;           cout << endl;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200000;   pair<int, bool> p[N * 2];   pair<int, int> t[N];   int main() {     int n;     scanf( %d , &n);     int l, r;     for (int i = 0; i < n; ++i) {       scanf( %d%d , &l, &r);       t[i] = make_pair(l, r);       p[i * 2].first = l;       p[i * 2].second = false;       p[i * 2 + 1].first = r + 1;       p[i * 2 + 1].second = true;     }     sort(p, p + n * 2);     int current = 0;     vector<int> v;     for (int i = 0; i < n * 2; ++i) {       if (!p[i].second)         ++current;       else         --current;       if ((i == n * 2 - 1 || p[i + 1].first != p[i].first) && current == 1)         v.push_back(p[i].first);     }     for (int i = 0; i < n; ++i) {       int it = lower_bound(v.begin(), v.end(), t[i].first) - v.begin();       if (it == v.size() || (v[it] > t[i].second)) {         printf( %d n , i + 1);         return 0;       }     }     printf( -1 n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, L, a[1005], b[1005], ans[1005], cc;   double dp[1005], dis[1005][1005];   int pre[1005];   inline bool check(double K) {     dp[0] = 0;     for (int i = 1; i <= n; ++i) {       dp[i] = -1e9;       for (int j = 0; j < i; ++j) {         double v = dp[j] + K * b[i] - dis[j][i];         if (v > dp[i]) dp[i] = v, pre[i] = j;       }     }     return dp[n] >= 0;   }   void output(int x) {     if (!x) return;     output(pre[x]);     printf( %d  , x);   }   int main() {     scanf( %d%d , &n, &L);     for (int i = 1; i <= n; ++i) scanf( %d%d , a + i, b + i);     for (int i = 0; i <= n; ++i)       for (int j = i + 1; j <= n; ++j) dis[i][j] = sqrt(abs(a[j] - a[i] - L));     double l = 0, r = 1e9, mid;     while (l + 1e-8 <= r) {       mid = (l + r) / 2;       if (check(mid))         r = mid;       else         l = mid;     }     check(r);     output(n);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> o, p, e;   int n, i, j, x;   int a[200000], b[200000];   struct T {     int i;   } t;   bool operator<(T t1, T t2) {     if ((t2.i - x - a[b[t2.i]] + 2 * n) % n !=         (t1.i - x - a[b[t1.i]] + 2 * n) % n)       return (t2.i - x - a[b[t2.i]] + 2 * n) % n <              (t1.i - x - a[b[t1.i]] + 2 * n) % n;     return t1.i < t2.i;   }   priority_queue<T> qp;   set<T> qo;   set<T>::iterator it;   int main() {     scanf( %d , &n);     for (i = 0; i < n; i++) {       scanf( %d , &x);       a[x - 1] = i;     }     for (i = 0; i < n; i++) {       scanf( %d , &b[i]);       b[i]--;     }     x = 0;     for (i = 0; i < n; i++)       if (a[b[i]] < i) {         t.i = i;         qp.push(t);       } else if (a[b[i]] > i) {         t.i = i;         qo.insert(t);       } else         e.push_back(i);     for (i = 0; i < n; i++) {       x = 1999999999;       if (e.size())         printf( 0 n );       else {         if (qp.size()) {           t = qp.top();           x = min(x, (t.i - i + n) % n - a[b[t.i]]);         }         if (qo.size()) {           it = qo.begin();           j = it->i;           x = min(x, a[b[j]] - (j - i + n) % n);         }         printf( %d n , x);       }       x = i + 1;       for (j = 0; j < e.size(); j++) {         if (e[j] != i) {           t.i = e[j];           qo.insert(t);         } else {           t.i = e[j];           qp.push(t);         }       }       e.clear();       while (!qp.empty()) {         t = qp.top();         if ((t.i - i - 1 + n) % n == a[b[t.i]]) {           e.push_back(t.i);           qp.pop();         } else           break;       }       t.i = i;       it = qo.find(t);       if (it != qo.end()) {         qo.erase(t);         if (a[b[i]] == n - 1)           e.push_back(i);         else {           t.i = i;           qp.push(t);         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int l, r;     cin >> l >> r;     for (int i = l; i < r + 1; i++) {       vector<int> cnts(10);       int x = i;       while (x > 0) {         cnts[x % 10]++;         x /= 10;       }       bool good = true;       for (int j = 0; j < 10; j++) {         if (cnts[j] > 1) {           good = false;         }       }       if (good) {         cout << i << endl;         return 0;       }     }     cout << -1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void file() {}   void fast() {     std::ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);   }   long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }   long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }   int dx[] = {-1, 0, 0, 1, 1, 1, -1, -1};   int dy[] = {0, 1, -1, 0, 1, -1, 1, -1};   int n, m, mem[100005][26];   string s;   bool a[26][26];   int solve(int i, int last) {     if (i == n) return 0;     int &ret = mem[i][last];     if (~ret) return ret;     if (a[s[i] -  a ][last]) return ret = 1 + solve(i + 1, last);     return ret = min(solve(i + 1, s[i] -  a ), 1 + solve(i + 1, last));   }   int main() {     file();     fast();     cin >> s;     n = s.size();     cin >> m;     while (m--) {       char c1, c2;       cin >> c1 >> c2;       a[c1 -  a ][c2 -  a ] = a[c2 -  a ][c1 -  a ] = 1;     }     memset(mem, -1, sizeof mem);     int mn = 1e9;     for (int i = 0; i < n; i++) mn = min(mn, i + solve(i, s[i] -  a ));     cout << mn;   }
#include <bits/stdc++.h>   using namespace std;   const int NMAX = 100005;   int A[NMAX];   int main() {     ios::sync_with_stdio(false);     int n;     cin >> n;     bool ok = true;     if (n % 2 == 1) {       if ((n - 1) % 4 == 0) {         for (int i = 1; i <= n / 2; i += 2) {           A[i] = i + 1;           A[i + 1] = n - i + 1;           A[n - i + 1] = n - i;           A[n - i] = i;         }         A[n / 2 + 1] = n / 2 + 1;       } else {         ok = false;       }     } else {       if (n % 4 == 0) {         for (int i = 1; i <= n / 2; i += 2) {           A[i] = i + 1;           A[i + 1] = n - i + 1;           A[n - i + 1] = n - i;           A[n - i] = i;         }       } else {         ok = false;       }     }     if (!ok) {       cout <<  -1 n ;     } else {       for (int i = 1; i <= n; ++i) {         cout << A[i] <<    ;       }       cout <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   template <class S, class T>   pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) {     return pair<S, T>(s.first + t.first, s.second + t.second);   }   template <class S, class T>   pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) {     return pair<S, T>(s.first - t.first, s.second - t.second);   }   template <class S, class T>   ostream &operator<<(ostream &os, pair<S, T> p) {     os <<  (  << p.first <<  ,   << p.second <<  ) ;     return os;   }   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;   }   const long long inf = 1000000001;   const long long INF = 2e18;   const long long MOD = 1000000007;   const double pi = 3.14159265358979323846;   int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};   int dx2[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dy2[8] = {0, 1, 1, 1, 0, -1, -1, -1};   vector<vector<int> > child(5010), parent(5010);   vector<int> color(5010, -1);   int n, m, s;   vector<int> roots, roots2;   void dfs1(int now, int col) {     color[now] = col;     for (long long i = 0; i < (long long)(child[now].size()); i++) {       if (color[child[now][i]] < 0) {         dfs1(child[now][i], col);       }     }   }   void dfs2(int now) {     color[now] = -2;     if (parent[now].size() == 0) {       roots.push_back(now);       return;     }     bool flag = true;     for (long long i = 0; i < (long long)(parent[now].size()); i++) {       if (color[parent[now][i]] == -1) {         dfs2(parent[now][i]);         flag = false;       }     }     if (flag) {       roots2.push_back(now);     }     return;   }   int main() {     cin >> n >> m >> s;     s--;     for (long long i = 0; i < (long long)(m); i++) {       int u, v;       cin >> u >> v;       u--;       v--;       child[u].push_back(v);       parent[v].push_back(u);     }     dfs1(s, s);     int ans = 0;     for (long long i = 0; i < (long long)(n); i++) {       if (color[i] >= 0) {         continue;       }       roots.clear();       dfs2(i);       ans += roots.size();       for (long long j = 0; j < (long long)(roots.size()); j++) {         dfs1(roots[j], roots[j]);       }     }     for (long long i = 0; i < (long long)(roots2.size()); i++) {       if (color[roots2[i]] < 0) {         ans++;         dfs1(roots2[i], roots2[i]);       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   deque<int> d;   string mot;   int n;   void f(int i) {     if (i == n)       return;     else {       f(i + 1);       if (mot[i] ==  l ) {         d.push_back(i + 1);       } else {         d.push_front(i + 1);       }     }   }   int main() {     cin >> mot;     n = mot.size();     f(0);     for (int i = 0; i < n; i++) cout << d[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int neg = 1, num = 0;     char c = getchar();     for (; !isdigit(c); c = getchar())       if (c ==  - ) neg = -1;     for (; isdigit(c); c = getchar()) num = (num << 1) + (num << 3) + c -  0 ;     return neg * num;   }   int n, a, b;   char s[300010];   int main() {     n = read();     a = read();     b = read();     scanf( %s , s + 1);     int las = 0, sum = 0;     s[n + 1] =  * ;     for (int i = 1; i <= n + 1; i++)       if (s[i] ==  * ) {         int x = (i - las - 1) / 2, y = i - las - 1 - x;         if (a > b) swap(a, b);         sum += min(a, x) + min(b, y);         a = max(0, a - x);         b = max(0, b - y);         las = i;       }     printf( %d , sum);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e6 + 10;   const int MM = 1e9 + 7;   void pts(int x, int y, int z) { printf( 3 %d %d %d n , x, y, z); }   void pts(int w, int x, int y, int z) { printf( 4 %d %d %d %d n , w, x, y, z); }   void gao(int n) {     if (n == 3) {       pts(1, 2, 3);       pts(1, 2, 3);     } else if (n == 4) {       pts(1, 2, 3, 4);       pts(1, 2, 4, 3);       pts(1, 4, 2, 3);     } else if (n == 5) {       pts(1, 3, 4, 2);       pts(2, 4, 5, 3);       pts(3, 5, 1, 4);       pts(4, 1, 2, 5);       pts(5, 2, 3, 1);     } else {       int m = n - 2;       gao(m);       pts(n - 1, n, m);       pts(n - 1, n, m - 1);       pts(n - 1, m - 1, n, m);       m -= 2;       for (int i = 0; i < m; i++) {         pts(n - 1, i + 1, n, (i + 1) % m + 1);       }     }   }   void solve(int casi) {     int n;     scanf( %d , &n);     if (n == 3)       printf( 2 n );     else {       int p = (n - 4) / 2 * 2;       int q;       if (n % 2 == 0)         q = 2 + (n / 2 - 1) * (n - 2) / 2;       else         q = 3 + n / 2 * (n - 3) / 2;       assert(3 * p + 4 * q == n * (n - 1));       printf( %d n , p + q);     }     gao(n);   }   int main() {     int T = 1;     for (int i = 1; i <= T; i++) solve(i);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int num1 = 0;   string s1, s2;   int counter = 0;   int ques = 0;   int main() {     cin >> s1 >> s2;     int num2 = 0;     for (int i = 0; i < s1.length(); i++)       if (s1[i] ==  + )         num1++;       else         num1--;     for (int i = 0; i < s2.length(); i++)       if (s2[i] ==  + )         num2++;       else if (s2[i] ==  - )         num2--;       else         ques++;     float num = 0;     int limit = (1 << ques);     for (int i = 0; i < limit; i++) {       int sum = num2;       for (int j = 0; j < ques; j++) {         if ((1 << j) & i)           sum++;         else           sum--;       }       if (sum == num1) counter++;     }     if (ques != 0) {       num = (float)counter / (1 << ques);     } else if (num2 == num1)       num = 1;     printf( %0.12f n , num);   }
#include <bits/stdc++.h>   using namespace std;   char s[111][3];   int main() {     char t[3];     scanf( %s , t);     int n;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %s , s[i]);     }     for (int i = 0; i < n; i++) {       if (t[0] == s[i][0] && t[1] == s[i][1]) {         puts( YES );         return 0;       }     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         if (t[0] == s[i][1] && t[1] == s[j][0]) {           puts( YES );           return 0;         }       }     }     puts( NO );     return 0;   }