malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int x = 0;     bool f = false;     char ch = getchar();     while (!isdigit(ch)) {       f |= ch ==  - ;       ch = getchar();     }     while (isdigit(ch)) {       x = (x << 3) + (x << 1) + (ch ^ 48);       ch = getchar();     }     return f ? -x : x;   }   void write(int x) {     if (x < 0) putchar( - ), x = -x;     if (x > 9) write(x / 10);     putchar(x % 10 + 48);   }   const int N = 2505, INF = 0x7fffffff;   int n;   int a[N][N];   int fa[N], d[N];   bool vis[N];   inline void prim() {     for (int i = 2; i <= n; i++) fa[i] = 1, d[i] = a[1][i];     memset(vis, false, sizeof(vis));     vis[1] = true;     int k, minn;     for (int tot = 2; tot <= n; tot++) {       minn = INF;       for (int i = 1; i <= n; i++)         if (minn > d[i] && !vis[i]) minn = d[i], k = i;       vis[k] = true;       for (int i = 1; i <= n; i++)         if (a[k][i] < d[i] && !vis[i]) d[i] = a[k][i], fa[i] = k;     }   }   int dep[N];   void getdep(int x) {     if (!dep[fa[x]]) getdep(fa[x]);     dep[x] = dep[fa[x]] + 1;   }   int main() {     n = read();     for (register int i = 1; i <= n; i++)       for (register int j = 1; j <= n; j++) a[i][j] = read();     for (register int i = 1; i <= n; i++)       if (a[i][i]) return puts( NOT MAGIC ), 0;     for (register int i = 1; i <= n; i++)       for (register int j = i + 1; j <= n; j++)         if (a[i][j] != a[j][i]) return puts( NOT MAGIC ), 0;     prim();     dep[1] = 1;     for (register int i = 2; i <= n; i++)       if (!dep[i]) getdep(i);     for (register int i = 1; i <= n; i++)       for (register int j = i + 1; j <= n; j++) {         int x = i, y = j;         if (dep[x] < dep[y]) swap(x, y);         if (a[x][y] > max(a[fa[x]][y], a[fa[x]][x])) return puts( NOT MAGIC ), 0;       }     return puts( MAGIC ), 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T1, typename T2>   inline std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p) {     return os <<  (  << p.first <<  ,   << p.second <<  ) ;   }   template <typename T>   inline std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {     bool first = true;     os <<  [ ;     for (unsigned int i = 0; i < v.size(); i++) {       if (!first) os <<  ,  ;       os << v[i];       first = false;     }     return os <<  ] ;   }   template <typename T>   inline std::ostream& operator<<(std::ostream& os, const std::set<T>& v) {     bool first = true;     os <<  [ ;     for (typename std::set<T>::const_iterator ii = v.begin(); ii != v.end();          ++ii) {       if (!first) os <<  ,  ;       os << *ii;       first = false;     }     return os <<  ] ;   }   template <typename T1, typename T2>   inline std::ostream& operator<<(std::ostream& os, const std::map<T1, T2>& v) {     bool first = true;     os <<  [ ;     for (typename std::map<T1, T2>::const_iterator ii = v.begin(); ii != v.end();          ++ii) {       if (!first) os <<  ,  ;       os << *ii;       first = false;     }     return os <<  ] ;   }   struct debugger {     bool first;     debugger() { first = true; }     template <typename T>     debugger& operator,(const T& v) {       if (!first) cout <<  ,  ;       cout << v;       first = false;       return *this;     }   };   long long n;   long long arr[10000000];   long long solve() {     vector<long long> st;     long long mx = 0;     for (long long i = 0; i < n; i++) {       while (!st.empty() && st.back() < arr[i]) st.pop_back();       st.push_back(arr[i]);       if (st.size() >= 2) mx = max(mx, st[st.size() - 1] ^ st[st.size() - 2]);     }     return mx;   }   int32_t main(void) {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n;     for (long long i = 0; i < n; i++) cin >> arr[i];     long long mx = solve();     reverse(arr, arr + n);     cout << max(mx, solve());   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   int find_first_num_index(long long &k, long long n) {     if (n == 1) {       return 0;     }     n--;     int first_num_index;     long long n_partial_fact = n;     while (k >= n_partial_fact && n > 1) {       n_partial_fact *= (n - 1);       n--;     }     first_num_index = k / n_partial_fact;     k %= n_partial_fact;     return first_num_index;   }   vector<long long> find_kth_permutation(long long n, long long k) {     vector<long long> Ans;     set<long long> S;     for (int i = 1; i <= n; i++) {       S.insert(i);     }     auto itr = S.begin();     k -= 1;     for (int i = 0; i < n; i++) {       int index = find_first_num_index(k, n - i);       advance(itr, index);       Ans.push_back((*itr));       S.erase(itr);       itr = S.begin();     }     return Ans;   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     long long n, q, t, x = 1;     cin >> n >> q;     long long suff_len = min(14LL, n);     long long pref_len = n - suff_len;     long long Sil[20];     Sil[0] = 1;     for (int i = 1; i <= suff_len; i++) {       Sil[i] = Sil[i - 1] * i;     }     vector<long long> Suff = find_kth_permutation(suff_len, 1);     while (q--) {       cin >> t;       if (t == 1) {         long long l, r, ans = 0;         cin >> l >> r;         int r_pr = min(r, pref_len);         if (l <= r_pr) {           ans += 1ll * (l + r_pr) * (r_pr - l + 1) / 2;         }         r -= pref_len + 1;         l -= pref_len + 1;         r_pr = max(r_pr - pref_len - 1, 0LL);         for (int i = max(l, 0LL); i <= r; i++) {           ans += pref_len + Suff[i];         }         cout << ans << endl;       } else {         int dx;         cin >> dx;         x += dx;         x = min(x, Sil[suff_len]);         Suff = find_kth_permutation(suff_len, x);       }     }     return 0;   }
#include <bits/stdc++.h>   inline int read() {     char c;     int x;     for (c = getchar(); !isdigit(c); c = getchar())       ;     for (x = 0; isdigit(c); c = getchar()) {       x = x * 10 + c -  0 ;     }     return x;   }   int n;   long long ans;   std::priority_queue<int> que;   int main() {     n = read();     for (int i = 0; i < n; i++) {       int x = read();       que.push(-x);       if (que.top() + x > 0) {         ans += que.top() + x;         que.push(-x);         que.pop();       }     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t;     cin >> t;     int n, m, k;     while (t--) {       cin >> n >> m >> k;       if (n % 2 == 0 && k % 2 == 1) {         cout <<  NO n ;         continue;       }       if (n % 2 == 0 && k % 2 == 0) {         if (m % 2 == 0)           cout <<  YES n ;         else {           if (k > n * (m - 1) / 2)             cout <<  NO n ;           else             cout <<  YES n ;         }         continue;       }       if (m / 2 % 2 == 0) {         if (k % 2 == 0 && k >= m / 2)           cout <<  YES n ;         else           cout <<  NO n ;       } else {         if (k % 2 == 1 && k >= m / 2)           cout <<  YES n ;         else           cout <<  NO n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1e7;   const long long MOD = 1e9 + 7;   const long long mod = 998244353;   const int MAX_N = 1e5 + 5;   template <typename Arg1>   void __f(const char* name, Arg1&& arg1) {     cout << name <<   :   << arg1 << endl;   }   template <typename Arg1, typename... Args>   void __f(const char* names, Arg1&& arg1, Args&&... args) {     const char* comma = strchr(names + 1,  , );     cout.write(names, comma - names) <<   :   << arg1 <<   |  ;     __f(comma + 1, args...);   }   vector<int> adj[1005];   int tsz[1005];   bool ga[1005];   void dfs(int u, int v = -1) {     tsz[u] = 1;     if (adj[u].size() == 1) ga[u] = true;     for (auto xd : adj[u]) {       if (xd == v) continue;       dfs(xd, u);       tsz[u] += tsz[xd];     }   }   int main() {     int tc;     cin >> tc;     while (tc--) {       for (int i = 0; i < 1005; i++) {         adj[i].clear();         tsz[i] = 0;       }       int n, x;       cin >> n >> x;       for (int i = 0; i < n - 1; i++) {         int a, b;         cin >> a >> b;         adj[a].push_back(b);         adj[b].push_back(a);       }       dfs(x);       if (adj[x].size() <= 1) {         cout <<  Ayush  << endl;         continue;       }       long long p = tsz[x] - 1;       if (p % 2 == 0)         cout <<  Ashish  << endl;       else         cout <<  Ayush  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 152;   int previ[maxn];   int curr[maxn];   int temp[maxn];   int main() {     ios_base::sync_with_stdio(0);     int n;     cin >> n;     previ[0] = 1;     curr[1] = 1;     for (int i = 0; i < n - 1; i++) {       temp[0] = 0;       for (int j = 0; j <= i + 1; j++) {         temp[j + 1] = curr[j];       }       for (int j = 0; j <= i; j++) {         temp[j] = (temp[j] + previ[j]) % 2;       }       for (int j = 0; j <= i + 2; j++) {         previ[j] = curr[j];         curr[j] = temp[j];       }     }     cout << n << endl;     for (int i = 0; i <= n; i++) {       cout << curr[i] <<    ;     }     cout << endl;     cout << n - 1 << endl;     for (int i = 0; i <= n - 1; i++) {       cout << previ[i] <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline void read(T &dig) {     dig = 0;     bool flag = false;     char c = getchar();     while (!isdigit(c) && c !=  - ) c = getchar();     if (c ==  - ) flag = true, c = getchar();     while (isdigit(c)) dig = dig * 10 + c -  0 , c = getchar();     if (flag) dig = -dig;   }   const int MAXN = (int)5e3 + 5;   int n, maxn = INT_MIN;   int times[MAXN], prep[MAXN];   inline void init() {     read(n);     for (register int i = (1); i <= (n); ++i) read(times[i]), prep[i] = times[i];     for (register int i = (2); i <= (n); ++i) prep[i] += prep[i - 1];   }   inline void solve() {     for (register int i = (1); i <= (n); ++i) {       for (register int j = (i); j <= (n); ++j) {         if (100 * (j - i + 1) < prep[j] - prep[i - 1])           maxn = max(maxn, j - i + 1);         else           continue;       }     }     printf( %d , maxn == INT_MIN ? 0 : maxn);   }   int main() {     init();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i, cnt;     double ans, a, dp[100005] = {0}, pr[100005] = {0};     cin >> n;     for (i = 1; i <= n; i++) {       cin >> a;       pr[i] = pr[i - 1] * a + a;       dp[i] = dp[i - 1] + a * (2 * pr[i - 1] + 1);     }     printf( %.15lf , dp[n]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int fa[5010], ba[5010], b[5010];   int main() {     ios_base::sync_with_stdio(0);     int i, j, k, l, n, m, t, tt, x = 0, y;     string s, second;     cin >> s;     n = s.length();     fa[0] = 0;     ba[n + 1] = 0;     b[0] = 0;     for (j = 1; j <= n; j++) {       fa[j] = fa[j - 1];       b[j] = b[j - 1];       if (s[j - 1] ==  a )         fa[j] = fa[j] + 1;       else         b[j] = b[j] + 1;     }     if (fa[n] == n) {       cout << n <<   n ;       return 0;     }     for (j = n; j > 0; j--) {       ba[j] = ba[j + 1];       if (s[j - 1] ==  a ) ba[j] = ba[j] + 1;     }     int mx = 0;     for (i = 1; i <= n; i++) {       for (j = i; j <= n; j++) {         mx = max(fa[i - 1] + b[j] - b[i - 1] + ba[j + 1], mx);       }     }     cout << mx;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int maxn;   int vis[100010], a[100010], in[100010], temp[100010], res[100010];   vector<int> q[100010];   int bfs(int x) {     int i, sum = 1, hash[100010] = {0};     hash[x] = 1;     while (in[x] < 2) {       temp[sum++] = x;       if (!hash[q[x][0]]) {         if (q[x][0] == 0) break;         x = q[x][0];       }     }     return sum - 1;   }   int main() {     int i, n;     while (scanf( %d , &n) != EOF) {       maxn = 0;       memset(in, 0, sizeof(in));       for (i = 1; i <= n; i++) scanf( %d , &vis[i]);       for (i = 1; i <= n; i++) {         scanf( %d , &a[i]);         in[a[i]]++;         q[i].push_back(a[i]);       }       for (i = 1; i <= n; i++) {         if (vis[i]) {           int t = bfs(i);           if (t > maxn) {             maxn = t;             for (int j = 1; j <= maxn; j++) res[j] = temp[j];           }         }       }       printf( %d n , maxn);       for (i = maxn; i > 0; i--) {         if (i != maxn) printf(   );         printf( %d , res[i]);       }       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   template <typename T>   inline void read(T &x) {     bool b = 0;     char c;     while (!isdigit(c = getchar()) && c !=  - )       ;     if (c ==  - ) c = getchar(), b = 1;     x = c - 48;     while (isdigit(c = getchar())) x = (x << 3) + (x << 1) + c - 48;     if (b) x = -x;   }   template <typename T>   inline void write(T x) {     if (x > 9) write(x / 10);     putchar(x % 10 + 48);   }   using namespace std;   const int N = 1e5 + 11;   int n, pos1, pos0, a[N], ans[N], ke[N], num[2];   int Max0(int pos) {     int res = 0;     for (int i = 1; i <= pos; i++) {       num[a[i]]++;       if (a[i])         res++;       else         res = max(res, num[0]);     }     num[0] = num[1] = 0;     return res;   }   int Max1(int pos) {     int res = 0;     for (int i = 1; i <= pos; i++) {       num[ans[i]]++;       if (ans[i])         res++;       else         res = max(res, num[0]);     }     num[0] = num[1] = 0;     return res;   }   int main() {     char c;     while (isdigit(c = getchar())) a[++n] = c - 48;     for (int i = 1; i <= n; i++) ans[i] = a[i];     ke[n + 1] = n;     ke[n] = n;     for (int i = n - 1; i > 0; i--) {       if (a[i] == a[i + 1])         ke[i] = ke[i + 1];       else         ke[i] = i;     }     for (int i = 1; i <= n; i++)       if (a[i]) {         pos1 = i;         break;       }     while (pos1 <= n) {       pos0 = ke[pos1] + 1;       int num0 = ke[pos0] - pos0 + 1;       int num1 = ke[pos1] - pos1 + 1;       if (num0 < num1) {         num1 -= num0;         for (int i = 1; i <= num1; i++) {           ans[pos1 + i - 1] = 0;           if (Max0(pos1 + i - 1) != Max1(pos1 + i - 1) || Max0(n) != Max1(n))             ans[pos1 + i - 1] = 1;         }       }       pos1 = ke[pos0] + 1;     }     for (int i = 1; i <= n; i++) cout << ans[i];   }
#include <bits/stdc++.h>   using namespace std;   int n, i, j, m, k;   int a[2000000];   bool bo[2000000];   int l, r, ans, tot;   int main() {     scanf( %d%d%d , &n, &m, &k);     for (i = 1; i <= n; i++) scanf( %d , &a[i]);     sort(a + 1, a + 1 + n);     int now = 0;     bo[0] = true;     for (i = 1; i <= n; i++) {       tot++;       while (a[i] - a[now] >= m && now <= n) tot -= (!bo[now]), now++;       if (tot >= k) ans++, tot--, bo[i] = true;     }     printf( %d , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int A[200005];   vector<int> L[105];   int dp[400005];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &A[i]);       L[A[i]].push_back(i);     }     int opt = 0;     int D = 0;     int N = min(n, 100);     for (int i = 1; i <= N; i++) {       if (L[i].size() > L[D].size()) D = i;     }     memset(dp, -1, sizeof(dp));     for (int V = 1; V <= N; V++) {       if (V == D) continue;       if (L[V].empty()) continue;       int bal = 0;       vector<int> T;       T.push_back(bal);       dp[bal + n] = 0;       for (int i = 1; i <= n; i++) {         if (A[i] == D)           bal++;         else if (A[i] == V)           bal--;         if (dp[bal + n] != -1) {           if (i - dp[bal + n] > opt) opt = i - dp[bal + n];         }         if (dp[bal + n] == -1) {           dp[bal + n] = i;           T.push_back(bal);         }       }       for (int v : T) {         dp[v + n] = -1;       }     }     printf( %d n , opt);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int K = 26;   struct Vertex {     int next[K];     long long int leaf = 0;     int p = -1;     char pch;     int link = -1;     int go[K];     long long int count = -1;     int leaflink = 0;     Vertex(int p = -1, char ch =  $ ) : p(p), pch(ch) {       fill(begin(next), end(next), -1);       fill(begin(go), end(go), -1);     }   };   vector<Vertex> t(1);   void add_string(string const& s) {     int v = 0;     for (char ch : s) {       int c = ch -  a ;       if (t[v].next[c] == -1) {         t[v].next[c] = t.size();         t.emplace_back(v, ch);       }       v = t[v].next[c];     }     t[v].leaf++;   }   int go(int v, char ch);   int get_link(int v);   long long int cnt(int v) {     if (t[v].count == -1) {       if (v == 0)         t[v].count = 0;       else         t[v].count = cnt(get_link(v)) + t[v].leaf;     }     return t[v].count;   }   int get_link(int v) {     if (t[v].link == -1) {       if (v == 0 || t[v].p == 0)         t[v].link = 0;       else         t[v].link = go(get_link(t[v].p), t[v].pch);     }     return t[v].link;   }   int go(int v, char ch) {     int c = ch -  a ;     if (t[v].go[c] == -1) {       if (t[v].next[c] != -1)         t[v].go[c] = t[v].next[c];       else         t[v].go[c] = v == 0 ? 0 : go(get_link(v), ch);     }     return t[v].go[c];   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     string ts;     cin >> ts;     int n;     cin >> n;     vector<string> v;     for (int i = 0; i < n; ++i) {       string s;       cin >> s;       v.push_back(s);       reverse(s.begin(), s.end());       add_string(s);     }     int m = ts.size();     vector<long long int> a = vector<long long int>(m, 0);     int cs = 0;     for (int i = m - 1; i > -1; --i) {       get_link(cs);       cs = go(cs, ts[i]);       get_link(cs);       a[i] = cnt(cs);     }     t = vector<Vertex>(1);     for (int i = 0; i < n; ++i) {       add_string(v[i]);     }     cs = 0;     long long int sol = 0;     for (int i = 0; i < m - 1; ++i) {       get_link(cs);       cs = go(cs, ts[i]);       get_link(cs);       sol += cnt(cs) * a[i + 1];     }     cout << sol << endl;   }
#include <bits/stdc++.h>   using namespace std;   void swap(int *a, int *b) {     int temp = *a;     *a = *b;     *b = temp;   }   void swap(char *a, char *b) {     char temp = *a;     *a = *b;     *b = temp;   }   int main() {     int xa, xb, xc, ya, yb, yc;     cin >> xa >> ya >> xb >> yb >> xc >> yc;     char ca =  A , cb =  B , cc =  C ;     int area = xa * ya + xb * yb + xc * yc;     int n = sqrt(area);     if (n * n != area) {       cout << -1;       return 0;     }     char arr[n][n];     if (xa < ya) swap(&xa, &ya);     if (xb < yb) swap(&xb, &yb);     if (xc < yc) swap(&xc, &yc);     if (xb == n) {       swap(&xa, &xb);       swap(&ya, &yb);       swap(&ca, &cb);     } else if (xc == n) {       swap(&xc, &xa);       swap(&ya, &yc);       swap(&ca, &cc);     }     if (xa != n) {       cout << -1;       return 0;     }     for (int i = 0; i < ya; i++) {       for (int j = 0; j < n; j++) arr[i][j] = ca;     }     if (yb == yc && xb + xc == n && ya + yb == n) {       for (int i = ya; i < n; i++) {         for (int j = 0; j < n; j++) {           if (j >= xb)             arr[i][j] = cc;           else             arr[i][j] = cb;         }       }     } else if (xb == xc && xb == n && ya + yb + yc == n) {       for (int i = ya; i < n; i++) {         for (int j = 0; j < n; j++) {           if (i >= yb + ya)             arr[i][j] = cc;           else             arr[i][j] = cb;         }       }     } else if (xb == xc && yb + yc == n && ya + xb == n) {       for (int i = ya; i < n; i++) {         for (int j = 0; j < n; j++) {           if (j >= yb)             arr[i][j] = cc;           else             arr[i][j] = cb;         }       }     } else if (xb == yc && yb + xc == n && ya + xb == n) {       for (int i = ya; i < n; i++) {         for (int j = 0; j < n; j++) {           if (j >= yb)             arr[i][j] = cc;           else             arr[i][j] = cb;         }       }     } else if (yb == xc && xb + yc == n && ya + yb == n) {       for (int i = ya; i < n; i++) {         for (int j = 0; j < n; j++) {           if (j >= xb)             arr[i][j] = cc;           else             arr[i][j] = cb;         }       }     } else {       cout << -1;       return 0;     }     cout << n << endl;     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) cout << arr[i][j];       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     int has = 0;     ;     cin >> n;     int d[n - 1];     for (int i = 0; i < n - 1; i++) cin >> d[i];     int a, b;     cin >> a >> b;     int m;     has = 0;     for (int m = a - 1; m < b - 1; m++) {       has = has + d[m];     }     cout << has << endl;   }
#include <bits/stdc++.h>   int max(int a, int b) { return a > b ? a : b; }   int main() {     static int aa[200000];     int n, d, q, i, h, j;     scanf( %d%d , &n, &d);     for (i = 0; i < n; i++) scanf( %d , &aa[i]);     scanf( %d , &q);     h = -1;     while (q--) {       int x, di, dj, d_;       double alpha, beta;       scanf( %d , &x);       if (x == 0 || x == aa[n - 1] + 1) {         printf( %.12f n , (atan(1) * 4) / 2);         continue;       }       while (h + 1 < n && aa[h + 1] < x) h++;       di = x - (aa[h] + 1);       dj = aa[h + 1] - x;       if (di == 0 && dj == 0) {         printf( %.12f n , (atan(1) * 4));         continue;       } else if (di == 0 || dj == 0) {         printf( %.12f n , (atan(1) * 4) / 2);         continue;       }       alpha = atan(1.0 / (di < dj ? di : dj));       d_ = (int)(1.0 / tan(alpha / 2.0) + 10);       for (i = h, j = h + 1; i >= 0 && j < n && (di = x - (aa[i] + 1)) < d_ &&                              (dj = aa[j] - x) < d_;)         if (di + 1 < dj)           i--;         else if (di > dj + 1)           j++;         else {           if (alpha < (beta = atan(1.0 / max(di, dj)) * 2)) alpha = beta;           break;         }       printf( %.12f n , alpha);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   using namespace std;   string s;   long long ispalindroma[2005][2005];   long long ispalindrome(long long i, long long j) {     if (i > j) return (1);     if (i == j) return (1);     if (ispalindroma[i][j] != -1) return (ispalindroma[i][j]);     long long ans = 0;     if (s[i] == s[j]) {       ans = ispalindrome(i + 1, j - 1);     }     return (ispalindroma[i][j] = ans);   }   int solve() {     cin >> s;     long long sum[2005], dp[2005];     dp[0] = sum[0] = 0;     for (long long i = 0; i < 2005; i++) {       for (long long j = 0; j < 2005; j++) ispalindroma[i][j] = -1;     }     long long a1 = ispalindrome(0, s.size() - 1);     for (long long i = 0; i < s.size(); i++) {       long long c = 0;       for (long long j = 0; j <= i; j++) {         if (ispalindrome(j, i)) c++;       }       sum[i + 1] = sum[i] + c;     }     for (long long i = 0; i < s.size(); i++) {       long long ans = 0;       for (long long j = 0; j <= i; j++) {         if (ispalindrome(j, i)) ans = ans + sum[j];       }       dp[i + 1] = dp[i] + ans;     }     cout << dp[s.size()] <<   n ;     return 0;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long t;     t = 1;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int x, y, z;     cin >> x >> y >> z;     if (x >= y) {       x = x - y;       if (x > z) {         cout <<  + ;       } else if (x <= z) {         if (z == 0) {           cout <<  0 ;         } else {           cout <<  ? ;         }       }     } else if (y > x) {       y = y - x;       if (y > z) {         cout <<  - ;       } else if (y <= z) {         if (z == 0) {           cout <<  0 ;         } else {           cout <<  ? ;         }       }     }     return 0;   }
#include <bits/stdc++.h>   int main() {     long long int n, x, y, i, j, k = 0, s;     scanf( %lld %lld %lld , &n, &x, &y);     long long int X[n], Y[n];     for (i = 0; i < n; i++) {       scanf( %lld %lld , &X[i], &Y[i]);       for (j = i - 1; j >= 0; j--) {         s = x * Y[i] + X[i] * Y[j] + X[j] * y - X[i] * y - X[j] * Y[i] - x * Y[j];         if (s == 0) {           break;         }       }       if (j < 0) {         k++;       }     }     printf( %lld n , k);     return 0;   }