, class R = less > ostream& operator << (ostream& out, priority_queue
const& M){static priority_queue
U;U = M;out << \"{ \";while(!U.empty()) out << U.top() << \" \", U.pop();return (out << \"}\");}\n\ntemplate ostream& operator << (ostream& out, queue const& M){static queue
U;U = M;out << \"{\"; string sep;while(!U.empty()){ out << sep << U.front(); sep = \", \"; U.pop();}return (out << \"}\");}\n\n \n\n#ifndef ONLINE_JUDGE\n\n#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)\n\ntemplate \n\nvoid __f(const char* name, Arg1&& arg1){cerr << name << \" : \" << arg1 << endl;}\n\ntemplate \n\nvoid __f(const char* names, Arg1&& arg1, Args&&... args){int count_open = 0, len = 1;for(int k = 1; ; ++k){ char cur = *(names + k); count_open += (cur == '(' ? 1 : (cur == ')' ? -1: 0)); if (cur == ',' && count_open == 0){ const char* comma = names + k; cerr.write(names, len) << \" : \" << arg1 << \" | \"; __f(comma + 1, args...); return; } len = (cur == ' ' ? len : k + 1);}}\n\n#else\n\n #define debug(...) 1\n\n#endif\n\n\n\n\n\ntemplate\n\nvoid pr(T&&... args) {\n\n ((cout << args << \" \"), ...);\n\n cout << '\\n';\n\n}\n\ntemplate\n\nvoid prln(T&&... args) {\n\n ((cout << args << '\\n'), ...);\n\n}\n\n\n\n\/*---------------------------------------------------------------------------------*\/\n\n\n\n\n\n\n\n\n\nvoid solve() {\n\n ll x;\n\n cin >> x;\n\n\n\n ll ans;\n\n for(ll i = 1; i * i <= x; i++) {\n\n if(x % i == 0 && lcm(i, x\/i) == x) {\n\n ans = i;\n\n }\n\n }\n\n\n\n pr(ans, x \/ ans);\n\n}\n\n\n\n \n\nint main() \n\n{ \n\n#ifndef ONLINE_JUDGE\n\n freopen(\"error.txt\", \"w\", stderr);\n\n#endif\n\n ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);\n\n int tt = 1; \n\n \/\/ cin >> tt;\n\n for(int tc = 1; tc <= tt; tc++) {\n\n solve();\n\n cerr << \"-----------\" << '\\n';\n\n }\n\n}","language":"cpp"}
{"contest_id":"1324","problem_id":"F","statement":"F. Maximum White Subtreetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a tree consisting of nn vertices. A tree is a connected undirected graph with n\u22121n\u22121 edges. Each vertex vv of this tree has a color assigned to it (av=1av=1 if the vertex vv is white and 00 if the vertex vv is black).You have to solve the following problem for each vertex vv: what is the maximum difference between the number of white and the number of black vertices you can obtain if you choose some subtree of the given tree that contains the vertex vv? The subtree of the tree is the connected subgraph of the given tree. More formally, if you choose the subtree that contains cntwcntw white vertices and cntbcntb black vertices, you have to maximize cntw\u2212cntbcntw\u2212cntb.InputThe first line of the input contains one integer nn (2\u2264n\u22642\u22c51052\u2264n\u22642\u22c5105) \u2014 the number of vertices in the tree.The second line of the input contains nn integers a1,a2,\u2026,ana1,a2,\u2026,an (0\u2264ai\u226410\u2264ai\u22641), where aiai is the color of the ii-th vertex.Each of the next n\u22121n\u22121 lines describes an edge of the tree. Edge ii is denoted by two integers uiui and vivi, the labels of vertices it connects (1\u2264ui,vi\u2264n,ui\u2260vi(1\u2264ui,vi\u2264n,ui\u2260vi).It is guaranteed that the given edges form a tree.OutputPrint nn integers res1,res2,\u2026,resnres1,res2,\u2026,resn, where resiresi is the maximum possible difference between the number of white and black vertices in some subtree that contains the vertex ii.ExamplesInputCopy9\n0 1 1 1 0 0 0 0 1\n1 2\n1 3\n3 4\n3 5\n2 6\n4 7\n6 8\n5 9\nOutputCopy2 2 2 2 2 1 1 0 2 \nInputCopy4\n0 0 1 0\n1 2\n1 3\n1 4\nOutputCopy0 -1 1 -1 \nNoteThe first example is shown below:The black vertices have bold borders.In the second example; the best subtree for vertices 2,32,3 and 44 are vertices 2,32,3 and 44 correspondingly. And the best subtree for the vertex 11 is the subtree consisting of vertices 11 and 33.","tags":["dfs and similar","dp","graphs","trees"],"code":"\/\/ <-- Code By: Ashu Mittal -->\n#include\n#include \n#include \nusing namespace std;\nusing namespace __gnu_pbds;\n\ntemplate\nusing minheap = priority_queue, greater >;\n\ntemplate\nusing ordered_set = tree, rb_tree_tag, tree_order_statistics_node_update> ;\n\ntemplate>\nusing ordered_map = tree;\n\n#define ff first\n#define ss second\n#define ll long long\n#define all(sss) (sss).begin(),(sss).end()\n#define pb push_back\n#define pob pop_back\n#define endl \"\\n\"\n#define input(ass) for(auto &x:(ass)) cin>>x;\n#define iendl \"\\n\", cout<>= 1; aaa = (aaa * aaa);} return ans;}\nll mod_inv(ll a) {return power(a, mod - 2);}\n\n\/*----------------------------------x x x---------------------------------*\/\n\nvoid solve() {\n\tll n;\n\tcin >> n;\n\n\tstd::vector co(n);\n\tfor (auto &x : co) {\n\t\tcin >> x;\n\t\tif (x == 0) x = -1;\n\t}\n\n\tstd::vector> v(n);\n\tfor (int i = 0; i < n - 1; i++) {\n\t\tll a, b; cin >> a >> b;\n\t\tv[a - 1].push_back(b - 1);\n\t\tv[b - 1].push_back(a - 1);\n\t}\n\n\tstd::vector dp(n, 0);\n\tfunction dfs = [&](ll i, ll p) {\n\t\tdp[i] += co[i];\n\t\tfor (auto &x : v[i]) {\n\t\t\tif (x == p) continue;\n\t\t\tdfs(x, i);\n\t\t\tdp[i] += max(0ll, dp[x]);\n\t\t}\n\t};\n\tdfs(0, -1);\n\tdbg(dp)\n\n\tfunction dfs1 = [&](ll i, ll p) {\n\t\tfor (auto &x : v[i]) {\n\t\t\tif (x == p) continue;\n\t\t\tll val = (dp[x] < 0) ? 0 : dp[x];\n\t\t\tdp[x] += max(0ll, dp[i] - val);\n\t\t\tdfs1(x, i);\n\t\t}\n\t};\n\tdfs1(0, -1);\n\n\tfor (auto &x : dp) cout << x << ' ';\n\tcout << endl;\n\n}\n\n\/*\n\n*\/\n\nint32_t main() {\n\n\tios::sync_with_stdio(0); cin.tie(0);\n#ifndef ONLINE_JUDGE\n\tfreopen(\"input.txt\", \"r\", stdin);\n\tfreopen(\"output.txt\", \"w\", stdout);\n\tfreopen(\"Error.txt\", \"w\", stderr);\n#endif\n\n\tll TT = 1;\n\t\/\/ cin >> TT;\n\tfor (ll TEST = 1; TEST <= TT; TEST++) {\n\t\t\/\/ cout<<\"Case #\"<\n\n\n\nusing namespace std;\n\n\n\nint main()\n\n{\n\n int t;\n\n cin>>t;\n\n while(t--){\n\n int n,d;\n\n cin>>n>>d;\n\n int l,r,mid,z;\n\n l=0;r=1e9;\n\n bool p=0;\n\n z=n\/2;\n\n z++;\n\n l=ceil((double)d\/z);\n\n z--;\n\n \n\n if((z+l)<=n){\n\n cout<<\"YES\\n\";\n\n }\n\n else cout<<\"NO\\n\";\n\n }\n\n\n\n return 0;\n\n}","language":"cpp"}
{"contest_id":"1310","problem_id":"E","statement":"E. Strange Functiontime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputLet's define the function ff of multiset aa as the multiset of number of occurences of every number, that is present in aa.E.g., f({5,5,1,2,5,2,3,3,9,5})={1,1,2,2,4}f({5,5,1,2,5,2,3,3,9,5})={1,1,2,2,4}.Let's define fk(a)fk(a), as applying ff to array aa kk times: fk(a)=f(fk\u22121(a)),f0(a)=afk(a)=f(fk\u22121(a)),f0(a)=a. E.g., f2({5,5,1,2,5,2,3,3,9,5})={1,2,2}f2({5,5,1,2,5,2,3,3,9,5})={1,2,2}.You are given integers n,kn,k and you are asked how many different values the function fk(a)fk(a) can have, where aa is arbitrary non-empty array with numbers of size no more than nn. Print the answer modulo 998244353998244353.InputThe first and only line of input consists of two integers n,kn,k (1\u2264n,k\u226420201\u2264n,k\u22642020).OutputPrint one number\u00a0\u2014 the number of different values of function fk(a)fk(a) on all possible non-empty arrays with no more than nn elements modulo 998244353998244353.ExamplesInputCopy3 1\nOutputCopy6\nInputCopy5 6\nOutputCopy1\nInputCopy10 1\nOutputCopy138\nInputCopy10 2\nOutputCopy33\n","tags":["dp"],"code":"#include \n\n#define ms(x, v) memset(x, v, sizeof(x))\n\n#define il __attribute__((always_inline))\n\n#define U(i,l,r) for(int i(l),END##i(r);i<=END##i;++i)\n\n#define D(i,r,l) for(int i(r),END##i(l);i>=END##i;--i)\n\nusing namespace std;\n\n\n\ntypedef unsigned long long ull;\n\ntypedef long long ll;\n\ntemplate using BS = basic_string;\n\n\n\n\/\/const int SZ(1 << 23);\n\n\/\/unsigned char buf[SZ], *S, *Q;\n\n\/\/#define getchar() ((S==Q)&&(Q=buf+fread(S=buf,1,SZ,stdin)),S==Q?EOF:*S++)\n\ntemplate \n\nvoid rd(T& s) {\n\n\tint c = getchar();\n\n\tT f = 1; s = 0;\n\n\twhile (!isdigit(c)) { if (c == '-') f = -1; c = getchar(); }\n\n\twhile (isdigit(c)) { s = s * 10 + (c ^ 48); c = getchar(); }\n\n\ts *= f;\n\n}\n\ntemplate \n\nvoid rd(T& x, Y&... y) { rd(x), rd(y...); }\n\ntemplate \n\nvoid pr(T s, bool f = 1) {\n\n if (s < 0) { printf(\"-\"); s = -s; }\n\n if (!s) return void(f ? printf(\"0\") : 0);\n\n pr(s \/ 10, 0);\n\n printf(\"%d\", (signed)(s % 10));\n\n}\n\n#define meow(...) fprintf(stderr, __VA_ARGS__)\n\n\n\nconst int N = 2025;\n\nconst ll P = 998244353;\n\n\n\nll sub1(ll n) {\n\n\t\/\/ \u6c42 \\sum_1^n \u5206\u62c6\u6570\n\n\tll f[N] {1}; \/\/ \u5212\u5206\u6570\n\n\tU (i, 1, n)\n\n\t\tU (j, i, n)\n\n\t\t\t(f[j] += f[j - i]) %= P;\n\n\tll ans = 0;\n\n\tU (i, 1, n) (ans += f[i]) %= P;\n\n\treturn ans;\n\n}\n\n\n\nll sub2(ll n) {\n\n\t\/\/ \u6784\u9020\u96c6\u5408\u4f7f\u5f97 i*t_i <= n\uff0c\u8ba1\u6570\n\n \/\/ \u5dee\u5206\u5219\u4e0d\u9700\u8981\u8003\u8651 t_i \u51cf\u7684\u9650\u5236\n\n \/\/ \u8fd9\u6837\u4e00\u4e2a c_i=t_i - t_{i-1}=1 \u5bf9\u548c\u7684\u53f3\u79fb\u4e3a sum 1..i = i(i-1)\/2\n\n ll f[N] {1};\n\n for (int i = 1; i * (i + 1) >> 1 <= n; ++i)\n\n for (int j = i * (i + 1) >> 1; j <= n; ++j)\n\n (f[j] += f[j - i * (i + 1) \/ 2]) %= P;\n\n ll ans = 0;\n\n U (i, 1, n) (ans += f[i]) %= P;\n\n return ans;\n\n}\n\n\n\nint n, k;\n\nbool extend(int k, vector v) {\n\n vector g;\n\n for (int j = 1; j < k; ++j) {\n\n int sum = 0;\n\n sort(v.rbegin(), v.rend());\n\n U (i, 0, v.size() - 1) sum += (i + 1) * v[i];\n\n if (sum > n) return 0;\n\n \/\/ if (j + 3 < k && sum > 23) return 0;\n\n U (i, 0, v.size() - 1)\n\n U (j, 1, v[i])\n\n g.push_back(i + 1);\n\n v.swap(g);\n\n vector().swap(g);\n\n }\n\n return 1;\n\n}\n\nvector v;\n\nll ans = 0;\n\nbool dfs(int lim) { \/\/ \u968f\u4fbf\u55ef\u5206\n\n if (!extend(k, v)) return 0;\n\n \/\/ clog << lim << ' ' << v.size() << endl;\n\n ++ans;\n\n \/\/ meow(\"x\");\n\n \/\/ for (int x : v) meow(\"%d \", x);\n\n \/\/ meow(\"\\n\");\n\n for (int i = lim, flag; ; ++i) {\n\n v.push_back(i);\n\n flag = dfs(i);\n\n v.pop_back();\n\n if (!flag) return 1;\n\n }\n\n return 1;\n\n}\n\nll sub3() {\n\n dfs(1);\n\n return ans - 1;\n\n}\n\n\n\nint main() {\n\n \/\/ Sol::main();\n\n \/\/ return 0;\n\n\trd(n, k);\n\n\tif (k == 1) exit(printf(\"%lld\", sub1(n)) & 0);\n\n if (k == 2) exit(printf(\"%lld\", sub2(n)) & 0);\n\n printf(\"%lld\", sub3());\n\n}","language":"cpp"}
{"contest_id":"1292","problem_id":"A","statement":"A. NEKO's Maze Gametime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output3R2 as DJ Mashiro - Happiness Breeze Ice - DJ Mashiro is dead or aliveNEKO#\u03a6\u03c9\u03a6 has just got a new maze game on her PC!The game's main puzzle is a maze; in the forms of a 2\u00d7n2\u00d7n rectangle grid. NEKO's task is to lead a Nekomimi girl from cell (1,1)(1,1) to the gate at (2,n)(2,n) and escape the maze. The girl can only move between cells sharing a common side.However, at some moments during the game, some cells may change their state: either from normal ground to lava (which forbids movement into that cell), or vice versa (which makes that cell passable again). Initially all cells are of the ground type.After hours of streaming, NEKO finally figured out there are only qq such moments: the ii-th moment toggles the state of cell (ri,ci)(ri,ci) (either from ground to lava or vice versa).Knowing this, NEKO wonders, after each of the qq moments, whether it is still possible to move from cell (1,1)(1,1) to cell (2,n)(2,n) without going through any lava cells.Although NEKO is a great streamer and gamer, she still can't get through quizzes and problems requiring large amount of Brain Power. Can you help her?InputThe first line contains integers nn, qq (2\u2264n\u22641052\u2264n\u2264105, 1\u2264q\u22641051\u2264q\u2264105).The ii-th of qq following lines contains two integers riri, cici (1\u2264ri\u226421\u2264ri\u22642, 1\u2264ci\u2264n1\u2264ci\u2264n), denoting the coordinates of the cell to be flipped at the ii-th moment.It is guaranteed that cells (1,1)(1,1) and (2,n)(2,n) never appear in the query list.OutputFor each moment, if it is possible to travel from cell (1,1)(1,1) to cell (2,n)(2,n), print \"Yes\", otherwise print \"No\". There should be exactly qq answers, one after every update.You can print the words in any case (either lowercase, uppercase or mixed).ExampleInputCopy5 5\n2 3\n1 4\n2 4\n2 3\n1 4\nOutputCopyYes\nNo\nNo\nNo\nYes\nNoteWe'll crack down the example test here: After the first query; the girl still able to reach the goal. One of the shortest path ways should be: (1,1)\u2192(1,2)\u2192(1,3)\u2192(1,4)\u2192(1,5)\u2192(2,5)(1,1)\u2192(1,2)\u2192(1,3)\u2192(1,4)\u2192(1,5)\u2192(2,5). After the second query, it's impossible to move to the goal, since the farthest cell she could reach is (1,3)(1,3). After the fourth query, the (2,3)(2,3) is not blocked, but now all the 44-th column is blocked, so she still can't reach the goal. After the fifth query, the column barrier has been lifted, thus she can go to the final goal again. ","tags":["data structures","dsu","implementation"],"code":"#include \n\n#define ll long long\n\n#define MAXN 100010\n\n\n\nusing namespace std;\n\n\n\nint X, Y, N, Q, da_li, rez = 0;\n\nvector > pos(3, vector (MAXN));\n\n\n\nint main()\n\n{\n\n ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);\n\n cin >> N >> Q;\n\n while(Q--)\n\n {\n\n da_li = 0;\n\n cin >> X >> Y;\n\n if(pos[X][Y]) da_li++;\n\n else da_li--;\n\n pos[X][Y] ^= 1;\n\n for(int i = -1; i <= 1; i++) {if(i+Y >= 1 && i+Y <= N && pos[3 - X][Y + i]) rez += da_li;}\n\n if(rez == 0) {cout << \"YES\" << endl;}\n\n else {cout << \"NO\" << endl;}\n\n }\n\n return 0;\n\n}\n\n","language":"cpp"}
{"contest_id":"1294","problem_id":"F","statement":"F. Three Paths on a Treetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an unweighted tree with nn vertices. Recall that a tree is a connected undirected graph without cycles.Your task is to choose three distinct vertices a,b,ca,b,c on this tree such that the number of edges which belong to at least one of the simple paths between aa and bb, bb and cc, or aa and cc is the maximum possible. See the notes section for a better understanding.The simple path is the path that visits each vertex at most once.InputThe first line contains one integer number nn (3\u2264n\u22642\u22c51053\u2264n\u22642\u22c5105) \u2014 the number of vertices in the tree. Next n\u22121n\u22121 lines describe the edges of the tree in form ai,biai,bi (1\u2264ai1\u2264ai, bi\u2264nbi\u2264n, ai\u2260biai\u2260bi). It is guaranteed that given graph is a tree.OutputIn the first line print one integer resres \u2014 the maximum number of edges which belong to at least one of the simple paths between aa and bb, bb and cc, or aa and cc.In the second line print three integers a,b,ca,b,c such that 1\u2264a,b,c\u2264n1\u2264a,b,c\u2264n and a\u2260,b\u2260c,a\u2260ca\u2260,b\u2260c,a\u2260c.If there are several answers, you can print any.ExampleInputCopy8\n1 2\n2 3\n3 4\n4 5\n4 6\n3 7\n3 8\nOutputCopy5\n1 8 6\nNoteThe picture corresponding to the first example (and another one correct answer):If you choose vertices 1,5,61,5,6 then the path between 11 and 55 consists of edges (1,2),(2,3),(3,4),(4,5)(1,2),(2,3),(3,4),(4,5), the path between 11 and 66 consists of edges (1,2),(2,3),(3,4),(4,6)(1,2),(2,3),(3,4),(4,6) and the path between 55 and 66 consists of edges (4,5),(4,6)(4,5),(4,6). The union of these paths is (1,2),(2,3),(3,4),(4,5),(4,6)(1,2),(2,3),(3,4),(4,5),(4,6) so the answer is 55. It can be shown that there is no better answer.","tags":["dfs and similar","dp","greedy","trees"],"code":"#include \n\n \n\n#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)\n\n#define file(s) if (fopen(s\".in\", \"r\")) freopen(s\".in\", \"r\", stdin), freopen(s\".out\", \"w\", stdout)\n\n#define all(a) a.begin() , a.end()\n\n#define F first\n\n#define S second\n\n \n\nusing namespace std;\n\nusing ll = long long;\n\n \n\nconst ll N = 3e5+5 , inf = 2e9 + 7;\n\nconst ll INF = 1e18 , mod = 1e9+7 , P = 6547;\t\n\n\n\nll dp[N] , a[4] , ans = 0;\n\nll n;\n\npair mx[N];\n\nvector g[N];\n\nvoid dfs(ll v , ll p = 0){\n\n\tdp[v] = dp[p]+1;\n\n\tmx[v].F = v;\n\n\tfor(ll to : g[v]) if(to != p) dfs(to,v);\n\n}\n\nvector V;\n\nqueue q;\n\n\n\nvoid go(){\n\n\twhile(!q.empty()){\n\n\t\tll v = q.front();\n\n\t\tq.pop();\n\n\t\tfor(ll to : g[v]){\n\n\t\t\tif(dp[to] > dp[v]+1){\n\n\t\t\t\tdp[to] = dp[v]+1;\n\n\t\t\t\tq.push(to);\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tll mx = 0;\n\n\tfor(ll i = 1; i <= n; i++){\n\n\t\tif(i != a[0] && i != a[1]){\n\n\t\t\tif(dp[i] >= mx) {\n\n\t\t\t\tmx = dp[i];\n\n\t\t\t\ta[2] = i;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n}\n\nvoid bfs(ll v , ll p = 0){\n\n\tV.push_back(v);\n\n\tif(v == a[0]){\n\n\t\tfor(ll x : V){\n\n\t\t\tdp[x] = 0;\n\n\t\t\tq.push(x);\n\n\t\t}\n\n\t\tgo();\n\n\t\treturn;\n\n\t}\n\n\tfor(ll to : g[v]) if(to != p) bfs(to,v);\n\n\tV.pop_back();\n\n}\n\nvoid solve(){\n\n\tcin >> n;\n\n\tfor(ll i = 1; i < n; i++) {\n\n\t\tll a , b;\n\n\t\tcin >> a >> b;\n\n\t\tg[a].push_back(b);\n\n\t\tg[b].push_back(a);\n\n\t}\n\n\tdfs(1);\n\n\tll V = 1 , mx = 0;\n\n\tfor(ll i = 1; i <= n; i++){\n\n\t\tif(dp[i] > mx) mx = dp[i] , V = i;\n\n\t\tdp[i] = 0;\n\n\t}\n\n\ta[0] = V;\n\n\tdfs(V);\n\n\tV = 1 , mx = 0;\n\n\tfor(ll i = 1; i <= n; i++){\n\n\t\tif(dp[i] > mx) mx = dp[i] , V = i;\n\n\t\tdp[i] = inf;\n\n\t}\n\n\ta[1] = V;\n\n\tbfs(V);\n\n\tcout << mx-1 + dp[a[2]] <<\"\\n\";\n\n\tcout << a[0] << \" \" << a[1] <<\" \" << a[2] <<\"\\n\";\n\n}\t\n\n\/*\n\n\n\n*\/\n\nsigned main(){\n\n\tios;\n\n\tsolve();\n\n\treturn 0;\n\n} ","language":"cpp"}
{"contest_id":"1316","problem_id":"E","statement":"E. Team Buildingtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice; the president of club FCB, wants to build a team for the new volleyball tournament. The team should consist of pp players playing in pp different positions. She also recognizes the importance of audience support, so she wants to select kk people as part of the audience.There are nn people in Byteland. Alice needs to select exactly pp players, one for each position, and exactly kk members of the audience from this pool of nn people. Her ultimate goal is to maximize the total strength of the club.The ii-th of the nn persons has an integer aiai associated with him\u00a0\u2014 the strength he adds to the club if he is selected as a member of the audience.For each person ii and for each position jj, Alice knows si,jsi,j \u00a0\u2014 the strength added by the ii-th person to the club if he is selected to play in the jj-th position.Each person can be selected at most once as a player or a member of the audience. You have to choose exactly one player for each position.Since Alice is busy, she needs you to help her find the maximum possible strength of the club that can be achieved by an optimal choice of players and the audience.InputThe first line contains 33 integers n,p,kn,p,k (2\u2264n\u2264105,1\u2264p\u22647,1\u2264k,p+k\u2264n2\u2264n\u2264105,1\u2264p\u22647,1\u2264k,p+k\u2264n).The second line contains nn integers a1,a2,\u2026,ana1,a2,\u2026,an. (1\u2264ai\u22641091\u2264ai\u2264109).The ii-th of the next nn lines contains pp integers si,1,si,2,\u2026,si,psi,1,si,2,\u2026,si,p. (1\u2264si,j\u22641091\u2264si,j\u2264109)OutputPrint a single integer resres \u00a0\u2014 the maximum possible strength of the club.ExamplesInputCopy4 1 2\n1 16 10 3\n18\n19\n13\n15\nOutputCopy44\nInputCopy6 2 3\n78 93 9 17 13 78\n80 97\n30 52\n26 17\n56 68\n60 36\n84 55\nOutputCopy377\nInputCopy3 2 1\n500 498 564\n100002 3\n422332 2\n232323 1\nOutputCopy422899\nNoteIn the first sample; we can select person 11 to play in the 11-st position and persons 22 and 33 as audience members. Then the total strength of the club will be equal to a2+a3+s1,1a2+a3+s1,1.","tags":["bitmasks","dp","greedy","sortings"],"code":"#include \n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include