malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int tree[(1 << 20)];   void add(int x, int val) {     for (int i = x; i < (1 << 20); i = ((i) | (i + 1))) tree[i] += val;   }   int sum(int x) {     int ans = 0;     for (int i = x; i > 0; i = ((i) & (i - 1))) ans += tree[i - 1];     return ans;   }   int N, Q;   map<int, int> idtohook;   map<int, int> appearance;   priority_queue<pair<int, int> > segments;   map<int, int> nextL, nextR;   vector<pair<int, pair<int, int> > > query;   map<int, int> zip;   vector<int> ans;   int input(void) {     int ans;     scanf( %d , &ans);     return ans;   }   void count_query(int low, int high) {     query.push_back(make_pair(0, make_pair(low, high)));     zip[low] = zip[high] = 0;   }   void enter_query(int id) {     int hook = -1;     while (1) {       pair<int, int> p = segments.top();       segments.pop();       int L = p.second;       int R = L + p.first;       if (nextR[L] != R || nextL[R] != L) continue;       hook = (L + R + 1) / 2;       nextL[hook] = L;       nextL[R] = hook;       nextR[L] = hook;       nextR[hook] = R;       segments.push(make_pair(hook - L, L));       segments.push(make_pair(R - hook, hook));       break;     }     query.push_back(make_pair(1, make_pair(hook, 1)));     idtohook[id] = hook;     zip[hook] = 0;   }   void leave_query(int id) {     int hook = idtohook[id];     int L = nextL[hook], R = nextR[hook];     nextL[hook] = nextR[hook] = -1;     nextL[R] = L;     nextR[L] = R;     segments.push(make_pair(R - L, L));     query.push_back(make_pair(1, make_pair(hook, -1)));   }   void solve(void) {     int i;     i = 0;     for (__typeof((zip).begin()) itr = (zip).begin(); itr != (zip).end(); itr++) {       (itr->second) = i;       i++;     }     for ((i) = 0; (i) < (int)(query.size()); (i)++) {       int type = query[i].first;       if (type == 0) {         int low = zip[query[i].second.first];         int high = zip[query[i].second.second];         int tmp = sum(high + 1);         if (low > 0) tmp -= sum(low);         ans.push_back(tmp);       } else {         int pos = zip[query[i].second.first];         add(pos, query[i].second.second);       }     }   }   int main(void) {     int i;     N = input();     Q = input();     segments.push(make_pair(N + 1, 0));     nextR[0] = N + 1;     nextL[N + 1] = 0;     zip[0] = zip[N + 1] = 0;     for ((i) = 0; (i) < (int)(Q); (i)++) {       int x = input();       if (x == 0) {         int low = input(), high = input();         count_query(low, high);       } else {         appearance[x]++;         int tmp = appearance[x];         if (tmp % 2 == 1) {           enter_query(x);         } else {           leave_query(x);         }       }     }     solve();     for ((i) = 0; (i) < (int)(ans.size()); (i)++) printf( %d n , ans[i]);     return 0;   }
#include <bits/stdc++.h>   int main() {     int x;     int n, m;     scanf( %d %d , &n, &m);     if (m == 3 && n > 4) {       printf( -1 n );       return 0;     }     for (x = 0; x < m; ++x) printf( %d %d n , x, x * x + 10001);     for (x = 0; x < n - m; ++x) printf( %d %d n , x, -x * x);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, tp;   int a[2000002];   int main() {     scanf( %d , &tp);     int p = 1, i, j;     for (i = 0; i <= 100; i++) {       n++;       if (p == tp) break;       p *= 4;     }     for (i = 0; i < tp; i++) scanf( %d , &a[i]);     sort(a, a + tp);     long long ans = 0;     p = 1;     for (i = 0; i < n; i++) {       for (j = 0; j < p; j++) ans += (long long)a[tp - j - 1];       p *= 4;     }     printf( %I64d , ans);   }
#include <bits/stdc++.h>   using namespace std;   int mod = 1000000007;   const int inf = 1034567891;   const long long LL_INF = 1234567890123456789ll;   template <typename Arg1>   void __f(const char* name, Arg1&& arg1) {     cout << name <<   :   << arg1 <<   n ;   }   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...);   }   template <typename T>   T GCD(T a, T b) {     long long t;     while (a) {       t = a;       a = b % a;       b = t;     }     return b;   }   template <typename T>   string toString(T a) {     return to_string(a);   }   template <typename T>   void toInt(string s, T& x) {     stringstream str(s);     str >> x;   }   inline int add(int x, int y) {     x += y;     if (x >= mod) x -= mod;     return x;   }   inline int sub(int x, int y) {     x -= y;     if (x < 0) x += mod;     return x;   }   inline int mul(int x, int y) { return (x * 1ll * y) % mod; }   inline int powr(int a, long long b) {     int x = 1 % mod;     while (b) {       if (b & 1) x = mul(x, a);       a = mul(a, a);       b >>= 1;     }     return x;   }   inline int inv(int a) { return powr(a, mod - 2); }   string str;   long long give(int l, int r) {     long long ans = 0, p = 0;     for (int i = r; i >= l; i--) {       ans += (1ll << p) * (str[i] - 48);       p++;     }     return ans;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int test;     cin >> test;     while (test--) {       cin >> str;       int n = str.size();       long long ans = 0;       int nxt = -1;       bool ok = false;       for (int i = n - 1; i >= 0; i--) {         if (!ok) {           nxt = i;         }         if (str[i] ==  1 ) {           nxt = i;         }         int e = nxt - i;         for (int j = nxt; j < nxt + 20 && j < n; j++) {           long long num = give(nxt, j);           if (num == (j - nxt + 1 + e)) {             ans++;           }         }         if (str[i] ==  1 ) {           ok = true;           nxt = i;         }       }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int OO = 0x3f3f3f3f, N = 1e5 + 5, mod = 1e9 + 7;   const double pi = acos(-1), EPS = 1e-8;   int n;   string str;   map<deque<char>, deque<char>> mp;   bool is(deque<char> ck, string s) {     if (ck.size() != s.size()) return 0;     for (int i = 0; i < s.size(); ++i)       if (ck[i] != s[i]) return 0;     return 1;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     deque<char> t;     t.push_back( v );     t.push_back( o );     t.push_back( i );     t.push_back( d );     mp[t] = t;     cin >> n;     cin.ignore();     while (n--) {       getline(cin, str);       bool out = 0;       deque<char> tmp, s;       for (int i = 0; i < str.size(); ++i) {         if (str[i] ==    ) {           if (tmp.size()) {             if (is(tmp,  typeof ))               out = 1;             else               s = tmp;           }           tmp.clear();         } else           tmp.push_back(str[i]);       }       deque<char> var = tmp;       if (out) {         int And = 0, pointer = 0;         while (var.front() ==  & ) ++And, var.pop_front();         while (var.back() ==  * ) ++pointer, var.pop_back();         if (mp[var].size() == 0) {           cout <<  errtype n ;           continue;         }         var = mp[var];         while (var.back() ==  * ) ++pointer, var.pop_back();         int x = min(And, pointer);         And -= x;         pointer -= x;         if (And)           cout <<  errtype n ;         else if (mp[var].size()) {           for (char go : mp[var]) cout << go;           while (pointer--) cout <<  * ;           cout <<   n ;         } else           cout <<  errtype n ;       } else {         int And = 0, pointer = 0;         while (s.front() ==  & ) {           ++And;           s.pop_front();         }         while (s.back() ==  * ) {           ++pointer;           s.pop_back();         }         int x = min(And, pointer);         pointer -= x;         And -= x;         if (mp[s].size()) {           s = mp[s];           while (s.back() ==  *  && And) {             --And;             s.pop_back();           }           while (s.front() ==  &  && pointer) {             --pointer;             s.pop_front();           }           if (And && mp[var].size())             mp.erase(var);           else if (And == 0) {             while (pointer--) s.push_back( * );             mp[var] = s;           }         } else if (mp[var].size())           mp.erase(var);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct debugger {     template <typename T>     debugger& operator,(const T& v) {       cerr << v <<   t ;       return *this;     }   } dbg;   template <class A, class B>   ostream& operator<<(ostream& o, const pair<A, B>& p) {     return o <<  (  << p.first <<  ,   << p.second <<  ) ;   }   template <class T>   ostream& operator<<(ostream& o, const vector<T>& v) {     o <<  [ ;     for (__typeof((v).end()) it = (v).begin(); it != (v).end(); ++it)       o << *it <<  ,  ;     return o <<  ] ;   }   template <class T>   ostream& operator<<(ostream& o, const set<T>& v) {     o <<  [ ;     for (__typeof((v).end()) it = (v).begin(); it != (v).end(); ++it)       o << *it <<  ,  ;     return o <<  ] ;   }   template <class T>   inline void MAX(T& a, T b) {     if (a < b) a = b;   }   template <class T>   inline void MIN(T& a, T b) {     if (a > b) a = b;   }   template <class T>   inline bool read(T& x) {     int c = getchar();     int sgn = 1;     while (~c && c <  0  || c >  9 ) {       if (c ==  - ) sgn = -1;       c = getchar();     }     for (x = 0; ~c &&  0  <= c && c <=  9 ; c = getchar()) x = x * 10 + c -  0 ;     x *= sgn;     return ~c;   }   int a[15], l = 0;   int main() {     memset(a, 0, sizeof a);     for (__typeof((6) - 1) i = (0); i <= (6) - 1; ++i) {       int x = ({         int a;         scanf( %d , &a);         a;       });       a[x]++;       if (a[x] >= 4) l = x;     }     if (!l)       puts( Alien );     else {       a[l] -= 4;       int c = 0;       for (__typeof((10) - 1) i = (0); i <= (10) - 1; ++i)         if (a[i]) c++;       if (c > 1)         puts( Bear );       else         puts( Elephant );     }   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast,unroll-loops )   #pragma loop - opt(on)   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,avx,avx2,fma,tune=native )   using namespace std;   const long long mxN = 1e5 + 5;   long long n, m, Q;   bitset<mxN> vis, in, incy;   long long dsu[mxN], lca[mxN], eu[mxN], ev[mxN], tag[mxN], sum[mxN];   vector<long long> g[mxN], q[mxN];   long long get(long long x) { return x == dsu[x] ? x : dsu[x] = get(dsu[x]); }   void tarjan(long long u, long long p = -1) {     dsu[u] = u;     in[u] = 1;     for (long long v : g[u])       if (!in[v]) tarjan(v, u);     for (long long i : q[u]) {       long long v = u ^ eu[i] ^ ev[i];       if (vis[v]) {         lca[i] = get(v);       }       if (v == u) lca[v] = u;     }     vis[u] = 1;     dsu[u] = p;   }   vector<long long> stk;   void dfs(long long u, long long p = -1) {     vis[u] = in[u] = 1;     stk.emplace_back(u);     for (long long v : g[u]) {       if (v == p) continue;       if (in[v]) {         tag[v]++;         incy[v] = 1;         while (!stk.empty() and stk.back() != v) {           incy[stk.back()] = 1, stk.pop_back();         }         stk.pop_back();       }       if (vis[v]) continue;       dfs(v, u);     }     if (!stk.empty() and stk.back() == u) stk.pop_back();     in[u] = 0;   }   void add(long long u) {     vis[u] = 1;     sum[u] += tag[u];     for (long long v : g[u]) {       if (vis[v]) continue;       sum[v] += sum[u];       add(v);     }   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     ;     cin >> n >> m;     while (m--) {       long long a, b;       cin >> a >> b;       g[a].emplace_back(b);       g[b].emplace_back(a);     }     dfs(1, 0);     vis = 0;     add(1);     cin >> Q;     for (long long i = 0; i < Q; i++) {       cin >> eu[i] >> ev[i];       q[eu[i]].emplace_back(i);       q[ev[i]].emplace_back(i);     }     vis = 0;     in = 0;     tarjan(1, 0);     vector<long long> p2(n + 1);     p2[0] = 1;     for (long long i = 1; i <= n; i++) p2[i] = (p2[i - 1] << 1) % 1000000007;     for (long long i = 0; i < Q; i++) {       cout << p2[sum[eu[i]] + sum[ev[i]] - 2 * sum[lca[i]] + incy[lca[i]]]            <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   char in[100000 + 1];   int main() {     vector<array<int, 4> > cur, nex;     cur.push_back(array<int, 4>{{}});     int n;     scanf( %d , &n);     scanf( %s , in);     for (int i = 0; i < n; i++) {       int p = -1;       switch (in[i]) {         case  G :           p = 0;           break;         case  H :           p = 1;           break;         case  R :           p = 2;           break;         case  S :           p = 3;           break;       }       if (p >= 0) {         for (int i = 0; i < cur.size(); i++) {           cur[i][p]++;         }         continue;       }       nex.clear();       for (auto a : cur) {         int m = a[0];         for (int i = 1; i < 4; i++) {           m = min(m, a[i]);         }         for (int i = 0; i < 4; i++) {           if (a[i] == m) {             nex.push_back(a);             nex.back()[i]++;           }         }       }       sort(nex.begin(), nex.end());       nex.resize(unique(nex.begin(), nex.end()) - nex.begin());       nex.swap(cur);     }     const char* str[] = { Gryffindor ,  Hufflepuff ,  Ravenclaw ,  Slytherin };     for (int i = 0; i < 4; i++) {       for (auto a : cur) {         int m = a[0];         for (int i = 1; i < 4; i++) {           m = min(m, a[i]);         }         if (a[i] == m) {           puts(str[i]);           break;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long cross(pair<long long, long long> a, pair<long long, long long> b,                   pair<long long, long long> c) {     pair<long long, long long> v1 =         make_pair(b.first - a.first, b.second - a.second);     pair<long long, long long> v2 =         make_pair(c.first - a.first, c.second - a.second);     if ((long long)v1.first * (long long)v2.second -             (long long)v2.first * (long long)v1.second >         0)       return 1;     else if ((long long)v1.first * (long long)v2.second -                  (long long)v2.first * (long long)v1.second <              0)       return -1;     return 0;   }   int main(int argc, char* argv[]) {     long long n;     cin >> n;     vector<long long> arr(n);     for (long long i = 0; i < n; i++) {       cin >> arr[i];     }     vector<pair<long long, long long> > p;     p.push_back(make_pair(-1, 0));     long long s = 0;     for (long long i = 0; i < n; i++) {       s += arr[i];       p.push_back(make_pair(i, s));     }     stack<pair<long long, long long> > ch;     ch.push(p[0]);     ch.push(p[1]);     for (long long i = 2; i < n + 1; i++) {       pair<long long, long long> top = ch.top();       ch.pop();       while (ch.size() > 0 && cross(ch.top(), top, p[i]) == -1) {         top = ch.top();         ch.pop();       }       ch.push(top);       ch.push(p[i]);     }     vector<pair<long long, long long> > vec;     while (ch.size()) {       vec.push_back(ch.top());       ch.pop();     }     reverse(vec.begin(), vec.end());     vector<double> cev;     long long cur = 0;     for (long long i = -1; i < n; i++) {       if (vec[cur].first == i)         cev.push_back(vec[cur].second);       else {         if (cur < vec.size() - 1 && vec[cur + 1].first <= i) {           cur++;           i--;           continue;         }         long long x1 = vec[cur + 1].first - vec[cur].first;         long long y1 = vec[cur + 1].second - vec[cur].second;         long long x2 = i - vec[cur].first;         cev.push_back((((double)x2 * (double)y1) / (double)x1) + vec[cur].second);       }     }     for (long long i = 0; i < cev.size() - 1; i++) {       cout << setprecision(13) << double(cev[i + 1] - cev[i]) <<    ;     }     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   bool func(deque<int>& v) {     int x = v.back();     if (x > 1) {       v.pop_back();       int y = x / 2;       int y2 = x - y;       if (y == 1)         v.push_front(y);       else         v.push_back(y);       if (y2 == 1)         v.push_front(y2);       else         v.push_back(y2);       return true;     }     return false;   }   void printv(deque<int>& v) {     for (int i = 0; i < v.size(); i++) cout << v[i] <<    ;     cout << endl;   }   int main() {     int k;     int xyz[3];     cin >> xyz[0] >> xyz[1] >> xyz[2] >> k;     sort(xyz, xyz + 3);     deque<int> first, second, third;     first.push_back(xyz[2]);     second.push_back(xyz[1]);     third.push_back(xyz[0]);     int i = 0;     while (i < k) {       if (func(first))         i++;       else         break;       if (i < k && func(second)) i++;       if (i < k && func(third)) i++;     }     cout << (long long int)first.size() * second.size() * third.size();   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n;     cin >> n;     string s;     cin >> s;     int cnt = 0;     vector<int> v;     char last =  * ;     for (int i = 0, to = n; i < to; i++) {       if (last != s[i]) {         if (cnt > 0) v.push_back(cnt);         cnt = 1;         last = s[i];       } else {         cnt++;       }     }     v.push_back(cnt);     int ans = 0;     int resto = 0;     for (int i = 0, to = (int)v.size(); i < to; i++) {       if (v[i] > 1) {         resto -= (v[i] - 2);         resto = max(resto, 0);         ans++;       } else {         resto++;         ans++;       }     }     cout << ans - resto / 2 <<   n ;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(NULL);     int t = 1;     cin >> t;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k = 0;     cin >> n;     int arr[n + 2];     arr[0] = arr[n + 1] = 0;     for (int i = 1; i <= n; i++) cin >> arr[i];     for (int i = 1; i <= n; i++)       if (arr[i - 1] == 1 && arr[i + 1] == 1 && arr[i] == 0) arr[i + 1] = 0, k++;     cout << k;     return 0;   }
#include <bits/stdc++.h>   const int N = 1e5 + 3;   struct edge {     int v, nxt;   } g[N + N];   int n, head[N], k;   double ans;   inline void Insert(int u, int v) {     g[++k] = (edge){v, head[u]};     head[u] = k;   }   void Dfs(int u, int dep, int fa) {     int v;     ans += 1.0 / dep;     for (int i = head[u]; i; i = g[i].nxt)       if ((v = g[i].v) != fa) Dfs(v, dep + 1, u);   }   int main() {     int u, v;     scanf( %d , &n);     for (int i = 1; i < n; i++) scanf( %d%d , &u, &v), Insert(u, v), Insert(v, u);     Dfs(1, 1, 0);     printf( %.9lf n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int test;     cin >> test;     int n;     string rakh1, rakh2, rakh, ch, ch_min;     while (test--) {       cin >> n;       cin >> ch;       ch_min = ch;       int pos = 1;       for (int i = 1; i < (n - 1); i++) {         rakh1 = ch.substr(0, i);         rakh2 = ch.substr(i, n - 1);         if ((n % 2 != 0 && i % 2 == 0) || (n % 2 == 0 && i % 2 != 0))           reverse(rakh1.begin(), rakh1.end());         rakh = rakh2 + rakh1;         if (ch_min > rakh) {           pos = i + 1;           ch_min = rakh;         }       }       reverse(ch.begin(), ch.end());       if (ch_min > ch) {         pos = n;         ch_min = ch;       }       cout << ch_min << endl;       cout << pos << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int fastMax(int x, int y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ y; }   int fastMin(int x, int y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ x; }   void solve() {     long long int x, y, z;     cin >> x >> y >> z;     long long int x1, y1, z1;     cin >> x1 >> y1 >> z1;     long long int a1, a2, a3, a4, a5, a6;     cin >> a1 >> a2 >> a3 >> a4 >> a5 >> a6;     long long int ans = 0;     if (x > x1)       ans += a6;     else if (x < 0)       ans += a5;     if (y > y1)       ans += a2;     else if (y < 0)       ans += a1;     if (z > z1)       ans += a4;     else if (z < 0)       ans += a3;     cout << ans << endl;   }   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     long long int t;     t = 1;     while (t--) solve();   }
#include <bits/stdc++.h>   using namespace std;   const int INF = INT_MAX;   const long long INFL = LLONG_MAX;   int N, M, ans[200100], n, m;   int main() {     cin >> N >> M;     n = m = 0;     ans[0] = 0;     n++;     for (int(i) = 1; (i) <= (N + M - 1); (i)++) {       if (i & 1) {         if (ans[i - 1]) {           if (n < N) {             ans[i] = 0;             n++;           } else {             ans[i] = 1;             m++;           }         } else {           if (m < M) {             ans[i] = 1;             m++;           } else {             ans[i] = 0;             n++;           }         }       } else {         if (ans[i - 1]) {           if (m < M) {             ans[i] = 1;             m++;           } else {             ans[i] = 0;             n++;           }         } else {           if (n < N) {             ans[i] = 0;             n++;           } else {             ans[i] = 1;             m++;           }         }       }     }     int s11 = 0;     int s12 = 0;     for (int(i) = 1; (i) <= (N + M - 1); (i)++) {       if (ans[i - 1] == ans[i])         s11++;       else         s12++;     }     n = m = 0;     ans[0] = 1;     m++;     for (int(i) = 1; (i) <= (N + M - 1); (i)++) {       if (i & 1) {         if (ans[i - 1]) {           if (n < N) {             ans[i] = 0;             n++;           } else {             ans[i] = 1;             m++;           }         } else {           if (m < M) {             ans[i] = 1;             m++;           } else {             ans[i] = 0;             n++;           }         }       } else {         if (ans[i - 1]) {           if (m < M) {             ans[i] = 1;             m++;           } else {             ans[i] = 0;             n++;           }         } else {           if (n < N) {             ans[i] = 0;             n++;           } else {             ans[i] = 1;             m++;           }         }       }     }     int s21 = 0;     int s22 = 0;     for (int(i) = 1; (i) <= (N + M - 1); (i)++) {       if (ans[i - 1] == ans[i])         s21++;       else         s22++;     }     if (s11 < s21) {       cout << s21 <<     << s22 << endl;     } else {       cout << s11 <<     << s12 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   long long n, mod;   pair<long long, long long> a[200100];   long long d[200100];   long long first(int t, int k) {     long long res = 1;     for (int i = 1; i <= k; i++) d[i] = i;     for (int j = 2; t;)       if (d[j] % 2)         j += 2;       else         while (d[j] % 2 == 0 && t) {           d[j] /= 2;           t--;         }     for (int i = 1; i <= k; i++) res = (res * d[i]) % mod;     return res;   }   int main() {     cin >> n;     for (int i = 0; i < 2 * n; ++i) {       cin >> a[i].first;       a[i].second = (i % n) + 1;     }     sort(a, a + 2 * n);     cin >> mod;     long long r = 1;     for (int i = 0; i < 2 * n; i++) {       long long k, t = 0;       for (k = i + 1; k < 2 * n && a[k].first == a[i].first; k++)         if (a[k].second == a[k - 1].second) t++;       k--;       r = (r * first(t, k - i + 1)) % mod;       i = k;     }     cout << r;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1e5 + 5;   long long n, k, z, a[N];   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long t;     cin >> t;     while (t--) {       cin >> n >> k >> z;       long long sum = 0;       for (long long i = 1; i <= n; i++) cin >> a[i];       long long ans = 0;       for (long long j = 0; j <= z; j++) {         long long s = k - j;         if (s < j) break;         long long sum = 0;         long long mx = 0;         for (long long i = 1; i <= s - j + 1; i++)           sum += a[i], mx = max(a[i] + a[i + 1], mx);         ans = max(ans, sum + mx * j);       }       cout << ans <<   n ;     }     return 0;   }