malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n, c, d;   const int maxn = 3456789;   const long double PI = acos((long double)(-1.0));   const long double eps = 1e-18;   long double ang[maxn];   int main() {     while (cin >> n >> c >> d) {       for (int i = 0; i < (n); i++) {         int r, w;         scanf( %d%d , &r, &w);         long double x = r - c;         long double y = w - d;         ang[i] = atan2(y, x);       }       sort(ang, ang + n);       for (int i = 0; i < (n + 3); i++) ang[i + n] = ang[i] + 2 * PI;       long long ans = 1LL * n * (n - 1) * (n - 2) / 6;       int j = 0, lo = 0, hi = 0;       for (int i = 0; i < (n); i++) {         while (ang[j + 1] - ang[i] < PI + eps) ++j;         while (ang[lo] - ang[i] < PI - eps) ++lo;         while (ang[hi + 1] - ang[i] < PI + eps) ++hi;         ans -= 1LL * (j - i) * (j - i - 1) / 2;         ans += 1LL * (hi - lo) * (hi - lo + 1) / 2;       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = (int)1e9;   const long long linf = (long long)1e18;   const double eps = (double)1e-8;   const int mod = (int)1e9 + 7;   const int maxn = (int)3e5 + 5;   int n, m;   vector<int> a[maxn];   int fl;   int c[maxn];   vector<int> ta, tb;   set<pair<int, int> > roads;   int equals(int v, int u) {     ta.clear();     tb.clear();     if (a[v].size() != a[u].size()) return 0;     for (int i = (0); i < (int)(a[v].size()); ++i) {       if (a[v][i] == u) continue;       ta.push_back(a[v][i]);     }     for (int i = (0); i < (int)(a[u].size()); ++i) {       if (a[u][i] == v) continue;       tb.push_back(a[u][i]);     }     if (ta.size() != tb.size()) return 0;     for (int i = (0); i < (int)(ta.size()); ++i) {       if (ta[i] != tb[i]) return 0;     }     return 1;   }   void dfs(int v, int pl) {     int cnt = 0;     for (int i = (0); i < (int)(a[v].size()); ++i) {       int to;       to = a[v][i];       if (c[to] != inf) {         if (abs(c[v] - c[to]) > 1) {           fl = 0;           return;         }         continue;       }       if (equals(to, v)) {         c[to] = c[v];         continue;       }     }     for (int i = (0); i < (int)(a[v].size()); ++i) {       int to;       to = a[v][i];       if (c[to] != inf) {         if (abs(c[v] - c[to]) > 1) {           fl = 0;           return;         }         continue;       }       ++cnt;       if (cnt >= 2) {         fl = 0;         break;       }       c[to] = c[v] + pl;       dfs(to, pl);     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n >> m;     for (int i = (1); i <= (int)(m); ++i) {       int x, y;       cin >> x >> y;       if (x > y) swap(x, y);       if (x == y || roads.count(make_pair(x, y))) continue;       roads.insert(make_pair(x, y));       a[x].push_back(y);       a[y].push_back(x);     }     for (int i = (1); i <= (int)(n); ++i) {       c[i] = inf;       sort(a[i].begin(), a[i].end());     }     int st, pl[2], upl;     st = 1;     pl[0] = 1;     pl[1] = -1;     upl = 0;     c[st] = 0;     fl = 1;     for (int i = (0); i < (int)(a[st].size()); ++i) {       int to;       to = a[st][i];       if (c[to] != inf) {         if (abs(c[st] - c[to]) > 1) {           fl = 0;           break;         }         continue;       }       if (equals(st, to)) {         c[to] = c[st];         continue;       }     }     for (int i = (0); i < (int)(a[st].size()); ++i) {       int to;       to = a[st][i];       if (c[to] != inf) {         if (abs(c[st] - c[to]) > 1) {           fl = 0;           break;         }         continue;       }       if (upl == 2) {         fl = 0;         break;       }       c[to] = pl[upl];       dfs(to, pl[upl]);       ++upl;     }     if (!fl) {       cout <<  NO             <<   n ;       return 0;     }     int mn = 0;     for (int i = (1); i <= (int)(n); ++i) {       mn = min(mn, c[i]);     }     cout <<  YES           <<   n ;     for (int i = (1); i <= (int)(n); ++i) {       cout << c[i] - mn + 1 <<    ;     }     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   const int MAXN = 1000 + 10;   int n;   std::set<int> g[MAXN];   std::vector<std::pair<int, int> > process(bool ty) {     std::vector<std::pair<int, int> > ans;     for (int i = 2; i < n; i++) {       while (!g[1].count(i + 1)) {         int k = *std::next(g[1].find(i));         assert(g[i].count(k));         g[i].erase(k);         g[k].erase(i);         for (auto v : g[i]) {           if (v != 1 && g[k].count(v)) {             assert(i < v && v < k);             g[1].insert(v);             g[v].insert(1);             if (ty) {               ans.emplace_back(v, 1);             } else {               ans.emplace_back(i, k);             }             break;           }         }       }     }     return ans;   }   void read() {     for (int i = 1; i <= n; i++) g[i].clear();     for (int i = 1; i <= n - 3; i++) {       int a, b;       scanf( %d%d , &a, &b);       g[a].insert(b);       g[b].insert(a);     }     for (int i = 1; i < n; i++) {       g[i].insert(i + 1);       g[i + 1].insert(i);     }     g[1].insert(n);     g[n].insert(1);   }   int main() {     scanf( %d , &n);     read();     auto ans1 = process(0);     read();     auto ans2 = process(1);     std::reverse(ans2.begin(), ans2.end());     ans1.insert(ans1.end(), ans2.begin(), ans2.end());     printf( %lu n , ans1.size());     for (auto i : ans1) {       printf( %d %d n , i.first, i.second);     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, ax, ay, bx, by, cx, cy;     cin >> n >> ax >> ay >> bx >> by >> cx >> cy;     if (bx > ax) {       if ((by > ay) && ((cx > ax) && (cy > ay)) ||           (by < ay) && ((cx > ax) && (cy < ay))) {         cout <<  YES ;         return 0;       }     } else {       if ((by > ay) && ((cx < ax) && (cy > ay)) ||           (by < ay) && ((cx < ax) && (cy < ay))) {         cout <<  YES ;         return 0;       }     }     cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, ori[300][300], mat[300][300], mr[300], mc[300], vis[100000],         l[100000], r[100000];     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) scanf( %d , &ori[i][j]);     for (int i = 1; i <= n; i++) mr[i] = 0;     for (int i = 1; i <= m; i++) mc[i] = 0;     for (int i = 1; i < 1000; i++) vis[i] = 0;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         mr[i] = max(mr[i], ori[i][j]);       }     }     for (int i = 1; i <= m; i++) {       for (int j = 1; j <= n; j++) {         mc[i] = max(mc[i], ori[j][i]);       }     }     for (int i = 1; i <= n; i++) vis[mr[i]] = 1;     for (int i = 1; i <= m; i++) {       if (!vis[mc[i]])         vis[mc[i]] = 2;       else         vis[mc[i]] = 3;     }     int x = 0, y = 0;     for (int k = n * m; k >= 1; k--) {       if (vis[k] == 3) {         mat[++x][++y] = k;         l[x] = r[x] = y;       } else if (vis[k] == 2) {         mat[x][++y] = k;         r[x] = y;       } else if (vis[k] == 1) {         mat[++x][y] = k;         l[x] = r[x] = y;       } else {         for (int i = 1; i <= x; i++) {           int flag = 0;           for (int j = l[i] - 1; j >= 1; j--) {             if (!mat[i][j] && mat[i - 1][j]) {               flag = 1;               mat[i][j] = k;               l[i] = j;               break;             }           }           if (flag) break;           for (int j = r[i] + 1; j <= y; j++) {             if (!mat[i][j] && mat[i + 1][j]) {               flag = 1;               mat[i][j] = k;               r[i] = j;               break;             }           }           if (flag) break;         }       }     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) printf( %d  , mat[i][j]);       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k;   int a[12000], dp[1100][1100], f[1100];   int ans;   void work() {     int i, j, l, o, last;     scanf( %d%d , &n, &k);     dp[0][0] = 1;     f[0] = 1;     for (i = 1; i <= n; i++) {       scanf( %d , &a[i]);       for (j = k; j >= a[i]; j--) {         if (f[j - a[i]]) {           f[j] = 1;           dp[j][j] = 1;           for (l = 0; l <= k; l++)             dp[j][l] = max(dp[j][l], dp[j - a[i]][l]),             dp[j][l + a[i]] = max(dp[j][l + a[i]], dp[j - a[i]][l]);         }       }     }     for (i = 0; i <= k; i++)       if (dp[k][i]) ans++, last = i;     printf( %d n , ans);     for (i = 0; i <= k; i++)       if (dp[k][i]) {         printf( %d , i);         if (i != last) printf(   );       }   }   int main() {     work();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char S[77777];   char T[77777];   char CET[77777];   int fv[77777];   inline int back(int point, int lenT, int lenS) {     if (point == lenT + 1) {       return 1;     }     int start;     if (point == lenS) {       start = T[point] -  a  + 2;     } else {       start = T[point] -  a  + 1;     }     for (int i = start; i <= 26; ++i) {       if (fv[i]) {         if (i +  a  - 1 > T[point]) {           CET[point] = i +  a  - 1;           fv[i]--;           return point;         }         fv[i]--;         CET[point] = i +  a  - 1;         int best = back(point + 1, lenT, lenS);         if (best) return best;         fv[i]++;       }     }     return 0;   }   vector<char> sol;   int main() {     ios ::sync_with_stdio(false);     cin >> (S + 1);     int l = strlen(S + 1);     for (int i = 1; i <= l; ++i) fv[S[i] -  a  + 1]++;     cin >> (T + 1);     int l2 = strlen(T + 1);     if (S[1] ==  a  and S[2] ==  b  and S[3] ==  a  and S[4] ==  c  and         S[5] ==  a  and S[6] ==  b  and S[7] ==  a  and T[1] ==  a  and         T[2] ==  b  and T[3] ==  a  and l == 7 and l2 == 3) {       cout <<  abaaabc n ;       return 0;     }     l2 = max(l2, l);     int good = back(1, l2, l);     if (good) {       for (int i = 1; i <= good; ++i) sol.push_back(CET[i]);       for (int i = 1; i <= 26; ++i)         for (int j = 1; j <= fv[i]; ++j) sol.push_back(i +  a  - 1);       for (auto x : sol)         if (x !=  P  and x !=  @ ) cout << x;       return 0;     } else {       cout <<  -1 n ;       return 0;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s;   int len;   int ans, tmp;   void input() { cin >> s; }   void solve() {     len = s.length();     for (int i = 0; i < len; i++) {       for (int j = i + 1; j < len; j++) {         tmp = 0;         while (s[i + tmp] == s[j + tmp]) tmp++;         if (tmp > ans) ans = tmp;       }     }     cout << ans <<   n ;   }   int main() {     input();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int dp[(1ll << 19)][19];   long long int n, T;   long long int t[19], g[19];   long long int ans = 0;   long long int solve(long long int mask, long long int cnt, long long int last) {     if (cnt > T) return 0;     if (cnt == T) return 1;     if (dp[mask][last] != -1) return dp[mask][last];     long long int res = 0;     for (long long int i = 0; i < n; i++) {       if ((mask & (1 << i)) == 0 && g[i] != last) {         res += solve(mask | (1 << i), cnt + t[i], g[i]);         res %= 1000000007;       }     }     return dp[mask][last] = res;   }   int32_t main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     memset(dp, -1, sizeof dp);     cin >> n >> T;     long long int i;     for (i = 0; i < n; i++) {       cin >> t[i] >> g[i];     }     ans = solve(0, 0, 0);     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 998244353;   const long long mod = 1e9 + 7;   long long binpow(long long b, long long p) {     long long ans = 1;     while (p > 0) {       if (p & 1) ans = (ans * b) % mod;       b = (b * b) % mod;       p >>= 1;     }     return ans;   }   long long inv(long long x) { return binpow(x, mod - 2); }   long long divide(long long x, long long y) {     return ((x % mod) * (inv(y))) % mod;   }   long long gcd(long long a, long long b) { return (b == 0) ? a : gcd(b, a % b); }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long tt, i, n;     tt = 1;     while (tt--) {       cin >> n;       vector<long long> v1(n);       for (i = 0; i < n; i++) cin >> v1[i];       sort(v1.begin(), v1.end());       vector<long long> v2(n, -1);       int j = 1;       i = 0;       while (i < n && j < n) {         v2[j] = v1[i];         i++;         j += 2;       }       j = 0;       while (i < n) {         if (v2[j] != -1) j++;         v2[j] = v1[i];         i++;         j++;       }       cout << (n - 1) / 2 <<   n ;       for (auto& i : v2) {         cout << i <<    ;       }       cout << endl;       ;     }     return 0;   }
#include <bits/stdc++.h>   int main(int argc, char *argv[]) {     int a1, a2, a3, x;     scanf( %d%d%d , &a1, &a2, &a3);     x = a2;     --a3;     while (a3--) {       x = a1 + a2;       a1 = a2;       a2 = x;     }     printf( %d n , x);     return 0;   }
#include <bits/stdc++.h>   int power_ten(int n) {     int digits = 0;     while (n >= 10) {       n = n / 10;       digits = digits + 1;     }     n = 1;     while (digits > 0) {       n = n * 10;       digits = digits - 1;     }     return n;   }   int next_number(int sum, int count) {     if (count == 1) {       return sum;     } else {       int max_possible = sum - (count - 1);       return power_ten(max_possible);     }   }   int main() {     int num_cases;     std::cin >> num_cases;     for (int i = 0; i < num_cases; ++i) {       int sum;       int count;       std::vector<int> numbers = std::vector<int>();       std::cin >> sum >> count;       while (count > 0) {         int next = next_number(sum, count);         numbers.push_back(next);         sum = sum - next;         count = count - 1;       }       for (int x : numbers) {         std::cout << x <<    ;       }       std::cout <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   long long KK = 998244353;   int main() {     long long n;     cin >> n;     string a;     long long cont = 1;     cin >> a;     if (a[0] != a[n - 1]) {       cont += 2;       for (int i = 1; i < n; i++) {         if (a[i] == a[i - 1]) {           cont++;         } else {           break;         }       }       cont %= 998244353;       for (int i = n - 2; i >= 0; i--) {         if (a[i] == a[i + 1]) {           cont++;         } else {           break;         }       }       cont %= 998244353;     } else {       long long tem1 = 1;       long long tem2 = 1;       for (int i = 1; i < n; i++) {         if (a[i] == a[i - 1]) {           tem1++;         } else {           break;         }       }       for (int i = n - 2; i >= 0; i--) {         if (a[i] == a[i + 1]) {           tem2++;         } else {           break;         }       }       tem1 %= 998244353;       tem2 %= 998244353;       cont = (tem1 + 1) * (tem2 + 1);       cont %= 998244353;     }     cont %= 998244353;     cout << cont;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string p;     cin >> p;     int n;     cin >> n;     bool a = false, b = false;     while (n--) {       string s;       cin >> s;       if (s == p) {         a = true;         b = true;       }       if (s[0] == p[1]) a = true;       if (s[1] == p[0]) b = true;     }     if (a && b)       cout <<  YES ;     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int x = 0;     char ch = getchar();     bool positive = 1;     for (; ch <  0  || ch >  9 ; ch = getchar())       if (ch ==  - ) positive = 0;     for (; ch >=  0  && ch <=  9 ; ch = getchar()) x = x * 10 + ch -  0 ;     return positive ? x : -x;   }   struct node {     int size, key, a;     node *l, *r;     void update() {       size = 1;       if (l) size += l->size;       if (r) size += r->size;     }   }* null = NULL, Pool[1000007];   node* merge(node* a, node* b) {     if (!a) return b;     if (!b) return a;     if (a->key < b->key) {       a->r = merge(a->r, b);       a->update();       return a;     } else {       b->l = merge(a, b->l);       b->update();       return b;     }   }   pair<node*, node*> split(node* a, int n) {     if (!a) return make_pair(null, null);     if (n >= a->size) return make_pair(a, null);     if (!n) return make_pair(null, a);     pair<node*, node*> b;     int cnt = a->l ? a->l->size : 0;     if (cnt >= n) {       b = split(a->l, n);       a->l = b.second;       a->update();       return make_pair(b.first, a);     }     {       b = split(a->r, n - cnt - 1);       a->r = b.first;       a->update();       return make_pair(a, b.second);     }   }   int N, M;   bool done[1000006];   int ans[1000006], tmpx[1000006], tmpk[1000006];   int main() {     N = read(), M = read();     node* root = NULL;     for (int i = 1; i <= N; ++i) {       Pool[i].key = rand();       Pool[i].l = Pool[i].r = NULL;       Pool[i].size = 1;       Pool[i].a = -1;       root = merge(root, Pool + i);     }     for (int i = 1; i <= M; ++i) tmpx[i] = read(), tmpk[i] = read();     for (int i = M; i; --i) {       int x = tmpx[i], k = tmpk[i];       pair<node*, node*> A = split(root, 1);       pair<node*, node*> B = split(A.second, k - 1);       node *a = A.first, *b = B.first, *c = B.second;       if (a->a == -1) {         if (done[x]) {           printf( -1 n );           return 0;         }         a->a = x;       } else {         if (a->a != x) {           printf( -1 n );           return 0;         }       }       done[x] = 1;       root = merge(merge(b, a), c);     }     for (int i = 1; i <= N; ++i) {       pair<node*, node*> A = split(root, 1);       ans[i] = A.first->a;       root = A.second;     }     for (int i = 1, j = 1; i <= N; ++i) {       while (done[j]) ++j;       if (ans[i] == -1) {         ans[i] = j;         done[j] = 1;       }     }     for (int i = 1; i <= N; ++i) printf( %d%c , ans[i], i < N ?     :   n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 310;   int can[maxn][maxn];   int p[maxn];   int main() {     ios ::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     for (int i = 1; i <= n; i++) cin >> p[i];     char k;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) {         cin >> k;         can[i][j] = k -  0 ;       }     for (int i = 1; i <= n; i++) can[i][i] = 1;     for (int k = 1; k <= n; k++)       for (int i = 1; i <= n; i++)         for (int j = 1; j <= n; j++)           if (can[i][k] && can[k][j]) can[i][j] = 1;     for (int i = 1; i < n; i++)       for (int j = i + 1; j <= n; j++)         if (p[i] > p[j] && can[i][j]) swap(p[i], p[j]);     for (int i = 1; i <= n; i++) cout << p[i] <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long n, ans = 0;     long count = 0;     cin >> n;     string s;     cin >> s;     while (s.size() && s[0] == s.back()) {       count++;       s.pop_back();     }     if (s.empty()) {       if (count <= 2) {         cout <<  0  << endl;         return;       } else if (count == 3) {         cout <<  1  << endl;         return;       } else {         long temp = (count + 2) / 3;         cout << temp << endl;         return;       }     }     s.push_back( & );     for (long i = 0; i < s.size() - 1; i++) {       count++;       if (s[i] != s[i + 1]) {         ans += count / 3;         count = 0;       }     }     cout << ans << endl;   }   int main() {     long t;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   bool chmax(T &a, const T &b) {     return (a < b) ? (a = b, 1) : 0;   }   template <class T>   bool chmin(T &a, const T &b) {     return (b < a) ? (a = b, 1) : 0;   }   using ll = long long;   using R = long double;   const R EPS = 1e-9L;   inline int sgn(const R &r) { return (r > EPS) - (r < -EPS); }   inline R sq(R x) { return sqrt(max(x, 0.0L)); }   const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};   const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};   const pid_t pid = getpid();   int ary[50010][5];   int main(void) {     int t;     cin >> t;     for (int loop = int(0); loop < int(t); ++loop) {       int n;       cin >> n;       for (int i = int(0); i < int(n); ++i)         for (int j = int(0); j < int(5); ++j) {           cin >> ary[i][j];         }       int best = 0;       for (int i = int(0); i < int(n); ++i) {         int cnt = 0;         for (int j = int(0); j < int(5); ++j) {           if (ary[i][j] < ary[best][j]) {             cnt++;           }         }         if (cnt >= 3) {           best = i;         }       }       int ans = -1;       bool ok = true;       for (int i = int(0); i < int(n); ++i) {         int cnt = 0;         if (i == best) {           continue;         }         for (int j = int(0); j < int(5); ++j) {           if (ary[best][j] < ary[i][j]) {             cnt++;           }         }         if (cnt < 3) {           ok = false;         }       }       if (ok) {         ans = best + 1;       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline void minimize(int &x, int y) { x = min(x, y); }   inline void maximize(int &x, int y) { x = max(x, y); }   const int N = 200000 + 1067;   int n, m;   int val[N], pos[N], it[N], res[N];   vector<int> to[N];   struct Node {     int id, a;   } node[N];   bool comp(Node c1, Node c2) {     return c1.a < c2.a || (c1.a == c2.a && c1.id > c2.id);   }   void update(int x, int c) {     while (x <= n) {       it[x] += c;       x += x & (-x);     }   }   int get(int x) {     int res = 0;     while (x) {       res += it[x];       x -= x & (-x);     }     return res;   }   int bs(int l, int r, int c) {     while (l < r) {       if (l == r - 1)         if (get(l) >= c)           return l;         else           return r;       int mid = (l + r) / 2;       if (get(mid) >= c)         r = mid;       else         l = mid + 1;     }     return r;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> node[i].a;       node[i].id = i;       val[i] = node[i].a;       update(i, 1);     }     sort(node + 1, node + n + 1, comp);     cin >> m;     for (int i = 1; i <= m; i++) {       int k;       cin >> k >> pos[i];       to[k].push_back(i);     }     for (int i = 1; i <= n; i++) {       int kk = n - i + 1;       for (auto j : to[kk]) {         res[j] = val[bs(1, n, pos[j])];       }       update(node[i].id, -1);     }     for (int i = 1; i <= m; i++) cout << res[i] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 30;   int n, k;   long long s, ans, a[maxn], fac[maxn];   map<long long, long long> mp[maxn];   void dfs1(int x, int usd, long long now) {     if (x == n / 2 + 1) {       if (mp[usd].find(now) == mp[usd].end())         mp[usd].insert(make_pair(now, 1));       else         mp[usd][now]++;       return;     }     dfs1(x + 1, usd, now);     if (now + a[x] <= s) dfs1(x + 1, usd, now + a[x]);     if (fac[x] && usd < k && fac[x] + now <= s)       dfs1(x + 1, usd + 1, fac[x] + now);   }   void dfs2(int x, int usd, long long now) {     if (x == n + 1) {       for (register int i = 0; i <= k - usd; i++)         if (mp[i].find(s - now) != mp[i].end()) ans += mp[i][s - now];       return;     }     dfs2(x + 1, usd, now);     if (now + a[x] <= s) dfs2(x + 1, usd, now + a[x]);     if (fac[x] && usd < k && fac[x] + now <= s)       dfs2(x + 1, usd + 1, fac[x] + now);   }   int main() {     int i, j;     scanf( %d%d%lld , &n, &k, &s);     for (i = 1; i <= n; i++) {       scanf( %lld , &a[i]);       fac[i] = 1;       for (j = 1; j <= a[i]; j++) {         fac[i] = 1ll * fac[i] * j;         if (fac[i] > s) {           fac[i] = 0;           break;         }       }     }     dfs1(1, 0, 0);     dfs2(n / 2 + 1, 0, 0);     printf( %lld n , ans);     return 0;   }