malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   using ll = long long int;   string s, t;   int mp[28], tempMap[28];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int i, j, len1, len2, can = -1;     cin >> s >> t;     len1 = (int)s.size(), len2 = (int)t.size();     for (i = 0; i < len1; i++) {       mp[s[i] -  a ]++;     }     int rng = min(len1, len2) - 1;     if (len1 > len2) rng++;     for (i = 0; i < rng; i++) {       if (mp[t[i] -  a ]) {         mp[t[i] -  a ]--;         for (j = 0; j < 26; j++) {           tempMap[j] = mp[j];         }         bool flag = false;         if (i == len2 - 1) {           if (len1 > len2 && i == rng - 1) flag = true, can = i;         } else {           for (j = t[i + 1] -  a  + 1; j < 26; j++) {             if (mp[j]) {               flag = true;               break;             }           }           if (flag) can = i;         }       } else {         break;       }     }     memset(mp, 0, sizeof mp);     for (i = 0; i < len1; i++) mp[s[i] -  a ]++;     if (can == -1) {       int found = -1;       for (i = t[0] -  a  + 1; i < 26; i++) {         if (mp[i]) {           found = i;           break;         }       }       if (found == -1)         cout << -1 << endl;       else {         cout << (char)(found +  a );         mp[found]--;         for (i = 0; i < 26; i++) {           for (j = 0; j < mp[i]; j++) {             cout << (char)(i +  a );           }         }         cout << endl;       }     } else {       for (i = 0; i <= can; i++) {         cout << t[i];         mp[t[i] -  a ]--;       }       if (len1 > len2 && can == len2 - 1) {         for (i = 0; i < 26; i++) {           for (j = 0; j < mp[i]; j++) {             cout << (char)(i +  a );           }         }         cout << endl;       } else {         for (i = t[can + 1] -  a  + 1; i < 26; i++) {           if (mp[i]) {             cout << (char)(i +  a );             mp[i]--;             break;           }         }         for (i = 0; i < 26; i++) {           for (j = 0; j < mp[i]; j++) {             cout << (char)(i +  a );           }         }         cout << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   int main() {     int n, h, arr[1000], c = 0, i;     scanf( %d %d , &n, &h);     for (i = 0; i < n; i++) {       scanf( %d , &arr[i]);       if (arr[i] > h)         c = c + 2;       else         c = c + 1;     }     printf( %d , c);     return 0;   }
#include <bits/stdc++.h>   const int M = 5004;   int n, m, a[55], b[55];   double p[55], eps = 1e-9;   double f[55][5005], cnt;   double chk(double x) {     for (int i = n; i >= 1; i--) {       for (int j = m + 1; j <= M; j++) f[i + 1][j] = x;       for (int j = 0; j <= m; j++) {         f[i][j] = (f[i + 1][j + a[i]] + a[i]) * p[i] +                   (f[i + 1][j + b[i]] + b[i]) * (1 - p[i]);         if (f[i][j] > x) f[i][j] = x;       }     }     return f[1][0];   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) {       scanf( %d%d%lf , &a[i], &b[i], &p[i]);       p[i] = p[i] / 100;     }     double l = 0, r = 1e9;     while (l + eps < r) {       long double mid = (l + r) / 2.0;       if (chk(mid) < mid)         r = mid;       else         l = mid;       cnt++;       if (cnt > 128) break;     }     printf( %.9lf n , l);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string a;     vector<string> input;     int n;     cin >> n;     bool flag = false;     for (int i = 0; i < n; i++) {       cin >> a;       if (!flag && a[0] == a[1] && a[0] ==  O ) {         a[0] =  + ;         a[1] =  + ;         flag = true;       }       if (!flag && a[3] == a[4] && a[3] ==  O ) {         a[3] =  + ;         a[4] =  + ;         flag = true;       }       input.push_back(a);     }     if (flag) {       cout <<  YES  << endl;       for (int i = 0; i < n; i++) {         cout << input[i] << endl;       }     } else       cout <<  NO  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   long long lb = 1000;   void vrikodara(long long n = 12) {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cout << setprecision(n) << fixed;   }   void solve() {     string s, t;     cin >> s >> t;     vector<long long> v1(26, 0), v2(26, 0);     for (auto i : s) v1[i -  a ]++;     for (auto i : t) v2[i -  a ]++;     long long n = t.length();     long long a = n;     if (s.length() <= n) {       a = s.length();       a--;     }     t += 55;     for (long long i = a - 1; i >= -1; i--) {       vector<long long> v = v1;       bool flag = true;       string ans =   ;       for (long long j = 0; j <= i; j++) {         if (!v[t[j] -  a ]) {           flag = false;           break;         }         ans += t[j];         v[t[j] -  a ]--;       }       if (flag) {         char ch = t[i + 1];         flag = false;         for (long long i = 0; i < 26; i++) {           if (v[i] && (char)( a  + i) > ch) {             v[i]--;             char r = (char)(i +  a );             ans += r;             for (long long i = 0; i < 26; i++) {               while (v[i]--) {                 char r = (char)(i +  a );                 ans += r;               }             }             cout << ans;             return;           }         }       }     }     cout <<  -1 ;   }   int32_t main() {     vrikodara();     long long t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> gaps(1e5 + 1);   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     long long t;     cin >> t;     while (t--) {       long long a, b, c, n;       cin >> a >> b >> c;       n = (abs(b - a)) * 2;       long long ans = ((n / 2) + c);       if (ans > n) ans = ans % n;       if (n % 2 != 0 || c > n || a > n || b > n || ans > n || ans == a ||           ans == b)         ans = -1;       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void print(vector<T> v) {     for (T e : v) {       cout << e <<    ;     }     cout << endl;   }   template <typename T>   void print(vector<vector<T>> v) {     int n = v.size();     for (int i = 0; i < n; i++) {       cout << i <<  :  ;       for (T e : v[i]) {         cout << e <<    ;       }       cout << endl;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     vector<int> a(6);     for (int i = 0; i < 6; i++) {       cin >> a[i];     }     cout << (int)(pow(a[0] + a[1] + a[2], 2) - a[0] * a[0] - a[2] * a[2] -                   a[4] * a[4])          << endl;   }
#include <bits/stdc++.h>   using namespace std;   const unsigned long long maxn = 1000 + 10;   const int INF = 0x3f3f3f3f;   const double eps = 1e-10;   const double pi = acos(-1.0);   int g[maxn][maxn];   struct haha {     int x, y, w;   } p[maxn * 10], p0[maxn * 10];   struct Edge {     int from, to, dist;   };   struct HeapNode {     int d, u;     bool operator<(const HeapNode& rhs) const { return d > rhs.d; }   };   struct Dijkstra {     int n, m;     vector<Edge> edges;     vector<int> G[maxn];     bool done[maxn];     int d[maxn];     int p[maxn];     void init(int n) {       this->n = n;       for (int i = 0; i < n; ++i) G[i].clear();       edges.clear();     }     void AddEdge(int from, int to, int dist) {       edges.push_back((Edge){from, to, dist});       m = edges.size();       G[from].push_back(m - 1);     }     void dijkstra(int s) {       priority_queue<HeapNode> Q;       p[s] = -1;       for (int i = 0; i < n; ++i) d[i] = INF;       d[s] = 0;       memset(done, 0, sizeof done);       Q.push((HeapNode){0, s});       while (!Q.empty()) {         HeapNode x = Q.top();         Q.pop();         int u = x.u;         if (done[u]) continue;         done[u] = true;         for (int i = 0; i < G[u].size(); ++i) {           Edge& e = edges[G[u][i]];           if (d[e.to] > d[u] + e.dist) {             d[e.to] = d[u] + e.dist;             p[e.to] = e.from;             Q.push((HeapNode){d[e.to], e.to});           }         }       }     }   } dij;   int main() {     int n, m, L, s, t;     int cnt = 0, cnt2 = 0;     scanf( %d %d %d %d %d , &n, &m, &L, &s, &t);     dij.init(n);     for (int i = 0; i < m; ++i) {       int u, v, w;       scanf( %d %d %d , &u, &v, &w);       g[u][v] = g[v][u] = w;       if (w) {         p[cnt].x = u;         p[cnt].w = w;         p[cnt++].y = v;         dij.AddEdge(u, v, w);         dij.AddEdge(v, u, w);       } else {         p0[cnt2].x = u;         p0[cnt2].w = 0;         p0[cnt2++].y = v;       }     }     dij.dijkstra(s);     if (dij.d[t] < L) return 0 * puts( NO );     if (dij.d[t] == L) {       puts( YES );       for (int i = 0; i < cnt; ++i) {         printf( %d %d %d n , p[i].x, p[i].y, p[i].w);       }       for (int i = 0; i < cnt2; ++i) {         printf( %d %d %d n , p0[i].x, p0[i].y, INF);       }       return 0;     }     int pos = -1;     for (int i = 0; i < cnt2; ++i) {       dij.AddEdge(p0[i].x, p0[i].y, 1);       dij.AddEdge(p0[i].y, p0[i].x, 1);       dij.dijkstra(s);       if (dij.d[t] > L) continue;       pos = i;       break;     }     if (pos == -1) return 0 * puts( NO );     puts( YES );     for (int i = 0; i < cnt; ++i) {       printf( %d %d %d n , p[i].x, p[i].y, p[i].w);     }     for (int i = 0; i < pos; ++i) printf( %d %d %d n , p0[i].x, p0[i].y, 1);     printf( %d %d %d n , p0[pos].x, p0[pos].y, L - dij.d[t] + 1);     for (int i = pos + 1; i < cnt2; ++i)       printf( %d %d %d n , p0[i].x, p0[i].y, INF);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long int;   using int64 = long long int;   template <typename T>   void chmax(T &a, T b) {     a = max(a, b);   }   template <typename T>   void chmin(T &a, T b) {     a = min(a, b);   }   template <typename T>   void chadd(T &a, T b) {     a = a + b;   }   int dx[] = {0, 0, 1, -1};   int dy[] = {1, -1, 0, 0};   const ll INF = 1001001001001001LL;   const ll MOD = 1000000007LL;   int main() {     int N;     scanf( %d , &N);     vector<int> A(N);     for (int i = 0; i < N; i++) scanf( %d , &A[i]);     sort(A.begin(), A.end());     ll ans = INF;     {       for (int x = 1; x * x <= A[0]; x++) {         int d = A[0] / x, m = A[0] % x;         for (int k = d; k >= d - (m == 0); k--) {           int mi = k, ma = k + 1;           ll sum = 0;           for (int i = 0; i < N; i++) {             ll b = (A[i] + ma - 1) / ma;             if (mi * b <= A[i])               sum += b;             else               sum = INF;           }           ans = min(ans, sum);         }       }     }     {       for (int x = 1; x * x <= A[0]; x++) {         int mi = x, ma = x + 1;         ll sum = 0;         for (int i = 0; i < N; i++) {           ll b = (A[i] + ma - 1) / ma;           if (mi * b <= A[i])             sum += b;           else             sum = INF;         }         ans = min(ans, sum);       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   const int N = 100010;   const int inf = 0x3f3f3f3f;   using namespace std;   map<string, int> A, B;   string y;   int solve(string x) {     y =   ;     int sz = x.size();     int a = 0, b = 0;     for (int i = 0; i < sz; i++) {       if (x[i] ==  * )         a++;       else if (x[i] ==  & )         b++;       else         y += x[i];     }     if (B[y] == 0 || A[y] == inf || (A[y] + a - b) < 0) return inf;     return A[y] + a - b;   }   int main() {     int n;     cin >> n;     A[ void ] = 0;     B[ void ] = 1;     for (int i = 0; i < n; i++) {       string a, b, c;       cin >> a >> b;       if (a ==  typedef ) {         cin >> c;         A[c] = solve(b);         B[c] = B[y];       } else {         A[b] = solve(b);         if (A[b] == inf)           puts( errtype );         else {           printf( void );           for (int j = 0; j < A[b]; j++) printf( * );           puts(  );         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline void read(int &data) {     data = 0;     int e = 1;     char ch = getchar();     while ((ch <  0  || ch >  9 ) && ch !=  - ) ch = getchar();     if (ch ==  - ) e = -1, ch = getchar();     while (ch >=  0  && ch <=  9 ) data = data * 10 + ch - 48, ch = getchar();     data *= e;   }   inline void read(long long &data) {     data = 0;     int e = 1;     char ch = getchar();     while ((ch <  0  || ch >  9 ) && ch !=  - ) ch = getchar();     if (ch ==  - ) e = -1, ch = getchar();     while (ch >=  0  && ch <=  9 ) data = data * 10 + ch - 48, ch = getchar();     data *= e;   }   inline void write(int data) {     if (data < 0) data = -data, putchar( - );     if (data > 9) write(data / 10);     putchar(data % 10 + 48);   }   inline void write(long long data) {     if (data < 0) data = -data, putchar( - );     if (data > 9) write(data / 10);     putchar(data % 10 + 48);   }   bool cmp(int a, int b) { return a < b; }   priority_queue<long long, vector<long long>, greater<long long> > q;   long long n, x, ans = 0;   int main() {     read(n);     for (int i = 1; i <= n; ++i) {       read(x);       if (q.empty() || q.top() > x)         q.push(x);       else {         ans += x - q.top();         q.pop();         q.push(x), q.push(x);       }     }     write(ans), puts(  );   }
#include <bits/stdc++.h>   using namespace std;   int x;   void dfsUtil(int node, int count, bool visited[], int& maxCount,                vector<vector<int> >& adj) {     visited[node] = true;     count++;     for (auto& i : adj[node]) {       if (!visited[i]) {         if (count >= maxCount) {           maxCount = count;           x = i;         }         dfsUtil(i, count, visited, maxCount, adj);       }     }   }   void dfs(int node, int n, vector<vector<int> >& adj, int& maxCount) {     bool visited[n];     int count = 0;     for (int i = 0; i < n; ++i) visited[i] = false;     dfsUtil(node, 1, visited, maxCount, adj);   }   int diameter(vector<vector<int> >& adj, int n) {     int maxCount = INT_MIN;     dfs(0, n, adj, maxCount);     dfs(x, n, adj, maxCount);     return maxCount;   }   bool vis[100010];   int dist[100010];   void dfs1(int v, int p, vector<vector<int> >& adj) {     if (vis[v]) return;     vis[v] = true;     if (p == -1)       dist[v] = 0;     else       dist[v] = dist[p] + 1;     for (auto& u : adj[v]) {       dfs1(u, v, adj);     }   }   void solve() {     int n, a, b, da, db;     cin >> n >> a >> b >> da >> db;     a--;     b--;     vector<vector<int> > adj(n);     for (int i = 0; i < n - 1; i++) {       int u, v;       cin >> u >> v;       u--;       v--;       adj[u].push_back(v);       adj[v].push_back(u);     }     if (db <= 2 * da) {       cout <<  Alice  << endl;       return;     }     for (int i = 0; i < n; i++) {       vis[i] = false;     }     dfs1(a, -1, adj);     if (dist[b] <= da) {       cout <<  Alice  << endl;       return;     }     if (diameter(adj, n) - 1 >= 2 * da + 1) {       cout <<  Bob  << endl;     } else {       cout <<  Alice  << endl;     }   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());     int t;     cin >> t;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   struct Nod {     int mark, label;   } nod[200010];   int val[200010];   bool cmp1(Nod n1, Nod n2) {     if (n1.mark != n2.mark) return n1.mark > n2.mark;     return n1.label < n2.label;   }   bool cmp2(Nod n1, Nod n2) {     if (n1.mark != n2.mark) return n1.mark > n2.mark;     return n1.label > n2.label;   }   int main() {     int n, a, b;     scanf( %d , &n);     scanf( %d%d , &a, &b);     for (int i = 0; i < n; ++i) {       scanf( %d , &nod[i].mark);       nod[i].label = i;     }     if (a == b) {       for (int i = 1; i < n; ++i)         if (i <= n / 2)           printf( 1  );         else           printf( 2  );       printf( 2 n );       return 0;     }     if (a < b) {       sort(nod, nod + n, cmp1);       for (int i = 0; i < n; ++i) {         if (i < a)           val[nod[i].label] = 1;         else           val[nod[i].label] = 2;       }     } else {       sort(nod, nod + n, cmp2);       for (int i = 0; i < n; ++i) {         if (i < b)           val[nod[i].label] = 2;         else           val[nod[i].label] = 1;       }     }     for (int i = 0; i < n - 1; ++i) printf( %d  , val[i]);     printf( %d n , val[n - 1]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int s[100], t[100], n, p, i, j, solv, tim, c;     scanf( %d%d , &n, &p);     for (i = 0; i < n; i++) {       scanf( %d%d , &s[i], &t[i]);     }     for (i = 1; i < n; i++)       for (j = 0; j < n - i; j++)         if (s[j] < s[j + 1] || (s[j] == s[j + 1] && t[j] > t[j + 1])) {           swap(s[j], s[j + 1]);           swap(t[j], t[j + 1]);         }     solv = s[p - 1];     tim = t[p - 1];     c = 0;     for (i = p - 1; i >= 0; i--) {       if (solv == s[i] && t[i] == tim)         c++;       else         break;     }     for (i = p; i < n; i++) {       if (solv == s[i] && t[i] == tim)         c++;       else         break;     }     printf( %d , c);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool valid(string s) {     int start = 0, end = s.length() - 1;     while (start < end) {       if (s[start] ==  a  && s[end] ==  a ) {         start++;         end--;       } else if (s[start] ==  a  && s[end] ==  z ) {         return false;       } else if (s[start] ==  z  && s[end] ==  a ) {         return false;       } else if (s[start] ==  z  && s[end] ==  z ) {         start++;         end--;       } else if (s[start] ==  z ) {         if (abs(s[start] - s[end]) == 2 || abs(s[start] - s[end]) == 0) {           start++;           end--;         } else {           return false;         }       } else if (s[start] ==  a ) {         if (abs(s[start] - s[end]) == 2 || abs(s[start] - s[end]) == 0) {           start++;           end--;         } else {           return false;         }       } else if (s[end] ==  a ) {         if (abs(s[start] - s[end]) == 2 || abs(s[start] - s[end]) == 0) {           start++;           end--;         } else {           return false;         }       } else if (s[end] ==  z ) {         if (abs(s[start] - s[end]) == 2 || abs(s[start] - s[end]) == 0) {           start++;           end--;         } else {           return false;         }       } else {         if (abs(s[start] - s[end]) == 2 || abs(s[start] - s[end]) == 0) {           start++;           end--;         } else {           return false;         }       }     }   }   int main() {     int n, t;     string s;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d , &t);       cin >> s;       if (valid(s))         cout <<  YES  << endl;       else         cout <<  NO  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using lli = long long int;   int main() {     std::string str;     lli q, a, b, n, needSum;     lli ost = 0;     std::cin >> q;     for (int i = 0; i < q; ++i) {       std::cin >> a >> b >> n >> needSum;       if (a * n == needSum || b == needSum) {         std::cout <<  Yes  << std::endl;         continue;       }       if (a * n > needSum) {         ost = needSum % n;         if (b >= ost) {           std::cout <<  Yes  << std::endl;           continue;         }       } else {         if (a * n + b >= needSum) {           std::cout <<  Yes  << std::endl;           continue;         }       }       std::cout <<  No  << std::endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 5;   int num[5005], cnt[5005] = {}, id[5005];   int dp[5005][5005];   bool used[5005];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n, k;     cin >> n >> k;     for (int i = 1; i <= n; i++) cin >> num[i];     sort(num + 1, num + n + 1);     for (int i = 1; i <= n; i++) {       int r = i;       while (r + 1 <= n && (num[r + 1] - num[i]) <= 5) r++;       cnt[i] = r;     }     for (int i = n; i >= 1; i--) {       for (int j = 1; j <= k; j++) {         dp[i][j] = dp[i + 1][j];         dp[i][j] = max(dp[i][j], dp[cnt[i] + 1][j - 1] + cnt[i] - i + 1);       }     }     int ans = 0;     for (int i = 1; i <= n; i++) ans = max(ans, dp[1][i]);     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   long long int powerMod(long long int x, unsigned long long int y) {     if (y == 0) return 1;     long long int p = powerMod(x, y / 2) % 1000000007;     p = (p * p) % 1000000007;     return (y % 2 == 0) ? p : (x * p) % 1000000007;   }   long long int power(long long int x, unsigned long long int y) {     if (y == 0) return 1;     long long int p = power(x, y / 2);     p = (p * p);     return (y % 2 == 0) ? p : (x * p);   }   int main() {     cin.tie(0)->sync_with_stdio(0);     int t;     cin >> t;     while (t--) {       long long int n;       cin >> n;       vector<long long int> arr(n);       for (int i = 0; i < n; ++i) cin >> arr[i];       if (n % 2 == 0)         cout <<  YES n ;       else {         bool ok = true;         for (int i = 0; i < n - 1; ++i) {           if (arr[i + 1] <= arr[i]) {             ok = false;             break;           }         }         if (!ok)           cout <<  YES n ;         else           cout <<  NO n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 7;   int n, m, B, a[N], c[N], ans[N];   struct Node {     int l, r, id;     Node() {}     Node(int _l, int _r, int _id) { l = _l, r = _r, id = _id; }     bool operator<(const Node &p) const { return r < p.r; }   } Q[N];   vector<int> V, q[400];   int calc(int l, int r) {     int ret = 0;     for (int i = (l); i < (r + 1); ++i) {       int x = a[i];       ++c[x];       ret += c[x] == V[x];       ret -= c[x] == V[x] + 1;     }     for (int i = (l); i < (r + 1); ++i) c[a[i]] = 0;     return ret;   }   int main() {     scanf( %d%d , &n, &m);     B = sqrt(n);     for (int i = (0); i < (n); ++i) {       scanf( %d , &a[i]);       V.push_back(a[i]);     }     sort(V.begin(), V.end());     V.erase(unique(V.begin(), V.end()), V.end());     for (int i = (0); i < (n); ++i)       a[i] = lower_bound(V.begin(), V.end(), a[i]) - V.begin();     for (int i = (0); i < (m); ++i) {       int l, r;       scanf( %d%d , &l, &r);       Q[i] = Node(l - 1, r - 1, i);     }     sort(Q, Q + m);     for (int i = (0); i < (m); ++i)       if (Q[i].r - Q[i].l + 1 <= B) {         ans[Q[i].id] = calc(Q[i].l, Q[i].r);       } else {         q[Q[i].l / B + (Q[i].l % B > 0)].push_back(i);       }     for (int i = (0); i < (B + 1); ++i) {       int j = 0, k = 0, cnt = 0;       for (j = B * i; j < n && k < ((int)(q[i]).size()); ++j) {         ++c[a[j]];         cnt += c[a[j]] == V[a[j]], cnt -= c[a[j]] == V[a[j]] + 1;         while (k < ((int)(q[i]).size()) && j == Q[q[i][k]].r) {           int tmp = cnt;           for (int r = (Q[q[i][k]].l); r < (B * i); ++r) {             ++c[a[r]];             tmp += c[a[r]] == V[a[r]], tmp -= c[a[r]] == V[a[r]] + 1;           }           for (int r = (Q[q[i][k]].l); r < (B * i); ++r) --c[a[r]];           ans[Q[q[i][k++]].id] = tmp;         }       }       for (int r = (B * i); r < (j); ++r) c[a[r]] = 0;     }     for (int i = (0); i < (m); ++i) printf( %d n , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1);   const double eps = 1e-8;   const int maxn = 1e6 + 5;   const int maxm = 3e4 + 5;   const long long mod = 1e9 + 7;   const long long inf = 0x3f3f3f3f;   const int _inf = -1e9 + 7;   inline int scan() {     int m = 0;     char c = getchar();     while (c <  0  || c >  9 ) c = getchar();     while (c >=  0  && c <=  9 ) m = m * 10 + c -  0 , c = getchar();     return m;   }   int N, Q, S, M, K;   int num[200];   int dp[200][30000];   int main() {     cin >> N >> K >> S;     for (int i = 1; i <= N; i++) {       scanf( %d , num + i);     }     memset(dp, inf, sizeof dp);     dp[0][0] = 0;     for (int i = 1; i <= N; i++) {       for (int j = i - 1; j >= 0; j--) {         for (int k = i * j; k >= 0; k--) {           dp[j + 1][k + i - j - 1] =               min(dp[j + 1][k + i - j - 1], dp[j][k] + num[i]);         }       }     }     int ans = inf;     for (int i = 0; i <= min(S, N * N); i++) ans = min(ans, dp[K][i]);     cout << ans;     return 0;   }