"{\"inputs\":\"The Olympic Games have just started and Federico is eager to watch the marathon race.\\n\\nThere will be n athletes, numbered from 1 to n, competing in the marathon, and all of them have taken part in 5 important marathons, numbered from 1 to 5, in the past. For each 1≤ i≤ n and 1≤ j≤ 5, Federico remembers that athlete i ranked r_{i,j}-th in marathon j (e.g., r_{2,4}=3 means that athlete 2 was third in marathon 4).\\n\\nFederico considers athlete x superior to athlete y if athlete x ranked better than athlete y in at least 3 past marathons, i.e., r_{x,j} q = new LinkedList<>();\\n for (int i = 0; i < n; i++) {\\n q.add(arr[i]);\\n }\\n helper(q);\\n if (q.size() == 0){\\n out.println(-1);\\n return;\\n }\\n int[] ok = q.poll();\\n\\/\\/ System.out.println(Arrays.toString(ok));\\n for (int i = 0; i < n; i++) {\\n int cnt = 0;\\n if (arr[i][5] == ok[5]) continue;\\n for (int j = 0; j < 5; j++) {\\n if (ok[j] < arr[i][j]){\\n cnt++;\\n }\\n }\\n if (cnt < 3) {\\n out.println(-1);\\n return;\\n }\\n }\\n out.println((ok[5] + 1));\\n }\\n\\n static void helper(LinkedList q){\\n while (q.size() > 1){\\n int[] l = q.poll(), r = q.poll();\\n int cnt1 = 0, cnt2 = 0;\\n for (int i = 0; i < 5; i++) {\\n if (l[i] > r[i]){\\n cnt2++;\\n }else if (l[i] < r[i]){\\n cnt1++;\\n }\\n }\\n if (cnt1 >= 3){\\n q.addFirst(l);\\n }else if (cnt2 >= 3){\\n q.addFirst(r);\\n }\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nYou had n positive integers a_1, a_2, ..., a_n arranged in a circle. For each pair of neighboring numbers (a_1 and a_2, a_2 and a_3, ..., a_{n - 1} and a_n, and a_n and a_1), you wrote down: are the numbers in the pair equal or not.\\n\\nUnfortunately, you've lost a piece of paper with the array a. Moreover, you are afraid that even information about equality of neighboring elements may be inconsistent. So, you are wondering: is there any array a which is consistent with information you have about equality or non-equality of corresponding pairs?\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases. Next t cases follow.\\n\\nThe first and only line of each test case contains a non-empty string s consisting of characters E and\\/or N. The length of s is equal to the size of array n and 2 ≤ n ≤ 50. For each i from 1 to n: \\n\\n * if s_i = E then a_i is equal to a_{i + 1} (a_n = a_1 for i = n); \\n * if s_i = N then a_i is not equal to a_{i + 1} (a_n ≠ a_1 for i = n). \\n\\nOutput\\n\\nFor each test case, print YES if it's possible to choose array a that are consistent with information from s you know. Otherwise, print NO.\\n\\nIt can be proved, that if there exists some array a, then there exists an array a of positive integers with values less or equal to 10^9.\\n\\nExample\\n\\nInput\\n\\n\\n4\\nEEE\\nEN\\nENNEENE\\nNENN\\n\\n\\nOutput\\n\\n\\nYES\\nNO\\nYES\\nYES\\n\\nNote\\n\\nIn the first test case, you can choose, for example, a_1 = a_2 = a_3 = 5.\\n\\nIn the second test case, there is no array a, since, according to s_1, a_1 is equal to a_2, but, according to s_2, a_2 is not equal to a_1.\\n\\nIn the third test case, you can, for example, choose array a = [20, 20, 4, 50, 50, 50, 20].\\n\\nIn the fourth test case, you can, for example, choose a = [1, 3, 3, 7].\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n int T;\\n cin >> T;\\n while (T--) {\\n string S;\\n cin >> S;\\n long long n = S.length();\\n long long count = 0;\\n for (long long i = 0; i < n; i++) {\\n if (S[i] == 'N') count++;\\n }\\n if ((count > 1) || (count == 0))\\n cout << \\\"YES\\\"\\n << \\\"\\\\n\\\";\\n else\\n cout << \\\"NO\\\"\\n << \\\"\\\\n\\\";\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Polycarp had an array a of 3 positive integers. He wrote out the sums of all non-empty subsequences of this array, sorted them in non-decreasing order, and got an array b of 7 integers.\\n\\nFor example, if a = \\\\{1, 4, 3\\\\}, then Polycarp wrote out 1, 4, 3, 1 + 4 = 5, 1 + 3 = 4, 4 + 3 = 7, 1 + 4 + 3 = 8. After sorting, he got an array b = \\\\{1, 3, 4, 4, 5, 7, 8\\\\}.\\n\\nUnfortunately, Polycarp lost the array a. He only has the array b left. Help him to restore the array a.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 5000) — the number of test cases.\\n\\nEach test case consists of one line which contains 7 integers b_1, b_2, ..., b_7 (1 ≤ b_i ≤ 10^9; b_i ≤ b_{i+1}). \\n\\nAdditional constraint on the input: there exists at least one array a which yields this array b as described in the statement.\\n\\nOutput\\n\\nFor each test case, print 3 integers — a_1, a_2 and a_3. If there can be several answers, print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n1 3 4 4 5 7 8\\n1 2 3 4 5 6 7\\n300000000 300000000 300000000 600000000 600000000 600000000 900000000\\n1 1 2 999999998 999999999 999999999 1000000000\\n1 2 2 3 3 4 5\\n\\n\\nOutput\\n\\n\\n1 4 3\\n4 1 2\\n300000000 300000000 300000000\\n999999998 1 1\\n1 2 2\\n\\nNote\\n\\nThe subsequence of the array a is a sequence that can be obtained from a by removing zero or more of its elements.\\n\\nTwo subsequences are considered different if index sets of elements included in them are different. That is, the values of the elements don't matter in the comparison of subsequences. In particular, any array of length 3 has exactly 7 different non-empty subsequences.\",\"targets\":\"import java.util.Scanner;\\npublic class Main\\n{\\n\\tpublic static void main(String[] args) \\n\\t{\\n\\t Scanner sc=new Scanner(System.in);\\n\\t int t=sc.nextInt();\\n\\t while(t-->0)\\n\\t {\\n\\t int b[]=new int[7];\\n\\t for(int i=0;i<=6;i++)\\n\\t {\\n\\t b[i]=sc.nextInt(); \\n\\t \\n\\t }\\n\\t System.out.println(b[0]+\\\" \\\"+b[1]+\\\" \\\"+(b[6]-(b[0]+b[1])));\\n\\t \\n\\t }\\n\\t\\t\\n\\t}\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 solution for \\\"You are given an array a of length n.\\n\\nLet's define the eversion operation. Let x = a_n. Then array a is partitioned into two parts: left and right. The left part contains the elements of a that are not greater than x (≤ x). The right part contains the elements of a that are strictly greater than x (> x). The order of elements in each part is kept the same as before the operation, i. e. the partition is stable. Then the array is replaced with the concatenation of the left and the right parts.\\n\\nFor example, if the array a is [2, 4, 1, 5, 3], the eversion goes like this: [2, 4, 1, 5, 3] → [2, 1, 3], [4, 5] → [2, 1, 3, 4, 5].\\n\\nWe start with the array a and perform eversions on this array. We can prove that after several eversions the array a stops changing. Output the minimum number k such that the array stops changing after k eversions.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 100). Description of the test cases follows.\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 2 ⋅ 10^5).\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9).\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case print a single integer k — the number of eversions after which the array stops changing.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n5\\n2 4 1 5 3\\n5\\n5 3 2 4 1\\n4\\n1 1 1 1\\n\\n\\nOutput\\n\\n\\n1\\n2\\n0\\n\\nNote\\n\\nConsider the fist example.\\n\\n * The first eversion: a = [1, 4, 2, 5, 3], x = 3. [2, 4, 1, 5, 3] → [2, 1, 3], [4, 5] → [2, 1, 3, 4, 5]. \\n * The second and following eversions: a = [2, 1, 3, 4, 5], x = 5. [2, 1, 3, 4, 5] → [2, 1, 3, 4, 5], [] → [2, 1, 3, 4, 5]. This eversion does not change the array, so the answer is 1. \\n\\n\\n\\nConsider the second example. \\n\\n * The first eversion: a = [5, 3, 2, 4, 1], x = 1. [5, 3, 2, 4, 1] → [1], [5, 3, 2, 4] → [1, 5, 3, 2, 4]. \\n * The second eversion: a = [1, 5, 3, 2, 4], x = 4. [1, 5, 3, 2, 4] → [1, 3, 2, 4], [5] → [1, 3, 2, 4, 5]. \\n * The third and following eversions: a = [1, 3, 2, 4,...\\\":\",\"targets\":\"import math\\nimport math as m\\ndef L():\\n return list(map(int, input().split()))\\ndef I():\\n return int(input())\\ndef M():\\n return map(int, input().split())\\n# def sortzip(arr1,arr2,ForS):\\n# return sorted(zip(arr1,arr2), key=lambda x:x[ForS])\\nfrom math import sqrt\\nfrom itertools import count, islice\\n\\ndef is_prime(n):\\n return n > 1 and all(n % i for i in islice(count(2), int(sqrt(n) - 1)))\\n\\ndef solve():\\n n = I()\\n arr = L()\\n nowval = -1\\n res=0\\n maxi = max(arr)\\n if arr[-1] == maxi:\\n print(0)\\n return\\n nowval = arr[-1]\\n res = 1\\n for i in range(n-1,-1,-1):\\n if arr[i] == maxi:\\n print(res)\\n return\\n if arr[i] > nowval:\\n res+=1\\n nowval =arr[i]\\n print(res)\\n\\nfor _ in range(I()):\\n solve()\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"An ant moves on the real line with constant speed of 1 unit per second. It starts at 0 and always moves to the right (so its position increases by 1 each second).\\n\\nThere are n portals, the i-th of which is located at position x_i and teleports to position y_i < x_i. Each portal can be either active or inactive. The initial state of the i-th portal is determined by s_i: if s_i=0 then the i-th portal is initially inactive, if s_i=1 then the i-th portal is initially active. When the ant travels through a portal (i.e., when its position coincides with the position of a portal): \\n\\n * if the portal is inactive, it becomes active (in this case the path of the ant is not affected); \\n * if the portal is active, it becomes inactive and the ant is instantly teleported to the position y_i, where it keeps on moving as normal. \\n\\n\\n\\nHow long (from the instant it starts moving) does it take for the ant to reach the position x_n + 1? It can be shown that this happens in a finite amount of time. Since the answer may be very large, compute it modulo 998 244 353.\\n\\nInput\\n\\nThe first line contains the integer n (1≤ n≤ 2⋅ 10^5) — the number of portals.\\n\\nThe i-th of the next n lines contains three integers x_i, y_i and s_i (1≤ y_i < x_i≤ 10^9, s_i∈\\\\{0,1\\\\}) — the position of the i-th portal, the position where the ant is teleported when it travels through the i-th portal (if it is active), and the initial state of the i-th portal.\\n\\nThe positions of the portals are strictly increasing, that is x_1\\nusing namespace std;\\nconst int P = 998244353;\\nint main() {\\n cin.tie(0)->sync_with_stdio(0);\\n int n;\\n cin >> n;\\n vector > v(n);\\n for (array &i : v)\\n for (int &j : i) cin >> j;\\n vector > o(1, {0, 0});\\n long long ans = 1;\\n for (array i : v) {\\n ans += i[0] - o.back()[0];\\n int j =\\n upper_bound(o.begin(), o.end(), array({i[1], 0})) - o.begin();\\n int suba = (i[0] - i[1]) % P;\\n if (o[j][0] > i[1])\\n suba = ((long long)suba + o.back()[1] - o[j - 1][1] + P) % P;\\n if (i[2]) ans += suba;\\n o.push_back({i[0], (suba + o.back()[1]) % P});\\n }\\n ans %= P;\\n cout << ans << '\\\\n';\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Casimir has a rectangular piece of paper with a checkered field of size n × m. Initially, all cells of the field are white.\\n\\nLet us denote the cell with coordinates i vertically and j horizontally by (i, j). The upper left cell will be referred to as (1, 1) and the lower right cell as (n, m).\\n\\nCasimir draws ticks of different sizes on the field. A tick of size d (d > 0) with its center in cell (i, j) is drawn as follows: \\n\\n 1. First, the center cell (i, j) is painted black. \\n 2. Then exactly d cells on the top-left diagonally to the center and exactly d cells on the top-right diagonally to the center are also painted black. \\n 3. That is all the cells with coordinates (i - h, j ± h) for all h between 0 and d are painted. In particular, a tick consists of 2d + 1 black cells. \\n\\n\\n\\nAn already painted cell will remain black if painted again. Below you can find an example of the 4 × 9 box, with two ticks of sizes 2 and 3.\\n\\n\\n\\nYou are given a description of a checkered field of size n × m. Casimir claims that this field came about after he drew some (possibly 0) ticks on it. The ticks could be of different sizes, but the size of each tick is at least k (that is, d ≥ k for all the ticks).\\n\\nDetermine whether this field can indeed be obtained by drawing some (possibly none) ticks of sizes d ≥ k or not.\\n\\nInput\\n\\nThe first line contains an integer t (1 ≤ t ≤ 100) — the number test cases.\\n\\nThe following lines contain the descriptions of the test cases. \\n\\nThe first line of the test case description contains the integers n, m, and k (1 ≤ k ≤ n ≤ 10; 1 ≤ m ≤ 19) — the field size and the minimum size of the ticks that Casimir drew. The following n lines describe the field: each line consists of m characters either being '.' if the corresponding cell is not yet painted or '*' otherwise.\\n\\nOutput\\n\\nPrint t lines, each line containing the answer to the corresponding test case. The answer to a test case should be YES if the given field can be obtained by drawing ticks of at least the given size and NO otherwise.\\n\\nYou may...\\ntests\",\"targets\":\"= int(input())\\nfor _ in range(0, tests):\\n n, m, k = map(int, input().split())\\n arr = []\\n inds = []\\n final = []\\n for _ in range(0, n):\\n i = input()\\n for j in range(0, m):\\n if i[j] == \\\"*\\\":\\n inds.append([_, j])\\n arr.append(i)\\n for i in range(n-1, k-1, -1):\\n for j in range(0, m):\\n if arr[i][j] == \\\"*\\\":\\n a = 1\\n b = 1\\n count = 0\\n new = []\\n while i-a >= 0 and j-b >= 0 and j+b <= m-1:\\n if arr[i-a][j-b] == \\\"*\\\" and arr[i-a][j+b] == \\\"*\\\":\\n new.append([i - a, j - b])\\n new.append([i - a, j + b])\\n a += 1\\n b += 1\\n count += 1\\n else:\\n break\\n if count >= k:\\n if [i,j] not in final:\\n final.append([i, j])\\n for pp in new:\\n if pp not in final:\\n final.append(pp)\\n if final != []:\\n for i in final:\\n if i in inds:\\n val = True\\n else:\\n val = False\\n break\\n if val and len(final) == len(inds):\\n print(\\\"YEs\\\")\\n else:\\n print(\\\"NO\\\")\\n elif final == [] and inds == []:\\n print(\\\"YES\\\")\\n else:\\n print(\\\"NO\\\")\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"During the break the schoolchildren, boys and girls, formed a queue of n people in the canteen. Initially the children stood in the order they entered the canteen. However, after a while the boys started feeling awkward for standing in front of the girls in the queue and they started letting the girls move forward each second. \\n\\nLet's describe the process more precisely. Let's say that the positions in the queue are sequentially numbered by integers from 1 to n, at that the person in the position number 1 is served first. Then, if at time x a boy stands on the i-th position and a girl stands on the (i + 1)-th position, then at time x + 1 the i-th position will have a girl and the (i + 1)-th position will have a boy. The time is given in seconds.\\n\\nYou've got the initial position of the children, at the initial moment of time. Determine the way the queue is going to look after t seconds.\\n\\nInput\\n\\nThe first line contains two integers n and t (1 ≤ n, t ≤ 50), which represent the number of children in the queue and the time after which the queue will transform into the arrangement you need to find. \\n\\nThe next line contains string s, which represents the schoolchildren's initial arrangement. If the i-th position in the queue contains a boy, then the i-th character of string s equals \\\"B\\\", otherwise the i-th character equals \\\"G\\\".\\n\\nOutput\\n\\nPrint string a, which describes the arrangement after t seconds. If the i-th position has a boy after the needed time, then the i-th character a must equal \\\"B\\\", otherwise it must equal \\\"G\\\".\\n\\nExamples\\n\\nInput\\n\\n5 1\\nBGGBG\\n\\n\\nOutput\\n\\nGBGGB\\n\\n\\nInput\\n\\n5 2\\nBGGBG\\n\\n\\nOutput\\n\\nGGBGB\\n\\n\\nInput\\n\\n4 1\\nGGGB\\n\\n\\nOutput\\n\\nGGGB\\nUsing python3 can you solve the prior task?\",\"targets\":\"n,t=list(map(int,input().split()))\\ns=str(input())\\nfor i in range(t):\\n s=s.replace('BG','GB')\\nprint(s)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Recently, Petya learned about a new game \\\"Slay the Dragon\\\". As the name suggests, the player will have to fight with dragons. To defeat a dragon, you have to kill it and defend your castle. To do this, the player has a squad of n heroes, the strength of the i-th hero is equal to a_i.\\n\\nAccording to the rules of the game, exactly one hero should go kill the dragon, all the others will defend the castle. If the dragon's defense is equal to x, then you have to send a hero with a strength of at least x to kill it. If the dragon's attack power is y, then the total strength of the heroes defending the castle should be at least y.\\n\\nThe player can increase the strength of any hero by 1 for one gold coin. This operation can be done any number of times.\\n\\nThere are m dragons in the game, the i-th of them has defense equal to x_i and attack power equal to y_i. Petya was wondering what is the minimum number of coins he needs to spend to defeat the i-th dragon.\\n\\nNote that the task is solved independently for each dragon (improvements are not saved).\\n\\nInput\\n\\nThe first line contains a single integer n (2 ≤ n ≤ 2 ⋅ 10^5) — number of heroes.\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^{12}), where a_i is the strength of the i-th hero.\\n\\nThe third line contains a single integer m (1 ≤ m ≤ 2 ⋅ 10^5) — the number of dragons.\\n\\nThe next m lines contain two integers each, x_i and y_i (1 ≤ x_i ≤ 10^{12}; 1 ≤ y_i ≤ 10^{18}) — defense and attack power of the i-th dragon.\\n\\nOutput\\n\\nPrint m lines, i-th of which contains a single integer — the minimum number of coins that should be spent to defeat the i-th dragon.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3 6 2 3\\n5\\n3 12\\n7 9\\n4 14\\n1 10\\n8 7\\n\\n\\nOutput\\n\\n\\n1\\n2\\n4\\n0\\n2\\n\\nNote\\n\\nTo defeat the first dragon, you can increase the strength of the third hero by 1, then the strength of the heroes will be equal to [3, 6, 3, 3]. To kill the dragon, you can choose the first hero.\\n\\nTo defeat the second dragon, you can increase the forces of the second and third heroes by 1, then the strength of the heroes will...\\nUsing java can you solve the prior task?\",\"targets\":\"import java.io.PrintWriter;\\nimport java.util.Arrays;\\nimport java.util.Random;\\nimport java.util.Scanner;\\n\\npublic class Main {\\n \\n public static void main(String[] args) {\\n \\n var sc = new Scanner(System.in);\\n var pw = new PrintWriter(System.out);\\n \\n int n = Integer.parseInt(sc.next());\\n var a = new long[n];\\n long sum = 0;\\n for(int i = 0; i < n; i++){\\n a[i] = Long.parseLong(sc.next());\\n sum += a[i];\\n }\\n shuffle(a);\\n Arrays.sort(a);\\n \\n int M = Integer.parseInt(sc.next());\\n for(int m = 0; m < M; m++){\\n long x = Long.parseLong(sc.next());\\n long y = Long.parseLong(sc.next());\\n \\n int index = lowerBound(a, x);\\n long ans = Long.MAX_VALUE;\\n if(index < n){\\n ans = Math.max(y - (sum - a[index]), 0);\\n }\\n \\n index--;\\n if(index >= 0){\\n long coins = 0;\\n coins += x - a[index];\\n coins += Math.max(y - (sum - a[index]), 0);\\n ans = Math.min(coins, ans);\\n }\\n pw.println(ans);\\n }\\n pw.flush();\\n }\\n \\n static void shuffle(long[] a){\\n int n = a.length;\\n Random r = new Random();\\n for(int i = n-1; i >= 1; i--){\\n int j = r.nextInt(i+1);\\n long tmp = a[i];\\n a[i] = a[j];\\n a[j] = tmp;\\n }\\n }\\n \\n static int lowerBound(long[] a, long key){\\n int left = -1;\\n int right = a.length;\\n while(right - left > 1){\\n int mid = left + (right - left) \\/ 2;\\n if(a[mid] >= key){\\n right = mid;\\n }else{\\n left = mid;\\n }\\n }\\n return right;\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"British mathematician John Littlewood once said about Indian mathematician Srinivasa Ramanujan that \\\"every positive integer was one of his personal friends.\\\"\\n\\nIt turns out that positive integers can also be friends with each other! You are given an array a of distinct positive integers. \\n\\nDefine a subarray a_i, a_{i+1}, …, a_j to be a friend group if and only if there exists an integer m ≥ 2 such that a_i mod m = a_{i+1} mod m = … = a_j mod m, where x mod y denotes the remainder when x is divided by y.\\n\\nYour friend Gregor wants to know the size of the largest friend group in a.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 2⋅ 10^4). \\n\\nEach test case begins with a line containing the integer n (1 ≤ n ≤ 2 ⋅ 10^5), the size of the array a.\\n\\nThe next line contains n positive integers a_1, a_2, …, a_n (1 ≤ a_i ≤ {10}^{18}), representing the contents of the array a. It is guaranteed that all the numbers in a are distinct.\\n\\nIt is guaranteed that the sum of n over all test cases is less than 2⋅ 10^5.\\n\\nOutput\\n\\nYour output should consist of t lines. Each line should consist of a single integer, the size of the largest friend group in a.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n5\\n1 5 2 4 6\\n4\\n8 2 5 10\\n2\\n1000 2000\\n8\\n465 55 3 54 234 12 45 78\\n\\n\\nOutput\\n\\n\\n3\\n3\\n2\\n6\\n\\nNote\\n\\nIn the first test case, the array is [1,5,2,4,6]. The largest friend group is [2,4,6], since all those numbers are congruent to 0 modulo 2, so m=2.\\n\\nIn the second test case, the array is [8,2,5,10]. The largest friend group is [8,2,5], since all those numbers are congruent to 2 modulo 3, so m=3.\\n\\nIn the third case, the largest friend group is [1000,2000]. There are clearly many possible values of m that work.\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nlong long x[200010];\\nlong long cha[200010];\\nlong long gcd(long long a, long long b) {\\n if (b == 0)\\n return a;\\n else\\n return gcd(b, a % b);\\n}\\nint main() {\\n int t;\\n scanf(\\\"%d\\\", &t);\\n while (t--) {\\n int n;\\n scanf(\\\"%d\\\", &n);\\n for (int i = 1; i <= n; i++) {\\n scanf(\\\"%lld\\\", &x[i]);\\n if (i > 1) cha[i - 1] = max(x[i] - x[i - 1], x[i - 1] - x[i]);\\n }\\n long long k = cha[1], fl = 1, mx = 1, tot = 1;\\n for (int i = 1; i < n; i++) {\\n k = gcd(k, cha[i]);\\n if (k == 1) {\\n k = cha[i];\\n tot = 2;\\n fl = i;\\n if (k == 1) {\\n k = cha[i + 1];\\n tot = 1;\\n continue;\\n }\\n for (int j = i - 1; j >= 1; j--) {\\n if (gcd(k, cha[j]) != 1)\\n k = gcd(k, cha[j]), tot++, fl = j;\\n else\\n break;\\n }\\n } else {\\n tot++;\\n mx = max(mx, tot);\\n }\\n }\\n printf(\\\"%d\\\\n\\\", mx);\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"The only difference between this problem and D1 is that you don't have to provide the way to construct the answer in D1, but you have to do it in this problem.\\n\\nThere's a table of n × m cells (n rows and m columns). The value of n ⋅ m is even.\\n\\nA domino is a figure that consists of two cells having a common side. It may be horizontal (one of the cells is to the right of the other) or vertical (one of the cells is above the other).\\n\\nYou need to place nm\\/2 dominoes on the table so that exactly k of them are horizontal and all the other dominoes are vertical. The dominoes cannot overlap and must fill the whole table.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of a single line. The line contains three integers n, m, k (1 ≤ n,m ≤ 100, 0 ≤ k ≤ nm\\/2, n ⋅ m is even) — the count of rows, columns and horizontal dominoes, respectively.\\n\\nOutput\\n\\nFor each test case:\\n\\n * print \\\"NO\\\" if it's not possible to place the dominoes on the table in the described way; \\n * otherwise, print \\\"YES\\\" on a separate line, then print n lines so that each of them contains m lowercase letters of the Latin alphabet — the layout of the dominoes on the table. Each cell of the table must be marked by the letter so that for every two cells having a common side, they are marked by the same letters if and only if they are occupied by the same domino. I.e. both cells of the same domino must be marked with the same letter, but two dominoes that share a side must be marked with different letters. If there are multiple solutions, print any of them. \\n\\nExample\\n\\nInput\\n\\n\\n8\\n4 4 2\\n2 3 0\\n3 2 3\\n1 2 0\\n2 4 2\\n5 2 2\\n2 17 16\\n2 1 1\\n\\n\\nOutput\\n\\n\\nYES\\naccx\\naegx\\nbega\\nbdda\\nYES\\naha\\naha\\nYES\\nzz\\naa\\nzz\\nNO\\nYES\\naaza\\nbbza\\nNO\\nYES\\nbbaabbaabbaabbaay\\nddccddccddccddccy\\nNO\",\"targets\":\"ans = []\\nfor _ in range(int(input())):\\n n, m, k = map(int, input().split())\\n if n % 2 == 0 and m % 2 == 0:\\n if k % 2 == 0:\\n ans.append('YES')\\n u = []\\n for i in range(n):\\n u.append(['a'] * m)\\n a = b = 0\\n cur = 'a'\\n for i in range(k \\/\\/ 2):\\n u[a][b] = cur\\n u[a][b + 1] = cur\\n cur = chr((ord(cur) - ord('a') + 1) % 26 + ord('a'))\\n u[a + 1][b] = cur\\n u[a + 1][b + 1] = cur\\n cur = chr((ord(cur) - ord('a') + 1) % 26 + ord('a'))\\n if b + 2 < m:\\n b += 2\\n else:\\n b = 0\\n a += 2\\n cur = u[a - 1][b]\\n cur = chr((ord(cur) - ord('a') + 1) % 26 + ord('a'))\\n cur = chr((ord(cur) - ord('a') + 1) % 26 + ord('a'))\\n for i in range(n * m \\/\\/ 4 - k \\/\\/ 2):\\n u[a][b] = cur\\n u[a + 1][b] = cur\\n cur = chr((ord(cur) - ord('a') + 1) % 26 + ord('a'))\\n u[a][b + 1] = cur\\n u[a + 1][b + 1] = cur\\n cur = chr((ord(cur) - ord('a') + 1) % 26 + ord('a'))\\n if b + 2 < m:\\n b += 2\\n else:\\n b = 0\\n a += 2\\n cur = u[a - 1][b]\\n cur = chr((ord(cur) - ord('a') + 1) % 26 + ord('a'))\\n cur = chr((ord(cur) - ord('a') + 1) % 26 + ord('a'))\\n for i in range(n):\\n ans.append(''.join(u[i]))\\n else:\\n ans.append('NO')\\n continue\\n ok = False\\n if n % 2 == 1:\\n k = n * m \\/\\/ 2 - k\\n n, m = m, n\\n ok = True\\n if k > n * m \\/\\/ 2 - n \\/\\/ 2:\\n ans.append('NO')\\n elif k % 2 == 1:\\n ans.append('NO')\\n else:\\n u = []\\n for i in range(n):\\n u.append(['a'] * m)\\n cur = 'a'\\n #print('\\\\n'.join(map(str, u)))\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nIn some country live wizards. They love to ride trolleybuses.\\n\\nA city in this country has a trolleybus depot with n trolleybuses. Every day the trolleybuses leave the depot, one by one and go to the final station. The final station is at a distance of d meters from the depot. We know for the i-th trolleybus that it leaves at the moment of time ti seconds, can go at a speed of no greater than vi meters per second, and accelerate with an acceleration no greater than a meters per second squared. A trolleybus can decelerate as quickly as you want (magic!). It can change its acceleration as fast as you want, as well. Note that the maximum acceleration is the same for all trolleys.\\n\\nDespite the magic the trolleys are still powered by an electric circuit and cannot overtake each other (the wires are to blame, of course). If a trolleybus catches up with another one, they go together one right after the other until they arrive at the final station. Also, the drivers are driving so as to arrive at the final station as quickly as possible.\\n\\nYou, as head of the trolleybuses' fans' club, are to determine for each trolley the minimum time by which it can reach the final station. At the time of arrival at the destination station the trolleybus does not necessarily have zero speed. When a trolley is leaving the depot, its speed is considered equal to zero. From the point of view of physics, the trolleybuses can be considered as material points, and also we should ignore the impact on the speed of a trolley bus by everything, except for the acceleration and deceleration provided by the engine.\\n\\nInput\\n\\nThe first input line contains three space-separated integers n, a, d (1 ≤ n ≤ 105, 1 ≤ a, d ≤ 106) — the number of trolleybuses, their maximum acceleration and the distance from the depot to the final station, correspondingly.\\n\\nNext n lines contain pairs of integers ti vi (0 ≤ t1 < t2... < tn - 1 < tn ≤ 106, 1 ≤ vi ≤ 106) — the time when the i-th trolleybus leaves the depot and its maximum speed, correspondingly. The numbers in...\",\"targets\":\"#include \\nusing namespace std;\\ntypedef struct _Bus {\\n double v, t;\\n _Bus(double v, double t) {\\n this->v = v;\\n this->t = t;\\n }\\n _Bus() {}\\n} Bus;\\nint n;\\ndouble a, d;\\nBus bus[100100];\\ndouble getMaxSpeedWhen(Bus b) { return b.v \\/ a; }\\ndouble lengthWhenMaxSpeed(Bus b) {\\n double t = getMaxSpeedWhen(b);\\n return 0.5f * a * t * t;\\n}\\ndouble timeToArrive(Bus b) {\\n double t = getMaxSpeedWhen(b);\\n double length = d - lengthWhenMaxSpeed(b);\\n if (length <= 0) return sqrt(2.0f * d \\/ a) + b.t;\\n return length \\/ b.v + t + b.t;\\n}\\nint main() {\\n scanf(\\\"%d %lf %lf\\\", &n, &a, &d);\\n for (int(i) = (0), _n = (n - 1); (i) <= _n; (i)++) {\\n double v, t;\\n scanf(\\\"%lf %lf\\\", &t, &v);\\n bus[i] = Bus(v, t);\\n }\\n double prevAns = timeToArrive(bus[0]);\\n for (int(i) = (0), _n = (n - 1); (i) <= _n; (i)++) {\\n double ans = timeToArrive(bus[i]);\\n if (prevAns >= ans)\\n ans = prevAns;\\n else\\n prevAns = ans;\\n printf(\\\"%.11lf\\\\n\\\", ans);\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"You are given an array a[0 … n - 1] = [a_0, a_1, …, a_{n - 1}] of zeroes and ones only. Note that in this problem, unlike the others, the array indexes are numbered from zero, not from one.\\n\\nIn one step, the array a is replaced by another array of length n according to the following rules: \\n\\n 1. First, a new array a^{→ d} is defined as a cyclic shift of the array a to the right by d cells. The elements of this array can be defined as a^{→ d}_i = a_{(i + n - d) mod n}, where (i + n - d) mod n is the remainder of integer division of i + n - d by n. \\n\\nIt means that the whole array a^{→ d} can be represented as a sequence $$$a^{→ d} = [a_{n - d}, a_{n - d + 1}, …, a_{n - 1}, a_0, a_1, …, a_{n - d - 1}]$$$\\n\\n 2. Then each element of the array a_i is replaced by a_i \\\\& a^{→ d}_i, where \\\\& is a logical \\\"AND\\\" operator. \\n\\n\\n\\nFor example, if a = [0, 0, 1, 1] and d = 1, then a^{→ d} = [1, 0, 0, 1] and the value of a after the first step will be [0 \\\\& 1, 0 \\\\& 0, 1 \\\\& 0, 1 \\\\& 1], that is [0, 0, 0, 1].\\n\\nThe process ends when the array stops changing. For a given array a, determine whether it will consist of only zeros at the end of the process. If yes, also find the number of steps the process will take before it finishes.\\n\\nInput\\n\\nThe first line contains an integer t (1 ≤ t ≤ 1000) — the number of test cases.\\n\\nThe next 2t lines contain descriptions of the test cases. \\n\\nThe first line of each test case description contains two integers: n (1 ≤ n ≤ 10^6) — array size and d (1 ≤ d ≤ n) — cyclic shift offset. The second line of the description contains n space-separated integers a_i (0 ≤ a_i ≤ 1) — elements of the array.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 10^6.\\n\\nOutput\\n\\nPrint t lines, each line containing the answer to the corresponding test case. The answer to a test case should be a single integer — the number of steps after which the array will contain only zeros for the first time. If there are still elements equal to 1 in the array after the end of the process, print...\\\":\",\"targets\":\"#include \\nusing namespace std;\\ntemplate \\nostream& operator<<(ostream& os, vector& v) {\\n if (v.size() == 0) {\\n os << \\\"empty vector\\\\n\\\";\\n return os;\\n }\\n for (auto element : v) os << element << \\\" \\\";\\n return os;\\n}\\ntemplate \\nostream& operator<<(ostream& os, pair& p) {\\n os << \\\"(\\\" << p.first << \\\", \\\" << p.second << \\\")\\\";\\n return os;\\n}\\ntemplate \\nostream& operator<<(ostream& os, set& v) {\\n if (v.size() == 0) {\\n os << \\\"empty set\\\\n\\\";\\n return os;\\n }\\n auto endit = v.end();\\n endit--;\\n os << \\\"[\\\";\\n for (auto it = v.begin(); it != v.end(); it++) {\\n os << *it;\\n if (it != endit) os << \\\", \\\";\\n }\\n os << \\\"]\\\";\\n return os;\\n}\\ntemplate \\nostream& operator<<(ostream& os, multiset& v) {\\n if (v.size() == 0) {\\n os << \\\"empty multiset\\\\n\\\";\\n return os;\\n }\\n auto endit = v.end();\\n endit--;\\n os << \\\"[\\\";\\n for (auto it = v.begin(); it != v.end(); it++) {\\n os << *it;\\n if (it != endit) os << \\\", \\\";\\n }\\n os << \\\"]\\\";\\n return os;\\n}\\ntemplate \\nostream& operator<<(ostream& os, map& v) {\\n if (v.size() == 0) {\\n os << \\\"empty map\\\\n\\\";\\n return os;\\n }\\n auto endit = v.end();\\n endit--;\\n os << \\\"{\\\";\\n for (auto it = v.begin(); it != v.end(); it++) {\\n os << \\\"(\\\" << (*it).first << \\\" : \\\" << (*it).second << \\\")\\\";\\n if (it != endit) os << \\\", \\\";\\n }\\n os << \\\"}\\\";\\n return os;\\n}\\ntemplate \\nostream& operator<<(ostream& os, vector>& v) {\\n for (auto& subv : v) {\\n for (auto& e : subv) os << e << \\\" \\\";\\n os << \\\"\\\\n\\\";\\n }\\n return os;\\n}\\nbool do_debug = false;\\nvoid Runtime_Terror() {\\n long long n, d;\\n cin >> n >> d;\\n vector v(n + 1);\\n for (long long i = 1; i < n + 1; i++) cin >> v[i];\\n map m;\\n map rev;\\n for (long long i = 1; i < n + 1; i++) {\\n m[i] = (i + n - d) % n;\\n if (m[i] == 0) m[i] = n;\\n long long tem = (i + n - d) % n;\\n if (tem == 0) tem = n;\\n rev[tem] = i;\\n }\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"This version of the problem differs from the next one only in the constraint on n.\\n\\nNote that the memory limit in this problem is lower than in others.\\n\\nYou have a vertical strip with n cells, numbered consecutively from 1 to n from top to bottom.\\n\\nYou also have a token that is initially placed in cell n. You will move the token up until it arrives at cell 1.\\n\\nLet the token be in cell x > 1 at some moment. One shift of the token can have either of the following kinds: \\n\\n * Subtraction: you choose an integer y between 1 and x-1, inclusive, and move the token from cell x to cell x - y. \\n * Floored division: you choose an integer z between 2 and x, inclusive, and move the token from cell x to cell ⌊ x\\/z ⌋ (x divided by z rounded down). \\n\\n\\n\\nFind the number of ways to move the token from cell n to cell 1 using one or more shifts, and print it modulo m. Note that if there are several ways to move the token from one cell to another in one shift, all these ways are considered distinct (check example explanation for a better understanding).\\n\\nInput\\n\\nThe only line contains two integers n and m (2 ≤ n ≤ 2 ⋅ 10^5; 10^8 < m < 10^9; m is a prime number) — the length of the strip and the modulo.\\n\\nOutput\\n\\nPrint the number of ways to move the token from cell n to cell 1, modulo m.\\n\\nExamples\\n\\nInput\\n\\n\\n3 998244353\\n\\n\\nOutput\\n\\n\\n5\\n\\n\\nInput\\n\\n\\n5 998244353\\n\\n\\nOutput\\n\\n\\n25\\n\\n\\nInput\\n\\n\\n42 998244353\\n\\n\\nOutput\\n\\n\\n793019428\\n\\nNote\\n\\nIn the first test, there are three ways to move the token from cell 3 to cell 1 in one shift: using subtraction of y = 2, or using division by z = 2 or z = 3.\\n\\nThere are also two ways to move the token from cell 3 to cell 1 via cell 2: first subtract y = 1, and then either subtract y = 1 again or divide by z = 2.\\n\\nTherefore, there are five ways in total.\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 101005;\\nvoid solve() {\\n int n, m;\\n cin >> n >> m;\\n vector dp(n + 1, 0);\\n dp[1] = 1;\\n long long sum = 1;\\n for (int i = 2; i <= n; i++) {\\n dp[i] = (dp[i] + sum) % m;\\n dp[i] += (i - i \\/ 2) * dp[1];\\n dp[i] %= m;\\n int sqr = sqrt(i);\\n for (int j = 2; j <= sqr; j++) {\\n dp[i] += ((i \\/ j - i \\/ (j + 1)) * dp[j]) % m;\\n dp[i] %= m;\\n if (i \\/ sqr > j) {\\n dp[i] = (dp[i] + dp[i \\/ j]) % m;\\n }\\n }\\n sum = (sum + dp[i]) % m;\\n }\\n cout << dp[n] << endl;\\n}\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cout << fixed << setprecision(30);\\n solve();\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"After a long day, Alice and Bob decided to play a little game. The game board consists of n cells in a straight line, numbered from 1 to n, where each cell contains a number a_i between 1 and n. Furthermore, no two cells contain the same number. \\n\\nA token is placed in one of the cells. They take alternating turns of moving the token around the board, with Alice moving first. The current player can move from cell i to cell j only if the following two conditions are satisfied: \\n\\n * the number in the new cell j must be strictly larger than the number in the old cell i (i.e. a_j > a_i), and \\n * the distance that the token travels during this turn must be a multiple of the number in the old cell (i.e. |i-j|mod a_i = 0). \\n\\n\\n\\nWhoever is unable to make a move, loses. For each possible starting position, determine who wins if they both play optimally. It can be shown that the game is always finite, i.e. there always is a winning strategy for one of the players.\\n\\nInput\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 10^5) — the number of numbers.\\n\\nThe second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ n). Furthermore, there are no pair of indices i ≠ j such that a_i = a_j.\\n\\nOutput\\n\\nPrint s — a string of n characters, where the i-th character represents the outcome of the game if the token is initially placed in the cell i. If Alice wins, then s_i has to be equal to \\\"A\\\"; otherwise, s_i has to be equal to \\\"B\\\". \\n\\nExamples\\n\\nInput\\n\\n8\\n3 6 5 4 2 7 1 8\\n\\n\\nOutput\\n\\nBAAAABAB\\n\\n\\nInput\\n\\n15\\n3 11 2 5 10 9 7 13 15 8 4 12 6 1 14\\n\\n\\nOutput\\n\\nABAAAABBBAABAAB\\n\\nNote\\n\\nIn the first sample, if Bob puts the token on the number (not position): \\n\\n * 1: Alice can move to any number. She can win by picking 7, from which Bob has no move. \\n * 2: Alice can move to 3 and 5. Upon moving to 5, Bob can win by moving to 8. If she chooses 3 instead, she wins, as Bob has only a move to 4, from which Alice can move to 8. \\n * 3: Alice can only move to 4, after which Bob wins by moving to 8. \\n * 4, 5, or 6: Alice wins by moving to 8. \\n * 7, 8:...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nlong long Set(long long N, long long pos) { return N = N | (1 << pos); }\\nlong long reset(long long N, long long pos) { return N = N & ~(1 << pos); }\\nconst int mx = 100000 + 100;\\nint arr[mx], ans[mx], pos[mx];\\nint main() {\\n int n;\\n cin >> n;\\n for (int i = 1; i <= n; i++) {\\n cin >> arr[i];\\n pos[arr[i]] = i;\\n }\\n for (int i = n; i >= 1; i--) {\\n int x = pos[i];\\n bool flag = true;\\n for (int j = x - i; j >= 1; j -= i) {\\n if (arr[j] > i) {\\n if (ans[arr[j]] == 0) {\\n flag = false;\\n }\\n }\\n }\\n for (int j = i + x; j <= n; j += i) {\\n if (arr[j] > i) {\\n if (ans[arr[j]] == 0) {\\n flag = false;\\n }\\n }\\n }\\n if (flag)\\n ans[i] = 0;\\n else\\n ans[i] = 1;\\n }\\n for (int i = 1; i <= n; i++) {\\n if (ans[arr[i]] == 0)\\n cout << \\\"B\\\";\\n else\\n cout << \\\"A\\\";\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"Gregor is learning about RSA cryptography, and although he doesn't understand how RSA works, he is now fascinated with prime numbers and factoring them.\\n\\nGregor's favorite prime number is P. Gregor wants to find two bases of P. Formally, Gregor is looking for two integers a and b which satisfy both of the following properties.\\n\\n * P mod a = P mod b, where x mod y denotes the remainder when x is divided by y, and \\n * 2 ≤ a < b ≤ P. \\n\\n\\n\\nHelp Gregor find two bases of his favorite prime number!\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 1000).\\n\\nEach subsequent line contains the integer P (5 ≤ P ≤ {10}^9), with P guaranteed to be prime.\\n\\nOutput\\n\\nYour output should consist of t lines. Each line should consist of two integers a and b (2 ≤ a < b ≤ P). If there are multiple possible solutions, print any.\\n\\nExample\\n\\nInput\\n\\n\\n2\\n17\\n5\\n\\n\\nOutput\\n\\n\\n3 5\\n2 4\\n\\nNote\\n\\nThe first query is P=17. a=3 and b=5 are valid bases in this case, because 17 mod 3 = 17 mod 5 = 2. There are other pairs which work as well.\\n\\nIn the second query, with P=5, the only solution is a=2 and b=4.\\\":\",\"targets\":\"import java.util.*;\\n\\/\\/ import java.lang.*;\\nimport java.io.*;\\n\\n\\npublic class A_Gregor_and_Cryptography\\n{\\n \\n public static class FastReader {\\n BufferedReader br;\\n StringTokenizer st;\\n \\n public FastReader()\\n {\\n br = new BufferedReader(\\n new InputStreamReader(System.in));\\n }\\n \\n String next()\\n {\\n while (st == null || !st.hasMoreElements()) {\\n try {\\n st = new StringTokenizer(br.readLine());\\n }\\n catch (IOException e) {\\n e.printStackTrace();\\n }\\n }\\n return st.nextToken();\\n }\\n \\n int nextInt() { return Integer.parseInt(next()); }\\n \\n long nextLong() { return Long.parseLong(next()); }\\n \\n double nextDouble()\\n {\\n return Double.parseDouble(next());\\n }\\n \\n String nextLine()\\n {\\n String str = \\\"\\\";\\n try {\\n str = br.readLine();\\n }\\n catch (IOException e) {\\n e.printStackTrace();\\n }\\n return str;\\n }\\n }\\n \\n public static void swap(int i, int j)\\n {\\n int temp = i;\\n i = j;\\n j = temp;\\n }\\n \\n\\tpublic static void main (String[] args) throws java.lang.Exception\\n\\t{\\n\\t\\tFastReader sc = new FastReader();\\n\\t\\tint t = sc.nextInt();\\n\\t\\twhile(t-->0){\\n\\t\\t int n = sc.nextInt();\\n System.out.println((n-1)\\/2+\\\" \\\"+(n-1));\\n\\t\\t}\\n\\t}\\n\\t\\n\\t\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"In a certain video game, the player controls a hero characterized by a single integer value: power. The hero will have to beat monsters that are also characterized by a single integer value: armor.\\n\\nOn the current level, the hero is facing n caves. To pass the level, the hero must enter all the caves in some order, each cave exactly once, and exit every cave safe and sound. When the hero enters cave i, he will have to fight k_i monsters in a row: first a monster with armor a_{i, 1}, then a monster with armor a_{i, 2} and so on, finally, a monster with armor a_{i, k_i}.\\n\\nThe hero can beat a monster if and only if the hero's power is strictly greater than the monster's armor. If the hero can't beat the monster he's fighting, the game ends and the player loses. Note that once the hero enters a cave, he can't exit it before he fights all the monsters in it, strictly in the given order.\\n\\nEach time the hero beats a monster, the hero's power increases by 1.\\n\\nFind the smallest possible power the hero must start the level with to be able to enter all the caves in some order and beat all the monsters.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^5). Description of the test cases follows.\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 10^5) — the number of caves.\\n\\nThe i-th of the next n lines contains an integer k_i (1 ≤ k_i ≤ 10^5) — the number of monsters in the i-th cave, followed by k_i integers a_{i, 1}, a_{i, 2}, …, a_{i, k_i} (1 ≤ a_{i, j} ≤ 10^9) — armor levels of the monsters in cave i in order the hero has to fight them.\\n\\nIt is guaranteed that the sum of k_i over all test cases does not exceed 10^5.\\n\\nOutput\\n\\nFor each test case print a single integer — the smallest possible power the hero must start the level with to be able to enter all the caves in some order and beat all the monsters.\\n\\nExample\\n\\nInput\\n\\n\\n2\\n1\\n1 42\\n2\\n3 10 15 8\\n2 12 11\\n\\n\\nOutput\\n\\n\\n43\\n13\\n\\nNote\\n\\nIn the first test case, the hero has to beat a single monster with...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n ios::sync_with_stdio(0);\\n cin.tie(0);\\n int T;\\n cin >> T;\\n while (T--) {\\n int n;\\n cin >> n;\\n vector> c;\\n for (int(j) = 0; (j) < (n); (j)++) {\\n int k;\\n cin >> k;\\n vector temp;\\n for (int(j) = 0; (j) < (k); (j)++) {\\n int a;\\n cin >> a;\\n temp.push_back(a);\\n }\\n int ma = 0;\\n for (int(j) = 0; (j) < (k); (j)++) {\\n ma = (ma < temp[j] - j + 1 ? temp[j] - j + 1 : ma);\\n }\\n int pos = 0;\\n for (int(j) = 0; (j) < (k); (j)++) {\\n if (ma == temp[j] - j + 1) {\\n pos = j;\\n break;\\n }\\n }\\n c.push_back(make_pair(ma, ma + k));\\n }\\n sort(c.begin(), c.end());\\n int ans = c[0].first;\\n for (int(i) = 0; (i) < (n - 1); (i)++) {\\n if (c[i].second > c[i + 1].first) {\\n c[i + 1].second = c[i].second + c[i + 1].second - c[i + 1].first;\\n } else {\\n ans += c[i + 1].first - c[i].second;\\n }\\n }\\n cout << ans << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given a sequence a_1, a_2, ..., a_n consisting of n pairwise distinct positive integers.\\n\\nFind \\\\left⌊ \\\\frac n 2 \\\\right⌋ different pairs of integers x and y such that: \\n\\n * x ≠ y; \\n * x and y appear in a; \\n * x~mod~y doesn't appear in a. \\n\\n\\n\\nNote that some x or y can belong to multiple pairs.\\n\\n⌊ x ⌋ denotes the floor function — the largest integer less than or equal to x. x~mod~y denotes the remainder from dividing x by y.\\n\\nIf there are multiple solutions, print any of them. It can be shown that at least one solution always exists.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.\\n\\nThe first line of each testcase contains a single integer n (2 ≤ n ≤ 2 ⋅ 10^5) — the length of the sequence.\\n\\nThe second line of each testcase contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^6).\\n\\nAll numbers in the sequence are pairwise distinct. The sum of n over all testcases doesn't exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nThe answer for each testcase should contain \\\\left⌊ \\\\frac n 2 \\\\right⌋ different pairs of integers x and y such that x ≠ y, x and y appear in a and x~mod~y doesn't appear in a. Print the pairs one after another.\\n\\nYou can print the pairs in any order. However, the order of numbers in the pair should be exactly such that the first number is x and the second number is y. All pairs should be pairwise distinct.\\n\\nIf there are multiple solutions, print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n2\\n1 4\\n4\\n2 8 3 4\\n5\\n3 8 5 9 7\\n6\\n2 7 5 3 4 8\\n\\n\\nOutput\\n\\n\\n4 1\\n8 2\\n8 4\\n9 5\\n7 5\\n8 7\\n4 3\\n5 2\\n\\nNote\\n\\nIn the first testcase there are only two pairs: (1, 4) and (4, 1). \\\\left⌊ \\\\frac 2 2 \\\\right⌋=1, so we have to find one pair. 1~mod~4=1, and 1 appears in a, so that pair is invalid. Thus, the only possible answer is a pair (4, 1).\\n\\nIn the second testcase, we chose pairs 8~mod~2=0 and 8~mod~4=0. 0 doesn't appear in a, so that answer is valid. There are multiple possible answers for that testcase.\\n\\nIn the third testcase, the chosen pairs are 9~mod~5=4 and 7~mod~5=2. Neither 4, nor 2, appears in a, so that...\",\"targets\":\"for _ in range(int(input())):\\n n=int(input())\\n arr=list(map(int,input().split()))\\n m=min(arr)\\n s=set(arr)\\n ans=[]\\n for el in sorted(arr)[1:]:\\n if el%m not in s:\\n ans.append((el,m))\\n for a,b in ans[:n\\/\\/2]:\\n print(a,b)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"City X consists of n vertical and n horizontal infinite roads, forming n × n intersections. Roads (both vertical and horizontal) are numbered from 1 to n, and the intersections are indicated by the numbers of the roads that form them.\\n\\nSand roads have long been recognized out of date, so the decision was made to asphalt them. To do this, a team of workers was hired and a schedule of work was made, according to which the intersections should be asphalted.\\n\\nRoad repairs are planned for n2 days. On the i-th day of the team arrives at the i-th intersection in the list and if none of the two roads that form the intersection were already asphalted they asphalt both roads. Otherwise, the team leaves the intersection, without doing anything with the roads.\\n\\nAccording to the schedule of road works tell in which days at least one road will be asphalted.\\n\\nInput\\n\\nThe first line contains integer n (1 ≤ n ≤ 50) — the number of vertical and horizontal roads in the city. \\n\\nNext n2 lines contain the order of intersections in the schedule. The i-th of them contains two numbers hi, vi (1 ≤ hi, vi ≤ n), separated by a space, and meaning that the intersection that goes i-th in the timetable is at the intersection of the hi-th horizontal and vi-th vertical roads. It is guaranteed that all the intersections in the timetable are distinct.\\n\\nOutput\\n\\nIn the single line print the numbers of the days when road works will be in progress in ascending order. The days are numbered starting from 1.\\n\\nExamples\\n\\nInput\\n\\n2\\n1 1\\n1 2\\n2 1\\n2 2\\n\\n\\nOutput\\n\\n1 4 \\n\\n\\nInput\\n\\n1\\n1 1\\n\\n\\nOutput\\n\\n1 \\n\\nNote\\n\\nIn the sample the brigade acts like that:\\n\\n 1. On the first day the brigade comes to the intersection of the 1-st horizontal and the 1-st vertical road. As none of them has been asphalted, the workers asphalt the 1-st vertical and the 1-st horizontal road; \\n 2. On the second day the brigade of the workers comes to the intersection of the 1-st horizontal and the 2-nd vertical road. The 2-nd vertical road hasn't been asphalted, but as the 1-st horizontal road has...\\nimpor\",\"targets\":\"t java.io.OutputStream;\\nimport java.io.IOException;\\nimport java.io.InputStream;\\nimport java.io.OutputStream;\\nimport java.io.PrintWriter;\\nimport java.io.BufferedWriter;\\nimport java.io.Writer;\\nimport java.io.OutputStreamWriter;\\nimport java.util.InputMismatchException;\\nimport java.io.IOException;\\nimport java.io.InputStream;\\n\\n\\/**\\n * Built using CHelper plug-in\\n * Actual solution is at the top\\n *\\n * @author PloadyFree\\n *\\/\\npublic class Main {\\n\\tpublic static void main(String[] args) {\\n\\t\\tInputStream inputStream = System.in;\\n\\t\\tOutputStream outputStream = System.out;\\n\\t\\tInputReader in = new InputReader(inputStream);\\n\\t\\tOutputWriter out = new OutputWriter(outputStream);\\n\\t\\tTaskA solver = new TaskA();\\n\\t\\tsolver.solve(1, in, out);\\n\\t\\tout.close();\\n\\t}\\n\\n\\tstatic class TaskA {\\n\\t\\tpublic void solve(int testNumber, InputReader in, OutputWriter out) {\\n\\t\\t\\tint n = in.readInt();\\n\\t\\t\\tboolean[] h0 = new boolean[n];\\n\\t\\t\\tboolean[] w0 = new boolean[n];\\n\\t\\t\\tfor (int i = 0; i < n * n; i++) {\\n\\t\\t\\t\\tint h = in.readInt() - 1;\\n\\t\\t\\t\\tint w = in.readInt() - 1;\\n\\t\\t\\t\\tif (!h0[h] && !w0[w]) {\\n\\t\\t\\t\\t\\tout.print((i + 1) + \\\" \\\");\\n\\t\\t\\t\\t\\th0[h] = w0[w] = true;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t}\\n\\n\\t}\\n\\n\\tstatic class OutputWriter {\\n\\t\\tprivate final PrintWriter writer;\\n\\n\\t\\tpublic OutputWriter(OutputStream outputStream) {\\n\\t\\t\\twriter = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));\\n\\t\\t}\\n\\n\\t\\tpublic OutputWriter(Writer writer) {\\n\\t\\t\\tthis.writer = new PrintWriter(writer);\\n\\t\\t}\\n\\n\\t\\tpublic void print(Object... objects) {\\n\\t\\t\\tfor (int i = 0; i < objects.length; i++) {\\n\\t\\t\\t\\tif (i != 0)\\n\\t\\t\\t\\t\\twriter.print(' ');\\n\\t\\t\\t\\twriter.print(objects[i]);\\n\\t\\t\\t}\\n\\t\\t}\\n\\n\\t\\tpublic void close() {\\n\\t\\t\\twriter.close();\\n\\t\\t}\\n\\n\\t}\\n\\n\\tstatic class InputReader {\\n\\t\\tprivate InputStream stream;\\n\\t\\tprivate byte[] buf = new byte[1024];\\n\\t\\tprivate int curChar;\\n\\t\\tprivate int numChars;\\n\\t\\tprivate SpaceCharFilter filter;\\n\\n\\t\\tpublic InputReader(InputStream stream) {\\n\\t\\t\\tthis.stream = stream;\\n\\t\\t}\\n\\n\\t\\tpublic int read() {\\n\\t\\t\\tif (numChars == -1)\\n\\t\\t\\t\\tthrow new InputMismatchException();\\n\\t\\t\\tif (curChar >= numChars) {\\n\\t\\t\\t\\tcurChar = 0;\\n\\t\\t\\t\\ttry...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"An exam for n students will take place in a long and narrow room, so the students will sit in a line in some order. The teacher suspects that students with adjacent numbers (i and i + 1) always studied side by side and became friends and if they take an exam sitting next to each other, they will help each other for sure.\\n\\nYour task is to choose the maximum number of students and make such an arrangement of students in the room that no two students with adjacent numbers sit side by side.\\n\\nInput\\n\\nA single line contains integer n (1 ≤ n ≤ 5000) — the number of students at an exam.\\n\\nOutput\\n\\nIn the first line print integer k — the maximum number of students who can be seated so that no two students with adjacent numbers sit next to each other.\\n\\nIn the second line print k distinct integers a1, a2, ..., ak (1 ≤ ai ≤ n), where ai is the number of the student on the i-th position. The students on adjacent positions mustn't have adjacent numbers. Formally, the following should be true: |ai - ai + 1| ≠ 1 for all i from 1 to k - 1.\\n\\nIf there are several possible answers, output any of them.\\n\\nExamples\\n\\nInput\\n\\n6\\n\\nOutput\\n\\n6\\n1 5 3 6 2 4\\n\\nInput\\n\\n3\\n\\n\\nOutput\\n\\n2\\n1 3\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nint n;\\nint main() {\\n scanf(\\\"%d\\\", &n);\\n if (n <= 2)\\n printf(\\\"1\\\\n1\\\");\\n else if (n == 3)\\n printf(\\\"2\\\\n1 3\\\");\\n else if (n == 4)\\n printf(\\\"4\\\\n3 1 4 2\\\");\\n else {\\n printf(\\\"%d\\\\n\\\", n);\\n for (int i = 1; i <= n; i++)\\n if (i % 2 != 0) printf(\\\"%d \\\", i);\\n for (int i = 1; i <= n; i++)\\n if (i % 2 == 0) printf(\\\"%d \\\", i);\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Monocarp is playing yet another computer game. In this game, his character has to kill a dragon. The battle with the dragon lasts 100^{500} seconds, during which Monocarp attacks the dragon with a poisoned dagger. The i-th attack is performed at the beginning of the a_i-th second from the battle start. The dagger itself does not deal damage, but it applies a poison effect on the dragon, which deals 1 damage during each of the next k seconds (starting with the same second when the dragon was stabbed by the dagger). However, if the dragon has already been poisoned, then the dagger updates the poison effect (i.e. cancels the current poison effect and applies a new one).\\n\\nFor example, suppose k = 4, and Monocarp stabs the dragon during the seconds 2, 4 and 10. Then the poison effect is applied at the start of the 2-nd second and deals 1 damage during the 2-nd and 3-rd seconds; then, at the beginning of the 4-th second, the poison effect is reapplied, so it deals exactly 1 damage during the seconds 4, 5, 6 and 7; then, during the 10-th second, the poison effect is applied again, and it deals 1 damage during the seconds 10, 11, 12 and 13. In total, the dragon receives 10 damage.\\n\\nMonocarp knows that the dragon has h hit points, and if he deals at least h damage to the dragon during the battle — he slays the dragon. Monocarp has not decided on the strength of the poison he will use during the battle, so he wants to find the minimum possible value of k (the number of seconds the poison effect lasts) that is enough to deal at least h damage to the dragon.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases.\\n\\nThe first line of the test case contains two integers n and h (1 ≤ n ≤ 100; 1 ≤ h ≤ 10^{18}) — the number of Monocarp's attacks and the amount of damage that needs to be dealt.\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9; a_i < a_{i + 1}), where a_i is the second when the i-th attack is performed.\\n\\nOutput\\n\\nFor each test case, print a single...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nconst int MAXN = 1010;\\nlong long t, n, arr[MAXN], h, sub[MAXN], cnt, add[MAXN];\\nlong long find(int x) {\\n long long l = 0, r = cnt + 1;\\n while (l < r) {\\n long long mid = (l + r) >> 1;\\n if (sub[mid] >= x)\\n r = mid;\\n else\\n l = mid + 1;\\n }\\n return l;\\n}\\nbool check(long long x) {\\n long long res = n;\\n int idx = lower_bound(sub, sub + cnt + 1, x - 1) - sub;\\n res += add[idx - 1] + (x - 1) * (n - idx + 1);\\n if (res >= h) return true;\\n return false;\\n}\\nint main() {\\n scanf(\\\"%d\\\", &t);\\n while (t--) {\\n cnt = 0;\\n memset(sub, 0, sizeof(sub));\\n memset(add, 0, sizeof(add));\\n scanf(\\\"%d%lld\\\", &n, &h);\\n for (int i = 1; i <= n; ++i) {\\n scanf(\\\"%d\\\", &arr[i]);\\n if (i > 1) sub[++cnt] = arr[i] - arr[i - 1] - 1;\\n }\\n sub[++cnt] = 1e18;\\n sort(sub + 1, sub + cnt + 1);\\n for (int i = 1; i <= cnt; ++i) add[i] = add[i - 1] + sub[i];\\n long long l = 1, r = h;\\n while (l < r) {\\n long long mid = (l + r) >> 1;\\n if (check(mid))\\n r = mid;\\n else\\n l = mid + 1;\\n }\\n printf(\\\"%lld\\\\n\\\", l);\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 solution for \\\"There is a chessboard of size n by n. The square in the i-th row from top and j-th column from the left is labelled (i,j).\\n\\nCurrently, Gregor has some pawns in the n-th row. There are also enemy pawns in the 1-st row. On one turn, Gregor moves one of his pawns. A pawn can move one square up (from (i,j) to (i-1,j)) if there is no pawn in the destination square. Additionally, a pawn can move one square diagonally up (from (i,j) to either (i-1,j-1) or (i-1,j+1)) if and only if there is an enemy pawn in that square. The enemy pawn is also removed.\\n\\nGregor wants to know what is the maximum number of his pawns that can reach row 1?\\n\\nNote that only Gregor takes turns in this game, and the enemy pawns never move. Also, when Gregor's pawn reaches row 1, it is stuck and cannot make any further moves.\\n\\nInput\\n\\nThe first line of the input contains one integer t (1≤ t≤ 2⋅ 10^4) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of three lines. The first line contains a single integer n (2≤ n≤ 2⋅{10}^{5}) — the size of the chessboard.\\n\\nThe second line consists of a string of binary digits of length n, where a 1 in the i-th position corresponds to an enemy pawn in the i-th cell from the left, and 0 corresponds to an empty cell.\\n\\nThe third line consists of a string of binary digits of length n, where a 1 in the i-th position corresponds to a Gregor's pawn in the i-th cell from the left, and 0 corresponds to an empty cell.\\n\\nIt is guaranteed that the sum of n across all test cases is less than 2⋅{10}^{5}.\\n\\nOutput\\n\\nFor each test case, print one integer: the maximum number of Gregor's pawns which can reach the 1-st row.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n000\\n111\\n4\\n1111\\n1111\\n3\\n010\\n010\\n5\\n11001\\n00000\\n\\n\\nOutput\\n\\n\\n3\\n4\\n0\\n0\\n\\nNote\\n\\nIn the first example, Gregor can simply advance all 3 of his pawns forward. Thus, the answer is 3.\\n\\nIn the second example, Gregor can guarantee that all 4 of his pawns reach the enemy row, by following the colored paths as demonstrated in the diagram below. Remember, only Gregor takes turns in...\\\":\",\"targets\":\"for _ in range(int(input())):\\n\\tn = int(input())\\n\\tY = list(input())\\n\\tX = list(input())\\n\\tcount = 0\\n\\tfor j in range(n):\\n\\t\\tif j == 0:\\n\\t\\t\\ta = None\\n\\t\\t\\tb = Y[0]\\n\\t\\t\\tc = Y[1]\\n\\t\\telif j == n-1:\\n\\t\\t\\ta = Y[n-2]\\n\\t\\t\\tb = Y[n-1]\\n\\t\\t\\tc = None\\n\\t\\telse:\\n\\t\\t\\ta = Y[j-1]\\n\\t\\t\\tb = Y[j]\\n\\t\\t\\tc = Y[j+1]\\n\\t\\tif X[j] == '1':\\n\\t\\t\\tif b == '0':\\n\\t\\t\\t\\tcount += 1\\n\\t\\t\\telif b == '1':\\n\\t\\t\\t\\tif a == '1':\\n\\t\\t\\t\\t\\tcount += 1\\n\\t\\t\\t\\t\\tY[j-1] = '0'\\n\\t\\t\\t\\telif c == '1':\\n\\t\\t\\t\\t\\tcount += 1\\n\\t\\t\\t\\t\\tY[j+1] = '0'\\n\\tprint(count)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alice lives on a flat planet that can be modeled as a square grid of size n × n, with rows and columns enumerated from 1 to n. We represent the cell at the intersection of row r and column c with ordered pair (r, c). Each cell in the grid is either land or water.\\n\\n An example planet with n = 5. It also appears in the first sample test.\\n\\nAlice resides in land cell (r_1, c_1). She wishes to travel to land cell (r_2, c_2). At any moment, she may move to one of the cells adjacent to where she is—in one of the four directions (i.e., up, down, left, or right).\\n\\nUnfortunately, Alice cannot swim, and there is no viable transportation means other than by foot (i.e., she can walk only on land). As a result, Alice's trip may be impossible.\\n\\nTo help Alice, you plan to create at most one tunnel between some two land cells. The tunnel will allow Alice to freely travel between the two endpoints. Indeed, creating a tunnel is a lot of effort: the cost of creating a tunnel between cells (r_s, c_s) and (r_t, c_t) is (r_s-r_t)^2 + (c_s-c_t)^2.\\n\\nFor now, your task is to find the minimum possible cost of creating at most one tunnel so that Alice could travel from (r_1, c_1) to (r_2, c_2). If no tunnel needs to be created, the cost is 0.\\n\\nInput\\n\\nThe first line contains one integer n (1 ≤ n ≤ 50) — the width of the square grid.\\n\\nThe second line contains two space-separated integers r_1 and c_1 (1 ≤ r_1, c_1 ≤ n) — denoting the cell where Alice resides.\\n\\nThe third line contains two space-separated integers r_2 and c_2 (1 ≤ r_2, c_2 ≤ n) — denoting the cell to which Alice wishes to travel.\\n\\nEach of the following n lines contains a string of n characters. The j-th character of the i-th such line (1 ≤ i, j ≤ n) is 0 if (i, j) is land or 1 if (i, j) is water.\\n\\nIt is guaranteed that (r_1, c_1) and (r_2, c_2) are land.\\n\\nOutput\\n\\nPrint an integer that is the minimum possible cost of creating at most one tunnel so that Alice could travel from (r_1, c_1) to (r_2, c_2).\\n\\nExamples\\n\\nInput\\n\\n\\n5\\n1 1\\n5...\\n\\/\\/pac\",\"targets\":\"kage CodeForces.C542;\\n\\n\\nimport javafx.util.Pair;\\n\\nimport java.io.OutputStream;\\nimport java.io.IOException;\\nimport java.io.InputStream;\\nimport java.io.PrintWriter;\\nimport java.util.*;\\nimport java.io.IOException;\\nimport java.io.BufferedReader;\\nimport java.io.InputStreamReader;\\nimport java.io.InputStream;\\n\\n\\/**\\n * Built using CHelper plug-in\\n * Actual solution is at the top\\n *\\/\\npublic class C {\\n public static void main(String[] args) {\\n InputStream inputStream = System.in;\\n OutputStream outputStream = System.out;\\n InputReader in = new InputReader(inputStream);\\n PrintWriter out = new PrintWriter(outputStream);\\n TaskE solver = new TaskE();\\n solver.solve(1, in, out);\\n out.close();\\n }\\n\\n static int[][] a;\\n static int n;\\n static PrintWriter out1;\\n\\n static boolean isvalid(int x, int y) {\\n if (x>=0 && x=0 && y> getneighbours(int x, int y) {\\n int[] nx = new int[]{-1,1,0,0};\\n int[] ny = new int[]{0,0,-1,1};\\n List> ans = new ArrayList<>();\\n for (int i=0;i<4;i++) {\\n if (isvalid(x+nx[i], y+ny[i])) {\\n ans.add(new Pair<>(x+nx[i], y+ny[i]));\\n }\\n }\\n return ans;\\n }\\n\\n static void dfs(int x, int y, int id) {\\n if (a[x][y] !=0)\\n return;\\n a[x][y] = id;\\n List> ans = getneighbours(x,y);\\n for (Pair te : ans) {\\n dfs(te.getKey(), te.getValue(), id);\\n }\\n }\\n\\n static class TaskE {\\n public void solve(int testNumber, InputReader in, PrintWriter out) {\\n n = in.nextInt();\\n int r1 = in.nextInt(),c1 = in.nextInt(), r2 = in.nextInt(),c2 = in.nextInt();\\n a = new int[n][n];\\n out1=out;\\n\\n\\n for (int i=0;i b)\\n a = (a + b) - (b = a);\\n if (a == 0L)\\n return b;\\n return gcd(b % a, a);\\n }\\n\\n public static ArrayList findDiv(int N) {\\n \\/\\/gens all divisors of N\\n ArrayList ls1 = new ArrayList();\\n ArrayList ls2 = new ArrayList();\\n for (int i = 1; i <= (int) (Math.sqrt(N) + 0.00000001); i++)\\n if (N % i == 0) {\\n ls1.add(i);\\n ls2.add(N \\/ i);\\n }\\n Collections.reverse(ls2);\\n for (int b : ls2)\\n if (b != ls1.get(ls1.size() - 1))\\n ls1.add(b);\\n return ls1;\\n }\\n\\n public static void sort(int[] arr) {\\n \\/\\/because Arrays.sort() uses quicksort which is dumb\\n \\/\\/Collections.sort() uses merge sort\\n ArrayList ls = new ArrayList();\\n for (int x : arr)\\n ls.add(x);\\n Collections.sort(ls);\\n\\n for (int i = 0; i < arr.length; i++)\\n arr[i] = ls.get(i);\\n }\\n\\n public static long power(long x, long y, long p) {\\n \\/\\/0^0 = 1\\n \\/\\/Modular Exponentiation (Power in Modular Arithmetic)\\n \\/\\/ O(logy)\\n long res = 1L;\\n x = x % p;\\n while (y > 0) {\\n if ((y & 1) == 1)\\n res = (res * x) % p;\\n y >>= 1;\\n x = (x * x) % p;\\n }\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Vlad has n friends, for each of whom he wants to buy one gift for the New Year.\\n\\nThere are m shops in the city, in each of which he can buy a gift for any of his friends. If the j-th friend (1 ≤ j ≤ n) receives a gift bought in the shop with the number i (1 ≤ i ≤ m), then the friend receives p_{ij} units of joy. The rectangular table p_{ij} is given in the input.\\n\\nVlad has time to visit at most n-1 shops (where n is the number of friends). He chooses which shops he will visit and for which friends he will buy gifts in each of them.\\n\\nLet the j-th friend receive a_j units of joy from Vlad's gift. Let's find the value α=min\\\\\\\\{a_1, a_2, ..., a_n\\\\}. Vlad's goal is to buy gifts so that the value of α is as large as possible. In other words, Vlad wants to maximize the minimum of the joys of his friends.\\n\\nFor example, let m = 2, n = 2. Let the joy from the gifts that we can buy in the first shop: p_{11} = 1, p_{12}=2, in the second shop: p_{21} = 3, p_{22}=4.\\n\\nThen it is enough for Vlad to go only to the second shop and buy a gift for the first friend, bringing joy 3, and for the second — bringing joy 4. In this case, the value α will be equal to min\\\\{3, 4\\\\} = 3\\n\\nHelp Vlad choose gifts for his friends so that the value of α is as high as possible. Please note that each friend must receive one gift. Vlad can visit at most n-1 shops (where n is the number of friends). In the shop, he can buy any number of gifts.\\n\\nInput\\n\\nThe first line of the input contains an integer t (1 ≤ t ≤ 10^4) — the number of test cases in the input.\\n\\nAn empty line is written before each test case. Then there is a line containing integers m and n (2 ≤ n, 2 ≤ n ⋅ m ≤ 10^5) separated by a space — the number of shops and the number of friends, where n ⋅ m is the product of n and m.\\n\\nThen m lines follow, each containing n numbers. The number in the i-th row of the j-th column p_{ij} (1 ≤ p_{ij} ≤ 10^9) is the joy of the product intended for friend number j in shop number i.\\n\\nIt is guaranteed that the sum of the values n ⋅ m over all test cases in...\\nSolve the task in PYTHON3.\",\"targets\":\"def solve(mid,p,m,n):\\n for i in range(n):\\n flag=1\\n for j in range(m):\\n if p[j][i]>=mid:\\n flag=0\\n break\\n if flag==1:\\n return False\\n for i in range(m):\\n count=0\\n for j in range(n):\\n if p[i][j]>=mid:\\n count+=1\\n if count>=2:\\n return True\\n return False\\nt=int(input())\\nfor _ in range(t):\\n input()\\n m,n=map(int,input().split())\\n p=[]\\n mini=10**8\\n maxi=0\\n mid=(mini+maxi)\\/\\/2\\n for i in range(m):\\n arr=list(map(int,input().split()))\\n mini=min(mini,min(arr))\\n maxi=max(maxi,max(arr))\\n p.append(arr)\\n ans=0\\n while(mini<=maxi):\\n mid=(mini+maxi)\\/\\/2\\n if(solve(mid,p,m,n)):\\n mini=mid+1\\n ans=max(ans,mid)\\n else:\\n maxi=mid-1\\n print(ans)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"You are given an array a of length n.\\n\\nLet's define the eversion operation. Let x = a_n. Then array a is partitioned into two parts: left and right. The left part contains the elements of a that are not greater than x (≤ x). The right part contains the elements of a that are strictly greater than x (> x). The order of elements in each part is kept the same as before the operation, i. e. the partition is stable. Then the array is replaced with the concatenation of the left and the right parts.\\n\\nFor example, if the array a is [2, 4, 1, 5, 3], the eversion goes like this: [2, 4, 1, 5, 3] → [2, 1, 3], [4, 5] → [2, 1, 3, 4, 5].\\n\\nWe start with the array a and perform eversions on this array. We can prove that after several eversions the array a stops changing. Output the minimum number k such that the array stops changing after k eversions.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 100). Description of the test cases follows.\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 2 ⋅ 10^5).\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9).\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case print a single integer k — the number of eversions after which the array stops changing.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n5\\n2 4 1 5 3\\n5\\n5 3 2 4 1\\n4\\n1 1 1 1\\n\\n\\nOutput\\n\\n\\n1\\n2\\n0\\n\\nNote\\n\\nConsider the fist example.\\n\\n * The first eversion: a = [1, 4, 2, 5, 3], x = 3. [2, 4, 1, 5, 3] → [2, 1, 3], [4, 5] → [2, 1, 3, 4, 5]. \\n * The second and following eversions: a = [2, 1, 3, 4, 5], x = 5. [2, 1, 3, 4, 5] → [2, 1, 3, 4, 5], [] → [2, 1, 3, 4, 5]. This eversion does not change the array, so the answer is 1. \\n\\n\\n\\nConsider the second example. \\n\\n * The first eversion: a = [5, 3, 2, 4, 1], x = 1. [5, 3, 2, 4, 1] → [1], [5, 3, 2, 4] → [1, 5, 3, 2, 4]. \\n * The second eversion: a = [1, 5, 3, 2, 4], x = 4. [1, 5, 3, 2, 4] → [1, 3, 2, 4], [5] → [1, 3, 2, 4, 5]. \\n * The third and following eversions: a = [1, 3, 2, 4,...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nconst long long MOD = 1e9 + 7;\\nvoid _print(long long t) { cerr << t; }\\nvoid _print(int t) { cerr << t; }\\nvoid _print(string t) { cerr << t; }\\nvoid _print(char t) { cerr << t; }\\nvoid _print(double t) { cerr << t; }\\ntemplate \\nvoid _print(pair p);\\ntemplate \\nvoid _print(vector v);\\ntemplate \\nvoid _print(set v);\\ntemplate \\nvoid _print(map v);\\ntemplate \\nvoid _print(multiset v);\\ntemplate \\nvoid _print(pair p) {\\n cerr << \\\"{\\\";\\n _print(p.ff);\\n cerr << \\\",\\\";\\n _print(p.ss);\\n cerr << \\\"}\\\";\\n}\\ntemplate \\nvoid _print(vector v) {\\n cerr << \\\"[ \\\";\\n for (T i : v) {\\n _print(i);\\n cerr << \\\" \\\";\\n }\\n cerr << \\\"]\\\";\\n}\\ntemplate \\nvoid _print(set v) {\\n cerr << \\\"[ \\\";\\n for (T i : v) {\\n _print(i);\\n cerr << \\\" \\\";\\n }\\n cerr << \\\"]\\\";\\n}\\ntemplate \\nvoid _print(multiset v) {\\n cerr << \\\"[ \\\";\\n for (T i : v) {\\n _print(i);\\n cerr << \\\" \\\";\\n }\\n cerr << \\\"]\\\";\\n}\\ntemplate \\nvoid _print(map v) {\\n cerr << \\\"[ \\\";\\n for (auto i : v) {\\n _print(i);\\n cerr << \\\" \\\";\\n }\\n cerr << \\\"]\\\";\\n}\\nlong long mod_add(long long a, long long b, long long m) {\\n a = a % m;\\n b = b % m;\\n return (((a + b) % m) + m) % m;\\n}\\nlong long mod_mul(long long a, long long b, long long m) {\\n a = a % m;\\n b = b % m;\\n return (((a * b) % m) + m) % m;\\n}\\nlong long mod_sub(long long a, long long b, long long m) {\\n a = a % m;\\n b = b % m;\\n return (((a - b) % m) + m) % m;\\n}\\nbool IsPrime(long long number) {\\n if (number <= 1) return false;\\n if (number == 2 || number == 3) return true;\\n if (number % 2 == 0 || number % 3 == 0) return false;\\n for (long long i = 5; i * i <= number; i += 2) {\\n if (number % i == 0) return false;\\n }\\n return true;\\n}\\nvoid solve() {\\n long long n;\\n cin >> n;\\n vector seq, arr;\\n long long elem = -1;\\n for (long long i = 0; i < n; i++) {\\n long long m;\\n cin >> m;\\n seq.push_back(m);\\n if (i == 0)\\n elem = m;\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"In a certain video game, the player controls a hero characterized by a single integer value: power. The hero will have to beat monsters that are also characterized by a single integer value: armor.\\n\\nOn the current level, the hero is facing n caves. To pass the level, the hero must enter all the caves in some order, each cave exactly once, and exit every cave safe and sound. When the hero enters cave i, he will have to fight k_i monsters in a row: first a monster with armor a_{i, 1}, then a monster with armor a_{i, 2} and so on, finally, a monster with armor a_{i, k_i}.\\n\\nThe hero can beat a monster if and only if the hero's power is strictly greater than the monster's armor. If the hero can't beat the monster he's fighting, the game ends and the player loses. Note that once the hero enters a cave, he can't exit it before he fights all the monsters in it, strictly in the given order.\\n\\nEach time the hero beats a monster, the hero's power increases by 1.\\n\\nFind the smallest possible power the hero must start the level with to be able to enter all the caves in some order and beat all the monsters.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^5). Description of the test cases follows.\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 10^5) — the number of caves.\\n\\nThe i-th of the next n lines contains an integer k_i (1 ≤ k_i ≤ 10^5) — the number of monsters in the i-th cave, followed by k_i integers a_{i, 1}, a_{i, 2}, …, a_{i, k_i} (1 ≤ a_{i, j} ≤ 10^9) — armor levels of the monsters in cave i in order the hero has to fight them.\\n\\nIt is guaranteed that the sum of k_i over all test cases does not exceed 10^5.\\n\\nOutput\\n\\nFor each test case print a single integer — the smallest possible power the hero must start the level with to be able to enter all the caves in some order and beat all the monsters.\\n\\nExample\\n\\nInput\\n\\n\\n2\\n1\\n1 42\\n2\\n3 10 15 8\\n2 12 11\\n\\n\\nOutput\\n\\n\\n43\\n13\\n\\nNote\\n\\nIn the first test case, the hero has to beat a single monster with...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nlong long MOD = 1e9 + 7;\\nvoid solve() {\\n long long n;\\n cin >> n;\\n vector>> A(n);\\n auto find_ans = [&](long long MID) {\\n bool ok = 1;\\n for (long long i = 0; i < n; i++) {\\n if (MID <= A[i].first) {\\n ok = 0;\\n break;\\n }\\n MID += (A[i].second.size());\\n }\\n if (!ok) return 0LL;\\n return MID;\\n };\\n for (long long i = 0; i < n; i++) {\\n long long z;\\n cin >> z;\\n for (long long j = 0; j < z; j++) {\\n long long y;\\n cin >> y;\\n A[i].second.push_back(y - j);\\n }\\n A[i].first = *max_element((A[i].second).begin(), (A[i].second).end());\\n }\\n sort((A).begin(), (A).end());\\n long long left = 0, right = 1e18, myans = 0;\\n while (left <= right) {\\n long long m = left + (right - left) \\/ 2;\\n if (find_ans(m)) {\\n myans = m;\\n right = m - 1;\\n } else\\n left = m + 1;\\n }\\n cout << myans << \\\"\\\\n\\\";\\n}\\nsigned main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n long long t = 1;\\n cin >> t;\\n while (t--) {\\n solve();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Let's call the string beautiful if it does not contain a substring of length at least 2, which is a palindrome. Recall that a palindrome is a string that reads the same way from the first character to the last and from the last character to the first. For example, the strings a, bab, acca, bcabcbacb are palindromes, but the strings ab, abbbaa, cccb are not.\\n\\nLet's define cost of a string as the minimum number of operations so that the string becomes beautiful, if in one operation it is allowed to change any character of the string to one of the first 3 letters of the Latin alphabet (in lowercase).\\n\\nYou are given a string s of length n, each character of the string is one of the first 3 letters of the Latin alphabet (in lowercase).\\n\\nYou have to answer m queries — calculate the cost of the substring of the string s from l_i-th to r_i-th position, inclusive.\\n\\nInput\\n\\nThe first line contains two integers n and m (1 ≤ n, m ≤ 2 ⋅ 10^5) — the length of the string s and the number of queries.\\n\\nThe second line contains the string s, it consists of n characters, each character one of the first 3 Latin letters.\\n\\nThe following m lines contain two integers l_i and r_i (1 ≤ l_i ≤ r_i ≤ n) — parameters of the i-th query.\\n\\nOutput\\n\\nFor each query, print a single integer — the cost of the substring of the string s from l_i-th to r_i-th position, inclusive.\\n\\nExample\\n\\nInput\\n\\n\\n5 4\\nbaacb\\n1 3\\n1 5\\n4 5\\n2 3\\n\\n\\nOutput\\n\\n\\n1\\n2\\n0\\n1\\n\\nNote\\n\\nConsider the queries of the example test.\\n\\n * in the first query, the substring is baa, which can be changed to bac in one operation; \\n * in the second query, the substring is baacb, which can be changed to cbacb in two operations; \\n * in the third query, the substring is cb, which can be left unchanged; \\n * in the fourth query, the substring is aa, which can be changed to ba in one operation. \\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"import sys\\ninput = lambda : sys.stdin.readline().rstrip()\\n\\nsys.setrecursionlimit(2*10**5+10)\\nwrite = lambda x: sys.stdout.write(x+\\\"\\\\n\\\")\\ndebug = lambda x: sys.stderr.write(x+\\\"\\\\n\\\")\\nwritef = lambda x: print(\\\"{:.12f}\\\".format(x))\\n\\n\\n\\nn,m = list(map(int, input().split()))\\nvs = [[0]*(n) for _ in range(3)]\\ni = 0\\nfor c in input():\\n v = ord(c) - ord(\\\"a\\\")\\n for vv in range(3):\\n if vv==v:\\n continue\\n vs[vv][i] += 1\\n i += 1\\nfor j in range(3):\\n for i in range(3,n):\\n vs[j][i] = vs[j][i-3] + vs[j][i]\\nans = []\\ninf = 10**12\\ndef _sub(l,r,v):\\n if l>r:\\n return 0\\n li = vs[v]\\n rr = l + ((r-l)\\/\\/3) * 3\\n return li[rr] - (li[l-3] if l>=3 else 0)\\ndef sub(l,r):\\n res = inf\\n for v0 in range(3):\\n for v1 in range(3):\\n if v0==v1:\\n continue\\n v2 = 3 ^ v0 ^ v1\\n res = min(res, _sub(l,r,v0)+_sub(l+1,r,v1)+_sub(l+2,r,v2))\\n return res\\nfor i in range(m):\\n l,r = map(int, input().split())\\n l -= 1\\n r -= 1\\n val = sub(l,r)\\n ans.append(val)\\nwrite(\\\"\\\\n\\\".join(map(str, ans)))\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given strings S and T, consisting of lowercase English letters. It is guaranteed that T is a permutation of the string abc. \\n\\nFind string S', the lexicographically smallest permutation of S such that T is not a subsequence of S'.\\n\\nString a is a permutation of string b if the number of occurrences of each distinct character is the same in both strings.\\n\\nA string a is a subsequence of a string b if a can be obtained from b by deletion of several (possibly, zero or all) elements.\\n\\nA string a is lexicographically smaller than a string b if and only if one of the following holds:\\n\\n * a is a prefix of b, but a ≠ b;\\n * in the first position where a and b differ, the string a has a letter that appears earlier in the alphabet than the corresponding letter in b.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases. Description of the test cases follows.\\n\\nThe first line of each test case contains a string S (1 ≤ |S| ≤ 100), consisting of lowercase English letters.\\n\\nThe second line of each test case contains a string T that is a permutation of the string abc. (Hence, |T| = 3).\\n\\nNote that there is no limit on the sum of |S| across all test cases.\\n\\nOutput\\n\\nFor each test case, output a single string S', the lexicographically smallest permutation of S such that T is not a subsequence of S'.\\n\\nExample\\n\\nInput\\n\\n\\n7\\nabacaba\\nabc\\ncccba\\nacb\\ndbsic\\nbac\\nabracadabra\\nabc\\ndddddddddddd\\ncba\\nbbc\\nabc\\nac\\nabc\\n\\n\\nOutput\\n\\n\\naaaacbb\\nabccc\\nbcdis\\naaaaacbbdrr\\ndddddddddddd\\nbbc\\nac\\n\\nNote\\n\\nIn the first test case, both aaaabbc and aaaabcb are lexicographically smaller than aaaacbb, but they contain abc as a subsequence.\\n\\nIn the second test case, abccc is the smallest permutation of cccba and does not contain acb as a subsequence.\\n\\nIn the third test case, bcdis is the smallest permutation of dbsic and does not contain bac as a subsequence.\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int t;\\n cin >> t;\\n string s, tt;\\n int a, b, c, k;\\n string result;\\n while (t--) {\\n cin >> s >> tt;\\n sort(s.begin(), s.end());\\n if (tt == \\\"abc\\\") {\\n for (int i = 0; i < s.length(); i++) {\\n if (s[i] == 'a') continue;\\n if (i == 0) break;\\n if (s[i] == 'b') {\\n k = i;\\n for (int j = i + 1; j < s.length(); j++)\\n if (s[j] == 'c') {\\n swap(s[k], s[j]);\\n k++;\\n }\\n break;\\n }\\n }\\n }\\n cout << s << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Allen wants to enter a fan zone that occupies a round square and has n entrances.\\n\\nThere already is a queue of a_i people in front of the i-th entrance. Each entrance allows one person from its queue to enter the fan zone in one minute.\\n\\nAllen uses the following strategy to enter the fan zone: \\n\\n * Initially he stands in the end of the queue in front of the first entrance. \\n * Each minute, if he is not allowed into the fan zone during the minute (meaning he is not the first in the queue), he leaves the current queue and stands in the end of the queue of the next entrance (or the first entrance if he leaves the last entrance). \\n\\n\\n\\nDetermine the entrance through which Allen will finally enter the fan zone.\\n\\nInput\\n\\nThe first line contains a single integer n (2 ≤ n ≤ 10^5) — the number of entrances.\\n\\nThe second line contains n integers a_1, a_2, …, a_n (0 ≤ a_i ≤ 10^9) — the number of people in queues. These numbers do not include Allen.\\n\\nOutput\\n\\nPrint a single integer — the number of entrance that Allen will use.\\n\\nExamples\\n\\nInput\\n\\n4\\n2 3 2 0\\n\\n\\nOutput\\n\\n3\\n\\n\\nInput\\n\\n2\\n10 10\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\n6\\n5 2 6 5 7 4\\n\\n\\nOutput\\n\\n6\\n\\nNote\\n\\nIn the first example the number of people (not including Allen) changes as follows: [2, 3, 2, 0] → [1, 2, 1, 0] → [0, 1, 0, 0]. The number in bold is the queue Alles stands in. We see that he will enter the fan zone through the third entrance.\\n\\nIn the second example the number of people (not including Allen) changes as follows: [10, 10] → [9, 9] → [8, 8] → [7, 7] → [6, 6] → \\\\\\\\\\\\ [5, 5] → [4, 4] → [3, 3] → [2, 2] → [1, 1] → [0, 0].\\n\\nIn the third example the number of people (not including Allen) changes as follows: [5, 2, 6, 5, 7, 4] → [4, 1, 5, 4, 6, 3] → [3, 0, 4, 3, 5, 2] → \\\\\\\\\\\\ [2, 0, 3, 2, 4, 1] → [1, 0, 2, 1, 3, 0] → [0, 0, 1, 0, 2, 0].\\nUsing java can you solve the prior task?\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\n\\n\\n\\/**\\n *\\n * @author DELL\\n *\\/\\npublic class JavaApplication99 {\\n\\n \\/**\\n * @param args the command line arguments\\n *\\/\\n public static void main(String[] args) throws IOException {\\n \\/\\/ TODO code application logic here\\n \\/*\\n inputCopy\\n4\\n2 3 2 0\\noutputCopy\\n3\\ninputCopy\\n2\\n10 10\\noutputCopy\\n1\\ninputCopy\\n6\\n5 2 6 5 7 4\\noutputCopy\\n6\\n *\\/\\n BufferedReader br=new BufferedReader(new InputStreamReader(System.in));\\n StringTokenizer st=new StringTokenizer(br.readLine());\\n int n=Integer.parseInt(st.nextToken());\\n int [] arr=new int[n];\\n st=new StringTokenizer(br.readLine());\\n for(int ni=0;ni The picture corresponds to the first example.\\n\\nThe following letters are vowels: 'A', 'E', 'I', 'O', 'U' and 'Y'.\\n\\nInput\\n\\nThe first line contains non-empty string consisting of capital English letters. It is guaranteed that the length of the string does not exceed 100. \\n\\nOutput\\n\\nPrint single integer a — the minimum jump ability of the Grasshopper (in the number of symbols) that is needed to overcome the given string, jumping only on vowels.\\n\\nExamples\\n\\nInput\\n\\nABABBBACFEYUKOTT\\n\\n\\nOutput\\n\\n4\\n\\nInput\\n\\nAAA\\n\\n\\nOutput\\n\\n1\\\":\",\"targets\":\"#include \\nusing namespace std;\\nbool bol[305];\\nint main() {\\n bol['A'] = bol['E'] = bol['I'] = bol['O'] = bol['U'] = bol['Y'] = 1;\\n string s;\\n getline(cin, s);\\n s += 'A';\\n int pos = -1, ans = 0;\\n for (int i = 0; i < s.size(); i++)\\n if (bol[s[i]]) {\\n ans = max(ans, i - pos);\\n pos = i;\\n }\\n printf(\\\"%d\\\\n\\\", ans);\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given n numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — to check his answers, he needs a program that among the given n numbers finds one that is different in evenness.\\n\\nInput\\n\\nThe first line contains integer n (3 ≤ n ≤ 100) — amount of numbers in the task. The second line contains n space-separated natural numbers, not exceeding 100. It is guaranteed, that exactly one of these numbers differs from the others in evenness.\\n\\nOutput\\n\\nOutput index of number that differs from the others in evenness. Numbers are numbered from 1 in the input order.\\n\\nExamples\\n\\nInput\\n\\n5\\n2 4 7 8 10\\n\\n\\nOutput\\n\\n3\\n\\n\\nInput\\n\\n4\\n1 2 1 1\\n\\n\\nOutput\\n\\n2\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"n=int(input())\\ns=input().split()\\na=list(map(int,s))\\nk1=k2=0\\nfor i in range(0,n):\\n if a[i]%2==0:\\n k1=k1+1\\n else:\\n k2=k2+1\\nfor i in range(0,n):\\n if a[i]%2==0 and k2>k1:\\n print(i+1)\\n elif a[i]%2!=0 and k1>k2:\\n print(i+1)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A new e-mail service \\\"Berlandesk\\\" is going to be opened in Berland in the near future. The site administration wants to launch their project as soon as possible, that's why they ask you to help. You're suggested to implement the prototype of site registration system. The system should work on the following principle. \\n\\nEach time a new user wants to register, he sends to the system a request with his name. If such a name does not exist in the system database, it is inserted into the database, and the user gets the response OK, confirming the successful registration. If the name already exists in the system database, the system makes up a new user name, sends it to the user as a prompt and also inserts the prompt into the database. The new name is formed by the following rule. Numbers, starting with 1, are appended one after another to name (name1, name2, ...), among these numbers the least i is found so that namei does not yet exist in the database.\\n\\nInput\\n\\nThe first line contains number n (1 ≤ n ≤ 105). The following n lines contain the requests to the system. Each request is a non-empty line, and consists of not more than 32 characters, which are all lowercase Latin letters.\\n\\nOutput\\n\\nPrint n lines, which are system responses to the requests: OK in case of successful registration, or a prompt with a new name, if the requested name is already taken.\\n\\nExamples\\n\\nInput\\n\\n4\\nabacaba\\nacaba\\nabacaba\\nacab\\n\\n\\nOutput\\n\\nOK\\nOK\\nabacaba1\\nOK\\n\\n\\nInput\\n\\n6\\nfirst\\nfirst\\nsecond\\nsecond\\nthird\\nthird\\n\\n\\nOutput\\n\\nOK\\nfirst1\\nOK\\nsecond1\\nOK\\nthird1\\nSolve the task in PYTHON3.\",\"targets\":\"def res(a):\\n global dict\\n if a in dict:\\n dict[a] = dict[a] + 1\\n return a+str(dict[a])\\n else:\\n dict[a] = 0\\n return \\\"OK\\\"\\nn = int(input())\\ndict = {}\\nfor i in range(n):\\n a = input()\\n print(res(a))\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nThere are n heroes fighting in the arena. Initially, the i-th hero has a_i health points.\\n\\nThe fight in the arena takes place in several rounds. At the beginning of each round, each alive hero deals 1 damage to all other heroes. Hits of all heroes occur simultaneously. Heroes whose health is less than 1 at the end of the round are considered killed.\\n\\nIf exactly 1 hero remains alive after a certain round, then he is declared the winner. Otherwise, there is no winner.\\n\\nYour task is to calculate the number of ways to choose the initial health points for each hero a_i, where 1 ≤ a_i ≤ x, so that there is no winner of the fight. The number of ways can be very large, so print it modulo 998244353. Two ways are considered different if at least one hero has a different amount of health. For example, [1, 2, 1] and [2, 1, 1] are different.\\n\\nInput\\n\\nThe only line contains two integers n and x (2 ≤ n ≤ 500; 1 ≤ x ≤ 500).\\n\\nOutput\\n\\nPrint one integer — the number of ways to choose the initial health points for each hero a_i, where 1 ≤ a_i ≤ x, so that there is no winner of the fight, taken modulo 998244353. \\n\\nExamples\\n\\nInput\\n\\n\\n2 5\\n\\n\\nOutput\\n\\n\\n5\\n\\n\\nInput\\n\\n\\n3 3\\n\\n\\nOutput\\n\\n\\n15\\n\\n\\nInput\\n\\n\\n5 4\\n\\n\\nOutput\\n\\n\\n1024\\n\\n\\nInput\\n\\n\\n13 37\\n\\n\\nOutput\\n\\n\\n976890680\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\n\\npublic final class Main {\\n\\n static PrintWriter out = new PrintWriter(System.out);\\n static FastReader in = new FastReader();\\n static Pair[] moves = new Pair[]{new Pair(-1, 0), new Pair(0, 1), new Pair(1, 0), new Pair(0, -1)};\\n static int mod = (int) (1e9 + 7);\\n static int mod2 = 998244353;\\n\\n public static void main(String[] args) {\\n int tt = 1;\\n while (tt-- > 0) {\\n solve();\\n }\\n out.flush();\\n }\\n\\n public static void solve() {\\n int n = i();\\n int x = i();\\n if (n > x) {\\n out.println(pow(x, n, mod2));\\n } else {\\n initializeFactorial(n, mod2);\\n long[][] dp = new long[n + 1][x + 1];\\n long ans = pow(x, n, mod2);\\n ans -= dfs(dp, n, x);\\n if (ans < 0) {\\n ans += mod2;\\n }\\n out.println(ans);\\n }\\n\\n }\\n\\n private static long dfs(long[][] dp, int i, int j) {\\n if (dp[i][j] > 0) {\\n return dp[i][j];\\n }\\n \\n long x = 0L;\\n if (i == 1) {\\n x = j;\\n } else if (j == 1) {\\n x = 0;\\n } else if (i == 2) {\\n x = pow(j, 2, mod2) - j;\\n if (x < 0) {\\n x += mod2;\\n }\\n } else if (i > j) {\\n x = 0;\\n } else if (i == j) {\\n x = i * pow(i - 1, i - 1, mod2) % mod2;\\n } else {\\n for (int k = 1; k <= i; k++) {\\n long r = pow(i - 1, i - k, mod2);\\n r *= binomialCoefficient(i, k, mod2);\\n r %= mod2;\\n x += (dfs(dp, k, j - i + 1) * r) % mod2;\\n x %= mod2;\\n }\\n }\\n\\n dp[i][j] = x;\\n return x;\\n }\\n\\n\\n static long[] fac;\\n static long[] inv;\\n\\n static void initializeFactorial(int n, int mod) {\\n fac = new long[n + 1];\\n inv = new long[n + 1];\\n long[] v = new long[fac.length];\\n fac[0] = inv[0] = 1;\\n for (int i = 1;...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Cowboy Beblop is a funny little boy who likes sitting at his computer. He somehow obtained two elastic hoops in the shape of 2D polygons, which are not necessarily convex. Since there's no gravity on his spaceship, the hoops are standing still in the air. Since the hoops are very elastic, Cowboy Beblop can stretch, rotate, translate or shorten their edges as much as he wants.\\n\\nFor both hoops, you are given the number of their vertices, as well as the position of each vertex, defined by the X , Y and Z coordinates. The vertices are given in the order they're connected: the 1st vertex is connected to the 2nd, which is connected to the 3rd, etc., and the last vertex is connected to the first one. Two hoops are connected if it's impossible to pull them to infinity in different directions by manipulating their edges, without having their edges or vertices intersect at any point – just like when two links of a chain are connected. The polygons' edges do not intersect or overlap. \\n\\nTo make things easier, we say that two polygons are well-connected, if the edges of one polygon cross the area of the other polygon in two different directions (from the upper and lower sides of the plane defined by that polygon) a different number of times.\\n\\nCowboy Beblop is fascinated with the hoops he has obtained and he would like to know whether they are well-connected or not. Since he’s busy playing with his dog, Zwei, he’d like you to figure it out for him. He promised you some sweets if you help him! \\n\\nInput\\n\\nThe first line of input contains an integer n (3 ≤ n ≤ 100 000), which denotes the number of edges of the first polygon. The next N lines each contain the integers x, y and z ( - 1 000 000 ≤ x, y, z ≤ 1 000 000) — coordinates of the vertices, in the manner mentioned above. The next line contains an integer m (3 ≤ m ≤ 100 000) , denoting the number of edges of the second polygon, followed by m lines containing the coordinates of the second polygon’s vertices.\\n\\nIt is guaranteed that both polygons are simple (no...\\nSolve the task in CPP.\",\"targets\":\"#include \\n#pragma GCC optimize(\\\"O3\\\")\\n#pragma GCC target(\\\"sse4\\\")\\nusing namespace std;\\nconst double PI = acos(double(-1));\\nconst double INF = 1e10;\\nconst double EPS = 1e-8;\\ninline double sqr(double x) { return x * x; }\\nnamespace G3 {\\nstruct PT3 {\\n double x, y, z;\\n PT3() {}\\n PT3(double x, double y, double z) : x(x), y(y), z(z) {}\\n void in() { scanf(\\\"%lf%lf%lf\\\", &x, &y, &z); }\\n double len() { return sqrt(sqr(x) + sqr(y) + sqr(z)); }\\n};\\nbool operator<(const PT3& p1, const PT3& p2) {\\n if (fabs(p1.x - p2.x) > EPS) return p1.x < p2.x;\\n if (fabs(p1.y - p2.y) > EPS) return p1.y < p2.y;\\n return p1.z + EPS < p2.z;\\n}\\nbool operator==(const PT3& p1, const PT3& p2) {\\n return fabs(p1.x - p2.x) < EPS && fabs(p1.y - p2.y) < EPS &&\\n fabs(p1.z - p2.z) < EPS;\\n}\\nPT3 operator-(PT3 p) { return PT3(-p.x, -p.y, -p.z); }\\nPT3 operator+(PT3 p1, PT3 p2) {\\n return PT3(p1.x + p2.x, p1.y + p2.y, p1.z + p2.z);\\n}\\nPT3 operator-(PT3 p1, PT3 p2) {\\n return PT3(p1.x - p2.x, p1.y - p2.y, p1.z - p2.z);\\n}\\nPT3 operator*(PT3 p, double c) { return PT3(p.x * c, p.y * c, p.z * c); }\\nPT3 operator\\/(PT3 p, double c) { return PT3(p.x \\/ c, p.y \\/ c, p.z \\/ c); }\\ndouble dist(PT3 P) { return P.len(); }\\ndouble dis2(PT3 p1, PT3 p2) {\\n return sqr(p1.x - p2.x) + sqr(p1.y - p2.y) + sqr(p1.z - p2.z);\\n}\\ndouble dis(PT3 p1, PT3 p2) { return sqrt(dis2(p1, p2)); }\\nPT3 vect(PT3 p1, PT3 p2) {\\n return PT3(p1.y * p2.z - p2.y * p1.z, -(p1.x * p2.z - p2.x * p1.z),\\n p1.x * p2.y - p2.x * p1.y);\\n}\\ndouble scal(PT3 p1, PT3 p2) { return p1.x * p2.x + p1.y * p2.y + p1.z * p2.z; }\\nPT3 vect(PT3 p, PT3 p1, PT3 p2) { return vect(p1 - p, p2 - p); }\\ndouble scal(PT3 p, PT3 p1, PT3 p2) { return scal(p1 - p, p2 - p); }\\nPT3 normalize(PT3 a) { return a \\/ sqrt(a.x * a.x + a.y * a.y + a.z * a.z); }\\nPT3 norm(PT3 a, PT3 b, PT3 c) { return normalize(vect(b - a, c - a)); }\\nvoid GetEquation(PT3 A, PT3 B, PT3 C, double& a, double& b, double& c,\\n double& d) {\\n PT3 DIR = vect(B - A, C - A);\\n a = DIR.x, b = DIR.y, c = DIR.z;\\n d = -a * A.x - b *...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"For a permutation p of numbers 1 through n, we define a stair array a as follows: a_i is length of the longest segment of permutation which contains position i and is made of consecutive values in sorted order: [x, x+1, …, y-1, y] or [y, y-1, …, x+1, x] for some x ≤ y. For example, for permutation p = [4, 1, 2, 3, 7, 6, 5] we have a = [1, 3, 3, 3, 3, 3, 3]. \\n\\nYou are given the stair array a. Your task is to calculate the number of permutations which have stair array equal to a. Since the number can be big, compute it modulo 998 244 353. Note that this number can be equal to zero.\\n\\nInput\\n\\nThe first line of input contains integer n (1 ≤ n ≤ 10^5) — the length of a stair array a.\\n\\nThe second line of input contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ n).\\n\\nOutput\\n\\nPrint the number of permutations which have stair array equal to a. Since the number can be big, compute it modulo 998 244 353.\\n\\nExamples\\n\\nInput\\n\\n\\n6\\n3 3 3 1 1 1\\n\\n\\nOutput\\n\\n\\n6\\n\\n\\nInput\\n\\n\\n7\\n4 4 4 4 3 3 3\\n\\n\\nOutput\\n\\n\\n6\\n\\n\\nInput\\n\\n\\n1\\n1\\n\\n\\nOutput\\n\\n\\n1\\n\\n\\nInput\\n\\n\\n8\\n2 2 2 2 2 2 1 1\\n\\n\\nOutput\\n\\n\\n370\\n\\n\\nInput\\n\\n\\n4\\n3 2 3 1\\n\\n\\nOutput\\n\\n\\n0\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\ntemplate \\nstruct Mint {\\n static const int mod = MOD;\\n static constexpr Mint rt() { return RT; }\\n int v;\\n explicit operator int() const { return v; }\\n Mint() { v = 0; }\\n Mint(long long _v) {\\n v = int((-MOD < _v && _v < MOD) ? _v : _v % MOD);\\n if (v < 0) v += MOD;\\n }\\n friend bool operator==(const Mint& a, const Mint& b) { return a.v == b.v; }\\n friend bool operator!=(const Mint& a, const Mint& b) { return !(a == b); }\\n friend bool operator<(const Mint& a, const Mint& b) { return a.v < b.v; }\\n friend bool operator>(const Mint& a, const Mint& b) { return a.v > b.v; }\\n friend bool operator<=(const Mint& a, const Mint& b) { return a.v <= b.v; }\\n friend bool operator>=(const Mint& a, const Mint& b) { return a.v >= b.v; }\\n friend istream& operator>>(istream& in, Mint& a) {\\n long long x;\\n cin >> x;\\n a = Mint(x);\\n return in;\\n }\\n friend ostream& operator<<(ostream& os, const Mint& a) { return os << a.v; }\\n Mint& operator+=(const Mint& m) {\\n if ((v += m.v) >= MOD) v -= MOD;\\n return *this;\\n }\\n Mint& operator-=(const Mint& m) {\\n if ((v -= m.v) < 0) v += MOD;\\n return *this;\\n }\\n Mint& operator*=(const Mint& m) {\\n v = (long long)v * m.v % MOD;\\n return *this;\\n }\\n Mint& operator\\/=(const Mint& m) { return (*this) *= inv(m); }\\n friend Mint pow(Mint a, long long p) {\\n Mint ans = 1;\\n assert(p >= 0);\\n for (; p; p \\/= 2, a *= a)\\n if (p & 1) ans *= a;\\n return ans;\\n }\\n friend Mint inv(const Mint& a) {\\n assert(a.v != 0);\\n return pow(a, MOD - 2);\\n }\\n Mint operator-() const { return Mint(-v); }\\n Mint& operator++() { return *this += 1; }\\n Mint& operator--() { return *this -= 1; }\\n friend Mint operator+(Mint a, const Mint& b) { return a += b; }\\n friend Mint operator-(Mint a, const Mint& b) { return a -= b; }\\n friend Mint operator*(Mint a, const Mint& b) { return a *= b; }\\n friend Mint operator\\/(Mint a, const Mint& b) { return a \\/= b; }\\n};\\nnamespace FFT {\\ntemplate \\nvoid...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A string is called beautiful if no two consecutive characters are equal. For example, \\\"ababcb\\\", \\\"a\\\" and \\\"abab\\\" are beautiful strings, while \\\"aaaaaa\\\", \\\"abaa\\\" and \\\"bb\\\" are not.\\n\\nAhcl wants to construct a beautiful string. He has a string s, consisting of only characters 'a', 'b', 'c' and '?'. Ahcl needs to replace each character '?' with one of the three characters 'a', 'b' or 'c', such that the resulting string is beautiful. Please help him!\\n\\nMore formally, after replacing all characters '?', the condition s_i ≠ s_{i+1} should be satisfied for all 1 ≤ i ≤ |s| - 1, where |s| is the length of the string s.\\n\\nInput\\n\\nThe first line contains positive integer t (1 ≤ t ≤ 1000) — the number of test cases. Next t lines contain the descriptions of test cases.\\n\\nEach line contains a non-empty string s consisting of only characters 'a', 'b', 'c' and '?'. \\n\\nIt is guaranteed that in each test case a string s has at least one character '?'. The sum of lengths of strings s in all test cases does not exceed 10^5.\\n\\nOutput\\n\\nFor each test case given in the input print the answer in the following format:\\n\\n * If it is impossible to create a beautiful string, print \\\"-1\\\" (without quotes); \\n * Otherwise, print the resulting beautiful string after replacing all '?' characters. If there are multiple answers, you can print any of them. \\n\\nExample\\n\\nInput\\n\\n\\n3\\na???cb\\na??bbc\\na?b?c\\n\\n\\nOutput\\n\\n\\nababcb\\n-1\\nacbac\\n\\nNote\\n\\nIn the first test case, all possible correct answers are \\\"ababcb\\\", \\\"abcacb\\\", \\\"abcbcb\\\", \\\"acabcb\\\" and \\\"acbacb\\\". The two answers \\\"abcbab\\\" and \\\"abaabc\\\" are incorrect, because you can replace only '?' characters and the resulting string must be beautiful.\\n\\nIn the second test case, it is impossible to create a beautiful string, because the 4-th and 5-th characters will be always equal.\\n\\nIn the third test case, the only answer is \\\"acbac\\\".\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\n#pragma GCC optimize(\\\"Ofast\\\")\\n#pragma GCC optimize(\\\"unroll-loops\\\")\\nconst long long int mod = 1000000007;\\nconst long long int inf = 0x3f3f3f3f3f3f3f3fLL;\\nconst double eps = 1e-9;\\nconst double PI = acos(-1);\\nlong long int i, j, k;\\nvoid solve(void);\\ninline bool equal(double a, double b) { return fabs(a - b) < eps; }\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(0);\\n cout << fixed << setprecision(10);\\n int t = 1;\\n cin >> t;\\n while (t--) solve();\\n ;\\n ;\\n return 0;\\n}\\nvoid solve() {\\n string s;\\n cin >> s;\\n if (s[0] == '?') {\\n if (s[1] == 'a')\\n s[0] = 'b';\\n else if (s[1] == 'b')\\n s[0] = 'c';\\n else if (s[1] == 'c')\\n s[0] = 'a';\\n else\\n s[0] = 'a';\\n }\\n for (i = 1; i <= (int)s.size() - 2; ++i)\\n if (s[i] == '?') {\\n if (s[i - 1] == 'a' &&\\n (s[i + 1] == 'b' || s[i + 1] == '?' || s[i + 1] == 'a'))\\n s[i] = 'c';\\n else if (s[i - 1] == 'a' &&\\n (s[i + 1] == 'c' || s[i + 1] == '?' || s[i + 1] == 'a'))\\n s[i] = 'b';\\n else if (s[i - 1] == 'b' &&\\n (s[i + 1] == 'b' || s[i + 1] == '?' || s[i + 1] == 'a'))\\n s[i] = 'c';\\n else if (s[i - 1] == 'b' &&\\n (s[i + 1] == 'b' || s[i + 1] == '?' || s[i + 1] == 'c'))\\n s[i] = 'a';\\n else if (s[i - 1] == 'c' &&\\n (s[i + 1] == 'b' || s[i + 1] == '?' || s[i + 1] == 'c'))\\n s[i] = 'a';\\n else if (s[i - 1] == 'c' &&\\n (s[i + 1] == 'a' || s[i + 1] == '?' || s[i + 1] == 'c'))\\n s[i] = 'b';\\n }\\n if (s[(int)s.size() - 1] == '?') {\\n if (s[(int)s.size() - 2] == 'a')\\n s[(int)s.size() - 1] = 'b';\\n else if (s[(int)s.size() - 2] == 'b')\\n s[(int)s.size() - 1] = 'c';\\n else if (s[(int)s.size() - 2] == 'c')\\n s[(int)s.size() - 1] = 'a';\\n else\\n s[(int)s.size() - 1] = 'a';\\n }\\n for (i = 0; i <= (int)s.size() - 2; ++i)\\n if (s[i] == s[i + 1]) {\\n cout << \\\"-1\\\\n\\\";\\n return;\\n }\\n cout << s << '\\\\n';\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nThis version of the problem differs from the next one only in the constraint on n.\\n\\nNote that the memory limit in this problem is lower than in others.\\n\\nYou have a vertical strip with n cells, numbered consecutively from 1 to n from top to bottom.\\n\\nYou also have a token that is initially placed in cell n. You will move the token up until it arrives at cell 1.\\n\\nLet the token be in cell x > 1 at some moment. One shift of the token can have either of the following kinds: \\n\\n * Subtraction: you choose an integer y between 1 and x-1, inclusive, and move the token from cell x to cell x - y. \\n * Floored division: you choose an integer z between 2 and x, inclusive, and move the token from cell x to cell ⌊ x\\/z ⌋ (x divided by z rounded down). \\n\\n\\n\\nFind the number of ways to move the token from cell n to cell 1 using one or more shifts, and print it modulo m. Note that if there are several ways to move the token from one cell to another in one shift, all these ways are considered distinct (check example explanation for a better understanding).\\n\\nInput\\n\\nThe only line contains two integers n and m (2 ≤ n ≤ 2 ⋅ 10^5; 10^8 < m < 10^9; m is a prime number) — the length of the strip and the modulo.\\n\\nOutput\\n\\nPrint the number of ways to move the token from cell n to cell 1, modulo m.\\n\\nExamples\\n\\nInput\\n\\n\\n3 998244353\\n\\n\\nOutput\\n\\n\\n5\\n\\n\\nInput\\n\\n\\n5 998244353\\n\\n\\nOutput\\n\\n\\n25\\n\\n\\nInput\\n\\n\\n42 998244353\\n\\n\\nOutput\\n\\n\\n793019428\\n\\nNote\\n\\nIn the first test, there are three ways to move the token from cell 3 to cell 1 in one shift: using subtraction of y = 2, or using division by z = 2 or z = 3.\\n\\nThere are also two ways to move the token from cell 3 to cell 1 via cell 2: first subtract y = 1, and then either subtract y = 1 again or divide by z = 2.\\n\\nTherefore, there are five ways in total.\",\"targets\":\"#include \\nusing namespace std;\\nlong long MOD;\\nlong long MAXN = 1e5 + 1;\\nlong long mod(long long a) { return ((a % MOD) + MOD) % MOD; }\\nlong long add(long long x, long long y) { return mod(mod(x) + mod(y)); }\\nlong long mul(long long x, long long y) { return mod(mod(x) * mod(y)); }\\nlong long power(long long x, long long y) {\\n if (y == 0) return 1;\\n long long ans = power(x, y \\/ 2);\\n ans = mul(ans, ans);\\n if (y % 2 == 1) {\\n ans = mul(ans, x);\\n }\\n return ans;\\n}\\nvoid solve() {\\n long long n, m;\\n cin >> n >> m;\\n vector dp(n + 1);\\n long long sum = 1;\\n dp[1] = 1;\\n for (long long i = 2; i <= n; i++) {\\n dp[i] = sum;\\n for (long long j = 1; j * j <= i; j++) {\\n dp[i] += (dp[j] * (i \\/ j - i \\/ (j + 1))) % m;\\n dp[i] %= m;\\n if ((not(j == i \\/ j)) && j > 1) {\\n dp[i] += dp[i \\/ j];\\n dp[i] %= m;\\n }\\n }\\n sum += dp[i];\\n sum %= m;\\n }\\n cout << dp[n] << endl;\\n}\\nint32_t main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n long long t = 1;\\n while (t--) {\\n solve();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"\\n\\nWilliam is not only interested in trading but also in betting on sports matches. n teams participate in each match. Each team is characterized by strength a_i. Each two teams i < j play with each other exactly once. Team i wins with probability (a_i)\\/(a_i + a_j) and team j wins with probability (a_j)\\/(a_i + a_j).\\n\\nThe team is called a winner if it directly or indirectly defeated all other teams. Team a defeated (directly or indirectly) team b if there is a sequence of teams c_1, c_2, ... c_k such that c_1 = a, c_k = b and team c_i defeated team c_{i + 1} for all i from 1 to k - 1. Note that it is possible that team a defeated team b and in the same time team b defeated team a.\\n\\nWilliam wants you to find the expected value of the number of winners.\\n\\nInput\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 14), which is the total number of teams participating in a match.\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^6) — the strengths of teams participating in a match.\\n\\nOutput\\n\\nOutput a single integer — the expected value of the number of winners of the tournament modulo 10^9 + 7.\\n\\nFormally, let M = 10^9+7. It can be demonstrated that the answer can be presented as a irreducible fraction p\\/q, where p and q are integers and q not ≡ 0 \\\\pmod{M}. Output a single integer equal to p ⋅ q^{-1} mod M. In other words, output an integer x such that 0 ≤ x < M and x ⋅ q ≡ p \\\\pmod{M}.\\n\\nExamples\\n\\nInput\\n\\n\\n2\\n1 2\\n\\n\\nOutput\\n\\n\\n1\\n\\n\\nInput\\n\\n\\n5\\n1 5 2 11 14\\n\\n\\nOutput\\n\\n\\n642377629\\n\\nNote\\n\\nTo better understand in which situation several winners are possible let's examine the second test:\\n\\nOne possible result of the tournament is as follows (a → b means that a defeated b):\\n\\n * 1 → 2 \\n * 2 → 3 \\n * 3 → 1 \\n * 1 → 4 \\n * 1 → 5 \\n * 2 → 4 \\n * 2 → 5 \\n * 3 → 4 \\n * 3 → 5 \\n * 4 → 5 \\n\\n\\n\\nOr more clearly in the picture:\\n\\n\\n\\nIn this case every team from the set \\\\{ 1, 2, 3 \\\\} directly or indirectly defeated everyone. I.e.:\\n\\n * 1st defeated everyone because they can get to everyone else in the following way...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\ntemplate \\nusing v2d = vector >;\\ntemplate \\nbool uin(T &a, T b) {\\n return a > b ? (a = b, true) : false;\\n}\\ntemplate \\nbool uax(T &a, T b) {\\n return a < b ? (a = b, true) : false;\\n}\\nmt19937 rng(chrono::system_clock::now().time_since_epoch().count());\\nconst int maxN = 14;\\nconst long long mod = 1e9 + 7;\\nint n;\\nlong long a[14], f[1 << 14], w[14][14], h[14][1 << 14];\\nlong long power(long long a, long long b) {\\n long long r = 1;\\n while (b) {\\n if (b & 1) {\\n r = r * a % mod;\\n }\\n b \\/= 2;\\n a = a * a % mod;\\n }\\n return r;\\n}\\nvoid solve() {\\n cin >> n;\\n for (int i = 0; i < (int)(n); ++i) {\\n cin >> a[i];\\n }\\n for (int i = 0; i < (int)(n); ++i) {\\n for (int j = 0; j < (int)(n); ++j) {\\n w[i][j] = a[i] * power(a[i] + a[j], mod - 2) % mod;\\n }\\n for (int mask = 0; mask < (int)(1 << n); ++mask) {\\n h[i][mask] = 1;\\n for (int j = 0; j < (int)(n); ++j) {\\n if (mask >> j & 1) {\\n h[i][mask] = h[i][mask] * w[i][j] % mod;\\n }\\n }\\n }\\n }\\n int m = (1 << n) - 1;\\n for (int mask = 1; mask <= (int)(m); ++mask) {\\n f[mask] = 1;\\n int submask = (mask - 1) & mask;\\n while (submask) {\\n long long p = 1;\\n for (int i = 0; i < (int)(n); ++i) {\\n if (submask >> i & 1) {\\n p = p * h[i][mask ^ submask] % mod;\\n }\\n }\\n f[mask] = (f[mask] - p * f[submask] + mod * mod) % mod;\\n submask = (submask - 1) & mask;\\n }\\n }\\n long long ans = 0;\\n for (int mask = 1; mask <= (int)(m); ++mask) {\\n int cnt = __builtin_popcount(mask);\\n long long p = 1;\\n for (int i = 0; i < (int)(n); ++i) {\\n if (mask >> i & 1) {\\n p = p * h[i][m ^ mask] % mod;\\n }\\n }\\n ans = (ans + cnt * f[mask] % mod * p) % mod;\\n }\\n cout << ans;\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(nullptr);\\n int T = 1;\\n while (T--) {\\n solve();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"This is the hard version of the problem. The only difference between the two versions is the constraint on n. You can make hacks only if all versions of the problem are solved.\\n\\nA forest is an undirected graph without cycles (not necessarily connected).\\n\\nMocha and Diana are friends in Zhijiang, both of them have a forest with nodes numbered from 1 to n, and they would like to add edges to their forests such that: \\n\\n * After adding edges, both of their graphs are still forests. \\n * They add the same edges. That is, if an edge (u, v) is added to Mocha's forest, then an edge (u, v) is added to Diana's forest, and vice versa. \\n\\n\\n\\nMocha and Diana want to know the maximum number of edges they can add, and which edges to add.\\n\\nInput\\n\\nThe first line contains three integers n, m_1 and m_2 (1 ≤ n ≤ 10^5, 0 ≤ m_1, m_2 < n) — the number of nodes and the number of initial edges in Mocha's forest and Diana's forest.\\n\\nEach of the next m_1 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the edges in Mocha's forest.\\n\\nEach of the next m_2 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the edges in Diana's forest.\\n\\nOutput\\n\\nThe first line contains only one integer h, the maximum number of edges Mocha and Diana can add.\\n\\nEach of the next h lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the edge you add each time.\\n\\nIf there are multiple correct answers, you can print any one of them.\\n\\nExamples\\n\\nInput\\n\\n\\n3 2 2\\n1 2\\n2 3\\n1 2\\n1 3\\n\\n\\nOutput\\n\\n\\n0\\n\\n\\nInput\\n\\n\\n5 3 2\\n5 4\\n2 1\\n4 3\\n4 3\\n1 4\\n\\n\\nOutput\\n\\n\\n1\\n2 4\\n\\n\\nInput\\n\\n\\n8 1 2\\n1 7\\n2 6\\n1 5\\n\\n\\nOutput\\n\\n\\n5\\n5 2\\n2 3\\n3 4\\n4 7\\n6 8\\n\\nNote\\n\\nIn the first example, we cannot add any edge.\\n\\nIn the second example, the initial forests are as follows.\\n\\n\\n\\nWe can add an edge (2, 4).\\n\\n\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\n \\npublic class Main extends PrintWriter {\\n \\n \\n void solve() {\\n int n = sc.nextInt();\\n int[] m = new int[2];\\n for(int i = 0; i < 2; i++) m[i] = sc.nextInt();\\n DSU[] dsu = new DSU[2];\\n for(int i = 0; i < 2; i++) {\\n dsu[i] = new DSU(n);\\n for(int j = 0; j < m[i]; j++) {\\n int u = sc.nextInt()-1;\\n int v = sc.nextInt()-1;\\n dsu[i].union(u, v);\\n }\\n }\\n ArrayDeque ans = new ArrayDeque<>();\\n boolean[][] done = new boolean[2][n];\\n for(int i = 0; i < 2; i++) {\\n int set = dsu[i].find_set(0);\\n for(int x : dsu[i].set[set]) {\\n done[i][x] = true;\\n }\\n }\\n for(int i = 1; i < n; i++) {\\n if(!done[0][i] && !done[1][i]) {\\n ans.add(\\\"1 \\\" + (i+1));\\n for(int t = 0; t < 2; t++) {\\n int set = dsu[t].find_set(i);\\n for(int x : dsu[t].set[set]) {\\n done[t][x] = true;\\n }\\n }\\n for(int t = 0; t < 2; t++) {\\n dsu[t].union(0, i);\\n }\\n }\\n }\\n int[] it = new int[2];\\n while(true) {\\n for(int t = 0; t < 2; t++) {\\n while(it[t] < n) {\\n if(done[t][it[t]] && !done[1-t][it[t]]) break;\\n it[t]++;\\n }\\n }\\n if(it[0] == n || it[1] == n) break;\\n ans.add((it[0]+1) + \\\" \\\" + (it[1]+1));\\n for(int t = 0; t < 2; t++) {\\n int set = dsu[t].find_set(it[1-t]);\\n for(int x : dsu[t].set[set]) {\\n done[t][x] = true;\\n }\\n }\\n for(int t = 0; t < 2; t++) {\\n dsu[t].union(it[0], it[1]);\\n }\\n }\\n println(n-1-Math.max(m[0], m[1]));\\n for(String s : ans) println(s);\\n }\\n \\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Dmitry has an array of n non-negative integers a_1, a_2, ..., a_n.\\n\\nIn one operation, Dmitry can choose any index j (1 ≤ j ≤ n) and increase the value of the element a_j by 1. He can choose the same index j multiple times.\\n\\nFor each i from 0 to n, determine whether Dmitry can make the MEX of the array equal to exactly i. If it is possible, then determine the minimum number of operations to do it.\\n\\nThe MEX of the array is equal to the minimum non-negative integer that is not in the array. For example, the MEX of the array [3, 1, 0] is equal to 2, and the array [3, 3, 1, 4] is equal to 0.\\n\\nInput\\n\\nThe first line of input data contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases in the input. \\n\\nThe descriptions of the test cases follow.\\n\\nThe first line of the description of each test case contains a single integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the length of the array a.\\n\\nThe second line of the description of each test case contains n integers a_1, a_2, ..., a_n (0 ≤ a_i ≤ n) — elements of the array a.\\n\\nIt is guaranteed that the sum of the values n over all test cases in the test does not exceed 2⋅10^5.\\n\\nOutput\\n\\nFor each test case, output n + 1 integer — i-th number is equal to the minimum number of operations for which you can make the array MEX equal to i (0 ≤ i ≤ n), or -1 if this cannot be done.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n3\\n0 1 3\\n7\\n0 1 2 3 4 3 2\\n4\\n3 0 0 0\\n7\\n4 6 2 3 5 0 5\\n5\\n4 0 1 0 4\\n\\n\\nOutput\\n\\n\\n1 1 0 -1 \\n1 1 2 2 1 0 2 6 \\n3 0 1 4 3 \\n1 0 -1 -1 -1 -1 -1 -1 \\n2 1 0 2 -1 -1 \\n\\nNote\\n\\nIn the first set of example inputs, n=3:\\n\\n * to get MEX=0, it is enough to perform one increment: a_1++; \\n * to get MEX=1, it is enough to perform one increment: a_2++; \\n * MEX=2 for a given array, so there is no need to perform increments; \\n * it is impossible to get MEX=3 by performing increments. \\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nusing ll = long long;\\ntemplate \\nvoid __f(const char *name, Arg1 &&arg1) {\\n cout << name << \\\" : \\\" << arg1 << '\\\\n';\\n}\\ntemplate \\nvoid __f(const char *names, Arg1 &&arg1, Args &&...args) {\\n const char *comma = strchr(names + 1, ',');\\n cout.write(names, comma - names) << \\\" : \\\" << arg1 << \\\" | \\\";\\n __f(comma + 1, args...);\\n}\\nvoid solve() {\\n ll n;\\n cin >> n;\\n vector ar(n);\\n ll cnt = 0;\\n for (ll i = 0; i < n; i++) cin >> ar[i];\\n sort(ar.begin(), ar.end());\\n ll ind = 0;\\n ll sum = 0;\\n vector dp(n + 1);\\n map mp;\\n for (ll i = 0; i <= n; i++) {\\n while (ind < ar.size() && ar[ind] < i) ind++;\\n if (ind < i) break;\\n ll pre = ind;\\n while (ind < ar.size() && ar[ind] == i) ind++;\\n if (i > 0) dp[i] = dp[i - 1];\\n ll num = ind - pre;\\n if (num > 1)\\n mp.insert({i, num - 1});\\n else if (num == 0 && mp.empty() == 0) {\\n auto cd = mp.rbegin();\\n dp[i] += i - cd->first;\\n if (cd->second == 1)\\n mp.erase(cd->first);\\n else\\n cd->second--;\\n }\\n ll tmp = (i) ? dp[i - 1] : 0;\\n cout << num + tmp << ' ';\\n }\\n while (ind++ < ar.size()) cout << \\\"-1 \\\";\\n cout << '\\\\n';\\n}\\nint32_t main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n clock_t z = clock();\\n ll t = 1;\\n cin >> t;\\n while (t--) solve();\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nPolycarp has a favorite sequence a[1 ... n] consisting of n integers. He wrote it out on the whiteboard as follows:\\n\\n * he wrote the number a_1 to the left side (at the beginning of the whiteboard); \\n * he wrote the number a_2 to the right side (at the end of the whiteboard); \\n * then as far to the left as possible (but to the right from a_1), he wrote the number a_3; \\n * then as far to the right as possible (but to the left from a_2), he wrote the number a_4; \\n * Polycarp continued to act as well, until he wrote out the entire sequence on the whiteboard. \\n\\n The beginning of the result looks like this (of course, if n ≥ 4).\\n\\nFor example, if n=7 and a=[3, 1, 4, 1, 5, 9, 2], then Polycarp will write a sequence on the whiteboard [3, 4, 5, 2, 9, 1, 1].\\n\\nYou saw the sequence written on the whiteboard and now you want to restore Polycarp's favorite sequence.\\n\\nInput\\n\\nThe first line contains a single positive integer t (1 ≤ t ≤ 300) — the number of test cases in the test. Then t test cases follow.\\n\\nThe first line of each test case contains an integer n (1 ≤ n ≤ 300) — the length of the sequence written on the whiteboard.\\n\\nThe next line contains n integers b_1, b_2,…, b_n (1 ≤ b_i ≤ 10^9) — the sequence written on the whiteboard.\\n\\nOutput\\n\\nOutput t answers to the test cases. Each answer — is a sequence a that Polycarp wrote out on the whiteboard.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n7\\n3 4 5 2 9 1 1\\n4\\n9 2 7 1\\n11\\n8 4 3 1 2 7 8 7 9 4 2\\n1\\n42\\n2\\n11 7\\n8\\n1 1 1 1 1 1 1 1\\n\\n\\nOutput\\n\\n\\n3 1 4 1 5 9 2 \\n9 1 2 7 \\n8 2 4 4 3 9 1 7 2 8 7 \\n42 \\n11 7 \\n1 1 1 1 1 1 1 1 \\n\\nNote\\n\\nIn the first test case, the sequence a matches the sequence from the statement. The whiteboard states after each step look like this:\\n\\n[3] ⇒ [3, 1] ⇒ [3, 4, 1] ⇒ [3, 4, 1, 1] ⇒ [3, 4, 5, 1, 1] ⇒ [3, 4, 5, 9, 1, 1] ⇒ [3, 4, 5, 2, 9, 1, 1].\",\"targets\":\"#include \\n#define ll long long\\n#define rep(i,a,b) for(ll i=a;i>a[i]\\nusing namespace std ;\\n\\nvoid solve(){\\n ll n;\\n cin>>n;\\n ll a[n];\\n arr(a,n);\\n ll mid=n\\/2;\\n if(n%2==0){\\n for(ll i=0,j=n-1;i=mid;)\\n {\\n cout<mid;)\\n {\\n cout<>t;\\n while(t--) solve();\\n }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Consider a sequence of integers a_1, a_2, …, a_n. In one move, you can select any element of the sequence and delete it. After an element is deleted, all elements to the right are shifted to the left by 1 position, so there are no empty spaces in the sequence. So after you make a move, the sequence's length decreases by 1. The indices of the elements after the move are recalculated.\\n\\nE. g. let the sequence be a=[3, 2, 2, 1, 5]. Let's select the element a_3=2 in a move. Then after the move the sequence will be equal to a=[3, 2, 1, 5], so the 3-rd element of the new sequence will be a_3=1 and the 4-th element will be a_4=5.\\n\\nYou are given a sequence a_1, a_2, …, a_n and a number k. You need to find the minimum number of moves you have to make so that in the resulting sequence there will be at least k elements that are equal to their indices, i. e. the resulting sequence b_1, b_2, …, b_m will contain at least k indices i such that b_i = i.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 100) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of two consecutive lines. The first line contains two integers n and k (1 ≤ k ≤ n ≤ 2000). The second line contains a sequence of integers a_1, a_2, …, a_n (1 ≤ a_i ≤ n). The numbers in the sequence are not necessarily different.\\n\\nIt is guaranteed that the sum of n over all test cases doesn't exceed 2000.\\n\\nOutput\\n\\nFor each test case output in a single line:\\n\\n * -1 if there's no desired move sequence; \\n * otherwise, the integer x (0 ≤ x ≤ n) — the minimum number of the moves to be made so that the resulting sequence will contain at least k elements that are equal to their indices. \\n\\nExample\\n\\nInput\\n\\n\\n4\\n7 6\\n1 1 2 3 4 5 6\\n5 2\\n5 1 3 2 3\\n5 2\\n5 5 5 5 4\\n8 4\\n1 2 3 3 2 2 5 5\\n\\n\\nOutput\\n\\n\\n1\\n2\\n-1\\n2\\n\\nNote\\n\\nIn the first test case the sequence doesn't satisfy the desired condition, but it can be provided by deleting the first element, hence the sequence will be [1, 2, 3, 4, 5, 6] and 6 elements will be equal to their indices.\\n\\nIn the second test case...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nint denom = 31607;\\nint powmod(int a, int b) {\\n int res = 1;\\n a %= denom;\\n for (; b; b >>= 1) {\\n if (b & 1) res = res * a % denom;\\n a = a * a % denom;\\n }\\n return res;\\n}\\nint n;\\nint solve(int idx, int k, vector& a, vector>& dp) {\\n if (k == 0) return 0;\\n if (idx >= n) return n + 1;\\n if (dp[idx][k] != -1) return dp[idx][k];\\n int result = n + 1;\\n for (int j = (idx + 1); j < (n); j++) {\\n if (a[j] <= a[idx]) continue;\\n int dIdx = j - idx;\\n int dVal = a[j] - a[idx];\\n if (dVal > dIdx) continue;\\n result = min(result, dIdx - dVal + solve(j, k - 1, a, dp));\\n if (dIdx == dVal) break;\\n }\\n dp[idx][k] = result;\\n return result;\\n}\\nint main(int argc, const char* argv[]) {\\n ios::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n int t;\\n cin >> t;\\n while (t-- > 0) {\\n int k;\\n cin >> n >> k;\\n vector a(n);\\n for (int i = (0); i < (n); i++) {\\n cin >> a[i];\\n a[i]--;\\n }\\n vector> dp(n, vector(k + 1, -1));\\n int res = INT_MAX;\\n for (int i = (0); i < (n); i++) {\\n if (a[i] > i) continue;\\n res = min(res, i - a[i] + solve(i, k - 1, a, dp));\\n }\\n cout << (res > n ? -1 : res) << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"As a New Year's gift, Dolphin received a string s of length 19.\\nThe string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`.\\nDolphin wants to convert the comma-separated string s into a space-separated string.\\nWrite a program to perform the conversion for him.\\n\\nConstraints\\n\\n* The length of s is 19.\\n* The sixth and fourteenth characters in s are `,`.\\n* The other characters in s are lowercase English letters.\\n\\nInput\\n\\nThe input is given from Standard Input in the following format:\\n\\n\\ns\\n\\n\\nOutput\\n\\nPrint the string after the conversion.\\n\\nExamples\\n\\nInput\\n\\nhappy,newyear,enjoy\\n\\n\\nOutput\\n\\nhappy newyear enjoy\\n\\n\\nInput\\n\\nhaiku,atcoder,tasks\\n\\n\\nOutput\\n\\nhaiku atcoder tasks\\n\\n\\nInput\\n\\nabcde,fghihgf,edcba\\n\\n\\nOutput\\n\\nabcde fghihgf edcba\\nimpor\",\"targets\":\"t java.util.*;\\npublic class Main {\\n\\n\\tpublic static void main(String[] args) {\\n\\t\\t\\/\\/ TODO Auto-generated method stub\\n\\t\\tScanner sc = new Scanner(System.in);\\n\\t\\tString s = sc.next();\\n\\t\\tSystem.out.println(s.replace(\\\",\\\", \\\" \\\"));\\n\\t\\t}\\n\\t\\t\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given three integers n, a, b. Determine if there exists a permutation p_1, p_2, …, p_n of integers from 1 to n, such that:\\n\\n * There are exactly a integers i with 2 ≤ i ≤ n-1 such that p_{i-1} < p_i > p_{i+1} (in other words, there are exactly a local maximums).\\n\\n * There are exactly b integers i with 2 ≤ i ≤ n-1 such that p_{i-1} > p_i < p_{i+1} (in other words, there are exactly b local minimums).\\n\\n\\n\\n\\nIf such permutations exist, find any such permutation.\\n\\nInput\\n\\nThe first line of the input contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. The description of test cases follows.\\n\\nThe only line of each test case contains three integers n, a and b (2 ≤ n ≤ 10^5, 0 ≤ a,b ≤ n).\\n\\nThe sum of n over all test cases doesn't exceed 10^5.\\n\\nOutput\\n\\nFor each test case, if there is no permutation with the requested properties, output -1.\\n\\nOtherwise, print the permutation that you are found. If there are several such permutations, you may print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n4 1 1\\n6 1 2\\n6 4 0\\n\\n\\nOutput\\n\\n\\n1 3 2 4\\n4 2 3 1 5 6\\n-1\\n\\nNote\\n\\nIn the first test case, one example of such permutations is [1, 3, 2, 4]. In it p_1 < p_2 > p_3, and 2 is the only such index, and p_2> p_3 < p_4, and 3 the only such index.\\n\\nOne can show that there is no such permutation for the third test case.\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nlong long int M = 1e9 + 7;\\nlong long int mE(long long int x, long long int n, long long int M) {\\n long long int result = 1;\\n while (n > 0) {\\n if (n % 2 == 1) result = (result * x) % M;\\n x = (x * x) % M;\\n n = n \\/ 2;\\n }\\n return result;\\n}\\nvoid light_yagami() {\\n long long int n, a, b;\\n cin >> n >> a >> b;\\n long long int aa = a, bb = b;\\n vector v(n);\\n for (int i = 0; i < n; i++) v[i] = i + 1;\\n if (a == 0 && b == 0) {\\n for (int i = 0; i < n; i++) cout << v[i] << \\\" \\\";\\n cout << endl;\\n } else if (n % 2 == 0) {\\n if (a >= (n \\/ 2) || b >= (n \\/ 2))\\n cout << -1 << endl;\\n else if (abs(a - b) > 1)\\n cout << -1 << endl;\\n else {\\n if (a > b) {\\n long long int i = n - 1ll;\\n while (a--) {\\n swap(v[i], v[i - 1]);\\n i -= 2ll;\\n }\\n } else {\\n long long int i = 1ll;\\n while (b--) {\\n swap(v[i], v[i - 1]);\\n i += 2ll;\\n }\\n }\\n if (aa == bb) swap(v[n - 1], v[n - 2]);\\n for (int i = 0; i < n; i++) cout << v[i] << \\\" \\\";\\n cout << endl;\\n }\\n } else {\\n if (a > ((n \\/ 2)) || b > ((n \\/ 2)))\\n cout << -1 << endl;\\n else if (a == n \\/ 2 && b == n \\/ 2)\\n cout << -1 << endl;\\n else if (abs(a - b) > 1)\\n cout << -1 << endl;\\n else {\\n if (a > b) {\\n long long int i = n - 1ll;\\n while (a--) {\\n swap(v[i], v[i - 1]);\\n i -= 2ll;\\n }\\n } else {\\n long long int i = 1ll;\\n while (b--) {\\n swap(v[i], v[i - 1]);\\n i += 2ll;\\n }\\n }\\n if (aa == bb) swap(v[n - 1], v[n - 2]);\\n for (int i = 0; i < n; i++) cout << v[i] << \\\" \\\";\\n cout << endl;\\n }\\n }\\n}\\nint main() {\\n int q;\\n cin >> q;\\n while (q--) {\\n light_yagami();\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in PYTHON3?\\nRecently, Petya learned about a new game \\\"Slay the Dragon\\\". As the name suggests, the player will have to fight with dragons. To defeat a dragon, you have to kill it and defend your castle. To do this, the player has a squad of n heroes, the strength of the i-th hero is equal to a_i.\\n\\nAccording to the rules of the game, exactly one hero should go kill the dragon, all the others will defend the castle. If the dragon's defense is equal to x, then you have to send a hero with a strength of at least x to kill it. If the dragon's attack power is y, then the total strength of the heroes defending the castle should be at least y.\\n\\nThe player can increase the strength of any hero by 1 for one gold coin. This operation can be done any number of times.\\n\\nThere are m dragons in the game, the i-th of them has defense equal to x_i and attack power equal to y_i. Petya was wondering what is the minimum number of coins he needs to spend to defeat the i-th dragon.\\n\\nNote that the task is solved independently for each dragon (improvements are not saved).\\n\\nInput\\n\\nThe first line contains a single integer n (2 ≤ n ≤ 2 ⋅ 10^5) — number of heroes.\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^{12}), where a_i is the strength of the i-th hero.\\n\\nThe third line contains a single integer m (1 ≤ m ≤ 2 ⋅ 10^5) — the number of dragons.\\n\\nThe next m lines contain two integers each, x_i and y_i (1 ≤ x_i ≤ 10^{12}; 1 ≤ y_i ≤ 10^{18}) — defense and attack power of the i-th dragon.\\n\\nOutput\\n\\nPrint m lines, i-th of which contains a single integer — the minimum number of coins that should be spent to defeat the i-th dragon.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3 6 2 3\\n5\\n3 12\\n7 9\\n4 14\\n1 10\\n8 7\\n\\n\\nOutput\\n\\n\\n1\\n2\\n4\\n0\\n2\\n\\nNote\\n\\nTo defeat the first dragon, you can increase the strength of the third hero by 1, then the strength of the heroes will be equal to [3, 6, 3, 3]. To kill the dragon, you can choose the first hero.\\n\\nTo defeat the second dragon, you can increase the forces of the second and third heroes by 1, then the strength of the heroes will...\",\"targets\":\"import os\\nimport sys\\nfrom io import BytesIO, IOBase\\nimport math as mt\\nimport itertools as it\\nimport operator as op\\nimport bisect as bs\\nimport heapq as hp\\nfrom functools import reduce\\nfrom io import BytesIO, IOBase\\nfrom collections import deque, defaultdict, OrderedDict, Counter, ChainMap, _chain\\nmaxx, localsys, mod = 1 << 60, 0, int(1e9 + 7)\\ndef nCr(n, r): return reduce(op.mul, range(n - r + 1, n + 1), 1) \\/\\/ mt.factorial(r)\\n\\ndef ceil(a, b): return (a + b - 1) \\/\\/ b\\n\\ndef lcm(a, b): return a * b \\/\\/ mt.gcd(a, b)\\n\\n\\ngcdm = lambda *args: reduce(mt.gcd, args, 0)\\n\\ndef lcm(a, b): return a * b \\/\\/ mt.gcd(a, b)\\n\\n\\nlcmm = lambda *args: reduce(lcm, args, 1)\\n\\n_str = str\\nstr = lambda x=b\\\"\\\": x if type(x) is bytes else _str(x).encode()\\n\\nBUFSIZE = 8192\\n\\n\\nclass FastIO(IOBase):\\n newlines = 0\\n\\n def __init__(self, file):\\n self._fd = file.fileno()\\n self.buffer = BytesIO()\\n self.writable = \\\"x\\\" in file.mode or \\\"r\\\" not in file.mode\\n self.write = self.buffer.write if self.writable else None\\n\\n def read(self):\\n while True:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n if not b:\\n break\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines = 0\\n return self.buffer.read()\\n\\n def readline(self):\\n while self.newlines == 0:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n self.newlines = b.count(b\\\"\\\\n\\\") + (not b)\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines -= 1\\n return self.buffer.readline()\\n\\n def flush(self):\\n if self.writable:\\n os.write(self._fd, self.buffer.getvalue())\\n self.buffer.truncate(0), self.buffer.seek(0)\\n\\n\\nclass IOWrapper(IOBase):\\n def __init__(self, file):\\n self.buffer = FastIO(file)\\n self.flush = self.buffer.flush\\n self.writable =...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"The robot is located on a checkered rectangular board of size n × m (n rows, m columns). The rows in the board are numbered from 1 to n from top to bottom, and the columns — from 1 to m from left to right.\\n\\nThe robot is able to move from the current cell to one of the four cells adjacent by side.\\n\\nThe sequence of commands s executed by the robot is given. Each command is denoted by one of the symbols 'L', 'R', 'D' or 'U', and triggers the movement to left, right, down or up, respectively.\\n\\nThe robot can start its movement in any cell. The robot executes the commands starting from the first one, strictly in the order in which they are listed in s. If the robot moves beyond the edge of the board, it falls and breaks. A command that causes the robot to break is not considered successfully executed.\\n\\nThe robot's task is to execute as many commands as possible without falling off the board. For example, on board 3 × 3, if the robot starts a sequence of actions s=\\\"RRDLUU\\\" (\\\"right\\\", \\\"right\\\", \\\"down\\\", \\\"left\\\", \\\"up\\\", \\\"up\\\") from the central cell, the robot will perform one command, then the next command will force him to cross the edge. If the robot starts moving from the cell (2, 1) (second row, first column) then all commands will be executed successfully and the robot will stop at the cell (1, 2) (first row, second column).\\n\\n The robot starts from cell (2, 1) (second row, first column). It moves right, right, down, left, up, and up. In this case it ends in the cell (1, 2) (first row, second column).\\n\\nDetermine the cell from which the robot should start its movement in order to execute as many commands as possible.\\n\\nInput\\n\\nThe first line contains an integer t (1 ≤ t ≤ 10^4) — the number of test cases.\\n\\nThe next 2t lines contain descriptions of the test cases.\\n\\nIn the description of each test case, the first line contains two integers n and m (1 ≤ n, m ≤ 10^6) — the height and width of the field that the robot is located on. The second line of the description is a string s consisting solely of characters 'L',...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nvoid RUN() { ios::sync_with_stdio(false), cin.tie(nullptr); }\\nint main() {\\n RUN();\\n int t;\\n cin >> t;\\n while (t--) {\\n int n, m;\\n cin >> n >> m;\\n string s;\\n cin >> s;\\n int curY = 0, y = 1, L = 0, R = 0;\\n int curX = 0, x = 1, U = 0, D = 0;\\n for (auto c : s) {\\n curY -= c == 'L', curY += c == 'R';\\n L = min(L, curY), R = max(R, curY);\\n curX -= c == 'U', curX += c == 'D';\\n U = min(U, curX), D = max(D, curX);\\n if (R - L + 1 <= m && D - U + 1 <= n) x = -U + 1, y = -L + 1;\\n }\\n cout << x << \\\" \\\" << y << '\\\\n';\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given a string s, consisting of n letters, each letter is either 'a' or 'b'. The letters in the string are numbered from 1 to n.\\n\\ns[l; r] is a continuous substring of letters from index l to r of the string inclusive. \\n\\nA string is called balanced if the number of letters 'a' in it is equal to the number of letters 'b'. For example, strings \\\"baba\\\" and \\\"aabbab\\\" are balanced and strings \\\"aaab\\\" and \\\"b\\\" are not.\\n\\nFind any non-empty balanced substring s[l; r] of string s. Print its l and r (1 ≤ l ≤ r ≤ n). If there is no such substring, then print -1 -1.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of testcases.\\n\\nThen the descriptions of t testcases follow.\\n\\nThe first line of the testcase contains a single integer n (1 ≤ n ≤ 50) — the length of the string.\\n\\nThe second line of the testcase contains a string s, consisting of n letters, each letter is either 'a' or 'b'.\\n\\nOutput\\n\\nFor each testcase print two integers. If there exists a non-empty balanced substring s[l; r], then print l r (1 ≤ l ≤ r ≤ n). Otherwise, print -1 -1.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n1\\na\\n6\\nabbaba\\n6\\nabbaba\\n9\\nbabbabbaa\\n\\n\\nOutput\\n\\n\\n-1 -1\\n1 6\\n3 6\\n2 5\\n\\nNote\\n\\nIn the first testcase there are no non-empty balanced subtrings.\\n\\nIn the second and third testcases there are multiple balanced substrings, including the entire string \\\"abbaba\\\" and substring \\\"baba\\\".\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nvoid solve() {\\n long long int n;\\n cin >> n;\\n string s;\\n cin >> s;\\n long long int a = 0, b = 0;\\n for (long long int i = 0; i < n; i++) {\\n a = 0, b = 0;\\n for (long long int j = i; j < n; j++) {\\n if (s[j] == 'a')\\n a++;\\n else\\n b++;\\n if (a == b) {\\n cout << i + 1 << \\\" \\\" << j + 1 << \\\"\\\\n\\\";\\n return;\\n }\\n }\\n }\\n cout << -1 << \\\" \\\" << -1 << \\\"\\\\n\\\";\\n}\\nint32_t main() {\\n ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);\\n ;\\n ;\\n long long int t;\\n cin >> t;\\n while (t--) {\\n solve();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Polycarp has a string s. Polycarp performs the following actions until the string s is empty (t is initially an empty string):\\n\\n * he adds to the right to the string t the string s, i.e. he does t = t + s, where t + s is a concatenation of the strings t and s; \\n * he selects an arbitrary letter of s and removes from s all its occurrences (the selected letter must occur in the string s at the moment of performing this action). \\n\\n\\n\\nPolycarp performs this sequence of actions strictly in this order.\\n\\nNote that after Polycarp finishes the actions, the string s will be empty and the string t will be equal to some value (that is undefined and depends on the order of removing).\\n\\nE.g. consider s=\\\"abacaba\\\" so the actions may be performed as follows:\\n\\n * t=\\\"abacaba\\\", the letter 'b' is selected, then s=\\\"aacaa\\\"; \\n * t=\\\"abacabaaacaa\\\", the letter 'a' is selected, then s=\\\"c\\\"; \\n * t=\\\"abacabaaacaac\\\", the letter 'c' is selected, then s=\\\"\\\" (the empty string). \\n\\n\\n\\nYou need to restore the initial value of the string s using only the final value of t and find the order of removing letters from s.\\n\\nInput\\n\\nThe first line contains one integer T (1 ≤ T ≤ 10^4) — the number of test cases. Then T test cases follow.\\n\\nEach test case contains one string t consisting of lowercase letters of the Latin alphabet. The length of t doesn't exceed 5 ⋅ 10^5. The sum of lengths of all strings t in the test cases doesn't exceed 5 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case output in a separate line:\\n\\n * -1, if the answer doesn't exist; \\n * two strings separated by spaces. The first one must contain a possible initial value of s. The second one must contain a sequence of letters — it's in what order one needs to remove letters from s to make the string t. E.g. if the string \\\"bac\\\" is outputted, then, first, all occurrences of the letter 'b' were deleted, then all occurrences of 'a', and then, finally, all occurrences of 'c'. If there are multiple solutions, print any one....\",\"targets\":\"def binarysearch(array,item):\\n if array==[]:\\n return False\\n i=0\\n j=len(array)-1\\n while iitem:\\n j=mid\\n else:\\n i=mid+1\\n else:\\n return True if array[i]==item else False\\n\\n\\ndef delet(list, item):\\n list2=[]\\n for i in list:\\n if (i!=item):\\n list2.append(i)\\n return list2\\n\\n\\ndef first(arr, x):\\n low = 0\\n high = len(arr) - 1\\n res = -1\\n while (low <= high):\\n mid = (low + high) \\/\\/ 2\\n if arr[mid] > x:\\n high = mid - 1\\n elif arr[mid] < x:\\n low = mid + 1\\n else:\\n res = mid\\n high = mid - 1\\n return res\\nt=int(input())\\nfor test in range(t):\\n strin=input()\\n d=len(strin)\\n array=[]\\n for item in strin:\\n array.append(item)\\n order=[]\\n search=[]\\n array.reverse()\\n for item in array:\\n if not binarysearch(search,item):\\n order.append(item)\\n search.append(item)\\n search.sort()\\n order.reverse()\\n array2=sorted(array)\\n l=0\\n for i in range(len(order)):\\n x=first(array2,order[i])\\n s=0\\n possible=0\\n while x+s0:\\n possible=-1\\n else:\\n l+=(s\\/\\/(i+1))\\n if possible==-1:\\n print(-1)\\n break\\n else:\\n array.reverse()\\n init=array[:l]\\n smple=array[:l]\\n for i in range(len(order)-1):\\n smple=delet(smple,order[i])\\n init+=smple\\n if init==array:\\n ar=array[:l]\\n s=\\\"\\\"\\n for item in ar:\\n s+=str(item)\\n s1=\\\"\\\"\\n for item in order:\\n s1+=str(item)\\n ans=[s,s1]\\n print(\\\" \\\".join(map(str,ans)))\\n else:\\n print(-1)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Bob loves everything sweet. His favorite chocolate bar consists of pieces, each piece may contain a nut. Bob wants to break the bar of chocolate into multiple pieces so that each part would contain exactly one nut and any break line goes between two adjacent pieces.\\n\\nYou are asked to calculate the number of ways he can do it. Two ways to break chocolate are considered distinct if one of them contains a break between some two adjacent pieces and the other one doesn't. \\n\\nPlease note, that if Bob doesn't make any breaks, all the bar will form one piece and it still has to have exactly one nut.\\n\\nInput\\n\\nThe first line of the input contains integer n (1 ≤ n ≤ 100) — the number of pieces in the chocolate bar.\\n\\nThe second line contains n integers ai (0 ≤ ai ≤ 1), where 0 represents a piece without the nut and 1 stands for a piece with the nut.\\n\\nOutput\\n\\nPrint the number of ways to break the chocolate into multiple parts so that each part would contain exactly one nut.\\n\\nExamples\\n\\nInput\\n\\n3\\n0 1 0\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\n5\\n1 0 1 0 1\\n\\n\\nOutput\\n\\n4\\n\\nNote\\n\\nIn the first sample there is exactly one nut, so the number of ways equals 1 — Bob shouldn't make any breaks.\\n\\nIn the second sample you can break the bar in four ways:\\n\\n10|10|1\\n\\n1|010|1\\n\\n10|1|01\\n\\n1|01|01\\nThe above is tricky. Write me a correct solution in PYTHON.\",\"targets\":\"n = int(raw_input())\\narr = map(int,raw_input().split())\\nt = []\\nfor i,val in enumerate(arr):\\n\\tif val == 1:\\n\\t\\tt.append(i)\\nx = [j-i for i, j in zip(t[:-1], t[1:])]\\nif (len(arr) == 1 and len(t) == 0) :\\n\\tprint \\\"0\\\"\\nelif (len(arr) == 1 and len(t) == 1) :\\n\\tprint \\\"1\\\"\\nelif len(t) == 0:\\n\\tprint \\\"0\\\"\\nelse:\\n\\ty = reduce(lambda x, y: x * y, x, 1)\\n\\tprint y\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Polycarp has a string s. Polycarp performs the following actions until the string s is empty (t is initially an empty string):\\n\\n * he adds to the right to the string t the string s, i.e. he does t = t + s, where t + s is a concatenation of the strings t and s; \\n * he selects an arbitrary letter of s and removes from s all its occurrences (the selected letter must occur in the string s at the moment of performing this action). \\n\\n\\n\\nPolycarp performs this sequence of actions strictly in this order.\\n\\nNote that after Polycarp finishes the actions, the string s will be empty and the string t will be equal to some value (that is undefined and depends on the order of removing).\\n\\nE.g. consider s=\\\"abacaba\\\" so the actions may be performed as follows:\\n\\n * t=\\\"abacaba\\\", the letter 'b' is selected, then s=\\\"aacaa\\\"; \\n * t=\\\"abacabaaacaa\\\", the letter 'a' is selected, then s=\\\"c\\\"; \\n * t=\\\"abacabaaacaac\\\", the letter 'c' is selected, then s=\\\"\\\" (the empty string). \\n\\n\\n\\nYou need to restore the initial value of the string s using only the final value of t and find the order of removing letters from s.\\n\\nInput\\n\\nThe first line contains one integer T (1 ≤ T ≤ 10^4) — the number of test cases. Then T test cases follow.\\n\\nEach test case contains one string t consisting of lowercase letters of the Latin alphabet. The length of t doesn't exceed 5 ⋅ 10^5. The sum of lengths of all strings t in the test cases doesn't exceed 5 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case output in a separate line:\\n\\n * -1, if the answer doesn't exist; \\n * two strings separated by spaces. The first one must contain a possible initial value of s. The second one must contain a sequence of letters — it's in what order one needs to remove letters from s to make the string t. E.g. if the string \\\"bac\\\" is outputted, then, first, all occurrences of the letter 'b' were deleted, then all occurrences of 'a', and then, finally, all occurrences of 'c'. If there are multiple solutions, print any one....\\nSolve the task in CPP.\",\"targets\":\"#include \\n#pragma GCC optimize(\\\"Ofast,unroll-loops\\\")\\n#pragma GCC target(\\\"avx,avx2,fma\\\")\\nusing namespace std;\\nconst long long mod1 = 998244353;\\nconst long long mod = 1e9 + 7;\\nlong long mod_mul(long long a, long long b) {\\n a = a % mod;\\n b = b % mod;\\n return (((a * b) % mod) + mod) % mod;\\n}\\nlong long inv(long long i) {\\n if (i == 1) return 1;\\n return (mod - ((mod \\/ i) * inv(mod % i)) % mod) % mod;\\n}\\nlong long gcd(long long a, long long b) {\\n if (b == 0) return a;\\n return gcd(b, a % b);\\n}\\nlong long pwr(long long a, long long b) {\\n a %= mod;\\n long long res = 1;\\n while (b > 0) {\\n if (b & 1) res = res * a % mod;\\n a = a * a % mod;\\n b >>= 1;\\n }\\n return res;\\n}\\nlong long findMinNumber(long long n) {\\n long long count = 0, ans = 1;\\n while (n % 2 == 0) {\\n count++;\\n n \\/= 2;\\n }\\n if (count % 2) ans *= 2;\\n for (int i = 3; i <= sqrt(n); i += 2) {\\n count = 0;\\n while (n % i == 0) {\\n count++;\\n n \\/= i;\\n }\\n if (count % 2) ans *= i;\\n }\\n if (n > 2) ans *= n;\\n return ans;\\n}\\nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n long long t;\\n cin >> t;\\n while (t--) {\\n string s, a;\\n cin >> s;\\n a = s;\\n long long n = s.length(), i, cnt1 = 0, cnt = 0, idx;\\n map m, m1;\\n for (i = 0; i < n; i++) {\\n m[s[i]]++;\\n if (m[s[i]] == 1) cnt++;\\n }\\n vector ans;\\n for (i = n - 1; i >= 0; i--) {\\n m1[s[i]]++;\\n if (m1[s[i]] == 1) {\\n ans.push_back(s[i]);\\n cnt1++;\\n if (cnt1 == cnt) {\\n idx = i;\\n break;\\n }\\n }\\n }\\n long long sum = 0;\\n for (i = 0; i < ans.size(); i++) {\\n sum += (cnt - i - 1) * (m[ans[i]]) \\/ (cnt - i);\\n }\\n long long l = n - sum, j;\\n string sans = s.substr(0, l);\\n for (i = cnt - 1; i >= 0; i--) {\\n for (j = 0; j < l; j++) {\\n if (s[j] == '#' or s[j] == ans[i]) {\\n s[j] = '#';\\n } else {\\n sans += s[j];\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nYou are given three integers n, a, b. Determine if there exists a permutation p_1, p_2, …, p_n of integers from 1 to n, such that:\\n\\n * There are exactly a integers i with 2 ≤ i ≤ n-1 such that p_{i-1} < p_i > p_{i+1} (in other words, there are exactly a local maximums).\\n\\n * There are exactly b integers i with 2 ≤ i ≤ n-1 such that p_{i-1} > p_i < p_{i+1} (in other words, there are exactly b local minimums).\\n\\n\\n\\n\\nIf such permutations exist, find any such permutation.\\n\\nInput\\n\\nThe first line of the input contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. The description of test cases follows.\\n\\nThe only line of each test case contains three integers n, a and b (2 ≤ n ≤ 10^5, 0 ≤ a,b ≤ n).\\n\\nThe sum of n over all test cases doesn't exceed 10^5.\\n\\nOutput\\n\\nFor each test case, if there is no permutation with the requested properties, output -1.\\n\\nOtherwise, print the permutation that you are found. If there are several such permutations, you may print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n4 1 1\\n6 1 2\\n6 4 0\\n\\n\\nOutput\\n\\n\\n1 3 2 4\\n4 2 3 1 5 6\\n-1\\n\\nNote\\n\\nIn the first test case, one example of such permutations is [1, 3, 2, 4]. In it p_1 < p_2 > p_3, and 2 is the only such index, and p_2> p_3 < p_4, and 3 the only such index.\\n\\nOne can show that there is no such permutation for the third test case.\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\n\\npublic class B {\\n\\tpublic static void main(String[] args) throws Exception {\\n\\t\\tScanner sc = new Scanner(System.in);\\n\\t\\tPrintWriter pw = new PrintWriter(System.out);\\n\\t\\tint t = sc.nextInt();\\n\\t\\twhile (t-- > 0) {\\n\\t\\t\\tint n = sc.nextInt();\\n\\t\\t\\tint a = sc.nextInt();\\n\\t\\t\\tint b = sc.nextInt();\\n\\/\\/ if(a + b > n-2){\\n\\/\\/ System.out.println(-1);\\n\\/\\/ continue;\\n\\/\\/ }\\n\\/\\/ \\n\\/\\/ if(Math.abs(a-b) > 1){\\n\\/\\/ System.out.println(-1);\\n\\/\\/ continue;\\n\\/\\/ }\\n\\t\\t\\tif ((a == 0 && b == 0)) {\\n\\t\\t\\t\\tfor (int i = 1; i <= n; i++) {\\n\\t\\t\\t\\t\\tpw.print(i + \\\" \\\");\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tpw.println();\\n\\t\\t\\t} else if (n % 2 == 0 && (a > ((n - 2) \\/ 2) || b > ((n - 2) \\/ 2))) {\\n\\t\\t\\t\\tpw.println(-1);\\n\\t\\t\\t} else if (n % 2 == 1 && (a > ((n - 2) \\/ 2) && b > ((n - 2) \\/ 2))) {\\n\\t\\t\\t\\tpw.println(-1);\\n\\t\\t\\t} else if (Math.abs(a - b) > 1) {\\n\\t\\t\\t\\tpw.println(-1);\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tif (a > b) {\\n\\t\\t\\t\\t\\tpw.print(1 + \\\" \\\");\\n\\t\\t\\t\\t\\tint i = 2;\\n\\t\\t\\t\\t\\tint j = n;\\n\\t\\t\\t\\t\\twhile (i < j) {\\n\\t\\t\\t\\t\\t\\tif (a == 1)\\n\\t\\t\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t\\t\\tpw.print(j + \\\" \\\");\\n\\t\\t\\t\\t\\t\\tpw.print(i + \\\" \\\");\\n\\t\\t\\t\\t\\t\\ta--;\\n\\t\\t\\t\\t\\t\\tj--;\\n\\t\\t\\t\\t\\t\\ti++;\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\tif (i < j) {\\n\\t\\t\\t\\t\\t\\tfor (int k = j; k >= i; k--) {\\n\\t\\t\\t\\t\\t\\t\\tpw.print(k + \\\" \\\");\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\tpw.println();\\n\\t\\t\\t\\t} else if (a < b) {\\n\\t\\t\\t\\t\\tpw.print(n + \\\" \\\");\\n\\t\\t\\t\\t\\tint i = 1;\\n\\t\\t\\t\\t\\tint j = n - 1;\\n\\t\\t\\t\\t\\twhile (i < j) {\\n\\t\\t\\t\\t\\t\\tif (b == 1)\\n\\t\\t\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t\\t\\tpw.print(i + \\\" \\\");\\n\\t\\t\\t\\t\\t\\tpw.print(j + \\\" \\\");\\n\\t\\t\\t\\t\\t\\tb--;\\n\\t\\t\\t\\t\\t\\tj--;\\n\\t\\t\\t\\t\\t\\ti++;\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\tif (i < j) {\\n\\t\\t\\t\\t\\t\\tfor (int k = i; k <= j; k++) {\\n\\t\\t\\t\\t\\t\\t\\tpw.print(k + \\\" \\\");\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\tpw.println();\\n\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\tpw.print(1 + \\\" \\\");\\n\\t\\t\\t\\t\\tint i = 2;\\n\\t\\t\\t\\t\\tint j = n;\\n\\t\\t\\t\\t\\twhile (i < j) {\\n\\t\\t\\t\\t\\t\\tif (a == 1)\\n\\t\\t\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t\\t\\tpw.print(j + \\\" \\\");\\n\\t\\t\\t\\t\\t\\tpw.print(i + \\\" \\\");\\n\\t\\t\\t\\t\\t\\ta--;\\n\\t\\t\\t\\t\\t\\tj--;\\n\\t\\t\\t\\t\\t\\ti++;\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\tpw.print(j + \\\" \\\");\\n\\t\\t\\t\\t\\tj--;\\n\\t\\t\\t\\t\\tif (i < j) {\\n\\t\\t\\t\\t\\t\\tfor (int k = i; k <= j; k++) {\\n\\t\\t\\t\\t\\t\\t\\tpw.print(k + \\\" \\\");\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\tpw.println();\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\tpw.close();\\n\\t}\\n\\n\\t\\/\\/ --------------------sTufF...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given a 1 by n pixel image. The i-th pixel of the image has color a_i. For each color, the number of pixels of that color is at most 20.\\n\\nYou can perform the following operation, which works like the bucket tool in paint programs, on this image: \\n\\n * pick a color — an integer from 1 to n; \\n * choose a pixel in the image; \\n * for all pixels connected to the selected pixel, change their colors to the selected color (two pixels of the same color are considered connected if all the pixels between them have the same color as those two pixels). \\n\\n\\n\\nCompute the minimum number of operations needed to make all the pixels in the image have the same color.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^3).\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 3⋅10^3) — the number of pixels in the image.\\n\\nThe second line of each test case contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ n) — the colors of the pixels in the image.\\n\\nNote: for each color, the number of pixels of that color is at most 20.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 3⋅10^3.\\n\\nOutput\\n\\nFor each test case, print one integer: the minimum number of operations needed to make all the pixels in the image have the same color.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n5\\n1 2 3 2 1\\n4\\n1 1 2 2\\n5\\n1 2 1 4 2\\n\\n\\nOutput\\n\\n\\n2\\n1\\n3\\n\\nNote\\n\\nIn the first example, the optimal solution is to apply the operation on the third pixel changing its color to 2 and then to apply the operation on any pixel that has color 2 changing its color and the color of all pixels connected to it to 1. The sequence of operations is then: [1, 2, 3, 2, 1] → [1, 2, 2, 2, 1] → [1, 1, 1, 1, 1].\\n\\nIn the second example, we can either change the 1s to 2s in one operation or change the 2s to 1s also in one operation.\\n\\nIn the third example, one possible way to make all the pixels have the same color is to apply the operation on the first, third and the fourth pixel each time changing its color to 2.\",\"targets\":\"#include \\nusing namespace std;\\nconstexpr int N = 3e3;\\nuint16_t a[N], lst[N], nxt[N], cnxt[19], dp[N][N];\\nint main() {\\n cin.tie(0), ios::sync_with_stdio(0);\\n int t, n;\\n cin >> t;\\n while (t--) {\\n cin >> n;\\n for (int i = 0; i < n; ++i) {\\n cin >> a[i], --a[i];\\n }\\n memset(lst, 0, n * sizeof *lst);\\n for (int i = 0; i < n; ++i) {\\n ++lst[a[i]];\\n }\\n int w = -1, r = 0, purged = 0;\\n while (r < n) {\\n if (w >= 0 && a[w] == a[r]) {\\n if (--lst[a[r++]] == 1) {\\n --w;\\n ++purged;\\n }\\n } else if (lst[a[r]] == 1) {\\n ++r;\\n ++purged;\\n } else {\\n a[++w] = a[r++];\\n }\\n }\\n memset(lst, -1, n * sizeof *lst);\\n n = w + 1;\\n memset(nxt, 127, n * sizeof *nxt);\\n for (int i = 0; i < n; ++i) {\\n if (lst[a[i]] != (uint16_t)-1) {\\n nxt[lst[a[i]]] = i;\\n }\\n lst[a[i]] = i;\\n }\\n for (int i = n - 1; i > -1; --i) {\\n auto* cnxte = cnxt;\\n for (int z = nxt[i]; z < n; z = nxt[z]) {\\n *cnxte++ = z;\\n }\\n cnxte = cnxt;\\n for (int j = i + 1; j < n; ++j) {\\n if (a[j] == a[i]) {\\n ++cnxte;\\n }\\n int t = dp[i + 1][j] - 1;\\n#pragma GCC unroll 19\\n for (const auto* z = cnxt; z != cnxte; ++z) {\\n t = max(t, dp[i + 1][*z - 1] + dp[*z][j]);\\n }\\n dp[i][j] = t + 1;\\n }\\n }\\n cout << (n ? n - dp[0][n - 1] : 0) - 1 + purged << '\\\\n';\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in PYTHON3?\\nThis is the easy version of the problem. The only difference between the two versions is the constraint on n. You can make hacks only if all versions of the problem are solved.\\n\\nA forest is an undirected graph without cycles (not necessarily connected).\\n\\nMocha and Diana are friends in Zhijiang, both of them have a forest with nodes numbered from 1 to n, and they would like to add edges to their forests such that: \\n\\n * After adding edges, both of their graphs are still forests. \\n * They add the same edges. That is, if an edge (u, v) is added to Mocha's forest, then an edge (u, v) is added to Diana's forest, and vice versa. \\n\\n\\n\\nMocha and Diana want to know the maximum number of edges they can add, and which edges to add.\\n\\nInput\\n\\nThe first line contains three integers n, m_1 and m_2 (1 ≤ n ≤ 1000, 0 ≤ m_1, m_2 < n) — the number of nodes and the number of initial edges in Mocha's forest and Diana's forest.\\n\\nEach of the next m_1 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the edges in Mocha's forest.\\n\\nEach of the next m_2 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the edges in Diana's forest.\\n\\nOutput\\n\\nThe first line contains only one integer h, the maximum number of edges Mocha and Diana can add (in each forest).\\n\\nEach of the next h lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the edge you add each time.\\n\\nIf there are multiple correct answers, you can print any one of them.\\n\\nExamples\\n\\nInput\\n\\n\\n3 2 2\\n1 2\\n2 3\\n1 2\\n1 3\\n\\n\\nOutput\\n\\n\\n0\\n\\n\\nInput\\n\\n\\n5 3 2\\n5 4\\n2 1\\n4 3\\n4 3\\n1 4\\n\\n\\nOutput\\n\\n\\n1\\n2 4\\n\\n\\nInput\\n\\n\\n8 1 2\\n1 7\\n2 6\\n1 5\\n\\n\\nOutput\\n\\n\\n5\\n5 2\\n2 3\\n3 4\\n4 7\\n6 8\\n\\nNote\\n\\nIn the first example, we cannot add any edge.\\n\\nIn the second example, the initial forests are as follows.\\n\\n\\n\\nWe can add an edge (2, 4).\\n\\n\",\"targets\":\"class DisjointSet:\\n def __init__(self, n):\\n self.__fa = [i for i in range(n + 1)]\\n self.__group = n\\n\\n def __father(self, u):\\n if self.__fa[u] == u:\\n return u\\n v = self.__father(self.__fa[u])\\n self.__fa[u] = v\\n return v\\n\\n def size(self):\\n return self.__group\\n\\n def same(self, u, v):\\n return self.__father(u) == self.__father(v)\\n\\n def add(self, u, v):\\n u = self.__father(u)\\n v = self.__father(v)\\n if u == v:\\n raise ValueError\\n self.__fa[u] = v\\n self.__group -= 1\\n\\n\\ndef main():\\n n, m1, m2 = [int(word) for word in input().strip().split()]\\n mocha = DisjointSet(n)\\n diana = DisjointSet(n)\\n for i in range(m1):\\n u, v = [int(word) for word in input().strip().split()]\\n mocha.add(u, v)\\n for i in range(m2):\\n u, v = [int(word) for word in input().strip().split()]\\n diana.add(u, v)\\n ans = []\\n flag = False\\n for i in range(1, n + 1):\\n if flag:\\n break\\n for j in range(i + 1, n + 1):\\n if mocha.same(i, j) or diana.same(i, j):\\n continue\\n mocha.add(i, j)\\n diana.add(i, j)\\n ans.append(str(i) + ' ' + str(j))\\n if mocha.size() == 1 or diana.size() == 1:\\n flag = True\\n break\\n print(len(ans))\\n for s in ans:\\n print(s)\\n\\n\\nif __name__ == \\\"__main__\\\":\\n main()\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Petya is a math teacher. n of his students has written a test consisting of m questions. For each student, it is known which questions he has answered correctly and which he has not.\\n\\nIf the student answers the j-th question correctly, he gets p_j points (otherwise, he gets 0 points). Moreover, the points for the questions are distributed in such a way that the array p is a permutation of numbers from 1 to m.\\n\\nFor the i-th student, Petya knows that he expects to get x_i points for the test. Petya wonders how unexpected the results could be. Petya believes that the surprise value of the results for students is equal to ∑_{i=1}^{n} |x_i - r_i|, where r_i is the number of points that the i-th student has got for the test.\\n\\nYour task is to help Petya find such a permutation p for which the surprise value of the results is maximum possible. If there are multiple answers, print any of them.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases.\\n\\nThe first line of each test case contains two integers n and m (1 ≤ n ≤ 10; 1 ≤ m ≤ 10^4) — the number of students and the number of questions, respectively.\\n\\nThe second line contains n integers x_1, x_2, ..., x_n (0 ≤ x_i ≤ (m(m+1))\\/(2)), where x_i is the number of points that the i-th student expects to get.\\n\\nThis is followed by n lines, the i-th line contains the string s_i (|s_i| = m; s_{i, j} ∈ \\\\{0, 1\\\\}), where s_{i, j} is 1 if the i-th student has answered the j-th question correctly, and 0 otherwise.\\n\\nThe sum of m for all test cases does not exceed 10^4.\\n\\nOutput\\n\\nFor each test case, print m integers — a permutation p for which the surprise value of the results is maximum possible. If there are multiple answers, print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n4 3\\n5 1 2 2\\n110\\n100\\n101\\n100\\n4 4\\n6 2 0 10\\n1001\\n0010\\n0110\\n0101\\n3 6\\n20 3 15\\n010110\\n000101\\n111111\\n\\n\\nOutput\\n\\n\\n3 1 2 \\n2 3 4 1 \\n3 1 4 5 2 6 \\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint x[10], re[10001], anss[10001];\\nstring s[10];\\npair h[10001];\\nint main() {\\n ios::sync_with_stdio(false);\\n cin.tie(NULL);\\n int T;\\n cin >> T;\\n while (T--) {\\n int n, m;\\n cin >> n >> m;\\n for (int i = 0; i < n; i++) cin >> x[i];\\n for (int i = 0; i < n; i++) cin >> s[i];\\n vector> b(m + 1);\\n for (int i = 1; i <= m; i++)\\n for (int j = 0; j < n; j++)\\n if (s[j][i - 1] == '1') b[i].push_back(j);\\n int ans = INT_MIN;\\n for (int bm = 0; bm < (1 << n); bm++) {\\n for (int i = 1; i <= m; i++) {\\n h[i].first = 0;\\n for (int &j : b[i])\\n h[i].first +=\\n ((bm >> j) & 1) ? (s[j][i - 1] - '0') : ('0' - s[j][i - 1]);\\n h[i].second = i;\\n }\\n int t = 0;\\n for (int i = 0; i < n; i++) t += ((bm >> i) & 1 ? -x[i] : x[i]);\\n sort(h + 1, h + m + 1);\\n for (int i = 1; i <= m; i++) t += h[i].first * i;\\n if (t > ans) {\\n ans = t;\\n for (int i = 1; i <= m; i++) anss[h[i].second] = i;\\n }\\n }\\n for (int i = 1; i <= m; i++) cout << anss[i] << ' ';\\n cout << '\\\\n';\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given n lengths of segments that need to be placed on an infinite axis with coordinates.\\n\\nThe first segment is placed on the axis so that one of its endpoints lies at the point with coordinate 0. Let's call this endpoint the \\\"start\\\" of the first segment and let's call its \\\"end\\\" as that endpoint that is not the start. \\n\\nThe \\\"start\\\" of each following segment must coincide with the \\\"end\\\" of the previous one. Thus, if the length of the next segment is d and the \\\"end\\\" of the previous one has the coordinate x, the segment can be placed either on the coordinates [x-d, x], and then the coordinate of its \\\"end\\\" is x - d, or on the coordinates [x, x+d], in which case its \\\"end\\\" coordinate is x + d.\\n\\nThe total coverage of the axis by these segments is defined as their overall union which is basically the set of points covered by at least one of the segments. It's easy to show that the coverage will also be a segment on the axis. Determine the minimal possible length of the coverage that can be obtained by placing all the segments on the axis without changing their order.\\n\\nInput\\n\\nThe first line contains an integer t (1 ≤ t ≤ 1000) — the number of test cases.\\n\\nThe next 2t lines contain descriptions of the test cases. \\n\\nThe first line of each test case description contains an integer n (1 ≤ n ≤ 10^4) — the number of segments. The second line of the description contains n space-separated integers a_i (1 ≤ a_i ≤ 1000) — lengths of the segments in the same order they should be placed on the axis.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 10^4.\\n\\nOutput\\n\\nPrint t lines, each line containing the answer to the corresponding test case. The answer to a test case should be a single integer — the minimal possible length of the axis coverage.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n2\\n1 3\\n3\\n1 2 3\\n4\\n6 2 3 9\\n4\\n6 8 4 5\\n7\\n1 2 4 6 7 7 3\\n8\\n8 6 5 1 2 2 3 6\\n\\n\\nOutput\\n\\n\\n3\\n3\\n9\\n9\\n7\\n8\\n\\nNote\\n\\nIn the third sample test case the segments should be arranged as follows: [0, 6] → [4, 6] → [4, 7] → [-2, 7]. As you can see, the last segment...\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nlong long get() {\\n char c = getchar();\\n long long x = 0LL;\\n while (c < '0' || c > '9') c = getchar();\\n while (c >= '0' && c <= '9') {\\n x *= 10LL;\\n x += (c - '0');\\n c = getchar();\\n }\\n return x;\\n}\\nstring i_t_s(int x) {\\n string t = \\\"\\\";\\n while (x) {\\n t += x % 10 + '0';\\n x \\/= 10;\\n }\\n reverse(t.begin(), t.end());\\n return t;\\n}\\nint s_t_i(string t) {\\n int x = 0;\\n for (int i = 0; i < (int)(t.size()); i++) {\\n x = x * 10 + (t[i] - '0');\\n }\\n return x;\\n}\\nlong long q_p(long long x, long long y) {\\n long long res = 1;\\n x %= 1000000007;\\n while (y) {\\n if (y % 2) {\\n res = res * x;\\n res %= 1000000007;\\n }\\n y \\/= 2;\\n x = x * x;\\n x %= 1000000007;\\n }\\n return res;\\n}\\nbool ok(int x, int y, int n, int m) {\\n return (x >= 0 && x < n && y >= 0 && y < m);\\n}\\nbool isprime(int x) {\\n if (x < 2) return false;\\n for (int i = 2; i * i <= x; i++)\\n if (x % i == 0) return false;\\n return true;\\n}\\nint dx[4] = {0, -1, 0, 1}, dy[4] = {1, 0, -1, 0};\\nint n;\\nint t;\\nint a[10001];\\nint dp[2][20001];\\nint main() {\\n ios::sync_with_stdio(0);\\n cin >> t;\\n while (t--) {\\n cin >> n;\\n for (int i = 0; i < n; i++) cin >> a[i];\\n for (int i = 0; i < 2; i++)\\n for (int j = 0; j < 20001; j++) dp[i][j] = 1e9;\\n dp[0][a[0]] = a[0];\\n dp[0][0] = a[0];\\n for (int i = 1; i < n; i++) {\\n for (int j = 0; j < 20001; j++) dp[i % 2][j] = 1e9;\\n for (int j = 0; j < 20001; j++) {\\n if (dp[(i - 1) % 2][j] == 1e9) continue;\\n dp[i % 2][j + a[i]] =\\n min(dp[i % 2][j + a[i]],\\n dp[(i - 1) % 2][j] + max(0, a[i] - dp[(i - 1) % 2][j] + j));\\n dp[i % 2][max(0, j - a[i])] = min(\\n dp[i % 2][max(0, j - a[i])], dp[(i - 1) % 2][j] + max(0, a[i] - j));\\n }\\n }\\n int ans = 1e9;\\n for (int i = 0; i < 20001; i++) {\\n ans = min(ans, dp[(n - 1) % 2][i]);\\n }\\n cout << ans << \\\"\\\\n\\\";\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Let's define S(x) to be the sum of digits of number x written in decimal system. For example, S(5) = 5, S(10) = 1, S(322) = 7.\\n\\nWe will call an integer x interesting if S(x + 1) < S(x). In each test you will be given one integer n. Your task is to calculate the number of integers x such that 1 ≤ x ≤ n and x is interesting.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 1000) — number of test cases.\\n\\nThen t lines follow, the i-th line contains one integer n (1 ≤ n ≤ 10^9) for the i-th test case.\\n\\nOutput\\n\\nPrint t integers, the i-th should be the answer for the i-th test case.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n1\\n9\\n10\\n34\\n880055535\\n\\n\\nOutput\\n\\n\\n0\\n1\\n1\\n3\\n88005553\\n\\nNote\\n\\nThe first interesting number is equal to 9.\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n long long int t;\\n cin >> t;\\n while (t--) {\\n long long int n;\\n cin >> n;\\n long long int x = n % 10;\\n cout << ((n == 9) ? 1 : (x == 9) ? n \\/ 10 + 1 : n \\/ 10) << endl;\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A coordinate line has n segments, the i-th segment starts at the position li and ends at the position ri. We will denote such a segment as [li, ri].\\n\\nYou have suggested that one of the defined segments covers all others. In other words, there is such segment in the given set, which contains all other ones. Now you want to test your assumption. Find in the given set the segment which covers all other segments, and print its number. If such a segment doesn't exist, print -1.\\n\\nFormally we will assume that segment [a, b] covers segment [c, d], if they meet this condition a ≤ c ≤ d ≤ b. \\n\\nInput\\n\\nThe first line contains integer n (1 ≤ n ≤ 105) — the number of segments. Next n lines contain the descriptions of the segments. The i-th line contains two space-separated integers li, ri (1 ≤ li ≤ ri ≤ 109) — the borders of the i-th segment.\\n\\nIt is guaranteed that no two segments coincide.\\n\\nOutput\\n\\nPrint a single integer — the number of the segment that covers all other segments in the set. If there's no solution, print -1.\\n\\nThe segments are numbered starting from 1 in the order in which they appear in the input.\\n\\nExamples\\n\\nInput\\n\\n3\\n1 1\\n2 2\\n3 3\\n\\n\\nOutput\\n\\n-1\\n\\n\\nInput\\n\\n6\\n1 5\\n2 3\\n1 10\\n7 10\\n7 7\\n10 10\\n\\n\\nOutput\\n\\n3\\nUsing python can you solve the prior task?\",\"targets\":\"n = input()\\narrSegments = []\\n\\nminLIndex, maxRIndex = [int(x) for x in raw_input().split()]\\narrSegments.append([minLIndex, maxRIndex])\\n\\nn = n - 1\\nfor i in range(n):\\n l,r = [int(x) for x in raw_input().split()]\\n if l < minLIndex:\\n minLIndex = l\\n if r > maxRIndex:\\n maxRIndex = r\\n arrSegments.append([l, r])\\n\\nindex = 1\\nfor segment in arrSegments:\\n if segment[0] == minLIndex and segment[1] == maxRIndex:\\n print(index)\\n exit(0)\\n index = index + 1\\n\\nprint(-1)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given two positive integers n and s. Find the maximum possible median of an array of n non-negative integers (not necessarily distinct), such that the sum of its elements is equal to s.\\n\\nA median of an array of integers of length m is the number standing on the ⌈ {m\\/2} ⌉-th (rounding up) position in the non-decreasing ordering of its elements. Positions are numbered starting from 1. For example, a median of the array [20,40,20,50,50,30] is the ⌈ m\\/2 ⌉-th element of [20,20,30,40,50,50], so it is 30. There exist other definitions of the median, but in this problem we use the described definition.\\n\\nInput\\n\\nThe input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. Description of the test cases follows.\\n\\nEach test case contains a single line with two integers n and s (1 ≤ n, s ≤ 10^9) — the length of the array and the required sum of the elements.\\n\\nOutput\\n\\nFor each test case print a single integer — the maximum possible median.\\n\\nExample\\n\\nInput\\n\\n\\n8\\n1 5\\n2 5\\n3 5\\n2 1\\n7 17\\n4 14\\n1 1000000000\\n1000000000 1\\n\\n\\nOutput\\n\\n\\n5\\n2\\n2\\n0\\n4\\n4\\n1000000000\\n0\\n\\nNote\\n\\nPossible arrays for the first three test cases (in each array the median is underlined):\\n\\n * In the first test case [\\\\underline{5}] \\n * In the second test case [\\\\underline{2}, 3] \\n * In the third test case [1, \\\\underline{2}, 2] \\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"t=int(input())\\nfor _ in range(t):\\n n,s=map(int,input().split())\\n print(s\\/\\/((n\\/\\/2)+1))\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Stephen Queen wants to write a story. He is a very unusual writer, he uses only letters 'a', 'b', 'c', 'd' and 'e'!\\n\\nTo compose a story, Stephen wrote out n words consisting of the first 5 lowercase letters of the Latin alphabet. He wants to select the maximum number of words to make an interesting story.\\n\\nLet a story be a sequence of words that are not necessarily different. A story is called interesting if there exists a letter which occurs among all words of the story more times than all other letters together.\\n\\nFor example, the story consisting of three words \\\"bac\\\", \\\"aaada\\\", \\\"e\\\" is interesting (the letter 'a' occurs 5 times, all other letters occur 4 times in total). But the story consisting of two words \\\"aba\\\", \\\"abcde\\\" is not (no such letter that it occurs more than all other letters in total).\\n\\nYou are given a sequence of n words consisting of letters 'a', 'b', 'c', 'd' and 'e'. Your task is to choose the maximum number of them to make an interesting story. If there's no way to make a non-empty story, output 0.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 5000) — the number of test cases. Then t test cases follow.\\n\\nThe first line of each test case contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of the words in the sequence. Then n lines follow, each of them contains a word — a non-empty string consisting of lowercase letters of the Latin alphabet. The words in the sequence may be non-distinct (i. e. duplicates are allowed). Only the letters 'a', 'b', 'c', 'd' and 'e' may occur in the words.\\n\\nIt is guaranteed that the sum of n over all test cases doesn't exceed 2 ⋅ 10^5; the sum of the lengths of all words over all test cases doesn't exceed 4 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, output the maximum number of words that compose an interesting story. Print 0 if there's no way to make a non-empty interesting story.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n3\\nbac\\naaada\\ne\\n3\\naba\\nabcde\\naba\\n2\\nbaba\\nbaba\\n4\\nab\\nab\\nc\\nbc\\n5\\ncbdca\\nd\\na\\nd\\ne\\n3\\nb\\nc\\nca\\n\\n\\nOutput\\n\\n\\n3\\n2\\n0\\n2\\n3\\n2\\n\\nNote\\n\\nIn the first test case of the example, all 3 words...\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nlong long freq_str(string s, char c) {\\n long long cunt = 0;\\n for (int i = 0; i < s.length(); i++) {\\n if (s[i] == c) cunt++;\\n }\\n return (cunt - (s.length() - cunt));\\n}\\nvoid solve() {\\n long long n, longest_string, cunt, ans = 0;\\n cin >> n;\\n vector v(n);\\n for (int i = 0; i < n; i++) {\\n cin >> v[i];\\n }\\n for (char c = 'a'; c <= 'e'; c++) {\\n vector fs(n);\\n for (int i = 0; i < n; i++) {\\n fs[i] = freq_str(v[i], c);\\n }\\n sort(fs.begin(), fs.end(), greater());\\n cunt = 0;\\n longest_string = 0;\\n for (int j = 0; j < n; j++) {\\n longest_string += fs[j];\\n if (longest_string > 0) {\\n cunt++;\\n } else\\n break;\\n }\\n ans = max(ans, cunt);\\n }\\n cout << ans << endl;\\n}\\nint main() {\\n int t;\\n cin >> t;\\n while (t--) {\\n solve();\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Frodo was caught by Saruman. He tore a pouch from Frodo's neck, shook out its contents —there was a pile of different rings: gold and silver...\\n\\n\\\"How am I to tell which is the One?!\\\" the mage howled.\\n\\n\\\"Throw them one by one into the Cracks of Doom and watch when Mordor falls!\\\" \\n\\nSomewhere in a parallel Middle-earth, when Saruman caught Frodo, he only found n rings. And the i-th ring was either gold or silver. For convenience Saruman wrote down a binary string s of n characters, where the i-th character was 0 if the i-th ring was gold, and 1 if it was silver.\\n\\nSaruman has a magic function f, which takes a binary string and returns a number obtained by converting the string into a binary number and then converting the binary number into a decimal number. For example, f(001010) = 10, f(111) = 7, f(11011101) = 221.\\n\\nSaruman, however, thinks that the order of the rings plays some important role. He wants to find 2 pairs of integers (l_1, r_1), (l_2, r_2), such that:\\n\\n * 1 ≤ l_1 ≤ n, 1 ≤ r_1 ≤ n, r_1-l_1+1≥ ⌊ n\\/2 ⌋ \\n * 1 ≤ l_2 ≤ n, 1 ≤ r_2 ≤ n, r_2-l_2+1≥ ⌊ n\\/2 ⌋ \\n * Pairs (l_1, r_1) and (l_2, r_2) are distinct. That is, at least one of l_1 ≠ l_2 and r_1 ≠ r_2 must hold.\\n * Let t be the substring s[l_1:r_1] of s, and w be the substring s[l_2:r_2] of s. Then there exists non-negative integer k, such that f(t) = f(w) ⋅ k.\\n\\n\\n\\nHere substring s[l:r] denotes s_ls_{l+1}… s_{r-1}s_r, and ⌊ x ⌋ denotes rounding the number down to the nearest integer.\\n\\nHelp Saruman solve this problem! It is guaranteed that under the constraints of the problem at least one solution exists.\\n\\nInput\\n\\nEach test contains multiple test cases.\\n\\nThe first line contains one positive integer t (1 ≤ t ≤ 10^3), denoting the number of test cases. Description of the test cases follows.\\n\\nThe first line of each test case contains one positive integer n (2 ≤ n ≤ 2 ⋅ 10^4) — length of the string.\\n\\nThe second line of each test case contains a non-empty binary string of length n.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nlong long int mod(long long int x, long long int m) { return (x % m + m) % m; }\\nlong long int gcd(long long int a, long long int b) {\\n if (b == 0) return a;\\n a %= b;\\n return gcd(b, a);\\n}\\nlong long int fast_exp(long long int base, long long int exp) {\\n long long int res = 1;\\n while (exp > 0) {\\n if (exp % 2 == 1) res = (res * base) % 1000000007;\\n base = (base * base) % 1000000007;\\n exp \\/= 2;\\n }\\n return res % 1000000007;\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n long long int t = 1, r, n, a, d, c, b, x, y, sum, cnt, i, j, k, m, l, q, maxx,\\n minn, temp, ans, flag, g, ts;\\n long long int mod = 1000000007;\\n char ch, chh;\\n double dans;\\n string str, ttr;\\n cin >> t;\\n for (ts = 1; ts <= t; ts++) {\\n flag = 0;\\n sum = 0;\\n cnt = 0;\\n ans = 0;\\n k = 0;\\n maxx = 0;\\n minn = 0;\\n a = 0;\\n b = 0;\\n temp = 0;\\n cin >> n >> str;\\n for (i = 0; i < (n) \\/ 2; i++) {\\n if (str[i] == '0') {\\n flag = 1;\\n ans = i;\\n break;\\n }\\n }\\n if (flag == 1) {\\n cout << ans + 1 << \\\" \\\" << n << \\\" \\\";\\n cout << ans + 2 << \\\" \\\" << n;\\n } else {\\n flag = 0;\\n for (i = ((n - 1) \\/ 2) + 1; i < n; i++) {\\n if (str[i] == '0') {\\n flag = 1;\\n ans = i;\\n break;\\n }\\n }\\n if (flag == 1) {\\n cout << 1 << \\\" \\\" << ans + 1 << \\\" \\\";\\n cout << 1 << \\\" \\\" << ans;\\n } else if (n % 2 == 1 && str[n \\/ 2] == '0') {\\n cout << \\\"1 \\\" << (n + 1) \\/ 2 << \\\" \\\";\\n cout << (n + 1) \\/ 2 << \\\" \\\" << n;\\n } else {\\n cout << \\\"1 \\\" << n - 1 << \\\" \\\";\\n cout << \\\"2 \\\" << n;\\n }\\n }\\n cout << \\\"\\\\n\\\";\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Ashish has an array a of consisting of 2n positive integers. He wants to compress a into an array b of size n-1. To do this, he first discards exactly 2 (any two) elements from a. He then performs the following operation until there are no elements left in a: \\n\\n * Remove any two elements from a and append their sum to b. \\n\\n\\n\\nThe compressed array b has to have a special property. The greatest common divisor (gcd) of all its elements should be greater than 1.\\n\\nRecall that the gcd of an array of positive integers is the biggest integer that is a divisor of all integers in the array.\\n\\nIt can be proven that it is always possible to compress array a into an array b of size n-1 such that gcd(b_1, b_2..., b_{n-1}) > 1. \\n\\nHelp Ashish find a way to do so.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10) — the number of test cases. The description of the test cases follows.\\n\\nThe first line of each test case contains a single integer n (2 ≤ n ≤ 1000).\\n\\nThe second line of each test case contains 2n integers a_1, a_2, …, a_{2n} (1 ≤ a_i ≤ 1000) — the elements of the array a.\\n\\nOutput\\n\\nFor each test case, output n-1 lines — the operations performed to compress the array a to the array b. The initial discard of the two elements is not an operation, you don't need to output anything about it.\\n\\nThe i-th line should contain two integers, the indices (1 —based) of the two elements from the array a that are used in the i-th operation. All 2n-2 indices should be distinct integers from 1 to 2n.\\n\\nYou don't need to output two initially discarded elements from a.\\n\\nIf there are multiple answers, you can find any.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n3\\n1 2 3 4 5 6\\n2\\n5 7 9 10\\n5\\n1 3 3 4 5 90 100 101 2 3\\n\\n\\nOutput\\n\\n\\n3 6\\n4 5\\n3 4\\n1 9\\n2 3\\n4 5\\n6 10\\n\\nNote\\n\\nIn the first test case, b = \\\\{3+6, 4+5\\\\} = \\\\{9, 9\\\\} and gcd(9, 9) = 9.\\n\\nIn the second test case, b = \\\\{9+10\\\\} = \\\\{19\\\\} and gcd(19) = 19.\\n\\nIn the third test case, b = \\\\{1+2, 3+3, 4+5, 90+3\\\\} = \\\\{3, 6, 9, 93\\\\} and gcd(3, 6, 9, 93) = 3.\\n\\/\\/Thi\",\"targets\":\"s code is written by प्रविण शंखपाळ \\n\\n\\/\\/package wizard;\\n\\nimport java.io.BufferedReader;\\nimport java.io.BufferedWriter;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.io.OutputStreamWriter;\\nimport java.text.DecimalFormat;\\nimport java.util.Collections;\\nimport java.util.Comparator;\\nimport java.util.Arrays;\\nimport java.util.ArrayList;\\nimport java.util.LinkedList;\\nimport java.util.Stack;\\nimport java.util.Queue;\\nimport java.util.PriorityQueue;\\nimport java.util.List;\\nimport java.util.HashSet;\\nimport java.util.LinkedHashSet;\\nimport java.util.TreeSet;\\nimport java.util.Map;\\nimport java.util.HashMap;\\nimport java.util.Scanner;\\nimport java.util.Set;\\nimport java.util.StringTokenizer;\\nimport java.util.Vector;\\n\\npublic class Luna_Lovegood {\\n\\n\\tpublic static void main(String[] args) {\\n\\n\\t\\ttry {\\n\\n\\t\\tFastReader fr = new FastReader();\\n\\t\\tBufferedWriter output = new BufferedWriter(new OutputStreamWriter(System.out));\\n\\n\\t\\tint t = fr.nextInt();\\n\\n\\t\\twhile (t > 0) {\\n\\n\\t\\t\\tint n = fr.nextInt();\\n\\n\\t\\t\\tn *= 2;\\n\\n\\t\\t\\tint A[] = new int[n];\\n\\n\\t\\t\\tfor (int i = 0; i < n; i++) {\\n\\n\\t\\t\\t\\tA[i] = fr.nextInt();\\n\\n\\t\\t\\t}\\n\\n\\t\\t\\tArrayList x = new ArrayList<>();\\n\\n\\t\\t\\tfor (int i = 0; i < n; i++) {\\n\\n\\t\\t\\t\\tif (A[i] % 2 == 0) {\\n\\n\\t\\t\\t\\t\\tfor (int j = i + 1; j < n; j++) {\\n\\n\\t\\t\\t\\t\\t\\tif (A[j] % 2 == 0) {\\n\\n\\t\\t\\t\\t\\t\\t\\tx.add(i);\\n\\t\\t\\t\\t\\t\\t\\tx.add(j);\\n\\t\\t\\t\\t\\t\\t\\ti = j;\\n\\t\\t\\t\\t\\t\\t\\tbreak;\\n\\n\\t\\t\\t\\t\\t\\t}\\n\\n\\t\\t\\t\\t\\t}\\n\\n\\t\\t\\t\\t}\\n\\n\\t\\t\\t}\\n\\n\\t\\t\\tfor (int i = 0; i < n; i++) {\\n\\n\\t\\t\\t\\tif (A[i] % 2 == 1) {\\n\\n\\t\\t\\t\\t\\tfor (int j = i + 1; j < n; j++) {\\n\\n\\t\\t\\t\\t\\t\\tif (A[j] % 2 == 1) {\\n\\n\\t\\t\\t\\t\\t\\t\\tx.add(i);\\n\\t\\t\\t\\t\\t\\t\\tx.add(j);\\n\\t\\t\\t\\t\\t\\t\\ti = j;\\n\\t\\t\\t\\t\\t\\t\\tbreak;\\n\\n\\t\\t\\t\\t\\t\\t}\\n\\n\\t\\t\\t\\t\\t}\\n\\n\\t\\t\\t\\t}\\n\\n\\t\\t\\t}\\n\\n\\t\\t\\tif (x.size() == n) {\\n\\n\\t\\t\\t\\tfor (int i = 0; i < n - 2; i += 2) {\\n\\n\\t\\t\\t\\t\\tSystem.out.println((x.get(i) + 1) + \\\" \\\" + (x.get(i + 1) + 1));\\n\\n\\t\\t\\t\\t}\\n\\n\\t\\t\\t} else {\\n\\n\\t\\t\\t\\tfor (int i = 0; i < x.size() - 1; i += 2) {\\n\\n\\t\\t\\t\\t\\tSystem.out.println((x.get(i) + 1) + \\\" \\\" + (x.get(i + 1) + 1));\\n\\n\\t\\t\\t\\t}\\n\\n\\t\\t\\t}\\n\\n\\t\\t\\tt--;\\n\\t\\t}\\n\\n\\t} catch (\\n\\n\\tException e) {\\n\\t\\treturn;\\n\\t}\\n\\t}\\n\\n\\tstatic void merge(int arr[], int l, int m, int r) {\\n\\n\\t\\tint n1 = m - l + 1;\\n\\t\\tint n2 = r - m;\\n\\n\\t\\tint L[]...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alice and Bob play a game. They have a binary string s (a string such that each character in it is either 0 or 1). Alice moves first, then Bob, then Alice again, and so on.\\n\\nDuring their move, the player can choose any number (not less than one) of consecutive equal characters in s and delete them.\\n\\nFor example, if the string is 10110, there are 6 possible moves (deleted characters are bold):\\n\\n 1. 10110 → 0110; \\n 2. 10110 → 1110; \\n 3. 10110 → 1010; \\n 4. 10110 → 1010; \\n 5. 10110 → 100; \\n 6. 10110 → 1011. \\n\\n\\n\\nAfter the characters are removed, the characters to the left and to the right of the removed block become adjacent. I. e. the following sequence of moves is valid: 10110 → 100 → 1.\\n\\nThe game ends when the string becomes empty, and the score of each player is the number of 1-characters deleted by them.\\n\\nEach player wants to maximize their score. Calculate the resulting score of Alice.\\n\\nInput\\n\\nThe first line contains one integer T (1 ≤ T ≤ 500) — the number of test cases.\\n\\nEach test case contains exactly one line containing a binary string s (1 ≤ |s| ≤ 100).\\n\\nOutput\\n\\nFor each test case, print one integer — the resulting score of Alice (the number of 1-characters deleted by her).\\n\\nExample\\n\\nInput\\n\\n\\n5\\n01111001\\n0000\\n111111\\n101010101\\n011011110111\\n\\n\\nOutput\\n\\n\\n4\\n0\\n6\\n3\\n6\\n\\nNote\\n\\nQuestions about the optimal strategy will be ignored.\\nimpor\",\"targets\":\"t java.io.*;\\nimport java.util.*;\\npublic class EDU93B {\\n\\n\\tpublic static void main(String[] args) {\\n\\t\\tJS scan = new JS();\\n\\t\\tint t = scan.nextInt();\\n\\t\\twhile(t-->0) {\\n\\t\\t\\tchar[] a = scan.next().toCharArray();\\n\\t\\t\\tint n = a.length;\\n\\t\\t\\tint[] ans = {0,0};\\n\\t\\t\\tint turn = 0;\\n\\t\\t\\tloop:while(true) {\\n\\t\\t\\t\\tint idx = 0;\\n\\t\\t\\t\\tint length = 0;\\n\\t\\t\\t\\tfor(int i = 0;ilength) {\\n\\t\\t\\t\\t\\t\\t\\tidx = i;\\n\\t\\t\\t\\t\\t\\t\\tlength = streak;\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tans[turn]+=length;\\n\\t\\t\\t\\tturn^=1;\\n\\t\\t\\t\\tfor(int i = idx;i'9'); c = nextChar()) {\\n\\t\\t\\t\\tif(c=='-')neg=true;\\n\\t\\t\\t}\\n\\t\\t\\tlong res = 0;\\n\\t\\t\\tfor(; c>='0' && c <='9'; c=nextChar()) {\\n\\t\\t\\t\\tres = (res<<3)+(res<<1)+c-'0';\\n\\t\\t\\t\\tnum*=10;\\n\\t\\t\\t}\\n\\t\\t\\treturn neg?-res:res;\\n\\t\\t}\\n\\n\\t\\tpublic double nextDouble() {\\n\\t\\t\\tdouble cur = nextLong();\\n\\t\\t\\treturn c!='.' ? cur:cur+nextLong()\\/num;\\n\\t\\t}\\n\\n\\t\\tpublic String next() {\\n\\t\\t\\tStringBuilder res = new StringBuilder();\\n\\t\\t\\twhile(c<=32)c=nextChar();\\n\\t\\t\\twhile(c>32) {\\n\\t\\t\\t\\tres.append(c);\\n\\t\\t\\t\\tc=nextChar();\\n\\t\\t\\t}\\n\\t\\t\\treturn...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Polycarp has found a table having an infinite number of rows and columns. The rows are numbered from 1, starting from the topmost one. The columns are numbered from 1, starting from the leftmost one.\\n\\nInitially, the table hasn't been filled and Polycarp wants to fix it. He writes integers from 1 and so on to the table as follows.\\n\\n The figure shows the placement of the numbers from 1 to 10. The following actions are denoted by the arrows.\\n\\nThe leftmost topmost cell of the table is filled with the number 1. Then he writes in the table all positive integers beginning from 2 sequentially using the following algorithm.\\n\\nFirst, Polycarp selects the leftmost non-filled cell in the first row and fills it. Then, while the left neighbor of the last filled cell is filled, he goes down and fills the next cell. So he goes down until the last filled cell has a non-filled neighbor to the left (look at the vertical arrow going down in the figure above).\\n\\nAfter that, he fills the cells from the right to the left until he stops at the first column (look at the horizontal row in the figure above). Then Polycarp selects the leftmost non-filled cell in the first row, goes down, and so on.\\n\\nA friend of Polycarp has a favorite number k. He wants to know which cell will contain the number. Help him to find the indices of the row and the column, such that the intersection of the row and the column is the cell containing the number k.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 100) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one line containing one integer k (1 ≤ k ≤ 10^9) which location must be found.\\n\\nOutput\\n\\nFor each test case, output in a separate line two integers r and c (r, c ≥ 1) separated by spaces — the indices of the row and the column containing the cell filled by the number k, respectively.\\n\\nExample\\n\\nInput\\n\\n\\n7\\n11\\n14\\n5\\n4\\n1\\n2\\n1000000000\\n\\n\\nOutput\\n\\n\\n2 4\\n4 3\\n1 3\\n2 1\\n1 1\\n1 2\\n31623 14130\\nSolve the task in PYTHON3.\",\"targets\":\"import sys\\ninput=sys.stdin.readline\\n\\nt=int(input())\\nfor i in range(t):\\n n=int(input())\\n x=int(n**(1\\/2))\\n a=n-x*x\\n if a==0:\\n print(x,1)\\n continue\\n x+=1\\n if a<=x:\\n print(a,x)\\n else:\\n print(x,x*2-a)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Stephen Queen wants to write a story. He is a very unusual writer, he uses only letters 'a', 'b', 'c', 'd' and 'e'!\\n\\nTo compose a story, Stephen wrote out n words consisting of the first 5 lowercase letters of the Latin alphabet. He wants to select the maximum number of words to make an interesting story.\\n\\nLet a story be a sequence of words that are not necessarily different. A story is called interesting if there exists a letter which occurs among all words of the story more times than all other letters together.\\n\\nFor example, the story consisting of three words \\\"bac\\\", \\\"aaada\\\", \\\"e\\\" is interesting (the letter 'a' occurs 5 times, all other letters occur 4 times in total). But the story consisting of two words \\\"aba\\\", \\\"abcde\\\" is not (no such letter that it occurs more than all other letters in total).\\n\\nYou are given a sequence of n words consisting of letters 'a', 'b', 'c', 'd' and 'e'. Your task is to choose the maximum number of them to make an interesting story. If there's no way to make a non-empty story, output 0.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 5000) — the number of test cases. Then t test cases follow.\\n\\nThe first line of each test case contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of the words in the sequence. Then n lines follow, each of them contains a word — a non-empty string consisting of lowercase letters of the Latin alphabet. The words in the sequence may be non-distinct (i. e. duplicates are allowed). Only the letters 'a', 'b', 'c', 'd' and 'e' may occur in the words.\\n\\nIt is guaranteed that the sum of n over all test cases doesn't exceed 2 ⋅ 10^5; the sum of the lengths of all words over all test cases doesn't exceed 4 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, output the maximum number of words that compose an interesting story. Print 0 if there's no way to make a non-empty interesting story.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n3\\nbac\\naaada\\ne\\n3\\naba\\nabcde\\naba\\n2\\nbaba\\nbaba\\n4\\nab\\nab\\nc\\nbc\\n5\\ncbdca\\nd\\na\\nd\\ne\\n3\\nb\\nc\\nca\\n\\n\\nOutput\\n\\n\\n3\\n2\\n0\\n2\\n3\\n2\\n\\nNote\\n\\nIn the first test case of the example, all 3 words...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\ntemplate \\nstruct rge {\\n c b, e;\\n};\\ntemplate \\nrge range(c i, c j) {\\n return rge{i, j};\\n}\\ntemplate \\nauto dud(c* x) -> decltype(cerr << *x, 0);\\ntemplate \\nchar dud(...);\\nstruct debug {\\n template \\n debug& operator<<(const c&) {\\n return *this;\\n }\\n};\\nconst double pi = acosl(-1);\\nvoid solve() {\\n long long n;\\n cin >> n;\\n vector a(n);\\n for (long long i = 0; i < (n); i++) {\\n cin >> a[i];\\n }\\n long long ans = 0;\\n for (char c : {'a', 'b', 'c', 'd', 'e'}) {\\n vector> temp;\\n for (long long i = 0; i < (n); i++) {\\n long long count = 0;\\n for (auto x : a[i]) {\\n count += (x == c);\\n }\\n temp.push_back({(long long)a[i].size() - 2 * count, count, i});\\n }\\n long long first = 0;\\n long long second = 0;\\n sort(temp.begin(), temp.end());\\n for (long long i = 0; i < (n); i++) {\\n first += temp[i][1];\\n second += temp[i][0] + temp[i][1];\\n if (first > second) ans = max(ans, i + 1);\\n }\\n }\\n cout << ans << '\\\\n';\\n}\\nsigned main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n long long tt = 1;\\n cin >> tt;\\n while (tt--) {\\n solve();\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Even polar bears feel cold when lying on the ice. Therefore, a polar bear Alice is going to make a carpet. The carpet can be viewed as a grid with height h and width w. Then the grid is divided into h × w squares. Alice is going to assign one of k different colors to each square. The colors are numbered from 1 to k. She may choose not to use all of the colors.\\n\\nHowever, there are some restrictions. For every two adjacent squares (squares that shares an edge) x and y, there is a color constraint in one of the forms: \\n\\n * color(x) = color(y), or \\n * color(x) ≠ color(y). \\n\\n\\n\\nExample of the color constraints:\\n\\n\\n\\nIdeally, Alice wants to satisfy all color constraints. But again, life in the Arctic is hard. It is not always possible to satisfy all color constraints. Fortunately, she will still be happy if at least of the color constraints are satisfied. \\n\\nIf she has 4 colors she can color the carpet in the following way:\\n\\n\\n\\nAnd she is happy because of the color constraints are satisfied, and . Your task is to help her color the carpet.\\n\\nInput\\n\\nThe first line contains three integers h, w, k (2 ≤ h, w ≤ 1000, 1 ≤ k ≤ w·h).\\n\\nThe next 2h - 1 lines describe the color constraints from top to bottom, left to right. They contain w - 1, w, w - 1, w, ..., w - 1 characters respectively. Each color constraint is represented by a character \\\"E\\\" or \\\"N\\\", where \\\"E\\\" means \\\" = \\\" and \\\"N\\\" means \\\" ≠ \\\".\\n\\nThe color constraints listed in the order they are depicted on the picture.\\n\\nOutput\\n\\nIf there is a coloring that satisfies at least of the color constraints, print \\\"YES\\\" (without quotes) in the first line. In each of the next h lines, print w integers describing the coloring.\\n\\nOtherwise, print \\\"NO\\\" (without quotes).\\n\\nExamples\\n\\nInput\\n\\n3 4 4\\nENE\\nNNEE\\nNEE\\nENEN\\nENN\\n\\n\\nOutput\\n\\nYES\\n1 1 2 2\\n3 4 1 1\\n3 3 2 4\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nint h, w, k;\\nchar data[2][1024][1024];\\nchar (*hrule)[1024], (*vrule)[1024];\\nint carpet[1024][1024];\\nint main() {\\n scanf(\\\"%d%d%d\\\", &h, &w, &k);\\n hrule = data[0];\\n vrule = data[1];\\n if (k == 1) {\\n int cnt = 0;\\n for (int i = 0; i < 2 * h - 1; ++i) {\\n scanf(\\\"%s\\\", hrule[i]);\\n for (int j = 0; hrule[i][j]; ++j)\\n if (hrule[i][j] == 'E') ++cnt;\\n }\\n if (4 * cnt >= 3 * (w * (h - 1) + (w - 1) * h)) {\\n puts(\\\"YES\\\");\\n for (int i = 0; i < h; ++i) {\\n for (int j = 0; j < w; ++j) {\\n putchar('1');\\n putchar(' ');\\n }\\n putchar('\\\\n');\\n }\\n } else {\\n puts(\\\"NO\\\");\\n }\\n return 0;\\n }\\n for (int i = 0; i < 2 * h - 1; ++i) {\\n if (i % 2 == 0) {\\n scanf(\\\"%s\\\", hrule[i \\/ 2]);\\n } else {\\n scanf(\\\"%s\\\", vrule[(i - 1) \\/ 2]);\\n }\\n }\\n bool flipped = false;\\n if (h > w) {\\n for (int i = 0; i < h; ++i)\\n for (int j = 0; j < w - 1; ++j) {\\n if (j < i || j >= h) swap(hrule[i][j], hrule[j][i]);\\n }\\n for (int i = 0; i < h - 1; ++i)\\n for (int j = 0; j < w; ++j) {\\n if (j < i || j >= h - 1) swap(vrule[i][j], vrule[j][i]);\\n }\\n swap(hrule, vrule);\\n swap(w, h);\\n flipped = true;\\n }\\n carpet[0][0] = 0;\\n for (int i = 1; i < w; ++i) {\\n if (hrule[0][i - 1] == 'N') {\\n carpet[0][i] = !carpet[0][i - 1];\\n } else {\\n carpet[0][i] = carpet[0][i - 1];\\n }\\n }\\n for (int i = 1; i < h; ++i) {\\n carpet[i][0] = 0;\\n for (int j = 1; j < w; ++j) {\\n if (hrule[i][j - 1] == 'N') {\\n carpet[i][j] = !carpet[i][j - 1];\\n } else {\\n carpet[i][j] = carpet[i][j - 1];\\n }\\n }\\n int cnt = 0;\\n for (int j = 0; j < w; ++j) {\\n if (carpet[i][j] == carpet[i - 1][j] && vrule[i - 1][j] == 'E' ||\\n carpet[i][j] != carpet[i - 1][j] && vrule[i - 1][j] == 'N')\\n ++cnt;\\n }\\n if (cnt * 2 < w) {\\n for (int j = 0; j < w; ++j) carpet[i][j] = !carpet[i][j];\\n }\\n }\\n if (flipped) {\\n for (int i = 0; i < h; ++i)\\n for...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"N Snukes called Snuke 1, Snuke 2, ..., Snuke N live in a town.\\n\\nThere are K kinds of snacks sold in this town, called Snack 1, Snack 2, ..., Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2}, \\\\cdots, A_{i, {d_i}}.\\n\\nTakahashi will walk around this town and make mischief on the Snukes who have no snacks. How many Snukes will fall victim to Takahashi's mischief?\\n\\nConstraints\\n\\n* All values in input are integers.\\n* 1 \\\\leq N \\\\leq 100\\n* 1 \\\\leq K \\\\leq 100\\n* 1 \\\\leq d_i \\\\leq N\\n* 1 \\\\leq A_{i, 1} < \\\\cdots < A_{i, d_i} \\\\leq N\\n\\nInput\\n\\nInput is given from Standard Input in the following format:\\n\\n\\nN K\\nd_1\\nA_{1, 1} \\\\cdots A_{1, d_1}\\n\\\\vdots\\nd_K\\nA_{K, 1} \\\\cdots A_{K, d_K}\\n\\n\\nOutput\\n\\nPrint the answer.\\n\\nExamples\\n\\nInput\\n\\n3 2\\n2\\n1 3\\n1\\n3\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\n3 3\\n1\\n3\\n1\\n3\\n1\\n3\\n\\n\\nOutput\\n\\n2\\\":\",\"targets\":\"#include \\nint cnt[105],tot;\\nint main(){\\n\\tint n,k,m,i,j,a;\\n\\tscanf(\\\"%d%d\\\",&n,&k);\\n\\tfor(i=1;i<=k;i++){\\n\\t\\tscanf(\\\"%d\\\",&m);\\n\\t\\tfor(j=1;j<=m;j++){\\n\\t\\t\\tscanf(\\\"%d\\\",&a);\\n\\t\\t\\tcnt[a]++;\\n\\t\\t}\\n\\t}\\t\\n\\tfor(i=1;i<=n;i++)\\n\\t\\tif(cnt[i])tot++;\\n\\tprintf(\\\"%d\\\\n\\\",n-tot);\\n\\treturn 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"There are n block towers in a row, where tower i has a height of a_i. You're part of a building crew, and you want to make the buildings look as nice as possible. In a single day, you can perform the following operation:\\n\\n * Choose two indices i and j (1 ≤ i, j ≤ n; i ≠ j), and move a block from tower i to tower j. This essentially decreases a_i by 1 and increases a_j by 1. \\n\\n\\n\\nYou think the ugliness of the buildings is the height difference between the tallest and shortest buildings. Formally, the ugliness is defined as max(a)-min(a). \\n\\nWhat's the minimum possible ugliness you can achieve, after any number of days?\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 1000) — the number of test cases. Then t cases follow.\\n\\nThe first line of each test case contains one integer n (2 ≤ n ≤ 100) — the number of buildings.\\n\\nThe second line of each test case contains n space separated integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^7) — the heights of the buildings.\\n\\nOutput\\n\\nFor each test case, output a single integer — the minimum possible ugliness of the buildings.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n3\\n10 10 10\\n4\\n3 2 1 2\\n5\\n1 2 3 1 5\\n\\n\\nOutput\\n\\n\\n0\\n0\\n1\\n\\nNote\\n\\nIn the first test case, the ugliness is already 0.\\n\\nIn the second test case, you should do one operation, with i = 1 and j = 3. The new heights will now be [2, 2, 2, 2], with an ugliness of 0.\\n\\nIn the third test case, you may do three operations: \\n\\n 1. with i = 3 and j = 1. The new array will now be [2, 2, 2, 1, 5], \\n 2. with i = 5 and j = 4. The new array will now be [2, 2, 2, 2, 4], \\n 3. with i = 5 and j = 3. The new array will now be [2, 2, 3, 2, 3]. \\n\\nThe resulting ugliness is 1. It can be proven that this is the minimum possible ugliness for this test.\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nvoid inputl() {}\\ntemplate \\nvoid inputl(long long int& a, Arg&&... args) {\\n scanf(\\\"%lld\\\", &a);\\n inputl(forward(args)...);\\n}\\nvoid outputl(long long int a) { printf(\\\"%lld \\\", a); }\\ntemplate \\nvoid outputl(long long int a, Arg... args) {\\n printf(\\\"%lld \\\", a);\\n outputl(args...);\\n}\\nvoid input() {}\\ntemplate \\nvoid input(int& a, Arg&&... args) {\\n scanf(\\\"%d\\\", &a);\\n input(forward(args)...);\\n}\\nvoid output(int a) { printf(\\\"%d \\\", a); }\\ntemplate \\nvoid output(int a, Arg... args) {\\n printf(\\\"%d \\\", a);\\n output(args...);\\n}\\nvoid solve() {\\n int t;\\n input(t);\\n ;\\n while (t--) {\\n int n;\\n input(n);\\n ;\\n int a[n];\\n for (int i = 0; i < n; ++i) scanf(\\\"%d\\\", &a[i]);\\n ;\\n int sum = 0;\\n for (int i = 0; i < n; ++i) sum += a[i];\\n output(sum % n == 0 ? 0 : 1);\\n ;\\n putchar('\\\\n');\\n }\\n}\\nint main() {\\n solve();\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alice and Bob play the following game. Alice has a set S of disjoint ranges of integers, initially containing only one range [1, n]. In one turn, Alice picks a range [l, r] from the set S and asks Bob to pick a number in the range. Bob chooses a number d (l ≤ d ≤ r). Then Alice removes [l, r] from S and puts into the set S the range [l, d - 1] (if l ≤ d - 1) and the range [d + 1, r] (if d + 1 ≤ r). The game ends when the set S is empty. We can show that the number of turns in each game is exactly n.\\n\\nAfter playing the game, Alice remembers all the ranges [l, r] she picked from the set S, but Bob does not remember any of the numbers that he picked. But Bob is smart, and he knows he can find out his numbers d from Alice's ranges, and so he asks you for help with your programming skill.\\n\\nGiven the list of ranges that Alice has picked ([l, r]), for each range, help Bob find the number d that Bob has picked.\\n\\nWe can show that there is always a unique way for Bob to choose his number for a list of valid ranges picked by Alice.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 1000). Description of the test cases follows.\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 1000).\\n\\nEach of the next n lines contains two integers l and r (1 ≤ l ≤ r ≤ n), denoting the range [l, r] that Alice picked at some point.\\n\\nNote that the ranges are given in no particular order.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 1000, and the ranges for each test case are from a valid game.\\n\\nOutput\\n\\nFor each test case print n lines. Each line should contain three integers l, r, and d, denoting that for Alice's range [l, r] Bob picked the number d.\\n\\nYou can print the lines in any order. We can show that the answer is unique.\\n\\nIt is not required to print a new line after each test case. The new lines in the output of the example are for readability only. \\n\\nExample\\n\\nInput\\n\\n\\n4\\n1\\n1 1\\n3\\n1 3\\n2 3\\n2 2\\n6\\n1 1\\n3 5\\n4 4\\n3 6\\n4 5\\n1 6\\n5\\n1 5\\n1 2\\n4 5\\n2...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nbool sortbysec(const pair &a, const pair &b) {\\n return (a.second < b.second);\\n}\\nint main() {\\n int t;\\n cin >> t;\\n while (t--) {\\n int n;\\n cin >> n;\\n vector> v;\\n for (int i = 0; i < n; i++) {\\n int x, y;\\n cin >> x >> y;\\n v.push_back({x, y});\\n }\\n sort(v.begin(), v.end(), sortbysec);\\n unordered_set isAvailable;\\n for (int i = 1; i <= n; i++) {\\n isAvailable.insert(i);\\n }\\n for (int i = 0; i < n; i++) {\\n for (int j = v[i].first; j <= v[i].second; j++) {\\n if (isAvailable.find(j) != isAvailable.end()) {\\n cout << v[i].first << \\\" \\\" << v[i].second << \\\" \\\" << j << \\\"\\\\n\\\";\\n isAvailable.erase(j);\\n break;\\n }\\n }\\n }\\n cout << \\\"\\\\n\\\";\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Theofanis really likes sequences of positive integers, thus his teacher (Yeltsa Kcir) gave him a problem about a sequence that consists of only special numbers.\\n\\nLet's call a positive number special if it can be written as a sum of different non-negative powers of n. For example, for n = 4 number 17 is special, because it can be written as 4^0 + 4^2 = 1 + 16 = 17, but 9 is not.\\n\\nTheofanis asks you to help him find the k-th special number if they are sorted in increasing order. Since this number may be too large, output it modulo 10^9+7.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases.\\n\\nThe first and only line of each test case contains two integers n and k (2 ≤ n ≤ 10^9; 1 ≤ k ≤ 10^9).\\n\\nOutput\\n\\nFor each test case, print one integer — the k-th special number in increasing order modulo 10^9+7.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n3 4\\n2 12\\n105 564\\n\\n\\nOutput\\n\\n\\n9\\n12\\n3595374\\n\\nNote\\n\\nFor n = 3 the sequence is [1,3,4,9...]\\nUsing python3 can you solve the prior task?\",\"targets\":\"import sys\\nfrom io import BytesIO\\nfrom os import read, fstat\\ninput = BytesIO(read(0, fstat(0).st_size)).readline\\n \\n# SOME SHIT\\n# map(int, input().split())\\n# sys.stdout.write(\\\"\\\") ~ |\\n \\n \\ndef solve_tc():\\n mod = 1000000007\\n n, k = map(int, input().split())\\n s = 0\\n for i in range(35):\\n if k & (1 << i):\\n s = (s + pow(n, i, mod)) % mod\\n return s\\n \\n \\nfor _ in range(int(input())):\\n sys.stdout.write(str(solve_tc()) + \\\"\\\\n\\\")\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Ashish has n elements arranged in a line. \\n\\nThese elements are represented by two integers a_i — the value of the element and b_i — the type of the element (there are only two possible types: 0 and 1). He wants to sort the elements in non-decreasing values of a_i.\\n\\nHe can perform the following operation any number of times: \\n\\n * Select any two elements i and j such that b_i ≠ b_j and swap them. That is, he can only swap two elements of different types in one move. \\n\\n\\n\\nTell him if he can sort the elements in non-decreasing values of a_i after performing any number of operations.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 100) — the number of test cases. The description of the test cases follows.\\n\\nThe first line of each test case contains one integer n (1 ≤ n ≤ 500) — the size of the arrays.\\n\\nThe second line contains n integers a_i (1 ≤ a_i ≤ 10^5) — the value of the i-th element.\\n\\nThe third line containts n integers b_i (b_i ∈ \\\\{0, 1\\\\}) — the type of the i-th element.\\n\\nOutput\\n\\nFor each test case, print \\\"Yes\\\" or \\\"No\\\" (without quotes) depending on whether it is possible to sort elements in non-decreasing order of their value.\\n\\nYou may print each letter in any case (upper or lower).\\n\\nExample\\n\\nInput\\n\\n\\n5\\n4\\n10 20 20 30\\n0 1 0 1\\n3\\n3 1 2\\n0 1 1\\n4\\n2 2 4 8\\n1 1 1 1\\n3\\n5 15 4\\n0 0 0\\n4\\n20 10 100 50\\n1 0 0 1\\n\\n\\nOutput\\n\\n\\nYes\\nYes\\nYes\\nNo\\nYes\\n\\nNote\\n\\nFor the first case: The elements are already in sorted order.\\n\\nFor the second case: Ashish may first swap elements at positions 1 and 2, then swap elements at positions 2 and 3.\\n\\nFor the third case: The elements are already in sorted order.\\n\\nFor the fourth case: No swap operations may be performed as there is no pair of elements i and j such that b_i ≠ b_j. The elements cannot be sorted.\\n\\nFor the fifth case: Ashish may swap elements at positions 3 and 4, then elements at positions 1 and 2.\\nimpor\",\"targets\":\"t math\\n#import math \\n#------------------------------warmup----------------------------\\nimport os\\nimport sys\\nfrom io import BytesIO, IOBase\\n \\nBUFSIZE = 8192\\n \\n \\nclass FastIO(IOBase):\\n newlines = 0\\n \\n def __init__(self, file):\\n self._fd = file.fileno()\\n self.buffer = BytesIO()\\n self.writable = \\\"x\\\" in file.mode or \\\"r\\\" not in file.mode\\n self.write = self.buffer.write if self.writable else None\\n \\n def read(self):\\n while True:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n if not b:\\n break\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines = 0\\n return self.buffer.read()\\n \\n def readline(self):\\n while self.newlines == 0:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n self.newlines = b.count(b\\\"\\\\n\\\") + (not b)\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines -= 1\\n return self.buffer.readline()\\n \\n def flush(self):\\n if self.writable:\\n os.write(self._fd, self.buffer.getvalue())\\n self.buffer.truncate(0), self.buffer.seek(0)\\n \\n \\nclass IOWrapper(IOBase):\\n def __init__(self, file):\\n self.buffer = FastIO(file)\\n self.flush = self.buffer.flush\\n self.writable = self.buffer.writable\\n self.write = lambda s: self.buffer.write(s.encode(\\\"ascii\\\"))\\n self.read = lambda: self.buffer.read().decode(\\\"ascii\\\")\\n self.readline = lambda: self.buffer.readline().decode(\\\"ascii\\\")\\n \\n \\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\\ninput = lambda: sys.stdin.readline().rstrip(\\\"\\\\r\\\\n\\\")\\n \\n#-------------------game starts now----------------------------------------------------import math\\nfor i in range(int(input())):\\n n=int(input())\\n l=list(map(int,input().split()))\\n a=list(map(int,input().split()))\\n w=sorted(l)\\n ...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given strings S and T, consisting of lowercase English letters. It is guaranteed that T is a permutation of the string abc. \\n\\nFind string S', the lexicographically smallest permutation of S such that T is not a subsequence of S'.\\n\\nString a is a permutation of string b if the number of occurrences of each distinct character is the same in both strings.\\n\\nA string a is a subsequence of a string b if a can be obtained from b by deletion of several (possibly, zero or all) elements.\\n\\nA string a is lexicographically smaller than a string b if and only if one of the following holds:\\n\\n * a is a prefix of b, but a ≠ b;\\n * in the first position where a and b differ, the string a has a letter that appears earlier in the alphabet than the corresponding letter in b.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases. Description of the test cases follows.\\n\\nThe first line of each test case contains a string S (1 ≤ |S| ≤ 100), consisting of lowercase English letters.\\n\\nThe second line of each test case contains a string T that is a permutation of the string abc. (Hence, |T| = 3).\\n\\nNote that there is no limit on the sum of |S| across all test cases.\\n\\nOutput\\n\\nFor each test case, output a single string S', the lexicographically smallest permutation of S such that T is not a subsequence of S'.\\n\\nExample\\n\\nInput\\n\\n\\n7\\nabacaba\\nabc\\ncccba\\nacb\\ndbsic\\nbac\\nabracadabra\\nabc\\ndddddddddddd\\ncba\\nbbc\\nabc\\nac\\nabc\\n\\n\\nOutput\\n\\n\\naaaacbb\\nabccc\\nbcdis\\naaaaacbbdrr\\ndddddddddddd\\nbbc\\nac\\n\\nNote\\n\\nIn the first test case, both aaaabbc and aaaabcb are lexicographically smaller than aaaacbb, but they contain abc as a subsequence.\\n\\nIn the second test case, abccc is the smallest permutation of cccba and does not contain acb as a subsequence.\\n\\nIn the third test case, bcdis is the smallest permutation of dbsic and does not contain bac as a subsequence.\\nfrom\",\"targets\":\"collections import defaultdict\\nimport sys\\ninput = sys.stdin.readline\\nflush = sys.stdout.flush\\nget_int = lambda : int(input().rstrip())\\nget_arr = lambda : [int(w) for w in input().split()]\\n\\n\\nt = get_int()\\n\\ndef func(c):\\n if c == 'b':\\n return 2\\n elif c == 'c':\\n return 1\\n else:\\n return ord(c) - ord('a')\\n\\n\\nfor _ in range(t):\\n s = input().rstrip()\\n t = input().rstrip()\\n\\n if t == 'abc' and 'a' in s:\\n print(''.join(sorted(s, key=func)))\\n else:\\n print(''.join(sorted(s)))\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"In the year 2420 humans have finally built a colony on Mars thanks to the work of Elon Tusk. There are 10^9+7 cities arranged in a circle in this colony and none of them are connected yet. Elon Tusk wants to connect some of those cities using only roads of the same size in order to lower the production cost of those roads. Because of that he gave a list on N cites where some cites can appear more than once and Q queries that you need to answer. For the query you need to determine if it is possible to connect all the cities from L_{i} to R_{i} on that list using only roads of length D_{i}. \\n\\nInput\\n\\nThe first line contains two integers N and Q (1 ≤ N, Q ≤ 2⋅10^5 ) — the length of the array of cities and the number of queries you need to answer. \\n\\nThe second lines contains N integers representing the array of cites. Next Q lines contain three integers L, R and D (1 ≤ L_{i}, R_{i} ≤ N, 0 ≤ D_{i} ≤ 10^9+6) — the range of cities that needs to be connected and the length of the road that you can use. \\n\\nOutput\\n\\nThe output contains Q lines. If it is possible to connect all the cities from the i-th query can be connected with roads of length D_{i} the i-th line should contain the word \\\"Yes\\\", otherwise it should contain the word \\\"No\\\". \\n\\nExamples\\n\\nInput\\n\\n\\n9 8\\n17 0 12 6 10 8 2 4 5\\n2 3 12\\n2 3 6\\n2 4 6\\n4 6 2\\n2 8 2\\n1 2 17\\n1 8 2\\n9 9 14\\n\\n\\nOutput\\n\\n\\nYes\\nNo\\nYes\\nYes\\nYes\\nYes\\nNo\\nYes\\n\\n\\nInput\\n\\n\\n4 1\\n7 21 14 0\\n1 4 1000000000\\n\\n\\nOutput\\n\\n\\nYes\\n\\nNote\\n\\nIn the 5^{th} query of the first test case we can connect cities in this order 0-2-4-6-8-10-12 this way distance between any two connected cities is 2. In the second test case we can connect cities in this order 21-14-7-0 this way distance between any two connected cities is 10^9 module 10^9+7. \\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nconst long long MOD = (long long)1e9 + 7;\\nconst int SIZE = 1000002;\\nconst long long INF = 1LL << 30;\\nconst double eps = 1e-6;\\nconst double PI = 3.1415926535897932;\\ntemplate \\nstruct ModInt {\\n unsigned x;\\n ModInt() : x(0) {}\\n ModInt(signed sig) : x(sig % MOD) {}\\n ModInt(signed long long sig) : x(sig % MOD) {}\\n int get() const { return (int)x; }\\n ModInt pow(long long p) {\\n ModInt res = 1, a = *this;\\n while (p) {\\n if (p & 1) res *= a;\\n a *= a;\\n p >>= 1;\\n }\\n return res;\\n }\\n ModInt &operator+=(ModInt that) {\\n if ((x += that.x) >= MOD) x -= MOD;\\n return *this;\\n }\\n ModInt &operator-=(ModInt that) {\\n if ((x += MOD - that.x) >= MOD) x -= MOD;\\n return *this;\\n }\\n ModInt &operator*=(ModInt that) {\\n x = (unsigned long long)x * that.x % MOD;\\n return *this;\\n }\\n ModInt &operator\\/=(ModInt that) { return (*this) *= that.pow(MOD - 2); }\\n ModInt operator+(ModInt that) const { return ModInt(*this) += that; }\\n ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }\\n ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }\\n ModInt operator\\/(ModInt that) const { return ModInt(*this) \\/= that; }\\n bool operator<(ModInt that) const { return x < that.x; }\\n friend ostream &operator<<(ostream &os, ModInt a) {\\n os << a.x;\\n return os;\\n }\\n};\\ntypedef ModInt<(int)1e9 + 7> mint;\\nint d[200009];\\nunordered_map> p;\\nint e[200009], root[200009];\\nstruct node {\\n int cnt, lc, rc;\\n long long sum;\\n pair hh;\\n} tree[4000009];\\nint nc = 0;\\nint create_node(int _lc, int _rc, int _cnt, long long _sum, pair ph,\\n pair nh) {\\n int idx = ++nc;\\n tree[idx].lc = _lc;\\n tree[idx].rc = _rc;\\n tree[idx].cnt = _cnt;\\n tree[idx].sum = _sum;\\n tree[idx].hh = {ph.first + nh.first, ph.second + nh.second};\\n return idx;\\n}\\nvoid up(int &root, int proot, int s, int e, int x, int v, pair nh) {\\n root = create_node(tree[proot].lc, tree[proot].rc,...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"\\n\\nInput\\n\\nThe input contains two integers a1, a2 (0 ≤ ai ≤ 32), separated by a single space.\\n\\nOutput\\n\\nOutput a single integer.\\n\\nExamples\\n\\nInput\\n\\n1 1\\n\\n\\nOutput\\n\\n0\\n\\n\\nInput\\n\\n3 7\\n\\n\\nOutput\\n\\n0\\n\\n\\nInput\\n\\n13 10\\n\\n\\nOutput\\n\\n1\\na, b\",\"targets\":\"= map(int, input().split())\\nprint(a + int(str(b)[::-1]))\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A monopole magnet is a magnet that only has one pole, either north or south. They don't actually exist since real magnets have two poles, but this is a programming contest problem, so we don't care.\\n\\nThere is an n× m grid. Initially, you may place some north magnets and some south magnets into the cells. You are allowed to place as many magnets as you like, even multiple in the same cell.\\n\\nAn operation is performed as follows. Choose a north magnet and a south magnet to activate. If they are in the same row or the same column and they occupy different cells, then the north magnet moves one unit closer to the south magnet. Otherwise, if they occupy the same cell or do not share a row or column, then nothing changes. Note that the south magnets are immovable.\\n\\nEach cell of the grid is colored black or white. Let's consider ways to place magnets in the cells so that the following conditions are met.\\n\\n 1. There is at least one south magnet in every row and every column. \\n 2. If a cell is colored black, then it is possible for a north magnet to occupy this cell after some sequence of operations from the initial placement. \\n 3. If a cell is colored white, then it is impossible for a north magnet to occupy this cell after some sequence of operations from the initial placement. \\n\\n\\n\\nDetermine if it is possible to place magnets such that these conditions are met. If it is possible, find the minimum number of north magnets required (there are no requirements on the number of south magnets).\\n\\nInput\\n\\nThe first line contains two integers n and m (1≤ n,m≤ 1000) — the number of rows and the number of columns, respectively.\\n\\nThe next n lines describe the coloring. The i-th of these lines contains a string of length m, where the j-th character denotes the color of the cell in row i and column j. The characters \\\"#\\\" and \\\".\\\" represent black and white, respectively. It is guaranteed, that the string will not contain any other characters.\\n\\nOutput\\n\\nOutput a single integer, the minimum possible number of north magnets...\\nUsing java can you solve the prior task?\",\"targets\":\"import javax.crypto.spec.PSource;\\nimport java.util.*;\\nimport java.lang.*;\\nimport java.io.*;\\nimport java.math.*;\\n\\n\\/**\\n * #\\n * @author master pttrung\\n *\\/\\npublic class Solution {\\n\\n public static long MOD = 1000000007;\\n\\n\\n public static void main(String[] args) throws FileNotFoundException {\\n \\/\\/ PrintWriter out = new PrintWriter(new FileOutputStream(new File(\\n \\/\\/ \\\"output.txt\\\")));\\n PrintWriter out = new PrintWriter(System.out);\\n Scanner in = new Scanner();\\n int n = in.nextInt();\\n int m = in.nextInt();\\n char[][] arr = new char[n][m];\\n for(int i=0; i 0) || (r > 0 && c == 0)) {\\n out.println(\\\"-1\\\");\\n out.close();\\n return;\\n }\\n\\n int result = 0;\\n for(int i=0; i= n || j>= m || arr[i][j] == '.') return;\\n arr[i][j] = '.';\\n ...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Another programming contest is over. You got hold of the contest's final results table. The table has the following data. For each team we are shown two numbers: the number of problems and the total penalty time. However, for no team we are shown its final place.\\n\\nYou know the rules of comparing the results of two given teams very well. Let's say that team a solved pa problems with total penalty time ta and team b solved pb problems with total penalty time tb. Team a gets a higher place than team b in the end, if it either solved more problems on the contest, or solved the same number of problems but in less total time. In other words, team a gets a higher place than team b in the final results' table if either pa > pb, or pa = pb and ta < tb. \\n\\nIt is considered that the teams that solve the same number of problems with the same penalty time share all corresponding places. More formally, let's say there is a group of x teams that solved the same number of problems with the same penalty time. Let's also say that y teams performed better than the teams from this group. In this case all teams from the group share places y + 1, y + 2, ..., y + x. The teams that performed worse than the teams from this group, get their places in the results table starting from the y + x + 1-th place.\\n\\nYour task is to count what number of teams from the given list shared the k-th place. \\n\\nInput\\n\\nThe first line contains two integers n and k (1 ≤ k ≤ n ≤ 50). Then n lines contain the description of the teams: the i-th line contains two integers pi and ti (1 ≤ pi, ti ≤ 50) — the number of solved problems and the total penalty time of the i-th team, correspondingly. All numbers in the lines are separated by spaces. \\n\\nOutput\\n\\nIn the only line print the sought number of teams that got the k-th place in the final results' table.\\n\\nExamples\\n\\nInput\\n\\n7 2\\n4 10\\n4 10\\n4 10\\n3 20\\n2 1\\n2 1\\n1 10\\n\\n\\nOutput\\n\\n3\\n\\n\\nInput\\n\\n5 4\\n3 1\\n3 1\\n5 3\\n3 1\\n3 1\\n\\n\\nOutput\\n\\n4\\n\\nNote\\n\\nThe final results' table for the first sample is: \\n\\n * 1-3 places — 4 solved problems, the...\",\"targets\":\"def inp():\\n return int(raw_input())\\ndef linp():\\n return map(int, raw_input().split())\\nn, k = linp()\\nli=[]\\nfor i in xrange(n):\\n a, b = linp()\\n li.append([a, b])\\nli = sorted(li, key=lambda x:(-x[0], x[1]))\\nch=li[k-1]\\nans=0\\nfor i in li:\\n if i==ch:\\n ans+=1\\nprint ans\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Gregor is learning about RSA cryptography, and although he doesn't understand how RSA works, he is now fascinated with prime numbers and factoring them.\\n\\nGregor's favorite prime number is P. Gregor wants to find two bases of P. Formally, Gregor is looking for two integers a and b which satisfy both of the following properties.\\n\\n * P mod a = P mod b, where x mod y denotes the remainder when x is divided by y, and \\n * 2 ≤ a < b ≤ P. \\n\\n\\n\\nHelp Gregor find two bases of his favorite prime number!\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 1000).\\n\\nEach subsequent line contains the integer P (5 ≤ P ≤ {10}^9), with P guaranteed to be prime.\\n\\nOutput\\n\\nYour output should consist of t lines. Each line should consist of two integers a and b (2 ≤ a < b ≤ P). If there are multiple possible solutions, print any.\\n\\nExample\\n\\nInput\\n\\n\\n2\\n17\\n5\\n\\n\\nOutput\\n\\n\\n3 5\\n2 4\\n\\nNote\\n\\nThe first query is P=17. a=3 and b=5 are valid bases in this case, because 17 mod 3 = 17 mod 5 = 2. There are other pairs which work as well.\\n\\nIn the second query, with P=5, the only solution is a=2 and b=4.\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nvoid printarray(int arr[], int size) {\\n for (int i = 0; i < size; i = i + 1) {\\n cout << arr[i] << ' ';\\n }\\n}\\nint main() {\\n int t;\\n cin >> t;\\n for (int m = 0; m < t; m = m + 1) {\\n int p{};\\n cin >> p;\\n cout << 2 << ' ' << p - 1 << '\\\\n';\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Polycarp likes squares and cubes of positive integers. Here is the beginning of the sequence of numbers he likes: 1, 4, 8, 9, ....\\n\\nFor a given number n, count the number of integers from 1 to n that Polycarp likes. In other words, find the number of such x that x is a square of a positive integer number or a cube of a positive integer number (or both a square and a cube simultaneously).\\n\\nInput\\n\\nThe first line contains an integer t (1 ≤ t ≤ 20) — the number of test cases.\\n\\nThen t lines contain the test cases, one per line. Each of the lines contains one integer n (1 ≤ n ≤ 10^9).\\n\\nOutput\\n\\nFor each test case, print the answer you are looking for — the number of integers from 1 to n that Polycarp likes.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n10\\n1\\n25\\n1000000000\\n999999999\\n500000000\\n\\n\\nOutput\\n\\n\\n4\\n1\\n6\\n32591\\n32590\\n23125\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"import math\\nt = int(input())\\nwhile t > 0:\\n n = int(input())\\n \\n if n == 1:\\n print(1)\\n else:\\n res = set()\\n i = 2\\n while i*i <= n:\\n res.add(i*i)\\n if i*i*i <= n:\\n res.add(i*i*i)\\n\\n i+=1\\n\\n print(len(res)+1)\\n\\n t-=1\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"It is a simplified version of problem F2. The difference between them is the constraints (F1: k ≤ 2, F2: k ≤ 10).\\n\\nYou are given an integer n. Find the minimum integer x such that x ≥ n and the number x is k-beautiful.\\n\\nA number is called k-beautiful if its decimal representation having no leading zeroes contains no more than k different digits. E.g. if k = 2, the numbers 3434443, 55550, 777 and 21 are k-beautiful whereas the numbers 120, 445435 and 998244353 are not.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10^4) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one line containing two integers n and k (1 ≤ n ≤ 10^9, 1 ≤ k ≤ 2).\\n\\nOutput\\n\\nFor each test case output on a separate line x — the minimum k-beautiful integer such that x ≥ n.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n1 1\\n221 2\\n177890 2\\n998244353 1\\n\\n\\nOutput\\n\\n\\n1\\n221\\n181111\\n999999999\\nSolve the task in PYTHON3.\",\"targets\":\"import os, sys\\nfrom io import BytesIO, IOBase\\n\\n\\nclass FastIO(IOBase):\\n newlines = 0\\n\\n def __init__(self, file):\\n self._fd = file.fileno()\\n self.buffer = BytesIO()\\n self.writable = \\\"x\\\" in file.mode or \\\"r\\\" not in file.mode\\n self.write = self.buffer.write if self.writable else None\\n\\n def read(self):\\n while True:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, 8192))\\n if not b:\\n break\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines = 0\\n return self.buffer.read()\\n\\n def readline(self):\\n while self.newlines == 0:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, 8192))\\n self.newlines = b.count(b\\\"\\\\n\\\") + (not b)\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines -= 1\\n return self.buffer.readline()\\n\\n def flush(self):\\n if self.writable:\\n os.write(self._fd, self.buffer.getvalue())\\n self.buffer.truncate(0), self.buffer.seek(0)\\n\\n\\nclass IOWrapper(IOBase):\\n def __init__(self, file):\\n self.buffer = FastIO(file)\\n self.flush = self.buffer.flush\\n self.writable = self.buffer.writable\\n self.write = lambda s: self.buffer.write(s.encode(\\\"ascii\\\"))\\n self.read = lambda: self.buffer.read().decode(\\\"ascii\\\")\\n self.readline = lambda: self.buffer.readline().decode(\\\"ascii\\\")\\n\\n\\nclass dict(dict):\\n def __missing__(self, key):\\n return 0\\n\\n\\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\\ninput = lambda: sys.stdin.readline().rstrip(\\\"\\\\r\\\\n\\\")\\ninp = lambda dtype: dtype(input().strip())\\ninp_d = lambda dtype: [dtype(x) for x in input().split()]\\ninp_2d = lambda dtype, n: [inp(dtype) for _ in range(n)]\\ninp_2ds = lambda dtype, n: [inp_d(dtype) for _ in range(n)]\\ninp_enu = lambda dtype: [(i, x) for i, x in enumerate(inp_d(dtype))]\\ninp_enus =...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Being tired of participating in too many Codeforces rounds, Gildong decided to take some rest in a park. He sat down on a bench, and soon he found two rabbits hopping around. One of the rabbits was taller than the other.\\n\\nHe noticed that the two rabbits were hopping towards each other. The positions of the two rabbits can be represented as integer coordinates on a horizontal line. The taller rabbit is currently on position x, and the shorter rabbit is currently on position y (x < y). Every second, each rabbit hops to another position. The taller rabbit hops to the positive direction by a, and the shorter rabbit hops to the negative direction by b.\\n\\n\\n\\nFor example, let's say x=0, y=10, a=2, and b=3. At the 1-st second, each rabbit will be at position 2 and 7. At the 2-nd second, both rabbits will be at position 4.\\n\\nGildong is now wondering: Will the two rabbits be at the same position at the same moment? If so, how long will it take? Let's find a moment in time (in seconds) after which the rabbits will be at the same point.\\n\\nInput\\n\\nEach test contains one or more test cases. The first line contains the number of test cases t (1 ≤ t ≤ 1000).\\n\\nEach test case contains exactly one line. The line consists of four integers x, y, a, b (0 ≤ x < y ≤ 10^9, 1 ≤ a,b ≤ 10^9) — the current position of the taller rabbit, the current position of the shorter rabbit, the hopping distance of the taller rabbit, and the hopping distance of the shorter rabbit, respectively.\\n\\nOutput\\n\\nFor each test case, print the single integer: number of seconds the two rabbits will take to be at the same position.\\n\\nIf the two rabbits will never be at the same position simultaneously, print -1.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n0 10 2 3\\n0 10 3 3\\n900000000 1000000000 1 9999999\\n1 2 1 1\\n1 3 1 1\\n\\n\\nOutput\\n\\n\\n2\\n-1\\n10\\n-1\\n1\\n\\nNote\\n\\nThe first case is explained in the description.\\n\\nIn the second case, each rabbit will be at position 3 and 7 respectively at the 1-st second. But in the 2-nd second they will be at 6 and 4 respectively, and we can see that they will never...\",\"targets\":\"ans = []\\n\\t\\nfor t in range(int(input())):\\n\\t[s, e, a, b] = [int(i) for i in input().split()]\\n\\tif (e - s) % (a + b) != 0:\\n\\t\\tans.append('-1')\\n\\t\\tcontinue\\n\\tans.append(str((e - s) \\/\\/ (a + b)))\\n\\t\\nprint('\\\\n'.join(ans))\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Morning desert sun horizon\\n\\nRise above the sands of time...\\n\\nFates Warning, \\\"Exodus\\\"\\n\\nAfter crossing the Windswept Wastes, Ori has finally reached the Windtorn Ruins to find the Heart of the Forest! However, the ancient repository containing this priceless Willow light did not want to open!\\n\\nOri was taken aback, but the Voice of the Forest explained to him that the cunning Gorleks had decided to add protection to the repository.\\n\\nThe Gorleks were very fond of the \\\"string expansion\\\" operation. They were also very fond of increasing subsequences.\\n\\nSuppose a string s_1s_2s_3 … s_n is given. Then its \\\"expansion\\\" is defined as the sequence of strings s_1, s_1 s_2, ..., s_1 s_2 … s_n, s_2, s_2 s_3, ..., s_2 s_3 … s_n, s_3, s_3 s_4, ..., s_{n-1} s_n, s_n. For example, the \\\"expansion\\\" the string 'abcd' will be the following sequence of strings: 'a', 'ab', 'abc', 'abcd', 'b', 'bc', 'bcd', 'c', 'cd', 'd'. \\n\\nTo open the ancient repository, Ori must find the size of the largest increasing subsequence of the \\\"expansion\\\" of the string s. Here, strings are compared lexicographically.\\n\\nHelp Ori with this task!\\n\\nA string a is lexicographically smaller than a string b if and only if one of the following holds:\\n\\n * a is a prefix of b, but a ≠ b;\\n * in the first position where a and b differ, the string a has a letter that appears earlier in the alphabet than the corresponding letter in b.\\n\\nInput\\n\\nEach test contains multiple test cases.\\n\\nThe first line contains one positive integer t (1 ≤ t ≤ 10^3), denoting the number of test cases. Description of the test cases follows.\\n\\nThe first line of each test case contains one positive integer n (1 ≤ n ≤ 5000) — length of the string.\\n\\nThe second line of each test case contains a non-empty string of length n, which consists of lowercase latin letters.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 10^4.\\n\\nOutput\\n\\nFor every test case print one non-negative integer — the answer to the...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst int INF = 0x3f3f3f3f;\\nconst long long INF64 = 0x3f3f3f3f3f3f3f3f;\\nconst double PI = acos(-1);\\ntypedef std::priority_queue, greater> small_pq;\\ntypedef std::priority_queue, less> big_pq;\\ntemplate \\nostream &operator<<(ostream &os, const pair &p) {\\n return os << '(' << p.first << \\\", \\\" << p.second << ')';\\n}\\ntemplate ::value,\\n typename T_container::value_type>::type>\\nostream &operator<<(ostream &os, const T_container &v) {\\n os << '{';\\n string sep;\\n for (const T &x : v) os << sep << x, sep = \\\", \\\";\\n return os << '}';\\n}\\nvoid dbg_out() {}\\ntemplate \\nvoid dbg_out(Head H, Tail... T) {\\n cerr << \\\" \\\" << H;\\n if (sizeof...(T) > 0) cerr << \\\" ,\\\";\\n dbg_out(T...);\\n}\\nvoid dbg_name(const string &s) {\\n string ss = s;\\n replace(ss.begin(), ss.end(), ',', ' ');\\n cerr << \\\" ( \\\" << ss << \\\" ) \\\";\\n}\\ntemplate \\ninline void setmin(T &a, const T &b) {\\n if (b < a) a = b;\\n}\\ntemplate \\ninline void setmax(T &a, const T &b) {\\n if (b > a) a = b;\\n}\\nstruct custom_hash {\\n static uint64_t splitmix64(uint64_t x) {\\n x += 0x9e3779b97f4a7c15;\\n x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;\\n x = (x ^ (x >> 27)) * 0x94d049bb133111eb;\\n return x ^ (x >> 31);\\n }\\n size_t operator()(uint64_t x) const {\\n static const uint64_t FIXED_RANDOM =\\n chrono::steady_clock::now().time_since_epoch().count();\\n return splitmix64(x + FIXED_RANDOM);\\n }\\n};\\nunordered_map safe_map;\\nmt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());\\nmt19937_64 rnd64(chrono::steady_clock::now().time_since_epoch().count());\\nconst int MOD = 998244353;\\nint mul(int x, int y) { return 1ll * x * y % MOD; }\\nint add(int x, int y) { return ((x + y) % MOD + MOD) % MOD; }\\nint sub(int x, int y) {...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in PYTHON3?\\nCasimir has a string s which consists of capital Latin letters 'A', 'B', and 'C' only. Each turn he can choose to do one of the two following actions:\\n\\n * he can either erase exactly one letter 'A' and exactly one letter 'B' from arbitrary places of the string (these letters don't have to be adjacent); \\n * or he can erase exactly one letter 'B' and exactly one letter 'C' from arbitrary places in the string (these letters don't have to be adjacent). \\n\\n\\n\\nTherefore, each turn the length of the string is decreased exactly by 2. All turns are independent so for each turn, Casimir can choose any of two possible actions.\\n\\nFor example, with s = \\\"ABCABC\\\" he can obtain a string s = \\\"ACBC\\\" in one turn (by erasing the first occurrence of 'B' and the second occurrence of 'A'). There are also many other options for a turn aside from this particular example.\\n\\nFor a given string s determine whether there is a sequence of actions leading to an empty string. In other words, Casimir's goal is to erase all letters from the string. Is there a way to do this?\\n\\nInput\\n\\nThe first line contains an integer t (1 ≤ t ≤ 1000) — the number of test cases.\\n\\nEach test case is described by one string s, for which you need to determine if it can be fully erased by some sequence of turns. The string s consists of capital letters 'A', 'B', 'C' and has a length from 1 to 50 letters, inclusive.\\n\\nOutput\\n\\nPrint t lines, each line containing the answer to the corresponding test case. The answer to a test case should be YES if there is a way to fully erase the corresponding string and NO otherwise.\\n\\nYou may print every letter in any case you want (so, for example, the strings yEs, yes, Yes, and YES will all be recognized as positive answers).\\n\\nExample\\n\\nInput\\n\\n\\n6\\nABACAB\\nABBA\\nAC\\nABC\\nCABCBB\\nBCBCBCBCBCBCBCBC\\n\\n\\nOutput\\n\\n\\nNO\\nYES\\nNO\\nNO\\nYES\\nYES\",\"targets\":\"import math\\nimport sys\\nimport collections\\nimport bisect\\nimport time\\nimport random\\nimport itertools\\nimport string\\nfrom collections import Counter,defaultdict\\ndef get_ints():return map(int, sys.stdin.readline().strip().split())\\ndef get_list():return list(map(int, sys.stdin.readline().strip().split()))\\ndef get_string():return sys.stdin.readline().strip()\\nfor t in range(int(input())):\\n s=list(get_string())\\n a,b,c=s.count(\\\"A\\\"),s.count(\\\"B\\\"),s.count(\\\"C\\\")\\n if b>=a and b-a==c:\\n print(\\\"YES\\\")\\n else:\\n print(\\\"NO\\\")\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Let's define S(x) to be the sum of digits of number x written in decimal system. For example, S(5) = 5, S(10) = 1, S(322) = 7.\\n\\nWe will call an integer x interesting if S(x + 1) < S(x). In each test you will be given one integer n. Your task is to calculate the number of integers x such that 1 ≤ x ≤ n and x is interesting.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 1000) — number of test cases.\\n\\nThen t lines follow, the i-th line contains one integer n (1 ≤ n ≤ 10^9) for the i-th test case.\\n\\nOutput\\n\\nPrint t integers, the i-th should be the answer for the i-th test case.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n1\\n9\\n10\\n34\\n880055535\\n\\n\\nOutput\\n\\n\\n0\\n1\\n1\\n3\\n88005553\\n\\nNote\\n\\nThe first interesting number is equal to 9.\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nlong long n, ans, tst;\\nint main() {\\n cin >> tst;\\n while (tst--) {\\n cin >> n;\\n ans = n \\/ 10;\\n if (n % 10 == 9) ans++;\\n cout << ans << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Finally, a basketball court has been opened in SIS, so Demid has decided to hold a basketball exercise session. 2 ⋅ n students have come to Demid's exercise session, and he lined up them into two rows of the same size (there are exactly n people in each row). Students are numbered from 1 to n in each row in order from left to right.\\n\\n\\n\\nNow Demid wants to choose a team to play basketball. He will choose players from left to right, and the index of each chosen player (excluding the first one taken) will be strictly greater than the index of the previously chosen player. To avoid giving preference to one of the rows, Demid chooses students in such a way that no consecutive chosen students belong to the same row. The first student can be chosen among all 2n students (there are no additional constraints), and a team can consist of any number of students. \\n\\nDemid thinks, that in order to compose a perfect team, he should choose students in such a way, that the total height of all chosen students is maximum possible. Help Demid to find the maximum possible total height of players in a team he can choose.\\n\\nInput\\n\\nThe first line of the input contains a single integer n (1 ≤ n ≤ 10^5) — the number of students in each row.\\n\\nThe second line of the input contains n integers h_{1, 1}, h_{1, 2}, …, h_{1, n} (1 ≤ h_{1, i} ≤ 10^9), where h_{1, i} is the height of the i-th student in the first row.\\n\\nThe third line of the input contains n integers h_{2, 1}, h_{2, 2}, …, h_{2, n} (1 ≤ h_{2, i} ≤ 10^9), where h_{2, i} is the height of the i-th student in the second row.\\n\\nOutput\\n\\nPrint a single integer — the maximum possible total height of players in a team Demid can choose.\\n\\nExamples\\n\\nInput\\n\\n\\n5\\n9 3 5 7 3\\n5 8 1 4 5\\n\\n\\nOutput\\n\\n\\n29\\n\\n\\nInput\\n\\n\\n3\\n1 2 9\\n10 1 1\\n\\n\\nOutput\\n\\n\\n19\\n\\n\\nInput\\n\\n\\n1\\n7\\n4\\n\\n\\nOutput\\n\\n\\n7\\n\\nNote\\n\\nIn the first example Demid can choose the following team as follows: \\n\\n\\n\\nIn the second example Demid can choose the following team as follows: \\n\\n\",\"targets\":\"\\/\\/ Created by Whiplash99\\nimport java.io.*;\\nimport java.util.*;\\npublic class B\\n{\\n public static void main(String[] args) throws IOException\\n {\\n BufferedReader br=new BufferedReader(new InputStreamReader(System.in));\\n\\n int i,j,N;\\n\\n N=Integer.parseInt(br.readLine().trim());\\n long a1[]=new long[N+5];\\n long a2[]=new long[N+5];\\n long dp[][]=new long[N+5][3];\\n\\n String s[]=br.readLine().trim().split(\\\" \\\");\\n for(i=0;i A sample of a circle of 6 persons. The orange arrows indicate who is looking at whom.\\n\\nYou don't know the exact number of people standing in the circle (but this number is even, no doubt). It is known that the person with the number a is looking at the person with the number b (and vice versa, of course). What is the number associated with a person being looked at by the person with the number c? If, for the specified a, b, and c, no such circle exists, output -1.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10^4) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one line containing three distinct integers a, b, c (1 ≤ a,b,c ≤ 10^8).\\n\\nOutput\\n\\nFor each test case output in a separate line a single integer d — the number of the person being looked at by the person with the number c in a circle such that the person with the number a is looking at the person with the number b. If there are multiple solutions, print any of them. Output -1 if there's no circle meeting the given conditions.\\n\\nExample\\n\\nInput\\n\\n\\n7\\n6 2 4\\n2 3 1\\n2 4 10\\n5 3 4\\n1 3 2\\n2 5 4\\n4 3 2\\n\\n\\nOutput\\n\\n\\n8\\n-1\\n-1\\n-1\\n4\\n1\\n-1\\n\\nNote\\n\\nIn the first test case, there's a desired circle of 8 people. The person with the number 6 will look at the person with the number 2 and the person with the number 8 will look at the person with the number 4.\\n\\nIn the second test case, there's no circle meeting the conditions. If the person with the number 2 is looking at the person with the number 3, the circle consists of 2 people because these persons are neighbors. But, in this case, they must have the numbers 1 and 2, but it doesn't meet the problem's conditions.\\n\\nIn the third test case, the only circle with the persons with the numbers 2 and 4 looking at each other consists of 4...\\nUsing python3 can you solve the prior task?\",\"targets\":\"for i in range(int(input())):\\n x,y,z=map(int,input().split())\\n if abs(x-y)*2>=max(x,y,z):\\n new=abs(x-y)*2\\n if z+abs(x-y)>new:\\n print((z+abs(x-y))%new)\\n else:\\n print(z+abs(x-y))\\n \\n else:\\n print('-1')\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A binary string is a string that consists of characters 0 and 1.\\n\\nLet \\\\operatorname{MEX} of a binary string be the smallest digit among 0, 1, or 2 that does not occur in the string. For example, \\\\operatorname{MEX} of 001011 is 2, because 0 and 1 occur in the string at least once, \\\\operatorname{MEX} of 1111 is 0, because 0 and 2 do not occur in the string and 0 < 2.\\n\\nA binary string s is given. You should cut it into any number of substrings such that each character is in exactly one substring. It is possible to cut the string into a single substring — the whole string.\\n\\nA string a is a substring of a string b if a can be obtained from b by deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end.\\n\\nWhat is the minimal sum of \\\\operatorname{MEX} of all substrings pieces can be?\\n\\nInput\\n\\nThe input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. Description of the test cases follows.\\n\\nEach test case contains a single binary string s (1 ≤ |s| ≤ 10^5).\\n\\nIt's guaranteed that the sum of lengths of s over all test cases does not exceed 10^5.\\n\\nOutput\\n\\nFor each test case print a single integer — the minimal sum of \\\\operatorname{MEX} of all substrings that it is possible to get by cutting s optimally.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n01\\n1111\\n01100\\n101\\n0000\\n01010\\n\\n\\nOutput\\n\\n\\n1\\n0\\n2\\n1\\n1\\n2\\n\\nNote\\n\\nIn the first test case the minimal sum is \\\\operatorname{MEX}(0) + \\\\operatorname{MEX}(1) = 1 + 0 = 1.\\n\\nIn the second test case the minimal sum is \\\\operatorname{MEX}(1111) = 0.\\n\\nIn the third test case the minimal sum is \\\\operatorname{MEX}(01100) = 2.\\nUsing python3 can you solve the prior task?\",\"targets\":\"t = int(input())\\nfor test in range(t):\\n s = input()\\n zeroes = s.count('0')\\n if zeroes == 0:\\n print(0)\\n continue\\n\\n first = s.find('0')\\n last = s.rfind('0')\\n if last - first + 1 == zeroes:\\n print(1)\\n else:\\n print(2)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 solution for \\\"PizzaForces is Petya's favorite pizzeria. PizzaForces makes and sells pizzas of three sizes: small pizzas consist of 6 slices, medium ones consist of 8 slices, and large pizzas consist of 10 slices each. Baking them takes 15, 20 and 25 minutes, respectively.\\n\\nPetya's birthday is today, and n of his friends will come, so he decided to make an order from his favorite pizzeria. Petya wants to order so much pizza that each of his friends gets at least one slice of pizza. The cooking time of the order is the total baking time of all the pizzas in the order.\\n\\nYour task is to determine the minimum number of minutes that is needed to make pizzas containing at least n slices in total. For example: \\n\\n * if 12 friends come to Petya's birthday, he has to order pizzas containing at least 12 slices in total. He can order two small pizzas, containing exactly 12 slices, and the time to bake them is 30 minutes; \\n * if 15 friends come to Petya's birthday, he has to order pizzas containing at least 15 slices in total. He can order a small pizza and a large pizza, containing 16 slices, and the time to bake them is 40 minutes; \\n * if 300 friends come to Petya's birthday, he has to order pizzas containing at least 300 slices in total. He can order 15 small pizzas, 10 medium pizzas and 13 large pizzas, in total they contain 15 ⋅ 6 + 10 ⋅ 8 + 13 ⋅ 10 = 300 slices, and the total time to bake them is 15 ⋅ 15 + 10 ⋅ 20 + 13 ⋅ 25 = 750 minutes; \\n * if only one friend comes to Petya's birthday, he can order a small pizza, and the time to bake it is 15 minutes. \\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.\\n\\nEach testcase consists of a single line that contains a single integer n (1 ≤ n ≤ 10^{16}) — the number of Petya's friends.\\n\\nOutput\\n\\nFor each testcase, print one integer — the minimum number of minutes that is needed to bake pizzas containing at least n slices in total.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n12\\n15\\n300\\n1\\n9999999999999999\\n3\\n\\n\\nOutput\\n\\n\\n30\\n40\\n750\\n15\\n25000000000000000\\n15\\\":\",\"targets\":\"N = int(input())\\n\\nfor i in range(N):\\n t = int(input())\\n if t % 2 == 1:\\n t += 1\\n\\n print(max(6, t)\\/\\/2 * 5)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 solution for \\\"You are given n integers a_1, a_2, …, a_n. Find the maximum value of max(a_l, a_{l + 1}, …, a_r) ⋅ min(a_l, a_{l + 1}, …, a_r) over all pairs (l, r) of integers for which 1 ≤ l < r ≤ n.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10 000) — the number of test cases.\\n\\nThe first line of each test case contains a single integer n (2 ≤ n ≤ 10^5).\\n\\nThe second line of each test case contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^6).\\n\\nIt is guaranteed that the sum of n over all test cases doesn't exceed 3 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print a single integer — the maximum possible value of the product from the statement.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n2 4 3\\n4\\n3 2 3 1\\n2\\n69 69\\n6\\n719313 273225 402638 473783 804745 323328\\n\\n\\nOutput\\n\\n\\n12\\n6\\n4761\\n381274500335\\n\\nNote\\n\\nLet f(l, r) = max(a_l, a_{l + 1}, …, a_r) ⋅ min(a_l, a_{l + 1}, …, a_r).\\n\\nIn the first test case, \\n\\n * f(1, 2) = max(a_1, a_2) ⋅ min(a_1, a_2) = max(2, 4) ⋅ min(2, 4) = 4 ⋅ 2 = 8. \\n * f(1, 3) = max(a_1, a_2, a_3) ⋅ min(a_1, a_2, a_3) = max(2, 4, 3) ⋅ min(2, 4, 3) = 4 ⋅ 2 = 8. \\n * f(2, 3) = max(a_2, a_3) ⋅ min(a_2, a_3) = max(4, 3) ⋅ min(4, 3) = 4 ⋅ 3 = 12. \\n\\n\\n\\nSo the maximum is f(2, 3) = 12.\\n\\nIn the second test case, the maximum is f(1, 2) = f(1, 3) = f(2, 3) = 6.\\\":\",\"targets\":\"def find():\\n n=int(input())\\n A=list(map(int,input().split()))\\n ans=0\\n stack=[]\\n for a in A:\\n while(stack and stack[-1]>a):\\n b=stack.pop()\\n ans=max(ans,a*b)\\n if stack:\\n ans=max(ans,stack[-1]*a)\\n stack.append(a)\\n \\n stack.reverse()\\n while(len(stack)>1):\\n ans=max(ans,stack[0]*stack.pop())\\n \\n # for i in range(len(stack)-1):\\n # ans=max(ans,stack[i]*stack[-1])\\n\\n print(ans)\\n\\n\\nt=int(input())\\n\\nfor _ in range(t):\\n find()\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"In Berland, n different types of banknotes are used. Banknotes of the i-th type have denomination 10^{a_i} burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly 1.\\n\\nLet's denote f(s) as the minimum number of banknotes required to represent exactly s burles. For example, if the denominations of banknotes used in Berland are 1, 10 and 100, then f(59) = 14: 9 banknotes with denomination of 1 burle and 5 banknotes with denomination of 10 burles can be used to represent exactly 9 ⋅ 1 + 5 ⋅ 10 = 59 burles, and there's no way to do it with fewer banknotes.\\n\\nFor a given integer k, find the minimum positive number of burles s that cannot be represented with k or fewer banknotes (that is, f(s) > k).\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — number of test cases.\\n\\nThe first line of each test case contains two integers n and k (1 ≤ n ≤ 10; 1 ≤ k ≤ 10^9).\\n\\nThe next line contains n integers a_1, a_2, ..., a_n (0 = a_1 < a_2 < ... < a_n ≤ 9).\\n\\nOutput\\n\\nFor each test case, print one integer — the minimum positive number of burles s that cannot be represented with k or fewer banknotes.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3 13\\n0 1 2\\n2 777\\n0 4\\n3 255\\n0 1 3\\n10 1000000000\\n0 1 2 3 4 5 6 7 8 9\\n\\n\\nOutput\\n\\n\\n59\\n778\\n148999\\n999999920999999999\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\nimport java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.util.Scanner;\\nimport java.util.StringTokenizer;\\n\\npublic class Test{\\n\\n static FastReader scan;\\n\\n static void solve(){\\n int n=scan.nextInt();\\n int notes=scan.nextInt();\\n notes++;\\n int []arr=new int[n];\\n for(int i=0;i0){\\n int currNotes=(int)Math.pow(10,arr[i+1]-arr[i]);\\n currNotes--;\\n\\n currNotes=Math.min(notes,currNotes);\\n ans+=(long)(Math.pow(10,arr[i])*currNotes);\\n notes=notes-currNotes;\\n } \\n else break; \\n }\\n if(notes>0){\\n ans+=(long)(Math.pow(10,arr[n-1])*notes);\\n }\\n\\n System.out.println(ans); \\n\\n\\n\\n }\\n \\n\\n public static void main (String[] args) throws java.lang.Exception{\\n scan=new FastReader();\\n int t=scan.nextInt();\\n while(t-->0){\\n solve();\\n }\\n }\\n\\n static class FastReader {\\n BufferedReader br;\\n StringTokenizer st;\\n\\n public FastReader()\\n {\\n br = new BufferedReader(\\n new InputStreamReader(System.in));\\n }\\n\\n String next()\\n {\\n while (st == null || !st.hasMoreElements()) {\\n try {\\n st = new StringTokenizer(br.readLine());\\n }\\n catch (IOException e) {\\n e.printStackTrace();\\n }\\n }\\n return st.nextToken();\\n }\\n\\n int nextInt() { return Integer.parseInt(next()); }\\n\\n long...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"\\\"Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score...\\\" — an excerpt from contest rules.\\n\\nA total of n participants took part in the contest (n ≥ k), and you already know their scores. Calculate how many participants will advance to the next round.\\n\\nInput\\n\\nThe first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 50) separated by a single space.\\n\\nThe second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 100), where ai is the score earned by the participant who got the i-th place. The given sequence is non-increasing (that is, for all i from 1 to n - 1 the following condition is fulfilled: ai ≥ ai + 1).\\n\\nOutput\\n\\nOutput the number of participants who advance to the next round.\\n\\nExamples\\n\\nInput\\n\\n8 5\\n10 9 8 7 7 7 5 5\\n\\n\\nOutput\\n\\n6\\n\\n\\nInput\\n\\n4 2\\n0 0 0 0\\n\\n\\nOutput\\n\\n0\\n\\nNote\\n\\nIn the first example the participant on the 5th place earned 7 points. As the participant on the 6th place also earned 7 points, there are 6 advancers.\\n\\nIn the second example nobody got a positive score.\\nUsing python3 can you solve the prior task?\",\"targets\":\"realInput = []\\n\\nno_of_lines = 2\\nfor i in range(no_of_lines):\\n realInput.append(input())\\n\\nvariables = realInput[0].split(\\\" \\\")\\n\\nn = variables[0]\\nk = variables[1]\\n\\nscores = realInput[1].split(\\\" \\\")\\n# print(scores)\\n\\nscore_to_advance = int(scores[int(k)-1])\\n\\nadvance = 0\\nfor score in scores:\\n if int(score) >= score_to_advance and int(score) != 0:\\n advance+=1\\n\\nprint(advance)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A soldier wants to buy w bananas in the shop. He has to pay k dollars for the first banana, 2k dollars for the second one and so on (in other words, he has to pay i·k dollars for the i-th banana). \\n\\nHe has n dollars. How many dollars does he have to borrow from his friend soldier to buy w bananas?\\n\\nInput\\n\\nThe first line contains three positive integers k, n, w (1 ≤ k, w ≤ 1000, 0 ≤ n ≤ 109), the cost of the first banana, initial number of dollars the soldier has and number of bananas he wants. \\n\\nOutput\\n\\nOutput one integer — the amount of dollars that the soldier must borrow from his friend. If he doesn't have to borrow money, output 0.\\n\\nExamples\\n\\nInput\\n\\n3 17 4\\n\\n\\nOutput\\n\\n13\\nSolve the task in PYTHON3.\",\"targets\":\"k,n,w=map(int,input().strip().split())\\nsum=0\\nfor i in range(w):\\n i=i+1\\n sum=i*k+sum\\nif sum-n < 0:\\n print(0)\\nelse:\\n print(sum-n)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Kawasiro Nitori is excellent in engineering. Thus she has been appointed to help maintain trains.\\n\\nThere are n models of trains, and Nitori's department will only have at most one train of each model at any moment. In the beginning, there are no trains, at each of the following m days, one train will be added, or one train will be removed. When a train of model i is added at day t, it works for x_i days (day t inclusive), then it is in maintenance for y_i days, then in work for x_i days again, and so on until it is removed.\\n\\nIn order to make management easier, Nitori wants you to help her calculate how many trains are in maintenance in each day.\\n\\nOn a day a train is removed, it is not counted as in maintenance.\\n\\nInput\\n\\nThe first line contains two integers n, m (1 ≤ n,m ≤ 2 ⋅ 10^5).\\n\\nThe i-th of the next n lines contains two integers x_i,y_i (1 ≤ x_i,y_i ≤ 10^9).\\n\\nEach of the next m lines contains two integers op, k (1 ≤ k ≤ n, op = 1 or op = 2). If op=1, it means this day's a train of model k is added, otherwise the train of model k is removed. It is guaranteed that when a train of model x is added, there is no train of the same model in the department, and when a train of model x is removed, there is such a train in the department.\\n\\nOutput\\n\\nPrint m lines, The i-th of these lines contains one integers, denoting the number of trains in maintenance in the i-th day.\\n\\nExamples\\n\\nInput\\n\\n\\n3 4\\n10 15\\n12 10\\n1 1\\n1 3\\n1 1\\n2 1\\n2 3\\n\\n\\nOutput\\n\\n\\n0\\n1\\n0\\n0\\n\\n\\nInput\\n\\n\\n5 4\\n1 1\\n10000000 100000000\\n998244353 1\\n2 1\\n1 2\\n1 5\\n2 5\\n1 5\\n1 1\\n\\n\\nOutput\\n\\n\\n0\\n0\\n0\\n1\\n\\nNote\\n\\nConsider the first example:\\n\\nThe first day: Nitori adds a train of model 3. Only a train of model 3 is running and no train is in maintenance.\\n\\nThe second day: Nitori adds a train of model 1. A train of model 1 is running and a train of model 3 is in maintenance.\\n\\nThe third day: Nitori removes a train of model 1. The situation is the same as the first day.\\n\\nThe fourth day: Nitori removes a train of model 3. There are no trains at all.\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 2e5 + 50, mod = 998244353, sqr = 500;\\nint n, m, x[N], y[N], ans[505][505], ans2[N], pref[N], st[N];\\nvector v[N];\\nint32_t main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cin >> n >> m;\\n for (int i = 1; i <= n; i++) cin >> x[i] >> y[i];\\n for (int i = 1; i <= m; i++) {\\n int op, idx;\\n cin >> op >> idx;\\n if (x[idx] + y[idx] >= sqr)\\n v[idx].push_back(i);\\n else {\\n if (op == 1) {\\n st[idx] = i;\\n int len = x[idx] + y[idx], start = st[idx] % len;\\n for (int j = 0; j < len; j++) {\\n int diff = (j - start + len) % len;\\n if (diff >= x[idx]) ans[len][j]++;\\n }\\n } else {\\n int len = x[idx] + y[idx], start = st[idx] % len;\\n for (int j = 0; j < len; j++) {\\n int diff = (j - start + len) % len;\\n if (diff >= x[idx]) ans[len][j]--;\\n }\\n }\\n }\\n for (int len = 2; len < sqr; len++) ans2[i] += ans[len][i % len];\\n }\\n for (int i = 1; i <= n; i++) {\\n if (v[i].empty()) continue;\\n if (v[i].size() % 2) v[i].push_back(m + 1);\\n for (int j = 0; j < v[i].size(); j += 2) {\\n int start = v[i][j] + x[i], period = x[i] + y[i];\\n while (start < v[i][j + 1]) {\\n int en = start + y[i];\\n en = min(en, v[i][j + 1]);\\n pref[start]++;\\n pref[en]--;\\n start += period;\\n }\\n }\\n }\\n for (int i = 1; i <= m; i++) {\\n pref[i] += pref[i - 1];\\n cout << pref[i] + ans2[i] << '\\\\n';\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nBarney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2i + 1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two intersections.\\n\\n\\n\\nInitially anyone can pass any road for free. But since SlapsGiving is ahead of us, there will q consecutive events happen soon. There are two types of events:\\n\\n1. Government makes a new rule. A rule can be denoted by integers v, u and w. As the result of this action, the passing fee of all roads on the shortest path from u to v increases by w dollars. \\n\\n2. Barney starts moving from some intersection v and goes to intersection u where there's a girl he wants to cuddle (using his fake name Lorenzo Von Matterhorn). He always uses the shortest path (visiting minimum number of intersections or roads) between two intersections.\\n\\nGovernment needs your calculations. For each time Barney goes to cuddle a girl, you need to tell the government how much money he should pay (sum of passing fee of all roads he passes).\\n\\nInput\\n\\nThe first line of input contains a single integer q (1 ≤ q ≤ 1 000).\\n\\nThe next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v by w dollars, or in form 2 v u if it's an event when Barnie goes to cuddle from the intersection v to the intersection u.\\n\\n1 ≤ v, u ≤ 1018, v ≠ u, 1 ≤ w ≤ 109 states for every description line.\\n\\nOutput\\n\\nFor each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events.\\n\\nExample\\n\\nInput\\n\\n7\\n1 3 4 30\\n1 4 1 2\\n1 3 6 8\\n2 4 3\\n1 6 1 40\\n2 3 7\\n2 2 4\\n\\n\\nOutput\\n\\n94\\n0\\n32\\n\\nNote\\n\\nIn the example testcase:\\n\\nHere are the intersections used:\\n\\n\\n\\n 1....\",\"targets\":\"#include \\nusing namespace std;\\nint Log2(long long u) {\\n int k = 0;\\n while (u > 0) {\\n ++k;\\n u \\/= 2;\\n }\\n return k;\\n}\\nint main() {\\n int queries;\\n cin >> queries;\\n map cost;\\n for (int qi = 0; qi < queries; ++qi) {\\n int type;\\n cin >> type;\\n if (type == 1) {\\n long long u, v, w;\\n cin >> u >> v >> w;\\n if (u > v) {\\n swap(u, v);\\n }\\n int logu = Log2(u);\\n int logv = Log2(v);\\n while (logv > logu) {\\n cost[v] += w;\\n v \\/= 2;\\n logv--;\\n }\\n while (u != v) {\\n cost[u] += w;\\n cost[v] += w;\\n u \\/= 2;\\n v \\/= 2;\\n }\\n } else {\\n long long u, v;\\n cin >> u >> v;\\n if (u > v) {\\n swap(u, v);\\n }\\n int logu = Log2(u);\\n int logv = Log2(v);\\n long long res = 0;\\n while (logv > logu) {\\n res += cost[v];\\n v \\/= 2;\\n logv--;\\n }\\n while (u != v) {\\n res += cost[u];\\n res += cost[v];\\n u \\/= 2;\\n v \\/= 2;\\n }\\n cout << res << endl;\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given a digital clock with n digits. Each digit shows an integer from 0 to 9, so the whole clock shows an integer from 0 to 10^n-1. The clock will show leading zeroes if the number is smaller than 10^{n-1}.\\n\\nYou want the clock to show 0 with as few operations as possible. In an operation, you can do one of the following: \\n\\n * decrease the number on the clock by 1, or \\n * swap two digits (you can choose which digits to swap, and they don't have to be adjacent). \\n\\n\\n\\nYour task is to determine the minimum number of operations needed to make the clock show 0.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^3).\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 100) — number of digits on the clock.\\n\\nThe second line of each test case contains a string of n digits s_1, s_2, …, s_n (0 ≤ s_1, s_2, …, s_n ≤ 9) — the number on the clock.\\n\\nNote: If the number is smaller than 10^{n-1} the clock will show leading zeroes.\\n\\nOutput\\n\\nFor each test case, print one integer: the minimum number of operations needed to make the clock show 0.\\n\\nExample\\n\\nInput\\n\\n\\n7\\n3\\n007\\n4\\n1000\\n5\\n00000\\n3\\n103\\n4\\n2020\\n9\\n123456789\\n30\\n001678294039710047203946100020\\n\\n\\nOutput\\n\\n\\n7\\n2\\n0\\n5\\n6\\n53\\n115\\n\\nNote\\n\\nIn the first example, it's optimal to just decrease the number 7 times.\\n\\nIn the second example, we can first swap the first and last position and then decrease the number by 1.\\n\\nIn the third example, the clock already shows 0, so we don't have to perform any operations.\\nfor i\",\"targets\":\"in range(int(input())):\\n n = int(input())\\n number = list(map(int, list(input())))\\n summ = sum(number)\\n changes = n - number.count(0)\\n if number[-1] != 0:\\n changes -= 1\\n print(summ + changes)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"Grandma Capa has decided to knit a scarf and asked Grandpa Sher to make a pattern for it, a pattern is a string consisting of lowercase English letters. Grandpa Sher wrote a string s of length n.\\n\\nGrandma Capa wants to knit a beautiful scarf, and in her opinion, a beautiful scarf can only be knit from a string that is a palindrome. She wants to change the pattern written by Grandpa Sher, but to avoid offending him, she will choose one lowercase English letter and erase some (at her choice, possibly none or all) occurrences of that letter in string s.\\n\\nShe also wants to minimize the number of erased symbols from the pattern. Please help her and find the minimum number of symbols she can erase to make string s a palindrome, or tell her that it's impossible. Notice that she can only erase symbols equal to the one letter she chose.\\n\\nA string is a palindrome if it is the same from the left to the right and from the right to the left. For example, the strings 'kek', 'abacaba', 'r' and 'papicipap' are palindromes, while the strings 'abb' and 'iq' are not.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. The next 2 ⋅ t lines contain the description of test cases. The description of each test case consists of two lines.\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 10^5) — the length of the string.\\n\\nThe second line of each test case contains the string s consisting of n lowercase English letters.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case print the minimum number of erased symbols required to make the string a palindrome, if it is possible, and -1, if it is impossible.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n8\\nabcaacab\\n6\\nxyzxyz\\n4\\nabba\\n8\\nrprarlap\\n10\\nkhyyhhyhky\\n\\n\\nOutput\\n\\n\\n2\\n-1\\n0\\n3\\n2\\n\\nNote\\n\\nIn the first test case, you can choose a letter 'a' and erase its first and last occurrences, you will get a string 'bcaacb', which is a palindrome. You can also choose a letter 'b' and erase all its occurrences, you...\\\":\",\"targets\":\"import java.io.*;\\nimport java.math.BigDecimal;\\nimport java.math.BigInteger;\\nimport java.util.ArrayList;\\nimport java.util.Arrays;\\nimport java.util.Collections;\\nimport java.util.Comparator;\\nimport java.util.Deque;\\nimport java.util.HashMap;\\nimport java.util.HashSet;\\nimport java.util.LinkedList;\\nimport java.util.List;\\nimport java.util.Map;\\nimport java.util.Map.Entry;\\nimport java.util.PriorityQueue;\\nimport java.util.Queue;\\nimport java.util.Scanner;\\nimport java.util.Stack;\\nimport java.util.TreeMap;\\nimport java.util.TreeSet;\\n\\npublic class Main {\\n\\tint t,a,b,c,i,j,n,k,u,v,w,x,l,r,ans;\\n\\tvoid run(String[]args) throws IOException{\\n\\/\\/\\t\\tScanner in=new Scanner(System.in);\\n\\t\\tt=in();\\n\\t\\tss:while(t-->0)\\n\\t\\t{\\n\\t\\t\\tn=in();\\n\\t\\t\\tchar[]ch=ins().toCharArray();\\n\\t\\t\\t{\\n\\t\\t\\t\\tl=0;\\n\\t\\t\\t\\tr=n-1;\\n\\t\\t\\t\\twhile(l=r) {\\n\\t\\t\\t\\t\\tout.println(0);\\n\\t\\t\\t\\t\\tcontinue ss;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\ti=l;\\n\\t\\t\\tj=r;\\n\\t\\t\\tans=-1;\\n\\t\\t\\t{\\n\\t\\t\\t\\tl=i;\\n\\t\\t\\t\\tr=j;\\n\\t\\t\\t\\ta=0;\\n\\t\\t\\t\\twhile(l=r) {\\n\\t\\t\\t\\t\\tans=a;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\t{\\n\\t\\t\\t\\tl=i;\\n\\t\\t\\t\\tr=j;\\n\\t\\t\\t\\ta=0;\\n\\t\\t\\t\\twhile(l=r) {\\n\\t\\t\\t\\t\\tif(ans==-1)ans=a;\\n\\t\\t\\t\\t\\telse ans=Math.min(ans, a);\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\tout.println(ans);\\n\\t\\t}\\n\\t\\tout.flush();\\n\\t}\\n\\tpublic static void main(String[]args) throws IOException {\\n\\t\\tnew Main().run(args);\\n\\t}\\n\\tStreamTokenizer in=new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));\\n\\tPrintWriter out=new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));\\n\\tdouble ind() throws IOException {\\n\\t\\tin.nextToken();\\n\\t\\treturn in.nval;\\n\\t}\\n\\tint in() throws IOException {\\n\\t\\tin.nextToken();\\n\\t\\treturn(int)in.nval;\\n\\t}\\n\\tlong inl() throws IOException...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PizzaForces is Petya's favorite pizzeria. PizzaForces makes and sells pizzas of three sizes: small pizzas consist of 6 slices, medium ones consist of 8 slices, and large pizzas consist of 10 slices each. Baking them takes 15, 20 and 25 minutes, respectively.\\n\\nPetya's birthday is today, and n of his friends will come, so he decided to make an order from his favorite pizzeria. Petya wants to order so much pizza that each of his friends gets at least one slice of pizza. The cooking time of the order is the total baking time of all the pizzas in the order.\\n\\nYour task is to determine the minimum number of minutes that is needed to make pizzas containing at least n slices in total. For example: \\n\\n * if 12 friends come to Petya's birthday, he has to order pizzas containing at least 12 slices in total. He can order two small pizzas, containing exactly 12 slices, and the time to bake them is 30 minutes; \\n * if 15 friends come to Petya's birthday, he has to order pizzas containing at least 15 slices in total. He can order a small pizza and a large pizza, containing 16 slices, and the time to bake them is 40 minutes; \\n * if 300 friends come to Petya's birthday, he has to order pizzas containing at least 300 slices in total. He can order 15 small pizzas, 10 medium pizzas and 13 large pizzas, in total they contain 15 ⋅ 6 + 10 ⋅ 8 + 13 ⋅ 10 = 300 slices, and the total time to bake them is 15 ⋅ 15 + 10 ⋅ 20 + 13 ⋅ 25 = 750 minutes; \\n * if only one friend comes to Petya's birthday, he can order a small pizza, and the time to bake it is 15 minutes. \\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.\\n\\nEach testcase consists of a single line that contains a single integer n (1 ≤ n ≤ 10^{16}) — the number of Petya's friends.\\n\\nOutput\\n\\nFor each testcase, print one integer — the minimum number of minutes that is needed to bake pizzas containing at least n slices in total.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n12\\n15\\n300\\n1\\n9999999999999999\\n3\\n\\n\\nOutput\\n\\n\\n30\\n40\\n750\\n15\\n25000000000000000\\n15\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nvoid main0();\\nint main() {\\n clock_t start, end;\\n ios::sync_with_stdio(false);\\n cin.tie(0);\\n main0();\\n return 0;\\n}\\nconst int dx[8] = {0, 1, -1, 0, 1, 1, -1, -1};\\nconst int dy[8] = {1, 0, 0, -1, 1, -1, -1, 1};\\nconst int N = 2e5 + 5;\\nconst int M = 1e5;\\nconst int INF = 0x3f3f3f3f;\\nconst long long INFF = 0x3f3f3f3f3f3f3f3f;\\nconst int mod = 998244353;\\nconst double eps = 1e-6;\\nconst double Pi = acos(-1.0);\\nmt19937 rnd(\\n (unsigned int)chrono::steady_clock::now().time_since_epoch().count());\\nlong long qpow(long long n, long long m) {\\n long long ret = 1;\\n while (m) {\\n if (m & 1) ret = ret * n % mod;\\n n = n * n % mod;\\n m >>= 1;\\n }\\n return ret;\\n}\\nlong long getinv(long long a) { return qpow(a, mod - 2); }\\nvoid main0() {\\n int T;\\n cin >> T;\\n while (T--) {\\n long long n;\\n cin >> n;\\n n = max(6ll, n);\\n n = (n + 1) \\/ 2;\\n cout << 5 * n << endl;\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Theofanis really likes sequences of positive integers, thus his teacher (Yeltsa Kcir) gave him a problem about a sequence that consists of only special numbers.\\n\\nLet's call a positive number special if it can be written as a sum of different non-negative powers of n. For example, for n = 4 number 17 is special, because it can be written as 4^0 + 4^2 = 1 + 16 = 17, but 9 is not.\\n\\nTheofanis asks you to help him find the k-th special number if they are sorted in increasing order. Since this number may be too large, output it modulo 10^9+7.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases.\\n\\nThe first and only line of each test case contains two integers n and k (2 ≤ n ≤ 10^9; 1 ≤ k ≤ 10^9).\\n\\nOutput\\n\\nFor each test case, print one integer — the k-th special number in increasing order modulo 10^9+7.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n3 4\\n2 12\\n105 564\\n\\n\\nOutput\\n\\n\\n9\\n12\\n3595374\\n\\nNote\\n\\nFor n = 3 the sequence is [1,3,4,9...]\\nUsing java can you solve the prior task?\",\"targets\":\"\\/* package codechef; \\/\\/ don't place package name! *\\/\\n\\nimport java.util.*;\\nimport java.lang.*;\\nimport java.io.*;\\n\\n\\/* Name of the class has to be \\\"Main\\\" only if the class is public. *\\/\\npublic class Codechef\\n{ static long mod=1000000007;\\n\\tpublic static void main (String[] args) throws java.lang.Exception\\n\\t{\\n\\t\\t\\/\\/your code goes here\\nScanner sc=new Scanner(System.in);\\nint t=sc.nextInt();\\nwhile(t>0){t--;\\n\\t\\t long n=sc.nextLong();\\n\\t\\t long k=sc.nextLong();\\n\\t\\t long ans=0;\\n\\t\\t \\n\\t\\t for(int i=0;i<=36;i++){\\n\\t\\t if((k&1)==1){\\n\\t\\t ans=(ans%mod+pow(n,i))%mod;\\n\\t\\t }\\n\\t\\t k=k>>1;\\n\\t\\t }\\n\\t\\t \\n\\t\\t System.out.println(ans%mod);\\n\\t}}\\n\\t\\n\\tstatic long pow(long a,long b){\\n\\t \\n\\t if(b==0){\\n\\t return 1;\\n\\t }\\n\\t \\n\\t \\n\\t long x=pow(a,b\\/2);\\n\\t if(b%2==0){\\n\\t return (x%mod*x%mod)%mod;\\n\\t }\\n\\t else{\\n\\t return ((a%mod)*(x%mod*x%mod)%mod)%mod;\\n\\t }\\n\\t \\n\\t}\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"You are given a rooted tree consisting of n vertices numbered from 1 to n. The root of the tree is the vertex 1.\\n\\nYou have to color all vertices of the tree into n colors (also numbered from 1 to n) so that there is exactly one vertex for each color. Let c_i be the color of vertex i, and p_i be the parent of vertex i in the rooted tree. The coloring is considered beautiful if there is no vertex k (k > 1) such that c_k = c_{p_k} - 1, i. e. no vertex such that its color is less than the color of its parent by exactly 1.\\n\\nCalculate the number of beautiful colorings, and print it modulo 998244353.\\n\\nInput\\n\\nThe first line contains one integer n (2 ≤ n ≤ 250000) — the number of vertices in the tree.\\n\\nThen n-1 lines follow, the i-th line contains two integers x_i and y_i (1 ≤ x_i, y_i ≤ n; x_i ≠ y_i) denoting an edge between the vertex x_i and the vertex y_i. These edges form a tree.\\n\\nOutput\\n\\nPrint one integer — the number of beautiful colorings, taken modulo 998244353.\\n\\nExamples\\n\\nInput\\n\\n\\n5\\n1 2\\n3 2\\n4 2\\n2 5\\n\\n\\nOutput\\n\\n\\n42\\n\\n\\nInput\\n\\n\\n5\\n1 2\\n2 3\\n3 4\\n4 5\\n\\n\\nOutput\\n\\n\\n53\\n\\n\\nInput\\n\\n\\n20\\n20 19\\n20 4\\n12 4\\n5 8\\n1 2\\n20 7\\n3 10\\n7 18\\n11 8\\n9 10\\n17 10\\n1 15\\n11 16\\n14 11\\n18 10\\n10 1\\n14 2\\n13 17\\n20 6\\n\\n\\nOutput\\n\\n\\n955085064\\\":\",\"targets\":\"#include \\nusing namespace std;\\nconst int G = 3;\\nconst int Gi = 332748118;\\nlong long su(long long a, long long b) {\\n a += b;\\n return (a >= 998244353) ? a - 998244353 : a;\\n}\\nint r[300000], lim;\\nlong long ksm(long long a, long long p) {\\n long long res = 1;\\n while (p) {\\n if (p & 1) {\\n res = res * a % 998244353;\\n }\\n a = a * a % 998244353;\\n p >>= 1;\\n }\\n return res;\\n}\\nvoid ntt(vector &A, int type) {\\n for (int i = 0; i <= lim - 1; ++i) {\\n if (i < r[i]) swap(A[i], A[r[i]]);\\n }\\n for (int mid = 1; mid <= lim - 1; mid <<= 1) {\\n long long Wn = ksm(type == 1 ? G : Gi, (998244353 - 1) \\/ (mid << 1));\\n for (int j = 0; j <= lim - 1; j += (mid << 1)) {\\n long long w = 1;\\n for (int k = 0; k <= mid - 1; ++k, w = (w * Wn) % 998244353) {\\n int x = A[j + k];\\n int y = w * A[j + mid + k] % 998244353;\\n A[j + k] = su(x, y);\\n A[j + mid + k] = su(x, 998244353 - y);\\n }\\n }\\n }\\n if (type == -1) {\\n long long tmp = ksm(lim, 998244353 - 2);\\n for (int i = 0; i <= lim - 1; ++i) {\\n A[i] = A[i] * tmp % 998244353;\\n }\\n }\\n}\\nvector operator*(vector A, vector B) {\\n int len = A.size() + B.size() - 1;\\n lim = 1;\\n while (lim <= len) lim <<= 1;\\n for (int i = 0; i <= lim - 1; ++i) {\\n r[i] = (r[i >> 1] >> 1) | ((i & 1) * (lim >> 1));\\n }\\n A.resize(lim);\\n B.resize(lim);\\n ntt(A, 1);\\n ntt(B, 1);\\n for (int i = 0; i <= lim - 1; ++i) {\\n A[i] = A[i] * B[i] % 998244353;\\n }\\n ntt(A, -1);\\n A.resize(len);\\n return A;\\n}\\nint i, j, k, n, m, t, a[250005];\\nlong long jc[250005];\\nvector v;\\nvector work(int l, int r) {\\n if (l == r) {\\n return {1, a[l] - (l != 1)};\\n }\\n return work(l, (l + r) \\/ 2) * work((l + r) \\/ 2 + 1, r);\\n}\\nint main() {\\n jc[0] = 1;\\n for (i = 1; i <= 250000; i++) {\\n jc[i] = jc[i - 1] * i % 998244353;\\n }\\n ios::sync_with_stdio(0);\\n cin >> n;\\n for (i = 1; i < n; i++) {\\n cin >> j >> k;\\n a[j]++;\\n a[k]++;\\n }\\n v = work(1, n);\\n long long res = 0;\\n for (i...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Polycarp likes squares and cubes of positive integers. Here is the beginning of the sequence of numbers he likes: 1, 4, 8, 9, ....\\n\\nFor a given number n, count the number of integers from 1 to n that Polycarp likes. In other words, find the number of such x that x is a square of a positive integer number or a cube of a positive integer number (or both a square and a cube simultaneously).\\n\\nInput\\n\\nThe first line contains an integer t (1 ≤ t ≤ 20) — the number of test cases.\\n\\nThen t lines contain the test cases, one per line. Each of the lines contains one integer n (1 ≤ n ≤ 10^9).\\n\\nOutput\\n\\nFor each test case, print the answer you are looking for — the number of integers from 1 to n that Polycarp likes.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n10\\n1\\n25\\n1000000000\\n999999999\\n500000000\\n\\n\\nOutput\\n\\n\\n4\\n1\\n6\\n32591\\n32590\\n23125\\nUsing java can you solve the prior task?\",\"targets\":\"import java.util.*;\\nimport java.lang.*;\\nimport java.io.*;\\n\\n\\/* Name of the class has to be \\\"Main\\\" only if the class is public. *\\/\\npublic class Codechef\\n{\\n\\tpublic static void main (String[] args) throws java.lang.Exception\\n\\t{\\n\\t\\t\\/\\/ your code goes here\\n\\t\\tScanner sc = new Scanner(System.in);\\n\\t\\tint t = sc.nextInt();\\n\\t\\twhile(t-- > 0) {\\n\\t\\t long n = sc.nextLong();\\n\\t\\t HashSet set = new HashSet<>();\\n\\t\\t for(long i=1;i*i<=n;i++){\\n\\t\\t set.add(i*i);\\n\\t\\t }\\n\\t\\t \\n\\t\\t for(long i=1;i*i*i<=n;i++){\\n\\t\\t set.add(i*i*i);\\n\\t\\t }\\n\\t\\t \\n\\t\\t System.out.println(set.size());\\n\\t\\t}\\n\\t}\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given a book with n chapters.\\n\\nEach chapter has a specified list of other chapters that need to be understood in order to understand this chapter. To understand a chapter, you must read it after you understand every chapter on its required list.\\n\\nCurrently you don't understand any of the chapters. You are going to read the book from the beginning till the end repeatedly until you understand the whole book. Note that if you read a chapter at a moment when you don't understand some of the required chapters, you don't understand this chapter.\\n\\nDetermine how many times you will read the book to understand every chapter, or determine that you will never understand every chapter no matter how many times you read the book.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 2⋅10^4).\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 2⋅10^5) — number of chapters.\\n\\nThen n lines follow. The i-th line begins with an integer k_i (0 ≤ k_i ≤ n-1) — number of chapters required to understand the i-th chapter. Then k_i integers a_{i,1}, a_{i,2}, ..., a_{i, k_i} (1 ≤ a_{i, j} ≤ n, a_{i, j} ≠ i, a_{i, j} ≠ a_{i, l} for j ≠ l) follow — the chapters required to understand the i-th chapter.\\n\\nIt is guaranteed that the sum of n and sum of k_i over all testcases do not exceed 2⋅10^5.\\n\\nOutput\\n\\nFor each test case, if the entire book can be understood, print how many times you will read it, otherwise print -1.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n4\\n1 2\\n0\\n2 1 4\\n1 2\\n5\\n1 5\\n1 1\\n1 2\\n1 3\\n1 4\\n5\\n0\\n0\\n2 1 2\\n1 2\\n2 2 1\\n4\\n2 2 3\\n0\\n0\\n2 3 2\\n5\\n1 2\\n1 3\\n1 4\\n1 5\\n0\\n\\n\\nOutput\\n\\n\\n2\\n-1\\n1\\n2\\n5\\n\\nNote\\n\\nIn the first example, we will understand chapters \\\\{2, 4\\\\} in the first reading and chapters \\\\{1, 3\\\\} in the second reading of the book.\\n\\nIn the second example, every chapter requires the understanding of some other chapter, so it is impossible to understand the book.\\n\\nIn the third example, every chapter requires only chapters that appear earlier in the book, so we can understand everything in one...\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\n\\npublic final class Main {\\n\\n static PrintWriter out = new PrintWriter(System.out);\\n static FastReader in = new FastReader();\\n static Pair[] moves = new Pair[]{new Pair(-1, 0), new Pair(1, 0), new Pair(0, -1), new Pair(0, 1)};\\n static int mod = (int) (1e9 + 7);\\n\\n public static void main(String[] args) {\\n int tt = i();\\n while (tt-- > 0) {\\n solve();\\n }\\n out.flush();\\n }\\n\\n public static void solve() {\\n int n = i();\\n\\n int[] deg = new int[n];\\n List[] edges = new List[n];\\n for (int i = 0; i < n; i++) {\\n edges[i] = new ArrayList<>();\\n }\\n for (int i = 0; i < n; i++) {\\n int m = i();\\n for (int j = 0; j < m; j++) {\\n int u = i() - 1;\\n edges[u].add(i);\\n deg[i]++;\\n }\\n }\\n\\n PriorityQueue pq = new PriorityQueue<>(new Comparator() {\\n @Override\\n public int compare(int[] o1, int[] o2) {\\n return o1[0] - o2[0];\\n }\\n }.thenComparing(new Comparator() {\\n @Override\\n public int compare(int[] o1, int[] o2) {\\n return o1[1] - o2[1];\\n }\\n }));\\n for (int i = 0; i < n; i++) {\\n if (deg[i] == 0) {\\n pq.offer(new int[]{1, i});\\n }\\n }\\n\\n int cnt = 0;\\n int max = 1;\\n while (pq.size() > 0) {\\n int[] cur = pq.poll();\\n cnt++;\\n max = Math.max(max, cur[0]);\\n\\n for (int v : edges[cur[1]]) {\\n deg[v]--;\\n if (deg[v] == 0) {\\n if (v > cur[1]) {\\n pq.offer(new int[]{cur[0], v});\\n } else {\\n pq.offer(new int[]{cur[0] + 1, v});\\n }\\n }\\n }\\n }\\n\\n if (cnt < n) {\\n out.println(-1);\\n } else {\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nThis is a simplified version of the problem B2. Perhaps you should read the problem B2 before you start solving B1.\\n\\nPaul and Mary have a favorite string s which consists of lowercase letters of the Latin alphabet. They want to paint it using pieces of chalk of two colors: red and green. Let's call a coloring of a string wonderful if the following conditions are met:\\n\\n 1. each letter of the string is either painted in exactly one color (red or green) or isn't painted; \\n 2. each two letters which are painted in the same color are different; \\n 3. the number of letters painted in red is equal to the number of letters painted in green; \\n 4. the number of painted letters of this coloring is maximum among all colorings of the string which meet the first three conditions. \\n\\n\\n\\nE. g. consider a string s equal to \\\"kzaaa\\\". One of the wonderful colorings of the string is shown in the figure.\\n\\n The example of a wonderful coloring of the string \\\"kzaaa\\\".\\n\\nPaul and Mary want to learn by themselves how to find a wonderful coloring of the string. But they are very young, so they need a hint. Help them find k — the number of red (or green, these numbers are equal) letters in a wonderful coloring.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 1000) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one non-empty string s which consists of lowercase letters of the Latin alphabet. The number of characters in the string doesn't exceed 50.\\n\\nOutput\\n\\nFor each test case, output a separate line containing one non-negative integer k — the number of letters which will be painted in red in a wonderful coloring.\\n\\nExample\\n\\nInput\\n\\n\\n5\\nkzaaa\\ncodeforces\\narchive\\ny\\nxxxxxx\\n\\n\\nOutput\\n\\n\\n2\\n5\\n3\\n0\\n1\\n\\nNote\\n\\nThe first test case contains the string from the statement. One of the wonderful colorings is shown in the figure. There's no wonderful coloring containing 3 or more red letters because the total number of painted symbols will exceed the string's length.\\n\\nThe string from the second test case can be...\",\"targets\":\"\\/\\/package MyPackage;\\nimport java.io.*;\\nimport java.util.*;\\npublic class MyClass {\\n final static long mod = 1_000_000_007;\\n final static int mini = Integer.MIN_VALUE;\\n final static int maxi = Integer.MAX_VALUE;\\n static long gcd(long a, long b) {\\n if (b == 0) return a;\\n return gcd(b, a % b);\\n }\\n static boolean isPrime(int n) {\\n if (n <= 1)\\n return false;\\n else if (n == 2)\\n return true;\\n else if (n % 2 == 0)\\n return false;\\n for (int i = 3; i <= Math.sqrt(n); i += 2) {\\n if (n % i == 0)\\n return false;\\n }\\n return true;\\n }\\n static int digits(long n) {\\n int count = 0;\\n long temp = n;\\n while (temp > 0) {\\n temp \\/= 10;\\n count++;\\n }\\n return count;\\n }\\n static boolean isPalindrome(long i) {\\n long originalNum = i;\\n long remainder;\\n long reversedNum = 0;\\n while (i != 0) {\\n remainder = i % 10;\\n reversedNum = reversedNum * 10 + remainder;\\n i \\/= 10;\\n }\\n return originalNum == reversedNum;\\n }\\n static long lcm(long a, long b) {\\n return (a \\/ gcd(a, b)) * b;\\n }\\n static void sort(long[] a) {\\n ArrayList l = new ArrayList<>();\\n for (long value : a) {\\n l.add(value);\\n }\\n Collections.sort(l);\\n for (int i = 0; i < l.size(); i++)\\n a[i] = l.get(i);\\n }\\n static void sort(int[] a) {\\n ArrayList l = new ArrayList<>();\\n for (int value : a) {\\n l.add(value);\\n }\\n Collections.sort(l);\\n for (int i = 0; i < l.size(); i++)\\n a[i] = l.get(i);\\n }\\n static void reverse(int[] arr) {\\n int l = 0;\\n int h = arr.length - 1;\\n while (l < h) {\\n swap(arr, l, h);\\n l++;\\n h--;\\n }\\n }\\n static String reverse(String s) {\\n StringBuilder res = new StringBuilder(s);\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Polycarp had an array a of 3 positive integers. He wrote out the sums of all non-empty subsequences of this array, sorted them in non-decreasing order, and got an array b of 7 integers.\\n\\nFor example, if a = \\\\{1, 4, 3\\\\}, then Polycarp wrote out 1, 4, 3, 1 + 4 = 5, 1 + 3 = 4, 4 + 3 = 7, 1 + 4 + 3 = 8. After sorting, he got an array b = \\\\{1, 3, 4, 4, 5, 7, 8\\\\}.\\n\\nUnfortunately, Polycarp lost the array a. He only has the array b left. Help him to restore the array a.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 5000) — the number of test cases.\\n\\nEach test case consists of one line which contains 7 integers b_1, b_2, ..., b_7 (1 ≤ b_i ≤ 10^9; b_i ≤ b_{i+1}). \\n\\nAdditional constraint on the input: there exists at least one array a which yields this array b as described in the statement.\\n\\nOutput\\n\\nFor each test case, print 3 integers — a_1, a_2 and a_3. If there can be several answers, print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n1 3 4 4 5 7 8\\n1 2 3 4 5 6 7\\n300000000 300000000 300000000 600000000 600000000 600000000 900000000\\n1 1 2 999999998 999999999 999999999 1000000000\\n1 2 2 3 3 4 5\\n\\n\\nOutput\\n\\n\\n1 4 3\\n4 1 2\\n300000000 300000000 300000000\\n999999998 1 1\\n1 2 2\\n\\nNote\\n\\nThe subsequence of the array a is a sequence that can be obtained from a by removing zero or more of its elements.\\n\\nTwo subsequences are considered different if index sets of elements included in them are different. That is, the values of the elements don't matter in the comparison of subsequences. In particular, any array of length 3 has exactly 7 different non-empty subsequences.\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 5e5 + 5;\\nconst long long inf = 0x3f3f3f3f3f3f3f3f;\\nconst long long mod = 1e9 + 7;\\ntemplate \\nvoid inline read(T &x) {\\n int f = 1;\\n x = 0;\\n char s = getchar();\\n while (s<'0' | s> '9') {\\n if (s == '-') f = -1;\\n s = getchar();\\n }\\n while (s <= '9' && s >= '0')\\n x = (x << 3) + (x << 1) + (s ^ 48), s = getchar();\\n x *= f;\\n}\\nlong long n, m, x, y, a[N], b[N];\\nvector G[N];\\ninline void run() {\\n for (long long i = (long long)(1); i <= (long long)(7); i++) {\\n cin >> a[i];\\n }\\n sort(a + 1, a + 8);\\n cout << a[1] << \\\" \\\" << a[2] << \\\" \\\" << a[7] - a[1] - a[2] << '\\\\n';\\n}\\nsigned main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(nullptr), cout.tie(nullptr);\\n long long T;\\n for (cin >> T; T > 0; T--) run();\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Appleman and Toastman play a game. Initially Appleman gives one group of n numbers to the Toastman, then they start to complete the following tasks:\\n\\n * Each time Toastman gets a group of numbers, he sums up all the numbers and adds this sum to the score. Then he gives the group to the Appleman. \\n * Each time Appleman gets a group consisting of a single number, he throws this group out. Each time Appleman gets a group consisting of more than one number, he splits the group into two non-empty groups (he can do it in any way) and gives each of them to Toastman. \\n\\n\\n\\nAfter guys complete all the tasks they look at the score value. What is the maximum possible value of score they can get?\\n\\nInput\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 3·105). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 106) — the initial group that is given to Toastman.\\n\\nOutput\\n\\nPrint a single integer — the largest possible score.\\n\\nExamples\\n\\nInput\\n\\n3\\n3 1 5\\n\\n\\nOutput\\n\\n26\\n\\n\\nInput\\n\\n1\\n10\\n\\n\\nOutput\\n\\n10\\n\\nNote\\n\\nConsider the following situation in the first example. Initially Toastman gets group [3, 1, 5] and adds 9 to the score, then he give the group to Appleman. Appleman splits group [3, 1, 5] into two groups: [3, 5] and [1]. Both of them should be given to Toastman. When Toastman receives group [1], he adds 1 to score and gives the group to Appleman (he will throw it out). When Toastman receives group [3, 5], he adds 8 to the score and gives the group to Appleman. Appleman splits [3, 5] in the only possible way: [5] and [3]. Then he gives both groups to Toastman. When Toastman receives [5], he adds 5 to the score and gives the group to Appleman (he will throws it out). When Toastman receives [3], he adds 3 to the score and gives the group to Appleman (he will throws it out). Finally Toastman have added 9 + 1 + 8 + 5 + 3 = 26 to the score. This is the optimal sequence of actions.\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint n, a[312345];\\nint main(int argc, char const *argv[]) {\\n scanf(\\\"%d\\\", &n);\\n for (int i = 0; i < n; i++) scanf(\\\"%d\\\", &a[i]);\\n std::sort(a, a + n);\\n if (n == 1)\\n printf(\\\"%d\\\\n\\\", a[n - 1]);\\n else if (n == 2)\\n printf(\\\"%d\\\\n\\\", 2 * (a[0] + a[1]));\\n else {\\n long long ans = 0;\\n for (int i = 0; i < n; i++) ans += (long long)min(2 + i, n) * a[i];\\n printf(\\\"%I64d\\\\n\\\", ans);\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You have an array of integers (initially empty).\\n\\nYou have to perform q queries. Each query is of one of two types: \\n\\n * \\\"1 x\\\" — add the element x to the end of the array; \\n * \\\"2 x y\\\" — replace all occurrences of x in the array with y. \\n\\n\\n\\nFind the resulting array after performing all the queries.\\n\\nInput\\n\\nThe first line contains a single integer q (1 ≤ q ≤ 5 ⋅ 10^5) — the number of queries.\\n\\nNext q lines contain queries (one per line). Each query is of one of two types: \\n\\n * \\\"1 x\\\" (1 ≤ x ≤ 5 ⋅ 10^5); \\n * \\\"2 x y\\\" (1 ≤ x, y ≤ 5 ⋅ 10^5). \\n\\n\\n\\nIt's guaranteed that there is at least one query of the first type.\\n\\nOutput\\n\\nIn a single line, print k integers — the resulting array after performing all the queries, where k is the number of queries of the first type.\\n\\nExamples\\n\\nInput\\n\\n\\n7\\n1 3\\n1 1\\n2 1 2\\n1 2\\n1 1\\n1 2\\n2 1 3\\n\\n\\nOutput\\n\\n\\n3 2 2 3 2 \\n\\nInput\\n\\n\\n4\\n1 1\\n1 2\\n1 1\\n2 2 2\\n\\n\\nOutput\\n\\n\\n1 2 1 \\n\\nInput\\n\\n\\n8\\n2 1 4\\n1 1\\n1 4\\n1 2\\n2 2 4\\n2 4 3\\n1 2\\n2 2 7\\n\\n\\nOutput\\n\\n\\n1 3 3 7 \\n\\nNote\\n\\nIn the first example, the array changes as follows:\\n\\n[] → [3] → [3, 1] → [3, 2] → [3, 2, 2] → [3, 2, 2, 1] → [3, 2, 2, 1, 2] → [3, 2, 2, 3, 2].\\n\\nIn the second example, the array changes as follows:\\n\\n[] → [1] → [1, 2] → [1, 2, 1] → [1, 2, 1].\\n\\nIn the third example, the array changes as follows:\\n\\n[] → [] → [1] → [1, 4] → [1, 4, 2] → [1, 4, 4] → [1, 3, 3] → [1, 3, 3, 2] → [1, 3, 3, 7].\\nUsing java can you solve the prior task?\",\"targets\":\"import java.io.BufferedOutputStream;\\nimport java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStream;\\nimport java.io.InputStreamReader;\\nimport java.io.PrintWriter;\\nimport java.util.ArrayDeque;\\nimport java.util.Arrays;\\nimport java.util.InputMismatchException;\\nimport java.util.Map;\\nimport java.util.StringTokenizer;\\n\\npublic class A5 {\\n\\n void solve() {\\n TIntList[] map = new TIntList[500_001];\\n int n = cint();\\n int index = 0;\\n for (int i = 0; i < n; i++) {\\n String line = cstr();\\n if (line.startsWith(\\\"1\\\")) {\\n int x = Integer.parseInt(line.substring(2));\\n TIntList list = map[x];\\n if (list == null) {\\n map[x] = list = new TIntList();\\n }\\n list.add(index);\\n index++;\\n } else {\\n String[] p = line.substring(2).split(\\\"[\\\\\\\\s]\\\");\\n int x = Integer.parseInt(p[0]);\\n int y = Integer.parseInt(p[1]);\\n TIntList list = map[x];\\n if (list != null) {\\n map[x] = null;\\n TIntList list2 = map[y];\\n if (list2 != null) {\\n list2.add(list);\\n } else {\\n map[y] = list;\\n }\\n }\\n }\\n }\\n \\n int[] a = new int[index];\\n ArrayDeque queue = new ArrayDeque<>();\\n for (int x = 1; x < map.length; x++) {\\n TIntList list = map[x];\\n if (list != null) {\\n queue.add(list);\\n list.value = x;\\n }\\n }\\n \\n while (!queue.isEmpty()) {\\n TIntList list = queue.removeFirst();\\n int x = list.value;\\n for (int i = 0; i < list.len; i++) {\\n a[list.x[i]] = x;\\n }\\n for (int i = 0; i < list.leny; i++) {\\n list.y[i].value = x;\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"\\n\\nThis is an interactive task\\n\\nWilliam has a certain sequence of integers a_1, a_2, ..., a_n in his mind, but due to security concerns, he does not want to reveal it to you completely. William is ready to respond to no more than 2 ⋅ n of the following questions:\\n\\n * What is the result of a [bitwise AND](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#AND) of two items with indices i and j (i ≠ j) \\n * What is the result of a [bitwise OR](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#OR) of two items with indices i and j (i ≠ j) \\n\\n\\n\\nYou can ask William these questions and you need to find the k-th smallest number of the sequence.\\n\\nFormally the k-th smallest number is equal to the number at the k-th place in a 1-indexed array sorted in non-decreasing order. For example in array [5, 3, 3, 10, 1] 4th smallest number is equal to 5, and 2nd and 3rd are 3.\\n\\nInput\\n\\nIt is guaranteed that for each element in a sequence the condition 0 ≤ a_i ≤ 10^9 is satisfied.\\n\\nInteraction\\n\\nIn the first line you will be given two integers n and k (3 ≤ n ≤ 10^4, 1 ≤ k ≤ n), which are the number of items in the sequence a and the number k.\\n\\nAfter that, you can ask no more than 2 ⋅ n questions (not including the \\\"finish\\\" operation).\\n\\nEach line of your output may be of one of the following types: \\n\\n * \\\"or i j\\\" (1 ≤ i, j ≤ n, i ≠ j), where i and j are indices of items for which you want to calculate the bitwise OR. \\n * \\\"and i j\\\" (1 ≤ i, j ≤ n, i ≠ j), where i and j are indices of items for which you want to calculate the bitwise AND. \\n * \\\"finish res\\\", where res is the kth smallest number in the sequence. After outputting this line the program execution must conclude. \\n\\n\\n\\nIn response to the first two types of queries, you will get an integer x, the result of the operation for the numbers you have selected.\\n\\nAfter outputting a line do not forget to output a new line character and flush the output buffer. Otherwise you will get the \\\"Idleness limit exceeded\\\". To flush the buffer use:\\n\\n * fflush(stdout) in C++ \\n *...\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\n\\npublic class D_1556 {\\n\\tpublic static void main(String[] args) throws Exception {\\n\\t\\tScanner sc = new Scanner(System.in);\\n\\t\\tPrintWriter pw = new PrintWriter(System.out);\\n\\t\\t\\n\\t\\tint n = sc.nextInt(), k = sc.nextInt();\\n\\t\\tpw.println(\\\"or 1 2\\\");\\n\\t\\tpw.flush();\\n\\t\\tpw.println(\\\"and 1 2\\\");\\n\\t\\tpw.flush();\\n\\t\\tint k1 = sc.nextInt() + sc.nextInt();\\n\\t\\tpw.println(\\\"or 2 3\\\");\\n\\t\\tpw.flush();\\n\\t\\tpw.println(\\\"and 2 3\\\");\\n\\t\\tpw.flush();\\n\\t\\tint k2 = sc.nextInt() + sc.nextInt();\\n\\t\\tpw.println(\\\"or 1 3\\\");\\n\\t\\tpw.flush();\\n\\t\\tpw.println(\\\"and 1 3\\\");\\n\\t\\tpw.flush();\\n\\t\\tint k3 = sc.nextInt() + sc.nextInt();\\n\\t\\t\\n\\t\\tint[] array = new int[n];\\n\\t\\tarray[0] = (k1 - k2 + k3) \\/ 2;\\n\\t\\tarray[1] = k1 - array[0];\\n\\t\\tarray[2] = k3 - array[0];\\n\\t\\t\\n\\t\\tfor(int i = 3; i < n; i++) {\\n\\t\\t\\tpw.println(\\\"or 1 \\\" + (i + 1));\\n\\t\\t\\tpw.flush();\\n\\t\\t\\tpw.println(\\\"and 1 \\\" + (i + 1));\\n\\t\\t\\tpw.flush();\\n\\t\\t\\tint sum = sc.nextInt() + sc.nextInt();\\n\\t\\t\\tarray[i] = sum - array[0];\\n\\t\\t}\\n\\t\\t\\n\\t\\tArrays.sort(sc.shuffle(array));\\n\\t\\t\\n\\t\\tpw.println(\\\"finish \\\" + array[k - 1]);\\n\\t\\tpw.flush();\\n\\t}\\n\\n\\tpublic static class Scanner {\\n\\t\\tStringTokenizer st;\\n\\t\\tBufferedReader br;\\n\\n\\t\\tpublic Scanner(InputStream system) {\\n\\t\\t\\tbr = new BufferedReader(new InputStreamReader(system));\\n\\t\\t}\\n\\n\\t\\tpublic Scanner(String file) throws Exception {\\n\\t\\t\\tbr = new BufferedReader(new FileReader(file));\\n\\t\\t}\\n\\n\\t\\tpublic String next() throws IOException {\\n\\t\\t\\twhile (st == null || !st.hasMoreTokens())\\n\\t\\t\\t\\tst = new StringTokenizer(br.readLine());\\n\\t\\t\\treturn st.nextToken();\\n\\t\\t}\\n\\n\\t\\tpublic String nextLine() throws IOException {\\n\\t\\t\\treturn br.readLine();\\n\\t\\t}\\n\\n\\t\\tpublic int nextInt() throws IOException {\\n\\t\\t\\treturn Integer.parseInt(next());\\n\\t\\t}\\n\\n\\t\\tpublic double nextDouble() throws IOException {\\n\\t\\t\\treturn Double.parseDouble(next());\\n\\t\\t}\\n\\n\\t\\tpublic char nextChar() throws IOException {\\n\\t\\t\\treturn next().charAt(0);\\n\\t\\t}\\n\\n\\t\\tpublic long nextLong() throws IOException {\\n\\t\\t\\treturn Long.parseLong(next());\\n\\t\\t}\\n\\n\\t\\tpublic int[] nextIntArray(int n) throws IOException {\\n\\t\\t\\tint[] array = new int[n];\\n\\t\\t\\tfor (int i = 0; i < n; i++)\\n\\t\\t\\t\\tarray[i] =...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Dr. Bruce Banner hates his enemies (like others don't). As we all know, he can barely talk when he turns into the incredible Hulk. That's why he asked you to help him to express his feelings.\\n\\nHulk likes the Inception so much, and like that his feelings are complicated. They have n layers. The first layer is hate, second one is love, third one is hate and so on...\\n\\nFor example if n = 1, then his feeling is \\\"I hate it\\\" or if n = 2 it's \\\"I hate that I love it\\\", and if n = 3 it's \\\"I hate that I love that I hate it\\\" and so on.\\n\\nPlease help Dr. Banner.\\n\\nInput\\n\\nThe only line of the input contains a single integer n (1 ≤ n ≤ 100) — the number of layers of love and hate.\\n\\nOutput\\n\\nPrint Dr.Banner's feeling in one line.\\n\\nExamples\\n\\nInput\\n\\n1\\n\\n\\nOutput\\n\\nI hate it\\n\\n\\nInput\\n\\n2\\n\\n\\nOutput\\n\\nI hate that I love it\\n\\n\\nInput\\n\\n3\\n\\n\\nOutput\\n\\nI hate that I love that I hate it\\nSolve the task in CPP.\",\"targets\":\"#include \\nint main(void) {\\n int num;\\n std::cin >> num;\\n for (int i = 0; i < num; i++) {\\n std::cout << \\\"I \\\";\\n if (i % 2 == 0) {\\n std::cout << \\\"hate \\\";\\n }\\n if (i % 2 == 1) {\\n std::cout << \\\"love \\\";\\n }\\n if (i != num - 1) {\\n std::cout << \\\"that \\\";\\n }\\n }\\n std::cout << \\\"it\\\\n\\\";\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given an integer n. In 1 move, you can do one of the following actions:\\n\\n * erase any digit of the number (it's acceptable that the number before the operation has exactly one digit and after the operation, it is \\\"empty\\\"); \\n * add one digit to the right. \\n\\n\\n\\nThe actions may be performed in any order any number of times.\\n\\nNote that if, after deleting some digit from a number, it will contain leading zeroes, they will not be deleted. E.g. if you delete from the number 301 the digit 3, the result is the number 01 (not 1).\\n\\nYou need to perform the minimum number of actions to make the number any power of 2 (i.e. there's an integer k (k ≥ 0) such that the resulting number is equal to 2^k). The resulting number must not have leading zeroes.\\n\\nE.g. consider n=1052. The answer is equal to 2. First, let's add to the right one digit 4 (the result will be 10524). Then let's erase the digit 5, so the result will be 1024 which is a power of 2.\\n\\nE.g. consider n=8888. The answer is equal to 3. Let's erase any of the digits 8 three times. The result will be 8 which is a power of 2.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10^4) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one line containing one integer n (1 ≤ n ≤ 10^9).\\n\\nOutput\\n\\nFor each test case, output in a separate line one integer m — the minimum number of moves to transform the number into any power of 2.\\n\\nExample\\n\\nInput\\n\\n\\n12\\n1052\\n8888\\n6\\n75\\n128\\n1\\n301\\n12048\\n1504\\n6656\\n1000000000\\n687194767\\n\\n\\nOutput\\n\\n\\n2\\n3\\n1\\n3\\n0\\n0\\n2\\n1\\n3\\n4\\n9\\n2\\n\\nNote\\n\\nThe answer for the first test case was considered above.\\n\\nThe answer for the second test case was considered above.\\n\\nIn the third test case, it's enough to add to the right the digit 4 — the number 6 will turn into 64.\\n\\nIn the fourth test case, let's add to the right the digit 8 and then erase 7 and 5 — the taken number will turn into 8.\\n\\nThe numbers of the fifth and the sixth test cases are already powers of two so there's no need to make any move.\\n\\nIn the seventh test case, you can...\\nUsing python3 can you solve the prior task?\",\"targets\":\"# for i in range(int(input())):\\n# n = int(input())\\n# c1 = n\\/\\/3\\n# c2 = c1\\n# if n % 3 == 1:\\n# c1 += 1\\n# elif n % 3 == 2:\\n# c2 += 1\\n# print(c1, c2)\\n\\n# t = int(input())\\n# for x in range(t):\\n# arr = list(input())\\n# cnt = [0] * 26\\n# for i in arr:\\n# cnt[ord(i) - 97] += 1\\n# cnt1 = cnt2 = 0\\n# for i in cnt:\\n# if i > 1:\\n# cnt2 += 1\\n# elif i == 1:\\n# cnt1 += 1\\n# print(cnt2 + cnt1\\/\\/2)\\n\\n# def solve():\\n# n, k = map(int, input().split())\\n# cnt = [0] * (n+1)\\n# a = []\\n# for i, x in enumerate(map(int, input().split())):\\n# if cnt[x] < k:\\n# a.append((x, i))\\n# cnt[x] += 1\\n# a.sort()\\n# cc = 0\\n\\n# color = [0] * n\\n# m = len(a) - len(a) % k\\n# for x, i in a[:m]:\\n# color[i] = cc + 1\\n# cc = (cc + 1) % k\\n# print(*color)\\n\\n# t = int(input())\\n# for _ in range(t): solve() \\n\\n# def solve():\\n# n, k = map(int, input().split())\\n# cnt = [0] * (n + 1)\\n# arr = []\\n# for i, x in enumerate(map(int, input().split())):\\n# if cnt[x] < k:\\n# arr.append((x, i))\\n# cnt[x] += 1\\n# arr.sort()\\n# # print(arr)\\n# color = [0] * n\\n# cc = 0\\n# m = len(arr) - len(arr) % k\\n# for x, i in arr[:m]:\\n# color[i] = cc + 1\\n# cc = (cc + 1)%k\\n# print(*color)\\n\\n# t = int(input())\\n# for _ in range(t): solve()\\n\\n# N = 3\\n# X = 2\\n# A = [2, 3, 4]\\n# def solve(A, N, X):\\n# arr = []\\n# for i in range(len(A)):\\n# if A[i] & 1: arr.append(i)\\n# ans = 0\\n# m = len(arr)\\n# for i in range(1, m - 1):\\n# ans1 = ans2 = -1\\n# low, high = 0, i - 1\\n# b =arr[i] - X\\n# while low <= high:\\n# mid = low + high >> 1\\n# if arr[mid] <= b:\\n# ans1 = mid\\n# low = mid + 1\\n# else:\\n# high = mid - 1\\n# low = i + 1\\n# r = m - 1\\n# b = arr[i] + X\\n# while l <= r:\\n# mid = l + r...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Berland Football Cup starts really soon! Commentators from all over the world come to the event.\\n\\nOrganizers have already built n commentary boxes. m regional delegations will come to the Cup. Every delegation should get the same number of the commentary boxes. If any box is left unoccupied then the delegations will be upset. So each box should be occupied by exactly one delegation.\\n\\nIf n is not divisible by m, it is impossible to distribute the boxes to the delegations at the moment.\\n\\nOrganizers can build a new commentary box paying a burles and demolish a commentary box paying b burles. They can both build and demolish boxes arbitrary number of times (each time paying a corresponding fee). It is allowed to demolish all the existing boxes.\\n\\nWhat is the minimal amount of burles organizers should pay to satisfy all the delegations (i.e. to make the number of the boxes be divisible by m)?\\n\\nInput\\n\\nThe only line contains four integer numbers n, m, a and b (1 ≤ n, m ≤ 10^{12}, 1 ≤ a, b ≤ 100), where n is the initial number of the commentary boxes, m is the number of delegations to come, a is the fee to build a box and b is the fee to demolish a box.\\n\\nOutput\\n\\nOutput the minimal amount of burles organizers should pay to satisfy all the delegations (i.e. to make the number of the boxes be divisible by m). It is allowed that the final number of the boxes is equal to 0.\\n\\nExamples\\n\\nInput\\n\\n9 7 3 8\\n\\n\\nOutput\\n\\n15\\n\\n\\nInput\\n\\n2 7 3 7\\n\\n\\nOutput\\n\\n14\\n\\n\\nInput\\n\\n30 6 17 19\\n\\n\\nOutput\\n\\n0\\n\\nNote\\n\\nIn the first example organizers can build 5 boxes to make the total of 14 paying 3 burles for the each of them.\\n\\nIn the second example organizers can demolish 2 boxes to make the total of 0 paying 7 burles for the each of them.\\n\\nIn the third example organizers are already able to distribute all the boxes equally among the delegations, each one get 5 boxes.\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n long long n, m, a, b, k;\\n cin >> n >> m >> a >> b;\\n k = n % m;\\n long long ans = min(b * k, (m - k) * a);\\n cout << ans << endl;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Paprika loves permutations. She has an array a_1, a_2, ..., a_n. She wants to make the array a permutation of integers 1 to n.\\n\\nIn order to achieve this goal, she can perform operations on the array. In each operation she can choose two integers i (1 ≤ i ≤ n) and x (x > 0), then perform a_i := a_i mod x (that is, replace a_i by the remainder of a_i divided by x). In different operations, the chosen i and x can be different.\\n\\nDetermine the minimum number of operations needed to make the array a permutation of integers 1 to n. If it is impossible, output -1.\\n\\nA permutation is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice in the array) and [1,3,4] is also not a permutation (n=3 but there is 4 in the array).\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. Description of the test cases follows.\\n\\nThe first line of each test case contains an integer n (1 ≤ n ≤ 10^5).\\n\\nThe second line of each test case contains n integers a_1, a_2, ..., a_n. (1 ≤ a_i ≤ 10^9).\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, output the minimum number of operations needed to make the array a permutation of integers 1 to n, or -1 if it is impossible.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n2\\n1 7\\n3\\n1 5 4\\n4\\n12345678 87654321 20211218 23571113\\n9\\n1 2 3 4 18 19 5 6 7\\n\\n\\nOutput\\n\\n\\n1\\n-1\\n4\\n2\\n\\nNote\\n\\nFor the first test, the only possible sequence of operations which minimizes the number of operations is: \\n\\n * Choose i=2, x=5. Perform a_2 := a_2 mod 5 = 2. \\n\\n\\n\\nFor the second test, it is impossible to obtain a permutation of integers from 1 to n.\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nvoid usefile() {}\\nint main() {\\n usefile();\\n int cas;\\n cin >> cas;\\n while (cas--) {\\n int n;\\n cin >> n;\\n int arr[n];\\n set st;\\n bool ok = true;\\n for (int i = 0; i < n; i++) {\\n cin >> arr[i];\\n }\\n int count[n + 1], tot = 0;\\n for (int i = 1; i <= n; i++) {\\n count[i] = 0;\\n }\\n int cnt = 0;\\n for (int i = 0; i < n; i++) {\\n if (st.count(arr[i]) == 0 && arr[i] <= n) {\\n count[arr[i]]++;\\n st.insert(arr[i]);\\n cnt++;\\n } else {\\n int mx = (arr[i] - 1) \\/ 2;\\n if (mx >= n) {\\n mx = n;\\n }\\n count[mx]++;\\n }\\n }\\n for (int i = 1; i <= n; i++) {\\n tot += count[i];\\n if (tot > i) {\\n ok = false;\\n }\\n }\\n if (tot == n && ok) {\\n cout << n - cnt << endl;\\n } else {\\n cout << -1 << endl;\\n }\\n st.clear();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"\\n\\nWilliam has an array of n integers a_1, a_2, ..., a_n. In one move he can swap two neighboring items. Two items a_i and a_j are considered neighboring if the condition |i - j| = 1 is satisfied.\\n\\nWilliam wants you to calculate the minimal number of swaps he would need to perform to make it so that the array does not contain two neighboring items with the same parity.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^4). Description of the test cases follows.\\n\\nThe first line of each test case contains an integer n (1 ≤ n ≤ 10^5) which is the total number of items in William's array.\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) which are William's array.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 10^5.\\n\\nOutput\\n\\nFor each test case output the minimal number of operations needed or -1 if it is impossible to get the array to a state when no neighboring numbers have the same parity.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n3\\n6 6 1\\n1\\n9\\n6\\n1 1 1 2 2 2\\n2\\n8 6\\n6\\n6 2 3 4 5 1\\n\\n\\nOutput\\n\\n\\n1\\n0\\n3\\n-1\\n2\\n\\nNote\\n\\nIn the first test case the following sequence of operations would satisfy the requirements: \\n\\n 1. swap(2, 3). Array after performing the operation: [6, 1, 6] \\n\\n\\n\\nIn the second test case the array initially does not contain two neighboring items of the same parity.\\n\\nIn the third test case the following sequence of operations would satisfy the requirements: \\n\\n 1. swap(3, 4). Array after performing the operation: [1, 1, 2, 1, 2, 2] \\n 2. swap(2, 3). Array after performing the operation: [1, 2, 1, 1, 2, 2] \\n 3. swap(4, 5). Array after performing the operation: [1, 2, 1, 2, 1, 2] \\n\\n\\n\\nIn the fourth test case it is impossible to satisfy the requirements.\\n\\nIn the fifth test case the following sequence of operations would satisfy the requirements: \\n\\n 1. swap(2, 3). Array after performing the operation: [6, 3, 2, 4, 5, 1] \\n 2. swap(4, 5). Array after performing the operation: [6, 3, 2, 5, 4, 1] \\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.util.*;\\nimport java.lang.*;\\nimport java.io.*;\\npublic class Main\\n{\\n static void sort(int a[]){\\n ArrayList arr=new ArrayList<>();\\n for(int i=0;i=0){\\n\\t int n=sc.nextInt();\\n\\t int a[]=new int[n];\\n\\t int ev=0,od=0;\\n\\t ArrayList even=new ArrayList<>();\\n\\t ArrayList odd=new ArrayList<>();\\n\\t for(int i=0;i=even.size()){\\n\\t z=1; break;\\n\\t }\\n\\t cnt=cnt+Math.max(even.get(i)-l,0);\\n\\t i++;\\n\\t l++;\\n\\t }\\n\\t else{\\n\\t if(j>=odd.size()){z=1; break;}\\n\\t cnt=cnt+Math.max(odd.get(j)-l,0);\\n\\t j++;\\n\\t l++;\\n\\t }\\n\\t }\\n\\t else{\\n\\t if(l%2!=0){\\n\\t if(i>=even.size()){\\n\\t ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: \\n\\n * Tetrahedron. Tetrahedron has 4 triangular faces. \\n * Cube. Cube has 6 square faces. \\n * Octahedron. Octahedron has 8 triangular faces. \\n * Dodecahedron. Dodecahedron has 12 pentagonal faces. \\n * Icosahedron. Icosahedron has 20 triangular faces. \\n\\n\\n\\nAll five kinds of polyhedrons are shown on the picture below:\\n\\n\\n\\nAnton has a collection of n polyhedrons. One day he decided to know, how many faces his polyhedrons have in total. Help Anton and find this number!\\n\\nInput\\n\\nThe first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of polyhedrons in Anton's collection.\\n\\nEach of the following n lines of the input contains a string si — the name of the i-th polyhedron in Anton's collection. The string can look like this:\\n\\n * \\\"Tetrahedron\\\" (without quotes), if the i-th polyhedron in Anton's collection is a tetrahedron. \\n * \\\"Cube\\\" (without quotes), if the i-th polyhedron in Anton's collection is a cube. \\n * \\\"Octahedron\\\" (without quotes), if the i-th polyhedron in Anton's collection is an octahedron. \\n * \\\"Dodecahedron\\\" (without quotes), if the i-th polyhedron in Anton's collection is a dodecahedron. \\n * \\\"Icosahedron\\\" (without quotes), if the i-th polyhedron in Anton's collection is an icosahedron. \\n\\nOutput\\n\\nOutput one number — the total number of faces in all the polyhedrons in Anton's collection.\\n\\nExamples\\n\\nInput\\n\\n4\\nIcosahedron\\nCube\\nTetrahedron\\nDodecahedron\\n\\n\\nOutput\\n\\n42\\n\\n\\nInput\\n\\n3\\nDodecahedron\\nOctahedron\\nOctahedron\\n\\n\\nOutput\\n\\n28\\n\\nNote\\n\\nIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.\",\"targets\":\"a=int(input())\\nsum=0\\nfor i in range(a):\\n s=input()\\n if s=='Icosahedron':\\n sum+=20\\n\\n if s=='Dodecahedron':\\n sum+=12\\n\\n if s == 'Octahedron':\\n sum += 8\\n\\n\\n if s=='Cube':\\n sum+=6\\n\\n if s=='Tetrahedron':\\n sum+=4\\n\\nprint(sum)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"\\n\\nWilliam has an array of n integers a_1, a_2, ..., a_n. In one move he can swap two neighboring items. Two items a_i and a_j are considered neighboring if the condition |i - j| = 1 is satisfied.\\n\\nWilliam wants you to calculate the minimal number of swaps he would need to perform to make it so that the array does not contain two neighboring items with the same parity.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^4). Description of the test cases follows.\\n\\nThe first line of each test case contains an integer n (1 ≤ n ≤ 10^5) which is the total number of items in William's array.\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) which are William's array.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 10^5.\\n\\nOutput\\n\\nFor each test case output the minimal number of operations needed or -1 if it is impossible to get the array to a state when no neighboring numbers have the same parity.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n3\\n6 6 1\\n1\\n9\\n6\\n1 1 1 2 2 2\\n2\\n8 6\\n6\\n6 2 3 4 5 1\\n\\n\\nOutput\\n\\n\\n1\\n0\\n3\\n-1\\n2\\n\\nNote\\n\\nIn the first test case the following sequence of operations would satisfy the requirements: \\n\\n 1. swap(2, 3). Array after performing the operation: [6, 1, 6] \\n\\n\\n\\nIn the second test case the array initially does not contain two neighboring items of the same parity.\\n\\nIn the third test case the following sequence of operations would satisfy the requirements: \\n\\n 1. swap(3, 4). Array after performing the operation: [1, 1, 2, 1, 2, 2] \\n 2. swap(2, 3). Array after performing the operation: [1, 2, 1, 1, 2, 2] \\n 3. swap(4, 5). Array after performing the operation: [1, 2, 1, 2, 1, 2] \\n\\n\\n\\nIn the fourth test case it is impossible to satisfy the requirements.\\n\\nIn the fifth test case the following sequence of operations would satisfy the requirements: \\n\\n 1. swap(2, 3). Array after performing the operation: [6, 3, 2, 4, 5, 1] \\n 2. swap(4, 5). Array after performing the operation: [6, 3, 2, 5, 4, 1] \\nUsing java can you solve the prior task?\",\"targets\":\"import java.util.ArrayList;\\nimport java.util.Collections;\\nimport java.util.HashMap;\\nimport java.util.PriorityQueue;\\nimport java.util.StringTokenizer;\\nimport java.io.*;\\n \\npublic class TakeYourPlaces {\\n\\t\\n\\tprivate static class MyScanner {\\n\\t BufferedReader br;\\n\\t StringTokenizer st;\\n\\n\\t public MyScanner() {\\n\\t br = new BufferedReader(new InputStreamReader(System.in));\\n\\t }\\n\\n\\t String next() {\\n\\t while (st == null || !st.hasMoreElements()) {\\n\\t try {\\n\\t st = new StringTokenizer(br.readLine());\\n\\t } catch (IOException e) {\\n\\t e.printStackTrace();\\n\\t }\\n\\t }\\n\\t return st.nextToken();\\n\\t }\\n\\n\\t int nextInt() {\\n\\t return Integer.parseInt(next());\\n\\t }\\n\\n\\t long nextLong() {\\n\\t return Long.parseLong(next());\\n\\t }\\n\\n\\t double nextDouble() {\\n\\t return Double.parseDouble(next());\\n\\t }\\n\\n\\t String nextLine(){\\n\\t String str = \\\"\\\";\\n\\t\\t try {\\n\\t\\t str = br.readLine();\\n\\t\\t } catch (IOException e) {\\n\\t\\t e.printStackTrace();\\n\\t\\t }\\n\\t\\t return str;\\n\\t }\\n\\n\\t }\\n\\t\\n\\n\\t\\n\\tpublic static int solution(int[] arr, int n)\\n\\t\\t\\t\\n\\t{\\n\\t\\tint count = 0;\\n\\t\\tint e = 0;\\n\\t\\tint o = 0;\\n\\t\\t\\n\\t\\tfor(int i = 0; i z1 = new ArrayList<>();\\n\\t\\t\\tArrayList o1 = new ArrayList<>();\\n\\t\\t\\t\\n\\t\\t\\tfor(int i = 0; i z2 = new ArrayList<>();\\n\\t\\t\\tArrayList o2 = new ArrayList<>();\\n\\t\\t\\t\\n\\t\\t\\tfor(int i = 0; i\\nusing namespace std;\\nint main() {\\n char s[101];\\n int n = 0, I = 0, t = 0, e = 0, p, q, r;\\n cin >> s;\\n int len = strlen(s);\\n for (int i = 0; i < len; i++) {\\n if (s[i] == 'n')\\n n++;\\n else if (s[i] == 'i')\\n I++;\\n else if (s[i] == 't')\\n t++;\\n else if (s[i] == 'e')\\n e++;\\n }\\n p = min((n - 1) \\/ 2, e \\/ 3);\\n q = min(I, t);\\n r = min(p, q);\\n cout << r << endl;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON solution for \\\"You are given a sequence of n integers a_1, a_2, ..., a_n.\\n\\nDoes there exist a sequence of n integers b_1, b_2, ..., b_n such that the following property holds?\\n\\n * For each 1 ≤ i ≤ n, there exist two (not necessarily distinct) indices j and k (1 ≤ j, k ≤ n) such that a_i = b_j - b_k. \\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 20) — the number of test cases. Then t test cases follow.\\n\\nThe first line of each test case contains one integer n (1 ≤ n ≤ 10).\\n\\nThe second line of each test case contains the n integers a_1, ..., a_n (-10^5 ≤ a_i ≤ 10^5).\\n\\nOutput\\n\\nFor each test case, output a line containing YES if a sequence b_1, ..., b_n satisfying the required property exists, and NO otherwise.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n5\\n4 -7 -1 5 10\\n1\\n0\\n3\\n1 10 100\\n4\\n-3 2 10 2\\n9\\n25 -171 250 174 152 242 100 -205 -258\\n\\n\\nOutput\\n\\n\\nYES\\nYES\\nNO\\nYES\\nYES\\n\\nNote\\n\\nIn the first test case, the sequence b = [-9, 2, 1, 3, -2] satisfies the property. Indeed, the following holds: \\n\\n * a_1 = 4 = 2 - (-2) = b_2 - b_5; \\n * a_2 = -7 = -9 - (-2) = b_1 - b_5; \\n * a_3 = -1 = 1 - 2 = b_3 - b_2; \\n * a_4 = 5 = 3 - (-2) = b_4 - b_5; \\n * a_5 = 10 = 1 - (-9) = b_3 - b_1. \\n\\n\\n\\nIn the second test case, it is sufficient to choose b = [0], since a_1 = 0 = 0 - 0 = b_1 - b_1.\\n\\nIn the third test case, it is possible to show that no sequence b of length 3 satisfies the property.\\\":\",\"targets\":\"def solve(ab=abs):\\n n = int(raw_input())\\n a = map(int, raw_input().split())\\n if n == 1:\\n print \\\"YES\\\" if a[0] == 0 else \\\"NO\\\"\\n return\\n a = map(ab, a)\\n if len(set(a)) < n:\\n print \\\"YES\\\"\\n return\\n s = set([a[0]])\\n for x in a[1:]:\\n s |= set(ab(y + x * m) for y in s for m in (1, -1))\\n s.add(x)\\n if 0 in s:\\n print \\\"YES\\\"\\n return\\n print \\\"NO\\\"\\n\\nT = int(raw_input())\\nfor t in xrange(T):\\n solve()\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Consider a simplified penalty phase at the end of a football match.\\n\\nA penalty phase consists of at most 10 kicks, the first team takes the first kick, the second team takes the second kick, then the first team takes the third kick, and so on. The team that scores more goals wins; if both teams score the same number of goals, the game results in a tie (note that it goes against the usual football rules). The penalty phase is stopped if one team has scored more goals than the other team could reach with all of its remaining kicks. For example, if after the 7-th kick the first team has scored 1 goal, and the second team has scored 3 goals, the penalty phase ends — the first team cannot reach 3 goals.\\n\\nYou know which player will be taking each kick, so you have your predictions for each of the 10 kicks. These predictions are represented by a string s consisting of 10 characters. Each character can either be 1, 0, or ?. This string represents your predictions in the following way:\\n\\n * if s_i is 1, then the i-th kick will definitely score a goal; \\n * if s_i is 0, then the i-th kick definitely won't score a goal; \\n * if s_i is ?, then the i-th kick could go either way. \\n\\n\\n\\nBased on your predictions, you have to calculate the minimum possible number of kicks there can be in the penalty phase (that means, the earliest moment when the penalty phase is stopped, considering all possible ways it could go). Note that the referee doesn't take into account any predictions when deciding to stop the penalty phase — you may know that some kick will\\/won't be scored, but the referee doesn't.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 1 000) — the number of test cases.\\n\\nEach test case is represented by one line containing the string s, consisting of exactly 10 characters. Each character is either 1, 0, or ?.\\n\\nOutput\\n\\nFor each test case, print one integer — the minimum possible number of kicks in the penalty phase.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n1?0???1001\\n1111111111\\n??????????\\n0100000000\\n\\n\\nOutput\\n\\n\\n7\\n10\\n6\\n9\\n\\nNote\\n\\nConsider...\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n int t;\\n cin >> t;\\n while (t--) {\\n string s;\\n cin >> s;\\n int a = 0, b = 0, x = 0, y = 0, c = 0;\\n int n = s.length();\\n for (int i = 0; i < n; i++) {\\n if (i % 2 == 0) {\\n if (s[i] == '1') a++;\\n if (s[i] == '?') b++;\\n }\\n if (i % 2 != 0) {\\n if (s[i] == '1') x++;\\n if (s[i] == '?') y++;\\n }\\n if (((x + y) > ((ceil((9 - i) \\/ 2)) + a)) or\\n ((a + b) > ((ceil((9 - i) \\/ 2.0)) + x))) {\\n cout << i + 1 << \\\"\\\\n\\\";\\n c++;\\n break;\\n }\\n }\\n if (c == 0) cout << n << \\\"\\\\n\\\";\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"There are n block towers in a row, where tower i has a height of a_i. You're part of a building crew, and you want to make the buildings look as nice as possible. In a single day, you can perform the following operation:\\n\\n * Choose two indices i and j (1 ≤ i, j ≤ n; i ≠ j), and move a block from tower i to tower j. This essentially decreases a_i by 1 and increases a_j by 1. \\n\\n\\n\\nYou think the ugliness of the buildings is the height difference between the tallest and shortest buildings. Formally, the ugliness is defined as max(a)-min(a). \\n\\nWhat's the minimum possible ugliness you can achieve, after any number of days?\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 1000) — the number of test cases. Then t cases follow.\\n\\nThe first line of each test case contains one integer n (2 ≤ n ≤ 100) — the number of buildings.\\n\\nThe second line of each test case contains n space separated integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^7) — the heights of the buildings.\\n\\nOutput\\n\\nFor each test case, output a single integer — the minimum possible ugliness of the buildings.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n3\\n10 10 10\\n4\\n3 2 1 2\\n5\\n1 2 3 1 5\\n\\n\\nOutput\\n\\n\\n0\\n0\\n1\\n\\nNote\\n\\nIn the first test case, the ugliness is already 0.\\n\\nIn the second test case, you should do one operation, with i = 1 and j = 3. The new heights will now be [2, 2, 2, 2], with an ugliness of 0.\\n\\nIn the third test case, you may do three operations: \\n\\n 1. with i = 3 and j = 1. The new array will now be [2, 2, 2, 1, 5], \\n 2. with i = 5 and j = 4. The new array will now be [2, 2, 2, 2, 4], \\n 3. with i = 5 and j = 3. The new array will now be [2, 2, 3, 2, 3]. \\n\\nThe resulting ugliness is 1. It can be proven that this is the minimum possible ugliness for this test.\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(nullptr);\\n int T;\\n cin >> T;\\n while (T--) {\\n int N;\\n cin >> N;\\n int tot = 0;\\n vector A(N);\\n for (int &a : A) cin >> a, tot += a;\\n cout << (tot % N ? 1 : 0) << '\\\\n';\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"As a German University in Cairo (GUC) student and a basketball player, Herr Wafa was delighted once he heard the news. GUC is finally participating in the Annual Basketball Competition (ABC). \\n\\nA team is to be formed of n players, all of which are GUC students. However, the team might have players belonging to different departments. There are m departments in GUC, numbered from 1 to m. Herr Wafa's department has number h. For each department i, Herr Wafa knows number si — how many students who play basketball belong to this department.\\n\\nHerr Wafa was also able to guarantee a spot on the team, using his special powers. But since he hates floating-point numbers, he needs your help at finding the probability that he will have at least one teammate belonging to his department. \\n\\nNote that every possible team containing Herr Wafa is equally probable. Consider all the students different from each other.\\n\\nInput\\n\\nThe first line contains three integers n, m and h (1 ≤ n ≤ 100, 1 ≤ m ≤ 1000, 1 ≤ h ≤ m) — the number of players on the team, the number of departments in GUC and Herr Wafa's department, correspondingly. \\n\\nThe second line contains a single-space-separated list of m integers si (1 ≤ si ≤ 100), denoting the number of students in the i-th department. Note that sh includes Herr Wafa.\\n\\nOutput\\n\\nPrint the probability that Herr Wafa will have at least one teammate from his department. If there is not enough basketball players in GUC to participate in ABC, print -1. The answer will be accepted if it has absolute or relative error not exceeding 10 - 6.\\n\\nExamples\\n\\nInput\\n\\n3 2 1\\n2 1\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\n3 2 1\\n1 1\\n\\n\\nOutput\\n\\n-1\\n\\n\\nInput\\n\\n3 2 1\\n2 2\\n\\n\\nOutput\\n\\n0.666667\\n\\nNote\\n\\nIn the first example all 3 players (2 from department 1 and 1 from department 2) must be chosen for the team. Both players from Wafa's departments will be chosen, so he's guaranteed to have a teammate from his department.\\n\\nIn the second example, there are not enough players.\\n\\nIn the third example, there are three possibilities to compose the team...\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint n, m, h;\\nint sum, s;\\nint main() {\\n while (cin >> n >> m >> h) {\\n sum = 0;\\n for (int i = 1, j; i <= m; i++) {\\n cin >> j;\\n sum += j;\\n if (i == h) s = j;\\n }\\n if (sum < n) {\\n cout << \\\"-1.0\\\" << endl;\\n continue;\\n }\\n if (s == 1) {\\n cout << \\\"0.00\\\" << endl;\\n continue;\\n }\\n sum -= s;\\n if (sum < n - 1 || sum + s == n) {\\n cout << \\\"1.0\\\" << endl;\\n continue;\\n }\\n double pp = 1.000000000000000;\\n double a = (double)sum;\\n double b = (double)sum + s - 1;\\n for (int i = 1; i < n; i++) {\\n pp *= a \\/ b;\\n a -= 1;\\n b -= 1;\\n }\\n printf(\\\"%.10lf\\\\n\\\", 1.00000 - pp);\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Recently, Petya learned about a new game \\\"Slay the Dragon\\\". As the name suggests, the player will have to fight with dragons. To defeat a dragon, you have to kill it and defend your castle. To do this, the player has a squad of n heroes, the strength of the i-th hero is equal to a_i.\\n\\nAccording to the rules of the game, exactly one hero should go kill the dragon, all the others will defend the castle. If the dragon's defense is equal to x, then you have to send a hero with a strength of at least x to kill it. If the dragon's attack power is y, then the total strength of the heroes defending the castle should be at least y.\\n\\nThe player can increase the strength of any hero by 1 for one gold coin. This operation can be done any number of times.\\n\\nThere are m dragons in the game, the i-th of them has defense equal to x_i and attack power equal to y_i. Petya was wondering what is the minimum number of coins he needs to spend to defeat the i-th dragon.\\n\\nNote that the task is solved independently for each dragon (improvements are not saved).\\n\\nInput\\n\\nThe first line contains a single integer n (2 ≤ n ≤ 2 ⋅ 10^5) — number of heroes.\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^{12}), where a_i is the strength of the i-th hero.\\n\\nThe third line contains a single integer m (1 ≤ m ≤ 2 ⋅ 10^5) — the number of dragons.\\n\\nThe next m lines contain two integers each, x_i and y_i (1 ≤ x_i ≤ 10^{12}; 1 ≤ y_i ≤ 10^{18}) — defense and attack power of the i-th dragon.\\n\\nOutput\\n\\nPrint m lines, i-th of which contains a single integer — the minimum number of coins that should be spent to defeat the i-th dragon.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3 6 2 3\\n5\\n3 12\\n7 9\\n4 14\\n1 10\\n8 7\\n\\n\\nOutput\\n\\n\\n1\\n2\\n4\\n0\\n2\\n\\nNote\\n\\nTo defeat the first dragon, you can increase the strength of the third hero by 1, then the strength of the heroes will be equal to [3, 6, 3, 3]. To kill the dragon, you can choose the first hero.\\n\\nTo defeat the second dragon, you can increase the forces of the second and third heroes by 1, then the strength of the heroes will...\",\"targets\":\"import traceback\\nimport os\\nimport sys\\nfrom io import BytesIO, IOBase\\n\\nBUFSIZE = 8192\\n\\nclass FastIO(IOBase):\\n newlines = 0\\n\\n def __init__(self, file):\\n self._fd = file.fileno()\\n self.buffer = BytesIO()\\n self.writable = \\\"x\\\" in file.mode or \\\"r\\\" not in file.mode\\n self.write = self.buffer.write if self.writable else None\\n\\n def read(self):\\n while True:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n if not b:\\n break\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines = 0\\n return self.buffer.read()\\n\\n def readline(self):\\n while self.newlines == 0:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n self.newlines = b.count(b\\\"\\\\n\\\") + (not b)\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines -= 1\\n return self.buffer.readline()\\n\\n def flush(self):\\n if self.writable:\\n os.write(self._fd, self.buffer.getvalue())\\n self.buffer.truncate(0), self.buffer.seek(0)\\n\\n\\nclass IOWrapper(IOBase):\\n def __init__(self, file):\\n self.buffer = FastIO(file)\\n self.flush = self.buffer.flush\\n self.writable = self.buffer.writable\\n self.write = lambda s: self.buffer.write(s.encode(\\\"ascii\\\"))\\n self.read = lambda: self.buffer.read().decode(\\\"ascii\\\")\\n self.readline = lambda: self.buffer.readline().decode(\\\"ascii\\\")\\n\\nsys.stdin = IOWrapper(sys.stdin)\\n# sys.stdout = IOWrapper(sys.stdout)\\ninput = lambda: sys.stdin.readline().rstrip(\\\"\\\\r\\\\n\\\")\\n\\n#####################################################################\\n\\nimport math\\nfrom collections import defaultdict as dfd, defaultdict, Counter, deque\\nfrom functools import lru_cache\\nfrom itertools import accumulate\\nfrom heapq import *\\nfrom bisect import *\\n# from sortedcontainers import SortedList\\n\\ndef geti():\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alice has an empty grid with n rows and m columns. Some of the cells are marked, and no marked cells are adjacent to the edge of the grid. (Two squares are adjacent if they share a side.) \\n\\nAlice wants to fill each cell with a number such that the following statements are true: \\n\\n * every unmarked cell contains either the number 1 or 4; \\n * every marked cell contains the sum of the numbers in all unmarked cells adjacent to it (if a marked cell is not adjacent to any unmarked cell, this sum is 0); \\n * every marked cell contains a multiple of 5. \\n\\nAlice couldn't figure it out, so she asks Bob to help her. Help Bob find any such grid, or state that no such grid exists.\\n\\nInput\\n\\nThe first line of input contains two integers n and m (1 ≤ n, m ≤ 500) — the number of rows and the number of columns in the grid, respectively.\\n\\nThen n lines follow, each containing m characters. Each of these characters is either '.' or 'X' — an unmarked and a marked cell, respectively. No marked cells are adjacent to the edge of the grid.\\n\\nOutput\\n\\nOutput \\\"'NO\\\" if no suitable grid exists. Otherwise, output \\\"'YES\\\"'. Then output n lines of m space-separated integers — the integers in the grid.\\n\\nExamples\\n\\nInput\\n\\n\\n5 5\\n.....\\n.XXX.\\n.X.X.\\n.XXX.\\n.....\\n\\n\\nOutput\\n\\n\\nYES\\n4 1 4 4 1\\n4 5 5 5 1\\n4 5 1 5 4\\n1 5 5 5 4\\n1 4 4 1 4\\n\\n\\nInput\\n\\n\\n5 5\\n.....\\n.XXX.\\n.XXX.\\n.XXX.\\n.....\\n\\n\\nOutput\\n\\n\\nNO\\n\\n\\nInput\\n\\n\\n3 2\\n..\\n..\\n..\\n\\n\\nOutput\\n\\n\\nYES\\n4 1\\n4 1\\n1 4\\n\\n\\nInput\\n\\n\\n9 9\\n.........\\n.XXXXX.X.\\n.X...X...\\n.X.XXXXX.\\n.X.X.X.X.\\n.X.XXX.X.\\n.X.....X.\\n.XXXXXXX.\\n.........\\n\\n\\nOutput\\n\\n\\nYES\\n4 4 4 1 4 1 4 1 4\\n1 5 5 5 5 5 4 10 1\\n4 5 1 4 1 5 4 4 4\\n4 5 1 5 5 0 5 5 1\\n4 5 1 5 4 5 1 5 4\\n4 5 1 5 5 5 4 5 1\\n1 5 4 4 1 1 4 5 1\\n4 5 5 5 5 5 5 5 4\\n1 1 1 1 4 4 1 1 4\\n\\nNote\\n\\nIt can be shown that no such grid exists for the second test.\",\"targets\":\"#include \\nusing namespace std;\\nusing ll = long long;\\nusing ull = long unsigned long;\\nusing ld = double long;\\nconst int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1};\\nconst int dy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};\\nint n, m;\\nstring s[505];\\nint dist[505][505], sol[505][505];\\nint main() {\\n ios::sync_with_stdio(!cin.tie(0));\\n cin >> n >> m;\\n for (int i = 0; i < n; i++) cin >> s[i];\\n for (int i = 1; i < n - 1; i++) {\\n for (int j = 1; j < m - 1; j++) {\\n if (s[i][j] == 'X') {\\n int c = 0;\\n c += s[i - 1][j] == '.';\\n c += s[i + 1][j] == '.';\\n c += s[i][j - 1] == '.';\\n c += s[i][j + 1] == '.';\\n if (c % 2 == 1) {\\n cout << \\\"NO\\\\n\\\";\\n return 0;\\n }\\n }\\n }\\n }\\n memset(dist, 255, sizeof(dist));\\n deque> q;\\n dist[0][0] = 0;\\n q.push_back({0, 0});\\n while (q.size()) {\\n auto [x, y] = q.front();\\n q.pop_front();\\n for (int d = 0; d < 8; d++) {\\n int u = x + dx[d];\\n int v = y + dy[d];\\n if (u < 0 || v < 0 || u >= n || v >= m) continue;\\n if (abs(dx[d]) + abs(dy[d]) == 2 && (s[u][v] == 'X' || s[x][y] == 'X')) {\\n continue;\\n }\\n if (dist[u][v] == -1) {\\n if (s[u][v] == 'X') {\\n dist[u][v] = dist[x][y] + 1;\\n q.push_back({u, v});\\n } else {\\n dist[u][v] = dist[x][y];\\n q.push_front({u, v});\\n }\\n }\\n }\\n }\\n for (int i = 0; i < n; i++) {\\n for (int j = 0; j < m; j++) {\\n if (s[i][j] == '.') {\\n sol[i][j] = ((i + dist[i][j]) % 2) * 3 + 1;\\n }\\n }\\n }\\n for (int i = 0; i < n; i++) {\\n for (int j = 0; j < m; j++) {\\n if (s[i][j] == 'X') {\\n int c = 0;\\n c += sol[i - 1][j] * (s[i - 1][j] == '.');\\n c += sol[i + 1][j] * (s[i + 1][j] == '.');\\n c += sol[i][j - 1] * (s[i][j - 1] == '.');\\n c += sol[i][j + 1] * (s[i][j + 1] == '.');\\n sol[i][j] = c;\\n }\\n }\\n }\\n cout << \\\"YES\\\\n\\\";\\n for (int i = 0; i < n; i++) {\\n for (int j = 0; j < m; j++) {\\n cout << sol[i][j] << \\\" \\\\n\\\"[j...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"The new generation external memory contains an array of integers a[1 … n] = [a_1, a_2, …, a_n].\\n\\nThis type of memory does not support changing the value of an arbitrary element. Instead, it allows you to cut out any segment of the given array, cyclically shift (rotate) it by any offset and insert it back into the same place.\\n\\nTechnically, each cyclic shift consists of two consecutive actions: \\n\\n 1. You may select arbitrary indices l and r (1 ≤ l < r ≤ n) as the boundaries of the segment. \\n 2. Then you replace the segment a[l … r] with it's cyclic shift to the left by an arbitrary offset d. The concept of a cyclic shift can be also explained by following relations: the sequence [1, 4, 1, 3] is a cyclic shift of the sequence [3, 1, 4, 1] to the left by the offset 1 and the sequence [4, 1, 3, 1] is a cyclic shift of the sequence [3, 1, 4, 1] to the left by the offset 2. \\n\\n\\n\\nFor example, if a = [1, \\\\color{blue}{3, 2, 8}, 5], then choosing l = 2, r = 4 and d = 2 yields a segment a[2 … 4] = [3, 2, 8]. This segment is then shifted by the offset d = 2 to the left, and you get a segment [8, 3, 2] which then takes the place of of the original elements of the segment. In the end you get a = [1, \\\\color{blue}{8, 3, 2}, 5].\\n\\nSort the given array a using no more than n cyclic shifts of any of its segments. Note that you don't need to minimize the number of cyclic shifts. Any method that requires n or less cyclic shifts will be accepted.\\n\\nInput\\n\\nThe first line contains an integer t (1 ≤ t ≤ 1000) — the number of test cases.\\n\\nThe next 2t lines contain the descriptions of the test cases. \\n\\nThe first line of each test case description contains an integer n (2 ≤ n ≤ 50) — the length of the array. The second line consists of space-separated elements of the array a_i (-10^9 ≤ a_i ≤ 10^9). Elements of array a may repeat and don't have to be unique.\\n\\nOutput\\n\\nPrint t answers to all input test cases. \\n\\nThe first line of the answer of each test case should contain an integer k (0 ≤ k ≤ n) — the number of actions to sort the array....\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"t = int(input())\\nans_mas = []\\nfor i in range(t):\\n help_mas = []\\n n = int(input())\\n b = input().split()\\n a = list(map(int,b))\\n l = 0\\n h = n-1 \\n \\n while True:\\n if h == 0:\\n break\\n max_a = max(a[0:h+1])\\n max_a_index = a[0:h + 1].index(max_a)\\n if max_a_index == h:\\n h -= 1\\n else: \\n y = a[h]\\n a[h] = a[max_a_index]\\n for j in reversed(range(max_a_index,h)):\\n a[j], y = y, a[j]\\n \\n help_mas.append(str(str(max_a_index + 1) + ' ' + str(h + 1) + ' ' + '1'))\\n l += 1\\n h -= 1 \\n ans_mas.append(l)\\n if len(help_mas) != 0:\\n for j in range(len(help_mas)):\\n ans_mas.append(help_mas[j])\\n \\nprint(*ans_mas, sep = '\\\\n')\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CQXYM is counting permutations length of 2n.\\n\\nA permutation is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice in the array) and [1,3,4] is also not a permutation (n=3 but there is 4 in the array).\\n\\nA permutation p(length of 2n) will be counted only if the number of i satisfying p_ip_2. Because 00)\\n {\\n st = new StringTokenizer(infile.readLine());\\n long N = Long.parseLong(st.nextToken());\\n long s = N;\\n for (int i = 2; i < 2 * N; i++) {\\n s = (s * i) % 1000000007;\\n }\\n out.println(s);\\n }\\n\\n \\/\\/BufferedReader infile = new BufferedReader(new FileReader(\\\"input.txt\\\"));\\n \\/\\/System.setOut(new PrintStream(new File(\\\"output.txt\\\")));\\n }\\n\\n public static long factorial(int n) {\\n return LongStream.rangeClosed(1, n).reduce(1, (long x, long y) -> x * y);\\n }\\n\\n public static int[] readArr(int N, BufferedReader infile, StringTokenizer st) throws Exception\\n {\\n int[] arr = new int[N];\\n st = new StringTokenizer(infile.readLine());\\n for(int i=0; i < N; i++)\\n arr[i] = Integer.parseInt(st.nextToken());\\n return arr;\\n }\\n public static void print(int[] arr)\\n {\\n \\/\\/for debugging only\\n for(int x: arr)\\n out.print(x+\\\" \\\");\\n out.println();\\n }\\n\\n public static long[] readArr2(int N, BufferedReader infile, StringTokenizer st) throws Exception\\n {\\n long[] arr = new long[N];\\n st = new StringTokenizer(infile.readLine());\\n for(int i=0; i < N; i++)\\n arr[i] = Long.parseLong(st.nextToken());\\n return arr;\\n }\\n public static boolean isPrime(long n) {\\n if(n < 2) return false;\\n if(n == 2 || n == 3) return true;\\n if(n%2...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Petya has got an interesting flower. Petya is a busy person, so he sometimes forgets to water it. You are given n days from Petya's live and you have to determine what happened with his flower in the end.\\n\\nThe flower grows as follows: \\n\\n * If the flower isn't watered for two days in a row, it dies. \\n * If the flower is watered in the i-th day, it grows by 1 centimeter. \\n * If the flower is watered in the i-th and in the (i-1)-th day (i > 1), then it grows by 5 centimeters instead of 1. \\n * If the flower is not watered in the i-th day, it does not grow. \\n\\n\\n\\nAt the beginning of the 1-st day the flower is 1 centimeter tall. What is its height after n days?\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 100). Description of the test cases follows.\\n\\nThe first line of each test case contains the only integer n (1 ≤ n ≤ 100).\\n\\nThe second line of each test case contains n integers a_1, a_2, ..., a_n (a_i = 0 or a_i = 1). If a_i = 1, the flower is watered in the i-th day, otherwise it is not watered.\\n\\nOutput\\n\\nFor each test case print a single integer k — the flower's height after n days, or -1, if the flower dies.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n1 0 1\\n3\\n0 1 1\\n4\\n1 0 0 1\\n1\\n0\\n\\n\\nOutput\\n\\n\\n3\\n7\\n-1\\n1\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n ios::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n long long int t;\\n cin >> t;\\n while (t-- != 0) {\\n long long int n;\\n cin >> n;\\n long long int a[n];\\n long long int val = 1;\\n for (long long int i = 0; i < n; i++) {\\n cin >> a[i];\\n if (val > 0) {\\n if (a[i] == 0) {\\n if (i > 0) {\\n if (a[i - 1] == 0) {\\n val = -1;\\n } else {\\n }\\n } else {\\n }\\n } else {\\n if (i > 0) {\\n if (a[i - 1] == 1) {\\n val += 5;\\n } else {\\n val++;\\n }\\n } else {\\n val++;\\n }\\n }\\n }\\n }\\n cout << val << endl;\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nn players are playing a game. \\n\\nThere are two different maps in the game. For each player, we know his strength on each map. When two players fight on a specific map, the player with higher strength on that map always wins. No two players have the same strength on the same map. \\n\\nYou are the game master and want to organize a tournament. There will be a total of n-1 battles. While there is more than one player in the tournament, choose any map and any two remaining players to fight on it. The player who loses will be eliminated from the tournament. \\n\\nIn the end, exactly one player will remain, and he is declared the winner of the tournament. For each player determine if he can win the tournament.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. The description of test cases follows.\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 10^5) — the number of players.\\n\\nThe second line of each test case contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9, a_i ≠ a_j for i ≠ j), where a_i is the strength of the i-th player on the first map. \\n\\nThe third line of each test case contains n integers b_1, b_2, ..., b_n (1 ≤ b_i ≤ 10^9, b_i ≠ b_j for i ≠ j), where b_i is the strength of the i-th player on the second map. \\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 10^5.\\n\\nOutput\\n\\nFor each test case print a string of length n. i-th character should be \\\"1\\\" if the i-th player can win the tournament, or \\\"0\\\" otherwise.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n4\\n1 2 3 4\\n1 2 3 4\\n4\\n11 12 20 21\\n44 22 11 30\\n1\\n1000000000\\n1000000000\\n\\n\\nOutput\\n\\n\\n0001\\n1111\\n1\\n\\nNote\\n\\nIn the first test case, the 4-th player will beat any other player on any game, so he will definitely win the tournament.\\n\\nIn the second test case, everyone can be a winner. \\n\\nIn the third test case, there is only one player. Clearly, he will win the tournament.\",\"targets\":\"#include \\nusing namespace std;\\nusing ll = long long;\\nint mod = (ll)1e9 + 7;\\nconst int INF = 1e9 + 1;\\nconst int N = 2e5 + 100;\\nconst double eps = 1e-7;\\ntemplate \\nusing V = vector;\\ntemplate \\nusing VV = V>;\\ntemplate \\nusing AR = array;\\ntemplate \\nusing PR = pair;\\ntemplate \\nbool ckma(XPAX &x, XPAX y) {\\n return (x < y ? x = y, 1 : 0);\\n}\\ntemplate \\nbool ckmi(XPAX &x, XPAX y) {\\n return (x > y ? x = y, 1 : 0);\\n}\\nvoid __print(int x) { cerr << x; }\\nvoid __print(long x) { cerr << x; }\\nvoid __print(long long x) { cerr << x; }\\nvoid __print(unsigned x) { cerr << x; }\\nvoid __print(unsigned long x) { cerr << x; }\\nvoid __print(unsigned long long x) { cerr << x; }\\nvoid __print(float x) { cerr << x; }\\nvoid __print(double x) { cerr << x; }\\nvoid __print(long double x) { cerr << x; }\\nvoid __print(char x) { cerr << '\\\\'' << x << '\\\\''; }\\nvoid __print(const char *x) { cerr << '\\\\\\\"' << x << '\\\\\\\"'; }\\nvoid __print(const string &x) { cerr << '\\\\\\\"' << x << '\\\\\\\"'; }\\nvoid __print(bool x) { cerr << (x ? \\\"true\\\" : \\\"false\\\"); }\\ntemplate \\nvoid __print(const pair &x) {\\n cerr << '{';\\n __print(x.first);\\n cerr << ',';\\n __print(x.second);\\n cerr << '}';\\n}\\ntemplate \\nvoid __print(const T &x) {\\n int f = 0;\\n cerr << '{';\\n for (auto &i : x) cerr << (f++ ? \\\",\\\" : \\\"\\\"), __print(i);\\n cerr << \\\"}\\\";\\n}\\nvoid _print() { cerr << \\\"]\\\\n\\\"; }\\ntemplate \\nvoid _print(T t, V... v) {\\n __print(t);\\n if (sizeof...(v)) cerr << \\\", \\\";\\n _print(v...);\\n}\\nvoid solve() {\\n int n;\\n cin >> n;\\n V A(n), B(n);\\n VV tt(n);\\n V> E;\\n for (int i = 0; i < (n); ++i) {\\n cin >> A[i];\\n }\\n for (int i = 0; i < (n); ++i) cin >> B[i];\\n for (int i = 0; i < (n); ++i) E.push_back({A[i], B[i], i});\\n sort((E).begin(), (E).end(),\\n [&](AR x, AR y) { return x[1] < y[1]; });\\n for (int i = 0; i < (n - 1); ++i) tt[E[i][2]].push_back(E[i + 1][2]);\\n sort((E).begin(), (E).end(),\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You have a string s and a chip, which you can place onto any character of this string. \\n\\nAfter placing the chip, you move it to the right several (maybe zero) times, i. e. you perform the following operation several times: if the current position of the chip is i, you move it to the position i + 1. Of course, moving the chip to the right is impossible if it is already in the last position.\\n\\nAfter moving the chip to the right, you move it to the left several (maybe zero) times, i. e. you perform the following operation several times: if the current position of the chip is i, you move it to the position i - 1. Of course, moving the chip to the left is impossible if it is already in the first position.\\n\\nWhen you place a chip or move it, you write down the character where the chip ends up after your action. For example, if s is abcdef, you place the chip onto the 3-rd character, move it to the right 2 times and then move it to the left 3 times, you write down the string cdedcb.\\n\\nYou are given two strings s and t. Your task is to determine whether it's possible to perform the described operations with s so that you write down the string t as a result.\\n\\nInput\\n\\nThe first line contains one integer q (1 ≤ q ≤ 500) — the number of test cases.\\n\\nEach test case consists of two lines. The first line contains the string s (1 ≤ |s| ≤ 500), the second line contains the string t (1 ≤ |t| ≤ 2 ⋅ |s| - 1). Both strings consist of lowercase English characters.\\n\\nIt is guaranteed that the sum of |s| over all test cases does not exceed 500.\\n\\nOutput\\n\\nFor each test case, print \\\"YES\\\" if you can obtain the string t by performing the process mentioned in the statement with the string s, or \\\"NO\\\" if you cannot.\\n\\nYou may print each letter in any case (YES, yes, Yes will all be recognized as positive answer, NO, no and nO will all be recognized as negative answer).\\n\\nExample\\n\\nInput\\n\\n\\n6\\nabcdef\\ncdedcb\\naaa\\naaaaa\\naab\\nbaaa\\nab\\nb\\nabcdef\\nabcdef\\nba\\nbaa\\n\\n\\nOutput\\n\\n\\nYES\\nYES\\nNO\\nYES\\nYES\\nNO\\n\\nNote\\n\\nConsider the examples.\\n\\nThe first test case is described in...\",\"targets\":\"import typing\\nimport sys\\nsys.setrecursionlimit(1 << 20)\\n\\n\\n\\ndef solve(\\n s: str,\\n t: str,\\n) -> typing.NoReturn:\\n\\n def dfs(\\n i: int,\\n j: int,\\n d: int,\\n ) -> bool:\\n if j == len(t):\\n return True\\n if i < 0 or len(s) <= i:\\n return False\\n if s[i] != t[j]:\\n return False\\n ok = dfs(i - 1, j + 1, 0)\\n if d == 0: return ok\\n ok |= dfs(i + 1, j + 1, 1)\\n return ok\\n \\n \\n for i in range(len(s)):\\n ok = dfs(i, 0, 1)\\n if ok: print('YES'); break\\n else:\\n print('NO')\\n \\n \\n\\ndef main() -> typing.NoReturn:\\n q = int(input())\\n for _ in range(q):\\n s = input()\\n t = input()\\n solve(s, t)\\n\\n\\nmain()\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"The Olympic Games have just started and Federico is eager to watch the marathon race.\\n\\nThere will be n athletes, numbered from 1 to n, competing in the marathon, and all of them have taken part in 5 important marathons, numbered from 1 to 5, in the past. For each 1≤ i≤ n and 1≤ j≤ 5, Federico remembers that athlete i ranked r_{i,j}-th in marathon j (e.g., r_{2,4}=3 means that athlete 2 was third in marathon 4).\\n\\nFederico considers athlete x superior to athlete y if athlete x ranked better than athlete y in at least 3 past marathons, i.e., r_{x,j}\\nusing namespace std;\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n long long t, n, k, m, cnt;\\n string s;\\n cin >> t;\\n while (t--) {\\n cin >> n;\\n long long ans;\\n cnt = 0;\\n vector> v(n);\\n for (int i = 0; i < n; i++) {\\n for (int j = 0; j < 5; j++) {\\n long long x;\\n cin >> x;\\n v[i].push_back(x);\\n }\\n }\\n for (int i = 1; i < n; i++) {\\n ans = 0;\\n for (int j = 0; j < 5; j++) {\\n if (v[i][j] < v[cnt][j]) {\\n ans++;\\n }\\n }\\n if (ans >= 3) {\\n cnt = i;\\n }\\n }\\n bool ok = true;\\n for (int i = 0; i < n; i++) {\\n ans = 0;\\n if (i != cnt) {\\n for (int j = 0; j < 5; j++) {\\n if (v[cnt][j] < v[i][j]) {\\n ans++;\\n }\\n }\\n if (ans < 3) {\\n ok = false;\\n }\\n }\\n }\\n if (n == 1) {\\n cout << 1 << endl;\\n } else {\\n if (ok) {\\n cout << cnt + 1 << endl;\\n } else {\\n cout << -1 << endl;\\n }\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A string s of length n, consisting of lowercase letters of the English alphabet, is given.\\n\\nYou must choose some number k between 0 and n. Then, you select k characters of s and permute them however you want. In this process, the positions of the other n-k characters remain unchanged. You have to perform this operation exactly once.\\n\\nFor example, if s=\\\"andrea\\\", you can choose the k=4 characters \\\"a_d_ea\\\" and permute them into \\\"d_e_aa\\\" so that after the operation the string becomes \\\"dneraa\\\".\\n\\nDetermine the minimum k so that it is possible to sort s alphabetically (that is, after the operation its characters appear in alphabetical order).\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases. Then t test cases follow.\\n\\nThe first line of each test case contains one integer n (1 ≤ n ≤ 40) — the length of the string.\\n\\nThe second line of each test case contains the string s. It is guaranteed that s contains only lowercase letters of the English alphabet.\\n\\nOutput\\n\\nFor each test case, output the minimum k that allows you to obtain a string sorted alphabetically, through the operation described above.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\nlol\\n10\\ncodeforces\\n5\\naaaaa\\n4\\ndcba\\n\\n\\nOutput\\n\\n\\n2\\n6\\n0\\n4\\n\\nNote\\n\\nIn the first test case, we can choose the k=2 characters \\\"_ol\\\" and rearrange them as \\\"_lo\\\" (so the resulting string is \\\"llo\\\"). It is not possible to sort the string choosing strictly less than 2 characters.\\n\\nIn the second test case, one possible way to sort s is to consider the k=6 characters \\\"_o__force_\\\" and rearrange them as \\\"_c__efoor_\\\" (so the resulting string is \\\"ccdeefoors\\\"). One can show that it is not possible to sort the string choosing strictly less than 6 characters.\\n\\nIn the third test case, string s is already sorted (so we can choose k=0 characters).\\n\\nIn the fourth test case, we can choose all k=4 characters \\\"dcba\\\" and reverse the whole string (so the resulting string is \\\"abcd\\\").\\nUsing python3 can you solve the prior task?\",\"targets\":\"for _ in range(int(input())):\\n n=int(input())\\n s=input()\\n d=sorted(s)\\n count=0\\n for i in range(n):\\n if(s[i]!=d[i]):\\n count+=1\\n print(count)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Berland State University has received a new update for the operating system. Initially it is installed only on the 1-st computer.\\n\\nUpdate files should be copied to all n computers. The computers are not connected to the internet, so the only way to transfer update files from one computer to another is to copy them using a patch cable (a cable connecting two computers directly). Only one patch cable can be connected to a computer at a time. Thus, from any computer where the update files are installed, they can be copied to some other computer in exactly one hour.\\n\\nYour task is to find the minimum number of hours required to copy the update files to all n computers if there are only k patch cables in Berland State University.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^5) — the number of test cases.\\n\\nEach test case consists of a single line that contains two integers n and k (1 ≤ k ≤ n ≤ 10^{18}) — the number of computers and the number of patch cables.\\n\\nOutput\\n\\nFor each test case print one integer — the minimum number of hours required to copy the update files to all n computers.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n8 3\\n6 6\\n7 1\\n1 1\\n\\n\\nOutput\\n\\n\\n4\\n3\\n6\\n0\\n\\nNote\\n\\nLet's consider the test cases of the example:\\n\\n * n=8, k=3: \\n 1. during the first hour, we copy the update files from the computer 1 to the computer 2; \\n 2. during the second hour, we copy the update files from the computer 1 to the computer 3, and from the computer 2 to the computer 4; \\n 3. during the third hour, we copy the update files from the computer 1 to the computer 5, from the computer 2 to the computer 6, and from the computer 3 to the computer 7; \\n 4. during the fourth hour, we copy the update files from the computer 2 to the computer 8. \\n * n=6, k=6: \\n 1. during the first hour, we copy the update files from the computer 1 to the computer 2; \\n 2. during the second hour, we copy the update files from the computer 1 to the computer 3, and from the computer 2 to the computer 4; \\n 3. during the third hour, we copy the update...\\nUsing python3 can you solve the prior task?\",\"targets\":\"from sys import stdin\\nlst = list(map(int, stdin.read().split()))\\n_s = 0\\ndef inp(n=1):\\n global _s\\n ret = lst[_s:_s + n]\\n _s += n\\n return ret\\ndef inp1():\\n return inp()[0]\\n\\nt = inp1()\\nfor _ in range(t):\\n n = inp1()\\n k = inp1()\\n done = 1\\n time = 0\\n while done <= k and done < n:\\n done += done\\n time += 1\\n if done < n:\\n time += (n - done + k - 1) \\/\\/ k\\n print(time)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alice, Bob and Charlie are playing Card Game for Three, as below:\\n\\n* At first, each of the three players has a deck consisting of some number of cards. Alice's deck has N cards, Bob's deck has M cards, and Charlie's deck has K cards. Each card has a letter `a`, `b` or `c` written on it. The orders of the cards in the decks cannot be rearranged.\\n* The players take turns. Alice goes first.\\n* If the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says `a`, Alice takes the next turn.)\\n* If the current player's deck is empty, the game ends and the current player wins the game.\\n\\n\\n\\nThere are 3^{N+M+K} possible patters of the three player's initial decks. Among these patterns, how many will lead to Alice's victory?\\n\\nSince the answer can be large, print the count modulo 1\\\\,000\\\\,000\\\\,007 (=10^9+7).\\n\\nConstraints\\n\\n* 1 \\\\leq N \\\\leq 3×10^5\\n* 1 \\\\leq M \\\\leq 3×10^5\\n* 1 \\\\leq K \\\\leq 3×10^5\\n\\nInput\\n\\nThe input is given from Standard Input in the following format:\\n\\n\\nN M K\\n\\n\\nOutput\\n\\nPrint the answer modulo 1\\\\,000\\\\,000\\\\,007 (=10^9+7).\\n\\nExamples\\n\\nInput\\n\\n1 1 1\\n\\n\\nOutput\\n\\n17\\n\\n\\nInput\\n\\n4 2 2\\n\\n\\nOutput\\n\\n1227\\n\\n\\nInput\\n\\n1000 1000 1000\\n\\n\\nOutput\\n\\n261790852\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include\\n#define inf 0x7fffffff\\n#define RG register\\n#define int long long\\n#define maxn 1000005\\n#define maxm 205\\nusing namespace std;\\ntypedef long long ll;\\nconst ll mod = 1e9 + 7;\\ninline ll read(){\\n ll x = 0, f = 1;\\n char ch = getchar();\\n while(ch > '9' || ch < '0') {if(ch == '-') f = -1;ch = getchar();}\\n while(ch >= '0' && ch <= '9'){x = x *10 + ch -'0';ch = getchar();}\\n return x * f;\\n}\\n \\nint n, m, k, po[2][maxn];\\nint qpow(int a, int b){\\n\\tint ans = 1, base = a;\\n\\twhile(b){\\n\\t\\tif(b & 1) ans = 1ll * ans * base % mod;\\n\\t\\tbase= 1ll * base * base % mod;\\n\\t\\tb >>= 1;\\n\\t}\\n\\treturn ans;\\n}\\nint fac[maxn], inv[maxn], ans;\\nint C(int n, int m){return 1ll * fac[n] * inv[m] % mod *inv[n - m] % mod;}\\nsigned main(){\\n\\tint i, j, x, l, r, mid;\\n\\tfac[0] = po[0][0] = po[1][0] = 1;\\n\\tfor(i = 1;i <= maxn - 5;i++) fac[i] = 1ll * fac[i - 1] * i % mod, po[0][i] = po[0][i - 1] * 2ll % mod, po[1][i] = po[1][i - 1] * 3ll % mod;\\n\\tinv[maxn - 5] = qpow(fac[maxn - 5], mod - 2);\\n\\tfor(i = maxn - 6;i >= 0;i--) inv[i] = 1ll * inv[i + 1] * (i + 1) % mod; \\n\\tn = read(), m = read(), k = read();\\n\\tint las = 1;\\n\\tfor(i = 0;i <= m + k;i++){\\n\\t\\tans = (ans + 1ll * C(n + i - 1, n - 1) * po[1][m + k -i] % mod * las % mod) % mod;\\n\\t\\tif(i + 1 <= m && i + 1 <= k) las = las * 2ll % mod;\\n\\t\\telse{\\n\\t\\t\\tif(i + 1 <= k) las = ((las * 2ll - C(i, m)) % mod + mod) % mod; \\n\\t\\t\\telse if(i + 1 <= m) las = ((las * 2ll - C(i, i - k)) % mod + mod) % mod;\\n\\t\\t\\telse las = (((las * 2ll - C(i, i - k)) % mod + mod - C(i, m) ) % mod + mod ) % mod;\\n\\t\\t}\\n\\t}\\n\\tprintf(\\\"%lld\\\\n\\\",ans);\\n\\treturn 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"There are n block towers in a row, where tower i has a height of a_i. You're part of a building crew, and you want to make the buildings look as nice as possible. In a single day, you can perform the following operation:\\n\\n * Choose two indices i and j (1 ≤ i, j ≤ n; i ≠ j), and move a block from tower i to tower j. This essentially decreases a_i by 1 and increases a_j by 1. \\n\\n\\n\\nYou think the ugliness of the buildings is the height difference between the tallest and shortest buildings. Formally, the ugliness is defined as max(a)-min(a). \\n\\nWhat's the minimum possible ugliness you can achieve, after any number of days?\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 1000) — the number of test cases. Then t cases follow.\\n\\nThe first line of each test case contains one integer n (2 ≤ n ≤ 100) — the number of buildings.\\n\\nThe second line of each test case contains n space separated integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^7) — the heights of the buildings.\\n\\nOutput\\n\\nFor each test case, output a single integer — the minimum possible ugliness of the buildings.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n3\\n10 10 10\\n4\\n3 2 1 2\\n5\\n1 2 3 1 5\\n\\n\\nOutput\\n\\n\\n0\\n0\\n1\\n\\nNote\\n\\nIn the first test case, the ugliness is already 0.\\n\\nIn the second test case, you should do one operation, with i = 1 and j = 3. The new heights will now be [2, 2, 2, 2], with an ugliness of 0.\\n\\nIn the third test case, you may do three operations: \\n\\n 1. with i = 3 and j = 1. The new array will now be [2, 2, 2, 1, 5], \\n 2. with i = 5 and j = 4. The new array will now be [2, 2, 2, 2, 4], \\n 3. with i = 5 and j = 3. The new array will now be [2, 2, 3, 2, 3]. \\n\\nThe resulting ugliness is 1. It can be proven that this is the minimum possible ugliness for this test.\\nUsing python3 can you solve the prior task?\",\"targets\":\"for t in range(int(input())):\\n n = int(input())\\n heights = list(map(int, input().split()))\\n tot = sum(heights)\\n print(1) if tot%n else print(0)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nShohag has an integer sequence a_1, a_2, …, a_n. He can perform the following operation any number of times (possibly, zero):\\n\\n * Select any positive integer k (it can be different in different operations). \\n * Choose any position in the sequence (possibly the beginning or end of the sequence, or in between any two elements) and insert k into the sequence at this position. \\n * This way, the sequence a changes, and the next operation is performed on this changed sequence. \\n\\n\\n\\nFor example, if a=[3,3,4] and he selects k = 2, then after the operation he can obtain one of the sequences [\\\\underline{2},3,3,4], [3,\\\\underline{2},3,4], [3,3,\\\\underline{2},4], or [3,3,4,\\\\underline{2}].\\n\\nShohag wants this sequence to satisfy the following condition: for each 1 ≤ i ≤ |a|, a_i ≤ i. Here, |a| denotes the size of a.\\n\\nHelp him to find the minimum number of operations that he has to perform to achieve this goal. We can show that under the constraints of the problem it's always possible to achieve this goal in a finite number of operations.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 200) — the number of test cases.\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 100) — the initial length of the sequence.\\n\\nThe second line of each test case contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^9) — the elements of the sequence.\\n\\nOutput\\n\\nFor each test case, print a single integer — the minimum number of operations needed to perform to achieve the goal mentioned in the statement.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n1 3 4\\n5\\n1 2 5 7 4\\n1\\n1\\n3\\n69 6969 696969\\n\\n\\nOutput\\n\\n\\n1\\n3\\n0\\n696966\\n\\nNote\\n\\nIn the first test case, we have to perform at least one operation, as a_2=3>2. We can perform the operation [1, 3, 4] → [1, \\\\underline{2}, 3, 4] (the newly inserted element is underlined), now the condition is satisfied.\\n\\nIn the second test case, Shohag can perform the following operations:\\n\\n[1, 2, 5, 7, 4] → [1, 2, \\\\underline{3}, 5, 7, 4] → [1, 2, 3, \\\\underline{4}, 5, 7, 4] → [1, 2, 3, 4, 5, \\\\underline{3}, 7, 4].\\n\\nIn the third...\",\"targets\":\"import java.util.Scanner;\\n\\npublic class SolutionA {\\n public static void main(String[] args) {\\n int t, n, max = 0, ans = 0, res = 0, maxIndex, maxMax;\\n Scanner scan = new Scanner(System.in);\\n t = scan.nextInt();\\n int[][] a = new int[200][];\\n for (int i = 0; i < t; i++) {\\n n = scan.nextInt();\\n a[i] = new int[n];\\n for (int j = 0; j < n; j++) {\\n a[i][j] = scan.nextInt();\\n }\\n }\\n\\n for (int i = 0; i < t; i++) {\\n max = 0;\\n maxIndex = 0;\\n res = 0;\\n ans = 0;\\n for (int j = 0; j < a[i].length; j++) {\\n if (a[i][j] > max) {\\n max = a[i][j];\\n maxIndex = j;\\n res = Math.max(0, a[i][maxIndex] - 1 - maxIndex);\\n if (res > ans) {\\n ans = res;\\n }\\n }\\n }\\n System.out.println(ans);\\n }\\n }\\n\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 ≤ si ≤ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum number of cars will the children need if all members of each group should ride in the same taxi (but one taxi can take more than one group)?\\n\\nInput\\n\\nThe first line contains integer n (1 ≤ n ≤ 105) — the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 ≤ si ≤ 4). The integers are separated by a space, si is the number of children in the i-th group.\\n\\nOutput\\n\\nPrint the single number — the minimum number of taxis necessary to drive all children to Polycarpus.\\n\\nExamples\\n\\nInput\\n\\n5\\n1 2 4 3 3\\n\\n\\nOutput\\n\\n4\\n\\n\\nInput\\n\\n8\\n2 3 4 4 2 1 3 1\\n\\n\\nOutput\\n\\n5\\n\\nNote\\n\\nIn the first test we can sort the children into four cars like this:\\n\\n * the third group (consisting of four children), \\n * the fourth group (consisting of three children), \\n * the fifth group (consisting of three children), \\n * the first and the second group (consisting of one and two children, correspondingly). \\n\\n\\n\\nThere are other ways to sort the groups into four cars.\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int n;\\n cin >> n;\\n vector passenger;\\n for (int i = 0; i < n; i++) {\\n int x;\\n cin >> x;\\n passenger.push_back(x);\\n }\\n sort(passenger.begin(), passenger.end());\\n int i = 0;\\n int j = n - 1;\\n int taxi = 0;\\n while (i != j) {\\n if (passenger[i] + passenger[j] <= 4) {\\n int temp = passenger[j];\\n passenger[j] = passenger[i] + temp;\\n i++;\\n } else {\\n taxi++;\\n j--;\\n }\\n }\\n taxi++;\\n cout << taxi;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"The only difference between this problem and D2 is that you don't have to provide the way to construct the answer in this problem, but you have to do it in D2.\\n\\nThere's a table of n × m cells (n rows and m columns). The value of n ⋅ m is even.\\n\\nA domino is a figure that consists of two cells having a common side. It may be horizontal (one of the cells is to the right of the other) or vertical (one of the cells is above the other).\\n\\nYou need to find out whether it is possible to place nm\\/2 dominoes on the table so that exactly k of them are horizontal and all the other dominoes are vertical. The dominoes cannot overlap and must fill the whole table.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of a single line. The line contains three integers n, m, k (1 ≤ n,m ≤ 100, 0 ≤ k ≤ nm\\/2, n ⋅ m is even) — the number of rows, columns and horizontal dominoes, respectively.\\n\\nOutput\\n\\nFor each test case output \\\"YES\\\", if it is possible to place dominoes in the desired way, or \\\"NO\\\" otherwise.\\n\\nYou may print each letter in any case (YES, yes, Yes will all be recognized as positive answer, NO, no and nO will all be recognized as negative answer).\\n\\nExample\\n\\nInput\\n\\n\\n8\\n4 4 2\\n2 3 0\\n3 2 3\\n1 2 0\\n2 4 2\\n5 2 2\\n2 17 16\\n2 1 1\\n\\n\\nOutput\\n\\n\\nYES\\nYES\\nYES\\nNO\\nYES\\nNO\\nYES\\nNO\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nint main() {\\n cin.sync_with_stdio(false);\\n cin.tie(nullptr);\\n int size;\\n cin >> size;\\n for (int i = 0; i < size; ++i) {\\n int n, m, k;\\n cin >> n >> m >> k;\\n bool res;\\n if (n % 2 == 0) {\\n if (m % 2 == 0)\\n res = k % 2 == 0;\\n else\\n res = k % 2 == 0 && k <= (n \\/ 2) * (m - 1);\\n } else {\\n res = k >= m \\/ 2 && (k - m \\/ 2) % 2 == 0;\\n }\\n cout << (res ? \\\"YES\\\\n\\\" : \\\"NO\\\\n\\\");\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nDmitry has an array of n non-negative integers a_1, a_2, ..., a_n.\\n\\nIn one operation, Dmitry can choose any index j (1 ≤ j ≤ n) and increase the value of the element a_j by 1. He can choose the same index j multiple times.\\n\\nFor each i from 0 to n, determine whether Dmitry can make the MEX of the array equal to exactly i. If it is possible, then determine the minimum number of operations to do it.\\n\\nThe MEX of the array is equal to the minimum non-negative integer that is not in the array. For example, the MEX of the array [3, 1, 0] is equal to 2, and the array [3, 3, 1, 4] is equal to 0.\\n\\nInput\\n\\nThe first line of input data contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases in the input. \\n\\nThe descriptions of the test cases follow.\\n\\nThe first line of the description of each test case contains a single integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the length of the array a.\\n\\nThe second line of the description of each test case contains n integers a_1, a_2, ..., a_n (0 ≤ a_i ≤ n) — elements of the array a.\\n\\nIt is guaranteed that the sum of the values n over all test cases in the test does not exceed 2⋅10^5.\\n\\nOutput\\n\\nFor each test case, output n + 1 integer — i-th number is equal to the minimum number of operations for which you can make the array MEX equal to i (0 ≤ i ≤ n), or -1 if this cannot be done.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n3\\n0 1 3\\n7\\n0 1 2 3 4 3 2\\n4\\n3 0 0 0\\n7\\n4 6 2 3 5 0 5\\n5\\n4 0 1 0 4\\n\\n\\nOutput\\n\\n\\n1 1 0 -1 \\n1 1 2 2 1 0 2 6 \\n3 0 1 4 3 \\n1 0 -1 -1 -1 -1 -1 -1 \\n2 1 0 2 -1 -1 \\n\\nNote\\n\\nIn the first set of example inputs, n=3:\\n\\n * to get MEX=0, it is enough to perform one increment: a_1++; \\n * to get MEX=1, it is enough to perform one increment: a_2++; \\n * MEX=2 for a given array, so there is no need to perform increments; \\n * it is impossible to get MEX=3 by performing increments.\",\"targets\":\"import java.util.*;\\nimport java.lang.*;\\nimport java.rmi.ConnectIOException;\\nimport java.io.*;\\n\\npublic class Main {\\n static FastReader in;\\n static PrintWriter out;\\n\\n static int bit(long n) {\\n return (n == 0) ? 0 : (1 + bit(n & (n - 1)));\\n }\\n\\n static void p(Object o) {\\n out.print(o);\\n }\\n\\n static void pn(Object o) {\\n out.println(o);\\n }\\n\\n static void pni(Object o) {\\n out.println(o);\\n out.flush();\\n }\\n\\n static String n() throws Exception {\\n return in.next();\\n }\\n\\n static String nln() throws Exception {\\n return in.nextLine();\\n }\\n\\n static int ni() throws Exception {\\n return Integer.parseInt(in.next());\\n }\\n\\n static long nl() throws Exception {\\n return Long.parseLong(in.next());\\n }\\n\\n static double nd() throws Exception {\\n return Double.parseDouble(in.next());\\n }\\n\\n static class FastReader {\\n static BufferedReader br;\\n static StringTokenizer st;\\n\\n public FastReader() {\\n br = new BufferedReader(new InputStreamReader(System.in));\\n }\\n\\n public FastReader(String s) throws Exception {\\n br = new BufferedReader(new FileReader(s));\\n }\\n\\n String next() throws Exception {\\n while (st == null || !st.hasMoreElements()) {\\n try {\\n st = new StringTokenizer(br.readLine());\\n } catch (IOException e) {\\n throw new Exception(e.toString());\\n }\\n }\\n return st.nextToken();\\n }\\n\\n String nextLine() throws Exception {\\n String str = \\\"\\\";\\n try {\\n str = br.readLine();\\n } catch (IOException e) {\\n throw new Exception(e.toString());\\n }\\n return str;\\n }\\n }\\n\\n static long power(long a, long b) {\\n if (b == 0)\\n return 1;\\n long val = power(a, b \\/ 2);\\n val = val * val;\\n if ((b % 2) != 0)\\n val =...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nStephen Queen wants to write a story. He is a very unusual writer, he uses only letters 'a', 'b', 'c', 'd' and 'e'!\\n\\nTo compose a story, Stephen wrote out n words consisting of the first 5 lowercase letters of the Latin alphabet. He wants to select the maximum number of words to make an interesting story.\\n\\nLet a story be a sequence of words that are not necessarily different. A story is called interesting if there exists a letter which occurs among all words of the story more times than all other letters together.\\n\\nFor example, the story consisting of three words \\\"bac\\\", \\\"aaada\\\", \\\"e\\\" is interesting (the letter 'a' occurs 5 times, all other letters occur 4 times in total). But the story consisting of two words \\\"aba\\\", \\\"abcde\\\" is not (no such letter that it occurs more than all other letters in total).\\n\\nYou are given a sequence of n words consisting of letters 'a', 'b', 'c', 'd' and 'e'. Your task is to choose the maximum number of them to make an interesting story. If there's no way to make a non-empty story, output 0.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 5000) — the number of test cases. Then t test cases follow.\\n\\nThe first line of each test case contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of the words in the sequence. Then n lines follow, each of them contains a word — a non-empty string consisting of lowercase letters of the Latin alphabet. The words in the sequence may be non-distinct (i. e. duplicates are allowed). Only the letters 'a', 'b', 'c', 'd' and 'e' may occur in the words.\\n\\nIt is guaranteed that the sum of n over all test cases doesn't exceed 2 ⋅ 10^5; the sum of the lengths of all words over all test cases doesn't exceed 4 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, output the maximum number of words that compose an interesting story. Print 0 if there's no way to make a non-empty interesting story.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n3\\nbac\\naaada\\ne\\n3\\naba\\nabcde\\naba\\n2\\nbaba\\nbaba\\n4\\nab\\nab\\nc\\nbc\\n5\\ncbdca\\nd\\na\\nd\\ne\\n3\\nb\\nc\\nca\\n\\n\\nOutput\\n\\n\\n3\\n2\\n0\\n2\\n3\\n2\\n\\nNote\\n\\nIn the first test case of the example, all 3 words...\",\"targets\":\"#include \\nusing namespace std;\\nlong long freq_str(string s, char c) {\\n long long cunt = 0;\\n for (int i = 0; i < s.length(); i++) {\\n if (s[i] == c) cunt++;\\n }\\n return (cunt - (s.length() - cunt));\\n}\\nvoid solve() {\\n long long n, longest_string, cunt, ans = 0;\\n cin >> n;\\n vector v(n);\\n for (int i = 0; i < n; i++) {\\n cin >> v[i];\\n }\\n for (char c = 'a'; c <= 'e'; c++) {\\n vector fs(n);\\n for (int i = 0; i < n; i++) {\\n fs[i] = freq_str(v[i], c);\\n }\\n sort(fs.begin(), fs.end(), greater());\\n cunt = 0;\\n longest_string = 0;\\n for (int j = 0; j < n; j++) {\\n longest_string += fs[j];\\n if (longest_string > 0) {\\n cunt++;\\n } else\\n break;\\n }\\n ans = max(ans, cunt);\\n }\\n cout << ans << endl;\\n}\\nint main() {\\n int t;\\n cin >> t;\\n while (t--) {\\n solve();\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Blake is a CEO of a large company called \\\"Blake Technologies\\\". He loves his company very much and he thinks that his company should be the best. That is why every candidate needs to pass through the interview that consists of the following problem.\\n\\nWe define function f(x, l, r) as a bitwise OR of integers xl, xl + 1, ..., xr, where xi is the i-th element of the array x. You are given two arrays a and b of length n. You need to determine the maximum value of sum f(a, l, r) + f(b, l, r) among all possible 1 ≤ l ≤ r ≤ n.\\n\\n\\n\\nInput\\n\\nThe first line of the input contains a single integer n (1 ≤ n ≤ 1000) — the length of the arrays.\\n\\nThe second line contains n integers ai (0 ≤ ai ≤ 109).\\n\\nThe third line contains n integers bi (0 ≤ bi ≤ 109).\\n\\nOutput\\n\\nPrint a single integer — the maximum value of sum f(a, l, r) + f(b, l, r) among all possible 1 ≤ l ≤ r ≤ n.\\n\\nExamples\\n\\nInput\\n\\n5\\n1 2 4 3 2\\n2 3 3 12 1\\n\\n\\nOutput\\n\\n22\\n\\nInput\\n\\n10\\n13 2 7 11 8 4 9 8 5 1\\n5 7 18 9 2 3 0 11 8 6\\n\\n\\nOutput\\n\\n46\\n\\nNote\\n\\nBitwise OR of two non-negative integers a and b is the number c = a OR b, such that each of its digits in binary notation is 1 if and only if at least one of a or b have 1 in the corresponding position in binary notation.\\n\\nIn the first sample, one of the optimal answers is l = 2 and r = 4, because f(a, 2, 4) + f(b, 2, 4) = (2 OR 4 OR 3) + (3 OR 3 OR 12) = 7 + 15 = 22. Other ways to get maximum value is to choose l = 1 and r = 4, l = 1 and r = 5, l = 2 and r = 4, l = 2 and r = 5, l = 3 and r = 4, or l = 3 and r = 5.\\n\\nIn the second sample, the maximum value is obtained for l = 1 and r = 9.\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n long long int v1[1010], v2[1010];\\n long long int tam;\\n scanf(\\\"%lld\\\", &tam);\\n for (int i = 0; i < tam; i++) {\\n scanf(\\\"%lld\\\", &v1[i]);\\n }\\n for (int i = 0; i < tam; i++) {\\n scanf(\\\"%lld\\\", &v2[i]);\\n }\\n long long int sum1 = 0, max1 = 0, sum2 = 0;\\n for (int l = 0; l < tam; l++) {\\n for (int r = l; r < tam; r++) {\\n sum1 |= v1[r];\\n sum2 |= v2[r];\\n max1 = max(sum1 + sum2, max1);\\n }\\n max1 = max(sum1 + sum2, max1);\\n sum1 = 0;\\n sum2 = 0;\\n }\\n printf(\\\"%lld\\\\n\\\", max1);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Given a positive integer n. Find three distinct positive integers a, b, c such that a + b + c = n and \\\\operatorname{gcd}(a, b) = c, where \\\\operatorname{gcd}(x, y) denotes the [greatest common divisor (GCD)](https:\\/\\/en.wikipedia.org\\/wiki\\/Greatest_common_divisor) of integers x and y.\\n\\nInput\\n\\nThe input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 10^5) — the number of test cases. Description of the test cases follows.\\n\\nThe first and only line of each test case contains a single integer n (10 ≤ n ≤ 10^9).\\n\\nOutput\\n\\nFor each test case, output three distinct positive integers a, b, c satisfying the requirements. If there are multiple solutions, you can print any. We can show that an answer always exists.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n18\\n63\\n73\\n91\\n438\\n122690412\\n\\n\\nOutput\\n\\n\\n6 9 3\\n21 39 3\\n29 43 1\\n49 35 7\\n146 219 73\\n28622 122661788 2\\n\\nNote\\n\\nIn the first test case, 6 + 9 + 3 = 18 and \\\\operatorname{gcd}(6, 9) = 3.\\n\\nIn the second test case, 21 + 39 + 3 = 63 and \\\\operatorname{gcd}(21, 39) = 3.\\n\\nIn the third test case, 29 + 43 + 1 = 73 and \\\\operatorname{gcd}(29, 43) = 1.\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"t=int(input())\\nfor www in range(t):\\n n=int(input())\\n if (n%2==0):\\n print((n-2)\\/\\/2, (n-2)\\/\\/2+1, 1)\\n else:\\n if (n%4==1):\\n print((n-3)\\/\\/2, (n-3)\\/\\/2+2, 1)\\n else:\\n print((n-5)\\/\\/2, (n-5)\\/\\/2+4, 1)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A bow adorned with nameless flowers that bears the earnest hopes of an equally nameless person.\\n\\nYou have obtained the elegant bow known as the Windblume Ode. Inscribed in the weapon is an array of n (n ≥ 3) positive distinct integers (i.e. different, no duplicates are allowed).\\n\\nFind the largest subset (i.e. having the maximum number of elements) of this array such that its sum is a composite number. A positive integer x is called composite if there exists a positive integer y such that 1 < y < x and x is divisible by y.\\n\\nIf there are multiple subsets with this largest size with the composite sum, you can output any of them. It can be proven that under the constraints of the problem such a non-empty subset always exists.\\n\\nInput\\n\\nEach test consists of multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 100). Description of the test cases follows.\\n\\nThe first line of each test case contains an integer n (3 ≤ n ≤ 100) — the length of the array.\\n\\nThe second line of each test case contains n distinct integers a_{1},a_{2},...,a_{n} (1 ≤ a_{i} ≤ 200) — the elements of the array.\\n\\nOutput\\n\\nEach test case should have two lines of output.\\n\\nThe first line should contain a single integer x: the size of the largest subset with composite sum. The next line should contain x space separated integers representing the indices of the subset of the initial array.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n8 1 2\\n4\\n6 9 4 2\\n9\\n1 2 3 4 5 6 7 8 9\\n3\\n200 199 198\\n\\n\\nOutput\\n\\n\\n2\\n2 1\\n4\\n2 1 4 3\\n9\\n6 9 1 2 3 4 5 7 8\\n3\\n1 2 3 \\n\\nNote\\n\\nIn the first test case, the subset \\\\\\\\{a_2, a_1\\\\} has a sum of 9, which is a composite number. The only subset of size 3 has a prime sum equal to 11. Note that you could also have selected the subset \\\\\\\\{a_1, a_3\\\\} with sum 8 + 2 = 10, which is composite as it's divisible by 2.\\n\\nIn the second test case, the sum of all elements equals to 21, which is a composite number. Here we simply take the whole array as our subset.\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nbool isprime(long long int n) {\\n if (n == 1) return false;\\n for (long long int i = 2; i * i <= n; i++) {\\n if (n % i == 0) {\\n return false;\\n }\\n }\\n return true;\\n}\\nvoid go() {\\n long long int n, sum = 0;\\n cin >> n;\\n long long int a[n];\\n for (long long int i = 0; i < n; i++) {\\n cin >> a[i];\\n sum += a[i];\\n }\\n if (isprime(sum) == false) {\\n cout << n << \\\"\\\\n\\\";\\n for (long long int i = 0; i < n; i++) cout << i + 1 << \\\" \\\";\\n cout << \\\"\\\\n\\\";\\n return;\\n }\\n long long int t = 0;\\n for (long long int i = 0; i < n; i++) {\\n if (isprime(sum - a[i]) == false) {\\n t = i;\\n break;\\n }\\n }\\n cout << n - 1 << \\\"\\\\n\\\";\\n for (long long int j = 0; j < n; j++) {\\n if (j != t) cout << j + 1 << \\\" \\\";\\n }\\n cout << \\\"\\\\n\\\";\\n return;\\n}\\nsigned main() {\\n ios::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n long long int t = 1;\\n cin >> t;\\n while (t--) {\\n go();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nGiven n, find any array a_1, a_2, …, a_n of integers such that all of the following conditions hold: \\n\\n * 1 ≤ a_i ≤ 10^9 for every i from 1 to n.\\n\\n * a_1 < a_2 < … 0){\\n \\t\\t\\t\\n \\t\\t\\tint n=sc.nextInt();\\n for(int i=1;i<=n;i++){\\n System.out.print((i+1)+\\\" \\\");\\n }\\n System.out.println();\\n \\n \\n \\n \\n \\n\\n \\n \\n\\n \\n\\n \\n \\n \\t\\t\\t\\n\\n }\\n \\n\\n \\n \\n \\n \\n \\n\\n\\n }\\n \\n\\n \\n \\t\\n \\t\\t\\t\\n }\\n \\n \\n \\n \\n \\n \\n\\n\\n\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\n\\/\\/ LCM AND GCD\\n\\/*\\n\\tpublic static int gcd(int a,int b){\\n\\t\\tif(b == 0){\\n\\t\\t\\treturn a;\\n\\t\\t}\\n\\t\\treturn gcd(b,a%b);\\n\\t}\\n \\n\\tpublic static int lcm(int a,int b){\\n\\t\\t return (a \\/ gcd(a, b)) * b;\\n\\t}*\\/\\n\\n\\n\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\n\\n\\/\\/Iterator\\n\\n\\n\\n\\/*Iterator iterator = object.iterator();\\n \\n while (iterator.hasNext()) {\\n System.out.print(iterator.next() + \\\" \\\");\\n }*\\/\\n\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\n\\n\\nclass FastScanner\\n{\\n \\/\\/I don't understand how this works lmao\\n private int BS = 1 << 16;\\n private char NC = (char) 0;\\n private byte[] buf = new byte[BS];\\n private int bId = 0, size = 0;\\n private char c = NC;\\n private double cnt = 1;\\n private BufferedInputStream in;\\n \\n public FastScanner() {\\n in = new BufferedInputStream(System.in, BS);\\n }\\n \\n public FastScanner(String s) {\\n try {\\n in = new BufferedInputStream(new FileInputStream(new File(s)), BS);\\n } catch (Exception e) {\\n in = new BufferedInputStream(System.in, BS);\\n }\\n }\\n \\n public char getChar() {\\n while (bId == size) {\\n try {\\n size = in.read(buf);\\n } catch (Exception e) {\\n return NC;\\n }\\n if (size...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A permutation is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them doesn't exceed n. Let's denote the i-th element of permutation p as pi. We'll call number n the size of permutation p1, p2, ..., pn.\\n\\nNickolas adores permutations. He likes some permutations more than the others. He calls such permutations perfect. A perfect permutation is such permutation p that for any i (1 ≤ i ≤ n) (n is the permutation size) the following equations hold ppi = i and pi ≠ i. Nickolas asks you to print any perfect permutation of size n for the given n.\\n\\nInput\\n\\nA single line contains a single integer n (1 ≤ n ≤ 100) — the permutation size.\\n\\nOutput\\n\\nIf a perfect permutation of size n doesn't exist, print a single integer -1. Otherwise print n distinct integers from 1 to n, p1, p2, ..., pn — permutation p, that is perfect. Separate printed numbers by whitespaces.\\n\\nExamples\\n\\nInput\\n\\n1\\n\\n\\nOutput\\n\\n-1\\n\\n\\nInput\\n\\n2\\n\\n\\nOutput\\n\\n2 1 \\n\\n\\nInput\\n\\n4\\n\\n\\nOutput\\n\\n2 1 4 3 \\nimpor\",\"targets\":\"t sys\\n\\nn = int(sys.stdin.readline())\\n\\nif n % 2 == 1:\\n print -1\\nelse:\\n flist = []\\n nlist = [x+1 for x in range(n)]\\n for x in range(n\\/2):\\n flist.append(str(nlist[2*x+1]))\\n flist.append(str(nlist[2*x]))\\n print ' '.join(flist)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given an array of integers a of length n. The elements of the array can be either different or the same. \\n\\nEach element of the array is colored either blue or red. There are no unpainted elements in the array. One of the two operations described below can be applied to an array in a single step:\\n\\n * either you can select any blue element and decrease its value by 1; \\n * or you can select any red element and increase its value by 1. \\n\\n\\n\\nSituations in which there are no elements of some color at all are also possible. For example, if the whole array is colored blue or red, one of the operations becomes unavailable.\\n\\nDetermine whether it is possible to make 0 or more steps such that the resulting array is a permutation of numbers from 1 to n?\\n\\nIn other words, check whether there exists a sequence of steps (possibly empty) such that after applying it, the array a contains in some order all numbers from 1 to n (inclusive), each exactly once.\\n\\nInput\\n\\nThe first line contains an integer t (1 ≤ t ≤ 10^4) — the number of input data sets in the test.\\n\\nThe description of each set of input data consists of three lines. The first line contains an integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the length of the original array a. The second line contains n integers a_1, a_2, ..., a_n (-10^9 ≤ a_i ≤ 10^9) — the array elements themselves.\\n\\nThe third line has length n and consists exclusively of the letters 'B' and\\/or 'R': ith character is 'B' if a_i is colored blue, and is 'R' if colored red.\\n\\nIt is guaranteed that the sum of n over all input sets does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nPrint t lines, each of which contains the answer to the corresponding test case of the input. Print YES as an answer if the corresponding array can be transformed into a permutation, and NO otherwise.\\n\\nYou can print the answer in any case (for example, the strings yEs, yes, Yes, and YES will be recognized as a positive answer).\\n\\nExample\\n\\nInput\\n\\n\\n8\\n4\\n1 2 5 2\\nBRBR\\n2\\n1 1\\nBB\\n5\\n3 1 4 2 5\\nRBRRB\\n5\\n3 1 3 1 3\\nRBRRB\\n5\\n5 1 5 1 5\\nRBRRB\\n4\\n2 2 2 2\\nBRBR\\n2\\n1 -2\\nBR\\n4\\n-2...\\nUsing java can you solve the prior task?\",\"targets\":\"import java.io.*;\\nimport java.math.*;\\nimport java.util.*;\\n\\nimport javafx.util.Pair;\\n\\npublic class Solution {\\n\\tInputStream is;\\n\\tFastWriter out;\\n\\tString INPUT = \\\"\\\";\\n\\t\\n\\tpublic static void main(String[] args) throws Exception \\n\\t{\\n\\t\\tnew Solution().run();\\/\\/ Here run assign I\\/O calls solve also tell total time invested\\n\\t}\\n\\t\\n\\tvoid solve()\\n\\t{\\n\\t\\tint t=ni();\\n\\t\\twhile(t-->0)\\n\\t\\t\\tgo();\\n\\t}\\n\\t\\n\\tvoid go()\\n\\t{\\n\\t\\tint i,j,n=ni();\\n\\t\\tint arr[]=ni(n);\\n\\t\\tchar str[]=ns(n);\\n\\t\\tMap> map=new HashMap<>();\\n\\t\\tfor(i=0;i()));\\n\\t\\t\\tmap.get(str[i]).add(arr[i]);\\n\\t\\t}\\n\\t\\tif(map.containsKey('B'))\\n\\t\\t{\\n\\t\\t\\tint p=1;\\n\\t\\t\\tCollections.sort(map.get('B'));\\n\\t\\t\\tfor(Integer ele : map.get('B'))\\n\\t\\t\\t{\\n\\t\\t\\t\\tif(ele>=p)\\n\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\tp++;\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\telse \\n\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\tout.println(\\\"No\\\");\\n\\t\\t\\t\\t\\treturn;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\tif(map.containsKey('R'))\\n\\t\\t{\\n\\t\\t\\tint p=n;\\n\\t\\t\\tCollections.sort(map.get('R'),(o1,o2)->o2-o1);\\n\\t\\t\\tfor(Integer ele : map.get('R'))\\n\\t\\t\\t{\\n\\t\\t\\t\\tif(ele<=p)\\n\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\tp--;\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\telse \\n\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\tout.println(\\\"No\\\");\\n\\t\\t\\t\\t\\treturn;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\tout.println(\\\"Yes\\\");\\n\\t}\\n\\t\\n\\tstatic boolean prime[];\\n\\tstatic int count=0;\\n\\tvoid sieve(int n)\\n\\t{\\n\\t\\tprime=new boolean[n+1];\\n\\t\\tArrays.fill(prime, true);\\n\\t\\tfor(int i=2;i<=Math.sqrt(n);i++)\\n\\t\\t\\tif(prime[i])\\n\\t\\t\\t\\tfor(int j=i*i;j<=n;j+=i)\\n\\t\\t\\t\\t\\tprime[j]=false;\\n\\t}\\n\\t\\n\\tboolean isPrime(int n)\\n\\t{\\n\\t\\tfor(int i=2;i<=Math.sqrt(n);i++)\\n\\t\\t\\tif(n%i==0)\\n\\t\\t\\t\\treturn false;\\n\\t\\treturn true;\\n\\t}\\n\\t\\n\\tlong gcd(long a,long b)\\n\\t{\\n\\t\\tif(a==0)\\n\\t\\t\\treturn b;\\n\\t\\treturn gcd(b%a,a);\\n\\t}\\n\\t\\n\\tvoid run() throws Exception\\n\\t{\\n\\t\\tis = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());\\n\\t\\tout = new FastWriter(System.out);\\n\\t\\t\\n\\t\\tlong s = System.currentTimeMillis();\\n\\t\\tsolve();\\n\\t\\tout.flush();\\n\\t\\ttr(System.currentTimeMillis()-s+\\\"ms\\\");\\n\\t}\\n\\t\\n\\tbyte[] inbuf = new byte[1024];\\n\\tpublic int lenbuf = 0, ptrbuf = 0;\\n\\t\\n\\tprivate int readByte()\\n\\t{\\n\\t\\tif(lenbuf == -1)throw new InputMismatchException();\\n\\t\\tif(ptrbuf >= lenbuf){\\n\\t\\t\\tptrbuf = 0;\\n\\t\\t\\ttry { lenbuf = is.read(inbuf); } catch (IOException e) { throw new...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You have a permutation: an array a = [a_1, a_2, …, a_n] of distinct integers from 1 to n. The length of the permutation n is odd.\\n\\nConsider the following algorithm of sorting the permutation in increasing order.\\n\\nA helper procedure of the algorithm, f(i), takes a single argument i (1 ≤ i ≤ n-1) and does the following. If a_i > a_{i+1}, the values of a_i and a_{i+1} are exchanged. Otherwise, the permutation doesn't change.\\n\\nThe algorithm consists of iterations, numbered with consecutive integers starting with 1. On the i-th iteration, the algorithm does the following: \\n\\n * if i is odd, call f(1), f(3), …, f(n - 2); \\n * if i is even, call f(2), f(4), …, f(n - 1). \\n\\n\\n\\nIt can be proven that after a finite number of iterations the permutation will be sorted in increasing order.\\n\\nAfter how many iterations will this happen for the first time?\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 100). Description of the test cases follows.\\n\\nThe first line of each test case contains a single integer n (3 ≤ n ≤ 999; n is odd) — the length of the permutation.\\n\\nThe second line contains n distinct integers a_1, a_2, …, a_n (1 ≤ a_i ≤ n) — the permutation itself. \\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 999.\\n\\nOutput\\n\\nFor each test case print the number of iterations after which the permutation will become sorted in increasing order for the first time.\\n\\nIf the given permutation is already sorted, print 0.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n3\\n3 2 1\\n7\\n4 5 7 1 3 2 6\\n5\\n1 2 3 4 5\\n\\n\\nOutput\\n\\n\\n3\\n5\\n0\\n\\nNote\\n\\nIn the first test case, the permutation will be changing as follows: \\n\\n * after the 1-st iteration: [2, 3, 1]; \\n * after the 2-nd iteration: [2, 1, 3]; \\n * after the 3-rd iteration: [1, 2, 3]. \\n\\n\\n\\nIn the second test case, the permutation will be changing as follows: \\n\\n * after the 1-st iteration: [4, 5, 1, 7, 2, 3, 6]; \\n * after the 2-nd iteration: [4, 1, 5, 2, 7, 3, 6]; \\n * after the 3-rd iteration: [1, 4, 2, 5, 3, 7, 6]; \\n * after the 4-th...\",\"targets\":\"#include \\nusing namespace std;\\nconst int mod = 1e9 + 7;\\nint t, n, ans;\\nvector a, v;\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n cin >> t;\\n while (t--) {\\n cin >> n;\\n ans = 0;\\n for (int i = 0; i < n; i++) {\\n int x;\\n cin >> x;\\n a.push_back(x);\\n v.push_back(x);\\n }\\n sort(v.begin(), v.end());\\n while (1) {\\n if (a == v) break;\\n ans++;\\n for (int i = 0; i < n - 1; i++) {\\n if (a[i] > a[i + 1]) {\\n if (ans & 1 && !(i & 1)) {\\n swap(a[i], a[i + 1]);\\n } else if (!(ans & 1) && (i & 1)) {\\n swap(a[i], a[i + 1]);\\n }\\n }\\n }\\n }\\n cout << ans << endl;\\n a.clear();\\n v.clear();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"The problem statement looms below, filling you with determination.\\n\\nConsider a grid in which some cells are empty and some cells are filled. Call a cell in this grid exitable if, starting at that cell, you can exit the grid by moving up and left through only empty cells. This includes the cell itself, so all filled in cells are not exitable. Note that you can exit the grid from any leftmost empty cell (cell in the first column) by going left, and from any topmost empty cell (cell in the first row) by going up.\\n\\nLet's call a grid determinable if, given only which cells are exitable, we can exactly determine which cells are filled in and which aren't.\\n\\nYou are given a grid a of dimensions n × m , i. e. a grid with n rows and m columns. You need to answer q queries (1 ≤ q ≤ 2 ⋅ 10^5). Each query gives two integers x_1, x_2 (1 ≤ x_1 ≤ x_2 ≤ m) and asks whether the subgrid of a consisting of the columns x_1, x_1 + 1, …, x_2 - 1, x_2 is determinable.\\n\\nInput\\n\\nThe first line contains two integers n, m (1 ≤ n, m ≤ 10^6, nm ≤ 10^6) — the dimensions of the grid a.\\n\\nn lines follow. The y-th line contains m characters, the x-th of which is 'X' if the cell on the intersection of the the y-th row and x-th column is filled and \\\".\\\" if it is empty.\\n\\nThe next line contains a single integer q (1 ≤ q ≤ 2 ⋅ 10^5) — the number of queries.\\n\\nq lines follow. Each line contains two integers x_1 and x_2 (1 ≤ x_1 ≤ x_2 ≤ m), representing a query asking whether the subgrid of a containing the columns x_1, x_1 + 1, …, x_2 - 1, x_2 is determinable.\\n\\nOutput\\n\\nFor each query, output one line containing \\\"YES\\\" if the subgrid specified by the query is determinable and \\\"NO\\\" otherwise. The output is case insensitive (so \\\"yEs\\\" and \\\"No\\\" will also be accepted).\\n\\nExample\\n\\nInput\\n\\n\\n4 5\\n..XXX\\n...X.\\n...X.\\n...X.\\n5\\n1 3\\n3 3\\n4 5\\n5 5\\n1 5\\n\\n\\nOutput\\n\\n\\nYES\\nYES\\nNO\\nYES\\nNO\\n\\nNote\\n\\nFor each query of the example, the corresponding subgrid is displayed twice below: first in its input format, then with each cell marked as \\\"E\\\" if it is exitable and \\\"N\\\" otherwise.\\n\\nFor the...\\nimpor\",\"targets\":\"t java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.util.*;\\n\\npublic class CF1 {\\n public static void main(String[] args) {\\n FastScanner sc=new FastScanner();\\n\\/\\/ int T=sc.nextInt();\\n\\/\\/ for (int tt=0; tt l=new ArrayList<>();\\n for (int i:a) l.add(i);\\n Collections.sort(l);\\n for (int i=0; i l=new ArrayList<>();\\n for (long i:a) l.add(i);\\n Collections.sort(l);\\n for (int i=0; i\\n#define range(i, a, b) for(int i = (a); i < (b); i++)\\n#define rep(i, a) range(i, 0, a)\\nusing namespace std;\\n\\nint main() {\\n\\tint n;\\n\\tmap mp;\\n\\trep (i, 52 * 2) {\\n\\t\\tif (i < 26) {\\n\\t\\t\\tmp[i] = 'a' + i;\\n\\t\\t} else if (i < 52) {\\n\\t\\t\\tmp[i] = 'A' + 26 - (52 - i);\\n\\t\\t} else if (i < 26 * 3) {\\n\\t\\t\\tmp[i] = 'a' + 26 - (26*3 - i);\\n\\t\\t} else {\\n\\t\\t\\tmp[i] = 'A' + 26 - (26*4 - i);\\n\\t\\t}\\n\\t}\\n\\n\\twhile (cin >> n, n) {\\n\\t\\tvector k(n);\\n\\t\\trep (i, n) cin >> k[i];\\n\\t\\tstring s;\\n\\t\\tcin >> s;\\n\\t\\tstring out = \\\"\\\";\\n\\n\\t\\trep (i, s.size()) {\\n\\t\\t\\tint tmp;\\n\\t\\t\\tif ('a' <= s[i] && s[i] <= 'z') tmp = 52 + s[i] - 'a';\\n\\t\\t\\telse tmp = s[i] - 'A' + 78;\\n\\t\\t\\tout.push_back((char)mp[tmp - k[i%n]]);\\n\\t\\t}\\n\\t\\tcout << out << endl;\\n\\t}\\n\\treturn 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Diverta City is a new city consisting of N towns numbered 1, 2, ..., N.\\n\\nThe mayor Ringo is planning to connect every pair of two different towns with a bidirectional road. The length of each road is undecided.\\n\\nA Hamiltonian path is a path that starts at one of the towns and visits each of the other towns exactly once. The reversal of a Hamiltonian path is considered the same as the original Hamiltonian path.\\n\\nThere are N! \\/ 2 Hamiltonian paths. Ringo wants all these paths to have distinct total lengths (the sum of the lengths of the roads on a path), to make the city diverse.\\n\\nFind one such set of the lengths of the roads, under the following conditions:\\n\\n* The length of each road must be a positive integer.\\n* The maximum total length of a Hamiltonian path must be at most 10^{11}.\\n\\nConstraints\\n\\n* N is a integer between 2 and 10 (inclusive).\\n\\nInput\\n\\nInput is given from Standard Input in the following format:\\n\\n\\nN\\n\\n\\nOutput\\n\\nPrint a set of the lengths of the roads that meets the objective, in the following format:\\n\\n\\nw_{1, 1} \\\\ w_{1, 2} \\\\ w_{1, 3} \\\\ ... \\\\ w_{1, N}\\nw_{2, 1} \\\\ w_{2, 2} \\\\ w_{2, 3} \\\\ ... \\\\ w_{2, N}\\n: : :\\nw_{N, 1} \\\\ w_{N, 2} \\\\ w_{N, 3} \\\\ ... \\\\ w_{N, N}\\n\\n\\nwhere w_{i, j} is the length of the road connecting Town i and Town j, which must satisfy the following conditions:\\n\\n* w_{i, i} = 0\\n* w_{i, j} = w_{j, i} \\\\ (i \\\\neq j)\\n* 1 \\\\leq w_{i, j} \\\\leq 10^{11} \\\\ (i \\\\neq j)\\n\\n\\n\\nIf there are multiple sets of lengths of the roads that meet the objective, any of them will be accepted.\\n\\nExamples\\n\\nInput\\n\\n3\\n\\n\\nOutput\\n\\n0 6 15\\n6 0 21\\n15 21 0\\n\\n\\nInput\\n\\n4\\n\\n\\nOutput\\n\\n0 111 157 193\\n111 0 224 239\\n157 224 0 258\\n193 239 258 0\",\"targets\":\"\\/\\/ https:\\/\\/atcoder.jp\\/contests\\/diverta2019-2\\/tasks\\/diverta2019_2_f\\n\\/**\\/\\n\\/\\/ #include \\\"Template.hpp\\\"\\n\\/*<\\/head>*\\/\\n\\n\\/**\\/\\n\\/* #region header *\\/\\n\\/* #region 1*\\/\\n\\/**\\n * @file Template.hpp\\n * @brief 競技プログラミング用テンプレート\\n * @author btk15049\\n * @date 2019\\/05\\/02\\n *\\/\\n#include \\nusing namespace std;\\n\\n\\/* #region macro *\\/\\n#ifdef BTK\\n# define DEBUG if (1)\\n# define CIN_ONLY if (0)\\n#else\\n# define DEBUG if (0)\\n# define CIN_ONLY if (1)\\n#endif\\n\\/** @def\\n * ALLマクロ\\n *\\/\\n#define ALL(v) (v).begin(), (v).end()\\n\\n\\/** @def\\n * 再帰ラムダをするためのマクロ\\n *\\/\\n#define REC(ret, ...) std::function\\n\\/* #endregion *\\/\\n\\nnamespace _Template_ {\\n \\/**\\n * @brief cin高速化処理を行うための構造体\\n * @details CIN_ONLYマクロで動作が変わる\\n *\\/\\n struct cww {\\n cww() {\\n CIN_ONLY {\\n ios::sync_with_stdio(false);\\n cin.tie(0);\\n }\\n }\\n } star;\\n \\/**\\n * @brief change min\\n * @tparam T 型\\n * @param l 参照\\n * @param r 非参照\\n * @return 更新があればtrue\\n *\\/\\n template \\n inline bool chmin(T& l, T r) {\\n bool a = l > r;\\n if (a) l = r;\\n return a;\\n }\\n \\/**\\n * @brief chminのmax版\\n * @see chmin\\n *\\/\\n template \\n inline bool chmax(T& l, T r) {\\n bool a = l < r;\\n if (a) l = r;\\n return a;\\n }\\n \\/**\\n * @brief\\n * vectorに直接cin流すためのやつ\\n * @tparam T\\n * @param is\\n * @param v\\n * @return istream&\\n *\\/\\n template \\n istream& operator>>(istream& is, vector& v) {\\n for (auto& it : v) is >> it;\\n return is;\\n }\\n \\/**\\n * @brief\\n * rangeを逆向きに操作したいとき用\\n * @details\\n * ループの範囲は[bg,ed)なので注意\\n * @see range\\n *\\/\\n class reverse_range {\\n private:\\n struct I {\\n int x;\\n int operator*() { return x - 1; }\\n bool operator!=(I& lhs) { return x > lhs.x; }\\n void operator++() { --x; }\\n };\\n I i, n;\\n\\n public:\\n reverse_range(int n) : i({0}), n({n}) {}\\n ...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"The robot is located on a checkered rectangular board of size n × m (n rows, m columns). The rows in the board are numbered from 1 to n from top to bottom, and the columns — from 1 to m from left to right.\\n\\nThe robot is able to move from the current cell to one of the four cells adjacent by side.\\n\\nThe sequence of commands s executed by the robot is given. Each command is denoted by one of the symbols 'L', 'R', 'D' or 'U', and triggers the movement to left, right, down or up, respectively.\\n\\nThe robot can start its movement in any cell. The robot executes the commands starting from the first one, strictly in the order in which they are listed in s. If the robot moves beyond the edge of the board, it falls and breaks. A command that causes the robot to break is not considered successfully executed.\\n\\nThe robot's task is to execute as many commands as possible without falling off the board. For example, on board 3 × 3, if the robot starts a sequence of actions s=\\\"RRDLUU\\\" (\\\"right\\\", \\\"right\\\", \\\"down\\\", \\\"left\\\", \\\"up\\\", \\\"up\\\") from the central cell, the robot will perform one command, then the next command will force him to cross the edge. If the robot starts moving from the cell (2, 1) (second row, first column) then all commands will be executed successfully and the robot will stop at the cell (1, 2) (first row, second column).\\n\\n The robot starts from cell (2, 1) (second row, first column). It moves right, right, down, left, up, and up. In this case it ends in the cell (1, 2) (first row, second column).\\n\\nDetermine the cell from which the robot should start its movement in order to execute as many commands as possible.\\n\\nInput\\n\\nThe first line contains an integer t (1 ≤ t ≤ 10^4) — the number of test cases.\\n\\nThe next 2t lines contain descriptions of the test cases.\\n\\nIn the description of each test case, the first line contains two integers n and m (1 ≤ n, m ≤ 10^6) — the height and width of the field that the robot is located on. The second line of the description is a string s consisting solely of characters 'L',...\\n# Thi\",\"targets\":\"s code is contributed by Siddharth\\n\\n\\nfrom sys import *\\ninput = stdin.readline\\n\\n\\n\\nimport threading\\nfrom bisect import *\\nimport math\\nfrom collections import *\\nimport operator\\nfrom heapq import *\\nfrom itertools import *\\ninf=10**19\\nmod=10**9+7\\nMOD=998244353\\nS1 = 'abcdefghijklmnopqrstuvwxyz'\\nS2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\\ndx = [-1,0]\\ndy = [0,-1]\\n# inverse modulo power pow(a,-1,mod) - it only works on py 3.8 ( *not in pypy )\\nsetrecursionlimit(200005)\\ndef asc(c):\\n return ord(c)-97+1\\n\\n\\n\\n\\n\\n# ==========================================> Code Starts Here <=====================================================================)\\n\\n\\n\\n\\nfor _ in range(int(input())):\\n n,m=map(int,input().split())\\n s=input()[:-1]\\n sx=0\\n sy=0\\n x=0\\n y=0\\n ans=0\\n mxx=0\\n mxy=0\\n\\n for i in s:\\n if i=='R':\\n x+=1\\n elif i=='L':\\n x-=1\\n elif i=='U':\\n y-=1\\n else:\\n y+=1\\n mxx=max(mxx,x)\\n mxy=max(mxy,y)\\n if x>=m or y>=n:\\n break\\n if x<0 and mxx0){\\n\\t\\t\\tsolve();\\n\\t\\t}\\n\\t}\\n\\t\\n\\tpublic static void solve() {\\n\\t\\tlong n = sc.nextLong();\\n\\t\\t\\n\\t\\tHashSet set = new HashSet<>();\\n\\t\\t\\n\\t\\tfor(int i = 1;i <= Math.min(31623, (int)Math.sqrt(n));i++) {\\n\\t\\t\\tlong sq = (long)i * (long)i;\\n\\t\\t\\tif(sq <= n)set.add(sq);\\n\\t\\t\\tsq = sq * (long)i;\\n\\t\\t\\tif(sq <= n)set.add(sq);\\n\\t\\t}\\n\\t\\t\\n\\t\\tSystem.out.println(set.size());\\n\\t}\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Capitalization is writing a word with its first letter as a capital letter. Your task is to capitalize the given word.\\n\\nNote, that during capitalization all the letters except the first one remains unchanged.\\n\\nInput\\n\\nA single line contains a non-empty word. This word consists of lowercase and uppercase English letters. The length of the word will not exceed 103.\\n\\nOutput\\n\\nOutput the given word after capitalization.\\n\\nExamples\\n\\nInput\\n\\nApPLe\\n\\n\\nOutput\\n\\nApPLe\\n\\n\\nInput\\n\\nkonjac\\n\\n\\nOutput\\n\\nKonjac\",\"targets\":\"from sys import stdin\\n\\ndef cap_first(word):\\n return word[0].upper() + word[1:]\\n\\nprint(cap_first(stdin.readline()))\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"You are given a simple undirected graph with n vertices, n is even. You are going to write a letter on each vertex. Each letter should be one of the first k letters of the Latin alphabet.\\n\\nA path in the graph is called Hamiltonian if it visits each vertex exactly once. A string is called palindromic if it reads the same from left to right and from right to left. A path in the graph is called palindromic if the letters on the vertices in it spell a palindromic string without changing the order.\\n\\nA string of length n is good if: \\n\\n * each letter is one of the first k lowercase Latin letters; \\n * if you write the i-th letter of the string on the i-th vertex of the graph, there will exist a palindromic Hamiltonian path in the graph. \\n\\n\\n\\nNote that the path doesn't necesserily go through the vertices in order 1, 2, ..., n.\\n\\nCount the number of good strings.\\n\\nInput\\n\\nThe first line contains three integers n, m and k (2 ≤ n ≤ 12; n is even; 0 ≤ m ≤ (n ⋅ (n-1))\\/(2); 1 ≤ k ≤ 12) — the number of vertices in the graph, the number of edges in the graph and the number of first letters of the Latin alphabet that can be used.\\n\\nEach of the next m lines contains two integers v and u (1 ≤ v, u ≤ n; v ≠ u) — the edges of the graph. The graph doesn't contain multiple edges and self-loops.\\n\\nOutput\\n\\nPrint a single integer — number of good strings.\\n\\nExamples\\n\\nInput\\n\\n\\n4 3 3\\n1 2\\n2 3\\n3 4\\n\\n\\nOutput\\n\\n\\n9\\n\\n\\nInput\\n\\n\\n4 6 3\\n1 2\\n1 3\\n1 4\\n2 3\\n2 4\\n3 4\\n\\n\\nOutput\\n\\n\\n21\\n\\n\\nInput\\n\\n\\n12 19 12\\n1 3\\n2 6\\n3 6\\n3 7\\n4 8\\n8 5\\n8 7\\n9 4\\n5 9\\n10 1\\n10 4\\n10 6\\n9 10\\n11 1\\n5 11\\n7 11\\n12 2\\n12 5\\n12 11\\n\\n\\nOutput\\n\\n\\n456165084\\\":\",\"targets\":\"#include \\nusing namespace std;\\nvector > g;\\nmap dp;\\nvoid brute(int n, vector &p) {\\n int x = find(p.begin(), p.end(), -1) - p.begin();\\n if (x == int(p.size())) {\\n vector > dp2(1 << n, vector(n));\\n vector pos1(n), pos2(n);\\n for (int i = 0; i < p.size(); i++) pos1[p[i]] = pos2[p[i]], pos2[p[i]] = i;\\n for (int i = 0; i < int(n); i++)\\n if (g[pos1[i]][pos2[i]]) dp2[1 << i][i] = true;\\n for (int mask = 0; mask < 1 << n; mask++)\\n for (int i = 0; i < n; i++)\\n if (dp2[mask][i])\\n for (int j = 0; j < n; j++)\\n if (!((mask >> j) & 1))\\n dp2[mask | (1 << j)][j] |=\\n (g[pos1[i]][pos1[j]] && g[pos2[i]][pos2[j]]),\\n dp2[mask | (1 << j)][j] |=\\n (g[pos1[i]][pos2[j]] && g[pos2[i]][pos1[j]]);\\n for (int i = 0; i < int(n); i++)\\n if (dp2[(1 << n) - 1][i]) {\\n long long num = 0;\\n for (int x : p) num = num * 6 + x;\\n dp[num] = true;\\n break;\\n }\\n return;\\n }\\n for (int y = x + 1; y < int(p.size()); ++y)\\n if (p[y] == -1) p[x] = p[y] = n, brute(n + 1, p), p[x] = p[y] = -1;\\n}\\nbool dfs(vector p) {\\n vector used(int(p.size()), -1);\\n int cnt = 0;\\n for (int i = 0; i < int(p.size()); i++)\\n if (used[p[i]] == -1) used[p[i]] = cnt++;\\n long long num = 0;\\n for (int &x : p) x = used[x], num = num * 6 + x;\\n if (dp.count(num)) return dp[num];\\n bool res = false;\\n vector cur(cnt);\\n for (int i = 0; i < int(p.size()); i++) ++cur[p[i]];\\n for (int i = 0; i < int(p.size()); i++)\\n if (cur[p[i]] > 2) {\\n int x = p[i];\\n for (int j = i + 1; j < int(p.size()); ++j)\\n if (p[j] == p[i]) {\\n p[i] = p[j] = cnt;\\n if (dfs(p)) {\\n res = true;\\n break;\\n }\\n p[i] = p[j] = x;\\n }\\n break;\\n }\\n return dp[num] = res;\\n}\\nvoid brute2(int n, vector &p) {\\n int x = find(p.begin(), p.end(), -1) - p.begin();\\n if (x == int(p.size())) {\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nIn a certain video game, the player controls a hero characterized by a single integer value: power. The hero will have to beat monsters that are also characterized by a single integer value: armor.\\n\\nOn the current level, the hero is facing n caves. To pass the level, the hero must enter all the caves in some order, each cave exactly once, and exit every cave safe and sound. When the hero enters cave i, he will have to fight k_i monsters in a row: first a monster with armor a_{i, 1}, then a monster with armor a_{i, 2} and so on, finally, a monster with armor a_{i, k_i}.\\n\\nThe hero can beat a monster if and only if the hero's power is strictly greater than the monster's armor. If the hero can't beat the monster he's fighting, the game ends and the player loses. Note that once the hero enters a cave, he can't exit it before he fights all the monsters in it, strictly in the given order.\\n\\nEach time the hero beats a monster, the hero's power increases by 1.\\n\\nFind the smallest possible power the hero must start the level with to be able to enter all the caves in some order and beat all the monsters.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^5). Description of the test cases follows.\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 10^5) — the number of caves.\\n\\nThe i-th of the next n lines contains an integer k_i (1 ≤ k_i ≤ 10^5) — the number of monsters in the i-th cave, followed by k_i integers a_{i, 1}, a_{i, 2}, …, a_{i, k_i} (1 ≤ a_{i, j} ≤ 10^9) — armor levels of the monsters in cave i in order the hero has to fight them.\\n\\nIt is guaranteed that the sum of k_i over all test cases does not exceed 10^5.\\n\\nOutput\\n\\nFor each test case print a single integer — the smallest possible power the hero must start the level with to be able to enter all the caves in some order and beat all the monsters.\\n\\nExample\\n\\nInput\\n\\n\\n2\\n1\\n1 42\\n2\\n3 10 15 8\\n2 12 11\\n\\n\\nOutput\\n\\n\\n43\\n13\\n\\nNote\\n\\nIn the first test case, the hero has to beat a single monster with...\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\n\\npublic final class Main {\\n\\n static PrintWriter out = new PrintWriter(System.out);\\n static FastReader in = new FastReader();\\n static Pair[] moves = new Pair[]{new Pair(-1, 0), new Pair(1, 0), new Pair(0, -1), new Pair(0, 1)};\\n static int mod = (int) (1e9 + 7);\\n\\n public static void main(String[] args) {\\n int tt = i();\\n while (tt-- > 0) {\\n solve();\\n }\\n out.flush();\\n }\\n \\n private static void solve() {\\n int n = i();\\n int[][] m = new int[n][2];\\n for (int i = 0; i < n; i++) {\\n int k = i();\\n int[] a = input(k);\\n int s = a[0] + 1;\\n for (int j = 0; j < k; j++) {\\n s = Math.max(s, a[j] - j + 1);\\n }\\n m[i] = new int[]{s, k};\\n }\\n Arrays.sort(m, Comparator.comparingInt(o -> o[0]));\\n\\n int ans = m[0][0];\\n int p = 0;\\n int d = 0;\\n for (int i = 0; i < n; i++) {\\n if (ans + p + d < m[i][0]) {\\n d = m[i][0] - ans - p;\\n }\\n p += m[i][1];\\n }\\n out.println(ans + d);\\n }\\n\\n static int[] pre(int[] a) {\\n int[] pre = new int[a.length];\\n pre[0] = a[0];\\n for (int i = 1; i < a.length; i++) {\\n pre[i] = pre[i - 1] + a[i];\\n }\\n return pre;\\n }\\n\\n static int[] preRev(int[] a) {\\n int[] pre = new int[a.length];\\n pre[a.length - 1] = a[a.length - 1];\\n for (int i = a.length - 2; i >= 0; i--) {\\n pre[i] = pre[i + 1] + a[i];\\n }\\n return pre;\\n }\\n\\n static void print(char A[]) {\\n for (char c : A) {\\n out.print(c);\\n }\\n out.println();\\n }\\n\\n static void print(boolean A[]) {\\n for (boolean c : A) {\\n out.print(c + \\\" \\\");\\n }\\n out.println();\\n }\\n\\n static void print(int A[]) {\\n for (int c : A) {\\n out.print(c + \\\" \\\");\\n }\\n out.println();\\n }\\n\\n static void...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nEzzat has an array of n integers (maybe negative). He wants to split it into two non-empty subsequences a and b, such that every element from the array belongs to exactly one subsequence, and the value of f(a) + f(b) is the maximum possible value, where f(x) is the average of the subsequence x. \\n\\nA sequence x is a subsequence of a sequence y if x can be obtained from y by deletion of several (possibly, zero or all) elements.\\n\\nThe average of a subsequence is the sum of the numbers of this subsequence divided by the size of the subsequence.\\n\\nFor example, the average of [1,5,6] is (1+5+6)\\/3 = 12\\/3 = 4, so f([1,5,6]) = 4.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^3)— the number of test cases. Each test case consists of two lines.\\n\\nThe first line contains a single integer n (2 ≤ n ≤ 10^5).\\n\\nThe second line contains n integers a_1, a_2, …, a_n (-10^9 ≤ a_i ≤ 10^9).\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 3⋅10^5.\\n\\nOutput\\n\\nFor each test case, print a single value — the maximum value that Ezzat can achieve.\\n\\nYour answer is considered correct if its absolute or relative error does not exceed 10^{-6}.\\n\\nFormally, let your answer be a, and the jury's answer be b. Your answer is accepted if and only if \\\\frac{|a - b|}{max{(1, |b|)}} ≤ 10^{-6}.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n3 1 2\\n3\\n-7 -6 -6\\n3\\n2 2 2\\n4\\n17 3 5 -3\\n\\n\\nOutput\\n\\n\\n4.500000000\\n-12.500000000\\n4.000000000\\n18.666666667\\n\\nNote\\n\\nIn the first test case, the array is [3, 1, 2]. These are all the possible ways to split this array: \\n\\n * a = [3], b = [1,2], so the value of f(a) + f(b) = 3 + 1.5 = 4.5. \\n * a = [3,1], b = [2], so the value of f(a) + f(b) = 2 + 2 = 4. \\n * a = [3,2], b = [1], so the value of f(a) + f(b) = 2.5 + 1 = 3.5. \\n\\nTherefore, the maximum possible value 4.5.\\n\\nIn the second test case, the array is [-7, -6, -6]. These are all the possible ways to split this array: \\n\\n * a = [-7], b = [-6,-6], so the value of f(a) + f(b) = (-7) + (-6) = -13. \\n * a = [-7,-6], b = [-6], so the value of f(a) + f(b) = (-6.5) + (-6) =...\",\"targets\":\"import java.util.*;\\npublic class test\\n{\\n\\tpublic static void main (String[] args) \\n\\t{\\n\\t\\tScanner s=new Scanner(System.in);\\n\\t\\tint t=s.nextInt();\\n\\t\\tfor(int r=0;rmax) max=arr[i];\\n\\t\\t\\t\\tsum+=arr[i];\\n\\t\\t\\t}\\n\\t\\t\\tSystem.out.println((double)(max +(double)(sum-max)\\/(n-1)));\\n\\t\\t\\t\\n\\t\\t}\\n\\t}\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nGregor is learning about RSA cryptography, and although he doesn't understand how RSA works, he is now fascinated with prime numbers and factoring them.\\n\\nGregor's favorite prime number is P. Gregor wants to find two bases of P. Formally, Gregor is looking for two integers a and b which satisfy both of the following properties.\\n\\n * P mod a = P mod b, where x mod y denotes the remainder when x is divided by y, and \\n * 2 ≤ a < b ≤ P. \\n\\n\\n\\nHelp Gregor find two bases of his favorite prime number!\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 1000).\\n\\nEach subsequent line contains the integer P (5 ≤ P ≤ {10}^9), with P guaranteed to be prime.\\n\\nOutput\\n\\nYour output should consist of t lines. Each line should consist of two integers a and b (2 ≤ a < b ≤ P). If there are multiple possible solutions, print any.\\n\\nExample\\n\\nInput\\n\\n\\n2\\n17\\n5\\n\\n\\nOutput\\n\\n\\n3 5\\n2 4\\n\\nNote\\n\\nThe first query is P=17. a=3 and b=5 are valid bases in this case, because 17 mod 3 = 17 mod 5 = 2. There are other pairs which work as well.\\n\\nIn the second query, with P=5, the only solution is a=2 and b=4.\",\"targets\":\"#include \\nvoid solve() {\\n int P;\\n scanf(\\\"%d\\\", &P);\\n int a, b;\\n a = P - 1;\\n b = (P - 1) \\/ 2;\\n printf(\\\"%d %d\\\\n\\\", b, a);\\n}\\nint main() {\\n int t;\\n scanf(\\\"%d\\\", &t);\\n while (t--) {\\n solve();\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"n students attended the first meeting of the Berland SU programming course (n is even). All students will be divided into two groups. Each group will be attending exactly one lesson each week during one of the five working days (Monday, Tuesday, Wednesday, Thursday and Friday), and the days chosen for the groups must be different. Furthermore, both groups should contain the same number of students.\\n\\nEach student has filled a survey in which they told which days of the week are convenient for them to attend a lesson, and which are not. \\n\\nYour task is to determine if it is possible to choose two different week days to schedule the lessons for the group (the first group will attend the lesson on the first chosen day, the second group will attend the lesson on the second chosen day), and divide the students into two groups, so the groups have equal sizes, and for each student, the chosen lesson day for their group is convenient.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.\\n\\nThen the descriptions of t testcases follow.\\n\\nThe first line of each testcase contains one integer n (2 ≤ n ≤ 1 000) — the number of students.\\n\\nThe i-th of the next n lines contains 5 integers, each of them is 0 or 1. If the j-th integer is 1, then the i-th student can attend the lessons on the j-th day of the week. If the j-th integer is 0, then the i-th student cannot attend the lessons on the j-th day of the week. \\n\\nAdditional constraints on the input: for each student, at least one of the days of the week is convenient, the total number of students over all testcases doesn't exceed 10^5.\\n\\nOutput\\n\\nFor each testcase print an answer. If it's possible to divide the students into two groups of equal sizes and choose different days for the groups so each student can attend the lesson in the chosen day of their group, print \\\"YES\\\" (without quotes). Otherwise, print \\\"NO\\\" (without quotes). \\n\\nExample\\n\\nInput\\n\\n\\n2\\n4\\n1 0 0 1 0\\n0 1 0 0 1\\n0 0 0 1 0\\n0 1 0 1 0\\n2\\n0 0 0 1 0\\n0 0 0 1 0\\n\\n\\nOutput\\n\\n\\nYES\\nNO\\n\\nNote\\n\\nIn...\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nconst long double PI = acos(-1.0);\\nconst int MOD = 1e9 + 7;\\nconst int INF = 1 << 30;\\nconst long double EPS = 1e-6;\\nconst int MAXN = 1000 + 5;\\nint a[MAXN][5];\\nint n;\\nvoid solve() {\\n cin >> n;\\n for (int i = 0; i < n; ++i)\\n for (int j = 0; j < 5; ++j) cin >> a[i][j];\\n for (int i = 0; i < 5; ++i) {\\n for (int j = i + 1; j < 5; ++j) {\\n vector cnt(3);\\n for (int k = 0; k < n; ++k) {\\n if (a[k][i] && a[k][j])\\n cnt[2]++;\\n else if (a[k][i])\\n cnt[0]++;\\n else if (a[k][j])\\n cnt[1]++;\\n }\\n if (cnt[0] + cnt[2] >= n \\/ 2 && cnt[1] + cnt[2] >= n \\/ 2 &&\\n cnt[0] + cnt[1] + cnt[2] == n) {\\n cout << \\\"YES\\\" << '\\\\n';\\n return;\\n }\\n }\\n }\\n cout << \\\"NO\\\" << '\\\\n';\\n return;\\n}\\nint main() {\\n ios::sync_with_stdio(false), cin.tie(nullptr);\\n int T = 1;\\n cin >> T;\\n while (T--) {\\n solve();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given an array A of length N weights of masses A_1, A_2...A_N. No two weights have the same mass. You can put every weight on one side of the balance (left or right). You don't have to put weights in order A_1,...,A_N. There is also a string S consisting of characters \\\"L\\\" and \\\"R\\\", meaning that after putting the i-th weight (not A_i, but i-th weight of your choice) left or right side of the balance should be heavier. Find the order of putting the weights on the balance such that rules of string S are satisfied. \\n\\nInput\\n\\nThe first line contains one integer N (1 ≤ N ≤ 2*10^5) - the length of the array A The second line contains N distinct integers: A_1, A_2,...,A_N (1 ≤ A_i ≤ 10^9) - the weights given The third line contains string S of length N consisting only of letters \\\"L\\\" and \\\"R\\\" - string determining which side of the balance should be heavier after putting the i-th weight of your choice\\n\\nOutput\\n\\nThe output contains N lines. In every line, you should print one integer and one letter - integer representing the weight you are putting on the balance in that move and the letter representing the side of the balance where you are putting the weight. If there is no solution, print -1.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n3 8 2 13 7\\nLLRLL\\n\\n\\nOutput\\n\\n\\n3 L\\n2 R\\n8 R\\n13 L\\n7 L\\n\\nNote\\n\\nExplanation for the test case: \\n\\nafter the 1st weight: 3 L (left side is heavier)\\n\\nafter the 2nd weight: 2 R (left side is heavier)\\n\\nafter the 3rd weight: 8 R (right side is heavier)\\n\\nafter the 4th weight: 13 L (left side is heavier)\\n\\nafter the 5th weight: 7 L (left side is heavier)\\n\\nSo, the rules given by string S are fulfilled and our order of putting the weights is correct.\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nusing VI = vector;\\nchar opo(char c) { return (c == 'L' ? 'R' : 'L'); }\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n int n;\\n cin >> n;\\n VI V(n);\\n for (int& x : V) cin >> x;\\n string s;\\n cin >> s;\\n sort(V.begin(), V.end());\\n int dre = 0;\\n int i = 0;\\n while (i < n) {\\n int j = i;\\n while (++j < n and s[j] == s[i])\\n ;\\n if ((j - i) % 2 == 0) ++dre;\\n i = j;\\n }\\n char petit = opo(s[0]);\\n int esq = dre - 1;\\n i = 0;\\n while (i < n) {\\n int j = i;\\n while (++j < n and s[j] == s[i])\\n ;\\n int q = j - i;\\n int m = (q + 1) \\/ 2;\\n for (int k = 0; k < m; ++k) cout << V[dre + 2 * k] << ' ' << s[i] << '\\\\n';\\n if (q % 2) {\\n for (int k = m; k < q; ++k)\\n cout << V[dre + 1 + 2 * (k - m)] << ' ' << opo(s[i]) << '\\\\n';\\n } else {\\n for (int k = m; k < q - 1; ++k)\\n cout << V[dre + 1 + 2 * (k - m)] << ' ' << opo(s[i]) << '\\\\n';\\n cout << V[esq--] << ' ' << petit << endl;\\n --dre;\\n petit = opo(petit);\\n }\\n dre += q;\\n i = j;\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A positive (strictly greater than zero) integer is called round if it is of the form d00...0. In other words, a positive integer is round if all its digits except the leftmost (most significant) are equal to zero. In particular, all numbers from 1 to 9 (inclusive) are round.\\n\\nFor example, the following numbers are round: 4000, 1, 9, 800, 90. The following numbers are not round: 110, 707, 222, 1001.\\n\\nYou are given a positive integer n (1 ≤ n ≤ 10^4). Represent the number n as a sum of round numbers using the minimum number of summands (addends). In other words, you need to represent the given number n as a sum of the least number of terms, each of which is a round number.\\n\\nInput\\n\\nThe first line contains an integer t (1 ≤ t ≤ 10^4) — the number of test cases in the input. Then t test cases follow.\\n\\nEach test case is a line containing an integer n (1 ≤ n ≤ 10^4).\\n\\nOutput\\n\\nPrint t answers to the test cases. Each answer must begin with an integer k — the minimum number of summands. Next, k terms must follow, each of which is a round number, and their sum is n. The terms can be printed in any order. If there are several answers, print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n5009\\n7\\n9876\\n10000\\n10\\n\\n\\nOutput\\n\\n\\n2\\n5000 9\\n1\\n7 \\n4\\n800 70 6 9000 \\n1\\n10000 \\n1\\n10 \\nSolve the task in PYTHON3.\",\"targets\":\"t = int(input())\\n\\nfor _ in range(t):\\n n = int(input())\\n\\n c = 0\\n x = \\\"1\\\"\\n ans = []\\n while n > 0:\\n r = n % 10\\n y = r * int(x)\\n\\n if y != 0:\\n ans.append(y)\\n c += 1\\n x += \\\"0\\\"\\n n = n \\/\\/ 10\\n print(c)\\n for i in ans:\\n print(i, end = \\\" \\\")\\n print()\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size n. Let's call them a and b.\\n\\nNote that a permutation of n elements is a sequence of numbers a_1, a_2, …, a_n, in which every number from 1 to n appears exactly once. \\n\\nThe message can be decoded by an arrangement of sequence a and b, such that the number of matching pairs of elements between them is maximum. A pair of elements a_i and b_j is said to match if: \\n\\n * i = j, that is, they are at the same index. \\n * a_i = b_j \\n\\n\\n\\nHis two disciples are allowed to perform the following operation any number of times: \\n\\n * choose a number k and cyclically shift one of the permutations to the left or right k times. \\n\\n\\n\\nA single cyclic shift to the left on any permutation c is an operation that sets c_1:=c_2, c_2:=c_3, …, c_n:=c_1 simultaneously. Likewise, a single cyclic shift to the right on any permutation c is an operation that sets c_1:=c_n, c_2:=c_1, …, c_n:=c_{n-1} simultaneously.\\n\\nHelp Ishika and Hriday find the maximum number of pairs of elements that match after performing the operation any (possibly zero) number of times.\\n\\nInput\\n\\nThe first line of the input contains a single integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the size of the arrays.\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ n) — the elements of the first permutation.\\n\\nThe third line contains n integers b_1, b_2, ..., b_n (1 ≤ b_i ≤ n) — the elements of the second permutation.\\n\\nOutput\\n\\nPrint the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times.\\n\\nExamples\\n\\nInput\\n\\n\\n5\\n1 2 3 4 5\\n2 3 4 5 1\\n\\n\\nOutput\\n\\n\\n5\\n\\nInput\\n\\n\\n5\\n5 4 3 2 1\\n1 2 3 4 5\\n\\n\\nOutput\\n\\n\\n1\\n\\nInput\\n\\n\\n4\\n1 3 2 4\\n4 2 3 1\\n\\n\\nOutput\\n\\n\\n2\\n\\nNote\\n\\nFor the first case: b can be shifted to the right by k = 1. The resulting permutations will be \\\\{1, 2, 3, 4, 5\\\\} and \\\\{1, 2, 3, 4, 5\\\\}.\\n\\nFor the second case: The operation is not required....\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.util.ArrayList;\\nimport java.util.Arrays;\\nimport java.util.BitSet;\\nimport java.util.HashMap;\\nimport java.util.HashSet;\\nimport java.util.Scanner;\\n\\npublic class C {\\n\\tstatic ArrayList[] grap;\\n\\tstatic String s2 = \\\"Ashish\\\", s1 = \\\"Ayush\\\";\\n\\n\\tpublic static void main(String[] args) {\\n\\n\\t\\tScanner nik = new Scanner(System.in);\\n\\t\\tint n = nik.nextInt();\\n\\n\\t\\tStringBuilder st = new StringBuilder();\\n\\t\\t\\n\\t\\tint p1[] = new int[n + 1];\\n\\t\\t\\n\\t\\tfor (int i = 1; i <= n; i++) {\\n\\t\\t\\tp1[nik.nextInt()] = i;\\n\\t\\t}\\n\\t\\t\\n\\t\\tint p2[] = new int[n + 1];\\n\\t\\t\\n\\t\\tfor (int j = 1; j <= n; j++)\\n\\t\\t\\tp2[nik.nextInt()] = j;\\n\\t\\t\\n\\t\\tint res[] = new int[n + 1];\\n\\t\\t\\n\\t\\t\\n\\t\\tfor (int i = 1; i <= n; i++) {\\n\\t\\t\\tint idx1 = p1[i], idx2 = p2[i];\\n\\t\\t\\tif (idx1 <= idx2) {\\n\\t\\t\\t\\tres[idx2 - idx1]++;\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tres[n - (idx1 - idx2)]++;\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\tint max = 0;\\n\\t\\tfor (int v : res)\\n\\t\\t\\tmax = Math.max(max, v);\\n\\n\\t\\tSystem.out.println(max);\\n\\n\\t}\\n\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"You have a string s and a chip, which you can place onto any character of this string. \\n\\nAfter placing the chip, you move it to the right several (maybe zero) times, i. e. you perform the following operation several times: if the current position of the chip is i, you move it to the position i + 1. Of course, moving the chip to the right is impossible if it is already in the last position.\\n\\nAfter moving the chip to the right, you move it to the left several (maybe zero) times, i. e. you perform the following operation several times: if the current position of the chip is i, you move it to the position i - 1. Of course, moving the chip to the left is impossible if it is already in the first position.\\n\\nWhen you place a chip or move it, you write down the character where the chip ends up after your action. For example, if s is abcdef, you place the chip onto the 3-rd character, move it to the right 2 times and then move it to the left 3 times, you write down the string cdedcb.\\n\\nYou are given two strings s and t. Your task is to determine whether it's possible to perform the described operations with s so that you write down the string t as a result.\\n\\nInput\\n\\nThe first line contains one integer q (1 ≤ q ≤ 500) — the number of test cases.\\n\\nEach test case consists of two lines. The first line contains the string s (1 ≤ |s| ≤ 500), the second line contains the string t (1 ≤ |t| ≤ 2 ⋅ |s| - 1). Both strings consist of lowercase English characters.\\n\\nIt is guaranteed that the sum of |s| over all test cases does not exceed 500.\\n\\nOutput\\n\\nFor each test case, print \\\"YES\\\" if you can obtain the string t by performing the process mentioned in the statement with the string s, or \\\"NO\\\" if you cannot.\\n\\nYou may print each letter in any case (YES, yes, Yes will all be recognized as positive answer, NO, no and nO will all be recognized as negative answer).\\n\\nExample\\n\\nInput\\n\\n\\n6\\nabcdef\\ncdedcb\\naaa\\naaaaa\\naab\\nbaaa\\nab\\nb\\nabcdef\\nabcdef\\nba\\nbaa\\n\\n\\nOutput\\n\\n\\nYES\\nYES\\nNO\\nYES\\nYES\\nNO\\n\\nNote\\n\\nConsider the examples.\\n\\nThe first test case is described in...\\\":\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.util.StringTokenizer;\\npublic class B{\\n\\tpublic static void main(String[] args){\\n\\t\\tFastReader sc = new FastReader();\\n\\t\\tint t=sc.nextInt();\\n\\t\\ta:while(t-->0){\\n\\t\\t\\tString a=sc.nextLine();\\n\\t\\t\\tString b=sc.nextLine();\\n\\t\\t\\tchar c=b.charAt(0);\\n\\t\\t\\tfor(int i=0;i=0) x=new StringBuilder(a.subSequence(l,right)).reverse().toString();\\n\\t\\t\\t\\t\\tif(x.compareTo(b)==0) {\\n\\t\\t\\t\\t\\t\\tSystem.out.println(\\\"yes\\\");\\n\\t\\t\\t\\t\\t\\tcontinue a;\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\tint left=0;boolean check=false; boolean found=true;\\n\\t\\t\\t\\t\\tfor(int j=1;j=0)rev=new StringBuilder(a.substring(l,right+1)).reverse().toString();\\n\\t\\t\\t\\t\\t\\t\\tif(r.compareTo(rev)==0) {\\n\\t\\t\\t\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\tright++;\\n\\t\\t\\t\\t\\t\\t}else if(left>=0 && a.charAt(left)==b.charAt(j)) {\\n\\t\\t\\t\\t\\t\\t\\tcheck=true;\\n\\t\\t\\t\\t\\t\\t\\tleft--;\\n\\t\\t\\t\\t\\t\\t}else {\\n\\t\\t\\t\\t\\t\\t\\tfound=false;\\n\\t\\t\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\tif(found) {\\n\\t\\t\\t\\t\\t\\tSystem.out.println(\\\"yes\\\");\\n\\t\\t\\t\\t\\t\\tcontinue a;\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\tSystem.out.println(\\\"no\\\");\\n\\t\\t}\\t\\t\\n\\t}\\n\\tstatic class ind {\\n\\t\\tint x;int y;\\n\\t\\t ind(int x,int y){\\n\\t\\t\\tthis.x=x;\\n\\t\\t\\tthis.y=y;\\n\\t\\t}\\n\\t\\t\\n\\t}\\n\\tstatic class FastReader {\\n\\t\\tBufferedReader br;\\n\\t\\tStringTokenizer st;\\n\\n\\t\\tpublic FastReader()\\n\\t\\t{\\n\\t\\t\\tbr = new BufferedReader(\\n\\t\\t\\t\\tnew InputStreamReader(System.in));\\n\\t\\t}\\n\\n\\t\\tString next()\\n\\t\\t{\\n\\t\\t\\twhile (st == null || !st.hasMoreElements()) {\\n\\t\\t\\t\\ttry {\\n\\t\\t\\t\\t\\tst = new StringTokenizer(br.readLine());\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tcatch (IOException e) {\\n\\t\\t\\t\\t\\te.printStackTrace();\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\treturn st.nextToken();\\n\\t\\t}\\n\\n\\t\\tint nextInt() { return Integer.parseInt(next()); }\\n\\n\\t\\tlong nextLong() { return Long.parseLong(next()); }\\n\\n\\t\\tdouble nextDouble()\\n\\t\\t{\\n\\t\\t\\treturn Double.parseDouble(next());\\n\\t\\t}\\n\\n\\t\\tString...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"\\n\\nWilliam has two arrays a and b, each consisting of n items.\\n\\nFor some segments l..r of these arrays William wants to know if it is possible to equalize the values of items in these segments using a balancing operation. Formally, the values are equalized if for each i from l to r holds a_i = b_i.\\n\\nTo perform a balancing operation an even number of indices must be selected, such that l ≤ pos_1 < pos_2 < ... < pos_k ≤ r. Next the items of array a at positions pos_1, pos_3, pos_5, ... get incremented by one and the items of array b at positions pos_2, pos_4, pos_6, ... get incremented by one.\\n\\nWilliam wants to find out if it is possible to equalize the values of elements in two arrays for each segment using some number of balancing operations, and what is the minimal number of operations required for that. Note that for each segment the operations are performed independently.\\n\\nInput\\n\\nThe first line contains a two integers n and q (2 ≤ n ≤ 10^5, 1 ≤ q ≤ 10^5), the size of arrays a and b and the number of segments.\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (0 ≤ a_i ≤ 10^9).\\n\\nThe third line contains n integers b_1, b_2, ..., b_n (0 ≤ b_i ≤ 10^9).\\n\\nEach of the next q lines contains two integers l_i and r_i (1 ≤ l_i < r_i ≤ n), the edges of segments.\\n\\nOutput\\n\\nFor each segment output a single number — the minimal number of balancing operations needed or \\\"-1\\\" if it is impossible to equalize segments of arrays.\\n\\nExample\\n\\nInput\\n\\n\\n8 5\\n0 1 2 9 3 2 7 5\\n2 2 1 9 4 1 5 8\\n2 6\\n1 7\\n2 4\\n7 8\\n5 8\\n\\n\\nOutput\\n\\n\\n1\\n3\\n1\\n-1\\n-1\\n\\nNote\\n\\nFor the first segment from 2 to 6 you can do one operation with pos = [2, 3, 5, 6], after this operation the arrays will be: a = [0, 2, 2, 9, 4, 2, 7, 5], b = [2, 2, 2, 9, 4, 2, 5, 8]. Arrays are equal on a segment from 2 to 6 after this operation.\\n\\nFor the second segment from 1 to 7 you can do three following operations: \\n\\n 1. pos = [1, 3, 5, 6] \\n 2. pos = [1, 7] \\n 3. pos = [2, 7] \\n\\n\\n\\nAfter these operations, the arrays will be: a = [2, 2, 2, 9, 4, 2, 7, 5], b = [2, 2, 2, 9, 4, 2, 7,...\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nlong long tree1[500000];\\nlong long tree2[500000];\\nvoid build_max(int now, int l, int r, vector& a) {\\n if (l == r) {\\n tree1[now] = a[l];\\n return;\\n }\\n int mid = (l + r) \\/ 2;\\n build_max(now * 2, l, mid, a);\\n build_max(now * 2 + 1, mid + 1, r, a);\\n tree1[now] = max(tree1[now * 2], tree1[now * 2 + 1]);\\n}\\nlong long get_max(int now, int l, int r, int l1, int r1) {\\n if (l1 > r || l > r1) {\\n return -100000000000000000ll;\\n }\\n if (l1 <= l && r <= r1) {\\n return tree1[now];\\n }\\n int mid = (l + r) \\/ 2;\\n return max(get_max(now * 2, l, mid, l1, r1),\\n get_max(now * 2 + 1, mid + 1, r, l1, r1));\\n}\\nvoid build_min(int now, int l, int r, vector& a) {\\n if (l == r) {\\n tree2[now] = a[l];\\n return;\\n }\\n int mid = (l + r) \\/ 2;\\n build_min(now * 2, l, mid, a);\\n build_min(now * 2 + 1, mid + 1, r, a);\\n tree2[now] = min(tree2[now * 2], tree2[now * 2 + 1]);\\n}\\nlong long get_min(int now, int l, int r, int l1, int r1) {\\n if (l1 > r || l > r1) {\\n return 100000000000000000ll;\\n }\\n if (l1 <= l && r <= r1) {\\n return tree2[now];\\n }\\n int mid = (l + r) \\/ 2;\\n return min(get_min(now * 2, l, mid, l1, r1),\\n get_min(now * 2 + 1, mid + 1, r, l1, r1));\\n}\\nint sign(int i) {\\n if (i > 0) {\\n return 1;\\n }\\n if (i < 0) {\\n return -1;\\n }\\n return 0;\\n}\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n int n, q;\\n cin >> n >> q;\\n vector a(n), b(n);\\n for (int i = 0; i < n; i++) {\\n cin >> a[i];\\n }\\n for (int i = 0; i < n; i++) {\\n cin >> b[i];\\n }\\n vector sum1(n + 1), sum2(n + 1);\\n vector get_next(n);\\n int prev = n;\\n for (int i = n - 1; i >= 0; i--) {\\n get_next[i] = prev;\\n if (i == 0 || sign(a[i] - b[i]) != sign(a[i - 1] - b[i - 1])) {\\n prev = i;\\n }\\n }\\n for (int i = 1; i <= n; i++) {\\n sum1[i] = sum1[i - 1] + a[i - 1];\\n sum2[i] = sum2[i - 1] + b[i - 1];\\n }\\n vector allfir(n + 1);\\n for (int i = 1; i <= n; i++) {\\n allfir[i] = allfir[i -...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"On a circle lie 2n distinct points, with the following property: however you choose 3 chords that connect 3 disjoint pairs of points, no point strictly inside the circle belongs to all 3 chords. The points are numbered 1, 2, ..., 2n in clockwise order.\\n\\nInitially, k chords connect k pairs of points, in such a way that all the 2k endpoints of these chords are distinct.\\n\\nYou want to draw n - k additional chords that connect the remaining 2(n - k) points (each point must be an endpoint of exactly one chord).\\n\\nIn the end, let x be the total number of intersections among all n chords. Compute the maximum value that x can attain if you choose the n - k chords optimally.\\n\\nNote that the exact position of the 2n points is not relevant, as long as the property stated in the first paragraph holds.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. Then t test cases follow.\\n\\nThe first line of each test case contains two integers n and k (1 ≤ n ≤ 100, 0 ≤ k ≤ n) — half the number of points and the number of chords initially drawn.\\n\\nThen k lines follow. The i-th of them contains two integers x_i and y_i (1 ≤ x_i, y_i ≤ 2n, x_i ≠ y_i) — the endpoints of the i-th chord. It is guaranteed that the 2k numbers x_1, y_1, x_2, y_2, ..., x_k, y_k are all distinct.\\n\\nOutput\\n\\nFor each test case, output the maximum number of intersections that can be obtained by drawing n - k additional chords.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n4 2\\n8 2\\n1 5\\n1 1\\n2 1\\n2 0\\n10 6\\n14 6\\n2 20\\n9 10\\n13 18\\n15 12\\n11 7\\n\\n\\nOutput\\n\\n\\n4\\n0\\n1\\n14\\n\\nNote\\n\\nIn the first test case, there are three ways to draw the 2 additional chords, shown below (black chords are the ones initially drawn, while red chords are the new ones):\\n\\n\\n\\nWe see that the third way gives the maximum number of intersections, namely 4.\\n\\nIn the second test case, there are no more chords to draw. Of course, with only one chord present there are no intersections.\\n\\nIn the third test case, we can make at most one intersection by drawing chords 1-3 and 2-4, as...\",\"targets\":\"\\/*\\n\\t\\t\\t\\tTO LEARN\\n\\t\\t\\t\\t1-segment trees\\n\\t\\t\\t\\t2-euler tour\\n\\t\\t\\t\\n\\t\\t\\t\\t*\\/\\n\\t\\t\\t\\t\\/*\\n\\t\\t\\t\\tTO SOLVE \\n\\t\\t\\t\\tuva 1103\\n\\t\\t\\t\\tcodeforces 722 kavi on pairing duty\\n\\t\\t\\t\\t*\\/\\n\\t\\t\\t\\t\\/*\\n\\t\\t\\t\\tbit manipulation shit\\n\\t\\t\\t\\t1-Computer Systems: A Programmer's Perspective\\n\\t\\t\\t\\t2-hacker's delight\\n\\t\\t\\t\\t3-(02-03-bits-ints)\\n\\t\\t\\t\\t4-machine-basics\\n\\t\\t\\t\\t5-Bits Manipulation tutorialspoint\\n\\t\\t\\t\\t*\\/\\n\\t\\t\\t\\t\\/*\\n\\t\\t\\t\\tTO WATCH\\n\\t\\t\\t\\t1-what is bitmasking by kartik arora youtube\\n\\t\\t\\t\\t*\\/\\n\\t\\t\\t\\t import java.util.*;\\n\\t\\t\\t\\t\\t\\t import java.math.*;\\n\\t\\t\\t\\t\\t\\t import java.io.*; \\n\\t\\t\\t\\t\\t\\t import java.util.stream.Collectors;\\n\\n\\t\\t\\t\\t\\t\\t public class A{\\n\\t\\t\\t\\t\\t\\t \\n\\t\\t\\t\\t\\t\\t static InputStream inputStream = System.in;\\n\\t\\t\\t\\t static FastScanner scan=new FastScanner();\\n\\t\\t\\t\\t\\t\\t public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));\\n\\tstatic void brute(long arr1[],long arr2[],long arr3[])\\n\\t{\\n\\t\\tfor(int i=0;iset2=new TreeSet();\\n\\t\\tTreeSetset3=new TreeSet();\\n\\t\\tfor(int i=0;i\\n\\nWe can add an edge (2, 4).\\n\\n\\\":\",\"targets\":\"# A efficient standard implementation of Unoin Find, based on rank optimization and path compression\\n#------------------------------- Unoin Find -------------------------------#\\nclass UnoinFind(object):\\n def __init__(self, n):\\n \\\"\\\"\\\"Define the Unoin Find:\\n findset findset index correspond to the root node\\n rank Each root node in the rank corresponds to the height of the tree\\n \\\"\\\"\\\"\\n self.__findset = [i for i in range(n + 1)]\\n self.__rank = [1 for i in range(n + 1)]\\n \\n def find(self, x):\\n \\\"\\\"\\\"Find the root node of node x based on path compression\\\"\\\"\\\"\\n if self.__findset[x] != x:\\n self.__findset[x] = self.find(self.__findset[x])\\n return self.__findset[x]\\n \\n def union(self, p, q):\\n \\\"\\\"\\\"Connect nodes P and Q based on heuristic merging\\\"\\\"\\\"\\n p_root = self.find(p)\\n q_root = self.find(q)\\n if self.__rank[p_root] < self.__rank[q_root]:\\n self.__findset[p_root] = q_root\\n elif self.__rank[p_root] > self.__rank[q_root]:\\n self.__findset[q_root] = p_root\\n else:\\n self.__findset[p_root] = q_root\\n self.__rank[q_root] += 1\\n \\n def is_connected(self, p, q):\\n \\\"\\\"\\\"Determine whether nodes P and q are connected\\\"\\\"\\\"\\n if self.find(p) == self.find(q):\\n return True\\n return False\\n \\n#------------------------------- Class End -------------------------------#\\n \\nn, m1, m2 = map(int, input().split())\\nU1 = UnoinFind(n)\\nU2 = UnoinFind(n)\\nfor _ in range(m1):\\n u, v = map(int, input().split())\\n U1.union(u, v)\\nfor _ in range(m2):\\n u, v = map(int, input().split())\\n U2.union(u, v)\\n \\nans = []\\nstack1 = []\\nstack2 = []\\nfor i in range(2, n + 1):\\n flag1 = U1.is_connected(1, i)\\n flag2 = U2.is_connected(1, i)\\n if not (flag1 or flag2):\\n ans.append((1, i))\\n U1.union(1, i)\\n U2.union(1, i)\\n elif flag1:\\n stack1.append(i)\\n elif flag2:\\n stack2.append(i)\\n \\nwhile stack1 != [] and stack2 != []:\\n if...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nYou are given a string s, consisting of n letters, each letter is either 'a' or 'b'. The letters in the string are numbered from 1 to n.\\n\\ns[l; r] is a continuous substring of letters from index l to r of the string inclusive. \\n\\nA string is called balanced if the number of letters 'a' in it is equal to the number of letters 'b'. For example, strings \\\"baba\\\" and \\\"aabbab\\\" are balanced and strings \\\"aaab\\\" and \\\"b\\\" are not.\\n\\nFind any non-empty balanced substring s[l; r] of string s. Print its l and r (1 ≤ l ≤ r ≤ n). If there is no such substring, then print -1 -1.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of testcases.\\n\\nThen the descriptions of t testcases follow.\\n\\nThe first line of the testcase contains a single integer n (1 ≤ n ≤ 50) — the length of the string.\\n\\nThe second line of the testcase contains a string s, consisting of n letters, each letter is either 'a' or 'b'.\\n\\nOutput\\n\\nFor each testcase print two integers. If there exists a non-empty balanced substring s[l; r], then print l r (1 ≤ l ≤ r ≤ n). Otherwise, print -1 -1.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n1\\na\\n6\\nabbaba\\n6\\nabbaba\\n9\\nbabbabbaa\\n\\n\\nOutput\\n\\n\\n-1 -1\\n1 6\\n3 6\\n2 5\\n\\nNote\\n\\nIn the first testcase there are no non-empty balanced subtrings.\\n\\nIn the second and third testcases there are multiple balanced substrings, including the entire string \\\"abbaba\\\" and substring \\\"baba\\\".\",\"targets\":\"import java.util.Scanner;\\n\\npublic class BalancedSubstring {\\n\\n\\tpublic static void main(String[] args) {\\n\\t\\tScanner sc = new Scanner(System.in);\\n\\t int t = sc.nextInt();\\n\\t\\n\\t for(int j=0 ;j=1 && a==b)\\n\\t\\t\\t {\\n\\t\\t\\t \\tl=1;\\n\\t\\t\\t \\tr=i;\\n\\t\\t\\t \\tbreak;\\n\\t\\t\\t }\\n\\t\\t else if(s.charAt(i)=='a' && s.charAt(j1)=='b' )\\n\\t \\t{\\n\\t \\t\\tl=i+1;\\n\\t \\t\\tr=j1+1;\\n\\t \\t\\tbreak;\\n\\t \\t}\\n\\t \\t\\n\\t \\telse if(s.charAt(i)=='b' && s.charAt(j1)=='a')\\n\\t \\t{\\n\\t \\t\\tl=i+1;\\n\\t \\t\\tr=j1+1;\\n\\t \\t\\tbreak;\\n\\t \\t}\\n\\t \\t\\n\\t \\n\\t \\n\\t \\t\\n\\t }\\n\\n\\t \\n\\t if(l==0)\\n\\t \\tSystem.out.println(\\\"-1 -1\\\");\\n\\t else \\n\\t \\tSystem.out.println(l+\\\" \\\"+r);\\n\\t \\n\\t \\n\\t\\n\\t \\n\\t \\n\\t }\\n\\t}\\n\\n\\t}\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"You are given n lengths of segments that need to be placed on an infinite axis with coordinates.\\n\\nThe first segment is placed on the axis so that one of its endpoints lies at the point with coordinate 0. Let's call this endpoint the \\\"start\\\" of the first segment and let's call its \\\"end\\\" as that endpoint that is not the start. \\n\\nThe \\\"start\\\" of each following segment must coincide with the \\\"end\\\" of the previous one. Thus, if the length of the next segment is d and the \\\"end\\\" of the previous one has the coordinate x, the segment can be placed either on the coordinates [x-d, x], and then the coordinate of its \\\"end\\\" is x - d, or on the coordinates [x, x+d], in which case its \\\"end\\\" coordinate is x + d.\\n\\nThe total coverage of the axis by these segments is defined as their overall union which is basically the set of points covered by at least one of the segments. It's easy to show that the coverage will also be a segment on the axis. Determine the minimal possible length of the coverage that can be obtained by placing all the segments on the axis without changing their order.\\n\\nInput\\n\\nThe first line contains an integer t (1 ≤ t ≤ 1000) — the number of test cases.\\n\\nThe next 2t lines contain descriptions of the test cases. \\n\\nThe first line of each test case description contains an integer n (1 ≤ n ≤ 10^4) — the number of segments. The second line of the description contains n space-separated integers a_i (1 ≤ a_i ≤ 1000) — lengths of the segments in the same order they should be placed on the axis.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 10^4.\\n\\nOutput\\n\\nPrint t lines, each line containing the answer to the corresponding test case. The answer to a test case should be a single integer — the minimal possible length of the axis coverage.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n2\\n1 3\\n3\\n1 2 3\\n4\\n6 2 3 9\\n4\\n6 8 4 5\\n7\\n1 2 4 6 7 7 3\\n8\\n8 6 5 1 2 2 3 6\\n\\n\\nOutput\\n\\n\\n3\\n3\\n9\\n9\\n7\\n8\\n\\nNote\\n\\nIn the third sample test case the segments should be arranged as follows: [0, 6] → [4, 6] → [4, 7] → [-2, 7]. As you can see, the last segment...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nconst int maxn = 1e5 + 5;\\nconst int inf = 1e9;\\nint dp[2][2005], a[10005];\\nint main() {\\n int t;\\n cin >> t;\\n while (t--) {\\n memset(dp, 0x3f, sizeof dp);\\n int n;\\n cin >> n;\\n for (int i = 1; i <= n; i++) {\\n cin >> a[i];\\n }\\n int now = 0;\\n dp[0][a[1]] = 0;\\n dp[0][0] = a[1];\\n for (int i = 2; i <= n; now ^= 1, i++) {\\n memset(dp[1 - now], 0x3f, sizeof dp[1 - now]);\\n for (int j = 0; j <= 2000; j++) {\\n if (j + a[i] <= 2000)\\n dp[1 - now][j + a[i]] =\\n min(dp[1 - now][j + a[i]], max(0, dp[now][j] - a[i]));\\n dp[1 - now][max(j - a[i], 0)] =\\n min(dp[1 - now][max(j - a[i], 0)], dp[now][j] + a[i]);\\n }\\n }\\n int ans = 2000000;\\n for (int j = 0; j <= 2000; j++) {\\n ans = min(ans, j + dp[now][j]);\\n }\\n cout << ans << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Finally Fox Ciel arrived in front of her castle!\\n\\nShe have to type a password to enter her castle. An input device attached to her castle is a bit unusual.\\n\\nThe input device is a 1 × n rectangle divided into n square panels. They are numbered 1 to n from left to right. Each panel has a state either ON or OFF. Initially all panels are in the OFF state. She can enter her castle if and only if x1-th, x2-th, ..., xk-th panels are in the ON state and other panels are in the OFF state.\\n\\nShe is given an array a1, ..., al. In each move, she can perform the following operation: choose an index i (1 ≤ i ≤ l), choose consecutive ai panels, and flip the states of those panels (i.e. ON → OFF, OFF → ON).\\n\\nUnfortunately she forgets how to type the password with only above operations. Determine the minimal number of operations required to enter her castle.\\n\\nInput\\n\\nThe first line contains three integers n, k and l (1 ≤ n ≤ 10000, 1 ≤ k ≤ 10, 1 ≤ l ≤ 100), separated by single spaces.\\n\\nThe second line contains k integers x1, ..., xk (1 ≤ x1 < x2 < ... < xk ≤ n), separated by single spaces.\\n\\nThe third line contains l integers a1, ..., al (1 ≤ ai ≤ n), separated by single spaces. It is possible that some elements of the array ai are equal value.\\n\\nOutput\\n\\nPrint the minimal number of moves required to type the password. If it's impossible, print -1.\\n\\nExamples\\n\\nInput\\n\\n10 8 2\\n1 2 3 5 6 7 8 9\\n3 5\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n3 2 1\\n1 2\\n3\\n\\n\\nOutput\\n\\n-1\\n\\nNote\\n\\nOne possible way to type the password in the first example is following: In the first move, choose 1st, 2nd, 3rd panels and flip those panels. In the second move, choose 5th, 6th, 7th, 8th, 9th panels and flip those panels.\\\":\",\"targets\":\"#include \\nusing namespace std;\\nconst int S = 21;\\nconst int N = 10005;\\nint n, m, t;\\nint f[1 << S], p[N], dis[N], a[N], b[N], q[N], c[S];\\nint g[S][S];\\nvoid bfs(int x) {\\n memset(dis, -1, sizeof dis);\\n int st = 0, ed = 1;\\n q[0] = x;\\n dis[x] = 0;\\n while (st < ed) {\\n int i = q[st++];\\n for (int j = 1; j <= t; ++j) {\\n if (i + p[j] <= n && dis[i + p[j]] == -1)\\n dis[i + p[j]] = dis[i] + 1, q[ed++] = i + p[j];\\n if (i - p[j] > 0 && dis[i - p[j]] == -1)\\n dis[i - p[j]] = dis[i] + 1, q[ed++] = i - p[j];\\n }\\n }\\n}\\nint main() {\\n scanf(\\\"%d%d%d\\\", &n, &m, &t);\\n ++n;\\n for (int i = 1; i <= m; ++i) {\\n int x;\\n scanf(\\\"%d\\\", &x);\\n a[x] ^= 1;\\n a[x + 1] ^= 1;\\n }\\n for (int i = 1; i <= t; ++i) scanf(\\\"%d\\\", &p[i]);\\n memset(b, -1, sizeof b);\\n int s = 0;\\n for (int i = 0; i <= n; ++i)\\n if (a[i]) c[s] = i, b[i] = s++;\\n for (int i = 0; i < s; ++i) {\\n bfs(c[i]);\\n for (int j = 0; j <= n; ++j)\\n if (b[j] >= 0) g[i][b[j]] = dis[j] >= 0 ? dis[j] : n * 20;\\n }\\n memset(f, 1, sizeof f);\\n f[0] = 0;\\n for (int i = 0; i + 1 < 1 << s; ++i)\\n if (f[i] < n * 20) {\\n int x;\\n for (int j = 0; j < s; ++j)\\n if ((i & 1 << j) == 0) {\\n x = j;\\n break;\\n }\\n for (int j = x + 1; j < s; ++j)\\n if ((i & 1 << j) == 0 && f[i] + g[x][j] < f[i | 1 << x | 1 << j])\\n f[i | 1 << x | 1 << j] = f[i] + g[x][j];\\n }\\n printf(\\\"%d\\\\n\\\", f[(1 << s) - 1] < n * 20 ? f[(1 << s) - 1] : -1);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nYou are given an array consisting of all integers from [l, r] inclusive. For example, if l = 2 and r = 5, the array would be [2, 3, 4, 5]. What's the minimum number of elements you can delete to make the [bitwise AND](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#AND) of the array non-zero?\\n\\nA bitwise AND is a binary operation that takes two equal-length binary representations and performs the AND operation on each pair of the corresponding bits.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10^4) — the number of test cases. Then t cases follow.\\n\\nThe first line of each test case contains two integers l and r (1 ≤ l ≤ r ≤ 2 ⋅ 10^5) — the description of the array.\\n\\nOutput\\n\\nFor each test case, output a single integer — the answer to the problem.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n1 2\\n2 8\\n4 5\\n1 5\\n100000 200000\\n\\n\\nOutput\\n\\n\\n1\\n3\\n0\\n2\\n31072\\n\\nNote\\n\\nIn the first test case, the array is [1, 2]. Currently, the bitwise AND is 0, as 1\\\\ \\\\& \\\\ 2 = 0. However, after deleting 1 (or 2), the array becomes [2] (or [1]), and the bitwise AND becomes 2 (or 1). This can be proven to be the optimal, so the answer is 1.\\n\\nIn the second test case, the array is [2, 3, 4, 5, 6, 7, 8]. Currently, the bitwise AND is 0. However, after deleting 4, 5, and 8, the array becomes [2, 3, 6, 7], and the bitwise AND becomes 2. This can be proven to be the optimal, so the answer is 3. Note that there may be other ways to delete 3 elements.\",\"targets\":\"#include \\nusing namespace std;\\nint a[20][200005];\\nvoid solve() {\\n int l, r;\\n cin >> l >> r;\\n int maxi = 0;\\n for (int i = 0; i < 20; i++) maxi = max(maxi, a[i][r] - a[i][l - 1]);\\n cout << (r - l + 1) - maxi << \\\"\\\\n\\\";\\n}\\nint main() {\\n ios::sync_with_stdio(0);\\n cin.tie(0);\\n int t;\\n cin >> t;\\n for (int i = 1; i <= 200000; i++) {\\n for (int j = 0; j < 20; j++) {\\n a[j][i] += a[j][i - 1];\\n if ((i >> j) & 1) a[j][i]++;\\n }\\n }\\n while (t--) solve();\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A new airplane SuperPuperJet has an infinite number of rows, numbered with positive integers starting with 1 from cockpit to tail. There are six seats in each row, denoted with letters from 'a' to 'f'. Seats 'a', 'b' and 'c' are located to the left of an aisle (if one looks in the direction of the cockpit), while seats 'd', 'e' and 'f' are located to the right. Seats 'a' and 'f' are located near the windows, while seats 'c' and 'd' are located near the aisle. \\n\\n\\n\\nIt's lunch time and two flight attendants have just started to serve food. They move from the first rows to the tail, always maintaining a distance of two rows from each other because of the food trolley. Thus, at the beginning the first attendant serves row 1 while the second attendant serves row 3. When both rows are done they move one row forward: the first attendant serves row 2 while the second attendant serves row 4. Then they move three rows forward and the first attendant serves row 5 while the second attendant serves row 7. Then they move one row forward again and so on.\\n\\nFlight attendants work with the same speed: it takes exactly 1 second to serve one passenger and 1 second to move one row forward. Each attendant first serves the passengers on the seats to the right of the aisle and then serves passengers on the seats to the left of the aisle (if one looks in the direction of the cockpit). Moreover, they always serve passengers in order from the window to the aisle. Thus, the first passenger to receive food in each row is located in seat 'f', and the last one — in seat 'c'. Assume that all seats are occupied.\\n\\nVasya has seat s in row n and wants to know how many seconds will pass before he gets his lunch.\\n\\nInput\\n\\nThe only line of input contains a description of Vasya's seat in the format ns, where n (1 ≤ n ≤ 1018) is the index of the row and s is the seat in this row, denoted as letter from 'a' to 'f'. The index of the row and the seat are not separated by a space.\\n\\nOutput\\n\\nPrint one integer — the number of seconds Vasya has to wait...\",\"targets\":\"# your code goes here\\nstrn=input()\\nn=int(strn[:-1])\\nseat=strn[len(strn)-1]\\ndict1={'f':1,'e':2,'d':3,'c':6,'b':5,'a':4}\\nsum=0\\ntemp=(n-1)\\/\\/4\\nsum+=(temp*16)\\nif n%2==0:\\n\\tsum+=7\\nsum+=dict1[seat]\\nprint(sum)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given a sequence of n integers a_1, a_2, ..., a_n.\\n\\nDoes there exist a sequence of n integers b_1, b_2, ..., b_n such that the following property holds?\\n\\n * For each 1 ≤ i ≤ n, there exist two (not necessarily distinct) indices j and k (1 ≤ j, k ≤ n) such that a_i = b_j - b_k. \\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 20) — the number of test cases. Then t test cases follow.\\n\\nThe first line of each test case contains one integer n (1 ≤ n ≤ 10).\\n\\nThe second line of each test case contains the n integers a_1, ..., a_n (-10^5 ≤ a_i ≤ 10^5).\\n\\nOutput\\n\\nFor each test case, output a line containing YES if a sequence b_1, ..., b_n satisfying the required property exists, and NO otherwise.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n5\\n4 -7 -1 5 10\\n1\\n0\\n3\\n1 10 100\\n4\\n-3 2 10 2\\n9\\n25 -171 250 174 152 242 100 -205 -258\\n\\n\\nOutput\\n\\n\\nYES\\nYES\\nNO\\nYES\\nYES\\n\\nNote\\n\\nIn the first test case, the sequence b = [-9, 2, 1, 3, -2] satisfies the property. Indeed, the following holds: \\n\\n * a_1 = 4 = 2 - (-2) = b_2 - b_5; \\n * a_2 = -7 = -9 - (-2) = b_1 - b_5; \\n * a_3 = -1 = 1 - 2 = b_3 - b_2; \\n * a_4 = 5 = 3 - (-2) = b_4 - b_5; \\n * a_5 = 10 = 1 - (-9) = b_3 - b_1. \\n\\n\\n\\nIn the second test case, it is sufficient to choose b = [0], since a_1 = 0 = 0 - 0 = b_1 - b_1.\\n\\nIn the third test case, it is possible to show that no sequence b of length 3 satisfies the property.\\nSolve the task in PYTHON.\",\"targets\":\"from collections import Counter, defaultdict, deque\\nimport bisect\\nfrom sys import stdin, stdout\\nfrom itertools import repeat, permutations\\nimport math\\nimport heapq\\n\\nMOD = 998244353\\ndef inp(force_list=False):\\n re = map(int, raw_input().split())\\n if len(re) == 1 and not force_list:\\n return re[0]\\n return re\\n\\ndef inpf(force_list=False):\\n re = map(float, raw_input().split())\\n if len(re) == 1 and not force_list:\\n return re[0]\\n return re\\n\\ndef inst():\\n return raw_input().strip()\\n\\ndef gcd(x, y):\\n while(y):\\n x, y = y, x % y\\n return x\\n\\ndef lcm(x, y):\\n return x*y\\/(gcd(x,y))\\n\\ndef qmod(a, b, mod=MOD):\\n res = 1\\n while b:\\n if b&1:\\n res = (res*a)%mod\\n b >>= 1\\n a = (a*a)%mod\\n # print b\\n return res\\n\\ndef inv(a):\\n return qmod(a, MOD-2)\\n\\ndef query(num):\\n print num\\n stdout.flush()\\n return inp()\\n\\ndef my_main():\\n kase = inp()\\n pans = []\\n cur = []\\n for _ in range(kase):\\n n = inp()\\n da = inp(True)\\n ok = 0\\n for i in xrange(1, 3**n):\\n if ok:\\n break\\n sum = 0\\n for j in range(n):\\n st = i%3\\n i \\/= 3\\n if st==1:\\n sum += da[j]\\n elif st==2:\\n sum -= da[j]\\n if sum==0:\\n ok = 1\\n break\\n pans.append(\\\"YES\\\" if ok else \\\"NO\\\")\\n\\n print '\\\\n'.join(pans)\\n\\n\\nmy_main()\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 solution for \\\"A bow adorned with nameless flowers that bears the earnest hopes of an equally nameless person.\\n\\nYou have obtained the elegant bow known as the Windblume Ode. Inscribed in the weapon is an array of n (n ≥ 3) positive distinct integers (i.e. different, no duplicates are allowed).\\n\\nFind the largest subset (i.e. having the maximum number of elements) of this array such that its sum is a composite number. A positive integer x is called composite if there exists a positive integer y such that 1 < y < x and x is divisible by y.\\n\\nIf there are multiple subsets with this largest size with the composite sum, you can output any of them. It can be proven that under the constraints of the problem such a non-empty subset always exists.\\n\\nInput\\n\\nEach test consists of multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 100). Description of the test cases follows.\\n\\nThe first line of each test case contains an integer n (3 ≤ n ≤ 100) — the length of the array.\\n\\nThe second line of each test case contains n distinct integers a_{1},a_{2},...,a_{n} (1 ≤ a_{i} ≤ 200) — the elements of the array.\\n\\nOutput\\n\\nEach test case should have two lines of output.\\n\\nThe first line should contain a single integer x: the size of the largest subset with composite sum. The next line should contain x space separated integers representing the indices of the subset of the initial array.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n8 1 2\\n4\\n6 9 4 2\\n9\\n1 2 3 4 5 6 7 8 9\\n3\\n200 199 198\\n\\n\\nOutput\\n\\n\\n2\\n2 1\\n4\\n2 1 4 3\\n9\\n6 9 1 2 3 4 5 7 8\\n3\\n1 2 3 \\n\\nNote\\n\\nIn the first test case, the subset \\\\\\\\{a_2, a_1\\\\} has a sum of 9, which is a composite number. The only subset of size 3 has a prime sum equal to 11. Note that you could also have selected the subset \\\\\\\\{a_1, a_3\\\\} with sum 8 + 2 = 10, which is composite as it's divisible by 2.\\n\\nIn the second test case, the sum of all elements equals to 21, which is a composite number. Here we simply take the whole array as our subset.\\\":\",\"targets\":\"import os, sys\\nfrom io import BytesIO, IOBase\\nfrom math import log2, ceil, sqrt, gcd\\nfrom _collections import deque\\nimport heapq as hp\\nfrom bisect import bisect_left, bisect_right\\nfrom math import cos, sin\\nfrom itertools import permutations\\nfrom operator import itemgetter\\n\\n# sys.setrecursionlimit(2*10**5+10000)\\nBUFSIZE = 8192\\n\\n\\nclass FastIO(IOBase):\\n newlines = 0\\n\\n def __init__(self, file):\\n self._fd = file.fileno()\\n self.buffer = BytesIO()\\n self.writable = \\\"x\\\" in file.mode or \\\"r\\\" not in file.mode\\n self.write = self.buffer.write if self.writable else None\\n\\n def read(self):\\n while True:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n if not b:\\n break\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines = 0\\n return self.buffer.read()\\n\\n def readline(self):\\n while self.newlines == 0:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n self.newlines = b.count(b\\\"\\\\n\\\") + (not b)\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines -= 1\\n return self.buffer.readline()\\n\\n def flush(self):\\n if self.writable:\\n os.write(self._fd, self.buffer.getvalue())\\n self.buffer.truncate(0), self.buffer.seek(0)\\n\\n\\nclass IOWrapper(IOBase):\\n def __init__(self, file):\\n self.buffer = FastIO(file)\\n self.flush = self.buffer.flush\\n self.writable = self.buffer.writable\\n self.write = lambda s: self.buffer.write(s.encode(\\\"ascii\\\"))\\n self.read = lambda: self.buffer.read().decode(\\\"ascii\\\")\\n self.readline = lambda: self.buffer.readline().decode(\\\"ascii\\\")\\n\\n\\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\\ninput = lambda: sys.stdin.readline().rstrip(\\\"\\\\r\\\\n\\\")\\n\\nbd = 1000001\\nar = [1] * (bd + 1)\\n\\nfor i in range(2, int(bd ** (1 \\/ 2)) + 1):\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nShe does her utmost to flawlessly carry out a person's last rites and preserve the world's balance of yin and yang.\\n\\nHu Tao, being the little prankster she is, has tried to scare you with this graph problem! You are given a connected undirected graph of n nodes with m edges. You also have q queries. Each query consists of two nodes a and b.\\n\\nInitially, all edges in the graph have a weight of 0. For each query, you must choose a simple path starting from a and ending at b. Then you add 1 to every edge along this path. Determine if it's possible, after processing all q queries, for all edges in this graph to have an even weight. If so, output the choice of paths for each query. \\n\\nIf it is not possible, determine the smallest number of extra queries you could add to make it possible. It can be shown that this number will not exceed 10^{18} under the given constraints.\\n\\nA simple path is defined as any path that does not visit a node more than once.\\n\\nAn edge is said to have an even weight if its value is divisible by 2.\\n\\nInput\\n\\nThe first line contains two integers n and m (2 ≤ n ≤ 3 ⋅ 10^5, n-1 ≤ m ≤ min{\\\\left((n(n-1))\\/(2), 3 ⋅ 10^5\\\\right)}).\\n\\nEach of the next m lines contains two integers x and y (1 ≤ x, y ≤ n, x≠ y) indicating an undirected edge between node x and y. The input will not contain self-loops or duplicate edges, and the provided graph will be connected.\\n\\nThe next line contains a single integer q (1 ≤ q ≤ 3 ⋅ 10^5).\\n\\nEach of the next q lines contains two integers a and b (1 ≤ a, b ≤ n, a ≠ b), the description of each query.\\n\\nIt is guaranteed that nq ≤ 3 ⋅ 10^5.\\n\\nOutput\\n\\nIf it is possible to force all edge weights to be even, print \\\"YES\\\" on the first line, followed by 2q lines indicating the choice of path for each query in the same order the queries are given. For each query, the first line should contain a single integer x: the number of nodes in the chosen path. The next line should then contain x spaced separated integers p_i indicating the path you take (p_1 = a, p_x = b and all numbers should...\",\"targets\":\"#include \\nusing namespace std;\\nconst int MAXN = 300005;\\nint n, m, q;\\nint cnt;\\nint u, v;\\nint c[MAXN], d[MAXN];\\nint tot[MAXN], sum;\\nint vis[MAXN];\\nint dep[MAXN], fa[MAXN];\\nint f[MAXN][21];\\nstack s;\\nstruct Node {\\n int v;\\n Node *next;\\n} * h[MAXN], pool[MAXN * 2];\\nvoid Adde(int u, int v) {\\n Node *p = &pool[++cnt];\\n p->v = v;\\n p->next = h[u];\\n h[u] = p;\\n}\\nvoid Dfs(int u) {\\n vis[u] = 1;\\n dep[u] = dep[fa[u]] + 1;\\n for (Node *p = h[u]; p; p = p->next) {\\n if (vis[p->v] == 0) {\\n fa[p->v] = u;\\n Dfs(p->v);\\n }\\n }\\n}\\nint Ask(int u, int v) {\\n if (dep[u] < dep[v]) swap(u, v);\\n for (int i = 20; i >= 0; --i)\\n if (dep[f[u][i]] >= dep[v]) u = f[u][i];\\n if (u == v) return u;\\n for (int i = 20; i >= 0; --i)\\n if (f[u][i] != f[v][i]) u = f[u][i], v = f[v][i];\\n return fa[u];\\n}\\nint main() {\\n scanf(\\\"%d%d\\\", &n, &m);\\n for (int i = 1; i <= m; ++i) {\\n scanf(\\\"%d%d\\\", &u, &v);\\n Adde(u, v);\\n Adde(v, u);\\n }\\n scanf(\\\"%d\\\", &q);\\n for (int i = 1; i <= q; ++i) {\\n scanf(\\\"%d%d\\\", &c[i], &d[i]);\\n tot[c[i]]++;\\n tot[d[i]]++;\\n }\\n for (int i = 1; i <= n; ++i) sum += (tot[i] % 2);\\n if (sum) {\\n printf(\\\"No\\\\n%d\\\\n\\\", sum \\/ 2);\\n return 0;\\n }\\n printf(\\\"Yes\\\\n\\\");\\n Dfs(1);\\n for (int i = 1; i <= n; ++i) f[i][0] = fa[i];\\n for (int i = 1; i <= 20; ++i)\\n for (int j = 1; j <= n; ++j) f[j][i] = f[f[j][i - 1]][i - 1];\\n for (int i = 1; i <= q; ++i) {\\n int lca = Ask(c[i], d[i]);\\n printf(\\\"%d\\\\n\\\", dep[c[i]] - dep[lca] + dep[d[i]] - dep[lca] + 1);\\n while (c[i] != lca) {\\n printf(\\\"%d \\\", c[i]);\\n c[i] = fa[c[i]];\\n }\\n printf(\\\"%d \\\", lca);\\n while (d[i] != lca) {\\n s.push(d[i]);\\n d[i] = fa[d[i]];\\n }\\n while (!s.empty()) {\\n int ans = s.top();\\n s.pop();\\n printf(\\\"%d \\\", ans);\\n }\\n printf(\\\"\\\\n\\\");\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"This is an interactive problem!\\n\\nAs part of your contribution in the Great Bubble War, you have been tasked with finding the newly built enemy fortress. The world you live in is a giant 10^9 × 10^9 grid, with squares having both coordinates between 1 and 10^9. \\n\\nYou know that the enemy base has the shape of a rectangle, with the sides parallel to the sides of the grid. The people of your world are extremely scared of being at the edge of the world, so you know that the base doesn't contain any of the squares on the edges of the grid (the x or y coordinate being 1 or 10^9). \\n\\nTo help you locate the base, you have been given a device that you can place in any square of the grid, and it will tell you the manhattan distance to the closest square of the base. The manhattan distance from square (a, b) to square (p, q) is calculated as |a−p|+|b−q|. If you try to place the device inside the enemy base, you will be captured by the enemy. Because of this, you need to make sure to never place the device inside the enemy base. \\n\\nUnfortunately, the device is powered by a battery and you can't recharge it. This means that you can use the device at most 40 times. \\n\\nInput\\n\\nThe input contains the answers to your queries. \\n\\nInteraction\\n\\nYour code is allowed to place the device on any square in the grid by writing \\\"? i j\\\" (1 ≤ i,j ≤ 10^9). In return, it will recieve the manhattan distance to the closest square of the enemy base from square (i,j) or -1 if the square you placed the device on is inside the enemy base or outside the grid. \\n\\nIf you recieve -1 instead of a positive number, exit immidiately and you will see the wrong answer verdict. Otherwise, you can get an arbitrary verdict because your solution will continue to read from a closed stream.\\n\\nYour solution should use no more than 40 queries. \\n\\nOnce you are sure where the enemy base is located, you should print \\\"! x y p q\\\" (1 ≤ x ≤ p≤ 10^9, 1 ≤ y ≤ q≤ 10^9), where (x, y) is the square inside the enemy base with the smallest x and y coordinates, and (p, q) is the square...\\\":\",\"targets\":\"#include \\nconst int MAXN = 1e9;\\nint main() {\\n printf(\\\"? 1 1\\\\n\\\");\\n fflush(stdout);\\n int a, b, c, d;\\n scanf(\\\"%d\\\", &a);\\n printf(\\\"? 1 %d\\\\n\\\", MAXN);\\n fflush(stdout);\\n scanf(\\\"%d\\\", &b);\\n printf(\\\"? %d 1\\\\n\\\", MAXN);\\n fflush(stdout);\\n scanf(\\\"%d\\\", &c);\\n printf(\\\"? %d %d\\\\n\\\", MAXN, MAXN);\\n fflush(stdout);\\n scanf(\\\"%d\\\", &d);\\n int x, y, p, q;\\n int l = 1, r = 1e9 + 1, mid, t;\\n while (l + 1 < r) {\\n mid = (l + r) \\/ 2;\\n printf(\\\"? 1 %d\\\\n\\\", mid);\\n fflush(stdout);\\n scanf(\\\"%d\\\", &t);\\n if (mid - 1 == a - t)\\n l = mid;\\n else\\n r = mid;\\n }\\n printf(\\\"? 1 %d\\\\n\\\", l);\\n fflush(stdout);\\n scanf(\\\"%d\\\", &t);\\n x = t + 1;\\n y = a - t + 1;\\n q = 1e9 - b + x - 1;\\n p = 1e9 - c + y - 1;\\n printf(\\\"! %d %d %d %d\\\\n\\\", x, y, p, q);\\n fflush(stdout);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"This is the hard version of the problem. The only difference between the two versions is the constraint on n. You can make hacks only if all versions of the problem are solved.\\n\\nA forest is an undirected graph without cycles (not necessarily connected).\\n\\nMocha and Diana are friends in Zhijiang, both of them have a forest with nodes numbered from 1 to n, and they would like to add edges to their forests such that: \\n\\n * After adding edges, both of their graphs are still forests. \\n * They add the same edges. That is, if an edge (u, v) is added to Mocha's forest, then an edge (u, v) is added to Diana's forest, and vice versa. \\n\\n\\n\\nMocha and Diana want to know the maximum number of edges they can add, and which edges to add.\\n\\nInput\\n\\nThe first line contains three integers n, m_1 and m_2 (1 ≤ n ≤ 10^5, 0 ≤ m_1, m_2 < n) — the number of nodes and the number of initial edges in Mocha's forest and Diana's forest.\\n\\nEach of the next m_1 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the edges in Mocha's forest.\\n\\nEach of the next m_2 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the edges in Diana's forest.\\n\\nOutput\\n\\nThe first line contains only one integer h, the maximum number of edges Mocha and Diana can add.\\n\\nEach of the next h lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the edge you add each time.\\n\\nIf there are multiple correct answers, you can print any one of them.\\n\\nExamples\\n\\nInput\\n\\n\\n3 2 2\\n1 2\\n2 3\\n1 2\\n1 3\\n\\n\\nOutput\\n\\n\\n0\\n\\n\\nInput\\n\\n\\n5 3 2\\n5 4\\n2 1\\n4 3\\n4 3\\n1 4\\n\\n\\nOutput\\n\\n\\n1\\n2 4\\n\\n\\nInput\\n\\n\\n8 1 2\\n1 7\\n2 6\\n1 5\\n\\n\\nOutput\\n\\n\\n5\\n5 2\\n2 3\\n3 4\\n4 7\\n6 8\\n\\nNote\\n\\nIn the first example, we cannot add any edge.\\n\\nIn the second example, the initial forests are as follows.\\n\\n\\n\\nWe can add an edge (2, 4).\\n\\n\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nconst long long N = 1e5 + 10;\\nlong long ans[N][2];\\nlong long fa1[N], fa2[N], s1[N], s2[N];\\nlong long find(long long fa[], long long x) {\\n return x == fa[x] ? x : fa[x] = find(fa, fa[x]);\\n}\\nvoid merge(long long fa[], long long x, long long y) {\\n long long fx = find(fa, x);\\n long long fy = find(fa, y);\\n fa[fx] = fy;\\n}\\nvoid init(long long fa[], long long n) {\\n for (long long i = 1; i <= n; ++i) fa[i] = i;\\n}\\nvoid solve() {\\n long long n, m1, m2;\\n cin >> n >> m1 >> m2;\\n init(fa1, n), init(fa2, n);\\n for (long long i = 1; i <= m1; ++i) {\\n long long u, v;\\n cin >> u >> v;\\n merge(fa1, u, v);\\n }\\n for (long long i = 1; i <= m2; ++i) {\\n long long u, v;\\n cin >> u >> v;\\n merge(fa2, u, v);\\n }\\n long long cnt = 0;\\n for (long long i = 2; i <= n; ++i)\\n if (find(fa1, 1) != find(fa1, i) && find(fa2, 1) != find(fa2, i)) {\\n ans[++cnt][0] = 1;\\n ans[cnt][1] = i;\\n merge(fa1, i, 1);\\n merge(fa2, i, 1);\\n }\\n long long sz1 = 0, sz2 = 0;\\n for (long long i = 2; i <= n; ++i) {\\n if (fa1[i] == i && fa1[i] != find(fa1, 1)) s1[sz1++] = i;\\n if (fa2[i] == i && fa2[i] != find(fa2, 1)) s2[sz2++] = i;\\n }\\n for (long long i = 0, j = 0; i < sz1 && j < sz2; ++i, ++j)\\n ans[++cnt][0] = s1[i], ans[cnt][1] = s2[j];\\n cout << cnt << '\\\\n';\\n for (long long i = 1; i <= cnt; ++i)\\n cout << ans[i][0] << ' ' << ans[i][1] << '\\\\n';\\n}\\nsigned main() {\\n ios::sync_with_stdio(false);\\n cin.tie(0);\\n solve();\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Given n, find any array a_1, a_2, …, a_n of integers such that all of the following conditions hold: \\n\\n * 1 ≤ a_i ≤ 10^9 for every i from 1 to n.\\n\\n * a_1 < a_2 < … \\n\\nThe algorithmic part of the mechanism detects each particular raindrop and predicts when and where it reaches the plane. At this exact moment the rope segment must contain the raindrop point (so the rope adsorbs the raindrop).\\n\\nYou are given the initial position of the rope endpoints and all information about raindrops. You are to choose the minimal possible speed v of the endpoints sliding (both endpoints can slide in any direction along their segments independently of each other) in such a way that it is possible to catch all raindrops moving both endpoints with speed not greater than v, or find out that it's impossible no matter how high the speed is.\\n\\nInput\\n\\nThe first line contains three integers n, w and h (1 ≤ n ≤ 10^5, 1≤ w, h ≤ 10^3), meaning that there are n raindrops, and two rails are represented as segments connecting (0, 0) and (w, 0) and connecting (0, h) and (w, h).\\n\\nThe second line contains two integers e_1 and e_2, meaning that the initial (that is, at the moment t = 0) positions of the endpoints are (e_1, 0) and (e_2, h) (0≤ e_1, e_2≤ w).\\n\\nThe i-th of the following n lines contains three integers t_i, x_i and y_i (1≤ t_i≤ 10^5, 0≤ x_i ≤ w, 0 < y_i < h) meaning that the i-th raindrop touches the plane at the point (x_i, y_i) at the time moment t_i. It is guaranteed that t_i ≤ t_{i+1} for all valid i.\\n\\nOutput\\n\\nIf it is impossible to catch all raindrops, print -1.\\n\\nOtherwise,...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nconst double inf = 1e9;\\nconst double eps = 1e-7;\\nint main() {\\n int n, width, height, begin0, begin1;\\n cin >> n >> width >> height >> begin0 >> begin1;\\n vector>> a(n + 1);\\n a[0] = make_pair(0, make_pair(1, begin1 - begin0));\\n for (int i = 1; i <= n; ++i) {\\n int x, y;\\n cin >> a[i].first >> x >> y;\\n a[i].second = make_pair(1 - (double)height \\/ y, (double)x * height \\/ y);\\n }\\n auto check = [&](double v) {\\n double l = begin0, r = begin0;\\n for (int i = 1; i <= n; ++i) {\\n double delta = v * (a[i].first - a[i - 1].first);\\n double k0 = a[i - 1].second.first, b0 = a[i - 1].second.second;\\n double k1 = a[i].second.first, b1 = a[i].second.second;\\n double k = k0 \\/ k1, tl, tr;\\n if (k1 > 0) {\\n tl = (b0 - delta - b1) \\/ k1;\\n tr = (b0 + delta - b1) \\/ k1;\\n } else {\\n tl = (b0 + delta - b1) \\/ k1;\\n tr = (b0 - delta - b1) \\/ k1;\\n }\\n if (fabs(k0 - k1) < eps) {\\n tl = max(tl, -delta);\\n tr = min(tr, delta);\\n if (tl > tr + eps) {\\n return false;\\n }\\n l += tl;\\n r += tr;\\n } else {\\n double ml = (tl + delta) \\/ (1 - k), mr = (tr - delta) \\/ (1 - k);\\n double nl = inf, nr = -inf;\\n if (k > 1) {\\n {\\n double left = max(l, mr), right = min(r, ml);\\n if (right >= left - eps) {\\n nl = min(nl, left - delta);\\n nr = max(nr, right + delta);\\n }\\n }\\n {\\n double left = max(l, max(ml, mr)), right = r;\\n if (right >= left - eps) {\\n right = min(right, (delta - tl) \\/ (k - 1));\\n if (right >= left - eps) {\\n nl = min(nl, k * left + tl);\\n nr = max(nr, right + delta);\\n }\\n }\\n }\\n {\\n double left = l, right = min(r, min(ml, mr));\\n if (right >= left - eps) {\\n left = max(left, -(delta + tr) \\/ (k - 1));\\n ...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A permutation p of size n is an array such that every integer from 1 to n occurs exactly once in this array.\\n\\nLet's call a permutation an almost identity permutation iff there exist at least n - k indices i (1 ≤ i ≤ n) such that pi = i.\\n\\nYour task is to count the number of almost identity permutations for given numbers n and k.\\n\\nInput\\n\\nThe first line contains two integers n and k (4 ≤ n ≤ 1000, 1 ≤ k ≤ 4).\\n\\nOutput\\n\\nPrint the number of almost identity permutations for given n and k.\\n\\nExamples\\n\\nInput\\n\\n4 1\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\n4 2\\n\\n\\nOutput\\n\\n7\\n\\n\\nInput\\n\\n5 3\\n\\n\\nOutput\\n\\n31\\n\\n\\nInput\\n\\n5 4\\n\\n\\nOutput\\n\\n76\",\"targets\":\"#include \\nusing namespace std;\\nint n, k;\\nlong long c(int a, int b) {\\n long long res = 1;\\n for (int i = 1; i <= b; ++i) {\\n res = res * (a + 1 - i) \\/ i;\\n }\\n return res;\\n}\\nint main() {\\n scanf(\\\"%d%d\\\", &n, &k);\\n long long ans = 1;\\n for (int i = 1; i <= k; ++i) {\\n if (i == 2) {\\n ans += c(n, 2);\\n }\\n if (i == 3) {\\n ans += 2 * c(n, 3);\\n }\\n if (i == 4) {\\n ans += 9 * c(n, 4);\\n }\\n }\\n printf(\\\"%lld\\\\n\\\", ans);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"\\n\\nWilliam is not only interested in trading but also in betting on sports matches. n teams participate in each match. Each team is characterized by strength a_i. Each two teams i < j play with each other exactly once. Team i wins with probability (a_i)\\/(a_i + a_j) and team j wins with probability (a_j)\\/(a_i + a_j).\\n\\nThe team is called a winner if it directly or indirectly defeated all other teams. Team a defeated (directly or indirectly) team b if there is a sequence of teams c_1, c_2, ... c_k such that c_1 = a, c_k = b and team c_i defeated team c_{i + 1} for all i from 1 to k - 1. Note that it is possible that team a defeated team b and in the same time team b defeated team a.\\n\\nWilliam wants you to find the expected value of the number of winners.\\n\\nInput\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 14), which is the total number of teams participating in a match.\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^6) — the strengths of teams participating in a match.\\n\\nOutput\\n\\nOutput a single integer — the expected value of the number of winners of the tournament modulo 10^9 + 7.\\n\\nFormally, let M = 10^9+7. It can be demonstrated that the answer can be presented as a irreducible fraction p\\/q, where p and q are integers and q not ≡ 0 \\\\pmod{M}. Output a single integer equal to p ⋅ q^{-1} mod M. In other words, output an integer x such that 0 ≤ x < M and x ⋅ q ≡ p \\\\pmod{M}.\\n\\nExamples\\n\\nInput\\n\\n\\n2\\n1 2\\n\\n\\nOutput\\n\\n\\n1\\n\\n\\nInput\\n\\n\\n5\\n1 5 2 11 14\\n\\n\\nOutput\\n\\n\\n642377629\\n\\nNote\\n\\nTo better understand in which situation several winners are possible let's examine the second test:\\n\\nOne possible result of the tournament is as follows (a → b means that a defeated b):\\n\\n * 1 → 2 \\n * 2 → 3 \\n * 3 → 1 \\n * 1 → 4 \\n * 1 → 5 \\n * 2 → 4 \\n * 2 → 5 \\n * 3 → 4 \\n * 3 → 5 \\n * 4 → 5 \\n\\n\\n\\nOr more clearly in the picture:\\n\\n\\n\\nIn this case every team from the set \\\\{ 1, 2, 3 \\\\} directly or indirectly defeated everyone. I.e.:\\n\\n * 1st defeated everyone because they can get to everyone else in the following way...\",\"targets\":\"#include \\n#pragma GCC optimize(\\\"O2,unroll-loops\\\")\\nusing namespace std;\\nconst int inf = 1000000010;\\nconst long long INF = 1000000000000001000LL;\\nconst int mod = 1000000007;\\nconst int N = 14;\\nint n, m, k, u, v, x, y, t, a, b, ans;\\nlong long A[N], P[N][N];\\nlong long tof[N][1 << N];\\nlong long tof2[1 << 7][1 << N], tof3[1 << 7][1 << N];\\nlong long dp[1 << N];\\nlong long powmod(long long a, long long b) {\\n long long res = 1;\\n for (; b; b >>= 1, a = a * a % mod)\\n if (b & 1) res = res * a % mod;\\n return res;\\n}\\nlong long Get(int mask1, int mask2) {\\n int x = (mask1 & 127), y = ((mask1 - x) >> 7);\\n return tof2[x][mask2] * tof3[y][mask2] % mod;\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n cin >> n;\\n for (int i = 0; i < n; i++) cin >> A[i];\\n for (int i = 0; i < n; i++)\\n for (int j = 0; j < n; j++)\\n P[i][j] = A[i] * powmod(A[i] + A[j], mod - 2) % mod;\\n for (int i = 0; i < n; i++) {\\n tof[i][0] = 1;\\n for (int j = 1; j < (1 << n); j++) {\\n int v = __builtin_ctz(j);\\n tof[i][j] = tof[i][j ^ (1 << v)] * P[i][v] % mod;\\n }\\n }\\n for (int i = 0; i < (1 << n); i++) tof2[0][i] = tof3[0][i] = 1;\\n for (int i = 1; i < (1 << 7); i++) {\\n int v = __builtin_ctz(i);\\n for (int mask = 0; mask < (1 << n); mask++) {\\n tof2[i][mask] = tof2[i ^ (1 << v)][mask] * tof[v][mask] % mod;\\n tof3[i][mask] = tof3[i ^ (1 << v)][mask] * tof[v + 7][mask] % mod;\\n }\\n }\\n dp[0] = 1;\\n for (int mask = 1; mask < (1 << n); mask++) {\\n dp[mask] = 1;\\n for (int sub = (mask - 1) & mask; sub; sub = (sub - 1) & mask)\\n dp[mask] = (dp[mask] - dp[sub] * Get(sub, mask ^ sub)) % mod;\\n long long ted = __builtin_popcount(mask);\\n ans = (ans + dp[mask] * Get(mask, (1 << n) - 1 - mask) % mod * ted) % mod;\\n }\\n if (ans < 0) ans += mod;\\n cout << ans << \\\"\\\\n\\\";\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"DZY loves Fast Fourier Transformation, and he enjoys using it.\\n\\nFast Fourier Transformation is an algorithm used to calculate convolution. Specifically, if a, b and c are sequences with length n, which are indexed from 0 to n - 1, and\\n\\n\\n\\nWe can calculate c fast using Fast Fourier Transformation.\\n\\nDZY made a little change on this formula. Now\\n\\n\\n\\nTo make things easier, a is a permutation of integers from 1 to n, and b is a sequence only containing 0 and 1. Given a and b, DZY needs your help to calculate c.\\n\\nBecause he is naughty, DZY provides a special way to get a and b. What you need is only three integers n, d, x. After getting them, use the code below to generate a and b.\\n \\n \\n \\n \\/\\/x is 64-bit variable; \\n function getNextX() { \\n x = (x * 37 + 10007) % 1000000007; \\n return x; \\n } \\n function initAB() { \\n for(i = 0; i < n; i = i + 1){ \\n a[i] = i + 1; \\n } \\n for(i = 0; i < n; i = i + 1){ \\n swap(a[i], a[getNextX() % (i + 1)]); \\n } \\n for(i = 0; i < n; i = i + 1){ \\n if (i < d) \\n b[i] = 1; \\n else \\n b[i] = 0; \\n } \\n for(i = 0; i < n; i = i + 1){ \\n swap(b[i], b[getNextX() % (i + 1)]); \\n } \\n } \\n \\n \\n\\nOperation x % y denotes remainder after division x by y. Function swap(x, y) swaps two values x and y.\\n\\nInput\\n\\nThe only line of input contains three space-separated integers n, d, x (1 ≤ d ≤ n ≤ 100000; 0 ≤ x ≤ 1000000006). Because DZY is naughty, x can't be equal to 27777500.\\n\\nOutput\\n\\nOutput n lines, the i-th line should contain an integer ci - 1.\\n\\nExamples\\n\\nInput\\n\\n3 1 1\\n\\n\\nOutput\\n\\n1\\n3\\n2\\n\\n\\nInput\\n\\n5 4 2\\n\\n\\nOutput\\n\\n2\\n2\\n4\\n5\\n5\\n\\n\\nInput\\n\\n5 4 3\\n\\n\\nOutput\\n\\n5\\n5\\n5\\n5\\n4\\n\\nNote\\n\\nIn the first sample, a is [1 3 2], b is [1 0 0], so c0 = max(1·1) = 1, c1 = max(1·0, 3·1) = 3, c2 = max(1·0, 3·0, 2·1) = 2.\\n\\nIn the second sample, a is [2 1 4 5 3], b is [1 1 1 0 1].\\n\\nIn the third sample, a is [5 2 1 4 3], b is [1 1 1 1 0].\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst int Maxn = 100005;\\nint n, d;\\nlong long x;\\nint a[Maxn], b[Maxn];\\nint c[Maxn];\\nvector ind;\\nset > S;\\nlong long getNextX() {\\n x = (x * 37 + 10007) % 1000000007;\\n return x;\\n}\\nvoid initAB() {\\n int i;\\n for (i = 0; i < n; i = i + 1) {\\n a[i] = i + 1;\\n }\\n for (i = 0; i < n; i = i + 1) {\\n swap(a[i], a[getNextX() % (i + 1)]);\\n }\\n for (i = 0; i < n; i = i + 1) {\\n if (i < d)\\n b[i] = 1;\\n else\\n b[i] = 0;\\n }\\n for (i = 0; i < n; i = i + 1) {\\n swap(b[i], b[getNextX() % (i + 1)]);\\n }\\n}\\nint main() {\\n scanf(\\\"%d %d %I64d\\\", &n, &d, &x);\\n initAB();\\n if (d <= 500) {\\n for (int i = 0; i < n; i++)\\n if (b[i]) ind.push_back(i);\\n for (int i = 0; i < n; i++)\\n for (int j = 0; j < ind.size() && ind[j] <= i; j++)\\n c[i] = max(c[i], a[i - ind[j]]);\\n } else\\n for (int i = 0; i < n; i++) {\\n S.insert(pair(a[i], i));\\n for (set >::reverse_iterator it = S.rbegin();\\n it != S.rend(); it++)\\n if (b[i - it->second]) {\\n c[i] = it->first;\\n break;\\n }\\n }\\n for (int i = 0; i < n; i++) printf(\\\"%d\\\\n\\\", c[i]);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"2^k teams participate in a playoff tournament. The tournament consists of 2^k - 1 games. They are held as follows: first of all, the teams are split into pairs: team 1 plays against team 2, team 3 plays against team 4 (exactly in this order), and so on (so, 2^{k-1} games are played in that phase). When a team loses a game, it is eliminated, and each game results in elimination of one team (there are no ties). After that, only 2^{k-1} teams remain. If only one team remains, it is declared the champion; otherwise, 2^{k-2} games are played: in the first one of them, the winner of the game \\\"1 vs 2\\\" plays against the winner of the game \\\"3 vs 4\\\", then the winner of the game \\\"5 vs 6\\\" plays against the winner of the game \\\"7 vs 8\\\", and so on. This process repeats until only one team remains.\\n\\nAfter the tournament ends, the teams are assigned places according to the tournament phase when they were eliminated. In particular:\\n\\n * the winner of the tournament gets place 1; \\n * the team eliminated in the finals gets place 2; \\n * both teams eliminated in the semifinals get place 3; \\n * all teams eliminated in the quarterfinals get place 5; \\n * all teams eliminated in the 1\\/8 finals get place 9, and so on. \\n\\n\\n\\nFor example, this picture describes one of the possible ways the tournament can go with k = 3, and the resulting places of the teams:\\n\\n\\n\\nAfter a tournament which was conducted by the aforementioned rules ended, its results were encoded in the following way. Let p_i be the place of the i-th team in the tournament. The hash value of the tournament h is calculated as h = (∑ _{i=1}^{2^k} i ⋅ A^{p_i}) mod 998244353, where A is some given integer.\\n\\nUnfortunately, due to a system crash, almost all tournament-related data was lost. The only pieces of data that remain are the values of k, A and h. You are asked to restore the resulting placing of the teams in the tournament, if it is possible at all.\\n\\nInput\\n\\nThe only line contains three integers k, A and h (1 ≤ k ≤ 5; 100 ≤ A ≤ 10^8; 0 ≤ h ≤ 998244352).\\n\\nOutput\\n\\nIf...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nconst long long MOD = 998244353;\\nlong long k, A, h, n;\\nlong long pw[100];\\nvector positions;\\nmap mp[50];\\nlong long ans[50];\\npair eval(long long mask, long long l, long long r) {\\n queue q;\\n for (long long i = l; i <= r; i++) q.push(i);\\n long long score = 0;\\n for (long long i = 0; i < (n \\/ 2) - 1; i++) {\\n long long p1 = q.front();\\n q.pop();\\n long long p2 = q.front();\\n q.pop();\\n if ((mask >> i) & 1) swap(p1, p2);\\n q.push(p1);\\n score += p2 * pw[positions[i]];\\n score %= MOD;\\n ans[p2] = positions[i];\\n }\\n return {score, q.front()};\\n}\\nvoid solve() {\\n cin >> k >> A >> h;\\n n = (1LL << k);\\n for (long long i = 0; i < k - 1; i++)\\n for (long long j = 0; j < (1LL << (k - i - 2)); j++)\\n positions.push_back((1LL << (k - i - 1)) + 1);\\n pw[0] = 1;\\n for (long long i = 1; i < 100; i++) pw[i] = (pw[i - 1] * A) % MOD;\\n for (long long i = 0; i < (1LL << ((n \\/ 2) - 1)); i++) {\\n auto temp = eval(i, 1, n \\/ 2);\\n mp[temp.second][temp.first] = i;\\n }\\n for (long long i = 0; i < (1LL << ((n \\/ 2) - 1)); i++) {\\n auto temp = eval(i, (n \\/ 2) + 1, n);\\n for (long long j = 1; j <= n \\/ 2; j++) {\\n for (long long v = 0; v <= 1; v++) {\\n long long need =\\n h - temp.first - temp.second * pw[v + 1] - j * pw[2 - v];\\n need %= MOD;\\n if (need < 0) need += MOD;\\n if (mp[j].find(need) != mp[j].end()) {\\n eval(mp[j][need], 1, n \\/ 2);\\n ans[temp.second] = v + 1;\\n ans[j] = 2 - v;\\n for (long long i = 1; i <= n; i++) cout << ans[i] << ' ';\\n return;\\n }\\n }\\n }\\n }\\n cout << -1;\\n}\\nsigned main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n solve();\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nPolycarp is a great fan of television.\\n\\nHe wrote down all the TV programs he is interested in for today. His list contains n shows, i-th of them starts at moment li and ends at moment ri.\\n\\nPolycarp owns two TVs. He can watch two different shows simultaneously with two TVs but he can only watch one show at any given moment on a single TV. If one show ends at the same moment some other show starts then you can't watch them on a single TV.\\n\\nPolycarp wants to check out all n shows. Are two TVs enough to do so?\\n\\nInput\\n\\nThe first line contains one integer n (1 ≤ n ≤ 2·105) — the number of shows.\\n\\nEach of the next n lines contains two integers li and ri (0 ≤ li < ri ≤ 109) — starting and ending time of i-th show.\\n\\nOutput\\n\\nIf Polycarp is able to check out all the shows using only two TVs then print \\\"YES\\\" (without quotes). Otherwise, print \\\"NO\\\" (without quotes).\\n\\nExamples\\n\\nInput\\n\\n3\\n1 2\\n2 3\\n4 5\\n\\n\\nOutput\\n\\nYES\\n\\n\\nInput\\n\\n4\\n1 2\\n2 3\\n2 3\\n1 2\\n\\n\\nOutput\\n\\nNO\",\"targets\":\"#include \\nusing namespace std;\\nint n, dem = 0;\\nvector > a;\\nint main() {\\n cin >> n;\\n for (int i = 1; i <= n; i++) {\\n int x, y;\\n cin >> x >> y;\\n a.push_back(make_pair(x, 1));\\n a.push_back(make_pair(y + 1, -1));\\n }\\n sort(a.begin(), a.end());\\n for (int i = 0; i < a.size(); i++) {\\n dem += a[i].second;\\n if (dem > 2) return cout << \\\"NO\\\", 0;\\n }\\n cout << \\\"YES\\\";\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Petya has got an interesting flower. Petya is a busy person, so he sometimes forgets to water it. You are given n days from Petya's live and you have to determine what happened with his flower in the end.\\n\\nThe flower grows as follows: \\n\\n * If the flower isn't watered for two days in a row, it dies. \\n * If the flower is watered in the i-th day, it grows by 1 centimeter. \\n * If the flower is watered in the i-th and in the (i-1)-th day (i > 1), then it grows by 5 centimeters instead of 1. \\n * If the flower is not watered in the i-th day, it does not grow. \\n\\n\\n\\nAt the beginning of the 1-st day the flower is 1 centimeter tall. What is its height after n days?\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 100). Description of the test cases follows.\\n\\nThe first line of each test case contains the only integer n (1 ≤ n ≤ 100).\\n\\nThe second line of each test case contains n integers a_1, a_2, ..., a_n (a_i = 0 or a_i = 1). If a_i = 1, the flower is watered in the i-th day, otherwise it is not watered.\\n\\nOutput\\n\\nFor each test case print a single integer k — the flower's height after n days, or -1, if the flower dies.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n1 0 1\\n3\\n0 1 1\\n4\\n1 0 0 1\\n1\\n0\\n\\n\\nOutput\\n\\n\\n3\\n7\\n-1\\n1\\nSolve the task in PYTHON3.\",\"targets\":\"for i in range(int(input())):\\n n = int(input())\\n l = list(map(int,input().split()))\\n x=1\\n if l[0] == 0 and len(l) == 1:\\n print(1)\\n else:\\n for i in range(n):\\n \\n if i>=1 and l[i] ==1 and l[i-1] == 1:\\n x+=5\\n \\n elif l[i] == 1:\\n x+=1\\n \\n \\n elif i[] g;\\n private ArrayList[] rg;\\n\\n public void solve() throws IOException {\\n int n = nextInt();\\n n = 2 * n;\\n g = new ArrayList[n];\\n rg = new ArrayList[n];\\n for (int i = 0; i < n; i++) {\\n g[i] = new ArrayList<>();\\n rg[i] = new ArrayList<>();\\n }\\n ArrayList toClear = new ArrayList<>();\\n for (int i = 0; i < n; i += 2) {\\n int t1 = nextInt() - 1;\\n int t2 = nextInt() - 1;\\n g[t1].add(t2);\\n rg[t2].add(t1);\\n if (t1 == t2) {\\n toClear.add(t1);\\n }\\n }\\n for (int v : toClear) {\\n clear(v);\\n }\\n long mm = 1000000007;\\n long res = 1;\\n for (int i = 0; i < n; i++) {\\n if (g[i].isEmpty()) {\\n res = res * clear(i) % mm;\\n }\\n }\\n Dsu dsu = new Dsu(n);\\n for (int i = 0; i < n; i++) {\\n for (int j : rg[i]) {\\n if (dsu.unionSets(i, j)) {\\n res = res * 2 % mm;\\n }\\n }\\n }\\n\\n\\n out.println(res);\\n }\\n\\n private static class Dsu {\\n private int[] parent;\\n private int[] rank;\\n\\n public Dsu(int n) {\\n parent = new int[n];\\n rank = new int[n];\\n for (int i = 0; i < n; i++) {\\n parent[i] = i;\\n rank[i] = 1;\\n }\\n }\\n\\n public int findSet(int v) {\\n if (v == parent[v]) {\\n ...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 solution for \\\"Grandma Capa has decided to knit a scarf and asked Grandpa Sher to make a pattern for it, a pattern is a string consisting of lowercase English letters. Grandpa Sher wrote a string s of length n.\\n\\nGrandma Capa wants to knit a beautiful scarf, and in her opinion, a beautiful scarf can only be knit from a string that is a palindrome. She wants to change the pattern written by Grandpa Sher, but to avoid offending him, she will choose one lowercase English letter and erase some (at her choice, possibly none or all) occurrences of that letter in string s.\\n\\nShe also wants to minimize the number of erased symbols from the pattern. Please help her and find the minimum number of symbols she can erase to make string s a palindrome, or tell her that it's impossible. Notice that she can only erase symbols equal to the one letter she chose.\\n\\nA string is a palindrome if it is the same from the left to the right and from the right to the left. For example, the strings 'kek', 'abacaba', 'r' and 'papicipap' are palindromes, while the strings 'abb' and 'iq' are not.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. The next 2 ⋅ t lines contain the description of test cases. The description of each test case consists of two lines.\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 10^5) — the length of the string.\\n\\nThe second line of each test case contains the string s consisting of n lowercase English letters.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case print the minimum number of erased symbols required to make the string a palindrome, if it is possible, and -1, if it is impossible.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n8\\nabcaacab\\n6\\nxyzxyz\\n4\\nabba\\n8\\nrprarlap\\n10\\nkhyyhhyhky\\n\\n\\nOutput\\n\\n\\n2\\n-1\\n0\\n3\\n2\\n\\nNote\\n\\nIn the first test case, you can choose a letter 'a' and erase its first and last occurrences, you will get a string 'bcaacb', which is a palindrome. You can also choose a letter 'b' and erase all its occurrences, you...\\\":\",\"targets\":\"#Code by Sounak, IIESTS\\n#------------------------------warmup----------------------------\\n\\nimport os\\nimport sys\\nimport math\\nfrom io import BytesIO, IOBase\\nimport io\\nfrom fractions import Fraction\\nimport collections\\nfrom itertools import permutations\\nfrom collections import defaultdict\\nfrom collections import deque\\nfrom collections import Counter\\nimport threading\\n\\n#sys.setrecursionlimit(300000)\\n#threading.stack_size(10**8)\\n\\nBUFSIZE = 8192\\n \\nclass FastIO(IOBase):\\n newlines = 0\\n \\n def __init__(self, file):\\n self._fd = file.fileno()\\n self.buffer = BytesIO()\\n self.writable = \\\"x\\\" in file.mode or \\\"r\\\" not in file.mode\\n self.write = self.buffer.write if self.writable else None\\n \\n def read(self):\\n while True:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n if not b:\\n break\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines = 0\\n return self.buffer.read()\\n \\n def readline(self):\\n while self.newlines == 0:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n self.newlines = b.count(b\\\"\\\\n\\\") + (not b)\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines -= 1\\n return self.buffer.readline()\\n \\n def flush(self):\\n if self.writable:\\n os.write(self._fd, self.buffer.getvalue())\\n self.buffer.truncate(0), self.buffer.seek(0)\\n \\n \\nclass IOWrapper(IOBase):\\n def __init__(self, file):\\n self.buffer = FastIO(file)\\n self.flush = self.buffer.flush\\n self.writable = self.buffer.writable\\n self.write = lambda s: self.buffer.write(s.encode(\\\"ascii\\\"))\\n self.read = lambda: self.buffer.read().decode(\\\"ascii\\\")\\n self.readline = lambda: self.buffer.readline().decode(\\\"ascii\\\")\\n \\n \\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\\ninput =...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Polycarp had an array a of 3 positive integers. He wrote out the sums of all non-empty subsequences of this array, sorted them in non-decreasing order, and got an array b of 7 integers.\\n\\nFor example, if a = \\\\{1, 4, 3\\\\}, then Polycarp wrote out 1, 4, 3, 1 + 4 = 5, 1 + 3 = 4, 4 + 3 = 7, 1 + 4 + 3 = 8. After sorting, he got an array b = \\\\{1, 3, 4, 4, 5, 7, 8\\\\}.\\n\\nUnfortunately, Polycarp lost the array a. He only has the array b left. Help him to restore the array a.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 5000) — the number of test cases.\\n\\nEach test case consists of one line which contains 7 integers b_1, b_2, ..., b_7 (1 ≤ b_i ≤ 10^9; b_i ≤ b_{i+1}). \\n\\nAdditional constraint on the input: there exists at least one array a which yields this array b as described in the statement.\\n\\nOutput\\n\\nFor each test case, print 3 integers — a_1, a_2 and a_3. If there can be several answers, print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n1 3 4 4 5 7 8\\n1 2 3 4 5 6 7\\n300000000 300000000 300000000 600000000 600000000 600000000 900000000\\n1 1 2 999999998 999999999 999999999 1000000000\\n1 2 2 3 3 4 5\\n\\n\\nOutput\\n\\n\\n1 4 3\\n4 1 2\\n300000000 300000000 300000000\\n999999998 1 1\\n1 2 2\\n\\nNote\\n\\nThe subsequence of the array a is a sequence that can be obtained from a by removing zero or more of its elements.\\n\\nTwo subsequences are considered different if index sets of elements included in them are different. That is, the values of the elements don't matter in the comparison of subsequences. In particular, any array of length 3 has exactly 7 different non-empty subsequences.\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst int mod = 1e9 + 7;\\nvoid solve() {\\n vector v(7);\\n for (auto &x : v) cin >> x;\\n cout << v[0] << \\\" \\\" << v[1] << \\\" \\\";\\n for (int i = 2; i < 6; i++) {\\n if (v[i] == v[i + 1]) {\\n cout << v[i] << endl;\\n return;\\n }\\n if (v[0] + v[1] != v[i]) {\\n cout << v[i] << endl;\\n return;\\n }\\n }\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n long long t = 1;\\n cin >> t;\\n while (t--) {\\n solve();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Polycarp had an array a of 3 positive integers. He wrote out the sums of all non-empty subsequences of this array, sorted them in non-decreasing order, and got an array b of 7 integers.\\n\\nFor example, if a = \\\\{1, 4, 3\\\\}, then Polycarp wrote out 1, 4, 3, 1 + 4 = 5, 1 + 3 = 4, 4 + 3 = 7, 1 + 4 + 3 = 8. After sorting, he got an array b = \\\\{1, 3, 4, 4, 5, 7, 8\\\\}.\\n\\nUnfortunately, Polycarp lost the array a. He only has the array b left. Help him to restore the array a.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 5000) — the number of test cases.\\n\\nEach test case consists of one line which contains 7 integers b_1, b_2, ..., b_7 (1 ≤ b_i ≤ 10^9; b_i ≤ b_{i+1}). \\n\\nAdditional constraint on the input: there exists at least one array a which yields this array b as described in the statement.\\n\\nOutput\\n\\nFor each test case, print 3 integers — a_1, a_2 and a_3. If there can be several answers, print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n1 3 4 4 5 7 8\\n1 2 3 4 5 6 7\\n300000000 300000000 300000000 600000000 600000000 600000000 900000000\\n1 1 2 999999998 999999999 999999999 1000000000\\n1 2 2 3 3 4 5\\n\\n\\nOutput\\n\\n\\n1 4 3\\n4 1 2\\n300000000 300000000 300000000\\n999999998 1 1\\n1 2 2\\n\\nNote\\n\\nThe subsequence of the array a is a sequence that can be obtained from a by removing zero or more of its elements.\\n\\nTwo subsequences are considered different if index sets of elements included in them are different. That is, the values of the elements don't matter in the comparison of subsequences. In particular, any array of length 3 has exactly 7 different non-empty subsequences.\\nSolve the task in PYTHON3.\",\"targets\":\"for _ in range(int(input())):\\n a = \\\"\\\"\\n b = [int(x) for x in input().split()]\\n a += str(b[6]-b[5])\\n a += \\\" \\\"\\n a += str(b[5]-b[1])\\n a += \\\" \\\"\\n a += str(b[1])\\n print(a)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"You are given an integer n. In 1 move, you can do one of the following actions:\\n\\n * erase any digit of the number (it's acceptable that the number before the operation has exactly one digit and after the operation, it is \\\"empty\\\"); \\n * add one digit to the right. \\n\\n\\n\\nThe actions may be performed in any order any number of times.\\n\\nNote that if, after deleting some digit from a number, it will contain leading zeroes, they will not be deleted. E.g. if you delete from the number 301 the digit 3, the result is the number 01 (not 1).\\n\\nYou need to perform the minimum number of actions to make the number any power of 2 (i.e. there's an integer k (k ≥ 0) such that the resulting number is equal to 2^k). The resulting number must not have leading zeroes.\\n\\nE.g. consider n=1052. The answer is equal to 2. First, let's add to the right one digit 4 (the result will be 10524). Then let's erase the digit 5, so the result will be 1024 which is a power of 2.\\n\\nE.g. consider n=8888. The answer is equal to 3. Let's erase any of the digits 8 three times. The result will be 8 which is a power of 2.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10^4) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one line containing one integer n (1 ≤ n ≤ 10^9).\\n\\nOutput\\n\\nFor each test case, output in a separate line one integer m — the minimum number of moves to transform the number into any power of 2.\\n\\nExample\\n\\nInput\\n\\n\\n12\\n1052\\n8888\\n6\\n75\\n128\\n1\\n301\\n12048\\n1504\\n6656\\n1000000000\\n687194767\\n\\n\\nOutput\\n\\n\\n2\\n3\\n1\\n3\\n0\\n0\\n2\\n1\\n3\\n4\\n9\\n2\\n\\nNote\\n\\nThe answer for the first test case was considered above.\\n\\nThe answer for the second test case was considered above.\\n\\nIn the third test case, it's enough to add to the right the digit 4 — the number 6 will turn into 64.\\n\\nIn the fourth test case, let's add to the right the digit 8 and then erase 7 and 5 — the taken number will turn into 8.\\n\\nThe numbers of the fifth and the sixth test cases are already powers of two so there's no need to make any move.\\n\\nIn the seventh test case, you can...\\\":\",\"targets\":\"import java.util.Scanner;\\nimport java.lang.Math;\\npublic class _1560D\\n{\\n public static void main(String[] args) {\\n Scanner sc=new Scanner(System.in);\\n int t=sc.nextInt();\\n while((t--)>0){\\n long n=sc.nextInt();\\n long min=Long.MAX_VALUE;\\n\\n for(long w=1;w<=1e18;w*=2){\\n long ans=0;\\n String a=String.valueOf(n);\\n String b=String.valueOf(w);\\n for(int i=0,j=0;i hm = new HashMap<>();\\n int c=0;\\n while(n-->0){\\n \\/\\/ print(hm+\\\" \\\"+(n+1));\\n int t=sc.nextInt();\\n if(t==1){\\n int x=sc.nextInt();\\n if(hm.containsKey(x)){\\n \\/\\/ print(x);\\n Pnode pn = hm.get(x);\\n Node curr=new Node(c++,pn.l);\\n pn.l=curr;\\n hm.put(x,pn);\\n \\n }else{\\n Pnode np= new Pnode();\\n Node nn= new Node(c++,null);\\n np.l=nn;\\n np.r=nn;\\n hm.put(x,np);\\n \\n }\\n }else{\\n \\n int x=sc.nextInt();\\n int y=sc.nextInt();\\n if(!hm.containsKey(x)){ continue;}\\n if(x==y){ continue;}\\n\\n Pnode px=hm.get(x);\\n if(hm.containsKey(y)){\\n Pnode py=hm.get(y);\\n \\/\\/ Pnode px=hm.get(x);\\n py.r.next=px.l;\\n py.r=px.r;\\n hm.put(y,py);\\n hm.remove(x);\\n\\n }else{\\n hm.put(y,hm.get(x));\\n hm.remove(x);\\n }\\n \\n \\n }\\n \\n }\\n int[] arr= new int[c];\\n\\n for(int no : hm.keySet()){\\n Pnode pn=hm.get(no);\\n Node curr=pn.l;\\n while(curr!=null){\\n arr[curr.id]=no;\\n curr=curr.next;\\n }\\n }\\n for(int i=0;i\\nusing namespace std;\\nlong long int mod = 1e9 + 1;\\nbool comparator(int a, int b) { return a > b; }\\nvoid solve() {\\n string s;\\n cin >> s;\\n int n = s.size();\\n if (n % 2 != 0) {\\n cout << \\\"NO\\\" << endl;\\n } else {\\n int low = 0;\\n int high = n \\/ 2;\\n bool flag = true;\\n while (high < n) {\\n if (s[low] == s[high]) {\\n low++;\\n high++;\\n continue;\\n } else {\\n flag = false;\\n }\\n low++;\\n high++;\\n }\\n if (flag) {\\n cout << \\\"YES\\\" << endl;\\n } else {\\n cout << \\\"NO\\\" << endl;\\n }\\n }\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n int t = 1;\\n cin >> t;\\n while (t--) {\\n solve();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"British mathematician John Littlewood once said about Indian mathematician Srinivasa Ramanujan that \\\"every positive integer was one of his personal friends.\\\"\\n\\nIt turns out that positive integers can also be friends with each other! You are given an array a of distinct positive integers. \\n\\nDefine a subarray a_i, a_{i+1}, …, a_j to be a friend group if and only if there exists an integer m ≥ 2 such that a_i mod m = a_{i+1} mod m = … = a_j mod m, where x mod y denotes the remainder when x is divided by y.\\n\\nYour friend Gregor wants to know the size of the largest friend group in a.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 2⋅ 10^4). \\n\\nEach test case begins with a line containing the integer n (1 ≤ n ≤ 2 ⋅ 10^5), the size of the array a.\\n\\nThe next line contains n positive integers a_1, a_2, …, a_n (1 ≤ a_i ≤ {10}^{18}), representing the contents of the array a. It is guaranteed that all the numbers in a are distinct.\\n\\nIt is guaranteed that the sum of n over all test cases is less than 2⋅ 10^5.\\n\\nOutput\\n\\nYour output should consist of t lines. Each line should consist of a single integer, the size of the largest friend group in a.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n5\\n1 5 2 4 6\\n4\\n8 2 5 10\\n2\\n1000 2000\\n8\\n465 55 3 54 234 12 45 78\\n\\n\\nOutput\\n\\n\\n3\\n3\\n2\\n6\\n\\nNote\\n\\nIn the first test case, the array is [1,5,2,4,6]. The largest friend group is [2,4,6], since all those numbers are congruent to 0 modulo 2, so m=2.\\n\\nIn the second test case, the array is [8,2,5,10]. The largest friend group is [8,2,5], since all those numbers are congruent to 2 modulo 3, so m=3.\\n\\nIn the third case, the largest friend group is [1000,2000]. There are clearly many possible values of m that work.\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"import sys\\nimport math\\n#import random\\ninput=sys.stdin\\noutput=sys.stdout\\n\\nt=int(input.readline().strip())\\nfor i in range(t):\\n n=int(input.readline().strip())\\n a=[int(x) for x in input.readline().strip().split()]\\n# n=random.randrange(1,100)\\n# a=[random.randrange(1,100000000) for x in range(n)]\\n\\n bmax=0\\n b=[0]*(n-1)\\n for j in range(n-1):\\n b[j]=a[j]-a[j+1]\\n if b[j]<0:\\n b[j]=-b[j]\\n if b[j]!=1:\\n bmax=1 \\n\\n if bmax==0:\\n print(1)\\n continue \\n\\n# def HCF(a, b):\\n# if a==0:\\n# return b\\n# elif b==0:\\n# return a\\n# elif a>b:\\n# return HCF(a%b, b)\\n# else:\\n# return HCF(b%a, a)\\n\\n# def HCF(x, y):\\n# while True:\\n# if x==0:\\n# return y\\n# elif y==0:\\n# return x\\n# elif x>y:\\n# x=x%y\\n# else:\\n# y=y%x\\n\\n def HCF(x, y):\\n while x>1:\\n x, y=y%x, x\\n if x==1:\\n return 1\\n else: \\n return y\\n \\n St=[[b[x]] for x in range(n-1)]\\n upton=1\\n while upton=num[k-1] and num[i]!=0):\\n s=s+1\\nprint(s)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"There are n candles on a Hanukkah menorah, and some of its candles are initially lit. We can describe which candles are lit with a binary string s, where the i-th candle is lit if and only if s_i=1.\\n\\n\\n\\nInitially, the candle lights are described by a string a. In an operation, you select a candle that is currently lit. By doing so, the candle you selected will remain lit, and every other candle will change (if it was lit, it will become unlit and if it was unlit, it will become lit).\\n\\nYou would like to make the candles look the same as string b. Your task is to determine if it is possible, and if it is, find the minimum number of operations required.\\n\\nInput\\n\\nThe first line contains an integer t (1≤ t≤ 10^4) — the number of test cases. Then t cases follow.\\n\\nThe first line of each test case contains a single integer n (1≤ n≤ 10^5) — the number of candles.\\n\\nThe second line contains a string a of length n consisting of symbols 0 and 1 — the initial pattern of lights.\\n\\nThe third line contains a string b of length n consisting of symbols 0 and 1 — the desired pattern of lights.\\n\\nIt is guaranteed that the sum of n does not exceed 10^5.\\n\\nOutput\\n\\nFor each test case, output the minimum number of operations required to transform a to b, or -1 if it's impossible.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n5\\n11010\\n11010\\n2\\n01\\n11\\n3\\n000\\n101\\n9\\n100010111\\n101101100\\n9\\n001011011\\n011010101\\n\\n\\nOutput\\n\\n\\n0\\n1\\n-1\\n3\\n4\\n\\nNote\\n\\nIn the first test case, the two strings are already equal, so we don't have to perform any operations.\\n\\nIn the second test case, we can perform a single operation selecting the second candle to transform 01 into 11.\\n\\nIn the third test case, it's impossible to perform any operations because there are no lit candles to select.\\n\\nIn the fourth test case, we can perform the following operations to transform a into b: \\n\\n 1. Select the 7-th candle: 100010{\\\\color{red}1}11→ 011101{\\\\color{red} 1}00. \\n 2. Select the 2-nd candle: 0{\\\\color{red} 1}1101100→ 1{\\\\color{red} 1}0010011. \\n 3. Select the 1-st candle: {\\\\color{red}1}10010011→...\\\":\",\"targets\":\"import java.util.Arrays;\\nimport java.util.Scanner;\\n\\npublic class First {\\n static Scanner sc = new Scanner(System.in);\\n public static void main(String[] args) {\\n int t = sc.nextInt();\\n while (t-- > 0) {\\n int n = sc.nextInt();\\n String a = sc.next();\\n String b = sc.next();\\n char ch1[] = a.toCharArray();\\n char ch2[] = b.toCharArray();\\n int zz = 0;\\n int oz = 0;\\n int zo = 0;\\n int oo = 0;\\n for (int i = 0; i < n; i++) {\\n if (ch1[i] == '0') {\\n if (ch2[i] == '0') {\\n zz += 1;\\n } else {\\n oz += 1;\\n }\\n } else {\\n if (ch2[i] == '0') {\\n zo += 1;\\n } else {\\n oo += 1;\\n }\\n }\\n }\\n int ans = -1;\\n if ((oo - zz) == 1 || zo == oz) {\\n int s1 = (int) 1e7;\\n int s2 = (int) 1e7;\\n if ((oo - zz) == 1) {\\n s1 = oo + zz;\\n }\\n if (zo == oz)\\n s2 = zo + oz;\\n ans = Math.min(s1, s2);\\n }\\n System.out.println(ans);\\n }\\n }\\n}\\n\\n\\/\\/9\\n\\/\\/001011011\\n\\/\\/011010101 3 2 2 2\\n\\/\\/9\\n\\/\\/100010111\\n\\/\\/101101100 2 1 3 3\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Monocarp wrote down two numbers on a whiteboard. Both numbers follow a specific format: a positive integer x with p zeros appended to its end.\\n\\nNow Monocarp asks you to compare these two numbers. Can you help him?\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.\\n\\nThe first line of each testcase contains two integers x_1 and p_1 (1 ≤ x_1 ≤ 10^6; 0 ≤ p_1 ≤ 10^6) — the description of the first number.\\n\\nThe second line of each testcase contains two integers x_2 and p_2 (1 ≤ x_2 ≤ 10^6; 0 ≤ p_2 ≤ 10^6) — the description of the second number.\\n\\nOutput\\n\\nFor each testcase print the result of the comparison of the given two numbers. If the first number is smaller than the second one, print '<'. If the first number is greater than the second one, print '>'. If they are equal, print '='.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n2 1\\n19 0\\n10 2\\n100 1\\n1999 0\\n2 3\\n1 0\\n1 0\\n99 0\\n1 2\\n\\n\\nOutput\\n\\n\\n>\\n=\\n<\\n=\\n<\\n\\nNote\\n\\nThe comparisons in the example are: 20 > 19, 1000 = 1000, 1999 < 2000, 1 = 1, 99 < 100.\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"for _ in range(int(input())):\\n x1, p1 = list(map(int, input().split()))\\n x2, p2 = list(map(int, input().split()))\\n if len(str(x1)) + p1 > len(str(x2)) + p2:\\n print('>')\\n elif len(str(x1)) + p1 < len(str(x2)) + p2:\\n print('<')\\n else:\\n if x1 > x2:\\n x2 = x2 * pow(10, (len(str(x1)) - len(str(x2))))\\n if x1 > x2:\\n print('>')\\n elif x1 < x2:\\n print('<')\\n else:\\n print('=')\\n elif x1 < x2:\\n x1 = x1 * pow(10, (len(str(x2)) - len(str(x1))))\\n if x1 > x2:\\n print('>')\\n elif x1 < x2:\\n print('<')\\n else:\\n print('=')\\n else:\\n print('=')\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given n integers a_1, a_2, …, a_n and an integer k. Find the maximum value of i ⋅ j - k ⋅ (a_i | a_j) over all pairs (i, j) of integers with 1 ≤ i < j ≤ n. Here, | is the [bitwise OR operator](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#OR).\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10 000) — the number of test cases.\\n\\nThe first line of each test case contains two integers n (2 ≤ n ≤ 10^5) and k (1 ≤ k ≤ min(n, 100)).\\n\\nThe second line of each test case contains n integers a_1, a_2, …, a_n (0 ≤ a_i ≤ n).\\n\\nIt is guaranteed that the sum of n over all test cases doesn't exceed 3 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print a single integer — the maximum possible value of i ⋅ j - k ⋅ (a_i | a_j).\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3 3\\n1 1 3\\n2 2\\n1 2\\n4 3\\n0 1 2 3\\n6 6\\n3 2 0 0 5 6\\n\\n\\nOutput\\n\\n\\n-1\\n-4\\n3\\n12\\n\\nNote\\n\\nLet f(i, j) = i ⋅ j - k ⋅ (a_i | a_j).\\n\\nIn the first test case, \\n\\n * f(1, 2) = 1 ⋅ 2 - k ⋅ (a_1 | a_2) = 2 - 3 ⋅ (1 | 1) = -1. \\n * f(1, 3) = 1 ⋅ 3 - k ⋅ (a_1 | a_3) = 3 - 3 ⋅ (1 | 3) = -6. \\n * f(2, 3) = 2 ⋅ 3 - k ⋅ (a_2 | a_3) = 6 - 3 ⋅ (1 | 3) = -3. \\n\\n\\n\\nSo the maximum is f(1, 2) = -1.\\n\\nIn the fourth test case, the maximum is f(3, 4) = 12.\\nUsing java can you solve the prior task?\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\n\\npublic class B {\\n\\n\\tpublic static void main(String[] args) {\\n\\t\\t\\n\\t\\tFastReader f = new FastReader();\\n\\t\\tStringBuffer sb=new StringBuffer();\\n\\t\\tint test=f.nextInt();\\n\\t\\tout:\\n\\t\\twhile(test-->0)\\n\\t\\t{\\t\\t\\t\\n\\t\\t\\tint n=f.nextInt();\\n\\t\\t\\tint k=f.nextInt();\\n\\t\\t\\t\\t\\t\\n\\t\\t\\tint a[]=new int[n];\\n\\t\\t\\tfor(int i=0;i=Math.max(0,n-200);i--)\\n\\t\\t\\t{\\n\\t\\t\\t\\tfor(int j=i-1;j>=Math.max(0,n-200);j--)\\n\\t\\t\\t\\t\\tmax=Math.max(max,((long)(i+1)*(j+1) - (long)k*(a[i]|a[j])));\\n\\t\\t\\t}\\n\\t\\t\\tsb.append(max+\\\"\\\\n\\\");\\n\\t\\t}\\n\\t\\tSystem.out.println(sb);\\n\\t}\\n\\t\\n\\tstatic class FastReader \\n\\t{ \\n\\t BufferedReader br; \\n\\t StringTokenizer st; \\n \\n\\t public FastReader() {\\n\\t \\tbr = new BufferedReader(new\\n\\t InputStreamReader(System.in)); \\n\\t }\\n\\t String next() { \\n\\t while (st == null || !st.hasMoreElements()) { \\n\\t try{ \\n\\t st = new StringTokenizer(br.readLine()); \\n\\t } \\n\\t catch (IOException e) { \\n\\t e.printStackTrace(); \\n\\t } \\n\\t } \\n\\t return st.nextToken(); \\n\\t } \\n\\t int nextInt() { \\n\\t return Integer.parseInt(next()); \\n\\t } \\n\\t long nextLong() { \\n\\t return Long.parseLong(next()); \\n\\t } \\n\\t double nextDouble() { \\n\\t return Double.parseDouble(next()); \\n\\t } \\n\\t String nextLine() { \\n\\t String str = \\\"\\\"; \\n\\t try{ \\n\\t str = br.readLine(); \\n\\t } \\n\\t catch (IOException e) { \\n\\t e.printStackTrace(); \\n\\t } \\n\\t return str; \\n\\t } \\n\\t} \\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"An identity permutation of length n is an array [1, 2, 3, ..., n].\\n\\nWe performed the following operations to an identity permutation of length n:\\n\\n * firstly, we cyclically shifted it to the right by k positions, where k is unknown to you (the only thing you know is that 0 ≤ k ≤ n - 1). When an array is cyclically shifted to the right by k positions, the resulting array is formed by taking k last elements of the original array (without changing their relative order), and then appending n - k first elements to the right of them (without changing relative order of the first n - k elements as well). For example, if we cyclically shift the identity permutation of length 6 by 2 positions, we get the array [5, 6, 1, 2, 3, 4]; \\n * secondly, we performed the following operation at most m times: pick any two elements of the array and swap them. \\n\\n\\n\\nYou are given the values of n and m, and the resulting array. Your task is to find all possible values of k in the cyclic shift operation.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10^5) — the number of test cases.\\n\\nEach test case consists of two lines. The first line contains two integers n and m (3 ≤ n ≤ 3 ⋅ 10^5; 0 ≤ m ≤ n\\/3).\\n\\nThe second line contains n integers p_1, p_2, ..., p_n (1 ≤ p_i ≤ n, each integer from 1 to n appears in this sequence exactly once) — the resulting array.\\n\\nThe sum of n over all test cases does not exceed 3 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print the answer in the following way:\\n\\n * firstly, print one integer r (0 ≤ r ≤ n) — the number of possible values of k for the cyclic shift operation; \\n * secondly, print r integers k_1, k_2, ..., k_r (0 ≤ k_i ≤ n - 1) — all possible values of k in increasing order. \\n\\nExample\\n\\nInput\\n\\n\\n4\\n4 1\\n2 3 1 4\\n3 1\\n1 2 3\\n3 1\\n3 2 1\\n6 0\\n1 2 3 4 6 5\\n\\n\\nOutput\\n\\n\\n1 3\\n1 0\\n3 0 1 2\\n0\\n\\nNote\\n\\nConsider the example: \\n\\n * in the first test case, the only possible value for the cyclic shift is 3. If we shift [1, 2, 3, 4] by 3 positions, we get [2, 3, 4, 1]. Then we can swap the 3-rd and the 4-th elements to get the...\\nimpor\",\"targets\":\"t sys\\ninput = sys.stdin.readline\\nfrom collections import Counter\\n\\nfor _ in range(int(input())):\\n n, m = map(int, input().split())\\n A = list(map(int, input().split()))\\n A = [a - 1 for a in A]\\n B = [(i - a) % n for i, a in enumerate(A)]\\n cnt = Counter(B)\\n ans = []\\n X = list(range(1, n + 1))\\n for k in range(n):\\n if n - cnt[k] > 2 * m: continue\\n seen = [0] * n\\n cycle = 0\\n cur = A[k:] + A[: k]\\n for i in range(n):\\n if seen[i]: continue\\n while not seen[i]:\\n seen[i] = 1\\n i = cur[i]\\n cycle += 1\\n if n - cycle <= m:\\n ans.append(k)\\n print(len(ans), *ans)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 solution for \\\"Luntik has decided to try singing. He has a one-minute songs, b two-minute songs and c three-minute songs. He wants to distribute all songs into two concerts such that every song should be included to exactly one concert.\\n\\nHe wants to make the absolute difference of durations of the concerts as small as possible. The duration of the concert is the sum of durations of all songs in that concert.\\n\\nPlease help Luntik and find the minimal possible difference in minutes between the concerts durations.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases.\\n\\nEach test case consists of one line containing three integers a, b, c (1 ≤ a, b, c ≤ 10^9) — the number of one-minute, two-minute and three-minute songs.\\n\\nOutput\\n\\nFor each test case print the minimal possible difference in minutes between the concerts durations.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n1 1 1\\n2 1 3\\n5 5 5\\n1 1 2\\n\\n\\nOutput\\n\\n\\n0\\n1\\n0\\n1\\n\\nNote\\n\\nIn the first test case, Luntik can include a one-minute song and a two-minute song into the first concert, and a three-minute song into the second concert. Then the difference will be equal to 0.\\n\\nIn the second test case, Luntik can include two one-minute songs and a two-minute song and a three-minute song into the first concert, and two three-minute songs into the second concert. The duration of the first concert will be 1 + 1 + 2 + 3 = 7, the duration of the second concert will be 6. The difference of them is |7-6| = 1.\\\":\",\"targets\":\"import sys\\ninput = lambda: sys.stdin.readline().rstrip('\\\\r\\\\n')\\n\\ninp_vars_int = lambda: map(int, input().split())\\ninp_list_int = lambda: list(map(int, input().split()))\\n\\nt = int(input())\\n\\nfor _ in range(t):\\n a, b, c = inp_vars_int()\\n full = a + 2 * b + 3 * c \\n print(full % 2)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"This is the easy version of the problem. The difference between the versions is that the easy version does not require you to output the numbers of the rods to be removed. You can make hacks only if all versions of the problem are solved.\\n\\nStitch likes experimenting with different machines with his friend Sparky. Today they built another machine.\\n\\nThe main element of this machine are n rods arranged along one straight line and numbered from 1 to n inclusive. Each of these rods must carry an electric charge quantitatively equal to either 1 or -1 (otherwise the machine will not work). Another condition for this machine to work is that the sign-variable sum of the charge on all rods must be zero.\\n\\nMore formally, the rods can be represented as an array of n numbers characterizing the charge: either 1 or -1. Then the condition must hold: a_1 - a_2 + a_3 - a_4 + … = 0, or ∑_{i=1}^n (-1)^{i-1} ⋅ a_i = 0.\\n\\nSparky charged all n rods with an electric current, but unfortunately it happened that the rods were not charged correctly (the sign-variable sum of the charge is not zero). The friends decided to leave only some of the rods in the machine. Sparky has q questions. In the ith question Sparky asks: if the machine consisted only of rods with numbers l_i to r_i inclusive, what minimal number of rods could be removed from the machine so that the sign-variable sum of charges on the remaining ones would be zero? Perhaps the friends got something wrong, and the sign-variable sum is already zero. In that case, you don't have to remove the rods at all.\\n\\nIf the number of rods is zero, we will assume that the sign-variable sum of charges is zero, that is, we can always remove all rods.\\n\\nHelp your friends and answer all of Sparky's questions!\\n\\nInput\\n\\nEach test contains multiple test cases.\\n\\nThe first line contains one positive integer t (1 ≤ t ≤ 10^3), denoting the number of test cases. Description of the test cases follows.\\n\\nThe first line of each test case contains two positive integers n and q (1 ≤ n, q ≤ 3 ⋅ 10^5) — the...\\nUsing python3 can you solve the prior task?\",\"targets\":\"import sys,io,os\\ntry: input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\\nexcept: input = lambda: sys.stdin.readline().encode()\\nread = lambda: map(int,input().split())\\nfrom collections import defaultdict as dd\\nO = []\\nneg = [1,-1]\\nfor _ in range(int(input())):\\n n,q = read()\\n s = input().strip()\\n p = [0]\\n for i in range(n):\\n p.append(p[-1]+(44-s[i])*neg[i&1])\\n for i in range(q):\\n l,r = read()\\n if (r-l)&1:\\n if p[r]-p[l-1]==0: O.append('0')\\n else: O.append('2')\\n else: O.append('1')\\nprint('\\\\n'.join(O))\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Ezzat has an array of n integers (maybe negative). He wants to split it into two non-empty subsequences a and b, such that every element from the array belongs to exactly one subsequence, and the value of f(a) + f(b) is the maximum possible value, where f(x) is the average of the subsequence x. \\n\\nA sequence x is a subsequence of a sequence y if x can be obtained from y by deletion of several (possibly, zero or all) elements.\\n\\nThe average of a subsequence is the sum of the numbers of this subsequence divided by the size of the subsequence.\\n\\nFor example, the average of [1,5,6] is (1+5+6)\\/3 = 12\\/3 = 4, so f([1,5,6]) = 4.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^3)— the number of test cases. Each test case consists of two lines.\\n\\nThe first line contains a single integer n (2 ≤ n ≤ 10^5).\\n\\nThe second line contains n integers a_1, a_2, …, a_n (-10^9 ≤ a_i ≤ 10^9).\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 3⋅10^5.\\n\\nOutput\\n\\nFor each test case, print a single value — the maximum value that Ezzat can achieve.\\n\\nYour answer is considered correct if its absolute or relative error does not exceed 10^{-6}.\\n\\nFormally, let your answer be a, and the jury's answer be b. Your answer is accepted if and only if \\\\frac{|a - b|}{max{(1, |b|)}} ≤ 10^{-6}.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n3 1 2\\n3\\n-7 -6 -6\\n3\\n2 2 2\\n4\\n17 3 5 -3\\n\\n\\nOutput\\n\\n\\n4.500000000\\n-12.500000000\\n4.000000000\\n18.666666667\\n\\nNote\\n\\nIn the first test case, the array is [3, 1, 2]. These are all the possible ways to split this array: \\n\\n * a = [3], b = [1,2], so the value of f(a) + f(b) = 3 + 1.5 = 4.5. \\n * a = [3,1], b = [2], so the value of f(a) + f(b) = 2 + 2 = 4. \\n * a = [3,2], b = [1], so the value of f(a) + f(b) = 2.5 + 1 = 3.5. \\n\\nTherefore, the maximum possible value 4.5.\\n\\nIn the second test case, the array is [-7, -6, -6]. These are all the possible ways to split this array: \\n\\n * a = [-7], b = [-6,-6], so the value of f(a) + f(b) = (-7) + (-6) = -13. \\n * a = [-7,-6], b = [-6], so the value of f(a) + f(b) = (-6.5) + (-6) =...\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.util.*;\\npublic class Solution{\\n public static void main(String[] args) {\\n \\tScanner sc = new Scanner(System.in);\\n \\tint t = sc.nextInt();\\n \\twhile(t-- > 0) {\\n \\t\\tint n = sc.nextInt();\\n \\t\\tint[] e = new int[n];\\n \\t\\tfor( int i = 0 ; i < n ; i++) {\\n \\t\\t\\te[i] = sc.nextInt();\\n \\t\\t}\\n \\t\\tArrays.sort(e);\\n \\t\\tint max = 0 ;\\n \\t\\tdouble avg = 0 ;\\n \\t\\t\\tmax = e[e.length-1];\\n \\t\\t\\tfor(int i = 0 ; i < n-1 ;i ++) {\\n \\t\\t\\t\\tavg += e[i] ; \\n \\t\\t\\t}\\n \\t\\t\\tavg = avg\\/(n-1) ;\\n \\t\\tSystem.out.println(max+avg);\\n \\t}\\n \\tsc.close();\\n \\t}\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given an integer n. Find any string s of length n consisting only of English lowercase letters such that each non-empty substring of s occurs in s an odd number of times. If there are multiple such strings, output any. It can be shown that such string always exists under the given constraints.\\n\\nA string a is a substring of a string b if a can be obtained from b by deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 500) — the number of test cases.\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 10^5).\\n\\nIt is guaranteed that the sum of n over all test cases doesn't exceed 3 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print a single line containing the string s. If there are multiple such strings, output any. It can be shown that such string always exists under the given constraints.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n5\\n9\\n19\\n\\n\\nOutput\\n\\n\\nabc\\ndiane\\nbbcaabbba\\nyouarethecutestuwuu\\n\\nNote\\n\\nIn the first test case, each substring of \\\"abc\\\" occurs exactly once.\\n\\nIn the third test case, each substring of \\\"bbcaabbba\\\" occurs an odd number of times. In particular, \\\"b\\\" occurs 5 times, \\\"a\\\" and \\\"bb\\\" occur 3 times each, and each of the remaining substrings occurs exactly once.\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\n\\npublic class D {\\n\\tpublic static void main(String[] args) throws IOException {\\n\\t\\tKattio io = new Kattio();\\n\\n\\t\\tint t = io.nextInt();\\n\\t\\tfor (int ii=0; ii 0) {\\n solve();\\n }\\n\\n\\n }\\n\\n\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Masha really loves algebra. On the last lesson, her strict teacher Dvastan gave she new exercise.\\n\\nYou are given geometric progression b defined by two integers b1 and q. Remind that a geometric progression is a sequence of integers b1, b2, b3, ..., where for each i > 1 the respective term satisfies the condition bi = bi - 1·q, where q is called the common ratio of the progression. Progressions in Uzhlyandia are unusual: both b1 and q can equal 0. Also, Dvastan gave Masha m \\\"bad\\\" integers a1, a2, ..., am, and an integer l.\\n\\nMasha writes all progression terms one by one onto the board (including repetitive) while condition |bi| ≤ l is satisfied (|x| means absolute value of x). There is an exception: if a term equals one of the \\\"bad\\\" integers, Masha skips it (doesn't write onto the board) and moves forward to the next term.\\n\\nBut the lesson is going to end soon, so Masha has to calculate how many integers will be written on the board. In order not to get into depression, Masha asked you for help: help her calculate how many numbers she will write, or print \\\"inf\\\" in case she needs to write infinitely many integers.\\n\\nInput\\n\\nThe first line of input contains four integers b1, q, l, m (-109 ≤ b1, q ≤ 109, 1 ≤ l ≤ 109, 1 ≤ m ≤ 105) — the initial term and the common ratio of progression, absolute value of maximal number that can be written on the board and the number of \\\"bad\\\" integers, respectively.\\n\\nThe second line contains m distinct integers a1, a2, ..., am (-109 ≤ ai ≤ 109) — numbers that will never be written on the board.\\n\\nOutput\\n\\nPrint the only integer, meaning the number of progression terms that will be written on the board if it is finite, or \\\"inf\\\" (without quotes) otherwise.\\n\\nExamples\\n\\nInput\\n\\n3 2 30 4\\n6 14 25 48\\n\\n\\nOutput\\n\\n3\\n\\nInput\\n\\n123 1 2143435 4\\n123 11 -5453 141245\\n\\n\\nOutput\\n\\n0\\n\\nInput\\n\\n123 1 2143435 4\\n54343 -13 6 124\\n\\n\\nOutput\\n\\ninf\\n\\nNote\\n\\nIn the first sample case, Masha will write integers 3, 12, 24. Progression term 6 will be skipped because it is a \\\"bad\\\" integer. Terms bigger than 24 won't be written...\\\":\",\"targets\":\"#include \\nbool check(std::vector &v, int a) {\\n auto l = std::lower_bound(v.begin(), v.end(), a);\\n return l != v.end() && *l == a;\\n}\\nint main() {\\n std::int64_t b, q, l, m;\\n std::cin >> b >> q >> l >> m;\\n std::vector v(m, 0);\\n for (int i = 0; i < m; ++i) {\\n std::cin >> v[i];\\n }\\n std::sort(v.begin(), v.end());\\n if (b == 0) {\\n if (check(v, b)) {\\n std::cout << 0;\\n } else {\\n std::cout << \\\"inf\\\";\\n }\\n return 0;\\n }\\n if (q == 0) {\\n if (std::abs(b) <= l) {\\n if (!check(v, b)) {\\n if (check(v, 0)) {\\n std::cout << 1;\\n } else {\\n std::cout << \\\"inf\\\";\\n }\\n } else {\\n if (check(v, 0)) {\\n std::cout << 0;\\n } else {\\n std::cout << \\\"inf\\\";\\n }\\n }\\n } else {\\n std::cout << 0;\\n }\\n return 0;\\n }\\n if (q == 1) {\\n if (std::abs(b) <= l && !check(v, b)) {\\n std::cout << \\\"inf\\\";\\n } else {\\n std::cout << 0;\\n }\\n return 0;\\n }\\n if (q == -1) {\\n if (std::abs(b) <= l && !(check(v, b) && check(v, -b))) {\\n std::cout << \\\"inf\\\";\\n } else {\\n std::cout << 0;\\n }\\n return 0;\\n }\\n int count = 0;\\n while (std::abs(b) <= l) {\\n if (!check(v, b)) {\\n ++count;\\n }\\n b *= q;\\n }\\n std::cout << count;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Let's call the string beautiful if it does not contain a substring of length at least 2, which is a palindrome. Recall that a palindrome is a string that reads the same way from the first character to the last and from the last character to the first. For example, the strings a, bab, acca, bcabcbacb are palindromes, but the strings ab, abbbaa, cccb are not.\\n\\nLet's define cost of a string as the minimum number of operations so that the string becomes beautiful, if in one operation it is allowed to change any character of the string to one of the first 3 letters of the Latin alphabet (in lowercase).\\n\\nYou are given a string s of length n, each character of the string is one of the first 3 letters of the Latin alphabet (in lowercase).\\n\\nYou have to answer m queries — calculate the cost of the substring of the string s from l_i-th to r_i-th position, inclusive.\\n\\nInput\\n\\nThe first line contains two integers n and m (1 ≤ n, m ≤ 2 ⋅ 10^5) — the length of the string s and the number of queries.\\n\\nThe second line contains the string s, it consists of n characters, each character one of the first 3 Latin letters.\\n\\nThe following m lines contain two integers l_i and r_i (1 ≤ l_i ≤ r_i ≤ n) — parameters of the i-th query.\\n\\nOutput\\n\\nFor each query, print a single integer — the cost of the substring of the string s from l_i-th to r_i-th position, inclusive.\\n\\nExample\\n\\nInput\\n\\n\\n5 4\\nbaacb\\n1 3\\n1 5\\n4 5\\n2 3\\n\\n\\nOutput\\n\\n\\n1\\n2\\n0\\n1\\n\\nNote\\n\\nConsider the queries of the example test.\\n\\n * in the first query, the substring is baa, which can be changed to bac in one operation; \\n * in the second query, the substring is baacb, which can be changed to cbacb in two operations; \\n * in the third query, the substring is cb, which can be left unchanged; \\n * in the fourth query, the substring is aa, which can be changed to ba in one operation. \\\":\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n ios::sync_with_stdio(false);\\n cin.tie(NULL);\\n int n, q;\\n cin >> n >> q;\\n string s;\\n cin >> s;\\n vector> f(6, vector(n));\\n int cnt = 0;\\n string a = \\\"abc\\\";\\n do {\\n string t;\\n while (((int)t.size()) < n) t += a;\\n t.resize(n);\\n for (int i = (0), _b = (n - 1); i <= _b; ++i) {\\n f[cnt][i] = int(s[i] != t[i]);\\n if (i) f[cnt][i] += f[cnt][i - 1];\\n }\\n ++cnt;\\n } while (next_permutation(a.begin(), a.end()));\\n while (q--) {\\n int l, r, res;\\n cin >> l >> r;\\n --l, --r;\\n res = n;\\n for (int i = (0), _b = (cnt - 1); i <= _b; ++i)\\n res = min(res, l ? f[i][r] - f[i][l - 1] : f[i][r]);\\n cout << res << '\\\\n';\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Gathering darkness shrouds the woods and the world. The moon sheds its light on the boat and the river.\\n\\n\\\"To curtain off the moonlight should be hardly possible; the shades present its mellow beauty and restful nature.\\\" Intonates Mino.\\n\\n\\\"See? The clouds are coming.\\\" Kanno gazes into the distance.\\n\\n\\\"That can't be better,\\\" Mino turns to Kanno. \\n\\nThe sky can be seen as a one-dimensional axis. The moon is at the origin whose coordinate is 0.\\n\\nThere are n clouds floating in the sky. Each cloud has the same length l. The i-th initially covers the range of (x_i, x_i + l) (endpoints excluded). Initially, it moves at a velocity of v_i, which equals either 1 or -1.\\n\\nFurthermore, no pair of clouds intersect initially, that is, for all 1 ≤ i < j ≤ n, \\\\lvert x_i - x_j \\\\rvert ≥ l.\\n\\nWith a wind velocity of w, the velocity of the i-th cloud becomes v_i + w. That is, its coordinate increases by v_i + w during each unit of time. Note that the wind can be strong and clouds can change their direction.\\n\\nYou are to help Mino count the number of pairs (i, j) (i < j), such that with a proper choice of wind velocity w not exceeding w_max in absolute value (possibly negative and\\/or fractional), the i-th and j-th clouds both cover the moon at the same future moment. This w doesn't need to be the same across different pairs.\\n\\nInput\\n\\nThe first line contains three space-separated integers n, l, and w_max (1 ≤ n ≤ 10^5, 1 ≤ l, w_max ≤ 10^8) — the number of clouds, the length of each cloud and the maximum wind speed, respectively.\\n\\nThe i-th of the following n lines contains two space-separated integers x_i and v_i (-10^8 ≤ x_i ≤ 10^8, v_i ∈ \\\\{-1, 1\\\\}) — the initial position and the velocity of the i-th cloud, respectively.\\n\\nThe input guarantees that for all 1 ≤ i < j ≤ n, \\\\lvert x_i - x_j \\\\rvert ≥ l.\\n\\nOutput\\n\\nOutput one integer — the number of unordered pairs of clouds such that it's possible that clouds from each pair cover the moon at the same future moment with a proper choice of wind velocity w.\\n\\nExamples\\n\\nInput\\n\\n5 1 2\\n-2 1\\n2 1\\n3 -1\\n5...\\\":\",\"targets\":\"#include \\n#pragma comment(linker, \\\"\\/STACK:1024000000,1024000000\\\")\\nusing namespace std;\\ninline void II(int &n) {\\n char ch = getchar();\\n n = 0;\\n bool t = 0;\\n for (; ch < '0'; ch = getchar())\\n if (ch == '-') t = 1;\\n for (; ch >= '0'; n = n * 10 + ch - '0', ch = getchar())\\n ;\\n if (t) n = -n;\\n}\\ninline void OO(int a) {\\n if (a < 0) {\\n putchar('-');\\n a = -a;\\n }\\n if (a >= 10) OO(a \\/ 10);\\n putchar(a % 10 + '0');\\n}\\nint n, l, w, an, bn;\\nlong double a[200005], b[200005];\\nint nl1, nl2, nr1, nr2, x, v;\\nconst long double eps = 1e-8;\\nint sgn(long double x) { return (x > eps) - (x < -eps); }\\nint main() {\\n scanf(\\\"%d%d%d\\\", &n, &l, &w);\\n for (int i = 1; i <= n; ++i) {\\n scanf(\\\"%d%d\\\", &x, &v);\\n if (v == 1) {\\n if (x < 0) ++nl1;\\n if (x <= 0) ++nl2;\\n a[++an] = x;\\n }\\n if (v == -1) {\\n if (x + l > 0) ++nr1;\\n if (x + l >= 0) ++nr2;\\n b[++bn] = x;\\n }\\n }\\n sort(a + 1, a + 1 + an);\\n sort(b + 1, b + 1 + bn);\\n long long ans = 0;\\n if (w == 1) {\\n ans = 1LL * nl1 * nr1;\\n } else {\\n ans = 1LL * nl2 * nr1 + 1LL * nl1 * (nr2 - nr1);\\n for (int i = 1; i <= an; ++i)\\n if (a[i] > 0) {\\n long double t = 1.0 * a[i] \\/ (1.0 * w - 1);\\n long double pos = t * (w + 1);\\n int id = upper_bound(b + 1, b + 1 + bn, pos - l + eps) - b;\\n ans += bn - id + 1;\\n }\\n for (int i = 1; i <= bn; ++i)\\n if (b[i] + l < 0) {\\n long double t = (b[i] + l) \\/ (1.0 * w - 1);\\n long double pos = t * (w + 1);\\n int id = lower_bound(a + 1, a + 1 + an, pos - eps) - a;\\n ans += id - 1;\\n }\\n }\\n cout << ans << endl;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"An identity permutation of length n is an array [1, 2, 3, ..., n].\\n\\nWe performed the following operations to an identity permutation of length n:\\n\\n * firstly, we cyclically shifted it to the right by k positions, where k is unknown to you (the only thing you know is that 0 ≤ k ≤ n - 1). When an array is cyclically shifted to the right by k positions, the resulting array is formed by taking k last elements of the original array (without changing their relative order), and then appending n - k first elements to the right of them (without changing relative order of the first n - k elements as well). For example, if we cyclically shift the identity permutation of length 6 by 2 positions, we get the array [5, 6, 1, 2, 3, 4]; \\n * secondly, we performed the following operation at most m times: pick any two elements of the array and swap them. \\n\\n\\n\\nYou are given the values of n and m, and the resulting array. Your task is to find all possible values of k in the cyclic shift operation.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10^5) — the number of test cases.\\n\\nEach test case consists of two lines. The first line contains two integers n and m (3 ≤ n ≤ 3 ⋅ 10^5; 0 ≤ m ≤ n\\/3).\\n\\nThe second line contains n integers p_1, p_2, ..., p_n (1 ≤ p_i ≤ n, each integer from 1 to n appears in this sequence exactly once) — the resulting array.\\n\\nThe sum of n over all test cases does not exceed 3 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print the answer in the following way:\\n\\n * firstly, print one integer r (0 ≤ r ≤ n) — the number of possible values of k for the cyclic shift operation; \\n * secondly, print r integers k_1, k_2, ..., k_r (0 ≤ k_i ≤ n - 1) — all possible values of k in increasing order. \\n\\nExample\\n\\nInput\\n\\n\\n4\\n4 1\\n2 3 1 4\\n3 1\\n1 2 3\\n3 1\\n3 2 1\\n6 0\\n1 2 3 4 6 5\\n\\n\\nOutput\\n\\n\\n1 3\\n1 0\\n3 0 1 2\\n0\\n\\nNote\\n\\nConsider the example: \\n\\n * in the first test case, the only possible value for the cyclic shift is 3. If we shift [1, 2, 3, 4] by 3 positions, we get [2, 3, 4, 1]. Then we can swap the 3-rd and the 4-th elements to get the...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nvector edge[300005];\\nbool visit[300005];\\nint dfs(int n) {\\n int ck = 1;\\n visit[n] = 1;\\n for (auto it : edge[n]) {\\n if (visit[it] == 0) ck += dfs(it);\\n }\\n return ck;\\n}\\nvoid solve() {\\n int n;\\n int m;\\n scanf(\\\"%d%d\\\", &n, &m);\\n int a[n + 2], b[n + 1];\\n memset(a, 0, sizeof(a));\\n for (int i = 1; i <= n; i++) {\\n int a1;\\n scanf(\\\"%d\\\", &a1);\\n b[i] = a1;\\n int x = n - (a1 - i);\\n if (x >= n) x -= n;\\n a[x]++;\\n }\\n vector v;\\n for (int i = 0; i < n; i++) {\\n int x = n - a[i];\\n if (x <= 2 * m) {\\n v.push_back(i);\\n }\\n }\\n vector ans;\\n for (auto it : v) {\\n int k = it;\\n int ok = 0;\\n int per[n + 2];\\n for (int i = 0; i < n; i++) {\\n int x = (i - k + n) % n + 1;\\n per[x] = i + 1;\\n }\\n for (int i = 1; i <= n; i++) {\\n int x = b[i];\\n edge[x].push_back(b[per[x]]);\\n }\\n for (int i = 1; i <= n; i++) {\\n ok += dfs(i) - 1;\\n }\\n for (int i = 1; i <= n; i++) {\\n edge[i].clear();\\n visit[i] = 0;\\n }\\n if (ok <= m) ans.push_back(k);\\n }\\n cout << ans.size();\\n for (auto it : ans) {\\n cout << \\\" \\\" << it;\\n }\\n cout << \\\"\\\\n\\\";\\n}\\nint main() {\\n int t;\\n scanf(\\\"%d\\\", &t);\\n while (t--) {\\n solve();\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"During the hypnosis session, Nicholas suddenly remembered a positive integer n, which doesn't contain zeros in decimal notation. \\n\\nSoon, when he returned home, he got curious: what is the maximum number of digits that can be removed from the number so that the number becomes not prime, that is, either composite or equal to one?\\n\\nFor some numbers doing so is impossible: for example, for number 53 it's impossible to delete some of its digits to obtain a not prime integer. However, for all n in the test cases of this problem, it's guaranteed that it's possible to delete some of their digits to obtain a not prime number.\\n\\nNote that you cannot remove all the digits from the number.\\n\\nA prime number is a number that has no divisors except one and itself. A composite is a number that has more than two divisors. 1 is neither a prime nor a composite number.\\n\\nInput\\n\\nEach test contains multiple test cases.\\n\\nThe first line contains one positive integer t (1 ≤ t ≤ 10^3), denoting the number of test cases. Description of the test cases follows.\\n\\nThe first line of each test case contains one positive integer k (1 ≤ k ≤ 50) — the number of digits in the number.\\n\\nThe second line of each test case contains a positive integer n, which doesn't contain zeros in decimal notation (10^{k-1} ≤ n < 10^{k}). It is guaranteed that it is always possible to remove less than k digits to make the number not prime.\\n\\nIt is guaranteed that the sum of k over all test cases does not exceed 10^4.\\n\\nOutput\\n\\nFor every test case, print two numbers in two lines. In the first line print the number of digits, that you have left in the number. In the second line print the digits left after all delitions. \\n\\nIf there are multiple solutions, print any.\\n\\nExample\\n\\nInput\\n\\n\\n7\\n3\\n237\\n5\\n44444\\n3\\n221\\n2\\n35\\n3\\n773\\n1\\n4\\n30\\n626221626221626221626221626221\\n\\n\\nOutput\\n\\n\\n2\\n27\\n1\\n4\\n1\\n1\\n2\\n35\\n2\\n77\\n1\\n4\\n1\\n6\\n\\nNote\\n\\nIn the first test case, you can't delete 2 digits from the number 237, as all the numbers 2, 3, and 7 are prime. However, you can delete 1 digit, obtaining a number 27 =...\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nconst long long N = 60;\\nconst long long M = 1e7;\\nlong long t;\\nchar s[N];\\nlong long n;\\nlong long visit[M + 10];\\nclass node {\\n public:\\n long long num;\\n long long len;\\n long long pos;\\n};\\nqueue q;\\nsigned main() {\\n visit[1] = 1;\\n for (long long i = 2; i <= M; i++) {\\n if (!visit[i])\\n for (long long j = i * i; j <= M; j += i) {\\n visit[j] = 1;\\n }\\n }\\n cin >> t;\\n while (t--) {\\n cin >> n;\\n cin >> s + 1;\\n while (!q.empty()) q.pop();\\n bool flag = 0;\\n for (long long i = 1; i <= n; i++) {\\n if (s[i] == '9' || (s[i] != '2' && ((s[i] - '0') % 2) == 0)) {\\n cout << 1 << endl;\\n cout << s[i] << endl;\\n flag = 1;\\n break;\\n }\\n node tn;\\n tn.pos = i;\\n tn.len = 1;\\n tn.num = s[i] - '0';\\n q.push(tn);\\n }\\n if (flag) continue;\\n while (!q.empty()) {\\n long long temp = q.front().num;\\n long long pos = q.front().pos;\\n long long len = q.front().len;\\n if (visit[temp]) {\\n cout << len << endl;\\n cout << temp << endl;\\n break;\\n }\\n for (long long i = pos + 1; i <= n; i++) {\\n node tn = q.front();\\n tn.len++;\\n tn.num *= 10;\\n tn.num += s[i] - '0';\\n tn.pos = i;\\n q.push(tn);\\n }\\n q.pop();\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Gregor is learning about RSA cryptography, and although he doesn't understand how RSA works, he is now fascinated with prime numbers and factoring them.\\n\\nGregor's favorite prime number is P. Gregor wants to find two bases of P. Formally, Gregor is looking for two integers a and b which satisfy both of the following properties.\\n\\n * P mod a = P mod b, where x mod y denotes the remainder when x is divided by y, and \\n * 2 ≤ a < b ≤ P. \\n\\n\\n\\nHelp Gregor find two bases of his favorite prime number!\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 1000).\\n\\nEach subsequent line contains the integer P (5 ≤ P ≤ {10}^9), with P guaranteed to be prime.\\n\\nOutput\\n\\nYour output should consist of t lines. Each line should consist of two integers a and b (2 ≤ a < b ≤ P). If there are multiple possible solutions, print any.\\n\\nExample\\n\\nInput\\n\\n\\n2\\n17\\n5\\n\\n\\nOutput\\n\\n\\n3 5\\n2 4\\n\\nNote\\n\\nThe first query is P=17. a=3 and b=5 are valid bases in this case, because 17 mod 3 = 17 mod 5 = 2. There are other pairs which work as well.\\n\\nIn the second query, with P=5, the only solution is a=2 and b=4.\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"for i in range(int(input())):\\n a = int(input())\\n print(2, a - 1)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Polycarp has found a table having an infinite number of rows and columns. The rows are numbered from 1, starting from the topmost one. The columns are numbered from 1, starting from the leftmost one.\\n\\nInitially, the table hasn't been filled and Polycarp wants to fix it. He writes integers from 1 and so on to the table as follows.\\n\\n The figure shows the placement of the numbers from 1 to 10. The following actions are denoted by the arrows.\\n\\nThe leftmost topmost cell of the table is filled with the number 1. Then he writes in the table all positive integers beginning from 2 sequentially using the following algorithm.\\n\\nFirst, Polycarp selects the leftmost non-filled cell in the first row and fills it. Then, while the left neighbor of the last filled cell is filled, he goes down and fills the next cell. So he goes down until the last filled cell has a non-filled neighbor to the left (look at the vertical arrow going down in the figure above).\\n\\nAfter that, he fills the cells from the right to the left until he stops at the first column (look at the horizontal row in the figure above). Then Polycarp selects the leftmost non-filled cell in the first row, goes down, and so on.\\n\\nA friend of Polycarp has a favorite number k. He wants to know which cell will contain the number. Help him to find the indices of the row and the column, such that the intersection of the row and the column is the cell containing the number k.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 100) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one line containing one integer k (1 ≤ k ≤ 10^9) which location must be found.\\n\\nOutput\\n\\nFor each test case, output in a separate line two integers r and c (r, c ≥ 1) separated by spaces — the indices of the row and the column containing the cell filled by the number k, respectively.\\n\\nExample\\n\\nInput\\n\\n\\n7\\n11\\n14\\n5\\n4\\n1\\n2\\n1000000000\\n\\n\\nOutput\\n\\n\\n2 4\\n4 3\\n1 3\\n2 1\\n1 1\\n1 2\\n31623 14130\\nSolve the task in PYTHON3.\",\"targets\":\"import math\\ndef solve(n):\\n if n==1:\\n return (1,1)\\n else:\\n x=math.floor(math.sqrt(n))\\n z=math.ceil(math.sqrt(n))\\n diff1=abs(n-(x**2))\\n diff2=abs(n-(z**2))\\n if diff1 m:\\n m = a\\n k = b\\n\\nprint(k + m)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"\\n\\nWilliam has an array of n integers a_1, a_2, ..., a_n. In one move he can swap two neighboring items. Two items a_i and a_j are considered neighboring if the condition |i - j| = 1 is satisfied.\\n\\nWilliam wants you to calculate the minimal number of swaps he would need to perform to make it so that the array does not contain two neighboring items with the same parity.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^4). Description of the test cases follows.\\n\\nThe first line of each test case contains an integer n (1 ≤ n ≤ 10^5) which is the total number of items in William's array.\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) which are William's array.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 10^5.\\n\\nOutput\\n\\nFor each test case output the minimal number of operations needed or -1 if it is impossible to get the array to a state when no neighboring numbers have the same parity.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n3\\n6 6 1\\n1\\n9\\n6\\n1 1 1 2 2 2\\n2\\n8 6\\n6\\n6 2 3 4 5 1\\n\\n\\nOutput\\n\\n\\n1\\n0\\n3\\n-1\\n2\\n\\nNote\\n\\nIn the first test case the following sequence of operations would satisfy the requirements: \\n\\n 1. swap(2, 3). Array after performing the operation: [6, 1, 6] \\n\\n\\n\\nIn the second test case the array initially does not contain two neighboring items of the same parity.\\n\\nIn the third test case the following sequence of operations would satisfy the requirements: \\n\\n 1. swap(3, 4). Array after performing the operation: [1, 1, 2, 1, 2, 2] \\n 2. swap(2, 3). Array after performing the operation: [1, 2, 1, 1, 2, 2] \\n 3. swap(4, 5). Array after performing the operation: [1, 2, 1, 2, 1, 2] \\n\\n\\n\\nIn the fourth test case it is impossible to satisfy the requirements.\\n\\nIn the fifth test case the following sequence of operations would satisfy the requirements: \\n\\n 1. swap(2, 3). Array after performing the operation: [6, 3, 2, 4, 5, 1] \\n 2. swap(4, 5). Array after performing the operation: [6, 3, 2, 5, 4, 1] \\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nlong long power(long long x, long long y, long long m) {\\n if (y == 0) return 1;\\n long long p = power(x, y \\/ 2, m) % m;\\n p = (p * p) % m;\\n return (y % 2 == 0) ? p : (x * p) % m;\\n}\\nvoid print(vector a) {\\n for (long long i = 0; i < a.size(); i++) cout << a[i] << \\\" \\\";\\n cout << \\\"\\\\n\\\";\\n}\\nlong long gcd(long long a, long long b) {\\n if (b == 0) return a;\\n return gcd(b, a % b);\\n}\\nlong long lcm(long long a, long long b) { return (a \\/ gcd(a, b)) * b; }\\nbool cmp(long long a, long long b) { return a > b; }\\nint32_t main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n long long t;\\n cin >> t;\\n for (long long tc = 0; tc < t; tc++) {\\n long long n;\\n cin >> n;\\n vector a(n);\\n for (long long i = 0; i < n; i++) cin >> a[i];\\n long long o = 0, e = 0;\\n vector od, ev;\\n for (auto k : a) {\\n if (k % 2 == 1)\\n o++;\\n else\\n e++;\\n }\\n for (long long i = 0; i < n; i++) {\\n if (a[i] % 2)\\n od.push_back(i);\\n else\\n ev.push_back(i);\\n }\\n if (abs(o - e) > 1)\\n cout << -1;\\n else {\\n long long ans = INT32_MAX;\\n long long c = 0;\\n long long pos = n - 1;\\n if (o == e) {\\n for (long long i = e - 1; i >= 0; i--) {\\n c += abs(ev[i] - pos);\\n pos -= 2;\\n }\\n } else {\\n if (o > e)\\n for (long long i = o - 1; i >= 0; i--) {\\n c += abs(od[i] - pos);\\n pos -= 2;\\n }\\n else\\n c = INT64_MAX;\\n }\\n ans = c;\\n c = 0, pos = n - 1;\\n if (o == e) {\\n for (long long i = o - 1; i >= 0; i--) {\\n c += abs(od[i] - pos);\\n pos -= 2;\\n }\\n } else {\\n if (o > e)\\n c = INT64_MAX;\\n else {\\n for (long long i = e - 1; i >= 0; i--) {\\n c += abs(ev[i] - pos);\\n pos -= 2;\\n }\\n }\\n }\\n ans = min(ans, c);\\n cout << ans;\\n }\\n cout << \\\"\\\\n\\\";\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nAt a geometry lesson Bob learnt that a triangle is called right-angled if it is nondegenerate and one of its angles is right. Bob decided to draw such a triangle immediately: on a sheet of paper he drew three points with integer coordinates, and joined them with segments of straight lines, then he showed the triangle to Peter. Peter said that Bob's triangle is not right-angled, but is almost right-angled: the triangle itself is not right-angled, but it is possible to move one of the points exactly by distance 1 so, that all the coordinates remain integer, and the triangle become right-angled. Bob asks you to help him and find out if Peter tricks him. By the given coordinates of the triangle you should find out if it is right-angled, almost right-angled, or neither of these.\\n\\nInput\\n\\nThe first input line contains 6 space-separated integers x1, y1, x2, y2, x3, y3 — coordinates of the triangle's vertices. All the coordinates are integer and don't exceed 100 in absolute value. It's guaranteed that the triangle is nondegenerate, i.e. its total area is not zero.\\n\\nOutput\\n\\nIf the given triangle is right-angled, output RIGHT, if it is almost right-angled, output ALMOST, and if it is neither of these, output NEITHER.\\n\\nExamples\\n\\nInput\\n\\n0 0 2 0 0 1\\n\\n\\nOutput\\n\\nRIGHT\\n\\n\\nInput\\n\\n2 3 4 5 6 6\\n\\n\\nOutput\\n\\nNEITHER\\n\\n\\nInput\\n\\n-1 0 2 0 0 1\\n\\n\\nOutput\\n\\nALMOST\",\"targets\":\"#include \\nusing namespace std;\\nbool check(double x1, double x2, double x3, double y1, double y2, double y3) {\\n if (x1 == x2 && y1 == y2 || x1 == x3 && y1 == y3 || x2 == x3 && y2 == y3)\\n return false;\\n double a[3];\\n a[0] = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);\\n a[1] = (x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3);\\n a[2] = (x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2);\\n sort(a, a + 3);\\n if (a[0] + a[1] == a[2])\\n return true;\\n else\\n return false;\\n}\\ndouble x1, x2, x3, y11, y2, y3;\\nint main() {\\n scanf(\\\"%lf %lf %lf %lf %lf %lf\\\", &x1, &y11, &x2, &y2, &x3, &y3);\\n if (check(x1, x2, x3, y11, y2, y3))\\n printf(\\\"RIGHT\\\");\\n else if (check(x1 + 1, x2, x3, y11, y2, y3) ||\\n check(x1 - 1, x2, x3, y11, y2, y3) ||\\n check(x1, x2 + 1, x3, y11, y2, y3) ||\\n check(x1, x2 - 1, x3, y11, y2, y3) ||\\n check(x1, x2, x3 + 1, y11, y2, y3) ||\\n check(x1, x2, x3 - 1, y11, y2, y3) ||\\n check(x1, x2, x3, y11 + 1, y2, y3) ||\\n check(x1, x2, x3, y11 - 1, y2, y3) ||\\n check(x1, x2, x3, y11, y2 + 1, y3) ||\\n check(x1, x2, x3, y11, y2 - 1, y3) ||\\n check(x1, x2, x3, y11, y2, y3 + 1) ||\\n check(x1, x2, x3, y11, y2, y3 - 1))\\n printf(\\\"ALMOST\\\");\\n else\\n printf(\\\"NEITHER\\\");\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"YouKn0wWho has two even integers x and y. Help him to find an integer n such that 1 ≤ n ≤ 2 ⋅ 10^{18} and n mod x = y mod n. Here, a mod b denotes the remainder of a after division by b. If there are multiple such integers, output any. It can be shown that such an integer always exists under the given constraints.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^5) — the number of test cases.\\n\\nThe first and only line of each test case contains two integers x and y (2 ≤ x, y ≤ 10^9, both are even).\\n\\nOutput\\n\\nFor each test case, print a single integer n (1 ≤ n ≤ 2 ⋅ 10^{18}) that satisfies the condition mentioned in the statement. If there are multiple such integers, output any. It can be shown that such an integer always exists under the given constraints.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n4 8\\n4 2\\n420 420\\n69420 42068\\n\\n\\nOutput\\n\\n\\n4\\n10\\n420\\n9969128\\n\\nNote\\n\\nIn the first test case, 4 mod 4 = 8 mod 4 = 0.\\n\\nIn the second test case, 10 mod 4 = 2 mod 10 = 2.\\n\\nIn the third test case, 420 mod 420 = 420 mod 420 = 0.\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\n#pragma GCC optimize(\\\"-ffloat-store\\\")\\nusing namespace std;\\nint T, x, y;\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n cin >> T;\\n for (long long cs = 1; cs <= T; cs++) {\\n cin >> x >> y;\\n if (x <= y) {\\n int hs = y \\/ x;\\n int near = hs * x;\\n cout << (near + y) \\/ 2 << \\\"\\\\n\\\";\\n } else {\\n cout << (x + y) << \\\"\\\\n\\\";\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nMonocarp is playing a computer game. Now he wants to complete the first level of this game.\\n\\nA level is a rectangular grid of 2 rows and n columns. Monocarp controls a character, which starts in cell (1, 1) — at the intersection of the 1-st row and the 1-st column.\\n\\nMonocarp's character can move from one cell to another in one step if the cells are adjacent by side and\\/or corner. Formally, it is possible to move from cell (x_1, y_1) to cell (x_2, y_2) in one step if |x_1 - x_2| ≤ 1 and |y_1 - y_2| ≤ 1. Obviously, it is prohibited to go outside the grid.\\n\\nThere are traps in some cells. If Monocarp's character finds himself in such a cell, he dies, and the game ends.\\n\\nTo complete a level, Monocarp's character should reach cell (2, n) — at the intersection of row 2 and column n.\\n\\nHelp Monocarp determine if it is possible to complete the level.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. Then the test cases follow. Each test case consists of three lines.\\n\\nThe first line contains a single integer n (3 ≤ n ≤ 100) — the number of columns.\\n\\nThe next two lines describe the level. The i-th of these lines describes the i-th line of the level — the line consists of the characters '0' and '1'. The character '0' corresponds to a safe cell, the character '1' corresponds to a trap cell.\\n\\nAdditional constraint on the input: cells (1, 1) and (2, n) are safe.\\n\\nOutput\\n\\nFor each test case, output YES if it is possible to complete the level, and NO otherwise.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n000\\n000\\n4\\n0011\\n1100\\n4\\n0111\\n1110\\n6\\n010101\\n101010\\n\\n\\nOutput\\n\\n\\nYES\\nYES\\nNO\\nYES\\n\\nNote\\n\\nConsider the example from the statement.\\n\\nIn the first test case, one of the possible paths is (1, 1) → (2, 2) → (2, 3).\\n\\nIn the second test case, one of the possible paths is (1, 1) → (1, 2) → (2, 3) → (2, 4).\\n\\nIn the fourth test case, one of the possible paths is (1, 1) → (2, 2) → (1, 3) → (2, 4) → (1, 5) → (2, 6).\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n long long t, n;\\n cin >> t;\\n while (t--) {\\n cin >> n;\\n string s1, s2;\\n bool flag = true;\\n cin >> s1 >> s2;\\n for (int i = 0; i < n; i++) {\\n if (s1[i] == '1' && s2[i] == '1') {\\n flag = false;\\n break;\\n }\\n }\\n if (flag == true)\\n cout << \\\"YES\\\";\\n else\\n cout << \\\"NO\\\";\\n cout << \\\"\\\\n\\\";\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alice and Bob are playing a game on a matrix, consisting of 2 rows and m columns. The cell in the i-th row in the j-th column contains a_{i, j} coins in it.\\n\\nInitially, both Alice and Bob are standing in a cell (1, 1). They are going to perform a sequence of moves to reach a cell (2, m).\\n\\nThe possible moves are: \\n\\n * Move right — from some cell (x, y) to (x, y + 1); \\n * Move down — from some cell (x, y) to (x + 1, y). \\n\\n\\n\\nFirst, Alice makes all her moves until she reaches (2, m). She collects the coins in all cells she visit (including the starting cell).\\n\\nWhen Alice finishes, Bob starts his journey. He also performs the moves to reach (2, m) and collects the coins in all cells that he visited, but Alice didn't.\\n\\nThe score of the game is the total number of coins Bob collects.\\n\\nAlice wants to minimize the score. Bob wants to maximize the score. What will the score of the game be if both players play optimally?\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.\\n\\nThen the descriptions of t testcases follow.\\n\\nThe first line of the testcase contains a single integer m (1 ≤ m ≤ 10^5) — the number of columns of the matrix.\\n\\nThe i-th of the next 2 lines contain m integers a_{i,1}, a_{i,2}, ..., a_{i,m} (1 ≤ a_{i,j} ≤ 10^4) — the number of coins in the cell in the i-th row in the j-th column of the matrix.\\n\\nThe sum of m over all testcases doesn't exceed 10^5.\\n\\nOutput\\n\\nFor each testcase print a single integer — the score of the game if both players play optimally.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n3\\n1 3 7\\n3 5 1\\n3\\n1 3 9\\n3 5 1\\n1\\n4\\n7\\n\\n\\nOutput\\n\\n\\n7\\n8\\n0\\n\\nNote\\n\\nThe paths for the testcases are shown on the following pictures. Alice's path is depicted in red and Bob's path is depicted in blue.\\n\\n\\nimpor\",\"targets\":\"t javax.swing.*;\\nimport java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.lang.reflect.Array;\\nimport java.math.BigInteger;\\nimport java.security.cert.CollectionCertStoreParameters;\\nimport java.util.*;\\n\\n\\n\\nimport static javax.swing.UIManager.get;\\nimport static javax.swing.UIManager.getString;\\n\\n\\npublic class Main {\\n\\n\\n static class Pair implements Comparable{\\n int x=0;\\n int y=0;\\n public Pair(int x1,int y1)\\n { x=x1;\\n y=y1;\\n }\\n\\n\\n @Override\\n public int compareTo(Pair o) {\\n return this.x-o.x;\\n }\\n }\\n\\n static boolean checkPallindrome(int n)\\n { ArrayList list = new ArrayList<>();\\n while(n>0)\\n { list.add(n%10);\\n n\\/=10;\\n }\\n int low=0,high=list.size()-1;\\n while(low<=high)\\n { if(list.get(low)!=list.get(high))\\n return false;\\n low++;\\n high--;\\n }\\n return true;\\n }\\n\\n\\n static boolean check(String s)\\n {\\n\\n int low=0,high=s.length()-1;\\n while(low<=high)\\n { if(s.charAt(low)!=s.charAt(high))\\n return false;\\n low++;\\n high--;\\n }\\n return true;\\n }\\n\\n static int min=Integer.MAX_VALUE;\\n public static void main(String[] args) throws IOException {\\n FastReader sc = new FastReader();\\n\\/\\/(1)very very important**(never take the first problem for granted, always check the test cases) take 5 minutes more and check the edge cases\\n \\/\\/ 5 minutes will not decreases rating as much as a wrong submission does it is easy u just think with an open mind and u will surely get the answer\\n \\/\\/(2)let ur brain consume the problem don't just jump to the solution. after reading the problem take a pause 1 minute\\n \\/\\/(3)go through the example test cases and also at least two of ur own test cases.Think of testcases which are difficult(edge cases).dry run ur concept\\n\\n int t = sc.nextInt();\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nA bracket sequence is a string containing only characters \\\"(\\\" and \\\")\\\". A regular bracket sequence (or, shortly, an RBS) is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters \\\"1\\\" and \\\"+\\\" between the original characters of the sequence. For example:\\n\\n * bracket sequences \\\"()()\\\" and \\\"(())\\\" are regular (the resulting expressions are: \\\"(1)+(1)\\\" and \\\"((1+1)+1)\\\"); \\n * bracket sequences \\\")(\\\", \\\"(\\\" and \\\")\\\" are not. \\n\\n\\n\\nLet's denote the concatenation of two strings x and y as x+y. For example, \\\"()()\\\" + \\\")(\\\" = \\\"()())(\\\".\\n\\nYou are given n bracket sequences s_1, s_2, ..., s_n. You can rearrange them in any order (you can rearrange only the strings themselves, but not the characters in them).\\n\\nYour task is to rearrange the strings in such a way that the string s_1 + s_2 + ... + s_n has as many non-empty prefixes that are RBS as possible.\\n\\nInput\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 20).\\n\\nThen n lines follow, the i-th of them contains s_i — a bracket sequence (a string consisting of characters \\\"(\\\" and\\/or \\\")\\\". All sequences s_i are non-empty, their total length does not exceed 4 ⋅ 10^5.\\n\\nOutput\\n\\nPrint one integer — the maximum number of non-empty prefixes that are RBS for the string s_1 + s_2 + ... + s_n, if the strings s_1, s_2, ..., s_n can be rearranged arbitrarily.\\n\\nExamples\\n\\nInput\\n\\n\\n2\\n(\\n)\\n\\n\\nOutput\\n\\n\\n1\\n\\n\\nInput\\n\\n\\n4\\n()()())\\n(\\n(\\n)\\n\\n\\nOutput\\n\\n\\n4\\n\\n\\nInput\\n\\n\\n1\\n(())\\n\\n\\nOutput\\n\\n\\n1\\n\\n\\nInput\\n\\n\\n1\\n)(()\\n\\n\\nOutput\\n\\n\\n0\\n\\nNote\\n\\nIn the first example, you can concatenate the strings as follows: \\\"(\\\" + \\\")\\\" = \\\"()\\\", the resulting string will have one prefix, that is an RBS: \\\"()\\\".\\n\\nIn the second example, you can concatenate the strings as follows: \\\"(\\\" + \\\")\\\" + \\\"()()())\\\" + \\\"(\\\" = \\\"()()()())(\\\", the resulting string will have four prefixes that are RBS: \\\"()\\\", \\\"()()\\\", \\\"()()()\\\", \\\"()()()()\\\".\\n\\nThe third and the fourth examples contain only one string each, so the order is fixed.\",\"targets\":\"#include \\nusing namespace std;\\nconst int64_t INF = 0x3f3f3f3f;\\nconst int64_t INFLL = 0x3f3f3f3f3f3f3f3f;\\nconst int64_t MOD = 1e9 + 7;\\nconst double EPS = 1e-9;\\nconst double PI = acos(-1);\\nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\\nint64_t rand(int64_t x, int64_t y) {\\n return uniform_int_distribution(x, y)(rng);\\n}\\nint64_t mul(int64_t a, int64_t b) {\\n int64_t ret = (1ll * (a % MOD) * (b % MOD)) % MOD;\\n return (ret + MOD) % MOD;\\n}\\nint64_t add(int64_t a, int64_t b) {\\n int64_t ret = (1ll * (a % MOD) + (b % MOD)) % MOD;\\n return (ret + MOD) % MOD;\\n}\\nint64_t pow_exp(int64_t n, int64_t p) {\\n if (!p) return 1;\\n if (p & 1) return mul(n, pow_exp(n, p - 1));\\n int64_t tmp = pow_exp(n, p \\/ 2);\\n return mul(tmp, tmp);\\n}\\nconst int64_t MAX = 2e5 + 10;\\nconst int64_t NMAX = 2e5 + 10;\\nconst int64_t MMAX = 2e5 + 10;\\nconst int64_t LOG_MAX = ceil(log2(double(NMAX)));\\nconst int64_t BLOCK = ceil(sqrt(double(NMAX)));\\nint64_t n;\\nstring str[20];\\nmap > mp[20];\\nint64_t tot[20];\\nint64_t mem[1 << 20];\\nint64_t go(int64_t msk, int64_t sm) {\\n if (msk + 1 == 1 << n) {\\n return 0;\\n }\\n int64_t &ret = mem[msk];\\n if (ret + 1) return ret;\\n int64_t ans = 0;\\n for (int64_t i = 0; i < n; i++)\\n if (((msk >> i) & 1) == 0) {\\n int64_t mn = mp[i].begin()->first;\\n if (sm + mn >= 0) {\\n int64_t cans = 0;\\n cans += go(msk ^ (1 << i), sm + tot[i]);\\n auto it = mp[i].find(-sm);\\n if (it != mp[i].end()) cans += it->second.size();\\n ans = max(ans, cans);\\n } else {\\n auto it = mp[i].find(-sm);\\n if (it == mp[i].end()) {\\n continue;\\n }\\n if (it == mp[i].begin()) {\\n int64_t cans = it->second.size();\\n ans = max(ans, cans);\\n } else {\\n auto &v = mp[i][-sm];\\n int64_t r = (--it)->second.front();\\n int64_t cans = lower_bound(v.begin(), v.end(), r) - v.begin();\\n ans = max(ans, cans);\\n }\\n }\\n }\\n return ret = ans;\\n}\\nint32_t main() {\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nThere are n heaps of stone. The i-th heap has h_i stones. You want to change the number of stones in the heap by performing the following process once: \\n\\n * You go through the heaps from the 3-rd heap to the n-th heap, in this order. \\n * Let i be the number of the current heap. \\n * You can choose a number d (0 ≤ 3 ⋅ d ≤ h_i), move d stones from the i-th heap to the (i - 1)-th heap, and 2 ⋅ d stones from the i-th heap to the (i - 2)-th heap. \\n * So after that h_i is decreased by 3 ⋅ d, h_{i - 1} is increased by d, and h_{i - 2} is increased by 2 ⋅ d. \\n * You can choose different or same d for different operations. Some heaps may become empty, but they still count as heaps. \\n\\n\\n\\nWhat is the maximum number of stones in the smallest heap after the process?\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 2⋅ 10^5). Description of the test cases follows.\\n\\nThe first line of each test case contains a single integer n (3 ≤ n ≤ 2 ⋅ 10^5).\\n\\nThe second lines of each test case contains n integers h_1, h_2, h_3, …, h_n (1 ≤ h_i ≤ 10^9).\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print the maximum number of stones that the smallest heap can contain.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n4\\n1 2 10 100\\n4\\n100 100 100 1\\n5\\n5 1 1 1 8\\n6\\n1 2 3 4 5 6\\n\\n\\nOutput\\n\\n\\n7\\n1\\n1\\n3\\n\\nNote\\n\\nIn the first test case, the initial heap sizes are [1, 2, 10, 100]. We can move the stones as follows. \\n\\n * move 3 stones and 6 from the 3-rd heap to the 2-nd and 1 heap respectively. The heap sizes will be [7, 5, 1, 100]; \\n * move 6 stones and 12 stones from the last heap to the 3-rd and 2-nd heap respectively. The heap sizes will be [7, 17, 7, 82]. \\n\\n\\n\\nIn the second test case, the last heap is 1, and we can not increase its size.\\n\\nIn the third test case, it is better not to move any stones.\\n\\nIn the last test case, the final achievable configuration of the heaps can be [3, 5, 3, 4, 3, 3].\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.util.*;\\n\\npublic class C {\\n static class RealScanner {\\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\\n StringTokenizer st = new StringTokenizer(\\\"\\\");\\n\\n String next() {\\n while (!st.hasMoreTokens())\\n try {\\n st = new StringTokenizer(br.readLine());\\n } catch (IOException e) {\\n e.printStackTrace();\\n }\\n return st.nextToken();\\n }\\n\\n int nextInt() {\\n return Integer.parseInt(next());\\n }\\n\\n int[] readArray(int n) {\\n int[] a = new int[n];\\n for (int i = 0; i < n; i++) a[i] = nextInt();\\n return a;\\n }\\n\\n long nextLong() {\\n return Long.parseLong(next());\\n }\\n }\\n\\n static List l = new ArrayList<>();\\n\\n static boolean ret(long mid, long n) {\\n long[] arr = new long[(int) n];\\n for (int i = 0; i < n; i++) {\\n arr[i] = l.get(i);\\n }\\n for (int i = (int) (n - 1); i >= 2; i--) {\\n if (arr[i] < mid) {\\n return false;\\n }\\n long min = Math.min(l.get(i), arr[i] - mid);\\n long div = min \\/ 3;\\n arr[i - 1] += div;\\n arr[i - 2] += 2 * div;\\n }\\n\\n return Math.min(arr[0], arr[1]) >= mid;\\n }\\n\\n public static void main(String[] args) {\\n RealScanner sc = new RealScanner();\\n int t = sc.nextInt();\\n while (t-- > 0) {\\n long n = sc.nextLong();\\n for (int i = 0; i < n; i++) {\\n l.add(sc.nextLong());\\n }\\n\\/\\/ List sub = new ArrayList<>();\\n\\/\\/ sub = l.subList(0, i + 1);\\n\\/\\/ int val = sub.get(sub.size() - 1);\\n\\/\\/ l.set(i, val % 3);\\n long low = 0, high = Collections.max(l) + 1;\\n while (low + 1 < high) {\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Monocarp is playing a computer game. Now he wants to complete the first level of this game.\\n\\nA level is a rectangular grid of 2 rows and n columns. Monocarp controls a character, which starts in cell (1, 1) — at the intersection of the 1-st row and the 1-st column.\\n\\nMonocarp's character can move from one cell to another in one step if the cells are adjacent by side and\\/or corner. Formally, it is possible to move from cell (x_1, y_1) to cell (x_2, y_2) in one step if |x_1 - x_2| ≤ 1 and |y_1 - y_2| ≤ 1. Obviously, it is prohibited to go outside the grid.\\n\\nThere are traps in some cells. If Monocarp's character finds himself in such a cell, he dies, and the game ends.\\n\\nTo complete a level, Monocarp's character should reach cell (2, n) — at the intersection of row 2 and column n.\\n\\nHelp Monocarp determine if it is possible to complete the level.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. Then the test cases follow. Each test case consists of three lines.\\n\\nThe first line contains a single integer n (3 ≤ n ≤ 100) — the number of columns.\\n\\nThe next two lines describe the level. The i-th of these lines describes the i-th line of the level — the line consists of the characters '0' and '1'. The character '0' corresponds to a safe cell, the character '1' corresponds to a trap cell.\\n\\nAdditional constraint on the input: cells (1, 1) and (2, n) are safe.\\n\\nOutput\\n\\nFor each test case, output YES if it is possible to complete the level, and NO otherwise.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n000\\n000\\n4\\n0011\\n1100\\n4\\n0111\\n1110\\n6\\n010101\\n101010\\n\\n\\nOutput\\n\\n\\nYES\\nYES\\nNO\\nYES\\n\\nNote\\n\\nConsider the example from the statement.\\n\\nIn the first test case, one of the possible paths is (1, 1) → (2, 2) → (2, 3).\\n\\nIn the second test case, one of the possible paths is (1, 1) → (1, 2) → (2, 3) → (2, 4).\\n\\nIn the fourth test case, one of the possible paths is (1, 1) → (2, 2) → (1, 3) → (2, 4) → (1, 5) → (2, 6).\",\"targets\":\"\\/\\/---#ON_MY_WAY---\\nimport static java.lang.Math.*;\\nimport java.io.*;\\nimport java.math.*;\\nimport java.util.*;\\n\\npublic class apples {\\n\\tstatic class pair {\\n\\t\\tint x, y;\\n\\n\\t\\tpublic pair(int a, int b) {\\n\\t\\t\\tx = a;\\n\\t\\t\\ty = b;\\n\\t\\t}\\n\\t}\\n\\n\\tstatic FastReader x = new FastReader();\\n\\tstatic OutputStream outputStream = System.out;\\n\\tstatic PrintWriter out = new PrintWriter(outputStream);\\n\\n\\t\\/*---------------------------------------CODE STARTS HERE-------------------------*\\/\\n\\tpublic static void main(String[] args) throws NumberFormatException, IOException {\\n\\t\\tlong startTime = System.nanoTime();\\n\\t\\tint mod = 1000000007;\\n\\t\\tint t = x.nextInt();\\n\\t\\tStringBuilder str = new StringBuilder();\\n\\t\\twhile (t > 0) {\\n\\t\\t\\tint n = x.nextInt();\\n\\t\\t\\tString a = x.next();\\n\\t\\t\\tString b = x.next();\\n\\t\\t\\tint f = 0;\\n\\t\\t\\tfor (int i = 0; i < n; i++) {\\n\\t\\t\\t\\tif(a.charAt(i)=='1'&&b.charAt(i)=='1') {\\n\\t\\t\\t\\t\\tf = 1;\\n\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\tif(f==1) str.append(\\\"NO\\\");\\n\\t\\t\\telse str.append(\\\"YES\\\");\\n\\t\\t\\tstr.append(\\\"\\\\n\\\");\\n\\t\\t\\tt--;\\n\\t\\t}\\n\\t\\tout.println(str);\\n\\t\\tout.flush();\\n\\t\\tlong endTime = System.nanoTime();\\n\\t\\t\\/\\/System.out.println((endTime-startTime)\\/1000000000.0);\\n\\t}\\n\\n\\t\\/*--------------------------------------------FAST I\\/O--------------------------------*\\/\\n\\tstatic class FastReader {\\n\\t\\tBufferedReader br;\\n\\t\\tStringTokenizer st;\\n\\n\\t\\tpublic FastReader() {\\n\\t\\t\\tbr = new BufferedReader(new InputStreamReader(System.in));\\n\\t\\t}\\n\\n\\t\\tString next() {\\n\\t\\t\\twhile (st == null || !st.hasMoreElements()) {\\n\\t\\t\\t\\ttry {\\n\\t\\t\\t\\t\\tst = new StringTokenizer(br.readLine());\\n\\t\\t\\t\\t} catch (IOException e) {\\n\\t\\t\\t\\t\\te.printStackTrace();\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\treturn st.nextToken();\\n\\t\\t}\\n\\n\\t\\tint nextInt() {\\n\\t\\t\\treturn Integer.parseInt(next());\\n\\t\\t}\\n\\n\\t\\tlong nextLong() {\\n\\t\\t\\treturn Long.parseLong(next());\\n\\t\\t}\\n\\n\\t\\tdouble nextDouble() {\\n\\t\\t\\treturn Double.parseDouble(next());\\n\\t\\t}\\n\\n\\t\\tString nextLine() {\\n\\t\\t\\tString str = \\\"\\\";\\n\\t\\t\\ttry {\\n\\t\\t\\t\\tstr = br.readLine();\\n\\t\\t\\t} catch (IOException e) {\\n\\t\\t\\t\\te.printStackTrace();\\n\\t\\t\\t}\\n\\t\\t\\treturn str;\\n\\t\\t}\\n\\n\\t\\tchar nextchar() {\\n\\t\\t\\tchar ch = ' ';\\n\\t\\t\\ttry {\\n\\t\\t\\t\\tch = (char) br.read();\\n\\t\\t\\t} catch (IOException e)...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 solution for \\\"Alice and Bob are playing a game on a matrix, consisting of 2 rows and m columns. The cell in the i-th row in the j-th column contains a_{i, j} coins in it.\\n\\nInitially, both Alice and Bob are standing in a cell (1, 1). They are going to perform a sequence of moves to reach a cell (2, m).\\n\\nThe possible moves are: \\n\\n * Move right — from some cell (x, y) to (x, y + 1); \\n * Move down — from some cell (x, y) to (x + 1, y). \\n\\n\\n\\nFirst, Alice makes all her moves until she reaches (2, m). She collects the coins in all cells she visit (including the starting cell).\\n\\nWhen Alice finishes, Bob starts his journey. He also performs the moves to reach (2, m) and collects the coins in all cells that he visited, but Alice didn't.\\n\\nThe score of the game is the total number of coins Bob collects.\\n\\nAlice wants to minimize the score. Bob wants to maximize the score. What will the score of the game be if both players play optimally?\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.\\n\\nThen the descriptions of t testcases follow.\\n\\nThe first line of the testcase contains a single integer m (1 ≤ m ≤ 10^5) — the number of columns of the matrix.\\n\\nThe i-th of the next 2 lines contain m integers a_{i,1}, a_{i,2}, ..., a_{i,m} (1 ≤ a_{i,j} ≤ 10^4) — the number of coins in the cell in the i-th row in the j-th column of the matrix.\\n\\nThe sum of m over all testcases doesn't exceed 10^5.\\n\\nOutput\\n\\nFor each testcase print a single integer — the score of the game if both players play optimally.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n3\\n1 3 7\\n3 5 1\\n3\\n1 3 9\\n3 5 1\\n1\\n4\\n7\\n\\n\\nOutput\\n\\n\\n7\\n8\\n0\\n\\nNote\\n\\nThe paths for the testcases are shown on the following pictures. Alice's path is depicted in red and Bob's path is depicted in blue.\\n\\n\\\":\",\"targets\":\"n = int(input())\\nfor i in range(n):\\n l1 = []\\n l2 = []\\n m = int(input())\\n g1 = input()\\n g1 = g1.split()\\n g2 = input()\\n g2 = g2.split()\\n for o in g1:\\n l1.append(int(o))\\n for o in g2:\\n l2.append(int(o))\\n\\n\\n s = sum(l1)\\n z1 = sum(l1) - l1[0]\\n z2 = 0\\n zaehler = -1\\n speicher = 1000000000\\n speicher2 = 1000000000\\n for x in range(len(l1) - 1):\\n z1 -= l1[x + 1]\\n z2 += l2[x]\\n if max(z1, z2) < speicher:\\n speicher = max(z1, z2)\\n if max(z1, z2) > speicher2:\\n break\\n speicher2 = speicher\\n\\n if speicher == 1000000000:\\n speicher = 0\\n elif speicher > sum(l1) - l1[0]:\\n speicher = sum(l1) - l1[0]\\n print(speicher)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A string is called square if it is some string written twice in a row. For example, the strings \\\"aa\\\", \\\"abcabc\\\", \\\"abab\\\" and \\\"baabaa\\\" are square. But the strings \\\"aaa\\\", \\\"abaaab\\\" and \\\"abcdabc\\\" are not square.\\n\\nFor a given string s determine if it is square.\\n\\nInput\\n\\nThe first line of input data contains an integer t (1 ≤ t ≤ 100) —the number of test cases.\\n\\nThis is followed by t lines, each containing a description of one test case. The given strings consist only of lowercase Latin letters and have lengths between 1 and 100 inclusive.\\n\\nOutput\\n\\nFor each test case, output on a separate line:\\n\\n * YES if the string in the corresponding test case is square, \\n * NO otherwise. \\n\\n\\n\\nYou can output YES and NO in any case (for example, strings yEs, yes, Yes and YES will be recognized as a positive response).\\n\\nExample\\n\\nInput\\n\\n\\n10\\na\\naa\\naaa\\naaaa\\nabab\\nabcabc\\nabacaba\\nxxyy\\nxyyx\\nxyxy\\n\\n\\nOutput\\n\\n\\nNO\\nYES\\nNO\\nYES\\nYES\\nYES\\nNO\\nNO\\nNO\\nYES\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\n\\npublic class Main {\\n public void solve() throws IOException {\\n int t=nextInt();\\n for (int i = 0; i < t; i++) {\\n String s=br.readLine();\\n if(s.length()%2!=0) out.println(\\\"NO\\\");\\n else{\\n String ans1=\\\"YES\\\";\\n char a[]=s.toCharArray();\\n for (int j = 0; j < s.length()\\/2; j++) {\\n if(a[j]!=a[j+s.length()\\/2]){\\n ans1=\\\"NO\\\";\\n break;\\n }\\n }\\n out.println(ans1);\\n }\\n }\\n out.close();\\n }\\n public void run() {\\n try {\\n br = new BufferedReader(new InputStreamReader(System.in));\\n out = new PrintWriter(System.out);\\n\\n solve();\\n\\n out.close();\\n } catch (IOException e) {\\n e.printStackTrace();\\n System.exit(1);\\n }\\n }\\n\\n BufferedReader br;\\n StringTokenizer in;\\n PrintWriter out;\\n\\n public String nextToken() throws IOException {\\n while (in == null || !in.hasMoreTokens()) {\\n in = new StringTokenizer(br.readLine());\\n }\\n return in.nextToken();\\n }\\n\\n public int nextInt() throws IOException {\\n return Integer.parseInt(nextToken());\\n }\\n\\n public double nextDouble() throws IOException {\\n return Double.parseDouble(nextToken());\\n }\\n\\n public long nextLong() throws IOException {\\n return Long.parseLong(nextToken());\\n }\\n\\n public static void main(String[] args) throws IOException {\\n Locale.setDefault(Locale.US);\\n new Main().run();\\n }\\n class gg implements Comparable {\\n long x;\\n long xlen;\\n\\n gg(long x, long xlen) {\\n this.x = x;\\n this.xlen = xlen;\\n }\\n\\n public int compareTo(gg other) {\\n return Long.compare(x, other.x);\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nModern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters.\\n\\nIn this problem you should implement the similar functionality.\\n\\nYou are given a string which only consists of:\\n\\n * uppercase and lowercase English letters, \\n * underscore symbols (they are used as separators), \\n * parentheses (both opening and closing). \\n\\n\\n\\nIt is guaranteed that each opening parenthesis has a succeeding closing parenthesis. Similarly, each closing parentheses has a preceding opening parentheses matching it. For each pair of matching parentheses there are no other parenthesis between them. In other words, each parenthesis in the string belongs to a matching \\\"opening-closing\\\" pair, and such pairs can't be nested.\\n\\nFor example, the following string is valid: \\\"_Hello_Vasya(and_Petya)__bye_(and_OK)\\\".\\n\\nWord is a maximal sequence of consecutive letters, i.e. such sequence that the first character to the left and the first character to the right of it is an underscore, a parenthesis, or it just does not exist. For example, the string above consists of seven words: \\\"Hello\\\", \\\"Vasya\\\", \\\"and\\\", \\\"Petya\\\", \\\"bye\\\", \\\"and\\\" and \\\"OK\\\". Write a program that finds:\\n\\n * the length of the longest word outside the parentheses (print 0, if there is no word outside the parentheses), \\n * the number of words inside the parentheses (print 0, if there is no word inside the parentheses). \\n\\nInput\\n\\nThe first line of the input contains a single integer n (1 ≤ n ≤ 255) — the length of the given string. The second line contains the string consisting of only lowercase and uppercase English letters, parentheses and underscore symbols. \\n\\nOutput\\n\\nPrint two space-separated integers:\\n\\n * the length of the longest word outside the parentheses (print 0, if there is no word outside the parentheses), \\n * the number of words inside the parentheses (print 0, if there is no word inside the parentheses)....\",\"targets\":\"#include \\nusing namespace std;\\nbool is(char c) { return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); }\\nint main() {\\n int n;\\n scanf(\\\"%d\\\", &n);\\n string str;\\n cin >> str;\\n int temp = 0;\\n bool word = false;\\n bool ok = true;\\n int mx = -1;\\n int qwe = 0;\\n for (int i = 0; i < n; ++i) {\\n if (is(str[i]) && ok) {\\n temp++;\\n } else {\\n mx = max(temp, mx);\\n temp = 0;\\n }\\n if (is(str[i]) && !ok) {\\n word = true;\\n }\\n if (!is(str[i]) && !ok && word) {\\n qwe++;\\n word = false;\\n }\\n if (!is(str[i]) && str[i] != '_') ok = !ok;\\n }\\n mx = max(mx, temp);\\n cout << mx << \\\" \\\" << qwe << endl;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"Polycarp likes squares and cubes of positive integers. Here is the beginning of the sequence of numbers he likes: 1, 4, 8, 9, ....\\n\\nFor a given number n, count the number of integers from 1 to n that Polycarp likes. In other words, find the number of such x that x is a square of a positive integer number or a cube of a positive integer number (or both a square and a cube simultaneously).\\n\\nInput\\n\\nThe first line contains an integer t (1 ≤ t ≤ 20) — the number of test cases.\\n\\nThen t lines contain the test cases, one per line. Each of the lines contains one integer n (1 ≤ n ≤ 10^9).\\n\\nOutput\\n\\nFor each test case, print the answer you are looking for — the number of integers from 1 to n that Polycarp likes.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n10\\n1\\n25\\n1000000000\\n999999999\\n500000000\\n\\n\\nOutput\\n\\n\\n4\\n1\\n6\\n32591\\n32590\\n23125\\\":\",\"targets\":\"import java.util.*;\\npublic class Main\\n{\\n\\tpublic static void main(String[] args) {\\n\\t\\tScanner sc=new Scanner(System.in);\\n\\t\\tint t=sc.nextInt();\\n\\t\\twhile(t-->0)\\n\\t\\t{\\n\\t\\tlong n=sc.nextLong();\\n\\t long ans=(long)Math.sqrt(n)+(long)Math.cbrt(n)-(long)Math.sqrt(Math.cbrt(n));\\n\\t\\n\\t\\tSystem.out.println(ans);\\n\\t\\t}\\n\\t}\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Theofanis has a riddle for you and if you manage to solve it, he will give you a Cypriot snack halloumi for free (Cypriot cheese).\\n\\nYou are given an integer n. You need to find two integers l and r such that -10^{18} ≤ l < r ≤ 10^{18} and l + (l + 1) + … + (r - 1) + r = n.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases.\\n\\nThe first and only line of each test case contains a single integer n (1 ≤ n ≤ 10^{18}).\\n\\nOutput\\n\\nFor each test case, print the two integers l and r such that -10^{18} ≤ l < r ≤ 10^{18} and l + (l + 1) + … + (r - 1) + r = n. \\n\\nIt can be proven that an answer always exists. If there are multiple answers, print any.\\n\\nExample\\n\\nInput\\n\\n\\n7\\n1\\n2\\n3\\n6\\n100\\n25\\n3000000000000\\n\\n\\nOutput\\n\\n\\n0 1\\n-1 2 \\n1 2 \\n1 3 \\n18 22\\n-2 7\\n999999999999 1000000000001\\n\\nNote\\n\\nIn the first test case, 0 + 1 = 1.\\n\\nIn the second test case, (-1) + 0 + 1 + 2 = 2.\\n\\nIn the fourth test case, 1 + 2 + 3 = 6.\\n\\nIn the fifth test case, 18 + 19 + 20 + 21 + 22 = 100.\\n\\nIn the sixth test case, (-2) + (-1) + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 = 25.\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.io.*;\\nimport java.util.StringTokenizer;\\n\\nimport static java.lang.Double.parseDouble;\\nimport static java.lang.Integer.parseInt;\\nimport static java.lang.Long.parseLong;\\nimport static java.lang.System.getProperty;\\nimport static java.lang.System.in;\\n\\npublic class Main {\\n\\n public static void main(String[] args) {\\n try (FastScanner scanner = getProperty(\\\"ONLINE_JUDGE\\\", \\\"\\\").isEmpty() ? new FastScanner(new File(\\\"test.txt\\\")) : new FastScanner(in)) {\\n int T = scanner.nextInt();\\n for (int t = 1; t <= T; ++t) {\\n long N = scanner.nextLong();\\n long[] s = new Main(N).solve();\\n System.out.print(s[0]);\\n System.out.print(\\\" \\\");\\n System.out.println(s[1]);\\n\\/*\\n long c = 0;\\n for (long i = s[0]; i <= s[1]; ++ i) {\\n c += i;\\n }\\n if (c != N) {\\n System.out.println(\\\"Error \\\" + c + \\\" \\\" + N);\\n }\\n*\\/\\n }\\n }\\n catch (Exception e) {\\n e.printStackTrace();\\n }\\n }\\n\\n private final long N;\\n\\n public Main(long n) {N = n;}\\n\\n public long[] solve() {\\n return solve(N, 1);\\n }\\n\\n public long[] solve(long n, long times) {\\n if (n % 2 == 1) {\\n long l = n \\/ 2 - (times - 1);\\n long r = n \\/ 2 + times;\\n return new long[]{l, r};\\n }\\n return solve(n \\/ 2, times * 2);\\n }\\n\\n static class FastScanner implements AutoCloseable {\\n final BufferedReader bufferedReader;\\n StringTokenizer stringTokenizer;\\n\\n private FastScanner(File file) throws FileNotFoundException {\\n bufferedReader = new BufferedReader(new FileReader(file));\\n }\\n\\n private FastScanner(InputStream in) {\\n bufferedReader = new BufferedReader(new InputStreamReader(in));\\n }\\n\\n @Override\\n public void close() throws Exception {\\n bufferedReader.close();\\n }\\n\\n public double...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A binary string is a string that consists of characters 0 and 1.\\n\\nLet \\\\operatorname{MEX} of a binary string be the smallest digit among 0, 1, or 2 that does not occur in the string. For example, \\\\operatorname{MEX} of 001011 is 2, because 0 and 1 occur in the string at least once, \\\\operatorname{MEX} of 1111 is 0, because 0 and 2 do not occur in the string and 0 < 2.\\n\\nA binary string s is given. You should cut it into any number of substrings such that each character is in exactly one substring. It is possible to cut the string into a single substring — the whole string.\\n\\nA string a is a substring of a string b if a can be obtained from b by deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end.\\n\\nWhat is the minimal sum of \\\\operatorname{MEX} of all substrings pieces can be?\\n\\nInput\\n\\nThe input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. Description of the test cases follows.\\n\\nEach test case contains a single binary string s (1 ≤ |s| ≤ 10^5).\\n\\nIt's guaranteed that the sum of lengths of s over all test cases does not exceed 10^5.\\n\\nOutput\\n\\nFor each test case print a single integer — the minimal sum of \\\\operatorname{MEX} of all substrings that it is possible to get by cutting s optimally.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n01\\n1111\\n01100\\n101\\n0000\\n01010\\n\\n\\nOutput\\n\\n\\n1\\n0\\n2\\n1\\n1\\n2\\n\\nNote\\n\\nIn the first test case the minimal sum is \\\\operatorname{MEX}(0) + \\\\operatorname{MEX}(1) = 1 + 0 = 1.\\n\\nIn the second test case the minimal sum is \\\\operatorname{MEX}(1111) = 0.\\n\\nIn the third test case the minimal sum is \\\\operatorname{MEX}(01100) = 2.\",\"targets\":\"\\/\\/package Codeforces;\\nimport java.util.*;\\nimport java.io.*;\\n\\npublic class template{\\n\\tstatic class FastScanner {\\n\\t\\tBufferedReader br=new BufferedReader(new InputStreamReader(System.in));\\n\\t\\tStringTokenizer st = new StringTokenizer(\\\"\\\");\\n\\t\\tString next () {\\n\\t\\t\\twhile(!st.hasMoreTokens()) {\\n\\t\\t\\t\\ttry {\\n\\t\\t\\t\\t\\tst=new StringTokenizer(br.readLine());\\n\\t\\t\\t\\t}catch(IOException e) {\\n\\t\\t\\t\\t\\te.printStackTrace();\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\treturn st.nextToken();\\n\\t\\t}\\n\\t\\t\\n\\t\\tint nextInt() {\\n\\t\\t\\treturn Integer.parseInt(next());\\n\\t\\t}\\n\\t\\t\\n\\t\\tint[] readArray(int n) {\\n\\t\\t\\tint a[] = new int[n];\\n\\t\\t\\tfor(int i=0;i0) {\\n\\t\\t\\t String s = sc.next();\\n\\t\\t\\t String onestr = s.replace(\\\"1\\\",\\\"\\\");\\n\\t\\t\\t String zerostr = s.replace(\\\"0\\\",\\\"\\\");\\n\\t\\t\\t if(zerostr.length() == 0) {\\n\\t\\t\\t\\t System.out.println(\\\"1\\\");\\n\\t\\t\\t\\t continue;\\n\\t\\t\\t }\\n\\t\\t\\t if(onestr.length() == 0) {\\n\\t\\t\\t\\t System.out.println(\\\"0\\\");\\n\\t\\t\\t\\t continue;\\n\\t\\t\\t }\\n\\t\\t\\t int count = 0;\\n\\t\\t\\t int c = 0;\\n\\t\\t\\t int i;\\n\\t\\t\\t for( i=0;i Illustration for the first example. The blue arc is the robot. The red star is the target dirty cell. Each second the robot cleans a row and a column, denoted by yellow stripes.\\n\\nGiven the floor size n and m, the robot's initial position (r_b, c_b) and the dirty cell's position (r_d, c_d), find the time for the robot to do its job.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^4). Description of the test cases follows.\\n\\nA test case consists of only one line, containing six integers n, m, r_b, c_b, r_d, and c_d (1 ≤ n, m ≤ 100, 1 ≤ r_b, r_d ≤ n, 1 ≤ c_b, c_d ≤ m) — the sizes of the room, the initial position of the robot and the position of the dirt cell.\\n\\nOutput\\n\\nFor each test case, print an integer — the time for the robot to clean the dirty cell. We can show that the robot always cleans the dirty cell eventually.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n10 10 6 1 2 8\\n10 10 9 9 1...\\nUsing python3 can you solve the prior task?\",\"targets\":\"for _ in range(int(input())):\\n n,m,rb,rd,cb,cd=map(int,input().split())\\n arr=[cb-rb,cd-rd,(2*n-cb-rb),(2*m-cd-rd)]\\n minm=10**8\\n for i in arr:\\n if i=0:\\n minm=i\\n print(minm)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You have an axis-aligned rectangle room with width W and height H, so the lower left corner is in point (0, 0) and the upper right corner is in (W, H).\\n\\nThere is a rectangular table standing in this room. The sides of the table are parallel to the walls, the lower left corner is in (x_1, y_1), and the upper right corner in (x_2, y_2).\\n\\nYou want to place another rectangular table in this room with width w and height h with the width of the table parallel to the width of the room.\\n\\nThe problem is that sometimes there is not enough space to place the second table without intersecting with the first one (there are no problems with tables touching, though).\\n\\nYou can't rotate any of the tables, but you can move the first table inside the room. \\n\\n Example of how you may move the first table.\\n\\nWhat is the minimum distance you should move the first table to free enough space for the second one?\\n\\nInput\\n\\nThe first line contains the single integer t (1 ≤ t ≤ 5000) — the number of the test cases.\\n\\nThe first line of each test case contains two integers W and H (1 ≤ W, H ≤ 10^8) — the width and the height of the room.\\n\\nThe second line contains four integers x_1, y_1, x_2 and y_2 (0 ≤ x_1 < x_2 ≤ W; 0 ≤ y_1 < y_2 ≤ H) — the coordinates of the corners of the first table.\\n\\nThe third line contains two integers w and h (1 ≤ w ≤ W; 1 ≤ h ≤ H) — the width and the height of the second table.\\n\\nOutput\\n\\nFor each test case, print the minimum distance you should move the first table, or -1 if there is no way to free enough space for the second table.\\n\\nYour answer will be considered correct if its absolute or relative error doesn't exceed 10^{-6}.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n8 5\\n2 1 7 4\\n4 2\\n5 4\\n2 2 5 4\\n3 3\\n1 8\\n0 3 1 6\\n1 5\\n8 1\\n3 0 6 1\\n5 1\\n8 10\\n4 5 7 8\\n8 5\\n\\n\\nOutput\\n\\n\\n1.000000000\\n-1\\n2.000000000\\n2.000000000\\n0.000000000\\n\\nNote\\n\\nThe configuration of the first test case is shown in the picture. But the movement of the first table is not optimal. One of the optimal movement, for example, is to move the table by (0, -1), so the lower left corner...\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint32_t main() {\\n ios::sync_with_stdio(0);\\n cin.tie(0);\\n long long t = 1;\\n cin >> t;\\n while (t--) {\\n long long w, h;\\n cin >> w >> h;\\n long long x1, y1, x2, y2;\\n cin >> x1 >> y1 >> x2 >> y2;\\n long long w1 = x2 - x1;\\n long long h1 = y2 - y1;\\n long long w2, h2;\\n cin >> w2 >> h2;\\n if (w1 + w2 > w && h1 + h2 > h) {\\n cout << -1;\\n cout << \\\"\\\\n\\\";\\n continue;\\n }\\n long long ans = 0;\\n if (w1 + w2 <= w && h1 + h2 <= h) {\\n ans = min(min(w2 - x1, w2 - (w - x2)), min(h2 - y1, h2 - (h - y2)));\\n } else {\\n if (w1 + w2 <= w) {\\n ans = min(w2 - x1, w2 - (w - x2));\\n } else if (h1 + h2 <= h) {\\n ans = min(h2 - y1, h2 - (h - y2));\\n }\\n }\\n cout << fixed << setprecision(9) << (double)max(0ll, ans);\\n cout << \\\"\\\\n\\\";\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error.\\n\\nKirill has already made his measurements, and has got the following integer values: x1, x2, ..., xn. It is important that the values are close to each other, namely, the difference between the maximum value and the minimum value is at most 2.\\n\\nAnya does not want to make the measurements, however, she can't just copy the values from Kirill's work, because the error of each measurement is a random value, and this coincidence will be noted by the teacher. Anya wants to write such integer values y1, y2, ..., yn in her work, that the following conditions are met:\\n\\n * the average value of x1, x2, ..., xn is equal to the average value of y1, y2, ..., yn;\\n * all Anya's measurements are in the same bounds as all Kirill's measurements, that is, the maximum value among Anya's values is not greater than the maximum value among Kirill's values, and the minimum value among Anya's values is not less than the minimum value among Kirill's values;\\n * the number of equal measurements in Anya's work and Kirill's work is as small as possible among options with the previous conditions met. Formally, the teacher goes through all Anya's values one by one, if there is equal value in Kirill's work and it is not strike off yet, he strikes off this Anya's value and one of equal values in Kirill's work. The number of equal measurements is then the total number of strike off values in Anya's work. \\n\\n\\n\\nHelp Anya to write such a set of measurements that the conditions above are met.\\n\\nInput\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 100 000) — the numeber of measurements made by Kirill.\\n\\nThe second line contains a sequence of integers x1, x2, ..., xn ( - 100 000 ≤ xi ≤ 100 000) — the measurements made by Kirill. It is guaranteed that the difference between the maximum and minimum values among values x1, x2, ..., xn does not exceed 2.\\n\\nOutput\\n\\nIn the first line...\\nimpor\",\"targets\":\"t java.util.*;\\nimport java.io.*;\\nimport java.math.*;\\nimport java.util.regex.*;\\n\\npublic class Main {\\n\\n static Scanner input = new Scanner(new BufferedReader(new InputStreamReader(System.in)));\\n static Reader fastInput = new Reader();\\n\\n public static void main(String[] args) throws IOException {\\n int n = fastInput.nextInt();\\n int[] x = new int[n];\\n int minV = Integer.MAX_VALUE;\\n int maxV = Integer.MIN_VALUE;\\n\\n for (int i = 0; i < n; i++) {\\n x[i] = fastInput.nextInt();\\n maxV = Math.max(maxV, x[i]);\\n minV = Math.min(minV, x[i]);\\n }\\n if (maxV - minV < 2) {\\n System.out.println(x.length);\\n System.out.println(Arrays.toString(x).replaceAll(\\\"[,\\\\\\\\[\\\\\\\\]]\\\", \\\"\\\"));\\n } else {\\n int[] y = new int[n];\\n int mid = (maxV + minV) \\/ 2;\\n int maxQ = 0;\\n int minQ = 0;\\n for (int i = 0; i < n; i++) {\\n if (x[i] == minV) {\\n minQ++;\\n } else if (x[i] == maxV) {\\n maxQ++;\\n }\\n }\\n int coef, coef1, coef2, newMaxQ, newMinQ, newMidQ;\\n {\\n newMaxQ = maxQ - Math.min(maxQ, minQ);\\n newMinQ = minQ - Math.min(maxQ, minQ);\\n newMidQ = n - newMinQ - newMaxQ;\\n coef1 = newMaxQ + newMinQ + n - maxQ - minQ;\\n }\\n {\\n newMaxQ = maxQ + (n - maxQ - minQ) \\/ 2;\\n newMinQ = minQ + (n - maxQ - minQ) \\/ 2;\\n newMidQ = n - newMinQ - newMaxQ;\\n coef2 = maxQ + minQ + newMidQ;\\n }\\n if (coef1 < coef2) {\\n newMaxQ = maxQ - Math.min(maxQ, minQ);\\n newMinQ = minQ - Math.min(maxQ, minQ);\\n newMidQ = n - newMinQ - newMaxQ;\\n coef = newMaxQ + newMinQ + n - maxQ - minQ;\\n } else {\\n newMaxQ = maxQ + (n - maxQ - minQ) \\/ 2;\\n newMinQ = minQ + (n - maxQ -...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"According to an old legeng, a long time ago Ankh-Morpork residents did something wrong to miss Fortune, and she cursed them. She said that at some time n snacks of distinct sizes will fall on the city, and the residents should build a Snacktower of them by placing snacks one on another. Of course, big snacks should be at the bottom of the tower, while small snacks should be at the top.\\n\\nYears passed, and once different snacks started to fall onto the city, and the residents began to build the Snacktower.\\n\\n\\n\\nHowever, they faced some troubles. Each day exactly one snack fell onto the city, but their order was strange. So, at some days the residents weren't able to put the new stack on the top of the Snacktower: they had to wait until all the bigger snacks fell. Of course, in order to not to anger miss Fortune again, the residents placed each snack on the top of the tower immediately as they could do it.\\n\\nWrite a program that models the behavior of Ankh-Morpork residents.\\n\\nInput\\n\\nThe first line contains single integer n (1 ≤ n ≤ 100 000) — the total number of snacks.\\n\\nThe second line contains n integers, the i-th of them equals the size of the snack which fell on the i-th day. Sizes are distinct integers from 1 to n. \\n\\nOutput\\n\\nPrint n lines. On the i-th of them print the sizes of the snacks which the residents placed on the top of the Snacktower on the i-th day in the order they will do that. If no snack is placed on some day, leave the corresponding line empty.\\n\\nExamples\\n\\nInput\\n\\n3\\n3 1 2\\n\\n\\nOutput\\n\\n3\\n \\n2 1\\n\\nInput\\n\\n5\\n4 5 1 2 3\\n\\n\\nOutput\\n\\n \\n5 4\\n \\n \\n3 2 1\\n\\nNote\\n\\nIn the example a snack of size 3 fell on the first day, and the residents immediately placed it. On the second day a snack of size 1 fell, and the residents weren't able to place it because they were missing the snack of size 2. On the third day a snack of size 2 fell, and the residents immediately placed it. Right after that they placed the snack of size 1 which had fallen before.\\nThe above is tricky. Write me a correct solution in PYTHON.\",\"targets\":\"n = input()\\nx = [int(i) for i in raw_input().split()]\\n\\narrived = [False] * (n+1) # 1 ~ n\\ncurrent = n\\n\\nfor i in x:\\n arrived[i] = True\\n \\n if i == current:\\n \\n ans = str(current) + ' '\\n current -= 1\\n \\n \\n \\n while current > 0 and arrived[current] is True:\\n ans += (str(current) + ' ')\\n current -= 1\\n\\n print ans\\n else:\\n print\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"An identity permutation of length n is an array [1, 2, 3, ..., n].\\n\\nWe performed the following operations to an identity permutation of length n:\\n\\n * firstly, we cyclically shifted it to the right by k positions, where k is unknown to you (the only thing you know is that 0 ≤ k ≤ n - 1). When an array is cyclically shifted to the right by k positions, the resulting array is formed by taking k last elements of the original array (without changing their relative order), and then appending n - k first elements to the right of them (without changing relative order of the first n - k elements as well). For example, if we cyclically shift the identity permutation of length 6 by 2 positions, we get the array [5, 6, 1, 2, 3, 4]; \\n * secondly, we performed the following operation at most m times: pick any two elements of the array and swap them. \\n\\n\\n\\nYou are given the values of n and m, and the resulting array. Your task is to find all possible values of k in the cyclic shift operation.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10^5) — the number of test cases.\\n\\nEach test case consists of two lines. The first line contains two integers n and m (3 ≤ n ≤ 3 ⋅ 10^5; 0 ≤ m ≤ n\\/3).\\n\\nThe second line contains n integers p_1, p_2, ..., p_n (1 ≤ p_i ≤ n, each integer from 1 to n appears in this sequence exactly once) — the resulting array.\\n\\nThe sum of n over all test cases does not exceed 3 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print the answer in the following way:\\n\\n * firstly, print one integer r (0 ≤ r ≤ n) — the number of possible values of k for the cyclic shift operation; \\n * secondly, print r integers k_1, k_2, ..., k_r (0 ≤ k_i ≤ n - 1) — all possible values of k in increasing order. \\n\\nExample\\n\\nInput\\n\\n\\n4\\n4 1\\n2 3 1 4\\n3 1\\n1 2 3\\n3 1\\n3 2 1\\n6 0\\n1 2 3 4 6 5\\n\\n\\nOutput\\n\\n\\n1 3\\n1 0\\n3 0 1 2\\n0\\n\\nNote\\n\\nConsider the example: \\n\\n * in the first test case, the only possible value for the cyclic shift is 3. If we shift [1, 2, 3, 4] by 3 positions, we get [2, 3, 4, 1]. Then we can swap the 3-rd and the 4-th elements to get the...\\nSolve the task in PYTHON3.\",\"targets\":\"def solve(k):\\n q = p[k:] + p[:k]\\n visited = [False] * n\\n cnt = 0\\n for i in range(n):\\n t = i\\n if not visited[t]:\\n cnt += 1\\n while not visited[t]:\\n visited[t] = True\\n t = q[t]\\n return n - cnt <= m\\n\\n\\nfor _ in range(int(input())):\\n n, m = [int(x) for x in input().split()]\\n p = [int(x) - 1 for x in input().split()]\\n good_k = {}\\n ans = []\\n for i in range(n):\\n k = (i - p[i] + n) % n\\n good_k[k] = good_k[k] + 1 if k in good_k else 1\\n for k in good_k:\\n if good_k[k] >= n - 2 * m:\\n if solve(k):\\n ans.append(k)\\n ans.sort()\\n print(len(ans), *ans)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nThe robot is located on a checkered rectangular board of size n × m (n rows, m columns). The rows in the board are numbered from 1 to n from top to bottom, and the columns — from 1 to m from left to right.\\n\\nThe robot is able to move from the current cell to one of the four cells adjacent by side.\\n\\nThe sequence of commands s executed by the robot is given. Each command is denoted by one of the symbols 'L', 'R', 'D' or 'U', and triggers the movement to left, right, down or up, respectively.\\n\\nThe robot can start its movement in any cell. The robot executes the commands starting from the first one, strictly in the order in which they are listed in s. If the robot moves beyond the edge of the board, it falls and breaks. A command that causes the robot to break is not considered successfully executed.\\n\\nThe robot's task is to execute as many commands as possible without falling off the board. For example, on board 3 × 3, if the robot starts a sequence of actions s=\\\"RRDLUU\\\" (\\\"right\\\", \\\"right\\\", \\\"down\\\", \\\"left\\\", \\\"up\\\", \\\"up\\\") from the central cell, the robot will perform one command, then the next command will force him to cross the edge. If the robot starts moving from the cell (2, 1) (second row, first column) then all commands will be executed successfully and the robot will stop at the cell (1, 2) (first row, second column).\\n\\n The robot starts from cell (2, 1) (second row, first column). It moves right, right, down, left, up, and up. In this case it ends in the cell (1, 2) (first row, second column).\\n\\nDetermine the cell from which the robot should start its movement in order to execute as many commands as possible.\\n\\nInput\\n\\nThe first line contains an integer t (1 ≤ t ≤ 10^4) — the number of test cases.\\n\\nThe next 2t lines contain descriptions of the test cases.\\n\\nIn the description of each test case, the first line contains two integers n and m (1 ≤ n, m ≤ 10^6) — the height and width of the field that the robot is located on. The second line of the description is a string s consisting solely of characters 'L',...\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\n\\n\\/\\/\\/\\/***************************************************************************\\n \\/* public class E_Gardener_and_Tree implements Runnable{\\n\\n public static void main(String[] args) throws Exception {\\n new Thread(null, new E_Gardener_and_Tree(), \\\"E_Gardener_and_Tree\\\", 1<<28).start();\\n }\\n public void run(){\\n WRITE YOUR CODE HERE!!!!\\n JUST WRITE EVERYTHING HERE WHICH YOU WRITE IN MAIN!!!\\n }\\n\\n }\\n*\\/\\n\\/\\/\\/\\/\\/**************************************************************************\\n\\n\\npublic class E_Robot_on_the_Board_1{\\n public static void main(String[] args) {\\n FastScanner s= new FastScanner();\\n \\/\\/ PrintWriter out=new PrintWriter(System.out);\\n \\/\\/end of program\\n \\/\\/out.println(answer);\\n \\/\\/out.close();\\n StringBuilder res = new StringBuilder();\\n int t=s.nextInt();\\n int p=0;\\n while(p=maxh){\\n break;\\n }\\n else{\\n l2=o2;\\n }\\n }\\n else if(str.charAt(i)=='L'){\\n currl--;\\n long o2=Math.min(l1,currl);\\n if(l2-o2>=maxh){\\n break;\\n }\\n else{\\n l1=o2;\\n }\\n }\\n else if(str.charAt(i)=='U'){\\n curru++;\\n long o2=Math.max(u2,curru);\\n if(o2-u1>=maxy){\\n break;\\n }\\n else{\\n u2=o2;\\n }\\n }\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"You are given a sequence a_1, a_2, ..., a_n consisting of n pairwise distinct positive integers.\\n\\nFind \\\\left⌊ \\\\frac n 2 \\\\right⌋ different pairs of integers x and y such that: \\n\\n * x ≠ y; \\n * x and y appear in a; \\n * x~mod~y doesn't appear in a. \\n\\n\\n\\nNote that some x or y can belong to multiple pairs.\\n\\n⌊ x ⌋ denotes the floor function — the largest integer less than or equal to x. x~mod~y denotes the remainder from dividing x by y.\\n\\nIf there are multiple solutions, print any of them. It can be shown that at least one solution always exists.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.\\n\\nThe first line of each testcase contains a single integer n (2 ≤ n ≤ 2 ⋅ 10^5) — the length of the sequence.\\n\\nThe second line of each testcase contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^6).\\n\\nAll numbers in the sequence are pairwise distinct. The sum of n over all testcases doesn't exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nThe answer for each testcase should contain \\\\left⌊ \\\\frac n 2 \\\\right⌋ different pairs of integers x and y such that x ≠ y, x and y appear in a and x~mod~y doesn't appear in a. Print the pairs one after another.\\n\\nYou can print the pairs in any order. However, the order of numbers in the pair should be exactly such that the first number is x and the second number is y. All pairs should be pairwise distinct.\\n\\nIf there are multiple solutions, print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n2\\n1 4\\n4\\n2 8 3 4\\n5\\n3 8 5 9 7\\n6\\n2 7 5 3 4 8\\n\\n\\nOutput\\n\\n\\n4 1\\n8 2\\n8 4\\n9 5\\n7 5\\n8 7\\n4 3\\n5 2\\n\\nNote\\n\\nIn the first testcase there are only two pairs: (1, 4) and (4, 1). \\\\left⌊ \\\\frac 2 2 \\\\right⌋=1, so we have to find one pair. 1~mod~4=1, and 1 appears in a, so that pair is invalid. Thus, the only possible answer is a pair (4, 1).\\n\\nIn the second testcase, we chose pairs 8~mod~2=0 and 8~mod~4=0. 0 doesn't appear in a, so that answer is valid. There are multiple possible answers for that testcase.\\n\\nIn the third testcase, the chosen pairs are 9~mod~5=4 and 7~mod~5=2. Neither 4, nor 2, appears in a, so that...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n ios::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n int t;\\n cin >> t;\\n while (t--) {\\n long long n;\\n cin >> n;\\n vector v(n);\\n for (long long i = 0; i < n; i++) cin >> v[i];\\n sort(v.begin(), v.end());\\n unordered_set st(v.begin(), v.end());\\n long long req = n \\/ 2;\\n for (long long i = 0; i < n; i++) {\\n for (long long j = i + 1; j < n; j++) {\\n if (st.find(v[j] % v[i]) == st.end()) {\\n cout << v[j] << \\\" \\\" << v[i] << endl;\\n req--;\\n }\\n if (req == 0) break;\\n }\\n if (req == 0) break;\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Polycarp had an array a of 3 positive integers. He wrote out the sums of all non-empty subsequences of this array, sorted them in non-decreasing order, and got an array b of 7 integers.\\n\\nFor example, if a = \\\\{1, 4, 3\\\\}, then Polycarp wrote out 1, 4, 3, 1 + 4 = 5, 1 + 3 = 4, 4 + 3 = 7, 1 + 4 + 3 = 8. After sorting, he got an array b = \\\\{1, 3, 4, 4, 5, 7, 8\\\\}.\\n\\nUnfortunately, Polycarp lost the array a. He only has the array b left. Help him to restore the array a.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 5000) — the number of test cases.\\n\\nEach test case consists of one line which contains 7 integers b_1, b_2, ..., b_7 (1 ≤ b_i ≤ 10^9; b_i ≤ b_{i+1}). \\n\\nAdditional constraint on the input: there exists at least one array a which yields this array b as described in the statement.\\n\\nOutput\\n\\nFor each test case, print 3 integers — a_1, a_2 and a_3. If there can be several answers, print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n1 3 4 4 5 7 8\\n1 2 3 4 5 6 7\\n300000000 300000000 300000000 600000000 600000000 600000000 900000000\\n1 1 2 999999998 999999999 999999999 1000000000\\n1 2 2 3 3 4 5\\n\\n\\nOutput\\n\\n\\n1 4 3\\n4 1 2\\n300000000 300000000 300000000\\n999999998 1 1\\n1 2 2\\n\\nNote\\n\\nThe subsequence of the array a is a sequence that can be obtained from a by removing zero or more of its elements.\\n\\nTwo subsequences are considered different if index sets of elements included in them are different. That is, the values of the elements don't matter in the comparison of subsequences. In particular, any array of length 3 has exactly 7 different non-empty subsequences.\",\"targets\":\"#include \\nusing namespace std;\\nint main(int argc, char *argv[]) {\\n int t;\\n cin >> t;\\n int A[7];\\n while (t--) {\\n for (int i = 0; i < 7; i++) cin >> A[i];\\n vector ans;\\n ans.push_back(A[0]);\\n ans.push_back(A[1]);\\n if (A[0] + A[1] > A[2])\\n ans.push_back(A[2]);\\n else\\n ans.push_back(A[3]);\\n for (int vals : ans) cout << vals << \\\" \\\";\\n puts(\\\"\\\");\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nA robot cleaner is placed on the floor of a rectangle room, surrounded by walls. The floor consists of n rows and m columns. The rows of the floor are numbered from 1 to n from top to bottom, and columns of the floor are numbered from 1 to m from left to right. The cell on the intersection of the r-th row and the c-th column is denoted as (r,c). The initial position of the robot is (r_b, c_b).\\n\\nIn one second, the robot moves by dr rows and dc columns, that is, after one second, the robot moves from the cell (r, c) to (r + dr, c + dc). Initially dr = 1, dc = 1. If there is a vertical wall (the left or the right walls) in the movement direction, dc is reflected before the movement, so the new value of dc is -dc. And if there is a horizontal wall (the upper or lower walls), dr is reflected before the movement, so the new value of dr is -dr.\\n\\nEach second (including the moment before the robot starts moving), the robot cleans every cell lying in the same row or the same column as its position. There is only one dirty cell at (r_d, c_d). The job of the robot is to clean that dirty cell.\\n\\n Illustration for the first example. The blue arc is the robot. The red star is the target dirty cell. Each second the robot cleans a row and a column, denoted by yellow stripes.\\n\\nGiven the floor size n and m, the robot's initial position (r_b, c_b) and the dirty cell's position (r_d, c_d), find the time for the robot to do its job.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^4). Description of the test cases follows.\\n\\nA test case consists of only one line, containing six integers n, m, r_b, c_b, r_d, and c_d (1 ≤ n, m ≤ 100, 1 ≤ r_b, r_d ≤ n, 1 ≤ c_b, c_d ≤ m) — the sizes of the room, the initial position of the robot and the position of the dirt cell.\\n\\nOutput\\n\\nFor each test case, print an integer — the time for the robot to clean the dirty cell. We can show that the robot always cleans the dirty cell eventually.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n10 10 6 1 2 8\\n10 10 9 9 1...\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n ;\\n int T;\\n cin >> T;\\n while (T--) {\\n int n, m, rb, cb, rd, cd;\\n cin >> n >> m >> rb >> cb >> rd >> cd;\\n int ans = 0, rc = 1, cc = 1;\\n while (rb != rd && cb != cd) {\\n if (1 <= rb && n >= rb && 1 <= cb && m >= cb) ans++;\\n if (rb + rc > n) rc = -1;\\n if (rb + rc < 1) rc = 1;\\n if (cb + cc > m) cc = -1;\\n if (cb + cc < 1) cc = 1;\\n rb += rc;\\n cb += cc;\\n }\\n cout << ans << '\\\\n';\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Polycarp has come up with a new game to play with you. He calls it \\\"A missing bigram\\\".\\n\\nA bigram of a word is a sequence of two adjacent letters in it.\\n\\nFor example, word \\\"abbaaba\\\" contains bigrams \\\"ab\\\", \\\"bb\\\", \\\"ba\\\", \\\"aa\\\", \\\"ab\\\" and \\\"ba\\\".\\n\\nThe game goes as follows. First, Polycarp comes up with a word, consisting only of lowercase letters 'a' and 'b'. Then, he writes down all its bigrams on a whiteboard in the same order as they appear in the word. After that, he wipes one of them off the whiteboard.\\n\\nFinally, Polycarp invites you to guess what the word that he has come up with was.\\n\\nYour goal is to find any word such that it's possible to write down all its bigrams and remove one of them, so that the resulting sequence of bigrams is the same as the one Polycarp ended up with.\\n\\nThe tests are generated in such a way that the answer exists. If there are multiple answers, you can print any of them.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 2000) — the number of testcases.\\n\\nThe first line of each testcase contains a single integer n (3 ≤ n ≤ 100) — the length of the word Polycarp has come up with.\\n\\nThe second line of each testcase contains n-2 bigrams of that word, separated by a single space. Each bigram consists of two letters, each of them is either 'a' or 'b'.\\n\\nAdditional constraint on the input: there exists at least one string such that it is possible to write down all its bigrams, except one, so that the resulting sequence is the same as the sequence in the input. In other words, the answer exists.\\n\\nOutput\\n\\nFor each testcase print a word, consisting of n letters, each of them should be either 'a' or 'b'. It should be possible to write down all its bigrams and remove one of them, so that the resulting sequence of bigrams is the same as the one Polycarp ended up with.\\n\\nThe tests are generated in such a way that the answer exists. If there are multiple answers, you can print any of them. \\n\\nExample\\n\\nInput\\n\\n\\n4\\n7\\nab bb ba aa ba\\n7\\nab ba aa ab ba\\n3\\naa\\n5\\nbb ab...\\nimpor\",\"targets\":\"t java.util.*;\\nimport java.io.*;\\n\\npublic class B_Missing_Bigram {\\n public static void main(String[] args) {\\n Scanner sc = new Scanner(System.in);\\n int t = sc.nextInt();\\n while (t-- > 0) {\\n int n = sc.nextInt();\\n String[] arr = new String[n - 2];\\n for (int i = 0; i < arr.length; i++) {\\n arr[i] = sc.next();\\n }\\n String ans = \\\"\\\";\\n boolean found = false;\\n for (int i = 0; i < n - 3; i++) {\\n ans += arr[i].charAt(0);\\n if (arr[i].charAt(1) != arr[i + 1].charAt(0)) {\\n ans += arr[i].charAt(1);\\n found = true;\\n }\\n }\\n ans += arr[n - 3];\\n if (!found) {\\n ans += 'a';\\n }\\n System.out.println(ans);\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Polycarp has come up with a new game to play with you. He calls it \\\"A missing bigram\\\".\\n\\nA bigram of a word is a sequence of two adjacent letters in it.\\n\\nFor example, word \\\"abbaaba\\\" contains bigrams \\\"ab\\\", \\\"bb\\\", \\\"ba\\\", \\\"aa\\\", \\\"ab\\\" and \\\"ba\\\".\\n\\nThe game goes as follows. First, Polycarp comes up with a word, consisting only of lowercase letters 'a' and 'b'. Then, he writes down all its bigrams on a whiteboard in the same order as they appear in the word. After that, he wipes one of them off the whiteboard.\\n\\nFinally, Polycarp invites you to guess what the word that he has come up with was.\\n\\nYour goal is to find any word such that it's possible to write down all its bigrams and remove one of them, so that the resulting sequence of bigrams is the same as the one Polycarp ended up with.\\n\\nThe tests are generated in such a way that the answer exists. If there are multiple answers, you can print any of them.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 2000) — the number of testcases.\\n\\nThe first line of each testcase contains a single integer n (3 ≤ n ≤ 100) — the length of the word Polycarp has come up with.\\n\\nThe second line of each testcase contains n-2 bigrams of that word, separated by a single space. Each bigram consists of two letters, each of them is either 'a' or 'b'.\\n\\nAdditional constraint on the input: there exists at least one string such that it is possible to write down all its bigrams, except one, so that the resulting sequence is the same as the sequence in the input. In other words, the answer exists.\\n\\nOutput\\n\\nFor each testcase print a word, consisting of n letters, each of them should be either 'a' or 'b'. It should be possible to write down all its bigrams and remove one of them, so that the resulting sequence of bigrams is the same as the one Polycarp ended up with.\\n\\nThe tests are generated in such a way that the answer exists. If there are multiple answers, you can print any of them. \\n\\nExample\\n\\nInput\\n\\n\\n4\\n7\\nab bb ba aa ba\\n7\\nab ba aa ab ba\\n3\\naa\\n5\\nbb ab...\\n\\/\\/\",\"targets\":\"package faltu;\\nimport java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\n\\/\\/import java.security.KeyStore.Entry;\\nimport java.util.*;\\nimport java.util.Map.Entry;\\n\\npublic class Main {\\n static long LowerBound(long[] a2, long x) { \\/\\/ x is the target value or key\\n\\t int l=-1,r=a2.length;\\n\\t while(l+1>>1;\\n\\t if(a2[m]>=x) r=m;\\n\\t else l=m;\\n\\t }\\n\\t return r;\\n\\t}\\n static int UpperBound(int a[], int x) {\\/\\/ x is the key or target value\\n\\t int l=-1,r=a.length;\\n\\t while(l+1>>1;\\n\\t if(a[m]<=x) l=m;\\n\\t else r=m;\\n\\t }\\n\\t return l+1;\\n }\\n public static long getClosest(long val1, long val2,long target)\\n\\t{\\n\\t\\tif (target - val1 >= val2 - target)\\n\\t\\treturn val2; \\n\\t\\telse\\n\\t\\treturn val1; \\n\\t}\\n static void ruffleSort(long[] a) {\\n\\t\\tint n=a.length;\\n\\t\\tRandom r=new Random();\\n\\t\\tfor (int i=0; i\\nusing namespace std;\\nconst int maxn = 5e5 + 10;\\nlong long int n, a[maxn], nx[maxn], pr[maxn];\\nvector > v;\\nint main() {\\n cin >> n;\\n for (int i = 0; i < n; i++) {\\n cin >> a[i];\\n nx[i] = i + 1;\\n pr[i] = i - 1;\\n v.push_back(make_pair(a[i], i));\\n }\\n long long int l = 0, r = n - 1;\\n long long int answer = 0;\\n sort(v.begin(), v.end());\\n for (int i = 0; i < n - 2; i++) {\\n long long int x = v[i].first;\\n long long int j = v[i].second;\\n if (j == l) {\\n answer += x;\\n l = nx[j];\\n } else if (j == r) {\\n answer += x;\\n r = pr[j];\\n } else {\\n answer += min(a[pr[j]], a[nx[j]]);\\n nx[pr[j]] = nx[j];\\n pr[nx[j]] = pr[j];\\n }\\n }\\n cout << answer;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"YouKn0wWho has an integer sequence a_1, a_2, … a_n. Now he will split the sequence a into one or more consecutive subarrays so that each element of a belongs to exactly one subarray. Let k be the number of resulting subarrays, and h_1, h_2, …, h_k be the lengths of the longest increasing subsequences of corresponding subarrays.\\n\\nFor example, if we split [2, 5, 3, 1, 4, 3, 2, 2, 5, 1] into [2, 5, 3, 1, 4], [3, 2, 2, 5], [1], then h = [3, 2, 1].\\n\\nYouKn0wWho wonders if it is possible to split the sequence a in such a way that the [bitwise XOR](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#XOR) of h_1, h_2, …, h_k is equal to 0. You have to tell whether it is possible.\\n\\nThe longest increasing subsequence (LIS) of a sequence b_1, b_2, …, b_m is the longest sequence of valid indices i_1, i_2, …, i_k such that i_1 < i_2 < … < i_k and b_{i_1} < b_{i_2} < … < b_{i_k}. For example, the LIS of [2, 5, 3, 3, 5] is [2, 3, 5], which has length 3.\\n\\nAn array c is a subarray of an array b if c can be obtained from b by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10 000) — the number of test cases.\\n\\nThe first line of each test case contains a single integer n (2 ≤ n ≤ 10^5).\\n\\nThe second line of each test case contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^9).\\n\\nIt is guaranteed that the sum of n over all test cases doesn't exceed 3 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print \\\"YES\\\" (without quotes) if it is possible to split into subarrays in the desired way, print \\\"NO\\\" (without quotes) otherwise. You can print each letter in any register (upper or lower).\\n\\nExample\\n\\nInput\\n\\n\\n4\\n7\\n1 3 4 2 2 1 5\\n3\\n1 3 4\\n5\\n1 3 2 4 2\\n4\\n4 3 2 1\\n\\n\\nOutput\\n\\n\\nYES\\nNO\\nYES\\nYES\\n\\nNote\\n\\nIn the first test case, YouKn0wWho can split the sequence in the following way: [1, 3, 4], [2, 2], [1, 5]. This way, the LIS lengths are h = [3, 1, 2], and the bitwise XOR of the LIS lengths is 3 ⊕ 1 ⊕ 2 = 0.\\n\\nIn the second test...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nlong long int poww(long long int x, long long int y) {\\n long long int ans = 1;\\n while (y-- > 0) {\\n ans *= x;\\n }\\n return ans;\\n}\\nvoid sieve() {\\n bool *primes = new bool[100000 + 1];\\n for (long long int i = 0; i < 100000 + 1; i++) {\\n primes[i] = true;\\n }\\n long long int sqr = sqrt(100000);\\n primes[0] = false;\\n primes[1] = false;\\n for (long long int p = 2; p <= sqr; p++) {\\n if (primes[p]) {\\n for (long long int i = p * p; i <= 100000; i += p) {\\n primes[i] = false;\\n }\\n }\\n }\\n vector v;\\n for (long long int i = 2; i <= 100000; i++) {\\n if (primes[i]) {\\n v.push_back(i);\\n }\\n }\\n}\\nint main() {\\n long long int t;\\n cin >> t;\\n while (t-- > 0) {\\n int n;\\n cin >> n;\\n long long int arr[n];\\n int ch = 0;\\n for (long long int i = 0; i <= n - 1; i++) {\\n cin >> arr[i];\\n }\\n if (n % 2 == 0) {\\n cout << \\\"YES\\\" << endl;\\n } else {\\n for (long long int i = 0; i <= n - 2; i++) {\\n if (arr[i] >= arr[i + 1]) {\\n ch = 1;\\n break;\\n }\\n }\\n if (ch == 1) {\\n cout << \\\"YES\\\" << endl;\\n } else {\\n cout << \\\"NO\\\" << endl;\\n }\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given a sequence of n integers a_1, a_2, ..., a_n.\\n\\nDoes there exist a sequence of n integers b_1, b_2, ..., b_n such that the following property holds?\\n\\n * For each 1 ≤ i ≤ n, there exist two (not necessarily distinct) indices j and k (1 ≤ j, k ≤ n) such that a_i = b_j - b_k. \\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 20) — the number of test cases. Then t test cases follow.\\n\\nThe first line of each test case contains one integer n (1 ≤ n ≤ 10).\\n\\nThe second line of each test case contains the n integers a_1, ..., a_n (-10^5 ≤ a_i ≤ 10^5).\\n\\nOutput\\n\\nFor each test case, output a line containing YES if a sequence b_1, ..., b_n satisfying the required property exists, and NO otherwise.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n5\\n4 -7 -1 5 10\\n1\\n0\\n3\\n1 10 100\\n4\\n-3 2 10 2\\n9\\n25 -171 250 174 152 242 100 -205 -258\\n\\n\\nOutput\\n\\n\\nYES\\nYES\\nNO\\nYES\\nYES\\n\\nNote\\n\\nIn the first test case, the sequence b = [-9, 2, 1, 3, -2] satisfies the property. Indeed, the following holds: \\n\\n * a_1 = 4 = 2 - (-2) = b_2 - b_5; \\n * a_2 = -7 = -9 - (-2) = b_1 - b_5; \\n * a_3 = -1 = 1 - 2 = b_3 - b_2; \\n * a_4 = 5 = 3 - (-2) = b_4 - b_5; \\n * a_5 = 10 = 1 - (-9) = b_3 - b_1. \\n\\n\\n\\nIn the second test case, it is sufficient to choose b = [0], since a_1 = 0 = 0 - 0 = b_1 - b_1.\\n\\nIn the third test case, it is possible to show that no sequence b of length 3 satisfies the property.\\nSolve the task in CPP.\",\"targets\":\"#include \\n#pragma GCC diagnostic push\\n#pragma GCC diagnostic ignored \\\"-Wunused-variable\\\"\\n#pragma GCC diagnostic ignored \\\"-Wc++11-extensions\\\"\\n#pragma GCC diagnostic ignored \\\"-Wunused-const-variable\\\"\\nusing namespace std;\\nint max(int a, int b) { return (a > b) ? a : b; }\\nint min(int a, int b) { return (a < b) ? a : b; }\\ndouble max(double a, double b) { return (a > b) ? a : b; }\\ndouble min(double a, double b) { return (a < b) ? a : b; }\\nvoid ain(vector& a) {\\n for (int i = 0; i < a.size(); i++) cin >> a[i];\\n}\\nint Ceil(double d) { return ((int)d == d) ? d : d + 1; }\\nint gcd(int a, int b) { return (a == 0) ? b : gcd(b % a, a); }\\nint n;\\nvector a;\\nvoid f(int ind, int sum, vector& v, set& all) {\\n all.insert(sum);\\n if (ind == v.size()) return;\\n f(ind + 1, sum + v[ind], v, all);\\n f(ind + 1, sum - v[ind], v, all);\\n f(ind + 1, sum, v, all);\\n}\\nint32_t main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n int _;\\n cin >> _;\\n while (_--) {\\n cin >> n;\\n a.assign(n, 0);\\n ain(a);\\n bool done = 0;\\n for (int i = 0; i < n; i++) {\\n vector v;\\n for (int j = 0; j < n; j++)\\n if (i != j) v.push_back(a[j]);\\n set sub;\\n f(0, 0, v, sub);\\n if (sub.find(a[i]) != sub.end()) {\\n done = 1;\\n cout << \\\"YES\\\\n\\\";\\n break;\\n }\\n }\\n if (!done) cout << \\\"NO\\\\n\\\";\\n }\\n return 0;\\n}\\n#pragma GCC diagnostic pop\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Let's call the string beautiful if it does not contain a substring of length at least 2, which is a palindrome. Recall that a palindrome is a string that reads the same way from the first character to the last and from the last character to the first. For example, the strings a, bab, acca, bcabcbacb are palindromes, but the strings ab, abbbaa, cccb are not.\\n\\nLet's define cost of a string as the minimum number of operations so that the string becomes beautiful, if in one operation it is allowed to change any character of the string to one of the first 3 letters of the Latin alphabet (in lowercase).\\n\\nYou are given a string s of length n, each character of the string is one of the first 3 letters of the Latin alphabet (in lowercase).\\n\\nYou have to answer m queries — calculate the cost of the substring of the string s from l_i-th to r_i-th position, inclusive.\\n\\nInput\\n\\nThe first line contains two integers n and m (1 ≤ n, m ≤ 2 ⋅ 10^5) — the length of the string s and the number of queries.\\n\\nThe second line contains the string s, it consists of n characters, each character one of the first 3 Latin letters.\\n\\nThe following m lines contain two integers l_i and r_i (1 ≤ l_i ≤ r_i ≤ n) — parameters of the i-th query.\\n\\nOutput\\n\\nFor each query, print a single integer — the cost of the substring of the string s from l_i-th to r_i-th position, inclusive.\\n\\nExample\\n\\nInput\\n\\n\\n5 4\\nbaacb\\n1 3\\n1 5\\n4 5\\n2 3\\n\\n\\nOutput\\n\\n\\n1\\n2\\n0\\n1\\n\\nNote\\n\\nConsider the queries of the example test.\\n\\n * in the first query, the substring is baa, which can be changed to bac in one operation; \\n * in the second query, the substring is baacb, which can be changed to cbacb in two operations; \\n * in the third query, the substring is cb, which can be left unchanged; \\n * in the fourth query, the substring is aa, which can be changed to ba in one operation. \\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"#from math import *\\n#from bisect import *\\n#from collections import *\\n#from random import *\\n#from decimal import *\\\"\\\"\\\"\\n#from heap import *\\nimport sys\\ninput=sys.stdin.readline\\ndef inp():\\n return int(input())\\ndef st():\\n return input().rstrip('\\\\n')\\ndef lis():\\n return list(map(int,input().split()))\\ndef ma():\\n return map(int,input().split())\\nt=1\\ngl={'a':0,'b':1,'c':2}\\nwhile(t):\\n t-=1\\n n,q=ma()\\n s=st()\\n first=[[0,0,0]]\\n second=[[0,0,0]]\\n third=[[0,0,0]]\\n for i in range(len(s)):\\n if(i%3==0):\\n x=first[-1][:]\\n if(s[i]=='a'):\\n first.append([x[0]+1,x[1],x[2]])\\n elif(s[i]=='b'):\\n first.append([x[0],x[1]+1,x[2]])\\n else:\\n first.append([x[0],x[1],x[2]+1])\\n second.append(second[-1])\\n third.append(third[-1])\\n elif(i%3==1):\\n x=second[-1][:]\\n if(s[i]=='a'):\\n second.append([x[0]+1,x[1],x[2]])\\n elif(s[i]=='b'):\\n second.append([x[0],x[1]+1,x[2]])\\n else:\\n second.append([x[0],x[1],x[2]+1])\\n first.append(first[-1])\\n third.append(third[-1])\\n else:\\n x=third[-1][:]\\n if(s[i]=='a'):\\n third.append([x[0]+1,x[1],x[2]])\\n elif(s[i]=='b'):\\n third.append([x[0],x[1]+1,x[2]])\\n else:\\n third.append([x[0],x[1],x[2]+1])\\n first.append(first[-1])\\n second.append(second[-1])\\n #print(first,second,third)\\n for i in range(q):\\n l,r=ma()\\n res=float('inf')\\n a=first[r][:]\\n b=first[l-1][:]\\n f1=[a[0]-b[0],a[1]-b[1],a[2]-b[2]]\\n a=second[r][:]\\n b=second[l-1][:]\\n f2=[a[0]-b[0],a[1]-b[1],a[2]-b[2]]\\n a=third[r][:]\\n b=third[l-1][:]\\n f3=[a[0]-b[0],a[1]-b[1],a[2]-b[2]]\\n #print(f1,f2,f3)\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alice and Bob are playing a game on a matrix, consisting of 2 rows and m columns. The cell in the i-th row in the j-th column contains a_{i, j} coins in it.\\n\\nInitially, both Alice and Bob are standing in a cell (1, 1). They are going to perform a sequence of moves to reach a cell (2, m).\\n\\nThe possible moves are: \\n\\n * Move right — from some cell (x, y) to (x, y + 1); \\n * Move down — from some cell (x, y) to (x + 1, y). \\n\\n\\n\\nFirst, Alice makes all her moves until she reaches (2, m). She collects the coins in all cells she visit (including the starting cell).\\n\\nWhen Alice finishes, Bob starts his journey. He also performs the moves to reach (2, m) and collects the coins in all cells that he visited, but Alice didn't.\\n\\nThe score of the game is the total number of coins Bob collects.\\n\\nAlice wants to minimize the score. Bob wants to maximize the score. What will the score of the game be if both players play optimally?\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.\\n\\nThen the descriptions of t testcases follow.\\n\\nThe first line of the testcase contains a single integer m (1 ≤ m ≤ 10^5) — the number of columns of the matrix.\\n\\nThe i-th of the next 2 lines contain m integers a_{i,1}, a_{i,2}, ..., a_{i,m} (1 ≤ a_{i,j} ≤ 10^4) — the number of coins in the cell in the i-th row in the j-th column of the matrix.\\n\\nThe sum of m over all testcases doesn't exceed 10^5.\\n\\nOutput\\n\\nFor each testcase print a single integer — the score of the game if both players play optimally.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n3\\n1 3 7\\n3 5 1\\n3\\n1 3 9\\n3 5 1\\n1\\n4\\n7\\n\\n\\nOutput\\n\\n\\n7\\n8\\n0\\n\\nNote\\n\\nThe paths for the testcases are shown on the following pictures. Alice's path is depicted in red and Bob's path is depicted in blue.\\n\\n\\nSolve the task in JAVA.\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\n public class Solution {\\n\\t\\tstatic FastScanner scr=new FastScanner();\\n\\/\\/\\t\\tstatic Scanner scr=new Scanner(System.in);\\n\\t\\tstatic PrintStream out=new PrintStream(System.out);\\n\\t\\tstatic StringBuilder sb=new StringBuilder();\\n\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\tstatic class pair{\\n\\t\\t\\tint x;int y;\\n\\t\\t\\tpair(int x,int y){ \\n\\t\\t\\t\\tthis.x=x;this.y=y;\\n\\t\\t\\t\\t\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\tstatic class triplet{\\n\\t\\t\\tint x;\\n\\t\\t\\tlong y;\\n\\t\\t\\tint z;\\n\\t\\t\\ttriplet(int x,long y,int z){\\n\\t\\t\\t\\tthis.x=x;\\n\\t\\t\\t\\tthis.y=y;\\n\\t\\t\\t\\tthis.z=z;\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\tstatic class FastScanner {\\n\\t\\t\\t BufferedReader br=new BufferedReader(new InputStreamReader(System.in));\\n\\t\\t\\tStringTokenizer st=new StringTokenizer(\\\"\\\");\\n\\t\\t \\tString next() {\\n\\t\\t \\t\\twhile (!st.hasMoreTokens())\\n\\t\\t \\t\\t\\ttry {\\n\\t\\t \\t\\t\\t\\tst=new StringTokenizer(br.readLine());\\n\\t\\t \\t\\t\\t} catch (IOException e) {\\n\\t\\t \\t\\t\\t\\te.printStackTrace();\\n\\t\\t \\t\\t\\t}\\n\\t\\t \\t\\t\\treturn st.nextToken();\\n\\t\\t\\t} long gcd(long a,long b){\\n\\t\\t\\t\\tif(b==0) {\\n\\t\\t\\t\\t\\treturn a;\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\treturn gcd(b,a%b);\\n\\t\\t\\t}\\n\\t\\t \\tint[] sort(int a[]) {\\n\\t\\t\\t\\t \\n\\t\\t int multiplier = 1, len = a.length, max = Integer.MIN_VALUE;\\n\\t\\t int b[] = new int[len];\\n\\t\\t int bucket[];\\n\\t\\t for (int i = 0; i < len; i++) if (max < a[i]) max = a[i];\\n\\t\\t while (max \\/ multiplier > 0) {\\n\\t\\t bucket = new int[10];\\n\\t\\t for (int i = 0; i < len; i++) bucket[(a[i] \\/ multiplier) % 10]++;\\n\\t\\t for (int i = 1; i < 10; i++) bucket[i] += (bucket[i - 1]);\\n\\t\\t for (int i = len - 1; i >= 0; i--) b[--bucket[(a[i] \\/ multiplier) % 10]] = a[i];\\n\\t\\t for (int i = 0; i < len; i++) a[i] = b[i];\\n\\t\\t multiplier *= 10;\\n\\t\\t }\\n\\t\\t return a;\\n\\t\\t }\\n\\t\\t \\t long modPow(long base,long exp) {\\n\\t\\t\\t\\tif(exp==0) {\\n\\t\\t\\t\\t\\treturn 1;\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tif(exp%2==0) {\\n\\t\\t\\t\\t\\tlong res=(modPow(base,exp\\/2));\\n\\t\\t\\t\\t\\treturn (res*res);\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\treturn (base*modPow(base,exp-1));\\n\\t\\t\\t}\\n\\t\\t\\tint []reverse(int a[]){\\n\\t\\t\\t\\tint b[]=new int[a.length];\\n\\t\\t\\t\\tint index=0;\\n\\t\\t\\t\\tfor(int i=a.length-1;i>=0;i--) {\\n\\t\\t\\t\\t\\tb[index]=a[i];\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\treturn b;\\n\\t\\t\\t}\\n\\t\\t\\tint nextInt() {\\n\\t\\t\\t\\treturn...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Denis, after buying flowers and sweets (you will learn about this story in the next task), went to a date with Nastya to ask her to become a couple. Now, they are sitting in the cafe and finally... Denis asks her to be together, but ... Nastya doesn't give any answer. \\n\\nThe poor boy was very upset because of that. He was so sad that he punched some kind of scoreboard with numbers. The numbers are displayed in the same way as on an electronic clock: each digit position consists of 7 segments, which can be turned on or off to display different numbers. The picture shows how all 10 decimal digits are displayed: \\n\\n\\n\\nAfter the punch, some segments stopped working, that is, some segments might stop glowing if they glowed earlier. But Denis remembered how many sticks were glowing and how many are glowing now. Denis broke exactly k segments and he knows which sticks are working now. Denis came up with the question: what is the maximum possible number that can appear on the board if you turn on exactly k sticks (which are off now)? \\n\\nIt is allowed that the number includes leading zeros.\\n\\nInput\\n\\nThe first line contains integer n (1 ≤ n ≤ 2000) — the number of digits on scoreboard and k (0 ≤ k ≤ 2000) — the number of segments that stopped working.\\n\\nThe next n lines contain one binary string of length 7, the i-th of which encodes the i-th digit of the scoreboard.\\n\\nEach digit on the scoreboard consists of 7 segments. We number them, as in the picture below, and let the i-th place of the binary string be 0 if the i-th stick is not glowing and 1 if it is glowing. Then a binary string of length 7 will specify which segments are glowing now.\\n\\n\\n\\nThus, the sequences \\\"1110111\\\", \\\"0010010\\\", \\\"1011101\\\", \\\"1011011\\\", \\\"0111010\\\", \\\"1101011\\\", \\\"1101111\\\", \\\"1010010\\\", \\\"1111111\\\", \\\"1111011\\\" encode in sequence all digits from 0 to 9 inclusive.\\n\\nOutput\\n\\nOutput a single number consisting of n digits — the maximum number that can be obtained if you turn on exactly k sticks or -1, if it is impossible to turn on exactly k sticks so that...\\nUsing python3 can you solve the prior task?\",\"targets\":\"import os\\nimport sys\\nfrom io import BytesIO, IOBase\\n# region fastio\\n\\nBUFSIZE = 8192\\n\\nclass FastIO(IOBase):\\n newlines = 0\\n\\n def __init__(self, file):\\n self._fd = file.fileno()\\n self.buffer = BytesIO()\\n self.writable = \\\"x\\\" in file.mode or \\\"r\\\" not in file.mode\\n self.write = self.buffer.write if self.writable else None\\n\\n def read(self):\\n while True:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n if not b:\\n break\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines = 0\\n return self.buffer.read()\\n\\n def readline(self):\\n while self.newlines == 0:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n self.newlines = b.count(b\\\"\\\\n\\\") + (not b)\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines -= 1\\n return self.buffer.readline()\\n\\n def flush(self):\\n if self.writable:\\n os.write(self._fd, self.buffer.getvalue())\\n self.buffer.truncate(0), self.buffer.seek(0)\\n\\n\\nclass IOWrapper(IOBase):\\n def __init__(self, file):\\n self.buffer = FastIO(file)\\n self.flush = self.buffer.flush\\n self.writable = self.buffer.writable\\n self.write = lambda s: self.buffer.write(s.encode(\\\"ascii\\\"))\\n self.read = lambda: self.buffer.read().decode(\\\"ascii\\\")\\n self.readline = lambda: self.buffer.readline().decode(\\\"ascii\\\")\\n\\n\\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\\ninput = lambda: sys.stdin.readline().rstrip(\\\"\\\\r\\\\n\\\")\\n\\n# ------------------------------\\n\\nfrom math import factorial\\nfrom collections import Counter, defaultdict\\nfrom heapq import heapify, heappop, heappush\\n\\ndef RL(): return map(int, sys.stdin.readline().rstrip().split())\\ndef RLL(): return list(map(int, sys.stdin.readline().rstrip().split()))\\ndef N(): return int(input())\\ndef...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"\\n\\nWilliam has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers c_1, c_2, ..., c_n where c_i is the number of consecutive brackets \\\"(\\\" if i is an odd number or the number of consecutive brackets \\\")\\\" if i is an even number.\\n\\nFor example for a bracket sequence \\\"((())()))\\\" a corresponding sequence of numbers is [3, 2, 1, 3].\\n\\nYou need to find the total number of continuous subsequences (subsegments) [l, r] (l ≤ r) of the original bracket sequence, which are regular bracket sequences.\\n\\nA bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters \\\"+\\\" and \\\"1\\\" into this sequence. For example, sequences \\\"(())()\\\", \\\"()\\\" and \\\"(()(()))\\\" are regular, while \\\")(\\\", \\\"(()\\\" and \\\"(()))(\\\" are not.\\n\\nInput\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 1000), the size of the compressed sequence.\\n\\nThe second line contains a sequence of integers c_1, c_2, ..., c_n (1 ≤ c_i ≤ 10^9), the compressed sequence.\\n\\nOutput\\n\\nOutput a single integer — the total number of subsegments of the original bracket sequence, which are regular bracket sequences.\\n\\nIt can be proved that the answer fits in the signed 64-bit integer data type.\\n\\nExamples\\n\\nInput\\n\\n\\n5\\n4 1 2 3 1\\n\\n\\nOutput\\n\\n\\n5\\n\\n\\nInput\\n\\n\\n6\\n1 3 2 1 2 4\\n\\n\\nOutput\\n\\n\\n6\\n\\n\\nInput\\n\\n\\n6\\n1 1 1 1 2 2\\n\\n\\nOutput\\n\\n\\n7\\n\\nNote\\n\\nIn the first example a sequence (((()(()))( is described. This bracket sequence contains 5 subsegments which form regular bracket sequences:\\n\\n 1. Subsequence from the 3rd to 10th character: (()(()))\\n 2. Subsequence from the 4th to 5th character: ()\\n 3. Subsequence from the 4th to 9th character: ()(())\\n 4. Subsequence from the 6th to 9th character: (())\\n 5. Subsequence from the 7th to 8th character: ()\\n\\n\\n\\nIn the second example a sequence ()))(()(()))) is described.\\n\\nIn the third example a sequence ()()(()) is described.\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int n;\\n cin >> n;\\n vector arr(n);\\n for (int i = 0; i < n; ++i) {\\n cin >> arr[i];\\n }\\n vector another_arr(n + 1);\\n another_arr[0] = 0;\\n for (int i = 0; i < n; ++i) {\\n if (i % 2 == 0) {\\n another_arr[i + 1] = another_arr[i] + arr[i];\\n } else {\\n another_arr[i + 1] = another_arr[i] - arr[i];\\n }\\n }\\n long long ans = 0;\\n for (int i = 0; i < n; i += 2) {\\n long long x = 1e18;\\n for (int j = i + 1; j < n; j += 2) {\\n long long maxi = min({another_arr[i + 1], another_arr[j], x + 1});\\n long long mini = max(another_arr[i], another_arr[j + 1]);\\n if (mini < maxi) {\\n ans += maxi - mini;\\n }\\n x = min(x, another_arr[j + 1]);\\n }\\n }\\n cout << ans << '\\\\n';\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CQXYM is counting permutations length of 2n.\\n\\nA permutation is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice in the array) and [1,3,4] is also not a permutation (n=3 but there is 4 in the array).\\n\\nA permutation p(length of 2n) will be counted only if the number of i satisfying p_ip_2. Because 0 0) {\\n solve();\\n if (T != 0) {\\n clear();\\n }\\n }\\n printAns();\\n }\\n\\n public static void main(String[] args) throws Exception {\\n new Main().run();\\n }\\n\\n StringBuilder sb = new StringBuilder();\\n BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));\\n StringTokenizer st;\\n\\n private void rf() throws IOException {\\n st = new StringTokenizer(infile.readLine());\\n }\\n\\n private int readInt() {\\n return Integer.parseInt(st.nextToken());\\n }\\n\\n private long readLong() {\\n return Long.parseLong(st.nextToken());\\n }\\n\\n\\n private void printAns() {\\n System.out.println(sb);\\n }\\n\\n private int[] readArr(int N) throws Exception {\\n int[] arr = new int[N];\\n rf();\\n for (int i = 0; i < N; i++) {\\n arr[i] = Integer.parseInt(st.nextToken());\\n }\\n return arr;\\n }\\n\\n private void print(int[] arr) {\\n \\/\\/for debugging only\\n for (int x : arr) {\\n System.out.print(x + \\\" \\\");\\n }\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alexander is a well-known programmer. Today he decided to finally go out and play football, but with the first hit he left a dent on the new Rolls-Royce of the wealthy businessman Big Vova. Vladimir has recently opened a store on the popular online marketplace \\\"Zmey-Gorynych\\\", and offers Alex a job: if he shows his programming skills by solving a task, he'll work as a cybersecurity specialist. Otherwise, he'll be delivering some doubtful products for the next two years.\\n\\nYou're given n positive integers a_1, a_2, ..., a_n. Using each of them exactly at once, you're to make such sequence b_1, b_2, ..., b_n that sequence c_1, c_2, ..., c_n is lexicographically maximal, where c_i=GCD(b_1,...,b_i) - the greatest common divisor of the first i elements of b. \\n\\nAlexander is really afraid of the conditions of this simple task, so he asks you to solve it.\\n\\nA sequence a is lexicographically smaller than a sequence b if and only if one of the following holds:\\n\\n * a is a prefix of b, but a ≠ b;\\n * in the first position where a and b differ, the sequence a has a smaller element than the corresponding element in b.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^3). Description of the test cases follows.\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 10^3) — the length of the sequence a.\\n\\nThe second line of each test case contains n integers a_1,...,a_n (1 ≤ a_i ≤ 10^3) — the sequence a.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 10^3.\\n\\nOutput\\n\\nFor each test case output the answer in a single line — the desired sequence b. If there are multiple answers, print any.\\n\\nExample\\n\\nInput\\n\\n\\n7\\n2\\n2 5\\n4\\n1 8 2 3\\n3\\n3 8 9\\n5\\n64 25 75 100 50\\n1\\n42\\n6\\n96 128 88 80 52 7\\n5\\n2 4 8 16 17\\n\\n\\nOutput\\n\\n\\n5 2 \\n8 2 1 3 \\n9 3 8 \\n100 50 25 75 64 \\n42 \\n128 96 80 88 52 7 \\n17 2 4 8 16 \\n\\nNote\\n\\nIn the first test case of the example, there are only two possible permutations b — [2, 5] and [5, 2]: for the first one c=[2, 1], for the second one c=[5,...\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nusing ll = long long;\\nconst long long int mod = 1e9 + 7;\\nvoid __print(int x) { cerr << x; }\\nvoid __print(long x) { cerr << x; }\\nvoid __print(long long x) { cerr << x; }\\nvoid __print(unsigned x) { cerr << x; }\\nvoid __print(unsigned long x) { cerr << x; }\\nvoid __print(unsigned long long x) { cerr << x; }\\nvoid __print(float x) { cerr << x; }\\nvoid __print(double x) { cerr << x; }\\nvoid __print(long double x) { cerr << x; }\\nvoid __print(char x) { cerr << '\\\\'' << x << '\\\\''; }\\nvoid __print(const char* x) { cerr << '\\\\\\\"' << x << '\\\\\\\"'; }\\nvoid __print(const string& x) { cerr << '\\\\\\\"' << x << '\\\\\\\"'; }\\nvoid __print(bool x) { cerr << (x ? \\\"true\\\" : \\\"false\\\"); }\\ntemplate \\nvoid __print(const pair& x) {\\n cerr << '{';\\n __print(x.first);\\n cerr << ',';\\n __print(x.second);\\n cerr << '}';\\n}\\ntemplate \\nvoid __print(const T& x) {\\n int f = 0;\\n cerr << '{';\\n for (auto& i : x) cerr << (f++ ? \\\",\\\" : \\\"\\\"), __print(i);\\n cerr << \\\"}\\\";\\n}\\nvoid _print() { cerr << \\\"]\\\\n\\\"; }\\ntemplate \\nvoid _print(T t, V... v) {\\n __print(t);\\n if (sizeof...(v)) cerr << \\\", \\\";\\n _print(v...);\\n}\\ntemplate \\nvoid print(vector v) {\\n for (T i : v) cout << i << \\\" \\\";\\n cout << '\\\\n';\\n}\\ntemplate \\nvoid print(vector>& v) {\\n for (vector& vv : v) {\\n for (T& i : vv) cout << i << \\\" \\\";\\n cout << '\\\\n';\\n }\\n}\\ntemplate \\nvoid read(vector& v) {\\n for (T& i : v) cin >> i;\\n}\\ntemplate \\nvoid read(T&& t) {\\n cin >> t;\\n}\\ntemplate \\nvoid read(T&& t, Args&&... args) {\\n cin >> t;\\n read(forward(args)...);\\n}\\ntemplate \\nvoid print(T&& t) {\\n cout << t << '\\\\n';\\n}\\ntemplate \\nvoid print(T&& t, Args&&... args) {\\n cout << t << \\\" \\\";\\n print(forward(args)...);\\n}\\nbool checkPrime(ll n) {\\n if (n <= 1) return false;\\n if (n <= 3) return true;\\n if (n % 2 == 0 || n % 3 == 0) return false;\\n for (ll i = 5; i * i <= n; i = i + 6)\\n if (n % i...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Monocarp has got an array a consisting of n integers. Let's denote k as the mathematic mean of these elements (note that it's possible that k is not an integer). \\n\\nThe mathematic mean of an array of n elements is the sum of elements divided by the number of these elements (i. e. sum divided by n).\\n\\nMonocarp wants to delete exactly two elements from a so that the mathematic mean of the remaining (n - 2) elements is still equal to k.\\n\\nYour task is to calculate the number of pairs of positions [i, j] (i < j) such that if the elements on these positions are deleted, the mathematic mean of (n - 2) remaining elements is equal to k (that is, it is equal to the mathematic mean of n elements of the original array a).\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.\\n\\nThe first line of each testcase contains one integer n (3 ≤ n ≤ 2 ⋅ 10^5) — the number of elements in the array.\\n\\nThe second line contains a sequence of integers a_1, a_2, ..., a_n (0 ≤ a_i ≤ 10^{9}), where a_i is the i-th element of the array.\\n\\nThe sum of n over all testcases doesn't exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nPrint one integer — the number of pairs of positions [i, j] (i < j) such that if the elements on these positions are deleted, the mathematic mean of (n - 2) remaining elements is equal to k (that is, it is equal to the mathematic mean of n elements of the original array a).\\n\\nExample\\n\\nInput\\n\\n\\n4\\n4\\n8 8 8 8\\n3\\n50 20 10\\n5\\n1 4 7 3 5\\n7\\n1 2 3 4 5 6 7\\n\\n\\nOutput\\n\\n\\n6\\n0\\n2\\n3\\n\\nNote\\n\\nIn the first example, any pair of elements can be removed since all of them are equal.\\n\\nIn the second example, there is no way to delete two elements so the mathematic mean doesn't change.\\n\\nIn the third example, it is possible to delete the elements on positions 1 and 3, or the elements on positions 4 and 5.\\nUsing java can you solve the prior task?\",\"targets\":\"import java.util.*;\\npublic class Sant {\\n \\n\\tpublic static void main(String[] args) {\\n\\t\\t\\/\\/ TODO Auto-generated method stub\\n Scanner sc=new Scanner(System.in);\\n int t=sc.nextInt();\\n while(t--!=0) {\\n \\t int n=sc.nextInt();\\n \\t long a[]=new long[n];\\n \\t long sum=0;\\n \\t HashMap hf=new HashMap<>();\\n\\/\\/ \\t HashMap hi=new HashMap<>();\\n \\t ArrayList arr=new ArrayList<>();\\n \\t for(int i=0;ia,int start,int end,long el) {\\n\\twhile(start<=end) {\\n\\t\\tint mid=start+(end-start)\\/2;\\n\\t\\tif(a.get(mid)==el)return mid;\\n\\t\\telse if(a.get(mid)0){\\n\\t\\t c++;\\n\\t\\t d=0;\\n\\t\\t }\\n\\t\\t }\\n\\t\\t if((s.charAt(s.length()-1)=='0')){\\n\\t\\t c++;\\n\\t\\t }\\n\\t\\t if(c>2){\\n\\t\\t System.out.println(\\\"2\\\");\\n\\t\\t }\\n\\t\\t else{\\n\\t\\t System.out.println(c);\\n\\t\\t }\\n\\t\\t}\\n\\t}\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out.\\n\\nBob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted them at home. Since he does not know which clue belongs to which obelisk, finding the treasure might pose a challenge. Can you help him?\\n\\nAs everyone knows, the world is a two-dimensional plane. The i-th obelisk is at integer coordinates (x_i, y_i). The j-th clue consists of 2 integers (a_j, b_j) and belongs to the obelisk p_j, where p is some (unknown) permutation on n elements. It means that the treasure is located at T=(x_{p_j} + a_j, y_{p_j} + b_j). This point T is the same for all clues.\\n\\nIn other words, each clue belongs to exactly one of the obelisks, and each obelisk has exactly one clue that belongs to it. A clue represents the vector from the obelisk to the treasure. The clues must be distributed among the obelisks in such a way that they all point to the same position of the treasure.\\n\\nYour task is to find the coordinates of the treasure. If there are multiple solutions, you may print any of them.\\n\\nNote that you don't need to find the permutation. Permutations are used only in order to explain the problem.\\n\\nInput\\n\\nThe first line contains an integer n (1 ≤ n ≤ 1000) — the number of obelisks, that is also equal to the number of clues.\\n\\nEach of the next n lines contains two integers x_i, y_i (-10^6 ≤ x_i, y_i ≤ 10^6) — the coordinates of the i-th obelisk. All coordinates are distinct, that is x_i ≠ x_j or y_i ≠ y_j will be satisfied for every (i, j) such that i ≠ j. \\n\\nEach of the next n lines contains two integers a_i, b_i (-2 ⋅ 10^6 ≤ a_i, b_i ≤ 2 ⋅ 10^6) — the direction of the i-th clue. All coordinates are distinct, that is a_i ≠ a_j or b_i ≠ b_j will be satisfied for every (i, j) such that i ≠ j. \\n\\nIt is guaranteed that there exists a permutation p, such that for all i,j it holds \\\\left(x_{p_i}...\\nUsing python3 can you solve the prior task?\",\"targets\":\"n = int(input())\\na, b = 0, 0\\n\\nfor _ in range(2 * n):\\n x, y = map(int, input().split())\\n a += x\\n b += y\\n\\nprint(a \\/\\/ n, b \\/\\/ n)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"As Famil Door’s birthday is coming, some of his friends (like Gabi) decided to buy a present for him. His friends are going to buy a string consisted of round brackets since Famil Door loves string of brackets of length n more than any other strings!\\n\\nThe sequence of round brackets is called valid if and only if: \\n\\n 1. the total number of opening brackets is equal to the total number of closing brackets; \\n 2. for any prefix of the sequence, the number of opening brackets is greater or equal than the number of closing brackets. \\n\\n\\n\\nGabi bought a string s of length m (m ≤ n) and want to complete it to obtain a valid sequence of brackets of length n. He is going to pick some strings p and q consisting of round brackets and merge them in a string p + s + q, that is add the string p at the beginning of the string s and string q at the end of the string s.\\n\\nNow he wonders, how many pairs of strings p and q exists, such that the string p + s + q is a valid sequence of round brackets. As this number may be pretty large, he wants to calculate it modulo 109 + 7.\\n\\nInput\\n\\nFirst line contains n and m (1 ≤ m ≤ n ≤ 100 000, n - m ≤ 2000) — the desired length of the string and the length of the string bought by Gabi, respectively.\\n\\nThe second line contains string s of length m consisting of characters '(' and ')' only.\\n\\nOutput\\n\\nPrint the number of pairs of string p and q such that p + s + q is a valid sequence of round brackets modulo 109 + 7.\\n\\nExamples\\n\\nInput\\n\\n4 1\\n(\\n\\n\\nOutput\\n\\n4\\n\\n\\nInput\\n\\n4 4\\n(())\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\n4 3\\n(((\\n\\n\\nOutput\\n\\n0\\n\\nNote\\n\\nIn the first sample there are four different valid pairs: \\n\\n 1. p = \\\"(\\\", q = \\\"))\\\" \\n 2. p = \\\"()\\\", q = \\\")\\\" \\n 3. p = \\\"\\\", q = \\\"())\\\" \\n 4. p = \\\"\\\", q = \\\")()\\\" \\n\\n\\n\\nIn the second sample the only way to obtain a desired string is choose empty p and q.\\n\\nIn the third sample there is no way to get a valid sequence of brackets.\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nconst int64_t mod = (int64_t)1e9 + 7;\\nint64_t n, m;\\nchar s[100000];\\nint64_t sum, mins;\\nint64_t dp[2017][2017][2];\\nint64_t calc(int64_t i, int64_t cur, bool has) {\\n if (cur < 0 || i > n - m) return 0;\\n if (i == n - m) {\\n if (!cur && has) return 1;\\n if (!has && cur + mins >= 0 && cur + sum <= n - m - i)\\n return calc(i, cur + sum, true);\\n }\\n if (dp[i][cur][has] != -1) return dp[i][cur][has];\\n int64_t res = (calc(i + 1, cur + 1, has) + calc(i + 1, cur - 1, has)) % mod;\\n if (!has && cur + mins >= 0 && cur + sum <= n - m - i)\\n res = (res + calc(i, cur + sum, true)) % mod;\\n return dp[i][cur][has] = res;\\n}\\nint32_t main() {\\n scanf(\\\"%I64d %I64d\\\", &n, &m);\\n scanf(\\\"%s\\\", s);\\n mins = 0;\\n for (int64_t i = 0; i < m; i++)\\n sum += (s[i] == '(' ? 1 : -1), mins = min(mins, sum);\\n memset(dp, -1, sizeof(dp));\\n printf(\\\"%I64d\\\\n\\\", calc(0, 0, 0));\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Polycarp has come up with a new game to play with you. He calls it \\\"A missing bigram\\\".\\n\\nA bigram of a word is a sequence of two adjacent letters in it.\\n\\nFor example, word \\\"abbaaba\\\" contains bigrams \\\"ab\\\", \\\"bb\\\", \\\"ba\\\", \\\"aa\\\", \\\"ab\\\" and \\\"ba\\\".\\n\\nThe game goes as follows. First, Polycarp comes up with a word, consisting only of lowercase letters 'a' and 'b'. Then, he writes down all its bigrams on a whiteboard in the same order as they appear in the word. After that, he wipes one of them off the whiteboard.\\n\\nFinally, Polycarp invites you to guess what the word that he has come up with was.\\n\\nYour goal is to find any word such that it's possible to write down all its bigrams and remove one of them, so that the resulting sequence of bigrams is the same as the one Polycarp ended up with.\\n\\nThe tests are generated in such a way that the answer exists. If there are multiple answers, you can print any of them.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 2000) — the number of testcases.\\n\\nThe first line of each testcase contains a single integer n (3 ≤ n ≤ 100) — the length of the word Polycarp has come up with.\\n\\nThe second line of each testcase contains n-2 bigrams of that word, separated by a single space. Each bigram consists of two letters, each of them is either 'a' or 'b'.\\n\\nAdditional constraint on the input: there exists at least one string such that it is possible to write down all its bigrams, except one, so that the resulting sequence is the same as the sequence in the input. In other words, the answer exists.\\n\\nOutput\\n\\nFor each testcase print a word, consisting of n letters, each of them should be either 'a' or 'b'. It should be possible to write down all its bigrams and remove one of them, so that the resulting sequence of bigrams is the same as the one Polycarp ended up with.\\n\\nThe tests are generated in such a way that the answer exists. If there are multiple answers, you can print any of them. \\n\\nExample\\n\\nInput\\n\\n\\n4\\n7\\nab bb ba aa ba\\n7\\nab ba aa ab ba\\n3\\naa\\n5\\nbb ab...\\nSolve the task in JAVA.\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\n\\npublic class B760d3 {\\n public static void main(String[] args) {\\n Scanner in = new Scanner(System.in);\\n PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));\\n\\n int n = in.nextInt();\\n while (n-- > 0) {\\n int k = in.nextInt();\\n String[] str = new String[k - 2];\\n for (int i = 0; i < k - 2; i++) {\\n str[i] = in.next();\\n }\\n StringBuilder bg = new StringBuilder();\\n bg.append(str[0]);\\n for (int i = 1; i < k - 2; i++) {\\n if (str[i - 1].charAt(1) != str[i].charAt(0))\\n bg.append(str[i]);\\n else\\n bg.append(str[i].charAt(1));\\n }\\n if (bg.length() != k)\\n bg.append('a');\\n\\n\\n \\/\\/debug(bg.toString());\\n pw.println(bg);\\n\\n\\n }\\n\\n pw.close();\\n }\\n\\n static void debug(Object... obj) {\\n System.err.println(Arrays.deepToString(obj));\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"The only difference between this problem and D2 is that you don't have to provide the way to construct the answer in this problem, but you have to do it in D2.\\n\\nThere's a table of n × m cells (n rows and m columns). The value of n ⋅ m is even.\\n\\nA domino is a figure that consists of two cells having a common side. It may be horizontal (one of the cells is to the right of the other) or vertical (one of the cells is above the other).\\n\\nYou need to find out whether it is possible to place nm\\/2 dominoes on the table so that exactly k of them are horizontal and all the other dominoes are vertical. The dominoes cannot overlap and must fill the whole table.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of a single line. The line contains three integers n, m, k (1 ≤ n,m ≤ 100, 0 ≤ k ≤ nm\\/2, n ⋅ m is even) — the number of rows, columns and horizontal dominoes, respectively.\\n\\nOutput\\n\\nFor each test case output \\\"YES\\\", if it is possible to place dominoes in the desired way, or \\\"NO\\\" otherwise.\\n\\nYou may print each letter in any case (YES, yes, Yes will all be recognized as positive answer, NO, no and nO will all be recognized as negative answer).\\n\\nExample\\n\\nInput\\n\\n\\n8\\n4 4 2\\n2 3 0\\n3 2 3\\n1 2 0\\n2 4 2\\n5 2 2\\n2 17 16\\n2 1 1\\n\\n\\nOutput\\n\\n\\nYES\\nYES\\nYES\\nNO\\nYES\\nNO\\nYES\\nNO\\\":\",\"targets\":\"#include \\nusing namespace std;\\nlong long powmod(long long a, long long b) {\\n long long res = 1;\\n if (a >= 1000000007) a %= 1000000007;\\n for (; b; b >>= 1) {\\n if (b & 1) res = res * a;\\n if (res >= 1000000007) res %= 1000000007;\\n a = a * a;\\n if (a >= 1000000007) a %= 1000000007;\\n }\\n return res;\\n}\\nlong long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }\\nint main() {\\n int t;\\n cin >> t;\\n while (t--) {\\n int n, m, k;\\n cin >> n >> m >> k;\\n int needed = 0;\\n if (n % 2) {\\n needed += m \\/ 2;\\n n--;\\n }\\n int col_count = 0;\\n bool flag = true;\\n while (n > 0 && needed < k) {\\n if (col_count + 1 > (m \\/ 2)) {\\n flag = false;\\n break;\\n }\\n needed += 2;\\n col_count++;\\n if (col_count == (m \\/ 2)) {\\n n -= 2;\\n col_count = 0;\\n }\\n }\\n if (needed != k || !flag) {\\n cout << \\\"NO\\\" << endl;\\n continue;\\n } else {\\n cout << \\\"YES\\\" << endl;\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Recently, Petya learned about a new game \\\"Slay the Dragon\\\". As the name suggests, the player will have to fight with dragons. To defeat a dragon, you have to kill it and defend your castle. To do this, the player has a squad of n heroes, the strength of the i-th hero is equal to a_i.\\n\\nAccording to the rules of the game, exactly one hero should go kill the dragon, all the others will defend the castle. If the dragon's defense is equal to x, then you have to send a hero with a strength of at least x to kill it. If the dragon's attack power is y, then the total strength of the heroes defending the castle should be at least y.\\n\\nThe player can increase the strength of any hero by 1 for one gold coin. This operation can be done any number of times.\\n\\nThere are m dragons in the game, the i-th of them has defense equal to x_i and attack power equal to y_i. Petya was wondering what is the minimum number of coins he needs to spend to defeat the i-th dragon.\\n\\nNote that the task is solved independently for each dragon (improvements are not saved).\\n\\nInput\\n\\nThe first line contains a single integer n (2 ≤ n ≤ 2 ⋅ 10^5) — number of heroes.\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^{12}), where a_i is the strength of the i-th hero.\\n\\nThe third line contains a single integer m (1 ≤ m ≤ 2 ⋅ 10^5) — the number of dragons.\\n\\nThe next m lines contain two integers each, x_i and y_i (1 ≤ x_i ≤ 10^{12}; 1 ≤ y_i ≤ 10^{18}) — defense and attack power of the i-th dragon.\\n\\nOutput\\n\\nPrint m lines, i-th of which contains a single integer — the minimum number of coins that should be spent to defeat the i-th dragon.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3 6 2 3\\n5\\n3 12\\n7 9\\n4 14\\n1 10\\n8 7\\n\\n\\nOutput\\n\\n\\n1\\n2\\n4\\n0\\n2\\n\\nNote\\n\\nTo defeat the first dragon, you can increase the strength of the third hero by 1, then the strength of the heroes will be equal to [3, 6, 3, 3]. To kill the dragon, you can choose the first hero.\\n\\nTo defeat the second dragon, you can increase the forces of the second and third heroes by 1, then the strength of the heroes will...\\nSolve the task in PYTHON3.\",\"targets\":\"import math\\nfrom collections import Counter, deque\\nfrom math import *\\nfrom bisect import *\\nmod = 998244353\\n\\n\\n# from functools import reduce\\n# from itertools import permutations\\n# import queue\\n\\n\\n\\ndef solve():\\n n=int(input())\\n l=list(map(int,input().split()))\\n l.sort()\\n sm=sum(l)\\n m=int(input())\\n l2=[]\\n for i in range(m):\\n l2.append(map(int,input().split()))\\n for i in range(m):\\n x,y=l2[i]\\n if x>l[-1]:\\n ans=x-l[-1]+max(0,y-sm+l[-1])\\n else:\\n\\n ind=bisect_left(l,x,0,n)\\n if l[ind]==x:\\n ans=max(0,y-sm+l[ind])\\n else:\\n ans1=max(0,x-l[ind])+max(0,y-sm+l[ind])\\n if ind!=0:\\n ans2=max(0,y-sm+l[ind-1])\\n ans2+=max(0,x-l[ind-1])\\n ans=min(ans1,ans2)\\n else:\\n ans=ans1\\n print(ans)\\n\\n\\n# t=int(input())\\nt = 1\\nfor _ in range(t):\\n # print(\\\"Case #{}: \\\".format(_ + 1), end=\\\"\\\")\\n solve()\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal integers by transforming some of them.\\n\\nHe may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (See Sample 2).\\n\\nFind the minimum total cost to achieve his objective.\\n\\nConstraints\\n\\n* 1≦N≦100\\n* -100≦a_i≦100\\n\\nInput\\n\\nThe input is given from Standard Input in the following format:\\n\\n\\nN\\na_1 a_2 ... a_N\\n\\n\\nOutput\\n\\nPrint the minimum total cost to achieve Evi's objective.\\n\\nExamples\\n\\nInput\\n\\n2\\n4 8\\n\\n\\nOutput\\n\\n8\\n\\n\\nInput\\n\\n3\\n1 1 3\\n\\n\\nOutput\\n\\n3\\n\\n\\nInput\\n\\n3\\n4 2 5\\n\\n\\nOutput\\n\\n5\\n\\n\\nInput\\n\\n4\\n-100 -100 -100 -100\\n\\n\\nOutput\\n\\n0\",\"targets\":\"n = int(raw_input())\\na = map(int, raw_input().split())\\n\\nsum = sum(a)\\nif(sum >= 0):\\n ave = int(float(sum) \\/ n + 0.5)\\nelse:\\n ave = int(float(sum) \\/ n - 0.5) \\n\\ncost = 0\\nfor item in a:\\n cost += pow(abs(item - ave), 2)\\n \\n\\nprint cost,\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"YouKn0wWho has two even integers x and y. Help him to find an integer n such that 1 ≤ n ≤ 2 ⋅ 10^{18} and n mod x = y mod n. Here, a mod b denotes the remainder of a after division by b. If there are multiple such integers, output any. It can be shown that such an integer always exists under the given constraints.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^5) — the number of test cases.\\n\\nThe first and only line of each test case contains two integers x and y (2 ≤ x, y ≤ 10^9, both are even).\\n\\nOutput\\n\\nFor each test case, print a single integer n (1 ≤ n ≤ 2 ⋅ 10^{18}) that satisfies the condition mentioned in the statement. If there are multiple such integers, output any. It can be shown that such an integer always exists under the given constraints.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n4 8\\n4 2\\n420 420\\n69420 42068\\n\\n\\nOutput\\n\\n\\n4\\n10\\n420\\n9969128\\n\\nNote\\n\\nIn the first test case, 4 mod 4 = 8 mod 4 = 0.\\n\\nIn the second test case, 10 mod 4 = 2 mod 10 = 2.\\n\\nIn the third test case, 420 mod 420 = 420 mod 420 = 0.\\nUsing java can you solve the prior task?\",\"targets\":\"import java.util.StringTokenizer;\\nimport java.io.InputStreamReader;\\nimport java.io.OutputStreamWriter;\\nimport java.lang.reflect.Array;\\nimport java.io.IOException;\\nimport java.io.BufferedReader;\\nimport java.io.BufferedWriter;\\nimport java.math.BigInteger;\\nimport java.util.Arrays;\\nimport java.util.Collections;\\nimport java.util.ArrayList;\\n\\npublic class p4\\n{\\n\\tBufferedReader br;\\n\\tStringTokenizer st;\\n\\tBufferedWriter bw;\\n\\tpublic static void main(String[] args)throws Exception\\n\\t{\\n\\t\\tnew p4().run();\\n\\t}\\n\\n\\tvoid run()throws IOException\\n\\t{\\n\\t\\tbr = new BufferedReader(new InputStreamReader(System.in));\\n\\t\\tbw=new BufferedWriter(new OutputStreamWriter(System.out));\\n\\n\\t\\tsolve();\\n\\t}\\n\\tvoid solve() throws IOException\\n\\t{\\n\\t\\tint t=ni();\\n\\t\\twhile(t-->0)\\n\\t\\t{\\n\\t\\t\\tint x=ni();\\n\\t\\t\\tint y=ni();\\n\\n\\t\\t\\tif(x>y)\\n\\t\\t\\t\\tSystem.out.println(x+y);\\n\\t\\t\\telse\\n\\t\\t\\t\\tSystem.out.println(y-(y%x)\\/2);\\n\\t\\t}\\n\\t}\\n\\n\\/*\\ny=ax, n=x\\nx>y, n=x+y\\ny>x, \\n\\n\\n*\\/\\n\\n\\n\\n\\n\\tpublic int gcd(int a, int b)\\n\\t{\\n\\t\\tif(a==0)\\n\\t\\t\\treturn b;\\n\\t\\telse\\n\\t\\t return gcd(b%a,a);\\n\\t}\\n\\n\\tint[] nai(int n) { int a[]=new int[n]; for(int i=-1;++i\\nint main() {\\n int t;\\n scanf(\\\"%d\\\", &t);\\n int i;\\n for (i = 0; i < t; i++) {\\n int n, k;\\n scanf(\\\"%d %d\\\", &n, &k);\\n int arr[n];\\n int j;\\n for (j = 0; j < n; j++) scanf(\\\"%d\\\", &arr[j]);\\n for (j = 0; j < n; j++) {\\n int l;\\n for (l = j + 1; l < n; l++) {\\n if (arr[j] > arr[l]) {\\n int a;\\n a = arr[j];\\n arr[j] = arr[l];\\n arr[l] = a;\\n }\\n }\\n }\\n long long int answer = 0;\\n for (j = 0; j < n - 2 * k; j++) answer = answer + arr[j];\\n int count = 1;\\n for (j = n - 2 * k + 1; j < n; j++) {\\n if (arr[j] == arr[j - 1]) {\\n count++;\\n if (count > k) {\\n for (j = j + 1; j < n; j++) {\\n if (arr[j] == arr[j - 1])\\n count++;\\n else\\n break;\\n }\\n break;\\n }\\n } else\\n count = 1;\\n }\\n if (count > k && k > 0) answer = answer + count - k;\\n printf(\\\"%lld\\\\n\\\", answer);\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 solution for \\\"Theofanis started playing the new online game called \\\"Among them\\\". However, he always plays with Cypriot players, and they all have the same name: \\\"Andreas\\\" (the most common name in Cyprus).\\n\\nIn each game, Theofanis plays with n other players. Since they all have the same name, they are numbered from 1 to n.\\n\\nThe players write m comments in the chat. A comment has the structure of \\\"i j c\\\" where i and j are two distinct integers and c is a string (1 ≤ i, j ≤ n; i ≠ j; c is either imposter or crewmate). The comment means that player i said that player j has the role c.\\n\\nAn imposter always lies, and a crewmate always tells the truth. \\n\\nHelp Theofanis find the maximum possible number of imposters among all the other Cypriot players, or determine that the comments contradict each other (see the notes for further explanation).\\n\\nNote that each player has exactly one role: either imposter or crewmate.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. Description of each test case follows.\\n\\nThe first line of each test case contains two integers n and m (1 ≤ n ≤ 2 ⋅ 10^5; 0 ≤ m ≤ 5 ⋅ 10^5) — the number of players except Theofanis and the number of comments.\\n\\nEach of the next m lines contains a comment made by the players of the structure \\\"i j c\\\" where i and j are two distinct integers and c is a string (1 ≤ i, j ≤ n; i ≠ j; c is either imposter or crewmate).\\n\\nThere can be multiple comments for the same pair of (i, j).\\n\\nIt is guaranteed that the sum of all n does not exceed 2 ⋅ 10^5 and the sum of all m does not exceed 5 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print one integer — the maximum possible number of imposters. If the comments contradict each other, print -1.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n3 2\\n1 2 imposter\\n2 3 crewmate\\n5 4\\n1 3 crewmate\\n2 5 crewmate\\n2 4 imposter\\n3 4 imposter\\n2 2\\n1 2 imposter\\n2 1 crewmate\\n3 5\\n1 2 imposter\\n1 2 imposter\\n3 2 crewmate\\n3 2 crewmate\\n1 3 imposter\\n5 0\\n\\n\\nOutput\\n\\n\\n2\\n4\\n-1\\n2\\n5\\n\\nNote\\n\\nIn the first test case, imposters can be Andreas 2 and 3.\\n\\nIn the second test...\\\":\",\"targets\":\"from collections import defaultdict,deque\\nfrom sys import *\\nfor _ in range(int(stdin.readline())):\\n n,k=map(int,stdin.readline().split())\\n d=defaultdict(list)\\n a={}\\n ans=0\\n for i in range(k):\\n x=list(stdin.readline().split())\\n u=int(x[0])\\n v=int(x[1])\\n d[u].append(v)\\n d[v].append(u)\\n if str(u)+\\\" \\\"+str(v) in a and x[2]!=a[str(u)+\\\" \\\"+str(v)]:\\n ans=-1\\n continue\\n a[str(u)+\\\" \\\"+str(v)]=x[2]\\n a[str(v)+\\\" \\\"+str(u)]=x[2]\\n if ans==-1:\\n stdout.write(str(ans)+\\\"\\\\n\\\")\\n continue\\n vis=[-1]*(n+1)\\n for i in range(1,n+1):\\n if vis[i]==-1:\\n q=deque([])\\n vis[i]=0\\n q.append(i)\\n crew=1\\n tot=1\\n while q:\\n s=q.popleft()\\n for j in d[s]:\\n if vis[j]==-1:\\n tot+=1\\n q.append(j)\\n if vis[s]==0:\\n if a[str(s)+\\\" \\\"+str(j)]==\\\"crewmate\\\":\\n vis[j]=0\\n crew+=1\\n else:\\n vis[j]=1\\n else:\\n if a[str(s)+\\\" \\\"+str(j)]==\\\"crewmate\\\":\\n vis[j]=1\\n else:\\n vis[j]=0\\n crew+=1\\n else:\\n if vis[s]==0:\\n if a[str(s)+\\\" \\\"+str(j)]==\\\"crewmate\\\":\\n if vis[j]==1:\\n ans=-1\\n else:\\n if vis[j]==0:\\n ans=-1\\n else:\\n if a[str(s) + \\\" \\\" + str(j)] == \\\"crewmate\\\":\\n if vis[j]==0:\\n ans=-1\\n else:\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given an undirected weighted graph, consisting of n vertices and m edges.\\n\\nSome queries happen with this graph:\\n\\n * Delete an existing edge from the graph. \\n * Add a non-existing edge to the graph. \\n\\n\\n\\nAt the beginning and after each query, you should find four different vertices a, b, c, d such that there exists a path between a and b, there exists a path between c and d, and the sum of lengths of two shortest paths from a to b and from c to d is minimal. The answer to the query is the sum of the lengths of these two shortest paths. The length of the path is equal to the sum of weights of edges in this path.\\n\\nInput\\n\\nThe first line contains two integers n and m (4 ≤ n, m ≤ 10^5) — the number of vertices and edges in the graph respectively.\\n\\nEach of the next m lines contain three integers v, u, w (1 ≤ v, u ≤ n, v ≠ u, 1 ≤ w ≤ 10^9) — this triple means that there is an edge between vertices v and u with weight w.\\n\\nThe next line contains a single integer q (0 ≤ q ≤ 10^5) — the number of queries.\\n\\nThe next q lines contain the queries of two types:\\n\\n * 0 v u — this query means deleting an edge between v and u (1 ≤ v, u ≤ n, v ≠ u). It is guaranteed that such edge exists in the graph. \\n * 1 v u w — this query means adding an edge between vertices v and u with weight w (1 ≤ v, u ≤ n, v ≠ u, 1 ≤ w ≤ 10^9). It is guaranteed that there was no such edge in the graph. \\n\\n\\n\\nIt is guaranteed that the initial graph does not contain multiple edges.\\n\\nAt the beginning and after each query, the graph doesn't need to be connected.\\n\\nIt is guaranteed that at each moment the number of edges will be at least 4. It can be proven, that at each moment there exist some four vertices a, b, c, d such that there exists a path between vertices a and b, and there exists a path between vertices c and d.\\n\\nOutput\\n\\nPrint q + 1 integers — the minimal sum of lengths of shortest paths between chosen pairs of vertices before the queries and after each of them.\\n\\nExample\\n\\nInput\\n\\n\\n6 6\\n1 3 6\\n4 3 1\\n1 4 1\\n2 6 4\\n2 4 2\\n5 4 3\\n4\\n1 2 5 2\\n0 1 4\\n0 3...\",\"targets\":\"#include \\nusing namespace std;\\nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\\ntemplate \\nT rand(T a, T b) {\\n return uniform_int_distribution(a, b)(rng);\\n}\\nconst int c = 100005, k = 140, sok = 2e9;\\nint n, m, q;\\nbool t[c][k];\\nmap, int> el;\\nmultiset s1[c];\\npriority_queue, greater > aa[k][2], bb[k][2];\\nmultiset r;\\nlong long res(int a) {\\n long long ans = 0;\\n int cnt = 0;\\n for (auto x : s1[a]) {\\n ans += x;\\n cnt++;\\n if (cnt == 3) {\\n return ans;\\n }\\n }\\n}\\nvoid valt(int id) {\\n int a, b, suly;\\n cin >> a >> b;\\n if (a > b) {\\n swap(a, b);\\n }\\n if (id) {\\n cin >> el[{a, b}];\\n }\\n suly = el[{a, b}];\\n if (!id) {\\n el.erase({a, b});\\n }\\n r.erase(r.find(res(a))), r.erase(r.find(res(b)));\\n if (id) {\\n s1[a].insert(suly), s1[b].insert(suly);\\n } else {\\n s1[a].erase(s1[a].find(suly)), s1[b].erase(s1[b].find(suly));\\n }\\n r.insert(res(a)), r.insert(res(b));\\n for (int i = 0; i < k; i++) {\\n if (t[a][i] == t[b][i]) {\\n int h = t[a][i];\\n if (id) {\\n aa[i][h].push(suly);\\n } else {\\n bb[i][h].push(suly);\\n }\\n }\\n }\\n}\\nvoid calc() {\\n long long mini = *(r.begin());\\n for (int i = 0; i < k; i++) {\\n long long sum = 0;\\n for (int j = 0; j < 2; j++) {\\n while (aa[i][j].top() == bb[i][j].top()) {\\n aa[i][j].pop(), bb[i][j].pop();\\n }\\n sum += aa[i][j].top();\\n }\\n mini = min(mini, sum);\\n }\\n cout << mini << \\\"\\\\n\\\";\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(0);\\n cin >> n >> m;\\n for (int i = 1; i <= n; i++) {\\n for (int j = 1; j <= 3; j++) {\\n s1[i].insert(sok);\\n }\\n r.insert(res(i));\\n }\\n for (int j = 0; j < k; j++) {\\n for (int i = 1; i <= n; i++) {\\n t[i][j] = rand(0, 1);\\n }\\n aa[j][0].push(sok), aa[j][1].push(sok);\\n bb[j][0].push(sok + 1), bb[j][1].push(sok + 1);\\n }\\n for (int i = 1; i <= m; i++) {\\n valt(1);\\n }\\n calc();\\n cin >> q;\\n for (int i = 1; i <= q; i++) {\\n int id;\\n cin >>...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"A dragon symbolizes wisdom, power and wealth. On Lunar New Year's Day, people model a dragon with bamboo strips and clothes, raise them with rods, and hold the rods high and low to resemble a flying dragon.\\n\\nA performer holding the rod low is represented by a 1, while one holding it high is represented by a 2. Thus, the line of performers can be represented by a sequence a1, a2, ..., an.\\n\\nLittle Tommy is among them. He would like to choose an interval [l, r] (1 ≤ l ≤ r ≤ n), then reverse al, al + 1, ..., ar so that the length of the longest non-decreasing subsequence of the new sequence is maximum.\\n\\nA non-decreasing subsequence is a sequence of indices p1, p2, ..., pk, such that p1 < p2 < ... < pk and ap1 ≤ ap2 ≤ ... ≤ apk. The length of the subsequence is k.\\n\\nInput\\n\\nThe first line contains an integer n (1 ≤ n ≤ 2000), denoting the length of the original sequence.\\n\\nThe second line contains n space-separated integers, describing the original sequence a1, a2, ..., an (1 ≤ ai ≤ 2, i = 1, 2, ..., n).\\n\\nOutput\\n\\nPrint a single integer, which means the maximum possible length of the longest non-decreasing subsequence of the new sequence.\\n\\nExamples\\n\\nInput\\n\\n4\\n1 2 1 2\\n\\n\\nOutput\\n\\n4\\n\\n\\nInput\\n\\n10\\n1 1 2 2 2 1 1 2 2 1\\n\\n\\nOutput\\n\\n9\\n\\nNote\\n\\nIn the first example, after reversing [2, 3], the array will become [1, 1, 2, 2], where the length of the longest non-decreasing subsequence is 4.\\n\\nIn the second example, after reversing [3, 7], the array will become [1, 1, 1, 1, 2, 2, 2, 2, 2, 1], where the length of the longest non-decreasing subsequence is 9.\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint a[2005], pre1[2005], aft2[2005];\\nint n;\\nint main() {\\n cin >> n;\\n for (int i = 1; i <= n; i++) {\\n cin >> a[i];\\n pre1[i] = pre1[i - 1] + (a[i] == 1);\\n }\\n for (int i = n; i >= 1; i--) aft2[i] = aft2[i + 1] + (a[i] == 2);\\n int ans = 0;\\n int kk, s1, s2;\\n for (int k = 1; k <= n; k++) {\\n int sum1 = 0, sum2 = 0;\\n for (int i = 1; i <= k; i++)\\n sum1 = max(sum1, pre1[i] + aft2[i] - aft2[k + 1]);\\n for (int i = k; i <= n; i++)\\n sum2 = max(sum2, aft2[i + 1] + pre1[i] - pre1[k]);\\n if (ans < sum1 + sum2) {\\n ans = sum1 + sum2;\\n kk = k;\\n s1 = sum1;\\n s2 = sum2;\\n }\\n }\\n cout << ans << endl;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Ayush is a cashier at the shopping center. Recently his department has started a ''click and collect\\\" service which allows users to shop online. \\n\\nThe store contains k items. n customers have already used the above service. Each user paid for m items. Let aij denote the j-th item in the i-th person's order.\\n\\nDue to the space limitations all the items are arranged in one single row. When Ayush receives the i-th order he will find one by one all the items aij (1 ≤ j ≤ m) in the row. Let pos(x) denote the position of the item x in the row at the moment of its collection. Then Ayush takes time equal to pos(ai1) + pos(ai2) + ... + pos(aim) for the i-th customer.\\n\\nWhen Ayush accesses the x-th element he keeps a new stock in the front of the row and takes away the x-th element. Thus the values are updating.\\n\\nYour task is to calculate the total time it takes for Ayush to process all the orders.\\n\\nYou can assume that the market has endless stock.\\n\\nInput\\n\\nThe first line contains three integers n, m and k (1 ≤ n, k ≤ 100, 1 ≤ m ≤ k) — the number of users, the number of items each user wants to buy and the total number of items at the market.\\n\\nThe next line contains k distinct integers pl (1 ≤ pl ≤ k) denoting the initial positions of the items in the store. The items are numbered with integers from 1 to k.\\n\\nEach of the next n lines contains m distinct integers aij (1 ≤ aij ≤ k) — the order of the i-th person.\\n\\nOutput\\n\\nPrint the only integer t — the total time needed for Ayush to process all the orders.\\n\\nExample\\n\\nInput\\n\\n2 2 5\\n3 4 1 2 5\\n1 5\\n3 1\\n\\n\\nOutput\\n\\n14\\n\\nNote\\n\\nCustomer 1 wants the items 1 and 5.\\n\\npos(1) = 3, so the new positions are: [1, 3, 4, 2, 5].\\n\\npos(5) = 5, so the new positions are: [5, 1, 3, 4, 2].\\n\\nTime taken for the first customer is 3 + 5 = 8.\\n\\nCustomer 2 wants the items 3 and 1.\\n\\npos(3) = 3, so the new positions are: [3, 5, 1, 4, 2].\\n\\npos(1) = 3, so the new positions are: [1, 3, 5, 4, 2].\\n\\nTime taken for the second customer is 3 + 3 = 6.\\n\\nTotal time is 8 + 6 = 14.\\n\\nFormally pos(x) is the index of x in the...\\nUsing java can you solve the prior task?\",\"targets\":\"import java.io.OutputStream;\\nimport java.io.IOException;\\nimport java.io.InputStream;\\nimport java.io.PrintWriter;\\nimport java.util.Scanner;\\nimport java.util.ArrayList;\\n\\n\\/**\\n * Built using CHelper plug-in\\n * Actual solution is at the top\\n *\\n * @author Aviously\\n *\\/\\npublic class Main {\\n public static void main(String[] args) {\\n InputStream inputStream = System.in;\\n OutputStream outputStream = System.out;\\n Scanner in = new Scanner(inputStream);\\n PrintWriter out = new PrintWriter(outputStream);\\n TaskB solver = new TaskB();\\n solver.solve(1, in, out);\\n out.close();\\n }\\n\\n static class TaskB {\\n public void solve(int testNumber, Scanner in, PrintWriter out) {\\n int n = in.nextInt();\\n int m = in.nextInt();\\n int k = in.nextInt();\\n int time = 0;\\n ArrayList a = new ArrayList<>();\\n for (int i = 0; i < k; i++) {\\n a.add(in.nextInt());\\n }\\n for (int i = 0; i < n; i++) {\\n for (int j = 0; j < m; j++) {\\n int item = in.nextInt();\\n int x = a.indexOf(item);\\n a.remove(x);\\n a.add(0, item);\\n time += x + 1;\\n }\\n }\\n out.println(time);\\n }\\n\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alice has just learned addition. However, she hasn't learned the concept of \\\"carrying\\\" fully — instead of carrying to the next column, she carries to the column two columns to the left.\\n\\nFor example, the regular way to evaluate the sum 2039 + 2976 would be as shown: \\n\\n\\n\\nHowever, Alice evaluates it as shown: \\n\\n\\n\\nIn particular, this is what she does: \\n\\n * add 9 and 6 to make 15, and carry the 1 to the column two columns to the left, i. e. to the column \\\"0 9\\\"; \\n * add 3 and 7 to make 10 and carry the 1 to the column two columns to the left, i. e. to the column \\\"2 2\\\"; \\n * add 1, 0, and 9 to make 10 and carry the 1 to the column two columns to the left, i. e. to the column above the plus sign; \\n * add 1, 2 and 2 to make 5; \\n * add 1 to make 1. \\n\\nThus, she ends up with the incorrect result of 15005.\\n\\nAlice comes up to Bob and says that she has added two numbers to get a result of n. However, Bob knows that Alice adds in her own way. Help Bob find the number of ordered pairs of positive integers such that when Alice adds them, she will get a result of n. Note that pairs (a, b) and (b, a) are considered different if a ≠ b.\\n\\nInput\\n\\nThe input consists of multiple test cases. The first line contains an integer t (1 ≤ t ≤ 1000) — the number of test cases. The description of the test cases follows.\\n\\nThe only line of each test case contains an integer n (2 ≤ n ≤ 10^9) — the number Alice shows Bob.\\n\\nOutput\\n\\nFor each test case, output one integer — the number of ordered pairs of positive integers such that when Alice adds them, she will get a result of n. \\n\\nExample\\n\\nInput\\n\\n\\n5\\n100\\n12\\n8\\n2021\\n10000\\n\\n\\nOutput\\n\\n\\n9\\n4\\n7\\n44\\n99\\n\\nNote\\n\\nIn the first test case, when Alice evaluates any of the sums 1 + 9, 2 + 8, 3 + 7, 4 + 6, 5 + 5, 6 + 4, 7 + 3, 8 + 2, or 9 + 1, she will get a result of 100. The picture below shows how Alice evaluates 6 + 4: \\n\\n\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst int maxv = 50010;\\nconst int maxn = 50010;\\n#pragma warning(disable : 4996)\\nint T;\\nstring S;\\nvoid solve() {\\n if (S.length() == 1) {\\n cout << stoll(S) - 1 << endl;\\n return;\\n }\\n string a = \\\"\\\", b = \\\"\\\";\\n for (int i = 0; i < S.length(); i++) {\\n if (i % 2)\\n a += S[i];\\n else\\n b += S[i];\\n }\\n long long x = stoll(a), y = stoll(b);\\n cout << (x + 1) * (y + 1) - 2 << endl;\\n}\\nint main() {\\n ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);\\n cin >> T;\\n while (T--) {\\n cin >> S;\\n solve();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"This is an easier version of the problem with smaller constraints.\\n\\nKorney Korneevich dag up an array a of length n. Korney Korneevich has recently read about the operation [bitwise XOR](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#XOR), so he wished to experiment with it. For this purpose, he decided to find all integers x ≥ 0 such that there exists an increasing subsequence of the array a, in which the bitwise XOR of numbers is equal to x.\\n\\nIt didn't take a long time for Korney Korneevich to find all such x, and he wants to check his result. That's why he asked you to solve this problem!\\n\\nA sequence s is a subsequence of a sequence b if s can be obtained from b by deletion of several (possibly, zero or all) elements.\\n\\nA sequence s_1, s_2, … , s_m is called increasing if s_1 < s_2 < … < s_m.\\n\\nInput\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 10^5).\\n\\nThe second line contains n integers a_1, a_2, …, a_n (0 ≤ a_i ≤ 500) — the elements of the array a.\\n\\nOutput\\n\\nIn the first line print a single integer k — the number of found x values.\\n\\nIn the second line print k integers in increasing order x_1, x_2, … x_k (0 ≤ x_1 < … < x_k) — found x values.\\n\\nExamples\\n\\nInput\\n\\n\\n4\\n4 2 2 4\\n\\n\\nOutput\\n\\n\\n4\\n0 2 4 6 \\n\\n\\nInput\\n\\n\\n8\\n1 0 1 7 12 5 3 2\\n\\n\\nOutput\\n\\n\\n12\\n0 1 2 3 4 5 6 7 10 11 12 13 \\n\\nNote\\n\\nIn the first test case:\\n\\n * To get value x = 0 it is possible to choose and empty subsequence \\n * To get value x = 2 it is possible to choose a subsequence [2] \\n * To get value x = 4 it is possible to choose a subsequence [4] \\n * To get value x = 6 it is possible to choose a subsequence [2, 4] \\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nvoid solve() {\\n int mx = 500 + 1, mxor = 512;\\n int n;\\n cin >> n;\\n vector v(n + 1);\\n vector> idx(mx);\\n for (int i = 1; i <= n; ++i) {\\n cin >> v[i];\\n idx[v[i]].push_back(i);\\n }\\n vector mi(mxor, n + 1);\\n mi[0] = 0;\\n vector> dp(mx, vector(mxor, n + 1));\\n dp[0][0] = 0;\\n for (int i = 1; i < mx; ++i) {\\n for (int j = 0; j < mxor; ++j) {\\n int c = i ^ j;\\n int z = mi[c];\\n auto nx = lower_bound(idx[i].begin(), idx[i].end(), z + 1);\\n if (nx != idx[i].end()) {\\n dp[i][j] = *nx;\\n }\\n }\\n for (int j = 0; j < mxor; ++j) {\\n mi[j] = min(mi[j], dp[i][j]);\\n }\\n }\\n vector a;\\n for (int j = 0; j < mxor; ++j) {\\n for (int i = 0; i < mx; ++i) {\\n if (dp[i][j] <= n) {\\n a.push_back(j);\\n break;\\n }\\n }\\n }\\n cout << a.size() << endl;\\n for (auto x : a) {\\n cout << x << ' ';\\n }\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(0);\\n solve();\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A string is called square if it is some string written twice in a row. For example, the strings \\\"aa\\\", \\\"abcabc\\\", \\\"abab\\\" and \\\"baabaa\\\" are square. But the strings \\\"aaa\\\", \\\"abaaab\\\" and \\\"abcdabc\\\" are not square.\\n\\nFor a given string s determine if it is square.\\n\\nInput\\n\\nThe first line of input data contains an integer t (1 ≤ t ≤ 100) —the number of test cases.\\n\\nThis is followed by t lines, each containing a description of one test case. The given strings consist only of lowercase Latin letters and have lengths between 1 and 100 inclusive.\\n\\nOutput\\n\\nFor each test case, output on a separate line:\\n\\n * YES if the string in the corresponding test case is square, \\n * NO otherwise. \\n\\n\\n\\nYou can output YES and NO in any case (for example, strings yEs, yes, Yes and YES will be recognized as a positive response).\\n\\nExample\\n\\nInput\\n\\n\\n10\\na\\naa\\naaa\\naaaa\\nabab\\nabcabc\\nabacaba\\nxxyy\\nxyyx\\nxyxy\\n\\n\\nOutput\\n\\n\\nNO\\nYES\\nNO\\nYES\\nYES\\nYES\\nNO\\nNO\\nNO\\nYES\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nvoid check(string str) {\\n int flag = 0;\\n if (str.size() % 2 != 0) {\\n cout << \\\"NO\\\" << endl;\\n } else {\\n int n = (str.size() - 1) \\/ 2;\\n for (int i = 0; i <= n; i++) {\\n if (str[i] != str[n + 1 + i]) {\\n flag = 1;\\n }\\n }\\n if (flag == 1) {\\n cout << \\\"NO\\\" << endl;\\n } else {\\n cout << \\\"YES\\\" << endl;\\n }\\n }\\n}\\nint main() {\\n int t;\\n cin >> t;\\n while (t--) {\\n string str;\\n cin >> str;\\n check(str);\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Chris the Rabbit has been interested in arrays ever since he was a child. At the moment he is researching arrays with the length of n, containing only integers from 1 to n. He is not good at math, that's why some simple things drive him crazy. For example, yesterday he grew keen on counting how many different beautiful arrays there are. Chris thinks that an array is beautiful if it meets one of the two conditions: \\n\\n * each elements, starting from the second one, is no more than the preceding one \\n * each element, starting from the second one, is no less than the preceding one \\n\\n\\n\\nHaving got absolutely mad at himself and at math, Chris came to Stewie and Brian to ask them for help. However, they only laughed at him and said that the answer is too simple and not interesting. Help Chris the Rabbit to find the answer at last.\\n\\nInput\\n\\nThe single line contains an integer n which is the size of the array (1 ≤ n ≤ 105).\\n\\nOutput\\n\\nYou must print the answer on a single line. As it can be rather long, you should print it modulo 1000000007.\\n\\nExamples\\n\\nInput\\n\\n2\\n\\n\\nOutput\\n\\n4\\n\\n\\nInput\\n\\n3\\n\\n\\nOutput\\n\\n17\\\":\",\"targets\":\"#include \\nusing namespace std;\\nvoid extgcd(long long a, long long b, long long &d, long long &x,\\n long long &y) {\\n if (!b) {\\n d = a;\\n x = 1;\\n y = 0;\\n } else {\\n extgcd(b, a % b, d, y, x);\\n y = (y - x * (a \\/ b)) % 1000000007;\\n }\\n}\\nlong long mod(long long x, long long n) { return (x % n + n) % n; }\\nlong long inv(long long a, long long n) {\\n long long d, x, y;\\n extgcd(a, n, d, x, y);\\n return d == 1 ? mod(x, n) : -1;\\n}\\nlong long fact(long long r, long long n) {\\n int i;\\n long long res = 1;\\n for (i = r; i <= n; i++) res = (i * res) % 1000000007;\\n return res;\\n}\\nlong long cal(int n) {\\n long long res;\\n res = fact(n, 2 * n - 1);\\n res = (res * inv(fact(1, n), 1000000007)) % 1000000007;\\n return res;\\n}\\nint main() {\\n int n;\\n long long res;\\n cin >> n;\\n res = cal(n);\\n cout << (2 * res - n) % 1000000007;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"During the break the schoolchildren, boys and girls, formed a queue of n people in the canteen. Initially the children stood in the order they entered the canteen. However, after a while the boys started feeling awkward for standing in front of the girls in the queue and they started letting the girls move forward each second. \\n\\nLet's describe the process more precisely. Let's say that the positions in the queue are sequentially numbered by integers from 1 to n, at that the person in the position number 1 is served first. Then, if at time x a boy stands on the i-th position and a girl stands on the (i + 1)-th position, then at time x + 1 the i-th position will have a girl and the (i + 1)-th position will have a boy. The time is given in seconds.\\n\\nYou've got the initial position of the children, at the initial moment of time. Determine the way the queue is going to look after t seconds.\\n\\nInput\\n\\nThe first line contains two integers n and t (1 ≤ n, t ≤ 50), which represent the number of children in the queue and the time after which the queue will transform into the arrangement you need to find. \\n\\nThe next line contains string s, which represents the schoolchildren's initial arrangement. If the i-th position in the queue contains a boy, then the i-th character of string s equals \\\"B\\\", otherwise the i-th character equals \\\"G\\\".\\n\\nOutput\\n\\nPrint string a, which describes the arrangement after t seconds. If the i-th position has a boy after the needed time, then the i-th character a must equal \\\"B\\\", otherwise it must equal \\\"G\\\".\\n\\nExamples\\n\\nInput\\n\\n5 1\\nBGGBG\\n\\n\\nOutput\\n\\nGBGGB\\n\\n\\nInput\\n\\n5 2\\nBGGBG\\n\\n\\nOutput\\n\\nGGBGB\\n\\n\\nInput\\n\\n4 1\\nGGGB\\n\\n\\nOutput\\n\\nGGGB\\nimpor\",\"targets\":\"t sys\\n\\n[n, t] = map(int, sys.stdin.readline().strip().split())\\nq = sys.stdin.readline().strip()\\nans = ''\\n\\nfor i in range(0,t):\\n j = 0\\n ans = ''\\n while (j The figure shows the placement of the numbers from 1 to 10. The following actions are denoted by the arrows.\\n\\nThe leftmost topmost cell of the table is filled with the number 1. Then he writes in the table all positive integers beginning from 2 sequentially using the following algorithm.\\n\\nFirst, Polycarp selects the leftmost non-filled cell in the first row and fills it. Then, while the left neighbor of the last filled cell is filled, he goes down and fills the next cell. So he goes down until the last filled cell has a non-filled neighbor to the left (look at the vertical arrow going down in the figure above).\\n\\nAfter that, he fills the cells from the right to the left until he stops at the first column (look at the horizontal row in the figure above). Then Polycarp selects the leftmost non-filled cell in the first row, goes down, and so on.\\n\\nA friend of Polycarp has a favorite number k. He wants to know which cell will contain the number. Help him to find the indices of the row and the column, such that the intersection of the row and the column is the cell containing the number k.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 100) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one line containing one integer k (1 ≤ k ≤ 10^9) which location must be found.\\n\\nOutput\\n\\nFor each test case, output in a separate line two integers r and c (r, c ≥ 1) separated by spaces — the indices of the row and the column containing the cell filled by the number k, respectively.\\n\\nExample\\n\\nInput\\n\\n\\n7\\n11\\n14\\n5\\n4\\n1\\n2\\n1000000000\\n\\n\\nOutput\\n\\n\\n2 4\\n4 3\\n1 3\\n2 1\\n1 1\\n1 2\\n31623 14130\",\"targets\":\"import java.util.Scanner;\\n\\npublic class codeforces {\\n\\n\\tpublic static void main(String[] args) {\\n\\tScanner sc = new Scanner(System.in);\\n\\n\\twhile(sc.hasNext()) {\\n\\t\\tint t = sc.nextInt();\\n\\t\\twhile(t-->0) {\\n long n = sc.nextLong();\\n long temp = 1000000000;\\n long cnt = 0;\\n boolean flag = true;\\n int i = 1;\\n while(flag) {\\n\\t long pow = i*i;\\n\\t if(pow>=n) {\\n\\t\\t cnt = i-1;\\n\\t\\t flag = false;\\n\\t\\t break;\\n\\t }\\n\\t i++;\\n }\\n \\n long r = cnt+1;\\n long c = cnt+1;\\n \\n long rem = (cnt+1)*(cnt+1) - cnt;\\n\\n if(n\\nusing namespace std;\\nstruct City {\\n int idx;\\n int depth;\\n vector children;\\n vector> costs;\\n};\\nstd::vector cities(300000 + 1);\\nauto cmp = [](const pair &city1,\\n const pair &city2) {\\n if (city1.first != city2.first) {\\n return city1.first > city2.first;\\n }\\n return cities[city1.second].depth > cities[city2.second].depth;\\n};\\nstruct SkewHeapNode {\\n SkewHeapNode *left = nullptr, *right = nullptr;\\n pair key;\\n int64_t addition = 0;\\n int dist = 0;\\n static pair get_key(SkewHeapNode *node) {\\n return {node->key.first + node->addition, node->key.second};\\n }\\n static pair split(SkewHeapNode *node) {\\n push(node);\\n return {node->left, node->right};\\n }\\n static void push(SkewHeapNode *node) {\\n if (node->left) node->left->addition += node->addition;\\n if (node->right) node->right->addition += node->addition;\\n node->key.first += node->addition;\\n node->addition = 0;\\n }\\n static SkewHeapNode *merge(SkewHeapNode *first, SkewHeapNode *second) {\\n if (first == nullptr) return second;\\n if (second == nullptr) return first;\\n push(first);\\n push(second);\\n if (first->key > second->key) swap(first, second);\\n first->right = merge(first->right, second);\\n if (!first->left || first->right->dist > first->left->dist) {\\n swap(first->left, first->right);\\n }\\n first->dist = first->right ? (first->right->dist + 1) : 0;\\n return first;\\n }\\n static void shift(SkewHeapNode *node, int64_t addition) {\\n if (!node) return;\\n node->addition += addition;\\n }\\n};\\nclass SkewHeap {\\n SkewHeapNode *heap = nullptr;\\n\\n public:\\n pair top() { return SkewHeapNode::get_key(heap); }\\n void insert(pair key) {\\n SkewHeapNode *node = new SkewHeapNode();\\n node->key = key;\\n heap = SkewHeapNode::merge(heap, node);\\n }\\n void pop() {\\n auto spl = SkewHeapNode::split(heap);\\n heap =...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Nate U. Smith runs a railroad company in a metropolitan area. In addition to his railroad company, there are rival railroad companies in this metropolitan area. The two companies are in a competitive relationship with each other.\\n\\nIn this metropolitan area, all lines are routed by the line segment connecting the stations at both ends in order to facilitate train operation. In addition, all lines are laid elevated or underground to avoid the installation of railroad crossings. Existing lines either run elevated over the entire line or run underground over the entire line.\\n\\nBy the way, recently, two blocks A and B in this metropolitan area have been actively developed, so Nate's company decided to establish a new line between these blocks. As with the conventional line, this new line wants to use a line segment with A and B at both ends as a route, but since there is another line in the middle of the route, the entire line will be laid either elevated or underground. That is impossible. Therefore, we decided to lay a part of the line elevated and the rest underground. At this time, where the new line intersects with the existing line of the company, in order to make the connection between the new line and the existing line convenient, if the existing line is elevated, the new line is also elevated, and if the existing line is underground, the new line is new. The line should also run underground. Also, where the new line intersects with the existing line of another company, the new line should run underground if the existing line is elevated, and the new line should run underground if the existing line is underground. It does not matter whether stations A and B are located elevated or underground.\\n\\nAs a matter of course, a doorway must be provided where the new line moves from elevated to underground or from underground to elevated. However, since it costs money to provide entrances and exits, we would like to minimize the number of entrances and exits to be provided on new routes. Thinking it would require...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nusing ll = long long;\\nusing ld = long double;\\nusing P = pair;\\nusing vi = vector;\\nusing vvi = vector>;\\nusing vll = vector;\\nusing vvll = vector>;\\nconst double eps = 1e-10;\\nconst ll MOD = 1000000007;\\nconst int INF = 1000000000;\\nconst ll LINF = 1ll<<50;\\ntemplate\\nvoid printv(const vector& s) {\\n for(int i=0;i<(int)(s.size());++i) {\\n cout << s[i];\\n if(i == (int)(s.size())-1) cout << endl;\\n else cout << \\\" \\\";\\n }\\n}\\ntemplate\\nostream& operator<<(ostream &os, const pair p) {\\n os << p.first << \\\":\\\" << p.second;\\n return os;\\n}\\nusing Point = std::complex;\\nconst ld pi = acos(-1.0);\\nnamespace std {\\nbool operator<(const Point &lhs, const Point &rhs) {\\n if (lhs.real() < rhs.real() - eps) return true;\\n if (lhs.real() > rhs.real() + eps) return false;\\n return lhs.imag() < rhs.imag();\\n}\\n}\\nPoint input_point() {\\n ld x, y;\\n std::cin >> x >> y;\\n return Point(x, y);\\n}\\nbool eq(ld a, ld b) { return (abs(a - b) < eps); }\\nld dot(Point a, Point b) { return real(conj(a) * b); }\\nld cross(Point a, Point b) { return imag(conj(a) * b); }\\nint ccw(Point a, Point b, Point c) {\\n b -= a;\\n c -= a;\\n if (cross(b, c) > eps) return 1;\\n if (cross(b, c) < -eps) return -1;\\n if (dot(b, c) < 0) return 2;\\n if (norm(b) < norm(c)) return -2;\\n return 0;\\n}\\nclass Line {\\n public:\\n Point a, b;\\n Line() : a(Point(0, 0)), b(Point(0, 0)) {}\\n Line(Point a, Point b) : a(a), b(b) {}\\n};\\nld dot(Line l, Line m) { return dot((l.a - l.b), (m.a - m.b)); }\\nbool isis_ll(Line l, Line m) { return !eq(cross(l.b - l.a, m.b - m.a), 0); }\\nbool isis_ls(Line l, Line s) {\\n return isis_ll(l, s) &&\\n (cross(l.b - l.a, s.a - l.a) * cross(l.b - l.a, s.b - l.a) < eps);\\n}\\nbool isis_ss(Line s, Line t) {\\n return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 &&\\n ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;\\n}\\nbool isis_lp(Line l, Point p) { return (abs(cross(l.b - p, l.a - p)) < eps); }\\nbool isis_sp(Line s, Point p) {\\n ...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"Berland Music is a music streaming service built specifically to support Berland local artist. Its developers are currently working on a song recommendation module.\\n\\nSo imagine Monocarp got recommended n songs, numbered from 1 to n. The i-th song had its predicted rating equal to p_i, where 1 ≤ p_i ≤ n and every integer from 1 to n appears exactly once. In other words, p is a permutation.\\n\\nAfter listening to each of them, Monocarp pressed either a like or a dislike button. Let his vote sequence be represented with a string s, such that s_i=0 means that he disliked the i-th song, and s_i=1 means that he liked it.\\n\\nNow the service has to re-evaluate the song ratings in such a way that:\\n\\n * the new ratings q_1, q_2, ..., q_n still form a permutation (1 ≤ q_i ≤ n; each integer from 1 to n appears exactly once); \\n * every song that Monocarp liked should have a greater rating than every song that Monocarp disliked (formally, for all i, j such that s_i=1 and s_j=0, q_i>q_j should hold). \\n\\n\\n\\nAmong all valid permutations q find the one that has the smallest value of ∑_{i=1}^n |p_i-q_i|, where |x| is an absolute value of x.\\n\\nPrint the permutation q_1, q_2, ..., q_n. If there are multiple answers, you can print any of them.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.\\n\\nThe first line of each testcase contains a single integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of songs.\\n\\nThe second line of each testcase contains n integers p_1, p_2, ..., p_n (1 ≤ p_i ≤ n) — the permutation of the predicted ratings.\\n\\nThe third line contains a single string s, consisting of n characters. Each character is either a 0 or a 1. 0 means that Monocarp disliked the song, and 1 means that he liked it.\\n\\nThe sum of n over all testcases doesn't exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each testcase, print a permutation q — the re-evaluated ratings of the songs. If there are multiple answers such that ∑_{i=1}^n |p_i-q_i| is minimum possible, you can print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n2\\n1 2\\n10\\n3\\n3 1 2\\n111\\n8\\n2...\\\":\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\n\\npublic class B {\\n public static void main(String[] args) throws IOException {\\n FastReader fr = new FastReader();\\n PrintWriter pr = new PrintWriter(new OutputStreamWriter(System.out));\\n int t = fr.nextInt();\\n\\n while (t-- > 0) {\\n int n = fr.nextInt();\\n\\n Pair[] arr = new Pair[n];\\n\\n for (int i = 0; i < n; i++) {\\n arr[i] = new Pair(fr.nextInt(), 0, i);\\n } \\n\\n String in = fr.nextLine();\\n\\n for (int i = 0; i < arr.length; i++) {\\n arr[i].y = toInt(in.charAt(i) + \\\"\\\");\\n }\\n\\n Arrays.sort(arr, new Comp());\\n\\n int[] out = new int[n];\\n\\n for (int i = 0; i < n; i++) {\\n out[arr[i].i] = i + 1;\\n }\\n\\n String ans = Arrays.toString(out).replaceAll(\\\",\\\", \\\"\\\");\\n pr.println(ans.substring(1, ans.length()-1));\\n }\\n\\n pr.close();\\n }\\n\\n static class Comp implements Comparator {\\n public int compare(Pair a, Pair b) {\\n if (a.y == b.y) {\\n return a.x - b.x;\\n } else {\\n return a.y - b.y;\\n }\\n }\\n }\\n\\n static class Pair {\\n int x, y, i;\\n\\n public Pair(int x, int y, int i) {\\n this.x = x;\\n this.y = y;\\n this.i = i;\\n }\\n }\\n\\n static int gcd(int a, int b) {\\n if (b == 0) return a;\\n return gcd(b, a % b);\\n }\\n\\n static int toInt(String s) {\\n return Integer.parseInt(s);\\n }\\n\\n \\/\\/ MERGE SORT IMPLEMENTATION\\n void sort(int[] arr, int l, int r) {\\n if (l < r) {\\n int m = l + (r - l) \\/ 2;\\n\\n sort(arr, l, m);\\n sort(arr, m + 1, r);\\n\\n \\/\\/ call merge\\n merge(arr, l, m, r);\\n }\\n }\\n\\n void merge(int[] arr, int l, int m, int r) {\\n \\/\\/ find sizes\\n int len1 = m - l + 1;\\n int len2 = r - m;\\n\\n int[] L = new int[len1];\\n int[] R = new...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A couple of friends, Axel and Marston are travelling across the country of Bitland. There are n towns in Bitland, with some pairs of towns connected by one-directional roads. Each road in Bitland is either a pedestrian road or a bike road. There can be multiple roads between any pair of towns, and may even be a road from a town to itself. However, no pair of roads shares the starting and the destination towns along with their types simultaneously.\\n\\nThe friends are now located in the town 1 and are planning the travel route. Axel enjoys walking, while Marston prefers biking. In order to choose a route diverse and equally interesting for both friends, they have agreed upon the following procedure for choosing the road types during the travel:\\n\\n * The route starts with a pedestrian route.\\n * Suppose that a beginning of the route is written in a string s of letters P (pedestrain road) and B (biking road). Then, the string is appended to s, where stands for the string s with each character changed to opposite (that is, all pedestrian roads changed to bike roads, and vice versa).\\n\\n\\n\\nIn the first few steps the route will look as follows: P, PB, PBBP, PBBPBPPB, PBBPBPPBBPPBPBBP, and so on.\\n\\nAfter that the friends start travelling from the town 1 via Bitlandian roads, choosing the next road according to the next character of their route type each time. If it is impossible to choose the next road, the friends terminate their travel and fly home instead.\\n\\nHelp the friends to find the longest possible route that can be travelled along roads of Bitland according to the road types choosing procedure described above. If there is such a route with more than 1018 roads in it, print -1 instead.\\n\\nInput\\n\\nThe first line contains two integers n and m (1 ≤ n ≤ 500, 0 ≤ m ≤ 2n2) — the number of towns and roads in Bitland respectively.\\n\\nNext m lines describe the roads. i-th of these lines contains three integers vi, ui and ti (1 ≤ vi, ui ≤ n, 0 ≤ ti ≤ 1), where vi and ui denote start and destination towns indices of...\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nbitset<501> dp[61][2][501], pre, cur;\\nint n, m;\\nint main() {\\n cin >> n >> m;\\n while (m--) {\\n int u, v, w;\\n cin >> u >> v >> w;\\n dp[0][w][u][v] = 1;\\n }\\n for (int i = 1; i <= 60; i++) {\\n for (int w = 0; w < 2; w++) {\\n for (int x = 1; x <= n; x++) {\\n for (int y = 1; y <= n; y++) {\\n if (dp[i - 1][w][x][y]) {\\n dp[i][w][x] |= dp[i - 1][w ^ 1][y];\\n }\\n }\\n }\\n }\\n }\\n long long ans = 0, w = 0;\\n pre[1] = 1;\\n for (int i = 60; i >= 0; i--) {\\n cur.reset();\\n for (int j = 1; j <= n; j++) {\\n if (pre[j]) cur |= dp[i][w][j];\\n }\\n if (cur.count()) {\\n ans |= (1LL << i);\\n pre = cur;\\n w ^= 1;\\n }\\n }\\n if (ans <= 1e18)\\n cout << ans;\\n else\\n cout << -1;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Ivan has n songs on his phone. The size of the i-th song is a_i bytes. Ivan also has a flash drive which can hold at most m bytes in total. Initially, his flash drive is empty.\\n\\nIvan wants to copy all n songs to the flash drive. He can compress the songs. If he compresses the i-th song, the size of the i-th song reduces from a_i to b_i bytes (b_i < a_i).\\n\\nIvan can compress any subset of the songs (possibly empty) and copy all the songs to his flash drive if the sum of their sizes is at most m. He can compress any subset of the songs (not necessarily contiguous).\\n\\nIvan wants to find the minimum number of songs he needs to compress in such a way that all his songs fit on the drive (i.e. the sum of their sizes is less than or equal to m).\\n\\nIf it is impossible to copy all the songs (even if Ivan compresses all the songs), print \\\"-1\\\". Otherwise print the minimum number of songs Ivan needs to compress.\\n\\nInput\\n\\nThe first line of the input contains two integers n and m (1 ≤ n ≤ 10^5, 1 ≤ m ≤ 10^9) — the number of the songs on Ivan's phone and the capacity of Ivan's flash drive.\\n\\nThe next n lines contain two integers each: the i-th line contains two integers a_i and b_i (1 ≤ a_i, b_i ≤ 10^9, a_i > b_i) — the initial size of the i-th song and the size of the i-th song after compression.\\n\\nOutput\\n\\nIf it is impossible to compress a subset of the songs in such a way that all songs fit on the flash drive, print \\\"-1\\\". Otherwise print the minimum number of the songs to compress.\\n\\nExamples\\n\\nInput\\n\\n4 21\\n10 8\\n7 4\\n3 1\\n5 4\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n4 16\\n10 8\\n7 4\\n3 1\\n5 4\\n\\n\\nOutput\\n\\n-1\\n\\nNote\\n\\nIn the first example Ivan can compress the first and the third songs so after these moves the sum of sizes will be equal to 8 + 7 + 1 + 5 = 21 ≤ 21. Also Ivan can compress the first and the second songs, then the sum of sizes will be equal 8 + 4 + 3 + 5 = 20 ≤ 21. Note that compressing any single song is not sufficient to copy all the songs on the flash drive (for example, after compressing the second song the sum of sizes will be equal to 10 + 4 + 3...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint main(void) {\\n long long int n, m, i, sum = 0, diff, count = 0;\\n cin >> n >> m;\\n pair arr[n];\\n long long int str[n];\\n for (i = 0; i < n; i++) {\\n cin >> arr[i].first >> arr[i].second;\\n str[i] = arr[i].first - arr[i].second;\\n sum += arr[i].first;\\n }\\n sort(str, str + n);\\n diff = sum - m;\\n while (diff > 0 && n >= 1) {\\n n--;\\n diff -= str[n];\\n count++;\\n }\\n if (diff <= 0)\\n cout << count;\\n else\\n cout << -1;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"The only difference between this problem and D1 is that you don't have to provide the way to construct the answer in D1, but you have to do it in this problem.\\n\\nThere's a table of n × m cells (n rows and m columns). The value of n ⋅ m is even.\\n\\nA domino is a figure that consists of two cells having a common side. It may be horizontal (one of the cells is to the right of the other) or vertical (one of the cells is above the other).\\n\\nYou need to place nm\\/2 dominoes on the table so that exactly k of them are horizontal and all the other dominoes are vertical. The dominoes cannot overlap and must fill the whole table.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of a single line. The line contains three integers n, m, k (1 ≤ n,m ≤ 100, 0 ≤ k ≤ nm\\/2, n ⋅ m is even) — the count of rows, columns and horizontal dominoes, respectively.\\n\\nOutput\\n\\nFor each test case:\\n\\n * print \\\"NO\\\" if it's not possible to place the dominoes on the table in the described way; \\n * otherwise, print \\\"YES\\\" on a separate line, then print n lines so that each of them contains m lowercase letters of the Latin alphabet — the layout of the dominoes on the table. Each cell of the table must be marked by the letter so that for every two cells having a common side, they are marked by the same letters if and only if they are occupied by the same domino. I.e. both cells of the same domino must be marked with the same letter, but two dominoes that share a side must be marked with different letters. If there are multiple solutions, print any of them. \\n\\nExample\\n\\nInput\\n\\n\\n8\\n4 4 2\\n2 3 0\\n3 2 3\\n1 2 0\\n2 4 2\\n5 2 2\\n2 17 16\\n2 1 1\\n\\n\\nOutput\\n\\n\\nYES\\naccx\\naegx\\nbega\\nbdda\\nYES\\naha\\naha\\nYES\\nzz\\naa\\nzz\\nNO\\nYES\\naaza\\nbbza\\nNO\\nYES\\nbbaabbaabbaabbaay\\nddccddccddccddccy\\nNO\",\"targets\":\"#include \\nusing namespace std;\\nchar c[105][105];\\nvoid prt(char c[][105], int n, int m) {\\n for (int i = 0; i < n; i++) {\\n for (int j = 0; j < m; j++) {\\n putchar(c[i][j]);\\n }\\n puts(\\\"\\\");\\n }\\n}\\nvoid prt(char c[][105], int n, int m, bool inverse) {\\n for (int i = 0; i < m; i++) {\\n for (int j = 0; j < n; j++) {\\n putchar(c[j][i]);\\n }\\n puts(\\\"\\\");\\n }\\n}\\nvoid analyse(int n, int m, int k, bool inverse) {\\n if (k % 2) {\\n puts(\\\"NO\\\");\\n } else {\\n int lie = k \\/ n;\\n lie += (k % n != 0);\\n if (lie * 2 > m) {\\n puts(\\\"NO\\\");\\n } else {\\n puts(\\\"YES\\\");\\n for (int i = 0; i < n; i++) {\\n for (int j = 0; j < lie - 1; j++) {\\n c[i][j * 2] = c[i][j * 2 + 1] = (i + j) % 2 ? 'b' : 'a';\\n }\\n }\\n int remain = k - (lie - 1) * n;\\n for (int i = 0; i < remain; i++) {\\n int j = lie - 1;\\n c[i][j * 2] = c[i][j * 2 + 1] = (i + j) % 2 ? 'b' : 'a';\\n }\\n if (lie > 0) {\\n int lieRemain = n - remain;\\n for (int i = 0; i * 2 < lieRemain; i++) {\\n int j = (lie - 1) * 2;\\n c[i * 2 + remain][j] = c[i * 2 + 1 + remain][j] =\\n (i + j) % 2 ? 'd' : 'c';\\n c[i * 2 + remain][j + 1] = c[i * 2 + 1 + remain][j + 1] =\\n (i + j + 1) % 2 ? 'd' : 'c';\\n }\\n }\\n for (int j = lie * 2; j < m; j++) {\\n for (int i = 0; i * 2 < n; i++) {\\n c[i * 2][j] = c[i * 2 + 1][j] = (i + j) % 2 ? 'e' : 'f';\\n }\\n }\\n if (inverse) {\\n prt(c, n, m, 1);\\n } else {\\n prt(c, n, m);\\n }\\n }\\n }\\n}\\nint main() {\\n int N;\\n cin >> N;\\n while (N--) {\\n int n, m, k;\\n cin >> n >> m >> k;\\n if (n % 2 == 0) {\\n analyse(n, m, k, 0);\\n } else {\\n swap(n, m);\\n k = n * m \\/ 2 - k;\\n analyse(n, m, k, 1);\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You have received data from a Bubble bot. You know your task is to make factory facilities, but before you even start, you need to know how big the factory is and how many rooms it has. When you look at the data you see that you have the dimensions of the construction, which is in rectangle shape: N x M. \\n\\nThen in the next N lines you have M numbers. These numbers represent factory tiles and they can go from 0 to 15. Each of these numbers should be looked in its binary form. Because from each number you know on which side the tile has walls. For example number 10 in it's binary form is 1010, which means that it has a wall from the North side, it doesn't have a wall from the East, it has a wall on the South side and it doesn't have a wall on the West side. So it goes North, East, South, West. \\n\\nIt is guaranteed that the construction always has walls on it's edges. The input will be correct. \\n\\nYour task is to print the size of the rooms from biggest to smallest. \\n\\nInput\\n\\nThe first line has two numbers which are N and M, the size of the construction. Both are integers: \\n\\nn (1 ≤ n ≤ 10^3)\\n\\nm (1 ≤ m ≤ 10^3)\\n\\nNext N x M numbers represent each tile of construction.\\n\\nOutput\\n\\nOnce you finish processing the data your output consists of one line sorted from biggest to smallest room sizes. \\n\\nExample\\n\\nInput\\n\\n\\n4 5\\n9 14 11 12 13\\n5 15 11 6 7\\n5 9 14 9 14\\n3 2 14 3 14\\n\\n\\nOutput\\n\\n\\n9 4 4 2 1 \\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nint currSize;\\nclass tile {\\n public:\\n bool n, s, e, w;\\n bool visited = false;\\n int i, j;\\n void make_walls(int n);\\n void print() {\\n cout << \\\"(\\\" << i << \\\",\\\" << j << \\\") \\\"\\n << \\\"n \\\" << n << \\\" \\\"\\n << \\\"e \\\" << e << \\\" \\\"\\n << \\\"s \\\" << s << \\\" \\\"\\n << \\\"w \\\" << w << \\\" \\\" << endl;\\n }\\n};\\ntile tiles[1000][1000];\\nvoid tile::make_walls(int x) {\\n w = x & 1;\\n s = (x >> 1) & 1;\\n e = (x >> 2) & 1;\\n n = (x >> 3) & 1;\\n}\\nvoid dfs(int i, int j) {\\n if (tiles[i][j].visited) return;\\n tiles[i][j].visited = true;\\n currSize++;\\n tile t = tiles[i][j];\\n if (!t.n) dfs(i - 1, j);\\n if (!t.e) dfs(i, j + 1);\\n if (!t.s) dfs(i + 1, j);\\n if (!t.w) dfs(i, j - 1);\\n}\\nvoid solve() {\\n int n, m, x;\\n cin >> n >> m;\\n vector sizes;\\n for (int i = 0; i < n; i++) {\\n for (int j = 0; j < m; j++) {\\n tile temp;\\n cin >> x;\\n temp.make_walls(x);\\n temp.i = i;\\n temp.j = j;\\n tiles[i][j] = temp;\\n }\\n }\\n for (int i = 0; i < n; i++) {\\n for (int j = 0; j < m; j++) {\\n if (!tiles[i][j].visited) {\\n currSize = 0;\\n dfs(i, j);\\n sizes.push_back(currSize);\\n }\\n }\\n }\\n sort(sizes.begin(), sizes.end(), greater());\\n for (int x : sizes) {\\n cout << x << \\\" \\\";\\n }\\n}\\nint main() {\\n cin.tie(NULL);\\n ios_base::sync_with_stdio(false);\\n int t = 1;\\n while (t--) {\\n solve();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alicia has an array, a_1, a_2, …, a_n, of non-negative integers. For each 1 ≤ i ≤ n, she has found a non-negative integer x_i = max(0, a_1, …, a_{i-1}). Note that for i=1, x_i = 0.\\n\\nFor example, if Alicia had the array a = \\\\{0, 1, 2, 0, 3\\\\}, then x = \\\\{0, 0, 1, 2, 2\\\\}.\\n\\nThen, she calculated an array, b_1, b_2, …, b_n: b_i = a_i - x_i.\\n\\nFor example, if Alicia had the array a = \\\\{0, 1, 2, 0, 3\\\\}, b = \\\\{0-0, 1-0, 2-1, 0-2, 3-2\\\\} = \\\\{0, 1, 1, -2, 1\\\\}.\\n\\nAlicia gives you the values b_1, b_2, …, b_n and asks you to restore the values a_1, a_2, …, a_n. Can you help her solve the problem?\\n\\nInput\\n\\nThe first line contains one integer n (3 ≤ n ≤ 200 000) – the number of elements in Alicia's array.\\n\\nThe next line contains n integers, b_1, b_2, …, b_n (-10^9 ≤ b_i ≤ 10^9).\\n\\nIt is guaranteed that for the given array b there is a solution a_1, a_2, …, a_n, for all elements of which the following is true: 0 ≤ a_i ≤ 10^9.\\n\\nOutput\\n\\nPrint n integers, a_1, a_2, …, a_n (0 ≤ a_i ≤ 10^9), such that if you calculate x according to the statement, b_1 will be equal to a_1 - x_1, b_2 will be equal to a_2 - x_2, ..., and b_n will be equal to a_n - x_n.\\n\\nIt is guaranteed that there exists at least one solution for the given tests. It can be shown that the solution is unique.\\n\\nExamples\\n\\nInput\\n\\n\\n5\\n0 1 1 -2 1\\n\\n\\nOutput\\n\\n\\n0 1 2 0 3 \\n\\nInput\\n\\n\\n3\\n1000 999999000 -1000000000\\n\\n\\nOutput\\n\\n\\n1000 1000000000 0 \\n\\nInput\\n\\n\\n5\\n2 1 2 2 3\\n\\n\\nOutput\\n\\n\\n2 3 5 7 10 \\n\\nNote\\n\\nThe first test was described in the problem statement.\\n\\nIn the second test, if Alicia had an array a = \\\\{1000, 1000000000, 0\\\\}, then x = \\\\{0, 1000, 1000000000\\\\} and b = \\\\{1000-0, 1000000000-1000, 0-1000000000\\\\} = \\\\{1000, 999999000, -1000000000\\\\}.\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"n=int(input())\\np=input().rstrip().split(' ')\\nS=10000025500000000000;\\nfor i in range(0,len(p)):\\n if S==10000025500000000000 and int(p[i]) < 0:\\n print(int(p[i]),end=' ')\\n else:\\n if int(p[i]) >=0 and S==10000025500000000000:\\n S=int(p[i])\\n print(S,end=' ')\\n elif (int(p[i]) < 0):\\n T=S+int(p[i]);\\n print(T,end=' ')\\n elif (int(p[i]) >= 0):\\n S+=int(p[i])\\n print(S,end=' ')\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"The new generation external memory contains an array of integers a[1 … n] = [a_1, a_2, …, a_n].\\n\\nThis type of memory does not support changing the value of an arbitrary element. Instead, it allows you to cut out any segment of the given array, cyclically shift (rotate) it by any offset and insert it back into the same place.\\n\\nTechnically, each cyclic shift consists of two consecutive actions: \\n\\n 1. You may select arbitrary indices l and r (1 ≤ l < r ≤ n) as the boundaries of the segment. \\n 2. Then you replace the segment a[l … r] with it's cyclic shift to the left by an arbitrary offset d. The concept of a cyclic shift can be also explained by following relations: the sequence [1, 4, 1, 3] is a cyclic shift of the sequence [3, 1, 4, 1] to the left by the offset 1 and the sequence [4, 1, 3, 1] is a cyclic shift of the sequence [3, 1, 4, 1] to the left by the offset 2. \\n\\n\\n\\nFor example, if a = [1, \\\\color{blue}{3, 2, 8}, 5], then choosing l = 2, r = 4 and d = 2 yields a segment a[2 … 4] = [3, 2, 8]. This segment is then shifted by the offset d = 2 to the left, and you get a segment [8, 3, 2] which then takes the place of of the original elements of the segment. In the end you get a = [1, \\\\color{blue}{8, 3, 2}, 5].\\n\\nSort the given array a using no more than n cyclic shifts of any of its segments. Note that you don't need to minimize the number of cyclic shifts. Any method that requires n or less cyclic shifts will be accepted.\\n\\nInput\\n\\nThe first line contains an integer t (1 ≤ t ≤ 1000) — the number of test cases.\\n\\nThe next 2t lines contain the descriptions of the test cases. \\n\\nThe first line of each test case description contains an integer n (2 ≤ n ≤ 50) — the length of the array. The second line consists of space-separated elements of the array a_i (-10^9 ≤ a_i ≤ 10^9). Elements of array a may repeat and don't have to be unique.\\n\\nOutput\\n\\nPrint t answers to all input test cases. \\n\\nThe first line of the answer of each test case should contain an integer k (0 ≤ k ≤ n) — the number of actions to sort the array....\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"import os, sys\\nfrom io import BytesIO, IOBase\\n\\n\\nclass FastIO(IOBase):\\n newlines = 0\\n\\n def __init__(self, file):\\n self._fd = file.fileno()\\n self.buffer = BytesIO()\\n self.writable = \\\"x\\\" in file.mode or \\\"r\\\" not in file.mode\\n self.write = self.buffer.write if self.writable else None\\n\\n def read(self):\\n while True:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, 8192))\\n if not b:\\n break\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines = 0\\n return self.buffer.read()\\n\\n def readline(self):\\n while self.newlines == 0:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, 8192))\\n self.newlines = b.count(b\\\"\\\\n\\\") + (not b)\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines -= 1\\n return self.buffer.readline()\\n\\n def flush(self):\\n if self.writable:\\n os.write(self._fd, self.buffer.getvalue())\\n self.buffer.truncate(0), self.buffer.seek(0)\\n\\n\\nclass IOWrapper(IOBase):\\n def __init__(self, file):\\n self.buffer = FastIO(file)\\n self.flush = self.buffer.flush\\n self.writable = self.buffer.writable\\n self.write = lambda s: self.buffer.write(s.encode(\\\"ascii\\\"))\\n self.read = lambda: self.buffer.read().decode(\\\"ascii\\\")\\n self.readline = lambda: self.buffer.readline().decode(\\\"ascii\\\")\\n\\n\\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\\ninput = lambda: sys.stdin.readline().rstrip(\\\"\\\\r\\\\n\\\")\\ninp = lambda dtype: [dtype(x) for x in input().split()]\\ninp_2d = lambda dtype, n: [dtype(input()) for _ in range(n)]\\ninp_2ds = lambda dtype, n: [inp(dtype) for _ in range(n)]\\ninp_enu = lambda dtype: [(i, x) for i, x in enumerate(inp(dtype))]\\ninp_enus = lambda dtype, n: [[i] + inp(dtype) for i in range(n)]\\nceil1 = lambda a, b: (a + b - 1) \\/\\/ b\\n\\nfor _ in...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON solution for \\\"The numbers 1, 2, ..., n ⋅ k are colored with n colors. These colors are indexed by 1, 2, ..., n. For each 1 ≤ i ≤ n, there are exactly k numbers colored with color i.\\n\\nLet [a, b] denote the interval of integers between a and b inclusive, that is, the set \\\\\\\\{a, a + 1, ..., b\\\\}. You must choose n intervals [a_1, b_1], [a_2, b_2], ..., [a_n, b_n] such that: \\n\\n * for each 1 ≤ i ≤ n, it holds 1 ≤ a_i < b_i ≤ n ⋅ k; \\n * for each 1 ≤ i ≤ n, the numbers a_i and b_i are colored with color i; \\n * each number 1 ≤ x ≤ n ⋅ k belongs to at most \\\\left⌈ (n)\\/(k - 1) \\\\right⌉ intervals. \\n\\n\\n\\nOne can show that such a family of intervals always exists under the given constraints.\\n\\nInput\\n\\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 2 ≤ k ≤ 100) — the number of colors and the number of occurrences of each color.\\n\\nThe second line contains n ⋅ k integers c_1, c_2, ..., c_{nk} (1 ≤ c_j ≤ n), where c_j is the color of number j. It is guaranteed that, for each 1 ≤ i ≤ n, it holds c_j = i for exactly k distinct indices j.\\n\\nOutput\\n\\nOutput n lines. The i-th line should contain the two integers a_i and b_i.\\n\\nIf there are multiple valid choices of the intervals, output any.\\n\\nExamples\\n\\nInput\\n\\n\\n4 3\\n2 4 3 1 1 4 2 3 2 1 3 4\\n\\n\\nOutput\\n\\n\\n4 5\\n1 7\\n8 11\\n6 12\\n\\nInput\\n\\n\\n1 2\\n1 1\\n\\n\\nOutput\\n\\n\\n1 2\\n\\n\\nInput\\n\\n\\n3 3\\n3 1 2 3 2 1 2 1 3\\n\\n\\nOutput\\n\\n\\n6 8\\n3 7\\n1 4\\n\\nInput\\n\\n\\n2 3\\n2 1 1 1 2 2\\n\\n\\nOutput\\n\\n\\n2 3\\n5 6\\n\\nNote\\n\\nIn the first sample, each number can be contained in at most \\\\left⌈ (4)\\/(3 - 1) \\\\right⌉ = 2 intervals. The output is described by the following picture:\\n\\n\\n\\nIn the second sample, the only interval to be chosen is forced to be [1, 2], and each number is indeed contained in at most \\\\left⌈ (1)\\/(2 - 1) \\\\right⌉ = 1 interval.\\n\\nIn the third sample, each number can be contained in at most \\\\left⌈ (3)\\/(3 - 1) \\\\right⌉ = 2 intervals. The output is described by the following picture:\\n\\n\\\":\",\"targets\":\"from __future__ import division,print_function\\nfrom heapq import*\\nfrom math import ceil\\nimport sys\\nle = sys.__stdin__.read().split(\\\"\\\\n\\\")[::-1]\\naf=[]\\nn,k=list(map(int,le.pop().split()))\\nl= list(map(int,le.pop().split()))\\nx = [[0]*k for i in range(n)]\\nix=[0]*n\\nfor a,b in enumerate(l):\\n b-=1\\n x[b][ix[b]]=a+1\\n ix[b]+=1\\navailable=[True]*n\\ndeb,fin=[0]*n,[0]*n\\nfor t in range(1,k):\\n to_sort=sorted((x[i][t],i) for i in range(n) if available[i])\\n for a,b in to_sort[:int(ceil(n\\/(k-1)))]:\\n available[b]=False\\n deb[b]=x[b][t-1]\\n fin[b]=a\\nfor i in range(n):\\n af.append(str(deb[i])+\\\" \\\"+str(fin[i]))\\nprint(\\\"\\\\n\\\".join(map(str,af)))\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Artem is building a new robot. He has a matrix a consisting of n rows and m columns. The cell located on the i-th row from the top and the j-th column from the left has a value a_{i,j} written in it. \\n\\nIf two adjacent cells contain the same value, the robot will break. A matrix is called good if no two adjacent cells contain the same value, where two cells are called adjacent if they share a side. \\n\\nArtem wants to increment the values in some cells by one to make a good.\\n\\nMore formally, find a good matrix b that satisfies the following condition — \\n\\n * For all valid (i,j), either b_{i,j} = a_{i,j} or b_{i,j} = a_{i,j}+1. \\n\\n\\n\\nFor the constraints of this problem, it can be shown that such a matrix b always exists. If there are several such tables, you can output any of them. Please note that you do not have to minimize the number of increments.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10). Description of the test cases follows.\\n\\nThe first line of each test case contains two integers n, m (1 ≤ n ≤ 100, 1 ≤ m ≤ 100) — the number of rows and columns, respectively.\\n\\nThe following n lines each contain m integers. The j-th integer in the i-th line is a_{i,j} (1 ≤ a_{i,j} ≤ 10^9).\\n\\nOutput\\n\\nFor each case, output n lines each containing m integers. The j-th integer in the i-th line is b_{i,j}.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n3 2\\n1 2\\n4 5\\n7 8\\n2 2\\n1 1\\n3 3\\n2 2\\n1 3\\n2 2\\n\\n\\nOutput\\n\\n\\n1 2\\n5 6\\n7 8\\n2 1\\n4 3\\n2 4\\n3 2\\n\\nNote\\n\\nIn all the cases, you can verify that no two adjacent cells have the same value and that b is the same as a with some values incremented by one.\",\"targets\":\"#include \\nusing namespace std;\\ninline long long read() {\\n long long s = 0, w = 1;\\n register char ch = getchar();\\n while (ch < '0' || ch > '9') {\\n if (ch == '-') w = -1;\\n ch = getchar();\\n }\\n while (ch >= '0' && ch <= '9')\\n s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar();\\n return s * w;\\n}\\nsigned main() {\\n for (register long long T = read(); T; T--) {\\n long long n, m;\\n n = read(), m = read();\\n for (register long long i = 1; i <= n; i++, puts(\\\"\\\"))\\n for (register long long j = 1; j <= m; j++) {\\n long long x = read();\\n if ((x & 1) == ((i + j) & 1))\\n printf(\\\"%lld \\\", x + 1);\\n else\\n printf(\\\"%lld \\\", x);\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"This is the easy version of the problem. The only difference between the two versions is the constraint on n. You can make hacks only if all versions of the problem are solved.\\n\\nA forest is an undirected graph without cycles (not necessarily connected).\\n\\nMocha and Diana are friends in Zhijiang, both of them have a forest with nodes numbered from 1 to n, and they would like to add edges to their forests such that: \\n\\n * After adding edges, both of their graphs are still forests. \\n * They add the same edges. That is, if an edge (u, v) is added to Mocha's forest, then an edge (u, v) is added to Diana's forest, and vice versa. \\n\\n\\n\\nMocha and Diana want to know the maximum number of edges they can add, and which edges to add.\\n\\nInput\\n\\nThe first line contains three integers n, m_1 and m_2 (1 ≤ n ≤ 1000, 0 ≤ m_1, m_2 < n) — the number of nodes and the number of initial edges in Mocha's forest and Diana's forest.\\n\\nEach of the next m_1 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the edges in Mocha's forest.\\n\\nEach of the next m_2 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the edges in Diana's forest.\\n\\nOutput\\n\\nThe first line contains only one integer h, the maximum number of edges Mocha and Diana can add (in each forest).\\n\\nEach of the next h lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the edge you add each time.\\n\\nIf there are multiple correct answers, you can print any one of them.\\n\\nExamples\\n\\nInput\\n\\n\\n3 2 2\\n1 2\\n2 3\\n1 2\\n1 3\\n\\n\\nOutput\\n\\n\\n0\\n\\n\\nInput\\n\\n\\n5 3 2\\n5 4\\n2 1\\n4 3\\n4 3\\n1 4\\n\\n\\nOutput\\n\\n\\n1\\n2 4\\n\\n\\nInput\\n\\n\\n8 1 2\\n1 7\\n2 6\\n1 5\\n\\n\\nOutput\\n\\n\\n5\\n5 2\\n2 3\\n3 4\\n4 7\\n6 8\\n\\nNote\\n\\nIn the first example, we cannot add any edge.\\n\\nIn the second example, the initial forests are as follows.\\n\\n\\n\\nWe can add an edge (2, 4).\\n\\n\",\"targets\":\"n,m1,m2=map(int,input().split())\\nr={}\\nx={}\\nt={}\\ny={}\\nfor i in range(1,n+1):\\n r[i]=i\\n x[i]={i}\\n t[i]=i\\n y[i]={i}\\nfor i in range(m1):\\n q,w=map(int,input().split())\\n if r[q]\\nusing namespace std;\\nconst double pi = acos(-1.0);\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n int t;\\n cin >> t;\\n while (t--) {\\n int n;\\n cin >> n;\\n string s;\\n cin >> s;\\n int count = 0;\\n for (int i = 0; i < s.size(); i += 1) {\\n if (s[i] == '2') count++;\\n }\\n if (count == 1 || count == 2) {\\n cout << \\\"NO\\\" << '\\\\n';\\n continue;\\n } else\\n cout << \\\"YES\\\" << '\\\\n';\\n char a[n][n];\\n for (int i = 0; i < n; i += 1) {\\n for (int j = 0; j < n; j += 1) {\\n if (i == j)\\n a[i][j] = 'X';\\n else\\n a[i][j] = '=';\\n }\\n }\\n if (count == 0) {\\n for (int i = 0; i < n; i += 1) {\\n for (int j = 0; j < n; j += 1) {\\n cout << a[i][j];\\n }\\n cout << '\\\\n';\\n }\\n continue;\\n }\\n int w = count;\\n for (int i = 0; i < n; i += 1) {\\n for (int j = 0; j < n; j += 1) {\\n if (i != j && s[j] != '1' && w > 0 && (s[i] != '1') && a[i][j] == '=' &&\\n a[j][i] == '=') {\\n a[i][j] = '+';\\n a[j][i] = '-';\\n w--;\\n break;\\n }\\n }\\n }\\n for (int i = 0; i < n; i += 1) {\\n for (int j = 0; j < n; j += 1) {\\n cout << a[i][j];\\n }\\n cout << '\\\\n';\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Theofanis really likes sequences of positive integers, thus his teacher (Yeltsa Kcir) gave him a problem about a sequence that consists of only special numbers.\\n\\nLet's call a positive number special if it can be written as a sum of different non-negative powers of n. For example, for n = 4 number 17 is special, because it can be written as 4^0 + 4^2 = 1 + 16 = 17, but 9 is not.\\n\\nTheofanis asks you to help him find the k-th special number if they are sorted in increasing order. Since this number may be too large, output it modulo 10^9+7.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases.\\n\\nThe first and only line of each test case contains two integers n and k (2 ≤ n ≤ 10^9; 1 ≤ k ≤ 10^9).\\n\\nOutput\\n\\nFor each test case, print one integer — the k-th special number in increasing order modulo 10^9+7.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n3 4\\n2 12\\n105 564\\n\\n\\nOutput\\n\\n\\n9\\n12\\n3595374\\n\\nNote\\n\\nFor n = 3 the sequence is [1,3,4,9...]\\nUsing python3 can you solve the prior task?\",\"targets\":\"import os\\nimport sys\\nfrom io import BytesIO, IOBase\\n\\nBUFSIZE = 8192\\n\\n\\nclass FastIO(IOBase):\\n newlines = 0\\n\\n def __init__(self, file):\\n self._fd = file.fileno()\\n self.buffer = BytesIO()\\n self.writable = \\\"x\\\" in file.mode or \\\"r\\\" not in file.mode\\n self.write = self.buffer.write if self.writable else None\\n\\n def read(self):\\n while True:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n if not b:\\n break\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines = 0\\n return self.buffer.read()\\n\\n def readline(self):\\n while self.newlines == 0:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n self.newlines = b.count(b\\\"\\\\n\\\") + (not b)\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines -= 1\\n return self.buffer.readline()\\n\\n def flush(self):\\n if self.writable:\\n os.write(self._fd, self.buffer.getvalue())\\n self.buffer.truncate(0), self.buffer.seek(0)\\n\\n\\nclass IOWrapper(IOBase):\\n def __init__(self, file):\\n self.buffer = FastIO(file)\\n self.flush = self.buffer.flush\\n self.writable = self.buffer.writable\\n self.write = lambda s: self.buffer.write(s.encode(\\\"ascii\\\"))\\n self.read = lambda: self.buffer.read().decode(\\\"ascii\\\")\\n self.readline = lambda: self.buffer.readline().decode(\\\"ascii\\\")\\n\\n\\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\\ninput = lambda: sys.stdin.readline().rstrip(\\\"\\\\r\\\\n\\\")\\n\\nfrom collections import defaultdict, Counter,deque\\nfrom math import sqrt, log10, log, floor, factorial,gcd\\nfrom bisect import bisect_left, bisect_right\\nfrom itertools import permutations,combinations\\nimport sys, io, os\\ninput = sys.stdin.readline\\ninput=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\\n# sys.setrecursionlimit(10000)\\ninf...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nKolya Gerasimov loves kefir very much. He lives in year 1984 and knows all the details of buying this delicious drink. One day, as you probably know, he found himself in year 2084, and buying kefir there is much more complicated.\\n\\nKolya is hungry, so he went to the nearest milk shop. In 2084 you may buy kefir in a plastic liter bottle, that costs a rubles, or in glass liter bottle, that costs b rubles. Also, you may return empty glass bottle and get c (c < b) rubles back, but you cannot return plastic bottles.\\n\\nKolya has n rubles and he is really hungry, so he wants to drink as much kefir as possible. There were no plastic bottles in his 1984, so Kolya doesn't know how to act optimally and asks for your help.\\n\\nInput\\n\\nFirst line of the input contains a single integer n (1 ≤ n ≤ 1018) — the number of rubles Kolya has at the beginning.\\n\\nThen follow three lines containing integers a, b and c (1 ≤ a ≤ 1018, 1 ≤ c < b ≤ 1018) — the cost of one plastic liter bottle, the cost of one glass liter bottle and the money one can get back by returning an empty glass bottle, respectively.\\n\\nOutput\\n\\nPrint the only integer — maximum number of liters of kefir, that Kolya can drink.\\n\\nExamples\\n\\nInput\\n\\n10\\n11\\n9\\n8\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n10\\n5\\n6\\n1\\n\\n\\nOutput\\n\\n2\\n\\nNote\\n\\nIn the first sample, Kolya can buy one glass bottle, then return it and buy one more glass bottle. Thus he will drink 2 liters of kefir.\\n\\nIn the second sample, Kolya can buy two plastic bottle and get two liters of kefir, or he can buy one liter glass bottle, then return it and buy one plastic bottle. In both cases he will drink two liters of kefir.\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n ifstream fin(\\\"input.txt\\\", ios::in);\\n ios_base::sync_with_stdio(false);\\n cout.tie(0);\\n cin.tie(0);\\n cout << setprecision(10);\\n cout << fixed;\\n long long n, a, b, c;\\n cin >> n >> a >> b >> c;\\n if (a <= b - c) return cout << n \\/ a, 0;\\n if (n < b) {\\n cout << n \\/ a;\\n return 0;\\n }\\n long long ans = 0;\\n long long op = (n - b) \\/ (b - c);\\n ans += op;\\n n -= op * (b - c);\\n if (n >= b) {\\n ans++;\\n n -= b;\\n n += c;\\n }\\n if (n >= b) {\\n ans++;\\n n -= b;\\n n += c;\\n }\\n ans += n \\/ a;\\n cout << ans;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"You have an axis-aligned rectangle room with width W and height H, so the lower left corner is in point (0, 0) and the upper right corner is in (W, H).\\n\\nThere is a rectangular table standing in this room. The sides of the table are parallel to the walls, the lower left corner is in (x_1, y_1), and the upper right corner in (x_2, y_2).\\n\\nYou want to place another rectangular table in this room with width w and height h with the width of the table parallel to the width of the room.\\n\\nThe problem is that sometimes there is not enough space to place the second table without intersecting with the first one (there are no problems with tables touching, though).\\n\\nYou can't rotate any of the tables, but you can move the first table inside the room. \\n\\n Example of how you may move the first table.\\n\\nWhat is the minimum distance you should move the first table to free enough space for the second one?\\n\\nInput\\n\\nThe first line contains the single integer t (1 ≤ t ≤ 5000) — the number of the test cases.\\n\\nThe first line of each test case contains two integers W and H (1 ≤ W, H ≤ 10^8) — the width and the height of the room.\\n\\nThe second line contains four integers x_1, y_1, x_2 and y_2 (0 ≤ x_1 < x_2 ≤ W; 0 ≤ y_1 < y_2 ≤ H) — the coordinates of the corners of the first table.\\n\\nThe third line contains two integers w and h (1 ≤ w ≤ W; 1 ≤ h ≤ H) — the width and the height of the second table.\\n\\nOutput\\n\\nFor each test case, print the minimum distance you should move the first table, or -1 if there is no way to free enough space for the second table.\\n\\nYour answer will be considered correct if its absolute or relative error doesn't exceed 10^{-6}.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n8 5\\n2 1 7 4\\n4 2\\n5 4\\n2 2 5 4\\n3 3\\n1 8\\n0 3 1 6\\n1 5\\n8 1\\n3 0 6 1\\n5 1\\n8 10\\n4 5 7 8\\n8 5\\n\\n\\nOutput\\n\\n\\n1.000000000\\n-1\\n2.000000000\\n2.000000000\\n0.000000000\\n\\nNote\\n\\nThe configuration of the first test case is shown in the picture. But the movement of the first table is not optimal. One of the optimal movement, for example, is to move the table by (0, -1), so the lower left corner...\\\":\",\"targets\":\"import java.io.*;\\nimport java.util.StringTokenizer;\\n\\npublic class Main {\\n \\n public static void main(String[] args) throws IOException {\\n Scanner scn = new Scanner(System.in);\\n OutputWriter out = new OutputWriter(System.out);\\n \\/\\/ Always print a trailing \\\"\\\\n\\\" and close the OutputWriter as shown at the end of your output\\n \\n \\/\\/ example:\\n int t=scn.nextInt();\\n for(int i1=0;i1\\nlisti=Datas.listi(s);listi.sort((x,y)->x[0]!=y[0]?Integer.compare(x[0],y[0]):Integer.compare(x[1],\\ny[1]));int[][]tmp=new int[n][n];for(int i=0;i0){int nplus=n-count[0]-1;if(nplus\\n<2){can=false;}else{tmp[count[0]][count[0]+1]='+';tmp[count[0]+1][count[0]]='-';\\ntmp[count[0]+1][count[0]+2]='+';tmp[count[0]+2][count[0]+1]='-';for(int i=count[0]\\n+2;ipw.println(Datas.join(Arrays.stream(v).mapToObj(u\\n->String.valueOf((char)u))).replace(\\\" \\\",\\\"\\\")));}else{pw.println(\\\"NO\\\");}}static public \\nvoid _main(String[]args)throws IOException{new B().run();}}static class Datas{final \\nstatic String...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Bear Limak wants to become the largest of bears, or at least to become larger than his brother Bob.\\n\\nRight now, Limak and Bob weigh a and b respectively. It's guaranteed that Limak's weight is smaller than or equal to his brother's weight.\\n\\nLimak eats a lot and his weight is tripled after every year, while Bob's weight is doubled after every year.\\n\\nAfter how many full years will Limak become strictly larger (strictly heavier) than Bob?\\n\\nInput\\n\\nThe only line of the input contains two integers a and b (1 ≤ a ≤ b ≤ 10) — the weight of Limak and the weight of Bob respectively.\\n\\nOutput\\n\\nPrint one integer, denoting the integer number of years after which Limak will become strictly larger than Bob.\\n\\nExamples\\n\\nInput\\n\\n4 7\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n4 9\\n\\n\\nOutput\\n\\n3\\n\\n\\nInput\\n\\n1 1\\n\\n\\nOutput\\n\\n1\\n\\nNote\\n\\nIn the first sample, Limak weighs 4 and Bob weighs 7 initially. After one year their weights are 4·3 = 12 and 7·2 = 14 respectively (one weight is tripled while the other one is doubled). Limak isn't larger than Bob yet. After the second year weights are 36 and 28, so the first weight is greater than the second one. Limak became larger than Bob after two years so you should print 2.\\n\\nIn the second sample, Limak's and Bob's weights in next years are: 12 and 18, then 36 and 36, and finally 108 and 72 (after three years). The answer is 3. Remember that Limak wants to be larger than Bob and he won't be satisfied with equal weights.\\n\\nIn the third sample, Limak becomes larger than Bob after the first year. Their weights will be 3 and 2 then.\\nUsing python3 can you solve the prior task?\",\"targets\":\"a,b=map(int,input().split())#1<=a<=b<=10\\ni=0\\nwhile a<=b:\\n i+=1\\n a=a*3\\n b=b*2\\nprint(i)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Currently Tiny is learning Computational Geometry. When trying to solve a problem called \\\"The Closest Pair Of Points In The Plane\\\", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.\\n\\nThe problem is the follows. Given n points in the plane, find a pair of points between which the distance is minimized. Distance between (x1, y1) and (x2, y2) is .\\n\\nThe pseudo code of the unexpected code is as follows:\\n \\n \\n \\n input n \\n for i from 1 to n \\n input the i-th point's coordinates into p[i] \\n sort array p[] by increasing of x coordinate first and increasing of y coordinate second \\n d=INF \\/\\/here INF is a number big enough \\n tot=0 \\n for i from 1 to n \\n for j from (i+1) to n \\n ++tot \\n if (p[j].x-p[i].x>=d) then break \\/\\/notice that \\\"break\\\" is only to be \\n \\/\\/out of the loop \\\"for j\\\" \\n d=min(d,distance(p[i],p[j])) \\n output d \\n \\n\\nHere, tot can be regarded as the running time of the code. Due to the fact that a computer can only run a limited number of operations per second, tot should not be more than k in order not to get Time Limit Exceeded.\\n\\nYou are a great hacker. Would you please help Tiny generate a test data and let the code get Time Limit Exceeded?\\n\\nInput\\n\\nA single line which contains two space-separated integers n and k (2 ≤ n ≤ 2000, 1 ≤ k ≤ 109).\\n\\nOutput\\n\\nIf there doesn't exist such a data which let the given code get TLE, print \\\"no solution\\\" (without quotes); else print n lines, and the i-th line contains two integers xi, yi (|xi|, |yi| ≤ 109) representing the coordinates of the i-th point.\\n\\nThe conditions below must be held:\\n\\n * All the points must be distinct. \\n * |xi|, |yi| ≤ 109. \\n * After running the given code, the value of tot should be larger than k. \\n\\nExamples\\n\\nInput\\n\\n4 3\\n\\n\\nOutput\\n\\n0 0\\n0 1\\n1 0\\n1 1\\n\\n\\nInput\\n\\n2 100\\n\\n\\nOutput\\n\\nno solution\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nlong long fp(long long n, long long p) {\\n if (p == 0) return 1;\\n if (p == 1) return n % (long long)(1000000007);\\n long long res;\\n res = fp(n, p \\/ 2) % (long long)(1000000007);\\n res = (res * res) % (long long)(1000000007);\\n if (p % 2) res = (res * n) % (long long)(1000000007);\\n return res;\\n}\\nint main() {\\n ios::sync_with_stdio(0);\\n ios_base::sync_with_stdio(0);\\n cin.tie(0), cout.tie(0);\\n ;\\n long long n, k;\\n cin >> n >> k;\\n int tot = 0;\\n for (int i = 0; i < n; i++)\\n for (int j = i + 1; j < n; j++) tot++;\\n if (tot <= k) return cout << \\\"no solution\\\" << '\\\\n', 0;\\n for (int i = 1; i <= n; i++) {\\n cout << 1 << \\\" \\\" << n - i + 1 << '\\\\n';\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A binary string is a string that consists of characters 0 and 1.\\n\\nLet \\\\operatorname{MEX} of a binary string be the smallest digit among 0, 1, or 2 that does not occur in the string. For example, \\\\operatorname{MEX} of 001011 is 2, because 0 and 1 occur in the string at least once, \\\\operatorname{MEX} of 1111 is 0, because 0 and 2 do not occur in the string and 0 < 2.\\n\\nA binary string s is given. You should cut it into any number of substrings such that each character is in exactly one substring. It is possible to cut the string into a single substring — the whole string.\\n\\nA string a is a substring of a string b if a can be obtained from b by deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end.\\n\\nWhat is the minimal sum of \\\\operatorname{MEX} of all substrings pieces can be?\\n\\nInput\\n\\nThe input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. Description of the test cases follows.\\n\\nEach test case contains a single binary string s (1 ≤ |s| ≤ 10^5).\\n\\nIt's guaranteed that the sum of lengths of s over all test cases does not exceed 10^5.\\n\\nOutput\\n\\nFor each test case print a single integer — the minimal sum of \\\\operatorname{MEX} of all substrings that it is possible to get by cutting s optimally.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n01\\n1111\\n01100\\n101\\n0000\\n01010\\n\\n\\nOutput\\n\\n\\n1\\n0\\n2\\n1\\n1\\n2\\n\\nNote\\n\\nIn the first test case the minimal sum is \\\\operatorname{MEX}(0) + \\\\operatorname{MEX}(1) = 1 + 0 = 1.\\n\\nIn the second test case the minimal sum is \\\\operatorname{MEX}(1111) = 0.\\n\\nIn the third test case the minimal sum is \\\\operatorname{MEX}(01100) = 2.\",\"targets\":\"import java.util.Arrays;\\nimport java.util.Scanner;\\n\\npublic class Main\\n{\\n\\tpublic static void main(String[] args)\\n\\t{\\n\\t\\tScanner sc=new Scanner(System.in);\\n\\t\\tint t=sc.nextInt();\\n\\t\\twhile(t-->0)\\n\\t\\t{\\n\\t\\t\\tString s=sc.next();\\n\\t\\t\\tString a[]=s.split(\\\"1+\\\");\\n\\t\\t\\tint cnt=0;\\n\\t\\t\\tfor(int i=0;i2?2:cnt);\\n\\t\\t}\\n\\t}\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nLet's write all the positive integer numbers one after another from 1 without any delimiters (i.e. as a single string). It will be the infinite sequence starting with 123456789101112131415161718192021222324252627282930313233343536...\\n\\nYour task is to print the k-th digit of this sequence.\\n\\nInput\\n\\nThe first and only line contains integer k (1 ≤ k ≤ 10^{12}) — the position to process (1-based index).\\n\\nOutput\\n\\nPrint the k-th digit of the resulting infinite sequence.\\n\\nExamples\\n\\nInput\\n\\n\\n7\\n\\n\\nOutput\\n\\n\\n7\\n\\n\\nInput\\n\\n\\n21\\n\\n\\nOutput\\n\\n\\n5\",\"targets\":\"#include \\nusing namespace std;\\nlong long n, m;\\nlong long a[30] = {0, 0, 0}, sum[30] = {0, 0, 0};\\nint main() {\\n int t;\\n long long ans = 9;\\n for (int i = 1; i <= 15; i++) {\\n a[i] = ans * i;\\n sum[i] = sum[i - 1] + a[i];\\n ans *= 10;\\n }\\n scanf(\\\"%lld\\\", &n);\\n int wei;\\n for (wei = 1; wei <= 15; wei++) {\\n if (sum[wei] >= n) break;\\n }\\n for (int i = 1; i < wei; i++) n -= a[i];\\n long long num = (n - 1) % wei + 1;\\n long long k = (n - num) \\/ wei;\\n long long nownum = 1;\\n long long c = wei - 1;\\n while (c--) nownum *= 10;\\n nownum += k;\\n for (int i = 1; i <= (wei - num); i++) nownum \\/= 10;\\n cout << nownum % 10 << endl;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in PYTHON3?\\nThis is a simplified version of the problem B2. Perhaps you should read the problem B2 before you start solving B1.\\n\\nPaul and Mary have a favorite string s which consists of lowercase letters of the Latin alphabet. They want to paint it using pieces of chalk of two colors: red and green. Let's call a coloring of a string wonderful if the following conditions are met:\\n\\n 1. each letter of the string is either painted in exactly one color (red or green) or isn't painted; \\n 2. each two letters which are painted in the same color are different; \\n 3. the number of letters painted in red is equal to the number of letters painted in green; \\n 4. the number of painted letters of this coloring is maximum among all colorings of the string which meet the first three conditions. \\n\\n\\n\\nE. g. consider a string s equal to \\\"kzaaa\\\". One of the wonderful colorings of the string is shown in the figure.\\n\\n The example of a wonderful coloring of the string \\\"kzaaa\\\".\\n\\nPaul and Mary want to learn by themselves how to find a wonderful coloring of the string. But they are very young, so they need a hint. Help them find k — the number of red (or green, these numbers are equal) letters in a wonderful coloring.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 1000) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one non-empty string s which consists of lowercase letters of the Latin alphabet. The number of characters in the string doesn't exceed 50.\\n\\nOutput\\n\\nFor each test case, output a separate line containing one non-negative integer k — the number of letters which will be painted in red in a wonderful coloring.\\n\\nExample\\n\\nInput\\n\\n\\n5\\nkzaaa\\ncodeforces\\narchive\\ny\\nxxxxxx\\n\\n\\nOutput\\n\\n\\n2\\n5\\n3\\n0\\n1\\n\\nNote\\n\\nThe first test case contains the string from the statement. One of the wonderful colorings is shown in the figure. There's no wonderful coloring containing 3 or more red letters because the total number of painted symbols will exceed the string's length.\\n\\nThe string from the second test case can be...\",\"targets\":\"test = int(input())\\nfor i in range(test):\\n word = input()\\n total = 0\\n count = 0\\n dict = {i: word.count(i) for i in word}\\n for i,j in dict.items():\\n if j >= 2:\\n total+=1\\n else:\\n count+=1\\n total+=count\\/\\/2\\n\\n print(total)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given an array a consisting of n positive integers. You have to choose a positive integer d and paint all elements into two colors. All elements which are divisible by d will be painted red, and all other elements will be painted blue.\\n\\nThe coloring is called beautiful if there are no pairs of adjacent elements with the same color in the array. Your task is to find any value of d which yields a beautiful coloring, or report that it is impossible.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of testcases.\\n\\nThe first line of each testcase contains one integer n (2 ≤ n ≤ 100) — the number of elements of the array.\\n\\nThe second line of each testcase contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^{18}).\\n\\nOutput\\n\\nFor each testcase print a single integer. If there is no such value of d that yields a beautiful coloring, print 0. Otherwise, print any suitable value of d (1 ≤ d ≤ 10^{18}).\\n\\nExample\\n\\nInput\\n\\n\\n5\\n5\\n1 2 3 4 5\\n3\\n10 5 15\\n3\\n100 10 200\\n10\\n9 8 2 6 6 2 8 6 5 4\\n2\\n1 3\\n\\n\\nOutput\\n\\n\\n2\\n0\\n100\\n0\\n3\\nUsing python3 can you solve the prior task?\",\"targets\":\"import io, os\\nimport sys \\nfrom sys import stdin\\n\\nfrom bisect import bisect_left, bisect_right\\nfrom collections import defaultdict, deque, namedtuple\\nfrom heapq import heappush, heappop\\nfrom math import gcd, ceil, floor, factorial, sqrt\\nfrom itertools import combinations, permutations\\n\\ninput = sys.stdin.buffer.readline\\n# input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\\n# input = sys.stdin.readline\\n\\ndef work():\\n ans = 0 \\n\\n return \\n\\n# sys.setrecursionlimit(200010)\\ndef main():\\n test = int(input())\\n\\n for idt in range(test):\\n n = int(input())\\n # n, m = map(int, input().split())\\n nums = list(map(int, input().split()))\\n a, b = [], []\\n for i in range(n):\\n if i % 2 == 0:\\n a.append(nums[i])\\n else:\\n b.append(nums[i])\\n\\n flag = False \\n for i in a:\\n if i in b:\\n flag = True \\n break \\n\\n max_gcd1 = a[0]\\n for i in range(1, len(a)):\\n max_gcd1 = gcd(max_gcd1, a[i])\\n\\n max_gcd2 = b[0]\\n for i in range(1, len(b)):\\n max_gcd2 = gcd(max_gcd2, b[i])\\n ans = 0 \\n if max_gcd1 == max_gcd2 or flag:\\n ans = 0 \\n else:\\n flag = True\\n for i in b:\\n if i % max_gcd1 == 0:\\n flag = False \\n break \\n if flag:\\n ans = max_gcd1 \\n \\n flag = True \\n for i in a:\\n if i % max_gcd2 == 0:\\n flag = False \\n break \\n if flag:\\n ans = max_gcd2 \\n print(ans) \\n \\n\\n\\n return \\n\\n\\nif __name__ == '__main__':\\n main()\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Everybody knows that the capital of Berland is connected to Bercouver (the Olympic capital) by a direct road. To improve the road's traffic capacity, there was placed just one traffic sign, limiting the maximum speed. Traffic signs in Berland are a bit peculiar, because they limit the speed only at that point on the road where they are placed. Right after passing the sign it is allowed to drive at any speed.\\n\\nIt is known that the car of an average Berland citizen has the acceleration (deceleration) speed of a km\\/h2, and has maximum speed of v km\\/h. The road has the length of l km, and the speed sign, limiting the speed to w km\\/h, is placed d km (1 ≤ d < l) away from the capital of Berland. The car has a zero speed at the beginning of the journey. Find the minimum time that an average Berland citizen will need to get from the capital to Bercouver, if he drives at the optimal speed.\\n\\nThe car can enter Bercouver at any speed.\\n\\nInput\\n\\nThe first line of the input file contains two integer numbers a and v (1 ≤ a, v ≤ 10000). The second line contains three integer numbers l, d and w (2 ≤ l ≤ 10000; 1 ≤ d < l; 1 ≤ w ≤ 10000).\\n\\nOutput\\n\\nPrint the answer with at least five digits after the decimal point.\\n\\nExamples\\n\\nInput\\n\\n1 1\\n2 1 3\\n\\n\\nOutput\\n\\n2.500000000000\\n\\n\\nInput\\n\\n5 70\\n200 170 40\\n\\n\\nOutput\\n\\n8.965874696353\\\":\",\"targets\":\"#include \\nusing namespace std;\\nconst int eps = 1e-8;\\nbool equal(double a, double b) {\\n a -= b;\\n if (a < 0) a = -a;\\n return a < eps;\\n}\\ndouble find_time2(double w, double x, double a, double v) {\\n double x2 = (v * v - w * w) \\/ (2 * a);\\n if (x2 <= x) {\\n double t1 = (x - x2) \\/ v;\\n return (v - w) \\/ a + t1;\\n }\\n double maxv = sqrt(2 * a * x + w * w);\\n return (maxv - w) \\/ a;\\n}\\ndouble a, v, l, d, w;\\nint main() {\\n while (~scanf(\\\"%lf %lf %lf %lf %lf\\\", &a, &v, &l, &d, &w)) {\\n double t = sqrt((2.0 * d) \\/ a);\\n double V = a * t;\\n V = min(v, V);\\n if (V <= w) {\\n printf(\\\"%.10lf\\\\n\\\", find_time2(0, l, a, v));\\n continue;\\n }\\n double x1 = v * v \\/ (2 * a);\\n double x2 = (v * v - w * w) \\/ (2 * a);\\n if (x1 + x2 <= d) {\\n double t3 = (d - x1 - x2) \\/ v;\\n printf(\\\"%.10lf\\\\n\\\", v \\/ a + (v - w) \\/ a + t3 + find_time2(w, l - d, a, v));\\n continue;\\n }\\n double v1 = sqrt(a * d + w * w \\/ 2);\\n double t1 = v1 \\/ a, t2 = (v1 - w) \\/ a;\\n printf(\\\"%.10lf\\\\n\\\", t1 + t2 + find_time2(w, l - d, a, v));\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Moamen and Ezzat are playing a game. They create an array a of n non-negative integers where every element is less than 2^k.\\n\\nMoamen wins if a_1 \\\\& a_2 \\\\& a_3 \\\\& … \\\\& a_n ≥ a_1 ⊕ a_2 ⊕ a_3 ⊕ … ⊕ a_n.\\n\\nHere \\\\& denotes the [bitwise AND operation](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#AND), and ⊕ denotes the [bitwise XOR operation](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#XOR).\\n\\nPlease calculate the number of winning for Moamen arrays a.\\n\\nAs the result may be very large, print the value modulo 1 000 000 007 (10^9 + 7).\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 5)— the number of test cases. \\n\\nEach test case consists of one line containing two integers n and k (1 ≤ n≤ 2⋅ 10^5, 0 ≤ k ≤ 2⋅ 10^5).\\n\\nOutput\\n\\nFor each test case, print a single value — the number of different arrays that Moamen wins with.\\n\\nPrint the result modulo 1 000 000 007 (10^9 + 7).\\n\\nExample\\n\\nInput\\n\\n\\n3\\n3 1\\n2 1\\n4 0\\n\\n\\nOutput\\n\\n\\n5\\n2\\n1\\n\\nNote\\n\\nIn the first example, n = 3, k = 1. As a result, all the possible arrays are [0,0,0], [0,0,1], [0,1,0], [1,0,0], [1,1,0], [0,1,1], [1,0,1], and [1,1,1].\\n\\nMoamen wins in only 5 of them: [0,0,0], [1,1,0], [0,1,1], [1,0,1], and [1,1,1].\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nvector fact((long long)3e5);\\nvector ifact((long long)3e5);\\nlong long modexp(long long x, long long y) {\\n x %= (long long)1e9 + 7;\\n if (x == 0) return 0;\\n long long res = 1;\\n while (y) {\\n if (y & 1) {\\n res = (x * res);\\n res %= (long long)1e9 + 7;\\n }\\n y \\/= 2;\\n x = (x * x);\\n x %= (long long)1e9 + 7;\\n }\\n return res;\\n}\\nlong long mod_inverse(long long n) { return modexp(n, (long long)1e9 + 7 - 2); }\\nlong long ncr(long long n, long long r) {\\n long long ans = (fact[n] * ifact[r]);\\n ans %= (long long)1e9 + 7;\\n ans = (ans * ifact[n - r]);\\n ans %= (long long)1e9 + 7;\\n return ans;\\n}\\nvoid solve() {\\n long long n, k;\\n cin >> n >> k;\\n if (k == 0) {\\n cout << 1 << endl;\\n return;\\n }\\n long long ans = 2;\\n for (long long i = 2; i < n; i += 2) {\\n ans += ncr(n, i);\\n }\\n if (n % 2) {\\n ans = modexp(ans, k);\\n ans %= (long long)1e9 + 7;\\n cout << ans << endl;\\n return;\\n }\\n long long total = modexp(ans - 1, k);\\n for (long long i = 1; i <= k; i++) {\\n long long curr = modexp(ans - 1, i - 1) * modexp(2, n * (k - i));\\n curr %= (long long)1e9 + 7;\\n total += curr;\\n total %= (long long)1e9 + 7;\\n }\\n cout << total << endl;\\n}\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n fact[0] = 1;\\n for (long long i = 1; i < (long long)3e5; i++) {\\n fact[i] = i * fact[i - 1];\\n fact[i] %= (long long)1e9 + 7;\\n ifact[i] = mod_inverse(fact[i]);\\n ifact[i] %= (long long)1e9 + 7;\\n }\\n long long t;\\n cin >> t;\\n while (t--) {\\n solve();\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nDuring the hypnosis session, Nicholas suddenly remembered a positive integer n, which doesn't contain zeros in decimal notation. \\n\\nSoon, when he returned home, he got curious: what is the maximum number of digits that can be removed from the number so that the number becomes not prime, that is, either composite or equal to one?\\n\\nFor some numbers doing so is impossible: for example, for number 53 it's impossible to delete some of its digits to obtain a not prime integer. However, for all n in the test cases of this problem, it's guaranteed that it's possible to delete some of their digits to obtain a not prime number.\\n\\nNote that you cannot remove all the digits from the number.\\n\\nA prime number is a number that has no divisors except one and itself. A composite is a number that has more than two divisors. 1 is neither a prime nor a composite number.\\n\\nInput\\n\\nEach test contains multiple test cases.\\n\\nThe first line contains one positive integer t (1 ≤ t ≤ 10^3), denoting the number of test cases. Description of the test cases follows.\\n\\nThe first line of each test case contains one positive integer k (1 ≤ k ≤ 50) — the number of digits in the number.\\n\\nThe second line of each test case contains a positive integer n, which doesn't contain zeros in decimal notation (10^{k-1} ≤ n < 10^{k}). It is guaranteed that it is always possible to remove less than k digits to make the number not prime.\\n\\nIt is guaranteed that the sum of k over all test cases does not exceed 10^4.\\n\\nOutput\\n\\nFor every test case, print two numbers in two lines. In the first line print the number of digits, that you have left in the number. In the second line print the digits left after all delitions. \\n\\nIf there are multiple solutions, print any.\\n\\nExample\\n\\nInput\\n\\n\\n7\\n3\\n237\\n5\\n44444\\n3\\n221\\n2\\n35\\n3\\n773\\n1\\n4\\n30\\n626221626221626221626221626221\\n\\n\\nOutput\\n\\n\\n2\\n27\\n1\\n4\\n1\\n1\\n2\\n35\\n2\\n77\\n1\\n4\\n1\\n6\\n\\nNote\\n\\nIn the first test case, you can't delete 2 digits from the number 237, as all the numbers 2, 3, and 7 are prime. However, you can delete 1 digit, obtaining a number 27 =...\",\"targets\":\"#include \\nusing namespace std;\\nint n, a[55];\\nchar s[100];\\nint p[100];\\nint main() {\\n int T;\\n scanf(\\\"%d\\\", &T);\\n while (T--) {\\n scanf(\\\"%d\\\", &n);\\n int fg = 0;\\n scanf(\\\"%s\\\", s + 1);\\n for (int i = 1; i <= n; i++) {\\n a[i] = s[i] - '0';\\n if (a[i] != 2 && a[i] != 3 && a[i] != 5 && a[i] != 7) {\\n fg = 1;\\n printf(\\\"1\\\\n%d\\\\n\\\", a[i]);\\n break;\\n }\\n }\\n if (fg == 1) {\\n continue;\\n }\\n puts(\\\"2\\\");\\n for (int i = 1; i <= n; i++) {\\n for (int j = i + 1; j <= n; j++) {\\n int x = a[i] * 10 + a[j];\\n if (x != 23 && x != 37 && x != 53 && x != 73) {\\n fg = x;\\n break;\\n }\\n }\\n if (fg) break;\\n }\\n printf(\\\"%d\\\\n\\\", fg);\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Paprika loves permutations. She has an array a_1, a_2, ..., a_n. She wants to make the array a permutation of integers 1 to n.\\n\\nIn order to achieve this goal, she can perform operations on the array. In each operation she can choose two integers i (1 ≤ i ≤ n) and x (x > 0), then perform a_i := a_i mod x (that is, replace a_i by the remainder of a_i divided by x). In different operations, the chosen i and x can be different.\\n\\nDetermine the minimum number of operations needed to make the array a permutation of integers 1 to n. If it is impossible, output -1.\\n\\nA permutation is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice in the array) and [1,3,4] is also not a permutation (n=3 but there is 4 in the array).\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. Description of the test cases follows.\\n\\nThe first line of each test case contains an integer n (1 ≤ n ≤ 10^5).\\n\\nThe second line of each test case contains n integers a_1, a_2, ..., a_n. (1 ≤ a_i ≤ 10^9).\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, output the minimum number of operations needed to make the array a permutation of integers 1 to n, or -1 if it is impossible.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n2\\n1 7\\n3\\n1 5 4\\n4\\n12345678 87654321 20211218 23571113\\n9\\n1 2 3 4 18 19 5 6 7\\n\\n\\nOutput\\n\\n\\n1\\n-1\\n4\\n2\\n\\nNote\\n\\nFor the first test, the only possible sequence of operations which minimizes the number of operations is: \\n\\n * Choose i=2, x=5. Perform a_2 := a_2 mod 5 = 2. \\n\\n\\n\\nFor the second test, it is impossible to obtain a permutation of integers from 1 to n.\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n long long int test_case, n;\\n cin >> test_case;\\n while (test_case--) {\\n cin >> n;\\n long long int ar[n], i, c = 0, b, j = 0;\\n vector w;\\n vector> v;\\n map m, p;\\n for (i = 0; i < n; i++) {\\n cin >> ar[i];\\n m[ar[i]]++;\\n }\\n sort(ar, ar + n);\\n for (i = 1; i <= n; i++) {\\n p[i] = 1;\\n if (m[i] == 0) {\\n w.push_back(i);\\n }\\n }\\n for (i = 0; i < n; i++) {\\n if (p[ar[i]] == 0) {\\n v.push_back({ar[i], w[j]});\\n j++;\\n } else {\\n p[ar[i]] = 0;\\n }\\n }\\n for (i = 0; i < v.size(); i++) {\\n b = v[i].first - v[i].second;\\n if (b <= v[i].second) {\\n c = 1;\\n break;\\n }\\n }\\n if (c) {\\n cout << \\\"-1\\\" << endl;\\n } else {\\n cout << v.size() << endl;\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"An elephant decided to visit his friend. It turned out that the elephant's house is located at point 0 and his friend's house is located at point x(x > 0) of the coordinate line. In one step the elephant can move 1, 2, 3, 4 or 5 positions forward. Determine, what is the minimum number of steps he need to make in order to get to his friend's house.\\n\\nInput\\n\\nThe first line of the input contains an integer x (1 ≤ x ≤ 1 000 000) — The coordinate of the friend's house.\\n\\nOutput\\n\\nPrint the minimum number of steps that elephant needs to make to get from point 0 to point x.\\n\\nExamples\\n\\nInput\\n\\n5\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\n12\\n\\n\\nOutput\\n\\n3\\n\\nNote\\n\\nIn the first sample the elephant needs to make one step of length 5 to reach the point x.\\n\\nIn the second sample the elephant can get to point x if he moves by 3, 5 and 4. There are other ways to get the optimal answer but the elephant cannot reach x in less than three moves.\",\"targets\":\"x = int(input())\\nif x<=5:\\n print(1)\\n \\nif x>5 and x%5 == 0:\\n print(x\\/\\/5)\\n \\nif x>5 and x%5 != 0:\\n g = x\\/\\/5\\n print(g+1)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Bessie and the cows are playing with sequences and need your help. They start with a sequence, initially containing just the number 0, and perform n operations. Each operation is one of the following:\\n\\n 1. Add the integer xi to the first ai elements of the sequence. \\n 2. Append an integer ki to the end of the sequence. (And hence the size of the sequence increases by 1) \\n 3. Remove the last element of the sequence. So, the size of the sequence decreases by one. Note, that this operation can only be done if there are at least two elements in the sequence. \\n\\n\\n\\nAfter each operation, the cows would like to know the average of all the numbers in the sequence. Help them!\\n\\nInput\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 2·105) — the number of operations. The next n lines describe the operations. Each line will start with an integer ti (1 ≤ ti ≤ 3), denoting the type of the operation (see above). If ti = 1, it will be followed by two integers ai, xi (|xi| ≤ 103; 1 ≤ ai). If ti = 2, it will be followed by a single integer ki (|ki| ≤ 103). If ti = 3, it will not be followed by anything.\\n\\nIt is guaranteed that all operations are correct (don't touch nonexistent elements) and that there will always be at least one element in the sequence.\\n\\nOutput\\n\\nOutput n lines each containing the average of the numbers in the sequence after the corresponding operation.\\n\\nThe answer will be considered correct if its absolute or relative error doesn't exceed 10 - 6.\\n\\nExamples\\n\\nInput\\n\\n5\\n2 1\\n3\\n2 3\\n2 1\\n3\\n\\n\\nOutput\\n\\n0.500000\\n0.000000\\n1.500000\\n1.333333\\n1.500000\\n\\n\\nInput\\n\\n6\\n2 1\\n1 2 20\\n2 2\\n1 2 -3\\n3\\n3\\n\\n\\nOutput\\n\\n0.500000\\n20.500000\\n14.333333\\n12.333333\\n17.500000\\n17.000000\\n\\nNote\\n\\nIn the second sample, the sequence becomes \\n\\/*\\n *\",\"targets\":\"To change this template, choose Tools | Templates\\n * and open the template in the editor.\\n *\\/\\n\\nimport java.io.*;\\nimport java.math.BigInteger;\\nimport java.util.*;\\nimport java.text.*;\\n\\npublic class cf284c {\\n\\n static BufferedReader br;\\n static Scanner sc;\\n static PrintWriter out;\\n\\n public static void initA() {\\n try {\\n br = new BufferedReader(new InputStreamReader(System.in));\\n \\/\\/br = new BufferedReader(new FileReader(\\\"input.txt\\\"));\\n sc = new Scanner(System.in);\\n \\/\\/out = new PrintWriter(\\\"output.txt\\\");\\n out = new PrintWriter(System.out);\\n } catch (Exception e) {\\n }\\n }\\n\\n public static void initB() {\\n try {\\n\\n br = new BufferedReader(new FileReader(\\\"input.txt\\\"));\\n sc = new Scanner(new FileReader(\\\"input.txt\\\"));\\n out = new PrintWriter(\\\"output.txt\\\");\\n\\n } catch (Exception e) {\\n }\\n }\\n\\n public static String getString() {\\n try {\\n return br.readLine();\\n } catch (Exception e) {\\n }\\n return \\\"\\\";\\n }\\n\\n public static Integer getInt() {\\n try {\\n return Integer.parseInt(br.readLine());\\n } catch (Exception e) {\\n }\\n return 0;\\n }\\n\\n public static Integer[] getIntArr() {\\n try {\\n StringTokenizer temp = new StringTokenizer(br.readLine());\\n int n = temp.countTokens();\\n Integer temp2[] = new Integer[n];\\n for (int i = 0; i < n; i++) {\\n temp2[i] = Integer.parseInt(temp.nextToken());\\n }\\n return temp2;\\n } catch (Exception e) {\\n }\\n return null;\\n }\\n\\n public static Long[] getLongArr() {\\n try {\\n StringTokenizer temp = new StringTokenizer(br.readLine());\\n int n = temp.countTokens();\\n Long temp2[] = new Long[n];\\n for (int i = 0; i < n; i++) {\\n temp2[i] = Long.parseLong(temp.nextToken());\\n }\\n return temp2;\\n ...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Kuzya started going to school. He was given math homework in which he was given an array a of length n and an array of symbols b of length n, consisting of symbols '*' and '\\/'.\\n\\nLet's denote a path of calculations for a segment [l; r] (1 ≤ l ≤ r ≤ n) in the following way: \\n\\n * Let x=1 initially. For every i from l to r we will consequently do the following: if b_i= '*', x=x*a_i, and if b_i= '\\/', then x=(x)\\/(a_i). Let's call a path of calculations for the segment [l; r] a list of all x that we got during the calculations (the number of them is exactly r - l + 1). \\n\\n\\n\\nFor example, let a=[7, 12, 3, 5, 4, 10, 9], b=[\\/, *, \\/, \\/, \\/, *, *], l=2, r=6, then the path of calculations for that segment is [12, 4, 0.8, 0.2, 2].\\n\\nLet's call a segment [l;r] simple if the path of calculations for it contains only integer numbers. \\n\\nKuzya needs to find the number of simple segments [l;r] (1 ≤ l ≤ r ≤ n). Since he obviously has no time and no interest to do the calculations for each option, he asked you to write a program to get to find that number!\\n\\nInput\\n\\nThe first line contains a single integer n (2 ≤ n ≤ 10^6).\\n\\nThe second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^6).\\n\\nThe third line contains n symbols without spaces between them — the array b_1, b_2 … b_n (b_i= '\\/' or b_i= '*' for every 1 ≤ i ≤ n).\\n\\nOutput\\n\\nPrint a single integer — the number of simple segments [l;r].\\n\\nExamples\\n\\nInput\\n\\n\\n3\\n1 2 3\\n*\\/*\\n\\n\\nOutput\\n\\n\\n2\\n\\n\\nInput\\n\\n\\n7\\n6 4 10 1 2 15 1\\n*\\/*\\/*\\/\\/\\n\\n\\nOutput\\n\\n\\n8\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint a[1000000 + 5];\\nchar b[1000000 + 5];\\nint las[1000000 + 5];\\nvoid get_prime() {\\n int n = 1000000;\\n for (int i = 2; i <= n; i++)\\n if (!las[i]) {\\n las[i] = i;\\n if (i > 1000) continue;\\n for (int j = i * i; j <= n; j += i) las[j] = i;\\n }\\n}\\nint pre[1000000 + 5];\\nvector p[1000000 + 5];\\nvoid add(int x, int id) {\\n pre[id] = id;\\n while (x != 1) p[las[x]].push_back(id), x \\/= las[x];\\n}\\nvoid del(int x, int id) {\\n pre[id] = id;\\n while (x != 1) {\\n if (!p[las[x]].size()) {\\n pre[id] = 0;\\n return;\\n }\\n pre[id] = min(pre[id], p[las[x]].back());\\n p[las[x]].pop_back();\\n x \\/= las[x];\\n }\\n}\\nvector > Q;\\nint main() {\\n int n, i, j;\\n scanf(\\\"%d\\\", &n);\\n for (i = 1; i <= n; i++) scanf(\\\"%d\\\", &a[i]);\\n scanf(\\\"%s\\\", b + 1);\\n get_prime();\\n for (i = 1; i <= n; i++)\\n if (b[i] == '*')\\n add(a[i], i);\\n else\\n del(a[i], i);\\n long long ans = 0;\\n for (i = n; i >= 1; i--) {\\n int cnt = 1;\\n while (!Q.empty() && Q.back().first >= pre[i])\\n cnt += Q.back().second, Q.pop_back();\\n Q.push_back(make_pair(pre[i], cnt));\\n if (pre[i] == i) ans += cnt;\\n }\\n printf(\\\"%lld\\\\n\\\", ans);\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Polycarp has a string s. Polycarp performs the following actions until the string s is empty (t is initially an empty string):\\n\\n * he adds to the right to the string t the string s, i.e. he does t = t + s, where t + s is a concatenation of the strings t and s; \\n * he selects an arbitrary letter of s and removes from s all its occurrences (the selected letter must occur in the string s at the moment of performing this action). \\n\\n\\n\\nPolycarp performs this sequence of actions strictly in this order.\\n\\nNote that after Polycarp finishes the actions, the string s will be empty and the string t will be equal to some value (that is undefined and depends on the order of removing).\\n\\nE.g. consider s=\\\"abacaba\\\" so the actions may be performed as follows:\\n\\n * t=\\\"abacaba\\\", the letter 'b' is selected, then s=\\\"aacaa\\\"; \\n * t=\\\"abacabaaacaa\\\", the letter 'a' is selected, then s=\\\"c\\\"; \\n * t=\\\"abacabaaacaac\\\", the letter 'c' is selected, then s=\\\"\\\" (the empty string). \\n\\n\\n\\nYou need to restore the initial value of the string s using only the final value of t and find the order of removing letters from s.\\n\\nInput\\n\\nThe first line contains one integer T (1 ≤ T ≤ 10^4) — the number of test cases. Then T test cases follow.\\n\\nEach test case contains one string t consisting of lowercase letters of the Latin alphabet. The length of t doesn't exceed 5 ⋅ 10^5. The sum of lengths of all strings t in the test cases doesn't exceed 5 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case output in a separate line:\\n\\n * -1, if the answer doesn't exist; \\n * two strings separated by spaces. The first one must contain a possible initial value of s. The second one must contain a sequence of letters — it's in what order one needs to remove letters from s to make the string t. E.g. if the string \\\"bac\\\" is outputted, then, first, all occurrences of the letter 'b' were deleted, then all occurrences of 'a', and then, finally, all occurrences of 'c'. If there are multiple solutions, print any one....\\n\\/*\\n *\",\"targets\":\"Java Coding Template for Competitive Programming\\n * Author: Kartik Gola\\n * Utilities Source: https:\\/\\/github.com\\/kartikgola\\/well-known-problems\\n * Copyright (c) 2021 | https:\\/\\/kartikgola.com\\n *\\/\\n\\nimport java.io.*;\\nimport java.util.*;\\nimport java.lang.*;\\n\\npublic class E {\\n\\n private static Pair f(String t) {\\n StringBuilder sb = new StringBuilder(t);\\n int[] ord = new int[26];\\n int[] freq = new int[26];\\n\\n StringBuilder rord = new StringBuilder();\\n int pos = -1;\\n Arrays.fill(ord, pos);\\n sb.reverse();\\n\\n for (int i = 0; i < sb.length(); ++i) {\\n if (ord[sb.charAt(i)-'a'] == -1) {\\n ord[sb.charAt(i)-'a'] = ++pos;\\n rord.append(sb.charAt(i));\\n }\\n freq[sb.charAt(i)-'a']++;\\n }\\n\\n int len = 0;\\n for (int i = 0; i < freq.length; ++i) {\\n if (freq[i] > 0) {\\n \\/\\/ freq[i] must be divisible by (pos+1-ord[i])\\n if (freq[i] % (pos+1-ord[i]) != 0) {\\n return null;\\n } else {\\n len += freq[i] \\/ (pos+1-ord[i]);\\n }\\n }\\n }\\n\\n String s = t.substring(0, len);\\n String rem = rord.reverse().toString();\\n return new Pair<>(s, rem);\\n }\\n\\n public static void main(String[] args) throws Exception {\\n setIO(); \\/\\/ Comment setIO(); if using AtCoder\\n int t = nextInt();\\n while (t-- > 0) {\\n String inp = nextString();\\n Pair pa = f(inp);\\n if (pa == null) {\\n System.out.println(-1);\\n continue;\\n }\\n \\n String sc = pa.key;\\n String rc = pa.value;\\n String tc = sc;\\n\\n for (int i = 0; i < rc.length(); ++i) {\\n sc = sc.replaceAll(Character.toString(rc.charAt(i)), \\\"\\\");\\n tc += sc;\\n }\\n\\n if (tc.equals(inp)) {\\n System.out.println(pa.key + \\\" \\\" +...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"After his wife's tragic death, Eurydice, Orpheus descended to the realm of death to see her. Reaching its gates was uneasy, but passing through them proved to be even more challenging. Mostly because of Cerberus, the three-headed hound of Hades. \\n\\nOrpheus, a famous poet, and musician plans to calm Cerberus with his poetry and safely walk past him. He created a very peculiar poem for Cerberus. It consists only of lowercase English letters. \\n\\nWe call a poem's substring a palindrome if and only if it reads the same backwards and forwards. A string a is a substring of a string b if a can be obtained from b by deleting several (possibly zero or all) characters from the beginning and several (possibly zero or all) characters from the end.\\n\\nUnfortunately, Cerberus dislikes palindromes of length greater than 1. For example in the poem abaa the hound of Hades wouldn't like substrings aba and aa.\\n\\nOrpheus can only calm Cerberus if the hound likes his poetry. That's why he wants to change his poem so that it does not contain any palindrome substrings of length greater than 1.\\n\\nOrpheus can modify the poem by replacing a letter at any position with any lowercase English letter. He can use this operation arbitrarily many times (possibly zero). Since there can be many palindromes in his poem, he may have to make some corrections. But how many, exactly? Given the poem, determine the minimal number of letters that have to be changed so that the poem does not contain any palindromes of length greater than 1.\\n\\nInput\\n\\nThe first line of the input contains a single integer t (1 ≤ t ≤ 10^5) denoting the number of test cases, then t test cases follow.\\n\\nThe first and only line of each test case contains a non-empty string of lowercase English letters, Orpheus' poem.\\n\\nThe sum of the length of Orpheus' poems in all test cases will not exceed 10^5.\\n\\nOutput\\n\\nYou should output t lines, i-th line should contain a single integer, answer to the i-th test...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"\\/\\/ STUPID.. AS ALWAYS\\n#include\\nusing namespace std;\\n#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);\\n#define ll long long \\n#define pll pair\\n#define vll vector\\n#define vs vector\\n#define ff first\\n#define ss second\\n#define all(x) x.begin(),x.end()\\n#define pb push_back\\n#define ppb pop_back\\n# define ln cout << \\\"\\\\n\\\" ;\\n#define maxHeap priority_queue\\n#define minHeap priority_queue , greater > \\n#define MOD 1000000009\\n#define MAX 2000000000000000000\\n#define MAXN 1000006\\n\\nvoid solve(){\\n ll n,i,j;\\n \\/\\/ cin >> n;\\n string s; cin >> s;\\n n = s.size();\\n ll ans =0;\\n for(i=1;i> t; for(ll i=1;i<=t;i++)\\n\\t \\/\\/cout << \\\"Case #\\\" << i << \\\": \\\",\\n\\t solve();\\n\\treturn 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Shohag has an integer sequence a_1, a_2, …, a_n. He can perform the following operation any number of times (possibly, zero):\\n\\n * Select any positive integer k (it can be different in different operations). \\n * Choose any position in the sequence (possibly the beginning or end of the sequence, or in between any two elements) and insert k into the sequence at this position. \\n * This way, the sequence a changes, and the next operation is performed on this changed sequence. \\n\\n\\n\\nFor example, if a=[3,3,4] and he selects k = 2, then after the operation he can obtain one of the sequences [\\\\underline{2},3,3,4], [3,\\\\underline{2},3,4], [3,3,\\\\underline{2},4], or [3,3,4,\\\\underline{2}].\\n\\nShohag wants this sequence to satisfy the following condition: for each 1 ≤ i ≤ |a|, a_i ≤ i. Here, |a| denotes the size of a.\\n\\nHelp him to find the minimum number of operations that he has to perform to achieve this goal. We can show that under the constraints of the problem it's always possible to achieve this goal in a finite number of operations.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 200) — the number of test cases.\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 100) — the initial length of the sequence.\\n\\nThe second line of each test case contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^9) — the elements of the sequence.\\n\\nOutput\\n\\nFor each test case, print a single integer — the minimum number of operations needed to perform to achieve the goal mentioned in the statement.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n1 3 4\\n5\\n1 2 5 7 4\\n1\\n1\\n3\\n69 6969 696969\\n\\n\\nOutput\\n\\n\\n1\\n3\\n0\\n696966\\n\\nNote\\n\\nIn the first test case, we have to perform at least one operation, as a_2=3>2. We can perform the operation [1, 3, 4] → [1, \\\\underline{2}, 3, 4] (the newly inserted element is underlined), now the condition is satisfied.\\n\\nIn the second test case, Shohag can perform the following operations:\\n\\n[1, 2, 5, 7, 4] → [1, 2, \\\\underline{3}, 5, 7, 4] → [1, 2, 3, \\\\underline{4}, 5, 7, 4] → [1, 2, 3, 4, 5, \\\\underline{3}, 7, 4].\\n\\nIn the third...\\nSolve the task in PYTHON3.\",\"targets\":\"import bisect\\nimport heapq\\nimport math\\nimport collections\\nimport sys\\nimport copy\\nfrom functools import reduce\\nimport decimal\\nfrom io import BytesIO, IOBase\\nimport os\\nimport itertools\\nimport functools\\nfrom types import GeneratorType\\n\\n#\\n# sys.setrecursionlimit(10 ** 9)\\ndecimal.getcontext().rounding = decimal.ROUND_HALF_UP\\n\\ngraphDict = collections.defaultdict\\n\\nqueue = collections.deque\\n\\n\\n################## pypy deep recursion handling ##############\\n# Author = @pajenegod\\ndef bootstrap(f, stack=[]):\\n def wrappedfunc(*args, **kwargs):\\n to = f(*args, **kwargs)\\n if stack:\\n return to\\n else:\\n while True:\\n if type(to) is GeneratorType:\\n stack.append(to)\\n to = next(to)\\n else:\\n stack.pop()\\n if not stack:\\n return to\\n to = stack[-1].send(to)\\n\\n return wrappedfunc\\n\\n\\n################## Graphs ###################\\nclass Graphs:\\n def __init__(self):\\n self.graph = graphDict(set)\\n\\n def add_edge(self, u, v):\\n self.graph[u].add(v)\\n self.graph[v].add(u)\\n\\n def dfs_utility(self, nodes, visited_nodes, colors, parity, level):\\n global count\\n if nodes == 1:\\n colors[nodes] = -1\\n else:\\n if len(self.graph[nodes]) == 1 and parity % 2 == 0:\\n if q == 1:\\n colors[nodes] = 1\\n else:\\n colors[nodes] = -1\\n count += 1\\n else:\\n if parity % 2 == 0:\\n colors[nodes] = -1\\n else:\\n colors[nodes] = 1\\n visited_nodes.add(nodes)\\n for neighbour in self.graph[nodes]:\\n new_level = level + 1\\n if neighbour not in visited_nodes:\\n self.dfs_utility(neighbour, visited_nodes, colors, level - 1, new_level)\\n\\n def dfs(self, node):\\n Visited = set()\\n color = collections.defaultdict()\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"This is the easy version of the problem. The only difference between the two versions is the constraint on n. You can make hacks only if all versions of the problem are solved.\\n\\nA forest is an undirected graph without cycles (not necessarily connected).\\n\\nMocha and Diana are friends in Zhijiang, both of them have a forest with nodes numbered from 1 to n, and they would like to add edges to their forests such that: \\n\\n * After adding edges, both of their graphs are still forests. \\n * They add the same edges. That is, if an edge (u, v) is added to Mocha's forest, then an edge (u, v) is added to Diana's forest, and vice versa. \\n\\n\\n\\nMocha and Diana want to know the maximum number of edges they can add, and which edges to add.\\n\\nInput\\n\\nThe first line contains three integers n, m_1 and m_2 (1 ≤ n ≤ 1000, 0 ≤ m_1, m_2 < n) — the number of nodes and the number of initial edges in Mocha's forest and Diana's forest.\\n\\nEach of the next m_1 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the edges in Mocha's forest.\\n\\nEach of the next m_2 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the edges in Diana's forest.\\n\\nOutput\\n\\nThe first line contains only one integer h, the maximum number of edges Mocha and Diana can add (in each forest).\\n\\nEach of the next h lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the edge you add each time.\\n\\nIf there are multiple correct answers, you can print any one of them.\\n\\nExamples\\n\\nInput\\n\\n\\n3 2 2\\n1 2\\n2 3\\n1 2\\n1 3\\n\\n\\nOutput\\n\\n\\n0\\n\\n\\nInput\\n\\n\\n5 3 2\\n5 4\\n2 1\\n4 3\\n4 3\\n1 4\\n\\n\\nOutput\\n\\n\\n1\\n2 4\\n\\n\\nInput\\n\\n\\n8 1 2\\n1 7\\n2 6\\n1 5\\n\\n\\nOutput\\n\\n\\n5\\n5 2\\n2 3\\n3 4\\n4 7\\n6 8\\n\\nNote\\n\\nIn the first example, we cannot add any edge.\\n\\nIn the second example, the initial forests are as follows.\\n\\n\\n\\nWe can add an edge (2, 4).\\n\\n\\nSolve the task in JAVA.\",\"targets\":\"import javax.swing.*;\\nimport java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.io.PrintWriter;\\nimport java.util.*;\\n\\npublic class A {\\n static List [] adj;\\n static ArrayList temp;\\n static int mod = (int) 1e9+7;\\n static boolean[] vis = new boolean[(int)1e5];\\n static List l = new ArrayList<>();\\n static int[] parent1;\\n static int[] rank1;\\n static int[] parent2;\\n static int[] rank2;\\n static void makeset(int v) {\\n parent1[v] = v;\\n parent2[v] = v;\\n }\\n\\n static int find_set1(int v){\\n if(v == parent1[v])\\n return v;\\n return parent1[v] = find_set1(parent1[v]);\\n }\\n\\n static int find_set2(int v){\\n if(v == parent2[v])\\n return v;\\n return parent2[v] = find_set2(parent2[v]);\\n }\\n\\n static void union_set1(int a,int b){\\n a = find_set1(a);\\n b = find_set1(b);\\n if(a!=b){\\n if(rank1[a]==rank1[b])rank1[a]++;\\n if(rank1[a]>rank1[b]){\\n parent1[b] = a;\\n }\\n else{\\n parent1[a] = b;\\n }\\n }\\n }\\n static void union_set2(int a,int b){\\n a = find_set2(a);\\n b = find_set2(b);\\n if(a!=b){\\n if(rank2[a]==rank2[b])rank2[a]++;\\n if(rank2[a]>rank2[b]){\\n parent2[b] = a;\\n }\\n else{\\n parent2[a] = b;\\n }\\n }\\n }\\n\\n\\n\\n\\n public static void main(String[] args) throws IOException {\\n FastScanner s=new FastScanner();\\n\\/\\/ int t = s.nextInt();\\n int t = 1;\\n while(t-->0) {\\n int n = s.nextInt();\\n int m1 = s.nextInt();\\n int m2 = s.nextInt();\\n parent1 = new int[n+1];\\n rank1 = new int[n+1];\\n parent2 = new int[n+1];\\n rank2 = new int[n+1];\\n for(int i=1;i<=n;i++){\\n makeset(i);;\\n }\\n for(int i = 1; i <= m1+m2; i++){\\n...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given a digital clock with n digits. Each digit shows an integer from 0 to 9, so the whole clock shows an integer from 0 to 10^n-1. The clock will show leading zeroes if the number is smaller than 10^{n-1}.\\n\\nYou want the clock to show 0 with as few operations as possible. In an operation, you can do one of the following: \\n\\n * decrease the number on the clock by 1, or \\n * swap two digits (you can choose which digits to swap, and they don't have to be adjacent). \\n\\n\\n\\nYour task is to determine the minimum number of operations needed to make the clock show 0.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^3).\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 100) — number of digits on the clock.\\n\\nThe second line of each test case contains a string of n digits s_1, s_2, …, s_n (0 ≤ s_1, s_2, …, s_n ≤ 9) — the number on the clock.\\n\\nNote: If the number is smaller than 10^{n-1} the clock will show leading zeroes.\\n\\nOutput\\n\\nFor each test case, print one integer: the minimum number of operations needed to make the clock show 0.\\n\\nExample\\n\\nInput\\n\\n\\n7\\n3\\n007\\n4\\n1000\\n5\\n00000\\n3\\n103\\n4\\n2020\\n9\\n123456789\\n30\\n001678294039710047203946100020\\n\\n\\nOutput\\n\\n\\n7\\n2\\n0\\n5\\n6\\n53\\n115\\n\\nNote\\n\\nIn the first example, it's optimal to just decrease the number 7 times.\\n\\nIn the second example, we can first swap the first and last position and then decrease the number by 1.\\n\\nIn the third example, the clock already shows 0, so we don't have to perform any operations.\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 1e5 + 10, INF = 0x3f3f3f3f, MOD = 998244353;\\nlong long t, n, m, k, q, tmp;\\nsigned main() {\\n ios::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n cin >> t;\\n while (t--) {\\n cin >> n;\\n string s;\\n cin >> s;\\n int ans = 0;\\n ans += s[n - 1] - '0';\\n for (int i = n - 2; i >= 0; i--) {\\n if (s[i] - '0' > 0) ans += s[i] - '0' + 1;\\n }\\n cout << ans << \\\"\\\\n\\\";\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"This is the easy version of the problem. The only difference between the two versions is the constraint on n. You can make hacks only if all versions of the problem are solved.\\n\\nA forest is an undirected graph without cycles (not necessarily connected).\\n\\nMocha and Diana are friends in Zhijiang, both of them have a forest with nodes numbered from 1 to n, and they would like to add edges to their forests such that: \\n\\n * After adding edges, both of their graphs are still forests. \\n * They add the same edges. That is, if an edge (u, v) is added to Mocha's forest, then an edge (u, v) is added to Diana's forest, and vice versa. \\n\\n\\n\\nMocha and Diana want to know the maximum number of edges they can add, and which edges to add.\\n\\nInput\\n\\nThe first line contains three integers n, m_1 and m_2 (1 ≤ n ≤ 1000, 0 ≤ m_1, m_2 < n) — the number of nodes and the number of initial edges in Mocha's forest and Diana's forest.\\n\\nEach of the next m_1 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the edges in Mocha's forest.\\n\\nEach of the next m_2 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the edges in Diana's forest.\\n\\nOutput\\n\\nThe first line contains only one integer h, the maximum number of edges Mocha and Diana can add (in each forest).\\n\\nEach of the next h lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the edge you add each time.\\n\\nIf there are multiple correct answers, you can print any one of them.\\n\\nExamples\\n\\nInput\\n\\n\\n3 2 2\\n1 2\\n2 3\\n1 2\\n1 3\\n\\n\\nOutput\\n\\n\\n0\\n\\n\\nInput\\n\\n\\n5 3 2\\n5 4\\n2 1\\n4 3\\n4 3\\n1 4\\n\\n\\nOutput\\n\\n\\n1\\n2 4\\n\\n\\nInput\\n\\n\\n8 1 2\\n1 7\\n2 6\\n1 5\\n\\n\\nOutput\\n\\n\\n5\\n5 2\\n2 3\\n3 4\\n4 7\\n6 8\\n\\nNote\\n\\nIn the first example, we cannot add any edge.\\n\\nIn the second example, the initial forests are as follows.\\n\\n\\n\\nWe can add an edge (2, 4).\\n\\n\\nSolve the task in PYTHON3.\",\"targets\":\"import os\\nimport sys\\nfrom io import BytesIO, IOBase\\n \\nBUFSIZE = 8192\\n \\n \\nclass FastIO(IOBase):\\n newlines = 0\\n \\n def __init__(self, file):\\n self._fd = file.fileno()\\n self.buffer = BytesIO()\\n self.writable = \\\"x\\\" in file.mode or \\\"r\\\" not in file.mode\\n self.write = self.buffer.write if self.writable else None\\n \\n def read(self):\\n while True:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n if not b:\\n break\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines = 0\\n return self.buffer.read()\\n \\n def readline(self):\\n while self.newlines == 0:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n self.newlines = b.count(b\\\"\\\\n\\\") + (not b)\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines -= 1\\n return self.buffer.readline()\\n \\n def flush(self):\\n if self.writable:\\n os.write(self._fd, self.buffer.getvalue())\\n self.buffer.truncate(0), self.buffer.seek(0)\\n \\n \\nclass IOWrapper(IOBase):\\n def __init__(self, file):\\n self.buffer = FastIO(file)\\n self.flush = self.buffer.flush\\n self.writable = self.buffer.writable\\n self.write = lambda s: self.buffer.write(s.encode(\\\"ascii\\\"))\\n self.read = lambda: self.buffer.read().decode(\\\"ascii\\\")\\n self.readline = lambda: self.buffer.readline().decode(\\\"ascii\\\")\\n \\nclass RangeQuery:\\n def __init__(self, data, func=min):\\n self.func = func\\n self._data = _data = [list(data)]\\n i, n = 1, len(_data[0])\\n while 2 * i <= n:\\n prev = _data[-1]\\n _data.append([func(prev[j], prev[j + i]) for j in range(n - 2 * i + 1)])\\n i <<= 1\\n \\n def query(self, start, stop):\\n \\\"\\\"\\\"func of data[start, stop)\\\"\\\"\\\"\\n depth =...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nIt's the turn of the year, so Bash wants to send presents to his friends. There are n cities in the Himalayan region and they are connected by m bidirectional roads. Bash is living in city s. Bash has exactly one friend in each of the other cities. Since Bash wants to surprise his friends, he decides to send a Pikachu to each of them. Since there may be some cities which are not reachable from Bash's city, he only sends a Pikachu to those friends who live in a city reachable from his own city. He also wants to send it to them as soon as possible.\\n\\nHe finds out the minimum time for each of his Pikachus to reach its destination city. Since he is a perfectionist, he informs all his friends with the time their gift will reach them. A Pikachu travels at a speed of 1 meters per second. His friends were excited to hear this and would be unhappy if their presents got delayed. Unfortunately Team Rocket is on the loose and they came to know of Bash's plan. They want to maximize the number of friends who are unhappy with Bash.\\n\\nThey do this by destroying exactly one of the other n - 1 cities. This implies that the friend residing in that city dies, so he is unhappy as well.\\n\\nNote that if a city is destroyed, all the roads directly connected to the city are also destroyed and the Pikachu may be forced to take a longer alternate route.\\n\\nPlease also note that only friends that are waiting for a gift count as unhappy, even if they die.\\n\\nSince Bash is already a legend, can you help Team Rocket this time and find out the maximum number of Bash's friends who can be made unhappy by destroying exactly one city.\\n\\nInput\\n\\nThe first line contains three space separated integers n, m and s (2 ≤ n ≤ 2·105, , 1 ≤ s ≤ n) — the number of cities and the number of roads in the Himalayan region and the city Bash lives in.\\n\\nEach of the next m lines contain three space-separated integers u, v and w (1 ≤ u, v ≤ n, u ≠ v, 1 ≤ w ≤ 109) denoting that there exists a road between city u and city v of length w meters.\\n\\nIt is guaranteed that no...\",\"targets\":\"#include \\nusing namespace std;\\nvector succ[200005], prod[200005], bucket[200005], dom_t[200005];\\nint semi[200005], anc[200005], idom[200005], best[200005], fa[200005],\\n val[200005];\\nint dfn[200005], redfn[200005];\\nint timestamp, root, n, m;\\nvoid dfs(int now) {\\n dfn[now] = ++timestamp;\\n redfn[timestamp] = now;\\n anc[timestamp] = idom[timestamp] = 0;\\n semi[timestamp] = best[timestamp] = timestamp;\\n int sz = succ[now].size();\\n for (int i = 0; i < sz; ++i) {\\n if (dfn[succ[now][i]] == -1) {\\n dfs(succ[now][i]);\\n fa[dfn[succ[now][i]]] = dfn[now];\\n }\\n prod[dfn[succ[now][i]]].push_back(dfn[now]);\\n }\\n}\\nvoid compress(int now) {\\n if (anc[anc[now]] != 0) {\\n compress(anc[now]);\\n if (semi[best[now]] > semi[best[anc[now]]]) best[now] = best[anc[now]];\\n anc[now] = anc[anc[now]];\\n }\\n}\\nint eval(int now) {\\n if (anc[now] == 0) return now;\\n compress(now);\\n return best[now];\\n}\\nvoid lengauer_tarjan(int n) {\\n for (int i = 0; i <= n; i++) dfn[i] = fa[i] = -1;\\n timestamp = 0;\\n dfs(root);\\n fa[1] = 0;\\n for (int w = timestamp; w > 1; --w) {\\n if (fa[w] == -1) continue;\\n int sz = prod[w].size();\\n for (int i = 0; i < sz; ++i) {\\n int u = eval(prod[w][i]);\\n if (semi[w] > semi[u]) semi[w] = semi[u];\\n }\\n bucket[semi[w]].push_back(w);\\n anc[w] = fa[w];\\n if (fa[w] == 0) continue;\\n sz = bucket[fa[w]].size();\\n for (int i = 0; i < sz; ++i) {\\n int u = eval(bucket[fa[w]][i]);\\n if (semi[u] < fa[w])\\n idom[bucket[fa[w]][i]] = u;\\n else\\n idom[bucket[fa[w]][i]] = fa[w];\\n }\\n bucket[fa[w]].clear();\\n }\\n for (int w = 2; w <= n; ++w) {\\n if (fa[w] == -1) continue;\\n if (idom[w] != semi[w]) idom[w] = idom[idom[w]];\\n }\\n idom[1] = 0;\\n for (int i = timestamp; i > 1; --i) {\\n if (fa[i] == -1) continue;\\n dom_t[idom[i]].push_back(i);\\n }\\n}\\nint sz[200005];\\nvoid dfs1(int u, int f) {\\n sz[u] = 1;\\n int tmp = f, cnt = 0;\\n int siz = dom_t[u].size();\\n for (int i = 0; i < siz; i++) {\\n dfs1(dom_t[u][i], u);\\n sz[u] +=...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You have a permutation: an array a = [a_1, a_2, …, a_n] of distinct integers from 1 to n. The length of the permutation n is odd.\\n\\nYou need to sort the permutation in increasing order.\\n\\nIn one step, you can choose any prefix of the permutation with an odd length and reverse it. Formally, if a = [a_1, a_2, …, a_n], you can choose any odd integer p between 1 and n, inclusive, and set a to [a_p, a_{p-1}, …, a_1, a_{p+1}, a_{p+2}, …, a_n].\\n\\nFind a way to sort a using no more than 5n\\/2 reversals of the above kind, or determine that such a way doesn't exist. The number of reversals doesn't have to be minimized.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 100). Description of the test cases follows.\\n\\nThe first line of each test case contains a single integer n (3 ≤ n ≤ 2021; n is odd) — the length of the permutation.\\n\\nThe second line contains n distinct integers a_1, a_2, …, a_n (1 ≤ a_i ≤ n) — the permutation itself. \\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 2021.\\n\\nOutput\\n\\nFor each test case, if it's impossible to sort the given permutation in at most 5n\\/2 reversals, print a single integer -1.\\n\\nOtherwise, print an integer m (0 ≤ m ≤ 5n\\/2), denoting the number of reversals in your sequence of steps, followed by m integers p_i (1 ≤ p_i ≤ n; p_i is odd), denoting the lengths of the prefixes of a to be reversed, in chronological order.\\n\\nNote that m doesn't have to be minimized. If there are multiple answers, print any.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n3\\n1 2 3\\n5\\n3 4 5 2 1\\n3\\n2 1 3\\n\\n\\nOutput\\n\\n\\n4\\n3 3 3 3\\n2\\n3 5\\n-1\\n\\nNote\\n\\nIn the first test case, the permutation is already sorted. Any even number of reversals of the length 3 prefix doesn't change that fact.\\n\\nIn the second test case, after reversing the prefix of length 3 the permutation will change to [5, 4, 3, 2, 1], and then after reversing the prefix of length 5 the permutation will change to [1, 2, 3, 4, 5].\\n\\nIn the third test case, it's impossible to sort the permutation.\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint a[2005], ans[10005], n, le;\\nint read() {\\n char ch = getchar();\\n int X = 0;\\n bool fl = 0;\\n while (ch < '0' || ch > '9') {\\n if (ch == '-') fl = 1;\\n ch = getchar();\\n }\\n while (ch >= '0' && ch <= '9') {\\n X = (X << 1) + (X << 3) + ch - '0';\\n ch = getchar();\\n }\\n if (fl) return ~(X - 1);\\n return X;\\n}\\nint ck(int x) {\\n for (int i = 1; i <= n; i++)\\n if (a[i] == x) return i;\\n}\\nint T;\\nint main() {\\n T = read();\\n for (; T; T--) {\\n n = read();\\n le = 0;\\n bool fl = 0;\\n for (int i = 1; i <= n; i++) a[i] = read();\\n for (int i = 1; i <= n; i++)\\n if (abs(a[i] - i) & 1) {\\n puts(\\\"-1\\\");\\n fl = 1;\\n break;\\n }\\n if (fl) {\\n continue;\\n }\\n for (int i = 1; i <= n \\/ 2; i++) {\\n int p1 = ck(i * 2 - 1);\\n reverse(a + 1, a + p1 + 1);\\n ans[++le] = p1;\\n int p2 = ck(i * 2);\\n reverse(a + 1, a + p2);\\n ans[++le] = p2 - 1;\\n reverse(a + 1, a + p2 + 2);\\n ans[++le] = p2 + 1;\\n reverse(a + 1, a + 4);\\n ans[++le] = 3;\\n reverse(a + 1, a + n - i * 2 + 3);\\n ans[++le] = n - i * 2 + 2;\\n }\\n reverse(a + 1, a + 1 + n);\\n ans[++le] = n;\\n cout << le << '\\\\n';\\n for (int i = 1; i <= le; i++) cout << ans[i] << ' ';\\n puts(\\\"\\\");\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Bajtek is learning to skate on ice. He's a beginner, so his only mode of transportation is pushing off from a snow drift to the north, east, south or west and sliding until he lands in another snow drift. He has noticed that in this way it's impossible to get from some snow drifts to some other by any sequence of moves. He now wants to heap up some additional snow drifts, so that he can get from any snow drift to any other one. He asked you to find the minimal number of snow drifts that need to be created.\\n\\nWe assume that Bajtek can only heap up snow drifts at integer coordinates.\\n\\nInput\\n\\nThe first line of input contains a single integer n (1 ≤ n ≤ 100) — the number of snow drifts. Each of the following n lines contains two integers xi and yi (1 ≤ xi, yi ≤ 1000) — the coordinates of the i-th snow drift.\\n\\nNote that the north direction coinсides with the direction of Oy axis, so the east direction coinсides with the direction of the Ox axis. All snow drift's locations are distinct.\\n\\nOutput\\n\\nOutput the minimal number of snow drifts that need to be created in order for Bajtek to be able to reach any snow drift from any other one.\\n\\nExamples\\n\\nInput\\n\\n2\\n2 1\\n1 2\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\n2\\n2 1\\n4 1\\n\\n\\nOutput\\n\\n0\\\":\",\"targets\":\"#include \\nusing namespace std;\\nvector adj[101];\\nbool visited[101];\\nvoid dfs(int s) {\\n if (visited[s])\\n return;\\n else {\\n visited[s] = true;\\n for (int i = 0; i < adj[s].size(); i++) dfs(adj[s][i]);\\n }\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n int j, n, i, x[101], y[101], br = 0;\\n cin >> n;\\n for (i = 1; i <= n; i++) {\\n cin >> x[i] >> y[i];\\n for (j = 1; j < i; j++)\\n if (x[i] == x[j] || y[i] == y[j]) {\\n adj[i].push_back(j);\\n adj[j].push_back(i);\\n }\\n }\\n dfs(1);\\n for (i = 2; i <= n; i++) {\\n if (visited[i] == false) {\\n dfs(i);\\n br++;\\n }\\n }\\n cout << br;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nArkady is playing Battleship. The rules of this game aren't really important.\\n\\nThere is a field of n × n cells. There should be exactly one k-decker on the field, i. e. a ship that is k cells long oriented either horizontally or vertically. However, Arkady doesn't know where it is located. For each cell Arkady knows if it is definitely empty or can contain a part of the ship.\\n\\nConsider all possible locations of the ship. Find such a cell that belongs to the maximum possible number of different locations of the ship.\\n\\nInput\\n\\nThe first line contains two integers n and k (1 ≤ k ≤ n ≤ 100) — the size of the field and the size of the ship.\\n\\nThe next n lines contain the field. Each line contains n characters, each of which is either '#' (denotes a definitely empty cell) or '.' (denotes a cell that can belong to the ship).\\n\\nOutput\\n\\nOutput two integers — the row and the column of a cell that belongs to the maximum possible number of different locations of the ship.\\n\\nIf there are multiple answers, output any of them. In particular, if no ship can be placed on the field, you can output any cell.\\n\\nExamples\\n\\nInput\\n\\n4 3\\n#..#\\n#.#.\\n....\\n.###\\n\\n\\nOutput\\n\\n3 2\\n\\n\\nInput\\n\\n10 4\\n#....##...\\n.#...#....\\n..#..#..#.\\n...#.#....\\n.#..##.#..\\n.....#...#\\n...#.##...\\n.#...#.#..\\n.....#..#.\\n...#.#...#\\n\\n\\nOutput\\n\\n6 1\\n\\n\\nInput\\n\\n19 6\\n##..............###\\n#......#####.....##\\n.....#########.....\\n....###########....\\n...#############...\\n..###############..\\n.#################.\\n.#################.\\n.#################.\\n.#################.\\n#####....##....####\\n####............###\\n####............###\\n#####...####...####\\n.#####..####..#####\\n...###........###..\\n....###########....\\n.........##........\\n#.................#\\n\\n\\nOutput\\n\\n1 8\\n\\nNote\\n\\nThe picture below shows the three possible locations of the ship that contain the cell (3, 2) in the first sample.\\n\\n\",\"targets\":\"#include \\n#pragma GCC optimize(\\\"Ofast\\\")\\n#pragma GCC optimize(\\\"no-stack-protector\\\")\\n#pragma GCC target(\\\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native\\\")\\n#pragma GCC optimize(\\\"unroll-loops\\\")\\nusing namespace std;\\nvoid seriy() {\\n ios::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n}\\nlong long ans[110][110];\\nsigned main() {\\n seriy();\\n long long n, k;\\n cin >> n >> k;\\n char c[n][n];\\n for (long long i = 0; i < n; i++) {\\n for (long long j = 0; j < n; j++) {\\n cin >> c[i][j];\\n }\\n }\\n long long mx = 0;\\n pair an = {1, 1};\\n for (long long i = 0; i < n; i++) {\\n for (long long j = 0; j < n; j++) {\\n bool fl = 0;\\n if (i + k - 1 < n) {\\n fl = 0;\\n for (long long f = i; f < i + k; f++) {\\n if (c[f][j] == '#') {\\n fl = 1;\\n break;\\n }\\n }\\n if (!fl) {\\n for (long long f = i; f < i + k; f++) {\\n ans[f][j]++;\\n if (ans[f][j] > mx) {\\n mx = ans[f][j];\\n an = {f + 1, j + 1};\\n }\\n }\\n }\\n }\\n if (j + k - 1 < n) {\\n fl = 0;\\n for (long long f = j; f < j + k; f++) {\\n if (c[i][f] == '#') {\\n fl = 1;\\n break;\\n }\\n }\\n if (!fl) {\\n for (long long f = j; f < j + k; f++) {\\n ans[i][f]++;\\n if (ans[i][f] > mx) {\\n mx = ans[i][f];\\n an = {i + 1, f + 1};\\n }\\n }\\n }\\n }\\n }\\n }\\n cout << an.first << \\\" \\\" << an.second;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"In a certain video game, the player controls a hero characterized by a single integer value: power. The hero will have to beat monsters that are also characterized by a single integer value: armor.\\n\\nOn the current level, the hero is facing n caves. To pass the level, the hero must enter all the caves in some order, each cave exactly once, and exit every cave safe and sound. When the hero enters cave i, he will have to fight k_i monsters in a row: first a monster with armor a_{i, 1}, then a monster with armor a_{i, 2} and so on, finally, a monster with armor a_{i, k_i}.\\n\\nThe hero can beat a monster if and only if the hero's power is strictly greater than the monster's armor. If the hero can't beat the monster he's fighting, the game ends and the player loses. Note that once the hero enters a cave, he can't exit it before he fights all the monsters in it, strictly in the given order.\\n\\nEach time the hero beats a monster, the hero's power increases by 1.\\n\\nFind the smallest possible power the hero must start the level with to be able to enter all the caves in some order and beat all the monsters.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^5). Description of the test cases follows.\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 10^5) — the number of caves.\\n\\nThe i-th of the next n lines contains an integer k_i (1 ≤ k_i ≤ 10^5) — the number of monsters in the i-th cave, followed by k_i integers a_{i, 1}, a_{i, 2}, …, a_{i, k_i} (1 ≤ a_{i, j} ≤ 10^9) — armor levels of the monsters in cave i in order the hero has to fight them.\\n\\nIt is guaranteed that the sum of k_i over all test cases does not exceed 10^5.\\n\\nOutput\\n\\nFor each test case print a single integer — the smallest possible power the hero must start the level with to be able to enter all the caves in some order and beat all the monsters.\\n\\nExample\\n\\nInput\\n\\n\\n2\\n1\\n1 42\\n2\\n3 10 15 8\\n2 12 11\\n\\n\\nOutput\\n\\n\\n43\\n13\\n\\nNote\\n\\nIn the first test case, the hero has to beat a single monster with...\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\nimport java.math.*;\\n\\n\\n\\/**\\n * @author Naitik\\n * \\n *\\/\\npublic class Main\\n\\n{ \\n\\t static FastReader sc=new FastReader(); \\n\\t static long dp[][][];\\n\\t static int mod=1000000007;\\n\\t static int mod1=998244353;\\n\\t static int max;\\n\\t static long bit[];\\n\\/\\/\\t static long seg[];\\n\\/\\/\\t static long fact[];\\n\\/\\/\\t static long A[];\\n\\t static PrintWriter out=new PrintWriter(System.out);\\n\\t public static void main(String[] args)\\n{\\n\\t\\t \\n\\t\\t StringBuffer sb=new StringBuffer(\\\"\\\");\\n\\t\\t int ttt=1;\\n\\t\\t ttt =i();\\n\\t outer :while (ttt-- > 0) \\n\\t\\t\\t{\\n\\t \\tint n=i();\\n\\t \\tlong B[]=new long[n];\\n\\t \\tint C[]=new int[n];\\n\\t \\tArrayList ll=new ArrayList();\\n\\t \\tfor(int i=0;i=y) {\\n\\t \\t\\t\\t\\t\\tl=mid+1;\\n\\t \\t\\t\\t\\t\\tcontinue bin;\\n\\t \\t\\t\\t\\t}\\n\\t \\t\\t\\t\\ty++;\\n\\t \\t\\t\\t}\\n\\t \\t\\t\\tans=mid;\\n\\t \\t\\t\\tu=mid-1;\\n\\t \\t\\t}\\n\\t \\t\\tB[i]=ans;\\n\\t \\t}\\n\\t \\tPair P[]=new Pair[n];\\n\\t \\tfor(int i=0;iy) {\\n\\t \\t\\t\\t\\tl=mid+1;\\n\\t \\t\\t\\t\\tcontinue bin;\\n\\t \\t\\t\\t}\\n\\t \\t\\t\\ty+=P[i].y;\\n\\t \\t\\t}\\n\\t \\t\\tans=mid;\\n\\t \\t\\tu=mid-1;\\n\\t \\t}\\n\\t \\tout.println(ans);\\n\\t \\t\\n\\t \\t\\n\\t }\\n\\t \\/\\/System.out.println(sb.toString());\\n\\t\\t out.close();\\n\\t \\n\\t \\n\\t \\/\\/CHECK FOR N=1 \\/\\/CHECK FOR M=0\\n \\/\\/CHECK FOR N=1 \\/\\/CHECK...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nVupsen and Pupsen were gifted an integer array. Since Vupsen doesn't like the number 0, he threw away all numbers equal to 0 from the array. As a result, he got an array a of length n.\\n\\nPupsen, on the contrary, likes the number 0 and he got upset when he saw the array without zeroes. To cheer Pupsen up, Vupsen decided to come up with another array b of length n such that ∑_{i=1}^{n}a_i ⋅ b_i=0. Since Vupsen doesn't like number 0, the array b must not contain numbers equal to 0. Also, the numbers in that array must not be huge, so the sum of their absolute values cannot exceed 10^9. Please help Vupsen to find any such array b!\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. The next 2 ⋅ t lines contain the description of test cases. The description of each test case consists of two lines.\\n\\nThe first line of each test case contains a single integer n (2 ≤ n ≤ 10^5) — the length of the array.\\n\\nThe second line contains n integers a_1, a_2, …, a_n (-10^4 ≤ a_i ≤ 10^4, a_i ≠ 0) — the elements of the array a.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case print n integers b_1, b_2, …, b_n — elements of the array b (|b_1|+|b_2|+… +|b_n| ≤ 10^9, b_i ≠ 0, ∑_{i=1}^{n}a_i ⋅ b_i=0).\\n\\nIt can be shown that the answer always exists.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n2\\n5 5\\n5\\n5 -2 10 -9 4\\n7\\n1 2 3 4 5 6 7\\n\\n\\nOutput\\n\\n\\n1 -1\\n-1 5 1 -1 -1\\n-10 2 2 -3 5 -1 -1\\n\\nNote\\n\\nIn the first test case, 5 ⋅ 1 + 5 ⋅ (-1)=5-5=0. You could also print 3 -3, for example, since 5 ⋅ 3 + 5 ⋅ (-3)=15-15=0\\n\\nIn the second test case, 5 ⋅ (-1) + (-2) ⋅ 5 + 10 ⋅ 1 + (-9) ⋅ (-1) + 4 ⋅ (-1)=-5-10+10+9-4=0.\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.File;\\nimport java.io.FileNotFoundException;\\nimport java.io.FileWriter;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.math.BigInteger;\\n\\nimport java.util.*;\\n\\npublic class Main\\n{\\n\\n \\n\\n public static void main(String[] args)\\n {\\n FastScanner input = new FastScanner();\\n StringBuilder result = new StringBuilder();\\n int tc = input.nextInt();\\n while (tc-- > 0) {\\n int n = input.nextInt();\\n int a[] = new int[n];\\n int b[] = new int[n];\\n for (int i = 0; i < n; i++) {\\n a[i] = input.nextInt();\\n \\n }\\n if(n%2==0)\\n {\\n for (int i = 0; i \\nint main(){\\nint a,b;\\nscanf(\\\"%d%d\\\",&a,&b);\\nif((a*b)%2==0)printf(\\\"Even\\\\n\\\");\\nelse printf(\\\"Odd\\\\n\\\");\\nreturn 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nCasimir has a rectangular piece of paper with a checkered field of size n × m. Initially, all cells of the field are white.\\n\\nLet us denote the cell with coordinates i vertically and j horizontally by (i, j). The upper left cell will be referred to as (1, 1) and the lower right cell as (n, m).\\n\\nCasimir draws ticks of different sizes on the field. A tick of size d (d > 0) with its center in cell (i, j) is drawn as follows: \\n\\n 1. First, the center cell (i, j) is painted black. \\n 2. Then exactly d cells on the top-left diagonally to the center and exactly d cells on the top-right diagonally to the center are also painted black. \\n 3. That is all the cells with coordinates (i - h, j ± h) for all h between 0 and d are painted. In particular, a tick consists of 2d + 1 black cells. \\n\\n\\n\\nAn already painted cell will remain black if painted again. Below you can find an example of the 4 × 9 box, with two ticks of sizes 2 and 3.\\n\\n\\n\\nYou are given a description of a checkered field of size n × m. Casimir claims that this field came about after he drew some (possibly 0) ticks on it. The ticks could be of different sizes, but the size of each tick is at least k (that is, d ≥ k for all the ticks).\\n\\nDetermine whether this field can indeed be obtained by drawing some (possibly none) ticks of sizes d ≥ k or not.\\n\\nInput\\n\\nThe first line contains an integer t (1 ≤ t ≤ 100) — the number test cases.\\n\\nThe following lines contain the descriptions of the test cases. \\n\\nThe first line of the test case description contains the integers n, m, and k (1 ≤ k ≤ n ≤ 10; 1 ≤ m ≤ 19) — the field size and the minimum size of the ticks that Casimir drew. The following n lines describe the field: each line consists of m characters either being '.' if the corresponding cell is not yet painted or '*' otherwise.\\n\\nOutput\\n\\nPrint t lines, each line containing the answer to the corresponding test case. The answer to a test case should be YES if the given field can be obtained by drawing ticks of at least the given size and NO otherwise.\\n\\nYou may...\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\n\\npublic class C {\\n\\n static PrintWriter pw;\\n\\n int n, m, k;\\n char[][] g;\\n\\n void solve() {\\n boolean[][] visit = new boolean[n][m];\\n for (int i = 0; i < n; i++) {\\n for (int j = 0; j < m; j++) {\\n if (g[i][j] == '*') {\\n int edge = 0;\\n while (i - edge >= 0 && j - edge >= 0 && j + edge < m\\n && g[i - edge][j - edge] != '.' && g[i - edge][j + edge] != '.') edge++;\\n edge--;\\n if (edge >= k) {\\n for (int l = 0; l <= edge; l++) {\\n visit[i - l][j - l] = true;\\n visit[i - l][j + l] = true;\\n }\\n }\\n }\\n }\\n }\\n for (int i = 0; i < n; i++) {\\n for (int j = 0; j < m; j++) {\\n if (g[i][j] == '*' && !visit[i][j]) {\\n pr(\\\"NO\\\");\\n return;\\n }\\n }\\n }\\n pr(\\\"YES\\\");\\n }\\n\\n private void run() {\\n \\/\\/ read_write_file(); \\/\\/ comment this before submission\\n FastScanner fs = new FastScanner();\\n int t = fs.nextInt();\\n while (t-- > 0) {\\n n = fs.nextInt();\\n m = fs.nextInt();\\n k = fs.nextInt();\\n g = new char[n][m];\\n for (int i = 0; i < n; i++) {\\n String s = fs.next();\\n g[i] = s.toCharArray();\\n }\\n solve();\\n }\\n }\\n\\n private final String INPUT = \\\"input.txt\\\";\\n private final String OUTPUT = \\\"output.txt\\\";\\n\\n void read_write_file() {\\n FileInputStream instream = null;\\n PrintStream outstream = null;\\n try {\\n instream = new FileInputStream(INPUT);\\n outstream = new PrintStream(new FileOutputStream(OUTPUT));\\n System.setIn(instream);\\n System.setOut(outstream);\\n } catch (Exception e) {\\n }\\n }\\n\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given strings S and T, consisting of lowercase English letters. It is guaranteed that T is a permutation of the string abc. \\n\\nFind string S', the lexicographically smallest permutation of S such that T is not a subsequence of S'.\\n\\nString a is a permutation of string b if the number of occurrences of each distinct character is the same in both strings.\\n\\nA string a is a subsequence of a string b if a can be obtained from b by deletion of several (possibly, zero or all) elements.\\n\\nA string a is lexicographically smaller than a string b if and only if one of the following holds:\\n\\n * a is a prefix of b, but a ≠ b;\\n * in the first position where a and b differ, the string a has a letter that appears earlier in the alphabet than the corresponding letter in b.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases. Description of the test cases follows.\\n\\nThe first line of each test case contains a string S (1 ≤ |S| ≤ 100), consisting of lowercase English letters.\\n\\nThe second line of each test case contains a string T that is a permutation of the string abc. (Hence, |T| = 3).\\n\\nNote that there is no limit on the sum of |S| across all test cases.\\n\\nOutput\\n\\nFor each test case, output a single string S', the lexicographically smallest permutation of S such that T is not a subsequence of S'.\\n\\nExample\\n\\nInput\\n\\n\\n7\\nabacaba\\nabc\\ncccba\\nacb\\ndbsic\\nbac\\nabracadabra\\nabc\\ndddddddddddd\\ncba\\nbbc\\nabc\\nac\\nabc\\n\\n\\nOutput\\n\\n\\naaaacbb\\nabccc\\nbcdis\\naaaaacbbdrr\\ndddddddddddd\\nbbc\\nac\\n\\nNote\\n\\nIn the first test case, both aaaabbc and aaaabcb are lexicographically smaller than aaaacbb, but they contain abc as a subsequence.\\n\\nIn the second test case, abccc is the smallest permutation of cccba and does not contain acb as a subsequence.\\n\\nIn the third test case, bcdis is the smallest permutation of dbsic and does not contain bac as a subsequence.\\nimpor\",\"targets\":\"t java.io.BufferedReader;\\nimport java.io.BufferedWriter;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.io.OutputStreamWriter;\\nimport java.util.StringTokenizer;\\n\\n\\/**\\n *\\n * @author eslam\\n *\\/\\npublic class JavaApplication936 {\\n\\n static class FastReader {\\n\\n BufferedReader br;\\n StringTokenizer st;\\n\\n public FastReader() {\\n br = new BufferedReader(\\n new InputStreamReader(System.in));\\n }\\n\\n String next() {\\n while (st == null || !st.hasMoreElements()) {\\n try {\\n st = new StringTokenizer(br.readLine());\\n } catch (IOException e) {\\n e.printStackTrace();\\n }\\n }\\n return st.nextToken();\\n }\\n\\n int nextInt() {\\n return Integer.parseInt(next());\\n }\\n\\n long nextLong() {\\n return Long.parseLong(next());\\n }\\n\\n double nextDouble() {\\n return Double.parseDouble(next());\\n }\\n\\n String nextLine() {\\n String str = \\\"\\\";\\n try {\\n str = br.readLine();\\n } catch (IOException e) {\\n e.printStackTrace();\\n }\\n return str;\\n }\\n }\\n\\n public static void main(String[] args) {\\n FastReader input = new FastReader();\\n BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out));\\n int t = input.nextInt();\\n while (t-- > 0) {\\n String w = input.next();\\n String s = input.next();\\n int a[] = new int[26];\\n for (int i = 0; i < w.length(); i++) {\\n a[w.charAt(i) - 'a']++;\\n }\\n if (s.equals(\\\"abc\\\")) {\\n if (a[0] > 0) {\\n for (int i = 0; i < a[0]; i++) {\\n System.out.print((char) (97));\\n }\\n for (int i = 0; i < a[2]; i++) {\\n System.out.print((char) (99));\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nA binary tree of n nodes is given. Nodes of the tree are numbered from 1 to n and the root is the node 1. Each node can have no child, only one left child, only one right child, or both children. For convenience, let's denote l_u and r_u as the left and the right child of the node u respectively, l_u = 0 if u does not have the left child, and r_u = 0 if the node u does not have the right child.\\n\\nEach node has a string label, initially is a single character c_u. Let's define the string representation of the binary tree as the concatenation of the labels of the nodes in the in-order. Formally, let f(u) be the string representation of the tree rooted at the node u. f(u) is defined as follows: $$$ f(u) = \\\\begin{cases} , & if u = 0; \\\\\\\\\\\\ f(l_u) + c_u + f(r_u) & otherwise, \\\\end{cases} where +$$$ denotes the string concatenation operation.\\n\\nThis way, the string representation of the tree is f(1).\\n\\nFor each node, we can duplicate its label at most once, that is, assign c_u with c_u + c_u, but only if u is the root of the tree, or if its parent also has its label duplicated.\\n\\nYou are given the tree and an integer k. What is the lexicographically smallest string representation of the tree, if we can duplicate labels of at most k nodes?\\n\\nA string a is lexicographically smaller than a string b if and only if one of the following holds: \\n\\n * a is a prefix of b, but a ≠ b; \\n * in the first position where a and b differ, the string a has a letter that appears earlier in the alphabet than the corresponding letter in b. \\n\\nInput\\n\\nThe first line contains two integers n and k (1 ≤ k ≤ n ≤ 2 ⋅ 10^5).\\n\\nThe second line contains a string c of n lower-case English letters, where c_i is the initial label of the node i for 1 ≤ i ≤ n. Note that the given string c is not the initial string representation of the tree.\\n\\nThe i-th of the next n lines contains two integers l_i and r_i (0 ≤ l_i, r_i ≤ n). If the node i does not have the left child, l_i = 0, and if the node i does not have the right child, r_i = 0.\\n\\nIt is...\",\"targets\":\"#include \\nusing namespace std;\\nconst int maxn = 2e5 + 10;\\nint n, k, l[maxn], r[maxn];\\nchar c[maxn];\\nvector v;\\nvoid dfs(int u) {\\n if (!u) return;\\n dfs(l[u]);\\n v.push_back(u);\\n dfs(r[u]);\\n}\\nint f[maxn], g[maxn];\\nvoid calc(int u, int cst) {\\n if (!u || cst > k) return;\\n calc(l[u], cst + 1);\\n if (g[l[u]])\\n g[u] = 1;\\n else if (f[u])\\n g[u] = 1, k -= cst;\\n if (g[u]) calc(r[u], 1);\\n}\\nint main() {\\n scanf(\\\"%d%d%s\\\", &n, &k, c + 1);\\n for (int i = 1; i <= n; ++i) scanf(\\\"%d%d\\\", &l[i], &r[i]);\\n dfs(1);\\n for (int i = n - 2; i >= 0; --i) {\\n if (c[v[i]] < c[v[i + 1]])\\n f[v[i]] = 1;\\n else if (c[v[i]] == c[v[i + 1]])\\n f[v[i]] = f[v[i + 1]];\\n }\\n calc(1, 1);\\n for (int i = 0; i < n; ++i) {\\n putchar(c[v[i]]);\\n if (g[v[i]]) putchar(c[v[i]]);\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given a tree with n nodes. As a reminder, a tree is a connected undirected graph without cycles.\\n\\nLet a_1, a_2, …, a_n be a sequence of integers. Perform the following operation exactly n times: \\n\\n * Select an unerased node u. Assign a_u := number of unerased nodes adjacent to u. Then, erase the node u along with all edges that have it as an endpoint. \\n\\n\\n\\nFor each integer k from 1 to n, find the number, modulo 998 244 353, of different sequences a_1, a_2, …, a_n that satisfy the following conditions:\\n\\n * it is possible to obtain a by performing the aforementioned operations exactly n times in some order. \\n * \\\\operatorname{gcd}(a_1, a_2, …, a_n) = k. Here, \\\\operatorname{gcd} means the greatest common divisor of the elements in a. \\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10 000) — the number of test cases.\\n\\nThe first line of each test case contains a single integer n (2 ≤ n ≤ 10^5).\\n\\nEach of the next n - 1 lines contains two integers u and v (1 ≤ u, v ≤ n) indicating there is an edge between vertices u and v. It is guaranteed that the given edges form a tree.\\n\\nIt is guaranteed that the sum of n over all test cases doesn't exceed 3 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print n integers in a single line, where for each k from 1 to n, the k-th integer denotes the answer when \\\\operatorname{gcd} equals to k.\\n\\nExample\\n\\nInput\\n\\n\\n2\\n3\\n2 1\\n1 3\\n2\\n1 2\\n\\n\\nOutput\\n\\n\\n3 1 0\\n2 0\\n\\nNote\\n\\nIn the first test case, \\n\\n\\n\\n * If we delete the nodes in order 1 → 2 → 3 or 1 → 3 → 2, then the obtained sequence will be a = [2, 0, 0] which has \\\\operatorname{gcd} equals to 2. \\n * If we delete the nodes in order 2 → 1 → 3, then the obtained sequence will be a = [1, 1, 0] which has \\\\operatorname{gcd} equals to 1. \\n * If we delete the nodes in order 3 → 1 → 2, then the obtained sequence will be a = [1, 0, 1] which has \\\\operatorname{gcd} equals to 1. \\n * If we delete the nodes in order 2 → 3 → 1 or 3 → 2 → 1, then the obtained sequence will be a = [0, 1, 1] which has \\\\operatorname{gcd} equals to 1. \\n\\n\\n\\nNote...\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"import sys\\n\\ninput = lambda: sys.stdin.readline().rstrip(\\\"\\\\r\\\\n\\\")\\nMOD = 998244353\\n\\nt = int(input())\\nwhile t > 0:\\n t -= 1\\n n = int(input())\\n g = [[] for i in range(n)]\\n for i in range(n - 1):\\n x, y = map(int, input().split())\\n g[x - 1] += [y - 1]\\n g[y - 1] += [x - 1]\\n f = [0] * n\\n parent = [0] * n\\n f[1] = pow(2, n - 1, MOD)\\n order = [0]\\n for v in order:\\n for u in g[v]:\\n if u != parent[v]:\\n parent[u] = v\\n order += [u]\\n\\n\\n def dfs(k):\\n size = [0] * n\\n for v in reversed(order):\\n if size[v] % k == 0:\\n if v != 0:\\n size[parent[v]] += 1\\n elif v == 0 or (size[v] + 1) % k != 0:\\n return False\\n return True\\n\\n\\n for i in range(2, n):\\n if (n - 1) % i == 0:\\n f[i] = int(dfs(i))\\n h = [0] * (n + 1)\\n for i in range(n - 1, 0, -1):\\n h[i] = f[i]\\n for j in range(i * 2, n, i):\\n h[i] -= h[j]\\n print(*(x for x in h[1:n + 1]))\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Polycarp has come up with a new game to play with you. He calls it \\\"A missing bigram\\\".\\n\\nA bigram of a word is a sequence of two adjacent letters in it.\\n\\nFor example, word \\\"abbaaba\\\" contains bigrams \\\"ab\\\", \\\"bb\\\", \\\"ba\\\", \\\"aa\\\", \\\"ab\\\" and \\\"ba\\\".\\n\\nThe game goes as follows. First, Polycarp comes up with a word, consisting only of lowercase letters 'a' and 'b'. Then, he writes down all its bigrams on a whiteboard in the same order as they appear in the word. After that, he wipes one of them off the whiteboard.\\n\\nFinally, Polycarp invites you to guess what the word that he has come up with was.\\n\\nYour goal is to find any word such that it's possible to write down all its bigrams and remove one of them, so that the resulting sequence of bigrams is the same as the one Polycarp ended up with.\\n\\nThe tests are generated in such a way that the answer exists. If there are multiple answers, you can print any of them.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 2000) — the number of testcases.\\n\\nThe first line of each testcase contains a single integer n (3 ≤ n ≤ 100) — the length of the word Polycarp has come up with.\\n\\nThe second line of each testcase contains n-2 bigrams of that word, separated by a single space. Each bigram consists of two letters, each of them is either 'a' or 'b'.\\n\\nAdditional constraint on the input: there exists at least one string such that it is possible to write down all its bigrams, except one, so that the resulting sequence is the same as the sequence in the input. In other words, the answer exists.\\n\\nOutput\\n\\nFor each testcase print a word, consisting of n letters, each of them should be either 'a' or 'b'. It should be possible to write down all its bigrams and remove one of them, so that the resulting sequence of bigrams is the same as the one Polycarp ended up with.\\n\\nThe tests are generated in such a way that the answer exists. If there are multiple answers, you can print any of them. \\n\\nExample\\n\\nInput\\n\\n\\n4\\n7\\nab bb ba aa ba\\n7\\nab ba aa ab ba\\n3\\naa\\n5\\nbb ab...\",\"targets\":\"t = int(input())\\n\\nfor i in range(t):\\n n = int(input())\\n ss = input()\\n s = ss.split(' ')\\n ans = []\\n t = False\\n ans.append(s[0][0])\\n for j in range(0, n-3):\\n if s[j][1] != s[j+1][0]:\\n t = True\\n ans.append(s[j][1])\\n ans.append(s[j+1][0])\\n else:\\n ans.append(s[j][1])\\n ans.append(s[n-3][1])\\n if t == False:\\n ans.append('a')\\n for x in ans:\\n print(x, end = \\\"\\\")\\n print()\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A bracket sequence is a string containing only characters \\\"(\\\" and \\\")\\\". A regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters \\\"1\\\" and \\\"+\\\" between the original characters of the sequence. For example, bracket sequences \\\"()()\\\" and \\\"(())\\\" are regular (the resulting expressions are: \\\"(1)+(1)\\\" and \\\"((1+1)+1)\\\"), and \\\")(\\\", \\\"(\\\" and \\\")\\\" are not.\\n\\nYou are given an integer n. Your goal is to construct and print exactly n different regular bracket sequences of length 2n.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 50) — the number of test cases.\\n\\nEach test case consists of one line containing one integer n (1 ≤ n ≤ 50).\\n\\nOutput\\n\\nFor each test case, print n lines, each containing a regular bracket sequence of length exactly 2n. All bracket sequences you output for a testcase should be different (though they may repeat in different test cases). If there are multiple answers, print any of them. It can be shown that it's always possible.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n3\\n1\\n3\\n\\n\\nOutput\\n\\n\\n()()()\\n((()))\\n(()())\\n()\\n((()))\\n(())()\\n()(())\\nUsing python3 can you solve the prior task?\",\"targets\":\"for _ in range(int(input())):\\n n = int(input())\\n for i in range(1, n + 1):\\n print('(' * i + ')' * i + '()' * (n - i))\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given an integer k and a string s that consists only of characters 'a' (a lowercase Latin letter) and '*' (an asterisk).\\n\\nEach asterisk should be replaced with several (from 0 to k inclusive) lowercase Latin letters 'b'. Different asterisk can be replaced with different counts of letter 'b'.\\n\\nThe result of the replacement is called a BA-string.\\n\\nTwo strings a and b are different if they either have different lengths or there exists such a position i that a_i ≠ b_i.\\n\\nA string a is lexicographically smaller than a string b if and only if one of the following holds: \\n\\n * a is a prefix of b, but a ≠ b; \\n * in the first position where a and b differ, the string a has a letter that appears earlier in the alphabet than the corresponding letter in b. \\n\\n\\n\\nNow consider all different BA-strings and find the x-th lexicographically smallest of them.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 2000) — the number of testcases.\\n\\nThe first line of each testcase contains three integers n, k and x (1 ≤ n ≤ 2000; 0 ≤ k ≤ 2000; 1 ≤ x ≤ 10^{18}). n is the length of string s.\\n\\nThe second line of each testcase is a string s. It consists of n characters, each of them is either 'a' (a lowercase Latin letter) or '*' (an asterisk).\\n\\nThe sum of n over all testcases doesn't exceed 2000. For each testcase x doesn't exceed the total number of different BA-strings. String s contains at least one character 'a'.\\n\\nOutput\\n\\nFor each testcase, print a single string, consisting only of characters 'b' and 'a' (lowercase Latin letters) — the x-th lexicographically smallest BA-string.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n2 4 3\\na*\\n4 1 3\\na**a\\n6 3 20\\n**a***\\n\\n\\nOutput\\n\\n\\nabb\\nabba\\nbabbbbbbbbb\\n\\nNote\\n\\nIn the first testcase of the example, BA-strings ordered lexicographically are: \\n\\n 1. a\\n 2. ab\\n 3. abb\\n 4. abbb\\n 5. abbbb\\n\\n\\n\\nIn the second testcase of the example, BA-strings ordered lexicographically are: \\n\\n 1. aa\\n 2. aba\\n 3. abba\\n\\n\\n\\nNote that string \\\"aba\\\" is only counted once, even though there are two ways to replace asterisks with characters...\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int T;\\n cin >> T;\\n while (T--) {\\n long long n, k, x;\\n cin >> n >> k >> x;\\n x--;\\n string s;\\n cin >> s;\\n stack lst;\\n int l[2005] = {0};\\n int c = 0;\\n s += '\\\\n';\\n for (int i = 0; i < n; i++) {\\n if (s[i] == '*') {\\n c++;\\n l[c] = 1;\\n while (s[i + 1] == '*') {\\n l[c]++;\\n i++;\\n }\\n }\\n }\\n for (int i = c; i >= 1; i--) {\\n lst.push(x % (l[i] * k + 1));\\n x \\/= (l[i] * k + 1);\\n }\\n for (int i = 0; i < n; i++) {\\n if (s[i] == '*') {\\n if (s[i + 1] != '*') {\\n for (int i = 0; i < lst.top(); i++) {\\n printf(\\\"b\\\");\\n }\\n lst.pop();\\n }\\n } else\\n printf(\\\"%c\\\", s[i]);\\n }\\n puts(\\\"\\\");\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Apart from Nian, there is a daemon named Sui, which terrifies children and causes them to become sick. Parents give their children money wrapped in red packets and put them under the pillow, so that when Sui tries to approach them, it will be driven away by the fairies inside.\\n\\nBig Banban is hesitating over the amount of money to give out. He considers loops to be lucky since it symbolizes unity and harmony.\\n\\nHe would like to find a positive integer n not greater than 1018, such that there are exactly k loops in the decimal representation of n, or determine that such n does not exist.\\n\\nA loop is a planar area enclosed by lines in the digits' decimal representation written in Arabic numerals. For example, there is one loop in digit 4, two loops in 8 and no loops in 5. Refer to the figure below for all exact forms.\\n\\n\\n\\nInput\\n\\nThe first and only line contains an integer k (1 ≤ k ≤ 106) — the desired number of loops.\\n\\nOutput\\n\\nOutput an integer — if no such n exists, output -1; otherwise output any such n. In the latter case, your output should be a positive decimal integer not exceeding 1018.\\n\\nExamples\\n\\nInput\\n\\n2\\n\\n\\nOutput\\n\\n462\\n\\nInput\\n\\n6\\n\\n\\nOutput\\n\\n8080\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"# Problem: B. A Prosperous Lot\\n# Contest: Codeforces - Codeforces Round #462 (Div. 2)\\n# URL: https:\\/\\/codeforces.com\\/contest\\/934\\/problem\\/B\\n# Memory Limit: 256 MB\\n# Time Limit: 1000 ms\\n# Powered by CP Editor (https:\\/\\/github.com\\/cpeditor\\/cpeditor)\\n\\nfrom sys import stdin\\nfrom math import floor\\ndef get_ints(): return list(map(int, stdin.readline().strip().split()))\\n\\nk = int(input())\\nif k >36:\\n\\tprint(-1)\\n\\texit()\\nn = \\\"8\\\" * (k\\/\\/2) if k%2 == 0 else (\\\"8\\\" * (floor(k\\/2)))+\\\"4\\\"\\nif int(n) > 10**18:\\n\\tprint(-1)\\nelse:\\n\\tprint(n)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alexandra has an even-length array a, consisting of 0s and 1s. The elements of the array are enumerated from 1 to n. She wants to remove at most n\\/2 elements (where n — length of array) in the way that alternating sum of the array will be equal 0 (i.e. a_1 - a_2 + a_3 - a_4 + ... = 0). In other words, Alexandra wants sum of all elements at the odd positions and sum of all elements at the even positions to become equal. The elements that you remove don't have to be consecutive.\\n\\nFor example, if she has a = [1, 0, 1, 0, 0, 0] and she removes 2nd and 4th elements, a will become equal [1, 1, 0, 0] and its alternating sum is 1 - 1 + 0 - 0 = 0.\\n\\nHelp her!\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^3). Description of the test cases follows.\\n\\nThe first line of each test case contains a single integer n (2 ≤ n ≤ 10^3, n is even) — length of the array.\\n\\nThe second line contains n integers a_1, a_2, …, a_n (0 ≤ a_i ≤ 1) — elements of the array.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 10^3.\\n\\nOutput\\n\\nFor each test case, firstly, print k (n\\/2 ≤ k ≤ n) — number of elements that will remain after removing in the order they appear in a. Then, print this k numbers. Note that you should print the numbers themselves, not their indices.\\n\\nWe can show that an answer always exists. If there are several answers, you can output any of them. \\n\\nExample\\n\\nInput\\n\\n\\n4\\n2\\n1 0\\n2\\n0 0\\n4\\n0 1 1 1\\n4\\n1 1 0 0\\n\\n\\nOutput\\n\\n\\n1\\n0\\n1\\n0\\n2\\n1 1\\n4\\n1 1 0 0\\n\\nNote\\n\\nIn the first and second cases, alternating sum of the array, obviously, equals 0.\\n\\nIn the third case, alternating sum of the array equals 1 - 1 = 0.\\n\\nIn the fourth case, alternating sum already equals 1 - 1 + 0 - 0 = 0, so we don't have to remove anything.\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"import sys\\nimport math\\n# import numpy as np\\nfast_reader=sys.stdin.readline\\nfast_writer=sys.stdout.write\\n \\ndef input():\\n return fast_reader().strip()\\n \\n# def print(*argv):\\n# fast_writer(' '.join((str(i)) for i in argv))\\n# fast_writer('\\\\n') \\n#############################################################################################\\nfor T in range(int(input())):\\n n=int(input())\\n a = list(map(int,input().split()))\\n ones = sum(a)\\n z = n -ones\\n if(z < n\\/\\/2):\\n k = n-z\\n if(k%2!=0):\\n k-=1\\n print ( k)\\n for i in range(k):\\n print(1,end=' ')\\n else:\\n print ( n - ones)\\n for i in range(n-ones):\\n print(0,end=' ')\\n print()\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Polycarp has a string s. Polycarp performs the following actions until the string s is empty (t is initially an empty string):\\n\\n * he adds to the right to the string t the string s, i.e. he does t = t + s, where t + s is a concatenation of the strings t and s; \\n * he selects an arbitrary letter of s and removes from s all its occurrences (the selected letter must occur in the string s at the moment of performing this action). \\n\\n\\n\\nPolycarp performs this sequence of actions strictly in this order.\\n\\nNote that after Polycarp finishes the actions, the string s will be empty and the string t will be equal to some value (that is undefined and depends on the order of removing).\\n\\nE.g. consider s=\\\"abacaba\\\" so the actions may be performed as follows:\\n\\n * t=\\\"abacaba\\\", the letter 'b' is selected, then s=\\\"aacaa\\\"; \\n * t=\\\"abacabaaacaa\\\", the letter 'a' is selected, then s=\\\"c\\\"; \\n * t=\\\"abacabaaacaac\\\", the letter 'c' is selected, then s=\\\"\\\" (the empty string). \\n\\n\\n\\nYou need to restore the initial value of the string s using only the final value of t and find the order of removing letters from s.\\n\\nInput\\n\\nThe first line contains one integer T (1 ≤ T ≤ 10^4) — the number of test cases. Then T test cases follow.\\n\\nEach test case contains one string t consisting of lowercase letters of the Latin alphabet. The length of t doesn't exceed 5 ⋅ 10^5. The sum of lengths of all strings t in the test cases doesn't exceed 5 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case output in a separate line:\\n\\n * -1, if the answer doesn't exist; \\n * two strings separated by spaces. The first one must contain a possible initial value of s. The second one must contain a sequence of letters — it's in what order one needs to remove letters from s to make the string t. E.g. if the string \\\"bac\\\" is outputted, then, first, all occurrences of the letter 'b' were deleted, then all occurrences of 'a', and then, finally, all occurrences of 'c'. If there are multiple solutions, print any one....\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nint32_t main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n long long t;\\n cin >> t;\\n while (t--) {\\n string s;\\n cin >> s;\\n long long cnt[26] = {};\\n for (char c : s) {\\n cnt[c - 'a']++;\\n }\\n string rem;\\n for (long long i = 0; i < s.length(); i++) {\\n if (cnt[s[i] - 'a'] == 1) {\\n rem += string(1, s[i]);\\n }\\n cnt[s[i] - 'a']--;\\n }\\n long long ac[26] = {};\\n for (char c : s) {\\n ac[c - 'a']++;\\n }\\n bool flag = 1;\\n for (long long i = 0; i < rem.size(); i++) {\\n if (ac[rem[i] - 'a'] % (i + 1) != 0)\\n flag = 0;\\n else {\\n ac[rem[i] - 'a'] \\/= (i + 1);\\n }\\n }\\n string r;\\n for (char c : s) {\\n if (ac[c - 'a']) {\\n r += string(1, c);\\n } else {\\n break;\\n }\\n ac[c - 'a']--;\\n }\\n string temp = r;\\n long long c[26] = {};\\n for (char ci : s) {\\n c[ci - 'a']++;\\n }\\n for (long long j = 0; j < rem.size(); j++) {\\n c[rem[j] - 'a'] = 0;\\n for (long long i = 0; i < r.size(); i++) {\\n if (c[r[i] - 'a']) {\\n temp += string(1, r[i]);\\n }\\n }\\n }\\n if (temp != s) {\\n flag = 0;\\n }\\n if (flag) {\\n cout << r << \\\" \\\" << rem;\\n } else {\\n cout << -1;\\n }\\n cout << endl;\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Anton likes to play chess, and so does his friend Danik.\\n\\nOnce they have played n games in a row. For each game it's known who was the winner — Anton or Danik. None of the games ended with a tie.\\n\\nNow Anton wonders, who won more games, he or Danik? Help him determine this.\\n\\nInput\\n\\nThe first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of games played.\\n\\nThe second line contains a string s, consisting of n uppercase English letters 'A' and 'D' — the outcome of each of the games. The i-th character of the string is equal to 'A' if the Anton won the i-th game and 'D' if Danik won the i-th game.\\n\\nOutput\\n\\nIf Anton won more games than Danik, print \\\"Anton\\\" (without quotes) in the only line of the output.\\n\\nIf Danik won more games than Anton, print \\\"Danik\\\" (without quotes) in the only line of the output.\\n\\nIf Anton and Danik won the same number of games, print \\\"Friendship\\\" (without quotes).\\n\\nExamples\\n\\nInput\\n\\n6\\nADAAAA\\n\\n\\nOutput\\n\\nAnton\\n\\n\\nInput\\n\\n7\\nDDDAADA\\n\\n\\nOutput\\n\\nDanik\\n\\n\\nInput\\n\\n6\\nDADADA\\n\\n\\nOutput\\n\\nFriendship\\n\\nNote\\n\\nIn the first sample, Anton won 6 games, while Danik — only 1. Hence, the answer is \\\"Anton\\\".\\n\\nIn the second sample, Anton won 3 games and Danik won 4 games, so the answer is \\\"Danik\\\".\\n\\nIn the third sample, both Anton and Danik won 3 games and the answer is \\\"Friendship\\\".\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"n = int(input())\\nl = list(input())\\nA = l.count('A')\\nB = l.count('D')\\nif A>B:\\n print(\\\"Anton\\\")\\nelif B>A:\\n print(\\\"Danik\\\")\\nelse :\\n print(\\\"Friendship\\\")\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"In Berland, n different types of banknotes are used. Banknotes of the i-th type have denomination 10^{a_i} burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly 1.\\n\\nLet's denote f(s) as the minimum number of banknotes required to represent exactly s burles. For example, if the denominations of banknotes used in Berland are 1, 10 and 100, then f(59) = 14: 9 banknotes with denomination of 1 burle and 5 banknotes with denomination of 10 burles can be used to represent exactly 9 ⋅ 1 + 5 ⋅ 10 = 59 burles, and there's no way to do it with fewer banknotes.\\n\\nFor a given integer k, find the minimum positive number of burles s that cannot be represented with k or fewer banknotes (that is, f(s) > k).\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — number of test cases.\\n\\nThe first line of each test case contains two integers n and k (1 ≤ n ≤ 10; 1 ≤ k ≤ 10^9).\\n\\nThe next line contains n integers a_1, a_2, ..., a_n (0 = a_1 < a_2 < ... < a_n ≤ 9).\\n\\nOutput\\n\\nFor each test case, print one integer — the minimum positive number of burles s that cannot be represented with k or fewer banknotes.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3 13\\n0 1 2\\n2 777\\n0 4\\n3 255\\n0 1 3\\n10 1000000000\\n0 1 2 3 4 5 6 7 8 9\\n\\n\\nOutput\\n\\n\\n59\\n778\\n148999\\n999999920999999999\\nUsing java can you solve the prior task?\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.io.PrintWriter;\\nimport java.text.DecimalFormat;\\nimport java.util.*;\\n\\n\\/\\/import sun.java2d.opengl.WGLSurfaceData.WGLVSyncOffScreenSurfaceData;\\n\\n\\n \\npublic class Codeforces {\\n\\t\\n\\tstatic int mod=998244353 ;\\n\\n\\tpublic static void main(String[] args) throws Exception {\\n\\t\\tPrintWriter out=new PrintWriter(System.out);\\n\\t\\tFastScanner fs=new FastScanner();\\n\\t\\tint t=fs.nextInt();\\n\\t\\twhile(t-->0) {\\n\\t\\t\\tint n=fs.nextInt(), k=fs.nextInt();\\n\\t\\t\\tint arr[]=fs.readArray(n);\\n\\t\\t\\tArrays.sort(arr);\\n\\t\\t\\tlong val[]=new long[n];\\n\\t\\t\\tfor(int i=0;i0&&i>1;\\n\\t\\t}\\n\\t\\treturn res;\\n\\t}\\n\\tstatic long gcd(long a,long b) {\\n\\t\\tif(b==0) return a;\\n\\t\\treturn gcd(b,a%b);\\n\\t}\\n\\tstatic long nck(int n,int k) {\\n\\t\\tif(k>n) return 0;\\n\\t\\tlong res=1;\\n\\t\\tres*=fact(n);\\n\\t\\tres%=mod;\\n\\t\\tres*=modInv(fact(k));\\n\\t\\tres%=mod;\\n\\t\\tres*=modInv(fact(n-k)); \\n\\t\\tres%=mod;\\n\\t\\treturn res;\\n\\t}\\n\\tstatic long fact(long n) {\\n\\/\\/\\t\\treturn fact[(int)n];\\n\\t\\tlong res=1;\\n\\t\\tfor(int i=2;i<=n;i++) {\\n\\t\\t\\tres*=i;\\n\\t\\t\\tres%=mod;\\n\\t\\t}\\n\\t\\treturn res;\\n\\t}\\n\\t\\n\\tstatic long modInv(long n) {\\n\\t\\treturn pow(n,mod-2);\\n\\t}\\n\\t\\n\\tstatic void sort(int[] a) {\\n\\t\\t\\/\\/suffle\\n\\t\\tint n=a.length;\\n\\t\\tRandom r=new Random();\\n\\t\\tfor (int i=0; i\\nusing namespace std;\\nint t, n, m, ans;\\nint main() {\\n scanf(\\\"%d\\\", &t);\\n while (t--) {\\n ans = 0;\\n scanf(\\\"%d%d\\\", &n, &m);\\n vector > v(n * m);\\n for (int i = 0; i < n * m; i++) {\\n scanf(\\\"%d\\\", &v[i].first);\\n v[i].second = i;\\n }\\n sort(v.begin(), v.end());\\n for (int i = 0; i < n * m; i++) v[i].second = -v[i].second;\\n for (int i = 0; i < n; i++) {\\n sort(v.begin() + i * m, v.begin() + (i + 1) * m);\\n for (int j = 0; j < m; j++)\\n for (int k = 0; k < j; k++)\\n if (v[i * m + j].second < v[i * m + k].second) ans++;\\n }\\n printf(\\\"%d\\\\n\\\", ans);\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A bracket sequence is a string, containing only characters \\\"(\\\", \\\")\\\", \\\"[\\\" and \\\"]\\\".\\n\\nA correct bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters \\\"1\\\" and \\\"+\\\" between the original characters of the sequence. For example, bracket sequences \\\"()[]\\\", \\\"([])\\\" are correct (the resulting expressions are: \\\"(1)+[1]\\\", \\\"([1+1]+1)\\\"), and \\\"](\\\" and \\\"[\\\" are not. The empty string is a correct bracket sequence by definition.\\n\\nA substring s[l... r] (1 ≤ l ≤ r ≤ |s|) of string s = s1s2... s|s| (where |s| is the length of string s) is the string slsl + 1... sr. The empty string is a substring of any string by definition.\\n\\nYou are given a bracket sequence, not necessarily correct. Find its substring which is a correct bracket sequence and contains as many opening square brackets «[» as possible.\\n\\nInput\\n\\nThe first and the only line contains the bracket sequence as a string, consisting only of characters \\\"(\\\", \\\")\\\", \\\"[\\\" and \\\"]\\\". It is guaranteed that the string is non-empty and its length doesn't exceed 105 characters.\\n\\nOutput\\n\\nIn the first line print a single integer — the number of brackets «[» in the required bracket sequence. In the second line print the optimal sequence. If there are more than one optimal solutions print any of them.\\n\\nExamples\\n\\nInput\\n\\n([])\\n\\n\\nOutput\\n\\n1\\n([])\\n\\n\\nInput\\n\\n(((\\n\\n\\nOutput\\n\\n0\\nSolve the task in PYTHON3.\",\"targets\":\"'''input\\n((()))([]\\n'''\\nfrom sys import stdin\\n\\n\\ndef check_valid(string):\\n\\tstack = []\\n\\tfor i in string:\\n\\t\\tif i in ['(', '[']:\\n\\t\\t\\tstack.append(i)\\n\\t\\telif i == ')':\\n\\t\\t\\tif len(stack) > 0:\\n\\t\\t\\t\\tif stack[-1] == '(':\\n\\t\\t\\t\\t\\tstack.pop()\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\treturn False\\n\\t\\telif i == ']':\\n\\t\\t\\tif len(stack) > 0:\\n\\t\\t\\t\\tif stack[-1] == '[':\\n\\t\\t\\t\\t\\tstack.pop()\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\treturn False\\n \\n\\treturn len(stack) == 0\\n \\n\\ndef merge(index):\\n\\t# refining\\n\\taux = []\\n\\tif len(index) > 0:\\n\\t\\tstart = index[0][0]\\n\\t\\tend = index[0][1]\\n\\t\\tfor i in range(1, len(index)):\\n\\t\\t\\ts, e = index[i]\\n\\t\\t\\tif e <= end:\\n\\t\\t\\t\\tpass\\n\\t\\t\\telif s >= end:\\n\\t\\t\\t\\taux.append([start, end])\\n\\t\\t\\t\\tstart, end = s, e\\n\\t\\taux.append([start, end])\\n\\tindex = aux\\n\\n\\n\\n\\n\\t# acutal merging\\n\\taux = []\\n\\tif len(index) > 0:\\n\\t\\taux = [index[0]]\\n\\t\\tfor i in range(1, len(index)):\\n\\t\\t\\tif index[i][0] == aux[-1][1] + 1:\\n\\t\\t\\t\\taux[-1][1] = index[i][1]\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif check_valid(string[aux[-1][1] + 1: index[i][0]]):\\n\\t\\t\\t\\t\\taux[-1][1] = index[i][1]\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\taux.append(index[i])\\n\\treturn aux\\n \\n\\n# main starts\\nstring = stdin.readline().strip()\\nstack = []\\nindex = []\\nstart = -1\\nend = -1\\nfor i in range(len(string)):\\n\\tif string[i] == '(':\\n\\t\\tstack.append(i)\\n\\telif string[i] == '[':\\n\\t\\tstack.append(i)\\n\\n\\telif string[i] == ')':\\n\\t\\tif len(stack) > 0 and string[stack[-1]] == '(':\\n\\t\\t\\tindex.append([stack[-1], i])\\n\\t\\t\\tstack.pop()\\n\\t\\telse:\\n\\t\\t\\tstack = []\\n\\telif string[i] == ']':\\n\\t\\tif len(stack) > 0 and string[stack[-1]] == '[':\\n\\t\\t\\tindex.append([stack[-1], i])\\n\\t\\t\\tstack.pop()\\t\\n\\t\\telse:\\n\\t\\t\\tstack = []\\n\\nindex.sort(key = lambda x:(x[0], x[1]))\\n\\n\\nindex = merge(index)\\ndiff = 0\\nans = [-1, -1]\\nfor i in index:\\n\\tstart, end = i\\n\\tc = string[start: end + 1].count('[')\\n\\tif diff < c :\\n\\t\\tans = [start, end + 1]\\n\\t\\tdiff = c\\n\\n\\nprint(diff)\\nprint(string[ans[0]: ans[1]])\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nGiven the number n, find the smallest positive integer which has exactly n divisors. It is guaranteed that for the given n the answer will not exceed 1018.\\n\\nInput\\n\\nThe first line of the input contains integer n (1 ≤ n ≤ 1000).\\n\\nOutput\\n\\nOutput the smallest positive integer with exactly n divisors.\\n\\nExamples\\n\\nInput\\n\\n4\\n\\n\\nOutput\\n\\n6\\n\\n\\nInput\\n\\n6\\n\\n\\nOutput\\n\\n12\",\"targets\":\"#include \\nusing namespace std;\\nconst long long maxi = 1e18;\\nlong long prime[] = {0, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29};\\nlong long dp[15][1005], mi[15][1005], ans;\\nint n;\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n for (int i = 1; i <= 10; i++) {\\n mi[i][0] = 1;\\n for (int j = 1; j <= 1000; j++) {\\n long long temp;\\n bool flag = __builtin_mul_overflow(mi[i][j - 1], prime[i], &temp);\\n if (!flag)\\n mi[i][j] = mi[i][j - 1] * prime[i];\\n else\\n mi[i][j] = maxi;\\n }\\n }\\n int n;\\n cin >> n;\\n for (int i = 1; i <= 10; i++) {\\n for (int j = 1; j <= n; j++) dp[i][j] = maxi;\\n }\\n for (int i = 1; i <= n; i++) dp[1][i] = mi[1][i - 1];\\n for (int i = 2; i <= 10; i++) {\\n for (int j = 1; j <= n; j++) {\\n for (int k = 1; k <= j; k++) {\\n if (j % k == 0) {\\n long long temp;\\n bool flag =\\n __builtin_mul_overflow(dp[i - 1][j \\/ k], mi[i][k - 1], &temp);\\n if (!flag) dp[i][j] = min(dp[i][j], dp[i - 1][j \\/ k] * mi[i][k - 1]);\\n }\\n }\\n }\\n }\\n cout << dp[10][n] << \\\"\\\\n\\\";\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"This is the hard version of the problem. The difference between the versions is that the hard version does require you to output the numbers of the rods to be removed. You can make hacks only if all versions of the problem are solved.\\n\\nStitch likes experimenting with different machines with his friend Sparky. Today they built another machine.\\n\\nThe main element of this machine are n rods arranged along one straight line and numbered from 1 to n inclusive. Each of these rods must carry an electric charge quantitatively equal to either 1 or -1 (otherwise the machine will not work). Another condition for this machine to work is that the sign-variable sum of the charge on all rods must be zero.\\n\\nMore formally, the rods can be represented as an array of n numbers characterizing the charge: either 1 or -1. Then the condition must hold: a_1 - a_2 + a_3 - a_4 + … = 0, or ∑_{i=1}^n (-1)^{i-1} ⋅ a_i = 0.\\n\\nSparky charged all n rods with an electric current, but unfortunately it happened that the rods were not charged correctly (the sign-variable sum of the charge is not zero). The friends decided to leave only some of the rods in the machine. Sparky has q questions. In the ith question Sparky asks: if the machine consisted only of rods with numbers l_i to r_i inclusive, what minimal number of rods could be removed from the machine so that the sign-variable sum of charges on the remaining ones would be zero? Also Sparky wants to know the numbers of these rods. Perhaps the friends got something wrong, and the sign-variable sum is already zero. In that case, you don't have to remove the rods at all.\\n\\nIf the number of rods is zero, we will assume that the sign-variable sum of charges is zero, that is, we can always remove all rods.\\n\\nHelp your friends and answer all of Sparky's questions!\\n\\nInput\\n\\nEach test contains multiple test cases.\\n\\nThe first line contains one positive integer t (1 ≤ t ≤ 10^3), denoting the number of test cases. Description of the test cases follows.\\n\\nThe first line of each test case contains two positive...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nconst double PI = 3.1415926535897932384626433;\\nconst int KL = 1e6;\\nconst long long MOD = 1e9 + 7;\\nusing namespace std;\\nlong long q, x, y, z, n, m, a[KL], mn = 1e9, mx = -1e9, ans;\\nstring t;\\nlong long fr[2][KL], pr[KL];\\nset vv[KL], uu[KL];\\nint main() {\\n long long T;\\n scanf(\\\"%lld\\\", &T);\\n while (T--) {\\n scanf(\\\"%lld\\\", &n);\\n scanf(\\\"%lld\\\", &q);\\n cin >> t;\\n for (int i = 0; i <= n; i++) vv[i].clear(), uu[i].clear();\\n for (int i = 0; i < n; i++) {\\n if ((i + 1) % 2 == 1) {\\n if (t[i] == '+')\\n t[i] = '-';\\n else\\n t[i] = '+';\\n }\\n }\\n for (int i = 1; i <= n; i++) {\\n if (t[i - 1] == '-') {\\n pr[i] = -1 + pr[i - 1];\\n } else {\\n pr[i] = 1 + pr[i - 1];\\n }\\n if (pr[i] >= 0) {\\n vv[pr[i]].insert(i);\\n } else {\\n uu[abs(pr[i])].insert(i);\\n }\\n }\\n while (q--) {\\n scanf(\\\"%lld\\\", &x);\\n scanf(\\\"%lld\\\", &y);\\n long long ret = pr[y] - pr[x - 1];\\n if (ret == 0) {\\n printf(\\\"0\\\\n\\\");\\n continue;\\n }\\n vector vec;\\n if (ret % 2 == 0) {\\n vec.push_back(x);\\n x++;\\n }\\n ret = pr[y] - pr[x - 1];\\n if (ret < 0)\\n ret--;\\n else\\n ret++;\\n long long v = ret \\/ 2;\\n auto it = vv[0].begin();\\n if (v + pr[x - 1] >= 0) {\\n it = vv[v + pr[x - 1]].lower_bound(x);\\n } else {\\n it = uu[abs(v + pr[x - 1])].lower_bound(x);\\n }\\n vec.push_back(*it);\\n printf(\\\"%d\\\\n\\\", (int)vec.size());\\n sort(vec.begin(), vec.end());\\n for (int i = 0; i < vec.size(); i++) {\\n printf(\\\"%lld \\\", vec[i]);\\n }\\n printf(\\\"\\\\n\\\");\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given a keyboard that consists of 26 keys. The keys are arranged sequentially in one row in a certain order. Each key corresponds to a unique lowercase Latin letter.\\n\\nYou have to type the word s on this keyboard. It also consists only of lowercase Latin letters.\\n\\nTo type a word, you need to type all its letters consecutively one by one. To type each letter you must position your hand exactly over the corresponding key and press it.\\n\\nMoving the hand between the keys takes time which is equal to the absolute value of the difference between positions of these keys (the keys are numbered from left to right). No time is spent on pressing the keys and on placing your hand over the first letter of the word.\\n\\nFor example, consider a keyboard where the letters from 'a' to 'z' are arranged in consecutive alphabetical order. The letters 'h', 'e', 'l' and 'o' then are on the positions 8, 5, 12 and 15, respectively. Therefore, it will take |5 - 8| + |12 - 5| + |12 - 12| + |15 - 12| = 13 units of time to type the word \\\"hello\\\". \\n\\nDetermine how long it will take to print the word s.\\n\\nInput\\n\\nThe first line contains an integer t (1 ≤ t ≤ 1000) — the number of test cases.\\n\\nThe next 2t lines contain descriptions of the test cases.\\n\\nThe first line of a description contains a keyboard — a string of length 26, which consists only of lowercase Latin letters. Each of the letters from 'a' to 'z' appears exactly once on the keyboard.\\n\\nThe second line of the description contains the word s. The word has a length from 1 to 50 letters inclusive and consists of lowercase Latin letters.\\n\\nOutput\\n\\nPrint t lines, each line containing the answer to the corresponding test case. The answer to the test case is the minimal time it takes to type the word s on the given keyboard.\\n\\nExample\\n\\nInput\\n\\n\\n5\\nabcdefghijklmnopqrstuvwxyz\\nhello\\nabcdefghijklmnopqrstuvwxyz\\ni\\nabcdefghijklmnopqrstuvwxyz\\ncodeforces\\nqwertyuiopasdfghjklzxcvbnm\\nqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\\nqwertyuiopasdfghjklzxcvbnm\\nabacaba\\n\\n\\nOutput\\n\\n\\n13\\n0\\n68\\n0\\n74\",\"targets\":\"t=int(input())\\nwhile t>=1:\\n t-=1\\n a=str(input())\\n s=str(input())\\n alpha=list(a)\\n l=[]\\n for i in range(len(s)):\\n for j in range(len(alpha)):\\n if s[i]==alpha[j]:\\n l.append(j+1)\\n ans=0\\n for i in range(len(l)-1):\\n ans+=abs(l[i]-l[i+1])\\n print(ans)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A chess tournament will be held soon, where n chess players will take part. Every participant will play one game against every other participant. Each game ends in either a win for one player and a loss for another player, or a draw for both players.\\n\\nEach of the players has their own expectations about the tournament, they can be one of two types:\\n\\n 1. a player wants not to lose any game (i. e. finish the tournament with zero losses); \\n 2. a player wants to win at least one game. \\n\\n\\n\\nYou have to determine if there exists an outcome for all the matches such that all the players meet their expectations. If there are several possible outcomes, print any of them. If there are none, report that it's impossible.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 200) — the number of test cases.\\n\\nThe first line of each test case contains one integer n (2 ≤ n ≤ 50) — the number of chess players.\\n\\nThe second line contains the string s (|s| = n; s_i ∈ \\\\{1, 2\\\\}). If s_i = 1, then the i-th player has expectations of the first type, otherwise of the second type.\\n\\nOutput\\n\\nFor each test case, print the answer in the following format:\\n\\nIn the first line, print NO if it is impossible to meet the expectations of all players.\\n\\nOtherwise, print YES, and the matrix of size n × n in the next n lines.\\n\\nThe matrix element in the i-th row and j-th column should be equal to:\\n\\n * +, if the i-th player won in a game against the j-th player; \\n * -, if the i-th player lost in a game against the j-th player; \\n * =, if the i-th and j-th players' game resulted in a draw; \\n * X, if i = j. \\n\\nExample\\n\\nInput\\n\\n\\n3\\n3\\n111\\n2\\n21\\n4\\n2122\\n\\n\\nOutput\\n\\n\\nYES\\nX==\\n=X=\\n==X\\nNO\\nYES\\nX--+\\n+X++\\n+-X-\\n--+X\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n int T;\\n cin >> T;\\n while (T--) {\\n int n;\\n cin >> n;\\n string types;\\n cin >> types;\\n vector twos;\\n for (int i = 0; i < n; i++)\\n if (types[i] == '2') twos.push_back(i);\\n if (twos.size() == 1 || twos.size() == 2) {\\n cout << \\\"NO\\\" << endl;\\n continue;\\n }\\n vector > match(n, vector(n, 0));\\n for (int i = 0; i < twos.size(); i++) {\\n for (int j = 0; j < twos.size(); j++) {\\n if (j == i + 1 || i == twos.size() - 1 && j == 0)\\n match[twos[i]][twos[j]] = 1;\\n if (j == i - 1 || i == 0 && j == twos.size() - 1)\\n match[twos[i]][twos[j]] = -1;\\n }\\n }\\n cout << \\\"YES\\\" << endl;\\n vector ans(n, \\\"\\\");\\n int pnt = 0;\\n for (int i = 0; i < n; i++) {\\n if (types[i] == '1') {\\n for (int j = 0; j < i; j++) ans[i] += '=';\\n ans[i] += 'X';\\n for (int j = i + 1; j < n; j++) ans[i] += '=';\\n } else {\\n pnt++;\\n pnt %= n;\\n for (int j = 0; j < n; j++) {\\n if (j == i)\\n ans[i] += 'X';\\n else if (match[i][j] == 1)\\n ans[i] += '+';\\n else if (match[i][j] == -1)\\n ans[i] += '-';\\n else\\n ans[i] += '=';\\n }\\n }\\n cout << ans[i] << endl;\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nPolycarp has come up with a new game to play with you. He calls it \\\"A missing bigram\\\".\\n\\nA bigram of a word is a sequence of two adjacent letters in it.\\n\\nFor example, word \\\"abbaaba\\\" contains bigrams \\\"ab\\\", \\\"bb\\\", \\\"ba\\\", \\\"aa\\\", \\\"ab\\\" and \\\"ba\\\".\\n\\nThe game goes as follows. First, Polycarp comes up with a word, consisting only of lowercase letters 'a' and 'b'. Then, he writes down all its bigrams on a whiteboard in the same order as they appear in the word. After that, he wipes one of them off the whiteboard.\\n\\nFinally, Polycarp invites you to guess what the word that he has come up with was.\\n\\nYour goal is to find any word such that it's possible to write down all its bigrams and remove one of them, so that the resulting sequence of bigrams is the same as the one Polycarp ended up with.\\n\\nThe tests are generated in such a way that the answer exists. If there are multiple answers, you can print any of them.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 2000) — the number of testcases.\\n\\nThe first line of each testcase contains a single integer n (3 ≤ n ≤ 100) — the length of the word Polycarp has come up with.\\n\\nThe second line of each testcase contains n-2 bigrams of that word, separated by a single space. Each bigram consists of two letters, each of them is either 'a' or 'b'.\\n\\nAdditional constraint on the input: there exists at least one string such that it is possible to write down all its bigrams, except one, so that the resulting sequence is the same as the sequence in the input. In other words, the answer exists.\\n\\nOutput\\n\\nFor each testcase print a word, consisting of n letters, each of them should be either 'a' or 'b'. It should be possible to write down all its bigrams and remove one of them, so that the resulting sequence of bigrams is the same as the one Polycarp ended up with.\\n\\nThe tests are generated in such a way that the answer exists. If there are multiple answers, you can print any of them. \\n\\nExample\\n\\nInput\\n\\n\\n4\\n7\\nab bb ba aa ba\\n7\\nab ba aa ab ba\\n3\\naa\\n5\\nbb ab...\",\"targets\":\"import javax.management.MBeanRegistration;\\nimport java.io.*;\\nimport java.util.*;\\npublic class Main {\\n private boolean oj = System.getProperty(\\\"ONLINE_JUDGE\\\") != null;\\n private FastWriter wr;\\n private Reader rd;\\n public final int MOD = 1000000007;\\n\\n \\/************************************************** FAST INPUT IMPLEMENTATION *********************************************\\/\\n class Reader {\\n BufferedReader br;\\n StringTokenizer st;\\n\\n public Reader() {\\n br = new BufferedReader(\\n new InputStreamReader(System.in));\\n }\\n\\n public Reader(String path) throws FileNotFoundException {\\n br = new BufferedReader(\\n new InputStreamReader(new FileInputStream(path)));\\n }\\n\\n String next() {\\n while (st == null || !st.hasMoreElements()) {\\n try {\\n st = new StringTokenizer(br.readLine());\\n } catch (IOException e) {\\n e.printStackTrace();\\n }\\n }\\n return st.nextToken();\\n }\\n\\n int nextInt() {\\n return Integer.parseInt(next());\\n }\\n\\n long nextLong() {\\n return Long.parseLong(next());\\n }\\n\\n double nextDouble() {\\n return Double.parseDouble(next());\\n }\\n\\n String nextLine() {\\n String str = \\\"\\\";\\n try {\\n str = br.readLine();\\n } catch (IOException e) {\\n e.printStackTrace();\\n }\\n return str;\\n }\\n }\\n\\n public int ni() throws IOException {\\n return rd.nextInt();\\n }\\n\\n public long nl() throws IOException {\\n return rd.nextLong();\\n }\\n\\n char nc() throws IOException {\\n return rd.next().charAt(0);\\n }\\n\\n public String ns() throws IOException {\\n return rd.nextLine();\\n }\\n\\n public Double nd() throws IOException {\\n return rd.nextDouble();\\n }\\n\\n public int[] nai(int n) throws IOException {\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Polycarp doesn't like integers that are divisible by 3 or end with the digit 3 in their decimal representation. Integers that meet both conditions are disliked by Polycarp, too.\\n\\nPolycarp starts to write out the positive (greater than 0) integers which he likes: 1, 2, 4, 5, 7, 8, 10, 11, 14, 16, .... Output the k-th element of this sequence (the elements are numbered from 1).\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 100) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one line containing one integer k (1 ≤ k ≤ 1000).\\n\\nOutput\\n\\nFor each test case, output in a separate line one integer x — the k-th element of the sequence that was written out by Polycarp.\\n\\nExample\\n\\nInput\\n\\n\\n10\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n1000\\n\\n\\nOutput\\n\\n\\n1\\n2\\n4\\n5\\n7\\n8\\n10\\n11\\n14\\n1666\\nSolve the task in JAVA.\",\"targets\":\"import java.util.Scanner;\\nimport java.util.ArrayList;\\n \\npublic class Rough{\\n public static void main(String[] args){\\n Scanner sc = new Scanner(System.in);\\n int test_cases = sc.nextInt();\\n ArrayList a1 = new ArrayList();\\n for(int j = 1; j<= 1666;j++)\\n if(j%3 == 0 || j%10 == 3)\\n continue;\\n else\\n a1.add(j);\\n for(int i=0; i 0) {\\n\\t\\t\\tStringBuffer buf = new StringBuffer();\\n\\t\\t\\tString[] str = br.readLine().split(\\\" \\\");\\n\\t\\t\\tint n = Integer.parseInt(str[0]);\\n\\t\\t\\tint[] a = new int[n];\\n\\t\\t\\tint[] b = new int[n];\\n\\t\\t\\tint[] counta = new int[n];\\n\\t\\t\\tint[] countb = new int[n];\\n\\t\\t\\tfor(int i=0; i i + 1:\\n f = False\\n break\\n if f:\\n print('YES')\\n else:\\n print('NO')\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Mr. Chanek gives you a sequence a indexed from 1 to n. Define f(a) as the number of indices where a_i = i. \\n\\nYou can pick an element from the current sequence and remove it, then concatenate the remaining elements together. For example, if you remove the 3-rd element from the sequence [4, 2, 3, 1], the resulting sequence will be [4, 2, 1]. \\n\\nYou want to remove some elements from a in order to maximize f(a), using zero or more operations. Find the largest possible f(a).\\n\\nInput\\n\\nThe first line contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the initial length of the sequence.\\n\\nThe second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 2 ⋅ 10^5) — the initial sequence a.\\n\\nOutput\\n\\nOutput an integer denoting the largest f(a) that can be obtained by doing zero or more operations.\\n\\nExamples\\n\\nInput\\n\\n\\n7\\n2 1 4 2 5 3 7\\n\\n\\nOutput\\n\\n\\n3\\n\\n\\nInput\\n\\n\\n4\\n4 2 3 1\\n\\n\\nOutput\\n\\n\\n2\\n\\nNote\\n\\nIn the first example, f(A) = 3 by doing the following operations.\\n\\n[2,1,4,2,5,3,7] → [2,1,2,5,3,7] → [1,2,5,3,7] → [1,2,5,3] → [1,2,3]\\n\\nIn the second example, f(A) = 2 and no additional operation is needed.\\\":\",\"targets\":\"#include \\nusing namespace std;\\nbool isprime(long long k) {\\n for (long long i = 2; i <= sqrt(k); i++)\\n if (k % i == 0) return false;\\n return true;\\n}\\nlong long bm(long long a, long long b, long long mod) {\\n if (b == 0) return 1;\\n long long t = bm(a, b \\/ 2, mod);\\n t = t * t % mod;\\n return (b % 2 == 1 ? t * a % mod : t);\\n}\\nlong long inv(long long a, long long mod) { return bm(a, mod - 2, mod); }\\nvoid gay(long long TC) { cout << \\\"Case #\\\" << TC << \\\": \\\"; }\\nstruct pe {\\n long long v;\\n long long id;\\n} a[200005];\\nlong long b[200005];\\nbool cmp(pe x, pe y) {\\n if (x.v == y.v) return x.id < y.id;\\n return x.v < y.v;\\n}\\nlong long d[200005];\\nlong long cnt;\\nlong long n;\\nbool can(long long k) {\\n long long pos;\\n cnt = 0;\\n for (long long i = 0; i < n; i++) d[i] = 0;\\n for (long long i = 1; i < n; i++) {\\n if (a[i].v >= 0) {\\n pos = i;\\n break;\\n }\\n }\\n for (long long i = pos; i < n; i++) {\\n if (cnt == 0 || a[i].id > d[cnt]) {\\n d[++cnt] = a[i].id;\\n } else {\\n long long k = lower_bound(d + 1, d + 1 + cnt, a[i].id) - d;\\n if (k >= 0) d[k] = a[i].id;\\n }\\n if (cnt >= k) return true;\\n }\\n return false;\\n}\\nvoid solve(long long TC) {\\n cin >> n;\\n for (long long i = 1; i <= n; i++) {\\n cin >> b[i];\\n if (b[i] > n) {\\n b[i] = n + 1;\\n }\\n a[i].v = i - b[i];\\n a[i].id = b[i];\\n }\\n sort(a + 1, a + 1 + n, cmp);\\n long long l = 0, r = n;\\n n++;\\n while (l < r) {\\n long long m = (l + r + 1) \\/ 2;\\n if (!can(m))\\n r = m - 1;\\n else\\n l = m;\\n }\\n cout << l << '\\\\n';\\n}\\nsigned main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n long long t = 1;\\n for (long long i = 1; i <= t; i++) solve(i);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"There are currently n hot topics numbered from 0 to n-1 at your local bridge club and 2^n players numbered from 0 to 2^n-1. Each player holds a different set of views on those n topics, more specifically, the i-th player holds a positive view on the j-th topic if i\\\\ \\\\&\\\\ 2^j > 0, and a negative view otherwise. Here \\\\& denotes the [bitwise AND operation](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#AND).\\n\\nYou are going to organize a bridge tournament capable of accommodating at most k pairs of players (bridge is played in teams of two people). You can select teams arbitrarily while each player is in at most one team, but there is one catch: two players cannot be in the same pair if they disagree on 2 or more of those n topics, as they would argue too much during the play.\\n\\nYou know that the i-th player will pay you a_i dollars if they play in this tournament. Compute the maximum amount of money that you can earn if you pair the players in your club optimally.\\n\\nInput\\n\\nThe first line contains two integers n, k (1 ≤ n ≤ 20, 1 ≤ k ≤ 200) — the number of hot topics and the number of pairs of players that your tournament can accommodate.\\n\\nThe second line contains 2^n integers a_0, a_1, ..., a_{2^n-1} (0 ≤ a_i ≤ 10^6) — the amounts of money that the players will pay to play in the tournament.\\n\\nOutput\\n\\nPrint one integer: the maximum amount of money that you can earn if you pair the players in your club optimally under the above conditions.\\n\\nExamples\\n\\nInput\\n\\n\\n3 1\\n8 3 5 7 1 10 3 2\\n\\n\\nOutput\\n\\n\\n13\\n\\n\\nInput\\n\\n\\n2 3\\n7 4 5 7\\n\\n\\nOutput\\n\\n\\n23\\n\\n\\nInput\\n\\n\\n3 2\\n1 9 1 5 7 8 1 1\\n\\n\\nOutput\\n\\n\\n29\\n\\nNote\\n\\nIn the first example, the best we can do is to pair together the 0-th player and the 2-nd player resulting in earnings of 8 + 5 = 13 dollars. Although pairing the 0-th player with the 5-th player would give us 8 + 10 = 18 dollars, we cannot do this because those two players disagree on 2 of the 3 hot topics.\\n\\nIn the second example, we can pair the 0-th player with the 1-st player and pair the 2-nd player with the 3-rd player resulting in...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nusing Flow = int;\\nusing Cost = long long;\\nnamespace mcf {\\nstruct edge {\\n int from, to;\\n Flow capacity;\\n Cost cost;\\n edge(int f, int t, Flow cap, Cost cst) {\\n from = f;\\n to = t;\\n capacity = cap;\\n cost = cst;\\n }\\n};\\nvector edges;\\nvector> adj;\\nconst Cost INF_COST = 1e12;\\nvoid shortest_paths(int v0, vector &d, vector &p) {\\n const int n = adj.size();\\n d.assign(n, INF_COST);\\n d[v0] = 0;\\n vector inq(n, false);\\n queue q;\\n q.push(v0);\\n p.assign(n, -1);\\n while (!q.empty()) {\\n int u = q.front();\\n q.pop();\\n inq[u] = false;\\n for (int id : adj[u]) {\\n const edge &e = edges[id];\\n int v = edges[id].to;\\n if (e.capacity > 0 && d[v] > d[u] + e.cost) {\\n d[v] = d[u] + e.cost;\\n p[v] = id;\\n if (!inq[v]) {\\n inq[v] = true;\\n q.push(v);\\n }\\n }\\n }\\n }\\n}\\nvoid init(int n) {\\n adj.assign(n, vector());\\n edges.clear();\\n}\\nvoid add(int from, int to, Flow cap, Cost c) {\\n adj[from].push_back(edges.size());\\n edges.emplace_back(from, to, cap, c);\\n adj[to].push_back(edges.size());\\n edges.emplace_back(to, from, 0, -c);\\n}\\nCost min_cost_flow(Flow K, int s, int t) {\\n Flow flow = 0;\\n Cost cost = 0;\\n vector d;\\n vector p;\\n while (flow < K) {\\n shortest_paths(s, d, p);\\n if (d[t] == INF_COST) {\\n break;\\n }\\n Flow f = K - flow;\\n int cur = t;\\n while (cur != s) {\\n f = min(f, edges[p[cur]].capacity);\\n cur = edges[p[cur]].from;\\n }\\n flow += f;\\n cost += f * d[t];\\n cur = t;\\n while (cur != s) {\\n edges[p[cur]].capacity -= f;\\n edges[p[cur] ^ 1].capacity += f;\\n cur = edges[p[cur]].from;\\n }\\n }\\n return cost;\\n}\\n}; \\/\\/ namespace mcf\\ntemplate \\nusing pqueue = priority_queue, function>;\\nvoid foo() {\\n int n, k;\\n cin >> n >> k;\\n const int V = 1 << n;\\n vector a(V);\\n for (int i = 0; i < V; i++) {\\n cin >> a[i];\\n }\\n vector> edges;\\n auto...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Petya has an array of integers a_1, a_2, …, a_n. He only likes sorted arrays. Unfortunately, the given array could be arbitrary, so Petya wants to sort it.\\n\\nPetya likes to challenge himself, so he wants to sort array using only 3-cycles. More formally, in one operation he can pick 3 pairwise distinct indices i, j, and k (1 ≤ i, j, k ≤ n) and apply i → j → k → i cycle to the array a. It simultaneously places a_i on position j, a_j on position k, and a_k on position i, without changing any other element.\\n\\nFor example, if a is [10, 50, 20, 30, 40, 60] and he chooses i = 2, j = 1, k = 5, then the array becomes [\\\\underline{50}, \\\\underline{40}, 20, 30, \\\\underline{10}, 60].\\n\\nPetya can apply arbitrary number of 3-cycles (possibly, zero). You are to determine if Petya can sort his array a, i. e. make it non-decreasing.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 5 ⋅ 10^5). Description of the test cases follows.\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 5 ⋅ 10^5) — the length of the array a.\\n\\nThe second line of each test case contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ n).\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 5 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print \\\"YES\\\" (without quotes) if Petya can sort the array a using 3-cycles, and \\\"NO\\\" (without quotes) otherwise. You can print each letter in any case (upper or lower).\\n\\nExample\\n\\nInput\\n\\n\\n7\\n1\\n1\\n2\\n2 2\\n2\\n2 1\\n3\\n1 2 3\\n3\\n2 1 3\\n3\\n3 1 2\\n4\\n2 1 4 3\\n\\n\\nOutput\\n\\n\\nYES\\nYES\\nNO\\nYES\\nNO\\nYES\\nYES\\n\\nNote\\n\\nIn the 6-th test case Petya can use the 3-cycle 1 → 3 → 2 → 1 to sort the array.\\n\\nIn the 7-th test case Petya can apply 1 → 3 → 2 → 1 and make a = [1, 4, 2, 3]. Then he can apply 2 → 4 → 3 → 2 and finally sort the array.\\nSolve the task in JAVA.\",\"targets\":\"import java.io.BufferedOutputStream;\\nimport java.io.BufferedReader;\\nimport java.io.FileInputStream;\\nimport java.io.FileNotFoundException;\\nimport java.io.FileOutputStream;\\nimport java.io.IOException;\\nimport java.io.InputStream;\\nimport java.io.InputStreamReader;\\nimport java.io.PrintWriter;\\nimport java.util.InputMismatchException;\\nimport java.util.Random;\\nimport java.util.StringTokenizer;\\n\\npublic class A4 {\\n\\n static MergeSort ms = new MergeSort(500_050);\\n \\n void solve() {\\n int n = cint();\\n int[] a = carr_int(n);\\n\\n if (n == 1) {\\n cout(\\\"YES\\\");\\n return;\\n }\\n if (n == 2) {\\n cout(a[0] <= a[1] ? \\\"YES\\\" : \\\"NO\\\");\\n return;\\n }\\n\\n ms.mergeSort(a);\\n for (int i = 1; i < n; i++) {\\n if (a[i] == a[i-1]) {\\n cout(\\\"YES\\\");\\n return;\\n }\\n }\\n\\n if (ms.invariants % 2 == 1) {\\n cout(\\\"NO\\\");\\n } else {\\n cout(\\\"YES\\\");\\n }\\n }\\n \\n static class MergeSort {\\n\\n final int[] b;\\n long invariants; \\/\\/ сумма попарных инвариантов в изначальном массиве\\n\\n public MergeSort(int maxSize) { \\/\\/ доп память\\n this.b = new int[maxSize];\\n }\\n\\n void mergeSort(int[] a) {\\n invariants = 0;\\n mergeSort(a, 0, a.length-1);\\n }\\n\\n void mergeSort(int[] a, int lo, int hi) {\\n if (hi <= lo) {\\n return;\\n }\\n int mid = lo + (hi - lo) \\/ 2;\\n mergeSort(a, lo, mid);\\n mergeSort(a, mid + 1, hi);\\n\\n System.arraycopy(a, lo, b, lo, hi-lo+1);\\n\\n int i = lo, j = mid + 1;\\n for (int k = lo; k <= hi; k++) {\\n if (i > mid) {\\n a[k] = b[j++];\\n } else if (j > hi) {\\n a[k] = b[i++];\\n } else if (b[j] < b[i]) {\\n a[k] = b[j++];\\n invariants += (mid - i + 1);\\n } else {\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Being tired of participating in too many Codeforces rounds, Gildong decided to take some rest in a park. He sat down on a bench, and soon he found two rabbits hopping around. One of the rabbits was taller than the other.\\n\\nHe noticed that the two rabbits were hopping towards each other. The positions of the two rabbits can be represented as integer coordinates on a horizontal line. The taller rabbit is currently on position x, and the shorter rabbit is currently on position y (x < y). Every second, each rabbit hops to another position. The taller rabbit hops to the positive direction by a, and the shorter rabbit hops to the negative direction by b.\\n\\n\\n\\nFor example, let's say x=0, y=10, a=2, and b=3. At the 1-st second, each rabbit will be at position 2 and 7. At the 2-nd second, both rabbits will be at position 4.\\n\\nGildong is now wondering: Will the two rabbits be at the same position at the same moment? If so, how long will it take? Let's find a moment in time (in seconds) after which the rabbits will be at the same point.\\n\\nInput\\n\\nEach test contains one or more test cases. The first line contains the number of test cases t (1 ≤ t ≤ 1000).\\n\\nEach test case contains exactly one line. The line consists of four integers x, y, a, b (0 ≤ x < y ≤ 10^9, 1 ≤ a,b ≤ 10^9) — the current position of the taller rabbit, the current position of the shorter rabbit, the hopping distance of the taller rabbit, and the hopping distance of the shorter rabbit, respectively.\\n\\nOutput\\n\\nFor each test case, print the single integer: number of seconds the two rabbits will take to be at the same position.\\n\\nIf the two rabbits will never be at the same position simultaneously, print -1.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n0 10 2 3\\n0 10 3 3\\n900000000 1000000000 1 9999999\\n1 2 1 1\\n1 3 1 1\\n\\n\\nOutput\\n\\n\\n2\\n-1\\n10\\n-1\\n1\\n\\nNote\\n\\nThe first case is explained in the description.\\n\\nIn the second case, each rabbit will be at position 3 and 7 respectively at the 1-st second. But in the 2-nd second they will be at 6 and 4 respectively, and we can see that they will never...\",\"targets\":\"for _ in range(int(input())):\\n x,y,a,b = list(map(int,input().split()))\\n y-=x\\n if (y%(a+b)!=0):\\n print(-1)\\n else:\\n print(int(y\\/(a+b)))\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"Polycarp doesn't like integers that are divisible by 3 or end with the digit 3 in their decimal representation. Integers that meet both conditions are disliked by Polycarp, too.\\n\\nPolycarp starts to write out the positive (greater than 0) integers which he likes: 1, 2, 4, 5, 7, 8, 10, 11, 14, 16, .... Output the k-th element of this sequence (the elements are numbered from 1).\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 100) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one line containing one integer k (1 ≤ k ≤ 1000).\\n\\nOutput\\n\\nFor each test case, output in a separate line one integer x — the k-th element of the sequence that was written out by Polycarp.\\n\\nExample\\n\\nInput\\n\\n\\n10\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n1000\\n\\n\\nOutput\\n\\n\\n1\\n2\\n4\\n5\\n7\\n8\\n10\\n11\\n14\\n1666\\\":\",\"targets\":\"import java.util.*;\\n \\npublic class HelloWorld {\\n \\n\\tpublic static void main(String[] args) {\\n\\t\\tScanner sc = new Scanner(System.in);\\n\\t\\tint t=sc.nextInt();\\n\\t\\tint x[]=new int[t];\\n\\t\\tfor(int i=0;i\\n\\nWilliam has two numbers a and b initially both equal to zero. William mastered performing three different operations with them quickly. Before performing each operation some positive integer k is picked, which is then used to perform one of the following operations: (note, that for each operation you can choose a new positive integer k)\\n\\n 1. add number k to both a and b, or \\n 2. add number k to a and subtract k from b, or \\n 3. add number k to b and subtract k from a. \\n\\n\\n\\nNote that after performing operations, numbers a and b may become negative as well.\\n\\nWilliam wants to find out the minimal number of operations he would have to perform to make a equal to his favorite number c and b equal to his second favorite number d.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^4). Description of the test cases follows.\\n\\nThe only line of each test case contains two integers c and d (0 ≤ c, d ≤ 10^9), which are William's favorite numbers and which he wants a and b to be transformed into.\\n\\nOutput\\n\\nFor each test case output a single number, which is the minimal number of operations which William would have to perform to make a equal to c and b equal to d, or -1 if it is impossible to achieve this using the described operations.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n1 2\\n3 5\\n5 3\\n6 6\\n8 0\\n0 0\\n\\n\\nOutput\\n\\n\\n-1\\n2\\n2\\n1\\n2\\n0\\n\\nNote\\n\\nLet us demonstrate one of the suboptimal ways of getting a pair (3, 5):\\n\\n * Using an operation of the first type with k=1, the current pair would be equal to (1, 1). \\n * Using an operation of the third type with k=8, the current pair would be equal to (-7, 9). \\n * Using an operation of the second type with k=7, the current pair would be equal to (0, 2). \\n * Using an operation of the first type with k=3, the current pair would be equal to (3, 5).\",\"targets\":\"import sys\\nimport io, os\\nimport math\\nfrom heapq import *\\ngcd = math.gcd\\nsqrt = math.sqrt\\nfloor=math.floor\\ndef ceil(a,b):\\n a=-a\\n k=a\\/\\/b\\n k=-k\\n return k\\n# arr=list(map(int, input().split()))\\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\\ndef strinp(testcases):\\n k = 5\\n if (testcases == -1 or testcases == 1):\\n k = 1\\n f = str(input())\\n f = f[2:len(f) - k]\\n return f\\ndef main():\\n t=int(input())\\n for _ in range(t):\\n arr=list(map(int, input().split()))\\n c=arr[0]\\n d=arr[1]\\n if(c==d):\\n if(c==0):\\n print(0)\\n else:\\n print(1)\\n continue\\n if((c+d)%2!=0):\\n print(-1)\\n else:\\n print(2)\\nmain()\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size n. Let's call them a and b.\\n\\nNote that a permutation of n elements is a sequence of numbers a_1, a_2, …, a_n, in which every number from 1 to n appears exactly once. \\n\\nThe message can be decoded by an arrangement of sequence a and b, such that the number of matching pairs of elements between them is maximum. A pair of elements a_i and b_j is said to match if: \\n\\n * i = j, that is, they are at the same index. \\n * a_i = b_j \\n\\n\\n\\nHis two disciples are allowed to perform the following operation any number of times: \\n\\n * choose a number k and cyclically shift one of the permutations to the left or right k times. \\n\\n\\n\\nA single cyclic shift to the left on any permutation c is an operation that sets c_1:=c_2, c_2:=c_3, …, c_n:=c_1 simultaneously. Likewise, a single cyclic shift to the right on any permutation c is an operation that sets c_1:=c_n, c_2:=c_1, …, c_n:=c_{n-1} simultaneously.\\n\\nHelp Ishika and Hriday find the maximum number of pairs of elements that match after performing the operation any (possibly zero) number of times.\\n\\nInput\\n\\nThe first line of the input contains a single integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the size of the arrays.\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ n) — the elements of the first permutation.\\n\\nThe third line contains n integers b_1, b_2, ..., b_n (1 ≤ b_i ≤ n) — the elements of the second permutation.\\n\\nOutput\\n\\nPrint the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times.\\n\\nExamples\\n\\nInput\\n\\n\\n5\\n1 2 3 4 5\\n2 3 4 5 1\\n\\n\\nOutput\\n\\n\\n5\\n\\nInput\\n\\n\\n5\\n5 4 3 2 1\\n1 2 3 4 5\\n\\n\\nOutput\\n\\n\\n1\\n\\nInput\\n\\n\\n4\\n1 3 2 4\\n4 2 3 1\\n\\n\\nOutput\\n\\n\\n2\\n\\nNote\\n\\nFor the first case: b can be shifted to the right by k = 1. The resulting permutations will be \\\\{1, 2, 3, 4, 5\\\\} and \\\\{1, 2, 3, 4, 5\\\\}.\\n\\nFor the second case: The operation is not required....\\nfrom\",\"targets\":\"collections import Counter\\nsize = int(input())\\nfirst_array = list(map(int, input().split()))\\nsecond_array = list(map(int, input().split()))\\nout_comes = []\\ncounter = 0\\ndata = {}\\nfor index, val in enumerate(second_array):\\n data[val] = index\\n\\nfor index, value in enumerate(first_array):\\n temp_val = data[value] - index\\n if temp_val >= 0:\\n out_comes.append(temp_val)\\n else:\\n out_comes.append(size + temp_val)\\nnew_list = Counter(out_comes).most_common()\\nprint(new_list[0][1])\\n# print(out_comes)\\n# print(list(dict(new_list).values()))\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"According to a new ISO standard, a flag of every country should have a chequered field n × m, each square should be of one of 10 colours, and the flag should be «striped»: each horizontal row of the flag should contain squares of the same colour, and the colours of adjacent horizontal rows should be different. Berland's government asked you to find out whether their flag meets the new ISO standard.\\n\\nInput\\n\\nThe first line of the input contains numbers n and m (1 ≤ n, m ≤ 100), n — the amount of rows, m — the amount of columns on the flag of Berland. Then there follows the description of the flag: each of the following n lines contain m characters. Each character is a digit between 0 and 9, and stands for the colour of the corresponding square.\\n\\nOutput\\n\\nOutput YES, if the flag meets the new ISO standard, and NO otherwise.\\n\\nExamples\\n\\nInput\\n\\n3 3\\n000\\n111\\n222\\n\\n\\nOutput\\n\\nYES\\n\\n\\nInput\\n\\n3 3\\n000\\n000\\n111\\n\\n\\nOutput\\n\\nNO\\n\\n\\nInput\\n\\n3 3\\n000\\n111\\n002\\n\\n\\nOutput\\n\\nNO\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.util.StringTokenizer;\\nimport java.io.InputStreamReader;\\n\\npublic class Main{\\n public static void main(String[] args)throws IOException{\\n BufferedReader br=new BufferedReader(new InputStreamReader(System.in));\\n String s=br.readLine();\\n StringTokenizer st=new StringTokenizer(s);\\n int n=Integer.parseInt(st.nextToken());\\n int m=Integer.parseInt(st.nextToken());\\n int [][]x=new int[n][m];\\n \\n int i=0;\\n for( i=0;i0 && x[i][j]!=x[i][j-1]){\\n \\n System.out.print(\\\"NO\\\");\\n return;\\n }\\n }\\n \\n if(i>0 && x[i][0]==x[i-1][0]){\\n \\n System.out.print(\\\"NO\\\");\\n return;\\n }\\n }\\n if(i==n)\\n System.out.print(\\\"YES\\\");\\n }}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Filya just learned new geometry object — rectangle. He is given a field consisting of n × n unit cells. Rows are numbered from bottom to top with integer from 1 to n. Columns are numbered from left to right with integers from 1 to n. Cell, located at the intersection of the row r and column c is denoted as (r, c). Filya has painted two rectangles, such that their sides are parallel to coordinate axes and each cell lies fully inside or fully outside each of them. Moreover, no cell lies in both rectangles.\\n\\nLater, hedgehog Filya became interested in the location of his rectangles but was unable to find the sheet of paper they were painted on. They were taken by Sonya and now she wants to play a little game with Filya. He tells her a query rectangle and she replies with the number of initial rectangles that lie fully inside the given query rectangle. The query rectangle should match the same conditions as initial rectangles. Rectangle lies fully inside the query if each o its cells lies inside the query.\\n\\nFilya knows Sonya really well, so is sure that if he asks more than 200 questions she will stop to reply.\\n\\nInput\\n\\nThe first line of the input contains an integer n (2 ≤ n ≤ 216) — size of the field.\\n\\nFor each query an integer between 0 and 2 is returned — the number of initial rectangles that lie fully inside the query rectangle.\\n\\nOutput\\n\\nTo make a query you have to print \\\"? x1 y1 x2 y2\\\" (without quotes) (1 ≤ x1 ≤ x2 ≤ n, 1 ≤ y1 ≤ y2 ≤ n), where (x1, y1) stands for the position of the bottom left cell of the query and (x2, y2) stands for the up right cell of the query. You are allowed to ask no more than 200 queries. After each query you should perform \\\"flush\\\" operation and read the answer.\\n\\nIn case you suppose you've already determined the location of two rectangles (or run out of queries) you should print \\\"! x11 y11 x12 y12 x21 y21 x22 y22\\\" (without quotes), where first four integers describe the bottom left and up right cells of the first rectangle, and following four describe the corresponding cells of the...\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 1e5 + 5;\\nint n, res[2][4];\\nvoid solve(int x1, int y1, int x2, int y2, int id) {\\n int l = x1, r = x2;\\n while (l < r) {\\n int m = (l + r) >> 1;\\n printf(\\\"? %d %d %d %d\\\\n\\\", x1, y1, m, y2);\\n fflush(stdout);\\n int num;\\n scanf(\\\"%d\\\", &num);\\n if (num > 0)\\n r = m;\\n else\\n l = m + 1;\\n }\\n x2 = l;\\n l = x1, r = x2;\\n while (l < r) {\\n int m = (l + r + 1) >> 1;\\n printf(\\\"? %d %d %d %d\\\\n\\\", m, y1, x2, y2);\\n fflush(stdout);\\n int num;\\n scanf(\\\"%d\\\", &num);\\n if (num > 0)\\n l = m;\\n else\\n r = m - 1;\\n }\\n x1 = l;\\n l = y1, r = y2;\\n while (l < r) {\\n int m = (l + r) >> 1;\\n printf(\\\"? %d %d %d %d\\\\n\\\", x1, y1, x2, m);\\n fflush(stdout);\\n int num;\\n scanf(\\\"%d\\\", &num);\\n if (num > 0)\\n r = m;\\n else\\n l = m + 1;\\n }\\n y2 = l;\\n l = y1, r = y2;\\n while (l < r) {\\n int m = (l + r + 1) >> 1;\\n printf(\\\"? %d %d %d %d\\\\n\\\", x1, m, x2, y2);\\n fflush(stdout);\\n int num;\\n scanf(\\\"%d\\\", &num);\\n if (num > 0)\\n l = m;\\n else\\n r = m - 1;\\n }\\n y1 = l;\\n res[id][0] = x1;\\n res[id][1] = y1;\\n res[id][2] = x2;\\n res[id][3] = y2;\\n}\\nvoid find() {\\n int l = 1, r = n;\\n while (l < r) {\\n int m = (l + r) >> 1;\\n printf(\\\"? 1 1 %d %d\\\\n\\\", n, m);\\n fflush(stdout);\\n int num;\\n scanf(\\\"%d\\\", &num);\\n if (num > 0)\\n r = m;\\n else\\n l = m + 1;\\n }\\n int num[2];\\n printf(\\\"? 1 1 %d %d\\\\n\\\", n, l);\\n fflush(stdout);\\n scanf(\\\"%d\\\", &num[0]);\\n if (l != n) {\\n printf(\\\"? 1 %d %d %d\\\\n\\\", l + 1, n, n);\\n fflush(stdout);\\n scanf(\\\"%d\\\", &num[1]);\\n } else\\n num[1] = 0;\\n if (num[0] == 1 && num[1] == 1) {\\n solve(1, 1, n, l, 0);\\n solve(1, l + 1, n, n, 1);\\n return;\\n }\\n l = 1, r = n;\\n while (l < r) {\\n int m = (l + r) >> 1;\\n printf(\\\"? 1 1 %d %d\\\\n\\\", m, n);\\n fflush(stdout);\\n int num;\\n scanf(\\\"%d\\\", &num);\\n if (num > 0)\\n r = m;\\n else\\n l = m + 1;\\n }\\n solve(1, 1, l, n, 0);\\n solve(l + 1, 1, n, n, 1);\\n}\\nint main() {\\n scanf(\\\"%d\\\", &n);\\n find();\\n printf(\\\"!\\\");\\n...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nAlice and Bob are playing a game. They are given an array A of length N. The array consists of integers. They are building a sequence together. In the beginning, the sequence is empty. In one turn a player can remove a number from the left or right side of the array and append it to the sequence. The rule is that the sequence they are building must be strictly increasing. The winner is the player that makes the last move. Alice is playing first. Given the starting array, under the assumption that they both play optimally, who wins the game?\\n\\nInput\\n\\nThe first line contains one integer N (1 ≤ N ≤ 2*10^5) - the length of the array A.\\n\\nThe second line contains N integers A_1, A_2,...,A_N (0 ≤ A_i ≤ 10^9)\\n\\nOutput\\n\\nThe first and only line of output consists of one string, the name of the winner. If Alice won, print \\\"Alice\\\", otherwise, print \\\"Bob\\\".\\n\\nExamples\\n\\nInput\\n\\n\\n1\\n5\\n\\n\\nOutput\\n\\n\\nAlice\\n\\n\\nInput\\n\\n\\n3\\n5 4 5\\n\\n\\nOutput\\n\\n\\nAlice\\n\\n\\nInput\\n\\n\\n6\\n5 8 2 1 10 9\\n\\n\\nOutput\\n\\n\\nBob\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.InputStreamReader;\\n\\npublic class Main {\\n public static void main(String[] args) {\\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\\n\\n int len;\\n int[] array;\\n\\n String[] values;\\n\\n try {\\n len = Integer.parseInt(br.readLine());\\n if (len == 1) {\\n System.out.println(\\\"Alice\\\");\\n return;\\n }\\n array = new int[len];\\n values = br.readLine().split(\\\" \\\");\\n } catch (Exception ex) {\\n throw new RuntimeException(ex);\\n }\\n\\n for (int i = 0; i < values.length; i++) {\\n array[i] = Integer.parseInt(values[i]);\\n }\\n\\n String[] participants = {\\n \\\"Alice\\\",\\n \\\"Bob\\\"\\n };\\n\\n int lIdx = 1, rIdx = 1;\\n\\n for (int i = 1; i < len; i++) {\\n if (array[i] > array[i-1]) {\\n lIdx++;\\n } else {\\n break;\\n }\\n }\\n\\n for (int i = len - 2; i > 0; i--) {\\n if (array[i] > array[i+1]) {\\n rIdx++;\\n } else {\\n break;\\n }\\n }\\n\\n System.out.println(participants[lIdx % 2 == 0 && rIdx % 2 == 0 ? 1 : 0]);\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nInitially there was an array a consisting of n integers. Positions in it are numbered from 1 to n.\\n\\nExactly q queries were performed on the array. During the i-th query some segment (l_i, r_i) (1 ≤ l_i ≤ r_i ≤ n) was selected and values of elements on positions from l_i to r_i inclusive got changed to i. The order of the queries couldn't be changed and all q queries were applied. It is also known that every position from 1 to n got covered by at least one segment.\\n\\nWe could have offered you the problem about checking if some given array (consisting of n integers with values from 1 to q) can be obtained by the aforementioned queries. However, we decided that it will come too easy for you.\\n\\nSo the enhancement we introduced to it is the following. Some set of positions (possibly empty) in this array is selected and values of elements on these positions are set to 0.\\n\\nYour task is to check if this array can be obtained by the aforementioned queries. Also if it can be obtained then restore this array.\\n\\nIf there are multiple possible arrays then print any of them.\\n\\nInput\\n\\nThe first line contains two integers n and q (1 ≤ n, q ≤ 2 ⋅ 10^5) — the number of elements of the array and the number of queries perfomed on it.\\n\\nThe second line contains n integer numbers a_1, a_2, ..., a_n (0 ≤ a_i ≤ q) — the resulting array. If element at some position j is equal to 0 then the value of element at this position can be any integer from 1 to q.\\n\\nOutput\\n\\nPrint \\\"YES\\\" if the array a can be obtained by performing q queries. Segments (l_i, r_i) (1 ≤ l_i ≤ r_i ≤ n) are chosen separately for each query. Every position from 1 to n should be covered by at least one segment. \\n\\nOtherwise print \\\"NO\\\".\\n\\nIf some array can be obtained then print n integers on the second line — the i-th number should be equal to the i-th element of the resulting array and should have value from 1 to q. This array should be obtainable by performing exactly q queries.\\n\\nIf there are multiple possible arrays then print any of them.\\n\\nExamples\\n\\nInput\\n\\n4 3\\n1 0 2...\",\"targets\":\"#include \\nusing namespace std;\\nconst long long MaX = 100005, infi = 1110111110111, mod = 1000000007;\\nconst int MX = 200005;\\nint n, m, q, sTree[MX][22], a[MX], sP[MX], eP[MX], fir, wi;\\nint query(int a, int b) {\\n int lgn = log2(b - a + 1);\\n return min(sTree[a][lgn], sTree[b - (1 << (lgn)) + 1][lgn]);\\n}\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n cin >> n >> q;\\n for (int i = 1; i <= n; i++) {\\n cin >> sTree[i][0];\\n if (sTree[i][0] == 0)\\n sTree[i][0] = MX - 1;\\n else if (!fir)\\n fir = sTree[i][0];\\n if (!sP[sTree[i][0]]) sP[sTree[i][0]] = i;\\n eP[sTree[i][0]] = i;\\n m = max(m, sTree[i][0]);\\n wi |= sTree[i][0] == q;\\n }\\n if (m < q) return cout << \\\"NO\\\", 0;\\n for (int j = 1; j < 21; j++)\\n for (int i = 1; i <= n - (1 << j) + 1; i++)\\n sTree[i][j] = min(sTree[i][j - 1], sTree[i + (1 << (j - 1))][j - 1]);\\n for (int i = 1; i <= n; i++) {\\n int x = sTree[i][0];\\n if (x == MX - 1) {\\n if (!wi)\\n sTree[i][0] = q, wi = 1;\\n else if (sTree[i - 1][0] > 0)\\n sTree[i][0] = sTree[i - 1][0];\\n else\\n sTree[i][0] = fir;\\n } else if (query(sP[x], eP[x]) < x)\\n return cout << \\\"NO\\\", 0;\\n }\\n cout << \\\"YES\\\\n\\\";\\n for (int i = 1; i <= n; i++) cout << sTree[i][0] << \\\" \\\";\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Consider a tunnel on a one-way road. During a particular day, n cars numbered from 1 to n entered and exited the tunnel exactly once. All the cars passed through the tunnel at constant speeds.\\n\\nA traffic enforcement camera is mounted at the tunnel entrance. Another traffic enforcement camera is mounted at the tunnel exit. Perfectly balanced.\\n\\nThanks to the cameras, the order in which the cars entered and exited the tunnel is known. No two cars entered or exited at the same time.\\n\\nTraffic regulations prohibit overtaking inside the tunnel. If car i overtakes any other car j inside the tunnel, car i must be fined. However, each car can be fined at most once.\\n\\nFormally, let's say that car i definitely overtook car j if car i entered the tunnel later than car j and exited the tunnel earlier than car j. Then, car i must be fined if and only if it definitely overtook at least one other car.\\n\\nFind the number of cars that must be fined. \\n\\nInput\\n\\nThe first line contains a single integer n (2 ≤ n ≤ 10^5), denoting the number of cars.\\n\\nThe second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ n), denoting the ids of cars in order of entering the tunnel. All a_i are pairwise distinct.\\n\\nThe third line contains n integers b_1, b_2, …, b_n (1 ≤ b_i ≤ n), denoting the ids of cars in order of exiting the tunnel. All b_i are pairwise distinct.\\n\\nOutput\\n\\nOutput the number of cars to be fined.\\n\\nExamples\\n\\nInput\\n\\n\\n5\\n3 5 2 1 4\\n4 3 2 5 1\\n\\n\\nOutput\\n\\n\\n2\\n\\n\\nInput\\n\\n\\n7\\n5 2 3 6 7 1 4\\n2 3 6 7 1 4 5\\n\\n\\nOutput\\n\\n\\n6\\n\\n\\nInput\\n\\n\\n2\\n1 2\\n1 2\\n\\n\\nOutput\\n\\n\\n0\\n\\nNote\\n\\nThe first example is depicted below:\\n\\n\\n\\nCar 2 definitely overtook car 5, while car 4 definitely overtook cars 1, 2, 3 and 5. Cars 2 and 4 must be fined.\\n\\nIn the second example car 5 was definitely overtaken by all other cars.\\n\\nIn the third example no car must be fined.\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int n;\\n cin >> n;\\n queue q;\\n vector ch(n + 1);\\n int ans = 0;\\n for (int i = 0; i < n; i++) {\\n int temp;\\n cin >> temp;\\n q.push(temp);\\n }\\n int now = q.front();\\n q.pop();\\n for (int i = 0; i < n; i++) {\\n int temp;\\n cin >> temp;\\n if (temp == now) {\\n while (!q.empty()) {\\n now = q.front();\\n q.pop();\\n if (!ch[now]) break;\\n }\\n } else {\\n if (!ch[temp]) {\\n ans++;\\n ch[temp] = true;\\n }\\n }\\n }\\n cout << ans;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Recently, Petya learned about a new game \\\"Slay the Dragon\\\". As the name suggests, the player will have to fight with dragons. To defeat a dragon, you have to kill it and defend your castle. To do this, the player has a squad of n heroes, the strength of the i-th hero is equal to a_i.\\n\\nAccording to the rules of the game, exactly one hero should go kill the dragon, all the others will defend the castle. If the dragon's defense is equal to x, then you have to send a hero with a strength of at least x to kill it. If the dragon's attack power is y, then the total strength of the heroes defending the castle should be at least y.\\n\\nThe player can increase the strength of any hero by 1 for one gold coin. This operation can be done any number of times.\\n\\nThere are m dragons in the game, the i-th of them has defense equal to x_i and attack power equal to y_i. Petya was wondering what is the minimum number of coins he needs to spend to defeat the i-th dragon.\\n\\nNote that the task is solved independently for each dragon (improvements are not saved).\\n\\nInput\\n\\nThe first line contains a single integer n (2 ≤ n ≤ 2 ⋅ 10^5) — number of heroes.\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^{12}), where a_i is the strength of the i-th hero.\\n\\nThe third line contains a single integer m (1 ≤ m ≤ 2 ⋅ 10^5) — the number of dragons.\\n\\nThe next m lines contain two integers each, x_i and y_i (1 ≤ x_i ≤ 10^{12}; 1 ≤ y_i ≤ 10^{18}) — defense and attack power of the i-th dragon.\\n\\nOutput\\n\\nPrint m lines, i-th of which contains a single integer — the minimum number of coins that should be spent to defeat the i-th dragon.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3 6 2 3\\n5\\n3 12\\n7 9\\n4 14\\n1 10\\n8 7\\n\\n\\nOutput\\n\\n\\n1\\n2\\n4\\n0\\n2\\n\\nNote\\n\\nTo defeat the first dragon, you can increase the strength of the third hero by 1, then the strength of the heroes will be equal to [3, 6, 3, 3]. To kill the dragon, you can choose the first hero.\\n\\nTo defeat the second dragon, you can increase the forces of the second and third heroes by 1, then the strength of the heroes will...\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\nimport java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.util.Scanner;\\nimport java.util.StringTokenizer;\\n\\npublic class Test{\\n\\n static FastReader scan;\\n\\n static void solve(){\\n int n=scan.nextInt();\\n long[]hero=new long[n];\\n long total=0;\\n for(int i=0;i0){\\n long d=scan.nextLong();\\n long a=scan.nextLong();\\n int left=0,right=n-1;\\n int index=0;\\n while(left<=right){\\n int mid=(left+right)\\/2;\\n if(hero[mid]<=d){\\n index=mid;\\n left=mid+1;\\n }\\n else right=mid-1;\\n }\\n\\n long ha=hero[index];\\n long hd=total-ha;\\n long fb=Math.max(0,d-ha)+Math.max(0,a-hd);\\n if(index0){\\n solve();\\n }\\n }\\n\\n \\n\\n static class FastReader {\\n BufferedReader br;\\n StringTokenizer st;\\n\\n public FastReader()\\n {\\n br = new BufferedReader(\\n new InputStreamReader(System.in));\\n }\\n\\n String next()\\n {\\n while (st == null || !st.hasMoreElements()) {\\n try {\\n st = new StringTokenizer(br.readLine());\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Stephen Queen wants to write a story. He is a very unusual writer, he uses only letters 'a', 'b', 'c', 'd' and 'e'!\\n\\nTo compose a story, Stephen wrote out n words consisting of the first 5 lowercase letters of the Latin alphabet. He wants to select the maximum number of words to make an interesting story.\\n\\nLet a story be a sequence of words that are not necessarily different. A story is called interesting if there exists a letter which occurs among all words of the story more times than all other letters together.\\n\\nFor example, the story consisting of three words \\\"bac\\\", \\\"aaada\\\", \\\"e\\\" is interesting (the letter 'a' occurs 5 times, all other letters occur 4 times in total). But the story consisting of two words \\\"aba\\\", \\\"abcde\\\" is not (no such letter that it occurs more than all other letters in total).\\n\\nYou are given a sequence of n words consisting of letters 'a', 'b', 'c', 'd' and 'e'. Your task is to choose the maximum number of them to make an interesting story. If there's no way to make a non-empty story, output 0.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 5000) — the number of test cases. Then t test cases follow.\\n\\nThe first line of each test case contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of the words in the sequence. Then n lines follow, each of them contains a word — a non-empty string consisting of lowercase letters of the Latin alphabet. The words in the sequence may be non-distinct (i. e. duplicates are allowed). Only the letters 'a', 'b', 'c', 'd' and 'e' may occur in the words.\\n\\nIt is guaranteed that the sum of n over all test cases doesn't exceed 2 ⋅ 10^5; the sum of the lengths of all words over all test cases doesn't exceed 4 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, output the maximum number of words that compose an interesting story. Print 0 if there's no way to make a non-empty interesting story.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n3\\nbac\\naaada\\ne\\n3\\naba\\nabcde\\naba\\n2\\nbaba\\nbaba\\n4\\nab\\nab\\nc\\nbc\\n5\\ncbdca\\nd\\na\\nd\\ne\\n3\\nb\\nc\\nca\\n\\n\\nOutput\\n\\n\\n3\\n2\\n0\\n2\\n3\\n2\\n\\nNote\\n\\nIn the first test case of the example, all 3 words...\",\"targets\":\"import java.io.IOException;\\nimport java.io.InputStream;\\nimport java.io.OutputStream;\\nimport java.io.PrintWriter;\\nimport java.util.ArrayList;\\nimport java.util.Arrays;\\n\\n\\/**\\n * Built using CHelper plug-in\\n * Actual solution is at the top\\n *\\/\\npublic class Solution {\\n public static void main(String[] args) {\\n InputStream inputStream = System.in;\\n OutputStream outputStream = System.out;\\n InputReader in = new InputReader(inputStream);\\n PrintWriter out = new PrintWriter(outputStream);\\n Main solver = new Main();\\n boolean multipleTC = true;\\n int testCount = multipleTC ? Integer.parseInt(in.next()) : 1;\\n for (int i = 1; i <= testCount; i++)\\n solver.solve(in, out, i);\\n out.close();\\n }\\n static class Main {\\n PrintWriter out;\\n InputReader in;\\n\\n public void solve(InputReader in, PrintWriter out, int test) {\\n this.out = out;\\n this.in = in;\\n int n = ni();\\n String[] arr = new String[n];\\n int[][] freq = new int[n][5];\\n int[][] rem = new int[n][5];\\n for(int i = 0; i < n; i++){\\n arr[i] = n();\\n for(int j = 0; j < arr[i].length(); j++)\\n freq[i][arr[i].charAt(j) - 'a']++;\\n for(int j = 0; j < 5; j++)\\n rem[i][j] = arr[i].length() - freq[i][j];\\n }\\n int ans = 0;\\n for(int i = 0; i < 5; i++){\\n int[] vals = new int[n];\\n for(int j = 0; j < n; j++)\\n vals[j] = freq[j][i] - rem[j][i];\\n Arrays.sort(vals);\\n int sum = 0, x = 0;\\n for(int j = n - 1; j >= 0; j--){\\n if(sum + vals[j] > 0){\\n x++;\\n sum += vals[j];\\n } else {\\n break;\\n }\\n }\\n if(x > ans) {\\n ans = x;\\n }\\n }\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nYou are given an array a of length n.\\n\\nLet's define the eversion operation. Let x = a_n. Then array a is partitioned into two parts: left and right. The left part contains the elements of a that are not greater than x (≤ x). The right part contains the elements of a that are strictly greater than x (> x). The order of elements in each part is kept the same as before the operation, i. e. the partition is stable. Then the array is replaced with the concatenation of the left and the right parts.\\n\\nFor example, if the array a is [2, 4, 1, 5, 3], the eversion goes like this: [2, 4, 1, 5, 3] → [2, 1, 3], [4, 5] → [2, 1, 3, 4, 5].\\n\\nWe start with the array a and perform eversions on this array. We can prove that after several eversions the array a stops changing. Output the minimum number k such that the array stops changing after k eversions.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 100). Description of the test cases follows.\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 2 ⋅ 10^5).\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9).\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case print a single integer k — the number of eversions after which the array stops changing.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n5\\n2 4 1 5 3\\n5\\n5 3 2 4 1\\n4\\n1 1 1 1\\n\\n\\nOutput\\n\\n\\n1\\n2\\n0\\n\\nNote\\n\\nConsider the fist example.\\n\\n * The first eversion: a = [1, 4, 2, 5, 3], x = 3. [2, 4, 1, 5, 3] → [2, 1, 3], [4, 5] → [2, 1, 3, 4, 5]. \\n * The second and following eversions: a = [2, 1, 3, 4, 5], x = 5. [2, 1, 3, 4, 5] → [2, 1, 3, 4, 5], [] → [2, 1, 3, 4, 5]. This eversion does not change the array, so the answer is 1. \\n\\n\\n\\nConsider the second example. \\n\\n * The first eversion: a = [5, 3, 2, 4, 1], x = 1. [5, 3, 2, 4, 1] → [1], [5, 3, 2, 4] → [1, 5, 3, 2, 4]. \\n * The second eversion: a = [1, 5, 3, 2, 4], x = 4. [1, 5, 3, 2, 4] → [1, 3, 2, 4], [5] → [1, 3, 2, 4, 5]. \\n * The third and following eversions: a = [1, 3, 2, 4,...\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.util.*;\\n\\npublic class Final {\\n\\t\\n public static void main(String[] args) throws IOException {\\n FastScanner s=new FastScanner();\\n int total = s.nextInt();\\n while(total-->0){\\n \\tint n = s.nextInt();\\n \\tlong[] a = new long[n];\\n \\t\\n \\tfor(int i=0;i=0;i--) {\\n \\t\\tif(b[i] > max) {\\n \\t\\t\\tmax = Math.max(b[i],max);\\n \\t\\t\\td++;\\n \\t\\t}\\n \\t}\\n \\tSystem.out.println(d);\\n }\\n }\\n\\n static class FastScanner {\\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\\n StringTokenizer sttoken = new StringTokenizer(\\\"\\\");\\n\\n String next() {\\n while (!sttoken.hasMoreTokens())\\n try {\\n sttoken = new StringTokenizer(br.readLine());\\n } catch (IOException e) {\\n e.printStackTrace();\\n }\\n return sttoken.nextToken();\\n }\\n\\n int nextInt() {\\n return Integer.parseInt(next());\\n }\\n\\n int[] readArray(int n) {\\n int[] a = new int[n];\\n for (int i = 0; i < n; i++)\\n a[i] = nextInt();\\n return a;\\n }\\n long nextLong() {\\n return Long.parseLong(next());\\n }\\n } \\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nAs you could know there are no male planes nor female planes. However, each plane on Earth likes some other plane. There are n planes on Earth, numbered from 1 to n, and the plane with number i likes the plane with number fi, where 1 ≤ fi ≤ n and fi ≠ i.\\n\\nWe call a love triangle a situation in which plane A likes plane B, plane B likes plane C and plane C likes plane A. Find out if there is any love triangle on Earth.\\n\\nInput\\n\\nThe first line contains a single integer n (2 ≤ n ≤ 5000) — the number of planes.\\n\\nThe second line contains n integers f1, f2, ..., fn (1 ≤ fi ≤ n, fi ≠ i), meaning that the i-th plane likes the fi-th.\\n\\nOutput\\n\\nOutput «YES» if there is a love triangle consisting of planes on Earth. Otherwise, output «NO».\\n\\nYou can output any letter in lower case or in upper case.\\n\\nExamples\\n\\nInput\\n\\n5\\n2 4 5 1 3\\n\\n\\nOutput\\n\\nYES\\n\\n\\nInput\\n\\n5\\n5 5 5 5 1\\n\\n\\nOutput\\n\\nNO\\n\\nNote\\n\\nIn first example plane 2 likes plane 4, plane 4 likes plane 1, plane 1 likes plane 2 and that is a love triangle.\\n\\nIn second example there are no love triangles.\",\"targets\":\"#include \\nusing namespace std;\\nvector arr[5001], trans[5001], order;\\nbool vis[5001];\\nvoid dfs(int node) {\\n vis[node] = true;\\n for (int child : arr[node]) {\\n if (!vis[child]) {\\n dfs(child);\\n }\\n }\\n order.push_back(node);\\n}\\nint dfs1(int node) {\\n vis[node] = true;\\n int cnt = 1;\\n for (int child : trans[node]) {\\n if (!vis[child]) {\\n cnt += dfs1(child);\\n }\\n }\\n return cnt;\\n}\\nint main(int argc, char const *argv[]) {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n int n, d;\\n bool flag = true;\\n cin >> n;\\n for (int i = 1; i <= n; i++) {\\n cin >> d;\\n arr[i].push_back(d);\\n trans[d].push_back(i);\\n vis[i] = false;\\n }\\n for (int i = 1; i <= n; i++) {\\n if (!vis[i]) {\\n dfs(i);\\n }\\n }\\n for (int i = 1; i < n + 1; i++) {\\n vis[i] = false;\\n }\\n for (int i = order.size() - 1; i > -1; i--) {\\n if (!vis[order[i]]) {\\n if (dfs1(order[i]) == 3) {\\n cout << \\\"YES\\\";\\n flag = false;\\n break;\\n }\\n }\\n }\\n if (flag) {\\n cout << \\\"NO\\\";\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Anton likes to play chess, and so does his friend Danik.\\n\\nOnce they have played n games in a row. For each game it's known who was the winner — Anton or Danik. None of the games ended with a tie.\\n\\nNow Anton wonders, who won more games, he or Danik? Help him determine this.\\n\\nInput\\n\\nThe first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of games played.\\n\\nThe second line contains a string s, consisting of n uppercase English letters 'A' and 'D' — the outcome of each of the games. The i-th character of the string is equal to 'A' if the Anton won the i-th game and 'D' if Danik won the i-th game.\\n\\nOutput\\n\\nIf Anton won more games than Danik, print \\\"Anton\\\" (without quotes) in the only line of the output.\\n\\nIf Danik won more games than Anton, print \\\"Danik\\\" (without quotes) in the only line of the output.\\n\\nIf Anton and Danik won the same number of games, print \\\"Friendship\\\" (without quotes).\\n\\nExamples\\n\\nInput\\n\\n6\\nADAAAA\\n\\n\\nOutput\\n\\nAnton\\n\\n\\nInput\\n\\n7\\nDDDAADA\\n\\n\\nOutput\\n\\nDanik\\n\\n\\nInput\\n\\n6\\nDADADA\\n\\n\\nOutput\\n\\nFriendship\\n\\nNote\\n\\nIn the first sample, Anton won 6 games, while Danik — only 1. Hence, the answer is \\\"Anton\\\".\\n\\nIn the second sample, Anton won 3 games and Danik won 4 games, so the answer is \\\"Danik\\\".\\n\\nIn the third sample, both Anton and Danik won 3 games and the answer is \\\"Friendship\\\".\",\"targets\":\"n = int(input())\\ns = input()\\nif(s.count(\\\"A\\\") < s.count(\\\"D\\\")):\\n print(\\\"Danik\\\")\\nelif (s.count(\\\"A\\\") > s.count(\\\"D\\\")):\\n print(\\\"Anton\\\")\\nelse:\\n print(\\\"Friendship\\\")\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"As behooves any intelligent schoolboy, Kevin Sun is studying psycowlogy, cowculus, and cryptcowgraphy at the Bovinia State University (BGU) under Farmer Ivan. During his Mathematics of Olympiads (MoO) class, Kevin was confronted with a weird functional equation and needs your help. For two fixed integers k and p, where p is an odd prime number, the functional equation states that \\n\\n\\n\\nfor some function . (This equation should hold for any integer x in the range 0 to p - 1, inclusive.)\\n\\nIt turns out that f can actually be many different functions. Instead of finding a solution, Kevin wants you to count the number of distinct functions f that satisfy this equation. Since the answer may be very large, you should print your result modulo 109 + 7.\\n\\nInput\\n\\nThe input consists of two space-separated integers p and k (3 ≤ p ≤ 1 000 000, 0 ≤ k ≤ p - 1) on a single line. It is guaranteed that p is an odd prime number.\\n\\nOutput\\n\\nPrint a single integer, the number of distinct functions f modulo 109 + 7.\\n\\nExamples\\n\\nInput\\n\\n3 2\\n\\n\\nOutput\\n\\n3\\n\\n\\nInput\\n\\n5 4\\n\\n\\nOutput\\n\\n25\\n\\nNote\\n\\nIn the first sample, p = 3 and k = 2. The following functions work: \\n\\n 1. f(0) = 0, f(1) = 1, f(2) = 2. \\n 2. f(0) = 0, f(1) = 2, f(2) = 1. \\n 3. f(0) = f(1) = f(2) = 0.\",\"targets\":\"import java.util.*;\\n\\/*\\n\\n *\\/\\nimport java.io.*;\\npublic class d \\n{\\n\\tpublic static void main(String[] arg)\\n\\t{\\n\\t\\tnew d();\\n\\t}\\n\\tint p, k;\\n\\tlong MOD = 1_000_000_007;\\n\\tboolean[] used;\\n\\tpublic d()\\n\\t{\\n\\t\\tFastScanner in = new FastScanner(System.in);\\n\\t\\tPrintWriter out = new PrintWriter(System.out);\\n\\t\\tp = in.nextInt();\\n\\t\\tk = in.nextInt();\\n\\t\\tif(k == 0)\\n\\t\\t{\\n\\t\\t\\tout.println(pow(p, p-1));\\n\\t\\t}\\n\\t\\telse if(k == 1)\\n\\t\\t{\\n\\t\\t\\tout.println(pow(p, p));\\n\\t\\t}\\n\\t\\telse\\n\\t\\t{\\n\\t\\t\\tused = new boolean[p];\\n\\t\\t\\tlong ret = 0;\\n\\t\\t\\tfor(int i = 0; i < p; i++)\\n\\t\\t\\t{\\n\\t\\t\\t\\tif(used[i]) continue;\\n\\t\\t\\t\\tcycle(i);\\n\\t\\t\\t\\tret++; \\n\\t\\t\\t}\\n\\t\\t\\tout.println(pow(p, ret-1));\\n\\t\\t}\\n\\t\\tin.close(); out.close();\\n\\t}\\n\\tvoid cycle(int num)\\n\\t{\\n\\t\\tif(used[num]) return;\\n\\t\\tused[num] = true;\\n\\t\\tcycle((int)((long)num*k%p));\\n\\t}\\n\\tlong pow(long base, long exp)\\n\\t{\\n\\t\\tif(exp == 0) return 1;\\n\\t\\tif((base&1) == 1) return base * pow(base, exp-1)%MOD;\\n\\t\\telse\\n\\t\\t{\\n\\t\\t\\tlong ret = pow(base, exp\\/2);\\n\\t\\t\\treturn ret*ret%MOD;\\n\\t\\t}\\n\\t}\\n\\tclass FastScanner \\n\\t{\\n\\t\\tfinal BufferedReader reader;\\n\\t\\tString line;\\n\\t\\tint index;\\n\\t\\tpublic FastScanner(InputStream in)\\n\\t\\t{\\n\\t\\t\\treader = new BufferedReader(new InputStreamReader(in));\\n\\t\\t}\\n\\t\\tpublic FastScanner(File f) throws FileNotFoundException\\n\\t\\t{\\n\\t\\t\\treader = new BufferedReader(new FileReader(f));\\n\\t\\t}\\n\\t\\tpublic String readLine()\\n\\t\\t{\\n\\t\\t\\ttry\\n\\t\\t\\t{\\n\\t\\t\\t\\tString line = reader.readLine();\\n\\t\\t\\t\\tif(line == null) throw new IOException(\\\"End of stream\\\");\\n\\t\\t\\t\\treturn line;\\n\\t\\t\\t}\\n\\t\\t\\tcatch(IOException exception)\\n\\t\\t\\t{\\n\\t\\t\\t\\tthrow new RuntimeException(exception);\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\tpublic String nextLine()\\n\\t\\t{\\n\\t\\t\\tif(line==null) return readLine();\\n\\t\\t\\tString s = line;\\n\\t\\t\\tline = null;\\n\\t\\t\\treturn s.substring(index);\\n\\t\\t}\\n\\t\\tpublic String next()\\n\\t\\t{\\n\\t\\t\\tif(line == null)\\n\\t\\t\\t{\\n\\t\\t\\t\\tline = readLine();\\n\\t\\t\\t\\tindex = 0;\\n\\t\\t\\t}\\n\\t\\t\\twhile(index >= line.length())\\n\\t\\t\\t{\\n\\t\\t\\t\\tline = readLine();\\n\\t\\t\\t\\tindex = 0;\\n\\t\\t\\t}\\n\\t\\t\\twhile(Character.isWhitespace(line.charAt(index)))\\n\\t\\t\\t{\\n\\t\\t\\t\\tindex++;\\n\\t\\t\\t\\twhile(index >= line.length())\\n\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\tline = readLine();\\n\\t\\t\\t\\t\\tindex = 0;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\tint endIndex = index;\\n\\t\\t\\twhile(endIndex < line.length() &&...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Apart from plush toys, Imp is a huge fan of little yellow birds!\\n\\n\\n\\nTo summon birds, Imp needs strong magic. There are n trees in a row on an alley in a park, there is a nest on each of the trees. In the i-th nest there are ci birds; to summon one bird from this nest Imp needs to stay under this tree and it costs him costi points of mana. However, for each bird summoned, Imp increases his mana capacity by B points. Imp summons birds one by one, he can summon any number from 0 to ci birds from the i-th nest. \\n\\nInitially Imp stands under the first tree and has W points of mana, and his mana capacity equals W as well. He can only go forward, and each time he moves from a tree to the next one, he restores X points of mana (but it can't exceed his current mana capacity). Moving only forward, what is the maximum number of birds Imp can summon?\\n\\nInput\\n\\nThe first line contains four integers n, W, B, X (1 ≤ n ≤ 103, 0 ≤ W, B, X ≤ 109) — the number of trees, the initial points of mana, the number of points the mana capacity increases after a bird is summoned, and the number of points restored when Imp moves from a tree to the next one.\\n\\nThe second line contains n integers c1, c2, ..., cn (0 ≤ ci ≤ 104) — where ci is the number of birds living in the i-th nest. It is guaranteed that .\\n\\nThe third line contains n integers cost1, cost2, ..., costn (0 ≤ costi ≤ 109), where costi is the mana cost to summon a bird from the i-th nest.\\n\\nOutput\\n\\nPrint a single integer — the maximum number of birds Imp can summon.\\n\\nExamples\\n\\nInput\\n\\n2 12 0 4\\n3 4\\n4 2\\n\\n\\nOutput\\n\\n6\\n\\n\\nInput\\n\\n4 1000 10 35\\n1 2 4 5\\n1000 500 250 200\\n\\n\\nOutput\\n\\n5\\n\\n\\nInput\\n\\n2 10 7 11\\n2 10\\n6 1\\n\\n\\nOutput\\n\\n11\\n\\nNote\\n\\nIn the first sample base amount of Imp's mana is equal to 12 (with maximum capacity also equal to 12). After he summons two birds from the first nest, he loses 8 mana points, although his maximum capacity will not increase (since B = 0). After this step his mana will be 4 of 12; during the move you will replenish 4 mana points, and hence own 8 mana out of...\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint w, b, x;\\nlong long from_to(int k, int j, int cost, vector &d) {\\n return min(d[k] + x, 1ll * w + 1ll * k * b) - 1ll * cost * (j - k);\\n}\\nint main() {\\n int n, cmax = 0;\\n cin >> n >> w >> b >> x;\\n vector c(n), cost(n);\\n for (int i = 0; i < n; ++i) {\\n cin >> c[i];\\n cmax += c[i];\\n }\\n for (int i = 0; i < n; ++i) {\\n cin >> cost[i];\\n }\\n vector> dp(2, vector(cmax + 1, -1));\\n for (int i = 0; i <= c[0]; ++i) {\\n dp[0][i] = w - 1ll * i * cost[0];\\n if (dp[0][i] < 0) dp[0][i] = -1;\\n }\\n for (int i = 1; i < n; ++i) {\\n int i1 = (i - 1) % 2;\\n int i2 = i % 2;\\n dp[i2][0] = w;\\n deque dq;\\n dq.push_back(0);\\n for (int j = 1; j <= cmax; ++j) {\\n while (!dq.empty() && dq.front() < j - c[i]) {\\n dq.pop_front();\\n }\\n if (dp[i1][j] != -1) {\\n while (!dq.empty() && from_to(dq.back(), j, cost[i], dp[i1]) <\\n from_to(j, j, cost[i], dp[i1])) {\\n dq.pop_back();\\n }\\n dq.push_back(j);\\n }\\n dp[i2][j] = -1;\\n if (!dq.empty()) {\\n dp[i2][j] = max(from_to(dq.front(), j, cost[i], dp[i1]), -1ll);\\n }\\n }\\n }\\n int i1 = (n - 1) % 2;\\n for (int i = cmax; i >= 0; --i) {\\n if (dp[i1][i] != -1) {\\n cout << i << \\\"\\\\n\\\";\\n break;\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given two positive integers n and s. Find the maximum possible median of an array of n non-negative integers (not necessarily distinct), such that the sum of its elements is equal to s.\\n\\nA median of an array of integers of length m is the number standing on the ⌈ {m\\/2} ⌉-th (rounding up) position in the non-decreasing ordering of its elements. Positions are numbered starting from 1. For example, a median of the array [20,40,20,50,50,30] is the ⌈ m\\/2 ⌉-th element of [20,20,30,40,50,50], so it is 30. There exist other definitions of the median, but in this problem we use the described definition.\\n\\nInput\\n\\nThe input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. Description of the test cases follows.\\n\\nEach test case contains a single line with two integers n and s (1 ≤ n, s ≤ 10^9) — the length of the array and the required sum of the elements.\\n\\nOutput\\n\\nFor each test case print a single integer — the maximum possible median.\\n\\nExample\\n\\nInput\\n\\n\\n8\\n1 5\\n2 5\\n3 5\\n2 1\\n7 17\\n4 14\\n1 1000000000\\n1000000000 1\\n\\n\\nOutput\\n\\n\\n5\\n2\\n2\\n0\\n4\\n4\\n1000000000\\n0\\n\\nNote\\n\\nPossible arrays for the first three test cases (in each array the median is underlined):\\n\\n * In the first test case [\\\\underline{5}] \\n * In the second test case [\\\\underline{2}, 3] \\n * In the third test case [1, \\\\underline{2}, 2] \\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\n#pragma GCC optimize(\\\"-O3\\\")\\nusing namespace std;\\nlong long mod = 1000000007;\\ninline long long add(long long a, long long b) {\\n return ((a % mod) + (b % mod) + mod) % mod;\\n}\\ninline long long mul(long long a, long long b) {\\n return (((a % mod) * (b % mod)) % mod + mod) % mod;\\n}\\ninline long long sub(long long a, long long b) {\\n return ((a % mod) - (b % mod) + mod) % mod;\\n}\\nint N = 2e5 + 5;\\nint GCD(int a, int b) {\\n if (b == 0) return a;\\n return GCD(b, a % b);\\n}\\nint prod(int a, int b) {\\n int res = 0;\\n a %= mod;\\n while (b) {\\n if (b & 1ll) res = (res + a) % mod;\\n a = (2ll * a) % mod;\\n b >>= 1ll;\\n }\\n return res;\\n}\\nint power(int a, int b) {\\n int res = 1ll;\\n while (b > 0) {\\n if (b % 2ll) res = (res * a) % mod;\\n a = (a * a) % mod;\\n b \\/= 2ll;\\n }\\n return res;\\n}\\nlong long binaryExponentiation(long long a, long long b) {\\n long long result = 1ll;\\n while (b > 0) {\\n if (b % 2 == 1) result = (result * a) % mod;\\n a = (a * a) % mod;\\n b \\/= 2ll;\\n }\\n return result;\\n}\\nlong long ModularInverse(long long a) {\\n return binaryExponentiation(a, mod - 2);\\n}\\nint fact(int n) {\\n int res = 1;\\n for (int i = 2; i <= n; i++) {\\n res = (res * i) % mod;\\n }\\n return res % mod;\\n}\\nint gcd(int a, int b) {\\n if (b == 0) return a;\\n return gcd(b, a % b);\\n}\\nbool isprime(int x) {\\n for (int i = 2; i * i <= x; i++) {\\n if (x % i == 0) return false;\\n }\\n return true;\\n}\\nint isPrime(int n) {\\n if (n < 2) return 0;\\n if (n < 4) return 1;\\n if (n % 2 == 0 or n % 3 == 0) return 0;\\n for (int i = 5; i * i <= n; i += 6)\\n if (n % i == 0 or n % (i + 2) == 0) return 0;\\n return 1;\\n}\\nvoid solve() {\\n long long n, s;\\n cin >> n >> s;\\n if (n == 1 && s == 1) {\\n cout << 1 << \\\"\\\\n\\\";\\n return;\\n } else if (n == 1) {\\n cout << s << \\\"\\\\n\\\";\\n return;\\n } else if (s == 1) {\\n cout << 0 << \\\"\\\\n\\\";\\n return;\\n } else {\\n int medind;\\n if (n % 2 != 0)\\n medind = (n \\/ 2) + 1;\\n else\\n medind = n \\/ 2;\\n int len = n - medind + 1;\\n if (s >= len) {\\n cout << (s \\/ len) <<...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given an array a of n integers, and another integer k such that 2k ≤ n.\\n\\nYou have to perform exactly k operations with this array. In one operation, you have to choose two elements of the array (let them be a_i and a_j; they can be equal or different, but their positions in the array must not be the same), remove them from the array, and add ⌊ (a_i)\\/(a_j) ⌋ to your score, where ⌊ x\\/y ⌋ is the maximum integer not exceeding x\\/y.\\n\\nInitially, your score is 0. After you perform exactly k operations, you add all the remaining elements of the array to the score.\\n\\nCalculate the minimum possible score you can get.\\n\\nInput\\n\\nThe first line of the input contains one integer t (1 ≤ t ≤ 500) — the number of test cases.\\n\\nEach test case consists of two lines. The first line contains two integers n and k (1 ≤ n ≤ 100; 0 ≤ k ≤ ⌊ n\\/2 ⌋).\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 2 ⋅ 10^5).\\n\\nOutput\\n\\nPrint one integer — the minimum possible score you can get.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n7 3\\n1 1 1 2 1 3 1\\n5 1\\n5 5 5 5 5\\n4 2\\n1 3 3 7\\n2 0\\n4 2\\n9 2\\n1 10 10 1 10 2 7 10 3\\n\\n\\nOutput\\n\\n\\n2\\n16\\n0\\n6\\n16\\n\\nNote\\n\\nLet's consider the example test.\\n\\nIn the first test case, one way to obtain a score of 2 is the following one:\\n\\n 1. choose a_7 = 1 and a_4 = 2 for the operation; the score becomes 0 + ⌊ 1\\/2 ⌋ = 0, the array becomes [1, 1, 1, 1, 3]; \\n 2. choose a_1 = 1 and a_5 = 3 for the operation; the score becomes 0 + ⌊ 1\\/3 ⌋ = 0, the array becomes [1, 1, 1]; \\n 3. choose a_1 = 1 and a_2 = 1 for the operation; the score becomes 0 + ⌊ 1\\/1 ⌋ = 1, the array becomes [1]; \\n 4. add the remaining element 1 to the score, so the resulting score is 2. \\n\\n\\n\\nIn the second test case, no matter which operations you choose, the resulting score is 16.\\n\\nIn the third test case, one way to obtain a score of 0 is the following one:\\n\\n 1. choose a_1 = 1 and a_2 = 3 for the operation; the score becomes 0 + ⌊ 1\\/3 ⌋ = 0, the array becomes [3, 7]; \\n 2. choose a_1 = 3 and a_2 = 7 for the operation; the score becomes 0 + ⌊ 3\\/7 ⌋ = 0, the array becomes...\\nSolve the task in JAVA.\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\n\\npublic class Main {\\n static BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));\\n static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));\\n static int mod = (int)1e9+7;\\n static boolean[] isprime=new boolean[1];\\n static {\\n for(int i=2;i 0) {\\n int b[] = new int[2];\\n getA(b);\\n int n = b[0], k = b[1];\\n int a[] = new int[n];\\n getA(a);\\n int ans = 0;\\n Arrays.sort(a);\\n int kk = k;\\n for(int i = n-1;i >= 0;i--){\\n if(kk == 0) break;\\n int j = i-k;\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"Polycarp must pay exactly n burles at the checkout. He has coins of two nominal values: 1 burle and 2 burles. Polycarp likes both kinds of coins equally. So he doesn't want to pay with more coins of one type than with the other.\\n\\nThus, Polycarp wants to minimize the difference between the count of coins of 1 burle and 2 burles being used. Help him by determining two non-negative integer values c_1 and c_2 which are the number of coins of 1 burle and 2 burles, respectively, so that the total value of that number of coins is exactly n (i. e. c_1 + 2 ⋅ c_2 = n), and the absolute value of the difference between c_1 and c_2 is as little as possible (i. e. you must minimize |c_1-c_2|).\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10^4) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one line. This line contains one integer n (1 ≤ n ≤ 10^9) — the number of burles to be paid by Polycarp.\\n\\nOutput\\n\\nFor each test case, output a separate line containing two integers c_1 and c_2 (c_1, c_2 ≥ 0) separated by a space where c_1 is the number of coins of 1 burle and c_2 is the number of coins of 2 burles. If there are multiple optimal solutions, print any one.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n1000\\n30\\n1\\n32\\n1000000000\\n5\\n\\n\\nOutput\\n\\n\\n334 333\\n10 10\\n1 0\\n10 11\\n333333334 333333333\\n1 2\\n\\nNote\\n\\nThe answer for the first test case is \\\"334 333\\\". The sum of the nominal values of all coins is 334 ⋅ 1 + 333 ⋅ 2 = 1000, whereas |334 - 333| = 1. One can't get the better value because if |c_1 - c_2| = 0, then c_1 = c_2 and c_1 ⋅ 1 + c_1 ⋅ 2 = 1000, but then the value of c_1 isn't an integer.\\n\\nThe answer for the second test case is \\\"10 10\\\". The sum of the nominal values is 10 ⋅ 1 + 10 ⋅ 2 = 30 and |10 - 10| = 0, whereas there's no number having an absolute value less than 0.\\\":\",\"targets\":\"import java.util.Scanner;\\n\\npublic class Main {\\n\\n\\tpublic static void main(String[] args) {\\n\\t\\tScanner s=new Scanner(System.in);\\n\\t\\tint t=s.nextInt();\\n\\t\\tfor(int i=1;i<=t;i++) {\\n\\t\\t\\tint x=s.nextInt();\\n\\t\\t\\tint xx=x\\/3;\\n\\t\\t\\tif(x%3==0) {\\n\\t\\t\\t\\tSystem.out.println(xx+\\\" \\\"+xx);\\n\\t\\t\\t}\\n\\t\\t\\telse if((xx+1)+(2*xx)==x) {\\n\\t\\t\\t\\tSystem.out.println((xx+1)+\\\" \\\"+xx);\\n\\t\\t\\t}\\n\\t\\t\\telse if((xx+2*(xx+1))==x){\\n\\t\\t\\t\\tSystem.out.println(xx+\\\" \\\"+(xx+1));\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nIahub and Sorin are the best competitive programmers in their town. However, they can't both qualify to an important contest. The selection will be made with the help of a single problem. Blatnatalag, a friend of Iahub, managed to get hold of the problem before the contest. Because he wants to make sure Iahub will be the one qualified, he tells Iahub the following task.\\n\\nYou're given an (1-based) array a with n elements. Let's define function f(i, j) (1 ≤ i, j ≤ n) as (i - j)2 + g(i, j)2. Function g is calculated by the following pseudo-code:\\n \\n \\n \\n int g(int i, int j) { \\n int sum = 0; \\n for (int k = min(i, j) + 1; k <= max(i, j); k = k + 1) \\n sum = sum + a[k]; \\n return sum; \\n } \\n \\n\\nFind a value mini ≠ j f(i, j).\\n\\nProbably by now Iahub already figured out the solution to this problem. Can you?\\n\\nInput\\n\\nThe first line of input contains a single integer n (2 ≤ n ≤ 100000). Next line contains n integers a[1], a[2], ..., a[n] ( - 104 ≤ a[i] ≤ 104). \\n\\nOutput\\n\\nOutput a single integer — the value of mini ≠ j f(i, j).\\n\\nExamples\\n\\nInput\\n\\n4\\n1 0 0 -1\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\n2\\n1 -1\\n\\n\\nOutput\\n\\n2\",\"targets\":\"#include \\nusing namespace std;\\nlong long n, m, k = 0, tempt[100010], sum[100010];\\nstruct Point {\\n long long x, y;\\n} point[100010];\\ninline bool cmpxy(const Point& a, Point& b) {\\n return a.x == b.x ? a.x < b.x : a.y < b.y;\\n}\\ninline bool cmpy(const long long& a, const long long& b) {\\n return point[a].y < point[b].y;\\n}\\ninline long long cal(long long x) { return x * x; }\\ninline long long dis(long long a, long long b) {\\n return cal(point[a].x - point[b].x) + cal(point[a].y - point[b].y);\\n}\\ninline long long Closest_Pair(long long l, long long r) {\\n long long d = 0x3f3f3f3f;\\n if (l == r) return d;\\n if (l + 1 == r) return dis(l, r);\\n long long mid = l + r >> 1;\\n long long d1 = Closest_Pair(l, mid);\\n long long d2 = Closest_Pair(mid + 1, r);\\n d = min(d1, d2), k = 0;\\n for (long long i = l; i <= r; i++)\\n if (cal(point[mid].x - point[i].x) <= d) tempt[++k] = i;\\n sort(tempt + 1, tempt + k + 1, cmpy);\\n for (long long i = 1; i <= k; i++)\\n for (long long j = i + 1;\\n j <= k && cal(point[tempt[j]].y - point[tempt[i]].y) <= d; j++)\\n d = min(d, dis(tempt[i], tempt[j]));\\n return d;\\n}\\nsigned main() {\\n scanf(\\\"%lld\\\", &n);\\n for (long long i = 1; i <= n; i++) {\\n long long x;\\n scanf(\\\"%lld\\\", &x);\\n sum[i] = sum[i - 1] + x;\\n point[i] = (Point){i, sum[i]};\\n }\\n sort(point + 1, point + n + 1, cmpxy);\\n printf(\\\"%lld\\\", Closest_Pair(1, n));\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given three integers n, a, b. Determine if there exists a permutation p_1, p_2, …, p_n of integers from 1 to n, such that:\\n\\n * There are exactly a integers i with 2 ≤ i ≤ n-1 such that p_{i-1} < p_i > p_{i+1} (in other words, there are exactly a local maximums).\\n\\n * There are exactly b integers i with 2 ≤ i ≤ n-1 such that p_{i-1} > p_i < p_{i+1} (in other words, there are exactly b local minimums).\\n\\n\\n\\n\\nIf such permutations exist, find any such permutation.\\n\\nInput\\n\\nThe first line of the input contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. The description of test cases follows.\\n\\nThe only line of each test case contains three integers n, a and b (2 ≤ n ≤ 10^5, 0 ≤ a,b ≤ n).\\n\\nThe sum of n over all test cases doesn't exceed 10^5.\\n\\nOutput\\n\\nFor each test case, if there is no permutation with the requested properties, output -1.\\n\\nOtherwise, print the permutation that you are found. If there are several such permutations, you may print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n4 1 1\\n6 1 2\\n6 4 0\\n\\n\\nOutput\\n\\n\\n1 3 2 4\\n4 2 3 1 5 6\\n-1\\n\\nNote\\n\\nIn the first test case, one example of such permutations is [1, 3, 2, 4]. In it p_1 < p_2 > p_3, and 2 is the only such index, and p_2> p_3 < p_4, and 3 the only such index.\\n\\nOne can show that there is no such permutation for the third test case.\\nUsing python3 can you solve the prior task?\",\"targets\":\"def buildPermutation(n,a,b):\\n array = [x for x in range(1,n+1)]\\n if abs(a-b) >1:\\n return [-1]\\n if a==b:\\n if (n-2)\\/\\/2 < a:\\n return [-1]\\n for x in range(a):\\n array[2*(x+1)-1],array[(2*(x+1))] = array[(2*(x+1))],array[2*(x+1)-1]\\n return array\\n\\n\\n\\n\\n else:\\n if (n-3)\\/\\/2 < min(a,b):\\n return [-1]\\n if a > b:\\n array[0],array[1] = array[1],array[0]\\n a-=1\\n for x in range(a):\\n array[2 * (x + 1)], array[(2 * (x + 1)) + 1] = array[(2 * (x + 1)) + 1], array[2 * (x + 1)]\\n else:\\n array[-1],array[-2] = array[-2],array[-1]\\n b-=1\\n\\n for x in range(b):\\n array[2*(x+1)-1],array[(2*(x+1))] = array[(2*(x+1))],array[2*(x+1)-1]\\n\\n\\n return array\\n\\n\\n\\nt = int(input())\\nfor _ in range(t):\\n n,a,b = map(int,input().split())\\n ans = buildPermutation(n,b,a)\\n for x in ans:\\n print(x,end=\\\" \\\")\\n print()\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"There are n candles on a Hanukkah menorah, and some of its candles are initially lit. We can describe which candles are lit with a binary string s, where the i-th candle is lit if and only if s_i=1.\\n\\n\\n\\nInitially, the candle lights are described by a string a. In an operation, you select a candle that is currently lit. By doing so, the candle you selected will remain lit, and every other candle will change (if it was lit, it will become unlit and if it was unlit, it will become lit).\\n\\nYou would like to make the candles look the same as string b. Your task is to determine if it is possible, and if it is, find the minimum number of operations required.\\n\\nInput\\n\\nThe first line contains an integer t (1≤ t≤ 10^4) — the number of test cases. Then t cases follow.\\n\\nThe first line of each test case contains a single integer n (1≤ n≤ 10^5) — the number of candles.\\n\\nThe second line contains a string a of length n consisting of symbols 0 and 1 — the initial pattern of lights.\\n\\nThe third line contains a string b of length n consisting of symbols 0 and 1 — the desired pattern of lights.\\n\\nIt is guaranteed that the sum of n does not exceed 10^5.\\n\\nOutput\\n\\nFor each test case, output the minimum number of operations required to transform a to b, or -1 if it's impossible.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n5\\n11010\\n11010\\n2\\n01\\n11\\n3\\n000\\n101\\n9\\n100010111\\n101101100\\n9\\n001011011\\n011010101\\n\\n\\nOutput\\n\\n\\n0\\n1\\n-1\\n3\\n4\\n\\nNote\\n\\nIn the first test case, the two strings are already equal, so we don't have to perform any operations.\\n\\nIn the second test case, we can perform a single operation selecting the second candle to transform 01 into 11.\\n\\nIn the third test case, it's impossible to perform any operations because there are no lit candles to select.\\n\\nIn the fourth test case, we can perform the following operations to transform a into b: \\n\\n 1. Select the 7-th candle: 100010{\\\\color{red}1}11→ 011101{\\\\color{red} 1}00. \\n 2. Select the 2-nd candle: 0{\\\\color{red} 1}1101100→ 1{\\\\color{red} 1}0010011. \\n 3. Select the 1-st candle: {\\\\color{red}1}10010011→...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nconst double pi = acos(-1.0);\\nconst int inf = 1e9 + 1, mod = 1e9 + 7;\\nvoid solve() {\\n int n, ans = 0, match = 0, unmatch = 0, signa = 0, signb = 0;\\n string stra, strb;\\n cin >> n >> stra >> strb;\\n if (stra == strb) {\\n cout << \\\"0\\\"\\n << \\\"\\\\n\\\";\\n return;\\n }\\n auto check = [&](string a, string b) {\\n int count01 = 0, count10 = 0;\\n for (int i = 0; i < n; i++) {\\n if (a[i] == '1' && b[i] == '0') count10++;\\n if (a[i] == '0' && b[i] == '1') count01++;\\n }\\n if (count01 != count10) return inf;\\n return count01 + count10;\\n };\\n auto change = [&](string a, string b, char ch) {\\n int index = -1;\\n for (int i = 0; i < n; i++) {\\n if (a[i] == '1' && b[i] == ch) {\\n index = i;\\n break;\\n }\\n }\\n if (index == -1) return inf;\\n for (int i = 0; i < n; i++) {\\n if (i == index) continue;\\n a[i] = (a[i] == '1') ? '0' : '1';\\n }\\n return check(a, b);\\n };\\n ans = check(stra, strb);\\n ans = min(ans, 1 + change(stra, strb, '1'));\\n ans = min(ans, 1 + change(stra, strb, '0'));\\n ans = (ans == inf) ? -1 : ans;\\n cout << ans << \\\"\\\\n\\\";\\n}\\nvoid fast() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n}\\nint32_t main() {\\n fast();\\n int t = 1;\\n cin >> t;\\n while (t--) solve();\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"This is the hard version of the problem. The difference between the versions is that the hard version does require you to output the numbers of the rods to be removed. You can make hacks only if all versions of the problem are solved.\\n\\nStitch likes experimenting with different machines with his friend Sparky. Today they built another machine.\\n\\nThe main element of this machine are n rods arranged along one straight line and numbered from 1 to n inclusive. Each of these rods must carry an electric charge quantitatively equal to either 1 or -1 (otherwise the machine will not work). Another condition for this machine to work is that the sign-variable sum of the charge on all rods must be zero.\\n\\nMore formally, the rods can be represented as an array of n numbers characterizing the charge: either 1 or -1. Then the condition must hold: a_1 - a_2 + a_3 - a_4 + … = 0, or ∑_{i=1}^n (-1)^{i-1} ⋅ a_i = 0.\\n\\nSparky charged all n rods with an electric current, but unfortunately it happened that the rods were not charged correctly (the sign-variable sum of the charge is not zero). The friends decided to leave only some of the rods in the machine. Sparky has q questions. In the ith question Sparky asks: if the machine consisted only of rods with numbers l_i to r_i inclusive, what minimal number of rods could be removed from the machine so that the sign-variable sum of charges on the remaining ones would be zero? Also Sparky wants to know the numbers of these rods. Perhaps the friends got something wrong, and the sign-variable sum is already zero. In that case, you don't have to remove the rods at all.\\n\\nIf the number of rods is zero, we will assume that the sign-variable sum of charges is zero, that is, we can always remove all rods.\\n\\nHelp your friends and answer all of Sparky's questions!\\n\\nInput\\n\\nEach test contains multiple test cases.\\n\\nThe first line contains one positive integer t (1 ≤ t ≤ 10^3), denoting the number of test cases. Description of the test cases follows.\\n\\nThe first line of each test case contains two positive...\\nUsing python3 can you solve the prior task?\",\"targets\":\"from collections import defaultdict\\nimport bisect\\nimport sys\\ninput = sys.stdin.readline\\n\\nt = int(input())\\nfor _ in range(t):\\n n, q = map(int, input().split())\\n s = list(input().rstrip())\\n x = [0]\\n for i in range(n):\\n if i % 2:\\n if s[i] == \\\"+\\\":\\n x.append(x[-1] + 1)\\n else:\\n x.append(x[-1] - 1)\\n else:\\n if s[i] == \\\"-\\\":\\n x.append(x[-1] + 1)\\n else:\\n x.append(x[-1] - 1)\\n d = defaultdict(lambda : [])\\n x0 = [x[i] + x[i + 1] for i in range(n)]\\n for i in range(n):\\n d[x[i] + x[i + 1]].append(i + 1)\\n for _ in range(q):\\n l, r = map(int, input().split())\\n c = x[r] - x[l - 1]\\n d0 = r - l + 1\\n if d0 % 2:\\n k = 1\\n else:\\n k = 0 if c == 0 else 2\\n ans = []\\n print(k)\\n if k == 1:\\n y = x[r] + x[l - 1]\\n ans.append(d[y][bisect.bisect_left(d[y], l - 0.5)])\\n if k == 2:\\n ans.append(l)\\n y = x[r] + x[l]\\n ans.append(d[y][bisect.bisect_left(d[y], l + 0.5)])\\n if k:\\n print(*ans)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given a rooted tree consisting of n vertices numbered from 1 to n. The root of the tree is the vertex 1.\\n\\nYou have to color all vertices of the tree into n colors (also numbered from 1 to n) so that there is exactly one vertex for each color. Let c_i be the color of vertex i, and p_i be the parent of vertex i in the rooted tree. The coloring is considered beautiful if there is no vertex k (k > 1) such that c_k = c_{p_k} - 1, i. e. no vertex such that its color is less than the color of its parent by exactly 1.\\n\\nCalculate the number of beautiful colorings, and print it modulo 998244353.\\n\\nInput\\n\\nThe first line contains one integer n (2 ≤ n ≤ 250000) — the number of vertices in the tree.\\n\\nThen n-1 lines follow, the i-th line contains two integers x_i and y_i (1 ≤ x_i, y_i ≤ n; x_i ≠ y_i) denoting an edge between the vertex x_i and the vertex y_i. These edges form a tree.\\n\\nOutput\\n\\nPrint one integer — the number of beautiful colorings, taken modulo 998244353.\\n\\nExamples\\n\\nInput\\n\\n\\n5\\n1 2\\n3 2\\n4 2\\n2 5\\n\\n\\nOutput\\n\\n\\n42\\n\\n\\nInput\\n\\n\\n5\\n1 2\\n2 3\\n3 4\\n4 5\\n\\n\\nOutput\\n\\n\\n53\\n\\n\\nInput\\n\\n\\n20\\n20 19\\n20 4\\n12 4\\n5 8\\n1 2\\n20 7\\n3 10\\n7 18\\n11 8\\n9 10\\n17 10\\n1 15\\n11 16\\n14 11\\n18 10\\n10 1\\n14 2\\n13 17\\n20 6\\n\\n\\nOutput\\n\\n\\n955085064\",\"targets\":\"#include \\nusing namespace std;\\ntemplate \\nostream& operator<<(ostream& ostream, pair& p) {\\n cout << p.first << \\\" \\\" << p.second;\\n return ostream;\\n}\\ntemplate \\nostream& operator<<(ostream& ostream, vector& v) {\\n for (auto& element : v) {\\n cout << element << \\\" \\\";\\n }\\n return ostream;\\n}\\ntemplate \\nostream& operator<<(ostream& ostream, vector>& v) {\\n for (auto& row : v) {\\n for (auto& cell : row) {\\n cout << cell << \\\" \\\";\\n }\\n cout << \\\"\\\\n\\\";\\n }\\n return ostream;\\n}\\ntemplate \\nistream& operator>>(istream& istream, pair& p) {\\n cin >> p.first >> p.second;\\n return istream;\\n}\\ntemplate \\nistream& operator>>(istream& istream, vector& v) {\\n for (auto& element : v) {\\n cin >> element;\\n }\\n return istream;\\n}\\nconstexpr int mod = 998244353;\\nconst long long infinity = 1000000000000000000;\\nconst int inf = 1e9 + 5;\\nconst long long root = 62;\\nlong long modpow(long long b, long long e) {\\n long long ans = 1;\\n for (; e; b = b * b % mod, e \\/= 2)\\n if (e & 1) ans = ans * b % mod;\\n return ans;\\n}\\nvoid ntt(vector& a) {\\n int n = (int)(a).size(), L = 31 - __builtin_clz(n);\\n static vector rt(2, 1);\\n for (static int k = 2, s = 2; k < n; k *= 2, s++) {\\n rt.resize(n);\\n long long z[] = {1, modpow(root, mod >> s)};\\n for (int i = k; i < (2 * k); ++i) rt[i] = rt[i \\/ 2] * z[i & 1] % mod;\\n }\\n vector rev(n);\\n for (int i = 0; i < (n); ++i) rev[i] = (rev[i \\/ 2] | (i & 1) << L) \\/ 2;\\n for (int i = 0; i < (n); ++i)\\n if (i < rev[i]) swap(a[i], a[rev[i]]);\\n for (int k = 1; k < n; k *= 2)\\n for (int i = 0; i < n; i += 2 * k)\\n for (int j = 0; j < (k); ++j) {\\n long long z = rt[j + k] * a[i + j + k] % mod, &ai = a[i + j];\\n a[i + j + k] = ai - z + (z > ai ? mod : 0);\\n ai += (ai + z >= mod ? z - mod : z);\\n }\\n}\\nvector conv(const vector a, const vector b) {\\n if (a.empty() || b.empty()) return {};\\n int s =...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 solution for \\\"Casimir has a string s which consists of capital Latin letters 'A', 'B', and 'C' only. Each turn he can choose to do one of the two following actions:\\n\\n * he can either erase exactly one letter 'A' and exactly one letter 'B' from arbitrary places of the string (these letters don't have to be adjacent); \\n * or he can erase exactly one letter 'B' and exactly one letter 'C' from arbitrary places in the string (these letters don't have to be adjacent). \\n\\n\\n\\nTherefore, each turn the length of the string is decreased exactly by 2. All turns are independent so for each turn, Casimir can choose any of two possible actions.\\n\\nFor example, with s = \\\"ABCABC\\\" he can obtain a string s = \\\"ACBC\\\" in one turn (by erasing the first occurrence of 'B' and the second occurrence of 'A'). There are also many other options for a turn aside from this particular example.\\n\\nFor a given string s determine whether there is a sequence of actions leading to an empty string. In other words, Casimir's goal is to erase all letters from the string. Is there a way to do this?\\n\\nInput\\n\\nThe first line contains an integer t (1 ≤ t ≤ 1000) — the number of test cases.\\n\\nEach test case is described by one string s, for which you need to determine if it can be fully erased by some sequence of turns. The string s consists of capital letters 'A', 'B', 'C' and has a length from 1 to 50 letters, inclusive.\\n\\nOutput\\n\\nPrint t lines, each line containing the answer to the corresponding test case. The answer to a test case should be YES if there is a way to fully erase the corresponding string and NO otherwise.\\n\\nYou may print every letter in any case you want (so, for example, the strings yEs, yes, Yes, and YES will all be recognized as positive answers).\\n\\nExample\\n\\nInput\\n\\n\\n6\\nABACAB\\nABBA\\nAC\\nABC\\nCABCBB\\nBCBCBCBCBCBCBCBC\\n\\n\\nOutput\\n\\n\\nNO\\nYES\\nNO\\nNO\\nYES\\nYES\\\":\",\"targets\":\"t = int(input())\\nfor _ in range(t):\\n s = input()\\n cnt = s.count('B')\\n if cnt != len(s)\\/\\/2 or len(s) % 2 != 0:\\n print(\\\"NO\\\")\\n else:\\n print(\\\"YES\\\")\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Polycarp had an array a of 3 positive integers. He wrote out the sums of all non-empty subsequences of this array, sorted them in non-decreasing order, and got an array b of 7 integers.\\n\\nFor example, if a = \\\\{1, 4, 3\\\\}, then Polycarp wrote out 1, 4, 3, 1 + 4 = 5, 1 + 3 = 4, 4 + 3 = 7, 1 + 4 + 3 = 8. After sorting, he got an array b = \\\\{1, 3, 4, 4, 5, 7, 8\\\\}.\\n\\nUnfortunately, Polycarp lost the array a. He only has the array b left. Help him to restore the array a.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 5000) — the number of test cases.\\n\\nEach test case consists of one line which contains 7 integers b_1, b_2, ..., b_7 (1 ≤ b_i ≤ 10^9; b_i ≤ b_{i+1}). \\n\\nAdditional constraint on the input: there exists at least one array a which yields this array b as described in the statement.\\n\\nOutput\\n\\nFor each test case, print 3 integers — a_1, a_2 and a_3. If there can be several answers, print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n1 3 4 4 5 7 8\\n1 2 3 4 5 6 7\\n300000000 300000000 300000000 600000000 600000000 600000000 900000000\\n1 1 2 999999998 999999999 999999999 1000000000\\n1 2 2 3 3 4 5\\n\\n\\nOutput\\n\\n\\n1 4 3\\n4 1 2\\n300000000 300000000 300000000\\n999999998 1 1\\n1 2 2\\n\\nNote\\n\\nThe subsequence of the array a is a sequence that can be obtained from a by removing zero or more of its elements.\\n\\nTwo subsequences are considered different if index sets of elements included in them are different. That is, the values of the elements don't matter in the comparison of subsequences. In particular, any array of length 3 has exactly 7 different non-empty subsequences.\",\"targets\":\"#include \\nusing namespace std;\\nvoid solve() {\\n vector v(7);\\n multiset s;\\n for (long long i = 0; i < 7; i++) {\\n cin >> v[i];\\n s.insert(v[i]);\\n }\\n for (long long i = 0; i < 7; i++) {\\n for (long long j = i + 1; j < 7; j++) {\\n for (long long h = j + 1; h < 7; h++) {\\n multiset r = s;\\n vector ok(7);\\n if (r.count(v[i]) >= 1) {\\n r.erase(r.find(v[i]));\\n ok[0] = true;\\n }\\n if (r.count(v[j]) >= 1) {\\n r.erase(r.find(v[j]));\\n ok[1] = true;\\n }\\n if (r.count(v[h]) >= 1) {\\n r.erase(r.find(v[h]));\\n ok[2] = true;\\n }\\n if (r.count(v[h] + v[i] + v[j]) >= 1) {\\n r.erase(r.find(v[h] + v[i] + v[j]));\\n ok[3] = true;\\n }\\n if (r.count(v[i] + v[j]) >= 1) {\\n r.erase(r.find(v[j] + v[i]));\\n ok[4] = true;\\n }\\n if (r.count(v[i] + v[h]) >= 1) {\\n r.erase(r.find(v[i] + v[h]));\\n ok[5] = true;\\n }\\n if (r.count(v[j] + v[h]) >= 1) {\\n r.erase(r.find(v[j] + v[h]));\\n ok[6] = true;\\n }\\n sort(ok.begin(), ok.end());\\n if (ok[6] && r.empty()) {\\n cout << v[i] << ' ' << v[j] << ' ' << v[h] << endl;\\n return;\\n }\\n }\\n }\\n }\\n}\\nsigned main() {\\n ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);\\n long long t;\\n cin >> t;\\n while (t--) {\\n solve();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nA bow adorned with nameless flowers that bears the earnest hopes of an equally nameless person.\\n\\nYou have obtained the elegant bow known as the Windblume Ode. Inscribed in the weapon is an array of n (n ≥ 3) positive distinct integers (i.e. different, no duplicates are allowed).\\n\\nFind the largest subset (i.e. having the maximum number of elements) of this array such that its sum is a composite number. A positive integer x is called composite if there exists a positive integer y such that 1 < y < x and x is divisible by y.\\n\\nIf there are multiple subsets with this largest size with the composite sum, you can output any of them. It can be proven that under the constraints of the problem such a non-empty subset always exists.\\n\\nInput\\n\\nEach test consists of multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 100). Description of the test cases follows.\\n\\nThe first line of each test case contains an integer n (3 ≤ n ≤ 100) — the length of the array.\\n\\nThe second line of each test case contains n distinct integers a_{1},a_{2},...,a_{n} (1 ≤ a_{i} ≤ 200) — the elements of the array.\\n\\nOutput\\n\\nEach test case should have two lines of output.\\n\\nThe first line should contain a single integer x: the size of the largest subset with composite sum. The next line should contain x space separated integers representing the indices of the subset of the initial array.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n8 1 2\\n4\\n6 9 4 2\\n9\\n1 2 3 4 5 6 7 8 9\\n3\\n200 199 198\\n\\n\\nOutput\\n\\n\\n2\\n2 1\\n4\\n2 1 4 3\\n9\\n6 9 1 2 3 4 5 7 8\\n3\\n1 2 3 \\n\\nNote\\n\\nIn the first test case, the subset \\\\\\\\{a_2, a_1\\\\} has a sum of 9, which is a composite number. The only subset of size 3 has a prime sum equal to 11. Note that you could also have selected the subset \\\\\\\\{a_1, a_3\\\\} with sum 8 + 2 = 10, which is composite as it's divisible by 2.\\n\\nIn the second test case, the sum of all elements equals to 21, which is a composite number. Here we simply take the whole array as our subset.\",\"targets\":\"\\/\\/package com.math;\\n\\nimport java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStream;\\nimport java.io.InputStreamReader;\\nimport java.util.StringTokenizer;\\n\\npublic class WindblumeOde {\\n\\n public boolean prime(int sum){\\n\\n if(sum < 2) return false;\\n\\n for(int j = 2; j * j <= sum; j ++){\\n if(sum % j == 0) return false;\\n }\\n return true;\\n }\\n\\n public void solve() {\\n FastScanner in = new FastScanner(System.in);\\n\\n int t = in.nextInt();\\n\\n while(t > 0){\\n int n = in.nextInt(), sum = 0;\\n int [] a = new int[n];\\n for(int i = 0; i < n; i ++){\\n a[i] = in.nextInt();\\n sum += a[i];\\n }\\n\\n if(!prime(sum)){\\n System.out.println(n);\\n for(int i = 1; i <= n; i ++)\\n System.out.print(i +\\\" \\\");\\n }else{\\n\\n System.out.println(n - 1);\\n for(int i = 0; i < n; i ++){\\n if(a[i] % 2 != 0){\\n for(int j = 0; j < n; j ++ ){\\n if(j != i)\\n System.out.print((j + 1) +\\\" \\\");\\n }\\n break;\\n }\\n }\\n }\\n System.out.println();\\n t --;\\n }\\n\\n }\\n\\n public static void main(String[] args) {\\n WindblumeOde x = new WindblumeOde();\\n x.solve();\\n\\n }\\n\\n private class FastScanner {\\n public BufferedReader r;\\n public StringTokenizer st = null;\\n\\n public FastScanner(InputStream stream) {\\n r = new BufferedReader(new InputStreamReader(stream), 32728);\\n\\n }\\n\\n\\n public String next() {\\n\\n while (st == null || !st.hasMoreTokens()) {\\n\\n try {\\n\\n st = new StringTokenizer(r.readLine());\\n } catch (IOException e) {\\n throw new RuntimeException();\\n }\\n }\\n\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Ehab loves number theory, but for some reason he hates the number x. Given an array a, find the length of its longest subarray such that the sum of its elements isn't divisible by x, or determine that such subarray doesn't exist.\\n\\nAn array a is a subarray of an array b if a can be obtained from b by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.\\n\\nInput\\n\\nThe first line contains an integer t (1 ≤ t ≤ 5) — the number of test cases you need to solve. The description of the test cases follows.\\n\\nThe first line of each test case contains 2 integers n and x (1 ≤ n ≤ 10^5, 1 ≤ x ≤ 10^4) — the number of elements in the array a and the number that Ehab hates.\\n\\nThe second line contains n space-separated integers a_1, a_2, …, a_{n} (0 ≤ a_i ≤ 10^4) — the elements of the array a.\\n\\nOutput\\n\\nFor each testcase, print the length of the longest subarray whose sum isn't divisible by x. If there's no such subarray, print -1.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n3 3\\n1 2 3\\n3 4\\n1 2 3\\n2 2\\n0 6\\n\\n\\nOutput\\n\\n\\n2\\n3\\n-1\\n\\nNote\\n\\nIn the first test case, the subarray [2,3] has sum of elements 5, which isn't divisible by 3.\\n\\nIn the second test case, the sum of elements of the whole array is 6, which isn't divisible by 4.\\n\\nIn the third test case, all subarrays have an even sum, so the answer is -1.\\nfor _\",\"targets\":\"in range(int(input())):\\n n=int(input())\\n l=[int(x) for x in input().split()]\\n l=set(l)\\n print(len(l))\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given two strings s and t, both consisting of lowercase English letters. You are going to type the string s character by character, from the first character to the last one.\\n\\nWhen typing a character, instead of pressing the button corresponding to it, you can press the \\\"Backspace\\\" button. It deletes the last character you have typed among those that aren't deleted yet (or does nothing if there are no characters in the current string). For example, if s is \\\"abcbd\\\" and you press Backspace instead of typing the first and the fourth characters, you will get the string \\\"bd\\\" (the first press of Backspace deletes no character, and the second press deletes the character 'c'). Another example, if s is \\\"abcaa\\\" and you press Backspace instead of the last two letters, then the resulting text is \\\"a\\\".\\n\\nYour task is to determine whether you can obtain the string t, if you type the string s and press \\\"Backspace\\\" instead of typing several (maybe zero) characters of s.\\n\\nInput\\n\\nThe first line contains a single integer q (1 ≤ q ≤ 10^5) — the number of test cases.\\n\\nThe first line of each test case contains the string s (1 ≤ |s| ≤ 10^5). Each character of s is a lowercase English letter.\\n\\nThe second line of each test case contains the string t (1 ≤ |t| ≤ 10^5). Each character of t is a lowercase English letter.\\n\\nIt is guaranteed that the total number of characters in the strings over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print \\\"YES\\\" if you can obtain the string t by typing the string s and replacing some characters with presses of \\\"Backspace\\\" button, or \\\"NO\\\" if you cannot.\\n\\nYou may print each letter in any case (YES, yes, Yes will all be recognized as positive answer, NO, no and nO will all be recognized as negative answer).\\n\\nExample\\n\\nInput\\n\\n\\n4\\nababa\\nba\\nababa\\nbb\\naaa\\naaaa\\naababa\\nababa\\n\\n\\nOutput\\n\\n\\nYES\\nNO\\nNO\\nYES\\n\\nNote\\n\\nConsider the example test from the statement.\\n\\nIn order to obtain \\\"ba\\\" from \\\"ababa\\\", you may press Backspace instead of typing the first and the fourth characters.\\n\\nThere's no way...\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nint T, h, t, la, lb;\\nstring a, b;\\nint main() {\\n scanf(\\\"%d\\\", &T);\\n while (T--) {\\n cin >> a;\\n cin >> b;\\n la = a.size();\\n lb = b.size();\\n h = t = 0;\\n if (la % 2 != lb % 2) h = 1;\\n for (int i = h; i < la; i++) {\\n if (a[i] == b[t])\\n t++;\\n else\\n i++;\\n if (t >= lb) break;\\n }\\n if (t < lb)\\n puts(\\\"NO\\\");\\n else\\n puts(\\\"YES\\\");\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in PYTHON3?\\nIt is the hard version of the problem. The only difference is that in this version 1 ≤ n ≤ 300.\\n\\nIn the cinema seats can be represented as the table with n rows and m columns. The rows are numbered with integers from 1 to n. The seats in each row are numbered with consecutive integers from left to right: in the k-th row from m (k - 1) + 1 to m k for all rows 1 ≤ k ≤ n.\\n\\n1| 2| ⋅⋅⋅| m - 1| m \\n---|---|---|---|--- \\nm + 1| m + 2| ⋅⋅⋅| 2 m - 1| 2 m \\n2m + 1| 2m + 2| ⋅⋅⋅| 3 m - 1| 3 m \\n\\\\vdots| \\\\vdots| \\\\ddots| \\\\vdots| \\\\vdots \\nm (n - 1) + 1| m (n - 1) + 2| ⋅⋅⋅| n m - 1| n m \\nThe table with seats indices\\n\\nThere are nm people who want to go to the cinema to watch a new film. They are numbered with integers from 1 to nm. You should give exactly one seat to each person.\\n\\nIt is known, that in this cinema as lower seat index you have as better you can see everything happening on the screen. i-th person has the level of sight a_i. Let's define s_i as the seat index, that will be given to i-th person. You want to give better places for people with lower sight levels, so for any two people i, j such that a_i < a_j it should be satisfied that s_i < s_j.\\n\\nAfter you will give seats to all people they will start coming to their seats. In the order from 1 to nm, each person will enter the hall and sit in their seat. To get to their place, the person will go to their seat's row and start moving from the first seat in this row to theirs from left to right. While moving some places will be free, some will be occupied with people already seated. The inconvenience of the person is equal to the number of occupied seats he or she will go through.\\n\\nLet's consider an example: m = 5, the person has the seat 4 in the first row, the seats 1, 3, 5 in the first row are already occupied, the seats 2 and 4 are free. The inconvenience of this person will be 2, because he will go through occupied seats 1 and 3.\\n\\nFind the minimal total inconvenience (the sum of inconveniences of all people), that is possible to have by giving places for all...\",\"targets\":\"import sys, os\\nfrom io import BytesIO, IOBase\\nfrom math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log\\nfrom collections import defaultdict as dd, deque\\nfrom heapq import merge, heapify, heappop, heappush, nsmallest\\nfrom bisect import bisect_left as bl, bisect_right as br, bisect, insort_left\\n \\n# region fastio\\nBUFSIZE = 8192\\n \\nclass FastIO(IOBase):\\n newlines = 0\\n \\n def __init__(self, file):\\n self._fd = file.fileno()\\n self.buffer = BytesIO()\\n self.writable = \\\"x\\\" in file.mode or \\\"r\\\" not in file.mode\\n self.write = self.buffer.write if self.writable else None\\n \\n def read(self):\\n while True:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n if not b:\\n break\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines = 0\\n return self.buffer.read()\\n \\n def readline(self):\\n while self.newlines == 0:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n self.newlines = b.count(b\\\"\\\\n\\\") + (not b)\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines -= 1\\n return self.buffer.readline()\\n \\n def flush(self):\\n if self.writable:\\n os.write(self._fd, self.buffer.getvalue())\\n self.buffer.truncate(0), self.buffer.seek(0)\\n \\nclass IOWrapper(IOBase):\\n def __init__(self, file):\\n self.buffer = FastIO(file)\\n self.flush = self.buffer.flush\\n self.writable = self.buffer.writable\\n self.write = lambda s: self.buffer.write(s.encode(\\\"ascii\\\"))\\n self.read = lambda: self.buffer.read().decode(\\\"ascii\\\")\\n self.readline = lambda: self.buffer.readline().decode(\\\"ascii\\\")\\n \\nstdin, stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout) \\n \\nmod = pow(10, 9) + 7\\nmod2 = 998244353\\n \\ndef inp(): return stdin.readline().strip()\\ndef iinp(): return int(inp())\\ndef...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A number is called quasibinary if its decimal representation contains only digits 0 or 1. For example, numbers 0, 1, 101, 110011 — are quasibinary and numbers 2, 12, 900 are not.\\n\\nYou are given a positive integer n. Represent it as a sum of minimum number of quasibinary numbers.\\n\\nInput\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 106).\\n\\nOutput\\n\\nIn the first line print a single integer k — the minimum number of numbers in the representation of number n as a sum of quasibinary numbers.\\n\\nIn the second line print k numbers — the elements of the sum. All these numbers should be quasibinary according to the definition above, their sum should equal n. Do not have to print the leading zeroes in the numbers. The order of numbers doesn't matter. If there are multiple possible representations, you are allowed to print any of them.\\n\\nExamples\\n\\nInput\\n\\n9\\n\\n\\nOutput\\n\\n9\\n1 1 1 1 1 1 1 1 1 \\n\\n\\nInput\\n\\n32\\n\\n\\nOutput\\n\\n3\\n10 11 11 \\nThe above is tricky. Write me a correct solution in PYTHON.\",\"targets\":\"import sys\\n\\nN = int(sys.stdin.readline())\\n\\norg = N\\ns = []\\n\\nwhile N != 0:\\n a = str(N)\\n t = 0\\n car = 1\\n for i in range(len(a)):\\n if a[len(a)-1-i] != '0':\\n t += car\\n car *= 10\\n s += [t]\\n N -= t\\nprint len(s)\\nfor i in s:\\n print i,\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 solution for \\\"Luntik has decided to try singing. He has a one-minute songs, b two-minute songs and c three-minute songs. He wants to distribute all songs into two concerts such that every song should be included to exactly one concert.\\n\\nHe wants to make the absolute difference of durations of the concerts as small as possible. The duration of the concert is the sum of durations of all songs in that concert.\\n\\nPlease help Luntik and find the minimal possible difference in minutes between the concerts durations.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases.\\n\\nEach test case consists of one line containing three integers a, b, c (1 ≤ a, b, c ≤ 10^9) — the number of one-minute, two-minute and three-minute songs.\\n\\nOutput\\n\\nFor each test case print the minimal possible difference in minutes between the concerts durations.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n1 1 1\\n2 1 3\\n5 5 5\\n1 1 2\\n\\n\\nOutput\\n\\n\\n0\\n1\\n0\\n1\\n\\nNote\\n\\nIn the first test case, Luntik can include a one-minute song and a two-minute song into the first concert, and a three-minute song into the second concert. Then the difference will be equal to 0.\\n\\nIn the second test case, Luntik can include two one-minute songs and a two-minute song and a three-minute song into the first concert, and two three-minute songs into the second concert. The duration of the first concert will be 1 + 1 + 2 + 3 = 7, the duration of the second concert will be 6. The difference of them is |7-6| = 1.\\\":\",\"targets\":\"t = int(input(\\\"\\\"))\\nfor i in range(t):\\n numbers = list(map(int, input(\\\"\\\").split(\\\" \\\")))\\n if(((numbers[0]) + (numbers[1]*2) + (numbers[2]*3)) % 2 == 0):\\n print(0)\\n else:\\n print(1)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nPetya has got an interesting flower. Petya is a busy person, so he sometimes forgets to water it. You are given n days from Petya's live and you have to determine what happened with his flower in the end.\\n\\nThe flower grows as follows: \\n\\n * If the flower isn't watered for two days in a row, it dies. \\n * If the flower is watered in the i-th day, it grows by 1 centimeter. \\n * If the flower is watered in the i-th and in the (i-1)-th day (i > 1), then it grows by 5 centimeters instead of 1. \\n * If the flower is not watered in the i-th day, it does not grow. \\n\\n\\n\\nAt the beginning of the 1-st day the flower is 1 centimeter tall. What is its height after n days?\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 100). Description of the test cases follows.\\n\\nThe first line of each test case contains the only integer n (1 ≤ n ≤ 100).\\n\\nThe second line of each test case contains n integers a_1, a_2, ..., a_n (a_i = 0 or a_i = 1). If a_i = 1, the flower is watered in the i-th day, otherwise it is not watered.\\n\\nOutput\\n\\nFor each test case print a single integer k — the flower's height after n days, or -1, if the flower dies.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n1 0 1\\n3\\n0 1 1\\n4\\n1 0 0 1\\n1\\n0\\n\\n\\nOutput\\n\\n\\n3\\n7\\n-1\\n1\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.util.*;\\nimport java.util.concurrent.ThreadLocalRandom;\\n\\npublic class Z {\\n private static void sport(int[] a) {\\n int n = a.length;\\n int ans = 1;\\n for (int i = 1; i < n; i++) {\\n if (a[i - 1] == 0 && a[i] == 0) {\\n System.out.println(-1);\\n return;\\n }\\n }\\n for (int i = 0; i < n; i++) {\\n if (i > 0 && a[i - 1] == 1 && a[i] == 1) {\\n ans += 5;\\n } else if (a[i] == 1) {\\n ans++;\\n }\\n }\\n System.out.println(ans);\\n }\\n\\n public static void main(String[] args) throws IOException {\\n FastScanner sc = new FastScanner();\\n int t = sc.nextInt();\\n for (int i = 0; i < t; i++) {\\n int n = sc.nextInt();\\n int[] a = sc.readArrayInt(n);\\n sport(a);\\n }\\n }\\n\\n static void shuffleArray(int[] ar) {\\n \\/\\/ If running on Java 6 or older, use `new Random()` on RHS here\\n Random rnd = ThreadLocalRandom.current();\\n for (int i = ar.length - 1; i > 0; i--) {\\n int index = rnd.nextInt(i + 1);\\n \\/\\/ Simple swap\\n int a = ar[index];\\n ar[index] = ar[i];\\n ar[i] = a;\\n }\\n }\\n\\n static class FastScanner {\\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\\n StringTokenizer st = new StringTokenizer(\\\"\\\");\\n\\n String next() {\\n while (!st.hasMoreTokens()) {\\n try {\\n st = new StringTokenizer(br.readLine());\\n } catch (IOException e) {\\n e.printStackTrace();\\n }\\n }\\n return st.nextToken();\\n }\\n\\n int nextInt() {\\n return Integer.parseInt(next());\\n }\\n\\n void nextLine() throws IOException {\\n br.readLine();\\n }\\n\\n long[] readArrayLong(int n) {\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A string is called square if it is some string written twice in a row. For example, the strings \\\"aa\\\", \\\"abcabc\\\", \\\"abab\\\" and \\\"baabaa\\\" are square. But the strings \\\"aaa\\\", \\\"abaaab\\\" and \\\"abcdabc\\\" are not square.\\n\\nFor a given string s determine if it is square.\\n\\nInput\\n\\nThe first line of input data contains an integer t (1 ≤ t ≤ 100) —the number of test cases.\\n\\nThis is followed by t lines, each containing a description of one test case. The given strings consist only of lowercase Latin letters and have lengths between 1 and 100 inclusive.\\n\\nOutput\\n\\nFor each test case, output on a separate line:\\n\\n * YES if the string in the corresponding test case is square, \\n * NO otherwise. \\n\\n\\n\\nYou can output YES and NO in any case (for example, strings yEs, yes, Yes and YES will be recognized as a positive response).\\n\\nExample\\n\\nInput\\n\\n\\n10\\na\\naa\\naaa\\naaaa\\nabab\\nabcabc\\nabacaba\\nxxyy\\nxyyx\\nxyxy\\n\\n\\nOutput\\n\\n\\nNO\\nYES\\nNO\\nYES\\nYES\\nYES\\nNO\\nNO\\nNO\\nYES\\n# coo\",\"targets\":\"k your dish here\\nfrom collections import deque, defaultdict\\nfrom math import sqrt, ceil, factorial, floor, inf, log2, sqrt, gcd\\nimport bisect\\nimport copy\\nfrom itertools import combinations\\nimport sys\\nimport heapq\\ndef get_array(): return list(map(int, sys.stdin.readline().strip().split()))\\ndef get_ints(): return map(int, sys.stdin.readline().strip().split())\\ndef input(): return sys.stdin.readline().strip()\\n\\n\\n\\nfor _ in range(int(input())):\\n s=input()\\n n=len(s)\\n if n%2==1:\\n print(\\\"NO\\\")\\n else:\\n n1=n\\/\\/2\\n s1=s[:n1]\\n s2=s[n1:]\\n if s1==s2:\\n print(\\\"YES\\\")\\n else:\\n print(\\\"NO\\\")\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Polycarp has found a table having an infinite number of rows and columns. The rows are numbered from 1, starting from the topmost one. The columns are numbered from 1, starting from the leftmost one.\\n\\nInitially, the table hasn't been filled and Polycarp wants to fix it. He writes integers from 1 and so on to the table as follows.\\n\\n The figure shows the placement of the numbers from 1 to 10. The following actions are denoted by the arrows.\\n\\nThe leftmost topmost cell of the table is filled with the number 1. Then he writes in the table all positive integers beginning from 2 sequentially using the following algorithm.\\n\\nFirst, Polycarp selects the leftmost non-filled cell in the first row and fills it. Then, while the left neighbor of the last filled cell is filled, he goes down and fills the next cell. So he goes down until the last filled cell has a non-filled neighbor to the left (look at the vertical arrow going down in the figure above).\\n\\nAfter that, he fills the cells from the right to the left until he stops at the first column (look at the horizontal row in the figure above). Then Polycarp selects the leftmost non-filled cell in the first row, goes down, and so on.\\n\\nA friend of Polycarp has a favorite number k. He wants to know which cell will contain the number. Help him to find the indices of the row and the column, such that the intersection of the row and the column is the cell containing the number k.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 100) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one line containing one integer k (1 ≤ k ≤ 10^9) which location must be found.\\n\\nOutput\\n\\nFor each test case, output in a separate line two integers r and c (r, c ≥ 1) separated by spaces — the indices of the row and the column containing the cell filled by the number k, respectively.\\n\\nExample\\n\\nInput\\n\\n\\n7\\n11\\n14\\n5\\n4\\n1\\n2\\n1000000000\\n\\n\\nOutput\\n\\n\\n2 4\\n4 3\\n1 3\\n2 1\\n1 1\\n1 2\\n31623 14130\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"from math import floor as fl\\nfrom math import sqrt\\ndef main():\\n k=int(input())\\n shell=fl(sqrt(k-0.5))\\n diag=1+shell**2+shell\\n\\n if (k==diag):\\n print('{} {}'.format(shell+1, shell+1))\\n elif (k que = new ArrayDeque();\\n que.add(new pair(0,0));\\n while(!que.isEmpty()){\\n pair p = que.poll();\\n if(p.x==h-1&&p.y==w-1)break;\\n for(int i=0;i<4;i++){\\n int cx = p.x+dx[i];\\n int cy = p.y+dy[i];\\n if(cx>=0&&cx<=h-1&&cy>=0&&cy<=w-1&&path[cx][cy]=='.'&&cnt[cx][cy]==-1){\\n cnt[cx][cy]=cnt[p.x][p.y]+1;\\n que.add(new pair(cx,cy));\\n }\\n }\\n }\\n if(cnt[h-1][w-1]!=-1)System.out.println(h*w-cnt[h-1][w-1]-res);\\n else System.out.println(-1);\\n }\\n public static class pair{\\n int x;\\n int y;\\n pair(int x,int y){\\n this.x = x;\\n this.y = y;\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A tree is an undirected connected graph without cycles.\\n\\nYou are given a tree of n vertices. Find the number of ways to choose exactly k vertices in this tree (i. e. a k-element subset of vertices) so that all pairwise distances between the selected vertices are equal (in other words, there exists an integer c such that for all u, v (u ≠ v, u, v are in selected vertices) d_{u,v}=c, where d_{u,v} is the distance from u to v).\\n\\nSince the answer may be very large, you need to output it modulo 10^9 + 7.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10) — the number of test cases. Then t test cases follow.\\n\\nEach test case is preceded by an empty line.\\n\\nEach test case consists of several lines. The first line of the test case contains two integers n and k (2 ≤ k ≤ n ≤ 100) — the number of vertices in the tree and the number of vertices to be selected, respectively. Then n - 1 lines follow, each of them contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) which describe a pair of vertices connected by an edge. It is guaranteed that the given graph is a tree and has no loops or multiple edges.\\n\\nOutput\\n\\nFor each test case output in a separate line a single integer — the number of ways to select exactly k vertices so that for all pairs of selected vertices the distances between the vertices in the pairs are equal, modulo 10^9 + 7 (in other words, print the remainder when divided by 1000000007).\\n\\nExample\\n\\nInput\\n\\n\\n3\\n\\n4 2\\n1 2\\n2 3\\n2 4\\n\\n3 3\\n1 2\\n2 3\\n\\n5 3\\n1 2\\n2 3\\n2 4\\n4 5\\n\\n\\nOutput\\n\\n\\n6\\n0\\n1\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nusing ll = long long;\\nusing VL = vector;\\nusing VVL = vector;\\nusing VI = vector;\\nusing VVI = vector;\\nconst ll MOD = 1e9 + 7;\\nVVI G;\\nVI V;\\nVVL M;\\nll f(int i, int j) {\\n if (j < 0 or j > i) return 0;\\n ll& res = M[i][j];\\n if (res != -1) return res;\\n if (j == 0) return res = 1;\\n return res = (f(i - 1, j) + V[i - 1] * f(i - 1, j - 1)) % MOD;\\n}\\nvoid dfs(int x, int p, int d, VI& V) {\\n if (d >= (int)V.size())\\n V.push_back(1);\\n else\\n ++V[d];\\n for (int y : G[x])\\n if (y != p) dfs(y, x, d + 1, V);\\n}\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n int t;\\n cin >> t;\\n while (t--) {\\n int n, k;\\n cin >> n >> k;\\n G = VVI(n);\\n for (int r = 0; r < n - 1; ++r) {\\n int x, y;\\n cin >> x >> y;\\n --x;\\n --y;\\n G[x].push_back(y);\\n G[y].push_back(x);\\n }\\n if (k == 2)\\n cout << n * (n - 1) \\/ 2 << endl;\\n else {\\n ll res = 0;\\n for (int x = 0; x < n; ++x) {\\n int m = G[x].size();\\n VVI T(m);\\n int mx = 0;\\n for (int i = 0; i < m; ++i) {\\n dfs(G[x][i], x, 0, T[i]);\\n mx = max(mx, (int)T[i].size());\\n }\\n for (int d = 0; d < mx; ++d) {\\n V.clear();\\n for (int i = 0; i < m; ++i)\\n if (d < (int)T[i].size()) V.push_back(T[i][d]);\\n int q = V.size();\\n if (q >= k) {\\n M = VVL(q + 1, VL(k + 1, -1));\\n res = (res + f(q, k)) % MOD;\\n }\\n }\\n }\\n cout << res << endl;\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nAn important meeting is to be held and there are exactly n people invited. At any moment, any two people can step back and talk in private. The same two people can talk several (as many as they want) times per meeting.\\n\\nEach person has limited sociability. The sociability of the i-th person is a non-negative integer a_i. This means that after exactly a_i talks this person leaves the meeting (and does not talk to anyone else anymore). If a_i = 0, the i-th person leaves the meeting immediately after it starts.\\n\\nA meeting is considered most productive if the maximum possible number of talks took place during it.\\n\\nYou are given an array of sociability a, determine which people should talk to each other so that the total number of talks is as large as possible.\\n\\nInput\\n\\nThe first line contains an integer t (1 ≤ t ≤ 1000) — the number of test cases.\\n\\nThe next 2t lines contain descriptions of the test cases.\\n\\nThe first line of each test case description contains an integer n (2 ≤ n ≤ 2 ⋅ 10^5) —the number of people in the meeting. The second line consists of n space-separated integers a_1, a_2, ..., a_n (0 ≤ a_i ≤ 2 ⋅ 10^5) — the sociability parameters of all people. \\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5. It is also guaranteed that the sum of all a_i (over all test cases and all i) does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nPrint t answers to all test cases.\\n\\nOn the first line of each answer print the number k — the maximum number of talks possible in a meeting.\\n\\nOn each of the next k lines print two integers i and j (1 ≤ i, j ≤ n and i ≠ j) — the numbers of people who will have another talk.\\n\\nIf there are several possible answers, you may print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n8\\n2\\n2 3\\n3\\n1 2 3\\n4\\n1 2 3 4\\n3\\n0 0 2\\n2\\n6 2\\n3\\n0 0 2\\n5\\n8 2 0 1 1\\n5\\n0 1 0 0 6\\n\\n\\nOutput\\n\\n\\n2\\n1 2\\n1 2\\n3\\n1 3\\n2 3\\n2 3\\n5\\n1 3\\n2 4\\n2 4\\n3 4\\n3 4\\n0\\n2\\n1 2\\n1 2\\n0\\n4\\n1 2\\n1 5\\n1 4\\n1 2\\n1\\n5 2\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.File;\\nimport java.io.FileNotFoundException;\\nimport java.io.FileReader;\\nimport java.io.IOException;\\nimport java.io.InputStream;\\nimport java.io.InputStreamReader;\\nimport java.io.OutputStream;\\nimport java.io.PrintWriter;\\nimport java.util.ArrayList;\\nimport java.util.Arrays;\\nimport java.util.List;\\nimport java.util.StringTokenizer;\\nimport java.util.TreeSet;\\n\\n\\npublic class Main {\\n\\n\\tstatic class Task {\\n\\t\\t\\n\\t\\tint NN = 200005;\\n\\t\\tint MOD = 1000000007;\\n\\t\\tint INF = 2000000000;\\n\\t\\tlong INFINITY = (1L<<63)-1;\\n\\n\\t\\tclass Tuple {\\n\\t\\t\\tInteger [] ara;\\n\\t\\t\\tpublic Tuple(Integer... a) {\\n\\t\\t\\t\\tthis.ara = a;\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\t\\n\\t\\tpublic void solve(InputReader in, PrintWriter out) {\\n\\t\\t\\tint t = in.nextInt();\\n\\t\\t\\twhile(t-->0) {\\n\\t\\t\\t\\tint n = in.nextInt();\\n\\t\\t\\t\\tTuple [] a = new Tuple[n];\\n\\t\\t\\t\\tTreeSet q = new TreeSet<>((t1, t2)->t1.ara[0].equals(t2.ara[0])\\n\\t\\t\\t\\t?t1.ara[1].compareTo(t2.ara[1])\\n\\t\\t\\t\\t:t1.ara[0].compareTo(t2.ara[0]));\\n\\t\\t\\t\\tfor(int i=0;i L = new ArrayList<>();\\n\\t\\t\\t\\twhile(q.size() > 1) {\\n\\t\\t\\t\\t\\tTuple t1 = q.pollLast();\\n\\t\\t\\t\\t\\tTuple t2 = q.pollLast();\\n\\t\\t\\t\\t\\tif(t2.ara[0] > 0) {\\n\\t\\t\\t\\t\\t\\tL.add(t1.ara[1]);L.add(t2.ara[1]);\\n\\t\\t\\t\\t\\t\\tif(t1.ara[0] > 1) q.add(new Tuple(t1.ara[0]-1, t1.ara[1]));\\n\\t\\t\\t\\t\\t\\tif(t2.ara[0] > 1) q.add(new Tuple(t2.ara[0]-1, t2.ara[1]));\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tout.println(L.size()\\/2);\\n\\t\\t\\t\\tfor(int i=0;iq_j should hold). \\n\\n\\n\\nAmong all valid permutations q find the one that has the smallest value of ∑_{i=1}^n |p_i-q_i|, where |x| is an absolute value of x.\\n\\nPrint the permutation q_1, q_2, ..., q_n. If there are multiple answers, you can print any of them.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.\\n\\nThe first line of each testcase contains a single integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of songs.\\n\\nThe second line of each testcase contains n integers p_1, p_2, ..., p_n (1 ≤ p_i ≤ n) — the permutation of the predicted ratings.\\n\\nThe third line contains a single string s, consisting of n characters. Each character is either a 0 or a 1. 0 means that Monocarp disliked the song, and 1 means that he liked it.\\n\\nThe sum of n over all testcases doesn't exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each testcase, print a permutation q — the re-evaluated ratings of the songs. If there are multiple answers such that ∑_{i=1}^n |p_i-q_i| is minimum possible, you can print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n2\\n1 2\\n10\\n3\\n3 1 2\\n111\\n8\\n2...\\\":\",\"targets\":\"#include \\n#pragma GCC optimize(\\\"O2,unroll-loops\\\")\\n#pragma GCC target( \\\\\\n \\\"avx2,bmi,bmi2,lzcnt,popcnt,sse,sse2,sse3,ssse3,sse4,abm,mmx,avx\\\")\\nusing namespace std;\\nusing ll = long long;\\nint t, n;\\npair, int> a[200001];\\nstring s;\\nbool cmp(pair, int> x, pair, int> y) {\\n if (x.first.second == y.first.second) return x.first.first < y.first.first;\\n return x.first.second < y.first.second;\\n}\\nbool cmp2(pair, int> x, pair, int> y) {\\n return x.second < y.second;\\n}\\nvoid input() {\\n cin >> n;\\n for (int i = 1; i <= n; i++) cin >> a[i].first.first;\\n cin >> s;\\n}\\nvoid solve() {\\n for (int i = 1; i <= n; i++) {\\n a[i].first.second = s[i - 1] - '0';\\n a[i].second = i;\\n }\\n sort(a + 1, a + n + 1, cmp);\\n for (int i = 1; i <= n; i++) a[i].first.second = i;\\n sort(a + 1, a + n + 1, cmp2);\\n for (int i = 1; i <= n; i++) cout << a[i].first.second << \\\" \\\";\\n cout << \\\"\\\\n\\\";\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(nullptr);\\n for (cin >> t; t--;) {\\n input();\\n solve();\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A robot cleaner is placed on the floor of a rectangle room, surrounded by walls. The floor consists of n rows and m columns. The rows of the floor are numbered from 1 to n from top to bottom, and columns of the floor are numbered from 1 to m from left to right. The cell on the intersection of the r-th row and the c-th column is denoted as (r,c). The initial position of the robot is (r_b, c_b).\\n\\nIn one second, the robot moves by dr rows and dc columns, that is, after one second, the robot moves from the cell (r, c) to (r + dr, c + dc). Initially dr = 1, dc = 1. If there is a vertical wall (the left or the right walls) in the movement direction, dc is reflected before the movement, so the new value of dc is -dc. And if there is a horizontal wall (the upper or lower walls), dr is reflected before the movement, so the new value of dr is -dr.\\n\\nEach second (including the moment before the robot starts moving), the robot cleans every cell lying in the same row or the same column as its position. There is only one dirty cell at (r_d, c_d). The job of the robot is to clean that dirty cell.\\n\\n Illustration for the first example. The blue arc is the robot. The red star is the target dirty cell. Each second the robot cleans a row and a column, denoted by yellow stripes.\\n\\nGiven the floor size n and m, the robot's initial position (r_b, c_b) and the dirty cell's position (r_d, c_d), find the time for the robot to do its job.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^4). Description of the test cases follows.\\n\\nA test case consists of only one line, containing six integers n, m, r_b, c_b, r_d, and c_d (1 ≤ n, m ≤ 100, 1 ≤ r_b, r_d ≤ n, 1 ≤ c_b, c_d ≤ m) — the sizes of the room, the initial position of the robot and the position of the dirt cell.\\n\\nOutput\\n\\nFor each test case, print an integer — the time for the robot to clean the dirty cell. We can show that the robot always cleans the dirty cell eventually.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n10 10 6 1 2 8\\n10 10 9 9 1...\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nusing namespace chrono;\\nvoid print(long long a) { cerr << a; }\\nvoid print(string a) { cerr << a; }\\nvoid print(char a) { cerr << a; }\\nvoid print(int a) { cerr << a; }\\nvoid print(bool a) { cerr << a; }\\nvoid print(long double a) { cerr << a; }\\nvoid print(unsigned long long a) { cerr << a; }\\ntemplate \\nvoid print(vector v);\\ntemplate \\nvoid print(pair p);\\ntemplate \\nvoid print(map m);\\ntemplate \\nvoid print(unordered_map m);\\ntemplate \\nvoid print(multimap m);\\ntemplate \\nvoid print(set s);\\ntemplate \\nvoid print(unordered_set s);\\ntemplate \\nvoid print(multiset s);\\ntemplate \\nvoid print(stack s);\\ntemplate \\nvoid print(vector v) {\\n cerr << \\\"[ \\\";\\n for (S it : v) {\\n print(it);\\n cerr << \\\" \\\";\\n }\\n cerr << \\\"]\\\";\\n}\\ntemplate \\nvoid print(pair p) {\\n cerr << \\\"{ \\\";\\n print(p.first);\\n cerr << \\\", \\\";\\n print(p.second);\\n cerr << \\\"}\\\";\\n}\\ntemplate \\nvoid print(map m) {\\n cerr << \\\"[ \\\";\\n for (auto it : m) {\\n print(it);\\n cerr << \\\" \\\";\\n }\\n cerr << \\\"]\\\";\\n}\\ntemplate \\nvoid print(unordered_map m) {\\n cerr << \\\"[ \\\";\\n for (auto it : m) {\\n print(it);\\n cerr << \\\" \\\";\\n }\\n cerr << \\\"]\\\";\\n}\\ntemplate \\nvoid print(multimap m) {\\n cerr << \\\"[ \\\";\\n for (auto it : m) {\\n print(it);\\n cerr << \\\" \\\";\\n }\\n cerr << \\\"]\\\";\\n}\\ntemplate \\nvoid print(set s) {\\n cerr << \\\"[ \\\";\\n for (S it : s) {\\n print(it);\\n cerr << \\\" \\\";\\n }\\n cerr << \\\"]\\\";\\n}\\ntemplate \\nvoid print(unordered_set s) {\\n cerr << \\\"[ \\\";\\n for (S it : s) {\\n print(it);\\n cerr << \\\" \\\";\\n }\\n cerr << \\\"]\\\";\\n}\\ntemplate \\nvoid print(multiset s) {\\n cerr << \\\"[ \\\";\\n for (S it : s) {\\n print(it);\\n cerr << \\\" \\\";\\n }\\n cerr << \\\"]\\\";\\n}\\ntemplate \\nvoid print(stack s) {\\n cerr << \\\"[ \\\";\\n while (!s.empty()) {\\n print(s.top());\\n cerr << \\\" \\\";\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 solution for \\\"Paprika loves permutations. She has an array a_1, a_2, ..., a_n. She wants to make the array a permutation of integers 1 to n.\\n\\nIn order to achieve this goal, she can perform operations on the array. In each operation she can choose two integers i (1 ≤ i ≤ n) and x (x > 0), then perform a_i := a_i mod x (that is, replace a_i by the remainder of a_i divided by x). In different operations, the chosen i and x can be different.\\n\\nDetermine the minimum number of operations needed to make the array a permutation of integers 1 to n. If it is impossible, output -1.\\n\\nA permutation is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice in the array) and [1,3,4] is also not a permutation (n=3 but there is 4 in the array).\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. Description of the test cases follows.\\n\\nThe first line of each test case contains an integer n (1 ≤ n ≤ 10^5).\\n\\nThe second line of each test case contains n integers a_1, a_2, ..., a_n. (1 ≤ a_i ≤ 10^9).\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, output the minimum number of operations needed to make the array a permutation of integers 1 to n, or -1 if it is impossible.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n2\\n1 7\\n3\\n1 5 4\\n4\\n12345678 87654321 20211218 23571113\\n9\\n1 2 3 4 18 19 5 6 7\\n\\n\\nOutput\\n\\n\\n1\\n-1\\n4\\n2\\n\\nNote\\n\\nFor the first test, the only possible sequence of operations which minimizes the number of operations is: \\n\\n * Choose i=2, x=5. Perform a_2 := a_2 mod 5 = 2. \\n\\n\\n\\nFor the second test, it is impossible to obtain a permutation of integers from 1 to n.\\\":\",\"targets\":\"import sys,os,io\\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\\n#input = sys.stdin.readline\\nimport math\\nimport bisect\\nt=int(input())\\nfor a0 in range(t):\\n n=int(input())\\n l=[int(i) for i in input().split()]\\n l.sort()\\n f=0 \\n c=0\\n perm=[0]*n \\n ind=0 \\n l1=[]\\n for i in range(n):\\n if(l[i]<=n):\\n perm[l[i]-1]+=1 \\n if(perm[l[i]-1])>1:l1.append(l[i])\\n else:\\n ind=i \\n break \\n l1.extend(l[ind::])\\n #print(l1)\\n i=0 \\n ind=0 \\n #print(perm,ind)\\n while(ind 0) {\\n long n = sc.nextLong();\\n if (n % 2 == 0)\\n out.println((n - 3) + \\\" \\\" + (2) + \\\" \\\" + (1));\\n else {\\n long a = n \\/ 2 + 1;\\n long b = n \\/ 2 - 1;\\n if (a % 2 == 0) {\\n a++;\\n b--;\\n }\\n long c = 1;\\n out.println(a + \\\" \\\" + b + \\\" \\\" + c);\\n }\\n }\\n \\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\n out.close();\\n\\n }\\n\\n static long power(long x, long y, long p) {\\n long res = 1;\\n x = x % p;\\n if (x == 0)\\n return 0;\\n while (y > 0) {\\n if ((y & 1) != 0)\\n res = (res * x) % p;\\n y = y >> 1;\\n x = (x * x) % p;\\n }\\n return res;\\n }\\n\\n static void sortI(int[] arr) {\\n int n = arr.length;\\n Random rnd = new Random();\\n for (int i = 0; i < n; ++i) {\\n int tmp = arr[i];\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Consider the following problem: given an array a containing n integers (indexed from 0 to n-1), find max_{0 ≤ l ≤ r ≤ n-1} ∑_{l ≤ i ≤ r} (r-l+1) ⋅ a_i. In this problem, 1 ≤ n ≤ 2 000 and |a_i| ≤ 10^6.\\n\\nIn an attempt to solve the problem described, Alice quickly came up with a blazing-fast greedy algorithm and coded it. Her implementation in pseudocode is as follows:\\n \\n \\n \\n function find_answer(n, a) \\n # Assumes n is an integer between 1 and 2000, inclusive \\n # Assumes a is a list containing n integers: a[0], a[1], ..., a[n-1] \\n res = 0 \\n cur = 0 \\n k = -1 \\n for i = 0 to i = n-1 \\n cur = cur + a[i] \\n if cur < 0 \\n cur = 0 \\n k = i \\n res = max(res, (i-k)*cur) \\n return res \\n \\n \\n\\nAlso, as you can see, Alice's idea is not entirely correct. For example, suppose n = 4 and a = [6, -8, 7, -42]. Then, find_answer(n, a) would return 7, but the correct answer is 3 ⋅ (6-8+7) = 15.\\n\\nYou told Alice that her solution is incorrect, but she did not believe what you said.\\n\\nGiven an integer k, you are to find any sequence a of n integers such that the correct answer and the answer produced by Alice's algorithm differ by exactly k. Note that although the choice of n and the content of the sequence is yours, you must still follow the constraints earlier given: that 1 ≤ n ≤ 2 000 and that the absolute value of each element does not exceed 10^6. If there is no such sequence, determine so.\\n\\nInput\\n\\nThe first and only line contains one integer k (1 ≤ k ≤ 10^9).\\n\\nOutput\\n\\nIf there is no sought sequence, print \\\"-1\\\".\\n\\nOtherwise, in the first line, print one integer n (1 ≤ n ≤ 2 000), denoting the number of elements in the sequence.\\n\\nThen, in the second line, print n space-separated integers: a_0, a_1, …, a_{n-1} (|a_i| ≤ 10^6).\\n\\nExamples\\n\\nInput\\n\\n\\n8\\n\\n\\nOutput\\n\\n\\n4\\n6 -8 7 -42\\n\\n\\nInput\\n\\n\\n612\\n\\n\\nOutput\\n\\n\\n7\\n30 -12 -99 123 -2 245 -300\\n\\nNote\\n\\nThe first sample corresponds to the example given in the problem...\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\nimport java.math.*;\\nimport java.util.Comparator;\\npublic class Main\\n{\\n public static void main(String[] args)throws IOException {\\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\\n int k = Integer.parseInt(br.readLine());\\n System.out.println(2000);\\n System.out.print(-1+\\\" \\\");\\n int S = k + 2000;\\n int div = (S+1)\\/1999;\\n for(int i=2;i<=2000;i++){\\n if(S >= 1000000){\\n System.out.print(1000000+\\\" \\\");\\n S -= 1000000;\\n }\\n else{\\n System.out.print(S+\\\" \\\");\\n S = 0;\\n }\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in PYTHON3?\\nAlice and Bob are playing a game on a matrix, consisting of 2 rows and m columns. The cell in the i-th row in the j-th column contains a_{i, j} coins in it.\\n\\nInitially, both Alice and Bob are standing in a cell (1, 1). They are going to perform a sequence of moves to reach a cell (2, m).\\n\\nThe possible moves are: \\n\\n * Move right — from some cell (x, y) to (x, y + 1); \\n * Move down — from some cell (x, y) to (x + 1, y). \\n\\n\\n\\nFirst, Alice makes all her moves until she reaches (2, m). She collects the coins in all cells she visit (including the starting cell).\\n\\nWhen Alice finishes, Bob starts his journey. He also performs the moves to reach (2, m) and collects the coins in all cells that he visited, but Alice didn't.\\n\\nThe score of the game is the total number of coins Bob collects.\\n\\nAlice wants to minimize the score. Bob wants to maximize the score. What will the score of the game be if both players play optimally?\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.\\n\\nThen the descriptions of t testcases follow.\\n\\nThe first line of the testcase contains a single integer m (1 ≤ m ≤ 10^5) — the number of columns of the matrix.\\n\\nThe i-th of the next 2 lines contain m integers a_{i,1}, a_{i,2}, ..., a_{i,m} (1 ≤ a_{i,j} ≤ 10^4) — the number of coins in the cell in the i-th row in the j-th column of the matrix.\\n\\nThe sum of m over all testcases doesn't exceed 10^5.\\n\\nOutput\\n\\nFor each testcase print a single integer — the score of the game if both players play optimally.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n3\\n1 3 7\\n3 5 1\\n3\\n1 3 9\\n3 5 1\\n1\\n4\\n7\\n\\n\\nOutput\\n\\n\\n7\\n8\\n0\\n\\nNote\\n\\nThe paths for the testcases are shown on the following pictures. Alice's path is depicted in red and Bob's path is depicted in blue.\\n\\n\",\"targets\":\"sr=lambda: input()\\nir=lambda: int(sr())\\nlr=lambda: list(map(int, sr().split()))\\n\\ninf=10**18\\n# mod=10**9+7\\nmod = 998244353\\n\\nif __name__=='__main__':\\n test = ir()\\n for t in range(test):\\n m=ir()\\n a1 = lr()\\n a2 = lr()\\n aa1 = [0]\\n aa2 = [0]\\n for i in range(m):\\n aa1.append(aa1[-1]+a1[i])\\n aa2.append(aa2[-1]+a2[i])\\n ans = inf\\n pre = 0\\n for i in range(m):\\n uans = aa1[m]-aa1[i+1]\\n dans = aa2[i]-aa2[0]\\n pre = max(uans, dans)\\n ans = min(ans, pre)\\n print(ans)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"During the hypnosis session, Nicholas suddenly remembered a positive integer n, which doesn't contain zeros in decimal notation. \\n\\nSoon, when he returned home, he got curious: what is the maximum number of digits that can be removed from the number so that the number becomes not prime, that is, either composite or equal to one?\\n\\nFor some numbers doing so is impossible: for example, for number 53 it's impossible to delete some of its digits to obtain a not prime integer. However, for all n in the test cases of this problem, it's guaranteed that it's possible to delete some of their digits to obtain a not prime number.\\n\\nNote that you cannot remove all the digits from the number.\\n\\nA prime number is a number that has no divisors except one and itself. A composite is a number that has more than two divisors. 1 is neither a prime nor a composite number.\\n\\nInput\\n\\nEach test contains multiple test cases.\\n\\nThe first line contains one positive integer t (1 ≤ t ≤ 10^3), denoting the number of test cases. Description of the test cases follows.\\n\\nThe first line of each test case contains one positive integer k (1 ≤ k ≤ 50) — the number of digits in the number.\\n\\nThe second line of each test case contains a positive integer n, which doesn't contain zeros in decimal notation (10^{k-1} ≤ n < 10^{k}). It is guaranteed that it is always possible to remove less than k digits to make the number not prime.\\n\\nIt is guaranteed that the sum of k over all test cases does not exceed 10^4.\\n\\nOutput\\n\\nFor every test case, print two numbers in two lines. In the first line print the number of digits, that you have left in the number. In the second line print the digits left after all delitions. \\n\\nIf there are multiple solutions, print any.\\n\\nExample\\n\\nInput\\n\\n\\n7\\n3\\n237\\n5\\n44444\\n3\\n221\\n2\\n35\\n3\\n773\\n1\\n4\\n30\\n626221626221626221626221626221\\n\\n\\nOutput\\n\\n\\n2\\n27\\n1\\n4\\n1\\n1\\n2\\n35\\n2\\n77\\n1\\n4\\n1\\n6\\n\\nNote\\n\\nIn the first test case, you can't delete 2 digits from the number 237, as all the numbers 2, 3, and 7 are prime. However, you can delete 1 digit, obtaining a number 27 =...\",\"targets\":\"#include \\n#pragma GCC optimize(\\\"unroll-loops\\\")\\n#pragma GCC optimize(\\\"O3\\\")\\n#pragma GCC target(\\\"avx2\\\")\\nusing namespace std;\\ntemplate \\nvoid debug(vector& arr) {\\n cerr << \\\"[ \\\";\\n for (auto& i : arr) {\\n cerr << i << \\\" \\\";\\n }\\n cerr << \\\"]\\\" << endl;\\n}\\ntemplate \\nvoid debug(T& a) {\\n cerr << a << endl;\\n}\\ntemplate \\nostream& operator<<(ostream& out, pair& P) {\\n cout << \\\"{\\\" << P.first << \\\", \\\" << P.second << \\\"}\\\";\\n return out;\\n}\\ntemplate \\nvoid debug(pair& P) {\\n cerr << \\\"{\\\" << P.first << \\\", \\\" << P.second << \\\"}\\\" << endl;\\n}\\nstring prime = \\\"2357\\\";\\nbool isPrime(long long X) {\\n for (long long i = 2; i * i <= X; i++) {\\n if (X % i == 0) return false;\\n }\\n return true;\\n}\\nvoid solve() {\\n long long n;\\n cin >> n;\\n string s;\\n cin >> s;\\n map cnt;\\n for (auto& i : s) {\\n if (!binary_search(prime.begin(), prime.end(), i)) {\\n cout << 1 << endl;\\n cout << i << endl;\\n return;\\n } else {\\n cnt[i]++;\\n }\\n }\\n for (auto& i : cnt) {\\n if (i.second >= 2) {\\n cout << 2 << endl;\\n cout << i.first << i.first << endl;\\n return;\\n }\\n }\\n string::iterator it = unique(s.begin(), s.end());\\n s.resize(distance(s.begin(), it));\\n for (long long i = 0; i < n; i++) {\\n for (long long j = 0; j < n; j++) {\\n if (j != i) {\\n string T;\\n T += s[i];\\n T += s[j];\\n long long X = stoi(T);\\n if (!isPrime(X)) {\\n cout << T.size() << endl;\\n cout << T << endl;\\n return;\\n }\\n }\\n }\\n }\\n}\\nsigned main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n clock_t begin = clock();\\n long long t = 1;\\n cin >> t;\\n for (long long i = 0; i < t; i++) {\\n cerr << \\\"Testcase #\\\" << i + 1 << endl;\\n solve();\\n cerr << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"A kindergarten teacher Natalia Pavlovna has invented a new ball game. This game not only develops the children's physique, but also teaches them how to count. \\n\\nThe game goes as follows. Kids stand in circle. Let's agree to think of the children as numbered with numbers from 1 to n clockwise and the child number 1 is holding the ball. First the first child throws the ball to the next one clockwise, i.e. to the child number 2. Then the child number 2 throws the ball to the next but one child, i.e. to the child number 4, then the fourth child throws the ball to the child that stands two children away from him, i.e. to the child number 7, then the ball is thrown to the child who stands 3 children away from the child number 7, then the ball is thrown to the child who stands 4 children away from the last one, and so on. It should be mentioned that when a ball is thrown it may pass the beginning of the circle. For example, if n = 5, then after the third throw the child number 2 has the ball again. Overall, n - 1 throws are made, and the game ends.\\n\\nThe problem is that not all the children get the ball during the game. If a child doesn't get the ball, he gets very upset and cries until Natalia Pavlovna gives him a candy. That's why Natalia Pavlovna asks you to help her to identify the numbers of the children who will get the ball after each throw.\\n\\nInput\\n\\nThe first line contains integer n (2 ≤ n ≤ 100) which indicates the number of kids in the circle.\\n\\nOutput\\n\\nIn the single line print n - 1 numbers which are the numbers of children who will get the ball after each throw. Separate the numbers by spaces.\\n\\nExamples\\n\\nInput\\n\\n10\\n\\n\\nOutput\\n\\n2 4 7 1 6 2 9 7 6\\n\\n\\nInput\\n\\n3\\n\\n\\nOutput\\n\\n2 1\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int n, cur = 1;\\n cin >> n;\\n for (int i = 1; i <= n - 1; i++) {\\n cur = (cur + i);\\n if (cur > n) cur -= n;\\n if (i == 1)\\n cout << cur;\\n else\\n cout << \\\" \\\" << cur;\\n }\\n cout << endl;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nIn the rush of modern life, people often forget how beautiful the world is. The time to enjoy those around them is so little that some even stand in queues to several rooms at the same time in the clinic, running from one queue to another.\\n\\n(Cultural note: standing in huge and disorganized queues for hours is a native tradition in Russia, dating back to the Soviet period. Queues can resemble crowds rather than lines. Not to get lost in such a queue, a person should follow a strict survival technique: you approach the queue and ask who the last person is, somebody answers and you join the crowd. Now you're the last person in the queue till somebody else shows up. You keep an eye on the one who was last before you as he is your only chance to get to your destination) I'm sure many people have had the problem when a stranger asks who the last person in the queue is and even dares to hint that he will be the last in the queue and then bolts away to some unknown destination. These are the representatives of the modern world, in which the ratio of lack of time is so great that they do not even watch foreign top-rated TV series. Such people often create problems in queues, because the newcomer does not see the last person in the queue and takes a place after the \\\"virtual\\\" link in this chain, wondering where this legendary figure has left.\\n\\nThe Smart Beaver has been ill and he's made an appointment with a therapist. The doctor told the Beaver the sad news in a nutshell: it is necessary to do an electrocardiogram. The next day the Smart Beaver got up early, put on the famous TV series on download (three hours till the download's complete), clenched his teeth and bravely went to join a queue to the electrocardiogram room, which is notorious for the biggest queues at the clinic.\\n\\nHaving stood for about three hours in the queue, the Smart Beaver realized that many beavers had not seen who was supposed to stand in the queue before them and there was a huge mess. He came up to each beaver in the ECG room queue and asked...\",\"targets\":\"#include \\nusing namespace std;\\nbool vis[1010], f[1010], b[1010];\\nint d[1010], a[1010];\\nvoid dfs(int x) {\\n if (x == 0) return;\\n vis[x] = true;\\n if (!vis[a[x]]) dfs(a[x]);\\n d[x] = d[a[x]] + 1;\\n}\\nint main() {\\n int n, k;\\n scanf(\\\"%d%d\\\", &n, &k);\\n for (int i = 1; i <= n; i++) scanf(\\\"%d\\\", &a[i]), b[a[i]] = true;\\n for (int i = 1; i <= n; i++) {\\n if (!vis[i]) dfs(i);\\n }\\n for (int i = 1; i <= n; i++) {\\n if (b[i]) continue;\\n int temp = i;\\n bool flag = false;\\n while (temp) {\\n if (temp == k) flag = true;\\n temp = a[temp];\\n }\\n if (flag) b[i] = true;\\n }\\n f[d[k]] = true;\\n for (int j = 1; j <= n; j++) {\\n if (b[j]) continue;\\n for (int i = n; i >= d[k] + d[j]; i--) {\\n f[i] |= f[i - d[j]];\\n }\\n }\\n for (int i = 1; i <= n; i++)\\n if (f[i]) printf(\\\"%d \\\", i);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nIt is the easy version of the problem. The only difference is that in this version n = 1.\\n\\nIn the cinema seats can be represented as the table with n rows and m columns. The rows are numbered with integers from 1 to n. The seats in each row are numbered with consecutive integers from left to right: in the k-th row from m (k - 1) + 1 to m k for all rows 1 ≤ k ≤ n.\\n\\n1| 2| ⋅⋅⋅| m - 1| m \\n---|---|---|---|--- \\nm + 1| m + 2| ⋅⋅⋅| 2 m - 1| 2 m \\n2m + 1| 2m + 2| ⋅⋅⋅| 3 m - 1| 3 m \\n\\\\vdots| \\\\vdots| \\\\ddots| \\\\vdots| \\\\vdots \\nm (n - 1) + 1| m (n - 1) + 2| ⋅⋅⋅| n m - 1| n m \\nThe table with seats indices\\n\\nThere are nm people who want to go to the cinema to watch a new film. They are numbered with integers from 1 to nm. You should give exactly one seat to each person.\\n\\nIt is known, that in this cinema as lower seat index you have as better you can see everything happening on the screen. i-th person has the level of sight a_i. Let's define s_i as the seat index, that will be given to i-th person. You want to give better places for people with lower sight levels, so for any two people i, j such that a_i < a_j it should be satisfied that s_i < s_j.\\n\\nAfter you will give seats to all people they will start coming to their seats. In the order from 1 to nm, each person will enter the hall and sit in their seat. To get to their place, the person will go to their seat's row and start moving from the first seat in this row to theirs from left to right. While moving some places will be free, some will be occupied with people already seated. The inconvenience of the person is equal to the number of occupied seats he or she will go through.\\n\\nLet's consider an example: m = 5, the person has the seat 4 in the first row, the seats 1, 3, 5 in the first row are already occupied, the seats 2 and 4 are free. The inconvenience of this person will be 2, because he will go through occupied seats 1 and 3.\\n\\nFind the minimal total inconvenience (the sum of inconveniences of all people), that is possible to have by giving places for all people...\",\"targets\":\"import java.io.*;\\n\\n\\n\\timport java.util.*;\\nimport java.util.concurrent.PriorityBlockingQueue;\\n\\n\\n\\tpublic class Aqueous {\\n\\t\\t\\n\\t\\tstatic MyScanner sc = new MyScanner();\\n\\t\\t\\n\\t\\tstatic class pair{\\n\\n\\t\\t\\t\\n\\t\\t\\tlong num;\\n\\t\\t\\tint ind;\\n\\t\\t\\t\\n\\t\\t\\t\\tpublic pair(long num, int ind) {\\n\\t\\t\\t\\t\\tthis.num = num;\\n\\t\\t\\t\\t\\tthis.ind = ind;\\n\\t\\t\\t\\t}\\n\\t\\t}\\n\\t\\t\\n\\t\\t\\n\\t\\tpublic static void main(String[] args) {\\n\\t\\n\\t\\t\\t\\n\\t\\t\\tint t = sc.nextInt();\\n\\t\\t\\t\\n\\t\\t\\t\\twhile(t-->0) {\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\tint n = sc.nextInt();\\n\\t\\t\\t\\t\\tint m = sc.nextInt();\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\tint eye[] = new int[m];\\n\\t\\t\\t\\t\\tint temp[] = new int[m];\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\tfor(int i = 0; i> hm = new HashMap>();\\n\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\tfor(int i = 0; i(Collections.reverseOrder()));\\n\\t\\t\\t\\t\\t\\t\\t\\thm.get(temp[i]).add(i+1);\\n\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\tboolean vis[] = new boolean[m+1];\\n\\t\\t\\t\\t\\t\\tlong ans = 0;\\n\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\tfor(int i =0; i=1; j--) {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tif(vis[j]==true) {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tans++;\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\tSystem.out.println(ans);\\n\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t}\\n\\t\\t}\\n\\t\\t \\t\\t\\n\\t\\tstatic void ruffleSort(int a[]) {\\n\\n\\t int n = a.length;\\n\\n\\t Random r = new Random();\\n\\n\\t for (int i = 0; i < n; i++) {\\n\\n\\t int oi = r.nextInt(n);\\n\\t int temp = a[oi];\\n\\t a[oi] = a[i];\\n\\t a[i] = temp;\\n\\t }\\n\\n\\t Arrays.sort(a);\\n\\t }\\n\\t\\t\\n\\t\\t\\n\\t\\tstatic void ruffleSort(long a[]) {\\n\\n\\t int n = a.length;\\n\\n\\t Random r = new Random();\\n\\n\\t for (int i = 0; i < n; i++) {\\n\\t int oi = r.nextInt(n);\\n\\n\\t long temp = a[oi];\\n\\t a[oi] = a[i];\\n\\t ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nYou are given two positive integers n and s. Find the maximum possible median of an array of n non-negative integers (not necessarily distinct), such that the sum of its elements is equal to s.\\n\\nA median of an array of integers of length m is the number standing on the ⌈ {m\\/2} ⌉-th (rounding up) position in the non-decreasing ordering of its elements. Positions are numbered starting from 1. For example, a median of the array [20,40,20,50,50,30] is the ⌈ m\\/2 ⌉-th element of [20,20,30,40,50,50], so it is 30. There exist other definitions of the median, but in this problem we use the described definition.\\n\\nInput\\n\\nThe input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. Description of the test cases follows.\\n\\nEach test case contains a single line with two integers n and s (1 ≤ n, s ≤ 10^9) — the length of the array and the required sum of the elements.\\n\\nOutput\\n\\nFor each test case print a single integer — the maximum possible median.\\n\\nExample\\n\\nInput\\n\\n\\n8\\n1 5\\n2 5\\n3 5\\n2 1\\n7 17\\n4 14\\n1 1000000000\\n1000000000 1\\n\\n\\nOutput\\n\\n\\n5\\n2\\n2\\n0\\n4\\n4\\n1000000000\\n0\\n\\nNote\\n\\nPossible arrays for the first three test cases (in each array the median is underlined):\\n\\n * In the first test case [\\\\underline{5}] \\n * In the second test case [\\\\underline{2}, 3] \\n * In the third test case [1, \\\\underline{2}, 2]\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.util.StringTokenizer;\\nimport java.util.Arrays;\\nimport java.util.ArrayList;\\nimport java.util.Comparator;\\nimport java.util.HashMap;\\nimport java.util.HashSet;\\nimport java.util.TreeSet;\\nimport java.util.TreeMap;\\nimport java.util.PriorityQueue;\\n\\nimport java.util.Iterator;\\n\\npublic class First {\\n\\n public static void main(String[] args) {\\n FastScanner fs = new FastScanner();\\n int T = fs.nextInt();\\n for (int tt = 0; tt < T; tt++) {\\n\\n solve(fs);\\n }\\n }\\n static void solve(FastScanner fs)\\n {\\n int n=fs.nextInt(), s=fs.nextInt();\\n\\n int left=-1;\\n if(n%2==0)\\n {\\n left=n\\/2-1;\\n }\\n else\\n left=n\\/2;\\n\\n pn((s)\\/(n-left));\\n \\n }\\n static int MOD=(int)(1e9+7);\\n \\n static long gcd(long a, long b) \\n {\\n if (a == 0)\\n return b; \\n return gcd(b%a, a);\\n }\\n static void pn(Object o) { System.out.println(o); } \\n static void p(Object o) { System.out.print(o); }\\n static void flush() { System.out.flush(); }\\n\\n static void debugInt(int[] arr)\\n {\\n for(int i=0;i 1 at some moment. One shift of the token can have either of the following kinds: \\n\\n * Subtraction: you choose an integer y between 1 and x-1, inclusive, and move the token from cell x to cell x - y. \\n * Floored division: you choose an integer z between 2 and x, inclusive, and move the token from cell x to cell ⌊ x\\/z ⌋ (x divided by z rounded down). \\n\\n\\n\\nFind the number of ways to move the token from cell n to cell 1 using one or more shifts, and print it modulo m. Note that if there are several ways to move the token from one cell to another in one shift, all these ways are considered distinct (check example explanation for a better understanding).\\n\\nInput\\n\\nThe only line contains two integers n and m (2 ≤ n ≤ 4 ⋅ 10^6; 10^8 < m < 10^9; m is a prime number) — the length of the strip and the modulo.\\n\\nOutput\\n\\nPrint the number of ways to move the token from cell n to cell 1, modulo m.\\n\\nExamples\\n\\nInput\\n\\n\\n3 998244353\\n\\n\\nOutput\\n\\n\\n5\\n\\n\\nInput\\n\\n\\n5 998244353\\n\\n\\nOutput\\n\\n\\n25\\n\\n\\nInput\\n\\n\\n42 998244353\\n\\n\\nOutput\\n\\n\\n793019428\\n\\n\\nInput\\n\\n\\n787788 100000007\\n\\n\\nOutput\\n\\n\\n94810539\\n\\nNote\\n\\nIn the first test, there are three ways to move the token from cell 3 to cell 1 in one shift: using subtraction of y = 2, or using division by z = 2 or z = 3.\\n\\nThere are also two ways to move the token from cell 3 to cell 1 via cell 2: first subtract y = 1, and then either subtract y = 1 again or divide by z = 2.\\n\\nTherefore, there are five ways in total.\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst long long maxn = 4e6 + 10;\\nlong long mod, n;\\nlong long f[maxn], g[maxn];\\nint main() {\\n scanf(\\\"%lld\\\", &n), scanf(\\\"%lld\\\", &mod);\\n f[1] = 1;\\n long long sum = 0;\\n for (long long i = 2; i <= n; ++i) {\\n g[i] += g[i - 1] + 1;\\n sum += f[i - 1];\\n f[i] = sum + g[i];\\n f[i] %= mod;\\n for (long long j = 2; j * i <= n; ++j) {\\n g[i * j] += f[i] - f[i - 1];\\n g[i * j] = (g[i * j] + mod) % mod;\\n }\\n }\\n printf(\\\"%lld\\\\n\\\", f[n] % mod);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A dragon symbolizes wisdom, power and wealth. On Lunar New Year's Day, people model a dragon with bamboo strips and clothes, raise them with rods, and hold the rods high and low to resemble a flying dragon.\\n\\nA performer holding the rod low is represented by a 1, while one holding it high is represented by a 2. Thus, the line of performers can be represented by a sequence a1, a2, ..., an.\\n\\nLittle Tommy is among them. He would like to choose an interval [l, r] (1 ≤ l ≤ r ≤ n), then reverse al, al + 1, ..., ar so that the length of the longest non-decreasing subsequence of the new sequence is maximum.\\n\\nA non-decreasing subsequence is a sequence of indices p1, p2, ..., pk, such that p1 < p2 < ... < pk and ap1 ≤ ap2 ≤ ... ≤ apk. The length of the subsequence is k.\\n\\nInput\\n\\nThe first line contains an integer n (1 ≤ n ≤ 2000), denoting the length of the original sequence.\\n\\nThe second line contains n space-separated integers, describing the original sequence a1, a2, ..., an (1 ≤ ai ≤ 2, i = 1, 2, ..., n).\\n\\nOutput\\n\\nPrint a single integer, which means the maximum possible length of the longest non-decreasing subsequence of the new sequence.\\n\\nExamples\\n\\nInput\\n\\n4\\n1 2 1 2\\n\\n\\nOutput\\n\\n4\\n\\n\\nInput\\n\\n10\\n1 1 2 2 2 1 1 2 2 1\\n\\n\\nOutput\\n\\n9\\n\\nNote\\n\\nIn the first example, after reversing [2, 3], the array will become [1, 1, 2, 2], where the length of the longest non-decreasing subsequence is 4.\\n\\nIn the second example, after reversing [3, 7], the array will become [1, 1, 1, 1, 2, 2, 2, 2, 2, 1], where the length of the longest non-decreasing subsequence is 9.\\nimpor\",\"targets\":\"t java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStream;\\nimport java.io.InputStreamReader;\\nimport java.util.Arrays;\\nimport java.util.StringTokenizer;\\n\\npublic class C {\\n\\n\\tpublic static void main(String[] args) throws IOException {\\n\\t\\tScanner sc=new Scanner(System.in);\\n\\t\\tint n=sc.nextInt();\\n\\t\\tint []a=new int [n];\\n\\t\\tint []v=new int [n];\\n\\t\\tint twos=0;\\n\\t\\tfor(int i=0;i 0)\\n \\t{\\n \\t\\tt--;\\n \\t\\tm = r.nextInt();\\n \\t\\tn = r.nextInt();\\n \\t\\tp = new long[m][n];\\n \\t\\tfor (int i = 0; i < m; i ++)\\n \\t\\t{\\n \\t\\t\\tfor (int j = 0; j < n; j ++)\\n \\t\\t\\t{\\n \\t\\t\\t\\tp[i][j] = r.nextLong();\\n \\t\\t\\t}\\n \\t\\t}\\n \\t\\tint shops = Math.min(m, n-1);\\n \\t\\tif (m <= n - 1)\\n \\t\\t{\\n \\t\\t\\tlong min = Integer.MAX_VALUE;\\n \\t\\t\\tfor (int j = 0; j < n; j ++)\\n \\t\\t\\t{\\n \\t\\t\\t\\tlong max = 0;\\n \\t\\t\\t\\tfor (int i = 0; i < m; i ++)\\n \\t\\t\\t\\t{\\n \\t\\t\\t\\t\\tmax = Math.max(max, p[i][j]);\\n \\t\\t\\t\\t}\\n \\t\\t\\t\\tmin = Math.min(min, max);\\n \\t\\t\\t}\\n \\t\\t\\tpw.println(min);\\n \\t\\t}\\n \\t\\telse\\n \\t\\t{\\n \\t\\t\\tpw.println(lastTrue(1,2000000000));\\n \\t\\t}\\n \\t}\\n pw.close();\\n }\\n static...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nYou are given a tree with n nodes. As a reminder, a tree is a connected undirected graph without cycles.\\n\\nLet a_1, a_2, …, a_n be a sequence of integers. Perform the following operation exactly n times: \\n\\n * Select an unerased node u. Assign a_u := number of unerased nodes adjacent to u. Then, erase the node u along with all edges that have it as an endpoint. \\n\\n\\n\\nFor each integer k from 1 to n, find the number, modulo 998 244 353, of different sequences a_1, a_2, …, a_n that satisfy the following conditions:\\n\\n * it is possible to obtain a by performing the aforementioned operations exactly n times in some order. \\n * \\\\operatorname{gcd}(a_1, a_2, …, a_n) = k. Here, \\\\operatorname{gcd} means the greatest common divisor of the elements in a. \\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10 000) — the number of test cases.\\n\\nThe first line of each test case contains a single integer n (2 ≤ n ≤ 10^5).\\n\\nEach of the next n - 1 lines contains two integers u and v (1 ≤ u, v ≤ n) indicating there is an edge between vertices u and v. It is guaranteed that the given edges form a tree.\\n\\nIt is guaranteed that the sum of n over all test cases doesn't exceed 3 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print n integers in a single line, where for each k from 1 to n, the k-th integer denotes the answer when \\\\operatorname{gcd} equals to k.\\n\\nExample\\n\\nInput\\n\\n\\n2\\n3\\n2 1\\n1 3\\n2\\n1 2\\n\\n\\nOutput\\n\\n\\n3 1 0\\n2 0\\n\\nNote\\n\\nIn the first test case, \\n\\n\\n\\n * If we delete the nodes in order 1 → 2 → 3 or 1 → 3 → 2, then the obtained sequence will be a = [2, 0, 0] which has \\\\operatorname{gcd} equals to 2. \\n * If we delete the nodes in order 2 → 1 → 3, then the obtained sequence will be a = [1, 1, 0] which has \\\\operatorname{gcd} equals to 1. \\n * If we delete the nodes in order 3 → 1 → 2, then the obtained sequence will be a = [1, 0, 1] which has \\\\operatorname{gcd} equals to 1. \\n * If we delete the nodes in order 2 → 3 → 1 or 3 → 2 → 1, then the obtained sequence will be a = [0, 1, 1] which has \\\\operatorname{gcd} equals to 1. \\n\\n\\n\\nNote...\",\"targets\":\"#include \\nusing namespace std;\\nconst int M = 998244353;\\nint Tc, n, ans[100004], dp[100004];\\nvector g[100004];\\nbool ok;\\nvoid dfs(int x, int par, int C) {\\n if (!ok) return;\\n for (auto y : g[x])\\n if (y != par) dfs(y, x, C);\\n if (dp[x] % C != 0) {\\n if (par) dp[x]++;\\n if (dp[x] % C != 0) {\\n ok = 0;\\n return;\\n }\\n } else\\n dp[par]++;\\n}\\nvoid solve() {\\n scanf(\\\"%d\\\", &n);\\n for (int i = 1; i <= n; i++) g[i].clear();\\n for (int i = 1; i < n; i++) {\\n int u, v;\\n scanf(\\\"%d%d\\\", &u, &v);\\n g[u].push_back(v), g[v].push_back(u);\\n }\\n for (int i = 1; i <= n; i++) ans[i] = 0;\\n ans[1] = 1;\\n for (int i = 1; i < n; i++) ans[1] = (ans[1] + ans[1]) % M;\\n for (int i = 2; i <= n - 1; i++)\\n if ((n - 1) % i == 0) {\\n for (int j = 0; j <= n; j++) dp[j] = 0;\\n ok = 1, dfs(1, 0, i), ans[i] = ok;\\n }\\n for (int i = n; i; i--)\\n for (int j = i + i; j <= n; j += i) ans[i] = (ans[i] - ans[j] + M) % M;\\n for (int i = 1; i <= n; i++) printf(\\\"%d \\\", ans[i]);\\n puts(\\\"\\\");\\n}\\nint main() {\\n for (scanf(\\\"%d\\\", &Tc); Tc--;) solve();\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given n integers a_1, a_2, …, a_n. Find the maximum value of max(a_l, a_{l + 1}, …, a_r) ⋅ min(a_l, a_{l + 1}, …, a_r) over all pairs (l, r) of integers for which 1 ≤ l < r ≤ n.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10 000) — the number of test cases.\\n\\nThe first line of each test case contains a single integer n (2 ≤ n ≤ 10^5).\\n\\nThe second line of each test case contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^6).\\n\\nIt is guaranteed that the sum of n over all test cases doesn't exceed 3 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print a single integer — the maximum possible value of the product from the statement.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n2 4 3\\n4\\n3 2 3 1\\n2\\n69 69\\n6\\n719313 273225 402638 473783 804745 323328\\n\\n\\nOutput\\n\\n\\n12\\n6\\n4761\\n381274500335\\n\\nNote\\n\\nLet f(l, r) = max(a_l, a_{l + 1}, …, a_r) ⋅ min(a_l, a_{l + 1}, …, a_r).\\n\\nIn the first test case, \\n\\n * f(1, 2) = max(a_1, a_2) ⋅ min(a_1, a_2) = max(2, 4) ⋅ min(2, 4) = 4 ⋅ 2 = 8. \\n * f(1, 3) = max(a_1, a_2, a_3) ⋅ min(a_1, a_2, a_3) = max(2, 4, 3) ⋅ min(2, 4, 3) = 4 ⋅ 2 = 8. \\n * f(2, 3) = max(a_2, a_3) ⋅ min(a_2, a_3) = max(4, 3) ⋅ min(4, 3) = 4 ⋅ 3 = 12. \\n\\n\\n\\nSo the maximum is f(2, 3) = 12.\\n\\nIn the second test case, the maximum is f(1, 2) = f(1, 3) = f(2, 3) = 6.\",\"targets\":\"import java.util.*;\\npublic class class20 {\\n public static void main(String args[])\\n {\\n Scanner sc=new Scanner(System.in);\\n \\n int t=sc.nextInt();\\n while(t-->0)\\n {\\n \\tint i,j,n;\\n n=sc.nextInt();\\n int a[]=new int[n];\\n for(i=0;ires)\\n {\\n \\n res=ans;\\n }\\n }\\n System.out.println(res);\\n }\\n \\n \\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"\\n\\nWilliam is not only interested in trading but also in betting on sports matches. n teams participate in each match. Each team is characterized by strength a_i. Each two teams i < j play with each other exactly once. Team i wins with probability (a_i)\\/(a_i + a_j) and team j wins with probability (a_j)\\/(a_i + a_j).\\n\\nThe team is called a winner if it directly or indirectly defeated all other teams. Team a defeated (directly or indirectly) team b if there is a sequence of teams c_1, c_2, ... c_k such that c_1 = a, c_k = b and team c_i defeated team c_{i + 1} for all i from 1 to k - 1. Note that it is possible that team a defeated team b and in the same time team b defeated team a.\\n\\nWilliam wants you to find the expected value of the number of winners.\\n\\nInput\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 14), which is the total number of teams participating in a match.\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^6) — the strengths of teams participating in a match.\\n\\nOutput\\n\\nOutput a single integer — the expected value of the number of winners of the tournament modulo 10^9 + 7.\\n\\nFormally, let M = 10^9+7. It can be demonstrated that the answer can be presented as a irreducible fraction p\\/q, where p and q are integers and q not ≡ 0 \\\\pmod{M}. Output a single integer equal to p ⋅ q^{-1} mod M. In other words, output an integer x such that 0 ≤ x < M and x ⋅ q ≡ p \\\\pmod{M}.\\n\\nExamples\\n\\nInput\\n\\n\\n2\\n1 2\\n\\n\\nOutput\\n\\n\\n1\\n\\n\\nInput\\n\\n\\n5\\n1 5 2 11 14\\n\\n\\nOutput\\n\\n\\n642377629\\n\\nNote\\n\\nTo better understand in which situation several winners are possible let's examine the second test:\\n\\nOne possible result of the tournament is as follows (a → b means that a defeated b):\\n\\n * 1 → 2 \\n * 2 → 3 \\n * 3 → 1 \\n * 1 → 4 \\n * 1 → 5 \\n * 2 → 4 \\n * 2 → 5 \\n * 3 → 4 \\n * 3 → 5 \\n * 4 → 5 \\n\\n\\n\\nOr more clearly in the picture:\\n\\n\\n\\nIn this case every team from the set \\\\{ 1, 2, 3 \\\\} directly or indirectly defeated everyone. I.e.:\\n\\n * 1st defeated everyone because they can get to everyone else in the following way...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst long long mod = (long long)1e9 + 7;\\nlong long binpow(long long a, long long b) {\\n if (b == 0) return 1;\\n long long ans = binpow(a, b \\/ 2);\\n ans = (1ll * ans * ans) % mod;\\n if (b & 1) ans = (1ll * ans * a) % mod;\\n return ans;\\n}\\nlong long INV(long long x) { return binpow(x, mod - 2); }\\ntemplate \\nvoid md(T &x) {\\n x %= mod;\\n if (x < 0) x += mod;\\n if (x >= mod) x -= mod;\\n}\\ntemplate \\nT mdd(T a) {\\n a %= mod;\\n if (a >= mod) a -= mod;\\n if (a < 0) a += mod;\\n return a;\\n}\\nconst long long B = 14;\\nlong long f[(1 << B) + 1], dp[(1 << B) + 1], m[B];\\nlong long win[B], lost[B];\\nlong long clrW[B], clrL[B];\\nlong long W[B][(1 << B) + 1], L[B][(1 << B) + 1];\\nsigned main() {\\n ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);\\n long long n;\\n cin >> n;\\n vector a(n);\\n for (auto &i : a) cin >> i;\\n for (long long i = 0; i < n; ++i) {\\n for (long long msk = 0; msk < (1 << n); ++msk) {\\n L[i][msk] = W[i][msk] = 1;\\n for (long long j = 0; j < n; ++j) {\\n if ((1 << j) & msk) {\\n W[i][msk] =\\n (1ll * W[i][msk] * a[i] % mod * INV(mdd(a[i] + a[j]))) % mod;\\n L[i][msk] =\\n (1ll * L[i][msk] * a[j] % mod * INV(mdd(a[i] + a[j]))) % mod;\\n }\\n }\\n }\\n }\\n for (long long msk = 0; msk < (1 << n); ++msk) {\\n if (__builtin_popcount(msk) == 1) {\\n f[msk] = 1;\\n continue;\\n }\\n if (msk == 0) continue;\\n long long tot = 0;\\n for (long long u = msk; u > 0; u = (u - 1) & msk) {\\n if (u != msk) {\\n long long cur = msk ^ u;\\n long long prob = 1;\\n for (long long x = 0; x < n; ++x) {\\n if ((1 << x) & cur) {\\n prob = (1ll * prob * W[x][u]) % mod;\\n }\\n }\\n tot += (1ll * prob * f[u]) % mod;\\n md(tot);\\n }\\n }\\n f[msk] = (1 - tot);\\n md(f[msk]);\\n }\\n long long ans = 0;\\n dp[0] = 1;\\n for (long long msk = 0; msk < (1 << n); ++msk) {\\n fill(m, m + B, 1);\\n for (long long x = 0; x < n; ++x) {\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Catherine received an array of integers as a gift for March 8. Eventually she grew bored with it, and she started calculated various useless characteristics for it. She succeeded to do it for each one she came up with. But when she came up with another one — xor of all pairwise sums of elements in the array, she realized that she couldn't compute it for a very large array, thus she asked for your help. Can you do it? Formally, you need to compute\\n\\n$$$ (a_1 + a_2) ⊕ (a_1 + a_3) ⊕ … ⊕ (a_1 + a_n) \\\\\\\\\\\\ ⊕ (a_2 + a_3) ⊕ … ⊕ (a_2 + a_n) \\\\\\\\\\\\ … \\\\\\\\\\\\ ⊕ (a_{n-1} + a_n) \\\\\\\\\\\\ $$$\\n\\nHere x ⊕ y is a bitwise XOR operation (i.e. x ^ y in many modern programming languages). You can read about it in Wikipedia: .\\n\\nInput\\n\\nThe first line contains a single integer n (2 ≤ n ≤ 400 000) — the number of integers in the array.\\n\\nThe second line contains integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^7).\\n\\nOutput\\n\\nPrint a single integer — xor of all pairwise sums of integers in the given array.\\n\\nExamples\\n\\nInput\\n\\n\\n2\\n1 2\\n\\n\\nOutput\\n\\n\\n3\\n\\nInput\\n\\n\\n3\\n1 2 3\\n\\n\\nOutput\\n\\n\\n2\\n\\nNote\\n\\nIn the first sample case there is only one sum 1 + 2 = 3.\\n\\nIn the second sample case there are three sums: 1 + 2 = 3, 1 + 3 = 4, 2 + 3 = 5. In binary they are represented as 011_2 ⊕ 100_2 ⊕ 101_2 = 010_2, thus the answer is 2.\\n\\n⊕ is the bitwise xor operation. To define x ⊕ y, consider binary representations of integers x and y. We put the i-th bit of the result to be 1 when exactly one of the i-th bits of x and y is 1. Otherwise, the i-th bit of the result is put to be 0. For example, 0101_2 ⊕ 0011_2 = 0110_2.\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint n, a[400009], ans;\\nvector v;\\nint solve(int x) { return upper_bound(v.begin(), v.end(), x) - v.begin(); }\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n cin >> n;\\n for (int i = 0; i < n; i++) cin >> a[i];\\n for (int i = 0; i <= 24; i++) {\\n v.clear();\\n for (int j = 0; j < n; j++) {\\n v.push_back(((1 << i + 1) - 1) & a[j]);\\n }\\n sort(v.begin(), v.end());\\n long long cnt = 0;\\n for (int j = 0; j < n; j++) {\\n int l = solve((1 << i) - 1 - v[j]) + 1,\\n r = solve((1 << (i + 1)) - 1 - v[j]);\\n cnt += (r - l + 1) - (j + 1 >= l && j + 1 <= r);\\n int val = (1 << i) + (1 << (i + 1));\\n cnt += n - solve(val - 1 - v[j]) - (2 * v[j] >= val);\\n }\\n cnt \\/= 2;\\n if (cnt % 2) ans += 1 << i;\\n }\\n cout << ans;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A kindergarten teacher Natalia Pavlovna has invented a new ball game. This game not only develops the children's physique, but also teaches them how to count. \\n\\nThe game goes as follows. Kids stand in circle. Let's agree to think of the children as numbered with numbers from 1 to n clockwise and the child number 1 is holding the ball. First the first child throws the ball to the next one clockwise, i.e. to the child number 2. Then the child number 2 throws the ball to the next but one child, i.e. to the child number 4, then the fourth child throws the ball to the child that stands two children away from him, i.e. to the child number 7, then the ball is thrown to the child who stands 3 children away from the child number 7, then the ball is thrown to the child who stands 4 children away from the last one, and so on. It should be mentioned that when a ball is thrown it may pass the beginning of the circle. For example, if n = 5, then after the third throw the child number 2 has the ball again. Overall, n - 1 throws are made, and the game ends.\\n\\nThe problem is that not all the children get the ball during the game. If a child doesn't get the ball, he gets very upset and cries until Natalia Pavlovna gives him a candy. That's why Natalia Pavlovna asks you to help her to identify the numbers of the children who will get the ball after each throw.\\n\\nInput\\n\\nThe first line contains integer n (2 ≤ n ≤ 100) which indicates the number of kids in the circle.\\n\\nOutput\\n\\nIn the single line print n - 1 numbers which are the numbers of children who will get the ball after each throw. Separate the numbers by spaces.\\n\\nExamples\\n\\nInput\\n\\n10\\n\\n\\nOutput\\n\\n2 4 7 1 6 2 9 7 6\\n\\n\\nInput\\n\\n3\\n\\n\\nOutput\\n\\n2 1\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int x = 0, n;\\n scanf(\\\"%d\\\", &n);\\n for (int i = 1; i < n; ++i) {\\n x = (x + i) % n;\\n printf(\\\"%d\\\", x + 1);\\n putchar(i < n - 1 ? ' ' : '\\\\n');\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A rare article in the Internet is posted without a possibility to comment it. On a Polycarp's website each article has comments feed.\\n\\nEach comment on Polycarp's website is a non-empty string consisting of uppercase and lowercase letters of English alphabet. Comments have tree-like structure, that means each comment except root comments (comments of the highest level) has exactly one parent comment.\\n\\nWhen Polycarp wants to save comments to his hard drive he uses the following format. Each comment he writes in the following format: \\n\\n * at first, the text of the comment is written; \\n * after that the number of comments is written, for which this comment is a parent comment (i. e. the number of the replies to this comments); \\n * after that the comments for which this comment is a parent comment are written (the writing of these comments uses the same algorithm). \\n\\nAll elements in this format are separated by single comma. Similarly, the comments of the first level are separated by comma.\\n\\nFor example, if the comments look like:\\n\\n\\n\\nthen the first comment is written as \\\"hello,2,ok,0,bye,0\\\", the second is written as \\\"test,0\\\", the third comment is written as \\\"one,1,two,2,a,0,b,0\\\". The whole comments feed is written as: \\\"hello,2,ok,0,bye,0,test,0,one,1,two,2,a,0,b,0\\\". For a given comments feed in the format specified above print the comments in a different format: \\n\\n * at first, print a integer d — the maximum depth of nesting comments; \\n * after that print d lines, the i-th of them corresponds to nesting level i; \\n * for the i-th row print comments of nesting level i in the order of their appearance in the Policarp's comments feed, separated by space. \\n\\nInput\\n\\nThe first line contains non-empty comments feed in the described format. It consists of uppercase and lowercase letters of English alphabet, digits and commas. \\n\\nIt is guaranteed that each comment is a non-empty string consisting of uppercase and lowercase English characters. Each of the number of comments is integer (consisting of at least one...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nconst int MN = 1e6 + 10;\\nconst int ME = 40000 + 10;\\nconst long long LL_min = 1LL << 63;\\nchar s[MN];\\nint l, r;\\nint Maxdeep;\\nvector vec[MN];\\nstruct Node {\\n int l, r;\\n} node[MN];\\nint u;\\nint build(int deep) {\\n Maxdeep = max(Maxdeep, deep);\\n int now = u;\\n if (now == 0) {\\n while (l <= r) {\\n u++;\\n vec[now].push_back(build(deep + 1));\\n }\\n } else {\\n int i;\\n int len = 0;\\n for (i = l; i < r; i++) {\\n if (s[i] == ',') {\\n break;\\n }\\n }\\n node[now].l = l;\\n node[now].r = i - 1;\\n u++;\\n int son = 0;\\n for (i++; i < r; i++) {\\n if (s[i] == ',') break;\\n son *= 10;\\n son += s[i] - '0';\\n }\\n l = i + 1;\\n if (son == 0) return now;\\n for (i = 0; i < son; i++) {\\n vec[now].push_back(build(deep + 1));\\n }\\n return now;\\n }\\n return 0;\\n}\\nint main() {\\n scanf(\\\"%s\\\", s);\\n l = 0;\\n Maxdeep = 0;\\n r = strlen(s);\\n u = 0;\\n int root = build(0);\\n printf(\\\"%d\\\\n\\\", Maxdeep);\\n int size = vec[0].size();\\n queue que;\\n int i;\\n for (i = 0; i < size; i++) {\\n que.push(vec[0][i]);\\n }\\n for (i = 0; i < Maxdeep; i++) {\\n int newsize = 0;\\n while (size--) {\\n int u = que.front();\\n que.pop();\\n int tmp = vec[u].size();\\n newsize += tmp;\\n int j;\\n for (j = 0; j < tmp; j++) {\\n que.push(vec[u][j]);\\n }\\n for (j = node[u].l; j <= node[u].r; j++) printf(\\\"%c\\\", s[j]);\\n printf(\\\" \\\");\\n }\\n printf(\\\"\\\\n\\\");\\n size = newsize;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A tree is a connected graph without cycles. A rooted tree has a special vertex called the root. The parent of a vertex v (different from root) is the previous to v vertex on the shortest path from the root to the vertex v. Children of the vertex v are all vertices for which v is the parent.\\n\\nA vertex is a leaf if it has no children. We call a vertex a bud, if the following three conditions are satisfied: \\n\\n * it is not a root, \\n * it has at least one child, and \\n * all its children are leaves. \\n\\n\\n\\nYou are given a rooted tree with n vertices. The vertex 1 is the root. In one operation you can choose any bud with all its children (they are leaves) and re-hang them to any other vertex of the tree. By doing that you delete the edge connecting the bud and its parent and add an edge between the bud and the chosen vertex of the tree. The chosen vertex cannot be the bud itself or any of its children. All children of the bud stay connected to the bud.\\n\\nWhat is the minimum number of leaves it is possible to get if you can make any number of the above-mentioned operations (possibly zero)?\\n\\nInput\\n\\nThe input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. Description of the test cases follows.\\n\\nThe first line of each test case contains a single integer n (2 ≤ n ≤ 2 ⋅ 10^5) — the number of the vertices in the given tree.\\n\\nEach of the next n-1 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) meaning that there is an edge between vertices u and v in the tree.\\n\\nIt is guaranteed that the given graph is a tree.\\n\\nIt is guaranteed that the sum of n over all test cases doesn't exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case print a single integer — the minimal number of leaves that is possible to get after some operations.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n7\\n1 2\\n1 3\\n1 4\\n2 5\\n2 6\\n4 7\\n6\\n1 2\\n1 3\\n2 4\\n2 5\\n3 6\\n2\\n1 2\\n7\\n7 3\\n1 5\\n1 3\\n4 6\\n4 7\\n2 1\\n6\\n2 1\\n2 3\\n4 5\\n3 4\\n3 6\\n\\n\\nOutput\\n\\n\\n2\\n2\\n1\\n2\\n1\\n\\nNote\\n\\nIn the first test case the tree looks as follows:\\n\\n\\n\\nFirstly you can choose...\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nconst int maxn = 2e5 + 5;\\nvector e[maxn];\\nint vis[maxn];\\nint ans;\\nint n;\\nint x, y;\\nvoid dfs(int now) {\\n vis[now] = 1;\\n int flag = 0;\\n for (auto i : e[now]) {\\n if (vis[i] == 0) {\\n dfs(i);\\n flag = flag | vis[i];\\n }\\n }\\n if (flag == 0)\\n vis[now] = 1;\\n else if (flag == 1)\\n vis[now] = 2;\\n else if (flag == 2)\\n vis[now] = 1;\\n else if (flag == 3)\\n vis[now] = 2;\\n else if (flag == 7)\\n vis[now] = 7;\\n}\\nint main() {\\n int t;\\n scanf(\\\"%d\\\", &t);\\n while (t--) {\\n scanf(\\\"%d\\\", &n);\\n for (int i = 1; i <= n; i++) vector().swap(e[i]);\\n for (int i = 1; i < n; i++) {\\n scanf(\\\"%d%d\\\", &x, &y);\\n e[x].push_back(y);\\n e[y].push_back(x);\\n }\\n for (int i = 1; i <= n; i++) vis[i] = 0;\\n ans = 0;\\n dfs(1);\\n int ans = 0;\\n for (int i = 1; i <= n; i++) {\\n if (vis[i] == 1)\\n ans++;\\n else if (vis[i] == 2)\\n ans--;\\n }\\n cout << ans + (vis[1] == 2) << endl;\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"\\n\\nWilliam has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers c_1, c_2, ..., c_n where c_i is the number of consecutive brackets \\\"(\\\" if i is an odd number or the number of consecutive brackets \\\")\\\" if i is an even number.\\n\\nFor example for a bracket sequence \\\"((())()))\\\" a corresponding sequence of numbers is [3, 2, 1, 3].\\n\\nYou need to find the total number of continuous subsequences (subsegments) [l, r] (l ≤ r) of the original bracket sequence, which are regular bracket sequences.\\n\\nA bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters \\\"+\\\" and \\\"1\\\" into this sequence. For example, sequences \\\"(())()\\\", \\\"()\\\" and \\\"(()(()))\\\" are regular, while \\\")(\\\", \\\"(()\\\" and \\\"(()))(\\\" are not.\\n\\nInput\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 1000), the size of the compressed sequence.\\n\\nThe second line contains a sequence of integers c_1, c_2, ..., c_n (1 ≤ c_i ≤ 10^9), the compressed sequence.\\n\\nOutput\\n\\nOutput a single integer — the total number of subsegments of the original bracket sequence, which are regular bracket sequences.\\n\\nIt can be proved that the answer fits in the signed 64-bit integer data type.\\n\\nExamples\\n\\nInput\\n\\n\\n5\\n4 1 2 3 1\\n\\n\\nOutput\\n\\n\\n5\\n\\n\\nInput\\n\\n\\n6\\n1 3 2 1 2 4\\n\\n\\nOutput\\n\\n\\n6\\n\\n\\nInput\\n\\n\\n6\\n1 1 1 1 2 2\\n\\n\\nOutput\\n\\n\\n7\\n\\nNote\\n\\nIn the first example a sequence (((()(()))( is described. This bracket sequence contains 5 subsegments which form regular bracket sequences:\\n\\n 1. Subsequence from the 3rd to 10th character: (()(()))\\n 2. Subsequence from the 4th to 5th character: ()\\n 3. Subsequence from the 4th to 9th character: ()(())\\n 4. Subsequence from the 6th to 9th character: (())\\n 5. Subsequence from the 7th to 8th character: ()\\n\\n\\n\\nIn the second example a sequence ()))(()(()))) is described.\\n\\nIn the third example a sequence ()()(()) is described.\\\":\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.util.StringTokenizer;\\n\\npublic class C {\\n static class RealScanner {\\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\\n StringTokenizer st = new StringTokenizer(\\\"\\\");\\n\\n String next() {\\n while (!st.hasMoreTokens())\\n try {\\n st = new StringTokenizer(br.readLine());\\n } catch (IOException e) {\\n e.printStackTrace();\\n }\\n return st.nextToken();\\n }\\n\\n int nextInt() {\\n return Integer.parseInt(next());\\n }\\n\\n int[] readArray(int n) {\\n int[] a = new int[n];\\n for (int i = 0; i < n; i++) a[i] = nextInt();\\n return a;\\n }\\n\\n long nextLong() {\\n return Long.parseLong(next());\\n }\\n }\\n\\n public static void main(String[] args) {\\n RealScanner sc = new RealScanner();\\n long n;\\n n = sc.nextLong();\\n long[] arr = new long[(int) n];\\n for (int i = 0; i < n; i++) {\\n arr[i] = sc.nextInt();\\n }\\n long res = 0;\\n for (int i = 0; i < n; i += 2) {\\n long min = arr[i];\\n long cursor = arr[i];\\n for (int j = i + 1; j < n; j++) {\\n if (j % 2 == 0) {\\n cursor += arr[j];\\n } else {\\n long val1 = Math.max(0, cursor - arr[j]);\\n long val2 = Math.min(min, Math.min(cursor - 1, arr[i] - 1));\\n if (val1 <= val2) {\\n res += val2 - val1 + 1;\\n }\\n cursor -= arr[j];\\n min = Math.min(cursor, min);\\n }\\n }\\n }\\n System.out.println(res);\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Shohag has an integer sequence a_1, a_2, …, a_n. He can perform the following operation any number of times (possibly, zero):\\n\\n * Select any positive integer k (it can be different in different operations). \\n * Choose any position in the sequence (possibly the beginning or end of the sequence, or in between any two elements) and insert k into the sequence at this position. \\n * This way, the sequence a changes, and the next operation is performed on this changed sequence. \\n\\n\\n\\nFor example, if a=[3,3,4] and he selects k = 2, then after the operation he can obtain one of the sequences [\\\\underline{2},3,3,4], [3,\\\\underline{2},3,4], [3,3,\\\\underline{2},4], or [3,3,4,\\\\underline{2}].\\n\\nShohag wants this sequence to satisfy the following condition: for each 1 ≤ i ≤ |a|, a_i ≤ i. Here, |a| denotes the size of a.\\n\\nHelp him to find the minimum number of operations that he has to perform to achieve this goal. We can show that under the constraints of the problem it's always possible to achieve this goal in a finite number of operations.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 200) — the number of test cases.\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 100) — the initial length of the sequence.\\n\\nThe second line of each test case contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^9) — the elements of the sequence.\\n\\nOutput\\n\\nFor each test case, print a single integer — the minimum number of operations needed to perform to achieve the goal mentioned in the statement.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n1 3 4\\n5\\n1 2 5 7 4\\n1\\n1\\n3\\n69 6969 696969\\n\\n\\nOutput\\n\\n\\n1\\n3\\n0\\n696966\\n\\nNote\\n\\nIn the first test case, we have to perform at least one operation, as a_2=3>2. We can perform the operation [1, 3, 4] → [1, \\\\underline{2}, 3, 4] (the newly inserted element is underlined), now the condition is satisfied.\\n\\nIn the second test case, Shohag can perform the following operations:\\n\\n[1, 2, 5, 7, 4] → [1, 2, \\\\underline{3}, 5, 7, 4] → [1, 2, 3, \\\\underline{4}, 5, 7, 4] → [1, 2, 3, 4, 5, \\\\underline{3}, 7, 4].\\n\\nIn the third...\\nimpor\",\"targets\":\"t java.util.*;\\nimport java.io.*;\\n\\npublic class Era {\\n\\n\\tpublic static void main(String[] args) throws IOException\\n\\t{\\n\\t\\tBufferedReader infile = new BufferedReader(new InputStreamReader(System.in));\\n BufferedWriter outfile = new BufferedWriter(new OutputStreamWriter(System.out));\\n \\n StringTokenizer st = new StringTokenizer(infile.readLine());\\n int T = Integer.parseInt(st.nextToken());\\n \\n while(T-- > 0)\\n {\\n \\tst = new StringTokenizer(infile.readLine());\\n int N = Integer.parseInt(st.nextToken());\\n int[] arr = readArr(N, infile, st);\\n \\n int max = 0;\\n for(int i = 0; i < N; i++)\\n {\\n \\tif(arr[i] > i + 1)\\n \\t{\\n \\t\\tint curr = arr[i] - (i + 1);\\n \\t\\tmax = Math.max(max, curr);\\n \\t}\\n }\\n \\n outfile.write(max + \\\"\\\\n\\\");\\n outfile.flush();\\n }\\n outfile.close();\\n\\t}\\n\\t\\n\\tpublic static int[] readArr(int N, BufferedReader infile, StringTokenizer st) throws IOException\\n {\\n int[] arr = new int[N];\\n st = new StringTokenizer(infile.readLine());\\n for(int i=0; i < N; i++)\\n arr[i] = Integer.parseInt(st.nextToken());\\n return arr;\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"This is the hard version of the problem. The difference between the versions is that the hard version does require you to output the numbers of the rods to be removed. You can make hacks only if all versions of the problem are solved.\\n\\nStitch likes experimenting with different machines with his friend Sparky. Today they built another machine.\\n\\nThe main element of this machine are n rods arranged along one straight line and numbered from 1 to n inclusive. Each of these rods must carry an electric charge quantitatively equal to either 1 or -1 (otherwise the machine will not work). Another condition for this machine to work is that the sign-variable sum of the charge on all rods must be zero.\\n\\nMore formally, the rods can be represented as an array of n numbers characterizing the charge: either 1 or -1. Then the condition must hold: a_1 - a_2 + a_3 - a_4 + … = 0, or ∑_{i=1}^n (-1)^{i-1} ⋅ a_i = 0.\\n\\nSparky charged all n rods with an electric current, but unfortunately it happened that the rods were not charged correctly (the sign-variable sum of the charge is not zero). The friends decided to leave only some of the rods in the machine. Sparky has q questions. In the ith question Sparky asks: if the machine consisted only of rods with numbers l_i to r_i inclusive, what minimal number of rods could be removed from the machine so that the sign-variable sum of charges on the remaining ones would be zero? Also Sparky wants to know the numbers of these rods. Perhaps the friends got something wrong, and the sign-variable sum is already zero. In that case, you don't have to remove the rods at all.\\n\\nIf the number of rods is zero, we will assume that the sign-variable sum of charges is zero, that is, we can always remove all rods.\\n\\nHelp your friends and answer all of Sparky's questions!\\n\\nInput\\n\\nEach test contains multiple test cases.\\n\\nThe first line contains one positive integer t (1 ≤ t ≤ 10^3), denoting the number of test cases. Description of the test cases follows.\\n\\nThe first line of each test case contains two positive...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nchar s[300002];\\nint a[300001];\\nint main() {\\n ios::sync_with_stdio(false);\\n cin.tie(nullptr);\\n cout.tie(nullptr);\\n int t;\\n cin >> t;\\n for (int tt = 1; tt <= t; tt++) {\\n int n, q;\\n cin >> n >> q >> s + 1;\\n for (int i = 1; i <= n; i++)\\n a[i] = a[i - 1] + ((s[i] == '+') ^ (i % 2 == 1) ? 1 : -1);\\n for (int i = 1; i <= q; i++) {\\n int l, r;\\n cin >> l >> r;\\n if (a[r] - a[l - 1] == 0)\\n printf(\\\"0\\\\n\\\");\\n else {\\n int ll = l, rr = r, ok = 0;\\n if ((r - l + 1) % 2 == 0) ok = 1, l++, ll++;\\n if (a[r] - a[l] == 0)\\n ll = rr = l;\\n else if (a[r - 1] - a[l - 1] == 0)\\n ll = rr = r;\\n else\\n while (ll != rr) {\\n int mid = ll + rr >> 1;\\n if ((a[mid - 1] - a[l - 1] == a[r] - a[mid]) ||\\n (a[mid - 1] - a[l - 1] > a[r] - a[mid]) == (-a[r] + a[l] < 0))\\n rr = mid;\\n else\\n ll = mid + 1;\\n }\\n if (ok)\\n printf(\\\"2\\\\n%d %d\\\\n\\\", l - 1, ll);\\n else\\n printf(\\\"1\\\\n%d\\\\n\\\", ll);\\n }\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nYou are given two integers n and m. Find the \\\\operatorname{MEX} of the sequence n ⊕ 0, n ⊕ 1, …, n ⊕ m. Here, ⊕ is the [bitwise XOR operator](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#XOR).\\n\\n\\\\operatorname{MEX} of the sequence of non-negative integers is the smallest non-negative integer that doesn't appear in this sequence. For example, \\\\operatorname{MEX}(0, 1, 2, 4) = 3, and \\\\operatorname{MEX}(1, 2021) = 0. \\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 30 000) — the number of test cases.\\n\\nThe first and only line of each test case contains two integers n and m (0 ≤ n, m ≤ 10^9).\\n\\nOutput\\n\\nFor each test case, print a single integer — the answer to the problem.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n3 5\\n4 6\\n3 2\\n69 696\\n123456 654321\\n\\n\\nOutput\\n\\n\\n4\\n3\\n0\\n640\\n530866\\n\\nNote\\n\\nIn the first test case, the sequence is 3 ⊕ 0, 3 ⊕ 1, 3 ⊕ 2, 3 ⊕ 3, 3 ⊕ 4, 3 ⊕ 5, or 3, 2, 1, 0, 7, 6. The smallest non-negative integer which isn't present in the sequence i. e. the \\\\operatorname{MEX} of the sequence is 4.\\n\\nIn the second test case, the sequence is 4 ⊕ 0, 4 ⊕ 1, 4 ⊕ 2, 4 ⊕ 3, 4 ⊕ 4, 4 ⊕ 5, 4 ⊕ 6, or 4, 5, 6, 7, 0, 1, 2. The smallest non-negative integer which isn't present in the sequence i. e. the \\\\operatorname{MEX} of the sequence is 3.\\n\\nIn the third test case, the sequence is 3 ⊕ 0, 3 ⊕ 1, 3 ⊕ 2, or 3, 2, 1. The smallest non-negative integer which isn't present in the sequence i. e. the \\\\operatorname{MEX} of the sequence is 0.\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\n\\npublic class GFG {\\n \\n public static class Pair{\\n long x;\\n int y;\\n Pair(long x,int y){\\n this.x = x;\\n this.y = y;\\n }\\n }\\n \\n\\tpublic static void main (String[] args) {\\n\\t Scanner sc = new Scanner(System.in);\\n\\t int t = sc.nextInt();\\n\\t while(t-- > 0){\\n\\t long n = sc.nextLong();\\n\\t long m = sc.nextLong();\\n\\t long prev = 0,ans = Long.MAX_VALUE;\\n\\t for(long i=32;i>=0;i--)\\n\\t {\\n\\t long bit1 = (1L<0){\\n\\t if(bit1==0)\\n\\t prev |= (1L< 0) {\\n\\n long rem = n % x;\\n\\n if (rem >= 2) {\\n return false;\\n }\\n\\n n = n \\/ x;\\n }\\n return true;\\n }\\n\\n static long pow(long a, long b) {\\n if (b == 0) {\\n return 1;\\n }\\n if (b == 1) {\\n return a;\\n }\\n long ans = pow(a, b \\/ 2) % MOD;\\n ans = (ans * ans) % MOD;\\n if (b % 2 == 1) {\\n\\n return (a * ans) % MOD;\\n }\\n return ans;\\n }\\n\\n public static void main(String[] args) throws IOException {\\n BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out));\\n FastReader sc = new FastReader();\\n\\n long t =...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A total of n depots are located on a number line. Depot i lies at the point x_i for 1 ≤ i ≤ n.\\n\\nYou are a salesman with n bags of goods, attempting to deliver one bag to each of the n depots. You and the n bags are initially at the origin 0. You can carry up to k bags at a time. You must collect the required number of goods from the origin, deliver them to the respective depots, and then return to the origin to collect your next batch of goods.\\n\\nCalculate the minimum distance you need to cover to deliver all the bags of goods to the depots. You do not have to return to the origin after you have delivered all the bags.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10 500). Description of the test cases follows.\\n\\nThe first line of each test case contains two integers n and k (1 ≤ k ≤ n ≤ 2 ⋅ 10^5).\\n\\nThe second line of each test case contains n integers x_1, x_2, …, x_n (-10^9 ≤ x_i ≤ 10^9). It is possible that some depots share the same position.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, output a single integer denoting the minimum distance you need to cover to deliver all the bags of goods to the depots. \\n\\nExample\\n\\nInput\\n\\n\\n4\\n5 1\\n1 2 3 4 5\\n9 3\\n-5 -10 -15 6 5 8 3 7 4\\n5 3\\n2 2 3 3 3\\n4 2\\n1000000000 1000000000 1000000000 1000000000\\n\\n\\nOutput\\n\\n\\n25\\n41\\n7\\n3000000000\\n\\nNote\\n\\nIn the first test case, you can carry only one bag at a time. Thus, the following is a solution sequence that gives a minimum travel distance: 0 → 2 → 0 → 4 → 0 → 3 → 0 → 1 → 0 → 5, where each 0 means you go the origin and grab one bag, and each positive integer means you deliver the bag to a depot at this coordinate, giving a total distance of 25 units. It must be noted that there are other sequences that give the same distance.\\n\\nIn the second test case, you can follow the following sequence, among multiple such sequences, to travel minimum distance: 0 → 6 → 8 → 7 → 0 → 5 → 4 → 3 → 0 → (-5) → (-10) → (-15), with distance...\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.io.PrintStream;\\nimport java.io.File;\\nimport java.io.FileInputStream;\\nimport java.util.*;\\n\\npublic class Main {\\n\\n \\/\\/ static final File ip = new File(\\\"input.txt\\\");\\n \\/\\/ static final File op = new File(\\\"output.txt\\\");\\n \\/\\/ static {\\n \\/\\/ try {\\n \\/\\/ System.setOut(new PrintStream(op));\\n \\/\\/ System.setIn(new FileInputStream(ip));\\n \\/\\/ } catch (Exception e) {\\n \\/\\/ }\\n \\/\\/ }\\n\\n public static void main(String[] args) {\\n FastReader sc = new FastReader();\\n int test = 1;\\n test = sc.nextInt();\\n while (test-- > 0) {\\n int n = sc.nextInt();\\n int k = sc.nextInt();\\n ArrayList pos = new ArrayList<>();\\n ArrayList neg = new ArrayList<>();\\n for (int i = 0; i < n; i++) {\\n long a = sc.nextLong();\\n if (a > 0)\\n pos.add(a);\\n else if (a < 0)\\n neg.add(-a);\\n }\\n Collections.sort(pos);\\n Collections.sort(neg);\\n long ans = 0;\\n for (int i = pos.size() - 1; i >= 0; i -= k) {\\n ans += 2 * pos.get(i);\\n }\\n for (int i = neg.size() - 1; i >= 0; i -= k) {\\n ans += 2 * neg.get(i);\\n }\\n long max = Math.max(pos.size() == 0 ? 0 : pos.get(pos.size() - 1),\\n neg.size() == 0 ? 0 : neg.get(neg.size() - 1));\\n System.out.println(ans - max);\\n }\\n }\\n\\n static long power(long x, long y, long p) {\\n long res = 1;\\n x = x % p;\\n if (x == 0)\\n return 0;\\n while (y > 0) {\\n if ((y & 1) != 0)\\n res = (res * x) % p;\\n y = y >> 1;\\n x = (x * x) % p;\\n }\\n return res;\\n }\\n\\n public static int countSetBits(long number) {\\n int count = 0;\\n while (number > 0) {\\n ++count;\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alice got many presents these days. So she decided to pack them into boxes and send them to her friends.\\n\\nThere are n kinds of presents. Presents of one kind are identical (i.e. there is no way to distinguish two gifts of the same kind). Presents of different kinds are different (i.e. that is, two gifts of different kinds are distinguishable). The number of presents of each kind, that Alice has is very big, so we can consider Alice has an infinite number of gifts of each kind.\\n\\nAlso, there are m boxes. All of them are for different people, so they are pairwise distinct (consider that the names of m friends are written on the boxes). For example, putting the first kind of present into the first box but not into the second box, is different from putting the first kind of present into the second box but not into the first box.\\n\\nAlice wants to pack presents with the following rules:\\n\\n * She won't pack more than one present of each kind into the same box, so each box should contain presents of different kinds (i.e. each box contains a subset of n kinds, empty boxes are allowed); \\n * For each kind at least one present should be packed into some box. \\n\\n\\n\\nNow Alice wants to know how many different ways to pack the presents exists. Please, help her and calculate this number. Since the answer can be huge, output it by modulo 10^9+7.\\n\\nSee examples and their notes for clarification.\\n\\nInput\\n\\nThe first line contains two integers n and m, separated by spaces (1 ≤ n,m ≤ 10^9) — the number of kinds of presents and the number of boxes that Alice has.\\n\\nOutput\\n\\nPrint one integer — the number of ways to pack the presents with Alice's rules, calculated by modulo 10^9+7\\n\\nExamples\\n\\nInput\\n\\n\\n1 3\\n\\n\\nOutput\\n\\n\\n7\\n\\nInput\\n\\n\\n2 2\\n\\n\\nOutput\\n\\n\\n9\\n\\nNote\\n\\nIn the first example, there are seven ways to pack presents:\\n\\n\\\\{1\\\\}\\\\{\\\\}\\\\{\\\\}\\n\\n\\\\{\\\\}\\\\{1\\\\}\\\\{\\\\}\\n\\n\\\\{\\\\}\\\\{\\\\}\\\\{1\\\\}\\n\\n\\\\{1\\\\}\\\\{1\\\\}\\\\{\\\\}\\n\\n\\\\{\\\\}\\\\{1\\\\}\\\\{1\\\\}\\n\\n\\\\{1\\\\}\\\\{\\\\}\\\\{1\\\\}\\n\\n\\\\{1\\\\}\\\\{1\\\\}\\\\{1\\\\}\\n\\nIn the second example there are nine ways to pack...\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nconst int mod = 1e9 + 7;\\nlong long qpow(long long a, long long n) {\\n long long ans = 1;\\n while (n) {\\n if (n & 1) ans = ans * a % mod;\\n a = a * a % mod;\\n n >>= 1;\\n }\\n return ans;\\n}\\nint main() {\\n long long n, m;\\n scanf(\\\"%lld%lld\\\", &n, &m);\\n printf(\\\"%lld\\\", qpow(qpow(2, m) - 1, n));\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page.\\n\\nYesterday evening Nastya did not manage to finish reading the book, so she marked the page with number k as the first page which was not read (i.e. she read all pages from the 1-st to the (k-1)-th).\\n\\nThe next day Nastya's friend Igor came and asked her, how many chapters remain to be read by Nastya? Nastya is too busy now, so she asks you to compute the number of chapters she has not completely read yet (i.e. the number of chapters she has not started to read or has finished reading somewhere in the middle).\\n\\nInput\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 100) — the number of chapters in the book.\\n\\nThere are n lines then. The i-th of these lines contains two integers l_i, r_i separated by space (l_1 = 1, l_i ≤ r_i) — numbers of the first and the last pages of the i-th chapter. It's guaranteed that l_{i+1} = r_i + 1 for all 1 ≤ i ≤ n-1, and also that every chapter contains at most 100 pages.\\n\\nThe (n+2)-th line contains a single integer k (1 ≤ k ≤ r_n) — the index of the marked page. \\n\\nOutput\\n\\nPrint a single integer — the number of chapters which has not been completely read so far.\\n\\nExamples\\n\\nInput\\n\\n\\n3\\n1 3\\n4 7\\n8 11\\n2\\n\\n\\nOutput\\n\\n\\n3\\n\\n\\nInput\\n\\n\\n3\\n1 4\\n5 9\\n10 12\\n9\\n\\n\\nOutput\\n\\n\\n2\\n\\n\\nInput\\n\\n\\n1\\n1 7\\n4\\n\\n\\nOutput\\n\\n\\n1\\n\\nNote\\n\\nIn the first example the book contains 11 pages and 3 chapters — [1;3], [4;7] and [8;11]. Nastya marked the 2-nd page, so she finished in the middle of the 1-st chapter. So, all chapters has not been read so far, so the answer is 3.\\n\\nThe book in the second example contains 12 pages and 3 chapters too, but Nastya finished reading in the middle of the 2-nd chapter, so that the answer is 2.\\nn = i\",\"targets\":\"nt(input())\\nlist1 = []\\nfor _ in range(n):\\n list1.append(tuple(map(int, input().split())))\\nk = int(input())\\n# print(list1[0])\\ntemp = 0\\nfor i in list1:\\n if i[0]<=k and i[1]>=k:\\n print(n-temp)\\n break\\n temp +=1\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A string s of length n, consisting of lowercase letters of the English alphabet, is given.\\n\\nYou must choose some number k between 0 and n. Then, you select k characters of s and permute them however you want. In this process, the positions of the other n-k characters remain unchanged. You have to perform this operation exactly once.\\n\\nFor example, if s=\\\"andrea\\\", you can choose the k=4 characters \\\"a_d_ea\\\" and permute them into \\\"d_e_aa\\\" so that after the operation the string becomes \\\"dneraa\\\".\\n\\nDetermine the minimum k so that it is possible to sort s alphabetically (that is, after the operation its characters appear in alphabetical order).\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases. Then t test cases follow.\\n\\nThe first line of each test case contains one integer n (1 ≤ n ≤ 40) — the length of the string.\\n\\nThe second line of each test case contains the string s. It is guaranteed that s contains only lowercase letters of the English alphabet.\\n\\nOutput\\n\\nFor each test case, output the minimum k that allows you to obtain a string sorted alphabetically, through the operation described above.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\nlol\\n10\\ncodeforces\\n5\\naaaaa\\n4\\ndcba\\n\\n\\nOutput\\n\\n\\n2\\n6\\n0\\n4\\n\\nNote\\n\\nIn the first test case, we can choose the k=2 characters \\\"_ol\\\" and rearrange them as \\\"_lo\\\" (so the resulting string is \\\"llo\\\"). It is not possible to sort the string choosing strictly less than 2 characters.\\n\\nIn the second test case, one possible way to sort s is to consider the k=6 characters \\\"_o__force_\\\" and rearrange them as \\\"_c__efoor_\\\" (so the resulting string is \\\"ccdeefoors\\\"). One can show that it is not possible to sort the string choosing strictly less than 6 characters.\\n\\nIn the third test case, string s is already sorted (so we can choose k=0 characters).\\n\\nIn the fourth test case, we can choose all k=4 characters \\\"dcba\\\" and reverse the whole string (so the resulting string is \\\"abcd\\\").\",\"targets\":\"#include \\nusing namespace std;\\nconst int MOD = 1e9 + 7;\\nconst int N = 2e5 + 5;\\nint t, n;\\nstring s, x;\\nint main() {\\n ios::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n cin >> t;\\n while (t--) {\\n cin >> n >> s;\\n x = s;\\n sort(x.begin(), x.end());\\n int ans = n;\\n for (int i = 0; i <= n - 1; ++i) ans -= (s[i] == x[i]);\\n cout << ans << '\\\\n';\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Moamen has an array of n distinct integers. He wants to sort that array in non-decreasing order by doing the following operations in order exactly once:\\n\\n 1. Split the array into exactly k non-empty subarrays such that each element belongs to exactly one subarray. \\n 2. Reorder these subarrays arbitrary. \\n 3. Merge the subarrays in their new order. \\n\\n\\n\\nA sequence a is a subarray of a sequence b if a can be obtained from b by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.\\n\\nCan you tell Moamen if there is a way to sort the array in non-decreasing order using the operations written above?\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^3) — the number of test cases. The description of the test cases follows.\\n\\nThe first line of each test case contains two integers n and k (1 ≤ k ≤ n ≤ 10^5).\\n\\nThe second line contains n integers a_1, a_2, …, a_n (0 ≤ |a_i| ≤ 10^9). It is guaranteed that all numbers are distinct.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 3⋅10^5.\\n\\nOutput\\n\\nFor each test case, you should output a single string.\\n\\nIf Moamen can sort the array in non-decreasing order, output \\\"YES\\\" (without quotes). Otherwise, output \\\"NO\\\" (without quotes).\\n\\nYou can print each letter of \\\"YES\\\" and \\\"NO\\\" in any case (upper or lower).\\n\\nExample\\n\\nInput\\n\\n\\n3\\n5 4\\n6 3 4 2 1\\n4 2\\n1 -4 0 -2\\n5 1\\n1 2 3 4 5\\n\\n\\nOutput\\n\\n\\nYes\\nNo\\nYes\\n\\nNote\\n\\nIn the first test case, a = [6, 3, 4, 2, 1], and k = 4, so we can do the operations as follows: \\n\\n 1. Split a into \\\\{ [6], [3, 4], [2], [1] \\\\}. \\n 2. Reorder them: \\\\{ [1], [2], [3,4], [6] \\\\}. \\n 3. Merge them: [1, 2, 3, 4, 6], so now the array is sorted. \\n\\n\\n\\nIn the second test case, there is no way to sort the array by splitting it into only 2 subarrays.\\n\\nAs an example, if we split it into \\\\{ [1, -4], [0, -2] \\\\}, we can reorder them into \\\\{ [1, -4], [0, -2] \\\\} or \\\\{ [0, -2], [1, -4] \\\\}. However, after merging the subarrays, it is impossible to get a sorted array.\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nint main() {\\n int t;\\n cin >> t;\\n while (t--) {\\n int n, k;\\n cin >> n >> k;\\n vector> A(n);\\n for (int i = 0; i < n; i++) {\\n cin >> A[i].first;\\n A[i].second = i;\\n }\\n sort(A.begin(), A.end());\\n int ans = 0;\\n for (int i = 0; i < n - 1; i++) {\\n if (A[i].second + 1 != A[i + 1].second) {\\n ans++;\\n }\\n }\\n if (ans + 1 <= k) {\\n cout << \\\"Yes\\\" << endl;\\n } else {\\n cout << \\\"No\\\" << endl;\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given a string s of length n consisting of characters a and\\/or b.\\n\\nLet \\\\operatorname{AB}(s) be the number of occurrences of string ab in s as a substring. Analogically, \\\\operatorname{BA}(s) is the number of occurrences of ba in s as a substring.\\n\\nIn one step, you can choose any index i and replace s_i with character a or b.\\n\\nWhat is the minimum number of steps you need to make to achieve \\\\operatorname{AB}(s) = \\\\operatorname{BA}(s)?\\n\\nReminder:\\n\\nThe number of occurrences of string d in s as substring is the number of indices i (1 ≤ i ≤ |s| - |d| + 1) such that substring s_i s_{i + 1} ... s_{i + |d| - 1} is equal to d. For example, \\\\operatorname{AB}(aabbbabaa) = 2 since there are two indices i: i = 2 where aabbbabaa and i = 6 where aabbbabaa.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 1000). Description of the test cases follows.\\n\\nThe first and only line of each test case contains a single string s (1 ≤ |s| ≤ 100, where |s| is the length of the string s), consisting only of characters a and\\/or b.\\n\\nOutput\\n\\nFor each test case, print the resulting string s with \\\\operatorname{AB}(s) = \\\\operatorname{BA}(s) you'll get making the minimum number of steps.\\n\\nIf there are multiple answers, print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n4\\nb\\naabbbabaa\\nabbb\\nabbaab\\n\\n\\nOutput\\n\\n\\nb\\naabbbabaa\\nbbbb\\nabbaaa\\n\\nNote\\n\\nIn the first test case, both \\\\operatorname{AB}(s) = 0 and \\\\operatorname{BA}(s) = 0 (there are no occurrences of ab (ba) in b), so can leave s untouched.\\n\\nIn the second test case, \\\\operatorname{AB}(s) = 2 and \\\\operatorname{BA}(s) = 2, so you can leave s untouched. \\n\\nIn the third test case, \\\\operatorname{AB}(s) = 1 and \\\\operatorname{BA}(s) = 0. For example, we can change s_1 to b and make both values zero.\\n\\nIn the fourth test case, \\\\operatorname{AB}(s) = 2 and \\\\operatorname{BA}(s) = 1. For example, we can change s_6 to a and make both values equal to 1.\\nimpor\",\"targets\":\"t java.io.*; \\n\\npublic class A {\\n\\tpublic static void main (String[] args) throws IOException {\\n\\t\\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\\n\\t\\tPrintWriter out = new PrintWriter(System.out);\\n\\t\\t\\n\\t\\tint t = Integer.parseInt(br.readLine());\\n\\t\\t\\n\\t\\tfor (int i = 0; i < t; i++) {\\n\\t\\t\\tString d = br.readLine();\\n\\t\\t\\tif (d.charAt(0) == d.charAt(d.length() - 1)) {\\n\\t\\t\\t\\tout.println(d);\\n\\t\\t\\t\\tcontinue;\\n\\t\\t\\t} else if (d.charAt(0) == 'a' && d.charAt(d.length() - 1) == 'b') {\\n\\t\\t\\t\\tout.println(d.substring(0, d.length() - 1) + \\\"a\\\");\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tout.println(\\\"a\\\" + d.substring(1));\\n\\t\\t\\t}\\n\\t\\t}\\n\\n\\t\\tout.close();\\n\\t}\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You have a string s and a chip, which you can place onto any character of this string. \\n\\nAfter placing the chip, you move it to the right several (maybe zero) times, i. e. you perform the following operation several times: if the current position of the chip is i, you move it to the position i + 1. Of course, moving the chip to the right is impossible if it is already in the last position.\\n\\nAfter moving the chip to the right, you move it to the left several (maybe zero) times, i. e. you perform the following operation several times: if the current position of the chip is i, you move it to the position i - 1. Of course, moving the chip to the left is impossible if it is already in the first position.\\n\\nWhen you place a chip or move it, you write down the character where the chip ends up after your action. For example, if s is abcdef, you place the chip onto the 3-rd character, move it to the right 2 times and then move it to the left 3 times, you write down the string cdedcb.\\n\\nYou are given two strings s and t. Your task is to determine whether it's possible to perform the described operations with s so that you write down the string t as a result.\\n\\nInput\\n\\nThe first line contains one integer q (1 ≤ q ≤ 500) — the number of test cases.\\n\\nEach test case consists of two lines. The first line contains the string s (1 ≤ |s| ≤ 500), the second line contains the string t (1 ≤ |t| ≤ 2 ⋅ |s| - 1). Both strings consist of lowercase English characters.\\n\\nIt is guaranteed that the sum of |s| over all test cases does not exceed 500.\\n\\nOutput\\n\\nFor each test case, print \\\"YES\\\" if you can obtain the string t by performing the process mentioned in the statement with the string s, or \\\"NO\\\" if you cannot.\\n\\nYou may print each letter in any case (YES, yes, Yes will all be recognized as positive answer, NO, no and nO will all be recognized as negative answer).\\n\\nExample\\n\\nInput\\n\\n\\n6\\nabcdef\\ncdedcb\\naaa\\naaaaa\\naab\\nbaaa\\nab\\nb\\nabcdef\\nabcdef\\nba\\nbaa\\n\\n\\nOutput\\n\\n\\nYES\\nYES\\nNO\\nYES\\nYES\\nNO\\n\\nNote\\n\\nConsider the examples.\\n\\nThe first test case is described in...\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\n \\n \\npublic class Solucion {\\n static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\\n static StringTokenizer cadena;\\n static StringBuilder out = new StringBuilder();\\n static String next() throws IOException {\\n while (cadena == null || !cadena.hasMoreTokens())\\n cadena = new StringTokenizer(br.readLine());\\n return cadena.nextToken();\\n }\\n static int leerInt() throws IOException {\\n return Integer.parseInt(next());\\n }\\n static String readLine() throws IOException {\\n return br.readLine();\\n }\\n \\n public static void main(String[] args) throws IOException {\\n int T = leerInt();\\n while(T-->0){\\n solve();\\n }\\n }\\n public static void solve() throws IOException {\\n String s = readLine();\\n String t = readLine();\\n int n = s.length();\\n int m = t.length();\\n \\n for (int l = 0; l < n; l++) {\\n for (int r = l; r < n; r++) {\\n if (r - l + 1 > m) {\\n continue;\\n }\\n boolean ok = true;\\n int rpos = 0;\\n for (int i = l; i <= r && ok; i++) {\\n if (s.charAt(i) != t.charAt(rpos++)) {\\n ok = false;\\n }\\n }\\n if (!ok) {\\n continue;\\n }\\n for (int i = r - 1; i >= 0 && rpos < m && ok; i--) {\\n if (s.charAt(i) != t.charAt(rpos++)) {\\n ok = false;\\n }\\n }\\n if (!ok || rpos < m) {\\n continue;\\n }\\n System.out.println(\\\"YES\\\");\\n return;\\n }\\n }\\n System.out.println(\\\"NO\\\");\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given two integer arrays of length N, A1 and A2. You are also given Q queries of 4 types: \\n\\n1 k l r x: set Ak_i:=min(Ak_i, x) for each l ≤ i ≤ r.\\n\\n2 k l r x: set Ak_i:=max(Ak_i, x) for each l ≤ i ≤ r.\\n\\n3 k l r x: set Ak_i:=Ak_i+x for each l ≤ i ≤ r.\\n\\n4 l r: find the (∑_{i=l}^r F(A1_i+A2_i)) \\\\% (10^9+7) where F(k) is the k-th Fibonacci number (F(0)=0, F(1)=1, F(k)=F(k-1)+F(k-2)), and x \\\\% y denotes the remainder of the division of x by y.\\n\\nYou should process these queries and answer each query of the fourth type.\\n\\nInput\\n\\nThe first line contains two integers N and Q. (1 ≤ N, Q ≤ 5 × 10^4) \\n\\nThe second line contains N integers, array A1_1, A1_2, ... A1_N. (0 ≤ A1_i ≤ 10^6)\\n\\nThe third line contains N integers, array A2_1, A2_2, ... A2_N. (0 ≤ A2_i ≤ 10^6)\\n\\nThe next Q lines describe the queries. Each line contains 5 or 3 integers, where the first integer denotes the type of the query. (k ∈ \\\\{1, 2\\\\}, 1 ≤ l ≤ r ≤ N)\\n\\nFor queries of type 1 and 2, 0 ≤ x ≤ 10^9 holds.\\n\\nFor queries of type 3, −10^6 ≤ x ≤ 10^6 holds.\\n\\nIt is guaranteed that after every query each number in arrays A1 and A2 will be nonnegative. \\n\\nOutput\\n\\nPrint the answer to each query of the fourth type, in separate lines. \\n\\nExamples\\n\\nInput\\n\\n\\n3 4\\n1 0 2\\n2 1 0\\n4 1 3\\n3 2 2 2 3\\n1 1 1 3 0\\n4 1 3\\n\\n\\nOutput\\n\\n\\n4\\n4\\n\\n\\nInput\\n\\n\\n5 4\\n1 3 5 3 2\\n4 2 1 3 3\\n4 1 3\\n4 2 5\\n2 1 2 4 6\\n4 2 4\\n\\n\\nOutput\\n\\n\\n18\\n26\\n68\\n\\nNote\\n\\nIn the first example: The answer for the first query is F(1 + 2) + F(0 + 1) + F(2 + 0) = F(3) + F(1) + F(2) = 2 + 1 + 1 = 4. After the second query, the array A2 changes to [2, 4, 0]. After the third query, the array A1 changes to [0, 0, 0]. The answer for the fourth query is F(0 + 2) + F(0 + 4) + F(0 + 0) = F(2) + F(4) + F(0) = 1 + 3 + 0 = 4. \\n\\nIn the second example: The answer for the first query is F(1 + 4) + F(3 + 2) + F(5 + 1) = F(5) + F(5) + F(6) = 5 + 5 + 8 = 18. The answer for the second query is F(3 + 2) + F(5 + 1) + F(3 + 3) + F(2 + 3) = F(5) + F(6) + F(6) + F(5) = 5 + 8 + 8 + 5 = 26. After the third query, the array A1 changes to [1, 6, 6, 6, 2]. The...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nconst int mod = 1e9 + 7;\\nint add(int x, int y) {\\n x += y;\\n return x >= mod ? x - mod : x;\\n}\\nvoid ckadd(int& x, int y) { x = add(x, y); }\\nint sub(int x, int y) {\\n x -= y;\\n return x < 0 ? x + mod : x;\\n}\\nvoid cksub(int& x, int y) { x = sub(x, y); }\\nint mul(int x, int y) { return (long long)x * y % mod; }\\nvoid ckmul(int& x, int y) { x = mul(x, y); }\\nstruct mat2x2 {\\n int a00, a01, a10, a11;\\n void init() { a00 = a01 = a10 = a11 = 0; }\\n mat2x2() { init(); }\\n mat2x2 operator+(mat2x2 other) const {\\n mat2x2 ret;\\n ret.a00 = add(a00, other.a00);\\n ret.a01 = add(a01, other.a01);\\n ret.a10 = add(a10, other.a10);\\n ret.a11 = add(a11, other.a11);\\n return ret;\\n }\\n mat2x2 operator*(mat2x2 other) const {\\n mat2x2 ret;\\n ret.a00 = ((long long)a00 * other.a00 + (long long)a01 * other.a10) % mod;\\n ret.a01 = ((long long)a00 * other.a01 + (long long)a01 * other.a11) % mod;\\n ret.a10 = ((long long)a10 * other.a00 + (long long)a11 * other.a10) % mod;\\n ret.a11 = ((long long)a10 * other.a01 + (long long)a11 * other.a11) % mod;\\n return ret;\\n }\\n};\\nvoid operator+=(mat2x2& a, mat2x2 b) { a = a + b; }\\nvoid operator*=(mat2x2& a, mat2x2 b) { a = a * b; }\\nmat2x2 get_id_mat() {\\n mat2x2 ret = mat2x2();\\n ret.a00 = ret.a11 = 1;\\n return ret;\\n}\\nmat2x2 get_f_mat() {\\n mat2x2 ret;\\n ret.a00 = 1;\\n ret.a01 = 1;\\n ret.a10 = 1;\\n ret.a11 = 0;\\n return ret;\\n}\\nmat2x2 get_i_f_mat() {\\n mat2x2 ret;\\n ret.a00 = 0;\\n ret.a01 = 1;\\n ret.a10 = 1;\\n ret.a11 = mod - 1;\\n return ret;\\n}\\nconst int H = 1000000;\\nconst int STEP = 1000000;\\nmat2x2 fib[H], rmd[STEP];\\nmat2x2 ifb[H], irm[STEP];\\nvoid init_fibonacci() {\\n mat2x2 f = get_f_mat();\\n mat2x2 i_f = get_i_f_mat();\\n rmd[0] = get_id_mat();\\n irm[0] = get_id_mat();\\n for (int i = 1; i < STEP; ++i) {\\n rmd[i] = rmd[i - 1] * f;\\n irm[i] = irm[i - 1] * i_f;\\n }\\n mat2x2 step = rmd[STEP - 1] * f;\\n mat2x2 istp = irm[STEP - 1] * i_f;\\n fib[0] = get_id_mat();\\n ifb[0] = get_id_mat();\\n for (int i = 1; i < H; ++i) {\\n fib[i] = fib[i -...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Some number of people (this number is even) have stood in a circle. The people stand in the circle evenly. They are numbered clockwise starting from a person with the number 1. Each person is looking through the circle's center at the opposite person.\\n\\n A sample of a circle of 6 persons. The orange arrows indicate who is looking at whom.\\n\\nYou don't know the exact number of people standing in the circle (but this number is even, no doubt). It is known that the person with the number a is looking at the person with the number b (and vice versa, of course). What is the number associated with a person being looked at by the person with the number c? If, for the specified a, b, and c, no such circle exists, output -1.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10^4) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one line containing three distinct integers a, b, c (1 ≤ a,b,c ≤ 10^8).\\n\\nOutput\\n\\nFor each test case output in a separate line a single integer d — the number of the person being looked at by the person with the number c in a circle such that the person with the number a is looking at the person with the number b. If there are multiple solutions, print any of them. Output -1 if there's no circle meeting the given conditions.\\n\\nExample\\n\\nInput\\n\\n\\n7\\n6 2 4\\n2 3 1\\n2 4 10\\n5 3 4\\n1 3 2\\n2 5 4\\n4 3 2\\n\\n\\nOutput\\n\\n\\n8\\n-1\\n-1\\n-1\\n4\\n1\\n-1\\n\\nNote\\n\\nIn the first test case, there's a desired circle of 8 people. The person with the number 6 will look at the person with the number 2 and the person with the number 8 will look at the person with the number 4.\\n\\nIn the second test case, there's no circle meeting the conditions. If the person with the number 2 is looking at the person with the number 3, the circle consists of 2 people because these persons are neighbors. But, in this case, they must have the numbers 1 and 2, but it doesn't meet the problem's conditions.\\n\\nIn the third test case, the only circle with the persons with the numbers 2 and 4 looking at each other consists of 4...\\nUsing python3 can you solve the prior task?\",\"targets\":\"n = int(input())\\nfor _ in range(n):\\n a,b,c = map(int, input().split(' '))\\n d = abs(a-b)\\n if c > d:\\n res = c - d\\n else:\\n res = c + d\\n if res > 0 and res <= 2*d and a <= 2*d and b <= 2*d and c <= 2*d:\\n print(res)\\n else:\\n print('-1')\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A soldier wants to buy w bananas in the shop. He has to pay k dollars for the first banana, 2k dollars for the second one and so on (in other words, he has to pay i·k dollars for the i-th banana). \\n\\nHe has n dollars. How many dollars does he have to borrow from his friend soldier to buy w bananas?\\n\\nInput\\n\\nThe first line contains three positive integers k, n, w (1 ≤ k, w ≤ 1000, 0 ≤ n ≤ 109), the cost of the first banana, initial number of dollars the soldier has and number of bananas he wants. \\n\\nOutput\\n\\nOutput one integer — the amount of dollars that the soldier must borrow from his friend. If he doesn't have to borrow money, output 0.\\n\\nExamples\\n\\nInput\\n\\n3 17 4\\n\\n\\nOutput\\n\\n13\",\"targets\":\"k, n, w = [int(x) for x in input().split()]\\n\\ndef sum_of_numbers(n):\\n return round(n\\/2 * (n + 1))\\n\\ndef positive_or_zero(n):\\n return n if n > 0 else 0\\n\\nprint(positive_or_zero(k * sum_of_numbers(w) - n))\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nAn atom of element X can exist in n distinct states with energies E1 < E2 < ... < En. Arkady wants to build a laser on this element, using a three-level scheme. Here is a simplified description of the scheme. \\n\\nThree distinct states i, j and k are selected, where i < j < k. After that the following process happens: \\n\\n 1. initially the atom is in the state i,\\n 2. we spend Ek - Ei energy to put the atom in the state k,\\n 3. the atom emits a photon with useful energy Ek - Ej and changes its state to the state j,\\n 4. the atom spontaneously changes its state to the state i, losing energy Ej - Ei,\\n 5. the process repeats from step 1. \\n\\n\\n\\nLet's define the energy conversion efficiency as , i. e. the ration between the useful energy of the photon and spent energy.\\n\\nDue to some limitations, Arkady can only choose such three states that Ek - Ei ≤ U.\\n\\nHelp Arkady to find such the maximum possible energy conversion efficiency within the above constraints.\\n\\nInput\\n\\nThe first line contains two integers n and U (3 ≤ n ≤ 105, 1 ≤ U ≤ 109) — the number of states and the maximum possible difference between Ek and Ei.\\n\\nThe second line contains a sequence of integers E1, E2, ..., En (1 ≤ E1 < E2... < En ≤ 109). It is guaranteed that all Ei are given in increasing order.\\n\\nOutput\\n\\nIf it is not possible to choose three states that satisfy all constraints, print -1.\\n\\nOtherwise, print one real number η — the maximum possible energy conversion efficiency. Your answer is considered correct its absolute or relative error does not exceed 10 - 9.\\n\\nFormally, let your answer be a, and the jury's answer be b. Your answer is considered correct if .\\n\\nExamples\\n\\nInput\\n\\n4 4\\n1 3 5 7\\n\\n\\nOutput\\n\\n0.5\\n\\n\\nInput\\n\\n10 8\\n10 13 15 16 17 19 20 22 24 25\\n\\n\\nOutput\\n\\n0.875\\n\\n\\nInput\\n\\n3 1\\n2 5 10\\n\\n\\nOutput\\n\\n-1\\n\\nNote\\n\\nIn the first example choose states 1, 2 and 3, so that the energy conversion efficiency becomes equal to .\\n\\nIn the second example choose states 4, 5 and 9, so that the energy conversion efficiency becomes equal to .\",\"targets\":\"#include \\nusing namespace std;\\nconst int MAXN = 1e5 + 13;\\nconst int mod = 1e9 + 7;\\nconst long long inf = 1e18 + 5;\\nconst long double pi = 3.1415926535897932384626433;\\nint fast_pow(int a, int b) {\\n int res = a, ret = 1;\\n while (b > 0) {\\n if (b % 2) ret = (ret * res) % mod;\\n res = (res * res) % mod;\\n b \\/= 2;\\n }\\n return ret;\\n}\\nint n, u, a[MAXN], x1 = -1, x2, x3, k;\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n cin >> n >> u;\\n for (int i = 0; i < n; ++i) cin >> a[i];\\n for (int i = 0; i < n; ++i) {\\n k = max(k, i);\\n while (k + 1 < n && a[k + 1] - a[i] <= u) {\\n k++;\\n }\\n if (k - i - 1 <= 0) {\\n continue;\\n }\\n int j = i + 1;\\n if (x1 == -1 || (a[k] - a[j]) * 1ll * (a[x3] - a[x1]) >\\n (a[x3] - a[x2]) * 1ll * (a[k] - a[i])) {\\n x1 = i, x2 = j, x3 = k;\\n }\\n }\\n if (x1 == -1) {\\n cout << -1 << endl;\\n return 0;\\n }\\n cout << fixed << setprecision(20) << (double)(a[x3] - a[x2]) \\/ (a[x3] - a[x1])\\n << endl;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You have a permutation: an array a = [a_1, a_2, …, a_n] of distinct integers from 1 to n. The length of the permutation n is odd.\\n\\nConsider the following algorithm of sorting the permutation in increasing order.\\n\\nA helper procedure of the algorithm, f(i), takes a single argument i (1 ≤ i ≤ n-1) and does the following. If a_i > a_{i+1}, the values of a_i and a_{i+1} are exchanged. Otherwise, the permutation doesn't change.\\n\\nThe algorithm consists of iterations, numbered with consecutive integers starting with 1. On the i-th iteration, the algorithm does the following: \\n\\n * if i is odd, call f(1), f(3), …, f(n - 2); \\n * if i is even, call f(2), f(4), …, f(n - 1). \\n\\n\\n\\nIt can be proven that after a finite number of iterations the permutation will be sorted in increasing order.\\n\\nAfter how many iterations will this happen for the first time?\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 100). Description of the test cases follows.\\n\\nThe first line of each test case contains a single integer n (3 ≤ n ≤ 999; n is odd) — the length of the permutation.\\n\\nThe second line contains n distinct integers a_1, a_2, …, a_n (1 ≤ a_i ≤ n) — the permutation itself. \\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 999.\\n\\nOutput\\n\\nFor each test case print the number of iterations after which the permutation will become sorted in increasing order for the first time.\\n\\nIf the given permutation is already sorted, print 0.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n3\\n3 2 1\\n7\\n4 5 7 1 3 2 6\\n5\\n1 2 3 4 5\\n\\n\\nOutput\\n\\n\\n3\\n5\\n0\\n\\nNote\\n\\nIn the first test case, the permutation will be changing as follows: \\n\\n * after the 1-st iteration: [2, 3, 1]; \\n * after the 2-nd iteration: [2, 1, 3]; \\n * after the 3-rd iteration: [1, 2, 3]. \\n\\n\\n\\nIn the second test case, the permutation will be changing as follows: \\n\\n * after the 1-st iteration: [4, 5, 1, 7, 2, 3, 6]; \\n * after the 2-nd iteration: [4, 1, 5, 2, 7, 3, 6]; \\n * after the 3-rd iteration: [1, 4, 2, 5, 3, 7, 6]; \\n * after the 4-th...\\nUsing java can you solve the prior task?\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.util.StringTokenizer;\\n\\npublic class pre72 {\\n static class FastReader {\\n BufferedReader br;\\n StringTokenizer st;\\n\\n public FastReader()\\n {\\n br = new BufferedReader(\\n new InputStreamReader(System.in));\\n }\\n\\n String next()\\n {\\n while (st == null || !st.hasMoreElements()) {\\n try {\\n st = new StringTokenizer(br.readLine());\\n }\\n catch (IOException e) {\\n e.printStackTrace();\\n }\\n }\\n return st.nextToken();\\n }\\n\\n int nextInt() { return Integer.parseInt(next()); }\\n\\n long nextLong() { return Long.parseLong(next()); }\\n\\n double nextDouble()\\n {\\n return Double.parseDouble(next());\\n }\\n\\n String nextLine()\\n {\\n String str = \\\"\\\";\\n try {\\n str = br.readLine();\\n }\\n catch (IOException e) {\\n e.printStackTrace();\\n }\\n return str;\\n }\\n }\\n static boolean check(int arr[]){\\n for(int i=0;iarr[i+1]) return false;\\n }\\n return true;\\n }\\n static void swap(int arr[],int i,int j){\\n int t = arr[i];\\n arr[i] = arr[j];\\n arr[j] = t;\\n }\\n public static void main(String args[]){\\n FastReader obj = new FastReader();\\n int tc = obj.nextInt();\\n while(tc--!=0){\\n int n = obj.nextInt(),arr[] = new int[n];\\n for(int i=0;iarr[j+1]){\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.\\n\\nGiven a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it ak) and delete it, at that all elements equal to ak + 1 and ak - 1 also must be deleted from the sequence. That step brings ak points to the player. \\n\\nAlex is a perfectionist, so he decided to get as many points as possible. Help him.\\n\\nInput\\n\\nThe first line contains integer n (1 ≤ n ≤ 105) that shows how many numbers are in Alex's sequence. \\n\\nThe second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 105).\\n\\nOutput\\n\\nPrint a single integer — the maximum number of points that Alex can earn.\\n\\nExamples\\n\\nInput\\n\\n2\\n1 2\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n3\\n1 2 3\\n\\n\\nOutput\\n\\n4\\n\\n\\nInput\\n\\n9\\n1 2 1 3 2 2 2 2 3\\n\\n\\nOutput\\n\\n10\\n\\nNote\\n\\nConsider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points.\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"from collections import Counter\\ndef fun(ls):\\n dct= Counter(ls)\\n mx=max(dct.keys())\\n for i in range(mx+1):\\n if(dct.get(i)==None):\\n dct[i]=0\\n # ans=get(mx,dct)\\n # print(ans)\\n dp=[]\\n dp.append(0)\\n dp.append(dct[1])\\n for i in range(2,mx+1):\\n dp.append(max(dct[i]*i+ dp[i-2],dp[i-1]))\\n print(dp[-1])\\n\\n \\nt= input()\\nls= list(map(int,input().split()))\\nfun(ls)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Let A = {a1, a2, ..., an} be any permutation of the first n natural numbers {1, 2, ..., n}. You are given a positive integer k and another sequence B = {b1, b2, ..., bn}, where bi is the number of elements aj in A to the left of the element at = i such that aj ≥ (i + k).\\n\\nFor example, if n = 5, a possible A is {5, 1, 4, 2, 3}. For k = 2, B is given by {1, 2, 1, 0, 0}. But if k = 3, then B = {1, 1, 0, 0, 0}.\\n\\nFor two sequences X = {x1, x2, ..., xn} and Y = {y1, y2, ..., yn}, let i-th elements be the first elements such that xi ≠ yi. If xi < yi, then X is lexicographically smaller than Y, while if xi > yi, then X is lexicographically greater than Y.\\n\\nGiven n, k and B, you need to determine the lexicographically smallest A.\\n\\nInput\\n\\nThe first line contains two space separated integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ n). On the second line are n integers specifying the values of B = {b1, b2, ..., bn}.\\n\\nOutput\\n\\nPrint on a single line n integers of A = {a1, a2, ..., an} such that A is lexicographically minimal. It is guaranteed that the solution exists.\\n\\nExamples\\n\\nInput\\n\\n5 2\\n1 2 1 0 0\\n\\n\\nOutput\\n\\n4 1 5 2 3 \\n\\nInput\\n\\n4 2\\n1 0 0 0\\n\\n\\nOutput\\n\\n2 3 1 4 \\\":\",\"targets\":\"#include \\nusing namespace std;\\nconst long maxn = 1005;\\nlong a[maxn];\\nlong b[maxn];\\nlong n, q, choice, k;\\nbool used[maxn];\\nint main() {\\n scanf(\\\"%ld%ld\\\", &n, &k);\\n for (q = 1; q <= n; q++) {\\n scanf(\\\"%ld\\\", &b[q]);\\n used[q] = false;\\n }\\n for (long step = 1; step <= n; step++) {\\n for (choice = 1; choice <= n; choice++)\\n if (!used[choice]) {\\n long temp = k + choice;\\n long cht = 0;\\n for (long pred = step - 1; pred >= 1; pred--)\\n if (a[pred] >= temp) cht++;\\n if (cht == b[choice]) break;\\n }\\n a[step] = choice;\\n used[choice] = true;\\n printf(\\\"%ld \\\", a[step]);\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alice gave Bob two integers a and b (a > 0 and b ≥ 0). Being a curious boy, Bob wrote down an array of non-negative integers with \\\\operatorname{MEX} value of all elements equal to a and \\\\operatorname{XOR} value of all elements equal to b.\\n\\nWhat is the shortest possible length of the array Bob wrote?\\n\\nRecall that the \\\\operatorname{MEX} (Minimum EXcluded) of an array is the minimum non-negative integer that does not belong to the array and the \\\\operatorname{XOR} of an array is the [bitwise XOR](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#XOR) of all the elements of the array.\\n\\nInput\\n\\nThe input consists of multiple test cases. The first line contains an integer t (1 ≤ t ≤ 5 ⋅ 10^4) — the number of test cases. The description of the test cases follows.\\n\\nThe only line of each test case contains two integers a and b (1 ≤ a ≤ 3 ⋅ 10^5; 0 ≤ b ≤ 3 ⋅ 10^5) — the \\\\operatorname{MEX} and \\\\operatorname{XOR} of the array, respectively.\\n\\nOutput\\n\\nFor each test case, output one (positive) integer — the length of the shortest array with \\\\operatorname{MEX} a and \\\\operatorname{XOR} b. We can show that such an array always exists.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n1 1\\n2 1\\n2 0\\n1 10000\\n2 10000\\n\\n\\nOutput\\n\\n\\n3\\n2\\n3\\n2\\n3\\n\\nNote\\n\\nIn the first test case, one of the shortest arrays with \\\\operatorname{MEX} 1 and \\\\operatorname{XOR} 1 is [0, 2020, 2021].\\n\\nIn the second test case, one of the shortest arrays with \\\\operatorname{MEX} 2 and \\\\operatorname{XOR} 1 is [0, 1].\\n\\nIt can be shown that these arrays are the shortest arrays possible.\\nSolve the task in PYTHON3.\",\"targets\":\"from math import *\\ndef computeXOR(n) :\\n \\n # Modulus operator are expensive\\n # on most of the computers. n & 3\\n # will be equivalent to n % 4.\\n if(n==0):\\n return 0\\n # if n is multiple of 4\\n if n % 4 == 0 :\\n return n\\n \\n # If n % 4 gives remainder 1\\n if n % 4 == 1 :\\n return 1\\n \\n # If n%4 gives remainder 2\\n if n % 4 == 2 :\\n return n + 1\\n \\n # If n%4 gives remainder 3\\n return 0\\n\\nt=int(input())\\nfor _ in range(t):\\n a,b=map(int,input().split())\\n calc=computeXOR(a-1)\\n if(calc==b):\\n print(a)\\n continue\\n #print(calc)\\n if(calc^b==a):\\n print(a+2)\\n else:\\n print(a+1)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number n. He asked what is this number and the teacher of mathematics Inna Petrovna answered Vova that n is the answer to the arithmetic task for first-graders. In the textbook, a certain positive integer x was given. The task was to add x to the sum of the digits of the number x written in decimal numeral system.\\n\\nSince the number n on the board was small, Vova quickly guessed which x could be in the textbook. Now he wants to get a program which will search for arbitrary values of the number n for all suitable values of x or determine that such x does not exist. Write such a program for Vova.\\n\\nInput\\n\\nThe first line contains integer n (1 ≤ n ≤ 109).\\n\\nOutput\\n\\nIn the first line print one integer k — number of different values of x satisfying the condition. \\n\\nIn next k lines print these values in ascending order.\\n\\nExamples\\n\\nInput\\n\\n21\\n\\n\\nOutput\\n\\n1\\n15\\n\\n\\nInput\\n\\n20\\n\\n\\nOutput\\n\\n0\\n\\nNote\\n\\nIn the first test case x = 15 there is only one variant: 15 + 1 + 5 = 21.\\n\\nIn the second test case there are no such x.\\\":\",\"targets\":\"#include \\nint convert_from_string(const std::string &s) {\\n std::istringstream i(s);\\n int x;\\n if (i >> x) return x;\\n return 0.0;\\n}\\nint main(int argc, char *argv[]) {\\n int n, k;\\n std::string n_s;\\n std::cin >> n_s;\\n std::vector aaa;\\n n = convert_from_string(n_s);\\n int down = std::max(n - (int)n_s.length() * 9, 0);\\n int cnt = 0;\\n for (int i = down; i <= n; i++) {\\n int temp = i, ans = i;\\n while (temp) {\\n ans += temp % 10;\\n temp \\/= 10;\\n }\\n if (ans == n) {\\n cnt++;\\n aaa.push_back(i);\\n }\\n }\\n std::cout << cnt << '\\\\n';\\n for (int i = 0; i < cnt; i++) {\\n std::cout << aaa[i] << '\\\\n';\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nLet's denote correct match equation (we will denote it as CME) an equation a + b = c there all integers a, b and c are greater than zero.\\n\\nFor example, equations 2 + 2 = 4 (||+||=||||) and 1 + 2 = 3 (|+||=|||) are CME but equations 1 + 2 = 4 (|+||=||||), 2 + 2 = 3 (||+||=|||), and 0 + 1 = 1 (+|=|) are not.\\n\\nNow, you have n matches. You want to assemble a CME using all your matches. Unfortunately, it is possible that you can't assemble the CME using all matches. But you can buy some extra matches and then assemble CME!\\n\\nFor example, if n = 2, you can buy two matches and assemble |+|=||, and if n = 5 you can buy one match and assemble ||+|=|||. \\n\\n\\n\\nCalculate the minimum number of matches which you have to buy for assembling CME.\\n\\nNote, that you have to answer q independent queries.\\n\\nInput\\n\\nThe first line contains one integer q (1 ≤ q ≤ 100) — the number of queries.\\n\\nThe only line of each query contains one integer n (2 ≤ n ≤ 10^9) — the number of matches.\\n\\nOutput\\n\\nFor each test case print one integer in single line — the minimum number of matches which you have to buy for assembling CME. \\n\\nExample\\n\\nInput\\n\\n\\n4\\n2\\n5\\n8\\n11\\n\\n\\nOutput\\n\\n\\n2\\n1\\n0\\n1\\n\\nNote\\n\\nThe first and second queries are explained in the statement.\\n\\nIn the third query, you can assemble 1 + 3 = 4 (|+|||=||||) without buying matches.\\n\\nIn the fourth query, buy one match and assemble 2 + 4 = 6 (||+||||=||||||).\",\"targets\":\"#include \\nusing namespace std;\\nint a[10000];\\nint main() {\\n int n;\\n int q;\\n cin >> n;\\n for (int i = 0; i < n; i++) {\\n cin >> q;\\n if (q == 2)\\n cout << 2 << endl;\\n else if (q == 3)\\n cout << 1 << endl;\\n else\\n cout << q % 2 << endl;\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Monocarp is playing a computer game. Now he wants to complete the first level of this game.\\n\\nA level is a rectangular grid of 2 rows and n columns. Monocarp controls a character, which starts in cell (1, 1) — at the intersection of the 1-st row and the 1-st column.\\n\\nMonocarp's character can move from one cell to another in one step if the cells are adjacent by side and\\/or corner. Formally, it is possible to move from cell (x_1, y_1) to cell (x_2, y_2) in one step if |x_1 - x_2| ≤ 1 and |y_1 - y_2| ≤ 1. Obviously, it is prohibited to go outside the grid.\\n\\nThere are traps in some cells. If Monocarp's character finds himself in such a cell, he dies, and the game ends.\\n\\nTo complete a level, Monocarp's character should reach cell (2, n) — at the intersection of row 2 and column n.\\n\\nHelp Monocarp determine if it is possible to complete the level.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. Then the test cases follow. Each test case consists of three lines.\\n\\nThe first line contains a single integer n (3 ≤ n ≤ 100) — the number of columns.\\n\\nThe next two lines describe the level. The i-th of these lines describes the i-th line of the level — the line consists of the characters '0' and '1'. The character '0' corresponds to a safe cell, the character '1' corresponds to a trap cell.\\n\\nAdditional constraint on the input: cells (1, 1) and (2, n) are safe.\\n\\nOutput\\n\\nFor each test case, output YES if it is possible to complete the level, and NO otherwise.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n000\\n000\\n4\\n0011\\n1100\\n4\\n0111\\n1110\\n6\\n010101\\n101010\\n\\n\\nOutput\\n\\n\\nYES\\nYES\\nNO\\nYES\\n\\nNote\\n\\nConsider the example from the statement.\\n\\nIn the first test case, one of the possible paths is (1, 1) → (2, 2) → (2, 3).\\n\\nIn the second test case, one of the possible paths is (1, 1) → (1, 2) → (2, 3) → (2, 4).\\n\\nIn the fourth test case, one of the possible paths is (1, 1) → (2, 2) → (1, 3) → (2, 4) → (1, 5) → (2, 6).\\nSolve the task in PYTHON3.\",\"targets\":\"for _ in range(int(input())):\\n n = int(input())\\n a = [[0, 0] for i in range(n)]\\n used = [[0, 0] for i in range(n)]\\n b = list(map(int, ' '.join(input().split())))\\n for i in range(n):\\n a[i][0] = b[i]\\n b = list(map(int, ' '.join(input().split())))\\n for i in range(n):\\n a[i][1] = b[i]\\n if a[0][1] == 1:\\n used[0][1] = 1\\n for i in range(1, n):\\n if not used[i - 1][0] or not used[i - 1][1]:\\n if a[i][0] and a[i][1]:\\n used[i] = [1, 1]\\n elif a[i][0] and not a[i][1]:\\n used[i] = [1, 0]\\n elif not a[i][0] and a[i][1]:\\n used[i] = [0, 1]\\n else:\\n used[i] = [0, 0]\\n else:\\n used[i] = [1, 1]\\n if not used[n - 1][1]:\\n print(\\\"YES\\\")\\n else:\\n print(\\\"NO\\\")\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"As Sherlock Holmes was investigating another crime, he found a certain number of clues. Also, he has already found direct links between some of those clues. The direct links between the clues are mutual. That is, the direct link between clues A and B and the direct link between clues B and A is the same thing. No more than one direct link can exist between two clues.\\n\\nOf course Sherlock is able to find direct links between all clues. But it will take too much time and the criminals can use this extra time to hide. To solve the crime, Sherlock needs each clue to be linked to all other clues (maybe not directly, via some other clues). Clues A and B are considered linked either if there is a direct link between them or if there is a direct link between A and some other clue C which is linked to B. \\n\\nSherlock Holmes counted the minimum number of additional direct links that he needs to find to solve the crime. As it turns out, it equals T.\\n\\nPlease count the number of different ways to find exactly T direct links between the clues so that the crime is solved in the end. Two ways to find direct links are considered different if there exist two clues which have a direct link in one way and do not have a direct link in the other way. \\n\\nAs the number of different ways can turn out rather big, print it modulo k.\\n\\nInput\\n\\nThe first line contains three space-separated integers n, m, k (1 ≤ n ≤ 105, 0 ≤ m ≤ 105, 1 ≤ k ≤ 109) — the number of clues, the number of direct clue links that Holmes has already found and the divisor for the modulo operation.\\n\\nEach of next m lines contains two integers a and b (1 ≤ a, b ≤ n, a ≠ b), that represent a direct link between clues. It is guaranteed that any two clues are linked by no more than one direct link. Note that the direct links between the clues are mutual.\\n\\nOutput\\n\\nPrint the single number — the answer to the problem modulo k.\\n\\nExamples\\n\\nInput\\n\\n2 0 1000000000\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\n3 0 100\\n\\n\\nOutput\\n\\n3\\n\\n\\nInput\\n\\n4 1 1000000000\\n1 4\\n\\n\\nOutput\\n\\n8\\n\\nNote\\n\\nThe first sample only has two...\",\"targets\":\"#include \\nusing namespace std;\\nchar buf[1 << 21], *p1 = buf, *p2 = buf;\\ntemplate \\nvoid read(T &x) {\\n x = 0;\\n int c = getchar();\\n int flag = 0;\\n while (c < '0' || c > '9') flag |= (c == '-'), c = getchar();\\n while (c >= '0' && c <= '9')\\n x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();\\n if (flag) x = -x;\\n}\\ntemplate \\nT _max(T a, T b) {\\n return b < a ? a : b;\\n}\\ntemplate \\nT _min(T a, T b) {\\n return a < b ? a : b;\\n}\\ntemplate \\nbool checkmax(T &a, T b) {\\n return a < b ? a = b, 1 : 0;\\n}\\ntemplate \\nbool checkmin(T &a, T b) {\\n return b < a ? a = b, 1 : 0;\\n}\\nconst int N = 100005;\\nint n, m, mod;\\nint fa[N], siz[N];\\nint getfather(int x) { return x == fa[x] ? x : fa[x] = getfather(fa[x]); }\\nvoid unite(int x, int y) {\\n x = getfather(x);\\n y = getfather(y);\\n if (x ^ y) {\\n fa[x] = y;\\n siz[y] += siz[x];\\n }\\n}\\nvoid init() {\\n read(n);\\n read(m);\\n read(mod);\\n for (int i = 1; i <= n; ++i) {\\n fa[i] = i;\\n siz[i] = 1;\\n }\\n for (int i = 1, u, v; i <= m; ++i) {\\n read(u);\\n read(v);\\n unite(u, v);\\n }\\n}\\nvoid solve() {\\n int ans = 1, total = 0;\\n for (int i = 1; i <= n; ++i) {\\n if (getfather(i) == i) {\\n ans = (long long)ans * siz[i] % mod;\\n ++total;\\n }\\n }\\n if (total == 1) {\\n printf(\\\"%d\\\\n\\\", 1 % mod);\\n return;\\n }\\n for (int i = 1; i <= total - 2; ++i) ans = (long long)ans * n % mod;\\n printf(\\\"%d\\\\n\\\", ans);\\n}\\nint main() {\\n init();\\n solve();\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Alice likes snow a lot! Unfortunately, this year's winter is already over, and she can't expect to have any more of it. Bob has thus bought her a gift — a large snow maker. He plans to make some amount of snow every day. On day i he will make a pile of snow of volume Vi and put it in her garden.\\n\\nEach day, every pile will shrink a little due to melting. More precisely, when the temperature on a given day is Ti, each pile will reduce its volume by Ti. If this would reduce the volume of a pile to or below zero, it disappears forever. All snow piles are independent of each other. \\n\\nNote that the pile made on day i already loses part of its volume on the same day. In an extreme case, this may mean that there are no piles left at the end of a particular day.\\n\\nYou are given the initial pile sizes and the temperature on each day. Determine the total volume of snow melted on each day. \\n\\nInput\\n\\nThe first line contains a single integer N (1 ≤ N ≤ 105) — the number of days. \\n\\nThe second line contains N integers V1, V2, ..., VN (0 ≤ Vi ≤ 109), where Vi is the initial size of a snow pile made on the day i.\\n\\nThe third line contains N integers T1, T2, ..., TN (0 ≤ Ti ≤ 109), where Ti is the temperature on the day i.\\n\\nOutput\\n\\nOutput a single line with N integers, where the i-th integer represents the total volume of snow melted on day i.\\n\\nExamples\\n\\nInput\\n\\n3\\n10 10 5\\n5 7 2\\n\\n\\nOutput\\n\\n5 12 4\\n\\n\\nInput\\n\\n5\\n30 25 20 15 10\\n9 10 12 4 13\\n\\n\\nOutput\\n\\n9 20 35 11 25\\n\\nNote\\n\\nIn the first sample, Bob first makes a snow pile of volume 10, which melts to the size of 5 on the same day. On the second day, he makes another pile of size 10. Since it is a bit warmer than the day before, the first pile disappears completely while the second pile shrinks to 3. At the end of the second day, he has only a single pile of size 3. On the third day he makes a smaller pile than usual, but as the temperature dropped too, both piles survive till the end of the day.\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int n;\\n scanf(\\\"%d\\\", &n);\\n int v[n];\\n for (int i = 0; i < n; i++) {\\n scanf(\\\"%d\\\", &v[i]);\\n }\\n int t[n];\\n for (int i = 0; i < n; i++) {\\n scanf(\\\"%d\\\", &t[i]);\\n }\\n multiset ms;\\n long long temp = 0;\\n for (int i = 0; i < n; i++) {\\n ms.insert(v[i] + temp);\\n temp += t[i];\\n auto lim = ms.lower_bound(temp + 1);\\n long long sum = 0;\\n for (auto it = ms.begin(); it != lim; it++) {\\n sum += (*it - (temp - t[i]));\\n }\\n ms.erase(ms.begin(), lim);\\n sum += t[i] * ms.size();\\n printf(\\\"%lld%c\\\", sum, (i == n - 1 ? '\\\\n' : ' '));\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nCarl has n coins of various colors, and he would like to sort them into piles. The coins are labeled 1,2,…,n, and each coin is exactly one of red, green, or blue. He would like to sort the coins into three different piles so one pile contains all red coins, one pile contains all green coins, and one pile contains all blue coins.\\n\\nUnfortunately, Carl is colorblind, so this task is impossible for him. Luckily, he has a friend who can take a pair of coins and tell Carl if they are the same color or not. Using his friend, Carl believes he can now sort the coins. The order of the piles doesn't matter, as long as all same colored coins are in the one pile, and no two different colored coins are in the same pile.\\n\\nHis friend will answer questions about multiple pairs of coins in batches, and will answer about all of those pairs in parallel. Each coin should be in at most one pair in each batch. The same coin can appear in different batches.\\n\\nCarl can use only 7 batches. Help him find the piles of coins after sorting.\\n\\nInteraction\\n\\nYou will be given multiple test cases. The first line contains an integer t (1 ≤ t ≤ 5) — the number of test cases.\\n\\nThe first line of each test case contains one integer n (1 ≤ n ≤ 10^5) — the number of coins. If you read in a value of -1 here, that means that you printed an invalid answer in the previous case and exit immediately to avoid getting other verdicts.\\n\\nTo ask a question, print \\\"Q k\\\\ x_1\\\\ y_1\\\\ …\\\\ x_k\\\\ y_k\\\" (1 ≤ k ≤ n\\/2, 1 ≤ x_i,y_i ≤ n, x_i ≠ y_i). k denotes the number of pairs in the batch, and x_i, y_i denote the i-th pair of coins in the batch. A coin can only appear at most once in a batch. All x_i and y_i should be distinct.\\n\\nThe judge will respond with a bitstring of length k, where the i-th character is \\\"1\\\" if x_i and y_i are the same color, and \\\"0\\\" otherwise. The judge will respond with -1 if you ever ask an invalid query. Make sure to exit immediately to avoid getting other verdicts.\\n\\nWhen you are ready to answer, print four lines.\\n\\nThe first line contains \\\"A k_1\\\\ k_2\\\\...\",\"targets\":\"#include \\nusing namespace std;\\nconst int Nmax = 1e5 + 5;\\nconst bool debug = 0;\\nvector> q;\\nint Col[Nmax], colour[Nmax], from[Nmax];\\nint n;\\nstring ans_mic() {\\n if (q.empty()) return \\\"\\\";\\n int i;\\n string ans;\\n if (debug)\\n for (i = 0; i < q.size(); ++i)\\n ans.push_back('0' + (Col[q[i].first] == Col[q[i].second]));\\n else {\\n cout << \\\"Q \\\" << q.size() << ' ';\\n for (auto it : q) cout << it.first << ' ' << it.second << ' ';\\n cout << endl;\\n cin >> ans;\\n }\\n return ans;\\n}\\nstring intercal(string a, string b) {\\n string ans;\\n int i;\\n for (i = 0; i < (int)a.size(); ++i) {\\n ans.push_back(a[i]);\\n if (i < b.size()) ans.push_back(b[i]);\\n }\\n return ans;\\n}\\nstring get_answer(vector &v) {\\n int i;\\n string ans1, ans2;\\n for (i = 0; i + 1 < (int)v.size(); i += 2) q.push_back({v[i], v[i + 1]});\\n ans1 = ans_mic();\\n q.clear();\\n for (i = 1; i + 1 < (int)v.size(); i += 2) q.push_back({v[i], v[i + 1]});\\n ans2 = ans_mic();\\n q.clear();\\n return intercal(ans1, ans2);\\n}\\nvoid prepare_interactor() {\\n int i;\\n for (i = 1; i <= n; ++i) cin >> Col[i];\\n}\\nvoid oooo() {\\n int i;\\n string ans;\\n vector v, F, F1, F2;\\n for (i = 1; i <= n; ++i) v.push_back(i);\\n ans = get_answer(v);\\n for (i = 1; i <= n; ++i)\\n if (i == 1 || ans[i - 2] == '0')\\n F.push_back(i);\\n else\\n from[i] = i - 1;\\n if (F.size() == 1) {\\n colour[F[0]] = 1;\\n return;\\n }\\n for (i = 0; i < (int)F.size(); i += 2) {\\n F1.push_back(F[i]);\\n if (i + 1 < (int)F.size()) F2.push_back(F[i + 1]);\\n }\\n string ans1, ans2;\\n ans = intercal(get_answer(F1), get_answer(F2));\\n colour[F[0]] = 1;\\n colour[F[1]] = 2;\\n for (i = 2; i < (int)F.size(); ++i)\\n if (ans[i - 2] == '1')\\n colour[F[i]] = colour[F[i - 2]];\\n else\\n colour[F[i]] = 6 - colour[F[i - 2]] - colour[F[i - 1]];\\n}\\nvoid solve() {\\n cin >> n;\\n if (debug) prepare_interactor();\\n oooo();\\n vector wh[5];\\n int i;\\n for (i = 1; i <= n; ++i) {\\n if (!colour[i]) colour[i] = colour[from[i]];\\n wh[colour[i]].push_back(i);\\n ...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Polycarp doesn't like integers that are divisible by 3 or end with the digit 3 in their decimal representation. Integers that meet both conditions are disliked by Polycarp, too.\\n\\nPolycarp starts to write out the positive (greater than 0) integers which he likes: 1, 2, 4, 5, 7, 8, 10, 11, 14, 16, .... Output the k-th element of this sequence (the elements are numbered from 1).\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 100) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one line containing one integer k (1 ≤ k ≤ 1000).\\n\\nOutput\\n\\nFor each test case, output in a separate line one integer x — the k-th element of the sequence that was written out by Polycarp.\\n\\nExample\\n\\nInput\\n\\n\\n10\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n1000\\n\\n\\nOutput\\n\\n\\n1\\n2\\n4\\n5\\n7\\n8\\n10\\n11\\n14\\n1666\\nUsing python3 can you solve the prior task?\",\"targets\":\"def chack(data):\\n count=0\\n i=0\\n for i in range(10000):\\n if((i%3!=0) and (i%10!=3)):\\n count+=1\\n if(count==data):\\n return i\\n\\n\\nif __name__ == '__main__':\\n for _ in range(int(input())):\\n k = int(input())\\n x= chack(k)\\n print(x)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Curry making\\n\\nAs the ACM-ICPC domestic qualifying is approaching, you who wanted to put more effort into practice decided to participate in a competitive programming camp held at a friend's house. Participants decided to prepare their own meals.\\n\\nOn the first night of the training camp, the participants finished the day's practice and began preparing dinner. Not only in competitive programming, but also in self-catering, you are often said to be a \\\"professional\\\", and you have spared time because you have finished making the menu for your charge in a blink of an eye. Therefore, I decided to help other people make curry.\\n\\nNow, there is a curry made by mixing R0 [g] roux with W0 [L] water. There is one type of roux used this time, and each roux is R [g]. Ru has a sufficient stockpile. When you use this roux, you think that the curry with a concentration of C [g \\/ L] is the most delicious, so add some roux and water to this curry appropriately to make the concentration C [g \\/ L]. I want to. Here, the concentration of curry in which roux R0 [g] is dissolved in water W0 [L] is R0 \\/ W0 [g \\/ L], and X roux of R [g] and water Y [L] are added to this curry. ] Is added, the concentration becomes (R0 + XR) \\/ (W0 + Y) [g \\/ L]. Although there are a lot of roux, you thought that it was not good to use too much, so you decided to make a curry with a concentration of C [g \\/ L] by reducing the number of roux to be added as much as possible.\\n\\nWhen making a curry with a concentration of C [g \\/ L] by properly adding either roux, water, or both to a curry with a concentration of R0 \\/ W0 [g \\/ L], the number of roux X to be added Find the minimum value.\\n\\nHowever, please note the following points regarding the curry making this time.\\n\\n* Number of roux to be added The value of X must be an integer greater than or equal to 0. In other words, it is not possible to add only 1\\/3 of the roux.\\n* The value of the volume Y of water to be added can be a real number greater than or equal to 0, and does not have to be an integer.\\n* In some...\",\"targets\":\"#include \\n#define REP(i,n,N) for(int i=n;i>R0>>W0>>C>>R,R0){\\n\\t\\tint ans;\\n\\t\\tint c=R0\\/W0;\\n\\t\\tfor(ans=0;c\\nusing namespace std;\\nconst int maxn = 200 + 10;\\nstring s;\\nint k, a, b, n;\\nint x[maxn];\\nint main() {\\n cin >> k >> a >> b;\\n cin >> s;\\n n = s.size();\\n if (k * b < n || k * a > n) {\\n cout << \\\"No solution\\\" << endl;\\n return 0;\\n }\\n int cnt = k * b;\\n for (int i = 1; i <= k; i++) x[i] = b;\\n for (int i = 1; i <= k; i++) {\\n if (cnt - n >= b - a) {\\n x[i] = a;\\n cnt -= b - a;\\n } else {\\n x[i] = x[i] - (cnt - n);\\n break;\\n }\\n }\\n int ind = 0;\\n for (int i = 1; i <= k; i++) {\\n int ind1 = ind;\\n int ind2 = ind + x[i] - 1;\\n ind = ind2 + 1;\\n for (int j = ind1; j <= ind2; j++) cout << s[j];\\n cout << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"For a permutation p of numbers 1 through n, we define a stair array a as follows: a_i is length of the longest segment of permutation which contains position i and is made of consecutive values in sorted order: [x, x+1, …, y-1, y] or [y, y-1, …, x+1, x] for some x ≤ y. For example, for permutation p = [4, 1, 2, 3, 7, 6, 5] we have a = [1, 3, 3, 3, 3, 3, 3]. \\n\\nYou are given the stair array a. Your task is to calculate the number of permutations which have stair array equal to a. Since the number can be big, compute it modulo 998 244 353. Note that this number can be equal to zero.\\n\\nInput\\n\\nThe first line of input contains integer n (1 ≤ n ≤ 10^5) — the length of a stair array a.\\n\\nThe second line of input contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ n).\\n\\nOutput\\n\\nPrint the number of permutations which have stair array equal to a. Since the number can be big, compute it modulo 998 244 353.\\n\\nExamples\\n\\nInput\\n\\n\\n6\\n3 3 3 1 1 1\\n\\n\\nOutput\\n\\n\\n6\\n\\n\\nInput\\n\\n\\n7\\n4 4 4 4 3 3 3\\n\\n\\nOutput\\n\\n\\n6\\n\\n\\nInput\\n\\n\\n1\\n1\\n\\n\\nOutput\\n\\n\\n1\\n\\n\\nInput\\n\\n\\n8\\n2 2 2 2 2 2 1 1\\n\\n\\nOutput\\n\\n\\n370\\n\\n\\nInput\\n\\n\\n4\\n3 2 3 1\\n\\n\\nOutput\\n\\n\\n0\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nlong long read() {\\n long long x = 0, f = 1;\\n char c = getchar();\\n while (c < '0' || c > '9') {\\n if (c == '-') f = -1;\\n c = getchar();\\n }\\n while (c >= '0' && c <= '9') x = x * 10 + (c - '0'), c = getchar();\\n return f * x;\\n}\\nconst int MAXN = 265011, mod = 998244353, inv2 = (mod + 1) >> 1;\\nlong long Qpow(long long a, long long p) {\\n long long res = 1;\\n while (p) {\\n if (p & 1) res = res * a % mod;\\n a = a * a % mod, p >>= 1;\\n }\\n return res;\\n}\\nvoid Add(int& a, int t) {\\n a += t;\\n if (a >= mod) a -= mod;\\n}\\ninline int S(int x) { return x < mod ? x : x - mod; }\\ninline int D(int x) { return x < 0 ? x + mod : x; }\\nnamespace NTT {\\nlong long RT[MAXN], invL[MAXN];\\nvoid init() {\\n invL[1] = 1;\\n for (int i = 1; i < (1 << 18); i <<= 1) {\\n long long R = Qpow(3, (mod - 1) \\/ (i << 1));\\n RT[i] = 1;\\n for (int j = 1; j < i; ++j) RT[i + j] = RT[i + j - 1] * R % mod;\\n invL[i << 1] = invL[i] * inv2 % mod;\\n }\\n}\\nint f[MAXN], g[MAXN], status[MAXN];\\nvoid DFT(int* a, int len) {\\n for (int i = 0; i < len; ++i)\\n if (status[i] > i) std::swap(a[i], a[status[i]]);\\n for (int cur = 1; cur < len; cur <<= 1)\\n for (int j = 0; j < len; j += cur << 1)\\n for (int k = 0; k < cur; ++k) {\\n int x = a[j + k], y = RT[cur + k] * a[j + cur + k] % mod;\\n a[j + k] = S(x + y), a[j + cur + k] = D(x - y);\\n }\\n}\\nvoid IDFT(int* a, int len) {\\n std::reverse(a + 1, a + len);\\n DFT(a, len);\\n for (int i = 0; i < len; ++i) a[i] = a[i] * invL[len] % mod;\\n}\\nvoid Mul(int n) {\\n int len = 1;\\n while (len < n) len <<= 1;\\n for (int i = 0; i < len; ++i)\\n status[i] = (status[i >> 1] >> 1) | ((i & 1) ? len >> 1 : 0);\\n DFT(f, len), DFT(g, len);\\n for (int i = 0; i < len; ++i) f[i] = long long(f[i]) * g[i] % mod, g[i] = 0;\\n IDFT(f, len);\\n}\\n} \\/\\/ namespace NTT\\nstruct poly : std::vector {\\n poly() { clear(); }\\n poly(int x) { resize(x); }\\n poly operator+(poly you) {\\n poly res = *this;\\n if (res.size() < you.size()) res.resize(you.size());\\n for (int i = 0; i < you.size(); ++i)...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"JATC and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an array a_1, a_2, ..., a_n of integers, such that 1 ≤ a_1 < a_2 < … < a_n ≤ 10^3, and then went to the bathroom.\\n\\nJATC decided to prank his friend by erasing some consecutive elements in the array. Since he doesn't want for the prank to go too far, he will only erase in a way, such that Giraffe can still restore the array using the information from the remaining elements. Because Giraffe has created the array, he's also aware that it's an increasing array and all the elements are integers in the range [1, 10^3].\\n\\nJATC wonders what is the greatest number of elements he can erase?\\n\\nInput\\n\\nThe first line of the input contains a single integer n (1 ≤ n ≤ 100) — the number of elements in the array.\\n\\nThe second line of the input contains n integers a_i (1 ≤ a_1\\nusing namespace std;\\nint v[105];\\nint main() {\\n int n, i, cnt = 0, cntmax = -1;\\n cin >> n;\\n for (i = 1; i <= n; i++) cin >> v[i];\\n v[i] = 1001;\\n for (i = 1; i <= n; i++) {\\n if (v[i] == v[i - 1] + 1 && v[i] == v[i + 1] - 1)\\n cnt++;\\n else {\\n if (cnt > cntmax) cntmax = cnt;\\n cnt = 0;\\n }\\n }\\n if (cnt > cntmax) cntmax = cnt;\\n cout << cntmax;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"Monocarp is playing yet another computer game. In this game, his character has to kill a dragon. The battle with the dragon lasts 100^{500} seconds, during which Monocarp attacks the dragon with a poisoned dagger. The i-th attack is performed at the beginning of the a_i-th second from the battle start. The dagger itself does not deal damage, but it applies a poison effect on the dragon, which deals 1 damage during each of the next k seconds (starting with the same second when the dragon was stabbed by the dagger). However, if the dragon has already been poisoned, then the dagger updates the poison effect (i.e. cancels the current poison effect and applies a new one).\\n\\nFor example, suppose k = 4, and Monocarp stabs the dragon during the seconds 2, 4 and 10. Then the poison effect is applied at the start of the 2-nd second and deals 1 damage during the 2-nd and 3-rd seconds; then, at the beginning of the 4-th second, the poison effect is reapplied, so it deals exactly 1 damage during the seconds 4, 5, 6 and 7; then, during the 10-th second, the poison effect is applied again, and it deals 1 damage during the seconds 10, 11, 12 and 13. In total, the dragon receives 10 damage.\\n\\nMonocarp knows that the dragon has h hit points, and if he deals at least h damage to the dragon during the battle — he slays the dragon. Monocarp has not decided on the strength of the poison he will use during the battle, so he wants to find the minimum possible value of k (the number of seconds the poison effect lasts) that is enough to deal at least h damage to the dragon.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases.\\n\\nThe first line of the test case contains two integers n and h (1 ≤ n ≤ 100; 1 ≤ h ≤ 10^{18}) — the number of Monocarp's attacks and the amount of damage that needs to be dealt.\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9; a_i < a_{i + 1}), where a_i is the second when the i-th attack is performed.\\n\\nOutput\\n\\nFor each test case, print a single...\\\":\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.io.PrintWriter;\\nimport java.util.ArrayList;\\nimport java.util.Collections;\\nimport java.util.StringTokenizer;\\n\\n\\n\\npublic class CodeForces {\\n\\n \\n static class FastScanner {\\n\\t\\tBufferedReader br=new BufferedReader(new InputStreamReader(System.in));\\n\\t\\tStringTokenizer st=new StringTokenizer(\\\"\\\");\\n\\t\\tString next() {\\n\\t\\t\\twhile (!st.hasMoreTokens())\\n\\t\\t\\t\\ttry {\\n\\t\\t\\t\\t\\tst=new StringTokenizer(br.readLine());\\n\\t\\t\\t\\t} catch (IOException e) {\\n\\t\\t\\t\\t\\te.printStackTrace();\\n\\t\\t\\t\\t}\\n\\t\\t\\treturn st.nextToken();\\n\\t\\t}\\n\\t\\t\\n\\t\\tint nextInt() {\\n\\t\\t\\treturn Integer.parseInt(next());\\n\\t\\t}\\n\\t\\tint[] readArray(int n) {\\n\\t\\t\\tint[] a=new int[n];\\n\\t\\t\\tfor (int i=0; i b = new ArrayList<>();\\n for(int i:a)b.add(i);\\n Collections.sort(b);\\n for(int i=0;i b = new ArrayList<>();\\n for(int i:a)b.add(i);\\n Collections.sort(b);\\n Collections.reverse(b);\\n for(int i=0;i b = new ArrayList<>();\\n for(long i:a)b.add(i);\\n Collections.sort(b);\\n for(int i=0;i\\nusing namespace std;\\nint n, k, last, c, arr[1000002];\\nlong long cnt;\\nstring s;\\nmap m;\\nint main() {\\n ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);\\n cin >> k >> s;\\n n = s.size();\\n arr[0]++;\\n for (int i = 0; i < n; i++) {\\n c += (s[i] == '1');\\n (c >= k) ? cnt += arr[c - k] : cnt += 0;\\n arr[c]++;\\n }\\n cout << cnt << \\\"\\\\n\\\";\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Fennec and Snuke are playing a board game.\\n\\nOn the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the graph formed by the cells and the roads is a tree.\\n\\nInitially, Cell 1 is painted black, and Cell N is painted white. The other cells are not yet colored. Fennec (who goes first) and Snuke (who goes second) alternately paint an uncolored cell. More specifically, each player performs the following action in her\\/his turn:\\n\\n* Fennec: selects an uncolored cell that is adjacent to a black cell, and paints it black.\\n* Snuke: selects an uncolored cell that is adjacent to a white cell, and paints it white.\\n\\n\\n\\nA player loses when she\\/he cannot paint a cell. Determine the winner of the game when Fennec and Snuke play optimally.\\n\\nConstraints\\n\\n* 2 \\\\leq N \\\\leq 10^5\\n* 1 \\\\leq a_i, b_i \\\\leq N\\n* The given graph is a tree.\\n\\nInput\\n\\nInput is given from Standard Input in the following format:\\n\\n\\nN\\na_1 b_1\\n:\\na_{N-1} b_{N-1}\\n\\n\\nOutput\\n\\nIf Fennec wins, print `Fennec`; if Snuke wins, print `Snuke`.\\n\\nExamples\\n\\nInput\\n\\n7\\n3 6\\n1 2\\n3 1\\n7 4\\n5 7\\n1 4\\n\\n\\nOutput\\n\\nFennec\\n\\n\\nInput\\n\\n4\\n1 4\\n4 2\\n2 3\\n\\n\\nOutput\\n\\nSnuke\\nUsing python3 can you solve the prior task?\",\"targets\":\"import sys\\nsys.setrecursionlimit(10000000)\\ndef search(prev, start, stop):\\n global nodes, edges\\n for neigh in nodes[start]:\\n if neigh==prev:\\n continue\\n if neigh==stop:\\n return [stop,start]\\n res=search(start,neigh,stop)\\n if res!=False:\\n res.append(start)\\n return res\\n return False\\n\\ndef size(prev, curr):\\n su=1\\n global nodes, edges\\n for neigh in nodes[curr]:\\n if neigh==prev:\\n continue\\n su+=size(curr,neigh)\\n return su\\n\\nn=int(input())\\nnodes=[[] for i in range (n)]\\nedges=[]\\nfor i in range(n-1):\\n line=input().split()\\n a=int(line[0])-1\\n b=int(line[1])-1\\n edges.append([a,b])\\n nodes[b].append(a)\\n nodes[a].append(b)\\n\\nres=search(-1,n-1,0)\\n\\nfennec=(len(res)-1)\\/\\/2\\nsnuke=fennec+1\\nsnuke=res[snuke]\\nfennec=res[fennec]\\nfennecsize=size(snuke,fennec)\\nsnukesize=size(fennec,snuke)\\n\\nif fennecsize>snukesize:\\n print (\\\"Fennec\\\")\\nelse:\\n print(\\\"Snuke\\\")\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Drazil is playing a math game with Varda.\\n\\nLet's define for positive integer x as a product of factorials of its digits. For example, .\\n\\nFirst, they choose a decimal number a consisting of n digits that contains at least one digit larger than 1. This number may possibly start with leading zeroes. Then they should find maximum positive number x satisfying following two conditions:\\n\\n1. x doesn't contain neither digit 0 nor digit 1.\\n\\n2. = .\\n\\nHelp friends find such number.\\n\\nInput\\n\\nThe first line contains an integer n (1 ≤ n ≤ 15) — the number of digits in a.\\n\\nThe second line contains n digits of a. There is at least one digit in a that is larger than 1. Number a may possibly contain leading zeroes.\\n\\nOutput\\n\\nOutput a maximum possible integer satisfying the conditions above. There should be no zeroes and ones in this number decimal representation.\\n\\nExamples\\n\\nInput\\n\\n4\\n1234\\n\\n\\nOutput\\n\\n33222\\n\\n\\nInput\\n\\n3\\n555\\n\\n\\nOutput\\n\\n555\\n\\nNote\\n\\nIn the first case, \\nn=int\",\"targets\":\"(input())\\ns1=str(input())\\na=list(s1)\\nlist1=[int(c) for c in a]\\nlist2=[]\\nfor i in range(n):\\n if list1[i]==2:\\n list2.append(2)\\n elif list1[i]==3:\\n list2.append(3)\\n elif list1[i]==4:\\n list2.append(3)\\n list2.append(2)\\n list2.append(2)\\n elif list1[i]==5:\\n list2.append(5)\\n elif list1[i]==6:\\n list2.append(3)\\n list2.append(5)\\n elif list1[i]==7:\\n list2.append(7)\\n elif list1[i]==8:\\n list2.append(7)\\n list2.append(2)\\n list2.append(2)\\n list2.append(2)\\n elif list1[i]==9:\\n list2.append(7)\\n list2.append(3)\\n list2.append(3)\\n list2.append(2)\\nlist2.sort()\\nlist2.reverse()\\n#print(list2)\\nlist3=[str(x) for x in list2]\\nprint(''.join(list3))\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"n players are playing a game. \\n\\nThere are two different maps in the game. For each player, we know his strength on each map. When two players fight on a specific map, the player with higher strength on that map always wins. No two players have the same strength on the same map. \\n\\nYou are the game master and want to organize a tournament. There will be a total of n-1 battles. While there is more than one player in the tournament, choose any map and any two remaining players to fight on it. The player who loses will be eliminated from the tournament. \\n\\nIn the end, exactly one player will remain, and he is declared the winner of the tournament. For each player determine if he can win the tournament.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. The description of test cases follows.\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 10^5) — the number of players.\\n\\nThe second line of each test case contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9, a_i ≠ a_j for i ≠ j), where a_i is the strength of the i-th player on the first map. \\n\\nThe third line of each test case contains n integers b_1, b_2, ..., b_n (1 ≤ b_i ≤ 10^9, b_i ≠ b_j for i ≠ j), where b_i is the strength of the i-th player on the second map. \\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 10^5.\\n\\nOutput\\n\\nFor each test case print a string of length n. i-th character should be \\\"1\\\" if the i-th player can win the tournament, or \\\"0\\\" otherwise.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n4\\n1 2 3 4\\n1 2 3 4\\n4\\n11 12 20 21\\n44 22 11 30\\n1\\n1000000000\\n1000000000\\n\\n\\nOutput\\n\\n\\n0001\\n1111\\n1\\n\\nNote\\n\\nIn the first test case, the 4-th player will beat any other player on any game, so he will definitely win the tournament.\\n\\nIn the second test case, everyone can be a winner. \\n\\nIn the third test case, there is only one player. Clearly, he will win the tournament.\\\":\",\"targets\":\"#include \\nusing namespace std;\\nstruct node {\\n int now;\\n int val;\\n} a[100005], b[100005];\\nbool cmp(node x, node y) { return x.val > y.val; }\\nint main() {\\n int t;\\n cin >> t;\\n while (t--) {\\n int n;\\n int mark[100005] = {0};\\n cin >> n;\\n for (int i = 1; i <= n; ++i) {\\n a[i].now = b[i].now = a[i].val = b[i].val = 0;\\n }\\n for (int i = 1; i <= n; ++i) {\\n cin >> a[i].val;\\n a[i].now = i;\\n }\\n for (int i = 1; i <= n; ++i) {\\n cin >> b[i].val;\\n b[i].now = i;\\n }\\n sort(a + 1, a + 1 + n, cmp);\\n sort(b + 1, b + 1 + n, cmp);\\n set st;\\n for (int i = 1; i <= n; ++i) {\\n st.insert(a[i].now);\\n st.insert(b[i].now);\\n mark[a[i].now] = 1;\\n mark[b[i].now] = 1;\\n if (st.size() == i) {\\n break;\\n }\\n }\\n for (int i = 1; i <= n; ++i) {\\n cout << mark[i];\\n }\\n cout << \\\"\\\\n\\\";\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given an array a of n integers, and another integer k such that 2k ≤ n.\\n\\nYou have to perform exactly k operations with this array. In one operation, you have to choose two elements of the array (let them be a_i and a_j; they can be equal or different, but their positions in the array must not be the same), remove them from the array, and add ⌊ (a_i)\\/(a_j) ⌋ to your score, where ⌊ x\\/y ⌋ is the maximum integer not exceeding x\\/y.\\n\\nInitially, your score is 0. After you perform exactly k operations, you add all the remaining elements of the array to the score.\\n\\nCalculate the minimum possible score you can get.\\n\\nInput\\n\\nThe first line of the input contains one integer t (1 ≤ t ≤ 500) — the number of test cases.\\n\\nEach test case consists of two lines. The first line contains two integers n and k (1 ≤ n ≤ 100; 0 ≤ k ≤ ⌊ n\\/2 ⌋).\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 2 ⋅ 10^5).\\n\\nOutput\\n\\nPrint one integer — the minimum possible score you can get.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n7 3\\n1 1 1 2 1 3 1\\n5 1\\n5 5 5 5 5\\n4 2\\n1 3 3 7\\n2 0\\n4 2\\n9 2\\n1 10 10 1 10 2 7 10 3\\n\\n\\nOutput\\n\\n\\n2\\n16\\n0\\n6\\n16\\n\\nNote\\n\\nLet's consider the example test.\\n\\nIn the first test case, one way to obtain a score of 2 is the following one:\\n\\n 1. choose a_7 = 1 and a_4 = 2 for the operation; the score becomes 0 + ⌊ 1\\/2 ⌋ = 0, the array becomes [1, 1, 1, 1, 3]; \\n 2. choose a_1 = 1 and a_5 = 3 for the operation; the score becomes 0 + ⌊ 1\\/3 ⌋ = 0, the array becomes [1, 1, 1]; \\n 3. choose a_1 = 1 and a_2 = 1 for the operation; the score becomes 0 + ⌊ 1\\/1 ⌋ = 1, the array becomes [1]; \\n 4. add the remaining element 1 to the score, so the resulting score is 2. \\n\\n\\n\\nIn the second test case, no matter which operations you choose, the resulting score is 16.\\n\\nIn the third test case, one way to obtain a score of 0 is the following one:\\n\\n 1. choose a_1 = 1 and a_2 = 3 for the operation; the score becomes 0 + ⌊ 1\\/3 ⌋ = 0, the array becomes [3, 7]; \\n 2. choose a_1 = 3 and a_2 = 7 for the operation; the score becomes 0 + ⌊ 3\\/7 ⌋ = 0, the array becomes...\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst int maxn = 129;\\nint t, n, k;\\nlong long a[maxn];\\nint main() {\\n ios_base ::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n cin >> t;\\n while (t--) {\\n long long ans = 0;\\n cin >> n >> k;\\n for (int i = 1; i <= n; i++) cin >> a[i];\\n sort(a + 1, a + 1 + n);\\n for (int i = 1; i <= n - 2 * k; i++) ans += a[i];\\n for (int i = n - 2 * k + 1; i <= n - k; i++) ans += a[i] \\/ a[i + k];\\n cout << ans << '\\\\n';\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A permutation of length n is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice in the array) and [1,3,4] is also not a permutation (n=3 but there is 4 in the array).\\n\\nFor a positive integer n, we call a permutation p of length n good if the following condition holds for every pair i and j (1 ≤ i ≤ j ≤ n) — \\n\\n * (p_i OR p_{i+1} OR … OR p_{j-1} OR p_{j}) ≥ j-i+1, where OR denotes the [bitwise OR operation.](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#OR)\\n\\n\\n\\nIn other words, a permutation p is good if for every subarray of p, the OR of all elements in it is not less than the number of elements in that subarray. \\n\\nGiven a positive integer n, output any good permutation of length n. We can show that for the given constraints such a permutation always exists.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 100). Description of the test cases follows.\\n\\nThe first and only line of every test case contains a single integer n (1 ≤ n ≤ 100).\\n\\nOutput\\n\\nFor every test, output any good permutation of length n on a separate line. \\n\\nExample\\n\\nInput\\n\\n\\n3\\n1\\n3\\n7\\n\\n\\nOutput\\n\\n\\n1\\n3 1 2\\n4 3 5 2 7 1 6\\n\\nNote\\n\\nFor n = 3, [3,1,2] is a good permutation. Some of the subarrays are listed below. \\n\\n * 3 OR 1 = 3 ≥ 2 (i = 1,j = 2) \\n * 3 OR 1 OR 2 = 3 ≥ 3 (i = 1,j = 3) \\n * 1 OR 2 = 3 ≥ 2 (i = 2,j = 3) \\n * 1 ≥ 1 (i = 2,j = 2) \\n\\n\\n\\nSimilarly, you can verify that [4,3,5,2,7,1,6] is also good.\\n\\nimpo\",\"targets\":\"rt java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.io.PrintWriter;\\nimport java.util.Arrays;\\nimport java.util.StringTokenizer;\\n\\npublic final class CodeForces658E {\\n\\n public static void pr(String st){\\n System.out.println(st);\\n }\\n \\n public static void main(String args[]) {\\n FastReader sc = new FastReader();\\n PrintWriter out = new PrintWriter(System.out);\\n int t = sc.nextInt();\\n while (t-- > 0) {\\n int n = sc.nextInt();\\n \\/\\/int i = \\n for(int i=n\\/2 + 1;i 0) {\\n\\t\\t\\tn = in.iscan(); m = in.iscan(); k = in.iscan();\\n\\t\\t\\tif (n % 2 == 1 && m % 2 == 0) { \\/\\/ -> n is odd, m is even\\n\\t\\t\\t\\tint needPerRow = m \\/ 2;\\n\\t\\t\\t\\tif (k < needPerRow) {\\n\\t\\t\\t\\t\\tout.println(\\\"NO\\\");\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\telse {\\n\\t\\t\\t\\t\\tk -= needPerRow;\\n\\t\\t\\t\\t\\tn--;\\n\\t\\t\\t\\t\\tif (k % 2 == 0) {\\n\\t\\t\\t\\t\\t\\tout.println(\\\"YES\\\");\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\telse {\\n\\t\\t\\t\\t\\t\\tout.println(\\\"NO\\\");\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\telse if (n % 2 == 0 && m % 2 == 1) { \\/\\/ n is even, m is odd\\n\\t\\t\\t\\tif (k % 2 == 1) {\\n\\t\\t\\t\\t\\tout.println(\\\"NO\\\");\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\telse {\\n\\t\\t\\t\\t\\tint max = m \\/ 2 * n;\\n\\t\\t\\t\\t\\tif (k > max) {\\n\\t\\t\\t\\t\\t\\tout.println(\\\"NO\\\");\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\telse {\\n\\t\\t\\t\\t\\t\\tout.println(\\\"YES\\\");\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\telse { \\/\\/ n is even and m is even\\n\\t\\t\\t\\tif (k % 2 == 1) {\\n\\t\\t\\t\\t\\tout.println(\\\"NO\\\");\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\telse {\\n\\t\\t\\t\\t\\tout.println(\\\"YES\\\");\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\tout.close();\\n\\t} \\n\\t\\n\\tstatic INPUT in = new INPUT(System.in);\\n\\tstatic PrintWriter out = new PrintWriter(System.out);\\n\\tprivate static class INPUT {\\n\\n\\t\\tprivate InputStream stream;\\n\\t\\tprivate byte[] buf = new byte[1024];\\n\\t\\tprivate int curChar, numChars;\\n\\n\\t\\tpublic INPUT (InputStream stream) {\\n\\t\\t\\tthis.stream = stream;\\n\\t\\t}\\n\\n\\t\\tpublic INPUT (String file) throws IOException {\\n\\t\\t\\tthis.stream = new FileInputStream (file);\\n\\t\\t}\\n\\n\\t\\tpublic int cscan () throws IOException {\\n\\t\\t\\tif (curChar >= numChars) {\\n\\t\\t\\t\\tcurChar = 0;\\n\\t\\t\\t\\tnumChars = stream.read (buf);\\n\\t\\t\\t}\\n\\t\\t\\t\\n\\t\\t\\tif (numChars == -1)\\n\\t\\t\\t\\treturn numChars;\\n\\n\\t\\t\\treturn buf[curChar++];\\n\\t\\t}\\n\\n\\t\\tpublic int iscan () throws IOException {\\n\\t\\t\\tint c = cscan (), sgn = 1;\\n\\t\\t\\t\\n\\t\\t\\twhile (space (c))\\n\\t\\t\\t\\tc = cscan ();\\n\\n\\t\\t\\tif (c == '-') {\\n\\t\\t\\t\\tsgn = -1;\\n\\t\\t\\t\\tc = cscan ();\\n\\t\\t\\t}\\n\\n\\t\\t\\tint res = 0;\\n\\n\\t\\t\\tdo {\\n\\t\\t\\t\\tres = (res << 1) + (res << 3);\\n\\t\\t\\t\\tres += c - '0';\\n\\t\\t\\t\\tc = cscan ();\\n\\t\\t\\t}\\n\\t\\t\\twhile (!space (c));\\n\\n\\t\\t\\treturn res * sgn;\\n\\t\\t}\\n\\n\\t\\tpublic String sscan () throws IOException {\\n\\t\\t\\tint c = cscan ();\\n\\t\\t\\t\\n\\t\\t\\twhile (space (c))\\n\\t\\t\\t\\tc = cscan ();\\n\\n\\t\\t\\tStringBuilder res =...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"The statement of this problem shares a lot with problem A. The differences are that in this problem, the probability is introduced, and the constraint is different.\\n\\nA robot cleaner is placed on the floor of a rectangle room, surrounded by walls. The floor consists of n rows and m columns. The rows of the floor are numbered from 1 to n from top to bottom, and columns of the floor are numbered from 1 to m from left to right. The cell on the intersection of the r-th row and the c-th column is denoted as (r,c). The initial position of the robot is (r_b, c_b).\\n\\nIn one second, the robot moves by dr rows and dc columns, that is, after one second, the robot moves from the cell (r, c) to (r + dr, c + dc). Initially dr = 1, dc = 1. If there is a vertical wall (the left or the right walls) in the movement direction, dc is reflected before the movement, so the new value of dc is -dc. And if there is a horizontal wall (the upper or lower walls), dr is reflected before the movement, so the new value of dr is -dr.\\n\\nEach second (including the moment before the robot starts moving), the robot cleans every cell lying in the same row or the same column as its position. There is only one dirty cell at (r_d, c_d). The job of the robot is to clean that dirty cell. \\n\\nAfter a lot of testings in problem A, the robot is now broken. It cleans the floor as described above, but at each second the cleaning operation is performed with probability \\\\frac p {100} only, and not performed with probability 1 - \\\\frac p {100}. The cleaning or not cleaning outcomes are independent each second.\\n\\nGiven the floor size n and m, the robot's initial position (r_b, c_b) and the dirty cell's position (r_d, c_d), find the expected time for the robot to do its job.\\n\\nIt can be shown that the answer can be expressed as an irreducible fraction \\\\frac x y, where x and y are integers and y not ≡ 0 \\\\pmod{10^9 + 7} . Output the integer equal to x ⋅ y^{-1} mod (10^9 + 7). In other words, output such an integer a that 0 ≤ a < 10^9 + 7 and a ⋅ y ≡ x \\\\pmod {10^9 +...\\nSolve the task in JAVA.\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.io.PrintWriter;\\nimport java.util.ArrayDeque;\\nimport java.util.StringTokenizer;\\n\\npublic class d {\\n\\tpublic static void main(String[] args) {\\n\\t\\tFastScanner scan=new FastScanner();\\n\\t\\tPrintWriter out=new PrintWriter(System.out);\\n\\n\\t\\tint t=scan.nextInt();\\n\\t\\tfor(int tt=0;tt coeff=new ArrayDeque<>();\\n\\t\\t\\tboolean start=true;\\n\\t\\t\\twhile(true) {\\n\\t\\t\\t\\tif(cs.i==ei||cs.j==ej) {\\n\\t\\t\\t\\t\\tif(!start) coeff.offer(since);\\n\\t\\t\\t\\t\\tsince=0;\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tif(cs.i==si&&cs.j==sj&&cs.di==initdi&&cs.dj==initdj&&!start) {\\n\\t\\t\\t\\t\\tif(!(si==ei||sj==ej)) {\\n\\t\\t\\t\\t\\t\\tcoeff.offer(since);\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tcs.move();\\n\\t\\t\\t\\tstart=false;\\n\\t\\t\\t\\tsince++;\\n\\t\\t\\t}\\n\\t\\t\\tlong q=sub(1,p);\\n\\t\\t\\tlong pow=(si==ei||sj==ej)?coeff.size():coeff.size()-1;\\n\\t\\t\\tlong res=0L;\\n\\t\\t\\twhile(coeff.size()>0) {\\n\\t\\t\\t\\tlong cur=coeff.pollLast();\\n\\t\\t\\t\\tres=mult(res,q);\\n\\t\\t\\t\\tres=add(res,cur);\\n\\t\\t\\t}\\n\\t\\t\\tlong den=sub(1,pow(q,pow));\\n\\t\\t\\tres=mult(res,modinv(den));\\n\\t\\t\\tif(si==ei||sj==ej) res=mult(res,q);\\n\\t\\t\\tout.println(res);\\n\\t\\t}\\n\\t\\tout.close();\\n\\t}\\n\\tstatic class state {\\n\\t\\tint i,j,di,dj;\\n\\t\\tstatic int n,m;\\n\\t\\tstate(int i, int j, int di, int dj) {\\n\\t\\t\\tthis.i=i;\\n\\t\\t\\tthis.j=j;\\n\\t\\t\\tthis.di=di;\\n\\t\\t\\tthis.dj=dj;\\n\\t\\t}\\n\\t\\tvoid updDir() {\\n\\t\\t\\tif(i+di==n) di*=-1;\\n\\t\\t\\telse if(i+di==-1) di*=-1;\\n\\t\\t\\tif(j+dj==m) dj*=-1;\\n\\t\\t\\telse if(j+dj==-1) dj*=-1;\\n\\t\\t}\\n\\t\\tvoid move() {\\n\\t\\t\\ti+=di;\\n\\t\\t\\tj+=dj;\\n\\t\\t\\tupdDir();\\n\\t\\t}\\n\\t}\\n\\tpublic static long powfraction(long num, long den, long e) {\\n\\t\\tlong pnum=pow(num,e), pden=pow(den,e);\\n\\t\\tlong res=1L;\\n\\t\\tres=mult(res,pnum);\\n\\t\\tres=mult(res,modinv(pden));\\n\\t\\treturn res;\\n\\t}\\n\\tpublic static long modinv(long x) {\\n\\t\\treturn pow(x,MOD-2);\\n\\t}\\n\\tpublic static long...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given an integer array a_1, a_2, ..., a_n and integer k.\\n\\nIn one step you can \\n\\n * either choose some index i and decrease a_i by one (make a_i = a_i - 1); \\n * or choose two indices i and j and set a_i equal to a_j (make a_i = a_j). \\n\\n\\n\\nWhat is the minimum number of steps you need to make the sum of array ∑_{i=1}^{n}{a_i} ≤ k? (You are allowed to make values of array negative).\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases.\\n\\nThe first line of each test case contains two integers n and k (1 ≤ n ≤ 2 ⋅ 10^5; 1 ≤ k ≤ 10^{15}) — the size of array a and upper bound on its sum.\\n\\nThe second line of each test case contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — the array itself.\\n\\nIt's guaranteed that the sum of n over all test cases doesn't exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print one integer — the minimum number of steps to make ∑_{i=1}^{n}{a_i} ≤ k.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n1 10\\n20\\n2 69\\n6 9\\n7 8\\n1 2 1 3 1 2 1\\n10 1\\n1 2 3 1 2 6 1 6 8 10\\n\\n\\nOutput\\n\\n\\n10\\n0\\n2\\n7\\n\\nNote\\n\\nIn the first test case, you should decrease a_1 10 times to get the sum lower or equal to k = 10.\\n\\nIn the second test case, the sum of array a is already less or equal to 69, so you don't need to change it.\\n\\nIn the third test case, you can, for example: \\n\\n 1. set a_4 = a_3 = 1; \\n 2. decrease a_4 by one, and get a_4 = 0. \\n\\nAs a result, you'll get array [1, 2, 1, 0, 1, 2, 1] with sum less or equal to 8 in 1 + 1 = 2 steps.\\n\\nIn the fourth test case, you can, for example: \\n\\n 1. choose a_7 and decrease in by one 3 times; you'll get a_7 = -2; \\n 2. choose 4 elements a_6, a_8, a_9 and a_{10} and them equal to a_7 = -2. \\n\\nAs a result, you'll get array [1, 2, 3, 1, 2, -2, -2, -2, -2, -2] with sum less or equal to 1 in 3 + 4 = 7 steps.\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nvoid fast() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n}\\nvoid solve() {\\n long long n, k;\\n cin >> n >> k;\\n vector a(n);\\n long long sum = 0;\\n for (long long i = 0; i < n; i++) {\\n cin >> a[i];\\n sum += a[i];\\n }\\n sort(a.begin(), a.end());\\n long long ans = sum - k;\\n long long dif = sum - k;\\n long long last = 1;\\n long long steps;\\n if (dif <= 0) {\\n cout << 0 << endl;\\n return;\\n }\\n while (n - last > 0) {\\n steps = (sum - k - a[n - last] + a[0]) \\/ (last + 1);\\n if ((sum - k - a[n - last] + a[0]) % (last + 1) &&\\n (sum - k - a[n - last] + a[0]) > 0)\\n steps++;\\n steps = max((long long)0, steps);\\n ans = min(ans, steps + last);\\n sum -= a[n - last] - a[0];\\n last++;\\n }\\n cout << ans << endl;\\n}\\nint main() {\\n long long t = 1;\\n fast();\\n cin >> t;\\n while (t--) solve();\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Despite his bad reputation, Captain Flint is a friendly person (at least, friendly to animals). Now Captain Flint is searching worthy sailors to join his new crew (solely for peaceful purposes). A sailor is considered as worthy if he can solve Flint's task.\\n\\nRecently, out of blue Captain Flint has been interested in math and even defined a new class of integers. Let's define a positive integer x as nearly prime if it can be represented as p ⋅ q, where 1 < p < q and p and q are prime numbers. For example, integers 6 and 10 are nearly primes (since 2 ⋅ 3 = 6 and 2 ⋅ 5 = 10), but integers 1, 3, 4, 16, 17 or 44 are not.\\n\\nCaptain Flint guessed an integer n and asked you: can you represent it as the sum of 4 different positive integers where at least 3 of them should be nearly prime.\\n\\nUncle Bogdan easily solved the task and joined the crew. Can you do the same?\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases.\\n\\nNext t lines contain test cases — one per line. The first and only line of each test case contains the single integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number Flint guessed.\\n\\nOutput\\n\\nFor each test case print: \\n\\n * YES and 4 different positive integers such that at least 3 of them are nearly prime and their sum is equal to n (if there are multiple answers print any of them); \\n * NO if there is no way to represent n as the sum of 4 different positive integers where at least 3 of them are nearly prime. \\n\\nYou can print each character of YES or NO in any case.\\n\\nExample\\n\\nInput\\n\\n\\n7\\n7\\n23\\n31\\n36\\n44\\n100\\n258\\n\\n\\nOutput\\n\\n\\nNO\\nNO\\nYES\\n14 10 6 1\\nYES\\n5 6 10 15\\nYES\\n6 7 10 21\\nYES\\n2 10 33 55\\nYES\\n10 21 221 6\\n\\nNote\\n\\nIn the first and second test cases, it can be proven that there are no four different positive integers such that at least three of them are nearly prime.\\n\\nIn the third test case, n=31=2 ⋅ 7 + 2 ⋅ 5 + 2 ⋅ 3 + 1: integers 14, 10, 6 are nearly prime.\\n\\nIn the fourth test case, n=36=5 + 2 ⋅ 3 + 2 ⋅ 5 + 3 ⋅ 5: integers 6, 10, 15 are nearly prime.\\n\\nIn the fifth test case, n=44=2 ⋅ 3 + 7 +...\",\"targets\":\"'''input\\n7\\n7\\n23\\n31\\n36\\n44\\n100\\n258\\n\\n\\n\\n'''\\n \\n\\n \\nfrom bisect import bisect_right as bl\\nfrom random import randint as R\\n\\n\\nRI = lambda : [int(_x) for _x in raw_input().split()]\\n\\nfor _ in range(input()):\\n\\tn = input()\\n\\tA = [6,10,14]\\n\\n\\ts1 = sum(A)\\n\\n\\tif n - s1<=0:\\n\\t\\tprint \\\"NO\\\"\\n\\n\\telse:\\n\\t\\td = n-s1\\n\\t\\tprint \\\"YES\\\"\\n\\t\\tif d in A:\\n\\t\\t\\t\\n\\t\\t\\tprint \\\"6 10 15 %d\\\"%(n-s1-1)\\n\\t\\telse:\\n\\t\\t\\tprint \\\"6 10 14 %d\\\"%(n-s1)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"And while Mishka is enjoying her trip...\\n\\nChris is a little brown bear. No one knows, where and when he met Mishka, but for a long time they are together (excluding her current trip). However, best friends are important too. John is Chris' best friend.\\n\\nOnce walking with his friend, John gave Chris the following problem:\\n\\nAt the infinite horizontal road of width w, bounded by lines y = 0 and y = w, there is a bus moving, presented as a convex polygon of n vertices. The bus moves continuously with a constant speed of v in a straight Ox line in direction of decreasing x coordinates, thus in time only x coordinates of its points are changing. Formally, after time t each of x coordinates of its points will be decreased by vt.\\n\\nThere is a pedestrian in the point (0, 0), who can move only by a vertical pedestrian crossing, presented as a segment connecting points (0, 0) and (0, w) with any speed not exceeding u. Thus the pedestrian can move only in a straight line Oy in any direction with any speed not exceeding u and not leaving the road borders. The pedestrian can instantly change his speed, thus, for example, he can stop instantly.\\n\\nPlease look at the sample note picture for better understanding.\\n\\nWe consider the pedestrian is hit by the bus, if at any moment the point he is located in lies strictly inside the bus polygon (this means that if the point lies on the polygon vertex or on its edge, the pedestrian is not hit by the bus).\\n\\nYou are given the bus position at the moment 0. Please help Chris determine minimum amount of time the pedestrian needs to cross the road and reach the point (0, w) and not to be hit by the bus.\\n\\nInput\\n\\nThe first line of the input contains four integers n, w, v, u (3 ≤ n ≤ 10 000, 1 ≤ w ≤ 109, 1 ≤ v, u ≤ 1000) — the number of the bus polygon vertices, road width, bus speed and pedestrian speed respectively.\\n\\nThe next n lines describes polygon vertices in counter-clockwise order. i-th of them contains pair of integers xi and yi ( - 109 ≤ xi ≤ 109, 0 ≤ yi ≤ w) — coordinates of i-th...\\nSolve the task in JAVA.\",\"targets\":\"import java.io.IOException;\\nimport java.util.InputMismatchException;\\n\\npublic class ChrisAndRoad {\\n public static void main(String[] args) {\\n FasterScanner sc = new FasterScanner();\\n \\n int N = sc.nextInt();\\n long W = sc.nextLong();\\n int V = sc.nextInt();\\n int U = sc.nextInt();\\n \\n long[] X = new long[N];\\n long[] Y = new long[N];\\n for (int i = 0; i < N; i++) {\\n \\tX[i] = sc.nextLong();\\n \\tY[i] = sc.nextLong();\\n }\\n \\n boolean canFront = true;\\n for (int i = 0; i < N; i++) {\\n \\tif (Y[i] * V > X[i] * U) {\\n \\t\\tcanFront = false;\\n \\t\\tbreak;\\n \\t}\\n }\\n \\n if (canFront) {\\n \\tSystem.out.format(\\\"%.10f\\\", (double)W \\/ U);\\n \\treturn;\\n }\\n \\n double maxTime = 0;\\n for (int i = 0; i < N; i++) {\\n \\tdouble currTime = Math.max((double)Y[i] \\/ U, (double)X[i] \\/ V) + (double)(W - Y[i]) \\/ U;\\n \\tmaxTime = Math.max(maxTime, currTime);\\n }\\n \\tSystem.out.format(\\\"%.10f\\\", maxTime);\\n }\\n\\n\\tpublic static class FasterScanner {\\n\\t\\tprivate byte[] buf = new byte[1024];\\n\\t\\tprivate int curChar;\\n\\t\\tprivate int numChars;\\n\\n\\t\\tpublic int read() {\\n\\t\\t\\tif (numChars == -1)\\n\\t\\t\\t\\tthrow new InputMismatchException();\\n\\t\\t\\tif (curChar >= numChars) {\\n\\t\\t\\t\\tcurChar = 0;\\n\\t\\t\\t\\ttry {\\n\\t\\t\\t\\t\\tnumChars = System.in.read(buf);\\n\\t\\t\\t\\t} catch (IOException e) {\\n\\t\\t\\t\\t\\tthrow new InputMismatchException();\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tif (numChars <= 0)\\n\\t\\t\\t\\t\\treturn -1;\\n\\t\\t\\t}\\n\\t\\t\\treturn buf[curChar++];\\n\\t\\t}\\n\\n\\t\\tpublic String nextLine() {\\n\\t\\t\\tint c = read();\\n\\t\\t\\twhile (isSpaceChar(c))\\n\\t\\t\\t\\tc = read();\\n\\t\\t\\tStringBuilder res = new StringBuilder();\\n\\t\\t\\tdo {\\n\\t\\t\\t\\tres.appendCodePoint(c);\\n\\t\\t\\t\\tc = read();\\n\\t\\t\\t} while (!isEndOfLine(c));\\n\\t\\t\\treturn res.toString();\\n\\t\\t}\\n\\n\\t\\tpublic String nextString() {\\n\\t\\t\\tint c = read();\\n\\t\\t\\twhile (isSpaceChar(c))\\n\\t\\t\\t\\tc = read();\\n\\t\\t\\tStringBuilder res = new StringBuilder();\\n\\t\\t\\tdo {\\n\\t\\t\\t\\tres.appendCodePoint(c);\\n\\t\\t\\t\\tc = read();\\n\\t\\t\\t} while (!isSpaceChar(c));\\n\\t\\t\\treturn res.toString();\\n\\t\\t}\\n\\n\\t\\tpublic long...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.\\n\\nGiven a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it ak) and delete it, at that all elements equal to ak + 1 and ak - 1 also must be deleted from the sequence. That step brings ak points to the player. \\n\\nAlex is a perfectionist, so he decided to get as many points as possible. Help him.\\n\\nInput\\n\\nThe first line contains integer n (1 ≤ n ≤ 105) that shows how many numbers are in Alex's sequence. \\n\\nThe second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 105).\\n\\nOutput\\n\\nPrint a single integer — the maximum number of points that Alex can earn.\\n\\nExamples\\n\\nInput\\n\\n2\\n1 2\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n3\\n1 2 3\\n\\n\\nOutput\\n\\n4\\n\\n\\nInput\\n\\n9\\n1 2 1 3 2 2 2 2 3\\n\\n\\nOutput\\n\\n10\\n\\nNote\\n\\nConsider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points.\",\"targets\":\"#include \\nusing namespace std;\\nint n, m, t, t1, t2, t3, t4, f;\\nvoid pvi(vector& thinger) {\\n for (int q = 0; q < thinger.size(); q++) cout << thinger[q] << \\\", \\\";\\n cout << \\\"\\\\n\\\";\\n}\\nvoid pvs(vector& thinger) {\\n for (int q = 0; q < thinger.size(); q++) cout << thinger[q] << \\\", \\\";\\n cout << \\\"\\\\n\\\";\\n}\\nvoid pvb(vector& thinger) {\\n for (int q = 0; q < thinger.size(); q++) cout << thinger[q] << \\\", \\\";\\n cout << \\\"\\\\n\\\";\\n}\\nvoid pvvi(vector >& t) {\\n for (auto q : t) pvi(q);\\n}\\nvoid pvll(vector& thinger) {\\n for (int q = 0; q < thinger.size(); q++) cout << thinger[q] << \\\", \\\";\\n cout << \\\"\\\\n\\\";\\n}\\nvoid pvvll(vector >& t) {\\n for (auto q : t) pvll(q);\\n}\\nvector split(string s, char l) {\\n vector temp;\\n stringstream ss(s);\\n string t;\\n while (getline(ss, t, l)) {\\n temp.push_back(t);\\n }\\n return temp;\\n}\\nvector counter(100005, 0), best(100005, -1);\\nlong long getbest(int k) {\\n if (k <= 0) return 0;\\n if (best[k] != -1) return best[k];\\n return best[k] = max(getbest(k - 1), getbest(k - 2) + k * counter[k]);\\n}\\nint main() {\\n long long t;\\n cin >> n;\\n f = n;\\n long long maxi = -1;\\n while (f--) {\\n cin >> t;\\n maxi = max(maxi, t);\\n counter[t]++;\\n }\\n best[1] = counter[1];\\n cout << (getbest(100000)) << \\\"\\\\n\\\";\\n ;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given strings S and T, consisting of lowercase English letters. It is guaranteed that T is a permutation of the string abc. \\n\\nFind string S', the lexicographically smallest permutation of S such that T is not a subsequence of S'.\\n\\nString a is a permutation of string b if the number of occurrences of each distinct character is the same in both strings.\\n\\nA string a is a subsequence of a string b if a can be obtained from b by deletion of several (possibly, zero or all) elements.\\n\\nA string a is lexicographically smaller than a string b if and only if one of the following holds:\\n\\n * a is a prefix of b, but a ≠ b;\\n * in the first position where a and b differ, the string a has a letter that appears earlier in the alphabet than the corresponding letter in b.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases. Description of the test cases follows.\\n\\nThe first line of each test case contains a string S (1 ≤ |S| ≤ 100), consisting of lowercase English letters.\\n\\nThe second line of each test case contains a string T that is a permutation of the string abc. (Hence, |T| = 3).\\n\\nNote that there is no limit on the sum of |S| across all test cases.\\n\\nOutput\\n\\nFor each test case, output a single string S', the lexicographically smallest permutation of S such that T is not a subsequence of S'.\\n\\nExample\\n\\nInput\\n\\n\\n7\\nabacaba\\nabc\\ncccba\\nacb\\ndbsic\\nbac\\nabracadabra\\nabc\\ndddddddddddd\\ncba\\nbbc\\nabc\\nac\\nabc\\n\\n\\nOutput\\n\\n\\naaaacbb\\nabccc\\nbcdis\\naaaaacbbdrr\\ndddddddddddd\\nbbc\\nac\\n\\nNote\\n\\nIn the first test case, both aaaabbc and aaaabcb are lexicographically smaller than aaaacbb, but they contain abc as a subsequence.\\n\\nIn the second test case, abccc is the smallest permutation of cccba and does not contain acb as a subsequence.\\n\\nIn the third test case, bcdis is the smallest permutation of dbsic and does not contain bac as a subsequence.\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.util.Scanner;\\n\\npublic class CodeForces_1617_A{\\n public static void main(String[] args) {\\n \\n Scanner scanner = new Scanner(System.in);\\n int test = scanner.nextInt();\\n scanner.nextLine();\\n while(test --> 0){\\n char[] s = scanner.nextLine().toCharArray();\\n String t = scanner.nextLine();\\n int[] counter = new int[26];\\n for(char x : s)\\n counter[(int)x - 97] += 1;\\n StringBuilder sb = new StringBuilder();\\n \\/\\/add character a\\n int temp = counter[0];\\n while(temp --> 0)\\n sb.append('a');\\n \\/\\/adding c before b if t is lexicgraphically the lowest subsequence\\n if(t.equals(\\\"abc\\\") && !(counter[0] == 0 || counter[1] == 0 || counter[2] == 0)){\\n while(counter[2] --> 0)\\n sb.append('c');\\n }\\n char ch = 'b';\\n for(int i = 1; i < counter.length; i++, ch++){\\n while(counter[i] --> 0)\\n sb.append(ch);\\n }\\n System.out.println(sb.toString());\\n }\\n scanner.close();\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Monocarp has got an array a consisting of n integers. Let's denote k as the mathematic mean of these elements (note that it's possible that k is not an integer). \\n\\nThe mathematic mean of an array of n elements is the sum of elements divided by the number of these elements (i. e. sum divided by n).\\n\\nMonocarp wants to delete exactly two elements from a so that the mathematic mean of the remaining (n - 2) elements is still equal to k.\\n\\nYour task is to calculate the number of pairs of positions [i, j] (i < j) such that if the elements on these positions are deleted, the mathematic mean of (n - 2) remaining elements is equal to k (that is, it is equal to the mathematic mean of n elements of the original array a).\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.\\n\\nThe first line of each testcase contains one integer n (3 ≤ n ≤ 2 ⋅ 10^5) — the number of elements in the array.\\n\\nThe second line contains a sequence of integers a_1, a_2, ..., a_n (0 ≤ a_i ≤ 10^{9}), where a_i is the i-th element of the array.\\n\\nThe sum of n over all testcases doesn't exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nPrint one integer — the number of pairs of positions [i, j] (i < j) such that if the elements on these positions are deleted, the mathematic mean of (n - 2) remaining elements is equal to k (that is, it is equal to the mathematic mean of n elements of the original array a).\\n\\nExample\\n\\nInput\\n\\n\\n4\\n4\\n8 8 8 8\\n3\\n50 20 10\\n5\\n1 4 7 3 5\\n7\\n1 2 3 4 5 6 7\\n\\n\\nOutput\\n\\n\\n6\\n0\\n2\\n3\\n\\nNote\\n\\nIn the first example, any pair of elements can be removed since all of them are equal.\\n\\nIn the second example, there is no way to delete two elements so the mathematic mean doesn't change.\\n\\nIn the third example, it is possible to delete the elements on positions 1 and 3, or the elements on positions 4 and 5.\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 2 * 1e5 + 10;\\nlong long a[N];\\nmap mp;\\nint main() {\\n int t, n;\\n cin >> t;\\n while (t--) {\\n mp.clear();\\n cin >> n;\\n long long sum = 0;\\n for (int i = 0; i < n; i++) {\\n cin >> a[i];\\n sum = sum + a[i];\\n }\\n long long ans = 0;\\n for (int i = 0; i < n; i++) {\\n ans = ans + mp[a[i] * n];\\n mp[2 * sum - a[i] * n] += 1;\\n }\\n cout << ans << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Let's call the following process a transformation of a sequence of length n.\\n\\nIf the sequence is empty, the process ends. Otherwise, append the [greatest common divisor](https:\\/\\/en.wikipedia.org\\/wiki\\/Greatest_common_divisor) (GCD) of all the elements of the sequence to the result and remove one arbitrary element from the sequence. Thus, when the process ends, we have a sequence of n integers: the greatest common divisors of all the elements in the sequence before each deletion.\\n\\nYou are given an integer sequence 1, 2, ..., n. Find the lexicographically maximum result of its transformation.\\n\\nA sequence a_1, a_2, …, a_n is lexicographically larger than a sequence b_1, b_2, …, b_n, if there is an index i such that a_j = b_j for all j < i, and a_i > b_i.\\n\\nInput\\n\\nThe first and only line of input contains one integer n (1≤ n≤ 10^6).\\n\\nOutput\\n\\nOutput n integers — the lexicographically maximum result of the transformation.\\n\\nExamples\\n\\nInput\\n\\n3\\n\\n\\nOutput\\n\\n1 1 3 \\n\\nInput\\n\\n2\\n\\n\\nOutput\\n\\n1 2 \\n\\nInput\\n\\n1\\n\\n\\nOutput\\n\\n1 \\n\\nNote\\n\\nIn the first sample the answer may be achieved this way:\\n\\n * Append GCD(1, 2, 3) = 1, remove 2. \\n * Append GCD(1, 3) = 1, remove 1. \\n * Append GCD(3) = 3, remove 3. \\n\\n\\n\\nWe get the sequence [1, 1, 3] as the result.\\\":\",\"targets\":\"#include \\nusing namespace std;\\nconst int maxn = 1e6 + 5;\\nint Num[maxn];\\nvector Ans;\\nvoid Solve(int N, int Factor) {\\n if (N == 1) {\\n Ans.push_back(Factor);\\n return;\\n } else if (N == 2) {\\n Ans.push_back(Factor);\\n Ans.push_back(Factor * 2);\\n return;\\n } else if (N == 3) {\\n Ans.push_back(Factor);\\n Ans.push_back(Factor);\\n Ans.push_back(Factor * 3);\\n return;\\n }\\n for (int i = 1; i <= N; ++i) {\\n if (Num[i] & 1) {\\n Ans.push_back(Factor);\\n }\\n }\\n for (int i = 1; i <= N \\/ 2; ++i) {\\n Num[i] = Num[2 * i] \\/ 2;\\n }\\n Solve(N \\/ 2, Factor * 2);\\n}\\nint main(int argc, char *argv[]) {\\n int N;\\n scanf(\\\"%d\\\", &N);\\n if (N <= 3) {\\n for (int i = 0; i < N - 1; ++i) {\\n printf(\\\"%d \\\", 1);\\n }\\n printf(\\\"%d\\\\n\\\", N);\\n return 0;\\n }\\n for (int i = 1; i <= N; ++i) {\\n Num[i] = i;\\n }\\n Solve(N, 1);\\n for (auto i : Ans) {\\n printf(\\\"%d \\\", i);\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"YouKn0wWho has two even integers x and y. Help him to find an integer n such that 1 ≤ n ≤ 2 ⋅ 10^{18} and n mod x = y mod n. Here, a mod b denotes the remainder of a after division by b. If there are multiple such integers, output any. It can be shown that such an integer always exists under the given constraints.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^5) — the number of test cases.\\n\\nThe first and only line of each test case contains two integers x and y (2 ≤ x, y ≤ 10^9, both are even).\\n\\nOutput\\n\\nFor each test case, print a single integer n (1 ≤ n ≤ 2 ⋅ 10^{18}) that satisfies the condition mentioned in the statement. If there are multiple such integers, output any. It can be shown that such an integer always exists under the given constraints.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n4 8\\n4 2\\n420 420\\n69420 42068\\n\\n\\nOutput\\n\\n\\n4\\n10\\n420\\n9969128\\n\\nNote\\n\\nIn the first test case, 4 mod 4 = 8 mod 4 = 0.\\n\\nIn the second test case, 10 mod 4 = 2 mod 10 = 2.\\n\\nIn the third test case, 420 mod 420 = 420 mod 420 = 0.\\\":\",\"targets\":\"#include \\ntemplate \\nT amax(T &a, T1 b) {\\n if (b > a) a = b;\\n return a;\\n}\\ntemplate \\nT amin(T &a, T1 b) {\\n if (b < a) a = b;\\n return a;\\n}\\nusing namespace std;\\nusing ld = long double;\\nusing vi = vector;\\nusing mi = map;\\nusing pi = pair;\\nconst int M = 1e9 + 7;\\nlong long mod(long long x) { return ((x % M + M) % M); }\\nlong long add(long long a, long long b) { return mod(mod(a) + mod(b)); }\\nlong long mul(long long a, long long b) { return mod(mod(a) * mod(b)); }\\nlong long int bin(long long int a, long long int b) {\\n if (b == 0) return 1;\\n long long int res = bin(a, b \\/ 2);\\n if (b % 2)\\n return res * res * a;\\n else\\n return res * res;\\n}\\nlong long int exponentMod(long long int A, long long int B, long long int C) {\\n if (A == 0) return 0;\\n if (B == 0) return 1;\\n long long int y;\\n if (B % 2 == 0) {\\n y = exponentMod(A, B \\/ 2, C);\\n y = (y * y) % C;\\n } else {\\n y = A % C;\\n y = (y * exponentMod(A, B - 1, C) % C) % C;\\n }\\n return (long long int)((y + C) % C);\\n}\\nlong long int isprime(long long int x) {\\n long long int i, res = 1;\\n for (i = 2; i <= sqrt(x); i++) {\\n if (x % i == 0) {\\n res = i;\\n break;\\n }\\n }\\n return res;\\n}\\nvoid solve() {\\n int x, y;\\n cin >> x >> y;\\n int t = y % x;\\n if (x > y)\\n printf(\\\"%lld\\\\n\\\", x + y);\\n else\\n printf(\\\"%lld\\\\n\\\", y - t \\/ 2);\\n}\\nint main() {\\n int t = 1;\\n cin >> t;\\n while (t--) {\\n solve();\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in PYTHON3?\\nThis problem is an extension of the problem \\\"Wonderful Coloring - 1\\\". It has quite many differences, so you should read this statement completely.\\n\\nRecently, Paul and Mary have found a new favorite sequence of integers a_1, a_2, ..., a_n. They want to paint it using pieces of chalk of k colors. The coloring of a sequence is called wonderful if the following conditions are met:\\n\\n 1. each element of the sequence is either painted in one of k colors or isn't painted; \\n 2. each two elements which are painted in the same color are different (i. e. there's no two equal values painted in the same color); \\n 3. let's calculate for each of k colors the number of elements painted in the color — all calculated numbers must be equal; \\n 4. the total number of painted elements of the sequence is the maximum among all colorings of the sequence which meet the first three conditions. \\n\\n\\n\\nE. g. consider a sequence a=[3, 1, 1, 1, 1, 10, 3, 10, 10, 2] and k=3. One of the wonderful colorings of the sequence is shown in the figure.\\n\\n The example of a wonderful coloring of the sequence a=[3, 1, 1, 1, 1, 10, 3, 10, 10, 2] and k=3. Note that one of the elements isn't painted.\\n\\nHelp Paul and Mary to find a wonderful coloring of a given sequence a.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10000) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of two lines. The first one contains two integers n and k (1 ≤ n ≤ 2⋅10^5, 1 ≤ k ≤ n) — the length of a given sequence and the number of colors, respectively. The second one contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ n).\\n\\nIt is guaranteed that the sum of n over all test cases doesn't exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nOutput t lines, each of them must contain a description of a wonderful coloring for the corresponding test case.\\n\\nEach wonderful coloring must be printed as a sequence of n integers c_1, c_2, ..., c_n (0 ≤ c_i ≤ k) separated by spaces where\\n\\n * c_i=0, if i-th element isn't painted; \\n * c_i>0, if i-th element is painted in the...\",\"targets\":\"NUM = int(input())\\nfor T in range(0,NUM):\\n n , k = map(int , input().split())\\n vallist = list(map(int , input().split()))\\n answer = [0] * n\\n countnum = [[] for i in range(0,n)]\\n for i in range(0,n): countnum[vallist[i] - 1].append(i)\\n ans = 0\\n for i in range(0,n): ans += min(k , len(countnum[i]))\\n ans \\/\\/= k\\n current = 0\\n for i in countnum:\\n for j in range(0 , min(k , len(i))):\\n if ans:\\n answer[i[j]] = current + 1\\n current = (current + 1) % k\\n ans -= current == 0\\n for i in answer: print(i, end = \\\" \\\")\\n print(\\\"\\\")\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Andrewid the Android is a galaxy-famous detective. He is now investigating the case of vandalism at the exhibition of contemporary art.\\n\\nThe main exhibit is a construction of n matryoshka dolls that can be nested one into another. The matryoshka dolls are numbered from 1 to n. A matryoshka with a smaller number can be nested in a matryoshka with a higher number, two matryoshkas can not be directly nested in the same doll, but there may be chain nestings, for example, 1 → 2 → 4 → 5. \\n\\nIn one second, you can perform one of the two following operations:\\n\\n * Having a matryoshka a that isn't nested in any other matryoshka and a matryoshka b, such that b doesn't contain any other matryoshka and is not nested in any other matryoshka, you may put a in b; \\n * Having a matryoshka a directly contained in matryoshka b, such that b is not nested in any other matryoshka, you may get a out of b. \\n\\n\\n\\nAccording to the modern aesthetic norms the matryoshka dolls on display were assembled in a specific configuration, i.e. as several separate chains of nested matryoshkas, but the criminal, following the mysterious plan, took out all the dolls and assembled them into a single large chain (1 → 2 → ... → n). In order to continue the investigation Andrewid needs to know in what minimum time it is possible to perform this action.\\n\\nInput\\n\\nThe first line contains integers n (1 ≤ n ≤ 105) and k (1 ≤ k ≤ 105) — the number of matryoshkas and matryoshka chains in the initial configuration.\\n\\nThe next k lines contain the descriptions of the chains: the i-th line first contains number mi (1 ≤ mi ≤ n), and then mi numbers ai1, ai2, ..., aimi — the numbers of matryoshkas in the chain (matryoshka ai1 is nested into matryoshka ai2, that is nested into matryoshka ai3, and so on till the matryoshka aimi that isn't nested into any other matryoshka).\\n\\nIt is guaranteed that m1 + m2 + ... + mk = n, the numbers of matryoshkas in all the chains are distinct, in each chain the numbers of matryoshkas follow in the ascending order.\\n\\nOutput\\n\\nIn the single...\\nUsing python3 can you solve the prior task?\",\"targets\":\"n, m = map(int, input().split())\\nc = {}\\nr = 0\\n\\nfor _ in range(m):\\n t = list(map(int, input().split()))\\n c[t[1]] = t[2:]\\n\\nd = list(c.keys())\\n\\nfor v in d:\\n if v == 1:\\n if c[v]:\\n x = 0\\n for i in range(len(c[v])):\\n if c[v][i] != i + 2:\\n break\\n x += 1\\n r += len(c[v]) - x\\n else:\\n r += len(c[v])\\n\\nprint(len(d) + r * 2 - 1)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Recently, Petya learned about a new game \\\"Slay the Dragon\\\". As the name suggests, the player will have to fight with dragons. To defeat a dragon, you have to kill it and defend your castle. To do this, the player has a squad of n heroes, the strength of the i-th hero is equal to a_i.\\n\\nAccording to the rules of the game, exactly one hero should go kill the dragon, all the others will defend the castle. If the dragon's defense is equal to x, then you have to send a hero with a strength of at least x to kill it. If the dragon's attack power is y, then the total strength of the heroes defending the castle should be at least y.\\n\\nThe player can increase the strength of any hero by 1 for one gold coin. This operation can be done any number of times.\\n\\nThere are m dragons in the game, the i-th of them has defense equal to x_i and attack power equal to y_i. Petya was wondering what is the minimum number of coins he needs to spend to defeat the i-th dragon.\\n\\nNote that the task is solved independently for each dragon (improvements are not saved).\\n\\nInput\\n\\nThe first line contains a single integer n (2 ≤ n ≤ 2 ⋅ 10^5) — number of heroes.\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^{12}), where a_i is the strength of the i-th hero.\\n\\nThe third line contains a single integer m (1 ≤ m ≤ 2 ⋅ 10^5) — the number of dragons.\\n\\nThe next m lines contain two integers each, x_i and y_i (1 ≤ x_i ≤ 10^{12}; 1 ≤ y_i ≤ 10^{18}) — defense and attack power of the i-th dragon.\\n\\nOutput\\n\\nPrint m lines, i-th of which contains a single integer — the minimum number of coins that should be spent to defeat the i-th dragon.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3 6 2 3\\n5\\n3 12\\n7 9\\n4 14\\n1 10\\n8 7\\n\\n\\nOutput\\n\\n\\n1\\n2\\n4\\n0\\n2\\n\\nNote\\n\\nTo defeat the first dragon, you can increase the strength of the third hero by 1, then the strength of the heroes will be equal to [3, 6, 3, 3]. To kill the dragon, you can choose the first hero.\\n\\nTo defeat the second dragon, you can increase the forces of the second and third heroes by 1, then the strength of the heroes will...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n ios::sync_with_stdio(0);\\n cin.tie(0);\\n int n;\\n cin >> n;\\n vector a(n);\\n long long sum = 0;\\n for (int i = 0; i < n; i++) {\\n cin >> a[i];\\n sum += a[i];\\n }\\n sort(a.begin(), a.end());\\n int m;\\n cin >> m;\\n while (m--) {\\n long long x, y;\\n cin >> x >> y;\\n int p = lower_bound(a.begin(), a.end(), x) - a.begin();\\n long long res = x + y;\\n if (p < n) res = min(res, max(long long(0), y - (sum - a[p])));\\n if (p - 1 >= 0)\\n res = min(res, x - a[p - 1] + max(long long(0), y - (sum - a[p - 1])));\\n cout << res << \\\"\\\\n\\\";\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given three integers n, a, b. Determine if there exists a permutation p_1, p_2, …, p_n of integers from 1 to n, such that:\\n\\n * There are exactly a integers i with 2 ≤ i ≤ n-1 such that p_{i-1} < p_i > p_{i+1} (in other words, there are exactly a local maximums).\\n\\n * There are exactly b integers i with 2 ≤ i ≤ n-1 such that p_{i-1} > p_i < p_{i+1} (in other words, there are exactly b local minimums).\\n\\n\\n\\n\\nIf such permutations exist, find any such permutation.\\n\\nInput\\n\\nThe first line of the input contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. The description of test cases follows.\\n\\nThe only line of each test case contains three integers n, a and b (2 ≤ n ≤ 10^5, 0 ≤ a,b ≤ n).\\n\\nThe sum of n over all test cases doesn't exceed 10^5.\\n\\nOutput\\n\\nFor each test case, if there is no permutation with the requested properties, output -1.\\n\\nOtherwise, print the permutation that you are found. If there are several such permutations, you may print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n4 1 1\\n6 1 2\\n6 4 0\\n\\n\\nOutput\\n\\n\\n1 3 2 4\\n4 2 3 1 5 6\\n-1\\n\\nNote\\n\\nIn the first test case, one example of such permutations is [1, 3, 2, 4]. In it p_1 < p_2 > p_3, and 2 is the only such index, and p_2> p_3 < p_4, and 3 the only such index.\\n\\nOne can show that there is no such permutation for the third test case.\\nSolve the task in JAVA.\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\n\\n\\/\\/ THIS TEMPLATE MADE BY AKSH BANSAL.\\n\\npublic class Solution {\\n static class FastReader {\\n BufferedReader br;\\n StringTokenizer st;\\n public FastReader() {\\n br = new BufferedReader(new InputStreamReader(System.in));\\n }\\n String next() {\\n while (st == null || !st.hasMoreElements()) {\\n try {\\n st = new StringTokenizer(br.readLine());\\n } catch (IOException e) {\\n e.printStackTrace();\\n }\\n }\\n return st.nextToken();\\n }\\n int nextInt() {\\n return Integer.parseInt(next());\\n }\\n long nextLong() {\\n return Long.parseLong(next());\\n }\\n double nextDouble() {\\n return Double.parseDouble(next());\\n }\\n String nextLine() {\\n String str = \\\"\\\";\\n try {\\n str = br.readLine();\\n } catch (IOException e) {\\n e.printStackTrace();\\n }\\n return str;\\n }\\n }\\n static void sort(int a[]){ \\/\\/ int -> long\\n ArrayList arr=new ArrayList<>(); \\/\\/ Integer -> Long\\n for(int i=0;i0){\\n res++;\\n n\\/=2;\\n }\\n return res;\\n }\\n\\n static int mod = (int)1e9+7;\\n static PrintWriter out;\\n static FastReader sc ;\\n public static void main(String[] args) throws IOException {\\n sc = new...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nMr. Chanek gives you a sequence a indexed from 1 to n. Define f(a) as the number of indices where a_i = i. \\n\\nYou can pick an element from the current sequence and remove it, then concatenate the remaining elements together. For example, if you remove the 3-rd element from the sequence [4, 2, 3, 1], the resulting sequence will be [4, 2, 1]. \\n\\nYou want to remove some elements from a in order to maximize f(a), using zero or more operations. Find the largest possible f(a).\\n\\nInput\\n\\nThe first line contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the initial length of the sequence.\\n\\nThe second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 2 ⋅ 10^5) — the initial sequence a.\\n\\nOutput\\n\\nOutput an integer denoting the largest f(a) that can be obtained by doing zero or more operations.\\n\\nExamples\\n\\nInput\\n\\n\\n7\\n2 1 4 2 5 3 7\\n\\n\\nOutput\\n\\n\\n3\\n\\n\\nInput\\n\\n\\n4\\n4 2 3 1\\n\\n\\nOutput\\n\\n\\n2\\n\\nNote\\n\\nIn the first example, f(A) = 3 by doing the following operations.\\n\\n[2,1,4,2,5,3,7] → [2,1,2,5,3,7] → [1,2,5,3,7] → [1,2,5,3] → [1,2,3]\\n\\nIn the second example, f(A) = 2 and no additional operation is needed.\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 4e5 + 10;\\nnamespace Seg {\\nint f[N << 1];\\ninline void Init() {\\n for (int i = 0; i < N << 1; ++i) f[i] = -1e9;\\n}\\ninline void Update(int x, int y) {\\n for (int i = N + x; i; i >>= 1) f[i] = max(f[i], y);\\n}\\ninline int Ask(int x, int y) {\\n int ans = -1e9;\\n for (int l = N + x - 1, r = N + y + 1; l ^ r ^ 1; l >>= 1, r >>= 1) {\\n if (~l & 1) ans = max(ans, f[l ^ 1]);\\n if (r & 1) ans = max(ans, f[r ^ 1]);\\n }\\n return ans;\\n}\\n} \\/\\/ namespace Seg\\nint n;\\npair p[N];\\nint main() {\\n scanf(\\\"%d\\\", &n);\\n for (int i = 1, x; i <= n; ++i) {\\n scanf(\\\"%d\\\", &x);\\n p[i] = pair(i - x, x);\\n }\\n sort(p + 1, p + n + 1);\\n Seg::Init();\\n Seg::Update(0, 0);\\n int ans = 0;\\n for (int i = 1; i <= n; ++i)\\n if (p[i].first >= 0) {\\n int f = Seg::Ask(0, p[i].second - 1) + 1;\\n ans = max(ans, f);\\n Seg::Update(p[i].second, f);\\n }\\n printf(\\\"%d\\\\n\\\", ans);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 solution for \\\"The only difference between this problem and D1 is that you don't have to provide the way to construct the answer in D1, but you have to do it in this problem.\\n\\nThere's a table of n × m cells (n rows and m columns). The value of n ⋅ m is even.\\n\\nA domino is a figure that consists of two cells having a common side. It may be horizontal (one of the cells is to the right of the other) or vertical (one of the cells is above the other).\\n\\nYou need to place nm\\/2 dominoes on the table so that exactly k of them are horizontal and all the other dominoes are vertical. The dominoes cannot overlap and must fill the whole table.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of a single line. The line contains three integers n, m, k (1 ≤ n,m ≤ 100, 0 ≤ k ≤ nm\\/2, n ⋅ m is even) — the count of rows, columns and horizontal dominoes, respectively.\\n\\nOutput\\n\\nFor each test case:\\n\\n * print \\\"NO\\\" if it's not possible to place the dominoes on the table in the described way; \\n * otherwise, print \\\"YES\\\" on a separate line, then print n lines so that each of them contains m lowercase letters of the Latin alphabet — the layout of the dominoes on the table. Each cell of the table must be marked by the letter so that for every two cells having a common side, they are marked by the same letters if and only if they are occupied by the same domino. I.e. both cells of the same domino must be marked with the same letter, but two dominoes that share a side must be marked with different letters. If there are multiple solutions, print any of them. \\n\\nExample\\n\\nInput\\n\\n\\n8\\n4 4 2\\n2 3 0\\n3 2 3\\n1 2 0\\n2 4 2\\n5 2 2\\n2 17 16\\n2 1 1\\n\\n\\nOutput\\n\\n\\nYES\\naccx\\naegx\\nbega\\nbdda\\nYES\\naha\\naha\\nYES\\nzz\\naa\\nzz\\nNO\\nYES\\naaza\\nbbza\\nNO\\nYES\\nbbaabbaabbaabbaay\\nddccddccddccddccy\\nNO\\\":\",\"targets\":\"from collections import deque\\nimport heapq\\nfrom math import sqrt\\nimport operator\\nfrom operator import itemgetter\\nimport sys\\n\\nimport copy\\n\\n \\ninf_var = 0\\nif inf_var == 1:\\n inf = open('input.txt', 'r')\\nelse:\\n inf = sys.stdin\\n \\ninput = inf.readline\\n# sys.stdout = open('output.txt', 'w')\\n \\ndef read_one_int():\\n return int(input().rstrip('\\\\n'))\\n\\n\\ndef read_one_float():\\n return float(input().rstrip('\\\\n'))\\n \\n \\ndef read_list_of_ints():\\n res = [int(val) for val in (input().rstrip('\\\\n')).split(' ')]\\n return res\\n \\ndef read_str():\\n return input().rstrip()\\n\\n\\ndef in_field(field, i, j):\\n return i >= 0 and j >= 0 and i < len(field) and j < len(field[0])\\n\\n\\ndef get_next_ch(field, i1, j1, i2, j2):\\n not_used = set('abcdefghijk')\\n\\n dx = [1, -1, 0, 0]\\n dy = [0, 0, -1, 1]\\n\\n for i in range(len(dx)):\\n cur_i = i1 + dx[i]\\n cur_j = j1 + dy[i]\\n if in_field(field, cur_i, cur_j):\\n if field[cur_i][cur_j] is not None:\\n if field[cur_i][cur_j] in not_used:\\n not_used.remove(field[cur_i][cur_j])\\n\\n cur_i = i2 + dx[i]\\n cur_j = j2 + dy[i]\\n if in_field(field, cur_i, cur_j):\\n if field[cur_i][cur_j] is not None:\\n if field[cur_i][cur_j] in not_used:\\n not_used.remove(field[cur_i][cur_j])\\n\\n return not_used.pop()\\n\\n\\ndef main():\\n tests = read_one_int()\\n\\n for _ in range(tests):\\n n, m, hor = read_list_of_ints()\\n field = [[None for _ in range(m)] for _ in range(n)]\\n vert = n * m \\/\\/ 2 - hor\\n\\n square = n * m\\n skip = None\\n\\n if n % 2:\\n hor -= m \\/\\/ 2\\n square -= m\\n n -= 1\\n\\n if hor < 0:\\n print('NO')\\n continue\\n\\n for i in range(0, m, 2):\\n cur_ch = get_next_ch(field, 0, i, 0, i + 1)\\n field[0][i] = cur_ch\\n field[0][i + 1] = cur_ch\\n skip = 'hor'\\n\\n if m % 2:\\n vert -= n \\/\\/ 2\\n square -= n\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Dr. Bruce Banner hates his enemies (like others don't). As we all know, he can barely talk when he turns into the incredible Hulk. That's why he asked you to help him to express his feelings.\\n\\nHulk likes the Inception so much, and like that his feelings are complicated. They have n layers. The first layer is hate, second one is love, third one is hate and so on...\\n\\nFor example if n = 1, then his feeling is \\\"I hate it\\\" or if n = 2 it's \\\"I hate that I love it\\\", and if n = 3 it's \\\"I hate that I love that I hate it\\\" and so on.\\n\\nPlease help Dr. Banner.\\n\\nInput\\n\\nThe only line of the input contains a single integer n (1 ≤ n ≤ 100) — the number of layers of love and hate.\\n\\nOutput\\n\\nPrint Dr.Banner's feeling in one line.\\n\\nExamples\\n\\nInput\\n\\n1\\n\\n\\nOutput\\n\\nI hate it\\n\\n\\nInput\\n\\n2\\n\\n\\nOutput\\n\\nI hate that I love it\\n\\n\\nInput\\n\\n3\\n\\n\\nOutput\\n\\nI hate that I love that I hate it\\nSolve the task in PYTHON3.\",\"targets\":\"n = int(input())\\n\\n\\ndef hulk(num):\\n hate = \\\"I hate\\\"\\n love = \\\"I love\\\"\\n res = \\\"\\\"\\n for i in range(1, num + 1):\\n if i == 1:\\n res += hate\\n elif i % 2 == 0:\\n res += \\\" that \\\" + love\\n else:\\n res += \\\" that \\\" + hate\\n return res\\n\\n\\nprint(hulk(n) + \\\" it\\\")\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Luntik has decided to try singing. He has a one-minute songs, b two-minute songs and c three-minute songs. He wants to distribute all songs into two concerts such that every song should be included to exactly one concert.\\n\\nHe wants to make the absolute difference of durations of the concerts as small as possible. The duration of the concert is the sum of durations of all songs in that concert.\\n\\nPlease help Luntik and find the minimal possible difference in minutes between the concerts durations.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases.\\n\\nEach test case consists of one line containing three integers a, b, c (1 ≤ a, b, c ≤ 10^9) — the number of one-minute, two-minute and three-minute songs.\\n\\nOutput\\n\\nFor each test case print the minimal possible difference in minutes between the concerts durations.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n1 1 1\\n2 1 3\\n5 5 5\\n1 1 2\\n\\n\\nOutput\\n\\n\\n0\\n1\\n0\\n1\\n\\nNote\\n\\nIn the first test case, Luntik can include a one-minute song and a two-minute song into the first concert, and a three-minute song into the second concert. Then the difference will be equal to 0.\\n\\nIn the second test case, Luntik can include two one-minute songs and a two-minute song and a three-minute song into the first concert, and two three-minute songs into the second concert. The duration of the first concert will be 1 + 1 + 2 + 3 = 7, the duration of the second concert will be 6. The difference of them is |7-6| = 1.\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nlong long n, t, a, b, c;\\nint main() {\\n cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);\\n cin >> t;\\n while (t--) {\\n cin >> a >> b >> c;\\n long long s = a + 2 * b + 3 * c;\\n if (s % 2 == 0)\\n cout << 0 << \\\"\\\\n\\\";\\n else\\n cout << 1 << \\\"\\\\n\\\";\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"You are given an integer n. Find any string s of length n consisting only of English lowercase letters such that each non-empty substring of s occurs in s an odd number of times. If there are multiple such strings, output any. It can be shown that such string always exists under the given constraints.\\n\\nA string a is a substring of a string b if a can be obtained from b by deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 500) — the number of test cases.\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 10^5).\\n\\nIt is guaranteed that the sum of n over all test cases doesn't exceed 3 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print a single line containing the string s. If there are multiple such strings, output any. It can be shown that such string always exists under the given constraints.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n5\\n9\\n19\\n\\n\\nOutput\\n\\n\\nabc\\ndiane\\nbbcaabbba\\nyouarethecutestuwuu\\n\\nNote\\n\\nIn the first test case, each substring of \\\"abc\\\" occurs exactly once.\\n\\nIn the third test case, each substring of \\\"bbcaabbba\\\" occurs an odd number of times. In particular, \\\"b\\\" occurs 5 times, \\\"a\\\" and \\\"bb\\\" occur 3 times each, and each of the remaining substrings occurs exactly once.\\\":\",\"targets\":\"\\/\\/ * * * the goal is to be worlds best * * * \\/\\/\\n import java.io.BufferedReader;\\n import java.io.IOException;\\n import java.io.InputStreamReader;\\n import java.util.*;\\n \\n \\n public class E {\\n static class Pair implements Comparable{\\n int a;\\n int b;\\n \\n Pair(int a , int b){\\n this.a = a;\\n this.b = b;\\n }\\n \\n public int compareTo(Pair o){\\n return this.a - o.a;\\n }\\n }\\n \\n \\/\\/==================================================================================================\\n \\n public static void main(String[] args) {\\n FastScanner sc = new FastScanner();\\n int t = sc.nextInt();\\n while(t-->0){\\n int n = sc.nextInt();\\n if(n == 1){\\n System.out.println(\\\"a\\\");\\n continue;\\n }\\n StringBuilder sb = new StringBuilder(\\\"\\\");\\n for(int i = 0; i < n \\/ 2; i++){\\n sb.append(\\\"a\\\");\\n }\\n sb.append(\\\"b\\\");\\n for(int i = 0; i < n \\/ 2 - 1; i++){\\n sb.append(\\\"a\\\");\\n }\\n if((n & 1) == 1){\\n sb.append(\\\"c\\\");\\n }\\n \\n System.out.println(sb.toString());\\n }\\n }\\n \\n \\/\\/==================================================================================================\\n \\n \\n \\/\\/ Use this instead of Arrays.sort() on an array of ints. Arrays.sort() is n^2\\n \\/\\/ worst case since it uses a version of quicksort. Although this would never\\n \\/\\/ actually show up in the real world, in codeforces, people can hack, so\\n \\/\\/ this is needed. \\n\\t static void sort(int[] arr) {\\n\\t\\t int n = arr.length;\\n\\t\\t ArrayList res = new ArrayList<>();\\n\\t\\t for (int a : arr) {\\n\\t\\t \\t res.add(a);\\n\\t\\t }\\n\\t\\t Collections.sort(res);\\n\\t\\t for (int i = 0; i < n; i++) {\\n\\t\\t\\t arr[i] = res.get(i);\\n\\t\\t }\\n\\t }\\n \\n\\t static void sort(long[] arr) {\\n\\t\\t int n = arr.length;\\n\\t\\t ArrayList res = new ArrayList<>();\\n\\t\\t for (long a : arr) {\\n\\t\\t\\t res.add(a);\\n\\t\\t }\\n\\t\\t...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alice likes word \\\"nineteen\\\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\\n\\nFor example, if she has string \\\"xiineteenppnnnewtnee\\\", she can get string \\\"xnineteenppnineteenw\\\", containing (the occurrences marked) two such words. More formally, word \\\"nineteen\\\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\\n\\nHelp her to find the maximum number of \\\"nineteen\\\"s that she can get in her string.\\n\\nInput\\n\\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\\n\\nOutput\\n\\nPrint a single integer — the maximum number of \\\"nineteen\\\"s that she can get in her string.\\n\\nExamples\\n\\nInput\\n\\nnniinneetteeeenn\\n\\n\\nOutput\\n\\n2\\n\\nInput\\n\\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\\n\\n\\nOutput\\n\\n2\\n\\nInput\\n\\nnineteenineteen\\n\\n\\nOutput\\n\\n2\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"s=input()\\nn=s.count('n')\\ne=s.count('e')\\ni=s.count('i')\\nt=s.count('t')\\nif n>2:\\n print(min(1+(n-3)\\/\\/2,e\\/\\/3,i,t))\\nelse:print(0)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alas, finding one's true love is not easy. Masha has been unsuccessful in that yet. Her friend Dasha told Masha about a way to determine the phone number of one's Prince Charming through arithmancy. \\n\\nThe phone number is divined like that. First one needs to write down one's own phone numbers. For example, let's suppose that Masha's phone number is 12345. After that one should write her favorite digit from 0 to 9 under the first digit of her number. That will be the first digit of the needed number. For example, Masha's favorite digit is 9. The second digit is determined as a half sum of the second digit of Masha's number and the already written down first digit from her beloved one's number. In this case the arithmetic average equals to (2 + 9) \\/ 2 = 5.5. Masha can round the number up or down, depending on her wishes. For example, she chooses the digit 5. Having written down the resulting digit under the second digit of her number, Masha moves to finding the third digit in the same way, i.e. finding the half sum the the third digit of her number and the second digit of the new number. The result is (5 + 3) \\/ 2 = 4. In this case the answer is unique. Thus, every i-th digit is determined as an arithmetic average of the i-th digit of Masha's number and the i - 1-th digit of her true love's number. If needed, the digit can be rounded up or down. For example, Masha can get: \\n\\n12345 95444 Unfortunately, when Masha tried dialing the number, she got disappointed: as it turned out, the number was unavailable or outside the coverage area. But Masha won't give up. Perhaps, she rounded to a wrong digit or chose the first digit badly. That's why she keeps finding more and more new numbers and calling them. Count the number of numbers Masha calls. Masha calls all the possible numbers that can be found by the described means of arithmancy, except for, perhaps, her own one.\\n\\nInput\\n\\nThe first line contains nonempty sequence consisting of digits from 0 to 9 — Masha's phone number. The sequence length does not exceed...\\nimpor\",\"targets\":\"t java.io.OutputStream;\\nimport java.io.IOException;\\nimport java.io.InputStream;\\nimport java.io.PrintWriter;\\nimport java.util.StringTokenizer;\\nimport java.io.IOException;\\nimport java.io.BufferedReader;\\nimport java.io.InputStreamReader;\\nimport java.io.InputStream;\\n\\n\\/**\\n * Built using CHelper plug-in\\n * Actual solution is at the top\\n *\\/\\npublic class Main {\\n public static void main(String[] args) {\\n InputStream inputStream = System.in;\\n OutputStream outputStream = System.out;\\n InputReader in = new InputReader(inputStream);\\n PrintWriter out = new PrintWriter(outputStream);\\n TaskH solver = new TaskH();\\n solver.solve(1, in, out);\\n out.close();\\n }\\n\\n static class TaskH {\\n String seq;\\n long[][] memo;\\n\\n public void solve(int testNumber, InputReader in, PrintWriter out) {\\n seq = in.next();\\n long ans = 0;\\n memo = new long[seq.length()][10];\\n for (int i = 0; i <= 9; i++) {\\n memo[seq.length() - 1][i] = 1;\\n }\\n for (int i = 0; i <= 9; i++) {\\n ans += calc(0, i);\\n }\\n if (can()) ans--;\\n out.println(ans);\\n }\\n\\n long calc(int ind, int digit) {\\n if (memo[ind][digit] == 0) {\\n memo[ind][digit] = _calc(ind, digit);\\n }\\n return memo[ind][digit];\\n }\\n\\n long _calc(int ind, int digit) {\\n if (ind == seq.length() - 1) return 1;\\n long res = 0;\\n int nextDigit2 = seq.charAt(ind + 1) - '0' + digit;\\n res += calc(ind + 1, nextDigit2 \\/ 2);\\n if (nextDigit2 % 2 == 1) {\\n res += calc(ind + 1, (nextDigit2 + 1) \\/ 2);\\n }\\n return res;\\n }\\n\\n boolean can() {\\n for (int i = 1; i < seq.length(); i++) {\\n int sum = seq.charAt(i) - '0' + seq.charAt(i - 1) - '0';\\n int dif = sum - 2 * (seq.charAt(i) - '0');\\n if (Math.abs(dif) > 1)...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"As you know, the game of \\\"Nim\\\" is played with n piles of stones, where the i-th pile initially contains ai stones. Two players alternate the turns. During a turn a player picks any non-empty pile and removes any positive number of stones from it. The one who is not able to make a move loses the game.\\n\\nPetya and Vasya are tired of playing Nim, so they invented their own version of the game and named it the \\\"Gambling Nim\\\". They have n two-sided cards, one side of the i-th card has number ai written on it, while the other side has number bi. At the beginning of the game the players put all the cards on the table, each card only one of its sides up, and this side is chosen independently and uniformly. Thus they obtain a sequence c1, c2, ..., cn, where ci is equal to ai or bi. Then they take n piles of stones, with i-th pile containing exactly ci stones and play Nim. Petya takes the first turn.\\n\\nGiven that both players play optimally, find the probability of Petya's victory. Output the answer as an irreducible fraction.\\n\\nInput\\n\\nThe first line of the input contains a single integer n (1 ≤ n ≤ 500 000) — the number of cards in the deck.\\n\\nEach of the following n lines contains the description of one card, consisting of two integers ai and bi (0 ≤ ai, bi ≤ 1018).\\n\\nOutput\\n\\nOutput the answer as an irreducible fraction p \\/ q. If the probability of Petya's victory is 0, print 0\\/1.\\n\\nExamples\\n\\nInput\\n\\n2\\n1 1\\n1 1\\n\\n\\nOutput\\n\\n0\\/1\\n\\n\\nInput\\n\\n2\\n1 2\\n1 2\\n\\n\\nOutput\\n\\n1\\/2\\n\\n\\nInput\\n\\n3\\n0 4\\n1 5\\n2 3\\n\\n\\nOutput\\n\\n1\\/1\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nconst long long N = 500500;\\nlong long i, j, k, n, sum, ch, t, ans, num;\\nlong long a[N], b[N], c[N];\\nvoid R(long long &x) {\\n x = 0;\\n ch = getchar();\\n while (ch < '0' || '9' < ch) ch = getchar();\\n while ('0' <= ch && ch <= '9') x = x * 10 + ch - '0', ch = getchar();\\n}\\nint main() {\\n R(n);\\n for (i = 1; i <= n; i++) {\\n R(a[i]);\\n R(b[i]);\\n c[i] = a[i] ^ b[i];\\n sum ^= a[i];\\n }\\n k = 60;\\n for (i = 1; i <= n; i++) {\\n for (j = i + 1; j <= n; j++)\\n if (c[i] < c[j]) t = c[i], c[i] = c[j], c[j] = t;\\n if (!c[i]) break;\\n while (!(c[i] & 1ll << k)) k--;\\n for (j = i + 1; j <= n; j++)\\n if (c[j] & 1ll << k) c[j] ^= c[i];\\n }\\n num = i - 1;\\n ans = 1ll << num;\\n j = 60;\\n for (i = 1; i <= num; i++) {\\n while (!(c[i] & 1ll << j)) j--;\\n if (sum & 1ll << j) sum ^= c[i];\\n }\\n if (sum)\\n puts(\\\"1\\/1\\\");\\n else\\n printf(\\\"%I64d\\/%I64d\\\\n\\\", ans - 1, ans);\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nA chess tournament will be held soon, where n chess players will take part. Every participant will play one game against every other participant. Each game ends in either a win for one player and a loss for another player, or a draw for both players.\\n\\nEach of the players has their own expectations about the tournament, they can be one of two types:\\n\\n 1. a player wants not to lose any game (i. e. finish the tournament with zero losses); \\n 2. a player wants to win at least one game. \\n\\n\\n\\nYou have to determine if there exists an outcome for all the matches such that all the players meet their expectations. If there are several possible outcomes, print any of them. If there are none, report that it's impossible.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 200) — the number of test cases.\\n\\nThe first line of each test case contains one integer n (2 ≤ n ≤ 50) — the number of chess players.\\n\\nThe second line contains the string s (|s| = n; s_i ∈ \\\\{1, 2\\\\}). If s_i = 1, then the i-th player has expectations of the first type, otherwise of the second type.\\n\\nOutput\\n\\nFor each test case, print the answer in the following format:\\n\\nIn the first line, print NO if it is impossible to meet the expectations of all players.\\n\\nOtherwise, print YES, and the matrix of size n × n in the next n lines.\\n\\nThe matrix element in the i-th row and j-th column should be equal to:\\n\\n * +, if the i-th player won in a game against the j-th player; \\n * -, if the i-th player lost in a game against the j-th player; \\n * =, if the i-th and j-th players' game resulted in a draw; \\n * X, if i = j. \\n\\nExample\\n\\nInput\\n\\n\\n3\\n3\\n111\\n2\\n21\\n4\\n2122\\n\\n\\nOutput\\n\\n\\nYES\\nX==\\n=X=\\n==X\\nNO\\nYES\\nX--+\\n+X++\\n+-X-\\n--+X\",\"targets\":\"#include \\nusing namespace std;\\nchar s[1010];\\nchar a[52][52];\\nint main() {\\n int T;\\n cin >> T;\\n while (T--) {\\n memset(a, 0, sizeof(a));\\n int n;\\n cin >> n >> s;\\n vector v;\\n for (int i = 0; i < n; i++) {\\n if (s[i] == '2') v.push_back(i + 1);\\n }\\n if (v.size() == 2 || v.size() == 1) {\\n cout << \\\"NO\\\\n\\\";\\n continue;\\n }\\n for (int i = 1; i <= n; i++) a[i][i] = 'X';\\n for (int i = 0; i < v.size(); i++) {\\n int j = (i + 1) % (v.size());\\n a[v[i]][v[j]] = '+';\\n a[v[j]][v[i]] = '-';\\n }\\n cout << \\\"YES\\\\n\\\";\\n for (int i = 1; i <= n; i++) {\\n for (int j = 1; j <= n; j++) {\\n if (a[i][j])\\n cout << a[i][j];\\n else\\n cout << \\\"=\\\";\\n }\\n cout << \\\"\\\\n\\\";\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You have an array a consisting of n distinct positive integers, numbered from 1 to n. Define p_k as $$$p_k = ∑_{1 ≤ i, j ≤ k} a_i mod a_j, where x \\\\bmod y denotes the remainder when x is divided by y. You have to find and print p_1, p_2, \\\\ldots, p_n$$$. \\n\\nInput\\n\\nThe first line contains n — the length of the array (2 ≤ n ≤ 2 ⋅ 10^5).\\n\\nThe second line contains n space-separated distinct integers a_1, …, a_n (1 ≤ a_i ≤ 3 ⋅ 10^5, a_i ≠ a_j if i ≠ j). \\n\\nOutput\\n\\nPrint n integers p_1, p_2, …, p_n. \\n\\nExamples\\n\\nInput\\n\\n\\n4\\n6 2 7 3\\n\\n\\nOutput\\n\\n\\n0 2 12 22\\n\\n\\nInput\\n\\n\\n3\\n3 2 1\\n\\n\\nOutput\\n\\n\\n0 3 5\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nusing ll = long long;\\nusing ld = long double;\\ntemplate \\nbool uin(T& a, const T& b) {\\n return a > b ? a = b, 1 : 0;\\n}\\ntemplate \\nbool uax(T& a, const T& b) {\\n return a < b ? a = b, 1 : 0;\\n}\\nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\\nconst int N = 3e5 + 10;\\nstruct {\\n int t[N << 1];\\n void activate(int p) {\\n for (t[p += N] = 1; p >>= 1;) t[p] = t[p << 1] + t[p << 1 | 1];\\n }\\n int query(int l, int r) {\\n int res = 0;\\n for (l += N, r = min(r, N) + N; l < r; l >>= 1, r >>= 1) {\\n if (l & 1) res += t[l++];\\n if (r & 1) res += t[--r];\\n }\\n return res;\\n }\\n} one;\\nstruct {\\n ll t[N << 1];\\n ll query(int p) {\\n ll res = 0;\\n for (p += N; p > 0; p >>= 1) res += t[p];\\n return res;\\n }\\n void update(int l, int r, int del) {\\n r = min(r, N);\\n for (l += N, r += N; l < r; l >>= 1, r >>= 1) {\\n if (l & 1) t[l++] += del;\\n if (r & 1) t[--r] += del;\\n }\\n }\\n} two;\\nsigned main() {\\n ios::sync_with_stdio(false);\\n cin.tie(nullptr);\\n int n;\\n cin >> n;\\n vector a(n);\\n for (auto& x : a) cin >> x;\\n ll sum = 0, ans = 0;\\n for (auto k = (0); k < (n); ++k) {\\n ans += sum;\\n ans += 1ll * k * a[k] - two.query(a[k]);\\n for (ll l = 0; l < N; l += a[k]) {\\n ans -= one.query(l, l + a[k]) * l;\\n two.update(l, l + a[k], l);\\n }\\n sum += a[k];\\n one.activate(a[k]);\\n cout << ans << ' ';\\n }\\n cout << '\\\\n';\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"In Berland, n different types of banknotes are used. Banknotes of the i-th type have denomination 10^{a_i} burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly 1.\\n\\nLet's denote f(s) as the minimum number of banknotes required to represent exactly s burles. For example, if the denominations of banknotes used in Berland are 1, 10 and 100, then f(59) = 14: 9 banknotes with denomination of 1 burle and 5 banknotes with denomination of 10 burles can be used to represent exactly 9 ⋅ 1 + 5 ⋅ 10 = 59 burles, and there's no way to do it with fewer banknotes.\\n\\nFor a given integer k, find the minimum positive number of burles s that cannot be represented with k or fewer banknotes (that is, f(s) > k).\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — number of test cases.\\n\\nThe first line of each test case contains two integers n and k (1 ≤ n ≤ 10; 1 ≤ k ≤ 10^9).\\n\\nThe next line contains n integers a_1, a_2, ..., a_n (0 = a_1 < a_2 < ... < a_n ≤ 9).\\n\\nOutput\\n\\nFor each test case, print one integer — the minimum positive number of burles s that cannot be represented with k or fewer banknotes.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3 13\\n0 1 2\\n2 777\\n0 4\\n3 255\\n0 1 3\\n10 1000000000\\n0 1 2 3 4 5 6 7 8 9\\n\\n\\nOutput\\n\\n\\n59\\n778\\n148999\\n999999920999999999\\nSolve the task in JAVA.\",\"targets\":\"import java.util.*;\\n\\nimport java.io.*;\\nimport java.math.*;\\n\\n\\n\\/**\\n * @author Naitik\\n * \\n *\\/\\npublic class Main\\n\\n{ \\n\\t static FastReader sc=new FastReader(); \\n\\t static int dp[][][];\\n\\t \\/\\/static int v[][];\\n\\t static int mod=998244353;;\\n\\/\\/\\t static int mod=1000000007;\\n\\t static long max;\\n\\t static long bit[];\\n\\t \\/\\/static long bit1[];\\n\\/\\/\\t static long seg[];\\n\\t \\/\\/static long fact[];\\n\\/\\/\\t static long A[];\\n\\t\\/\\/ static TreeMap map;\\n\\t \\/\\/static StringBuffer sb=new StringBuffer(\\\"\\\");\\n\\t static HashMap map;\\n\\t static PrintWriter out=new PrintWriter(System.out);\\n\\t \\n\\t public static void main(String[] args)\\n\\t {\\n\\t\\t \\/\\/ StringBuffer sb=new StringBuffer(\\\"\\\");\\n\\t\\t int ttt=1;\\n\\t\\t ttt =i();\\t\\t\\t \\n\\t outer :while (ttt-- > 0) \\n\\t\\t\\t{\\n\\t \\tint n=i();\\n\\t \\tlong k=l();\\n\\t \\tint A[]=input(n);\\n\\t \\tlong B[]=new long[10];\\n\\t \\tB[0]=1;\\n\\t \\tHashMap map=hash(A);\\n\\t \\tfor(int i=1;i<10;i++) {\\n\\t \\t\\tif(!map.containsKey(i)) {\\n\\t \\t\\t\\tB[i]=B[i-1];\\n\\t \\t\\t}\\n\\t \\t\\telse {\\n\\t \\t\\t\\tB[i]=power(10, i);\\n\\t \\t\\t}\\n\\t \\t}\\n\\t \\tlong D[]=new long[19];\\n\\t \\tfor(int i=0;i<19;i++) {\\n\\t \\t\\tD[i]=power(10, i);\\n\\t \\t}\\n\\t \\tlong y=0;\\n\\t \\tint c=0;\\n\\t \\twhile(true) {\\n\\t \\t\\ty=9*D[c]+y;\\n\\t \\t\\tlong op1=go(y, B,D);\\n\\t \\t\\tif(op1>k)\\n\\t \\t\\t\\tbreak;\\n\\t \\t\\tc++;\\n\\t \\t}\\n\\t \\tchar C[]=(y+\\\"\\\").toCharArray();\\n\\t \\tn=C.length-1;\\n\\t \\tlong ans=Long.MAX_VALUE;\\n\\t \\tfor(int i=0;i=0;j--) {\\n\\t \\t\\t\\tlong op1=y-j*D[n-i];\\n\\t \\t\\t\\tlong go=go(op1, B,D);\\n\\t \\t\\t\\tif(go>k) {\\n\\t \\t\\t\\t\\tans=op1;\\n\\t \\t\\t\\t\\tbreak;\\n\\t \\t\\t\\t\\t\\n\\t \\t\\t\\t}\\n\\t \\t\\t}\\n\\t \\t\\ty=ans;\\n\\t \\t}\\n\\t \\t\\n\\t \\tout.println(y);\\n\\t \\t\\n\\t \\t\\n\\t \\t\\n\\t }\\n\\t \\/\\/System.out.println(sb.toString());\\n\\t\\t out.close();\\n\\t \\n\\t \\n\\t \\/\\/CHECK FOR N=1 \\/\\/CHECK FOR M=0\\n \\/\\/CHECK FOR N=1 ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"This is a simplified version of the problem B2. Perhaps you should read the problem B2 before you start solving B1.\\n\\nPaul and Mary have a favorite string s which consists of lowercase letters of the Latin alphabet. They want to paint it using pieces of chalk of two colors: red and green. Let's call a coloring of a string wonderful if the following conditions are met:\\n\\n 1. each letter of the string is either painted in exactly one color (red or green) or isn't painted; \\n 2. each two letters which are painted in the same color are different; \\n 3. the number of letters painted in red is equal to the number of letters painted in green; \\n 4. the number of painted letters of this coloring is maximum among all colorings of the string which meet the first three conditions. \\n\\n\\n\\nE. g. consider a string s equal to \\\"kzaaa\\\". One of the wonderful colorings of the string is shown in the figure.\\n\\n The example of a wonderful coloring of the string \\\"kzaaa\\\".\\n\\nPaul and Mary want to learn by themselves how to find a wonderful coloring of the string. But they are very young, so they need a hint. Help them find k — the number of red (or green, these numbers are equal) letters in a wonderful coloring.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 1000) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one non-empty string s which consists of lowercase letters of the Latin alphabet. The number of characters in the string doesn't exceed 50.\\n\\nOutput\\n\\nFor each test case, output a separate line containing one non-negative integer k — the number of letters which will be painted in red in a wonderful coloring.\\n\\nExample\\n\\nInput\\n\\n\\n5\\nkzaaa\\ncodeforces\\narchive\\ny\\nxxxxxx\\n\\n\\nOutput\\n\\n\\n2\\n5\\n3\\n0\\n1\\n\\nNote\\n\\nThe first test case contains the string from the statement. One of the wonderful colorings is shown in the figure. There's no wonderful coloring containing 3 or more red letters because the total number of painted symbols will exceed the string's length.\\n\\nThe string from the second test case can be...\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.util.*;\\n\\npublic class Wonderful_ColoringA {\\n private static final Scanner SCANNER=new Scanner(System.in);\\n\\n public static void main(String[] args) {\\n int t=SCANNER.nextInt();\\n while (t-->0){\\n String s=SCANNER.next();\\n int[] count=new int[26];\\n int ans=0;\\n for (int i=0;i\\nusing namespace std;\\nint main() {\\n int i, j, k;\\n int n, l, r;\\n bool f;\\n cin >> n;\\n pair, int> a[n];\\n for (i = 0; i < n; i++) {\\n cin >> l >> r;\\n a[i] = {{l, r}, i + 1};\\n }\\n sort(a, a + n);\\n vector, int>> temp;\\n vector v;\\n for (i = 0; i < n; i++) {\\n for (j = 0; j < n; j++) {\\n if (j != i) temp.push_back(a[j]);\\n }\\n f = true;\\n for (j = 1; j < temp.size(); j++) {\\n if (temp[j].first.first < temp[j - 1].first.second) {\\n f = false;\\n break;\\n }\\n }\\n if (f) v.push_back(a[i].second);\\n temp.clear();\\n }\\n sort(v.begin(), v.end());\\n cout << v.size() << endl;\\n for (i = 0; i < v.size(); i++) cout << v[i] << \\\" \\\";\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A matrix of size n × m, such that each cell of it contains either 0 or 1, is considered beautiful if the sum in every contiguous submatrix of size 2 × 2 is exactly 2, i. e. every \\\"square\\\" of size 2 × 2 contains exactly two 1's and exactly two 0's.\\n\\nYou are given a matrix of size n × m. Initially each cell of this matrix is empty. Let's denote the cell on the intersection of the x-th row and the y-th column as (x, y). You have to process the queries of three types:\\n\\n * x y -1 — clear the cell (x, y), if there was a number in it; \\n * x y 0 — write the number 0 in the cell (x, y), overwriting the number that was there previously (if any); \\n * x y 1 — write the number 1 in the cell (x, y), overwriting the number that was there previously (if any). \\n\\n\\n\\nAfter each query, print the number of ways to fill the empty cells of the matrix so that the resulting matrix is beautiful. Since the answers can be large, print them modulo 998244353.\\n\\nInput\\n\\nThe first line contains three integers n, m and k (2 ≤ n, m ≤ 10^6; 1 ≤ k ≤ 3 ⋅ 10^5) — the number of rows in the matrix, the number of columns, and the number of queries, respectively.\\n\\nThen k lines follow, the i-th of them contains three integers x_i, y_i, t_i (1 ≤ x_i ≤ n; 1 ≤ y_i ≤ m; -1 ≤ t_i ≤ 1) — the parameters for the i-th query.\\n\\nOutput\\n\\nFor each query, print one integer — the number of ways to fill the empty cells of the matrix after the respective query, taken modulo 998244353.\\n\\nExample\\n\\nInput\\n\\n\\n2 2 7\\n1 1 1\\n1 2 1\\n2 1 1\\n1 1 0\\n1 2 -1\\n2 1 -1\\n1 1 -1\\n\\n\\nOutput\\n\\n\\n3\\n1\\n0\\n1\\n2\\n3\\n6\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nconst long long MOD = 998244353;\\nlong long pw[1010101];\\nint N, M, Q;\\nint X[1010101][2];\\nint Y[1010101][2];\\nint cntX[4];\\nint cntY[4];\\nint C[2];\\nmap, int> mp;\\nint getX(int x) {\\n int a = !!(X[x][0]), b = !!(X[x][1]);\\n return a << 1 | b;\\n}\\nint getY(int y) {\\n int a = !!(Y[y][0]), b = !!(Y[y][1]);\\n return a << 1 | b;\\n}\\nvoid ers(int x, int y) {\\n int t = mp[{x, y}];\\n mp.erase({x, y});\\n cntX[getX(x)]--;\\n X[x][y & 1 ^ t]--;\\n cntX[getX(x)]++;\\n cntY[getY(y)]--;\\n Y[y][x & 1 ^ t]--;\\n cntY[getY(y)]++;\\n C[x & 1 ^ y & 1 ^ t]--;\\n}\\nvoid add(int x, int y, int t) {\\n mp[{x, y}] = t;\\n cntX[getX(x)]--;\\n X[x][y & 1 ^ t]++;\\n cntX[getX(x)]++;\\n cntY[getY(y)]--;\\n Y[y][x & 1 ^ t]++;\\n cntY[getY(y)]++;\\n C[x & 1 ^ y & 1 ^ t]++;\\n}\\nint main() {\\n scanf(\\\"%d%d%d\\\", &N, &M, &Q);\\n pw[0] = 1;\\n for (int i = 1; i <= max(N, M); i++) pw[i] = pw[i - 1] * 2 % MOD;\\n cntX[0] = N;\\n cntY[0] = M;\\n while (Q--) {\\n int x, y, t;\\n scanf(\\\"%d%d%d\\\", &x, &y, &t);\\n if (t == -1) {\\n if (mp.find({x, y}) != mp.end()) ers(x, y);\\n } else {\\n if (mp.find({x, y}) != mp.end()) ers(x, y);\\n add(x, y, t);\\n }\\n long long ans = 0;\\n if (!cntX[3]) {\\n ans = (ans + pw[cntX[0]]) % MOD;\\n }\\n if (!cntY[3]) {\\n ans = (ans + pw[cntY[0]]) % MOD;\\n }\\n ans = (ans + MOD - !(C[0])) % MOD;\\n ans = (ans + MOD - !(C[1])) % MOD;\\n printf(\\\"%lld\\\\n\\\", ans);\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given four integer values a, b, c and m.\\n\\nCheck if there exists a string that contains: \\n\\n * a letters 'A'; \\n * b letters 'B'; \\n * c letters 'C'; \\n * no other letters; \\n * exactly m pairs of adjacent equal letters (exactly m such positions i that the i-th letter is equal to the (i+1)-th one). \\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.\\n\\nEach of the next t lines contains the description of the testcase — four integers a, b, c and m (1 ≤ a, b, c ≤ 10^8; 0 ≤ m ≤ 10^8).\\n\\nOutput\\n\\nFor each testcase print \\\"YES\\\" if there exists a string that satisfies all the requirements. Print \\\"NO\\\" if there are no such strings.\\n\\nYou may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES will all be recognized as positive answer).\\n\\nExample\\n\\nInput\\n\\n\\n3\\n2 2 1 0\\n1 1 1 1\\n1 2 3 2\\n\\n\\nOutput\\n\\n\\nYES\\nNO\\nYES\\n\\nNote\\n\\nIn the first testcase strings \\\"ABCAB\\\" or \\\"BCABA\\\" satisfy the requirements. There exist other possible strings.\\n\\nIn the second testcase there's no way to put adjacent equal letters if there's no letter that appears at least twice.\\n\\nIn the third testcase string \\\"CABBCC\\\" satisfies the requirements. There exist other possible strings.\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nconst long long M = 1e9 + 7;\\nvoid flashSpeed() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n}\\nconst long long N = 2e5 + 5;\\nlong long fact[N];\\ndouble Round(double var) {\\n float value = (long long)(var * 100 + .5);\\n return (float)value \\/ 100;\\n}\\nlong long ceils(long long x, long long y) { return x \\/ y + ((x % y) != 0); }\\nlong long Gcd(long long a, long long b) {\\n if (b > a) {\\n return Gcd(b, a);\\n }\\n if (b == 0)\\n return a;\\n else\\n return Gcd(b, a % b);\\n}\\nlong long lcm(long long a, long long b) { return a \\/ Gcd(a, b) * b; }\\nbool isPal(string s) {\\n for (long long i = 0; i < (long long)s.size() \\/ 2; i++) {\\n if (s[i] != s[(long long)s.size() - 1 - i]) return false;\\n }\\n return true;\\n}\\nlong long Sumdigits(long long a) {\\n long long total = 0;\\n while (a) {\\n total += a % 10;\\n a \\/= 10;\\n }\\n return total;\\n}\\nbool isPerfectSquare(long long n) {\\n for (long long i = 1; i * i <= n; i++) {\\n if ((n % i == 0) && (n \\/ i == i)) {\\n return true;\\n }\\n }\\n return false;\\n}\\nbool isPowerOfTwo(long long n) { return (ceil(log2(n)) == floor(log2(n))); }\\nvoid lexosmaintest(string s, string c) {\\n string t1 = s;\\n sort(t1.begin(), t1.end());\\n long long index = -1;\\n for (long long i = 0; i < s.length(); i++) {\\n if (s[i] != t1[i]) {\\n index = i;\\n break;\\n }\\n }\\n long long j;\\n for (long long i = 0; i < s.length(); i++) {\\n if (s[i] == t1[index]) j = i;\\n }\\n swap(s[index], s[j]);\\n}\\nconst long long NN = 1e4 + 5;\\nlong long primes[NN];\\nvector pr;\\nvoid sieve() {\\n for (long long i = 2; i < NN; i++) {\\n if (primes[i] == 0) {\\n pr.push_back(i);\\n for (long long j = i * i; j < NN; j += i) {\\n primes[j] = 1;\\n }\\n }\\n primes[i] ^= 1;\\n }\\n}\\nconst long long mod2 = 998244353;\\nlong long powerr(long long x, long long y, long long p = mod2) {\\n long long res = 1;\\n x = x % p;\\n if (x == 0) return 0;\\n while (y > 0) {\\n if (y & 1) res = (res * x) % p;\\n y = y >> 1;\\n x = (x * x) % p;\\n }\\n return...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"One day Squidward, Spongebob and Patrick decided to go to the beach. Unfortunately, the weather was bad, so the friends were unable to ride waves. However, they decided to spent their time building sand castles.\\n\\nAt the end of the day there were n castles built by friends. Castles are numbered from 1 to n, and the height of the i-th castle is equal to hi. When friends were about to leave, Squidward noticed, that castles are not ordered by their height, and this looks ugly. Now friends are going to reorder the castles in a way to obtain that condition hi ≤ hi + 1 holds for all i from 1 to n - 1.\\n\\nSquidward suggested the following process of sorting castles: \\n\\n * Castles are split into blocks — groups of consecutive castles. Therefore the block from i to j will include castles i, i + 1, ..., j. A block may consist of a single castle. \\n * The partitioning is chosen in such a way that every castle is a part of exactly one block. \\n * Each block is sorted independently from other blocks, that is the sequence hi, hi + 1, ..., hj becomes sorted. \\n * The partitioning should satisfy the condition that after each block is sorted, the sequence hi becomes sorted too. This may always be achieved by saying that the whole sequence is a single block. \\n\\n\\n\\nEven Patrick understands that increasing the number of blocks in partitioning will ease the sorting process. Now friends ask you to count the maximum possible number of blocks in a partitioning that satisfies all the above requirements.\\n\\nInput\\n\\nThe first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of castles Spongebob, Patrick and Squidward made from sand during the day.\\n\\nThe next line contains n integers hi (1 ≤ hi ≤ 109). The i-th of these integers corresponds to the height of the i-th castle.\\n\\nOutput\\n\\nPrint the maximum possible number of blocks in a valid partitioning.\\n\\nExamples\\n\\nInput\\n\\n3\\n1 2 3\\n\\n\\nOutput\\n\\n3\\n\\n\\nInput\\n\\n4\\n2 1 3 2\\n\\n\\nOutput\\n\\n2\\n\\nNote\\n\\nIn the first sample the partitioning looks like that: [1][2][3].\\n\\n\\n\\nIn the second...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nconst int INF = 1e18 + 7;\\nconst int N = 3e5 + 7;\\nconst int MOD = 1e9 + 7;\\nconst double Pi = 3.14159265358979323846;\\nint a[N], b[N];\\nsigned main() {\\n {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cout << fixed << setprecision(20);\\n cerr << fixed << setprecision(11);\\n };\\n int n;\\n cin >> n;\\n for (int i = 0; i < n; i++) {\\n cin >> a[i];\\n b[i] = a[i];\\n }\\n sort(b, b + n);\\n int ans = 0, k = 0;\\n map mp;\\n for (int i = 0; i < n; i++) {\\n k -= (mp[b[i]] > 0) + (mp[a[i]] > 0);\\n mp[b[i]]++;\\n mp[a[i]]--;\\n k += (mp[b[i]] > 0) + (mp[a[i]] > 0);\\n if (k == 0) ans++;\\n }\\n cout << ans;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nBees Alice and Alesya gave beekeeper Polina famous card game \\\"Set\\\" as a Christmas present. The deck consists of cards that vary in four features across three options for each kind of feature: number of shapes, shape, shading, and color. In this game, some combinations of three cards are said to make up a set. For every feature — color, number, shape, and shading — the three cards must display that feature as either all the same, or pairwise different. The picture below shows how sets look.\\n\\n\\n\\nPolina came up with a new game called \\\"Hyperset\\\". In her game, there are n cards with k features, each feature has three possible values: \\\"S\\\", \\\"E\\\", or \\\"T\\\". The original \\\"Set\\\" game can be viewed as \\\"Hyperset\\\" with k = 4.\\n\\nSimilarly to the original game, three cards form a set, if all features are the same for all cards or are pairwise different. The goal of the game is to compute the number of ways to choose three cards that form a set.\\n\\nUnfortunately, winter holidays have come to an end, and it's time for Polina to go to school. Help Polina find the number of sets among the cards lying on the table.\\n\\nInput\\n\\nThe first line of each test contains two integers n and k (1 ≤ n ≤ 1500, 1 ≤ k ≤ 30) — number of cards and number of features.\\n\\nEach of the following n lines contains a card description: a string consisting of k letters \\\"S\\\", \\\"E\\\", \\\"T\\\". The i-th character of this string decribes the i-th feature of that card. All cards are distinct.\\n\\nOutput\\n\\nOutput a single integer — the number of ways to choose three cards that form a set.\\n\\nExamples\\n\\nInput\\n\\n\\n3 3\\nSET\\nETS\\nTSE\\n\\n\\nOutput\\n\\n\\n1\\n\\nInput\\n\\n\\n3 4\\nSETE\\nETSE\\nTSES\\n\\n\\nOutput\\n\\n\\n0\\n\\nInput\\n\\n\\n5 4\\nSETT\\nTEST\\nEEET\\nESTE\\nSTES\\n\\n\\nOutput\\n\\n\\n2\\n\\nNote\\n\\nIn the third example test, these two triples of cards are sets:\\n\\n 1. \\\"SETT\\\", \\\"TEST\\\", \\\"EEET\\\" \\n 2. \\\"TEST\\\", \\\"ESTE\\\", \\\"STES\\\"\",\"targets\":\"#include \\nusing namespace std;\\nmap mp;\\nstring s[1510];\\nint main() {\\n int n, m;\\n cin >> n >> m;\\n int ans = 0;\\n for (int i = 1; i <= n; i++) {\\n cin >> s[i];\\n mp[s[i]]++;\\n }\\n for (int i = 1; i <= n; i++) {\\n for (int j = i + 1; j <= n; j++) {\\n string aim;\\n for (int k = 0; k < m; k++) {\\n if (s[i][k] == s[j][k])\\n aim += s[i][k];\\n else\\n aim += 'S' + 'E' + 'T' - s[i][k] - s[j][k];\\n }\\n if (s[i] == s[j])\\n ans += mp[aim] - 2;\\n else if (mp.count(aim))\\n ans += mp[aim];\\n }\\n }\\n ans \\/= 3;\\n cout << ans << endl;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alice and Bob begin their day with a quick game. They first choose a starting number X0 ≥ 3 and try to reach one million by the process described below. \\n\\nAlice goes first and then they take alternating turns. In the i-th turn, the player whose turn it is selects a prime number smaller than the current number, and announces the smallest multiple of this prime number that is not smaller than the current number.\\n\\nFormally, he or she selects a prime p < Xi - 1 and then finds the minimum Xi ≥ Xi - 1 such that p divides Xi. Note that if the selected prime p already divides Xi - 1, then the number does not change.\\n\\nEve has witnessed the state of the game after two turns. Given X2, help her determine what is the smallest possible starting number X0. Note that the players don't necessarily play optimally. You should consider all possible game evolutions.\\n\\nInput\\n\\nThe input contains a single integer X2 (4 ≤ X2 ≤ 106). It is guaranteed that the integer X2 is composite, that is, is not prime.\\n\\nOutput\\n\\nOutput a single integer — the minimum possible X0.\\n\\nExamples\\n\\nInput\\n\\n14\\n\\n\\nOutput\\n\\n6\\n\\n\\nInput\\n\\n20\\n\\n\\nOutput\\n\\n15\\n\\n\\nInput\\n\\n8192\\n\\n\\nOutput\\n\\n8191\\n\\nNote\\n\\nIn the first test, the smallest possible starting number is X0 = 6. One possible course of the game is as follows: \\n\\n * Alice picks prime 5 and announces X1 = 10\\n * Bob picks prime 7 and announces X2 = 14. \\n\\n\\n\\nIn the second case, let X0 = 15. \\n\\n * Alice picks prime 2 and announces X1 = 16\\n * Bob picks prime 5 and announces X2 = 20. \\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nconst int maxn = 1000006;\\nint prime[maxn];\\nvoid getprime() {\\n int n = 2;\\n while (n < maxn) {\\n int num = n * 2;\\n while (num < maxn) {\\n prime[num] = n;\\n num += n;\\n }\\n num = n + 1;\\n while (prime[num] != 0 && num < maxn) {\\n num++;\\n }\\n n = num;\\n }\\n}\\nint main() {\\n getprime();\\n int x0, x1, x2;\\n while (~scanf(\\\"%d\\\", &x2)) {\\n int a = 0, b = 0;\\n b = prime[x2];\\n x0 = 99999999;\\n for (int i = x2 - b + 1; i <= x2; i++) {\\n a = prime[i];\\n x0 = min(i - a + 1, x0);\\n }\\n printf(\\\"%d\\\\n\\\", x0);\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CQXYM is counting permutations length of 2n.\\n\\nA permutation is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice in the array) and [1,3,4] is also not a permutation (n=3 but there is 4 in the array).\\n\\nA permutation p(length of 2n) will be counted only if the number of i satisfying p_ip_2. Because 0\\n\\nAn example of such a bar can be seen on the picture.\\n\\n\\n\\nFor the given n, k, t determine the measures of saturation for all the squares ai of the progress bar.\\n\\nInput\\n\\nWe are given 3 space-separated integers n, k, t (1 ≤ n, k ≤ 100, 0 ≤ t ≤ 100).\\n\\nOutput\\n\\nPrint n numbers. The i-th of them should be equal to ai.\\n\\nExamples\\n\\nInput\\n\\n10 10 54\\n\\n\\nOutput\\n\\n10 10 10 10 10 4 0 0 0 0 \\n\\nInput\\n\\n11 13 37\\n\\n\\nOutput\\n\\n13 13 13 13 0 0 0 0 0 0 0 \\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst long long N = 2e5 + 7;\\nconst long long M = 1e9 + 7;\\nconst long long lmx = 92233720368547758;\\nint main() {\\n long long n, m, a, b, c, d, x, y, i, j, k;\\n long long t;\\n scanf(\\\"%lld%lld%lld\\\", &n, &x, &t);\\n k = (n * x * t) \\/ 100;\\n for (i = 1; i <= n && k > 0; i++) {\\n printf(\\\"%lld \\\", min(x, k));\\n k -= x;\\n }\\n for (; i <= n; i++) printf(\\\"0 \\\");\\n printf(\\\"\\\\n\\\");\\n printf(\\\"\\\\n\\\");\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nMonocarp is playing yet another computer game. In this game, his character has to kill a dragon. The battle with the dragon lasts 100^{500} seconds, during which Monocarp attacks the dragon with a poisoned dagger. The i-th attack is performed at the beginning of the a_i-th second from the battle start. The dagger itself does not deal damage, but it applies a poison effect on the dragon, which deals 1 damage during each of the next k seconds (starting with the same second when the dragon was stabbed by the dagger). However, if the dragon has already been poisoned, then the dagger updates the poison effect (i.e. cancels the current poison effect and applies a new one).\\n\\nFor example, suppose k = 4, and Monocarp stabs the dragon during the seconds 2, 4 and 10. Then the poison effect is applied at the start of the 2-nd second and deals 1 damage during the 2-nd and 3-rd seconds; then, at the beginning of the 4-th second, the poison effect is reapplied, so it deals exactly 1 damage during the seconds 4, 5, 6 and 7; then, during the 10-th second, the poison effect is applied again, and it deals 1 damage during the seconds 10, 11, 12 and 13. In total, the dragon receives 10 damage.\\n\\nMonocarp knows that the dragon has h hit points, and if he deals at least h damage to the dragon during the battle — he slays the dragon. Monocarp has not decided on the strength of the poison he will use during the battle, so he wants to find the minimum possible value of k (the number of seconds the poison effect lasts) that is enough to deal at least h damage to the dragon.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases.\\n\\nThe first line of the test case contains two integers n and h (1 ≤ n ≤ 100; 1 ≤ h ≤ 10^{18}) — the number of Monocarp's attacks and the amount of damage that needs to be dealt.\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9; a_i < a_{i + 1}), where a_i is the second when the i-th attack is performed.\\n\\nOutput\\n\\nFor each test case, print a single...\",\"targets\":\"import java.lang.*;\\nimport java.io.*;\\nimport java.util.*;\\npublic class Main{\\n public static void main(String args[]){\\n Scanner sc=new Scanner(System.in);\\n int t=sc.nextInt();\\n while(t-->0){\\n int n=sc.nextInt();\\n long h=sc.nextLong();\\n long a[]=new long[n];\\n for(int i = 0; i < n; i++)\\n a[i]=sc.nextLong();\\n long l = 1;\\n long r = h;\\n while(l <= r){\\n long mid = (l + r) \\/ 2;\\n long sum = mid;\\n for(int i = 1; i < n; i++){\\n sum += Math.min(a[i] - a[i - 1], mid);\\n }\\n if(sum >= h) r = mid - 1;\\n else l = mid + 1;\\n }\\n System.out.println(l);\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in PYTHON3?\\nIvan is playing yet another roguelike computer game. He controls a single hero in the game. The hero has n equipment slots. There is a list of c_i items for the i-th slot, the j-th of them increases the hero strength by a_{i,j}. The items for each slot are pairwise distinct and are listed in the increasing order of their strength increase. So, a_{i,1} < a_{i,2} < ... < a_{i,c_i}.\\n\\nFor each slot Ivan chooses exactly one item. Let the chosen item for the i-th slot be the b_i-th item in the corresponding list. The sequence of choices [b_1, b_2, ..., b_n] is called a build.\\n\\nThe strength of a build is the sum of the strength increases of the items in it. Some builds are banned from the game. There is a list of m pairwise distinct banned builds. It's guaranteed that there's at least one build that's not banned.\\n\\nWhat is the build with the maximum strength that is not banned from the game? If there are multiple builds with maximum strength, print any of them.\\n\\nInput\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 10) — the number of equipment slots.\\n\\nThe i-th of the next n lines contains the description of the items for the i-th slot. First, one integer c_i (1 ≤ c_i ≤ 2 ⋅ 10^5) — the number of items for the i-th slot. Then c_i integers a_{i,1}, a_{i,2}, ..., a_{i,c_i} (1 ≤ a_{i,1} < a_{i,2} < ... < a_{i,c_i} ≤ 10^8).\\n\\nThe sum of c_i doesn't exceed 2 ⋅ 10^5.\\n\\nThe next line contains a single integer m (0 ≤ m ≤ 10^5) — the number of banned builds.\\n\\nEach of the next m lines contains a description of a banned build — a sequence of n integers b_1, b_2, ..., b_n (1 ≤ b_i ≤ c_i).\\n\\nThe builds are pairwise distinct, and there's at least one build that's not banned.\\n\\nOutput\\n\\nPrint the build with the maximum strength that is not banned from the game. If there are multiple builds with maximum strength, print any of them.\\n\\nExamples\\n\\nInput\\n\\n\\n3\\n3 1 2 3\\n2 1 5\\n3 2 4 6\\n2\\n3 2 3\\n3 2 2\\n\\n\\nOutput\\n\\n\\n2 2 3 \\n\\n\\nInput\\n\\n\\n3\\n3 1 2 3\\n2 1 5\\n3 2 4 6\\n2\\n3 2 3\\n2 2 3\\n\\n\\nOutput\\n\\n\\n1 2 3\\n\\n\\nInput\\n\\n\\n3\\n3 1 2 3\\n2 1 5\\n3 2 4 6\\n2\\n3 2 3\\n2 2 3\\n\\n\\nOutput\\n\\n\\n3 2...\",\"targets\":\"import os\\nimport sys\\nfrom io import BytesIO, IOBase\\n \\n# region fastio\\n \\nBUFSIZE = 8192\\n \\n \\nclass FastIO(IOBase):\\n newlines = 0\\n \\n def __init__(self, file):\\n self._fd = file.fileno()\\n self.buffer = BytesIO()\\n self.writable = \\\"x\\\" in file.mode or \\\"r\\\" not in file.mode\\n self.write = self.buffer.write if self.writable else None\\n \\n def read(self):\\n while True:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n if not b:\\n break\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines = 0\\n return self.buffer.read()\\n \\n def readline(self):\\n while self.newlines == 0:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n self.newlines = b.count(b\\\"\\\\n\\\") + (not b)\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines -= 1\\n return self.buffer.readline()\\n \\n def flush(self):\\n if self.writable:\\n os.write(self._fd, self.buffer.getvalue())\\n self.buffer.truncate(0), self.buffer.seek(0)\\n \\n \\nclass IOWrapper(IOBase):\\n def __init__(self, file):\\n self.buffer = FastIO(file)\\n self.flush = self.buffer.flush\\n self.writable = self.buffer.writable\\n self.write = lambda s: self.buffer.write(s.encode(\\\"ascii\\\"))\\n self.read = lambda: self.buffer.read().decode(\\\"ascii\\\")\\n self.readline = lambda: self.buffer.readline().decode(\\\"ascii\\\")\\n \\n \\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\\ninput = lambda: sys.stdin.readline().rstrip(\\\"\\\\r\\\\n\\\")\\n\\nn = int(input())\\na = [None]*n\\nfor i in range(n):\\n a[i] = list(map(int,input().split()))\\n\\nm = int(input())\\nb = [None]*m\\nfor i in range(m):\\n b[i] = tuple(map(int,input().split()))\\n\\ns = set(b)\\nif tuple(a[i][0] for i in range(n)) not in s:\\n print(*tuple(a[i][0] for i in range(n)))\\n exit()\\n\\nmx = 0\\nans...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nYou are given a 1 by n pixel image. The i-th pixel of the image has color a_i. For each color, the number of pixels of that color is at most 20.\\n\\nYou can perform the following operation, which works like the bucket tool in paint programs, on this image: \\n\\n * pick a color — an integer from 1 to n; \\n * choose a pixel in the image; \\n * for all pixels connected to the selected pixel, change their colors to the selected color (two pixels of the same color are considered connected if all the pixels between them have the same color as those two pixels). \\n\\n\\n\\nCompute the minimum number of operations needed to make all the pixels in the image have the same color.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^3).\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 3⋅10^3) — the number of pixels in the image.\\n\\nThe second line of each test case contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ n) — the colors of the pixels in the image.\\n\\nNote: for each color, the number of pixels of that color is at most 20.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 3⋅10^3.\\n\\nOutput\\n\\nFor each test case, print one integer: the minimum number of operations needed to make all the pixels in the image have the same color.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n5\\n1 2 3 2 1\\n4\\n1 1 2 2\\n5\\n1 2 1 4 2\\n\\n\\nOutput\\n\\n\\n2\\n1\\n3\\n\\nNote\\n\\nIn the first example, the optimal solution is to apply the operation on the third pixel changing its color to 2 and then to apply the operation on any pixel that has color 2 changing its color and the color of all pixels connected to it to 1. The sequence of operations is then: [1, 2, 3, 2, 1] → [1, 2, 2, 2, 1] → [1, 1, 1, 1, 1].\\n\\nIn the second example, we can either change the 1s to 2s in one operation or change the 2s to 1s also in one operation.\\n\\nIn the third example, one possible way to make all the pixels have the same color is to apply the operation on the first, third and the fourth pixel each time changing its color to 2.\",\"targets\":\"#include \\nusing namespace std;\\nmt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());\\nlong long a[3005], dp[3005][3005], locc[3005], rocc[3005], go_l[3005],\\n go_r[3005];\\nvoid solve() {\\n long long n;\\n cin >> n;\\n for (long long i = 1; i <= n; i++) cin >> a[i];\\n for (long long i = 1; i <= n; i++) {\\n locc[i] = 0;\\n rocc[i] = n + 1;\\n }\\n for (long long i = 1; i <= n; i++) {\\n go_l[i] = locc[a[i]];\\n locc[a[i]] = i;\\n }\\n for (long long i = n; i >= 1; i--) {\\n go_r[i] = rocc[a[i]];\\n rocc[a[i]] = i;\\n }\\n for (long long d = 2; d <= n; d++) {\\n for (long long l = 1; l <= n - d + 1; l++) {\\n long long r = l + d - 1;\\n dp[l][r] = min(dp[l + 1][r], dp[l][r - 1]) + 1;\\n dp[l][r] = min(dp[l][r], dp[l + 1][r - 1] + (d > 2) + (a[l] != a[r]));\\n if (a[l] == a[r]) {\\n for (long long mid = go_r[l]; mid < r; mid = go_r[mid])\\n dp[l][r] = min(dp[l][r], dp[l][mid] + dp[mid + 1][r]);\\n } else {\\n for (long long mid = go_r[l]; mid < r; mid = go_r[mid])\\n dp[l][r] = min(dp[l][r], dp[l][mid] + dp[mid + 1][r] + 1);\\n for (long long mid = go_l[r]; mid > l; mid = go_l[mid])\\n dp[l][r] = min(dp[l][r], dp[l][mid - 1] + dp[mid][r] + 1);\\n }\\n }\\n }\\n cout << dp[1][n] << \\\"\\\\n\\\";\\n}\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n long long t;\\n cin >> t;\\n while (t--) solve();\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in PYTHON3?\\nAlice and Borys are playing tennis.\\n\\nA tennis match consists of games. In each game, one of the players is serving and the other one is receiving.\\n\\nPlayers serve in turns: after a game where Alice is serving follows a game where Borys is serving, and vice versa.\\n\\nEach game ends with a victory of one of the players. If a game is won by the serving player, it's said that this player holds serve. If a game is won by the receiving player, it's said that this player breaks serve.\\n\\nIt is known that Alice won a games and Borys won b games during the match. It is unknown who served first and who won which games.\\n\\nFind all values of k such that exactly k breaks could happen during the match between Alice and Borys in total.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^3). Description of the test cases follows.\\n\\nEach of the next t lines describes one test case and contains two integers a and b (0 ≤ a, b ≤ 10^5; a + b > 0) — the number of games won by Alice and Borys, respectively.\\n\\nIt is guaranteed that the sum of a + b over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case print two lines.\\n\\nIn the first line, print a single integer m (1 ≤ m ≤ a + b + 1) — the number of values of k such that exactly k breaks could happen during the match.\\n\\nIn the second line, print m distinct integers k_1, k_2, …, k_m (0 ≤ k_1 < k_2 < … < k_m ≤ a + b) — the sought values of k in increasing order.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n2 1\\n1 1\\n0 5\\n\\n\\nOutput\\n\\n\\n4\\n0 1 2 3\\n2\\n0 2\\n2\\n2 3\\n\\nNote\\n\\nIn the first test case, any number of breaks between 0 and 3 could happen during the match: \\n\\n * Alice holds serve, Borys holds serve, Alice holds serve: 0 breaks; \\n * Borys holds serve, Alice holds serve, Alice breaks serve: 1 break; \\n * Borys breaks serve, Alice breaks serve, Alice holds serve: 2 breaks; \\n * Alice breaks serve, Borys breaks serve, Alice breaks serve: 3 breaks. \\n\\n\\n\\nIn the second test case, the players could either both hold serves (0 breaks) or both break serves (2...\",\"targets\":\"for _ in range(int(input())):\\n x=list(map(int,input().split()))\\n b=max(x)\\n a=min(x)\\n start=(b-a)\\/\\/2\\n end=(a+b)-start\\n ans=[]\\n if (a+b)&1:\\n for i in range(start,end+1):\\n ans+=[i]\\n print(len(ans))\\n print(*ans)\\n else:\\n for i in range(start,end+1,2):\\n ans+=[i]\\n print(len(ans))\\n print(*ans)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in PYTHON?\\nYou are given a string s, consisting of n letters, each letter is either 'a' or 'b'. The letters in the string are numbered from 1 to n.\\n\\ns[l; r] is a continuous substring of letters from index l to r of the string inclusive. \\n\\nA string is called balanced if the number of letters 'a' in it is equal to the number of letters 'b'. For example, strings \\\"baba\\\" and \\\"aabbab\\\" are balanced and strings \\\"aaab\\\" and \\\"b\\\" are not.\\n\\nFind any non-empty balanced substring s[l; r] of string s. Print its l and r (1 ≤ l ≤ r ≤ n). If there is no such substring, then print -1 -1.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of testcases.\\n\\nThen the descriptions of t testcases follow.\\n\\nThe first line of the testcase contains a single integer n (1 ≤ n ≤ 50) — the length of the string.\\n\\nThe second line of the testcase contains a string s, consisting of n letters, each letter is either 'a' or 'b'.\\n\\nOutput\\n\\nFor each testcase print two integers. If there exists a non-empty balanced substring s[l; r], then print l r (1 ≤ l ≤ r ≤ n). Otherwise, print -1 -1.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n1\\na\\n6\\nabbaba\\n6\\nabbaba\\n9\\nbabbabbaa\\n\\n\\nOutput\\n\\n\\n-1 -1\\n1 6\\n3 6\\n2 5\\n\\nNote\\n\\nIn the first testcase there are no non-empty balanced subtrings.\\n\\nIn the second and third testcases there are multiple balanced substrings, including the entire string \\\"abbaba\\\" and substring \\\"baba\\\".\",\"targets\":\"from sys import stdin\\nraw_input = lambda: stdin.readline().rstrip()\\ninput = lambda: int(raw_input())\\nI=lambda: map(int, raw_input().split())\\nt = input()\\nfor _ in xrange(t):\\n\\tn = input()\\n\\ts = raw_input()\\n\\tr = -1\\n\\tfor i in xrange(n-1):\\n\\t\\tif s[i]!=s[i+1]:\\n\\t\\t\\tr = i\\n\\t\\t\\tbreak\\n\\tif r==-1:\\n\\t\\ta = -1\\n\\t\\tb = -1\\n\\telse:\\n\\t\\ta = i+1\\n\\t\\tb = i+2\\n\\tprint a, b\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Consider a sequence of distinct integers a_1, …, a_n, each representing one node of a graph. There is an edge between two nodes if the two values are not coprime, i. e. they have a common divisor greater than 1.\\n\\nThere are q queries, in each query, you want to get from one given node a_s to another a_t. In order to achieve that, you can choose an existing value a_i and create new value a_{n+1} = a_i ⋅ (1 + a_i), with edges to all values that are not coprime with a_{n+1}. Also, n gets increased by 1. You can repeat that operation multiple times, possibly making the sequence much longer and getting huge or repeated values. What's the minimum possible number of newly created nodes so that a_t is reachable from a_s?\\n\\nQueries are independent. In each query, you start with the initial sequence a given in the input.\\n\\nInput\\n\\nThe first line contains two integers n and q (2 ≤ n ≤ 150 000, 1 ≤ q ≤ 300 000) — the size of the sequence and the number of queries.\\n\\nThe second line contains n distinct integers a_1, a_2, …, a_n (2 ≤ a_i ≤ 10^6, a_i ≠ a_j if i ≠ j).\\n\\nThe j-th of the following q lines contains two distinct integers s_j and t_j (1 ≤ s_j, t_j ≤ n, s_j ≠ t_j) — indices of nodes for j-th query.\\n\\nOutput\\n\\nPrint q lines. The j-th line should contain one integer: the minimum number of new nodes you create in order to move from a_{s_j} to a_{t_j}.\\n\\nExamples\\n\\nInput\\n\\n\\n3 3\\n2 10 3\\n1 2\\n1 3\\n2 3\\n\\n\\nOutput\\n\\n\\n0\\n1\\n1\\n\\n\\nInput\\n\\n\\n5 12\\n3 8 7 6 25\\n1 2\\n1 3\\n1 4\\n1 5\\n2 1\\n2 3\\n2 4\\n2 5\\n3 1\\n3 2\\n3 4\\n3 5\\n\\n\\nOutput\\n\\n\\n0\\n1\\n0\\n1\\n0\\n1\\n0\\n1\\n1\\n1\\n1\\n2\\n\\nNote\\n\\nIn the first example, you can first create new value 2 ⋅ 3 = 6 or 10 ⋅ 11 = 110 or 3 ⋅ 4 = 12. None of that is needed in the first query because you can already get from a_1 = 2 to a_2 = 10.\\n\\nIn the second query, it's optimal to first create 6 or 12. For example, creating 6 makes it possible to get from a_1 = 2 to a_3 = 3 with a path (2, 6, 3).\\n\\n\\n\\nIn the last query of the second example, we want to get from a_3 = 7 to a_5 = 25. One way to achieve that is to first create 6 ⋅ 7 = 42 and then create 25...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = (int)1e6 + 10;\\nint n, q, a[N], p[N + N], lp[N];\\nint get(int v) {\\n if (p[v] == v) return v;\\n return p[v] = get(p[v]);\\n}\\nvoid unite(int u, int v) {\\n u = get(u), v = get(v);\\n if (u == v) return;\\n if (rand() & 1) swap(u, v);\\n p[u] = v;\\n}\\nbool was[N];\\nunordered_map used[N + N];\\nint main() {\\n scanf(\\\"%d%d\\\", &n, &q);\\n for (int i = 0; i < N + N; i++) p[i] = i;\\n for (int i = 1; i <= n; i++) {\\n scanf(\\\"%d\\\", &a[i]);\\n was[a[i]] = 1;\\n }\\n for (int pr = 2; pr < N; pr++) {\\n if (lp[pr]) continue;\\n for (int i = pr; i < N; i += pr) {\\n if (!lp[i]) lp[i] = pr;\\n if (was[i]) {\\n unite(i, N + pr);\\n }\\n }\\n }\\n for (int i = 1; i <= n; i++) {\\n vector v;\\n int x = a[i];\\n while (x > 1) {\\n int p = lp[x];\\n v.push_back(N + p);\\n while (x % p == 0) x \\/= p;\\n }\\n x = a[i] + 1;\\n while (x > 1) {\\n int p = lp[x];\\n v.push_back(N + p);\\n while (x % p == 0) x \\/= p;\\n }\\n for (auto x : v)\\n for (auto y : v) {\\n used[get(x)][get(y)] = used[get(y)][get(x)] = 1;\\n }\\n }\\n while (q--) {\\n int s, t;\\n scanf(\\\"%d%d\\\", &s, &t);\\n if (get(a[s]) == get(a[t])) {\\n puts(\\\"0\\\");\\n continue;\\n }\\n vector v1, v2;\\n int x = a[s];\\n while (x > 1) {\\n int p = lp[x];\\n v1.push_back(N + p);\\n while (x % p == 0) x \\/= p;\\n }\\n x = a[t];\\n while (x > 1) {\\n int p = lp[x];\\n v2.push_back(N + p);\\n while (x % p == 0) x \\/= p;\\n }\\n bool found = 0;\\n for (auto x : v1) {\\n for (auto y : v2) {\\n if (used[get(x)][get(y)]) {\\n found = 1;\\n break;\\n }\\n }\\n }\\n if (found)\\n puts(\\\"1\\\");\\n else\\n puts(\\\"2\\\");\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A country has a budget of more than 81 trillion yen. We want to process such data, but conventional integer type which uses signed 32 bit can represent up to 2,147,483,647.\\n\\nYour task is to write a program which reads two integers (more than or equal to zero), and prints a sum of these integers.\\n\\nIf given integers or the sum have more than 80 digits, print \\\"overflow\\\".\\n\\n\\n\\nInput\\n\\nInput consists of several datasets. In the first line, the number of datasets N (1 ≤ N ≤ 50) is given. Each dataset consists of 2 lines:\\n\\n\\nThe first integer\\nThe second integer\\n\\n\\nThe integer has at most 100 digits.\\n\\nOutput\\n\\nFor each dataset, print the sum of given integers in a line.\\n\\nExample\\n\\nInput\\n\\n6\\n1000\\n800\\n9999999999999999999999999999999999999999\\n1\\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\\n1\\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\\n0\\n100000000000000000000000000000000000000000000000000000000000000000000000000000000\\n1\\n100000000000000000000000000000000000000000000000000000000000000000000000000000000\\n100000000000000000000000000000000000000000000000000000000000000000000000000000000\\n\\n\\nOutput\\n\\n1800\\n10000000000000000000000000000000000000000\\noverflow\\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\\noverflow\\noverflow\",\"targets\":\"import sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\n\\nfor i in range(n):\\n n1 = int(sys.stdin.readline())\\n n2 = int(sys.stdin.readline())\\n if n1+n2<100000000000000000000000000000000000000000000000000000000000000000000000000000000 :\\n print(n1+n2)\\n else:\\n print(\\\"overflow\\\")\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Given n, find any array a_1, a_2, …, a_n of integers such that all of the following conditions hold: \\n\\n * 1 ≤ a_i ≤ 10^9 for every i from 1 to n.\\n\\n * a_1 < a_2 < … \\nusing namespace std;\\nvoid print(bool n) {\\n if (n)\\n cout << \\\"YES\\\";\\n else\\n cout << \\\"NO\\\";\\n cout << '\\\\n';\\n}\\nsigned main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n long long ttt;\\n cin >> ttt;\\n for (long long T = 1; T <= ttt; T++) {\\n long long n;\\n cin >> n;\\n long long x = 2;\\n while (n--) cout << x++ << ' ';\\n cout << '\\\\n';\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alice guesses the strings that Bob made for her.\\n\\nAt first, Bob came up with the secret string a consisting of lowercase English letters. The string a has a length of 2 or more characters. Then, from string a he builds a new string b and offers Alice the string b so that she can guess the string a.\\n\\nBob builds b from a as follows: he writes all the substrings of length 2 of the string a in the order from left to right, and then joins them in the same order into the string b.\\n\\nFor example, if Bob came up with the string a=\\\"abac\\\", then all the substrings of length 2 of the string a are: \\\"ab\\\", \\\"ba\\\", \\\"ac\\\". Therefore, the string b=\\\"abbaac\\\".\\n\\nYou are given the string b. Help Alice to guess the string a that Bob came up with. It is guaranteed that b was built according to the algorithm given above. It can be proved that the answer to the problem is unique.\\n\\nInput\\n\\nThe first line contains a single positive integer t (1 ≤ t ≤ 1000) — the number of test cases in the test. Then t test cases follow.\\n\\nEach test case consists of one line in which the string b is written, consisting of lowercase English letters (2 ≤ |b| ≤ 100) — the string Bob came up with, where |b| is the length of the string b. It is guaranteed that b was built according to the algorithm given above.\\n\\nOutput\\n\\nOutput t answers to test cases. Each answer is the secret string a, consisting of lowercase English letters, that Bob came up with.\\n\\nExample\\n\\nInput\\n\\n\\n4\\nabbaac\\nac\\nbccddaaf\\nzzzzzzzzzz\\n\\n\\nOutput\\n\\n\\nabac\\nac\\nbcdaf\\nzzzzzz\\n\\nNote\\n\\nThe first test case is explained in the statement.\\n\\nIn the second test case, Bob came up with the string a=\\\"ac\\\", the string a has a length 2, so the string b is equal to the string a.\\n\\nIn the third test case, Bob came up with the string a=\\\"bcdaf\\\", substrings of length 2 of string a are: \\\"bc\\\", \\\"cd\\\", \\\"da\\\", \\\"af\\\", so the string b=\\\"bccddaaf\\\".\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"t=int(input())\\nfor i in range(t):\\n\\ts=input()\\n\\tp=len(s)\\n\\tans=\\\"\\\"\\n\\tfor j in range(p):\\n\\t\\tif (j%2==0)or (j==p-1):\\n\\t\\t\\tans+=s[j]\\n\\n\\tprint (ans)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"On the board, Bob wrote n positive integers in [base](https:\\/\\/en.wikipedia.org\\/wiki\\/Positional_notation#Base_of_the_numeral_system) 10 with sum s (i. e. in decimal numeral system). Alice sees the board, but accidentally interprets the numbers on the board as base-11 integers and adds them up (in base 11).\\n\\nWhat numbers should Bob write on the board, so Alice's sum is as large as possible?\\n\\nInput\\n\\nThe input consists of multiple test cases. The first line contains an integer t (1 ≤ t ≤ 100) — the number of test cases. The description of the test cases follows.\\n\\nThe only line of each test case contains two integers s and n (1 ≤ s ≤ 10^9; 1 ≤ n ≤ min(100, s)) — the sum and amount of numbers on the board, respectively. Numbers s and n are given in decimal notation (base 10).\\n\\nOutput\\n\\nFor each test case, output n positive integers — the numbers Bob should write on the board, so Alice's sum is as large as possible. If there are multiple answers, print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n97 2\\n17 1\\n111 4\\n100 2\\n10 9\\n999999 3\\n\\n\\nOutput\\n\\n\\n70 27 \\n17 \\n3 4 100 4\\n10 90\\n1 1 2 1 1 1 1 1 1 \\n999900 90 9\\n\\nNote\\n\\nIn the first test case, 70_{10} + 27_{10} = 97_{10}, and Alice's sum is $$$70_{11} + 27_{11} = 97_{11} = 9 ⋅ 11 + 7 = 106_{10}. (Here x_b represents the number x in base b.) It can be shown that it is impossible for Alice to get a larger sum than 106_{10}$$$.\\n\\nIn the second test case, Bob can only write a single number on the board, so he must write 17.\\n\\nIn the third test case, 3_{10} + 4_{10} + 100_{10} + 4_{10} = 111_{10}, and Alice's sum is $$$3_{11} + 4_{11} + 100_{11} + 4_{11} = 110_{11} = 1 ⋅ 11^2 + 1 ⋅ 11 = 132_{10}. It can be shown that it is impossible for Alice to get a larger sum than 132_{10}$$$.\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint T, num[100], n, len, a, ans, now, len2, aa, nn;\\nint main() {\\n scanf(\\\"%d\\\", &T);\\n while (T--) {\\n scanf(\\\"%d%d\\\", &a, &n);\\n aa = a;\\n len = ans = 0;\\n while (a) {\\n num[++len] = a % 10;\\n ans += num[len];\\n a \\/= 10;\\n }\\n now = 1;\\n nn = n;\\n if (ans < n) {\\n for (int i = 2; i <= len && ans < nn;) {\\n while (i == 1 || num[i] == 0) i++;\\n num[i - 1] += 10;\\n num[i]--;\\n i--;\\n nn -= 9;\\n }\\n }\\n ans = 0;\\n while (num[len] == 0) len--;\\n for (int i = 1; i < len; i++) now *= 10;\\n len2 = len;\\n for (int i = 1; i <= n - 1; i++) {\\n while (num[len2] == 0) len2--, now \\/= 10;\\n printf(\\\"%d \\\", now);\\n num[len2]--;\\n ans += now;\\n }\\n printf(\\\"%d\\\\n\\\", aa - ans);\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A bracket sequence is a string containing only characters \\\"(\\\" and \\\")\\\". A regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters \\\"1\\\" and \\\"+\\\" between the original characters of the sequence. For example, bracket sequences \\\"()()\\\" and \\\"(())\\\" are regular (the resulting expressions are: \\\"(1)+(1)\\\" and \\\"((1+1)+1)\\\"), and \\\")(\\\", \\\"(\\\" and \\\")\\\" are not.\\n\\nYou are given an integer n. Your goal is to construct and print exactly n different regular bracket sequences of length 2n.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 50) — the number of test cases.\\n\\nEach test case consists of one line containing one integer n (1 ≤ n ≤ 50).\\n\\nOutput\\n\\nFor each test case, print n lines, each containing a regular bracket sequence of length exactly 2n. All bracket sequences you output for a testcase should be different (though they may repeat in different test cases). If there are multiple answers, print any of them. It can be shown that it's always possible.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n3\\n1\\n3\\n\\n\\nOutput\\n\\n\\n()()()\\n((()))\\n(()())\\n()\\n((()))\\n(())()\\n()(())\",\"targets\":\"#include \\nusing namespace std;\\nint n;\\nint cnt = 0;\\nvoid rec(vector mask, int i, int ops) {\\n if (cnt == n) return;\\n if (i == n) {\\n for (int j = 0; j < n; j++) cout << char('(' + mask[j]);\\n for (int j = 0; j < n; j++) {\\n if (ops > 0) {\\n cout << ')';\\n ops--;\\n } else {\\n cout << '(';\\n ops++;\\n }\\n }\\n cout << endl;\\n cnt++;\\n } else {\\n mask[i] = 0;\\n rec(mask, i + 1, ops + 1);\\n if (ops > 0) {\\n mask[i] = 1;\\n rec(mask, i + 1, ops - 1);\\n }\\n }\\n}\\nint main() {\\n ios::sync_with_stdio(false);\\n cin.tie(0);\\n int T;\\n cin >> T;\\n while (T--) {\\n cin >> n;\\n cnt = 0;\\n vector t(n, 0);\\n rec(t, 0, 0);\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nThis is a simplified version of the problem B2. Perhaps you should read the problem B2 before you start solving B1.\\n\\nPaul and Mary have a favorite string s which consists of lowercase letters of the Latin alphabet. They want to paint it using pieces of chalk of two colors: red and green. Let's call a coloring of a string wonderful if the following conditions are met:\\n\\n 1. each letter of the string is either painted in exactly one color (red or green) or isn't painted; \\n 2. each two letters which are painted in the same color are different; \\n 3. the number of letters painted in red is equal to the number of letters painted in green; \\n 4. the number of painted letters of this coloring is maximum among all colorings of the string which meet the first three conditions. \\n\\n\\n\\nE. g. consider a string s equal to \\\"kzaaa\\\". One of the wonderful colorings of the string is shown in the figure.\\n\\n The example of a wonderful coloring of the string \\\"kzaaa\\\".\\n\\nPaul and Mary want to learn by themselves how to find a wonderful coloring of the string. But they are very young, so they need a hint. Help them find k — the number of red (or green, these numbers are equal) letters in a wonderful coloring.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 1000) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one non-empty string s which consists of lowercase letters of the Latin alphabet. The number of characters in the string doesn't exceed 50.\\n\\nOutput\\n\\nFor each test case, output a separate line containing one non-negative integer k — the number of letters which will be painted in red in a wonderful coloring.\\n\\nExample\\n\\nInput\\n\\n\\n5\\nkzaaa\\ncodeforces\\narchive\\ny\\nxxxxxx\\n\\n\\nOutput\\n\\n\\n2\\n5\\n3\\n0\\n1\\n\\nNote\\n\\nThe first test case contains the string from the statement. One of the wonderful colorings is shown in the figure. There's no wonderful coloring containing 3 or more red letters because the total number of painted symbols will exceed the string's length.\\n\\nThe string from the second test case can be...\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\n\\npublic class p2 {\\n public static void main(String[] args) {\\n Scanner sc = new Scanner(System.in);\\n int t = sc.nextInt();\\n while (t-- > 0) {\\n String s = sc.next();\\n int n = s.length();\\n int k = 0, m = 0, sum = 0;\\n int c[] = new int[26];\\n for (int i = 0; i < n; i++) {\\n c[(s.charAt(i)) - 'a']++;\\n }\\n for (int i = 0; i < 26; i++) {\\n if (c[i] == 1)\\n k++;\\n if (c[i] > 1)\\n m++;\\n }\\n sum = k \\/ 2 + m;\\n System.out.println(sum);\\n }\\n\\n }\\n\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"An English booklet has been created for publicizing Aizu to the world. When you read it carefully, you found a misnomer (an error in writing) on the last name of Masayuki Hoshina, the lord of the Aizu domain. The booklet says \\\"Hoshino\\\" not \\\"Hoshina\\\".\\n\\nYour task is to write a program which replace all the words \\\"Hoshino\\\" with \\\"Hoshina\\\". You can assume that the number of characters in a text is less than or equal to 1000.\\n\\n\\n\\nInput\\n\\nThe input consists of several datasets. There will be the number of datasets n in the first line. There will be n lines. A line consisting of english texts will be given for each dataset.\\n\\nOutput\\n\\nFor each dataset, print the converted texts in a line.\\n\\nExample\\n\\nInput\\n\\n3\\nHoshino\\nHashino\\nMasayuki Hoshino was the grandson of Ieyasu Tokugawa.\\n\\n\\nOutput\\n\\nHoshina\\nHashino\\nMasayuki Hoshina was the grandson of Ieyasu Tokugawa.\\n# cod\",\"targets\":\"ing:utf-8\\n\\ninputCount = int(input())\\n\\nwhile 0 < inputCount:\\n\\n content = input().replace(\\\"Hoshino\\\", \\\"Hoshina\\\")\\n print(content)\\n\\n inputCount -= 1\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"There is a city park represented as a tree with n attractions as its vertices and n - 1 rails as its edges. The i-th attraction has happiness value a_i.\\n\\nEach rail has a color. It is either black if t_i = 0, or white if t_i = 1. Black trains only operate on a black rail track, and white trains only operate on a white rail track. If you are previously on a black train and want to ride a white train, or you are previously on a white train and want to ride a black train, you need to use 1 ticket.\\n\\nThe path of a tour must be a simple path — it must not visit an attraction more than once. You do not need a ticket the first time you board a train. You only have k tickets, meaning you can only switch train types at most k times. In particular, you do not need a ticket to go through a path consisting of one rail color.\\n\\nDefine f(u, v) as the sum of happiness values of the attractions in the tour (u, v), which is a simple path that starts at the u-th attraction and ends at the v-th attraction. Find the sum of f(u,v) for all valid tours (u, v) (1 ≤ u ≤ v ≤ n) that does not need more than k tickets, modulo 10^9 + 7.\\n\\nInput\\n\\nThe first line contains two integers n and k (2 ≤ n ≤ 2 ⋅ 10^5, 0 ≤ k ≤ n-1) — the number of attractions in the city park and the number of tickets you have.\\n\\nThe second line contains n integers a_1, a_2,…, a_n (0 ≤ a_i ≤ 10^9) — the happiness value of each attraction.\\n\\nThe i-th of the next n - 1 lines contains three integers u_i, v_i, and t_i (1 ≤ u_i, v_i ≤ n, 0 ≤ t_i ≤ 1) — an edge between vertices u_i and v_i with color t_i. The given edges form a tree.\\n\\nOutput\\n\\nOutput an integer denoting the total happiness value for all valid tours (u, v) (1 ≤ u ≤ v ≤ n), modulo 10^9 + 7.\\n\\nExamples\\n\\nInput\\n\\n\\n5 0\\n1 3 2 6 4\\n1 2 1\\n1 4 0\\n3 2 1\\n2 5 0\\n\\n\\nOutput\\n\\n\\n45\\n\\n\\nInput\\n\\n\\n3 1\\n1 1 1\\n1 2 1\\n3 2 0\\n\\n\\nOutput\\n\\n\\n10\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 2e5 + 5, mod = 1e9 + 7;\\nvector> g[N];\\nint a[N], sz[N], big[N], die[N];\\nvoid get_sz(int v, int par = -1) {\\n sz[v] = 1;\\n big[v] = -1;\\n for (auto& e : g[v]) {\\n int u = e.first;\\n if (u == par || die[u]) continue;\\n get_sz(u, v);\\n if (big[v] == -1 || sz[u] > sz[big[v]]) big[v] = u;\\n sz[v] += sz[u];\\n }\\n}\\nvoid add(long long& var, long long val) {\\n var += val;\\n if (var >= mod)\\n var -= mod;\\n else if (var < 0)\\n var += mod;\\n}\\nlong long ans = 0;\\nstruct Fenwick {\\n long long sum[N];\\n Fenwick() { memset(sum, 0, sizeof sum); }\\n long long get(int x) {\\n long long ret = 0;\\n for (++x; x; x -= x & -x) add(ret, sum[x]);\\n return ret;\\n }\\n void update(int x, int v) {\\n for (++x; x < N; x += x & -x) add(sum[x], v);\\n }\\n};\\nFenwick sum[2];\\nFenwick cnt[2];\\nint mul = 1;\\nvoid dfs(int v, int par, long long cost, int change, int col) {\\n int last = col ^ (change & 1);\\n add(cost, a[v]);\\n sum[col].update(change, mul * cost);\\n cnt[col].update(change, mul);\\n for (auto& e : g[v]) {\\n int u = e.first;\\n if (u == par || die[u]) continue;\\n dfs(u, v, cost, change + (last != e.second), col);\\n }\\n}\\nint n, k;\\nvoid dfs2(int v, int par, long long cost, int change, int col) {\\n if (change > k) return;\\n int last = col ^ (change & 1);\\n add(cost, a[v]);\\n ans = (ans + 1LL * cnt[col].get(k - change) * cost +\\n 1LL * sum[col].get(k - change));\\n if (change + 1 <= k)\\n ans = (ans + 1LL * cnt[col ^ 1].get(k - change - 1) * cost +\\n 1LL * sum[col ^ 1].get(k - change - 1));\\n for (auto& e : g[v]) {\\n int u = e.first;\\n if (u == par || die[u]) continue;\\n dfs2(u, v, cost, change + (last != e.second), col);\\n }\\n}\\nvoid centroid(int v) {\\n get_sz(v);\\n int tot = sz[v];\\n while (big[v] != -1 && sz[big[v]] * 2 >= tot) v = big[v];\\n for (auto& e : g[v]) {\\n int u = e.first;\\n if (die[u]) continue;\\n dfs2(u, v, 0, 0, e.second);\\n mul = 1;\\n dfs(u, v, a[v], 0, e.second);\\n }\\n ans = (ans + a[v]) % mod;\\n for...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the corner: Gogol is ready to release it's new tablet Lastus 3000.\\n\\nThis new device is equipped with specially designed artificial intelligence (AI). Employees of Pineapple did their best to postpone the release of Lastus 3000 as long as possible. Finally, they found out, that the name of the new artificial intelligence is similar to the name of the phone, that Pineapple released 200 years ago. As all rights on its name belong to Pineapple, they stand on changing the name of Gogol's artificial intelligence.\\n\\nPineapple insists, that the name of their phone occurs in the name of AI as a substring. Because the name of technology was already printed on all devices, the Gogol's director decided to replace some characters in AI name with \\\"#\\\". As this operation is pretty expensive, you should find the minimum number of characters to replace with \\\"#\\\", such that the name of AI doesn't contain the name of the phone as a substring.\\n\\nSubstring is a continuous subsequence of a string.\\n\\nInput\\n\\nThe first line of the input contains the name of AI designed by Gogol, its length doesn't exceed 100 000 characters. Second line contains the name of the phone released by Pineapple 200 years ago, its length doesn't exceed 30. Both string are non-empty and consist of only small English letters.\\n\\nOutput\\n\\nPrint the minimum number of characters that must be replaced with \\\"#\\\" in order to obtain that the name of the phone doesn't occur in the name of AI as a substring.\\n\\nExamples\\n\\nInput\\n\\nintellect\\ntell\\n\\n\\nOutput\\n\\n1\\n\\nInput\\n\\ngoogle\\napple\\n\\n\\nOutput\\n\\n0\\n\\nInput\\n\\nsirisiri\\nsir\\n\\n\\nOutput\\n\\n2\\n\\nNote\\n\\nIn the first sample AI's name may be replaced with \\\"int#llect\\\".\\n\\nIn the second sample Gogol can just keep things as they are.\\n\\nIn the third sample one of the new possible names of AI may be \\\"s#ris#ri\\\".\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"g=input()\\np=input()\\ni=0\\nc=0\\nwhile i<=len(g)-len(p):\\n if g[i:i+len(p)]==p:\\n c+=1\\n i+=len(p)\\n else: \\n i+=1\\nprint(c)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A chess tournament will be held soon, where n chess players will take part. Every participant will play one game against every other participant. Each game ends in either a win for one player and a loss for another player, or a draw for both players.\\n\\nEach of the players has their own expectations about the tournament, they can be one of two types:\\n\\n 1. a player wants not to lose any game (i. e. finish the tournament with zero losses); \\n 2. a player wants to win at least one game. \\n\\n\\n\\nYou have to determine if there exists an outcome for all the matches such that all the players meet their expectations. If there are several possible outcomes, print any of them. If there are none, report that it's impossible.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 200) — the number of test cases.\\n\\nThe first line of each test case contains one integer n (2 ≤ n ≤ 50) — the number of chess players.\\n\\nThe second line contains the string s (|s| = n; s_i ∈ \\\\{1, 2\\\\}). If s_i = 1, then the i-th player has expectations of the first type, otherwise of the second type.\\n\\nOutput\\n\\nFor each test case, print the answer in the following format:\\n\\nIn the first line, print NO if it is impossible to meet the expectations of all players.\\n\\nOtherwise, print YES, and the matrix of size n × n in the next n lines.\\n\\nThe matrix element in the i-th row and j-th column should be equal to:\\n\\n * +, if the i-th player won in a game against the j-th player; \\n * -, if the i-th player lost in a game against the j-th player; \\n * =, if the i-th and j-th players' game resulted in a draw; \\n * X, if i = j. \\n\\nExample\\n\\nInput\\n\\n\\n3\\n3\\n111\\n2\\n21\\n4\\n2122\\n\\n\\nOutput\\n\\n\\nYES\\nX==\\n=X=\\n==X\\nNO\\nYES\\nX--+\\n+X++\\n+-X-\\n--+X\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"\\/\\/import java.io.IOException;\\n\\nimport java.io.IOException;\\nimport java.io.InputStream;\\nimport java.io.PrintWriter;\\nimport java.util.Arrays;\\nimport java.util.InputMismatchException;\\n\\npublic class chesstournament {\\n static InputReader inputReader=new InputReader(System.in);\\n static void solve()\\n {\\n int n=inputReader.nextInt();\\n String str=inputReader.readString();\\n char arr[][]=new char[n][n];\\n for (char ele[]:arr)\\n {\\n Arrays.fill(ele,'#');\\n }\\n for (int i=0;i\\n\\nBarney asked the bar tender Carl about this distance value, but Carl was so busy talking to the customers so he wrote the distance value (it's a real number) on a napkin. The problem is that he wrote it in scientific notation. The scientific notation of some real number x is the notation of form AeB, where A is a real number and B is an integer and x = A × 10B is true. In our case A is between 0 and 9 and B is non-negative.\\n\\nBarney doesn't know anything about scientific notation (as well as anything scientific at all). So he asked you to tell him the distance value in usual decimal representation with minimal number of digits after the decimal point (and no decimal point if it is an integer). See the output format for better understanding.\\n\\nInput\\n\\nThe first and only line of input contains a single string of form a.deb where a, d and b are integers and e is usual character 'e' (0 ≤ a ≤ 9, 0 ≤ d < 10100, 0 ≤ b ≤ 100) — the scientific notation of the desired distance value.\\n\\na and b contain no leading zeros and d contains no trailing zeros (but may be equal to 0). Also, b can not be non-zero if a is zero.\\n\\nOutput\\n\\nPrint the only real number x (the desired distance value) in the only line in its decimal notation. \\n\\nThus if x is an integer, print it's integer value without decimal part and decimal point and without leading zeroes. \\n\\nOtherwise print x in a form of p.q such that p is an integer that have no leading zeroes (but may be equal to zero), and q is an integer that have no trailing zeroes (and may not be equal to zero).\\n\\nExamples\\n\\nInput\\n\\n8.549e2\\n\\n\\nOutput\\n\\n854.9\\n\\n\\nInput\\n\\n8.549e3\\n\\n\\nOutput\\n\\n8549\\n\\n\\nInput\\n\\n0.33e0\\n\\n\\nOutput\\n\\n0.33\\nSolve the task in PYTHON3.\",\"targets\":\"from decimal import *\\nimport math\\n\\nx = input()\\nx = Decimal(x)\\ny = int(x)\\nif x == y:\\n x = int(x)\\n\\nprint(x)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A robot cleaner is placed on the floor of a rectangle room, surrounded by walls. The floor consists of n rows and m columns. The rows of the floor are numbered from 1 to n from top to bottom, and columns of the floor are numbered from 1 to m from left to right. The cell on the intersection of the r-th row and the c-th column is denoted as (r,c). The initial position of the robot is (r_b, c_b).\\n\\nIn one second, the robot moves by dr rows and dc columns, that is, after one second, the robot moves from the cell (r, c) to (r + dr, c + dc). Initially dr = 1, dc = 1. If there is a vertical wall (the left or the right walls) in the movement direction, dc is reflected before the movement, so the new value of dc is -dc. And if there is a horizontal wall (the upper or lower walls), dr is reflected before the movement, so the new value of dr is -dr.\\n\\nEach second (including the moment before the robot starts moving), the robot cleans every cell lying in the same row or the same column as its position. There is only one dirty cell at (r_d, c_d). The job of the robot is to clean that dirty cell.\\n\\n Illustration for the first example. The blue arc is the robot. The red star is the target dirty cell. Each second the robot cleans a row and a column, denoted by yellow stripes.\\n\\nGiven the floor size n and m, the robot's initial position (r_b, c_b) and the dirty cell's position (r_d, c_d), find the time for the robot to do its job.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^4). Description of the test cases follows.\\n\\nA test case consists of only one line, containing six integers n, m, r_b, c_b, r_d, and c_d (1 ≤ n, m ≤ 100, 1 ≤ r_b, r_d ≤ n, 1 ≤ c_b, c_d ≤ m) — the sizes of the room, the initial position of the robot and the position of the dirt cell.\\n\\nOutput\\n\\nFor each test case, print an integer — the time for the robot to clean the dirty cell. We can show that the robot always cleans the dirty cell eventually.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n10 10 6 1 2 8\\n10 10 9 9 1...\\nUsing java can you solve the prior task?\",\"targets\":\"import java.io.*;\\nimport java.lang.*;\\nimport java.util.*;\\n\\n\\npublic class A {\\n private static void solve() throws IOException {\\n \\/\\/Solve here\\n int n=sc.nextInt();\\n int m=sc.nextInt();\\n int rb=sc.nextInt();\\n int cb=sc.nextInt();\\n int rd=sc.nextInt();\\n int cd=sc.nextInt();\\n int res=Integer.MAX_VALUE;\\n if (rd==rb || cd==cb) ans.append(0+\\\"\\\\n\\\");\\n else {\\n if (rd > rb) res = Math.min(rd - rb, res);\\n else res = Math.min(n - rb + n - rd, res);\\n if (cd > cb) res = Math.min(res, cd - cb);\\n else res = Math.min(m - cb + m - cd, res);\\n ans.append(res+\\\"\\\\n\\\");\\n }\\n\\n }\\n\\n public static void main(String[] args) throws IOException {\\n int t = sc.nextInt();\\n while (t-- > 0) {\\n solve();\\n }\\n System.out.println(ans);\\n }\\n\\n static final FastReader sc = new FastReader();\\n static StringBuilder ans = new StringBuilder();\\n static boolean[] prime;\\n static final Random random = new Random();\\n static int M = 1_000_000_007;\\n\\n static void sort(int[] arr)\\n {\\n int n = arr.length;\\n for(int i=0; i 0) {\\n if (array[index - 1]...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"As you might remember from the previous round, Vova is currently playing a strategic game known as Rage of Empires.\\n\\nVova managed to build a large army, but forgot about the main person in the army - the commander. So he tries to hire a commander, and he wants to choose the person who will be respected by warriors.\\n\\nEach warrior is represented by his personality — an integer number pi. Each commander has two characteristics — his personality pj and leadership lj (both are integer numbers). Warrior i respects commander j only if ( is the bitwise excluding OR of x and y).\\n\\nInitially Vova's army is empty. There are three different types of events that can happen with the army:\\n\\n * 1 pi — one warrior with personality pi joins Vova's army; \\n * 2 pi — one warrior with personality pi leaves Vova's army; \\n * 3 pi li — Vova tries to hire a commander with personality pi and leadership li. \\n\\n\\n\\nFor each event of the third type Vova wants to know how many warriors (counting only those who joined the army and haven't left yet) respect the commander he tries to hire.\\n\\nInput\\n\\nThe first line contains one integer q (1 ≤ q ≤ 100000) — the number of events.\\n\\nThen q lines follow. Each line describes the event:\\n\\n * 1 pi (1 ≤ pi ≤ 108) — one warrior with personality pi joins Vova's army; \\n * 2 pi (1 ≤ pi ≤ 108) — one warrior with personality pi leaves Vova's army (it is guaranteed that there is at least one such warrior in Vova's army by this moment); \\n * 3 pi li (1 ≤ pi, li ≤ 108) — Vova tries to hire a commander with personality pi and leadership li. There is at least one event of this type. \\n\\nOutput\\n\\nFor each event of the third type print one integer — the number of warriors who respect the commander Vova tries to hire in the event.\\n\\nExample\\n\\nInput\\n\\n5\\n1 3\\n1 4\\n3 6 3\\n2 4\\n3 6 3\\n\\n\\nOutput\\n\\n1\\n0\\n\\nNote\\n\\nIn the example the army consists of two warriors with personalities 3 and 4 after first two events. Then Vova tries to hire a commander with personality 6 and leadership 3, and only one warrior respects him (,...\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nstruct node {\\n node* a[2] = {NULL, NULL};\\n int count = 0;\\n};\\nnode* root = new node;\\nvoid update(int p, int val) {\\n node* cur = root;\\n for (int i = 31; i >= 0; i--) {\\n int id = p >> i & 1;\\n if (cur->a[id] == NULL) cur->a[id] = new node;\\n cur = cur->a[id];\\n cur->count += val;\\n }\\n}\\nint solve(int p, int l) {\\n node* cur = root;\\n int ans = 0;\\n for (int i = 31; i >= 0; i--) {\\n if (cur == NULL) break;\\n int pi = p >> i & 1;\\n int li = l >> i & 1;\\n if (li && cur->a[pi]) ans += cur->a[pi]->count;\\n cur = cur->a[pi ^ li];\\n }\\n return ans;\\n}\\nint main() {\\n ios::sync_with_stdio(0);\\n cin.tie(0);\\n int q;\\n cin >> q;\\n while (q--) {\\n int x;\\n cin >> x;\\n if (x == 1) {\\n int p;\\n cin >> p;\\n update(p, 1);\\n } else if (x == 2) {\\n int p;\\n cin >> p;\\n update(p, -1);\\n } else {\\n int p, l;\\n cin >> p >> l;\\n cout << solve(p, l) << endl;\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nYou are given N points on an infinite plane with the Cartesian coordinate system on it. N-1 points lay on one line, and one point isn't on that line. You are on point K at the start, and the goal is to visit every point. You can move between any two points in a straight line, and you can revisit points. What is the minimum length of the path? \\n\\nInput\\n\\nThe first line contains two integers: N (3 ≤ N ≤ 2*10^5) - the number of points, and K (1 ≤ K ≤ N) - the index of the starting point.\\n\\nEach of the next N lines contain two integers, A_i, B_i (-10^6 ≤ A_i, B_i ≤ 10^6) - coordinates of the i-th point.\\n\\nOutput\\n\\nThe output contains one number - the shortest path to visit all given points starting from point K. The absolute difference between your solution and the main solution shouldn't exceed 10^-6;\\n\\nExample\\n\\nInput\\n\\n\\n5 2\\n0 0\\n-1 1\\n2 -2\\n0 1\\n-2 2\\n\\n\\nOutput\\n\\n\\n7.478709\\n\\nNote\\n\\nThe shortest path consists of these moves: \\n\\n2 -> 5 \\n\\n5 -> 4 \\n\\n4 -> 1 \\n\\n1 -> 3 \\n\\nThere isn't any shorter path possible.\",\"targets\":\"#include \\nusing namespace std;\\nint n, k, l;\\npair p[200020], now;\\ndouble dis(pair x, pair y) {\\n return sqrt((x.first - y.first) * (x.first - y.first) +\\n (x.second - y.second) * (x.second - y.second));\\n}\\nint check() {\\n for (int i = 1; i < 4; i++)\\n for (int j = i + 1; j < 4; j++)\\n if ((p[i].second - p[0].second) * (p[j].first - p[0].first) ==\\n (p[i].first - p[0].first) * (p[j].second - p[0].second))\\n return true;\\n return false;\\n}\\nint find() {\\n int o;\\n for (int i = 1; i < 4; i++)\\n for (int j = i + 1; j < 4; j++)\\n if ((p[i].second - p[0].second) * (p[j].first - p[0].first) ==\\n (p[i].first - p[0].first) * (p[j].second - p[0].second))\\n o = i;\\n for (int i = 1; i < n; i++)\\n if ((p[i].second - p[0].second) * (p[o].first - p[0].first) !=\\n (p[i].first - p[0].first) * (p[o].second - p[0].second))\\n return i;\\n}\\ndouble calc(pair x, pair y,\\n pair z) {\\n return min(dis(x, y), dis(x, z)) + dis(y, z);\\n}\\nint main() {\\n scanf(\\\"%d%d\\\", &n, &k);\\n double res = 1e+12;\\n k--;\\n for (int i = 0; i < n; i++) scanf(\\\"%lld%lld\\\", &p[i].first, &p[i].second);\\n if (n == 3) {\\n swap(p[0], p[k]);\\n res = calc(p[0], p[1], p[2]);\\n } else {\\n if (!check()) {\\n swap(p[0], p[1]);\\n if (k < 2) k = k ^ 1;\\n }\\n int tmp = find();\\n swap(p[tmp], p[n - 1]);\\n if (k == tmp)\\n k = n - 1;\\n else if (k == n - 1)\\n k = tmp;\\n now = p[k];\\n sort(p, p + n - 1);\\n l = n;\\n for (int i = 0; i < n; i++)\\n if (p[i] == now) {\\n l = min(l, i);\\n k = i;\\n }\\n if (k == n - 1) {\\n res = calc(p[k], p[0], p[n - 2]);\\n } else {\\n res = dis(p[k], p[n - 1]) + calc(p[n - 1], p[0], p[n - 2]);\\n res = min(res, dis(p[k], p[0]) + dis(p[0], p[n - 1]) +\\n (k != n - 2) * (calc(p[n - 1], p[k + 1], p[n - 2])));\\n res = min(res, dis(p[k], p[n - 2]) +...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given an array a of n integers, and another integer k such that 2k ≤ n.\\n\\nYou have to perform exactly k operations with this array. In one operation, you have to choose two elements of the array (let them be a_i and a_j; they can be equal or different, but their positions in the array must not be the same), remove them from the array, and add ⌊ (a_i)\\/(a_j) ⌋ to your score, where ⌊ x\\/y ⌋ is the maximum integer not exceeding x\\/y.\\n\\nInitially, your score is 0. After you perform exactly k operations, you add all the remaining elements of the array to the score.\\n\\nCalculate the minimum possible score you can get.\\n\\nInput\\n\\nThe first line of the input contains one integer t (1 ≤ t ≤ 500) — the number of test cases.\\n\\nEach test case consists of two lines. The first line contains two integers n and k (1 ≤ n ≤ 100; 0 ≤ k ≤ ⌊ n\\/2 ⌋).\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 2 ⋅ 10^5).\\n\\nOutput\\n\\nPrint one integer — the minimum possible score you can get.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n7 3\\n1 1 1 2 1 3 1\\n5 1\\n5 5 5 5 5\\n4 2\\n1 3 3 7\\n2 0\\n4 2\\n9 2\\n1 10 10 1 10 2 7 10 3\\n\\n\\nOutput\\n\\n\\n2\\n16\\n0\\n6\\n16\\n\\nNote\\n\\nLet's consider the example test.\\n\\nIn the first test case, one way to obtain a score of 2 is the following one:\\n\\n 1. choose a_7 = 1 and a_4 = 2 for the operation; the score becomes 0 + ⌊ 1\\/2 ⌋ = 0, the array becomes [1, 1, 1, 1, 3]; \\n 2. choose a_1 = 1 and a_5 = 3 for the operation; the score becomes 0 + ⌊ 1\\/3 ⌋ = 0, the array becomes [1, 1, 1]; \\n 3. choose a_1 = 1 and a_2 = 1 for the operation; the score becomes 0 + ⌊ 1\\/1 ⌋ = 1, the array becomes [1]; \\n 4. add the remaining element 1 to the score, so the resulting score is 2. \\n\\n\\n\\nIn the second test case, no matter which operations you choose, the resulting score is 16.\\n\\nIn the third test case, one way to obtain a score of 0 is the following one:\\n\\n 1. choose a_1 = 1 and a_2 = 3 for the operation; the score becomes 0 + ⌊ 1\\/3 ⌋ = 0, the array becomes [3, 7]; \\n 2. choose a_1 = 3 and a_2 = 7 for the operation; the score becomes 0 + ⌊ 3\\/7 ⌋ = 0, the array becomes...\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\n\\n\\/**\\n * Provide prove of correctness before implementation. Implementation can cost a\\n * lot of time.\\n * Anti test that prove that it's wrong.\\n *

\\n * Do not confuse i j k g indexes, upTo and length. Do extra methods!!! Write\\n * more informative names to simulation\\n *

\\n * Will program ever exceed limit?\\n * Try all approaches with prove of correctness if task is not obvious.\\n * If you are given formula\\/rule: Try to play with it.\\n * Analytic solution\\/Hardcoded solution\\/Constructive\\/Greedy\\/DP\\/Math\\/Brute\\n * force\\/Symmetric data\\n * Number theory\\n * Game theory (optimal play) that consider local and global strategy.\\n *\\/\\npublic class TemplateFast {\\n\\n private void solveOne() {\\n int n = nextInt();\\n int k = nextInt();\\n int[] a = radixSort2(nextIntArr(n));\\n long ans = 0L;\\n for(int i = 0; i < n - 2 * k; i++) {\\n ans += a[i];\\n }\\n \\n for(int l = n - 2 * k; l < n - k; l ++) {\\n ans += a[l] \\/ a[l + k];\\n }\\n\\n System.out.println(ans);\\n }\\n\\n public static int[] radixSort2(int[] a) {\\n int n = a.length;\\n int[] c0 = new int[0x101];\\n int[] c1 = new int[0x101];\\n int[] c2 = new int[0x101];\\n int[] c3 = new int[0x101];\\n for (int v : a) {\\n c0[(v & 0xff) + 1]++;\\n c1[(v >>> 8 & 0xff) + 1]++;\\n c2[(v >>> 16 & 0xff) + 1]++;\\n c3[(v >>> 24 ^ 0x80) + 1]++;\\n }\\n for (int i = 0; i < 0xff; i++) {\\n c0[i + 1] += c0[i];\\n c1[i + 1] += c1[i];\\n c2[i + 1] += c2[i];\\n c3[i + 1] += c3[i];\\n }\\n int[] t = new int[n];\\n for (int v : a) t[c0[v & 0xff]++] = v;\\n for (int v : t) a[c1[v >>> 8 & 0xff]++] = v;\\n for (int v : a) t[c2[v >>> 16 & 0xff]++] = v;\\n for (int v : t) a[c3[v >>> 24 ^ 0x80]++] = v;\\n return a;\\n }\\n\\n private void solve() {\\n int t = System.in.readInt();\\n for (int tt = 0; tt < t; tt++) {\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"There are n block towers in a row, where tower i has a height of a_i. You're part of a building crew, and you want to make the buildings look as nice as possible. In a single day, you can perform the following operation:\\n\\n * Choose two indices i and j (1 ≤ i, j ≤ n; i ≠ j), and move a block from tower i to tower j. This essentially decreases a_i by 1 and increases a_j by 1. \\n\\n\\n\\nYou think the ugliness of the buildings is the height difference between the tallest and shortest buildings. Formally, the ugliness is defined as max(a)-min(a). \\n\\nWhat's the minimum possible ugliness you can achieve, after any number of days?\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 1000) — the number of test cases. Then t cases follow.\\n\\nThe first line of each test case contains one integer n (2 ≤ n ≤ 100) — the number of buildings.\\n\\nThe second line of each test case contains n space separated integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^7) — the heights of the buildings.\\n\\nOutput\\n\\nFor each test case, output a single integer — the minimum possible ugliness of the buildings.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n3\\n10 10 10\\n4\\n3 2 1 2\\n5\\n1 2 3 1 5\\n\\n\\nOutput\\n\\n\\n0\\n0\\n1\\n\\nNote\\n\\nIn the first test case, the ugliness is already 0.\\n\\nIn the second test case, you should do one operation, with i = 1 and j = 3. The new heights will now be [2, 2, 2, 2], with an ugliness of 0.\\n\\nIn the third test case, you may do three operations: \\n\\n 1. with i = 3 and j = 1. The new array will now be [2, 2, 2, 1, 5], \\n 2. with i = 5 and j = 4. The new array will now be [2, 2, 2, 2, 4], \\n 3. with i = 5 and j = 3. The new array will now be [2, 2, 3, 2, 3]. \\n\\nThe resulting ugliness is 1. It can be proven that this is the minimum possible ugliness for this test.\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\ntemplate \\nvoid read(vector& v);\\ntemplate \\nvoid read(array& a);\\ntemplate \\nvoid read(T& x) {\\n cin >> x;\\n}\\nvoid read(double& d) {\\n string t;\\n read(t);\\n d = stod(t);\\n}\\nvoid read(long double& d) {\\n string t;\\n read(t);\\n d = stold(t);\\n}\\ntemplate \\nvoid read(H& h, T&... t) {\\n read(h);\\n read(t...);\\n}\\ntemplate \\nvoid read(vector& x) {\\n for (auto& a : x) read(a);\\n}\\ntemplate \\nvoid read(array& x) {\\n for (auto& a : x) read(a);\\n}\\nvoid solve() {\\n int n;\\n cin >> n;\\n long long ans = 0;\\n for (int i = 0; i < n; i++) {\\n int x;\\n cin >> x;\\n ans += x;\\n }\\n if (ans % n == 0) {\\n cout << 0 << endl;\\n } else {\\n cout << 1 << endl;\\n }\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n int t = 1;\\n cin >> t;\\n while (t--) solve();\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"In Berland, n different types of banknotes are used. Banknotes of the i-th type have denomination 10^{a_i} burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly 1.\\n\\nLet's denote f(s) as the minimum number of banknotes required to represent exactly s burles. For example, if the denominations of banknotes used in Berland are 1, 10 and 100, then f(59) = 14: 9 banknotes with denomination of 1 burle and 5 banknotes with denomination of 10 burles can be used to represent exactly 9 ⋅ 1 + 5 ⋅ 10 = 59 burles, and there's no way to do it with fewer banknotes.\\n\\nFor a given integer k, find the minimum positive number of burles s that cannot be represented with k or fewer banknotes (that is, f(s) > k).\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — number of test cases.\\n\\nThe first line of each test case contains two integers n and k (1 ≤ n ≤ 10; 1 ≤ k ≤ 10^9).\\n\\nThe next line contains n integers a_1, a_2, ..., a_n (0 = a_1 < a_2 < ... < a_n ≤ 9).\\n\\nOutput\\n\\nFor each test case, print one integer — the minimum positive number of burles s that cannot be represented with k or fewer banknotes.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3 13\\n0 1 2\\n2 777\\n0 4\\n3 255\\n0 1 3\\n10 1000000000\\n0 1 2 3 4 5 6 7 8 9\\n\\n\\nOutput\\n\\n\\n59\\n778\\n148999\\n999999920999999999\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nlong long int mod = 1e9 + 7;\\nvoid yes() { cout << \\\"YES\\\" << endl; }\\nvoid no() { cout << \\\"NO\\\" << endl; }\\nbool compare(pair > &a,\\n pair > &b) {\\n if (a.first == b.first) {\\n return a.second.second <= b.second.second;\\n }\\n return a.first < b.first;\\n}\\nbool isPrime(long long int n) {\\n for (int i = 2; i <= sqrt(n); i++) {\\n if (n % i == 0) {\\n return 0;\\n }\\n }\\n return 1;\\n}\\nlong long int solve() {\\n long long int n, k, m;\\n cin >> n >> k;\\n string s, t = \\\"\\\", r;\\n long long int count = 0, prev = 0, cnt = 0, ans = 0, curr = 0;\\n bool turn = 1, win = 0, flag = 1;\\n vector v(n, 0);\\n for (int i = 0; i < n; i++) cin >> v[i];\\n if (v[0] != 0) {\\n ans = 1;\\n } else if (n == 1) {\\n ans = k + 1;\\n } else {\\n count = k;\\n for (int i = 1; i < n; i++) {\\n cnt = (long long int)pow((long long int)10, v[i]) -\\n (long long int)pow((long long int)10, v[i - 1]);\\n if (count * (long long int)pow((long long int)10, v[i - 1]) < cnt) {\\n ans += (count + 1) * (long long int)pow((long long int)10, v[i - 1]);\\n count = -1;\\n break;\\n } else {\\n ans += cnt;\\n count -= cnt \\/ (long long int)pow((long long int)10, v[i - 1]);\\n }\\n }\\n ans += (count + 1) * (long long int)pow((long long int)10, v[n - 1]);\\n }\\n cout << ans << endl;\\n return ans;\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n int test = 1;\\n cin >> test;\\n for (int i = 0; i < test; i++) {\\n solve();\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"British mathematician John Littlewood once said about Indian mathematician Srinivasa Ramanujan that \\\"every positive integer was one of his personal friends.\\\"\\n\\nIt turns out that positive integers can also be friends with each other! You are given an array a of distinct positive integers. \\n\\nDefine a subarray a_i, a_{i+1}, …, a_j to be a friend group if and only if there exists an integer m ≥ 2 such that a_i mod m = a_{i+1} mod m = … = a_j mod m, where x mod y denotes the remainder when x is divided by y.\\n\\nYour friend Gregor wants to know the size of the largest friend group in a.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 2⋅ 10^4). \\n\\nEach test case begins with a line containing the integer n (1 ≤ n ≤ 2 ⋅ 10^5), the size of the array a.\\n\\nThe next line contains n positive integers a_1, a_2, …, a_n (1 ≤ a_i ≤ {10}^{18}), representing the contents of the array a. It is guaranteed that all the numbers in a are distinct.\\n\\nIt is guaranteed that the sum of n over all test cases is less than 2⋅ 10^5.\\n\\nOutput\\n\\nYour output should consist of t lines. Each line should consist of a single integer, the size of the largest friend group in a.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n5\\n1 5 2 4 6\\n4\\n8 2 5 10\\n2\\n1000 2000\\n8\\n465 55 3 54 234 12 45 78\\n\\n\\nOutput\\n\\n\\n3\\n3\\n2\\n6\\n\\nNote\\n\\nIn the first test case, the array is [1,5,2,4,6]. The largest friend group is [2,4,6], since all those numbers are congruent to 0 modulo 2, so m=2.\\n\\nIn the second test case, the array is [8,2,5,10]. The largest friend group is [8,2,5], since all those numbers are congruent to 2 modulo 3, so m=3.\\n\\nIn the third case, the largest friend group is [1000,2000]. There are clearly many possible values of m that work.\\n\\/*\",\"targets\":\"Author : Akshat Jindal\\n from NIT Jalandhar , Punjab , India\\n JAI MATA DI\\n *\\/\\nimport java.util.*;\\nimport java.io.*;\\nimport java.math.*;\\nimport java.sql.Array;\\n\\n\\n\\npublic class Main {\\n\\t static class FR{\\n\\t\\t \\n\\t\\t\\tBufferedReader br;\\n\\t\\t\\tStringTokenizer st;\\n\\t\\t\\tpublic FR() {\\n\\t\\t\\t\\tbr = new BufferedReader(new InputStreamReader(System.in));\\n\\t\\t\\t}\\n\\t\\t\\tString next() \\n\\t\\t { \\n\\t\\t while (st == null || !st.hasMoreElements()) \\n\\t\\t { \\n\\t\\t try\\n\\t\\t { \\n\\t\\t st = new StringTokenizer(br.readLine()); \\n\\t\\t } \\n\\t\\t catch (IOException e) \\n\\t\\t { \\n\\t\\t e.printStackTrace(); \\n\\t\\t } \\n\\t\\t } \\n\\t\\t return st.nextToken(); \\n\\t\\t } \\n\\n\\t\\t int nextInt() \\n\\t\\t { \\n\\t\\t return Integer.parseInt(next()); \\n\\t\\t } \\n\\n\\t\\t long nextLong() \\n\\t\\t { \\n\\t\\t return Long.parseLong(next()); \\n\\t\\t } \\n\\n\\t\\t double nextDouble() \\n\\t\\t { \\n\\t\\t return Double.parseDouble(next()); \\n\\t\\t } \\n\\n\\t\\t String nextLine() \\n\\t\\t { \\n\\t\\t String str = \\\"\\\"; \\n\\t\\t try\\n\\t\\t { \\n\\t\\t str = br.readLine(); \\n\\t\\t } \\n\\t\\t catch (IOException e) \\n\\t\\t { \\n\\t\\t e.printStackTrace(); \\n\\t\\t } \\n\\t\\t return str; \\n\\t\\t } \\n\\t\\t}\\n\\t \\n\\t static long mod = (long)(1e9 + 7);\\n\\t \\n\\tstatic void sort(long[] arr ) {\\n\\t\\t ArrayList al = new ArrayList<>();\\n\\t\\t for(long e:arr) al.add(e);\\n\\t\\t Collections.sort(al);\\n\\t\\t for(int i = 0 ; i al = new ArrayList<>();\\n\\t\\t for(int e:arr) al.add(e);\\n\\t\\t Collections.sort(al);\\n\\t\\t for(int i = 0 ; i find) r = m-1;\\n\\t\\t\\telse l = m+1;\\n\\t\\t}\\n\\t\\treturn r;\\n\\t}\\n\\tstatic int UB(int[] arr , long find , int l , int...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Theofanis really likes sequences of positive integers, thus his teacher (Yeltsa Kcir) gave him a problem about a sequence that consists of only special numbers.\\n\\nLet's call a positive number special if it can be written as a sum of different non-negative powers of n. For example, for n = 4 number 17 is special, because it can be written as 4^0 + 4^2 = 1 + 16 = 17, but 9 is not.\\n\\nTheofanis asks you to help him find the k-th special number if they are sorted in increasing order. Since this number may be too large, output it modulo 10^9+7.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases.\\n\\nThe first and only line of each test case contains two integers n and k (2 ≤ n ≤ 10^9; 1 ≤ k ≤ 10^9).\\n\\nOutput\\n\\nFor each test case, print one integer — the k-th special number in increasing order modulo 10^9+7.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n3 4\\n2 12\\n105 564\\n\\n\\nOutput\\n\\n\\n9\\n12\\n3595374\\n\\nNote\\n\\nFor n = 3 the sequence is [1,3,4,9...]\",\"targets\":\"#include \\nusing namespace std;\\nlong long binPow(long long a, long long n) {\\n if (n == 0)\\n return 1;\\n else if (n % 2)\\n return binPow(a, n - 1) * a % 1000000007;\\n else {\\n long long b = binPow(a, n \\/ 2);\\n return b * b % 1000000007;\\n }\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(nullptr);\\n cout.tie(nullptr);\\n int t;\\n cin >> t;\\n while (t--) {\\n long long n, k, ans = 0;\\n cin >> n >> k;\\n int l = 0;\\n while (k != 0) {\\n if (k % 2) ans = (ans + binPow(n, l)) % 1000000007;\\n k \\/= 2;\\n l++;\\n }\\n cout << ans << endl;\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"Alice gave Bob two integers a and b (a > 0 and b ≥ 0). Being a curious boy, Bob wrote down an array of non-negative integers with \\\\operatorname{MEX} value of all elements equal to a and \\\\operatorname{XOR} value of all elements equal to b.\\n\\nWhat is the shortest possible length of the array Bob wrote?\\n\\nRecall that the \\\\operatorname{MEX} (Minimum EXcluded) of an array is the minimum non-negative integer that does not belong to the array and the \\\\operatorname{XOR} of an array is the [bitwise XOR](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#XOR) of all the elements of the array.\\n\\nInput\\n\\nThe input consists of multiple test cases. The first line contains an integer t (1 ≤ t ≤ 5 ⋅ 10^4) — the number of test cases. The description of the test cases follows.\\n\\nThe only line of each test case contains two integers a and b (1 ≤ a ≤ 3 ⋅ 10^5; 0 ≤ b ≤ 3 ⋅ 10^5) — the \\\\operatorname{MEX} and \\\\operatorname{XOR} of the array, respectively.\\n\\nOutput\\n\\nFor each test case, output one (positive) integer — the length of the shortest array with \\\\operatorname{MEX} a and \\\\operatorname{XOR} b. We can show that such an array always exists.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n1 1\\n2 1\\n2 0\\n1 10000\\n2 10000\\n\\n\\nOutput\\n\\n\\n3\\n2\\n3\\n2\\n3\\n\\nNote\\n\\nIn the first test case, one of the shortest arrays with \\\\operatorname{MEX} 1 and \\\\operatorname{XOR} 1 is [0, 2020, 2021].\\n\\nIn the second test case, one of the shortest arrays with \\\\operatorname{MEX} 2 and \\\\operatorname{XOR} 1 is [0, 1].\\n\\nIt can be shown that these arrays are the shortest arrays possible.\\\":\",\"targets\":\"import java.util.*;\\npublic class Main {\\n static int [] arr=new int[300005+1];\\n static Scanner sc;\\n static void solve(){\\n int a=sc.nextInt();\\n int b=sc.nextInt();\\n int num=arr[a];\\n if(num==b){\\n System.out.println(a);\\n }else if((num^b)==a){\\n System.out.println(a+2);\\n }else{\\n System.out.println(a+1);\\n }\\n }\\n public static void main(String[] args){\\n sc=new Scanner(System.in);\\n int t=sc.nextInt();\\n for(int i=1;i<=300005;i++){\\n arr[i]=arr[i-1]^(i-1);\\n }\\n while(t-->0) {\\n solve();\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alice has an integer sequence a of length n and all elements are different. She will choose a subsequence of a of length m, and defines the value of a subsequence a_{b_1},a_{b_2},…,a_{b_m} as $$$∑_{i = 1}^m (m ⋅ a_{b_i}) - ∑_{i = 1}^m ∑_{j = 1}^m f(min(b_i, b_j), max(b_i, b_j)), where f(i, j) denotes \\\\min(a_i, a_{i + 1}, \\\\ldots, a_j)$$$.\\n\\nAlice wants you to help her to maximize the value of the subsequence she choose.\\n\\nA sequence s is a subsequence of a sequence t if s can be obtained from t by deletion of several (possibly, zero or all) elements.\\n\\nInput\\n\\nThe first line contains two integers n and m (1 ≤ m ≤ n ≤ 4000).\\n\\nThe second line contains n distinct integers a_1, a_2, …, a_n (1 ≤ a_i < 2^{31}).\\n\\nOutput\\n\\nPrint the maximal value Alice can get.\\n\\nExamples\\n\\nInput\\n\\n\\n6 4\\n15 2 18 12 13 4\\n\\n\\nOutput\\n\\n\\n100\\n\\n\\nInput\\n\\n\\n11 5\\n9 3 7 1 8 12 10 20 15 18 5\\n\\n\\nOutput\\n\\n\\n176\\n\\n\\nInput\\n\\n\\n1 1\\n114514\\n\\n\\nOutput\\n\\n\\n0\\n\\n\\nInput\\n\\n\\n2 1\\n666 888\\n\\n\\nOutput\\n\\n\\n0\\n\\nNote\\n\\nIn the first example, Alice can choose the subsequence [15, 2, 18, 13], which has the value 4 ⋅ (15 + 2 + 18 + 13) - (15 + 2 + 2 + 2) - (2 + 2 + 2 + 2) - (2 + 2 + 18 + 12) - (2 + 2 + 12 + 13) = 100. In the second example, there are a variety of subsequences with value 176, and one of them is [9, 7, 12, 20, 18].\",\"targets\":\"#include \\nusing namespace std;\\nlong long read() {\\n long long x = 0, b = 1;\\n char c;\\n do c = getchar();\\n while ((c > '9' || c < '0') && c != '-');\\n if (c == '-') b = 0;\\n do x = x * 10 + c - '0', c = getchar();\\n while (c >= '0' && c <= '9');\\n return b ? x : -x;\\n}\\nconst long long maxn = 4010;\\nlong long i, j, k, n, m, T, a[maxn], son[maxn][2], root, cnt, dp[maxn][maxn],\\n size[maxn];\\nvoid dfs(long long &root, long long L, long long R) {\\n if (L > R) return;\\n if (!root) root = ++cnt;\\n long long Min = L;\\n for (long long i = L; i <= R; i++)\\n if (a[i] < a[Min]) Min = i;\\n dfs(son[root][0], L, Min - 1);\\n dfs(son[root][1], Min + 1, R);\\n size[root] = size[son[root][0]] + size[son[root][1]] + 1;\\n for (long long i = 0; i <= size[son[root][0]]; i++)\\n for (long long j = 0; j <= size[son[root][1]]; j++) {\\n dp[root][i + j] =\\n max(dp[root][i + j],\\n dp[son[root][0]][i] + dp[son[root][1]][j] - 2 * i * j * a[Min]);\\n dp[root][i + j + 1] =\\n max(dp[root][i + j + 1],\\n dp[son[root][0]][i] + dp[son[root][1]][j] + m * a[Min] -\\n (2 * i * j + 2 * i + 2 * j + 1) * a[Min]);\\n }\\n}\\nsigned main() {\\n cin >> n >> m;\\n for (i = 1; i <= n; i++) a[i] = read();\\n dfs(root, 1, n);\\n long long Ans = 0;\\n cout << dp[root][m] << endl;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"This is an interactive problem.\\n\\nICPC Assiut Community decided to hold a unique chess contest, and you were chosen to control a queen and hunt down the hidden king, while a member of ICPC Assiut Community controls this king.\\n\\nYou compete on an 8×8 chessboard, the rows are numerated from top to bottom, and the columns are numerated left to right, and the cell in row x and column y is denoted as (x, y).\\n\\nIn one turn you can move the queen to any of the squares on the same horizontal line, vertical line, or any of the diagonals. For example, if the queen was on square (4, 5), you can move to (q_1, 5), (4, q_1), (q_1, 9-q_1), or (q_2, q_2+1) where (1 ≤ q_1 ≤ 8, q_1 ≠ 4, 1 ≤ q_2 ≤ 7, q_2 ≠ 4). Note that the queen cannot stay on its current cell. \\n\\n\\n\\nIn one turn, the king can move \\\"Right\\\", \\\"Left\\\", \\\"Up\\\", \\\"Down\\\", \\\"Down-Right\\\", \\\"Down-Left\\\", \\\"Up-Left\\\", or \\\"Up-Right\\\" such that he doesn't get out of the board. The king cannot move into a cell that is on the same row, column or diagonal with the queen (including the position of the queen itself). For example, if the king was on square (4, 5), he can move to (4+k_1, 5+k_2) where (-1 ≤ k_1,k_2 ≤ 1, (k_1, k_2) ≠ (0, 0)). \\n\\n\\n\\nAt the start of the game, you should place the queen at any location on the board, and this is done once per game. After that the king is secretly placed at any cell different from the queen's location. You do not know the position of the king. Then, the king and the queen take turns with the king moving first. The king moves to one of the possible directions (\\\"Right\\\", \\\"Down\\\", \\\"Up-Left\\\", etc.), and you are only given the direction it moves to. After that, you should move your queen by declaring the square to which your queen will move. The game follows like this until you win the game or run out of moves.\\n\\nYou win if the king has no valid moves. You lose if after 130 moves of the queen the king still has valid moves.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 60) — the number of test cases.\\n\\nInteraction\\n\\nIn each test case,...\",\"targets\":\"#include \\nusing namespace std;\\nint T, row, col;\\nstring s;\\nvoid mov(int x, int y) {\\n printf(\\\"%d %d\\\\n\\\", x, y);\\n col = y;\\n cin >> s;\\n}\\nint scan(int row) {\\n for (int c = (col == 1 ? 2 : 1); c <= 8; ++c) {\\n mov(row, c);\\n if (s == \\\"Done\\\") return true;\\n if (s.find(\\\"Down\\\") != -1) return false;\\n if (s.find(\\\"Up\\\") != -1) return scan(row);\\n }\\n return false;\\n}\\nint main() {\\n scanf(\\\"%d\\\", &T);\\n while (T--) {\\n col = 1;\\n for (int row = 1; row <= 8; row++) {\\n mov(row, col);\\n if (col != 1) {\\n if (s == \\\"Done\\\") break;\\n col = 1;\\n mov(row, col);\\n }\\n if (s == \\\"Done\\\") break;\\n if (scan(row)) break;\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"On a circle lie 2n distinct points, with the following property: however you choose 3 chords that connect 3 disjoint pairs of points, no point strictly inside the circle belongs to all 3 chords. The points are numbered 1, 2, ..., 2n in clockwise order.\\n\\nInitially, k chords connect k pairs of points, in such a way that all the 2k endpoints of these chords are distinct.\\n\\nYou want to draw n - k additional chords that connect the remaining 2(n - k) points (each point must be an endpoint of exactly one chord).\\n\\nIn the end, let x be the total number of intersections among all n chords. Compute the maximum value that x can attain if you choose the n - k chords optimally.\\n\\nNote that the exact position of the 2n points is not relevant, as long as the property stated in the first paragraph holds.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. Then t test cases follow.\\n\\nThe first line of each test case contains two integers n and k (1 ≤ n ≤ 100, 0 ≤ k ≤ n) — half the number of points and the number of chords initially drawn.\\n\\nThen k lines follow. The i-th of them contains two integers x_i and y_i (1 ≤ x_i, y_i ≤ 2n, x_i ≠ y_i) — the endpoints of the i-th chord. It is guaranteed that the 2k numbers x_1, y_1, x_2, y_2, ..., x_k, y_k are all distinct.\\n\\nOutput\\n\\nFor each test case, output the maximum number of intersections that can be obtained by drawing n - k additional chords.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n4 2\\n8 2\\n1 5\\n1 1\\n2 1\\n2 0\\n10 6\\n14 6\\n2 20\\n9 10\\n13 18\\n15 12\\n11 7\\n\\n\\nOutput\\n\\n\\n4\\n0\\n1\\n14\\n\\nNote\\n\\nIn the first test case, there are three ways to draw the 2 additional chords, shown below (black chords are the ones initially drawn, while red chords are the new ones):\\n\\n\\n\\nWe see that the third way gives the maximum number of intersections, namely 4.\\n\\nIn the second test case, there are no more chords to draw. Of course, with only one chord present there are no intersections.\\n\\nIn the third test case, we can make at most one intersection by drawing chords 1-3 and 2-4, as...\\nUsing java can you solve the prior task?\",\"targets\":\"import java.util.*;\\nimport java.lang.*;\\nimport java.io.*;\\nimport java.math.*;\\n\\npublic class Main\\n{\\n static class FastReader \\n { \\n BufferedReader br; \\n StringTokenizer st; \\n \\n public FastReader() \\n { \\n br = new BufferedReader(new\\n InputStreamReader(System.in)); \\n } \\n \\n String n() \\n { \\n while (st == null || !st.hasMoreElements()) \\n { \\n try\\n { \\n st = new StringTokenizer(br.readLine()); \\n } \\n catch (IOException e) \\n { \\n e.printStackTrace(); \\n } \\n } \\n return st.nextToken(); \\n } \\n \\n int ni() \\n { \\n return Integer.parseInt(n()); \\n } \\n \\n long nl() \\n { \\n return Long.parseLong(n()); \\n } \\n \\n double nd() \\n { \\n return Double.parseDouble(n()); \\n } \\n \\n String nline() \\n { \\n String str = \\\"\\\"; \\n try\\n { \\n str = br.readLine(); \\n } \\n catch (IOException e) \\n { \\n e.printStackTrace(); \\n } \\n return str; \\n } \\n }\\n\\n \\n public static long[] randomize(long arr[])\\n {\\n Random rand = new Random();\\nfor (int i = 0; i < arr.length; ++i) {\\n int index = rand.nextInt(arr.length - i);\\n long tmp = arr[arr.length - 1 - i];\\n arr[arr.length - 1 - i] = arr[index];\\n arr[index] = tmp;\\n}\\n\\nreturn arr;\\n } \\n\\n static long mod = 1000000007;\\n\\n \\n public static void main (String[] args) throws java.lang.Exception\\n {\\n FastReader sc = new FastReader();\\n StringBuilder fo = new StringBuilder();\\n\\n int test=sc.ni();\\n \\n while(test-->0)\\n {\\n int n = sc.ni();\\n\\n int k1 =sc.ni();\\n \\n List> points = new ArrayList<>();\\n Set...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A guy named Vasya attends the final grade of a high school. One day Vasya decided to watch a match of his favorite hockey team. And, as the boy loves hockey very much, even more than physics, he forgot to do the homework. Specifically, he forgot to complete his physics tasks. Next day the teacher got very angry at Vasya and decided to teach him a lesson. He gave the lazy student a seemingly easy task: You are given an idle body in space and the forces that affect it. The body can be considered as a material point with coordinates (0; 0; 0). Vasya had only to answer whether it is in equilibrium. \\\"Piece of cake\\\" — thought Vasya, we need only to check if the sum of all vectors is equal to 0. So, Vasya began to solve the problem. But later it turned out that there can be lots and lots of these forces, and Vasya can not cope without your help. Help him. Write a program that determines whether a body is idle or is moving by the given vectors of forces.\\n\\nInput\\n\\nThe first line contains a positive integer n (1 ≤ n ≤ 100), then follow n lines containing three integers each: the xi coordinate, the yi coordinate and the zi coordinate of the force vector, applied to the body ( - 100 ≤ xi, yi, zi ≤ 100).\\n\\nOutput\\n\\nPrint the word \\\"YES\\\" if the body is in equilibrium, or the word \\\"NO\\\" if it is not.\\n\\nExamples\\n\\nInput\\n\\n3\\n4 1 7\\n-2 4 -1\\n1 -5 -3\\n\\n\\nOutput\\n\\nNO\\n\\nInput\\n\\n3\\n3 -1 7\\n-5 2 -4\\n2 -1 -3\\n\\n\\nOutput\\n\\nYES\\nUsing python3 can you solve the prior task?\",\"targets\":\"a=0\\nb=0\\nc=0\\nfor i in range(int(input())):\\n x,y,z=map(int,input().split())\\n a+=x\\n b+=y\\n c+=z\\nif a==0 and b==0 and c==0 :\\n print(\\\"YES\\\")\\nelse:\\n print(\\\"NO\\\")\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Monocarp wrote down two numbers on a whiteboard. Both numbers follow a specific format: a positive integer x with p zeros appended to its end.\\n\\nNow Monocarp asks you to compare these two numbers. Can you help him?\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.\\n\\nThe first line of each testcase contains two integers x_1 and p_1 (1 ≤ x_1 ≤ 10^6; 0 ≤ p_1 ≤ 10^6) — the description of the first number.\\n\\nThe second line of each testcase contains two integers x_2 and p_2 (1 ≤ x_2 ≤ 10^6; 0 ≤ p_2 ≤ 10^6) — the description of the second number.\\n\\nOutput\\n\\nFor each testcase print the result of the comparison of the given two numbers. If the first number is smaller than the second one, print '<'. If the first number is greater than the second one, print '>'. If they are equal, print '='.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n2 1\\n19 0\\n10 2\\n100 1\\n1999 0\\n2 3\\n1 0\\n1 0\\n99 0\\n1 2\\n\\n\\nOutput\\n\\n\\n>\\n=\\n<\\n=\\n<\\n\\nNote\\n\\nThe comparisons in the example are: 20 > 19, 1000 = 1000, 1999 < 2000, 1 = 1, 99 < 100.\",\"targets\":\"T = int(input())\\nfor _ in range(T):\\n x, px = map(int, input().split())\\n y, py = map(int, input().split())\\n while x < 1e6:\\n x *= 10\\n px -= 1\\n while y < 1e6:\\n y *= 10\\n py -= 1\\n\\n if px > py:\\n print(\\\">\\\")\\n elif px < py:\\n print(\\\"<\\\")\\n else:\\n if x > y:\\n print(\\\">\\\")\\n elif x < y:\\n print(\\\"<\\\")\\n else:\\n print(\\\"=\\\")\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nIn the year 2420 humans have finally built a colony on Mars thanks to the work of Elon Tusk. There are 10^9+7 cities arranged in a circle in this colony and none of them are connected yet. Elon Tusk wants to connect some of those cities using only roads of the same size in order to lower the production cost of those roads. Because of that he gave a list on N cites where some cites can appear more than once and Q queries that you need to answer. For the query you need to determine if it is possible to connect all the cities from L_{i} to R_{i} on that list using only roads of length D_{i}. \\n\\nInput\\n\\nThe first line contains two integers N and Q (1 ≤ N, Q ≤ 2⋅10^5 ) — the length of the array of cities and the number of queries you need to answer. \\n\\nThe second lines contains N integers representing the array of cites. Next Q lines contain three integers L, R and D (1 ≤ L_{i}, R_{i} ≤ N, 0 ≤ D_{i} ≤ 10^9+6) — the range of cities that needs to be connected and the length of the road that you can use. \\n\\nOutput\\n\\nThe output contains Q lines. If it is possible to connect all the cities from the i-th query can be connected with roads of length D_{i} the i-th line should contain the word \\\"Yes\\\", otherwise it should contain the word \\\"No\\\". \\n\\nExamples\\n\\nInput\\n\\n\\n9 8\\n17 0 12 6 10 8 2 4 5\\n2 3 12\\n2 3 6\\n2 4 6\\n4 6 2\\n2 8 2\\n1 2 17\\n1 8 2\\n9 9 14\\n\\n\\nOutput\\n\\n\\nYes\\nNo\\nYes\\nYes\\nYes\\nYes\\nNo\\nYes\\n\\n\\nInput\\n\\n\\n4 1\\n7 21 14 0\\n1 4 1000000000\\n\\n\\nOutput\\n\\n\\nYes\\n\\nNote\\n\\nIn the 5^{th} query of the first test case we can connect cities in this order 0-2-4-6-8-10-12 this way distance between any two connected cities is 2. In the second test case we can connect cities in this order 21-14-7-0 this way distance between any two connected cities is 10^9 module 10^9+7.\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 2e5 + 5, mod = 1e9 + 7;\\nint n, q, inc, s1[N], s2[N];\\nint inv(int x) {\\n int res = 1, y = mod - 2;\\n while (y) {\\n if (y & 1) res = 1ll * res * x % mod;\\n x = 1ll * x * x % mod;\\n y >>= 1;\\n }\\n return res;\\n}\\nsigned main() {\\n scanf(\\\"%d%d\\\", &n, &q);\\n inc = rand() % mod;\\n for (int i = 1, x; i <= n; i++) {\\n scanf(\\\"%d\\\", &x);\\n (x += inc) %= mod;\\n s1[i] = (s1[i - 1] + x) % mod;\\n s2[i] = (s2[i - 1] + 1ll * x * x % mod) % mod;\\n }\\n while (q--) {\\n int l, r, d, m;\\n scanf(\\\"%d%d%d\\\", &l, &r, &d);\\n m = r - l + 1;\\n int x = (s1[r] - s1[l - 1] - m * (m - 1ll) \\/ 2 % mod * d % mod + mod * 2) *\\n inv(m) % mod;\\n int y =\\n (1ll * m * x % mod * x % mod + m * (m - 1ll) % mod * d % mod * x % mod +\\n m * (m - 1ll) * (m * 2 - 1) \\/ 6 % mod * d % mod * d % mod) %\\n mod;\\n if ((s2[r] - s2[l - 1] + mod) % mod == y)\\n puts(\\\"Yes\\\");\\n else\\n puts(\\\"No\\\");\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"For a sequence of strings [t_1, t_2, ..., t_m], let's define the function f([t_1, t_2, ..., t_m]) as the number of different strings (including the empty string) that are subsequences of at least one string t_i. f([]) = 0 (i. e. the number of such strings for an empty sequence is 0).\\n\\nYou are given a sequence of strings [s_1, s_2, ..., s_n]. Every string in this sequence consists of lowercase Latin letters and is sorted (i. e., each string begins with several (maybe zero) characters a, then several (maybe zero) characters b, ..., ends with several (maybe zero) characters z).\\n\\nFor each of 2^n subsequences of [s_1, s_2, ..., s_n], calculate the value of the function f modulo 998244353.\\n\\nInput\\n\\nThe first line contains one integer n (1 ≤ n ≤ 23) — the number of strings.\\n\\nThen n lines follow. The i-th line contains the string s_i (1 ≤ |s_i| ≤ 2 ⋅ 10^4), consisting of lowercase Latin letters. Each string s_i is sorted.\\n\\nOutput\\n\\nSince printing up to 2^{23} integers would be really slow, you should do the following:\\n\\nFor each of the 2^n subsequences (which we denote as [s_{i_1}, s_{i_2}, ..., s_{i_k}]), calculate f([s_{i_1}, s_{i_2}, ..., s_{i_k}]), take it modulo 998244353, then multiply it by k ⋅ (i_1 + i_2 + ... + i_k). Print the XOR of all 2^n integers you get.\\n\\nThe indices i_1, i_2, ..., i_k in the description of each subsequences are 1-indexed (i. e. are from 1 to n).\\n\\nExamples\\n\\nInput\\n\\n\\n3\\na\\nb\\nc\\n\\n\\nOutput\\n\\n\\n92\\n\\n\\nInput\\n\\n\\n2\\naa\\na\\n\\n\\nOutput\\n\\n\\n21\\n\\n\\nInput\\n\\n\\n2\\na\\na\\n\\n\\nOutput\\n\\n\\n10\\n\\n\\nInput\\n\\n\\n2\\nabcd\\naabb\\n\\n\\nOutput\\n\\n\\n124\\n\\n\\nInput\\n\\n\\n3\\nddd\\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\naaaaaaaabbbbbbbbbbbcccccccccccciiiiiiiiiiiiiiiiiiiiiiooooooooooqqqqqqqqqqqqqqqqqqvvvvvzzzzzzzzzzzz\\n\\n\\nOutput\\n\\n\\n15706243380\",\"targets\":\"#include \\nusing namespace std;\\nconst int MOD = 998244353;\\nconst int C = 26;\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n int n;\\n cin >> n;\\n vector> A(n);\\n for (int i = 0; i < n; i++) {\\n string s;\\n cin >> s;\\n for (char c : s) {\\n A[i][c - 'a']++;\\n }\\n }\\n vector dp(1 << n, 1);\\n dp[0] = 0;\\n for (int mask = 1; mask < (1 << n); mask++) {\\n array intersection;\\n for (int j = 0; j < C; j++) intersection[j] = 1e9;\\n for (int i = 0; i < n; i++) {\\n if ((mask >> i) & 1) {\\n for (int j = 0; j < C; j++) {\\n intersection[j] = min(intersection[j], A[i][j]);\\n }\\n }\\n }\\n for (int val : intersection) {\\n dp[mask] = 1LL * dp[mask] * (val + 1) % MOD;\\n }\\n if (!(__builtin_popcount(mask) & 1)) dp[mask] = -dp[mask];\\n }\\n for (int b = 1; b < (1 << n); b <<= 1) {\\n for (int mask = 1; mask < (1 << n); mask++) {\\n if (mask & b) {\\n dp[mask] = (dp[mask] + dp[mask ^ b]) % MOD;\\n }\\n }\\n }\\n long long ans = 0;\\n for (int mask = 1; mask < (1 << n); mask++) {\\n int k = 0;\\n int s = 0;\\n for (int i = 0; i < n; i++) {\\n if ((mask >> i) & 1) {\\n k++;\\n s += i + 1;\\n }\\n }\\n dp[mask] = (dp[mask] + MOD) % MOD;\\n ans ^= 1LL * k * s * dp[mask];\\n }\\n cout << ans << endl;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A tree is a connected graph without cycles. A rooted tree has a special vertex called the root. The parent of a vertex v (different from root) is the previous to v vertex on the shortest path from the root to the vertex v. Children of the vertex v are all vertices for which v is the parent.\\n\\nA vertex is a leaf if it has no children. We call a vertex a bud, if the following three conditions are satisfied: \\n\\n * it is not a root, \\n * it has at least one child, and \\n * all its children are leaves. \\n\\n\\n\\nYou are given a rooted tree with n vertices. The vertex 1 is the root. In one operation you can choose any bud with all its children (they are leaves) and re-hang them to any other vertex of the tree. By doing that you delete the edge connecting the bud and its parent and add an edge between the bud and the chosen vertex of the tree. The chosen vertex cannot be the bud itself or any of its children. All children of the bud stay connected to the bud.\\n\\nWhat is the minimum number of leaves it is possible to get if you can make any number of the above-mentioned operations (possibly zero)?\\n\\nInput\\n\\nThe input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. Description of the test cases follows.\\n\\nThe first line of each test case contains a single integer n (2 ≤ n ≤ 2 ⋅ 10^5) — the number of the vertices in the given tree.\\n\\nEach of the next n-1 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) meaning that there is an edge between vertices u and v in the tree.\\n\\nIt is guaranteed that the given graph is a tree.\\n\\nIt is guaranteed that the sum of n over all test cases doesn't exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case print a single integer — the minimal number of leaves that is possible to get after some operations.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n7\\n1 2\\n1 3\\n1 4\\n2 5\\n2 6\\n4 7\\n6\\n1 2\\n1 3\\n2 4\\n2 5\\n3 6\\n2\\n1 2\\n7\\n7 3\\n1 5\\n1 3\\n4 6\\n4 7\\n2 1\\n6\\n2 1\\n2 3\\n4 5\\n3 4\\n3 6\\n\\n\\nOutput\\n\\n\\n2\\n2\\n1\\n2\\n1\\n\\nNote\\n\\nIn the first test case the tree looks as follows:\\n\\n\\n\\nFirstly you can choose...\",\"targets\":\"#include \\nusing namespace std;\\nmt19937 rnd(time(0));\\ninline int in() {\\n char ch = getchar();\\n int f = 1, x = 0;\\n while (ch < '0' || ch > '9') {\\n if (ch == '-') f = -1;\\n ch = getchar();\\n }\\n while (ch >= '0' && ch <= '9')\\n x = (x << 1) + (x << 3) + ch - '0', ch = getchar();\\n return f * x;\\n}\\nconst int inf = 0x3f3f3f3f;\\nconst int mod = 998244353;\\nconst int N = 200010;\\nvoid Initialization() {}\\nvector e[N];\\npair f[N];\\nvoid dfs(int u, int F) {\\n if (e[u].size() == 0) {\\n f[u] = {0, 1};\\n return;\\n }\\n int A = 0, B = 0;\\n for (auto v : e[u])\\n if (v != F) {\\n dfs(v, u);\\n A += f[v].first;\\n B += f[v].second;\\n }\\n if (B == 0) {\\n f[u] = {A, 1};\\n } else {\\n f[u] = {A + 1, 0};\\n }\\n}\\nvoid solve(int CaseNum) {\\n int n = in();\\n for (int i = (1); i <= (int)(n); ++i) e[i].clear();\\n for (int i = (1); i <= (int)(n - 1); ++i) {\\n int u = in(), v = in();\\n e[u].push_back(v);\\n e[v].push_back(u);\\n }\\n dfs(1, 0);\\n int ans = 0;\\n for (int i = (2); i <= (int)(n); ++i) ans += (f[i].second == 1);\\n int A = 0, B = 0;\\n for (auto v : e[1]) {\\n A += f[v].first;\\n B += f[v].second;\\n }\\n if (B == 0 && A >= 1) {\\n ans -= A - 1;\\n } else {\\n ans -= A;\\n }\\n printf(\\\"%d\\\\n\\\", ans);\\n}\\nint main() {\\n int T = 1;\\n T = in();\\n Initialization();\\n for (int _ = (1); _ <= (int)(T); ++_) solve(_);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Consider a simplified penalty phase at the end of a football match.\\n\\nA penalty phase consists of at most 10 kicks, the first team takes the first kick, the second team takes the second kick, then the first team takes the third kick, and so on. The team that scores more goals wins; if both teams score the same number of goals, the game results in a tie (note that it goes against the usual football rules). The penalty phase is stopped if one team has scored more goals than the other team could reach with all of its remaining kicks. For example, if after the 7-th kick the first team has scored 1 goal, and the second team has scored 3 goals, the penalty phase ends — the first team cannot reach 3 goals.\\n\\nYou know which player will be taking each kick, so you have your predictions for each of the 10 kicks. These predictions are represented by a string s consisting of 10 characters. Each character can either be 1, 0, or ?. This string represents your predictions in the following way:\\n\\n * if s_i is 1, then the i-th kick will definitely score a goal; \\n * if s_i is 0, then the i-th kick definitely won't score a goal; \\n * if s_i is ?, then the i-th kick could go either way. \\n\\n\\n\\nBased on your predictions, you have to calculate the minimum possible number of kicks there can be in the penalty phase (that means, the earliest moment when the penalty phase is stopped, considering all possible ways it could go). Note that the referee doesn't take into account any predictions when deciding to stop the penalty phase — you may know that some kick will\\/won't be scored, but the referee doesn't.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 1 000) — the number of test cases.\\n\\nEach test case is represented by one line containing the string s, consisting of exactly 10 characters. Each character is either 1, 0, or ?.\\n\\nOutput\\n\\nFor each test case, print one integer — the minimum possible number of kicks in the penalty phase.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n1?0???1001\\n1111111111\\n??????????\\n0100000000\\n\\n\\nOutput\\n\\n\\n7\\n10\\n6\\n9\\n\\nNote\\n\\nConsider...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst long long N = 100005;\\nvoid solve() {\\n long long n, k, i, ans = 0, a = 0, b = 0, c = 0, d = 0;\\n string s;\\n cin >> s;\\n string t = s;\\n for (i = 0; i < 10; i++) {\\n if (i % 2 == 0) {\\n if (s[i] == '?') s[i] = '1';\\n if (t[i] == '?') t[i] = '0';\\n } else {\\n if (s[i] == '?') s[i] = '0';\\n if (t[i] == '?') t[i] = '1';\\n }\\n }\\n for (i = 0; i < 10; i++) {\\n if (i % 2 == 0) {\\n if (s[i] == '1') a++;\\n if (t[i] == '1') c++;\\n } else {\\n if (s[i] == '1') b++;\\n if (t[i] == '1') d++;\\n }\\n if (a - b > (10 - i) \\/ 2 || c - d > (10 - i) \\/ 2 || b - a > (9 - i) \\/ 2 ||\\n d - c > (9 - i) \\/ 2) {\\n cout << i + 1 << \\\"\\\\n\\\";\\n return;\\n }\\n }\\n cout << 10 << \\\"\\\\n\\\";\\n}\\nint32_t main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n long long t = 1;\\n cin >> t;\\n for (long long i = 1; i <= t; i++) {\\n solve();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"YouKn0wWho has an integer sequence a_1, a_2, … a_n. Now he will split the sequence a into one or more consecutive subarrays so that each element of a belongs to exactly one subarray. Let k be the number of resulting subarrays, and h_1, h_2, …, h_k be the lengths of the longest increasing subsequences of corresponding subarrays.\\n\\nFor example, if we split [2, 5, 3, 1, 4, 3, 2, 2, 5, 1] into [2, 5, 3, 1, 4], [3, 2, 2, 5], [1], then h = [3, 2, 1].\\n\\nYouKn0wWho wonders if it is possible to split the sequence a in such a way that the [bitwise XOR](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#XOR) of h_1, h_2, …, h_k is equal to 0. You have to tell whether it is possible.\\n\\nThe longest increasing subsequence (LIS) of a sequence b_1, b_2, …, b_m is the longest sequence of valid indices i_1, i_2, …, i_k such that i_1 < i_2 < … < i_k and b_{i_1} < b_{i_2} < … < b_{i_k}. For example, the LIS of [2, 5, 3, 3, 5] is [2, 3, 5], which has length 3.\\n\\nAn array c is a subarray of an array b if c can be obtained from b by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10 000) — the number of test cases.\\n\\nThe first line of each test case contains a single integer n (2 ≤ n ≤ 10^5).\\n\\nThe second line of each test case contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^9).\\n\\nIt is guaranteed that the sum of n over all test cases doesn't exceed 3 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print \\\"YES\\\" (without quotes) if it is possible to split into subarrays in the desired way, print \\\"NO\\\" (without quotes) otherwise. You can print each letter in any register (upper or lower).\\n\\nExample\\n\\nInput\\n\\n\\n4\\n7\\n1 3 4 2 2 1 5\\n3\\n1 3 4\\n5\\n1 3 2 4 2\\n4\\n4 3 2 1\\n\\n\\nOutput\\n\\n\\nYES\\nNO\\nYES\\nYES\\n\\nNote\\n\\nIn the first test case, YouKn0wWho can split the sequence in the following way: [1, 3, 4], [2, 2], [1, 5]. This way, the LIS lengths are h = [3, 1, 2], and the bitwise XOR of the LIS lengths is 3 ⊕ 1 ⊕ 2 = 0.\\n\\nIn the second test...\",\"targets\":\"\\/\\/ Problem: B. XOR Specia-LIS-t\\n\\/\\/ Contest: Codeforces - Codeforces Round #752 (Div. 2)\\n\\/\\/ URL: https:\\/\\/codeforces.com\\/contest\\/1604\\/problem\\/B\\n\\/\\/ Memory Limit: 256 MB\\n\\/\\/ Time Limit: 1000 ms\\n\\/\\/ \\n\\/\\/ Powered by CP Editor (https:\\/\\/cpeditor.org)\\n\\nimport java.io.*;\\nimport java.util.*;\\n\\nimport static java.lang.Math.max;\\nimport static java.lang.Math.min;\\nimport static java.lang.Math.abs;\\n\\n\\n\\npublic class Main {\\n\\n private void preparation() {\\n\\n }\\n\\n\\n private void clear() {\\n\\n }\\n\\n private void solve() throws Exception {\\n rf();\\n int n = ri();\\n int [] data = new int[n];\\n rf();\\n for(int i = 0; i < n; i++){\\n \\tdata[i] = ri();\\n }\\n if(n % 2 == 0){\\n \\taddAns(\\\"YES\\\");\\n \\treturn ;\\n }\\n boolean flag = false;\\n for(int i = 1; i < n; i++){\\n \\tif(data[i] <= data[i - 1]){\\n \\t\\tflag = true;\\n \\t\\tbreak;\\n \\t}\\n }\\n if(flag){\\n \\taddAns(\\\"YES\\\");\\n }else{\\n \\taddAns(\\\"NO\\\");\\n }\\n\\t\\t\\n }\\n\\n private void run() throws Exception {\\n\\t\\t\\n int T = 1;\\n\\t\\trf();\\n\\t\\tT = ri();\\n\\t\\t\\n\\t\\tpreparation();\\n while (T-- > 0) {\\n solve();\\n if (T != 0) {\\n clear();\\n }\\n }\\n printAns();\\n }\\n\\n public static void main(String[] args) throws Exception {\\n new Main().run();\\n }\\n\\n StringBuilder sb = new StringBuilder();\\n BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));\\n StringTokenizer strT;\\n\\n\\tprivate void addAns(int a){\\n\\t\\tsb.append(a + \\\"\\\\n\\\");\\n\\t}\\n\\t\\n\\tprivate void addAns(long a){\\n\\t\\tsb.append(a + \\\"\\\\n\\\");\\n\\t}\\n\\t\\n\\tprivate void addAns(String s){\\n\\t\\tsb.append(s + \\\"\\\\n\\\");\\n\\t}\\n\\n private void rf() throws IOException {\\n strT = new StringTokenizer(infile.readLine());\\n }\\n\\n\\n private int ri() {\\n return Integer.parseInt(strT.nextToken());\\n }\\n\\n private long rl() {\\n return Long.parseLong(strT.nextToken());\\n }\\n\\n\\tprivate char [] rs2c(){\\n\\t\\treturn strT.nextToken().toCharArray();\\n\\t}\\n\\t\\n\\tprivate...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given a sequence a_1, a_2, ..., a_n consisting of n pairwise distinct positive integers.\\n\\nFind \\\\left⌊ \\\\frac n 2 \\\\right⌋ different pairs of integers x and y such that: \\n\\n * x ≠ y; \\n * x and y appear in a; \\n * x~mod~y doesn't appear in a. \\n\\n\\n\\nNote that some x or y can belong to multiple pairs.\\n\\n⌊ x ⌋ denotes the floor function — the largest integer less than or equal to x. x~mod~y denotes the remainder from dividing x by y.\\n\\nIf there are multiple solutions, print any of them. It can be shown that at least one solution always exists.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.\\n\\nThe first line of each testcase contains a single integer n (2 ≤ n ≤ 2 ⋅ 10^5) — the length of the sequence.\\n\\nThe second line of each testcase contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^6).\\n\\nAll numbers in the sequence are pairwise distinct. The sum of n over all testcases doesn't exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nThe answer for each testcase should contain \\\\left⌊ \\\\frac n 2 \\\\right⌋ different pairs of integers x and y such that x ≠ y, x and y appear in a and x~mod~y doesn't appear in a. Print the pairs one after another.\\n\\nYou can print the pairs in any order. However, the order of numbers in the pair should be exactly such that the first number is x and the second number is y. All pairs should be pairwise distinct.\\n\\nIf there are multiple solutions, print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n2\\n1 4\\n4\\n2 8 3 4\\n5\\n3 8 5 9 7\\n6\\n2 7 5 3 4 8\\n\\n\\nOutput\\n\\n\\n4 1\\n8 2\\n8 4\\n9 5\\n7 5\\n8 7\\n4 3\\n5 2\\n\\nNote\\n\\nIn the first testcase there are only two pairs: (1, 4) and (4, 1). \\\\left⌊ \\\\frac 2 2 \\\\right⌋=1, so we have to find one pair. 1~mod~4=1, and 1 appears in a, so that pair is invalid. Thus, the only possible answer is a pair (4, 1).\\n\\nIn the second testcase, we chose pairs 8~mod~2=0 and 8~mod~4=0. 0 doesn't appear in a, so that answer is valid. There are multiple possible answers for that testcase.\\n\\nIn the third testcase, the chosen pairs are 9~mod~5=4 and 7~mod~5=2. Neither 4, nor 2, appears in a, so that...\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.io.PrintWriter;\\nimport java.math.BigInteger;\\nimport java.util.ArrayList;\\nimport java.util.Arrays;\\nimport java.util.Comparator;\\nimport java.util.HashMap;\\nimport java.util.HashSet;\\nimport java.util.Random;\\nimport java.util.Stack;\\nimport java.util.StringTokenizer;\\nimport java.util.TreeMap;\\n\\n\\/\\/ CFPS -> CodeForcesProblemSet\\npublic final class CFPS {\\n\\tstatic FastReader fr = new FastReader();\\n\\tstatic PrintWriter out = new PrintWriter(System.out);\\n\\tstatic final int gigamod = 1000000007;\\n\\tstatic int t = 1;\\n\\tstatic double epsilon = 0.0000001;\\n\\t\\n\\tpublic static void main(String[] args) {\\n\\t\\tt = fr.nextInt();\\n\\t\\tOUTER: \\n\\t\\tfor (int tc = 0; tc < t; tc++) {\\n\\t\\t\\t\\n\\t\\t\\tint n = fr.nextInt();\\n\\t\\t\\tint[] arr = fr.nextIntArray(n);\\n\\t\\t\\t\\n\\t\\t\\t\\/\\/ Observations: \\n\\t\\t\\t\\n\\t\\t\\t\\/\\/ 1. If x < y, x mod y will be 'x' and the pair will be invalid.\\n\\t\\t\\t\\n\\t\\t\\t\\/\\/ 2. x != y\\n\\t\\t\\t\\n\\t\\t\\t\\/\\/ 3. x > y for sure.\\n\\t\\t\\t\\n\\t\\t\\tsort(arr);\\n\\t\\t\\t\\/\\/ out.println(toString(arr));\\n\\t\\t\\t\\n\\t\\t\\t\\/\\/ 4. If there is a 1 in the array, since (anything mod 1) == 0, we make pairs\\n\\t\\t\\t\\/\\/ with 1 right away.\\n\\t\\t\\t\\n\\t\\t\\t\\/\\/ 5. The key to solve the problem will be to try to make mod equal to zero and 1.\\n\\t\\t\\t\\n\\t\\t\\tint pairCtr = 0;\\n\\t\\t\\tif (arr[0] == 1) {\\n\\t\\t\\t\\tint idx = 1;\\n\\t\\t\\t\\twhile (pairCtr < n \\/ 2) {\\n\\t\\t\\t\\t\\tpairCtr++;\\n\\t\\t\\t\\t\\tout.println(arr[idx++] + \\\" \\\" + 1);\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tcontinue OUTER;\\n\\t\\t\\t}\\n\\t\\t\\t\\n\\t\\t\\tHashSet content = new HashSet<>();\\n\\t\\t\\tfor (int i : arr)\\n\\t\\t\\t\\tcontent.add(i);\\n\\t\\t\\t\\n\\t\\t\\tfor (int i = 0; i < n; i++)\\n\\t\\t\\t\\tfor (int j = i + 1; j < n; j++) {\\n\\t\\t\\t\\t\\t\\/\\/ Checking if 'j' and 'i' make a pair.\\n\\t\\t\\t\\t\\tif (!content.contains(arr[j] % arr[i])) {\\n\\t\\t\\t\\t\\t\\tpairCtr++;\\n\\t\\t\\t\\t\\t\\tout.println(arr[j] + \\\" \\\" + arr[i]);\\n\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\tif (pairCtr == n \\/ 2) continue OUTER;\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t}\\n\\t\\tout.close();\\n\\t}\\n\\t\\n\\t\\/\\/ Manual implementation of RB-BST for C++ PBDS functionality.\\n\\t\\/\\/ Modification required according to requirements.\\n\\tpublic static final class RedBlackCountSet {\\n\\t\\t\\/\\/ Colors for Nodes:\\n\\t\\tprivate static final boolean RED = true;\\n\\t\\tprivate...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in PYTHON3?\\nEzzat has an array of n integers (maybe negative). He wants to split it into two non-empty subsequences a and b, such that every element from the array belongs to exactly one subsequence, and the value of f(a) + f(b) is the maximum possible value, where f(x) is the average of the subsequence x. \\n\\nA sequence x is a subsequence of a sequence y if x can be obtained from y by deletion of several (possibly, zero or all) elements.\\n\\nThe average of a subsequence is the sum of the numbers of this subsequence divided by the size of the subsequence.\\n\\nFor example, the average of [1,5,6] is (1+5+6)\\/3 = 12\\/3 = 4, so f([1,5,6]) = 4.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^3)— the number of test cases. Each test case consists of two lines.\\n\\nThe first line contains a single integer n (2 ≤ n ≤ 10^5).\\n\\nThe second line contains n integers a_1, a_2, …, a_n (-10^9 ≤ a_i ≤ 10^9).\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 3⋅10^5.\\n\\nOutput\\n\\nFor each test case, print a single value — the maximum value that Ezzat can achieve.\\n\\nYour answer is considered correct if its absolute or relative error does not exceed 10^{-6}.\\n\\nFormally, let your answer be a, and the jury's answer be b. Your answer is accepted if and only if \\\\frac{|a - b|}{max{(1, |b|)}} ≤ 10^{-6}.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n3 1 2\\n3\\n-7 -6 -6\\n3\\n2 2 2\\n4\\n17 3 5 -3\\n\\n\\nOutput\\n\\n\\n4.500000000\\n-12.500000000\\n4.000000000\\n18.666666667\\n\\nNote\\n\\nIn the first test case, the array is [3, 1, 2]. These are all the possible ways to split this array: \\n\\n * a = [3], b = [1,2], so the value of f(a) + f(b) = 3 + 1.5 = 4.5. \\n * a = [3,1], b = [2], so the value of f(a) + f(b) = 2 + 2 = 4. \\n * a = [3,2], b = [1], so the value of f(a) + f(b) = 2.5 + 1 = 3.5. \\n\\nTherefore, the maximum possible value 4.5.\\n\\nIn the second test case, the array is [-7, -6, -6]. These are all the possible ways to split this array: \\n\\n * a = [-7], b = [-6,-6], so the value of f(a) + f(b) = (-7) + (-6) = -13. \\n * a = [-7,-6], b = [-6], so the value of f(a) + f(b) = (-6.5) + (-6) =...\",\"targets\":\"t=int(input())\\nfor tt in range(t):\\n n=int(input())\\n arr=list(map(int,input().split()))\\n arr.sort()\\n ans=(sum(arr[:-1])\\/(n-1)+arr[-1])\\n print(\\\"{:.9f}\\\".format(ans))\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A process RAM is a sequence of bytes that are indexed from 1 to n. Polycarpus's program contains such instructions as \\\"memset\\\", that is, the operations of filling memory cells on a segment with some value. The details are: the code only contains m instructions that look like \\\"set13 a_i l_i\\\". Instruction i fills a continuous memory segment of length li, starting from cell number ai, (that it cells with numbers ai, ai + 1, ..., ai + li - 1) with values 13.\\n\\nIn Polycarpus's code, the optimizer's task is to remove the maximum number of instructions from his code in such a way that the remaining instructions set value 13 in all the memory bytes that got this value from the code before the optimization. Also, the value 13 should be set only in the memory bytes that got this value from the code before the optimization. Your task is to implement the optimizer for such program.\\n\\nInput\\n\\nThe first line contains integers n and m (1 ≤ n ≤ 2·106, 1 ≤ m ≤ 2·105) — the number of bytes (memory cells) and the number of instructions in Polycarpus's code. Then m lines follow, each line contains a pair of integers ai, li (1 ≤ ai ≤ n, 1 ≤ li ≤ n - ai + 1).\\n\\nOutput\\n\\nPrint in the first line the sought maximum number of instructions that can be removed from the code. In the second line print the numbers of the instructions. The instructions are numbered from 1 to m in the order they appeared in the input. If there are multiple solutions, print any of them.\\n\\nExamples\\n\\nInput\\n\\n10 4\\n3 3\\n3 1\\n4 1\\n9 2\\n\\n\\nOutput\\n\\n2\\n2 3 \\n\\nInput\\n\\n1 1\\n1 1\\n\\n\\nOutput\\n\\n0\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nstruct Node {\\n int l, r, i;\\n} a[2000010], b[2000010];\\nint n, M, m, ans, r;\\nbool c[2000010];\\ninline int read() {\\n int x = 0, f = 1;\\n char ch = getchar();\\n while (ch < '0' || ch > '9') {\\n if (ch == '-') f = -1;\\n ch = getchar();\\n }\\n while (ch >= '0' && ch <= '9') {\\n x = x * 10 + ch - '0';\\n ch = getchar();\\n }\\n return x * f;\\n}\\nbool cmp(Node a, Node b) {\\n if (a.l != b.l) return a.l < b.l;\\n return a.r > b.r;\\n}\\nint main() {\\n n = read();\\n m = read();\\n for (int i = 1; i <= m; i++) {\\n a[i].l = read();\\n a[i].r = read();\\n a[i].r = a[i].l + a[i].r - 1;\\n a[i].i = i;\\n }\\n sort(a + 1, a + 1 + m, cmp);\\n r = a[1].r;\\n for (int i = 2; i <= m; i++)\\n if (a[i].r <= r)\\n c[i] = true;\\n else\\n r = a[i].r;\\n r = 0;\\n for (int i = 1; i <= m; i++)\\n if (!c[i]) b[++r] = a[i];\\n M = m;\\n m = r;\\n memset(c, 0, sizeof(c));\\n int l = 1;\\n r = 2;\\n c[a[1].i] = true;\\n while (l <= m) {\\n while (r <= m && b[l].r + 1 >= b[r].l) r++;\\n r--;\\n if (l == r)\\n l++, c[b[l].i] = 1, ans++;\\n else\\n c[b[r].i] = 1, l = r, ans++;\\n }\\n printf(\\\"%d\\\\n\\\", M - ans);\\n for (int i = 1; i <= M; i++)\\n if (!c[i]) printf(\\\"%d \\\", i);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given an integer k and a string s that consists only of characters 'a' (a lowercase Latin letter) and '*' (an asterisk).\\n\\nEach asterisk should be replaced with several (from 0 to k inclusive) lowercase Latin letters 'b'. Different asterisk can be replaced with different counts of letter 'b'.\\n\\nThe result of the replacement is called a BA-string.\\n\\nTwo strings a and b are different if they either have different lengths or there exists such a position i that a_i ≠ b_i.\\n\\nA string a is lexicographically smaller than a string b if and only if one of the following holds: \\n\\n * a is a prefix of b, but a ≠ b; \\n * in the first position where a and b differ, the string a has a letter that appears earlier in the alphabet than the corresponding letter in b. \\n\\n\\n\\nNow consider all different BA-strings and find the x-th lexicographically smallest of them.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 2000) — the number of testcases.\\n\\nThe first line of each testcase contains three integers n, k and x (1 ≤ n ≤ 2000; 0 ≤ k ≤ 2000; 1 ≤ x ≤ 10^{18}). n is the length of string s.\\n\\nThe second line of each testcase is a string s. It consists of n characters, each of them is either 'a' (a lowercase Latin letter) or '*' (an asterisk).\\n\\nThe sum of n over all testcases doesn't exceed 2000. For each testcase x doesn't exceed the total number of different BA-strings. String s contains at least one character 'a'.\\n\\nOutput\\n\\nFor each testcase, print a single string, consisting only of characters 'b' and 'a' (lowercase Latin letters) — the x-th lexicographically smallest BA-string.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n2 4 3\\na*\\n4 1 3\\na**a\\n6 3 20\\n**a***\\n\\n\\nOutput\\n\\n\\nabb\\nabba\\nbabbbbbbbbb\\n\\nNote\\n\\nIn the first testcase of the example, BA-strings ordered lexicographically are: \\n\\n 1. a\\n 2. ab\\n 3. abb\\n 4. abbb\\n 5. abbbb\\n\\n\\n\\nIn the second testcase of the example, BA-strings ordered lexicographically are: \\n\\n 1. aa\\n 2. aba\\n 3. abba\\n\\n\\n\\nNote that string \\\"aba\\\" is only counted once, even though there are two ways to replace asterisks with characters...\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"import os\\nimport sys\\nfrom io import BytesIO, IOBase\\n\\n_print = print\\nBUFSIZE = 8192\\n\\n\\ndef dbg(*args, **kwargs):\\n _print('\\\\33[95m', end='')\\n _print(*args, **kwargs)\\n _print('\\\\33[0m', end='')\\n\\n\\nclass FastIO(IOBase):\\n newlines = 0\\n\\n def __init__(self, file):\\n self._fd = file.fileno()\\n self.buffer = BytesIO()\\n self.writable = 'x' in file.mode or 'r' not in file.mode\\n self.write = self.buffer.write if self.writable else None\\n\\n def read(self):\\n while True:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n if not b:\\n break\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines = 0\\n return self.buffer.read()\\n\\n def readline(self):\\n while self.newlines == 0:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n self.newlines = b.count(b'\\\\n') + (not b)\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines -= 1\\n return self.buffer.readline()\\n\\n def flush(self):\\n if self.writable:\\n os.write(self._fd, self.buffer.getvalue())\\n self.buffer.truncate(0), self.buffer.seek(0)\\n\\n\\nclass IOWrapper(IOBase):\\n def __init__(self, file):\\n self.buffer = FastIO(file)\\n self.flush = self.buffer.flush\\n self.writable = self.buffer.writable\\n self.write = lambda s: self.buffer.write(s.encode('ascii'))\\n self.read = lambda: self.buffer.read().decode('ascii')\\n self.readline = lambda: self.buffer.readline().decode('ascii')\\n\\n\\ndef inp():\\n return sys.stdin.readline().rstrip()\\n\\n\\ndef mpint():\\n return map(int, inp().split(' '))\\n\\n\\ndef itg():\\n return int(inp())\\n\\n\\n# ############################## import\\ndef split_consecutive(sorted_data, cmp=lambda a, b: a == b):\\n result = []\\n group = []\\n prev = None\\n for item in sorted_data:\\n if...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Andrey's favourite number is n. Andrey's friends gave him two identical numbers n as a New Year present. He hung them on a wall and watched them adoringly.\\n\\nThen Andrey got bored from looking at the same number and he started to swap digits first in one, then in the other number, then again in the first number and so on (arbitrary number of changes could be made in each number). At some point it turned out that if we sum the resulting numbers, then the number of zeroes with which the sum will end would be maximum among the possible variants of digit permutations in those numbers.\\n\\nGiven number n, can you find the two digit permutations that have this property?\\n\\nInput\\n\\nThe first line contains a positive integer n — the original number. The number of digits in this number does not exceed 105. The number is written without any leading zeroes.\\n\\nOutput\\n\\nPrint two permutations of digits of number n, such that the sum of these numbers ends with the maximum number of zeroes. The permutations can have leading zeroes (if they are present, they all should be printed). The permutations do not have to be different. If there are several answers, print any of them.\\n\\nExamples\\n\\nInput\\n\\n198\\n\\n\\nOutput\\n\\n981\\n819\\n\\n\\nInput\\n\\n500\\n\\n\\nOutput\\n\\n500\\n500\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nconst int maxN = 20, inf = 1000 * 1000 * 1000;\\nint i, n, ans, t, j, k, a[maxN], b[maxN], c[maxN], d[maxN], nul, h;\\nbool f;\\nstring s;\\nint main() {\\n getline(cin, s);\\n n = s.length();\\n for (i = 0; i < n; ++i) {\\n ++a[s[i] - '0'];\\n }\\n j = 0;\\n ans = 0;\\n k = 0;\\n for (i = 1; i <= 9; ++i) {\\n for (j = 0; j < 10; ++j) {\\n b[j] = a[j];\\n c[j] = a[j];\\n }\\n t = 0;\\n if (b[i] > 0 && c[10 - i] > 0) {\\n --b[i];\\n --c[10 - i];\\n ++t;\\n for (j = 0; j < 10; ++j) {\\n t += min(b[j], c[9 - j]);\\n }\\n if (t > ans) {\\n ans = t;\\n k = i;\\n }\\n }\\n }\\n for (i = 0; i < 10; ++i) {\\n b[i] = a[i];\\n c[i] = a[i];\\n }\\n f = false;\\n if (b[k] > 0 && c[10 - k] > 0) {\\n --b[k];\\n --c[10 - k];\\n f = true;\\n }\\n h = min(c[0] - min(b[9], c[0]), b[0] - min(b[0], c[9]));\\n for (i = 0; i < b[0] - h - min(b[0], c[9]); ++i) {\\n cout << 0;\\n }\\n for (i = 1; i < 10; ++i) {\\n for (j = 0; j < b[i] - min(b[i], c[9 - i]); ++j) {\\n cout << i;\\n ++d[i];\\n }\\n }\\n for (i = 0; i < 10; ++i) {\\n for (j = 0; j < min(b[i], c[9 - i]); ++j) {\\n cout << i;\\n ++d[i];\\n }\\n }\\n if (f) {\\n cout << k;\\n ++d[k];\\n }\\n for (i = 0; i < h; ++i) {\\n cout << 0;\\n ++d[0];\\n }\\n cout << endl;\\n for (i = 0; i < c[0] - h - min(b[9], c[0]); ++i) {\\n cout << 0;\\n }\\n for (i = 1; i < 10; ++i) {\\n for (j = 0; j < c[i] - min(b[9 - i], c[i]); ++j) {\\n cout << i;\\n --d[i];\\n }\\n }\\n for (i = 9; i >= 0; --i) {\\n for (j = 0; j < min(b[9 - i], c[i]); ++j) {\\n cout << i;\\n --d[i];\\n }\\n }\\n if (f) {\\n cout << 10 - k;\\n --d[10 - k];\\n }\\n for (i = 0; i < h; ++i) {\\n cout << 0;\\n --d[0];\\n }\\n cout << endl;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nCertainly, everyone is familiar with tic-tac-toe game. The rules are very simple indeed. Two players take turns marking the cells in a 3 × 3 grid (one player always draws crosses, the other — noughts). The player who succeeds first in placing three of his marks in a horizontal, vertical or diagonal line wins, and the game is finished. The player who draws crosses goes first. If the grid is filled, but neither Xs, nor 0s form the required line, a draw is announced.\\n\\nYou are given a 3 × 3 grid, each grid cell is empty, or occupied by a cross or a nought. You have to find the player (first or second), whose turn is next, or print one of the verdicts below: \\n\\n * illegal — if the given board layout can't appear during a valid game; \\n * the first player won — if in the given board layout the first player has just won; \\n * the second player won — if in the given board layout the second player has just won; \\n * draw — if the given board layout has just let to a draw. \\n\\nInput\\n\\nThe input consists of three lines, each of the lines contains characters \\\".\\\", \\\"X\\\" or \\\"0\\\" (a period, a capital letter X, or a digit zero).\\n\\nOutput\\n\\nPrint one of the six verdicts: first, second, illegal, the first player won, the second player won or draw.\\n\\nExamples\\n\\nInput\\n\\nX0X\\n.0.\\n.X.\\n\\n\\nOutput\\n\\nsecond\",\"targets\":\"#include \\nusing namespace std;\\nstring x[3];\\nint getWin(char c) {\\n int ans = 0;\\n if (x[0][0] == x[0][1] && x[0][1] == x[0][2] && x[0][0] == c) ans++;\\n if (x[0][0] == x[1][1] && x[1][1] == x[2][2] && x[0][0] == c) ans++;\\n if (x[0][0] == x[1][0] && x[1][0] == x[2][0] && x[0][0] == c) ans++;\\n if (x[2][0] == x[2][1] && x[2][1] == x[2][2] && x[2][0] == c) ans++;\\n if (x[0][2] == x[1][2] && x[1][2] == x[2][2] && x[0][2] == c) ans++;\\n if (x[2][0] == x[1][1] && x[1][1] == x[0][2] && x[2][0] == c) ans++;\\n if (x[0][1] == x[1][1] && x[1][1] == x[2][1] && x[0][1] == c) ans++;\\n if (x[1][0] == x[1][1] && x[1][1] == x[1][2] && x[1][0] == c) ans++;\\n return ans;\\n}\\nint main() {\\n int xc = 0, oc = 0;\\n for (int i = 0; i < 3; i++) {\\n cin >> x[i];\\n for (int j = 0; j < 3; j++) {\\n if (x[i][j] == 'X') xc++;\\n if (x[i][j] == '0') oc++;\\n }\\n }\\n if (xc - oc > 1 || oc > xc) {\\n cout << \\\"illegal\\\" << endl;\\n return 0;\\n }\\n int xw = getWin('X');\\n int ow = getWin('0');\\n if (xw == 1 && ow == 1) {\\n cout << \\\"illegal\\\" << endl;\\n return 0;\\n }\\n if (xw >= 1) {\\n if (xc > oc)\\n cout << \\\"the first player won\\\" << endl;\\n else\\n cout << \\\"illegal\\\" << endl;\\n return 0;\\n }\\n if (ow >= 1) {\\n if (xc == oc)\\n cout << \\\"the second player won\\\" << endl;\\n else\\n cout << \\\"illegal\\\" << endl;\\n return 0;\\n }\\n if (xc + oc == 9) {\\n cout << \\\"draw\\\" << endl;\\n return 0;\\n }\\n if (xc == oc) {\\n cout << \\\"first\\\" << endl;\\n return 0;\\n }\\n cout << \\\"second\\\" << endl;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"\\n\\nSenor Vorpal Kickass'o invented an innovative method to encrypt integer sequences of length n. To encrypt a sequence, one has to choose a secret sequence , that acts as a key.\\n\\nVorpal is very selective, so the key should be such a sequence bi, that its cyclic shifts are linearly independent, that is, there is no non-zero set of coefficients x0, x1, ..., xn - 1, such that for all k at the same time.\\n\\nAfter that for a sequence you should build the following cipher:\\n\\n\\n\\nIn other words, you are to compute the quadratic deviation between each cyclic shift of bi and the sequence ai. The resulting sequence is the Kickass's cipher. The cipher is in development right now and Vorpal wants to decipher a sequence after it has been encrypted. You are to solve this problem for him. You are given sequences ci and bi. You are to find all suitable sequences ai.\\n\\nInput\\n\\nThe first line contains a single integer n ().\\n\\nThe second line contains n integers b0, b1, ..., bn - 1 ().\\n\\nThe third line contains n integers c0, c1, ..., cn - 1 ().\\n\\nIt is guaranteed that all cyclic shifts of sequence bi are linearly independent.\\n\\nOutput\\n\\nIn the first line print a single integer k — the number of sequences ai, such that after encrypting them with key bi you get the sequence ci.\\n\\nAfter that in each of k next lines print n integers a0, a1, ..., an - 1. Print the sequences in lexicographical order.\\n\\nNote that k could be equal to 0.\\n\\nExamples\\n\\nInput\\n\\n1\\n1\\n0\\n\\n\\nOutput\\n\\n1\\n1\\n\\n\\nInput\\n\\n1\\n100\\n81\\n\\n\\nOutput\\n\\n2\\n91\\n109\\n\\n\\nInput\\n\\n3\\n1 1 3\\n165 185 197\\n\\n\\nOutput\\n\\n2\\n-6 -9 -1\\n8 5 13\",\"targets\":\"#include \\nusing namespace std;\\nconst int oo = 0x3f3f3f3f;\\nconst long long ooo = 9223372036854775807ll;\\nconst int _cnt = 1000 * 1000 + 7;\\nconst int _p = 1000 * 1000 * 1000 + 7;\\nconst int N = 1500105;\\nconst double PI = acos(-1.0);\\nconst double eps = 1e-9;\\nint o(int x) { return x % _p; }\\nint gcd(int a, int b) { return b ? gcd(b, a % b) : a; }\\nint lcm(int a, int b) { return a \\/ gcd(a, b) * b; }\\nvoid file_put() {\\n freopen(\\\"filename.in\\\", \\\"r\\\", stdin);\\n freopen(\\\"filename.out\\\", \\\"w\\\", stdout);\\n}\\nlong long p, g;\\nlong long mul(long long a, long long b) {\\n return a * b - (long long)((long double)a * b \\/ p) * p;\\n}\\nlong long Pow(long long a, long long b) {\\n long long res = 1;\\n for (; b; b >>= 1, a = mul(a, a))\\n if (b & 1) res = mul(res, a);\\n return res;\\n}\\nstruct FT {\\n int rev[N], len;\\n long long w[2][N], W[2][N], F[N], G[N];\\n void Init(int n) {\\n for (len = 1; len < 2 * n; len <<= 1)\\n ;\\n len <<= 1;\\n long long lcm = 1ll * n * len \\/ gcd(n, len);\\n p = lcm + 1;\\n while (p < 100000) p += lcm;\\n for (;; p += lcm) {\\n int chk = 1;\\n for (int j = 2; (long long)j * j <= p && chk; j++)\\n if (p % j == 0) chk = 0;\\n if (chk) break;\\n }\\n for (g = 2;; g++) {\\n int chk = 1;\\n for (int j = 2; 1ll * j * j <= p - 1 && chk; j++)\\n if ((p - 1) % j == 0) {\\n if (Pow(g, j) == 1)\\n chk = 0;\\n else if (Pow(g, (p - 1) \\/ j) == 1)\\n chk = 0;\\n }\\n if (chk) break;\\n }\\n }\\n void preFFT(int n) {\\n long long w0 = Pow(g, (p - 1) \\/ n);\\n int m;\\n w[0][0] = w[1][0] = 1;\\n for (int i = (1); i <= (n - 1); ++i) w[0][i] = mul(w[0][i - 1], w0);\\n for (int i = (1); i <= (n - 1); ++i) w[1][i] = w[0][n - i];\\n for (m = 0; (1 << m) != n; m++)\\n ;\\n rev[0] = 0;\\n for (int i = (1); i <= (n - 1); ++i)\\n rev[i] = (rev[i >> 1] >> 1) | (i & 1) << m - 1;\\n }\\n void FFT(long long *A, int n, int op) {\\n for (int i = (0); i <= (n - 1); ++i)\\n if (i < rev[i]) swap(A[i], A[rev[i]]);\\n for (int i = 1; i < n; i <<= 1)\\n...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"An old document says that a Ninja House in Kanazawa City was in fact a defensive fortress, which was designed like a maze. Its rooms were connected by hidden doors in a complicated manner, so that any invader would become lost. Each room has at least two doors.\\n\\nThe Ninja House can be modeled by a graph, as shown in Figure l. A circle represents a room. Each line connecting two circles represents a door between two rooms.\\n\\n Figure l. Graph Model of Ninja House. | Figure 2. Ninja House exploration.\\n---|---\\n\\nI decided to draw a map, since no map was available. Your mission is to help me draw a map from the record of my exploration.\\n\\nI started exploring by entering a single entrance that was open to the outside. The path I walked is schematically shown in Figure 2, by a line with arrows. The rules for moving between rooms are described below.\\n\\nAfter entering a room, I first open the rightmost door and move to the next room. However, if the next room has already been visited, I close the door without entering, and open the next rightmost door, and so on. When I have inspected all the doors of a room, I go back through the door I used to enter the room.\\n\\nI have a counter with me to memorize the distance from the first room. The counter is incremented when I enter a new room, and decremented when I go back from a room. In Figure 2, each number in parentheses is the value of the counter when I have entered the room, i.e., the distance from the first room. In contrast, the numbers not in parentheses represent the order of my visit.\\n\\nI take a record of my exploration. Every time I open a door, I record a single number, according to the following rules.\\n\\n1. If the opposite side of the door is a new room, I record the number of doors in that room, which is a positive number.\\n2. If it is an already visited room, say R, I record ``the distance of R from the first room'' minus ``the distance of the current room from the first room'', which is a negative number.\\n\\n\\n\\nIn the example shown in Figure 2, as the first...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\ntypedef long long ll;\\n\\nint main() {\\n int T;\\n cin >> T;\\n for(;T>0;T--){\\n vector a;\\n for(int x=1; x!=0;){\\n cin >> x;\\n if(x!=0) a.push_back(x);\\n }\\n int m = 1;\\n stack st;\\n vector deg, depth;\\n vector > g;\\n st.push(0);\\n depth.push_back(0);\\n deg.push_back(a[0]);\\n g.push_back({});\\n a.erase(a.begin());\\n for(auto x : a){\\n int prev = st.top();\\n if(x > 0){\\n deg.push_back(x);\\n depth.push_back(depth[prev]+1);\\n g.push_back({});\\n g[m].push_back(prev);\\n g[prev].push_back(m);\\n deg[m]--;\\n deg[prev]--;\\n st.push(m);\\n m++;\\n }\\n else{\\n for(int i=0;i0){\\n g[i].push_back(prev);\\n g[prev].push_back(i);\\n deg[i]--;\\n deg[prev]--;\\n break;\\n }\\n }\\n }\\n while(!st.empty() && deg[st.top()]==0) st.pop();\\n }\\n for(int i=0;i\\nusing namespace std;\\nconst int N = 52, mod = 1e9 + 7;\\nint c[N], dp[N][N][N], power[N];\\ninline long long mul(int a, int b) { return 1LL * a * b % mod; }\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n int n, p;\\n cin >> n >> p;\\n for (int i = 0; i < n; i++) cin >> c[i];\\n dp[0][0][0] = 1;\\n power[0] = 1;\\n for (int i = 1; i < N; i++) power[i] = 2LL * power[i - 1] % mod;\\n for (int i = 1; i <= n; i++)\\n for (int j = 0; j <= i; j++)\\n for (int k = 0; k + j <= i; k++) {\\n if (c[i - 1] != 1) {\\n long long ways = 0;\\n if (j) {\\n if (k == 0)\\n ways = power[i - 1];\\n else\\n ways = power[i - 2];\\n dp[i][j][k] += mul(ways, dp[i - 1][j - 1][k]), dp[i][j][k] %= mod;\\n }\\n if (k == 0)\\n ways = 0;\\n else\\n ways = power[i - 2];\\n dp[i][j][k] += mul(ways, dp[i - 1][j][k]), dp[i][j][k] %= mod;\\n }\\n if (c[i - 1] != 0) {\\n long long ways = 0;\\n if (k) {\\n if (j == 0)\\n ways = power[i - 1];\\n else\\n ways = power[i - 2];\\n dp[i][j][k] += mul(ways, dp[i - 1][j][k - 1]) % mod,\\n dp[i][j][k] %= mod;\\n }\\n if (j == 0)\\n ways = 0;\\n else\\n ways = power[i - 2];\\n dp[i][j][k] += mul(ways, dp[i - 1][j][k]) % mod, dp[i][j][k] %= mod;\\n }\\n }\\n int ans = 0;\\n for (int j = 0; j <= n; j++)\\n for (int k = 0; k + j <= n; k++)\\n if ((k + j) % 2 == p) ans += dp[n][j][k], ans %= mod;\\n cout << ans << endl;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given two positive integers n and s. Find the maximum possible median of an array of n non-negative integers (not necessarily distinct), such that the sum of its elements is equal to s.\\n\\nA median of an array of integers of length m is the number standing on the ⌈ {m\\/2} ⌉-th (rounding up) position in the non-decreasing ordering of its elements. Positions are numbered starting from 1. For example, a median of the array [20,40,20,50,50,30] is the ⌈ m\\/2 ⌉-th element of [20,20,30,40,50,50], so it is 30. There exist other definitions of the median, but in this problem we use the described definition.\\n\\nInput\\n\\nThe input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. Description of the test cases follows.\\n\\nEach test case contains a single line with two integers n and s (1 ≤ n, s ≤ 10^9) — the length of the array and the required sum of the elements.\\n\\nOutput\\n\\nFor each test case print a single integer — the maximum possible median.\\n\\nExample\\n\\nInput\\n\\n\\n8\\n1 5\\n2 5\\n3 5\\n2 1\\n7 17\\n4 14\\n1 1000000000\\n1000000000 1\\n\\n\\nOutput\\n\\n\\n5\\n2\\n2\\n0\\n4\\n4\\n1000000000\\n0\\n\\nNote\\n\\nPossible arrays for the first three test cases (in each array the median is underlined):\\n\\n * In the first test case [\\\\underline{5}] \\n * In the second test case [\\\\underline{2}, 3] \\n * In the third test case [1, \\\\underline{2}, 2] \\nSolve the task in JAVA.\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.util.*;\\n\\npublic class B {\\n static class FastReader {\\n BufferedReader br;\\n StringTokenizer st;\\n\\n public FastReader() {\\n br = new BufferedReader(new InputStreamReader(System.in));\\n }\\n\\n String next() {\\n while (st == null || !st.hasMoreElements()) {\\n try {\\n st = new StringTokenizer(br.readLine());\\n } catch (IOException e) {\\n e.printStackTrace();\\n }\\n }\\n return st.nextToken();\\n }\\n\\n ArrayList readIntArrayList(int n) {\\n ArrayList a = new ArrayList<>();\\n for (int i = 0; i < n; i++)\\n a.add(nextInt());\\n return a;\\n }\\n\\n ArrayList readLongArrayList(int n) {\\n ArrayList a = new ArrayList<>();\\n for (int i = 0; i < n; i++)\\n a.add(nextLong());\\n return a;\\n }\\n\\n int[] readIntArray(int n) {\\n int[] a = new int[n];\\n for (int i = 0; i < n; i++)\\n a[i] = nextInt();\\n return a;\\n }\\n\\n long[] readLongArray(int n) {\\n long[] a = new long[n];\\n for (int i = 0; i < n; i++)\\n a[i] = nextLong();\\n return a;\\n }\\n\\n char[] readCharArray(int n) {\\n char[] a = new char[n];\\n for (int i = 0; i < n; i++)\\n a[i] = next().charAt(0);\\n return a;\\n }\\n\\n int nextInt() {\\n return Integer.parseInt(next());\\n }\\n\\n long nextLong() {\\n return Long.parseLong(next());\\n }\\n\\n double nextDouble() {\\n return Double.parseDouble(next());\\n }\\n\\n String nextLine() {\\n String str = \\\"\\\";\\n try {\\n str = br.readLine();\\n } catch (IOException e) {\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Vupsen and Pupsen were gifted an integer array. Since Vupsen doesn't like the number 0, he threw away all numbers equal to 0 from the array. As a result, he got an array a of length n.\\n\\nPupsen, on the contrary, likes the number 0 and he got upset when he saw the array without zeroes. To cheer Pupsen up, Vupsen decided to come up with another array b of length n such that ∑_{i=1}^{n}a_i ⋅ b_i=0. Since Vupsen doesn't like number 0, the array b must not contain numbers equal to 0. Also, the numbers in that array must not be huge, so the sum of their absolute values cannot exceed 10^9. Please help Vupsen to find any such array b!\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. The next 2 ⋅ t lines contain the description of test cases. The description of each test case consists of two lines.\\n\\nThe first line of each test case contains a single integer n (2 ≤ n ≤ 10^5) — the length of the array.\\n\\nThe second line contains n integers a_1, a_2, …, a_n (-10^4 ≤ a_i ≤ 10^4, a_i ≠ 0) — the elements of the array a.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case print n integers b_1, b_2, …, b_n — elements of the array b (|b_1|+|b_2|+… +|b_n| ≤ 10^9, b_i ≠ 0, ∑_{i=1}^{n}a_i ⋅ b_i=0).\\n\\nIt can be shown that the answer always exists.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n2\\n5 5\\n5\\n5 -2 10 -9 4\\n7\\n1 2 3 4 5 6 7\\n\\n\\nOutput\\n\\n\\n1 -1\\n-1 5 1 -1 -1\\n-10 2 2 -3 5 -1 -1\\n\\nNote\\n\\nIn the first test case, 5 ⋅ 1 + 5 ⋅ (-1)=5-5=0. You could also print 3 -3, for example, since 5 ⋅ 3 + 5 ⋅ (-3)=15-15=0\\n\\nIn the second test case, 5 ⋅ (-1) + (-2) ⋅ 5 + 10 ⋅ 1 + (-9) ⋅ (-1) + 4 ⋅ (-1)=-5-10+10+9-4=0.\",\"targets\":\"#include \\nusing namespace std;\\nconst double eps = 1e-8;\\nconst int maxn = 1e6 + 10;\\ninline int gcd(int a, int b) { return !b ? a : gcd(b, a % b); }\\nint b[maxn];\\nstruct a_node {\\n int x;\\n int id;\\n} a[maxn];\\nbool cmp(a_node x, a_node y) { return abs(x.x) < abs(y.x); }\\nint main() {\\n int T;\\n scanf(\\\"%d\\\", &T);\\n while (T--) {\\n int n;\\n scanf(\\\"%d\\\", &n);\\n for (int i = 1; i <= n; ++i) scanf(\\\"%d\\\", &a[i].x), b[i] = 0, a[i].id = i;\\n sort(a + 1, a + n + 1, cmp);\\n if (n % 2) {\\n for (int i = 1; i < n - 2; i += 2) {\\n int tmp = abs(gcd(a[i].x, a[i + 1].x));\\n b[a[i].id] = a[i + 1].x \\/ tmp;\\n b[a[i + 1].id] = (-1) * a[i].x \\/ tmp;\\n }\\n int x = a[n - 1].x + a[n].x, y = a[n - 2].x;\\n int tmp = abs(gcd(x, y));\\n b[a[n - 2].id] = (-1) * (x) \\/ tmp;\\n b[a[n].id] = y \\/ tmp, b[a[n - 1].id] = y \\/ tmp;\\n tmp = abs(gcd(a[n - 2].x, a[n].x));\\n while (b[a[n - 2].id] == 0) {\\n b[a[n - 2].id] -= a[n].x \\/ tmp;\\n b[a[n].id] += a[n - 2].x \\/ tmp;\\n }\\n } else {\\n for (int i = 1; i <= n; i += 2) {\\n int tmp = abs(gcd(a[i].x, a[i + 1].x));\\n b[a[i].id] = a[i + 1].x \\/ tmp;\\n b[a[i + 1].id] = -1 * a[i].x \\/ tmp;\\n }\\n }\\n for (int i = 1; i <= n; ++i) {\\n printf(\\\"%d \\\", b[i]);\\n }\\n printf(\\\"\\\\n\\\");\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A Ministry for Defense sent a general to inspect the Super Secret Military Squad under the command of the Colonel SuperDuper. Having learned the news, the colonel ordered to all n squad soldiers to line up on the parade ground.\\n\\nBy the military charter the soldiers should stand in the order of non-increasing of their height. But as there's virtually no time to do that, the soldiers lined up in the arbitrary order. However, the general is rather short-sighted and he thinks that the soldiers lined up correctly if the first soldier in the line has the maximum height and the last soldier has the minimum height. Please note that the way other solders are positioned does not matter, including the case when there are several soldiers whose height is maximum or minimum. Only the heights of the first and the last soldier are important.\\n\\nFor example, the general considers the sequence of heights (4, 3, 4, 2, 1, 1) correct and the sequence (4, 3, 1, 2, 2) wrong.\\n\\nWithin one second the colonel can swap any two neighboring soldiers. Help him count the minimum time needed to form a line-up which the general will consider correct.\\n\\nInput\\n\\nThe first input line contains the only integer n (2 ≤ n ≤ 100) which represents the number of soldiers in the line. The second line contains integers a1, a2, ..., an (1 ≤ ai ≤ 100) the values of the soldiers' heights in the order of soldiers' heights' increasing in the order from the beginning of the line to its end. The numbers are space-separated. Numbers a1, a2, ..., an are not necessarily different.\\n\\nOutput\\n\\nPrint the only integer — the minimum number of seconds the colonel will need to form a line-up the general will like.\\n\\nExamples\\n\\nInput\\n\\n4\\n33 44 11 22\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n7\\n10 10 58 31 63 40 76\\n\\n\\nOutput\\n\\n10\\n\\nNote\\n\\nIn the first sample the colonel will need to swap the first and second soldier and then the third and fourth soldier. That will take 2 seconds. The resulting position of the soldiers is (44, 33, 22, 11).\\n\\nIn the second sample the colonel may swap the soldiers in the...\\nSolve the task in PYTHON3.\",\"targets\":\"n = int(input())\\na = [int(i) for i in input().split()]\\nc = 0\\nmini = a.index(min(a))\\nmaxi = a.index(max(a))\\ni = maxi\\nwhile a[0] != max(a):\\n t = a[i]\\n a[i] = a[i - 1]\\n a[i - 1] = t\\n c += 1\\n i -= 1\\nfor i in range(n):\\n if a[i] == min(a):\\n mini = i\\nfor i in range(mini, n - 1):\\n t = a[i]\\n a[i] = a[i + 1]\\n a[i + 1] = t\\n c += 1\\nprint(c)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CQXYM is counting permutations length of 2n.\\n\\nA permutation is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice in the array) and [1,3,4] is also not a permutation (n=3 but there is 4 in the array).\\n\\nA permutation p(length of 2n) will be counted only if the number of i satisfying p_ip_2. Because 0\\nusing namespace std;\\nint main() {\\n int t;\\n cin >> t;\\n while (t--) {\\n int n;\\n cin >> n;\\n long long ans = 1, mod = 1e9 + 7;\\n for (int i = 2 * n; i >= 3; i--) {\\n ans = (ans * i) % mod;\\n }\\n ans %= mod;\\n cout << ans << \\\"\\\\n\\\";\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You had n positive integers a_1, a_2, ..., a_n arranged in a circle. For each pair of neighboring numbers (a_1 and a_2, a_2 and a_3, ..., a_{n - 1} and a_n, and a_n and a_1), you wrote down: are the numbers in the pair equal or not.\\n\\nUnfortunately, you've lost a piece of paper with the array a. Moreover, you are afraid that even information about equality of neighboring elements may be inconsistent. So, you are wondering: is there any array a which is consistent with information you have about equality or non-equality of corresponding pairs?\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases. Next t cases follow.\\n\\nThe first and only line of each test case contains a non-empty string s consisting of characters E and\\/or N. The length of s is equal to the size of array n and 2 ≤ n ≤ 50. For each i from 1 to n: \\n\\n * if s_i = E then a_i is equal to a_{i + 1} (a_n = a_1 for i = n); \\n * if s_i = N then a_i is not equal to a_{i + 1} (a_n ≠ a_1 for i = n). \\n\\nOutput\\n\\nFor each test case, print YES if it's possible to choose array a that are consistent with information from s you know. Otherwise, print NO.\\n\\nIt can be proved, that if there exists some array a, then there exists an array a of positive integers with values less or equal to 10^9.\\n\\nExample\\n\\nInput\\n\\n\\n4\\nEEE\\nEN\\nENNEENE\\nNENN\\n\\n\\nOutput\\n\\n\\nYES\\nNO\\nYES\\nYES\\n\\nNote\\n\\nIn the first test case, you can choose, for example, a_1 = a_2 = a_3 = 5.\\n\\nIn the second test case, there is no array a, since, according to s_1, a_1 is equal to a_2, but, according to s_2, a_2 is not equal to a_1.\\n\\nIn the third test case, you can, for example, choose array a = [20, 20, 4, 50, 50, 50, 20].\\n\\nIn the fourth test case, you can, for example, choose a = [1, 3, 3, 7].\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int t;\\n cin >> t;\\n while (t--) {\\n string s;\\n cin >> s;\\n int cnt = 0;\\n for (auto u : s)\\n if (u == 'N') cnt++;\\n (cnt != 1) ? cout << \\\"YES\\\\n\\\" : cout << \\\"NO\\\\n\\\";\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alice and Bob are playing a game on a matrix, consisting of 2 rows and m columns. The cell in the i-th row in the j-th column contains a_{i, j} coins in it.\\n\\nInitially, both Alice and Bob are standing in a cell (1, 1). They are going to perform a sequence of moves to reach a cell (2, m).\\n\\nThe possible moves are: \\n\\n * Move right — from some cell (x, y) to (x, y + 1); \\n * Move down — from some cell (x, y) to (x + 1, y). \\n\\n\\n\\nFirst, Alice makes all her moves until she reaches (2, m). She collects the coins in all cells she visit (including the starting cell).\\n\\nWhen Alice finishes, Bob starts his journey. He also performs the moves to reach (2, m) and collects the coins in all cells that he visited, but Alice didn't.\\n\\nThe score of the game is the total number of coins Bob collects.\\n\\nAlice wants to minimize the score. Bob wants to maximize the score. What will the score of the game be if both players play optimally?\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.\\n\\nThen the descriptions of t testcases follow.\\n\\nThe first line of the testcase contains a single integer m (1 ≤ m ≤ 10^5) — the number of columns of the matrix.\\n\\nThe i-th of the next 2 lines contain m integers a_{i,1}, a_{i,2}, ..., a_{i,m} (1 ≤ a_{i,j} ≤ 10^4) — the number of coins in the cell in the i-th row in the j-th column of the matrix.\\n\\nThe sum of m over all testcases doesn't exceed 10^5.\\n\\nOutput\\n\\nFor each testcase print a single integer — the score of the game if both players play optimally.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n3\\n1 3 7\\n3 5 1\\n3\\n1 3 9\\n3 5 1\\n1\\n4\\n7\\n\\n\\nOutput\\n\\n\\n7\\n8\\n0\\n\\nNote\\n\\nThe paths for the testcases are shown on the following pictures. Alice's path is depicted in red and Bob's path is depicted in blue.\\n\\n\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.io.PrintWriter;\\nimport java.util.*;\\n\\n\\npublic class Main {\\n static int i, j, k, n, m, t, y, x, sum = 0;\\n static long mod = 998244353;\\n static FastScanner fs = new FastScanner();\\n static PrintWriter out = new PrintWriter(System.out);\\n static String str;\\n static long ans;\\n\\n\\n public static void main(String[] args) {\\n\\n t = fs.nextInt();\\n\\n while(t-- >0) {\\n\\n n = fs.nextInt();\\n\\n long[][] arr = new long[2][n];\\n\\n for(i=0;i=0;i--){\\n suffix[i] = arr[0][i]+suffix[i+1];\\n }\\n\\n ans = Integer.MAX_VALUE;\\n for(i=0;i\\nusing namespace std;\\nint n, l[100002], r[100002], g[100002];\\nint main() {\\n cin >> n;\\n for (int i = 1; i < n; i++) cin >> l[i] >> r[i];\\n for (int i = 1; i <= n; i++) cin >> g[i];\\n int ar = 0, er = 0;\\n for (int i = 1; i < n; i++) {\\n if (g[l[i]] != g[r[i]]) {\\n if (ar == 0 && er == 0) {\\n ar = l[i];\\n er = r[i];\\n if (ar < er) swap(ar, er);\\n } else {\\n if (l[i] < r[i]) swap(l[i], r[i]);\\n if (ar != l[i] && ar != r[i]) ar = -1;\\n if (er != l[i] && er != r[i]) er = -1;\\n }\\n }\\n }\\n if (ar < er) swap(ar, er);\\n if (ar == -1) {\\n cout << \\\"NO\\\" << endl;\\n return 0;\\n }\\n cout << \\\"YES\\\" << endl << (ar == 0 ? 1 : ar) << endl;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"There are n heaps of stone. The i-th heap has h_i stones. You want to change the number of stones in the heap by performing the following process once: \\n\\n * You go through the heaps from the 3-rd heap to the n-th heap, in this order. \\n * Let i be the number of the current heap. \\n * You can choose a number d (0 ≤ 3 ⋅ d ≤ h_i), move d stones from the i-th heap to the (i - 1)-th heap, and 2 ⋅ d stones from the i-th heap to the (i - 2)-th heap. \\n * So after that h_i is decreased by 3 ⋅ d, h_{i - 1} is increased by d, and h_{i - 2} is increased by 2 ⋅ d. \\n * You can choose different or same d for different operations. Some heaps may become empty, but they still count as heaps. \\n\\n\\n\\nWhat is the maximum number of stones in the smallest heap after the process?\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 2⋅ 10^5). Description of the test cases follows.\\n\\nThe first line of each test case contains a single integer n (3 ≤ n ≤ 2 ⋅ 10^5).\\n\\nThe second lines of each test case contains n integers h_1, h_2, h_3, …, h_n (1 ≤ h_i ≤ 10^9).\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print the maximum number of stones that the smallest heap can contain.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n4\\n1 2 10 100\\n4\\n100 100 100 1\\n5\\n5 1 1 1 8\\n6\\n1 2 3 4 5 6\\n\\n\\nOutput\\n\\n\\n7\\n1\\n1\\n3\\n\\nNote\\n\\nIn the first test case, the initial heap sizes are [1, 2, 10, 100]. We can move the stones as follows. \\n\\n * move 3 stones and 6 from the 3-rd heap to the 2-nd and 1 heap respectively. The heap sizes will be [7, 5, 1, 100]; \\n * move 6 stones and 12 stones from the last heap to the 3-rd and 2-nd heap respectively. The heap sizes will be [7, 17, 7, 82]. \\n\\n\\n\\nIn the second test case, the last heap is 1, and we can not increase its size.\\n\\nIn the third test case, it is better not to move any stones.\\n\\nIn the last test case, the final achievable configuration of the heaps can be [3, 5, 3, 4, 3, 3].\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nconstexpr long long SZ = 2e5 + 7;\\nint tc_cnt = 1;\\nint modpow(int a, int b, int m = (long long)1000000007) {\\n a = a & m;\\n int ans = 1;\\n while (b) {\\n if (b & 1) {\\n ans = (ans * a) % m;\\n }\\n b = b >> 1;\\n a = (a * a) % m;\\n }\\n return ans;\\n}\\nbool sortbysec(const pair &a,\\n const pair &b) {\\n return (a.second < b.second);\\n}\\nvoid maxi() {\\n int n, i;\\n cin >> n;\\n vector a(n);\\n for (i = 0; i < n; i++) {\\n cin >> a[i];\\n }\\n int ans = 0, lo = 0, hi = INT_MAX;\\n while (lo <= hi) {\\n auto v = a;\\n int mid = (lo + hi) \\/ 2;\\n bool can = true;\\n for (int i = n - 1; i > 1; i--) {\\n if (v[i] < mid) break;\\n int extra = v[i] - mid;\\n extra = min(extra, a[i]);\\n extra \\/= 3;\\n v[i - 1] += extra;\\n v[i - 2] += 2 * extra;\\n }\\n for (auto x : v) {\\n if (x < mid) {\\n can = false;\\n break;\\n }\\n }\\n if (can) {\\n ans = mid;\\n lo = mid + 1;\\n } else\\n hi = mid - 1;\\n }\\n cout << (ans) << endl;\\n}\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n long long t;\\n cin >> t;\\n while (t--) {\\n maxi();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nDenote a cyclic sequence of size n as an array s such that s_n is adjacent to s_1. The segment s[r, l] where l < r is the concatenation of s[r, n] and s[1, l].\\n\\nYou are given an array a consisting of n integers. Define b as the cyclic sequence obtained from concatenating m copies of a. Note that b has size n ⋅ m.\\n\\nYou are given an integer k where k = 1 or k is a prime number. Find the number of different segments in b where the sum of elements in the segment is divisible by k.\\n\\nTwo segments are considered different if the set of indices of the segments are different. For example, when n = 3 and m = 2, the set of indices for segment s[2, 5] is \\\\{2, 3, 4, 5\\\\}, and for segment s[5, 2] is \\\\{5, 6, 1, 2\\\\}. In particular, the segments s[1, 6], s[2,1], …, s[6, 5] are considered as the same segment.\\n\\nOutput the answer modulo 10^9 + 7.\\n\\nInput\\n\\nThe first line contains three integers n, m, and k (1 ≤ n, m, k ≤ 2 ⋅ 10^5, k = 1 or k is a prime number).\\n\\nThe second line contains n integers a_1, a_2, …, a_n (0 ≤ a_i ≤ 2 ⋅ 10^5).\\n\\nOutput\\n\\nOutput an integer denoting the number of different segments in b where the sum of elements in the segment is divisible by k, modulo 10^9 + 7.\\n\\nExamples\\n\\nInput\\n\\n\\n5 1 5\\n1 2 3 4 3\\n\\n\\nOutput\\n\\n\\n4\\n\\n\\nInput\\n\\n\\n5 1 5\\n1 2 3 4 5\\n\\n\\nOutput\\n\\n\\n5\\n\\n\\nInput\\n\\n\\n5 4 5\\n1 2 3 4 5\\n\\n\\nOutput\\n\\n\\n125\\n\\nNote\\n\\nIn the first example, all valid segments are [1,4], [2, 3], [3, 5], and [4, 2].\\n\\nIn the second example, one of the valid segments is [1, 5].\",\"targets\":\"#include \\nusing namespace std;\\nconstexpr long long mod = 1000000007;\\nconst long long INF = mod * mod;\\nconst double eps = 1e-8;\\nconst double pi = acosl(-1.0);\\nlong long mod_pow(long long x, long long n, long long m = mod) {\\n if (n < 0) {\\n long long res = mod_pow(x, -n, m);\\n return mod_pow(res, m - 2, m);\\n }\\n if (abs(x) >= m) x %= m;\\n if (x < 0) x += m;\\n long long res = 1;\\n while (n) {\\n if (n & 1) res = res * x % m;\\n x = x * x % m;\\n n >>= 1;\\n }\\n return res;\\n}\\nstruct modint {\\n long long n;\\n modint() : n(0) { ; }\\n modint(long long m) : n(m) {\\n if (n >= mod)\\n n %= mod;\\n else if (n < 0)\\n n = (n % mod + mod) % mod;\\n }\\n operator int() { return n; }\\n};\\nbool operator==(modint a, modint b) { return a.n == b.n; }\\nmodint operator+=(modint& a, modint b) {\\n a.n += b.n;\\n if (a.n >= mod) a.n -= mod;\\n return a;\\n}\\nmodint operator-=(modint& a, modint b) {\\n a.n -= b.n;\\n if (a.n < 0) a.n += mod;\\n return a;\\n}\\nmodint operator*=(modint& a, modint b) {\\n a.n = ((long long)a.n * b.n) % mod;\\n return a;\\n}\\nmodint operator+(modint a, modint b) { return a += b; }\\nmodint operator-(modint a, modint b) { return a -= b; }\\nmodint operator*(modint a, modint b) { return a *= b; }\\nmodint operator^(modint a, long long n) {\\n if (n == 0) return modint(1);\\n modint res = (a * a) ^ (n \\/ 2);\\n if (n % 2) res = res * a;\\n return res;\\n}\\nlong long inv(long long a, long long p) {\\n return (a == 1 ? 1 : (1 - p * inv(p % a, a)) \\/ a + p);\\n}\\nmodint operator\\/(modint a, modint b) { return a * modint(inv(b, mod)); }\\nmodint operator\\/=(modint& a, modint b) {\\n a = a \\/ b;\\n return a;\\n}\\nconst int max_n = 1 << 2;\\nmodint fact[max_n], factinv[max_n];\\nvoid init_f() {\\n fact[0] = modint(1);\\n for (int i = 0; i < max_n - 1; i++) {\\n fact[i + 1] = fact[i] * modint(i + 1);\\n }\\n factinv[max_n - 1] = modint(1) \\/ fact[max_n - 1];\\n for (int i = max_n - 2; i >= 0; i--) {\\n factinv[i] = factinv[i + 1] * modint(i + 1);\\n }\\n}\\nmodint comb(int a, int b) {\\n if (a < 0 || b < 0 || a < b) return 0;\\n return fact[a] *...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nBoboniu likes playing chess with his employees. As we know, no employee can beat the boss in the chess game, so Boboniu has never lost in any round.\\n\\nYou are a new applicant for his company. Boboniu will test you with the following chess question:\\n\\nConsider a n× m grid (rows are numbered from 1 to n, and columns are numbered from 1 to m). You have a chess piece, and it stands at some cell (S_x,S_y) which is not on the border (i.e. 2 ≤ S_x ≤ n-1 and 2 ≤ S_y ≤ m-1).\\n\\nFrom the cell (x,y), you can move your chess piece to (x,y') (1≤ y'≤ m, y' ≠ y) or (x',y) (1≤ x'≤ n, x'≠ x). In other words, the chess piece moves as a rook. From the cell, you can move to any cell on the same row or column.\\n\\nYour goal is to visit each cell exactly once. Can you find a solution?\\n\\nNote that cells on the path between two adjacent cells in your route are not counted as visited, and it is not required to return to the starting point.\\n\\nInput\\n\\nThe only line of the input contains four integers n, m, S_x and S_y (3≤ n,m≤ 100, 2 ≤ S_x ≤ n-1, 2 ≤ S_y ≤ m-1) — the number of rows, the number of columns, and the initial position of your chess piece, respectively.\\n\\nOutput\\n\\nYou should print n⋅ m lines.\\n\\nThe i-th line should contain two integers x_i and y_i (1 ≤ x_i ≤ n, 1 ≤ y_i ≤ m), denoting the i-th cell that you visited. You should print exactly nm pairs (x_i, y_i), they should cover all possible pairs (x_i, y_i), such that 1 ≤ x_i ≤ n, 1 ≤ y_i ≤ m.\\n\\nWe can show that under these constraints there always exists a solution. If there are multiple answers, print any.\\n\\nExamples\\n\\nInput\\n\\n\\n3 3 2 2\\n\\n\\nOutput\\n\\n\\n2 2\\n1 2\\n1 3\\n2 3\\n3 3\\n3 2\\n3 1\\n2 1\\n1 1\\n\\n\\nInput\\n\\n\\n3 4 2 2\\n\\n\\nOutput\\n\\n\\n2 2\\n2 1\\n2 3\\n2 4\\n1 4\\n3 4\\n3 3\\n3 2\\n3 1\\n1 1\\n1 2\\n1 3\\n\\nNote\\n\\nPossible routes for two examples:\\n\\n\",\"targets\":\"#include \\nint main() {\\n int a, b, c, d, i, t, n, m, j = 1, p = 0, q = 0, ans1 = 0, ans2 = 0;\\n scanf(\\\"%d %d %d %d\\\", &n, &m, &a, &b);\\n printf(\\\"%d %d\\\\n1 %d\\\\n1 1\\\\n\\\", a, b, b);\\n for (i = 1; i <= n; i++) {\\n if (i % 2 == 1)\\n j = 1;\\n else\\n j = m;\\n for (;;) {\\n if (j < 1 || j > m) break;\\n if ((i == 1 && j == 1) || (i == a && j == b) || (i == 1 && j == b)) {\\n if (i % 2 == 1)\\n j++;\\n else\\n j--;\\n continue;\\n }\\n printf(\\\"%d %d\\\\n\\\", i, j);\\n if (i % 2 == 1)\\n j++;\\n else\\n j--;\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"500-yen Saving\\n\\n\\\"500-yen Saving\\\" is one of Japanese famous methods to save money. The method is quite simple; whenever you receive a 500-yen coin in your change of shopping, put the coin to your 500-yen saving box. Typically, you will find more than one million yen in your saving box in ten years.\\n\\nSome Japanese people are addicted to the 500-yen saving. They try their best to collect 500-yen coins efficiently by using 1000-yen bills and some coins effectively in their purchasing. For example, you will give 1320 yen (one 1000-yen bill, three 100-yen coins and two 10-yen coins) to pay 817 yen, to receive one 500-yen coin (and three 1-yen coins) in the change.\\n\\nA friend of yours is one of these 500-yen saving addicts. He is planning a sightseeing trip and wants to visit a number of souvenir shops along his way. He will visit souvenir shops one by one according to the trip plan. Every souvenir shop sells only one kind of souvenir goods, and he has the complete list of their prices. He wants to collect as many 500-yen coins as possible through buying at most one souvenir from a shop. On his departure, he will start with sufficiently many 1000-yen bills and no coins at all. The order of shops to visit cannot be changed. As far as he can collect the same number of 500-yen coins, he wants to cut his expenses as much as possible.\\n\\nLet's say that he is visiting shops with their souvenir prices of 800 yen, 700 yen, 1600 yen, and 600 yen, in this order. He can collect at most two 500-yen coins spending 2900 yen, the least expenses to collect two 500-yen coins, in this case. After skipping the first shop, the way of spending 700-yen at the second shop is by handing over a 1000-yen bill and receiving three 100-yen coins. In the next shop, handing over one of these 100-yen coins and two 1000-yen bills for buying a 1600-yen souvenir will make him receive one 500-yen coin. In almost the same way, he can obtain another 500-yen coin at the last shop. He can also collect two 500-yen coins buying at the first shop, but his total...\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\ntypedef pair P;\\nP dp[101][50001];\\n\\nvoid Max(P &a,P b){a=max(a,b);}\\n\\nint main(){\\n int n,p[101];\\n while(cin>>n,n){\\n for(int i=0;i>p[i];\\n \\n memset(dp,-1,sizeof(dp));\\n dp[0][0]=P(0,0);\\n \\n for(int i=0;i=500) Max(dp[i+1][j-500],P(coin+1,ncost));\\n\\t\\n\\tif(p[i]%1000>500) {\\n\\t if(j>=p[i]%500)Max(dp[i+1][j-p[i]%500],P(coin+1,ncost));\\n\\t else Max(dp[i+1][j+(500-p[i]%500)],P(coin,ncost));\\n\\t}\\n }\\n \\n \\n P ans=P(0,0);\\n for(int i=0;i<50000;i++)Max(ans,dp[n][i]);\\n cout < The upper left fragment 5 × 5 of the parking\\n\\nLeha wants to ask the watchman q requests, which can help him to find his car. Every request is represented as five integers x1, y1, x2, y2, k. The watchman have to consider all cells (x, y) of the matrix, such that x1 ≤ x ≤ x2 and y1 ≤ y ≤ y2, and if the number of the car in cell (x, y) does not exceed k, increase the answer to the request by the number of the car in cell (x, y). For each request Leha asks the watchman to tell him the resulting sum. Due to the fact that the sum can turn out to be quite large, hacker asks to calculate it modulo 109 + 7.\\n\\nHowever the requests seem to be impracticable for the watchman. Help the watchman to answer all Leha's requests.\\n\\nInput\\n\\nThe first line contains one integer q (1 ≤ q ≤ 104) — the number of Leha's requests.\\n\\nThe next q lines contain five integers x1, y1, x2, y2, k (1 ≤ x1 ≤ x2 ≤ 109, 1 ≤ y1 ≤ y2 ≤ 109, 1 ≤ k ≤ 2·109) — parameters of Leha's requests.\\n\\nOutput\\n\\nPrint exactly q lines — in the first line print the answer to the first request, in the second — the answer to the second request and so on.\\n\\nExample\\n\\nInput\\n\\n4\\n1 1 1 1 1\\n3 2 5 4 5\\n1 1 5 5...\",\"targets\":\"#include \\nusing namespace std;\\ninline void Rd(int &res) {\\n char c;\\n res = 0;\\n while (c = getchar(), c < '0')\\n ;\\n do {\\n res = (res << 1) + (res << 3) + (c ^ 48);\\n } while (c = getchar(), c >= '0');\\n}\\nconst int N = 32;\\nconst int M = 35;\\nconst int P = (int)1e9 + 7;\\nint q;\\nint dp1[M][2][2][2], dp2[M][2][2][2], X[M], Y[M], K[M];\\ninline void Add(int &a, int b) { a = (a + b) % P; }\\nint solve(int x, int y, int k) {\\n if (x < 0 || y < 0) return 0;\\n memset(dp1, 0, sizeof(dp1));\\n memset(dp2, 0, sizeof(dp2));\\n for (int i = 1; i <= N; i++) {\\n X[i] = (x & 1), Y[i] = (y & 1), K[i] = (k & 1);\\n x >>= 1, y >>= 1, k >>= 1;\\n }\\n reverse(X + 1, X + N + 1), reverse(Y + 1, Y + N + 1),\\n reverse(K + 1, K + N + 1);\\n dp1[1][1][1][1] = 1;\\n for (int i = 1; i < N; i++)\\n for (int j = 0; j < 2; j++)\\n for (int k = 0; k < 2; k++)\\n for (int t = 0; t < 2; t++)\\n for (int x = 0; x < 2; x++)\\n for (int y = 0; y < 2; y++) {\\n if (!dp1[i][j][k][t]) continue;\\n int z = x ^ y;\\n if (j && (x > X[i + 1])) continue;\\n if (k && (y > Y[i + 1])) continue;\\n if (t && (z > K[i + 1])) continue;\\n Add(dp1[i + 1][j & (x == X[i + 1])][k & (y == Y[i + 1])]\\n [t & (z == K[i + 1])],\\n dp1[i][j][k][t]);\\n Add(dp2[i + 1][j & (x == X[i + 1])][k & (y == Y[i + 1])]\\n [t & (z == K[i + 1])],\\n dp2[i][j][k][t]);\\n Add(dp2[i + 1][j & (x == X[i + 1])][k & (y == Y[i + 1])]\\n [t & (z == K[i + 1])],\\n dp1[i][j][k][t] * ((long long)z << (N - 1 - i)) % P);\\n }\\n int res = 0;\\n for (int i = 0; i < 2; i++)\\n for (int j = 0; j < 2; j++)\\n for (int t = 0; t < 2; t++)\\n Add(res, (dp1[N][i][j][t] + dp2[N][i][j][t]) % P);\\n return res;\\n}\\nint main() {\\n Rd(q);\\n while (q--) {\\n int x1, y1, x2, y2, k, ans = 0;\\n Rd(x1), Rd(y1), Rd(x2), Rd(y2), Rd(k);\\n x1--, y1--, x2--, y2--, k--;\\n ans...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Connect the countless points with lines, till we reach the faraway yonder.\\n\\nThere are n points on a coordinate plane, the i-th of which being (i, yi).\\n\\nDetermine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of them, and each of them passes through at least one point in the set.\\n\\nInput\\n\\nThe first line of input contains a positive integer n (3 ≤ n ≤ 1 000) — the number of points.\\n\\nThe second line contains n space-separated integers y1, y2, ..., yn ( - 109 ≤ yi ≤ 109) — the vertical coordinates of each point.\\n\\nOutput\\n\\nOutput \\\"Yes\\\" (without quotes) if it's possible to fulfill the requirements, and \\\"No\\\" otherwise.\\n\\nYou can print each letter in any case (upper or lower).\\n\\nExamples\\n\\nInput\\n\\n5\\n7 5 8 6 9\\n\\n\\nOutput\\n\\nYes\\n\\n\\nInput\\n\\n5\\n-1 -2 0 0 -5\\n\\n\\nOutput\\n\\nNo\\n\\n\\nInput\\n\\n5\\n5 4 3 2 1\\n\\n\\nOutput\\n\\nNo\\n\\n\\nInput\\n\\n5\\n1000000000 0 0 0 0\\n\\n\\nOutput\\n\\nYes\\n\\nNote\\n\\nIn the first example, there are five points: (1, 7), (2, 5), (3, 8), (4, 6) and (5, 9). It's possible to draw a line that passes through points 1, 3, 5, and another one that passes through points 2, 4 and is parallel to the first one.\\n\\nIn the second example, while it's possible to draw two lines that cover all points, they cannot be made parallel.\\n\\nIn the third example, it's impossible to satisfy both requirements at the same time.\\\":\",\"targets\":\"#include \\nusing namespace std;\\nvector pre;\\nbool visit[1005];\\ndouble val[1005];\\ndouble cal(int u, int v) { return (val[v] - val[u]) \\/ (v - u); }\\nbool check() {\\n int sz = pre.size();\\n if (sz <= 2) return true;\\n double dis = cal(pre[0], pre[1]);\\n int id = pre[1];\\n for (int i = 2; i < sz; i++)\\n if (cal(pre[i - 1], pre[i]) != dis) return false;\\n return true;\\n}\\nint main() {\\n std::ios::sync_with_stdio(false);\\n int n;\\n cin >> n;\\n for (int i = 1; i <= n; i++) cin >> val[i];\\n bool OK = false;\\n for (int i = 2; i <= n;) {\\n if (!check()) break;\\n for (int j = 1; j <= n; j++)\\n if (j <= i)\\n visit[j] = true;\\n else\\n visit[j] = false;\\n double dis = cal(1, i);\\n int id = i, last = n + 1;\\n int fir = -1, sec = -1;\\n bool flag = true;\\n for (int j = i + 1; j <= n; j++) {\\n if (cal(id, j) == dis) {\\n visit[j] = true;\\n id = j;\\n } else {\\n if (fir == -1)\\n fir = j;\\n else if (sec == -1)\\n sec = j;\\n if (flag) last = j;\\n flag = false;\\n }\\n }\\n int sz = pre.size();\\n if (!sz) {\\n if (fir == -1) {\\n for (int j = i; j < last; j++) pre.push_back(j);\\n i = last;\\n continue;\\n } else if (sec == -1 && cal(1, fir) != cal(1, i)) {\\n OK = true;\\n break;\\n }\\n dis = cal(fir, sec);\\n id = sec;\\n } else if (sz == 1) {\\n if (fir == -1 && cal(1, pre[0]) != cal(1, i)) {\\n OK = true;\\n break;\\n }\\n dis = cal(pre[0], fir);\\n id = fir;\\n } else\\n dis = cal(pre[0], pre[1]), id = pre[sz - 1];\\n flag = true;\\n for (int j = id + 1; j <= n; j++) {\\n if (cal(id, j) == dis) {\\n if (visit[j]) {\\n flag = false;\\n break;\\n }\\n } else {\\n if (!visit[j]) {\\n flag = false;\\n break;\\n }\\n }\\n }\\n if (flag && dis == cal(1, i)) {\\n OK = true;\\n break;\\n }\\n for (int j = i; j < last; j++) pre.push_back(j);\\n i = last;\\n }\\n if (!OK) {\\n double dis...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nPolycarp has created his own training plan to prepare for the programming contests. He will train for n days, all days are numbered from 1 to n, beginning from the first.\\n\\nOn the i-th day Polycarp will necessarily solve a_i problems. One evening Polycarp plans to celebrate the equator. He will celebrate it on the first evening of such a day that from the beginning of the training and to this day inclusive he will solve half or more of all the problems.\\n\\nDetermine the index of day when Polycarp will celebrate the equator.\\n\\nInput\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 200 000) — the number of days to prepare for the programming contests.\\n\\nThe second line contains a sequence a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10 000), where a_i equals to the number of problems, which Polycarp will solve on the i-th day.\\n\\nOutput\\n\\nPrint the index of the day when Polycarp will celebrate the equator.\\n\\nExamples\\n\\nInput\\n\\n4\\n1 3 2 1\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n6\\n2 2 2 2 2 2\\n\\n\\nOutput\\n\\n3\\n\\nNote\\n\\nIn the first example Polycarp will celebrate the equator on the evening of the second day, because up to this day (inclusive) he will solve 4 out of 7 scheduled problems on four days of the training.\\n\\nIn the second example Polycarp will celebrate the equator on the evening of the third day, because up to this day (inclusive) he will solve 6 out of 12 scheduled problems on six days of the training.\",\"targets\":\"#include \\nusing namespace std;\\nconst int maxn = 200000 + 10;\\nint arr[maxn];\\nint main() {\\n int n, sum = 0;\\n scanf(\\\"%d\\\", &n);\\n for (int i = 1; i <= n; i++) {\\n int x;\\n scanf(\\\"%d\\\", &x);\\n arr[i] = arr[i - 1] + x;\\n sum += x;\\n }\\n int half = (sum + 1) \\/ 2;\\n for (int i = 1; i <= n; i++)\\n if (arr[i] >= half) {\\n cout << i << endl;\\n break;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"n people gathered to hold a jury meeting of the upcoming competition, the i-th member of the jury came up with a_i tasks, which they want to share with each other.\\n\\nFirst, the jury decides on the order which they will follow while describing the tasks. Let that be a permutation p of numbers from 1 to n (an array of size n where each integer from 1 to n occurs exactly once).\\n\\nThen the discussion goes as follows:\\n\\n * If a jury member p_1 has some tasks left to tell, then they tell one task to others. Otherwise, they are skipped. \\n * If a jury member p_2 has some tasks left to tell, then they tell one task to others. Otherwise, they are skipped. \\n * ... \\n * If a jury member p_n has some tasks left to tell, then they tell one task to others. Otherwise, they are skipped. \\n * If there are still members with tasks left, then the process repeats from the start. Otherwise, the discussion ends. \\n\\n\\n\\nA permutation p is nice if none of the jury members tell two or more of their own tasks in a row. \\n\\nCount the number of nice permutations. The answer may be really large, so print it modulo 998 244 353.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases.\\n\\nThe first line of the test case contains a single integer n (2 ≤ n ≤ 2 ⋅ 10^5) — number of jury members.\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — the number of problems that the i-th member of the jury came up with.\\n\\nThe sum of n over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print one integer — the number of nice permutations, taken modulo 998 244 353.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n2\\n1 2\\n3\\n5 5 5\\n4\\n1 3 3 7\\n6\\n3 4 2 1 3 3\\n\\n\\nOutput\\n\\n\\n1\\n6\\n0\\n540\\n\\nNote\\n\\nExplanation of the first test case from the example:\\n\\nThere are two possible permutations, p = [1, 2] and p = [2, 1]. For p = [1, 2], the process is the following:\\n\\n 1. the first jury member tells a task; \\n 2. the second jury member tells a task; \\n 3. the first jury member doesn't have any tasks left to tell, so they are skipped;...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nconst long long N = 2e5 + 10;\\nconst long long mod = 998244353;\\nlong long a[N];\\nlong long rjc[N];\\nlong long jc[N];\\nlong long inverse(long long n) {\\n long long ans = 1, p = 998244351;\\n while (p) {\\n if (p & 1) ans = (ans * n) % 998244353;\\n n = (n * n) % 998244353;\\n p >>= 1;\\n }\\n return ans;\\n}\\nvoid init() {\\n long long res = 1;\\n rjc[0] = jc[0] = 1;\\n for (long long i = 1; i <= 2e5; i++) {\\n jc[i] = (jc[i - 1] * i) % mod;\\n rjc[i] = (rjc[i - 1] * inverse(i)) % mod;\\n }\\n}\\nlong long cal(long long m, long long n) {\\n return ((jc[n] * rjc[n - m]) % mod) % mod;\\n}\\nsigned main() {\\n init();\\n long long t;\\n cin >> t;\\n while (t--) {\\n long long n;\\n cin >> n;\\n for (long long i = 0; i < n; i++) {\\n cin >> a[i];\\n }\\n long long ans = 0, cnt1 = 0, cnt2 = 0;\\n sort(a, a + n, greater());\\n long long maxx = a[0];\\n for (long long i = 0; i < n; i++) {\\n if (a[i] == maxx) cnt1++;\\n if (a[i] == maxx - 1) cnt2++;\\n if (a[i] < maxx - 1) break;\\n }\\n if (cnt1 >= 2)\\n cout << jc[n] << '\\\\n';\\n else if (cnt1 < n && cnt2 == 0)\\n cout << 0 << '\\\\n';\\n else {\\n long long ans = jc[n];\\n ans = (ans - jc[n - 1] + mod) % mod;\\n long long cnt = n - cnt1 - cnt2;\\n for (long long i = 1; i <= cnt; i++) {\\n long long temp = cal(i, cnt) % mod;\\n temp = (temp * jc[n - i - 1]) % mod;\\n ans -= temp;\\n ans = (ans + mod) % mod;\\n }\\n cout << ans << '\\\\n';\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"ButCoder Inc. is a startup company whose main business is the development and operation of the programming competition site \\\"ButCoder\\\".\\n\\nThere are N members of the company including the president, and each member except the president has exactly one direct boss. Each member has a unique ID number from 1 to N, and the member with the ID i is called Member i. The president is Member 1, and the direct boss of Member i (2 ≤ i ≤ N) is Member b_i (1 ≤ b_i < i).\\n\\nAll the members in ButCoder have gathered in the great hall in the main office to take a group photo. The hall is very large, and all N people can stand in one line. However, they have been unable to decide the order in which they stand. For some reason, all of them except the president want to avoid standing next to their direct bosses.\\n\\nHow many ways are there for them to stand in a line that satisfy their desires? Find the count modulo 10^9+7.\\n\\nConstraints\\n\\n* 2 ≤ N ≤ 2000\\n* 1 ≤ b_i < i (2 ≤ i ≤ N)\\n\\nInput\\n\\nInput is given from Standard Input in the following format:\\n\\n\\nN\\nb_2\\nb_3\\n:\\nb_N\\n\\n\\nOutput\\n\\nPrint the number of ways for the N members to stand in a line, such that no member except the president is next to his\\/her direct boss, modulo 10^9+7.\\n\\nExamples\\n\\nInput\\n\\n4\\n1\\n2\\n3\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n3\\n1\\n2\\n\\n\\nOutput\\n\\n0\\n\\n\\nInput\\n\\n5\\n1\\n1\\n3\\n3\\n\\n\\nOutput\\n\\n8\\n\\n\\nInput\\n\\n15\\n1\\n2\\n3\\n1\\n4\\n2\\n7\\n1\\n8\\n2\\n8\\n1\\n8\\n2\\n\\n\\nOutput\\n\\n97193524\\\":\",\"targets\":\"#include \\n#include \\n#define ll long long\\n#define inf 1000000007\\n#define inf16 0x3f3f3f3f\\n#define INF 1000000000000000007LL\\n#define VI vector\\n#define VPII vector >\\n#define VLL vector\\n#define PII pair\\n#define st first\\n#define nd second\\n#define pb push_back\\n#define mp make_pair\\n#define eb emplace_back\\n#define endl '\\\\n'\\n#define ALL(c) (c).begin(), (c).end()\\nusing namespace std;\\n\\n#define int ll\\nconst int mod = 1e9+7;\\nconst int N = 2007;\\nconst int inv2 = (mod+1)\\/2;\\n\\nint n;\\n\\nVI G[N];\\n\\nint sub[N];\\nint dp[2][N][N][3][2]; \\/\\/[korzen][ile skladowych][stopien korzenia][parzystosc liczby krawedzi]\\nint c[N];\\n\\nvoid dfs(int v)\\n{\\n\\tsub[v] = 1;\\n\\n\\tdp[c[v]][v][1][0][0] = 1;\\n\\n\\tfor(auto u:G[v])\\n\\t{\\n\\t\\tdfs(u);\\n\\n\\t\\tfor(int degv = 2; degv >= 0; --degv)\\n\\t\\t{\\n\\t\\t\\tfor(int sv = sub[v]; sv >= 1; --sv)\\n\\t\\t\\t{\\n\\t\\t\\t\\tfor(int pv = 0; pv < 2; ++pv)\\n\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\tfor(int degu = 2; degu >= 0; --degu)\\n\\t\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\t\\tfor(int su = sub[u]; su >= 1; --su)\\n\\t\\t\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\t\\t\\tfor(int pu = 0; pu < 2; ++pu)\\n\\t\\t\\t\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\t\\t\\t\\tif(degv<=1 && degu<=1) \\/\\/uzywam krawedzi\\n\\t\\t\\t\\t\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tint ndeg = degv+1;\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tint np = (pv+pu+1)%2;\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tint ns = sv+su-1;\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tint mult = 1;\\n\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tif(degv==0 && degu==0)\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tmult *= 2;\\n\\t\\t\\t\\t\\t\\t\\t\\t\\telse if(degv==1 && degu==1)\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tmult *= inv2;\\n\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tdp[c[v]^1][v][ns][ndeg][np] += mult*dp[c[v]][v][sv][degv][pv]%mod*dp[c[u]][u][su][degu][pu]%mod;\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tdp[c[v]^1][v][ns][ndeg][np] %= mod;\\n\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\n\\t\\t\\t\\t\\t\\t\\t\\t\\/\\/nie uzywam krawedzi\\n\\n\\t\\t\\t\\t\\t\\t\\t\\tint ndeg = degv;\\n\\t\\t\\t\\t\\t\\t\\t\\tint np = (pv+pu)%2;\\n\\t\\t\\t\\t\\t\\t\\t\\tint ns = sv+su;\\n\\n\\t\\t\\t\\t\\t\\t\\t\\tdp[c[v]^1][v][ns][ndeg][np] += dp[c[v]][v][sv][degv][pv]*dp[c[u]][u][su][degu][pu]%mod;\\n\\t\\t\\t\\t\\t\\t\\t\\tdp[c[v]^1][v][ns][ndeg][np] %= mod;\\n\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t}\\n\\n\\t\\t\\t\\t\\tdp[c[v]][v][sv][degv][pv] = 0;\\n\\t\\t\\t\\t}\\t\\n\\t\\t\\t}\\n\\t\\t}\\n\\n\\t\\tc[v] ^= 1;\\n\\t\\tsub[v] += sub[u];\\n\\t}\\n}\\n\\nint32_t main()\\n{\\n\\tios_base::sync_with_stdio(0);\\n\\tcin.tie(NULL);\\n\\n\\tcin >> n;\\n\\n\\tfor(int i = 2; i <= n; ++i)\\n\\t{\\n\\t\\tint x;\\n\\t\\tcin >> x;\\n\\t\\tG[x].pb(i);\\n\\t}\\n\\n\\tdfs(1);\\n\\n\\tint fact = 1;\\n\\tint ans = 0;\\n\\n\\tfor(int i = 1; i...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A group of n alpinists has just reached the foot of the mountain. The initial difficulty of climbing this mountain can be described as an integer d.\\n\\nEach alpinist can be described by two integers s and a, where s is his skill of climbing mountains and a is his neatness.\\n\\nAn alpinist of skill level s is able to climb a mountain of difficulty p only if p ≤ s. As an alpinist climbs a mountain, they affect the path and thus may change mountain difficulty. Specifically, if an alpinist of neatness a climbs a mountain of difficulty p the difficulty of this mountain becomes max(p, a). \\n\\nAlpinists will climb the mountain one by one. And before the start, they wonder, what is the maximum number of alpinists who will be able to climb the mountain if they choose the right order. As you are the only person in the group who does programming, you are to answer the question.\\n\\nNote that after the order is chosen, each alpinist who can climb the mountain, must climb the mountain at that time. \\n\\nInput\\n\\nThe first line contains two integers n and d (1 ≤ n ≤ 500 000; 0 ≤ d ≤ 10^9) — the number of alpinists and the initial difficulty of the mountain.\\n\\nEach of the next n lines contains two integers s_i and a_i (0 ≤ s_i, a_i ≤ 10^9) that define the skill of climbing and the neatness of the i-th alpinist.\\n\\nOutput\\n\\nPrint one integer equal to the maximum number of alpinists who can climb the mountain if they choose the right order to do so.\\n\\nExamples\\n\\nInput\\n\\n\\n3 2\\n2 6\\n3 5\\n5 7\\n\\n\\nOutput\\n\\n\\n2\\n\\n\\nInput\\n\\n\\n3 3\\n2 4\\n6 4\\n4 6\\n\\n\\nOutput\\n\\n\\n2\\n\\n\\nInput\\n\\n\\n5 0\\n1 5\\n4 8\\n2 7\\n7 6\\n3 2\\n\\n\\nOutput\\n\\n\\n3\\n\\nNote\\n\\nIn the first example, alpinists 2 and 3 can climb the mountain if they go in this order. There is no other way to achieve the answer of 2.\\n\\nIn the second example, alpinist 1 is not able to climb because of the initial difficulty of the mountain, while alpinists 2 and 3 can go up in any order.\\n\\nIn the third example, the mountain can be climbed by alpinists 5, 3 and 4 in this particular order. There is no other way to achieve optimal answer.\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nint n, d, s, a;\\nvector > v[2];\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n cin >> n >> d;\\n for (int i = 0; i < n; i++) {\\n cin >> s >> a;\\n if (s < d) {\\n continue;\\n }\\n if (s >= a) {\\n v[0].push_back({s, a});\\n } else {\\n v[1].push_back({a, s});\\n }\\n }\\n sort((v[0]).begin(), (v[0]).end());\\n sort((v[1]).begin(), (v[1]).end());\\n int j = 0;\\n int ans = (int)v[0].size();\\n for (int i = 0; i < (int)v[1].size(); i++) {\\n while (j < (int)v[0].size() && v[0][j].first < v[1][i].first) {\\n d = max(d, v[0][j++].second);\\n }\\n if (d <= v[1][i].second) {\\n d = max(d, v[1][i].first);\\n ans++;\\n }\\n }\\n cout << ans;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Given a positive integer n. Find three distinct positive integers a, b, c such that a + b + c = n and \\\\operatorname{gcd}(a, b) = c, where \\\\operatorname{gcd}(x, y) denotes the [greatest common divisor (GCD)](https:\\/\\/en.wikipedia.org\\/wiki\\/Greatest_common_divisor) of integers x and y.\\n\\nInput\\n\\nThe input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 10^5) — the number of test cases. Description of the test cases follows.\\n\\nThe first and only line of each test case contains a single integer n (10 ≤ n ≤ 10^9).\\n\\nOutput\\n\\nFor each test case, output three distinct positive integers a, b, c satisfying the requirements. If there are multiple solutions, you can print any. We can show that an answer always exists.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n18\\n63\\n73\\n91\\n438\\n122690412\\n\\n\\nOutput\\n\\n\\n6 9 3\\n21 39 3\\n29 43 1\\n49 35 7\\n146 219 73\\n28622 122661788 2\\n\\nNote\\n\\nIn the first test case, 6 + 9 + 3 = 18 and \\\\operatorname{gcd}(6, 9) = 3.\\n\\nIn the second test case, 21 + 39 + 3 = 63 and \\\\operatorname{gcd}(21, 39) = 3.\\n\\nIn the third test case, 29 + 43 + 1 = 73 and \\\\operatorname{gcd}(29, 43) = 1.\\nimpor\",\"targets\":\"t math\\nfor _ in range(int(input())):\\n n = int(input())\\n for i in range(2,n):\\n res = n-i-1\\n if math.gcd(i,res) == 1:\\n print(i,res,1)\\n break\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Bear Limak prepares problems for a programming competition. Of course, it would be unprofessional to mention the sponsor name in the statement. Limak takes it seriously and he is going to change some words. To make it still possible to read, he will try to modify each word as little as possible.\\n\\nLimak has a string s that consists of uppercase English letters. In one move he can swap two adjacent letters of the string. For example, he can transform a string \\\"ABBC\\\" into \\\"BABC\\\" or \\\"ABCB\\\" in one move.\\n\\nLimak wants to obtain a string without a substring \\\"VK\\\" (i.e. there should be no letter 'V' immediately followed by letter 'K'). It can be easily proved that it's possible for any initial string s.\\n\\nWhat is the minimum possible number of moves Limak can do?\\n\\nInput\\n\\nThe first line of the input contains an integer n (1 ≤ n ≤ 75) — the length of the string.\\n\\nThe second line contains a string s, consisting of uppercase English letters. The length of the string is equal to n.\\n\\nOutput\\n\\nPrint one integer, denoting the minimum possible number of moves Limak can do, in order to obtain a string without a substring \\\"VK\\\".\\n\\nExamples\\n\\nInput\\n\\n4\\nVKVK\\n\\n\\nOutput\\n\\n3\\n\\n\\nInput\\n\\n5\\nBVVKV\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n7\\nVVKEVKK\\n\\n\\nOutput\\n\\n3\\n\\n\\nInput\\n\\n20\\nVKVKVVVKVOVKVQKKKVVK\\n\\n\\nOutput\\n\\n8\\n\\n\\nInput\\n\\n5\\nLIMAK\\n\\n\\nOutput\\n\\n0\\n\\nNote\\n\\nIn the first sample, the initial string is \\\"VKVK\\\". The minimum possible number of moves is 3. One optimal sequence of moves is:\\n\\n 1. Swap two last letters. The string becomes \\\"VKKV\\\".\\n 2. Swap first two letters. The string becomes \\\"KVKV\\\".\\n 3. Swap the second and the third letter. The string becomes \\\"KKVV\\\". Indeed, this string doesn't have a substring \\\"VK\\\".\\n\\n\\n\\nIn the second sample, there are two optimal sequences of moves. One is \\\"BVVKV\\\" → \\\"VBVKV\\\" → \\\"VVBKV\\\". The other is \\\"BVVKV\\\" → \\\"BVKVV\\\" → \\\"BKVVV\\\".\\n\\nIn the fifth sample, no swaps are necessary.\\\":\",\"targets\":\"#include \\nusing namespace std;\\nconst int maxn = 77;\\nconst int INF = 1e9;\\nint n;\\nchar str[maxn];\\nint dp[maxn][maxn][maxn][2];\\nint cv[maxn];\\nint ck[maxn];\\nint cx[maxn];\\nint vp[maxn];\\nint kp[maxn];\\nint xp[maxn];\\nbool ban[maxn];\\nvoid ckMin(int &a, int b) {\\n if (b < a) {\\n a = b;\\n }\\n}\\nint main() {\\n cin >> n;\\n scanf(\\\"%s\\\", str + 1);\\n for (int i = 1; i <= n; i++) {\\n if (str[i] == 'V') {\\n cv[i] = cv[i - 1] + 1;\\n ck[i] = ck[i - 1];\\n cx[i] = cx[i - 1];\\n vp[cv[i]] = i;\\n } else if (str[i] == 'K') {\\n cv[i] = cv[i - 1];\\n ck[i] = ck[i - 1] + 1;\\n cx[i] = cx[i - 1];\\n kp[ck[i]] = i;\\n } else {\\n cv[i] = cv[i - 1];\\n ck[i] = ck[i - 1];\\n cx[i] = cx[i - 1] + 1;\\n xp[cx[i]] = i;\\n }\\n }\\n for (int i = 0; i < maxn; i++) {\\n for (int j = 0; j < maxn; j++) {\\n for (int k = 0; k < maxn; k++) {\\n dp[i][j][k][0] = dp[i][j][k][1] = INF;\\n }\\n }\\n }\\n dp[0][0][0][0] = 0;\\n for (int i = 0; i <= cv[n]; i++) {\\n for (int j = 0; j <= ck[n]; j++) {\\n for (int k = 0; k <= cx[n]; k++) {\\n int pos = i + j + k;\\n int dis;\\n if (i < cv[n]) {\\n dis = 0;\\n dis += max(0, ck[vp[i + 1]] - j);\\n dis += max(0, cx[vp[i + 1]] - k);\\n ckMin(dp[i + 1][j][k][1], dp[i][j][k][0] + dis);\\n ckMin(dp[i + 1][j][k][1], dp[i][j][k][1] + dis);\\n }\\n if (j < ck[n]) {\\n dis = 0;\\n dis += max(0, cv[kp[j + 1]] - i);\\n dis += max(0, cx[kp[j + 1]] - k);\\n ckMin(dp[i][j + 1][k][0], dp[i][j][k][0] + dis);\\n }\\n if (k < cx[n]) {\\n dis = 0;\\n dis += max(0, cv[xp[k + 1]] - i);\\n dis += max(0, ck[xp[k + 1]] - j);\\n ckMin(dp[i][j][k + 1][0], dp[i][j][k][0] + dis);\\n ckMin(dp[i][j][k + 1][0], dp[i][j][k][1] + dis);\\n }\\n }\\n }\\n }\\n cout << min(dp[cv[n]][ck[n]][cx[n]][0], dp[cv[n]][ck[n]][cx[n]][1]) << endl;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Certainly, everyone is familiar with tic-tac-toe game. The rules are very simple indeed. Two players take turns marking the cells in a 3 × 3 grid (one player always draws crosses, the other — noughts). The player who succeeds first in placing three of his marks in a horizontal, vertical or diagonal line wins, and the game is finished. The player who draws crosses goes first. If the grid is filled, but neither Xs, nor 0s form the required line, a draw is announced.\\n\\nYou are given a 3 × 3 grid, each grid cell is empty, or occupied by a cross or a nought. You have to find the player (first or second), whose turn is next, or print one of the verdicts below: \\n\\n * illegal — if the given board layout can't appear during a valid game; \\n * the first player won — if in the given board layout the first player has just won; \\n * the second player won — if in the given board layout the second player has just won; \\n * draw — if the given board layout has just let to a draw. \\n\\nInput\\n\\nThe input consists of three lines, each of the lines contains characters \\\".\\\", \\\"X\\\" or \\\"0\\\" (a period, a capital letter X, or a digit zero).\\n\\nOutput\\n\\nPrint one of the six verdicts: first, second, illegal, the first player won, the second player won or draw.\\n\\nExamples\\n\\nInput\\n\\nX0X\\n.0.\\n.X.\\n\\n\\nOutput\\n\\nsecond\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst bool online_judge = true;\\nconst long long inf = 1LL << 60;\\nlong long toInt(string s) {\\n long long res;\\n stringstream ss;\\n ss << s;\\n ss >> res;\\n return res;\\n}\\nstring toString(long long n) {\\n stringstream ss;\\n ss << n;\\n return ss.str();\\n}\\nbool win(char p, vector board) {\\n for (long long i = 0; i < 3; i++) {\\n bool ok = true;\\n for (long long j = 0; j < 3; j++)\\n if (board[i][j] != p) ok = false;\\n if (ok) return true;\\n }\\n for (long long j = 0; j < 3; j++) {\\n bool ok = true;\\n for (long long i = 0; i < 3; i++)\\n if (board[i][j] != p) ok = false;\\n if (ok) return true;\\n }\\n if (board[0][0] == p && board[1][1] == p && board[2][2] == p) return true;\\n if (board[2][0] == p && board[1][1] == p && board[0][2] == p) return true;\\n return false;\\n}\\nvoid run() {\\n vector board(3);\\n for (long long i = 0; i < 3; i++) cin >> board[i];\\n map cnt;\\n for (long long i = 0; i < 3; i++)\\n for (long long j = 0; j < 3; j++) cnt[board[i][j]]++;\\n long long sub = cnt['X'] - cnt['0'];\\n if (!((sub) >= (0) && (sub) <= (1))) {\\n cout << \\\"illegal\\\" << endl;\\n return;\\n }\\n bool f = win('X', board), s = win('0', board);\\n if (f && s) {\\n cout << \\\"illegal\\\" << endl;\\n return;\\n }\\n if (f) {\\n if (sub == 1)\\n cout << \\\"the first player won\\\" << endl;\\n else\\n cout << \\\"illegal\\\" << endl;\\n return;\\n }\\n if (s) {\\n if (sub == 0)\\n cout << \\\"the second player won\\\" << endl;\\n else\\n cout << \\\"illegal\\\" << endl;\\n return;\\n }\\n if (cnt['.'] == 0) {\\n cout << \\\"draw\\\" << endl;\\n return;\\n }\\n cout << ((sub == 0) ? \\\"first\\\" : \\\"second\\\") << endl;\\n}\\nint main(int argc, char *argv[]) {\\n run();\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alice and Bob play a game. They have a binary string s (a string such that each character in it is either 0 or 1). Alice moves first, then Bob, then Alice again, and so on.\\n\\nDuring their move, the player can choose any number (not less than one) of consecutive equal characters in s and delete them.\\n\\nFor example, if the string is 10110, there are 6 possible moves (deleted characters are bold):\\n\\n 1. 10110 → 0110; \\n 2. 10110 → 1110; \\n 3. 10110 → 1010; \\n 4. 10110 → 1010; \\n 5. 10110 → 100; \\n 6. 10110 → 1011. \\n\\n\\n\\nAfter the characters are removed, the characters to the left and to the right of the removed block become adjacent. I. e. the following sequence of moves is valid: 10110 → 100 → 1.\\n\\nThe game ends when the string becomes empty, and the score of each player is the number of 1-characters deleted by them.\\n\\nEach player wants to maximize their score. Calculate the resulting score of Alice.\\n\\nInput\\n\\nThe first line contains one integer T (1 ≤ T ≤ 500) — the number of test cases.\\n\\nEach test case contains exactly one line containing a binary string s (1 ≤ |s| ≤ 100).\\n\\nOutput\\n\\nFor each test case, print one integer — the resulting score of Alice (the number of 1-characters deleted by her).\\n\\nExample\\n\\nInput\\n\\n\\n5\\n01111001\\n0000\\n111111\\n101010101\\n011011110111\\n\\n\\nOutput\\n\\n\\n4\\n0\\n6\\n3\\n6\\n\\nNote\\n\\nQuestions about the optimal strategy will be ignored.\",\"targets\":\"for _ in range(int(input())):\\n s = input().split('0')\\n s = sorted(s, reverse=True)\\n ans = 0\\n for i in range(len(s)):\\n if i % 2 == 0:\\n ans += len(s[i])\\n print(ans)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Another Codeforces Round has just finished! It has gathered n participants, and according to the results, the expected rating change of participant i is a_i. These rating changes are perfectly balanced — their sum is equal to 0.\\n\\nUnfortunately, due to minor technical glitches, the round is declared semi-rated. It means that all rating changes must be divided by two.\\n\\nThere are two conditions though: \\n\\n * For each participant i, their modified rating change b_i must be integer, and as close to (a_i)\\/(2) as possible. It means that either b_i = ⌊ (a_i)\\/(2) ⌋ or b_i = ⌈ (a_i)\\/(2) ⌉. In particular, if a_i is even, b_i = (a_i)\\/(2). Here ⌊ x ⌋ denotes rounding down to the largest integer not greater than x, and ⌈ x ⌉ denotes rounding up to the smallest integer not smaller than x. \\n * The modified rating changes must be perfectly balanced — their sum must be equal to 0. \\n\\n\\n\\nCan you help with that?\\n\\nInput\\n\\nThe first line contains a single integer n (2 ≤ n ≤ 13 845), denoting the number of participants.\\n\\nEach of the next n lines contains a single integer a_i (-336 ≤ a_i ≤ 1164), denoting the rating change of the i-th participant.\\n\\nThe sum of all a_i is equal to 0.\\n\\nOutput\\n\\nOutput n integers b_i, each denoting the modified rating change of the i-th participant in order of input.\\n\\nFor any i, it must be true that either b_i = ⌊ (a_i)\\/(2) ⌋ or b_i = ⌈ (a_i)\\/(2) ⌉. The sum of all b_i must be equal to 0.\\n\\nIf there are multiple solutions, print any. We can show that a solution exists for any valid input.\\n\\nExamples\\n\\nInput\\n\\n\\n3\\n10\\n-5\\n-5\\n\\n\\nOutput\\n\\n\\n5\\n-2\\n-3\\n\\n\\nInput\\n\\n\\n7\\n-7\\n-29\\n0\\n3\\n24\\n-29\\n38\\n\\n\\nOutput\\n\\n\\n-3\\n-15\\n0\\n2\\n12\\n-15\\n19\\n\\nNote\\n\\nIn the first example, b_1 = 5, b_2 = -3 and b_3 = -2 is another correct solution.\\n\\nIn the second example there are 6 possible solutions, one of them is shown in the example output.\\nUsing java can you solve the prior task?\",\"targets\":\"import java.util.Scanner;\\n\\npublic class CGR5 {\\n\\tpublic static void main(String[] args) {\\n\\n\\t\\tint n;\\n\\t\\tScanner scan = new Scanner(System.in);\\n\\t\\tn = scan.nextInt();\\n\\t\\tint a[] = new int[n];\\n\\n\\t\\tint i;\\n\\t\\tint f = 1;\\n\\t\\tint d;\\n\\t\\tfor (i = 0; i < n; i++) {\\n\\t\\t\\ta[i] = scan.nextInt();\\n\\t\\t\\tif (a[i] % 2 == 0) {\\n\\t\\t\\t\\tSystem.out.println(a[i] \\/ 2);\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tSystem.out.println((a[i] + f) \\/ 2);\\n\\t\\t\\t\\tf *= -1;\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given a string s of length n consisting of characters a and\\/or b.\\n\\nLet \\\\operatorname{AB}(s) be the number of occurrences of string ab in s as a substring. Analogically, \\\\operatorname{BA}(s) is the number of occurrences of ba in s as a substring.\\n\\nIn one step, you can choose any index i and replace s_i with character a or b.\\n\\nWhat is the minimum number of steps you need to make to achieve \\\\operatorname{AB}(s) = \\\\operatorname{BA}(s)?\\n\\nReminder:\\n\\nThe number of occurrences of string d in s as substring is the number of indices i (1 ≤ i ≤ |s| - |d| + 1) such that substring s_i s_{i + 1} ... s_{i + |d| - 1} is equal to d. For example, \\\\operatorname{AB}(aabbbabaa) = 2 since there are two indices i: i = 2 where aabbbabaa and i = 6 where aabbbabaa.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 1000). Description of the test cases follows.\\n\\nThe first and only line of each test case contains a single string s (1 ≤ |s| ≤ 100, where |s| is the length of the string s), consisting only of characters a and\\/or b.\\n\\nOutput\\n\\nFor each test case, print the resulting string s with \\\\operatorname{AB}(s) = \\\\operatorname{BA}(s) you'll get making the minimum number of steps.\\n\\nIf there are multiple answers, print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n4\\nb\\naabbbabaa\\nabbb\\nabbaab\\n\\n\\nOutput\\n\\n\\nb\\naabbbabaa\\nbbbb\\nabbaaa\\n\\nNote\\n\\nIn the first test case, both \\\\operatorname{AB}(s) = 0 and \\\\operatorname{BA}(s) = 0 (there are no occurrences of ab (ba) in b), so can leave s untouched.\\n\\nIn the second test case, \\\\operatorname{AB}(s) = 2 and \\\\operatorname{BA}(s) = 2, so you can leave s untouched. \\n\\nIn the third test case, \\\\operatorname{AB}(s) = 1 and \\\\operatorname{BA}(s) = 0. For example, we can change s_1 to b and make both values zero.\\n\\nIn the fourth test case, \\\\operatorname{AB}(s) = 2 and \\\\operatorname{BA}(s) = 1. For example, we can change s_6 to a and make both values equal to 1.\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nvoid solve() {\\n long long int n, m, k, x, y, i, j, ans = 0, c = 0, sum = 0;\\n string s;\\n cin >> s;\\n n = s.size();\\n for (i = 1; i < n; i++) {\\n if (s[i] == 'a' && s[i - 1] == 'b')\\n c++;\\n else if (s[i] == 'b' && s[i - 1] == 'a')\\n c--;\\n }\\n if (c == 0) {\\n cout << s << \\\"\\\\n\\\";\\n return;\\n }\\n if (c > 0) {\\n for (i = n - 1; i >= 0; i--) {\\n if (s[i] == 'a') {\\n c--;\\n s[i] = 'b';\\n break;\\n }\\n }\\n cout << s << \\\"\\\\n\\\";\\n } else {\\n for (i = 0; i < n; i++) {\\n if (s[i] == 'a') {\\n s[i] = 'b';\\n break;\\n }\\n }\\n cout << s << \\\"\\\\n\\\";\\n }\\n}\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n int t;\\n t = 1;\\n cin >> t;\\n while (t--) {\\n solve();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"The grasshopper is located on the numeric axis at the point with coordinate x_0.\\n\\nHaving nothing else to do he starts jumping between integer points on the axis. Making a jump from a point with coordinate x with a distance d to the left moves the grasshopper to a point with a coordinate x - d, while jumping to the right moves him to a point with a coordinate x + d.\\n\\nThe grasshopper is very fond of positive integers, so for each integer i starting with 1 the following holds: exactly i minutes after the start he makes a jump with a distance of exactly i. So, in the first minutes he jumps by 1, then by 2, and so on.\\n\\nThe direction of a jump is determined as follows: if the point where the grasshopper was before the jump has an even coordinate, the grasshopper jumps to the left, otherwise he jumps to the right.\\n\\nFor example, if after 18 consecutive jumps he arrives at the point with a coordinate 7, he will jump by a distance of 19 to the right, since 7 is an odd number, and will end up at a point 7 + 19 = 26. Since 26 is an even number, the next jump the grasshopper will make to the left by a distance of 20, and it will move him to the point 26 - 20 = 6.\\n\\nFind exactly which point the grasshopper will be at after exactly n jumps.\\n\\nInput\\n\\nThe first line of input contains an integer t (1 ≤ t ≤ 10^4) — the number of test cases.\\n\\nEach of the following t lines contains two integers x_0 (-10^{14} ≤ x_0 ≤ 10^{14}) and n (0 ≤ n ≤ 10^{14}) — the coordinate of the grasshopper's initial position and the number of jumps.\\n\\nOutput\\n\\nPrint exactly t lines. On the i-th line print one integer — the answer to the i-th test case — the coordinate of the point the grasshopper will be at after making n jumps from the point x_0.\\n\\nExample\\n\\nInput\\n\\n\\n9\\n0 1\\n0 2\\n10 10\\n10 99\\n177 13\\n10000000000 987654321\\n-433494437 87178291199\\n1 0\\n-1 1\\n\\n\\nOutput\\n\\n\\n-1\\n1\\n11\\n110\\n190\\n9012345679\\n-87611785637\\n1\\n0\\n\\nNote\\n\\nThe first two test cases in the example correspond to the first two jumps from the point x_0 = 0. \\n\\nSince 0 is an even number, the first jump of length...\\nUsing java can you solve the prior task?\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.util.ArrayList;\\nimport java.util.Arrays;\\nimport java.util.HashMap;\\nimport java.util.HashSet;\\nimport java.util.Scanner;\\nimport java.util.StringTokenizer;\\n\\npublic class ProblemA {\\n \\n public static void main(String[] args) throws NumberFormatException, IOException {\\n BufferedReader in = new BufferedReader(new InputStreamReader(System.in));\\n int t = Integer.parseInt(in.readLine());\\n for(int i = 0; i1:\\n for itemB in lista[1]:\\n listOfNumbers.append (itemA+itemB)\\n listOfNumbers.append (itemB)\\n if n==3:\\n for itemC in lista[2]:\\n listOfNumbers.append (itemA+itemB+itemC)\\n listOfNumbers.append (itemA+itemC)\\n listOfNumbers.append (itemB+itemC)\\n listOfNumbers.append (itemC)\\nlistOfNumbersB=[]\\nfor item in listOfNumbers:\\n nums=list(permutations (item, len (item)))\\n for num in nums:\\n listOfNumbersB.append (''.join(map(str, num)))\\n\\nlistOfNumbersB=list(set (listOfNumbersB))\\nlistOfNumbers=set(listOfNumbers+listOfNumbersB)\\nlistOfNumbers=deque(sorted(list(listOfNumbers)))\\n\\n\\nind=None\\nfor i, item in enumerate(listOfNumbers):\\n if item[0]!=\\\"0\\\":\\n ind=i\\n break\\n\\n\\nif ind != None:\\n for i in xrange (ind):\\n listOfNumbers.popleft()\\n\\n\\n\\nfor a,item in enumerate(listOfNumbers):\\n listOfNumbers[a]=int(item)\\n\\nlistOfNumbers=sorted(listOfNumbers)\\n\\n\\n\\nres=listOfNumbers[-1]\\n\\nfor i, item in enumerate (listOfNumbers):\\n if item != i+1:\\n res=i\\n break\\nprint res\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. \\n\\nMasha came to test these cars. She could climb into all cars, but she liked only the smallest car. \\n\\nIt's known that a character with size a can climb into some car with size b if and only if a ≤ b, he or she likes it if and only if he can climb into this car and 2a ≥ b.\\n\\nYou are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars.\\n\\nInput\\n\\nYou are given four integers V1, V2, V3, Vm(1 ≤ Vi ≤ 100) — sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3.\\n\\nOutput\\n\\nOutput three integers — sizes of father bear's car, mother bear's car and son bear's car, respectively.\\n\\nIf there are multiple possible solutions, print any.\\n\\nIf there is no solution, print \\\"-1\\\" (without quotes).\\n\\nExamples\\n\\nInput\\n\\n50 30 10 10\\n\\n\\nOutput\\n\\n50\\n30\\n10\\n\\n\\nInput\\n\\n100 50 10 21\\n\\n\\nOutput\\n\\n-1\\n\\nNote\\n\\nIn first test case all conditions for cars' sizes are satisfied.\\n\\nIn second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20.\\nUsing java can you solve the prior task?\",\"targets\":\"var N = readline().split(' ');\\nvar a1 = parseInt(N[0]) , a2 = parseInt(N[1]) , a3 = parseInt(N[2]) , a4 = parseInt(N[3]) ;\\nvar b1 = 0 ,b2 = 0 , b3 = 0;\\nfor(var i=200;i>0;i--){\\n if(i>= a1 && i<=2*a1 && b1==0 && i >=a4 && i> 2*a4){\\n b1 = i;\\n continue;\\n }\\n if(i>= a2 && i<=2*a2 && b2==0 && i >=a4 && i> 2*a4){\\n b2 = i;\\n continue;\\n }\\n if(i>= a3 && i<= 2*a3 && b3==0 && i >=a4 && i <= 2*a4){\\n b3 = i;\\n break;\\n }\\n\\n}\\n\\n\\nif(b1 == 0 || b2 == 0 || b3 == 0){\\n print(\\\"-1\\\");\\n}else{\\n print(b1);\\n print(b2);\\n print(b3);\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Vupsen and Pupsen were gifted an integer array. Since Vupsen doesn't like the number 0, he threw away all numbers equal to 0 from the array. As a result, he got an array a of length n.\\n\\nPupsen, on the contrary, likes the number 0 and he got upset when he saw the array without zeroes. To cheer Pupsen up, Vupsen decided to come up with another array b of length n such that ∑_{i=1}^{n}a_i ⋅ b_i=0. Since Vupsen doesn't like number 0, the array b must not contain numbers equal to 0. Also, the numbers in that array must not be huge, so the sum of their absolute values cannot exceed 10^9. Please help Vupsen to find any such array b!\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. The next 2 ⋅ t lines contain the description of test cases. The description of each test case consists of two lines.\\n\\nThe first line of each test case contains a single integer n (2 ≤ n ≤ 10^5) — the length of the array.\\n\\nThe second line contains n integers a_1, a_2, …, a_n (-10^4 ≤ a_i ≤ 10^4, a_i ≠ 0) — the elements of the array a.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case print n integers b_1, b_2, …, b_n — elements of the array b (|b_1|+|b_2|+… +|b_n| ≤ 10^9, b_i ≠ 0, ∑_{i=1}^{n}a_i ⋅ b_i=0).\\n\\nIt can be shown that the answer always exists.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n2\\n5 5\\n5\\n5 -2 10 -9 4\\n7\\n1 2 3 4 5 6 7\\n\\n\\nOutput\\n\\n\\n1 -1\\n-1 5 1 -1 -1\\n-10 2 2 -3 5 -1 -1\\n\\nNote\\n\\nIn the first test case, 5 ⋅ 1 + 5 ⋅ (-1)=5-5=0. You could also print 3 -3, for example, since 5 ⋅ 3 + 5 ⋅ (-3)=15-15=0\\n\\nIn the second test case, 5 ⋅ (-1) + (-2) ⋅ 5 + 10 ⋅ 1 + (-9) ⋅ (-1) + 4 ⋅ (-1)=-5-10+10+9-4=0.\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nsigned main() {\\n ios::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n long long t;\\n cin >> t;\\n while (t--) {\\n long long n;\\n cin >> n;\\n vector arr;\\n for (long long i = 0; i < n; i++) {\\n long long num;\\n cin >> num;\\n arr.push_back(num);\\n }\\n vector b(n, 0);\\n if (n % 2 == 0) {\\n for (long long i = 0; i < n; i += 2) {\\n b[i] = arr[i + 1];\\n b[i + 1] = -arr[i];\\n }\\n } else {\\n for (long long i = 3; i < n; i += 2) {\\n b[i] = arr[i + 1];\\n b[i + 1] = -arr[i];\\n }\\n vector s({arr[0], arr[1], arr[2]});\\n sort((s).begin(), (s).end());\\n long long sum = 0;\\n if (s[1] > 0) {\\n for (long long i = 0; i < 3; i++) {\\n if (s[0] == arr[i]) {\\n b[i] = s[2] + s[1];\\n ;\\n b[(i + 1) % 3] = -s[0];\\n b[(i + 2) % 3] = -s[0];\\n break;\\n }\\n }\\n } else {\\n for (long long i = 0; i < 3; i++) {\\n if (s[2] == arr[i]) {\\n b[i] = s[0] + s[1];\\n ;\\n b[(i + 1) % 3] = -s[2];\\n b[(i + 2) % 3] = -s[2];\\n break;\\n }\\n }\\n }\\n }\\n for (auto i : b) {\\n cout << i << \\\" \\\";\\n }\\n cout << \\\"\\\\n\\\";\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"\\\"Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score...\\\" — an excerpt from contest rules.\\n\\nA total of n participants took part in the contest (n ≥ k), and you already know their scores. Calculate how many participants will advance to the next round.\\n\\nInput\\n\\nThe first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 50) separated by a single space.\\n\\nThe second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 100), where ai is the score earned by the participant who got the i-th place. The given sequence is non-increasing (that is, for all i from 1 to n - 1 the following condition is fulfilled: ai ≥ ai + 1).\\n\\nOutput\\n\\nOutput the number of participants who advance to the next round.\\n\\nExamples\\n\\nInput\\n\\n8 5\\n10 9 8 7 7 7 5 5\\n\\n\\nOutput\\n\\n6\\n\\n\\nInput\\n\\n4 2\\n0 0 0 0\\n\\n\\nOutput\\n\\n0\\n\\nNote\\n\\nIn the first example the participant on the 5th place earned 7 points. As the participant on the 6th place also earned 7 points, there are 6 advancers.\\n\\nIn the second example nobody got a positive score.\",\"targets\":\"n, k = map(int, input().split())\\na = input()\\n\\nb = []\\nnumber = \\\"\\\"\\n\\nfor i in range(len(a)):\\n if a[i] != \\\" \\\":\\n number += a[i]\\n else:\\n b.append(int(number))\\n number = \\\"\\\"\\n if i == len(a)-1:\\n b.append(int(number))\\n\\ns = 0\\n\\nfor i in range(len(b)):\\n if b[i] >= b[k-1] and b[i] > 0:\\n s += 1\\n\\nprint(s)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A binary heap which satisfies max-heap property is called max-heap. In a max-heap, for every node $i$ other than the root, $A[i] \\\\leq A[parent(i)]$, that is, the value of a node is at most the value of its parent. The largest element in a max-heap is stored at the root, and the subtree rooted at a node contains values no larger than that contained at the node itself.\\n\\nHere is an example of a max-heap.\\n\\n\\n\\n\\nWrite a program which reads an array and constructs a max-heap from the array based on the following pseudo code.\\n\\n$maxHeapify(A, i)$ move the value of $A[i]$ down to leaves to make a sub-tree of node $i$ a max-heap. Here, $H$ is the size of the heap.\\n\\n\\n1 maxHeapify(A, i)\\n2 l = left(i)\\n3 r = right(i)\\n4 \\/\\/ select the node which has the maximum value\\n5 if l ≤ H and A[l] > A[i]\\n6 largest = l\\n7 else\\n8 largest = i\\n9 if r ≤ H and A[r] > A[largest]\\n10 largest = r\\n11\\n12 if largest ≠ i \\/\\/ value of children is larger than that of i\\n13 swap A[i] and A[largest]\\n14 maxHeapify(A, largest) \\/\\/ call recursively\\n\\n\\nThe following procedure buildMaxHeap(A) makes $A$ a max-heap by performing maxHeapify in a bottom-up manner.\\n\\n\\n1 buildMaxHeap(A)\\n2 for i = H\\/2 downto 1\\n3 maxHeapify(A, i)\\n\\n\\n\\n\\nInput\\n\\nIn the first line, an integer $H$ is given. In the second line, $H$ integers which represent elements in the binary heap are given in order of node id (from $1$ to $H$).\\n\\nOutput\\n\\nPrint values of nodes in the max-heap in order of their id (from $1$ to $H$). Print a single space character before each value.\\n\\nExample\\n\\nInput\\n\\n10\\n4 1 3 2 16 9 10 14 8 7\\n\\n\\nOutput\\n\\n16 14 10 8 7 9 3 2 4 1\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include\\n#include\\n#include\\nusing namespace std;\\n\\nint h[200000000];\\nint H;\\n\\nvoid HEAP(int h[], int i) {\\n\\tint l, r, a, b, MAX;\\n\\tl = i * 2;\\n\\tr = i * 2 + 1;\\n\\tif (h[l] > h[i] && l<=H) {\\n\\t\\tMAX = l;\\n\\t}\\n\\telse {\\n\\t\\tMAX = i;\\n\\t}\\n\\tif (h[MAX] < h[r] && r<=H) {\\n\\t\\tMAX = r;\\n\\t}\\n\\tif (MAX != i) {\\n\\t\\ta = h[i];\\n\\t\\tb = h[MAX];\\n\\t\\th[i] = b;\\n\\t\\th[MAX] = a;\\n\\t\\tHEAP(h, MAX);\\n\\t}\\n}\\n\\nvoid HEAP2(int h[]){\\n\\tfor (int i = H \\/ 2; i >= 1; i--) {\\n\\t\\tHEAP(h, i);\\n\\t}\\n}\\n\\nint main() {\\n\\tcin >> H;\\n\\tfor (int i = 1; i <= H; i++) {\\n\\t\\tcin >> h[i];\\n\\t}\\n\\tHEAP2(h);\\n\\tfor (int i = 1; i <= H; i++) {\\n\\t\\tcout << ' ';\\n\\t\\tcout << h[i];\\n\\t}\\n\\tcout << endl;\\n\\treturn 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nJAG-channel\\n\\nNathan O. Davis operates an electronic bulletin board called JAG-channel. He is currently working on adding a new feature called Thread View.\\n\\nLike many other electronic bulletin boards, JAG-channel is thread-based. Here, a thread refers to a group of conversations consisting of a series of posts. There are two types of posts:\\n\\n* First post to create a new thread\\n* Reply to past posts of existing threads\\n\\n\\n\\nThe thread view is a tree-like view that represents the logical structure of the reply \\/ reply relationship between posts. Each post becomes a node of the tree and has a reply to that post as a child node. Note that direct and indirect replies to a post are subtrees as a whole.\\n\\nLet's look at an example. For example, the first post \\\"hoge\\\" has two replies \\\"fuga\\\" and \\\"piyo\\\", \\\"fuga\\\" has more replies \\\"foobar\\\" and \\\"jagjag\\\", and \\\"jagjag\\\" Suppose you get a reply \\\"zigzag\\\". The tree of this thread looks like this:\\n\\n\\nhoge\\n├─fuga\\n│ ├─foobar\\n│ └─jagjag\\n│ └─ zigzag\\n└─piyo\\n\\nNathan O. Davis hired a programmer to implement the feature, but the programmer disappeared in the final stages. This programmer has created a tree of threads and completed it to the point of displaying it in a simple format. In this simple format, the depth of the reply is represented by'.' (Half-width dot), and the reply to a certain post has one more'.' To the left than the original post. Also, the reply to a post always comes below the original post. Between the reply source post and the reply, other replies to the reply source post (and direct and indirect replies to it) may appear, but no other posts appear between them. .. The simple format display of the above tree is as follows.\\n\\n\\nhoge\\n.fuga\\n..foobar\\n..jagjag\\n... zigzag\\n.piyo\\n\\nYour job is to receive this simple format display and format it for easy viewing. That is,\\n\\n* The'.' Immediately to the left of each post (the rightmost'.' To the left of each post) is'+' (half-width plus),\\n* For direct replies to the same post, the'.' Located between the'+' immediately to the left of each...\",\"targets\":\"#include \\\"bits\\/stdc++.h\\\"\\nusing namespace std;\\nint main() {\\n\\tcin.tie(0); ios::sync_with_stdio(false);\\n\\tint n; \\n\\twhile (cin >> n, n) {\\n\\t\\tvector reply(n);\\n\\t\\tvector dot_cnt(n,0);\\n\\t\\tfor (int i = 0; i < n;i++) {\\n\\t\\t\\tcin >> reply[i];\\n\\t\\t\\tfor (int j = 0; j < reply[i].length();j++) {\\n\\t\\t\\t\\tif (reply[i][j] == '.')dot_cnt[i]++;\\n\\t\\t\\t\\telse break;\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\tfor (int i = 1; i < n;i++) {\\n\\t\\t\\treply[i][dot_cnt[i] - 1] = '+';\\n\\t\\t\\tfor (int j = i + 1;j < n;j++) {\\n\\t\\t\\t\\tif (dot_cnt[i] > dot_cnt[j])break;\\n\\t\\t\\t\\tif (dot_cnt[i] == dot_cnt[j]) {\\n\\t\\t\\t\\t\\tfor (int k = i + 1; k < j; k++) {\\n\\t\\t\\t\\t\\t\\treply[k][dot_cnt[i] - 1] = '|';\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\tfor (int i = 0; i < n;i++) {\\n\\t\\t\\tfor (int j = 0; j < reply[i].length();j++) {\\n\\t\\t\\t\\tif (reply[i][j] == '.' && j < dot_cnt[i])cout << \\\" \\\";\\n\\t\\t\\t\\telse cout << reply[i][j];\\n\\t\\t\\t}\\n\\t\\t\\tcout << endl;\\n\\t\\t}\\n\\t}\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Calculate the minimum number of characters you need to change in the string s, so that it contains at least k different letters, or print that it is impossible.\\n\\nString s consists only of lowercase Latin letters, and it is allowed to change characters only to lowercase Latin letters too.\\n\\nInput\\n\\nFirst line of input contains string s, consisting only of lowercase Latin letters (1 ≤ |s| ≤ 1000, |s| denotes the length of s).\\n\\nSecond line of input contains integer k (1 ≤ k ≤ 26).\\n\\nOutput\\n\\nPrint single line with a minimum number of necessary changes, or the word «impossible» (without quotes) if it is impossible.\\n\\nExamples\\n\\nInput\\n\\nyandex\\n6\\n\\n\\nOutput\\n\\n0\\n\\n\\nInput\\n\\nyahoo\\n5\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\ngoogle\\n7\\n\\n\\nOutput\\n\\nimpossible\\n\\nNote\\n\\nIn the first test case string contains 6 different letters, so we don't need to change anything.\\n\\nIn the second test case string contains 4 different letters: {'a', 'h', 'o', 'y'}. To get 5 different letters it is necessary to change one occurrence of 'o' to some letter, which doesn't occur in the string, for example, {'b'}.\\n\\nIn the third test case, it is impossible to make 7 different letters because the length of the string is 6.\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nint main() {\\n string s;\\n cin >> s;\\n int k, i, count = 0;\\n cin >> k;\\n int n = s.length();\\n if (k > n)\\n cout << \\\"impossible\\\" << endl;\\n else {\\n map m;\\n for (i = 0; i < n; i++) {\\n m[s[i]]++;\\n }\\n for (i = 0; i < 26; i++) {\\n if (m[i + 'a'] > 0) count++;\\n }\\n if (count >= k) {\\n cout << 0 << endl;\\n } else {\\n cout << k - count << endl;\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given n segments on a number line, numbered from 1 to n. The i-th segments covers all integer points from l_i to r_i and has a value w_i.\\n\\nYou are asked to select a subset of these segments (possibly, all of them). Once the subset is selected, it's possible to travel between two integer points if there exists a selected segment that covers both of them. A subset is good if it's possible to reach point m starting from point 1 in arbitrary number of moves.\\n\\nThe cost of the subset is the difference between the maximum and the minimum values of segments in it. Find the minimum cost of a good subset.\\n\\nIn every test there exists at least one good subset.\\n\\nInput\\n\\nThe first line contains two integers n and m (1 ≤ n ≤ 3 ⋅ 10^5; 2 ≤ m ≤ 10^6) — the number of segments and the number of integer points.\\n\\nEach of the next n lines contains three integers l_i, r_i and w_i (1 ≤ l_i < r_i ≤ m; 1 ≤ w_i ≤ 10^6) — the description of the i-th segment.\\n\\nIn every test there exists at least one good subset.\\n\\nOutput\\n\\nPrint a single integer — the minimum cost of a good subset.\\n\\nExamples\\n\\nInput\\n\\n\\n5 12\\n1 5 5\\n3 4 10\\n4 10 6\\n11 12 5\\n10 12 3\\n\\n\\nOutput\\n\\n\\n3\\n\\n\\nInput\\n\\n\\n1 10\\n1 10 23\\n\\n\\nOutput\\n\\n\\n0\\nSolve the task in JAVA.\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\n\\npublic class Main {\\n\\tstatic BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\\n\\tstatic StringTokenizer st;\\n\\tstatic PrintWriter pr = new PrintWriter(new OutputStreamWriter(System.out));\\n\\tstatic String readLine() throws IOException {\\n\\t\\treturn br.readLine();\\n\\t}\\n\\tstatic String next() throws IOException {\\n\\t\\twhile (st == null || !st.hasMoreTokens())\\n\\t\\t\\tst = new StringTokenizer(readLine());\\n\\t\\treturn st.nextToken();\\n\\t}\\n\\tstatic int readInt() throws IOException {\\n\\t\\treturn Integer.parseInt(next());\\n\\t}\\n\\tstatic long readLong() throws IOException {\\n\\t\\treturn Long.parseLong(next());\\n\\t}\\n\\tstatic double readDouble() throws IOException {\\n\\t\\treturn Double.parseDouble(next());\\n\\t}\\n\\tstatic char readChar() throws IOException {\\n\\t\\treturn next().charAt(0);\\n\\t}\\n\\tstatic class Pair implements Comparable {\\n\\t\\tint f, s;\\n\\t\\tPair(int f, int s) {\\n\\t\\t\\tthis.f = f; this.s = s;\\n\\t\\t}\\n\\t\\tpublic int compareTo(Pair other) {\\n\\t\\t\\tif (this.f != other.f) return this.f - other.f;\\n\\t\\t\\treturn this.s - other.s;\\n\\t\\t}\\n\\t}\\n\\tstatic class Segment implements Comparable {\\n\\t\\tint L, R, w;\\n\\t\\tSegment(int L, int R, int w) {\\n\\t\\t\\tthis.L = L; this.R = R; this.w = w;\\n\\t\\t}\\n\\t\\tpublic int compareTo(Segment other) {\\n\\t\\t\\treturn this.w - other.w;\\n\\t\\t}\\n\\t}\\n\\tfinal static int inf = (int)1e9;\\n\\tstatic int t[], lz[];\\n\\tstatic void push(int v) {\\n\\t\\tif (lz[v] != 0) {\\n\\t\\t\\tt[v<<1] = Math.max(t[v<<1], lz[v]);\\n\\t\\t\\tlz[v<<1] = Math.max(lz[v<<1], lz[v]);\\n\\t\\t\\tt[v<<1|1] = Math.max(t[v<<1|1], lz[v]);\\n\\t\\t\\tlz[v<<1|1] = Math.max(lz[v<<1|1], lz[v]);\\n\\t\\t\\tlz[v] = 0;\\n\\t\\t}\\n\\t}\\n\\tstatic void update(int qL, int qR, int val, int L, int R, int v) {\\n\\t\\tif (qL <= L && R <= qR) {\\n\\t\\t\\tt[v] = Math.max(t[v], val);\\n\\t\\t\\tlz[v] = Math.max(lz[v], val);\\n\\t\\t} else if (qL <= R && L <= qR) {\\n\\t\\t\\tint M = (L + R)>>1;\\n\\t\\t\\tpush(v);\\n\\t\\t\\tupdate(qL, qR, val, L, M, v<<1);\\n\\t\\t\\tupdate(qL, qR, val, M + 1, R, v<<1|1);\\n\\t\\t\\tt[v] = Math.min(t[v<<1], t[v<<1|1]);\\n\\t\\t}\\n\\t}\\n\\tstatic int n, m;\\n\\tstatic Segment seg[];\\n\\tstatic void solve() throws IOException {\\n\\t\\tn = readInt();\\n\\t\\tm = readInt();\\n\\t\\tseg = new...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nOn the well-known testing system MathForces, a draw of n rating units is arranged. The rating will be distributed according to the following algorithm: if k participants take part in this event, then the n rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.\\n\\nFor example, if n = 5 and k = 3, then each participant will recieve an 1 rating unit, and also 2 rating units will remain unused. If n = 5, and k = 6, then none of the participants will increase their rating.\\n\\nVasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.\\n\\nFor example, if n=5, then the answer is equal to the sequence 0, 1, 2, 5. Each of the sequence values (and only them) can be obtained as ⌊ n\\/k ⌋ for some positive integer k (where ⌊ x ⌋ is the value of x rounded down): 0 = ⌊ 5\\/7 ⌋, 1 = ⌊ 5\\/5 ⌋, 2 = ⌊ 5\\/2 ⌋, 5 = ⌊ 5\\/1 ⌋.\\n\\nWrite a program that, for a given n, finds a sequence of all possible rating increments.\\n\\nInput\\n\\nThe first line contains integer number t (1 ≤ t ≤ 10) — the number of test cases in the input. Then t test cases follow.\\n\\nEach line contains an integer n (1 ≤ n ≤ 10^9) — the total number of the rating units being drawn.\\n\\nOutput\\n\\nOutput the answers for each of t test cases. Each answer should be contained in two lines.\\n\\nIn the first line print a single integer m — the number of different rating increment values that Vasya can get.\\n\\nIn the following line print m integers in ascending order — the values of possible rating increments.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n5\\n11\\n1\\n3\\n\\n\\nOutput\\n\\n\\n4\\n0 1 2 5 \\n6\\n0 1 2 3 5 11 \\n2\\n0 1 \\n3\\n0 1 3\",\"targets\":\"#include \\nusing namespace std;\\nlong long t;\\nlong long n;\\nint main() {\\n cin >> t;\\n for (; t >= 1; --t) {\\n cin >> n;\\n vector f;\\n for (int i = 1; i <= trunc(sqrt(n)); ++i)\\n if (n \\/ i == i)\\n f.push_back(i);\\n else\\n f.push_back(i), f.push_back(n \\/ i);\\n f.push_back(0);\\n sort(f.begin(), f.end());\\n cout << f.size() << endl;\\n for (int i = 0; i < f.size(); ++i) cout << f[i] << \\\" \\\";\\n cout << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nNow that you have proposed a fake post for the HC2 Facebook page, Heidi wants to measure the quality of the post before actually posting it. She recently came across a (possibly fake) article about the impact of fractal structure on multimedia messages and she is now trying to measure the self-similarity of the message, which is defined as\\n\\n\\n\\nwhere the sum is over all nonempty strings p and is the number of occurences of p in s as a substring. (Note that the sum is infinite, but it only has a finite number of nonzero summands.)\\n\\nHeidi refuses to do anything else until she knows how to calculate this self-similarity. Could you please help her? (If you would like to instead convince Heidi that a finite string cannot be a fractal anyway – do not bother, we have already tried.)\\n\\nInput\\n\\nThe input starts with a line indicating the number of test cases T (1 ≤ T ≤ 10). After that, T test cases follow, each of which consists of one line containing a string s (1 ≤ |s| ≤ 100 000) composed of lowercase letters (a-z).\\n\\nOutput\\n\\nOutput T lines, every line containing one number – the answer to the corresponding test case.\\n\\nExample\\n\\nInput\\n\\n4\\naa\\nabcd\\nccc\\nabcc\\n\\n\\nOutput\\n\\n5\\n10\\n14\\n12\\n\\nNote\\n\\nA string s contains another string p as a substring if p is a contiguous subsequence of s. For example, ab is a substring of cab but not of acb.\",\"targets\":\"#include \\nusing namespace std;\\nint T, n, fa[200010], son[200010][26], len[200010], val[200010], cnt, las,\\n c[200010], sa[200010];\\nlong long ans;\\nchar s[200010];\\nvoid add(int c) {\\n int now = ++cnt, p = las;\\n len[now] = len[p] + 1;\\n while (p && !son[p][c]) son[p][c] = now, p = fa[p];\\n if (!p)\\n fa[now] = 1;\\n else {\\n int q = son[p][c];\\n if (len[q] == len[p] + 1)\\n fa[now] = q;\\n else {\\n int nq = ++cnt;\\n memcpy(son[nq], son[q], sizeof son[q]);\\n fa[nq] = fa[q];\\n len[nq] = len[p] + 1;\\n while (p && son[p][c] == q) son[p][c] = nq, p = fa[p];\\n fa[now] = fa[q] = nq;\\n }\\n }\\n ++val[now];\\n las = now;\\n}\\nint main() {\\n scanf(\\\"%d\\\", &T);\\n while (T--) {\\n ans = 0;\\n cnt = las = 1;\\n memset(son, 0, sizeof(son));\\n memset(c, 0, sizeof(c));\\n memset(val, 0, sizeof(val));\\n scanf(\\\"%s\\\", s + 1);\\n n = strlen(s + 1);\\n for (int i = 1; i <= n; ++i) add(s[i] - 'a');\\n for (int i = 1; i <= cnt; ++i) ++c[len[i]];\\n for (int i = 1; i <= n; ++i) c[i] += c[i - 1];\\n for (int i = cnt; i >= 1; --i) sa[c[len[i]]--] = i;\\n for (int i = cnt; i >= 1; --i) {\\n int k = sa[i];\\n ans += (long long)(len[k] - len[fa[k]]) * val[k] * val[k];\\n val[fa[k]] += val[k];\\n }\\n printf(\\\"%lld\\\\n\\\", ans);\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A string is called square if it is some string written twice in a row. For example, the strings \\\"aa\\\", \\\"abcabc\\\", \\\"abab\\\" and \\\"baabaa\\\" are square. But the strings \\\"aaa\\\", \\\"abaaab\\\" and \\\"abcdabc\\\" are not square.\\n\\nFor a given string s determine if it is square.\\n\\nInput\\n\\nThe first line of input data contains an integer t (1 ≤ t ≤ 100) —the number of test cases.\\n\\nThis is followed by t lines, each containing a description of one test case. The given strings consist only of lowercase Latin letters and have lengths between 1 and 100 inclusive.\\n\\nOutput\\n\\nFor each test case, output on a separate line:\\n\\n * YES if the string in the corresponding test case is square, \\n * NO otherwise. \\n\\n\\n\\nYou can output YES and NO in any case (for example, strings yEs, yes, Yes and YES will be recognized as a positive response).\\n\\nExample\\n\\nInput\\n\\n\\n10\\na\\naa\\naaa\\naaaa\\nabab\\nabcabc\\nabacaba\\nxxyy\\nxyyx\\nxyxy\\n\\n\\nOutput\\n\\n\\nNO\\nYES\\nNO\\nYES\\nYES\\nYES\\nNO\\nNO\\nNO\\nYES\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"def process(s):\\n\\n if len(s)%2==1:\\n return False\\n\\n else: return s[0:int(len(s)\\/2)]==s[int(len(s)\\/2):]\\n\\n\\n\\nt = int(input())\\n\\nfor i in range(t):\\n \\n s = input()\\n\\n b = process(s)\\n if(b):\\n print(\\\"YES\\\")\\n else:\\n print(\\\"NO\\\")\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CQXYM wants to create a connected undirected graph with n nodes and m edges, and the diameter of the graph must be strictly less than k-1. Also, CQXYM doesn't want a graph that contains self-loops or multiple edges (i.e. each edge connects two different vertices and between each pair of vertices there is at most one edge).\\n\\nThe diameter of a graph is the maximum distance between any two nodes.\\n\\nThe distance between two nodes is the minimum number of the edges on the path which endpoints are the two nodes.\\n\\nCQXYM wonders whether it is possible to create such a graph.\\n\\nInput\\n\\nThe input consists of multiple test cases. \\n\\nThe first line contains an integer t (1 ≤ t ≤ 10^5) — the number of test cases. The description of the test cases follows.\\n\\nOnly one line of each test case contains three integers n(1 ≤ n ≤ 10^9), m, k (0 ≤ m,k ≤ 10^9).\\n\\nOutput\\n\\nFor each test case, print YES if it is possible to create the graph, or print NO if it is impossible. You can print each letter in any case (upper or lower).\\n\\nExample\\n\\nInput\\n\\n\\n5\\n1 0 3\\n4 5 3\\n4 6 3\\n5 4 1\\n2 1 1\\n\\n\\nOutput\\n\\n\\nYES\\nNO\\nYES\\nNO\\nNO\\n\\nNote\\n\\nIn the first test case, the graph's diameter equal to 0.\\n\\nIn the second test case, the graph's diameter can only be 2.\\n\\nIn the third test case, the graph's diameter can only be 1.\\nSolve the task in JAVA.\",\"targets\":\"import java.util.*;\\nimport java.util.Map.Entry;\\nimport java.io.*;\\n\\npublic class CF {\\n\\tprivate static FS sc = new FS();\\n\\t\\n\\tprivate static class FS {\\n\\t\\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\\n\\t\\tStringTokenizer st = new StringTokenizer(\\\"\\\");\\n\\t\\tString next() {\\n\\t\\t\\twhile (!st.hasMoreTokens())\\n\\t\\t\\t\\ttry {\\n\\t\\t\\t\\t\\tst=new StringTokenizer(br.readLine());\\t\\t\\t\\t \\n\\t } catch (IOException e) {}\\n\\t\\t\\treturn st.nextToken();\\n\\t\\t}\\n\\t\\t\\n\\t\\tint nextInt() {\\n\\t\\t\\treturn Integer.parseInt(next());\\n\\t\\t}\\n\\t\\tlong nextLong() {\\n\\t\\t\\treturn Long.parseLong(next());\\n\\t\\t}\\n\\t}\\n\\t\\n\\tprivate static class extra {\\n\\t\\t\\n\\t\\tstatic int[] intArr(int size) {\\n\\t\\t\\tint[] a = new int[size];\\n\\t\\t\\tfor(int i = 0; i < size; i++) a[i] = sc.nextInt();\\n\\t\\t\\treturn a;\\n\\t\\t}\\n\\t\\t\\n\\t\\tstatic long[] longArr(int size) {\\n\\t\\t\\tlong[] a = new long[size];\\n\\t\\t\\tfor(int i = 0; i < size; i++) a[i] = sc.nextLong();\\n\\t\\t\\treturn a;\\n\\t\\t}\\n\\t\\t\\n\\t\\tstatic long intSum(int[] a) {\\n\\t\\t\\tlong sum = 0; \\n\\t\\t\\tfor(int i = 0; i < a.length; i++) {\\n\\t\\t\\t\\tsum += a[i];\\n\\t\\t\\t}\\n\\t\\t\\treturn sum;\\n\\t\\t}\\n\\t\\t\\n\\t\\tstatic long longSum(long[] a) {\\n\\t\\t\\tlong sum = 0; \\n\\t\\t\\tfor(int i = 0; i < a.length; i++) {\\n\\t\\t\\t\\tsum += a[i];\\n\\t\\t\\t}\\n\\t\\t\\treturn sum;\\n\\t\\t}\\n\\t\\t\\n\\t\\tstatic LinkedList[] graphD(int vertices, int edges) {\\n\\t\\t\\tLinkedList[] temp = new LinkedList[vertices+1];\\n\\t\\t\\tfor(int i = 0; i <= vertices; i++) temp[i] = new LinkedList<>();\\n\\t\\t\\tfor(int i = 0; i < edges; i++) {\\n\\t\\t\\t\\tint x = sc.nextInt();\\n\\t\\t\\t\\tint y = sc.nextInt();\\n\\t\\t\\t\\ttemp[x].add(y);\\n\\t\\t\\t}\\n\\t\\t\\treturn temp;\\n\\t\\t}\\n\\t\\t\\n\\t\\tstatic LinkedList[] graphUD(int vertices, int edges) {\\n\\t\\t\\tLinkedList[] temp = new LinkedList[vertices+1];\\n\\t\\t\\tfor(int i = 0; i <= vertices; i++) temp[i] = new LinkedList<>();\\n\\t\\t\\tfor(int i = 0; i < edges; i++) {\\n\\t\\t\\t\\tint x = sc.nextInt();\\n\\t\\t\\t\\tint y = sc.nextInt();\\n\\t\\t\\t\\ttemp[x].add(y);\\n\\t\\t\\t\\ttemp[y].add(x);\\n\\t\\t\\t}\\n\\t\\t\\treturn temp;\\n\\t\\t}\\n\\t\\t\\n\\t\\tstatic void printG(LinkedList[] temp) {\\n\\t\\t\\tfor(LinkedList aa:temp) System.out.println(aa);\\n\\t\\t}\\n\\t\\t\\n\\t\\tstatic long cal(long val, long pow, long mod) {\\n\\t\\t\\tif(pow == 0) return 1;\\n\\t\\t\\tlong res = cal(val, pow\\/2,...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Breaking news from zombie neurology! It turns out that – contrary to previous beliefs – every zombie is born with a single brain, and only later it evolves into a complicated brain structure. In fact, whenever a zombie consumes a brain, a new brain appears in its nervous system and gets immediately connected to one of the already existing brains using a single brain connector. Researchers are now interested in monitoring the brain latency of a zombie. Your task is to write a program which, given a history of evolution of a zombie's nervous system, computes its brain latency at every stage.\\n\\nInput\\n\\nThe first line of the input contains one number n – the number of brains in the final nervous system (2 ≤ n ≤ 200000). In the second line a history of zombie's nervous system evolution is given. For convenience, we number all the brains by 1, 2, ..., n in the same order as they appear in the nervous system (the zombie is born with a single brain, number 1, and subsequently brains 2, 3, ..., n are added). The second line contains n - 1 space-separated numbers p2, p3, ..., pn, meaning that after a new brain k is added to the system, it gets connected to a parent-brain .\\n\\nOutput\\n\\nOutput n - 1 space-separated numbers – the brain latencies after the brain number k is added, for k = 2, 3, ..., n.\\n\\nExample\\n\\nInput\\n\\n6\\n1\\n2\\n2\\n1\\n5\\n\\n\\nOutput\\n\\n1 2 2 3 4 \\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nint in[200001], out[200001], p[200001][21], h[200001], timer;\\nvector g[200001];\\nvoid dfs(int cur) {\\n in[cur] = ++timer;\\n for (int i(0); i < g[cur].size(); ++i) dfs(g[cur][i]);\\n out[cur] = ++timer;\\n}\\nbool is_A_of(int ver, int A) { return in[A] <= in[ver] && out[A] >= out[ver]; }\\nint LCA(int u, int v) {\\n if (h[u] < h[v]) swap(u, v);\\n if (is_A_of(u, v)) return v;\\n int up(20);\\n for (; up && (!p[v][up] || is_A_of(u, p[v][up])); --up)\\n ;\\n return LCA(u, p[v][up]);\\n}\\nint get_dist(int u, int v) { return h[u] + h[v] - 2 * h[LCA(u, v)]; }\\nint main() {\\n ios_base::sync_with_stdio(false);\\n int n;\\n cin >> n;\\n h[1] = 0;\\n int q;\\n for (int i(0); i < n - 1; ++i) {\\n cin >> q;\\n g[q].push_back(i + 2);\\n p[i + 2][0] = q;\\n h[i + 2] = h[q] + 1;\\n }\\n dfs(1);\\n for (int H(1); H <= 20; ++H)\\n for (int i(1); i <= n; ++i) p[i][H] = p[p[i][H - 1]][H - 1];\\n int u(1), v(1), dist(0);\\n for (int i(2); i <= n; ++i) {\\n int dist1(get_dist(i, u)), dist2(get_dist(i, v));\\n if (dist1 > dist2) {\\n if (dist1 > dist) v = i, dist = dist1;\\n } else {\\n if (dist2 > dist) u = i, dist = dist2;\\n }\\n cout << dist << ' ';\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Cardbluff is popular sport game in Telegram. Each Cardbluff player has ever dreamed about entrance in the professional layer. There are n judges now in the layer and you are trying to pass the entrance exam. You have a number k — your skill in Cardbluff.\\n\\nEach judge has a number a_i — an indicator of uncertainty about your entrance to the professional layer and a number e_i — an experience playing Cardbluff. To pass the exam you need to convince all judges by playing with them. You can play only one game with each judge. As a result of a particular game, you can divide the uncertainty of i-th judge by any natural divisor of a_i which is at most k. If GCD of all indicators is equal to 1, you will enter to the professional layer and become a judge.\\n\\nAlso, you want to minimize the total amount of spent time. So, if you play with x judges with total experience y you will spend x ⋅ y seconds.\\n\\nPrint minimal time to enter to the professional layer or -1 if it's impossible.\\n\\nInput\\n\\nThere are two numbers in the first line n and k (1 ≤ n ≤ 10^6, 1 ≤ k ≤ 10^{12}) — the number of judges and your skill in Cardbluff.\\n\\nThe second line contains n integers, where i-th number a_i (1 ≤ a_i ≤ 10^{12}) — the uncertainty of i-th judge\\n\\nThe third line contains n integers in the same format (1 ≤ e_i ≤ 10^9), e_i — the experience of i-th judge.\\n\\nOutput\\n\\nPrint the single integer — minimal number of seconds to pass exam, or -1 if it's impossible\\n\\nExamples\\n\\nInput\\n\\n\\n3 6\\n30 30 30\\n100 4 5\\n\\n\\nOutput\\n\\n\\n18\\n\\n\\nInput\\n\\n\\n1 1000000\\n1\\n100\\n\\n\\nOutput\\n\\n\\n0\\n\\n\\nInput\\n\\n\\n3 5\\n7 7 7\\n1 1 1\\n\\n\\nOutput\\n\\n\\n-1\\nSolve the task in CPP.\",\"targets\":\"#include \\n#pragma comment(linker, \\\"\\/STACK:512000000\\\")\\nusing namespace std;\\nusing li = long long;\\nusing ld = long double;\\nvoid solve(bool);\\nvoid precalc();\\nclock_t start;\\nint main() {\\n start = clock();\\n int t = 1;\\n cout.sync_with_stdio(0);\\n cin.tie(0);\\n cout.precision(20);\\n cout << fixed;\\n precalc();\\n while (t--) {\\n solve(true);\\n }\\n cout.flush();\\n return 0;\\n}\\ntemplate \\nT binpow(T q, T w, T mod) {\\n if (!w) return 1 % mod;\\n if (w & 1) return q * 1LL * binpow(q, w - 1, mod) % mod;\\n return binpow(q * 1LL * q % mod, w \\/ 2, mod);\\n}\\ntemplate \\nT gcd(T q, T w) {\\n while (w) {\\n q %= w;\\n swap(q, w);\\n }\\n return q;\\n}\\ntemplate \\nT lcm(T q, T w) {\\n return q \\/ gcd(q, w) * w;\\n}\\ntemplate \\nvoid make_unique(vector& vec) {\\n sort(vec.begin(), vec.end());\\n vec.erase(unique(vec.begin(), vec.end()), vec.end());\\n}\\ntemplate \\nvoid relax_min(T& cur, T val) {\\n cur = min(cur, val);\\n}\\ntemplate \\nvoid relax_max(T& cur, T val) {\\n cur = max(cur, val);\\n}\\nmt19937 rng(\\n (unsigned long long)chrono::steady_clock::now().time_since_epoch().count());\\nvoid precalc() {}\\nli dp[2][12][1 << 12];\\nvoid solve(__attribute__((unused)) bool read) {\\n int n;\\n li k;\\n if (read) {\\n cin >> n >> k;\\n } else {\\n n = 1e6;\\n k = (li)1e12;\\n }\\n vector

  • a(n), cost(n);\\n li g = 0;\\n for (int i = 0; i < n; ++i) {\\n if (read) {\\n cin >> a[i];\\n } else {\\n a[i] = 200560490130LL;\\n }\\n g = gcd(a[i], g);\\n }\\n for (int i = 0; i < n; ++i) {\\n if (read) {\\n cin >> cost[i];\\n } else {\\n cost[i] = rand();\\n }\\n }\\n vector
  • primes;\\n for (li p = 2; p * p <= g; ++p) {\\n if (g % p == 0) {\\n primes.push_back(p);\\n while (g % p == 0) {\\n g \\/= p;\\n }\\n }\\n }\\n if (g > 1) {\\n primes.push_back(g);\\n }\\n if (primes.empty()) {\\n cout << \\\"0\\\\n\\\";\\n return;\\n }\\n vector> mapa;\\n for (int i = 0; i < n; ++i) {\\n li cur_val = 1;\\n for (int j = 0; j < primes.size(); ++j) {\\n auto p =...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given two integers n and m. Find the \\\\operatorname{MEX} of the sequence n ⊕ 0, n ⊕ 1, …, n ⊕ m. Here, ⊕ is the [bitwise XOR operator](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#XOR).\\n\\n\\\\operatorname{MEX} of the sequence of non-negative integers is the smallest non-negative integer that doesn't appear in this sequence. For example, \\\\operatorname{MEX}(0, 1, 2, 4) = 3, and \\\\operatorname{MEX}(1, 2021) = 0. \\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 30 000) — the number of test cases.\\n\\nThe first and only line of each test case contains two integers n and m (0 ≤ n, m ≤ 10^9).\\n\\nOutput\\n\\nFor each test case, print a single integer — the answer to the problem.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n3 5\\n4 6\\n3 2\\n69 696\\n123456 654321\\n\\n\\nOutput\\n\\n\\n4\\n3\\n0\\n640\\n530866\\n\\nNote\\n\\nIn the first test case, the sequence is 3 ⊕ 0, 3 ⊕ 1, 3 ⊕ 2, 3 ⊕ 3, 3 ⊕ 4, 3 ⊕ 5, or 3, 2, 1, 0, 7, 6. The smallest non-negative integer which isn't present in the sequence i. e. the \\\\operatorname{MEX} of the sequence is 4.\\n\\nIn the second test case, the sequence is 4 ⊕ 0, 4 ⊕ 1, 4 ⊕ 2, 4 ⊕ 3, 4 ⊕ 4, 4 ⊕ 5, 4 ⊕ 6, or 4, 5, 6, 7, 0, 1, 2. The smallest non-negative integer which isn't present in the sequence i. e. the \\\\operatorname{MEX} of the sequence is 3.\\n\\nIn the third test case, the sequence is 3 ⊕ 0, 3 ⊕ 1, 3 ⊕ 2, or 3, 2, 1. The smallest non-negative integer which isn't present in the sequence i. e. the \\\\operatorname{MEX} of the sequence is 0.\",\"targets\":\"#include \\nusing namespace std;\\nint n, k;\\nvoid solve() {\\n cin >> n >> k;\\n int ans = 0;\\n for (int i = 30; i >= 0; --i) {\\n int t1 = 0, t2 = 0;\\n if (n & (1 << i)) t1 = 1;\\n if (k & (1 << i)) t2 = 1;\\n if (t1 && t2)\\n continue;\\n else if (t1) {\\n cout << ans << endl;\\n return;\\n } else if (t2) {\\n ans += (1 << i);\\n } else {\\n if ((k % (1 << i)) + 1 == (1 << i)) {\\n cout << ans + (1 << i) << endl;\\n return;\\n }\\n }\\n }\\n cout << ans << endl;\\n}\\nint main() {\\n int t = 1;\\n cin >> t;\\n while (t--) solve();\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"\\n\\nWilliam has an array of n integers a_1, a_2, ..., a_n. In one move he can swap two neighboring items. Two items a_i and a_j are considered neighboring if the condition |i - j| = 1 is satisfied.\\n\\nWilliam wants you to calculate the minimal number of swaps he would need to perform to make it so that the array does not contain two neighboring items with the same parity.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^4). Description of the test cases follows.\\n\\nThe first line of each test case contains an integer n (1 ≤ n ≤ 10^5) which is the total number of items in William's array.\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) which are William's array.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 10^5.\\n\\nOutput\\n\\nFor each test case output the minimal number of operations needed or -1 if it is impossible to get the array to a state when no neighboring numbers have the same parity.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n3\\n6 6 1\\n1\\n9\\n6\\n1 1 1 2 2 2\\n2\\n8 6\\n6\\n6 2 3 4 5 1\\n\\n\\nOutput\\n\\n\\n1\\n0\\n3\\n-1\\n2\\n\\nNote\\n\\nIn the first test case the following sequence of operations would satisfy the requirements: \\n\\n 1. swap(2, 3). Array after performing the operation: [6, 1, 6] \\n\\n\\n\\nIn the second test case the array initially does not contain two neighboring items of the same parity.\\n\\nIn the third test case the following sequence of operations would satisfy the requirements: \\n\\n 1. swap(3, 4). Array after performing the operation: [1, 1, 2, 1, 2, 2] \\n 2. swap(2, 3). Array after performing the operation: [1, 2, 1, 1, 2, 2] \\n 3. swap(4, 5). Array after performing the operation: [1, 2, 1, 2, 1, 2] \\n\\n\\n\\nIn the fourth test case it is impossible to satisfy the requirements.\\n\\nIn the fifth test case the following sequence of operations would satisfy the requirements: \\n\\n 1. swap(2, 3). Array after performing the operation: [6, 3, 2, 4, 5, 1] \\n 2. swap(4, 5). Array after performing the operation: [6, 3, 2, 5, 4, 1]\",\"targets\":\"#include \\nusing namespace std;\\ntemplate \\ninline void amin(T &x, U y) {\\n if (y < x) x = y;\\n}\\ntemplate \\ninline void amax(T &x, U y) {\\n if (x < y) x = y;\\n}\\nconst int N = 1e5 + 169;\\nint a[N], pos[N];\\nlong long cal(int x, int n) {\\n int cnt[2] = {1 + (x != 0), 1 + (x != 1)};\\n vector before[2];\\n vector after[2];\\n for (int i = 1; i <= n; ++i) {\\n before[a[i] % 2].push_back(i);\\n after[a[i] % 2].push_back(cnt[a[i] % 2]);\\n cnt[a[i] % 2] += 2;\\n }\\n long long res = 1e18;\\n for (int i = 0; i < 2; ++i) {\\n int Count = 0;\\n for (int j = 0; j < before[i].size(); ++j) {\\n if (before[i][j] > n || after[i][j] > n) return 1e18;\\n Count += abs(before[i][j] - after[i][j]);\\n }\\n amin(res, Count);\\n }\\n return res;\\n}\\nint Solve() {\\n int n;\\n cin >> n;\\n int cnt[2] = {0, 0};\\n for (int i = 1; i <= n; ++i) {\\n cin >> a[i];\\n cnt[a[i] % 2]++;\\n }\\n if (abs(cnt[0] - cnt[1]) > 1) return cout << \\\"-1\\\\n\\\", 0;\\n cout << min(cal(0, n), cal(1, n)) << '\\\\n';\\n return 0;\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n ;\\n int t = 1;\\n cin >> t;\\n while (t--) {\\n Solve();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Monocarp is playing yet another computer game. In this game, his character has to kill a dragon. The battle with the dragon lasts 100^{500} seconds, during which Monocarp attacks the dragon with a poisoned dagger. The i-th attack is performed at the beginning of the a_i-th second from the battle start. The dagger itself does not deal damage, but it applies a poison effect on the dragon, which deals 1 damage during each of the next k seconds (starting with the same second when the dragon was stabbed by the dagger). However, if the dragon has already been poisoned, then the dagger updates the poison effect (i.e. cancels the current poison effect and applies a new one).\\n\\nFor example, suppose k = 4, and Monocarp stabs the dragon during the seconds 2, 4 and 10. Then the poison effect is applied at the start of the 2-nd second and deals 1 damage during the 2-nd and 3-rd seconds; then, at the beginning of the 4-th second, the poison effect is reapplied, so it deals exactly 1 damage during the seconds 4, 5, 6 and 7; then, during the 10-th second, the poison effect is applied again, and it deals 1 damage during the seconds 10, 11, 12 and 13. In total, the dragon receives 10 damage.\\n\\nMonocarp knows that the dragon has h hit points, and if he deals at least h damage to the dragon during the battle — he slays the dragon. Monocarp has not decided on the strength of the poison he will use during the battle, so he wants to find the minimum possible value of k (the number of seconds the poison effect lasts) that is enough to deal at least h damage to the dragon.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases.\\n\\nThe first line of the test case contains two integers n and h (1 ≤ n ≤ 100; 1 ≤ h ≤ 10^{18}) — the number of Monocarp's attacks and the amount of damage that needs to be dealt.\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9; a_i < a_{i + 1}), where a_i is the second when the i-th attack is performed.\\n\\nOutput\\n\\nFor each test case, print a single...\",\"targets\":\"import sys\\ntesting = len(sys.argv) == 4 and sys.argv[3] == \\\"myTest\\\"\\ninteractive = False\\nif testing:\\n cmd = sys.stdout\\n from time import time\\n start_time = int(round(time() * 1000)) \\n readAll = open(sys.argv[1], 'r').read\\n sys.stdout = open(sys.argv[2], 'w')\\nelse:\\n readAll = sys.stdin.read\\n\\n# ############ ---- I\\/O Functions ---- ############\\n\\nclass InputData:\\n def __init__(self):\\n self.lines = readAll().split('\\\\n')\\n self.n = len(self.lines)\\n self.ii = -1\\n def input(self):\\n self.ii += 1\\n assert self.ii < self.n\\n return self.lines[self.ii]\\n\\nflush = sys.stdout.flush\\nif interactive and not testing:\\n input = sys.stdin.readline\\nelse:\\n inputData = InputData()\\n input = inputData.input\\n\\ndef intin():\\n return(int(input()))\\ndef intlin():\\n return(list(map(int,input().split())))\\ndef chrin():\\n return(list(input()))\\ndef strin():\\n return input()\\ndef lout(l, sep=\\\"\\\\n\\\", toStr=True):\\n print(sep.join(map(str, l) if toStr else l))\\ndef dout(*args, **kargs):\\n if not testing: return\\n if args: print(args[0] if len(args)==1 else args)\\n if kargs: print([(k,v) for k,v in kargs.items()])\\ndef ask(q):\\n sys.stdout.write(str(q)+'\\\\n')\\n flush()\\n return intin()\\n \\n# ############ ---- I\\/O Functions ---- ############\\n\\n# from math import ceil\\n# from collections import defaultdict as ddict, Counter\\n# from heapq import *\\n# from Queue import Queue\\n\\ndef main():\\n n,h = intlin()\\n a = intlin()\\n if n == 1:\\n return h\\n b = [a[i]-a[i-1] for i in xrange(1,n)]\\n b.sort()\\n k = h\\/n\\n if k*n >= h and k <= b[0]:\\n return k\\n if (k+1)*n >= h and k+1 <= b[0]:\\n return k+1\\n # dout(b)\\n i = 0\\n while i < n-1:\\n h -= b[i]\\n i += 1\\n if i == n-1:\\n return h\\n if b[i]*(n-i) >= h:\\n k = h\\/(n-i)\\n if k*(n-i) >= h:\\n return k\\n return k+1\\n \\n\\nanss = []\\nfor _ in xrange(intin()):\\n anss.append(main())\\n # anss.append(\\\"YES\\\" if main() else...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given an array a of length n.\\n\\nLet's define the eversion operation. Let x = a_n. Then array a is partitioned into two parts: left and right. The left part contains the elements of a that are not greater than x (≤ x). The right part contains the elements of a that are strictly greater than x (> x). The order of elements in each part is kept the same as before the operation, i. e. the partition is stable. Then the array is replaced with the concatenation of the left and the right parts.\\n\\nFor example, if the array a is [2, 4, 1, 5, 3], the eversion goes like this: [2, 4, 1, 5, 3] → [2, 1, 3], [4, 5] → [2, 1, 3, 4, 5].\\n\\nWe start with the array a and perform eversions on this array. We can prove that after several eversions the array a stops changing. Output the minimum number k such that the array stops changing after k eversions.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 100). Description of the test cases follows.\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 2 ⋅ 10^5).\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9).\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case print a single integer k — the number of eversions after which the array stops changing.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n5\\n2 4 1 5 3\\n5\\n5 3 2 4 1\\n4\\n1 1 1 1\\n\\n\\nOutput\\n\\n\\n1\\n2\\n0\\n\\nNote\\n\\nConsider the fist example.\\n\\n * The first eversion: a = [1, 4, 2, 5, 3], x = 3. [2, 4, 1, 5, 3] → [2, 1, 3], [4, 5] → [2, 1, 3, 4, 5]. \\n * The second and following eversions: a = [2, 1, 3, 4, 5], x = 5. [2, 1, 3, 4, 5] → [2, 1, 3, 4, 5], [] → [2, 1, 3, 4, 5]. This eversion does not change the array, so the answer is 1. \\n\\n\\n\\nConsider the second example. \\n\\n * The first eversion: a = [5, 3, 2, 4, 1], x = 1. [5, 3, 2, 4, 1] → [1], [5, 3, 2, 4] → [1, 5, 3, 2, 4]. \\n * The second eversion: a = [1, 5, 3, 2, 4], x = 4. [1, 5, 3, 2, 4] → [1, 3, 2, 4], [5] → [1, 3, 2, 4, 5]. \\n * The third and following eversions: a = [1, 3, 2, 4,...\\nUsing python3 can you solve the prior task?\",\"targets\":\"from sys import stdout, stdin\\nfrom io import IOBase, BytesIO\\nfrom os import read, supports_follow_symlinks, write, fstat\\n\\nBUFSIZE = 8192\\n\\n\\nclass FastIO(IOBase):\\n newlines = 0\\n\\n def __init__(self, file):\\n self._fd = file.fileno()\\n self.buffer = BytesIO()\\n self.writable = \\\"x\\\" in file.mode or \\\"r\\\" not in file.mode\\n self.write = self.buffer.write if self.writable else None\\n\\n def read(self):\\n while True:\\n b = read(self._fd, max(fstat(self._fd).st_size, BUFSIZE))\\n if not b:\\n break\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines = 0\\n return self.buffer.read()\\n\\n def readline(self, size: int = ...):\\n while self.newlines == 0:\\n b = read(self._fd, max(fstat(self._fd).st_size, BUFSIZE))\\n self.newlines = b.count(b\\\"\\\\n\\\") + (not b)\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines -= 1\\n return self.buffer.readline()\\n\\n def flush(self):\\n if self.writable:\\n write(self._fd, self.buffer.getvalue())\\n self.buffer.truncate(0), self.buffer.seek(0)\\n\\n\\nclass IOWrapper(IOBase):\\n def __init__(self, file):\\n self.buffer = FastIO(file)\\n self.flush = self.buffer.flush\\n self.writable = self.buffer.writable\\n self.write = lambda s: self.buffer.write(s.encode(\\\"ascii\\\"))\\n self.read = lambda: self.buffer.read().decode(\\\"ascii\\\")\\n self.readline = lambda: self.buffer.readline().decode(\\\"ascii\\\")\\n\\n\\ndef print(*args, **kwargs):\\n \\\"\\\"\\\"Prints the values to a stream, or to sys.stdout by default.\\\"\\\"\\\"\\n sep, file = kwargs.pop(\\\"sep\\\", \\\" \\\"), kwargs.pop(\\\"file\\\", stdout)\\n at_start = True\\n for x in args:\\n if not at_start:\\n file.write(sep)\\n file.write(str(x))\\n at_start = False\\n file.write(kwargs.pop(\\\"end\\\", \\\"\\\\n\\\"))\\n if kwargs.pop(\\\"flush\\\", False):\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"There are currently n hot topics numbered from 0 to n-1 at your local bridge club and 2^n players numbered from 0 to 2^n-1. Each player holds a different set of views on those n topics, more specifically, the i-th player holds a positive view on the j-th topic if i\\\\ \\\\&\\\\ 2^j > 0, and a negative view otherwise. Here \\\\& denotes the [bitwise AND operation](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#AND).\\n\\nYou are going to organize a bridge tournament capable of accommodating at most k pairs of players (bridge is played in teams of two people). You can select teams arbitrarily while each player is in at most one team, but there is one catch: two players cannot be in the same pair if they disagree on 2 or more of those n topics, as they would argue too much during the play.\\n\\nYou know that the i-th player will pay you a_i dollars if they play in this tournament. Compute the maximum amount of money that you can earn if you pair the players in your club optimally.\\n\\nInput\\n\\nThe first line contains two integers n, k (1 ≤ n ≤ 20, 1 ≤ k ≤ 200) — the number of hot topics and the number of pairs of players that your tournament can accommodate.\\n\\nThe second line contains 2^n integers a_0, a_1, ..., a_{2^n-1} (0 ≤ a_i ≤ 10^6) — the amounts of money that the players will pay to play in the tournament.\\n\\nOutput\\n\\nPrint one integer: the maximum amount of money that you can earn if you pair the players in your club optimally under the above conditions.\\n\\nExamples\\n\\nInput\\n\\n\\n3 1\\n8 3 5 7 1 10 3 2\\n\\n\\nOutput\\n\\n\\n13\\n\\n\\nInput\\n\\n\\n2 3\\n7 4 5 7\\n\\n\\nOutput\\n\\n\\n23\\n\\n\\nInput\\n\\n\\n3 2\\n1 9 1 5 7 8 1 1\\n\\n\\nOutput\\n\\n\\n29\\n\\nNote\\n\\nIn the first example, the best we can do is to pair together the 0-th player and the 2-nd player resulting in earnings of 8 + 5 = 13 dollars. Although pairing the 0-th player with the 5-th player would give us 8 + 10 = 18 dollars, we cannot do this because those two players disagree on 2 of the 3 hot topics.\\n\\nIn the second example, we can pair the 0-th player with the 1-st player and pair the 2-nd player with the 3-rd player resulting in...\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = (1 << 20) + 10;\\nstruct elem {\\n int l, r, second;\\n bool operator<(const elem& y) const { return second < y.second; }\\n} t;\\nstruct edge {\\n int t, first, c, nxt;\\n} e[160010];\\nint n, m, K, C[N], a[N], tmp, TIM, u, v, n1, n2, ind[N], con[N],\\n cnt = 1, be[N], S, T, fr[N], es[160010], siz, dis[N], iq[N], ans;\\npair a1[(1 << 19) + 10], a2[(1 << 19) + 10];\\npriority_queue q;\\nqueue qu;\\nvoid add(const int& x, const int& y, const int& c) {\\n if (!con[x]) con[x] = 1, es[++siz] = x, add(S, x, 0);\\n if (!con[y]) con[y] = 1, es[++siz] = y, add(y, T, 0);\\n e[++cnt] = (edge){y, 1, c, be[x]}, be[x] = cnt;\\n e[++cnt] = (edge){x, 0, -c, be[y]}, be[y] = cnt;\\n}\\nvoid SPFA() {\\n for (int i = 1; i <= siz; ++i) dis[es[i]] = -1e9;\\n dis[S] = 0, qu.push(S), iq[S] = 1;\\n while (!qu.empty()) {\\n tmp = qu.front(), qu.pop();\\n for (int i = be[tmp]; i; i = e[i].nxt)\\n if (e[i].first && dis[e[i].t] < dis[tmp] + e[i].c)\\n dis[e[i].t] = dis[tmp] + e[i].c, fr[e[i].t] = i,\\n !iq[e[i].t] ? qu.push(e[i].t), iq[e[i].t] = 1 : 0;\\n iq[tmp] = 0;\\n }\\n}\\nint main() {\\n scanf(\\\"%d%d\\\", &n, &K), m = (1 << n - 1), K = min(K, m), S = (1 << n),\\n T = (1 << n) + 1, con[S] = con[T] = 1, es[++siz] = S,\\n es[++siz] = T;\\n for (int i = 0; i < (1 << n); ++i)\\n scanf(\\\"%d\\\", &a[i]), (C[i] = (C[i >> 1] ^ (i & 1)))\\n ? a1[++n1] = (pair){a[i], i}\\n : a2[++n2] = (pair){a[i], i};\\n sort(a1 + 1, a1 + m + 1), sort(a2 + 1, a2 + m + 1);\\n for (int i = 1; i <= m; ++i) ind[a1[i].second] = ind[a2[i].second] = i;\\n for (int i = 1; i <= m; ++i) {\\n tmp = -1, u = a1[i].second;\\n for (int j = 0; j < n; ++j)\\n if (tmp < 0 || ind[u ^ (1 << j)] > ind[tmp]) tmp = (u ^ (1 << j));\\n q.push((elem){u, tmp, a[u] + a[tmp]});\\n }\\n for (int fr = 1; fr <= (n << 1) * K && !q.empty(); ++fr) {\\n t = q.top(), q.pop(), u = t.l, v = t.r;\\n add(u, v, t.second);\\n tmp =...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You have an array a consisting of n distinct positive integers, numbered from 1 to n. Define p_k as $$$p_k = ∑_{1 ≤ i, j ≤ k} a_i mod a_j, where x \\\\bmod y denotes the remainder when x is divided by y. You have to find and print p_1, p_2, \\\\ldots, p_n$$$. \\n\\nInput\\n\\nThe first line contains n — the length of the array (2 ≤ n ≤ 2 ⋅ 10^5).\\n\\nThe second line contains n space-separated distinct integers a_1, …, a_n (1 ≤ a_i ≤ 3 ⋅ 10^5, a_i ≠ a_j if i ≠ j). \\n\\nOutput\\n\\nPrint n integers p_1, p_2, …, p_n. \\n\\nExamples\\n\\nInput\\n\\n\\n4\\n6 2 7 3\\n\\n\\nOutput\\n\\n\\n0 2 12 22\\n\\n\\nInput\\n\\n\\n3\\n3 2 1\\n\\n\\nOutput\\n\\n\\n0 3 5\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nnamespace gao {\\nint B = 512, N = 300001, tot = N \\/ B;\\nlong long sumb[1010], sumpre[303000];\\nlong long cb[1010], cpre[303000];\\nvoid add(int pos) {\\n for (int i = pos \\/ B + 1; i <= tot; ++i) sumb[i] += pos, cb[i] += 1;\\n for (int i = pos; i \\/ B == pos \\/ B; ++i) {\\n sumpre[i] += pos, cpre[i] += 1;\\n }\\n}\\npair que(int pos) {\\n pos = min(pos, N);\\n return (pair){sumb[pos \\/ B] + sumpre[pos],\\n cb[pos \\/ B] + cpre[pos]};\\n}\\n} \\/\\/ namespace gao\\nint n;\\nlong long ans;\\nconst int maxn = 300000;\\nint main() {\\n for (cin >> n; n--;) {\\n int x;\\n scanf(\\\"%d\\\", &x);\\n {\\n pair las = {0ll, 0ll};\\n for (int i = 0; i * x <= maxn; ++i) {\\n pair now = gao::que((i + 1) * x - 1);\\n long long sum = now.first - las.first, c = now.second - las.second;\\n las = now;\\n ans += sum - c * x * i;\\n }\\n }\\n {\\n pair las = {0ll, 0ll};\\n int i = 1, sqr = sqrt(x) - 3;\\n for (; i < x;) {\\n int ne = i;\\n if (i >= sqr) ne = x \\/ (x \\/ i);\\n pair now = gao::que(ne);\\n long long sum = now.first - las.first, c = now.second - las.second;\\n las = now;\\n ans += x * c - sum * (x \\/ i);\\n i = ne + 1;\\n }\\n ans += (gao::que(maxn).second - gao::que(x).second) * x;\\n }\\n gao::add(x);\\n printf(\\\"%lld \\\", ans);\\n }\\n puts(\\\"\\\");\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given an array a consisting of n positive integers. You have to choose a positive integer d and paint all elements into two colors. All elements which are divisible by d will be painted red, and all other elements will be painted blue.\\n\\nThe coloring is called beautiful if there are no pairs of adjacent elements with the same color in the array. Your task is to find any value of d which yields a beautiful coloring, or report that it is impossible.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of testcases.\\n\\nThe first line of each testcase contains one integer n (2 ≤ n ≤ 100) — the number of elements of the array.\\n\\nThe second line of each testcase contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^{18}).\\n\\nOutput\\n\\nFor each testcase print a single integer. If there is no such value of d that yields a beautiful coloring, print 0. Otherwise, print any suitable value of d (1 ≤ d ≤ 10^{18}).\\n\\nExample\\n\\nInput\\n\\n\\n5\\n5\\n1 2 3 4 5\\n3\\n10 5 15\\n3\\n100 10 200\\n10\\n9 8 2 6 6 2 8 6 5 4\\n2\\n1 3\\n\\n\\nOutput\\n\\n\\n2\\n0\\n100\\n0\\n3\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"\\/\\/package Codeforces;\\nimport java.util.*;\\n\\nimport java.io.*;\\npublic class template{\\n\\t\\n\\tstatic class FastScanner {\\n\\t\\tBufferedReader br=new BufferedReader(new InputStreamReader(System.in));\\n\\t\\tStringTokenizer st = new StringTokenizer(\\\"\\\");\\n\\t\\tString next () {\\n\\t\\t\\twhile(!st.hasMoreTokens()) {\\n\\t\\t\\t\\ttry {\\n\\t\\t\\t\\t\\tst=new StringTokenizer(br.readLine());\\n\\t\\t\\t\\t}catch(IOException e) {\\n\\t\\t\\t\\t\\te.printStackTrace();\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\treturn st.nextToken();\\n\\t\\t}\\n\\t\\t\\n\\t\\tint nextInt() {\\n\\t\\t\\treturn Integer.parseInt(next());\\n\\t\\t}\\n\\t\\t\\n\\t\\tint[] readArray(int n) {\\n\\t\\t\\tint a[] = new int[n];\\n\\t\\t\\tfor(int i=0;i0\\n dist = 0\\n q = int(n\\/k)\\n r = n - q*k\\n if r != 0:\\n for i in range(q):\\n dist += 2*L[i*k+r-1]\\n dist += L[-1]\\n return dist\\n if r == 0:\\n for i in range(1, q):\\n dist += 2*L[i*k-1]\\n dist += L[-1]\\n return dist\\n\\ncases = int(input())\\nfor wow in range(cases):\\n line1 = input().split( )\\n n = int(line1[0])\\n k = int(line1[1])\\n long = input().split( )\\n L1 = []\\n n1 = 0\\n L2 = []\\n n2 = 0\\n for elem in long:\\n elem = int(elem)\\n if elem > 0:\\n L1.append(elem)\\n n1 += 1\\n elif elem < 0:\\n L2.append(-elem)\\n n2 += 1\\n L1.sort()\\n L2.sort()\\n if n1 == 0:\\n print(walk(n2, k, L2))\\n elif n2 == 0:\\n print(walk(n1, k, L1))\\n else:\\n if L1[-1] > L2[-1]:\\n print(walk(n1, k, L1) + walk(n2, k, L2) + L2[-1])\\n else:\\n print(walk(n1, k, L1) + walk(n2, k, L2) + L1[-1])\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\n\\n\\nWilliam really likes puzzle kits. For one of his birthdays, his friends gifted him a complete undirected edge-weighted graph consisting of n vertices.\\n\\nHe wants to build a spanning tree of this graph, such that for the first k vertices the following condition is satisfied: the degree of a vertex with index i does not exceed d_i. Vertices from k + 1 to n may have any degree.\\n\\nWilliam wants you to find the minimum weight of a spanning tree that satisfies all the conditions.\\n\\nA spanning tree is a subset of edges of a graph that forms a tree on all n vertices of the graph. The weight of a spanning tree is defined as the sum of weights of all the edges included in a spanning tree.\\n\\nInput\\n\\nThe first line of input contains two integers n, k (2 ≤ n ≤ 50, 1 ≤ k ≤ min(n - 1, 5)).\\n\\nThe second line contains k integers d_1, d_2, …, d_k (1 ≤ d_i ≤ n). \\n\\nThe i-th of the next n - 1 lines contains n - i integers w_{i,i+1}, w_{i,i+2}, …, w_{i,n} (1 ≤ w_{i,j} ≤ 100): weights of edges (i,i+1),(i,i+2),…,(i,n).\\n\\nOutput\\n\\nPrint one integer: the minimum weight of a spanning tree under given degree constraints for the first k vertices. \\n\\nExample\\n\\nInput\\n\\n\\n10 5\\n5 3 4 2 1\\n29 49 33 12 55 15 32 62 37\\n61 26 15 58 15 22 8 58\\n37 16 9 39 20 14 58\\n10 15 40 3 19 55\\n53 13 37 44 52\\n23 59 58 4\\n69 80 29\\n89 28\\n48\\n\\n\\nOutput\\n\\n\\n95\",\"targets\":\"#include \\nusing namespace std;\\nconst int max_n = 55, inf = 1000111222;\\nint copy_dsu[max_n];\\nstruct dsu {\\n int p_or_sz[max_n];\\n void init(int n) {\\n for (int i = 0; i < n; ++i) {\\n p_or_sz[i] = -1;\\n }\\n }\\n void init_from_copy(int n) {\\n for (int i = 0; i < n; ++i) {\\n p_or_sz[i] = copy_dsu[i];\\n }\\n }\\n int find_set(int v) {\\n if (p_or_sz[v] < 0) {\\n return v;\\n }\\n return p_or_sz[v] = find_set(p_or_sz[v]);\\n }\\n bool union_set(int v1, int v2) {\\n v1 = find_set(v1);\\n v2 = find_set(v2);\\n if (v1 == v2) {\\n return false;\\n }\\n if (-p_or_sz[v1] > -p_or_sz[v2]) {\\n swap(v1, v2);\\n }\\n p_or_sz[v2] += p_or_sz[v1];\\n p_or_sz[v1] = v2;\\n return true;\\n }\\n};\\nint n, k, max_deg[max_n], D[max_n][max_n];\\nint deg[max_n];\\ndsu d;\\nbool get_bit(int mask, int pos) { return (mask >> pos) & 1; }\\nstruct GroundSetElement {\\n int u, v;\\n int cost;\\n bool taken;\\n GroundSetElement() {}\\n GroundSetElement(int u, int v, int cost)\\n : u(u), v(v), cost(cost), taken(false) {}\\n bool operator<(const GroundSetElement &g) const { return cost < g.cost; }\\n};\\nconst int max_e = max_n * max_n \\/ 2;\\nvector elems;\\nint cur_deg[max_n];\\nint parent[max_e], weight[max_e];\\npair dist[max_e];\\nvector> edges;\\nbool is_s[max_e], is_t[max_e];\\nvoid prepare() {\\n d.init_from_copy(n);\\n copy(deg, deg + n, cur_deg);\\n for (int i = 0; i < elems.size(); ++i) {\\n if (elems[i].taken) {\\n d.union_set(elems[i].u, elems[i].v);\\n --cur_deg[elems[i].u];\\n --cur_deg[elems[i].v];\\n }\\n }\\n}\\nbool is_ok1(const GroundSetElement &a) {\\n return d.find_set(a.u) != d.find_set(a.v);\\n}\\nbool is_ok2(const GroundSetElement &a) {\\n return cur_deg[a.u] > 0 && cur_deg[a.v] > 0;\\n}\\nbool augment() {\\n edges.clear();\\n prepare();\\n for (int i = 0; i < elems.size(); ++i) {\\n if (!elems[i].taken) {\\n is_s[i] = is_ok1(elems[i]);\\n is_t[i] = is_ok2(elems[i]);\\n weight[i] = -elems[i].cost;\\n } else {\\n is_s[i] = is_t[i] = false;\\n weight[i] =...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"As you very well know, the whole Universe traditionally uses three-dimensional Cartesian system of coordinates. In this system each point corresponds to three real coordinates (x, y, z). In this coordinate system, the distance between the center of the Universe and the point is calculated by the following formula: . Mushroom scientists that work for the Great Mushroom King think that the Universe isn't exactly right and the distance from the center of the Universe to a point equals xa·yb·zc.\\n\\nTo test the metric of mushroom scientists, the usual scientists offered them a task: find such x, y, z (0 ≤ x, y, z; x + y + z ≤ S), that the distance between the center of the Universe and the point (x, y, z) is maximum possible in the metric of mushroom scientists. The mushroom scientists aren't good at maths, so they commissioned you to do the task.\\n\\nNote that in this problem, it is considered that 00 = 1.\\n\\nInput\\n\\nThe first line contains a single integer S (1 ≤ S ≤ 103) — the maximum sum of coordinates of the sought point.\\n\\nThe second line contains three space-separated integers a, b, c (0 ≤ a, b, c ≤ 103) — the numbers that describe the metric of mushroom scientists.\\n\\nOutput\\n\\nPrint three real numbers — the coordinates of the point that reaches maximum value in the metrics of mushroom scientists. If there are multiple answers, print any of them that meets the limitations.\\n\\nA natural logarithm of distance from the center of the Universe to the given point in the metric of mushroom scientists shouldn't differ from the natural logarithm of the maximum distance by more than 10 - 6. We think that ln(0) = - ∞.\\n\\nExamples\\n\\nInput\\n\\n3\\n1 1 1\\n\\n\\nOutput\\n\\n1.0 1.0 1.0\\n\\n\\nInput\\n\\n3\\n2 0 0\\n\\n\\nOutput\\n\\n3.0 0.0 0.0\",\"targets\":\"#include \\nusing namespace std;\\nlong long null = 0;\\nstruct segment;\\nstruct line;\\nstruct point;\\nstruct vec;\\nstruct ray;\\nstruct point {\\n long double x, y;\\n point() {}\\n point(long double x1, long double y1) {\\n x = x1;\\n y = y1;\\n }\\n long double dist_to_point(point p) {\\n return sqrt((p.x - x) * (p.x - x) + (p.y - y) * (p.y - y));\\n }\\n bool operator<(point p) { return (x < p.x) || ((x == p.x) && (y < p.y)); }\\n};\\nstruct vec {\\n long double x, y;\\n vec(long double x1, long double y1) {\\n x = x1;\\n y = y1;\\n }\\n vec(point a, point b) {\\n x = b.x - a.x;\\n y = b.y - a.y;\\n }\\n vec normal() {\\n vec ans;\\n ans.x = y;\\n ans.y = -x;\\n return ans;\\n }\\n vec opposite() {\\n vec ans;\\n ans.x = -x;\\n ans.y = -y;\\n return ans;\\n }\\n vec sum(vec b) {\\n vec ans;\\n ans.x = x + b.x;\\n ans.y = y + b.y;\\n return ans;\\n }\\n long double cross_product(vec v) { return x * v.y - v.x * y; }\\n long double dot_product(vec v) { return x * v.x + y * v.y; }\\n vec resize(long double size) {\\n vec ans;\\n ans.x = (x * size) \\/ len();\\n ans.y = (y * size) \\/ len();\\n return ans;\\n }\\n vec() {}\\n long double len() { return sqrt(x * x + y * y); }\\n};\\nstruct line {\\n long double a, b, c;\\n line(point a1, point b1) {\\n a = a1.y - b1.y;\\n b = b1.x - a1.x;\\n c = -a1.x * a - a1.y * b;\\n }\\n line(long double a1, long double b1, long double c1) {\\n a = a1;\\n b = b1;\\n c = c1;\\n }\\n line() {}\\n vec normal_vec() {\\n vec ans;\\n ans.x = a;\\n ans.y = b;\\n return ans;\\n }\\n line normal_line(point p) {\\n line ans;\\n ans.a = -b;\\n ans.b = a;\\n ans.c = -ans.a * p.x - ans.b * p.y;\\n return ans;\\n }\\n long double get_x(long double y1) {\\n if (a == 0) return 0;\\n return (-c - b * y1) \\/ a;\\n }\\n long double get_y(long double x1) {\\n if (b == 0) return 0;\\n return (-c - a * x1) \\/ b;\\n }\\n point intersection(line l) {\\n point ans;\\n ans.x = (-c * l.b + l.c * b) \\/ (a * l.b - l.a * b);\\n ans.y = (-a * l.c + l.a * c) \\/ (a * l.b - l.a * b);\\n return ans;\\n }\\n long...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"On the board, Bob wrote n positive integers in [base](https:\\/\\/en.wikipedia.org\\/wiki\\/Positional_notation#Base_of_the_numeral_system) 10 with sum s (i. e. in decimal numeral system). Alice sees the board, but accidentally interprets the numbers on the board as base-11 integers and adds them up (in base 11).\\n\\nWhat numbers should Bob write on the board, so Alice's sum is as large as possible?\\n\\nInput\\n\\nThe input consists of multiple test cases. The first line contains an integer t (1 ≤ t ≤ 100) — the number of test cases. The description of the test cases follows.\\n\\nThe only line of each test case contains two integers s and n (1 ≤ s ≤ 10^9; 1 ≤ n ≤ min(100, s)) — the sum and amount of numbers on the board, respectively. Numbers s and n are given in decimal notation (base 10).\\n\\nOutput\\n\\nFor each test case, output n positive integers — the numbers Bob should write on the board, so Alice's sum is as large as possible. If there are multiple answers, print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n97 2\\n17 1\\n111 4\\n100 2\\n10 9\\n999999 3\\n\\n\\nOutput\\n\\n\\n70 27 \\n17 \\n3 4 100 4\\n10 90\\n1 1 2 1 1 1 1 1 1 \\n999900 90 9\\n\\nNote\\n\\nIn the first test case, 70_{10} + 27_{10} = 97_{10}, and Alice's sum is $$$70_{11} + 27_{11} = 97_{11} = 9 ⋅ 11 + 7 = 106_{10}. (Here x_b represents the number x in base b.) It can be shown that it is impossible for Alice to get a larger sum than 106_{10}$$$.\\n\\nIn the second test case, Bob can only write a single number on the board, so he must write 17.\\n\\nIn the third test case, 3_{10} + 4_{10} + 100_{10} + 4_{10} = 111_{10}, and Alice's sum is $$$3_{11} + 4_{11} + 100_{11} + 4_{11} = 110_{11} = 1 ⋅ 11^2 + 1 ⋅ 11 = 132_{10}. It can be shown that it is impossible for Alice to get a larger sum than 132_{10}$$$.\\nUsing python3 can you solve the prior task?\",\"targets\":\"import sys\\ninput = sys.stdin.readline\\nt = int(input())\\nfor _ in range(t):\\n s,n =map(int,input().split())\\n ans = []\\n for i in range(n-1):\\n ss = int(s)\\n ls = []\\n while ss > 0:\\n ls.append(ss%10)\\n ss \\/\\/= 10\\n sign = True\\n p = len(ls) - 1\\n while sign:\\n if s - 10**p >= n-i-1:\\n ans.append(10**p)\\n s -= 10**p\\n sign = False\\n else:\\n p -= 1\\n ans.append(s)\\n print(*ans)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Notes\\n\\nTemplate in C\\n\\nConstraints\\n\\n2 ≤ the number of operands in the expression ≤ 100\\n1 ≤ the number of operators in the expression ≤ 99\\n-1 × 109 ≤ values in the stack ≤ 109\\n\\nInput\\n\\nAn expression is given in a line. Two consequtive symbols (operand or operator) are separated by a space character.\\n\\nYou can assume that +, - and * are given as the operator and an operand is a positive integer less than 106\\n\\nOutput\\n\\nPrint the computational result in a line.\\n\\nExamples\\n\\nInput\\n\\n1 2 +\\n\\n\\nOutput\\n\\n3\\n\\n\\nInput\\n\\n1 2 + 3 4 - *\\n\\n\\nOutput\\n\\n-3\\\":\",\"targets\":\"#include\\n#include\\n#include \\nusing namespace std;\\nint top,S[1000];\\nvoid push(int x){\\n\\tS[++top] = x;\\n}\\nint pop(){\\n\\ttop--;\\n\\treturn S[top+1];\\n}\\nint main(){\\n\\tint a,b;\\n\\ttop = 0;\\n\\tchar s[100]; \\n\\twhile(cin>>s){\\n\\t\\tif(s[0]=='+'){\\n\\t\\t\\ta = pop();\\n\\t\\t\\tb =pop();\\n\\t\\t\\tpush(a+b);\\n\\t\\t}\\n\\t\\telse if(s[0]=='-'){\\n\\t\\t\\tb = pop();\\n\\t\\t\\ta = pop();\\n\\t\\t\\tpush(a-b);\\n\\t\\t}\\n\\t\\telse if(s[0]=='*'){\\n\\t\\t\\ta = pop();\\n\\t\\t\\tb = pop();\\n\\t\\t\\tpush(a*b);\\n\\t\\t}\\n\\t\\telse {\\n\\t\\t\\tpush(atoi(s));\\n\\t\\t}\\n\\t}\\n\\tcout<\\nusing namespace std;\\nconst int Mod = 998244353;\\nconst int MaxN = 5e5 + 5;\\nint T, N, Ans;\\nint A[MaxN], F[MaxN], G[MaxN], H[MaxN];\\nint tF[MaxN], tG[MaxN], tH[MaxN];\\nint main() {\\n int i, j;\\n scanf(\\\"%d\\\", &T);\\n while (T--) {\\n scanf(\\\"%d\\\", &N);\\n for (i = 0; i <= N; i++) F[i] = G[i] = H[i] = 0;\\n for (Ans = 0, i = 1; i <= N; i++) {\\n scanf(\\\"%d\\\", &A[i]);\\n F[A[i]] = (F[A[i]] << 1) % Mod;\\n G[A[i]] = (G[A[i]] << 1) % Mod;\\n H[A[i]] = (H[A[i]] << 1) % Mod;\\n if (!A[i]) F[0]++;\\n if (A[i] == 1) G[1]++;\\n if (A[i]) F[A[i]] = (F[A[i]] + F[A[i] - 1]) % Mod;\\n if (A[i] > 1) {\\n G[A[i]] = (G[A[i]] + F[A[i] - 2]) % Mod;\\n G[A[i]] = (G[A[i]] + H[A[i] - 2]) % Mod;\\n }\\n if (A[i] + 2 <= N) H[A[i]] = (H[A[i]] + G[A[i] + 2]) % Mod;\\n }\\n for (i = 0; i <= N; i++) {\\n Ans = (Ans + F[i]) % Mod;\\n Ans = (Ans + G[i]) % Mod;\\n Ans = (Ans + H[i]) % Mod;\\n }\\n printf(\\\"%d\\\\n\\\", Ans);\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 solution for \\\"A rectangle with its opposite corners in (0, 0) and (w, h) and sides parallel to the axes is drawn on a plane.\\n\\nYou are given a list of lattice points such that each point lies on a side of a rectangle but not in its corner. Also, there are at least two points on every side of a rectangle.\\n\\nYour task is to choose three points in such a way that: \\n\\n * exactly two of them belong to the same side of a rectangle; \\n * the area of a triangle formed by them is maximum possible. \\n\\n\\n\\nPrint the doubled area of this triangle. It can be shown that the doubled area of any triangle formed by lattice points is always an integer.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.\\n\\nThe first line of each testcase contains two integers w and h (3 ≤ w, h ≤ 10^6) — the coordinates of the corner of a rectangle.\\n\\nThe next two lines contain the description of the points on two horizontal sides. First, an integer k (2 ≤ k ≤ 2 ⋅ 10^5) — the number of points. Then, k integers x_1 < x_2 < ... < x_k (0 < x_i < w) — the x coordinates of the points in the ascending order. The y coordinate for the first line is 0 and for the second line is h.\\n\\nThe next two lines contain the description of the points on two vertical sides. First, an integer k (2 ≤ k ≤ 2 ⋅ 10^5) — the number of points. Then, k integers y_1 < y_2 < ... < y_k (0 < y_i < h) — the y coordinates of the points in the ascending order. The x coordinate for the first line is 0 and for the second line is w.\\n\\nThe total number of points on all sides in all testcases doesn't exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each testcase print a single integer — the doubled maximum area of a triangle formed by such three points that exactly two of them belong to the same side.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n5 8\\n2 1 2\\n3 2 3 4\\n3 1 4 6\\n2 4 5\\n10 7\\n2 3 9\\n2 1 7\\n3 1 3 4\\n3 4 5 6\\n11 5\\n3 1 6 8\\n3 3 6 8\\n3 1 3 4\\n2 2 4\\n\\n\\nOutput\\n\\n\\n25\\n42\\n35\\n\\nNote\\n\\nThe points in the first testcase of the example: \\n\\n * (1, 0), (2, 0); \\n * (2, 8), (3, 8), (4, 8); \\n * (0, 1), (0, 4), (0, 6); \\n * (5, 4), (5,...\\\":\",\"targets\":\"for _ in range(int(input())):\\n w, h = map(int, input().split())\\n w1 = list(map(int, input().split()))\\n w2 = list(map(int, input().split()))\\n h1 = list(map(int, input().split()))\\n h2 = list(map(int, input().split()))\\n w1.pop(0)\\n w2.pop(0)\\n h1.pop(0)\\n h2.pop(0)\\n ans = [(max(w1) - min(w1)) * h, (max(w2) - min(w2)) * h, (max(h1) - min(h1)) * w, (max(h2) - min(h2)) * w]\\n print(max(ans))\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Berland Music is a music streaming service built specifically to support Berland local artist. Its developers are currently working on a song recommendation module.\\n\\nSo imagine Monocarp got recommended n songs, numbered from 1 to n. The i-th song had its predicted rating equal to p_i, where 1 ≤ p_i ≤ n and every integer from 1 to n appears exactly once. In other words, p is a permutation.\\n\\nAfter listening to each of them, Monocarp pressed either a like or a dislike button. Let his vote sequence be represented with a string s, such that s_i=0 means that he disliked the i-th song, and s_i=1 means that he liked it.\\n\\nNow the service has to re-evaluate the song ratings in such a way that:\\n\\n * the new ratings q_1, q_2, ..., q_n still form a permutation (1 ≤ q_i ≤ n; each integer from 1 to n appears exactly once); \\n * every song that Monocarp liked should have a greater rating than every song that Monocarp disliked (formally, for all i, j such that s_i=1 and s_j=0, q_i>q_j should hold). \\n\\n\\n\\nAmong all valid permutations q find the one that has the smallest value of ∑_{i=1}^n |p_i-q_i|, where |x| is an absolute value of x.\\n\\nPrint the permutation q_1, q_2, ..., q_n. If there are multiple answers, you can print any of them.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.\\n\\nThe first line of each testcase contains a single integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of songs.\\n\\nThe second line of each testcase contains n integers p_1, p_2, ..., p_n (1 ≤ p_i ≤ n) — the permutation of the predicted ratings.\\n\\nThe third line contains a single string s, consisting of n characters. Each character is either a 0 or a 1. 0 means that Monocarp disliked the song, and 1 means that he liked it.\\n\\nThe sum of n over all testcases doesn't exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each testcase, print a permutation q — the re-evaluated ratings of the songs. If there are multiple answers such that ∑_{i=1}^n |p_i-q_i| is minimum possible, you can print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n2\\n1 2\\n10\\n3\\n3 1 2\\n111\\n8\\n2...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint a[200002], b[200002], c[200002];\\nvoid solve() {\\n int n, m;\\n string s;\\n m = 1;\\n cin >> n;\\n for (int i = 1; i <= n; i++) cin >> a[i];\\n cin >> s;\\n for (int i = 1; i <= n; i++) b[a[i]] = i;\\n for (int i = 1; i <= n; i++) {\\n if (s[b[i] - 1] == '0') {\\n c[m] = b[i];\\n m++;\\n }\\n }\\n for (int i = 1; i <= n; i++) {\\n if (s[b[i] - 1] == '1') {\\n c[m] = b[i];\\n m++;\\n }\\n }\\n for (int i = 1; i <= n; i++) {\\n a[c[i]] = i;\\n }\\n for (int i = 1; i <= n; i++) {\\n cout << a[i];\\n cout << \\\" \\\";\\n }\\n cout << \\\"\\\\n\\\";\\n}\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n int tc;\\n cin >> tc;\\n while (tc--) {\\n solve();\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nYou are the organizer of the famous \\\"Zurich Music Festival\\\". There will be n singers who will perform at the festival, identified by the integers 1, 2, ..., n. You must choose in which order they are going to perform on stage. \\n\\nYou have m friends and each of them has a set of favourite singers. More precisely, for each 1≤ i≤ m, the i-th friend likes singers s_{i,1}, s_{i, 2}, ..., \\\\,s_{i, q_i}.\\n\\nA friend of yours is happy if the singers he likes perform consecutively (in an arbitrary order). An ordering of the singers is valid if it makes all your friends happy.\\n\\nCompute the number of valid orderings modulo 998 244 353.\\n\\nInput\\n\\nThe first line contains two integers n and m (1≤ n,\\\\,m≤ 100) — the number of singers and the number of friends correspondingly.\\n\\nThe i-th of the next m lines contains the integer q_i (1≤ q_i≤ n) — the number of favorite singers of the i-th friend – followed by the q_i integers s_{i,1}, s_{i, 2}, ..., \\\\,s_{i, q_i} (1≤ s_{i,1}\\nusing namespace std;\\nconst int N = 2000;\\nconst int M = 2000;\\nint mod = 1000007;\\nvoid die() {\\n printf(\\\"0\\\\n\\\");\\n exit(0);\\n}\\nstruct group {\\n vector domain;\\n vector sets;\\n};\\nstruct pattern {\\n pattern *left, *right;\\n group g;\\n};\\nbool matrix[N + 1][M + 1];\\nint Size[N + 1];\\nbool intersects[N + 1];\\nvoid insertBefore(pattern* p, group g) {\\n pattern* left = p->left;\\n p->left = new pattern;\\n p->left->right = p;\\n p->left->left = left;\\n p->left->g = g;\\n if (p->left->left != NULL) p->left->left->right = p->left;\\n}\\nvoid insertAfter(pattern* p, group g) {\\n pattern* right = p->right;\\n p->right = new pattern;\\n p->right->left = p;\\n p->right->right = right;\\n p->right->g = g;\\n if (p->right->right != NULL) p->right->right->left = p->right;\\n}\\npair split(group& g, int set) {\\n group gdifference, gintersection;\\n for (vector::iterator it = g.domain.begin(); it != g.domain.end();\\n ++it) {\\n if (matrix[set][*it]) {\\n gintersection.domain.push_back(*it);\\n matrix[set][*it] = 0;\\n --Size[set];\\n } else\\n gdifference.domain.push_back(*it);\\n }\\n if (gdifference.domain.empty()) return make_pair(gdifference, g);\\n if (gintersection.domain.empty()) return make_pair(g, gintersection);\\n bool swp = 0;\\n if (gdifference.domain.size() < gintersection.domain.size()) {\\n swp = 1;\\n swap(gdifference, gintersection);\\n }\\n for (vector::iterator it = g.sets.begin(); it != g.sets.end(); ++it) {\\n int intsize = 0;\\n for (vector::iterator jt = gintersection.domain.begin();\\n jt != gintersection.domain.end(); ++jt) {\\n if (matrix[*it][*jt]) ++intsize;\\n }\\n if (intsize == 0)\\n gdifference.sets.push_back(*it);\\n else if (intsize == Size[*it])\\n gintersection.sets.push_back(*it);\\n else\\n intersects[*it] = true;\\n }\\n if (swp) swap(gdifference, gintersection);\\n return make_pair(gdifference, gintersection);\\n}\\nvoid erase(vector& v, unsigned i) {\\n swap(v[i], v[v.size() - 1]);\\n v.pop_back();\\n}\\nint f(group g)...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nEveryone knows that DNA strands consist of nucleotides. There are four types of nucleotides: \\\"A\\\", \\\"T\\\", \\\"G\\\", \\\"C\\\". A DNA strand is a sequence of nucleotides. Scientists decided to track evolution of a rare species, which DNA strand was string s initially. \\n\\nEvolution of the species is described as a sequence of changes in the DNA. Every change is a change of some nucleotide, for example, the following change can happen in DNA strand \\\"AAGC\\\": the second nucleotide can change to \\\"T\\\" so that the resulting DNA strand is \\\"ATGC\\\".\\n\\nScientists know that some segments of the DNA strand can be affected by some unknown infections. They can represent an infection as a sequence of nucleotides. Scientists are interested if there are any changes caused by some infections. Thus they sometimes want to know the value of impact of some infection to some segment of the DNA. This value is computed as follows:\\n\\n * Let the infection be represented as a string e, and let scientists be interested in DNA strand segment starting from position l to position r, inclusive. \\n * Prefix of the string eee... (i.e. the string that consists of infinitely many repeats of string e) is written under the string s from position l to position r, inclusive. \\n * The value of impact is the number of positions where letter of string s coincided with the letter written under it. \\n\\n\\n\\nBeing a developer, Innokenty is interested in bioinformatics also, so the scientists asked him for help. Innokenty is busy preparing VK Cup, so he decided to delegate the problem to the competitors. Help the scientists!\\n\\nInput\\n\\nThe first line contains the string s (1 ≤ |s| ≤ 105) that describes the initial DNA strand. It consists only of capital English letters \\\"A\\\", \\\"T\\\", \\\"G\\\" and \\\"C\\\".\\n\\nThe next line contains single integer q (1 ≤ q ≤ 105) — the number of events.\\n\\nAfter that, q lines follow, each describes one event. Each of the lines has one of two formats: \\n\\n * 1 x c, where x is an integer (1 ≤ x ≤ |s|), and c is a letter \\\"A\\\", \\\"T\\\", \\\"G\\\" or \\\"C\\\", which means that there is a...\",\"targets\":\"#include \\nusing namespace std;\\nconst long long maxn = 200005;\\nlong long tree[4][maxn];\\nvoid add(long long letter, long long k, long long v) {\\n for (long long i = k; i < maxn; i += i & -i) tree[letter][i] += v;\\n}\\nlong long qry(long long letter, long long k) {\\n long long res = 0;\\n for (long long i = k; i >= 1; i -= i & -i) res += tree[letter][i];\\n return res;\\n}\\nlong long get(char c) {\\n if (c == 'A') return 0;\\n if (c == 'T') return 1;\\n if (c == 'G') return 2;\\n if (c == 'C') return 3;\\n}\\nsigned main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n for (long long i = 0; i < 4; i++)\\n for (long long j = 0; j < maxn; j++) tree[i][j] = 0;\\n string ori;\\n cin >> ori;\\n long long q;\\n cin >> q;\\n vector, string>> queries;\\n long long ts[q];\\n long long res[q];\\n for (long long i = 0; i < q; i++) {\\n long long t;\\n cin >> t;\\n ts[i] = t;\\n res[i] = 0;\\n if (t == 1) {\\n long long x;\\n char y;\\n cin >> x >> y;\\n queries.push_back({{x, get(y)}, \\\"\\\"});\\n } else {\\n long long l, r;\\n string e;\\n cin >> l >> r >> e;\\n queries.push_back({{l, r}, e});\\n }\\n }\\n for (long long mod = 1; mod <= 10; mod++) {\\n for (long long parity = 0; parity < mod; parity++) {\\n string s = ori;\\n for (long long i = 0; i < 4; i++)\\n for (long long j = 0; j < maxn; j++) tree[i][j] = 0;\\n for (long long i = 1; i <= s.length(); i++) {\\n long long c = get(s[i - 1]);\\n if (i % mod == parity) {\\n add(c, i, 1);\\n }\\n }\\n for (long long i = 0; i < q; i++) {\\n long long t = ts[i];\\n if (t == 1) {\\n long long x = queries[i].first.first;\\n long long old = get(s[x - 1]);\\n long long c = queries[i].first.second;\\n if (c == 0) s[x - 1] = 'A';\\n if (c == 1) s[x - 1] = 'T';\\n if (c == 2) s[x - 1] = 'G';\\n if (c == 3) s[x - 1] = 'C';\\n if (x % mod == parity) {\\n add(old, x, -1);\\n add(c, x, 1);\\n }\\n ...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given an integer k and a string s that consists only of characters 'a' (a lowercase Latin letter) and '*' (an asterisk).\\n\\nEach asterisk should be replaced with several (from 0 to k inclusive) lowercase Latin letters 'b'. Different asterisk can be replaced with different counts of letter 'b'.\\n\\nThe result of the replacement is called a BA-string.\\n\\nTwo strings a and b are different if they either have different lengths or there exists such a position i that a_i ≠ b_i.\\n\\nA string a is lexicographically smaller than a string b if and only if one of the following holds: \\n\\n * a is a prefix of b, but a ≠ b; \\n * in the first position where a and b differ, the string a has a letter that appears earlier in the alphabet than the corresponding letter in b. \\n\\n\\n\\nNow consider all different BA-strings and find the x-th lexicographically smallest of them.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 2000) — the number of testcases.\\n\\nThe first line of each testcase contains three integers n, k and x (1 ≤ n ≤ 2000; 0 ≤ k ≤ 2000; 1 ≤ x ≤ 10^{18}). n is the length of string s.\\n\\nThe second line of each testcase is a string s. It consists of n characters, each of them is either 'a' (a lowercase Latin letter) or '*' (an asterisk).\\n\\nThe sum of n over all testcases doesn't exceed 2000. For each testcase x doesn't exceed the total number of different BA-strings. String s contains at least one character 'a'.\\n\\nOutput\\n\\nFor each testcase, print a single string, consisting only of characters 'b' and 'a' (lowercase Latin letters) — the x-th lexicographically smallest BA-string.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n2 4 3\\na*\\n4 1 3\\na**a\\n6 3 20\\n**a***\\n\\n\\nOutput\\n\\n\\nabb\\nabba\\nbabbbbbbbbb\\n\\nNote\\n\\nIn the first testcase of the example, BA-strings ordered lexicographically are: \\n\\n 1. a\\n 2. ab\\n 3. abb\\n 4. abbb\\n 5. abbbb\\n\\n\\n\\nIn the second testcase of the example, BA-strings ordered lexicographically are: \\n\\n 1. aa\\n 2. aba\\n 3. abba\\n\\n\\n\\nNote that string \\\"aba\\\" is only counted once, even though there are two ways to replace asterisks with characters...\",\"targets\":\"import java.math.BigInteger;\\nimport java.util.ArrayList;\\nimport java.util.Arrays;\\nimport java.util.List;\\nimport java.util.Stack;\\n\\npublic class Main {\\n static long MOD = 998244353l;\\n int re = 0;\\n int min = Integer.MAX_VALUE;\\n\\n public static void main(String[] args) throws Exception {\\n \\/\\/ FileInputStream fis = new FileInputStream(new\\n \\/\\/ File(\\\"\\/Users\\/goudezhao\\/Public\\/JavaTest\\/1.txt\\\"));\\n var sc = new FastScanner();\\n \\/\\/ var sc = new FastScanner(fis);\\n \\/\\/ var pw = new FastPrintStream(\\\"\\/Users\\/goudezhao\\/Public\\/JavaTest\\/1.out\\\");\\n var pw = new FastPrintStream();\\n solve(sc, pw);\\n sc.close();\\n pw.flush();\\n pw.close();\\n }\\n\\n public static void solve(FastScanner sc, FastPrintStream pw) {\\n int t = sc.nextInt();\\n for (int times = 0; times < t; times++) {\\n int n = sc.nextInt();\\n int k = sc.nextInt();\\n long x = sc.nextLong();\\n String s = sc.next();\\n List list = new ArrayList();\\n int aster = 0;\\n for (int i = 0; i < n; i++) {\\n if (s.charAt(i) == 'a') {\\n if (aster > 0) {\\n list.add(aster * k + 1);\\n aster = 0;\\n }\\n } else {\\n aster++;\\n }\\n }\\n if (aster>0) {\\n list.add(aster*k+1);\\n }\\n if (list.size() == 0 || k == 0) {\\n s= s.replace(\\\"*\\\", \\\"\\\");\\n pw.println(s);\\n continue;\\n }\\n long tempcount[] = new long[list.size()];\\n long bcount[] = new long[list.size()];\\n if (list.size() > 1) {\\n tempcount[list.size() - 2] = list.get(list.size() - 1);\\n for (int i = list.size() - 3; i >= 0; i--) {\\n if (x \\/ tempcount[i + 1] >= list.get(i + 1)) {\\n tempcount[i] = tempcount[i + 1] * list.get(i + 1);\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Vlad has n friends, for each of whom he wants to buy one gift for the New Year.\\n\\nThere are m shops in the city, in each of which he can buy a gift for any of his friends. If the j-th friend (1 ≤ j ≤ n) receives a gift bought in the shop with the number i (1 ≤ i ≤ m), then the friend receives p_{ij} units of joy. The rectangular table p_{ij} is given in the input.\\n\\nVlad has time to visit at most n-1 shops (where n is the number of friends). He chooses which shops he will visit and for which friends he will buy gifts in each of them.\\n\\nLet the j-th friend receive a_j units of joy from Vlad's gift. Let's find the value α=min\\\\\\\\{a_1, a_2, ..., a_n\\\\}. Vlad's goal is to buy gifts so that the value of α is as large as possible. In other words, Vlad wants to maximize the minimum of the joys of his friends.\\n\\nFor example, let m = 2, n = 2. Let the joy from the gifts that we can buy in the first shop: p_{11} = 1, p_{12}=2, in the second shop: p_{21} = 3, p_{22}=4.\\n\\nThen it is enough for Vlad to go only to the second shop and buy a gift for the first friend, bringing joy 3, and for the second — bringing joy 4. In this case, the value α will be equal to min\\\\{3, 4\\\\} = 3\\n\\nHelp Vlad choose gifts for his friends so that the value of α is as high as possible. Please note that each friend must receive one gift. Vlad can visit at most n-1 shops (where n is the number of friends). In the shop, he can buy any number of gifts.\\n\\nInput\\n\\nThe first line of the input contains an integer t (1 ≤ t ≤ 10^4) — the number of test cases in the input.\\n\\nAn empty line is written before each test case. Then there is a line containing integers m and n (2 ≤ n, 2 ≤ n ⋅ m ≤ 10^5) separated by a space — the number of shops and the number of friends, where n ⋅ m is the product of n and m.\\n\\nThen m lines follow, each containing n numbers. The number in the i-th row of the j-th column p_{ij} (1 ≤ p_{ij} ≤ 10^9) is the joy of the product intended for friend number j in shop number i.\\n\\nIt is guaranteed that the sum of the values n ⋅ m over all test cases in...\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nlong long n, t, m, k, test;\\nconst long long MAX = 1e6;\\nvector> mapp;\\nbool check(long long x) {\\n vector abl(n);\\n bool flag = false;\\n for (long long i = 0; i < m; i++) {\\n long long c = 0;\\n for (long long j = 0; j < n; j++) {\\n if (mapp[i][j] >= x) {\\n abl[j] = true;\\n c++;\\n }\\n }\\n if (c > 1) flag = true;\\n }\\n if (!flag) return false;\\n bool ans = true;\\n for (auto check : abl) {\\n ans &= check;\\n }\\n return ans;\\n}\\nint main() {\\n ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);\\n cin >> t;\\n while (t--) {\\n cin >> m >> n;\\n mapp = vector>(m, vector(n));\\n for (int i = 0; i < m; i++) {\\n for (long long j = 0; j < n; j++) {\\n cin >> mapp[i][j];\\n }\\n }\\n long long l = 1, r = 1e9;\\n while (l < r) {\\n long long mid = (r + l + 1) \\/ 2;\\n if (check(mid))\\n l = mid;\\n else\\n r = mid - 1;\\n }\\n cout << l << \\\"\\\\n\\\";\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nLittle boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and array a.\\n \\n \\n \\n loop integer variable i from 1 to n - 1 \\n     loop integer variable j from i to n - 1 \\n         if (aj > aj + 1), then swap the values of elements aj and aj + 1 \\n \\n\\nBut Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.\\n\\nInput\\n\\nYou've got a single integer n (1 ≤ n ≤ 50) — the size of the sorted array.\\n\\nOutput\\n\\nPrint n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.\\n\\nIf there are several counter-examples, consisting of n numbers, you are allowed to print any of them.\\n\\nExamples\\n\\nInput\\n\\n1\\n\\n\\nOutput\\n\\n-1\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int n;\\n cin >> n;\\n if (n <= 2)\\n cout << \\\"-1\\\" << endl;\\n else {\\n while (n) {\\n cout << n << \\\" \\\";\\n n -= 1;\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"This problem is an extension of the problem \\\"Wonderful Coloring - 1\\\". It has quite many differences, so you should read this statement completely.\\n\\nRecently, Paul and Mary have found a new favorite sequence of integers a_1, a_2, ..., a_n. They want to paint it using pieces of chalk of k colors. The coloring of a sequence is called wonderful if the following conditions are met:\\n\\n 1. each element of the sequence is either painted in one of k colors or isn't painted; \\n 2. each two elements which are painted in the same color are different (i. e. there's no two equal values painted in the same color); \\n 3. let's calculate for each of k colors the number of elements painted in the color — all calculated numbers must be equal; \\n 4. the total number of painted elements of the sequence is the maximum among all colorings of the sequence which meet the first three conditions. \\n\\n\\n\\nE. g. consider a sequence a=[3, 1, 1, 1, 1, 10, 3, 10, 10, 2] and k=3. One of the wonderful colorings of the sequence is shown in the figure.\\n\\n The example of a wonderful coloring of the sequence a=[3, 1, 1, 1, 1, 10, 3, 10, 10, 2] and k=3. Note that one of the elements isn't painted.\\n\\nHelp Paul and Mary to find a wonderful coloring of a given sequence a.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10000) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of two lines. The first one contains two integers n and k (1 ≤ n ≤ 2⋅10^5, 1 ≤ k ≤ n) — the length of a given sequence and the number of colors, respectively. The second one contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ n).\\n\\nIt is guaranteed that the sum of n over all test cases doesn't exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nOutput t lines, each of them must contain a description of a wonderful coloring for the corresponding test case.\\n\\nEach wonderful coloring must be printed as a sequence of n integers c_1, c_2, ..., c_n (0 ≤ c_i ≤ k) separated by spaces where\\n\\n * c_i=0, if i-th element isn't painted; \\n * c_i>0, if i-th element is painted in the...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n ;\\n int t;\\n cin >> t;\\n while (t--) {\\n int n, k;\\n cin >> n >> k;\\n int arr[n];\\n for (int i = 0; i < n; i++) cin >> arr[i];\\n unordered_map freq;\\n unordered_map> make_pair;\\n for (int i = 0; i < n; i++) {\\n make_pair[arr[i]].push_back(i);\\n freq[arr[i]]++;\\n }\\n int curr = 0;\\n for (auto i : freq) {\\n curr += min(i.second, k);\\n }\\n int ans = curr \\/ k;\\n int ret[n];\\n memset(ret, 0, sizeof(ret));\\n int cols = 1;\\n int tcount = 0;\\n for (auto i : make_pair) {\\n int count = 0;\\n for (auto j : i.second) {\\n count++;\\n tcount++;\\n ret[j] = cols;\\n cols++;\\n if (cols == k + 1) cols = 1;\\n if (count >= k) break;\\n if (tcount >= k * ans) break;\\n }\\n if (tcount >= k * ans) break;\\n }\\n for (int i = 0; i < n; i++) {\\n cout << ret[i] << \\\" \\\";\\n }\\n cout << \\\"\\\\n\\\";\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nAnother Codeforces Round has just finished! It has gathered n participants, and according to the results, the expected rating change of participant i is a_i. These rating changes are perfectly balanced — their sum is equal to 0.\\n\\nUnfortunately, due to minor technical glitches, the round is declared semi-rated. It means that all rating changes must be divided by two.\\n\\nThere are two conditions though: \\n\\n * For each participant i, their modified rating change b_i must be integer, and as close to (a_i)\\/(2) as possible. It means that either b_i = ⌊ (a_i)\\/(2) ⌋ or b_i = ⌈ (a_i)\\/(2) ⌉. In particular, if a_i is even, b_i = (a_i)\\/(2). Here ⌊ x ⌋ denotes rounding down to the largest integer not greater than x, and ⌈ x ⌉ denotes rounding up to the smallest integer not smaller than x. \\n * The modified rating changes must be perfectly balanced — their sum must be equal to 0. \\n\\n\\n\\nCan you help with that?\\n\\nInput\\n\\nThe first line contains a single integer n (2 ≤ n ≤ 13 845), denoting the number of participants.\\n\\nEach of the next n lines contains a single integer a_i (-336 ≤ a_i ≤ 1164), denoting the rating change of the i-th participant.\\n\\nThe sum of all a_i is equal to 0.\\n\\nOutput\\n\\nOutput n integers b_i, each denoting the modified rating change of the i-th participant in order of input.\\n\\nFor any i, it must be true that either b_i = ⌊ (a_i)\\/(2) ⌋ or b_i = ⌈ (a_i)\\/(2) ⌉. The sum of all b_i must be equal to 0.\\n\\nIf there are multiple solutions, print any. We can show that a solution exists for any valid input.\\n\\nExamples\\n\\nInput\\n\\n\\n3\\n10\\n-5\\n-5\\n\\n\\nOutput\\n\\n\\n5\\n-2\\n-3\\n\\n\\nInput\\n\\n\\n7\\n-7\\n-29\\n0\\n3\\n24\\n-29\\n38\\n\\n\\nOutput\\n\\n\\n-3\\n-15\\n0\\n2\\n12\\n-15\\n19\\n\\nNote\\n\\nIn the first example, b_1 = 5, b_2 = -3 and b_3 = -2 is another correct solution.\\n\\nIn the second example there are 6 possible solutions, one of them is shown in the example output.\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n long long n, i, k, l, flag = 1, y;\\n double x;\\n vector V;\\n cin >> n;\\n for (i = 0; i < n; i++) {\\n cin >> k;\\n V.push_back(k);\\n }\\n for (i = 0; i < n; i++) {\\n if (V[i] % 2 == 0)\\n cout << V[i] \\/ 2 << endl;\\n else {\\n y = floor(double(V[i]) \\/ 2);\\n if (flag == 1) {\\n cout << y << endl;\\n flag = 0;\\n } else {\\n cout << y + 1 << endl;\\n flag = 1;\\n }\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Monocarp is playing yet another computer game. In this game, his character has to kill a dragon. The battle with the dragon lasts 100^{500} seconds, during which Monocarp attacks the dragon with a poisoned dagger. The i-th attack is performed at the beginning of the a_i-th second from the battle start. The dagger itself does not deal damage, but it applies a poison effect on the dragon, which deals 1 damage during each of the next k seconds (starting with the same second when the dragon was stabbed by the dagger). However, if the dragon has already been poisoned, then the dagger updates the poison effect (i.e. cancels the current poison effect and applies a new one).\\n\\nFor example, suppose k = 4, and Monocarp stabs the dragon during the seconds 2, 4 and 10. Then the poison effect is applied at the start of the 2-nd second and deals 1 damage during the 2-nd and 3-rd seconds; then, at the beginning of the 4-th second, the poison effect is reapplied, so it deals exactly 1 damage during the seconds 4, 5, 6 and 7; then, during the 10-th second, the poison effect is applied again, and it deals 1 damage during the seconds 10, 11, 12 and 13. In total, the dragon receives 10 damage.\\n\\nMonocarp knows that the dragon has h hit points, and if he deals at least h damage to the dragon during the battle — he slays the dragon. Monocarp has not decided on the strength of the poison he will use during the battle, so he wants to find the minimum possible value of k (the number of seconds the poison effect lasts) that is enough to deal at least h damage to the dragon.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases.\\n\\nThe first line of the test case contains two integers n and h (1 ≤ n ≤ 100; 1 ≤ h ≤ 10^{18}) — the number of Monocarp's attacks and the amount of damage that needs to be dealt.\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9; a_i < a_{i + 1}), where a_i is the second when the i-th attack is performed.\\n\\nOutput\\n\\nFor each test case, print a single...\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"from __future__ import division, print_function\\nimport math\\nimport sys\\nimport os\\nfrom io import BytesIO, IOBase\\n#from collections import deque, Counter, OrderedDict, defaultdict\\n#import heapq\\n#ceil,floor,log,sqrt,factorial,pow,pi,gcd\\n#import bisect\\n#from bisect import bisect_left,bisect_right\\n\\nBUFSIZE = 8192\\n\\n\\nclass FastIO(IOBase):\\n\\tnewlines = 0\\n\\n\\tdef __init__(self, file):\\n\\t\\tself._fd = file.fileno()\\n\\t\\tself.buffer = BytesIO()\\n\\t\\tself.writable = \\\"x\\\" in file.mode or \\\"r\\\" not in file.mode\\n\\t\\tself.write = self.buffer.write if self.writable else None\\n\\n\\tdef read(self):\\n\\t\\twhile True:\\n\\t\\t\\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n\\t\\t\\tif not b:\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tptr = self.buffer.tell()\\n\\t\\t\\tself.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n\\t\\tself.newlines = 0\\n\\t\\treturn self.buffer.read()\\n\\n\\tdef readline(self):\\n\\t\\twhile self.newlines == 0:\\n\\t\\t\\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n\\t\\t\\tself.newlines = b.count(b\\\"\\\\n\\\") + (not b)\\n\\t\\t\\tptr = self.buffer.tell()\\n\\t\\t\\tself.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n\\t\\tself.newlines -= 1\\n\\t\\treturn self.buffer.readline()\\n\\n\\tdef flush(self):\\n\\t\\tif self.writable:\\n\\t\\t\\tos.write(self._fd, self.buffer.getvalue())\\n\\t\\t\\tself.buffer.truncate(0), self.buffer.seek(0)\\n\\n\\nclass IOWrapper(IOBase):\\n\\tdef __init__(self, file):\\n\\t\\tself.buffer = FastIO(file)\\n\\t\\tself.flush = self.buffer.flush\\n\\t\\tself.writable = self.buffer.writable\\n\\t\\tself.write = lambda s: self.buffer.write(s.encode(\\\"ascii\\\"))\\n\\t\\tself.read = lambda: self.buffer.read().decode(\\\"ascii\\\")\\n\\t\\tself.readline = lambda: self.buffer.readline().decode(\\\"ascii\\\")\\n\\n\\ndef print(*args, **kwargs):\\n\\t\\\"\\\"\\\"Prints the values to a stream, or to sys.stdout by default.\\\"\\\"\\\"\\n\\tsep, file = kwargs.pop(\\\"sep\\\", \\\" \\\"), kwargs.pop(\\\"file\\\", sys.stdout)\\n\\tat_start = True\\n\\tfor x in args:\\n\\t\\tif not at_start:\\n\\t\\t\\tfile.write(sep)\\n\\t\\tfile.write(str(x))\\n\\t\\tat_start = False\\n\\tfile.write(kwargs.pop(\\\"end\\\", \\\"\\\\n\\\"))\\n\\tif kwargs.pop(\\\"flush\\\", False):\\n\\t\\tfile.flush()\\n\\n\\nif sys.version_info[0] < 3:\\n\\tsys.stdin, sys.stdout = FastIO(sys.stdin),...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Breaking Good is a new video game which a lot of gamers want to have. There is a certain level in the game that is really difficult even for experienced gamers.\\n\\nWalter William, the main character of the game, wants to join a gang called Los Hermanos (The Brothers). The gang controls the whole country which consists of n cities with m bidirectional roads connecting them. There is no road is connecting a city to itself and for any two cities there is at most one road between them. The country is connected, in the other words, it is possible to reach any city from any other city using the given roads. \\n\\nThe roads aren't all working. There are some roads which need some more work to be performed to be completely functioning.\\n\\nThe gang is going to rob a bank! The bank is located in city 1. As usual, the hardest part is to escape to their headquarters where the police can't get them. The gang's headquarters is in city n. To gain the gang's trust, Walter is in charge of this operation, so he came up with a smart plan.\\n\\nFirst of all the path which they are going to use on their way back from city 1 to their headquarters n must be as short as possible, since it is important to finish operation as fast as possible.\\n\\nThen, gang has to blow up all other roads in country that don't lay on this path, in order to prevent any police reinforcements. In case of non-working road, they don't have to blow up it as it is already malfunctional. \\n\\nIf the chosen path has some roads that doesn't work they'll have to repair those roads before the operation.\\n\\nWalter discovered that there was a lot of paths that satisfied the condition of being shortest possible so he decided to choose among them a path that minimizes the total number of affected roads (both roads that have to be blown up and roads to be repaired).\\n\\nCan you help Walter complete his task and gain the gang's trust?\\n\\nInput\\n\\nThe first line of input contains two integers n, m (2 ≤ n ≤ 105, ), the number of cities and number of roads respectively.\\n\\nIn following m lines...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint n, m;\\nvector > > v;\\nqueue q;\\nint mn[100100];\\nbool vis[100100];\\nint lv[100100];\\npair > adj[100100];\\nset > > s;\\nset > s1;\\nint main() {\\n ios::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n ;\\n cin >> n >> m;\\n v.clear();\\n v.resize(n + 1);\\n for (int i = 0; i < m; i++) {\\n int x, y, z;\\n cin >> x >> y >> z;\\n adj[i] = {x, {y, z}};\\n v[x].push_back({y, z});\\n v[y].push_back({x, z});\\n }\\n for (int i = 0; i <= n; i++) mn[i] = 1e9;\\n memset(lv, -1, sizeof lv);\\n lv[1] = 1;\\n mn[1] = 0;\\n q.push(1);\\n while (!q.empty()) {\\n int node = q.front();\\n q.pop();\\n if (vis[node]) continue;\\n vis[node] = true;\\n for (int i = 0; i < v[node].size(); i++) {\\n int child = v[node][i].first;\\n bool z = v[node][i].second;\\n if (lv[child] <= lv[node] && lv[child] + 1) continue;\\n lv[child] = lv[node] + 1;\\n mn[child] = min(mn[child], mn[node] + !z);\\n if (!vis[child]) q.push(child);\\n }\\n }\\n memset(vis, 0, sizeof vis);\\n q.push(n);\\n while (!q.empty()) {\\n int node = q.front();\\n q.pop();\\n if (vis[node]) continue;\\n vis[node] = true;\\n for (int i = 0; i < v[node].size(); i++) {\\n int child = v[node][i].first;\\n bool z = v[node][i].second;\\n if (lv[child] >= lv[node]) continue;\\n if (mn[node] - !z == mn[child]) {\\n q.push(child);\\n if (node > child) swap(node, child);\\n s.insert({node, {child, z}});\\n break;\\n }\\n }\\n }\\n for (int i = 0; i < m; i++) {\\n int x = adj[i].first;\\n int y = adj[i].second.first;\\n int z = adj[i].second.second;\\n if (x > y) swap(x, y);\\n if (z && s.find({x, {y, z}}) == s.end()) s1.insert({x, y});\\n }\\n cout << s1.size() + mn[n] << endl;\\n for (auto x : s) {\\n if (!x.second.second)\\n cout << x.first << \\\" \\\" << x.second.first << \\\" \\\" << 1 << endl;\\n }\\n for (auto x : s1) {\\n cout << x.first << \\\" \\\" << x.second << \\\" \\\" << 0 << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nMisha and Vanya have played several table tennis sets. Each set consists of several serves, each serve is won by one of the players, he receives one point and the loser receives nothing. Once one of the players scores exactly k points, the score is reset and a new set begins.\\n\\nAcross all the sets Misha scored a points in total, and Vanya scored b points. Given this information, determine the maximum number of sets they could have played, or that the situation is impossible.\\n\\nNote that the game consisted of several complete sets.\\n\\nInput\\n\\nThe first line contains three space-separated integers k, a and b (1 ≤ k ≤ 109, 0 ≤ a, b ≤ 109, a + b > 0).\\n\\nOutput\\n\\nIf the situation is impossible, print a single number -1. Otherwise, print the maximum possible number of sets.\\n\\nExamples\\n\\nInput\\n\\n11 11 5\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\n11 2 3\\n\\n\\nOutput\\n\\n-1\\n\\nNote\\n\\nNote that the rules of the game in this problem differ from the real table tennis game, for example, the rule of \\\"balance\\\" (the winning player has to be at least two points ahead to win a set) has no power within the present problem.\",\"targets\":\"#include \\nusing namespace std;\\nint vis[30];\\nchar s[1000];\\nint main() {\\n int k, n, m;\\n scanf(\\\"%d%d%d\\\", &k, &n, &m);\\n int yu1 = n % k;\\n int yu2 = m % k;\\n int me1 = n \\/ k;\\n int me2 = m \\/ k;\\n if ((yu1 && me2 == 0) || (yu2 && me1 == 0)) {\\n printf(\\\"-1\\\\n\\\");\\n } else if (n < k && m < k) {\\n printf(\\\"-1\\\\n\\\");\\n } else {\\n printf(\\\"%d\\\\n\\\", m \\/ k + n \\/ k);\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\n* This story is fiction and has nothing to do with real people or groups.\\n\\nSocial games have become very popular these days, and many companies are developing social games.\\n\\nYou are infiltrating one of the competing social game developers as a spy.\\n\\nproblem\\n\\nThe company you work for develops social games. The game we are developing is a game in which we collect cards and fight, and the main source of profit is the paid \\\"Gacha Gacha\\\" for 300 yen each time. There are three types of cards in this game: \\\"normal\\\", \\\"rare\\\", and \\\"S rare\\\". There are N types of \\\"S rare\\\" cards. With the paid \\\"Gacha Gacha\\\", there is a 97% chance that you will get one rare card, and a 3% chance that you will get one S rare card.\\n\\nIf you have the authority to control the appearance rate of each S rare card (3% in total) in the paid \\\"Gacha Gacha\\\", you decided to \\\"decrease\\\" the profit of the company.\\n\\nFirst, when we investigated the usage tendency of paid \\\"Gacha Gacha\\\" by various players, \\\"Each player is satisfied when he draws his favorite S rare card, and after that he does not use\\\" Gacha Gacha \\\".\\\" Became clear. From the above information, you have modeled the profits of the company under the assumption that \\\"each player prefers a particular S rare card and keeps playing until he draws that S rare card\\\".\\n\\nIn other words, the profit of the company is the sum of the percentage of people who like S rare card i x the expected value of the amount of money consumed until the S rare card i is obtained.\\n\\n\\\"Minimize\\\" your company's profits by properly manipulating the appearance rate of S rare cards.\\n\\nHowever, the appearance rate must meet the following conditions.\\n\\n* The sum of the appearance rate of all S rare cards is 3%.\\n* The appearance rate of each S rare card is at least 0.01%\\n\\n\\n\\ninput\\n\\n\\nN (S rare card type)\\nP_1 (Percentage of people who like card 1)\\nP_2 (Percentage of people who like Card 2)\\n...\\nP_N (percentage of people who like card N)\\n\\n\\noutput\\n\\nOutput the minimum value of the company's profit defined in the problem...\",\"targets\":\"#include \\n#include \\n#include \\nusing namespace std;\\nconst double lim = 0.0001;\\nint n; double p[309], sq[309], a[309];\\nint main() {\\n\\tcin >> n;\\n\\tfor (int i = 0; i < n; i++) cin >> p[i], sq[i] = sqrt(p[i]), a[i] = 0.03 \\/ n;\\n\\tdouble ret = 1.0e+9; int cnt = 0;\\n\\twhile (true) {\\n\\t\\tdouble curval = 0.0;\\n\\t\\tfor (int i = 0; i < n; i++) curval += p[i] \\/ a[i];\\n\\t\\tfor (int i = 0; i < n; i++) {\\n\\t\\t\\tfor (int j = 0; j < i; j++) {\\n\\t\\t\\t\\tdouble sa = a[i] + a[j], sp = sq[i] + sq[j];\\n\\t\\t\\t\\ta[i] = sq[i] \\/ sp * sa;\\n\\t\\t\\t\\ta[j] = sq[j] \\/ sp * sa;\\n\\t\\t\\t\\tif (a[i] < lim) a[j] -= lim - a[i], a[i] = lim;\\n\\t\\t\\t\\tif (a[j] < lim) a[i] -= lim - a[j], a[j] = lim;\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\tret = 0.0;\\n\\t\\tfor (int i = 0; i < n; i++) ret += p[i] \\/ a[i];\\n\\t\\tif (abs(curval - ret) < 1.0e-8) break;\\n\\t\\tcnt++;\\n\\t}\\n\\tcout << fixed << setprecision(15) << 300 * ret << endl;\\n\\treturn 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Fafa owns a company that works on huge projects. There are n employees in Fafa's company. Whenever the company has a new project to start working on, Fafa has to divide the tasks of this project among all the employees.\\n\\nFafa finds doing this every time is very tiring for him. So, he decided to choose the best l employees in his company as team leaders. Whenever there is a new project, Fafa will divide the tasks among only the team leaders and each team leader will be responsible of some positive number of employees to give them the tasks. To make this process fair for the team leaders, each one of them should be responsible for the same number of employees. Moreover, every employee, who is not a team leader, has to be under the responsibility of exactly one team leader, and no team leader is responsible for another team leader.\\n\\nGiven the number of employees n, find in how many ways Fafa could choose the number of team leaders l in such a way that it is possible to divide employees between them evenly.\\n\\nInput\\n\\nThe input consists of a single line containing a positive integer n (2 ≤ n ≤ 105) — the number of employees in Fafa's company.\\n\\nOutput\\n\\nPrint a single integer representing the answer to the problem.\\n\\nExamples\\n\\nInput\\n\\n2\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\n10\\n\\n\\nOutput\\n\\n3\\n\\nNote\\n\\nIn the second sample Fafa has 3 ways:\\n\\n * choose only 1 employee as a team leader with 9 employees under his responsibility. \\n * choose 2 employees as team leaders with 4 employees under the responsibility of each of them. \\n * choose 5 employees as team leaders with 1 employee under the responsibility of each of them. \\nn = i\",\"targets\":\"nt(input())\\nanswer = 1\\nfor i in range(2, n\\/\\/2 + 1):\\n if (n-i)%i == 0:\\n answer +=1\\nprint(answer)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You have a string s and a chip, which you can place onto any character of this string. \\n\\nAfter placing the chip, you move it to the right several (maybe zero) times, i. e. you perform the following operation several times: if the current position of the chip is i, you move it to the position i + 1. Of course, moving the chip to the right is impossible if it is already in the last position.\\n\\nAfter moving the chip to the right, you move it to the left several (maybe zero) times, i. e. you perform the following operation several times: if the current position of the chip is i, you move it to the position i - 1. Of course, moving the chip to the left is impossible if it is already in the first position.\\n\\nWhen you place a chip or move it, you write down the character where the chip ends up after your action. For example, if s is abcdef, you place the chip onto the 3-rd character, move it to the right 2 times and then move it to the left 3 times, you write down the string cdedcb.\\n\\nYou are given two strings s and t. Your task is to determine whether it's possible to perform the described operations with s so that you write down the string t as a result.\\n\\nInput\\n\\nThe first line contains one integer q (1 ≤ q ≤ 500) — the number of test cases.\\n\\nEach test case consists of two lines. The first line contains the string s (1 ≤ |s| ≤ 500), the second line contains the string t (1 ≤ |t| ≤ 2 ⋅ |s| - 1). Both strings consist of lowercase English characters.\\n\\nIt is guaranteed that the sum of |s| over all test cases does not exceed 500.\\n\\nOutput\\n\\nFor each test case, print \\\"YES\\\" if you can obtain the string t by performing the process mentioned in the statement with the string s, or \\\"NO\\\" if you cannot.\\n\\nYou may print each letter in any case (YES, yes, Yes will all be recognized as positive answer, NO, no and nO will all be recognized as negative answer).\\n\\nExample\\n\\nInput\\n\\n\\n6\\nabcdef\\ncdedcb\\naaa\\naaaaa\\naab\\nbaaa\\nab\\nb\\nabcdef\\nabcdef\\nba\\nbaa\\n\\n\\nOutput\\n\\n\\nYES\\nYES\\nNO\\nYES\\nYES\\nNO\\n\\nNote\\n\\nConsider the examples.\\n\\nThe first test case is described in...\\nimpor\",\"targets\":\"t java.io.*;\\nimport java.util.*;\\n \\npublic class Codeforces {\\n\\tpublic static void main(String[] args) throws IOException {\\n\\t\\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\\n\\t\\tint cases = Integer.parseInt(br.readLine());\\n\\t\\to : while(cases-- > 0) {\\n\\t\\t\\t\\/\\/String[] str = br.readLine().split(\\\" \\\");\\n\\t\\t\\t\\/\\/int n = Integer.parseInt(str[0]);\\n\\t\\t\\tString s = br.readLine();\\n\\t\\t\\tString t = br.readLine();\\n\\t\\t\\tStringBuffer rev = new StringBuffer(t);\\n\\t\\t\\trev = rev.reverse();\\n\\t\\t\\tif(s.indexOf(t) != -1 || s.indexOf(rev.toString()) != -1) {\\n\\t\\t\\t\\tSystem.out.println(\\\"YES\\\");\\n\\t\\t\\t\\tcontinue;\\n\\t\\t\\t}\\n\\t\\t\\tfor(int i=1; i=0 && r=0) {\\n\\t\\t\\t\\t\\tpreappend = t.substring(0, l+1);\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tif(good) {\\n\\t\\t\\t\\t\\tStringBuffer buf = new StringBuffer(fromnow);\\n\\t\\t\\t\\t\\tbuf = buf.reverse();\\n\\t\\t\\t\\t\\tbuf.insert(0, preappend);\\n\\t\\t\\t\\t\\tif(s.indexOf(buf.toString()) != -1) {\\n\\t\\t\\t\\t\\t\\tSystem.out.println(\\\"YES\\\");\\n\\t\\t\\t\\t\\t\\tcontinue o;\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\tSystem.out.println(\\\"NO\\\");\\n\\t\\t}\\n\\t}\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Frodo was caught by Saruman. He tore a pouch from Frodo's neck, shook out its contents —there was a pile of different rings: gold and silver...\\n\\n\\\"How am I to tell which is the One?!\\\" the mage howled.\\n\\n\\\"Throw them one by one into the Cracks of Doom and watch when Mordor falls!\\\" \\n\\nSomewhere in a parallel Middle-earth, when Saruman caught Frodo, he only found n rings. And the i-th ring was either gold or silver. For convenience Saruman wrote down a binary string s of n characters, where the i-th character was 0 if the i-th ring was gold, and 1 if it was silver.\\n\\nSaruman has a magic function f, which takes a binary string and returns a number obtained by converting the string into a binary number and then converting the binary number into a decimal number. For example, f(001010) = 10, f(111) = 7, f(11011101) = 221.\\n\\nSaruman, however, thinks that the order of the rings plays some important role. He wants to find 2 pairs of integers (l_1, r_1), (l_2, r_2), such that:\\n\\n * 1 ≤ l_1 ≤ n, 1 ≤ r_1 ≤ n, r_1-l_1+1≥ ⌊ n\\/2 ⌋ \\n * 1 ≤ l_2 ≤ n, 1 ≤ r_2 ≤ n, r_2-l_2+1≥ ⌊ n\\/2 ⌋ \\n * Pairs (l_1, r_1) and (l_2, r_2) are distinct. That is, at least one of l_1 ≠ l_2 and r_1 ≠ r_2 must hold.\\n * Let t be the substring s[l_1:r_1] of s, and w be the substring s[l_2:r_2] of s. Then there exists non-negative integer k, such that f(t) = f(w) ⋅ k.\\n\\n\\n\\nHere substring s[l:r] denotes s_ls_{l+1}… s_{r-1}s_r, and ⌊ x ⌋ denotes rounding the number down to the nearest integer.\\n\\nHelp Saruman solve this problem! It is guaranteed that under the constraints of the problem at least one solution exists.\\n\\nInput\\n\\nEach test contains multiple test cases.\\n\\nThe first line contains one positive integer t (1 ≤ t ≤ 10^3), denoting the number of test cases. Description of the test cases follows.\\n\\nThe first line of each test case contains one positive integer n (2 ≤ n ≤ 2 ⋅ 10^4) — length of the string.\\n\\nThe second line of each test case contains a non-empty binary string of length n.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nusing ll = long long;\\nconst int N = 40 + 1;\\nint n, m, arr[N], hi, lo;\\nstring str[5210];\\nmap _std;\\nvector find_divisor(int x) {\\n vector ret;\\n for (int i = 1; i * i <= x; i++) {\\n if (x == i * (x \\/ i)) {\\n ret.push_back(i);\\n if (i != x \\/ i) ret.push_back(x \\/ i);\\n }\\n }\\n sort(ret.begin(), ret.end());\\n reverse(ret.begin(), ret.end());\\n return ret;\\n}\\nbool is_possible(int val) {\\n bool ret = 1;\\n for (int i = 0; i < n; i++) {\\n for (int j = 0; j + val <= n; j += val) {\\n for (int k = j + 1; k < j + val; k++)\\n if (str[i][k] != str[i][j]) return 0;\\n }\\n }\\n for (int i = 0; i < n; i++) {\\n for (int j = 0; j + val <= n; j += val) {\\n for (int k = j + 1; k < j + val; k++)\\n if (str[k][i] != str[j][i]) return 0;\\n }\\n }\\n return 1;\\n}\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n int tst;\\n cin >> tst;\\n while (tst--) {\\n int n;\\n cin >> n;\\n string str;\\n cin >> str;\\n int first_zero = -1;\\n int i;\\n for (i = n - 1; i >= 0; i--) {\\n if (str[i] == '0') {\\n if (2 * (i + 1) > n) {\\n cout << 1 << ' ' << i + 1 << ' ' << 1 << ' ' << i << '\\\\n';\\n break;\\n } else {\\n cout << i + 1 << ' ' << n << ' ' << i + 2 << ' ' << n << '\\\\n';\\n break;\\n }\\n }\\n }\\n if (i < 0) {\\n if (n & 1) {\\n cout << 2 << ' ' << n << ' ' << (n + 1) \\/ 2 + 1 << ' ' << n << '\\\\n';\\n } else {\\n cout << 1 << ' ' << n << ' ' << n \\/ 2 + 1 << ' ' << n << '\\\\n';\\n }\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Let's denote d(n) as the number of divisors of a positive integer n. You are given three integers a, b and c. Your task is to calculate the following sum:\\n\\n\\n\\nFind the sum modulo 1073741824 (230).\\n\\nInput\\n\\nThe first line contains three space-separated integers a, b and c (1 ≤ a, b, c ≤ 100).\\n\\nOutput\\n\\nPrint a single integer — the required sum modulo 1073741824 (230).\\n\\nExamples\\n\\nInput\\n\\n2 2 2\\n\\n\\nOutput\\n\\n20\\n\\n\\nInput\\n\\n5 6 7\\n\\n\\nOutput\\n\\n1520\\n\\nNote\\n\\nFor the first example.\\n\\n * d(1·1·1) = d(1) = 1; \\n * d(1·1·2) = d(2) = 2; \\n * d(1·2·1) = d(2) = 2; \\n * d(1·2·2) = d(4) = 3; \\n * d(2·1·1) = d(2) = 2; \\n * d(2·1·2) = d(4) = 3; \\n * d(2·2·1) = d(4) = 3; \\n * d(2·2·2) = d(8) = 4. \\n\\n\\n\\nSo the result is 1 + 2 + 2 + 3 + 2 + 3 + 3 + 4 = 20.\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint main(int argc, char** argv) {\\n int a, b, c, ans = 0;\\n cin >> a >> b >> c;\\n int D[1000001] = {1, 1};\\n for (int i = 1; i < a + 1; i++) {\\n for (int j = 1; j < b + 1; j++) {\\n for (int k = 1; k < c + 1; k++) {\\n int l = i * j * k;\\n if (!D[l]) {\\n long double sqi = sqrtl(l);\\n int sum = 0;\\n for (int m = 2; m < (int)sqi + 1; m++) {\\n if (!(l % m)) {\\n if (sqi == m) {\\n sum++;\\n continue;\\n }\\n sum += 2;\\n }\\n }\\n D[l] = sum + 2;\\n }\\n ans += D[l];\\n }\\n }\\n }\\n cout << ans % (1 << 31) << endl;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given a digital clock with n digits. Each digit shows an integer from 0 to 9, so the whole clock shows an integer from 0 to 10^n-1. The clock will show leading zeroes if the number is smaller than 10^{n-1}.\\n\\nYou want the clock to show 0 with as few operations as possible. In an operation, you can do one of the following: \\n\\n * decrease the number on the clock by 1, or \\n * swap two digits (you can choose which digits to swap, and they don't have to be adjacent). \\n\\n\\n\\nYour task is to determine the minimum number of operations needed to make the clock show 0.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^3).\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 100) — number of digits on the clock.\\n\\nThe second line of each test case contains a string of n digits s_1, s_2, …, s_n (0 ≤ s_1, s_2, …, s_n ≤ 9) — the number on the clock.\\n\\nNote: If the number is smaller than 10^{n-1} the clock will show leading zeroes.\\n\\nOutput\\n\\nFor each test case, print one integer: the minimum number of operations needed to make the clock show 0.\\n\\nExample\\n\\nInput\\n\\n\\n7\\n3\\n007\\n4\\n1000\\n5\\n00000\\n3\\n103\\n4\\n2020\\n9\\n123456789\\n30\\n001678294039710047203946100020\\n\\n\\nOutput\\n\\n\\n7\\n2\\n0\\n5\\n6\\n53\\n115\\n\\nNote\\n\\nIn the first example, it's optimal to just decrease the number 7 times.\\n\\nIn the second example, we can first swap the first and last position and then decrease the number by 1.\\n\\nIn the third example, the clock already shows 0, so we don't have to perform any operations.\\nSolve the task in JAVA.\",\"targets\":\"import java.io.IOException;\\nimport java.io.InputStream;\\nimport java.io.OutputStream;\\nimport java.util.Arrays;\\nimport java.util.InputMismatchException;\\n\\n\\/**\\n * @author ethan55\\n *\\/\\npublic class Solution {\\n\\n public static void main(String[] args) {\\n TestRunner.run();\\n }\\n\\n public static class TestCase {\\n\\n static final boolean MULTIPLE = true;\\n\\n public void solve(InputReader in, OutputWriter out) {\\n char[] n = in.nextCharArray(in.nextInt());\\n int result = 0;\\n for (int i = n.length - 1; i >= 0; i--) {\\n int d = Character.getNumericValue(n[i]);\\n result += d;\\n if (i < n.length - 1 && d > 0) {\\n result++;\\n }\\n }\\n out.println(result);\\n }\\n }\\n\\n public static class TestRunner {\\n\\n public static void run() {\\n InputReader in = new InputReader(System.in);\\n try (OutputWriter out = new OutputWriter(System.out)) {\\n int testCases = TestCase.MULTIPLE ? in.nextInt() : 1;\\n for (int i = 1; i <= testCases; i++) {\\n new TestCase().solve(in, out);\\n }\\n }\\n }\\n\\n }\\n\\n public static class InputReader {\\n\\n private final InputStream inputStream;\\n private final byte[] inputBuffer = new byte[1024];\\n private int bytesRead = 0;\\n private int inputBufferIndex = 0;\\n\\n public InputReader(InputStream inputStream) {\\n this.inputStream = inputStream;\\n }\\n\\n private int readByte() {\\n if (bytesRead == -1) {\\n throw new InputMismatchException();\\n }\\n if (inputBufferIndex >= bytesRead) {\\n inputBufferIndex = 0;\\n try {\\n bytesRead = inputStream.read(inputBuffer);\\n } catch (IOException e) {\\n throw new InputMismatchException();\\n }\\n if (bytesRead <= 0) {\\n return -1;\\n }\\n }\\n return inputBuffer[inputBufferIndex++];\\n }\\n\\n private int skip() {\\n int b;\\n do {\\n b = readByte();\\n } while (b != -1 && Character.isWhitespace(b));\\n return b;\\n }\\n\\n public int nextInt() {\\n return (int)...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"You have a permutation: an array a = [a_1, a_2, …, a_n] of distinct integers from 1 to n. The length of the permutation n is odd.\\n\\nYou need to sort the permutation in increasing order.\\n\\nIn one step, you can choose any prefix of the permutation with an odd length and reverse it. Formally, if a = [a_1, a_2, …, a_n], you can choose any odd integer p between 1 and n, inclusive, and set a to [a_p, a_{p-1}, …, a_1, a_{p+1}, a_{p+2}, …, a_n].\\n\\nFind a way to sort a using no more than 5n\\/2 reversals of the above kind, or determine that such a way doesn't exist. The number of reversals doesn't have to be minimized.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 100). Description of the test cases follows.\\n\\nThe first line of each test case contains a single integer n (3 ≤ n ≤ 2021; n is odd) — the length of the permutation.\\n\\nThe second line contains n distinct integers a_1, a_2, …, a_n (1 ≤ a_i ≤ n) — the permutation itself. \\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 2021.\\n\\nOutput\\n\\nFor each test case, if it's impossible to sort the given permutation in at most 5n\\/2 reversals, print a single integer -1.\\n\\nOtherwise, print an integer m (0 ≤ m ≤ 5n\\/2), denoting the number of reversals in your sequence of steps, followed by m integers p_i (1 ≤ p_i ≤ n; p_i is odd), denoting the lengths of the prefixes of a to be reversed, in chronological order.\\n\\nNote that m doesn't have to be minimized. If there are multiple answers, print any.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n3\\n1 2 3\\n5\\n3 4 5 2 1\\n3\\n2 1 3\\n\\n\\nOutput\\n\\n\\n4\\n3 3 3 3\\n2\\n3 5\\n-1\\n\\nNote\\n\\nIn the first test case, the permutation is already sorted. Any even number of reversals of the length 3 prefix doesn't change that fact.\\n\\nIn the second test case, after reversing the prefix of length 3 the permutation will change to [5, 4, 3, 2, 1], and then after reversing the prefix of length 5 the permutation will change to [1, 2, 3, 4, 5].\\n\\nIn the third test case, it's impossible to sort the permutation.\\\":\",\"targets\":\"#include \\nusing namespace std;\\nsigned main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n long long t;\\n cin >> t;\\n while (t--) {\\n long long n;\\n cin >> n;\\n vector v(n);\\n for (long long &first : v) cin >> first;\\n bool flag = false;\\n for (long long i = 0; i < n; i++) {\\n if ((i & 1) && (v[i] & 1)) flag = true;\\n if (!(i & 1) && !(v[i] & 1)) flag = true;\\n }\\n if (flag) {\\n cout << -1 << '\\\\n';\\n continue;\\n }\\n vector res(n);\\n iota((res).begin(), (res).end(), 1);\\n long long curr = n - 1;\\n vector ans;\\n while (v != res) {\\n for (long long i = 0; i < n; i++) {\\n if (v[i] == res[curr]) {\\n ans.emplace_back(i + 1);\\n reverse(v.begin(), v.begin() + i + 1);\\n break;\\n }\\n }\\n long long pos = 0;\\n for (long long i = 0; i < n; i++) {\\n if (v[i] == res[curr - 1]) {\\n ans.emplace_back(i);\\n pos = i + 2;\\n reverse(v.begin(), v.begin() + i);\\n break;\\n }\\n }\\n ans.emplace_back(pos);\\n reverse(v.begin(), v.begin() + pos);\\n ans.emplace_back(3);\\n reverse(v.begin(), v.begin() + 3);\\n ans.emplace_back(curr + 1);\\n reverse(v.begin(), v.begin() + curr + 1);\\n curr -= 2;\\n }\\n cout << ans.size() << '\\\\n';\\n for (long long first : ans) cout << first << ' ';\\n cout << '\\\\n';\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nFox Ciel has a board with n rows and n columns, there is one integer in each cell.\\n\\nIt's known that n is an odd number, so let's introduce . Fox Ciel can do the following operation many times: she choose a sub-board with size x rows and x columns, then all numbers in it will be multiplied by -1.\\n\\nReturn the maximal sum of numbers in the board that she can get by these operations.\\n\\nInput\\n\\nThe first line contains an integer n, (1 ≤ n ≤ 33, and n is an odd integer) — the size of the board.\\n\\nEach of the next n lines contains n integers — the numbers in the board. Each number doesn't exceed 1000 by its absolute value.\\n\\nOutput\\n\\nOutput a single integer: the maximal sum of numbers in the board that can be accomplished.\\n\\nExamples\\n\\nInput\\n\\n3\\n-1 -1 1\\n-1 1 -1\\n1 -1 -1\\n\\n\\nOutput\\n\\n9\\n\\n\\nInput\\n\\n5\\n-2 0 0 0 -2\\n0 -2 0 -2 0\\n0 0 -2 0 0\\n0 -2 0 -2 0\\n-2 0 0 0 -2\\n\\n\\nOutput\\n\\n18\\n\\nNote\\n\\nIn the first test, we can apply this operation twice: first on the top left 2 × 2 sub-board, then on the bottom right 2 × 2 sub-board. Then all numbers will become positive.\\n\\n\",\"targets\":\"#include \\nusing namespace std;\\nint n, m;\\nint a[55][55];\\nint ans = -1e9;\\nvoid dfs(int now) {\\n if (now + m - 1 > n) {\\n int sum = 0;\\n for (int i = 1; i <= n; i++) {\\n for (int j = 1; j <= n; j++) {\\n sum += a[i][j];\\n }\\n }\\n for (int i = 1; i + m - 1 < n; i++) {\\n int maxn1 = 0, maxn2 = 0;\\n for (int j = n - m + 2; j <= n; j++) {\\n maxn1 += max(\\n 0, -2 * (a[j][i] + a[j - m][i] + a[j][i + m] + a[j - m][i + m]));\\n maxn2 += max(-2 * (a[j][i] + a[j][i + m]),\\n -2 * (a[j - m][i] + a[j - m][i + m]));\\n }\\n maxn2 += -2 * (a[n - m + 1][i] + a[n - m + 1][i + m]);\\n sum += max(maxn1, maxn2);\\n }\\n ans = max(ans, sum);\\n return;\\n }\\n for (int i = 1; i <= m; i++) {\\n for (int j = n - m + 1; j <= n; j++) {\\n a[now + i - 1][j] *= -1;\\n }\\n }\\n dfs(now + 1);\\n for (int i = 1; i <= m; i++) {\\n for (int j = n - m + 1; j <= n; j++) {\\n a[now + i - 1][j] *= -1;\\n }\\n }\\n dfs(now + 1);\\n}\\nint main() {\\n scanf(\\\"%d\\\", &n);\\n m = (n + 1) \\/ 2;\\n for (int i = 1; i <= n; i++) {\\n for (int j = 1; j <= n; j++) {\\n scanf(\\\"%d\\\", &a[i][j]);\\n }\\n }\\n dfs(1);\\n printf(\\\"%d\\\\n\\\", ans);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"This is a simplified version of the problem B2. Perhaps you should read the problem B2 before you start solving B1.\\n\\nPaul and Mary have a favorite string s which consists of lowercase letters of the Latin alphabet. They want to paint it using pieces of chalk of two colors: red and green. Let's call a coloring of a string wonderful if the following conditions are met:\\n\\n 1. each letter of the string is either painted in exactly one color (red or green) or isn't painted; \\n 2. each two letters which are painted in the same color are different; \\n 3. the number of letters painted in red is equal to the number of letters painted in green; \\n 4. the number of painted letters of this coloring is maximum among all colorings of the string which meet the first three conditions. \\n\\n\\n\\nE. g. consider a string s equal to \\\"kzaaa\\\". One of the wonderful colorings of the string is shown in the figure.\\n\\n The example of a wonderful coloring of the string \\\"kzaaa\\\".\\n\\nPaul and Mary want to learn by themselves how to find a wonderful coloring of the string. But they are very young, so they need a hint. Help them find k — the number of red (or green, these numbers are equal) letters in a wonderful coloring.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 1000) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one non-empty string s which consists of lowercase letters of the Latin alphabet. The number of characters in the string doesn't exceed 50.\\n\\nOutput\\n\\nFor each test case, output a separate line containing one non-negative integer k — the number of letters which will be painted in red in a wonderful coloring.\\n\\nExample\\n\\nInput\\n\\n\\n5\\nkzaaa\\ncodeforces\\narchive\\ny\\nxxxxxx\\n\\n\\nOutput\\n\\n\\n2\\n5\\n3\\n0\\n1\\n\\nNote\\n\\nThe first test case contains the string from the statement. One of the wonderful colorings is shown in the figure. There's no wonderful coloring containing 3 or more red letters because the total number of painted symbols will exceed the string's length.\\n\\nThe string from the second test case can be...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nint main() {\\n ios::sync_with_stdio(false);\\n cin.tie(0);\\n long long T, pozw, n1, x, k, n, mi, m, qqq, b, z, kot, t, w, g, h, sum, f,\\n poz, kry, kol, ot, i, q, ma, kolv, p, l, r, y, za, zu, sum1, x1, y1, d,\\n ost, ostv;\\n string s;\\n vector a, st(61), vt(26);\\n cin >> t;\\n for (qqq = 0; qqq < t; qqq = qqq + 1) {\\n a.clear();\\n cin >> s;\\n y = s.size();\\n for (i = 0; i < 26; i = i + 1) {\\n vt[i] = 0;\\n }\\n for (i = 0; i < y; i = i + 1) {\\n x = s[i] - 'a';\\n vt[x] = vt[x] + 1;\\n }\\n kol = 0;\\n kolv = 0;\\n for (i = 0; i < 26; i = i + 1) {\\n if (vt[i] >= 2) {\\n kol = kol + 1;\\n } else {\\n if (vt[i] == 1) {\\n kolv = kolv + 1;\\n }\\n }\\n }\\n cout << kol + kolv \\/ 2 << \\\"\\\\n\\\";\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Count the pairs of length-N sequences consisting of integers between 1 and M (inclusive), A_1, A_2, \\\\cdots, A_{N} and B_1, B_2, \\\\cdots, B_{N}, that satisfy all of the following conditions:\\n\\n* A_i \\\\neq B_i, for every i such that 1\\\\leq i\\\\leq N.\\n* A_i \\\\neq A_j and B_i \\\\neq B_j, for every (i, j) such that 1\\\\leq i < j\\\\leq N.\\n\\n\\n\\nSince the count can be enormous, print it modulo (10^9+7).\\n\\nConstraints\\n\\n* 1\\\\leq N \\\\leq M \\\\leq 5\\\\times10^5\\n* All values in input are integers.\\n\\nInput\\n\\nInput is given from Standard Input in the following format:\\n\\n\\nN M\\n\\n\\nOutput\\n\\nPrint the count modulo (10^9+7).\\n\\nExamples\\n\\nInput\\n\\n2 2\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n2 3\\n\\n\\nOutput\\n\\n18\\n\\n\\nInput\\n\\n141421 356237\\n\\n\\nOutput\\n\\n881613484\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include\\nconst int MOD=1e9+7;\\nstatic inline int IN(void)\\n{\\n int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}\\n while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;\\n}\\nstatic inline void OUT(int x){if(x<0)putchar('-'),x=-x;if(x>=10)OUT(x\\/10);putchar(x%10+48);}\\nint main(void)\\n{\\n int N=IN(),M=IN(),a=1,i=0,p=1,q=0,temp;\\n while(i 0) {\\n int n = fastReader.nextInt();\\n long[] arr = new long[n];\\n\\n int zeros = 0;\\n int ones = 0;\\n\\n for (int i = 0; i < n; i++) {\\n arr[i] = fastReader.nextLong();\\n\\n if (arr[i] == 0) zeros++;\\n if (arr[i] == 1) ones++;\\n }\\n\\n long ans = (1L << zeros) * (ones);\\n\\n printWriter.println(ans);\\n }\\n\\n printWriter.close();\\n }\\n\\n static class FastReader\\n {\\n BufferedReader br;\\n StringTokenizer st;\\n\\n public FastReader()\\n {\\n br = new BufferedReader(new InputStreamReader(System.in));\\n }\\n\\n String next()\\n {\\n while (st == null || !st.hasMoreElements())\\n {\\n try\\n {\\n st = new StringTokenizer(br.readLine());\\n }\\n catch (IOException e)\\n {\\n e.printStackTrace();\\n }\\n }\\n return st.nextToken();\\n }\\n\\n int nextInt()\\n {\\n return Integer.parseInt(next());\\n }\\n\\n long nextLong()\\n {\\n return Long.parseLong(next());\\n }\\n\\n double nextDouble()\\n {\\n return Double.parseDouble(next());\\n }\\n\\n String nextLine()\\n {\\n String str = \\\"\\\";\\n try\\n {\\n str = br.readLine();\\n }\\n catch (IOException e)\\n {\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A robot cleaner is placed on the floor of a rectangle room, surrounded by walls. The floor consists of n rows and m columns. The rows of the floor are numbered from 1 to n from top to bottom, and columns of the floor are numbered from 1 to m from left to right. The cell on the intersection of the r-th row and the c-th column is denoted as (r,c). The initial position of the robot is (r_b, c_b).\\n\\nIn one second, the robot moves by dr rows and dc columns, that is, after one second, the robot moves from the cell (r, c) to (r + dr, c + dc). Initially dr = 1, dc = 1. If there is a vertical wall (the left or the right walls) in the movement direction, dc is reflected before the movement, so the new value of dc is -dc. And if there is a horizontal wall (the upper or lower walls), dr is reflected before the movement, so the new value of dr is -dr.\\n\\nEach second (including the moment before the robot starts moving), the robot cleans every cell lying in the same row or the same column as its position. There is only one dirty cell at (r_d, c_d). The job of the robot is to clean that dirty cell.\\n\\n Illustration for the first example. The blue arc is the robot. The red star is the target dirty cell. Each second the robot cleans a row and a column, denoted by yellow stripes.\\n\\nGiven the floor size n and m, the robot's initial position (r_b, c_b) and the dirty cell's position (r_d, c_d), find the time for the robot to do its job.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^4). Description of the test cases follows.\\n\\nA test case consists of only one line, containing six integers n, m, r_b, c_b, r_d, and c_d (1 ≤ n, m ≤ 100, 1 ≤ r_b, r_d ≤ n, 1 ≤ c_b, c_d ≤ m) — the sizes of the room, the initial position of the robot and the position of the dirt cell.\\n\\nOutput\\n\\nFor each test case, print an integer — the time for the robot to clean the dirty cell. We can show that the robot always cleans the dirty cell eventually.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n10 10 6 1 2 8\\n10 10 9 9 1...\\nUsing java can you solve the prior task?\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\npublic class Solution {\\n static class FastReader {\\n BufferedReader br;\\n StringTokenizer st;\\n public FastReader() {\\n br = new BufferedReader(new InputStreamReader(System.in));\\n }\\n String next() {\\n while (st == null || !st.hasMoreElements()) {\\n try {\\n st = new StringTokenizer(br.readLine());\\n } catch (IOException e) {\\n e.printStackTrace();\\n }\\n }\\n return st.nextToken();\\n }\\n int nextInt() {\\n return Integer.parseInt(next());\\n }\\n long nextLong() {\\n return Long.parseLong(next());\\n }\\n double nextDouble() {\\n return Double.parseDouble(next());\\n }\\n String nextLine() {\\n String str = \\\"\\\";\\n try {\\n str = br.readLine();\\n } catch (IOException e) {\\n e.printStackTrace();\\n }\\n return str;\\n }\\n }\\n static void sort(int a[]){ \\/\\/ int -> long\\n ArrayList arr=new ArrayList<>(); \\/\\/ Integer -> Long\\n for(int i=0;i0){\\n res++;\\n n\\/=2;\\n }\\n return res;\\n }\\n\\n static int mod = (int)1e9+7;\\n static int INF = Integer.MAX_VALUE;\\n static PrintWriter out;\\n static FastReader sc ;\\n public static void main(String[] args) throws IOException {\\n sc = new...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"Let's call the string beautiful if it does not contain a substring of length at least 2, which is a palindrome. Recall that a palindrome is a string that reads the same way from the first character to the last and from the last character to the first. For example, the strings a, bab, acca, bcabcbacb are palindromes, but the strings ab, abbbaa, cccb are not.\\n\\nLet's define cost of a string as the minimum number of operations so that the string becomes beautiful, if in one operation it is allowed to change any character of the string to one of the first 3 letters of the Latin alphabet (in lowercase).\\n\\nYou are given a string s of length n, each character of the string is one of the first 3 letters of the Latin alphabet (in lowercase).\\n\\nYou have to answer m queries — calculate the cost of the substring of the string s from l_i-th to r_i-th position, inclusive.\\n\\nInput\\n\\nThe first line contains two integers n and m (1 ≤ n, m ≤ 2 ⋅ 10^5) — the length of the string s and the number of queries.\\n\\nThe second line contains the string s, it consists of n characters, each character one of the first 3 Latin letters.\\n\\nThe following m lines contain two integers l_i and r_i (1 ≤ l_i ≤ r_i ≤ n) — parameters of the i-th query.\\n\\nOutput\\n\\nFor each query, print a single integer — the cost of the substring of the string s from l_i-th to r_i-th position, inclusive.\\n\\nExample\\n\\nInput\\n\\n\\n5 4\\nbaacb\\n1 3\\n1 5\\n4 5\\n2 3\\n\\n\\nOutput\\n\\n\\n1\\n2\\n0\\n1\\n\\nNote\\n\\nConsider the queries of the example test.\\n\\n * in the first query, the substring is baa, which can be changed to bac in one operation; \\n * in the second query, the substring is baacb, which can be changed to cbacb in two operations; \\n * in the third query, the substring is cb, which can be left unchanged; \\n * in the fourth query, the substring is aa, which can be changed to ba in one operation. \\\":\",\"targets\":\"import java.util.ArrayList;\\nimport java.io.BufferedReader;\\nimport java.io.FileReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.util.StringTokenizer;\\nimport java.util.Arrays;\\nimport java.util.Random;\\nimport java.io.FileWriter;\\nimport java.io.PrintWriter;\\n\\/*\\n Solution Created: 18:40:36 30\\/07\\/2021\\n Custom Competitive programming helper.\\n*\\/\\n\\npublic class Main {\\n\\tpublic static void solve() {\\n\\t\\tint n = in.nextInt(), q = in.nextInt();\\n\\t\\tchar[] a = in.nca();\\n\\t\\tArrayList vs = new ArrayList<>();\\n\\t\\t\\n\\t\\tvs.add(getMatch(a,new char[]{'a','b','c'}));\\n\\t\\tvs.add(getMatch(a,new char[]{'a','c','b'}));\\n\\t\\tvs.add(getMatch(a,new char[]{'b','a','c'}));\\n\\t\\tvs.add(getMatch(a,new char[]{'b','c','a'}));\\n\\t\\tvs.add(getMatch(a,new char[]{'c','a','b'}));\\n\\t\\tvs.add(getMatch(a,new char[]{'c','b','a'}));\\n\\t\\twhile(q-->0) {\\n\\t\\t\\tint l = in.nextInt()-1, r= in.nextInt()-1;\\n\\t\\t\\tint ans = Integer.MAX_VALUE;\\n\\t\\t\\tfor(int[] v : vs) ans = Math.min(ans, v[r+1]-v[l]);\\n\\t\\t\\tout.println(ans);\\n\\t\\t}\\n\\t}\\n\\tstatic int[] getMatch(char[] a, char[] demo) {\\n\\t\\tint n = a.length;\\n\\t\\tint[] an = new int[n+1];\\n\\t\\tfor(int i = 0; i0) solve();\\n\\t\\tout.exit();\\n\\t}\\n\\tstatic Reader in; static Writer out;\\n\\nstatic class Reader {\\n\\tstatic BufferedReader br;\\n\\tstatic StringTokenizer st;\\n\\t\\n\\tpublic Reader() {\\n\\t\\tthis.br = new BufferedReader(new InputStreamReader(System.in));\\n\\t}\\n\\t\\n\\tpublic Reader(String f){\\n\\t\\ttry {\\n\\t\\t\\tthis.br = new BufferedReader(new FileReader(f));\\n\\t\\t} catch (IOException e) {\\n\\t\\t\\te.printStackTrace();\\n\\t\\t}\\n\\t}\\n\\t\\n\\tpublic int[] na(int n) {\\n\\t\\tint[] a = new int[n];\\n\\t\\tfor (int i = 0; i < n; i++) a[i] = nextInt();\\n\\t\\treturn a;\\n\\t}\\n\\n\\tpublic double[] nd(int n) {\\n\\t\\tdouble[] a = new double[n];\\n\\t\\tfor (int i = 0; i < n; i++) a[i] = nextDouble();\\n\\t\\treturn a;\\n\\t}\\n\\t\\n\\tpublic long[] nl(int n) {\\n\\t\\tlong[] a = new long[n];\\n\\t\\tfor (int i = 0; i < n; i++) a[i] =...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"It is the easy version of the problem. The difference is that in this version, there are no nodes with already chosen colors.\\n\\nTheofanis is starving, and he wants to eat his favorite food, sheftalia. However, he should first finish his homework. Can you help him with this problem?\\n\\nYou have a perfect binary tree of 2^k - 1 nodes — a binary tree where all vertices i from 1 to 2^{k - 1} - 1 have exactly two children: vertices 2i and 2i + 1. Vertices from 2^{k - 1} to 2^k - 1 don't have any children. You want to color its vertices with the 6 Rubik's cube colors (White, Green, Red, Blue, Orange and Yellow).\\n\\nLet's call a coloring good when all edges connect nodes with colors that are neighboring sides in the Rubik's cube.\\n\\n| \\n---|--- \\nA picture of Rubik's cube and its 2D map.\\n\\nMore formally: \\n\\n * a white node can not be neighboring with white and yellow nodes; \\n * a yellow node can not be neighboring with white and yellow nodes; \\n * a green node can not be neighboring with green and blue nodes; \\n * a blue node can not be neighboring with green and blue nodes; \\n * a red node can not be neighboring with red and orange nodes; \\n * an orange node can not be neighboring with red and orange nodes; \\n\\n\\n\\nYou want to calculate the number of the good colorings of the binary tree. Two colorings are considered different if at least one node is colored with a different color.\\n\\nThe answer may be too large, so output the answer modulo 10^9+7.\\n\\nInput\\n\\nThe first and only line contains the integers k (1 ≤ k ≤ 60) — the number of levels in the perfect binary tree you need to color.\\n\\nOutput\\n\\nPrint one integer — the number of the different colorings modulo 10^9+7.\\n\\nExamples\\n\\nInput\\n\\n\\n3\\n\\n\\nOutput\\n\\n\\n24576\\n\\n\\nInput\\n\\n\\n14\\n\\n\\nOutput\\n\\n\\n934234\\n\\nNote\\n\\nIn the picture below, you can see one of the correct colorings of the first example.\\n\\n\",\"targets\":\"def power(x, y, p) :\\n res = 1\\n x = x % p\\n if (x == 0) :\\n return 0\\n while (y > 0) :\\n if ((y & 1) == 1) :\\n res = (res * x) % p\\n y = y >> 1\\n x = (x * x) % p\\n return res\\nmod=1000000007\\nn=int(input())\\nnodes=int(pow(2,n)-2)\\nans=((6%mod)*(power(4,nodes,mod)))%mod\\nprint(ans)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Bob is playing with 6-sided dice. A net of such standard cube is shown below.\\n\\n\\n\\nHe has an unlimited supply of these dice and wants to build a tower by stacking multiple dice on top of each other, while choosing the orientation of each dice. Then he counts the number of visible pips on the faces of the dice.\\n\\nFor example, the number of visible pips on the tower below is 29 — the number visible on the top is 1, from the south 5 and 3, from the west 4 and 2, from the north 2 and 4 and from the east 3 and 5.\\n\\n\\n\\nThe one at the bottom and the two sixes by which the dice are touching are not visible, so they are not counted towards total.\\n\\nBob also has t favourite integers x_i, and for every such integer his goal is to build such a tower that the number of visible pips is exactly x_i. For each of Bob's favourite integers determine whether it is possible to build a tower that has exactly that many visible pips.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of favourite integers of Bob. \\n\\nThe second line contains t space-separated integers x_i (1 ≤ x_i ≤ 10^{18}) — Bob's favourite integers.\\n\\nOutput\\n\\nFor each of Bob's favourite integers, output \\\"YES\\\" if it is possible to build the tower, or \\\"NO\\\" otherwise (quotes for clarity).\\n\\nExample\\n\\nInput\\n\\n\\n4\\n29 34 19 38\\n\\n\\nOutput\\n\\n\\nYES\\nYES\\nYES\\nNO\\n\\nNote\\n\\nThe first example is mentioned in the problem statement.\\n\\nIn the second example, one can build the tower by flipping the top dice from the previous tower.\\n\\nIn the third example, one can use a single die that has 5 on top.\\n\\nThe fourth example is impossible.\\nt = i\",\"targets\":\"nt(input())\\na = list(map(int, input().split()))\\nfor n in a:\\n if n < 15:\\n print(\\\"NO\\\")\\n continue\\n m = n % 14\\n if m > 0 and m <= 6:\\n print(\\\"YES\\\")\\n else:\\n print(\\\"NO\\\")\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A soldier wants to buy w bananas in the shop. He has to pay k dollars for the first banana, 2k dollars for the second one and so on (in other words, he has to pay i·k dollars for the i-th banana). \\n\\nHe has n dollars. How many dollars does he have to borrow from his friend soldier to buy w bananas?\\n\\nInput\\n\\nThe first line contains three positive integers k, n, w (1 ≤ k, w ≤ 1000, 0 ≤ n ≤ 109), the cost of the first banana, initial number of dollars the soldier has and number of bananas he wants. \\n\\nOutput\\n\\nOutput one integer — the amount of dollars that the soldier must borrow from his friend. If he doesn't have to borrow money, output 0.\\n\\nExamples\\n\\nInput\\n\\n3 17 4\\n\\n\\nOutput\\n\\n13\",\"targets\":\"lst = input().split()\\nk = int(lst[0])\\nn = int(lst[1])\\nw = int(lst[2])\\ni = 1\\ntotal = 0\\nwhile i <= w:\\n total += i*k\\n i += 1\\nloan = total - n\\nif loan > 0:\\n print(loan)\\nelse:\\n print('0')\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Consider a sequence of integers a_1, a_2, …, a_n. In one move, you can select any element of the sequence and delete it. After an element is deleted, all elements to the right are shifted to the left by 1 position, so there are no empty spaces in the sequence. So after you make a move, the sequence's length decreases by 1. The indices of the elements after the move are recalculated.\\n\\nE. g. let the sequence be a=[3, 2, 2, 1, 5]. Let's select the element a_3=2 in a move. Then after the move the sequence will be equal to a=[3, 2, 1, 5], so the 3-rd element of the new sequence will be a_3=1 and the 4-th element will be a_4=5.\\n\\nYou are given a sequence a_1, a_2, …, a_n and a number k. You need to find the minimum number of moves you have to make so that in the resulting sequence there will be at least k elements that are equal to their indices, i. e. the resulting sequence b_1, b_2, …, b_m will contain at least k indices i such that b_i = i.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 100) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of two consecutive lines. The first line contains two integers n and k (1 ≤ k ≤ n ≤ 2000). The second line contains a sequence of integers a_1, a_2, …, a_n (1 ≤ a_i ≤ n). The numbers in the sequence are not necessarily different.\\n\\nIt is guaranteed that the sum of n over all test cases doesn't exceed 2000.\\n\\nOutput\\n\\nFor each test case output in a single line:\\n\\n * -1 if there's no desired move sequence; \\n * otherwise, the integer x (0 ≤ x ≤ n) — the minimum number of the moves to be made so that the resulting sequence will contain at least k elements that are equal to their indices. \\n\\nExample\\n\\nInput\\n\\n\\n4\\n7 6\\n1 1 2 3 4 5 6\\n5 2\\n5 1 3 2 3\\n5 2\\n5 5 5 5 4\\n8 4\\n1 2 3 3 2 2 5 5\\n\\n\\nOutput\\n\\n\\n1\\n2\\n-1\\n2\\n\\nNote\\n\\nIn the first test case the sequence doesn't satisfy the desired condition, but it can be provided by deleting the first element, hence the sequence will be [1, 2, 3, 4, 5, 6] and 6 elements will be equal to their indices.\\n\\nIn the second test case...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint denom = 31607;\\nint powmod(int a, int b) {\\n int res = 1;\\n a %= denom;\\n for (; b; b >>= 1) {\\n if (b & 1) res = res * a % denom;\\n a = a * a % denom;\\n }\\n return res;\\n}\\nint n;\\nint solve(int idx, int k, vector& a, vector>& dp) {\\n if (k == 0) return 0;\\n if (idx >= n) return n + 1;\\n if (dp[idx][k] != -1) return dp[idx][k];\\n int result = n + 1;\\n for (int j = (idx + 1); j < (n); j++) {\\n if (a[j] <= a[idx]) continue;\\n int dIdx = j - idx;\\n int dVal = a[j] - a[idx];\\n if (dVal > dIdx) continue;\\n result = min(result, dIdx - dVal + solve(j, k - 1, a, dp));\\n if (dIdx == dVal) break;\\n }\\n dp[idx][k] = result;\\n return result;\\n}\\nint main(int argc, const char* argv[]) {\\n ios::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n int t;\\n cin >> t;\\n while (t-- > 0) {\\n int k;\\n cin >> n >> k;\\n vector a(n);\\n for (int i = (0); i < (n); i++) {\\n cin >> a[i];\\n a[i]--;\\n }\\n vector> dp(n, vector(k + 1, -1));\\n int res = INT_MAX;\\n for (int i = (0); i < (n); i++) {\\n if (a[i] > i) continue;\\n res = min(res, i - a[i] + solve(i, k - 1, a, dp));\\n }\\n cout << (res > n ? -1 : res) << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Theofanis started playing the new online game called \\\"Among them\\\". However, he always plays with Cypriot players, and they all have the same name: \\\"Andreas\\\" (the most common name in Cyprus).\\n\\nIn each game, Theofanis plays with n other players. Since they all have the same name, they are numbered from 1 to n.\\n\\nThe players write m comments in the chat. A comment has the structure of \\\"i j c\\\" where i and j are two distinct integers and c is a string (1 ≤ i, j ≤ n; i ≠ j; c is either imposter or crewmate). The comment means that player i said that player j has the role c.\\n\\nAn imposter always lies, and a crewmate always tells the truth. \\n\\nHelp Theofanis find the maximum possible number of imposters among all the other Cypriot players, or determine that the comments contradict each other (see the notes for further explanation).\\n\\nNote that each player has exactly one role: either imposter or crewmate.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. Description of each test case follows.\\n\\nThe first line of each test case contains two integers n and m (1 ≤ n ≤ 2 ⋅ 10^5; 0 ≤ m ≤ 5 ⋅ 10^5) — the number of players except Theofanis and the number of comments.\\n\\nEach of the next m lines contains a comment made by the players of the structure \\\"i j c\\\" where i and j are two distinct integers and c is a string (1 ≤ i, j ≤ n; i ≠ j; c is either imposter or crewmate).\\n\\nThere can be multiple comments for the same pair of (i, j).\\n\\nIt is guaranteed that the sum of all n does not exceed 2 ⋅ 10^5 and the sum of all m does not exceed 5 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print one integer — the maximum possible number of imposters. If the comments contradict each other, print -1.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n3 2\\n1 2 imposter\\n2 3 crewmate\\n5 4\\n1 3 crewmate\\n2 5 crewmate\\n2 4 imposter\\n3 4 imposter\\n2 2\\n1 2 imposter\\n2 1 crewmate\\n3 5\\n1 2 imposter\\n1 2 imposter\\n3 2 crewmate\\n3 2 crewmate\\n1 3 imposter\\n5 0\\n\\n\\nOutput\\n\\n\\n2\\n4\\n-1\\n2\\n5\\n\\nNote\\n\\nIn the first test case, imposters can be Andreas 2 and 3.\\n\\nIn the second test...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = (int)3e5 + 10;\\nconst int lg = 22;\\nconst int mod = (int)1e9 + 7;\\nint c[N];\\nvector>> g;\\nbool ok;\\nint r, b;\\nbool used[N];\\nvoid dfs(int v) {\\n if (c[v] == 0)\\n r++;\\n else\\n b++;\\n used[v] = 1;\\n for (pair to : g[v]) {\\n if (used[to.first]) {\\n if (c[to.first] ^ c[v] != to.second) {\\n ok = 0;\\n }\\n } else {\\n c[to.first] = c[v] ^ to.second;\\n dfs(to.first);\\n }\\n }\\n}\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n int q;\\n cin >> q;\\n while (q--) {\\n int n, m;\\n cin >> n >> m;\\n g.clear();\\n g.resize(n);\\n for (int i = 0; i <= n; i++) used[i] = 0;\\n for (int i = 1; i <= m; i++) {\\n int u, v;\\n string s;\\n cin >> u >> v >> s;\\n --u, --v;\\n if (s == \\\"crewmate\\\") {\\n g[u].push_back({v, 0});\\n g[v].push_back({u, 0});\\n } else {\\n g[u].push_back({v, 1});\\n g[v].push_back({u, 1});\\n }\\n }\\n ok = 1;\\n int res = 0;\\n for (int i = 0; i < n; i++) {\\n if (used[i] == 0) {\\n b = 0;\\n r = 0;\\n c[i] = 1;\\n dfs(i);\\n res += max(r, b);\\n }\\n }\\n if (!ok) {\\n cout << -1 << '\\\\n';\\n continue;\\n }\\n cout << res << '\\\\n';\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A new e-mail service \\\"Berlandesk\\\" is going to be opened in Berland in the near future. The site administration wants to launch their project as soon as possible, that's why they ask you to help. You're suggested to implement the prototype of site registration system. The system should work on the following principle. \\n\\nEach time a new user wants to register, he sends to the system a request with his name. If such a name does not exist in the system database, it is inserted into the database, and the user gets the response OK, confirming the successful registration. If the name already exists in the system database, the system makes up a new user name, sends it to the user as a prompt and also inserts the prompt into the database. The new name is formed by the following rule. Numbers, starting with 1, are appended one after another to name (name1, name2, ...), among these numbers the least i is found so that namei does not yet exist in the database.\\n\\nInput\\n\\nThe first line contains number n (1 ≤ n ≤ 105). The following n lines contain the requests to the system. Each request is a non-empty line, and consists of not more than 32 characters, which are all lowercase Latin letters.\\n\\nOutput\\n\\nPrint n lines, which are system responses to the requests: OK in case of successful registration, or a prompt with a new name, if the requested name is already taken.\\n\\nExamples\\n\\nInput\\n\\n4\\nabacaba\\nacaba\\nabacaba\\nacab\\n\\n\\nOutput\\n\\nOK\\nOK\\nabacaba1\\nOK\\n\\n\\nInput\\n\\n6\\nfirst\\nfirst\\nsecond\\nsecond\\nthird\\nthird\\n\\n\\nOutput\\n\\nOK\\nfirst1\\nOK\\nsecond1\\nOK\\nthird1\\nUsing python can you solve the prior task?\",\"targets\":\"# coding =utf-8\\nstrcol = {}\\nfor i in range(int(raw_input())):\\n\\tstrtemp = raw_input()\\n\\tv = strcol.get(strtemp,0)\\n\\tprint [ 'OK',strtemp+str(v)][v>0]\\n\\tstrcol[strtemp] = v + 1\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"British mathematician John Littlewood once said about Indian mathematician Srinivasa Ramanujan that \\\"every positive integer was one of his personal friends.\\\"\\n\\nIt turns out that positive integers can also be friends with each other! You are given an array a of distinct positive integers. \\n\\nDefine a subarray a_i, a_{i+1}, …, a_j to be a friend group if and only if there exists an integer m ≥ 2 such that a_i mod m = a_{i+1} mod m = … = a_j mod m, where x mod y denotes the remainder when x is divided by y.\\n\\nYour friend Gregor wants to know the size of the largest friend group in a.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 2⋅ 10^4). \\n\\nEach test case begins with a line containing the integer n (1 ≤ n ≤ 2 ⋅ 10^5), the size of the array a.\\n\\nThe next line contains n positive integers a_1, a_2, …, a_n (1 ≤ a_i ≤ {10}^{18}), representing the contents of the array a. It is guaranteed that all the numbers in a are distinct.\\n\\nIt is guaranteed that the sum of n over all test cases is less than 2⋅ 10^5.\\n\\nOutput\\n\\nYour output should consist of t lines. Each line should consist of a single integer, the size of the largest friend group in a.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n5\\n1 5 2 4 6\\n4\\n8 2 5 10\\n2\\n1000 2000\\n8\\n465 55 3 54 234 12 45 78\\n\\n\\nOutput\\n\\n\\n3\\n3\\n2\\n6\\n\\nNote\\n\\nIn the first test case, the array is [1,5,2,4,6]. The largest friend group is [2,4,6], since all those numbers are congruent to 0 modulo 2, so m=2.\\n\\nIn the second test case, the array is [8,2,5,10]. The largest friend group is [8,2,5], since all those numbers are congruent to 2 modulo 3, so m=3.\\n\\nIn the third case, the largest friend group is [1000,2000]. There are clearly many possible values of m that work.\\nSolve the task in JAVA.\",\"targets\":\"import java.io.PrintWriter;\\nimport java.util.*;\\npublic class student {\\n public static int m, n, k;\\n public static long[] arr, pos, log;\\n public static long[][] st;\\n\\n public static Scanner obj = new Scanner(System.in);\\n public static PrintWriter out = new PrintWriter(System.out);\\n\\n public static void main(String[] args) {\\n int length = obj.nextInt();\\n while (length-- != 0) {\\n solve();\\n }\\n out.flush();\\n }\\n\\n public static void solve() {\\n m = obj.nextInt();\\n n = m - 1;\\n arr = new long[m];\\n for (int i = 0; i < m; i++) arr[i] = obj.nextLong();\\n if (m == 1) {\\n out.println(1);\\n return;\\n }\\n pos = new long[n];\\n for (int i = 0; i < n; i++) pos[i] = Math.abs(arr[i + 1] - arr[i]);\\n k = (int) (Math.log(m) \\/ Math.log(2));\\n st = new long[n][k + 1];\\n precompute();\\n \\n int ans = 0;\\n for (int i = 0; i < n; i++) {\\n int j = bs(i);\\n if (j == 1 && st[i][0] == 1) continue;\\n ans = Math.max(ans, j);\\n }\\n out.println(ans + 1);\\n }\\n\\n public static void precompute() {\\n log = new long[n + 1];\\n log[1] = 0;\\n for (int i = 2; i <= n; i++) log[i] = log[i \\/ 2] + 1;\\n for (int i = 0; i < n; i++) st[i][0] = pos[i];\\n for (int j = 1; j <= k; j++) {\\n for (int i = 0; i + (1 << j) <= n; i++) {\\n st[i][j] = gcd(st[i][j - 1], st[i + (1 << (j - 1))][j - 1]);\\n }\\n }\\n }\\n\\n public static int bs(int i) {\\n int l = i, r = n - 1;\\n int ans = i;\\n while (l <= r) {\\n int mid = (l + r) \\/ 2;\\n if (query(i, mid)) {\\n l = mid + 1;\\n ans = mid;\\n } else r = mid - 1;\\n }\\n return ans - i + 1;\\n }\\n\\n public static boolean query(int l, int r) {\\n int j = (int) log[r - l + 1];\\n return gcd(st[l][j], st[r - (1 << j) + 1][j]) >= 2;\\n }\\n\\n public static long...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given three integers n, a, b. Determine if there exists a permutation p_1, p_2, …, p_n of integers from 1 to n, such that:\\n\\n * There are exactly a integers i with 2 ≤ i ≤ n-1 such that p_{i-1} < p_i > p_{i+1} (in other words, there are exactly a local maximums).\\n\\n * There are exactly b integers i with 2 ≤ i ≤ n-1 such that p_{i-1} > p_i < p_{i+1} (in other words, there are exactly b local minimums).\\n\\n\\n\\n\\nIf such permutations exist, find any such permutation.\\n\\nInput\\n\\nThe first line of the input contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. The description of test cases follows.\\n\\nThe only line of each test case contains three integers n, a and b (2 ≤ n ≤ 10^5, 0 ≤ a,b ≤ n).\\n\\nThe sum of n over all test cases doesn't exceed 10^5.\\n\\nOutput\\n\\nFor each test case, if there is no permutation with the requested properties, output -1.\\n\\nOtherwise, print the permutation that you are found. If there are several such permutations, you may print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n4 1 1\\n6 1 2\\n6 4 0\\n\\n\\nOutput\\n\\n\\n1 3 2 4\\n4 2 3 1 5 6\\n-1\\n\\nNote\\n\\nIn the first test case, one example of such permutations is [1, 3, 2, 4]. In it p_1 < p_2 > p_3, and 2 is the only such index, and p_2> p_3 < p_4, and 3 the only such index.\\n\\nOne can show that there is no such permutation for the third test case.\",\"targets\":\"t = int(input())\\n\\n\\n\\ndef solve():\\n n, a, b = map(int, input().split())\\n # Handle unable to cases\\n if abs(a-b) > 1 or a+b > n-2:\\n print(-1)\\n return\\n\\n c = 0\\n d = n-1\\n if a >= b:\\n out = [c]\\n c += 1\\n while a or b:\\n if a > 0:\\n out.append(d)\\n a -= 1\\n d -= 1\\n if b > 0:\\n out.append(c)\\n b -= 1\\n c += 1\\n else:\\n out = [d]\\n d -= 1\\n while a or b:\\n if b > 0:\\n out.append(c)\\n b -= 1\\n c += 1\\n if a > 0:\\n out.append(d)\\n a -= 1\\n d -= 1\\n if out[-1] == c-1:\\n out += range(c, d+1)\\n else:\\n out += range(d, c-1, -1)\\n\\n out = [x+1 for x in out]\\n print(*out)\\n return\\n\\n\\nfor _ in range(t):\\n solve()\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Create a program of the square picking method, which is one of the classical random number generation methods. The square harvesting method was proposed by von Neumann in the mid-1940s.\\n\\nIn the square picking method, when the number of digits of the generated random number is n, the square of the initial value s is calculated, and the value is regarded as a 2n digit number (the number of squared digits as shown in the example below). If is not enough, make up for 0.) Let the n numbers in the center be the first random number. Then square this random number and take the n numbers in the center in the same way to get the next random number. For example, if 123 is the initial value\\n\\n\\n1232 = 00015129 → 0151\\n1512 = 00022801 → 0228\\n2282 = 00051984 → 0519\\n5192 = 00269361 → 2693\\n26932 = 07252249 → 2522\\n\\n\\nIt will be like. Use this method to create a program that takes the initial value s (a positive integer less than 10000) as an input and generates and outputs 10 random numbers when n = 4.\\n\\n\\n\\nInput\\n\\nGiven multiple datasets. The first line gives the number of datasets d (d ≤ 10). For each dataset, one row is given the initial value s (integer, 1 ≤ s <10000).\\n\\nOutput\\n\\nFor each dataset\\n\\n\\nCase x: (x is a dataset number starting with 1)\\nThe first generated random number (integer)\\nThe second generated random number (integer)\\n:\\n:\\n10th generated random number (integer)\\n\\n\\nPlease output.\\n\\nExample\\n\\nInput\\n\\n2\\n123\\n567\\n\\n\\nOutput\\n\\nCase 1:\\n151\\n228\\n519\\n2693\\n2522\\n3604\\n9888\\n7725\\n6756\\n6435\\nCase 2:\\n3214\\n3297\\n8702\\n7248\\n5335\\n4622\\n3628\\n1623\\n6341\\n2082\",\"targets\":\"#include \\n#include \\n#include \\nusing namespace std;\\n\\nint main(){\\n\\tint N;\\n\\tlong long int s;\\n\\tcin >> N;\\n\\tfor(int i = 1;i <= N;i++){\\n\\t\\t\\n\\t\\tcin >> s;\\n\\t\\tcout << \\\"Case \\\" << i << \\\":\\\" << endl;\\n\\n\\t\\tfor(int j = 10;j;j--){\\n\\t\\t\\ts *= s;\\n\\t\\t\\tstringstream ss;\\n\\t\\t\\tss << s;\\n\\t\\t\\tstring a = ss.str();\\n\\t\\t\\tint asize = a.size();\\n\\t\\t\\t\\/\\/a.size()‚͉•Ï\\n\\t\\t\\tfor(int k = 0;k < 8 - asize;k++){a = \\\"0\\\" + a;}\\n\\n\\t\\t\\tss.str(\\\"\\\");\\n\\t\\t\\tss << a.substr(2,4);\\n\\t\\t\\tlong long int b;\\n\\t\\t\\tss >> b;\\n\\t\\t\\ts = b;\\n\\t\\t\\tcout << b << endl;\\n\\t\\t}\\n\\t}\\n\\treturn 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alice and Bob are playing a game on a matrix, consisting of 2 rows and m columns. The cell in the i-th row in the j-th column contains a_{i, j} coins in it.\\n\\nInitially, both Alice and Bob are standing in a cell (1, 1). They are going to perform a sequence of moves to reach a cell (2, m).\\n\\nThe possible moves are: \\n\\n * Move right — from some cell (x, y) to (x, y + 1); \\n * Move down — from some cell (x, y) to (x + 1, y). \\n\\n\\n\\nFirst, Alice makes all her moves until she reaches (2, m). She collects the coins in all cells she visit (including the starting cell).\\n\\nWhen Alice finishes, Bob starts his journey. He also performs the moves to reach (2, m) and collects the coins in all cells that he visited, but Alice didn't.\\n\\nThe score of the game is the total number of coins Bob collects.\\n\\nAlice wants to minimize the score. Bob wants to maximize the score. What will the score of the game be if both players play optimally?\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.\\n\\nThen the descriptions of t testcases follow.\\n\\nThe first line of the testcase contains a single integer m (1 ≤ m ≤ 10^5) — the number of columns of the matrix.\\n\\nThe i-th of the next 2 lines contain m integers a_{i,1}, a_{i,2}, ..., a_{i,m} (1 ≤ a_{i,j} ≤ 10^4) — the number of coins in the cell in the i-th row in the j-th column of the matrix.\\n\\nThe sum of m over all testcases doesn't exceed 10^5.\\n\\nOutput\\n\\nFor each testcase print a single integer — the score of the game if both players play optimally.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n3\\n1 3 7\\n3 5 1\\n3\\n1 3 9\\n3 5 1\\n1\\n4\\n7\\n\\n\\nOutput\\n\\n\\n7\\n8\\n0\\n\\nNote\\n\\nThe paths for the testcases are shown on the following pictures. Alice's path is depicted in red and Bob's path is depicted in blue.\\n\\n\\nUsing java can you solve the prior task?\",\"targets\":\"import java.util.*;\\npublic class WUB {\\n\\tpublic static void main(String[] args) {\\n\\t\\tScanner sc = new Scanner(System.in);\\n\\t\\tint t = sc.nextInt();\\n\\t\\tfor (int xx = 0; xx < t; xx++) {\\n\\t\\t\\tint n = sc.nextInt();\\n\\t\\t\\tlong[][] arr = new long[2][n];\\n\\t\\t\\tfor(int i=0;i<2;i++)\\n\\t\\t\\tfor (int j = 0; j < n; j++)\\n\\t\\t\\t\\tarr[i][j] = sc.nextLong();\\n\\t\\t\\tlong ans = Long.MAX_VALUE;\\n\\t\\t\\tlong s1 = 0;\\n\\t\\t\\tlong s2 = 0;\\n\\t\\t\\tfor(int i=0;i\\nusing namespace std;\\nint n, m;\\nchar s[100005];\\nint p[100005];\\nint v[10];\\nint w[10];\\nvoid init() { w[2] = w[3] = w[5] = w[7] = 1; }\\nvoid solve() {\\n memset(v, 0, sizeof v);\\n cin >> n;\\n cin >> s + 1;\\n for (int i = 1; i <= n; i++) {\\n p[i] = s[i] - '0';\\n v[p[i]]++;\\n if (!w[p[i]]) {\\n cout << 1 << \\\"\\\\n\\\";\\n cout << p[i] << \\\"\\\\n\\\";\\n return;\\n }\\n }\\n if (v[2] > 1)\\n cout << \\\"2\\\\n22\\\\n\\\";\\n else if (v[3] > 1)\\n cout << \\\"2\\\\n33\\\\n\\\";\\n else if (v[5] > 1)\\n cout << \\\"2\\\\n55\\\\n\\\";\\n else if (v[7] > 1)\\n cout << \\\"2\\\\n77\\\\n\\\";\\n else {\\n for (int i = n; i >= 2; i--) {\\n if (p[i] == 7) {\\n for (int j = i - 1; j >= 1; j--) {\\n if (p[j] == 2 || p[j] == 5) {\\n cout << \\\"2\\\\n\\\";\\n cout << p[j] << p[i] << \\\"\\\\n\\\";\\n return;\\n }\\n }\\n }\\n }\\n for (int i = n; i >= 2; i--) {\\n if (p[i] == 2 || p[i] == 5) {\\n cout << \\\"2\\\\n\\\";\\n cout << p[1] << p[i] << \\\"\\\\n\\\";\\n return;\\n }\\n }\\n cout << \\\"3\\\\n\\\";\\n cout << p[1];\\n for (int i = 2; i <= n; i++) {\\n if (p[i] == 3) {\\n cout << \\\"37\\\\n\\\";\\n return;\\n } else if (p[i] == 7) {\\n cout << \\\"73\\\\n\\\";\\n return;\\n }\\n }\\n }\\n}\\nint main() {\\n ios::sync_with_stdio(false);\\n int ce;\\n ce = 1;\\n while (cin >> ce) {\\n init();\\n while (ce--) solve();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Another programming contest is over. You got hold of the contest's final results table. The table has the following data. For each team we are shown two numbers: the number of problems and the total penalty time. However, for no team we are shown its final place.\\n\\nYou know the rules of comparing the results of two given teams very well. Let's say that team a solved pa problems with total penalty time ta and team b solved pb problems with total penalty time tb. Team a gets a higher place than team b in the end, if it either solved more problems on the contest, or solved the same number of problems but in less total time. In other words, team a gets a higher place than team b in the final results' table if either pa > pb, or pa = pb and ta < tb. \\n\\nIt is considered that the teams that solve the same number of problems with the same penalty time share all corresponding places. More formally, let's say there is a group of x teams that solved the same number of problems with the same penalty time. Let's also say that y teams performed better than the teams from this group. In this case all teams from the group share places y + 1, y + 2, ..., y + x. The teams that performed worse than the teams from this group, get their places in the results table starting from the y + x + 1-th place.\\n\\nYour task is to count what number of teams from the given list shared the k-th place. \\n\\nInput\\n\\nThe first line contains two integers n and k (1 ≤ k ≤ n ≤ 50). Then n lines contain the description of the teams: the i-th line contains two integers pi and ti (1 ≤ pi, ti ≤ 50) — the number of solved problems and the total penalty time of the i-th team, correspondingly. All numbers in the lines are separated by spaces. \\n\\nOutput\\n\\nIn the only line print the sought number of teams that got the k-th place in the final results' table.\\n\\nExamples\\n\\nInput\\n\\n7 2\\n4 10\\n4 10\\n4 10\\n3 20\\n2 1\\n2 1\\n1 10\\n\\n\\nOutput\\n\\n3\\n\\n\\nInput\\n\\n5 4\\n3 1\\n3 1\\n5 3\\n3 1\\n3 1\\n\\n\\nOutput\\n\\n4\\n\\nNote\\n\\nThe final results' table for the first sample is: \\n\\n * 1-3 places — 4 solved problems, the...\\nThe above is tricky. Write me a correct solution in PYTHON.\",\"targets\":\"from Queue import * # Queue, LifoQueue, PriorityQueue\\nfrom bisect import * #bisect, insort\\nfrom datetime import * \\nfrom collections import * #deque, Counter,OrderedDict,defaultdict\\nimport calendar\\nimport heapq\\nimport math\\nimport copy\\nimport itertools\\nmyread = lambda : map(int,raw_input().split())\\ndef cmp_teams(x,y):\\n if x[0] != y[0]:\\n return y[0] - x[0]\\n else:\\n return x[1] - y[1]\\n\\n\\ndef solver():\\n n,k = myread()\\n teams = []\\n for _ in xrange(n):\\n p,t = myread()\\n teams.append((p,t))\\n\\n teams.sort(cmp=cmp_teams)\\n mycount = 1\\n same_teams = 1\\n now_teams = teams[0]\\n \\n center = teams[k-1]\\n ans = 1\\n for i in range(k-1):\\n if teams[i] == center:\\n ans += 1\\n\\n for i in range(k,n):\\n if teams[i] == center:\\n ans += 1\\n\\n\\n print ans\\n \\n\\n \\n\\n\\n\\n\\nif __name__ == \\\"__main__\\\":\\n solver()\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Some number of people (this number is even) have stood in a circle. The people stand in the circle evenly. They are numbered clockwise starting from a person with the number 1. Each person is looking through the circle's center at the opposite person.\\n\\n A sample of a circle of 6 persons. The orange arrows indicate who is looking at whom.\\n\\nYou don't know the exact number of people standing in the circle (but this number is even, no doubt). It is known that the person with the number a is looking at the person with the number b (and vice versa, of course). What is the number associated with a person being looked at by the person with the number c? If, for the specified a, b, and c, no such circle exists, output -1.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10^4) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one line containing three distinct integers a, b, c (1 ≤ a,b,c ≤ 10^8).\\n\\nOutput\\n\\nFor each test case output in a separate line a single integer d — the number of the person being looked at by the person with the number c in a circle such that the person with the number a is looking at the person with the number b. If there are multiple solutions, print any of them. Output -1 if there's no circle meeting the given conditions.\\n\\nExample\\n\\nInput\\n\\n\\n7\\n6 2 4\\n2 3 1\\n2 4 10\\n5 3 4\\n1 3 2\\n2 5 4\\n4 3 2\\n\\n\\nOutput\\n\\n\\n8\\n-1\\n-1\\n-1\\n4\\n1\\n-1\\n\\nNote\\n\\nIn the first test case, there's a desired circle of 8 people. The person with the number 6 will look at the person with the number 2 and the person with the number 8 will look at the person with the number 4.\\n\\nIn the second test case, there's no circle meeting the conditions. If the person with the number 2 is looking at the person with the number 3, the circle consists of 2 people because these persons are neighbors. But, in this case, they must have the numbers 1 and 2, but it doesn't meet the problem's conditions.\\n\\nIn the third test case, the only circle with the persons with the numbers 2 and 4 looking at each other consists of 4...\",\"targets\":\"for _ in range(int(input())):\\n a,b,c = map(int,input().split())\\n n = 2*abs(b-a)\\n if (c>n)or(max(a,b)>n):\\n print(-1)\\n elif c>n\\/2:\\n print(int(c-n\\/2))\\n else:\\n print(int(c+n\\/2))\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 solution for \\\"Mocha wants to be an astrologer. There are n stars which can be seen in Zhijiang, and the brightness of the i-th star is a_i. \\n\\nMocha considers that these n stars form a constellation, and she uses (a_1,a_2,…,a_n) to show its state. A state is called mathematical if all of the following three conditions are satisfied:\\n\\n * For all i (1≤ i≤ n), a_i is an integer in the range [l_i, r_i].\\n * ∑ _{i=1} ^ n a_i ≤ m.\\n * \\\\gcd(a_1,a_2,…,a_n)=1.\\n\\n\\n\\nHere, \\\\gcd(a_1,a_2,…,a_n) denotes the [greatest common divisor (GCD)](https:\\/\\/en.wikipedia.org\\/wiki\\/Greatest_common_divisor) of integers a_1,a_2,…,a_n.\\n\\nMocha is wondering how many different mathematical states of this constellation exist. Because the answer may be large, you must find it modulo 998 244 353.\\n\\nTwo states (a_1,a_2,…,a_n) and (b_1,b_2,…,b_n) are considered different if there exists i (1≤ i≤ n) such that a_i ≠ b_i.\\n\\nInput\\n\\nThe first line contains two integers n and m (2 ≤ n ≤ 50, 1 ≤ m ≤ 10^5) — the number of stars and the upper bound of the sum of the brightness of stars.\\n\\nEach of the next n lines contains two integers l_i and r_i (1 ≤ l_i ≤ r_i ≤ m) — the range of the brightness of the i-th star.\\n\\nOutput\\n\\nPrint a single integer — the number of different mathematical states of this constellation, modulo 998 244 353.\\n\\nExamples\\n\\nInput\\n\\n\\n2 4\\n1 3\\n1 2\\n\\n\\nOutput\\n\\n\\n4\\n\\nInput\\n\\n\\n5 10\\n1 10\\n1 10\\n1 10\\n1 10\\n1 10\\n\\n\\nOutput\\n\\n\\n251\\n\\nInput\\n\\n\\n5 100\\n1 94\\n1 96\\n1 91\\n4 96\\n6 97\\n\\n\\nOutput\\n\\n\\n47464146\\n\\nNote\\n\\nIn the first example, there are 4 different mathematical states of this constellation:\\n\\n * a_1=1, a_2=1.\\n * a_1=1, a_2=2.\\n * a_1=2, a_2=1.\\n * a_1=3, a_2=1.\\\":\",\"targets\":\"def naiveSolve():\\n \\n \\n \\n return\\n\\nfrom collections import Counter\\n\\ndef main():\\n \\n n,m=readIntArr()\\n l=[]\\n r=[]\\n for _ in range(n):\\n ll,rr=readIntArr()\\n l.append(ll)\\n r.append(rr)\\n \\n def countWays(mult): # count the number of ways that gcd is a multiple of mult\\n # compress everything by mult\\n m2=m\\/\\/mult\\n cnts=[0]*(m2+1) # counts\\n cnts[0]=1\\n p=cnts.copy() # prefix sum\\n for i in range(1,m2+1):\\n p[i]+=p[i-1]\\n # print('m2:{} cnts:{} p:{}'.format(m2,cnts,p))\\n for i in range(n):\\n lower=(l[i]+mult-1)\\/\\/mult\\n upper=r[i]\\/\\/mult\\n if lower>upper: # cnts will be all 0\\n return 0\\n cnts2=[0]*(m2+1)\\n for summ in range(m2+1):\\n prevUpper=min(summ-lower,m2+1)\\n prevLower=max(0,summ-upper)\\n # print('summ:{} prevU:{} prevL:{}'.format(summ,prevUpper,prevLower))\\n if prevLower<=prevUpper:\\n if prevLower==0:\\n cnts2[summ]=p[prevUpper]\\n else:\\n cnts2[summ]=p[prevUpper]-p[prevLower-1]\\n if cnts2[summ]<0:\\n cnts2[summ]+=MOD # smart mod\\n # cnts2[summ]=(cnts2[summ]+MOD)%MOD\\n p2=cnts2.copy()\\n for j in range(1,m2+1):\\n p2[j]+=p2[j-1]\\n if p2[j]>=MOD:\\n p2[j]-=MOD # smart mod\\n # p2[j]%=MOD\\n cnts=cnts2\\n p=p2\\n # print('i:{} lower:{} upper:{} cnts:{} p:{}'.format(i,lower,upper,cnts,p))\\n return p2[m2]\\n \\n \\n cnts=[-1]*(m+1) # cnts[gcd] = counts with gcd being gcd\\n for mult in range(m,0,-1):\\n nWays=countWays(mult)\\n for mult2 in range(mult*2,m+1,mult):\\n nWays-=cnts[mult2]\\n if nWays<0:\\n nWays+=MOD\\n # nWays=(nWays+MOD)%MOD\\n cnts[mult]=nWays\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"As you may know, MemSQL has American offices in both San Francisco and Seattle. Being a manager in the company, you travel a lot between the two cities, always by plane.\\n\\nYou prefer flying from Seattle to San Francisco than in the other direction, because it's warmer in San Francisco. You are so busy that you don't remember the number of flights you have made in either direction. However, for each of the last n days you know whether you were in San Francisco office or in Seattle office. You always fly at nights, so you never were at both offices on the same day. Given this information, determine if you flew more times from Seattle to San Francisco during the last n days, or not.\\n\\nInput\\n\\nThe first line of input contains single integer n (2 ≤ n ≤ 100) — the number of days.\\n\\nThe second line contains a string of length n consisting of only capital 'S' and 'F' letters. If the i-th letter is 'S', then you were in Seattle office on that day. Otherwise you were in San Francisco. The days are given in chronological order, i.e. today is the last day in this sequence.\\n\\nOutput\\n\\nPrint \\\"YES\\\" if you flew more times from Seattle to San Francisco, and \\\"NO\\\" otherwise.\\n\\nYou can print each letter in any case (upper or lower).\\n\\nExamples\\n\\nInput\\n\\n4\\nFSSF\\n\\n\\nOutput\\n\\nNO\\n\\n\\nInput\\n\\n2\\nSF\\n\\n\\nOutput\\n\\nYES\\n\\n\\nInput\\n\\n10\\nFFFFFFFFFF\\n\\n\\nOutput\\n\\nNO\\n\\n\\nInput\\n\\n10\\nSSFFSFFSFF\\n\\n\\nOutput\\n\\nYES\\n\\nNote\\n\\nIn the first example you were initially at San Francisco, then flew to Seattle, were there for two days and returned to San Francisco. You made one flight in each direction, so the answer is \\\"NO\\\".\\n\\nIn the second example you just flew from Seattle to San Francisco, so the answer is \\\"YES\\\".\\n\\nIn the third example you stayed the whole period in San Francisco, so the answer is \\\"NO\\\".\\n\\nIn the fourth example if you replace 'S' with ones, and 'F' with zeros, you'll get the first few digits of π in binary representation. Not very useful information though.\\nSolve the task in JAVA.\",\"targets\":\"\\/*\\nLANG: JAVA\\nTASK: \\n*\\/\\n\\nimport java.io.*;\\nimport java.util.*;\\npublic class cf\\n{\\n\\tpublic static void main(String[] args)\\n\\t{\\n\\t\\tScanner c= new Scanner(System.in);\\n\\t\\tint N = c.nextInt();\\n\\t\\tString str = c.next();\\n\\t\\t\\n\\t\\tint f = 0, s= 0;\\n\\t\\tfor(int i=1; is)?\\\"YES\\\":\\\"NO\\\");\\n\\t}\\n\\t\\n\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"As you may know, MemSQL has American offices in both San Francisco and Seattle. Being a manager in the company, you travel a lot between the two cities, always by plane.\\n\\nYou prefer flying from Seattle to San Francisco than in the other direction, because it's warmer in San Francisco. You are so busy that you don't remember the number of flights you have made in either direction. However, for each of the last n days you know whether you were in San Francisco office or in Seattle office. You always fly at nights, so you never were at both offices on the same day. Given this information, determine if you flew more times from Seattle to San Francisco during the last n days, or not.\\n\\nInput\\n\\nThe first line of input contains single integer n (2 ≤ n ≤ 100) — the number of days.\\n\\nThe second line contains a string of length n consisting of only capital 'S' and 'F' letters. If the i-th letter is 'S', then you were in Seattle office on that day. Otherwise you were in San Francisco. The days are given in chronological order, i.e. today is the last day in this sequence.\\n\\nOutput\\n\\nPrint \\\"YES\\\" if you flew more times from Seattle to San Francisco, and \\\"NO\\\" otherwise.\\n\\nYou can print each letter in any case (upper or lower).\\n\\nExamples\\n\\nInput\\n\\n4\\nFSSF\\n\\n\\nOutput\\n\\nNO\\n\\n\\nInput\\n\\n2\\nSF\\n\\n\\nOutput\\n\\nYES\\n\\n\\nInput\\n\\n10\\nFFFFFFFFFF\\n\\n\\nOutput\\n\\nNO\\n\\n\\nInput\\n\\n10\\nSSFFSFFSFF\\n\\n\\nOutput\\n\\nYES\\n\\nNote\\n\\nIn the first example you were initially at San Francisco, then flew to Seattle, were there for two days and returned to San Francisco. You made one flight in each direction, so the answer is \\\"NO\\\".\\n\\nIn the second example you just flew from Seattle to San Francisco, so the answer is \\\"YES\\\".\\n\\nIn the third example you stayed the whole period in San Francisco, so the answer is \\\"NO\\\".\\n\\nIn the fourth example if you replace 'S' with ones, and 'F' with zeros, you'll get the first few digits of π in binary representation. Not very useful information though.\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"n = input()\\ns = input()\\nsf, fs = 0, 0\\nfor i in range(1, len(s)):\\n if s[i] == 'S' and s[i - 1] == 'F':\\n sf += 1\\n if s[i] == 'F' and s[i - 1] == 'S':\\n fs += 1 \\nprint(['YES','NO'][sf>=fs])\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Polycarp has come up with a new game to play with you. He calls it \\\"A missing bigram\\\".\\n\\nA bigram of a word is a sequence of two adjacent letters in it.\\n\\nFor example, word \\\"abbaaba\\\" contains bigrams \\\"ab\\\", \\\"bb\\\", \\\"ba\\\", \\\"aa\\\", \\\"ab\\\" and \\\"ba\\\".\\n\\nThe game goes as follows. First, Polycarp comes up with a word, consisting only of lowercase letters 'a' and 'b'. Then, he writes down all its bigrams on a whiteboard in the same order as they appear in the word. After that, he wipes one of them off the whiteboard.\\n\\nFinally, Polycarp invites you to guess what the word that he has come up with was.\\n\\nYour goal is to find any word such that it's possible to write down all its bigrams and remove one of them, so that the resulting sequence of bigrams is the same as the one Polycarp ended up with.\\n\\nThe tests are generated in such a way that the answer exists. If there are multiple answers, you can print any of them.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 2000) — the number of testcases.\\n\\nThe first line of each testcase contains a single integer n (3 ≤ n ≤ 100) — the length of the word Polycarp has come up with.\\n\\nThe second line of each testcase contains n-2 bigrams of that word, separated by a single space. Each bigram consists of two letters, each of them is either 'a' or 'b'.\\n\\nAdditional constraint on the input: there exists at least one string such that it is possible to write down all its bigrams, except one, so that the resulting sequence is the same as the sequence in the input. In other words, the answer exists.\\n\\nOutput\\n\\nFor each testcase print a word, consisting of n letters, each of them should be either 'a' or 'b'. It should be possible to write down all its bigrams and remove one of them, so that the resulting sequence of bigrams is the same as the one Polycarp ended up with.\\n\\nThe tests are generated in such a way that the answer exists. If there are multiple answers, you can print any of them. \\n\\nExample\\n\\nInput\\n\\n\\n4\\n7\\nab bb ba aa ba\\n7\\nab ba aa ab ba\\n3\\naa\\n5\\nbb ab...\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"import os\\nimport sys\\nfrom io import BytesIO, IOBase\\nfrom collections import Counter\\nfrom collections import OrderedDict\\nfrom collections import defaultdict\\nimport bisect\\nimport math\\nfrom sys import setrecursionlimit\\n\\n\\ndef read():\\n sys.stdin = open('input.txt', 'r')\\n sys.stdout = open('output.txt', 'w')\\n\\n\\nabc = 'abcdefghijklmnopqrstuvwxyz'\\nabd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12,\\n 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}\\nmod = 1000000007\\n\\n\\ndef gcd(a, b):\\n if a == 0:\\n return b\\n return gcd(b % a, a)\\n\\n\\ndef fre_count(mylist):\\n return Counter(mylist)\\n\\n\\ndef lcm(a, b):\\n return (a \\/ gcd(a, b)) * b\\n\\n\\ndef main():\\n #read()\\n # setrecursionlimit(10**6)\\n t = int(input())\\n for _ in range(t):\\n n = int(input())\\n # l,r=map(int,input().split())\\n arr = [x for x in input().split()]\\n # arr=[int(x) for x in input()]\\n # grid=[[int(x) for x in input().split()] for x in range(n)]\\n # arr=list(input())\\n ans=\\\"\\\"\\n for i in range(1,len(arr)):\\n if arr[i][0] == arr[i-1][1]:\\n arr[i-1]=arr[i-1][0]\\n ans=\\\"\\\".join(arr)\\n if len(ans) < n:\\n ans=\\\"a\\\"+ans\\n print(ans)\\n\\nBUFSIZE = 8192\\n\\n\\nclass FastIO(IOBase):\\n newlines = 0\\n\\n def __init__(self, file):\\n self._fd = file.fileno()\\n self.buffer = BytesIO()\\n self.writable = \\\"x\\\" in file.mode or \\\"r\\\" not in file.mode\\n self.write = self.buffer.write if self.writable else None\\n\\n def read(self):\\n while True:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n if not b:\\n break\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines = 0\\n return self.buffer.read()\\n\\n def readline(self):\\n while self.newlines == 0:\\n b =...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"The city where Mocha lives in is called Zhijiang. There are n+1 villages and 2n-1 directed roads in this city. \\n\\nThere are two kinds of roads:\\n\\n * n-1 roads are from village i to village i+1, for all 1≤ i ≤ n-1. \\n * n roads can be described by a sequence a_1,…,a_n. If a_i=0, the i-th of these roads goes from village i to village n+1, otherwise it goes from village n+1 to village i, for all 1≤ i≤ n. \\n\\n\\n\\nMocha plans to go hiking with Taki this weekend. To avoid the trip being boring, they plan to go through every village exactly once. They can start and finish at any villages. Can you help them to draw up a plan? \\n\\nInput\\n\\nEach test contains multiple test cases. \\n\\nThe first line contains a single integer t (1 ≤ t ≤ 20) — the number of test cases. Each test case consists of two lines.\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 10^4) — indicates that the number of villages is n+1.\\n\\nThe second line of each test case contains n integers a_1, a_2, …, a_n (0 ≤ a_i ≤ 1). If a_i=0, it means that there is a road from village i to village n+1. If a_i=1, it means that there is a road from village n+1 to village i.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 10^4.\\n\\nOutput\\n\\nFor each test case, print a line with n+1 integers, where the i-th number is the i-th village they will go through. If the answer doesn't exist, print -1.\\n\\nIf there are multiple correct answers, you can print any one of them.\\n\\nExample\\n\\nInput\\n\\n\\n2\\n3\\n0 1 0\\n3\\n1 1 0\\n\\n\\nOutput\\n\\n\\n1 4 2 3 \\n4 1 2 3 \\n\\nNote\\n\\nIn the first test case, the city looks like the following graph:\\n\\n\\n\\nSo all possible answers are (1 → 4 → 2 → 3), (1 → 2 → 3 → 4).\\n\\nIn the second test case, the city looks like the following graph:\\n\\n\\n\\nSo all possible answers are (4 → 1 → 2 → 3), (1 → 2 → 3 → 4), (3 → 4 → 1 → 2), (2 → 3 → 4 → 1).\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nusing namespace chrono;\\nusing namespace this_thread;\\nconst int mod = 1e9 + 7;\\nconst char space = ' ';\\nchar cc = 0;\\ntemplate \\nvoid readers(type &var) {\\n var = 0;\\n char prev;\\n while (cc < 48 || cc >= 58) {\\n prev = cc;\\n cc = getchar();\\n }\\n if (prev == 45) {\\n while (cc >= 48 && cc < 58) {\\n var = (var * 10) - (cc - 48);\\n cc = getchar();\\n }\\n } else {\\n while (cc >= 48 && cc < 58) {\\n var = (var << 1) + (var << 3) + (cc - 48);\\n cc = getchar();\\n }\\n }\\n}\\nvoid readers(string &var) {\\n var = \\\"\\\";\\n while (cc <= 32 || cc == 126) {\\n cc = getchar();\\n }\\n while (cc > 32 && cc != 126) {\\n var.push_back(cc);\\n cc = getchar();\\n }\\n}\\nstruct reader {\\n template \\n reader &operator>>(type &var) {\\n readers(var);\\n return *this;\\n }\\n};\\nsigned main() {\\n cin.tie(NULL);\\n cout.tie(NULL);\\n ios_base::sync_with_stdio(false);\\n long long tc;\\n cin >> tc;\\n for (long long n; tc; --tc) {\\n cin >> n;\\n long long arr[n];\\n for (auto &x : arr) cin >> x;\\n if (arr[0]) {\\n cout << n + 1 << ' ';\\n for (long long i = 1; i <= n; ++i) cout << i << ' ';\\n cout << '\\\\n';\\n } else if (!arr[n - 1]) {\\n for (long long i = 0; i <= n; ++i) cout << i + 1 << ' ';\\n cout << '\\\\n';\\n } else {\\n long long yes = 1;\\n for (long long i = 0; i < n - 1; ++i) {\\n if (!arr[i] && arr[i + 1]) {\\n yes = 0;\\n for (long long j = 0; j <= i; ++j) cout << j + 1 << ' ';\\n cout << n + 1;\\n for (long long j = i + 2; j <= n; ++j) cout << ' ' << j;\\n cout << '\\\\n';\\n break;\\n }\\n }\\n if (yes) cout << -1 << '\\\\n';\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Luntik has decided to try singing. He has a one-minute songs, b two-minute songs and c three-minute songs. He wants to distribute all songs into two concerts such that every song should be included to exactly one concert.\\n\\nHe wants to make the absolute difference of durations of the concerts as small as possible. The duration of the concert is the sum of durations of all songs in that concert.\\n\\nPlease help Luntik and find the minimal possible difference in minutes between the concerts durations.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases.\\n\\nEach test case consists of one line containing three integers a, b, c (1 ≤ a, b, c ≤ 10^9) — the number of one-minute, two-minute and three-minute songs.\\n\\nOutput\\n\\nFor each test case print the minimal possible difference in minutes between the concerts durations.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n1 1 1\\n2 1 3\\n5 5 5\\n1 1 2\\n\\n\\nOutput\\n\\n\\n0\\n1\\n0\\n1\\n\\nNote\\n\\nIn the first test case, Luntik can include a one-minute song and a two-minute song into the first concert, and a three-minute song into the second concert. Then the difference will be equal to 0.\\n\\nIn the second test case, Luntik can include two one-minute songs and a two-minute song and a three-minute song into the first concert, and two three-minute songs into the second concert. The duration of the first concert will be 1 + 1 + 2 + 3 = 7, the duration of the second concert will be 6. The difference of them is |7-6| = 1.\\nimpor\",\"targets\":\"t java.io.*;\\nimport java.util.*;\\n\\npublic class A1 {\\n static final Reader s = new Reader();\\n static final PrintWriter out = new PrintWriter(System.out);\\n\\n public static void main(String[] args) throws IOException {\\n int t = s.nextInt();\\n\\/\\/ int t=1;\\n for(int i=1; i<=t; ++i) {\\n\\/\\/ out.print(\\\"Case #\\\"+i+\\\": \\\");\\n new Solver();\\n }\\n out.close();\\n }\\n static class Solver {\\n \\tSolver() {\\n \\t\\tlong a = s.nextLong();\\n \\t\\tlong b = s.nextLong();\\n \\t\\tlong c = s.nextLong();\\n \\t\\tSystem.out.println((a+2*(long)b+3*(long)c)%2);\\n \\t}\\n }\\n static class Reader {\\n BufferedReader in = new BufferedReader(new InputStreamReader(System.in));\\n StringTokenizer st;\\n String next() {\\n while(st==null||!st.hasMoreTokens()) {\\n try {\\n st=new StringTokenizer(in.readLine());\\n } catch(Exception e) {}\\n }\\n return st.nextToken();\\n }\\n int nextInt() {\\n return Integer.parseInt(next());\\n }\\n long nextLong() {\\n return Long.parseLong(next());\\n }\\n }\\n\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A rectangle with its opposite corners in (0, 0) and (w, h) and sides parallel to the axes is drawn on a plane.\\n\\nYou are given a list of lattice points such that each point lies on a side of a rectangle but not in its corner. Also, there are at least two points on every side of a rectangle.\\n\\nYour task is to choose three points in such a way that: \\n\\n * exactly two of them belong to the same side of a rectangle; \\n * the area of a triangle formed by them is maximum possible. \\n\\n\\n\\nPrint the doubled area of this triangle. It can be shown that the doubled area of any triangle formed by lattice points is always an integer.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.\\n\\nThe first line of each testcase contains two integers w and h (3 ≤ w, h ≤ 10^6) — the coordinates of the corner of a rectangle.\\n\\nThe next two lines contain the description of the points on two horizontal sides. First, an integer k (2 ≤ k ≤ 2 ⋅ 10^5) — the number of points. Then, k integers x_1 < x_2 < ... < x_k (0 < x_i < w) — the x coordinates of the points in the ascending order. The y coordinate for the first line is 0 and for the second line is h.\\n\\nThe next two lines contain the description of the points on two vertical sides. First, an integer k (2 ≤ k ≤ 2 ⋅ 10^5) — the number of points. Then, k integers y_1 < y_2 < ... < y_k (0 < y_i < h) — the y coordinates of the points in the ascending order. The x coordinate for the first line is 0 and for the second line is w.\\n\\nThe total number of points on all sides in all testcases doesn't exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each testcase print a single integer — the doubled maximum area of a triangle formed by such three points that exactly two of them belong to the same side.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n5 8\\n2 1 2\\n3 2 3 4\\n3 1 4 6\\n2 4 5\\n10 7\\n2 3 9\\n2 1 7\\n3 1 3 4\\n3 4 5 6\\n11 5\\n3 1 6 8\\n3 3 6 8\\n3 1 3 4\\n2 2 4\\n\\n\\nOutput\\n\\n\\n25\\n42\\n35\\n\\nNote\\n\\nThe points in the first testcase of the example: \\n\\n * (1, 0), (2, 0); \\n * (2, 8), (3, 8), (4, 8); \\n * (0, 1), (0, 4), (0, 6); \\n * (5, 4), (5,...\\nUsing python3 can you solve the prior task?\",\"targets\":\"# cook your dish here\\nimport math\\nimport collections\\ndef modInverse(p, q):\\n\\t\\n\\t mod = 998244353\\n\\t expo = 0\\n\\t expo = mod - 2\\n\\n\\t # Loop to find the value\\n\\t # until the expo is not zero\\n\\t while (expo):\\n\\t if (expo & 1):\\n\\t p = (p * q) % mod\\n\\t q = (q * q) % mod\\n\\t expo >>= 1\\n\\t return p\\n\\t \\ndef answer(x,y,li):\\n s=[]\\n for p in range(0,len(li)-1):\\n s.append(li[p+1]-li[p])\\n s.append(int(1e18))\\n \\n def solu(s,fi,y):\\n m=0\\n for j in range(0,len(s)):\\n m=m+min(s[j],fi)\\n return(m>=y)\\n \\n low=1\\n high=int(1e18)\\n ans=0\\n while (low (int(x2[-1])-int(x2[1]))*y:\\n ans1=(int(x1[-1])-int(x1[1]))*y\\n else:\\n ans1=(int(x2[-1])-int(x2[1]))*y\\n \\n if (int(y1[-1])-int(y1[1]))*x > (int(y2[-1])-int(y2[1]))*x:\\n ans2=(int(y1[-1])-int(y1[1]))*x\\n else:\\n ans2=(int(y2[-1])-int(y2[1]))*x\\n \\n \\n if ans1>ans2:\\n print(ans1)\\n else:\\n print(ans2)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Moamen has an array of n distinct integers. He wants to sort that array in non-decreasing order by doing the following operations in order exactly once:\\n\\n 1. Split the array into exactly k non-empty subarrays such that each element belongs to exactly one subarray. \\n 2. Reorder these subarrays arbitrary. \\n 3. Merge the subarrays in their new order. \\n\\n\\n\\nA sequence a is a subarray of a sequence b if a can be obtained from b by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.\\n\\nCan you tell Moamen if there is a way to sort the array in non-decreasing order using the operations written above?\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^3) — the number of test cases. The description of the test cases follows.\\n\\nThe first line of each test case contains two integers n and k (1 ≤ k ≤ n ≤ 10^5).\\n\\nThe second line contains n integers a_1, a_2, …, a_n (0 ≤ |a_i| ≤ 10^9). It is guaranteed that all numbers are distinct.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 3⋅10^5.\\n\\nOutput\\n\\nFor each test case, you should output a single string.\\n\\nIf Moamen can sort the array in non-decreasing order, output \\\"YES\\\" (without quotes). Otherwise, output \\\"NO\\\" (without quotes).\\n\\nYou can print each letter of \\\"YES\\\" and \\\"NO\\\" in any case (upper or lower).\\n\\nExample\\n\\nInput\\n\\n\\n3\\n5 4\\n6 3 4 2 1\\n4 2\\n1 -4 0 -2\\n5 1\\n1 2 3 4 5\\n\\n\\nOutput\\n\\n\\nYes\\nNo\\nYes\\n\\nNote\\n\\nIn the first test case, a = [6, 3, 4, 2, 1], and k = 4, so we can do the operations as follows: \\n\\n 1. Split a into \\\\{ [6], [3, 4], [2], [1] \\\\}. \\n 2. Reorder them: \\\\{ [1], [2], [3,4], [6] \\\\}. \\n 3. Merge them: [1, 2, 3, 4, 6], so now the array is sorted. \\n\\n\\n\\nIn the second test case, there is no way to sort the array by splitting it into only 2 subarrays.\\n\\nAs an example, if we split it into \\\\{ [1, -4], [0, -2] \\\\}, we can reorder them into \\\\{ [1, -4], [0, -2] \\\\} or \\\\{ [0, -2], [1, -4] \\\\}. However, after merging the subarrays, it is impossible to get a sorted array.\\n\\nimpo\",\"targets\":\"rt java.util.*;\\nimport java.util.Map.Entry;\\nimport java.io.*;\\nimport java.util.regex.Pattern;\\n\\n\\npublic class KSubArray {\\n\\t\\t\\t\\t\\n\\t\\t static FastReader sc=new FastReader();\\n\\t\\t public static void main(String[] args)\\n\\t\\t {\\n\\t\\t int t = sc.nextInt();\\n\\t\\t while(t-->0) {\\n\\t\\t \\t int n = sc.nextInt();\\n\\t\\t \\t int k = sc.nextInt();\\n\\t\\t \\t int a[] = new int[n];\\n\\t\\t \\t int b[] = new int[n];\\n\\t\\t \\t for (int i = 0; i < a.length; i++) {\\n\\t\\t\\t\\t\\ta[i]= sc.nextInt();\\n\\t\\t\\t\\t\\tb[i]= a[i];\\n\\t\\t\\t\\t}\\n\\t\\t \\t Arrays.sort(b);\\n\\t\\t \\t int count =0;\\n\\t\\t \\t for (int i =1; i < b.length; i++) {\\n\\t\\t\\t\\t\\tif(a[i-1]>a[i]) {\\n\\t\\t\\t\\t\\t\\tcount++;\\n\\t\\t\\t\\t\\t}else {\\n\\t\\t\\t\\t\\t\\tint idx = Arrays.binarySearch(b,a[i-1]);\\n\\t\\t\\t\\t\\t\\tif(idx==n-1||b[idx+1]!=a[i]) {\\n\\t\\t\\t\\t\\t\\t\\tcount++;\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t \\t if(count>k-1) {\\n\\t\\t \\t\\t System.out.println(\\\"No\\\");\\n\\t\\t \\t }else {\\n\\t\\t \\t\\t System.out.println(\\\"Yes\\\");\\n\\t\\t \\t }\\n\\n\\t\\t }\\n\\t\\t \\n\\t\\t \\n\\t\\t \\n\\t\\t }\\n\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\tstatic long mod = (long) 1e+9+7;\\n\\t\\t\\/\\/ Array Input\\n\\t\\tstatic void REP(int arr[], int a, int b) {\\n\\t\\t\\tfor ( int i = a; i <=b; i++){\\n\\t\\t\\t\\tarr[i]= sc.nextInt();\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\t\\/\\/ Array Display\\n\\t\\tstatic void display(int arr[], int a, int b) {\\n\\t\\t\\tfor ( int i = a; i <=b; i++){\\n\\t\\t\\t\\tSystem.out.println(arr[i]);\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\t\\n\\t\\t\\/\\/linear Search\\n\\t\\tstatic int search(int arr[],int x) {\\n\\t\\t\\tfor (int i = 0; i < arr.length; i++) {\\n\\t\\t\\t\\tif(arr[i]==x) {\\n\\t\\t\\t\\t\\treturn i;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\treturn -1;\\n\\t\\t}\\n\\t\\t\\/\\/return boolean\\n\\t\\tstatic boolean search2(int arr[],int x) {\\n\\t\\t\\tfor (int i = 0; i < arr.length; i++) {\\n\\t\\t\\t\\tif(arr[i]==x) {\\n\\t\\t\\t\\t\\treturn true;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\treturn false;\\n\\t\\t}\\n\\t\\t\\/\\/binary Search\\n\\t\\tstatic int binarySearch(int arr[],int x) {\\n\\t\\t\\tint i=0;\\n\\t\\t\\tint j=arr.length-1;\\n\\t\\t\\twhile(i\\nusing namespace std;\\nlong long a[202020];\\nlong long dp[202020][2];\\nstruct Segment {\\n long long l, r;\\n} s[202020];\\nbool cmp(const Segment &x, const Segment &y) {\\n if (x.l != y.l) return x.l < y.l;\\n return x.r > y.r;\\n}\\nint main() {\\n int T;\\n scanf(\\\"%d\\\", &T);\\n while (T--) {\\n int n, m;\\n scanf(\\\"%d%d\\\", &n, &m);\\n for (int i = 1; i <= n; i++) scanf(\\\"%lld\\\", &a[i]);\\n for (int i = 1; i <= m; i++) scanf(\\\"%lld%lld\\\", &s[i].l, &s[i].r);\\n sort(a + 1, a + n + 1);\\n sort(s + 1, s + m + 1, cmp);\\n int mm = 0;\\n for (int i = 1, j = 1; i <= m; i++) {\\n while (j <= n && a[j] < s[i].l) j++;\\n if (j <= n && s[i].l <= a[j] && a[j] <= s[i].r) continue;\\n while (mm > 0 && s[mm].r >= s[i].r) mm--;\\n mm++;\\n s[mm] = s[i];\\n }\\n m = mm;\\n dp[0][0] = dp[0][1] = 0;\\n a[n + 1] = 1e9 + 100;\\n for (int i = 1, j = 1; i <= n + 1; i++) {\\n dp[i][0] = dp[i][1] = 1e18;\\n vector V;\\n while (j <= m && s[j].r <= a[i]) {\\n V.push_back(s[j]);\\n j++;\\n }\\n if (V.empty()) {\\n dp[i][0] = min(dp[i - 1][0], dp[i - 1][1]);\\n dp[i][1] = min(dp[i - 1][0], dp[i - 1][1]);\\n continue;\\n }\\n if (i == 1) {\\n dp[i][0] = 2 * (a[i] - V[0].r);\\n dp[i][1] = a[i] - V[0].r;\\n continue;\\n }\\n if (i == n + 1) {\\n dp[i][0] = dp[i - 1][0] + (V[V.size() - 1].l - a[i - 1]);\\n dp[i][1] = dp[i - 1][1] + 2 * (V[V.size() - 1].l - a[i - 1]);\\n continue;\\n }\\n for (int k = 0; k <= V.size(); k++) {\\n int ll, rr;\\n if (k == 0)\\n ll = a[i - 1];\\n else\\n ll = V[k - 1].l;\\n if (k == V.size())\\n rr = a[i];\\n else\\n rr = V[k].r;\\n dp[i][0] =\\n min(dp[i][0],\\n min(dp[i - 1][0] + (ll - a[i - 1]) + (a[i] - rr) * 2,\\n dp[i - 1][1] + (ll - a[i - 1]) * 2 + (a[i] - rr) * 2));\\n dp[i][1] = min(dp[i][1],\\n min(dp[i - 1][0] + (ll - a[i - 1]) + (a[i] - rr),\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 solution for \\\"You have an axis-aligned rectangle room with width W and height H, so the lower left corner is in point (0, 0) and the upper right corner is in (W, H).\\n\\nThere is a rectangular table standing in this room. The sides of the table are parallel to the walls, the lower left corner is in (x_1, y_1), and the upper right corner in (x_2, y_2).\\n\\nYou want to place another rectangular table in this room with width w and height h with the width of the table parallel to the width of the room.\\n\\nThe problem is that sometimes there is not enough space to place the second table without intersecting with the first one (there are no problems with tables touching, though).\\n\\nYou can't rotate any of the tables, but you can move the first table inside the room. \\n\\n Example of how you may move the first table.\\n\\nWhat is the minimum distance you should move the first table to free enough space for the second one?\\n\\nInput\\n\\nThe first line contains the single integer t (1 ≤ t ≤ 5000) — the number of the test cases.\\n\\nThe first line of each test case contains two integers W and H (1 ≤ W, H ≤ 10^8) — the width and the height of the room.\\n\\nThe second line contains four integers x_1, y_1, x_2 and y_2 (0 ≤ x_1 < x_2 ≤ W; 0 ≤ y_1 < y_2 ≤ H) — the coordinates of the corners of the first table.\\n\\nThe third line contains two integers w and h (1 ≤ w ≤ W; 1 ≤ h ≤ H) — the width and the height of the second table.\\n\\nOutput\\n\\nFor each test case, print the minimum distance you should move the first table, or -1 if there is no way to free enough space for the second table.\\n\\nYour answer will be considered correct if its absolute or relative error doesn't exceed 10^{-6}.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n8 5\\n2 1 7 4\\n4 2\\n5 4\\n2 2 5 4\\n3 3\\n1 8\\n0 3 1 6\\n1 5\\n8 1\\n3 0 6 1\\n5 1\\n8 10\\n4 5 7 8\\n8 5\\n\\n\\nOutput\\n\\n\\n1.000000000\\n-1\\n2.000000000\\n2.000000000\\n0.000000000\\n\\nNote\\n\\nThe configuration of the first test case is shown in the picture. But the movement of the first table is not optimal. One of the optimal movement, for example, is to move the table by (0, -1), so the lower left corner...\\\":\",\"targets\":\"from __future__ import print_function\\nfrom math import *\\nfrom collections import deque\\nimport os\\nimport sys\\nfrom io import BytesIO, IOBase\\n#import time\\n \\ndef main():\\n pass\\n \\n# region fastio\\n \\nBUFSIZE = 8192\\n \\n \\nclass FastIO(IOBase):\\n newlines = 0\\n \\n def __init__(self, file):\\n self._fd = file.fileno()\\n self.buffer = BytesIO()\\n self.writable = \\\"x\\\" in file.mode or \\\"r\\\" not in file.mode\\n self.write = self.buffer.write if self.writable else None\\n \\n def read(self):\\n while True:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n if not b:\\n break\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines = 0\\n return self.buffer.read()\\n \\n def readline(self):\\n while self.newlines == 0:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n self.newlines = b.count(b\\\"\\\\n\\\") + (not b)\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines -= 1\\n return self.buffer.readline()\\n \\n def flush(self):\\n if self.writable:\\n os.write(self._fd, self.buffer.getvalue())\\n self.buffer.truncate(0), self.buffer.seek(0)\\n \\n \\nclass IOWrapper(IOBase):\\n def __init__(self, file):\\n self.buffer = FastIO(file)\\n self.flush = self.buffer.flush\\n self.writable = self.buffer.writable\\n self.write = lambda s: self.buffer.write(s.encode(\\\"ascii\\\"))\\n self.read = lambda: self.buffer.read().decode(\\\"ascii\\\")\\n self.readline = lambda: self.buffer.readline().decode(\\\"ascii\\\")\\n \\n \\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\\n#sys.stdin, sys.stdout =open(\\\"test.txt\\\",\\\"r\\\"),open(\\\"result.txt\\\",\\\"w\\\")\\n#ini=time.time()\\ninput = lambda: sys.stdin.readline().rstrip(\\\"\\\\r\\\\n\\\")\\nmod=10**9+7\\n############ ---- Input Functions ---- ############\\ndef inp():\\n return(int(input()))\\ndef...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.\\n\\nIn this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word \\\"helllo\\\" contains a typo). Besides, a couple of identical letters immediately followed by another couple of identical letters is a typo too (for example, words \\\"helloo\\\" and \\\"wwaatt\\\" contain typos).\\n\\nWrite a code that deletes the minimum number of letters from a word, correcting described typos in the word. You are allowed to delete letters from both ends and from the middle of the word.\\n\\nInput\\n\\nThe single line of the input contains word s, its length is from 1 to 200000 characters. The given word s consists of lowercase English letters.\\n\\nOutput\\n\\nPrint such word t that it doesn't contain any typos described in the problem statement and is obtained from s by deleting the least number of letters.\\n\\nIf there are multiple solutions, print any of them.\\n\\nExamples\\n\\nInput\\n\\nhelloo\\n\\n\\nOutput\\n\\nhello\\n\\n\\nInput\\n\\nwoooooow\\n\\n\\nOutput\\n\\nwoow\\n\\nNote\\n\\nThe second valid answer to the test from the statement is \\\"heloo\\\".\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n string s;\\n cin >> s;\\n int i, n = s.size();\\n vector a;\\n vector b;\\n char last = '-';\\n for (i = 0; i < n; i++) {\\n if (s[i] == last) {\\n a[a.size() - 1]++;\\n } else {\\n a.push_back(1);\\n b.push_back(s[i]);\\n }\\n last = s[i];\\n }\\n for (i = 0; i < a.size(); i++) {\\n if (a[i] > 2) {\\n a[i] = 2;\\n }\\n }\\n cout << b[0];\\n if (a[0] == 2) {\\n cout << b[0];\\n }\\n for (i = 1; i < a.size(); i++) {\\n if (a[i] == 2 && a[i - 1] == 2) {\\n a[i] = 1;\\n }\\n cout << b[i];\\n if (a[i] == 2) {\\n cout << b[i];\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"In Berland each high school student is characterized by academic performance — integer value between 1 and 5.\\n\\nIn high school 0xFF there are two groups of pupils: the group A and the group B. Each group consists of exactly n students. An academic performance of each student is known — integer value between 1 and 5.\\n\\nThe school director wants to redistribute students between groups so that each of the two groups has the same number of students whose academic performance is equal to 1, the same number of students whose academic performance is 2 and so on. In other words, the purpose of the school director is to change the composition of groups, so that for each value of academic performance the numbers of students in both groups are equal.\\n\\nTo achieve this, there is a plan to produce a series of exchanges of students between groups. During the single exchange the director selects one student from the class A and one student of class B. After that, they both change their groups.\\n\\nPrint the least number of exchanges, in order to achieve the desired equal numbers of students for each academic performance.\\n\\nInput\\n\\nThe first line of the input contains integer number n (1 ≤ n ≤ 100) — number of students in both groups.\\n\\nThe second line contains sequence of integer numbers a1, a2, ..., an (1 ≤ ai ≤ 5), where ai is academic performance of the i-th student of the group A.\\n\\nThe third line contains sequence of integer numbers b1, b2, ..., bn (1 ≤ bi ≤ 5), where bi is academic performance of the i-th student of the group B.\\n\\nOutput\\n\\nPrint the required minimum number of exchanges or -1, if the desired distribution of students can not be obtained.\\n\\nExamples\\n\\nInput\\n\\n4\\n5 4 4 4\\n5 5 4 5\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\n6\\n1 1 1 1 1 1\\n5 5 5 5 5 5\\n\\n\\nOutput\\n\\n3\\n\\n\\nInput\\n\\n1\\n5\\n3\\n\\n\\nOutput\\n\\n-1\\n\\n\\nInput\\n\\n9\\n3 2 5 5 2 3 3 3 2\\n4 1 4 1 1 2 4 4 1\\n\\n\\nOutput\\n\\n4\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint n, b, i, v[105], v2[105], a[7], a2[7], s;\\nint main() {\\n cin >> n;\\n for (i = 1; i <= n; i++) {\\n cin >> v[i];\\n a[v[i]]++;\\n }\\n for (i = 1; i <= n; i++) {\\n cin >> v2[i];\\n a2[v2[i]]++;\\n }\\n int k = 0;\\n for (i = 1; i <= 5; i++)\\n if ((a[i] + a2[i]) % 2 != 0) k = 1;\\n if (k == 1)\\n cout << \\\"-1\\\";\\n else {\\n for (i = 1; i <= 5; i++) s = s + abs(a[i] - a2[i]);\\n cout << s \\/ 4;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"CQXYM found a rectangle A of size n × m. There are n rows and m columns of blocks. Each block of the rectangle is an obsidian block or empty. CQXYM can change an obsidian block to an empty block or an empty block to an obsidian block in one operation.\\n\\nA rectangle M size of a × b is called a portal if and only if it satisfies the following conditions:\\n\\n * a ≥ 5,b ≥ 4. \\n * For all 1 < x < a, blocks M_{x,1} and M_{x,b} are obsidian blocks. \\n * For all 1 < x < b, blocks M_{1,x} and M_{a,x} are obsidian blocks. \\n * For all 1\\nusing namespace std;\\nconst int maxn = 404;\\nchar s[maxn][maxn];\\nint sum[maxn][maxn], sr[maxn], sc[maxn], sc2[maxn];\\nint main(void) {\\n int T;\\n scanf(\\\"%d\\\", &T);\\n while (T--) {\\n int n, m;\\n scanf(\\\"%d%d\\\", &n, &m);\\n for (int i = 1; i <= n; i++) scanf(\\\"%s\\\", s[i] + 1);\\n for (int i = 1; i <= n; i++) {\\n for (int j = 1; j <= m; j++) {\\n sum[i][j] =\\n sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + s[i][j] - '0';\\n }\\n }\\n int ans = n * m;\\n for (int x = 1; x <= n; x++) {\\n for (int y = x + 4; y <= n; y++) {\\n int h = y - x - 1;\\n for (int j = 1; j <= m; j++) {\\n sr[j] = sum[x][j] - sum[x - 1][j] + sum[y][j] - sum[y - 1][j];\\n sc[j] = sum[y - 1][j] - sum[y - 1][j - 1] - sum[x][j] + sum[x][j - 1];\\n sc2[j] = sc2[j - 1] + sc[j];\\n }\\n int mn = (int)1e9;\\n for (int l = 1, r = 4; r <= m; l++, r++) {\\n mn = min(mn, -sc[l] - 2 * l + sr[l] - sc2[l]);\\n ans =\\n min(ans, mn + 2 * h - sc[r] + 2 * r - 2 - sr[r - 1] + sc2[r - 1]);\\n }\\n }\\n }\\n printf(\\\"%d\\\\n\\\", ans);\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nMoamen has an array of n distinct integers. He wants to sort that array in non-decreasing order by doing the following operations in order exactly once:\\n\\n 1. Split the array into exactly k non-empty subarrays such that each element belongs to exactly one subarray. \\n 2. Reorder these subarrays arbitrary. \\n 3. Merge the subarrays in their new order. \\n\\n\\n\\nA sequence a is a subarray of a sequence b if a can be obtained from b by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.\\n\\nCan you tell Moamen if there is a way to sort the array in non-decreasing order using the operations written above?\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^3) — the number of test cases. The description of the test cases follows.\\n\\nThe first line of each test case contains two integers n and k (1 ≤ k ≤ n ≤ 10^5).\\n\\nThe second line contains n integers a_1, a_2, …, a_n (0 ≤ |a_i| ≤ 10^9). It is guaranteed that all numbers are distinct.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 3⋅10^5.\\n\\nOutput\\n\\nFor each test case, you should output a single string.\\n\\nIf Moamen can sort the array in non-decreasing order, output \\\"YES\\\" (without quotes). Otherwise, output \\\"NO\\\" (without quotes).\\n\\nYou can print each letter of \\\"YES\\\" and \\\"NO\\\" in any case (upper or lower).\\n\\nExample\\n\\nInput\\n\\n\\n3\\n5 4\\n6 3 4 2 1\\n4 2\\n1 -4 0 -2\\n5 1\\n1 2 3 4 5\\n\\n\\nOutput\\n\\n\\nYes\\nNo\\nYes\\n\\nNote\\n\\nIn the first test case, a = [6, 3, 4, 2, 1], and k = 4, so we can do the operations as follows: \\n\\n 1. Split a into \\\\{ [6], [3, 4], [2], [1] \\\\}. \\n 2. Reorder them: \\\\{ [1], [2], [3,4], [6] \\\\}. \\n 3. Merge them: [1, 2, 3, 4, 6], so now the array is sorted. \\n\\n\\n\\nIn the second test case, there is no way to sort the array by splitting it into only 2 subarrays.\\n\\nAs an example, if we split it into \\\\{ [1, -4], [0, -2] \\\\}, we can reorder them into \\\\{ [1, -4], [0, -2] \\\\} or \\\\{ [0, -2], [1, -4] \\\\}. However, after merging the subarrays, it is impossible to get a sorted array.\",\"targets\":\"#include \\n#pragma GCC target(\\\"popcnt\\\")\\nusing namespace std;\\nconst int N = 3e5 + 9;\\nconst int mod = 998244353;\\nconst int moh = 1e9 + 3;\\nconst int base = 311;\\nconst int oi = 2e9;\\nconst long long oo = 1e18;\\nconst double eps = 1e-9;\\nint dx[] = {0, 1, 0, -1, 1, 1, -1, -1};\\nint dy[] = {-1, 0, 1, 0, -1, 1, -1, 1};\\nint n, k;\\npair a[N];\\nvoid solve() {\\n cin >> n >> k;\\n for (int i = 1; i <= n; i++) {\\n cin >> a[i].first;\\n }\\n int d = 1;\\n a[1].second = 1;\\n for (int i = 2; i <= n; i++) {\\n if (a[i].first < a[i - 1].first) {\\n d++;\\n }\\n a[i].second = d;\\n }\\n sort(a + 1, a + n + 1);\\n int z = 1;\\n for (int i = 2; i <= n; i++) {\\n if (a[i].second - a[i - 1].second) {\\n z++;\\n }\\n }\\n if (z <= k) {\\n cout << \\\"YES\\\"\\n << \\\"\\\\n\\\";\\n } else {\\n cout << \\\"NO\\\"\\n << \\\"\\\\n\\\";\\n }\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n int test;\\n cin >> test;\\n while (test--) {\\n solve();\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given n lengths of segments that need to be placed on an infinite axis with coordinates.\\n\\nThe first segment is placed on the axis so that one of its endpoints lies at the point with coordinate 0. Let's call this endpoint the \\\"start\\\" of the first segment and let's call its \\\"end\\\" as that endpoint that is not the start. \\n\\nThe \\\"start\\\" of each following segment must coincide with the \\\"end\\\" of the previous one. Thus, if the length of the next segment is d and the \\\"end\\\" of the previous one has the coordinate x, the segment can be placed either on the coordinates [x-d, x], and then the coordinate of its \\\"end\\\" is x - d, or on the coordinates [x, x+d], in which case its \\\"end\\\" coordinate is x + d.\\n\\nThe total coverage of the axis by these segments is defined as their overall union which is basically the set of points covered by at least one of the segments. It's easy to show that the coverage will also be a segment on the axis. Determine the minimal possible length of the coverage that can be obtained by placing all the segments on the axis without changing their order.\\n\\nInput\\n\\nThe first line contains an integer t (1 ≤ t ≤ 1000) — the number of test cases.\\n\\nThe next 2t lines contain descriptions of the test cases. \\n\\nThe first line of each test case description contains an integer n (1 ≤ n ≤ 10^4) — the number of segments. The second line of the description contains n space-separated integers a_i (1 ≤ a_i ≤ 1000) — lengths of the segments in the same order they should be placed on the axis.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 10^4.\\n\\nOutput\\n\\nPrint t lines, each line containing the answer to the corresponding test case. The answer to a test case should be a single integer — the minimal possible length of the axis coverage.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n2\\n1 3\\n3\\n1 2 3\\n4\\n6 2 3 9\\n4\\n6 8 4 5\\n7\\n1 2 4 6 7 7 3\\n8\\n8 6 5 1 2 2 3 6\\n\\n\\nOutput\\n\\n\\n3\\n3\\n9\\n9\\n7\\n8\\n\\nNote\\n\\nIn the third sample test case the segments should be arranged as follows: [0, 6] → [4, 6] → [4, 7] → [-2, 7]. As you can see, the last segment...\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.io.PrintWriter;\\nimport java.util.Arrays;\\nimport java.util.StringTokenizer;\\n\\npublic class G {\\n\\n public static void main(String[] args)\\n {\\n FastScanner sc=new FastScanner();\\n int t=sc.nextInt();\\n PrintWriter pw=new PrintWriter(System.out);\\n while(t-->0) {\\n int n=sc.nextInt();\\n int[] a=sc.readArray(n);\\n int[][] dp=new int[2][3005];\\n Arrays.fill(dp[0],Integer.MAX_VALUE\\/2);\\n dp[0][0]=0;\\n\\n for(int i=0;i\\n\\nThe dragon has a hit point of x initially. When its hit point goes to 0 or under 0, it will be defeated. In order to defeat the dragon, Kana can cast the two following types of spells. \\n\\n * Void Absorption\\n\\nAssume that the dragon's current hit point is h, after casting this spell its hit point will become \\\\left⌊ h\\/2 \\\\right⌋ + 10. Here \\\\left⌊ h\\/2 \\\\right⌋ denotes h divided by two, rounded down.\\n\\n * Lightning Strike\\n\\nThis spell will decrease the dragon's hit point by 10. Assume that the dragon's current hit point is h, after casting this spell its hit point will be lowered to h-10.\\n\\n\\n\\n\\nDue to some reasons Kana can only cast no more than n Void Absorptions and m Lightning Strikes. She can cast the spells in any order and doesn't have to cast all the spells. Kana isn't good at math, so you are going to help her to find out whether it is possible to defeat the dragon.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases.\\n\\nThe next t lines describe test cases. For each test case the only line contains three integers x, n, m (1≤ x ≤ 10^5, 0≤ n,m≤30) — the dragon's intitial hit point, the maximum number of Void Absorptions and Lightning Strikes Kana can cast respectively.\\n\\nOutput\\n\\nIf it is possible to defeat the dragon, print \\\"YES\\\" (without quotes). Otherwise, print \\\"NO\\\" (without quotes).\\n\\nYou can print each letter in any case (upper or lower).\\n\\nExample\\n\\nInput\\n\\n\\n7\\n100 3 4\\n189 3 4\\n64 2 3\\n63 2 3\\n30 27 7\\n10 9 1\\n69117 21 2\\n\\n\\nOutput\\n\\n\\nYES\\nNO\\nNO\\nYES\\nYES\\nYES\\nYES\\n\\nNote\\n\\nOne possible casting sequence of the first test case is shown below:\\n\\n * Void Absorption \\\\left⌊ 100\\/2 \\\\right⌋ + 10=60.\\n * Lightning Strike 60-10=50.\\n * Void Absorption \\\\left⌊ 50\\/2 \\\\right⌋ + 10=35.\\n * Void Absorption \\\\left⌊...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n long long t, x, n, m, i, j;\\n cin >> t;\\n while (t--) {\\n cin >> x >> n >> m;\\n if ((x - m * 10) <= 0)\\n cout << \\\"YES\\\" << endl;\\n else {\\n for (i = 0; i < n; i++) {\\n x = (x \\/ 2) + 10;\\n }\\n long long minhaj = x - (10 * m);\\n if (minhaj <= 0)\\n cout << \\\"YES\\\" << endl;\\n else\\n cout << \\\"NO\\\" << endl;\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"After making bad dives into swimming pools, Wilbur wants to build a swimming pool in the shape of a rectangle in his backyard. He has set up coordinate axes, and he wants the sides of the rectangle to be parallel to them. Of course, the area of the rectangle must be positive. Wilbur had all four vertices of the planned pool written on a paper, until his friend came along and erased some of the vertices.\\n\\nNow Wilbur is wondering, if the remaining n vertices of the initial rectangle give enough information to restore the area of the planned swimming pool.\\n\\nInput\\n\\nThe first line of the input contains a single integer n (1 ≤ n ≤ 4) — the number of vertices that were not erased by Wilbur's friend.\\n\\nEach of the following n lines contains two integers xi and yi ( - 1000 ≤ xi, yi ≤ 1000) —the coordinates of the i-th vertex that remains. Vertices are given in an arbitrary order.\\n\\nIt's guaranteed that these points are distinct vertices of some rectangle, that has positive area and which sides are parallel to the coordinate axes.\\n\\nOutput\\n\\nPrint the area of the initial rectangle if it could be uniquely determined by the points remaining. Otherwise, print - 1. \\n\\nExamples\\n\\nInput\\n\\n2\\n0 0\\n1 1\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\n1\\n1 1\\n\\n\\nOutput\\n\\n-1\\n\\nNote\\n\\nIn the first sample, two opposite corners of the initial rectangle are given, and that gives enough information to say that the rectangle is actually a unit square.\\n\\nIn the second sample there is only one vertex left and this is definitely not enough to uniquely define the area.\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst int maxn = 10;\\nstruct point {\\n int x, y;\\n} a[maxn];\\nint x, y, n, i, ans;\\nbool cmp(point a, point b) { return a.x < b.x || (a.x == b.x && a.y < b.y); }\\nint main() {\\n scanf(\\\"%d\\\", &n);\\n for (i = 1; i <= n; i++) {\\n scanf(\\\"%d%d\\\", &x, &y);\\n a[i] = (point){x, y};\\n }\\n sort(a + 1, a + n + 1, cmp);\\n if (n == 1) {\\n ans = -1;\\n } else if (n == 2) {\\n if (a[1].x == a[2].x || a[1].y == a[2].y)\\n ans = -1;\\n else\\n ans = abs(a[1].x - a[2].x) * abs(a[1].y - a[2].y);\\n } else if (n == 3) {\\n if (a[1].x == a[2].x) {\\n if (a[3].y == a[1].y || a[3].y == a[2].y)\\n ans = abs(a[2].y - a[1].y) * abs(a[3].x - a[1].x);\\n else\\n ans = -1;\\n } else if (a[1].y == a[2].y) {\\n if (a[3].x == a[2].x)\\n ans = (a[2].x - a[1].x) * (a[3].y - a[2].y);\\n else\\n ans = -1;\\n } else if (a[1].y == a[3].y && a[3].x == a[2].x)\\n ans = (a[3].x - a[1].x) * (a[3].y - a[2].y);\\n else\\n ans = -1;\\n } else {\\n if (a[1].x == a[2].x && a[1].y == a[3].y && a[3].x == a[4].x &&\\n a[2].y == a[4].y)\\n ans = (a[4].x - a[1].x) * (a[4].y - a[1].y);\\n else\\n ans = -1;\\n }\\n printf(\\\"%d\\\", ans);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given n integers a_1, a_2, …, a_n. Find the maximum value of max(a_l, a_{l + 1}, …, a_r) ⋅ min(a_l, a_{l + 1}, …, a_r) over all pairs (l, r) of integers for which 1 ≤ l < r ≤ n.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10 000) — the number of test cases.\\n\\nThe first line of each test case contains a single integer n (2 ≤ n ≤ 10^5).\\n\\nThe second line of each test case contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^6).\\n\\nIt is guaranteed that the sum of n over all test cases doesn't exceed 3 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print a single integer — the maximum possible value of the product from the statement.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n2 4 3\\n4\\n3 2 3 1\\n2\\n69 69\\n6\\n719313 273225 402638 473783 804745 323328\\n\\n\\nOutput\\n\\n\\n12\\n6\\n4761\\n381274500335\\n\\nNote\\n\\nLet f(l, r) = max(a_l, a_{l + 1}, …, a_r) ⋅ min(a_l, a_{l + 1}, …, a_r).\\n\\nIn the first test case, \\n\\n * f(1, 2) = max(a_1, a_2) ⋅ min(a_1, a_2) = max(2, 4) ⋅ min(2, 4) = 4 ⋅ 2 = 8. \\n * f(1, 3) = max(a_1, a_2, a_3) ⋅ min(a_1, a_2, a_3) = max(2, 4, 3) ⋅ min(2, 4, 3) = 4 ⋅ 2 = 8. \\n * f(2, 3) = max(a_2, a_3) ⋅ min(a_2, a_3) = max(4, 3) ⋅ min(4, 3) = 4 ⋅ 3 = 12. \\n\\n\\n\\nSo the maximum is f(2, 3) = 12.\\n\\nIn the second test case, the maximum is f(1, 2) = f(1, 3) = f(2, 3) = 6.\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"# Problem A\\nfor _ in range(int(input())):\\n n = int(input())\\n nums = list(map(int,input().split()))\\n max_product = None \\n for i in range(n-1):\\n if max_product is None:\\n max_product = nums[i]*nums[i+1]\\n elif max_product < nums[i]*nums[i+1]:\\n max_product = nums[i]*nums[i+1]\\n print(max_product) \\n\\n\\n# Problem - B\\n# for _ in range(int(input())):\\n# nk = list(map(int,input().split()))\\n# n = nk[0]\\n# k = nk[1]\\n# nums = list(map(int,input().split()))\\n# max_product = None \\n# for i in range(n):\\n# for j in range(i+1,n):\\n# if max_product is None:\\n# max_product = (i+1)*(j+1) - (k*(nums[i] | nums[j]))\\n# elif max_product < (i+1)*(j+1) - (k*(nums[i] | nums[j])):\\n# max_product = (i+1)*(j+1) - (k*(nums[i] | nums[j]))\\n# print((i+1)*(j+1) - (k*(nums[i] | nums[j]))) \\n# print(max_product)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given three integers n, a, b. Determine if there exists a permutation p_1, p_2, …, p_n of integers from 1 to n, such that:\\n\\n * There are exactly a integers i with 2 ≤ i ≤ n-1 such that p_{i-1} < p_i > p_{i+1} (in other words, there are exactly a local maximums).\\n\\n * There are exactly b integers i with 2 ≤ i ≤ n-1 such that p_{i-1} > p_i < p_{i+1} (in other words, there are exactly b local minimums).\\n\\n\\n\\n\\nIf such permutations exist, find any such permutation.\\n\\nInput\\n\\nThe first line of the input contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. The description of test cases follows.\\n\\nThe only line of each test case contains three integers n, a and b (2 ≤ n ≤ 10^5, 0 ≤ a,b ≤ n).\\n\\nThe sum of n over all test cases doesn't exceed 10^5.\\n\\nOutput\\n\\nFor each test case, if there is no permutation with the requested properties, output -1.\\n\\nOtherwise, print the permutation that you are found. If there are several such permutations, you may print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n4 1 1\\n6 1 2\\n6 4 0\\n\\n\\nOutput\\n\\n\\n1 3 2 4\\n4 2 3 1 5 6\\n-1\\n\\nNote\\n\\nIn the first test case, one example of such permutations is [1, 3, 2, 4]. In it p_1 < p_2 > p_3, and 2 is the only such index, and p_2> p_3 < p_4, and 3 the only such index.\\n\\nOne can show that there is no such permutation for the third test case.\\nUsing python3 can you solve the prior task?\",\"targets\":\"import sys,os,io\\nimport math \\nfrom collections import defaultdict\\ndef ii():\\n return int(input())\\ndef li():\\n return list(map(int,input().split()))\\nif(os.path.exists('input.txt')):\\n sys.stdin = open(\\\"input.txt\\\",\\\"r\\\") ; sys.stdout = open(\\\"output.txt\\\",\\\"w\\\") \\nelse:\\n input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\\n\\ndef solve():\\n n,a,b = li()\\n cnt = n - 2 \\n if n==2:\\n if a==b==0:\\n print(1,2)\\n else:\\n print(-1)\\n return \\n if a+b>cnt:\\n print(-1)\\n return \\n if abs(a-b)>1:\\n print(-1)\\n return \\n \\n if b>=a:#local minimum more \\n ans = [i for i in range(1,n+1)]\\n ans.reverse()\\n ind = 1\\n for i in range(b):\\n ans[ind],ans[ind+1]=ans[ind+1],ans[ind]\\n ind+=2 \\n if b>a:\\n x = ans[ind-1]\\n y = ans[ind:]\\n ans[ind-1:-1]=y \\n ans[-1]=x \\n else:\\n ans = [i for i in range(1,n+1)]\\n ans.reverse()\\n ind = 1\\n for i in range(a):\\n ans[ind],ans[ind+1]=ans[ind+1],ans[ind]\\n ind+=2 \\n x = ans[ind-1]\\n y = ans[ind:]\\n ans[ind-1:-1]=y \\n ans[-1]=x \\n # print(*ans)\\n for i in range(n):\\n ans[i] = n - ans[i]+1\\n print(*ans)\\n\\n \\n\\n \\n\\n\\nt = 1\\nt = ii()\\nfor _ in range(t):\\n solve()\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nIn Berland, n different types of banknotes are used. Banknotes of the i-th type have denomination 10^{a_i} burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly 1.\\n\\nLet's denote f(s) as the minimum number of banknotes required to represent exactly s burles. For example, if the denominations of banknotes used in Berland are 1, 10 and 100, then f(59) = 14: 9 banknotes with denomination of 1 burle and 5 banknotes with denomination of 10 burles can be used to represent exactly 9 ⋅ 1 + 5 ⋅ 10 = 59 burles, and there's no way to do it with fewer banknotes.\\n\\nFor a given integer k, find the minimum positive number of burles s that cannot be represented with k or fewer banknotes (that is, f(s) > k).\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — number of test cases.\\n\\nThe first line of each test case contains two integers n and k (1 ≤ n ≤ 10; 1 ≤ k ≤ 10^9).\\n\\nThe next line contains n integers a_1, a_2, ..., a_n (0 = a_1 < a_2 < ... < a_n ≤ 9).\\n\\nOutput\\n\\nFor each test case, print one integer — the minimum positive number of burles s that cannot be represented with k or fewer banknotes.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3 13\\n0 1 2\\n2 777\\n0 4\\n3 255\\n0 1 3\\n10 1000000000\\n0 1 2 3 4 5 6 7 8 9\\n\\n\\nOutput\\n\\n\\n59\\n778\\n148999\\n999999920999999999\",\"targets\":\"#include \\nusing namespace std;\\nlong long PM(long long a, long long b) { return ((a % b) + b) % b; }\\nvoid solve() {\\n long long n, k;\\n cin >> n >> k;\\n int b = 0;\\n for (long long i = (0); i < (n); i++) {\\n int y;\\n cin >> y;\\n b |= (1 << y);\\n }\\n k += 1;\\n long long t = 0, z = 9;\\n string ans = \\\"\\\";\\n for (long long i = (0); i < (11); i++) {\\n if (i == 10)\\n ans = to_string(k - t) + ans;\\n else if (b & (1 << (i + 1))) {\\n ans = to_string(min(z, k - t)) + ans;\\n t += min(z, k - t);\\n z = 9;\\n } else {\\n z *= 10ll;\\n z += 9ll;\\n }\\n if (t >= k) break;\\n }\\n cout << ans << endl;\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n int t;\\n cin >> t;\\n while (t--) {\\n solve();\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices.\\n\\nOne day, a group of three good friends living in the Matsunaga housing complex bloomed with an advertisement for Seven-Eleven. Since this sale was called \\\"Customer Thanksgiving Day\\\", the highlight is that the cheapest vegetables in the bag are free. When I read the advertisement, it looks like the following sale.\\n\\n* Up to m vegetables can be packed in one bag.\\n* For bags packed with m vegetables, the cheapest vegetables are free.\\n* Bags with less than m vegetables are not eligible for the discount.\\n\\n\\n\\nThe three went shopping at Seven Mart immediately.\\n\\nWhen the three people who met outside the store after shopping were satisfied with the fact that they were able to buy a lot at a low price, they apparently found that they were all buying the same vegetables. One person said, \\\"It's really cheap, isn't it? This is XXX yen!\\\", And the other was surprised, \\\"What? I was ** yen higher than that! Why?\\\", And the rest One of them saw the receipt and noticed that he bought the cheapest one.\\n\\nNow, how can you pack the bag at the lowest purchase price? Enter the number of vegetables to purchase, the number of vegetables in the bag, and the price of each vegetable, and create a program that outputs the minimum purchase price.\\n\\n\\n\\nInput\\n\\nA sequence of multiple datasets is given as input. The end of the input is indicated by two lines of zeros. Each dataset is given in the following format:\\n\\n\\nn m\\np1 p2 ... pn\\n\\n\\nThe first line gives the number of vegetables to buy n (1 ≤ n ≤ 1000) and the number of vegetables to put in the bag m (1 ≤ m ≤ 1000). The second line gives the price pi (10 ≤ pi ≤ 10000) for each vegetable.\\n\\nThe number of datasets does not exceed 100.\\n\\nOutput\\n\\nPrints the minimum purchase price on one line for each input dataset.\\n\\nExample\\n\\nInput\\n\\n4 2\\n50 40 100 80\\n7 3\\n400 300 100 700 200 600 500\\n0...\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\n\\nint main() {\\n int N, M;\\n while (cin >> N >> M, N || M) {\\n vector v(N);\\n for (auto& i : v) cin >> i;\\n sort(v.begin(), v.end());\\n int ans = 0;\\n for (int i = 1; i <= N; i++) {\\n if (i % M) ans += v[N - i];\\n }\\n cout << ans << endl;\\n }\\n\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"n players are playing a game. \\n\\nThere are two different maps in the game. For each player, we know his strength on each map. When two players fight on a specific map, the player with higher strength on that map always wins. No two players have the same strength on the same map. \\n\\nYou are the game master and want to organize a tournament. There will be a total of n-1 battles. While there is more than one player in the tournament, choose any map and any two remaining players to fight on it. The player who loses will be eliminated from the tournament. \\n\\nIn the end, exactly one player will remain, and he is declared the winner of the tournament. For each player determine if he can win the tournament.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. The description of test cases follows.\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 10^5) — the number of players.\\n\\nThe second line of each test case contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9, a_i ≠ a_j for i ≠ j), where a_i is the strength of the i-th player on the first map. \\n\\nThe third line of each test case contains n integers b_1, b_2, ..., b_n (1 ≤ b_i ≤ 10^9, b_i ≠ b_j for i ≠ j), where b_i is the strength of the i-th player on the second map. \\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 10^5.\\n\\nOutput\\n\\nFor each test case print a string of length n. i-th character should be \\\"1\\\" if the i-th player can win the tournament, or \\\"0\\\" otherwise.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n4\\n1 2 3 4\\n1 2 3 4\\n4\\n11 12 20 21\\n44 22 11 30\\n1\\n1000000000\\n1000000000\\n\\n\\nOutput\\n\\n\\n0001\\n1111\\n1\\n\\nNote\\n\\nIn the first test case, the 4-th player will beat any other player on any game, so he will definitely win the tournament.\\n\\nIn the second test case, everyone can be a winner. \\n\\nIn the third test case, there is only one player. Clearly, he will win the tournament.\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nlong long denom = 998244353;\\nlong long powmod(long long a, long long b) {\\n long long res = 1;\\n a %= denom;\\n for (; b; b >>= 1) {\\n if (b & 1) res = res * a % denom;\\n a = a * a % denom;\\n }\\n return res;\\n}\\nint main(int argc, const char* argv[]) {\\n ios::sync_with_stdio(0), cin.tie(0);\\n long long t;\\n cin >> t;\\n while (t-- > 0) {\\n long long n;\\n cin >> n;\\n vector> v(n);\\n vector> a(n), b(n);\\n for (long long i = (0); i < (n); i++) {\\n cin >> a[i].first;\\n a[i].second = i;\\n v[i].first = a[i].first;\\n }\\n for (long long i = (0); i < (n); i++) {\\n cin >> b[i].first;\\n b[i].second = i;\\n v[i].second = b[i].first;\\n }\\n sort((a).begin(), (a).end());\\n sort((b).begin(), (b).end());\\n vector vis_a(n, false);\\n vector vis_b(n, false);\\n long long a_idx = n - 1;\\n vector res(n, false);\\n while (true) {\\n long long min_b_val = INT_MAX;\\n for (long long i = a_idx; i < n; i++) {\\n if (vis_a[i]) break;\\n min_b_val = min(v[a[i].second].second, min_b_val);\\n res[a[i].second] = true;\\n vis_a[i] = true;\\n }\\n if (min_b_val == INT_MAX) break;\\n pair p = {min_b_val - 1, INT_MAX};\\n auto it = lower_bound(b.begin(), b.end(), p);\\n long long b_idx = it - b.begin();\\n long long min_a_val = INT_MAX;\\n for (long long i = b_idx; i < n; i++) {\\n if (vis_b[i]) break;\\n min_a_val = min(min_a_val, v[b[i].second].first);\\n res[b[i].second] = true;\\n vis_b[i] = true;\\n }\\n p = {min_a_val - 1, INT_MAX};\\n a_idx = lower_bound(a.begin(), a.end(), p) - a.begin();\\n }\\n for (long long i = (0); i < (n); i++) cout << (res[i] ? \\\"1\\\" : \\\"0\\\");\\n cout << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A triangular number is the number of dots in an equilateral triangle uniformly filled with dots. For example, three dots can be arranged in a triangle; thus three is a triangular number. The n-th triangular number is the number of dots in a triangle with n dots on a side. . You can learn more about these numbers from Wikipedia (http:\\/\\/en.wikipedia.org\\/wiki\\/Triangular_number).\\n\\nYour task is to find out if a given integer is a triangular number.\\n\\nInput\\n\\nThe first line contains the single number n (1 ≤ n ≤ 500) — the given integer.\\n\\nOutput\\n\\nIf the given integer is a triangular number output YES, otherwise output NO.\\n\\nExamples\\n\\nInput\\n\\n1\\n\\n\\nOutput\\n\\nYES\\n\\n\\nInput\\n\\n2\\n\\n\\nOutput\\n\\nNO\\n\\n\\nInput\\n\\n3\\n\\n\\nOutput\\n\\nYES\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int n, a = 0, i;\\n int h[50000] = {};\\n int flag = 0;\\n cin >> n;\\n for (i = 0; i < 500; i++) {\\n a = (i * (i + 1)) \\/ 2;\\n h[a]++;\\n if (a > 500) break;\\n if (h[n]) {\\n return cout << \\\"YES\\\", 0;\\n }\\n }\\n cout << \\\"NO\\\";\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Dora the explorer has decided to use her money after several years of juicy royalties to go shopping. What better place to shop than Nlogonia?\\n\\nThere are n stores numbered from 1 to n in Nlogonia. The i-th of these stores offers a positive integer a_i.\\n\\nEach day among the last m days Dora bought a single integer from some of the stores. The same day, Swiper the fox bought a single integer from all the stores that Dora did not buy an integer from on that day.\\n\\nDora considers Swiper to be her rival, and she considers that she beat Swiper on day i if and only if the least common multiple of the numbers she bought on day i is strictly greater than the least common multiple of the numbers that Swiper bought on day i.\\n\\nThe least common multiple (LCM) of a collection of integers is the smallest positive integer that is divisible by all the integers in the collection.\\n\\nHowever, Dora forgot the values of a_i. Help Dora find out if there are positive integer values of a_i such that she beat Swiper on every day. You don't need to find what are the possible values of a_i though.\\n\\nNote that it is possible for some values of a_i to coincide in a solution.\\n\\nInput\\n\\nThe first line contains integers m and n (1≤ m ≤ 50, 1≤ n ≤ 10^4) — the number of days and the number of stores.\\n\\nAfter this m lines follow, the i-th line starts with an integer s_i (1≤ s_i ≤ n-1), the number of integers Dora bought on day i, followed by s_i distinct integers, the indices of the stores where Dora bought an integer on the i-th day. The indices are between 1 and n.\\n\\nOutput\\n\\nOutput must consist of a single line containing \\\"possible\\\" if there exist positive integers a_i such that for each day the least common multiple of the integers bought by Dora is strictly greater than the least common multiple of the integers bought by Swiper on that day. Otherwise, print \\\"impossible\\\".\\n\\nNote that you don't have to restore the integers themselves.\\n\\nExamples\\n\\nInput\\n\\n\\n2 5\\n3 1 2 3\\n3 3 4 5\\n\\n\\nOutput\\n\\n\\npossible\\n\\n\\nInput\\n\\n\\n10 10\\n1 1\\n1 2\\n1 3\\n1 4\\n1 5\\n1 6\\n1 7\\n1 8\\n1 9\\n1...\",\"targets\":\"#include \\nusing namespace std;\\nint Set(int N, int pos) { return N = N | (1 << pos); }\\nint reset(int N, int pos) { return N = N & ~(1 << pos); }\\nbool check(int N, int pos) { return (bool)(N & (1 << pos)); }\\nvoid mor() {\\n cout << \\\"impossible\\\";\\n exit(0);\\n}\\nint main() {\\n int n, m;\\n scanf(\\\"%d%d\\\", &m, &n);\\n string s(n, '0');\\n vector v;\\n for (int i = 0; i < m; i++) {\\n int x;\\n scanf(\\\"%d\\\", &x);\\n string now = s;\\n for (int j = 0; j < x; j++) {\\n int y;\\n scanf(\\\"%d\\\", &y);\\n now[y - 1] = '1';\\n }\\n for (int j = 0; j < v.size(); j++) {\\n int cnt = 0;\\n for (int k = 0; k < n; k++) cnt += (now[k] == '1' && v[j][k] == '0');\\n if (cnt == x) mor();\\n }\\n v.push_back(now);\\n }\\n cout << \\\"possible\\\";\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given an array a consisting of n positive integers. You have to choose a positive integer d and paint all elements into two colors. All elements which are divisible by d will be painted red, and all other elements will be painted blue.\\n\\nThe coloring is called beautiful if there are no pairs of adjacent elements with the same color in the array. Your task is to find any value of d which yields a beautiful coloring, or report that it is impossible.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of testcases.\\n\\nThe first line of each testcase contains one integer n (2 ≤ n ≤ 100) — the number of elements of the array.\\n\\nThe second line of each testcase contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^{18}).\\n\\nOutput\\n\\nFor each testcase print a single integer. If there is no such value of d that yields a beautiful coloring, print 0. Otherwise, print any suitable value of d (1 ≤ d ≤ 10^{18}).\\n\\nExample\\n\\nInput\\n\\n\\n5\\n5\\n1 2 3 4 5\\n3\\n10 5 15\\n3\\n100 10 200\\n10\\n9 8 2 6 6 2 8 6 5 4\\n2\\n1 3\\n\\n\\nOutput\\n\\n\\n2\\n0\\n100\\n0\\n3\\nSolve the task in PYTHON3.\",\"targets\":\"# cook your dish here\\n#import sys\\n#sys.setrecursionlimit(10**9) \\nll=lambda:map(int,input().split())\\nt=lambda:int(input())\\nss=lambda:input()\\nlx=lambda x:map(int,input().split(x))\\nyy=lambda:print(\\\"YES\\\")\\nnn=lambda:print(\\\"NO\\\")\\n\\nfrom math import log10 ,log2,ceil,factorial as fac,gcd,inf,sqrt,log,floor\\n#from itertools import combinations_with_replacement as cs \\n#from functools import reduce\\nfrom bisect import bisect_right as br,bisect_left as bl,insort\\nfrom collections import Counter\\n#from math import inf\\n\\n\\nmod=10**9+7\\n\\n\\ndef Nprime(n):\\n if n==2 or n==3:\\n return 0\\n if n==1:\\n return 1\\n i=2\\n while i*i<=n:\\n if n%i==0:\\n return 1\\n i+=1\\n return 0\\n\\ndef sum_(a,n):\\n d=4\\n s=(n*(2*a+(n-1)*d))\\/\\/2\\n return s\\n \\ndef aux(x,y):\\n if x=='a' and y=='z':\\n return 1\\n if y=='a' and x==\\\"z\\\":\\n return 1\\n return abs(ord(x)-ord(y))\\ndef aux1(x,y):\\n if x=='a' and y=='z':\\n return 1\\n if y=='z' and x=='a':\\n return 1\\n return ord('z')-ord(y)+ord(x)-ord('a')\\ndef find(low,high,p,ans):\\n while low <= high:\\n mid = (low+high)\\/\\/2\\n temp = pow(mid,p)\\n if temp == ans:\\n return mid\\n elif temp > ans:\\n high = mid-1\\n else:\\n low = mid + 1\\n return high\\n\\nfor _ in range(t()):\\n \\n#def f():\\n\\n \\n n=t()\\n a=list(ll())\\n c=a[::2]\\n d=a[1::2]\\n y=c[0]\\n fl=0\\n for i in c:\\n if gcd(i,y)==1:\\n y=1\\n break\\n y=gcd(i,y)\\n \\n\\n z=d[0]\\n \\n for i in d:\\n if gcd(i,z)==1:\\n z=1\\n break\\n z=gcd(i,z)\\n \\n for i in c:\\n if i%z==0:\\n fl+=1\\n break\\n else:\\n print(z)\\n if fl:\\n for i in d:\\n if i%y==0:\\n fl+=1\\n break\\n else:\\n print(y)\\n if fl>1:\\n print(0)\\n \\n \\n \\n \\n \\n\\n \\n \\n \\n \\n \\n'''\\np m\\n\\n5 9\\n3 7\\n1 5\\n\\n3 2\\n49 1\\n\\ndist[child]=dist[parent]+dist[node]\\n\\n\\n9 8 7...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nPolycarp has a string s. Polycarp performs the following actions until the string s is empty (t is initially an empty string):\\n\\n * he adds to the right to the string t the string s, i.e. he does t = t + s, where t + s is a concatenation of the strings t and s; \\n * he selects an arbitrary letter of s and removes from s all its occurrences (the selected letter must occur in the string s at the moment of performing this action). \\n\\n\\n\\nPolycarp performs this sequence of actions strictly in this order.\\n\\nNote that after Polycarp finishes the actions, the string s will be empty and the string t will be equal to some value (that is undefined and depends on the order of removing).\\n\\nE.g. consider s=\\\"abacaba\\\" so the actions may be performed as follows:\\n\\n * t=\\\"abacaba\\\", the letter 'b' is selected, then s=\\\"aacaa\\\"; \\n * t=\\\"abacabaaacaa\\\", the letter 'a' is selected, then s=\\\"c\\\"; \\n * t=\\\"abacabaaacaac\\\", the letter 'c' is selected, then s=\\\"\\\" (the empty string). \\n\\n\\n\\nYou need to restore the initial value of the string s using only the final value of t and find the order of removing letters from s.\\n\\nInput\\n\\nThe first line contains one integer T (1 ≤ T ≤ 10^4) — the number of test cases. Then T test cases follow.\\n\\nEach test case contains one string t consisting of lowercase letters of the Latin alphabet. The length of t doesn't exceed 5 ⋅ 10^5. The sum of lengths of all strings t in the test cases doesn't exceed 5 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case output in a separate line:\\n\\n * -1, if the answer doesn't exist; \\n * two strings separated by spaces. The first one must contain a possible initial value of s. The second one must contain a sequence of letters — it's in what order one needs to remove letters from s to make the string t. E.g. if the string \\\"bac\\\" is outputted, then, first, all occurrences of the letter 'b' were deleted, then all occurrences of 'a', and then, finally, all occurrences of 'c'. If there are multiple solutions, print any one....\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\n\\npublic class _739 {\\n public static void main(String[] args) {\\n MyScanner sc = new MyScanner();\\n PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));\\n int t = sc.nextInt();\\n while (t-- > 0) {\\n String s = sc.next();\\n int n = s.length();\\n ArrayList order = new ArrayList<>();\\n Set set = new HashSet<>();\\n for (int i = n - 1; i >= 0; i--) {\\n if (!set.contains(s.charAt(i))) {\\n order.add(s.charAt(i));\\n set.add(s.charAt(i));\\n }\\n }\\n int sz = order.size();\\n Collections.reverse(order);\\n int [] count = new int[sz];\\n for (int i = 0; i < n; i++) {\\n for (int j = 0; j < sz; j++) {\\n if (s.charAt(i) == order.get(j)) {\\n count[j]++;\\n }\\n }\\n }\\n boolean ok = true;\\n for (int i = 0; i < sz; i++) {\\n ok = ok && count[i] % (i + 1) == 0;\\n }\\n if (!ok) {\\n out.println(-1);\\n continue;\\n }\\n for (int i = 0; i < sz; i++) {\\n count[i] \\/= (i + 1);\\n }\\n int [] cur = new int[sz];\\n int good = 0;\\n int end = 0;\\n for (int i = 0; i < n; i++) {\\n for (int j = 0; j < sz; j++) {\\n if (s.charAt(i) == order.get(j)) {\\n cur[j]++;\\n if (cur[j] == count[j]) good++;\\n }\\n }\\n if (good == sz) {\\n end = i;\\n break;\\n }\\n }\\n ok = true;\\n for (int i = 0; i < sz; i++) {\\n ok = ok && cur[i] == count[i];\\n }\\n if (!ok) {\\n out.println(-1);\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"DZY has a hash table with p buckets, numbered from 0 to p - 1. He wants to insert n numbers, in the order they are given, into the hash table. For the i-th number xi, DZY will put it into the bucket numbered h(xi), where h(x) is the hash function. In this problem we will assume, that h(x) = x mod p. Operation a mod b denotes taking a remainder after division a by b.\\n\\nHowever, each bucket can contain no more than one element. If DZY wants to insert an number into a bucket which is already filled, we say a \\\"conflict\\\" happens. Suppose the first conflict happens right after the i-th insertion, you should output i. If no conflict happens, just output -1.\\n\\nInput\\n\\nThe first line contains two integers, p and n (2 ≤ p, n ≤ 300). Then n lines follow. The i-th of them contains an integer xi (0 ≤ xi ≤ 109).\\n\\nOutput\\n\\nOutput a single integer — the answer to the problem.\\n\\nExamples\\n\\nInput\\n\\n10 5\\n0\\n21\\n53\\n41\\n53\\n\\n\\nOutput\\n\\n4\\n\\n\\nInput\\n\\n5 5\\n0\\n1\\n2\\n3\\n4\\n\\n\\nOutput\\n\\n-1\\nSolve the task in PYTHON3.\",\"targets\":\"from collections import Counter\\n \\nn, k = map(int, input().split())\\nc = Counter()\\nans = -1\\nfor i in range(1, k+1):\\n x = int(input())\\n c[x % n] += 1\\n \\n if ans == -1 and c[x % n] > 1:\\n ans = i\\n \\nprint(ans)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Lord Omkar would like to have a tree with n nodes (3 ≤ n ≤ 10^5) and has asked his disciples to construct the tree. However, Lord Omkar has created m (1 ≤ m < n) restrictions to ensure that the tree will be as heavenly as possible. \\n\\nA tree with n nodes is an connected undirected graph with n nodes and n-1 edges. Note that for any two nodes, there is exactly one simple path between them, where a simple path is a path between two nodes that does not contain any node more than once.\\n\\nHere is an example of a tree: \\n\\n\\n\\nA restriction consists of 3 pairwise distinct integers, a, b, and c (1 ≤ a,b,c ≤ n). It signifies that node b cannot lie on the simple path between node a and node c. \\n\\nCan you help Lord Omkar and become his most trusted disciple? You will need to find heavenly trees for multiple sets of restrictions. It can be shown that a heavenly tree will always exist for any set of restrictions under the given constraints.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^4). Description of the test cases follows.\\n\\nThe first line of each test case contains two integers, n and m (3 ≤ n ≤ 10^5, 1 ≤ m < n), representing the size of the tree and the number of restrictions.\\n\\nThe i-th of the next m lines contains three integers a_i, b_i, c_i (1 ≤ a_i, b_i, c_i ≤ n, a, b, c are distinct), signifying that node b_i cannot lie on the simple path between nodes a_i and c_i. \\n\\nIt is guaranteed that the sum of n across all test cases will not exceed 10^5.\\n\\nOutput\\n\\nFor each test case, output n-1 lines representing the n-1 edges in the tree. On each line, output two integers u and v (1 ≤ u, v ≤ n, u ≠ v) signifying that there is an edge between nodes u and v. Given edges have to form a tree that satisfies Omkar's restrictions.\\n\\nExample\\n\\nInput\\n\\n\\n2\\n7 4\\n1 2 3\\n3 4 5\\n5 6 7\\n6 5 4\\n5 3\\n1 2 3\\n2 3 4\\n3 4 5\\n\\n\\nOutput\\n\\n\\n1 2\\n1 3\\n3 5\\n3 4\\n2 7\\n7 6\\n5 1\\n1 3\\n3 2\\n2 4\\n\\nNote\\n\\nThe output of the first sample case corresponds to the following tree: \\n\\n For the first restriction,...\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nlong long int MOD = 1e9 + 7;\\nvoid solve() {\\n long long int n, m;\\n cin >> n >> m;\\n long long int a, b, c;\\n set s;\\n for (int i = 0; i < m; i++) {\\n cin >> a >> b >> c;\\n s.insert(b);\\n }\\n long long int pos = -1;\\n for (int i = 1; i <= n; i++) {\\n if (s.find(i) == s.end()) {\\n pos = i;\\n break;\\n }\\n }\\n for (int i = 1; i <= n; i++) {\\n if (i != pos) cout << pos << \\\" \\\" << i << endl;\\n }\\n}\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n int t = 1;\\n cin >> t;\\n while (t--) solve();\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Theofanis has a riddle for you and if you manage to solve it, he will give you a Cypriot snack halloumi for free (Cypriot cheese).\\n\\nYou are given an integer n. You need to find two integers l and r such that -10^{18} ≤ l < r ≤ 10^{18} and l + (l + 1) + … + (r - 1) + r = n.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases.\\n\\nThe first and only line of each test case contains a single integer n (1 ≤ n ≤ 10^{18}).\\n\\nOutput\\n\\nFor each test case, print the two integers l and r such that -10^{18} ≤ l < r ≤ 10^{18} and l + (l + 1) + … + (r - 1) + r = n. \\n\\nIt can be proven that an answer always exists. If there are multiple answers, print any.\\n\\nExample\\n\\nInput\\n\\n\\n7\\n1\\n2\\n3\\n6\\n100\\n25\\n3000000000000\\n\\n\\nOutput\\n\\n\\n0 1\\n-1 2 \\n1 2 \\n1 3 \\n18 22\\n-2 7\\n999999999999 1000000000001\\n\\nNote\\n\\nIn the first test case, 0 + 1 = 1.\\n\\nIn the second test case, (-1) + 0 + 1 + 2 = 2.\\n\\nIn the fourth test case, 1 + 2 + 3 = 6.\\n\\nIn the fifth test case, 18 + 19 + 20 + 21 + 22 = 100.\\n\\nIn the sixth test case, (-2) + (-1) + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 = 25.\\nUsing java can you solve the prior task?\",\"targets\":\"import java.sql.Date;\\nimport java.text.SimpleDateFormat;\\nimport java.util.Arrays;\\nimport java.util.Random;\\nimport java.util.Scanner;\\nimport java.util.Set;\\n\\npublic class bubble_sort {\\n static Scanner sc = new Scanner(System.in);\\n\\n public static void main(String[] args) {\\n\\n int t = sc.nextInt();\\n while (t > 0) {\\n long n = sc.nextLong();\\n\\n System.out.println((0 - n + 1) + \\\" \\\" + n);\\n\\n t--;\\n }\\n }\\n\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"For an array c of nonnegative integers, MEX(c) denotes the smallest nonnegative integer that doesn't appear in it. For example, MEX([0, 1, 3]) = 2, MEX([42]) = 0.\\n\\nYou are given integers n, k, and an array [b_1, b_2, …, b_n].\\n\\nFind the number of arrays [a_1, a_2, …, a_n], for which the following conditions hold:\\n\\n * 0 ≤ a_i ≤ n for each i for each i from 1 to n.\\n\\n * |MEX([a_1, a_2, …, a_i]) - b_i| ≤ k for each i from 1 to n.\\n\\n\\n\\n\\nAs this number can be very big, output it modulo 998 244 353.\\n\\nInput\\n\\nThe first line of the input contains two integers n, k (1 ≤ n ≤ 2000, 0 ≤ k ≤ 50).\\n\\nThe second line of the input contains n integers b_1, b_2, …, b_n (-k ≤ b_i ≤ n+k) — elements of the array b.\\n\\nOutput\\n\\nOutput a single integer — the number of arrays which satisfy the conditions from the statement, modulo 998 244 353.\\n\\nExamples\\n\\nInput\\n\\n\\n4 0\\n0 0 0 0\\n\\n\\nOutput\\n\\n\\n256\\n\\n\\nInput\\n\\n\\n4 1\\n0 0 0 0\\n\\n\\nOutput\\n\\n\\n431\\n\\n\\nInput\\n\\n\\n4 1\\n0 0 1 1\\n\\n\\nOutput\\n\\n\\n509\\n\\n\\nInput\\n\\n\\n5 2\\n0 0 2 2 0\\n\\n\\nOutput\\n\\n\\n6546\\n\\n\\nInput\\n\\n\\n3 2\\n-2 0 4\\n\\n\\nOutput\\n\\n\\n11\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nconst int mod = 998244353;\\ninline int addmod(int x) { return x >= mod ? x - mod : x; }\\nint n, m, b[100005], f[2][2005][2005], c[2005][2005], pn = 2e3;\\ninline void upd(int &x, int y) { x = addmod(x + y); }\\nint main() {\\n for (int i = 0; i <= pn; i++) c[i][0] = 1;\\n for (int i = 1; i <= pn; i++)\\n for (int j = 1; j <= pn; j++)\\n c[i][j] = addmod(c[i - 1][j - 1] + c[i - 1][j]);\\n scanf(\\\"%d%d\\\", &n, &m);\\n for (int i = 1; i <= n; i++) scanf(\\\"%d\\\", &b[i]);\\n f[0][0][0] = 1;\\n int L = 0;\\n for (int i = 0; i < n; i++) {\\n int nw = i % 2;\\n for (int j = 0; j <= n; j++)\\n if (min(min(L - 1, b[i] - m), b[i + 1] - m) <= j && j <= b[i + 1] + m)\\n for (int k = 0; k <= i + 1; k++) f[nw ^ 1][j][k] = 0;\\n for (int j = 0; j <= n; j++)\\n if (b[i] - m <= j && j <= b[i] + m)\\n for (int k = 0; k <= i + 1; k++) upd(f[nw ^ 1][j + 1][k], f[nw][j][k]);\\n for (int j = 0; j <= n; j++)\\n if (L <= j + 1 && j + 1 <= b[i + 1] + m)\\n for (int k = 1; k <= i + 1; k++)\\n upd(f[nw ^ 1][j + 1][k - 1], f[nw ^ 1][j][k]);\\n for (int j = 0; j <= n; j++)\\n if (b[i] - m <= j && j <= b[i] + m)\\n for (int k = 0; k <= i + 1; k++) {\\n upd(f[nw ^ 1][j][k], 1ll * (k + j) * f[nw][j][k] % mod);\\n upd(f[nw ^ 1][j][k + 1], 1ll * (k + 1) * f[nw][j][k] % mod);\\n }\\n L = max(L, b[i] - m);\\n }\\n int ans = 0;\\n for (int i = 0; i <= n; i++)\\n if (b[n] - m <= i && i <= b[n] + m)\\n for (int j = 0; j <= n; j++)\\n upd(ans, 1ll * f[n % 2][i][j] * c[n - i][j] % mod);\\n printf(\\\"%d\\\\n\\\", ans);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nMr. Chanek has a new game called Dropping Balls. Initially, Mr. Chanek has a grid a of size n × m\\n\\nEach cell (x,y) contains an integer a_{x,y} denoting the direction of how the ball will move.\\n\\n * a_{x,y}=1 — the ball will move to the right (the next cell is (x, y + 1)); \\n * a_{x,y}=2 — the ball will move to the bottom (the next cell is (x + 1, y)); \\n * a_{x,y}=3 — the ball will move to the left (the next cell is (x, y - 1)). \\n\\n\\n\\nEvery time a ball leaves a cell (x,y), the integer a_{x,y} will change to 2. Mr. Chanek will drop k balls sequentially, each starting from the first row, and on the c_1, c_2, ..., c_k-th (1 ≤ c_i ≤ m) columns.\\n\\nDetermine in which column each ball will end up in (position of the ball after leaving the grid).\\n\\nInput\\n\\nThe first line contains three integers n, m, and k (1 ≤ n, m ≤ 1000, 1 ≤ k ≤ 10^5) — the size of the grid and the number of balls dropped by Mr. Chanek.\\n\\nThe i-th of the next n lines contains m integers a_{i,1},a_{i,2},…,a_{i,m} (1 ≤ a_{i,j} ≤ 3). It will satisfy a_{i, 1} ≠ 3 and a_{i, m} ≠ 1.\\n\\nThe next line contains k integers c_1, c_2, …, c_k (1 ≤ c_i ≤ m) — the balls' column positions dropped by Mr. Chanek sequentially.\\n\\nOutput\\n\\nOutput k integers — the i-th integer denoting the column where the i-th ball will end.\\n\\nExamples\\n\\nInput\\n\\n\\n5 5 3\\n1 2 3 3 3\\n2 2 2 2 2\\n2 2 2 2 2\\n2 2 2 2 2\\n2 2 2 2 2\\n1 2 1\\n\\n\\nOutput\\n\\n\\n2 2 1 \\n\\n\\nInput\\n\\n\\n1 2 2\\n1 3\\n1 2\\n\\n\\nOutput\\n\\n\\n1 2 \\n\\nNote\\n\\nIn the first example, the first ball will drop as follows. Note that the cell (1, 1) will change direction to the bottom direction.\\n\\n\\n\\nThe second and third balls will drop as follows. \\n\\n\\n\\nAll balls will be dropped from the first row and on the c_1, c_2, ..., c_k-th columns respectively. A ball will stop dropping once it leaves the grid.\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n int n;\\n int m;\\n int k;\\n cin >> n >> m >> k;\\n int a[n][m];\\n int i, j, l, p;\\n for (i = 0; i < n; i++) {\\n for (j = 0; j < m; j++) {\\n cin >> a[i][j];\\n }\\n }\\n int b[k];\\n for (i = 0; i < k; i++) cin >> b[i];\\n for (int u = 0; u < k; u++) {\\n int row = 0;\\n int col = b[u] - 1;\\n while (row < n) {\\n p = a[row][col];\\n a[row][col] = 2;\\n if (p == 1) {\\n col += 1;\\n } else if (p == 2) {\\n row += 1;\\n } else if (p == 3) {\\n col -= 1;\\n }\\n }\\n cout << col + 1 << \\\" \\\";\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A binary string is a string that consists of characters 0 and 1.\\n\\nLet \\\\operatorname{MEX} of a binary string be the smallest digit among 0, 1, or 2 that does not occur in the string. For example, \\\\operatorname{MEX} of 001011 is 2, because 0 and 1 occur in the string at least once, \\\\operatorname{MEX} of 1111 is 0, because 0 and 2 do not occur in the string and 0 < 2.\\n\\nA binary string s is given. You should cut it into any number of substrings such that each character is in exactly one substring. It is possible to cut the string into a single substring — the whole string.\\n\\nA string a is a substring of a string b if a can be obtained from b by deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end.\\n\\nWhat is the minimal sum of \\\\operatorname{MEX} of all substrings pieces can be?\\n\\nInput\\n\\nThe input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. Description of the test cases follows.\\n\\nEach test case contains a single binary string s (1 ≤ |s| ≤ 10^5).\\n\\nIt's guaranteed that the sum of lengths of s over all test cases does not exceed 10^5.\\n\\nOutput\\n\\nFor each test case print a single integer — the minimal sum of \\\\operatorname{MEX} of all substrings that it is possible to get by cutting s optimally.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n01\\n1111\\n01100\\n101\\n0000\\n01010\\n\\n\\nOutput\\n\\n\\n1\\n0\\n2\\n1\\n1\\n2\\n\\nNote\\n\\nIn the first test case the minimal sum is \\\\operatorname{MEX}(0) + \\\\operatorname{MEX}(1) = 1 + 0 = 1.\\n\\nIn the second test case the minimal sum is \\\\operatorname{MEX}(1111) = 0.\\n\\nIn the third test case the minimal sum is \\\\operatorname{MEX}(01100) = 2.\\nSolve the task in JAVA.\",\"targets\":\"import java.io.*;\\nimport java.text.DecimalFormat;\\nimport java.util.*;\\n\\n\\npublic class Main {\\n\\n public static void main(String[] args) throws IOException {\\n Reader.init(System.in);\\n BufferedWriter output = new BufferedWriter(new OutputStreamWriter(System.out));\\n int t = Reader.nextInt();\\n while ( t > 0) {\\n char string[] = Reader.next().toCharArray();\\n int i = 0;\\n boolean allZero = true;\\n boolean allOne = true;\\n if ( string[0] == '0'){\\n allZero = true;\\n allOne = false;\\n }\\n else{\\n allOne = true;\\n allZero = false;\\n }\\n i = 1;\\n int b =0 ;\\n while ( i < string.length){\\n if ( string[i] != string[i-1]){\\n b++;\\n }\\n i++;\\n }\\n if ( b == 0){\\n if (allOne){\\n System.out.println(0);\\n }\\n else{\\n System.out.println(1);\\n }\\n }\\n else if ( b== 1){\\n System.out.println(1);\\n }\\n else{\\n int ans =2;\\n if ( allOne){\\n if ( b == 2){\\n ans = 1;\\n }\\n \\n }\\n System.out.println(ans);\\n }\\n t--;\\n }\\n\\n\\n }\\n\\n private static boolean calculate(int l,int r,int[] a,int b[]){\\n int countA = 0;\\n int countB = 0;\\n if ( l == 0){\\n countA = a[r];\\n countB = b[r];\\n }\\n else{\\n countA = a[r] - a[l-1];\\n countB = b[r] - b[l-1];\\n }\\n if ( countA == countB){\\n return true;\\n }\\n else{\\n return false;\\n }\\n }\\n\\n\\n\\n private static long calculate(ArrayList array,int n){\\n int i = 1;\\n long count = 0;\\n while ( i <= n){\\n if ( (i&1) == 1){\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"'Twas the night before Christmas, and Santa's frantically setting up his new Christmas tree! There are n nodes in the tree, connected by n-1 edges. On each edge of the tree, there's a set of Christmas lights, which can be represented by an integer in binary representation.\\n\\n\\n\\nHe has m elves come over and admire his tree. Each elf is assigned two nodes, a and b, and that elf looks at all lights on the simple path between the two nodes. After this, the elf's favorite number becomes the [bitwise XOR](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#XOR) of the values of the lights on the edges in that path.\\n\\nHowever, the North Pole has been recovering from a nasty bout of flu. Because of this, Santa forgot some of the configurations of lights he had put on the tree, and he has already left the North Pole! Fortunately, the elves came to the rescue, and each one told Santa what pair of nodes he was assigned (a_i, b_i), as well as the parity of the number of set bits in his favorite number. In other words, he remembers whether the number of 1's when his favorite number is written in binary is odd or even.\\n\\nHelp Santa determine if it's possible that the memories are consistent, and if it is, remember what his tree looked like, and maybe you'll go down in history!\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 2 ⋅ 10^4) — the number of test cases. Then t cases follow.\\n\\nThe first line of each test case contains two integers, n and m (2 ≤ n ≤ 2 ⋅ 10^5; 1 ≤ m ≤ 2 ⋅ 10^5) — the size of tree and the number of elves respectively.\\n\\nThe next n-1 lines of each test case each contains three integers, x, y, and v (1 ≤ x, y ≤ n; -1 ≤ v < 2^{30}) — meaning that there's an edge between nodes x and y. If \\n\\n * v = -1: Santa doesn't remember what the set of lights were on for this edge. \\n * v ≥ 0: The set of lights on the edge is v. \\n\\n\\n\\nThe next m lines of each test case each contains three integers, a, b, and p (1 ≤ a, b ≤ n; a ≠ b; 0 ≤ p ≤ 1) — the nodes that the elf was assigned to, and the parity of the number of...\\\":\",\"targets\":\"#include \\n#pragma GCC optimize(\\\"Ofast\\\")\\n#pragma GCC target(\\\"avx,avx2,fma\\\")\\nusing namespace std;\\nconst int MAX = 2e5 + 10;\\nconst long long MOD = 1e9 + 7;\\nconst int INF = 0x3f3f3f3f;\\nconst long long LLINF = 0x3f3f3f3f3f3f3f3f;\\nconst long double EPS = 1e-8;\\nconst long double PI = acos(-1);\\nvector > > g;\\nvector visto, color;\\nbool dfs(int u, int c = 0) {\\n bool ans = true;\\n if (visto[u]) return (color[u] == c);\\n visto[u] = true;\\n color[u] = c;\\n for (auto [v, w] : g[u]) {\\n ans &= dfs(v, (w ? !c : c));\\n }\\n return ans;\\n}\\nint32_t main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n ;\\n int t;\\n cin >> t;\\n while (t--) {\\n int n, m, a, b, p;\\n cin >> n >> m;\\n g.assign(n + 1, vector >());\\n visto.assign(n + 1, false);\\n color.assign(n + 1, false);\\n vector > ans(n - 1), choose;\\n vector > equal, diff;\\n for (int i = 0; i < n - 1; i++) {\\n cin >> a >> b >> p;\\n if (p == -1)\\n choose.push_back({a, b, i});\\n else if (__builtin_popcount(p) % 2 == 0) {\\n g[b].push_back({a, 0});\\n g[a].push_back({b, 0});\\n ans[i] = {a, b, p};\\n } else {\\n g[b].push_back({a, 1});\\n g[a].push_back({b, 1});\\n ans[i] = {a, b, p};\\n }\\n }\\n for (int i = 0; i < m; i++) {\\n cin >> a >> b >> p;\\n if (p == 0) {\\n g[b].push_back({a, 0});\\n g[a].push_back({b, 0});\\n } else {\\n g[b].push_back({a, 1});\\n g[a].push_back({b, 1});\\n }\\n }\\n bool pos = true;\\n for (int i = 1; i <= n; i++) {\\n if (!visto[i]) pos &= dfs(i);\\n }\\n if (!pos) {\\n cout << \\\"NO\\\\n\\\";\\n continue;\\n }\\n for (auto [a, b, id] : choose) {\\n bool eq = color[a] == color[b];\\n if (eq)\\n ans[id] = {a, b, 0};\\n else\\n ans[id] = {a, b, 1};\\n }\\n cout << \\\"YES\\\\n\\\";\\n for (auto [a, b, p] : ans) cout << a << \\\" \\\" << b << \\\" \\\" << p << '\\\\n';\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nMethodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exactly one symbol).\\n\\nFor example, as a result of typing the word \\\"hello\\\", the following words could be printed: \\\"hello\\\", \\\"hhhhello\\\", \\\"hheeeellllooo\\\", but the following could not be printed: \\\"hell\\\", \\\"helo\\\", \\\"hhllllooo\\\".\\n\\nNote, that when you press a key, the corresponding symbol must appear (possibly, more than once). The keyboard is broken in a random manner, it means that pressing the same key you can get the different number of letters in the result.\\n\\nFor each word in the letter, Methodius has guessed what word Polycarp actually wanted to write, but he is not sure about it, so he asks you to help him.\\n\\nYou are given a list of pairs of words. For each pair, determine if the second word could be printed by typing the first one on Polycarp's keyboard.\\n\\nInput\\n\\nThe first line of the input contains one integer n (1 ≤ n ≤ 10^5) — the number of pairs to check. Further input contains n descriptions of pairs.\\n\\nThe first line of each description contains a single non-empty word s consisting of lowercase Latin letters. The second line of the description contains a single non-empty word t consisting of lowercase Latin letters. The lengths of both strings are not greater than 10^6.\\n\\nIt is guaranteed that the total length of all words s in the input is not greater than 10^6. Also, it is guaranteed that the total length of all words t in the input is not greater than 10^6.\\n\\nOutput\\n\\nOutput n lines. In the i-th line for the i-th pair of words s and t print YES if the word t could be printed by typing the word s. Otherwise, print NO.\\n\\nExamples\\n\\nInput\\n\\n\\n4\\nhello\\nhello\\nhello\\nhelloo\\nhello\\nhlllloo\\nhello\\nhelo\\n\\n\\nOutput\\n\\n\\nYES\\nYES\\nNO\\nNO\\n\\n\\nInput\\n\\n\\n5\\naa\\nbb\\ncodeforces\\ncodeforce\\npolycarp\\npoolycarpp\\naaaa\\naaaab\\nabcdefghijklmnopqrstuvwxyz\\nzabcdefghijklmnopqrstuvwxyz\\n\\n\\nOutput\\n\\n\\nNO\\nNO\\nYES\\nNO\\nNO\",\"targets\":\"#include \\nusing namespace std;\\nlong double const pi = 3.141592653589793238462;\\nlong long int const mod = 1e9 + 7;\\nlong long int power(long long int a, long long int b) {\\n long long int f = 1;\\n while (b > 0) {\\n if (b & 1) {\\n f = f * a;\\n }\\n a = a * a;\\n b = b \\/ 2;\\n }\\n return f;\\n}\\nbool rev(long long int a, long long int b) { return a >= b; }\\nlong long int const N = 3e5 + 5;\\nint32_t main() {\\n std::ios::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n ;\\n long long int t;\\n cin >> t;\\n while (t--) {\\n string a, b;\\n cin >> a >> b;\\n long long int ans = 1;\\n long long int i, j, l;\\n if (b.size() < a.size()) {\\n cout << \\\"NO\\\" << endl;\\n continue;\\n }\\n j = 0;\\n for (i = 0; i < a.size(); i++) {\\n for (l = i + 1; l < a.size(); l++) {\\n if (a[l] != a[i]) break;\\n }\\n long long int ca = l - i;\\n i = l - 1;\\n for (l = j; l < b.size(); l++) {\\n if (b[l] != a[i]) break;\\n }\\n long long int cb = l - j;\\n if (ca > cb) {\\n ans = 0;\\n break;\\n }\\n j = l;\\n }\\n if (j < b.size()) ans = 0;\\n if (ans)\\n cout << \\\"YES\\\" << endl;\\n else\\n cout << \\\"NO\\\" << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Calendars in widespread use today include the Gregorian calendar, which is the de facto international standard, and is used almost everywhere in the world for civil purposes. The Gregorian reform modified the Julian calendar's scheme of leap years as follows:\\n\\nEvery year that is exactly divisible by four is a leap year, except for years that are exactly divisible by 100; the centurial years that are exactly divisible by 400 are still leap years. For example, the year 1900 is not a leap year; the year 2000 is a leap year. \\n\\n\\n\\nIn this problem, you have been given two dates and your task is to calculate how many days are between them. Note, that leap years have unusual number of days in February.\\n\\nLook at the sample to understand what borders are included in the aswer.\\n\\nInput\\n\\nThe first two lines contain two dates, each date is in the format yyyy:mm:dd (1900 ≤ yyyy ≤ 2038 and yyyy:mm:dd is a legal date).\\n\\nOutput\\n\\nPrint a single integer — the answer to the problem.\\n\\nExamples\\n\\nInput\\n\\n1900:01:01\\n2038:12:31\\n\\n\\nOutput\\n\\n50768\\n\\n\\nInput\\n\\n1996:03:09\\n1991:11:12\\n\\n\\nOutput\\n\\n1579\",\"targets\":\"#include \\nconst int days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};\\nint y, m, d, v1, v2;\\nbool is_leap(int y) {\\n if (y % 400 == 0) return true;\\n if (y % 100 == 0) return false;\\n if (y % 4 == 0) return true;\\n return false;\\n}\\nint calc(int y, int m, int d) {\\n int res = 0;\\n for (int i = 1900; i < y; i++) res += is_leap(i) ? 366 : 365;\\n for (int i = 1; i < m; i++) {\\n res += days[i];\\n if (i == 2 && is_leap(y)) res++;\\n }\\n return res + d;\\n}\\nint main() {\\n scanf(\\\"%d:%d:%d\\\", &y, &m, &d);\\n v1 = calc(y, m, d);\\n scanf(\\\"%d:%d:%d\\\", &y, &m, &d);\\n v2 = calc(y, m, d);\\n printf(\\\"%d\\\\n\\\", labs(v1 - v2));\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Let's call the string beautiful if it does not contain a substring of length at least 2, which is a palindrome. Recall that a palindrome is a string that reads the same way from the first character to the last and from the last character to the first. For example, the strings a, bab, acca, bcabcbacb are palindromes, but the strings ab, abbbaa, cccb are not.\\n\\nLet's define cost of a string as the minimum number of operations so that the string becomes beautiful, if in one operation it is allowed to change any character of the string to one of the first 3 letters of the Latin alphabet (in lowercase).\\n\\nYou are given a string s of length n, each character of the string is one of the first 3 letters of the Latin alphabet (in lowercase).\\n\\nYou have to answer m queries — calculate the cost of the substring of the string s from l_i-th to r_i-th position, inclusive.\\n\\nInput\\n\\nThe first line contains two integers n and m (1 ≤ n, m ≤ 2 ⋅ 10^5) — the length of the string s and the number of queries.\\n\\nThe second line contains the string s, it consists of n characters, each character one of the first 3 Latin letters.\\n\\nThe following m lines contain two integers l_i and r_i (1 ≤ l_i ≤ r_i ≤ n) — parameters of the i-th query.\\n\\nOutput\\n\\nFor each query, print a single integer — the cost of the substring of the string s from l_i-th to r_i-th position, inclusive.\\n\\nExample\\n\\nInput\\n\\n\\n5 4\\nbaacb\\n1 3\\n1 5\\n4 5\\n2 3\\n\\n\\nOutput\\n\\n\\n1\\n2\\n0\\n1\\n\\nNote\\n\\nConsider the queries of the example test.\\n\\n * in the first query, the substring is baa, which can be changed to bac in one operation; \\n * in the second query, the substring is baacb, which can be changed to cbacb in two operations; \\n * in the third query, the substring is cb, which can be left unchanged; \\n * in the fourth query, the substring is aa, which can be changed to ba in one operation. \\nUsing java can you solve the prior task?\",\"targets\":\"import java.io.BufferedReader; \\nimport java.io.IOException; \\nimport java.io.InputStreamReader; \\nimport java.util.Scanner; \\nimport java.util.StringTokenizer;\\nimport java.util.*;\\npublic class codeforcesA{\\n static class FastReader \\n { \\n BufferedReader br; \\n StringTokenizer st; \\n \\n public FastReader() \\n { \\n br = new BufferedReader(new\\n InputStreamReader(System.in)); \\n } \\n \\n String next() \\n { \\n while (st == null || !st.hasMoreElements()) \\n { \\n try\\n { \\n st = new StringTokenizer(br.readLine()); \\n } \\n catch (IOException e) \\n { \\n e.printStackTrace(); \\n } \\n } \\n return st.nextToken(); \\n } \\n \\n int nextInt() \\n { \\n return Integer.parseInt(next()); \\n } \\n \\n long nextLong() \\n { \\n return Long.parseLong(next()); \\n } \\n \\n double nextDouble() \\n { \\n return Double.parseDouble(next()); \\n } \\n \\n String nextLine() \\n { \\n String str = \\\"\\\"; \\n try\\n { \\n str = br.readLine(); \\n } \\n catch (IOException e) \\n { \\n e.printStackTrace(); \\n } \\n return str; \\n } \\n } \\n public static void main(String args[]){\\n FastReader sc=new FastReader();\\n int n=sc.nextInt();\\n int m=sc.nextInt();\\n String s=sc.nextLine();\\n int ar1[]=new int[n+1];\\/\\/abc \\n int ar2[]=new int[n+1];\\/\\/bca\\n int ar3[]=new int[n+1];\\/\\/cab\\n int ar4[]=new int[n+1];\\/\\/acb\\n int ar5[]=new int[n+1];\\/\\/cba\\n int ar6[]=new int[n+1];\\/\\/bac\\n for(int i=0;ia:\\n more[a]+=1\\n less[b]+=1\\n else:\\n less[a]+=1\\n more[b]+=1\\n\\nalive=(n+1)*[1]\\nfor i in range(1,n+1):\\n if more[i]:\\n alive[i]=0\\n\\ncurr = -1\\nfor i in alive:\\n curr+=i\\n\\nfor _ in range(rn()):\\n query=rl()\\n if query[0]==1:\\n a,b=sorted(query[1:])\\n more[a]+=1\\n less[b]+=1\\n if alive[a]:\\n alive[a] = 0\\n curr -= 1\\n elif query[0]==2:\\n a, b = sorted(query[1:])\\n more[a] -= 1\\n less[b] -= 1\\n if alive[a]==0 and more[a]==0:\\n alive[a]=1\\n curr+=1\\n else:\\n print(curr)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nHurricane came to Berland and to suburbs Stringsvill. You are going to it to check if it's all right with you favorite string. Hurrinace broke it a bit by reversing some of its non-intersecting substrings. You have a photo of this string before hurricane and you want to restore it to original state using reversing minimum possible number of its substrings and find out which substrings you should reverse.\\n\\nYou are given a string s — original state of your string and string t — state of the string after hurricane. You should select k non-intersecting substrings of t in such a way that after reverse of these substrings string will be equal s and k is minimum possible.\\n\\nInput\\n\\nFirst line of input contains string s and second line contains string t. Both strings have same length and consist of lowercase English letters. 1 ≤ |s| = |t| ≤ 5·105\\n\\nOutput\\n\\nIn first line print k — minimum number of substrings you should reverse. Next output k lines. Each line should contain two integers li, ri meaning that you should reverse substring from symbol number li to symbol ri (strings are 1-indexed). These substrings shouldn't intersect. If there are multiple answers print any. If it's impossible to restore string output -1.\\n\\nExample\\n\\nInput\\n\\nabcxxxdef\\ncbaxxxfed\\n\\n\\nOutput\\n\\n2\\n7 9\\n1 3\",\"targets\":\"#include \\nusing namespace std;\\nconst int NN = 1000100;\\nint link[NN], fail[NN], len[NN], dif[NN], nxt[NN][26];\\nint ed, sz, cur;\\nchar s[NN], S[NN], T[NN];\\nint tp[NN], dp[NN], pre[NN], pr[NN];\\nvoid clear(int u, int L = 0) { len[u] = L; }\\nvoid init() {\\n sz = 2;\\n ed = 1;\\n cur = 0;\\n s[cur] = -1;\\n clear(0);\\n clear(1, -1);\\n fail[0] = 1;\\n}\\ninline int get_fail(int u) {\\n while (s[cur - len[u] - 1] != s[cur]) u = fail[u];\\n return u;\\n}\\nint insert(char c) {\\n s[++cur] = c -= 'a';\\n ed = get_fail(ed);\\n if (!nxt[ed][c]) {\\n int p1 = sz++;\\n clear(p1, len[ed] + 2);\\n fail[p1] = nxt[get_fail(fail[ed])][c];\\n nxt[ed][c] = p1;\\n dif[p1] = len[p1] - len[fail[p1]];\\n if (dif[p1] == dif[fail[p1]])\\n link[p1] = link[fail[p1]];\\n else\\n link[p1] = fail[p1];\\n }\\n ed = nxt[ed][c];\\n return ed;\\n}\\nint main() {\\n scanf(\\\"%s%s\\\", S, T);\\n int n = strlen(S);\\n init();\\n memset(tp, 0x3f, sizeof tp);\\n for (int i = 1, now; i <= n * 2; i++) {\\n if (i & 1)\\n now = insert(S[i - 1 >> 1]);\\n else\\n now = insert(T[i - 1 >> 1]);\\n dp[i] = 0x3f3f3f3f;\\n if ((~i & 1) && S[i - 1 >> 1] == T[i - 1 >> 1]) {\\n dp[i] = dp[i - 2];\\n pre[i] = i - 2;\\n }\\n for (int u = now; u; u = link[u]) {\\n pr[u] = i - len[link[u]] - dif[u];\\n tp[u] = dp[pr[u]];\\n if (link[u] ^ fail[u]) {\\n if (tp[u] > tp[fail[u]]) {\\n tp[u] = tp[fail[u]];\\n pr[u] = pr[fail[u]];\\n }\\n }\\n if (~i & 1) {\\n if (dp[i] > tp[u] + 1) {\\n dp[i] = tp[u] + 1;\\n pre[i] = pr[u];\\n }\\n }\\n }\\n }\\n if (dp[n * 2] == 0x3f3f3f3f) return puts(\\\"-1\\\");\\n vector> ans;\\n int now = n * 2;\\n while (now) {\\n int pre = ::pre[now];\\n if (now - pre > 2) ans.emplace_back((pre >> 1) + 1, now >> 1);\\n now = pre;\\n }\\n cout << ans.size() << endl;\\n for (auto &a : ans) printf(\\\"%d %d\\\\n\\\", a.first, a.second);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A group of university students wants to get to the top of a mountain to have a picnic there. For that they decided to use a cableway.\\n\\nA cableway is represented by some cablecars, hanged onto some cable stations by a cable. A cable is scrolled cyclically between the first and the last cable stations (the first of them is located at the bottom of the mountain and the last one is located at the top). As the cable moves, the cablecar attached to it move as well.\\n\\nThe number of cablecars is divisible by three and they are painted three colors: red, green and blue, in such manner that after each red cablecar goes a green one, after each green cablecar goes a blue one and after each blue cablecar goes a red one. Each cablecar can transport no more than two people, the cablecars arrive with the periodicity of one minute (i. e. every minute) and it takes exactly 30 minutes for a cablecar to get to the top.\\n\\nAll students are divided into three groups: r of them like to ascend only in the red cablecars, g of them prefer only the green ones and b of them prefer only the blue ones. A student never gets on a cablecar painted a color that he doesn't like,\\n\\nThe first cablecar to arrive (at the moment of time 0) is painted red. Determine the least time it will take all students to ascend to the mountain top.\\n\\nInput\\n\\nThe first line contains three integers r, g and b (0 ≤ r, g, b ≤ 100). It is guaranteed that r + g + b > 0, it means that the group consists of at least one student. \\n\\nOutput\\n\\nPrint a single number — the minimal time the students need for the whole group to ascend to the top of the mountain.\\n\\nExamples\\n\\nInput\\n\\n1 3 2\\n\\n\\nOutput\\n\\n34\\n\\nInput\\n\\n3 2 1\\n\\n\\nOutput\\n\\n33\\n\\nNote\\n\\nLet's analyze the first sample.\\n\\nAt the moment of time 0 a red cablecar comes and one student from the r group get on it and ascends to the top at the moment of time 30.\\n\\nAt the moment of time 1 a green cablecar arrives and two students from the g group get on it; they get to the top at the moment of time 31.\\n\\nAt the moment of time 2 comes the blue...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int r, g, b, t;\\n cin >> r >> g >> b;\\n for (t = 0; g > 0 || r > 0 || b > 0; t++) {\\n if (t % 3 == 0) {\\n r = max(0, r - 2);\\n } else if (t % 3 == 1) {\\n g = max(0, g - 2);\\n } else {\\n b = max(0, b - 2);\\n }\\n }\\n cout << t + 30 - 1 << endl;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"An identity permutation of length n is an array [1, 2, 3, ..., n].\\n\\nWe performed the following operations to an identity permutation of length n:\\n\\n * firstly, we cyclically shifted it to the right by k positions, where k is unknown to you (the only thing you know is that 0 ≤ k ≤ n - 1). When an array is cyclically shifted to the right by k positions, the resulting array is formed by taking k last elements of the original array (without changing their relative order), and then appending n - k first elements to the right of them (without changing relative order of the first n - k elements as well). For example, if we cyclically shift the identity permutation of length 6 by 2 positions, we get the array [5, 6, 1, 2, 3, 4]; \\n * secondly, we performed the following operation at most m times: pick any two elements of the array and swap them. \\n\\n\\n\\nYou are given the values of n and m, and the resulting array. Your task is to find all possible values of k in the cyclic shift operation.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10^5) — the number of test cases.\\n\\nEach test case consists of two lines. The first line contains two integers n and m (3 ≤ n ≤ 3 ⋅ 10^5; 0 ≤ m ≤ n\\/3).\\n\\nThe second line contains n integers p_1, p_2, ..., p_n (1 ≤ p_i ≤ n, each integer from 1 to n appears in this sequence exactly once) — the resulting array.\\n\\nThe sum of n over all test cases does not exceed 3 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print the answer in the following way:\\n\\n * firstly, print one integer r (0 ≤ r ≤ n) — the number of possible values of k for the cyclic shift operation; \\n * secondly, print r integers k_1, k_2, ..., k_r (0 ≤ k_i ≤ n - 1) — all possible values of k in increasing order. \\n\\nExample\\n\\nInput\\n\\n\\n4\\n4 1\\n2 3 1 4\\n3 1\\n1 2 3\\n3 1\\n3 2 1\\n6 0\\n1 2 3 4 6 5\\n\\n\\nOutput\\n\\n\\n1 3\\n1 0\\n3 0 1 2\\n0\\n\\nNote\\n\\nConsider the example: \\n\\n * in the first test case, the only possible value for the cyclic shift is 3. If we shift [1, 2, 3, 4] by 3 positions, we get [2, 3, 4, 1]. Then we can swap the 3-rd and the 4-th elements to get the...\\nimpor\",\"targets\":\"t sys\\ninput = sys.stdin.readline\\n\\nclass UnionFind:\\n def __init__(self, n):\\n self.par = [i for i in range(n+1)]\\n self.rank = [0] * (n + 1)\\n self.size = [1] * (n + 1)\\n \\n def find(self, x):\\n if self.par[x] == x:\\n return x\\n else:\\n self.par[x] = self.find(self.par[x])\\n return self.par[x]\\n\\n def unite(self, x, y):\\n x = self.find(x)\\n y = self.find(y)\\n if x == y:\\n return\\n if self.rank[x] < self.rank[y]:\\n self.par[x] = y\\n self.size[y] += self.size[x]\\n else:\\n self.par[y] = x\\n self.size[x] += self.size[y]\\n if self.rank[x] == self.rank[y]:\\n self.rank[x] += 1\\n \\n def same_check(self, x, y):\\n return self.find(x) == self.find(y)\\n\\nt = int(input())\\nfor _ in range(t):\\n n, m = map(int, input().split())\\n p = list(map(int, input().split()))\\n l = [0] * n\\n for i in range(n):\\n l[(i + 1 - p[i]) % n] += 1\\n res = []\\n for i in range(n):\\n if l[i] * 3 >= n:\\n uf = UnionFind(n)\\n for j in range(n):\\n uf.unite((p[j] + i - 1) % n, j)\\n d = [0] * n\\n ans = n\\n for j in range(n):\\n j = uf.find(j)\\n if d[j]:\\n continue\\n d[j] = 1\\n ans -= 1\\n if ans <= m:\\n res.append(i)\\n print(len(res), *res)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Capitalization is writing a word with its first letter as a capital letter. Your task is to capitalize the given word.\\n\\nNote, that during capitalization all the letters except the first one remains unchanged.\\n\\nInput\\n\\nA single line contains a non-empty word. This word consists of lowercase and uppercase English letters. The length of the word will not exceed 103.\\n\\nOutput\\n\\nOutput the given word after capitalization.\\n\\nExamples\\n\\nInput\\n\\nApPLe\\n\\n\\nOutput\\n\\nApPLe\\n\\n\\nInput\\n\\nkonjac\\n\\n\\nOutput\\n\\nKonjac\\nstr=\",\"targets\":\"input()\\nstr1 = str[1:]\\nstr2 = str[0].title()\\nprint(str2+str1)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"The grasshopper is located on the numeric axis at the point with coordinate x_0.\\n\\nHaving nothing else to do he starts jumping between integer points on the axis. Making a jump from a point with coordinate x with a distance d to the left moves the grasshopper to a point with a coordinate x - d, while jumping to the right moves him to a point with a coordinate x + d.\\n\\nThe grasshopper is very fond of positive integers, so for each integer i starting with 1 the following holds: exactly i minutes after the start he makes a jump with a distance of exactly i. So, in the first minutes he jumps by 1, then by 2, and so on.\\n\\nThe direction of a jump is determined as follows: if the point where the grasshopper was before the jump has an even coordinate, the grasshopper jumps to the left, otherwise he jumps to the right.\\n\\nFor example, if after 18 consecutive jumps he arrives at the point with a coordinate 7, he will jump by a distance of 19 to the right, since 7 is an odd number, and will end up at a point 7 + 19 = 26. Since 26 is an even number, the next jump the grasshopper will make to the left by a distance of 20, and it will move him to the point 26 - 20 = 6.\\n\\nFind exactly which point the grasshopper will be at after exactly n jumps.\\n\\nInput\\n\\nThe first line of input contains an integer t (1 ≤ t ≤ 10^4) — the number of test cases.\\n\\nEach of the following t lines contains two integers x_0 (-10^{14} ≤ x_0 ≤ 10^{14}) and n (0 ≤ n ≤ 10^{14}) — the coordinate of the grasshopper's initial position and the number of jumps.\\n\\nOutput\\n\\nPrint exactly t lines. On the i-th line print one integer — the answer to the i-th test case — the coordinate of the point the grasshopper will be at after making n jumps from the point x_0.\\n\\nExample\\n\\nInput\\n\\n\\n9\\n0 1\\n0 2\\n10 10\\n10 99\\n177 13\\n10000000000 987654321\\n-433494437 87178291199\\n1 0\\n-1 1\\n\\n\\nOutput\\n\\n\\n-1\\n1\\n11\\n110\\n190\\n9012345679\\n-87611785637\\n1\\n0\\n\\nNote\\n\\nThe first two test cases in the example correspond to the first two jumps from the point x_0 = 0. \\n\\nSince 0 is an even number, the first jump of length...\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nlong long mod = 1000000007;\\nlong long mod_expo(long long a, long long b, long long mod) {\\n long long res = 1;\\n while (b > 0) {\\n if (b & 1) res = (res * a) % mod;\\n a = (a * a) % mod;\\n b = b >> 1;\\n }\\n return res;\\n}\\nlong long mod_add(long long a, long long b, long long m) {\\n a = a % m;\\n b = b % m;\\n return (((a + b) % m) + m) % m;\\n}\\nlong long mod_mul(long long a, long long b, long long m) {\\n a = a % m;\\n b = b % m;\\n return (((a * b) % m) + m) % m;\\n}\\nlong long mod_sub(long long a, long long b, long long m) {\\n a = a % m;\\n b = b % m;\\n return (((a - b) % m) + m) % m;\\n}\\nvoid solve() {\\n long long x, n;\\n cin >> x >> n;\\n if ((n % 4) == 0) {\\n cout << x << \\\"\\\\n\\\";\\n } else {\\n long long val = n;\\n long long m = (n % 4);\\n if (x & 1) {\\n if (m == 1)\\n x += val;\\n else if (m == 2)\\n x--;\\n else if (m == 3)\\n x -= (1 + n);\\n } else {\\n if (m == 1)\\n x -= val;\\n else if (m == 2)\\n x++;\\n else if (m == 3)\\n x += 1 + n;\\n }\\n cout << x << \\\"\\\\n\\\";\\n }\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n int t;\\n cin >> t;\\n while (t-- > 0) {\\n solve();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A binary tree of n nodes is given. Nodes of the tree are numbered from 1 to n and the root is the node 1. Each node can have no child, only one left child, only one right child, or both children. For convenience, let's denote l_u and r_u as the left and the right child of the node u respectively, l_u = 0 if u does not have the left child, and r_u = 0 if the node u does not have the right child.\\n\\nEach node has a string label, initially is a single character c_u. Let's define the string representation of the binary tree as the concatenation of the labels of the nodes in the in-order. Formally, let f(u) be the string representation of the tree rooted at the node u. f(u) is defined as follows: $$$ f(u) = \\\\begin{cases} , & if u = 0; \\\\\\\\\\\\ f(l_u) + c_u + f(r_u) & otherwise, \\\\end{cases} where +$$$ denotes the string concatenation operation.\\n\\nThis way, the string representation of the tree is f(1).\\n\\nFor each node, we can duplicate its label at most once, that is, assign c_u with c_u + c_u, but only if u is the root of the tree, or if its parent also has its label duplicated.\\n\\nYou are given the tree and an integer k. What is the lexicographically smallest string representation of the tree, if we can duplicate labels of at most k nodes?\\n\\nA string a is lexicographically smaller than a string b if and only if one of the following holds: \\n\\n * a is a prefix of b, but a ≠ b; \\n * in the first position where a and b differ, the string a has a letter that appears earlier in the alphabet than the corresponding letter in b. \\n\\nInput\\n\\nThe first line contains two integers n and k (1 ≤ k ≤ n ≤ 2 ⋅ 10^5).\\n\\nThe second line contains a string c of n lower-case English letters, where c_i is the initial label of the node i for 1 ≤ i ≤ n. Note that the given string c is not the initial string representation of the tree.\\n\\nThe i-th of the next n lines contains two integers l_i and r_i (0 ≤ l_i, r_i ≤ n). If the node i does not have the left child, l_i = 0, and if the node i does not have the right child, r_i = 0.\\n\\nIt is...\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.FileInputStream;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.io.PrintWriter;\\nimport java.util.ArrayList;\\nimport java.util.Arrays;\\nimport java.util.Comparator;\\nimport java.util.HashMap;\\nimport java.util.HashSet;\\nimport java.util.Map;\\nimport java.util.StringTokenizer;\\nimport java.util.TreeMap;\\nimport java.util.TreeSet;\\n\\npublic class Solution {\\n \\/\\/ VM options: -Xmx1024m -Xss1024m\\n\\n\\n private void solve() throws IOException {\\n n = nextInt();\\n k = nextInt();\\n s = nextToken().toCharArray();\\n nx = new int[n][2];\\n ints = new Int[n];\\n for (int i = 0; i < n; i++) {\\n nx[i][0] = nextInt() - 1;\\n nx[i][1] = nextInt() - 1;\\n ints[i] = new Int(i);\\n }\\n doubled = new boolean[n];\\n order = new int[n];\\n orderSize = 0;\\n go(0);\\n lastIdx = new int[n];\\n for (int last = n - 1, i = n - 1; i >= 0; i--) {\\n if (s[order[last]] != s[order[i]]) {\\n last = i;\\n }\\n lastIdx[order[i]] = last;\\n }\\n go2(0, new ArrayList<>(), true);\\n for (int i : order) {\\n out.print(s[i]);\\n if (doubled[i]) out.print(s[i]);\\n }\\n out.println();\\n }\\n\\n private int[] lastIdx;\\n private int n;\\n private char[] s;\\n private Int[] ints;\\n private int[] order;\\n private int orderSize;\\n private int[][] nx;\\n private int k;\\n private boolean[] doubled;\\n\\n private void go2(int v, ArrayList notMarked, boolean allow) {\\n notMarked.add(ints[v]);\\n if (allow && notMarked.size() <= k && (lastIdx[v] + 1 < n && s[v] < s[order[lastIdx[v] + 1]])) {\\n k -= notMarked.size();\\n for (Int i : notMarked) {\\n doubled[i.x] = true;\\n }\\n notMarked.clear();\\n }\\n if (nx[v][0] != -1) {\\n go2(nx[v][0], notMarked, allow);\\n }\\n if (!notMarked.isEmpty()) {\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A tree is a graph with n vertices and exactly n - 1 edges; this graph should meet the following condition: there exists exactly one shortest (by number of edges) path between any pair of its vertices.\\n\\nA subtree of a tree T is a tree with both vertices and edges as subsets of vertices and edges of T.\\n\\nYou're given a tree with n vertices. Consider its vertices numbered with integers from 1 to n. Additionally an integer is written on every vertex of this tree. Initially the integer written on the i-th vertex is equal to vi. In one move you can apply the following operation:\\n\\n 1. Select the subtree of the given tree that includes the vertex with number 1. \\n 2. Increase (or decrease) by one all the integers which are written on the vertices of that subtree. \\n\\n\\n\\nCalculate the minimum number of moves that is required to make all the integers written on the vertices of the given tree equal to zero.\\n\\nInput\\n\\nThe first line of the input contains n (1 ≤ n ≤ 105). Each of the next n - 1 lines contains two integers ai and bi (1 ≤ ai, bi ≤ n; ai ≠ bi) indicating there's an edge between vertices ai and bi. It's guaranteed that the input graph is a tree. \\n\\nThe last line of the input contains a list of n space-separated integers v1, v2, ..., vn (|vi| ≤ 109).\\n\\nOutput\\n\\nPrint the minimum number of operations needed to solve the task.\\n\\nPlease, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.\\n\\nExamples\\n\\nInput\\n\\n3\\n1 2\\n1 3\\n1 -1 1\\n\\n\\nOutput\\n\\n3\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nint dcmp(double x, double y) {\\n return fabs(x - y) <= 1e-9 ? 0 : x < y ? -1 : 1;\\n}\\nconst int MAX = 100007;\\nlong long arr[MAX], add[MAX], sub[MAX], n;\\nvector > adj;\\nvoid dfs(int u, int p) {\\n add[u] = sub[u] = 0;\\n for (int i = 0; i < ((int)((adj[u]).size())); ++i) {\\n int child = adj[u][i];\\n if (child != p) {\\n dfs(child, u);\\n add[u] = max(add[u], add[child]);\\n sub[u] = max(sub[u], sub[child]);\\n }\\n }\\n arr[u] += add[u] - sub[u];\\n if (arr[u] > 0) {\\n sub[u] += arr[u];\\n } else {\\n add[u] -= arr[u];\\n }\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n ;\\n cin >> n;\\n adj = vector >(n + 1);\\n for (int i = 0; i < (int)(n - 1); ++i) {\\n int u, v;\\n cin >> u >> v;\\n adj[u].push_back(v);\\n swap(u, v);\\n adj[u].push_back(v);\\n }\\n for (int i = 0; i < (int)(n); ++i) {\\n cin >> arr[i + 1];\\n }\\n dfs(1, -1);\\n cout << add[1] + sub[1] << '\\\\n';\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given two positive integers n and s. Find the maximum possible median of an array of n non-negative integers (not necessarily distinct), such that the sum of its elements is equal to s.\\n\\nA median of an array of integers of length m is the number standing on the ⌈ {m\\/2} ⌉-th (rounding up) position in the non-decreasing ordering of its elements. Positions are numbered starting from 1. For example, a median of the array [20,40,20,50,50,30] is the ⌈ m\\/2 ⌉-th element of [20,20,30,40,50,50], so it is 30. There exist other definitions of the median, but in this problem we use the described definition.\\n\\nInput\\n\\nThe input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. Description of the test cases follows.\\n\\nEach test case contains a single line with two integers n and s (1 ≤ n, s ≤ 10^9) — the length of the array and the required sum of the elements.\\n\\nOutput\\n\\nFor each test case print a single integer — the maximum possible median.\\n\\nExample\\n\\nInput\\n\\n\\n8\\n1 5\\n2 5\\n3 5\\n2 1\\n7 17\\n4 14\\n1 1000000000\\n1000000000 1\\n\\n\\nOutput\\n\\n\\n5\\n2\\n2\\n0\\n4\\n4\\n1000000000\\n0\\n\\nNote\\n\\nPossible arrays for the first three test cases (in each array the median is underlined):\\n\\n * In the first test case [\\\\underline{5}] \\n * In the second test case [\\\\underline{2}, 3] \\n * In the third test case [1, \\\\underline{2}, 2] \\nimpor\",\"targets\":\"t java.util.*;\\nimport java.io.*;\\npublic class Main {\\n\\/\\/ For fast input output\\nstatic class FastReader {\\nBufferedReader br;\\nStringTokenizer st;\\npublic FastReader()\\n{ try {br = new BufferedReader(\\nnew FileReader(\\\"input.txt\\\"));\\nPrintStream out = new PrintStream(new FileOutputStream(\\\"output.txt\\\"));\\nSystem.setOut(out);}\\ncatch(Exception e) { br = new BufferedReader(new InputStreamReader(System.in));}\\n}\\nString next()\\n{\\nwhile (st == null || !st.hasMoreElements()) {\\ntry {st = new StringTokenizer(br.readLine());}\\ncatch (IOException e) {\\ne.printStackTrace();}\\n}\\nreturn st.nextToken();\\n}\\nint nextInt() { return Integer.parseInt(next()); }\\nlong nextLong() { return Long.parseLong(next()); }\\ndouble nextDouble() {return Double.parseDouble(next()); }\\nString nextLine()\\n{\\nString str = \\\"\\\";\\ntry {\\nstr = br.readLine();\\n}\\ncatch (IOException e) {\\ne.printStackTrace();\\n}\\nreturn str;\\n}\\n}\\n\\/\\/ end of fast i\\/o code\\npublic static void main(String[] args) {\\n FastReader reader = new FastReader();\\n int Q = reader.nextInt();\\n outer: for (int q = 0; q < Q; q++) {\\n int n = reader.nextInt(), sum = reader.nextInt();\\n int index = (n % 2 == 1 ? n \\/ 2 : (n - 1) \\/ 2);\\n \\/\\/ sum -= index;\\n System.out.println(sum \\/ (n - index));\\n }\\n}}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"The grasshopper is located on the numeric axis at the point with coordinate x_0.\\n\\nHaving nothing else to do he starts jumping between integer points on the axis. Making a jump from a point with coordinate x with a distance d to the left moves the grasshopper to a point with a coordinate x - d, while jumping to the right moves him to a point with a coordinate x + d.\\n\\nThe grasshopper is very fond of positive integers, so for each integer i starting with 1 the following holds: exactly i minutes after the start he makes a jump with a distance of exactly i. So, in the first minutes he jumps by 1, then by 2, and so on.\\n\\nThe direction of a jump is determined as follows: if the point where the grasshopper was before the jump has an even coordinate, the grasshopper jumps to the left, otherwise he jumps to the right.\\n\\nFor example, if after 18 consecutive jumps he arrives at the point with a coordinate 7, he will jump by a distance of 19 to the right, since 7 is an odd number, and will end up at a point 7 + 19 = 26. Since 26 is an even number, the next jump the grasshopper will make to the left by a distance of 20, and it will move him to the point 26 - 20 = 6.\\n\\nFind exactly which point the grasshopper will be at after exactly n jumps.\\n\\nInput\\n\\nThe first line of input contains an integer t (1 ≤ t ≤ 10^4) — the number of test cases.\\n\\nEach of the following t lines contains two integers x_0 (-10^{14} ≤ x_0 ≤ 10^{14}) and n (0 ≤ n ≤ 10^{14}) — the coordinate of the grasshopper's initial position and the number of jumps.\\n\\nOutput\\n\\nPrint exactly t lines. On the i-th line print one integer — the answer to the i-th test case — the coordinate of the point the grasshopper will be at after making n jumps from the point x_0.\\n\\nExample\\n\\nInput\\n\\n\\n9\\n0 1\\n0 2\\n10 10\\n10 99\\n177 13\\n10000000000 987654321\\n-433494437 87178291199\\n1 0\\n-1 1\\n\\n\\nOutput\\n\\n\\n-1\\n1\\n11\\n110\\n190\\n9012345679\\n-87611785637\\n1\\n0\\n\\nNote\\n\\nThe first two test cases in the example correspond to the first two jumps from the point x_0 = 0. \\n\\nSince 0 is an even number, the first jump of length...\\nSolve the task in PYTHON3.\",\"targets\":\"for t in range(int(input())):\\n x,n= map(int, input().split())\\n #lis = list(map(int, input().split()))\\n #s=input()\\n val=n%4\\n if n<=3:\\n step=1\\n for i in range(n):\\n if x%2==0:\\n x-=(i+1)\\n else:\\n x+=(i+1)\\n step+=1\\n else:\\n\\n for i in range(val-1,-1,-1):\\n #print(i,x,n-i)\\n if x%2==0:\\n x-=(n-i)\\n else:\\n x+=(n-i)\\n print(x)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Consider a table of size n × m, initially fully white. Rows are numbered 1 through n from top to bottom, columns 1 through m from left to right. Some square inside the table with odd side length was painted black. Find the center of this square.\\n\\nInput\\n\\nThe first line contains two integers n and m (1 ≤ n, m ≤ 115) — the number of rows and the number of columns in the table.\\n\\nThe i-th of the next n lines contains a string of m characters s_{i1} s_{i2} … s_{im} (s_{ij} is 'W' for white cells and 'B' for black cells), describing the i-th row of the table.\\n\\nOutput\\n\\nOutput two integers r and c (1 ≤ r ≤ n, 1 ≤ c ≤ m) separated by a space — the row and column numbers of the center of the black square.\\n\\nExamples\\n\\nInput\\n\\n5 6\\nWWBBBW\\nWWBBBW\\nWWBBBW\\nWWWWWW\\nWWWWWW\\n\\n\\nOutput\\n\\n2 4\\n\\n\\nInput\\n\\n3 3\\nWWW\\nBWW\\nWWW\\n\\n\\nOutput\\n\\n2 1\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n long long n, m, rcnt = 0, ccnt = 0, fixi, fixj;\\n cin >> n >> m;\\n char c;\\n for (long long i = 0; i < n; i++) {\\n long long x = 0;\\n for (long long j = 0; j < m; j++) {\\n cin >> c;\\n if (c == 'B') x++, fixj = j;\\n }\\n if (x > 0) rcnt++, fixi = i, ccnt = max(ccnt, x);\\n }\\n cout << (fixi + 1 - (rcnt \\/ 2)) << ' ' << (fixj + 1 - (ccnt \\/ 2));\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nChristmas is coming, Icy has just received a box of chocolates from her grandparents! The box contains n chocolates. The i-th chocolate has a non-negative integer type a_i.\\n\\nIcy believes that good things come in pairs. Unfortunately, all types of chocolates are distinct (all a_i are distinct). Icy wants to make at least one pair of chocolates the same type. \\n\\nAs a result, she asks her grandparents to perform some chocolate exchanges. Before performing any chocolate exchanges, Icy chooses two chocolates with indices x and y (1 ≤ x, y ≤ n, x ≠ y).\\n\\nIn a chocolate exchange, Icy's grandparents choose a non-negative integer k, such that 2^k ≥ a_x, and change the type of the chocolate x from a_x to 2^k - a_x (that is, perform a_x := 2^k - a_x).\\n\\nThe chocolate exchanges will be stopped only when a_x = a_y. Note that other pairs of equal chocolate types do not stop the procedure.\\n\\nIcy's grandparents are smart, so they would choose the sequence of chocolate exchanges that minimizes the number of exchanges needed. Since Icy likes causing trouble, she wants to maximize the minimum number of exchanges needed by choosing x and y appropriately. She wonders what is the optimal pair (x, y) such that the minimum number of exchanges needed is maximized across all possible choices of (x, y).\\n\\nSince Icy is not good at math, she hopes that you can help her solve the problem.\\n\\nInput\\n\\nThe first line of the input contains a single integer n (2 ≤ n ≤ 2 ⋅ 10^5) — the number of chocolates.\\n\\nThe second line of the input contains n integers a_1, a_2, ..., a_n (0 ≤ a_i ≤ 10^9).\\n\\nIt is guaranteed that all a_i are distinct.\\n\\nOutput\\n\\nOutput three integers x, y, and m.\\n\\nx and y are indices of the optimal chocolates to perform exchanges on. Your output must satisfy 1 ≤ x, y ≤ n, x ≠ y.\\n\\nm is the number of exchanges needed to obtain a_x = a_y. We can show that m ≤ 10^9 for any pair of chocolates.\\n\\nIf there are multiple solutions, output any.\\n\\nExamples\\n\\nInput\\n\\n\\n5\\n5 6 7 8 9\\n\\n\\nOutput\\n\\n\\n2 5 5\\n\\n\\nInput\\n\\n\\n2\\n4 8\\n\\n\\nOutput\\n\\n\\n1 2 2\\n\\nNote\\n\\nIn the first...\",\"targets\":\"#include \\nusing namespace std;\\nint msb(int n) { return 32 - __builtin_clz(n); }\\nmap ind;\\nmap> adj;\\nint n;\\nvoid build(int x) {\\n if (adj[x].size()) return;\\n while (x > 0) {\\n int m = msb(x);\\n int nxt = (1 << m) - x;\\n if (x == nxt) nxt = 0;\\n if (adj[nxt].size()) {\\n adj[nxt].push_back(x);\\n break;\\n }\\n adj[nxt].push_back(x);\\n x = nxt;\\n }\\n}\\npair par = {-1, -1};\\nint val = 0;\\npair dfs(int v) {\\n vector> first;\\n first.push_back({0, v});\\n for (auto x : adj[v]) {\\n pair p = dfs(x);\\n p.first++;\\n first.push_back(p);\\n }\\n sort(begin(first), end(first),\\n [&](pair a, pair b) { return a.first > b.first; });\\n if (first.size() == 1) return first[0];\\n if (first[0].first + first[1].first > val) {\\n par = {first[0].second, first[1].second};\\n val = first[0].first + first[1].first;\\n }\\n return first[0];\\n}\\nsigned main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n cin >> n;\\n for (int i = 1; i <= n; i++) {\\n int x;\\n cin >> x;\\n build(x);\\n ind[x] = i;\\n }\\n dfs(0);\\n cout << ind[par.first] << \\\" \\\" << ind[par.second] << \\\" \\\" << val << endl;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Peter got a new snow blower as a New Year present. Of course, Peter decided to try it immediately. After reading the instructions he realized that it does not work like regular snow blowing machines. In order to make it work, you need to tie it to some point that it does not cover, and then switch it on. As a result it will go along a circle around this point and will remove all the snow from its path.\\n\\nFormally, we assume that Peter's machine is a polygon on a plane. Then, after the machine is switched on, it will make a circle around the point to which Peter tied it (this point lies strictly outside the polygon). That is, each of the points lying within or on the border of the polygon will move along the circular trajectory, with the center of the circle at the point to which Peter tied his machine.\\n\\nPeter decided to tie his car to point P and now he is wondering what is the area of ​​the region that will be cleared from snow. Help him.\\n\\nInput\\n\\nThe first line of the input contains three integers — the number of vertices of the polygon n (), and coordinates of point P.\\n\\nEach of the next n lines contains two integers — coordinates of the vertices of the polygon in the clockwise or counterclockwise order. It is guaranteed that no three consecutive vertices lie on a common straight line.\\n\\nAll the numbers in the input are integers that do not exceed 1 000 000 in their absolute value.\\n\\nOutput\\n\\nPrint a single real value number — the area of the region that will be cleared. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 6. \\n\\nNamely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct, if .\\n\\nExamples\\n\\nInput\\n\\n3 0 0\\n0 1\\n-1 2\\n1 2\\n\\n\\nOutput\\n\\n12.566370614359172464\\n\\n\\nInput\\n\\n4 1 -1\\n0 0\\n1 2\\n2 0\\n1 1\\n\\n\\nOutput\\n\\n21.991148575128551812\\n\\nNote\\n\\nIn the first sample snow will be removed from that area:\\n\\n\\\":\",\"targets\":\"#include \\nusing namespace std;\\nconst int MAXN = (int)1e5 + 5;\\nconst unsigned long long MOD = (unsigned long long)1e8;\\nconst double PI = acos(-1.0);\\nstruct point {\\n double x, y;\\n point() {}\\n point(double _x, double _y) {\\n x = _x;\\n y = _y;\\n }\\n point operator-(const point &b) const { return point(x - b.x, y - b.y); }\\n double operator*(const point &b) const { return x * b.x + y * b.y; }\\n} arr[MAXN];\\nstruct line {\\n point s, e;\\n line() {}\\n line(point _s, point _e) {\\n s = _s;\\n e = _e;\\n }\\n};\\ndouble dist(point a, point b) { return (a - b) * (a - b); }\\npoint neare(point P, line L) {\\n point result;\\n double t = (P - L.s) * (L.e - L.s) \\/ ((L.e - L.s) * (L.e - L.s));\\n if (t >= 0 && t <= 1) {\\n result.x = L.s.x + (L.e.x - L.s.x) * t;\\n result.y = L.s.y + (L.e.y - L.s.y) * t;\\n } else {\\n if (dist(P, L.s) < dist(P, L.e)) {\\n result = L.s;\\n } else {\\n result = L.e;\\n }\\n }\\n return result;\\n}\\nint main() {\\n int n;\\n point P;\\n while (scanf(\\\"%d%lf%lf\\\", &n, &P.x, &P.y) != EOF) {\\n double mi = 1e15, ma = 0.0;\\n for (int i = 0; i < n; ++i) {\\n scanf(\\\"%lf%lf\\\", &arr[i].x, &arr[i].y);\\n }\\n for (int i = 0; i < n; ++i) {\\n mi = min(mi, dist(neare(P, line(arr[i], arr[(i + 1) % n])), P));\\n ma = max(ma, dist(P, arr[i]));\\n }\\n printf(\\\"%.15lf\\\\n\\\", (ma - mi) * PI);\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A string is called diverse if it contains consecutive (adjacent) letters of the Latin alphabet and each letter occurs exactly once. For example, the following strings are diverse: \\\"fced\\\", \\\"xyz\\\", \\\"r\\\" and \\\"dabcef\\\". The following string are not diverse: \\\"az\\\", \\\"aa\\\", \\\"bad\\\" and \\\"babc\\\". Note that the letters 'a' and 'z' are not adjacent.\\n\\nFormally, consider positions of all letters in the string in the alphabet. These positions should form contiguous segment, i.e. they should come one by one without any gaps. And all letters in the string should be distinct (duplicates are not allowed).\\n\\nYou are given a sequence of strings. For each string, if it is diverse, print \\\"Yes\\\". Otherwise, print \\\"No\\\".\\n\\nInput\\n\\nThe first line contains integer n (1 ≤ n ≤ 100), denoting the number of strings to process. The following n lines contains strings, one string per line. Each string contains only lowercase Latin letters, its length is between 1 and 100, inclusive.\\n\\nOutput\\n\\nPrint n lines, one line per a string in the input. The line should contain \\\"Yes\\\" if the corresponding string is diverse and \\\"No\\\" if the corresponding string is not diverse. You can print each letter in any case (upper or lower). For example, \\\"YeS\\\", \\\"no\\\" and \\\"yES\\\" are all acceptable.\\n\\nExample\\n\\nInput\\n\\n\\n8\\nfced\\nxyz\\nr\\ndabcef\\naz\\naa\\nbad\\nbabc\\n\\n\\nOutput\\n\\n\\nYes\\nYes\\nYes\\nYes\\nNo\\nNo\\nNo\\nNo\\nUsing python3 can you solve the prior task?\",\"targets\":\"import math\\nimport sys\\n\\n#imgur.com\\/Pkt7iIf.png\\n\\ndef ii(): return int(input())\\ndef mi(): return map(int, input().split())\\ndef li(): return list(map(int, input().split()))\\n\\nn = ii()\\nfor j in range(n):\\n t = sorted(input())\\n print(\\\"No\\\") if any(ord(t[i]) != ord(t[i+1]) - 1 for i in range(len(t)-1)) else print(\\\"Yes\\\")\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 solution for \\\"Ezzat has an array of n integers (maybe negative). He wants to split it into two non-empty subsequences a and b, such that every element from the array belongs to exactly one subsequence, and the value of f(a) + f(b) is the maximum possible value, where f(x) is the average of the subsequence x. \\n\\nA sequence x is a subsequence of a sequence y if x can be obtained from y by deletion of several (possibly, zero or all) elements.\\n\\nThe average of a subsequence is the sum of the numbers of this subsequence divided by the size of the subsequence.\\n\\nFor example, the average of [1,5,6] is (1+5+6)\\/3 = 12\\/3 = 4, so f([1,5,6]) = 4.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^3)— the number of test cases. Each test case consists of two lines.\\n\\nThe first line contains a single integer n (2 ≤ n ≤ 10^5).\\n\\nThe second line contains n integers a_1, a_2, …, a_n (-10^9 ≤ a_i ≤ 10^9).\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 3⋅10^5.\\n\\nOutput\\n\\nFor each test case, print a single value — the maximum value that Ezzat can achieve.\\n\\nYour answer is considered correct if its absolute or relative error does not exceed 10^{-6}.\\n\\nFormally, let your answer be a, and the jury's answer be b. Your answer is accepted if and only if \\\\frac{|a - b|}{max{(1, |b|)}} ≤ 10^{-6}.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n3 1 2\\n3\\n-7 -6 -6\\n3\\n2 2 2\\n4\\n17 3 5 -3\\n\\n\\nOutput\\n\\n\\n4.500000000\\n-12.500000000\\n4.000000000\\n18.666666667\\n\\nNote\\n\\nIn the first test case, the array is [3, 1, 2]. These are all the possible ways to split this array: \\n\\n * a = [3], b = [1,2], so the value of f(a) + f(b) = 3 + 1.5 = 4.5. \\n * a = [3,1], b = [2], so the value of f(a) + f(b) = 2 + 2 = 4. \\n * a = [3,2], b = [1], so the value of f(a) + f(b) = 2.5 + 1 = 3.5. \\n\\nTherefore, the maximum possible value 4.5.\\n\\nIn the second test case, the array is [-7, -6, -6]. These are all the possible ways to split this array: \\n\\n * a = [-7], b = [-6,-6], so the value of f(a) + f(b) = (-7) + (-6) = -13. \\n * a = [-7,-6], b = [-6], so the value of f(a) + f(b) = (-6.5) + (-6) =...\\\":\",\"targets\":\"N = int(input())\\nfor _ in range(N):\\n n = int(input())\\n lst = sorted(list(map(int, input().split())))\\n pref_sum = [0]\\n for i in range(n):\\n pref_sum.append(pref_sum[-1] + lst[i])\\n sm = sum(lst)\\n mx = -(10**18)\\n for i in range(1, n):\\n sm1 = pref_sum[i]\\n sm2 = sm - sm1\\n val1 = sm1 \\/ i\\n val2 = sm2 \\/ (n - i)\\n mx = max(mx, val1 + val2)\\n print(mx)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"There is a grid, consisting of n rows and m columns. Each cell of the grid is either free or blocked. One of the free cells contains a lab. All the cells beyond the borders of the grid are also blocked.\\n\\nA crazy robot has escaped from this lab. It is currently in some free cell of the grid. You can send one of the following commands to the robot: \\\"move right\\\", \\\"move down\\\", \\\"move left\\\" or \\\"move up\\\". Each command means moving to a neighbouring cell in the corresponding direction.\\n\\nHowever, as the robot is crazy, it will do anything except following the command. Upon receiving a command, it will choose a direction such that it differs from the one in command and the cell in that direction is not blocked. If there is such a direction, then it will move to a neighbouring cell in that direction. Otherwise, it will do nothing.\\n\\nWe want to get the robot to the lab to get it fixed. For each free cell, determine if the robot can be forced to reach the lab starting in this cell. That is, after each step of the robot a command can be sent to a robot such that no matter what different directions the robot chooses, it will end up in a lab.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of testcases.\\n\\nThe first line of each testcase contains two integers n and m (1 ≤ n, m ≤ 10^6; n ⋅ m ≤ 10^6) — the number of rows and the number of columns in the grid.\\n\\nThe i-th of the next n lines provides a description of the i-th row of the grid. It consists of m elements of one of three types: \\n\\n * '.' — the cell is free; \\n * '#' — the cell is blocked; \\n * 'L' — the cell contains a lab. \\n\\n\\n\\nThe grid contains exactly one lab. The sum of n ⋅ m over all testcases doesn't exceed 10^6.\\n\\nOutput\\n\\nFor each testcase find the free cells that the robot can be forced to reach the lab from. Given the grid, replace the free cells (marked with a dot) with a plus sign ('+') for the cells that the robot can be forced to reach the lab from. Print the resulting grid.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3 3\\n...\\n.L.\\n...\\n4...\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\n\\npublic class PS1613E {\\n static final int sepLen = System.lineSeparator().length();\\n\\/\\/ static final int sepLen = 2;\\n\\n public static void main(String[] args) throws IOException {\\n BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));\\n int cases = Integer.parseInt(reader.readLine());\\n for (int i = 0; i < cases; i++) {\\n\\n\\/\\/ long t = System.currentTimeMillis();\\n String[] rc = reader.readLine().split(\\\" \\\");\\n int row = Integer.parseInt(rc[0]);\\n int col = Integer.parseInt(rc[1]);\\n char[] grid = new char[row * (col + sepLen)];\\n int Lr = -1, Lc = -1;\\n reader.read(grid);\\n for (int j = 0; j < grid.length; j++) {\\n if (grid[j] == 'L') {\\n Lr = j \\/ (col + sepLen);\\n Lc = j - Lr * (col + sepLen);\\n }\\n }\\n\\n\\/\\/ System.out.println(System.currentTimeMillis() - t);\\n\\n solve(grid, row, col, Lr, Lc);\\n\\n\\/\\/ System.out.println(System.currentTimeMillis() - t);\\n\\n System.out.print(grid);\\n }\\n }\\n\\n private static void solve(char[] grid, int row, int col, int Lr, int Lc) {\\n int colSize = col + sepLen;\\n int Li = Lr * colSize + Lc;\\n if (Lr > 0 && grid[Li - colSize] == '.') iterativeMark(grid, row, col, Lr - 1, Lc); \\/\\/ up\\n if (Lr < row - 1 && grid[Li + colSize] == '.') iterativeMark(grid, row, col, Lr + 1, Lc); \\/\\/ down\\n if (Lc > 0 && grid[Li - 1] == '.') iterativeMark(grid, row, col, Lr, Lc - 1); \\/\\/ left\\n if (Lc < col - 1 && grid[Li + 1] == '.') iterativeMark(grid, row, col, Lr, Lc + 1); \\/\\/ right\\n }\\n\\n private static void iterativeMark(char[] grid, int row, int col, int pr, int pc) {\\n byte counter;\\n int dr, dc;\\n while (true) {\\n counter = 0;\\n dr = dc = 0;\\n int colSize = col + sepLen;\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given an array of integers a of length n. The elements of the array can be either different or the same. \\n\\nEach element of the array is colored either blue or red. There are no unpainted elements in the array. One of the two operations described below can be applied to an array in a single step:\\n\\n * either you can select any blue element and decrease its value by 1; \\n * or you can select any red element and increase its value by 1. \\n\\n\\n\\nSituations in which there are no elements of some color at all are also possible. For example, if the whole array is colored blue or red, one of the operations becomes unavailable.\\n\\nDetermine whether it is possible to make 0 or more steps such that the resulting array is a permutation of numbers from 1 to n?\\n\\nIn other words, check whether there exists a sequence of steps (possibly empty) such that after applying it, the array a contains in some order all numbers from 1 to n (inclusive), each exactly once.\\n\\nInput\\n\\nThe first line contains an integer t (1 ≤ t ≤ 10^4) — the number of input data sets in the test.\\n\\nThe description of each set of input data consists of three lines. The first line contains an integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the length of the original array a. The second line contains n integers a_1, a_2, ..., a_n (-10^9 ≤ a_i ≤ 10^9) — the array elements themselves.\\n\\nThe third line has length n and consists exclusively of the letters 'B' and\\/or 'R': ith character is 'B' if a_i is colored blue, and is 'R' if colored red.\\n\\nIt is guaranteed that the sum of n over all input sets does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nPrint t lines, each of which contains the answer to the corresponding test case of the input. Print YES as an answer if the corresponding array can be transformed into a permutation, and NO otherwise.\\n\\nYou can print the answer in any case (for example, the strings yEs, yes, Yes, and YES will be recognized as a positive answer).\\n\\nExample\\n\\nInput\\n\\n\\n8\\n4\\n1 2 5 2\\nBRBR\\n2\\n1 1\\nBB\\n5\\n3 1 4 2 5\\nRBRRB\\n5\\n3 1 3 1 3\\nRBRRB\\n5\\n5 1 5 1 5\\nRBRRB\\n4\\n2 2 2 2\\nBRBR\\n2\\n1 -2\\nBR\\n4\\n-2...\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"\\/\\/package codeforces;\\nimport java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.io.PrintWriter;\\nimport java.util.*;\\npublic class codeforces{ \\n\\tpublic static void main(String[] args){\\n \\tFastScanner s=new FastScanner();\\n \\tPrintWriter out=new PrintWriter(System.out);\\n \\tint t=s.nextInt();\\n \\tfor(int tt=0;tt r=new ArrayList<>(),b=new ArrayList<>();\\n \\t\\tfor(int i=0;i=(i+1));\\n \\t\\t}\\n \\t\\tfor(int i=0;i set=new HashSet<>();\\n if (n <= 1)\\n return 1;\\n for (long i = 2; i <= Math.sqrt(n); i ++){\\n if (n % i == 0) {\\n \\tset.add(i);\\n \\t\\/\\/System.out.println(i+\\\" \\\"+n\\/i);\\n \\tset.add(n\\/i);\\n }\\n }\\n return set.size()+1;\\n }\\n\\tpublic static void printb(boolean ans) {\\n\\t\\tif(ans) {\\n\\t\\t\\tSystem.out.println(\\\"Yes\\\");\\n\\t\\t}else {\\n\\t\\t\\tSystem.out.println(\\\"No\\\");\\n\\t\\t}\\n\\t}\\n static void sort(long [] a) {\\n\\t\\tArrayList l=new ArrayList<>();\\n\\t\\tfor (long i:a) l.add(i);\\n\\t\\tCollections.sort(l);\\n\\t\\tfor (int i=0; i l=new ArrayList<>();\\n\\t\\tfor (int i:a) l.add(i);\\n\\t\\tCollections.sort(l);\\n\\t\\tfor (int i=0; i {\\n\\t\\t\\tif(x[c]>y[c]) {\\n\\t\\t\\t\\treturn 1;\\n\\t\\t\\t}else {\\n\\t\\t\\t\\treturn -1;\\n\\t\\t\\t}\\n\\t\\t});\\n\\t}\\n static class FastScanner...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in PYTHON3?\\nPolycarp doesn't like integers that are divisible by 3 or end with the digit 3 in their decimal representation. Integers that meet both conditions are disliked by Polycarp, too.\\n\\nPolycarp starts to write out the positive (greater than 0) integers which he likes: 1, 2, 4, 5, 7, 8, 10, 11, 14, 16, .... Output the k-th element of this sequence (the elements are numbered from 1).\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 100) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one line containing one integer k (1 ≤ k ≤ 1000).\\n\\nOutput\\n\\nFor each test case, output in a separate line one integer x — the k-th element of the sequence that was written out by Polycarp.\\n\\nExample\\n\\nInput\\n\\n\\n10\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n1000\\n\\n\\nOutput\\n\\n\\n1\\n2\\n4\\n5\\n7\\n8\\n10\\n11\\n14\\n1666\",\"targets\":\"t=int(input())\\nfor _ in range(t):\\n k=int(input())\\n i=1\\n while k>0:\\n if i%3==0 or i%10==3:\\n i=i+1\\n else:\\n i=i+1\\n k=k-1\\n print(i-1)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"\\n\\nFor given three points p0, p1, p2, print\\n\\n\\nCOUNTER_CLOCKWISE\\n\\n\\nif p0, p1, p2 make a counterclockwise turn (1),\\n\\n\\nCLOCKWISE\\n\\n\\nif p0, p1, p2 make a clockwise turn (2),\\n\\n\\nONLINE_BACK\\n\\n\\nif p2 is on a line p2, p0, p1 in this order (3),\\n\\n\\nONLINE_FRONT\\n\\n\\nif p2 is on a line p0, p1, p2 in this order (4),\\n\\n\\nON_SEGMENT\\n\\n\\nif p2 is on a segment p0p1 (5).\\n\\nConstraints\\n\\n* 1 ≤ q ≤ 1000\\n* -10000 ≤ xi, yi ≤ 10000\\n* p0 and p1 are not identical.\\n\\nInput\\n\\n\\nxp0 yp0 xp1 yp1\\nq\\nxp20 yp20\\nxp21 yp21\\n...\\nxp2q-1 yp2q-1\\n\\n\\nIn the first line, integer coordinates of p0 and p1 are given. Then, q queries are given for integer coordinates of p2.\\n\\nOutput\\n\\nFor each query, print the above mentioned status.\\n\\nExamples\\n\\nInput\\n\\n0 0 2 0\\n2\\n-1 1\\n-1 -1\\n\\n\\nOutput\\n\\nCOUNTER_CLOCKWISE\\nCLOCKWISE\\n\\n\\nInput\\n\\n0 0 2 0\\n3\\n-1 0\\n0 0\\n3 0\\n\\n\\nOutput\\n\\nONLINE_BACK\\nON_SEGMENT\\nONLINE_FRONT\\nSolve the task in CPP.\",\"targets\":\"#include \\n#include \\n#include \\nusing namespace std;\\nconst double EPS = 1e-8;\\nconst double INF = 1e12;\\ntypedef complex P;\\nnamespace std {\\n bool operator < (const P& a, const P& b) {\\n return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);\\n }\\n}\\ndouble cross(const P& a, const P& b) {\\n return imag(conj(a)*b);\\n}\\ndouble dot(const P& a, const P& b) {\\n return real(conj(a)*b);\\n}\\n\\nstruct L : public vector

    {\\n L(const P &a, const P &b) {\\n push_back(a); push_back(b);\\n }\\n};\\n\\ntypedef vector

    G;\\n\\nstruct C {\\n P p; double r;\\n C(const P &p, double r) : p(p), r(r) { }\\n};\\n\\nint ccw(P a, P b, P c) {\\n b -= a; c -= a;\\n if (cross(b, c) > 0) return +1; \\/\\/ counter clockwise\\n if (cross(b, c) < 0) return -1; \\/\\/ clockwise\\n if (dot(b, c) < 0) return +2; \\/\\/ c--a--b on line\\n if (norm(b) < norm(c)) return -2; \\/\\/ a--b--c on line\\n return 0; \\/\\/ a--c--b on line\\n}\\n\\nconst char *z[]={\\\"ONLINE_FRONT\\\",\\\"CLOCKWISE\\\",\\\"ON_SEGMENT\\\",\\\"COUNTER_CLOCKWISE\\\",\\\"ONLINE_BACK\\\"};\\nint main(){\\n\\tdouble x,y;\\n\\tint q;\\n\\tscanf(\\\"%lf%lf\\\",&x,&y);P p0(x,y);\\n\\tscanf(\\\"%lf%lf%d\\\",&x,&y,&q);P p1(x,y);\\n\\tfor(;q--;){\\n\\t\\tscanf(\\\"%lf%lf\\\",&x,&y);P p(x,y);\\n\\t\\tputs(z[ccw(p0,p1,p)+2]);\\n\\t}\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"The only difference between this problem and D2 is that you don't have to provide the way to construct the answer in this problem, but you have to do it in D2.\\n\\nThere's a table of n × m cells (n rows and m columns). The value of n ⋅ m is even.\\n\\nA domino is a figure that consists of two cells having a common side. It may be horizontal (one of the cells is to the right of the other) or vertical (one of the cells is above the other).\\n\\nYou need to find out whether it is possible to place nm\\/2 dominoes on the table so that exactly k of them are horizontal and all the other dominoes are vertical. The dominoes cannot overlap and must fill the whole table.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of a single line. The line contains three integers n, m, k (1 ≤ n,m ≤ 100, 0 ≤ k ≤ nm\\/2, n ⋅ m is even) — the number of rows, columns and horizontal dominoes, respectively.\\n\\nOutput\\n\\nFor each test case output \\\"YES\\\", if it is possible to place dominoes in the desired way, or \\\"NO\\\" otherwise.\\n\\nYou may print each letter in any case (YES, yes, Yes will all be recognized as positive answer, NO, no and nO will all be recognized as negative answer).\\n\\nExample\\n\\nInput\\n\\n\\n8\\n4 4 2\\n2 3 0\\n3 2 3\\n1 2 0\\n2 4 2\\n5 2 2\\n2 17 16\\n2 1 1\\n\\n\\nOutput\\n\\n\\nYES\\nYES\\nYES\\nNO\\nYES\\nNO\\nYES\\nNO\\nt=+re\",\"targets\":\"adline();\\nwhile(t--){\\n r=readline().split` `\\n n=+r[0],m=+r[1],k=+r[2];\\n if(n%2==0 && m%2==0){\\n print(k%2==0?\\\"YES\\\":\\\"NO\\\");\\n }\\n else if(n%2==1 && m%2==0){\\n if(k\\n\\nInitially all the cells of the matrix are free.\\n\\nYou have to process q queries, each of them flips the state of a single cell. So, if a cell is currently free, it makes it locked, and if a cell is currently locked, it makes it free.\\n\\nPrint the number of different staircases after each query. Two staircases are considered different if there exists such a cell that appears in one path and doesn't appear in the other path.\\n\\nInput\\n\\nThe first line contains three integers n, m and q (1 ≤ n, m ≤ 1000; 1 ≤ q ≤ 10^4) — the sizes of the matrix and the number of queries.\\n\\nEach of the next q lines contains two integers x and y (1 ≤ x ≤ n; 1 ≤ y ≤ m) — the description of each query.\\n\\nOutput\\n\\nPrint q integers — the i-th value should be equal to the number of different staircases after i queries. Two staircases are considered different if there exists such a cell that appears in one path and doesn't appear in the other path.\\n\\nExamples\\n\\nInput\\n\\n\\n2 2 8\\n1 1\\n1 1\\n1 1\\n2 2\\n1 1\\n1 2\\n2 1\\n1 1\\n\\n\\nOutput\\n\\n\\n5\\n10\\n5\\n2\\n5\\n3\\n1\\n0\\n\\n\\nInput\\n\\n\\n3 4 10\\n1 4\\n1 2\\n2 3\\n1 2\\n2 3\\n3 2\\n1 3\\n3 4\\n1 3\\n3 1\\n\\n\\nOutput\\n\\n\\n49\\n35\\n24\\n29\\n49\\n39\\n31\\n23\\n29\\n27\\n\\n\\nInput\\n\\n\\n1000 1000 2\\n239 634\\n239 634\\n\\n\\nOutput\\n\\n\\n1332632508\\n1333333000\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nconst long long N = 1e3 + 7;\\nlong long n;\\nlong long m;\\nlong long dp[N][N][2];\\nlong long on[N][N];\\nlong long all;\\nlong long q;\\nvoid calc(long long x, long long y) {\\n long long ban = on[x][y] * (dp[x][y][0] + dp[x][y][1] - 1);\\n all += ban;\\n for (long long i = 0; i <= 1; i++) {\\n long long a = x, b = y;\\n bool c = i;\\n while (1) {\\n if (c == 1)\\n ++b;\\n else\\n ++a;\\n if (a > n || b > m) break;\\n c ^= 1;\\n dp[a][b][c] += on[x][y] * dp[x][y][i];\\n if (on[a][b] == 1) break;\\n all += on[x][y] * dp[x][y][i];\\n }\\n }\\n on[x][y] = -on[x][y];\\n}\\nsigned main() {\\n ios::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n cin >> n >> m >> q;\\n for (long long i = 1; i <= n; i++) {\\n for (long long j = 1; j <= m; j++) {\\n on[i][j] = -1;\\n dp[i][j][1] = dp[i - 1][j][0] + 1;\\n dp[i][j][0] = dp[i][j - 1][1] + 1;\\n all += dp[i][j][0] + dp[i][j][1] - 1;\\n }\\n }\\n while (q--) {\\n long long x, y;\\n cin >> x >> y;\\n calc(x, y);\\n cout << all << '\\\\n';\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Polycarp has found a table having an infinite number of rows and columns. The rows are numbered from 1, starting from the topmost one. The columns are numbered from 1, starting from the leftmost one.\\n\\nInitially, the table hasn't been filled and Polycarp wants to fix it. He writes integers from 1 and so on to the table as follows.\\n\\n The figure shows the placement of the numbers from 1 to 10. The following actions are denoted by the arrows.\\n\\nThe leftmost topmost cell of the table is filled with the number 1. Then he writes in the table all positive integers beginning from 2 sequentially using the following algorithm.\\n\\nFirst, Polycarp selects the leftmost non-filled cell in the first row and fills it. Then, while the left neighbor of the last filled cell is filled, he goes down and fills the next cell. So he goes down until the last filled cell has a non-filled neighbor to the left (look at the vertical arrow going down in the figure above).\\n\\nAfter that, he fills the cells from the right to the left until he stops at the first column (look at the horizontal row in the figure above). Then Polycarp selects the leftmost non-filled cell in the first row, goes down, and so on.\\n\\nA friend of Polycarp has a favorite number k. He wants to know which cell will contain the number. Help him to find the indices of the row and the column, such that the intersection of the row and the column is the cell containing the number k.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 100) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one line containing one integer k (1 ≤ k ≤ 10^9) which location must be found.\\n\\nOutput\\n\\nFor each test case, output in a separate line two integers r and c (r, c ≥ 1) separated by spaces — the indices of the row and the column containing the cell filled by the number k, respectively.\\n\\nExample\\n\\nInput\\n\\n\\n7\\n11\\n14\\n5\\n4\\n1\\n2\\n1000000000\\n\\n\\nOutput\\n\\n\\n2 4\\n4 3\\n1 3\\n2 1\\n1 1\\n1 2\\n31623 14130\\\":\",\"targets\":\"#include \\nusing namespace std;\\nvoid solve() {\\n int k;\\n cin >> k;\\n int s = sqrt(k);\\n if ((s * s) != k) s += 1;\\n int c = s;\\n int r = 1;\\n int res = (s - 1) * (s - 1) + 1;\\n while (r <= s) {\\n if (res == k) {\\n cout << r << \\\" \\\" << c << \\\"\\\\n\\\";\\n return;\\n }\\n res++;\\n r++;\\n }\\n r = s;\\n c = s - 1;\\n while (c >= 0) {\\n if (res == k) {\\n cout << r << \\\" \\\" << c << \\\"\\\\n\\\";\\n return;\\n }\\n res++;\\n c--;\\n }\\n}\\nint main() {\\n int t;\\n cin >> t;\\n while (t--) {\\n solve();\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A binary string is a string that consists of characters 0 and 1.\\n\\nLet \\\\operatorname{MEX} of a binary string be the smallest digit among 0, 1, or 2 that does not occur in the string. For example, \\\\operatorname{MEX} of 001011 is 2, because 0 and 1 occur in the string at least once, \\\\operatorname{MEX} of 1111 is 0, because 0 and 2 do not occur in the string and 0 < 2.\\n\\nA binary string s is given. You should cut it into any number of substrings such that each character is in exactly one substring. It is possible to cut the string into a single substring — the whole string.\\n\\nA string a is a substring of a string b if a can be obtained from b by deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end.\\n\\nWhat is the minimal sum of \\\\operatorname{MEX} of all substrings pieces can be?\\n\\nInput\\n\\nThe input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. Description of the test cases follows.\\n\\nEach test case contains a single binary string s (1 ≤ |s| ≤ 10^5).\\n\\nIt's guaranteed that the sum of lengths of s over all test cases does not exceed 10^5.\\n\\nOutput\\n\\nFor each test case print a single integer — the minimal sum of \\\\operatorname{MEX} of all substrings that it is possible to get by cutting s optimally.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n01\\n1111\\n01100\\n101\\n0000\\n01010\\n\\n\\nOutput\\n\\n\\n1\\n0\\n2\\n1\\n1\\n2\\n\\nNote\\n\\nIn the first test case the minimal sum is \\\\operatorname{MEX}(0) + \\\\operatorname{MEX}(1) = 1 + 0 = 1.\\n\\nIn the second test case the minimal sum is \\\\operatorname{MEX}(1111) = 0.\\n\\nIn the third test case the minimal sum is \\\\operatorname{MEX}(01100) = 2.\\nfor i\",\"targets\":\"in range(int(input())):\\n s=input()\\n n=len(s)\\n c=s.count('0')\\n s1=c*'0'\\n # print(s1)\\n if s1 in s and c>0:\\n print(1)\\n elif c>1:\\n print(2)\\n else:\\n print(c)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Polycarp has found a table having an infinite number of rows and columns. The rows are numbered from 1, starting from the topmost one. The columns are numbered from 1, starting from the leftmost one.\\n\\nInitially, the table hasn't been filled and Polycarp wants to fix it. He writes integers from 1 and so on to the table as follows.\\n\\n The figure shows the placement of the numbers from 1 to 10. The following actions are denoted by the arrows.\\n\\nThe leftmost topmost cell of the table is filled with the number 1. Then he writes in the table all positive integers beginning from 2 sequentially using the following algorithm.\\n\\nFirst, Polycarp selects the leftmost non-filled cell in the first row and fills it. Then, while the left neighbor of the last filled cell is filled, he goes down and fills the next cell. So he goes down until the last filled cell has a non-filled neighbor to the left (look at the vertical arrow going down in the figure above).\\n\\nAfter that, he fills the cells from the right to the left until he stops at the first column (look at the horizontal row in the figure above). Then Polycarp selects the leftmost non-filled cell in the first row, goes down, and so on.\\n\\nA friend of Polycarp has a favorite number k. He wants to know which cell will contain the number. Help him to find the indices of the row and the column, such that the intersection of the row and the column is the cell containing the number k.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 100) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one line containing one integer k (1 ≤ k ≤ 10^9) which location must be found.\\n\\nOutput\\n\\nFor each test case, output in a separate line two integers r and c (r, c ≥ 1) separated by spaces — the indices of the row and the column containing the cell filled by the number k, respectively.\\n\\nExample\\n\\nInput\\n\\n\\n7\\n11\\n14\\n5\\n4\\n1\\n2\\n1000000000\\n\\n\\nOutput\\n\\n\\n2 4\\n4 3\\n1 3\\n2 1\\n1 1\\n1 2\\n31623 14130\\nUsing java can you solve the prior task?\",\"targets\":\"import java.io.OutputStream;\\nimport java.io.IOException;\\nimport java.io.InputStream;\\nimport java.io.PrintWriter;\\nimport java.util.Scanner;\\n\\n\\/**\\n * Built using CHelper plug-in\\n * Actual solution is at the top\\n *\\n * @author wiseberg\\n *\\/\\npublic class Main {\\n public static void main(String[] args) {\\n InputStream inputStream = System.in;\\n OutputStream outputStream = System.out;\\n Scanner in = new Scanner(inputStream);\\n PrintWriter out = new PrintWriter(outputStream);\\n TaskC solver = new TaskC();\\n solver.solve(1, in, out);\\n out.close();\\n }\\n\\n static class TaskC {\\n public void solve(int testNumber, Scanner in, PrintWriter out) {\\n int t = in.nextInt();\\n int k;\\n double r, c;\\n for (int i = 0; i < t; i++) {\\n k = in.nextInt();\\n r = Math.pow(Math.round(Math.sqrt(k)), 2);\\n if (r < k) {\\n c = Math.sqrt(r) + 1;\\n r = k - r;\\n } else {\\n c = r - k + 1;\\n r = Math.sqrt(r);\\n }\\n out.println((int) r + \\\" \\\" + (int) c);\\n\\n }\\n }\\n\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alexander is a well-known programmer. Today he decided to finally go out and play football, but with the first hit he left a dent on the new Rolls-Royce of the wealthy businessman Big Vova. Vladimir has recently opened a store on the popular online marketplace \\\"Zmey-Gorynych\\\", and offers Alex a job: if he shows his programming skills by solving a task, he'll work as a cybersecurity specialist. Otherwise, he'll be delivering some doubtful products for the next two years.\\n\\nYou're given n positive integers a_1, a_2, ..., a_n. Using each of them exactly at once, you're to make such sequence b_1, b_2, ..., b_n that sequence c_1, c_2, ..., c_n is lexicographically maximal, where c_i=GCD(b_1,...,b_i) - the greatest common divisor of the first i elements of b. \\n\\nAlexander is really afraid of the conditions of this simple task, so he asks you to solve it.\\n\\nA sequence a is lexicographically smaller than a sequence b if and only if one of the following holds:\\n\\n * a is a prefix of b, but a ≠ b;\\n * in the first position where a and b differ, the sequence a has a smaller element than the corresponding element in b.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^3). Description of the test cases follows.\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 10^3) — the length of the sequence a.\\n\\nThe second line of each test case contains n integers a_1,...,a_n (1 ≤ a_i ≤ 10^3) — the sequence a.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 10^3.\\n\\nOutput\\n\\nFor each test case output the answer in a single line — the desired sequence b. If there are multiple answers, print any.\\n\\nExample\\n\\nInput\\n\\n\\n7\\n2\\n2 5\\n4\\n1 8 2 3\\n3\\n3 8 9\\n5\\n64 25 75 100 50\\n1\\n42\\n6\\n96 128 88 80 52 7\\n5\\n2 4 8 16 17\\n\\n\\nOutput\\n\\n\\n5 2 \\n8 2 1 3 \\n9 3 8 \\n100 50 25 75 64 \\n42 \\n128 96 80 88 52 7 \\n17 2 4 8 16 \\n\\nNote\\n\\nIn the first test case of the example, there are only two possible permutations b — [2, 5] and [5, 2]: for the first one c=[2, 1], for the second one c=[5,...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint read() {\\n int tot = 0, fh = 1;\\n char c = getchar();\\n while (c < '0' || c > '9') {\\n if (c == '-') fh = -1;\\n c = getchar();\\n }\\n while (c >= '0' && c <= '9') {\\n tot = tot * 10 + c - '0';\\n c = getchar();\\n }\\n return tot * fh;\\n}\\nvoid getstr(char *a) {\\n char c = getchar();\\n int len = 0;\\n while (!((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') ||\\n (c >= '0' && c <= '9')))\\n c = getchar();\\n while ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') ||\\n (c >= '0' && c <= '9')) {\\n a[++len] = c;\\n c = getchar();\\n }\\n}\\nint gcd(int x, int y) {\\n while (y) {\\n int z = x % y;\\n x = y;\\n y = z;\\n }\\n return x;\\n}\\nconst int maxn = 2020;\\nint t, n, a[maxn], rem, tmp, b[maxn], c[maxn];\\nbool d[maxn];\\nint main() {\\n t = read();\\n while (t--) {\\n n = read();\\n for (int i = 1; i <= n; i++) {\\n a[i] = read();\\n d[i] = true;\\n }\\n tmp = 0;\\n rem = 1;\\n for (int i = 1; i <= n; i++)\\n if (a[i] > tmp) {\\n tmp = a[i];\\n rem = i;\\n }\\n b[1] = a[rem];\\n c[1] = a[rem];\\n d[rem] = false;\\n for (int i = 2; i <= n; i++) {\\n tmp = 0;\\n for (int j = 1; j <= n; j++)\\n if (d[j] && gcd(c[i - 1], a[j]) > tmp) {\\n rem = j;\\n tmp = gcd(c[i - 1], a[j]);\\n }\\n b[i] = a[rem];\\n c[i] = gcd(b[i], c[i - 1]);\\n d[rem] = false;\\n }\\n for (int i = 1; i <= n; i++) cout << b[i] << \\\" \\\";\\n cout << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Arkady's code contains n variables. Each variable has a unique name consisting of lowercase English letters only. One day Arkady decided to shorten his code.\\n\\nHe wants to replace each variable name with its non-empty prefix so that these new names are still unique (however, a new name of some variable can coincide with some old name of another or same variable). Among such possibilities he wants to find the way with the smallest possible total length of the new names.\\n\\nA string a is a prefix of a string b if you can delete some (possibly none) characters from the end of b and obtain a.\\n\\nPlease find this minimum possible total length of new names.\\n\\nInput\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 10^5) — the number of variables.\\n\\nThe next n lines contain variable names, one per line. Each name is non-empty and contains only lowercase English letters. The total length of these strings is not greater than 10^5. The variable names are distinct.\\n\\nOutput\\n\\nPrint a single integer — the minimum possible total length of new variable names.\\n\\nExamples\\n\\nInput\\n\\n3\\ncodeforces\\ncodehorses\\ncode\\n\\n\\nOutput\\n\\n6\\n\\n\\nInput\\n\\n5\\nabba\\nabb\\nab\\naa\\naacada\\n\\n\\nOutput\\n\\n11\\n\\n\\nInput\\n\\n3\\ntelegram\\ndigital\\nresistance\\n\\n\\nOutput\\n\\n3\\n\\nNote\\n\\nIn the first example one of the best options is to shorten the names in the given order as \\\"cod\\\", \\\"co\\\", \\\"c\\\".\\n\\nIn the second example we can shorten the last name to \\\"aac\\\" and the first name to \\\"a\\\" without changing the other names.\",\"targets\":\"#include \\nusing namespace std;\\nstruct vertex {\\n map next, go;\\n int parent, link, up, number = 0, size = 0;\\n char parent_char;\\n bool leaf;\\n};\\nvector bor;\\nint size;\\nvoid init() {\\n bor.push_back({});\\n bor[0].parent = bor[0].link = -1;\\n size = 1;\\n}\\nvoid add_string(const string &s) {\\n int v = 0;\\n for (char c : s) {\\n if (bor[v].next[c] == 0) {\\n bor.push_back({});\\n bor[size].up = bor[size].link = -1;\\n bor[size].parent = v;\\n bor[size].parent_char = c;\\n bor[v].next[c] = size++;\\n }\\n v = bor[v].next[c];\\n bor[v].size++;\\n }\\n bor[v].leaf = true;\\n}\\nint go(int v, char c);\\nint get_link(int v) {\\n if (bor[v].link == -1) {\\n if (v == 0 || bor[v].parent == 0) {\\n bor[v].link = 0;\\n } else {\\n bor[v].link = go(get_link(bor[v].parent), bor[v].parent_char);\\n }\\n }\\n return bor[v].link;\\n}\\nint go(int v, char c) {\\n if (bor[v].go[c] == 0) {\\n if (bor[v].next[c] != 0) {\\n bor[v].go[c] = bor[v].next[c];\\n } else {\\n bor[v].go[c] = (v == 0 ? 0 : go(get_link(v), c));\\n }\\n }\\n return bor[v].go[c];\\n}\\nint get_up(int v) {\\n if (bor[v].up == -1) {\\n if (bor[get_link(v)].leaf) {\\n bor[v].up = get_link(v);\\n } else if (get_link(v) == 0) {\\n bor[v].up = 0;\\n } else {\\n bor[v].up = get_up(get_link(v));\\n }\\n }\\n return bor[v].up;\\n}\\nvoid dfs(int vertex, priority_queue &p, int deep) {\\n priority_queue Q;\\n for (auto j : bor[vertex].next) {\\n dfs(j.second, Q, deep + 1);\\n while (!Q.empty()) {\\n p.push(Q.top());\\n Q.pop();\\n }\\n }\\n if (!bor[vertex].leaf && deep != 0) {\\n p.pop();\\n }\\n p.push(deep);\\n}\\nint main() {\\n ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);\\n int n;\\n cin >> n;\\n init();\\n for (int i = 0; i < n; i++) {\\n string s;\\n cin >> s;\\n add_string(s);\\n }\\n priority_queue p;\\n dfs(0, p, 0);\\n int ans = 0;\\n while (!p.empty()) {\\n ans += p.top();\\n p.pop();\\n }\\n cout << ans;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Consider the insertion sort algorithm used to sort an integer sequence [a_1, a_2, …, a_n] of length n in non-decreasing order.\\n\\nFor each i in order from 2 to n, do the following. If a_i ≥ a_{i-1}, do nothing and move on to the next value of i. Otherwise, find the smallest j such that a_i < a_j, shift the elements on positions from j to i-1 by one position to the right, and write down the initial value of a_i to position j. In this case we'll say that we performed an insertion of an element from position i to position j.\\n\\nIt can be noticed that after processing any i, the prefix of the sequence [a_1, a_2, …, a_i] is sorted in non-decreasing order, therefore, the algorithm indeed sorts any sequence.\\n\\nFor example, sorting [4, 5, 3, 1, 3] proceeds as follows: \\n\\n * i = 2: a_2 ≥ a_1, do nothing; \\n * i = 3: j = 1, insert from position 3 to position 1: [3, 4, 5, 1, 3]; \\n * i = 4: j = 1, insert from position 4 to position 1: [1, 3, 4, 5, 3]; \\n * i = 5: j = 3, insert from position 5 to position 3: [1, 3, 3, 4, 5]. \\n\\n\\n\\nYou are given an integer n and a list of m integer pairs (x_i, y_i). We are interested in sequences such that if you sort them using the above algorithm, exactly m insertions will be performed: first from position x_1 to position y_1, then from position x_2 to position y_2, ..., finally, from position x_m to position y_m.\\n\\nHow many sequences of length n consisting of (not necessarily distinct) integers between 1 and n, inclusive, satisfy the above condition? Print this number modulo 998 244 353.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^5). Description of the test cases follows.\\n\\nThe first line of each test case contains two integers n and m (2 ≤ n ≤ 2 ⋅ 10^5; 0 ≤ m < n) — the length of the sequence and the number of insertions.\\n\\nThe i-th of the following m lines contains two integers x_i and y_i (2 ≤ x_1 < x_2 < … < x_m ≤ n; 1 ≤ y_i < x_i). These lines describe the sequence of insertions in chronological order.\\n\\nIt is guaranteed...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint mod = 998244353;\\nnamespace math {\\nint inc(int x, int y) { return x + y >= mod ? x + y - mod : x + y; }\\nint qpow(int a, int x, int mo) {\\n int res = 1;\\n while (x) {\\n if (x & 1) res = 1ll * res * a % mod;\\n a = 1ll * a * a % mod;\\n x >>= 1;\\n }\\n return res;\\n}\\nvector Fac, invFac;\\nvoid Finit(int n) {\\n Fac.resize(n + 1);\\n invFac.resize(n + 1);\\n Fac[0] = 1;\\n invFac[0] = 1;\\n for (int i = 1; i <= n; i++) Fac[i] = 1ll * Fac[i - 1] * i % mod;\\n invFac[n] = qpow(Fac[n], mod - 2, mod);\\n for (int i = n - 1; i >= 1; i--)\\n invFac[i] = 1ll * invFac[i + 1] * (i + 1) % mod;\\n}\\nint C(int n, int m) {\\n if (m == 0) return 1;\\n if (n < m || m < 0) return 0;\\n return (int)(1ll * Fac[n] * invFac[m] % mod * invFac[n - m] % mod);\\n}\\nint A(int n, int m) {\\n if (n < m || m < 0) return 0;\\n return (int)(1ll * Fac[n] * invFac[n - m] % mod);\\n}\\n} \\/\\/ namespace math\\nusing namespace math;\\nstd::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count());\\nconst int N = 1e6 + 10;\\nstruct FHQ {\\n vector ls{0}, rs{0}, siz{0}, key{0}, val{0};\\n int tcnt;\\n int root;\\n int newNode(int x) {\\n siz.push_back(1);\\n val.push_back(x);\\n key.push_back(rnd());\\n ls.push_back(0);\\n rs.push_back(0);\\n return val.size() - 1;\\n }\\n void pushup(int pos) { siz[pos] = siz[ls[pos]] + siz[rs[pos]] + 1; }\\n void split(int pos, int v, int &ll, int &rr) {\\n if (!pos) {\\n ll = 0, rr = 0;\\n return;\\n }\\n if (siz[ls[pos]] + 1 <= v) {\\n ll = pos;\\n split(rs[pos], v - siz[ls[pos]] - 1, rs[pos], rr);\\n } else {\\n rr = pos;\\n split(ls[pos], v, ll, ls[pos]);\\n }\\n pushup(pos);\\n }\\n int merge(int l, int r) {\\n if (!l || !r) return l + r;\\n if (key[l] < key[r]) {\\n rs[l] = merge(rs[l], r);\\n pushup(l);\\n return l;\\n } else {\\n ls[r] = merge(l, ls[r]);\\n pushup(r);\\n return r;\\n }\\n }\\n void init(int n) {\\n for (int i = 1; i <= n; i++) {\\n int pos = newNode(i);\\n root = merge(root, pos);\\n }\\n }\\n}...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"Let's call the string beautiful if it does not contain a substring of length at least 2, which is a palindrome. Recall that a palindrome is a string that reads the same way from the first character to the last and from the last character to the first. For example, the strings a, bab, acca, bcabcbacb are palindromes, but the strings ab, abbbaa, cccb are not.\\n\\nLet's define cost of a string as the minimum number of operations so that the string becomes beautiful, if in one operation it is allowed to change any character of the string to one of the first 3 letters of the Latin alphabet (in lowercase).\\n\\nYou are given a string s of length n, each character of the string is one of the first 3 letters of the Latin alphabet (in lowercase).\\n\\nYou have to answer m queries — calculate the cost of the substring of the string s from l_i-th to r_i-th position, inclusive.\\n\\nInput\\n\\nThe first line contains two integers n and m (1 ≤ n, m ≤ 2 ⋅ 10^5) — the length of the string s and the number of queries.\\n\\nThe second line contains the string s, it consists of n characters, each character one of the first 3 Latin letters.\\n\\nThe following m lines contain two integers l_i and r_i (1 ≤ l_i ≤ r_i ≤ n) — parameters of the i-th query.\\n\\nOutput\\n\\nFor each query, print a single integer — the cost of the substring of the string s from l_i-th to r_i-th position, inclusive.\\n\\nExample\\n\\nInput\\n\\n\\n5 4\\nbaacb\\n1 3\\n1 5\\n4 5\\n2 3\\n\\n\\nOutput\\n\\n\\n1\\n2\\n0\\n1\\n\\nNote\\n\\nConsider the queries of the example test.\\n\\n * in the first query, the substring is baa, which can be changed to bac in one operation; \\n * in the second query, the substring is baacb, which can be changed to cbacb in two operations; \\n * in the third query, the substring is cb, which can be left unchanged; \\n * in the fourth query, the substring is aa, which can be changed to ba in one operation. \\\":\",\"targets\":\"import java.util.Scanner;\\n\\npublic class sayNoPalindrome {\\n\\n\\tpublic static void main(String[] args) {\\n\\t\\t\\/\\/ TODO Auto-generated method stub\\n\\t\\tScanner sc = new Scanner(System.in);\\n\\t\\tint n =sc .nextInt();\\n\\t\\tint m = sc.nextInt();\\n\\t\\tsc.nextLine();\\n\\t\\tString s = sc.nextLine();\\n\\t\\tString[] str = new String[] {\\\"abc\\\", \\\"acb\\\", \\\"bac\\\", \\\"bca\\\", \\\"cab\\\", \\\"cba\\\"};\\n\\t\\tint[][] arr = solve(s, str);\\n\\t\\tint i,j;\\n\\/\\/\\t\\tfor(i=0; i\\nusing namespace std;\\ntemplate \\nbool ckmin(T &a, const U &b) {\\n return b < a ? a = b, true : false;\\n}\\ntemplate \\nbool ckmax(T &a, const U &b) {\\n return b > a ? a = b, true : false;\\n}\\ntemplate \\nstruct SegmentTree {\\n int SZ;\\n T id;\\n vector t;\\n SegmentTree(T x, int sz) : id(x), SZ(sz) { t.assign((SZ << 2) + 5, id); }\\n SegmentTree(vector &a, T x, int sz) {\\n id = x;\\n SZ = sz;\\n t.assign((SZ << 2) + 5, id);\\n build(1, 0, SZ - 1, a);\\n }\\n T cmb(T x, T y) { return x + y; }\\n void build(int v, int tl, int tr, vector &a) {\\n if (tl == tr)\\n t[v] = a[tl];\\n else {\\n int tm = tl + (tr - tl) \\/ 2;\\n build(v << 1, tl, tm, a);\\n build((v << 1) | 1, tm + 1, tr, a);\\n t[v] = cmb(t[v << 1], t[(v << 1) | 1]);\\n }\\n }\\n T qry(int l, int r) { return qry(1, 0, SZ - 1, l, r); }\\n T qry(int v, int tl, int tr, int l, int r) {\\n if (l > r) return id;\\n if (tl == l && tr == r) return t[v];\\n int tm = tl + (tr - tl) \\/ 2;\\n return cmb(qry(v << 1, tl, tm, l, min(r, tm)),\\n qry((v << 1) | 1, tm + 1, tr, max(l, tm + 1), r));\\n }\\n void upd(int u, T x) { upd(1, 0, SZ - 1, u, x); }\\n void upd(int v, int tl, int tr, int u, T x) {\\n if (tl == tr)\\n t[v] = x;\\n else {\\n int tm = tl + (tr - tl) \\/ 2;\\n if (u > tm)\\n upd((v << 1) | 1, tm + 1, tr, u, x);\\n else\\n upd(v << 1, tl, tm, u, x);\\n t[v] = cmb(t[v << 1], t[(v << 1) | 1]);\\n }\\n }\\n void chng(int u, T x) { chng(1, 0, SZ - 1, u, x); }\\n void chng(int v, int tl, int tr, int u, T x) {\\n if (tl == tr)\\n t[v] = cmb(t[v], x);\\n else {\\n int tm = tl + (tr - tl) \\/ 2;\\n if (u > tm)\\n chng((v << 1) | 1, tm + 1, tr, u, x);\\n else\\n chng(v << 1, tl, tm, u, x);\\n t[v] = cmb(t[v << 1], t[(v << 1) | 1]);\\n }\\n }\\n};\\nint tt;\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n cin >> tt;\\n while (tt--) {\\n int n, m;\\n cin >> n >> m;\\n vector> v(n...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Everyone knows that long ago on the territory of present-day Berland there lived Bindian tribes. Their capital was surrounded by n hills, forming a circle. On each hill there was a watchman, who watched the neighbourhood day and night.\\n\\nIn case of any danger the watchman could make a fire on the hill. One watchman could see the signal of another watchman, if on the circle arc connecting the two hills there was no hill higher than any of the two. As for any two hills there are two different circle arcs connecting them, the signal was seen if the above mentioned condition was satisfied on at least one of the arcs. For example, for any two neighbouring watchmen it is true that the signal of one will be seen by the other.\\n\\nAn important characteristics of this watch system was the amount of pairs of watchmen able to see each other's signals. You are to find this amount by the given heights of the hills.\\n\\nInput\\n\\nThe first line of the input data contains an integer number n (3 ≤ n ≤ 106), n — the amount of hills around the capital. The second line contains n numbers — heights of the hills in clockwise order. All height numbers are integer and lie between 1 and 109.\\n\\nOutput\\n\\nPrint the required amount of pairs.\\n\\nExamples\\n\\nInput\\n\\n5\\n1 2 4 5 3\\n\\n\\nOutput\\n\\n7\\\":\",\"targets\":\"#include \\nusing namespace std;\\nconst int G = 1000 * 1000 + 10;\\nint a[G], b[G], l[G], r[G], brbr[G];\\nstack> cnex, cper;\\nint main() {\\n int n;\\n cin >> n;\\n int mx = 0;\\n for (int i = 1; i <= n; i++) {\\n cin >> b[i];\\n if (b[i] > b[mx]) mx = i;\\n }\\n int y = 1;\\n a[0] = b[mx];\\n a[n] = b[mx];\\n for (int i = mx + 1; i <= n; i++) {\\n a[y] = b[i];\\n y++;\\n }\\n for (int i = 1; i < mx; i++) {\\n a[y] = b[i];\\n y++;\\n }\\n cnex.push(make_pair(a[n], n));\\n r[n] = n + 1;\\n r[0] = n + 1;\\n for (int i = n - 1; i > 0; i--) {\\n while (cnex.size() && cnex.top().first < a[i]) {\\n cnex.pop();\\n }\\n int u = cnex.top().second;\\n if (cnex.size()) {\\n if (a[i] == cnex.top().first) {\\n brbr[i] = brbr[cnex.top().second] + 1;\\n r[i] = r[u];\\n } else {\\n r[i] = u;\\n }\\n } else\\n r[i] = n + 1;\\n cnex.push(make_pair(a[i], i));\\n }\\n cper.push(make_pair(a[0], 0));\\n l[0] = -1;\\n l[n] = -1;\\n for (int i = 1; i < n; i++) {\\n while (cper.size() && cper.top().first <= a[i]) {\\n cper.pop();\\n }\\n if (cper.size() && a[i] != cper.top().first)\\n l[i] = cper.top().second;\\n else\\n l[i] = -1;\\n cper.push(make_pair(a[i], i));\\n }\\n long long ans = 0;\\n for (int i = 0; i < n; i++) {\\n if (l[i] != -1) {\\n if (l[i] != 0 || r[i] != n) {\\n ans++;\\n }\\n }\\n if (r[i] != n + 1) {\\n ans++;\\n }\\n ans += brbr[i];\\n }\\n cout << ans << endl;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alica and Bob are playing a game.\\n\\nInitially they have a binary string s consisting of only characters 0 and 1.\\n\\nAlice and Bob make alternating moves: Alice makes the first move, Bob makes the second move, Alice makes the third one, and so on. During each move, the current player must choose two different adjacent characters of string s and delete them. For example, if s = 1011001 then the following moves are possible: \\n\\n 1. delete s_1 and s_2: 1011001 → 11001; \\n 2. delete s_2 and s_3: 1011001 → 11001; \\n 3. delete s_4 and s_5: 1011001 → 10101; \\n 4. delete s_6 and s_7: 1011001 → 10110. \\n\\n\\n\\nIf a player can't make any move, they lose. Both players play optimally. You have to determine if Alice can win.\\n\\nInput\\n\\nFirst line contains one integer t (1 ≤ t ≤ 1000) — the number of test cases.\\n\\nOnly line of each test case contains one string s (1 ≤ |s| ≤ 100), consisting of only characters 0 and 1.\\n\\nOutput\\n\\nFor each test case print answer in the single line.\\n\\nIf Alice can win print DA (YES in Russian) in any register. Otherwise print NET (NO in Russian) in any register.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n01\\n1111\\n0011\\n\\n\\nOutput\\n\\n\\nDA\\nNET\\nNET\\n\\nNote\\n\\nIn the first test case after Alice's move string s become empty and Bob can not make any move.\\n\\nIn the second test case Alice can not make any move initially.\\n\\nIn the third test case after Alice's move string s turn into 01. Then, after Bob's move string s become empty and Alice can not make any move.\",\"targets\":\"from collections import Counter, defaultdict\\n\\nBS=\\\"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\ndef to_base(s, b):\\n res = \\\"\\\"\\n while s:\\n res+=BS[s%b]\\n s\\/\\/= b\\n return res[::-1] or \\\"0\\\"\\nalpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nfrom math import floor, ceil,pi\\n\\nprimes =...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.\\n\\nInitially, there are n superheroes in avengers team having powers a_1, a_2, …, a_n, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by 1. They can do at most m operations. Also, on a particular superhero at most k operations can be done.\\n\\nCan you help the avengers team to maximize the average power of their crew?\\n\\nInput\\n\\nThe first line contains three integers n, k and m (1 ≤ n ≤ 10^{5}, 1 ≤ k ≤ 10^{5}, 1 ≤ m ≤ 10^{7}) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.\\n\\nThe second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^{6}) — the initial powers of the superheroes in the cast of avengers.\\n\\nOutput\\n\\nOutput a single number — the maximum final average power.\\n\\nYour answer is considered correct if its absolute or relative error does not exceed 10^{-6}.\\n\\nFormally, let your answer be a, and the jury's answer be b. Your answer is accepted if and only if \\\\frac{|a - b|}{max{(1, |b|)}} ≤ 10^{-6}.\\n\\nExamples\\n\\nInput\\n\\n\\n2 4 6\\n4 7\\n\\n\\nOutput\\n\\n\\n11.00000000000000000000\\n\\n\\nInput\\n\\n\\n4 2 6\\n1 3 2 3\\n\\n\\nOutput\\n\\n\\n5.00000000000000000000\\n\\nNote\\n\\nIn the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.\\n\\nIn the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by 2 each.\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\nimport static java.lang.Math.*;\\npublic class Main {\\n static final long MOD = 1_000_000_007, INF = 1_000_000_000_000_000_000L;\\n static final int INf = 1_000_000_000;\\n static FastReader reader;\\n static PrintWriter writer;\\n public static void main(String[] args) {\\n Thread t = new Thread(null, new O(), \\\"Integer.MAX_VALUE\\\", 100000000);\\n t.start();\\n }\\n static class O implements Runnable {\\n public void run() {\\n try {\\n magic();\\n }\\n catch (Exception e) {\\n e.printStackTrace();\\n System.exit(1);\\n }\\n }\\n }\\n static class FastReader {\\n final private int BUFFER_SIZE = 1 << 16;\\n private DataInputStream din;\\n private byte[] buffer;\\n private int bufferPointer, bytesRead;\\n\\n public FastReader() {\\n din = new DataInputStream(System.in);\\n buffer = new byte[BUFFER_SIZE];\\n bufferPointer = bytesRead = 0;\\n }\\n\\n public FastReader(String file_name) throws IOException {\\n din = new DataInputStream(new FileInputStream(file_name));\\n buffer = new byte[BUFFER_SIZE];\\n bufferPointer = bytesRead = 0;\\n }\\n\\n public String readLine() throws IOException {\\n byte[] buf = new byte[1000000];\\n int cnt = 0, c;\\n while ((c = read()) != -1) {\\n if (c == '\\\\n') break;\\n buf[cnt++] = (byte) c;\\n }\\n return new String(buf, 0, cnt);\\n }\\n\\n public int nextInt() throws IOException {\\n int ret = 0;\\n byte c = read();\\n while (c <= ' ') c = read();\\n boolean neg = (c == '-');\\n if (neg) c = read();\\n do {\\n ret = ret * 10 + c - '0';\\n } while ((c = read()) >= '0' && c <= '9');\\n if (neg) return -ret;\\n return ret;\\n }\\n\\n public long nextLong() throws IOException...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Archaeologists found some information about an ancient land of Treeland. We know for sure that the Treeland consisted of n cities connected by the n - 1 road, such that you can get from each city to any other one along the roads. However, the information about the specific design of roads in Treeland has been lost. The only thing that the archaeologists can use is the preserved information about near cities.\\n\\nTwo cities of Treeland were called near, if it were possible to move from one city to the other one by moving through at most two roads. Also, a city is considered near to itself. During the recent excavations archaeologists found a set of n notes, each of them represents a list of cities, near to some of the n cities of the country. However, unfortunately, none of the found records lets you understand in what order the cities go in the list and for which city in the list the near to it cities were listed. \\n\\nHelp the archaeologists and restore any variant of the map of Treeland that meets the found information.\\n\\nInput\\n\\nThe first line contains integer n (2 ≤ n ≤ 1000) — the number of cities in the country. \\n\\nNext n lines describe the found lists of near cities. Each list starts from number k (1 ≤ k ≤ n), representing the number of cities in the list followed by k city numbers. All numbers in each list are distinct.\\n\\nIt is guaranteed that the given information determines at least one possible road map.\\n\\nOutput\\n\\nPrint n - 1 pairs of numbers representing the roads of the country. The i-th line must contain two integers ai, bi (1 ≤ ai, bi ≤ n, ai ≠ bi), showing that there is a road between cities ai and bi.\\n\\nThe answer you print must satisfy the description of close cities from the input. You may print the roads of the countries in any order. The cities that are connected by a road may also be printed in any order.\\n\\nIf there are multiple good answers, you may print any of them.\\n\\nExamples\\n\\nInput\\n\\n5\\n4 3 2 4 1\\n5 5 3 2 4 1\\n5 4 2 1 5 3\\n4 2 1 4 3\\n3 1 4 5\\n\\n\\nOutput\\n\\n1 4\\n1 2\\n1 3\\n4 5\\n\\n\\nInput\\n\\n6\\n5 6 1 3 4 2\\n5 2 1 3 4...\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nnamespace SHENZHEBEI {\\nstatic const int GYN = 2333333;\\nchar SZB[GYN], *S = SZB, *T = SZB;\\ninline char gc() {\\n if (S == T) {\\n T = (S = SZB) + fread(SZB, 1, GYN, stdin);\\n if (S == T) return '\\\\n';\\n }\\n return *S++;\\n}\\ninline int read() {\\n int x = 0, g = 1;\\n char ch = gc();\\n for (; !isdigit(ch); ch = gc())\\n if (ch == '-') g = -1;\\n for (; isdigit(ch); ch = gc()) x = x * 10 - 48 + ch;\\n return x * g;\\n}\\ninline void write(int x) {\\n if (x < 0) putchar('-'), x = -x;\\n if (x >= 10) write(x \\/ 10);\\n putchar(x % 10 + '0');\\n}\\ninline char readchar() {\\n char ch = gc();\\n for (; isspace(ch); ch = gc())\\n ;\\n return ch;\\n}\\ninline int readstr(char *s) {\\n char ch = gc();\\n int cur = 0;\\n for (; isspace(ch); ch = gc())\\n ;\\n for (; !isspace(ch); ch = gc()) s[cur++] = ch;\\n s[cur] = '\\\\0';\\n return cur;\\n}\\nvoid Print(long long *a, int s, int t) {\\n for (int i = int(s); i <= int(t); ++i) printf(\\\"%lld \\\", a[i]);\\n puts(\\\"\\\");\\n}\\nvoid Print(int *a, int s, int t) {\\n for (int i = int(s); i <= int(t); ++i) printf(\\\"%d \\\", a[i]);\\n puts(\\\"\\\");\\n}\\nvoid Print(char *a, int s, int t) {\\n for (int i = int(s); i <= int(t); ++i) putchar(a[i]);\\n puts(\\\"\\\");\\n}\\nvoid writeln(int x) { write(x), puts(\\\"\\\"); }\\nvoid rewrite(int x, int y) {\\n write(x), putchar(' ');\\n writeln(y);\\n}\\n} \\/\\/ namespace SHENZHEBEI\\nusing namespace SHENZHEBEI;\\nconst int N = 2010;\\nint fa[N], n, cnt, ok[N], rt1, rt2, Cnt;\\nvector > edge[N];\\nbitset<1010> a[N];\\nint find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }\\nvoid same(int x, int y) {\\n fa[find(x)] = find(y);\\n fa[find(x + n)] = find(y + n);\\n}\\nvoid unsame(int x, int y) {\\n fa[find(x)] = find(y + n);\\n fa[find(x + n)] = find(y);\\n}\\nint main() {\\n n = read();\\n if (n == 1) return 0;\\n if (n == 2) return puts(\\\"1 2\\\"), 0;\\n for (int i = int(1); i <= int(n); ++i) {\\n int sum = read();\\n for (int j = int(1); j <= int(sum); ++j) a[read()][i] = 1;\\n }\\n for (int i = int(1); i <= int(2 * n); ++i) fa[i] = i;\\n for (int i = int(1); i <= int(n); ++i)\\n for...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nMonocarp is playing a computer game. Now he wants to complete the first level of this game.\\n\\nA level is a rectangular grid of 2 rows and n columns. Monocarp controls a character, which starts in cell (1, 1) — at the intersection of the 1-st row and the 1-st column.\\n\\nMonocarp's character can move from one cell to another in one step if the cells are adjacent by side and\\/or corner. Formally, it is possible to move from cell (x_1, y_1) to cell (x_2, y_2) in one step if |x_1 - x_2| ≤ 1 and |y_1 - y_2| ≤ 1. Obviously, it is prohibited to go outside the grid.\\n\\nThere are traps in some cells. If Monocarp's character finds himself in such a cell, he dies, and the game ends.\\n\\nTo complete a level, Monocarp's character should reach cell (2, n) — at the intersection of row 2 and column n.\\n\\nHelp Monocarp determine if it is possible to complete the level.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. Then the test cases follow. Each test case consists of three lines.\\n\\nThe first line contains a single integer n (3 ≤ n ≤ 100) — the number of columns.\\n\\nThe next two lines describe the level. The i-th of these lines describes the i-th line of the level — the line consists of the characters '0' and '1'. The character '0' corresponds to a safe cell, the character '1' corresponds to a trap cell.\\n\\nAdditional constraint on the input: cells (1, 1) and (2, n) are safe.\\n\\nOutput\\n\\nFor each test case, output YES if it is possible to complete the level, and NO otherwise.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n000\\n000\\n4\\n0011\\n1100\\n4\\n0111\\n1110\\n6\\n010101\\n101010\\n\\n\\nOutput\\n\\n\\nYES\\nYES\\nNO\\nYES\\n\\nNote\\n\\nConsider the example from the statement.\\n\\nIn the first test case, one of the possible paths is (1, 1) → (2, 2) → (2, 3).\\n\\nIn the second test case, one of the possible paths is (1, 1) → (1, 2) → (2, 3) → (2, 4).\\n\\nIn the fourth test case, one of the possible paths is (1, 1) → (2, 2) → (1, 3) → (2, 4) → (1, 5) → (2, 6).\",\"targets\":\"#include \\nusing namespace std;\\nint dy[] = {1, 1, 1};\\nint dx[] = {1, 0, -1};\\nvoid traverse(int x, int y, vector > &ans, int n, bool &flag) {\\n if (flag == true) return;\\n if (x == 1 and y == n - 1) {\\n flag = true;\\n return;\\n }\\n for (int k = 0; k < 3; k++) {\\n if (!flag and x + dx[k] >= 0 and x + dx[k] <= 1 and y + dy[k] >= 0 and\\n y + dy[k] <= n - 1 and ans[x + dx[k]][y + dy[k]] == 0) {\\n return (traverse(x + dx[k], y + dy[k], ans, n, flag));\\n }\\n }\\n}\\nint main() {\\n int t;\\n cin >> t;\\n while (t--) {\\n int n;\\n cin >> n;\\n vector > ans(2, vector(n, 0));\\n string stub;\\n for (int i = 0; i < 2; i++) {\\n string temp;\\n cin >> temp;\\n stub += temp;\\n }\\n int start = 0;\\n for (int i = 0; i < 2; i++) {\\n for (int j = 0; j < n; j++) {\\n ans[i][j] = stub[start] - '0';\\n start++;\\n }\\n }\\n bool flag = false;\\n traverse(0, 0, ans, n, flag);\\n if (flag)\\n cout << \\\"YES\\\";\\n else\\n cout << \\\"NO\\\";\\n cout << endl;\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"YouKn0wWho has two even integers x and y. Help him to find an integer n such that 1 ≤ n ≤ 2 ⋅ 10^{18} and n mod x = y mod n. Here, a mod b denotes the remainder of a after division by b. If there are multiple such integers, output any. It can be shown that such an integer always exists under the given constraints.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^5) — the number of test cases.\\n\\nThe first and only line of each test case contains two integers x and y (2 ≤ x, y ≤ 10^9, both are even).\\n\\nOutput\\n\\nFor each test case, print a single integer n (1 ≤ n ≤ 2 ⋅ 10^{18}) that satisfies the condition mentioned in the statement. If there are multiple such integers, output any. It can be shown that such an integer always exists under the given constraints.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n4 8\\n4 2\\n420 420\\n69420 42068\\n\\n\\nOutput\\n\\n\\n4\\n10\\n420\\n9969128\\n\\nNote\\n\\nIn the first test case, 4 mod 4 = 8 mod 4 = 0.\\n\\nIn the second test case, 10 mod 4 = 2 mod 10 = 2.\\n\\nIn the third test case, 420 mod 420 = 420 mod 420 = 0.\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int t;\\n cin >> t;\\n while (t--) {\\n long long int x, y;\\n cin >> x >> y;\\n if (x > y)\\n cout << x + y << '\\\\n';\\n else if (x == y)\\n cout << x << '\\\\n';\\n else {\\n long long int k = (x + y) \\/ 2;\\n if (y < 2 * x) {\\n cout << k << '\\\\n';\\n } else if (!(y % x)) {\\n cout << x << '\\\\n';\\n } else {\\n cout << ((y \\/ x) * x + y) \\/ 2 << '\\\\n';\\n }\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nIt is said that a legendary treasure left by Mr. Yao is sleeping somewhere in Hachioji long ago. The treasure map, which is said to show its whereabouts, has been handed down by Yao's n descendants, divided into several pieces.\\n\\nNow, the descendants of Mr. Yao were trying to cooperate to obtain the treasure. However, the treasure cannot be found only by a part of the treasure map that points to the location of the treasure. Therefore, all the descendants of Mr. Yao gathered and tried to collect the map in one place. However, even if I tried to put it into practice, I couldn't get together because I couldn't meet the schedule. However, this information about the treasure is valuable information that has been secretly passed down in the clan. Considering the risk of leakage, exchanging maps using public communication means is out of the question.\\n\\nTherefore, I decided to collect the map for one descendant by repeating the process of meeting the descendants in person and handing over the map. There is no limit to the number of people that one person can meet in a day, but it is necessary that there is a schedule for each other.\\n\\nYour job is to write a program that asks for at least how many days it will take to collect a map from a list of open days on schedule for each offspring.\\n\\nBy the way, the unity of the Yao clan is very tight. If the descendants who finally get the entire map betray the other descendants and take away the treasure, they will be sanctioned by the clan. The sanctions are so horrifying that it is virtually impossible for their descendants to actually carry away the treasure.\\n\\n\\n\\nInput\\n\\nThe input consists of multiple datasets.\\n\\nEach dataset consists of multiple rows. The first line contains the integer n (1 \\n\\nusing namespace std;\\ntypedef long long int ll;\\ntypedef pair P;\\ntypedef pair Pll;\\ntypedef vector Vi;\\ntypedef tuple T;\\n#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)\\n#define REP(i,x) FOR(i,0,x)\\n#define ALL(c) c.begin(), c.end()\\n#define DUMP( x ) cerr << #x << \\\" = \\\" << ( x ) << endl\\n\\nconst int dr[4] = {-1, 0, 1, 0};\\nconst int dc[4] = {0, 1, 0, -1};\\n\\nint N;\\nbool s[50][50];\\n\\nbool check() {\\n REP(i, N) {\\n bool flag = true;\\n REP(j, N) flag &= s[i][j];\\n if (flag) return true;\\n }\\n return false;\\n}\\n\\nint main() {\\n \\/\\/ use scanf in CodeForces!\\n cin.tie(0);\\n ios_base::sync_with_stdio(false);\\n\\n while (true) {\\n cin >> N;\\n if (N == 0) break;\\n Vi edge[30];\\n REP(i, N) {\\n int c;\\n cin >> c;\\n REP(j, c) {\\n\\tint k;\\n\\tcin >> k; k--;\\n\\tedge[k].push_back(i);\\n }\\n }\\n\\n REP(i, N) fill(s[i], s[i] + N, false);\\n REP(d, 30) {\\n for (int i : edge[d]) {\\n\\tfor (int j : edge[d]) {\\n\\t s[i][j] = true;\\n\\t REP(k, N) s[i][k] |= s[j][k];\\n\\t}\\n }\\n if (check()) {\\n\\tcout << d + 1 << endl;\\n\\tbreak;\\n } else if (d == 29) {\\n\\tcout << -1 << endl;\\n\\tbreak;\\n }\\n }\\t\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"After getting bored by playing with crayons, you decided to switch to Legos! Today, you're working with a long strip, with height 1 and length n, some positions of which are occupied by 1 by 1 Lego pieces.\\n\\nIn one second, you can either remove two adjacent Lego pieces from the strip (if both are present), or add two Lego pieces to adjacent positions (if both are absent). You can only add or remove Lego's at two adjacent positions at the same time, as otherwise your chubby fingers run into precision issues.\\n\\nYou want to know exactly how much time you'll spend playing with Legos. You value efficiency, so given some starting state and some ending state, you'll always spend the least number of seconds to transform the starting state into the ending state. If it's impossible to transform the starting state into the ending state, you just skip it (so you spend 0 seconds).\\n\\nThe issue is that, for some positions, you don't remember whether there were Legos there or not (in either the starting state, the ending state, or both). Over all pairs of (starting state, ending state) that are consistent with your memory, find the total amount of time it will take to transform the starting state to the ending state. Print this value modulo 1 000 000 007 (10^9 + 7). \\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 1000) — the number of test cases. Then t cases follow.\\n\\nThe first line of each test case contains one integer n (2 ≤ n ≤ 2000) — the size of the Lego strip.\\n\\nThe second line of each test case contains a string s of length n, consisting of the characters 0, 1, and ? — your memory of the starting state: \\n\\n * 1 represents a position that definitely has a Lego piece, \\n * 0 represents a position that definitely does not have a Lego piece, \\n * and ? represents a position that you don't remember. \\n\\n\\n\\nThe third line of each test case contains a string t of length n, consisting of the characters 0, 1, and ? — your memory of the ending state. It follows a similar format to the starting state.\\n\\nIt's guaranteed that the...\\n#incl\",\"targets\":\"ude \\nconst int mod = 1000000007;\\nconst int gmod = 3;\\nconst int inf = 1039074182;\\nconst double eps = 1e-9;\\nconst double pi = 3.141592653589793238462643383279;\\nconst long long llinf = 2LL * inf * inf;\\ntemplate \\ninline void chmin(T1 &x, T2 b) {\\n if (b < x) x = b;\\n}\\ntemplate \\ninline void chmax(T1 &x, T2 b) {\\n if (b > x) x = b;\\n}\\ninline void chadd(int &x, int b) {\\n x += b - mod;\\n x += (x >> 31 & mod);\\n}\\ntemplate \\ninline void chadd(T1 &x, T2 b) {\\n x += b;\\n if (x >= mod) x -= mod;\\n}\\ntemplate \\ninline void chmul(T1 &x, T2 b) {\\n x = 1LL * x * b % mod;\\n}\\ntemplate \\ninline void chmod(T1 &x, T2 b) {\\n x %= b, x += b;\\n if (x >= b) x -= b;\\n}\\ntemplate \\ninline T mabs(T x) {\\n return (x < 0 ? -x : x);\\n}\\nusing namespace std;\\nusing namespace std;\\ntemplate \\nostream &operator<<(ostream &cout, const vector &vec) {\\n cout << \\\"{\\\";\\n for (int i = 0; i < (int)vec.size(); i++) {\\n cout << vec[i];\\n if (i != (int)vec.size() - 1) cout << ',';\\n }\\n cout << \\\"}\\\";\\n return cout;\\n}\\ntemplate \\nostream &operator<<(ostream &cout, pair p) {\\n cout << \\\"(\\\" << p.first << ',' << p.second << \\\")\\\";\\n return cout;\\n}\\ntemplate \\nostream &operator<<(ostream &cout, set s) {\\n vector t;\\n for (auto x : s) t.push_back(x);\\n cout << t;\\n return cout;\\n}\\ntemplate \\nostream &operator<<(ostream &cout, multiset s) {\\n vector t;\\n for (auto x : s) t.push_back(x);\\n cout << t;\\n return cout;\\n}\\ntemplate \\nostream &operator<<(ostream &cout, queue q) {\\n vector t;\\n while (q.size()) {\\n t.push_back(q.front());\\n q.pop();\\n }\\n cout << t;\\n return cout;\\n}\\ntemplate \\nostream &operator<<(ostream &cout, map m) {\\n for (auto &x : m) {\\n cout << \\\"Key: \\\" << x.first << ' ' << \\\"Value: \\\" << x.second << endl;\\n }\\n return...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Akaki, a patissier, can make N kinds of doughnut using only a certain powder called \\\"Okashi no Moto\\\" (literally \\\"material of pastry\\\", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts.\\n\\nNow, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition:\\n\\n* For each of the N kinds of doughnuts, make at least one doughnut of that kind.\\n\\n\\n\\nAt most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.\\n\\nConstraints\\n\\n* 2 ≤ N ≤ 100\\n* 1 ≤ m_i ≤ 1000\\n* m_1 + m_2 + ... + m_N ≤ X ≤ 10^5\\n* All values in input are integers.\\n\\nInput\\n\\nInput is given from Standard Input in the following format:\\n\\n\\nN X\\nm_1\\nm_2\\n:\\nm_N\\n\\n\\nOutput\\n\\nPrint the maximum number of doughnuts that can be made under the condition.\\n\\nExamples\\n\\nInput\\n\\n3 1000\\n120\\n100\\n140\\n\\n\\nOutput\\n\\n9\\n\\n\\nInput\\n\\n4 360\\n90\\n90\\n90\\n90\\n\\n\\nOutput\\n\\n4\\n\\n\\nInput\\n\\n5 3000\\n150\\n130\\n150\\n130\\n110\\n\\n\\nOutput\\n\\n26\\nimpor\",\"targets\":\"t java.util.Arrays;\\nimport java.util.Scanner;\\npublic class Main {\\n\\tpublic static void main(String[] args) {\\n\\t\\tScanner sc = new Scanner(System.in);\\n\\t\\tint N = sc.nextInt();\\n\\t\\tint X = sc.nextInt();\\n\\t\\tInteger[] m = new Integer[N];\\n\\t\\tint M = 0;\\n\\t\\tfor (int i=0; i\\n\\nWilliam is not only interested in trading but also in betting on sports matches. n teams participate in each match. Each team is characterized by strength a_i. Each two teams i < j play with each other exactly once. Team i wins with probability (a_i)\\/(a_i + a_j) and team j wins with probability (a_j)\\/(a_i + a_j).\\n\\nThe team is called a winner if it directly or indirectly defeated all other teams. Team a defeated (directly or indirectly) team b if there is a sequence of teams c_1, c_2, ... c_k such that c_1 = a, c_k = b and team c_i defeated team c_{i + 1} for all i from 1 to k - 1. Note that it is possible that team a defeated team b and in the same time team b defeated team a.\\n\\nWilliam wants you to find the expected value of the number of winners.\\n\\nInput\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 14), which is the total number of teams participating in a match.\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^6) — the strengths of teams participating in a match.\\n\\nOutput\\n\\nOutput a single integer — the expected value of the number of winners of the tournament modulo 10^9 + 7.\\n\\nFormally, let M = 10^9+7. It can be demonstrated that the answer can be presented as a irreducible fraction p\\/q, where p and q are integers and q not ≡ 0 \\\\pmod{M}. Output a single integer equal to p ⋅ q^{-1} mod M. In other words, output an integer x such that 0 ≤ x < M and x ⋅ q ≡ p \\\\pmod{M}.\\n\\nExamples\\n\\nInput\\n\\n\\n2\\n1 2\\n\\n\\nOutput\\n\\n\\n1\\n\\n\\nInput\\n\\n\\n5\\n1 5 2 11 14\\n\\n\\nOutput\\n\\n\\n642377629\\n\\nNote\\n\\nTo better understand in which situation several winners are possible let's examine the second test:\\n\\nOne possible result of the tournament is as follows (a → b means that a defeated b):\\n\\n * 1 → 2 \\n * 2 → 3 \\n * 3 → 1 \\n * 1 → 4 \\n * 1 → 5 \\n * 2 → 4 \\n * 2 → 5 \\n * 3 → 4 \\n * 3 → 5 \\n * 4 → 5 \\n\\n\\n\\nOr more clearly in the picture:\\n\\n\\n\\nIn this case every team from the set \\\\{ 1, 2, 3 \\\\} directly or indirectly defeated everyone. I.e.:\\n\\n * 1st defeated everyone because they can get to everyone else in the following way...\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\ninline int read() {\\n int res = 0, f = 1;\\n char ch;\\n while (ch = getchar(), ch < '0' || ch > '9')\\n if (ch == '-') f = -1;\\n while (ch >= '0' && ch <= '9') res = res * 10 + ch - '0', ch = getchar();\\n return res * f;\\n}\\nconst int N = 14, M = 4782969, P = 1e9 + 7;\\ninline int qpow(int a, int b) {\\n int ans = 1, base = a;\\n while (b) {\\n if (b & 1) ans = 1ll * ans * base % P;\\n base = 1ll * base * base % P;\\n b >>= 1;\\n }\\n return ans;\\n}\\nint rev[1 << N], cnt[1 << N], n, A, a[N];\\nint F[1 << N], G[1 << N], v[N][1 << N];\\ninline int get(int S, int T) {\\n if (!S) return 1;\\n if (G[S]) return G[S];\\n return G[S] = 1ll * get(S & (S - 1), T) * v[rev[S & -S]][T] % P;\\n}\\nint main() {\\n n = read(), A = (1 << n) - 1;\\n for (int i = 0; i < n; ++i) a[i] = read(), rev[1 << i] = i;\\n for (int i = 0; i < n; ++i) {\\n v[i][0] = 1;\\n for (int S = 1; S < (1 << n); ++S)\\n v[i][S] = 1ll * v[i][S & (S - 1)] * a[i] % P *\\n qpow((a[rev[S & -S]] + a[i]) % P, P - 2) % P;\\n }\\n for (int S = 1; S < (1 << n); ++S) {\\n int tmp = 0;\\n cnt[S] = cnt[S >> 1] + (S & 1);\\n for (int T = (S - 1) & S; T; T = (T - 1) & S)\\n (tmp += 1ll * F[T] * get(S ^ T, A ^ S) % P) %= P;\\n F[S] = (get(S, A ^ S) - tmp + P) % P;\\n for (int T = S; T; T = (T - 1) & S) G[T] = 0;\\n }\\n int res = 0;\\n for (int S = 1; S < (1 << n); ++S) (res += 1ll * F[S] * cnt[S] % P) %= P;\\n printf(\\\"%d\\\", res);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"The only difference between this problem and D1 is that you don't have to provide the way to construct the answer in D1, but you have to do it in this problem.\\n\\nThere's a table of n × m cells (n rows and m columns). The value of n ⋅ m is even.\\n\\nA domino is a figure that consists of two cells having a common side. It may be horizontal (one of the cells is to the right of the other) or vertical (one of the cells is above the other).\\n\\nYou need to place nm\\/2 dominoes on the table so that exactly k of them are horizontal and all the other dominoes are vertical. The dominoes cannot overlap and must fill the whole table.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of a single line. The line contains three integers n, m, k (1 ≤ n,m ≤ 100, 0 ≤ k ≤ nm\\/2, n ⋅ m is even) — the count of rows, columns and horizontal dominoes, respectively.\\n\\nOutput\\n\\nFor each test case:\\n\\n * print \\\"NO\\\" if it's not possible to place the dominoes on the table in the described way; \\n * otherwise, print \\\"YES\\\" on a separate line, then print n lines so that each of them contains m lowercase letters of the Latin alphabet — the layout of the dominoes on the table. Each cell of the table must be marked by the letter so that for every two cells having a common side, they are marked by the same letters if and only if they are occupied by the same domino. I.e. both cells of the same domino must be marked with the same letter, but two dominoes that share a side must be marked with different letters. If there are multiple solutions, print any of them. \\n\\nExample\\n\\nInput\\n\\n\\n8\\n4 4 2\\n2 3 0\\n3 2 3\\n1 2 0\\n2 4 2\\n5 2 2\\n2 17 16\\n2 1 1\\n\\n\\nOutput\\n\\n\\nYES\\naccx\\naegx\\nbega\\nbdda\\nYES\\naha\\naha\\nYES\\nzz\\naa\\nzz\\nNO\\nYES\\naaza\\nbbza\\nNO\\nYES\\nbbaabbaabbaabbaay\\nddccddccddccddccy\\nNO\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\npublic class D2 {\\n static char[][] output;\\n public static void main(String[] args){\\n Scanner s = new Scanner(System.in);\\n for (int t=s.nextInt(); t>0; t--) {\\n int n = s.nextInt();\\n int m = s.nextInt();\\n int k = s.nextInt();\\n int l = m * n \\/ 2 - k;\\n output = new char[n][m];\\n if (n % 2 == 1) {\\n if (m \\/ 2 > k || (k - m \\/ 2) % 2 == 1) {\\n System.out.println(\\\"NO\\\");\\n } else {\\n System.out.println(\\\"YES\\\");\\n k -= m\\/2;\\n for (int i=0; i l || (l - n \\/ 2) % 2 == 1) {\\n System.out.println(\\\"NO\\\");\\n } else {\\n System.out.println(\\\"YES\\\");\\n for (int i=0; i 0 ? (i % 4 < 2 ? (j % 4 < 2 ? (i % 2 == 0 ? (j % 2 == 0 ? 'c' : 'c' + --k * 0) : (j % 2 == 0 ? 'd' : 'd' + --k * 0)) : (i % 2 == 0 ? (j % 2 == 0 ? 'e' : 'e' + --k * 0) : (j % 2 == 0 ? 'f' : 'f' + --k * 0))) : (j % 4 < 2 ? (i % 2 == 0 ? (j % 2 == 0 ? 'g' : 'g' + --k * 0) : (j % 2 == 0 ? 'h' : 'h' + --k *...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given an array a of length n.\\n\\nLet's define the eversion operation. Let x = a_n. Then array a is partitioned into two parts: left and right. The left part contains the elements of a that are not greater than x (≤ x). The right part contains the elements of a that are strictly greater than x (> x). The order of elements in each part is kept the same as before the operation, i. e. the partition is stable. Then the array is replaced with the concatenation of the left and the right parts.\\n\\nFor example, if the array a is [2, 4, 1, 5, 3], the eversion goes like this: [2, 4, 1, 5, 3] → [2, 1, 3], [4, 5] → [2, 1, 3, 4, 5].\\n\\nWe start with the array a and perform eversions on this array. We can prove that after several eversions the array a stops changing. Output the minimum number k such that the array stops changing after k eversions.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 100). Description of the test cases follows.\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 2 ⋅ 10^5).\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9).\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case print a single integer k — the number of eversions after which the array stops changing.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n5\\n2 4 1 5 3\\n5\\n5 3 2 4 1\\n4\\n1 1 1 1\\n\\n\\nOutput\\n\\n\\n1\\n2\\n0\\n\\nNote\\n\\nConsider the fist example.\\n\\n * The first eversion: a = [1, 4, 2, 5, 3], x = 3. [2, 4, 1, 5, 3] → [2, 1, 3], [4, 5] → [2, 1, 3, 4, 5]. \\n * The second and following eversions: a = [2, 1, 3, 4, 5], x = 5. [2, 1, 3, 4, 5] → [2, 1, 3, 4, 5], [] → [2, 1, 3, 4, 5]. This eversion does not change the array, so the answer is 1. \\n\\n\\n\\nConsider the second example. \\n\\n * The first eversion: a = [5, 3, 2, 4, 1], x = 1. [5, 3, 2, 4, 1] → [1], [5, 3, 2, 4] → [1, 5, 3, 2, 4]. \\n * The second eversion: a = [1, 5, 3, 2, 4], x = 4. [1, 5, 3, 2, 4] → [1, 3, 2, 4], [5] → [1, 3, 2, 4, 5]. \\n * The third and following eversions: a = [1, 3, 2, 4,...\\nUsing java can you solve the prior task?\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\nimport java.math.BigInteger;\\n\\npublic class Main {\\n\\tstatic int[][] grid;\\n\\n\\tstatic int res[][];\\n\\n\\tpublic static void main(String[] args) throws IOException, InterruptedException {\\n\\t\\tScanner sc = new Scanner(System.in);\\n\\t\\tPrintWriter pw = new PrintWriter(System.out);\\n\\t\\tint t = sc.nextInt();\\n\\t\\twhile (t-- > 0) {\\n\\t\\t\\tint n = sc.nextInt();\\n\\t\\t\\tlong [] arr = new long[n];\\n\\t\\t\\tlong max = 0;\\n\\t\\t\\tfor (int i = 0; i < arr.length; i++) {\\n\\t\\t\\t\\tarr[i] = sc.nextLong();\\n\\t\\t\\t\\tmax = Math.max(max, arr[i]);\\n\\t\\t\\t}\\n\\t\\t\\tif(arr[n-1]==max) {\\n\\t\\t\\t\\tpw.println(0);\\n\\t\\t\\t}\\n\\t\\t\\telse {\\n\\t\\t\\t\\tint res = 1;\\n\\t\\t\\t\\tlong curr = arr[n-1];\\n\\t\\t\\t\\tfor (int i = n-2; i >=0; i--) {\\n\\t\\t\\t\\t\\tif(arr[i]>curr) {\\n\\t\\t\\t\\t\\t\\tif(arr[i]==max)\\n\\t\\t\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t\\t\\tcurr = arr[i];\\n\\t\\t\\t\\t\\t\\tres++;\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tpw.println(res);\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\tpw.flush();\\n\\t}\\n\\n\\tpublic static void solve(int i, int j) {\\n\\n\\t\\tif (valid(i, j)) {\\n\\t\\t\\tif (res[i][j] == -5 || res[i][j] == 1)\\n\\t\\t\\t\\treturn;\\n\\t\\t\\tint c = 0;\\n\\t\\t\\tint c2 = 0;\\n\\t\\t\\tif (valid(i + 1, j)) {\\n\\t\\t\\t\\tc++;\\n\\t\\t\\t\\tif (res[i + 1][j] == 1||res[i+1][j]==-5)\\n\\t\\t\\t\\t\\tc2++;\\n\\t\\t\\t}\\n\\t\\t\\tif (valid(i, j + 1)) {\\n\\t\\t\\t\\tc++;\\n\\t\\t\\t\\t\\n\\t\\t\\t\\tif (res[i ][j+1] == 1||res[i][j+1]==-5)\\n\\t\\t\\t\\t\\tc2++;\\n\\t\\t\\t}\\n\\t\\t\\tif (valid(i, j - 1)) {\\n\\t\\t\\t\\tc++;\\n\\t\\t\\t\\t\\n\\t\\t\\t\\tif (res[i][j - 1] == 1||res[i][j-1]==-5)\\n\\t\\t\\t\\t\\tc2++;\\n\\t\\t\\t}\\n\\t\\t\\tif (valid(i - 1, j)) {\\n\\t\\t\\t\\tc++;\\n\\t\\t\\t\\t\\n\\t\\t\\t\\tif (res[i - 1][j] == 1||res[i-1][j]==-5)\\n\\t\\t\\t\\t\\tc2++;\\n\\t\\t\\t}\\n\\t\\t\\tif (c == 0)\\n\\t\\t\\t\\treturn;\\n\\t\\t\\tif(c-c2<=1) {\\n\\t\\t\\t\\tres[i][j] = 1;\\n\\t\\t\\t\\tsolve(i,j+1);\\n\\t\\t\\t\\tsolve(i,j-1);\\n\\t\\t\\t\\tsolve(i+1,j);\\n\\t\\t\\t\\tsolve(i-1,j);\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n\\tpublic static boolean valid(int i, int j) {\\n\\t\\tif (i < 0)\\n\\t\\t\\treturn false;\\n\\t\\tif (i >= grid.length)\\n\\t\\t\\treturn false;\\n\\t\\tif (j < 0)\\n\\t\\t\\treturn false;\\n\\t\\tif (j >= grid[0].length)\\n\\t\\t\\treturn false;\\n\\t\\tif (grid[i][j] == -1)\\n\\t\\t\\treturn false;\\n\\t\\treturn true;\\n\\t}\\n}\\n\\nclass segTree {\\n\\tlong[] arr, sTree;\\n\\tint n;\\n\\n\\tpublic segTree(long[] a) {\\n\\t\\tn = 1;\\n\\t\\twhile (n < a.length)\\n\\t\\t\\tn <<= 1;\\n\\n\\t\\tarr = new long[n + 1];\\n\\t\\tArrays.fill(arr, Long.MAX_VALUE);\\n\\t\\tfor (int i = 0; i < a.length; i++) {\\n\\t\\t\\tarr[i + 1] = a[i];\\n\\t\\t}\\n\\t\\tsTree = new long[n << 1];\\n\\t\\tbuild(1,...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"A known chef has prepared n dishes: the i-th dish consists of a_i grams of fish and b_i grams of meat. \\n\\nThe banquet organizers estimate the balance of n dishes as follows. The balance is equal to the absolute value of the difference between the total mass of fish and the total mass of meat.\\n\\nTechnically, the balance equals to \\\\left|∑_{i=1}^n a_i - ∑_{i=1}^n b_i\\\\right|. The smaller the balance, the better.\\n\\nIn order to improve the balance, a taster was invited. He will eat exactly m grams of food from each dish. For each dish, the taster determines separately how much fish and how much meat he will eat. The only condition is that he should eat exactly m grams of each dish in total.\\n\\nDetermine how much of what type of food the taster should eat from each dish so that the value of the balance is as minimal as possible. If there are several correct answers, you may choose any of them.\\n\\nInput\\n\\nThe first line of input data contains an integer t (1 ≤ t ≤ 10^4) — the number of the test cases.\\n\\nEach test case's description is preceded by a blank line. Next comes a line that contains integers n and m (1 ≤ n ≤ 2 ⋅ 10^5; 0 ≤ m ≤ 10^6). The next n lines describe dishes, the i-th of them contains a pair of integers a_i and b_i (0 ≤ a_i, b_i ≤ 10^6) — the masses of fish and meat in the i-th dish.\\n\\nIt is guaranteed that it is possible to eat m grams of food from each dish. In other words, m ≤ a_i+b_i for all i from 1 to n inclusive.\\n\\nThe sum of all n values over all test cases in the test does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print on the first line the minimal balance value that can be achieved by eating exactly m grams of food from each dish.\\n\\nThen print n lines that describe a way to do this: the i-th line should contain two integers x_i and y_i (0 ≤ x_i ≤ a_i; 0 ≤ y_i ≤ b_i; x_i+y_i=m), where x_i is how many grams of fish taster should eat from the i-th meal and y_i is how many grams of meat.\\n\\nIf there are several ways to achieve a minimal balance, find any of them.\\n\\nExample\\n\\nInput\\n\\n\\n8\\n\\n1 5\\n3 4\\n\\n1 6\\n3...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nlong long a[1000005], b[1000005], first[1000005], second[1000005], a1[1000005],\\n b1[1000005];\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n int t;\\n cin >> t;\\n while (t-- > 0) {\\n long long n, m;\\n cin >> n >> m;\\n long long sa = 0, sb = 0;\\n for (int i = 1; i <= n; ++i) {\\n cin >> a[i] >> b[i];\\n a1[i] = a[i];\\n b1[i] = b[i];\\n }\\n for (int i = 1; i <= n; ++i) {\\n first[i] = min(m, a[i]);\\n second[i] = m - first[i];\\n a[i] -= first[i];\\n b[i] -= second[i];\\n sa += a[i];\\n sb += b[i];\\n }\\n for (int i = 1; i <= n; ++i) {\\n if (sa > sb) {\\n long long o = min({a[i], b1[i] - b[i], (sa - sb) \\/ 2});\\n a[i] -= o;\\n first[i] += o;\\n b[i] += o;\\n second[i] -= o;\\n sa -= o;\\n sb += o;\\n } else if (sa < sb) {\\n long long o = min({b[i], a1[i] - a[i], (sb - sa) \\/ 2});\\n a[i] += o;\\n first[i] -= o;\\n b[i] -= o;\\n second[i] += o;\\n sa += o;\\n sb -= o;\\n }\\n }\\n cout << abs(sa - sb) << endl;\\n for (int i = 1; i <= n; ++i) cout << first[i] << \\\" \\\" << second[i] << endl;\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"It is the easy version of the problem. The only difference is that in this version n = 1.\\n\\nIn the cinema seats can be represented as the table with n rows and m columns. The rows are numbered with integers from 1 to n. The seats in each row are numbered with consecutive integers from left to right: in the k-th row from m (k - 1) + 1 to m k for all rows 1 ≤ k ≤ n.\\n\\n1| 2| ⋅⋅⋅| m - 1| m \\n---|---|---|---|--- \\nm + 1| m + 2| ⋅⋅⋅| 2 m - 1| 2 m \\n2m + 1| 2m + 2| ⋅⋅⋅| 3 m - 1| 3 m \\n\\\\vdots| \\\\vdots| \\\\ddots| \\\\vdots| \\\\vdots \\nm (n - 1) + 1| m (n - 1) + 2| ⋅⋅⋅| n m - 1| n m \\nThe table with seats indices\\n\\nThere are nm people who want to go to the cinema to watch a new film. They are numbered with integers from 1 to nm. You should give exactly one seat to each person.\\n\\nIt is known, that in this cinema as lower seat index you have as better you can see everything happening on the screen. i-th person has the level of sight a_i. Let's define s_i as the seat index, that will be given to i-th person. You want to give better places for people with lower sight levels, so for any two people i, j such that a_i < a_j it should be satisfied that s_i < s_j.\\n\\nAfter you will give seats to all people they will start coming to their seats. In the order from 1 to nm, each person will enter the hall and sit in their seat. To get to their place, the person will go to their seat's row and start moving from the first seat in this row to theirs from left to right. While moving some places will be free, some will be occupied with people already seated. The inconvenience of the person is equal to the number of occupied seats he or she will go through.\\n\\nLet's consider an example: m = 5, the person has the seat 4 in the first row, the seats 1, 3, 5 in the first row are already occupied, the seats 2 and 4 are free. The inconvenience of this person will be 2, because he will go through occupied seats 1 and 3.\\n\\nFind the minimal total inconvenience (the sum of inconveniences of all people), that is possible to have by giving places for all people...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nconst int mod = 1000000007;\\nconst int N = 4e4 + 1;\\nint main() {\\n int t;\\n cin >> t;\\n while (t--) {\\n int n, m;\\n cin >> n >> m;\\n vector v(m);\\n for (int &x : v) {\\n cin >> x;\\n }\\n long long ans = 0;\\n for (int i = 1; i < m; i++) {\\n for (int j = 0; j < i; j++) {\\n if (v[j] < v[i]) {\\n ans++;\\n }\\n }\\n }\\n cout << ans << endl;\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"As their story unravels, a timeless tale is told once again...\\n\\nShirahime, a friend of Mocha's, is keen on playing the music game Arcaea and sharing Mocha interesting puzzles to solve. This day, Shirahime comes up with a new simple puzzle and wants Mocha to solve them. However, these puzzles are too easy for Mocha to solve, so she wants you to solve them and tell her the answers. The puzzles are described as follow.\\n\\nThere are n squares arranged in a row, and each of them can be painted either red or blue.\\n\\nAmong these squares, some of them have been painted already, and the others are blank. You can decide which color to paint on each blank square.\\n\\nSome pairs of adjacent squares may have the same color, which is imperfect. We define the imperfectness as the number of pairs of adjacent squares that share the same color.\\n\\nFor example, the imperfectness of \\\"BRRRBBR\\\" is 3, with \\\"BB\\\" occurred once and \\\"RR\\\" occurred twice.\\n\\nYour goal is to minimize the imperfectness and print out the colors of the squares after painting. \\n\\nInput\\n\\nEach test contains multiple test cases. \\n\\nThe first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. Each test case consists of two lines.\\n\\nThe first line of each test case contains an integer n (1≤ n≤ 100) — the length of the squares row.\\n\\nThe second line of each test case contains a string s with length n, containing characters 'B', 'R' and '?'. Here 'B' stands for a blue square, 'R' for a red square, and '?' for a blank square.\\n\\nOutput\\n\\nFor each test case, print a line with a string only containing 'B' and 'R', the colors of the squares after painting, which imperfectness is minimized. If there are multiple solutions, print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n7\\n?R???BR\\n7\\n???R???\\n1\\n?\\n1\\nB\\n10\\n?R??RB??B?\\n\\n\\nOutput\\n\\n\\nBRRBRBR\\nBRBRBRB\\nB\\nB\\nBRRBRBBRBR\\n\\nNote\\n\\nIn the first test case, if the squares are painted \\\"BRRBRBR\\\", the imperfectness is 1 (since squares 2 and 3 have the same color), which is the minimum possible imperfectness.\",\"targets\":\"#include \\nusing namespace std;\\nint t, n;\\nchar a[105];\\nvector st;\\nint main() {\\n cin >> t;\\n while (t--) {\\n cin >> n;\\n a[0] = 'B';\\n st.clear();\\n for (int i = 1; i <= n; i++) {\\n char x;\\n cin >> x;\\n if (x == '?') {\\n st.push_back(i);\\n continue;\\n }\\n a[i] = x;\\n while (!st.empty()) {\\n if (x == 'B') {\\n a[st.back()] = 'R';\\n x = 'R';\\n } else {\\n a[st.back()] = 'B';\\n x = 'B';\\n }\\n st.pop_back();\\n }\\n }\\n if (!st.empty()) {\\n char x = a[st.front() - 1];\\n for (int i = st.front(); i <= st.back(); i++) {\\n if (x == 'B') {\\n a[i] = 'R';\\n x = 'R';\\n } else {\\n a[i] = 'B';\\n x = 'B';\\n }\\n }\\n }\\n for (int i = 1; i <= n; i++) cout << a[i];\\n cout << endl;\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"\\n\\nWilliam has two numbers a and b initially both equal to zero. William mastered performing three different operations with them quickly. Before performing each operation some positive integer k is picked, which is then used to perform one of the following operations: (note, that for each operation you can choose a new positive integer k)\\n\\n 1. add number k to both a and b, or \\n 2. add number k to a and subtract k from b, or \\n 3. add number k to b and subtract k from a. \\n\\n\\n\\nNote that after performing operations, numbers a and b may become negative as well.\\n\\nWilliam wants to find out the minimal number of operations he would have to perform to make a equal to his favorite number c and b equal to his second favorite number d.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^4). Description of the test cases follows.\\n\\nThe only line of each test case contains two integers c and d (0 ≤ c, d ≤ 10^9), which are William's favorite numbers and which he wants a and b to be transformed into.\\n\\nOutput\\n\\nFor each test case output a single number, which is the minimal number of operations which William would have to perform to make a equal to c and b equal to d, or -1 if it is impossible to achieve this using the described operations.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n1 2\\n3 5\\n5 3\\n6 6\\n8 0\\n0 0\\n\\n\\nOutput\\n\\n\\n-1\\n2\\n2\\n1\\n2\\n0\\n\\nNote\\n\\nLet us demonstrate one of the suboptimal ways of getting a pair (3, 5):\\n\\n * Using an operation of the first type with k=1, the current pair would be equal to (1, 1). \\n * Using an operation of the third type with k=8, the current pair would be equal to (-7, 9). \\n * Using an operation of the second type with k=7, the current pair would be equal to (0, 2). \\n * Using an operation of the first type with k=3, the current pair would be equal to (3, 5). \\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nlong long t, a, b;\\nint main() {\\n cin >> t;\\n while (t--) {\\n scanf(\\\"%lld%lld\\\", &a, &b);\\n if (a == b) {\\n if (a == 0)\\n printf(\\\"0\\\\n\\\");\\n else\\n printf(\\\"1\\\\n\\\");\\n } else {\\n if ((a + b) % 2 == 0)\\n printf(\\\"2\\\\n\\\");\\n else\\n printf(\\\"-1\\\\n\\\");\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nIt's now the season of TAKOYAKI FESTIVAL!\\n\\nThis year, N takoyaki (a ball-shaped food with a piece of octopus inside) will be served. The deliciousness of the i-th takoyaki is d_i.\\n\\nAs is commonly known, when you eat two takoyaki of deliciousness x and y together, you restore x \\\\times y health points.\\n\\nThere are \\\\frac{N \\\\times (N - 1)}{2} ways to choose two from the N takoyaki served in the festival. For each of these choices, find the health points restored from eating the two takoyaki, then compute the sum of these \\\\frac{N \\\\times (N - 1)}{2} values.\\n\\nConstraints\\n\\n* All values in input are integers.\\n* 2 \\\\leq N \\\\leq 50\\n* 0 \\\\leq d_i \\\\leq 100\\n\\nInput\\n\\nInput is given from Standard Input in the following format:\\n\\n\\nN\\nd_1 d_2 ... d_N\\n\\n\\nOutput\\n\\nPrint the sum of the health points restored from eating two takoyaki over all possible choices of two takoyaki from the N takoyaki served.\\n\\nExamples\\n\\nInput\\n\\n3\\n3 1 2\\n\\n\\nOutput\\n\\n11\\n\\n\\nInput\\n\\n7\\n5 0 7 8 3 3 2\\n\\n\\nOutput\\n\\n312\",\"targets\":\"#include\\nusing namespace std;\\n\\nint n,ans,arr[100];\\n\\nint main(){\\n\\tscanf(\\\"%d\\\",&n);\\n\\tfor(int i = 0;i\\n\\nusing namespace std;\\n\\nint main() {\\n string s;\\n cin >> s;\\n int sum = 0;\\n for (auto c:s) {\\n sum += c - '0';\\n }\\n cout << ((sum % 9 == 0) ? \\\"Yes\\\" : \\\"No\\\") << endl;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Bear Limak wants to become the largest of bears, or at least to become larger than his brother Bob.\\n\\nRight now, Limak and Bob weigh a and b respectively. It's guaranteed that Limak's weight is smaller than or equal to his brother's weight.\\n\\nLimak eats a lot and his weight is tripled after every year, while Bob's weight is doubled after every year.\\n\\nAfter how many full years will Limak become strictly larger (strictly heavier) than Bob?\\n\\nInput\\n\\nThe only line of the input contains two integers a and b (1 ≤ a ≤ b ≤ 10) — the weight of Limak and the weight of Bob respectively.\\n\\nOutput\\n\\nPrint one integer, denoting the integer number of years after which Limak will become strictly larger than Bob.\\n\\nExamples\\n\\nInput\\n\\n4 7\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n4 9\\n\\n\\nOutput\\n\\n3\\n\\n\\nInput\\n\\n1 1\\n\\n\\nOutput\\n\\n1\\n\\nNote\\n\\nIn the first sample, Limak weighs 4 and Bob weighs 7 initially. After one year their weights are 4·3 = 12 and 7·2 = 14 respectively (one weight is tripled while the other one is doubled). Limak isn't larger than Bob yet. After the second year weights are 36 and 28, so the first weight is greater than the second one. Limak became larger than Bob after two years so you should print 2.\\n\\nIn the second sample, Limak's and Bob's weights in next years are: 12 and 18, then 36 and 36, and finally 108 and 72 (after three years). The answer is 3. Remember that Limak wants to be larger than Bob and he won't be satisfied with equal weights.\\n\\nIn the third sample, Limak becomes larger than Bob after the first year. Their weights will be 3 and 2 then.\",\"targets\":\"n,m=input().split()\\nn=int(n)\\nm=int(m)\\nc=0\\nwhile n<=m:\\n n=n*3\\n m=m*2\\n c=c+1\\nprint(c)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"n players are playing a game. \\n\\nThere are two different maps in the game. For each player, we know his strength on each map. When two players fight on a specific map, the player with higher strength on that map always wins. No two players have the same strength on the same map. \\n\\nYou are the game master and want to organize a tournament. There will be a total of n-1 battles. While there is more than one player in the tournament, choose any map and any two remaining players to fight on it. The player who loses will be eliminated from the tournament. \\n\\nIn the end, exactly one player will remain, and he is declared the winner of the tournament. For each player determine if he can win the tournament.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. The description of test cases follows.\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 10^5) — the number of players.\\n\\nThe second line of each test case contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9, a_i ≠ a_j for i ≠ j), where a_i is the strength of the i-th player on the first map. \\n\\nThe third line of each test case contains n integers b_1, b_2, ..., b_n (1 ≤ b_i ≤ 10^9, b_i ≠ b_j for i ≠ j), where b_i is the strength of the i-th player on the second map. \\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 10^5.\\n\\nOutput\\n\\nFor each test case print a string of length n. i-th character should be \\\"1\\\" if the i-th player can win the tournament, or \\\"0\\\" otherwise.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n4\\n1 2 3 4\\n1 2 3 4\\n4\\n11 12 20 21\\n44 22 11 30\\n1\\n1000000000\\n1000000000\\n\\n\\nOutput\\n\\n\\n0001\\n1111\\n1\\n\\nNote\\n\\nIn the first test case, the 4-th player will beat any other player on any game, so he will definitely win the tournament.\\n\\nIn the second test case, everyone can be a winner. \\n\\nIn the third test case, there is only one player. Clearly, he will win the tournament.\",\"targets\":\"#include \\nusing namespace std;\\nconst int MOD = 998244353;\\nconst double eps = 1e-11;\\ntemplate \\nusing vi2 = vector>;\\nusing ll = long long;\\nusing pii = pair;\\nusing ull = unsigned long long;\\ntemplate \\nT fp(T a, int b) {\\n T res = 1;\\n for (; b; b >>= 1, a = a * a)\\n if (b & 1) res = res * a;\\n return res;\\n}\\nstruct MINT {\\n int num;\\n MINT(ll x = 0) {\\n x %= MOD;\\n if (x < 0) x += MOD;\\n num = x;\\n }\\n inline int val() const { return num; }\\n MINT inv() const { return fp(*this, MOD - 2); }\\n MINT operator-() { return MINT(MOD - num); }\\n MINT operator+(const MINT x) const {\\n return MINT(num + x.num >= MOD ? num + x.num - MOD : num + x.num);\\n }\\n MINT operator-(const MINT x) const {\\n return MINT(num - x.num < 0 ? num - x.num + MOD : num - x.num);\\n }\\n MINT operator*(const MINT x) const { return MINT(1LL * num * x.num % MOD); }\\n MINT operator\\/(const MINT x) const { return *this * x.inv(); }\\n};\\nint main() {\\n auto solve = [&]() {\\n int n;\\n cin >> n;\\n vector ans(n + 1);\\n vector> a(n + 1);\\n for (int i = 1, _i = int(n); i <= _i; i++) cin >> get<0>(a[i]);\\n for (int i = 1, _i = int(n); i <= _i; i++) cin >> get<1>(a[i]);\\n for (int i = 1, _i = int(n); i <= _i; i++) get<2>(a[i]) = i;\\n sort(a.begin() + 1, a.end());\\n vector> b = a;\\n auto cmp = [&](tuple a, tuple b) -> bool {\\n return get<1>(a) < get<1>(b);\\n };\\n sort(b.begin() + 1, b.end(), cmp);\\n vector pre(n + 1), sur(n + 2);\\n for (int i = 1, _i = int(n); i <= _i; i++)\\n pre[i] = max(pre[i - 1], get<1>(a[i]));\\n for (int i = n, _i = int(1); i >= _i; i--)\\n sur[i] = max(sur[i + 1], get<1>(a[i]));\\n auto chk = [&](int x) {\\n int ta, tb, id;\\n vector vis(n + 1);\\n tie(ta, tb, id) = a[x];\\n int maxa = ta, maxb = pre[x];\\n for (int i = 1, _i = int(x); i <= _i; i++) {\\n vis[i] = 1;\\n }\\n int cnt1 = 1, cnt2 = 1;\\n while ((cnt1 <= n &&...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Berland Music is a music streaming service built specifically to support Berland local artist. Its developers are currently working on a song recommendation module.\\n\\nSo imagine Monocarp got recommended n songs, numbered from 1 to n. The i-th song had its predicted rating equal to p_i, where 1 ≤ p_i ≤ n and every integer from 1 to n appears exactly once. In other words, p is a permutation.\\n\\nAfter listening to each of them, Monocarp pressed either a like or a dislike button. Let his vote sequence be represented with a string s, such that s_i=0 means that he disliked the i-th song, and s_i=1 means that he liked it.\\n\\nNow the service has to re-evaluate the song ratings in such a way that:\\n\\n * the new ratings q_1, q_2, ..., q_n still form a permutation (1 ≤ q_i ≤ n; each integer from 1 to n appears exactly once); \\n * every song that Monocarp liked should have a greater rating than every song that Monocarp disliked (formally, for all i, j such that s_i=1 and s_j=0, q_i>q_j should hold). \\n\\n\\n\\nAmong all valid permutations q find the one that has the smallest value of ∑_{i=1}^n |p_i-q_i|, where |x| is an absolute value of x.\\n\\nPrint the permutation q_1, q_2, ..., q_n. If there are multiple answers, you can print any of them.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.\\n\\nThe first line of each testcase contains a single integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of songs.\\n\\nThe second line of each testcase contains n integers p_1, p_2, ..., p_n (1 ≤ p_i ≤ n) — the permutation of the predicted ratings.\\n\\nThe third line contains a single string s, consisting of n characters. Each character is either a 0 or a 1. 0 means that Monocarp disliked the song, and 1 means that he liked it.\\n\\nThe sum of n over all testcases doesn't exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each testcase, print a permutation q — the re-evaluated ratings of the songs. If there are multiple answers such that ∑_{i=1}^n |p_i-q_i| is minimum possible, you can print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n2\\n1 2\\n10\\n3\\n3 1 2\\n111\\n8\\n2...\\nfor _\",\"targets\":\"in range(int(input())):\\n n = int(input())\\n p = list(map(int, input().split()))\\n s = input()\\n zeros, ones = [], []\\n for i in range(n):\\n if s[i] == '0': zeros.append(p[i])\\n else: ones.append(p[i])\\n if not zeros or not ones:\\n for x in p: print(x, end= ' ')\\n else:\\n zeros.sort()\\n ones.sort()\\n dic = {}\\n start = 1\\n for x in zeros:\\n dic[x] = start\\n start += 1\\n for y in ones:\\n dic[y] = start\\n start += 1\\n for x in p:\\n print(dic[x], end = ' ')\\n print()\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alan decided to get in shape for the summer, so he created a precise workout plan to follow. His plan is to go to a different gym every day during the next N days and lift X[i] grams on day i. In order to improve his workout performance at the gym, he can buy exactly one pre-workout drink at the gym he is currently in and it will improve his performance by A grams permanently and immediately. In different gyms these pre-workout drinks can cost different amounts C[i] because of the taste and the gym's location but its permanent workout gains are the same. Before the first day of starting his workout plan, Alan knows he can lift a maximum of K grams. Help Alan spend a minimum total amount of money in order to reach his workout plan. If there is no way for him to complete his workout plan successfully output -1.\\n\\nInput\\n\\nThe first one contains two integer numbers, integers N (1 ≤ N ≤ 10^5) and K (1 ≤ K ≤ 10^5) – representing number of days in the workout plan and how many grams he can lift before starting his workout plan respectively. The second line contains N integer numbers X[i] (1 ≤ X[i] ≤ 10^9) separated by a single space representing how many grams Alan wants to lift on day i. The third line contains one integer number A (1 ≤ A ≤ 10^9) representing permanent performance gains from a single drink. The last line contains N integer numbers C[i] (1 ≤ C[i] ≤ 10^9) , representing cost of performance booster drink in the gym he visits on day i.\\n\\nOutput\\n\\nOne integer number representing minimal money spent to finish his workout plan. If he cannot finish his workout plan, output -1.\\n\\nExamples\\n\\nInput\\n\\n\\n5 10000\\n10000 30000 30000 40000 20000\\n20000\\n5 2 8 3 6\\n\\n\\nOutput\\n\\n\\n5\\n\\n\\nInput\\n\\n\\n5 10000\\n10000 40000 30000 30000 20000\\n10000\\n5 2 8 3 6\\n\\n\\nOutput\\n\\n\\n-1\\n\\nNote\\n\\nFirst example: After buying drinks on days 2 and 4 Alan can finish his workout plan. Second example: Alan cannot lift 40000 grams on day 2.\\nSolve the task in JAVA.\",\"targets\":\"import java.io.BufferedReader; \\nimport java.io.IOException; \\nimport java.io.InputStreamReader; \\nimport java.util.*; \\nimport java.util.StringTokenizer;\\nimport java.io.DataInputStream; \\nimport java.io.FileInputStream;\\nimport java.io.File;\\nimport java.lang.*;\\n\\n\\n\\n \\npublic class cf1200A\\n{ \\n static class FastReader \\n { \\n BufferedReader br; \\n StringTokenizer st; \\n \\n public FastReader() \\n { \\n br = new BufferedReader(new\\n InputStreamReader(System.in)); \\n } \\n \\n String next() \\n { \\n while (st == null || !st.hasMoreElements()) \\n { \\n try\\n { \\n st = new StringTokenizer(br.readLine()); \\n } \\n catch (IOException e) \\n { \\n e.printStackTrace(); \\n } \\n } \\n return st.nextToken(); \\n } \\n \\n int nextInt() \\n { \\n return Integer.parseInt(next()); \\n } \\n \\n long nextLong() \\n { \\n return Long.parseLong(next()); \\n } \\n \\n double nextDouble() \\n { \\n return Double.parseDouble(next()); \\n } \\n \\n String nextLine() \\n { \\n String str = \\\"\\\"; \\n try\\n { \\n str = br.readLine(); \\n } \\n catch (IOException e) \\n { \\n e.printStackTrace(); \\n } \\n return str; \\n } \\n }\\n static class mycomaparator implements Comparator{\\n public int compare(Integer a,Integer b){\\n return a-b;\\n }\\n }\\n public static void main(String[] args){\\n FastReader f=new FastReader();\\n int n =f.nextInt();long tc=0;\\n long capacity=f.nextLong();\\n long []arr=new long[n];\\n int []cost=new int [n];\\n for (int i=0;i 0) {\\n\\n\\t\\t\\tint n = fr.nextInt(), count = 0, count2 = 0;\\n\\t\\t\\tString str = fr.next();\\n\\t\\t\\tboolean flag = false;\\n\\n\\t\\t\\tfor (int i = 0; i < n; i++) {\\n\\t\\t\\t\\tif (str.charAt(i) == '2') {\\n\\t\\t\\t\\t\\tcount2++;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\n\\t\\t\\tchar A[][] = new char[n][n];\\n\\n\\t\\t\\tfor (int i = 0; i < n; i++) {\\n\\t\\t\\t\\tfor (int j = 0; j < n; j++) {\\n\\t\\t\\t\\t\\tA[i][j] = '*';\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\n\\t\\t\\tfor (int i = 0; i < n; i++) {\\n\\t\\t\\t\\tif (str.charAt(i) == '1') {\\n\\t\\t\\t\\t\\tfor (int j = 0; j < n; j++) {\\n\\t\\t\\t\\t\\t\\tA[i][j] = '=';\\n\\t\\t\\t\\t\\t\\tA[j][i] = '=';\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\n\\/\\/\\t\\t\\tpt.println(count);\\n\\n\\t\\t\\tfor (int i = 0; i < n; i++) {\\n\\t\\t\\t\\tfor (int j = 0; j < n; j++) {\\n\\t\\t\\t\\t\\tif (i == j) {\\n\\t\\t\\t\\t\\t\\tA[i][j] = 'X';\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\n\\t\\t\\tfor (int i = 0; i < n; i++) {\\n\\t\\t\\t\\tfor (int j = 0; j < n; j++) {\\n\\t\\t\\t\\t\\tif (A[i][j] == '*') {\\n\\t\\t\\t\\t\\t\\tcount++;\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\/\\/\\n\\/\\/\\t\\t\\tfor (int i = 0; i < n; i++) {\\n\\/\\/\\t\\t\\t\\tfor (int j = 0; j < n; j++) {\\n\\/\\/\\t\\t\\t\\t\\tpt.print(A[i][j]);\\n\\/\\/\\t\\t\\t\\t}\\n\\/\\/\\t\\t\\t\\tpt.println();\\n\\/\\/\\t\\t\\t}\\n\\n\\t\\t\\tif (count % 2 == 0 && (count2 <= count)) {\\n\\t\\t\\t\\tflag = true;\\n\\t\\t\\t}\\n\\n\\t\\t\\tfor (int i = 0; i < n; i++) {\\n\\n\\t\\t\\t\\tif (str.charAt(i) == '2') {\\n\\t\\t\\t\\t\\tfor (int j = 0; j < n; j++) {\\n\\t\\t\\t\\t\\t\\tif (A[i][j] == '*' && A[j][i] == '*') {\\n\\t\\t\\t\\t\\t\\t\\tA[i][j] = '+';\\n\\t\\t\\t\\t\\t\\t\\tA[j][i] = '-';\\n\\t\\t\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\n\\t\\t\\t}\\n\\n\\t\\t\\tfor (int i = 0; i < n; i++) {\\n\\t\\t\\t\\tfor (int j = 0; j < n; j++) {\\n\\t\\t\\t\\t\\tif (A[i][j] == '*') {\\n\\t\\t\\t\\t\\t\\tA[i][j] = '-';\\n\\t\\t\\t\\t\\t\\tA[j][i] = '+';\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\n\\t\\t\\tfor (int i = 0; i < n; i++) {\\n\\n\\t\\t\\t\\tif (str.charAt(i) == '2') {\\n\\n\\t\\t\\t\\t\\tboolean flag1 = false;\\n\\n\\t\\t\\t\\t\\tfor (int j = 0; j < n; j++) {\\n\\t\\t\\t\\t\\t\\tif (A[i][j] == '+') {\\n\\t\\t\\t\\t\\t\\t\\tflag1 = true;\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t}\\n\\n\\t\\t\\t\\t\\tif (flag1 == false) {\\n\\t\\t\\t\\t\\t\\tflag = false;\\n\\t\\t\\t\\t\\t}\\n\\n\\t\\t\\t\\t}\\n\\n\\t\\t\\t}\\n\\n\\t\\t\\tif (flag)...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Being tired of participating in too many Codeforces rounds, Gildong decided to take some rest in a park. He sat down on a bench, and soon he found two rabbits hopping around. One of the rabbits was taller than the other.\\n\\nHe noticed that the two rabbits were hopping towards each other. The positions of the two rabbits can be represented as integer coordinates on a horizontal line. The taller rabbit is currently on position x, and the shorter rabbit is currently on position y (x < y). Every second, each rabbit hops to another position. The taller rabbit hops to the positive direction by a, and the shorter rabbit hops to the negative direction by b.\\n\\n\\n\\nFor example, let's say x=0, y=10, a=2, and b=3. At the 1-st second, each rabbit will be at position 2 and 7. At the 2-nd second, both rabbits will be at position 4.\\n\\nGildong is now wondering: Will the two rabbits be at the same position at the same moment? If so, how long will it take? Let's find a moment in time (in seconds) after which the rabbits will be at the same point.\\n\\nInput\\n\\nEach test contains one or more test cases. The first line contains the number of test cases t (1 ≤ t ≤ 1000).\\n\\nEach test case contains exactly one line. The line consists of four integers x, y, a, b (0 ≤ x < y ≤ 10^9, 1 ≤ a,b ≤ 10^9) — the current position of the taller rabbit, the current position of the shorter rabbit, the hopping distance of the taller rabbit, and the hopping distance of the shorter rabbit, respectively.\\n\\nOutput\\n\\nFor each test case, print the single integer: number of seconds the two rabbits will take to be at the same position.\\n\\nIf the two rabbits will never be at the same position simultaneously, print -1.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n0 10 2 3\\n0 10 3 3\\n900000000 1000000000 1 9999999\\n1 2 1 1\\n1 3 1 1\\n\\n\\nOutput\\n\\n\\n2\\n-1\\n10\\n-1\\n1\\n\\nNote\\n\\nThe first case is explained in the description.\\n\\nIn the second case, each rabbit will be at position 3 and 7 respectively at the 1-st second. But in the 2-nd second they will be at 6 and 4 respectively, and we can see that they will never...\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst int MOD = 1e9 + 7;\\nconst int N = 1e6 + 7;\\nvoid solve() {\\n long long x, y, a, b;\\n cin >> x >> y >> a >> b;\\n if ((y - x) % (a + b)) {\\n cout << -1 << endl;\\n } else\\n cout << (y - x) \\/ (a + b) << endl;\\n}\\nint main() {\\n ios::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n int t = 1;\\n cin >> t;\\n while (t--) solve();\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"CQXYM is counting permutations length of 2n.\\n\\nA permutation is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice in the array) and [1,3,4] is also not a permutation (n=3 but there is 4 in the array).\\n\\nA permutation p(length of 2n) will be counted only if the number of i satisfying p_ip_2. Because 0\\nusing namespace std;\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n int t;\\n cin >> t;\\n while (t--) {\\n long long n, ans = 1;\\n cin >> n;\\n for (long long i = 1; i <= n + n; i++) {\\n if (i != 2) {\\n ans = ans * i;\\n ans = ans % 1000000007;\\n }\\n }\\n cout << ans << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in PYTHON?\\nYou are given an array a of length n.\\n\\nLet's define the eversion operation. Let x = a_n. Then array a is partitioned into two parts: left and right. The left part contains the elements of a that are not greater than x (≤ x). The right part contains the elements of a that are strictly greater than x (> x). The order of elements in each part is kept the same as before the operation, i. e. the partition is stable. Then the array is replaced with the concatenation of the left and the right parts.\\n\\nFor example, if the array a is [2, 4, 1, 5, 3], the eversion goes like this: [2, 4, 1, 5, 3] → [2, 1, 3], [4, 5] → [2, 1, 3, 4, 5].\\n\\nWe start with the array a and perform eversions on this array. We can prove that after several eversions the array a stops changing. Output the minimum number k such that the array stops changing after k eversions.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 100). Description of the test cases follows.\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 2 ⋅ 10^5).\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9).\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case print a single integer k — the number of eversions after which the array stops changing.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n5\\n2 4 1 5 3\\n5\\n5 3 2 4 1\\n4\\n1 1 1 1\\n\\n\\nOutput\\n\\n\\n1\\n2\\n0\\n\\nNote\\n\\nConsider the fist example.\\n\\n * The first eversion: a = [1, 4, 2, 5, 3], x = 3. [2, 4, 1, 5, 3] → [2, 1, 3], [4, 5] → [2, 1, 3, 4, 5]. \\n * The second and following eversions: a = [2, 1, 3, 4, 5], x = 5. [2, 1, 3, 4, 5] → [2, 1, 3, 4, 5], [] → [2, 1, 3, 4, 5]. This eversion does not change the array, so the answer is 1. \\n\\n\\n\\nConsider the second example. \\n\\n * The first eversion: a = [5, 3, 2, 4, 1], x = 1. [5, 3, 2, 4, 1] → [1], [5, 3, 2, 4] → [1, 5, 3, 2, 4]. \\n * The second eversion: a = [1, 5, 3, 2, 4], x = 4. [1, 5, 3, 2, 4] → [1, 3, 2, 4], [5] → [1, 3, 2, 4, 5]. \\n * The third and following eversions: a = [1, 3, 2, 4,...\",\"targets\":\"import sys\\nraw_input = iter(sys.stdin.read().splitlines()).next\\n\\ndef solution():\\n n = int(raw_input())\\n a = map(int, raw_input().strip().split())\\n result = -1\\n mx = 0\\n for i in reversed(xrange(n)):\\n if a[i] > mx:\\n result += 1\\n mx = max(mx, a[i])\\n return result\\n\\nfor case in xrange(int(raw_input())):\\n print '%s' % solution()\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given a string s, consisting of n letters, each letter is either 'a' or 'b'. The letters in the string are numbered from 1 to n.\\n\\ns[l; r] is a continuous substring of letters from index l to r of the string inclusive. \\n\\nA string is called balanced if the number of letters 'a' in it is equal to the number of letters 'b'. For example, strings \\\"baba\\\" and \\\"aabbab\\\" are balanced and strings \\\"aaab\\\" and \\\"b\\\" are not.\\n\\nFind any non-empty balanced substring s[l; r] of string s. Print its l and r (1 ≤ l ≤ r ≤ n). If there is no such substring, then print -1 -1.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of testcases.\\n\\nThen the descriptions of t testcases follow.\\n\\nThe first line of the testcase contains a single integer n (1 ≤ n ≤ 50) — the length of the string.\\n\\nThe second line of the testcase contains a string s, consisting of n letters, each letter is either 'a' or 'b'.\\n\\nOutput\\n\\nFor each testcase print two integers. If there exists a non-empty balanced substring s[l; r], then print l r (1 ≤ l ≤ r ≤ n). Otherwise, print -1 -1.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n1\\na\\n6\\nabbaba\\n6\\nabbaba\\n9\\nbabbabbaa\\n\\n\\nOutput\\n\\n\\n-1 -1\\n1 6\\n3 6\\n2 5\\n\\nNote\\n\\nIn the first testcase there are no non-empty balanced subtrings.\\n\\nIn the second and third testcases there are multiple balanced substrings, including the entire string \\\"abbaba\\\" and substring \\\"baba\\\".\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nvoid dg(long long x) {\\n cout << \\\" # \\\"\\n << \\\" : \\\" << (x) << '\\\\n';\\n}\\nconst double pi = acos(-1);\\nconst long long mod = 1000000007;\\nint t, n;\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n ;\\n cin >> t;\\n while (t--) {\\n string s;\\n cin >> n >> s;\\n bool b = 0;\\n for (int i = 0; i < n - 1; ++i) {\\n if (s[i] != s[i + 1]) {\\n cout << i + 1 << ' ' << i + 2 << '\\\\n';\\n b = 1;\\n break;\\n }\\n }\\n if (!b) cout << -1 << ' ' << -1 << '\\\\n';\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Consider writing each of the integers from 1 to N \\\\times M in a grid with N rows and M columns, without duplicates. Takahashi thinks it is not fun enough, and he will write the numbers under the following conditions:\\n\\n* The largest among the values in the i-th row (1 \\\\leq i \\\\leq N) is A_i.\\n* The largest among the values in the j-th column (1 \\\\leq j \\\\leq M) is B_j.\\n\\n\\n\\nFor him, find the number of ways to write the numbers under these conditions, modulo 10^9 + 7.\\n\\nConstraints\\n\\n* 1 \\\\leq N \\\\leq 1000\\n* 1 \\\\leq M \\\\leq 1000\\n* 1 \\\\leq A_i \\\\leq N \\\\times M\\n* 1 \\\\leq B_j \\\\leq N \\\\times M\\n* A_i and B_j are integers.\\n\\nInput\\n\\nInput is given from Standard Input in the following format:\\n\\n\\nN M\\nA_1 A_2 ... A_{N}\\nB_1 B_2 ... B_{M}\\n\\n\\nOutput\\n\\nPrint the number of ways to write the numbers under the conditions, modulo 10^9 + 7.\\n\\nExamples\\n\\nInput\\n\\n2 2\\n4 3\\n3 4\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n3 3\\n5 9 7\\n3 6 9\\n\\n\\nOutput\\n\\n0\\n\\n\\nInput\\n\\n2 2\\n4 4\\n4 4\\n\\n\\nOutput\\n\\n0\\n\\n\\nInput\\n\\n14 13\\n158 167 181 147 178 151 179 182 176 169 180 129 175 168\\n181 150 178 179 167 180 176 169 182 177 175 159 173\\n\\n\\nOutput\\n\\n343772227\",\"targets\":\"from collections import Counter\\n\\nN,M = map(int,input().split())\\nA = sorted(list(map(int,input().split())),reverse=True)\\nB = sorted(list(map(int,input().split())),reverse=True)\\nmod = pow(10,9)+7\\n\\nn,m = 0,0\\nans = 1\\n\\ndef istwo(L):\\n if len(list(filter(lambda x:x>1,Counter(L).values())))>0:\\n return True\\n else:\\n return False\\n\\nif istwo(A) or istwo(B):\\n print(0)\\nelse:\\n for i in range(1,(N*M)+1)[::-1]:\\n if n0 and m>0 and i == A[n-1] and i == B[m-1]:\\n ans = ans%mod\\n elif n>0 and i == A[n-1]:\\n ans = (ans*(m))%mod\\n elif m>0 and i == B[m-1]:\\n ans = (ans*(n))%mod\\n else:\\n ans = (ans*(n*m-(N*M-i)))%mod\\n #print(i,n,A[n-1],m,B[m-1],ans)\\n print(ans)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"This problem is an extension of the problem \\\"Wonderful Coloring - 1\\\". It has quite many differences, so you should read this statement completely.\\n\\nRecently, Paul and Mary have found a new favorite sequence of integers a_1, a_2, ..., a_n. They want to paint it using pieces of chalk of k colors. The coloring of a sequence is called wonderful if the following conditions are met:\\n\\n 1. each element of the sequence is either painted in one of k colors or isn't painted; \\n 2. each two elements which are painted in the same color are different (i. e. there's no two equal values painted in the same color); \\n 3. let's calculate for each of k colors the number of elements painted in the color — all calculated numbers must be equal; \\n 4. the total number of painted elements of the sequence is the maximum among all colorings of the sequence which meet the first three conditions. \\n\\n\\n\\nE. g. consider a sequence a=[3, 1, 1, 1, 1, 10, 3, 10, 10, 2] and k=3. One of the wonderful colorings of the sequence is shown in the figure.\\n\\n The example of a wonderful coloring of the sequence a=[3, 1, 1, 1, 1, 10, 3, 10, 10, 2] and k=3. Note that one of the elements isn't painted.\\n\\nHelp Paul and Mary to find a wonderful coloring of a given sequence a.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10000) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of two lines. The first one contains two integers n and k (1 ≤ n ≤ 2⋅10^5, 1 ≤ k ≤ n) — the length of a given sequence and the number of colors, respectively. The second one contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ n).\\n\\nIt is guaranteed that the sum of n over all test cases doesn't exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nOutput t lines, each of them must contain a description of a wonderful coloring for the corresponding test case.\\n\\nEach wonderful coloring must be printed as a sequence of n integers c_1, c_2, ..., c_n (0 ≤ c_i ≤ k) separated by spaces where\\n\\n * c_i=0, if i-th element isn't painted; \\n * c_i>0, if i-th element is painted in the...\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"for _ in range(int(input())):\\n n,k = list(map(int,input().split()))\\n arr = list(map(int,input().split()))\\n mapper = {}\\n for i in range(n):\\n if arr[i] in mapper:\\n mapper[arr[i]].append(i)\\n else:\\n mapper[arr[i]] = [i]\\n ans = [0 for i in range(n)]\\n rem = []\\n for i in mapper:\\n l = len(mapper[i])\\n if l>=k:\\n for j in range(k):\\n ans[mapper[i][j]] = j+1\\n else:\\n rem+=mapper[i]\\n l = len(rem)\\n f = l\\/\\/k\\n for j in range(f*k):\\n ans[rem[j]] = (j%k)+1\\n print(*ans)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"Consider a simplified penalty phase at the end of a football match.\\n\\nA penalty phase consists of at most 10 kicks, the first team takes the first kick, the second team takes the second kick, then the first team takes the third kick, and so on. The team that scores more goals wins; if both teams score the same number of goals, the game results in a tie (note that it goes against the usual football rules). The penalty phase is stopped if one team has scored more goals than the other team could reach with all of its remaining kicks. For example, if after the 7-th kick the first team has scored 1 goal, and the second team has scored 3 goals, the penalty phase ends — the first team cannot reach 3 goals.\\n\\nYou know which player will be taking each kick, so you have your predictions for each of the 10 kicks. These predictions are represented by a string s consisting of 10 characters. Each character can either be 1, 0, or ?. This string represents your predictions in the following way:\\n\\n * if s_i is 1, then the i-th kick will definitely score a goal; \\n * if s_i is 0, then the i-th kick definitely won't score a goal; \\n * if s_i is ?, then the i-th kick could go either way. \\n\\n\\n\\nBased on your predictions, you have to calculate the minimum possible number of kicks there can be in the penalty phase (that means, the earliest moment when the penalty phase is stopped, considering all possible ways it could go). Note that the referee doesn't take into account any predictions when deciding to stop the penalty phase — you may know that some kick will\\/won't be scored, but the referee doesn't.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 1 000) — the number of test cases.\\n\\nEach test case is represented by one line containing the string s, consisting of exactly 10 characters. Each character is either 1, 0, or ?.\\n\\nOutput\\n\\nFor each test case, print one integer — the minimum possible number of kicks in the penalty phase.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n1?0???1001\\n1111111111\\n??????????\\n0100000000\\n\\n\\nOutput\\n\\n\\n7\\n10\\n6\\n9\\n\\nNote\\n\\nConsider...\\\":\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.util.Arrays;\\nimport java.util.Random;\\nimport java.util.StringTokenizer;\\n \\n\\npublic class Zlatan{\\n\\t\\n\\tstatic final long mod=1_000_000_007;\\n \\n\\tpublic static void main(String[] args)throws IOException {\\n\\t BufferedReader br=new BufferedReader(new InputStreamReader(System.in));\\n\\t\\tint t=Integer.parseInt(br.readLine());\\n\\t\\t\\n\\t\\tfor(int i=0;i5-(j)) break;\\n\\t\\t if(arr2[j]==2) sum2+=0;\\n\\t\\t else sum2+=arr2[j];\\n\\t\\t min1++;\\n\\t\\t diff=sum1-sum2;\\n\\t\\t if(diff>5-(j+1)) break;\\n\\t\\t }\\n\\t\\t sum1=0;\\n\\t\\t sum2=0;\\n\\t\\t for(int j=0;j<5;j++){\\n\\t\\t if(arr1[j]==2) sum1+=0;\\n\\t\\t else sum1+=arr1[j];\\n\\t\\t min2++;\\n\\t\\t diff=sum2-sum1;\\n\\t\\t if(diff>5-(j+1)) break;\\n\\t\\t if(arr2[j]==2) sum2+=1;\\n\\t\\t else sum2+=arr2[j];\\n\\t\\t min2++;\\n\\t\\t diff=sum2-sum1;\\n\\t\\t if(diff>5-(j+1)) break;\\n\\t\\t }\\n\\t\\t System.out.println(Math.min(min1,min2));\\n\\t\\t}\\n\\t}\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given a permutation p consisting of n integers 1, 2, ..., n (a permutation is an array where each element from 1 to n occurs exactly once).\\n\\nLet's call an array a bipartite if the following undirected graph is bipartite:\\n\\n * the graph consists of n vertices; \\n * two vertices i and j are connected by an edge if i < j and a_i > a_j. \\n\\n\\n\\nYour task is to find a bipartite array of integers a of size n, such that a_i = p_i or a_i = -p_i, or report that no such array exists. If there are multiple answers, print any of them.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 2 ⋅ 10^5) — the number of test cases.\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 10^6) — the size of the permutation.\\n\\nThe second line contains n integers p_1, p_2, ..., p_n.\\n\\nThe sum of n over all test cases doesn't exceed 10^6.\\n\\nOutput\\n\\nFor each test case, print the answer in the following format. If such an array a does not exist, print \\\"NO\\\" in a single line. Otherwise, print \\\"YES\\\" in the first line and n integers — array a in the second line.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n1 2 3\\n6\\n1 3 2 6 5 4\\n4\\n4 1 3 2\\n8\\n3 2 1 6 7 8 5 4\\n\\n\\nOutput\\n\\n\\nYES\\n1 2 3\\nNO\\nYES\\n-4 -1 -3 -2\\nYES\\n-3 -2 1 6 7 -8 -5 -4\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 1e6 + 5;\\nint n, p[N][2], dp[N][2][2];\\npair g[N][2][2];\\nvoid cmin(int& x, int y) {\\n if (x > y) x = y;\\n}\\nvoid solve() {\\n scanf(\\\"%d\\\", &n);\\n for (int i = 1; i <= n; i++) scanf(\\\"%d\\\", &p[i][1]), p[i][0] = -p[i][1];\\n for (int i = 1; i <= n; i++)\\n for (int j = 0; j <= 1; j++)\\n for (int k = 0; k <= 1; k++) dp[i][j][k] = n + 1;\\n dp[1][0][0] = dp[1][0][1] = -n - 1;\\n for (int i = 1; i < n; i++)\\n for (int j = 0; j <= 1; j++)\\n for (int k = 0; k <= 1; k++)\\n for (int l = 0; l <= 1; l++) {\\n int x = (j == 0) ? p[i][k] : dp[i][j][k],\\n y = (j == 1) ? p[i][k] : dp[i][j][k];\\n if (x > p[i + 1][l] && p[i + 1][l] > y && dp[i + 1][1][l] > x)\\n dp[i + 1][1][l] = x, g[i + 1][1][l] = {j, k};\\n if (p[i + 1][l] > x && dp[i + 1][0][l] > y)\\n dp[i + 1][0][l] = y, g[i + 1][0][l] = {j, k};\\n }\\n vector ans;\\n for (int i = 0; i <= 1; i++)\\n for (int j = 0; j <= 1; j++)\\n if (dp[n][i][j] != n + 1) {\\n puts(\\\"YES\\\");\\n pair now = g[n][i][j];\\n int tmp = n - 1;\\n ans.push_back(p[n][j]);\\n while (tmp) {\\n ans.push_back(p[tmp][now.second]);\\n now = g[tmp][now.first][now.second];\\n tmp--;\\n }\\n for (int i = ans.size() - 1; i >= 0; i--) printf(\\\"%d \\\", ans[i]);\\n puts(\\\"\\\");\\n return;\\n }\\n puts(\\\"NO\\\");\\n}\\nint main() {\\n int T;\\n scanf(\\\"%d\\\", &T);\\n while (T--) solve();\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Theofanis has a riddle for you and if you manage to solve it, he will give you a Cypriot snack halloumi for free (Cypriot cheese).\\n\\nYou are given an integer n. You need to find two integers l and r such that -10^{18} ≤ l < r ≤ 10^{18} and l + (l + 1) + … + (r - 1) + r = n.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases.\\n\\nThe first and only line of each test case contains a single integer n (1 ≤ n ≤ 10^{18}).\\n\\nOutput\\n\\nFor each test case, print the two integers l and r such that -10^{18} ≤ l < r ≤ 10^{18} and l + (l + 1) + … + (r - 1) + r = n. \\n\\nIt can be proven that an answer always exists. If there are multiple answers, print any.\\n\\nExample\\n\\nInput\\n\\n\\n7\\n1\\n2\\n3\\n6\\n100\\n25\\n3000000000000\\n\\n\\nOutput\\n\\n\\n0 1\\n-1 2 \\n1 2 \\n1 3 \\n18 22\\n-2 7\\n999999999999 1000000000001\\n\\nNote\\n\\nIn the first test case, 0 + 1 = 1.\\n\\nIn the second test case, (-1) + 0 + 1 + 2 = 2.\\n\\nIn the fourth test case, 1 + 2 + 3 = 6.\\n\\nIn the fifth test case, 18 + 19 + 20 + 21 + 22 = 100.\\n\\nIn the sixth test case, (-2) + (-1) + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 = 25.\",\"targets\":\"t = int(input())\\n\\nwhile(t):\\n t = t - 1\\n n = int(input())\\n print(\\\"{} {}\\\".format(-n + 1, n))\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nThis is the hard version of the problem. The only difference between the two versions is the constraint on n. You can make hacks only if all versions of the problem are solved.\\n\\nA forest is an undirected graph without cycles (not necessarily connected).\\n\\nMocha and Diana are friends in Zhijiang, both of them have a forest with nodes numbered from 1 to n, and they would like to add edges to their forests such that: \\n\\n * After adding edges, both of their graphs are still forests. \\n * They add the same edges. That is, if an edge (u, v) is added to Mocha's forest, then an edge (u, v) is added to Diana's forest, and vice versa. \\n\\n\\n\\nMocha and Diana want to know the maximum number of edges they can add, and which edges to add.\\n\\nInput\\n\\nThe first line contains three integers n, m_1 and m_2 (1 ≤ n ≤ 10^5, 0 ≤ m_1, m_2 < n) — the number of nodes and the number of initial edges in Mocha's forest and Diana's forest.\\n\\nEach of the next m_1 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the edges in Mocha's forest.\\n\\nEach of the next m_2 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the edges in Diana's forest.\\n\\nOutput\\n\\nThe first line contains only one integer h, the maximum number of edges Mocha and Diana can add.\\n\\nEach of the next h lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the edge you add each time.\\n\\nIf there are multiple correct answers, you can print any one of them.\\n\\nExamples\\n\\nInput\\n\\n\\n3 2 2\\n1 2\\n2 3\\n1 2\\n1 3\\n\\n\\nOutput\\n\\n\\n0\\n\\n\\nInput\\n\\n\\n5 3 2\\n5 4\\n2 1\\n4 3\\n4 3\\n1 4\\n\\n\\nOutput\\n\\n\\n1\\n2 4\\n\\n\\nInput\\n\\n\\n8 1 2\\n1 7\\n2 6\\n1 5\\n\\n\\nOutput\\n\\n\\n5\\n5 2\\n2 3\\n3 4\\n4 7\\n6 8\\n\\nNote\\n\\nIn the first example, we cannot add any edge.\\n\\nIn the second example, the initial forests are as follows.\\n\\n\\n\\nWe can add an edge (2, 4).\\n\\n\",\"targets\":\"#include \\nusing namespace std;\\nconst long long mod = 998244353;\\nconst long long N = 3e5 + 5;\\nconst double eps = 1e-8;\\nconst double PI = acos(-1);\\nlong long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }\\nlong long re() {\\n long long x;\\n scanf(\\\"%lld\\\", &x);\\n return x;\\n}\\nlong long qk(long long a, long long b) {\\n long long ans = 1;\\n while (b) {\\n if (b & 1) ans = ans * a % mod;\\n a = a * a % mod;\\n b \\/= 2;\\n }\\n return ans;\\n}\\nint dx[8] = {1, 0, -1, 0, 1, 1, -1, -1}, dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};\\nint a[N], b[N];\\nvector v1, v2;\\nint fina(int x) { return a[x] = a[x] == x ? x : fina(a[x]); }\\nint finb(int x) { return b[x] = b[x] == x ? x : finb(b[x]); }\\nvoid solve() {\\n int n, m1, m2;\\n cin >> n >> m1 >> m2;\\n for (int i = 1; i <= n; i++) a[i] = i, b[i] = i;\\n int x, y;\\n for (int i = 1; i <= m1; i++) {\\n scanf(\\\"%d%d\\\", &x, &y);\\n a[fina(x)] = fina(y);\\n }\\n for (int i = 1; i <= m2; i++) {\\n scanf(\\\"%d%d\\\", &x, &y);\\n b[finb(x)] = finb(y);\\n }\\n vector > v;\\n for (int i = 1; i <= 1; i++) {\\n for (int j = i + 1; j <= n; j++) {\\n if (fina(i) != fina(j) && finb(i) != finb(j)) {\\n a[fina(i)] = fina(j);\\n b[finb(i)] = finb(j);\\n v.emplace_back(make_pair(i, j));\\n }\\n if (fina(j) != fina(1)) v1.emplace_back(j);\\n if (finb(j) != finb(1)) v2.emplace_back(j);\\n }\\n }\\n for (int i = 0, j = 0; i < v1.size() && j < v2.size();) {\\n if (fina(v1[i]) == fina(1) && finb(v1[i]) == finb(1)) {\\n i++;\\n continue;\\n }\\n if (fina(v2[j]) == fina(1) && finb(v2[j]) == finb(1)) {\\n j++;\\n continue;\\n }\\n a[fina(v1[i])] = fina(v2[j]);\\n b[finb(v1[i])] = finb(v2[j]);\\n v.emplace_back(v1[i], v2[j]);\\n }\\n cout << v.size() << '\\\\n';\\n for (int i = 0; i < v.size(); i++) {\\n printf(\\\"%d %d\\\\n\\\", v[i].first, v[i].second);\\n }\\n}\\nint main() {\\n int T = 1;\\n while (T--) solve();\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"During the hypnosis session, Nicholas suddenly remembered a positive integer n, which doesn't contain zeros in decimal notation. \\n\\nSoon, when he returned home, he got curious: what is the maximum number of digits that can be removed from the number so that the number becomes not prime, that is, either composite or equal to one?\\n\\nFor some numbers doing so is impossible: for example, for number 53 it's impossible to delete some of its digits to obtain a not prime integer. However, for all n in the test cases of this problem, it's guaranteed that it's possible to delete some of their digits to obtain a not prime number.\\n\\nNote that you cannot remove all the digits from the number.\\n\\nA prime number is a number that has no divisors except one and itself. A composite is a number that has more than two divisors. 1 is neither a prime nor a composite number.\\n\\nInput\\n\\nEach test contains multiple test cases.\\n\\nThe first line contains one positive integer t (1 ≤ t ≤ 10^3), denoting the number of test cases. Description of the test cases follows.\\n\\nThe first line of each test case contains one positive integer k (1 ≤ k ≤ 50) — the number of digits in the number.\\n\\nThe second line of each test case contains a positive integer n, which doesn't contain zeros in decimal notation (10^{k-1} ≤ n < 10^{k}). It is guaranteed that it is always possible to remove less than k digits to make the number not prime.\\n\\nIt is guaranteed that the sum of k over all test cases does not exceed 10^4.\\n\\nOutput\\n\\nFor every test case, print two numbers in two lines. In the first line print the number of digits, that you have left in the number. In the second line print the digits left after all delitions. \\n\\nIf there are multiple solutions, print any.\\n\\nExample\\n\\nInput\\n\\n\\n7\\n3\\n237\\n5\\n44444\\n3\\n221\\n2\\n35\\n3\\n773\\n1\\n4\\n30\\n626221626221626221626221626221\\n\\n\\nOutput\\n\\n\\n2\\n27\\n1\\n4\\n1\\n1\\n2\\n35\\n2\\n77\\n1\\n4\\n1\\n6\\n\\nNote\\n\\nIn the first test case, you can't delete 2 digits from the number 237, as all the numbers 2, 3, and 7 are prime. However, you can delete 1 digit, obtaining a number 27 =...\\nu=set\",\"targets\":\"()\\ndef Sieve(n):\\n\\n prime = [True for i in range(n+1)]\\n p = 2\\n while (p * p <= n):\\n if (prime[p] == True):\\n for i in range(p * p, n+1, p):\\n prime[i] = False\\n p += 1\\n for p in range(2, n+1):\\n if prime[p]:\\n u.add(p)\\nSieve(10000)\\n \\n \\nfrom itertools import combinations as C\\n \\ndef solve():\\n a=0\\n n=int(input());a+=1\\n l=list(input());a+=1\\n s='';e=0;a+=1\\n for i in range(1,n+1):\\n for j in C(l,i):\\n if int(''.join(j)) not in u:\\n s=''.join(j);e=1\\n break\\n if e==1:\\n break\\n print(len(s))\\n a+=1\\n a+=1\\n a+=1\\n print(s)\\n a+=1\\n a+=1\\n a+=1\\n \\nt=int(input())\\nwhile(t):\\n solve()\\n t-=1\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given three integers n, a, b. Determine if there exists a permutation p_1, p_2, …, p_n of integers from 1 to n, such that:\\n\\n * There are exactly a integers i with 2 ≤ i ≤ n-1 such that p_{i-1} < p_i > p_{i+1} (in other words, there are exactly a local maximums).\\n\\n * There are exactly b integers i with 2 ≤ i ≤ n-1 such that p_{i-1} > p_i < p_{i+1} (in other words, there are exactly b local minimums).\\n\\n\\n\\n\\nIf such permutations exist, find any such permutation.\\n\\nInput\\n\\nThe first line of the input contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. The description of test cases follows.\\n\\nThe only line of each test case contains three integers n, a and b (2 ≤ n ≤ 10^5, 0 ≤ a,b ≤ n).\\n\\nThe sum of n over all test cases doesn't exceed 10^5.\\n\\nOutput\\n\\nFor each test case, if there is no permutation with the requested properties, output -1.\\n\\nOtherwise, print the permutation that you are found. If there are several such permutations, you may print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n4 1 1\\n6 1 2\\n6 4 0\\n\\n\\nOutput\\n\\n\\n1 3 2 4\\n4 2 3 1 5 6\\n-1\\n\\nNote\\n\\nIn the first test case, one example of such permutations is [1, 3, 2, 4]. In it p_1 < p_2 > p_3, and 2 is the only such index, and p_2> p_3 < p_4, and 3 the only such index.\\n\\nOne can show that there is no such permutation for the third test case.\",\"targets\":\"import sys\\ninput=sys.stdin.readline\\n\\nfor i in ' '*int(input()):\\n n,a,b=map(int,input().split())\\n if abs(a-b)>1 or a+b>n-2:\\n print(-1)\\n continue\\n res=[]\\n if a>b:\\n for i in range(b):\\n res.append(n-i)\\n res.append(i+1)\\n res.append(n-b)\\n not_used=[b+1,n-b]\\n elif a==b:\\n for i in range(b):\\n res.append(n-i)\\n res.append(i+1)\\n not_used=[b+1, n-b+1]\\n else:\\n for i in range(a):\\n res.append(i+1)\\n res.append(n-i)\\n res.append(a+1)\\n not_used=[a+2, n-a+1]\\n l,r=not_used\\n for i in range(l,r):\\n if i==l:res=[i]+res\\n else:\\n if a>b:\\n res.append(l+r-i)\\n else: res.append(i)\\n for i in res:\\n print(i,end=' ')\\n print()\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nThere is a chessboard of size n by n. The square in the i-th row from top and j-th column from the left is labelled (i,j).\\n\\nCurrently, Gregor has some pawns in the n-th row. There are also enemy pawns in the 1-st row. On one turn, Gregor moves one of his pawns. A pawn can move one square up (from (i,j) to (i-1,j)) if there is no pawn in the destination square. Additionally, a pawn can move one square diagonally up (from (i,j) to either (i-1,j-1) or (i-1,j+1)) if and only if there is an enemy pawn in that square. The enemy pawn is also removed.\\n\\nGregor wants to know what is the maximum number of his pawns that can reach row 1?\\n\\nNote that only Gregor takes turns in this game, and the enemy pawns never move. Also, when Gregor's pawn reaches row 1, it is stuck and cannot make any further moves.\\n\\nInput\\n\\nThe first line of the input contains one integer t (1≤ t≤ 2⋅ 10^4) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of three lines. The first line contains a single integer n (2≤ n≤ 2⋅{10}^{5}) — the size of the chessboard.\\n\\nThe second line consists of a string of binary digits of length n, where a 1 in the i-th position corresponds to an enemy pawn in the i-th cell from the left, and 0 corresponds to an empty cell.\\n\\nThe third line consists of a string of binary digits of length n, where a 1 in the i-th position corresponds to a Gregor's pawn in the i-th cell from the left, and 0 corresponds to an empty cell.\\n\\nIt is guaranteed that the sum of n across all test cases is less than 2⋅{10}^{5}.\\n\\nOutput\\n\\nFor each test case, print one integer: the maximum number of Gregor's pawns which can reach the 1-st row.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n000\\n111\\n4\\n1111\\n1111\\n3\\n010\\n010\\n5\\n11001\\n00000\\n\\n\\nOutput\\n\\n\\n3\\n4\\n0\\n0\\n\\nNote\\n\\nIn the first example, Gregor can simply advance all 3 of his pawns forward. Thus, the answer is 3.\\n\\nIn the second example, Gregor can guarantee that all 4 of his pawns reach the enemy row, by following the colored paths as demonstrated in the diagram below. Remember, only Gregor takes turns in...\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n long long t;\\n long long n, ans = 0;\\n cin >> t;\\n string b;\\n string a;\\n for (int i = 0; i < t; i++) {\\n ans = 0;\\n cin >> n;\\n cin >> a;\\n cin >> b;\\n if (a[0] == '1') {\\n if (b[1] == '1') {\\n b[1] = '0';\\n a[0] = '2';\\n ans++;\\n }\\n } else if (a[0] == '0') {\\n if (b[0] == '1') {\\n b[0] = '0';\\n a[0] = '2';\\n ans++;\\n }\\n }\\n for (long long j = 1; j < n - 1; j++) {\\n if (a[j] == '1') {\\n if (b[j - 1] == '1') {\\n b[j - 1] = '0';\\n a[j] = '2';\\n ans++;\\n } else if (b[j + 1] == '1') {\\n b[j + 1] = '0';\\n a[j] = '2';\\n ans++;\\n }\\n } else if (a[j] == '0') {\\n if (b[j] == '1') {\\n b[j] = '0';\\n a[j] = '2';\\n ans++;\\n }\\n }\\n }\\n if (a[n - 1] == '1') {\\n if (b[n - 2] == '1') {\\n b[n - 2] = '0';\\n a[n - 1] = '2';\\n ans++;\\n }\\n } else if (a[n - 1] == '0') {\\n if (b[n - 1] == '1') {\\n b[n - 1] = '0';\\n a[n - 1] = '2';\\n ans++;\\n }\\n }\\n cout << ans << endl;\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity.\\n\\nYour favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2i - 1 liters and costs ci roubles. The number of bottles of each type in the store can be considered infinite.\\n\\nYou want to buy at least L liters of lemonade. How many roubles do you have to spend?\\n\\nInput\\n\\nThe first line contains two integers n and L (1 ≤ n ≤ 30; 1 ≤ L ≤ 109) — the number of types of bottles in the store and the required amount of lemonade in liters, respectively.\\n\\nThe second line contains n integers c1, c2, ..., cn (1 ≤ ci ≤ 109) — the costs of bottles of different types.\\n\\nOutput\\n\\nOutput a single integer — the smallest number of roubles you have to pay in order to buy at least L liters of lemonade.\\n\\nExamples\\n\\nInput\\n\\n4 12\\n20 30 70 90\\n\\n\\nOutput\\n\\n150\\n\\n\\nInput\\n\\n4 3\\n10000 1000 100 10\\n\\n\\nOutput\\n\\n10\\n\\n\\nInput\\n\\n4 3\\n10 100 1000 10000\\n\\n\\nOutput\\n\\n30\\n\\n\\nInput\\n\\n5 787787787\\n123456789 234567890 345678901 456789012 987654321\\n\\n\\nOutput\\n\\n44981600785557577\\n\\nNote\\n\\nIn the first example you should buy one 8-liter bottle for 90 roubles and two 2-liter bottles for 30 roubles each. In total you'll get 12 liters of lemonade for just 150 roubles.\\n\\nIn the second example, even though you need only 3 liters, it's cheaper to buy a single 8-liter bottle for 10 roubles.\\n\\nIn the third example it's best to buy three 1-liter bottles for 10 roubles each, getting three liters for 30 roubles.\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int n;\\n long long L;\\n cin >> n >> L;\\n long long c[33];\\n for (int i = 0; i < n; ++i) {\\n cin >> c[i];\\n }\\n for (int i = n; i < 33; ++i) {\\n c[i] = LLONG_MAX;\\n }\\n for (int i = 1; i < 33; ++i) {\\n c[i] = min(c[i], 2 * c[i - 1]);\\n }\\n long long ans = 0;\\n for (int i = 0; i < 33; ++i) {\\n if (c[i] < ans) {\\n ans = c[i];\\n }\\n if ((1LL << i) & L) {\\n ans += c[i];\\n }\\n }\\n std::cout << ans << '\\\\n';\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in PYTHON3?\\nYou are given a sequence of n integers a_1, a_2, ..., a_n.\\n\\nDoes there exist a sequence of n integers b_1, b_2, ..., b_n such that the following property holds?\\n\\n * For each 1 ≤ i ≤ n, there exist two (not necessarily distinct) indices j and k (1 ≤ j, k ≤ n) such that a_i = b_j - b_k. \\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 20) — the number of test cases. Then t test cases follow.\\n\\nThe first line of each test case contains one integer n (1 ≤ n ≤ 10).\\n\\nThe second line of each test case contains the n integers a_1, ..., a_n (-10^5 ≤ a_i ≤ 10^5).\\n\\nOutput\\n\\nFor each test case, output a line containing YES if a sequence b_1, ..., b_n satisfying the required property exists, and NO otherwise.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n5\\n4 -7 -1 5 10\\n1\\n0\\n3\\n1 10 100\\n4\\n-3 2 10 2\\n9\\n25 -171 250 174 152 242 100 -205 -258\\n\\n\\nOutput\\n\\n\\nYES\\nYES\\nNO\\nYES\\nYES\\n\\nNote\\n\\nIn the first test case, the sequence b = [-9, 2, 1, 3, -2] satisfies the property. Indeed, the following holds: \\n\\n * a_1 = 4 = 2 - (-2) = b_2 - b_5; \\n * a_2 = -7 = -9 - (-2) = b_1 - b_5; \\n * a_3 = -1 = 1 - 2 = b_3 - b_2; \\n * a_4 = 5 = 3 - (-2) = b_4 - b_5; \\n * a_5 = 10 = 1 - (-9) = b_3 - b_1. \\n\\n\\n\\nIn the second test case, it is sufficient to choose b = [0], since a_1 = 0 = 0 - 0 = b_1 - b_1.\\n\\nIn the third test case, it is possible to show that no sequence b of length 3 satisfies the property.\",\"targets\":\"for _ in range(int(input())):\\n N = int(input())\\n lis = list(map(int, input().split()))\\n\\n sums = set([lis[0], -lis[0]])\\n\\n for i in range(1, N):\\n cur_sums = sums.copy()\\n sums.add(lis[i])\\n for m in cur_sums:\\n sums.add(m + lis[i])\\n sums.add(m - lis[i])\\n print(\\\"YES\\\" if 0 in sums else \\\"NO\\\")\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"As you might remember from our previous rounds, Vova really likes computer games. Now he is playing a strategy game known as Rage of Empires.\\n\\nIn the game Vova can hire n different warriors; ith warrior has the type ai. Vova wants to create a balanced army hiring some subset of warriors. An army is called balanced if for each type of warrior present in the game there are not more than k warriors of this type in the army. Of course, Vova wants his army to be as large as possible.\\n\\nTo make things more complicated, Vova has to consider q different plans of creating his army. ith plan allows him to hire only warriors whose numbers are not less than li and not greater than ri.\\n\\nHelp Vova to determine the largest size of a balanced army for each plan.\\n\\nBe aware that the plans are given in a modified way. See input section for details.\\n\\nInput\\n\\nThe first line contains two integers n and k (1 ≤ n, k ≤ 100000).\\n\\nThe second line contains n integers a1, a2, ... an (1 ≤ ai ≤ 100000).\\n\\nThe third line contains one integer q (1 ≤ q ≤ 100000).\\n\\nThen q lines follow. ith line contains two numbers xi and yi which represent ith plan (1 ≤ xi, yi ≤ n).\\n\\nYou have to keep track of the answer to the last plan (let's call it last). In the beginning last = 0. Then to restore values of li and ri for the ith plan, you have to do the following:\\n\\n 1. li = ((xi + last) mod n) + 1; \\n 2. ri = ((yi + last) mod n) + 1; \\n 3. If li > ri, swap li and ri. \\n\\nOutput\\n\\nPrint q numbers. ith number must be equal to the maximum size of a balanced army when considering ith plan.\\n\\nExample\\n\\nInput\\n\\n6 2\\n1 1 1 2 2 2\\n5\\n1 6\\n4 3\\n1 1\\n2 6\\n2 6\\n\\n\\nOutput\\n\\n2\\n4\\n1\\n3\\n2\\n\\nNote\\n\\nIn the first example the real plans are: \\n\\n 1. 1 2\\n 2. 1 6\\n 3. 6 6\\n 4. 2 4\\n 5. 4 6\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nvector vt[100005];\\nint Time[100005 * 2];\\nint tree[100005 * 40], lchild[100005 * 40], rchild[100005 * 40], root[100005],\\n tot;\\nvoid insert(int last, int cur, int x, int L, int R, int k) {\\n tree[cur] = tree[last] + k;\\n lchild[cur] = lchild[last];\\n rchild[cur] = rchild[last];\\n if (L == R) return;\\n int mid = L + R >> 1;\\n if (x <= mid)\\n insert(lchild[last], lchild[cur] = ++tot, x, L, mid, k);\\n else\\n insert(rchild[last], rchild[cur] = ++tot, x, mid + 1, R, k);\\n}\\nint query(int l, int r, int L, int R, int root) {\\n if (l <= L && R <= r) return tree[root];\\n int mid = L + R >> 1;\\n if (r <= mid)\\n return query(l, r, L, mid, lchild[root]);\\n else if (l > mid)\\n return query(l, r, mid + 1, R, rchild[root]);\\n else\\n return query(l, mid, L, mid, lchild[root]) +\\n query(mid + 1, r, mid + 1, R, rchild[root]);\\n}\\nint main() {\\n int n, k, q, top = 0, x;\\n scanf(\\\"%d%d\\\", &n, &k);\\n for (int i = 1; i <= n; i++) {\\n scanf(\\\"%d\\\", &x);\\n vt[x].push_back(i);\\n insert(Time[top], Time[top + 1] = ++tot, i, 1, n, 1), top++;\\n if (vt[x].size() > k)\\n insert(Time[top], Time[top + 1] = ++tot, vt[x][vt[x].size() - k - 1], 1,\\n n, -1),\\n top++;\\n root[i] = Time[top];\\n }\\n int last = 0;\\n scanf(\\\"%d\\\", &q);\\n while (q--) {\\n int l, r;\\n scanf(\\\"%d%d\\\", &l, &r);\\n l = (l + last) % n + 1;\\n r = (r + last) % n + 1;\\n if (l > r) swap(l, r);\\n last = query(l, r, 1, n, root[r]);\\n printf(\\\"%d\\\\n\\\", last);\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Grandma Capa has decided to knit a scarf and asked Grandpa Sher to make a pattern for it, a pattern is a string consisting of lowercase English letters. Grandpa Sher wrote a string s of length n.\\n\\nGrandma Capa wants to knit a beautiful scarf, and in her opinion, a beautiful scarf can only be knit from a string that is a palindrome. She wants to change the pattern written by Grandpa Sher, but to avoid offending him, she will choose one lowercase English letter and erase some (at her choice, possibly none or all) occurrences of that letter in string s.\\n\\nShe also wants to minimize the number of erased symbols from the pattern. Please help her and find the minimum number of symbols she can erase to make string s a palindrome, or tell her that it's impossible. Notice that she can only erase symbols equal to the one letter she chose.\\n\\nA string is a palindrome if it is the same from the left to the right and from the right to the left. For example, the strings 'kek', 'abacaba', 'r' and 'papicipap' are palindromes, while the strings 'abb' and 'iq' are not.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. The next 2 ⋅ t lines contain the description of test cases. The description of each test case consists of two lines.\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 10^5) — the length of the string.\\n\\nThe second line of each test case contains the string s consisting of n lowercase English letters.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case print the minimum number of erased symbols required to make the string a palindrome, if it is possible, and -1, if it is impossible.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n8\\nabcaacab\\n6\\nxyzxyz\\n4\\nabba\\n8\\nrprarlap\\n10\\nkhyyhhyhky\\n\\n\\nOutput\\n\\n\\n2\\n-1\\n0\\n3\\n2\\n\\nNote\\n\\nIn the first test case, you can choose a letter 'a' and erase its first and last occurrences, you will get a string 'bcaacb', which is a palindrome. You can also choose a letter 'b' and erase all its occurrences, you...\",\"targets\":\"import java.io.ByteArrayInputStream;\\nimport java.io.IOException;\\nimport java.io.InputStream;\\nimport java.io.PrintWriter;\\nimport java.util.Arrays;\\nimport java.util.InputMismatchException;\\n\\n\\/\\/ Solution\\npublic class Solution {\\n\\n static InputStream is;\\n static PrintWriter out;\\n static String INPUT = \\\"\\\";\\n\\n static void solve() {\\n for (int T = ni(), cas = 1; T > 0; T--, cas++) {\\n \\/\\/out.print(\\\"Case #\\\" + cas + \\\": \\\");\\n go();\\n }\\n }\\n\\n static void go() {\\n int n = ni();\\n String s = ns();\\n\\n int ans = n + 1;\\n for (int c = 0; c < 26; ++c) {\\n int l = 0, r = n - 1, cnt = 0;\\n while (l <= r) {\\n if (s.charAt(l) == s.charAt(r)) {\\n l++;\\n r--;\\n }\\n else if (s.charAt(l) == (char) c + 'a' ) {\\n cnt++;\\n l++;\\n }\\n else if (s.charAt(r) == (char) c + 'a') {\\n cnt++;\\n r--;\\n }\\n else {\\n cnt = n + 1;\\n break;\\n }\\n }\\n ans = Math.min(ans, cnt);\\n }\\n if (ans == n + 1) ans = -1;\\n out.println(ans) ;\\n \\n \\n }\\n\\n public static void main(String[] args) throws Exception {\\n long S = System.currentTimeMillis();\\n is =\\n INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());\\n out = new PrintWriter(System.out);\\n\\n solve();\\n out.flush();\\n long G = System.currentTimeMillis();\\n tr(G - S + \\\"ms\\\");\\n }\\n\\n private static boolean eof() {\\n if (lenbuf == -1) return true;\\n int lptr = ptrbuf;\\n while (lptr < lenbuf) if (!isSpaceChar(inbuf[lptr++])) return false;\\n\\n try {\\n is.mark(1000);\\n while (true) {\\n int b = is.read();\\n if (b == -1) {\\n is.reset();\\n return true;\\n } else if (!isSpaceChar(b)) {\\n is.reset();\\n return false;\\n }\\n }\\n } catch (IOException e) {\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A chess tournament will be held soon, where n chess players will take part. Every participant will play one game against every other participant. Each game ends in either a win for one player and a loss for another player, or a draw for both players.\\n\\nEach of the players has their own expectations about the tournament, they can be one of two types:\\n\\n 1. a player wants not to lose any game (i. e. finish the tournament with zero losses); \\n 2. a player wants to win at least one game. \\n\\n\\n\\nYou have to determine if there exists an outcome for all the matches such that all the players meet their expectations. If there are several possible outcomes, print any of them. If there are none, report that it's impossible.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 200) — the number of test cases.\\n\\nThe first line of each test case contains one integer n (2 ≤ n ≤ 50) — the number of chess players.\\n\\nThe second line contains the string s (|s| = n; s_i ∈ \\\\{1, 2\\\\}). If s_i = 1, then the i-th player has expectations of the first type, otherwise of the second type.\\n\\nOutput\\n\\nFor each test case, print the answer in the following format:\\n\\nIn the first line, print NO if it is impossible to meet the expectations of all players.\\n\\nOtherwise, print YES, and the matrix of size n × n in the next n lines.\\n\\nThe matrix element in the i-th row and j-th column should be equal to:\\n\\n * +, if the i-th player won in a game against the j-th player; \\n * -, if the i-th player lost in a game against the j-th player; \\n * =, if the i-th and j-th players' game resulted in a draw; \\n * X, if i = j. \\n\\nExample\\n\\nInput\\n\\n\\n3\\n3\\n111\\n2\\n21\\n4\\n2122\\n\\n\\nOutput\\n\\n\\nYES\\nX==\\n=X=\\n==X\\nNO\\nYES\\nX--+\\n+X++\\n+-X-\\n--+X\\nt = i\",\"targets\":\"nt(input())\\nfor k in range(t):\\n n = int(input())\\n s = input()\\n ret = [['X' for i in range(n)] for j in range(n)]\\n twos = 0\\n ones = 0\\n for i in range(n):\\n if s[i] == '2':\\n twos += 1\\n else:\\n ones += 1\\n if twos == 1 or twos == 2:\\n print('NO')\\n continue\\n else:\\n print('YES')\\n for i in range(n):\\n p = s[i]\\n ex = False\\n for j in range(i + 1, n):\\n if p == '1':\\n if s[j] == '1':\\n ret[i][j] = '='\\n else:\\n ret[i][j] = '+'\\n else:\\n # k = twos.pop(0)\\n if s[j] == '1':\\n ret[i][j] = '-'\\n else:\\n if not ex:\\n ex = True\\n ret[i][j] = '+'\\n else:\\n ret[i][j] = '-'\\n \\n for i in range(n):\\n for j in range(0, i):\\n if ret[j][i] == '-':\\n ret[i][j] = '+'\\n elif ret[j][i] == '+':\\n ret[i][j] = '-'\\n else:\\n ret[i][j] = '='\\n \\n for i in range(n):\\n for j in range(n):\\n print(ret[i][j], end = '')\\n print()\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You had n positive integers a_1, a_2, ..., a_n arranged in a circle. For each pair of neighboring numbers (a_1 and a_2, a_2 and a_3, ..., a_{n - 1} and a_n, and a_n and a_1), you wrote down: are the numbers in the pair equal or not.\\n\\nUnfortunately, you've lost a piece of paper with the array a. Moreover, you are afraid that even information about equality of neighboring elements may be inconsistent. So, you are wondering: is there any array a which is consistent with information you have about equality or non-equality of corresponding pairs?\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases. Next t cases follow.\\n\\nThe first and only line of each test case contains a non-empty string s consisting of characters E and\\/or N. The length of s is equal to the size of array n and 2 ≤ n ≤ 50. For each i from 1 to n: \\n\\n * if s_i = E then a_i is equal to a_{i + 1} (a_n = a_1 for i = n); \\n * if s_i = N then a_i is not equal to a_{i + 1} (a_n ≠ a_1 for i = n). \\n\\nOutput\\n\\nFor each test case, print YES if it's possible to choose array a that are consistent with information from s you know. Otherwise, print NO.\\n\\nIt can be proved, that if there exists some array a, then there exists an array a of positive integers with values less or equal to 10^9.\\n\\nExample\\n\\nInput\\n\\n\\n4\\nEEE\\nEN\\nENNEENE\\nNENN\\n\\n\\nOutput\\n\\n\\nYES\\nNO\\nYES\\nYES\\n\\nNote\\n\\nIn the first test case, you can choose, for example, a_1 = a_2 = a_3 = 5.\\n\\nIn the second test case, there is no array a, since, according to s_1, a_1 is equal to a_2, but, according to s_2, a_2 is not equal to a_1.\\n\\nIn the third test case, you can, for example, choose array a = [20, 20, 4, 50, 50, 50, 20].\\n\\nIn the fourth test case, you can, for example, choose a = [1, 3, 3, 7].\\nUsing python3 can you solve the prior task?\",\"targets\":\"cases = input()\\n\\nfor a in range(int(cases)): \\n \\n s = str(input())\\n \\n n = [c for c in s if c == 'N']\\n ll = len(n)\\n\\n if ll == 1:\\n print('NO')\\n else:\\n print('YES')\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Ahmed and Mostafa used to compete together in many programming contests for several years. Their coach Fegla asked them to solve one challenging problem, of course Ahmed was able to solve it but Mostafa couldn't.\\n\\nThis problem is similar to a standard problem but it has a different format and constraints.\\n\\nIn the standard problem you are given an array of integers, and you have to find one or more consecutive elements in this array where their sum is the maximum possible sum.\\n\\nBut in this problem you are given n small arrays, and you will create one big array from the concatenation of one or more instances of the small arrays (each small array could occur more than once). The big array will be given as an array of indexes (1-based) of the small arrays, and the concatenation should be done in the same order as in this array. Then you should apply the standard problem mentioned above on the resulting big array.\\n\\nFor example let's suppose that the small arrays are {1, 6, -2}, {3, 3} and {-5, 1}. And the indexes in the big array are {2, 3, 1, 3}. So the actual values in the big array after formatting it as concatenation of the small arrays will be {3, 3, -5, 1, 1, 6, -2, -5, 1}. In this example the maximum sum is 9.\\n\\nCan you help Mostafa solve this problem?\\n\\nInput\\n\\nThe first line contains two integers n and m, n is the number of the small arrays (1 ≤ n ≤ 50), and m is the number of indexes in the big array (1 ≤ m ≤ 250000). Then follow n lines, the i-th line starts with one integer l which is the size of the i-th array (1 ≤ l ≤ 5000), followed by l integers each one will be greater than or equal -1000 and less than or equal 1000. The last line contains m integers which are the indexes in the big array, and you should concatenate the small arrays in the same order, and each index will be greater than or equal to 1 and less than or equal to n.\\n\\nThe small arrays are numbered from 1 to n in the same order as given in the input. Some of the given small arrays may not be used in big array.\\n\\nNote, that the array is very...\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.BufferedWriter;\\nimport java.io.InputStreamReader;\\nimport java.io.OutputStreamWriter;\\nimport java.io.PrintWriter;\\nimport java.util.Scanner;\\n\\npublic class s67_d {\\n\\tstatic int n, m;\\n\\tstatic long[] gen = new long[50], lft = new long[50], rght = new long[50],\\n\\t\\t\\ttot = new long[50];\\n\\n\\tpublic static void main(String[] args) {\\n\\t\\tBufferedReader bfin = new BufferedReader(new InputStreamReader(\\n\\t\\t\\t\\tSystem.in));\\n\\t\\tBufferedWriter bfout = new BufferedWriter(new OutputStreamWriter(\\n\\t\\t\\t\\tSystem.out));\\n\\t\\tScanner cin = new Scanner(bfin);\\n\\t\\tPrintWriter cout = new PrintWriter(bfout);\\n\\t\\tn = cin.nextInt();\\n\\t\\tm = cin.nextInt();\\n\\t\\tint len, num;\\n\\t\\tfor (int i = 0; i < n; i++) {\\n\\t\\t\\tlen = cin.nextInt();\\n\\t\\t\\tint mx = -(1 << 30);\\n\\t\\t\\tint sum = 0;\\n\\t\\t\\tfor (int j = 0; j < len; j++) {\\n\\t\\t\\t\\tnum = cin.nextInt();\\n\\t\\t\\t\\ttot[i] += num;\\n\\t\\t\\t\\tlft[i] = Math.max(lft[i], tot[i]);\\n\\t\\t\\t\\trght[i] = Math.min(rght[i], tot[i]);\\n\\t\\t\\t\\tmx = Math.max(mx, num);\\n\\t\\t\\t\\tsum += num;\\n\\t\\t\\t\\tif (sum < 0)\\n\\t\\t\\t\\t\\tsum = 0;\\n\\t\\t\\t\\telse\\n\\t\\t\\t\\t\\tmx = Math.max(mx, sum);\\n\\t\\t\\t}\\n\\t\\t\\tgen[i] = mx;\\n\\t\\t\\trght[i] = tot[i] - rght[i];\\n\\t\\t}\\n\\t\\tlong cur = 0;\\n\\t\\tlong best = (long) (-1e18);\\n\\t\\twhile (m-- > 0) {\\n\\t\\t\\tint i;\\n\\t\\t\\ti = cin.nextInt();\\n\\t\\t\\ti--;\\n\\t\\t\\tbest = Math.max(best, gen[i]);\\n\\t\\t\\tif (cur > 0)\\n\\t\\t\\t\\tbest = Math.max(best, cur + lft[i]);\\n\\t\\t\\tcur = Math.max(0, Math.max(rght[i], cur + tot[i]));\\n\\t\\t}\\n\\t\\tSystem.out.println(best);\\n\\t\\tcout.close();\\n\\t}\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Each employee of the \\\"Blake Techologies\\\" company uses a special messaging app \\\"Blake Messenger\\\". All the stuff likes this app and uses it constantly. However, some important futures are missing. For example, many users want to be able to search through the message history. It was already announced that the new feature will appear in the nearest update, when developers faced some troubles that only you may help them to solve.\\n\\nAll the messages are represented as a strings consisting of only lowercase English letters. In order to reduce the network load strings are represented in the special compressed form. Compression algorithm works as follows: string is represented as a concatenation of n blocks, each block containing only equal characters. One block may be described as a pair (li, ci), where li is the length of the i-th block and ci is the corresponding letter. Thus, the string s may be written as the sequence of pairs .\\n\\nYour task is to write the program, that given two compressed string t and s finds all occurrences of s in t. Developers know that there may be many such occurrences, so they only ask you to find the number of them. Note that p is the starting position of some occurrence of s in t if and only if tptp + 1...tp + |s| - 1 = s, where ti is the i-th character of string t.\\n\\nNote that the way to represent the string in compressed form may not be unique. For example string \\\"aaaa\\\" may be given as , , ...\\n\\nInput\\n\\nThe first line of the input contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of blocks in the strings t and s, respectively.\\n\\nThe second line contains the descriptions of n parts of string t in the format \\\"li-ci\\\" (1 ≤ li ≤ 1 000 000) — the length of the i-th part and the corresponding lowercase English letter.\\n\\nThe second line contains the descriptions of m parts of string s in the format \\\"li-ci\\\" (1 ≤ li ≤ 1 000 000) — the length of the i-th part and the corresponding lowercase English letter.\\n\\nOutput\\n\\nPrint a single integer — the number of...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nstruct dat {\\n long long l;\\n char c;\\n friend bool operator<=(const dat &d1, const dat &d2) {\\n return (d1.c == d2.c) && (d1.l <= d2.l);\\n }\\n friend bool operator==(const dat &d1, const dat &d2) {\\n return (d1.c == d2.c) && (d1.l == d2.l);\\n }\\n} a[200001], b[200001];\\nint f[200001], n, m;\\nvoid cp(dat *a, int &n) {\\n int m = 0;\\n for (int i = 0; i < n; ++i) {\\n if (m == 0 || a[m - 1].c != a[i].c)\\n a[m++] = a[i];\\n else\\n a[m - 1].l += a[i].l;\\n }\\n n = m;\\n}\\nint main() {\\n scanf(\\\"%d%d\\\", &n, &m);\\n for (int i = 0; i < n; ++i) scanf(\\\"%lld-%c\\\", &a[i].l, &a[i].c);\\n for (int i = 0; i < m; ++i) scanf(\\\"%lld-%c\\\", &b[i].l, &b[i].c);\\n cp(a, n);\\n cp(b, m);\\n long long ans = 0;\\n switch (m) {\\n case 1: {\\n for (int i = 0; i < n; ++i)\\n if (b[0] <= a[i]) ans += a[i].l - b[0].l + 1;\\n break;\\n }\\n case 2: {\\n for (int i = 0; i < n - 1; ++i)\\n if (b[0] <= a[i] && b[1] <= a[i + 1]) ++ans;\\n break;\\n }\\n default: {\\n f[1] = 0;\\n for (int i = 2; i < m - 1; i++) {\\n int j = f[i - 1];\\n while (j > 0 && !(b[j + 1] == b[i])) j = f[j];\\n if (b[j + 1] == b[i]) j++;\\n f[i] = j;\\n }\\n for (int i = 1, j = 0; i < n - 1; i++) {\\n while (j > 0 && !(b[j + 1] == a[i])) j = f[j];\\n if (b[j + 1] == a[i]) j++;\\n if (j == m - 2) {\\n if (b[0] <= a[i - j] && b[j + 1] <= a[i + 1]) ans++;\\n j = f[j];\\n }\\n }\\n }\\n }\\n printf(\\\"%lld\\\\n\\\", ans);\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"n students attended the first meeting of the Berland SU programming course (n is even). All students will be divided into two groups. Each group will be attending exactly one lesson each week during one of the five working days (Monday, Tuesday, Wednesday, Thursday and Friday), and the days chosen for the groups must be different. Furthermore, both groups should contain the same number of students.\\n\\nEach student has filled a survey in which they told which days of the week are convenient for them to attend a lesson, and which are not. \\n\\nYour task is to determine if it is possible to choose two different week days to schedule the lessons for the group (the first group will attend the lesson on the first chosen day, the second group will attend the lesson on the second chosen day), and divide the students into two groups, so the groups have equal sizes, and for each student, the chosen lesson day for their group is convenient.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.\\n\\nThen the descriptions of t testcases follow.\\n\\nThe first line of each testcase contains one integer n (2 ≤ n ≤ 1 000) — the number of students.\\n\\nThe i-th of the next n lines contains 5 integers, each of them is 0 or 1. If the j-th integer is 1, then the i-th student can attend the lessons on the j-th day of the week. If the j-th integer is 0, then the i-th student cannot attend the lessons on the j-th day of the week. \\n\\nAdditional constraints on the input: for each student, at least one of the days of the week is convenient, the total number of students over all testcases doesn't exceed 10^5.\\n\\nOutput\\n\\nFor each testcase print an answer. If it's possible to divide the students into two groups of equal sizes and choose different days for the groups so each student can attend the lesson in the chosen day of their group, print \\\"YES\\\" (without quotes). Otherwise, print \\\"NO\\\" (without quotes). \\n\\nExample\\n\\nInput\\n\\n\\n2\\n4\\n1 0 0 1 0\\n0 1 0 0 1\\n0 0 0 1 0\\n0 1 0 1 0\\n2\\n0 0 0 1 0\\n0 0 0 1 0\\n\\n\\nOutput\\n\\n\\nYES\\nNO\\n\\nNote\\n\\nIn...\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.util.ArrayList;\\nimport java.util.Collections;\\nimport java.util.HashSet;\\nimport java.util.StringTokenizer;\\n\\n\\npublic class B {\\n\\n\\tpublic static void main(String[] args)\\n {\\n FastReader s=new FastReader();\\n int t = s.nextInt(); \\/\\/ Number of test cases\\n for (int i = 0; i= n\\/2 && count2 >= n\\/2) {\\n \\t\\t\\t\\tSystem.out.println(\\\"Yes\\\");\\n \\t\\t\\t\\tdone = true;\\n \\t\\t\\t\\tbreak;\\n \\t\\t\\t}\\n \\t\\t}\\n \\t\\tif (done == true) break;\\n \\t}\\n \\tif (done == false) System.out.println(\\\"No\\\");\\n }\\n\\n \\n \\n\\n \\n \\n }\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n static void sort(int[] a) {\\n \\tArrayList l = new ArrayList<>();\\n \\tfor (int i : a) l.add(i);\\n \\tCollections.sort(l);\\n \\tfor (int i = 0; i{\\n\\t \\tint slotNo;\\n\\t ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nGiven any integer x, Aoki can do the operation below.\\n\\nOperation: Replace x with the absolute difference of x and K.\\n\\nYou are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.\\n\\nConstraints\\n\\n* 0 ≤ N ≤ 10^{18}\\n* 1 ≤ K ≤ 10^{18}\\n* All values in input are integers.\\n\\nInput\\n\\nInput is given from Standard Input in the following format:\\n\\n\\nN K\\n\\n\\nOutput\\n\\nPrint the minimum possible value taken by N after Aoki does the operation zero or more times.\\n\\nExamples\\n\\nInput\\n\\n7 4\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\n2 6\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n1000000000000000000 1\\n\\n\\nOutput\\n\\n0\",\"targets\":\"#include\\n#define min(a,b) (a\\n\\nIn the first query, their movement from the 1-st to the 2-nd room is as follows.\\n\\n * 1 → 5 — takes max(|10 + 4|, |10 - 4|) = 14 energy. \\n * 5 → 6 — takes max(|4 + (-6)|, |4 - (-6)|) = 10 energy. \\n * 6 → 2 —...\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nvoid read(int& x) { scanf(\\\"%d\\\", &x); }\\nvoid read(long long& x) { scanf(\\\"%lld\\\", &x); }\\nvoid read(double& x) { scanf(\\\"%lf\\\", &x); }\\nlong long gcd(long long x, long long y) {\\n while (y) {\\n long long t = x % y;\\n x = y;\\n y = t;\\n }\\n return x;\\n}\\nvoid update(vector& b, int sp, int x, long long val) {\\n x += sp;\\n b[x] = val;\\n x >>= 1;\\n while (x >= 1) {\\n b[x] = b[x << 1] + b[(x << 1) + 1];\\n x >>= 1;\\n }\\n}\\nlong long query(vector& b, int sp, int s, int e) {\\n s += sp;\\n e += sp;\\n long long ret = 0;\\n while (s <= e) {\\n if (s == e) {\\n ret += b[s];\\n break;\\n }\\n if (s & 1) {\\n ret += b[s];\\n s = (s + 1) >> 1;\\n } else\\n s >>= 1;\\n if (e & 1)\\n e >>= 1;\\n else {\\n ret += b[e];\\n e = (e - 1) >> 1;\\n }\\n }\\n return ret;\\n}\\nint lca(int u, int v, vector>& pars, vector& h) {\\n int d = h[v] - h[u];\\n for (int k = 0; d; k++, d >>= 1) {\\n if (d & 1) v = pars[v][k];\\n }\\n if (u == v) return u;\\n for (int k = pars[u].size() - 1; k >= 0; k--) {\\n if (k >= pars[u].size() || pars[u][k] == pars[v][k]) continue;\\n u = pars[u][k];\\n v = pars[v][k];\\n }\\n return pars[u][0];\\n}\\nvoid print_tree(int sp, vector& b) {\\n for (int i = 1; i < (sp * 2); i++) {\\n printf(\\\"%d \\\", b[i]);\\n if ((i & (i + 1)) == 0) printf(\\\"\\\\n\\\");\\n }\\n printf(\\\"\\\\n\\\");\\n}\\nvoid solve() {\\n int n, q;\\n scanf(\\\"%d%d\\\", &n, &q);\\n vector a(n + 1);\\n for (int i = 1; i <= n; i++) {\\n scanf(\\\"%lld\\\", &a[i]);\\n if (a[i] < 0) a[i] = -a[i];\\n }\\n vector> adj(n + 1);\\n for (int i = 1; i < n; i++) {\\n int u, v;\\n scanf(\\\"%d%d\\\", &u, &v);\\n adj[u].push_back(v);\\n adj[v].push_back(u);\\n }\\n vector h(n + 1, -1);\\n vector> pars(n + 1);\\n {\\n vector q;\\n q.push_back(1);\\n int hd = 0;\\n h[1] = 0;\\n while (hd < q.size()) {\\n int u = q[hd++];\\n if (pars[u].size()) {\\n for (int k = 1; k - 1 < pars[pars[u][k - 1]].size(); k++) {\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"The city where Mocha lives in is called Zhijiang. There are n+1 villages and 2n-1 directed roads in this city. \\n\\nThere are two kinds of roads:\\n\\n * n-1 roads are from village i to village i+1, for all 1≤ i ≤ n-1. \\n * n roads can be described by a sequence a_1,…,a_n. If a_i=0, the i-th of these roads goes from village i to village n+1, otherwise it goes from village n+1 to village i, for all 1≤ i≤ n. \\n\\n\\n\\nMocha plans to go hiking with Taki this weekend. To avoid the trip being boring, they plan to go through every village exactly once. They can start and finish at any villages. Can you help them to draw up a plan? \\n\\nInput\\n\\nEach test contains multiple test cases. \\n\\nThe first line contains a single integer t (1 ≤ t ≤ 20) — the number of test cases. Each test case consists of two lines.\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 10^4) — indicates that the number of villages is n+1.\\n\\nThe second line of each test case contains n integers a_1, a_2, …, a_n (0 ≤ a_i ≤ 1). If a_i=0, it means that there is a road from village i to village n+1. If a_i=1, it means that there is a road from village n+1 to village i.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 10^4.\\n\\nOutput\\n\\nFor each test case, print a line with n+1 integers, where the i-th number is the i-th village they will go through. If the answer doesn't exist, print -1.\\n\\nIf there are multiple correct answers, you can print any one of them.\\n\\nExample\\n\\nInput\\n\\n\\n2\\n3\\n0 1 0\\n3\\n1 1 0\\n\\n\\nOutput\\n\\n\\n1 4 2 3 \\n4 1 2 3 \\n\\nNote\\n\\nIn the first test case, the city looks like the following graph:\\n\\n\\n\\nSo all possible answers are (1 → 4 → 2 → 3), (1 → 2 → 3 → 4).\\n\\nIn the second test case, the city looks like the following graph:\\n\\n\\n\\nSo all possible answers are (4 → 1 → 2 → 3), (1 → 2 → 3 → 4), (3 → 4 → 1 → 2), (2 → 3 → 4 → 1).\\nt = i\",\"targets\":\"nt(input())\\n\\nfor _ in range(t):\\n n = int(input())\\n\\n a = list(map(int, input().split()))\\n\\n l = 0\\n flag = False\\n if a[0] == 1:\\n print(n+1, *list(range(1, n+1)))\\n else:\\n while flag == False:\\n l += 1\\n if l == n:\\n print(*list(range(1, n+2)))\\n flag = True\\n elif a[l] == 1:\\n print(*list(range(1, l+1)), n + 1, *list(range(l+1, n + 1)))\\n flag = True\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alice and Bob are playing a fun game of tree tag.\\n\\nThe game is played on a tree of n vertices numbered from 1 to n. Recall that a tree on n vertices is an undirected, connected graph with n-1 edges.\\n\\nInitially, Alice is located at vertex a, and Bob at vertex b. They take turns alternately, and Alice makes the first move. In a move, Alice can jump to a vertex with distance at most da from the current vertex. And in a move, Bob can jump to a vertex with distance at most db from the current vertex. The distance between two vertices is defined as the number of edges on the unique simple path between them. In particular, either player is allowed to stay at the same vertex in a move. Note that when performing a move, a player only occupies the starting and ending vertices of their move, not the vertices between them.\\n\\nIf after at most 10^{100} moves, Alice and Bob occupy the same vertex, then Alice is declared the winner. Otherwise, Bob wins.\\n\\nDetermine the winner if both players play optimally.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^4). Description of the test cases follows.\\n\\nThe first line of each test case contains five integers n,a,b,da,db (2≤ n≤ 10^5, 1≤ a,b≤ n, a≠ b, 1≤ da,db≤ n-1) — the number of vertices, Alice's vertex, Bob's vertex, Alice's maximum jumping distance, and Bob's maximum jumping distance, respectively.\\n\\nThe following n-1 lines describe the edges of the tree. The i-th of these lines contains two integers u, v (1≤ u, v≤ n, u≠ v), denoting an edge between vertices u and v. It is guaranteed that these edges form a tree structure.\\n\\nIt is guaranteed that the sum of n across all test cases does not exceed 10^5.\\n\\nOutput\\n\\nFor each test case, output a single line containing the winner of the game: \\\"Alice\\\" or \\\"Bob\\\".\\n\\nExample\\n\\nInput\\n\\n\\n4\\n4 3 2 1 2\\n1 2\\n1 3\\n1 4\\n6 6 1 2 5\\n1 2\\n6 5\\n2 3\\n3 4\\n4 5\\n9 3 9 2 5\\n1 2\\n1 6\\n1 9\\n1 3\\n9 5\\n7 9\\n4 8\\n4 3\\n11 8 11 3 3\\n1 2\\n11 9\\n4 9\\n6 5\\n2 10\\n3 2\\n5 9\\n8 3\\n7 4\\n7 10\\n\\n\\nOutput\\n\\n\\nAlice\\nBob\\nAlice\\nAlice\\n\\nNote\\n\\nIn the...\\nUsing python3 can you solve the prior task?\",\"targets\":\"import collections\\nimport sys\\n\\n\\n*data, = map(int, sys.stdin.read().split()[::-1])\\ndef inp():\\n return int(data.pop())\\n\\nUNDEF = -1\\n\\ndef bfs(g, v):\\n distances = [UNDEF] * len(g)\\n q = collections.deque()\\n q.append(v)\\n distances[v] = 0\\n while q:\\n v = q.popleft()\\n for w in g[v]:\\n if distances[w] == UNDEF:\\n distances[w] = distances[v] + 1\\n q.append(w)\\n return distances\\n\\n\\ndef diameter(g):\\n distances = bfs(g, 0)\\n best_i = 0\\n for i in range(len(g)):\\n if distances[i] > distances[best_i]:\\n best_i = i\\n distances = bfs(g, best_i)\\n return max(distances)\\n\\n\\ndef solve(g, a, b, da, db):\\n if 2 * da >= db:\\n return True\\n distances = bfs(g, a)\\n if distances[b] <= da:\\n return True\\n diam = diameter(g)\\n # print(da, db, diam)\\n if 2 * da >= diam:\\n return True\\n if da < db:\\n return False\\n return False\\n raise RuntimeError(\\\"\\\")\\n\\nfor _ in range(int(inp())):\\n n, a, b, da, db = inp(), inp(), inp(), inp(), inp()\\n a -= 1\\n b -= 1\\n g = [[] for _ in range(n)]\\n for _ in range(n - 1):\\n src, dst = inp(), inp()\\n src -= 1\\n dst -= 1\\n g[src].append(dst)\\n g[dst].append(src)\\n print(\\\"Alice\\\" if solve(g, a, b, da, db) else \\\"Bob\\\")\\n # print('*'* 10)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Polycarp must pay exactly n burles at the checkout. He has coins of two nominal values: 1 burle and 2 burles. Polycarp likes both kinds of coins equally. So he doesn't want to pay with more coins of one type than with the other.\\n\\nThus, Polycarp wants to minimize the difference between the count of coins of 1 burle and 2 burles being used. Help him by determining two non-negative integer values c_1 and c_2 which are the number of coins of 1 burle and 2 burles, respectively, so that the total value of that number of coins is exactly n (i. e. c_1 + 2 ⋅ c_2 = n), and the absolute value of the difference between c_1 and c_2 is as little as possible (i. e. you must minimize |c_1-c_2|).\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10^4) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one line. This line contains one integer n (1 ≤ n ≤ 10^9) — the number of burles to be paid by Polycarp.\\n\\nOutput\\n\\nFor each test case, output a separate line containing two integers c_1 and c_2 (c_1, c_2 ≥ 0) separated by a space where c_1 is the number of coins of 1 burle and c_2 is the number of coins of 2 burles. If there are multiple optimal solutions, print any one.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n1000\\n30\\n1\\n32\\n1000000000\\n5\\n\\n\\nOutput\\n\\n\\n334 333\\n10 10\\n1 0\\n10 11\\n333333334 333333333\\n1 2\\n\\nNote\\n\\nThe answer for the first test case is \\\"334 333\\\". The sum of the nominal values of all coins is 334 ⋅ 1 + 333 ⋅ 2 = 1000, whereas |334 - 333| = 1. One can't get the better value because if |c_1 - c_2| = 0, then c_1 = c_2 and c_1 ⋅ 1 + c_1 ⋅ 2 = 1000, but then the value of c_1 isn't an integer.\\n\\nThe answer for the second test case is \\\"10 10\\\". The sum of the nominal values is 10 ⋅ 1 + 10 ⋅ 2 = 30 and |10 - 10| = 0, whereas there's no number having an absolute value less than 0.\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.BufferedWriter;\\nimport java.io.DataInputStream;\\nimport java.io.FileReader;\\nimport java.io.FileWriter;\\nimport java.io.IOException;\\nimport java.io.InputStream;\\nimport java.io.InputStreamReader;\\nimport java.io.OutputStream;\\nimport java.io.OutputStreamWriter;\\nimport java.io.PrintWriter;\\nimport java.io.Writer;\\nimport java.util.*;\\npublic class Main{\\n static int modulo=(int)1e9+7;\\n public static void main(String[] args) throws IOException {\\n\\tScanner in=new Scanner(System.in);\\n int test=in.nextInt();\\n StringBuilder sb=new StringBuilder();\\n while(test-->0){\\n long n=in.nextInt();\\n if(n%3==0){\\n System.out.println(n\\/3+\\\" \\\"+(n\\/3));\\n }\\n else if(n%3==1){\\n System.out.println((n\\/3+1)+\\\" \\\"+(n\\/3));\\n }\\n else{\\n System.out.println((n\\/3)+\\\" \\\"+(n\\/3+1));\\n }\\n }\\n \\n }\\n }\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nDenis was very sad after Nastya rejected him. So he decided to walk through the gateways to have some fun. And luck smiled at him! When he entered the first courtyard, he met a strange man who was selling something. \\n\\nDenis bought a mysterious item and it was... Random permutation generator! Denis could not believed his luck.\\n\\nWhen he arrived home, he began to study how his generator works and learned the algorithm. The process of generating a permutation consists of n steps. At the i-th step, a place is chosen for the number i (1 ≤ i ≤ n). The position for the number i is defined as follows:\\n\\n * For all j from 1 to n, we calculate r_j — the minimum index such that j ≤ r_j ≤ n, and the position r_j is not yet occupied in the permutation. If there are no such positions, then we assume that the value of r_j is not defined. \\n * For all t from 1 to n, we calculate count_t — the number of positions 1 ≤ j ≤ n such that r_j is defined and r_j = t. \\n * Consider the positions that are still not occupied by permutation and among those we consider the positions for which the value in the count array is maximum. \\n * The generator selects one of these positions for the number i. The generator can choose any position. \\n\\n\\n\\nLet's have a look at the operation of the algorithm in the following example:\\n\\n\\n\\nLet n = 5 and the algorithm has already arranged the numbers 1, 2, 3 in the permutation. Consider how the generator will choose a position for the number 4:\\n\\n * The values of r will be r = [3, 3, 3, 4, ×], where × means an indefinite value. \\n * Then the count values will be count = [0, 0, 3, 1, 0]. \\n * There are only two unoccupied positions in the permutation: 3 and 4. The value in the count array for position 3 is 3, for position 4 it is 1. \\n * The maximum value is reached only for position 3, so the algorithm will uniquely select this position for number 4. \\n\\n\\n\\nSatisfied with his purchase, Denis went home. For several days without a break, he generated permutations. He believes that he can come up with...\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 1e5;\\nint cnt[N + 100], vis[N + 100];\\nint main() {\\n int t;\\n scanf(\\\"%d\\\", &t);\\n while (t--) {\\n int n;\\n set > stp;\\n set sti;\\n scanf(\\\"%d\\\", &n);\\n for (int i = 1; i <= n; i++) {\\n int p;\\n scanf(\\\"%d\\\", &p);\\n vis[p] = i;\\n stp.insert(make_pair(1, i));\\n sti.insert(i);\\n cnt[i] = 1;\\n }\\n bool flag = true;\\n for (int i = 1; i <= n; i++) {\\n auto e = stp.end();\\n e--;\\n int cur = vis[i];\\n if (e->first != cnt[cur]) {\\n flag = false;\\n break;\\n }\\n sti.erase(cur);\\n stp.erase(make_pair(cnt[cur], cur));\\n auto nxt = sti.lower_bound(cur);\\n if (nxt != sti.end()) {\\n int del = *nxt;\\n stp.erase(make_pair(cnt[del], del));\\n cnt[del] += cnt[cur];\\n stp.insert(make_pair(cnt[del], del));\\n }\\n }\\n if (flag == true) {\\n printf(\\\"Yes\\\\n\\\");\\n } else {\\n printf(\\\"No\\\\n\\\");\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"This is an easier version of the problem with smaller constraints.\\n\\nKorney Korneevich dag up an array a of length n. Korney Korneevich has recently read about the operation [bitwise XOR](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#XOR), so he wished to experiment with it. For this purpose, he decided to find all integers x ≥ 0 such that there exists an increasing subsequence of the array a, in which the bitwise XOR of numbers is equal to x.\\n\\nIt didn't take a long time for Korney Korneevich to find all such x, and he wants to check his result. That's why he asked you to solve this problem!\\n\\nA sequence s is a subsequence of a sequence b if s can be obtained from b by deletion of several (possibly, zero or all) elements.\\n\\nA sequence s_1, s_2, … , s_m is called increasing if s_1 < s_2 < … < s_m.\\n\\nInput\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 10^5).\\n\\nThe second line contains n integers a_1, a_2, …, a_n (0 ≤ a_i ≤ 500) — the elements of the array a.\\n\\nOutput\\n\\nIn the first line print a single integer k — the number of found x values.\\n\\nIn the second line print k integers in increasing order x_1, x_2, … x_k (0 ≤ x_1 < … < x_k) — found x values.\\n\\nExamples\\n\\nInput\\n\\n\\n4\\n4 2 2 4\\n\\n\\nOutput\\n\\n\\n4\\n0 2 4 6 \\n\\n\\nInput\\n\\n\\n8\\n1 0 1 7 12 5 3 2\\n\\n\\nOutput\\n\\n\\n12\\n0 1 2 3 4 5 6 7 10 11 12 13 \\n\\nNote\\n\\nIn the first test case:\\n\\n * To get value x = 0 it is possible to choose and empty subsequence \\n * To get value x = 2 it is possible to choose a subsequence [2] \\n * To get value x = 4 it is possible to choose a subsequence [4] \\n * To get value x = 6 it is possible to choose a subsequence [2, 4] \\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\ntemplate \\nstruct rge {\\n c b, e;\\n};\\ntemplate \\nrge range(c i, c j) {\\n return rge{i, j};\\n}\\ntemplate \\nauto dud(c *x) -> decltype(cerr << *x, 0);\\ntemplate \\nchar dud(...);\\nstruct debug {\\n template \\n debug &operator<<(const c &) {\\n return *this;\\n }\\n};\\nlong long __pow(long long x, long long y, long long M) {\\n long long res = 1;\\n while (y > 0) {\\n if (y & 1) res = (res * x) % M;\\n y >>= 1;\\n x = (x * x) % M;\\n }\\n return res % M;\\n}\\nlong long __pow(long long x, long long y) {\\n long long res = 1;\\n while (y > 0) {\\n if (y & 1) res = (res * x);\\n y >>= 1;\\n x = (x * x);\\n }\\n return res;\\n}\\nlong long mi(long long x, long long M) { return __pow(x, M - 2, M); }\\nlong long mul(vector a, long long M) {\\n long long res = 1;\\n for (auto x : a) res = (res * x) % M;\\n return res;\\n}\\nlong long cl(long long a, long long b) {\\n if (a % b == 0) return a \\/ b;\\n return a \\/ b + 1;\\n}\\nvoid umax(long long &a, long long b) { a = max(a, b); }\\nvoid umin(long long &a, long long b) { a = min(a, b); }\\nconst long long N = 2e5 + 2, inf = 1e18, M = 998244353, LN = 20;\\nlong long Test, n, m, k, q, a[N];\\nbool ok = 1;\\nclass BIT {\\n long long n, VAL;\\n vector bit;\\n\\n public:\\n BIT() {}\\n BIT(long long _n, long long val) {\\n n = _n;\\n VAL = val;\\n bit.assign(2 * n + 2, VAL);\\n }\\n long long todo(long long a, long long b) { return a + b; }\\n void update(long long i, long long x) {\\n i++;\\n for (; i <= n; i += (i & -i)) bit[i] = todo(bit[i], x);\\n }\\n long long get(long long i) {\\n i++;\\n long long res = VAL;\\n for (; i; i -= (i & -i)) res = todo(res, bit[i]);\\n return res;\\n }\\n};\\nvoid test_case() {\\n cin >> n;\\n vector trees(512);\\n for (long long i = 0; i <= 511; i++) trees[i] = BIT(512, 0);\\n vector vis(512);\\n vis[0] = 1;\\n long long cnt = 1;\\n for (long long i = 1, x; i <= n; i++) {\\n cin >> x;\\n if (!vis[x]) cnt++;\\n vis[x] = 1;\\n trees[x].update(x, 1);\\n for (long long j =...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"This is the hard version of the problem. The only difference between the two versions is the constraint on n. You can make hacks only if all versions of the problem are solved.\\n\\nA forest is an undirected graph without cycles (not necessarily connected).\\n\\nMocha and Diana are friends in Zhijiang, both of them have a forest with nodes numbered from 1 to n, and they would like to add edges to their forests such that: \\n\\n * After adding edges, both of their graphs are still forests. \\n * They add the same edges. That is, if an edge (u, v) is added to Mocha's forest, then an edge (u, v) is added to Diana's forest, and vice versa. \\n\\n\\n\\nMocha and Diana want to know the maximum number of edges they can add, and which edges to add.\\n\\nInput\\n\\nThe first line contains three integers n, m_1 and m_2 (1 ≤ n ≤ 10^5, 0 ≤ m_1, m_2 < n) — the number of nodes and the number of initial edges in Mocha's forest and Diana's forest.\\n\\nEach of the next m_1 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the edges in Mocha's forest.\\n\\nEach of the next m_2 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the edges in Diana's forest.\\n\\nOutput\\n\\nThe first line contains only one integer h, the maximum number of edges Mocha and Diana can add.\\n\\nEach of the next h lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the edge you add each time.\\n\\nIf there are multiple correct answers, you can print any one of them.\\n\\nExamples\\n\\nInput\\n\\n\\n3 2 2\\n1 2\\n2 3\\n1 2\\n1 3\\n\\n\\nOutput\\n\\n\\n0\\n\\n\\nInput\\n\\n\\n5 3 2\\n5 4\\n2 1\\n4 3\\n4 3\\n1 4\\n\\n\\nOutput\\n\\n\\n1\\n2 4\\n\\n\\nInput\\n\\n\\n8 1 2\\n1 7\\n2 6\\n1 5\\n\\n\\nOutput\\n\\n\\n5\\n5 2\\n2 3\\n3 4\\n4 7\\n6 8\\n\\nNote\\n\\nIn the first example, we cannot add any edge.\\n\\nIn the second example, the initial forests are as follows.\\n\\n\\n\\nWe can add an edge (2, 4).\\n\\n\\\":\",\"targets\":\"#include \\nusing namespace std;\\nconst long long mod = 998244353;\\nconst long long N = 3e5 + 5;\\nconst double eps = 1e-8;\\nconst double PI = acos(-1);\\nlong long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }\\nlong long re() {\\n long long x;\\n scanf(\\\"%lld\\\", &x);\\n return x;\\n}\\nlong long qk(long long a, long long b) {\\n long long ans = 1;\\n while (b) {\\n if (b & 1) ans = ans * a % mod;\\n a = a * a % mod;\\n b \\/= 2;\\n }\\n return ans;\\n}\\nint dx[8] = {1, 0, -1, 0, 1, 1, -1, -1}, dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};\\nint a[N], b[N];\\nvector v1, v2;\\nint fina(int x) { return a[x] = a[x] == x ? x : fina(a[x]); }\\nint finb(int x) { return b[x] = b[x] == x ? x : finb(b[x]); }\\nvoid solve() {\\n int n, m1, m2;\\n cin >> n >> m1 >> m2;\\n for (int i = 1; i <= n; i++) a[i] = i, b[i] = i;\\n int x, y;\\n for (int i = 1; i <= m1; i++) {\\n scanf(\\\"%d%d\\\", &x, &y);\\n a[fina(x)] = fina(y);\\n }\\n for (int i = 1; i <= m2; i++) {\\n scanf(\\\"%d%d\\\", &x, &y);\\n b[finb(x)] = finb(y);\\n }\\n vector > v;\\n for (int i = 1; i <= 1; i++) {\\n for (int j = i + 1; j <= n; j++) {\\n if (fina(i) != fina(j) && finb(i) != finb(j)) {\\n a[fina(i)] = fina(j);\\n b[finb(i)] = finb(j);\\n v.emplace_back(make_pair(i, j));\\n }\\n if (fina(j) != fina(1)) v1.emplace_back(j);\\n if (finb(j) != finb(1)) v2.emplace_back(j);\\n }\\n }\\n for (int i = 0, j = 0; i < v1.size() && j < v2.size();) {\\n if (fina(v1[i]) == fina(1) && finb(v1[i]) == finb(1)) {\\n i++;\\n continue;\\n }\\n if (fina(v2[j]) == fina(1) && finb(v2[j]) == finb(1)) {\\n j++;\\n continue;\\n }\\n a[fina(v1[i])] = fina(v2[j]);\\n b[finb(v1[i])] = finb(v2[j]);\\n v.emplace_back(v1[i], v2[j]);\\n }\\n cout << v.size() << '\\\\n';\\n for (int i = 0; i < v.size(); i++) {\\n printf(\\\"%d %d\\\\n\\\", v[i].first, v[i].second);\\n }\\n}\\nint main() {\\n int T = 1;\\n while (T--) solve();\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"The grasshopper is located on the numeric axis at the point with coordinate x_0.\\n\\nHaving nothing else to do he starts jumping between integer points on the axis. Making a jump from a point with coordinate x with a distance d to the left moves the grasshopper to a point with a coordinate x - d, while jumping to the right moves him to a point with a coordinate x + d.\\n\\nThe grasshopper is very fond of positive integers, so for each integer i starting with 1 the following holds: exactly i minutes after the start he makes a jump with a distance of exactly i. So, in the first minutes he jumps by 1, then by 2, and so on.\\n\\nThe direction of a jump is determined as follows: if the point where the grasshopper was before the jump has an even coordinate, the grasshopper jumps to the left, otherwise he jumps to the right.\\n\\nFor example, if after 18 consecutive jumps he arrives at the point with a coordinate 7, he will jump by a distance of 19 to the right, since 7 is an odd number, and will end up at a point 7 + 19 = 26. Since 26 is an even number, the next jump the grasshopper will make to the left by a distance of 20, and it will move him to the point 26 - 20 = 6.\\n\\nFind exactly which point the grasshopper will be at after exactly n jumps.\\n\\nInput\\n\\nThe first line of input contains an integer t (1 ≤ t ≤ 10^4) — the number of test cases.\\n\\nEach of the following t lines contains two integers x_0 (-10^{14} ≤ x_0 ≤ 10^{14}) and n (0 ≤ n ≤ 10^{14}) — the coordinate of the grasshopper's initial position and the number of jumps.\\n\\nOutput\\n\\nPrint exactly t lines. On the i-th line print one integer — the answer to the i-th test case — the coordinate of the point the grasshopper will be at after making n jumps from the point x_0.\\n\\nExample\\n\\nInput\\n\\n\\n9\\n0 1\\n0 2\\n10 10\\n10 99\\n177 13\\n10000000000 987654321\\n-433494437 87178291199\\n1 0\\n-1 1\\n\\n\\nOutput\\n\\n\\n-1\\n1\\n11\\n110\\n190\\n9012345679\\n-87611785637\\n1\\n0\\n\\nNote\\n\\nThe first two test cases in the example correspond to the first two jumps from the point x_0 = 0. \\n\\nSince 0 is an even number, the first jump of length...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nlong long process_brute(long long x, long long n) {\\n for (int i = 1; i <= n; i++) {\\n if (abs(x) % 2 == 0)\\n x -= i;\\n else\\n x += i;\\n }\\n return x;\\n}\\nlong long process(long long x, long long n) {\\n long long b = 0;\\n if (abs(x) % 2 == 0) {\\n if (n % 4 == 0) b = 0;\\n if (n % 4 == 1) b = -n;\\n if (n % 4 == 2) b = 1;\\n if (n % 4 == 3) b = n + 1;\\n } else {\\n if (n % 4 == 0) b = 0;\\n if (n % 4 == 1) b = n;\\n if (n % 4 == 2) b = -1;\\n if (n % 4 == 3) b = -n - 1;\\n }\\n return x + b;\\n}\\nint main() {\\n int T = 0;\\n scanf(\\\"%d\\\", &T);\\n long long x = 0, n = 0;\\n while (T--) {\\n scanf(\\\"%lld%lld\\\", &x, &n);\\n printf(\\\"%lld\\\\n\\\", process(x, n));\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Berland Music is a music streaming service built specifically to support Berland local artist. Its developers are currently working on a song recommendation module.\\n\\nSo imagine Monocarp got recommended n songs, numbered from 1 to n. The i-th song had its predicted rating equal to p_i, where 1 ≤ p_i ≤ n and every integer from 1 to n appears exactly once. In other words, p is a permutation.\\n\\nAfter listening to each of them, Monocarp pressed either a like or a dislike button. Let his vote sequence be represented with a string s, such that s_i=0 means that he disliked the i-th song, and s_i=1 means that he liked it.\\n\\nNow the service has to re-evaluate the song ratings in such a way that:\\n\\n * the new ratings q_1, q_2, ..., q_n still form a permutation (1 ≤ q_i ≤ n; each integer from 1 to n appears exactly once); \\n * every song that Monocarp liked should have a greater rating than every song that Monocarp disliked (formally, for all i, j such that s_i=1 and s_j=0, q_i>q_j should hold). \\n\\n\\n\\nAmong all valid permutations q find the one that has the smallest value of ∑_{i=1}^n |p_i-q_i|, where |x| is an absolute value of x.\\n\\nPrint the permutation q_1, q_2, ..., q_n. If there are multiple answers, you can print any of them.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.\\n\\nThe first line of each testcase contains a single integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of songs.\\n\\nThe second line of each testcase contains n integers p_1, p_2, ..., p_n (1 ≤ p_i ≤ n) — the permutation of the predicted ratings.\\n\\nThe third line contains a single string s, consisting of n characters. Each character is either a 0 or a 1. 0 means that Monocarp disliked the song, and 1 means that he liked it.\\n\\nThe sum of n over all testcases doesn't exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each testcase, print a permutation q — the re-evaluated ratings of the songs. If there are multiple answers such that ∑_{i=1}^n |p_i-q_i| is minimum possible, you can print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n2\\n1 2\\n10\\n3\\n3 1 2\\n111\\n8\\n2...\\nSolve the task in PYTHON3.\",\"targets\":\"v=int(input().strip())\\nfor val in range(v):\\n n=int(input().strip())\\n class data:\\n def __init__(self,x):\\n self.x=x\\n self.y=None\\n def __repr__(self):\\n return \\\"({},{})\\\".format(self.x,self.y)\\n \\n p=[data(int(x)) for x in input().strip().split(\\\" \\\")]\\n s=input().strip()\\n liked=[]\\n disliked=[]\\n for i in range(n):\\n if s[i]==\\\"1\\\":\\n liked.extend([p[i]])\\n else:\\n disliked.extend([p[i]])\\n #print(liked)\\n #print(disliked)\\n \\n def Bsort(L,n):\\n X=[None for i in range(n)]\\n for val in L:\\n X[(val.x-1)%n]=val\\n Y=[]\\n for i in X:\\n if i!=None :\\n Y.extend([i])\\n return Y \\n liked=Bsort(liked,n)\\n disliked=Bsort(disliked,n)\\n disliked.extend(liked)\\n \\n \\n for i in range(n):\\n disliked[i].y=i+1 \\n #print(disliked)\\n for i in p:\\n print(i.y,end=\\\" \\\")\\n print()\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"There is a city park represented as a tree with n attractions as its vertices and n - 1 rails as its edges. The i-th attraction has happiness value a_i.\\n\\nEach rail has a color. It is either black if t_i = 0, or white if t_i = 1. Black trains only operate on a black rail track, and white trains only operate on a white rail track. If you are previously on a black train and want to ride a white train, or you are previously on a white train and want to ride a black train, you need to use 1 ticket.\\n\\nThe path of a tour must be a simple path — it must not visit an attraction more than once. You do not need a ticket the first time you board a train. You only have k tickets, meaning you can only switch train types at most k times. In particular, you do not need a ticket to go through a path consisting of one rail color.\\n\\nDefine f(u, v) as the sum of happiness values of the attractions in the tour (u, v), which is a simple path that starts at the u-th attraction and ends at the v-th attraction. Find the sum of f(u,v) for all valid tours (u, v) (1 ≤ u ≤ v ≤ n) that does not need more than k tickets, modulo 10^9 + 7.\\n\\nInput\\n\\nThe first line contains two integers n and k (2 ≤ n ≤ 2 ⋅ 10^5, 0 ≤ k ≤ n-1) — the number of attractions in the city park and the number of tickets you have.\\n\\nThe second line contains n integers a_1, a_2,…, a_n (0 ≤ a_i ≤ 10^9) — the happiness value of each attraction.\\n\\nThe i-th of the next n - 1 lines contains three integers u_i, v_i, and t_i (1 ≤ u_i, v_i ≤ n, 0 ≤ t_i ≤ 1) — an edge between vertices u_i and v_i with color t_i. The given edges form a tree.\\n\\nOutput\\n\\nOutput an integer denoting the total happiness value for all valid tours (u, v) (1 ≤ u ≤ v ≤ n), modulo 10^9 + 7.\\n\\nExamples\\n\\nInput\\n\\n\\n5 0\\n1 3 2 6 4\\n1 2 1\\n1 4 0\\n3 2 1\\n2 5 0\\n\\n\\nOutput\\n\\n\\n45\\n\\n\\nInput\\n\\n\\n3 1\\n1 1 1\\n1 2 1\\n3 2 0\\n\\n\\nOutput\\n\\n\\n10\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nconst int MOD = (int)1e9 + 7;\\nconst int INF = (int)1e9 + 47;\\nconst int nax = 2 * (int)1e5 + 10;\\nint n, k;\\nvector> g[nax];\\nint u[nax];\\nint a[nax];\\nint sz[nax];\\nint pref[nax];\\nint tot[nax][2], cnt[nax][2];\\nint add(int a, int b) {\\n a += b;\\n if (a >= MOD) a -= MOD;\\n return a;\\n}\\nint mul(int a, int b) { return a * 1ll * b % MOD; }\\nint sub(int a, int b) {\\n a -= b;\\n if (a < 0) a += MOD;\\n return a;\\n}\\nvoid dfs(int v, int tot = 0, int p = -1) {\\n tot = add(tot, a[v]);\\n pref[v] = tot;\\n sz[v] = 1;\\n for (auto nxt : g[v]) {\\n int to = nxt.first;\\n if (to == p || u[to]) continue;\\n dfs(to, tot, v);\\n sz[v] += sz[to];\\n }\\n}\\nvoid dfs_get(int v, vector>& vec, int cur, int alr = 0,\\n int p = -1) {\\n if (alr <= k) vec.push_back({alr, v});\\n for (auto nxt : g[v]) {\\n int to = nxt.first;\\n if (to == p || u[to]) continue;\\n dfs_get(to, vec, nxt.second, alr + (cur != nxt.second), v);\\n }\\n}\\nint build(int v) {\\n dfs(v);\\n int p = v;\\n int sz_all = sz[v];\\n while (true) {\\n int x = -1;\\n for (auto nxt : g[v]) {\\n int to = nxt.first;\\n if (to == p || u[to]) continue;\\n if (sz[to] * 2 > sz_all) {\\n x = to;\\n break;\\n }\\n }\\n if (x == -1) break;\\n p = v;\\n v = x;\\n }\\n u[v] = 1;\\n dfs(v);\\n int res = 0;\\n vector>> vec(g[v].size());\\n for (int i = 0; i < g[v].size(); i++) {\\n if (!u[g[v][i].first]) dfs_get(g[v][i].first, vec[i], g[v][i].second);\\n }\\n for (int i = 0; i < g[v].size(); i++) {\\n int to = g[v][i].first;\\n int cc = g[v][i].second;\\n if (u[to]) continue;\\n sort(vec[i].begin(), vec[i].end(), greater>());\\n vector id(2, 0);\\n int count = 0, totl = 0;\\n for (auto x : vec[i]) {\\n for (int c = 0; c < 2; ++c) {\\n while (cc < sz[v] && x.first + id[c] + (c != cc) <= k) {\\n if (!cnt[id[c]][c]) break;\\n count += cnt[id[c]][c];\\n totl = add(totl, tot[id[c]][c]);\\n ++id[c];\\n }\\n }\\n res...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"\\n\\nWilliam has two numbers a and b initially both equal to zero. William mastered performing three different operations with them quickly. Before performing each operation some positive integer k is picked, which is then used to perform one of the following operations: (note, that for each operation you can choose a new positive integer k)\\n\\n 1. add number k to both a and b, or \\n 2. add number k to a and subtract k from b, or \\n 3. add number k to b and subtract k from a. \\n\\n\\n\\nNote that after performing operations, numbers a and b may become negative as well.\\n\\nWilliam wants to find out the minimal number of operations he would have to perform to make a equal to his favorite number c and b equal to his second favorite number d.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^4). Description of the test cases follows.\\n\\nThe only line of each test case contains two integers c and d (0 ≤ c, d ≤ 10^9), which are William's favorite numbers and which he wants a and b to be transformed into.\\n\\nOutput\\n\\nFor each test case output a single number, which is the minimal number of operations which William would have to perform to make a equal to c and b equal to d, or -1 if it is impossible to achieve this using the described operations.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n1 2\\n3 5\\n5 3\\n6 6\\n8 0\\n0 0\\n\\n\\nOutput\\n\\n\\n-1\\n2\\n2\\n1\\n2\\n0\\n\\nNote\\n\\nLet us demonstrate one of the suboptimal ways of getting a pair (3, 5):\\n\\n * Using an operation of the first type with k=1, the current pair would be equal to (1, 1). \\n * Using an operation of the third type with k=8, the current pair would be equal to (-7, 9). \\n * Using an operation of the second type with k=7, the current pair would be equal to (0, 2). \\n * Using an operation of the first type with k=3, the current pair would be equal to (3, 5). \\\":\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\n\\npublic class Solution {\\n static FastScanner fs;\\n static PrintWriter pw;\\n public static void main(String[] args) {\\n fs = new FastScanner();\\n pw = new PrintWriter(System.out);\\n precomp();\\n int t = fs.nextInt();\\n while (t-- > 0)\\n solve();\\n pw.close();\\n }\\n public static void precomp() {\\n\\n }\\n public static void solve() {\\n int c = fs.nextInt();\\n int d = fs.nextInt();\\n if ((c+d)%2==1) pw.println(-1);\\n else if (c==0 && d==0) pw.println(0);\\n else if (c==d) pw.println(1);\\n else pw.println(2);\\n\\n\\n }\\n static long pow(long b, long exp, long mod) {\\n long ret = 1;\\n while (exp > 0) {\\n if ((exp & 1) > 0)\\n ret = (ret * b) % mod;\\n b = (b * b) % mod;\\n exp >>= 1;\\n }\\n return ret;\\n }\\n \\/\\/ static int k;\\n\\/\\/ static int par(int curr) {\\n\\/\\/ return (1< 0 and score >= min_score_to_advance, scores))))\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nAfter getting bored by playing with crayons, you decided to switch to Legos! Today, you're working with a long strip, with height 1 and length n, some positions of which are occupied by 1 by 1 Lego pieces.\\n\\nIn one second, you can either remove two adjacent Lego pieces from the strip (if both are present), or add two Lego pieces to adjacent positions (if both are absent). You can only add or remove Lego's at two adjacent positions at the same time, as otherwise your chubby fingers run into precision issues.\\n\\nYou want to know exactly how much time you'll spend playing with Legos. You value efficiency, so given some starting state and some ending state, you'll always spend the least number of seconds to transform the starting state into the ending state. If it's impossible to transform the starting state into the ending state, you just skip it (so you spend 0 seconds).\\n\\nThe issue is that, for some positions, you don't remember whether there were Legos there or not (in either the starting state, the ending state, or both). Over all pairs of (starting state, ending state) that are consistent with your memory, find the total amount of time it will take to transform the starting state to the ending state. Print this value modulo 1 000 000 007 (10^9 + 7). \\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 1000) — the number of test cases. Then t cases follow.\\n\\nThe first line of each test case contains one integer n (2 ≤ n ≤ 2000) — the size of the Lego strip.\\n\\nThe second line of each test case contains a string s of length n, consisting of the characters 0, 1, and ? — your memory of the starting state: \\n\\n * 1 represents a position that definitely has a Lego piece, \\n * 0 represents a position that definitely does not have a Lego piece, \\n * and ? represents a position that you don't remember. \\n\\n\\n\\nThe third line of each test case contains a string t of length n, consisting of the characters 0, 1, and ? — your memory of the ending state. It follows a similar format to the starting state.\\n\\nIt's guaranteed that the...\",\"targets\":\"#include \\nusing namespace std;\\nconst long long MOD = 1e9 + 7;\\nlong long tt, n;\\npair dp[2010][2010][2];\\nstring s, t;\\nvoid add(pair &x, pair y) {\\n (x.first += y.first) %= MOD;\\n (x.second += y.second) %= MOD;\\n}\\nint main() {\\n ios::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n cin >> tt;\\n for (long long tn = 0; tn < tt; ++tn) {\\n cin >> n >> s >> t;\\n for (long long i = 0; i < n; ++i)\\n if (i % 2 == 1) {\\n if (s[i] == '0')\\n s[i] = '1';\\n else if (s[i] == '1')\\n s[i] = '0';\\n if (t[i] == '0')\\n t[i] = '1';\\n else if (t[i] == '1')\\n t[i] = '0';\\n }\\n for (long long i = 0; i < n + 3; ++i)\\n for (long long j = 0; j < n + 3; ++j)\\n for (long long k = 0; k < 2; ++k) dp[i][j][k] = make_pair(0, 0);\\n dp[0][0][0] = make_pair(1, 0);\\n for (long long i = 0; i < n; ++i)\\n for (long long j = 0; j < i + 1; ++j)\\n for (long long k = 0; k < 2; ++k)\\n if (dp[i][j][k].first > 0 || dp[i][j][k].second > 0) {\\n long long wys = dp[i][j][k].first, val = dp[i][j][k].second;\\n if (k == 0) {\\n if (s[i] != '1' && t[i] != '1')\\n add(dp[i + 1][j][0], make_pair(wys, (val + wys * j) % MOD));\\n if (s[i] != '0' && t[i] != '1')\\n add(dp[i + 1][j + 1][0], make_pair(wys, (val + wys * j) % MOD));\\n if (s[i] != '1' && t[i] != '0') {\\n if (j == 0)\\n add(dp[i + 1][1][1], make_pair(wys, val));\\n else\\n add(dp[i + 1][j - 1][0],\\n make_pair(wys, (val + wys * j) % MOD));\\n }\\n if (s[i] != '0' && t[i] != '0')\\n add(dp[i + 1][j][0], make_pair(wys, (val + wys * j) % MOD));\\n } else {\\n if (s[i] != '1' && t[i] != '1')\\n add(dp[i + 1][j][1], make_pair(wys, (val + wys * j) % MOD));\\n if (s[i] != '1' && t[i] != '0')\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"This is a simplified version of the problem B2. Perhaps you should read the problem B2 before you start solving B1.\\n\\nPaul and Mary have a favorite string s which consists of lowercase letters of the Latin alphabet. They want to paint it using pieces of chalk of two colors: red and green. Let's call a coloring of a string wonderful if the following conditions are met:\\n\\n 1. each letter of the string is either painted in exactly one color (red or green) or isn't painted; \\n 2. each two letters which are painted in the same color are different; \\n 3. the number of letters painted in red is equal to the number of letters painted in green; \\n 4. the number of painted letters of this coloring is maximum among all colorings of the string which meet the first three conditions. \\n\\n\\n\\nE. g. consider a string s equal to \\\"kzaaa\\\". One of the wonderful colorings of the string is shown in the figure.\\n\\n The example of a wonderful coloring of the string \\\"kzaaa\\\".\\n\\nPaul and Mary want to learn by themselves how to find a wonderful coloring of the string. But they are very young, so they need a hint. Help them find k — the number of red (or green, these numbers are equal) letters in a wonderful coloring.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 1000) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one non-empty string s which consists of lowercase letters of the Latin alphabet. The number of characters in the string doesn't exceed 50.\\n\\nOutput\\n\\nFor each test case, output a separate line containing one non-negative integer k — the number of letters which will be painted in red in a wonderful coloring.\\n\\nExample\\n\\nInput\\n\\n\\n5\\nkzaaa\\ncodeforces\\narchive\\ny\\nxxxxxx\\n\\n\\nOutput\\n\\n\\n2\\n5\\n3\\n0\\n1\\n\\nNote\\n\\nThe first test case contains the string from the statement. One of the wonderful colorings is shown in the figure. There's no wonderful coloring containing 3 or more red letters because the total number of painted symbols will exceed the string's length.\\n\\nThe string from the second test case can be...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nvoid fast() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n}\\nvoid comp() {\\n string s;\\n cin >> s;\\n map m;\\n for (int i = 0; i < s.length(); i++) m[s[i]]++;\\n int ans = 0, cnt = 0;\\n for (pair p : m) {\\n if (p.second >= 2)\\n ans++;\\n else\\n cnt++;\\n }\\n ans += cnt \\/ 2;\\n cout << ans << \\\"\\\\n\\\";\\n}\\nint main() {\\n fast();\\n int t = 1;\\n cin >> t;\\n while (t--) {\\n comp();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given array a_1, a_2, …, a_n, consisting of non-negative integers.\\n\\nLet's define operation of \\\"elimination\\\" with integer parameter k (1 ≤ k ≤ n) as follows:\\n\\n * Choose k distinct array indices 1 ≤ i_1 < i_2 < … < i_k ≤ n. \\n * Calculate x = a_{i_1} ~ \\\\& ~ a_{i_2} ~ \\\\& ~ … ~ \\\\& ~ a_{i_k}, where \\\\& denotes the [bitwise AND operation](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#AND) (notes section contains formal definition). \\n * Subtract x from each of a_{i_1}, a_{i_2}, …, a_{i_k}; all other elements remain untouched. \\n\\n\\n\\nFind all possible values of k, such that it's possible to make all elements of array a equal to 0 using a finite number of elimination operations with parameter k. It can be proven that exists at least one possible k for any array a.\\n\\nNote that you firstly choose k and only after that perform elimination operations with value k you've chosen initially.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^4). Description of the test cases follows.\\n\\nThe first line of each test case contains one integer n (1 ≤ n ≤ 200 000) — the length of array a.\\n\\nThe second line of each test case contains n integers a_1, a_2, …, a_n (0 ≤ a_i < 2^{30}) — array a itself.\\n\\nIt's guaranteed that the sum of n over all test cases doesn't exceed 200 000.\\n\\nOutput\\n\\nFor each test case, print all values k, such that it's possible to make all elements of a equal to 0 in a finite number of elimination operations with the given parameter k.\\n\\nPrint them in increasing order.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n4\\n4 4 4 4\\n4\\n13 7 25 19\\n6\\n3 5 3 1 7 1\\n1\\n1\\n5\\n0 0 0 0 0\\n\\n\\nOutput\\n\\n\\n1 2 4\\n1 2\\n1\\n1\\n1 2 3 4 5\\n\\nNote\\n\\nIn the first test case:\\n\\n * If k = 1, we can make four elimination operations with sets of indices \\\\{1\\\\}, \\\\{2\\\\}, \\\\{3\\\\}, \\\\{4\\\\}. Since \\\\& of one element is equal to the element itself, then for each operation x = a_i, so a_i - x = a_i - a_i = 0. \\n * If k = 2, we can make two elimination operations with, for example, sets of indices \\\\{1, 3\\\\} and \\\\{2, 4\\\\}: x = a_1 ~ \\\\& ~ a_3...\",\"targets\":\"\\/\\/package round751;\\nimport java.io.*;\\nimport java.util.ArrayDeque;\\nimport java.util.Arrays;\\nimport java.util.InputMismatchException;\\nimport java.util.Queue;\\n\\npublic class A {\\n\\tInputStream is;\\n\\tFastWriter out;\\n\\tString INPUT = \\\"\\\";\\n\\t\\n\\tvoid solve()\\n\\t{\\n\\t\\tfor(int T = ni();T > 0;T--)go();\\n\\t}\\n\\n\\tvoid go()\\n\\t{\\n\\t\\tint n = ni();\\n\\t\\tint[] a = na(n);\\n\\t\\tint g = 0;\\n\\t\\tfor(int d = 0;d < 30;d++){\\n\\t\\t\\tint ct = 0;\\n\\t\\t\\tfor(int v : a){\\n\\t\\t\\t\\tct += v>>>d&1;\\n\\t\\t\\t}\\n\\t\\t\\tg = gcd(g, ct);\\n\\t\\t}\\n\\t\\tfor(int i = 1;i <= n;i++){\\n\\t\\t\\tif(g % i == 0){\\n\\t\\t\\t\\tout.print(i + \\\" \\\");\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\tout.println();\\n\\t}\\n\\n\\tpublic static int gcd(int a, int b) {\\n\\t\\twhile (b > 0) {\\n\\t\\t\\tint c = a;\\n\\t\\t\\ta = b;\\n\\t\\t\\tb = c % b;\\n\\t\\t}\\n\\t\\treturn a;\\n\\t}\\n\\n\\n\\tvoid run() throws Exception\\n\\t{\\n\\t\\tis = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());\\n\\t\\tout = new FastWriter(System.out);\\n\\t\\t\\n\\t\\tlong s = System.currentTimeMillis();\\n\\t\\tsolve();\\n\\t\\tout.flush();\\n\\t\\ttr(System.currentTimeMillis()-s+\\\"ms\\\");\\n\\t}\\n\\t\\n\\tpublic static void main(String[] args) throws Exception { new A().run(); }\\n\\t\\n\\tprivate byte[] inbuf = new byte[1024];\\n\\tpublic int lenbuf = 0, ptrbuf = 0;\\n\\t\\n\\tprivate int readByte()\\n\\t{\\n\\t\\tif(lenbuf == -1)throw new InputMismatchException();\\n\\t\\tif(ptrbuf >= lenbuf){\\n\\t\\t\\tptrbuf = 0;\\n\\t\\t\\ttry { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }\\n\\t\\t\\tif(lenbuf <= 0)return -1;\\n\\t\\t}\\n\\t\\treturn inbuf[ptrbuf++];\\n\\t}\\n\\t\\n\\tprivate boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }\\n\\tprivate int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }\\n\\t\\n\\tprivate double nd() { return Double.parseDouble(ns()); }\\n\\tprivate char nc() { return (char)skip(); }\\n\\t\\n\\tprivate String ns()\\n\\t{\\n\\t\\tint b = skip();\\n\\t\\tStringBuilder sb = new StringBuilder();\\n\\t\\twhile(!(isSpaceChar(b))){ \\/\\/ when nextLine, (isSpaceChar(b) && b != ' ')\\n\\t\\t\\tsb.appendCodePoint(b);\\n\\t\\t\\tb = readByte();\\n\\t\\t}\\n\\t\\treturn sb.toString();\\n\\t}\\n\\t\\n\\tprivate char[] ns(int n)\\n\\t{\\n\\t\\tchar[] buf = new char[n];\\n\\t\\tint b = skip(), p = 0;\\n\\t\\twhile(p < n && !(isSpaceChar(b))){\\n\\t\\t\\tbuf[p++] = (char)b;\\n\\t\\t\\tb = readByte();\\n\\t\\t}\\n\\t\\treturn n...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given an array a consisting of n positive integers. You have to choose a positive integer d and paint all elements into two colors. All elements which are divisible by d will be painted red, and all other elements will be painted blue.\\n\\nThe coloring is called beautiful if there are no pairs of adjacent elements with the same color in the array. Your task is to find any value of d which yields a beautiful coloring, or report that it is impossible.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of testcases.\\n\\nThe first line of each testcase contains one integer n (2 ≤ n ≤ 100) — the number of elements of the array.\\n\\nThe second line of each testcase contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^{18}).\\n\\nOutput\\n\\nFor each testcase print a single integer. If there is no such value of d that yields a beautiful coloring, print 0. Otherwise, print any suitable value of d (1 ≤ d ≤ 10^{18}).\\n\\nExample\\n\\nInput\\n\\n\\n5\\n5\\n1 2 3 4 5\\n3\\n10 5 15\\n3\\n100 10 200\\n10\\n9 8 2 6 6 2 8 6 5 4\\n2\\n1 3\\n\\n\\nOutput\\n\\n\\n2\\n0\\n100\\n0\\n3\",\"targets\":\"import java.util.Scanner;\\n\\npublic class PaintTheArray {\\n public static void main(String[] args) {\\n Scanner scanner = new Scanner(System.in);\\n\\/\\/ System.out.println(gcd(10,36));\\n int t = scanner.nextInt();\\n while (t-->0){\\n int n = scanner.nextInt();\\n long[] arr = new long[n];\\n int index = 0;\\n long odd = -1;\\n long even = -1;\\n while (n-->0){\\n arr[index] = scanner.nextLong();\\n if ((index&1) == 0){\\n if(odd == -1){\\n odd = arr[index];\\n }else\\n odd = gcd(odd,arr[index]);\\n }else{\\n if(even == -1){\\n even = arr[index];\\n }else\\n even = gcd(even,arr[index]);\\n }\\n index++;\\n }\\n\\/\\/ System.out.println(even+\\\" \\\"+odd);\\n boolean flag = true;\\n for (int i = 0; i < arr.length; i++) {\\n if((i&1) == 0 && arr[i] % even == 0 || (i&1) != 0 && arr[i] % even != 0){\\n flag = false;\\n break;\\n }\\n }\\n\\n boolean flag1 = true;\\n for (int i =0 ; i < arr.length; i++) {\\n if((i&1) != 0 && arr[i] % odd == 0 || (i&1) == 0 && arr[i] % odd != 0){\\n flag1 = false;\\n break;\\n }\\n }\\n if (flag){\\n System.out.println(even);\\n }else if (flag1){\\n System.out.println(odd);\\n }else {\\n System.out.println(0);\\n }\\n\\n }\\n }\\n\\n public static long gcd(long a, long b){\\n if(b == 0){\\n return a;\\n }\\n\\/\\/ if(a>b){\\n\\/\\/ return gcd(b,a%b);\\n\\/\\/ }\\n return gcd(b,a%b);\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Consider a long corridor which can be divided into n square cells of size 1 × 1. These cells are numbered from 1 to n from left to right.\\n\\nThere are two people in this corridor, a hooligan and a security guard. Initially, the hooligan is in the a-th cell, the guard is in the b-th cell (a ≠ b). \\n\\n One of the possible situations. The corridor consists of 7 cells, the hooligan is in the 3-rd cell, the guard is in the 6-th (n = 7, a = 3, b = 6).\\n\\nThere are m firecrackers in the hooligan's pocket, the i-th firecracker explodes in s_i seconds after being lit.\\n\\nThe following events happen each second (sequentially, exactly in the following order):\\n\\n 1. firstly, the hooligan either moves into an adjacent cell (from the cell i, he can move to the cell (i + 1) or to the cell (i - 1), and he cannot leave the corridor) or stays in the cell he is currently. If the hooligan doesn't move, he can light one of his firecrackers and drop it. The hooligan can't move into the cell where the guard is; \\n 2. secondly, some firecrackers that were already dropped may explode. Formally, if the firecracker j is dropped on the T-th second, then it will explode on the (T + s_j)-th second (for example, if a firecracker with s_j = 2 is dropped on the 4-th second, it explodes on the 6-th second); \\n 3. finally, the guard moves one cell closer to the hooligan. If the guard moves to the cell where the hooligan is, the hooligan is caught. \\n\\n\\n\\nObviously, the hooligan will be caught sooner or later, since the corridor is finite. His goal is to see the maximum number of firecrackers explode before he is caught; that is, he will act in order to maximize the number of firecrackers that explodes before he is caught.\\n\\nYour task is to calculate the number of such firecrackers, if the hooligan acts optimally.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 1000) — the number of test cases.\\n\\nEach test case consists of two lines. The first line contains four integers n, m, a and b (2 ≤ n ≤ 10^9; 1 ≤ m ≤ 2 ⋅ 10^5; 1 ≤ a, b ≤ n; a ≠ b) — the...\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"\\\"\\\"\\\"\\n Author - Satwik Tiwari .\\n 15th Dec , 2020 - Tuesday\\n\\\"\\\"\\\"\\n\\n#===============================================================================================\\n#importing some useful libraries.\\n\\nfrom __future__ import division, print_function\\nfrom fractions import Fraction\\nimport sys\\nimport os\\nfrom io import BytesIO, IOBase\\nfrom functools import cmp_to_key\\n\\n# from itertools import *\\nfrom heapq import *\\nfrom math import gcd, factorial,floor,ceil,sqrt\\n\\nfrom copy import deepcopy\\nfrom collections import deque\\n\\n\\nfrom bisect import bisect_left as bl\\nfrom bisect import bisect_right as br\\nfrom bisect import bisect\\n\\n#==============================================================================================\\n#fast I\\/O region\\nBUFSIZE = 8192\\n\\n\\nclass FastIO(IOBase):\\n newlines = 0\\n\\n def __init__(self, file):\\n self._fd = file.fileno()\\n self.buffer = BytesIO()\\n self.writable = \\\"x\\\" in file.mode or \\\"r\\\" not in file.mode\\n self.write = self.buffer.write if self.writable else None\\n\\n def read(self):\\n while True:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n if not b:\\n break\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines = 0\\n return self.buffer.read()\\n\\n def readline(self):\\n while self.newlines == 0:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n self.newlines = b.count(b\\\"\\\\n\\\") + (not b)\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines -= 1\\n return self.buffer.readline()\\n\\n def flush(self):\\n if self.writable:\\n os.write(self._fd, self.buffer.getvalue())\\n self.buffer.truncate(0), self.buffer.seek(0)\\n\\n\\nclass IOWrapper(IOBase):\\n def __init__(self, file):\\n self.buffer = FastIO(file)\\n self.flush = self.buffer.flush\\n self.writable =...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 solution for \\\"A bracket sequence is a string containing only characters \\\"(\\\" and \\\")\\\". A regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters \\\"1\\\" and \\\"+\\\" between the original characters of the sequence. For example, bracket sequences \\\"()()\\\" and \\\"(())\\\" are regular (the resulting expressions are: \\\"(1)+(1)\\\" and \\\"((1+1)+1)\\\"), and \\\")(\\\", \\\"(\\\" and \\\")\\\" are not.\\n\\nYou are given an integer n. Your goal is to construct and print exactly n different regular bracket sequences of length 2n.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 50) — the number of test cases.\\n\\nEach test case consists of one line containing one integer n (1 ≤ n ≤ 50).\\n\\nOutput\\n\\nFor each test case, print n lines, each containing a regular bracket sequence of length exactly 2n. All bracket sequences you output for a testcase should be different (though they may repeat in different test cases). If there are multiple answers, print any of them. It can be shown that it's always possible.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n3\\n1\\n3\\n\\n\\nOutput\\n\\n\\n()()()\\n((()))\\n(()())\\n()\\n((()))\\n(())()\\n()(())\\\":\",\"targets\":\"for _ in range(int(input())):\\n n=int(input())\\n for i in range(1, n+1):\\n s=\\\"\\\"\\n for j in range(i):\\n s=s+'('\\n for j in range(i):\\n s=s+')'\\n for j in range(i,n):\\n s=s+'()'\\n print(s)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nPolycarp must pay exactly n burles at the checkout. He has coins of two nominal values: 1 burle and 2 burles. Polycarp likes both kinds of coins equally. So he doesn't want to pay with more coins of one type than with the other.\\n\\nThus, Polycarp wants to minimize the difference between the count of coins of 1 burle and 2 burles being used. Help him by determining two non-negative integer values c_1 and c_2 which are the number of coins of 1 burle and 2 burles, respectively, so that the total value of that number of coins is exactly n (i. e. c_1 + 2 ⋅ c_2 = n), and the absolute value of the difference between c_1 and c_2 is as little as possible (i. e. you must minimize |c_1-c_2|).\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10^4) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one line. This line contains one integer n (1 ≤ n ≤ 10^9) — the number of burles to be paid by Polycarp.\\n\\nOutput\\n\\nFor each test case, output a separate line containing two integers c_1 and c_2 (c_1, c_2 ≥ 0) separated by a space where c_1 is the number of coins of 1 burle and c_2 is the number of coins of 2 burles. If there are multiple optimal solutions, print any one.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n1000\\n30\\n1\\n32\\n1000000000\\n5\\n\\n\\nOutput\\n\\n\\n334 333\\n10 10\\n1 0\\n10 11\\n333333334 333333333\\n1 2\\n\\nNote\\n\\nThe answer for the first test case is \\\"334 333\\\". The sum of the nominal values of all coins is 334 ⋅ 1 + 333 ⋅ 2 = 1000, whereas |334 - 333| = 1. One can't get the better value because if |c_1 - c_2| = 0, then c_1 = c_2 and c_1 ⋅ 1 + c_1 ⋅ 2 = 1000, but then the value of c_1 isn't an integer.\\n\\nThe answer for the second test case is \\\"10 10\\\". The sum of the nominal values is 10 ⋅ 1 + 10 ⋅ 2 = 30 and |10 - 10| = 0, whereas there's no number having an absolute value less than 0.\",\"targets\":\"import java.util.*;\\npublic class coins \\n{\\n public static void main(String[] args)\\n {\\n try\\n {\\n Scanner sc=new Scanner (System.in);\\n int T=sc.nextInt();\\n for(int j=0;j\\nusing namespace std;\\nint main() {\\n int q;\\n string s, t;\\n cin >> q;\\n while (q--) {\\n cin >> s;\\n cin >> t;\\n int flag = 0, i, j;\\n for (i = s.size() - 1, j = t.size() - 1; i >= 0;) {\\n if (s[i] == t[j]) {\\n i--;\\n j--;\\n } else {\\n i -= 2;\\n }\\n if (j == -1) {\\n flag = 1;\\n break;\\n }\\n }\\n if (flag)\\n cout << \\\"YES\\\\n\\\";\\n else\\n cout << \\\"NO\\\\n\\\";\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A permutation of length n is a sequence of integers from 1 to n of length n containing each number exactly once. For example, [1], [4, 3, 5, 1, 2], [3, 2, 1] are permutations, and [1, 1], [0, 1], [2, 2, 1, 4] are not.\\n\\nThere was a permutation p[1 ... n]. It was merged with itself. In other words, let's take two instances of p and insert elements of the second p into the first maintaining relative order of elements. The result is a sequence of the length 2n.\\n\\nFor example, if p=[3, 1, 2] some possible results are: [3, 1, 2, 3, 1, 2], [3, 3, 1, 1, 2, 2], [3, 1, 3, 1, 2, 2]. The following sequences are not possible results of a merging: [1, 3, 2, 1, 2, 3], [3, 1, 2, 3, 2, 1], [3, 3, 1, 2, 2, 1].\\n\\nFor example, if p=[2, 1] the possible results are: [2, 2, 1, 1], [2, 1, 2, 1]. The following sequences are not possible results of a merging: [1, 1, 2, 2], [2, 1, 1, 2], [1, 2, 2, 1].\\n\\nYour task is to restore the permutation p by the given resulting sequence a. It is guaranteed that the answer exists and is unique.\\n\\nYou have to answer t independent test cases.\\n\\nInput\\n\\nThe first line of the input contains one integer t (1 ≤ t ≤ 400) — the number of test cases. Then t test cases follow.\\n\\nThe first line of the test case contains one integer n (1 ≤ n ≤ 50) — the length of permutation. The second line of the test case contains 2n integers a_1, a_2, ..., a_{2n} (1 ≤ a_i ≤ n), where a_i is the i-th element of a. It is guaranteed that the array a represents the result of merging of some permutation p with the same permutation p.\\n\\nOutput\\n\\nFor each test case, print the answer: n integers p_1, p_2, ..., p_n (1 ≤ p_i ≤ n), representing the initial permutation. It is guaranteed that the answer exists and is unique.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n2\\n1 1 2 2\\n4\\n1 3 1 4 3 4 2 2\\n5\\n1 2 1 2 3 4 3 5 4 5\\n3\\n1 2 3 1 2 3\\n4\\n2 3 2 4 1 3 4 1\\n\\n\\nOutput\\n\\n\\n1 2 \\n1 3 4 2 \\n1 2 3 4 5 \\n1 2 3 \\n2 3 4 1\",\"targets\":\"t = int(input())\\nfor _ in range(t):\\n n = int(input())\\n p = list(map(int, input().split()))\\n a = []\\n for i in p:\\n if i not in a:\\n a.append(i)\\n if(len(a)==n):\\n break\\n for i in a:\\n print(i, end=\\\" \\\")\\n print()\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Demonstrative competitions will be held in the run-up to the 20NN Berlatov Olympic Games. Today is the day for the running competition!\\n\\nBerlatov team consists of 2n runners which are placed on two running tracks; n runners are placed on each track. The runners are numbered from 1 to n on each track. The runner with number i runs through the entire track in i seconds.\\n\\nThe competition is held as follows: first runners on both tracks start running at the same time; when the slower of them arrives at the end of the track, second runners on both tracks start running, and everyone waits until the slower of them finishes running, and so on, until all n pairs run through the track.\\n\\nThe organizers want the run to be as long as possible, but if it lasts for more than k seconds, the crowd will get bored. As the coach of the team, you may choose any order in which the runners are arranged on each track (but you can't change the number of runners on each track or swap runners between different tracks).\\n\\nYou have to choose the order of runners on each track so that the duration of the competition is as long as possible, but does not exceed k seconds.\\n\\nFormally, you want to find two permutations p and q (both consisting of n elements) such that sum = ∑_{i=1}^{n} max(p_i, q_i) is maximum possible, but does not exceed k. If there is no such pair, report about it.\\n\\nInput\\n\\nThe first line contains two integers n and k (1 ≤ n ≤ 10^6, 1 ≤ k ≤ n^2) — the number of runners on each track and the maximum possible duration of the competition, respectively.\\n\\nOutput\\n\\nIf it is impossible to reorder the runners so that the duration of the competition does not exceed k seconds, print -1. \\n\\nOtherwise, print three lines. The first line should contain one integer sum — the maximum possible duration of the competition not exceeding k. The second line should contain a permutation of n integers p_1, p_2, ..., p_n (1 ≤ p_i ≤ n, all p_i should be pairwise distinct) — the numbers of runners on the first track in the order they participate in the...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nint n;\\nlong long k, le, ri, aa, lk;\\nint a[1000100];\\nint main() {\\n ios::sync_with_stdio(0);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n cin >> n >> k;\\n le = (long long)(n) * (long long)(n + 1) \\/ 2LL;\\n for (int i = 1; i <= n; i++) {\\n ri += (long long)(max(i, n - i + 1));\\n a[i] = i;\\n }\\n if (k < le) {\\n cout << \\\"-1\\\" << endl;\\n return 0;\\n }\\n k = min(k, ri);\\n lk = k;\\n int ll = 1, rr = n;\\n k -= le;\\n while (1) {\\n aa = (long long)(rr - ll);\\n if (aa >= k) {\\n swap(a[rr], a[rr - k]);\\n break;\\n } else {\\n swap(a[ll], a[rr]);\\n ll++;\\n rr--;\\n k -= aa;\\n }\\n if (ll >= rr) break;\\n }\\n cout << lk << endl;\\n for (int i = 1; i <= n; i++) cout << i << ' ';\\n cout << endl;\\n for (int i = 1; i <= n; i++) cout << a[i] << ' ';\\n cout << endl;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Polycarp likes squares and cubes of positive integers. Here is the beginning of the sequence of numbers he likes: 1, 4, 8, 9, ....\\n\\nFor a given number n, count the number of integers from 1 to n that Polycarp likes. In other words, find the number of such x that x is a square of a positive integer number or a cube of a positive integer number (or both a square and a cube simultaneously).\\n\\nInput\\n\\nThe first line contains an integer t (1 ≤ t ≤ 20) — the number of test cases.\\n\\nThen t lines contain the test cases, one per line. Each of the lines contains one integer n (1 ≤ n ≤ 10^9).\\n\\nOutput\\n\\nFor each test case, print the answer you are looking for — the number of integers from 1 to n that Polycarp likes.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n10\\n1\\n25\\n1000000000\\n999999999\\n500000000\\n\\n\\nOutput\\n\\n\\n4\\n1\\n6\\n32591\\n32590\\n23125\",\"targets\":\"\\/\\/package haridevelops.commons.contest762.dev3;\\n\\n\\nimport java.lang.*;\\n\\nimport java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.util.Comparator;\\nimport java.util.List;\\nimport java.util.StringTokenizer;\\n\\npublic class B {\\n static FastReader fr;\\n static int arrForIndexSort[];\\n static Integer map1[];\\n static Integer map2[];\\n\\n static class FastReader {\\n BufferedReader br;\\n StringTokenizer st;\\n\\n public FastReader()\\n {\\n br = new BufferedReader(\\n new InputStreamReader(System.in));\\n }\\n\\n String next()\\n {\\n while (st == null || !st.hasMoreElements()) {\\n try {\\n st = new StringTokenizer(br.readLine());\\n }\\n catch (IOException e) {\\n e.printStackTrace();\\n }\\n }\\n return st.nextToken();\\n }\\n\\n int nextInt() { return Integer.parseInt(next()); }\\n\\n long nextLong() { return Long.parseLong(next()); }\\n\\n double nextDouble()\\n {\\n return Double.parseDouble(next());\\n }\\n\\n String nextLine()\\n {\\n String str = \\\"\\\";\\n try {\\n str = br.readLine();\\n }\\n catch (IOException e) {\\n e.printStackTrace();\\n }\\n return str;\\n }\\n }\\n static class Pair{\\n int first;\\n int second;\\n Pair(int first, int second){\\n this.first = first;\\n this.second = second;\\n }\\n @Override\\n public boolean equals(Object b) {\\n Pair a = (Pair)b;\\n if(this.first == a.first && this.second==a.second) {\\n return true;\\n }\\n return false;\\n }\\n }\\n class PairSorter implements Comparator{\\n public int compare(Pair a, Pair b) {\\n if(a.first!=b.first) {\\n return a.first-b.first;\\n }\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Gregor is learning about RSA cryptography, and although he doesn't understand how RSA works, he is now fascinated with prime numbers and factoring them.\\n\\nGregor's favorite prime number is P. Gregor wants to find two bases of P. Formally, Gregor is looking for two integers a and b which satisfy both of the following properties.\\n\\n * P mod a = P mod b, where x mod y denotes the remainder when x is divided by y, and \\n * 2 ≤ a < b ≤ P. \\n\\n\\n\\nHelp Gregor find two bases of his favorite prime number!\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 1000).\\n\\nEach subsequent line contains the integer P (5 ≤ P ≤ {10}^9), with P guaranteed to be prime.\\n\\nOutput\\n\\nYour output should consist of t lines. Each line should consist of two integers a and b (2 ≤ a < b ≤ P). If there are multiple possible solutions, print any.\\n\\nExample\\n\\nInput\\n\\n\\n2\\n17\\n5\\n\\n\\nOutput\\n\\n\\n3 5\\n2 4\\n\\nNote\\n\\nThe first query is P=17. a=3 and b=5 are valid bases in this case, because 17 mod 3 = 17 mod 5 = 2. There are other pairs which work as well.\\n\\nIn the second query, with P=5, the only solution is a=2 and b=4.\\nSolve the task in JAVA.\",\"targets\":\"import java.util.*;\\npublic class GAC\\n{\\n\\tpublic static void main(String args[])\\n\\t{\\n\\t\\tScanner in = new Scanner(System.in);\\n\\t\\tint t=in.nextInt();\\n\\t\\twhile(t--!=0)\\n\\t\\t{\\n\\t\\t\\tint n=in.nextInt();\\n\\t\\t\\tSystem.out.println(2+\\\" \\\"+(n-1));\\n\\t\\t}\\n\\t}\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nOne day Igor K. stopped programming and took up math. One late autumn evening he was sitting at a table reading a book and thinking about something. \\n\\nThe following statement caught his attention: \\\"Among any six people there are either three pairwise acquainted people or three pairwise unacquainted people\\\"\\n\\nIgor just couldn't get why the required minimum is 6 people. \\\"Well, that's the same for five people, too!\\\" — he kept on repeating in his mind. — \\\"Let's take, say, Max, Ilya, Vova — here, they all know each other! And now let's add Dima and Oleg to Vova — none of them is acquainted with each other! Now, that math is just rubbish!\\\"\\n\\nIgor K. took 5 friends of his and wrote down who of them is friends with whom. Now he wants to check whether it is true for the five people that among them there are either three pairwise acquainted or three pairwise not acquainted people.\\n\\nInput\\n\\nThe first line contains an integer m (0 ≤ m ≤ 10), which is the number of relations of acquaintances among the five friends of Igor's.\\n\\nEach of the following m lines contains two integers ai and bi (1 ≤ ai, bi ≤ 5;ai ≠ bi), where (ai, bi) is a pair of acquainted people. It is guaranteed that each pair of the acquaintances is described exactly once. The acquaintance relation is symmetrical, i.e. if x is acquainted with y, then y is also acquainted with x.\\n\\nOutput\\n\\nPrint \\\"FAIL\\\", if among those five people there are no either three pairwise acquainted or three pairwise unacquainted people. Otherwise print \\\"WIN\\\".\\n\\nExamples\\n\\nInput\\n\\n4\\n1 3\\n2 3\\n1 4\\n5 3\\n\\n\\nOutput\\n\\nWIN\\n\\n\\nInput\\n\\n5\\n1 2\\n2 3\\n3 4\\n4 5\\n5 1\\n\\n\\nOutput\\n\\nFAIL\",\"targets\":\"#include \\nusing namespace std;\\nint arr[10][10];\\nint main() {\\n int n;\\n cin >> n;\\n int t1, t2;\\n for (int i = 0; i < n; i++) {\\n cin >> t1 >> t2;\\n arr[t1][t2] = 1;\\n arr[t2][t1] = 1;\\n }\\n for (int i = 1; i <= 5; i++) {\\n for (int j = i + 1; j <= 5; j++) {\\n for (int k = j + 1; k <= 5; k++) {\\n if (arr[i][j] && arr[i][k] && arr[k][j]) {\\n cout << \\\"WIN\\\";\\n return 0;\\n }\\n if (!arr[i][j] && !arr[i][k] && !arr[k][j]) {\\n cout << \\\"WIN\\\";\\n return 0;\\n }\\n }\\n }\\n }\\n cout << \\\"FAIL\\\";\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"The chef has cooked n dishes yet again: the i-th dish consists of a_i grams of fish and b_i grams of meat. \\n\\nBanquet organizers consider two dishes i and j equal if a_i=a_j and b_i=b_j at the same time.\\n\\nThe banquet organizers estimate the variety of n dishes as follows. The variety of a set of dishes is equal to the number of different dishes in it. The less variety is, the better.\\n\\nIn order to reduce the variety, a taster was invited. He will eat exactly m_i grams of food from each dish. For each dish, the taster determines separately how much fish and how much meat he will eat. The only condition is that he will eat exactly m_i grams of the i-th dish in total.\\n\\nDetermine how much of what type of food the taster should eat from each dish so that the value of variety is the minimum possible. If there are several correct answers, you may output any of them.\\n\\nInput\\n\\nThe first line of input data contains an integer t (1 ≤ t ≤ 10^4) — the number of test cases.\\n\\nEach test case's description is preceded by a blank line. Next comes a line that contains an integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of dishes. Then follows n lines, i-th of which contains three integers a_i, b_i and m_i (0 ≤ a_i, b_i ≤ 10^6; 0 ≤ m_i ≤ a_i+b_i) — the mass of fish in i-th dish, the mass of meat in i-th dish and how many grams in total the taster should eat in i-th dish.\\n\\nThe sum of all n values for all input data sets in the test does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print on the first line the minimum value of variety that can be achieved by eating exactly m_i grams of food (for all i from 1 to n) from a dish i.\\n\\nThen print n lines that describe a way to do this: the i-th line should contain two integers x_i and y_i (0 ≤ x_i ≤ a_i; 0 ≤ y_i ≤ b_i; x_i+y_i=m_i), where x_i is how many grams of fish the taster should eat from i-th dish, and y_i is how many grams of meat.\\n\\nIf there are several ways to achieve a minimum balance, print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n\\n3\\n10 10 2\\n9 9 0\\n10 9 1\\n\\n2\\n3 4 1\\n5 1 2\\n\\n3\\n7 2 5\\n6 5 4\\n5 5...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nconst int N = 2e5 + 5, inf = 1e9;\\nint n, a[N], b[N], m[N], x[N], y[N];\\nvoid solve() {\\n cin >> n;\\n vector> ve;\\n for (int i = 0; i < (n); ++i) {\\n cin >> a[i] >> b[i] >> m[i];\\n ve.push_back({a[i] + b[i] - m[i], i});\\n }\\n sort(begin(ve), end(ve));\\n int ans = 0;\\n for (int i = 0; i < (int)(ve).size();) {\\n int cnt = 0;\\n vector, int>> ve2;\\n while (i < n && ve[i].first == ve[i - cnt].first) {\\n int pos = ve[i].second;\\n int l = max(0, a[pos] - m[pos]), r = a[pos] - max(0, m[pos] - b[pos]);\\n ve2.push_back({{l, r}, pos});\\n ++i, ++cnt;\\n }\\n sort(begin(ve2), end(ve2));\\n pair I = {-inf, inf};\\n int pre = -1;\\n for (int j = 0; j < ((int)(ve2).size()); ++j) {\\n int l = ve2[j].first.first, r = ve2[j].first.second;\\n if (l > I.second) {\\n int target = I.second;\\n ++ans;\\n for (int k = pre + 1; k < (j); ++k) {\\n int pos = ve2[k].second;\\n x[pos] = a[pos] - target;\\n y[pos] = m[pos] - x[pos];\\n }\\n pre = j - 1;\\n I = {-inf, inf};\\n --j;\\n } else {\\n I.first = max(I.first, l);\\n I.second = min(I.second, r);\\n }\\n }\\n int target = I.second;\\n ++ans;\\n for (int k = pre + 1; k < ((int)(ve2).size()); ++k) {\\n int pos = ve2[k].second;\\n x[pos] = a[pos] - target;\\n y[pos] = m[pos] - x[pos];\\n }\\n }\\n cout << ans << '\\\\n';\\n for (int i = 0; i < (n); ++i) {\\n cout << x[i] << ' ' << y[i] << '\\\\n';\\n }\\n}\\nint main() {\\n cin.tie(0)->sync_with_stdio(0);\\n cin.exceptions(cin.failbit);\\n int t;\\n cin >> t;\\n while (t--) {\\n solve();\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Arkady decides to observe a river for n consecutive days. The river's water level on each day is equal to some real value.\\n\\nArkady goes to the riverside each day and makes a mark on the side of the channel at the height of the water level, but if it coincides with a mark made before, no new mark is created. The water does not wash the marks away. Arkady writes down the number of marks strictly above the water level each day, on the i-th day this value is equal to mi.\\n\\nDefine di as the number of marks strictly under the water level on the i-th day. You are to find out the minimum possible sum of di over all days. There are no marks on the channel before the first day.\\n\\nInput\\n\\nThe first line contains a single positive integer n (1 ≤ n ≤ 105) — the number of days.\\n\\nThe second line contains n space-separated integers m1, m2, ..., mn (0 ≤ mi < i) — the number of marks strictly above the water on each day.\\n\\nOutput\\n\\nOutput one single integer — the minimum possible sum of the number of marks strictly below the water level among all days.\\n\\nExamples\\n\\nInput\\n\\n6\\n0 1 0 3 0 2\\n\\n\\nOutput\\n\\n6\\n\\n\\nInput\\n\\n5\\n0 1 2 1 2\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\n5\\n0 1 1 2 2\\n\\n\\nOutput\\n\\n0\\n\\nNote\\n\\nIn the first example, the following figure shows an optimal case.\\n\\n\\n\\nNote that on day 3, a new mark should be created because if not, there cannot be 3 marks above water on day 4. The total number of marks underwater is 0 + 0 + 2 + 0 + 3 + 1 = 6.\\n\\nIn the second example, the following figure shows an optimal case.\\n\\n\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nlong long mod = 1000000007;\\nusing namespace std;\\nint n;\\nlong long powmod(long long a, long long b) {\\n long long res = 1;\\n a %= mod;\\n for (; b; b >>= 1) {\\n if (b & 1) res = res * a % mod;\\n a = a * a % mod;\\n }\\n return res;\\n}\\nint a[100005];\\nint main() {\\n int i, j, fl, test, pos = 0, mx = 0;\\n scanf(\\\"%d\\\", &n);\\n long long ans = 0;\\n for (i = 0; i < n; i++) {\\n scanf(\\\"%d\\\", &a[i]);\\n if (a[i] > mx) {\\n mx = a[i];\\n pos = i;\\n }\\n }\\n for (i = pos; i < n; i++) {\\n ans = ans + (mx - a[i]);\\n }\\n int sofar[100005];\\n sofar[0] = 0;\\n for (i = 1; i < pos; i++) {\\n sofar[i] = max(sofar[i - 1], a[i]);\\n }\\n for (i = pos - 1; i >= 0; i--) {\\n mx--;\\n mx = max(mx, a[i]);\\n ans = ans + max((mx - a[i]), (sofar[i] - a[i]));\\n }\\n printf(\\\"%lld\\\\n\\\", ans);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"'Twas the night before Christmas, and Santa's frantically setting up his new Christmas tree! There are n nodes in the tree, connected by n-1 edges. On each edge of the tree, there's a set of Christmas lights, which can be represented by an integer in binary representation.\\n\\n\\n\\nHe has m elves come over and admire his tree. Each elf is assigned two nodes, a and b, and that elf looks at all lights on the simple path between the two nodes. After this, the elf's favorite number becomes the [bitwise XOR](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#XOR) of the values of the lights on the edges in that path.\\n\\nHowever, the North Pole has been recovering from a nasty bout of flu. Because of this, Santa forgot some of the configurations of lights he had put on the tree, and he has already left the North Pole! Fortunately, the elves came to the rescue, and each one told Santa what pair of nodes he was assigned (a_i, b_i), as well as the parity of the number of set bits in his favorite number. In other words, he remembers whether the number of 1's when his favorite number is written in binary is odd or even.\\n\\nHelp Santa determine if it's possible that the memories are consistent, and if it is, remember what his tree looked like, and maybe you'll go down in history!\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 2 ⋅ 10^4) — the number of test cases. Then t cases follow.\\n\\nThe first line of each test case contains two integers, n and m (2 ≤ n ≤ 2 ⋅ 10^5; 1 ≤ m ≤ 2 ⋅ 10^5) — the size of tree and the number of elves respectively.\\n\\nThe next n-1 lines of each test case each contains three integers, x, y, and v (1 ≤ x, y ≤ n; -1 ≤ v < 2^{30}) — meaning that there's an edge between nodes x and y. If \\n\\n * v = -1: Santa doesn't remember what the set of lights were on for this edge. \\n * v ≥ 0: The set of lights on the edge is v. \\n\\n\\n\\nThe next m lines of each test case each contains three integers, a, b, and p (1 ≤ a, b ≤ n; a ≠ b; 0 ≤ p ≤ 1) — the nodes that the elf was assigned to, and the parity of the number of...\\nUsing java can you solve the prior task?\",\"targets\":\"import java.util.*;\\n\\n\\n@SuppressWarnings(\\\"unused\\\")\\npublic class Main {\\n static class DisjointSet {\\n public int[] upper; \\/\\/ minus:num_element(root) plus:root(normal)\\n \\/\\/\\tpublic int[] w;\\n \\n public DisjointSet(int n)\\n {\\n upper = new int[n];\\n Arrays.fill(upper, -1);\\n \\/\\/\\t\\tw = new int[n];\\n }\\n \\n public DisjointSet(DisjointSet ds)\\n {\\n this.upper = Arrays.copyOf(ds.upper, ds.upper.length);\\n }\\t\\t\\n \\n public int root(int x)\\n {\\n return upper[x] < 0 ? x : (upper[x] = root(upper[x]));\\n }\\n \\n public boolean equiv(int x, int y)\\n {\\n return root(x) == root(y);\\n }\\n \\n public boolean union(int x, int y)\\n {\\n x = root(x);\\n y = root(y);\\n if(x != y) {\\n if(upper[y] < upper[x]) {\\n int d = x; x = y; y = d;\\n }\\n \\/\\/\\t\\t\\tw[x] += w[y];\\n upper[x] += upper[y];\\n upper[y] = x;\\n }\\n return x == y;\\n }\\n \\n public int count()\\n {\\n int ct = 0;\\n for(int u : upper){\\n if(u < 0)ct++;\\n }\\n return ct;\\n }\\n \\n public int[][] toBucket()\\n {\\n int n = upper.length;\\n int[][] ret = new int[n][];\\n int[] rp = new int[n];\\n for(int i = 0;i < n;i++){\\n if(upper[i] < 0)ret[i] = new int[-upper[i]];\\n }\\n for(int i = 0;i < n;i++){\\n int r = root(i);\\n ret[r][rp[r]++] = i;\\n }\\n return ret;\\n }\\n }\\n\\n private static void solve() {\\n int t = ni();\\n outer: for (int i = 0; i < t;i ++) {\\n int n = ni();\\n int m = ni();\\n var ds = new DisjointSet(n * 2);\\n\\n int[] from = new int[n-1];\\n int[] to = new int[n-1];\\n int[] v = new int[n-1];\\n for (int j = 0; j < n-1; j ++) {\\n from[j] = ni() - 1;\\n to[j] = ni() - 1;\\n v[j] = ni();\\n int u = -1;\\n if (v[j] >= 0) {\\n u = Integer.bitCount(v[j]) % 2;\\n }\\n if (u == 0) {\\n ds.union(from[j] * 2 + 0, to[j] * 2 + 0);\\n ds.union(from[j] * 2 + 1, to[j] * 2 + 1);\\n } else if (u == 1) {\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Cat Noku has obtained a map of the night sky. On this map, he found a constellation with n stars numbered from 1 to n. For each i, the i-th star is located at coordinates (xi, yi). No two stars are located at the same position.\\n\\nIn the evening Noku is going to take a look at the night sky. He would like to find three distinct stars and form a triangle. The triangle must have positive area. In addition, all other stars must lie strictly outside of this triangle. He is having trouble finding the answer and would like your help. Your job is to find the indices of three stars that would form a triangle that satisfies all the conditions. \\n\\nIt is guaranteed that there is no line such that all stars lie on that line. It can be proven that if the previous condition is satisfied, there exists a solution to this problem.\\n\\nInput\\n\\nThe first line of the input contains a single integer n (3 ≤ n ≤ 100 000).\\n\\nEach of the next n lines contains two integers xi and yi ( - 109 ≤ xi, yi ≤ 109).\\n\\nIt is guaranteed that no two stars lie at the same point, and there does not exist a line such that all stars lie on that line.\\n\\nOutput\\n\\nPrint three distinct integers on a single line — the indices of the three points that form a triangle that satisfies the conditions stated in the problem.\\n\\nIf there are multiple possible answers, you may print any of them.\\n\\nExamples\\n\\nInput\\n\\n3\\n0 1\\n1 0\\n1 1\\n\\n\\nOutput\\n\\n1 2 3\\n\\n\\nInput\\n\\n5\\n0 0\\n0 2\\n2 0\\n2 2\\n1 1\\n\\n\\nOutput\\n\\n1 3 5\\n\\nNote\\n\\nIn the first sample, we can print the three indices in any order.\\n\\nIn the second sample, we have the following picture. \\n\\n\\n\\nNote that the triangle formed by starts 1, 4 and 3 doesn't satisfy the conditions stated in the problem, as point 5 is not strictly outside of this triangle (it lies on it's border).\\nUsing java can you solve the prior task?\",\"targets\":\"\\/\\/package wunderfundround;\\n\\n\\nimport java.io.*;\\nimport java.util.*;\\n\\npublic class C {\\n\\n public static void main(String[] args) {\\n CIO io = new CIO();\\n try {\\n Csolver solver = new Csolver(io);\\n } finally {\\n io.close();\\n }\\n }\\n\\n}\\n\\nclass Csolver {\\n\\n public Csolver(CIO io) {\\n int n = io.nextInt();\\n Star[] lista = new Star[n];\\n HashSet seenX = new HashSet<>();\\n HashSet seenY = new HashSet<>();\\n Long foundManyAtSameX = null;\\n Long foundManyAtSameY = null;\\n for (int i=0; i stars = new PriorityQueue<>();\\n for (Star star : lista) stars.add(star);\\n \\n if (foundManyAtSameX != null) {\\n Star lastlyPolled = stars.poll();\\n while (lastlyPolled.x != foundManyAtSameX) {\\n lastlyPolled = stars.poll();\\n }\\n Star a = lastlyPolled;\\n \\n lastlyPolled = stars.poll();\\n while (lastlyPolled.x != foundManyAtSameX) {\\n lastlyPolled = stars.poll();\\n }\\n Star b = lastlyPolled; \\/\\/ b on a:n lähin naapuri viivalla\\n \\n double smallestKnownDistance = Double.POSITIVE_INFINITY;\\n Star smallestKnownStar = null;\\n for (Star star : lista) {\\n if (star.x == foundManyAtSameX) continue;\\n double dist = minDistFromPointToLineSegment(star.x, star.y, a.x, a.y, b.x, b.y);\\n if (dist < smallestKnownDistance) {\\n smallestKnownDistance = dist;\\n smallestKnownStar = star;\\n }\\n }\\n ...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Moamen was drawing a grid of n rows and 10^9 columns containing only digits 0 and 1. Ezzat noticed what Moamen was drawing and became interested in the minimum number of rows one needs to remove to make the grid beautiful.\\n\\nA grid is beautiful if and only if for every two consecutive rows there is at least one column containing 1 in these two rows.\\n\\nEzzat will give you the number of rows n, and m segments of the grid that contain digits 1. Every segment is represented with three integers i, l, and r, where i represents the row number, and l and r represent the first and the last column of the segment in that row.\\n\\nFor example, if n = 3, m = 6, and the segments are (1,1,1), (1,7,8), (2,7,7), (2,15,15), (3,1,1), (3,15,15), then the grid is:\\n\\n\\n\\nYour task is to tell Ezzat the minimum number of rows that should be removed to make the grid beautiful.\\n\\nInput\\n\\nThe first line contains two integers n and m (1 ≤ n, m ≤ 3⋅10^5).\\n\\nEach of the next m lines contains three integers i, l, and r (1 ≤ i ≤ n, 1 ≤ l ≤ r ≤ 10^9). Each of these m lines means that row number i contains digits 1 in columns from l to r, inclusive.\\n\\nNote that the segments may overlap.\\n\\nOutput\\n\\nIn the first line, print a single integer k — the minimum number of rows that should be removed.\\n\\nIn the second line print k distinct integers r_1, r_2, …, r_k, representing the rows that should be removed (1 ≤ r_i ≤ n), in any order.\\n\\nIf there are multiple answers, print any.\\n\\nExamples\\n\\nInput\\n\\n\\n3 6\\n1 1 1\\n1 7 8\\n2 7 7\\n2 15 15\\n3 1 1\\n3 15 15\\n\\n\\nOutput\\n\\n\\n0\\n\\n\\nInput\\n\\n\\n5 4\\n1 2 3\\n2 4 6\\n3 3 5\\n5 1 1\\n\\n\\nOutput\\n\\n\\n3\\n2 4 5\\n\\nNote\\n\\nIn the first test case, the grid is the one explained in the problem statement. The grid has the following properties: \\n\\n 1. The 1-st row and the 2-nd row have a common 1 in the column 7. \\n 2. The 2-nd row and the 3-rd row have a common 1 in the column 15. \\n\\nAs a result, this grid is beautiful and we do not need to remove any row.\\n\\nIn the second test case, the given grid is as follows: \\n\\n\\n#incl\",\"targets\":\"ude \\nstruct SegTree {\\n struct Node {\\n int l = 0, r = 0;\\n std::pair v = {0, -1}, p = {0, -1};\\n };\\n std::vector tree = {{}, {}};\\n void visit(int n, int l, int m, int r) {\\n if (!tree[n].l && l <= m) tree[n].l = tree.size(), tree.emplace_back();\\n if (!tree[n].r && m + 1 <= r) tree[n].r = tree.size(), tree.emplace_back();\\n setMax(tree[n].l, l, m, l, r, tree[n].p);\\n setMax(tree[n].r, m + 1, r, l, r, tree[n].p);\\n tree[n].p = Node().p;\\n }\\n void setMax(int n, int l, int r, int lq, int rq, std::pair v) {\\n if (!n || r < lq || rq < l || rq < lq) {\\n return;\\n } else if (lq <= l && r <= rq) {\\n tree[n].v = std::max(tree[n].v, v);\\n tree[n].p = std::max(tree[n].p, v);\\n } else {\\n int m = l + (r - l) \\/ 2;\\n visit(n, l, m, r);\\n setMax(tree[n].l, l, m, lq, rq, v);\\n setMax(tree[n].r, m + 1, r, lq, rq, v);\\n tree[n].v = std::max(tree[tree[n].l].v, tree[tree[n].r].v);\\n }\\n }\\n std::pair getMax(int n, int l, int r, int lq, int rq) {\\n if (!n || r < lq || rq < l || rq < lq)\\n return Node().v;\\n else if (lq <= l && r <= rq)\\n return tree[n].v;\\n int m = l + (r - l) \\/ 2;\\n visit(n, l, m, r);\\n return std::max(getMax(tree[n].l, l, m, lq, rq),\\n getMax(tree[n].r, m + 1, r, lq, rq));\\n }\\n};\\nint main() {\\n int n, m;\\n scanf(\\\"%d %d\\\", &n, &m);\\n std::map relpoint;\\n std::vector>> intervals(n + 1);\\n for (int x = 0, i, l, r; x < m; ++x) {\\n scanf(\\\"%d %d %d\\\", &i, &l, &r);\\n intervals[i].push_back({l, r});\\n relpoint[l] = relpoint[r] = 0;\\n }\\n int points = 0;\\n for (auto &kv : relpoint) kv.second = ++points;\\n SegTree tree;\\n tree.tree.reserve(points * 3);\\n std::vector bptr(n + 1, -1);\\n for (int row = 1; row <= n; ++row) {\\n auto &v = intervals[row];\\n std::sort(v.begin(), v.end());\\n std::vector> ranges;\\n for (int i = 0, j; i < v.size(); i = j) {\\n int l = v[i].first, r = v[i].second;\\n for (j...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"As their story unravels, a timeless tale is told once again...\\n\\nShirahime, a friend of Mocha's, is keen on playing the music game Arcaea and sharing Mocha interesting puzzles to solve. This day, Shirahime comes up with a new simple puzzle and wants Mocha to solve them. However, these puzzles are too easy for Mocha to solve, so she wants you to solve them and tell her the answers. The puzzles are described as follow.\\n\\nThere are n squares arranged in a row, and each of them can be painted either red or blue.\\n\\nAmong these squares, some of them have been painted already, and the others are blank. You can decide which color to paint on each blank square.\\n\\nSome pairs of adjacent squares may have the same color, which is imperfect. We define the imperfectness as the number of pairs of adjacent squares that share the same color.\\n\\nFor example, the imperfectness of \\\"BRRRBBR\\\" is 3, with \\\"BB\\\" occurred once and \\\"RR\\\" occurred twice.\\n\\nYour goal is to minimize the imperfectness and print out the colors of the squares after painting. \\n\\nInput\\n\\nEach test contains multiple test cases. \\n\\nThe first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. Each test case consists of two lines.\\n\\nThe first line of each test case contains an integer n (1≤ n≤ 100) — the length of the squares row.\\n\\nThe second line of each test case contains a string s with length n, containing characters 'B', 'R' and '?'. Here 'B' stands for a blue square, 'R' for a red square, and '?' for a blank square.\\n\\nOutput\\n\\nFor each test case, print a line with a string only containing 'B' and 'R', the colors of the squares after painting, which imperfectness is minimized. If there are multiple solutions, print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n7\\n?R???BR\\n7\\n???R???\\n1\\n?\\n1\\nB\\n10\\n?R??RB??B?\\n\\n\\nOutput\\n\\n\\nBRRBRBR\\nBRBRBRB\\nB\\nB\\nBRRBRBBRBR\\n\\nNote\\n\\nIn the first test case, if the squares are painted \\\"BRRBRBR\\\", the imperfectness is 1 (since squares 2 and 3 have the same color), which is the minimum possible imperfectness.\\n\\n\\nimp\",\"targets\":\"ort java.util.*;\\nimport java.io.*;\\n\\npublic class B {\\n\\tstatic StringBuilder sb;\\n\\tstatic dsu dsu;\\n\\tstatic long fact[];\\n\\tstatic long mod = (int) (1e9 + 7);\\n\\n\\tstatic void solve() {\\n\\t\\tint n = i();\\n\\t\\tchar[] ch = s().toCharArray();\\n\\n\\t\\tboolean flag = false;\\n\\t\\tfor (int i = 0; i < n; i++) {\\n\\t\\t\\tif (ch[i] != '?') {\\n\\t\\t\\t\\tflag = true;\\n\\t\\t\\t}\\n\\t\\t}\\n\\n\\t\\tif (flag == false) {\\n\\t\\t\\tfor (int i = 0; i < n; i++) {\\n\\t\\t\\t\\tif (i % 2 == 0) {\\n\\t\\t\\t\\t\\tsb.append(\\\"R\\\");\\n\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\tsb.append(\\\"B\\\");\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\tsb.append(\\\"\\\\n\\\");\\n\\t\\t\\treturn;\\n\\t\\t}\\n\\n\\t\\tchar[] ans = new char[n];\\n\\t\\tint idx = -1;\\n\\t\\tfor (int i = 0; i < n; i++) {\\n\\t\\t\\tif (ch[i] != '?') {\\n\\t\\t\\t\\tidx = i;\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\tchar c = ch[idx];\\n\\t\\tans[idx] = c;\\n\\t\\tfor (int i = idx + 1; i < n; i++) {\\n\\t\\t\\tif (c == 'R') {\\n\\t\\t\\t\\tans[i] = 'B';\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tans[i] = 'R';\\n\\t\\t\\t}\\n\\t\\t\\tc = ans[i];\\n\\t\\t}\\n\\n\\t\\tc = ch[idx];\\n\\t\\tfor (int i = idx - 1; i >= 0; i--) {\\n\\t\\t\\tif (ch[i] == '?') {\\n\\t\\t\\t\\tif (c == 'R') {\\n\\t\\t\\t\\t\\tans[i] = 'B';\\n\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\tans[i] = 'R';\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tc = ans[i];\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tc = ch[i];\\n\\t\\t\\t\\tans[i] = c;\\n\\t\\t\\t}\\n\\t\\t}\\n\\n\\t\\tfor (int i = 0; i < ans.length; i++) {\\n\\t\\t\\tsb.append(ans[i]);\\n\\t\\t}\\n\\t\\tsb.append(\\\"\\\\n\\\");\\n\\n\\t}\\n\\n\\tpublic static void main(String[] args) {\\n\\t\\tsb = new StringBuilder();\\n\\t\\tint test = 1;\\n\\t\\ttest = i();\\n\\t\\twhile (test-- > 0) {\\n\\t\\t\\tsolve();\\n\\t\\t}\\n\\t\\tSystem.out.println(sb);\\n\\n\\t}\\n\\n\\t\\/*\\n\\t * fact=new long[(int)1e6+10]; fact[0]=fact[1]=1; for(int i=2;i n)\\n\\t\\t\\treturn (long) 0;\\n\\n\\t\\tlong res = fact[n] % mod;\\n\\t\\t\\/\\/ System.out.println(res);\\n\\t\\tres = ((long) (res % mod) * (long) (p(fact[r], mod - 2) % mod)) % mod;\\n\\t\\tres = ((long) (res % mod) * (long) (p(fact[n - r], mod - 2) % mod)) % mod;\\n\\t\\t\\/\\/ System.out.println(res);\\n\\t\\treturn res;\\n\\n\\t}\\n\\n\\tstatic long p(long x, long y)\\/\\/ POWER FXN \\/\\/\\n\\t{\\n\\t\\tif (y == 0)\\n\\t\\t\\treturn 1;\\n\\n\\t\\tlong res = 1;\\n\\t\\twhile (y > 0) {\\n\\t\\t\\tif (y % 2 == 1) {\\n\\t\\t\\t\\tres = (res * x) % mod;\\n\\t\\t\\t\\ty--;\\n\\t\\t\\t}\\n\\n\\t\\t\\tx = (x * x) % mod;\\n\\t\\t\\ty = y \\/ 2;\\n\\n\\t\\t}\\n\\t\\treturn...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Let's define S(x) to be the sum of digits of number x written in decimal system. For example, S(5) = 5, S(10) = 1, S(322) = 7.\\n\\nWe will call an integer x interesting if S(x + 1) < S(x). In each test you will be given one integer n. Your task is to calculate the number of integers x such that 1 ≤ x ≤ n and x is interesting.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 1000) — number of test cases.\\n\\nThen t lines follow, the i-th line contains one integer n (1 ≤ n ≤ 10^9) for the i-th test case.\\n\\nOutput\\n\\nPrint t integers, the i-th should be the answer for the i-th test case.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n1\\n9\\n10\\n34\\n880055535\\n\\n\\nOutput\\n\\n\\n0\\n1\\n1\\n3\\n88005553\\n\\nNote\\n\\nThe first interesting number is equal to 9.\\nSolve the task in PYTHON3.\",\"targets\":\"x=int(input())\\nfor i in range(x):\\n y=int(input())\\n print((y+1)\\/\\/10)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller.\\n\\nAmr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some number occurs in this array. He wants to choose the smallest subsegment of this array such that the beauty of it will be the same as the original array.\\n\\nHelp Amr by choosing the smallest subsegment possible.\\n\\nInput\\n\\nThe first line contains one number n (1 ≤ n ≤ 105), the size of the array.\\n\\nThe second line contains n integers ai (1 ≤ ai ≤ 106), representing elements of the array.\\n\\nOutput\\n\\nOutput two integers l, r (1 ≤ l ≤ r ≤ n), the beginning and the end of the subsegment chosen respectively.\\n\\nIf there are several possible answers you may output any of them. \\n\\nExamples\\n\\nInput\\n\\n5\\n1 1 2 2 1\\n\\n\\nOutput\\n\\n1 5\\n\\nInput\\n\\n5\\n1 2 2 3 1\\n\\n\\nOutput\\n\\n2 3\\n\\nInput\\n\\n6\\n1 2 2 1 1 2\\n\\n\\nOutput\\n\\n1 5\\n\\nNote\\n\\nA subsegment B of an array A from l to r is an array of size r - l + 1 where Bi = Al + i - 1 for all 1 ≤ i ≤ r - l + 1\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nint kol[1000005] = {}, a[1000005], l[1000005] = {}, r[1000005] = {};\\nint main() {\\n int n;\\n cin >> n;\\n int m = 0;\\n for (int i = 1; i <= n; i++) {\\n int x;\\n cin >> x;\\n a[i] = x;\\n kol[x]++;\\n m = max(m, kol[x]);\\n }\\n for (int i = 1; i <= n; i++)\\n if (kol[a[i]] == m && l[a[i]] == 0) {\\n l[a[i]] = i;\\n }\\n int i1 = -1, m1 = 1000000;\\n for (int i = n; i >= 1; i--)\\n if (kol[a[i]] == m && r[a[i]] == 0) {\\n r[a[i]] = i;\\n if (r[a[i]] - l[a[i]] < m1) {\\n m1 = r[a[i]] - l[a[i]];\\n i1 = a[i];\\n }\\n }\\n cout << l[i1] << \\\" \\\" << r[i1];\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Anton likes to play chess, and so does his friend Danik.\\n\\nOnce they have played n games in a row. For each game it's known who was the winner — Anton or Danik. None of the games ended with a tie.\\n\\nNow Anton wonders, who won more games, he or Danik? Help him determine this.\\n\\nInput\\n\\nThe first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of games played.\\n\\nThe second line contains a string s, consisting of n uppercase English letters 'A' and 'D' — the outcome of each of the games. The i-th character of the string is equal to 'A' if the Anton won the i-th game and 'D' if Danik won the i-th game.\\n\\nOutput\\n\\nIf Anton won more games than Danik, print \\\"Anton\\\" (without quotes) in the only line of the output.\\n\\nIf Danik won more games than Anton, print \\\"Danik\\\" (without quotes) in the only line of the output.\\n\\nIf Anton and Danik won the same number of games, print \\\"Friendship\\\" (without quotes).\\n\\nExamples\\n\\nInput\\n\\n6\\nADAAAA\\n\\n\\nOutput\\n\\nAnton\\n\\n\\nInput\\n\\n7\\nDDDAADA\\n\\n\\nOutput\\n\\nDanik\\n\\n\\nInput\\n\\n6\\nDADADA\\n\\n\\nOutput\\n\\nFriendship\\n\\nNote\\n\\nIn the first sample, Anton won 6 games, while Danik — only 1. Hence, the answer is \\\"Anton\\\".\\n\\nIn the second sample, Anton won 3 games and Danik won 4 games, so the answer is \\\"Danik\\\".\\n\\nIn the third sample, both Anton and Danik won 3 games and the answer is \\\"Friendship\\\".\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"a=int(input())\\nb=input()\\nif (b.count(\\\"A\\\")>b.count(\\\"D\\\")):\\n print (\\\"Anton\\\")\\nelif (b.count(\\\"A\\\")==b.count(\\\"D\\\")):\\n print (\\\"Friendship\\\")\\nelse:\\n print (\\\"Danik\\\")\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Theofanis started playing the new online game called \\\"Among them\\\". However, he always plays with Cypriot players, and they all have the same name: \\\"Andreas\\\" (the most common name in Cyprus).\\n\\nIn each game, Theofanis plays with n other players. Since they all have the same name, they are numbered from 1 to n.\\n\\nThe players write m comments in the chat. A comment has the structure of \\\"i j c\\\" where i and j are two distinct integers and c is a string (1 ≤ i, j ≤ n; i ≠ j; c is either imposter or crewmate). The comment means that player i said that player j has the role c.\\n\\nAn imposter always lies, and a crewmate always tells the truth. \\n\\nHelp Theofanis find the maximum possible number of imposters among all the other Cypriot players, or determine that the comments contradict each other (see the notes for further explanation).\\n\\nNote that each player has exactly one role: either imposter or crewmate.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. Description of each test case follows.\\n\\nThe first line of each test case contains two integers n and m (1 ≤ n ≤ 2 ⋅ 10^5; 0 ≤ m ≤ 5 ⋅ 10^5) — the number of players except Theofanis and the number of comments.\\n\\nEach of the next m lines contains a comment made by the players of the structure \\\"i j c\\\" where i and j are two distinct integers and c is a string (1 ≤ i, j ≤ n; i ≠ j; c is either imposter or crewmate).\\n\\nThere can be multiple comments for the same pair of (i, j).\\n\\nIt is guaranteed that the sum of all n does not exceed 2 ⋅ 10^5 and the sum of all m does not exceed 5 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print one integer — the maximum possible number of imposters. If the comments contradict each other, print -1.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n3 2\\n1 2 imposter\\n2 3 crewmate\\n5 4\\n1 3 crewmate\\n2 5 crewmate\\n2 4 imposter\\n3 4 imposter\\n2 2\\n1 2 imposter\\n2 1 crewmate\\n3 5\\n1 2 imposter\\n1 2 imposter\\n3 2 crewmate\\n3 2 crewmate\\n1 3 imposter\\n5 0\\n\\n\\nOutput\\n\\n\\n2\\n4\\n-1\\n2\\n5\\n\\nNote\\n\\nIn the first test case, imposters can be Andreas 2 and 3.\\n\\nIn the second test...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nconst int N = 4e5 + 5;\\nint n, vis[N], f[N], fl[N], c0, c1;\\nvector e[N];\\nvoid dfs(int u) {\\n if (vis[u]) return;\\n c1 += (u > n);\\n vis[u] = 1;\\n for (int v : e[u]) dfs(v);\\n}\\nint find(int x) { return x == f[x] ? x : f[x] = find(f[x]); }\\nvoid add(int u, int v) {\\n e[u].push_back(v), e[v].push_back(u);\\n u = find(u), v = find(v);\\n if (u == v) return;\\n f[u] = v;\\n}\\nvoid solve() {\\n int m;\\n cin >> n >> m;\\n for (int i = 1; i <= n + n; ++i)\\n f[i] = i, fl[i] = 0, e[i].clear(), vis[i] = 0;\\n for (int i = 1; i <= m; ++i) {\\n int u, v;\\n string c;\\n cin >> u >> v >> c;\\n if (c == \\\"imposter\\\")\\n add(u, v + n), add(v, u + n);\\n else\\n add(u, v), add(u + n, v + n);\\n }\\n for (int i = 1; i <= n; ++i)\\n if (find(i) == find(i + n)) return (void)(cout << \\\"-1\\\\n\\\");\\n int ans = 0;\\n for (int i = 1; i <= n; ++i)\\n if (!vis[i]) {\\n c1 = 0, dfs(i), c0 = c1;\\n c1 = 0, dfs(i + n);\\n ans += max(c0, c1);\\n }\\n cout << ans << \\\"\\\\n\\\";\\n}\\nsigned main() {\\n ios::sync_with_stdio(false);\\n cin.tie(0), cout.tie(0);\\n int T = 1;\\n cin >> T;\\n while (T--) solve();\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given an array a of length n.\\n\\nLet's define the eversion operation. Let x = a_n. Then array a is partitioned into two parts: left and right. The left part contains the elements of a that are not greater than x (≤ x). The right part contains the elements of a that are strictly greater than x (> x). The order of elements in each part is kept the same as before the operation, i. e. the partition is stable. Then the array is replaced with the concatenation of the left and the right parts.\\n\\nFor example, if the array a is [2, 4, 1, 5, 3], the eversion goes like this: [2, 4, 1, 5, 3] → [2, 1, 3], [4, 5] → [2, 1, 3, 4, 5].\\n\\nWe start with the array a and perform eversions on this array. We can prove that after several eversions the array a stops changing. Output the minimum number k such that the array stops changing after k eversions.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 100). Description of the test cases follows.\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 2 ⋅ 10^5).\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9).\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case print a single integer k — the number of eversions after which the array stops changing.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n5\\n2 4 1 5 3\\n5\\n5 3 2 4 1\\n4\\n1 1 1 1\\n\\n\\nOutput\\n\\n\\n1\\n2\\n0\\n\\nNote\\n\\nConsider the fist example.\\n\\n * The first eversion: a = [1, 4, 2, 5, 3], x = 3. [2, 4, 1, 5, 3] → [2, 1, 3], [4, 5] → [2, 1, 3, 4, 5]. \\n * The second and following eversions: a = [2, 1, 3, 4, 5], x = 5. [2, 1, 3, 4, 5] → [2, 1, 3, 4, 5], [] → [2, 1, 3, 4, 5]. This eversion does not change the array, so the answer is 1. \\n\\n\\n\\nConsider the second example. \\n\\n * The first eversion: a = [5, 3, 2, 4, 1], x = 1. [5, 3, 2, 4, 1] → [1], [5, 3, 2, 4] → [1, 5, 3, 2, 4]. \\n * The second eversion: a = [1, 5, 3, 2, 4], x = 4. [1, 5, 3, 2, 4] → [1, 3, 2, 4], [5] → [1, 3, 2, 4, 5]. \\n * The third and following eversions: a = [1, 3, 2, 4,...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nusing str = string;\\ninline void __print(int x) { cerr << x; }\\ninline void __print(long x) { cerr << x; }\\ninline void __print(long long x) { cerr << x; }\\ninline void __print(unsigned x) { cerr << x; }\\ninline void __print(unsigned long x) { cerr << x; }\\ninline void __print(unsigned long long x) { cerr << x; }\\ninline void __print(float x) { cerr << x; }\\ninline void __print(double x) { cerr << x; }\\ninline void __print(long double x) { cerr << x; }\\ninline void __print(char x) { cerr << '\\\\'' << x << '\\\\''; }\\ninline void __print(const char *x) { cerr << '\\\\\\\"' << x << '\\\\\\\"'; }\\ninline void __print(const string &x) { cerr << '\\\\\\\"' << x << '\\\\\\\"'; }\\ninline void __print(bool x) { cerr << (x ? \\\"true\\\" : \\\"false\\\"); }\\ntemplate \\ninline void __print(vector &v) {\\n for (auto x : v) {\\n cerr << x << \\\" \\\";\\n }\\n}\\ntemplate \\nT gcd(T a, T b) {\\n if (!b) return a;\\n return gcd(b, a % b);\\n}\\ntemplate \\nT lcm(T a, T b) {\\n return a * b \\/ gcd(a, b);\\n}\\nconst int MAXN = 1000005;\\nconst int MOD = 1e9 + 7;\\ninline string IntToString(long long a) {\\n char x[100];\\n sprintf(x, \\\"%lld\\\", a);\\n string second = x;\\n return second;\\n}\\ninline long long StringToInt(string a) {\\n char x[100];\\n long long res;\\n strcpy(x, a.c_str());\\n sscanf(x, \\\"%lld\\\", &res);\\n return res;\\n}\\ninline string GetString(void) {\\n char x[MAXN];\\n scanf(\\\"%s\\\", x);\\n string second = x;\\n return second;\\n}\\ninline string uppercase(string second) {\\n int n = int((second).size());\\n for (int(i) = 0; i < n; i++)\\n if (second[i] >= 'a' && second[i] <= 'z') second[i] = second[i] - 'a' + 'A';\\n return second;\\n}\\ninline string lowercase(string second) {\\n int n = int((second).size());\\n for (int(i) = 0; i < n; i++)\\n if (second[i] >= 'A' && second[i] <= 'Z') second[i] = second[i] - 'A' + 'a';\\n return second;\\n}\\nstruct UF {\\n int n;\\n vector par;\\n UF(int _n) : n(_n) {\\n for (int i = 0; i < n; i++) par.push_back(i);\\n }\\n int find(int a) {\\n if (a != par[a]) par[a] = find(par[a]);\\n return par[a];\\n }\\n...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nThis is the easy version of the problem. The difference between the versions is that the easy version does not require you to output the numbers of the rods to be removed. You can make hacks only if all versions of the problem are solved.\\n\\nStitch likes experimenting with different machines with his friend Sparky. Today they built another machine.\\n\\nThe main element of this machine are n rods arranged along one straight line and numbered from 1 to n inclusive. Each of these rods must carry an electric charge quantitatively equal to either 1 or -1 (otherwise the machine will not work). Another condition for this machine to work is that the sign-variable sum of the charge on all rods must be zero.\\n\\nMore formally, the rods can be represented as an array of n numbers characterizing the charge: either 1 or -1. Then the condition must hold: a_1 - a_2 + a_3 - a_4 + … = 0, or ∑_{i=1}^n (-1)^{i-1} ⋅ a_i = 0.\\n\\nSparky charged all n rods with an electric current, but unfortunately it happened that the rods were not charged correctly (the sign-variable sum of the charge is not zero). The friends decided to leave only some of the rods in the machine. Sparky has q questions. In the ith question Sparky asks: if the machine consisted only of rods with numbers l_i to r_i inclusive, what minimal number of rods could be removed from the machine so that the sign-variable sum of charges on the remaining ones would be zero? Perhaps the friends got something wrong, and the sign-variable sum is already zero. In that case, you don't have to remove the rods at all.\\n\\nIf the number of rods is zero, we will assume that the sign-variable sum of charges is zero, that is, we can always remove all rods.\\n\\nHelp your friends and answer all of Sparky's questions!\\n\\nInput\\n\\nEach test contains multiple test cases.\\n\\nThe first line contains one positive integer t (1 ≤ t ≤ 10^3), denoting the number of test cases. Description of the test cases follows.\\n\\nThe first line of each test case contains two positive integers n and q (1 ≤ n, q ≤ 3 ⋅ 10^5) — the...\",\"targets\":\"#include \\nusing namespace std;\\nclass Fenwick {\\n public:\\n vector t;\\n int n;\\n void init(int nn) {\\n n = nn;\\n t.assign(n, 0);\\n }\\n int sum(int r) {\\n int result = 0;\\n for (; r >= 0; r = (r & (r + 1)) - 1) result += t[r];\\n return result;\\n }\\n void inc(int i, int delta) {\\n for (; i < n; i = (i | (i + 1))) t[i] += delta;\\n }\\n int sum(int l, int r) { return sum(r) - sum(l - 1); }\\n void init(vector &a) {\\n init((int)a.size());\\n for (int i = 0; i < a.size(); i++) inc(i, a[i]);\\n }\\n};\\nint main() {\\n int tst;\\n cin >> tst;\\n for (int t = 0; t < tst; ++t) {\\n int n, q;\\n cin >> n >> q;\\n vector arr;\\n for (int i = 0; i < n; i++) {\\n char c;\\n cin >> c;\\n if (c == '+') {\\n if (i % 2 == 0) {\\n arr.push_back(1);\\n } else {\\n arr.push_back(-1);\\n }\\n } else {\\n if (i % 2 == 1) {\\n arr.push_back(1);\\n } else {\\n arr.push_back(-1);\\n }\\n }\\n }\\n Fenwick fw;\\n fw.init(arr);\\n for (int i = 0; i < q; ++i) {\\n int l, r;\\n cin >> l >> r;\\n --l, --r;\\n int sm = fw.sum(l, r);\\n if (sm == 0) {\\n cout << 0 << endl;\\n } else if ((r - l + 1) % 2 == 1) {\\n cout << 1 << endl;\\n } else {\\n cout << 2 << endl;\\n }\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A binary string is a string that consists of characters 0 and 1. A bi-table is a table that has exactly two rows of equal length, each being a binary string.\\n\\nLet \\\\operatorname{MEX} of a bi-table be the smallest digit among 0, 1, or 2 that does not occur in the bi-table. For example, \\\\operatorname{MEX} for \\\\begin{bmatrix} 0011\\\\\\\\\\\\ 1010 \\\\end{bmatrix} is 2, because 0 and 1 occur in the bi-table at least once. \\\\operatorname{MEX} for \\\\begin{bmatrix} 111\\\\\\\\\\\\ 111 \\\\end{bmatrix} is 0, because 0 and 2 do not occur in the bi-table, and 0 < 2.\\n\\nYou are given a bi-table with n columns. You should cut it into any number of bi-tables (each consisting of consecutive columns) so that each column is in exactly one bi-table. It is possible to cut the bi-table into a single bi-table — the whole bi-table.\\n\\nWhat is the maximal sum of \\\\operatorname{MEX} of all resulting bi-tables can be?\\n\\nInput\\n\\nThe input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. Description of the test cases follows.\\n\\nThe first line of the description of each test case contains a single integer n (1 ≤ n ≤ 10^5) — the number of columns in the bi-table.\\n\\nEach of the next two lines contains a binary string of length n — the rows of the bi-table.\\n\\nIt's guaranteed that the sum of n over all test cases does not exceed 10^5.\\n\\nOutput\\n\\nFor each test case print a single integer — the maximal sum of \\\\operatorname{MEX} of all bi-tables that it is possible to get by cutting the given bi-table optimally.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n7\\n0101000\\n1101100\\n5\\n01100\\n10101\\n2\\n01\\n01\\n6\\n000000\\n111111\\n\\n\\nOutput\\n\\n\\n8\\n8\\n2\\n12\\n\\nNote\\n\\nIn the first test case you can cut the bi-table as follows:\\n\\n * \\\\begin{bmatrix} 0\\\\\\\\\\\\ 1 \\\\end{bmatrix}, its \\\\operatorname{MEX} is 2.\\n * \\\\begin{bmatrix} 10\\\\\\\\\\\\ 10 \\\\end{bmatrix}, its \\\\operatorname{MEX} is 2.\\n * \\\\begin{bmatrix} 1\\\\\\\\\\\\ 1 \\\\end{bmatrix}, its \\\\operatorname{MEX} is 0.\\n * \\\\begin{bmatrix} 0\\\\\\\\\\\\ 1 \\\\end{bmatrix}, its \\\\operatorname{MEX} is 2.\\n * \\\\begin{bmatrix} 0\\\\\\\\\\\\ 0 \\\\end{bmatrix}, its...\",\"targets\":\"#include \\nusing namespace std;\\nusing ll = long long;\\nusing pii = pair;\\nusing vi = vector;\\nusing str = string;\\nconst ll inf = 2 * 1e18;\\nint main() {\\n ios::sync_with_stdio(false);\\n cin.tie(0);\\n int tc;\\n cin >> tc;\\n while (tc--) {\\n int n;\\n cin >> n;\\n string s1, s2;\\n cin >> s1 >> s2;\\n int ans = 0;\\n for (int i = 0; i < n; ++i) {\\n if (i < n - 1) {\\n if (s1[i] == '0' && s2[i] == '0') {\\n if (s1[i + 1] == '1' && s2[i + 1] == '1') {\\n ans += 2;\\n ++i;\\n } else {\\n ++ans;\\n }\\n continue;\\n }\\n if (s1[i] == '1' && s2[i] == '1') {\\n if (s1[i + 1] == '0' && s2[i + 1] == '0') {\\n ans += 2;\\n ++i;\\n }\\n continue;\\n }\\n ans += 2;\\n } else {\\n if (s1[i] == '0' && s2[i] == '0') {\\n ++ans;\\n } else if (s1[i] == '1' && s2[i] == '1') {\\n } else {\\n ans += 2;\\n }\\n }\\n }\\n cout << ans << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given an integer n. Find any string s of length n consisting only of English lowercase letters such that each non-empty substring of s occurs in s an odd number of times. If there are multiple such strings, output any. It can be shown that such string always exists under the given constraints.\\n\\nA string a is a substring of a string b if a can be obtained from b by deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 500) — the number of test cases.\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 10^5).\\n\\nIt is guaranteed that the sum of n over all test cases doesn't exceed 3 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print a single line containing the string s. If there are multiple such strings, output any. It can be shown that such string always exists under the given constraints.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n5\\n9\\n19\\n\\n\\nOutput\\n\\n\\nabc\\ndiane\\nbbcaabbba\\nyouarethecutestuwuu\\n\\nNote\\n\\nIn the first test case, each substring of \\\"abc\\\" occurs exactly once.\\n\\nIn the third test case, each substring of \\\"bbcaabbba\\\" occurs an odd number of times. In particular, \\\"b\\\" occurs 5 times, \\\"a\\\" and \\\"bb\\\" occur 3 times each, and each of the remaining substrings occurs exactly once.\\nfrom\",\"targets\":\"functools import lru_cache\\nfrom collections import deque\\n# cost = lambda i : i and i or 2\\ndef solve():\\n t = int(input())\\n for _ in range(t):\\n n = int(input())\\n if n % 2 == 0:\\n print('a' * (n \\/\\/ 2) + 'b' + 'a' * ((n - 1) \\/\\/ 2))\\n elif n == 1:\\n print('a')\\n else:\\n print('a' * ((n - 1) \\/\\/ 2) + 'bc' + 'a' * ((n - 2) \\/\\/ 2))\\nsolve()\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A string s of length n, consisting of lowercase letters of the English alphabet, is given.\\n\\nYou must choose some number k between 0 and n. Then, you select k characters of s and permute them however you want. In this process, the positions of the other n-k characters remain unchanged. You have to perform this operation exactly once.\\n\\nFor example, if s=\\\"andrea\\\", you can choose the k=4 characters \\\"a_d_ea\\\" and permute them into \\\"d_e_aa\\\" so that after the operation the string becomes \\\"dneraa\\\".\\n\\nDetermine the minimum k so that it is possible to sort s alphabetically (that is, after the operation its characters appear in alphabetical order).\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases. Then t test cases follow.\\n\\nThe first line of each test case contains one integer n (1 ≤ n ≤ 40) — the length of the string.\\n\\nThe second line of each test case contains the string s. It is guaranteed that s contains only lowercase letters of the English alphabet.\\n\\nOutput\\n\\nFor each test case, output the minimum k that allows you to obtain a string sorted alphabetically, through the operation described above.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\nlol\\n10\\ncodeforces\\n5\\naaaaa\\n4\\ndcba\\n\\n\\nOutput\\n\\n\\n2\\n6\\n0\\n4\\n\\nNote\\n\\nIn the first test case, we can choose the k=2 characters \\\"_ol\\\" and rearrange them as \\\"_lo\\\" (so the resulting string is \\\"llo\\\"). It is not possible to sort the string choosing strictly less than 2 characters.\\n\\nIn the second test case, one possible way to sort s is to consider the k=6 characters \\\"_o__force_\\\" and rearrange them as \\\"_c__efoor_\\\" (so the resulting string is \\\"ccdeefoors\\\"). One can show that it is not possible to sort the string choosing strictly less than 6 characters.\\n\\nIn the third test case, string s is already sorted (so we can choose k=0 characters).\\n\\nIn the fourth test case, we can choose all k=4 characters \\\"dcba\\\" and reverse the whole string (so the resulting string is \\\"abcd\\\").\",\"targets\":\"#include \\nusing namespace std;\\nvector > v;\\nint main() {\\n cin.tie(nullptr)->sync_with_stdio(false);\\n int T;\\n cin >> T;\\n while (T--) {\\n int n;\\n string s, str;\\n cin >> n >> s;\\n v.clear();\\n for (int i = 0; i < s.length(); i++) {\\n int a = s[i] - 'a', b = i;\\n v.push_back({a, b});\\n }\\n sort(v.begin(), v.end());\\n int ans = 0;\\n for (int i = 0; i < s.length(); i++) {\\n if (s[i] != (char)(v[i].first + 'a')) ans++;\\n }\\n cout << ans << endl;\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nOne day Vasya the Hipster decided to count how many socks he had. It turned out that he had a red socks and b blue socks.\\n\\nAccording to the latest fashion, hipsters should wear the socks of different colors: a red one on the left foot, a blue one on the right foot.\\n\\nEvery day Vasya puts on new socks in the morning and throws them away before going to bed as he doesn't want to wash them.\\n\\nVasya wonders, what is the maximum number of days when he can dress fashionable and wear different socks, and after that, for how many days he can then wear the same socks until he either runs out of socks or cannot make a single pair from the socks he's got.\\n\\nCan you help him?\\n\\nInput\\n\\nThe single line of the input contains two positive integers a and b (1 ≤ a, b ≤ 100) — the number of red and blue socks that Vasya's got.\\n\\nOutput\\n\\nPrint two space-separated integers — the maximum number of days when Vasya can wear different socks and the number of days when he can wear the same socks until he either runs out of socks or cannot make a single pair from the socks he's got.\\n\\nKeep in mind that at the end of the day Vasya throws away the socks that he's been wearing on that day.\\n\\nExamples\\n\\nInput\\n\\n3 1\\n\\n\\nOutput\\n\\n1 1\\n\\n\\nInput\\n\\n2 3\\n\\n\\nOutput\\n\\n2 0\\n\\n\\nInput\\n\\n7 3\\n\\n\\nOutput\\n\\n3 2\\n\\nNote\\n\\nIn the first sample Vasya can first put on one pair of different socks, after that he has two red socks left to wear on the second day.\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(nullptr);\\n cout.tie(nullptr);\\n int a, b, c, d;\\n cin >> a >> b;\\n if (a >= b) cout << b;\\n int x = abs(a - b) \\/ 2;\\n if (b > a) cout << a;\\n cout << \\\" \\\" << x;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"The Hat is a game of speedy explanation\\/guessing words (similar to Alias). It's fun. Try it! In this problem, we are talking about a variant of the game when the players are sitting at the table and everyone plays individually (i.e. not teams, but individual gamers play).\\n\\nn people gathered in a room with m tables (n ≥ 2m). They want to play the Hat k times. Thus, k games will be played at each table. Each player will play in k games.\\n\\nTo do this, they are distributed among the tables for each game. During each game, one player plays at exactly one table. A player can play at different tables.\\n\\nPlayers want to have the most \\\"fair\\\" schedule of games. For this reason, they are looking for a schedule (table distribution for each game) such that:\\n\\n * At any table in each game there are either ⌊n\\/m⌋ people or ⌈n\\/m⌉ people (that is, either n\\/m rounded down, or n\\/m rounded up). Different numbers of people can play different games at the same table.\\n * Let's calculate for each player the value b_i — the number of times the i-th player played at a table with ⌈n\\/m⌉ persons (n\\/m rounded up). Any two values of b_imust differ by no more than 1. In other words, for any two players i and j, it must be true |b_i - b_j| ≤ 1. \\n\\n\\n\\nFor example, if n=5, m=2 and k=2, then at the request of the first item either two players or three players should play at each table. Consider the following schedules:\\n\\n * First game: 1, 2, 3 are played at the first table, and 4, 5 at the second one. The second game: at the first table they play 5, 1, and at the second — 2, 3, 4. This schedule is not \\\"fair\\\" since b_2=2 (the second player played twice at a big table) and b_5=0 (the fifth player did not play at a big table).\\n * First game: 1, 2, 3 are played at the first table, and 4, 5 at the second one. The second game: at the first table they play 4, 5, 2, and at the second one — 1, 3. This schedule is \\\"fair\\\": b=[1,2,1,1,1] (any two values of b_i differ by no more than 1). \\n\\n\\n\\nFind any \\\"fair\\\" game schedule for n people if they play on the m...\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"from __future__ import division, print_function\\nimport math\\nimport sys\\nimport os\\nfrom io import BytesIO, IOBase\\nfrom typing import DefaultDict\\nfrom collections import deque, Counter, OrderedDict, defaultdict\\n#import heapq\\n#ceil,floor,log,sqrt,factorial,pow,pi,gcd\\n#import bisect\\n#from bisect import bisect_left,bisect_right\\n\\nBUFSIZE = 8192\\n\\n\\nclass FastIO(IOBase):\\n\\tnewlines = 0\\n\\n\\tdef __init__(self, file):\\n\\t\\tself._fd = file.fileno()\\n\\t\\tself.buffer = BytesIO()\\n\\t\\tself.writable = \\\"x\\\" in file.mode or \\\"r\\\" not in file.mode\\n\\t\\tself.write = self.buffer.write if self.writable else None\\n\\n\\tdef read(self):\\n\\t\\twhile True:\\n\\t\\t\\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n\\t\\t\\tif not b:\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tptr = self.buffer.tell()\\n\\t\\t\\tself.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n\\t\\tself.newlines = 0\\n\\t\\treturn self.buffer.read()\\n\\n\\tdef readline(self):\\n\\t\\twhile self.newlines == 0:\\n\\t\\t\\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n\\t\\t\\tself.newlines = b.count(b\\\"\\\\n\\\") + (not b)\\n\\t\\t\\tptr = self.buffer.tell()\\n\\t\\t\\tself.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n\\t\\tself.newlines -= 1\\n\\t\\treturn self.buffer.readline()\\n\\n\\tdef flush(self):\\n\\t\\tif self.writable:\\n\\t\\t\\tos.write(self._fd, self.buffer.getvalue())\\n\\t\\t\\tself.buffer.truncate(0), self.buffer.seek(0)\\n\\n\\nclass IOWrapper(IOBase):\\n\\tdef __init__(self, file):\\n\\t\\tself.buffer = FastIO(file)\\n\\t\\tself.flush = self.buffer.flush\\n\\t\\tself.writable = self.buffer.writable\\n\\t\\tself.write = lambda s: self.buffer.write(s.encode(\\\"ascii\\\"))\\n\\t\\tself.read = lambda: self.buffer.read().decode(\\\"ascii\\\")\\n\\t\\tself.readline = lambda: self.buffer.readline().decode(\\\"ascii\\\")\\n\\n\\ndef print(*args, **kwargs):\\n\\t\\\"\\\"\\\"Prints the values to a stream, or to sys.stdout by default.\\\"\\\"\\\"\\n\\tsep, file = kwargs.pop(\\\"sep\\\", \\\" \\\"), kwargs.pop(\\\"file\\\", sys.stdout)\\n\\tat_start = True\\n\\tfor x in args:\\n\\t\\tif not at_start:\\n\\t\\t\\tfile.write(sep)\\n\\t\\tfile.write(str(x))\\n\\t\\tat_start = False\\n\\tfile.write(kwargs.pop(\\\"end\\\", \\\"\\\\n\\\"))\\n\\tif kwargs.pop(\\\"flush\\\", False):\\n\\t\\tfile.flush()\\n\\n\\nif sys.version_info[0] < 3:\\n\\tsys.stdin, sys.stdout...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"When you play the game of thrones, you win, or you die. There is no middle ground.\\n\\nCersei Lannister, A Game of Thrones by George R. R. Martin\\n\\nThere are n nobles, numbered from 1 to n. Noble i has a power of i. There are also m \\\"friendships\\\". A friendship between nobles a and b is always mutual.\\n\\nA noble is defined to be vulnerable if both of the following conditions are satisfied: \\n\\n * the noble has at least one friend, and \\n * all of that noble's friends have a higher power. \\n\\n\\n\\nYou will have to process the following three types of queries. \\n\\n 1. Add a friendship between nobles u and v. \\n 2. Remove a friendship between nobles u and v. \\n 3. Calculate the answer to the following process. \\n\\n\\n\\nThe process: all vulnerable nobles are simultaneously killed, and all their friendships end. Then, it is possible that new nobles become vulnerable. The process repeats itself until no nobles are vulnerable. It can be proven that the process will end in finite time. After the process is complete, you need to calculate the number of remaining nobles.\\n\\nNote that the results of the process are not carried over between queries, that is, every process starts with all nobles being alive!\\n\\nInput\\n\\nThe first line contains the integers n and m (1 ≤ n ≤ 2⋅ 10^5, 0 ≤ m ≤ 2⋅ 10^5) — the number of nobles and number of original friendships respectively.\\n\\nThe next m lines each contain the integers u and v (1 ≤ u,v ≤ n, u ≠ v), describing a friendship. No friendship is listed twice.\\n\\nThe next line contains the integer q (1 ≤ q ≤ 2⋅ {10}^{5}) — the number of queries. \\n\\nThe next q lines contain the queries themselves, each query has one of the following three formats. \\n\\n * 1 u v (1 ≤ u,v ≤ n, u ≠ v) — add a friendship between u and v. It is guaranteed that u and v are not friends at this moment. \\n * 2 u v (1 ≤ u,v ≤ n, u ≠ v) — remove a friendship between u and v. It is guaranteed that u and v are friends at this moment. \\n * 3 — print the answer to the process described in the statement. \\n\\nOutput\\n\\nFor each type 3 query print one...\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n int n, m, a, b, s = 0;\\n cin >> n >> m;\\n int arr[n + 1];\\n memset(arr, 0, sizeof(arr));\\n for (int i = 0; i < m; i++) {\\n cin >> a >> b;\\n if (a > b) swap(a, b);\\n arr[a]++;\\n if (arr[a] == 1) s++;\\n }\\n int q;\\n cin >> q;\\n while (q--) {\\n int p;\\n cin >> p;\\n if (p == 1) {\\n cin >> a >> b;\\n if (a > b) swap(a, b);\\n arr[a]++;\\n if (arr[a] == 1) s++;\\n } else if (p == 2) {\\n cin >> a >> b;\\n if (a > b) swap(a, b);\\n arr[a]--;\\n if (arr[a] == 0) s--;\\n } else {\\n cout << n - s << \\\"\\\\n\\\";\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"As meticulous Gerald sets the table and caring Alexander sends the postcards, Sergey makes snowmen. Each showman should consist of three snowballs: a big one, a medium one and a small one. Sergey's twins help him: they've already made n snowballs with radii equal to r1, r2, ..., rn. To make a snowman, one needs any three snowballs whose radii are pairwise different. For example, the balls with radii 1, 2 and 3 can be used to make a snowman but 2, 2, 3 or 2, 2, 2 cannot. Help Sergey and his twins to determine what maximum number of snowmen they can make from those snowballs.\\n\\nInput\\n\\nThe first line contains integer n (1 ≤ n ≤ 105) — the number of snowballs. The next line contains n integers — the balls' radii r1, r2, ..., rn (1 ≤ ri ≤ 109). The balls' radii can coincide.\\n\\nOutput\\n\\nPrint on the first line a single number k — the maximum number of the snowmen. Next k lines should contain the snowmen's descriptions. The description of each snowman should consist of three space-separated numbers — the big ball's radius, the medium ball's radius and the small ball's radius. It is allowed to print the snowmen in any order. If there are several solutions, print any of them.\\n\\nExamples\\n\\nInput\\n\\n7\\n1 2 3 4 5 6 7\\n\\n\\nOutput\\n\\n2\\n3 2 1\\n6 5 4\\n\\n\\nInput\\n\\n3\\n2 2 3\\n\\n\\nOutput\\n\\n0\\n#incl\",\"targets\":\"ude \\n#pragma comment(linker, \\\"\\/STACK:16777216\\\")\\nusing namespace std;\\nusing namespace std;\\ndouble EPS = 1e-7;\\nmap m;\\nset > s;\\nvector a, b, c;\\nint main() {\\n int n;\\n scanf(\\\"%d\\\", &n);\\n for (int i = 0; i < n; i++) {\\n int x;\\n scanf(\\\"%d\\\", &x);\\n m[x]++;\\n }\\n for (map::iterator i = m.begin(); i != m.end(); i++) {\\n pair X = *i;\\n s.insert(make_pair(-X.second, X.first));\\n }\\n while (s.size() >= 3) {\\n pair A, B, C;\\n A = *s.begin();\\n s.erase(s.begin());\\n B = *s.begin();\\n s.erase(s.begin());\\n C = *s.begin();\\n s.erase(s.begin());\\n a.push_back(A.second);\\n b.push_back(B.second);\\n c.push_back(C.second);\\n A.first++;\\n B.first++;\\n C.first++;\\n if (A.first != 0) s.insert(A);\\n if (B.first != 0) s.insert(B);\\n if (C.first != 0) s.insert(C);\\n }\\n printf(\\\"%d\\\\n\\\", a.size());\\n for (int i = 0; i < a.size(); i++) {\\n int A[3] = {a[i], b[i], c[i]};\\n sort(A, A + 3);\\n printf(\\\"%d %d %d\\\\n\\\", A[2], A[1], A[0]);\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"The new generation external memory contains an array of integers a[1 … n] = [a_1, a_2, …, a_n].\\n\\nThis type of memory does not support changing the value of an arbitrary element. Instead, it allows you to cut out any segment of the given array, cyclically shift (rotate) it by any offset and insert it back into the same place.\\n\\nTechnically, each cyclic shift consists of two consecutive actions: \\n\\n 1. You may select arbitrary indices l and r (1 ≤ l < r ≤ n) as the boundaries of the segment. \\n 2. Then you replace the segment a[l … r] with it's cyclic shift to the left by an arbitrary offset d. The concept of a cyclic shift can be also explained by following relations: the sequence [1, 4, 1, 3] is a cyclic shift of the sequence [3, 1, 4, 1] to the left by the offset 1 and the sequence [4, 1, 3, 1] is a cyclic shift of the sequence [3, 1, 4, 1] to the left by the offset 2. \\n\\n\\n\\nFor example, if a = [1, \\\\color{blue}{3, 2, 8}, 5], then choosing l = 2, r = 4 and d = 2 yields a segment a[2 … 4] = [3, 2, 8]. This segment is then shifted by the offset d = 2 to the left, and you get a segment [8, 3, 2] which then takes the place of of the original elements of the segment. In the end you get a = [1, \\\\color{blue}{8, 3, 2}, 5].\\n\\nSort the given array a using no more than n cyclic shifts of any of its segments. Note that you don't need to minimize the number of cyclic shifts. Any method that requires n or less cyclic shifts will be accepted.\\n\\nInput\\n\\nThe first line contains an integer t (1 ≤ t ≤ 1000) — the number of test cases.\\n\\nThe next 2t lines contain the descriptions of the test cases. \\n\\nThe first line of each test case description contains an integer n (2 ≤ n ≤ 50) — the length of the array. The second line consists of space-separated elements of the array a_i (-10^9 ≤ a_i ≤ 10^9). Elements of array a may repeat and don't have to be unique.\\n\\nOutput\\n\\nPrint t answers to all input test cases. \\n\\nThe first line of the answer of each test case should contain an integer k (0 ≤ k ≤ n) — the number of actions to sort the array....\\nSolve the task in JAVA.\",\"targets\":\"import java.util.ArrayList;\\nimport java.io.BufferedReader;\\nimport java.io.FileReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.util.StringTokenizer;\\nimport java.util.Arrays;\\nimport java.util.Random;\\nimport java.io.FileWriter;\\nimport java.io.PrintWriter;\\n\\/*\\n Solution Created: 17:53:23 28\\/09\\/2021\\n Custom Competitive programming helper.\\n*\\/\\n\\npublic class Main {\\n\\t\\n\\tpublic static void solve() {\\n\\t\\tint n = in.nextInt();\\n\\t\\tint[] a = in.na(n);\\n\\t\\tint[] s = a.clone();\\n\\t\\tUtil.sortArray(s);\\n\\t\\tArrayList moves = new ArrayList<>();\\n\\t\\tfor(int i = 0; il; i--) a[i] = a[i-1];\\n\\t\\ta[l] = tmp;\\n\\t}\\n\\tpublic static void main(String[] args) {\\n\\t\\tin = new Reader();\\n\\t\\tout = new Writer();\\n\\t\\tint t = in.nextInt();\\n\\t\\twhile(t-->0) solve();\\n\\t\\tout.exit();\\n\\t}\\n\\tstatic Reader in; static Writer out;\\n\\nstatic class Reader {\\n\\tstatic BufferedReader br;\\n\\tstatic StringTokenizer st;\\n\\t\\n\\tpublic Reader() {\\n\\t\\tthis.br = new BufferedReader(new InputStreamReader(System.in));\\n\\t}\\n\\t\\n\\tpublic Reader(String f){\\n\\t\\ttry {\\n\\t\\t\\tthis.br = new BufferedReader(new FileReader(f));\\n\\t\\t} catch (IOException e) {\\n\\t\\t\\te.printStackTrace();\\n\\t\\t}\\n\\t}\\n\\t\\n\\tpublic int[] na(int n) {\\n\\t\\tint[] a = new int[n];\\n\\t\\tfor (int i = 0; i < n; i++) a[i] = nextInt();\\n\\t\\treturn a;\\n\\t}\\n\\n\\tpublic double[] nd(int n) {\\n\\t\\tdouble[] a = new double[n];\\n\\t\\tfor (int i = 0; i < n; i++) a[i] = nextDouble();\\n\\t\\treturn a;\\n\\t}\\n\\t\\n\\tpublic long[] nl(int n) {\\n\\t\\tlong[] a = new long[n];\\n\\t\\tfor (int i = 0; i < n; i++) a[i] = nextLong();\\n\\t\\treturn a;\\n\\t}\\n\\n\\tpublic char[] nca() {\\n\\t\\treturn next().toCharArray();\\n\\t}\\n\\n\\tpublic String[] ns(int n) {\\n\\t\\tString[] a =...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"An important meeting is to be held and there are exactly n people invited. At any moment, any two people can step back and talk in private. The same two people can talk several (as many as they want) times per meeting.\\n\\nEach person has limited sociability. The sociability of the i-th person is a non-negative integer a_i. This means that after exactly a_i talks this person leaves the meeting (and does not talk to anyone else anymore). If a_i = 0, the i-th person leaves the meeting immediately after it starts.\\n\\nA meeting is considered most productive if the maximum possible number of talks took place during it.\\n\\nYou are given an array of sociability a, determine which people should talk to each other so that the total number of talks is as large as possible.\\n\\nInput\\n\\nThe first line contains an integer t (1 ≤ t ≤ 1000) — the number of test cases.\\n\\nThe next 2t lines contain descriptions of the test cases.\\n\\nThe first line of each test case description contains an integer n (2 ≤ n ≤ 2 ⋅ 10^5) —the number of people in the meeting. The second line consists of n space-separated integers a_1, a_2, ..., a_n (0 ≤ a_i ≤ 2 ⋅ 10^5) — the sociability parameters of all people. \\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5. It is also guaranteed that the sum of all a_i (over all test cases and all i) does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nPrint t answers to all test cases.\\n\\nOn the first line of each answer print the number k — the maximum number of talks possible in a meeting.\\n\\nOn each of the next k lines print two integers i and j (1 ≤ i, j ≤ n and i ≠ j) — the numbers of people who will have another talk.\\n\\nIf there are several possible answers, you may print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n8\\n2\\n2 3\\n3\\n1 2 3\\n4\\n1 2 3 4\\n3\\n0 0 2\\n2\\n6 2\\n3\\n0 0 2\\n5\\n8 2 0 1 1\\n5\\n0 1 0 0 6\\n\\n\\nOutput\\n\\n\\n2\\n1 2\\n1 2\\n3\\n1 3\\n2 3\\n2 3\\n5\\n1 3\\n2 4\\n2 4\\n3 4\\n3 4\\n0\\n2\\n1 2\\n1 2\\n0\\n4\\n1 2\\n1 5\\n1 4\\n1 2\\n1\\n5 2\",\"targets\":\"#include \\nusing namespace std;\\nvoid Tez() {\\n ios::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n}\\nint32_t main() {\\n Tez();\\n long long t;\\n cin >> t;\\n while (t--) {\\n long long n;\\n cin >> n;\\n long long a[n];\\n for (long long i = 0; i <= n - 1; i++) cin >> a[i];\\n priority_queue> pq;\\n for (long long i = 0; i <= n - 1; i++) {\\n if (a[i] != 0) {\\n pq.push({a[i], i + 1});\\n }\\n }\\n long long cnt = 0;\\n vector> res;\\n while (pq.size() > 1) {\\n auto p1 = pq.top();\\n pq.pop();\\n auto p2 = pq.top();\\n pq.pop();\\n cnt++;\\n res.push_back({p1.second, p2.second});\\n p1.first -= 1;\\n p2.first -= 1;\\n if (p1.first > 0) pq.push(p1);\\n if (p2.first > 0) pq.push(p2);\\n }\\n cout << cnt << '\\\\n';\\n for (auto vec : res) {\\n cout << vec[0] << \\\" \\\" << vec[1] << '\\\\n';\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"The city where Mocha lives in is called Zhijiang. There are n+1 villages and 2n-1 directed roads in this city. \\n\\nThere are two kinds of roads:\\n\\n * n-1 roads are from village i to village i+1, for all 1≤ i ≤ n-1. \\n * n roads can be described by a sequence a_1,…,a_n. If a_i=0, the i-th of these roads goes from village i to village n+1, otherwise it goes from village n+1 to village i, for all 1≤ i≤ n. \\n\\n\\n\\nMocha plans to go hiking with Taki this weekend. To avoid the trip being boring, they plan to go through every village exactly once. They can start and finish at any villages. Can you help them to draw up a plan? \\n\\nInput\\n\\nEach test contains multiple test cases. \\n\\nThe first line contains a single integer t (1 ≤ t ≤ 20) — the number of test cases. Each test case consists of two lines.\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 10^4) — indicates that the number of villages is n+1.\\n\\nThe second line of each test case contains n integers a_1, a_2, …, a_n (0 ≤ a_i ≤ 1). If a_i=0, it means that there is a road from village i to village n+1. If a_i=1, it means that there is a road from village n+1 to village i.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 10^4.\\n\\nOutput\\n\\nFor each test case, print a line with n+1 integers, where the i-th number is the i-th village they will go through. If the answer doesn't exist, print -1.\\n\\nIf there are multiple correct answers, you can print any one of them.\\n\\nExample\\n\\nInput\\n\\n\\n2\\n3\\n0 1 0\\n3\\n1 1 0\\n\\n\\nOutput\\n\\n\\n1 4 2 3 \\n4 1 2 3 \\n\\nNote\\n\\nIn the first test case, the city looks like the following graph:\\n\\n\\n\\nSo all possible answers are (1 → 4 → 2 → 3), (1 → 2 → 3 → 4).\\n\\nIn the second test case, the city looks like the following graph:\\n\\n\\n\\nSo all possible answers are (4 → 1 → 2 → 3), (1 → 2 → 3 → 4), (3 → 4 → 1 → 2), (2 → 3 → 4 → 1).\",\"targets\":\"import os\\nimport sys\\nfrom io import BytesIO, IOBase\\n \\n \\n#--------------------fastio--------------------\\n\\nBUFSIZE = 8192\\n\\n\\nclass FastIO(IOBase):\\n newlines = 0\\n\\n def __init__(self, file):\\n self._fd = file.fileno()\\n self.buffer = BytesIO()\\n self.writable = \\\"x\\\" in file.mode or \\\"r\\\" not in file.mode\\n self.write = self.buffer.write if self.writable else None\\n\\n def read(self):\\n while True:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n if not b:\\n break\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines = 0\\n return self.buffer.read()\\n\\n def readline(self):\\n while self.newlines == 0:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n self.newlines = b.count(b\\\"\\\\n\\\") + (not b)\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines -= 1\\n return self.buffer.readline()\\n\\n def flush(self):\\n if self.writable:\\n os.write(self._fd, self.buffer.getvalue())\\n self.buffer.truncate(0), self.buffer.seek(0)\\n\\n\\nclass IOWrapper(IOBase):\\n def __init__(self, file):\\n self.buffer = FastIO(file)\\n self.flush = self.buffer.flush\\n self.writable = self.buffer.writable\\n self.write = lambda s: self.buffer.write(s.encode(\\\"ascii\\\"))\\n self.read = lambda: self.buffer.read().decode(\\\"ascii\\\")\\n self.readline = lambda: self.buffer.readline().decode(\\\"ascii\\\")\\n\\n\\nif(os.path.exists('input.txt')):\\n sys.stdin = open('input.txt','r') ; sys.stdout = open('output.txt','w')\\nelse:\\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\\n input = lambda: sys.stdin.readline().rstrip(\\\"\\\\r\\\\n\\\")\\n\\nfor t in range(int(input())):\\n n = int(input())\\n a = list(map(int, input().split()))\\n if n==1:\\n if a[0] == 0:\\n print(1,2)\\n else:\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Bob is playing a game named \\\"Walk on Matrix\\\".\\n\\nIn this game, player is given an n × m matrix A=(a_{i,j}), i.e. the element in the i-th row in the j-th column is a_{i,j}. Initially, player is located at position (1,1) with score a_{1,1}. \\n\\nTo reach the goal, position (n,m), player can move right or down, i.e. move from (x,y) to (x,y+1) or (x+1,y), as long as player is still on the matrix.\\n\\nHowever, each move changes player's score to the [bitwise AND](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#AND) of the current score and the value at the position he moves to.\\n\\nBob can't wait to find out the maximum score he can get using the tool he recently learnt — dynamic programming. Here is his algorithm for this problem. \\n\\n\\n\\nHowever, he suddenly realize that the algorithm above fails to output the maximum score for some matrix A. Thus, for any given non-negative integer k, he wants to find out an n × m matrix A=(a_{i,j}) such that \\n\\n * 1 ≤ n,m ≤ 500 (as Bob hates large matrix); \\n * 0 ≤ a_{i,j} ≤ 3 ⋅ 10^5 for all 1 ≤ i≤ n,1 ≤ j≤ m (as Bob hates large numbers); \\n * the difference between the maximum score he can get and the output of his algorithm is exactly k. \\n\\n\\n\\nIt can be shown that for any given integer k such that 0 ≤ k ≤ 10^5, there exists a matrix satisfying the above constraints.\\n\\nPlease help him with it!\\n\\nInput\\n\\nThe only line of the input contains one single integer k (0 ≤ k ≤ 10^5).\\n\\nOutput\\n\\nOutput two integers n, m (1 ≤ n,m ≤ 500) in the first line, representing the size of the matrix. \\n\\nThen output n lines with m integers in each line, a_{i,j} in the (i+1)-th row, j-th column.\\n\\nExamples\\n\\nInput\\n\\n\\n0\\n\\n\\nOutput\\n\\n\\n1 1\\n300000\\n\\nInput\\n\\n\\n1\\n\\n\\nOutput\\n\\n\\n3 4\\n7 3 3 1\\n4 8 3 6\\n7 7 7 3\\n\\nNote\\n\\nIn the first example, the maximum score Bob can achieve is 300000, while the output of his algorithm is 300000.\\n\\nIn the second example, the maximum score Bob can achieve is 7\\\\&3\\\\&3\\\\&3\\\\&7\\\\&3=3, while the output of his algorithm is 2.\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nint mod(int a, int b) { return a >= 0 ? a % b : (b + a % b) % b; }\\nint dceil(int a, int b) { return (a + b - 1) \\/ b; }\\nint mat[500][500];\\nint pont[500][500];\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n int eb = 1 << 17;\\n int k;\\n cin >> k;\\n int nk = (1 << 17) - 1 - k;\\n cout << 3 << \\\" \\\" << 3 << \\\"\\\\n\\\";\\n int arr[3][3];\\n arr[0][0] = arr[0][1] = arr[1][2] = eb + k;\\n arr[0][2] = arr[2][2] = k;\\n arr[1][0] = arr[2][0] = arr[2][1] = 0;\\n arr[1][1] = eb + nk;\\n for (int i = 0; i < 3; i++) {\\n for (int j = 0; j < 3; j++) {\\n cout << arr[i][j] << \\\" \\\";\\n }\\n cout << \\\"\\\\n\\\";\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Two painters, Amin and Benj, are repainting Gregor's living room ceiling! The ceiling can be modeled as an n × m grid.\\n\\nFor each i between 1 and n, inclusive, painter Amin applies a_i layers of paint to the entire i-th row. For each j between 1 and m, inclusive, painter Benj applies b_j layers of paint to the entire j-th column. Therefore, the cell (i,j) ends up with a_i+b_j layers of paint.\\n\\nGregor considers the cell (i,j) to be badly painted if a_i+b_j ≤ x. Define a badly painted region to be a maximal connected component of badly painted cells, i. e. a connected component of badly painted cells such that all adjacent to the component cells are not badly painted. Two cells are considered adjacent if they share a side.\\n\\nGregor is appalled by the state of the finished ceiling, and wants to know the number of badly painted regions.\\n\\nInput\\n\\nThe first line contains three integers n, m and x (1 ≤ n,m ≤ 2⋅ 10^5, 1 ≤ x ≤ 2⋅ 10^5) — the dimensions of Gregor's ceiling, and the maximum number of paint layers in a badly painted cell.\\n\\nThe second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 2⋅ 10^5), the number of paint layers Amin applies to each row.\\n\\nThe third line contains m integers b_1, b_2, …, b_m (1 ≤ b_j ≤ 2⋅ 10^5), the number of paint layers Benj applies to each column.\\n\\nOutput\\n\\nPrint a single integer, the number of badly painted regions.\\n\\nExamples\\n\\nInput\\n\\n\\n3 4 11\\n9 8 5\\n10 6 7 2\\n\\n\\nOutput\\n\\n\\n2\\n\\n\\nInput\\n\\n\\n3 4 12\\n9 8 5\\n10 6 7 2\\n\\n\\nOutput\\n\\n\\n1\\n\\n\\nInput\\n\\n\\n3 3 2\\n1 2 1\\n1 2 1\\n\\n\\nOutput\\n\\n\\n4\\n\\n\\nInput\\n\\n\\n5 23 6\\n1 4 3 5 2\\n2 3 1 6 1 5 5 6 1 3 2 6 2 3 1 6 1 4 1 6 1 5 5\\n\\n\\nOutput\\n\\n\\n6\\n\\nNote\\n\\nThe diagram below represents the first example. The numbers to the left of each row represent the list a, and the numbers above each column represent the list b. The numbers inside each cell represent the number of paint layers in that cell.\\n\\nThe colored cells correspond to badly painted cells. The red and blue cells respectively form 2 badly painted regions.\\n\\n\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nconst int INFi = 2e9 + 5;\\nconst int maxN = 2e5 + 5;\\nconst int md = 998244353;\\nconst long long INF = 2e18;\\ndouble getTime() { return clock() \\/ (double)CLOCKS_PER_SEC; }\\nvector> solve(vector &a) {\\n int n = a.size();\\n vector> stk = {{-INFi, -INFi}};\\n vector> result(n);\\n for (int i = 0; i < (n); ++i) {\\n int mx = stk.back().second;\\n while (!stk.empty() && stk.back().first >= a[i]) {\\n stk.pop_back();\\n mx = max(mx, stk.back().second);\\n }\\n stk.back().second = max(mx, a[i]);\\n if (stk.size() == 1) mx = INFi;\\n result[i] = {a[i], mx};\\n stk.emplace_back(a[i], -INFi);\\n }\\n stk = {{-INFi, -INFi}};\\n for (int i = n - 1; i >= 0; --i) {\\n int mx = stk.back().second;\\n while (!stk.empty() && stk.back().first > a[i]) {\\n stk.pop_back();\\n mx = max(mx, stk.back().second);\\n }\\n stk.back().second = max(mx, a[i]);\\n if (stk.size() == 1) mx = INFi;\\n result[i].second = min(result[i].second, mx);\\n stk.emplace_back(a[i], -INFi);\\n }\\n return result;\\n}\\nstruct fenwick {\\n int n{};\\n vector fenw{};\\n void build(int k) {\\n n = k;\\n fenw.resize(n);\\n }\\n void upd(int i, long long x) {\\n for (; i < n; i = i | (i + 1)) fenw[i] += x;\\n }\\n long long get(int i) {\\n long long res = 0;\\n for (; i >= 0; i = (i & (i + 1)) - 1) res += fenw[i];\\n return res;\\n }\\n long long get(int l, int r) {\\n if (l > r) return 0;\\n return get(r) - get(l - 1);\\n }\\n};\\nvoid solve() {\\n int n, m;\\n cin >> n >> m;\\n int x;\\n cin >> x;\\n vector a(n), b(m);\\n for (int i = 0; i < (n); ++i) cin >> a[i];\\n for (int i = 0; i < (m); ++i) cin >> b[i];\\n auto p1 = solve(a), p2 = solve(b);\\n sort((p1).begin(), (p1).end());\\n sort((p2).rbegin(), (p2).rend());\\n int j = 0;\\n multiset> have;\\n fenwick f;\\n f.build(maxN);\\n long long ans = 0;\\n for (auto &[c, ct] : p2) {\\n while (j < n && p1[j].first + c <= x) {\\n have.insert({p1[j].second, p1[j].first});\\n f.upd(p1[j].first,...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Morning desert sun horizon\\n\\nRise above the sands of time...\\n\\nFates Warning, \\\"Exodus\\\"\\n\\nAfter crossing the Windswept Wastes, Ori has finally reached the Windtorn Ruins to find the Heart of the Forest! However, the ancient repository containing this priceless Willow light did not want to open!\\n\\nOri was taken aback, but the Voice of the Forest explained to him that the cunning Gorleks had decided to add protection to the repository.\\n\\nThe Gorleks were very fond of the \\\"string expansion\\\" operation. They were also very fond of increasing subsequences.\\n\\nSuppose a string s_1s_2s_3 … s_n is given. Then its \\\"expansion\\\" is defined as the sequence of strings s_1, s_1 s_2, ..., s_1 s_2 … s_n, s_2, s_2 s_3, ..., s_2 s_3 … s_n, s_3, s_3 s_4, ..., s_{n-1} s_n, s_n. For example, the \\\"expansion\\\" the string 'abcd' will be the following sequence of strings: 'a', 'ab', 'abc', 'abcd', 'b', 'bc', 'bcd', 'c', 'cd', 'd'. \\n\\nTo open the ancient repository, Ori must find the size of the largest increasing subsequence of the \\\"expansion\\\" of the string s. Here, strings are compared lexicographically.\\n\\nHelp Ori with this task!\\n\\nA string a is lexicographically smaller than a string b if and only if one of the following holds:\\n\\n * a is a prefix of b, but a ≠ b;\\n * in the first position where a and b differ, the string a has a letter that appears earlier in the alphabet than the corresponding letter in b.\\n\\nInput\\n\\nEach test contains multiple test cases.\\n\\nThe first line contains one positive integer t (1 ≤ t ≤ 10^3), denoting the number of test cases. Description of the test cases follows.\\n\\nThe first line of each test case contains one positive integer n (1 ≤ n ≤ 5000) — length of the string.\\n\\nThe second line of each test case contains a non-empty string of length n, which consists of lowercase latin letters.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 10^4.\\n\\nOutput\\n\\nFor every test case print one non-negative integer — the answer to the...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint lcp[5042][5042], dp[5042];\\nint main() {\\n int t;\\n cin >> t;\\n while (t--) {\\n int n;\\n cin >> n;\\n string s;\\n cin >> s;\\n for (int i = 0; i <= n; i++) lcp[i][n] = 0;\\n for (int i = n - 1; i >= 0; i--)\\n for (int j = i; j >= 0; j--)\\n if (s[i] == s[j])\\n lcp[j][i] = 1 + lcp[j + 1][i + 1];\\n else\\n lcp[j][i] = 0;\\n int ans = 0;\\n for (int i = 0; i < n; i++) {\\n int il = n - i;\\n dp[i] = il;\\n for (int j = 0; j < i; j++) {\\n int lp = lcp[j][i];\\n char sjlp = s[j + lp];\\n if (i + lp == n) continue;\\n char silp = s[i + lp];\\n if (sjlp < silp) dp[i] = max(dp[i], il - lp + dp[j]);\\n }\\n ans = max(ans, dp[i]);\\n }\\n cout << ans << '\\\\n';\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"\\\"Night gathers, and now my watch begins. It shall not end until my death. I shall take no wife, hold no lands, father no children. I shall wear no crowns and win no glory. I shall live and die at my post. I am the sword in the darkness. I am the watcher on the walls. I am the shield that guards the realms of men. I pledge my life and honor to the Night's Watch, for this night and all the nights to come.\\\" — The Night's Watch oath.\\n\\nWith that begins the watch of Jon Snow. He is assigned the task to support the stewards.\\n\\nThis time he has n stewards with him whom he has to provide support. Each steward has his own strength. Jon Snow likes to support a steward only if there exists at least one steward who has strength strictly less than him and at least one steward who has strength strictly greater than him.\\n\\nCan you find how many stewards will Jon support?\\n\\nInput\\n\\nFirst line consists of a single integer n (1 ≤ n ≤ 105) — the number of stewards with Jon Snow.\\n\\nSecond line consists of n space separated integers a1, a2, ..., an (0 ≤ ai ≤ 109) representing the values assigned to the stewards.\\n\\nOutput\\n\\nOutput a single integer representing the number of stewards which Jon will feed.\\n\\nExamples\\n\\nInput\\n\\n2\\n1 5\\n\\n\\nOutput\\n\\n0\\n\\nInput\\n\\n3\\n1 2 5\\n\\n\\nOutput\\n\\n1\\n\\nNote\\n\\nIn the first sample, Jon Snow cannot support steward with strength 1 because there is no steward with strength less than 1 and he cannot support steward with strength 5 because there is no steward with strength greater than 5.\\n\\nIn the second sample, Jon Snow can support steward with strength 2 because there are stewards with strength less than 2 and greater than 2.\\nSolve the task in PYTHON.\",\"targets\":\"n = int(raw_input())\\nnumbers = sorted(map(int, raw_input().split()))\\nleft, right = 0, 1\\nfor i in range(n - 1):\\n if numbers[i + 1] > numbers[i]:\\n left = i\\n break\\nfor i in range(n - 1):\\n if numbers[n - 1 - i] > numbers[n - 1 - i - 1]:\\n right = n - 1 - i\\n break\\nprint right - left - 1\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"John Smith knows that his son, Thomas Smith, is among the best students in his class and even in his school. After the students of the school took the exams in English, German, Math, and History, a table of results was formed.\\n\\nThere are n students, each of them has a unique id (from 1 to n). Thomas's id is 1. Every student has four scores correspond to his or her English, German, Math, and History scores. The students are given in order of increasing of their ids.\\n\\nIn the table, the students will be sorted by decreasing the sum of their scores. So, a student with the largest sum will get the first place. If two or more students have the same sum, these students will be sorted by increasing their ids. \\n\\nPlease help John find out the rank of his son. \\n\\nInput\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 1000) — the number of students.\\n\\nEach of the next n lines contains four integers a_i, b_i, c_i, and d_i (0≤ a_i, b_i, c_i, d_i≤ 100) — the grades of the i-th student on English, German, Math, and History. The id of the i-th student is equal to i.\\n\\nOutput\\n\\nPrint the rank of Thomas Smith. Thomas's id is 1.\\n\\nExamples\\n\\nInput\\n\\n5\\n100 98 100 100\\n100 100 100 100\\n100 100 99 99\\n90 99 90 100\\n100 98 60 99\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n6\\n100 80 90 99\\n60 60 60 60\\n90 60 100 60\\n60 100 60 80\\n100 100 0 100\\n0 0 0 0\\n\\n\\nOutput\\n\\n1\\n\\nNote\\n\\nIn the first sample, the students got total scores: 398, 400, 398, 379, and 357. Among the 5 students, Thomas and the third student have the second highest score, but Thomas has a smaller id, so his rank is 2.\\n\\nIn the second sample, the students got total scores: 369, 240, 310, 300, 300, and 0. Among the 6 students, Thomas got the highest score, so his rank is 1.\\\":\",\"targets\":\"#include \\nusing namespace std;\\nconst int maxn = 1e5 + 7;\\nconst int INF = 0x3f3f3f3f;\\nconst int M = 1e9 + 7;\\nlong long dp[maxn];\\nint b[maxn];\\nint main() {\\n ios::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n int n, a, b, c, d, sum = 0, t, r = 1;\\n cin >> n;\\n cin >> a >> b >> c >> d;\\n t = a + b + c + d;\\n n--;\\n while (n--) {\\n cin >> a >> b >> c >> d;\\n sum = a + b + c + d;\\n if (t < sum) r++;\\n }\\n cout << r << \\\"\\\\n\\\";\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Mr. Chanek wants to knit a batik, a traditional cloth from Indonesia. The cloth forms a grid a with size n × m. There are k colors, and each cell in the grid can be one of the k colors.\\n\\nDefine a sub-rectangle as an ordered pair of two cells ((x_1, y_1), (x_2, y_2)), denoting the top-left cell and bottom-right cell (inclusively) of a sub-rectangle in a. Two sub-rectangles ((x_1, y_1), (x_2, y_2)) and ((x_3, y_3), (x_4, y_4)) have the same pattern if and only if the following holds: \\n\\n * they have the same width (x_2 - x_1 = x_4 - x_3); \\n * they have the same height (y_2 - y_1 = y_4 - y_3); \\n * for every pair (i, j) where 0 ≤ i ≤ x_2 - x_1 and 0 ≤ j ≤ y_2 - y_1, the color of cells (x_1 + i, y_1 + j) and (x_3 + i, y_3 + j) are equal. \\n\\n\\n\\nCount the number of possible batik color combinations, such that the subrectangles ((a_x, a_y),(a_x + r - 1, a_y + c - 1)) and ((b_x, b_y),(b_x + r - 1, b_y + c - 1)) have the same pattern.\\n\\nOutput the answer modulo 10^9 + 7.\\n\\nInput\\n\\nThe first line contains five integers n, m, k, r, and c (1 ≤ n, m ≤ 10^9, 1 ≤ k ≤ 10^9, 1 ≤ r ≤ min(10^6, n), 1 ≤ c ≤ min(10^6, m)) — the size of the batik, the number of colors, and size of the sub-rectangle.\\n\\nThe second line contains four integers a_x, a_y, b_x, and b_y (1 ≤ a_x, b_x ≤ n, 1 ≤ a_y, b_y ≤ m) — the top-left corners of the first and second sub-rectangle. Both of the sub-rectangles given are inside the grid (1 ≤ a_x + r - 1, b_x + r - 1 ≤ n, 1 ≤ a_y + c - 1, b_y + c - 1 ≤ m).\\n\\nOutput\\n\\nOutput an integer denoting the number of possible batik color combinations modulo 10^9 + 7.\\n\\nExamples\\n\\nInput\\n\\n\\n3 3 2 2 2\\n1 1 2 2\\n\\n\\nOutput\\n\\n\\n32\\n\\n\\nInput\\n\\n\\n4 5 170845 2 2\\n1 4 3 1\\n\\n\\nOutput\\n\\n\\n756680455\\n\\nNote\\n\\nThe following are all 32 possible color combinations in the first example.\\n\\n\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\ntemplate \\ninline void mine(T1 &x, const T2 &y) {\\n if (y < x) x = y;\\n}\\ntemplate \\ninline void maxe(T1 &x, const T2 &y) {\\n if (x < y) x = y;\\n}\\ntemplate \\nostream &operator<<(ostream &os, const vector &b) {\\n for (const auto &k : b) os << k << ' ';\\n return os;\\n}\\ntemplate \\nistream &operator>>(istream &is, vector &b) {\\n for (auto &k : b) is >> k;\\n return is;\\n}\\ntemplate \\nostream &operator<<(ostream &os, const set &b) {\\n for (const auto &k : b) os << k << ' ';\\n return os;\\n}\\ntemplate \\nostream &operator<<(ostream &os, const pair &b) {\\n os << b.first << ' ' << b.second;\\n return os;\\n}\\nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\\nconst long long MOD = 1e9 + 7;\\nnamespace md {\\nlong long mod(long long n) {\\n if (n <= -MOD || n >= MOD) n %= MOD;\\n if (n < 0)\\n return n + MOD;\\n else\\n return n;\\n}\\nlong long add(long long a, long long b) {\\n a += b;\\n if (a >= MOD) return a - MOD;\\n return a;\\n}\\nlong long sub(long long a, long long b) {\\n a -= b;\\n if (a < 0) return a + MOD;\\n return a;\\n}\\nlong long mult(long long a, long long b) { return a * b % MOD; }\\nlong long powmod(long long a, long long p) {\\n if (p == 0) return 1;\\n if (p & 1) return mult(a, powmod(a, p - 1));\\n return powmod(mult(a, a), p \\/ 2);\\n}\\nlong long rev(long long a) { return powmod(a, MOD - 2); }\\n} \\/\\/ namespace md\\nstruct M {\\n long long x;\\n M(long long _x) { x = md::mod(_x); }\\n M() { x = 0; }\\n M operator+(M y) const { return M(md::add(x, y.x)); }\\n M operator-(M y) const { return M(md::sub(x, y.x)); }\\n M operator*(M y) const { return md::mult(x, y.x); }\\n M operator\\/(M y) const { return md::mult(x, md::rev(y.x)); }\\n M operator+(long long y) { return (*this) + M(y); }\\n M operator-(long long y) { return (*this) - M(y); }\\n M operator*(long long y) { return (*this) * M(y); }\\n M operator\\/(long long y) { return (*this) \\/ M(y); }\\n M operator^(long long...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nLord Omkar would like to have a tree with n nodes (3 ≤ n ≤ 10^5) and has asked his disciples to construct the tree. However, Lord Omkar has created m (1 ≤ m < n) restrictions to ensure that the tree will be as heavenly as possible. \\n\\nA tree with n nodes is an connected undirected graph with n nodes and n-1 edges. Note that for any two nodes, there is exactly one simple path between them, where a simple path is a path between two nodes that does not contain any node more than once.\\n\\nHere is an example of a tree: \\n\\n\\n\\nA restriction consists of 3 pairwise distinct integers, a, b, and c (1 ≤ a,b,c ≤ n). It signifies that node b cannot lie on the simple path between node a and node c. \\n\\nCan you help Lord Omkar and become his most trusted disciple? You will need to find heavenly trees for multiple sets of restrictions. It can be shown that a heavenly tree will always exist for any set of restrictions under the given constraints.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^4). Description of the test cases follows.\\n\\nThe first line of each test case contains two integers, n and m (3 ≤ n ≤ 10^5, 1 ≤ m < n), representing the size of the tree and the number of restrictions.\\n\\nThe i-th of the next m lines contains three integers a_i, b_i, c_i (1 ≤ a_i, b_i, c_i ≤ n, a, b, c are distinct), signifying that node b_i cannot lie on the simple path between nodes a_i and c_i. \\n\\nIt is guaranteed that the sum of n across all test cases will not exceed 10^5.\\n\\nOutput\\n\\nFor each test case, output n-1 lines representing the n-1 edges in the tree. On each line, output two integers u and v (1 ≤ u, v ≤ n, u ≠ v) signifying that there is an edge between nodes u and v. Given edges have to form a tree that satisfies Omkar's restrictions.\\n\\nExample\\n\\nInput\\n\\n\\n2\\n7 4\\n1 2 3\\n3 4 5\\n5 6 7\\n6 5 4\\n5 3\\n1 2 3\\n2 3 4\\n3 4 5\\n\\n\\nOutput\\n\\n\\n1 2\\n1 3\\n3 5\\n3 4\\n2 7\\n7 6\\n5 1\\n1 3\\n3 2\\n2 4\\n\\nNote\\n\\nThe output of the first sample case corresponds to the following tree: \\n\\n For the first restriction,...\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int t;\\n cin >> t;\\n while (t--) {\\n int n, m;\\n cin >> n >> m;\\n vector v(n + 1, 0);\\n int i;\\n for (int i = 0; i < m; i++) {\\n int a, b, c;\\n cin >> a >> b >> c;\\n v[b] = 1;\\n }\\n for (i = 1; i <= n; i++)\\n if (!v[i]) break;\\n for (int j = 1; j <= n; j++)\\n if (i != j) cout << i << \\\" \\\" << j << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"There are n candles on a Hanukkah menorah, and some of its candles are initially lit. We can describe which candles are lit with a binary string s, where the i-th candle is lit if and only if s_i=1.\\n\\n\\n\\nInitially, the candle lights are described by a string a. In an operation, you select a candle that is currently lit. By doing so, the candle you selected will remain lit, and every other candle will change (if it was lit, it will become unlit and if it was unlit, it will become lit).\\n\\nYou would like to make the candles look the same as string b. Your task is to determine if it is possible, and if it is, find the minimum number of operations required.\\n\\nInput\\n\\nThe first line contains an integer t (1≤ t≤ 10^4) — the number of test cases. Then t cases follow.\\n\\nThe first line of each test case contains a single integer n (1≤ n≤ 10^5) — the number of candles.\\n\\nThe second line contains a string a of length n consisting of symbols 0 and 1 — the initial pattern of lights.\\n\\nThe third line contains a string b of length n consisting of symbols 0 and 1 — the desired pattern of lights.\\n\\nIt is guaranteed that the sum of n does not exceed 10^5.\\n\\nOutput\\n\\nFor each test case, output the minimum number of operations required to transform a to b, or -1 if it's impossible.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n5\\n11010\\n11010\\n2\\n01\\n11\\n3\\n000\\n101\\n9\\n100010111\\n101101100\\n9\\n001011011\\n011010101\\n\\n\\nOutput\\n\\n\\n0\\n1\\n-1\\n3\\n4\\n\\nNote\\n\\nIn the first test case, the two strings are already equal, so we don't have to perform any operations.\\n\\nIn the second test case, we can perform a single operation selecting the second candle to transform 01 into 11.\\n\\nIn the third test case, it's impossible to perform any operations because there are no lit candles to select.\\n\\nIn the fourth test case, we can perform the following operations to transform a into b: \\n\\n 1. Select the 7-th candle: 100010{\\\\color{red}1}11→ 011101{\\\\color{red} 1}00. \\n 2. Select the 2-nd candle: 0{\\\\color{red} 1}1101100→ 1{\\\\color{red} 1}0010011. \\n 3. Select the 1-st candle: {\\\\color{red}1}10010011→...\\nUsing java can you solve the prior task?\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\n\\npublic class CF1615C extends PrintWriter {\\n\\tCF1615C() { super(System.out); }\\n\\tScanner sc = new Scanner(System.in);\\n\\tpublic static void main(String[] $) {\\n\\t\\tCF1615C o = new CF1615C(); o.main(); o.flush();\\n\\t}\\n\\n\\tstatic final int INF = 0x3f3f3f3f;\\n\\tvoid main() {\\n\\t\\tint t = sc.nextInt();\\n\\t\\twhile (t-- > 0) {\\n\\t\\t\\tint n = sc.nextInt();\\n\\t\\t\\tbyte[] aa = sc.next().getBytes();\\n\\t\\t\\tbyte[] bb = sc.next().getBytes();\\n\\t\\t\\tint n00 = 0, n01 = 0, n10 = 0, n11 = 0;\\n\\t\\t\\tfor (int i = 0; i < n; i++) {\\n\\t\\t\\t\\tint a = aa[i] - '0';\\n\\t\\t\\t\\tint b = bb[i] - '0';\\n\\t\\t\\t\\tif (a == 0 && b == 0)\\n\\t\\t\\t\\t\\tn00++;\\n\\t\\t\\t\\telse if (a == 0 && b == 1)\\n\\t\\t\\t\\t\\tn01++;\\n\\t\\t\\t\\telse if (a == 1 && b == 0)\\n\\t\\t\\t\\t\\tn10++;\\n\\t\\t\\t\\telse\\n\\t\\t\\t\\t\\tn11++;\\n\\t\\t\\t}\\n\\t\\t\\tint ans = INF;\\n\\t\\t\\tif (n10 == n01)\\n\\t\\t\\t\\tans = Math.min(ans, n10 + n01);\\n\\t\\t\\tif (n11 == n00 + 1)\\n\\t\\t\\t\\tans = Math.min(ans, n11 + n00);\\n\\t\\t\\tif (ans == INF)\\n\\t\\t\\t\\tans = -1;\\n\\t\\t\\tprintln(ans);\\n\\t\\t}\\n\\t}\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given array a_1, a_2, …, a_n, consisting of non-negative integers.\\n\\nLet's define operation of \\\"elimination\\\" with integer parameter k (1 ≤ k ≤ n) as follows:\\n\\n * Choose k distinct array indices 1 ≤ i_1 < i_2 < … < i_k ≤ n. \\n * Calculate x = a_{i_1} ~ \\\\& ~ a_{i_2} ~ \\\\& ~ … ~ \\\\& ~ a_{i_k}, where \\\\& denotes the [bitwise AND operation](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#AND) (notes section contains formal definition). \\n * Subtract x from each of a_{i_1}, a_{i_2}, …, a_{i_k}; all other elements remain untouched. \\n\\n\\n\\nFind all possible values of k, such that it's possible to make all elements of array a equal to 0 using a finite number of elimination operations with parameter k. It can be proven that exists at least one possible k for any array a.\\n\\nNote that you firstly choose k and only after that perform elimination operations with value k you've chosen initially.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^4). Description of the test cases follows.\\n\\nThe first line of each test case contains one integer n (1 ≤ n ≤ 200 000) — the length of array a.\\n\\nThe second line of each test case contains n integers a_1, a_2, …, a_n (0 ≤ a_i < 2^{30}) — array a itself.\\n\\nIt's guaranteed that the sum of n over all test cases doesn't exceed 200 000.\\n\\nOutput\\n\\nFor each test case, print all values k, such that it's possible to make all elements of a equal to 0 in a finite number of elimination operations with the given parameter k.\\n\\nPrint them in increasing order.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n4\\n4 4 4 4\\n4\\n13 7 25 19\\n6\\n3 5 3 1 7 1\\n1\\n1\\n5\\n0 0 0 0 0\\n\\n\\nOutput\\n\\n\\n1 2 4\\n1 2\\n1\\n1\\n1 2 3 4 5\\n\\nNote\\n\\nIn the first test case:\\n\\n * If k = 1, we can make four elimination operations with sets of indices \\\\{1\\\\}, \\\\{2\\\\}, \\\\{3\\\\}, \\\\{4\\\\}. Since \\\\& of one element is equal to the element itself, then for each operation x = a_i, so a_i - x = a_i - a_i = 0. \\n * If k = 2, we can make two elimination operations with, for example, sets of indices \\\\{1, 3\\\\} and \\\\{2, 4\\\\}: x = a_1 ~ \\\\& ~ a_3...\",\"targets\":\"#include \\nusing namespace std;\\nconst long long MOD = 1e9 + 7;\\nconst int infi = INT_MAX;\\nconst long long infll = LLONG_MAX;\\nconst long double PI = 3.1415926535897932384626;\\nlong long power(long long a, long long b) {\\n long long ans = 1;\\n while (b) {\\n if (b & 1) {\\n ans = (ans * a) % MOD;\\n }\\n a = (a * a) % MOD;\\n b = b >> 1;\\n }\\n return ans;\\n}\\nvoid solve(int test_case) {\\n long long n;\\n cin >> n;\\n vector a(n);\\n for (int i = 0; i < n; i++) {\\n cin >> a[i];\\n }\\n vector bits(32, 0);\\n for (int i = 0; i < 32; i++) {\\n for (int j = 0; j < n; j++) {\\n if (a[j] & (1 << i)) bits[i]++;\\n }\\n }\\n vector ans;\\n for (int i = 1; i <= n; i++) {\\n int ok = 1;\\n for (int j = 0; j < 32; j++) {\\n if (bits[j] % i != 0) {\\n ok = 0;\\n break;\\n }\\n }\\n if (ok) ans.push_back(i);\\n }\\n for (auto itr : ans) {\\n cout << itr << \\\" \\\";\\n }\\n cout << endl;\\n}\\nint main() {\\n ios_base ::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n int tc = 1;\\n cin >> tc;\\n while (tc--) solve(tc);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"There are n candles on a Hanukkah menorah, and some of its candles are initially lit. We can describe which candles are lit with a binary string s, where the i-th candle is lit if and only if s_i=1.\\n\\n\\n\\nInitially, the candle lights are described by a string a. In an operation, you select a candle that is currently lit. By doing so, the candle you selected will remain lit, and every other candle will change (if it was lit, it will become unlit and if it was unlit, it will become lit).\\n\\nYou would like to make the candles look the same as string b. Your task is to determine if it is possible, and if it is, find the minimum number of operations required.\\n\\nInput\\n\\nThe first line contains an integer t (1≤ t≤ 10^4) — the number of test cases. Then t cases follow.\\n\\nThe first line of each test case contains a single integer n (1≤ n≤ 10^5) — the number of candles.\\n\\nThe second line contains a string a of length n consisting of symbols 0 and 1 — the initial pattern of lights.\\n\\nThe third line contains a string b of length n consisting of symbols 0 and 1 — the desired pattern of lights.\\n\\nIt is guaranteed that the sum of n does not exceed 10^5.\\n\\nOutput\\n\\nFor each test case, output the minimum number of operations required to transform a to b, or -1 if it's impossible.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n5\\n11010\\n11010\\n2\\n01\\n11\\n3\\n000\\n101\\n9\\n100010111\\n101101100\\n9\\n001011011\\n011010101\\n\\n\\nOutput\\n\\n\\n0\\n1\\n-1\\n3\\n4\\n\\nNote\\n\\nIn the first test case, the two strings are already equal, so we don't have to perform any operations.\\n\\nIn the second test case, we can perform a single operation selecting the second candle to transform 01 into 11.\\n\\nIn the third test case, it's impossible to perform any operations because there are no lit candles to select.\\n\\nIn the fourth test case, we can perform the following operations to transform a into b: \\n\\n 1. Select the 7-th candle: 100010{\\\\color{red}1}11→ 011101{\\\\color{red} 1}00. \\n 2. Select the 2-nd candle: 0{\\\\color{red} 1}1101100→ 1{\\\\color{red} 1}0010011. \\n 3. Select the 1-st candle: {\\\\color{red}1}10010011→...\\nSolve the task in JAVA.\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\npublic class C {\\n\\n\\tpublic static void main(String[] args) {\\n\\t\\tFastScanner sc = new FastScanner();\\n\\t\\tint T = sc.nextInt();\\n\\t\\twhile(T-->0) {\\n\\t\\t\\tint n = sc.nextInt();\\n\\t\\t\\tchar[] s = new char[n];\\n\\t\\t\\tchar[] t = new char[n];\\n\\t\\t\\ts = sc.next().toCharArray();\\n\\t\\t\\tt = sc.next().toCharArray();\\n\\t\\t\\tint a = 0, b = 0, c = 0, d = 0;\\n\\t\\t\\tfor(int i = 0; i < n; i++) {\\n\\t\\t\\t\\tif(s[i] == '0' && t[i] == '0') a++;\\n\\t\\t\\t\\tif(s[i] == '1' && t[i] == '0') b++;\\n\\t\\t\\t\\tif(s[i] == '0' && t[i] == '1') c++;\\n\\t\\t\\t\\tif(s[i] == '1' && t[i] == '1') d++;\\n\\t\\t\\t}\\n\\t\\t\\tint res = Integer.MAX_VALUE;\\n\\t\\t\\tif(b == c || b+1 == c) {\\n\\t\\t\\t\\tif((b + c) % 2 == 0) {\\n\\t\\t\\t\\t\\tres = Math.min(res, b + c);\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\tif(a == d || a+1 == d) {\\n\\t\\t\\t\\tif((a + d) % 2 == 1) {\\n\\t\\t\\t\\t\\tres = Math.min(res, a + d);\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\tif(res == Integer.MAX_VALUE) System.out.println(-1);\\n\\t\\t\\telse System.out.println(res);\\n\\t\\t}\\n\\t}\\n\\t\\n\\tstatic class FastScanner {\\n\\t\\tpublic BufferedReader reader;\\n\\t\\tpublic StringTokenizer tokenizer;\\n\\t\\tpublic FastScanner() {\\n\\t\\t\\treader = new BufferedReader(new InputStreamReader(System.in), 32768);\\n\\t\\t\\ttokenizer = null;\\n\\t\\t}\\n\\t\\tpublic String next() {\\n\\t\\t\\twhile (tokenizer == null || !tokenizer.hasMoreTokens()) {\\n\\t\\t\\t\\ttry {\\n\\t\\t\\t\\t\\ttokenizer = new StringTokenizer(reader.readLine());\\n\\t\\t\\t\\t} catch (IOException e) {\\n\\t\\t\\t\\t\\tthrow new RuntimeException(e);\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\treturn tokenizer.nextToken();\\n\\t\\t}\\n\\t\\tpublic int nextInt() {\\n\\t\\t\\treturn Integer.parseInt(next());\\n\\t\\t}\\n\\t\\tpublic long nextLong() {\\n\\t\\t\\treturn Long.parseLong(next());\\n\\t\\t}\\n\\t\\tpublic double nextDouble() {\\n\\t\\t\\treturn Double.parseDouble(next());\\n\\t\\t}\\n\\t\\tpublic String nextLine() {\\n\\t\\t\\ttry {\\n\\t\\t\\t\\treturn reader.readLine();\\n\\t\\t\\t} catch(IOException e) {\\n\\t\\t\\t\\tthrow new RuntimeException(e);\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given a book with n chapters.\\n\\nEach chapter has a specified list of other chapters that need to be understood in order to understand this chapter. To understand a chapter, you must read it after you understand every chapter on its required list.\\n\\nCurrently you don't understand any of the chapters. You are going to read the book from the beginning till the end repeatedly until you understand the whole book. Note that if you read a chapter at a moment when you don't understand some of the required chapters, you don't understand this chapter.\\n\\nDetermine how many times you will read the book to understand every chapter, or determine that you will never understand every chapter no matter how many times you read the book.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 2⋅10^4).\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 2⋅10^5) — number of chapters.\\n\\nThen n lines follow. The i-th line begins with an integer k_i (0 ≤ k_i ≤ n-1) — number of chapters required to understand the i-th chapter. Then k_i integers a_{i,1}, a_{i,2}, ..., a_{i, k_i} (1 ≤ a_{i, j} ≤ n, a_{i, j} ≠ i, a_{i, j} ≠ a_{i, l} for j ≠ l) follow — the chapters required to understand the i-th chapter.\\n\\nIt is guaranteed that the sum of n and sum of k_i over all testcases do not exceed 2⋅10^5.\\n\\nOutput\\n\\nFor each test case, if the entire book can be understood, print how many times you will read it, otherwise print -1.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n4\\n1 2\\n0\\n2 1 4\\n1 2\\n5\\n1 5\\n1 1\\n1 2\\n1 3\\n1 4\\n5\\n0\\n0\\n2 1 2\\n1 2\\n2 2 1\\n4\\n2 2 3\\n0\\n0\\n2 3 2\\n5\\n1 2\\n1 3\\n1 4\\n1 5\\n0\\n\\n\\nOutput\\n\\n\\n2\\n-1\\n1\\n2\\n5\\n\\nNote\\n\\nIn the first example, we will understand chapters \\\\{2, 4\\\\} in the first reading and chapters \\\\{1, 3\\\\} in the second reading of the book.\\n\\nIn the second example, every chapter requires the understanding of some other chapter, so it is impossible to understand the book.\\n\\nIn the third example, every chapter requires only chapters that appear earlier in the book, so we can understand everything in one...\\nSolve the task in PYTHON3.\",\"targets\":\"import os, sys\\nfrom io import BytesIO, IOBase\\nimport operator as op\\nfrom bisect import *\\nfrom itertools import chain, repeat, starmap\\nfrom functools import reduce\\n\\n\\nclass SortedList():\\n \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\\"\\\"\\\"\\n DEFAULT_LOAD_FACTOR = 500\\n\\n def __init__(self, iterable=None):\\n \\\"\\\"\\\"Initialize sorted list instance.\\\"\\\"\\\"\\n self._len = 0\\n self._load = self.DEFAULT_LOAD_FACTOR\\n self._lists = []\\n self._maxes = []\\n self._index = []\\n self._offset = 0\\n if iterable is not None:\\n self.update(iterable)\\n\\n def clear(self):\\n \\\"\\\"\\\"Remove all values from sorted list.\\\"\\\"\\\"\\n self._len = 0\\n del self._lists[:]\\n del self._maxes[:]\\n del self._index[:]\\n self._offset = 0\\n\\n def add(self, value):\\n \\\"\\\"\\\"Add `value` to sorted list.\\\"\\\"\\\"\\n _lists = self._lists\\n _maxes = self._maxes\\n if _maxes:\\n pos = bisect_right(_maxes, value)\\n if pos == len(_maxes):\\n _lists[pos - 1].append(value)\\n _maxes[pos - 1] = value\\n else:\\n insort(_lists[pos], value)\\n self._expand(pos)\\n else:\\n _lists.append([value])\\n _maxes.append(value)\\n self._len += 1\\n\\n def _expand(self, pos):\\n \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\\"\\\"\\\"\\n _load = self._load\\n _lists = self._lists\\n _index = self._index\\n\\n if len(_lists[pos]) > (_load << 1):\\n _maxes = self._maxes\\n _lists_pos = _lists[pos]\\n half = _lists_pos[_load:]\\n del _lists_pos[_load:]\\n _maxes[pos] = _lists_pos[-1]\\n _lists.insert(pos + 1, half)\\n _maxes.insert(pos + 1, half[-1])\\n del _index[:]\\n else:\\n if _index:\\n child = self._offset + pos\\n while child:\\n _index[child] += 1\\n child = (child - 1) >> 1\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Polycarp has come up with a new game to play with you. He calls it \\\"A missing bigram\\\".\\n\\nA bigram of a word is a sequence of two adjacent letters in it.\\n\\nFor example, word \\\"abbaaba\\\" contains bigrams \\\"ab\\\", \\\"bb\\\", \\\"ba\\\", \\\"aa\\\", \\\"ab\\\" and \\\"ba\\\".\\n\\nThe game goes as follows. First, Polycarp comes up with a word, consisting only of lowercase letters 'a' and 'b'. Then, he writes down all its bigrams on a whiteboard in the same order as they appear in the word. After that, he wipes one of them off the whiteboard.\\n\\nFinally, Polycarp invites you to guess what the word that he has come up with was.\\n\\nYour goal is to find any word such that it's possible to write down all its bigrams and remove one of them, so that the resulting sequence of bigrams is the same as the one Polycarp ended up with.\\n\\nThe tests are generated in such a way that the answer exists. If there are multiple answers, you can print any of them.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 2000) — the number of testcases.\\n\\nThe first line of each testcase contains a single integer n (3 ≤ n ≤ 100) — the length of the word Polycarp has come up with.\\n\\nThe second line of each testcase contains n-2 bigrams of that word, separated by a single space. Each bigram consists of two letters, each of them is either 'a' or 'b'.\\n\\nAdditional constraint on the input: there exists at least one string such that it is possible to write down all its bigrams, except one, so that the resulting sequence is the same as the sequence in the input. In other words, the answer exists.\\n\\nOutput\\n\\nFor each testcase print a word, consisting of n letters, each of them should be either 'a' or 'b'. It should be possible to write down all its bigrams and remove one of them, so that the resulting sequence of bigrams is the same as the one Polycarp ended up with.\\n\\nThe tests are generated in such a way that the answer exists. If there are multiple answers, you can print any of them. \\n\\nExample\\n\\nInput\\n\\n\\n4\\n7\\nab bb ba aa ba\\n7\\nab ba aa ab ba\\n3\\naa\\n5\\nbb ab...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int tc;\\n cin >> tc;\\n while (tc--) {\\n int n;\\n cin >> n;\\n bool test = 0;\\n string s;\\n char prev;\\n vector v;\\n for (long long i = 0; i < n - 2; i++) {\\n cin >> s;\\n if (!test) {\\n v.push_back(s[0]);\\n v.push_back(s[1]);\\n prev = s[1];\\n test = 1;\\n } else {\\n if (s[0] != prev) {\\n v.push_back(s[0]);\\n v.push_back(s[1]);\\n } else\\n v.push_back(s[1]);\\n prev = s[1];\\n }\\n }\\n int nb = 0;\\n for (auto it : v) {\\n cout << it;\\n nb++;\\n }\\n if (nb != n) cout << \\\"b\\\";\\n cout << '\\\\n';\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Monocarp wrote down two numbers on a whiteboard. Both numbers follow a specific format: a positive integer x with p zeros appended to its end.\\n\\nNow Monocarp asks you to compare these two numbers. Can you help him?\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.\\n\\nThe first line of each testcase contains two integers x_1 and p_1 (1 ≤ x_1 ≤ 10^6; 0 ≤ p_1 ≤ 10^6) — the description of the first number.\\n\\nThe second line of each testcase contains two integers x_2 and p_2 (1 ≤ x_2 ≤ 10^6; 0 ≤ p_2 ≤ 10^6) — the description of the second number.\\n\\nOutput\\n\\nFor each testcase print the result of the comparison of the given two numbers. If the first number is smaller than the second one, print '<'. If the first number is greater than the second one, print '>'. If they are equal, print '='.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n2 1\\n19 0\\n10 2\\n100 1\\n1999 0\\n2 3\\n1 0\\n1 0\\n99 0\\n1 2\\n\\n\\nOutput\\n\\n\\n>\\n=\\n<\\n=\\n<\\n\\nNote\\n\\nThe comparisons in the example are: 20 > 19, 1000 = 1000, 1999 < 2000, 1 = 1, 99 < 100.\\nUsing java can you solve the prior task?\",\"targets\":\"import java.math.BigInteger;\\nimport java.util.Arrays;\\nimport java.util.Scanner;\\n\\npublic class LongComparison {\\n public static void main(String[] args) {\\n Scanner scanner = new Scanner(System.in);\\n int t = scanner.nextInt();\\n while (t-->0){\\n\\/\\/ int k = 2;\\n BigInteger num1 = null;\\n BigInteger num2 = null;\\n\\/\\/ while (k-->0){\\n int n1 = scanner.nextInt();\\n int p1 = scanner.nextInt();\\n int n2 = scanner.nextInt();\\n int p2 = scanner.nextInt();\\n\\n if(p1 == p2){\\n if(n1 < n2)\\n System.out.println(\\\"<\\\");\\n else if(n1>n2)\\n System.out.println(\\\">\\\");\\n else\\n System.out.println(\\\"=\\\");\\n }else{\\n while (n1 <= 1000000){\\n if (p1 == 0)\\n break;\\n n1 *= 10;\\n p1--;\\n }\\n\\n while (n2 <= 1000000){\\n if (p2 == 0)\\n break;\\n n2 *= 10;\\n p2--;\\n }\\n\\n if(p1 > p2){\\n System.out.println(\\\">\\\");\\n }else if(p1 < p2){\\n System.out.println(\\\"<\\\");\\n }else{\\n if(n1 < n2)\\n System.out.println(\\\"<\\\");\\n else if(n1 > n2)\\n System.out.println(\\\">\\\");\\n else\\n System.out.println(\\\"=\\\");\\n }\\n\\n }\\n\\n\\/\\/ char[] zeros = new char[p];\\n\\/\\/ Arrays.fill(zeros,'0');\\n\\/\\/ BigInteger num = new BigInteger(n + String.valueOf(zeros));\\n\\/\\/ if (k == 1){\\n\\/\\/ num1 = num;\\n\\/\\/ }\\n\\/\\/ num2 =...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"\\n\\nMatryoshka is a wooden doll in the shape of a female figure and is a typical Russian folk craft. Matryoshka has a nested structure in which smaller dolls are contained inside a large doll, and is composed of multiple dolls of different sizes. In order to have such a nested structure, the body of each doll has a tubular structure that can be divided into upper and lower parts. Matryoshka dolls are handmade by craftsmen, so each doll is unique and extremely valuable in the world.\\n\\nBrothers Ichiro and Jiro loved to play with matryoshka dolls, and each had a pair of matryoshka dolls. Ichiro's matryoshka is made up of n dolls, and Jiro's matryoshka is made up of m dolls.\\n\\nOne day, curious Ichiro wondered if he could combine the dolls contained in these two pairs of matryoshka dolls to create a new matryoshka doll containing more dolls. In other words, I tried to make a pair of matryoshka dolls consisting of k dolls using n + m dolls. If k can be made larger than the larger of n and m, Ichiro's purpose will be achieved.\\n\\nThe two brothers got along well and wondered how to combine the dolls to maximize the value of k. But for the two younger ones, the problem is so difficult that you, older, decided to program to help your brothers.\\n\\nCreate a program that inputs the information of the matryoshka dolls of Ichiro and Jiro and outputs the number k of the dolls that the new matryoshka contains. No doll of the same size exists. Also, if we consider a doll to be a cylinder with a height h and a radius r, a doll with a height h and a radius r can contain a doll with a height x radius y that satisfies x \\nusing namespace std;\\n\\ntemplate inline void chmax(T &a, const T &b) { if(a < b) a = b; }\\n\\nvoid input_dolls(vector> &dolls, int n) {\\n\\tfor(int i = 0; i < n; ++i) {\\n\\t\\tint h, r;\\n\\t\\tcin >> h >> r;\\n\\t\\tdolls.emplace_back(h, r);\\n\\t}\\n}\\n\\nint main() {\\n\\tcin.tie(nullptr);\\n\\tios::sync_with_stdio(false);\\n\\n\\tfor(int n; cin >> n && n;) {\\n\\t\\tvector> dolls;\\n\\t\\tinput_dolls(dolls, n);\\n\\n\\t\\tint m;\\n\\t\\tcin >> m;\\n\\t\\tinput_dolls(dolls, m);\\n\\n\\t\\tsort(dolls.begin(), dolls.end());\\n\\n\\t\\tint prev_h = -1;\\n\\t\\tvector dp(1000, 0);\\n\\t\\tvector tmp(dp);\\n\\n\\t\\tfor(const auto &doll : dolls) {\\n\\t\\t\\tconst int h = doll.first;\\n\\t\\t\\tconst int r = doll.second;\\n\\n\\t\\t\\tif(prev_h < h) {\\n\\t\\t\\t\\ttmp = dp;\\n\\t\\t\\t\\tprev_h = h;\\n\\t\\t\\t}\\n\\n\\t\\t\\tconst int num = *max_element(tmp.begin(), tmp.begin() + r);\\n\\t\\t\\tchmax(dp[r], num + 1);\\n\\t\\t}\\n\\n\\t\\tcout << *max_element(dp.begin(), dp.end()) << endl;\\n\\t}\\n\\n\\treturn EXIT_SUCCESS;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Anton likes to play chess, and so does his friend Danik.\\n\\nOnce they have played n games in a row. For each game it's known who was the winner — Anton or Danik. None of the games ended with a tie.\\n\\nNow Anton wonders, who won more games, he or Danik? Help him determine this.\\n\\nInput\\n\\nThe first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of games played.\\n\\nThe second line contains a string s, consisting of n uppercase English letters 'A' and 'D' — the outcome of each of the games. The i-th character of the string is equal to 'A' if the Anton won the i-th game and 'D' if Danik won the i-th game.\\n\\nOutput\\n\\nIf Anton won more games than Danik, print \\\"Anton\\\" (without quotes) in the only line of the output.\\n\\nIf Danik won more games than Anton, print \\\"Danik\\\" (without quotes) in the only line of the output.\\n\\nIf Anton and Danik won the same number of games, print \\\"Friendship\\\" (without quotes).\\n\\nExamples\\n\\nInput\\n\\n6\\nADAAAA\\n\\n\\nOutput\\n\\nAnton\\n\\n\\nInput\\n\\n7\\nDDDAADA\\n\\n\\nOutput\\n\\nDanik\\n\\n\\nInput\\n\\n6\\nDADADA\\n\\n\\nOutput\\n\\nFriendship\\n\\nNote\\n\\nIn the first sample, Anton won 6 games, while Danik — only 1. Hence, the answer is \\\"Anton\\\".\\n\\nIn the second sample, Anton won 3 games and Danik won 4 games, so the answer is \\\"Danik\\\".\\n\\nIn the third sample, both Anton and Danik won 3 games and the answer is \\\"Friendship\\\".\\nUsing python3 can you solve the prior task?\",\"targets\":\"n = int(input())\\ns = input()\\nanton = []\\ndanik = []\\nfor i in s:\\n if i == 'A':\\n anton.append(i)\\n else:\\n danik.append(i)\\nif len(anton) > len(danik):\\n print('Anton')\\nelif len(anton) < len(danik):\\n print('Danik')\\nelse:\\n print('Friendship')\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Polycarp must pay exactly n burles at the checkout. He has coins of two nominal values: 1 burle and 2 burles. Polycarp likes both kinds of coins equally. So he doesn't want to pay with more coins of one type than with the other.\\n\\nThus, Polycarp wants to minimize the difference between the count of coins of 1 burle and 2 burles being used. Help him by determining two non-negative integer values c_1 and c_2 which are the number of coins of 1 burle and 2 burles, respectively, so that the total value of that number of coins is exactly n (i. e. c_1 + 2 ⋅ c_2 = n), and the absolute value of the difference between c_1 and c_2 is as little as possible (i. e. you must minimize |c_1-c_2|).\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10^4) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one line. This line contains one integer n (1 ≤ n ≤ 10^9) — the number of burles to be paid by Polycarp.\\n\\nOutput\\n\\nFor each test case, output a separate line containing two integers c_1 and c_2 (c_1, c_2 ≥ 0) separated by a space where c_1 is the number of coins of 1 burle and c_2 is the number of coins of 2 burles. If there are multiple optimal solutions, print any one.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n1000\\n30\\n1\\n32\\n1000000000\\n5\\n\\n\\nOutput\\n\\n\\n334 333\\n10 10\\n1 0\\n10 11\\n333333334 333333333\\n1 2\\n\\nNote\\n\\nThe answer for the first test case is \\\"334 333\\\". The sum of the nominal values of all coins is 334 ⋅ 1 + 333 ⋅ 2 = 1000, whereas |334 - 333| = 1. One can't get the better value because if |c_1 - c_2| = 0, then c_1 = c_2 and c_1 ⋅ 1 + c_1 ⋅ 2 = 1000, but then the value of c_1 isn't an integer.\\n\\nThe answer for the second test case is \\\"10 10\\\". The sum of the nominal values is 10 ⋅ 1 + 10 ⋅ 2 = 30 and |10 - 10| = 0, whereas there's no number having an absolute value less than 0.\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nint which_coin_more(int n) { return (n % 3); }\\nvoid solve() {\\n int n;\\n cin >> n;\\n int a[2] = {n \\/ 3, n \\/ 3};\\n if (which_coin_more(n) == 1)\\n a[0]++;\\n else if (which_coin_more(n) == 2)\\n a[1]++;\\n cout << a[0] << \\\" \\\" << a[1] << \\\"\\\\n\\\";\\n}\\nint main() {\\n cin.tie(0)->sync_with_stdio(0);\\n cin.exceptions(cin.failbit);\\n int n;\\n cin >> n;\\n while (n--) {\\n solve();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A and B are preparing themselves for programming contests.\\n\\nAn important part of preparing for a competition is sharing programming knowledge from the experienced members to those who are just beginning to deal with the contests. Therefore, during the next team training A decided to make teams so that newbies are solving problems together with experienced participants.\\n\\nA believes that the optimal team of three people should consist of one experienced participant and two newbies. Thus, each experienced participant can share the experience with a large number of people.\\n\\nHowever, B believes that the optimal team should have two experienced members plus one newbie. Thus, each newbie can gain more knowledge and experience.\\n\\nAs a result, A and B have decided that all the teams during the training session should belong to one of the two types described above. Furthermore, they agree that the total number of teams should be as much as possible.\\n\\nThere are n experienced members and m newbies on the training session. Can you calculate what maximum number of teams can be formed?\\n\\nInput\\n\\nThe first line contains two integers n and m (0 ≤ n, m ≤ 5·105) — the number of experienced participants and newbies that are present at the training session. \\n\\nOutput\\n\\nPrint the maximum number of teams that can be formed.\\n\\nExamples\\n\\nInput\\n\\n2 6\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n4 5\\n\\n\\nOutput\\n\\n3\\n\\nNote\\n\\nLet's represent the experienced players as XP and newbies as NB.\\n\\nIn the first test the teams look as follows: (XP, NB, NB), (XP, NB, NB).\\n\\nIn the second test sample the teams look as follows: (XP, NB, NB), (XP, NB, NB), (XP, XP, NB).\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int n, m, c = 0;\\n cin >> n >> m;\\n while (true) {\\n if (n == 0 || m == 0) break;\\n if (n + m < 3) break;\\n if (n >= m) {\\n n = n - 2;\\n m = m - 1;\\n } else {\\n m = m - 2;\\n n = n - 1;\\n }\\n c++;\\n }\\n cout << c << endl;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"It is the easy version of the problem. The only difference is that in this version n = 1.\\n\\nIn the cinema seats can be represented as the table with n rows and m columns. The rows are numbered with integers from 1 to n. The seats in each row are numbered with consecutive integers from left to right: in the k-th row from m (k - 1) + 1 to m k for all rows 1 ≤ k ≤ n.\\n\\n1| 2| ⋅⋅⋅| m - 1| m \\n---|---|---|---|--- \\nm + 1| m + 2| ⋅⋅⋅| 2 m - 1| 2 m \\n2m + 1| 2m + 2| ⋅⋅⋅| 3 m - 1| 3 m \\n\\\\vdots| \\\\vdots| \\\\ddots| \\\\vdots| \\\\vdots \\nm (n - 1) + 1| m (n - 1) + 2| ⋅⋅⋅| n m - 1| n m \\nThe table with seats indices\\n\\nThere are nm people who want to go to the cinema to watch a new film. They are numbered with integers from 1 to nm. You should give exactly one seat to each person.\\n\\nIt is known, that in this cinema as lower seat index you have as better you can see everything happening on the screen. i-th person has the level of sight a_i. Let's define s_i as the seat index, that will be given to i-th person. You want to give better places for people with lower sight levels, so for any two people i, j such that a_i < a_j it should be satisfied that s_i < s_j.\\n\\nAfter you will give seats to all people they will start coming to their seats. In the order from 1 to nm, each person will enter the hall and sit in their seat. To get to their place, the person will go to their seat's row and start moving from the first seat in this row to theirs from left to right. While moving some places will be free, some will be occupied with people already seated. The inconvenience of the person is equal to the number of occupied seats he or she will go through.\\n\\nLet's consider an example: m = 5, the person has the seat 4 in the first row, the seats 1, 3, 5 in the first row are already occupied, the seats 2 and 4 are free. The inconvenience of this person will be 2, because he will go through occupied seats 1 and 3.\\n\\nFind the minimal total inconvenience (the sum of inconveniences of all people), that is possible to have by giving places for all people...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nlong long n, m;\\ntypedef struct node {\\n long long val, idx;\\n} node;\\nnode a[(int)3e2 + 10];\\nmap mp;\\nbool visited[(int)3e2 + 10];\\nbool cmp(node a, node b) {\\n if (a.val == b.val) {\\n return a.idx > b.idx;\\n }\\n return a.val < b.val;\\n}\\nint main() {\\n int t;\\n cin.tie(0);\\n cin >> t;\\n while (t--) {\\n mp.clear();\\n cin >> n >> m;\\n for (long long i = 1; i <= m; i++) {\\n cin >> a[i].val;\\n a[i].idx = i;\\n mp[a[i].val]++;\\n }\\n long long ans = 0;\\n memset(visited, 0, sizeof(visited));\\n for (long long i = 1; i <= m; i++) {\\n long long cnt = 0;\\n for (long long j = i + 1; j <= m; j++) {\\n if (a[j].val > a[i].val) {\\n cnt++;\\n }\\n }\\n long long idx;\\n long long tmp = 0;\\n for (long long k = m; k >= 1 && tmp <= cnt; k--) {\\n if (!visited[k]) {\\n tmp++;\\n }\\n idx = k;\\n }\\n for (long long j = idx; j >= 1; j--) {\\n if (visited[j]) {\\n continue;\\n }\\n for (long long k = 1; k < j; k++) {\\n if (visited[k]) {\\n ans++;\\n }\\n }\\n visited[j] = true;\\n break;\\n }\\n }\\n cout << ans << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alyona's mother wants to present an array of n non-negative integers to Alyona. The array should be special. \\n\\nAlyona is a capricious girl so after she gets the array, she inspects m of its subarrays. Subarray is a set of some subsequent elements of the array. The i-th subarray is described with two integers li and ri, and its elements are a[li], a[li + 1], ..., a[ri].\\n\\nAlyona is going to find mex for each of the chosen subarrays. Among these m mexes the girl is going to find the smallest. She wants this minimum mex to be as large as possible. \\n\\nYou are to find an array a of n elements so that the minimum mex among those chosen by Alyona subarrays is as large as possible.\\n\\nThe mex of a set S is a minimum possible non-negative integer that is not in S.\\n\\nInput\\n\\nThe first line contains two integers n and m (1 ≤ n, m ≤ 105).\\n\\nThe next m lines contain information about the subarrays chosen by Alyona. The i-th of these lines contains two integers li and ri (1 ≤ li ≤ ri ≤ n), that describe the subarray a[li], a[li + 1], ..., a[ri].\\n\\nOutput\\n\\nIn the first line print single integer — the maximum possible minimum mex.\\n\\nIn the second line print n integers — the array a. All the elements in a should be between 0 and 109.\\n\\nIt is guaranteed that there is an optimal answer in which all the elements in a are between 0 and 109.\\n\\nIf there are multiple solutions, print any of them.\\n\\nExamples\\n\\nInput\\n\\n5 3\\n1 3\\n2 5\\n4 5\\n\\n\\nOutput\\n\\n2\\n1 0 2 1 0\\n\\n\\nInput\\n\\n4 2\\n1 4\\n2 4\\n\\n\\nOutput\\n\\n3\\n5 2 0 1\\n\\nNote\\n\\nThe first example: the mex of the subarray (1, 3) is equal to 3, the mex of the subarray (2, 5) is equal to 3, the mex of the subarray (4, 5) is equal to 2 as well, thus the minumal mex among the subarrays chosen by Alyona is equal to 2.\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n ios::sync_with_stdio(false);\\n long long int N, M;\\n cin >> N >> M;\\n long long int w = (1ll << 62);\\n for (long long int i = (0); i < (long long int)(M); ++i) {\\n long long int a, b;\\n cin >> a >> b;\\n a--;\\n long long int ww = b - a;\\n if (ww < w) {\\n w = ww;\\n }\\n }\\n vector res(N);\\n long long int idx = 0;\\n for (long long int i = (0); i < (long long int)(N); ++i) {\\n res[i] = idx;\\n idx++;\\n if (idx == w) idx = 0;\\n }\\n cout << w << endl;\\n for (long long int i = (0); i < (long long int)(N); ++i)\\n cout << res[i] << ' ';\\n cout << endl;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alex decided to go on a touristic trip over the country.\\n\\nFor simplicity let's assume that the country has n cities and m bidirectional roads connecting them. Alex lives in city s and initially located in it. To compare different cities Alex assigned each city a score w_i which is as high as interesting city seems to Alex.\\n\\nAlex believes that his trip will be interesting only if he will not use any road twice in a row. That is if Alex came to city v from city u, he may choose as the next city in the trip any city connected with v by the road, except for the city u.\\n\\nYour task is to help Alex plan his city in a way that maximizes total score over all cities he visited. Note that for each city its score is counted at most once, even if Alex been there several times during his trip.\\n\\nInput\\n\\nFirst line of input contains two integers n and m, (1 ≤ n ≤ 2 ⋅ 10^5, 0 ≤ m ≤ 2 ⋅ 10^5) which are numbers of cities and roads in the country.\\n\\nSecond line contains n integers w_1, w_2, …, w_n (0 ≤ w_i ≤ 10^9) which are scores of all cities.\\n\\nThe following m lines contain description of the roads. Each of these m lines contains two integers u and v (1 ≤ u, v ≤ n) which are cities connected by this road.\\n\\nIt is guaranteed that there is at most one direct road between any two cities, no city is connected to itself by the road and, finally, it is possible to go from any city to any other one using only roads.\\n\\nThe last line contains single integer s (1 ≤ s ≤ n), which is the number of the initial city.\\n\\nOutput\\n\\nOutput single integer which is the maximum possible sum of scores of visited cities.\\n\\nExamples\\n\\nInput\\n\\n\\n5 7\\n2 2 8 6 9\\n1 2\\n1 3\\n2 4\\n3 2\\n4 5\\n2 5\\n1 5\\n2\\n\\n\\nOutput\\n\\n\\n27\\n\\n\\nInput\\n\\n\\n10 12\\n1 7 1 9 3 3 6 30 1 10\\n1 2\\n1 3\\n3 5\\n5 7\\n2 3\\n5 4\\n6 9\\n4 6\\n3 7\\n6 8\\n9 4\\n9 10\\n6\\n\\n\\nOutput\\n\\n\\n61\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.io.OutputStream;\\nimport java.io.IOException;\\nimport java.io.InputStream;\\nimport java.io.OutputStream;\\nimport java.io.PrintWriter;\\nimport java.util.Arrays;\\nimport java.util.Iterator;\\nimport java.io.BufferedWriter;\\nimport java.util.InputMismatchException;\\nimport java.util.Random;\\nimport java.io.IOException;\\nimport java.io.Writer;\\nimport java.io.OutputStreamWriter;\\nimport java.util.NoSuchElementException;\\nimport java.io.InputStream;\\n\\n\\/**\\n * Built using CHelper plug-in\\n * Actual solution is at the top\\n *\\n * @author aryssoncf\\n *\\/\\npublic class Main {\\n public static void main(String[] args) {\\n InputStream inputStream = System.in;\\n OutputStream outputStream = System.out;\\n InputReader in = new InputReader(inputStream);\\n OutputWriter out = new OutputWriter(outputStream);\\n ETourism solver = new ETourism();\\n solver.solve(1, in, out);\\n out.close();\\n }\\n\\n static class ETourism {\\n public void solve(int testNumber, InputReader in, OutputWriter out) {\\n int n = in.readInt(), m = in.readInt();\\n int[] W = in.readIntArray(n);\\n int[] U = new int[m], V = new int[m];\\n in.readIntArrays(U, V);\\n MiscUtils.decreaseByOne(U, V);\\n IntSet[] graph = new IntSet[n];\\n Arrays.setAll(graph, i -> new IntHashSet());\\n for (int i = 0; i < m; i++) {\\n graph[U[i]].add(V[i]);\\n graph[V[i]].add(U[i]);\\n }\\n int s = in.readInt() - 1;\\n long res = ArrayUtils.sumArray(W) - bfs(graph, s, W);\\n out.printLine(res);\\n }\\n\\n long bfs(IntSet[] graph, int source, int[] W) {\\n int n = graph.length;\\n IntQueue queue = new IntArrayQueue();\\n long[] starting = new long[n];\\n for (int i = 0; i < n; i++) {\\n if (i != source && graph[i].size() == 1) {\\n queue.add(i);\\n }\\n }\\n long sum = 0;\\n while (!queue.isEmpty())...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out.\\n\\nBob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted them at home. Since he does not know which clue belongs to which obelisk, finding the treasure might pose a challenge. Can you help him?\\n\\nAs everyone knows, the world is a two-dimensional plane. The i-th obelisk is at integer coordinates (x_i, y_i). The j-th clue consists of 2 integers (a_j, b_j) and belongs to the obelisk p_j, where p is some (unknown) permutation on n elements. It means that the treasure is located at T=(x_{p_j} + a_j, y_{p_j} + b_j). This point T is the same for all clues.\\n\\nIn other words, each clue belongs to exactly one of the obelisks, and each obelisk has exactly one clue that belongs to it. A clue represents the vector from the obelisk to the treasure. The clues must be distributed among the obelisks in such a way that they all point to the same position of the treasure.\\n\\nYour task is to find the coordinates of the treasure. If there are multiple solutions, you may print any of them.\\n\\nNote that you don't need to find the permutation. Permutations are used only in order to explain the problem.\\n\\nInput\\n\\nThe first line contains an integer n (1 ≤ n ≤ 1000) — the number of obelisks, that is also equal to the number of clues.\\n\\nEach of the next n lines contains two integers x_i, y_i (-10^6 ≤ x_i, y_i ≤ 10^6) — the coordinates of the i-th obelisk. All coordinates are distinct, that is x_i ≠ x_j or y_i ≠ y_j will be satisfied for every (i, j) such that i ≠ j. \\n\\nEach of the next n lines contains two integers a_i, b_i (-2 ⋅ 10^6 ≤ a_i, b_i ≤ 2 ⋅ 10^6) — the direction of the i-th clue. All coordinates are distinct, that is a_i ≠ a_j or b_i ≠ b_j will be satisfied for every (i, j) such that i ≠ j. \\n\\nIt is guaranteed that there exists a permutation p, such that for all i,j it holds \\\\left(x_{p_i}...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nvoid Solves() {\\n long long n;\\n cin >> n;\\n vector > obelisk(n);\\n vector > clue(n);\\n for (long long i = 0; i < n; i++)\\n cin >> obelisk[i].first >> obelisk[i].second;\\n for (long long i = 0; i < n; i++) cin >> clue[i].first >> clue[i].second;\\n sort(obelisk.begin(), obelisk.end());\\n sort(clue.begin(), clue.end(), greater >());\\n cout << obelisk[0].first + clue[0].first << \\\" \\\"\\n << obelisk[0].second + clue[0].second << endl;\\n}\\nint main() {\\n Solves();\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"The only difference between this problem and D2 is that you don't have to provide the way to construct the answer in this problem, but you have to do it in D2.\\n\\nThere's a table of n × m cells (n rows and m columns). The value of n ⋅ m is even.\\n\\nA domino is a figure that consists of two cells having a common side. It may be horizontal (one of the cells is to the right of the other) or vertical (one of the cells is above the other).\\n\\nYou need to find out whether it is possible to place nm\\/2 dominoes on the table so that exactly k of them are horizontal and all the other dominoes are vertical. The dominoes cannot overlap and must fill the whole table.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of a single line. The line contains three integers n, m, k (1 ≤ n,m ≤ 100, 0 ≤ k ≤ nm\\/2, n ⋅ m is even) — the number of rows, columns and horizontal dominoes, respectively.\\n\\nOutput\\n\\nFor each test case output \\\"YES\\\", if it is possible to place dominoes in the desired way, or \\\"NO\\\" otherwise.\\n\\nYou may print each letter in any case (YES, yes, Yes will all be recognized as positive answer, NO, no and nO will all be recognized as negative answer).\\n\\nExample\\n\\nInput\\n\\n\\n8\\n4 4 2\\n2 3 0\\n3 2 3\\n1 2 0\\n2 4 2\\n5 2 2\\n2 17 16\\n2 1 1\\n\\n\\nOutput\\n\\n\\nYES\\nYES\\nYES\\nNO\\nYES\\nNO\\nYES\\nNO\\nUsing java can you solve the prior task?\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\n\\nimport static java.lang.Math.max;\\nimport static java.lang.Math.min;\\nimport static java.util.Arrays.sort;\\nimport static java.util.Comparator.comparingInt;\\n\\npublic class Round {\\n FastScanner in;\\n PrintWriter out;\\n\\n private void solve() throws IOException {\\n solve_d1();\\n }\\n\\n private void solve_a() throws IOException {\\n int n = in.nextInt();\\n out.println(n \\/ 3 + (n % 3 == 1 ? 1 : 0) + \\\" \\\" + (n \\/ 3 + (n % 3 == 2 ? 1 : 0)));\\n }\\n\\n private void solve_b1() throws IOException {\\n char[] s = in.next().toCharArray();\\n int n = s.length, k = 2, alpha = 'z' - 'a' + 1;\\n\\n ArrayList[] pos = new ArrayList[alpha];\\n for (int i = 0; i < alpha; i++)\\n pos[i] = new ArrayList<>();\\n\\n for (int i = 0; i < n; i++)\\n pos[s[i] - 'a'].add(i);\\n\\n int max_cnt = 0;\\n for (int i = 0; i < alpha; i++)\\n max_cnt += min(k, pos[i].size());\\n\\n max_cnt -= max_cnt % k;\\n\\n out.println(max_cnt \\/ k);\\n }\\n\\n private void solve_b2() throws IOException {\\n int n = in.nextInt(), k = in.nextInt();\\n\\n ArrayList[] pos = new ArrayList[n];\\n for (int i = 0; i < n; i++)\\n pos[i] = new ArrayList<>();\\n\\n for (int i = 0; i < n; i++)\\n pos[in.nextInt() - 1].add(i);\\n\\n int max_cnt = 0;\\n for (int i = 0; i < n; i++)\\n max_cnt += min(k, pos[i].size());\\n\\n max_cnt -= max_cnt % k;\\n\\n int[] c = new int[n];\\n int cur = 0;\\n\\n for (int i = 0; i < n; i++) {\\n if (pos[i].size() >= k) {\\n for (int j = 0; j < k; j++) {\\n c[pos[i].get(j)] = cur % k + 1;\\n cur++;\\n }\\n }\\n }\\n\\n for (int i = 0; i < n && cur < max_cnt; i++) {\\n if (pos[i].size() < k) {\\n for (int j = 0; j < pos[i].size() && cur < max_cnt; j++) {\\n c[pos[i].get(j)] = cur % k + 1;\\n cur++;\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"It is the hard version of the problem. The only difference is that in this version 1 ≤ n ≤ 300.\\n\\nIn the cinema seats can be represented as the table with n rows and m columns. The rows are numbered with integers from 1 to n. The seats in each row are numbered with consecutive integers from left to right: in the k-th row from m (k - 1) + 1 to m k for all rows 1 ≤ k ≤ n.\\n\\n1| 2| ⋅⋅⋅| m - 1| m \\n---|---|---|---|--- \\nm + 1| m + 2| ⋅⋅⋅| 2 m - 1| 2 m \\n2m + 1| 2m + 2| ⋅⋅⋅| 3 m - 1| 3 m \\n\\\\vdots| \\\\vdots| \\\\ddots| \\\\vdots| \\\\vdots \\nm (n - 1) + 1| m (n - 1) + 2| ⋅⋅⋅| n m - 1| n m \\nThe table with seats indices\\n\\nThere are nm people who want to go to the cinema to watch a new film. They are numbered with integers from 1 to nm. You should give exactly one seat to each person.\\n\\nIt is known, that in this cinema as lower seat index you have as better you can see everything happening on the screen. i-th person has the level of sight a_i. Let's define s_i as the seat index, that will be given to i-th person. You want to give better places for people with lower sight levels, so for any two people i, j such that a_i < a_j it should be satisfied that s_i < s_j.\\n\\nAfter you will give seats to all people they will start coming to their seats. In the order from 1 to nm, each person will enter the hall and sit in their seat. To get to their place, the person will go to their seat's row and start moving from the first seat in this row to theirs from left to right. While moving some places will be free, some will be occupied with people already seated. The inconvenience of the person is equal to the number of occupied seats he or she will go through.\\n\\nLet's consider an example: m = 5, the person has the seat 4 in the first row, the seats 1, 3, 5 in the first row are already occupied, the seats 2 and 4 are free. The inconvenience of this person will be 2, because he will go through occupied seats 1 and 3.\\n\\nFind the minimal total inconvenience (the sum of inconveniences of all people), that is possible to have by giving places for all...\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\ntemplate \\ninline T vmin(T v) {\\n return v;\\n}\\ntemplate \\ninline T vmax(T v) {\\n return v;\\n}\\ntemplate \\ninline T vmin(T first, Args... args) {\\n return min(first, (T)vmin(args...));\\n}\\ntemplate \\ninline T vmax(T first, Args... args) {\\n return max(first, (T)vmax(args...));\\n}\\ntemplate \\ninline void smin(T &x, Args... args) {\\n x = (T)vmin(x, args...);\\n}\\ntemplate \\ninline void smax(T &x, Args... args) {\\n x = (T)vmax(x, args...);\\n}\\nconst long double eps = 1e-15;\\nconst int maxN = 1 * 300 + 10, mod = (int)1e9 + 7, inf = (int)1e9 + 1;\\nint t, n, m;\\nbool cmp(pair a, pair b) {\\n if (a.first < b.first)\\n return 1;\\n else if (a.first == b.first)\\n return (a.second > b.second);\\n else\\n return 0;\\n}\\nint mat[maxN][maxN];\\nint main() {\\n ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);\\n cin >> t;\\n while (t--) {\\n cin >> n >> m;\\n vector > a(n * m);\\n vector b(n * m);\\n for (int i = (int)(0); i < (int)(n * m); ++i) {\\n cin >> a[i].first;\\n a[i].second = i;\\n mat[i \\/ m][i % m] = 0;\\n }\\n sort(a.begin(), a.end());\\n for (int i = (int)(0); i < (int)(n); ++i) {\\n int start = -1;\\n int end = -1;\\n for (int j = (int)(0); j < (int)(m); ++j) {\\n if (start == -1 && j != m - 1 &&\\n a[i * m + j].first == a[i * m + j + 1].first)\\n start = i * m + j;\\n if (start != -1 && j != m - 1 &&\\n a[i * m + j].first != a[i * m + j + 1].first) {\\n end = i * m + j;\\n sort(a.begin() + start, a.begin() + end + 1, cmp);\\n start = -1;\\n }\\n }\\n if (start != -1) sort(a.begin() + start, a.begin() + i * m + m, cmp);\\n }\\n for (int i = (int)(0); i < (int)(n * m); ++i) b[a[i].second] = i;\\n long long res = 0;\\n for (int i = (int)(0); i < (int)(n * m); ++i) {\\n int c = b[i] \\/ m;\\n for (int j =...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"It is the hard version of the problem. The only difference is that in this version 1 ≤ n ≤ 300.\\n\\nIn the cinema seats can be represented as the table with n rows and m columns. The rows are numbered with integers from 1 to n. The seats in each row are numbered with consecutive integers from left to right: in the k-th row from m (k - 1) + 1 to m k for all rows 1 ≤ k ≤ n.\\n\\n1| 2| ⋅⋅⋅| m - 1| m \\n---|---|---|---|--- \\nm + 1| m + 2| ⋅⋅⋅| 2 m - 1| 2 m \\n2m + 1| 2m + 2| ⋅⋅⋅| 3 m - 1| 3 m \\n\\\\vdots| \\\\vdots| \\\\ddots| \\\\vdots| \\\\vdots \\nm (n - 1) + 1| m (n - 1) + 2| ⋅⋅⋅| n m - 1| n m \\nThe table with seats indices\\n\\nThere are nm people who want to go to the cinema to watch a new film. They are numbered with integers from 1 to nm. You should give exactly one seat to each person.\\n\\nIt is known, that in this cinema as lower seat index you have as better you can see everything happening on the screen. i-th person has the level of sight a_i. Let's define s_i as the seat index, that will be given to i-th person. You want to give better places for people with lower sight levels, so for any two people i, j such that a_i < a_j it should be satisfied that s_i < s_j.\\n\\nAfter you will give seats to all people they will start coming to their seats. In the order from 1 to nm, each person will enter the hall and sit in their seat. To get to their place, the person will go to their seat's row and start moving from the first seat in this row to theirs from left to right. While moving some places will be free, some will be occupied with people already seated. The inconvenience of the person is equal to the number of occupied seats he or she will go through.\\n\\nLet's consider an example: m = 5, the person has the seat 4 in the first row, the seats 1, 3, 5 in the first row are already occupied, the seats 2 and 4 are free. The inconvenience of this person will be 2, because he will go through occupied seats 1 and 3.\\n\\nFind the minimal total inconvenience (the sum of inconveniences of all people), that is possible to have by giving places for all...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nvoid dbg() { cout << \\\"DEBUG\\\\n\\\"; }\\nconst int INF = 1e9;\\nconst long long LINF = 1e18;\\nconst long long mod = 1e9 + 7;\\nconst int maxn = 100000;\\nstruct Node {\\n int val;\\n} seg[maxn << 2];\\nvoid pushup(int cur) {\\n seg[cur].val = seg[cur << 1].val + seg[cur << 1 | 1].val;\\n return;\\n}\\nvoid init(int cur, int l, int r) {\\n if (l + 1 == r) {\\n seg[cur].val = 0;\\n return;\\n }\\n int mid = (l + r) >> 1;\\n init(cur << 1, l, mid);\\n init(cur << 1 | 1, mid, r);\\n pushup(cur);\\n return;\\n}\\nvoid update(int cur, int l, int r, int pos, int data) {\\n if (l + 1 == r) {\\n seg[cur].val += data;\\n return;\\n }\\n int mid = (l + r) >> 1;\\n if (pos < mid)\\n update(cur << 1, l, mid, pos, data);\\n else\\n update(cur << 1 | 1, mid, r, pos, data);\\n pushup(cur);\\n return;\\n}\\nint query(int cur, int l, int r, int x, int y) {\\n if (l >= y || r <= x) return 0;\\n if (l >= x && r <= y) return seg[cur].val;\\n int mid = (l + r) >> 1;\\n return query(cur << 1, l, mid, x, y) + query(cur << 1 | 1, mid, r, x, y);\\n}\\nvoid solve() {\\n int m, n;\\n cin >> m >> n;\\n vector arr(m * n);\\n for (auto &x : arr) cin >> x;\\n map cnt;\\n for (auto &x : arr) cnt[x]++;\\n unordered_map> index;\\n vector vis(n * m, false);\\n int pos = 0, l = 1;\\n for (auto &x : cnt) {\\n int cur = x.first, times = x.second;\\n while (times) {\\n if (l * n - pos <= times) {\\n times -= l * n - pos;\\n vis[l * n - 1] = true;\\n index[cur].push(l * n - 1);\\n pos = l * n;\\n l++;\\n } else {\\n pos += times;\\n vis[pos - 1] = true;\\n index[cur].push(pos - 1);\\n times = 0;\\n }\\n }\\n }\\n vector res(m * n);\\n for (int i = 0; i < m * n; i++) {\\n int cur = index[arr[i]].front();\\n res[i] = cur;\\n cur--;\\n if (cur < 0 || vis[cur])\\n index[arr[i]].pop();\\n else\\n index[arr[i]].front() -= 1;\\n }\\n int ans = 0;\\n init(1, 0, n * m);\\n for (int i = 0; i < n * m; i++) {\\n int layer = res[i] \\/ n;\\n ans += query(1, 0, n * m, layer...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"You are given an array A of length N weights of masses A_1, A_2...A_N. No two weights have the same mass. You can put every weight on one side of the balance (left or right). You don't have to put weights in order A_1,...,A_N. There is also a string S consisting of characters \\\"L\\\" and \\\"R\\\", meaning that after putting the i-th weight (not A_i, but i-th weight of your choice) left or right side of the balance should be heavier. Find the order of putting the weights on the balance such that rules of string S are satisfied. \\n\\nInput\\n\\nThe first line contains one integer N (1 ≤ N ≤ 2*10^5) - the length of the array A The second line contains N distinct integers: A_1, A_2,...,A_N (1 ≤ A_i ≤ 10^9) - the weights given The third line contains string S of length N consisting only of letters \\\"L\\\" and \\\"R\\\" - string determining which side of the balance should be heavier after putting the i-th weight of your choice\\n\\nOutput\\n\\nThe output contains N lines. In every line, you should print one integer and one letter - integer representing the weight you are putting on the balance in that move and the letter representing the side of the balance where you are putting the weight. If there is no solution, print -1.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n3 8 2 13 7\\nLLRLL\\n\\n\\nOutput\\n\\n\\n3 L\\n2 R\\n8 R\\n13 L\\n7 L\\n\\nNote\\n\\nExplanation for the test case: \\n\\nafter the 1st weight: 3 L (left side is heavier)\\n\\nafter the 2nd weight: 2 R (left side is heavier)\\n\\nafter the 3rd weight: 8 R (right side is heavier)\\n\\nafter the 4th weight: 13 L (left side is heavier)\\n\\nafter the 5th weight: 7 L (left side is heavier)\\n\\nSo, the rules given by string S are fulfilled and our order of putting the weights is correct.\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint n, a[666666], b[666666];\\nchar c[666666];\\nstring s;\\nint main() {\\n cin >> n;\\n for (int i = 0; i < n; ++i) cin >> a[i];\\n cin >> s;\\n sort(a, a + n);\\n a[n] = 2e9;\\n int r = -1;\\n int op = 0;\\n for (int i = 0; i < n; ++i)\\n if (i && s[i] == s[i - 1]) ++r;\\n int l = r + 1;\\n for (int i = 0; i < n; ++i) {\\n if (i && s[i] == s[i - 1]) {\\n c[i] = op ^= 1;\\n b[i] = a[r--];\\n } else {\\n c[i] = (s[i] == 'R');\\n b[i] = a[l++];\\n if (!i) op = (s[i] == 'R');\\n }\\n }\\n for (int i = 0; i < n; ++i) cout << b[i] << \\\" \\\" << (\\\"LR\\\"[c[i]]) << \\\"\\\\n\\\";\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nYou are given an array of n positive integers a_1, a_2, …, a_n. Your task is to calculate the number of arrays of n positive integers b_1, b_2, …, b_n such that: \\n\\n * 1 ≤ b_i ≤ a_i for every i (1 ≤ i ≤ n), and \\n * b_i ≠ b_{i+1} for every i (1 ≤ i ≤ n - 1). \\n\\n\\n\\nThe number of such arrays can be very large, so print it modulo 998 244 353.\\n\\nInput\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the length of the array a.\\n\\nThe second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^9).\\n\\nOutput\\n\\nPrint the answer modulo 998 244 353 in a single line.\\n\\nExamples\\n\\nInput\\n\\n\\n3\\n2 2 2\\n\\n\\nOutput\\n\\n\\n2\\n\\nInput\\n\\n\\n2\\n2 3\\n\\n\\nOutput\\n\\n\\n4\\n\\nInput\\n\\n\\n3\\n1 1 1\\n\\n\\nOutput\\n\\n\\n0\\n\\nNote\\n\\nIn the first test case possible arrays are [1, 2, 1] and [2, 1, 2].\\n\\nIn the second test case possible arrays are [1, 2], [1, 3], [2, 1] and [2, 3].\",\"targets\":\"#include \\nusing namespace std;\\ntemplate \\nvoid rd(vector &v);\\ntemplate \\nvoid rd(T &x) {\\n cin >> x;\\n}\\ntemplate \\nvoid rd(H &h, T &...t) {\\n rd(h);\\n rd(t...);\\n}\\ntemplate \\nvoid rd(vector &x) {\\n for (auto &a : x) rd(a);\\n}\\ntemplate \\nbool ckmin(T &a, const T b) {\\n return b < a ? a = b, 1 : 0;\\n}\\ntemplate \\nbool ckmax(T &a, const T b) {\\n return a < b ? a = b, 1 : 0;\\n}\\ntemplate \\nvoid __p(T a) {\\n cout << a;\\n}\\ntemplate \\nvoid __p(pair a) {\\n cout << \\\"{\\\";\\n __p(a.first);\\n cout << \\\",\\\";\\n __p(a.second);\\n cout << \\\"}\\\\n\\\";\\n}\\ntemplate \\nvoid __p(std::vector a) {\\n cout << \\\"{\\\";\\n for (auto it = a.begin(); it < a.end(); it++)\\n __p(*it), cout << \\\",}\\\\n\\\"[it + 1 == a.end()];\\n}\\ntemplate \\nvoid __p(T a1, Arg... a) {\\n __p(a1);\\n __p(a...);\\n}\\ntemplate \\nvoid __f(const char *name, Arg1 &&arg1) {\\n cout << name << \\\" : \\\";\\n __p(arg1);\\n cout << \\\"\\\\n\\\";\\n}\\ntemplate \\nvoid __f(const char *names, Arg1 &&arg1, Args &&...args) {\\n int bracket = 0, i = 0;\\n for (;; i++)\\n if (names[i] == ',' && bracket == 0)\\n break;\\n else if (names[i] == '(')\\n bracket++;\\n else if (names[i] == ')')\\n bracket--;\\n const char *comma = names + i;\\n cout.write(names, comma - names) << \\\" : \\\";\\n __p(arg1);\\n cout << \\\" | \\\";\\n __f(comma + 1, args...);\\n}\\nvoid setIO(string s = \\\"\\\") {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n cin.exceptions(cin.failbit);\\n cout.precision(15);\\n cout << fixed;\\n if (((int)(s).size())) {\\n freopen((s + \\\".in\\\").c_str(), \\\"r\\\", stdin);\\n freopen((s + \\\".out\\\").c_str(), \\\"w\\\", stdout);\\n }\\n}\\ntemplate \\nstruct _m_int {\\n int val;\\n _m_int(int64_t v = 0) {\\n if (v < 0) v = v % MOD + MOD;\\n if (v >= MOD) v %= MOD;\\n val = v;\\n }\\n static int inv_mod(int a, int m = MOD) {\\n int g = m, r = a, x = 0, y = 1;\\n while (r != 0) {\\n int q = g \\/ r;\\n g...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Mr. Chanek gives you a sequence a indexed from 1 to n. Define f(a) as the number of indices where a_i = i. \\n\\nYou can pick an element from the current sequence and remove it, then concatenate the remaining elements together. For example, if you remove the 3-rd element from the sequence [4, 2, 3, 1], the resulting sequence will be [4, 2, 1]. \\n\\nYou want to remove some elements from a in order to maximize f(a), using zero or more operations. Find the largest possible f(a).\\n\\nInput\\n\\nThe first line contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the initial length of the sequence.\\n\\nThe second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 2 ⋅ 10^5) — the initial sequence a.\\n\\nOutput\\n\\nOutput an integer denoting the largest f(a) that can be obtained by doing zero or more operations.\\n\\nExamples\\n\\nInput\\n\\n\\n7\\n2 1 4 2 5 3 7\\n\\n\\nOutput\\n\\n\\n3\\n\\n\\nInput\\n\\n\\n4\\n4 2 3 1\\n\\n\\nOutput\\n\\n\\n2\\n\\nNote\\n\\nIn the first example, f(A) = 3 by doing the following operations.\\n\\n[2,1,4,2,5,3,7] → [2,1,2,5,3,7] → [1,2,5,3,7] → [1,2,5,3] → [1,2,3]\\n\\nIn the second example, f(A) = 2 and no additional operation is needed.\\\":\",\"targets\":\"#include \\nusing namespace std;\\nconst int MAXN = 2e5 + 5;\\nconst int FINF = 0xcccccccc;\\nint dp[MAXN];\\nint v[MAXN];\\nint a[MAXN];\\nint tree[MAXN];\\ninline int lowbit(int x) { return x & -x; }\\nvoid change(int lo, int x, int n) {\\n for (int i = lo; i <= n; i += lowbit(i)) tree[i] = max(tree[i], x);\\n}\\nint getmax(int lo) {\\n int ret = FINF;\\n for (int i = lo; i; i -= lowbit(i)) ret = max(ret, tree[i]);\\n return ret;\\n}\\nvoid cal(int ll, int rr) {\\n if (ll == rr) return;\\n int mid = (ll + rr) \\/ 2;\\n cal(ll, mid);\\n vector> l, r;\\n vector ids;\\n for (int i = ll; i <= mid; i++)\\n l.push_back({v[i], a[i], i, dp[i]}), ids.push_back(a[i]);\\n for (int i = mid + 1; i <= rr; i++)\\n r.push_back({v[i], a[i], i, dp[i]}), ids.push_back(a[i]);\\n sort(l.begin(), l.end());\\n sort(r.begin(), r.end());\\n sort(ids.begin(), ids.end());\\n ids.erase(unique(ids.begin(), ids.end()), ids.end());\\n int n = ids.size();\\n auto getid = [&](int x) {\\n return n - (lower_bound(ids.begin(), ids.end(), x) - ids.begin());\\n };\\n memset(tree, 0xcc, sizeof(int) * (n + 1));\\n int aa = 0;\\n for (auto x : r) {\\n while (aa < l.size() && get<0>(l[aa]) < get<0>(x)) {\\n change(getid(get<1>(l[aa])), get<3>(l[aa]), n);\\n aa++;\\n }\\n int i = get<2>(x);\\n dp[i] = max(dp[i], getmax(getid(get<1>(x))) + 1);\\n }\\n cal(mid + 1, rr);\\n}\\nint main() {\\n ios::sync_with_stdio(false);\\n cin.tie(0);\\n int n;\\n cin >> n;\\n for (int i = 1; i <= n; i++) cin >> v[i];\\n memset(dp, 0xcc, sizeof dp);\\n dp[0] = 0;\\n for (int i = 1; i <= n; i++) a[i] = v[i] - i;\\n cal(0, n);\\n cout << *max_element(dp, dp + 1 + n);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"N players will participate in a tennis tournament. We will call them Player 1, Player 2, \\\\ldots, Player N.\\n\\nThe tournament is round-robin format, and there will be N(N-1)\\/2 matches in total. Is it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required.\\n\\n* Each player plays at most one matches in a day.\\n* Each player i (1 \\\\leq i \\\\leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \\\\ldots, A_{i, N-1} in this order.\\n\\nConstraints\\n\\n* 3 \\\\leq N \\\\leq 1000\\n* 1 \\\\leq A_{i, j} \\\\leq N\\n* A_{i, j} \\\\neq i\\n* A_{i, 1}, A_{i, 2}, \\\\ldots, A_{i, N-1} are all different.\\n\\nInput\\n\\nInput is given from Standard Input in the following format:\\n\\n\\nN\\nA_{1, 1} A_{1, 2} \\\\ldots A_{1, N-1}\\nA_{2, 1} A_{2, 2} \\\\ldots A_{2, N-1}\\n:\\nA_{N, 1} A_{N, 2} \\\\ldots A_{N, N-1}\\n\\n\\nOutput\\n\\nIf it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print `-1`.\\n\\nExamples\\n\\nInput\\n\\n3\\n2 3\\n1 3\\n1 2\\n\\n\\nOutput\\n\\n3\\n\\n\\nInput\\n\\n4\\n2 3 4\\n1 3 4\\n4 1 2\\n3 1 2\\n\\n\\nOutput\\n\\n4\\n\\n\\nInput\\n\\n3\\n2 3\\n3 1\\n1 2\\n\\n\\nOutput\\n\\n-1\\\":\",\"targets\":\"#include\\nusing namespace std;\\ntypedef long long ll;\\nconst int N = 1e3+5;\\n\\nint n;\\nint a[N][N],t[N],p[N];\\nqueueq[2];\\n\\nint main(){\\n\\tscanf(\\\"%d\\\",&n);\\n\\tfor(int i=1;i<=n;++i)\\n\\tfor(int j=1;j\\nusing namespace std;\\nconst int mod = 998244353;\\nint qpow(int a, int b) {\\n int res = 1;\\n while (b) {\\n if (b & 1) res = (long long)res * a % mod;\\n a = (long long)a * a % mod;\\n b >>= 1;\\n }\\n return res;\\n}\\nint fac[200015 << 1], ifac[200015 << 1];\\nint C(int n, int m) {\\n if (n < m || m < 0) return 0;\\n return (long long)fac[n] * ifac[m] % mod * ifac[n - m] % mod;\\n}\\nint t, n, m, x[200015], y[200015];\\nint sum[200015];\\nvoid add(int p, int v) {\\n for (; p <= n; p += ((p) & (-p))) sum[p] += v;\\n}\\nint query(int p) {\\n int res = 0;\\n for (; p; p -= ((p) & (-p))) res += sum[p];\\n return res;\\n}\\nint getpos(int x) {\\n int l = 1, r = n, ans = 0;\\n while (l <= r) {\\n int mid = (l + r) >> 1;\\n if (mid - query(mid) == x) {\\n ans = mid;\\n }\\n if (mid - query(mid) < x)\\n l = mid + 1;\\n else\\n r = mid - 1;\\n }\\n return ans;\\n}\\nint main() {\\n fac[0] = 1;\\n for (int i = (1); i <= (400000); i++)\\n fac[i] = (long long)fac[i - 1] * i % mod;\\n for (int i = (0); i <= (400000); i++) ifac[i] = qpow(fac[i], mod - 2);\\n scanf(\\\"%d\\\", &t);\\n while (t--) {\\n scanf(\\\"%d%d\\\", &n, &m);\\n for (int i = (1); i <= (m); i++) scanf(\\\"%d%d\\\", &x[i], &y[i]);\\n int cnt = n - 1;\\n vector vec;\\n for (int i = (m); i >= (1); i--) {\\n if (y[i] < n) {\\n int p1 = getpos(y[i]);\\n int p2 = getpos(y[i] + 1);\\n if (p1 + 1 == p2) cnt--;\\n }\\n int p = getpos(y[i]);\\n add(p, 1);\\n vec.push_back(p);\\n }\\n printf(\\\"%d\\\\n\\\", C(n + cnt, n));\\n for (auto x : vec) add(x, -1);\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A string s of length n, consisting of lowercase letters of the English alphabet, is given.\\n\\nYou must choose some number k between 0 and n. Then, you select k characters of s and permute them however you want. In this process, the positions of the other n-k characters remain unchanged. You have to perform this operation exactly once.\\n\\nFor example, if s=\\\"andrea\\\", you can choose the k=4 characters \\\"a_d_ea\\\" and permute them into \\\"d_e_aa\\\" so that after the operation the string becomes \\\"dneraa\\\".\\n\\nDetermine the minimum k so that it is possible to sort s alphabetically (that is, after the operation its characters appear in alphabetical order).\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases. Then t test cases follow.\\n\\nThe first line of each test case contains one integer n (1 ≤ n ≤ 40) — the length of the string.\\n\\nThe second line of each test case contains the string s. It is guaranteed that s contains only lowercase letters of the English alphabet.\\n\\nOutput\\n\\nFor each test case, output the minimum k that allows you to obtain a string sorted alphabetically, through the operation described above.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\nlol\\n10\\ncodeforces\\n5\\naaaaa\\n4\\ndcba\\n\\n\\nOutput\\n\\n\\n2\\n6\\n0\\n4\\n\\nNote\\n\\nIn the first test case, we can choose the k=2 characters \\\"_ol\\\" and rearrange them as \\\"_lo\\\" (so the resulting string is \\\"llo\\\"). It is not possible to sort the string choosing strictly less than 2 characters.\\n\\nIn the second test case, one possible way to sort s is to consider the k=6 characters \\\"_o__force_\\\" and rearrange them as \\\"_c__efoor_\\\" (so the resulting string is \\\"ccdeefoors\\\"). One can show that it is not possible to sort the string choosing strictly less than 6 characters.\\n\\nIn the third test case, string s is already sorted (so we can choose k=0 characters).\\n\\nIn the fourth test case, we can choose all k=4 characters \\\"dcba\\\" and reverse the whole string (so the resulting string is \\\"abcd\\\").\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"for __ in range(int(input())):\\n n = int(input())\\n s = list(input())\\n s_ = sorted(s)\\n count = 0\\n for i in range(n):\\n if s[i] != s_[i]:\\n count += 1\\n print(count)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"By 2312 there were n Large Hadron Colliders in the inhabited part of the universe. Each of them corresponded to a single natural number from 1 to n. However, scientists did not know what activating several colliders simultaneously could cause, so the colliders were deactivated.\\n\\nIn 2312 there was a startling discovery: a collider's activity is safe if and only if all numbers of activated colliders are pairwise relatively prime to each other (two numbers are relatively prime if their greatest common divisor equals 1)! If two colliders with relatively nonprime numbers are activated, it will cause a global collapse.\\n\\nUpon learning this, physicists rushed to turn the colliders on and off and carry out all sorts of experiments. To make sure than the scientists' quickness doesn't end with big trouble, the Large Hadron Colliders' Large Remote Control was created. You are commissioned to write the software for the remote (well, you do not expect anybody to operate it manually, do you?).\\n\\nInitially, all colliders are deactivated. Your program receives multiple requests of the form \\\"activate\\/deactivate the i-th collider\\\". The program should handle requests in the order of receiving them. The program should print the processed results in the format described below.\\n\\nTo the request of \\\"+ i\\\" (that is, to activate the i-th collider), the program should print exactly one of the following responses: \\n\\n * \\\"Success\\\" if the activation was successful. \\n * \\\"Already on\\\", if the i-th collider was already activated before the request. \\n * \\\"Conflict with j\\\", if there is a conflict with the j-th collider (that is, the j-th collider is on, and numbers i and j are not relatively prime). In this case, the i-th collider shouldn't be activated. If a conflict occurs with several colliders simultaneously, you should print the number of any of them. \\n\\n\\n\\nThe request of \\\"- i\\\" (that is, to deactivate the i-th collider), should receive one of the following responses from the program: \\n\\n * \\\"Success\\\", if the deactivation was successful. \\n *...\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\nimport java.math.BigInteger;\\npublic class C109D2{\\n static BufferedReader br;\\n public static void main(String args[])throws Exception{\\n br=new BufferedReader(new InputStreamReader(System.in));\\n PrintStream out = new PrintStream(System.out);\\n\\n int nm[]=toIntArray();\\n int n=nm[0];\\n int m=nm[1];\\n String res[]=new String[m];\\n int maxP=0;\\n String on=\\\"Already on\\\";\\n String suc=\\\"Success\\\";\\n String conf=\\\"Conflict with \\\";\\n String off=\\\"Already off\\\";\\n int state[]=new int[n+1];\\n Arrays.fill(state, 0);\\n\\n ArrayList ar = new ArrayList();\\n int exist[]=new int[n+1];\\n Arrays.fill(exist, 0);\\n\\n boolean isPrime[]=new boolean[n+1];\\n Arrays.fill(isPrime, true);\\n isPrime[0]=false;\\n isPrime[1]=false;\\n for (int i = 2; i * i <= n; i++) {\\n if (isPrime[i]) {\\n for (int j = i; i * j <= n; j++) {\\n isPrime[i * j] = false;\\n }\\n }\\n }\\n\\n int prod[]=new int[n+1];\\n \\n for(int i=0;i temp = new ArrayList();\\n if(isPrime[col]){\\n temp.add(col);\\n }\\n else{\\n for(int j=2;j<=cc;){\\n if(cc%j==0){\\n temp.add(j);\\n while(cc%j==0)cc=cc\\/j;\\n }\\n j++;\\n if(isPrime[cc]){\\n temp.add(cc);\\n break;\\n }\\n }\\n }\\n if(s[0].charAt(0)=='+'){\\n\\n if(state[col]==0){\\n if(isPrime[col] && exist[col]==0){\\n out.println(suc);\\/\\/res[i]=suc;\\n state[col]=1;\\n ...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given an integer n. In 1 move, you can do one of the following actions:\\n\\n * erase any digit of the number (it's acceptable that the number before the operation has exactly one digit and after the operation, it is \\\"empty\\\"); \\n * add one digit to the right. \\n\\n\\n\\nThe actions may be performed in any order any number of times.\\n\\nNote that if, after deleting some digit from a number, it will contain leading zeroes, they will not be deleted. E.g. if you delete from the number 301 the digit 3, the result is the number 01 (not 1).\\n\\nYou need to perform the minimum number of actions to make the number any power of 2 (i.e. there's an integer k (k ≥ 0) such that the resulting number is equal to 2^k). The resulting number must not have leading zeroes.\\n\\nE.g. consider n=1052. The answer is equal to 2. First, let's add to the right one digit 4 (the result will be 10524). Then let's erase the digit 5, so the result will be 1024 which is a power of 2.\\n\\nE.g. consider n=8888. The answer is equal to 3. Let's erase any of the digits 8 three times. The result will be 8 which is a power of 2.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10^4) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one line containing one integer n (1 ≤ n ≤ 10^9).\\n\\nOutput\\n\\nFor each test case, output in a separate line one integer m — the minimum number of moves to transform the number into any power of 2.\\n\\nExample\\n\\nInput\\n\\n\\n12\\n1052\\n8888\\n6\\n75\\n128\\n1\\n301\\n12048\\n1504\\n6656\\n1000000000\\n687194767\\n\\n\\nOutput\\n\\n\\n2\\n3\\n1\\n3\\n0\\n0\\n2\\n1\\n3\\n4\\n9\\n2\\n\\nNote\\n\\nThe answer for the first test case was considered above.\\n\\nThe answer for the second test case was considered above.\\n\\nIn the third test case, it's enough to add to the right the digit 4 — the number 6 will turn into 64.\\n\\nIn the fourth test case, let's add to the right the digit 8 and then erase 7 and 5 — the taken number will turn into 8.\\n\\nThe numbers of the fifth and the sixth test cases are already powers of two so there's no need to make any move.\\n\\nIn the seventh test case, you can...\\nUsing python3 can you solve the prior task?\",\"targets\":\"ans=[1]\\nwhile(ans[-1]<=pow(10,19)):\\n ans.append(ans[-1]*2)\\n\\n\\nimport math\\n\\na=int(input())\\n\\ndef check(val,s):\\n\\n \\n q=str(s)\\n s=str(val)\\n j=0\\n i=0\\n req=0\\n cnt=0\\n while(j, with the last number AN remaining the same. For example, if we start with an array A with a = 2 and N = 4, then after one product transformation A = [4, 4, 4, 2], and after two product transformations A = [16, 16, 8, 2].\\n\\nYour simple task is to calculate the array A after M product transformations. Since the numbers can get quite big you should output them modulo Q.\\n\\nInput\\n\\nThe first and only line of input contains four integers N, M, a, Q (7 ≤ Q ≤ 109 + 123, 2 ≤ a ≤ 106 + 123, , is prime), where is the multiplicative order of the integer a modulo Q, see notes for definition.\\n\\nOutput\\n\\nYou should output the array A from left to right.\\n\\nExample\\n\\nInput\\n\\n2 2 2 7\\n\\n\\nOutput\\n\\n1 2 \\n\\nNote\\n\\nThe multiplicative order of a number a modulo Q , is the smallest natural number x such that ax mod Q = 1. For example, .\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nlong long pow(long long a, long long b, long long mod, long long r = 1) {\\n for (long long i = b; i; i >>= 1, a = (1LL * a * a) % mod)\\n if (i & 1) r = (1LL * r * a) % mod;\\n return r;\\n}\\nstruct comb {\\n long long n, mod, i;\\n vector F, I;\\n comb(long long n, long long mod)\\n : n(n),\\n mod(mod),\\n F(vector(n + 1, 1)),\\n I(vector(n + 1, 1)) {\\n for (i = 1; i <= n; i++) F[i] = (1LL * F[i - 1] * i) % mod;\\n i--;\\n for (I[n] = pow(F[n], mod - 2, mod); i; i--)\\n I[i - 1] = (1LL * I[i] * i) % mod;\\n }\\n long long nCr(long long n, long long r) {\\n return n >= r ? (1LL * F[n] * ((1LL * I[n - r] * I[r]) % mod)) % mod : 0;\\n }\\n};\\nconst long long N = 2e6;\\nlong long coeff[N];\\nint32_t main() {\\n ios_base ::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n long long n, m, a, q, p;\\n cin >> n >> m >> a >> q;\\n for (long long i = 2; true; i++)\\n if (pow(a, i, q) == 1) {\\n p = i;\\n break;\\n }\\n comb C(m, p);\\n for (long long i = 0; i <= m && i < n; i++) {\\n long long prv = i ? coeff[i - 1] : 0;\\n coeff[i] = (prv + C.nCr(m, i)) % p;\\n }\\n for (long long i = m + 1; i < n; i++) {\\n coeff[i] = pow(2, m, p);\\n }\\n for (long long i = 1; i <= n; i++) {\\n cout << pow(a, coeff[n - i], q) << \\\" \\\\n\\\"[i == n];\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"This version of the problem differs from the next one only in the constraint on n.\\n\\nNote that the memory limit in this problem is lower than in others.\\n\\nYou have a vertical strip with n cells, numbered consecutively from 1 to n from top to bottom.\\n\\nYou also have a token that is initially placed in cell n. You will move the token up until it arrives at cell 1.\\n\\nLet the token be in cell x > 1 at some moment. One shift of the token can have either of the following kinds: \\n\\n * Subtraction: you choose an integer y between 1 and x-1, inclusive, and move the token from cell x to cell x - y. \\n * Floored division: you choose an integer z between 2 and x, inclusive, and move the token from cell x to cell ⌊ x\\/z ⌋ (x divided by z rounded down). \\n\\n\\n\\nFind the number of ways to move the token from cell n to cell 1 using one or more shifts, and print it modulo m. Note that if there are several ways to move the token from one cell to another in one shift, all these ways are considered distinct (check example explanation for a better understanding).\\n\\nInput\\n\\nThe only line contains two integers n and m (2 ≤ n ≤ 2 ⋅ 10^5; 10^8 < m < 10^9; m is a prime number) — the length of the strip and the modulo.\\n\\nOutput\\n\\nPrint the number of ways to move the token from cell n to cell 1, modulo m.\\n\\nExamples\\n\\nInput\\n\\n\\n3 998244353\\n\\n\\nOutput\\n\\n\\n5\\n\\n\\nInput\\n\\n\\n5 998244353\\n\\n\\nOutput\\n\\n\\n25\\n\\n\\nInput\\n\\n\\n42 998244353\\n\\n\\nOutput\\n\\n\\n793019428\\n\\nNote\\n\\nIn the first test, there are three ways to move the token from cell 3 to cell 1 in one shift: using subtraction of y = 2, or using division by z = 2 or z = 3.\\n\\nThere are also two ways to move the token from cell 3 to cell 1 via cell 2: first subtract y = 1, and then either subtract y = 1 again or divide by z = 2.\\n\\nTherefore, there are five ways in total.\",\"targets\":\"#include \\nusing namespace std;\\nvoid solve() {\\n long long n, m;\\n cin >> n >> m;\\n vector dp(n + 1, 0);\\n dp[1] = 1;\\n long long prefSum = dp[1];\\n for (long long(i) = (2); (i) < (n + 1); ++(i)) {\\n dp[i] = prefSum;\\n for (long long j = 1; j * j <= i; ++j) {\\n dp[i] = (dp[i] + (dp[j] * ((i \\/ j) - (i \\/ (j + 1)))) % m) % m;\\n if (j != i \\/ j && j > 1) {\\n dp[i] = (dp[i] + dp[i \\/ j]) % m;\\n }\\n }\\n prefSum = (prefSum + dp[i]) % m;\\n }\\n cout << dp[n];\\n}\\nint32_t main() {\\n ios::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n ;\\n long long tc = 1;\\n while (tc--) {\\n solve();\\n cout << '\\\\n';\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nThe only difference between this problem and D1 is that you don't have to provide the way to construct the answer in D1, but you have to do it in this problem.\\n\\nThere's a table of n × m cells (n rows and m columns). The value of n ⋅ m is even.\\n\\nA domino is a figure that consists of two cells having a common side. It may be horizontal (one of the cells is to the right of the other) or vertical (one of the cells is above the other).\\n\\nYou need to place nm\\/2 dominoes on the table so that exactly k of them are horizontal and all the other dominoes are vertical. The dominoes cannot overlap and must fill the whole table.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of a single line. The line contains three integers n, m, k (1 ≤ n,m ≤ 100, 0 ≤ k ≤ nm\\/2, n ⋅ m is even) — the count of rows, columns and horizontal dominoes, respectively.\\n\\nOutput\\n\\nFor each test case:\\n\\n * print \\\"NO\\\" if it's not possible to place the dominoes on the table in the described way; \\n * otherwise, print \\\"YES\\\" on a separate line, then print n lines so that each of them contains m lowercase letters of the Latin alphabet — the layout of the dominoes on the table. Each cell of the table must be marked by the letter so that for every two cells having a common side, they are marked by the same letters if and only if they are occupied by the same domino. I.e. both cells of the same domino must be marked with the same letter, but two dominoes that share a side must be marked with different letters. If there are multiple solutions, print any of them. \\n\\nExample\\n\\nInput\\n\\n\\n8\\n4 4 2\\n2 3 0\\n3 2 3\\n1 2 0\\n2 4 2\\n5 2 2\\n2 17 16\\n2 1 1\\n\\n\\nOutput\\n\\n\\nYES\\naccx\\naegx\\nbega\\nbdda\\nYES\\naha\\naha\\nYES\\nzz\\naa\\nzz\\nNO\\nYES\\naaza\\nbbza\\nNO\\nYES\\nbbaabbaabbaabbaay\\nddccddccddccddccy\\nNO\",\"targets\":\"\\/\\/ package com.company;\\nimport java.util.*;\\nimport java.io.*;\\nimport java.lang.*;\\nimport java.util.jar.JarEntry;\\n\\npublic class Main{\\n \\/* || श्री गणेशाय नमः ||\\n @𝐚𝐮𝐭𝐡𝐨𝐫 𝐉𝐢𝐠𝐚𝐫 𝐍𝐚𝐢𝐧𝐮𝐣𝐢\\n 𝐒𝐕𝐍𝐈𝐓- 𝐒𝐮𝐫𝐚𝐭\\n *\\/\\n public static void main(String args[]){\\n InputReader in=new InputReader(System.in);\\n TASK solver = new TASK();\\n int t=1;\\n t = in.nextInt();\\n for(int i=1;i<=t;i++)\\n {\\n solver.solve(in,i);\\n }\\n }\\n static class TASK {\\n static void solve(char[][] s,int n,int m,int k)\\n {\\n for(int j=0;j0) {\\n if (j % 4 == 0) {\\n if (i % 2 == 1) {\\n s[i][j] = 'a';\\n s[i][j + 1] = 'a';\\n } else {\\n s[i][j] = 'b';\\n s[i][j + 1] = 'b';\\n }\\n k--;\\n } else {\\n if (i % 2 == 0) {\\n s[i][j] = 'a';\\n s[i][j + 1] = 'a';\\n } else {\\n s[i][j] = 'b';\\n s[i][j + 1] = 'b';\\n }\\n k--;\\n }\\n }\\n else\\n {\\n if(j%4==0)\\n {\\n if(i%4<=1)\\n {\\n s[i][j]='c';\\n s[i][j+1]='d';\\n }\\n else\\n {\\n s[i][j]='e';\\n s[i][j+1]='f';\\n }\\n }\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Given a positive integer n. Find three distinct positive integers a, b, c such that a + b + c = n and \\\\operatorname{gcd}(a, b) = c, where \\\\operatorname{gcd}(x, y) denotes the [greatest common divisor (GCD)](https:\\/\\/en.wikipedia.org\\/wiki\\/Greatest_common_divisor) of integers x and y.\\n\\nInput\\n\\nThe input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 10^5) — the number of test cases. Description of the test cases follows.\\n\\nThe first and only line of each test case contains a single integer n (10 ≤ n ≤ 10^9).\\n\\nOutput\\n\\nFor each test case, output three distinct positive integers a, b, c satisfying the requirements. If there are multiple solutions, you can print any. We can show that an answer always exists.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n18\\n63\\n73\\n91\\n438\\n122690412\\n\\n\\nOutput\\n\\n\\n6 9 3\\n21 39 3\\n29 43 1\\n49 35 7\\n146 219 73\\n28622 122661788 2\\n\\nNote\\n\\nIn the first test case, 6 + 9 + 3 = 18 and \\\\operatorname{gcd}(6, 9) = 3.\\n\\nIn the second test case, 21 + 39 + 3 = 63 and \\\\operatorname{gcd}(21, 39) = 3.\\n\\nIn the third test case, 29 + 43 + 1 = 73 and \\\\operatorname{gcd}(29, 43) = 1.\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\n\\npublic class GCDProblem {\\n\\n\\tpublic static void main(String[] args) {\\n\\t\\tStringBuilder outputBuffer = new StringBuilder();\\n\\n\\t\\tint tests = ni();\\n\\t\\tfor (int i = 0; i < tests; i++) {\\n\\t\\t\\tint number = ni();\\n\\t\\t\\tint temp = number \\/ 2;\\n\\t\\t\\tif (number % 2 == 0) {\\n\\t\\t\\t\\toutputBuffer.append(temp + \\\" \\\" + (number - temp - 1) + \\\" \\\" + 1 + \\\"\\\\n\\\");\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tif ((number \\/ 2) % 2 == 0) {\\n\\t\\t\\t\\t\\toutputBuffer.append((temp + 1) + \\\" \\\" + (number - temp - 2) + \\\" \\\" + 1 + \\\"\\\\n\\\");\\n\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\toutputBuffer.append((temp + 2) + \\\" \\\" + (number - temp - 3) + \\\" \\\" + 1 + \\\"\\\\n\\\");\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\tSystem.out.println(outputBuffer);\\n\\t}\\n\\n\\tpublic static long gcd(long a, long b) {\\n\\t\\treturn b == 0 ? Math.abs(a) : gcd(b, a % b);\\n\\t}\\n\\n\\tstatic InputStream is = System.in;\\n\\n\\tstatic byte[] inbuf = new byte[1 << 24];\\n\\tstatic int lenbuf = 0, ptrbuf = 0;\\n\\n\\tstatic int readByte() {\\n\\t\\tif (lenbuf == -1)\\n\\t\\t\\tthrow new InputMismatchException();\\n\\t\\tif (ptrbuf >= lenbuf) {\\n\\t\\t\\tptrbuf = 0;\\n\\t\\t\\ttry {\\n\\t\\t\\t\\tlenbuf = is.read(inbuf);\\n\\t\\t\\t} catch (IOException e) {\\n\\t\\t\\t\\tthrow new InputMismatchException();\\n\\t\\t\\t}\\n\\t\\t\\tif (lenbuf <= 0)\\n\\t\\t\\t\\treturn -1;\\n\\t\\t}\\n\\t\\treturn inbuf[ptrbuf++];\\n\\t}\\n\\n\\tstatic boolean isSpaceChar(int c) {\\n\\t\\treturn !(c >= 33 && c <= 126);\\n\\t}\\n\\n\\tstatic int skip() {\\n\\t\\tint b;\\n\\t\\twhile ((b = readByte()) != -1 && isSpaceChar(b))\\n\\t\\t\\t;\\n\\t\\treturn b;\\n\\t}\\n\\n\\tstatic float nf() {\\n\\t\\treturn Float.parseFloat(ns());\\n\\t}\\n\\n\\tstatic double nd() {\\n\\t\\treturn Double.parseDouble(ns());\\n\\t}\\n\\n\\tstatic char nc() {\\n\\t\\treturn (char) skip();\\n\\t}\\n\\n\\tstatic String ns() {\\n\\t\\tint b = skip();\\n\\t\\tStringBuilder sb = new StringBuilder();\\n\\t\\twhile (!(isSpaceChar(b))) {\\n\\t\\t\\tsb.appendCodePoint(b);\\n\\t\\t\\tb = readByte();\\n\\t\\t}\\n\\t\\treturn sb.toString();\\n\\t}\\n\\n\\tstatic char[] ns(int n) {\\n\\t\\tchar[] buf = new char[n];\\n\\t\\tint b = skip(), p = 0;\\n\\t\\twhile (p < n && !(isSpaceChar(b))) {\\n\\t\\t\\tbuf[p++] = (char) b;\\n\\t\\t\\tb = readByte();\\n\\t\\t}\\n\\t\\treturn n == p ? buf : Arrays.copyOf(buf, p);\\n\\t}\\n\\n\\tstatic int ni() {\\n\\t\\tint num = 0, b;\\n\\t\\tboolean minus = false;\\n\\t\\twhile ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b ==...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"\\\"Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score...\\\" — an excerpt from contest rules.\\n\\nA total of n participants took part in the contest (n ≥ k), and you already know their scores. Calculate how many participants will advance to the next round.\\n\\nInput\\n\\nThe first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 50) separated by a single space.\\n\\nThe second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 100), where ai is the score earned by the participant who got the i-th place. The given sequence is non-increasing (that is, for all i from 1 to n - 1 the following condition is fulfilled: ai ≥ ai + 1).\\n\\nOutput\\n\\nOutput the number of participants who advance to the next round.\\n\\nExamples\\n\\nInput\\n\\n8 5\\n10 9 8 7 7 7 5 5\\n\\n\\nOutput\\n\\n6\\n\\n\\nInput\\n\\n4 2\\n0 0 0 0\\n\\n\\nOutput\\n\\n0\\n\\nNote\\n\\nIn the first example the participant on the 5th place earned 7 points. As the participant on the 6th place also earned 7 points, there are 6 advancers.\\n\\nIn the second example nobody got a positive score.\",\"targets\":\"N,K = map(int,input().split())\\nL = list(map(int,input().split()))[:N]\\ncount = 0\\nfor i in L:\\n if i==0:\\n continue\\n elif i>=L[K-1]:\\n count+=1\\nprint(count)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Gregor is learning about RSA cryptography, and although he doesn't understand how RSA works, he is now fascinated with prime numbers and factoring them.\\n\\nGregor's favorite prime number is P. Gregor wants to find two bases of P. Formally, Gregor is looking for two integers a and b which satisfy both of the following properties.\\n\\n * P mod a = P mod b, where x mod y denotes the remainder when x is divided by y, and \\n * 2 ≤ a < b ≤ P. \\n\\n\\n\\nHelp Gregor find two bases of his favorite prime number!\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 1000).\\n\\nEach subsequent line contains the integer P (5 ≤ P ≤ {10}^9), with P guaranteed to be prime.\\n\\nOutput\\n\\nYour output should consist of t lines. Each line should consist of two integers a and b (2 ≤ a < b ≤ P). If there are multiple possible solutions, print any.\\n\\nExample\\n\\nInput\\n\\n\\n2\\n17\\n5\\n\\n\\nOutput\\n\\n\\n3 5\\n2 4\\n\\nNote\\n\\nThe first query is P=17. a=3 and b=5 are valid bases in this case, because 17 mod 3 = 17 mod 5 = 2. There are other pairs which work as well.\\n\\nIn the second query, with P=5, the only solution is a=2 and b=4.\\nSolve the task in PYTHON.\",\"targets\":\"import sys\\nimport os\\nfrom io import BytesIO\\n\\n# pypy2\\nsys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))\\n\\nf = sys.stdin\\n\\nline = lambda: f.readline().strip('\\\\r\\\\n').split()\\n\\ndef write(w):\\n sys.stdout.write(w)\\n sys.stdout.write(\\\"\\\\n\\\")\\n\\ndef solve():\\n a = 2\\n b = P \\/\\/ 2 if P != 5 else 4\\n \\n return str(a) + \\\" \\\" + str(b)\\n\\nT = int(line()[0])\\nfor test in range(1,T+1):\\n P = int(line()[0])\\n \\n write(solve())\\n \\nf.close()\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A lot of people in Berland hates rain, but you do not. Rain pacifies, puts your thoughts in order. By these years you have developed a good tradition — when it rains, you go on the street and stay silent for a moment, contemplate all around you, enjoy freshness, think about big deeds you have to do. \\n\\nToday everything had changed quietly. You went on the street with a cup contained water, your favorite drink. In a moment when you were drinking a water you noticed that the process became quite long: the cup still contained water because of rain. You decided to make a formal model of what was happening and to find if it was possible to drink all water in that situation. \\n\\nThus, your cup is a cylinder with diameter equals d centimeters. Initial level of water in cup equals h centimeters from the bottom. \\n\\n\\n\\nYou drink a water with a speed equals v milliliters per second. But rain goes with such speed that if you do not drink a water from the cup, the level of water increases on e centimeters per second. The process of drinking water from the cup and the addition of rain to the cup goes evenly and continuously. \\n\\nFind the time needed to make the cup empty or find that it will never happen. It is guaranteed that if it is possible to drink all water, it will happen not later than after 104 seconds.\\n\\nNote one milliliter equals to one cubic centimeter.\\n\\nInput\\n\\nThe only line of the input contains four integer numbers d, h, v, e (1 ≤ d, h, v, e ≤ 104), where:\\n\\n * d — the diameter of your cylindrical cup, \\n * h — the initial level of water in the cup, \\n * v — the speed of drinking process from the cup in milliliters per second, \\n * e — the growth of water because of rain if you do not drink from the cup. \\n\\nOutput\\n\\nIf it is impossible to make the cup empty, print \\\"NO\\\" (without quotes).\\n\\nOtherwise print \\\"YES\\\" (without quotes) in the first line. In the second line print a real number — time in seconds needed the cup will be empty. The answer will be considered correct if its relative or absolute error doesn't...\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"d, h, v, e = map(int, input().split())\\nfrom math import pi\\nv \\/= pi * d ** 2 \\/ 4\\nif v < e: print('NO')\\nelse:\\n ans = h \\/ (v - e)\\n print('YES')\\n print(ans)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A robot cleaner is placed on the floor of a rectangle room, surrounded by walls. The floor consists of n rows and m columns. The rows of the floor are numbered from 1 to n from top to bottom, and columns of the floor are numbered from 1 to m from left to right. The cell on the intersection of the r-th row and the c-th column is denoted as (r,c). The initial position of the robot is (r_b, c_b).\\n\\nIn one second, the robot moves by dr rows and dc columns, that is, after one second, the robot moves from the cell (r, c) to (r + dr, c + dc). Initially dr = 1, dc = 1. If there is a vertical wall (the left or the right walls) in the movement direction, dc is reflected before the movement, so the new value of dc is -dc. And if there is a horizontal wall (the upper or lower walls), dr is reflected before the movement, so the new value of dr is -dr.\\n\\nEach second (including the moment before the robot starts moving), the robot cleans every cell lying in the same row or the same column as its position. There is only one dirty cell at (r_d, c_d). The job of the robot is to clean that dirty cell.\\n\\n Illustration for the first example. The blue arc is the robot. The red star is the target dirty cell. Each second the robot cleans a row and a column, denoted by yellow stripes.\\n\\nGiven the floor size n and m, the robot's initial position (r_b, c_b) and the dirty cell's position (r_d, c_d), find the time for the robot to do its job.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^4). Description of the test cases follows.\\n\\nA test case consists of only one line, containing six integers n, m, r_b, c_b, r_d, and c_d (1 ≤ n, m ≤ 100, 1 ≤ r_b, r_d ≤ n, 1 ≤ c_b, c_d ≤ m) — the sizes of the room, the initial position of the robot and the position of the dirt cell.\\n\\nOutput\\n\\nFor each test case, print an integer — the time for the robot to clean the dirty cell. We can show that the robot always cleans the dirty cell eventually.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n10 10 6 1 2 8\\n10 10 9 9 1...\\nSolve the task in PYTHON3.\",\"targets\":\"for _ in range(int(input())):\\n #n=int(input())\\n #a=list(map(int,input().split()))\\n #s=input()\\n n,m,a,b,ta,tb=map(int,input().split())\\n if a>ta:\\n v=2*(n-a)+a-ta\\n else:\\n v=ta-a\\n if b>tb:\\n h=2*(m-b)+b-tb\\n else:\\n h=tb-b\\n ans=min(h,v)\\n print(ans)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nYou are given a tree with n nodes. As a reminder, a tree is a connected undirected graph without cycles.\\n\\nLet a_1, a_2, …, a_n be a sequence of integers. Perform the following operation exactly n times: \\n\\n * Select an unerased node u. Assign a_u := number of unerased nodes adjacent to u. Then, erase the node u along with all edges that have it as an endpoint. \\n\\n\\n\\nFor each integer k from 1 to n, find the number, modulo 998 244 353, of different sequences a_1, a_2, …, a_n that satisfy the following conditions:\\n\\n * it is possible to obtain a by performing the aforementioned operations exactly n times in some order. \\n * \\\\operatorname{gcd}(a_1, a_2, …, a_n) = k. Here, \\\\operatorname{gcd} means the greatest common divisor of the elements in a. \\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10 000) — the number of test cases.\\n\\nThe first line of each test case contains a single integer n (2 ≤ n ≤ 10^5).\\n\\nEach of the next n - 1 lines contains two integers u and v (1 ≤ u, v ≤ n) indicating there is an edge between vertices u and v. It is guaranteed that the given edges form a tree.\\n\\nIt is guaranteed that the sum of n over all test cases doesn't exceed 3 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print n integers in a single line, where for each k from 1 to n, the k-th integer denotes the answer when \\\\operatorname{gcd} equals to k.\\n\\nExample\\n\\nInput\\n\\n\\n2\\n3\\n2 1\\n1 3\\n2\\n1 2\\n\\n\\nOutput\\n\\n\\n3 1 0\\n2 0\\n\\nNote\\n\\nIn the first test case, \\n\\n\\n\\n * If we delete the nodes in order 1 → 2 → 3 or 1 → 3 → 2, then the obtained sequence will be a = [2, 0, 0] which has \\\\operatorname{gcd} equals to 2. \\n * If we delete the nodes in order 2 → 1 → 3, then the obtained sequence will be a = [1, 1, 0] which has \\\\operatorname{gcd} equals to 1. \\n * If we delete the nodes in order 3 → 1 → 2, then the obtained sequence will be a = [1, 0, 1] which has \\\\operatorname{gcd} equals to 1. \\n * If we delete the nodes in order 2 → 3 → 1 or 3 → 2 → 1, then the obtained sequence will be a = [0, 1, 1] which has \\\\operatorname{gcd} equals to 1. \\n\\n\\n\\nNote...\",\"targets\":\"#include \\nusing namespace std;\\nconst int maxn = 300000 + 50;\\nconst long long mm = 998244353;\\nint n, m, ans, T;\\nlong long f[maxn], w[maxn];\\nvector tr[maxn];\\nlong long dfs1(int x, int fa) {\\n long long tot = 1;\\n w[x] = 1;\\n for (int i = 0; i < tr[x].size(); ++i)\\n if (tr[x][i] != fa)\\n tot = tot * dfs1(tr[x][i], x) * 2 % mm, w[x] = (w[x] + w[tr[x][i]]);\\n return tot;\\n}\\nint dfs(int x, int fa, int z, int y) {\\n int tot = 0;\\n for (int i = 0; i < tr[x].size(); ++i)\\n if (tr[x][i] != fa)\\n if (w[tr[x][i]] % z == 0) {\\n if (!dfs(tr[x][i], x, z, 1)) return 0;\\n } else if ((w[tr[x][i]] - 1) % z == 0) {\\n ++tot;\\n if (!dfs(tr[x][i], x, z, 0)) return 0;\\n } else\\n return 0;\\n if ((tot + y) % z == 0)\\n ;\\n else\\n return 0;\\n return 1;\\n}\\nint main() {\\n scanf(\\\"%d\\\", &T);\\n for (int oo = 1; oo <= T; ++oo) {\\n scanf(\\\"%d\\\", &n);\\n for (int i = 1; i <= n; ++i)\\n while (!tr[i].empty()) tr[i].pop_back();\\n for (int i = 1; i < n; ++i) {\\n int q1, q2;\\n scanf(\\\"%d%d\\\", &q1, &q2);\\n tr[q1].push_back(q2);\\n tr[q2].push_back(q1);\\n }\\n for (int i = 1; i <= n; ++i) f[i] = 0;\\n f[1] = dfs1(1, 1);\\n for (int i = n - 1; i > 1; --i)\\n if ((n - 1) % i == 0 && !f[i]) {\\n f[i] += dfs(1, 1, i, 0);\\n if (f[i])\\n for (int j = 1; j * j <= i; ++j)\\n if (i % j == 0) {\\n f[j] -= f[i];\\n if (j * j != i && j != 1) f[i \\/ j] -= f[i];\\n }\\n }\\n for (int i = 1; i <= n; ++i)\\n if (f[i] >= 0)\\n printf(\\\"%lld \\\", (f[i] + mm) % mm);\\n else\\n printf(\\\"0 \\\");\\n printf(\\\"\\\\n\\\");\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Polycarp likes squares and cubes of positive integers. Here is the beginning of the sequence of numbers he likes: 1, 4, 8, 9, ....\\n\\nFor a given number n, count the number of integers from 1 to n that Polycarp likes. In other words, find the number of such x that x is a square of a positive integer number or a cube of a positive integer number (or both a square and a cube simultaneously).\\n\\nInput\\n\\nThe first line contains an integer t (1 ≤ t ≤ 20) — the number of test cases.\\n\\nThen t lines contain the test cases, one per line. Each of the lines contains one integer n (1 ≤ n ≤ 10^9).\\n\\nOutput\\n\\nFor each test case, print the answer you are looking for — the number of integers from 1 to n that Polycarp likes.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n10\\n1\\n25\\n1000000000\\n999999999\\n500000000\\n\\n\\nOutput\\n\\n\\n4\\n1\\n6\\n32591\\n32590\\n23125\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\n\\npublic class B {\\n\\n\\tpublic static void main(String args[]) throws IOException {\\n\\n\\t\\tFastReader fr = new FastReader();\\n\\t\\tPrintWriter out = new PrintWriter(System.out);\\n\\n\\t\\tint t = fr.nextInt();\\n\\t\\t\\n\\t\\tfor(int test = 0;test < t;test++) {\\n\\t\\t\\t\\n\\t\\t\\tint n = fr.nextInt();\\n\\t\\t\\t\\n\\t\\t\\tint ans = 0;\\n\\t\\t\\t\\n\\t\\t\\tfor(int i = 1;i <= n;i++) {\\n\\t\\t\\t\\t\\n\\t\\t\\t\\tif(i * i <= n) {\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\tans++;\\n\\t\\t\\t\\t\\t\\n\\/\\/\\t\\t\\t\\t\\tSystem.out.println(\\\"i1 = \\\"+i*i);\\n\\t\\t\\t\\t\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\n\\t\\t\\t\\telse break;\\n\\t\\t\\t\\t\\n\\t\\t\\t}\\n\\t\\t\\t\\n\\t\\t\\tfor(int i = 1;i <= n;i++) {\\n\\t\\t\\t\\t\\n\\t\\t\\t\\tif(i * i * i <= n && isPerfectSquare(i * i * i) == false) {\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\tans++;\\n\\t\\t\\t\\t\\t\\n\\/\\/\\t\\t\\t\\t\\tSystem.out.println(\\\"i2 = \\\"+i*i*i);\\n\\t\\t\\t\\t\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\n\\t\\t\\t\\telse if(i * i * i > n) break;\\n\\t\\t\\t\\t\\n\\t\\t\\t}\\n\\t\\t\\t\\n\\t\\t\\tout.println(ans);\\n\\t\\t\\t\\n\\t\\t}\\n\\t\\t\\n\\t\\tfr.close();\\n\\t\\tout.close();\\n\\n\\t}\\n\\t\\n\\tstatic boolean isPerfectSquare(int n) {\\n\\t\\t\\n\\t\\tint s = (int) Math.sqrt((double)n);\\n\\t\\t\\n\\t\\tboolean b = false;\\n\\t\\t\\n\\t\\tif(s * s == n) b = true;\\n\\t\\t\\n\\t\\treturn b;\\n\\t\\t\\n\\t}\\n\\n\\tstatic class FastReader {\\n\\n\\t\\tBufferedReader br;\\n\\t\\tStringTokenizer st;\\n\\n\\t\\tpublic FastReader() {\\n\\n\\t\\t\\tbr = new BufferedReader(new InputStreamReader(System.in));\\n\\n\\t\\t}\\n\\n\\t\\tString next() {\\n\\n\\t\\t\\twhile(st == null || !st.hasMoreElements()) {\\n\\n\\t\\t\\t\\ttry {\\n\\n\\t\\t\\t\\t\\tst = new StringTokenizer(br.readLine());\\n\\n\\t\\t\\t\\t}\\n\\n\\t\\t\\t\\tcatch(IOException e) {\\n\\n\\t\\t\\t\\t\\te.printStackTrace();\\n\\n\\t\\t\\t\\t}\\n\\n\\t\\t\\t}\\n\\n\\t\\t\\treturn st.nextToken();\\n\\n\\t\\t}\\n\\n\\t\\tint nextInt() {\\n\\n\\t\\t\\treturn Integer.parseInt(next());\\n\\n\\t\\t}\\n\\n\\t\\tlong nextLong() {\\n\\n\\t\\t\\treturn Long.parseLong(next());\\n\\n\\t\\t}\\n\\n\\t\\tdouble nextDouble() {\\n\\n\\t\\t\\treturn Double.parseDouble(next());\\n\\n\\t\\t}\\n\\n\\t\\tString nextLine() {\\n\\n\\t\\t\\tString str = \\\"\\\";\\n\\n\\t\\t\\ttry {\\n\\n\\t\\t\\t\\tstr = br.readLine();\\n\\n\\t\\t\\t}\\n\\n\\t\\t\\tcatch(IOException e) {\\n\\n\\t\\t\\t\\te.printStackTrace();\\n\\n\\t\\t\\t}\\n\\n\\t\\t\\treturn str;\\n\\n\\t\\t}\\n\\n\\t\\tvoid close() throws IOException {\\n\\n\\t\\t\\tbr.close();\\n\\n\\t\\t}\\n\\n\\t}\\n\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in PYTHON?\\nPolycarp must pay exactly n burles at the checkout. He has coins of two nominal values: 1 burle and 2 burles. Polycarp likes both kinds of coins equally. So he doesn't want to pay with more coins of one type than with the other.\\n\\nThus, Polycarp wants to minimize the difference between the count of coins of 1 burle and 2 burles being used. Help him by determining two non-negative integer values c_1 and c_2 which are the number of coins of 1 burle and 2 burles, respectively, so that the total value of that number of coins is exactly n (i. e. c_1 + 2 ⋅ c_2 = n), and the absolute value of the difference between c_1 and c_2 is as little as possible (i. e. you must minimize |c_1-c_2|).\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10^4) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one line. This line contains one integer n (1 ≤ n ≤ 10^9) — the number of burles to be paid by Polycarp.\\n\\nOutput\\n\\nFor each test case, output a separate line containing two integers c_1 and c_2 (c_1, c_2 ≥ 0) separated by a space where c_1 is the number of coins of 1 burle and c_2 is the number of coins of 2 burles. If there are multiple optimal solutions, print any one.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n1000\\n30\\n1\\n32\\n1000000000\\n5\\n\\n\\nOutput\\n\\n\\n334 333\\n10 10\\n1 0\\n10 11\\n333333334 333333333\\n1 2\\n\\nNote\\n\\nThe answer for the first test case is \\\"334 333\\\". The sum of the nominal values of all coins is 334 ⋅ 1 + 333 ⋅ 2 = 1000, whereas |334 - 333| = 1. One can't get the better value because if |c_1 - c_2| = 0, then c_1 = c_2 and c_1 ⋅ 1 + c_1 ⋅ 2 = 1000, but then the value of c_1 isn't an integer.\\n\\nThe answer for the second test case is \\\"10 10\\\". The sum of the nominal values is 10 ⋅ 1 + 10 ⋅ 2 = 30 and |10 - 10| = 0, whereas there's no number having an absolute value less than 0.\",\"targets\":\"import sys\\nimport math\\n\\nif sys.subversion[0] == \\\"PyPy\\\":\\n import io, atexit\\n\\n sys.stdout = io.BytesIO()\\n atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))\\n\\n sys.stdin = io.BytesIO(sys.stdin.read())\\n input = lambda: sys.stdin.readline().rstrip()\\n\\nt = int(raw_input())\\n\\n# python codesforces210710.py < input.txt\\nfor x in range(t):\\n a = int(raw_input())\\n b = a\\/3\\n ob = 0\\n tb = 0\\n if a % 3 == 1:\\n ob = 1\\n if a % 3 == 2:\\n tb = 1\\n tb += b\\n ob += b\\n tb = str(tb)\\n ob = str(ob)\\n print(ob + ' ' + tb)\\n\\n\\n #print( )\\n #aaaa = map(int, aaa)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Anton likes to play chess, and so does his friend Danik.\\n\\nOnce they have played n games in a row. For each game it's known who was the winner — Anton or Danik. None of the games ended with a tie.\\n\\nNow Anton wonders, who won more games, he or Danik? Help him determine this.\\n\\nInput\\n\\nThe first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of games played.\\n\\nThe second line contains a string s, consisting of n uppercase English letters 'A' and 'D' — the outcome of each of the games. The i-th character of the string is equal to 'A' if the Anton won the i-th game and 'D' if Danik won the i-th game.\\n\\nOutput\\n\\nIf Anton won more games than Danik, print \\\"Anton\\\" (without quotes) in the only line of the output.\\n\\nIf Danik won more games than Anton, print \\\"Danik\\\" (without quotes) in the only line of the output.\\n\\nIf Anton and Danik won the same number of games, print \\\"Friendship\\\" (without quotes).\\n\\nExamples\\n\\nInput\\n\\n6\\nADAAAA\\n\\n\\nOutput\\n\\nAnton\\n\\n\\nInput\\n\\n7\\nDDDAADA\\n\\n\\nOutput\\n\\nDanik\\n\\n\\nInput\\n\\n6\\nDADADA\\n\\n\\nOutput\\n\\nFriendship\\n\\nNote\\n\\nIn the first sample, Anton won 6 games, while Danik — only 1. Hence, the answer is \\\"Anton\\\".\\n\\nIn the second sample, Anton won 3 games and Danik won 4 games, so the answer is \\\"Danik\\\".\\n\\nIn the third sample, both Anton and Danik won 3 games and the answer is \\\"Friendship\\\".\\nn = i\",\"targets\":\"nt(input())\\nres = input()\\na = 0\\nd = 0\\nfor part in res:\\n if part == 'A':\\n a += 1\\n else:\\n d += 1\\nif a > d:\\n print('Anton')\\nelif a < d:\\n print('Danik')\\nelse:\\n print('Friendship')\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"The problem statement looms below, filling you with determination.\\n\\nConsider a grid in which some cells are empty and some cells are filled. Call a cell in this grid exitable if, starting at that cell, you can exit the grid by moving up and left through only empty cells. This includes the cell itself, so all filled in cells are not exitable. Note that you can exit the grid from any leftmost empty cell (cell in the first column) by going left, and from any topmost empty cell (cell in the first row) by going up.\\n\\nLet's call a grid determinable if, given only which cells are exitable, we can exactly determine which cells are filled in and which aren't.\\n\\nYou are given a grid a of dimensions n × m , i. e. a grid with n rows and m columns. You need to answer q queries (1 ≤ q ≤ 2 ⋅ 10^5). Each query gives two integers x_1, x_2 (1 ≤ x_1 ≤ x_2 ≤ m) and asks whether the subgrid of a consisting of the columns x_1, x_1 + 1, …, x_2 - 1, x_2 is determinable.\\n\\nInput\\n\\nThe first line contains two integers n, m (1 ≤ n, m ≤ 10^6, nm ≤ 10^6) — the dimensions of the grid a.\\n\\nn lines follow. The y-th line contains m characters, the x-th of which is 'X' if the cell on the intersection of the the y-th row and x-th column is filled and \\\".\\\" if it is empty.\\n\\nThe next line contains a single integer q (1 ≤ q ≤ 2 ⋅ 10^5) — the number of queries.\\n\\nq lines follow. Each line contains two integers x_1 and x_2 (1 ≤ x_1 ≤ x_2 ≤ m), representing a query asking whether the subgrid of a containing the columns x_1, x_1 + 1, …, x_2 - 1, x_2 is determinable.\\n\\nOutput\\n\\nFor each query, output one line containing \\\"YES\\\" if the subgrid specified by the query is determinable and \\\"NO\\\" otherwise. The output is case insensitive (so \\\"yEs\\\" and \\\"No\\\" will also be accepted).\\n\\nExample\\n\\nInput\\n\\n\\n4 5\\n..XXX\\n...X.\\n...X.\\n...X.\\n5\\n1 3\\n3 3\\n4 5\\n5 5\\n1 5\\n\\n\\nOutput\\n\\n\\nYES\\nYES\\nNO\\nYES\\nNO\\n\\nNote\\n\\nFor each query of the example, the corresponding subgrid is displayed twice below: first in its input format, then with each cell marked as \\\"E\\\" if it is exitable and \\\"N\\\" otherwise.\\n\\nFor the...\\\":\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\n\\n\\/\\/ THIS TEMPLATE MADE BY AKSH BANSAL.\\n\\npublic class Solution {\\n static class FastReader {\\n BufferedReader br;\\n StringTokenizer st;\\n public FastReader() {\\n br = new BufferedReader(new InputStreamReader(System.in));\\n }\\n String next() {\\n while (st == null || !st.hasMoreElements()) {\\n try {\\n st = new StringTokenizer(br.readLine());\\n } catch (IOException e) {\\n e.printStackTrace();\\n }\\n }\\n return st.nextToken();\\n }\\n int nextInt() {\\n return Integer.parseInt(next());\\n }\\n long nextLong() {\\n return Long.parseLong(next());\\n }\\n double nextDouble() {\\n return Double.parseDouble(next());\\n }\\n String nextLine() {\\n String str = \\\"\\\";\\n try {\\n str = br.readLine();\\n } catch (IOException e) {\\n e.printStackTrace();\\n }\\n return str;\\n }\\n }\\n static void sort(int a[]){ \\/\\/ int -> long\\n ArrayList arr=new ArrayList<>(); \\/\\/ Integer -> Long\\n for(int i=0;i\\n\\nHowever, Alice evaluates it as shown: \\n\\n\\n\\nIn particular, this is what she does: \\n\\n * add 9 and 6 to make 15, and carry the 1 to the column two columns to the left, i. e. to the column \\\"0 9\\\"; \\n * add 3 and 7 to make 10 and carry the 1 to the column two columns to the left, i. e. to the column \\\"2 2\\\"; \\n * add 1, 0, and 9 to make 10 and carry the 1 to the column two columns to the left, i. e. to the column above the plus sign; \\n * add 1, 2 and 2 to make 5; \\n * add 1 to make 1. \\n\\nThus, she ends up with the incorrect result of 15005.\\n\\nAlice comes up to Bob and says that she has added two numbers to get a result of n. However, Bob knows that Alice adds in her own way. Help Bob find the number of ordered pairs of positive integers such that when Alice adds them, she will get a result of n. Note that pairs (a, b) and (b, a) are considered different if a ≠ b.\\n\\nInput\\n\\nThe input consists of multiple test cases. The first line contains an integer t (1 ≤ t ≤ 1000) — the number of test cases. The description of the test cases follows.\\n\\nThe only line of each test case contains an integer n (2 ≤ n ≤ 10^9) — the number Alice shows Bob.\\n\\nOutput\\n\\nFor each test case, output one integer — the number of ordered pairs of positive integers such that when Alice adds them, she will get a result of n. \\n\\nExample\\n\\nInput\\n\\n\\n5\\n100\\n12\\n8\\n2021\\n10000\\n\\n\\nOutput\\n\\n\\n9\\n4\\n7\\n44\\n99\\n\\nNote\\n\\nIn the first test case, when Alice evaluates any of the sums 1 + 9, 2 + 8, 3 + 7, 4 + 6, 5 + 5, 6 + 4, 7 + 3, 8 + 2, or 9 + 1, she will get a result of 100. The picture below shows how Alice evaluates 6 + 4: \\n\\n\\nUsing java can you solve the prior task?\",\"targets\":\"import java.util.Scanner;\\n\\npublic class Carrying_Conundrum {\\n public static void main(String[] args) {\\n Scanner sc = new Scanner(System.in);\\n int t= sc.nextInt();\\n for (int i = 0; i < t; i++){\\n int n = sc.nextInt();\\n if (n \\/ 10 == 0){\\n System.out.println(n-1);\\n }else {\\n int a = 0, b = 0;\\n int cnt = 0;\\n boolean flag = false;\\n while (n > 0){\\n int num = n % 10;\\n if (!flag){\\n a += num *Math.pow(10,cnt);\\n }else {\\n b += num * Math.pow(10,cnt++);\\n }\\n flag = !flag;\\n n \\/= 10;\\n }\\n System.out.println((a+1)*(b+1)-2);\\n }\\n }\\n sc.close();\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nC: Digital Clock\\n\\nstory\\n\\nAizu Nyan has recently caught a cold. I can't get out of bed because I'm too lazy. The spicy appearance is also cute.\\n\\nHowever, Aizu Nyan, who had no choice but to spare time, came up with a way to play with the digital clock under the pillow. The number of glowing bars of a digital clock as shown in the figure below is counted every second, just earnestly.\\n\\n\\n\\nAfter playing this game for several hours, Aizu Nyan noticed that the number of glowing sticks may be the same even if the time is different. I was wondering how many times the number of glowing sticks was the same, and Aizunyan asked you to count it while you were nursing.\\n\\nFor Aizu Nyan who can't get out of bed, you decide to write a program and ask for it.\\n\\nproblem\\n\\nThere is a digital clock like the one shown above that displays the year, month, day, and hour, minute, and second. Answer how many years, months, days, minutes, and seconds the number of glowing bars is exactly N. However, since the digital clock is partially broken, there are some sticks that never shine. Note that even if the display looks the same depending on the non-illuminating stick, if the year, month, day, hour, minute, and second you tried to display are different, they are counted separately.\\n\\nThe shining parts of each number are as shown in the following figure.\\n\\n\\n\\nDigital clocks display the year in 0-sized 4 digits (0000 to 9999) and month, day, hour, minute, and second in 0-sized 2 digits.\\n\\nThe month starts on the 1st, April, 6, 9, November until the 30th, and 1, 3, 5, 7, 8, 10, December until the 31st. February is usually up to 28th, but leap years are up to 29th. Here, a leap year is the following year.\\n\\n1. A year in which the Christian era is divisible by 400 is a leap year.\\n2. The year is not divisible by 400, but the year divisible by 100 is not a leap year.\\n3. The year is not divisible by 100, but the year divisible by 4 is a leap year.\\n4. A year in which the Christian era is not divisible by 4 is not a leap year.\\n\\n\\n\\nThe hours...\",\"targets\":\"#include \\n\\nusing namespace std;\\n\\nusing int64 = long long;\\n\\n\\nint digit[] = {\\n 0b1110111,\\n 0b0010010,\\n 0b1011101,\\n 0b1011011,\\n 0b0111010,\\n 0b1101011,\\n 0b1101111,\\n 0b1010010,\\n 0b1111111,\\n 0b1111011\\n};\\n\\nint main() {\\n\\n for(int i = 0; i < 10; i++) {\\n int rev = 0;\\n for(int j = 0; j < 7; j++) {\\n rev |= ((digit[i] >> (6 - j) & 1)) << j;\\n }\\n digit[i] = rev;\\n }\\n\\n\\n int N, K;\\n int mask[1333] = {};\\n for(int i = 0; i < 1333; i++) {\\n mask[i] = (1 << 8) - 1;\\n }\\n\\n\\n cin >> N >> K;\\n for(int i = 0; i < K; i++) {\\n int p, q;\\n cin >> p >> q;\\n mask[13 - p] ^= 1 << q;\\n }\\n\\n const int m[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};\\n\\n int latte[100] = {}, malta[100] = {};\\n\\n for(int i = 0; i < 10000; i++) {\\n for(int j = 1; j <= 12; j++) {\\n int x = m[j - 1];\\n if(j == 2 && (i % 400 == 0 || (i % 100 != 0 && i % 4 == 0))) {\\n ++x;\\n }\\n for(int k = 1; k <= x; k++) {\\n int bit = i * 10000 + j * 100 + k, add = 0;\\n for(int l = 6; l <= 13; l++) {\\n add += __builtin_popcount(digit[bit % 10] & mask[l]);\\n bit \\/= 10;\\n }\\n latte[add]++;\\n }\\n }\\n }\\n\\n for(int i = 0; i < 24; i++) {\\n for(int j = 0; j < 60; j++) {\\n for(int k = 0; k < 60; k++) {\\n int bit = i * 10000 + j * 100 + k, add = 0;\\n for(int l = 0; l <= 5; l++) {\\n add += __builtin_popcount(digit[bit % 10] & mask[l]);\\n bit \\/= 10;\\n }\\n malta[add]++;\\n }\\n }\\n }\\n\\n int64 ret = 0;\\n for(int i = 0; i <= N; i++) {\\n ret += 1LL * latte[i] * malta[N - i];\\n }\\n cout << ret << endl;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"The only difference between this problem and D1 is that you don't have to provide the way to construct the answer in D1, but you have to do it in this problem.\\n\\nThere's a table of n × m cells (n rows and m columns). The value of n ⋅ m is even.\\n\\nA domino is a figure that consists of two cells having a common side. It may be horizontal (one of the cells is to the right of the other) or vertical (one of the cells is above the other).\\n\\nYou need to place nm\\/2 dominoes on the table so that exactly k of them are horizontal and all the other dominoes are vertical. The dominoes cannot overlap and must fill the whole table.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of a single line. The line contains three integers n, m, k (1 ≤ n,m ≤ 100, 0 ≤ k ≤ nm\\/2, n ⋅ m is even) — the count of rows, columns and horizontal dominoes, respectively.\\n\\nOutput\\n\\nFor each test case:\\n\\n * print \\\"NO\\\" if it's not possible to place the dominoes on the table in the described way; \\n * otherwise, print \\\"YES\\\" on a separate line, then print n lines so that each of them contains m lowercase letters of the Latin alphabet — the layout of the dominoes on the table. Each cell of the table must be marked by the letter so that for every two cells having a common side, they are marked by the same letters if and only if they are occupied by the same domino. I.e. both cells of the same domino must be marked with the same letter, but two dominoes that share a side must be marked with different letters. If there are multiple solutions, print any of them. \\n\\nExample\\n\\nInput\\n\\n\\n8\\n4 4 2\\n2 3 0\\n3 2 3\\n1 2 0\\n2 4 2\\n5 2 2\\n2 17 16\\n2 1 1\\n\\n\\nOutput\\n\\n\\nYES\\naccx\\naegx\\nbega\\nbdda\\nYES\\naha\\naha\\nYES\\nzz\\naa\\nzz\\nNO\\nYES\\naaza\\nbbza\\nNO\\nYES\\nbbaabbaabbaabbaay\\nddccddccddccddccy\\nNO\\nUsing python3 can you solve the prior task?\",\"targets\":\"#from math import *\\n#from bisect import *\\nfrom collections import *\\n#from random import *\\n#from decimal import *\\\"\\\"\\\"\\n#from heapq import *\\n#from random import *\\nimport sys\\ninput=sys.stdin.readline\\n#sys.setrecursionlimit(3*(10**5))\\ndef inp():\\n return int(input())\\ndef st():\\n return input().rstrip('\\\\n')\\ndef lis():\\n return list(map(int,input().split()))\\ndef ma():\\n return map(int,input().split())\\nt=inp()\\ngl={'a':'b','b':'a'}\\ngl1={'c':'d','d':'c'}\\nwhile(t):\\n t-=1\\n n,m,k=ma()\\n if(n%2==m%2 and n%2==0):\\n if(k%2):\\n print(\\\"NO\\\")\\n else:\\n print(\\\"YES\\\")\\n shift=0\\n if(n%4==0):\\n shift=1\\n cur='a'\\n res=[['$' for i in range(m)] for j in range(n)]\\n for i in range(m):\\n for j in range(0,n,2):\\n res[j][i]=cur\\n res[j+1][i]=cur\\n cur=gl[cur]\\n if(shift):\\n cur=gl[cur]\\n shift=0\\n if(m%4==0):\\n shift=1\\n cur='c'\\n for i in range(0,m,2):\\n if(k==0):\\n break\\n for j in range(0,n):\\n k-=1\\n res[j][i]=cur\\n res[j][i+1]=cur\\n cur=gl1[cur]\\n if(k==0):\\n break\\n if(k==0):\\n break\\n if(1):\\n cur=gl1[cur]\\n for i in res:\\n print(''.join(i))\\n \\n else:\\n if(0):\\n if(m%2):\\n print(\\\"NO\\\")\\n else:\\n print(\\\"YES\\\")\\n continue\\n else:\\n tot=k*2\\n if(n%2):\\n re=k-m\\/\\/2\\n if(re>=0 and re%2==0):\\n print(\\\"YES\\\")\\n shift=0\\n if((n-1)%4==0):\\n shift=1\\n cur='a'\\n res=[['$' for i in range(m)] for j in...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A non-empty string is called palindrome, if it reads the same from the left to the right and from the right to the left. For example, \\\"abcba\\\", \\\"a\\\", and \\\"abba\\\" are palindromes, while \\\"abab\\\" and \\\"xy\\\" are not.\\n\\nA string is called a substring of another string, if it can be obtained from that string by dropping some (possibly zero) number of characters from the beginning and from the end of it. For example, \\\"abc\\\", \\\"ab\\\", and \\\"c\\\" are substrings of the string \\\"abc\\\", while \\\"ac\\\" and \\\"d\\\" are not.\\n\\nLet's define a palindromic count of the string as the number of its substrings that are palindromes. For example, the palindromic count of the string \\\"aaa\\\" is 6 because all its substrings are palindromes, and the palindromic count of the string \\\"abc\\\" is 3 because only its substrings of length 1 are palindromes.\\n\\nYou are given a string s. You can arbitrarily rearrange its characters. You goal is to obtain a string with the maximum possible value of palindromic count.\\n\\nInput\\n\\nThe first line contains an integer n (1 ≤ n ≤ 100 000) — the length of string s.\\n\\nThe second line contains string s that consists of exactly n lowercase characters of Latin alphabet.\\n\\nOutput\\n\\nPrint string t, which consists of the same set of characters (and each characters appears exactly the same number of times) as string s. Moreover, t should have the maximum possible value of palindromic count among all such strings strings.\\n\\nIf there are multiple such strings, print any of them.\\n\\nExamples\\n\\nInput\\n\\n5\\noolol\\n\\n\\nOutput\\n\\nololo\\n\\n\\nInput\\n\\n16\\ngagadbcgghhchbdf\\n\\n\\nOutput\\n\\nabccbaghghghgdfd\\n\\nNote\\n\\nIn the first example, string \\\"ololo\\\" has 9 palindromic substrings: \\\"o\\\", \\\"l\\\", \\\"o\\\", \\\"l\\\", \\\"o\\\", \\\"olo\\\", \\\"lol\\\", \\\"olo\\\", \\\"ololo\\\". Note, that even though some substrings coincide, they are counted as many times as they appear in the resulting string.\\n\\nIn the second example, the palindromic count of string \\\"abccbaghghghgdfd\\\" is 29.\\nSolve the task in PYTHON3.\",\"targets\":\"n = input()\\ns = input()\\nprint(''.join(sorted(s)))\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"Grandma Capa has decided to knit a scarf and asked Grandpa Sher to make a pattern for it, a pattern is a string consisting of lowercase English letters. Grandpa Sher wrote a string s of length n.\\n\\nGrandma Capa wants to knit a beautiful scarf, and in her opinion, a beautiful scarf can only be knit from a string that is a palindrome. She wants to change the pattern written by Grandpa Sher, but to avoid offending him, she will choose one lowercase English letter and erase some (at her choice, possibly none or all) occurrences of that letter in string s.\\n\\nShe also wants to minimize the number of erased symbols from the pattern. Please help her and find the minimum number of symbols she can erase to make string s a palindrome, or tell her that it's impossible. Notice that she can only erase symbols equal to the one letter she chose.\\n\\nA string is a palindrome if it is the same from the left to the right and from the right to the left. For example, the strings 'kek', 'abacaba', 'r' and 'papicipap' are palindromes, while the strings 'abb' and 'iq' are not.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. The next 2 ⋅ t lines contain the description of test cases. The description of each test case consists of two lines.\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 10^5) — the length of the string.\\n\\nThe second line of each test case contains the string s consisting of n lowercase English letters.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case print the minimum number of erased symbols required to make the string a palindrome, if it is possible, and -1, if it is impossible.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n8\\nabcaacab\\n6\\nxyzxyz\\n4\\nabba\\n8\\nrprarlap\\n10\\nkhyyhhyhky\\n\\n\\nOutput\\n\\n\\n2\\n-1\\n0\\n3\\n2\\n\\nNote\\n\\nIn the first test case, you can choose a letter 'a' and erase its first and last occurrences, you will get a string 'bcaacb', which is a palindrome. You can also choose a letter 'b' and erase all its occurrences, you...\\\":\",\"targets\":\"import java.util.*;\\n import java.lang.*;\\n import java.io.*;\\n\\npublic class C_Grandma_Capa_Knits_a_Scarf\\n {\\n static int M = 1_000_000_007;\\n static final PrintWriter out =new PrintWriter(System.out);\\n static final FastReader fs = new FastReader();\\n static boolean prime[];\\n public static void main (String[] args) throws java.lang.Exception\\n {\\n \\n int t= fs.nextInt();\\n for(int i=0;i 0)\\n return modMult(x,modMult(temp,temp));\\n else\\n return (modMult(temp,temp)) \\/ x;\\n }\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 solution for \\\"Vupsen and Pupsen were gifted an integer array. Since Vupsen doesn't like the number 0, he threw away all numbers equal to 0 from the array. As a result, he got an array a of length n.\\n\\nPupsen, on the contrary, likes the number 0 and he got upset when he saw the array without zeroes. To cheer Pupsen up, Vupsen decided to come up with another array b of length n such that ∑_{i=1}^{n}a_i ⋅ b_i=0. Since Vupsen doesn't like number 0, the array b must not contain numbers equal to 0. Also, the numbers in that array must not be huge, so the sum of their absolute values cannot exceed 10^9. Please help Vupsen to find any such array b!\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. The next 2 ⋅ t lines contain the description of test cases. The description of each test case consists of two lines.\\n\\nThe first line of each test case contains a single integer n (2 ≤ n ≤ 10^5) — the length of the array.\\n\\nThe second line contains n integers a_1, a_2, …, a_n (-10^4 ≤ a_i ≤ 10^4, a_i ≠ 0) — the elements of the array a.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case print n integers b_1, b_2, …, b_n — elements of the array b (|b_1|+|b_2|+… +|b_n| ≤ 10^9, b_i ≠ 0, ∑_{i=1}^{n}a_i ⋅ b_i=0).\\n\\nIt can be shown that the answer always exists.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n2\\n5 5\\n5\\n5 -2 10 -9 4\\n7\\n1 2 3 4 5 6 7\\n\\n\\nOutput\\n\\n\\n1 -1\\n-1 5 1 -1 -1\\n-10 2 2 -3 5 -1 -1\\n\\nNote\\n\\nIn the first test case, 5 ⋅ 1 + 5 ⋅ (-1)=5-5=0. You could also print 3 -3, for example, since 5 ⋅ 3 + 5 ⋅ (-3)=15-15=0\\n\\nIn the second test case, 5 ⋅ (-1) + (-2) ⋅ 5 + 10 ⋅ 1 + (-9) ⋅ (-1) + 4 ⋅ (-1)=-5-10+10+9-4=0.\\\":\",\"targets\":\"import sys\\nimport math\\n\\ninp = sys.stdin.readline\\n\\n\\ndef solve():\\n n = int(inp())\\n a = list(map(int, inp().split()))\\n c = [None] * n\\n h = 0\\n for i in range(n - 2):\\n if abs(h + a[i]) <= abs(h - a[i]):\\n h += a[i]\\n c[i] = 1\\n else:\\n h -= a[i]\\n c[i] = -1\\n i = n - 2\\n if i >= 0:\\n if h + a[i] != 0:\\n h += a[i]\\n c[i] = 1\\n else:\\n h -= a[i]\\n c[i] = -1\\n if h == 0:\\n raise Exception('wut')\\n if h < 0:\\n h = -h\\n for i in range(n - 1):\\n c[i] = -c[i]\\n d = a[-1]\\n e = 1\\n if d < 0:\\n e = -1\\n d = -d\\n #print(c, h, e, d)\\n lcm = h * d \\/\\/ math.gcd(h, d)\\n x = lcm \\/\\/ h\\n c[-1] = -lcm \\/\\/ d * e\\n for i in range(n - 1):\\n c[i] *= x\\n h = 0\\n for i in range(n):\\n h += c[i] * a[i]\\n #print(h)\\n print(' '.join(map(str, c)))\\n\\n\\ndef main():\\n for i in range(int(inp())):\\n solve()\\n\\n\\nif __name__ == '__main__':\\n main()\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"When you play the game of thrones, you win, or you die. There is no middle ground.\\n\\nCersei Lannister, A Game of Thrones by George R. R. Martin\\n\\nThere are n nobles, numbered from 1 to n. Noble i has a power of i. There are also m \\\"friendships\\\". A friendship between nobles a and b is always mutual.\\n\\nA noble is defined to be vulnerable if both of the following conditions are satisfied: \\n\\n * the noble has at least one friend, and \\n * all of that noble's friends have a higher power. \\n\\n\\n\\nYou will have to process the following three types of queries. \\n\\n 1. Add a friendship between nobles u and v. \\n 2. Remove a friendship between nobles u and v. \\n 3. Calculate the answer to the following process. \\n\\n\\n\\nThe process: all vulnerable nobles are simultaneously killed, and all their friendships end. Then, it is possible that new nobles become vulnerable. The process repeats itself until no nobles are vulnerable. It can be proven that the process will end in finite time. After the process is complete, you need to calculate the number of remaining nobles.\\n\\nNote that the results of the process are not carried over between queries, that is, every process starts with all nobles being alive!\\n\\nInput\\n\\nThe first line contains the integers n and m (1 ≤ n ≤ 2⋅ 10^5, 0 ≤ m ≤ 2⋅ 10^5) — the number of nobles and number of original friendships respectively.\\n\\nThe next m lines each contain the integers u and v (1 ≤ u,v ≤ n, u ≠ v), describing a friendship. No friendship is listed twice.\\n\\nThe next line contains the integer q (1 ≤ q ≤ 2⋅ {10}^{5}) — the number of queries. \\n\\nThe next q lines contain the queries themselves, each query has one of the following three formats. \\n\\n * 1 u v (1 ≤ u,v ≤ n, u ≠ v) — add a friendship between u and v. It is guaranteed that u and v are not friends at this moment. \\n * 2 u v (1 ≤ u,v ≤ n, u ≠ v) — remove a friendship between u and v. It is guaranteed that u and v are friends at this moment. \\n * 3 — print the answer to the process described in the statement. \\n\\nOutput\\n\\nFor each type 3 query print one...\\nSolve the task in JAVA.\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.util.HashMap;\\nimport java.util.Scanner;\\nimport java.util.StringTokenizer;\\n\\npublic class webOflies {\\n\\t\\n\\tstatic class FastReader {\\n\\t\\tBufferedReader br;\\n\\t\\tStringTokenizer st;\\n\\n\\t\\tpublic FastReader() {\\n\\t\\t\\tbr = new BufferedReader(new InputStreamReader(System.in));\\n\\t\\t}\\n\\n\\t\\tString next() {\\n\\t\\t\\twhile (st == null || !st.hasMoreElements()) {\\n\\t\\t\\t\\ttry {\\n\\t\\t\\t\\t\\tst = new StringTokenizer(br.readLine());\\n\\t\\t\\t\\t} catch (IOException e) {\\n\\t\\t\\t\\t\\te.printStackTrace();\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\treturn st.nextToken();\\n\\t\\t}\\n\\n\\t\\tint nextInt() {\\n\\t\\t\\treturn Integer.parseInt(next());\\n\\t\\t}\\n\\n\\t\\tlong nextLong() {\\n\\t\\t\\treturn Long.parseLong(next());\\n\\t\\t}\\n\\n\\t\\tdouble nextDouble() {\\n\\t\\t\\treturn Double.parseDouble(next());\\n\\t\\t}\\n\\n\\t\\tString nextLine() {\\n\\t\\t\\tString str = \\\"\\\";\\n\\t\\t\\ttry {\\n\\t\\t\\t\\tstr = br.readLine();\\n\\t\\t\\t} catch (IOException e) {\\n\\t\\t\\t\\te.printStackTrace();\\n\\t\\t\\t}\\n\\t\\t\\treturn str;\\n\\t\\t}\\n\\t}\\n\\tpublic static void main(String[] args) {\\n\\t\\t\\/\\/ TODO Auto-generated method stub\\n\\t\\tFastReader sc=new FastReader();\\n\\t\\tint n=sc.nextInt();\\n\\t\\tint m=sc.nextInt();\\n\\t\\tint arr[]=new int[200050];\\n\\t\\tint count=0;\\n\\t\\tfor(int i=1;i<=m;i++)\\n\\t\\t{\\n\\t\\t\\tint u=sc.nextInt();\\n\\t\\t\\tint v=sc.nextInt();\\n\\t\\t\\tint min=Math.min(u, v);\\n\\t\\t\\tarr[min]=++arr[min];\\n\\t\\t\\tif(arr[min]==1)\\n\\t\\t\\t\\tcount++;\\n\\t\\t}\\n\\t\\t\\/\\/for(int i=0;i<5;i++)\\n\\t\\t\\t\\/\\/System.out.println(arr[i]);\\n\\t\\tint q=sc.nextInt();\\n\\t\\twhile(q-->0)\\n\\t\\t{\\n\\t\\t\\tint t=sc.nextInt();\\n\\t\\t\\tif(t==1)\\n\\t\\t\\t{\\n\\t\\t\\t\\tint u=sc.nextInt();\\n\\t\\t\\t\\tint v=sc.nextInt();\\n\\t\\t\\t\\tint min=Math.min(u, v);\\n\\t\\t\\t\\tarr[min]=++arr[min];\\n\\t\\t\\t\\tif(arr[min]==1)\\n\\t\\t\\t\\t\\tcount++;\\n\\t\\t\\t}\\n\\t\\t\\tif(t==2)\\n\\t\\t\\t{\\n\\t\\t\\t\\tint u=sc.nextInt();\\n\\t\\t\\t\\tint v=sc.nextInt();\\n\\t\\t\\t\\tint min=Math.min(u, v);\\n\\t\\t\\t\\tarr[min]=--arr[min];\\n\\t\\t\\t\\tif(arr[min]==0)\\n\\t\\t\\t\\t\\tcount--;\\n\\t\\t\\t}\\n\\t\\t\\tif(t==3)\\n\\t\\t\\t\\tSystem.out.println(n-count);\\n\\t\\t}\\n\\t}\\n\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Ehab has an array a of length n. He has just enough free time to make a new array consisting of n copies of the old array, written back-to-back. What will be the length of the new array's longest increasing subsequence?\\n\\nA sequence a is a subsequence of an array b if a can be obtained from b by deletion of several (possibly, zero or all) elements. The longest increasing subsequence of an array is the longest subsequence such that its elements are ordered in strictly increasing order.\\n\\nInput\\n\\nThe first line contains an integer t — the number of test cases you need to solve. The description of the test cases follows.\\n\\nThe first line of each test case contains an integer n (1 ≤ n ≤ 10^5) — the number of elements in the array a.\\n\\nThe second line contains n space-separated integers a_1, a_2, …, a_{n} (1 ≤ a_i ≤ 10^9) — the elements of the array a.\\n\\nThe sum of n across the test cases doesn't exceed 10^5.\\n\\nOutput\\n\\nFor each testcase, output the length of the longest increasing subsequence of a if you concatenate it to itself n times.\\n\\nExample\\n\\nInput\\n\\n\\n2\\n3\\n3 2 1\\n6\\n3 1 4 1 5 9\\n\\n\\nOutput\\n\\n\\n3\\n5\\n\\nNote\\n\\nIn the first sample, the new array is [3,2,1,3,2,1,3,2,1]. The longest increasing subsequence is marked in bold.\\n\\nIn the second sample, the longest increasing subsequence will be [1,3,4,5,9].\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.InputStreamReader;\\nimport java.util.*;\\npublic class cdf628b\\n{\\n\\tstatic void merge(int arr[], int l, int m, int r) \\n { \\n int n1 = m - l + 1; \\n int n2 = r - m; \\n int L[] = new int [n1]; \\n int R[] = new int [n2]; \\n for (int i=0; i\\nusing namespace std;\\nconst long long int mod = 1e9 + 7;\\nvoid solve() {\\n string s;\\n cin >> s;\\n int cntr1 = 10, cntr2 = 10;\\n int wt1 = 0, wt2 = 0;\\n for (int i = 0; i < 10; i++) {\\n if (i % 2 == 0) {\\n if (s[i] == '1' || s[i] == '?') wt1++;\\n } else {\\n if (s[i] == '1') wt2++;\\n }\\n int left_t1 = 0, left_t2 = 0;\\n for (int j = i + 1; j < 10; j++) {\\n if (j % 2 == 0) {\\n left_t1++;\\n } else {\\n left_t2++;\\n }\\n }\\n if (wt1 > wt2 + left_t2) {\\n cntr1 = i + 1;\\n break;\\n }\\n if (wt2 > wt1 + left_t1) {\\n cntr1 = i + 1;\\n break;\\n }\\n }\\n wt1 = 0, wt2 = 0;\\n for (int i = 0; i < 10; i++) {\\n if (i % 2 == 0) {\\n if (s[i] == '1') wt1++;\\n } else {\\n if (s[i] == '1' || s[i] == '?') wt2++;\\n }\\n int left_t1 = 0, left_t2 = 0;\\n for (int j = i + 1; j < 10; j++) {\\n if (j % 2 == 0) {\\n left_t1++;\\n } else {\\n left_t2++;\\n }\\n }\\n if (wt1 > wt2 + left_t2) {\\n cntr2 = i + 1;\\n break;\\n }\\n if (wt2 > wt1 + left_t1) {\\n cntr2 = i + 1;\\n break;\\n }\\n }\\n cout << min(cntr1, cntr2);\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n int t;\\n cin >> t;\\n while (t-- > 0) {\\n solve();\\n cout << \\\"\\\\n\\\";\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"During one of the space missions, humans have found an evidence of previous life at one of the planets. They were lucky enough to find a book with birth and death years of each individual that had been living at this planet. What's interesting is that these years are in the range (1, 10^9)! Therefore, the planet was named Longlifer.\\n\\nIn order to learn more about Longlifer's previous population, scientists need to determine the year with maximum number of individuals that were alive, as well as the number of alive individuals in that year. Your task is to help scientists solve this problem!\\n\\nInput\\n\\nThe first line contains an integer n (1 ≤ n ≤ 10^5) — the number of people.\\n\\nEach of the following n lines contain two integers b and d (1 ≤ b < d ≤ 10^9) representing birth and death year (respectively) of each individual.\\n\\nOutput\\n\\nPrint two integer numbers separated by blank character, y — the year with a maximum number of people alive and k — the number of people alive in year y.\\n\\nIn the case of multiple possible solutions, print the solution with minimum year.\\n\\nExamples\\n\\nInput\\n\\n\\n3\\n1 5\\n2 4\\n5 6\\n\\n\\nOutput\\n\\n\\n2 2\\n\\n\\nInput\\n\\n\\n4\\n3 4\\n4 5\\n4 6\\n8 10\\n\\n\\nOutput\\n\\n\\n4 2\\n\\nNote\\n\\nYou can assume that an individual living from b to d has been born at the beginning of b and died at the beginning of d, and therefore living for d - b years.\\nUsing java can you solve the prior task?\",\"targets\":\"\\/\\/package codeforces.bubble_cup_final_mirror._13;\\n\\nimport java.util.*;\\n\\npublic class G_Years {\\n static class Event {\\n int year;\\n boolean birth;\\n\\n public Event(int year, boolean birth) {\\n this.year = year;\\n this.birth = birth;\\n }\\n }\\n\\n public static void main(String[] args) {\\n Scanner scanner = new Scanner(System.in);\\n int n = scanner.nextInt();\\n List eventList = new ArrayList<>();\\n\\n for (int i = 0; i < n; i++) {\\n int birth = scanner.nextInt();\\n int death = scanner.nextInt();\\n eventList.add(new Event(birth, true));\\n eventList.add(new Event(death, false));\\n }\\n int maxYearWithAlive = -1;\\n int maxAlive = 0;\\n Collections.sort(eventList, (e1, e2) -> {\\n if (e1.year == e2.year) {\\n if (e1.birth) return 1;\\n return -1;\\n }\\n return Integer.compare(e1.year, e2.year);\\n });\\n int currentAlive = 0;\\n for (int i = 0; i < eventList.size(); i++) {\\n Event event = eventList.get(i);\\n if (event.birth) {\\n currentAlive++;\\n if (currentAlive > maxAlive) {\\n maxAlive = currentAlive;\\n maxYearWithAlive = event.year;\\n }\\n } else {\\n currentAlive--;\\n }\\n }\\n System.out.println(maxYearWithAlive + \\\" \\\" + maxAlive);\\n\\n }\\n\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Mr. Chanek has a new game called Dropping Balls. Initially, Mr. Chanek has a grid a of size n × m\\n\\nEach cell (x,y) contains an integer a_{x,y} denoting the direction of how the ball will move.\\n\\n * a_{x,y}=1 — the ball will move to the right (the next cell is (x, y + 1)); \\n * a_{x,y}=2 — the ball will move to the bottom (the next cell is (x + 1, y)); \\n * a_{x,y}=3 — the ball will move to the left (the next cell is (x, y - 1)). \\n\\n\\n\\nEvery time a ball leaves a cell (x,y), the integer a_{x,y} will change to 2. Mr. Chanek will drop k balls sequentially, each starting from the first row, and on the c_1, c_2, ..., c_k-th (1 ≤ c_i ≤ m) columns.\\n\\nDetermine in which column each ball will end up in (position of the ball after leaving the grid).\\n\\nInput\\n\\nThe first line contains three integers n, m, and k (1 ≤ n, m ≤ 1000, 1 ≤ k ≤ 10^5) — the size of the grid and the number of balls dropped by Mr. Chanek.\\n\\nThe i-th of the next n lines contains m integers a_{i,1},a_{i,2},…,a_{i,m} (1 ≤ a_{i,j} ≤ 3). It will satisfy a_{i, 1} ≠ 3 and a_{i, m} ≠ 1.\\n\\nThe next line contains k integers c_1, c_2, …, c_k (1 ≤ c_i ≤ m) — the balls' column positions dropped by Mr. Chanek sequentially.\\n\\nOutput\\n\\nOutput k integers — the i-th integer denoting the column where the i-th ball will end.\\n\\nExamples\\n\\nInput\\n\\n\\n5 5 3\\n1 2 3 3 3\\n2 2 2 2 2\\n2 2 2 2 2\\n2 2 2 2 2\\n2 2 2 2 2\\n1 2 1\\n\\n\\nOutput\\n\\n\\n2 2 1 \\n\\n\\nInput\\n\\n\\n1 2 2\\n1 3\\n1 2\\n\\n\\nOutput\\n\\n\\n1 2 \\n\\nNote\\n\\nIn the first example, the first ball will drop as follows. Note that the cell (1, 1) will change direction to the bottom direction.\\n\\n\\n\\nThe second and third balls will drop as follows. \\n\\n\\n\\nAll balls will be dropped from the first row and on the c_1, c_2, ..., c_k-th columns respectively. A ball will stop dropping once it leaves the grid.\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nlong long solve();\\nvector a;\\nstring s;\\nlong long n;\\nint32_t main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n long long t = 1;\\n while (t--) {\\n solve();\\n }\\n return 0;\\n}\\nlong long in(vector &a, long long n) {\\n long long i = 0, x, sum = 0;\\n for (i = 0; i < n; i++) {\\n cin >> x;\\n a.push_back({x});\\n }\\n return sum;\\n}\\nlong long cnt[1001][1001];\\nlong long mat[1001][1001];\\nlong long m;\\nlong long find(long long row, long long curcolumn) {\\n if (row == n + 1) return curcolumn;\\n long long ans;\\n if (mat[row][curcolumn] == 1) {\\n mat[row][curcolumn] = 2;\\n ans = find(row, curcolumn + 1);\\n if (row < n)\\n cnt[row][curcolumn] = 1 + cnt[row + 1][curcolumn];\\n else\\n cnt[row][curcolumn] = 1;\\n return ans;\\n }\\n if (mat[row][curcolumn] == 3) {\\n mat[row][curcolumn] = 2;\\n ans = find(row, curcolumn - 1);\\n if (row < n)\\n cnt[row][curcolumn] = 1 + cnt[row + 1][curcolumn];\\n else\\n cnt[row][curcolumn] = 1;\\n return ans;\\n }\\n if (cnt[row][curcolumn]) {\\n ans = find(row + cnt[row][curcolumn], curcolumn);\\n } else\\n ans = find(row + 1, curcolumn);\\n if (row < n)\\n cnt[row][curcolumn] = 1 + cnt[row + 1][curcolumn];\\n else\\n cnt[row][curcolumn] = 1;\\n return ans;\\n}\\nlong long solve() {\\n a.clear();\\n s.clear();\\n long long i = 0, j = 0, k = 0;\\n long long flag = 0;\\n long long x = 0, y = 0, z = 0;\\n cin >> n;\\n cin >> m >> k;\\n memset(cnt, 0, sizeof(cnt));\\n for (i = 1; i <= n; i++) {\\n for (j = 1; j <= m; j++) {\\n cin >> mat[i][j];\\n }\\n }\\n long long col;\\n for (i = 0; i < k; i++) {\\n cin >> col;\\n cout << find(1, col) << \\\"\\\\n\\\";\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Monocarp has got an array a consisting of n integers. Let's denote k as the mathematic mean of these elements (note that it's possible that k is not an integer). \\n\\nThe mathematic mean of an array of n elements is the sum of elements divided by the number of these elements (i. e. sum divided by n).\\n\\nMonocarp wants to delete exactly two elements from a so that the mathematic mean of the remaining (n - 2) elements is still equal to k.\\n\\nYour task is to calculate the number of pairs of positions [i, j] (i < j) such that if the elements on these positions are deleted, the mathematic mean of (n - 2) remaining elements is equal to k (that is, it is equal to the mathematic mean of n elements of the original array a).\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.\\n\\nThe first line of each testcase contains one integer n (3 ≤ n ≤ 2 ⋅ 10^5) — the number of elements in the array.\\n\\nThe second line contains a sequence of integers a_1, a_2, ..., a_n (0 ≤ a_i ≤ 10^{9}), where a_i is the i-th element of the array.\\n\\nThe sum of n over all testcases doesn't exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nPrint one integer — the number of pairs of positions [i, j] (i < j) such that if the elements on these positions are deleted, the mathematic mean of (n - 2) remaining elements is equal to k (that is, it is equal to the mathematic mean of n elements of the original array a).\\n\\nExample\\n\\nInput\\n\\n\\n4\\n4\\n8 8 8 8\\n3\\n50 20 10\\n5\\n1 4 7 3 5\\n7\\n1 2 3 4 5 6 7\\n\\n\\nOutput\\n\\n\\n6\\n0\\n2\\n3\\n\\nNote\\n\\nIn the first example, any pair of elements can be removed since all of them are equal.\\n\\nIn the second example, there is no way to delete two elements so the mathematic mean doesn't change.\\n\\nIn the third example, it is possible to delete the elements on positions 1 and 3, or the elements on positions 4 and 5.\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nvoid solve() {\\n long long n;\\n cin >> n;\\n long long arr[n];\\n long long sum = 0;\\n for (long long i = 0; i < n; i++) {\\n cin >> arr[i];\\n sum += arr[i];\\n }\\n long long target = 2 * sum \\/ n;\\n if ((sum - target) * n != sum * (n - 2)) {\\n cout << 0 << '\\\\n';\\n return;\\n }\\n map mp;\\n long long ans = 0;\\n for (long long i = 0; i < n; i++) {\\n ans += mp[target - arr[i]];\\n mp[arr[i]]++;\\n }\\n cout << ans << '\\\\n';\\n}\\nsigned main() {\\n ios::sync_with_stdio(0);\\n cin.tie(0);\\n long long t;\\n cin >> t;\\n while (t--) solve();\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"It turns out that the meaning of life is a permutation p_1, p_2, …, p_n of the integers 1, 2, …, n (2 ≤ n ≤ 100). Omkar, having created all life, knows this permutation, and will allow you to figure it out using some queries.\\n\\nA query consists of an array a_1, a_2, …, a_n of integers between 1 and n. a is not required to be a permutation. Omkar will first compute the pairwise sum of a and p, meaning that he will compute an array s where s_j = p_j + a_j for all j = 1, 2, …, n. Then, he will find the smallest index k such that s_k occurs more than once in s, and answer with k. If there is no such index k, then he will answer with 0.\\n\\nYou can perform at most 2n queries. Figure out the meaning of life p.\\n\\nInteraction\\n\\nStart the interaction by reading single integer n (2 ≤ n ≤ 100) — the length of the permutation p.\\n\\nYou can then make queries. A query consists of a single line \\\"? \\\\enspace a_1 \\\\enspace a_2 \\\\enspace … \\\\enspace a_n\\\" (1 ≤ a_j ≤ n).\\n\\nThe answer to each query will be a single integer k as described above (0 ≤ k ≤ n).\\n\\nAfter making a query do not forget to output end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use:\\n\\n * fflush(stdout) or cout.flush() in C++;\\n * System.out.flush() in Java;\\n * flush(output) in Pascal;\\n * stdout.flush() in Python;\\n * see documentation for other languages.\\n\\n\\n\\nTo output your answer, print a single line \\\"! \\\\enspace p_1 \\\\enspace p_2 \\\\enspace … \\\\enspace p_n\\\" then terminate.\\n\\nYou can make at most 2n queries. Outputting the answer does not count as a query.\\n\\nHack Format\\n\\nTo hack, first output a line containing n (2 ≤ n ≤ 100), then output another line containing the hidden permutation p_1, p_2, …, p_n of numbers from 1 to n.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n\\n2\\n\\n0\\n\\n1\\n\\n\\nOutput\\n\\n\\n\\n? 4 4 2 3 2\\n\\n? 3 5 1 5 5\\n\\n? 5 2 4 3 1\\n\\n! 3 2 1 5 4\\n\\nNote\\n\\nIn the sample, the hidden permutation p is [3, 2, 1, 5, 4]. Three queries were made.\\n\\nThe first query is a = [4, 4, 2, 3, 2]. This yields s = [3 + 4, 2 + 4, 1 + 2, 5 + 3, 4 + 2] = [7, 6, 3, 8, 6]. 6 is the only...\\nSolve the task in JAVA.\",\"targets\":\"\\/\\/ Generated by Code Flattener.\\n\\/\\/ https:\\/\\/plugins.jetbrains.com\\/plugin\\/9979-idea-code-flattener\\n\\nimport java.io.*;\\nimport java.util.StringTokenizer;\\n\\npublic class Main {\\n public static void main(String[] args) {\\n Solution solution = new ASolution();\\n boolean local = System.getProperty(\\\"ONLINE_JUDGE\\\") == null && !solution.isInteractive();\\n String input = local ? \\\"input.txt\\\" : null;\\n solution.in = new MyScanner(input);\\n solution.out = MyWriter.of(null);\\n solution.bm = new Benchmark();\\n solution.al = new Algorithm();\\n solution.run();\\n solution.close();\\n }\\n\\n private abstract static class Solution {\\n public MyScanner in;\\n public MyWriter out;\\n public Benchmark bm;\\n public Algorithm al;\\n\\n public void init() {\\n }\\n\\n public abstract void solve();\\n\\n protected boolean isMultiTest() {\\n return true;\\n }\\n\\n public void run() {\\n init();\\n if (isMultiTest()) {\\n int t = in.nextInt();\\n for (int i = 0; i < t; i++) {\\n solve();\\n }\\n } else {\\n solve();\\n }\\n }\\n\\n public void close() {\\n out.close();\\n }\\n\\n public boolean isInteractive() {\\n return false;\\n }\\n }\\n\\n private static class ASolution extends Solution {\\n int ask(int[] a) {\\n for (int i = 0; i < a.length; i++) {\\n a[i]++;\\n }\\n out.print(\\\"? \\\");\\n for (int el : a) {\\n out.print(el + \\\" \\\");\\n }\\n out.println();\\n out.flush();\\n return in.nextInt();\\n }\\n\\n public void solve() {\\n int n = in.nextInt();\\n\\n int lastNum = n;\\n int l = 1;\\n int r = n - 1;\\n while (l <= r) {\\n int m = (l + r) \\/ 2;\\n int[] a = new int[n];\\n a[n - 1] = m;\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given two integers l and r, l≤ r. Find the largest possible value of a mod b over all pairs (a, b) of integers for which r≥ a ≥ b ≥ l.\\n\\nAs a reminder, a mod b is a remainder we get when dividing a by b. For example, 26 mod 8 = 2.\\n\\nInput\\n\\nEach test contains multiple test cases.\\n\\nThe first line contains one positive integer t (1≤ t≤ 10^4), denoting the number of test cases. Description of the test cases follows.\\n\\nThe only line of each test case contains two integers l, r (1≤ l ≤ r ≤ 10^9).\\n\\nOutput\\n\\nFor every test case, output the largest possible value of a mod b over all pairs (a, b) of integers for which r≥ a ≥ b ≥ l.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n1 1\\n999999999 1000000000\\n8 26\\n1 999999999\\n\\n\\nOutput\\n\\n\\n0\\n1\\n12\\n499999999\\n\\nNote\\n\\nIn the first test case, the only allowed pair is (a, b) = (1, 1), for which a mod b = 1 mod 1 = 0.\\n\\nIn the second test case, the optimal choice is pair (a, b) = (1000000000, 999999999), for which a mod b = 1.\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nvoid solve(int test_case) {\\n int a, b;\\n cin >> a >> b;\\n cout << b % max(b \\/ 2 + 1, a) << \\\"\\\\n\\\";\\n}\\nint main() {\\n ios::sync_with_stdio(false);\\n cin.tie(nullptr);\\n int t;\\n cin >> t;\\n for (int test_case = 1; test_case <= t; ++test_case) {\\n solve(test_case);\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given an array a of n integers, and another integer k such that 2k ≤ n.\\n\\nYou have to perform exactly k operations with this array. In one operation, you have to choose two elements of the array (let them be a_i and a_j; they can be equal or different, but their positions in the array must not be the same), remove them from the array, and add ⌊ (a_i)\\/(a_j) ⌋ to your score, where ⌊ x\\/y ⌋ is the maximum integer not exceeding x\\/y.\\n\\nInitially, your score is 0. After you perform exactly k operations, you add all the remaining elements of the array to the score.\\n\\nCalculate the minimum possible score you can get.\\n\\nInput\\n\\nThe first line of the input contains one integer t (1 ≤ t ≤ 500) — the number of test cases.\\n\\nEach test case consists of two lines. The first line contains two integers n and k (1 ≤ n ≤ 100; 0 ≤ k ≤ ⌊ n\\/2 ⌋).\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 2 ⋅ 10^5).\\n\\nOutput\\n\\nPrint one integer — the minimum possible score you can get.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n7 3\\n1 1 1 2 1 3 1\\n5 1\\n5 5 5 5 5\\n4 2\\n1 3 3 7\\n2 0\\n4 2\\n9 2\\n1 10 10 1 10 2 7 10 3\\n\\n\\nOutput\\n\\n\\n2\\n16\\n0\\n6\\n16\\n\\nNote\\n\\nLet's consider the example test.\\n\\nIn the first test case, one way to obtain a score of 2 is the following one:\\n\\n 1. choose a_7 = 1 and a_4 = 2 for the operation; the score becomes 0 + ⌊ 1\\/2 ⌋ = 0, the array becomes [1, 1, 1, 1, 3]; \\n 2. choose a_1 = 1 and a_5 = 3 for the operation; the score becomes 0 + ⌊ 1\\/3 ⌋ = 0, the array becomes [1, 1, 1]; \\n 3. choose a_1 = 1 and a_2 = 1 for the operation; the score becomes 0 + ⌊ 1\\/1 ⌋ = 1, the array becomes [1]; \\n 4. add the remaining element 1 to the score, so the resulting score is 2. \\n\\n\\n\\nIn the second test case, no matter which operations you choose, the resulting score is 16.\\n\\nIn the third test case, one way to obtain a score of 0 is the following one:\\n\\n 1. choose a_1 = 1 and a_2 = 3 for the operation; the score becomes 0 + ⌊ 1\\/3 ⌋ = 0, the array becomes [3, 7]; \\n 2. choose a_1 = 3 and a_2 = 7 for the operation; the score becomes 0 + ⌊ 3\\/7 ⌋ = 0, the array becomes...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nint main() {\\n int t;\\n cin >> t;\\n while (t--) {\\n int n, k;\\n cin >> n >> k;\\n vector a(n);\\n for (int i = 0; i < (n); i++) cin >> a[i];\\n sort((a).rbegin(), (a).rend());\\n vector v(k * 2);\\n long long tot = 0;\\n for (int i = 0; i < (n); i++) {\\n if (i < k * 2)\\n v[i] = a[i];\\n else\\n tot += a[i];\\n }\\n for (int i = 0; i < (k); i++) tot += v[i + k] \\/ v[i];\\n cout << tot << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"There are n heaps of stone. The i-th heap has h_i stones. You want to change the number of stones in the heap by performing the following process once: \\n\\n * You go through the heaps from the 3-rd heap to the n-th heap, in this order. \\n * Let i be the number of the current heap. \\n * You can choose a number d (0 ≤ 3 ⋅ d ≤ h_i), move d stones from the i-th heap to the (i - 1)-th heap, and 2 ⋅ d stones from the i-th heap to the (i - 2)-th heap. \\n * So after that h_i is decreased by 3 ⋅ d, h_{i - 1} is increased by d, and h_{i - 2} is increased by 2 ⋅ d. \\n * You can choose different or same d for different operations. Some heaps may become empty, but they still count as heaps. \\n\\n\\n\\nWhat is the maximum number of stones in the smallest heap after the process?\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 2⋅ 10^5). Description of the test cases follows.\\n\\nThe first line of each test case contains a single integer n (3 ≤ n ≤ 2 ⋅ 10^5).\\n\\nThe second lines of each test case contains n integers h_1, h_2, h_3, …, h_n (1 ≤ h_i ≤ 10^9).\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print the maximum number of stones that the smallest heap can contain.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n4\\n1 2 10 100\\n4\\n100 100 100 1\\n5\\n5 1 1 1 8\\n6\\n1 2 3 4 5 6\\n\\n\\nOutput\\n\\n\\n7\\n1\\n1\\n3\\n\\nNote\\n\\nIn the first test case, the initial heap sizes are [1, 2, 10, 100]. We can move the stones as follows. \\n\\n * move 3 stones and 6 from the 3-rd heap to the 2-nd and 1 heap respectively. The heap sizes will be [7, 5, 1, 100]; \\n * move 6 stones and 12 stones from the last heap to the 3-rd and 2-nd heap respectively. The heap sizes will be [7, 17, 7, 82]. \\n\\n\\n\\nIn the second test case, the last heap is 1, and we can not increase its size.\\n\\nIn the third test case, it is better not to move any stones.\\n\\nIn the last test case, the final achievable configuration of the heaps can be [3, 5, 3, 4, 3, 3].\\ndef s\",\"targets\":\"olve(n, k, a):\\n ex = [0 for i in a]\\n for i in range(n - 1, 1, -1):\\n s = a[i] + ex[i]\\n if s < k:\\n return False\\n sh = a[i] - max(k - ex[i], 0)\\n ex[i - 1] += sh \\/\\/ 3\\n ex[i - 2] += 2 * (sh \\/\\/ 3)\\n return a[0] + ex[0] >= k and a[1] + ex[1] >= k\\n\\n\\nt = int(input())\\n\\nfor _ in range(t):\\n n = int(input())\\n a = list(map(int, input().split()))\\n\\n l=min(a)\\n r = max(a)\\n ans = l\\n while r >= l:\\n m = l + (r-l)\\/\\/2\\n if solve(n, m, a):\\n ans = max(ans, m)\\n l = m+1\\n else:\\n r = m-1\\n print(ans)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CQXYM is counting permutations length of 2n.\\n\\nA permutation is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice in the array) and [1,3,4] is also not a permutation (n=3 but there is 4 in the array).\\n\\nA permutation p(length of 2n) will be counted only if the number of i satisfying p_ip_2. Because 0\\n#pragma GCC optimize(\\\"O3\\\")\\nusing namespace std;\\nlong long bp(long long a, long long b, long long mod) {\\n if (b == 0LL) return 1LL;\\n if (b % 2LL == 0LL) {\\n long long tmp = bp(a, b \\/ 2LL, mod);\\n return tmp * tmp % mod;\\n }\\n return a * bp(a, b - 1LL, mod) % mod;\\n}\\nint solve() {\\n long long n;\\n cin >> n;\\n if (n == 1LL) return cout << 1 << '\\\\n', 0;\\n long long ans = 1;\\n for (long long i = 2; i <= 2LL * n; ++i) {\\n ans = (ans * i) % (long long)(1e9 + 7LL);\\n }\\n cout << ans * bp(2, 1e9 + 5, 1e9 + 7) % (long long)(1e9 + 7LL) << '\\\\n';\\n return 0;\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n int t = 1;\\n cin >> t;\\n while (t--) {\\n solve();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nLet G be a simple graph. Let W be a non-empty subset of vertices. Then W is almost-k-uniform if for each pair of distinct vertices u,v ∈ W the distance between u and v is either k or k+1.\\n\\nYou are given a tree on n vertices. For each i between 1 and n, find the maximum size of an almost-i-uniform set.\\n\\nInput\\n\\nThe first line contains a single integer n (2 ≤ n ≤ 5 ⋅ 10^5) – the number of vertices of the tree.\\n\\nThen n-1 lines follows, the i-th of which consisting of two space separated integers u_i, v_i (1 ≤ u_i, v_i ≤ n) meaning that there is an edge between vertices u_i and v_i. \\n\\nIt is guaranteed that the given graph is tree. \\n\\nOutput\\n\\nOutput a single line containing n space separated integers a_i, where a_i is the maximum size of an almost-i-uniform set.\\n\\nExamples\\n\\nInput\\n\\n\\n5\\n1 2\\n1 3\\n1 4\\n4 5\\n\\n\\nOutput\\n\\n\\n4 3 2 1 1\\n\\n\\nInput\\n\\n\\n6\\n1 2\\n1 3\\n1 4\\n4 5\\n4 6\\n\\n\\nOutput\\n\\n\\n4 4 2 1 1 1\\n\\nNote\\n\\nConsider the first example. \\n\\n * The only maximum almost-1-uniform set is \\\\{1, 2, 3, 4\\\\}. \\n * One of the maximum almost-2-uniform sets is or \\\\{2, 3, 5\\\\}, another one is \\\\{2, 3, 4\\\\}. \\n * A maximum almost-3-uniform set is any pair of vertices on distance 3. \\n * Any single vertex is an almost-k-uniform set for k ≥ 1. \\n\\n\\n\\nIn the second sample there is an almost-2-uniform set of size 4, and that is \\\\{2, 3, 5, 6\\\\}.\",\"targets\":\"#include \\nusing namespace std;\\nconst int c = 500005;\\nint n, ans[2 * c], leut[c];\\nvector sz[c], t[c];\\nvector > csop[c];\\nbool v[c], v2[c];\\nvoid dfs(int a) {\\n v[a] = true;\\n for (int x : sz[a]) {\\n if (!v[x]) {\\n dfs(x);\\n t[a].push_back(leut[x] + 1);\\n leut[a] = max(leut[a], leut[x] + 1);\\n }\\n }\\n}\\nvoid dfs2(int a) {\\n sort(t[a].begin(), t[a].end());\\n for (int x : t[a]) {\\n if (csop[a].size() == 0 || x != csop[a].back().first) {\\n csop[a].push_back({x, 1});\\n } else {\\n csop[a].back().second++;\\n }\\n }\\n int si = csop[a].size(), sum = 0;\\n for (int i = si - 1; i >= 0; i--) {\\n int fi = csop[a][i].first, se = csop[a][i].second;\\n sum += se;\\n ans[2 * fi - 1] = max(ans[2 * fi - 1], sum);\\n ans[2 * fi] = max(ans[2 * fi], sum);\\n if (i > 0) {\\n int el = csop[a][i - 1].first;\\n ans[2 * el + 1] = max(ans[2 * el + 1], sum + 1);\\n }\\n }\\n int opt = csop[a].back().first, opt2 = 0;\\n if (csop[a].back().second > 1) {\\n opt2 = opt;\\n } else {\\n if (si > 1) {\\n opt2 = csop[a][si - 2].first;\\n }\\n }\\n v2[a] = true;\\n for (int x : sz[a]) {\\n if (!v2[x]) {\\n if (leut[x] + 1 == opt) {\\n t[x].push_back(opt2 + 1);\\n } else {\\n t[x].push_back(opt + 1);\\n }\\n dfs2(x);\\n int p1 = csop[a].size(), p2 = csop[x].size();\\n p1--, p2--;\\n sum = -2;\\n bool spec = (a == 1 && x == 4);\\n while (p1 >= 0 || p2 >= 0) {\\n if (p2 < 0 || (p1 >= 0 && csop[a][p1].first >= csop[x][p2].first)) {\\n int s = csop[a][p1].first;\\n sum += csop[a][p1].second;\\n p1--;\\n ans[2 * s] = max(ans[2 * s], sum);\\n } else {\\n int s = csop[x][p2].first;\\n sum += csop[x][p2].second;\\n p2--;\\n ans[2 * s] = max(ans[2 * s], sum);\\n }\\n }\\n }\\n }\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin >> n;\\n for (int i = 1; i < n; i++) {\\n int a, b;\\n cin >> a >> b;\\n sz[a].push_back(b), sz[b].push_back(a);\\n }\\n for (int i = 1; i <= n;...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nBenjamin Forest VIII is a king of a country. One of his best friends Nod lives in a village far from his castle. Nod gets seriously sick and is on the verge of death. Benjamin orders his subordinate Red to bring good medicine for him as soon as possible. However, there is no road from the castle to the village. Therefore, Red needs to climb over mountains and across canyons to reach the village. He has decided to get to the village on the shortest path on a map, that is, he will move on the straight line between the castle and the village. Then his way can be considered as polyline with n points (x1, y1) . . . (xn , yn ) as illustlated in the following figure.\\n\\n\\n\\nFigure 1: An example route from the castle to the village\\n\\nHere, xi indicates the distance between the castle and the point i, as the crow flies, and yi indicates the height of the point i. The castle is located on the point (x1 , y1 ), and the village is located on the point (xn , yn).\\n\\nRed can walk in speed vw . Also, since he has a skill to cut a tunnel through a mountain horizontally, he can move inside the mountain in speed vc.\\n\\nYour job is to write a program to the minimum time to get to the village.\\n\\n\\n\\nInput\\n\\nThe input is a sequence of datasets. Each dataset is given in the following format:\\n\\n\\nn\\nvw vc\\nx1 y1\\n...\\nxn yn\\n\\n\\nYou may assume all the following: n ≤ 1,000, 1 ≤ vw, vc ≤ 10, -10,000 ≤ xi, yi ≤ 10,000, and xi < xj for all i < j.\\n\\nThe input is terminated in case of n = 0. This is not part of any datasets and thus should not be processed.\\n\\nOutput\\n\\nFor each dataset, you should print the minimum time required to get to the village in a line. Each minimum time should be given as a decimal with an arbitrary number of fractional digits and with an absolute error of at most 10-6 . No extra space or character is allowed.\\n\\nExample\\n\\nInput\\n\\n3\\n2 1\\n0 0\\n50 50\\n100 0\\n3\\n1 1\\n0 0\\n50 50\\n100 0\\n3\\n1 2\\n0 0\\n50 50\\n100 0\\n3\\n2 1\\n0 0\\n100 100\\n150 50\\n6\\n1 2\\n0 0\\n50 50\\n100 0\\n150 0\\n200 50\\n250 0\\n0\\n\\n\\nOutput\\n\\n70.710678\\n100.000000\\n50.000000\\n106.066017\\n150.000000\",\"targets\":\"#include\\n#include\\n#include\\n#include\\n#include\\n#include\\n#include\\n\\nusing namespace std;\\n\\ntypedef double elem;\\ntypedef complex point, vec;\\ntypedef pair line;\\n\\n#define N 1001\\n\\nconst elem eps = 1.0e-7;\\nconst elem infty = 300000000.0;\\n\\nelem W[N][N];\\nelem A[N];\\nbool G[N][N];\\n\\nstruct State{\\n int now;\\n elem cost;\\n bool operator>(const State&t)const{\\n return cost > t.cost;\\n }\\n};\\n\\nelem cross(point a, point b){\\n return a.real() * b.imag() - a.imag() * b.real();\\n}\\n\\nelem dist(point a, point b){\\n return abs(b-a);\\n}\\nelem dist(point a1, point a2, point x){\\n return abs( cross(a2-a1,x-a1)) \\/ abs(a2-a1);\\n}\\n\\ninline bool intersected_seg(point a1, point a2, point b1, point b2){\\n return (cross(a2-a1,b1-a1)*cross(a2-a1,b2-a1) < eps &&\\n\\t cross(b2-b1,a1-b1)*cross(b2-b1,a2-b1) < eps );\\n}\\n\\ninline point intersection_seg(point a1, point a2, point b1, point b2){\\n elem d1=dist(b1,b2,a1);\\n elem d2=dist(b1,b2,a2);\\n elem t=d1\\/(d1+d2);\\n return a1+t*(a2-a1);\\n}\\n\\nvoid ResetGraph(){\\n for(int i = 0; i < N; ++i){\\n A[i] = infty;\\n for(int j = 0; j < N; ++j){\\n W[i][j] = infty;\\n G[i][j] = false;\\n }\\n }\\n}\\n\\nelem dijkstra(int goal){\\n priority_queue< State, vector, greater > pq;\\n bool visited[N]={false,};\\n State st;\\n\\n st.now = 0;\\n visited[0] = true;\\n st.cost = 0;\\n A[0] = 0;\\n pq.push( st );\\n\\n while( !pq.empty() ){\\n st = pq.top();\\n \\/\\/cout << \\\" QUEUE SIZE \\\" << pq.size() << endl;\\n pq.pop();\\n\\n \\/\\/cout << \\\"NOW: \\\" << st.now << \\\" COST : \\\" << st.cost << endl;\\n\\n \\/\\/visited[st.now] = false;\\n if( st.now == goal ){\\n return A[goal];\\n }\\n visited[st.now] = true;\\n\\n for(int i = 0; i < N; ++i){\\n if( G[st.now][i] ){\\n\\tif( !visited[i] && A[st.now] + W[st.now][i] < A[i] ){\\n\\t State next;\\n\\t next.now = i;\\n\\t A[i] = A[st.now] + W[st.now][i];\\n\\t \\/\\/cout << \\\"Goto : \\\" << i << endl;\\n\\t \\/\\/cout << \\\"Right : \\\" << A[st.now] << \\\" + \\\" << W[st.now][i] << endl;\\n\\t next.cost = A[i];\\n\\t pq.push( next );\\n\\t}\\n }\\n }\\n }\\n ...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in PYTHON3?\\nIt is the hard version of the problem. The only difference is that in this version 1 ≤ n ≤ 300.\\n\\nIn the cinema seats can be represented as the table with n rows and m columns. The rows are numbered with integers from 1 to n. The seats in each row are numbered with consecutive integers from left to right: in the k-th row from m (k - 1) + 1 to m k for all rows 1 ≤ k ≤ n.\\n\\n1| 2| ⋅⋅⋅| m - 1| m \\n---|---|---|---|--- \\nm + 1| m + 2| ⋅⋅⋅| 2 m - 1| 2 m \\n2m + 1| 2m + 2| ⋅⋅⋅| 3 m - 1| 3 m \\n\\\\vdots| \\\\vdots| \\\\ddots| \\\\vdots| \\\\vdots \\nm (n - 1) + 1| m (n - 1) + 2| ⋅⋅⋅| n m - 1| n m \\nThe table with seats indices\\n\\nThere are nm people who want to go to the cinema to watch a new film. They are numbered with integers from 1 to nm. You should give exactly one seat to each person.\\n\\nIt is known, that in this cinema as lower seat index you have as better you can see everything happening on the screen. i-th person has the level of sight a_i. Let's define s_i as the seat index, that will be given to i-th person. You want to give better places for people with lower sight levels, so for any two people i, j such that a_i < a_j it should be satisfied that s_i < s_j.\\n\\nAfter you will give seats to all people they will start coming to their seats. In the order from 1 to nm, each person will enter the hall and sit in their seat. To get to their place, the person will go to their seat's row and start moving from the first seat in this row to theirs from left to right. While moving some places will be free, some will be occupied with people already seated. The inconvenience of the person is equal to the number of occupied seats he or she will go through.\\n\\nLet's consider an example: m = 5, the person has the seat 4 in the first row, the seats 1, 3, 5 in the first row are already occupied, the seats 2 and 4 are free. The inconvenience of this person will be 2, because he will go through occupied seats 1 and 3.\\n\\nFind the minimal total inconvenience (the sum of inconveniences of all people), that is possible to have by giving places for all...\",\"targets\":\"#from itertools import product, permutations, combinations, accumulate, compress\\n#from collections import Counter, defaultdict, deque # deque([iterable[, maxlen]]) #appendleft popleft rotate\\n#from heapq import heapify, heappop, heappush # func(heapifiedlist, item)\\nfrom bisect import bisect_left, bisect_right, insort # func(sortedlist, item)\\n# TODO: more coping mechanisms...?\\n#from sys import setrecursionlimit\\n\\nimport os, sys\\ninput = lambda: sys.stdin.buffer.readline().rstrip(b'\\\\r\\\\n')\\n\\ndef dbp(*args, **kwargs): # calling with dbp(locals()) is perfectly cromulent\\n\\tprint(*args, file=sys.stderr, **kwargs)\\n\\na_str = lambda: input().decode('ascii')\\nget_int_list = lambda: [int(x) for x in input().split()]\\njoin_str = lambda l, ch=' ': ch.join((str(x) for x in l)) # ch is a default, not kwarg\\n\\ndef do_thing():\\n\\tn, m = get_int_list()\\n\\talist = get_int_list()\\n\\tslist = sorted(alist)\\n\\t'''\\n\\tslists = []\\n\\tfor i in range(0, n*m, m):\\n\\t\\tslists.append(slist[i:i+m])\\n\\theads = [sl[0] for sl in slists]\\n\\t'''\\n\\n\\tseats = [0] * (n*m) \\n\\ttotal = 0\\n\\t#dbp(locals())\\n\\tfor aidx, a in enumerate(alist):\\n\\t\\t\\n\\t\\tlbound = bisect_left(slist, a)\\n\\t\\tubound = bisect_right(slist, a)-1\\n\\t\\t#dbp('trying to place:', a, 'in:', slist[lbound:ubound+1])\\n\\n\\t\\t# fill up lowest row, deepest seat\\n\\t\\trow, col = divmod(lbound, m)\\t\\n\\t\\tplaced = False\\t\\n\\t\\t# best row was full, backup\\n\\t\\twhile row*m <= ubound and row < n:\\n\\t\\t\\tcol = min(m-1, ubound-(row*m))\\n\\t\\t\\t#dbp('initial r c:', row, col)\\n\\t\\t\\twhile row*m + col > lbound and col > 0 and seats[row*m+col]:\\n\\t\\t\\t\\tcol -= 1\\n\\t\\t\\tif not seats[row*m+col]:\\n\\t\\t\\t\\tseats[row*m+col] = 1\\n\\t\\t\\t\\ttotal += sum(seats[row*m:row*m+col])\\n\\t\\t\\t\\tplaced = True\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif placed:\\n\\t\\t\\t\\tbreak\\n\\t\\t\\trow += 1\\n\\t\\t#dbp(locals())\\n\\n\\t\\tif not placed:\\n\\t\\t\\traise Exception('ruh roh')\\n\\n\\n\\treturn total\\n\\nif __name__ == \\\"__main__\\\":\\n\\tmaxcc = 1\\n\\tmaxcc = int(input())\\n\\tfor cc in range(maxcc):\\n\\t\\tprint(do_thing())\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Two players, Red and Blue, are at it again, and this time they're playing with crayons! The mischievous duo is now vandalizing a rooted tree, by coloring the nodes while playing their favorite game.\\n\\nThe game works as follows: there is a tree of size n, rooted at node 1, where each node is initially white. Red and Blue get one turn each. Red goes first. \\n\\nIn Red's turn, he can do the following operation any number of times: \\n\\n * Pick any subtree of the rooted tree, and color every node in the subtree red. \\n\\nHowever, to make the game fair, Red is only allowed to color k nodes of the tree. In other words, after Red's turn, at most k of the nodes can be colored red.\\n\\nThen, it's Blue's turn. Blue can do the following operation any number of times: \\n\\n * Pick any subtree of the rooted tree, and color every node in the subtree blue. However, he's not allowed to choose a subtree that contains a node already colored red, as that would make the node purple and no one likes purple crayon. \\n\\nNote: there's no restriction on the number of nodes Blue can color, as long as he doesn't color a node that Red has already colored.\\n\\nAfter the two turns, the score of the game is determined as follows: let w be the number of white nodes, r be the number of red nodes, and b be the number of blue nodes. The score of the game is w ⋅ (r - b).\\n\\nRed wants to maximize this score, and Blue wants to minimize it. If both players play optimally, what will the final score of the game be?\\n\\nInput\\n\\nThe first line contains two integers n and k (2 ≤ n ≤ 2 ⋅ 10^5; 1 ≤ k ≤ n) — the number of vertices in the tree and the maximum number of red nodes.\\n\\nNext n - 1 lines contains description of edges. The i-th line contains two space separated integers u_i and v_i (1 ≤ u_i, v_i ≤ n; u_i ≠ v_i) — the i-th edge of the tree.\\n\\nIt's guaranteed that given edges form a tree.\\n\\nOutput\\n\\nPrint one integer — the resulting score if both Red and Blue play optimally.\\n\\nExamples\\n\\nInput\\n\\n\\n4 2\\n1 2\\n1 3\\n1 4\\n\\n\\nOutput\\n\\n\\n1\\n\\n\\nInput\\n\\n\\n5 2\\n1 2\\n2 3\\n3 4\\n4 5\\n\\n\\nOutput\\n\\n\\n6\\n\\n\\nInput\\n\\n\\n7...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\ninline int read() {\\n int x = 0, w = 0;\\n char ch = getchar();\\n while (ch < '0' || ch > '9') {\\n w |= ch == '-';\\n ch = getchar();\\n }\\n while (ch >= '0' && ch <= '9') {\\n x = (x << 3) + (x << 1) + ch - '0';\\n ch = getchar();\\n }\\n return w ? -x : x;\\n}\\nint n;\\nvector G[200005];\\nint dep[200005], dfn[200005], siz[200005], tot, vis[200005];\\nint t[200005 * 4], pos[200005 * 4], tag[200005 * 4], fat[200005], rk[200005];\\nvoid dfs(int x, int fa) {\\n fat[x] = fa;\\n dep[x] = dep[fa] + 1;\\n dfn[x] = ++tot;\\n rk[tot] = x;\\n siz[x] = 1;\\n for (auto V : G[x]) {\\n if (V == fa) continue;\\n dfs(V, x), siz[x] += siz[V];\\n }\\n}\\ninline void pushup(int x) {\\n t[x] = max(t[((x) << 1)], t[((x) << 1 | 1)]);\\n if (t[((x) << 1)] > t[((x) << 1 | 1)])\\n pos[x] = pos[((x) << 1)];\\n else\\n pos[x] = pos[((x) << 1 | 1)];\\n}\\ninline void pushdown(int x) {\\n if (!tag[x]) return;\\n tag[((x) << 1)] += tag[x];\\n t[((x) << 1)] += tag[x];\\n tag[((x) << 1 | 1)] += tag[x];\\n t[((x) << 1 | 1)] += tag[x];\\n tag[x] = 0;\\n}\\nvoid build(int x, int l, int r) {\\n if (l == r) {\\n pos[x] = rk[l];\\n t[x] = dep[rk[l]];\\n return;\\n }\\n int mid = (l + r) >> 1;\\n build(((x) << 1), l, mid);\\n build(((x) << 1 | 1), mid + 1, r);\\n pushup(x);\\n}\\nvoid add(int x, int l, int r, int a, int b, int d) {\\n if (a <= l && r <= b) {\\n t[x] += d;\\n tag[x] += d;\\n return;\\n }\\n pushdown(x);\\n int mid = (l + r) >> 1;\\n if (a <= mid) add(((x) << 1), l, mid, a, b, d);\\n if (b > mid) add(((x) << 1 | 1), mid + 1, r, a, b, d);\\n pushup(x);\\n}\\nvoid work(int x) {\\n if (vis[x] || !x) return;\\n vis[x] = 1;\\n add(1, 1, n, dfn[x], dfn[x] + siz[x] - 1, -1);\\n work(fat[x]);\\n}\\nint main() {\\n int k;\\n scanf(\\\"%d%d\\\", &n, &k);\\n for (int i = 1; i < n; i++) {\\n int x = read(), y = read();\\n G[x].push_back(y);\\n G[y].push_back(x);\\n }\\n dfs(1, 0);\\n build(1, 1, n);\\n long long ans = -(long long)n * n;\\n int num = 0;\\n for (int i = 1; i <= k; i++) {\\n int now = pos[1];\\n num += t[1];\\n long long tmp = min(n \\/ 2, n - num);\\n...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A new agent called Killjoy invented a virus COVID-2069 that infects accounts on Codeforces. Each account has a rating, described by an integer (it can possibly be negative or very large).\\n\\nKilljoy's account is already infected and has a rating equal to x. Its rating is constant. There are n accounts except hers, numbered from 1 to n. The i-th account's initial rating is a_i. Any infected account (initially the only infected account is Killjoy's) instantly infects any uninfected account if their ratings are equal. This can happen at the beginning (before any rating changes) and after each contest. If an account is infected, it can not be healed.\\n\\nContests are regularly held on Codeforces. In each contest, any of these n accounts (including infected ones) can participate. Killjoy can't participate. After each contest ratings are changed this way: each participant's rating is changed by an integer, but the sum of all changes must be equal to zero. New ratings can be any integer.\\n\\nFind out the minimal number of contests needed to infect all accounts. You can choose which accounts will participate in each contest and how the ratings will change.\\n\\nIt can be proven that all accounts can be infected in some finite number of contests.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. The next 2t lines contain the descriptions of all test cases.\\n\\nThe first line of each test case contains two integers n and x (2 ≤ n ≤ 10^3, -4000 ≤ x ≤ 4000) — the number of accounts on Codeforces and the rating of Killjoy's account.\\n\\nThe second line of each test case contains n integers a_1, a_2, ..., a_n (-4000 ≤ a_i ≤ 4000) — the ratings of other accounts.\\n\\nOutput\\n\\nFor each test case output the minimal number of contests needed to infect all accounts.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n2 69\\n68 70\\n6 4\\n4 4 4 4 4 4\\n9 38\\n-21 83 50 -59 -77 15 -71 -78 20\\n\\n\\nOutput\\n\\n\\n1\\n0\\n2\\n\\nNote\\n\\nIn the first test case it's possible to make all ratings equal to 69. First account's rating will increase by 1, and second account's...\",\"targets\":\"\\/\\/created by Whiplash99\\nimport java.io.*;\\nimport java.util.*;\\npublic class D\\n{\\n public static void main(String[] args) throws IOException\\n {\\n BufferedReader br=new BufferedReader(new InputStreamReader(System.in));\\n\\n int i,N;\\n\\n int T=Integer.parseInt(br.readLine().trim());\\n StringBuilder sb=new StringBuilder();\\n\\n while (T-->0)\\n {\\n String[] s=br.readLine().trim().split(\\\" \\\");\\n N=Integer.parseInt(s[0]);\\n int X=Integer.parseInt(s[1]);\\n\\n long sum=0;\\n s=br.readLine().trim().split(\\\" \\\");\\n int a[]=new int[N];\\n for(i=0;i=1) sb.append(1).append(\\\"\\\\n\\\");\\n else sb.append(2).append(\\\"\\\\n\\\");\\n }\\n System.out.println(sb);\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nTheofanis has a riddle for you and if you manage to solve it, he will give you a Cypriot snack halloumi for free (Cypriot cheese).\\n\\nYou are given an integer n. You need to find two integers l and r such that -10^{18} ≤ l < r ≤ 10^{18} and l + (l + 1) + … + (r - 1) + r = n.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases.\\n\\nThe first and only line of each test case contains a single integer n (1 ≤ n ≤ 10^{18}).\\n\\nOutput\\n\\nFor each test case, print the two integers l and r such that -10^{18} ≤ l < r ≤ 10^{18} and l + (l + 1) + … + (r - 1) + r = n. \\n\\nIt can be proven that an answer always exists. If there are multiple answers, print any.\\n\\nExample\\n\\nInput\\n\\n\\n7\\n1\\n2\\n3\\n6\\n100\\n25\\n3000000000000\\n\\n\\nOutput\\n\\n\\n0 1\\n-1 2 \\n1 2 \\n1 3 \\n18 22\\n-2 7\\n999999999999 1000000000001\\n\\nNote\\n\\nIn the first test case, 0 + 1 = 1.\\n\\nIn the second test case, (-1) + 0 + 1 + 2 = 2.\\n\\nIn the fourth test case, 1 + 2 + 3 = 6.\\n\\nIn the fifth test case, 18 + 19 + 20 + 21 + 22 = 100.\\n\\nIn the sixth test case, (-2) + (-1) + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 = 25.\",\"targets\":\"#include \\nusing namespace std;\\nint t;\\nlong long n;\\nint main() {\\n cin >> t;\\n while (t--) {\\n scanf(\\\"%lld\\\", &n);\\n printf(\\\"%lld %lld\\\\n\\\", -n + 1, n);\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"\\n\\nThis is an interactive task\\n\\nWilliam has a certain sequence of integers a_1, a_2, ..., a_n in his mind, but due to security concerns, he does not want to reveal it to you completely. William is ready to respond to no more than 2 ⋅ n of the following questions:\\n\\n * What is the result of a [bitwise AND](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#AND) of two items with indices i and j (i ≠ j) \\n * What is the result of a [bitwise OR](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#OR) of two items with indices i and j (i ≠ j) \\n\\n\\n\\nYou can ask William these questions and you need to find the k-th smallest number of the sequence.\\n\\nFormally the k-th smallest number is equal to the number at the k-th place in a 1-indexed array sorted in non-decreasing order. For example in array [5, 3, 3, 10, 1] 4th smallest number is equal to 5, and 2nd and 3rd are 3.\\n\\nInput\\n\\nIt is guaranteed that for each element in a sequence the condition 0 ≤ a_i ≤ 10^9 is satisfied.\\n\\nInteraction\\n\\nIn the first line you will be given two integers n and k (3 ≤ n ≤ 10^4, 1 ≤ k ≤ n), which are the number of items in the sequence a and the number k.\\n\\nAfter that, you can ask no more than 2 ⋅ n questions (not including the \\\"finish\\\" operation).\\n\\nEach line of your output may be of one of the following types: \\n\\n * \\\"or i j\\\" (1 ≤ i, j ≤ n, i ≠ j), where i and j are indices of items for which you want to calculate the bitwise OR. \\n * \\\"and i j\\\" (1 ≤ i, j ≤ n, i ≠ j), where i and j are indices of items for which you want to calculate the bitwise AND. \\n * \\\"finish res\\\", where res is the kth smallest number in the sequence. After outputting this line the program execution must conclude. \\n\\n\\n\\nIn response to the first two types of queries, you will get an integer x, the result of the operation for the numbers you have selected.\\n\\nAfter outputting a line do not forget to output a new line character and flush the output buffer. Otherwise you will get the \\\"Idleness limit exceeded\\\". To flush the buffer use:\\n\\n * fflush(stdout) in C++ \\n *...\",\"targets\":\"#include \\nusing namespace std;\\nconst int M = 1e4 + 5;\\ninline int read() {\\n char c = getchar();\\n int x = 0, f = 1;\\n for (; c < '0' || c > '9'; c = getchar())\\n if (c == '-') f = 0;\\n for (; c <= '9' && c >= '0'; c = getchar())\\n x = (x << 1) + (x << 3) + (c ^ 48);\\n return f ? x : -x;\\n}\\ninline int abs(int x) { return x > 0 ? x : -x; }\\ninline int min(int a, int b) { return a < b ? a : b; }\\ninline int max(int a, int b) { return a > b ? a : b; }\\ninline void swap(int &a, int &b) { a ^= b ^= a ^= b; }\\nint n, k, a[M], c[M], t1, t2;\\nint main() {\\n n = read(), k = read();\\n for (int i = 2; i <= n; i++) {\\n printf(\\\"and %d %d\\\\n\\\", i - 1, i);\\n fflush(stdout);\\n scanf(\\\"%d\\\", &t1);\\n printf(\\\"or %d %d\\\\n\\\", i - 1, i);\\n fflush(stdout);\\n scanf(\\\"%d\\\", &t2);\\n c[i] = t1 + t2;\\n }\\n printf(\\\"and 1 3\\\\n\\\");\\n fflush(stdout);\\n scanf(\\\"%d\\\", &t1);\\n printf(\\\"or 1 3\\\\n\\\");\\n fflush(stdout);\\n scanf(\\\"%d\\\", &t2);\\n a[2] = c[2] - t1 - t2 + c[3] >> 1, a[1] = c[2] - a[2];\\n for (register int i = 3; i <= n; i++) a[i] = c[i] - a[i - 1];\\n sort(a + 1, a + 1 + n);\\n printf(\\\"finish %d\\\\n\\\", a[k]);\\n fflush(stdout);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nThe only difference between this problem and D2 is that you don't have to provide the way to construct the answer in this problem, but you have to do it in D2.\\n\\nThere's a table of n × m cells (n rows and m columns). The value of n ⋅ m is even.\\n\\nA domino is a figure that consists of two cells having a common side. It may be horizontal (one of the cells is to the right of the other) or vertical (one of the cells is above the other).\\n\\nYou need to find out whether it is possible to place nm\\/2 dominoes on the table so that exactly k of them are horizontal and all the other dominoes are vertical. The dominoes cannot overlap and must fill the whole table.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of a single line. The line contains three integers n, m, k (1 ≤ n,m ≤ 100, 0 ≤ k ≤ nm\\/2, n ⋅ m is even) — the number of rows, columns and horizontal dominoes, respectively.\\n\\nOutput\\n\\nFor each test case output \\\"YES\\\", if it is possible to place dominoes in the desired way, or \\\"NO\\\" otherwise.\\n\\nYou may print each letter in any case (YES, yes, Yes will all be recognized as positive answer, NO, no and nO will all be recognized as negative answer).\\n\\nExample\\n\\nInput\\n\\n\\n8\\n4 4 2\\n2 3 0\\n3 2 3\\n1 2 0\\n2 4 2\\n5 2 2\\n2 17 16\\n2 1 1\\n\\n\\nOutput\\n\\n\\nYES\\nYES\\nYES\\nNO\\nYES\\nNO\\nYES\\nNO\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int t;\\n cin >> t;\\n while (t--) {\\n int n, m, k, p;\\n cin >> n >> m >> k;\\n p = (n * m) \\/ 2 - k;\\n if (n == m) {\\n if (k % 2 == 0)\\n cout << \\\"yes\\\\n\\\";\\n else\\n cout << \\\"no\\\\n\\\";\\n } else if (n % 2 != 0) {\\n if ((k - m \\/ 2) % 2 == 0 && k >= m \\/ 2)\\n cout << \\\"yes\\\\n\\\";\\n else\\n cout << \\\"no\\\\n\\\";\\n } else if (m % 2 != 0) {\\n if ((p - n \\/ 2) % 2 == 0 && p >= n \\/ 2)\\n cout << \\\"yes\\\\n\\\";\\n else\\n cout << \\\"no\\\\n\\\";\\n } else if (n > m) {\\n if (k % 2 == 0)\\n cout << \\\"yes\\\\n\\\";\\n else\\n cout << \\\"no\\\\n\\\";\\n } else {\\n if (p % 2 == 0)\\n cout << \\\"yes\\\\n\\\";\\n else\\n cout << \\\"no\\\\n\\\";\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A string is called palindrome if it reads the same from left to right and from right to left. For example \\\"kazak\\\", \\\"oo\\\", \\\"r\\\" and \\\"mikhailrubinchikkihcniburliahkim\\\" are palindroms, but strings \\\"abb\\\" and \\\"ij\\\" are not.\\n\\nYou are given string s consisting of lowercase Latin letters. At once you can choose any position in the string and change letter in that position to any other lowercase letter. So after each changing the length of the string doesn't change. At first you can change some letters in s. Then you can permute the order of letters as you want. Permutation doesn't count as changes. \\n\\nYou should obtain palindrome with the minimal number of changes. If there are several ways to do that you should get the lexicographically (alphabetically) smallest palindrome. So firstly you should minimize the number of changes and then minimize the palindrome lexicographically.\\n\\nInput\\n\\nThe only line contains string s (1 ≤ |s| ≤ 2·105) consisting of only lowercase Latin letters.\\n\\nOutput\\n\\nPrint the lexicographically smallest palindrome that can be obtained with the minimal number of changes.\\n\\nExamples\\n\\nInput\\n\\naabc\\n\\n\\nOutput\\n\\nabba\\n\\n\\nInput\\n\\naabcd\\n\\n\\nOutput\\n\\nabcba\\nimpor\",\"targets\":\"t java.io.*;\\nimport java.util.*;\\nimport java.math.*;\\n \\npublic class Main{ \\n \\n static boolean ONLINE_JUDGE = false;\\/\\/change before submit\\n static Fast f = new Fast();\\n static PrintWriter out = new PrintWriter(System.out); \\n static boolean TEST_CASES = false;\\n\\n \\n static void solve(int TC_NO) {\\n \\n String s = rs();\\n\\n int[] hash = new int[26];\\n for(int i = 0; i < s.length(); i++) {\\n hash[s.charAt(i)-'a']++;\\n }\\n \\n int odd = 0;\\n\\n ArrayList l = new ArrayList<>();\\n\\n for(int i = 0; i < 26; i++) {\\n if(hash[i]>0 && MMath.mod(hash[i],2)==1) l.add(i);\\n }\\n\\n for(int i = 0; i < l.size()\\/2; i++){\\n hash[l.get(i)]++;\\n hash[l.get(l.size()-1-i)]--;\\n }\\n\\n StringBuilder res = new StringBuilder();\\n char[] ans = new char[s.length()]; \\n int iter = 0;\\n int ind = -1;\\n for(int i = 0; i < 26; i++){\\n while(hash[i]>1){\\n ans[iter] = (char)(i+97);\\n ans[ans.length-1-iter] = (char)(i+97);\\n hash[i]-=2;\\n iter++;\\n }\\n if(hash[i]==1){\\n ind = i;\\n }\\n }\\n \\n if(ind!=-1) ans[ans.length\\/2] = (char)(ind+97);\\n for(int i = 0; i < ans.length; i++) res.append(ans[i]);\\n\\n out.println(res);\\n \\/* WARNING : change [ONLINE_JUDGE = false] before SUBMIT *\\/ \\n }\\n\\n \\n \\n\\n public static void main(String[] args)throws Exception{\\n\\n out = ONLINE_JUDGE? new PrintWriter(new BufferedWriter(new FileWriter(\\\"output.txt\\\"))): new PrintWriter(System.out);\\n \\n if(TEST_CASES){\\n \\n int t = ri();\\n int i = 1;\\n while(i<=t){\\n solve(i);\\n i++;\\n }\\n\\n }\\n\\n else {\\n\\n solve(1);\\n \\n }\\n \\n out.close();\\n\\n }\\n\\n static int ri() {\\n\\n return f.nextInt();\\n \\n }\\n\\n static long rl() {\\n \\n return f.nextLong();\\n \\n }\\n\\n static double rd() {\\n\\n return f.nextDouble();\\n \\n }\\n\\n static...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"2^k teams participate in a playoff tournament. The tournament consists of 2^k - 1 games. They are held as follows: first of all, the teams are split into pairs: team 1 plays against team 2, team 3 plays against team 4 (exactly in this order), and so on (so, 2^{k-1} games are played in that phase). When a team loses a game, it is eliminated, and each game results in elimination of one team (there are no ties). After that, only 2^{k-1} teams remain. If only one team remains, it is declared the champion; otherwise, 2^{k-2} games are played: in the first one of them, the winner of the game \\\"1 vs 2\\\" plays against the winner of the game \\\"3 vs 4\\\", then the winner of the game \\\"5 vs 6\\\" plays against the winner of the game \\\"7 vs 8\\\", and so on. This process repeats until only one team remains.\\n\\nAfter the tournament ends, the teams are assigned places according to the tournament phase when they were eliminated. In particular:\\n\\n * the winner of the tournament gets place 1; \\n * the team eliminated in the finals gets place 2; \\n * both teams eliminated in the semifinals get place 3; \\n * all teams eliminated in the quarterfinals get place 5; \\n * all teams eliminated in the 1\\/8 finals get place 9, and so on. \\n\\n\\n\\nFor example, this picture describes one of the possible ways the tournament can go with k = 3, and the resulting places of the teams:\\n\\n\\n\\nAfter a tournament which was conducted by the aforementioned rules ended, its results were encoded in the following way. Let p_i be the place of the i-th team in the tournament. The hash value of the tournament h is calculated as h = (∑ _{i=1}^{2^k} i ⋅ A^{p_i}) mod 998244353, where A is some given integer.\\n\\nUnfortunately, due to a system crash, almost all tournament-related data was lost. The only pieces of data that remain are the values of k, A and h. You are asked to restore the resulting placing of the teams in the tournament, if it is possible at all.\\n\\nInput\\n\\nThe only line contains three integers k, A and h (1 ≤ k ≤ 5; 100 ≤ A ≤ 10^8; 0 ≤ h ≤ 998244352).\\n\\nOutput\\n\\nIf...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint yh() {\\n int ret = 0;\\n bool f = 0;\\n char c = getchar();\\n while (!isdigit(c)) {\\n if (c == EOF) return -1;\\n if (c == '-') f = 1;\\n c = getchar();\\n }\\n while (isdigit(c)) ret = (ret << 3) + (ret << 1) + (c ^ 48), c = getchar();\\n return f ? -ret : ret;\\n}\\nconst int maxn = 3e5 + 5, mod = 998244353;\\nint n, k, A, h;\\nint a[maxn];\\nint p[maxn];\\nint tmp[2][maxn];\\nvoid calc(int *p, int match, int n) {\\n int cur = 0;\\n for (int i = (0), iss = (n - 1); i <= iss; i++) tmp[0][i] = i;\\n int last = 1, now = 0;\\n int rank = n \\/ 2 + 1;\\n while (n >= 2) {\\n last ^= 1, now ^= 1;\\n int pos = 0;\\n for (int i = (0), iss = (n \\/ 2 - 1); i <= iss; i++) {\\n if (!(match & (1 << cur))) {\\n tmp[now][pos++] = tmp[last][(i << 1)];\\n p[tmp[last][i << 1 | 1]] = rank;\\n } else {\\n tmp[now][pos++] = tmp[last][(i << 1 | 1)];\\n p[tmp[last][i << 1]] = rank;\\n }\\n cur++;\\n }\\n rank = (rank + 1) >> 1;\\n n >>= 1;\\n }\\n p[tmp[now][0]] = 1;\\n}\\nint pw[maxn];\\nint adjust(int *p, int n, int win, int shift) {\\n int ans = 0;\\n for (int i = (0), iss = (n - 1); i <= iss; i++) {\\n if (p[i] == 1) {\\n p[i] = 2 - win;\\n } else\\n p[i] = p[i] * 2 - 1;\\n (ans += (long long)(shift + i) * pw[p[i]] % mod) %= mod;\\n }\\n return ans;\\n}\\nmap ha;\\npair, int> ans;\\nint main() {\\n k = yh();\\n n = 1 << k;\\n A = yh(), h = yh();\\n pw[0] = 1;\\n for (int i = (1), iss = (n); i <= iss; i++)\\n pw[i] = (long long)pw[i - 1] * A % mod;\\n if (k <= 2) {\\n int tm = n - 1;\\n for (int s = 0; s < (1 << tm); s++) {\\n calc(p, s, n);\\n int ans = 0;\\n for (int i = (0), iss = (n - 1); i <= iss; i++)\\n (ans += ((long long)pw[p[i]] * (i + 1))) %= mod;\\n if (ans == h) {\\n for (int i = (0), iss = (n - 1); i <= iss; i++)\\n cout << p[i] << \\\" \\\\n\\\"[i == n - 1];\\n return 0;\\n }\\n }\\n puts(\\\"-1\\\");\\n return 0;\\n }\\n ans = {{-1, -1}, -1};\\n for (int c = (0), css = (1); c <= css; c++) {\\n ha.clear();\\n int n...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A string is a palindrome if it reads the same from the left to the right and from the right to the left. For example, the strings \\\"kek\\\", \\\"abacaba\\\", \\\"r\\\" and \\\"papicipap\\\" are palindromes, while the strings \\\"abb\\\" and \\\"iq\\\" are not.\\n\\nA substring s[l … r] (1 ≤ l ≤ r ≤ |s|) of a string s = s_{1}s_{2} … s_{|s|} is the string s_{l}s_{l + 1} … s_{r}.\\n\\nAnna does not like palindromes, so she makes her friends call her Ann. She also changes all the words she reads in a similar way. Namely, each word s is changed into its longest substring that is not a palindrome. If all the substrings of s are palindromes, she skips the word at all.\\n\\nSome time ago Ann read the word s. What is the word she changed it into?\\n\\nInput\\n\\nThe first line contains a non-empty string s with length at most 50 characters, containing lowercase English letters only.\\n\\nOutput\\n\\nIf there is such a substring in s that is not a palindrome, print the maximum length of such a substring. Otherwise print 0.\\n\\nNote that there can be multiple longest substrings that are not palindromes, but their length is unique.\\n\\nExamples\\n\\nInput\\n\\nmew\\n\\n\\nOutput\\n\\n3\\n\\n\\nInput\\n\\nwuffuw\\n\\n\\nOutput\\n\\n5\\n\\n\\nInput\\n\\nqqqqqqqq\\n\\n\\nOutput\\n\\n0\\n\\nNote\\n\\n\\\"mew\\\" is not a palindrome, so the longest substring of it that is not a palindrome, is the string \\\"mew\\\" itself. Thus, the answer for the first example is 3.\\n\\nThe string \\\"uffuw\\\" is one of the longest non-palindrome substrings (of length 5) of the string \\\"wuffuw\\\", so the answer for the second example is 5.\\n\\nAll substrings of the string \\\"qqqqqqqq\\\" consist of equal characters so they are palindromes. This way, there are no non-palindrome substrings. Thus, the answer for the third example is 0.\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"#981A Antipalindrome\\ndef isPalin(t):\\n u=\\\"\\\"\\n for i in t:\\n u=i+u\\n if u==t:\\n return True\\n else:\\n return False\\ns=input()\\nn=len(s)\\ni=0\\nfor i in range(n-1, -1,-1):\\n f=0\\n if s[0]!=s[i]:\\n f=1\\n else:\\n S=s[:i+1]\\n if not isPalin(S):\\n f=1\\n if f==1:\\n break\\nif i==0:\\n print(i)\\nelse:\\n print(i+1)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Little Johnny Bubbles enjoys spending hours in front of his computer playing video games. His favorite game is Bubble Strike, fast-paced bubble shooting online game for two players.\\n\\nEach game is set in one of the N maps, each having different terrain configuration. First phase of each game decides on which map the game will be played. The game system randomly selects three maps and shows them to the players. Each player must pick one of those three maps to be discarded. The game system then randomly selects one of the maps that were not picked by any of the players and starts the game.\\n\\nJohnny is deeply enthusiastic about the game and wants to spend some time studying maps, thus increasing chances to win games played on those maps. However, he also needs to do his homework, so he does not have time to study all the maps. That is why he asked himself the following question: \\\"What is the minimum number of maps I have to study, so that the probability to play one of those maps is at least P\\\"?\\n\\nCan you help Johnny find the answer for this question? You can assume Johnny's opponents do not know him, and they will randomly pick maps.\\n\\nInput\\n\\nThe first line contains two integers N (3 ≤ N ≤ 10^{3}) and P (0 ≤ P ≤ 1) – total number of maps in the game and probability to play map Johnny has studied. P will have at most four digits after the decimal point.\\n\\nOutput\\n\\nOutput contains one integer number – minimum number of maps Johnny has to study.\\n\\nExample\\n\\nInput\\n\\n\\n7 1.0000\\n\\n\\nOutput\\n\\n\\n6\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nlong long p0, p1, p2, p3, l, r, m, n, ans;\\ndouble p, c;\\nint check(long long x) {\\n long long a = x, b = n - x;\\n p0 = a * (a - 1) * (a - 2);\\n p1 = a * (a - 1) * b;\\n p2 = a * b * (b - 1);\\n p3 = b * (b - 1) * (b - 2);\\n if (2 * p0 + 6 * p1 + 3 * p2 >= c)\\n return 1;\\n else\\n return 0;\\n}\\nint main() {\\n scanf(\\\"%lld%lf\\\", &n, &p);\\n c = p * 2 * n * (n - 1) * (n - 2);\\n l = 0;\\n r = n;\\n while (l <= r) {\\n m = l + r >> 1;\\n if (check(m))\\n ans = m, r = m - 1;\\n else\\n l = m + 1;\\n }\\n printf(\\\"%lld\\\\n\\\", ans);\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Andrey's favourite number is n. Andrey's friends gave him two identical numbers n as a New Year present. He hung them on a wall and watched them adoringly.\\n\\nThen Andrey got bored from looking at the same number and he started to swap digits first in one, then in the other number, then again in the first number and so on (arbitrary number of changes could be made in each number). At some point it turned out that if we sum the resulting numbers, then the number of zeroes with which the sum will end would be maximum among the possible variants of digit permutations in those numbers.\\n\\nGiven number n, can you find the two digit permutations that have this property?\\n\\nInput\\n\\nThe first line contains a positive integer n — the original number. The number of digits in this number does not exceed 105. The number is written without any leading zeroes.\\n\\nOutput\\n\\nPrint two permutations of digits of number n, such that the sum of these numbers ends with the maximum number of zeroes. The permutations can have leading zeroes (if they are present, they all should be printed). The permutations do not have to be different. If there are several answers, print any of them.\\n\\nExamples\\n\\nInput\\n\\n198\\n\\n\\nOutput\\n\\n981\\n819\\n\\n\\nInput\\n\\n500\\n\\n\\nOutput\\n\\n500\\n500\\nUsing java can you solve the prior task?\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\n\\npublic class B {\\n\\n\\tpublic B () throws IOException {\\n\\t\\tString N = sc.next();\\n\\t\\tsolve(N);\\n\\t}\\n\\t\\n\\tpublic void solve (String N) {\\n\\t\\tt = millis();\\n\\t\\t\\n\\t\\tint [] D = new int [10];\\n\\t\\tint L = N.length();\\n\\n\\t\\tfor (char c : N.toCharArray())\\n\\t\\t\\t++D[c-'0'];\\n\\t\\t\\n\\t\\tint ZZ = D[0];\\n\\t\\tint MAX = -1, mz = -1, mm = -1;\\n\\t\\t\\n\\t\\tfor (int z = 0; z <= ZZ; ++z) {\\n\\t\\t\\tfor (int m = 1; m <= 9; ++m) {\\n\\t\\t\\t\\tint [] EX = new int [10];\\n\\t\\t\\t\\tint [] EY = new int [10];\\n\\t\\t\\t\\tfor (int i = 0; i < 10; ++i) {\\n\\t\\t\\t\\t\\tEX[i] = D[i];\\n\\t\\t\\t\\t\\tEY[i] = D[i];\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\n\\t\\t\\t\\tint M = 0;\\n\\t\\t\\t\\t\\n\\t\\t\\t\\tEX[0] -= z;\\n\\t\\t\\t\\tEY[0] -= z;\\n\\t\\t\\t\\tM += z;\\n\\t\\t\\t\\t\\n\\t\\t\\t\\tif (EX[m] > 0 && EY[10-m] > 0) {\\n\\t\\t\\t\\t\\t--EX[m];\\n\\t\\t\\t\\t\\t--EY[10-m];\\n\\t\\t\\t\\t\\t++M;\\n\\t\\t\\t\\t\\tfor (int n = 0; n <= 9; ++n)\\n\\t\\t\\t\\t\\t\\tM += Math.min(EX[n], EY[9-n]);\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\n\\t\\t\\t\\tif (M > MAX) {\\n\\t\\t\\t\\t\\tMAX = M; mz = z; mm = m;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\t\\n\\t\\tint [] X = new int [L];\\n\\t\\tint [] Y = new int [L];\\n\\t\\tint x = L-1, y = L-1;\\n\\t\\t\\n\\t\\tint [] DX = new int [10];\\n\\t\\tint [] DY = new int [10];\\n\\t\\tfor (int i = 0; i < 10; ++i) {\\n\\t\\t\\tDX[i] = D[i];\\n\\t\\t\\tDY[i] = D[i];\\n\\t\\t}\\n\\t\\t\\n\\t\\tfor (int i = 0; i < mz; ++i) {\\n\\t\\t\\tX[x--] = 0; --DX[0];\\n\\t\\t\\tY[y--] = 0; --DY[0];\\n\\t\\t}\\n\\t\\t\\n\\t\\tif (DX[mm] > 0 && DY[10-mm] > 0) {\\n\\t\\t\\tX[x--] = mm; --DX[mm];\\n\\t\\t\\tY[y--] = 10-mm; --DY[10-mm];\\n\\t\\t\\t\\n\\t\\t\\tfor (int n = 0; n <= 9; ++n) {\\n\\t\\t\\t\\twhile (DX[n] > 0 && DY[9-n] > 0) {\\n\\t\\t\\t\\t\\tX[x--] = n; --DX[n];\\n\\t\\t\\t\\t\\tY[y--] = 9-n; --DY[9-n];\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\t\\n\\t\\tfor (int i = 0; i < 10; ++i) {\\n\\t\\t\\tfor (int j = 0; j < DX[i]; ++j)\\n\\t\\t\\t\\tX[x--] = i;\\n\\t\\t\\tfor (int j = 0; j < DY[i]; ++j)\\n\\t\\t\\t\\tY[y--] = i;\\n\\t\\t}\\n\\t\\t\\t\\n\\t\\tchar [] XX = new char[L];\\n\\t\\tchar [] YY = new char[L];\\n\\t\\t\\n\\t\\tfor (int i = 0; i < L; ++i) {\\n\\t\\t\\tXX[i] = (char)(X[i] + '0');\\n\\t\\t\\tYY[i] = (char)(Y[i] + '0');\\n\\t\\t}\\n\\t\\t\\n\\t\\tprint2(new String(XX));\\n\\t\\tprint(new String(YY));\\n\\t}\\n\\t\\n\\t\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\n\\n\\tstatic Scanner sc;\\n\\tstatic long t;\\n\\t\\n\\tstatic void print2 (Object o) {\\n\\t\\tSystem.out.println(o);\\n\\t}\\n\\t\\n\\tstatic void print (Object o) {\\n\\t\\tprint2(o);\\n\\t\\t\\/\\/print2((millis() - t) \\/...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"During the study of the Martians Petya clearly understood that the Martians are absolutely lazy. They like to sleep and don't like to wake up. \\n\\nImagine a Martian who has exactly n eyes located in a row and numbered from the left to the right from 1 to n. When a Martian sleeps, he puts a patch on each eye (so that the Martian morning doesn't wake him up). The inner side of each patch has an uppercase Latin letter. So, when a Martian wakes up and opens all his eyes he sees a string s consisting of uppercase Latin letters. The string's length is n. \\n\\n\\\"Ding dong!\\\" — the alarm goes off. A Martian has already woken up but he hasn't opened any of his eyes. He feels that today is going to be a hard day, so he wants to open his eyes and see something good. The Martian considers only m Martian words beautiful. Besides, it is hard for him to open all eyes at once so early in the morning. So he opens two non-overlapping segments of consecutive eyes. More formally, the Martian chooses four numbers a, b, c, d, (1 ≤ a ≤ b < c ≤ d ≤ n) and opens all eyes with numbers i such that a ≤ i ≤ b or c ≤ i ≤ d. After the Martian opens the eyes he needs, he reads all the visible characters from the left to the right and thus, he sees some word.\\n\\nLet's consider all different words the Martian can see in the morning. Your task is to find out how many beautiful words are among them.\\n\\nInput\\n\\nThe first line contains a non-empty string s consisting of uppercase Latin letters. The strings' length is n (2 ≤ n ≤ 105). The second line contains an integer m (1 ≤ m ≤ 100) — the number of beautiful words. Next m lines contain the beautiful words pi, consisting of uppercase Latin letters. Their length is from 1 to 1000. All beautiful strings are pairwise different.\\n\\nOutput\\n\\nPrint the single integer — the number of different beautiful strings the Martian can see this morning.\\n\\nExamples\\n\\nInput\\n\\nABCBABA\\n2\\nBAAB\\nABBA\\n\\n\\nOutput\\n\\n1\\n\\nNote\\n\\nLet's consider the sample test. There the Martian can get only the second beautiful string if he opens segments of...\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nvector prefix_function(string s) {\\n int n = (int)s.size();\\n vector pi(n);\\n for (int i = 1; i < n; i++) {\\n int j = pi[i - 1];\\n while (j > 0 && s[i] != s[j]) j = pi[j - 1];\\n if (s[i] == s[j]) j++;\\n pi[i] = j;\\n }\\n return pi;\\n}\\nint id[100005];\\nint Ok(string t, string s) {\\n if (t.size() < 2) return 0;\\n vector pi = prefix_function(t + \\\"#\\\" + s);\\n int pos1 = -1, mx1 = -1, pos2;\\n for (int i = t.size() + 1; i < pi.size(); i++) {\\n if (pi[i] > mx1) {\\n mx1 = pi[i];\\n pos1 = i - t.size() - 1;\\n }\\n }\\n reverse(s.begin(), s.end());\\n reverse(t.begin(), t.end());\\n vector pi2 = prefix_function(t + \\\"#\\\" + s);\\n memset(id, -1, sizeof(id));\\n ;\\n for (int i = t.size() + 1; i < pi2.size(); i++) {\\n if (~id[pi2[i]]) continue;\\n id[pi2[i]] = s.size() - (i - t.size());\\n }\\n sort(pi2.begin(), pi2.end());\\n (pi2).resize(unique(pi2.begin(), pi2.end()) - (pi2).begin());\\n for (int i = t.size() + 1; i < pi.size(); i++) {\\n pos1 = i - t.size() - 1;\\n int x = t.size() - pi[i];\\n int y = lower_bound(pi2.begin(), pi2.end(), x) - pi2.begin();\\n if (id[y] > pos1 && y + pi[i] >= t.size()) return 1;\\n }\\n return 0;\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n string s, t;\\n cin >> s;\\n int n;\\n cin >> n;\\n int ans = 0;\\n while (n--) {\\n cin >> t;\\n ans += Ok(t, s);\\n }\\n cout << ans << \\\"\\\\n\\\";\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Theofanis has a riddle for you and if you manage to solve it, he will give you a Cypriot snack halloumi for free (Cypriot cheese).\\n\\nYou are given an integer n. You need to find two integers l and r such that -10^{18} ≤ l < r ≤ 10^{18} and l + (l + 1) + … + (r - 1) + r = n.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases.\\n\\nThe first and only line of each test case contains a single integer n (1 ≤ n ≤ 10^{18}).\\n\\nOutput\\n\\nFor each test case, print the two integers l and r such that -10^{18} ≤ l < r ≤ 10^{18} and l + (l + 1) + … + (r - 1) + r = n. \\n\\nIt can be proven that an answer always exists. If there are multiple answers, print any.\\n\\nExample\\n\\nInput\\n\\n\\n7\\n1\\n2\\n3\\n6\\n100\\n25\\n3000000000000\\n\\n\\nOutput\\n\\n\\n0 1\\n-1 2 \\n1 2 \\n1 3 \\n18 22\\n-2 7\\n999999999999 1000000000001\\n\\nNote\\n\\nIn the first test case, 0 + 1 = 1.\\n\\nIn the second test case, (-1) + 0 + 1 + 2 = 2.\\n\\nIn the fourth test case, 1 + 2 + 3 = 6.\\n\\nIn the fifth test case, 18 + 19 + 20 + 21 + 22 = 100.\\n\\nIn the sixth test case, (-2) + (-1) + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 = 25.\\nUsing python3 can you solve the prior task?\",\"targets\":\"import math\\nt = int(input())\\nfor i in range(t):\\n n = int(input())\\n if n==1:\\n print(0,1)\\n if n==-1:\\n print(-1,0)\\n if n==0:\\n print(-1,1)\\n x = 2*n\\n for j in range(1,math.floor(math.sqrt(x))):\\n if x%j == 0:\\n k = x\\/\\/j-j\\n if k%2 !=0:\\n l = (k+1)\\/\\/2\\n r = x\\/\\/j-l\\n if l != r and (l+r)*(r-l+1)==x:\\n print(l,r)\\n break\\n l = (-k+1)\\/\\/2\\n r = j-l\\n if l != r and (l+r)*(r-l+1)==x:\\n print(l,r)\\n break\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Bessie and the cows are playing with sequences and need your help. They start with a sequence, initially containing just the number 0, and perform n operations. Each operation is one of the following:\\n\\n 1. Add the integer xi to the first ai elements of the sequence. \\n 2. Append an integer ki to the end of the sequence. (And hence the size of the sequence increases by 1) \\n 3. Remove the last element of the sequence. So, the size of the sequence decreases by one. Note, that this operation can only be done if there are at least two elements in the sequence. \\n\\n\\n\\nAfter each operation, the cows would like to know the average of all the numbers in the sequence. Help them!\\n\\nInput\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 2·105) — the number of operations. The next n lines describe the operations. Each line will start with an integer ti (1 ≤ ti ≤ 3), denoting the type of the operation (see above). If ti = 1, it will be followed by two integers ai, xi (|xi| ≤ 103; 1 ≤ ai). If ti = 2, it will be followed by a single integer ki (|ki| ≤ 103). If ti = 3, it will not be followed by anything.\\n\\nIt is guaranteed that all operations are correct (don't touch nonexistent elements) and that there will always be at least one element in the sequence.\\n\\nOutput\\n\\nOutput n lines each containing the average of the numbers in the sequence after the corresponding operation.\\n\\nThe answer will be considered correct if its absolute or relative error doesn't exceed 10 - 6.\\n\\nExamples\\n\\nInput\\n\\n5\\n2 1\\n3\\n2 3\\n2 1\\n3\\n\\n\\nOutput\\n\\n0.500000\\n0.000000\\n1.500000\\n1.333333\\n1.500000\\n\\n\\nInput\\n\\n6\\n2 1\\n1 2 20\\n2 2\\n1 2 -3\\n3\\n3\\n\\n\\nOutput\\n\\n0.500000\\n20.500000\\n14.333333\\n12.333333\\n17.500000\\n17.000000\\n\\nNote\\n\\nIn the second sample, the sequence becomes \\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nconst int X = 2e5 + 9;\\nint a[X], add[X];\\nint main() {\\n long long sum = 0, n, sz = 1, d, k, l;\\n scanf(\\\"%I64d\\\", &n);\\n while (n--) {\\n scanf(\\\"%I64d\\\", &d);\\n if (d == 1) {\\n scanf(\\\"%I64d%I64d\\\", &k, &l);\\n sum += k * l;\\n add[k] += l;\\n } else if (d == 2) {\\n scanf(\\\"%I64d\\\", &k);\\n sum += k;\\n a[++sz] = k;\\n } else {\\n sum -= add[sz--];\\n add[sz] += add[sz + 1];\\n add[sz + 1] = 0;\\n sum -= a[sz + 1];\\n }\\n printf(\\\"%.6f\\\\n\\\", sum \\/ (double)sz);\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nAlice and Borys are playing tennis.\\n\\nA tennis match consists of games. In each game, one of the players is serving and the other one is receiving.\\n\\nPlayers serve in turns: after a game where Alice is serving follows a game where Borys is serving, and vice versa.\\n\\nEach game ends with a victory of one of the players. If a game is won by the serving player, it's said that this player holds serve. If a game is won by the receiving player, it's said that this player breaks serve.\\n\\nIt is known that Alice won a games and Borys won b games during the match. It is unknown who served first and who won which games.\\n\\nFind all values of k such that exactly k breaks could happen during the match between Alice and Borys in total.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^3). Description of the test cases follows.\\n\\nEach of the next t lines describes one test case and contains two integers a and b (0 ≤ a, b ≤ 10^5; a + b > 0) — the number of games won by Alice and Borys, respectively.\\n\\nIt is guaranteed that the sum of a + b over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case print two lines.\\n\\nIn the first line, print a single integer m (1 ≤ m ≤ a + b + 1) — the number of values of k such that exactly k breaks could happen during the match.\\n\\nIn the second line, print m distinct integers k_1, k_2, …, k_m (0 ≤ k_1 < k_2 < … < k_m ≤ a + b) — the sought values of k in increasing order.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n2 1\\n1 1\\n0 5\\n\\n\\nOutput\\n\\n\\n4\\n0 1 2 3\\n2\\n0 2\\n2\\n2 3\\n\\nNote\\n\\nIn the first test case, any number of breaks between 0 and 3 could happen during the match: \\n\\n * Alice holds serve, Borys holds serve, Alice holds serve: 0 breaks; \\n * Borys holds serve, Alice holds serve, Alice breaks serve: 1 break; \\n * Borys breaks serve, Alice breaks serve, Alice holds serve: 2 breaks; \\n * Alice breaks serve, Borys breaks serve, Alice breaks serve: 3 breaks. \\n\\n\\n\\nIn the second test case, the players could either both hold serves (0 breaks) or both break serves (2...\",\"targets\":\"#include \\nusing namespace std;\\nusing namespace chrono;\\ntemplate \\nvoid _print(T t) {\\n cerr << t;\\n}\\ntemplate \\nvoid _print(pair p);\\ntemplate \\nvoid _print(vector v);\\ntemplate \\nvoid _print(set v);\\ntemplate \\nvoid _print(map v);\\ntemplate \\nvoid _print(multiset v);\\ntemplate \\nvoid _print(pair p) {\\n cerr << \\\"{\\\";\\n _print(p.first);\\n cerr << \\\",\\\";\\n _print(p.second);\\n cerr << \\\"}\\\";\\n}\\ntemplate \\nvoid _print(vector v) {\\n cerr << \\\"[ \\\";\\n for (T i : v) {\\n _print(i);\\n cerr << \\\" \\\";\\n }\\n cerr << \\\"]\\\";\\n}\\ntemplate \\nvoid _print(set v) {\\n cerr << \\\"[ \\\";\\n for (T i : v) {\\n _print(i);\\n cerr << \\\" \\\";\\n }\\n cerr << \\\"]\\\";\\n}\\ntemplate \\nvoid _print(multiset v) {\\n cerr << \\\"[ \\\";\\n for (T i : v) {\\n _print(i);\\n cerr << \\\" \\\";\\n }\\n cerr << \\\"]\\\";\\n}\\ntemplate \\nvoid _print(map v) {\\n cerr << \\\"[ \\\";\\n for (auto i : v) {\\n _print(i);\\n cerr << \\\" \\\";\\n }\\n cerr << \\\"]\\\";\\n}\\ntemplate \\nvector& operator--(vector& v) {\\n for (auto& i : v) --i;\\n return v;\\n}\\ntemplate \\nvector& operator++(vector& v) {\\n for (auto& i : v) ++i;\\n return v;\\n}\\ntemplate \\nistream& operator>>(istream& is, vector& v) {\\n for (auto& i : v) is >> i;\\n return is;\\n}\\ntemplate \\nostream& operator<<(ostream& os, vector v) {\\n for (auto& i : v) os << i << ' ';\\n return os;\\n}\\ntemplate \\npair& operator--(pair& p) {\\n --p.first;\\n --p.second;\\n return p;\\n}\\ntemplate \\npair& operator++(pair& p) {\\n ++p.first;\\n ++p.second;\\n return p;\\n}\\ntemplate \\nistream& operator>>(istream& is, pair& p) {\\n is >> p.first >> p.second;\\n return is;\\n}\\ntemplate \\nostream& operator<<(ostream& os, pair p) {\\n os << p.first << ' ' << p.second;\\n return os;\\n}\\ntemplate \\npair operator-(pair...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"At regular competition Vladik and Valera won a and b candies respectively. Vladik offered 1 his candy to Valera. After that Valera gave Vladik 2 his candies, so that no one thought that he was less generous. Vladik for same reason gave 3 candies to Valera in next turn.\\n\\nMore formally, the guys take turns giving each other one candy more than they received in the previous turn.\\n\\nThis continued until the moment when one of them couldn’t give the right amount of candy. Candies, which guys got from each other, they don’t consider as their own. You need to know, who is the first who can’t give the right amount of candy.\\n\\nInput\\n\\nSingle line of input data contains two space-separated integers a, b (1 ≤ a, b ≤ 109) — number of Vladik and Valera candies respectively.\\n\\nOutput\\n\\nPring a single line \\\"Vladik’’ in case, if Vladik first who can’t give right amount of candy, or \\\"Valera’’ otherwise.\\n\\nExamples\\n\\nInput\\n\\n1 1\\n\\n\\nOutput\\n\\nValera\\n\\n\\nInput\\n\\n7 6\\n\\n\\nOutput\\n\\nVladik\\n\\nNote\\n\\nIllustration for first test case:\\n\\n\\n\\nIllustration for second test case:\\n\\n\\nSolve the task in PYTHON3.\",\"targets\":\"#n = int(input())\\nm,n = map(int,input().split())\\n#s = input()\\n#arr = [int(x) for x in input().split()]\\nval = int(m**(1\\/2))\\nval += 1\\ntemp = val*(val-1)\\nif n>=temp:\\n\\tprint(\\\"Vladik\\\")\\nelse:\\n\\tprint(\\\"Valera\\\")\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"This is the hard version of the problem. The only difference between the two versions is the constraint on n. You can make hacks only if all versions of the problem are solved.\\n\\nA forest is an undirected graph without cycles (not necessarily connected).\\n\\nMocha and Diana are friends in Zhijiang, both of them have a forest with nodes numbered from 1 to n, and they would like to add edges to their forests such that: \\n\\n * After adding edges, both of their graphs are still forests. \\n * They add the same edges. That is, if an edge (u, v) is added to Mocha's forest, then an edge (u, v) is added to Diana's forest, and vice versa. \\n\\n\\n\\nMocha and Diana want to know the maximum number of edges they can add, and which edges to add.\\n\\nInput\\n\\nThe first line contains three integers n, m_1 and m_2 (1 ≤ n ≤ 10^5, 0 ≤ m_1, m_2 < n) — the number of nodes and the number of initial edges in Mocha's forest and Diana's forest.\\n\\nEach of the next m_1 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the edges in Mocha's forest.\\n\\nEach of the next m_2 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the edges in Diana's forest.\\n\\nOutput\\n\\nThe first line contains only one integer h, the maximum number of edges Mocha and Diana can add.\\n\\nEach of the next h lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the edge you add each time.\\n\\nIf there are multiple correct answers, you can print any one of them.\\n\\nExamples\\n\\nInput\\n\\n\\n3 2 2\\n1 2\\n2 3\\n1 2\\n1 3\\n\\n\\nOutput\\n\\n\\n0\\n\\n\\nInput\\n\\n\\n5 3 2\\n5 4\\n2 1\\n4 3\\n4 3\\n1 4\\n\\n\\nOutput\\n\\n\\n1\\n2 4\\n\\n\\nInput\\n\\n\\n8 1 2\\n1 7\\n2 6\\n1 5\\n\\n\\nOutput\\n\\n\\n5\\n5 2\\n2 3\\n3 4\\n4 7\\n6 8\\n\\nNote\\n\\nIn the first example, we cannot add any edge.\\n\\nIn the second example, the initial forests are as follows.\\n\\n\\n\\nWe can add an edge (2, 4).\\n\\n\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nconst int N = 4e5 + 5;\\nint n, m1, m2, fa[N], fa2[N];\\nint as, pa, pb, a[N], b[N];\\npair t[N];\\nint find(int x) {\\n if (fa[x] == x) return x;\\n return fa[x] = find(fa[x]);\\n}\\nint find2(int x) {\\n if (fa2[x] == x) return x;\\n return fa2[x] = find2(fa2[x]);\\n}\\nint main() {\\n scanf(\\\"%d%d%d\\\", &n, &m1, &m2);\\n for (int i = 1; i <= n; i++) fa[i] = i, fa2[i] = i;\\n for (int i = 1; i <= m1; i++) {\\n int a, b;\\n scanf(\\\"%d%d\\\", &a, &b);\\n fa[find(a)] = find(b);\\n }\\n for (int i = 1; i <= m2; i++) {\\n int a, b;\\n scanf(\\\"%d%d\\\", &a, &b);\\n fa2[find2(a)] = find2(b);\\n }\\n for (int i = 2; i <= n; i++) {\\n int fi = find(1), fv = find(i), fi2 = find2(1), fv2 = find2(i);\\n if (fi == fv || fi2 == fv2) continue;\\n fa[fv] = fi, fa2[fv2] = fi2;\\n t[++as] = {1, i};\\n }\\n for (int i = 2; i <= n; i++) {\\n int fi = find(1), fv = find(i), fi2 = find2(1), fv2 = find2(i);\\n if (fi != fv) a[++pa] = i, fa[fv] = fi;\\n if (fi2 != fv2) b[++pb] = i, fa2[fv2] = fi2;\\n }\\n printf(\\\"%d\\\\n\\\", as + min(pa, pb));\\n for (int i = 1; i <= as; i++) printf(\\\"%d %d\\\\n\\\", t[i].first, t[i].second);\\n for (int i = 1; i <= min(pa, pb); i++) printf(\\\"%d %d\\\\n\\\", a[i], b[i]);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given an integer array a_1, a_2, ..., a_n and integer k.\\n\\nIn one step you can \\n\\n * either choose some index i and decrease a_i by one (make a_i = a_i - 1); \\n * or choose two indices i and j and set a_i equal to a_j (make a_i = a_j). \\n\\n\\n\\nWhat is the minimum number of steps you need to make the sum of array ∑_{i=1}^{n}{a_i} ≤ k? (You are allowed to make values of array negative).\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases.\\n\\nThe first line of each test case contains two integers n and k (1 ≤ n ≤ 2 ⋅ 10^5; 1 ≤ k ≤ 10^{15}) — the size of array a and upper bound on its sum.\\n\\nThe second line of each test case contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — the array itself.\\n\\nIt's guaranteed that the sum of n over all test cases doesn't exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print one integer — the minimum number of steps to make ∑_{i=1}^{n}{a_i} ≤ k.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n1 10\\n20\\n2 69\\n6 9\\n7 8\\n1 2 1 3 1 2 1\\n10 1\\n1 2 3 1 2 6 1 6 8 10\\n\\n\\nOutput\\n\\n\\n10\\n0\\n2\\n7\\n\\nNote\\n\\nIn the first test case, you should decrease a_1 10 times to get the sum lower or equal to k = 10.\\n\\nIn the second test case, the sum of array a is already less or equal to 69, so you don't need to change it.\\n\\nIn the third test case, you can, for example: \\n\\n 1. set a_4 = a_3 = 1; \\n 2. decrease a_4 by one, and get a_4 = 0. \\n\\nAs a result, you'll get array [1, 2, 1, 0, 1, 2, 1] with sum less or equal to 8 in 1 + 1 = 2 steps.\\n\\nIn the fourth test case, you can, for example: \\n\\n 1. choose a_7 and decrease in by one 3 times; you'll get a_7 = -2; \\n 2. choose 4 elements a_6, a_8, a_9 and a_{10} and them equal to a_7 = -2. \\n\\nAs a result, you'll get array [1, 2, 3, 1, 2, -2, -2, -2, -2, -2] with sum less or equal to 1 in 3 + 4 = 7 steps.\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"import math\\n\\nt = int(input())\\n\\nfor x in range(t):\\n [n, k] = [int(d) for d in input().split()]\\n A = [int(d) for d in input().split()]\\n A.sort()\\n left = sum(A) - k\\n if left <= 0:\\n print(\\\"0\\\")\\n continue\\n ans = left\\n for a in range(n-1, 0, -1):\\n left -= A[a] - A[0]\\n ans = min(ans, n - a + max(0, math.ceil(left\\/(n - a + 1))))\\n print(ans)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A company has n employees numbered from 1 to n. Each employee either has no immediate manager or exactly one immediate manager, who is another employee with a different number. An employee A is said to be the superior of another employee B if at least one of the following is true:\\n\\n * Employee A is the immediate manager of employee B\\n * Employee B has an immediate manager employee C such that employee A is the superior of employee C. \\n\\n\\n\\nThe company will not have a managerial cycle. That is, there will not exist an employee who is the superior of his\\/her own immediate manager.\\n\\nToday the company is going to arrange a party. This involves dividing all n employees into several groups: every employee must belong to exactly one group. Furthermore, within any single group, there must not be two employees A and B such that A is the superior of B.\\n\\nWhat is the minimum number of groups that must be formed?\\n\\nInput\\n\\nThe first line contains integer n (1 ≤ n ≤ 2000) — the number of employees.\\n\\nThe next n lines contain the integers pi (1 ≤ pi ≤ n or pi = -1). Every pi denotes the immediate manager for the i-th employee. If pi is -1, that means that the i-th employee does not have an immediate manager. \\n\\nIt is guaranteed, that no employee will be the immediate manager of him\\/herself (pi ≠ i). Also, there will be no managerial cycles.\\n\\nOutput\\n\\nPrint a single integer denoting the minimum number of groups that will be formed in the party.\\n\\nExamples\\n\\nInput\\n\\n5\\n-1\\n1\\n2\\n1\\n-1\\n\\n\\nOutput\\n\\n3\\n\\nNote\\n\\nFor the first example, three groups are sufficient, for example: \\n\\n * Employee 1 \\n * Employees 2 and 4 \\n * Employees 3 and 5 \\nSolve the task in JAVA.\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.util.ArrayList;\\nimport java.util.LinkedList;\\n\\n\\npublic class Party_A115 {\\n\\tstatic ArrayList[] adjList;\\n\\tstatic ArrayList roots;\\n \\n static int n;\\n public static void main(String[] args) throws NumberFormatException,IOException{\\n\\t\\tBufferedReader br =new BufferedReader(new InputStreamReader(System.in));\\n\\t\\t n =Integer.parseInt(br.readLine());\\n\\t\\troots=new ArrayList<>();\\n\\t\\tadjList=new ArrayList[n+1];\\n\\t\\tfor (int i = 0; i < n+1; i++) \\n\\t\\t\\tadjList[i]=new ArrayList<>();\\n\\t\\t\\n\\t\\tfor (int i = 0; i < n; i++) {\\n\\t\\t\\tint x=Integer.parseInt(br.readLine());\\n\\t\\t\\tif(x!=-1)\\n\\t\\t adjList[x-1].add(i);\\n\\t\\t\\telse roots.add(i);\\n\\t\\t}\\n\\t\\tint max=1;\\n\\t\\tfor (int i = 0; i < roots.size(); i++) {\\n\\t\\t\\tmax=Math.max(max, dfs(roots.get(i)));\\n\\t\\t}\\n\\t\\tSystem.out.println(max);\\n\\t\\n\\t}\\n static int dfs(int root){\\n int max=1;\\n for (int i:adjList[root]) \\n\\tmax=Math.max(max, 1+dfs(i)); \\n\\t\\n\\n \\n \\t\\n \\treturn max;\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"\\n\\nWilliam has an array of n integers a_1, a_2, ..., a_n. In one move he can swap two neighboring items. Two items a_i and a_j are considered neighboring if the condition |i - j| = 1 is satisfied.\\n\\nWilliam wants you to calculate the minimal number of swaps he would need to perform to make it so that the array does not contain two neighboring items with the same parity.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^4). Description of the test cases follows.\\n\\nThe first line of each test case contains an integer n (1 ≤ n ≤ 10^5) which is the total number of items in William's array.\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) which are William's array.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 10^5.\\n\\nOutput\\n\\nFor each test case output the minimal number of operations needed or -1 if it is impossible to get the array to a state when no neighboring numbers have the same parity.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n3\\n6 6 1\\n1\\n9\\n6\\n1 1 1 2 2 2\\n2\\n8 6\\n6\\n6 2 3 4 5 1\\n\\n\\nOutput\\n\\n\\n1\\n0\\n3\\n-1\\n2\\n\\nNote\\n\\nIn the first test case the following sequence of operations would satisfy the requirements: \\n\\n 1. swap(2, 3). Array after performing the operation: [6, 1, 6] \\n\\n\\n\\nIn the second test case the array initially does not contain two neighboring items of the same parity.\\n\\nIn the third test case the following sequence of operations would satisfy the requirements: \\n\\n 1. swap(3, 4). Array after performing the operation: [1, 1, 2, 1, 2, 2] \\n 2. swap(2, 3). Array after performing the operation: [1, 2, 1, 1, 2, 2] \\n 3. swap(4, 5). Array after performing the operation: [1, 2, 1, 2, 1, 2] \\n\\n\\n\\nIn the fourth test case it is impossible to satisfy the requirements.\\n\\nIn the fifth test case the following sequence of operations would satisfy the requirements: \\n\\n 1. swap(2, 3). Array after performing the operation: [6, 3, 2, 4, 5, 1] \\n 2. swap(4, 5). Array after performing the operation: [6, 3, 2, 5, 4, 1] \\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint main(void) {\\n int t, n, i, j, x;\\n int n1, n2;\\n int a, b, p, q;\\n cin >> t;\\n for (i = 0; i < t; i++) {\\n cin >> n;\\n n1 = 0, n2 = 0;\\n vector v, v1, v2;\\n vector even, odd;\\n for (j = 0; j < n; j++) {\\n cin >> x;\\n if (x % 2) {\\n n1++;\\n odd.push_back(j);\\n } else {\\n n2++;\\n even.push_back(j);\\n }\\n v.push_back(x);\\n v1.push_back(x);\\n v2.push_back(x);\\n }\\n long long max1 = 0, max2 = 0, max_total;\\n int k, temp;\\n a = 0, b = 0;\\n if (n % 2) {\\n if (abs(n1 - n2) != 1) {\\n cout << \\\"-1\\\\n\\\";\\n } else {\\n if (n1 < n2) {\\n for (k = 0; k < n; k++) {\\n if (k % 2) {\\n while (a < n && !(v1[a] % 2)) {\\n a++;\\n }\\n max1 += abs(a - k);\\n if (a != k) {\\n temp = v1[a];\\n v1[a] = v1[k];\\n v1[k] = temp;\\n }\\n a++;\\n } else {\\n while (b < n && v1[b] % 2) {\\n b++;\\n }\\n max1 += abs(b - k);\\n if (b != k) {\\n temp = v1[b];\\n v1[b] = v1[k];\\n v1[k] = temp;\\n }\\n b++;\\n }\\n }\\n cout << max1 << \\\"\\\\n\\\";\\n } else {\\n for (k = 0; k < n; k++) {\\n if (!(k % 2)) {\\n while (a < n && !(v2[a] % 2)) {\\n a++;\\n }\\n max2 += abs(a - k);\\n if (a != k) {\\n temp = v2[a];\\n v2[a] = v2[k];\\n v2[k] = temp;\\n }\\n a++;\\n } else {\\n while (b < n && v2[b] % 2) {\\n b++;\\n }\\n max2 += abs(b - k);\\n if (b != k) {\\n temp = v2[b];\\n v2[b] = v2[k];\\n v2[k] = temp;\\n }\\n b++;\\n }\\n }\\n cout <<...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A frog lives on the axis Ox and needs to reach home which is in the point n. She starts from the point 1. The frog can jump to the right at a distance not more than d. So, after she jumped from the point x she can reach the point x + a, where a is an integer from 1 to d.\\n\\nFor each point from 1 to n is known if there is a lily flower in it. The frog can jump only in points with a lilies. Guaranteed that there are lilies in the points 1 and n.\\n\\nDetermine the minimal number of jumps that the frog needs to reach home which is in the point n from the point 1. Consider that initially the frog is in the point 1. If the frog can not reach home, print -1.\\n\\nInput\\n\\nThe first line contains two integers n and d (2 ≤ n ≤ 100, 1 ≤ d ≤ n - 1) — the point, which the frog wants to reach, and the maximal length of the frog jump.\\n\\nThe second line contains a string s of length n, consisting of zeros and ones. If a character of the string s equals to zero, then in the corresponding point there is no lily flower. In the other case, in the corresponding point there is a lily flower. Guaranteed that the first and the last characters of the string s equal to one.\\n\\nOutput\\n\\nIf the frog can not reach the home, print -1.\\n\\nIn the other case, print the minimal number of jumps that the frog needs to reach the home which is in the point n from the point 1.\\n\\nExamples\\n\\nInput\\n\\n8 4\\n10010101\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n4 2\\n1001\\n\\n\\nOutput\\n\\n-1\\n\\n\\nInput\\n\\n8 4\\n11100101\\n\\n\\nOutput\\n\\n3\\n\\n\\nInput\\n\\n12 3\\n101111100101\\n\\n\\nOutput\\n\\n4\\n\\nNote\\n\\nIn the first example the from can reach home in two jumps: the first jump from the point 1 to the point 4 (the length of the jump is three), and the second jump from the point 4 to the point 8 (the length of the jump is four).\\n\\nIn the second example the frog can not reach home, because to make it she need to jump on a distance three, but the maximum length of her jump equals to two.\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.util.Scanner;\\npublic class codef{\\n public static void main(String[] args){\\n Scanner sc = new Scanner(System.in);\\n int n,d;\\n n = sc.nextInt();\\n d = sc.nextInt();\\n String s = new String();\\n s = sc.next();\\n int nb=0;\\n int ind=0;\\n boolean ok;\\n while(true){\\n ok = false;\\n if(ind+d>=n-1) {nb++;break;}\\n for(int i=ind+d;i>ind;i--){\\n if(s.charAt(i)=='1') {\\n nb++;\\n ind = i;\\n ok = true;\\n break;\\n }\\n }\\n if(!ok) {nb=-1;break;}\\n \\n }\\n System.out.println(nb);\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given an array consisting of all integers from [l, r] inclusive. For example, if l = 2 and r = 5, the array would be [2, 3, 4, 5]. What's the minimum number of elements you can delete to make the [bitwise AND](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#AND) of the array non-zero?\\n\\nA bitwise AND is a binary operation that takes two equal-length binary representations and performs the AND operation on each pair of the corresponding bits.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10^4) — the number of test cases. Then t cases follow.\\n\\nThe first line of each test case contains two integers l and r (1 ≤ l ≤ r ≤ 2 ⋅ 10^5) — the description of the array.\\n\\nOutput\\n\\nFor each test case, output a single integer — the answer to the problem.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n1 2\\n2 8\\n4 5\\n1 5\\n100000 200000\\n\\n\\nOutput\\n\\n\\n1\\n3\\n0\\n2\\n31072\\n\\nNote\\n\\nIn the first test case, the array is [1, 2]. Currently, the bitwise AND is 0, as 1\\\\ \\\\& \\\\ 2 = 0. However, after deleting 1 (or 2), the array becomes [2] (or [1]), and the bitwise AND becomes 2 (or 1). This can be proven to be the optimal, so the answer is 1.\\n\\nIn the second test case, the array is [2, 3, 4, 5, 6, 7, 8]. Currently, the bitwise AND is 0. However, after deleting 4, 5, and 8, the array becomes [2, 3, 6, 7], and the bitwise AND becomes 2. This can be proven to be the optimal, so the answer is 3. Note that there may be other ways to delete 3 elements.\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\n\\npublic class B {\\n\\tpublic static void main(String[] args) throws Exception {\\n\\t\\tScanner sc = new Scanner(System.in);\\n\\t\\tPrintWriter pw = new PrintWriter(System.out);\\n\\t\\tint t = sc.nextInt();\\n\\t\\tint[][] a = new int[300000][18];\\n\\t\\tfor (int i = 1; i < 200010; i++) {\\n\\t\\t\\tString s = Integer.toBinaryString(i);\\n\\t\\t\\tint j = s.length() - 1;\\n\\t\\t\\tint idx = 17;\\n\\t\\t\\twhile (j >= 0 && idx >= 0) {\\n\\t\\t\\t\\tif (s.charAt(j) == '1') {\\n\\t\\t\\t\\t\\ta[i][idx]++;\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\ta[i][idx] += a[i - 1][idx];\\n\\t\\t\\t\\tidx--;\\n\\t\\t\\t\\tj--;\\n\\t\\t\\t}\\n\\t\\t\\twhile (idx >= 0) {\\n\\t\\t\\t\\ta[i][idx] += a[i - 1][idx];\\n\\t\\t\\t\\tidx--;\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\twhile (t-- > 0) {\\n\\t\\t\\tint l = sc.nextInt();\\n\\t\\t\\tint r = sc.nextInt();\\n\\t\\t\\tString s2 = Integer.toBinaryString(l);\\n\\t\\t\\tint j = s2.length() - 1;\\n\\t\\t\\tint min = Integer.MAX_VALUE;\\n\\t\\t\\tfor (int i = 17; i >= 0; i--) {\\n\\t\\t\\t\\tint c = 0;\\n\\t\\t\\t\\tif (j >= 0) {\\n\\t\\t\\t\\t\\tif (s2.charAt(j) == '1')\\n\\t\\t\\t\\t\\t\\tc = 1;\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tmin = Math.min(min, (r - l + 1) - Math.abs(c + a[r][i] - a[l][i]));\\n\\t\\t\\t\\tj--;\\n\\t\\t\\t}\\n\\t\\t\\tpw.println(Math.max(0, min));\\n\\t\\t}\\n\\t\\tpw.close();\\n\\t}\\n\\n\\t\\/\\/ --------------------sTufF ----------------------\\n\\tstatic class Scanner {\\n\\t\\tStringTokenizer st;\\n\\t\\tBufferedReader br;\\n\\n\\t\\tpublic Scanner(InputStream s) {\\n\\t\\t\\tbr = new BufferedReader(new InputStreamReader(s));\\n\\t\\t}\\n\\n\\t\\tpublic Scanner(FileReader r) {\\n\\t\\t\\tbr = new BufferedReader(r);\\n\\t\\t}\\n\\n\\t\\tpublic String next() throws IOException {\\n\\t\\t\\twhile (st == null || !st.hasMoreTokens())\\n\\t\\t\\t\\tst = new StringTokenizer(br.readLine());\\n\\t\\t\\treturn st.nextToken();\\n\\t\\t}\\n\\n\\t\\tpublic int nextInt() throws IOException {\\n\\t\\t\\treturn Integer.parseInt(next());\\n\\t\\t}\\n\\n\\t\\tpublic long nextLong() throws IOException {\\n\\t\\t\\treturn Long.parseLong(next());\\n\\t\\t}\\n\\n\\t\\tpublic String nextLine() throws IOException {\\n\\t\\t\\treturn br.readLine();\\n\\t\\t}\\n\\n\\t\\tpublic double nextDouble() throws IOException {\\n\\t\\t\\tString x = next();\\n\\t\\t\\tStringBuilder sb = new StringBuilder(\\\"0\\\");\\n\\t\\t\\tdouble res = 0, f = 1;\\n\\t\\t\\tboolean dec = false, neg = false;\\n\\t\\t\\tint start = 0;\\n\\t\\t\\tif (x.charAt(0) == '-') {\\n\\t\\t\\t\\tneg = true;\\n\\t\\t\\t\\tstart++;\\n\\t\\t\\t}\\n\\t\\t\\tfor (int i = start; i < x.length(); i++)\\n\\t\\t\\t\\tif...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A binary string is a string that consists of characters 0 and 1. A bi-table is a table that has exactly two rows of equal length, each being a binary string.\\n\\nLet \\\\operatorname{MEX} of a bi-table be the smallest digit among 0, 1, or 2 that does not occur in the bi-table. For example, \\\\operatorname{MEX} for \\\\begin{bmatrix} 0011\\\\\\\\\\\\ 1010 \\\\end{bmatrix} is 2, because 0 and 1 occur in the bi-table at least once. \\\\operatorname{MEX} for \\\\begin{bmatrix} 111\\\\\\\\\\\\ 111 \\\\end{bmatrix} is 0, because 0 and 2 do not occur in the bi-table, and 0 < 2.\\n\\nYou are given a bi-table with n columns. You should cut it into any number of bi-tables (each consisting of consecutive columns) so that each column is in exactly one bi-table. It is possible to cut the bi-table into a single bi-table — the whole bi-table.\\n\\nWhat is the maximal sum of \\\\operatorname{MEX} of all resulting bi-tables can be?\\n\\nInput\\n\\nThe input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. Description of the test cases follows.\\n\\nThe first line of the description of each test case contains a single integer n (1 ≤ n ≤ 10^5) — the number of columns in the bi-table.\\n\\nEach of the next two lines contains a binary string of length n — the rows of the bi-table.\\n\\nIt's guaranteed that the sum of n over all test cases does not exceed 10^5.\\n\\nOutput\\n\\nFor each test case print a single integer — the maximal sum of \\\\operatorname{MEX} of all bi-tables that it is possible to get by cutting the given bi-table optimally.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n7\\n0101000\\n1101100\\n5\\n01100\\n10101\\n2\\n01\\n01\\n6\\n000000\\n111111\\n\\n\\nOutput\\n\\n\\n8\\n8\\n2\\n12\\n\\nNote\\n\\nIn the first test case you can cut the bi-table as follows:\\n\\n * \\\\begin{bmatrix} 0\\\\\\\\\\\\ 1 \\\\end{bmatrix}, its \\\\operatorname{MEX} is 2.\\n * \\\\begin{bmatrix} 10\\\\\\\\\\\\ 10 \\\\end{bmatrix}, its \\\\operatorname{MEX} is 2.\\n * \\\\begin{bmatrix} 1\\\\\\\\\\\\ 1 \\\\end{bmatrix}, its \\\\operatorname{MEX} is 0.\\n * \\\\begin{bmatrix} 0\\\\\\\\\\\\ 1 \\\\end{bmatrix}, its \\\\operatorname{MEX} is 2.\\n * \\\\begin{bmatrix} 0\\\\\\\\\\\\ 0 \\\\end{bmatrix}, its...\",\"targets\":\"import java.util.Scanner;\\n\\npublic class Problem1566C {\\n public static void main(String[] args) {\\n Scanner sc = new Scanner(System.in);\\n int t = sc.nextInt();\\n while (t-- >= 1) {\\n int n = sc.nextInt();\\n String s = sc.next();\\n String s1 = sc.next();\\n int arr[][] = new int[2][n];\\n for (int i = 0; i < 2; i++) {\\n for (int j = 0; j < n; j++) {\\n if (i == 1) {\\n arr[i][j] = s1.charAt(j) - 48;\\n } else {\\n arr[i][j] = s.charAt(j) - 48;\\n }\\n }\\n }\\n long max = 0;\\n for (int i = 0; i < 1; i++) {\\n for (int j = 0; j < n; ) {\\n if ((arr[0][j] == 1 && arr[1][j] == 0)|| (arr[0][j] == 0 && arr[1][j] == 1)) {\\n max = max + 2;\\n j++;\\n } else if (j + 1 < n && arr[0][j] == 1 && arr[0][j + 1] == 0) {\\n max = max + 2;\\n j = j + 2;\\n }\\n else if (j + 1 < n && arr[0][j] == 0 && arr[0][j + 1] == 1) {\\n if(arr[1][j+1] == 1) {\\n max = max + 2;\\n j = j + 2;\\n }else{\\n max = max+1;\\n j++;\\n }\\n }\\n else if (arr[0][j] == 0 && arr[1][j] == 0) {\\n max = max + 1;\\n j++;\\n } else {\\n j++;\\n }\\n }\\n }\\n System.out.println(max);\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A binary string is a string that consists of characters 0 and 1. A bi-table is a table that has exactly two rows of equal length, each being a binary string.\\n\\nLet \\\\operatorname{MEX} of a bi-table be the smallest digit among 0, 1, or 2 that does not occur in the bi-table. For example, \\\\operatorname{MEX} for \\\\begin{bmatrix} 0011\\\\\\\\\\\\ 1010 \\\\end{bmatrix} is 2, because 0 and 1 occur in the bi-table at least once. \\\\operatorname{MEX} for \\\\begin{bmatrix} 111\\\\\\\\\\\\ 111 \\\\end{bmatrix} is 0, because 0 and 2 do not occur in the bi-table, and 0 < 2.\\n\\nYou are given a bi-table with n columns. You should cut it into any number of bi-tables (each consisting of consecutive columns) so that each column is in exactly one bi-table. It is possible to cut the bi-table into a single bi-table — the whole bi-table.\\n\\nWhat is the maximal sum of \\\\operatorname{MEX} of all resulting bi-tables can be?\\n\\nInput\\n\\nThe input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. Description of the test cases follows.\\n\\nThe first line of the description of each test case contains a single integer n (1 ≤ n ≤ 10^5) — the number of columns in the bi-table.\\n\\nEach of the next two lines contains a binary string of length n — the rows of the bi-table.\\n\\nIt's guaranteed that the sum of n over all test cases does not exceed 10^5.\\n\\nOutput\\n\\nFor each test case print a single integer — the maximal sum of \\\\operatorname{MEX} of all bi-tables that it is possible to get by cutting the given bi-table optimally.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n7\\n0101000\\n1101100\\n5\\n01100\\n10101\\n2\\n01\\n01\\n6\\n000000\\n111111\\n\\n\\nOutput\\n\\n\\n8\\n8\\n2\\n12\\n\\nNote\\n\\nIn the first test case you can cut the bi-table as follows:\\n\\n * \\\\begin{bmatrix} 0\\\\\\\\\\\\ 1 \\\\end{bmatrix}, its \\\\operatorname{MEX} is 2.\\n * \\\\begin{bmatrix} 10\\\\\\\\\\\\ 10 \\\\end{bmatrix}, its \\\\operatorname{MEX} is 2.\\n * \\\\begin{bmatrix} 1\\\\\\\\\\\\ 1 \\\\end{bmatrix}, its \\\\operatorname{MEX} is 0.\\n * \\\\begin{bmatrix} 0\\\\\\\\\\\\ 1 \\\\end{bmatrix}, its \\\\operatorname{MEX} is 2.\\n * \\\\begin{bmatrix} 0\\\\\\\\\\\\ 0 \\\\end{bmatrix}, its...\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"t = int(input())\\nfor _ in range(t):\\n n = int(input())\\n #a = list(map(int, input().split()))\\n #n, s = list(map(int, input().split()))\\n s1 = input()\\n s2 = input()\\n \\n s = []\\n for i in range(n):\\n if s1[i] == '0' and s2[i] == '0':\\n s.append('0')\\n elif s1[i] == '1' and s2[i] == '1':\\n s.append('1')\\n else:\\n s.append('2')\\n \\n s = ''.join(s)\\n #print(s)\\n\\n \\n i = 0\\n total = 0\\n while i < len(s) - 1:\\n \\n if s[i] == '2':\\n total += 2\\n i += 1\\n continue\\n elif s[i] == '0' and s[i+1] == '1':\\n total += 2\\n i += 2\\n elif s[i] == '1' and s[i+1] == '0':\\n total += 2\\n i += 2\\n elif s[i] == '1':\\n i += 1\\n elif s[i] == '0':\\n total += 1\\n i += 1\\n\\n \\n #print(i, s)\\n \\n if i == len(s) -1:\\n \\n if s[i] == '2':\\n total += 2\\n elif s[i] == '0':\\n total += 1\\n \\n print(total)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"On a circle lie 2n distinct points, with the following property: however you choose 3 chords that connect 3 disjoint pairs of points, no point strictly inside the circle belongs to all 3 chords. The points are numbered 1, 2, ..., 2n in clockwise order.\\n\\nInitially, k chords connect k pairs of points, in such a way that all the 2k endpoints of these chords are distinct.\\n\\nYou want to draw n - k additional chords that connect the remaining 2(n - k) points (each point must be an endpoint of exactly one chord).\\n\\nIn the end, let x be the total number of intersections among all n chords. Compute the maximum value that x can attain if you choose the n - k chords optimally.\\n\\nNote that the exact position of the 2n points is not relevant, as long as the property stated in the first paragraph holds.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. Then t test cases follow.\\n\\nThe first line of each test case contains two integers n and k (1 ≤ n ≤ 100, 0 ≤ k ≤ n) — half the number of points and the number of chords initially drawn.\\n\\nThen k lines follow. The i-th of them contains two integers x_i and y_i (1 ≤ x_i, y_i ≤ 2n, x_i ≠ y_i) — the endpoints of the i-th chord. It is guaranteed that the 2k numbers x_1, y_1, x_2, y_2, ..., x_k, y_k are all distinct.\\n\\nOutput\\n\\nFor each test case, output the maximum number of intersections that can be obtained by drawing n - k additional chords.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n4 2\\n8 2\\n1 5\\n1 1\\n2 1\\n2 0\\n10 6\\n14 6\\n2 20\\n9 10\\n13 18\\n15 12\\n11 7\\n\\n\\nOutput\\n\\n\\n4\\n0\\n1\\n14\\n\\nNote\\n\\nIn the first test case, there are three ways to draw the 2 additional chords, shown below (black chords are the ones initially drawn, while red chords are the new ones):\\n\\n\\n\\nWe see that the third way gives the maximum number of intersections, namely 4.\\n\\nIn the second test case, there are no more chords to draw. Of course, with only one chord present there are no intersections.\\n\\nIn the third test case, we can make at most one intersection by drawing chords 1-3 and 2-4, as...\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 50010, INF = 0x3f3f3f3f;\\nvector > q;\\nbool st[N];\\nvoid solve() {\\n int n, k;\\n cin >> n >> k;\\n q.clear();\\n memset(st, false, sizeof st);\\n for (int i = 0; i < k; i++) {\\n int a, b;\\n cin >> a >> b;\\n if (a > b) swap(a, b);\\n q.push_back({a, b});\\n st[a] = st[b] = true;\\n }\\n vector res;\\n for (int i = 1; i <= 2 * n; i++)\\n if (!st[i]) res.push_back(i);\\n sort(res.begin(), res.end());\\n for (int i = 0, j = res.size() \\/ 2; i < res.size() \\/ 2; i++, j++)\\n q.push_back({res[i], res[j]});\\n int ans = 0;\\n for (int i = 0; i < q.size(); i++)\\n for (int j = 0; j < q.size(); j++) {\\n if (i == j) continue;\\n if (q[j].first >= q[i].first && q[j].first <= q[i].second &&\\n !(q[j].second >= q[i].first && q[j].second <= q[i].second))\\n ans++;\\n }\\n cout << ans << endl;\\n}\\nint main() {\\n int T;\\n cin >> T;\\n while (T--) {\\n solve();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nYou are given a permutation p consisting of n integers 1, 2, ..., n (a permutation is an array where each element from 1 to n occurs exactly once).\\n\\nLet's call an array a bipartite if the following undirected graph is bipartite:\\n\\n * the graph consists of n vertices; \\n * two vertices i and j are connected by an edge if i < j and a_i > a_j. \\n\\n\\n\\nYour task is to find a bipartite array of integers a of size n, such that a_i = p_i or a_i = -p_i, or report that no such array exists. If there are multiple answers, print any of them.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 2 ⋅ 10^5) — the number of test cases.\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 10^6) — the size of the permutation.\\n\\nThe second line contains n integers p_1, p_2, ..., p_n.\\n\\nThe sum of n over all test cases doesn't exceed 10^6.\\n\\nOutput\\n\\nFor each test case, print the answer in the following format. If such an array a does not exist, print \\\"NO\\\" in a single line. Otherwise, print \\\"YES\\\" in the first line and n integers — array a in the second line.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n1 2 3\\n6\\n1 3 2 6 5 4\\n4\\n4 1 3 2\\n8\\n3 2 1 6 7 8 5 4\\n\\n\\nOutput\\n\\n\\nYES\\n1 2 3\\nNO\\nYES\\n-4 -1 -3 -2\\nYES\\n-3 -2 1 6 7 -8 -5 -4\",\"targets\":\"#include \\nusing namespace std;\\nconst int INF = 1e9;\\nconst int N = 1000 * 1000 + 13;\\nint n;\\nint p[N], a[N];\\nint dp[N][2][2];\\npair pr[N][2][2];\\nvoid solve() {\\n scanf(\\\"%d\\\", &n);\\n for (int i = 0; i < int(n); ++i) scanf(\\\"%d\\\", &p[i]);\\n for (int i = 0; i < int(n); ++i)\\n for (int pos = 0; pos < int(2); ++pos)\\n for (int sg = 0; sg < int(2); ++sg) dp[i][pos][sg] = INF;\\n dp[0][0][0] = dp[0][0][1] = -INF;\\n for (int i = 0; i < int(n - 1); ++i)\\n for (int pos = 0; pos < int(2); ++pos)\\n for (int sg = 0; sg < int(2); ++sg)\\n if (dp[i][pos][sg] != INF) {\\n for (int nsg = 0; nsg < int(2); ++nsg) {\\n int x = sg ? -p[i] : p[i];\\n int y = dp[i][pos][sg];\\n if (pos) swap(x, y);\\n int z = nsg ? -p[i + 1] : p[i + 1];\\n if (z > x) {\\n if (dp[i + 1][0][nsg] > y) {\\n dp[i + 1][0][nsg] = y;\\n pr[i + 1][0][nsg] = make_pair(pos, sg);\\n }\\n } else if (z > y) {\\n if (dp[i + 1][1][nsg] > x) {\\n dp[i + 1][1][nsg] = x;\\n pr[i + 1][1][nsg] = make_pair(pos, sg);\\n }\\n }\\n }\\n }\\n int pos = -1, sg = -1;\\n for (int j = 0; j < int(2); ++j)\\n for (int k = 0; k < int(2); ++k)\\n if (dp[n - 1][j][k] != INF) pos = j, sg = k;\\n if (pos == -1) {\\n puts(\\\"NO\\\");\\n return;\\n }\\n for (int i = n - 1; i >= 0; i--) {\\n a[i] = sg ? -p[i] : p[i];\\n tie(pos, sg) = pr[i][pos][sg];\\n }\\n puts(\\\"YES\\\");\\n for (int i = 0; i < int(n); ++i) printf(\\\"%d \\\", a[i]);\\n puts(\\\"\\\");\\n}\\nint main() {\\n int t;\\n scanf(\\\"%d\\\", &t);\\n while (t--) solve();\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Monocarp is playing a computer game. Now he wants to complete the first level of this game.\\n\\nA level is a rectangular grid of 2 rows and n columns. Monocarp controls a character, which starts in cell (1, 1) — at the intersection of the 1-st row and the 1-st column.\\n\\nMonocarp's character can move from one cell to another in one step if the cells are adjacent by side and\\/or corner. Formally, it is possible to move from cell (x_1, y_1) to cell (x_2, y_2) in one step if |x_1 - x_2| ≤ 1 and |y_1 - y_2| ≤ 1. Obviously, it is prohibited to go outside the grid.\\n\\nThere are traps in some cells. If Monocarp's character finds himself in such a cell, he dies, and the game ends.\\n\\nTo complete a level, Monocarp's character should reach cell (2, n) — at the intersection of row 2 and column n.\\n\\nHelp Monocarp determine if it is possible to complete the level.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. Then the test cases follow. Each test case consists of three lines.\\n\\nThe first line contains a single integer n (3 ≤ n ≤ 100) — the number of columns.\\n\\nThe next two lines describe the level. The i-th of these lines describes the i-th line of the level — the line consists of the characters '0' and '1'. The character '0' corresponds to a safe cell, the character '1' corresponds to a trap cell.\\n\\nAdditional constraint on the input: cells (1, 1) and (2, n) are safe.\\n\\nOutput\\n\\nFor each test case, output YES if it is possible to complete the level, and NO otherwise.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n000\\n000\\n4\\n0011\\n1100\\n4\\n0111\\n1110\\n6\\n010101\\n101010\\n\\n\\nOutput\\n\\n\\nYES\\nYES\\nNO\\nYES\\n\\nNote\\n\\nConsider the example from the statement.\\n\\nIn the first test case, one of the possible paths is (1, 1) → (2, 2) → (2, 3).\\n\\nIn the second test case, one of the possible paths is (1, 1) → (1, 2) → (2, 3) → (2, 4).\\n\\nIn the fourth test case, one of the possible paths is (1, 1) → (2, 2) → (1, 3) → (2, 4) → (1, 5) → (2, 6).\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"for _ in range(int(input())):\\n n = int(input())\\n a = [[0, 0] for i in range(n)]\\n used = [[0, 0] for i in range(n)]\\n b = list(map(int, ' '.join(input().split())))\\n for i in range(n):\\n a[i][0] = b[i]\\n b = list(map(int, ' '.join(input().split())))\\n for i in range(n):\\n a[i][1] = b[i]\\n if a[0][1] == 1:\\n used[0][1] = 1\\n for i in range(1, n):\\n if not used[i - 1][0] or not used[i - 1][1]:\\n if a[i][0] and a[i][1]:\\n used[i] = [1, 1]\\n elif a[i][0] and not a[i][1]:\\n used[i] = [1, 0]\\n elif not a[i][0] and a[i][1]:\\n used[i] = [0, 1]\\n else:\\n used[i] = [0, 0]\\n else:\\n used[i] = [1, 1]\\n if not used[n - 1][1]:\\n print(\\\"YES\\\")\\n else:\\n print(\\\"NO\\\")\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A frog is about to return to the burrow. The burrow is D centimeters ahead of the frog, and the frog goes straight toward the burrow. There are only two actions that a frog can do:\\n\\n* Large jump (go forward L centimeters)\\n* Small jump (go 1 cm forward)\\n\\n\\n\\nThe frog aims to just land in the burrow without jumping over it.\\n\\nCreate a program that asks how many times a frog needs to jump to return to its burrow.\\n\\n\\n\\nInput\\n\\nThe input is given in the following format.\\n\\n\\nDL\\n\\n\\nThe input is one line, given the distance D (1 ≤ D ≤ 10000) to the burrow and the distance L (2 ≤ L ≤ 10000) for the frog to travel on a large jump.\\n\\nOutput\\n\\nPrint on one line how many times the frog needs to jump.\\n\\nExamples\\n\\nInput\\n\\n10 5\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n7 4\\n\\n\\nOutput\\n\\n4\\nUsing python3 can you solve the prior task?\",\"targets\":\"import math\\nD,L = map(int, input().split())\\nc = D \\/ L + D % L\\nprint(math.floor(c))\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A car moves from point A to point B at speed v meters per second. The action takes place on the X-axis. At the distance d meters from A there are traffic lights. Starting from time 0, for the first g seconds the green light is on, then for the following r seconds the red light is on, then again the green light is on for the g seconds, and so on.\\n\\nThe car can be instantly accelerated from 0 to v and vice versa, can instantly slow down from the v to 0. Consider that it passes the traffic lights at the green light instantly. If the car approaches the traffic lights at the moment when the red light has just turned on, it doesn't have time to pass it. But if it approaches the traffic lights at the moment when the green light has just turned on, it can move. The car leaves point A at the time 0.\\n\\nWhat is the minimum time for the car to get from point A to point B without breaking the traffic rules?\\n\\nInput\\n\\nThe first line contains integers l, d, v, g, r (1 ≤ l, d, v, g, r ≤ 1000, d < l) — the distance between A and B (in meters), the distance from A to the traffic lights, car's speed, the duration of green light and the duration of red light.\\n\\nOutput\\n\\nOutput a single number — the minimum time that the car needs to get from point A to point B. Your output must have relative or absolute error less than 10 - 6.\\n\\nExamples\\n\\nInput\\n\\n2 1 3 4 5\\n\\n\\nOutput\\n\\n0.66666667\\n\\n\\nInput\\n\\n5 4 3 1 1\\n\\n\\nOutput\\n\\n2.33333333\\nThe above is tricky. Write me a correct solution in PYTHON.\",\"targets\":\"import math\\nl,d,v,g,r=map(int,raw_input().split())\\nL=(d+0.0)\\/v\\nR=(d+0.0)\\/v+(g+r)\\nfor i in xrange(300):\\n M=(L+R)\\/2\\n if math.ceil(L\\/(g+r))!=math.ceil(M\\/(g+r)):\\n R=M\\n else:\\n L=M\\nL=(d+0.0)\\/v\\nif R-L>r+1e-8:\\n R=L\\nprint (R-L)+(l+0.0)\\/v\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Igor the analyst has adopted n little bunnies. As we all know, bunnies love carrots. Thus, Igor has bought a carrot to be shared between his bunnies. Igor wants to treat all the bunnies equally, and thus he wants to cut the carrot into n pieces of equal area. \\n\\nFormally, the carrot can be viewed as an isosceles triangle with base length equal to 1 and height equal to h. Igor wants to make n - 1 cuts parallel to the base to cut the carrot into n pieces. He wants to make sure that all n pieces have the same area. Can you help Igor determine where to cut the carrot so that each piece have equal area?\\n\\n Illustration to the first example.\\n\\nInput\\n\\nThe first and only line of input contains two space-separated integers, n and h (2 ≤ n ≤ 1000, 1 ≤ h ≤ 105).\\n\\nOutput\\n\\nThe output should contain n - 1 real numbers x1, x2, ..., xn - 1. The number xi denotes that the i-th cut must be made xi units away from the apex of the carrot. In addition, 0 < x1 < x2 < ... < xn - 1 < h must hold. \\n\\nYour output will be considered correct if absolute or relative error of every number in your output doesn't exceed 10 - 6.\\n\\nFormally, let your answer be a, and the jury's answer be b. Your answer is considered correct if .\\n\\nExamples\\n\\nInput\\n\\n3 2\\n\\n\\nOutput\\n\\n1.154700538379 1.632993161855\\n\\n\\nInput\\n\\n2 100000\\n\\n\\nOutput\\n\\n70710.678118654752\\n\\nNote\\n\\nDefinition of isosceles triangle: .\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int n;\\n double h, area, ans;\\n cin >> n >> h;\\n area = .5 * h;\\n for (int i = 1; i < n; i++) {\\n ans = sqrt((i * area * 2) \\/ ((double)n * h));\\n ans = h * ans;\\n printf(\\\"%.12f \\\", ans);\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Polycarp has found a table having an infinite number of rows and columns. The rows are numbered from 1, starting from the topmost one. The columns are numbered from 1, starting from the leftmost one.\\n\\nInitially, the table hasn't been filled and Polycarp wants to fix it. He writes integers from 1 and so on to the table as follows.\\n\\n The figure shows the placement of the numbers from 1 to 10. The following actions are denoted by the arrows.\\n\\nThe leftmost topmost cell of the table is filled with the number 1. Then he writes in the table all positive integers beginning from 2 sequentially using the following algorithm.\\n\\nFirst, Polycarp selects the leftmost non-filled cell in the first row and fills it. Then, while the left neighbor of the last filled cell is filled, he goes down and fills the next cell. So he goes down until the last filled cell has a non-filled neighbor to the left (look at the vertical arrow going down in the figure above).\\n\\nAfter that, he fills the cells from the right to the left until he stops at the first column (look at the horizontal row in the figure above). Then Polycarp selects the leftmost non-filled cell in the first row, goes down, and so on.\\n\\nA friend of Polycarp has a favorite number k. He wants to know which cell will contain the number. Help him to find the indices of the row and the column, such that the intersection of the row and the column is the cell containing the number k.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 100) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one line containing one integer k (1 ≤ k ≤ 10^9) which location must be found.\\n\\nOutput\\n\\nFor each test case, output in a separate line two integers r and c (r, c ≥ 1) separated by spaces — the indices of the row and the column containing the cell filled by the number k, respectively.\\n\\nExample\\n\\nInput\\n\\n\\n7\\n11\\n14\\n5\\n4\\n1\\n2\\n1000000000\\n\\n\\nOutput\\n\\n\\n2 4\\n4 3\\n1 3\\n2 1\\n1 1\\n1 2\\n31623 14130\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nint main() {\\n int a;\\n cin >> a;\\n for (int i = 0; i < a; i++) {\\n long long b;\\n cin >> b;\\n long long all = sqrt(b);\\n if (b == 1) {\\n cout << 1 << \\\" \\\" << 1 << endl;\\n } else if (all * all == b) {\\n cout << all << \\\" \\\" << 1 << endl;\\n } else {\\n all++;\\n long long c = (all * all) - ((all - 1) * (all - 1));\\n long long x, y;\\n if (b - (all - 1) * (all - 1) <= c \\/ 2) {\\n x = all;\\n y = b - (all - 1) * (all - 1);\\n } else if (b - (all - 1) * (all - 1) == c \\/ 2 + 1) {\\n y = all;\\n x = all;\\n } else {\\n y = all;\\n x = c - (b - (all - 1) * (all - 1)) + 1;\\n }\\n cout << y << \\\" \\\" << x << endl;\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are the organizer of the famous \\\"Zurich Music Festival\\\". There will be n singers who will perform at the festival, identified by the integers 1, 2, ..., n. You must choose in which order they are going to perform on stage. \\n\\nYou have m friends and each of them has a set of favourite singers. More precisely, for each 1≤ i≤ m, the i-th friend likes singers s_{i,1}, s_{i, 2}, ..., \\\\,s_{i, q_i}.\\n\\nA friend of yours is happy if the singers he likes perform consecutively (in an arbitrary order). An ordering of the singers is valid if it makes all your friends happy.\\n\\nCompute the number of valid orderings modulo 998 244 353.\\n\\nInput\\n\\nThe first line contains two integers n and m (1≤ n,\\\\,m≤ 100) — the number of singers and the number of friends correspondingly.\\n\\nThe i-th of the next m lines contains the integer q_i (1≤ q_i≤ n) — the number of favorite singers of the i-th friend – followed by the q_i integers s_{i,1}, s_{i, 2}, ..., \\\\,s_{i, q_i} (1≤ s_{i,1}\\nusing namespace std;\\nconst int maxn = (int)1e3 + 9, maxm = (int)1e6 + 9;\\nconst int maxc = 26, maxd = 10;\\nconst int mod = 998244353, INF = 0x3f3f3f3f;\\nconst long long INFLL = (long long)INF << 32 | INF;\\nconst double eps = (double)1e-12, pi = acos((double)-1);\\ninline int sgn(double x) { return (x > eps) - (x < -eps); }\\ninline bool is_prime(int x) {\\n if (x <= 2 || !(x & 1)) return x == 2;\\n for (int i = 3; i * i <= x; i += 2)\\n if (x % i == 0) return 0;\\n return 1;\\n}\\ninline long long mod_mul(long long x, long long y, long long mod) {\\n long long ret = x * y - (long long)((long double)x * y \\/ mod + 1e-3) * mod;\\n for (; ret < 0; ret += mod)\\n ;\\n return ret;\\n}\\ninline long long mod_pow(long long x, long long k, long long mod) {\\n long long ret = mod > 1 ? 1 : 0;\\n for (; k > 0; k >>= 1, x = mod_mul(x, x, mod))\\n if (k & 1) ret = mod_mul(ret, x, mod);\\n return ret;\\n}\\nclass PQTree {\\n private:\\n bool failed;\\n int n, tot, rt, typ[maxn];\\n vector sub[maxn];\\n int newNode() {\\n typ[++tot] = 0;\\n vector().swap(sub[tot]);\\n return tot;\\n }\\n int newP(vector &vec) {\\n if (vec.empty()) return 0;\\n if (vec.size() == 1) return vec.back();\\n int u = newNode();\\n sub[u] = vec;\\n idx[u] = 0;\\n return u;\\n }\\n void addChild(int u, int v) {\\n if (v) sub[u].push_back(v);\\n }\\n void mergeSub(int u, int v) {\\n sub[u].insert(sub[u].end(), sub[v].begin(), sub[v].end());\\n }\\n int sz[maxn], ctr[maxn], idx[maxn];\\n int getID(int u) { return ctr[u] ? (ctr[u] < sz[u] ? 1 : 2) : 0; }\\n void dfs(int u, vector &row) {\\n sz[u] = u <= n;\\n ctr[u] = u <= n && row[u];\\n for (int v : sub[u]) {\\n dfs(v, row);\\n sz[u] += sz[v];\\n ctr[u] += ctr[v];\\n }\\n idx[u] = ctr[u] ? (ctr[u] < sz[u] ? 1 : 2) : 0;\\n }\\n int solve(int u, int uid) {\\n if (failed) return 0;\\n vector vec[3];\\n for (int v : sub[u]) vec[idx[v]].push_back(v);\\n if (vec[1].size() > 2 || (uid > 0 && vec[1].size() > 1)) {\\n failed = 1;\\n return 0;\\n }\\n if (!uid &&...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given a digital clock with n digits. Each digit shows an integer from 0 to 9, so the whole clock shows an integer from 0 to 10^n-1. The clock will show leading zeroes if the number is smaller than 10^{n-1}.\\n\\nYou want the clock to show 0 with as few operations as possible. In an operation, you can do one of the following: \\n\\n * decrease the number on the clock by 1, or \\n * swap two digits (you can choose which digits to swap, and they don't have to be adjacent). \\n\\n\\n\\nYour task is to determine the minimum number of operations needed to make the clock show 0.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^3).\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 100) — number of digits on the clock.\\n\\nThe second line of each test case contains a string of n digits s_1, s_2, …, s_n (0 ≤ s_1, s_2, …, s_n ≤ 9) — the number on the clock.\\n\\nNote: If the number is smaller than 10^{n-1} the clock will show leading zeroes.\\n\\nOutput\\n\\nFor each test case, print one integer: the minimum number of operations needed to make the clock show 0.\\n\\nExample\\n\\nInput\\n\\n\\n7\\n3\\n007\\n4\\n1000\\n5\\n00000\\n3\\n103\\n4\\n2020\\n9\\n123456789\\n30\\n001678294039710047203946100020\\n\\n\\nOutput\\n\\n\\n7\\n2\\n0\\n5\\n6\\n53\\n115\\n\\nNote\\n\\nIn the first example, it's optimal to just decrease the number 7 times.\\n\\nIn the second example, we can first swap the first and last position and then decrease the number by 1.\\n\\nIn the third example, the clock already shows 0, so we don't have to perform any operations.\\nUsing python3 can you solve the prior task?\",\"targets\":\"for _ in range(int(input())):\\n n = int(input())\\n s = input()\\n k = 0\\n for i in s[:-1]:\\n k += int(i)\\n if i != \\\"0\\\":\\n k += 1\\n k += int(s[-1])\\n print(k)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Dmitry has an array of n non-negative integers a_1, a_2, ..., a_n.\\n\\nIn one operation, Dmitry can choose any index j (1 ≤ j ≤ n) and increase the value of the element a_j by 1. He can choose the same index j multiple times.\\n\\nFor each i from 0 to n, determine whether Dmitry can make the MEX of the array equal to exactly i. If it is possible, then determine the minimum number of operations to do it.\\n\\nThe MEX of the array is equal to the minimum non-negative integer that is not in the array. For example, the MEX of the array [3, 1, 0] is equal to 2, and the array [3, 3, 1, 4] is equal to 0.\\n\\nInput\\n\\nThe first line of input data contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases in the input. \\n\\nThe descriptions of the test cases follow.\\n\\nThe first line of the description of each test case contains a single integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the length of the array a.\\n\\nThe second line of the description of each test case contains n integers a_1, a_2, ..., a_n (0 ≤ a_i ≤ n) — elements of the array a.\\n\\nIt is guaranteed that the sum of the values n over all test cases in the test does not exceed 2⋅10^5.\\n\\nOutput\\n\\nFor each test case, output n + 1 integer — i-th number is equal to the minimum number of operations for which you can make the array MEX equal to i (0 ≤ i ≤ n), or -1 if this cannot be done.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n3\\n0 1 3\\n7\\n0 1 2 3 4 3 2\\n4\\n3 0 0 0\\n7\\n4 6 2 3 5 0 5\\n5\\n4 0 1 0 4\\n\\n\\nOutput\\n\\n\\n1 1 0 -1 \\n1 1 2 2 1 0 2 6 \\n3 0 1 4 3 \\n1 0 -1 -1 -1 -1 -1 -1 \\n2 1 0 2 -1 -1 \\n\\nNote\\n\\nIn the first set of example inputs, n=3:\\n\\n * to get MEX=0, it is enough to perform one increment: a_1++; \\n * to get MEX=1, it is enough to perform one increment: a_2++; \\n * MEX=2 for a given array, so there is no need to perform increments; \\n * it is impossible to get MEX=3 by performing increments. \\nimpor\",\"targets\":\"t java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.io.PrintWriter;\\nimport java.util.*;\\n\\npublic class taske {\\n public static void main(String[] args) {\\n FastScanner in = new FastScanner();\\n PrintWriter out = new PrintWriter(System.out);\\n int tt = in.nextInt();\\n while (tt-- > 0) {\\n taske sol = new taske();\\n sol.solve(in, out);\\n }\\n out.flush();\\n }\\n\\n void solve(FastScanner in, PrintWriter out) {\\n int n = in.nextInt();\\n int a[] = new int[n];\\n int cnt[] = new int[n + 10];\\n for (int i = 0; i < n; i++) {\\n a[i] = in.nextInt();\\n cnt[a[i]]++;\\n }\\n long ans[] = new long[n + 10];\\n Arrays.fill(ans, -1);\\n Stack s = new Stack<>();\\n long sum = 0;\\n for (int i = 0; i <= n; i++) {\\n if (i > 0 && cnt[i - 1] == 0) {\\n if (s.isEmpty()) {\\n break;\\n }\\n int x = s.pop();\\n sum += (long) i - 1 - x;\\n }\\n ans[i] = sum + cnt[i];\\n if (i > 0) {\\n for (int j = 0; j < cnt[i - 1] - 1; j++) {\\n s.add(i - 1);\\n }\\n }\\n }\\n for (int i = 0; i <= n; i++) {\\n out.printf(\\\"%d \\\", ans[i]);\\n }\\n out.println(\\\"\\\");\\n }\\n\\n static class FastScanner {\\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\\n StringTokenizer st = new StringTokenizer(\\\"\\\");\\n String next() {\\n while (!st.hasMoreTokens()) {\\n try {\\n st = new StringTokenizer(br.readLine());\\n } catch (IOException e) {\\n e.printStackTrace();\\n }\\n }\\n return st.nextToken();\\n }\\n int nextInt() { return Integer.parseInt(next()); }\\n long nextLong() { return Long.parseLong(next()); }\\n float nextFloat() {...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A robot cleaner is placed on the floor of a rectangle room, surrounded by walls. The floor consists of n rows and m columns. The rows of the floor are numbered from 1 to n from top to bottom, and columns of the floor are numbered from 1 to m from left to right. The cell on the intersection of the r-th row and the c-th column is denoted as (r,c). The initial position of the robot is (r_b, c_b).\\n\\nIn one second, the robot moves by dr rows and dc columns, that is, after one second, the robot moves from the cell (r, c) to (r + dr, c + dc). Initially dr = 1, dc = 1. If there is a vertical wall (the left or the right walls) in the movement direction, dc is reflected before the movement, so the new value of dc is -dc. And if there is a horizontal wall (the upper or lower walls), dr is reflected before the movement, so the new value of dr is -dr.\\n\\nEach second (including the moment before the robot starts moving), the robot cleans every cell lying in the same row or the same column as its position. There is only one dirty cell at (r_d, c_d). The job of the robot is to clean that dirty cell.\\n\\n Illustration for the first example. The blue arc is the robot. The red star is the target dirty cell. Each second the robot cleans a row and a column, denoted by yellow stripes.\\n\\nGiven the floor size n and m, the robot's initial position (r_b, c_b) and the dirty cell's position (r_d, c_d), find the time for the robot to do its job.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^4). Description of the test cases follows.\\n\\nA test case consists of only one line, containing six integers n, m, r_b, c_b, r_d, and c_d (1 ≤ n, m ≤ 100, 1 ≤ r_b, r_d ≤ n, 1 ≤ c_b, c_d ≤ m) — the sizes of the room, the initial position of the robot and the position of the dirt cell.\\n\\nOutput\\n\\nFor each test case, print an integer — the time for the robot to clean the dirty cell. We can show that the robot always cleans the dirty cell eventually.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n10 10 6 1 2 8\\n10 10 9 9 1...\",\"targets\":\"\\/\\/1623A\\nimport java.util.*;\\npublic class Robot_Cleaner\\n{\\n public static void main(String args[])\\n {\\n Scanner sc=new Scanner(System.in);\\n int t=sc.nextInt();\\n for(int i=1;i<=t;i++)\\n {\\n String s[]=(sc.next()+sc.nextLine()).split(\\\" \\\");\\n int n=Integer.parseInt(s[0]),m=Integer.parseInt(s[1]),rb=Integer.parseInt(s[2]),cb=Integer.parseInt(s[3]),rd=Integer.parseInt(s[4]),cd=Integer.parseInt(s[5]),s1=Math.abs(rb-rd),s2=Math.abs(cb-cd);\\n if(rb>rd) s1+=(2*(n-rb));\\n if(cb>cd) s2+=(2*(m-cb));\\n System.out.println(Math.min(s1,s2));\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Gregor is learning about RSA cryptography, and although he doesn't understand how RSA works, he is now fascinated with prime numbers and factoring them.\\n\\nGregor's favorite prime number is P. Gregor wants to find two bases of P. Formally, Gregor is looking for two integers a and b which satisfy both of the following properties.\\n\\n * P mod a = P mod b, where x mod y denotes the remainder when x is divided by y, and \\n * 2 ≤ a < b ≤ P. \\n\\n\\n\\nHelp Gregor find two bases of his favorite prime number!\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 1000).\\n\\nEach subsequent line contains the integer P (5 ≤ P ≤ {10}^9), with P guaranteed to be prime.\\n\\nOutput\\n\\nYour output should consist of t lines. Each line should consist of two integers a and b (2 ≤ a < b ≤ P). If there are multiple possible solutions, print any.\\n\\nExample\\n\\nInput\\n\\n\\n2\\n17\\n5\\n\\n\\nOutput\\n\\n\\n3 5\\n2 4\\n\\nNote\\n\\nThe first query is P=17. a=3 and b=5 are valid bases in this case, because 17 mod 3 = 17 mod 5 = 2. There are other pairs which work as well.\\n\\nIn the second query, with P=5, the only solution is a=2 and b=4.\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n long long int t;\\n cin >> t;\\n while (t--) {\\n long long int n;\\n cin >> n;\\n cout << \\\"2\\\"\\n << \\\" \\\" << n - 1 << endl;\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given two integers n and m. Find the \\\\operatorname{MEX} of the sequence n ⊕ 0, n ⊕ 1, …, n ⊕ m. Here, ⊕ is the [bitwise XOR operator](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#XOR).\\n\\n\\\\operatorname{MEX} of the sequence of non-negative integers is the smallest non-negative integer that doesn't appear in this sequence. For example, \\\\operatorname{MEX}(0, 1, 2, 4) = 3, and \\\\operatorname{MEX}(1, 2021) = 0. \\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 30 000) — the number of test cases.\\n\\nThe first and only line of each test case contains two integers n and m (0 ≤ n, m ≤ 10^9).\\n\\nOutput\\n\\nFor each test case, print a single integer — the answer to the problem.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n3 5\\n4 6\\n3 2\\n69 696\\n123456 654321\\n\\n\\nOutput\\n\\n\\n4\\n3\\n0\\n640\\n530866\\n\\nNote\\n\\nIn the first test case, the sequence is 3 ⊕ 0, 3 ⊕ 1, 3 ⊕ 2, 3 ⊕ 3, 3 ⊕ 4, 3 ⊕ 5, or 3, 2, 1, 0, 7, 6. The smallest non-negative integer which isn't present in the sequence i. e. the \\\\operatorname{MEX} of the sequence is 4.\\n\\nIn the second test case, the sequence is 4 ⊕ 0, 4 ⊕ 1, 4 ⊕ 2, 4 ⊕ 3, 4 ⊕ 4, 4 ⊕ 5, 4 ⊕ 6, or 4, 5, 6, 7, 0, 1, 2. The smallest non-negative integer which isn't present in the sequence i. e. the \\\\operatorname{MEX} of the sequence is 3.\\n\\nIn the third test case, the sequence is 3 ⊕ 0, 3 ⊕ 1, 3 ⊕ 2, or 3, 2, 1. The smallest non-negative integer which isn't present in the sequence i. e. the \\\\operatorname{MEX} of the sequence is 0.\\nUsing java can you solve the prior task?\",\"targets\":\"import java.util.*;\\nimport java.util.Map.Entry;\\n\\n\\nimport java.io.*;\\nimport static java.util.Map.Entry.*;\\n\\n\\/* Name of the class has to be \\\"Main\\\" only if the class is public. *\\/\\npublic class Main\\n{\\n\\tstatic long mod=(long) (1e9+7); \\n\\tpublic static void main (String[] args) throws Exception\\n\\t{\\n\\t\\t\\n\\t\\tfinal long mod1=(long) 1e9+7;\\n\\t\\tReader s=new Reader();\\n\\t\\t PrintWriter pt=new PrintWriter(System.out);\\n\\t\\t \\n\\t\\t BufferedReader br=new BufferedReader(new InputStreamReader(System.in));\\n\\t\\t int T=s.nextInt();\\n\\/\\/\\t\\t int T=Integer.parseInt(br.readLine());\\n\\/\\/\\t\\t int T=1;\\n\\t\\t \\n\\t\\t while(T-->0) {\\n\\t\\t\\t int n=s.nextInt();\\n\\t\\t\\t int m=s.nextInt();\\n\\t\\t\\t if(m hm=new HashMap();\\n while (n%2==0)\\n {\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"n students attended the first meeting of the Berland SU programming course (n is even). All students will be divided into two groups. Each group will be attending exactly one lesson each week during one of the five working days (Monday, Tuesday, Wednesday, Thursday and Friday), and the days chosen for the groups must be different. Furthermore, both groups should contain the same number of students.\\n\\nEach student has filled a survey in which they told which days of the week are convenient for them to attend a lesson, and which are not. \\n\\nYour task is to determine if it is possible to choose two different week days to schedule the lessons for the group (the first group will attend the lesson on the first chosen day, the second group will attend the lesson on the second chosen day), and divide the students into two groups, so the groups have equal sizes, and for each student, the chosen lesson day for their group is convenient.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.\\n\\nThen the descriptions of t testcases follow.\\n\\nThe first line of each testcase contains one integer n (2 ≤ n ≤ 1 000) — the number of students.\\n\\nThe i-th of the next n lines contains 5 integers, each of them is 0 or 1. If the j-th integer is 1, then the i-th student can attend the lessons on the j-th day of the week. If the j-th integer is 0, then the i-th student cannot attend the lessons on the j-th day of the week. \\n\\nAdditional constraints on the input: for each student, at least one of the days of the week is convenient, the total number of students over all testcases doesn't exceed 10^5.\\n\\nOutput\\n\\nFor each testcase print an answer. If it's possible to divide the students into two groups of equal sizes and choose different days for the groups so each student can attend the lesson in the chosen day of their group, print \\\"YES\\\" (without quotes). Otherwise, print \\\"NO\\\" (without quotes). \\n\\nExample\\n\\nInput\\n\\n\\n2\\n4\\n1 0 0 1 0\\n0 1 0 0 1\\n0 0 0 1 0\\n0 1 0 1 0\\n2\\n0 0 0 1 0\\n0 0 0 1 0\\n\\n\\nOutput\\n\\n\\nYES\\nNO\\n\\nNote\\n\\nIn...\\nfor _\",\"targets\":\"in range(int(input())):\\n\\tn = int(input())\\n\\ta = list()\\n\\tf = False\\n\\tfor i in range(n):\\n\\t\\ta.append(list(map(int, input().split())))\\n\\tfor i in range(5):\\n\\t\\tfor j in range(i + 1, 5):\\n\\t\\t\\tp = q = r = 0\\n\\t\\t\\tfor k in range(n):\\n\\t\\t\\t\\tp += (a[k][i] == 1)\\n\\t\\t\\t\\tq += (a[k][j] == 1)\\n\\t\\t\\t\\tr += (a[k][j] == 1 and a[k][i] == 1)\\n\\t\\t\\tp -= r\\n\\t\\t\\tq -= r\\n\\t\\t\\tif p <= n \\/\\/ 2 and q <= n \\/\\/ 2 and p + q + r == n:\\n\\t\\t\\t\\tf = True\\n\\tprint(\\\"YES\\\" if f else \\\"NO\\\")\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 solution for \\\"Given n, find any array a_1, a_2, …, a_n of integers such that all of the following conditions hold: \\n\\n * 1 ≤ a_i ≤ 10^9 for every i from 1 to n.\\n\\n * a_1 < a_2 < … = a):\\n b *= 2\\n a *= 3\\n i += 1\\n return i\\n\\na, b = map(int, input().split())\\nprint(func(a, b))\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Ann and Borya have n piles with candies and n is even number. There are ai candies in pile with number i.\\n\\nAnn likes numbers which are square of some integer and Borya doesn't like numbers which are square of any integer. During one move guys can select some pile with candies and add one candy to it (this candy is new and doesn't belong to any other pile) or remove one candy (if there is at least one candy in this pile). \\n\\nFind out minimal number of moves that is required to make exactly n \\/ 2 piles contain number of candies that is a square of some integer and exactly n \\/ 2 piles contain number of candies that is not a square of any integer.\\n\\nInput\\n\\nFirst line contains one even integer n (2 ≤ n ≤ 200 000) — number of piles with candies.\\n\\nSecond line contains sequence of integers a1, a2, ..., an (0 ≤ ai ≤ 109) — amounts of candies in each pile.\\n\\nOutput\\n\\nOutput minimal number of steps required to make exactly n \\/ 2 piles contain number of candies that is a square of some integer and exactly n \\/ 2 piles contain number of candies that is not a square of any integer. If condition is already satisfied output 0.\\n\\nExamples\\n\\nInput\\n\\n4\\n12 14 30 4\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n6\\n0 0 0 0 0 0\\n\\n\\nOutput\\n\\n6\\n\\n\\nInput\\n\\n6\\n120 110 23 34 25 45\\n\\n\\nOutput\\n\\n3\\n\\n\\nInput\\n\\n10\\n121 56 78 81 45 100 1 0 54 78\\n\\n\\nOutput\\n\\n0\\n\\nNote\\n\\nIn first example you can satisfy condition in two moves. During each move you should add one candy to second pile. After it size of second pile becomes 16. After that Borya and Ann will have two piles with number of candies which is a square of integer (second and fourth pile) and two piles with number of candies which is not a square of any integer (first and third pile).\\n\\nIn second example you should add two candies to any three piles.\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint toNumber(string s) {\\n int Number;\\n if (!(istringstream(s) >> Number)) Number = 0;\\n return Number;\\n}\\nstring toString(int number) {\\n ostringstream ostr;\\n ostr << number;\\n return ostr.str();\\n}\\nlong long ele(long long a, long long b) {\\n if (b == 0) return 1;\\n if (b % 2 == 0) {\\n return ele((a * a), b \\/ 2);\\n } else {\\n return a * ele((a * a), b \\/ 2);\\n }\\n}\\nlong long mcd(long long a, long long b) {\\n if (a == 0) return b;\\n return mcd(b % a, a);\\n}\\ndouble d_abs(long a, long b) {\\n if (a > b) {\\n return a - b;\\n }\\n return b - a;\\n}\\nset cuads;\\nint hacerCuad(int p) {\\n set::iterator mayor = cuads.upper_bound(p);\\n long long ret = 1e9;\\n if (mayor != cuads.end()) {\\n ret = min(ret, (long long)abs(*mayor - p));\\n }\\n mayor--;\\n ret = min(ret, (long long)abs(*mayor - p));\\n return ret;\\n}\\nvoid solve() {\\n int n;\\n cin >> n;\\n vector > si, no;\\n for (int i = 0; i < (int)(n); i++) {\\n int p;\\n cin >> p;\\n if (cuads.find(p) == cuads.end()) {\\n no.push_back(make_pair(hacerCuad(p), p));\\n } else {\\n si.push_back(make_pair(p == 0 ? 2 : 1, p));\\n }\\n }\\n sort(si.begin(), si.end());\\n sort(no.begin(), no.end());\\n long long cambios = 0;\\n if (si.size() > no.size()) {\\n for (int i = 0; i < (int)((si.size() - no.size()) \\/ 2); i++) {\\n cambios += si[i].first;\\n }\\n } else if (si.size() < no.size()) {\\n for (int i = 0; i < (int)((no.size() - si.size()) \\/ 2); i++) {\\n cambios += no[i].first;\\n }\\n }\\n cout << cambios << endl;\\n}\\nint main() {\\n ios::sync_with_stdio(0);\\n cin.tie(0);\\n int T;\\n T = 1;\\n for (int i = 0; i * i <= 1000300002; i++) {\\n cuads.insert(i * i);\\n }\\n while (T--) {\\n solve();\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Polycarp had an array a of 3 positive integers. He wrote out the sums of all non-empty subsequences of this array, sorted them in non-decreasing order, and got an array b of 7 integers.\\n\\nFor example, if a = \\\\{1, 4, 3\\\\}, then Polycarp wrote out 1, 4, 3, 1 + 4 = 5, 1 + 3 = 4, 4 + 3 = 7, 1 + 4 + 3 = 8. After sorting, he got an array b = \\\\{1, 3, 4, 4, 5, 7, 8\\\\}.\\n\\nUnfortunately, Polycarp lost the array a. He only has the array b left. Help him to restore the array a.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 5000) — the number of test cases.\\n\\nEach test case consists of one line which contains 7 integers b_1, b_2, ..., b_7 (1 ≤ b_i ≤ 10^9; b_i ≤ b_{i+1}). \\n\\nAdditional constraint on the input: there exists at least one array a which yields this array b as described in the statement.\\n\\nOutput\\n\\nFor each test case, print 3 integers — a_1, a_2 and a_3. If there can be several answers, print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n1 3 4 4 5 7 8\\n1 2 3 4 5 6 7\\n300000000 300000000 300000000 600000000 600000000 600000000 900000000\\n1 1 2 999999998 999999999 999999999 1000000000\\n1 2 2 3 3 4 5\\n\\n\\nOutput\\n\\n\\n1 4 3\\n4 1 2\\n300000000 300000000 300000000\\n999999998 1 1\\n1 2 2\\n\\nNote\\n\\nThe subsequence of the array a is a sequence that can be obtained from a by removing zero or more of its elements.\\n\\nTwo subsequences are considered different if index sets of elements included in them are different. That is, the values of the elements don't matter in the comparison of subsequences. In particular, any array of length 3 has exactly 7 different non-empty subsequences.\\nt = i\",\"targets\":\"nt(input())\\n\\nwhile t:\\n\\n t -= 1\\n dat = list(map(int, input().split()))\\n print(dat[0], dat[1], dat[-1] - dat[0] - dat[1])\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alice gave Bob two integers a and b (a > 0 and b ≥ 0). Being a curious boy, Bob wrote down an array of non-negative integers with \\\\operatorname{MEX} value of all elements equal to a and \\\\operatorname{XOR} value of all elements equal to b.\\n\\nWhat is the shortest possible length of the array Bob wrote?\\n\\nRecall that the \\\\operatorname{MEX} (Minimum EXcluded) of an array is the minimum non-negative integer that does not belong to the array and the \\\\operatorname{XOR} of an array is the [bitwise XOR](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#XOR) of all the elements of the array.\\n\\nInput\\n\\nThe input consists of multiple test cases. The first line contains an integer t (1 ≤ t ≤ 5 ⋅ 10^4) — the number of test cases. The description of the test cases follows.\\n\\nThe only line of each test case contains two integers a and b (1 ≤ a ≤ 3 ⋅ 10^5; 0 ≤ b ≤ 3 ⋅ 10^5) — the \\\\operatorname{MEX} and \\\\operatorname{XOR} of the array, respectively.\\n\\nOutput\\n\\nFor each test case, output one (positive) integer — the length of the shortest array with \\\\operatorname{MEX} a and \\\\operatorname{XOR} b. We can show that such an array always exists.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n1 1\\n2 1\\n2 0\\n1 10000\\n2 10000\\n\\n\\nOutput\\n\\n\\n3\\n2\\n3\\n2\\n3\\n\\nNote\\n\\nIn the first test case, one of the shortest arrays with \\\\operatorname{MEX} 1 and \\\\operatorname{XOR} 1 is [0, 2020, 2021].\\n\\nIn the second test case, one of the shortest arrays with \\\\operatorname{MEX} 2 and \\\\operatorname{XOR} 1 is [0, 1].\\n\\nIt can be shown that these arrays are the shortest arrays possible.\\nUsing python3 can you solve the prior task?\",\"targets\":\"t = int(input())\\nfor _ in range(t):\\n def computeXOR(n) :\\n if n % 4 == 0 :\\n return n\\n if n % 4 == 1 :\\n return 1\\n if n % 4 == 2 :\\n return n + 1\\n return 0\\n n,k = map(int , input().split())\\n xor= computeXOR(n-1)\\n if xor==k:\\n print(n)\\n elif xor!=k and xor!=0 and xor^k!=n:\\n print(n+1)\\n elif xor!=k and xor!=0 and xor^k==n:\\n print(n+2)\\n elif xor!=k and xor==0 and n!=k:\\n print(n+1)\\n elif xor!=k and xor==0 and n==k:\\n print(n+2)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nIahub and Iahubina went to a date at a luxury restaurant. Everything went fine until paying for the food. Instead of money, the waiter wants Iahub to write a Hungry sequence consisting of n integers. \\n\\nA sequence a1, a2, ..., an, consisting of n integers, is Hungry if and only if: \\n\\n * Its elements are in increasing order. That is an inequality ai < aj holds for any two indices i, j (i < j). \\n * For any two indices i and j (i < j), aj must not be divisible by ai. \\n\\n\\n\\nIahub is in trouble, so he asks you for help. Find a Hungry sequence with n elements.\\n\\nInput\\n\\nThe input contains a single integer: n (1 ≤ n ≤ 105).\\n\\nOutput\\n\\nOutput a line that contains n space-separated integers a1 a2, ..., an (1 ≤ ai ≤ 107), representing a possible Hungry sequence. Note, that each ai must not be greater than 10000000 (107) and less than 1.\\n\\nIf there are multiple solutions you can output any one.\\n\\nExamples\\n\\nInput\\n\\n3\\n\\n\\nOutput\\n\\n2 9 15\\n\\n\\nInput\\n\\n5\\n\\n\\nOutput\\n\\n11 14 20 27 31\",\"targets\":\"#include \\nusing namespace std;\\nconst int MAXN = 2 * 1e6 + 4;\\nint used[MAXN];\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n std::ios::sync_with_stdio(false);\\n used[0] = 1;\\n used[1] = 1;\\n for (int i = 2; i < MAXN; i++) {\\n if (used[i] == 0) {\\n for (int j = i + i; j < MAXN; j += i) {\\n used[j] = 1;\\n }\\n }\\n }\\n int n;\\n cin >> n;\\n for (int i = 0; i < MAXN; i++) {\\n if (used[i] == 0) {\\n cout << i << \\\" \\\";\\n n--;\\n if (n == 0) {\\n return 0;\\n }\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"It is a simplified version of problem F2. The difference between them is the constraints (F1: k ≤ 2, F2: k ≤ 10).\\n\\nYou are given an integer n. Find the minimum integer x such that x ≥ n and the number x is k-beautiful.\\n\\nA number is called k-beautiful if its decimal representation having no leading zeroes contains no more than k different digits. E.g. if k = 2, the numbers 3434443, 55550, 777 and 21 are k-beautiful whereas the numbers 120, 445435 and 998244353 are not.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10^4) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one line containing two integers n and k (1 ≤ n ≤ 10^9, 1 ≤ k ≤ 2).\\n\\nOutput\\n\\nFor each test case output on a separate line x — the minimum k-beautiful integer such that x ≥ n.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n1 1\\n221 2\\n177890 2\\n998244353 1\\n\\n\\nOutput\\n\\n\\n1\\n221\\n181111\\n999999999\\n\\nimpo\",\"targets\":\"rt java.io.BufferedReader;\\nimport java.io.File;\\nimport java.io.FileInputStream;\\nimport java.io.FileNotFoundException;\\nimport java.io.FileOutputStream;\\nimport java.io.InputStreamReader;\\nimport java.io.PrintWriter;\\nimport java.math.BigInteger;\\nimport java.util.ArrayList;\\nimport java.util.Arrays;\\nimport java.util.BitSet;\\nimport java.util.Calendar;\\nimport java.util.Collections;\\nimport java.util.Comparator;\\nimport java.util.HashMap;\\nimport java.util.HashSet;\\nimport java.util.LinkedList;\\nimport java.util.PriorityQueue;\\nimport java.util.SortedSet;\\nimport java.util.Stack;\\nimport java.util.StringTokenizer;\\nimport java.util.TreeMap;\\nimport java.util.TreeSet;\\n\\n\\/**\\n * #\\n *\\n * @author pttrung\\n *\\/\\npublic class F1_Round_739_Div3 {\\n public static long MOD = 1000000007;\\n\\n static long[][] dp;\\n static HashMap map = new HashMap<>();\\n\\n public static void main(String[] args) throws FileNotFoundException {\\n \\/\\/ PrintWriter out = new PrintWriter(new FileOutputStream(new File(\\n \\/\\/ \\\"output.txt\\\")));\\n PrintWriter out = new PrintWriter(System.out);\\n Scanner in = new Scanner();\\n int T = in.nextInt();\\n for (int Z = 0; Z < T; Z++) {\\n int n = in.nextInt();\\n int k = in.nextInt();\\n out.println(cal(n, k));\\n }\\n out.close();\\n }\\n\\n static long cal(int n, int K) {\\n String N = \\\"\\\" + n;\\n long result = Long.MAX_VALUE;\\n if (K == 2 && map.containsKey(n)) {\\n return map.get(n);\\n }\\n for (int i = 1; i < 10; i++) {\\n int c = 0;\\n long cur = 0;\\n for (int j = 0; j < N.length(); j++) {\\n int v = N.charAt(j) - '0';\\n if (v > i) {\\n if (c < 1) {\\n c = -1;\\n }\\n } else if (v < i && c == 0) {\\n c = 1;\\n }\\n cur = cur * 10 + i;\\n }\\n if (c < 0) {\\n cur = cur * 10 + i;\\n }\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Anya loves to fold and stick. Today she decided to do just that.\\n\\nAnya has n cubes lying in a line and numbered from 1 to n from left to right, with natural numbers written on them. She also has k stickers with exclamation marks. We know that the number of stickers does not exceed the number of cubes.\\n\\nAnya can stick an exclamation mark on the cube and get the factorial of the number written on the cube. For example, if a cube reads 5, then after the sticking it reads 5!, which equals 120.\\n\\nYou need to help Anya count how many ways there are to choose some of the cubes and stick on some of the chosen cubes at most k exclamation marks so that the sum of the numbers written on the chosen cubes after the sticking becomes equal to S. Anya can stick at most one exclamation mark on each cube. Can you do it?\\n\\nTwo ways are considered the same if they have the same set of chosen cubes and the same set of cubes with exclamation marks.\\n\\nInput\\n\\nThe first line of the input contains three space-separated integers n, k and S (1 ≤ n ≤ 25, 0 ≤ k ≤ n, 1 ≤ S ≤ 1016) — the number of cubes and the number of stickers that Anya has, and the sum that she needs to get. \\n\\nThe second line contains n positive integers ai (1 ≤ ai ≤ 109) — the numbers, written on the cubes. The cubes in the input are described in the order from left to right, starting from the first one. \\n\\nMultiple cubes can contain the same numbers.\\n\\nOutput\\n\\nOutput the number of ways to choose some number of cubes and stick exclamation marks on some of them so that the sum of the numbers became equal to the given number S.\\n\\nExamples\\n\\nInput\\n\\n2 2 30\\n4 3\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\n2 2 7\\n4 3\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\n3 1 1\\n1 1 1\\n\\n\\nOutput\\n\\n6\\n\\nNote\\n\\nIn the first sample the only way is to choose both cubes and stick an exclamation mark on each of them.\\n\\nIn the second sample the only way is to choose both cubes but don't stick an exclamation mark on any of them.\\n\\nIn the third sample it is possible to choose any of the cubes in three ways, and also we may choose to stick or not to stick the...\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 2e5 + 10;\\nconst int Mod = 1e9 + 7;\\nmap Left[26], Right[26];\\nint n, k, a[30];\\nlong long sum, fact[20];\\nvoid cal(int pos, int crk, long long crSum, int last) {\\n if (pos == last) {\\n if (last != n)\\n Left[crk][crSum]++;\\n else\\n Right[crk][crSum]++;\\n return;\\n }\\n if (crk < k && a[pos] < 19) cal(pos + 1, crk + 1, crSum + fact[a[pos]], last);\\n cal(pos + 1, crk, crSum + a[pos], last);\\n cal(pos + 1, crk, crSum, last);\\n}\\nint main() {\\n ios::sync_with_stdio(false);\\n cin.tie(nullptr);\\n cin >> n >> k >> sum;\\n for (int i = 0; i < n; ++i) cin >> a[i];\\n fact[0] = 1;\\n for (long long i = 1; i < 20; ++i) fact[i] = i * fact[i - 1];\\n cal(0, 0, 0, n \\/ 2);\\n cal(n \\/ 2, 0, 0, n);\\n long long ans = 0;\\n for (int i = 0; i <= k; ++i) Left[i][0] = Right[i][0] = 1;\\n for (int i = 0; i <= k; ++i) {\\n for (auto j : Left[i]) {\\n if (j.first == sum) {\\n ans += j.second;\\n continue;\\n }\\n if (j.first == 0) continue;\\n for (int x = 0; x + i <= k; ++x) {\\n if (Right[x].count(sum - j.first))\\n ans += (j.second * Right[x][sum - j.first]);\\n }\\n }\\n }\\n for (int i = 0; i <= k; ++i) {\\n for (auto j : Right[i]) {\\n if (j.first == sum) ans += j.second;\\n }\\n }\\n cout << ans;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Everybody knows that we have been living in the Matrix for a long time. And in the new seventh Matrix the world is ruled by beavers.\\n\\nSo let's take beaver Neo. Neo has so-called \\\"deja vu\\\" outbursts when he gets visions of events in some places he's been at or is going to be at. Let's examine the phenomenon in more detail.\\n\\nWe can say that Neo's city is represented by a directed graph, consisting of n shops and m streets that connect the shops. No two streets connect the same pair of shops (besides, there can't be one street from A to B and one street from B to A). No street connects a shop with itself. As Neo passes some streets, he gets visions. No matter how many times he passes street k, every time he will get the same visions in the same order. A vision is a sequence of shops.\\n\\nWe know that Neo is going to get really shocked if he passes the way from some shop a to some shop b, possible coinciding with a, such that the list of visited shops in the real life and in the visions coincide.\\n\\nSuggest beaver Neo such path of non-zero length. Or maybe you can even count the number of such paths modulo 1000000007 (109 + 7)?..\\n\\nInput\\n\\nThe first line contains integers n and m — the number of shops and the number of streets, correspondingly, 1 ≤ n ≤ 50, . Next m lines contain the descriptions of the streets in the following format: xi yi ki v1 v2 ... vk, where xi and yi (1 ≤ xi, yi ≤ n, xi ≠ yi) are numbers of shops connected by a street, ki (0 ≤ ki ≤ n) is the number of visions on the way from xi to yi; v1, v2, ..., vk (1 ≤ vi ≤ n) describe the visions: the numbers of the shops Neo saw. Note that the order of the visions matters.\\n\\nIt is guaranteed that the total number of visions on all streets doesn't exceed 105.\\n\\n * to get 50 points, you need to find any (not necessarily simple) path of length at most 2·n, that meets the attributes described above (subproblem E1); \\n * to get 50 more points, you need to count for each length from 1 to 2·n the number of paths that have the attribute described above...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint b[51][51][51], c[51][51], d1[10001], d2[10001], n, m, i, j, k, l, x, h, t1,\\n t2;\\nlong long f[2][101][51], g[3][101][51][51], ans[101];\\nbool a[51][51], Ans1;\\nvoid work1() {\\n int i, j, k, l, x, len;\\n for (i = 1; i <= n; i++) {\\n for (j = 1; j <= n; j++)\\n if (a[i][j] && c[i][j]) {\\n for (k = 1; k <= c[i][j] - 1; k++)\\n if (b[i][j][k] == i && b[i][j][k + 1] == j) {\\n x = i;\\n h = t1 = 1;\\n d1[1] = i;\\n len = 1;\\n for (l = k - 1; l >= 1; l--) d1[++t1] = b[i][j][l], ++len;\\n while (h < t1) {\\n ++h;\\n if (len > n + n || !a[d1[h]][x]) {\\n h = -114514;\\n break;\\n }\\n for (l = c[d1[h]][x]; l >= 1; l--)\\n d1[++t1] = b[d1[h]][x][l], ++len;\\n x = d1[h];\\n }\\n if (h < t1) break;\\n x = j;\\n h = t2 = 1;\\n d2[1] = j;\\n for (l = k + 2; l <= c[i][j]; l++) d2[++t2] = b[i][j][l], ++len;\\n while (h < t2) {\\n ++h;\\n if (len > n + n || !a[x][d2[h]]) {\\n h = -114514;\\n break;\\n }\\n for (l = 1; l <= c[x][d2[h]]; l++)\\n d2[++t2] = b[x][d2[h]][l], ++len;\\n x = d2[h];\\n }\\n if (h < t2) break;\\n if (!Ans1) {\\n Ans1 = 1;\\n }\\n ++g[1][len][d1[t1]][d2[t2]];\\n break;\\n }\\n if (b[i][j][c[i][j]] == i) {\\n x = i;\\n h = t1 = 1;\\n d1[1] = i;\\n len = 1;\\n for (l = c[i][j] - 1; l >= 1; l--) d1[++t1] = b[i][j][l], ++len;\\n while (h < t1) {\\n ++h;\\n if (len > n + n || !a[d1[h]][x]) {\\n h = -114514;\\n break;\\n }\\n for (l = c[d1[h]][x]; l >= 1; l--) d1[++t1] = b[d1[h]][x][l], ++len;\\n x = d1[h];\\n }\\n if (!(len > n + n || h < t1))...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"All cities of Lineland are located on the Ox coordinate axis. Thus, each city is associated with its position xi — a coordinate on the Ox axis. No two cities are located at a single point.\\n\\nLineland residents love to send letters to each other. A person may send a letter only if the recipient lives in another city (because if they live in the same city, then it is easier to drop in).\\n\\nStrange but true, the cost of sending the letter is exactly equal to the distance between the sender's city and the recipient's city.\\n\\nFor each city calculate two values ​​mini and maxi, where mini is the minimum cost of sending a letter from the i-th city to some other city, and maxi is the the maximum cost of sending a letter from the i-th city to some other city\\n\\nInput\\n\\nThe first line of the input contains integer n (2 ≤ n ≤ 105) — the number of cities in Lineland. The second line contains the sequence of n distinct integers x1, x2, ..., xn ( - 109 ≤ xi ≤ 109), where xi is the x-coordinate of the i-th city. All the xi's are distinct and follow in ascending order.\\n\\nOutput\\n\\nPrint n lines, the i-th line must contain two integers mini, maxi, separated by a space, where mini is the minimum cost of sending a letter from the i-th city, and maxi is the maximum cost of sending a letter from the i-th city.\\n\\nExamples\\n\\nInput\\n\\n4\\n-5 -2 2 7\\n\\n\\nOutput\\n\\n3 12\\n3 9\\n4 7\\n5 12\\n\\n\\nInput\\n\\n2\\n-1 1\\n\\n\\nOutput\\n\\n2 2\\n2 2\\nSolve the task in PYTHON.\",\"targets\":\"n = input()\\na = [-10**11] + map(int, raw_input().split()) + [10**11]\\nfor x, y in [(min(a[i + 1] - a[i], a[i + 2] - a[i + 1]), max(a[i + 1] - a[1], a[-2] - a[i + 1])) for i in xrange(n)]:\\n print x, y\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Luntik has decided to try singing. He has a one-minute songs, b two-minute songs and c three-minute songs. He wants to distribute all songs into two concerts such that every song should be included to exactly one concert.\\n\\nHe wants to make the absolute difference of durations of the concerts as small as possible. The duration of the concert is the sum of durations of all songs in that concert.\\n\\nPlease help Luntik and find the minimal possible difference in minutes between the concerts durations.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases.\\n\\nEach test case consists of one line containing three integers a, b, c (1 ≤ a, b, c ≤ 10^9) — the number of one-minute, two-minute and three-minute songs.\\n\\nOutput\\n\\nFor each test case print the minimal possible difference in minutes between the concerts durations.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n1 1 1\\n2 1 3\\n5 5 5\\n1 1 2\\n\\n\\nOutput\\n\\n\\n0\\n1\\n0\\n1\\n\\nNote\\n\\nIn the first test case, Luntik can include a one-minute song and a two-minute song into the first concert, and a three-minute song into the second concert. Then the difference will be equal to 0.\\n\\nIn the second test case, Luntik can include two one-minute songs and a two-minute song and a three-minute song into the first concert, and two three-minute songs into the second concert. The duration of the first concert will be 1 + 1 + 2 + 3 = 7, the duration of the second concert will be 6. The difference of them is |7-6| = 1.\\nUsing java can you solve the prior task?\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\n\\n\\/\\/\\/\\/***************************************************************************\\n \\/* public class E_Gardener_and_Tree implements Runnable{\\n\\n public static void main(String[] args) throws Exception {\\n new Thread(null, new E_Gardener_and_Tree(), \\\"E_Gardener_and_Tree\\\", 1<<28).start();\\n }\\n public void run(){\\n WRITE YOUR CODE HERE!!!!\\n JUST WRITE EVERYTHING HERE WHICH YOU WRITE IN MAIN!!!\\n }\\n\\n }\\n*\\/\\n\\/\\/\\/\\/\\/**************************************************************************\\n\\n\\npublic class A_Luntik_and_Concerts{\\n public static void main(String[] args) {\\n FastScanner s= new FastScanner();\\n \\/\\/ PrintWriter out=new PrintWriter(System.out);\\n \\/\\/end of program\\n \\/\\/out.println(answer);\\n \\/\\/out.close();\\n StringBuilder res = new StringBuilder();\\n int t=s.nextInt();\\n int p=0;\\n while(p= 1:\\n print(1)\\n print(s)\\n return\\n for s in '2357':\\n if c[s] >= 2:\\n print(2)\\n print(s + s)\\n return\\n for s in '25':\\n if c[s] >= 1 and x[0] != s:\\n print(2)\\n print(x[0] + s)\\n return\\n if x in magic:\\n print(2)\\n print(magic[x])\\n return\\n print(l)\\n print(x)\\n\\nif __name__ == \\\"__main__\\\":\\n n = int(input())\\n for _ in range(n):\\n solve()\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"It turns out that the meaning of life is a permutation p_1, p_2, …, p_n of the integers 1, 2, …, n (2 ≤ n ≤ 100). Omkar, having created all life, knows this permutation, and will allow you to figure it out using some queries.\\n\\nA query consists of an array a_1, a_2, …, a_n of integers between 1 and n. a is not required to be a permutation. Omkar will first compute the pairwise sum of a and p, meaning that he will compute an array s where s_j = p_j + a_j for all j = 1, 2, …, n. Then, he will find the smallest index k such that s_k occurs more than once in s, and answer with k. If there is no such index k, then he will answer with 0.\\n\\nYou can perform at most 2n queries. Figure out the meaning of life p.\\n\\nInteraction\\n\\nStart the interaction by reading single integer n (2 ≤ n ≤ 100) — the length of the permutation p.\\n\\nYou can then make queries. A query consists of a single line \\\"? \\\\enspace a_1 \\\\enspace a_2 \\\\enspace … \\\\enspace a_n\\\" (1 ≤ a_j ≤ n).\\n\\nThe answer to each query will be a single integer k as described above (0 ≤ k ≤ n).\\n\\nAfter making a query do not forget to output end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use:\\n\\n * fflush(stdout) or cout.flush() in C++;\\n * System.out.flush() in Java;\\n * flush(output) in Pascal;\\n * stdout.flush() in Python;\\n * see documentation for other languages.\\n\\n\\n\\nTo output your answer, print a single line \\\"! \\\\enspace p_1 \\\\enspace p_2 \\\\enspace … \\\\enspace p_n\\\" then terminate.\\n\\nYou can make at most 2n queries. Outputting the answer does not count as a query.\\n\\nHack Format\\n\\nTo hack, first output a line containing n (2 ≤ n ≤ 100), then output another line containing the hidden permutation p_1, p_2, …, p_n of numbers from 1 to n.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n\\n2\\n\\n0\\n\\n1\\n\\n\\nOutput\\n\\n\\n\\n? 4 4 2 3 2\\n\\n? 3 5 1 5 5\\n\\n? 5 2 4 3 1\\n\\n! 3 2 1 5 4\\n\\nNote\\n\\nIn the sample, the hidden permutation p is [3, 2, 1, 5, 4]. Three queries were made.\\n\\nThe first query is a = [4, 4, 2, 3, 2]. This yields s = [3 + 4, 2 + 4, 1 + 2, 5 + 3, 4 + 2] = [7, 6, 3, 8, 6]. 6 is the only...\\\":\",\"targets\":\"import java.io.OutputStream;\\nimport java.io.IOException;\\nimport java.io.InputStream;\\nimport java.io.PrintWriter;\\nimport java.io.OutputStream;\\nimport java.util.Arrays;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.io.FileNotFoundException;\\nimport java.util.StringTokenizer;\\nimport java.io.Writer;\\nimport java.io.BufferedReader;\\nimport java.io.InputStream;\\n\\n\\/**\\n * Built using CHelper plug-in\\n * Actual solution is at the top\\n *\\n * @author Asgar Javadov\\n *\\/\\npublic class Main {\\n public static void main(String[] args) {\\n InputStream inputStream = System.in;\\n OutputStream outputStream = System.out;\\n InputReader in = new InputReader(inputStream);\\n OutputWriter out = new OutputWriter(outputStream);\\n DOmkarAndTheMeaningOfLife solver = new DOmkarAndTheMeaningOfLife();\\n solver.solve(1, in, out);\\n out.close();\\n }\\n\\n static class DOmkarAndTheMeaningOfLife {\\n public void solve(int testNumber, InputReader in, OutputWriter out) {\\n int n = in.nextInt();\\n var a = new int[n];\\n Arrays.fill(a, 1);\\n var p = new int[n];\\n\\n int[] link = new int[n];\\n Arrays.fill(link, -1);\\n for (int i = 0; i < a.length; i++) {\\n a[i] = 2;\\n var k = query(a, out, in);\\n if (k > 0 && k < i + 1) {\\n link[i] = k - 1;\\n }\\n a[i] = 1;\\n }\\n\\n Arrays.fill(a, 2);\\n var one = -1;\\n for (int i = 0; i < a.length; i++) {\\n a[i] = 1;\\n var k = query(a, out, in);\\n if (k == 0) {\\n one = i;\\n } else if (k < i + 1) {\\n link[k - 1] = i;\\n }\\n a[i] = 2;\\n }\\n\\n p[one] = 1;\\n for (int i = one; link[i] != -1; i = link[i]) {\\n p[link[i]] = p[i] + 1;\\n }\\n\\n out.print(\\\"! \\\");\\n out.println(p);\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page.\\n\\nYesterday evening Nastya did not manage to finish reading the book, so she marked the page with number k as the first page which was not read (i.e. she read all pages from the 1-st to the (k-1)-th).\\n\\nThe next day Nastya's friend Igor came and asked her, how many chapters remain to be read by Nastya? Nastya is too busy now, so she asks you to compute the number of chapters she has not completely read yet (i.e. the number of chapters she has not started to read or has finished reading somewhere in the middle).\\n\\nInput\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 100) — the number of chapters in the book.\\n\\nThere are n lines then. The i-th of these lines contains two integers l_i, r_i separated by space (l_1 = 1, l_i ≤ r_i) — numbers of the first and the last pages of the i-th chapter. It's guaranteed that l_{i+1} = r_i + 1 for all 1 ≤ i ≤ n-1, and also that every chapter contains at most 100 pages.\\n\\nThe (n+2)-th line contains a single integer k (1 ≤ k ≤ r_n) — the index of the marked page. \\n\\nOutput\\n\\nPrint a single integer — the number of chapters which has not been completely read so far.\\n\\nExamples\\n\\nInput\\n\\n\\n3\\n1 3\\n4 7\\n8 11\\n2\\n\\n\\nOutput\\n\\n\\n3\\n\\n\\nInput\\n\\n\\n3\\n1 4\\n5 9\\n10 12\\n9\\n\\n\\nOutput\\n\\n\\n2\\n\\n\\nInput\\n\\n\\n1\\n1 7\\n4\\n\\n\\nOutput\\n\\n\\n1\\n\\nNote\\n\\nIn the first example the book contains 11 pages and 3 chapters — [1;3], [4;7] and [8;11]. Nastya marked the 2-nd page, so she finished in the middle of the 1-st chapter. So, all chapters has not been read so far, so the answer is 3.\\n\\nThe book in the second example contains 12 pages and 3 chapters too, but Nastya finished reading in the middle of the 2-nd chapter, so that the answer is 2.\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nint main() {\\n int n;\\n cin >> n;\\n int a[n][2];\\n for (int i = 0; i < n; i++) {\\n for (int j = 0; j < 2; j++) {\\n cin >> a[i][j];\\n }\\n }\\n int k;\\n cin >> k;\\n int count = 0;\\n for (int x = 0; x < n; x++) {\\n if (a[x][1] >= k) {\\n count++;\\n }\\n }\\n cout << count;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Arseniy is already grown-up and independent. His mother decided to leave him alone for m days and left on a vacation. She have prepared a lot of food, left some money and washed all Arseniy's clothes. \\n\\nTen minutes before her leave she realized that it would be also useful to prepare instruction of which particular clothes to wear on each of the days she will be absent. Arseniy's family is a bit weird so all the clothes is enumerated. For example, each of Arseniy's n socks is assigned a unique integer from 1 to n. Thus, the only thing his mother had to do was to write down two integers li and ri for each of the days — the indices of socks to wear on the day i (obviously, li stands for the left foot and ri for the right). Each sock is painted in one of k colors.\\n\\nWhen mother already left Arseniy noticed that according to instruction he would wear the socks of different colors on some days. Of course, that is a terrible mistake cause by a rush. Arseniy is a smart boy, and, by some magical coincidence, he posses k jars with the paint — one for each of k colors.\\n\\nArseniy wants to repaint some of the socks in such a way, that for each of m days he can follow the mother's instructions and wear the socks of the same color. As he is going to be very busy these days he will have no time to change the colors of any socks so he has to finalize the colors now.\\n\\nThe new computer game Bota-3 was just realised and Arseniy can't wait to play it. What is the minimum number of socks that need their color to be changed in order to make it possible to follow mother's instructions and wear the socks of the same color during each of m days.\\n\\nInput\\n\\nThe first line of input contains three integers n, m and k (2 ≤ n ≤ 200 000, 0 ≤ m ≤ 200 000, 1 ≤ k ≤ 200 000) — the number of socks, the number of days and the number of available colors respectively.\\n\\nThe second line contain n integers c1, c2, ..., cn (1 ≤ ci ≤ k) — current colors of Arseniy's socks.\\n\\nEach of the following m lines contains two integers li and ri (1 ≤ li, ri ≤ n, li ≠...\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nvector g[200001];\\nint vis[200001];\\nint c[200001];\\nmap m;\\nint no;\\nvoid dfs(int i) {\\n vis[i] = 1;\\n no++;\\n m[c[i]]++;\\n for (int j = 0; j < g[i].size(); j++) {\\n if (!vis[g[i][j]]) dfs(g[i][j]);\\n }\\n}\\nint main() {\\n int n, mm, k;\\n cin >> n >> mm >> k;\\n for (int i = 1; i < n + 1; i++) cin >> c[i];\\n for (int i = 0; i < mm; i++) {\\n int x, y;\\n cin >> x >> y;\\n g[x].push_back(y);\\n g[y].push_back(x);\\n }\\n int ans = 0;\\n for (int i = 1; i < n + 1; i++) {\\n if (!vis[i]) {\\n no = 0;\\n m.clear();\\n dfs(i);\\n int yo = 0;\\n for (map::iterator it = m.begin(); it != m.end(); it++) {\\n yo = max(it->second, yo);\\n }\\n ans += (no - yo);\\n }\\n }\\n cout << ans << endl;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"As their story unravels, a timeless tale is told once again...\\n\\nShirahime, a friend of Mocha's, is keen on playing the music game Arcaea and sharing Mocha interesting puzzles to solve. This day, Shirahime comes up with a new simple puzzle and wants Mocha to solve them. However, these puzzles are too easy for Mocha to solve, so she wants you to solve them and tell her the answers. The puzzles are described as follow.\\n\\nThere are n squares arranged in a row, and each of them can be painted either red or blue.\\n\\nAmong these squares, some of them have been painted already, and the others are blank. You can decide which color to paint on each blank square.\\n\\nSome pairs of adjacent squares may have the same color, which is imperfect. We define the imperfectness as the number of pairs of adjacent squares that share the same color.\\n\\nFor example, the imperfectness of \\\"BRRRBBR\\\" is 3, with \\\"BB\\\" occurred once and \\\"RR\\\" occurred twice.\\n\\nYour goal is to minimize the imperfectness and print out the colors of the squares after painting. \\n\\nInput\\n\\nEach test contains multiple test cases. \\n\\nThe first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. Each test case consists of two lines.\\n\\nThe first line of each test case contains an integer n (1≤ n≤ 100) — the length of the squares row.\\n\\nThe second line of each test case contains a string s with length n, containing characters 'B', 'R' and '?'. Here 'B' stands for a blue square, 'R' for a red square, and '?' for a blank square.\\n\\nOutput\\n\\nFor each test case, print a line with a string only containing 'B' and 'R', the colors of the squares after painting, which imperfectness is minimized. If there are multiple solutions, print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n7\\n?R???BR\\n7\\n???R???\\n1\\n?\\n1\\nB\\n10\\n?R??RB??B?\\n\\n\\nOutput\\n\\n\\nBRRBRBR\\nBRBRBRB\\nB\\nB\\nBRRBRBBRBR\\n\\nNote\\n\\nIn the first test case, if the squares are painted \\\"BRRBRBR\\\", the imperfectness is 1 (since squares 2 and 3 have the same color), which is the minimum possible imperfectness.\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n long long int T;\\n cin >> T;\\n while (T) {\\n long long int n, f = -1;\\n cin >> n;\\n string a;\\n cin >> a;\\n for (long long int i = 0; i < n; i++) {\\n if (a[i] != '?') {\\n f = i;\\n break;\\n }\\n }\\n char x;\\n if (f % 2 == 0)\\n x = a[f];\\n else {\\n if (a[f] == 'R')\\n x = 'B';\\n else\\n x = 'R';\\n }\\n for (long long int i = 0; i < n; i++) {\\n if (a[i] == '?') a[i] = x;\\n if (a[i] == 'R') x = 'B';\\n if (a[i] == 'B') x = 'R';\\n }\\n cout << a << endl;\\n T--;\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nIt is a simplified version of problem F2. The difference between them is the constraints (F1: k ≤ 2, F2: k ≤ 10).\\n\\nYou are given an integer n. Find the minimum integer x such that x ≥ n and the number x is k-beautiful.\\n\\nA number is called k-beautiful if its decimal representation having no leading zeroes contains no more than k different digits. E.g. if k = 2, the numbers 3434443, 55550, 777 and 21 are k-beautiful whereas the numbers 120, 445435 and 998244353 are not.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10^4) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one line containing two integers n and k (1 ≤ n ≤ 10^9, 1 ≤ k ≤ 2).\\n\\nOutput\\n\\nFor each test case output on a separate line x — the minimum k-beautiful integer such that x ≥ n.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n1 1\\n221 2\\n177890 2\\n998244353 1\\n\\n\\nOutput\\n\\n\\n1\\n221\\n181111\\n999999999\",\"targets\":\"import java.util.Scanner;\\npublic class Main\\n{\\n static String go(int i,int n,int dist,String nw,int k,String ori){\\n if(dist>k){\\n return \\\"\\\";\\n }\\n if((nw.substring(0,i)).compareTo(ori.substring(0,i))<0){\\n return \\\"\\\";\\n }\\n if(i>=n){\\n return nw;\\n }\\n for(char val='0';val<='9';++val){\\n nw = nw.substring(0,i)+val+nw.substring(i+1);\\/\\/replacing val at index i in string nw\\n boolean found=false;\\n for(int j=0;j0){\\n\\t\\t int n=sc.nextInt();\\n\\t\\t int k=sc.nextInt();\\n\\t\\t String s=String.valueOf(n);\\n\\t\\t String str=\\\"\\\";\\n\\t\\t for(int i=0;i\\n\\nthen the first comment is written as \\\"hello,2,ok,0,bye,0\\\", the second is written as \\\"test,0\\\", the third comment is written as \\\"one,1,two,2,a,0,b,0\\\". The whole comments feed is written as: \\\"hello,2,ok,0,bye,0,test,0,one,1,two,2,a,0,b,0\\\". For a given comments feed in the format specified above print the comments in a different format: \\n\\n * at first, print a integer d — the maximum depth of nesting comments; \\n * after that print d lines, the i-th of them corresponds to nesting level i; \\n * for the i-th row print comments of nesting level i in the order of their appearance in the Policarp's comments feed, separated by space. \\n\\nInput\\n\\nThe first line contains non-empty comments feed in the described format. It consists of uppercase and lowercase letters of English alphabet, digits and commas. \\n\\nIt is guaranteed that each comment is a non-empty string consisting of uppercase and lowercase English characters. Each of the number of comments is integer (consisting of at least one...\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nconst int maxn = 400005;\\nstring s[maxn];\\nvector G[maxn];\\nint tot;\\nint ans;\\nint now;\\nint len;\\nchar input[1000005];\\nvoid dfs(int u, int num, int dep) {\\n ans = max(ans, dep);\\n for (int i = 0; i < num; i++) {\\n string tmp = \\\"\\\";\\n int n = 0;\\n int d = 0;\\n char c;\\n while (now <= len, c = input[now++]) {\\n if (c == '\\\\n') break;\\n if (c != ',') {\\n if (n == 0)\\n tmp += c;\\n else {\\n d = d * 10 + c - '0';\\n }\\n } else {\\n n++;\\n if (n == 2) break;\\n }\\n }\\n if (tmp == \\\"\\\") break;\\n tot++;\\n G[u].push_back(tot);\\n s[tot] = tmp;\\n dfs(tot, d, dep + 1);\\n }\\n}\\nint main() {\\n scanf(\\\"%s\\\", input + 1);\\n len = strlen(input + 1);\\n input[++len] = ',';\\n now = 1;\\n dfs(0, maxn - 1, 0);\\n queue q;\\n q.push(0);\\n q.push(-1);\\n cout << ans << endl;\\n while (!q.empty()) {\\n int p = q.front();\\n q.pop();\\n if (p == -1) {\\n if (!q.empty()) q.push(-1);\\n continue;\\n }\\n for (int i = 0; i < G[p].size(); i++) {\\n int to = G[p][i];\\n q.push(to);\\n }\\n if (p == 0)\\n continue;\\n else {\\n cout << s[p];\\n if (q.front() != -1)\\n printf(\\\" \\\");\\n else\\n printf(\\\"\\\\n\\\");\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given two strings s and t, both consisting of lowercase English letters. You are going to type the string s character by character, from the first character to the last one.\\n\\nWhen typing a character, instead of pressing the button corresponding to it, you can press the \\\"Backspace\\\" button. It deletes the last character you have typed among those that aren't deleted yet (or does nothing if there are no characters in the current string). For example, if s is \\\"abcbd\\\" and you press Backspace instead of typing the first and the fourth characters, you will get the string \\\"bd\\\" (the first press of Backspace deletes no character, and the second press deletes the character 'c'). Another example, if s is \\\"abcaa\\\" and you press Backspace instead of the last two letters, then the resulting text is \\\"a\\\".\\n\\nYour task is to determine whether you can obtain the string t, if you type the string s and press \\\"Backspace\\\" instead of typing several (maybe zero) characters of s.\\n\\nInput\\n\\nThe first line contains a single integer q (1 ≤ q ≤ 10^5) — the number of test cases.\\n\\nThe first line of each test case contains the string s (1 ≤ |s| ≤ 10^5). Each character of s is a lowercase English letter.\\n\\nThe second line of each test case contains the string t (1 ≤ |t| ≤ 10^5). Each character of t is a lowercase English letter.\\n\\nIt is guaranteed that the total number of characters in the strings over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print \\\"YES\\\" if you can obtain the string t by typing the string s and replacing some characters with presses of \\\"Backspace\\\" button, or \\\"NO\\\" if you cannot.\\n\\nYou may print each letter in any case (YES, yes, Yes will all be recognized as positive answer, NO, no and nO will all be recognized as negative answer).\\n\\nExample\\n\\nInput\\n\\n\\n4\\nababa\\nba\\nababa\\nbb\\naaa\\naaaa\\naababa\\nababa\\n\\n\\nOutput\\n\\n\\nYES\\nNO\\nNO\\nYES\\n\\nNote\\n\\nConsider the example test from the statement.\\n\\nIn order to obtain \\\"ba\\\" from \\\"ababa\\\", you may press Backspace instead of typing the first and the fourth characters.\\n\\nThere's no way...\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst int maxn = 2e5 + 5;\\nint nxt[maxn][26];\\nchar s[maxn], t[maxn];\\nint main() {\\n int T;\\n cin >> T;\\n while (T--) {\\n scanf(\\\"%s\\\", s);\\n scanf(\\\"%s\\\", t);\\n int n = strlen(s);\\n for (int i = (0); i < (26); ++i) nxt[n][i] = nxt[n + 1][i] = n;\\n for (int i = n - 1; i >= 0; --i) {\\n for (int x = (0); x < (26); ++x) nxt[i][x] = nxt[i + 1][x];\\n int x = s[i] - 'a';\\n nxt[i][x] = i;\\n }\\n int c = 0;\\n int ok = 0;\\n int len = strlen(t);\\n c = 0;\\n int p = -1;\\n for (int i = 0; i < len; ++i) {\\n int x = t[i] - 'a';\\n p = nxt[p + 1][x];\\n while (p < n && (p & 1) != c) p = nxt[p + 1][x];\\n if (p >= n) break;\\n c ^= 1;\\n }\\n if (p < n && (n - 1 - p) % 2 == 0) ok = 1;\\n c = 1;\\n p = -1;\\n for (int i = 0; i < len; ++i) {\\n int x = t[i] - 'a';\\n p = nxt[p + 1][x];\\n while (p < n && (p & 1) != c) p = nxt[p + 1][x];\\n if (p >= n) break;\\n c ^= 1;\\n }\\n if (p < n && (n - 1 - p) % 2 == 0) ok = 1;\\n if (ok)\\n puts(\\\"YES\\\");\\n else\\n puts(\\\"NO\\\");\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"n people gathered to hold a jury meeting of the upcoming competition, the i-th member of the jury came up with a_i tasks, which they want to share with each other.\\n\\nFirst, the jury decides on the order which they will follow while describing the tasks. Let that be a permutation p of numbers from 1 to n (an array of size n where each integer from 1 to n occurs exactly once).\\n\\nThen the discussion goes as follows:\\n\\n * If a jury member p_1 has some tasks left to tell, then they tell one task to others. Otherwise, they are skipped. \\n * If a jury member p_2 has some tasks left to tell, then they tell one task to others. Otherwise, they are skipped. \\n * ... \\n * If a jury member p_n has some tasks left to tell, then they tell one task to others. Otherwise, they are skipped. \\n * If there are still members with tasks left, then the process repeats from the start. Otherwise, the discussion ends. \\n\\n\\n\\nA permutation p is nice if none of the jury members tell two or more of their own tasks in a row. \\n\\nCount the number of nice permutations. The answer may be really large, so print it modulo 998 244 353.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases.\\n\\nThe first line of the test case contains a single integer n (2 ≤ n ≤ 2 ⋅ 10^5) — number of jury members.\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — the number of problems that the i-th member of the jury came up with.\\n\\nThe sum of n over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print one integer — the number of nice permutations, taken modulo 998 244 353.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n2\\n1 2\\n3\\n5 5 5\\n4\\n1 3 3 7\\n6\\n3 4 2 1 3 3\\n\\n\\nOutput\\n\\n\\n1\\n6\\n0\\n540\\n\\nNote\\n\\nExplanation of the first test case from the example:\\n\\nThere are two possible permutations, p = [1, 2] and p = [2, 1]. For p = [1, 2], the process is the following:\\n\\n 1. the first jury member tells a task; \\n 2. the second jury member tells a task; \\n 3. the first jury member doesn't have any tasks left to tell, so they are skipped;...\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\npublic class Main {\\n public static void main(String args[])\\n {\\n FastReader input=new FastReader();\\n PrintWriter out=new PrintWriter(System.out);\\n int T=input.nextInt();\\n while(T-->0)\\n {\\n int n=input.nextInt();\\n int a[]=new int[n];\\n for(int i=0;i1)\\n {\\n out.println(0);\\n }\\n else if(dif==1)\\n {\\n int c=0;\\n for(int i=n-2;i>=0;i--)\\n {\\n if(a[n-1]-a[i]==1)\\n {\\n c++;\\n }\\n else\\n {\\n break;\\n }\\n }\\n long sum=0;\\n for(int i=c+1;i<=n;i++)\\n {\\n long p1=fac[c];\\n long p2=comb(fac,i-1,c,m);\\n long p3=fac[n-c-1];\\n long p=(p1*p2)%m;\\n p=(p*p3)%m;\\n sum=(sum+p)%m;\\n }\\n long ans=(fac[n]-sum)%m;\\n if(ans<0) ans+=m;\\n out.println(ans);\\n }\\n else\\n {\\n out.println(fac[n]);\\n }\\n }\\n out.close();\\n }\\n public static long comb(long fac[],int nu,int b,long m)\\n {\\n long x=fac[nu];\\n long y=(fac[b]%m*fac[nu-b]%m)%m;\\n long v=power(y,m-2,m);\\n long z=(x%m*v%m)%m;\\n return z;\\n }\\n public static long power(long a,long b,long m)\\n {\\n long res=1;\\n while(b>0)\\n {\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Shohag has an integer sequence a_1, a_2, …, a_n. He can perform the following operation any number of times (possibly, zero):\\n\\n * Select any positive integer k (it can be different in different operations). \\n * Choose any position in the sequence (possibly the beginning or end of the sequence, or in between any two elements) and insert k into the sequence at this position. \\n * This way, the sequence a changes, and the next operation is performed on this changed sequence. \\n\\n\\n\\nFor example, if a=[3,3,4] and he selects k = 2, then after the operation he can obtain one of the sequences [\\\\underline{2},3,3,4], [3,\\\\underline{2},3,4], [3,3,\\\\underline{2},4], or [3,3,4,\\\\underline{2}].\\n\\nShohag wants this sequence to satisfy the following condition: for each 1 ≤ i ≤ |a|, a_i ≤ i. Here, |a| denotes the size of a.\\n\\nHelp him to find the minimum number of operations that he has to perform to achieve this goal. We can show that under the constraints of the problem it's always possible to achieve this goal in a finite number of operations.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 200) — the number of test cases.\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 100) — the initial length of the sequence.\\n\\nThe second line of each test case contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^9) — the elements of the sequence.\\n\\nOutput\\n\\nFor each test case, print a single integer — the minimum number of operations needed to perform to achieve the goal mentioned in the statement.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n1 3 4\\n5\\n1 2 5 7 4\\n1\\n1\\n3\\n69 6969 696969\\n\\n\\nOutput\\n\\n\\n1\\n3\\n0\\n696966\\n\\nNote\\n\\nIn the first test case, we have to perform at least one operation, as a_2=3>2. We can perform the operation [1, 3, 4] → [1, \\\\underline{2}, 3, 4] (the newly inserted element is underlined), now the condition is satisfied.\\n\\nIn the second test case, Shohag can perform the following operations:\\n\\n[1, 2, 5, 7, 4] → [1, 2, \\\\underline{3}, 5, 7, 4] → [1, 2, 3, \\\\underline{4}, 5, 7, 4] → [1, 2, 3, 4, 5, \\\\underline{3}, 7, 4].\\n\\nIn the third...\\nt=int\",\"targets\":\"(input())\\n\\nwhile t>0:\\n n=int(input())\\n ar=list(map(int, input().split()))\\n \\n x=1\\n cnt=0\\n for i in range(n):\\n if ar[i]>x:\\n cnt+=(ar[i]-x)\\n x=ar[i]+1\\n else:\\n x+=1\\n print(cnt)\\n t-=1\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"n people gathered to hold a jury meeting of the upcoming competition, the i-th member of the jury came up with a_i tasks, which they want to share with each other.\\n\\nFirst, the jury decides on the order which they will follow while describing the tasks. Let that be a permutation p of numbers from 1 to n (an array of size n where each integer from 1 to n occurs exactly once).\\n\\nThen the discussion goes as follows:\\n\\n * If a jury member p_1 has some tasks left to tell, then they tell one task to others. Otherwise, they are skipped. \\n * If a jury member p_2 has some tasks left to tell, then they tell one task to others. Otherwise, they are skipped. \\n * ... \\n * If a jury member p_n has some tasks left to tell, then they tell one task to others. Otherwise, they are skipped. \\n * If there are still members with tasks left, then the process repeats from the start. Otherwise, the discussion ends. \\n\\n\\n\\nA permutation p is nice if none of the jury members tell two or more of their own tasks in a row. \\n\\nCount the number of nice permutations. The answer may be really large, so print it modulo 998 244 353.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases.\\n\\nThe first line of the test case contains a single integer n (2 ≤ n ≤ 2 ⋅ 10^5) — number of jury members.\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — the number of problems that the i-th member of the jury came up with.\\n\\nThe sum of n over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print one integer — the number of nice permutations, taken modulo 998 244 353.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n2\\n1 2\\n3\\n5 5 5\\n4\\n1 3 3 7\\n6\\n3 4 2 1 3 3\\n\\n\\nOutput\\n\\n\\n1\\n6\\n0\\n540\\n\\nNote\\n\\nExplanation of the first test case from the example:\\n\\nThere are two possible permutations, p = [1, 2] and p = [2, 1]. For p = [1, 2], the process is the following:\\n\\n 1. the first jury member tells a task; \\n 2. the second jury member tells a task; \\n 3. the first jury member doesn't have any tasks left to tell, so they are skipped;...\\nSolve the task in PYTHON3.\",\"targets\":\"from sys import stdin\\n# input=stdin.buffer.readline\\ninput=lambda : stdin.readline().strip()\\nlin=lambda :list(map(int,input().split()))\\niin=lambda :int(input())\\nmain=lambda :map(int,input().split())\\nfrom math import ceil,sqrt,factorial,log\\nfrom collections import deque\\nfrom bisect import bisect_left\\nmod=998244353\\n# mod=1000000007\\ndef moduloinverse(a):\\n\\treturn(pow(a,mod-2,mod))\\ndef solve(we):\\n\\tn=iin()\\n\\tl=lin()\\n\\tl.sort()\\n\\tif l[-1]-l[-2]>=2:\\n\\t\\tprint(0)\\n\\t\\treturn\\n\\tfac=[1]\\n\\tfor i in range(1,n+1):\\n\\t\\tfac.append((fac[-1]*i)%mod)\\n\\tif l[-1]==l[-2] or l[-1]==l[0]:\\n\\t\\tprint((fac[-1])%mod)\\n\\telse:\\n\\t\\tt=l.count(l[-2])\\n\\t\\tq=n-t-1\\n\\t\\tans=fac[n-1]\\n\\t\\tfor i in range(1,n-t):\\n\\t\\t\\tz=(fac[n-1-i]*fac[q])%mod\\n\\t\\t\\tz=(z*moduloinverse(fac[q-i]))%mod\\n\\t\\t\\tans=(ans+z)%mod\\n\\t\\tprint((fac[n]-ans)%mod)\\n\\n\\n\\n\\n\\nqwe=1\\nqwe=iin()\\nfor _ in range(qwe):\\n\\tsolve(_+1)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A binary string is a string that consists of characters 0 and 1.\\n\\nLet \\\\operatorname{MEX} of a binary string be the smallest digit among 0, 1, or 2 that does not occur in the string. For example, \\\\operatorname{MEX} of 001011 is 2, because 0 and 1 occur in the string at least once, \\\\operatorname{MEX} of 1111 is 0, because 0 and 2 do not occur in the string and 0 < 2.\\n\\nA binary string s is given. You should cut it into any number of substrings such that each character is in exactly one substring. It is possible to cut the string into a single substring — the whole string.\\n\\nA string a is a substring of a string b if a can be obtained from b by deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end.\\n\\nWhat is the minimal sum of \\\\operatorname{MEX} of all substrings pieces can be?\\n\\nInput\\n\\nThe input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. Description of the test cases follows.\\n\\nEach test case contains a single binary string s (1 ≤ |s| ≤ 10^5).\\n\\nIt's guaranteed that the sum of lengths of s over all test cases does not exceed 10^5.\\n\\nOutput\\n\\nFor each test case print a single integer — the minimal sum of \\\\operatorname{MEX} of all substrings that it is possible to get by cutting s optimally.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n01\\n1111\\n01100\\n101\\n0000\\n01010\\n\\n\\nOutput\\n\\n\\n1\\n0\\n2\\n1\\n1\\n2\\n\\nNote\\n\\nIn the first test case the minimal sum is \\\\operatorname{MEX}(0) + \\\\operatorname{MEX}(1) = 1 + 0 = 1.\\n\\nIn the second test case the minimal sum is \\\\operatorname{MEX}(1111) = 0.\\n\\nIn the third test case the minimal sum is \\\\operatorname{MEX}(01100) = 2.\",\"targets\":\"#include \\nusing namespace std;\\nvoid solve() {\\n string s;\\n cin >> s;\\n bool flag0 = false;\\n bool flag1 = false;\\n for (int i = 0; i < s.size(); i++) {\\n if (s[i] == '0') {\\n flag0 = true;\\n } else {\\n flag1 = true;\\n }\\n }\\n if (!flag0) {\\n cout << 0 << \\\"\\\\n\\\";\\n return;\\n }\\n if (!flag1) {\\n cout << 1 << \\\"\\\\n\\\";\\n return;\\n }\\n char prev = s[0];\\n int app0 = 0;\\n int app1 = 0;\\n if (prev == '0') {\\n app0++;\\n } else {\\n app1++;\\n }\\n for (int i = 1; i < s.size(); i++) {\\n if (s[i] == '0') {\\n if (prev == '1') {\\n app0++;\\n prev = '0';\\n }\\n } else {\\n if (prev == '0') {\\n app1++;\\n prev = '1';\\n }\\n }\\n }\\n if (app0 > 1) {\\n cout << 2 << \\\"\\\\n\\\";\\n } else {\\n cout << 1 << \\\"\\\\n\\\";\\n }\\n}\\nint main() {\\n ios::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n long long t;\\n cin >> t;\\n for (int i = 1; i <= t; i++) {\\n solve();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Three little pigs from all over the world are meeting for a convention! Every minute, a triple of 3 new pigs arrives on the convention floor. After the n-th minute, the convention ends.\\n\\nThe big bad wolf has learned about this convention, and he has an attack plan. At some minute in the convention, he will arrive and eat exactly x pigs. Then he will get away.\\n\\nThe wolf wants Gregor to help him figure out the number of possible attack plans that involve eating exactly x pigs for various values of x (1 ≤ x ≤ 3n). Two attack plans are considered different, if they occur at different times or if the sets of little pigs to eat are different.\\n\\nNote that all queries are independent, that is, the wolf does not eat the little pigs, he only makes plans!\\n\\nInput\\n\\nThe first line of input contains two integers n and q (1 ≤ n ≤ 10^6, 1 ≤ q ≤ 2⋅ 10^5), the number of minutes the convention lasts and the number of queries the wolf asks.\\n\\nEach of the next q lines contains a single integer x_i (1 ≤ x_i ≤ 3n), the number of pigs the wolf will eat in the i-th query.\\n\\nOutput\\n\\nYou should print q lines, with line i representing the number of attack plans if the wolf wants to eat x_i pigs. Since each query answer can be large, output each answer modulo 10^9+7.\\n\\nExamples\\n\\nInput\\n\\n\\n2 3\\n1\\n5\\n6\\n\\n\\nOutput\\n\\n\\n9\\n6\\n1\\n\\n\\nInput\\n\\n\\n5 4\\n2\\n4\\n6\\n8\\n\\n\\nOutput\\n\\n\\n225\\n2001\\n6014\\n6939\\n\\nNote\\n\\nIn the example test, n=2. Thus, there are 3 pigs at minute 1, and 6 pigs at minute 2. There are three queries: x=1, x=5, and x=6.\\n\\nIf the wolf wants to eat 1 pig, he can do so in 3+6=9 possible attack plans, depending on whether he arrives at minute 1 or 2.\\n\\nIf the wolf wants to eat 5 pigs, the wolf cannot arrive at minute 1, since there aren't enough pigs at that time. Therefore, the wolf has to arrive at minute 2, and there are 6 possible attack plans.\\n\\nIf the wolf wants to eat 6 pigs, his only plan is to arrive at the end of the convention and devour everybody.\\n\\nRemember to output your answers modulo 10^9+7!\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nconst int max_n = 1e6 + 10;\\nlong long dp[max_n * 3][3];\\nconst long long mod = 1e9 + 7;\\nint inv[max_n * 3];\\nvoid inverse(int n, long long mod) {\\n inv[1] = 1;\\n for (int i = 2; i <= n; ++i) {\\n inv[i] = (long long)(mod - mod \\/ i) * inv[mod % i] % mod;\\n }\\n}\\nlong long c[max_n * 3];\\nint main() {\\n int n, q;\\n cin >> n >> q;\\n dp[0][0] = dp[0][1] = dp[0][2] = n;\\n inverse(3 * n, mod);\\n long long sum = 3 * n;\\n c[1] = sum;\\n c[0] = 1;\\n for (int i = 1; i <= 3 * n - 1; ++i) {\\n sum = sum * (3 * n * 1ll - i) % mod * inv[i + 1] % mod;\\n c[i + 1] = sum;\\n dp[i][0] =\\n (sum - dp[i - 1][1] - dp[i - 1][0] * 2 + 3 * mod) % mod * inv[3] % mod;\\n dp[i][1] = (dp[i][0] + dp[i - 1][0]) % mod;\\n }\\n while (q--) {\\n int x;\\n scanf(\\\"%d\\\", &x);\\n if (x >= 3 * n) {\\n cout << 1 << '\\\\n';\\n continue;\\n }\\n printf(\\\"%lld\\\\n\\\", (dp[x][0] + c[x]) % mod);\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nTanya is learning how to add numbers, but so far she is not doing it correctly. She is adding two numbers a and b using the following algorithm:\\n\\n 1. If one of the numbers is shorter than the other, Tanya adds leading zeros so that the numbers are the same length. \\n 2. The numbers are processed from right to left (that is, from the least significant digits to the most significant). \\n 3. In the first step, she adds the last digit of a to the last digit of b and writes their sum in the answer. \\n 4. At each next step, she performs the same operation on each pair of digits in the same place and writes the result to the left side of the answer. \\n\\n\\n\\nFor example, the numbers a = 17236 and b = 3465 Tanya adds up as follows:\\n\\n$$$ \\\\large{ \\\\begin{array}{r} + \\\\begin{array}{r} 17236\\\\\\\\\\\\ 03465\\\\\\\\\\\\ \\\\end{array} \\\\\\\\\\\\ \\\\hline \\\\begin{array}{r} 1106911 \\\\end{array} \\\\end{array}} $$$\\n\\n * calculates the sum of 6 + 5 = 11 and writes 11 in the answer. \\n * calculates the sum of 3 + 6 = 9 and writes the result to the left side of the answer to get 911. \\n * calculates the sum of 2 + 4 = 6 and writes the result to the left side of the answer to get 6911. \\n * calculates the sum of 7 + 3 = 10, and writes the result to the left side of the answer to get 106911. \\n * calculates the sum of 1 + 0 = 1 and writes the result to the left side of the answer and get 1106911. \\n\\n\\n\\nAs a result, she gets 1106911.\\n\\nYou are given two positive integers a and s. Find the number b such that by adding a and b as described above, Tanya will get s. Or determine that no suitable b exists.\\n\\nInput\\n\\nThe first line of input data contains an integer t (1 ≤ t ≤ 10^4) — the number of test cases.\\n\\nEach test case consists of a single line containing two positive integers a and s (1 ≤ a < s ≤ 10^{18}) separated by a space.\\n\\nOutput\\n\\nFor each test case print the answer on a separate line.\\n\\nIf the solution exists, print a single positive integer b. The answer must be written without leading zeros. If multiple answers exist, print any of them.\\n\\nIf no suitable number b...\",\"targets\":\"#include \\nusing namespace std;\\nlong long a, s, mahdi, t;\\nvector v;\\nint main() {\\n cin >> t;\\n t++;\\n while (--t) {\\n cin >> a >> s;\\n vector v;\\n while (s > 0) {\\n long long x = a % 10;\\n long long y = s % 10;\\n mahdi = 0;\\n if (x <= y) {\\n v.push_back(y - x);\\n } else {\\n s \\/= 10;\\n y += 10 * (s % 10);\\n if (x < y && y >= 10 && y <= 19) {\\n v.push_back(y - x);\\n } else {\\n mahdi = 1;\\n break;\\n }\\n }\\n a \\/= 10;\\n s \\/= 10;\\n }\\n if (a > 0 || mahdi == 1) {\\n cout << -1 << endl;\\n } else {\\n while (v.back() == 0) {\\n v.pop_back();\\n }\\n for (int i = v.size() - 1; i >= 0; i--) {\\n cout << v[i];\\n }\\n cout << endl;\\n v.clear();\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You have an axis-aligned rectangle room with width W and height H, so the lower left corner is in point (0, 0) and the upper right corner is in (W, H).\\n\\nThere is a rectangular table standing in this room. The sides of the table are parallel to the walls, the lower left corner is in (x_1, y_1), and the upper right corner in (x_2, y_2).\\n\\nYou want to place another rectangular table in this room with width w and height h with the width of the table parallel to the width of the room.\\n\\nThe problem is that sometimes there is not enough space to place the second table without intersecting with the first one (there are no problems with tables touching, though).\\n\\nYou can't rotate any of the tables, but you can move the first table inside the room. \\n\\n Example of how you may move the first table.\\n\\nWhat is the minimum distance you should move the first table to free enough space for the second one?\\n\\nInput\\n\\nThe first line contains the single integer t (1 ≤ t ≤ 5000) — the number of the test cases.\\n\\nThe first line of each test case contains two integers W and H (1 ≤ W, H ≤ 10^8) — the width and the height of the room.\\n\\nThe second line contains four integers x_1, y_1, x_2 and y_2 (0 ≤ x_1 < x_2 ≤ W; 0 ≤ y_1 < y_2 ≤ H) — the coordinates of the corners of the first table.\\n\\nThe third line contains two integers w and h (1 ≤ w ≤ W; 1 ≤ h ≤ H) — the width and the height of the second table.\\n\\nOutput\\n\\nFor each test case, print the minimum distance you should move the first table, or -1 if there is no way to free enough space for the second table.\\n\\nYour answer will be considered correct if its absolute or relative error doesn't exceed 10^{-6}.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n8 5\\n2 1 7 4\\n4 2\\n5 4\\n2 2 5 4\\n3 3\\n1 8\\n0 3 1 6\\n1 5\\n8 1\\n3 0 6 1\\n5 1\\n8 10\\n4 5 7 8\\n8 5\\n\\n\\nOutput\\n\\n\\n1.000000000\\n-1\\n2.000000000\\n2.000000000\\n0.000000000\\n\\nNote\\n\\nThe configuration of the first test case is shown in the picture. But the movement of the first table is not optimal. One of the optimal movement, for example, is to move the table by (0, -1), so the lower left corner...\\n# by\",\"targets\":\"the authority of GOD author: manhar singh sachdev #\\n\\nimport os,sys\\nfrom io import BytesIO, IOBase\\n\\ndef main():\\n inf = float(\\\"inf\\\")\\n for _ in range(int(input())):\\n W,H = map(int,input().split())\\n x1,y1,x2,y2 = map(int,input().split())\\n w,h = map(int,input().split())\\n dx,dy = inf,inf\\n if x2-x1+w <= W:\\n dx = max(0,min(w-W+x2,w-x1))\\n if y2-y1+h <= H:\\n dy = max(0,min(h-H+y2,h-y1))\\n if dx == inf and dy == inf:\\n print(-1)\\n continue\\n print(min(dx,dy))\\n\\n# Fast IO Region\\nBUFSIZE = 8192\\nclass FastIO(IOBase):\\n newlines = 0\\n def __init__(self, file):\\n self._fd = file.fileno()\\n self.buffer = BytesIO()\\n self.writable = \\\"x\\\" in file.mode or \\\"r\\\" not in file.mode\\n self.write = self.buffer.write if self.writable else None\\n def read(self):\\n while True:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n if not b:\\n break\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines = 0\\n return self.buffer.read()\\n def readline(self):\\n while self.newlines == 0:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n self.newlines = b.count(b\\\"\\\\n\\\") + (not b)\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines -= 1\\n return self.buffer.readline()\\n def flush(self):\\n if self.writable:\\n os.write(self._fd, self.buffer.getvalue())\\n self.buffer.truncate(0), self.buffer.seek(0)\\nclass IOWrapper(IOBase):\\n def __init__(self, file):\\n self.buffer = FastIO(file)\\n self.flush = self.buffer.flush\\n self.writable = self.buffer.writable\\n self.write = lambda s: self.buffer.write(s.encode(\\\"ascii\\\"))\\n self.read = lambda: self.buffer.read().decode(\\\"ascii\\\")\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Moamen was drawing a grid of n rows and 10^9 columns containing only digits 0 and 1. Ezzat noticed what Moamen was drawing and became interested in the minimum number of rows one needs to remove to make the grid beautiful.\\n\\nA grid is beautiful if and only if for every two consecutive rows there is at least one column containing 1 in these two rows.\\n\\nEzzat will give you the number of rows n, and m segments of the grid that contain digits 1. Every segment is represented with three integers i, l, and r, where i represents the row number, and l and r represent the first and the last column of the segment in that row.\\n\\nFor example, if n = 3, m = 6, and the segments are (1,1,1), (1,7,8), (2,7,7), (2,15,15), (3,1,1), (3,15,15), then the grid is:\\n\\n\\n\\nYour task is to tell Ezzat the minimum number of rows that should be removed to make the grid beautiful.\\n\\nInput\\n\\nThe first line contains two integers n and m (1 ≤ n, m ≤ 3⋅10^5).\\n\\nEach of the next m lines contains three integers i, l, and r (1 ≤ i ≤ n, 1 ≤ l ≤ r ≤ 10^9). Each of these m lines means that row number i contains digits 1 in columns from l to r, inclusive.\\n\\nNote that the segments may overlap.\\n\\nOutput\\n\\nIn the first line, print a single integer k — the minimum number of rows that should be removed.\\n\\nIn the second line print k distinct integers r_1, r_2, …, r_k, representing the rows that should be removed (1 ≤ r_i ≤ n), in any order.\\n\\nIf there are multiple answers, print any.\\n\\nExamples\\n\\nInput\\n\\n\\n3 6\\n1 1 1\\n1 7 8\\n2 7 7\\n2 15 15\\n3 1 1\\n3 15 15\\n\\n\\nOutput\\n\\n\\n0\\n\\n\\nInput\\n\\n\\n5 4\\n1 2 3\\n2 4 6\\n3 3 5\\n5 1 1\\n\\n\\nOutput\\n\\n\\n3\\n2 4 5\\n\\nNote\\n\\nIn the first test case, the grid is the one explained in the problem statement. The grid has the following properties: \\n\\n 1. The 1-st row and the 2-nd row have a common 1 in the column 7. \\n 2. The 2-nd row and the 3-rd row have a common 1 in the column 15. \\n\\nAs a result, this grid is beautiful and we do not need to remove any row.\\n\\nIn the second test case, the given grid is as follows: \\n\\n\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 6e5;\\nconst int M = N + 7;\\nconst double EPS = 1e-10;\\nconst int MOD = 1e9 + 7;\\nconst long long INF = 1e18 + 17;\\nint n, m, dp[M];\\nvector > g[M];\\nint t[4 * M], add[4 * M];\\nvoid push(int v, int tl, int tr) {\\n int tm = (tl + tr) >> 1;\\n if (add[v] != -1) {\\n t[v + v] = add[v];\\n add[v + v] = add[v];\\n t[v + v + 1] = add[v];\\n add[v + v + 1] = add[v];\\n add[v] = -1;\\n }\\n}\\nvoid upd(int v, int tl, int tr, int l, int r, int x) {\\n if (l > r) return;\\n if (tl == l && tr == r) {\\n t[v] = x;\\n add[v] = x;\\n return;\\n }\\n push(v, tl, tr);\\n int tm = (tl + tr) >> 1;\\n upd(v + v, tl, tm, l, min(r, tm), x);\\n upd(v + v + 1, tm + 1, tr, max(l, tm + 1), r, x);\\n t[v] = max(t[v + v], t[v + v + 1]);\\n}\\nint get(int v, int tl, int tr, int l, int r) {\\n if (l > r) return 0;\\n if (tl == l && tr == r) return t[v];\\n push(v, tl, tr);\\n int tm = (tl + tr) >> 1;\\n return max(get(v + v, tl, tm, l, min(tm, r)),\\n get(v + v + 1, tm + 1, tr, max(tm + 1, l), r));\\n}\\nvoid solve() {\\n cin >> n >> m;\\n map com;\\n for (int i = 0; i < m; i++) {\\n int id, l, r;\\n cin >> id >> l >> r;\\n com[l]++, com[r]++;\\n g[id].push_back({l, r});\\n }\\n int val = 1;\\n for (auto &it : com) it.second = val++;\\n for (int i = 1; i <= n; i++)\\n for (auto &it : g[i]) it.first = com[it.first], it.second = com[it.second];\\n int nn = val - 1;\\n dp[1] = 1;\\n for (auto iv : g[1]) upd(1, 1, nn, iv.first, iv.second, 1);\\n for (int i = 2; i <= n; i++) {\\n dp[i] = 1;\\n for (auto iv : g[i])\\n dp[i] = max(dp[i], get(1, 1, nn, iv.first, iv.second) + 1);\\n for (auto iv : g[i]) upd(1, 1, nn, iv.first, iv.second, dp[i]);\\n }\\n int ans = *max_element(dp + 1, dp + n + 1), last = -1;\\n cout << n - ans << '\\\\n';\\n for (int i = n; i >= 1; i--) {\\n bool ok = 0;\\n if (last == -1)\\n ok = 1;\\n else {\\n for (auto iv : g[i])\\n for (auto lastv : g[last])\\n if (max(iv.first, lastv.first) <= min(iv.second, lastv.second))\\n ok = 1;\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"The grasshopper is located on the numeric axis at the point with coordinate x_0.\\n\\nHaving nothing else to do he starts jumping between integer points on the axis. Making a jump from a point with coordinate x with a distance d to the left moves the grasshopper to a point with a coordinate x - d, while jumping to the right moves him to a point with a coordinate x + d.\\n\\nThe grasshopper is very fond of positive integers, so for each integer i starting with 1 the following holds: exactly i minutes after the start he makes a jump with a distance of exactly i. So, in the first minutes he jumps by 1, then by 2, and so on.\\n\\nThe direction of a jump is determined as follows: if the point where the grasshopper was before the jump has an even coordinate, the grasshopper jumps to the left, otherwise he jumps to the right.\\n\\nFor example, if after 18 consecutive jumps he arrives at the point with a coordinate 7, he will jump by a distance of 19 to the right, since 7 is an odd number, and will end up at a point 7 + 19 = 26. Since 26 is an even number, the next jump the grasshopper will make to the left by a distance of 20, and it will move him to the point 26 - 20 = 6.\\n\\nFind exactly which point the grasshopper will be at after exactly n jumps.\\n\\nInput\\n\\nThe first line of input contains an integer t (1 ≤ t ≤ 10^4) — the number of test cases.\\n\\nEach of the following t lines contains two integers x_0 (-10^{14} ≤ x_0 ≤ 10^{14}) and n (0 ≤ n ≤ 10^{14}) — the coordinate of the grasshopper's initial position and the number of jumps.\\n\\nOutput\\n\\nPrint exactly t lines. On the i-th line print one integer — the answer to the i-th test case — the coordinate of the point the grasshopper will be at after making n jumps from the point x_0.\\n\\nExample\\n\\nInput\\n\\n\\n9\\n0 1\\n0 2\\n10 10\\n10 99\\n177 13\\n10000000000 987654321\\n-433494437 87178291199\\n1 0\\n-1 1\\n\\n\\nOutput\\n\\n\\n-1\\n1\\n11\\n110\\n190\\n9012345679\\n-87611785637\\n1\\n0\\n\\nNote\\n\\nThe first two test cases in the example correspond to the first two jumps from the point x_0 = 0. \\n\\nSince 0 is an even number, the first jump of length...\\nSolve the task in JAVA.\",\"targets\":\"\\/\\/package currentContest;\\n\\nimport java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.util.ArrayDeque;\\nimport java.util.ArrayList;\\nimport java.util.Arrays;\\nimport java.util.Collections;\\nimport java.util.Comparator;\\nimport java.util.HashSet;\\nimport java.util.Random;\\nimport java.util.StringTokenizer;\\nimport java.util.TreeSet;\\n\\npublic class P2 {\\n\\tstatic long power(long pow, long pow2, long mod) {\\n\\t\\tlong res = 1; \\/\\/ Initialize result\\n\\n\\t\\tpow = pow % mod; \\/\\/ Update x if it is more than or\\n\\t\\t\\/\\/ equal to p\\n\\n\\t\\tif (pow == 0)\\n\\t\\t\\treturn 0; \\/\\/ In case x is divisible by p;\\n\\n\\t\\twhile (pow2 > 0) {\\n\\n\\t\\t\\t\\/\\/ If y is odd, multiply x with result\\n\\t\\t\\tif ((pow2 & 1) != 0)\\n\\t\\t\\t\\tres = (res * pow) % mod;\\n\\n\\t\\t\\t\\/\\/ y must be even now\\n\\t\\t\\tpow2 = pow2 >> 1; \\/\\/ y = y\\/2\\n\\t\\t\\tpow = (pow * pow) % mod;\\n\\t\\t}\\n\\t\\treturn res;\\n\\t}\\n\\n\\tpublic static void main(String[] args) {\\n\\t\\t\\/\\/ TODO Auto-generated method stub\\n\\t\\tStringBuilder st = new StringBuilder();\\n\\t\\tFastReader sc = new FastReader();\\n\\t\\tint t=sc.nextInt();\\n\\t\\twhile(t--!=0) {\\n\\t\\t\\tlong x=sc.nextLong();\\n\\t\\t\\tlong n=sc.nextLong();\\n\\t\\t\\tint keep=(int) (n%4);\\n\\t\\t\\tlong ans=0;\\n\\t\\t\\tif(keep==1) {\\n\\t\\t\\t\\tans=0-n;\\n\\t\\t\\t}else if(keep==2) {\\n\\t\\t\\t\\tans=1;\\n\\t\\t\\t}else if(keep==3) {\\n\\t\\t\\t\\tans=n+1;\\n\\t\\t\\t}else {\\n\\t\\t\\t\\tans=0;\\n\\t\\t\\t}\\n\\t\\t\\tif(x%2==0) {\\n\\t\\t\\t\\tans=ans+x;\\n\\t\\t\\t}else {\\n\\t\\t\\t\\tans=x-ans;\\n\\t\\t\\t}\\n\\t\\t\\tst.append(ans+\\\"\\\\n\\\");\\n\\t\\t}\\n\\t\\tSystem.out.println(st);\\n\\t}\\n\\n\\tstatic FastReader sc = new FastReader();\\n\\n\\tpublic static void solvegraph() {\\n\\t\\tint n = sc.nextInt();\\n\\n\\t\\tint edge[][] = new int[n - 1][2];\\n\\t\\tfor (int i = 0; i < n - 1; i++) {\\n\\t\\t\\tedge[i][0] = sc.nextInt() - 1;\\n\\t\\t\\tedge[i][1] = sc.nextInt() - 1;\\n\\t\\t}\\n\\t\\tArrayList> ad = new ArrayList<>();\\n\\t\\tfor (int i = 0; i < n; i++) {\\n\\t\\t\\tad.add(new ArrayList());\\n\\t\\t}\\n\\t\\tfor (int i = 0; i < n - 1; i++) {\\n\\t\\t\\tad.get(edge[i][0]).add(edge[i][1]);\\n\\t\\t\\tad.get(edge[i][1]).add(edge[i][0]);\\n\\t\\t}\\n\\t\\tint parent[] = new int[n];\\n\\t\\tArrays.fill(parent, -1);\\n\\t\\tparent[0] = n;\\n\\t\\tArrayDeque queue = new ArrayDeque<>();\\n\\t\\tqueue.add(0);\\n\\t\\tint child[] = new...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Amr is a young coder who likes music a lot. He always wanted to learn how to play music but he was busy coding so he got an idea.\\n\\nAmr has n instruments, it takes ai days to learn i-th instrument. Being busy, Amr dedicated k days to learn how to play the maximum possible number of instruments.\\n\\nAmr asked for your help to distribute his free days between instruments so that he can achieve his goal.\\n\\nInput\\n\\nThe first line contains two numbers n, k (1 ≤ n ≤ 100, 0 ≤ k ≤ 10 000), the number of instruments and number of days respectively.\\n\\nThe second line contains n integers ai (1 ≤ ai ≤ 100), representing number of days required to learn the i-th instrument.\\n\\nOutput\\n\\nIn the first line output one integer m representing the maximum number of instruments Amr can learn.\\n\\nIn the second line output m space-separated integers: the indices of instruments to be learnt. You may output indices in any order.\\n\\nif there are multiple optimal solutions output any. It is not necessary to use all days for studying.\\n\\nExamples\\n\\nInput\\n\\n4 10\\n4 3 1 2\\n\\n\\nOutput\\n\\n4\\n1 2 3 4\\n\\nInput\\n\\n5 6\\n4 3 1 1 2\\n\\n\\nOutput\\n\\n3\\n1 3 4\\n\\nInput\\n\\n1 3\\n4\\n\\n\\nOutput\\n\\n0\\n\\nNote\\n\\nIn the first test Amr can learn all 4 instruments.\\n\\nIn the second test other possible solutions are: {2, 3, 5} or {3, 4, 5}.\\n\\nIn the third test Amr doesn't have enough time to learn the only presented instrument.\",\"targets\":\"import java.util.ArrayList;\\nimport java.util.Collections;\\nimport java.util.Comparator;\\nimport java.util.List;\\nimport java.util.Scanner;\\n\\npublic class ProblemA {\\n\\n public static void main(String[] args) {\\n Scanner sc = new Scanner(System.in);\\n int n = sc.nextInt();\\n int k = sc.nextInt();\\n final int[] a = new int[n];\\n List idx = new ArrayList();\\n for (int i = 0; i < n; i++) {\\n a[i] = sc.nextInt();\\n idx.add(i);\\n }\\n Collections.sort(idx, new Comparator() {\\n @Override\\n public int compare(Integer o1, Integer o2) {\\n return Integer.compare(a[o1], a[o2]);\\n }\\n });\\n int sum = 0;\\n int i = 0;\\n int cnt = 0;\\n while (i < a.length && sum + a[idx.get(i)] <= k) {\\n\\n sum += a[idx.get(i)];\\n i++;\\n cnt++;\\n }\\n System.out.println(cnt);\\n for (i = 0; i < cnt; i++) {\\n System.out.print((idx.get(i) + 1) + \\\" \\\");\\n }\\n System.out.println();\\n sc.close();\\n }\\n\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"\\\"Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score...\\\" — an excerpt from contest rules.\\n\\nA total of n participants took part in the contest (n ≥ k), and you already know their scores. Calculate how many participants will advance to the next round.\\n\\nInput\\n\\nThe first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 50) separated by a single space.\\n\\nThe second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 100), where ai is the score earned by the participant who got the i-th place. The given sequence is non-increasing (that is, for all i from 1 to n - 1 the following condition is fulfilled: ai ≥ ai + 1).\\n\\nOutput\\n\\nOutput the number of participants who advance to the next round.\\n\\nExamples\\n\\nInput\\n\\n8 5\\n10 9 8 7 7 7 5 5\\n\\n\\nOutput\\n\\n6\\n\\n\\nInput\\n\\n4 2\\n0 0 0 0\\n\\n\\nOutput\\n\\n0\\n\\nNote\\n\\nIn the first example the participant on the 5th place earned 7 points. As the participant on the 6th place also earned 7 points, there are 6 advancers.\\n\\nIn the second example nobody got a positive score.\\nUsing python3 can you solve the prior task?\",\"targets\":\"n, k = map(int, input().split())\\nnSpace = list(map(int, input().split()))\\nlistAccept = []\\n\\nknum = nSpace[k - 1]\\nfor i in range(n):\\n numth = nSpace[i]\\n\\n if i <= (k - 1) and (numth > 0):\\n listAccept.append(numth)\\n elif (i > (k - 1)) and (numth == knum) and (numth > 0):\\n listAccept.append(numth)\\n\\nprint(len(listAccept))\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Everything red frightens Nian the monster. So do red paper and... you, red on Codeforces, potential or real.\\n\\nBig Banban has got a piece of paper with endless lattice points, where lattice points form squares with the same area. His most favorite closed shape is the circle because of its beauty and simplicity. Once he had obtained this piece of paper, he prepares it for paper-cutting.\\n\\n\\n\\nHe drew n concentric circles on it and numbered these circles from 1 to n such that the center of each circle is the same lattice point and the radius of the k-th circle is times the length of a lattice edge.\\n\\nDefine the degree of beauty of a lattice point as the summation of the indices of circles such that this lattice point is inside them, or on their bounds. Banban wanted to ask you the total degree of beauty of all the lattice points, but changed his mind.\\n\\nDefining the total degree of beauty of all the lattice points on a piece of paper with n circles as f(n), you are asked to figure out .\\n\\nInput\\n\\nThe first line contains one integer m (1 ≤ m ≤ 1012).\\n\\nOutput\\n\\nIn the first line print one integer representing .\\n\\nExamples\\n\\nInput\\n\\n5\\n\\n\\nOutput\\n\\n387\\n\\n\\nInput\\n\\n233\\n\\n\\nOutput\\n\\n788243189\\n\\nNote\\n\\nA piece of paper with 5 circles is shown in the following.\\n\\n\\n\\nThere are 5 types of lattice points where the degree of beauty of each red point is 1 + 2 + 3 + 4 + 5 = 15, the degree of beauty of each orange point is 2 + 3 + 4 + 5 = 14, the degree of beauty of each green point is 4 + 5 = 9, the degree of beauty of each blue point is 5 and the degree of beauty of each gray point is 0. Therefore, f(5) = 5·15 + 4·14 + 4·9 + 8·5 = 207.\\n\\nSimilarly, f(1) = 5, f(2) = 23, f(3) = 50, f(4) = 102 and consequently .\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst int mod = 1e9 + 7, N = 1e6 + 100, inv2 = (mod + 1) >> 1,\\n inv6 = (mod + 1) \\/ 6;\\nlong long n, nn, Ans, s1[N], s2[N], s3[N];\\nvoid Inc(long long &x, long long y) { x += y, x = x >= mod ? x - mod : x; }\\nint main() {\\n scanf(\\\"%lld\\\", &n);\\n nn = n % mod;\\n for (long long x = 1, tp = 1; x * x <= n; ++x, tp = x * x % mod) {\\n s1[x] = s1[x - 1], s2[x] = s2[x - 1], s3[x] = s3[x - 1], Inc(s1[x], tp),\\n Inc(s2[x], tp * tp % mod), Inc(s3[x], tp * tp % mod * tp % mod);\\n }\\n for (long long x = 0; x * x <= n; ++x) {\\n long long y = sqrt(n - x * x), tp = x * x % mod;\\n long long tmp = 0;\\n Inc(tmp, (nn + 1) * inv2 % mod * (nn * nn % mod + nn + tp - tp * tp % mod) %\\n mod * (2 * y + 1) % mod);\\n Inc(tmp, mod - (nn + 1) * inv2 % mod * (2 * tp + mod - 1) % mod * s1[y] %\\n mod * 2 % mod);\\n Inc(tmp, mod - (nn + 1) % mod * inv2 % mod * s2[y] % mod * 2 % mod);\\n Inc(tmp, inv6 * (6 * tp % mod * tp % mod - 6 * tp % mod + mod + 1) % mod *\\n s1[y] % mod * 2 % mod);\\n Inc(tmp, inv6 * (6 * tp % mod + mod - 3) % mod * s2[y] % mod * 2 % mod);\\n Inc(tmp, inv6 * (4 * s3[y]) % mod);\\n Inc(tmp, inv6 *\\n (2 * tp % mod * tp % mod * tp % mod - 3 * tp * tp % mod + mod +\\n tp) %\\n mod * (2 * y + 1) % mod);\\n Inc(tmp, mod - (2 * nn + 1) * inv6 % mod * nn % mod * (nn + 1) % mod *\\n (2 * y + 1) % mod);\\n if (x) Inc(tmp, tmp);\\n Inc(Ans, tmp);\\n }\\n printf(\\\"%lld\\\", Ans);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Let's define S(x) to be the sum of digits of number x written in decimal system. For example, S(5) = 5, S(10) = 1, S(322) = 7.\\n\\nWe will call an integer x interesting if S(x + 1) < S(x). In each test you will be given one integer n. Your task is to calculate the number of integers x such that 1 ≤ x ≤ n and x is interesting.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 1000) — number of test cases.\\n\\nThen t lines follow, the i-th line contains one integer n (1 ≤ n ≤ 10^9) for the i-th test case.\\n\\nOutput\\n\\nPrint t integers, the i-th should be the answer for the i-th test case.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n1\\n9\\n10\\n34\\n880055535\\n\\n\\nOutput\\n\\n\\n0\\n1\\n1\\n3\\n88005553\\n\\nNote\\n\\nThe first interesting number is equal to 9.\\nSolve the task in CPP.\",\"targets\":\"#include \\n#pragma GCC optimize(\\\"Ofast,no-stack-protector\\\")\\n#pragma GCC target(\\\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native\\\")\\n#pragma GCC optimize(\\\"unroll-loops\\\")\\nusing namespace std;\\nconst int MAX = 1000000000;\\nconst int inf = 1e9;\\nconst long double PI = 3.141592653589793238460;\\nint max(int a, int b) {\\n if (a > b) return a;\\n return b;\\n}\\nvoid solve() {\\n int n;\\n cin >> n;\\n if (n < 9) {\\n cout << 0 << '\\\\n';\\n return;\\n }\\n if (n == 9)\\n cout << 1 << '\\\\n';\\n else {\\n if (n % 10 == 9)\\n cout << 1 + n \\/ 10 << '\\\\n';\\n else\\n cout << n \\/ 10 << '\\\\n';\\n }\\n}\\nint32_t main() {\\n ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);\\n int T = 1;\\n cin >> T;\\n while (T--) {\\n solve();\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Even if you just leave them be, they will fall to pieces all by themselves. So, someone has to protect them, right?\\n\\nYou find yourself playing with Teucer again in the city of Liyue. As you take the eccentric little kid around, you notice something interesting about the structure of the city.\\n\\nLiyue can be represented as a directed graph containing n nodes. Nodes are labeled from 1 to n. There is a directed edge from node a to node b if and only if a < b.\\n\\nA path between nodes a and b is defined as a sequence of edges such that you can start at a, travel along all of these edges in the corresponding direction, and end at b. The length of a path is defined by the number of edges. A rainbow path of length x is defined as a path in the graph such that there exists at least 2 distinct colors among the set of x edges.\\n\\nTeucer's favorite number is k. You are curious about the following scenario: If you were to label each edge with a color, what is the minimum number of colors needed to ensure that all paths of length k or longer are rainbow paths?\\n\\nTeucer wants to surprise his older brother with a map of Liyue. He also wants to know a valid coloring of edges that uses the minimum number of colors. Please help him with this task!\\n\\nInput\\n\\nThe only line of input contains two integers n and k (2 ≤ k < n ≤ 1000). \\n\\nOutput\\n\\nOn the first line, output c, the minimum colors you need to satisfy the above requirements.\\n\\nOn the second line, print a valid edge coloring as an array of (n(n-1))\\/(2) integers ranging from 1 to c. Exactly c distinct colors should exist in the construction. Print the edges in increasing order by the start node first, then by the second node.\\n\\nFor example, if n=4, the edge colors will correspond to this order of edges: (1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)\\n\\nExamples\\n\\nInput\\n\\n\\n5 3\\n\\n\\nOutput\\n\\n\\n2\\n1 2 2 2 2 2 2 1 1 1\\n\\n\\nInput\\n\\n\\n5 2\\n\\n\\nOutput\\n\\n\\n3\\n3 2 2 1 2 2 1 3 1 1 \\n\\n\\nInput\\n\\n\\n8 7\\n\\n\\nOutput\\n\\n\\n2\\n2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\n\\n\\nInput\\n\\n\\n3 2\\n\\n\\nOutput\\n\\n\\n2\\n1 2 2 \\n\\nNote\\n\\nThe...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 1e3 + 10;\\nint a[N][N], n, k;\\nint main() {\\n ios::sync_with_stdio(false);\\n cin.tie(nullptr);\\n cin >> n >> k;\\n int ans = 0, v = 1;\\n while (v < n) {\\n ++ans;\\n for (int i = 0; i < n; i++)\\n for (int j = i + 1; j < n; j++)\\n if (i \\/ v % k != j \\/ v % k) a[i][j] = ans;\\n v *= k;\\n }\\n cout << ans << \\\"\\\\n\\\";\\n for (int i = 0; i < n; i++)\\n for (int j = i + 1; j < n; j++)\\n cout << a[i][j] << \\\" \\\\n\\\"[i == n - 2 && j == n - 1];\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"This problem is an extension of the problem \\\"Wonderful Coloring - 1\\\". It has quite many differences, so you should read this statement completely.\\n\\nRecently, Paul and Mary have found a new favorite sequence of integers a_1, a_2, ..., a_n. They want to paint it using pieces of chalk of k colors. The coloring of a sequence is called wonderful if the following conditions are met:\\n\\n 1. each element of the sequence is either painted in one of k colors or isn't painted; \\n 2. each two elements which are painted in the same color are different (i. e. there's no two equal values painted in the same color); \\n 3. let's calculate for each of k colors the number of elements painted in the color — all calculated numbers must be equal; \\n 4. the total number of painted elements of the sequence is the maximum among all colorings of the sequence which meet the first three conditions. \\n\\n\\n\\nE. g. consider a sequence a=[3, 1, 1, 1, 1, 10, 3, 10, 10, 2] and k=3. One of the wonderful colorings of the sequence is shown in the figure.\\n\\n The example of a wonderful coloring of the sequence a=[3, 1, 1, 1, 1, 10, 3, 10, 10, 2] and k=3. Note that one of the elements isn't painted.\\n\\nHelp Paul and Mary to find a wonderful coloring of a given sequence a.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10000) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of two lines. The first one contains two integers n and k (1 ≤ n ≤ 2⋅10^5, 1 ≤ k ≤ n) — the length of a given sequence and the number of colors, respectively. The second one contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ n).\\n\\nIt is guaranteed that the sum of n over all test cases doesn't exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nOutput t lines, each of them must contain a description of a wonderful coloring for the corresponding test case.\\n\\nEach wonderful coloring must be printed as a sequence of n integers c_1, c_2, ..., c_n (0 ≤ c_i ≤ k) separated by spaces where\\n\\n * c_i=0, if i-th element isn't painted; \\n * c_i>0, if i-th element is painted in the...\\nSolve the task in JAVA.\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\n\\npublic class Main{\\n\\tstatic void main() throws Exception{\\n\\t\\tint n=sc.nextInt(),k=sc.nextInt();\\n\\t\\tLinkedList[]occ=new LinkedList[n];\\n\\t\\tfor(int i=0;i();\\n\\t\\t\\n\\t\\tfor(int i=0;icur=new LinkedList();\\n\\t\\tfor(int i=0;i\\nusing namespace std;\\nint readint() {\\n char c;\\n while (c = getchar(), (c < '0' || c > '9') && c != '-')\\n ;\\n bool flag = (c == '-');\\n if (flag) c = getchar();\\n int x = 0;\\n while (c >= '0' && c <= '9') {\\n x = x * 10 + c - 48;\\n c = getchar();\\n }\\n return flag ? -x : x;\\n}\\nstringstream ss;\\nint n, m, siz;\\nchar c[555][555];\\nbool u[555][555];\\ninline void dfs(int x, int y, bool fst) {\\n if (x < 0 || x == n || y < 0 || y == m) return;\\n if (u[x][y] == 1) return;\\n ss << \\\"B \\\" << x + 1 << \\\" \\\" << y + 1 << '\\\\n';\\n siz++;\\n u[x][y] = 1;\\n dfs(x, y - 1, 1);\\n dfs(x - 1, y, 1);\\n dfs(x + 1, y, 1);\\n dfs(x, y + 1, 1);\\n if (fst) {\\n siz += 2;\\n ss << \\\"D \\\" << x + 1 << \\\" \\\" << y + 1 << '\\\\n';\\n ss << \\\"R \\\" << x + 1 << \\\" \\\" << y + 1 << '\\\\n';\\n }\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n int i, j;\\n cin >> n >> m;\\n for (i = 0; i < n; i++)\\n for (j = 0; j < m; j++) {\\n cin >> c[i][j];\\n if (c[i][j] == '#') u[i][j] = 1;\\n }\\n for (i = 0; i < n; i++)\\n for (j = 0; j < m; j++)\\n if (!u[i][j]) dfs(i, j, 0);\\n cout << siz << endl;\\n cout << ss.str();\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alice and Bob are playing a game with n piles of stones. It is guaranteed that n is an even number. The i-th pile has a_i stones.\\n\\nAlice and Bob will play a game alternating turns with Alice going first.\\n\\nOn a player's turn, they must choose exactly n\\/2 nonempty piles and independently remove a positive number of stones from each of the chosen piles. They can remove a different number of stones from the piles in a single turn. The first player unable to make a move loses (when there are less than n\\/2 nonempty piles).\\n\\nGiven the starting configuration, determine who will win the game.\\n\\nInput\\n\\nThe first line contains one integer n (2 ≤ n ≤ 50) — the number of piles. It is guaranteed that n is an even number.\\n\\nThe second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 50) — the number of stones in the piles.\\n\\nOutput\\n\\nPrint a single string \\\"Alice\\\" if Alice wins; otherwise, print \\\"Bob\\\" (without double quotes).\\n\\nExamples\\n\\nInput\\n\\n\\n2\\n8 8\\n\\n\\nOutput\\n\\n\\nBob\\n\\n\\nInput\\n\\n\\n4\\n3 1 4 1\\n\\n\\nOutput\\n\\n\\nAlice\\n\\nNote\\n\\nIn the first example, each player can only remove stones from one pile (2\\/2=1). Alice loses, since Bob can copy whatever Alice does on the other pile, so Alice will run out of moves first.\\n\\nIn the second example, Alice can remove 2 stones from the first pile and 3 stones from the third pile on her first move to guarantee a win.\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nvoid deb(istream_iterator it) { cerr << endl; }\\ntemplate \\nvoid deb(istream_iterator it, T a, Args... args) {\\n cerr << *it << \\\" = \\\" << a << \\\", \\\";\\n deb(++it, args...);\\n}\\nint main() {\\n ios::sync_with_stdio(false);\\n cin.tie(0);\\n int n;\\n cin >> n;\\n vector a(n);\\n int mn = 1000000007;\\n for (auto &it : a) {\\n cin >> it;\\n mn = min(mn, it);\\n }\\n int cnt = 0;\\n for (int i = 0; i < n; i++) {\\n if (a[i] == mn) cnt++;\\n }\\n if (cnt > n \\/ 2)\\n cout << \\\"Bob\\\" << '\\\\n';\\n else\\n cout << \\\"Alice\\\\n\\\";\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"You are given a permutation p consisting of n integers 1, 2, ..., n (a permutation is an array where each element from 1 to n occurs exactly once).\\n\\nLet's call an array a bipartite if the following undirected graph is bipartite:\\n\\n * the graph consists of n vertices; \\n * two vertices i and j are connected by an edge if i < j and a_i > a_j. \\n\\n\\n\\nYour task is to find a bipartite array of integers a of size n, such that a_i = p_i or a_i = -p_i, or report that no such array exists. If there are multiple answers, print any of them.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 2 ⋅ 10^5) — the number of test cases.\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 10^6) — the size of the permutation.\\n\\nThe second line contains n integers p_1, p_2, ..., p_n.\\n\\nThe sum of n over all test cases doesn't exceed 10^6.\\n\\nOutput\\n\\nFor each test case, print the answer in the following format. If such an array a does not exist, print \\\"NO\\\" in a single line. Otherwise, print \\\"YES\\\" in the first line and n integers — array a in the second line.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n1 2 3\\n6\\n1 3 2 6 5 4\\n4\\n4 1 3 2\\n8\\n3 2 1 6 7 8 5 4\\n\\n\\nOutput\\n\\n\\nYES\\n1 2 3\\nNO\\nYES\\n-4 -1 -3 -2\\nYES\\n-3 -2 1 6 7 -8 -5 -4\\\":\",\"targets\":\"#include \\nusing namespace std;\\nusing ll = long long;\\nusing ld = long double;\\ntemplate \\nbool uin(T& a, const T& b) {\\n return a > b ? a = b, true : false;\\n}\\ntemplate \\nbool uax(T& a, const T& b) {\\n return a < b ? a = b, true : false;\\n}\\nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\\nconstexpr int inf = 1e9;\\nvoid solve() {\\n int n;\\n cin >> n;\\n vector p(n);\\n for (auto& x : p) cin >> x;\\n p.insert(begin(p), -inf);\\n vector> par(n + 1);\\n array dp;\\n fill(begin(dp), end(dp), -inf);\\n for (int i = 1; i <= n; ++i) {\\n array nxt;\\n fill(begin(nxt), end(nxt), inf);\\n for (int x = -p[i], j = 0; j < 2; ++j, x = -x) {\\n if (x > -p[i - 1] && uin(nxt[j], dp[0])) par[i][j] = 0;\\n if (x > dp[0] && uin(nxt[j], -p[i - 1])) par[i][j] = 0;\\n if (x > +p[i - 1] && uin(nxt[j], dp[1])) par[i][j] = 1;\\n if (x > dp[1] && uin(nxt[j], +p[i - 1])) par[i][j] = 1;\\n }\\n dp = move(nxt);\\n }\\n if (min(dp[0], dp[1]) > n) {\\n cout << \\\"NO\\\\n\\\";\\n return;\\n }\\n cout << \\\"YES\\\\n\\\";\\n vector res;\\n for (int i = n, state = dp[1] <= n; i > 0; --i) {\\n if (state)\\n res.push_back(+p[i]);\\n else\\n res.push_back(-p[i]);\\n state = par[i][state];\\n }\\n reverse(begin(res), end(res));\\n for (auto x : res) cout << x << ' ';\\n cout << '\\\\n';\\n}\\nsigned main() {\\n ios::sync_with_stdio(false);\\n cin.tie(nullptr);\\n int t;\\n cin >> t;\\n while (t--) solve();\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nFor a positive integer X, let f(X) be the number of positive divisors of X.\\n\\nGiven a positive integer N, find \\\\sum_{K=1}^N K\\\\times f(K).\\n\\nConstraints\\n\\n* 1 \\\\leq N \\\\leq 10^7\\n\\nInput\\n\\nInput is given from Standard Input in the following format:\\n\\n\\nN\\n\\n\\nOutput\\n\\nPrint the value \\\\sum_{K=1}^N K\\\\times f(K).\\n\\nExamples\\n\\nInput\\n\\n4\\n\\n\\nOutput\\n\\n23\\n\\n\\nInput\\n\\n100\\n\\n\\nOutput\\n\\n26879\\n\\n\\nInput\\n\\n10000000\\n\\n\\nOutput\\n\\n838627288460105\",\"targets\":\"#include \\nusing namespace std;\\n\\nint main() {\\n int64_t N,Z=0;\\n cin>>N;\\n for(int i=1;i<=N;i++){\\n Z+=i*(N\\/i)*(N\\/i+1)\\/2;\\n }\\n cout<\\nusing namespace std;\\nconst int MAXN = 510;\\nint n, m;\\nstring f[MAXN];\\nint dp[MAXN][26][26];\\nchar g[MAXN][2];\\nint main() {\\n cin >> n >> m;\\n for (int i = 0; i < n; i++) cin >> f[i];\\n for (int i = 0; i < n; i++) {\\n for (int a = 0; a < 26; a++)\\n for (int b = 0; b < 26; b++)\\n if (a != b) {\\n int ans = 0;\\n for (int j = 0; j < m; j++)\\n if ((j % 2 == 0 && f[i][j] - 'a' != a) ||\\n (j % 2 == 1 && f[i][j] - 'a' != b))\\n ans++;\\n if (i > 0) {\\n int mini = n * m;\\n for (int c = 0; c < 26; c++)\\n for (int d = 0; d < 26; d++)\\n if (c != d && c != a && d != b && dp[i - 1][c][d] < mini)\\n mini = dp[i - 1][c][d];\\n ans += mini;\\n }\\n dp[i][a][b] = ans;\\n }\\n }\\n int mini = dp[n - 1][0][1];\\n for (int a = 0; a < 26; a++)\\n for (int b = 0; b < 26; b++)\\n if (a != b && dp[n - 1][a][b] < mini) mini = dp[n - 1][a][b];\\n cout << mini << endl;\\n int pa = -1, pb = -1;\\n for (int i = n - 1; i > -1; i--) {\\n int mini = n * m, mina = -1, minb = -1;\\n for (int a = 0; a < 26; a++)\\n for (int b = 0; b < 26; b++)\\n if (a != b && a != pa && b != pb && dp[i][a][b] < mini) {\\n mini = dp[i][a][b];\\n mina = a;\\n minb = b;\\n }\\n pa = mina;\\n pb = minb;\\n g[i][0] = char('a' + pa);\\n g[i][1] = char('a' + pb);\\n }\\n for (int i = 0; i < n; i++) {\\n for (int j = 0; j < m; j++) cout << g[i][j % 2];\\n cout << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in PYTHON3?\\nEzzat has an array of n integers (maybe negative). He wants to split it into two non-empty subsequences a and b, such that every element from the array belongs to exactly one subsequence, and the value of f(a) + f(b) is the maximum possible value, where f(x) is the average of the subsequence x. \\n\\nA sequence x is a subsequence of a sequence y if x can be obtained from y by deletion of several (possibly, zero or all) elements.\\n\\nThe average of a subsequence is the sum of the numbers of this subsequence divided by the size of the subsequence.\\n\\nFor example, the average of [1,5,6] is (1+5+6)\\/3 = 12\\/3 = 4, so f([1,5,6]) = 4.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^3)— the number of test cases. Each test case consists of two lines.\\n\\nThe first line contains a single integer n (2 ≤ n ≤ 10^5).\\n\\nThe second line contains n integers a_1, a_2, …, a_n (-10^9 ≤ a_i ≤ 10^9).\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 3⋅10^5.\\n\\nOutput\\n\\nFor each test case, print a single value — the maximum value that Ezzat can achieve.\\n\\nYour answer is considered correct if its absolute or relative error does not exceed 10^{-6}.\\n\\nFormally, let your answer be a, and the jury's answer be b. Your answer is accepted if and only if \\\\frac{|a - b|}{max{(1, |b|)}} ≤ 10^{-6}.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n3 1 2\\n3\\n-7 -6 -6\\n3\\n2 2 2\\n4\\n17 3 5 -3\\n\\n\\nOutput\\n\\n\\n4.500000000\\n-12.500000000\\n4.000000000\\n18.666666667\\n\\nNote\\n\\nIn the first test case, the array is [3, 1, 2]. These are all the possible ways to split this array: \\n\\n * a = [3], b = [1,2], so the value of f(a) + f(b) = 3 + 1.5 = 4.5. \\n * a = [3,1], b = [2], so the value of f(a) + f(b) = 2 + 2 = 4. \\n * a = [3,2], b = [1], so the value of f(a) + f(b) = 2.5 + 1 = 3.5. \\n\\nTherefore, the maximum possible value 4.5.\\n\\nIn the second test case, the array is [-7, -6, -6]. These are all the possible ways to split this array: \\n\\n * a = [-7], b = [-6,-6], so the value of f(a) + f(b) = (-7) + (-6) = -13. \\n * a = [-7,-6], b = [-6], so the value of f(a) + f(b) = (-6.5) + (-6) =...\",\"targets\":\"# cook your dish here\\nt=int(input())\\nfor _ in range(t):\\n n=int(input())\\n a=list(map(int,input().split()))\\n a.sort()\\n s=[a[0]]\\n for i in range(1,n):\\n s.append(s[-1]+a[i])\\n ans=-10**10\\n for i in range(n-1):\\n ans=max(ans,s[i]\\/(i+1)+(s[-1]-s[i])\\/(n-i-1))\\n print(ans)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Drazil is a monkey. He lives in a circular park. There are n trees around the park. The distance between the i-th tree and (i + 1)-st trees is di, the distance between the n-th tree and the first tree is dn. The height of the i-th tree is hi.\\n\\nDrazil starts each day with the morning run. The morning run consists of the following steps:\\n\\n * Drazil chooses two different trees \\n * He starts with climbing up the first tree \\n * Then he climbs down the first tree, runs around the park (in one of two possible directions) to the second tree, and climbs on it \\n * Then he finally climbs down the second tree. \\n\\n\\n\\nBut there are always children playing around some consecutive trees. Drazil can't stand children, so he can't choose the trees close to children. He even can't stay close to those trees.\\n\\nIf the two trees Drazil chooses are x-th and y-th, we can estimate the energy the morning run takes to him as 2(hx + hy) + dist(x, y). Since there are children on exactly one of two arcs connecting x and y, the distance dist(x, y) between trees x and y is uniquely defined.\\n\\nNow, you know that on the i-th day children play between ai-th tree and bi-th tree. More formally, if ai ≤ bi, children play around the trees with indices from range [ai, bi], otherwise they play around the trees with indices from .\\n\\nPlease help Drazil to determine which two trees he should choose in order to consume the most energy (since he wants to become fit and cool-looking monkey) and report the resulting amount of energy for each day.\\n\\nInput\\n\\nThe first line contains two integer n and m (3 ≤ n ≤ 105, 1 ≤ m ≤ 105), denoting number of trees and number of days, respectively. \\n\\nThe second line contains n integers d1, d2, ..., dn (1 ≤ di ≤ 109), the distances between consecutive trees.\\n\\nThe third line contains n integers h1, h2, ..., hn (1 ≤ hi ≤ 109), the heights of trees.\\n\\nEach of following m lines contains two integers ai and bi (1 ≤ ai, bi ≤ n) describing each new day. There are always at least two different trees Drazil can choose that are...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\ntemplate \\ninline T read() {\\n T s = 0, f = 1;\\n char ch = getchar();\\n while (!isdigit(ch)) {\\n if (ch == '-') f = -1;\\n ch = getchar();\\n }\\n while (isdigit(ch)) {\\n s = (s << 3) + (s << 1) + ch - 48;\\n ch = getchar();\\n }\\n return s * f;\\n}\\ntemplate \\ninline void print(T x) {\\n if (x < 0) putchar('-'), x = -x;\\n if (x > 9) print(x \\/ 10);\\n putchar(x % 10 + '0');\\n}\\nconst int N = 2e5 + 100;\\nconst int mod = 1e9 + 7;\\nlong long h[N], w[N], sum[N];\\nstruct Segment {\\n static const int maxn = 2e5 + 100;\\n struct star {\\n long long lsum, rsum, sum;\\n } s[maxn << 2];\\n void pushup(int node, int l, int r) {\\n int mid = l + r >> 1;\\n s[node].lsum =\\n max(s[node << 1].lsum, h[l] + sum[mid - 1] - sum[l - 1] +\\n s[node << 1 | 1].lsum - h[mid + 1] + w[mid]);\\n s[node].lsum = max(s[node].lsum, h[l] + h[mid + 1] + sum[mid] - sum[l - 1]);\\n s[node].rsum =\\n max(s[node << 1 | 1].rsum,\\n h[r] + sum[r - 1] - sum[mid] + s[node << 1].rsum - h[mid] + w[mid]);\\n s[node].rsum = max(s[node].rsum, h[r] + h[mid] + sum[r - 1] - sum[mid - 1]);\\n s[node].sum = max(s[node << 1].rsum + s[node << 1 | 1].lsum - h[mid] -\\n h[mid + 1] + w[mid],\\n max(s[node << 1].sum, s[node << 1 | 1].sum));\\n s[node].sum = max(s[node].sum, max(s[node].lsum, s[node].rsum));\\n s[node].sum = max(s[node].sum, h[r] + h[l] + sum[r - 1] - sum[l - 1]);\\n s[node].sum = max(\\n s[node].sum, max(s[node << 1].rsum - h[mid] + h[mid + 1] + w[mid],\\n s[node << 1 | 1].lsum - h[mid + 1] + h[mid] + w[mid]));\\n s[node].sum = max(s[node].sum, h[mid] + h[mid + 1] + w[mid]);\\n }\\n void build(int node, int l, int r) {\\n if (l == r) {\\n s[node].lsum = s[node].rsum = h[l];\\n s[node].sum = 0;\\n return;\\n }\\n int mid = l + r >> 1;\\n build(node << 1, l, mid);\\n build(node << 1 | 1, mid + 1, r);\\n pushup(node, l, r);\\n }\\n star query(int node,...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"In this problem you have to implement an algorithm to defragment your hard disk. The hard disk consists of a sequence of clusters, numbered by integers from 1 to n. The disk has m recorded files, the i-th file occupies clusters with numbers ai, 1, ai, 2, ..., ai, ni. These clusters are not necessarily located consecutively on the disk, but the order in which they are given corresponds to their sequence in the file (cluster ai, 1 contains the first fragment of the i-th file, cluster ai, 2 has the second fragment, etc.). Also the disc must have one or several clusters which are free from files.\\n\\nYou are permitted to perform operations of copying the contents of cluster number i to cluster number j (i and j must be different). Moreover, if the cluster number j used to keep some information, it is lost forever. Clusters are not cleaned, but after the defragmentation is complete, some of them are simply declared unusable (although they may possibly still contain some fragments of files).\\n\\nYour task is to use a sequence of copy operations to ensure that each file occupies a contiguous area of memory. Each file should occupy a consecutive cluster section, the files must follow one after another from the beginning of the hard disk. After defragmentation all free (unused) clusters should be at the end of the hard disk. After defragmenting files can be placed in an arbitrary order. Clusters of each file should go consecutively from first to last. See explanatory examples in the notes.\\n\\nPrint the sequence of operations leading to the disk defragmentation. Note that you do not have to minimize the number of operations, but it should not exceed 2n.\\n\\nInput\\n\\nThe first line contains two integers n and m (1 ≤ n, m ≤ 200) — the number of clusters and the number of files, correspondingly. Next m lines contain descriptions of the files. The first number in the line is ni (ni ≥ 1), the number of clusters occupied by the i-th file. Then follow ni numbers ai, 1, ai, 2, ..., ai, ni (1 ≤ ai, j ≤ n). It is guaranteed that each cluster...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nbool used[210];\\nint belong[210];\\nint visited[210];\\nstruct node {\\n int a, b;\\n} op[(210 << 1)];\\nint opnum;\\nint main() {\\n int N, M, i, nn, j, pt, empty, opnum;\\n while (scanf(\\\"%d%d\\\", &N, &M) != EOF) {\\n memset(used, false, sizeof(used));\\n pt = 0;\\n opnum = 0;\\n empty = 1;\\n for (i = 0; i < M; i++) {\\n scanf(\\\"%d\\\", &nn);\\n for (j = 0; j < nn; j++) {\\n scanf(\\\"%d\\\", &visited[++pt]);\\n used[visited[pt]] = true;\\n belong[visited[pt]] = pt;\\n }\\n }\\n for (i = 1; i <= pt; i++) {\\n if (visited[i] != i) {\\n if (used[i] == true)\\n for (empty = 1; empty <= N; empty++) {\\n if (used[empty] == false) {\\n used[empty] = true;\\n used[visited[i]] = false;\\n visited[belong[i]] = empty;\\n belong[empty] = belong[i];\\n op[++opnum].a = i;\\n op[opnum].b = empty;\\n op[++opnum].a = visited[i];\\n op[opnum].b = i;\\n belong[i] = i;\\n visited[i] = i;\\n break;\\n }\\n }\\n else {\\n used[i] = true;\\n used[visited[i]] = false;\\n op[++opnum].a = visited[i];\\n op[opnum].b = i;\\n belong[i] = i;\\n visited[i] = i;\\n }\\n }\\n }\\n printf(\\\"%d\\\\n\\\", opnum);\\n for (i = 1; i <= opnum; i++) printf(\\\"%d %d\\\\n\\\", op[i].a, op[i].b);\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given an integer n. In 1 move, you can do one of the following actions:\\n\\n * erase any digit of the number (it's acceptable that the number before the operation has exactly one digit and after the operation, it is \\\"empty\\\"); \\n * add one digit to the right. \\n\\n\\n\\nThe actions may be performed in any order any number of times.\\n\\nNote that if, after deleting some digit from a number, it will contain leading zeroes, they will not be deleted. E.g. if you delete from the number 301 the digit 3, the result is the number 01 (not 1).\\n\\nYou need to perform the minimum number of actions to make the number any power of 2 (i.e. there's an integer k (k ≥ 0) such that the resulting number is equal to 2^k). The resulting number must not have leading zeroes.\\n\\nE.g. consider n=1052. The answer is equal to 2. First, let's add to the right one digit 4 (the result will be 10524). Then let's erase the digit 5, so the result will be 1024 which is a power of 2.\\n\\nE.g. consider n=8888. The answer is equal to 3. Let's erase any of the digits 8 three times. The result will be 8 which is a power of 2.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10^4) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one line containing one integer n (1 ≤ n ≤ 10^9).\\n\\nOutput\\n\\nFor each test case, output in a separate line one integer m — the minimum number of moves to transform the number into any power of 2.\\n\\nExample\\n\\nInput\\n\\n\\n12\\n1052\\n8888\\n6\\n75\\n128\\n1\\n301\\n12048\\n1504\\n6656\\n1000000000\\n687194767\\n\\n\\nOutput\\n\\n\\n2\\n3\\n1\\n3\\n0\\n0\\n2\\n1\\n3\\n4\\n9\\n2\\n\\nNote\\n\\nThe answer for the first test case was considered above.\\n\\nThe answer for the second test case was considered above.\\n\\nIn the third test case, it's enough to add to the right the digit 4 — the number 6 will turn into 64.\\n\\nIn the fourth test case, let's add to the right the digit 8 and then erase 7 and 5 — the taken number will turn into 8.\\n\\nThe numbers of the fifth and the sixth test cases are already powers of two so there's no need to make any move.\\n\\nIn the seventh test case, you can...\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int t;\\n cin >> t;\\n vector powers;\\n for (long long i = 1; i <= 2e18; i *= 2) {\\n powers.push_back(to_string(i));\\n }\\n while (t--) {\\n string num;\\n cin >> num;\\n int size = num.size();\\n int minimum = 1e5;\\n for (int i = 0; i < powers.size(); i++) {\\n string temp = num;\\n int cnt = 0;\\n for (long long j = 0; j < temp.size(); j++) {\\n if (temp[j] != powers[i][j]) {\\n temp.erase(temp.begin() + j);\\n j--;\\n } else {\\n cnt++;\\n }\\n }\\n int res = size - cnt + powers[i].size() - cnt;\\n minimum = min(minimum, res);\\n }\\n cout << minimum << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given an array consisting of all integers from [l, r] inclusive. For example, if l = 2 and r = 5, the array would be [2, 3, 4, 5]. What's the minimum number of elements you can delete to make the [bitwise AND](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#AND) of the array non-zero?\\n\\nA bitwise AND is a binary operation that takes two equal-length binary representations and performs the AND operation on each pair of the corresponding bits.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10^4) — the number of test cases. Then t cases follow.\\n\\nThe first line of each test case contains two integers l and r (1 ≤ l ≤ r ≤ 2 ⋅ 10^5) — the description of the array.\\n\\nOutput\\n\\nFor each test case, output a single integer — the answer to the problem.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n1 2\\n2 8\\n4 5\\n1 5\\n100000 200000\\n\\n\\nOutput\\n\\n\\n1\\n3\\n0\\n2\\n31072\\n\\nNote\\n\\nIn the first test case, the array is [1, 2]. Currently, the bitwise AND is 0, as 1\\\\ \\\\& \\\\ 2 = 0. However, after deleting 1 (or 2), the array becomes [2] (or [1]), and the bitwise AND becomes 2 (or 1). This can be proven to be the optimal, so the answer is 1.\\n\\nIn the second test case, the array is [2, 3, 4, 5, 6, 7, 8]. Currently, the bitwise AND is 0. However, after deleting 4, 5, and 8, the array becomes [2, 3, 6, 7], and the bitwise AND becomes 2. This can be proven to be the optimal, so the answer is 3. Note that there may be other ways to delete 3 elements.\\n\\nimpo\",\"targets\":\"rt java.io.IOException;\\nimport java.io.InputStream;\\nimport static java.lang.Math.sqrt;\\n\\npublic class B {\\n\\n \\/**\\n * Template\\n *\\n * @author William Fiset, william.alexandre.fiset@gmail.com\\n *\\n *\\/\\n static InputReader in = new InputReader(System.in);\\n\\n private static int bitCount(int l, int bit) {\\n int fullcycle = (1 << bit);\\n int cyclecount = l \\/ fullcycle;\\n int cyclebits = (cyclecount \\/2) * fullcycle;\\n int leftbits = l % fullcycle + 1;\\n if (cyclecount % 2 == 1) {\\n cyclebits += leftbits;\\n }\\n return cyclebits;\\n }\\n\\n static class InputReader {\\n\\n private static final int DEFAULT_BUFFER_SIZE = 1 << 16;\\n private static final InputStream DEFAULT_STREAM = System.in;\\n private static final int MAX_DECIMAL_PRECISION = 21;\\n private int c;\\n private byte[] buf;\\n private int bufferSize, bufIndex, numBytesRead;\\n\\n private InputStream stream;\\n\\n private static final byte EOF = -1;\\n private static final byte NEW_LINE = 10;\\n private static final byte SPACE = 32;\\n private static final byte DASH = 45;\\n private static final byte DOT = 46;\\n\\n private char[] charBuffer;\\n\\n private static byte[] bytes = new byte[58];\\n private static int[] ints = new int[58];\\n private static char[] chars = new char[128];\\n\\n static {\\n char ch = ' ';\\n int value = 0;\\n byte _byte = 0;\\n for (int i = 48; i < 58; i++) {\\n bytes[i] = _byte++;\\n }\\n for (int i = 48; i < 58; i++) {\\n ints[i] = value++;\\n }\\n for (int i = 32; i < 128; i++) {\\n chars[i] = ch++;\\n }\\n }\\n\\n private static final double[][] doubles = {\\n {0.0d, 0.00d, 0.000d, 0.0000d, 0.00000d, 0.000000d, 0.0000000d, 0.00000000d, 0.000000000d,\\n 0.0000000000d, 0.00000000000d, 0.000000000000d,\\n 0.0000000000000d, 0.00000000000000d, 0.000000000000000d, 0.0000000000000000d,\\n 0.00000000000000000d, 0.000000000000000000d,\\n 0.0000000000000000000d, 0.00000000000000000000d, 0.000000000000000000000d},\\n {0.1d, 0.01d, 0.001d, 0.0001d,...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Petya has an array of integers a_1, a_2, …, a_n. He only likes sorted arrays. Unfortunately, the given array could be arbitrary, so Petya wants to sort it.\\n\\nPetya likes to challenge himself, so he wants to sort array using only 3-cycles. More formally, in one operation he can pick 3 pairwise distinct indices i, j, and k (1 ≤ i, j, k ≤ n) and apply i → j → k → i cycle to the array a. It simultaneously places a_i on position j, a_j on position k, and a_k on position i, without changing any other element.\\n\\nFor example, if a is [10, 50, 20, 30, 40, 60] and he chooses i = 2, j = 1, k = 5, then the array becomes [\\\\underline{50}, \\\\underline{40}, 20, 30, \\\\underline{10}, 60].\\n\\nPetya can apply arbitrary number of 3-cycles (possibly, zero). You are to determine if Petya can sort his array a, i. e. make it non-decreasing.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 5 ⋅ 10^5). Description of the test cases follows.\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 5 ⋅ 10^5) — the length of the array a.\\n\\nThe second line of each test case contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ n).\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 5 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print \\\"YES\\\" (without quotes) if Petya can sort the array a using 3-cycles, and \\\"NO\\\" (without quotes) otherwise. You can print each letter in any case (upper or lower).\\n\\nExample\\n\\nInput\\n\\n\\n7\\n1\\n1\\n2\\n2 2\\n2\\n2 1\\n3\\n1 2 3\\n3\\n2 1 3\\n3\\n3 1 2\\n4\\n2 1 4 3\\n\\n\\nOutput\\n\\n\\nYES\\nYES\\nNO\\nYES\\nNO\\nYES\\nYES\\n\\nNote\\n\\nIn the 6-th test case Petya can use the 3-cycle 1 → 3 → 2 → 1 to sort the array.\\n\\nIn the 7-th test case Petya can apply 1 → 3 → 2 → 1 and make a = [1, 4, 2, 3]. Then he can apply 2 → 4 → 3 → 2 and finally sort the array.\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\ntemplate \\nstruct rge {\\n c b, e;\\n};\\ntemplate \\nrge range(c i, c j) {\\n return rge{i, j};\\n}\\ntemplate \\nauto dud(c *x) -> decltype(cerr << *x, 0);\\ntemplate \\nchar dud(...);\\nstruct debug {\\n template \\n debug &operator<<(const c &) {\\n return *this;\\n }\\n};\\ntemplate \\nvoid read(T &x) {\\n cin >> x;\\n}\\ntemplate \\nvoid read(T &x, U &y) {\\n cin >> x >> y;\\n}\\ntemplate \\nvoid read(vector &a) {\\n for (T &x : a) read(x);\\n}\\ntemplate \\nT cd(T u, T v) {\\n return (u + v - 1) \\/ v;\\n}\\nvoid solve() {\\n long long n;\\n read(n);\\n vector a(n);\\n read(a);\\n auto v = a;\\n sort(v.begin(), v.end());\\n if (n <= 2) {\\n cout << (a == v ? \\\"YES\\\\n\\\" : \\\"NO\\\\n\\\");\\n return;\\n }\\n map> mp;\\n for (long long i = 0; i < n; i++) mp[a[i]].insert(i);\\n for (long long i = 0; i < n - 2; i++) {\\n if (a[i] == v[i]) {\\n mp[a[i]].erase(i);\\n } else {\\n long long j = *mp[v[i]].begin();\\n long long k = (j == n - 1) ? n - 2 : n - 1;\\n mp[a[i]].erase(i);\\n mp[a[k]].erase(k);\\n mp[a[j]].erase(j);\\n long long temp = a[i];\\n a[i] = a[j];\\n a[j] = a[k];\\n a[k] = temp;\\n mp[a[k]].insert(k);\\n mp[a[j]].insert(j);\\n assert(set({i, j, k}).size() == 3);\\n }\\n debug() << \\\" [\\\"\\n << \\\"mp\\\"\\n \\\": \\\"\\n << (mp) << \\\"] \\\";\\n }\\n for (long long i = n - 2; i < n; i++) {\\n if (a[i] != v[i]) {\\n map mpp;\\n for (long long j = 0; j < n; j++) mpp[a[j]]++;\\n for (auto &p : mpp) {\\n if (p.second >= 2) {\\n cout << \\\"YES\\\\n\\\";\\n return;\\n }\\n }\\n cout << \\\"NO\\\\n\\\";\\n return;\\n }\\n }\\n assert(is_sorted(a.begin(), a.end()));\\n cout << \\\"YES\\\\n\\\";\\n}\\nint32_t main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n long long t = 1;\\n read(t);\\n for (long long testcase = 1; testcase <= t; testcase++) {\\n solve();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A word or a sentence in some language is called a pangram if all the characters of the alphabet of this language appear in it at least once. Pangrams are often used to demonstrate fonts in printing or test the output devices.\\n\\nYou are given a string consisting of lowercase and uppercase Latin letters. Check whether this string is a pangram. We say that the string contains a letter of the Latin alphabet if this letter occurs in the string in uppercase or lowercase.\\n\\nInput\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 100) — the number of characters in the string.\\n\\nThe second line contains the string. The string consists only of uppercase and lowercase Latin letters.\\n\\nOutput\\n\\nOutput \\\"YES\\\", if the string is a pangram and \\\"NO\\\" otherwise.\\n\\nExamples\\n\\nInput\\n\\n12\\ntoosmallword\\n\\n\\nOutput\\n\\nNO\\n\\n\\nInput\\n\\n35\\nTheQuickBrownFoxJumpsOverTheLazyDog\\n\\n\\nOutput\\n\\nYES\\nSolve the task in PYTHON3.\",\"targets\":\"n = int(input())\\ns = input()\\ns = s.lower()\\nm = {}\\nfor c in s:\\n m[c] = m.get(c, 0) + 1\\nif (len(m) > 25):\\n print(\\\"YES\\\")\\nelse:\\n print(\\\"NO\\\")\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given an array of integers a of length n. The elements of the array can be either different or the same. \\n\\nEach element of the array is colored either blue or red. There are no unpainted elements in the array. One of the two operations described below can be applied to an array in a single step:\\n\\n * either you can select any blue element and decrease its value by 1; \\n * or you can select any red element and increase its value by 1. \\n\\n\\n\\nSituations in which there are no elements of some color at all are also possible. For example, if the whole array is colored blue or red, one of the operations becomes unavailable.\\n\\nDetermine whether it is possible to make 0 or more steps such that the resulting array is a permutation of numbers from 1 to n?\\n\\nIn other words, check whether there exists a sequence of steps (possibly empty) such that after applying it, the array a contains in some order all numbers from 1 to n (inclusive), each exactly once.\\n\\nInput\\n\\nThe first line contains an integer t (1 ≤ t ≤ 10^4) — the number of input data sets in the test.\\n\\nThe description of each set of input data consists of three lines. The first line contains an integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the length of the original array a. The second line contains n integers a_1, a_2, ..., a_n (-10^9 ≤ a_i ≤ 10^9) — the array elements themselves.\\n\\nThe third line has length n and consists exclusively of the letters 'B' and\\/or 'R': ith character is 'B' if a_i is colored blue, and is 'R' if colored red.\\n\\nIt is guaranteed that the sum of n over all input sets does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nPrint t lines, each of which contains the answer to the corresponding test case of the input. Print YES as an answer if the corresponding array can be transformed into a permutation, and NO otherwise.\\n\\nYou can print the answer in any case (for example, the strings yEs, yes, Yes, and YES will be recognized as a positive answer).\\n\\nExample\\n\\nInput\\n\\n\\n8\\n4\\n1 2 5 2\\nBRBR\\n2\\n1 1\\nBB\\n5\\n3 1 4 2 5\\nRBRRB\\n5\\n3 1 3 1 3\\nRBRRB\\n5\\n5 1 5 1 5\\nRBRRB\\n4\\n2 2 2 2\\nBRBR\\n2\\n1 -2\\nBR\\n4\\n-2...\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 2e5 + 10;\\nint blue[N], red[N], c[N];\\nint main() {\\n int t;\\n cin >> t;\\n while (t--) {\\n int cnt = 0, cns = 0;\\n int n;\\n cin >> n;\\n for (int i = 1; i <= n; i++) cin >> c[i];\\n string ss;\\n cin >> ss;\\n for (int i = 0, j = 1; i < ss.size(); i++, j++)\\n if (ss[i] == 'B')\\n blue[++cnt] = c[j];\\n else\\n red[++cns] = c[j];\\n sort(blue + 1, blue + 1 + cnt);\\n sort(red + 1, red + 1 + cns);\\n bool flag = true;\\n for (int i = 1; i <= cnt; i++)\\n if (blue[i] < i) {\\n flag = false;\\n break;\\n }\\n for (int i = cns, j = n; i >= 1; i--, j--)\\n if (red[i] > j) {\\n flag = false;\\n break;\\n }\\n if (flag)\\n cout << \\\"YES\\\" << endl;\\n else\\n cout << \\\"NO\\\" << endl;\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nLet's define S(x) to be the sum of digits of number x written in decimal system. For example, S(5) = 5, S(10) = 1, S(322) = 7.\\n\\nWe will call an integer x interesting if S(x + 1) < S(x). In each test you will be given one integer n. Your task is to calculate the number of integers x such that 1 ≤ x ≤ n and x is interesting.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 1000) — number of test cases.\\n\\nThen t lines follow, the i-th line contains one integer n (1 ≤ n ≤ 10^9) for the i-th test case.\\n\\nOutput\\n\\nPrint t integers, the i-th should be the answer for the i-th test case.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n1\\n9\\n10\\n34\\n880055535\\n\\n\\nOutput\\n\\n\\n0\\n1\\n1\\n3\\n88005553\\n\\nNote\\n\\nThe first interesting number is equal to 9.\",\"targets\":\"import java.util.*;\\nimport java.lang.*;\\nimport java.math.BigInteger;\\nimport java.io.*;\\npublic class Main {\\n static class FastReader \\n { \\n BufferedReader br; \\n StringTokenizer st; \\n\\n public FastReader() \\n { \\n br = new BufferedReader(new\\n InputStreamReader(System.in)); \\n } \\n\\n String next() \\n { \\n while (st == null || !st.hasMoreElements()) \\n { \\n try\\n { \\n st = new StringTokenizer(br.readLine()); \\n } \\n catch (IOException e) \\n { \\n e.printStackTrace(); \\n } \\n } \\n return st.nextToken(); \\n } \\n\\n int nextInt() \\n { \\n return Integer.parseInt(next()); \\n } \\n\\n long nextLong() \\n { \\n return Long.parseLong(next()); \\n } \\n\\n double nextDouble() \\n { \\n return Double.parseDouble(next()); \\n } \\n\\n String nextLine() \\n { \\n String str = \\\"\\\"; \\n try\\n { \\n str = br.readLine(); \\n } \\n catch (IOException e) \\n { \\n e.printStackTrace(); \\n } \\n return str; \\n } \\n }\\n public static void main(String [] args) throws Exception {\\n OutputStream outputStream =System.out;\\n PrintWriter out =new PrintWriter(outputStream);\\n FastReader sc =new FastReader();\\n int t = sc.nextInt();\\n \\n while(t-->0)\\n {\\n long n = sc.nextLong();\\n if(n%10==9)\\n {\\n out.println((n\\/10)+1);\\n }\\n else \\n out.println(n\\/10);\\n }\\n \\n out.close();\\n }\\n \\n \\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Yelisey has an array a of n integers.\\n\\nIf a has length strictly greater than 1, then Yelisei can apply an operation called minimum extraction to it: \\n\\n 1. First, Yelisei finds the minimal number m in the array. If there are several identical minima, Yelisey can choose any of them. \\n 2. Then the selected minimal element is removed from the array. After that, m is subtracted from each remaining element. \\n\\n\\n\\nThus, after each operation, the length of the array is reduced by 1.\\n\\nFor example, if a = [1, 6, -4, -2, -4], then the minimum element in it is a_3 = -4, which means that after this operation the array will be equal to a=[1 {- (-4)}, 6 {- (-4)}, -2 {- (-4)}, -4 {- (-4)}] = [5, 10, 2, 0].\\n\\nSince Yelisey likes big numbers, he wants the numbers in the array a to be as big as possible.\\n\\nFormally speaking, he wants to make the minimum of the numbers in array a to be maximal possible (i.e. he want to maximize a minimum). To do this, Yelisey can apply the minimum extraction operation to the array as many times as he wants (possibly, zero). Note that the operation cannot be applied to an array of length 1.\\n\\nHelp him find what maximal value can the minimal element of the array have after applying several (possibly, zero) minimum extraction operations to the array.\\n\\nInput\\n\\nThe first line contains an integer t (1 ≤ t ≤ 10^4) — the number of test cases.\\n\\nThe next 2t lines contain descriptions of the test cases.\\n\\nIn the description of each test case, the first line contains an integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the original length of the array a. The second line of the description lists n space-separated integers a_i (-10^9 ≤ a_i ≤ 10^9) — elements of the array a.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nPrint t lines, each of them containing the answer to the corresponding test case. The answer to the test case is a single integer — the maximal possible minimum in a, which can be obtained by several applications of the described operation to...\\nimpor\",\"targets\":\"t java.util.*;\\nimport java.io.*;\\npublic class Main {\\n\\t\\tstatic long mod = 1000000007;\\n\\t\\tstatic long max ;\\n\\t\\tstatic PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));\\n\\t\\tpublic static void main(String[] args) throws IOException {\\n\\t\\t\\tFastReader sc = new FastReader();\\n\\t\\t\\tint t = sc.nextInt();\\n\\t\\t\\twhile( t-- > 0) {\\n\\t\\t\\t\\tint n = sc.nextInt();\\n\\t\\t\\t\\tint arr[] = new int[n];\\n\\t\\t\\t\\tfor( int i = 0 ;i < n; i++) {\\n\\t\\t\\t\\t\\tarr[i] = sc.nextInt();\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tmySort(arr);\\n\\t\\t\\t\\tlong temp = 0;\\n\\t\\t\\t\\tlong max = Long.MIN_VALUE;\\n\\t\\t\\t\\tfor(int i= 0 ;i < n;i++) {\\n\\t\\t\\t\\t\\tmax = Math.max(max , arr[i] - temp);\\n\\t\\t\\t\\t\\ttemp+=(arr[i] - temp);\\n\\/\\/\\t\\t\\t\\t\\tout.println( max + \\\" \\\" + temp);\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tout.println(max);\\n\\t\\t\\t}\\n\\t\\t\\tout.flush();\\n\\t\\t}\\n\\t\\n\\t\\tpublic static boolean ifpowof2(long n ) {\\n\\t\\t\\treturn ((n&(n-1)) == 0);\\n\\t\\t}\\n\\t\\t\\n\\t\\tpublic static int[] nextLargerElement(int[] arr, int n)\\t{ \\n\\t\\t\\tStack stack = new Stack<>();\\n\\t\\t\\tint rtrn[] = new int[n];\\n\\t\\t\\trtrn[n-1] = -1;\\n\\t stack.push( n-1);\\n\\t for( int i = n-2 ;i >= 0 ; i--){\\n\\t int temp = arr[i];\\n\\t int lol = -1;\\n\\t while( !stack.isEmpty() && arr[stack.peek()] <= temp){\\n\\t \\tif(arr[stack.peek()] == temp ) {\\n\\t \\t\\tlol = stack.peek();\\n\\t \\t}\\n\\t stack.pop();\\n\\t }\\n\\t if( stack.isEmpty()){\\n\\t \\tif( lol != -1) {\\n\\t \\t\\trtrn[i] = lol;\\n\\t \\t}\\n\\t \\telse {\\n\\t \\t\\trtrn[i] = -1;\\n\\t \\t}\\n\\t }\\n\\t else{\\n\\t \\trtrn[i] = stack.peek();\\n\\t }\\n\\t stack.push( i);\\n\\t }\\n\\t return rtrn;\\n\\t\\t}\\n\\t\\t\\n\\t\\t@SuppressWarnings(\\\"unused\\\")\\n\\t\\tprivate static void mySort(int[] arr) {\\n\\t for(int i=0;i\\n\\nA restriction consists of 3 pairwise distinct integers, a, b, and c (1 ≤ a,b,c ≤ n). It signifies that node b cannot lie on the simple path between node a and node c. \\n\\nCan you help Lord Omkar and become his most trusted disciple? You will need to find heavenly trees for multiple sets of restrictions. It can be shown that a heavenly tree will always exist for any set of restrictions under the given constraints.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^4). Description of the test cases follows.\\n\\nThe first line of each test case contains two integers, n and m (3 ≤ n ≤ 10^5, 1 ≤ m < n), representing the size of the tree and the number of restrictions.\\n\\nThe i-th of the next m lines contains three integers a_i, b_i, c_i (1 ≤ a_i, b_i, c_i ≤ n, a, b, c are distinct), signifying that node b_i cannot lie on the simple path between nodes a_i and c_i. \\n\\nIt is guaranteed that the sum of n across all test cases will not exceed 10^5.\\n\\nOutput\\n\\nFor each test case, output n-1 lines representing the n-1 edges in the tree. On each line, output two integers u and v (1 ≤ u, v ≤ n, u ≠ v) signifying that there is an edge between nodes u and v. Given edges have to form a tree that satisfies Omkar's restrictions.\\n\\nExample\\n\\nInput\\n\\n\\n2\\n7 4\\n1 2 3\\n3 4 5\\n5 6 7\\n6 5 4\\n5 3\\n1 2 3\\n2 3 4\\n3 4 5\\n\\n\\nOutput\\n\\n\\n1 2\\n1 3\\n3 5\\n3 4\\n2 7\\n7 6\\n5 1\\n1 3\\n3 2\\n2 4\\n\\nNote\\n\\nThe output of the first sample case corresponds to the following tree: \\n\\n For the first restriction,...\\nSolve the task in PYTHON3.\",\"targets\":\"inf = float('inf')\\nimport sys\\nimport pprint\\nimport logging\\nfrom logging import getLogger\\nimport array\\n\\n# sys.setrecursionlimit(10 ** 9)\\n\\ndef input(): return sys.stdin.readline().rstrip(\\\"\\\\r\\\\n\\\")\\n\\ndef maps(): return [int(i) for i in input().split()]\\n\\n\\nlogging.basicConfig(\\n format=\\\"%(message)s\\\",\\n level=logging.WARNING,\\n)\\nlogger = getLogger(__name__)\\nlogger.setLevel(logging.INFO)\\n\\n\\ndef debug(msg, *args):\\n logger.info(f'{msg}={pprint.pformat(args)}')\\n\\n\\n# def A():\\n# print(sum(sorted(list(maps()))[1:]))\\n\\n\\n# A()\\ndef check(x):\\n se = set()\\n for i in range(1, int(x**0.5) + 1):\\n if x % i == 0:\\n se.add(i)\\n se.add(x \\/\\/ i)\\n se.remove(1)\\n if x in se:\\n se.remove(x)\\n if len(se):\\n return True\\n return False\\n\\n\\ndef A():\\n for _ in range(*maps()):\\n n, = maps()\\n a = [*maps()]\\n s = sum(a)\\n mi_e, mi_o = inf, inf\\n for i in range(n):\\n if a[i] % 2:\\n mi_o = min(mi_o, a[i])\\n else:\\n mi_e = min(mi_e, a[i])\\n if check(s):\\n print(n)\\n print(*list(range(1, n + 1)))\\n else:\\n x = min(mi_e, mi_o)\\n S = s\\n S -= x\\n if check(S):\\n print(n - 1)\\n A = []\\n for i in range(n):\\n if a[i] == x:\\n continue\\n A.append(i + 1)\\n print(*A)\\n continue\\n x = max(mi_e, mi_o)\\n S = s\\n S -= x\\n if check(S):\\n print(n - 1)\\n A = []\\n for i in range(n):\\n if a[i] == x:\\n continue\\n A.append(i + 1)\\n print(*A)\\n continue\\n\\n\\nclass DisjointSetUnion:\\n def __init__(self, n):\\n self.n = n\\n self.parent = list(range(n))\\n self.size = [1] * n\\n self.numsets = n\\n\\n def find(self, x):\\n xcopy = x\\n while...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"There are n reindeer at the North Pole, all battling for the highest spot on the \\\"Top Reindeer\\\" leaderboard on the front page of CodeNorses (a popular competitive reindeer gaming website). Interestingly, the \\\"Top Reindeer\\\" title is just a measure of upvotes and has nothing to do with their skill level in the reindeer games, but they still give it the utmost importance.\\n\\nCurrently, the i-th reindeer has a score of a_i. You would like to influence the leaderboard with some operations. In an operation, you can choose a reindeer, and either increase or decrease his score by 1 unit. Negative scores are allowed.\\n\\nYou have m requirements for the resulting scores. Each requirement is given by an ordered pair (u, v), meaning that after all operations, the score of reindeer u must be less than or equal to the score of reindeer v.\\n\\nYour task is to perform the minimum number of operations so that all requirements will be satisfied.\\n\\nInput\\n\\nThe first line contains two integers n and m (2≤ n≤ 1000; 1≤ m≤ 1000) — the number of reindeer and requirements, respectively.\\n\\nThe second line contains n integers a_1,…, a_n (1≤ a_i≤ 10^9), where a_i is the current score of reindeer i.\\n\\nThe next m lines describe the requirements.\\n\\nThe i-th of these lines contains two integers u_i and v_i (1≤ u_i, v_i≤ n; u_i≠ v_i) — the two reindeer of the i-th requirement.\\n\\nOutput\\n\\nPrint n integers b_1,…, b_n (-10^{15}≤ b_i≤ 10^{15}), where b_i is the score of the i-th reindeer after all operations.\\n\\nIf there are multiple solutions achieving the minimum number of operations, you may output any.\\n\\nWe can prove that there is always an optimal solution such that |b_i|≤ 10^{15} for all i.\\n\\nExamples\\n\\nInput\\n\\n\\n7 6\\n3 1 4 9 2 5 6\\n1 2\\n2 3\\n3 4\\n4 5\\n5 6\\n6 7\\n\\n\\nOutput\\n\\n\\n1 1 4 4 4 5 6 \\n\\n\\nInput\\n\\n\\n4 6\\n6 5 8 2\\n3 1\\n4 1\\n3 2\\n1 2\\n2 3\\n3 1\\n\\n\\nOutput\\n\\n\\n6 6 6 2 \\n\\n\\nInput\\n\\n\\n10 18\\n214 204 195 182 180 176 176 172 169 167\\n1 2\\n3 2\\n4 2\\n5 2\\n6 2\\n7 2\\n8 2\\n9 2\\n10 2\\n6 1\\n6 2\\n6 3\\n6 4\\n6 5\\n6 7\\n6 8\\n6 9\\n6 10\\n\\n\\nOutput\\n\\n\\n204 204 195 182 180 167 176 172 169 167 \\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst long long INF = 1e18;\\nconst long long N = 1005, M = 70;\\nlong long n, m, w[N], val[N], S, T, a[N], b[N];\\nlong long id[N], tmp[N], ans[N];\\nlist G[N];\\nlist::iterator it, itt;\\nnamespace Flow {\\nconst long long N = ::N + 5, M = ::N * ::M * 2;\\nlong long fir[N], to[M], nxt[M], cnt = 1, d[N], cur[N];\\nlong long fl[M];\\ninline void addedge(long long u, long long v, long long f) {\\n to[++cnt] = v;\\n fl[cnt] = f;\\n nxt[cnt] = fir[u];\\n fir[u] = cnt;\\n}\\ninline void addflow(long long u, long long v, long long f) {\\n addedge(u, v, f);\\n addedge(v, u, 0);\\n}\\ninline void clear(long long l, long long r) {\\n cnt = 1;\\n for (long long i = (l); i <= (r); ++i) fir[id[i]] = 0;\\n fir[S] = fir[T] = 0;\\n}\\ninline long long bfs(long long l, long long r) {\\n queue q;\\n d[S] = 0;\\n q.push(S);\\n for (long long i = (l); i <= (r); ++i) d[id[i]] = -1, cur[id[i]] = fir[id[i]];\\n d[T] = -1;\\n cur[S] = fir[S], cur[T] = fir[T];\\n while (!q.empty()) {\\n long long u = q.front();\\n q.pop();\\n for (long long i = fir[u], v; v = to[i], i; i = nxt[i])\\n if (fl[i] && d[v] == -1) q.push(v), d[v] = d[u] + 1;\\n }\\n return d[T] != -1;\\n}\\nlong long Dinic(long long u, long long flow) {\\n if (u == T) return flow;\\n long long rest = flow;\\n for (long long i = cur[u], v; v = to[i], (i && rest); i = nxt[i]) {\\n cur[u] = i;\\n if (fl[i] && d[v] == d[u] + 1) {\\n long long res = Dinic(v, min(rest, fl[i]));\\n fl[i] -= res, fl[i ^ 1] += res, rest -= res;\\n }\\n }\\n return flow - rest;\\n}\\nbool vis[N];\\ninline long long solve(long long l, long long r) {\\n for (long long i = (l); i <= (r); ++i) vis[id[i]] = 1;\\n for (long long i = (l); i <= (r); ++i)\\n for (it = G[id[i]].begin(); it != G[id[i]].end();)\\n if (vis[*it])\\n addflow(id[i], *it, INF), ++it;\\n else\\n itt = it, ++it, G[id[i]].erase(itt);\\n for (long long i = (l); i <= (r); ++i)\\n if (val[id[i]] >= 0)\\n addflow(S, id[i], val[id[i]]);\\n else\\n addflow(id[i], T, -val[id[i]]);\\n while...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"There are three sticks with integer lengths l_1, l_2 and l_3.\\n\\nYou are asked to break exactly one of them into two pieces in such a way that: \\n\\n * both pieces have positive (strictly greater than 0) integer length; \\n * the total length of the pieces is equal to the original length of the stick; \\n * it's possible to construct a rectangle from the resulting four sticks such that each stick is used as exactly one of its sides. \\n\\n\\n\\nA square is also considered a rectangle.\\n\\nDetermine if it's possible to do that.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.\\n\\nThe only line of each testcase contains three integers l_1, l_2, l_3 (1 ≤ l_i ≤ 10^8) — the lengths of the sticks.\\n\\nOutput\\n\\nFor each testcase, print \\\"YES\\\" if it's possible to break one of the sticks into two pieces with positive integer length in such a way that it's possible to construct a rectangle from the resulting four sticks. Otherwise, print \\\"NO\\\".\\n\\nYou may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES are all recognized as a positive answer).\\n\\nExample\\n\\nInput\\n\\n\\n4\\n6 1 5\\n2 5 2\\n2 4 2\\n5 5 4\\n\\n\\nOutput\\n\\n\\nYES\\nNO\\nYES\\nYES\\n\\nNote\\n\\nIn the first testcase, the first stick can be broken into parts of length 1 and 5. We can construct a rectangle with opposite sides of length 1 and 5.\\n\\nIn the second testcase, breaking the stick of length 2 can only result in sticks of lengths 1, 1, 2, 5, which can't be made into a rectangle. Breaking the stick of length 5 can produce results 2, 3 or 1, 4 but neither of them can't be put into a rectangle.\\n\\nIn the third testcase, the second stick can be broken into parts of length 2 and 2. The resulting rectangle has opposite sides 2 and 2 (which is a square).\\n\\nIn the fourth testcase, the third stick can be broken into parts of length 2 and 2. The resulting rectangle has opposite sides 2 and 5.\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nlong long int ar[500009], cr[500009], br[500009], vis[500009], dr[500009],\\n fact[500009];\\nmap mp, mp1;\\nvector v, v1;\\nstring s, q;\\nlong long int mod = 1e9 + 7;\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n ;\\n long long int a, b, c, d, e, i, j, k = 0, x, y, z, f, g, h, n, m, t, r;\\n cin >> t;\\n while (t--) {\\n cin >> a >> b >> c;\\n ar[1] = a;\\n ar[2] = b;\\n ar[3] = c;\\n sort(ar + 1, ar + 3 + 1);\\n k = 0;\\n if (ar[3] == (ar[1] + ar[2])) {\\n k = 1;\\n }\\n if (ar[1] == ar[2] and ar[3] % 2 == 0) {\\n k = 1;\\n }\\n if (ar[1] == ar[3] and ar[2] % 2 == 0) {\\n k = 1;\\n }\\n if (ar[3] == ar[2] and ar[1] % 2 == 0) {\\n k = 1;\\n }\\n if (k == 1) {\\n cout << \\\"YES\\\" << endl;\\n } else {\\n cout << \\\"NO\\\" << endl;\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"In 2028 and after a continuous growth, AtCoder Inc. finally built an empire with six cities (City 1, 2, 3, 4, 5, 6)!\\n\\nThere are five means of transport in this empire:\\n\\n* Train: travels from City 1 to 2 in one minute. A train can occupy at most A people.\\n* Bus: travels from City 2 to 3 in one minute. A bus can occupy at most B people.\\n* Taxi: travels from City 3 to 4 in one minute. A taxi can occupy at most C people.\\n* Airplane: travels from City 4 to 5 in one minute. An airplane can occupy at most D people.\\n* Ship: travels from City 5 to 6 in one minute. A ship can occupy at most E people.\\n\\n\\n\\nFor each of them, one vehicle leaves the city at each integer time (time 0, 1, 2, ...).\\n\\nThere is a group of N people at City 1, and they all want to go to City 6.\\nAt least how long does it take for all of them to reach there? You can ignore the time needed to transfer.\\n\\nConstraints\\n\\n* 1 \\\\leq N, A, B, C, D, E \\\\leq 10^{15}\\n* All values in input are integers.\\n\\nInput\\n\\nInput is given from Standard Input in the following format:\\n\\n\\nN\\nA\\nB\\nC\\nD\\nE\\n\\n\\nOutput\\n\\nPrint the minimum time required for all of the people to reach City 6, in minutes.\\n\\nExamples\\n\\nInput\\n\\n5\\n3\\n2\\n4\\n3\\n5\\n\\n\\nOutput\\n\\n7\\n\\n\\nInput\\n\\n10\\n123\\n123\\n123\\n123\\n123\\n\\n\\nOutput\\n\\n5\\n\\n\\nInput\\n\\n10000000007\\n2\\n3\\n5\\n7\\n11\\n\\n\\nOutput\\n\\n5000000008\\\":\",\"targets\":\"#include \\n\\nusing namespace std;\\n\\nint main() {\\n\\tlong long N, A, B, C, D, E;\\n\\tcin >> N >> A >> B >> C >> D >> E;\\n\\tcout << max({ (N - 1) \\/ A, (N - 1) \\/ B, (N - 1) \\/ C, (N - 1) \\/ D, (N - 1) \\/ E }) + 5;\\n\\treturn 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation.\\n\\nFind the total number of biscuits produced within T + 0.5 seconds after activation.\\n\\nConstraints\\n\\n* All values in input are integers.\\n* 1 \\\\leq A, B, T \\\\leq 20\\n\\nInput\\n\\nInput is given from Standard Input in the following format:\\n\\n\\nA B T\\n\\n\\nOutput\\n\\nPrint the total number of biscuits produced within T + 0.5 seconds after activation.\\n\\nExamples\\n\\nInput\\n\\n3 5 7\\n\\n\\nOutput\\n\\n10\\n\\n\\nInput\\n\\n3 2 9\\n\\n\\nOutput\\n\\n6\\n\\n\\nInput\\n\\n20 20 19\\n\\n\\nOutput\\n\\n0\",\"targets\":\"#include\\nusing namespace std;\\nint main(){\\n int a,b,c;\\n cin >> a >> b >> c;\\n cout << c\\/a*b << endl;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Monocarp is playing a computer game. Now he wants to complete the first level of this game.\\n\\nA level is a rectangular grid of 2 rows and n columns. Monocarp controls a character, which starts in cell (1, 1) — at the intersection of the 1-st row and the 1-st column.\\n\\nMonocarp's character can move from one cell to another in one step if the cells are adjacent by side and\\/or corner. Formally, it is possible to move from cell (x_1, y_1) to cell (x_2, y_2) in one step if |x_1 - x_2| ≤ 1 and |y_1 - y_2| ≤ 1. Obviously, it is prohibited to go outside the grid.\\n\\nThere are traps in some cells. If Monocarp's character finds himself in such a cell, he dies, and the game ends.\\n\\nTo complete a level, Monocarp's character should reach cell (2, n) — at the intersection of row 2 and column n.\\n\\nHelp Monocarp determine if it is possible to complete the level.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. Then the test cases follow. Each test case consists of three lines.\\n\\nThe first line contains a single integer n (3 ≤ n ≤ 100) — the number of columns.\\n\\nThe next two lines describe the level. The i-th of these lines describes the i-th line of the level — the line consists of the characters '0' and '1'. The character '0' corresponds to a safe cell, the character '1' corresponds to a trap cell.\\n\\nAdditional constraint on the input: cells (1, 1) and (2, n) are safe.\\n\\nOutput\\n\\nFor each test case, output YES if it is possible to complete the level, and NO otherwise.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n000\\n000\\n4\\n0011\\n1100\\n4\\n0111\\n1110\\n6\\n010101\\n101010\\n\\n\\nOutput\\n\\n\\nYES\\nYES\\nNO\\nYES\\n\\nNote\\n\\nConsider the example from the statement.\\n\\nIn the first test case, one of the possible paths is (1, 1) → (2, 2) → (2, 3).\\n\\nIn the second test case, one of the possible paths is (1, 1) → (1, 2) → (2, 3) → (2, 4).\\n\\nIn the fourth test case, one of the possible paths is (1, 1) → (2, 2) → (1, 3) → (2, 4) → (1, 5) → (2, 6).\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst int MAX = 1e5 + 5;\\nconst int MOD = 1e9 + 7;\\nint main() {\\n ios_base ::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n short int t, n, i;\\n cin >> t;\\n string x, y;\\n while (t--) {\\n cin >> n;\\n cin >> x;\\n cin >> y;\\n bool b = 1;\\n for (i = 0; i < n; i++) {\\n if (x[i] == '1' && y[i] == '1') {\\n b = 0;\\n break;\\n }\\n }\\n cout << ((b == 1) ? (\\\"YES\\\\n\\\") : (\\\"NO\\\\n\\\"));\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Amr lives in Lala Land. Lala Land is a very beautiful country that is located on a coordinate line. Lala Land is famous with its apple trees growing everywhere.\\n\\nLala Land has exactly n apple trees. Tree number i is located in a position xi and has ai apples growing on it. Amr wants to collect apples from the apple trees. Amr currently stands in x = 0 position. At the beginning, he can choose whether to go right or left. He'll continue in his direction until he meets an apple tree he didn't visit before. He'll take all of its apples and then reverse his direction, continue walking in this direction until he meets another apple tree he didn't visit before and so on. In the other words, Amr reverses his direction when visiting each new apple tree. Amr will stop collecting apples when there are no more trees he didn't visit in the direction he is facing.\\n\\nWhat is the maximum number of apples he can collect?\\n\\nInput\\n\\nThe first line contains one number n (1 ≤ n ≤ 100), the number of apple trees in Lala Land.\\n\\nThe following n lines contains two integers each xi, ai ( - 105 ≤ xi ≤ 105, xi ≠ 0, 1 ≤ ai ≤ 105), representing the position of the i-th tree and number of apples on it.\\n\\nIt's guaranteed that there is at most one apple tree at each coordinate. It's guaranteed that no tree grows in point 0.\\n\\nOutput\\n\\nOutput the maximum number of apples Amr can collect.\\n\\nExamples\\n\\nInput\\n\\n2\\n-1 5\\n1 5\\n\\n\\nOutput\\n\\n10\\n\\nInput\\n\\n3\\n-2 2\\n1 4\\n-1 3\\n\\n\\nOutput\\n\\n9\\n\\nInput\\n\\n3\\n1 9\\n3 5\\n7 10\\n\\n\\nOutput\\n\\n9\\n\\nNote\\n\\nIn the first sample test it doesn't matter if Amr chose at first to go left or right. In both cases he'll get all the apples.\\n\\nIn the second sample test the optimal solution is to go left to x = - 1, collect apples from there, then the direction will be reversed, Amr has to go to x = 1, collect apples from there, then the direction will be reversed and Amr goes to the final tree x = - 2.\\n\\nIn the third sample test the optimal solution is to go right to x = 1, collect apples from there, then the direction will be reversed and Amr will not be able...\",\"targets\":\"l = list()\\nr = list()\\nn = input()\\n\\nfor i in range(n):\\n x, a = map(int, raw_input().split())\\n if x < 0:\\n l.append((-x, a))\\n else:\\n r.append((x, a))\\n\\nl.sort()\\nr.sort()\\n\\nm = min(len(l), len(r)) + int(len(r) != len(l))\\nprint sum(map(lambda x: x[1], l[:m] + r[:m]))\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"In fact, the problems E1 and E2 do not have much in common. You should probably think of them as two separate problems.\\n\\nYou are given an integer array a[1 … n] = [a_1, a_2, …, a_n].\\n\\nLet us consider an empty [deque](https:\\/\\/tinyurl.com\\/pfeucbux) (double-ended queue). A deque is a data structure that supports adding elements to both the beginning and the end. So, if there are elements [3, 4, 4] currently in the deque, adding an element 1 to the beginning will produce the sequence [\\\\color{red}{1}, 3, 4, 4], and adding the same element to the end will produce [3, 4, 4, \\\\color{red}{1}].\\n\\nThe elements of the array are sequentially added to the initially empty deque, starting with a_1 and finishing with a_n. Before adding each element to the deque, you may choose whether to add it to the beginning or to the end.\\n\\nFor example, if we consider an array a = [3, 7, 5, 5], one of the possible sequences of actions looks like this: 1. | add 3 to the beginning of the deque: | deque has a sequence [\\\\color{red}{3}] in it; \\n---|---|--- \\n 2. | add 7 to the end of the deque: | deque has a sequence [3, \\\\color{red}{7}] in it; \\n 3. | add 5 to the end of the deque: | deque has a sequence [3, 7, \\\\color{red}{5}] in it; \\n 4. | add 5 to the beginning of the deque: | deque has a sequence [\\\\color{red}{5}, 3, 7, 5] in it; \\n \\nFind the minimal possible number of inversions in the deque after the whole array is processed. \\n\\nAn inversion in sequence d is a pair of indices (i, j) such that i < j and d_i > d_j. For example, the array d = [5, 3, 7, 5] has exactly two inversions — (1, 2) and (3, 4), since d_1 = 5 > 3 = d_2 and d_3 = 7 > 5 = d_4.\\n\\nInput\\n\\nThe first line contains an integer t (1 ≤ t ≤ 1000) — the number of test cases.\\n\\nThe next 2t lines contain descriptions of the test cases. \\n\\nThe first line of each test case description contains an integer n (1 ≤ n ≤ 2 ⋅ 10^5) — array size. The second line of the description contains n space-separated integers a_i (-10^9 ≤ a_i ≤ 10^9) — elements of the array.\\n\\nIt is...\\nUsing java can you solve the prior task?\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.File;\\nimport java.io.FileNotFoundException;\\nimport java.io.FileReader;\\nimport java.io.IOException;\\nimport java.io.InputStream;\\nimport java.io.InputStreamReader;\\nimport java.io.OutputStream;\\nimport java.io.PrintWriter;\\nimport java.util.ArrayList;\\nimport java.util.Arrays;\\nimport java.util.HashMap;\\nimport java.util.List;\\nimport java.util.Map;\\nimport java.util.StringTokenizer;\\nimport java.util.TreeSet;\\n\\n\\npublic class Main {\\n\\n\\tstatic class Task {\\n\\t\\t\\n\\t\\tint NN = 200005;\\n\\t\\tint MOD = 1000000007;\\n\\t\\tint INF = 2000000000;\\n\\t\\tlong INFINITY = (1L<<63)-1;\\n\\n\\t\\tclass Tuple {\\n\\t\\t\\tInteger [] ara;\\n\\t\\t\\tpublic Tuple(Integer... a) {\\n\\t\\t\\t\\tthis.ara = a;\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\t\\n\\t\\tpublic void solve(InputReader in, PrintWriter out) {\\n\\t\\t\\tint t = in.nextInt();\\n\\t\\t\\twhile(t-->0) {\\n\\t\\t\\t\\tint n = in.nextInt();\\n\\t\\t\\t\\tInteger [] a = new Integer[n];\\n\\t\\t\\t\\tfor(int i=0;i mp = new HashMap<>();\\n\\n\\t\\t\\tpublic BIT(Integer []a) {\\n\\t\\t\\t\\tInteger []b = Arrays.copyOf(a, a.length);\\n\\t\\t\\t\\tArrays.sort(b);\\n\\t\\t\\t\\tint val = 0;\\n\\t\\t\\t\\tfor(int i=0;i 0) {\\n\\t\\t\\t\\t\\tret += t[num];num-=num&-num;\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\treturn ret;\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\t\\n\\t}\\n\\t\\n\\tstatic void prepareIO(boolean isFileIO) {\\n\\t\\t\\/\\/long t1 = System.currentTimeMillis();\\n\\t\\tTask solver = new Task();\\n\\t\\t\\/\\/ Standard IO\\n\\t\\tif(!isFileIO) { \\n\\t\\t\\tInputStream inputStream =...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Mr. Chanek has a new game called Dropping Balls. Initially, Mr. Chanek has a grid a of size n × m\\n\\nEach cell (x,y) contains an integer a_{x,y} denoting the direction of how the ball will move.\\n\\n * a_{x,y}=1 — the ball will move to the right (the next cell is (x, y + 1)); \\n * a_{x,y}=2 — the ball will move to the bottom (the next cell is (x + 1, y)); \\n * a_{x,y}=3 — the ball will move to the left (the next cell is (x, y - 1)). \\n\\n\\n\\nEvery time a ball leaves a cell (x,y), the integer a_{x,y} will change to 2. Mr. Chanek will drop k balls sequentially, each starting from the first row, and on the c_1, c_2, ..., c_k-th (1 ≤ c_i ≤ m) columns.\\n\\nDetermine in which column each ball will end up in (position of the ball after leaving the grid).\\n\\nInput\\n\\nThe first line contains three integers n, m, and k (1 ≤ n, m ≤ 1000, 1 ≤ k ≤ 10^5) — the size of the grid and the number of balls dropped by Mr. Chanek.\\n\\nThe i-th of the next n lines contains m integers a_{i,1},a_{i,2},…,a_{i,m} (1 ≤ a_{i,j} ≤ 3). It will satisfy a_{i, 1} ≠ 3 and a_{i, m} ≠ 1.\\n\\nThe next line contains k integers c_1, c_2, …, c_k (1 ≤ c_i ≤ m) — the balls' column positions dropped by Mr. Chanek sequentially.\\n\\nOutput\\n\\nOutput k integers — the i-th integer denoting the column where the i-th ball will end.\\n\\nExamples\\n\\nInput\\n\\n\\n5 5 3\\n1 2 3 3 3\\n2 2 2 2 2\\n2 2 2 2 2\\n2 2 2 2 2\\n2 2 2 2 2\\n1 2 1\\n\\n\\nOutput\\n\\n\\n2 2 1 \\n\\n\\nInput\\n\\n\\n1 2 2\\n1 3\\n1 2\\n\\n\\nOutput\\n\\n\\n1 2 \\n\\nNote\\n\\nIn the first example, the first ball will drop as follows. Note that the cell (1, 1) will change direction to the bottom direction.\\n\\n\\n\\nThe second and third balls will drop as follows. \\n\\n\\n\\nAll balls will be dropped from the first row and on the c_1, c_2, ..., c_k-th columns respectively. A ball will stop dropping once it leaves the grid.\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n ios::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n int n, m, k;\\n cin >> n >> m >> k;\\n vector> a(n, vector(m));\\n vector up(m, n - 1), nxt(m), lst(m);\\n for (int i = 0; i < m; ++i) nxt[i] = i + 1, lst[i] = i - 1;\\n int f = 0;\\n auto upd = [&]() {\\n for (int i = f; i < m; i = nxt[i]) {\\n while (up[i] && a[up[i]][i] == 2) {\\n --up[i];\\n }\\n if (up[i] == -1) {\\n if (lst[i] != -1) nxt[lst[i]] = nxt[i];\\n if (nxt[i] != n) lst[nxt[i]] = lst[i];\\n if (i == f) f += 1;\\n }\\n }\\n };\\n for (int i = 0; i < n; ++i) {\\n for (int j = 0; j < m; ++j) {\\n cin >> a[i][j];\\n }\\n }\\n for (int i = 0; i < k; ++i) {\\n int y;\\n cin >> y;\\n --y;\\n int x = 0;\\n while (x < n) {\\n if (a[x][y] == 2) {\\n x += 1;\\n } else if (a[x][y] == 3) {\\n a[x][y] = 2;\\n y -= 1;\\n } else if (a[x][y] == 1) {\\n a[x][y] = 2;\\n y += 1;\\n }\\n if (x > up[y]) break;\\n }\\n upd();\\n cout << y + 1 << ' ';\\n }\\n cout << endl;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Ann has recently started commuting by subway. We know that a one ride subway ticket costs a rubles. Besides, Ann found out that she can buy a special ticket for m rides (she can buy it several times). It costs b rubles. Ann did the math; she will need to use subway n times. Help Ann, tell her what is the minimum sum of money she will have to spend to make n rides?\\n\\nInput\\n\\nThe single line contains four space-separated integers n, m, a, b (1 ≤ n, m, a, b ≤ 1000) — the number of rides Ann has planned, the number of rides covered by the m ride ticket, the price of a one ride ticket and the price of an m ride ticket. \\n\\nOutput\\n\\nPrint a single integer — the minimum sum in rubles that Ann will need to spend.\\n\\nExamples\\n\\nInput\\n\\n6 2 1 2\\n\\n\\nOutput\\n\\n6\\n\\n\\nInput\\n\\n5 2 2 3\\n\\n\\nOutput\\n\\n8\\n\\nNote\\n\\nIn the first sample one of the optimal solutions is: each time buy a one ride ticket. There are other optimal solutions. For example, buy three m ride tickets.\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"from sys import stdin\\nfrom collections import deque\\nfrom math import sqrt, floor, ceil, log, log2, log10, pi\\ndef ii(): return int(stdin.readline())\\ndef fi(): return float(stdin.readline())\\ndef mi(): return map(int, stdin.readline().split())\\ndef fmi(): return map(float, stdin.readline().split())\\ndef li(): return list(mi())\\ndef si(): return stdin.readline()\\nn, m, a, b=mi()\\np=n*a\\nq=(n\\/\\/m)*b+(n%m)*a\\nr=ceil(n\\/m)*b\\nprint(min(p, q, r))\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Polycarp doesn't like integers that are divisible by 3 or end with the digit 3 in their decimal representation. Integers that meet both conditions are disliked by Polycarp, too.\\n\\nPolycarp starts to write out the positive (greater than 0) integers which he likes: 1, 2, 4, 5, 7, 8, 10, 11, 14, 16, .... Output the k-th element of this sequence (the elements are numbered from 1).\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 100) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one line containing one integer k (1 ≤ k ≤ 1000).\\n\\nOutput\\n\\nFor each test case, output in a separate line one integer x — the k-th element of the sequence that was written out by Polycarp.\\n\\nExample\\n\\nInput\\n\\n\\n10\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n1000\\n\\n\\nOutput\\n\\n\\n1\\n2\\n4\\n5\\n7\\n8\\n10\\n11\\n14\\n1666\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.util.*;\\nimport java.lang.*;\\npublic class polyc\\n{\\n public static void main (String[]args)\\n {\\n ArrayListal=new ArrayList();\\n for(int i=1;i<2000;i++)\\n {\\n String a=String.valueOf(i);\\n if(i%3!=0 && a.charAt(a.length()-1)!='3')\\n al.add(i);\\n }\\n Scanner sc= new Scanner (System.in);\\n int n=sc.nextInt();\\n ArrayListal2=new ArrayList();\\n for(int i=0;iq_j should hold). \\n\\n\\n\\nAmong all valid permutations q find the one that has the smallest value of ∑_{i=1}^n |p_i-q_i|, where |x| is an absolute value of x.\\n\\nPrint the permutation q_1, q_2, ..., q_n. If there are multiple answers, you can print any of them.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.\\n\\nThe first line of each testcase contains a single integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of songs.\\n\\nThe second line of each testcase contains n integers p_1, p_2, ..., p_n (1 ≤ p_i ≤ n) — the permutation of the predicted ratings.\\n\\nThe third line contains a single string s, consisting of n characters. Each character is either a 0 or a 1. 0 means that Monocarp disliked the song, and 1 means that he liked it.\\n\\nThe sum of n over all testcases doesn't exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each testcase, print a permutation q — the re-evaluated ratings of the songs. If there are multiple answers such that ∑_{i=1}^n |p_i-q_i| is minimum possible, you can print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n2\\n1 2\\n10\\n3\\n3 1 2\\n111\\n8\\n2...\",\"targets\":\"t=int(input())\\nfor test in range(t):\\n n=int(input())\\n l=list(map(int,input().split()))\\n s=list(map(int,input()))\\n d={}\\n d1={}\\n z=0\\n for i in range(n):\\n d1[i+1]=0\\n if s[i]==0:\\n z+=1\\n d[l[i]]=s[i]\\n b=z+1\\n for i in range(1,z+1):\\n if d[i]==1:\\n while b<=n:\\n if d[b]==0:\\n d1[b]=i\\n d1[i]=b\\n b+=1\\n break\\n b+=1\\n else:\\n d1[i]=i\\n for i in range(z+1,n+1):\\n if d1[i]==0:\\n d1[i]=i\\n for i in l:\\n print(d1[i],end=\\\" \\\")\\n print()\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nA known chef has prepared n dishes: the i-th dish consists of a_i grams of fish and b_i grams of meat. \\n\\nThe banquet organizers estimate the balance of n dishes as follows. The balance is equal to the absolute value of the difference between the total mass of fish and the total mass of meat.\\n\\nTechnically, the balance equals to \\\\left|∑_{i=1}^n a_i - ∑_{i=1}^n b_i\\\\right|. The smaller the balance, the better.\\n\\nIn order to improve the balance, a taster was invited. He will eat exactly m grams of food from each dish. For each dish, the taster determines separately how much fish and how much meat he will eat. The only condition is that he should eat exactly m grams of each dish in total.\\n\\nDetermine how much of what type of food the taster should eat from each dish so that the value of the balance is as minimal as possible. If there are several correct answers, you may choose any of them.\\n\\nInput\\n\\nThe first line of input data contains an integer t (1 ≤ t ≤ 10^4) — the number of the test cases.\\n\\nEach test case's description is preceded by a blank line. Next comes a line that contains integers n and m (1 ≤ n ≤ 2 ⋅ 10^5; 0 ≤ m ≤ 10^6). The next n lines describe dishes, the i-th of them contains a pair of integers a_i and b_i (0 ≤ a_i, b_i ≤ 10^6) — the masses of fish and meat in the i-th dish.\\n\\nIt is guaranteed that it is possible to eat m grams of food from each dish. In other words, m ≤ a_i+b_i for all i from 1 to n inclusive.\\n\\nThe sum of all n values over all test cases in the test does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print on the first line the minimal balance value that can be achieved by eating exactly m grams of food from each dish.\\n\\nThen print n lines that describe a way to do this: the i-th line should contain two integers x_i and y_i (0 ≤ x_i ≤ a_i; 0 ≤ y_i ≤ b_i; x_i+y_i=m), where x_i is how many grams of fish taster should eat from the i-th meal and y_i is how many grams of meat.\\n\\nIf there are several ways to achieve a minimal balance, find any of them.\\n\\nExample\\n\\nInput\\n\\n\\n8\\n\\n1 5\\n3 4\\n\\n1 6\\n3...\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 2.1e5;\\nint lim[N], a[N], b[N];\\nint main() {\\n int t;\\n cin >> t;\\n while (t--) {\\n int n, m, i;\\n long long dl = 0, dr = 0;\\n cin >> n >> m;\\n for (i = 1; i <= n; i++) {\\n int x, y, l, r;\\n cin >> x >> y;\\n a[i] = min(x, m);\\n b[i] = m - a[i];\\n if (x <= m)\\n l = m - x - y;\\n else\\n l = x - m - y;\\n if (y <= m)\\n r = x - m + y;\\n else\\n r = x + m - y;\\n assert(l <= r);\\n lim[i] = r - l >> 1;\\n dl -= l;\\n dr += r - l;\\n }\\n if (dl >= 0 && dl <= dr) {\\n cout << (dl & 1) << '\\\\n';\\n dl >>= 1;\\n for (i = 1; i <= n; i++)\\n if (dl >= lim[i])\\n dl -= lim[i], cout << a[i] - lim[i] << ' ' << b[i] + lim[i] << '\\\\n';\\n else\\n cout << a[i] - dl << ' ' << b[i] + dl << '\\\\n', dl = 0;\\n } else if (dl < 0) {\\n cout << -dl << '\\\\n';\\n for (i = 1; i <= n; i++) cout << a[i] << ' ' << b[i] << '\\\\n';\\n } else {\\n cout << dl - dr << '\\\\n';\\n for (i = 1; i <= n; i++)\\n cout << a[i] - lim[i] << ' ' << b[i] + lim[i] << '\\\\n';\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"She does her utmost to flawlessly carry out a person's last rites and preserve the world's balance of yin and yang.\\n\\nHu Tao, being the little prankster she is, has tried to scare you with this graph problem! You are given a connected undirected graph of n nodes with m edges. You also have q queries. Each query consists of two nodes a and b.\\n\\nInitially, all edges in the graph have a weight of 0. For each query, you must choose a simple path starting from a and ending at b. Then you add 1 to every edge along this path. Determine if it's possible, after processing all q queries, for all edges in this graph to have an even weight. If so, output the choice of paths for each query. \\n\\nIf it is not possible, determine the smallest number of extra queries you could add to make it possible. It can be shown that this number will not exceed 10^{18} under the given constraints.\\n\\nA simple path is defined as any path that does not visit a node more than once.\\n\\nAn edge is said to have an even weight if its value is divisible by 2.\\n\\nInput\\n\\nThe first line contains two integers n and m (2 ≤ n ≤ 3 ⋅ 10^5, n-1 ≤ m ≤ min{\\\\left((n(n-1))\\/(2), 3 ⋅ 10^5\\\\right)}).\\n\\nEach of the next m lines contains two integers x and y (1 ≤ x, y ≤ n, x≠ y) indicating an undirected edge between node x and y. The input will not contain self-loops or duplicate edges, and the provided graph will be connected.\\n\\nThe next line contains a single integer q (1 ≤ q ≤ 3 ⋅ 10^5).\\n\\nEach of the next q lines contains two integers a and b (1 ≤ a, b ≤ n, a ≠ b), the description of each query.\\n\\nIt is guaranteed that nq ≤ 3 ⋅ 10^5.\\n\\nOutput\\n\\nIf it is possible to force all edge weights to be even, print \\\"YES\\\" on the first line, followed by 2q lines indicating the choice of path for each query in the same order the queries are given. For each query, the first line should contain a single integer x: the number of nodes in the chosen path. The next line should then contain x spaced separated integers p_i indicating the path you take (p_1 = a, p_x = b and all numbers should...\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nvector> g, sg;\\nvector vis;\\nvoid dfs(int u) {\\n vis[u] = 1;\\n for (int v : g[u]) {\\n if (!vis[v]) {\\n sg[u].push_back(v);\\n sg[v].push_back(u);\\n dfs(v);\\n }\\n }\\n}\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n int n, m;\\n cin >> n >> m;\\n g.resize(n);\\n sg.resize(n);\\n for (int i = 0; i < m; i++) {\\n int u, v;\\n cin >> u >> v;\\n u--;\\n v--;\\n g[u].push_back(v);\\n g[v].push_back(u);\\n }\\n vis.assign(n, 0);\\n dfs(0);\\n auto find_path = [&](int u, int v) {\\n swap(u, v);\\n queue qu;\\n vector p(n, -1);\\n vis.assign(n, 0);\\n vis[u] = 1;\\n qu.push(u);\\n while (!qu.empty()) {\\n int x = qu.front();\\n qu.pop();\\n for (int y : sg[x]) {\\n if (!vis[y]) {\\n vis[y] = 1;\\n qu.push(y);\\n p[y] = x;\\n }\\n }\\n }\\n vector ret;\\n for (int x = v; x != u; x = p[x]) {\\n ret.push_back(x);\\n }\\n ret.push_back(u);\\n return ret;\\n };\\n int q;\\n cin >> q;\\n vector> queries(q);\\n vector deg(n, 0);\\n vector> ans(q);\\n for (int i = 0; i < q; i++) {\\n int u, v;\\n cin >> u >> v;\\n u--;\\n v--;\\n deg[u]++;\\n deg[v]++;\\n queries[i] = {u, v};\\n ans[i] = find_path(u, v);\\n }\\n int cnt_odd = 0;\\n for (int u = 0; u < n; u++) cnt_odd += deg[u] % 2;\\n if (cnt_odd) {\\n cout << \\\"NO\\\\n\\\" << cnt_odd \\/ 2 << '\\\\n';\\n } else {\\n cout << \\\"YES\\\\n\\\";\\n for (auto v : ans) {\\n cout << v.size() << '\\\\n';\\n for (int x : v) cout << x + 1 << ' ';\\n cout << '\\\\n';\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.\\n\\nGiven a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it ak) and delete it, at that all elements equal to ak + 1 and ak - 1 also must be deleted from the sequence. That step brings ak points to the player. \\n\\nAlex is a perfectionist, so he decided to get as many points as possible. Help him.\\n\\nInput\\n\\nThe first line contains integer n (1 ≤ n ≤ 105) that shows how many numbers are in Alex's sequence. \\n\\nThe second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 105).\\n\\nOutput\\n\\nPrint a single integer — the maximum number of points that Alex can earn.\\n\\nExamples\\n\\nInput\\n\\n2\\n1 2\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n3\\n1 2 3\\n\\n\\nOutput\\n\\n4\\n\\n\\nInput\\n\\n9\\n1 2 1 3 2 2 2 2 3\\n\\n\\nOutput\\n\\n10\\n\\nNote\\n\\nConsider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points.\\\":\",\"targets\":\"#include \\nusing namespace std;\\nlong long int frequency[100001];\\nlong long int depth[100001];\\nlong long int boredom(long long int i) {\\n if (i == 0) return 0;\\n if (i == 1) return frequency[1];\\n if (depth[i] != -1) return depth[i];\\n depth[i] = max(boredom(i - 1), boredom(i - 2) + i * frequency[i]);\\n return depth[i];\\n}\\nint main() {\\n long long int cases, maximum = 0;\\n cin >> cases;\\n for (long long int i = 0; i < cases; i++) {\\n long long int integer;\\n cin >> integer;\\n maximum = max(maximum, integer);\\n frequency[integer]++;\\n }\\n memset(depth, -1, sizeof(depth));\\n cout << boredom(maximum);\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Alice and Borys are playing tennis.\\n\\nA tennis match consists of games. In each game, one of the players is serving and the other one is receiving.\\n\\nPlayers serve in turns: after a game where Alice is serving follows a game where Borys is serving, and vice versa.\\n\\nEach game ends with a victory of one of the players. If a game is won by the serving player, it's said that this player holds serve. If a game is won by the receiving player, it's said that this player breaks serve.\\n\\nIt is known that Alice won a games and Borys won b games during the match. It is unknown who served first and who won which games.\\n\\nFind all values of k such that exactly k breaks could happen during the match between Alice and Borys in total.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^3). Description of the test cases follows.\\n\\nEach of the next t lines describes one test case and contains two integers a and b (0 ≤ a, b ≤ 10^5; a + b > 0) — the number of games won by Alice and Borys, respectively.\\n\\nIt is guaranteed that the sum of a + b over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case print two lines.\\n\\nIn the first line, print a single integer m (1 ≤ m ≤ a + b + 1) — the number of values of k such that exactly k breaks could happen during the match.\\n\\nIn the second line, print m distinct integers k_1, k_2, …, k_m (0 ≤ k_1 < k_2 < … < k_m ≤ a + b) — the sought values of k in increasing order.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n2 1\\n1 1\\n0 5\\n\\n\\nOutput\\n\\n\\n4\\n0 1 2 3\\n2\\n0 2\\n2\\n2 3\\n\\nNote\\n\\nIn the first test case, any number of breaks between 0 and 3 could happen during the match: \\n\\n * Alice holds serve, Borys holds serve, Alice holds serve: 0 breaks; \\n * Borys holds serve, Alice holds serve, Alice breaks serve: 1 break; \\n * Borys breaks serve, Alice breaks serve, Alice holds serve: 2 breaks; \\n * Alice breaks serve, Borys breaks serve, Alice breaks serve: 3 breaks. \\n\\n\\n\\nIn the second test case, the players could either both hold serves (0 breaks) or both break serves (2...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nvoid solve() {\\n long long alice, bob;\\n cin >> alice >> bob;\\n long long n = alice + bob;\\n if (n == 1) {\\n cout << \\\"2\\\\n0 1\\\\n\\\";\\n return;\\n }\\n set ans;\\n {\\n long long a = alice;\\n long long b = bob;\\n long long p = min(a, b);\\n long long a_end = 1e9;\\n long long b_end = 1e9;\\n for (long long i = 1; i <= n; i++) {\\n if (i % 2) {\\n if (b) {\\n b--;\\n } else {\\n a--;\\n }\\n if (!b) {\\n b_end = min(b_end, i);\\n }\\n } else {\\n if (a) {\\n a--;\\n } else {\\n b--;\\n }\\n if (!a) {\\n a_end = min(a_end, i);\\n }\\n }\\n }\\n long long st = (n - 2 * p) \\/ 2 + (a_end < b_end && (n - 2 * p) % 2 == 1);\\n for (long long k = st; k <= st + 2 * p; k += 2) {\\n ans.insert(k);\\n }\\n }\\n {\\n long long a = alice;\\n long long b = bob;\\n long long p = min(a, b);\\n long long a_end = 1e9;\\n long long b_end = 1e9;\\n for (long long i = 1; i <= n; i++) {\\n if (!(i % 2)) {\\n if (b) {\\n b--;\\n } else {\\n a--;\\n }\\n if (!b) {\\n b_end = min(b_end, i);\\n }\\n } else {\\n if (a) {\\n a--;\\n } else {\\n b--;\\n }\\n if (!a) {\\n a_end = min(a_end, i);\\n }\\n }\\n }\\n long long st = (n - 2 * p) \\/ 2 + (a_end > b_end && (n - 2 * p) % 2 == 1);\\n for (long long k = st; k <= st + 2 * p; k += 2) {\\n ans.insert(k);\\n }\\n }\\n cout << ans.size() << '\\\\n';\\n for (auto& x : ans) {\\n cout << x << ' ';\\n }\\n cout << '\\\\n';\\n}\\nint main() {\\n long long t;\\n cin >> t;\\n while (t--) {\\n solve();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nAndryusha has found a perplexing arcade machine. The machine is a vertically adjusted board divided into square cells. The board has w columns numbered from 1 to w from left to right, and h rows numbered from 1 to h from the bottom to the top.\\n\\nFurther, there are barriers in some of board rows. There are n barriers in total, and i-th of them occupied the cells li through ri of the row ui. Andryusha recollects well that no two barriers share the same row. Furthermore, no row is completely occupied with a barrier, that is, at least one cell in each row is free.\\n\\nThe player can throw a marble to any column of the machine from above. A marble falls downwards until it encounters a barrier, or falls through the bottom of the board. A marble disappears once it encounters a barrier but is replaced by two more marbles immediately to the left and to the right of the same barrier. In a situation when the barrier is at an edge of the board, both marbles appear next to the barrier at the side opposite to the edge. More than one marble can occupy the same place of the board, without obstructing each other's movement. Ultimately, all marbles are bound to fall from the bottom of the machine.\\n\\n Examples of marble-barrier interaction.\\n\\nPeculiarly, sometimes marbles can go through barriers as if they were free cells. That is so because the barriers are in fact alive, and frightened when a marble was coming at them from a very high altitude. More specifically, if a marble falls towards the barrier i from relative height more than si (that is, it started its fall strictly higher than ui + si), then the barrier evades the marble. If a marble is thrown from the top of the board, it is considered to appear at height (h + 1).\\n\\nAndryusha remembers to have thrown a marble once in each of the columns. Help him find the total number of marbles that came down at the bottom of the machine. Since the answer may be large, print it modulo 109 + 7.\\n\\nInput\\n\\nThe first line contains three integers h, w, and n (1 ≤ h ≤ 109, 2 ≤ w ≤ 105, 0 ≤...\",\"targets\":\"#include \\nusing namespace std;\\ninline int read() {\\n int sum = 0;\\n char c = getchar();\\n bool f = 0;\\n while (c < '0' || c > '9') {\\n if (c == '-') f = 1;\\n c = getchar();\\n }\\n while (c >= '0' && c <= '9') {\\n sum = sum * 10 + c - '0';\\n c = getchar();\\n }\\n if (f) return -sum;\\n return sum;\\n}\\nconst int N = 100005;\\nconst int mod = 1000000007;\\nconst int orz = 2147483647;\\nint h, n, m;\\nstruct ex {\\n int u, l, r, s;\\n inline void init() { u = read(), l = read(), r = read(), s = read(); }\\n} za[N];\\ninline bool operator<(const ex &a, const ex &b) { return a.u > b.u; }\\nvector > t[N];\\nint mn[N * 4];\\nvector >::iterator it, ed;\\ninline void build(int p, int l, int r) {\\n mn[p] = h + 1;\\n if (l == r) {\\n t[l].push_back(make_pair(orz, 1));\\n t[l].push_back(make_pair(h + 1, 1));\\n return;\\n }\\n int mid = (l + r) >> 1;\\n build(p << 1, l, mid);\\n build(p << 1 | 1, mid + 1, r);\\n}\\nint U, lx, rx, S, inc;\\ninline void INIT(const ex &x) {\\n U = x.u;\\n lx = x.l;\\n rx = x.r;\\n S = x.s;\\n}\\ninline void up(int &x, int y) {\\n x += y;\\n if (x >= mod) x -= mod;\\n}\\ninline void ASK(int p, int l, int r) {\\n if (l == r) {\\n pair X;\\n while ((X = t[l].back()).first - U <= S) up(inc, X.second), t[l].pop_back();\\n mn[p] = t[l].back().first;\\n return;\\n }\\n if (mn[p] - U > S) return;\\n int mid = (l + r) >> 1;\\n ASK(p << 1, l, mid);\\n ASK(p << 1 | 1, mid + 1, r);\\n mn[p] = min(mn[p << 1], mn[p << 1 | 1]);\\n}\\ninline void ask(int p, int l, int r, int L, int R) {\\n if (mn[p] - U > S) return;\\n if (l == L && r == R) {\\n ASK(p, l, r);\\n return;\\n }\\n int mid = (l + r) >> 1;\\n if (R <= mid)\\n ask(p << 1, l, mid, L, R);\\n else if (L > mid)\\n ask(p << 1 | 1, mid + 1, r, L, R);\\n else\\n ask(p << 1, l, mid, L, mid), ask(p << 1 | 1, mid + 1, r, mid + 1, R);\\n mn[p] = min(mn[p << 1], mn[p << 1 | 1]);\\n}\\ninline void add(int p, int l, int r) {\\n if (l == r) {\\n t[l].push_back(make_pair(U, inc));\\n mn[p] = U;\\n return;\\n }\\n int mid = (l + r) >> 1;\\n if (S <= mid)\\n add(p...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"CQXYM wants to create a connected undirected graph with n nodes and m edges, and the diameter of the graph must be strictly less than k-1. Also, CQXYM doesn't want a graph that contains self-loops or multiple edges (i.e. each edge connects two different vertices and between each pair of vertices there is at most one edge).\\n\\nThe diameter of a graph is the maximum distance between any two nodes.\\n\\nThe distance between two nodes is the minimum number of the edges on the path which endpoints are the two nodes.\\n\\nCQXYM wonders whether it is possible to create such a graph.\\n\\nInput\\n\\nThe input consists of multiple test cases. \\n\\nThe first line contains an integer t (1 ≤ t ≤ 10^5) — the number of test cases. The description of the test cases follows.\\n\\nOnly one line of each test case contains three integers n(1 ≤ n ≤ 10^9), m, k (0 ≤ m,k ≤ 10^9).\\n\\nOutput\\n\\nFor each test case, print YES if it is possible to create the graph, or print NO if it is impossible. You can print each letter in any case (upper or lower).\\n\\nExample\\n\\nInput\\n\\n\\n5\\n1 0 3\\n4 5 3\\n4 6 3\\n5 4 1\\n2 1 1\\n\\n\\nOutput\\n\\n\\nYES\\nNO\\nYES\\nNO\\nNO\\n\\nNote\\n\\nIn the first test case, the graph's diameter equal to 0.\\n\\nIn the second test case, the graph's diameter can only be 2.\\n\\nIn the third test case, the graph's diameter can only be 1.\\\":\",\"targets\":\"import java.util.*;\\nimport java.lang.*;\\nimport java.io.*;\\n\\npublic final class Codechef{\\n\\tstatic class FastReader {\\n BufferedReader br;\\n StringTokenizer st;\\n \\n public FastReader()\\n {\\n br = new BufferedReader(\\n new InputStreamReader(System.in));\\n }\\n \\n String next()\\n {\\n while (st == null || !st.hasMoreElements()) {\\n try {\\n st = new StringTokenizer(br.readLine());\\n }\\n catch (IOException e) {\\n e.printStackTrace();\\n }\\n }\\n return st.nextToken();\\n }\\n \\n int nextInt() { return Integer.parseInt(next()); }\\n \\n long nextLong() { return Long.parseLong(next()); }\\n \\n double nextDouble()\\n {\\n return Double.parseDouble(next());\\n }\\n \\n String nextLine()\\n {\\n String str = \\\"\\\";\\n try {\\n str = br.readLine();\\n }\\n catch (IOException e) {\\n e.printStackTrace();\\n }\\n return str;\\n }\\n }\\n\\t\\n \\tpublic static void main(String[] args) throws java.lang.Exception{\\n \\t\\tFastReader sc = new FastReader();\\n \\t\\tint t=sc.nextInt(); \\t\\n \\t\\twhile(t-->0) {\\n \\t\\t\\tlong n=sc.nextLong(), m=sc.nextLong(), k=sc.nextLong();\\n \\t\\t\\tif(m=2) System.out.println(\\\"YES\\\");\\n \\t\\t\\telse {\\n \\t\\t\\t\\tif(m>n*(n-1)\\/2) System.out.println(\\\"NO\\\");\\n \\t\\t\\t\\telse if(k>=4) System.out.println(\\\"YES\\\");\\n \\t\\t\\t\\telse if(k>=3 && m==n*(n-1)\\/2) System.out.println(\\\"YES\\\");\\n \\t\\t\\t\\telse System.out.println(\\\"NO\\\");\\n \\t\\t\\t\\t}\\n \\t\\t\\n \\t\\t\\t}\\n \\t\\t}\\n \\t}\\n\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given an array consisting of all integers from [l, r] inclusive. For example, if l = 2 and r = 5, the array would be [2, 3, 4, 5]. What's the minimum number of elements you can delete to make the [bitwise AND](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#AND) of the array non-zero?\\n\\nA bitwise AND is a binary operation that takes two equal-length binary representations and performs the AND operation on each pair of the corresponding bits.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10^4) — the number of test cases. Then t cases follow.\\n\\nThe first line of each test case contains two integers l and r (1 ≤ l ≤ r ≤ 2 ⋅ 10^5) — the description of the array.\\n\\nOutput\\n\\nFor each test case, output a single integer — the answer to the problem.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n1 2\\n2 8\\n4 5\\n1 5\\n100000 200000\\n\\n\\nOutput\\n\\n\\n1\\n3\\n0\\n2\\n31072\\n\\nNote\\n\\nIn the first test case, the array is [1, 2]. Currently, the bitwise AND is 0, as 1\\\\ \\\\& \\\\ 2 = 0. However, after deleting 1 (or 2), the array becomes [2] (or [1]), and the bitwise AND becomes 2 (or 1). This can be proven to be the optimal, so the answer is 1.\\n\\nIn the second test case, the array is [2, 3, 4, 5, 6, 7, 8]. Currently, the bitwise AND is 0. However, after deleting 4, 5, and 8, the array becomes [2, 3, 6, 7], and the bitwise AND becomes 2. This can be proven to be the optimal, so the answer is 3. Note that there may be other ways to delete 3 elements.\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nlong long int power(long long int x, long long int y, long long int p) {\\n long long int res = 1;\\n while (y > 0) {\\n if (y & 1) res = ((res % p) * (x % p)) % p;\\n y = y >> 1;\\n x = ((x % p) * (x % p)) % p;\\n }\\n return res % p;\\n}\\nlong long int previouss[200005][31];\\nvoid precalculate() {\\n long long int N = 2e5 + 5;\\n for (long long int i = 1; i < N; i++) {\\n for (int j = 0; j <= 30; j++) {\\n if (i & (1 << j)) previouss[i][j] = 1;\\n previouss[i][j] += previouss[i - 1][j];\\n }\\n }\\n}\\nvoid solve() {\\n long long int n, m;\\n cin >> n >> m;\\n long long int total = m - n + 1;\\n long long int ans = 1e10;\\n for (int j = 0; j <= 30; j++) {\\n long long int curr = (previouss[m][j] - previouss[n - 1][j]);\\n ans = min(ans, total - curr);\\n }\\n cout << ans << endl;\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n precalculate();\\n int t = 1;\\n cin >> t;\\n while (t--) {\\n solve();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"This is the easy version of the problem. The difference between the versions is that the easy version does not require you to output the numbers of the rods to be removed. You can make hacks only if all versions of the problem are solved.\\n\\nStitch likes experimenting with different machines with his friend Sparky. Today they built another machine.\\n\\nThe main element of this machine are n rods arranged along one straight line and numbered from 1 to n inclusive. Each of these rods must carry an electric charge quantitatively equal to either 1 or -1 (otherwise the machine will not work). Another condition for this machine to work is that the sign-variable sum of the charge on all rods must be zero.\\n\\nMore formally, the rods can be represented as an array of n numbers characterizing the charge: either 1 or -1. Then the condition must hold: a_1 - a_2 + a_3 - a_4 + … = 0, or ∑_{i=1}^n (-1)^{i-1} ⋅ a_i = 0.\\n\\nSparky charged all n rods with an electric current, but unfortunately it happened that the rods were not charged correctly (the sign-variable sum of the charge is not zero). The friends decided to leave only some of the rods in the machine. Sparky has q questions. In the ith question Sparky asks: if the machine consisted only of rods with numbers l_i to r_i inclusive, what minimal number of rods could be removed from the machine so that the sign-variable sum of charges on the remaining ones would be zero? Perhaps the friends got something wrong, and the sign-variable sum is already zero. In that case, you don't have to remove the rods at all.\\n\\nIf the number of rods is zero, we will assume that the sign-variable sum of charges is zero, that is, we can always remove all rods.\\n\\nHelp your friends and answer all of Sparky's questions!\\n\\nInput\\n\\nEach test contains multiple test cases.\\n\\nThe first line contains one positive integer t (1 ≤ t ≤ 10^3), denoting the number of test cases. Description of the test cases follows.\\n\\nThe first line of each test case contains two positive integers n and q (1 ≤ n, q ≤ 3 ⋅ 10^5) — the...\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"#------------------------------------------ BEGIN FASTIO ------------------------------------------#\\n \\nimport os\\nimport sys\\nfrom io import BytesIO, IOBase\\n \\n \\n# region fastio\\n \\nBUFSIZE = 8192\\n \\n \\nclass FastIO(IOBase):\\n newlines = 0\\n \\n def __init__(self, file):\\n self._fd = file.fileno()\\n self.buffer = BytesIO()\\n self.writable = \\\"x\\\" in file.mode or \\\"r\\\" not in file.mode\\n self.write = self.buffer.write if self.writable else None\\n \\n def read(self):\\n while True:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n if not b:\\n break\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines = 0\\n return self.buffer.read()\\n \\n def readline(self):\\n while self.newlines == 0:\\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n self.newlines = b.count(b\\\"\\\\n\\\") + (not b)\\n ptr = self.buffer.tell()\\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\\n self.newlines -= 1\\n return self.buffer.readline()\\n \\n def flush(self):\\n if self.writable:\\n os.write(self._fd, self.buffer.getvalue())\\n self.buffer.truncate(0), self.buffer.seek(0)\\n \\n \\nclass IOWrapper(IOBase):\\n def __init__(self, file):\\n self.buffer = FastIO(file)\\n self.flush = self.buffer.flush\\n self.writable = self.buffer.writable\\n self.write = lambda s: self.buffer.write(s.encode(\\\"ascii\\\"))\\n self.read = lambda: self.buffer.read().decode(\\\"ascii\\\")\\n self.readline = lambda: self.buffer.readline().decode(\\\"ascii\\\")\\n \\n \\ndef print(*args, **kwargs):\\n \\\"\\\"\\\"Prints the values to a stream, or to sys.stdout by default.\\\"\\\"\\\"\\n sep, file = kwargs.pop(\\\"sep\\\", \\\" \\\"), kwargs.pop(\\\"file\\\", sys.stdout)\\n at_start = True\\n for x in args:\\n if not at_start:\\n file.write(sep)\\n file.write(str(x))\\n at_start = False\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nAlice has an integer sequence a of length n and all elements are different. She will choose a subsequence of a of length m, and defines the value of a subsequence a_{b_1},a_{b_2},…,a_{b_m} as $$$∑_{i = 1}^m (m ⋅ a_{b_i}) - ∑_{i = 1}^m ∑_{j = 1}^m f(min(b_i, b_j), max(b_i, b_j)), where f(i, j) denotes \\\\min(a_i, a_{i + 1}, \\\\ldots, a_j)$$$.\\n\\nAlice wants you to help her to maximize the value of the subsequence she choose.\\n\\nA sequence s is a subsequence of a sequence t if s can be obtained from t by deletion of several (possibly, zero or all) elements.\\n\\nInput\\n\\nThe first line contains two integers n and m (1 ≤ m ≤ n ≤ 4000).\\n\\nThe second line contains n distinct integers a_1, a_2, …, a_n (1 ≤ a_i < 2^{31}).\\n\\nOutput\\n\\nPrint the maximal value Alice can get.\\n\\nExamples\\n\\nInput\\n\\n\\n6 4\\n15 2 18 12 13 4\\n\\n\\nOutput\\n\\n\\n100\\n\\n\\nInput\\n\\n\\n11 5\\n9 3 7 1 8 12 10 20 15 18 5\\n\\n\\nOutput\\n\\n\\n176\\n\\n\\nInput\\n\\n\\n1 1\\n114514\\n\\n\\nOutput\\n\\n\\n0\\n\\n\\nInput\\n\\n\\n2 1\\n666 888\\n\\n\\nOutput\\n\\n\\n0\\n\\nNote\\n\\nIn the first example, Alice can choose the subsequence [15, 2, 18, 13], which has the value 4 ⋅ (15 + 2 + 18 + 13) - (15 + 2 + 2 + 2) - (2 + 2 + 2 + 2) - (2 + 2 + 18 + 12) - (2 + 2 + 12 + 13) = 100. In the second example, there are a variety of subsequences with value 176, and one of them is [9, 7, 12, 20, 18].\",\"targets\":\"#include \\nusing namespace std;\\ntemplate \\ninline void read(_T &x) {\\n x = 0;\\n long long f = 1;\\n char s = getchar();\\n while (s < '0' || s > '9') {\\n f = 1;\\n if (s == '-') f = -1;\\n s = getchar();\\n }\\n while ('0' <= s && s <= '9') {\\n x = (x << 3) + (x << 1) + s - '0';\\n s = getchar();\\n }\\n x *= f;\\n}\\nconst long long np = 1e5 + 5;\\nconst long long INF = 1 << 30;\\nlong long val[np];\\nlong long dp[4005][4005];\\nlong long ls[np], rs[np];\\nlong long sta[np], top;\\nlong long siz[np];\\nlong long n, m, tmp[np];\\ninline void dfs(long long x) {\\n dp[x][0] = 0;\\n dp[x][1] = m * val[x] - val[x];\\n siz[x] = 1;\\n if (!ls[x] && !rs[x]) return;\\n if (ls[x]) {\\n dfs(ls[x]);\\n for (long long i = 0; i <= siz[x] + siz[ls[x]]; i++) tmp[i] = 0;\\n for (long long i = 0; i <= siz[x]; i++) {\\n for (long long j = 0; j <= siz[ls[x]]; j++) {\\n tmp[i + j] =\\n max(tmp[i + j], dp[x][i] + dp[ls[x]][j] - val[x] * 2 * i * j);\\n }\\n }\\n siz[x] += siz[ls[x]];\\n for (long long i = 0; i <= siz[x]; i++) dp[x][i] = tmp[i];\\n }\\n if (rs[x]) {\\n dfs(rs[x]);\\n for (long long i = 0; i <= siz[x] + siz[rs[x]]; i++) tmp[i] = 0;\\n for (long long i = 0; i <= siz[x]; i++) {\\n for (long long j = 0; j <= siz[rs[x]]; j++) {\\n tmp[i + j] =\\n max(tmp[i + j], dp[x][i] + dp[rs[x]][j] - val[x] * 2 * i * j);\\n }\\n }\\n siz[x] += siz[rs[x]];\\n for (long long i = 0; i <= siz[x]; i++) dp[x][i] = tmp[i];\\n }\\n}\\nsigned main() {\\n dp[0][0] = 0;\\n read(n), read(m);\\n for (long long i = 1; i <= n; i++) read(val[i]);\\n for (long long i = 1; i <= n; i++) {\\n long long top_ = top;\\n while (top && val[sta[top]] > val[i]) top--;\\n if (top) rs[sta[top]] = i;\\n if (top < top_) ls[i] = sta[top + 1];\\n sta[++top] = i;\\n }\\n dfs(sta[1]);\\n printf(\\\"%lld\\\\n\\\", dp[sta[1]][m]);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"At regular competition Vladik and Valera won a and b candies respectively. Vladik offered 1 his candy to Valera. After that Valera gave Vladik 2 his candies, so that no one thought that he was less generous. Vladik for same reason gave 3 candies to Valera in next turn.\\n\\nMore formally, the guys take turns giving each other one candy more than they received in the previous turn.\\n\\nThis continued until the moment when one of them couldn’t give the right amount of candy. Candies, which guys got from each other, they don’t consider as their own. You need to know, who is the first who can’t give the right amount of candy.\\n\\nInput\\n\\nSingle line of input data contains two space-separated integers a, b (1 ≤ a, b ≤ 109) — number of Vladik and Valera candies respectively.\\n\\nOutput\\n\\nPring a single line \\\"Vladik’’ in case, if Vladik first who can’t give right amount of candy, or \\\"Valera’’ otherwise.\\n\\nExamples\\n\\nInput\\n\\n1 1\\n\\n\\nOutput\\n\\nValera\\n\\n\\nInput\\n\\n7 6\\n\\n\\nOutput\\n\\nVladik\\n\\nNote\\n\\nIllustration for first test case:\\n\\n\\n\\nIllustration for second test case:\\n\\n\",\"targets\":\"a , b = map(int, input().split())\\nfor i in range(1 , max(a,b) + 2):\\n if i % 2 == 0:\\n if i > b:\\n print(\\\"Valera\\\")\\n break\\n else: b -= i\\n else:\\n if i > a:\\n print(\\\"Vladik\\\")\\n break\\n else: a -= i\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Tanya is learning how to add numbers, but so far she is not doing it correctly. She is adding two numbers a and b using the following algorithm:\\n\\n 1. If one of the numbers is shorter than the other, Tanya adds leading zeros so that the numbers are the same length. \\n 2. The numbers are processed from right to left (that is, from the least significant digits to the most significant). \\n 3. In the first step, she adds the last digit of a to the last digit of b and writes their sum in the answer. \\n 4. At each next step, she performs the same operation on each pair of digits in the same place and writes the result to the left side of the answer. \\n\\n\\n\\nFor example, the numbers a = 17236 and b = 3465 Tanya adds up as follows:\\n\\n$$$ \\\\large{ \\\\begin{array}{r} + \\\\begin{array}{r} 17236\\\\\\\\\\\\ 03465\\\\\\\\\\\\ \\\\end{array} \\\\\\\\\\\\ \\\\hline \\\\begin{array}{r} 1106911 \\\\end{array} \\\\end{array}} $$$\\n\\n * calculates the sum of 6 + 5 = 11 and writes 11 in the answer. \\n * calculates the sum of 3 + 6 = 9 and writes the result to the left side of the answer to get 911. \\n * calculates the sum of 2 + 4 = 6 and writes the result to the left side of the answer to get 6911. \\n * calculates the sum of 7 + 3 = 10, and writes the result to the left side of the answer to get 106911. \\n * calculates the sum of 1 + 0 = 1 and writes the result to the left side of the answer and get 1106911. \\n\\n\\n\\nAs a result, she gets 1106911.\\n\\nYou are given two positive integers a and s. Find the number b such that by adding a and b as described above, Tanya will get s. Or determine that no suitable b exists.\\n\\nInput\\n\\nThe first line of input data contains an integer t (1 ≤ t ≤ 10^4) — the number of test cases.\\n\\nEach test case consists of a single line containing two positive integers a and s (1 ≤ a < s ≤ 10^{18}) separated by a space.\\n\\nOutput\\n\\nFor each test case print the answer on a separate line.\\n\\nIf the solution exists, print a single positive integer b. The answer must be written without leading zeros. If multiple answers exist, print any of them.\\n\\nIf no suitable number b...\",\"targets\":\"for i in range(int(input())):\\n a,s = map(int,input().split())\\n a = str(a)\\n s = str(s)\\n b = []\\n jud = 0\\n now = len(s)-1\\n for i in range(len(a)-1,-1,-1):\\n if now < 0:\\n jud = 1\\n break\\n if int(a[i]) > int(s[now]):\\n if now <= 0 or s[now-1] != \\\"1\\\":\\n jud = 1\\n break\\n b.append(10-(int(a[i])-int(s[now])))\\n now -= 2\\n else:\\n b.append(int(s[now])-int(a[i]))\\n now -= 1\\n \\n for i in range(now,-1,-1):\\n b.append(s[i])\\n n = len(b)\\n for i in range(n-1,-1,-1):\\n if b[i] == 0:\\n b.pop(-1)\\n else:\\n break\\n \\n if jud == 1:\\n print(-1)\\n else:\\n if b == []:\\n print(0)\\n else:\\n ans = \\\"\\\"\\n for i in range(len(b)-1):\\n ans+= str(b[-(i+1)])\\n ans += str(b[0])\\n print(int(ans))\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Casimir has a string s which consists of capital Latin letters 'A', 'B', and 'C' only. Each turn he can choose to do one of the two following actions:\\n\\n * he can either erase exactly one letter 'A' and exactly one letter 'B' from arbitrary places of the string (these letters don't have to be adjacent); \\n * or he can erase exactly one letter 'B' and exactly one letter 'C' from arbitrary places in the string (these letters don't have to be adjacent). \\n\\n\\n\\nTherefore, each turn the length of the string is decreased exactly by 2. All turns are independent so for each turn, Casimir can choose any of two possible actions.\\n\\nFor example, with s = \\\"ABCABC\\\" he can obtain a string s = \\\"ACBC\\\" in one turn (by erasing the first occurrence of 'B' and the second occurrence of 'A'). There are also many other options for a turn aside from this particular example.\\n\\nFor a given string s determine whether there is a sequence of actions leading to an empty string. In other words, Casimir's goal is to erase all letters from the string. Is there a way to do this?\\n\\nInput\\n\\nThe first line contains an integer t (1 ≤ t ≤ 1000) — the number of test cases.\\n\\nEach test case is described by one string s, for which you need to determine if it can be fully erased by some sequence of turns. The string s consists of capital letters 'A', 'B', 'C' and has a length from 1 to 50 letters, inclusive.\\n\\nOutput\\n\\nPrint t lines, each line containing the answer to the corresponding test case. The answer to a test case should be YES if there is a way to fully erase the corresponding string and NO otherwise.\\n\\nYou may print every letter in any case you want (so, for example, the strings yEs, yes, Yes, and YES will all be recognized as positive answers).\\n\\nExample\\n\\nInput\\n\\n\\n6\\nABACAB\\nABBA\\nAC\\nABC\\nCABCBB\\nBCBCBCBCBCBCBCBC\\n\\n\\nOutput\\n\\n\\nNO\\nYES\\nNO\\nNO\\nYES\\nYES\\nSolve the task in PYTHON3.\",\"targets\":\"import sys\\nreadline=sys.stdin.readline\\n\\nT=int(readline())\\nfor _ in range(T):\\n S=readline().rstrip()\\n A,B,C=0,0,0\\n for s in S:\\n if s==\\\"A\\\":\\n A+=1\\n elif s==\\\"B\\\":\\n B+=1\\n else:\\n C+=1\\n if A+C==B:\\n ans=\\\"YES\\\"\\n else:\\n ans=\\\"NO\\\"\\n print(ans)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Polycarp must pay exactly n burles at the checkout. He has coins of two nominal values: 1 burle and 2 burles. Polycarp likes both kinds of coins equally. So he doesn't want to pay with more coins of one type than with the other.\\n\\nThus, Polycarp wants to minimize the difference between the count of coins of 1 burle and 2 burles being used. Help him by determining two non-negative integer values c_1 and c_2 which are the number of coins of 1 burle and 2 burles, respectively, so that the total value of that number of coins is exactly n (i. e. c_1 + 2 ⋅ c_2 = n), and the absolute value of the difference between c_1 and c_2 is as little as possible (i. e. you must minimize |c_1-c_2|).\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10^4) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one line. This line contains one integer n (1 ≤ n ≤ 10^9) — the number of burles to be paid by Polycarp.\\n\\nOutput\\n\\nFor each test case, output a separate line containing two integers c_1 and c_2 (c_1, c_2 ≥ 0) separated by a space where c_1 is the number of coins of 1 burle and c_2 is the number of coins of 2 burles. If there are multiple optimal solutions, print any one.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n1000\\n30\\n1\\n32\\n1000000000\\n5\\n\\n\\nOutput\\n\\n\\n334 333\\n10 10\\n1 0\\n10 11\\n333333334 333333333\\n1 2\\n\\nNote\\n\\nThe answer for the first test case is \\\"334 333\\\". The sum of the nominal values of all coins is 334 ⋅ 1 + 333 ⋅ 2 = 1000, whereas |334 - 333| = 1. One can't get the better value because if |c_1 - c_2| = 0, then c_1 = c_2 and c_1 ⋅ 1 + c_1 ⋅ 2 = 1000, but then the value of c_1 isn't an integer.\\n\\nThe answer for the second test case is \\\"10 10\\\". The sum of the nominal values is 10 ⋅ 1 + 10 ⋅ 2 = 30 and |10 - 10| = 0, whereas there's no number having an absolute value less than 0.\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nvoid solve() {\\n long long n;\\n cin >> n;\\n if (n % 3 == 0) {\\n cout << n \\/ 3 << ' ' << n \\/ 3;\\n cout << '\\\\n';\\n return;\\n }\\n if (n % 3 == 2) {\\n cout << n \\/ 3 << ' ' << n \\/ 3 + 1;\\n cout << '\\\\n';\\n return;\\n }\\n cout << n \\/ 3 + 1 << ' ' << n \\/ 3;\\n cout << '\\\\n';\\n}\\nsigned main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n long long _ = 1;\\n cin >> _;\\n for (long long i = 1; i <= _; i++) {\\n solve();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"There are three sticks with integer lengths l_1, l_2 and l_3.\\n\\nYou are asked to break exactly one of them into two pieces in such a way that: \\n\\n * both pieces have positive (strictly greater than 0) integer length; \\n * the total length of the pieces is equal to the original length of the stick; \\n * it's possible to construct a rectangle from the resulting four sticks such that each stick is used as exactly one of its sides. \\n\\n\\n\\nA square is also considered a rectangle.\\n\\nDetermine if it's possible to do that.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.\\n\\nThe only line of each testcase contains three integers l_1, l_2, l_3 (1 ≤ l_i ≤ 10^8) — the lengths of the sticks.\\n\\nOutput\\n\\nFor each testcase, print \\\"YES\\\" if it's possible to break one of the sticks into two pieces with positive integer length in such a way that it's possible to construct a rectangle from the resulting four sticks. Otherwise, print \\\"NO\\\".\\n\\nYou may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES are all recognized as a positive answer).\\n\\nExample\\n\\nInput\\n\\n\\n4\\n6 1 5\\n2 5 2\\n2 4 2\\n5 5 4\\n\\n\\nOutput\\n\\n\\nYES\\nNO\\nYES\\nYES\\n\\nNote\\n\\nIn the first testcase, the first stick can be broken into parts of length 1 and 5. We can construct a rectangle with opposite sides of length 1 and 5.\\n\\nIn the second testcase, breaking the stick of length 2 can only result in sticks of lengths 1, 1, 2, 5, which can't be made into a rectangle. Breaking the stick of length 5 can produce results 2, 3 or 1, 4 but neither of them can't be put into a rectangle.\\n\\nIn the third testcase, the second stick can be broken into parts of length 2 and 2. The resulting rectangle has opposite sides 2 and 2 (which is a square).\\n\\nIn the fourth testcase, the third stick can be broken into parts of length 2 and 2. The resulting rectangle has opposite sides 2 and 5.\\\":\",\"targets\":\"import java.util.Arrays;\\nimport java.util.Scanner;\\n\\npublic class ProblemA {\\n\\n\\tpublic static void main(String[] args) {\\n\\t\\tScanner sc = new Scanner(System.in);\\n\\t\\tint t = sc.nextInt();\\n\\t\\tlong[][] arr = new long[t][3];\\n\\n\\t\\tfor(int i=0;i\\nvoid testcase() {\\n int n;\\n std::cin >> n;\\n std::vector a(n, 0);\\n for (auto &x : a) {\\n std::cin >> x;\\n }\\n unsigned long long tot = 0;\\n for (const auto &x : a) {\\n tot += x;\\n }\\n unsigned long long ans = 0;\\n std::map counts;\\n for (const auto &x : a) {\\n ans += counts[2 * tot - n * x];\\n counts[n * x] += 1;\\n }\\n std::cout << ans << std::endl;\\n}\\nint main() {\\n int t;\\n std::cin >> t;\\n for (int i = 0; i < t; ++i) {\\n testcase();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alice is playing with some stones.\\n\\nNow there are three numbered heaps of stones. The first of them contains a stones, the second of them contains b stones and the third of them contains c stones.\\n\\nEach time she can do one of two operations:\\n\\n 1. take one stone from the first heap and two stones from the second heap (this operation can be done only if the first heap contains at least one stone and the second heap contains at least two stones); \\n 2. take one stone from the second heap and two stones from the third heap (this operation can be done only if the second heap contains at least one stone and the third heap contains at least two stones). \\n\\n\\n\\nShe wants to get the maximum number of stones, but she doesn't know what to do. Initially, she has 0 stones. Can you help her?\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 100) — the number of test cases. Next t lines describe test cases in the following format:\\n\\nLine contains three non-negative integers a, b and c, separated by spaces (0 ≤ a,b,c ≤ 100) — the number of stones in the first, the second and the third heap, respectively.\\n\\nIn hacks it is allowed to use only one test case in the input, so t = 1 should be satisfied.\\n\\nOutput\\n\\nPrint t lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer — the maximum possible number of stones that Alice can take after making some operations. \\n\\nExample\\n\\nInput\\n\\n\\n3\\n3 4 5\\n1 0 5\\n5 3 2\\n\\n\\nOutput\\n\\n\\n9\\n0\\n6\\n\\nNote\\n\\nFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones, that Alice will take is 9. It is impossible to make some operations to take more than 9 stones, so the answer is 9.\\ndef f\",\"targets\":\"1(a, b, c):\\n res = 0\\n d= min(b, c \\/\\/ 2)\\n res += 3 * d\\n b -= d\\n res += min(a, b \\/\\/ 2) * 3\\n return res\\n\\ndef f2(a, b, c):\\n res = 0\\n d = min(a, b \\/\\/ 2)\\n res += 3 * d\\n b -= 2 * d\\n res += min(b, c \\/\\/ 2) * 3\\n return res\\n\\n\\nt = int(input())\\nfor i in range(t):\\n a, b, c = map(int, input().split())\\n print(max(f1(a, b, c), f2(a, b, c)))\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nA total of n depots are located on a number line. Depot i lies at the point x_i for 1 ≤ i ≤ n.\\n\\nYou are a salesman with n bags of goods, attempting to deliver one bag to each of the n depots. You and the n bags are initially at the origin 0. You can carry up to k bags at a time. You must collect the required number of goods from the origin, deliver them to the respective depots, and then return to the origin to collect your next batch of goods.\\n\\nCalculate the minimum distance you need to cover to deliver all the bags of goods to the depots. You do not have to return to the origin after you have delivered all the bags.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10 500). Description of the test cases follows.\\n\\nThe first line of each test case contains two integers n and k (1 ≤ k ≤ n ≤ 2 ⋅ 10^5).\\n\\nThe second line of each test case contains n integers x_1, x_2, …, x_n (-10^9 ≤ x_i ≤ 10^9). It is possible that some depots share the same position.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, output a single integer denoting the minimum distance you need to cover to deliver all the bags of goods to the depots. \\n\\nExample\\n\\nInput\\n\\n\\n4\\n5 1\\n1 2 3 4 5\\n9 3\\n-5 -10 -15 6 5 8 3 7 4\\n5 3\\n2 2 3 3 3\\n4 2\\n1000000000 1000000000 1000000000 1000000000\\n\\n\\nOutput\\n\\n\\n25\\n41\\n7\\n3000000000\\n\\nNote\\n\\nIn the first test case, you can carry only one bag at a time. Thus, the following is a solution sequence that gives a minimum travel distance: 0 → 2 → 0 → 4 → 0 → 3 → 0 → 1 → 0 → 5, where each 0 means you go the origin and grab one bag, and each positive integer means you deliver the bag to a depot at this coordinate, giving a total distance of 25 units. It must be noted that there are other sequences that give the same distance.\\n\\nIn the second test case, you can follow the following sequence, among multiple such sequences, to travel minimum distance: 0 → 6 → 8 → 7 → 0 → 5 → 4 → 3 → 0 → (-5) → (-10) → (-15), with distance...\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\n\\npublic class Main {\\n\\tstatic class FastReader {\\n\\t\\tBufferedReader br;\\n\\t\\tStringTokenizer st;\\n\\n\\t\\tpublic FastReader() {\\n\\t\\t\\tbr = new BufferedReader(new InputStreamReader(System.in));\\n\\t\\t}\\n\\n\\t\\tString next() {\\n\\t\\t\\twhile (st == null || !st.hasMoreElements()) {\\n\\t\\t\\t\\ttry {\\n\\t\\t\\t\\t\\tst = new StringTokenizer(br.readLine());\\n\\t\\t\\t\\t} catch (IOException e) {\\n\\t\\t\\t\\t\\te.printStackTrace();\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\treturn st.nextToken();\\n\\t\\t}\\n\\n\\t\\tint nextInt() {\\n\\t\\t\\treturn Integer.parseInt(next());\\n\\t\\t}\\n\\n\\t\\tlong nextLong() {\\n\\t\\t\\treturn Long.parseLong(next());\\n\\t\\t}\\n\\n\\t\\tdouble nextDouble() {\\n\\t\\t\\treturn Double.parseDouble(next());\\n\\t\\t}\\n\\n\\t\\tString nextLine() {\\n\\t\\t\\tString str = \\\"\\\";\\n\\t\\t\\ttry {\\n\\t\\t\\t\\tstr = br.readLine();\\n\\t\\t\\t} catch (IOException e) {\\n\\t\\t\\t\\te.printStackTrace();\\n\\t\\t\\t}\\n\\t\\t\\treturn str;\\n\\t\\t}\\n\\t}\\n\\n\\tpublic static void main(String[] args) {\\n\\t\\tFastReader obj = new FastReader();\\n\\t\\tPrintWriter out = new PrintWriter(System.out);\\n\\t\\tint len = obj.nextInt();\\n\\t\\twhile (len-- != 0) {\\n\\t\\t\\tint n = obj.nextInt();\\n\\t\\t\\tint k=obj.nextInt();\\n\\t\\t\\tLong[] num=new Long[n];\\n\\t\\t\\tVector pos=new Vector<>();\\n\\t\\t\\tVector neg=new Vector<>();\\n\\t\\t\\tfor(int i=0;i0)pos.add(num[i]);\\n\\t\\t\\t\\telse if(num[i]<0)neg.add(Math.abs(num[i]));\\n\\t\\t\\t}\\n\\t\\t\\tCollections.sort(pos,Collections.reverseOrder());\\n\\t\\t\\tCollections.sort(neg,Collections.reverseOrder());\\n\\t\\t\\tlong ans=0;\\n\\t\\t\\tint i=0;\\n\\t\\t\\tfor(i=0;i=1 && neg.size()==0)ans-=pos.get(0);\\t\\t\\n\\t\\t\\t else if(pos.size()==0 && neg.size()>=1)ans-=neg.get(0);\\n\\t\\t\\t else ans-=Math.max(pos.get(0),neg.get(0));\\n\\t\\t\\t out.println(ans);\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\tout.flush();\\n\\t}\\n\\t\\/\\/Cover the small test cases like for n=1 .\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Dima has a hamsters farm. Soon N hamsters will grow up on it and Dima will sell them in a city nearby.\\n\\nHamsters should be transported in boxes. If some box is not completely full, the hamsters in it are bored, that's why each box should be completely full with hamsters.\\n\\nDima can buy boxes at a factory. The factory produces boxes of K kinds, boxes of the i-th kind can contain in themselves ai hamsters. Dima can buy any amount of boxes, but he should buy boxes of only one kind to get a wholesale discount.\\n\\nOf course, Dima would buy boxes in such a way that each box can be completely filled with hamsters and transported to the city. If there is no place for some hamsters, Dima will leave them on the farm.\\n\\nFind out how many boxes and of which type should Dima buy to transport maximum number of hamsters.\\n\\nInput\\n\\nThe first line contains two integers N and K (0 ≤ N ≤ 1018, 1 ≤ K ≤ 105) — the number of hamsters that will grow up on Dima's farm and the number of types of boxes that the factory produces.\\n\\nThe second line contains K integers a1, a2, ..., aK (1 ≤ ai ≤ 1018 for all i) — the capacities of boxes.\\n\\nOutput\\n\\nOutput two integers: the type of boxes that Dima should buy and the number of boxes of that type Dima should buy. Types of boxes are numbered from 1 to K in the order they are given in input.\\n\\nIf there are many correct answers, output any of them.\\n\\nExamples\\n\\nInput\\n\\n19 3\\n5 4 10\\n\\n\\nOutput\\n\\n2 4\\n\\n\\nInput\\n\\n28 3\\n5 6 30\\n\\n\\nOutput\\n\\n1 5\\\":\",\"targets\":\"#include \\nint main() {\\n long long m, n, i, sum, temp, max = 0, index = 0, num = 0;\\n scanf(\\\"%lld%lld\\\", &m, &n);\\n for (long long i = 1; i <= n; i++) {\\n scanf(\\\"%lld\\\", &temp);\\n sum = (m \\/ temp) * temp;\\n if (sum >= max) {\\n max = sum;\\n index = i;\\n num = m \\/ temp;\\n }\\n }\\n printf(\\\"%lld %lld\\\\n\\\", index, num);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A team quiz game called \\\"What? Where? When?\\\" is very popular in Berland. The game is centered on two teams competing. They are the team of six Experts versus the team of the Audience. A person from the audience asks a question and the experts are allowed a minute on brainstorming and finding the right answer to the question. All it takes to answer a typical question is general knowledge and common logic. The question sent be the audience are in envelops lain out in a circle on a round table. Each envelop is marked by the name of the asker's town. Each question is positioned in a separate sector. In the centre of the table is a spinning arrow. Thus, the table rather resembles a roulette table with no ball but with a spinning arrow instead. The host sets off the spinning arrow to choose a question for the experts: when the arrow stops spinning, the question it is pointing at is chosen. If the arrow points at the question that has already been asked, the host chooses the next unanswered question in the clockwise direction. Your task is to determine which will be the number of the next asked question if the arrow points at sector number k.\\n\\nInput\\n\\nThe first line contains two positive integers n and k (1 ≤ n ≤ 1000 and 1 ≤ k ≤ n) — the numbers of sectors on the table and the number of the sector where the arrow is pointing. The second line contains n numbers: ai = 0 if the question from sector i has already been asked and ai = 1 if the question from sector i hasn't been asked yet (1 ≤ i ≤ n). The sectors are given in the clockwise order, the first sector follows after the n-th one.\\n\\nOutput\\n\\nPrint the single number — the number of the sector containing the question the experts will be asked. It is guaranteed that the answer exists, that is that not all the questions have already been asked.\\n\\nExamples\\n\\nInput\\n\\n5 5\\n0 1 0 1 0\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n2 1\\n1 1\\n\\n\\nOutput\\n\\n1\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.io.File;\\nimport java.io.FileReader;\\nimport java.io.IOException;\\nimport java.io.PrintWriter;\\nimport java.util.Scanner;\\n\\npublic class Solution {\\n public static void main(String[] args) throws IOException {\\n Scanner scanner = new Scanner(new FileReader(\\\"input.txt\\\"));\\n PrintWriter writer = new PrintWriter(new File(\\\"output.txt\\\"));\\n\\n int n = scanner.nextInt();\\n int k = scanner.nextInt();\\n scanner.nextLine();\\n\\n int[] array = new int[n];\\n for (int i = 0; i < n; i++) {\\n array[i] = scanner.nextInt();\\n }\\n\\n\\n int i = k - 1;\\n for (int j = 0; j < n; j++) {\\n if (i == n) {\\n i = 0;\\n }\\n\\n if (array[i++] == 1) {\\n writer.print(i);\\n break;\\n }\\n }\\n\\n writer.close();\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given an array a consisting of n positive integers. You have to choose a positive integer d and paint all elements into two colors. All elements which are divisible by d will be painted red, and all other elements will be painted blue.\\n\\nThe coloring is called beautiful if there are no pairs of adjacent elements with the same color in the array. Your task is to find any value of d which yields a beautiful coloring, or report that it is impossible.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of testcases.\\n\\nThe first line of each testcase contains one integer n (2 ≤ n ≤ 100) — the number of elements of the array.\\n\\nThe second line of each testcase contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^{18}).\\n\\nOutput\\n\\nFor each testcase print a single integer. If there is no such value of d that yields a beautiful coloring, print 0. Otherwise, print any suitable value of d (1 ≤ d ≤ 10^{18}).\\n\\nExample\\n\\nInput\\n\\n\\n5\\n5\\n1 2 3 4 5\\n3\\n10 5 15\\n3\\n100 10 200\\n10\\n9 8 2 6 6 2 8 6 5 4\\n2\\n1 3\\n\\n\\nOutput\\n\\n\\n2\\n0\\n100\\n0\\n3\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"import math\\n\\n\\ndef gcd_many(s):\\n g = 0\\n for i in range(len(s)):\\n if i == 0:\\n g = s[i]\\n else:\\n g=math.gcd(g,s[i])\\n return g\\nmm = int(input())\\nfor i in range(mm):\\n le = int(input())\\n lst = list(map(int,input().split()))\\n ou = lst[1:len(lst):2]\\n ji = lst[0:len(lst):2]\\n a = gcd_many(ji)\\n flag = 0\\n for l in ou:\\n if l%a == 0:\\n flag = 1\\n break\\n if flag == 0:\\n print(a)\\n else:\\n b = gcd_many(ou)\\n for l in ji:\\n if l%b == 0:\\n flag = 0\\n break\\n if flag == 1:\\n print(b)\\n else:\\n print(0)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given three integers n, a, b. Determine if there exists a permutation p_1, p_2, …, p_n of integers from 1 to n, such that:\\n\\n * There are exactly a integers i with 2 ≤ i ≤ n-1 such that p_{i-1} < p_i > p_{i+1} (in other words, there are exactly a local maximums).\\n\\n * There are exactly b integers i with 2 ≤ i ≤ n-1 such that p_{i-1} > p_i < p_{i+1} (in other words, there are exactly b local minimums).\\n\\n\\n\\n\\nIf such permutations exist, find any such permutation.\\n\\nInput\\n\\nThe first line of the input contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. The description of test cases follows.\\n\\nThe only line of each test case contains three integers n, a and b (2 ≤ n ≤ 10^5, 0 ≤ a,b ≤ n).\\n\\nThe sum of n over all test cases doesn't exceed 10^5.\\n\\nOutput\\n\\nFor each test case, if there is no permutation with the requested properties, output -1.\\n\\nOtherwise, print the permutation that you are found. If there are several such permutations, you may print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n4 1 1\\n6 1 2\\n6 4 0\\n\\n\\nOutput\\n\\n\\n1 3 2 4\\n4 2 3 1 5 6\\n-1\\n\\nNote\\n\\nIn the first test case, one example of such permutations is [1, 3, 2, 4]. In it p_1 < p_2 > p_3, and 2 is the only such index, and p_2> p_3 < p_4, and 3 the only such index.\\n\\nOne can show that there is no such permutation for the third test case.\\nSolve the task in JAVA.\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\nimport java.math.*;\\n\\npublic class test {\\n\\tstatic StringBuilder sb;\\n\\tstatic long fact[];\\n\\tstatic int mod = (int) (1e9 + 7);\\n\\n\\tstatic class Pair implements Comparable {\\n\\t\\tint x;\\n\\t\\tint y;\\n\\n\\t\\tPair(int x, int y) {\\n\\t\\t\\tthis.x = x;\\n\\t\\t\\tthis.y = y;\\n\\t\\t}\\n\\n\\t\\tpublic int compareTo(Pair o) {\\n\\t\\t\\treturn (int) (this.y - o.y);\\n\\t\\t}\\n\\t}\\n\\n\\/\\/\\tstatic void solve() {\\n\\/\\/\\t\\tint N = i();\\n\\/\\/\\t\\tint[] arr1 = readArray(N);\\n\\/\\/\\t\\tint[] arr = new int[N + 1];\\n\\/\\/\\t\\tfor (int i = 1; i <= N; i++) {\\n\\/\\/\\t\\t\\tarr[i] = arr1[i - 1];\\n\\/\\/\\t\\t}\\n\\/\\/\\t\\t\\n\\/\\/\\t\\tfenwicktree(arr);\\n\\/\\/\\n\\/\\/\\t\\tint Q = i();\\n\\/\\/\\t\\tfor (int i = 0; i < Q; i++) {\\n\\/\\/\\t\\t\\tString s = s();\\n\\/\\/\\t\\t\\tif (s.equals(\\\"q\\\")) {\\n\\/\\/\\t\\t\\t\\tint l = i();\\n\\/\\/\\t\\t\\t\\tint r = i();\\n\\/\\/\\t\\t\\t\\tlong val = query(l, r);\\n\\/\\/\\t\\t\\t\\tsb.append(val + \\\"\\\\n\\\");\\n\\/\\/\\t\\t\\t} else {\\n\\/\\/\\t\\t\\t\\tint idx = i();\\n\\/\\/\\t\\t\\t\\tint delta = i();\\n\\/\\/\\t\\t\\t\\tarr[idx] += delta;\\n\\/\\/\\t\\t\\t\\tupdate(idx, delta);\\n\\/\\/\\t\\t\\t}\\n\\/\\/\\t\\t}\\n\\/\\/\\t}\\n\\t\\n\\tstatic void solve() {\\n\\t\\tint n = i();\\n\\t\\tint a = i();\\n\\t\\tint b = i();\\n\\t\\t\\n\\t\\tif (Math.abs(a-b) > 1 || (a+b) > n-2) {\\n System.out.println(-1);\\n return;\\n }\\n \\n int count = 0 ;\\n \\n if (a > b) {\\n \\tSystem.out.print(1 + \\\" \\\") ;\\n int high = n, low = 2 ;\\n for (int i = 0 ; i < b ; i++)\\n {\\n \\tSystem.out.print(high + \\\" \\\");\\n \\tSystem.out.print(low + \\\" \\\");\\n high--;\\n low++ ;\\n }\\n \\n for (; high >= low; high--) System.out.print(high + \\\" \\\") ;\\n }\\n \\n else if (a < b)\\n {\\n \\tSystem.out.print(n + \\\" \\\");\\n int high = n-1, low = 1 ;\\n \\n for (int i = 0 ; i < a ; i++)\\n {\\n \\tSystem.out.print(low+\\\" \\\"+ high + \\\" \\\");\\n low++ ; high-- ;\\n }\\n for (; low <= high; low++) System.out.print(low+ \\\" \\\");\\n }\\n else {\\n \\tSystem.out.print(1 + \\\" \\\");\\n int high = n, low = 2 ;\\n for (int i = 0 ; i < b ; i++)\\n {\\n \\tSystem.out.print(high + \\\" \\\");\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Berland is a tourist country! At least, it can become such — the government of Berland is confident about this. \\n\\nThere are n cities in Berland, some pairs of which are connected by two-ways roads. Each road connects two different cities. In Berland there are no roads which connect the same pair of cities. It is possible to get from any city to any other city using given two-ways roads. \\n\\nAccording to the reform each road will become one-way. It will be oriented to one of two directions.\\n\\nTo maximize the tourist attraction of Berland, after the reform for each city i the value ri will be calculated. It will equal to the number of cities x for which there is an oriented path from the city i to the city x. In other words, ri will equal the number of cities which can be reached from the city i by roads. \\n\\nThe government is sure that tourist's attention will be focused on the minimum value of ri.\\n\\nHelp the government of Berland make the reform to maximize the minimum of ri.\\n\\nInput\\n\\nThe first line contains two integers n, m (2 ≤ n ≤ 400 000, 1 ≤ m ≤ 400 000) — the number of cities and the number of roads. \\n\\nThe next m lines describe roads in Berland: the j-th of them contains two integers uj and vj (1 ≤ uj, vj ≤ n, uj ≠ vj), where uj and vj are the numbers of cities which are connected by the j-th road.\\n\\nThe cities are numbered from 1 to n. It is guaranteed that it is possible to get from any city to any other by following two-ways roads. In Berland there are no roads which connect the same pair of cities. \\n\\nOutput\\n\\nIn the first line print single integer — the maximum possible value min1 ≤ i ≤ n{ri} after the orientation of roads. \\n\\nThe next m lines must contain the description of roads after the orientation: the j-th of them must contain two integers uj, vj, it means that the j-th road will be directed from the city uj to the city vj. Print roads in the same order as they are given in the input data. \\n\\nExample\\n\\nInput\\n\\n7 9\\n4 3\\n2 6\\n7 1\\n4 1\\n7 3\\n3 5\\n7 4\\n6 5\\n2 5\\n\\n\\nOutput\\n\\n4\\n4 3\\n6 2\\n7 1\\n1 4\\n3 7\\n5 3\\n7 4\\n5 6\\n2 5\\\":\",\"targets\":\"#include \\nusing namespace std;\\nbool vis[500005];\\nint low[500005], d[500005], par[500005], rnk[500005], lev[500005], timer;\\nvector adj[500005], tree[500005];\\nvector> edges;\\nmap> ed, br;\\nint get(int x) { return (par[x] == x ? x : par[x] = get(par[x])); }\\nvoid link(int x, int y) {\\n x = get(x);\\n y = get(y);\\n if (x == y) return;\\n if (rnk[x] > rnk[y]) swap(x, y);\\n par[x] = y;\\n rnk[y] += rnk[x];\\n}\\nvoid bridge_find(int u, int par) {\\n timer++;\\n d[u] = low[u] = timer;\\n for (auto x : adj[u]) {\\n if (x == par) continue;\\n if (d[x] > 0) {\\n low[u] = min(low[u], d[x]);\\n if (ed[x][u] == 0) ed[u][x] = 1;\\n } else {\\n bridge_find(x, u);\\n low[u] = min(low[u], low[x]);\\n if (d[u] < low[x])\\n br[u][x] = 1, br[x][u] = 1;\\n else {\\n ed[u][x] = 1;\\n link(u, x);\\n }\\n }\\n }\\n}\\nvoid dfs(int child, int par) {\\n vis[child] = 1;\\n for (auto x : adj[child]) {\\n if (x == par) continue;\\n if (br[x][child]) ed[x][child] = 1;\\n if (!vis[x]) dfs(x, child);\\n }\\n}\\nint main() {\\n int n, m;\\n scanf(\\\"%d %d\\\", &n, &m);\\n for (int i = 1; i <= n; i++) rnk[i] = 1, par[i] = i;\\n for (int i = 0; i < m; i++) {\\n int x, y;\\n scanf(\\\"%d %d\\\", &x, &y);\\n edges.push_back({x, y});\\n adj[x].push_back(y);\\n adj[y].push_back(x);\\n }\\n bridge_find(1, -1);\\n int mx = 0, cur;\\n for (int i = 1; i <= n; i++) {\\n int x;\\n x = get(i);\\n lev[x]++;\\n if (mx < lev[x]) {\\n mx = lev[x], cur = x;\\n }\\n }\\n dfs(cur, -1);\\n cout << mx << endl;\\n for (int i = 0; i < m; i++) {\\n if (ed[edges[i].first][edges[i].second])\\n cout << edges[i].first << \\\" \\\" << edges[i].second << endl;\\n else if (ed[edges[i].second][edges[i].first])\\n cout << edges[i].second << \\\" \\\" << edges[i].first << endl;\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You have an undirected graph consisting of n vertices with weighted edges.\\n\\nA simple cycle is a cycle of the graph without repeated vertices. Let the weight of the cycle be the [XOR](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#XOR) of weights of edges it consists of.\\n\\nLet's say the graph is good if all its simple cycles have weight 1. A graph is bad if it's not good.\\n\\nInitially, the graph is empty. Then q queries follow. Each query has the next type: \\n\\n * u v x — add edge between vertices u and v of weight x if it doesn't make the graph bad. \\n\\n\\n\\nFor each query print, was the edge added or not.\\n\\nInput\\n\\nThe first line contains two integers n and q (3 ≤ n ≤ 3 ⋅ 10^5; 1 ≤ q ≤ 5 ⋅ 10^5) — the number of vertices and queries.\\n\\nNext q lines contain queries — one per line. Each query contains three integers u, v and x (1 ≤ u, v ≤ n; u ≠ v; 0 ≤ x ≤ 1) — the vertices of the edge and its weight.\\n\\nIt's guaranteed that there are no multiple edges in the input.\\n\\nOutput\\n\\nFor each query, print YES if the edge was added to the graph, or NO otherwise (both case-insensitive).\\n\\nExample\\n\\nInput\\n\\n\\n9 12\\n6 1 0\\n1 3 1\\n3 6 0\\n6 2 0\\n6 4 1\\n3 4 1\\n2 4 0\\n2 5 0\\n4 5 0\\n7 8 1\\n8 9 1\\n9 7 0\\n\\n\\nOutput\\n\\n\\nYES\\nYES\\nYES\\nYES\\nYES\\nNO\\nYES\\nYES\\nNO\\nYES\\nYES\\nNO\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint read() {\\n char ch = getchar();\\n int x = 0, pd = 0;\\n while (ch < '0' || ch > '9') pd ^= ch == '-', ch = getchar();\\n while ('0' <= ch && ch <= '9') x = x * 10 + (ch ^ 48), ch = getchar();\\n return pd ? -x : x;\\n}\\nconst int maxn = 300005;\\nint n, m;\\nstruct Edge {\\n int u, v, w, bj;\\n} d[maxn * 2];\\nint Fa[maxn];\\nint ff(int x) { return Fa[x] == x ? x : Fa[x] = ff(Fa[x]); }\\nint e, bg[maxn], to[maxn << 1], nx[maxn << 1], w[maxn << 1];\\nvoid link(int u, int v, int _w) {\\n to[++e] = v, nx[e] = bg[u], w[e] = _w, bg[u] = e;\\n}\\nint val[maxn], fa[maxn], sz[maxn], son[maxn], dep[maxn], id[maxn], rk[maxn],\\n top[maxn];\\nvoid dfs1(int u) {\\n sz[u] = 1, dep[u] = dep[fa[u]] + 1;\\n for (int i = bg[u]; i; i = nx[i]) {\\n int v = to[i];\\n if (v == u[fa]) continue;\\n v[fa] = u, v[val] = w[i], dfs1(v);\\n sz[u] += sz[v];\\n if (sz[v] > sz[son[u]]) son[u] = v;\\n }\\n}\\nint tot;\\nvoid dfs2(int u, int t) {\\n top[u] = t, rk[id[u] = ++tot] = u;\\n if (son[u])\\n dfs2(son[u], t);\\n else\\n return;\\n for (int i = bg[u]; i; i = nx[i])\\n if (to[i] != u[fa] && to[i] != son[u]) dfs2(to[i], to[i]);\\n}\\nbool yh[maxn << 2], fg[maxn << 2];\\nbool tag[maxn << 2];\\nvoid pushdown(int o) {\\n (o << 1)[fg] = (o << 1 | 1)[fg] = 1;\\n (o << 1)[tag] = (o << 1 | 1)[tag] = 1;\\n o[tag] = 0;\\n}\\nvoid build(int o, int l, int r) {\\n if (l == r) {\\n o[yh] = val[rk[l]];\\n return;\\n }\\n int mid = (l + r) >> 1;\\n build((o << 1), l, mid), build((o << 1 | 1), mid + 1, r);\\n o[yh] = (o << 1)[yh] ^ (o << 1 | 1)[yh];\\n}\\nvoid cover(int o, int l, int r, int L, int R) {\\n o[fg] = 1;\\n if (L <= l && r <= R) {\\n o[tag] = 1;\\n return;\\n }\\n int mid = (l + r) >> 1;\\n if (L <= mid) cover((o << 1), l, mid, L, R);\\n if (R > mid) cover((o << 1 | 1), mid + 1, r, L, R);\\n}\\nbool query(int o, int l, int r, int L, int R) {\\n if (L <= l && r <= R) return o[yh];\\n int mid = (l + r) >> 1;\\n if (o[tag]) pushdown(o);\\n if (R <= mid) return query((o << 1), l, mid, L, R);\\n if (L > mid) return query((o << 1 | 1), mid + 1, r, L, R);\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Theofanis started playing the new online game called \\\"Among them\\\". However, he always plays with Cypriot players, and they all have the same name: \\\"Andreas\\\" (the most common name in Cyprus).\\n\\nIn each game, Theofanis plays with n other players. Since they all have the same name, they are numbered from 1 to n.\\n\\nThe players write m comments in the chat. A comment has the structure of \\\"i j c\\\" where i and j are two distinct integers and c is a string (1 ≤ i, j ≤ n; i ≠ j; c is either imposter or crewmate). The comment means that player i said that player j has the role c.\\n\\nAn imposter always lies, and a crewmate always tells the truth. \\n\\nHelp Theofanis find the maximum possible number of imposters among all the other Cypriot players, or determine that the comments contradict each other (see the notes for further explanation).\\n\\nNote that each player has exactly one role: either imposter or crewmate.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. Description of each test case follows.\\n\\nThe first line of each test case contains two integers n and m (1 ≤ n ≤ 2 ⋅ 10^5; 0 ≤ m ≤ 5 ⋅ 10^5) — the number of players except Theofanis and the number of comments.\\n\\nEach of the next m lines contains a comment made by the players of the structure \\\"i j c\\\" where i and j are two distinct integers and c is a string (1 ≤ i, j ≤ n; i ≠ j; c is either imposter or crewmate).\\n\\nThere can be multiple comments for the same pair of (i, j).\\n\\nIt is guaranteed that the sum of all n does not exceed 2 ⋅ 10^5 and the sum of all m does not exceed 5 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print one integer — the maximum possible number of imposters. If the comments contradict each other, print -1.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n3 2\\n1 2 imposter\\n2 3 crewmate\\n5 4\\n1 3 crewmate\\n2 5 crewmate\\n2 4 imposter\\n3 4 imposter\\n2 2\\n1 2 imposter\\n2 1 crewmate\\n3 5\\n1 2 imposter\\n1 2 imposter\\n3 2 crewmate\\n3 2 crewmate\\n1 3 imposter\\n5 0\\n\\n\\nOutput\\n\\n\\n2\\n4\\n-1\\n2\\n5\\n\\nNote\\n\\nIn the first test case, imposters can be Andreas 2 and 3.\\n\\nIn the second test...\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 1e6 + 99;\\nint n, t, m, ck, a[N], col[N], d[2], mark[N];\\nvector > g[N];\\nvoid dfs(int x) {\\n mark[x] = 1;\\n d[col[x]]++;\\n for (int i = 0; i < g[x].size(); i++) {\\n if (!mark[g[x][i].first]) {\\n col[g[x][i].first] = col[x] ^ g[x][i].second;\\n dfs(g[x][i].first);\\n }\\n if (col[g[x][i].first] != (col[x] ^ g[x][i].second)) ck = 1;\\n }\\n}\\nint main() {\\n ios::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n cin >> t;\\n while (t--) {\\n int ans = 0;\\n ck = 0;\\n cin >> n >> m;\\n for (int i = 1; i < n + 1; i++) g[i].clear(), mark[i] = 0;\\n for (int i = 0; i < m; i++) {\\n int u, v;\\n string s;\\n cin >> u >> v >> s;\\n g[u].push_back(make_pair(v, (s[0] == 'i')));\\n g[v].push_back(make_pair(u, (s[0] == 'i')));\\n }\\n for (int i = 1; i < n + 1; i++) {\\n d[0] = d[1] = 0;\\n if (!mark[i]) {\\n col[i] = 0;\\n dfs(i);\\n }\\n ans += max(d[0], d[1]);\\n }\\n if (ck)\\n cout << -1 << endl;\\n else\\n cout << ans << endl;\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A Ministry for Defense sent a general to inspect the Super Secret Military Squad under the command of the Colonel SuperDuper. Having learned the news, the colonel ordered to all n squad soldiers to line up on the parade ground.\\n\\nBy the military charter the soldiers should stand in the order of non-increasing of their height. But as there's virtually no time to do that, the soldiers lined up in the arbitrary order. However, the general is rather short-sighted and he thinks that the soldiers lined up correctly if the first soldier in the line has the maximum height and the last soldier has the minimum height. Please note that the way other solders are positioned does not matter, including the case when there are several soldiers whose height is maximum or minimum. Only the heights of the first and the last soldier are important.\\n\\nFor example, the general considers the sequence of heights (4, 3, 4, 2, 1, 1) correct and the sequence (4, 3, 1, 2, 2) wrong.\\n\\nWithin one second the colonel can swap any two neighboring soldiers. Help him count the minimum time needed to form a line-up which the general will consider correct.\\n\\nInput\\n\\nThe first input line contains the only integer n (2 ≤ n ≤ 100) which represents the number of soldiers in the line. The second line contains integers a1, a2, ..., an (1 ≤ ai ≤ 100) the values of the soldiers' heights in the order of soldiers' heights' increasing in the order from the beginning of the line to its end. The numbers are space-separated. Numbers a1, a2, ..., an are not necessarily different.\\n\\nOutput\\n\\nPrint the only integer — the minimum number of seconds the colonel will need to form a line-up the general will like.\\n\\nExamples\\n\\nInput\\n\\n4\\n33 44 11 22\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n7\\n10 10 58 31 63 40 76\\n\\n\\nOutput\\n\\n10\\n\\nNote\\n\\nIn the first sample the colonel will need to swap the first and second soldier and then the third and fourth soldier. That will take 2 seconds. The resulting position of the soldiers is (44, 33, 22, 11).\\n\\nIn the second sample the colonel may swap the soldiers in the...\\nSolve the task in PYTHON3.\",\"targets\":\"import sys\\n\\ninput = lambda: sys.stdin.readline().strip(\\\"\\\\r\\\\n\\\")\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\nmaxi = max(a)\\nmini = min(a)\\nmaxind = a.index(maxi)\\nminind = a[::-1].index(mini)\\nif maxind <= n - minind - 1:\\n print(maxind + minind)\\nelse:\\n print(maxind + minind - 1)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A binary string is a string that consists of characters 0 and 1. A bi-table is a table that has exactly two rows of equal length, each being a binary string.\\n\\nLet \\\\operatorname{MEX} of a bi-table be the smallest digit among 0, 1, or 2 that does not occur in the bi-table. For example, \\\\operatorname{MEX} for \\\\begin{bmatrix} 0011\\\\\\\\\\\\ 1010 \\\\end{bmatrix} is 2, because 0 and 1 occur in the bi-table at least once. \\\\operatorname{MEX} for \\\\begin{bmatrix} 111\\\\\\\\\\\\ 111 \\\\end{bmatrix} is 0, because 0 and 2 do not occur in the bi-table, and 0 < 2.\\n\\nYou are given a bi-table with n columns. You should cut it into any number of bi-tables (each consisting of consecutive columns) so that each column is in exactly one bi-table. It is possible to cut the bi-table into a single bi-table — the whole bi-table.\\n\\nWhat is the maximal sum of \\\\operatorname{MEX} of all resulting bi-tables can be?\\n\\nInput\\n\\nThe input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. Description of the test cases follows.\\n\\nThe first line of the description of each test case contains a single integer n (1 ≤ n ≤ 10^5) — the number of columns in the bi-table.\\n\\nEach of the next two lines contains a binary string of length n — the rows of the bi-table.\\n\\nIt's guaranteed that the sum of n over all test cases does not exceed 10^5.\\n\\nOutput\\n\\nFor each test case print a single integer — the maximal sum of \\\\operatorname{MEX} of all bi-tables that it is possible to get by cutting the given bi-table optimally.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n7\\n0101000\\n1101100\\n5\\n01100\\n10101\\n2\\n01\\n01\\n6\\n000000\\n111111\\n\\n\\nOutput\\n\\n\\n8\\n8\\n2\\n12\\n\\nNote\\n\\nIn the first test case you can cut the bi-table as follows:\\n\\n * \\\\begin{bmatrix} 0\\\\\\\\\\\\ 1 \\\\end{bmatrix}, its \\\\operatorname{MEX} is 2.\\n * \\\\begin{bmatrix} 10\\\\\\\\\\\\ 10 \\\\end{bmatrix}, its \\\\operatorname{MEX} is 2.\\n * \\\\begin{bmatrix} 1\\\\\\\\\\\\ 1 \\\\end{bmatrix}, its \\\\operatorname{MEX} is 0.\\n * \\\\begin{bmatrix} 0\\\\\\\\\\\\ 1 \\\\end{bmatrix}, its \\\\operatorname{MEX} is 2.\\n * \\\\begin{bmatrix} 0\\\\\\\\\\\\ 0 \\\\end{bmatrix}, its...\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\n \\n \\npublic class template {\\n static class Reader {\\n final private int BUFFER_SIZE = 1 << 16;\\n private DataInputStream din;\\n private byte[] buffer;\\n private int bufferPointer, bytesRead;\\n \\n public Reader()\\n {\\n din = new DataInputStream(System.in);\\n buffer = new byte[BUFFER_SIZE];\\n bufferPointer = bytesRead = 0;\\n }\\n \\n public Reader(String file_name) throws IOException\\n {\\n din = new DataInputStream(\\n new FileInputStream(file_name));\\n buffer = new byte[BUFFER_SIZE];\\n bufferPointer = bytesRead = 0;\\n }\\n \\n public String readLine() throws IOException\\n {\\n byte[] buf = new byte[64]; \\/\\/ line length\\n int cnt = 0, c;\\n while ((c = read()) != -1) {\\n if (c == '\\\\n') {\\n if (cnt != 0) {\\n break;\\n }\\n else {\\n continue;\\n }\\n }\\n buf[cnt++] = (byte)c;\\n }\\n return new String(buf, 0, cnt);\\n }\\n \\n public int nextInt() throws IOException\\n {\\n int ret = 0;\\n byte c = read();\\n while (c <= ' ') {\\n c = read();\\n }\\n boolean neg = (c == '-');\\n if (neg)\\n c = read();\\n do {\\n ret = ret * 10 + c - '0';\\n } while ((c = read()) >= '0' && c <= '9');\\n \\n if (neg)\\n return -ret;\\n return ret;\\n }\\n \\n public long nextLong() throws IOException\\n {\\n long ret = 0;\\n byte c = read();\\n while (c <= ' ')\\n c = read();\\n boolean neg = (c == '-');\\n if (neg)\\n c = read();\\n do {\\n ret = ret * 10 + c - '0';\\n } while ((c = read()) >= '0'...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nAlice and Bob are playing a game on a matrix, consisting of 2 rows and m columns. The cell in the i-th row in the j-th column contains a_{i, j} coins in it.\\n\\nInitially, both Alice and Bob are standing in a cell (1, 1). They are going to perform a sequence of moves to reach a cell (2, m).\\n\\nThe possible moves are: \\n\\n * Move right — from some cell (x, y) to (x, y + 1); \\n * Move down — from some cell (x, y) to (x + 1, y). \\n\\n\\n\\nFirst, Alice makes all her moves until she reaches (2, m). She collects the coins in all cells she visit (including the starting cell).\\n\\nWhen Alice finishes, Bob starts his journey. He also performs the moves to reach (2, m) and collects the coins in all cells that he visited, but Alice didn't.\\n\\nThe score of the game is the total number of coins Bob collects.\\n\\nAlice wants to minimize the score. Bob wants to maximize the score. What will the score of the game be if both players play optimally?\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.\\n\\nThen the descriptions of t testcases follow.\\n\\nThe first line of the testcase contains a single integer m (1 ≤ m ≤ 10^5) — the number of columns of the matrix.\\n\\nThe i-th of the next 2 lines contain m integers a_{i,1}, a_{i,2}, ..., a_{i,m} (1 ≤ a_{i,j} ≤ 10^4) — the number of coins in the cell in the i-th row in the j-th column of the matrix.\\n\\nThe sum of m over all testcases doesn't exceed 10^5.\\n\\nOutput\\n\\nFor each testcase print a single integer — the score of the game if both players play optimally.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n3\\n1 3 7\\n3 5 1\\n3\\n1 3 9\\n3 5 1\\n1\\n4\\n7\\n\\n\\nOutput\\n\\n\\n7\\n8\\n0\\n\\nNote\\n\\nThe paths for the testcases are shown on the following pictures. Alice's path is depicted in red and Bob's path is depicted in blue.\\n\\n\",\"targets\":\"import java.util.*;\\npublic class Solution{\\n public static void main(String[] args) {\\n Scanner sc = new Scanner(System.in);\\n int t = sc.nextInt();\\n while(t-- > 0) {\\n int[][] coins = new int[2][sc.nextInt()];\\n for( int i = 0 ; i < 2 ; i++) {\\n for( int j = 0 ; j < coins[0].length ; j++) {\\n coins[i][j] = sc.nextInt() ;\\n }\\n }\\n int min = Integer.MAX_VALUE ;\\n int sum1 = 0 , sum2 = 0 ;\\n for( int i = 0 ; i < coins[0].length ; i ++) {\\n sum1 += coins[0][i] ;\\n }\\n for( int i = 0 ; i < coins[0].length ; i ++) {\\n sum1 -= coins[0][i];\\n min = Math.min(min,Math.max(sum2,sum1));\\n sum2 += coins[1][i];\\n }\\n System.out.println(min);\\n }\\n sc.close(); \\n }\\n \\t}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A string is called square if it is some string written twice in a row. For example, the strings \\\"aa\\\", \\\"abcabc\\\", \\\"abab\\\" and \\\"baabaa\\\" are square. But the strings \\\"aaa\\\", \\\"abaaab\\\" and \\\"abcdabc\\\" are not square.\\n\\nFor a given string s determine if it is square.\\n\\nInput\\n\\nThe first line of input data contains an integer t (1 ≤ t ≤ 100) —the number of test cases.\\n\\nThis is followed by t lines, each containing a description of one test case. The given strings consist only of lowercase Latin letters and have lengths between 1 and 100 inclusive.\\n\\nOutput\\n\\nFor each test case, output on a separate line:\\n\\n * YES if the string in the corresponding test case is square, \\n * NO otherwise. \\n\\n\\n\\nYou can output YES and NO in any case (for example, strings yEs, yes, Yes and YES will be recognized as a positive response).\\n\\nExample\\n\\nInput\\n\\n\\n10\\na\\naa\\naaa\\naaaa\\nabab\\nabcabc\\nabacaba\\nxxyy\\nxyyx\\nxyxy\\n\\n\\nOutput\\n\\n\\nNO\\nYES\\nNO\\nYES\\nYES\\nYES\\nNO\\nNO\\nNO\\nYES\\nimpor\",\"targets\":\"t java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.util.StringTokenizer;\\n\\npublic class cf1619A {\\n \\n public static void main(String[] args) {\\n FastReader sc = new FastReader();\\n int t = sc.nextInt();\\n\\n while(t-->0) {\\n String s = sc.nextLine();\\n System.out.println(s.substring(0, s.length()\\/2).equalsIgnoreCase(s.substring(s.length()\\/2)) ? \\\"YES\\\" : \\\"NO\\\");\\n }\\n \\n }\\n \\n static class FastReader {\\n BufferedReader br;\\n StringTokenizer st;\\n \\n public FastReader() {\\n br = new BufferedReader(new InputStreamReader(System.in));\\n }\\n \\n String next() {\\n while (st == null || !st.hasMoreElements()) {\\n try {\\n st = new StringTokenizer(br.readLine());\\n } catch (IOException e) {\\n e.printStackTrace();\\n }\\n }\\n return st.nextToken();\\n }\\n \\n int nextInt() { return Integer.parseInt(next()); }\\n \\n long nextLong() { return Long.parseLong(next()); }\\n \\n double nextDouble() { return Double.parseDouble(next()); }\\n \\n String nextLine() {\\n String str = \\\"\\\";\\n try {\\n str = br.readLine();\\n } catch (IOException e) {\\n e.printStackTrace();\\n }\\n return str;\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Vupsen and Pupsen were gifted an integer array. Since Vupsen doesn't like the number 0, he threw away all numbers equal to 0 from the array. As a result, he got an array a of length n.\\n\\nPupsen, on the contrary, likes the number 0 and he got upset when he saw the array without zeroes. To cheer Pupsen up, Vupsen decided to come up with another array b of length n such that ∑_{i=1}^{n}a_i ⋅ b_i=0. Since Vupsen doesn't like number 0, the array b must not contain numbers equal to 0. Also, the numbers in that array must not be huge, so the sum of their absolute values cannot exceed 10^9. Please help Vupsen to find any such array b!\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. The next 2 ⋅ t lines contain the description of test cases. The description of each test case consists of two lines.\\n\\nThe first line of each test case contains a single integer n (2 ≤ n ≤ 10^5) — the length of the array.\\n\\nThe second line contains n integers a_1, a_2, …, a_n (-10^4 ≤ a_i ≤ 10^4, a_i ≠ 0) — the elements of the array a.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case print n integers b_1, b_2, …, b_n — elements of the array b (|b_1|+|b_2|+… +|b_n| ≤ 10^9, b_i ≠ 0, ∑_{i=1}^{n}a_i ⋅ b_i=0).\\n\\nIt can be shown that the answer always exists.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n2\\n5 5\\n5\\n5 -2 10 -9 4\\n7\\n1 2 3 4 5 6 7\\n\\n\\nOutput\\n\\n\\n1 -1\\n-1 5 1 -1 -1\\n-10 2 2 -3 5 -1 -1\\n\\nNote\\n\\nIn the first test case, 5 ⋅ 1 + 5 ⋅ (-1)=5-5=0. You could also print 3 -3, for example, since 5 ⋅ 3 + 5 ⋅ (-3)=15-15=0\\n\\nIn the second test case, 5 ⋅ (-1) + (-2) ⋅ 5 + 10 ⋅ 1 + (-9) ⋅ (-1) + 4 ⋅ (-1)=-5-10+10+9-4=0.\\nUsing python3 can you solve the prior task?\",\"targets\":\"#coding=utf-8\\nDEBUG = 0\\n\\nif DEBUG==1:\\n data = open('1.in', 'r')\\n #sys.stdout = open('tmp.out', 'w')\\n\\ndef readline():\\n if DEBUG == 1:\\n return data.readline().strip('\\\\r\\\\n')\\n else:\\n try:\\n return input().strip('\\\\r\\\\n')\\n except EOFError:\\n return ''\\n\\ndef readi():\\n return [int(t) for t in readline().split()]\\n\\ntc, = readi()\\nfor _ in range(tc):\\n n, = readi()\\n a = readi()\\n \\n if n%2==0:\\n for i in range(0,n-1,2):\\n print(a[i+1], -a[i], end=' ')\\n print()\\n else:\\n for i in range(0,n-4,2):\\n print(a[i+1], -a[i], end=' ')\\n a1 = a[-3]\\n a2 = a[-2]\\n a3 = a[-1]\\n b1,b2,b3=0,0,0\\n if (a2+a3) != 0:\\n b1 = -(a2+a3)\\n b2 = a1\\n b3 = a1\\n elif (a1+a3) != 0:\\n b1 = a2\\n b2 = -(a1+a3)\\n b3 = a2\\n elif (a1+a2) != 0:\\n b1 = a3\\n b2 = a3\\n b3 = -(a1+a2)\\n print(b1,b2,b3)\\n\\n\\nif DEBUG==1:\\n data.close()\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"As you know, Bob's brother lives in Flatland. In Flatland there are n cities, connected by n - 1 two-way roads. The cities are numbered from 1 to n. You can get from one city to another moving along the roads.\\n\\nThe «Two Paths» company, where Bob's brother works, has won a tender to repair two paths in Flatland. A path is a sequence of different cities, connected sequentially by roads. The company is allowed to choose by itself the paths to repair. The only condition they have to meet is that the two paths shouldn't cross (i.e. shouldn't have common cities).\\n\\nIt is known that the profit, the «Two Paths» company will get, equals the product of the lengths of the two paths. Let's consider the length of each road equals 1, and the length of a path equals the amount of roads in it. Find the maximum possible profit for the company.\\n\\nInput\\n\\nThe first line contains an integer n (2 ≤ n ≤ 200), where n is the amount of cities in the country. The following n - 1 lines contain the information about the roads. Each line contains a pair of numbers of the cities, connected by the road ai, bi (1 ≤ ai, bi ≤ n).\\n\\nOutput\\n\\nOutput the maximum possible profit.\\n\\nExamples\\n\\nInput\\n\\n4\\n1 2\\n2 3\\n3 4\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\n7\\n1 2\\n1 3\\n1 4\\n1 5\\n1 6\\n1 7\\n\\n\\nOutput\\n\\n0\\n\\n\\nInput\\n\\n6\\n1 2\\n2 3\\n2 4\\n5 4\\n6 4\\n\\n\\nOutput\\n\\n4\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.util.Arrays;\\nimport java.util.HashMap;\\nimport java.util.LinkedList;\\nimport java.util.*;\\n\\npublic class TwoPaths {\\n\\tstatic class DisjointSet {\\n\\n\\t\\tpublic int[] set;\\n\\n\\t\\tpublic DisjointSet(int n) {\\n\\t\\t\\tset = new int[n];\\n\\t\\t\\tfor (int i = 0; i < set.length; i++) {\\n\\t\\t\\t\\tset[i] = i;\\n\\t\\t\\t}\\n\\t\\t}\\n\\n\\t\\tpublic int find(int x) {\\n\\t\\t\\tif (set[x] == x)\\n\\t\\t\\t\\treturn x;\\n\\t\\t\\treturn set[x] = find(set[x]);\\n\\t\\t}\\n\\n\\t\\tpublic void union(int x, int y) {\\n\\t\\t\\tset[find(x)] = find(y);\\n\\t\\t}\\n\\n\\t\\tpublic int countDSets() {\\n\\t\\t\\tint c = 0;\\n\\t\\t\\tfor (int i = 0; i < set.length; i++)\\n\\t\\t\\t\\tif (set[i] == i)\\n\\t\\t\\t\\t\\tc++;\\n\\t\\t\\treturn c;\\n\\t\\t}\\n\\n\\t}\\n\\n\\tstatic int rem1;\\n\\tstatic int rem2;\\n\\n\\tpublic static void main(String[] args) throws IOException {\\n\\t\\t\\/\\/ TODO Auto-generated method stub\\n\\t\\tBufferedReader r = new BufferedReader(new InputStreamReader(System.in));\\n\\t\\tString s = r.readLine();\\n\\t\\tint n = new Integer(s);\\n\\t\\tVector[] adj = new Vector[n];\\n\\t\\tfor (int i = 0; i < adj.length; i++) {\\n\\t\\t\\tadj[i] = new Vector();\\n\\t\\t}\\n\\t\\tVector edges = new Vector();\\n\\t\\tfor (int i = 0; i < n - 1; i++) {\\n\\t\\t\\ts = r.readLine();\\n\\t\\t\\tString[] sp = s.split(\\\" \\\");\\n\\t\\t\\tint from = new Integer(sp[0]) - 1;\\n\\t\\t\\tint to = new Integer(sp[1]) - 1;\\n\\t\\t\\tadj[from].add(to);\\n\\t\\t\\tadj[to].add(from);\\n\\t\\t\\tedges.add(from);\\n\\t\\t\\tedges.add(to);\\n\\t\\t}\\n\\t\\tint max = 0;\\n\\t\\tfor (int i = 0; i < edges.size(); i += 2) {\\n\\t\\t\\trem1 = edges.get(i);\\n\\t\\t\\trem2 = edges.get(i + 1);\\n\\t\\t\\tDisjointSet ds = new DisjointSet(n);\\n\\t\\t\\tfor (int j = 0; j < edges.size(); j += 2) {\\n\\t\\t\\t\\tif (i == j)\\n\\t\\t\\t\\t\\tcontinue;\\n\\t\\t\\t\\tds.union(edges.get(j), edges.get(j + 1));\\n\\t\\t\\t}\\n\\t\\t\\tHashMap hm = new HashMap();\\n\\t\\t\\tint p1 = -1, p2 = -1;\\n\\n\\t\\t\\tfor (int j = 0; j < n; j++) {\\n\\t\\t\\t\\tv = new boolean[n];\\n\\t\\t\\t\\tdp = new int[n];\\n\\t\\t\\t\\tArrays.fill(dp, -1);\\n\\t\\t\\t\\tv[j] = true;\\n\\t\\t\\t\\tint longest = go(j, adj);\\n\\t\\t\\t\\tint parent = ds.find(j);\\n\\t\\t\\t\\tif (p1 == -1)\\n\\t\\t\\t\\t\\tp1 = parent;\\n\\t\\t\\t\\telse if (p2 == -1 && p1 != parent)\\n\\t\\t\\t\\t\\tp2 = parent;\\n\\t\\t\\t\\tif...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A prime number is a number which has exactly two distinct divisors: one and itself. For example, numbers 2, 7, 3 are prime, and 1, 6, 4 are not.\\n\\nThe next prime number after x is the smallest prime number greater than x. For example, the next prime number after 2 is 3, and the next prime number after 3 is 5. Note that there is exactly one next prime number after each number. So 5 is not the next prime number for 2.\\n\\nOne cold April morning Panoramix predicted that soon Kakofonix will break free from his straitjacket, and this will be a black day for the residents of the Gallic countryside.\\n\\nPanoramix's prophecy tells that if some day Asterix and Obelix beat exactly x Roman soldiers, where x is a prime number, and next day they beat exactly y Roman soldiers, where y is the next prime number after x, then it's time to wait for Armageddon, for nothing can shut Kakofonix up while he sings his infernal song.\\n\\nYesterday the Gauls beat n Roman soldiers and it turned out that the number n was prime! Today their victims were a troop of m Romans (m > n). Determine whether the Gauls should wait for the black day after today's victory of Asterix and Obelix?\\n\\nInput\\n\\nThe first and only input line contains two positive integers — n and m (2 ≤ n < m ≤ 50). It is guaranteed that n is prime.\\n\\nPretests contain all the cases with restrictions 2 ≤ n < m ≤ 4.\\n\\nOutput\\n\\nPrint YES, if m is the next prime number after n, or NO otherwise.\\n\\nExamples\\n\\nInput\\n\\n3 5\\n\\n\\nOutput\\n\\nYES\\n\\nInput\\n\\n7 11\\n\\n\\nOutput\\n\\nYES\\n\\nInput\\n\\n7 9\\n\\n\\nOutput\\n\\nNO\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\nimport java.util.regex.*;\\nimport java.math.BigInteger;\\n\\npublic class Codeforces{\\n\\t\\n\\tstatic class MyScanner{\\n\\t\\tBufferedReader br;\\n\\t\\tStringTokenizer st;\\n\\t\\t\\n\\t\\tMyScanner(FileReader fileReader){\\n\\t\\t\\tbr = new BufferedReader(fileReader);\\n\\t\\t}\\n\\t\\t\\n\\t\\tMyScanner(){\\n\\t\\t\\tbr = new BufferedReader(new InputStreamReader(System.in));\\n\\t\\t}\\n\\t\\t\\n\\t\\tString nn(){\\n\\t\\t\\twhile(st == null || !st.hasMoreElements()){\\n\\t\\t\\t\\ttry{\\n\\t\\t\\t\\t\\tst = new StringTokenizer(br.readLine());\\n\\t\\t\\t\\t}catch(IOException e){\\n\\t\\t\\t\\t\\te.printStackTrace();\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\treturn st.nextToken();\\n\\t\\t}\\n\\t\\t\\n\\t\\tint ni(){\\n\\t\\t\\treturn Integer.parseInt(nn());\\n\\t\\t}\\n\\t\\t\\n\\t\\tlong nl(){\\n\\t\\t\\treturn Long.parseLong(nn());\\n\\t\\t}\\n\\t\\t\\n\\t\\tdouble nd(){\\n\\t\\t\\treturn Double.parseDouble(nn());\\n\\t\\t}\\n\\t}\\n\\t\\n\\tprivate static PrintWriter out;\\n\\t\\n\\tpublic static void main(String[] args) throws FileNotFoundException{\\n\\t\\t\\n\\t\\t\\n\\t\\t\\/\\/ Input from file\\n\\t\\t\\/\\/ File inputFile = new File(\\\"input.txt\\\");\\n\\t\\t\\/\\/ File outputFile = new File(\\\"output.txt\\\");\\n\\t\\t\\/\\/ FileReader fileReader = new FileReader(inputFile);\\n\\t\\t\\/\\/ Here it ends\\n\\t\\t\\t\\n\\t\\tMyScanner sc = new MyScanner();\\n\\t\\t\\n\\t\\tout = new PrintWriter(new BufferedOutputStream(System.out)); \\/\\/ Output to console\\n\\t\\t\\/\\/ out = new PrintWriter(new PrintStream(outputFile)); \\/\\/ Output to file\\n\\t\\t\\n\\t\\tBigInteger n = BigInteger.valueOf(sc.ni()), m = BigInteger.valueOf(sc.ni());\\n\\t\\t\\n\\t\\tBigInteger n1 = n.nextProbablePrime();\\n\\t\\t\\/\\/ out.println(n1);\\n\\t\\tout.println((n1.equals(m))? \\\"YES\\\": \\\"NO\\\");\\n\\t\\t\\n\\t\\tout.close();\\n\\t}\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"When you play the game of thrones, you win, or you die. There is no middle ground.\\n\\nCersei Lannister, A Game of Thrones by George R. R. Martin\\n\\nThere are n nobles, numbered from 1 to n. Noble i has a power of i. There are also m \\\"friendships\\\". A friendship between nobles a and b is always mutual.\\n\\nA noble is defined to be vulnerable if both of the following conditions are satisfied: \\n\\n * the noble has at least one friend, and \\n * all of that noble's friends have a higher power. \\n\\n\\n\\nYou will have to process the following three types of queries. \\n\\n 1. Add a friendship between nobles u and v. \\n 2. Remove a friendship between nobles u and v. \\n 3. Calculate the answer to the following process. \\n\\n\\n\\nThe process: all vulnerable nobles are simultaneously killed, and all their friendships end. Then, it is possible that new nobles become vulnerable. The process repeats itself until no nobles are vulnerable. It can be proven that the process will end in finite time. After the process is complete, you need to calculate the number of remaining nobles.\\n\\nNote that the results of the process are not carried over between queries, that is, every process starts with all nobles being alive!\\n\\nInput\\n\\nThe first line contains the integers n and m (1 ≤ n ≤ 2⋅ 10^5, 0 ≤ m ≤ 2⋅ 10^5) — the number of nobles and number of original friendships respectively.\\n\\nThe next m lines each contain the integers u and v (1 ≤ u,v ≤ n, u ≠ v), describing a friendship. No friendship is listed twice.\\n\\nThe next line contains the integer q (1 ≤ q ≤ 2⋅ {10}^{5}) — the number of queries. \\n\\nThe next q lines contain the queries themselves, each query has one of the following three formats. \\n\\n * 1 u v (1 ≤ u,v ≤ n, u ≠ v) — add a friendship between u and v. It is guaranteed that u and v are not friends at this moment. \\n * 2 u v (1 ≤ u,v ≤ n, u ≠ v) — remove a friendship between u and v. It is guaranteed that u and v are friends at this moment. \\n * 3 — print the answer to the process described in the statement. \\n\\nOutput\\n\\nFor each type 3 query print one...\\\":\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\nimport static java.lang.System.*;\\nimport static java.lang.Math.*;\\npublic class CodechefCook\\n{\\n void run() {\\n StringBuilder sb = new StringBuilder();\\n int n=ni(),m=ni();\\n int cnt[] = new int[n+1],ans=0;\\n for(int i=0;i0) {\\n int qt=ni();\\n if(qt==1) {\\n int u=ni(),v=ni();\\n cnt[min(u,v)]++;\\n if(cnt[min(u,v)]==1) ans++;\\n }\\n else if(qt==2) {\\n int u=ni(),v=ni();\\n cnt[min(u,v)]--;\\n if(cnt[min(u,v)]==0) ans--;\\n }\\n else {\\n sb.append(n-ans).append(\\\"\\\\n\\\");\\n }\\n }\\n out.println(sb);\\n out.flush(); \\n out.close();\\n }\\n\\n int calc(Set set[]) {\\n int ct=0;\\n for(int i=1;i itr = set[i].iterator();\\n while(itr.hasNext()) set[itr.next()].remove(i);\\n }\\n }\\n return ct;\\n }\\n\\n public static void main(String[] args)throws Exception {\\n try { \\n \\/\\/ new Thread(null, new CodechefCook()::run, \\\"1\\\", 1 << 26).start();\\n new Thread(null, new CodechefCook(\\\"ONLINE_JUDGE\\\")::run, \\\"1\\\", 1 << 26).start();\\n } catch(Exception e) {}\\n }\\n\\n FastReader sc=null;PrintWriter out = null;\\n public CodechefCook()throws Exception {\\n sc = new FastReader(new FileInputStream(\\\"D:\\\\\\\\CP\\\\\\\\input.txt\\\"));\\n out = new PrintWriter(new BufferedWriter(new FileWriter(\\\"D:\\\\\\\\CP\\\\\\\\output.txt\\\")));\\n }\\n public CodechefCook(String JUDGE) {\\n sc = new FastReader(System.in);\\n out = new PrintWriter(System.out); \\n }\\n \\n String ns() { return sc.next(); }\\n int ni() { return sc.nextInt(); }\\n long nl() {...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A festival will be held in a town's main street. There are n sections in the main street. The sections are numbered 1 through n from left to right. The distance between each adjacent sections is 1.\\n\\nIn the festival m fireworks will be launched. The i-th (1 ≤ i ≤ m) launching is on time ti at section ai. If you are at section x (1 ≤ x ≤ n) at the time of i-th launching, you'll gain happiness value bi - |ai - x| (note that the happiness value might be a negative value).\\n\\nYou can move up to d length units in a unit time interval, but it's prohibited to go out of the main street. Also you can be in an arbitrary section at initial time moment (time equals to 1), and want to maximize the sum of happiness that can be gained from watching fireworks. Find the maximum total happiness.\\n\\nNote that two or more fireworks can be launched at the same time.\\n\\nInput\\n\\nThe first line contains three integers n, m, d (1 ≤ n ≤ 150000; 1 ≤ m ≤ 300; 1 ≤ d ≤ n).\\n\\nEach of the next m lines contains integers ai, bi, ti (1 ≤ ai ≤ n; 1 ≤ bi ≤ 109; 1 ≤ ti ≤ 109). The i-th line contains description of the i-th launching.\\n\\nIt is guaranteed that the condition ti ≤ ti + 1 (1 ≤ i < m) will be satisfied.\\n\\nOutput\\n\\nPrint a single integer — the maximum sum of happiness that you can gain from watching all the fireworks.\\n\\nPlease, do not write the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.\\n\\nExamples\\n\\nInput\\n\\n50 3 1\\n49 1 1\\n26 1 4\\n6 1 10\\n\\n\\nOutput\\n\\n-31\\n\\n\\nInput\\n\\n10 2 1\\n1 1000 4\\n9 1000 4\\n\\n\\nOutput\\n\\n1992\\nSolve the task in CPP.\",\"targets\":\"#include \\n#pragma GCC optimize(\\\"Ofast,no-stack-protector,unroll-loops\\\")\\n#pragma GCC optimize(\\\"no-stack-protector,fast-math\\\")\\n#pragma GCC target(\\\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native\\\")\\nusing namespace std;\\ntemplate \\ninline S smax(S &l, T r) {\\n return l = max(l, (S)r);\\n}\\ntemplate \\ninline S smin(S &l, T r) {\\n return l = min(l, (S)r);\\n}\\nint32_t main() {\\n ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);\\n long long n, m, d;\\n cin >> n >> m >> d;\\n vector dp(n);\\n vector pd(n);\\n long long time = 0;\\n for (long long i = 0; i < m; ++i) {\\n long long a, b, t;\\n cin >> a >> b >> t;\\n a--;\\n long long mx = 0;\\n for (long long j = 0; j < n; ++j)\\n if (dp[mx] < dp[j]) mx = j;\\n for (long long j = 0; j < n; ++j) {\\n if ((j + (t - time) * d) <= mx)\\n pd[j] = dp[j + (t - time) * d];\\n else if ((j - (t - time) * d) >= mx)\\n pd[j] = dp[j - (t - time) * d];\\n else\\n pd[j] = dp[mx];\\n }\\n for (long long j = 0; j < n; ++j) pd[j] += (b - abs(a - j));\\n for (long long j = 0; j < n; ++j) dp[j] = pd[j];\\n time = t;\\n }\\n long long ans = (long long)(-1e9);\\n for (long long i : dp) smax(ans, i);\\n cout << ans << \\\"\\\\n\\\";\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Pavel cooks barbecue. There are n skewers, they lay on a brazier in a row, each on one of n positions. Pavel wants each skewer to be cooked some time in every of n positions in two directions: in the one it was directed originally and in the reversed direction.\\n\\nPavel has a plan: a permutation p and a sequence b1, b2, ..., bn, consisting of zeros and ones. Each second Pavel move skewer on position i to position pi, and if bi equals 1 then he reverses it. So he hope that every skewer will visit every position in both directions.\\n\\nUnfortunately, not every pair of permutation p and sequence b suits Pavel. What is the minimum total number of elements in the given permutation p and the given sequence b he needs to change so that every skewer will visit each of 2n placements? Note that after changing the permutation should remain a permutation as well.\\n\\nThere is no problem for Pavel, if some skewer visits some of the placements several times before he ends to cook. In other words, a permutation p and a sequence b suit him if there is an integer k (k ≥ 2n), so that after k seconds each skewer visits each of the 2n placements.\\n\\nIt can be shown that some suitable pair of permutation p and sequence b exists for any n.\\n\\nInput\\n\\nThe first line contain the integer n (1 ≤ n ≤ 2·105) — the number of skewers.\\n\\nThe second line contains a sequence of integers p1, p2, ..., pn (1 ≤ pi ≤ n) — the permutation, according to which Pavel wants to move the skewers.\\n\\nThe third line contains a sequence b1, b2, ..., bn consisting of zeros and ones, according to which Pavel wants to reverse the skewers.\\n\\nOutput\\n\\nPrint single integer — the minimum total number of elements in the given permutation p and the given sequence b he needs to change so that every skewer will visit each of 2n placements.\\n\\nExamples\\n\\nInput\\n\\n4\\n4 3 2 1\\n0 1 1 1\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n3\\n2 3 1\\n0 0 0\\n\\n\\nOutput\\n\\n1\\n\\nNote\\n\\nIn the first example Pavel can change the permutation to 4, 3, 1, 2.\\n\\nIn the second example Pavel can change any element of b to 1.\\\":\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 2e5 + 5;\\nint n;\\nint arr[N];\\nbool visited[N];\\nint cnt;\\nint arr2[N];\\nint main() {\\n scanf(\\\"%d\\\", &n);\\n for (int i = 1; i <= n; ++i) {\\n scanf(\\\"%d\\\", arr + i);\\n visited[i] = 0;\\n }\\n for (int i = 1; i <= n; ++i) {\\n scanf(\\\"%d\\\", arr2 + i);\\n }\\n cnt = 0;\\n int onez = 0;\\n int v = 0;\\n for (int i = 1; i <= n; ++i) {\\n if (!visited[i]) {\\n int node = i;\\n int lol = 0;\\n do {\\n ++lol;\\n visited[node] = 1;\\n node = arr[node];\\n } while (node != i);\\n if (lol > 1) {\\n ++v;\\n } else {\\n onez += 1;\\n }\\n }\\n }\\n if (n == 1) {\\n cnt = 0;\\n } else if (onez == n) {\\n cnt = n;\\n } else {\\n if (v == 1) {\\n cnt = 1 + onez;\\n } else {\\n cnt = v + onez;\\n }\\n }\\n if (v == 1 && onez == 0) {\\n cnt = 0;\\n }\\n int ones = 0;\\n for (int i = 1; i <= n; ++i) {\\n ones += arr2[i];\\n }\\n if (!(ones & 1)) {\\n ++cnt;\\n }\\n cout << cnt << endl;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given two integers l and r, l≤ r. Find the largest possible value of a mod b over all pairs (a, b) of integers for which r≥ a ≥ b ≥ l.\\n\\nAs a reminder, a mod b is a remainder we get when dividing a by b. For example, 26 mod 8 = 2.\\n\\nInput\\n\\nEach test contains multiple test cases.\\n\\nThe first line contains one positive integer t (1≤ t≤ 10^4), denoting the number of test cases. Description of the test cases follows.\\n\\nThe only line of each test case contains two integers l, r (1≤ l ≤ r ≤ 10^9).\\n\\nOutput\\n\\nFor every test case, output the largest possible value of a mod b over all pairs (a, b) of integers for which r≥ a ≥ b ≥ l.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n1 1\\n999999999 1000000000\\n8 26\\n1 999999999\\n\\n\\nOutput\\n\\n\\n0\\n1\\n12\\n499999999\\n\\nNote\\n\\nIn the first test case, the only allowed pair is (a, b) = (1, 1), for which a mod b = 1 mod 1 = 0.\\n\\nIn the second test case, the optimal choice is pair (a, b) = (1000000000, 999999999), for which a mod b = 1.\\nSolve the task in JAVA.\",\"targets\":\"import java.util.*; \\/\\/ Implicit import\\nimport java.io.*;\\nimport java.math.BigInteger; \\/\\/ Explicit import\\n\\npublic class A {\\n\\n\\tstatic FastReader\\t\\tsc\\t= new FastReader();\\n\\tstatic PrintWriter\\tout\\t= new PrintWriter(System.out);\\n\\n\\n\\tpublic static void main(String[] args) throws Exception {\\n\\n\\t\\tint t = sc.ni();\\n\\t\\twhile (t-- > 0) {\\n\\t\\t\\tA.go();\\n\\t\\t}\\n\\t\\tout.flush();\\n\\n\\t}\\n\\n\\t\\/\\/ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Code Starts <<<<<<<<<<<<<<<<<<<<<<<<<<<<< \\/\\/\\n static void go() {\\n\\t long l=sc.ni();\\n\\t long r=sc.ni();\\n\\t if(l==r) {\\n\\t\\t out.println(0);\\n\\t\\t return;\\n\\t }\\n\\t\\/\\/ a=b+x;\\n\\tif((r-l)==1) {\\n\\t\\tout.println(r%l);\\n\\t\\treturn;\\n\\t}\\n\\n\\t\\tif(l>r\\/2) {\\n\\t\\t\\tout.println(r%(l));\\n\\t\\t}else {\\n\\t\\t\\tout.println(r%(r\\/2+1));\\n\\t\\t}\\n\\t\\n\\t\\n}\\n\\n\\t\\/\\/ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Code Ends <<<<<<<<<<<<<<<<<<<<<<<<<<<<< \\/\\/\\n\\tstatic long\\tfact[];\\n\\tstatic long\\tinvfact[];\\n\\n\\tstatic long ncr(int n, int k) {\\n\\t\\tif (k < 0 || k > n) {\\n\\t\\t\\treturn 0;\\n\\t\\t}\\n\\t\\tlong x = fact[n] % mod;\\n\\t\\tlong y = invfact[k] % mod;\\n\\t\\tlong yy = invfact[n - k] % mod;\\n\\t\\tlong ans = (x * y) % mod;\\n\\t\\tans = (ans * yy) % mod;\\n\\t\\treturn ans;\\n\\t}\\n\\n\\tstatic long gcd(long a, long b) {\\n\\t\\tif (b == 0) {\\n\\t\\t\\treturn a;\\n\\t\\t}\\n\\t\\treturn gcd(b, a % b);\\n\\t}\\n\\n\\tstatic int\\tprime[]\\t= new int[200005];\\n\\tstatic int\\tN\\t\\t\\t\\t= 200005;\\n\\n\\tstatic void sieve() {\\n\\n\\t\\tfor (int i = 0; i < N; i++) {\\n\\t\\t\\tprime[i] = i;\\n\\t\\t}\\n\\t\\tfor (int i = 2; i * i <= N; i++) {\\n\\t\\t\\tif (prime[i] == i) {\\n\\t\\t\\t\\tprime[i] = i;\\n\\t\\t\\t\\tfor (int j = i; j < N; j += i) {\\n\\t\\t\\t\\t\\tprime[j] = i;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n\\tstatic int gcd(int a, int b) {\\n\\t\\tif (b == 0) {\\n\\t\\t\\treturn a;\\n\\t\\t}\\n\\t\\treturn gcd(b, a % b);\\n\\t}\\n\\n\\tstatic void sort(int[] a) {\\n\\t\\tArrayList aa = new ArrayList<>();\\n\\t\\tfor (Integer i : a) {\\n\\t\\t\\taa.add(i);\\n\\t\\t}\\n\\t\\tCollections.sort(aa);\\n\\t\\tfor (int i = 0; i < a.length; i++)\\n\\t\\t\\ta[i] = aa.get(i);\\n\\t}\\n\\n\\tstatic void sort(long[] a) {\\n\\t\\tArrayList aa = new ArrayList<>();\\n\\t\\tfor (Long i : a) {\\n\\t\\t\\taa.add(i);\\n\\t\\t}\\n\\t\\tCollections.sort(aa);\\n\\t\\tfor (int i = 0; i < a.length; i++)\\n\\t\\t\\ta[i] = aa.get(i);\\n\\t}\\n\\n\\tstatic int mod = (int) 1000000007;\\n\\n\\tstatic long pow(long x, long y) {\\n\\t\\tlong res = 1l;\\n\\t\\twhile (y != 0)...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"In this problem you will meet the simplified model of game King of Thieves.\\n\\nIn a new ZeptoLab game called \\\"King of Thieves\\\" your aim is to reach a chest with gold by controlling your character, avoiding traps and obstacles on your way.\\n\\n\\n\\nAn interesting feature of the game is that you can design your own levels that will be available to other players. Let's consider the following simple design of a level.\\n\\nA dungeon consists of n segments located at a same vertical level, each segment is either a platform that character can stand on, or a pit with a trap that makes player lose if he falls into it. All segments have the same length, platforms on the scheme of the level are represented as '*' and pits are represented as '.'. \\n\\nOne of things that affects speedrun characteristics of the level is a possibility to perform a series of consecutive jumps of the same length. More formally, when the character is on the platform number i1, he can make a sequence of jumps through the platforms i1 < i2 < ... < ik, if i2 - i1 = i3 - i2 = ... = ik - ik - 1. Of course, all segments i1, i2, ... ik should be exactly the platforms, not pits. \\n\\nLet's call a level to be good if you can perform a sequence of four jumps of the same length or in the other words there must be a sequence i1, i2, ..., i5, consisting of five platforms so that the intervals between consecutive platforms are of the same length. Given the scheme of the level, check if it is good.\\n\\nInput\\n\\nThe first line contains integer n (1 ≤ n ≤ 100) — the number of segments on the level.\\n\\nNext line contains the scheme of the level represented as a string of n characters '*' and '.'.\\n\\nOutput\\n\\nIf the level is good, print the word \\\"yes\\\" (without the quotes), otherwise print the word \\\"no\\\" (without the quotes).\\n\\nExamples\\n\\nInput\\n\\n16\\n.**.*..*.***.**.\\n\\n\\nOutput\\n\\nyes\\n\\nInput\\n\\n11\\n.*.*...*.*.\\n\\n\\nOutput\\n\\nno\\n\\nNote\\n\\nIn the first sample test you may perform a sequence of jumps through platforms 2, 5, 8, 11, 14.\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int n;\\n cin >> n;\\n string inp;\\n cin >> inp;\\n string a;\\n for (int i = 0; i < inp.size(); ++i) {\\n if (inp[i] == '*') {\\n for (int length = 1; length <= inp.size(); ++length) {\\n int k = 0;\\n for (int j = i + length; j < inp.size(); j += length) {\\n if (inp[j] != '*')\\n break;\\n else\\n k++;\\n }\\n if (k >= 4) {\\n a = \\\"yes\\\";\\n goto end;\\n }\\n }\\n }\\n }\\n a = \\\"no\\\";\\nend:;\\n cout << a << '\\\\n';\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"The robot is located on a checkered rectangular board of size n × m (n rows, m columns). The rows in the board are numbered from 1 to n from top to bottom, and the columns — from 1 to m from left to right.\\n\\nThe robot is able to move from the current cell to one of the four cells adjacent by side.\\n\\nEach cell has one of the symbols 'L', 'R', 'D' or 'U' written on it, indicating the direction in which the robot will move when it gets in that cell — left, right, down or up, respectively.\\n\\nThe robot can start its movement in any cell. He then moves to the adjacent square in the direction indicated on the current square in one move. \\n\\n * If the robot moves beyond the edge of the board, it falls and breaks. \\n * If the robot appears in the cell it already visited before, it breaks (it stops and doesn't move anymore). \\n\\n\\n\\nRobot can choose any cell as the starting cell. Its goal is to make the maximum number of steps before it breaks or stops.\\n\\nDetermine from which square the robot should start its movement in order to execute as many commands as possible. A command is considered successfully completed if the robot has moved from the square on which that command was written (it does not matter whether to another square or beyond the edge of the board).\\n\\nInput\\n\\nThe first line contains an integer t (1 ≤ t ≤ 10000) — the number of test cases in the test.\\n\\nEach test case's description is preceded by a blank line. Next is a line that contains integers n and m (1 ≤ n ≤ 2000; 1 ≤ m ≤ 2000) — the height and width of the board. This line followed by n lines, the i-th of which describes the i-th line of the board. Each of them is exactly m letters long and consists of symbols 'L', 'R', 'D' and 'U'.\\n\\nIt is guaranteed that the sum of sizes of all boards in the input does not exceed 4⋅10^6.\\n\\nOutput\\n\\nFor each test case, output three integers r, c and d (1 ≤ r ≤ n; 1 ≤ c ≤ m; d ≥ 0), which denote that the robot should start moving from cell (r, c) to make the maximum number of moves d. If there are several answers, output any of...\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nbool CustomCompareF(const pair &,\\n const pair &);\\nstruct CustomCompareS {\\n bool operator()(const pair &,\\n const pair &);\\n};\\nlong long int modmul(long long int, long long int);\\nlong long int modadd(long long int, long long int);\\nlong long int modsub(long long int, long long int);\\nlong long int moddiv(long long int, long long int);\\nlong long int ncr(long long int, long long int);\\nlong long int fpow(long long int x, long long int y,\\n long long int p = 1000000007);\\nvector fact(5000005, 0);\\nvoid facto();\\ntemplate \\nostream &operator<<(ostream &os, pair P);\\ntemplate \\nostream &operator<<(ostream &os, vector V);\\ntemplate \\nostream &operator<<(ostream &os, set second);\\ntemplate \\nostream &operator<<(ostream &os, unordered_set second);\\ntemplate \\nostream &operator<<(ostream &os, map second);\\ntemplate \\nostream &operator<<(ostream &os, unordered_map second);\\nint n, m;\\nvector mat;\\nvector > dp, vis, perm;\\nint t;\\nint inRange(int r, int c) { return r >= 0 && r < n && c >= 0 && c < m; }\\npair get_p(char c) {\\n switch (c) {\\n case 'U':\\n return {-1, 0};\\n case 'D':\\n return {1, 0};\\n case 'R':\\n return {0, 1};\\n case 'L':\\n return {0, -1};\\n }\\n return {-1, -1};\\n}\\nvoid markCycle(int r, int c, int length) {\\n int nextr = r, nextc = c;\\n do {\\n vis[nextr][nextc] = 0;\\n dp[nextr][nextc] = length;\\n pair next = get_p(mat[nextr][nextc]);\\n nextr = nextr + next.first;\\n nextc = nextc + next.second;\\n } while (!(nextr == r && nextc == c));\\n}\\nvoid dfs(int r, int c) {\\n int r1 = r, c1 = c;\\n while (inRange(r, c) && !perm[r][c]) {\\n if (vis[r][c]) {\\n markCycle(r, c, t -...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You have an array of integers (initially empty).\\n\\nYou have to perform q queries. Each query is of one of two types: \\n\\n * \\\"1 x\\\" — add the element x to the end of the array; \\n * \\\"2 x y\\\" — replace all occurrences of x in the array with y. \\n\\n\\n\\nFind the resulting array after performing all the queries.\\n\\nInput\\n\\nThe first line contains a single integer q (1 ≤ q ≤ 5 ⋅ 10^5) — the number of queries.\\n\\nNext q lines contain queries (one per line). Each query is of one of two types: \\n\\n * \\\"1 x\\\" (1 ≤ x ≤ 5 ⋅ 10^5); \\n * \\\"2 x y\\\" (1 ≤ x, y ≤ 5 ⋅ 10^5). \\n\\n\\n\\nIt's guaranteed that there is at least one query of the first type.\\n\\nOutput\\n\\nIn a single line, print k integers — the resulting array after performing all the queries, where k is the number of queries of the first type.\\n\\nExamples\\n\\nInput\\n\\n\\n7\\n1 3\\n1 1\\n2 1 2\\n1 2\\n1 1\\n1 2\\n2 1 3\\n\\n\\nOutput\\n\\n\\n3 2 2 3 2 \\n\\nInput\\n\\n\\n4\\n1 1\\n1 2\\n1 1\\n2 2 2\\n\\n\\nOutput\\n\\n\\n1 2 1 \\n\\nInput\\n\\n\\n8\\n2 1 4\\n1 1\\n1 4\\n1 2\\n2 2 4\\n2 4 3\\n1 2\\n2 2 7\\n\\n\\nOutput\\n\\n\\n1 3 3 7 \\n\\nNote\\n\\nIn the first example, the array changes as follows:\\n\\n[] → [3] → [3, 1] → [3, 2] → [3, 2, 2] → [3, 2, 2, 1] → [3, 2, 2, 1, 2] → [3, 2, 2, 3, 2].\\n\\nIn the second example, the array changes as follows:\\n\\n[] → [1] → [1, 2] → [1, 2, 1] → [1, 2, 1].\\n\\nIn the third example, the array changes as follows:\\n\\n[] → [] → [1] → [1, 4] → [1, 4, 2] → [1, 4, 4] → [1, 3, 3] → [1, 3, 3, 2] → [1, 3, 3, 7].\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\ntemplate \\nusing vc = vector;\\ntemplate \\nusing vvc = vc>;\\ntemplate \\nvoid mkuni(vector& v) {\\n sort(v.begin(), v.end());\\n v.erase(unique(v.begin(), v.end()), v.end());\\n}\\ntemplate \\nvoid print(T x, int suc = 1) {\\n cout << x;\\n if (suc == 1)\\n cout << '\\\\n';\\n else\\n cout << ' ';\\n}\\ntemplate \\nvoid print(const vector& v, int suc = 1) {\\n for (int i = 0; i < v.size(); i++)\\n print(v[i], i == (int)(v.size()) - 1 ? suc : 2);\\n}\\nint dp[500050];\\npair a[500050];\\nint main() {\\n ios::sync_with_stdio(false);\\n cin.tie(nullptr);\\n int q;\\n cin >> q;\\n for (int i = 1, op; i <= q; ++i) {\\n cin >> op;\\n if (op == 1) {\\n int x;\\n cin >> x;\\n a[i] = {x, -1};\\n } else {\\n int x, y;\\n cin >> x >> y;\\n a[i] = {x, y};\\n }\\n }\\n vector ans;\\n for (int i = q; i >= 1; --i) {\\n if (a[i].second == -1) {\\n if (dp[a[i].first] == 0)\\n ans.push_back(a[i].first), dp[a[i].first] = a[i].first;\\n else\\n ans.push_back(dp[a[i].first]);\\n } else {\\n int x = a[i].first, y = a[i].second;\\n if (dp[y] == 0) dp[y] = y;\\n dp[x] = dp[y];\\n }\\n }\\n reverse(ans.begin(), ans.end());\\n print(ans);\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given N points on an infinite plane with the Cartesian coordinate system on it. N-1 points lay on one line, and one point isn't on that line. You are on point K at the start, and the goal is to visit every point. You can move between any two points in a straight line, and you can revisit points. What is the minimum length of the path? \\n\\nInput\\n\\nThe first line contains two integers: N (3 ≤ N ≤ 2*10^5) - the number of points, and K (1 ≤ K ≤ N) - the index of the starting point.\\n\\nEach of the next N lines contain two integers, A_i, B_i (-10^6 ≤ A_i, B_i ≤ 10^6) - coordinates of the i-th point.\\n\\nOutput\\n\\nThe output contains one number - the shortest path to visit all given points starting from point K. The absolute difference between your solution and the main solution shouldn't exceed 10^-6;\\n\\nExample\\n\\nInput\\n\\n\\n5 2\\n0 0\\n-1 1\\n2 -2\\n0 1\\n-2 2\\n\\n\\nOutput\\n\\n\\n7.478709\\n\\nNote\\n\\nThe shortest path consists of these moves: \\n\\n2 -> 5 \\n\\n5 -> 4 \\n\\n4 -> 1 \\n\\n1 -> 3 \\n\\nThere isn't any shorter path possible.\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nint N, M;\\npair arr[200005], s;\\nlong double dist(int a, int b) {\\n return sqrt((arr[a].first - arr[b].first) * (arr[a].first - arr[b].first) +\\n (arr[a].second - arr[b].second) *\\n (arr[a].second - arr[b].second));\\n}\\nbool chk(int a, int b, int c) {\\n return ((arr[b].first - arr[a].first) * (arr[c].second - arr[a].second) -\\n (arr[c].first - arr[a].first) * (arr[b].second - arr[a].second)) == 0;\\n}\\nint main() {\\n cin >> N >> M;\\n for (int i = 1; i <= N; ++i) {\\n cin >> arr[i].first >> arr[i].second;\\n }\\n s = arr[M];\\n if (chk(1, 2, 3)) {\\n for (int i = 4; i <= N; ++i) {\\n if (!chk(1, 2, i)) {\\n swap(arr[i], arr[N]);\\n break;\\n }\\n }\\n } else if (N > 3) {\\n if (chk(1, 2, 4)) {\\n swap(arr[3], arr[N]);\\n } else if (chk(1, 3, 4)) {\\n swap(arr[2], arr[N]);\\n } else {\\n swap(arr[1], arr[N]);\\n }\\n }\\n sort(arr + 1, arr + N);\\n for (int i = 1; i <= N; ++i) {\\n if (arr[i] == s) M = i;\\n }\\n cout << setprecision(10) << fixed;\\n if (M == N) {\\n cout << min(dist(1, N), dist(N - 1, N)) + dist(1, N - 1) << endl;\\n return 0;\\n }\\n long double ans = dist(1, N - 1) + min(dist(1, M) + dist(N - 1, N),\\n dist(M, N - 1) + dist(1, N));\\n for (int i = 1; i < N - 1; ++i) {\\n int A = i;\\n int B = i + 1;\\n int C = 1;\\n int D = N - 1;\\n if (i < M) {\\n swap(A, B);\\n swap(C, D);\\n }\\n ans = min(\\n ans,\\n min(dist(M, A) + dist(A, C) + dist(C, N) + dist(N, B) + dist(B, D),\\n dist(M, C) + dist(C, A) + dist(A, N) + dist(N, B) + dist(B, D)));\\n }\\n cout << ans << endl;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nThe robot is located on a checkered rectangular board of size n × m (n rows, m columns). The rows in the board are numbered from 1 to n from top to bottom, and the columns — from 1 to m from left to right.\\n\\nThe robot is able to move from the current cell to one of the four cells adjacent by side.\\n\\nEach cell has one of the symbols 'L', 'R', 'D' or 'U' written on it, indicating the direction in which the robot will move when it gets in that cell — left, right, down or up, respectively.\\n\\nThe robot can start its movement in any cell. He then moves to the adjacent square in the direction indicated on the current square in one move. \\n\\n * If the robot moves beyond the edge of the board, it falls and breaks. \\n * If the robot appears in the cell it already visited before, it breaks (it stops and doesn't move anymore). \\n\\n\\n\\nRobot can choose any cell as the starting cell. Its goal is to make the maximum number of steps before it breaks or stops.\\n\\nDetermine from which square the robot should start its movement in order to execute as many commands as possible. A command is considered successfully completed if the robot has moved from the square on which that command was written (it does not matter whether to another square or beyond the edge of the board).\\n\\nInput\\n\\nThe first line contains an integer t (1 ≤ t ≤ 10000) — the number of test cases in the test.\\n\\nEach test case's description is preceded by a blank line. Next is a line that contains integers n and m (1 ≤ n ≤ 2000; 1 ≤ m ≤ 2000) — the height and width of the board. This line followed by n lines, the i-th of which describes the i-th line of the board. Each of them is exactly m letters long and consists of symbols 'L', 'R', 'D' and 'U'.\\n\\nIt is guaranteed that the sum of sizes of all boards in the input does not exceed 4⋅10^6.\\n\\nOutput\\n\\nFor each test case, output three integers r, c and d (1 ≤ r ≤ n; 1 ≤ c ≤ m; d ≥ 0), which denote that the robot should start moving from cell (r, c) to make the maximum number of moves d. If there are several answers, output any of...\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 2010;\\nint n, m, cnt;\\nint dist[N][N];\\nbool st[N][N];\\nchar g[N][N];\\npair p[N * N];\\nint dfs(int first, int second) {\\n p[++cnt] = {first, second};\\n if (first < 1 || first > n || second < 1 || second > m || st[first][second])\\n return dist[first][second];\\n st[first][second] = true;\\n auto &k = dist[first][second];\\n if (g[first][second] == 'U') k = dfs(first - 1, second) + 1;\\n if (g[first][second] == 'D') k = dfs(first + 1, second) + 1;\\n if (g[first][second] == 'L') k = dfs(first, second - 1) + 1;\\n if (g[first][second] == 'R') k = dfs(first, second + 1) + 1;\\n return dist[first][second];\\n}\\nvoid solve() {\\n cin >> n >> m;\\n for (int i = 1; i <= n; i++)\\n for (int j = 1; j <= m; j++) cin >> g[i][j];\\n for (int i = 0; i <= n + 5; i++)\\n for (int j = 0; j <= m + 5; j++) st[i][j] = false, dist[i][j] = 0;\\n for (int i = 1; i <= n; i++)\\n for (int j = 1; j <= m; j++) {\\n if (!st[i][j]) {\\n cnt = 0;\\n dfs(i, j);\\n pair t = p[cnt];\\n for (int k = 1; k <= cnt; k++)\\n if (t == p[k]) {\\n for (int h = k; h < cnt; h++)\\n dist[p[h].first][p[h].second] = cnt - k;\\n }\\n }\\n }\\n int first = 0, second = 0, res = 0;\\n for (int i = 1; i <= n; i++)\\n for (int j = 1; j <= m; j++)\\n if (dist[i][j] > res) first = i, second = j, res = dist[i][j];\\n cout << first << \\\" \\\" << second << \\\" \\\" << res << endl;\\n}\\nint main() {\\n int T;\\n cin >> T;\\n while (T--) solve();\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given n integers a_1, a_2, …, a_n. Find the maximum value of max(a_l, a_{l + 1}, …, a_r) ⋅ min(a_l, a_{l + 1}, …, a_r) over all pairs (l, r) of integers for which 1 ≤ l < r ≤ n.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10 000) — the number of test cases.\\n\\nThe first line of each test case contains a single integer n (2 ≤ n ≤ 10^5).\\n\\nThe second line of each test case contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^6).\\n\\nIt is guaranteed that the sum of n over all test cases doesn't exceed 3 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print a single integer — the maximum possible value of the product from the statement.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n2 4 3\\n4\\n3 2 3 1\\n2\\n69 69\\n6\\n719313 273225 402638 473783 804745 323328\\n\\n\\nOutput\\n\\n\\n12\\n6\\n4761\\n381274500335\\n\\nNote\\n\\nLet f(l, r) = max(a_l, a_{l + 1}, …, a_r) ⋅ min(a_l, a_{l + 1}, …, a_r).\\n\\nIn the first test case, \\n\\n * f(1, 2) = max(a_1, a_2) ⋅ min(a_1, a_2) = max(2, 4) ⋅ min(2, 4) = 4 ⋅ 2 = 8. \\n * f(1, 3) = max(a_1, a_2, a_3) ⋅ min(a_1, a_2, a_3) = max(2, 4, 3) ⋅ min(2, 4, 3) = 4 ⋅ 2 = 8. \\n * f(2, 3) = max(a_2, a_3) ⋅ min(a_2, a_3) = max(4, 3) ⋅ min(4, 3) = 4 ⋅ 3 = 12. \\n\\n\\n\\nSo the maximum is f(2, 3) = 12.\\n\\nIn the second test case, the maximum is f(1, 2) = f(1, 3) = f(2, 3) = 6.\\nimpor\",\"targets\":\"t java.io.*;\\nimport java.util.*;\\n\\npublic class Main{\\n\\tstatic void main() throws Exception{\\n\\t int n=sc.nextInt();\\n\\t\\tlong ans=0;\\n\\t\\tlong prev=sc.nextInt();\\n\\t\\tfor(int i=1;i\\nusing namespace std;\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n int t;\\n cin >> t;\\n while (t--) {\\n long long int x;\\n cin >> x;\\n if (x % 3 == 0) {\\n cout << x \\/ 3 << \\\" \\\" << x \\/ 3 << '\\\\n';\\n } else {\\n long long temp = x \\/ 3 + 1;\\n long long temp2 = x \\/ 3;\\n if (temp + 2 * temp2 == x) {\\n cout << temp << \\\" \\\" << temp2 << '\\\\n';\\n } else\\n cout << temp2 << \\\" \\\" << temp << '\\\\n';\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A two dimensional array is called a bracket array if each grid contains one of the two possible brackets — \\\"(\\\" or \\\")\\\". A path through the two dimensional array cells is called monotonous if any two consecutive cells in the path are side-adjacent and each cell of the path is located below or to the right from the previous one. \\n\\nA two dimensional array whose size equals n × m is called a correct bracket array, if any string formed by writing out the brackets on some monotonous way from cell (1, 1) to cell (n, m) forms a correct bracket sequence. \\n\\nLet's define the operation of comparing two correct bracket arrays of equal size (a and b) like that. Let's consider a given two dimensional array of priorities (c) — a two dimensional array of same size, containing different integers from 1 to nm. Let's find such position (i, j) in the two dimensional array, that ai, j ≠ bi, j. If there are several such positions, let's choose the one where number ci, j is minimum. If ai, j = \\\"(\\\", then a < b, otherwise a > b. If the position (i, j) is not found, then the arrays are considered equal.\\n\\nYour task is to find a k-th two dimensional correct bracket array. It is guaranteed that for the given sizes of n and m there will be no less than k two dimensional correct bracket arrays.\\n\\nInput\\n\\nThe first line contains integers n, m and k — the sizes of the array and the number of the sought correct bracket array (1 ≤ n, m ≤ 100, 1 ≤ k ≤ 1018). Then an array of priorities is given, n lines each containing m numbers, number pi, j shows the priority of character j in line i (1 ≤ pi, j ≤ nm, all pi, j are different).\\n\\nPlease do not use the %lld specificator to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specificator.\\n\\nOutput\\n\\nPrint the k-th two dimensional correct bracket array.\\n\\nExamples\\n\\nInput\\n\\n1 2 1\\n1 2\\n\\n\\nOutput\\n\\n()\\n\\n\\nInput\\n\\n2 3 1\\n1 2 3\\n4 5 6\\n\\n\\nOutput\\n\\n(()\\n())\\n\\n\\nInput\\n\\n3 2 2\\n3 6\\n1 4\\n2 5\\n\\n\\nOutput\\n\\n()\\n)(\\n()\\n\\nNote\\n\\nIn the first sample exists only one correct two-dimensional bracket...\\nimpor\",\"targets\":\"t java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.io.PrintWriter;\\nimport java.util.StringTokenizer;\\n\\npublic class C {\\n\\n static BufferedReader bf = new BufferedReader(new InputStreamReader(\\n System.in));\\n static StringTokenizer st;\\n static PrintWriter out = new PrintWriter(System.out);\\n\\n static String nextToken() throws IOException {\\n while (st == null || !st.hasMoreTokens()) {\\n String s = bf.readLine();\\n if (s == null)\\n return null;\\n st = new StringTokenizer(s);\\n }\\n\\n return st.nextToken();\\n }\\n\\n static int nextInt() throws IOException {\\n return Integer.parseInt(nextToken());\\n }\\n\\n static long nextLong() throws IOException {\\n return Long.parseLong(nextToken());\\n }\\n\\n static String nextStr() throws IOException {\\n return nextToken();\\n }\\n\\n static double nextDouble() throws IOException {\\n return Double.parseDouble(nextToken());\\n }\\n \\n static long f(char s[], long k, long a[][], int d, int p) {\\n if (d > p + 1) {\\n return 0;\\n }\\n if (p == 0) {\\n if (d == 1) {\\n return 1;\\n } else {\\n return 0;\\n }\\n }\\n \\n if (a[d][p] != Long.MAX_VALUE) {\\n return a[d][p];\\n }\\n \\n long res = 0;\\n if (s[p] == '(') {\\n if (d != 0) {\\n res = f(s, k, a, d - 1, p - 1);\\n }\\n } else if (s[p] == ')') {\\n res = f(s, k, a, d + 1, p - 1);\\n } else {\\n if (d != 0) {\\n res = f(s, k, a, d - 1, p - 1) + f(s, k, a, d + 1, p - 1);\\n } else {\\n res = f(s, k, a, d + 1, p - 1);\\n }\\n }\\n \\n if (res > k) {\\n a[d][p] = k + 1;\\n } else {\\n a[d][p] = res;\\n }\\n \\n return a[d][p];\\n }\\n\\n public static void main(String[] args) throws IOException...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"An important meeting is to be held and there are exactly n people invited. At any moment, any two people can step back and talk in private. The same two people can talk several (as many as they want) times per meeting.\\n\\nEach person has limited sociability. The sociability of the i-th person is a non-negative integer a_i. This means that after exactly a_i talks this person leaves the meeting (and does not talk to anyone else anymore). If a_i = 0, the i-th person leaves the meeting immediately after it starts.\\n\\nA meeting is considered most productive if the maximum possible number of talks took place during it.\\n\\nYou are given an array of sociability a, determine which people should talk to each other so that the total number of talks is as large as possible.\\n\\nInput\\n\\nThe first line contains an integer t (1 ≤ t ≤ 1000) — the number of test cases.\\n\\nThe next 2t lines contain descriptions of the test cases.\\n\\nThe first line of each test case description contains an integer n (2 ≤ n ≤ 2 ⋅ 10^5) —the number of people in the meeting. The second line consists of n space-separated integers a_1, a_2, ..., a_n (0 ≤ a_i ≤ 2 ⋅ 10^5) — the sociability parameters of all people. \\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5. It is also guaranteed that the sum of all a_i (over all test cases and all i) does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nPrint t answers to all test cases.\\n\\nOn the first line of each answer print the number k — the maximum number of talks possible in a meeting.\\n\\nOn each of the next k lines print two integers i and j (1 ≤ i, j ≤ n and i ≠ j) — the numbers of people who will have another talk.\\n\\nIf there are several possible answers, you may print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n8\\n2\\n2 3\\n3\\n1 2 3\\n4\\n1 2 3 4\\n3\\n0 0 2\\n2\\n6 2\\n3\\n0 0 2\\n5\\n8 2 0 1 1\\n5\\n0 1 0 0 6\\n\\n\\nOutput\\n\\n\\n2\\n1 2\\n1 2\\n3\\n1 3\\n2 3\\n2 3\\n5\\n1 3\\n2 4\\n2 4\\n3 4\\n3 4\\n0\\n2\\n1 2\\n1 2\\n0\\n4\\n1 2\\n1 5\\n1 4\\n1 2\\n1\\n5 2\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\n\\npublic class D {\\n\\n\\tpublic static void main(String[] args) throws IOException {\\n\\t\\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\\n\\t\\tStringBuilder bw = new StringBuilder();\\n\\t\\tint TC = Integer.parseInt(br.readLine());\\n\\t\\twhile (TC-- > 0) {\\n\\t\\t\\tint N = Integer.parseInt(br.readLine());\\n\\t\\t\\tPriorityQueue pq = new PriorityQueue<>();\\n\\t\\t\\tStringTokenizer st = new StringTokenizer(br.readLine(), \\\" \\\");\\n\\t\\t\\tfor (int i = 1; i <= N; i++) {\\n\\t\\t\\t\\tint x = Integer.parseInt(st.nextToken());\\n\\t\\t\\t\\tif (x > 0) pq.offer(new Pair(i, x));\\n\\t\\t\\t}\\n\\t\\t\\tint t = 0;\\n\\t\\t\\tStringBuilder temp = new StringBuilder();\\n\\t\\t\\twhile (pq.size() >= 2) {\\n\\t\\t\\t\\tPair p = pq.poll();\\n\\t\\t\\t\\tPair q = pq.poll();\\n\\t\\t\\t\\ttemp.append(String.format(\\\"%d %d\\\\n\\\", p.index, q.index));\\n\\t\\t\\t\\tif (--p.value > 0) pq.offer(p);\\n\\t\\t\\t\\tif (--q.value > 0) pq.offer(q);\\n\\t\\t\\t\\tt++;\\n\\t\\t\\t}\\n\\t\\t\\tbw.append(t).append(\\\"\\\\n\\\");\\n\\t\\t\\tbw.append(temp);\\n\\t\\t}\\n\\t\\tSystem.out.print(bw);\\n\\t}\\n\\n}\\nclass Pair implements Comparable {\\n\\tint index, value;\\n\\n\\tPair(int i, int v) { index = i; value = v; }\\n\\n\\t@Override\\n\\tpublic int compareTo(Pair o) { return o.value - value; }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A country has a budget of more than 81 trillion yen. We want to process such data, but conventional integer type which uses signed 32 bit can represent up to 2,147,483,647.\\n\\nYour task is to write a program which reads two integers (more than or equal to zero), and prints a sum of these integers.\\n\\nIf given integers or the sum have more than 80 digits, print \\\"overflow\\\".\\n\\n\\n\\nInput\\n\\nInput consists of several datasets. In the first line, the number of datasets N (1 ≤ N ≤ 50) is given. Each dataset consists of 2 lines:\\n\\n\\nThe first integer\\nThe second integer\\n\\n\\nThe integer has at most 100 digits.\\n\\nOutput\\n\\nFor each dataset, print the sum of given integers in a line.\\n\\nExample\\n\\nInput\\n\\n6\\n1000\\n800\\n9999999999999999999999999999999999999999\\n1\\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\\n1\\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\\n0\\n100000000000000000000000000000000000000000000000000000000000000000000000000000000\\n1\\n100000000000000000000000000000000000000000000000000000000000000000000000000000000\\n100000000000000000000000000000000000000000000000000000000000000000000000000000000\\n\\n\\nOutput\\n\\n1800\\n10000000000000000000000000000000000000000\\noverflow\\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\\noverflow\\noverflow\\nSolve the task in PYTHON3.\",\"targets\":\"n = int(input())\\nfor i in range(n):\\n\\ts = int(input())+int(input())\\n\\tif len(str(s))>80:\\n\\t\\tprint(\\\"overflow\\\")\\n\\telse:\\n\\t\\tprint(s)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"YouKn0wWho has two even integers x and y. Help him to find an integer n such that 1 ≤ n ≤ 2 ⋅ 10^{18} and n mod x = y mod n. Here, a mod b denotes the remainder of a after division by b. If there are multiple such integers, output any. It can be shown that such an integer always exists under the given constraints.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^5) — the number of test cases.\\n\\nThe first and only line of each test case contains two integers x and y (2 ≤ x, y ≤ 10^9, both are even).\\n\\nOutput\\n\\nFor each test case, print a single integer n (1 ≤ n ≤ 2 ⋅ 10^{18}) that satisfies the condition mentioned in the statement. If there are multiple such integers, output any. It can be shown that such an integer always exists under the given constraints.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n4 8\\n4 2\\n420 420\\n69420 42068\\n\\n\\nOutput\\n\\n\\n4\\n10\\n420\\n9969128\\n\\nNote\\n\\nIn the first test case, 4 mod 4 = 8 mod 4 = 0.\\n\\nIn the second test case, 10 mod 4 = 2 mod 10 = 2.\\n\\nIn the third test case, 420 mod 420 = 420 mod 420 = 0.\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\npriority_queue, greater> pq1, pq2;\\nlong long mod = 1000000007;\\nlong long power(long long a, long long b) {\\n long long res = 1;\\n while (b > 0) {\\n if (b % 2 != 0) res = (res * a) % mod;\\n b \\/= 2;\\n a = (a * a) % mod;\\n }\\n return res;\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n long long t, a, b, ans;\\n cin >> t;\\n while (t--) {\\n cin >> a >> b;\\n if (a == b) {\\n cout << a << endl;\\n continue;\\n }\\n if (a < b) {\\n long long st = b \\/ a;\\n long long st1 = b % a;\\n if (st1 == 0) {\\n st--;\\n }\\n long long num = b - st * a;\\n ans = st * a + num \\/ 2;\\n cout << ans << endl;\\n } else {\\n cout << a + b << endl;\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"\\\"Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score...\\\" — an excerpt from contest rules.\\n\\nA total of n participants took part in the contest (n ≥ k), and you already know their scores. Calculate how many participants will advance to the next round.\\n\\nInput\\n\\nThe first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 50) separated by a single space.\\n\\nThe second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 100), where ai is the score earned by the participant who got the i-th place. The given sequence is non-increasing (that is, for all i from 1 to n - 1 the following condition is fulfilled: ai ≥ ai + 1).\\n\\nOutput\\n\\nOutput the number of participants who advance to the next round.\\n\\nExamples\\n\\nInput\\n\\n8 5\\n10 9 8 7 7 7 5 5\\n\\n\\nOutput\\n\\n6\\n\\n\\nInput\\n\\n4 2\\n0 0 0 0\\n\\n\\nOutput\\n\\n0\\n\\nNote\\n\\nIn the first example the participant on the 5th place earned 7 points. As the participant on the 6th place also earned 7 points, there are 6 advancers.\\n\\nIn the second example nobody got a positive score.\\nUsing python3 can you solve the prior task?\",\"targets\":\"n, m = input().split()\\nm = int(m)\\ns = input().split()\\na = 0 \\nfor i in range(len(s)):\\n if int(s[i]) >= int(s[m-1]) and int(s[i]) != 0:\\n a += 1\\n else:\\n break\\nprint(a)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A girl named Xenia has a cupboard that looks like an arc from ahead. The arc is made of a semicircle with radius r (the cupboard's top) and two walls of height h (the cupboard's sides). The cupboard's depth is r, that is, it looks like a rectangle with base r and height h + r from the sides. The figure below shows what the cupboard looks like (the front view is on the left, the side view is on the right).\\n\\n\\n\\nXenia got lots of balloons for her birthday. The girl hates the mess, so she wants to store the balloons in the cupboard. Luckily, each balloon is a sphere with radius . Help Xenia calculate the maximum number of balloons she can put in her cupboard. \\n\\nYou can say that a balloon is in the cupboard if you can't see any part of the balloon on the left or right view. The balloons in the cupboard can touch each other. It is not allowed to squeeze the balloons or deform them in any way. You can assume that the cupboard's walls are negligibly thin.\\n\\nInput\\n\\nThe single line contains two integers r, h (1 ≤ r, h ≤ 107).\\n\\nOutput\\n\\nPrint a single integer — the maximum number of balloons Xenia can put in the cupboard.\\n\\nExamples\\n\\nInput\\n\\n1 1\\n\\n\\nOutput\\n\\n3\\n\\n\\nInput\\n\\n1 2\\n\\n\\nOutput\\n\\n5\\n\\n\\nInput\\n\\n2 1\\n\\n\\nOutput\\n\\n2\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int h, r;\\n while (cin >> r >> h) {\\n int ans = h \\/ r * 2;\\n h %= r;\\n if (h * 2 < r)\\n ans += 1;\\n else if (h * 2 >= sqrt(3) * r)\\n ans += 3;\\n else\\n ans += 2;\\n printf(\\\"%d\\\\n\\\", ans);\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Dmitry has an array of n non-negative integers a_1, a_2, ..., a_n.\\n\\nIn one operation, Dmitry can choose any index j (1 ≤ j ≤ n) and increase the value of the element a_j by 1. He can choose the same index j multiple times.\\n\\nFor each i from 0 to n, determine whether Dmitry can make the MEX of the array equal to exactly i. If it is possible, then determine the minimum number of operations to do it.\\n\\nThe MEX of the array is equal to the minimum non-negative integer that is not in the array. For example, the MEX of the array [3, 1, 0] is equal to 2, and the array [3, 3, 1, 4] is equal to 0.\\n\\nInput\\n\\nThe first line of input data contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases in the input. \\n\\nThe descriptions of the test cases follow.\\n\\nThe first line of the description of each test case contains a single integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the length of the array a.\\n\\nThe second line of the description of each test case contains n integers a_1, a_2, ..., a_n (0 ≤ a_i ≤ n) — elements of the array a.\\n\\nIt is guaranteed that the sum of the values n over all test cases in the test does not exceed 2⋅10^5.\\n\\nOutput\\n\\nFor each test case, output n + 1 integer — i-th number is equal to the minimum number of operations for which you can make the array MEX equal to i (0 ≤ i ≤ n), or -1 if this cannot be done.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n3\\n0 1 3\\n7\\n0 1 2 3 4 3 2\\n4\\n3 0 0 0\\n7\\n4 6 2 3 5 0 5\\n5\\n4 0 1 0 4\\n\\n\\nOutput\\n\\n\\n1 1 0 -1 \\n1 1 2 2 1 0 2 6 \\n3 0 1 4 3 \\n1 0 -1 -1 -1 -1 -1 -1 \\n2 1 0 2 -1 -1 \\n\\nNote\\n\\nIn the first set of example inputs, n=3:\\n\\n * to get MEX=0, it is enough to perform one increment: a_1++; \\n * to get MEX=1, it is enough to perform one increment: a_2++; \\n * MEX=2 for a given array, so there is no need to perform increments; \\n * it is impossible to get MEX=3 by performing increments. \\nUsing java can you solve the prior task?\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\npublic class Main {\\n\\t\\tstatic long mod = 1000000007;\\n\\t\\tstatic PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));\\n\\t\\tpublic static void main(String[] args) throws IOException {\\n\\t\\t\\tFastReader sc = new FastReader();\\n\\t\\t\\tint t = sc.nextInt();\\n\\t\\t\\twhile( t-- > 0) {\\n\\t\\t\\t\\t\\/*\\n\\t\\t\\t\\t * i will make a count which will store the number that are less than euqual to cur and avail\\n\\t\\t\\t\\t * if will carray a boolean that will tell if that is true for the previous one\\n\\t\\t\\t\\t *\\/\\n\\t\\t\\t\\tint n = sc.nextInt();\\n\\t\\t\\t\\tHashMap hm = new HashMap<>();\\n\\t\\t\\t\\tfor( int i = 0 ;i <= n ;i++) {\\n\\t\\t\\t\\t\\thm.put((long)i, 0L);\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tfor( int i = 0 ;i< n ;i++) {\\n\\t\\t\\t\\t\\tlong temp = sc.nextLong();\\n\\t\\t\\t\\t\\thm.put(temp, hm.get(temp)+1);\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tboolean x = true;\\n\\t\\t\\t\\tlong tem = 0;\\n\\t\\t\\t\\tPriorityQueue count = new PriorityQueue<>(Collections.reverseOrder());\\n\\t\\t\\t\\tlong c= 0;\\n\\t\\t\\t\\tfor( int i = 0 ;i <= n ; i++) {\\n\\t\\t\\t\\t\\tif( x) {\\n\\t\\t\\t\\t\\t\\tlong temp = hm.get((long)i);\\n\\t\\t\\t\\t\\t\\tout.print((temp+ tem) + \\\" \\\");\\n\\t\\t\\t\\t\\t\\tif( temp \\t== 0) {\\n\\t\\t\\t\\t\\t\\t\\tif( c == 0) {\\n\\t\\t\\t\\t\\t\\t\\t\\tx = false;\\n\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\telse {\\n\\t\\t\\t\\t\\t\\t\\t\\tc--;\\n\\t\\t\\t\\t\\t\\t\\t\\ttem+= (i - count.poll()); \\n\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\telse {\\n\\t\\t\\t\\t\\t\\t\\tfor( int j = 0 ;j< temp -1 ; j++) {\\n\\t\\t\\t\\t\\t\\t\\t\\tcount.add((long)i);\\n\\t\\t\\t\\t\\t\\t\\t\\tc++;\\n\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\telse {\\n\\t\\t\\t\\t\\t\\tout.print(-1 + \\\" \\\");\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tout.println();\\n\\t\\t\\t}\\n\\t\\t\\tout.flush();\\n\\t\\t}\\n\\t\\t\\/*\\n\\t\\t * WARNING -> DONT EVER USE ARRAYS.SORT() IN ANY WAY.\\n\\t\\t * FIRST AND VERY IMP -> READ AND UNDERSTAND THE QUESTION VERY CAREFULLY.\\n\\t\\t * WARNING -> DONT CODE BULLSHIT , ALWAYS CHECK THE LOGIC ON MULTIPLE TESTCASES AND EDGECASES BEFORE. \\n\\t\\t * SECOND -> TRY TO FIND RELEVENT PATTERN SMARTLY.\\n\\t\\t * WARNING -> IF YOU THINK YOUR SOLUION IS JUST DUMB DONT SUBMIT IT BEFORE RECHECKING ON YOUR END.\\n\\t\\t *\\/\\n\\t\\tpublic static boolean ifpowof2(long n ) {\\n\\t\\t\\treturn ((n&(n-1)) == 0);\\n\\t\\t}\\n\\t\\t\\n\\t\\tstatic boolean isprime(long x ) {\\n\\t\\t\\tif( x== 2) {\\n\\t\\t\\t\\treturn true;\\n\\t\\t\\t}\\n\\t\\t\\tif( x%2 == 0) {\\n\\t\\t\\t\\treturn false;\\n\\t\\t\\t}\\n\\t\\t\\tfor( long i = 3 ;i*i <= x ;i+=2) {\\n\\t\\t\\t\\tif( x%i == 0)...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"Polycarp has a string s. Polycarp performs the following actions until the string s is empty (t is initially an empty string):\\n\\n * he adds to the right to the string t the string s, i.e. he does t = t + s, where t + s is a concatenation of the strings t and s; \\n * he selects an arbitrary letter of s and removes from s all its occurrences (the selected letter must occur in the string s at the moment of performing this action). \\n\\n\\n\\nPolycarp performs this sequence of actions strictly in this order.\\n\\nNote that after Polycarp finishes the actions, the string s will be empty and the string t will be equal to some value (that is undefined and depends on the order of removing).\\n\\nE.g. consider s=\\\"abacaba\\\" so the actions may be performed as follows:\\n\\n * t=\\\"abacaba\\\", the letter 'b' is selected, then s=\\\"aacaa\\\"; \\n * t=\\\"abacabaaacaa\\\", the letter 'a' is selected, then s=\\\"c\\\"; \\n * t=\\\"abacabaaacaac\\\", the letter 'c' is selected, then s=\\\"\\\" (the empty string). \\n\\n\\n\\nYou need to restore the initial value of the string s using only the final value of t and find the order of removing letters from s.\\n\\nInput\\n\\nThe first line contains one integer T (1 ≤ T ≤ 10^4) — the number of test cases. Then T test cases follow.\\n\\nEach test case contains one string t consisting of lowercase letters of the Latin alphabet. The length of t doesn't exceed 5 ⋅ 10^5. The sum of lengths of all strings t in the test cases doesn't exceed 5 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case output in a separate line:\\n\\n * -1, if the answer doesn't exist; \\n * two strings separated by spaces. The first one must contain a possible initial value of s. The second one must contain a sequence of letters — it's in what order one needs to remove letters from s to make the string t. E.g. if the string \\\"bac\\\" is outputted, then, first, all occurrences of the letter 'b' were deleted, then all occurrences of 'a', and then, finally, all occurrences of 'c'. If there are multiple solutions, print any one....\\\":\",\"targets\":\"\\/\\/Created by Aminul on 18\\/8\\/21.\\n\\nimport java.awt.geom.Point2D;\\nimport java.io.*;\\nimport java.util.*;\\n\\nimport static java.lang.Math.*;\\n\\npublic class E {\\n public static void main(String[] args) throws Exception {\\n InputReader in = new InputReader(System.in);\\n PrintWriter pw = new PrintWriter(System.out);\\n\\n int test = in.nextInt();\\n for (int t = 1; t <= test; t++) {\\n String s = in.next();\\n char[] removalOrder = getRemovalOrder(s);\\n int[][] prefixSum = getPrefixSumOfChars(s);\\n int prefixLength = getPrefixLength(s, removalOrder, prefixSum);\\n String res = checkString(s, prefixLength, removalOrder);\\n if (res == null) {\\n pw.println(-1);\\n } else {\\n pw.println(res + \\\" \\\" + new String(removalOrder));\\n }\\n }\\n\\n\\n pw.close();\\n }\\n\\n static String checkString(String s, int prefixLength, char[] removalOrder) {\\n if (prefixLength == -1) {\\n return null;\\n }\\n String prefix = s.substring(0, prefixLength);\\n StringBuilder sb = new StringBuilder(prefix);\\n for (char c : removalOrder) {\\n prefix = prefix.replaceAll(\\\"\\\" + c, \\\"\\\");\\n sb.append(prefix);\\n }\\n if (s.equals(sb.toString())) {\\n return s.substring(0, prefixLength);\\n } else {\\n return null;\\n }\\n }\\n\\n static int getPrefixLength(String s, char[] order, int[][] prefixSum) {\\n int[] frq = new int[26];\\n for (int i = 0; i < s.length(); i++) {\\n int c = s.charAt(i) - 'a';\\n frq[c]++;\\n\\n { \\/\\/ check prefix\\n boolean ok = true;\\n long len = i + 1;\\n long currLen = i + 1;\\n for (char rem : order) {\\n currLen -= frq[rem - 'a'];\\n\\n if (len > s.length() || getSum((int) len, s.length() - 1, prefixSum[rem - 'a']) != 0) {\\n ok = false;\\n break;\\n...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Ezzat has an array of n integers (maybe negative). He wants to split it into two non-empty subsequences a and b, such that every element from the array belongs to exactly one subsequence, and the value of f(a) + f(b) is the maximum possible value, where f(x) is the average of the subsequence x. \\n\\nA sequence x is a subsequence of a sequence y if x can be obtained from y by deletion of several (possibly, zero or all) elements.\\n\\nThe average of a subsequence is the sum of the numbers of this subsequence divided by the size of the subsequence.\\n\\nFor example, the average of [1,5,6] is (1+5+6)\\/3 = 12\\/3 = 4, so f([1,5,6]) = 4.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^3)— the number of test cases. Each test case consists of two lines.\\n\\nThe first line contains a single integer n (2 ≤ n ≤ 10^5).\\n\\nThe second line contains n integers a_1, a_2, …, a_n (-10^9 ≤ a_i ≤ 10^9).\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 3⋅10^5.\\n\\nOutput\\n\\nFor each test case, print a single value — the maximum value that Ezzat can achieve.\\n\\nYour answer is considered correct if its absolute or relative error does not exceed 10^{-6}.\\n\\nFormally, let your answer be a, and the jury's answer be b. Your answer is accepted if and only if \\\\frac{|a - b|}{max{(1, |b|)}} ≤ 10^{-6}.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n3 1 2\\n3\\n-7 -6 -6\\n3\\n2 2 2\\n4\\n17 3 5 -3\\n\\n\\nOutput\\n\\n\\n4.500000000\\n-12.500000000\\n4.000000000\\n18.666666667\\n\\nNote\\n\\nIn the first test case, the array is [3, 1, 2]. These are all the possible ways to split this array: \\n\\n * a = [3], b = [1,2], so the value of f(a) + f(b) = 3 + 1.5 = 4.5. \\n * a = [3,1], b = [2], so the value of f(a) + f(b) = 2 + 2 = 4. \\n * a = [3,2], b = [1], so the value of f(a) + f(b) = 2.5 + 1 = 3.5. \\n\\nTherefore, the maximum possible value 4.5.\\n\\nIn the second test case, the array is [-7, -6, -6]. These are all the possible ways to split this array: \\n\\n * a = [-7], b = [-6,-6], so the value of f(a) + f(b) = (-7) + (-6) = -13. \\n * a = [-7,-6], b = [-6], so the value of f(a) + f(b) = (-6.5) + (-6) =...\",\"targets\":\"#include \\nusing namespace std;\\nvoid solve() {\\n int n;\\n cin >> n;\\n int a[n];\\n double ans, sum = 0.0;\\n for (int i = 0; i < n; i++) {\\n cin >> a[i];\\n }\\n sort(a, a + n);\\n for (int i = 0; i < n - 1; i++) {\\n sum = sum + a[i];\\n }\\n ans = (sum \\/ (n - 1)) + a[n - 1];\\n cout << fixed << setprecision(9) << ans << endl;\\n ;\\n}\\nint main() {\\n int tc;\\n cin >> tc;\\n while (tc--) {\\n solve();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Consider the insertion sort algorithm used to sort an integer sequence [a_1, a_2, …, a_n] of length n in non-decreasing order.\\n\\nFor each i in order from 2 to n, do the following. If a_i ≥ a_{i-1}, do nothing and move on to the next value of i. Otherwise, find the smallest j such that a_i < a_j, shift the elements on positions from j to i-1 by one position to the right, and write down the initial value of a_i to position j. In this case we'll say that we performed an insertion of an element from position i to position j.\\n\\nIt can be noticed that after processing any i, the prefix of the sequence [a_1, a_2, …, a_i] is sorted in non-decreasing order, therefore, the algorithm indeed sorts any sequence.\\n\\nFor example, sorting [4, 5, 3, 1, 3] proceeds as follows: \\n\\n * i = 2: a_2 ≥ a_1, do nothing; \\n * i = 3: j = 1, insert from position 3 to position 1: [3, 4, 5, 1, 3]; \\n * i = 4: j = 1, insert from position 4 to position 1: [1, 3, 4, 5, 3]; \\n * i = 5: j = 3, insert from position 5 to position 3: [1, 3, 3, 4, 5]. \\n\\n\\n\\nYou are given an integer n and a list of m integer pairs (x_i, y_i). We are interested in sequences such that if you sort them using the above algorithm, exactly m insertions will be performed: first from position x_1 to position y_1, then from position x_2 to position y_2, ..., finally, from position x_m to position y_m.\\n\\nHow many sequences of length n consisting of (not necessarily distinct) integers between 1 and n, inclusive, satisfy the above condition? Print this number modulo 998 244 353.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^5). Description of the test cases follows.\\n\\nThe first line of each test case contains two integers n and m (2 ≤ n ≤ 2 ⋅ 10^5; 0 ≤ m < n) — the length of the sequence and the number of insertions.\\n\\nThe i-th of the following m lines contains two integers x_i and y_i (2 ≤ x_1 < x_2 < … < x_m ≤ n; 1 ≤ y_i < x_i). These lines describe the sequence of insertions in chronological order.\\n\\nIt is guaranteed...\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 4e5 + 10, MX = 2e5;\\nconst long long mod = 998244353;\\nint bit[N];\\nvoid add(int x, int v) {\\n for (int i = x; i <= MX; i += (i & -i)) bit[i] += v;\\n}\\nint find_pos(int v) {\\n v--;\\n int pos = 0;\\n for (int i = (1 << 17); i; i >>= 1)\\n if ((pos | i) <= MX && bit[pos | i] <= v) pos |= i, v -= bit[pos];\\n return pos + 1;\\n}\\nlong long fact[N], inv[N], ifact[N];\\nvoid precal(int n) {\\n inv[1] = ifact[0] = ifact[1] = fact[0] = fact[1] = 1;\\n for (int i = 2; i <= n; ++i) {\\n inv[i] = mod - mod \\/ i * inv[mod % i] % mod;\\n ifact[i] = ifact[i - 1] * inv[i] % mod;\\n fact[i] = fact[i - 1] * i % mod;\\n }\\n}\\nlong long C(int t, int h) {\\n return fact[h] * ifact[t] % mod * ifact[h - t] % mod;\\n}\\nint x[N], y[N], n, m;\\nint main() {\\n ios::sync_with_stdio(false);\\n cin.tie(0);\\n precal(4e5);\\n for (int i = 1; i <= MX; ++i) add(i, 1);\\n int t;\\n cin >> t;\\n while (t--) {\\n cin >> n >> m;\\n for (int i = 1; i <= m; ++i) cin >> x[i] >> y[i];\\n map a;\\n for (int i = m; i; --i) {\\n int pos = find_pos(y[i]);\\n add(pos, -1);\\n a[pos] = x[i];\\n }\\n for (pair p : a) add(p.first, 1);\\n for (pair p : a)\\n if (a.count(p.first + 1) && a[p.first + 1] > p.second) m--;\\n cout << C(n, 2 * n - 1 - m) << \\\"\\\\n\\\";\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"\\n\\nWilliam has an array of n integers a_1, a_2, ..., a_n. In one move he can swap two neighboring items. Two items a_i and a_j are considered neighboring if the condition |i - j| = 1 is satisfied.\\n\\nWilliam wants you to calculate the minimal number of swaps he would need to perform to make it so that the array does not contain two neighboring items with the same parity.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^4). Description of the test cases follows.\\n\\nThe first line of each test case contains an integer n (1 ≤ n ≤ 10^5) which is the total number of items in William's array.\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) which are William's array.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 10^5.\\n\\nOutput\\n\\nFor each test case output the minimal number of operations needed or -1 if it is impossible to get the array to a state when no neighboring numbers have the same parity.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n3\\n6 6 1\\n1\\n9\\n6\\n1 1 1 2 2 2\\n2\\n8 6\\n6\\n6 2 3 4 5 1\\n\\n\\nOutput\\n\\n\\n1\\n0\\n3\\n-1\\n2\\n\\nNote\\n\\nIn the first test case the following sequence of operations would satisfy the requirements: \\n\\n 1. swap(2, 3). Array after performing the operation: [6, 1, 6] \\n\\n\\n\\nIn the second test case the array initially does not contain two neighboring items of the same parity.\\n\\nIn the third test case the following sequence of operations would satisfy the requirements: \\n\\n 1. swap(3, 4). Array after performing the operation: [1, 1, 2, 1, 2, 2] \\n 2. swap(2, 3). Array after performing the operation: [1, 2, 1, 1, 2, 2] \\n 3. swap(4, 5). Array after performing the operation: [1, 2, 1, 2, 1, 2] \\n\\n\\n\\nIn the fourth test case it is impossible to satisfy the requirements.\\n\\nIn the fifth test case the following sequence of operations would satisfy the requirements: \\n\\n 1. swap(2, 3). Array after performing the operation: [6, 3, 2, 4, 5, 1] \\n 2. swap(4, 5). Array after performing the operation: [6, 3, 2, 5, 4, 1] \\nSolve the task in JAVA.\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\npublic class Main {\\n\\t\\tstatic HashMap hm;\\n\\t\\tstatic PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));\\n\\t\\tpublic static void main(String[] args) throws IOException {\\n\\t\\t\\tFastReader sc = new FastReader();\\n\\t\\t\\tint t = sc.nextInt();\\n\\t\\t\\twhile( t-- > 0) {\\n\\t\\t\\t\\tint n = sc.nextInt();\\n\\t\\t\\t\\tint arr[] = new int[n];\\n\\t\\t\\t\\tint a[] = new int[n];\\n\\t\\t\\t\\tint e = 0 , o = 0;\\n\\t\\t\\t\\tfor( int i = 0 ;i < n ; i++) {\\n\\t\\t\\t\\t\\tarr[i] = sc.nextInt();\\n\\t\\t\\t\\t\\tif( arr[i] % 2 == 0) {\\n\\t\\t\\t\\t\\t\\ta[i] = 0;\\n\\t\\t\\t\\t\\t\\te++;\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\telse {\\n\\t\\t\\t\\t\\t\\ta[i] = 1;\\n\\t\\t\\t\\t\\t\\to++;\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\/\\/\\t\\t\\t\\tfor( int x : a) {\\n\\/\\/\\t\\t\\t\\t\\tout.print( x + \\\" \\\");\\n\\/\\/\\t\\t\\t\\t}\\n\\/\\/\\t\\t\\t\\tout.println();\\n\\t\\t\\t\\tif( Math.abs(e - o) > 1) {\\n\\t\\t\\t\\t\\tout.println(-1);\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\telse {\\n\\t\\t\\t\\t\\tint ans = 0;\\n\\t\\t\\t\\t\\tif( o >e ) {\\n\\t\\t\\t\\t\\t\\tans = solve( a , 1 );\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\telse if( e > o) {\\n\\t\\t\\t\\t\\t\\tans = solve( a , 0);\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\telse {\\n\\t\\t\\t\\t\\t\\t\\/\\/out.println( solve( a , 1 ) ) ;\\n\\t\\t\\t\\t\\t\\tans = Math.min( solve( a, 1) , solve( a , 0));\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\tout.println(ans);\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\n\\t\\t\\t}\\n\\t\\t\\tout.flush();\\n\\t\\t}\\n\\t\\t\\n\\n\\t\\tprivate static int solve(int[] a, int i) {\\n\\t\\t\\tArrayList x = new ArrayList<>();\\n\\t\\t\\tArrayList y = new ArrayList<>();\\n\\t\\t\\tint rtrn = 0;\\n\\t\\t\\tfor( int j = 0 ;j < a.length ;j++) {\\n\\t\\t\\t\\tif( a[j] != i) {\\n\\t\\t\\t\\t\\tif( i == 1) {\\n\\t\\t\\t\\t\\t\\tx.add( j);\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\telse {\\n\\t\\t\\t\\t\\t\\ty.add(j);\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tif( i == 0 ) {\\n\\t\\t\\t\\t\\ti = 1;\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\telse {\\n\\t\\t\\t\\t\\ti= 0;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\tfor( int j = 0 ; j< x.size() ; j++) {\\n\\t\\t\\t\\tint temp = Math.abs(x.get(j) - y.get(j));\\n\\t\\t\\t\\t\\/\\/temp = temp + (temp -1 );\\n\\t\\t\\t\\trtrn+=temp;\\n\\t\\t\\t\\t\\n\\t\\t\\t\\t\\/\\/out.println(x.get(j) + \\\" \\\" + y.get(j) );\\n\\t\\t\\t}\\n\\t\\t\\treturn rtrn;\\n\\t\\t}\\n\\n\\n\\t\\tpublic static int[] nextLargerElement(int[] arr, int n)\\n\\t\\t{ \\n\\t\\t\\tStack stack = new Stack<>();\\n\\t int rtrn[] = new int[n];\\n\\t rtrn[n-1] = -1;\\n\\t stack.push( n-1);\\n\\t for( int i = n-2 ;i >= 0 ; i--){\\n\\t int temp = arr[i];\\n\\t int lol = -1;\\n\\t while( !stack.isEmpty() && arr[stack.peek()] <= temp){\\n\\t \\tif(arr[stack.peek()] ==...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A telephone number is a sequence of exactly 11 digits, where the first digit is 8. For example, the sequence 80011223388 is a telephone number, but the sequences 70011223388 and 80000011223388 are not.\\n\\nYou are given a string s of length n, consisting of digits.\\n\\nIn one operation you can delete any character from string s. For example, it is possible to obtain strings 112, 111 or 121 from string 1121.\\n\\nYou need to determine whether there is such a sequence of operations (possibly empty), after which the string s becomes a telephone number.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 100) — the number of test cases.\\n\\nThe first line of each test case contains one integer n (1 ≤ n ≤ 100) — the length of string s.\\n\\nThe second line of each test case contains the string s (|s| = n) consisting of digits.\\n\\nOutput\\n\\nFor each test print one line.\\n\\nIf there is a sequence of operations, after which s becomes a telephone number, print YES.\\n\\nOtherwise, print NO.\\n\\nExample\\n\\nInput\\n\\n\\n2\\n13\\n7818005553535\\n11\\n31415926535\\n\\n\\nOutput\\n\\n\\nYES\\nNO\\n\\nNote\\n\\nIn the first test case you need to delete the first and the third digits. Then the string 7818005553535 becomes 88005553535.\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"for i in range(int(input())):\\n n = int(input())\\n s = input()\\n pos = n\\n for i in range(n):\\n if(s[i] == '8'):\\n pos = i\\n break\\n if(n - pos >= 11):\\n print('YES')\\n else:\\n print('NO')\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"After returned from forest, Alyona started reading a book. She noticed strings s and t, lengths of which are n and m respectively. As usual, reading bored Alyona and she decided to pay her attention to strings s and t, which she considered very similar.\\n\\nAlyona has her favourite positive integer k and because she is too small, k does not exceed 10. The girl wants now to choose k disjoint non-empty substrings of string s such that these strings appear as disjoint substrings of string t and in the same order as they do in string s. She is also interested in that their length is maximum possible among all variants.\\n\\nFormally, Alyona wants to find a sequence of k non-empty strings p1, p2, p3, ..., pk satisfying following conditions:\\n\\n * s can be represented as concatenation a1p1a2p2... akpkak + 1, where a1, a2, ..., ak + 1 is a sequence of arbitrary strings (some of them may be possibly empty); \\n * t can be represented as concatenation b1p1b2p2... bkpkbk + 1, where b1, b2, ..., bk + 1 is a sequence of arbitrary strings (some of them may be possibly empty); \\n * sum of the lengths of strings in sequence is maximum possible. \\n\\n\\n\\nPlease help Alyona solve this complicated problem and find at least the sum of the lengths of the strings in a desired sequence.\\n\\nA substring of a string is a subsequence of consecutive characters of the string.\\n\\nInput\\n\\nIn the first line of the input three integers n, m, k (1 ≤ n, m ≤ 1000, 1 ≤ k ≤ 10) are given — the length of the string s, the length of the string t and Alyona's favourite number respectively.\\n\\nThe second line of the input contains string s, consisting of lowercase English letters.\\n\\nThe third line of the input contains string t, consisting of lowercase English letters.\\n\\nOutput\\n\\nIn the only line print the only non-negative integer — the sum of the lengths of the strings in a desired sequence.\\n\\nIt is guaranteed, that at least one desired sequence exists.\\n\\nExamples\\n\\nInput\\n\\n3 2 2\\nabc\\nab\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n9 12 4\\nbbaaababb\\nabbbabbaaaba\\n\\n\\nOutput\\n\\n7\\n\\nNote\\n\\nThe following image...\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nlong long int max(long long int a, long long int b) {\\n if (a > b)\\n return a;\\n else\\n return b;\\n}\\nlong long int min(long long int a, long long int b) {\\n if (a < b)\\n return a;\\n else\\n return b;\\n}\\nconst int dx[4] = {-1, 1, 0, 0};\\nconst int dy[4] = {0, 0, -1, 1};\\nint XX[] = {-1, -1, -1, 0, 0, 1, 1, 1};\\nint YY[] = {-1, 0, 1, -1, 1, -1, 0, 1};\\nlong long int n, m, k;\\nstring s, t;\\nlong long int dp[1005][1005][12][2];\\nlong long int func(long long int i, long long int j, long long int count,\\n long long int end) {\\n if (i >= n || j >= m) {\\n if (count == k) return 0;\\n return INT_MIN;\\n }\\n if (dp[i][j][count][end] != -1) return dp[i][j][count][end];\\n long long int maxi = 0;\\n maxi = max(maxi, func(i + 1, j, count, 0));\\n maxi = max(maxi, func(i, j + 1, count, 0));\\n if (s[i] == t[j]) {\\n if (end == 0) {\\n if (count < k) maxi = max(maxi, 1 + func(i + 1, j + 1, count + 1, 1));\\n } else {\\n maxi = max(maxi, func(i + 1, j + 1, count, 1) + 1);\\n if (count < k) maxi = max(maxi, func(i + 1, j + 1, count + 1, 1) + 1);\\n }\\n }\\n return dp[i][j][count][end] = maxi;\\n}\\nint main() {\\n memset(dp, -1, sizeof(dp));\\n ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);\\n long long int i, j;\\n cin >> n >> m >> k;\\n cin >> s >> t;\\n long long int ans = func(0, 0, 0, 0);\\n cout << ans;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Given n, find any array a_1, a_2, …, a_n of integers such that all of the following conditions hold: \\n\\n * 1 ≤ a_i ≤ 10^9 for every i from 1 to n.\\n\\n * a_1 < a_2 < … \\nusing namespace std;\\nvoid fastio() {\\n ios_base::sync_with_stdio;\\n cin.tie(NULL);\\n cin.tie(NULL);\\n ios_base::sync_with_stdio;\\n cin.tie(NULL);\\n cout.tie(NULL);\\n}\\nint main() {\\n fastio();\\n long long int t;\\n cin >> t;\\n while (t--) {\\n long long int n;\\n cin >> n;\\n vector v;\\n if (n == 1)\\n cout << 1 << endl;\\n else {\\n v.push_back(n);\\n for (long long int i = 1; i < n; i++) {\\n v.push_back(v[i - 1] + 1);\\n }\\n for (long long int i = 0; i < v.size(); i++) cout << v[i] << \\\" \\\";\\n cout << endl;\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Monocarp wrote down two numbers on a whiteboard. Both numbers follow a specific format: a positive integer x with p zeros appended to its end.\\n\\nNow Monocarp asks you to compare these two numbers. Can you help him?\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.\\n\\nThe first line of each testcase contains two integers x_1 and p_1 (1 ≤ x_1 ≤ 10^6; 0 ≤ p_1 ≤ 10^6) — the description of the first number.\\n\\nThe second line of each testcase contains two integers x_2 and p_2 (1 ≤ x_2 ≤ 10^6; 0 ≤ p_2 ≤ 10^6) — the description of the second number.\\n\\nOutput\\n\\nFor each testcase print the result of the comparison of the given two numbers. If the first number is smaller than the second one, print '<'. If the first number is greater than the second one, print '>'. If they are equal, print '='.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n2 1\\n19 0\\n10 2\\n100 1\\n1999 0\\n2 3\\n1 0\\n1 0\\n99 0\\n1 2\\n\\n\\nOutput\\n\\n\\n>\\n=\\n<\\n=\\n<\\n\\nNote\\n\\nThe comparisons in the example are: 20 > 19, 1000 = 1000, 1999 < 2000, 1 = 1, 99 < 100.\",\"targets\":\"#include \\nusing ll = long long;\\nusing namespace std;\\nint getLen(int x) {\\n int ret = 0;\\n while (x) {\\n x \\/= 10;\\n ret += 1;\\n }\\n return ret;\\n}\\nvoid run_test_case() {\\n ll x1, p1, x2, p2;\\n cin >> x1 >> p1 >> x2 >> p2;\\n int len1 = getLen(x1) + p1;\\n int len2 = getLen(x2) + p2;\\n if (len1 < len2) {\\n cout << \\\"<\\\\n\\\";\\n return;\\n }\\n if (len1 > len2) {\\n cout << \\\">\\\\n\\\";\\n return;\\n }\\n if (p1 < p2) {\\n for (int i = (0); i < int(p2 - p1); ++i) {\\n x2 *= 10;\\n }\\n } else if (p1 > p2) {\\n for (int i = (0); i < int(p1 - p2); ++i) {\\n x1 *= 10;\\n }\\n }\\n if (x1 < x2) {\\n cout << \\\"<\\\\n\\\";\\n return;\\n }\\n if (x1 > x2) {\\n cout << \\\">\\\\n\\\";\\n return;\\n }\\n cout << \\\"=\\\\n\\\";\\n return;\\n}\\nint main() {\\n cin.tie(nullptr)->sync_with_stdio(false);\\n int t = 1;\\n bool read_t = true;\\n if (read_t) {\\n cin >> t;\\n }\\n while (t--) {\\n run_test_case();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"This is the easy version of the problem. The only difference between the two versions is the constraint on n. You can make hacks only if all versions of the problem are solved.\\n\\nA forest is an undirected graph without cycles (not necessarily connected).\\n\\nMocha and Diana are friends in Zhijiang, both of them have a forest with nodes numbered from 1 to n, and they would like to add edges to their forests such that: \\n\\n * After adding edges, both of their graphs are still forests. \\n * They add the same edges. That is, if an edge (u, v) is added to Mocha's forest, then an edge (u, v) is added to Diana's forest, and vice versa. \\n\\n\\n\\nMocha and Diana want to know the maximum number of edges they can add, and which edges to add.\\n\\nInput\\n\\nThe first line contains three integers n, m_1 and m_2 (1 ≤ n ≤ 1000, 0 ≤ m_1, m_2 < n) — the number of nodes and the number of initial edges in Mocha's forest and Diana's forest.\\n\\nEach of the next m_1 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the edges in Mocha's forest.\\n\\nEach of the next m_2 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the edges in Diana's forest.\\n\\nOutput\\n\\nThe first line contains only one integer h, the maximum number of edges Mocha and Diana can add (in each forest).\\n\\nEach of the next h lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the edge you add each time.\\n\\nIf there are multiple correct answers, you can print any one of them.\\n\\nExamples\\n\\nInput\\n\\n\\n3 2 2\\n1 2\\n2 3\\n1 2\\n1 3\\n\\n\\nOutput\\n\\n\\n0\\n\\n\\nInput\\n\\n\\n5 3 2\\n5 4\\n2 1\\n4 3\\n4 3\\n1 4\\n\\n\\nOutput\\n\\n\\n1\\n2 4\\n\\n\\nInput\\n\\n\\n8 1 2\\n1 7\\n2 6\\n1 5\\n\\n\\nOutput\\n\\n\\n5\\n5 2\\n2 3\\n3 4\\n4 7\\n6 8\\n\\nNote\\n\\nIn the first example, we cannot add any edge.\\n\\nIn the second example, the initial forests are as follows.\\n\\n\\n\\nWe can add an edge (2, 4).\\n\\n\",\"targets\":\"'''Author- Akshit Monga'''\\nfrom sys import stdin, stdout\\ninput = stdin.readline\\nfrom types import GeneratorType\\n\\n\\ndef bootstrap(f, stack=[]):\\n def wrappedfunc(*args, **kwargs):\\n if stack:\\n return f(*args, **kwargs)\\n else:\\n to = f(*args, **kwargs)\\n while True:\\n if type(to) is GeneratorType:\\n stack.append(to)\\n to = next(to)\\n else:\\n stack.pop()\\n if not stack:\\n break\\n to = stack[-1].send(to)\\n return to\\n\\n return wrappedfunc\\n\\n\\n# @bootstrap\\ndef dfs(start,val,par):\\n vis.add(start)\\n if val:\\n xx[start]=kk\\n pivot2[-1].append(start)\\n for i in g2[start]:\\n if i not in vis:\\n dfs(i,val,par)\\n else:\\n yy[start]=kk\\n pivot1[-1].append(start)\\n for i in g1[start]:\\n if i not in vis:\\n dfs(i,val,par)\\n # yield\\n\\nt = 1\\nfor _ in range(t):\\n n,x,y=map(int,input().split())\\n all=set()\\n g1=[[] for i in range(n)]\\n g2=[[] for i in range(n)]\\n for i in range(x):\\n a,b=map(int,input().split())\\n all.add((a-1,b-1))\\n g1[a-1].append(b-1)\\n g1[b-1].append(a-1)\\n for i in range(y):\\n a,b=map(int,input().split())\\n all.add((a - 1, b - 1))\\n g2[a-1].append(b-1)\\n g2[b-1].append(a-1)\\n pivot1=[]\\n pivot2=[]\\n vis=set()\\n xx=[-1 for i in range(n)]\\n yy=[-1 for i in range(n)]\\n kk=0\\n for i in range(n):\\n if i not in vis:\\n kk+=1\\n pivot1.append([])\\n dfs(i,0,i)\\n vis=set()\\n kk=0\\n for i in range(n):\\n if i not in vis:\\n kk+=1\\n pivot2.append([])\\n dfs(i,1,i)\\n ans=[]\\n for i in range(n):\\n for j in range(n):\\n if xx[i]!=xx[j] and yy[i]!=yy[j]:\\n ans.append((i+1,j+1))\\n k=xx[j]\\n for p in range(n):\\n if...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Despite his bad reputation, Captain Flint is a friendly person (at least, friendly to animals). Now Captain Flint is searching worthy sailors to join his new crew (solely for peaceful purposes). A sailor is considered as worthy if he can solve Flint's task.\\n\\nRecently, out of blue Captain Flint has been interested in math and even defined a new class of integers. Let's define a positive integer x as nearly prime if it can be represented as p ⋅ q, where 1 < p < q and p and q are prime numbers. For example, integers 6 and 10 are nearly primes (since 2 ⋅ 3 = 6 and 2 ⋅ 5 = 10), but integers 1, 3, 4, 16, 17 or 44 are not.\\n\\nCaptain Flint guessed an integer n and asked you: can you represent it as the sum of 4 different positive integers where at least 3 of them should be nearly prime.\\n\\nUncle Bogdan easily solved the task and joined the crew. Can you do the same?\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases.\\n\\nNext t lines contain test cases — one per line. The first and only line of each test case contains the single integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number Flint guessed.\\n\\nOutput\\n\\nFor each test case print: \\n\\n * YES and 4 different positive integers such that at least 3 of them are nearly prime and their sum is equal to n (if there are multiple answers print any of them); \\n * NO if there is no way to represent n as the sum of 4 different positive integers where at least 3 of them are nearly prime. \\n\\nYou can print each character of YES or NO in any case.\\n\\nExample\\n\\nInput\\n\\n\\n7\\n7\\n23\\n31\\n36\\n44\\n100\\n258\\n\\n\\nOutput\\n\\n\\nNO\\nNO\\nYES\\n14 10 6 1\\nYES\\n5 6 10 15\\nYES\\n6 7 10 21\\nYES\\n2 10 33 55\\nYES\\n10 21 221 6\\n\\nNote\\n\\nIn the first and second test cases, it can be proven that there are no four different positive integers such that at least three of them are nearly prime.\\n\\nIn the third test case, n=31=2 ⋅ 7 + 2 ⋅ 5 + 2 ⋅ 3 + 1: integers 14, 10, 6 are nearly prime.\\n\\nIn the fourth test case, n=36=5 + 2 ⋅ 3 + 2 ⋅ 5 + 3 ⋅ 5: integers 6, 10, 15 are nearly prime.\\n\\nIn the fifth test case, n=44=2 ⋅ 3 + 7 +...\\nUsing python3 can you solve the prior task?\",\"targets\":\"t = int(input())\\n\\nfor i in range(t) :\\n n = int(input())\\n a = [6,10,14]\\n if n > 30 :\\n res = n - 30\\n if res == 6 :\\n a.remove(14)\\n a.append(15)\\n a.append(5)\\n print('YES')\\n print(*a)\\n elif res == 10 :\\n a.remove(10)\\n a.append(15)\\n a.append(5)\\n print('YES')\\n print(*a)\\n elif res == 14 :\\n a.remove(14)\\n a.append(21)\\n a.append(7)\\n print('YES')\\n print(*a)\\n else :\\n a.append(n-30)\\n print('YES')\\n print(*a)\\n else :\\n print('NO')\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Polycarp must pay exactly n burles at the checkout. He has coins of two nominal values: 1 burle and 2 burles. Polycarp likes both kinds of coins equally. So he doesn't want to pay with more coins of one type than with the other.\\n\\nThus, Polycarp wants to minimize the difference between the count of coins of 1 burle and 2 burles being used. Help him by determining two non-negative integer values c_1 and c_2 which are the number of coins of 1 burle and 2 burles, respectively, so that the total value of that number of coins is exactly n (i. e. c_1 + 2 ⋅ c_2 = n), and the absolute value of the difference between c_1 and c_2 is as little as possible (i. e. you must minimize |c_1-c_2|).\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10^4) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one line. This line contains one integer n (1 ≤ n ≤ 10^9) — the number of burles to be paid by Polycarp.\\n\\nOutput\\n\\nFor each test case, output a separate line containing two integers c_1 and c_2 (c_1, c_2 ≥ 0) separated by a space where c_1 is the number of coins of 1 burle and c_2 is the number of coins of 2 burles. If there are multiple optimal solutions, print any one.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n1000\\n30\\n1\\n32\\n1000000000\\n5\\n\\n\\nOutput\\n\\n\\n334 333\\n10 10\\n1 0\\n10 11\\n333333334 333333333\\n1 2\\n\\nNote\\n\\nThe answer for the first test case is \\\"334 333\\\". The sum of the nominal values of all coins is 334 ⋅ 1 + 333 ⋅ 2 = 1000, whereas |334 - 333| = 1. One can't get the better value because if |c_1 - c_2| = 0, then c_1 = c_2 and c_1 ⋅ 1 + c_1 ⋅ 2 = 1000, but then the value of c_1 isn't an integer.\\n\\nThe answer for the second test case is \\\"10 10\\\". The sum of the nominal values is 10 ⋅ 1 + 10 ⋅ 2 = 30 and |10 - 10| = 0, whereas there's no number having an absolute value less than 0.\",\"targets\":\"#include \\nusing namespace std;\\nvoid solve() {\\n long long int t;\\n cin >> t;\\n while (t--) {\\n long long int n;\\n cin >> n;\\n long long int d = n % 3;\\n if (d == 0) {\\n cout << n \\/ 3 << \\\" \\\" << n \\/ 3 << \\\"\\\\n\\\";\\n } else if (d == 1) {\\n cout << (n \\/ 3) + 1 << \\\" \\\" << n \\/ 3 << \\\"\\\\n\\\";\\n } else {\\n cout << (n \\/ 3) << \\\" \\\" << (n \\/ 3) + 1 << \\\"\\\\n\\\";\\n }\\n }\\n}\\nsigned main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n solve();\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Polycarp has found a table having an infinite number of rows and columns. The rows are numbered from 1, starting from the topmost one. The columns are numbered from 1, starting from the leftmost one.\\n\\nInitially, the table hasn't been filled and Polycarp wants to fix it. He writes integers from 1 and so on to the table as follows.\\n\\n The figure shows the placement of the numbers from 1 to 10. The following actions are denoted by the arrows.\\n\\nThe leftmost topmost cell of the table is filled with the number 1. Then he writes in the table all positive integers beginning from 2 sequentially using the following algorithm.\\n\\nFirst, Polycarp selects the leftmost non-filled cell in the first row and fills it. Then, while the left neighbor of the last filled cell is filled, he goes down and fills the next cell. So he goes down until the last filled cell has a non-filled neighbor to the left (look at the vertical arrow going down in the figure above).\\n\\nAfter that, he fills the cells from the right to the left until he stops at the first column (look at the horizontal row in the figure above). Then Polycarp selects the leftmost non-filled cell in the first row, goes down, and so on.\\n\\nA friend of Polycarp has a favorite number k. He wants to know which cell will contain the number. Help him to find the indices of the row and the column, such that the intersection of the row and the column is the cell containing the number k.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 100) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one line containing one integer k (1 ≤ k ≤ 10^9) which location must be found.\\n\\nOutput\\n\\nFor each test case, output in a separate line two integers r and c (r, c ≥ 1) separated by spaces — the indices of the row and the column containing the cell filled by the number k, respectively.\\n\\nExample\\n\\nInput\\n\\n\\n7\\n11\\n14\\n5\\n4\\n1\\n2\\n1000000000\\n\\n\\nOutput\\n\\n\\n2 4\\n4 3\\n1 3\\n2 1\\n1 1\\n1 2\\n31623 14130\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nusing namespace std::chrono;\\nlong long g(long long a, long long b) {\\n if (b == 0) return a;\\n return g(b, a % b);\\n}\\ndouble min(double x, double y) {\\n if (x < y) return x;\\n return y;\\n}\\nint64_t max(int64_t x, int64_t y) {\\n if (x > y) return x;\\n return y;\\n}\\nvoid solveandrun(int testo) {\\n long long k;\\n cin >> k;\\n if (k == 1) {\\n cout << 1 << \\\" \\\" << 1;\\n return;\\n }\\n long long i = 1, ans = 0;\\n while (i * i < k) ans = i, i += 1;\\n if (k == i * i - ans)\\n cout << i << \\\" \\\" << i;\\n else if (k > i * i - ans) {\\n cout << i << \\\" \\\" << i * i - k + 1;\\n } else if (k < i * i - ans)\\n cout << k - ans * ans << \\\" \\\" << i;\\n}\\nint32_t main() {\\n int i = 1;\\n int t = 1;\\n cin >> t;\\n for (int i = 1; i <= t; i++) {\\n solveandrun(t);\\n cout << \\\"\\\\n\\\";\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"On a circle lie 2n distinct points, with the following property: however you choose 3 chords that connect 3 disjoint pairs of points, no point strictly inside the circle belongs to all 3 chords. The points are numbered 1, 2, ..., 2n in clockwise order.\\n\\nInitially, k chords connect k pairs of points, in such a way that all the 2k endpoints of these chords are distinct.\\n\\nYou want to draw n - k additional chords that connect the remaining 2(n - k) points (each point must be an endpoint of exactly one chord).\\n\\nIn the end, let x be the total number of intersections among all n chords. Compute the maximum value that x can attain if you choose the n - k chords optimally.\\n\\nNote that the exact position of the 2n points is not relevant, as long as the property stated in the first paragraph holds.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. Then t test cases follow.\\n\\nThe first line of each test case contains two integers n and k (1 ≤ n ≤ 100, 0 ≤ k ≤ n) — half the number of points and the number of chords initially drawn.\\n\\nThen k lines follow. The i-th of them contains two integers x_i and y_i (1 ≤ x_i, y_i ≤ 2n, x_i ≠ y_i) — the endpoints of the i-th chord. It is guaranteed that the 2k numbers x_1, y_1, x_2, y_2, ..., x_k, y_k are all distinct.\\n\\nOutput\\n\\nFor each test case, output the maximum number of intersections that can be obtained by drawing n - k additional chords.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n4 2\\n8 2\\n1 5\\n1 1\\n2 1\\n2 0\\n10 6\\n14 6\\n2 20\\n9 10\\n13 18\\n15 12\\n11 7\\n\\n\\nOutput\\n\\n\\n4\\n0\\n1\\n14\\n\\nNote\\n\\nIn the first test case, there are three ways to draw the 2 additional chords, shown below (black chords are the ones initially drawn, while red chords are the new ones):\\n\\n\\n\\nWe see that the third way gives the maximum number of intersections, namely 4.\\n\\nIn the second test case, there are no more chords to draw. Of course, with only one chord present there are no intersections.\\n\\nIn the third test case, we can make at most one intersection by drawing chords 1-3 and 2-4, as...\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 210;\\nint a[N];\\nint vis[N];\\nvector > v;\\nint check(pair a, pair b) {\\n if (a.first > b.first) swap(a, b);\\n return a.second < b.second && b.first < a.second;\\n}\\nint main() {\\n int t;\\n cin >> t;\\n while (t--) {\\n int n, k;\\n cin >> n >> k;\\n v.clear();\\n memset(vis, 0, sizeof vis);\\n for (int i = 1; i <= k; i++) {\\n int first, second;\\n cin >> first >> second;\\n if (first > second) swap(first, second);\\n vis[first] = 1, vis[second] = 1;\\n v.push_back({first, second});\\n }\\n int cnt = 1;\\n for (int i = 1; i <= 2 * n; i++)\\n if (!vis[i]) a[cnt++] = i;\\n for (int i = 1; i <= n - k; i++) v.push_back({a[i], a[i + n - k]});\\n int ans = 0;\\n for (int i = 0; i < n; i++)\\n for (int j = i + 1; j < n; j++)\\n if (check(v[i], v[j])) ans++;\\n cout << ans << endl;\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"\\\"Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score...\\\" — an excerpt from contest rules.\\n\\nA total of n participants took part in the contest (n ≥ k), and you already know their scores. Calculate how many participants will advance to the next round.\\n\\nInput\\n\\nThe first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 50) separated by a single space.\\n\\nThe second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 100), where ai is the score earned by the participant who got the i-th place. The given sequence is non-increasing (that is, for all i from 1 to n - 1 the following condition is fulfilled: ai ≥ ai + 1).\\n\\nOutput\\n\\nOutput the number of participants who advance to the next round.\\n\\nExamples\\n\\nInput\\n\\n8 5\\n10 9 8 7 7 7 5 5\\n\\n\\nOutput\\n\\n6\\n\\n\\nInput\\n\\n4 2\\n0 0 0 0\\n\\n\\nOutput\\n\\n0\\n\\nNote\\n\\nIn the first example the participant on the 5th place earned 7 points. As the participant on the 6th place also earned 7 points, there are 6 advancers.\\n\\nIn the second example nobody got a positive score.\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\npublic class Solution\\n{\\n public static void main(String[] args)\\n {\\n Scanner sc=new Scanner(System.in);\\n int n=sc.nextInt();\\n int k=sc.nextInt();\\n int[] a=new int[n];\\n for(int i=0;i0 && a[i]>=val)\\n count++;\\n }\\n System.out.println(count);\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 solution for \\\"n students attended the first meeting of the Berland SU programming course (n is even). All students will be divided into two groups. Each group will be attending exactly one lesson each week during one of the five working days (Monday, Tuesday, Wednesday, Thursday and Friday), and the days chosen for the groups must be different. Furthermore, both groups should contain the same number of students.\\n\\nEach student has filled a survey in which they told which days of the week are convenient for them to attend a lesson, and which are not. \\n\\nYour task is to determine if it is possible to choose two different week days to schedule the lessons for the group (the first group will attend the lesson on the first chosen day, the second group will attend the lesson on the second chosen day), and divide the students into two groups, so the groups have equal sizes, and for each student, the chosen lesson day for their group is convenient.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.\\n\\nThen the descriptions of t testcases follow.\\n\\nThe first line of each testcase contains one integer n (2 ≤ n ≤ 1 000) — the number of students.\\n\\nThe i-th of the next n lines contains 5 integers, each of them is 0 or 1. If the j-th integer is 1, then the i-th student can attend the lessons on the j-th day of the week. If the j-th integer is 0, then the i-th student cannot attend the lessons on the j-th day of the week. \\n\\nAdditional constraints on the input: for each student, at least one of the days of the week is convenient, the total number of students over all testcases doesn't exceed 10^5.\\n\\nOutput\\n\\nFor each testcase print an answer. If it's possible to divide the students into two groups of equal sizes and choose different days for the groups so each student can attend the lesson in the chosen day of their group, print \\\"YES\\\" (without quotes). Otherwise, print \\\"NO\\\" (without quotes). \\n\\nExample\\n\\nInput\\n\\n\\n2\\n4\\n1 0 0 1 0\\n0 1 0 0 1\\n0 0 0 1 0\\n0 1 0 1 0\\n2\\n0 0 0 1 0\\n0 0 0 1 0\\n\\n\\nOutput\\n\\n\\nYES\\nNO\\n\\nNote\\n\\nIn...\\\":\",\"targets\":\"# Online Python compiler (interpreter) to run Python online.\\n# Write Python 3 code in this online editor and run it.\\nt=int(input())\\nfor i in range(t):\\n n=int(input())\\n etudiants=[]\\n for i in range(n):\\n raw=input().split()\\n etudiant=[]\\n for jour in raw:\\n etudiant.append(int(jour))\\n etudiants.append(etudiant)\\n jours=['lundi','mardi','mercredi','jeudi','vendredi']\\n dispo={day:[] for day in jours}\\n indispo={day:[] for day in jours}\\n indice=0\\n for key in dispo:\\n for i in range(n):\\n if(etudiants[i][indice]==1):\\n dispo[key].append(i)\\n indice+=1\\n\\n jours_possible=[]\\n for key in dispo:\\n if(len(dispo[key])>=n\\/2):\\n jours_possible.append(key)\\n res='NO'\\n for key in jours_possible:\\n for i in range(n):\\n if i not in dispo[key]:\\n indispo[key].append(i)\\n for key2 in jours_possible:\\n test = True\\n for el in indispo[key]:\\n if el not in dispo[key2]:\\n test=False\\n if key2!=key and test==True:\\n res='YES'\\n break\\n print(res)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Moamen has an array of n distinct integers. He wants to sort that array in non-decreasing order by doing the following operations in order exactly once:\\n\\n 1. Split the array into exactly k non-empty subarrays such that each element belongs to exactly one subarray. \\n 2. Reorder these subarrays arbitrary. \\n 3. Merge the subarrays in their new order. \\n\\n\\n\\nA sequence a is a subarray of a sequence b if a can be obtained from b by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.\\n\\nCan you tell Moamen if there is a way to sort the array in non-decreasing order using the operations written above?\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^3) — the number of test cases. The description of the test cases follows.\\n\\nThe first line of each test case contains two integers n and k (1 ≤ k ≤ n ≤ 10^5).\\n\\nThe second line contains n integers a_1, a_2, …, a_n (0 ≤ |a_i| ≤ 10^9). It is guaranteed that all numbers are distinct.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 3⋅10^5.\\n\\nOutput\\n\\nFor each test case, you should output a single string.\\n\\nIf Moamen can sort the array in non-decreasing order, output \\\"YES\\\" (without quotes). Otherwise, output \\\"NO\\\" (without quotes).\\n\\nYou can print each letter of \\\"YES\\\" and \\\"NO\\\" in any case (upper or lower).\\n\\nExample\\n\\nInput\\n\\n\\n3\\n5 4\\n6 3 4 2 1\\n4 2\\n1 -4 0 -2\\n5 1\\n1 2 3 4 5\\n\\n\\nOutput\\n\\n\\nYes\\nNo\\nYes\\n\\nNote\\n\\nIn the first test case, a = [6, 3, 4, 2, 1], and k = 4, so we can do the operations as follows: \\n\\n 1. Split a into \\\\{ [6], [3, 4], [2], [1] \\\\}. \\n 2. Reorder them: \\\\{ [1], [2], [3,4], [6] \\\\}. \\n 3. Merge them: [1, 2, 3, 4, 6], so now the array is sorted. \\n\\n\\n\\nIn the second test case, there is no way to sort the array by splitting it into only 2 subarrays.\\n\\nAs an example, if we split it into \\\\{ [1, -4], [0, -2] \\\\}, we can reorder them into \\\\{ [1, -4], [0, -2] \\\\} or \\\\{ [0, -2], [1, -4] \\\\}. However, after merging the subarrays, it is impossible to get a sorted array.\\nimpor\",\"targets\":\"t java.io.*;\\nimport java.util.*;\\n\\n\\/**\\n * -----------------|___________|---------------------\\n * CCCCCCCCC OOOOOOOOOO DDDDDDDD EEEEEEEEE\\n * CCCC OOO OOO DD DDD EEEE\\n * CCCC OOO OOO DD DDD EEEEEEEEEE\\n * CCCC OOO OOO DD DDDD EEEE\\n * CCCCCCCCC OOOOOOOOOO DDDDDDDDDDDD EEEEEEEEEE\\n * -----------------|___________|---------------------\\n *\\/\\n\\npublic class Main {\\n public static void main(String[] args) {\\n InputStream inputStream = System.in;\\n OutputStream outputStream = System.out;\\n InputReader in = new InputReader(inputStream);\\n PrintWriter sout = new PrintWriter(outputStream);\\n int t = in.nextInt();\\n while (t > 0) {\\n t--;\\n int n = in.nextInt();\\n int k = in.nextInt();\\n int[] arr = new int[n];\\n Map map = new HashMap<>();\\n for (int i = 0; i < n; i++) {\\n int val = in.nextInt();\\n arr[i] = val;\\n map.put(val,i);\\n }\\n int mxk = 1;\\n Arrays.sort(arr);\\n for(int i = 0; i\\n#pragma GCC optimize(3, \\\"Ofast\\\", \\\"inline\\\")\\nusing namespace std;\\nmt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());\\nconst int mod = 1e9 + 7;\\nconst int seed = 233;\\nconst double PI = acos(-1.0);\\nconst double eps = 1e-7;\\nconst int inf = 0x3f3f3f3f;\\nconst int max_n = 600005;\\nchar str[max_n];\\nvoid rs(string& s) {\\n scanf(\\\" %s\\\", str);\\n s = str;\\n}\\nnamespace {\\ninline int Add(int x, int y) { return (x += y) >= mod ? x - mod : x; }\\ninline int Sub(int x, int y) { return (x -= y) < 0 ? x + mod : x; }\\ninline int Mul(int x, int y) { return 1ll * x * y % mod; }\\ninline int Pow(int x, int y = mod - 2) {\\n int res = 1;\\n while (y) {\\n if (y & 1) res = 1ll * res * x % mod;\\n x = 1ll * x * x % mod;\\n y >>= 1;\\n }\\n return res;\\n}\\n} \\/\\/ namespace\\nstruct Seg {\\n int d[1 << 22], lazy[1 << 22];\\n void pushup(int rt) { d[rt] = min(d[rt << 1], d[rt << 1 | 1]); }\\n void pushdown(int rt, int ln = 1, int rn = 1) {\\n if (lazy[rt]) {\\n d[rt << 1] += lazy[rt] * ln;\\n d[rt << 1 | 1] += lazy[rt] * rn;\\n lazy[rt << 1] += lazy[rt];\\n lazy[rt << 1 | 1] += lazy[rt];\\n lazy[rt] = 0;\\n }\\n }\\n void init(int l, int r, int rt) {\\n d[rt] = INT_MAX, lazy[rt] = 0;\\n if (l == r) return;\\n int mid = l + r >> 1;\\n init(l, mid, rt << 1), init(mid + 1, r, rt << 1 | 1);\\n }\\n void ins(int x, int c, int l, int r, int rt) {\\n if (l == r) {\\n d[rt] = min(d[rt], c);\\n return;\\n }\\n int mid = l + r >> 1;\\n pushdown(rt);\\n if (x <= mid)\\n ins(x, c, l, mid, rt << 1);\\n else\\n ins(x, c, mid + 1, r, rt << 1 | 1);\\n pushup(rt);\\n }\\n void update(int L, int R, int C, int l, int r, int rt) {\\n if (L > R) return;\\n if (l >= L && r <= R) {\\n d[rt] += C;\\n lazy[rt] += C;\\n return;\\n }\\n int mid = l + r >> 1;\\n pushdown(rt);\\n if (mid >= L) update(L, R, C, l, mid, rt << 1);\\n if (mid < R) update(L, R, C, mid + 1, r, rt << 1 | 1);\\n pushup(rt);\\n }\\n int query(int L, int R, int l, int r, int rt) {\\n if (L > R || L > r || R < l) return...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"It is a simplified version of problem F2. The difference between them is the constraints (F1: k ≤ 2, F2: k ≤ 10).\\n\\nYou are given an integer n. Find the minimum integer x such that x ≥ n and the number x is k-beautiful.\\n\\nA number is called k-beautiful if its decimal representation having no leading zeroes contains no more than k different digits. E.g. if k = 2, the numbers 3434443, 55550, 777 and 21 are k-beautiful whereas the numbers 120, 445435 and 998244353 are not.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10^4) — the number of test cases. Then t test cases follow.\\n\\nEach test case consists of one line containing two integers n and k (1 ≤ n ≤ 10^9, 1 ≤ k ≤ 2).\\n\\nOutput\\n\\nFor each test case output on a separate line x — the minimum k-beautiful integer such that x ≥ n.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n1 1\\n221 2\\n177890 2\\n998244353 1\\n\\n\\nOutput\\n\\n\\n1\\n221\\n181111\\n999999999\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nstring solve1(string s) {\\n for (char i = '0'; i <= '9'; i++) {\\n string ans(s.length(), i);\\n if (ans >= s) {\\n return ans;\\n }\\n }\\n}\\nstring solve2(string s) {\\n string res = solve1(s);\\n for (char a = '0'; a <= '9'; a++) {\\n for (char b = a + 1; b <= '9'; b++) {\\n int f = 1;\\n for (int i = 0; i < s.length(); i++) {\\n if (s[i] < b) {\\n string t = s;\\n if (t[i] < a)\\n t[i] = a;\\n else\\n t[i] = b;\\n for (int j = i + 1; j < s.length(); j++) t[j] = a;\\n if (res > t) res = t;\\n }\\n if (s[i] != a && s[i] != b) {\\n f = 0;\\n break;\\n }\\n }\\n if (f) {\\n return s;\\n }\\n }\\n }\\n return res;\\n}\\nvoid solve() {\\n string s;\\n cin >> s;\\n int k;\\n cin >> k;\\n if (k == 1) {\\n cout << solve1(s) << \\\"\\\\n\\\";\\n return;\\n } else\\n cout << solve2(s);\\n cout << \\\"\\\\n\\\";\\n}\\nint main() {\\n ios::sync_with_stdio(false);\\n cin.tie(0);\\n int t;\\n cin >> t;\\n while (t--) {\\n solve();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array a of n non-negative integers.\\n\\nDark created that array 1000 years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elements with a high absolute difference between them. He doesn't have much time so he wants to choose an integer k (0 ≤ k ≤ 10^{9}) and replaces all missing elements in the array a with k.\\n\\nLet m be the maximum absolute difference between all adjacent elements (i.e. the maximum value of |a_i - a_{i+1}| for all 1 ≤ i ≤ n - 1) in the array a after Dark replaces all missing elements with k.\\n\\nDark should choose an integer k so that m is minimized. Can you help him?\\n\\nInput\\n\\nThe input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. The description of the test cases follows.\\n\\nThe first line of each test case contains one integer n (2 ≤ n ≤ 10^{5}) — the size of the array a.\\n\\nThe second line of each test case contains n integers a_1, a_2, …, a_n (-1 ≤ a_i ≤ 10 ^ {9}). If a_i = -1, then the i-th integer is missing. It is guaranteed that at least one integer is missing in every test case.\\n\\nIt is guaranteed, that the sum of n for all test cases does not exceed 4 ⋅ 10 ^ {5}.\\n\\nOutput\\n\\nPrint the answers for each test case in the following format:\\n\\nYou should print two integers, the minimum possible value of m and an integer k (0 ≤ k ≤ 10^{9}) that makes the maximum absolute difference between adjacent elements in the array a equal to m.\\n\\nMake sure that after replacing all the missing elements with k, the maximum absolute difference between adjacent elements becomes m.\\n\\nIf there is more than one possible k, you can print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n7\\n5\\n-1 10 -1 12 -1\\n5\\n-1 40 35 -1 35\\n6\\n-1 -1 9 -1 3 -1\\n2\\n-1 -1\\n2\\n0 -1\\n4\\n1 -1 3 -1\\n7\\n1 -1 7 5 2 -1 5\\n\\n\\nOutput\\n\\n\\n1 11\\n5 35\\n3 6\\n0 42\\n0 0\\n1 2\\n3 4\\n\\nNote\\n\\nIn the first test case after replacing all missing elements...\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\nimport java.math.*;\\nimport java.lang.*;\\n \\nimport static java.lang.Math.*;\\n \\npublic class MakingString implements Runnable \\n{\\n static class InputReader \\n {\\n private InputStream stream;\\n private byte[] buf = new byte[1024];\\n private int curChar;\\n private int numChars;\\n private SpaceCharFilter filter;\\n private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\\n \\n public InputReader(InputStream stream) \\n {\\n this.stream = stream;\\n }\\n \\n public int read()\\n {\\n if (numChars==-1) \\n throw new InputMismatchException();\\n \\n if (curChar >= numChars) \\n {\\n curChar = 0;\\n try\\n {\\n numChars = stream.read(buf);\\n }\\n catch (IOException e)\\n {\\n throw new InputMismatchException();\\n }\\n \\n if(numChars <= 0) \\n return -1;\\n }\\n return buf[curChar++];\\n }\\n \\n public String nextLine()\\n {\\n String str = \\\"\\\";\\n try\\n {\\n str = br.readLine();\\n }\\n catch (IOException e)\\n {\\n e.printStackTrace();\\n }\\n return str;\\n }\\n public int nextInt() \\n {\\n int c = read();\\n \\n while(isSpaceChar(c)) \\n c = read();\\n \\n int sgn = 1;\\n \\n if (c == '-') \\n {\\n sgn = -1;\\n c = read();\\n }\\n \\n int res = 0;\\n do\\n {\\n if(c<'0'||c>'9') \\n throw new InputMismatchException();\\n res *= 10;\\n res += c - '0';\\n c = read();\\n }\\n ...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given two integers n and m. Find the \\\\operatorname{MEX} of the sequence n ⊕ 0, n ⊕ 1, …, n ⊕ m. Here, ⊕ is the [bitwise XOR operator](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#XOR).\\n\\n\\\\operatorname{MEX} of the sequence of non-negative integers is the smallest non-negative integer that doesn't appear in this sequence. For example, \\\\operatorname{MEX}(0, 1, 2, 4) = 3, and \\\\operatorname{MEX}(1, 2021) = 0. \\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 30 000) — the number of test cases.\\n\\nThe first and only line of each test case contains two integers n and m (0 ≤ n, m ≤ 10^9).\\n\\nOutput\\n\\nFor each test case, print a single integer — the answer to the problem.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n3 5\\n4 6\\n3 2\\n69 696\\n123456 654321\\n\\n\\nOutput\\n\\n\\n4\\n3\\n0\\n640\\n530866\\n\\nNote\\n\\nIn the first test case, the sequence is 3 ⊕ 0, 3 ⊕ 1, 3 ⊕ 2, 3 ⊕ 3, 3 ⊕ 4, 3 ⊕ 5, or 3, 2, 1, 0, 7, 6. The smallest non-negative integer which isn't present in the sequence i. e. the \\\\operatorname{MEX} of the sequence is 4.\\n\\nIn the second test case, the sequence is 4 ⊕ 0, 4 ⊕ 1, 4 ⊕ 2, 4 ⊕ 3, 4 ⊕ 4, 4 ⊕ 5, 4 ⊕ 6, or 4, 5, 6, 7, 0, 1, 2. The smallest non-negative integer which isn't present in the sequence i. e. the \\\\operatorname{MEX} of the sequence is 3.\\n\\nIn the third test case, the sequence is 3 ⊕ 0, 3 ⊕ 1, 3 ⊕ 2, or 3, 2, 1. The smallest non-negative integer which isn't present in the sequence i. e. the \\\\operatorname{MEX} of the sequence is 0.\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\n\\npublic class C_Mikasa{\\n public static void main(String[] args) {\\n FastScanner s= new FastScanner();\\n StringBuilder res = new StringBuilder();\\n int t=s.nextInt();\\n int p=0;\\n while(pm){\\n res.append(\\\"0\\\\n\\\");\\n p++;\\n continue;\\n }\\n int first[]= new int[32];\\n int second[]= new int[32];\\n int num1=n;\\n int k=0;\\n while(num1>0){\\n int yo=num1&1;\\n first[k]=yo;\\n num1=num1>>1;\\n k++;\\n\\n }\\n k=0;\\n num1=m;\\n while(num1>0){\\n int yo=num1&1;\\n second[k]=yo;\\n num1=num1>>1;\\n k++;\\n\\n }\\n \\/\\/ for(int i=0;i<32;i++){\\n \\/\\/ System.out.print(first[i]+\\\" \\\");\\n \\/\\/ }\\n \\/\\/ System.out.println();\\n\\n \\/\\/ for(int i=0;i<32;i++){\\n \\/\\/ System.out.print(second[i]+\\\" \\\");\\n \\/\\/ }\\n \\/\\/ System.out.println();\\n long min=Long.MAX_VALUE;\\n long val=0;\\n for(int i=31;i>=0;i--){\\n if(second[i]==0){\\n int num2=1^first[i];\\n long pow=0;\\n \\n pow=((long)Math.pow(2,i))*num2;\\n min=Math.min(min,(val+pow));\\n \\n \\n \\n \\n }\\n else{\\n long numm=((long)Math.pow(2,i))*(1^first[i]);\\n val+=numm;\\n }\\n }\\n res.append(min+\\\"\\\\n\\\");\\n p++;\\n }\\n System.out.println(res);\\n\\n\\n }\\n static class FastScanner {\\n\\t\\tBufferedReader br;\\n\\t\\tStringTokenizer st;\\n \\n\\t\\tpublic FastScanner(String s) {\\n\\t\\t\\ttry {\\n\\t\\t\\t\\tbr = new BufferedReader(new FileReader(s));\\n\\t\\t\\t} catch (FileNotFoundException e) {\\n\\t\\t\\t\\t\\/\\/ TODO Auto-generated catch block\\n\\t\\t\\t\\te.printStackTrace();\\n\\t\\t\\t}\\n\\t\\t}\\n \\n\\t\\tpublic FastScanner() {\\n\\t\\t\\tbr = new BufferedReader(new InputStreamReader(System.in));\\n\\t\\t}\\n \\n\\t\\tString...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1, a2, ..., an centimeters. Some soldiers are of the same height. Bob wants to know, how many ways exist to form a reconnaissance unit of two soldiers from his detachment.\\n\\nWays (1, 2) and (2, 1) should be regarded as different.\\n\\nInput\\n\\nThe first line contains two integers n and d (1 ≤ n ≤ 1000, 1 ≤ d ≤ 109) — amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers — heights of all the soldiers in Bob's detachment. These numbers don't exceed 109.\\n\\nOutput\\n\\nOutput one number — amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d.\\n\\nExamples\\n\\nInput\\n\\n5 10\\n10 20 50 60 65\\n\\n\\nOutput\\n\\n6\\n\\n\\nInput\\n\\n5 1\\n55 30 29 31 55\\n\\n\\nOutput\\n\\n6\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\ninline int min(int a, int b) { return a < b ? a : b; }\\ninline int max(int a, int b) { return a > b ? a : b; }\\nconst int maxV = 2500;\\nconst int maxE = 900000;\\nconst int INF = 214748364;\\nconst double eps = 1e-8;\\nint a[10009], b[10009];\\nint main(int argc, char** argv) {\\n int n, i, k, j, t;\\n while (scanf(\\\"%d%d\\\", &n, &k) != EOF) {\\n for (i = 1; i <= n; i++) scanf(\\\"%d\\\", &a[i]);\\n sort(a + 1, a + n + 1);\\n t = 0;\\n for (i = 1; i <= n; i++) {\\n for (j = i + 1; j <= n; j++) {\\n if (a[j] - a[i] > k) break;\\n t++;\\n }\\n }\\n printf(\\\"%d\\\\n\\\", 2 * t);\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given a binary string (i. e. a string consisting of characters 0 and\\/or 1) s of length n. You can perform the following operation with the string s at most once: choose a substring (a contiguous subsequence) of s having exactly k characters 1 in it, and shuffle it (reorder the characters in the substring as you wish).\\n\\nCalculate the number of different strings which can be obtained from s by performing this operation at most once.\\n\\nInput\\n\\nThe first line contains two integers n and k (2 ≤ n ≤ 5000; 0 ≤ k ≤ n).\\n\\nThe second line contains the string s of length n, consisting of characters 0 and\\/or 1.\\n\\nOutput\\n\\nPrint one integer — the number of different strings which can be obtained from s by performing the described operation at most once. Since the answer can be large, output it modulo 998244353.\\n\\nExamples\\n\\nInput\\n\\n\\n7 2\\n1100110\\n\\n\\nOutput\\n\\n\\n16\\n\\n\\nInput\\n\\n\\n5 0\\n10010\\n\\n\\nOutput\\n\\n\\n1\\n\\n\\nInput\\n\\n\\n8 1\\n10001000\\n\\n\\nOutput\\n\\n\\n10\\n\\n\\nInput\\n\\n\\n10 8\\n0010011000\\n\\n\\nOutput\\n\\n\\n1\\n\\nNote\\n\\nSome strings you can obtain in the first example:\\n\\n * to obtain 0110110, you can take the substring from the 1-st character to the 4-th character, which is 1100, and reorder its characters to get 0110; \\n * to obtain 1111000, you can take the substring from the 3-rd character to the 7-th character, which is 00110, and reorder its characters to get 11000; \\n * to obtain 1100101, you can take the substring from the 5-th character to the 7-th character, which is 110, and reorder its characters to get 101. \\n\\n\\n\\nIn the second example, k = 0 so you can only choose the substrings consisting only of 0 characters. Reordering them doesn't change the string at all, so the only string you can obtain is 10010.\\nimpor\",\"targets\":\"t sys\\nimport heapq\\nfrom bisect import bisect_left\\nfrom collections import Counter, deque, defaultdict\\ninput = lambda: sys.stdin.readline().rstrip(\\\"\\\\r\\\\n\\\")\\nsys.setrecursionlimit(300005)\\nLOGN = 20\\nINF = 10 ** 9 + 5\\n# MOD = 10 ** 9 + 7\\nMOD = 998244353\\n# ============================ START OF MY CODE ============================\\n\\nclass nCk:\\n def __init__(self, maxn, mod):\\n self.mod = mod\\n self.fact = fact = [1 for _ in range(maxn + 1)]\\n self.temp = temp = [1 for _ in range(maxn + 1)]\\n self.invs = invs = [1 for _ in range(maxn + 1)]\\n for i in range(2, maxn + 1):\\n fact[i] = fact[i - 1] * i % mod\\n temp[i] = (- temp[mod % i] * (mod \\/\\/ i)) % mod\\n invs[i] = invs[i - 1] * temp[i] % mod\\n\\n def get(self, n, k):\\n if not 0 <= k <= n:\\n return 0\\n return (self.fact[n] * self.invs[k] % self.mod) * self.invs[n - k] % self.mod\\n\\ndef solve():\\n N, K = map(int, input().split())\\n S = input()\\n if S.count('1') < K or K == 0:\\n print(1)\\n return\\n\\n nck = nCk(5001, MOD)\\n ans = left = 0\\n cur_ones = 0\\n for right in range(N):\\n cur_ones += int(S[right])\\n while cur_ones > K:\\n cur_ones -= int(S[left])\\n left += 1\\n if S[right] == '1' and right - left >= cur_ones:\\n ans += nck.get(right - left, cur_ones)\\n if S[right] != '1' and right - left >= cur_ones - 1 >= 0:\\n ans += nck.get(right - left, cur_ones - 1)\\n ans %= MOD\\n print((ans + 1) % MOD)\\n\\nif __name__ == \\\"__main__\\\":\\n solve()\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Let's call a set of positive integers a_1, a_2, ..., a_k quadratic if the product of the factorials of its elements is a square of an integer, i. e. ∏_{i=1}^{k} a_i! = m^2, for some integer m.\\n\\nYou are given a positive integer n.\\n\\nYour task is to find a quadratic subset of a set 1, 2, ..., n of maximum size. If there are multiple answers, print any of them.\\n\\nInput\\n\\nA single line contains a single integer n (1 ≤ n ≤ 10^6).\\n\\nOutput\\n\\nIn the first line, print a single integer — the size of the maximum subset. In the second line, print the subset itself in an arbitrary order.\\n\\nExamples\\n\\nInput\\n\\n\\n1\\n\\n\\nOutput\\n\\n\\n1\\n1 \\n\\n\\nInput\\n\\n\\n4\\n\\n\\nOutput\\n\\n\\n3\\n1 3 4 \\n\\n\\nInput\\n\\n\\n7\\n\\n\\nOutput\\n\\n\\n4\\n1 4 5 6 \\n\\n\\nInput\\n\\n\\n9\\n\\n\\nOutput\\n\\n\\n7\\n1 2 4 5 6 7 9 \\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\n#pragma GCC optimize(\\\"Ofast\\\")\\nusing namespace std;\\ntemplate \\nbool ckmin(T &a, const T &b) {\\n return b < a ? a = b, 1 : 0;\\n}\\ntemplate \\nbool ckmax(T &a, const T &b) {\\n return a < b ? a = b, 1 : 0;\\n}\\nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\\nmt19937 rnd(time(nullptr));\\nvoid __print(long long first) { cerr << first; }\\nvoid __print(long first) { cerr << first; }\\nvoid __print(unsigned first) { cerr << first; }\\nvoid __print(unsigned long first) { cerr << first; }\\nvoid __print(unsigned long long first) { cerr << first; }\\nvoid __print(float first) { cerr << first; }\\nvoid __print(double first) { cerr << first; }\\nvoid __print(long double first) { cerr << first; }\\nvoid __print(char first) { cerr << '\\\\'' << first << '\\\\''; }\\nvoid __print(const char *first) { cerr << '\\\\\\\"' << first << '\\\\\\\"'; }\\nvoid __print(const string &first) { cerr << '\\\\\\\"' << first << '\\\\\\\"'; }\\nvoid __print(bool first) { cerr << (first ? \\\"true\\\" : \\\"false\\\"); }\\ntemplate \\nvoid __print(const pair &first) {\\n cerr << '{';\\n __print(first.first);\\n cerr << \\\", \\\";\\n __print(first.second);\\n cerr << '}';\\n}\\ntemplate \\nvoid __print(const T &first) {\\n long long f = 0;\\n cerr << '{';\\n for (auto &i : first) cerr << (f++ ? \\\", \\\" : \\\"\\\"), __print(i);\\n cerr << \\\"}\\\";\\n}\\nvoid _print() { cerr << \\\"]\\\\n\\\"; }\\ntemplate \\nvoid _print(T t, V... v) {\\n __print(t);\\n if (sizeof...(v)) cerr << \\\", \\\";\\n _print(v...);\\n}\\nconst long long N = 1e6 + 5;\\nvector fact[N];\\nlong long val[N], hsh[N];\\nbool try_(long long n) {\\n long long res = 0;\\n for (long long i = 2; i <= n; ++i) {\\n res ^= val[i];\\n }\\n if (res == 0) {\\n cout << n << \\\"\\\\n\\\";\\n for (long long i = 1; i <= n; ++i) {\\n cout << i << \\\" \\\";\\n }\\n return true;\\n }\\n for (long long i = 2; i <= n; ++i) {\\n if (val[i] == res) {\\n cout << n - 1 << \\\"\\\\n\\\";\\n for (long long j = 1; j <= n; ++j) {\\n if (i != j) {\\n cout << j << \\\" \\\";\\n }\\n }\\n return true;\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"The grasshopper is located on the numeric axis at the point with coordinate x_0.\\n\\nHaving nothing else to do he starts jumping between integer points on the axis. Making a jump from a point with coordinate x with a distance d to the left moves the grasshopper to a point with a coordinate x - d, while jumping to the right moves him to a point with a coordinate x + d.\\n\\nThe grasshopper is very fond of positive integers, so for each integer i starting with 1 the following holds: exactly i minutes after the start he makes a jump with a distance of exactly i. So, in the first minutes he jumps by 1, then by 2, and so on.\\n\\nThe direction of a jump is determined as follows: if the point where the grasshopper was before the jump has an even coordinate, the grasshopper jumps to the left, otherwise he jumps to the right.\\n\\nFor example, if after 18 consecutive jumps he arrives at the point with a coordinate 7, he will jump by a distance of 19 to the right, since 7 is an odd number, and will end up at a point 7 + 19 = 26. Since 26 is an even number, the next jump the grasshopper will make to the left by a distance of 20, and it will move him to the point 26 - 20 = 6.\\n\\nFind exactly which point the grasshopper will be at after exactly n jumps.\\n\\nInput\\n\\nThe first line of input contains an integer t (1 ≤ t ≤ 10^4) — the number of test cases.\\n\\nEach of the following t lines contains two integers x_0 (-10^{14} ≤ x_0 ≤ 10^{14}) and n (0 ≤ n ≤ 10^{14}) — the coordinate of the grasshopper's initial position and the number of jumps.\\n\\nOutput\\n\\nPrint exactly t lines. On the i-th line print one integer — the answer to the i-th test case — the coordinate of the point the grasshopper will be at after making n jumps from the point x_0.\\n\\nExample\\n\\nInput\\n\\n\\n9\\n0 1\\n0 2\\n10 10\\n10 99\\n177 13\\n10000000000 987654321\\n-433494437 87178291199\\n1 0\\n-1 1\\n\\n\\nOutput\\n\\n\\n-1\\n1\\n11\\n110\\n190\\n9012345679\\n-87611785637\\n1\\n0\\n\\nNote\\n\\nThe first two test cases in the example correspond to the first two jumps from the point x_0 = 0. \\n\\nSince 0 is an even number, the first jump of length...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n int t;\\n cin >> t;\\n while (t--) {\\n long long int x, n;\\n cin >> x >> n;\\n if (n == 0)\\n cout << x << endl;\\n else if (n > 0) {\\n long long int nums = (n \\/ 4) * 4;\\n n = n % 4;\\n long long int cnt = 0;\\n nums++;\\n while (cnt < n) {\\n if (x % 2 == 0)\\n x -= nums;\\n else\\n x += nums;\\n cnt++;\\n nums++;\\n }\\n cout << x << endl;\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given n integers a_1, a_2, …, a_n and an integer k. Find the maximum value of i ⋅ j - k ⋅ (a_i | a_j) over all pairs (i, j) of integers with 1 ≤ i < j ≤ n. Here, | is the [bitwise OR operator](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#OR).\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10 000) — the number of test cases.\\n\\nThe first line of each test case contains two integers n (2 ≤ n ≤ 10^5) and k (1 ≤ k ≤ min(n, 100)).\\n\\nThe second line of each test case contains n integers a_1, a_2, …, a_n (0 ≤ a_i ≤ n).\\n\\nIt is guaranteed that the sum of n over all test cases doesn't exceed 3 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print a single integer — the maximum possible value of i ⋅ j - k ⋅ (a_i | a_j).\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3 3\\n1 1 3\\n2 2\\n1 2\\n4 3\\n0 1 2 3\\n6 6\\n3 2 0 0 5 6\\n\\n\\nOutput\\n\\n\\n-1\\n-4\\n3\\n12\\n\\nNote\\n\\nLet f(i, j) = i ⋅ j - k ⋅ (a_i | a_j).\\n\\nIn the first test case, \\n\\n * f(1, 2) = 1 ⋅ 2 - k ⋅ (a_1 | a_2) = 2 - 3 ⋅ (1 | 1) = -1. \\n * f(1, 3) = 1 ⋅ 3 - k ⋅ (a_1 | a_3) = 3 - 3 ⋅ (1 | 3) = -6. \\n * f(2, 3) = 2 ⋅ 3 - k ⋅ (a_2 | a_3) = 6 - 3 ⋅ (1 | 3) = -3. \\n\\n\\n\\nSo the maximum is f(1, 2) = -1.\\n\\nIn the fourth test case, the maximum is f(3, 4) = 12.\\n#incl\",\"targets\":\"ude \\nconst long long N = 2e5 + 5, MOD = 1e9 + 7, INF = LONG_MAX;\\nusing namespace std;\\nint dx[] = {-1, -1, 0, 1, 1, 1, 0, -1};\\nint dy[] = {0, 1, 1, 1, 0, -1, -1, -1};\\nlong long n, m, t;\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n cin >> t;\\n while (t--) {\\n cin >> n >> m;\\n vector a(n);\\n for (auto &it : a) cin >> it;\\n long long ans = -1e9;\\n for (long long i = max(0LL, n - 1000); i < n; ++i) {\\n for (long long j = i + 1; j < n; ++j)\\n ans = max(ans, ((i + 1) * (j + 1)) - m * (a[i] | a[j]));\\n }\\n cout << ans << '\\\\n';\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nJohnny is at a carnival which has n raffles. Raffle i has a prize with value pi. Each participant can put tickets in whichever raffles they choose (they may have more than one ticket in a single raffle). At the end of the carnival, one ticket is selected at random from each raffle, and the owner of the ticket wins the associated prize. A single person can win multiple prizes from different raffles. \\n\\nHowever, county rules prevent any one participant from owning more than half the tickets in a single raffle, i.e. putting more tickets in the raffle than all the other participants combined. To help combat this (and possibly win some prizes), the organizers started by placing a single ticket in each raffle, which they will never remove.\\n\\nJohnny bought t tickets and is wondering where to place them. Currently, there are a total of li tickets in the i-th raffle. He watches as other participants place tickets and modify their decisions and, at every moment in time, wants to know how much he can possibly earn. Find the maximum possible expected value of Johnny's winnings at each moment if he distributes his tickets optimally. Johnny may redistribute all of his tickets arbitrarily between each update, but he may not place more than t tickets total or have more tickets in a single raffle than all other participants combined.\\n\\nInput\\n\\nThe first line contains two integers n, t, and q (1 ≤ n, t, q ≤ 200 000) — the number of raffles, the number of tickets Johnny has, and the total number of updates, respectively.\\n\\nThe second line contains n space-separated integers pi (1 ≤ pi ≤ 1000) — the value of the i-th prize.\\n\\nThe third line contains n space-separated integers li (1 ≤ li ≤ 1000) — the number of tickets initially in the i-th raffle.\\n\\nThe last q lines contain the descriptions of the updates. Each description contains two integers tk, rk (1 ≤ tk ≤ 2, 1 ≤ rk ≤ n) — the type of the update and the raffle number. An update of type 1 represents another participant adding a ticket to raffle rk. An update of type 2 represents...\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 1e6;\\nint gi() {\\n int w = 0;\\n bool q = 1;\\n char c = getchar();\\n while ((c < '0' || c > '9') && c != '-') c = getchar();\\n if (c == '-') q = 0, c = getchar();\\n while (c >= '0' && c <= '9') w = w * 10 + c - '0', c = getchar();\\n return q ? w : -w;\\n}\\ndouble ans;\\nint n, T;\\nint use[N], l[N];\\ndouble p[N];\\nstruct heap {\\n int q[N], in[N];\\n double v[N];\\n inline void up(int a) {\\n int id = q[a], b = a >> 1;\\n while (b && v[q[b]] < v[id]) {\\n in[q[a] = q[b]] = a;\\n a = b, b >>= 1;\\n }\\n in[q[a] = id] = a;\\n }\\n inline void down(int a) {\\n int id = q[a], b = a << 1;\\n while (b <= n) {\\n if (b < n && v[q[b | 1]] > v[q[b]]) b |= 1;\\n if (v[id] > v[q[b]]) break;\\n in[q[a] = q[b]] = a;\\n a = b, b <<= 1;\\n }\\n in[q[a] = id] = a;\\n }\\n} q1, q2;\\ninline bool cmp(const int &a, const int &b) { return q1.v[a] > q1.v[b]; }\\ninline void update(int k) {\\n q1.v[k] = use[k] == l[k] ? -1\\n : p[k] * (use[k] + 1) \\/ (use[k] + l[k] + 1) -\\n p[k] * use[k] \\/ (use[k] + l[k]);\\n q2.v[k] = use[k] ? p[k] * (use[k] - 1) \\/ (use[k] - 1 + l[k]) -\\n p[k] * use[k] \\/ (use[k] + l[k])\\n : -1 << 30;\\n q1.up(q1.in[k]);\\n q1.down(q1.in[k]);\\n q2.up(q2.in[k]);\\n q2.down(q2.in[k]);\\n}\\ninline void ins(int k) {\\n T--;\\n ans += q1.v[k];\\n ++use[k];\\n update(k);\\n}\\ninline void del(int k) {\\n T++;\\n ans += q2.v[k];\\n --use[k];\\n update(k);\\n}\\nint main() {\\n n = gi(), T = gi();\\n int Q = gi(), i, k;\\n for (i = 1; i <= n; i++) p[i] = gi();\\n for (i = 1; i <= n; i++) l[i] = gi();\\n for (i = 1; i <= n; i++) q1.v[q1.q[i] = i] = p[i] \\/ (l[i] + 1);\\n sort(q1.q + 1, q1.q + 1 + n, cmp);\\n for (i = 1; i <= n; i++) q1.in[q1.q[i]] = i;\\n for (i = 1; i <= n; i++) q2.q[q2.in[i] = i] = i, q2.v[i] = -1 << 30;\\n while (T && q1.v[k = q1.q[1]] > 0) ins(k);\\n while (Q--) {\\n if (gi() == 1) {\\n k = gi();\\n ans -= p[k] * use[k] \\/ (use[k] + l[k]);\\n ans += p[k] * use[k] \\/ (use[k]...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CQXYM wants to create a connected undirected graph with n nodes and m edges, and the diameter of the graph must be strictly less than k-1. Also, CQXYM doesn't want a graph that contains self-loops or multiple edges (i.e. each edge connects two different vertices and between each pair of vertices there is at most one edge).\\n\\nThe diameter of a graph is the maximum distance between any two nodes.\\n\\nThe distance between two nodes is the minimum number of the edges on the path which endpoints are the two nodes.\\n\\nCQXYM wonders whether it is possible to create such a graph.\\n\\nInput\\n\\nThe input consists of multiple test cases. \\n\\nThe first line contains an integer t (1 ≤ t ≤ 10^5) — the number of test cases. The description of the test cases follows.\\n\\nOnly one line of each test case contains three integers n(1 ≤ n ≤ 10^9), m, k (0 ≤ m,k ≤ 10^9).\\n\\nOutput\\n\\nFor each test case, print YES if it is possible to create the graph, or print NO if it is impossible. You can print each letter in any case (upper or lower).\\n\\nExample\\n\\nInput\\n\\n\\n5\\n1 0 3\\n4 5 3\\n4 6 3\\n5 4 1\\n2 1 1\\n\\n\\nOutput\\n\\n\\nYES\\nNO\\nYES\\nNO\\nNO\\n\\nNote\\n\\nIn the first test case, the graph's diameter equal to 0.\\n\\nIn the second test case, the graph's diameter can only be 2.\\n\\nIn the third test case, the graph's diameter can only be 1.\\nSolve the task in PYTHON3.\",\"targets\":\"def c(n):\\n return n*(n-1)\\/\\/2\\n\\ndef solve(n, m, k):\\n if n==1:\\n ## dia is 0\\n if m==0 and k>=2:\\n return \\\"YES\\\"\\n else:\\n return \\\"NO\\\"\\n if n==2:\\n ## dia is 1\\n if m==1 and k>=3:\\n return \\\"YES\\\"\\n else:\\n return \\\"NO\\\"\\n if m < n-1:\\n return \\\"NO\\\"\\n if m < c(n):\\n ## diameter is 2\\n if k>3:\\n return \\\"YES\\\"\\n elif m == c(n):\\n ## dai is always 1\\n if k>=3:\\n return \\\"YES\\\"\\n return \\\"NO\\\"\\nfor case in range(int(input())):\\n n, m, k = map(int, input().split())\\n ans = solve(n, m, k)\\n print(ans)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"An important meeting is to be held and there are exactly n people invited. At any moment, any two people can step back and talk in private. The same two people can talk several (as many as they want) times per meeting.\\n\\nEach person has limited sociability. The sociability of the i-th person is a non-negative integer a_i. This means that after exactly a_i talks this person leaves the meeting (and does not talk to anyone else anymore). If a_i = 0, the i-th person leaves the meeting immediately after it starts.\\n\\nA meeting is considered most productive if the maximum possible number of talks took place during it.\\n\\nYou are given an array of sociability a, determine which people should talk to each other so that the total number of talks is as large as possible.\\n\\nInput\\n\\nThe first line contains an integer t (1 ≤ t ≤ 1000) — the number of test cases.\\n\\nThe next 2t lines contain descriptions of the test cases.\\n\\nThe first line of each test case description contains an integer n (2 ≤ n ≤ 2 ⋅ 10^5) —the number of people in the meeting. The second line consists of n space-separated integers a_1, a_2, ..., a_n (0 ≤ a_i ≤ 2 ⋅ 10^5) — the sociability parameters of all people. \\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5. It is also guaranteed that the sum of all a_i (over all test cases and all i) does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nPrint t answers to all test cases.\\n\\nOn the first line of each answer print the number k — the maximum number of talks possible in a meeting.\\n\\nOn each of the next k lines print two integers i and j (1 ≤ i, j ≤ n and i ≠ j) — the numbers of people who will have another talk.\\n\\nIf there are several possible answers, you may print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n8\\n2\\n2 3\\n3\\n1 2 3\\n4\\n1 2 3 4\\n3\\n0 0 2\\n2\\n6 2\\n3\\n0 0 2\\n5\\n8 2 0 1 1\\n5\\n0 1 0 0 6\\n\\n\\nOutput\\n\\n\\n2\\n1 2\\n1 2\\n3\\n1 3\\n2 3\\n2 3\\n5\\n1 3\\n2 4\\n2 4\\n3 4\\n3 4\\n0\\n2\\n1 2\\n1 2\\n0\\n4\\n1 2\\n1 5\\n1 4\\n1 2\\n1\\n5 2\\nSolve the task in PYTHON3.\",\"targets\":\"import io,os\\nimport heapq \\n\\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\\n\\ndef main(t):\\n\\n\\n n = int(input())\\n arr = list(map(int,input().split()))\\n ans = []\\n\\n\\n heap = []\\n for i in range(n): heapq.heappush(heap,[-arr[i],i+1])\\n\\n while len(heap)>1:\\n p1 = heapq.heappop(heap)\\n p2 = heapq.heappop(heap)\\n if p1[0]==0 or p2[0]==0: break\\n p1[0] += 1\\n p2[0] += 1\\n ans.append([p1[1],p2[1]])\\n if p1[0]<0: heapq.heappush(heap,p1)\\n if p2[0]<0: heapq.heappush(heap,p2)\\n \\n\\n print(len(ans))\\n for ele in ans:\\n print(min(ele),max(ele))\\n\\n \\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\nT = int(input())\\nt = 1\\nwhile t<=T:\\n main(t)\\n t += 1\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A and B are preparing themselves for programming contests.\\n\\nTo train their logical thinking and solve problems better, A and B decided to play chess. During the game A wondered whose position is now stronger.\\n\\nFor each chess piece we know its weight: \\n\\n * the queen's weight is 9, \\n * the rook's weight is 5, \\n * the bishop's weight is 3, \\n * the knight's weight is 3, \\n * the pawn's weight is 1, \\n * the king's weight isn't considered in evaluating position. \\n\\n\\n\\nThe player's weight equals to the sum of weights of all his pieces on the board.\\n\\nAs A doesn't like counting, he asked you to help him determine which player has the larger position weight.\\n\\nInput\\n\\nThe input contains eight lines, eight characters each — the board's description.\\n\\nThe white pieces on the board are marked with uppercase letters, the black pieces are marked with lowercase letters.\\n\\nThe white pieces are denoted as follows: the queen is represented is 'Q', the rook — as 'R', the bishop — as'B', the knight — as 'N', the pawn — as 'P', the king — as 'K'.\\n\\nThe black pieces are denoted as 'q', 'r', 'b', 'n', 'p', 'k', respectively.\\n\\nAn empty square of the board is marked as '.' (a dot). \\n\\nIt is not guaranteed that the given chess position can be achieved in a real game. Specifically, there can be an arbitrary (possibly zero) number pieces of each type, the king may be under attack and so on.\\n\\nOutput\\n\\nPrint \\\"White\\\" (without quotes) if the weight of the position of the white pieces is more than the weight of the position of the black pieces, print \\\"Black\\\" if the weight of the black pieces is more than the weight of the white pieces and print \\\"Draw\\\" if the weights of the white and black pieces are equal.\\n\\nExamples\\n\\nInput\\n\\n...QK...\\n........\\n........\\n........\\n........\\n........\\n........\\n...rk...\\n\\n\\nOutput\\n\\nWhite\\n\\n\\nInput\\n\\nrnbqkbnr\\npppppppp\\n........\\n........\\n........\\n........\\nPPPPPPPP\\nRNBQKBNR\\n\\n\\nOutput\\n\\nDraw\\n\\n\\nInput\\n\\nrppppppr\\n...k....\\n........\\n........\\n........\\n........\\nK...Q...\\n........\\n\\n\\nOutput\\n\\nBlack\\n\\nNote\\n\\nIn the first test sample the weight of...\\nSolve the task in PYTHON.\",\"targets\":\"#!\\/usr\\/bin\\/python2.7\\nwb = ww = 0\\nfor i in range(8):\\n\\tstr = raw_input()\\n\\tfor j in str:\\n\\t\\tif j == 'Q': ww += 9\\n\\t\\telif j == 'R': ww += 5\\n\\t\\telif j == 'B': ww += 3\\n\\t\\telif j == 'N': ww += 3\\n\\t\\telif j == 'P': ww += 1\\n\\t\\telif j == 'q': wb += 9\\n\\t\\telif j == 'r': wb += 5\\n\\t\\telif j == 'b': wb += 3\\n\\t\\telif j == 'n': wb += 3\\n\\t\\telif j == 'p': wb += 1\\nif ww > wb:\\n\\tprint 'White'\\nelif ww < wb:\\n\\tprint 'Black'\\nelse:\\n\\tprint 'Draw'\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n"