"{\"inputs\":\"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...\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.util.*;\\nimport java.lang.*;\\nimport java.io.*;\\n \\npublic class main\\n{\\n \\n \\n\\tpublic static void main (String[] args) throws java.lang.Exception\\n\\t{\\n\\t\\tFastReader sc=new FastReader();\\n int t = sc.nextInt();\\n while(t-->0){\\n int n = sc.nextInt();\\n \\n String u = sc.next();\\n String d = sc.next();\\n \\n char[] up = u.toCharArray();\\n char[] down = d.toCharArray();\\n int res = 0;\\n \\n for(int i=0;i0 && up[i-1]=='1'){\\n up[i-1]='2';\\n res++;\\n }\\n else if(up[i]=='0'){\\n up[i]='2';\\n res++;\\n }\\n else if(i'. 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.\\nfor _\",\"targets\":\"in range(int(input())):\\n \\n x1, p1 = map(int, input().split())\\n x2, p2 = map(int, input().split())\\n\\n gu = len(str(x1)) +p1\\n a2c = len(str(x2)) +p2\\n if (gu> a2c):\\n print(\\\">\\\")\\n elif (gu< a2c):\\n print(\\\"<\\\")\\n else:\\n a = min(p1, p2)\\n p1 = p1 -a\\n p2 = p2 - a\\n\\n\\n\\n gullu = (p1 *'0')\\n gul = str(x1) + gullu\\n a20 = (p2 *'0')\\n gull = str(x2) + a20\\n if (int(gul) > int(gull)):\\n print(\\\">\\\")\\n elif (int(gul) == int(gull)):\\n print(\\\"=\\\")\\n else:\\n print( \\\"<\\\" )\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A subsequence of a string S is a string that can be obtained by deleting zero or more characters from S without changing the order of the remaining characters. For example, `arc`, `artistic` and (an empty string) are all subsequences of `artistic`; `abc` and `ci` are not.\\n\\nYou are given a string A consisting of lowercase English letters. Find the shortest string among the strings consisting of lowercase English letters that are not subsequences of A. If there are more than one such string, find the lexicographically smallest one among them.\\n\\nConstraints\\n\\n* 1 \\\\leq |A| \\\\leq 2 \\\\times 10^5\\n* A consists of lowercase English letters.\\n\\nInput\\n\\nInput is given from Standard Input in the following format:\\n\\n\\nA\\n\\n\\nOutput\\n\\nPrint the lexicographically smallest string among the shortest strings consisting of lowercase English letters that are not subsequences of A.\\n\\nExamples\\n\\nInput\\n\\natcoderregularcontest\\n\\n\\nOutput\\n\\nb\\n\\n\\nInput\\n\\nabcdefghijklmnopqrstuvwxyz\\n\\n\\nOutput\\n\\naa\\n\\n\\nInput\\n\\nfrqnvhydscshfcgdemurlfrutcpzhopfotpifgepnqjxupnskapziurswqazdwnwbgdhyktfyhqqxpoidfhjdakoxraiedxskywuepzfniuyskxiyjpjlxuqnfgmnjcvtlpnclfkpervxmdbvrbrdn\\n\\n\\nOutput\\n\\naca\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\n\\nint dp[200010];\\nint last[200010], CCC[200010];\\nint nxt[26];\\n\\nint main () {\\n\\tstring s; cin >> s;\\n\\tint n = s.size();\\n\\tfor (int i = 0; i < 26; i++) {\\n\\t\\tnxt[i] = n;\\n\\t}\\n\\tmemset(dp, 0x3f, sizeof(dp));\\n\\tdp[n] = 1, dp[n + 1] = 0;\\n\\tfor (int i = n - 1; i >= 0; i--) {\\n\\t\\tnxt[s[i] - 'a'] = i;\\n\\t\\tfor (int j = 0; j < 26; j++) {\\n\\t\\t\\tif (dp[i] > dp[nxt[j] + 1] + 1) {\\n\\t\\t\\t\\tdp[i] = dp[nxt[j] + 1] + 1;\\n\\t\\t\\t\\tlast[i] = nxt[j] + 1, CCC[i] = j;\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\tint now = 0;\\n\\twhile (now < n) {\\n\\t\\tprintf(\\\"%c\\\", char(CCC[now] + 'a'));\\n\\t\\tnow = last[now];\\n\\t}\\n\\tprintf(\\\"\\\\n\\\");\\n\\treturn 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"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.*;\\n\\npublic class Main {\\n public static void main(String[] args) {\\n Scanner in = new Scanner(System.in);\\n int t = in.nextInt();\\n while(t-->0){\\n int m = in.nextInt();\\n int n = in.nextInt();\\n int d = in.nextInt();\\n char map[][] = new char[m][n];\\n boolean ans[][] = new boolean[m][n];\\n in.nextLine();\\n for (int i = 0; i < m; i++) {\\n String s = in.nextLine();\\n for (int j = 0; j < n; j++) {\\n map[i][j] = s.charAt(j);\\n if(map[i][j] == '.'){\\n ans[i][j] = true;\\n }else{\\n int h = 1;\\n while(i-h>=0&&j+h=0){\\n if(map[i-h][j-h] == '*' && map[i-h][j+h] == '*'){\\n h++;\\n }else{\\n break;\\n }\\n }\\n h = h - 1;\\n if(h>=d){\\n for (int k = 0; k <= h; k++) {\\n ans[i-k][j-k] = true;\\n ans[i-k][j+k] = true;\\n }\\n }\\n }\\n }\\n }\\n boolean answer = true;\\n for (int i = 0; i < m; i++) {\\n for (int j = 0; j < n; j++) {\\n answer = answer & ans[i][j];\\n }\\n }\\n if(answer){\\n System.out.println(\\\"YES\\\");\\n }else{\\n System.out.println(\\\"NO\\\");\\n }\\n }\\n }\\n}\\nclass ans{\\n int a;\\n int b;\\n public ans(int a,int b){\\n this.a=a;\\n this.b=b;\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nIn this problem you have to solve a simple classification task: given an image, determine whether it depicts a Fourier doodle. \\n\\nYou are given a set of 50 images with ids 1 through 50. You are also given a text file labels.txt containing the labels for images with ids 1 through 20, which comprise the learning data set. \\n\\nYou have to output the classification results for images with ids 21 through 50 in the same format.\\n\\nInput\\n\\n[Download the images and the training labels](http:\\/\\/tc-alchemy.progopedia.com\\/fourier-doodles.zip)\\n\\nEach line of the file labels.txt contains a single integer 0 or 1. Line i (1-based) contains the label of the image {i}.png. Label 1 means that the image depicts a Fourier doodle, label 0 - that it does not.\\n\\nOutput\\n\\nOutput 30 lines, one line per image 21 through 50. Line i (1-based) should contain the classification result for the image {i + 20}.png.\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n ios::sync_with_stdio(0);\\n cin.tie(0), cout.tie(0);\\n for (int i = 21; i <= 50; ++i)\\n cout << ((min(i, 25) + i) % (2 + i % 3) > 0) << '\\\\n';\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"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;\\nsigned main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n long long n, m;\\n cin >> n >> m;\\n vector dp(n + 1);\\n dp[1] = 1;\\n for (long long i = 2; i <= n; i++) {\\n if (i == 2)\\n dp[i] = 2;\\n else {\\n dp[i] += 2 * dp[i - 1];\\n dp[i]++;\\n dp[i] %= m;\\n }\\n long long v = dp[i] - dp[i - 1] + m;\\n for (long long j = 2 * i; j <= n; j += i) {\\n dp[j] += v;\\n }\\n }\\n cout << dp[n] << \\\"\\\\n\\\";\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A project is underway to build a new viewing tower in Bange town called “Bange Hills Tower” whose selling point will be the gorgeous view of the entire main keep of Wakamatsu Castle from top to bottom. Therefore, the view line from the top of the tower must reach the bottom of the keep without being hindered by any of the buildings in the town.\\n\\n\\n\\n\\nWrite a program to calculate the minimum tower height required to view the keep in its entirety based on the following information: the planned location of the tower and the heights and locations of existing buildings. Assume all the buildings, including the keep, are vertical lines without horizontal stretch. “view of the entire keep” means that the view line from the tower top can cover the keep from the bottom to the top without intersecting (contacts at the top are exempted) any of the other vertical lines (i.e., buildings).\\n\\n\\n\\nInput\\n\\nThe input is given in the following format.\\n\\n\\nN t\\nx_1 h_1\\nx_2 h_2\\n:\\nx_N h_N\\n\\n\\nThe first line provides the number of existing buildings N (1≤N≤1000) and the planned location of the tower t (2≤t≤105) in integers. Each of the subsequent N lines provides the information of the i-th building: location x_i (1 ≤ x_i < t) and height from the ground h_i (1 ≤ h_i ≤ 100). All position information is one-dimensional along the ground line whose origin coincides with the Keep location. No more than one building is located in the same location (i.e. if i ≠ j, then x_i ≠ x_j).\\n\\nOutput\\n\\nOutput the required height as a real number. No limits on the number of decimal places as long as the error does not exceed ± 10-3.\\n\\nExample\\n\\nInput\\n\\n3 10\\n6 4\\n4 2\\n3 2\\n\\n\\nOutput\\n\\n6.666667\\nUsing python3 can you solve the prior task?\",\"targets\":\"N, t = [int(e) for e in input().split()]\\n\\nts = [[int(e) for e in input().split()] for _ in range(N)]\\n\\nresult = 0\\nfor x, h in ts:\\n r = h * t \\/ x\\n result = max(result, r)\\n\\nprint(result)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"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...\\nfrom\",\"targets\":\"sys import stdin\\nfrom bisect import bisect, insort\\n\\nfor testcase in range(int(stdin.readline())):\\n n, m = map(int, stdin.readline().split())\\n sights = list(map(int, stdin.readline().split()))\\n\\n sightIndices = {}\\n for index in range(n*m):\\n if sights[index] in sightIndices: sightIndices[sights[index]].append(index)\\n else: sightIndices[sights[index]] = [index]\\n \\n sightsOrder = sorted(sightIndices)\\n seatingOrderByIndices = []\\n \\n for sight in sightsOrder:\\n seatingOrderByIndices.extend(sightIndices[sight][::-1])\\n \\n occupiedSeats = []\\n inconvenience = 0\\n for seating in seatingOrderByIndices:\\n inconvenience += bisect(occupiedSeats, seating)\\n insort(occupiedSeats, seating)\\n \\n print(inconvenience)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"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...\",\"targets\":\"import java.util.*;\\nimport java.lang.*;\\nimport java.io.*;\\n\\/\\/ There is a bug..............\\n\\/* Name of the class has to be \\\"Main\\\" only if the class is public. *\\/\\npublic class twoTables\\n{\\n private static class FastReader\\n {\\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 } catch (IOException e) {\\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 str = br.readLine();\\n } catch (IOException e) {\\n e.printStackTrace();\\n }\\n return str;\\n }\\n }\\n\\/\\/ static FastReader sc = new FastReader();\\n static Scanner sc = new Scanner(System.in);\\n\\n public static void main(String[] args) throws Exception\\n {\\n int testCases = sc.nextInt();\\n\\n while (testCases-- > 0)\\n {\\n System.out.println( m1() );\\n\\/\\/ System.out.println( m2() );\\n }\\n\\n }\\n\\n private static double m2()\\n {\\n double W = sc.nextDouble();\\n double H = sc.nextDouble();\\n\\n double x1 = sc.nextDouble();\\n double y1 = sc.nextDouble();\\n double x2 = sc.nextDouble();\\n double y2 = sc.nextDouble();\\n\\n double w = sc.nextDouble();\\n double h = sc.nextDouble();\\n\\n if( w +x2-x1>W && h +y2-y1>H ) return -1;\\n\\n if( h<=y1 || h<=H-y2 || w<=x1...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"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...\\n# Leg\",\"targets\":\"ends Always Come Up with Solution\\n# Author: Manvir Singh\\n\\nimport os\\nimport sys\\nfrom io import BytesIO, IOBase\\n\\ndef solve():\\n n = int(input())\\n a = [list(map(int,input().split())) for _ in range(n)]\\n for i in range(5):\\n for j in range(i + 1, 5):\\n x,y,f=0,0,1\\n for k in range(n):\\n if not (a[k][i]|a[k][j]):\\n f=0\\n break\\n x+=a[k][i]\\n y+=a[k][j]\\n if f and x>=(n\\/\\/2) and y>=(n\\/\\/2):\\n return \\\"YES\\\"\\n return \\\"NO\\\"\\n\\ndef main():\\n for _ in range(int(input())):\\n print(solve())\\n\\n# FASTIO REGION\\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 ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"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...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst double PI = acos(-1);\\nconst long long mod = 9901;\\nconst long long N = 1e5 + 100, M = 110;\\nlong long a[N];\\nsigned main() {\\n std::ios::sync_with_stdio(false);\\n long long t;\\n cin >> t;\\n while (t--) {\\n long long a, b;\\n cin >> a >> b;\\n if ((a + b) % 2 == 0) {\\n long long p = (max(a, b) - min(a, b)) \\/ 2;\\n long long cnt = min(a, b) + 1;\\n cout << cnt << endl;\\n while (cnt--) {\\n cout << p;\\n p += 2;\\n if (cnt != 0) cout << ' ';\\n }\\n cout << endl;\\n } else {\\n long long k = max(a, b) - min(a, b);\\n k = k \\/ 2;\\n cout << a + b - k * 2 + 1 << endl;\\n for (long long i = k; i <= a + b - k; i++) {\\n if (i != k) cout << ' ';\\n cout << i;\\n }\\n cout << endl;\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"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\":\"from sys import stdin\\nfrom bisect import bisect_left\\n\\n\\ncount_h = stdin.readline()\\nheroes = list(map(int, stdin.readline().split(' '))) + [1000000000001]\\nheroes.sort()\\nheroes_sum = sum(heroes[:-1])\\nfor i in range(int(stdin.readline())):\\n p, a = map(int, stdin.readline().split(' '))\\n bis = bisect_left(heroes, p)\\n hero_under, hero_above = heroes[bis], heroes[bis - 1 * (bis != 0)]\\n protect_1, attack_1 = p - hero_under, a - (heroes_sum - hero_under)\\n protect_2, attack_2 = p - hero_above, a - (heroes_sum - hero_above)\\n print(min(protect_1 * (protect_1 > 0) + attack_1 * (attack_1 > 0), protect_2 * (protect_2 > 0) + attack_2 * (attack_2 > 0)))\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Dante is engaged in a fight with \\\"The Savior\\\". Before he can fight it with his sword, he needs to break its shields. He has two guns, Ebony and Ivory, each of them is able to perform any non-negative number of shots.\\n\\nFor every bullet that hits the shield, Ebony deals a units of damage while Ivory deals b units of damage. In order to break the shield Dante has to deal exactly c units of damage. Find out if this is possible.\\n\\nInput\\n\\nThe first line of the input contains three integers a, b, c (1 ≤ a, b ≤ 100, 1 ≤ c ≤ 10 000) — the number of units of damage dealt by Ebony gun and Ivory gun, and the total number of damage required to break the shield, respectively.\\n\\nOutput\\n\\nPrint \\\"Yes\\\" (without quotes) if Dante can deal exactly c damage to the shield and \\\"No\\\" (without quotes) otherwise.\\n\\nExamples\\n\\nInput\\n\\n4 6 15\\n\\n\\nOutput\\n\\nNo\\n\\n\\nInput\\n\\n3 2 7\\n\\n\\nOutput\\n\\nYes\\n\\n\\nInput\\n\\n6 11 6\\n\\n\\nOutput\\n\\nYes\\n\\nNote\\n\\nIn the second sample, Dante can fire 1 bullet from Ebony and 2 from Ivory to deal exactly 1·3 + 2·2 = 7 damage. In the third sample, Dante can fire 1 bullet from ebony and no bullets from ivory to do 1·6 + 0·11 = 6 damage.\",\"targets\":\"#include \\nusing namespace std;\\nint egcd(int a, int b, int& x, int& y) {\\n if (b == 0) {\\n x = 1;\\n y = 0;\\n return a;\\n }\\n int x1, y1;\\n int g = egcd(b, a % b, x1, y1);\\n x = y1;\\n y = x1 - (a \\/ b) * y1;\\n return g;\\n}\\nbool find_sol(int a, int b, int c, int& g, int& x, int& y) {\\n g = egcd(a, b, x, y);\\n if (c % g) return false;\\n x *= c \\/ g;\\n y *= c \\/ g;\\n return true;\\n}\\nvoid shift_sol(int a, int b, int& x, int& y, int k) {\\n x += k * b;\\n y -= k * a;\\n}\\nint main() {\\n int a, b, c, x, y, g;\\n cin >> a >> b >> c;\\n if (!find_sol(a, b, c, g, x, y)) {\\n cout << \\\"No\\\" << endl;\\n return 0;\\n }\\n a \\/= g;\\n b \\/= g;\\n if (x >= 0 && y >= 0) {\\n cout << \\\"Yes\\\" << endl;\\n return 0;\\n }\\n if (x < 0 && y < 0) {\\n cout << \\\"No\\\" << endl;\\n return 0;\\n }\\n if (y < x) {\\n swap(y, x);\\n swap(a, b);\\n }\\n shift_sol(a, b, x, y, (-x) \\/ b);\\n if (x < 0) shift_sol(a, b, x, y, 1);\\n if (y >= 0) {\\n cout << \\\"Yes\\\" << endl;\\n return 0;\\n } else {\\n cout << \\\"NO\\\" << endl;\\n return 0;\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Bizon the Champion isn't just charming, he also is very smart.\\n\\nWhile some of us were learning the multiplication table, Bizon the Champion had fun in his own manner. Bizon the Champion painted an n × m multiplication table, where the element on the intersection of the i-th row and j-th column equals i·j (the rows and columns of the table are numbered starting from 1). Then he was asked: what number in the table is the k-th largest number? Bizon the Champion always answered correctly and immediately. Can you repeat his success?\\n\\nConsider the given multiplication table. If you write out all n·m numbers from the table in the non-decreasing order, then the k-th number you write out is called the k-th largest number.\\n\\nInput\\n\\nThe single line contains integers n, m and k (1 ≤ n, m ≤ 5·105; 1 ≤ k ≤ n·m).\\n\\nOutput\\n\\nPrint the k-th largest number in a n × m multiplication table.\\n\\nExamples\\n\\nInput\\n\\n2 2 2\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n2 3 4\\n\\n\\nOutput\\n\\n3\\n\\n\\nInput\\n\\n1 10 5\\n\\n\\nOutput\\n\\n5\\n\\nNote\\n\\nA 2 × 3 multiplication table looks like this:\\n \\n \\n \\n 1 2 3 \\n 2 4 6 \\n \\n \\\":\",\"targets\":\"#include \\nusing namespace std;\\ntemplate \\ninline bool isLeap(T y) {\\n return (y % 400 == 0) || (y % 100 ? y % 4 == 0 : false);\\n}\\ntemplate \\ninline T gcd(T a, T b) {\\n return (b) == 0 ? (a) : gcd((b), ((a) % (b)));\\n}\\ntemplate \\ninline T lcm(T a, T b) {\\n return ((a) \\/ gcd((a), (b)) * (b));\\n}\\ntemplate \\ninline T BigMod(T Base, T power, T M = 1000000007) {\\n if (power == 0) return 1;\\n if (power & 1)\\n return ((Base % M) * (BigMod(Base, power - 1, M) % M)) % M;\\n else {\\n T y = BigMod(Base, power \\/ 2, M) % M;\\n return (y * y) % M;\\n }\\n}\\ntemplate \\ninline T ModInv(T A, T M = 1000000007) {\\n return BigMod(A, M - 2, M);\\n}\\nint fx[] = {-1, +0, +1, +0, +1, +1, -1, -1, +0};\\nint fy[] = {+0, -1, +0, +1, +1, -1, +1, -1, +0};\\nint day[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n long long n, m, k;\\n cin >> n >> m >> k;\\n long long low = 1, high = 1e12, mid, save;\\n while (low <= high) {\\n mid = (low + high) >> 1;\\n long long cnt = 0;\\n for (int i = 1; i <= n; i++) {\\n long long x = mid \\/ i;\\n if (mid % i == 0) x--;\\n if (x > m) x = m;\\n cnt += x;\\n }\\n if (cnt >= k) {\\n save = mid;\\n high = mid - 1;\\n } else\\n low = mid + 1;\\n }\\n long long mx = 0;\\n for (int i = 1; i <= n; i++) {\\n long long x = save;\\n long long pnt = x \\/ i;\\n if (x % i == 0) pnt--;\\n if (pnt > m) pnt = m;\\n mx = max(mx, pnt * i);\\n }\\n cout << mx;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"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 JAVA.\",\"targets\":\"import java.util.*;\\nimport java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.util.StringTokenizer;\\npublic class Main {\\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 public static void main(String[] args) {\\n try {\\n FastReader abc = new FastReader();\\n long t=abc.nextLong();\\n while(t!=0)\\n {\\n long n=abc.nextLong();\\n long m= abc.nextLong();\\n long rb= abc.nextLong();\\n long cb= abc.nextLong();\\n long rd= abc.nextLong();\\n long cd= abc.nextLong();\\n long res=0;\\n int dr=1;\\n int dc=1;\\n while(rb!=rd && cb!=cd)\\n {\\n if(rb+dr>n || rb+dr<1)\\n dr=dr*-1;\\n if(cb+dc>m || cb+dc<1)\\n dc=dc*-1;\\n rb+=dr;\\n cb+=dc;\\n res++;\\n }\\n ...\",\"language\":\"python\",\"split\":\"test\",\"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...\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\nimport java.lang.*;\\n\\npublic class Problem {\\n static int Mod = 1000000007;\\n\\n public static void main(String[] args) {\\n MyScanner scan = new MyScanner();\\n PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));\\n int t = scan.nextInt();\\n \\/\\/ int t=1;\\n while (t-- > 0) {\\n int n = scan.nextInt();\\n int a[][] = new int[n][2];\\n for (int i = 0; i < n; i++) {\\n a[i][0] = scan.nextInt();\\n }\\n String s = scan.nextLine();\\n for (int i = 0; i < n; i++) {\\n a[i][1] = s.charAt(i) - '0';\\n }\\n\\n Arrays.sort(a, (b, c) -> {\\n if (b[1] < c[1])\\n return -1;\\n else if (b[1] > c[1])\\n return 1;\\n else\\n return b[0] - c[0];\\n });\\n\\n boolean ans = true;\\n\\n for (int i = 0; i < n; i++) {\\n if (a[i][1] == 18) {\\n if (a[i][0] < i + 1) {\\n ans = false;\\n break;\\n }\\n } else {\\n if (a[i][0] > i + 1) {\\n ans = false;\\n break;\\n }\\n }\\n }\\n\\n if (ans)\\n out.println(\\\"YES\\\");\\n else\\n out.println(\\\"NO\\\");\\n\\n }\\n out.close();\\n }\\n\\n static class Pair {\\n int l;\\n int r;\\n\\n Pair(int l, int r) {\\n this.l = l;\\n this.r = r;\\n }\\n\\n @Override\\n public int hashCode() {\\n final int prime = 31;\\n int result = 1;\\n result = prime * result + l;\\n result = prime * result + r;\\n return result;\\n }\\n\\n @Override\\n public boolean equals(Object obj) {\\n if (this == obj)\\n return true;\\n if (obj == null)\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"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\":\"#include \\nusing namespace std;\\nsigned main() {\\n long long t;\\n cin >> t;\\n while (t--) {\\n long long n;\\n cin >> n;\\n string s1;\\n cin >> s1;\\n string s2;\\n cin >> s2;\\n long long cnt = 0;\\n for (long long i = 0; i < n; i++)\\n if (s2[i] == '1') {\\n if (i != 0 && s1[i - 1] == '1') {\\n s1[i - 1] = '2';\\n cnt++;\\n } else if (s1[i] == '0') {\\n s1[i] = '2';\\n cnt++;\\n } else if (i != n - 1 && s1[i + 1] == '1') {\\n s1[i + 1] = '2';\\n cnt++;\\n }\\n }\\n cout << cnt << endl;\\n }\\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] \\nUsing cpp can you solve the prior task?\",\"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 arr[n];\\n long long int b[n];\\n long long int o = 0, e = 0;\\n for (long long int i = 0; i < n; i++) {\\n cin >> arr[i];\\n if (arr[i] % 2 == 0) {\\n b[i] = 0;\\n e++;\\n }\\n if (arr[i] % 2 != 0) {\\n b[i] = 1;\\n o++;\\n }\\n }\\n vector v1, v2, v3, v4;\\n if (n % 2 != 0) {\\n if (abs(o - e) > 1) {\\n cout << -1 << endl;\\n } else {\\n long long int ans = 0;\\n if (o > e) {\\n for (long long int i = 0; i < n; i++) {\\n if (i % 2 == 0 && b[i] != 1) {\\n v1.push_back(i);\\n }\\n if (i % 2 != 0 && b[i] != 0) {\\n v2.push_back(i);\\n }\\n }\\n for (long long int i = 0; i < v1.size(); i++) {\\n ans += abs(v1[i] - v2[i]);\\n }\\n cout << ans << endl;\\n }\\n if (o < e) {\\n for (long long int i = 0; i < n; i++) {\\n if (i % 2 == 0 && b[i] != 0) {\\n v1.push_back(i);\\n }\\n if (i % 2 != 0 && b[i] != 1) {\\n v2.push_back(i);\\n }\\n }\\n for (long long int i = 0; i < v1.size(); i++) {\\n ans += abs(v1[i] - v2[i]);\\n }\\n cout << ans << endl;\\n }\\n }\\n }\\n if (n % 2 == 0) {\\n if (o - e != 0) {\\n cout << -1 << endl;\\n } else {\\n long long int ans1 = 0, ans2 = 0;\\n for (long long int i = 0; i < n; i++) {\\n if (i % 2 == 0 && b[i] != 0) {\\n v1.push_back(i);\\n }\\n if (i % 2 != 0 && b[i] != 1) {\\n v2.push_back(i);\\n }\\n }\\n for (long long int i = 0; i < v1.size(); i++) {\\n ans1 += abs(v1[i] - v2[i]);\\n }\\n for (long long int i = 0; i < n; i++) {\\n if (i % 2 == 0 && b[i] != 1) {\\n v3.push_back(i);\\n }\\n if (i % 2 != 0 &&...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in PYTHON3?\\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\":\"for _ in range(int(input())):\\n\\tn=int(input())\\n\\tif n%10==9:\\n\\t\\tprint((n\\/\\/10)+1)\\n\\telse:\\n\\t\\tprint(n\\/\\/10)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"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\\nUsing java can you solve the prior task?\",\"targets\":\"import java.util.Scanner;\\n\\npublic class Main {\\n\\n\\tpublic static void main(String[] args) {\\n\\t\\tScanner sc = new Scanner(System.in);\\n\\t\\tint A = sc.nextInt(), B = sc.nextInt(), T = sc.nextInt();\\n\\t\\tSystem.out.println(B*((T)\\/A));\\n\\t}\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nn 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 static java.lang.Math.*;\\nimport static java.lang.System.out;\\nimport java.util.*;\\nimport java.io.File;\\nimport java.io.PrintStream;\\nimport java.io.PrintWriter;\\nimport java.math.BigInteger;\\npublic class Main {\\n \\n\\t\\n\\t\\/* 10^(7) = 1s.\\n\\t * ceilVal = (a+b-1) \\/ b *\\/\\n\\t\\n\\tstatic final int mod = 1000000007;\\n\\tstatic final long temp = 998244353;\\n\\tstatic final long MOD = 1000000007;\\n\\tstatic final long M = (long)1e9+7;\\n \\n\\tstatic class Pair implements Comparable \\n\\t{\\n\\t\\tint first, second;\\n\\t\\t\\n\\t\\tpublic Pair(int first, int second) \\n\\t\\t{\\n\\t\\t\\tthis.first = first;\\n\\t\\t\\tthis.second = second;\\n\\t\\t}\\n\\t\\t\\n\\t\\tpublic int compareTo(Pair ob) \\n\\t\\t{\\n\\t\\t\\treturn (int)(first - ob.first);\\n\\t\\t}\\n\\t}\\n\\t\\n\\t\\n\\tstatic class Tuple implements Comparable\\n\\t{\\n\\t\\tint first, second,third;\\n\\t\\tpublic Tuple(int first, int second, int third)\\n\\t\\t{\\n\\t\\t\\tthis.first = first;\\n\\t\\t\\tthis.second = second;\\n\\t\\t\\tthis.third = third;\\n\\t\\t}\\n\\t\\tpublic int compareTo(Tuple o)\\n\\t\\t{\\n\\t\\t\\treturn (int)(o.third - this.third);\\n\\t\\t}\\n\\t}\\n\\t\\n\\tpublic static class DSU\\n\\t{\\n\\t\\tint[] parent;\\n\\t\\tint[] rank; \\/\\/Size of the trees is used as the rank\\n\\t\\tpublic DSU(int n)\\n\\t\\t{\\n\\t\\t\\tparent = new int[n];\\n\\t\\t\\trank = new int[n];\\n\\t\\t\\tArrays.fill(parent, -1);\\n\\t\\t\\tArrays.fill(rank, 1);\\n\\t\\t}\\n\\t\\t\\n\\t\\tpublic int find(int i) \\/\\/finding through path compression\\n\\t\\t{\\n\\t\\t\\treturn parent[i] < 0 ? i : (parent[i] = find(parent[i]));\\n\\t\\t}\\n\\t\\t\\n\\t\\tpublic boolean union(int a, int b) \\/\\/Union Find by Rank \\n\\t\\t{\\n\\t\\t\\ta = find(a);\\n\\t\\t\\tb = find(b);\\n\\t\\t\\t\\n\\t\\t\\tif(a == b) return false; \\/\\/if they are already connected we exit by returning false.\\n\\t\\t\\t\\n\\t\\t\\t\\/\\/ if a's parent is less than b's parent\\n\\t\\t\\tif(rank[a] < rank[b])\\n\\t\\t\\t{\\n\\t\\t\\t\\t\\/\\/then move a under b\\n\\t\\t\\t\\tparent[a] = b;\\n\\t\\t\\t}\\n\\t\\t\\t\\/\\/else if rank of j's parent is less than i's parent\\n\\t\\t\\telse if(rank[a] > rank[b])\\n\\t\\t\\t{\\n\\t\\t\\t\\t\\/\\/then move b under a\\n\\t\\t\\t\\tparent[b] = a;\\n\\t\\t\\t}\\n\\t\\t\\t\\/\\/if both have the same rank.\\n\\t\\t\\telse\\n\\t\\t\\t{\\n\\t\\t\\t\\t\\/\\/move a under b (it doesnt matter if its the other way around.\\n\\t\\t\\t\\tparent[b] = a;\\n\\t\\t\\t\\trank[a] = 1 + rank[a];\\n\\t\\t\\t}\\n\\t\\t\\treturn...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nConsider 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...\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\npublic class Main {\\n\\tpublic static void main(String[] args) throws IOException \\n\\t{ \\n\\t\\tFastScanner f = new FastScanner(); \\n\\t\\tint ttt=1;\\n\\t\\tttt=f.nextInt();\\n\\t\\tPrintWriter out=new PrintWriter(System.out);\\n\\t\\touter:for(int tt=0;tt= k){\\n\\t\\t\\t\\t\\tSystem.out.println(i);\\n\\t\\t\\t\\t\\tcontinue outer;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\t\\n\\t\\t\\tSystem.out.println(-1);\\n\\t\\t}\\n\\t\\tout.close();\\n\\t} \\n\\tstatic void sort(int[] p) {\\n ArrayList q = new ArrayList<>();\\n for (int i: p) q.add( i);\\n Collections.sort(q);\\n for (int i = 0; i < p.length; i++) p[i] = q.get(i);\\n }\\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\\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 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...\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\npublic class Sol{\\n\\n\\/* \\n->n=1 important test case\\n->Dont get stuck on one approach try all possibilities\\n->check int overflow,array bounds,etc\\n->Dont think just idea think of its (correct) implementation completely (then only code)\\n*\\/\\n\\npublic static void main(String []args){\\n\\/\\/precomp();\\nint times=ni();while(times-->0){solve();}out.close();}\\n\\nstatic void solve(){ int w=ni();int h=ni();\\n int x1=ni();int y1=ni();int x2=ni();int y2=ni();\\n int h1=y2-y1;int w1=x2-x1;\\n int w2=ni();int h2=ni();\\n \\/\\/edge case 2 table can also be moved\\n int ans=Max;\\n if(h1+h2<=h){\\n int c1=Math.max(h2-(h-y2),0);\\n int c2=Math.max(h2-y1,0);\\n ans=Math.min(ans,Math.min(c1,c2)); \\n }\\n if(w1+w2<=w){\\n int c1=Math.max(w2-(w-x2),0);\\n int c2=Math.max(w2-x1,0);\\n ans=Math.min(ans,Math.min(c1,c2));\\n }\\n \\n if(ans==Max){ans=-1;}\\n out.println(ans);\\n \\n \\n return;\\n }\\n\\nstatic int max3(int a,int b,int c){return Math.max(a,Math.max(b,c));}\\n\\/\\/-----------------Utility--------------------------------------------\\n\\nstatic int gcd(int a,int b){if(b==0)return a; return gcd(b,a%b);}\\n \\nstatic int Max=Integer.MAX_VALUE; static long mod=1000000007;\\n \\nstatic int v(char c){return (int)(c-'a');}\\n\\npublic static long power(long x, long y )\\n {\\n \\/\\/0^0 = 1\\n long res = 1L;\\n x = x%mod;\\n while(y > 0)\\n {\\n if((y&1)==1)\\n res = (res*x)%mod;\\n y >>= 1;\\n x = (x*x)%mod;\\n }\\n return res;\\n }\\n \\nstatic class Pair implements Comparable{\\n int id;int value;Pair next;\\n public Pair(int id,int value) {\\n \\n this.id=id;this.value=value;next=null;\\n }\\n @Override\\n public int compareTo(Pair p){return Long.compare(value,p.value);}\\n }\\n\\n\\/\\/----------------------I\\/O---------------------------------------------\\n \\nstatic InputStream inputStream = System.in;\\nstatic OutputStream outputStream...\",\"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.\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nconst long long int mod = 1000000007ll;\\nconst long long int num = (1 << 24);\\nvector prim;\\nlong long int pow(long long int n, long long int x = 2ll) {\\n if (n == 0ll)\\n return 1ll;\\n else if (n == 1ll)\\n return (x % mod);\\n else {\\n if (n % 2 == 1ll)\\n return ((x % mod) * (pow(n \\/ 2, ((x * x) % mod)) % mod)) % mod;\\n else\\n return (pow(n \\/ 2, ((x * x) % mod)) % mod);\\n }\\n}\\nvoid SieveOfEratosthenes() {\\n bool prime[num + 1];\\n memset(prime, true, sizeof(prime));\\n for (int p = 2; p * p <= num; p++) {\\n if (prime[p] == true) {\\n for (int i = p * p; i <= num; i += p) prime[i] = false;\\n }\\n }\\n for (int p = 2; p <= num; p++)\\n if (prime[p]) prim.push_back(p);\\n}\\nint gcdExtended(int a, int b, int *x, int *y) {\\n if (a == 0) {\\n *x = 0;\\n *y = 1;\\n return b;\\n }\\n int x1, y1;\\n int gcd = gcdExtended(b % a, a, &x1, &y1);\\n *x = y1 - (b \\/ a) * x1;\\n *y = x1;\\n return gcd;\\n}\\nint gcd(int a, int b) {\\n int x, y;\\n return gcdExtended(a, b, &x, &y);\\n}\\nvector getFact(int x) {\\n vector result;\\n int i = 1;\\n while (i * i <= x) {\\n if (x % i == 0) {\\n result.push_back(i);\\n if (x \\/ i != i) {\\n result.push_back(x \\/ i);\\n }\\n }\\n i++;\\n }\\n return result;\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n int T, n;\\n cin >> T;\\n string s, t, ans;\\n while (T--) {\\n cin >> s;\\n cin >> t;\\n int a[26];\\n memset(a, 0, sizeof(a));\\n for (int i = 0; i < s.size(); i++) {\\n a[s[i] - 'a']++;\\n }\\n ans = \\\"\\\";\\n if (((t[0] == 'a') && (t[1] == 'b') && (t[2] == 'c')) && (a[0] != 0)) {\\n for (int i = 0; i < a[0]; i++) {\\n ans = ans + 'a';\\n }\\n for (int i = 0; i < a[2]; i++) {\\n ans = ans + 'c';\\n }\\n for (int i = 0; i < a[1]; i++) {\\n ans = ans + 'b';\\n }\\n for (int i = 3; i < 26; i++) {\\n for (int j = 0; j < a[i]; j++) {\\n ans = ans + (char)('a' + i);\\n }\\n }\\n } else {\\n for (int i = 0; i < 26; i++) {\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"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\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"n = int(input())\\nl1 = [0, 0] + list(map(int, input().split()))\\nl2 = [0, 0] + list(map(int, input().split()))\\nans1 = [0] * (n + 3)\\nans2 = [0] * (n + 3)\\nfor i in range(2, n + 2):\\n ans1[i] = max(ans2[i - 1], ans2[i - 2]) + l1[i]\\n ans2[i] = max(ans1[i - 1], ans1[i - 2]) + l2[i]\\nprint(max(ans1[n + 1], ans2[n + 1]))\",\"language\":\"python\",\"split\":\"train\",\"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.\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n long long int t;\\n cin >> t;\\n while (t--) {\\n long long int n, l, r;\\n cin >> n;\\n if (n == 1) {\\n cout << 0 << \\\" \\\" << 1 << endl;\\n } else if (n == 2) {\\n cout << -1 << \\\" \\\" << 2 << endl;\\n } else {\\n cout << (-1) * (n - 1) << \\\" \\\" << n << endl;\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Everyone knows that agents in Valorant decide, who will play as attackers, and who will play as defenders. To do that Raze and Breach decided to play t matches of a digit game...\\n\\nIn each of t matches of the digit game, a positive integer is generated. It consists of n digits. The digits of this integer are numerated from 1 to n from the highest-order digit to the lowest-order digit. After this integer is announced, the match starts.\\n\\nAgents play in turns. Raze starts. In one turn an agent can choose any unmarked digit and mark it. Raze can choose digits on odd positions, but can not choose digits on even positions. Breach can choose digits on even positions, but can not choose digits on odd positions. The match ends, when there is only one unmarked digit left. If the single last digit is odd, then Raze wins, else Breach wins.\\n\\nIt can be proved, that before the end of the match (for every initial integer with n digits) each agent has an ability to make a turn, i.e. there is at least one unmarked digit, that stands on a position of required parity.\\n\\nFor each of t matches find out, which agent wins, if both of them want to win and play optimally.\\n\\nInput\\n\\nFirst line of input contains an integer t (1 ≤ t ≤ 100) — the number of matches.\\n\\nThe first line of each match description contains an integer n (1 ≤ n ≤ 10^3) — the number of digits of the generated number.\\n\\nThe second line of each match description contains an n-digit positive integer without leading zeros.\\n\\nOutput\\n\\nFor each match print 1, if Raze wins, and 2, if Breach wins.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n1\\n2\\n1\\n3\\n3\\n102\\n4\\n2069\\n\\n\\nOutput\\n\\n\\n2\\n1\\n1\\n2\\n\\nNote\\n\\nIn the first match no one can make a turn, the only digit left is 2, it's even, so Breach wins.\\n\\nIn the second match the only digit left is 3, it's odd, so Raze wins.\\n\\nIn the third match Raze can mark the last digit, after that Breach can only mark 0. 1 will be the last digit left, it's odd, so Raze wins.\\n\\nIn the fourth match no matter how Raze plays, Breach can mark 9, and in the end there will be digit 0. It's even, so...\",\"targets\":\"def solve(n):\\n s=input() \\n if n%2==1:\\n for i in range(0,n,2):\\n if s[i] in '13579' :\\n return 1\\n return 2\\n else:\\n for i in range(1,n,2):\\n if s[i] in '02468' :\\n return 2\\n return 1\\n\\nt=int(input())\\n\\nfor _ in range(t):\\n n=int(input())\\n print(solve(n))\",\"language\":\"python\",\"split\":\"train\",\"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.\\nfor _\",\"targets\":\"in range(int(input())):\\n #n=int(input())\\n n,k=map(int,input().split())\\n a=list(map(int,input().split()))\\n #input()\\n ans=0\\n if k==n:\\n print('YES')\\n continue\\n mapp=dict()\\n for i in range(n):\\n mapp[a[i]]=i\\n a.sort()\\n for i in range(n):\\n a[i]=mapp[a[i]]\\n for i in range(1,n):\\n if a[i]!=(a[i-1]+1):\\n ans+=1\\n if k>ans:\\n print('YES')\\n else:\\n print('NO')\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"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;\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n int tt = 1;\\n cin >> tt;\\n while (tt--) {\\n string s;\\n cin >> s;\\n string t = s;\\n reverse(t.begin(), t.end());\\n string o = \\\"\\\";\\n int a[26] = {0};\\n int sum = 0;\\n for (auto c : t) {\\n if (a[c - 'a'] == 0) {\\n sum++;\\n o += c;\\n a[c - 'a'] = 1;\\n }\\n }\\n if (sum == 1) {\\n cout << s << \\\" \\\" << s[0] << \\\"\\\\n\\\";\\n continue;\\n }\\n reverse(o.begin(), o.end());\\n char f = o[0];\\n char s1;\\n for (auto c : s) {\\n if (c != f) {\\n s1 = c;\\n break;\\n }\\n }\\n string s2 = \\\"\\\";\\n int e1 = -1;\\n for (int i = 0; i < s.size(); i++) {\\n if (s[i] == s1 && s2.size() != 0 && sum == 0) {\\n if (s.substr(i, s2.size()) == s2) {\\n e1 = i;\\n }\\n }\\n if (a[s[i] - 'a'] == 1) {\\n a[s[i] - 'a'] = 0;\\n sum--;\\n }\\n if (s[i] != f) {\\n s2 += s[i];\\n }\\n }\\n if (e1 == -1) {\\n cout << -1 << \\\"\\\\n\\\";\\n continue;\\n }\\n string ans = s.substr(0, e1);\\n string tf = ans;\\n string curr = ans;\\n for (auto c : o) {\\n string temp = \\\"\\\";\\n for (auto e : curr) {\\n if (e != c) {\\n temp += e;\\n }\\n }\\n if (temp.size() > 0) tf += temp;\\n curr = temp;\\n }\\n if (s != tf) {\\n cout << -1 << \\\"\\\\n\\\";\\n } else {\\n cout << ans << \\\" \\\" << o << \\\"\\\\n\\\";\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"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...\\nimpor\",\"targets\":\"t sys\\nfrom math import factorial, gcd\\n#from math import comb, perm \\t\\nfrom collections import Counter, deque, defaultdict\\nfrom bisect import bisect_left, bisect_right \\nfrom heapq import heappop, heappush, heapify, nlargest, nsmallest\\nfrom itertools import groupby\\nfrom copy import deepcopy\\nMOD = 10**9+7\\nINF = float('inf')\\n\\nrl = lambda : list(map(int, sys.stdin.readline().split()))\\nrs = lambda : sys.stdin.readline().strip()\\n\\nfor _ in range(int(input())):\\n\\tn = int(input())\\n\\treq = Counter()\\n\\tB = defaultdict(list)\\n\\tfor i in range(1, n+1):\\n\\t\\tk, *A = rl()\\n\\t\\treq[i] = k\\n\\t\\tfor x in A:\\n\\t\\t\\tB[x].append(i)\\n\\n\\tq = []\\n\\tcount = 0\\n\\tfor i in range(1, n+1):\\n\\t\\tif req[i] == 0:\\n\\t\\t\\tcount += 1\\n\\t\\t\\tq.append(i)\\n\\n\\tans = 0\\n\\twhile q:\\n\\t\\tans += 1\\n\\t\\tnq = []\\n\\t\\twhile q:\\n\\t\\t\\tx = heappop(q)\\n\\n\\t\\t\\tfor v in B[x]:\\n\\t\\t\\t\\treq[v] -= 1\\n\\n\\t\\t\\t\\tif req[v] == 0:\\n\\t\\t\\t\\t\\tcount += 1\\n\\t\\t\\t\\t\\tif v > x:\\n\\t\\t\\t\\t\\t\\theappush(q, v)\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\theappush(nq, v)\\n\\n\\t\\tq = nq\\n\\n\\tprint(ans if count == n else -1)\",\"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\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"word = input()\\nprint(word[0].upper(),word[1:],sep='')\",\"language\":\"python\",\"split\":\"train\",\"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 \\nUsing python3 can you solve the prior task?\",\"targets\":\"t=int(input())\\nwhile(t>0):\\n n=int(input())\\n if(n\\/\\/10==0):\\n print(1)\\n print(n)\\n else:\\n l=[]\\n p=1\\n while(n>0):\\n if n%10>0:\\n l.append(((n%10)*p))\\n n=n\\/\\/10\\n p*=10\\n\\n print(len(l))\\n for i in l:\\n print(i,end=\\\" \\\")\\n \\n t-=1\",\"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. \\ndef m\",\"targets\":\"ain():\\n test = int(input())\\n\\n for idt in range(test):\\n n = int(input())\\n a = list(map(int, input().split()))\\n cnt = [0] * (n + 1)\\n for i in a:\\n cnt[i] += 1 \\n \\n tot = 0 \\n stk = [] \\n ans = [-1] * (n + 1)\\n for i in range(n + 1):\\n if tot == -1:\\n break \\n \\n ans[i] = tot + cnt[i]\\n\\n for _ in range(cnt[i]):\\n stk.append(i)\\n if len(stk) == 0:\\n tot = -1 \\n else:\\n tot += i - stk.pop()\\n\\n print(*ans, sep=\\\" \\\") \\n return\\n\\nmain()\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Codeforces user' handle color depends on his rating — it is red if his rating is greater or equal to 2400; it is orange if his rating is less than 2400 but greater or equal to 2200, etc. Each time participant takes part in a rated contest, his rating is changed depending on his performance.\\n\\nAnton wants the color of his handle to become red. He considers his performance in the rated contest to be good if he outscored some participant, whose handle was colored red before the contest and his rating has increased after it.\\n\\nAnton has written a program that analyses contest results and determines whether he performed good or not. Are you able to do the same?\\n\\nInput\\n\\nThe first line of the input contains a single integer n (1 ≤ n ≤ 100) — the number of participants Anton has outscored in this contest .\\n\\nThe next n lines describe participants results: the i-th of them consists of a participant handle namei and two integers beforei and afteri ( - 4000 ≤ beforei, afteri ≤ 4000) — participant's rating before and after the contest, respectively. Each handle is a non-empty string, consisting of no more than 10 characters, which might be lowercase and uppercase English letters, digits, characters «_» and «-» characters.\\n\\nIt is guaranteed that all handles are distinct.\\n\\nOutput\\n\\nPrint «YES» (quotes for clarity), if Anton has performed good in the contest and «NO» (quotes for clarity) otherwise.\\n\\nExamples\\n\\nInput\\n\\n3\\nBurunduk1 2526 2537\\nBudAlNik 2084 2214\\nsubscriber 2833 2749\\n\\n\\nOutput\\n\\nYES\\n\\nInput\\n\\n3\\nApplejack 2400 2400\\nFluttershy 2390 2431\\nPinkie_Pie -2500 -2450\\n\\n\\nOutput\\n\\nNO\\n\\nNote\\n\\nIn the first sample, Anton has outscored user with handle Burunduk1, whose handle was colored red before the contest and his rating has increased after the contest.\\n\\nIn the second sample, Applejack's rating has not increased after the contest, while both Fluttershy's and Pinkie_Pie's handles were not colored red before the contest.\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"n=int(input())\\nfor _ in range(n):\\n _,x,y=input().split()\\n x=int(x)\\n y=int(y)\\n if x=2400: print('YES'); break\\nelse: print('NO')\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Polycarp is very fond of playing the game Minesweeper. Recently he found a similar game and there are such rules.\\n\\nThere are mines on the field, for each the coordinates of its location are known (x_i, y_i). Each mine has a lifetime in seconds, after which it will explode. After the explosion, the mine also detonates all mines vertically and horizontally at a distance of k (two perpendicular lines). As a result, we get an explosion on the field in the form of a \\\"plus\\\" symbol ('+'). Thus, one explosion can cause new explosions, and so on.\\n\\nAlso, Polycarp can detonate anyone mine every second, starting from zero seconds. After that, a chain reaction of explosions also takes place. Mines explode instantly and also instantly detonate other mines according to the rules described above.\\n\\nPolycarp wants to set a new record and asks you to help him calculate in what minimum number of seconds all mines can be detonated.\\n\\nInput\\n\\nThe first line of the input contains an integer t (1 ≤ t ≤ 10^4) — the number of test cases in the test.\\n\\nAn empty line is written in front of each test suite.\\n\\nNext comes a line that contains integers n and k (1 ≤ n ≤ 2 ⋅ 10^5, 0 ≤ k ≤ 10^9) — the number of mines and the distance that hit by mines during the explosion, respectively.\\n\\nThen n lines follow, the i-th of which describes the x and y coordinates of the i-th mine and the time until its explosion (-10^9 ≤ x, y ≤ 10^9, 0 ≤ timer ≤ 10^9). It is guaranteed that all mines have different coordinates.\\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\\nPrint t lines, each of the lines must contain the answer to the corresponding set of input data — the minimum number of seconds it takes to explode all the mines.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n\\n5 0\\n0 0 1\\n0 1 4\\n1 0 2\\n1 1 3\\n2 2 9\\n\\n5 2\\n0 0 1\\n0 1 4\\n1 0 2\\n1 1 3\\n2 2 9\\n\\n6 1\\n1 -1 3\\n0 -1 9\\n0 1 7\\n-1 0 1\\n-1 1 9\\n-1 -1 7\\n\\n\\nOutput\\n\\n\\n2\\n1\\n0\\n\\nNote\\n\\n Picture from examples\\n\\nFirst example: \\n\\n * 0 second: we explode a mine at the cell (2, 2), it does not...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nconst long long mod = 998244353;\\nconst long long inf = 1LL << 62;\\nstruct Mine {\\n long long x, y, timer;\\n long long x_pos, y_pos;\\n long long comp_num;\\n Mine() : x(0), y(0), timer(0), x_pos(-1), y_pos(-1), comp_num(-1) {}\\n Mine(long long xx, long long yy, long long tm)\\n : x(xx), y(yy), timer(tm), x_pos(-1), y_pos(-1), comp_num(-1) {}\\n};\\nlong long n, k;\\nvector a;\\nmap>> x, y;\\nvector timer;\\nbool my_less(pair l, pair r) {\\n return l.first < r.first;\\n}\\nvoid dfs(long long i, long long curr_comp) {\\n a[i].comp_num = curr_comp;\\n timer[curr_comp] = min(timer[curr_comp], a[i].timer);\\n auto& vy = x[a[i].x];\\n auto it = lower_bound(vy.begin(), vy.end(), make_pair(a[i].y, i));\\n if (it != vy.begin()) {\\n auto j = *(it - 1);\\n if (abs(a[i].y - j.first) <= k && a[j.second].comp_num < 0)\\n dfs(j.second, curr_comp);\\n }\\n if (it + 1 != vy.end()) {\\n auto j = *(it + 1);\\n if (abs(a[i].y - j.first) <= k && a[j.second].comp_num < 0)\\n dfs(j.second, curr_comp);\\n }\\n auto& vx = y[a[i].y];\\n it = lower_bound(vx.begin(), vx.end(), make_pair(a[i].x, i));\\n if (it != vx.begin()) {\\n auto j = *(it - 1);\\n if (abs(a[i].x - j.first) <= k && a[j.second].comp_num < 0)\\n dfs(j.second, curr_comp);\\n }\\n if (it + 1 != vx.end()) {\\n auto j = *(it + 1);\\n if (abs(a[i].x - j.first) <= k && a[j.second].comp_num < 0)\\n dfs(j.second, curr_comp);\\n }\\n}\\nvoid solve() {\\n long long i;\\n cin >> n >> k;\\n a.resize(n);\\n x.clear();\\n y.clear();\\n timer.resize(n);\\n for (i = 0; i < n; ++i) {\\n long long xx, yy, tm;\\n cin >> xx >> yy >> tm;\\n a[i] = Mine(xx, yy, tm);\\n x[xx].push_back(make_pair(yy, i));\\n y[yy].push_back(make_pair(xx, i));\\n timer[i] = inf;\\n }\\n for (auto& [xx, v] : x) {\\n sort(v.begin(), v.end(), my_less);\\n }\\n for (auto& [yy, v] : y) {\\n sort(v.begin(), v.end(), my_less);\\n }\\n long long curr_component = 0;\\n for (i = 0; i < n; ++i)\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP 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\":\"#include \\nusing namespace std;\\nint t, n, a, b;\\ninline int read() {\\n int s = 0, w = 1;\\n char ch = getchar();\\n while (ch < '0' || ch > '9') {\\n if (ch == '-') w = -1;\\n ch = getchar();\\n }\\n while (ch <= '9' && ch >= '0') {\\n s = s * 10 + ch - '0';\\n ch = getchar();\\n }\\n return s * w;\\n}\\nint main() {\\n t = read();\\n while (t--) {\\n n = read();\\n int flag = 0;\\n a = b = 0;\\n for (int i = 1; i < n; i++) {\\n for (int j = i + 1; j < n; j++) {\\n if (n % j == i) {\\n if (!a && !b) {\\n a = j;\\n b = (n - i) \\/ j;\\n if (a == b)\\n b = 0;\\n else\\n flag = 1;\\n } else if (a && !b)\\n b = j, flag = 1;\\n }\\n if (flag == 1) break;\\n }\\n if (flag == 1)\\n break;\\n else\\n a = b = 0;\\n }\\n cout << a << \\\" \\\" << b << endl;\\n }\\n return 0;\\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) =...\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nlong long const INF = 1e16;\\nlong long power(long long a, long long b) {\\n long long result = 1;\\n while (b) {\\n if (b % 2) result = (result * a) % 1000000007;\\n a = (a * a) % 1000000007;\\n b \\/= 2;\\n }\\n return result;\\n}\\nvoid CP_IS_LOVE() {\\n int 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 sum = 0;\\n for (int i = 0; i < n; i++) sum += a[i];\\n int maxi = *max_element((a).begin(), (a).end());\\n sum -= (maxi);\\n double ans = maxi + sum * 1.0 \\/ (n - 1);\\n cout << fixed << setprecision(7) << ans << \\\"\\\\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 for (int t = 1; t <= T; t++) {\\n CP_IS_LOVE();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 solution for \\\"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 heapq\\nfor i in range(int(input())):\\n n=int(input())\\n l=list(map(int,input().split()))\\n x = []\\n for i in range(n):\\n if l[i]>0:\\n x.append([-l[i],i])\\n heapq.heapify(x)\\n a=0\\n ans=[]\\n while len(x)>1:\\n xx=heapq.heappop(x)\\n yy=heapq.heappop(x)\\n a += 1\\n xx[0] += 1\\n yy[0] += 1\\n ans.append([xx[1]+1,yy[1]+1])\\n if xx[0]<0:\\n heapq.heappush(x,xx)\\n if yy[0]<0:\\n heapq.heappush(x,yy)\\n print(a)\\n for i in ans:\\n print(*i)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 solution for \\\"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())\\nwhile t:\\n a,b=map(int,input().split())\\n c,d=map(int,input().split())\\n if abs(b-d)>=7:\\n if b>d:\\n print('>')\\n else:\\n print('<')\\n else:\\n if b>=d:\\n a=a*10**(b-d)\\n else:\\n c=c*10**(d-b)\\n if a>c:\\n print('>')\\n elif a==c:\\n print('=')\\n else:\\n print('<')\\n t-=1\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"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;\\nconst long long mod = 1e9 + 7;\\nunsigned long long v[100001];\\nint main() {\\n int n, x, i;\\n v[1] = 1;\\n for (i = 2; i <= 100000; i++)\\n v[i] = (((v[i - 1] * 2 * i) % mod) * (2 * i - 1)) % mod;\\n cin >> n;\\n for (i = 0; i < n; ++i) {\\n cin >> x;\\n cout << v[x] << '\\\\n';\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"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.\\ndef f\",\"targets\":\"ind(n, a, b):\\n if abs(a - b) > 1:\\n return -1\\n if a + b > n-2:\\n return -1\\n up = [n-i for i in range(a)]\\n down = [i+1 for i in range(b)]\\n combine = [str(b+1), ]\\n if a == b:\\n for i in range(a):\\n combine.append(str(up[i]))\\n combine.append(str(down[i]))\\n else:\\n c = b\\n if a < b:\\n up, down = down, up\\n c = a\\n for i in range(c):\\n combine.append(str(up[i]))\\n combine.append(str(down[i]))\\n combine.append(str(up[-1]))\\n if int(combine[-1]) == n-a+1:\\n for i in range(n-a, b+1, -1):\\n combine.append(str(i))\\n else:\\n for i in range(b + 2, n - a + 1):\\n combine.append(str(i))\\n return ' '.join(combine)\\n\\ncases = int(input())\\nfor y in range(cases):\\n line = input().split( )\\n n, a, b = int(line[0]), int(line[1]), int(line[2])\\n print(find(n, a, b))\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"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.*;\\nimport java.util.Map.Entry;\\nimport java.lang.*;\\nimport java.io.*;\\nimport java.math.BigInteger;\\n\\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) {\\n\\t\\t\\tif(pow == 0)...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nLet's call a positive integer good if there is no digit 0 in its decimal representation.\\n\\nFor an array of a good numbers a, one found out that the sum of some two neighboring elements is equal to x (i.e. x = a_i + a_{i + 1} for some i). x had turned out to be a good number as well.\\n\\nThen the elements of the array a were written out one after another without separators into one string s. For example, if a = [12, 5, 6, 133], then s = 1256133.\\n\\nYou are given a string s and a number x. Your task is to determine the positions in the string that correspond to the adjacent elements of the array that have sum x. If there are several possible answers, you can print any of them.\\n\\nInput\\n\\nThe first line contains the string s (2 ≤ |s| ≤ 5 ⋅ 10^5).\\n\\nThe second line contains an integer x (2 ≤ x < 10^{200000}).\\n\\nAn additional constraint on the input: the answer always exists, i.e you can always select two adjacent substrings of the string s so that if you convert these substrings to integers, their sum is equal to x.\\n\\nOutput\\n\\nIn the first line, print two integers l_1, r_1, meaning that the first term of the sum (a_i) is in the string s from position l_1 to position r_1.\\n\\nIn the second line, print two integers l_2, r_2, meaning that the second term of the sum (a_{i + 1}) is in the string s from position l_2 to position r_2.\\n\\nExamples\\n\\nInput\\n\\n\\n1256133\\n17\\n\\n\\nOutput\\n\\n\\n1 2\\n3 3\\n\\n\\nInput\\n\\n\\n9544715561\\n525\\n\\n\\nOutput\\n\\n\\n2 3\\n4 6\\n\\n\\nInput\\n\\n\\n239923\\n5\\n\\n\\nOutput\\n\\n\\n1 1\\n2 2\\n\\n\\nInput\\n\\n\\n1218633757639\\n976272\\n\\n\\nOutput\\n\\n\\n2 7\\n8 13\\n\\nNote\\n\\nIn the first example s[1;2] = 12 and s[3;3] = 5, 12+5=17.\\n\\nIn the second example s[2;3] = 54 and s[4;6] = 471, 54+471=525.\\n\\nIn the third example s[1;1] = 2 and s[2;2] = 3, 2+3=5.\\n\\nIn the fourth example s[2;7] = 218633 and s[8;13] = 757639, 218633+757639=976272.\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 500000;\\nmt19937 Rand(time(0));\\nint mod[3];\\nstruct hasher {\\n int a[3];\\n hasher(int x = 0) { a[0] = a[1] = a[2] = x; }\\n friend hasher operator+(const hasher &a, const hasher &b) {\\n hasher res;\\n for (int i = 0; i < 3; ++i) {\\n res.a[i] = a.a[i] + b.a[i];\\n if (res.a[i] >= mod[i]) res.a[i] -= mod[i];\\n }\\n return res;\\n }\\n friend hasher operator-(const hasher &a, const hasher &b) {\\n hasher res;\\n for (int i = 0; i < 3; ++i) {\\n res.a[i] = a.a[i] - b.a[i];\\n if (res.a[i] < 0) res.a[i] += mod[i];\\n }\\n return res;\\n }\\n friend hasher operator*(const hasher &a, const hasher &b) {\\n hasher res;\\n for (int i = 0; i < 3; ++i) res.a[i] = 1LL * a.a[i] * b.a[i] % mod[i];\\n return res;\\n }\\n friend bool operator==(const hasher &a, const hasher &b) {\\n for (int i = 0; i < 3; ++i)\\n if (a.a[i] != b.a[i]) return 0;\\n return 1;\\n }\\n hasher inv() {\\n hasher res = 1;\\n for (int i = 0; i < 3; ++i) {\\n int k = mod[i] - 2, x = a[i];\\n for (; k; k >>= 1, x = 1LL * x * x % mod[i])\\n if (k & 1) res.a[i] = 1LL * res.a[i] * x % mod[i];\\n }\\n return res;\\n }\\n} pw[N + 9];\\nvoid Get_pw() {\\n pw[0] = 1;\\n pw[1] = 10;\\n for (int i = 2; i <= N; ++i) pw[i] = pw[i - 1] * pw[1];\\n}\\nhasher Get_hash(hasher *h, int l, int r) {\\n return h[r] - h[l - 1] * pw[r - l + 1];\\n}\\nhasher Get_hash(vector &h, int l, int r) {\\n return h[r] - h[l - 1] * pw[r - l + 1];\\n}\\nchar s[N + 9], t[N + 9];\\nint n, m;\\nvoid into() {\\n scanf(\\\"%s%s\\\", s + 1, t + 1);\\n n = strlen(s + 1);\\n m = strlen(t + 1);\\n}\\nint Get_mod0() { return 19260817; }\\nbool Check_prime(int n) {\\n for (int i = 2; i * i <= n; ++i)\\n if (n % i == 0) return 0;\\n return 1;\\n}\\nint Get_prime(int n) {\\n for (; !Check_prime(n); ++n)\\n ;\\n return n;\\n}\\nint Get_mod1() {\\n int sum = 0;\\n for (int i = 1; i <= n; ++i) sum += s[i];\\n for (int i = 1; i <= m; ++i) sum += t[i];\\n int n = Rand() % 200000000 + 300000000 + sum;\\n return Get_prime(n);\\n}\\nint Get_mod2() {\\n int x =...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Theofanis has a string s_1 s_2 ... s_n and a character c. He wants to make all characters of the string equal to c using the minimum number of operations.\\n\\nIn one operation he can choose a number x (1 ≤ x ≤ n) and for every position i, where i is not divisible by x, replace s_i with c. \\n\\nFind the minimum number of operations required to make all the characters equal to c and the x-s that he should use in his operations.\\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 the integer n (3 ≤ n ≤ 3 ⋅ 10^5) and a lowercase Latin letter c — the length of the string s and the character the resulting string should consist of.\\n\\nThe second line of each test case contains a string s of lowercase Latin letters — the initial string.\\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, firstly print one integer m — the minimum number of operations required to make all the characters equal to c.\\n\\nNext, print m integers x_1, x_2, ..., x_m (1 ≤ x_j ≤ n) — the x-s that should be used in the order they are given.\\n\\nIt can be proved that under given constraints, an answer always exists. If there are multiple answers, print any.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n4 a\\naaaa\\n4 a\\nbaaa\\n4 b\\nbzyx\\n\\n\\nOutput\\n\\n\\n0\\n1\\n2\\n2 \\n2 3\\n\\nNote\\n\\nLet's describe what happens in the third test case: \\n\\n 1. x_1 = 2: we choose all positions that are not divisible by 2 and replace them, i. e. bzyx → bzbx; \\n 2. x_2 = 3: we choose all positions that are not divisible by 3 and replace them, i. e. bzbx → bbbb.\",\"targets\":\"from sys import stdin\\ndef solve():\\n n, c = stdin.readline().split()\\n n = int(n)\\n s = stdin.readline().strip()\\n a = [x == c for x in s]\\n if all(x for x in a):\\n print 0\\n return\\n for i in xrange(n, 1, -1):\\n if a[i-1]:\\n j = i * 2 - 1\\n while j < n:\\n if not a[j]:\\n break\\n j += i\\n else:\\n print 1\\n print i\\n return\\n print 2\\n print n - 1, n\\nT = int(stdin.readline())\\nfor t in xrange(T):\\n solve()\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nIahub is very proud of his recent discovery, propagating trees. Right now, he invented a new tree, called xor-tree. After this new revolutionary discovery, he invented a game for kids which uses xor-trees.\\n\\nThe game is played on a tree having n nodes, numbered from 1 to n. Each node i has an initial value initi, which is either 0 or 1. The root of the tree is node 1.\\n\\nOne can perform several (possibly, zero) operations on the tree during the game. The only available type of operation is to pick a node x. Right after someone has picked node x, the value of node x flips, the values of sons of x remain the same, the values of sons of sons of x flips, the values of sons of sons of sons of x remain the same and so on.\\n\\nThe goal of the game is to get each node i to have value goali, which can also be only 0 or 1. You need to reach the goal of the game by using minimum number of operations.\\n\\nInput\\n\\nThe first line contains an integer n (1 ≤ n ≤ 105). Each of the next n - 1 lines contains two integers ui and vi (1 ≤ ui, vi ≤ n; ui ≠ vi) meaning there is an edge between nodes ui and vi. \\n\\nThe next line contains n integer numbers, the i-th of them corresponds to initi (initi is either 0 or 1). The following line also contains n integer numbers, the i-th number corresponds to goali (goali is either 0 or 1).\\n\\nOutput\\n\\nIn the first line output an integer number cnt, representing the minimal number of operations you perform. Each of the next cnt lines should contain an integer xi, representing that you pick a node xi.\\n\\nExamples\\n\\nInput\\n\\n10\\n2 1\\n3 1\\n4 2\\n5 1\\n6 2\\n7 5\\n8 6\\n9 8\\n10 5\\n1 0 1 1 0 1 0 1 0 1\\n1 0 1 0 0 1 1 1 0 1\\n\\n\\nOutput\\n\\n2\\n4\\n7\",\"targets\":\"#include \\nusing namespace std;\\nvector adjList[100005], goal, ini, ans, isVisited;\\nvoid DFS(int x, bool odd, bool even, int status) {\\n if (!isVisited[x]) {\\n isVisited[x] = 1;\\n if (((status & 1) && odd) || (!(status & 1) && even))\\n ini[x - 1] = !ini[x - 1];\\n if (ini[x - 1] != goal[x - 1]) {\\n ans.push_back(x);\\n status& 1 ? odd = !odd : even = !even;\\n }\\n for (auto child : adjList[x]) DFS(child, odd, even, status + 1);\\n }\\n}\\nint main(void) {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n cerr.tie(NULL);\\n ;\\n int n, u, v;\\n cin >> n;\\n isVisited.assign(n + 1, 0);\\n for (int i = 1; i < n; i++) {\\n cin >> u >> v;\\n adjList[u].push_back(v);\\n adjList[v].push_back(u);\\n }\\n for (int i = 0; i < n; i++) {\\n cin >> u;\\n ini.push_back(u);\\n }\\n for (int i = 0; i < n; i++) {\\n cin >> u;\\n goal.push_back(u);\\n }\\n DFS(1, 0, 0, 0);\\n cout << ans.size() << '\\\\n';\\n for (auto it : ans) cout << it << '\\\\n';\\n cout << '\\\\n';\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"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;\\nconst int mod = (119 << 23) + 1, root = 3;\\nconst long double pi = 4 * atan((long double)1);\\nint size(int s) { return s > 1 ? 32 - __builtin_clz(s - 1) : 0; }\\nint sum(int a, const int& b) {\\n if ((a += b) >= mod) a -= mod;\\n return a;\\n}\\nint sub(int a, const int& b) {\\n if ((a -= b) < 0) a += mod;\\n return a;\\n}\\nint mult(int a, const int& b) { return (1LL * a * b) % mod; }\\nint binpow(long long x, long long p) {\\n int ans;\\n for (ans = 1; p; p >>= 1) {\\n if (p & 1LL) ans = mult(ans, x);\\n x = mult(x, x);\\n }\\n return ans;\\n}\\nvoid genRoots(vector>& roots) {\\n int n = roots.size();\\n long double ang = 2 * pi \\/ n;\\n for (int i = 0; i < n; ++i)\\n roots[i] = complex(cos(ang * i), sin(ang * i));\\n}\\nvoid genRoots(vector& roots) {\\n int n = roots.size();\\n int r = binpow(root, (mod - 1) \\/ n);\\n roots[0] = 1;\\n for (int i = 1; i < n; ++i) roots[i] = mult(roots[i - 1], r);\\n}\\nvoid Fft(vector& a, const vector& roots, bool inv = 0) {\\n int n = a.size();\\n for (int i = 1, j = 0; i < n; ++i) {\\n int bit = n >> 1;\\n for (; j & bit; bit >>= 1) j ^= bit;\\n j ^= bit;\\n if (i < j) swap(a[i], a[j]);\\n }\\n for (int len = 2; len <= n; len <<= 1)\\n for (int i = 0; i < n; i += len)\\n for (int j = 0; j < len \\/ 2; ++j) {\\n int ind = n \\/ len * j;\\n if (inv && ind) ind = n - ind;\\n int u = a[i + j], v = mult(a[i + j + len \\/ 2], roots[ind]);\\n a[i + j] = sum(u, v), a[i + j + len \\/ 2] = sub(u, v);\\n }\\n if (inv) {\\n int i = binpow(n, mod - 2);\\n for (int& x : a) x = mult(x, i);\\n }\\n}\\nvector Mult(vector a, vector b) {\\n int as = a.size(), bs = b.size();\\n if (!min(as, bs)) return {};\\n int s = as + bs - 1, n = 1 << size(s);\\n vector roots(n);\\n genRoots(roots);\\n a.resize(n);\\n Fft(a, roots);\\n b.resize(n);\\n Fft(b, roots);\\n for (int i = 0; i < n; ++i) a[i] = mult(a[i], b[i]);\\n Fft(a, roots, true);\\n a.resize(s);\\n return a;\\n}\\ntemplate \\nstruct Tint {\\n T val;\\n Tint() :...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"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...\\nSolve the task in PYTHON3.\",\"targets\":\"t=int(input())\\nwhile t>0:\\n n=int(input())\\n enemys=str(input())\\n ours=str(input())\\n enemy=[]\\n our=[]\\n for i in range(n):\\n enemy.append(int(enemys[i]))\\n our.append(int(ours[i]))\\n ep=0\\n op=0\\n ans=0\\n for i in enemy:\\n if i==1:\\n ep+=1\\n for i in our:\\n if i==1:\\n op+=1\\n if ep==0:\\n print(op)\\n else:\\n if op==0:\\n print(0)\\n else:\\n for i in range(n):\\n if enemy[i]==0 and our[i]==1:\\n ans+=1\\n our[i]=0\\n for i in range(n):\\n if our[i]==1:\\n if i>0 and enemy[i-1]==1:\\n ans+=1\\n enemy[i-1]=0\\n elif i\\nusing namespace std;\\nnamespace my_rand {\\nuint64_t rng() {\\n static uint64_t x_ =\\n uint64_t(chrono::duration_cast(\\n chrono::high_resolution_clock::now().time_since_epoch())\\n .count()) *\\n 10150724397891781847ULL;\\n x_ ^= x_ << 7;\\n return x_ ^= x_ >> 9;\\n}\\nint64_t randint(int64_t l, int64_t r) {\\n assert(l < r);\\n return l + rng() % (r - l);\\n}\\nvector randset(int64_t l, int64_t r, int64_t n) {\\n assert(l <= r && n <= r - l);\\n unordered_set s;\\n for (int64_t i = n; i; --i) {\\n int64_t m = randint(l, r + 1 - i);\\n if (s.find(m) != s.end()) m = r - i;\\n s.insert(m);\\n }\\n vector ret;\\n for (auto& x : s) ret.push_back(x);\\n return ret;\\n}\\ndouble rnd() {\\n union raw_cast {\\n double t;\\n uint64_t u;\\n };\\n constexpr uint64_t p = uint64_t(1023 - 64) << 52;\\n return rng() * ((raw_cast*)(&p))->t;\\n}\\ntemplate \\nvoid randshf(vector& v) {\\n int n = v.size();\\n for (int loop = 0; loop < 2; loop++)\\n for (int i = 0; i < n; i++) swap(v[i], v[randint(0, n)]);\\n}\\n} \\/\\/ namespace my_rand\\nusing my_rand::randint;\\nusing my_rand::randset;\\nusing my_rand::randshf;\\nusing my_rand::rnd;\\nusing my_rand::rng;\\ntemplate \\nstruct Sieve {\\n int spf[SZ];\\n Sieve() {\\n spf[1] = 1;\\n for (int i = 2; i < SZ; i++) spf[i] = i;\\n for (int i = 4; i < SZ; i += 2) spf[i] = 2;\\n for (int i = 3; i * i < SZ; i++)\\n if (spf[i] == i)\\n for (int j = i * i; j < SZ; j += i)\\n if (spf[j] == j) spf[j] = i;\\n }\\n std::vector> factor(int x) {\\n std::vector> ret;\\n while (x != 1) {\\n if ((int)ret.size() == 0)\\n ret.emplace_back(spf[x], 1);\\n else {\\n if (ret.back().first == spf[x])\\n ret.back().second++;\\n else\\n ret.emplace_back(spf[x], 1);\\n }\\n x \\/= spf[x];\\n }\\n return ret;\\n }\\n};\\nvector check3(int n) {\\n if (n % 4 == 0 || n % 4 == 1) {\\n if (n % 4 == 1) {\\n --n;\\n }\\n vector...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Consider creating the following number pattern.\\n\\n\\n4 8 2 3 1 0 8 3 7 6\\n2 0 5 4 1 8 1 0 3\\n2 5 9 5 9 9 1 3\\n7 4 4 4 8 0 4\\n1 8 8 2 8 4\\n9 6 0 0 2\\n5 6 0 2\\n1 6 2\\n7 8\\nFive\\n\\n\\nThis pattern follows the rules below.\\n\\n\\nA B\\nC\\n\\n\\nIn the sequence of numbers, C is the ones digit of A + B. For example\\n\\n\\n9 5\\nFour\\n\\n\\nNow, the ones digit of 9 + 5 = 14, or 4 is placed diagonally below 9 and 5. Also,\\n\\n\\ntwenty three\\nFive\\n\\n\\nNow, the ones digit of 2 + 3 = 5, that is, 5 is placed diagonally below 2 and 3.\\n\\nWrite a program that reads the 10 integers in the top line and outputs one number in the bottom line.\\n\\n\\n\\nInput\\n\\nThe input consists of multiple datasets. For each dataset, the top 10 numbers are given as strings on one line.\\n\\nThe number of datasets does not exceed 20.\\n\\nOutput\\n\\nOutputs the numbers in the bottom line to one line for each dataset.\\n\\nExample\\n\\nInput\\n\\n4823108376\\n1234567890\\n0123456789\\n\\n\\nOutput\\n\\n5\\n6\\n4\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.util.Scanner;\\n\\npublic class Main\\n{\\n\\tstatic int aa[] = new int[10]; \\n\\tpublic static void main(String arg[])\\n\\t{\\n\\t\\tScanner sc = new Scanner(System.in);\\n\\t\\twhile(sc.hasNext())\\n\\t\\t{\\n\\t\\t\\tString a =sc.next();\\n\\t\\t\\tfor(int i=0; i<10; i++)\\n\\t\\t\\t{\\n\\t\\t\\t\\taa[i]= a.charAt(i)-48;\\n\\t\\t\\t}\\n\\n\\t\\t\\tsumdi(9,aa);\\n\\t\\t}\\n\\t}\\n\\tpublic static int sumdi(int n, int a[])\\n\\t{\\n\\t\\tif(n==0)\\n\\t\\t\\treturn 0;\\n\\t\\tfor(int i=0; i< n; i++)\\n\\t\\t\\ta[i] = (a[i]+a[i+1])%10;\\n\\t\\tif(n==1)\\n\\t\\t\\tSystem.out.println(a[0]);\\n\\t\\treturn sumdi(n-1, a);\\n\\t}\\n\\n\\n}\",\"language\":\"python\",\"split\":\"train\",\"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. \\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nvoid solve() {\\n int n, a;\\n long long c = 0;\\n cin >> n;\\n vector cou(n + 1, 0), last;\\n for (int i = 1; i <= n; i++) {\\n cin >> a;\\n cou[a]++;\\n }\\n for (int i = 0; i <= n; i++) {\\n cout << (long long)c + cou[i] << ' ';\\n for (int j = 1; j <= cou[i]; j++) last.push_back(i);\\n if (last.empty()) {\\n for (int j = i + 1; j <= n; j++) cout << \\\"-1 \\\";\\n break;\\n } else {\\n c = c + i - last.back();\\n last.pop_back();\\n }\\n }\\n cout << '\\\\n';\\n}\\nshort test;\\nint main() {\\n cin >> test;\\n for (short i = 1; i <= test; i++) solve();\\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?\\nCQXYM 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\":\"#include \\nusing namespace std;\\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 long long n, m, k;\\n cin >> n >> m >> k;\\n if (m < n - 1) {\\n cout << \\\"NO\\\\n\\\";\\n continue;\\n } else if (k <= 1) {\\n cout << \\\"NO\\\\n\\\";\\n } else if (n == 1 && k > 1 && (n * (n - 1)) \\/ 2 >= m) {\\n cout << \\\"YES\\\\n\\\";\\n } else if (n == 1 && (n * (n - 1)) \\/ 2 < m) {\\n cout << \\\"NO\\\\n\\\";\\n } else if (m > (n * (n - 1)) \\/ 2) {\\n cout << \\\"NO\\\\n\\\";\\n } else {\\n if (1 < k - 1 && ((n * (n - 1)) \\/ 2 == m)) {\\n cout << \\\"YES\\\\n\\\";\\n } else if (2 < k - 1 && ((n * (n - 1)) \\/ 2 > m)) {\\n cout << \\\"YES\\\\n\\\";\\n } else {\\n cout << \\\"NO\\\\n\\\";\\n }\\n }\\n }\\n return 0;\\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\":\"#include \\nusing namespace std;\\nint main() {\\n cin.tie(0)->sync_with_stdio(0);\\n int t = 1;\\n cin >> t;\\n while (t--) {\\n long long n;\\n cin >> n;\\n char ch[3][n + 5];\\n for (int i = 1; i <= 2; ++i) {\\n for (int j = 1; j <= n; ++j) {\\n cin >> ch[i][j];\\n }\\n }\\n bool found = true;\\n for (int i = 1; i <= n; ++i) {\\n if (i == n) continue;\\n if (ch[1][i + 1] == ch[2][i + 1] && ch[1][i + 1] == '1') {\\n found = false;\\n break;\\n }\\n }\\n cout << (found ? \\\"YES\\\" : \\\"NO\\\") << '\\\\n';\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"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....\\nimpor\",\"targets\":\"t java.util.*;\\n\\npublic class CodeForces {\\n \\n public static Boolean det(String t) {\\n String rem = \\\"\\\"; List aantallen = new ArrayList<>();\\n String temp = t;\\n while (!temp.isEmpty()) {\\n String cur = temp.substring(temp.length()-1);\\n rem = cur+rem;\\n int aantal = temp.length();\\n temp = temp.replaceAll(cur,\\\"\\\");\\n aantal -= temp.length();\\n aantallen.add(0,aantal);\\n }\\n int s_length = 0;\\n for (int i=0;i t.length()) {break;}\\n s_res = t.substring(0,s_res.length()+1);\\n }\\n return false;\\n }\\n \\n public static void main(String[] args) {\\n try (Scanner scanner = new Scanner(System.in)) {\\n int T = scanner.nextInt();\\n for (int i=1;i<=T;i++) {\\n String t = scanner.next();\\n Boolean found = det(t);\\n if (!found) {System.out.println(-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?\\nKuriyama Mirai has killed many monsters and got many (namely n) stones. She numbers the stones from 1 to n. The cost of the i-th stone is vi. Kuriyama Mirai wants to know something about these stones so she will ask you two kinds of questions:\\n\\n 1. She will tell you two numbers, l and r (1 ≤ l ≤ r ≤ n), and you should tell her . \\n 2. Let ui be the cost of the i-th cheapest stone (the cost that will be on the i-th place if we arrange all the stone costs in non-decreasing order). This time she will tell you two numbers, l and r (1 ≤ l ≤ r ≤ n), and you should tell her . \\n\\n\\n\\nFor every question you should give the correct answer, or Kuriyama Mirai will say \\\"fuyukai desu\\\" and then become unhappy.\\n\\nInput\\n\\nThe first line contains an integer n (1 ≤ n ≤ 105). The second line contains n integers: v1, v2, ..., vn (1 ≤ vi ≤ 109) — costs of the stones. \\n\\nThe third line contains an integer m (1 ≤ m ≤ 105) — the number of Kuriyama Mirai's questions. Then follow m lines, each line contains three integers type, l and r (1 ≤ l ≤ r ≤ n; 1 ≤ type ≤ 2), describing a question. If type equal to 1, then you should output the answer for the first question, else you should output the answer for the second one.\\n\\nOutput\\n\\nPrint m lines. Each line must contain an integer — the answer to Kuriyama Mirai's question. Print the answers to the questions in the order of input.\\n\\nExamples\\n\\nInput\\n\\n6\\n6 4 2 7 2 7\\n3\\n2 3 6\\n1 3 4\\n1 1 6\\n\\n\\nOutput\\n\\n24\\n9\\n28\\n\\n\\nInput\\n\\n4\\n5 5 2 3\\n10\\n1 2 4\\n2 1 4\\n1 1 1\\n2 1 4\\n2 1 2\\n1 1 1\\n1 3 3\\n1 1 3\\n1 4 4\\n1 2 2\\n\\n\\nOutput\\n\\n10\\n15\\n5\\n15\\n5\\n5\\n2\\n12\\n3\\n5\\n\\nNote\\n\\nPlease note that the answers to the questions may overflow 32-bit integer type.\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int n, m, x, y, z;\\n cin >> n;\\n long long a[n], b[n], c[n];\\n for (int i = 0; i < n; i++) cin >> a[i];\\n b[0] = c[0] = 0;\\n for (int i = 1; i <= n; i++) b[i] = b[i - 1] + a[i - 1];\\n sort(a, a + n);\\n for (int i = 1; i <= n; i++) c[i] = c[i - 1] + a[i - 1];\\n cin >> m;\\n while (m--) {\\n cin >> x >> y >> z;\\n if (x == 1)\\n cout << b[z] - b[y - 1] << endl;\\n else\\n cout << c[z] - c[y - 1] << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.\\n\\nHelp Timofey to color his rectangles in 4 different colors in such a way that every two rectangles touching each other by side would have different color, or determine that it is impossible.\\n\\nTwo rectangles intersect if their intersection has positive area. Two rectangles touch by sides if there is a pair of sides such that their intersection has non-zero length\\n\\n The picture corresponds to the first example\\n\\nInput\\n\\nThe first line contains single integer n (1 ≤ n ≤ 5·105) — the number of rectangles.\\n\\nn lines follow. The i-th of these lines contains four integers x1, y1, x2 and y2 ( - 109 ≤ x1 < x2 ≤ 109, - 109 ≤ y1 < y2 ≤ 109), that means that points (x1, y1) and (x2, y2) are the coordinates of two opposite corners of the i-th rectangle.\\n\\nIt is guaranteed, that all sides of the rectangles have odd lengths and rectangles don't intersect each other.\\n\\nOutput\\n\\nPrint \\\"NO\\\" in the only line if it is impossible to color the rectangles in 4 different colors in such a way that every two rectangles touching each other by side would have different color.\\n\\nOtherwise, print \\\"YES\\\" in the first line. Then print n lines, in the i-th of them print single integer ci (1 ≤ ci ≤ 4) — the color of i-th rectangle.\\n\\nExample\\n\\nInput\\n\\n8\\n0 0 5 3\\n2 -1 5 0\\n-3 -4 2 -1\\n-1 -1 2 0\\n-3 0 0 5\\n5 2 10 3\\n7 -3 10 2\\n4 -2 7 -1\\n\\n\\nOutput\\n\\nYES\\n1\\n2\\n2\\n3\\n2\\n2\\n4\\n1\\\":\",\"targets\":\"#include \\nusing namespace std;\\nconst int MAXN = 500005;\\nint ans[MAXN];\\nint main() {\\n ios_base::sync_with_stdio(false);\\n long long n, x1, y1, x2, y2;\\n cin >> n;\\n for (int i = 0; i < n; i++) {\\n cin >> x1 >> y1 >> x2 >> y2;\\n x1 += (long long)(1e9);\\n y1 += (long long)(1e9);\\n ans[i] = ((x1 & 1) << 1) + (y1 & 1);\\n }\\n cout << \\\"YES\\\" << endl;\\n for (int i = 0; i < n; i++) cout << ans[i] + 1 << \\\"\\\\n\\\";\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 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\":\"for i in range(int(input())):\\n n = int(input())\\n s = input()\\n ans = ''\\n d = {\\\"B\\\": \\\"R\\\", \\\"R\\\": \\\"B\\\"}\\n for j in range(n):\\n if s[j] != '?':\\n ans += s[j]\\n else:\\n if j == 0:\\n h = '.'\\n o = 0\\n for k in range(n):\\n if s[k] != '?':\\n h = s[k]\\n o = k\\n break\\n if h == '.':\\n ans += 'B'\\n else:\\n if o % 2 != 0:\\n ans += d[h]\\n else:\\n ans += h\\n else:\\n ans += d[ans[-1]]\\n print(ans)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\n> I would, if I could,\\n> If I couldn't how could I?\\n> I couldn't, without I could, could I?\\n> Could you, without you could, could ye?\\n> Could ye? could ye?\\n> Could you, without you could, could ye?\\n\\nIt is true, as this old rhyme says, that we can only DO what we can DO and we cannot DO what we cannot DO. Changing some of DOs with COUNTs, we have another statement that we can only COUNT what we can DO and we cannot COUNT what we cannot DO, which looks rather false. We could count what we could do as well as we could count what we couldn't do. Couldn't we, if we confine ourselves to finite issues?\\n\\nSurely we can count, in principle, both what we can do and what we cannot do, if the object space is finite. Yet, sometimes we cannot count in practice what we can do or what we cannot do. Here, you are challenged, in a set of all positive integers up to (and including) a given bound n, to count all the integers that cannot be represented by a formula of the form a*i+b*j, where a and b are given positive integers and i and j are variables ranging over non-negative integers. You are requested to report only the result of the count, i.e. how many integers are not representable. For example, given n = 7, a = 2, b = 5, you should answer 2, since 1 and 3 cannot be represented in a specified form, and the other five numbers are representable as follows:\\n\\n\\n2 = 2*1 + 5*0, 4 = 2*2 + 5*0, 5 = 2*0 + 5*1,\\n6 = 2*3 + 5*0, 7 = 2*1 + 5*1.\\n\\n\\n\\n\\nInput\\n\\nThe input is a sequence of lines. Each line consists of three integers, n, a and b, in this order, separated by a space. The integers n, a and b are all positive and at most one million, except those in the last line. The last line consists of three zeros.\\n\\nOutput\\n\\nFor each input line except the last one, your program should write out a line that contains only the result of the count.\\n\\nExample\\n\\nInput\\n\\n10 2 3\\n10 2 5\\n100 5 25\\n0 0 0\\n\\n\\nOutput\\n\\n1\\n2\\n80\",\"targets\":\"#include\\n#include\\n#include\\n#include\\n#include\\n#include\\nusing namespace std;\\nint main(){\\n int i;\\n int n,a,b;\\n while(cin>>n>>a>>b&&n+a+b){\\n int ct=n+1;\\n bool c[n+1];\\n memset(c,0,n+1);\\n c[0]=1;\\n for(i=0;i\\nusing namespace std;\\nint main() {\\n cin.tie(0);\\n ios_base::sync_with_stdio(0);\\n long long t;\\n cin >> t;\\n while (t--) {\\n vector v(7);\\n for (auto& e : v) cin >> e;\\n sort(v.begin(), v.end());\\n cout << v[0] << ' ' << v[1] << ' ';\\n if (v[2] != v[1] + v[0])\\n cout << v[2] << endl;\\n else\\n cout << v[3] << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Andrew often reads articles in his favorite magazine 2Char. The main feature of these articles is that each of them uses at most two distinct letters. Andrew decided to send an article to the magazine, but as he hasn't written any article, he just decided to take a random one from magazine 26Char. However, before sending it to the magazine 2Char, he needs to adapt the text to the format of the journal. To do so, he removes some words from the chosen article, in such a way that the remaining text can be written using no more than two distinct letters.\\n\\nSince the payment depends from the number of non-space characters in the article, Andrew wants to keep the words with the maximum total length.\\n\\nInput\\n\\nThe first line of the input contains number n (1 ≤ n ≤ 100) — the number of words in the article chosen by Andrew. Following are n lines, each of them contains one word. All the words consist only of small English letters and their total length doesn't exceed 1000. The words are not guaranteed to be distinct, in this case you are allowed to use a word in the article as many times as it appears in the input.\\n\\nOutput\\n\\nPrint a single integer — the maximum possible total length of words in Andrew's article.\\n\\nExamples\\n\\nInput\\n\\n4\\nabb\\ncacc\\naaa\\nbbb\\n\\n\\nOutput\\n\\n9\\n\\nInput\\n\\n5\\na\\na\\nbcbcb\\ncdecdecdecdecdecde\\naaaa\\n\\n\\nOutput\\n\\n6\\n\\nNote\\n\\nIn the first sample the optimal way to choose words is {'abb', 'aaa', 'bbb'}.\\n\\nIn the second sample the word 'cdecdecdecdecdecde' consists of three distinct letters, and thus cannot be used in the article. The optimal answer is {'a', 'a', 'aaaa'}.\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nint main() {\\n vector > a(30, vector(30, 0));\\n int n, maks = 0;\\n cin >> n;\\n for (int i = 0; i < n; i++) {\\n string bes, crk = \\\"\\\";\\n cin >> bes;\\n int len = bes.length();\\n for (int j = 0; j < bes.length(); j++) {\\n if (crk.find(bes[j]) == string::npos) {\\n crk += bes[j];\\n }\\n }\\n int c = crk[0] - 'a';\\n if (crk.length() == 2) {\\n int c = min(crk[0], crk[1]) - 'a', d = max(crk[0], crk[1]) - 'a';\\n a[c][d] += len;\\n if (a[c][d] > maks) maks = a[c][d];\\n } else if (crk.length() == 1) {\\n for (int j = 0; j < 30; j++) {\\n a[j][c] += len;\\n if (a[j][c] > maks) maks = a[j][c];\\n if (c != j) {\\n a[c][j] += len;\\n if (a[c][j] > maks) maks = a[c][j];\\n }\\n }\\n }\\n }\\n cout << maks << endl;\\n return 0;\\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.\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"\\/**\\n * 12\\/16\\/21 morning\\n * https:\\/\\/codeforces.com\\/contest\\/1617\\/problem\\/0\\n *\\/\\n\\/\\/ package codeforce.cf.div2.r761;\\n\\nimport java.util.*;\\nimport java.io.*;\\n\\npublic class A {\\n static PrintWriter pw;\\n\\n void solve1(String s, String t) {\\n char[] a = s.toCharArray();\\n char[] b = t.toCharArray();\\n Arrays.sort(a);\\n while (true) {\\n if (!isSubsequence(a, b)) {\\n pr(new String(a));\\n return;\\n }\\n next_permutation(a);\\n }\\n }\\n\\n void solve(String s, String t) {\\n char[] a = s.toCharArray();\\n char[] b = t.toCharArray();\\n Arrays.sort(b);\\n String smallest = new String(b);\\n next_permutation(b);\\n String next_small = new String(b);\\n String order = t.equals(smallest) ? next_small : smallest;\\n \\/\\/ tr(\\\"s\\\", s, \\\"t\\\", t, \\\"order\\\", order);\\n int[] f = new int[26];\\n for (char c : a) f[c - 'a']++;\\n if (f[0] == 0 || f[1] == 0 || f[2] == 0) { \\/\\/ a b c not full\\n Arrays.sort(a);\\n pr(new String(a));\\n return;\\n }\\n String res = \\\"\\\";\\n if (order.equals(smallest)) { \\/\\/ 'abc'\\n for (int i = 0; i < 26; i++) {\\n if (f[i] == 0) continue;\\n char c = (char) ('a' + i);\\n String tmp = (c + \\\"\\\").repeat(f[c - 'a']);\\n res += tmp;\\n }\\n } else { \\/\\/ 'acb'\\n res += \\\"a\\\".repeat(f[0]);\\n res += \\\"c\\\".repeat(f[2]);\\n res += \\\"b\\\".repeat(f[1]);\\n for (int i = 3; i < 26; i++) {\\n if (f[i] == 0) continue;\\n char c = (char) ('a' + i);\\n String tmp = (c + \\\"\\\").repeat(f[c - 'a']);\\n res += tmp;\\n }\\n }\\n pr(res);\\n }\\n\\n boolean isSubsequence(char[] s, char[] t) {\\n int sn = s.length, tn = t.length, i = 0, j = 0;\\n while (i < sn && j < tn) {\\n if (s[i] == t[j]) {\\n i++;\\n j++;\\n } else {\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nYou 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.util.ArrayList;\\nimport java.util.Collections;\\nimport java.util.Comparator;\\nimport java.util.HashMap;\\nimport java.util.HashSet;\\nimport java.util.LinkedHashMap;\\nimport java.util.LinkedList;\\nimport java.util.List;\\nimport java.util.Map;\\nimport java.util.Set;\\nimport java.util.StringTokenizer;\\n\\npublic class P1613B {\\n\\tstatic PrintWriter out = new PrintWriter(System.out);\\n\\tstatic MyFastReaderP1613B in = new MyFastReaderP1613B();\\n\\tstatic long mod = (long) (1e9 + 7);\\n\\n\\tpublic static void main(String[] args) throws Exception {\\n\\t\\tint test = i();\\n\\t\\twhile (test-- > 0) {\\n int n=i();\\n int[] arr=arrI(n);\\n sort(arr);\\n \\n for(int i=1;i<=n\\/2;i++) out.println(arr[i]+\\\" \\\"+arr[0]);\\n \\t\\n\\t\\t\\tout.flush();\\n\\t\\t}\\n\\t\\tout.close();\\n\\t}\\n\\n\\tstatic class pair {\\n\\t\\tlong x, y;\\n\\n\\t\\tpair(long ar, long ar2) {\\n\\t\\t\\tx = ar;\\n\\t\\t\\ty = ar2;\\n\\t\\t}\\n\\t}\\n\\n\\tstatic void sort(long[] a) \\/\\/ check for long\\n\\t{\\n\\t\\tArrayList l = new ArrayList<>();\\n\\t\\tfor (long i : a)\\n\\t\\t\\tl.add(i);\\n\\t\\tCollections.sort(l);\\n\\t\\tfor (int i = 0; i < a.length; i++)\\n\\t\\t\\ta[i] = l.get(i);\\n\\t}\\n\\n\\tstatic void sort(int[] a) {\\n\\t\\tArrayList l = new ArrayList<>();\\n\\t\\tfor (int i : a)\\n\\t\\t\\tl.add(i);\\n\\t\\tCollections.sort(l);\\n\\t\\tfor (int i = 0; i < a.length; i++)\\n\\t\\t\\ta[i] = l.get(i);\\n\\t}\\n\\n\\tpublic static int gcd(int a, int b) {\\n\\t\\tif (a == 0)\\n\\t\\t\\treturn b;\\n\\t\\treturn gcd(b % a, a);\\n\\t}\\n\\n\\tstatic class DescendingComparator implements Comparator {\\n\\t\\tpublic int compare(Integer a, Integer b) {\\n\\t\\t\\treturn b - a;\\n\\t\\t}\\n\\t}\\n\\n\\tstatic class AscendingComparator implements Comparator {\\n\\t\\tpublic int compare(Integer a, Integer b) {\\n\\t\\t\\treturn a - b;\\n\\t\\t}\\n\\t}\\n\\n\\tstatic boolean isPalindrome(char X[]) {\\n\\t\\tint l = 0, r = X.length - 1;\\n\\t\\twhile (l <= r) {\\n\\t\\t\\tif (X[l] != X[r])\\n\\t\\t\\t\\treturn false;\\n\\t\\t\\tl++;\\n\\t\\t\\tr--;\\n\\t\\t}\\n\\t\\treturn true;\\n\\t}\\n\\n\\tstatic long fact(long N) {\\n\\t\\tlong num = 1L;\\n\\t\\twhile (N >= 1) {\\n\\t\\t\\tnum = ((num % mod) * (N % mod)) %...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 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\":\"tt = int(input())\\nfor _ in range(tt):\\n n = int(input())\\n s = input()\\n i = s.find(\\\"0\\\")\\n if i == -1:\\n m = n - n % 2\\n j = m \\/\\/ 2\\n print(1, m, 1, j)\\n elif i < n \\/\\/ 2:\\n print(i+2, n, i+1, n)\\n else:\\n print(1, i+1, 1, i)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Doraemon gave Nobita a gadget that swaps words inside a string in the following manner :\\n\\nIf there are W words, word 1 is swapped with word W, word 2 is swapped with word W-1 and so on.\\nThe problem is that Nobita himself cannot verify the answer for large strings. Help him write a program to do so.\\n\\nINPUT : \\nthe first line of the input contains the number of test cases. Each test case consists of a single line containing the string.\\n\\nOUTPUT :\\noutput the string with the words swapped as stated above.\\n\\nCONSTRAINTS :\\n|string length| ≤ 100000\\nstring contains english alphabets and spaces\\n\\nSAMPLE INPUT\\n1\\r\\nhello world\\n\\nSAMPLE OUTPUT\\nworld hello\\nUsing python can you solve the prior task?\",\"targets\":\"'''\\n# Read input from stdin and provide input before running code\\n\\nname = raw_input('What is your name?\\\\n')\\nprint 'Hi, %s.' % name\\n'''\\nt = input()\\nwhile(t>0):\\n\\ts = map(str,raw_input().split(\\\" \\\"))\\n\\tl = len(s)\\n\\tk={}\\n\\tc=0\\n\\tc_l=l-1\\n\\twhile c_l >=0 :\\n\\t\\tk[c]=s[c_l]\\n\\t\\tc+=1\\n\\t\\tc_l-=1\\n\\trev=\\\"\\\"\\n\\tfor i in range(l):\\n\\t\\trev += k[i]\\n\\t\\trev+=' '\\n\\t\\tl-=1\\n\\tt=t-1\\n\\tprint rev\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alice has recently received an array a_1, a_2, ..., a_n for her birthday! She is very proud of her array, and when she showed her friend Bob the array, he was very happy with her present too!\\n\\nHowever, soon Bob became curious, and as any sane friend would do, asked Alice to perform q operations of two types on her array:\\n\\n * 1 x y: update the element a_x to y (set a_x = y). \\n * 2 l r: calculate how many non-decreasing subarrays exist within the subarray [a_l, a_{l+1}, ..., a_r]. More formally, count the number of pairs of integers (p,q) such that l ≤ p ≤ q ≤ r and a_p ≤ a_{p+1} ≤ ... ≤ a_{q-1} ≤ a_q. \\n\\n\\n\\nHelp Alice answer Bob's queries!\\n\\nInput\\n\\nThe first line contains two integers n and q (1 ≤ n, q ≤ 2 ⋅ 10^5) — the size of the array, and the number of queries, respectively.\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — the elements of Alice's array.\\n\\nThe next q lines consist of three integers each. The first integer of the i-th line is t_i, the operation being performed on the i-th step (t_i = 1 or t_i = 2).\\n\\nIf t_i = 1, the next two integers are x_i and y_i (1 ≤ x_i ≤ n; 1 ≤ y_i ≤ 10^9), updating the element at position x_i to y_i (setting a_{x_i} = y_i).\\n\\nIf t_i = 2, the next two integers are l_i and r_i (1 ≤ l_i ≤ r_i ≤ n), the two indices Bob asks Alice about for the i-th query.\\n\\nIt's guaranteed that there is at least one operation of the second type.\\n\\nOutput\\n\\nFor each query of type 2, print a single integer, the answer to the query.\\n\\nExample\\n\\nInput\\n\\n\\n5 6\\n3 1 4 1 5\\n2 2 5\\n2 1 3\\n1 4 4\\n2 2 5\\n1 2 6\\n2 2 5\\n\\n\\nOutput\\n\\n\\n6\\n4\\n10\\n7\\n\\nNote\\n\\nFor the first query, l = 2 and r = 5, and the non-decreasing subarrays [p,q] are [2,2], [3,3], [4,4], [5,5], [2,3] and [4,5].\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nlong long int gcd(long long int a, long long int b) {\\n if (!b)\\n return a;\\n else\\n return gcd(b, a % b);\\n}\\nstruct node {\\n long long int sum = 0;\\n node(long long int a) : sum(a) {}\\n};\\nclass pointseg {\\n private:\\n int n;\\n vector t;\\n vector a;\\n void upd(int v, int tl, int tr, int pos, node val) {\\n if (tl == tr) {\\n t[v] = val;\\n return;\\n }\\n int tm = (tl + tr) \\/ 2;\\n if (pos <= tm)\\n upd(2 * v, tl, tm, pos, val);\\n else\\n upd(2 * v + 1, tm + 1, tr, pos, val);\\n t[v] = merge(t[2 * v], t[2 * v + 1]);\\n }\\n node query(int v, int l, int r, int tl, int tr) {\\n if (l > r) return node(0);\\n if (l == tl && r == tr) {\\n return t[v];\\n }\\n int tm = (tl + tr) \\/ 2;\\n return merge(query(2 * v, l, min(r, tm), tl, tm),\\n query(2 * v + 1, max(l, tm + 1), r, tm + 1, tr));\\n }\\n void build(int v, int tl, int tr) {\\n if (tl == tr) {\\n t[v] = a[tl];\\n return;\\n }\\n int tm = (tl + tr) \\/ 2;\\n build(2 * v, tl, tm);\\n build(2 * v + 1, tm + 1, tr);\\n t[v] = merge(t[2 * v], t[2 * v + 1]);\\n }\\n\\n public:\\n node merge(node a, node b) { return node(a.sum + b.sum); }\\n void upd(int pos, node val) { upd(1, 1, n, pos, val); }\\n node query(int l, int r) { return query(1, l, r, 1, n); }\\n void build() { build(1, 1, n); }\\n pointseg(int _n, vector _a = {}) {\\n n = _n;\\n t.assign(4 * n, node(0));\\n a = _a;\\n }\\n pointseg() {}\\n} s;\\nlong long int eval(long long int x) { return x * (x + 1) \\/ 2; }\\nset pos;\\nvoid change(int x) {\\n auto it = pos.upper_bound(x);\\n auto it2 = it;\\n it2--;\\n if (it != pos.end()) s.upd(*it, eval(*it - *it2));\\n it = pos.lower_bound(x);\\n it2 = it;\\n it2--;\\n s.upd(*it, eval(*it - *it2));\\n}\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n int n, q;\\n cin >> n >> q;\\n vector a(n + 2);\\n for (int i = 1; i <= n; i++) cin >> a[i];\\n a[n + 1] = -(long long int)(1e18);\\n int last = 0;\\n pos.insert(0);\\n s = pointseg(n + 1);\\n for...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in PYTHON?\\nYou 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\":\"# Time: O(n)\\n# Space: O(n)\\n\\nfrom itertools import islice, izip\\n\\ndef solution():\\n keyboard, s = [raw_input().strip() for _ in xrange(2)]\\n idx = {c:i for i, c in enumerate(keyboard)}\\n return sum(abs(idx[x]-idx[y]) for x, y in izip(islice(s, 1, len(s)), islice(s, 0, len(s)-1)))\\n\\nfor case in xrange(input()):\\n print '%s' % solution()\",\"language\":\"python\",\"split\":\"test\",\"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.\",\"targets\":\"import sys\\ninput=sys.stdin.readline\\nI = lambda : list(map(int,input().split()))\\n\\nt,=I()\\nfor _ in range(t):\\n\\tn, = I()\\n\\ta = n\\/\\/2\\n\\tb = n\\/\\/2\\n\\tif n%2:\\n\\t\\tn-=1\\n\\t\\tif (n\\/\\/2)%2:\\n\\t\\t\\ta -= 2\\n\\t\\t\\tb += 2\\n\\t\\telse:\\n\\t\\t\\ta -= 1\\n\\t\\t\\tb += 1\\n\\telse:\\n\\t\\tb-=1\\n\\tc=1\\n\\tprint(a,b,c)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"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.\\n# You\",\"targets\":\"r code here\\n#!\\/usr\\/bin\\/env python\\n# from __future__ import division, print_function\\nimport math\\nimport os\\nimport sys\\n# from fractions import *\\nfrom sys import *\\nfrom decimal import *\\nfrom io import BytesIO, IOBase\\nimport threading\\nfrom itertools import *\\nfrom collections import *\\nfrom array import *\\nimport random\\nM = 10 ** 9 + 7\\nimport heapq\\nimport bisect\\nfrom functools import lru_cache\\nfrom queue import PriorityQueue\\nBUFSIZE = 8192\\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...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"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.\",\"targets\":\"#include \\nusing namespace std;\\nconst long long int MOD = ((1e9) + 7);\\nconst long long int INF = 1e18;\\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}\\nint main() {\\n ios::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n long long int n, m, k;\\n cin >> n >> m >> k;\\n vector> a(n + 2, (vector(m + 2, 0)));\\n for (long long int i = 1; i <= n; i++) {\\n for (long long int j = 1; j <= m; j++) {\\n cin >> a[i][j];\\n }\\n }\\n for (long long int i = 1; i <= n; i++) {\\n for (long long int j = 1; j < m; j++) {\\n if (a[i][j] == 1 && a[i][j + 1] == 3) {\\n a[i][j] = 2;\\n a[i][j + 1] = 2;\\n }\\n }\\n }\\n while (k--) {\\n long long int x;\\n cin >> x;\\n long long int p1 = 1;\\n long long int p2 = x;\\n while (a[p1][p2] != 0 && p2 > 0 && p2 <= m) {\\n if (a[p1][p2] == 2)\\n p1++;\\n else if (a[p1][p2] == 1) {\\n a[p1][p2] = 2;\\n p2++;\\n } else {\\n a[p1][p2] = 2;\\n p2--;\\n }\\n }\\n cout << p2 << \\\"...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"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;\\nconst long long mod = 1e9 + 7;\\nint main(void) {\\n long long n, t;\\n cin >> t;\\n while (t--) {\\n cin >> n;\\n long long sum = 1;\\n long long i;\\n for (i = 1; i <= 2 * n; i++) {\\n sum = sum * i % mod;\\n if (i == 2) sum \\/= 2;\\n }\\n printf(\\\"%lld\\\\n\\\", sum);\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"In ABBYY a wonderful Smart Beaver lives. This time, he began to study history. When he read about the Roman Empire, he became interested in the life of merchants.\\n\\nThe Roman Empire consisted of n cities numbered from 1 to n. It also had m bidirectional roads numbered from 1 to m. Each road connected two different cities. Any two cities were connected by no more than one road.\\n\\nWe say that there is a path between cities c1 and c2 if there exists a finite sequence of cities t1, t2, ..., tp (p ≥ 1) such that:\\n\\n * t1 = c1\\n * tp = c2\\n * for any i (1 ≤ i < p), cities ti and ti + 1 are connected by a road \\n\\n\\n\\nWe know that there existed a path between any two cities in the Roman Empire.\\n\\nIn the Empire k merchants lived numbered from 1 to k. For each merchant we know a pair of numbers si and li, where si is the number of the city where this merchant's warehouse is, and li is the number of the city where his shop is. The shop and the warehouse could be located in different cities, so the merchants had to deliver goods from the warehouse to the shop.\\n\\nLet's call a road important for the merchant if its destruction threatens to ruin the merchant, that is, without this road there is no path from the merchant's warehouse to his shop. Merchants in the Roman Empire are very greedy, so each merchant pays a tax (1 dinar) only for those roads which are important for him. In other words, each merchant pays di dinars of tax, where di (di ≥ 0) is the number of roads important for the i-th merchant.\\n\\nThe tax collection day came in the Empire. The Smart Beaver from ABBYY is very curious by nature, so he decided to count how many dinars each merchant had paid that day. And now he needs your help.\\n\\nInput\\n\\nThe first input line contains two integers n and m, separated by a space, n is the number of cities, and m is the number of roads in the empire.\\n\\nThe following m lines contain pairs of integers ai, bi (1 ≤ ai, bi ≤ n, ai ≠ bi), separated by a space — the numbers of cities connected by the i-th road. It is guaranteed that any two...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nclass ufds {\\n private:\\n vector parent;\\n vector size;\\n int qty_disjoint_sets;\\n\\n public:\\n ufds() {}\\n ufds(int N) {\\n parent.resize(N);\\n size.assign(N, 1);\\n qty_disjoint_sets = N;\\n for (int n = 0; n < N; n++) parent[n] = n;\\n }\\n int find_set(int n) {\\n if (parent[n] == n) return n;\\n return parent[n] = find_set(parent[n]);\\n }\\n bool is_same_set(int n, int m) { return find_set(n) == find_set(m); }\\n void union_sets(int n, int m) {\\n int nId = find_set(n);\\n int mId = find_set(m);\\n if (!is_same_set(nId, mId)) {\\n if (size[nId] > size[mId]) swap(nId, mId);\\n parent[nId] = mId;\\n size[mId] += size[nId];\\n qty_disjoint_sets--;\\n }\\n }\\n int set_size(int n) { return size[find_set(n)]; }\\n int count() { return qty_disjoint_sets; }\\n};\\nclass sparse_table {\\n private:\\n vector A;\\n int N;\\n vector> table;\\n int range_combination(int i, int j) { return A[i] < A[j] ? i : j; }\\n void build() {\\n int P = (int)floor(log2(N));\\n table.assign(P + 1, vector(N));\\n for (int n = 0; n < N; n++) table[0][n] = n;\\n for (int p = 1; p <= P; p++)\\n for (int n = 0; n + (1 << (p)) <= N; n++) {\\n table[p][n] = range_combination(table[p - 1][n],\\n table[p - 1][n + (1 << (p - 1))]);\\n }\\n }\\n\\n public:\\n sparse_table() {}\\n sparse_table(vector const &A) {\\n this->A = A;\\n N = (int)A.size();\\n build();\\n }\\n int range_query(int l, int r) {\\n int size = r - l + 1;\\n int p = (int)floor(log2(size));\\n return range_combination(table[p][l], table[p][r - (1 << (p)) + 1]);\\n }\\n};\\nclass lca {\\n private:\\n vector> adj_list;\\n int V;\\n int e;\\n vector tour_depth;\\n vector tour_vertex;\\n vector depth;\\n vector last_e;\\n vector seen;\\n sparse_table st;\\n void process(int u, int u_depth) {\\n tour_vertex[e] = u;\\n tour_depth[e] = u_depth;\\n last_e[u] = e++;\\n }\\n void dfs(int u, int u_depth = 0) {\\n seen[u] = true;\\n ...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Arkady has got an infinite plane painted in color 0. Then he draws n rectangles filled with paint with sides parallel to the Cartesian coordinate axes, one after another. The color of the i-th rectangle is i (rectangles are enumerated from 1 to n in the order he draws them). It is possible that new rectangles cover some of the previous ones completely or partially.\\n\\nCount the number of different colors on the plane after Arkady draws all the rectangles.\\n\\nInput\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 100 000) — the number of rectangles.\\n\\nThe i-th of the next n lines contains 4 integers x_1, y_1, x_2 and y_2 (-10^9 ≤ x_1 < x_2 ≤ 10^9, -10^9 ≤ y_1 < y_2 ≤ 10^9) — the coordinates of corners of the i-th rectangle.\\n\\nOutput\\n\\nIn the single line print the number of different colors in the plane, including color 0.\\n\\nExamples\\n\\nInput\\n\\n5\\n-1 -1 1 1\\n-4 0 0 4\\n0 0 4 4\\n-4 -4 0 0\\n0 -4 4 0\\n\\n\\nOutput\\n\\n5\\n\\nInput\\n\\n4\\n0 0 4 4\\n-4 -4 0 0\\n0 -4 4 0\\n-2 -4 2 4\\n\\n\\nOutput\\n\\n5\\n\\nNote\\n\\n That's how the plane looks in the first sample\\n\\n That's how the plane looks in the second sample\\n\\n0 = white, 1 = cyan, 2 = blue, 3 = purple, 4 = yellow, 5 = red. \\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\ntemplate \\ninline void read(_T &f) {\\n f = 0;\\n _T fu = 1;\\n char c = getchar();\\n while (c < '0' || c > '9') {\\n if (c == '-') {\\n fu = -1;\\n }\\n c = getchar();\\n }\\n while (c >= '0' && c <= '9') {\\n f = (f << 3) + (f << 1) + (c & 15);\\n c = getchar();\\n }\\n f *= fu;\\n}\\ntemplate \\nvoid print(T x) {\\n if (x < 0) putchar('-'), x = -x;\\n if (x < 10)\\n putchar(x + 48);\\n else\\n print(x \\/ 10), putchar(x % 10 + 48);\\n}\\ntemplate \\nvoid print(T x, char t) {\\n print(x);\\n putchar(t);\\n}\\nconst int N = 2e5 + 5;\\nstruct ele {\\n int lx, rx, ly, ry;\\n} a[N];\\nstruct event_t {\\n int t, l, r, id;\\n} q[N];\\nbool operator<(const event_t a, const event_t b) { return a.t < b.t; }\\nset col[N << 2];\\nint mx[N << 2], lim[N << 2], cando[N];\\nint bx[N], by[N];\\nint n, lenx, leny, tot, ans;\\nvoid update(int u, int l, int r) {\\n if (l == r)\\n mx[u] = lim[u] = 0;\\n else {\\n mx[u] = max(mx[u << 1], mx[u << 1 | 1]);\\n lim[u] = min(lim[u << 1], lim[u << 1 | 1]);\\n }\\n if (!col[u].size()) return;\\n int id = *col[u].rbegin();\\n if (cando[id])\\n lim[u] = max(lim[u], id);\\n else\\n mx[u] = max(mx[u], id);\\n if (mx[u] < lim[u]) mx[u] = 0;\\n}\\nvoid change(int u, int L, int R, int l, int r, int x) {\\n if (l <= L && R <= r) {\\n if (x > 0) col[u].insert(x);\\n if (x < 0) col[u].erase(-x);\\n update(u, L, R);\\n return;\\n }\\n int mid = (L + R) >> 1;\\n if (mid >= l) change(u << 1, L, mid, l, r, x);\\n if (mid + 1 <= r) change(u << 1 | 1, mid + 1, R, l, r, x);\\n update(u, L, R);\\n}\\nint main() {\\n read(n);\\n for (int i = 1; i <= n; i++) {\\n read(a[i].lx);\\n read(a[i].ly);\\n read(a[i].rx);\\n read(a[i].ry);\\n bx[++lenx] = a[i].lx;\\n bx[++lenx] = a[i].rx;\\n by[++leny] = a[i].ly;\\n by[++leny] = a[i].ry;\\n }\\n sort(bx + 1, bx + lenx + 1);\\n lenx = unique(bx + 1, bx + lenx + 1) - bx - 1;\\n sort(by + 1, by + leny + 1);\\n leny = unique(by + 1, by + leny + 1) - by - 1;\\n for (int i = 1; i <= n; i++) {\\n a[i].lx = lower_bound(bx + 1, bx + lenx +...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Emuskald is addicted to Codeforces, and keeps refreshing the main page not to miss any changes in the \\\"recent actions\\\" list. He likes to read thread conversations where each thread consists of multiple messages.\\n\\nRecent actions shows a list of n different threads ordered by the time of the latest message in the thread. When a new message is posted in a thread that thread jumps on the top of the list. No two messages of different threads are ever posted at the same time.\\n\\nEmuskald has just finished reading all his opened threads and refreshes the main page for some more messages to feed his addiction. He notices that no new threads have appeared in the list and at the i-th place in the list there is a thread that was at the ai-th place before the refresh. He doesn't want to waste any time reading old messages so he wants to open only threads with new messages.\\n\\nHelp Emuskald find out the number of threads that surely have new messages. A thread x surely has a new message if there is no such sequence of thread updates (posting messages) that both conditions hold: \\n\\n 1. thread x is not updated (it has no new messages); \\n 2. the list order 1, 2, ..., n changes to a1, a2, ..., an. \\n\\nInput\\n\\nThe first line of input contains an integer n, the number of threads (1 ≤ n ≤ 105). The next line contains a list of n space-separated integers a1, a2, ..., an where ai (1 ≤ ai ≤ n) is the old position of the i-th thread in the new list. It is guaranteed that all of the ai are distinct.\\n\\nOutput\\n\\nOutput a single integer — the number of threads that surely contain a new message.\\n\\nExamples\\n\\nInput\\n\\n5\\n5 2 1 3 4\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n3\\n1 2 3\\n\\n\\nOutput\\n\\n0\\n\\n\\nInput\\n\\n4\\n4 3 2 1\\n\\n\\nOutput\\n\\n3\\n\\nNote\\n\\nIn the first test case, threads 2 and 5 are placed before the thread 1, so these threads must contain new messages. Threads 1, 3 and 4 may contain no new messages, if only threads 2 and 5 have new messages.\\n\\nIn the second test case, there may be no new messages at all, since the thread order hasn't changed.\\n\\nIn the third test case, only thread 1...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int n;\\n scanf(\\\"%d\\\", &n);\\n int ant;\\n scanf(\\\"%d\\\", &ant);\\n int max_mes = 0;\\n for (int i = 1; i < n; i++) {\\n int aux;\\n scanf(\\\"%d\\\", &aux);\\n if (aux < ant) max_mes = i;\\n ant = aux;\\n }\\n printf(\\\"%d\\\\n\\\", max_mes);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A revolution took place on the Buka Island. New government replaced the old one. The new government includes n parties and each of them is entitled to some part of the island according to their contribution to the revolution. However, they can't divide the island.\\n\\nThe island can be conventionally represented as two rectangles a × b and c × d unit squares in size correspondingly. The rectangles are located close to each other. At that, one of the sides with the length of a and one of the sides with the length of c lie on one line. You can see this in more details on the picture.\\n\\n\\n\\nThe i-th party is entitled to a part of the island equal to xi unit squares. Every such part should fully cover several squares of the island (it is not allowed to cover the squares partially) and be a connected figure. A \\\"connected figure\\\" presupposes that from any square of this party one can move to any other square of the same party moving through edge-adjacent squares also belonging to that party.\\n\\nYour task is to divide the island between parties.\\n\\nInput\\n\\nThe first line contains 5 space-separated integers — a, b, c, d and n (1 ≤ a, b, c, d ≤ 50, b ≠ d, 1 ≤ n ≤ 26). The second line contains n space-separated numbers. The i-th of them is equal to number xi (1 ≤ xi ≤ a × b + c × d). It is guaranteed that .\\n\\nOutput\\n\\nIf dividing the island between parties in the required manner is impossible, print \\\"NO\\\" (without the quotes). Otherwise, print \\\"YES\\\" (also without the quotes) and, starting from the next line, print max(b, d) lines each containing a + c characters. To mark what square should belong to what party, use lowercase Latin letters. For the party that is first in order in the input data, use \\\"a\\\", for the second one use \\\"b\\\" and so on. Use \\\".\\\" for the squares that belong to the sea. The first symbol of the second line of the output data should correspond to the square that belongs to the rectangle a × b. The last symbol of the second line should correspond to the square that belongs to the rectangle c × d.\\n\\nIf...\\nimpor\",\"targets\":\"t java.util.Map;\\nimport java.util.Scanner;\\n\\npublic class Main {\\n\\n\\n public static void main(String[] args) {\\n Scanner sc = new Scanner(System.in);\\n int b = sc.nextInt();\\n int a= sc.nextInt();\\n int d = sc.nextInt();\\n int c = sc.nextInt();\\n int n = sc.nextInt();\\n int [] arr = new int[n];\\n int sum = 0;\\n for(int i=0 ; i a*b + c*d) {\\n System.out.println(\\\"NO\\\");\\n return;\\n }\\n\\n char [][] rec1 = new char[a][b];\\n char [][] rec2 = new char[c][d];\\n\\n\\n System.out.println(\\\"YES\\\");\\n solve(rec1,rec2,arr);\\n for(int i = 0; i < Math.max(a,c); i++){\\n for(int j=0 ; j\\nusing namespace std;\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(nullptr);\\n int n;\\n cin >> n;\\n vector v(n);\\n for (int i = 0; i < n; i += 1) cin >> v[i];\\n vector w;\\n int cw = 0, fl = 0;\\n for (int i = 0; i < n; i += 1) {\\n if (v[i] == 0 && fl == 0) {\\n if (i != 0) w.emplace_back(cw);\\n cw = 1;\\n fl = 1;\\n } else if (v[i] == 0 && fl == 1)\\n cw++;\\n else if (v[i] == 1 && fl == 1) {\\n w.emplace_back(cw);\\n cw = 1;\\n fl = 0;\\n } else if (v[i] == 1 && fl == 0)\\n cw++;\\n }\\n w.emplace_back(cw);\\n unordered_set s;\\n for (int i = 0; i < (int)w.size(); i += 1) s.insert(w[i]);\\n cout << (s.size() == 1 ? \\\"YES\\\" : \\\"NO\\\");\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"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;...\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nusing ll = long long;\\nconst ll mod = 998244353;\\ninline namespace {\\ntemplate \\ninline B slow_pow(const B &b, const E &e) {\\n assert(e >= 0);\\n B res = 1;\\n for (int q = 0; q < e; q++) res *= b;\\n return res;\\n}\\ntemplate \\ninline B bin_pow(const B &b, const E &e) {\\n assert(e >= 0);\\n B res = 1;\\n B a = b;\\n for (E q = e; q; q >>= 1) {\\n if (q & 1) res *= a;\\n a *= a;\\n }\\n return res;\\n}\\ntemplate \\ninline B mod_pow(const B &b, const E &e) {\\n assert(e >= 0);\\n B res = 1;\\n B a = b;\\n for (E q = e; q; q >>= 1) {\\n if (q & 1) res = (res * a) % mod;\\n a = (a * a) % mod;\\n }\\n return res;\\n}\\n} \\/\\/ namespace\\nll fact[200001];\\nvoid pre() {\\n fact[0] = 1;\\n for (ll x = 1; x <= 200000; x++) fact[x] = (fact[x - 1] * x) % mod;\\n}\\nll mod_inv(const ll &x) { return mod_pow(x, mod - 2); }\\nll choose(const int &n, const int &k) {\\n return (((fact[n] * mod_inv(fact[k])) % mod) * mod_inv(fact[n - k])) % mod;\\n}\\nvoid solve() {\\n int n;\\n cin >> n;\\n vector a(n);\\n for (int i = 0; i < n; i++) cin >> a[i];\\n sort(a.begin(), a.end());\\n ll ans;\\n if (a[n - 1] == a[n - 2])\\n ans = fact[n];\\n else if (a[n - 1] == a[n - 2] + 1) {\\n int cnt = 0;\\n ans = 0;\\n for (int i = 0; i < n - 1; i++) {\\n if (a[i] + 1 == a[n - 1]) cnt++;\\n }\\n ans = (((choose(n, cnt + 1) * (((fact[cnt + 1] - fact[cnt]) + mod) % mod)) %\\n mod) *\\n fact[n - cnt - 1]) %\\n mod;\\n } else\\n ans = 0;\\n cout << ans << '\\\\n';\\n}\\nint main() {\\n ios_base::sync_with_stdio(false), cin.tie(NULL);\\n pre();\\n int T = 1;\\n cin >> T;\\n while (T--) solve();\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"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...\\nimpor\",\"targets\":\"t sys\\n\\ninput = sys.stdin.buffer.readline\\n\\nn, m = [int(x) for x in input().split()]\\nindeg = [0]*(n+1) \\nsurvi = n\\nfor a in range(m):\\n u, v = [int(x) for x in input().split()]\\n mi = min(u, v)\\n if indeg[mi] == 0:\\n survi-=1\\n indeg[mi]+=1\\n\\n\\nq = int(input())\\nfor a in range(q):\\n inp = [int(x) for x in input().split()]\\n if inp[0] == 3:\\n print(survi)\\n elif inp[0] == 1:\\n u, v = inp[1], inp[2]\\n mi = min(u, v)\\n if indeg[mi] == 0:\\n survi-=1\\n indeg[mi]+=1\\n else:\\n u, v = inp[1], inp[2]\\n mi = min(u, v)\\n indeg[mi]-=1\\n if indeg[mi] == 0:\\n survi+=1\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"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...\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n ios::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n ;\\n long long t;\\n cin >> t;\\n while (t--) {\\n string s;\\n cin >> s;\\n string k = \\\"#\\\" + s;\\n long long ans = 10;\\n long long n = s.length();\\n for (long long i = 1; i <= n; i++) {\\n long long goala = 0;\\n long long goalb = 0;\\n long long rema = 0;\\n long long remb = 0;\\n long long goalaa = 0;\\n long long goalbb = 0;\\n for (int j = 1; j <= i; j++) {\\n if (j % 2) {\\n if (k[j] == '1' || k[j] == '?') {\\n goala++;\\n }\\n if (k[j] == '1') {\\n goalaa++;\\n }\\n } else {\\n if (k[j] == '1') {\\n goalb++;\\n }\\n if (k[j] == '1' || k[j] == '?') {\\n goalbb++;\\n }\\n }\\n }\\n for (int j = i + 1; j <= n; j++) {\\n if (j % 2) {\\n rema++;\\n } else {\\n remb++;\\n }\\n }\\n if (goala > remb + goalb) {\\n ans = i;\\n break;\\n } else if (goalbb > rema + goalaa) {\\n ans = i;\\n break;\\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\":\"PYTHON3 solution for \\\"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\":\"from math import ceil, pow\\n\\n\\ntests = int(input())\\nfor testcase in range(tests):\\n n, k = map(int, input().split())\\n a = list(map(int, input().split()))\\n # s = list(input())\\n a.sort()\\n ans = 0\\n c = 0\\n for i, e in enumerate(a):\\n \\n if i==n-1:\\n ans += int(pow(10, a[i])*(k-c+1))\\n print(int((ans)))\\n break\\n \\n u = pow(10,(a[i+1]-a[i]))\\n if k-c < u-1:\\n ans += int(pow(10, a[i])*(k-c))\\n print(int((ans+pow(10, a[i]))))\\n break\\n elif k-c == u-1:\\n ans += int(pow(10, a[i])*(k-c))\\n print(int((ans+pow(10, a[i+1]))))\\n break\\n else:\\n ans += int(pow(10, a[i])*(u-1))\\n c+=u-1\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"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...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint32_t main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n long long t1;\\n t1 = 1;\\n cin >> t1;\\n while (t1--) {\\n string s, t;\\n cin >> s >> t;\\n long long n = s.length();\\n long long m = t.length();\\n if (n < m) {\\n cout << \\\"NO\\\"\\n << \\\"\\\\n\\\";\\n continue;\\n }\\n if (n == m) {\\n if (s == t) {\\n cout << \\\"YES\\\"\\n << \\\"\\\\n\\\";\\n } else {\\n cout << \\\"NO\\\"\\n << \\\"\\\\n\\\";\\n }\\n continue;\\n }\\n long long i = n - 1;\\n long long j = m - 1;\\n while (i >= 0 && j >= 0) {\\n if (s[i] == t[j]) {\\n --i;\\n --j;\\n } else {\\n --i;\\n --i;\\n }\\n }\\n if (j == -1) {\\n cout << \\\"YES\\\"\\n << \\\"\\\\n\\\";\\n } else {\\n cout << \\\"NO\\\"\\n << \\\"\\\\n\\\";\\n }\\n }\\n return 0;\\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.\\nUsing java can you solve the prior task?\",\"targets\":\"import java.io.*;\\nimport java.lang.*;\\nimport java.util.*;\\n\\npublic class GFG {\\n \\n\\tpublic static void main (String[] args) throws Exception {\\n\\t Scanner sc = new Scanner(System.in);\\n\\t int t = sc.nextInt();\\n\\t \\n\\t while(t!=0){\\n\\t t--;\\n\\t String s = sc.next();\\n\\t if(!s.contains(\\\"0\\\"))System.out.println(\\\"0\\\");\\n\\t else if(!s.contains(\\\"1\\\"))System.out.println(\\\"1\\\");else{\\n\\t if(s.contains(\\\"10\\\") && s.contains(\\\"01\\\")){\\n\\t int i = s.indexOf('0');\\n\\t if(s.substring(i+1).contains(\\\"10\\\"))System.out.println(\\\"2\\\");\\n\\t else System.out.println(\\\"1\\\");\\n\\t }\\n\\t else System.out.println(\\\"1\\\");\\n\\t }\\n\\t }\\n\\t}\\n\\t\\n\\t\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string \\\"aabaabaabaab\\\" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.\\n\\nYou are given a string s, consisting of lowercase English letters and a positive integer k. Your task is to reorder the letters in the string s in such a way that the resulting string is a k-string.\\n\\nInput\\n\\nThe first input line contains integer k (1 ≤ k ≤ 1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1 ≤ |s| ≤ 1000, where |s| is the length of string s.\\n\\nOutput\\n\\nRearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them.\\n\\nIf the solution doesn't exist, print \\\"-1\\\" (without quotes).\\n\\nExamples\\n\\nInput\\n\\n2\\naazz\\n\\n\\nOutput\\n\\nazaz\\n\\n\\nInput\\n\\n3\\nabcabcabz\\n\\n\\nOutput\\n\\n-1\",\"targets\":\"from __future__ import division, print_function\\n\\n\\ndef main():\\n # Template 1.0\\n import sys, re\\n from collections import deque, defaultdict, Counter, OrderedDict\\n from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians\\n from heapq import heappush, heappop, heapify, nlargest, nsmallest\\n def STR():\\n return list(input())\\n\\n def INT():\\n return int(input())\\n\\n def MAP():\\n return map(int, input().split())\\n\\n def LIST():\\n return list(map(int, input().split()))\\n\\n def list2d(a, b, c):\\n return [[c] * b for i in range(a)]\\n\\n def sortListWithIndex(listOfTuples, idx):\\n return (sorted(listOfTuples, key=lambda x: x[idx]))\\n\\n def sortDictWithVal(passedDic):\\n temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))[::-1]\\n toret = {}\\n for tup in temp:\\n toret[tup[0]] = tup[1]\\n return toret\\n\\n def sortDictWithKey(passedDic):\\n return dict(OrderedDict(sorted(passedDic.items())))\\n\\n INF = float('inf')\\n mod = 10 ** 9 + 7\\n\\n\\n k = INT()\\n\\n s = input()\\n\\n n = len(s)\\n\\n if(n%k!=0):\\n print(-1)\\n else:\\n occ = defaultdict(int)\\n for ch in s:\\n occ[ch]+=1\\n ans = 0\\n for key in occ:\\n if(occ[key]%k!=0):\\n ans = -1\\n break\\n if(ans!=-1):\\n ANS = [\\\"\\\"]*k\\n for key in occ:\\n temp = occ[key]\\/\\/k\\n for i in range(k):\\n ANS[i]+=str(key)*temp\\n print(\\\"\\\".join(ANS))\\n else:\\n print(-1)\\n\\n\\n######## Python 2 and 3 footer by Pajenegod and c1729\\n\\n# Note because cf runs old PyPy3 version which doesn't have the sped up\\n# unicode strings, PyPy3 strings will many times be slower than pypy2.\\n# There is a way to get around this by using binary strings in PyPy3\\n# but its syntax is different which makes it kind of a mess to use.\\n\\n# So on cf, use PyPy2 for best string performance.\\n\\npy2 = round(0.5)\\nif py2:\\n from future_builtins import...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nConsider 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...\",\"targets\":\"#include \\nusing namespace std;\\nconst int dx[4] = {-1, 0, 0, 1};\\nconst int dy[4] = {0, -1, 1, 0};\\nconst int maxn = 150005;\\nconst int maxm = 1000006;\\nconst int oo = 1000000009;\\nconst int mod = 14062008;\\nconst long long base = 1000000000000000000;\\nint n, q, maxa, a[maxn], p[maxm], f[maxm];\\nmap > m;\\nint root(int x) { return (f[x] < 0 ? x : f[x] = root(f[x])); }\\nvoid merge(int x, int y) {\\n x = root(x);\\n y = root(y);\\n if (x != y) {\\n if (f[y] < f[x]) swap(x, y);\\n f[x] += f[y];\\n f[y] = x;\\n }\\n}\\nvector factor(int a) {\\n vector res(0);\\n while (a > 1) {\\n res.push_back(p[a]);\\n while (p[a] == res.back()) a \\/= p[a];\\n }\\n return res;\\n}\\nbool check(int x, int y) {\\n vector facX = factor(x);\\n vector facY = factor(y);\\n for (int i : facX)\\n for (int j : facY)\\n if (m[root(i)][root(j)]) return true;\\n return false;\\n}\\nint main() {\\n ios::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 >> a[i];\\n maxa = (maxa > a[i] + 1 ? maxa : a[i] + 1);\\n }\\n for (int i = 2; i * i <= maxa; ++i)\\n if (p[i] == 0)\\n for (int j = i * i; j <= maxa; j += i)\\n if (p[j] == 0) p[j] = i;\\n for (int i = 1; i <= maxa; ++i) {\\n if (p[i] == 0) p[i] = i;\\n f[i] = -1;\\n }\\n for (int i = 1; i <= n; ++i) {\\n vector facA = factor(a[i]);\\n merge(a[i], facA[0]);\\n for (int i = 0; i <= int(facA.size() - 2); ++i) merge(facA[i], facA[i + 1]);\\n }\\n for (int i = 1; i <= n; ++i) {\\n vector facA = factor(a[i]);\\n vector facB = factor(a[i] + 1);\\n for (int i : facA)\\n for (int j : facB)\\n if (i != j) {\\n int rootI = root(i);\\n int rootJ = root(j);\\n m[rootI][rootJ] = true;\\n m[rootJ][rootI] = true;\\n }\\n for (int i = 0; i <= int(facB.size() - 2); ++i)\\n for (int j = i + 1; j <= int(facB.size() - 1); ++j) {\\n int rootI = root(facB[i]);\\n int rootJ = root(facB[j]);\\n m[rootI][rootJ] = true;\\n m[rootJ][rootI] =...\",\"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...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint t;\\nint d[1000010];\\nint main() {\\n cin >> t;\\n while (t--) {\\n int n, m = -(1 << 30);\\n cin >> n;\\n for (int i = 1; i <= n; i++) {\\n cin >> d[i];\\n }\\n sort(d + 1, d + n + 1);\\n for (int i = n; i >= 1; i--) {\\n d[i] -= d[i - 1];\\n m = max(m, d[i]);\\n }\\n cout << m << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"One day, at the \\\"Russian Code Cup\\\" event it was decided to play football as an out of competition event. All participants was divided into n teams and played several matches, two teams could not play against each other more than once.\\n\\nThe appointed Judge was the most experienced member — Pavel. But since he was the wisest of all, he soon got bored of the game and fell asleep. Waking up, he discovered that the tournament is over and the teams want to know the results of all the matches.\\n\\nPavel didn't want anyone to discover about him sleeping and not keeping an eye on the results, so he decided to recover the results of all games. To do this, he asked all the teams and learned that the real winner was friendship, that is, each team beat the other teams exactly k times. Help Pavel come up with chronology of the tournir that meets all the conditions, or otherwise report that there is no such table.\\n\\nInput\\n\\nThe first line contains two integers — n and k (1 ≤ n, k ≤ 1000).\\n\\nOutput\\n\\nIn the first line print an integer m — number of the played games. The following m lines should contain the information about all the matches, one match per line. The i-th line should contain two integers ai and bi (1 ≤ ai, bi ≤ n; ai ≠ bi). The numbers ai and bi mean, that in the i-th match the team with number ai won against the team with number bi. You can assume, that the teams are numbered from 1 to n.\\n\\nIf a tournir that meets the conditions of the problem does not exist, then print -1.\\n\\nExamples\\n\\nInput\\n\\n3 1\\n\\n\\nOutput\\n\\n3\\n1 2\\n2 3\\n3 1\\\":\",\"targets\":\"#include \\n#pragma GCC optimize(\\\"Ofast\\\")\\n#pragma GCC target(\\\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma\\\")\\n#pragma GCC optimize(\\\"unroll-loops\\\")\\nusing namespace std;\\nlong long int MOD = 1000000007;\\ndouble eps = 1e-12;\\nvoid solve();\\nlong long int gcd(long long int a, long long int b) {\\n if (a == 0) return b;\\n return gcd(b % a, a);\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n long long int t = 1;\\n while (t--) {\\n solve();\\n }\\n return 0;\\n}\\nvoid solve() {\\n long long int n, k;\\n cin >> n >> k;\\n if (n < 2 * k + 1) {\\n cout << -1 << endl;\\n return;\\n }\\n cout << n * k << endl;\\n for (int i = 0; i < n; i++) {\\n for (int j = 0; j < k; j++) {\\n int next = (i + j + 1) % n;\\n printf(\\\"%d %d\\\\n\\\", i + 1, next + 1);\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP 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\":\"#include \\nusing namespace std;\\nint n;\\nchar ch[100005];\\nvector pos[30];\\ntemplate \\nvoid Read(Azir &x) {\\n x = 0;\\n char ch = getchar();\\n int f = 1;\\n while (!isdigit(ch)) {\\n if (ch == '-') f = -f;\\n ch = getchar();\\n }\\n while (isdigit(ch)) {\\n x = (x << 1) + (x << 3) + (ch ^ 48);\\n ch = getchar();\\n }\\n x = x * f;\\n}\\ntemplate \\nvoid write(Azir x) {\\n if (x >= 10) write(x \\/ 10);\\n putchar((char)(x % 10 + '0'));\\n}\\ntemplate \\nvoid writeln(Azir x) {\\n write(x);\\n puts(\\\"\\\");\\n}\\nint main() {\\n int tmp;\\n scanf(\\\"%d\\\", &tmp);\\n while (tmp--) {\\n scanf(\\\"%d\\\", &n);\\n scanf(\\\"%s\\\", ch + 1);\\n bool flg = 0;\\n for (int i = 1; i <= 26; ++i) pos[i].clear();\\n for (int i = 1; i <= n; ++i) {\\n pos[ch[i] - 'a' + 1].push_back(i);\\n }\\n int mx = INT_MAX;\\n for (int i = 1; i <= 26; ++i) {\\n int l, r, cnt;\\n l = 1;\\n r = n;\\n cnt = 0;\\n while (l < r) {\\n if (ch[l] == ch[r]) {\\n --r;\\n ++l;\\n continue;\\n }\\n if (ch[l] - 'a' + 1 == i) {\\n ++cnt;\\n ++l;\\n continue;\\n }\\n if (ch[r] - 'a' + 1 == i) {\\n ++cnt;\\n --r;\\n continue;\\n }\\n if (ch[l] != ch[r]) {\\n cnt = INT_MAX;\\n break;\\n }\\n }\\n mx = min(mx, cnt);\\n }\\n if (mx != INT_MAX)\\n printf(\\\"%d\\\\n\\\", mx);\\n else\\n puts(\\\"-1\\\");\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"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.\",\"targets\":\"for _ in range(int(input())):\\n a, b, c, m = map(int, input().split())\\n a, b, c = sorted((a, b, c))\\n trans = min(c - b, m)\\n c -= trans\\n m -= trans\\n if m > 0:\\n trans = min((b - a) * 2, m)\\n m -= trans\\n b -= (trans + 1) \\/\\/ 2\\n c -= trans \\/\\/ 2\\n if m > 0:\\n trans = min(a + b + c, m)\\n m -= trans\\n a -= (trans + 2) \\/\\/ 3\\n b -= (trans + 1) \\/\\/ 3\\n c -= trans \\/\\/ 3\\n if a == 0 or a + b + 1 < c or m > 0:\\n print(\\\"NO\\\")\\n else:\\n print(\\\"YES\\\")\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"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.\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 2105;\\nconst long long mod = 998244353;\\nint n, T, x[N];\\nvoid solve() {\\n cin >> n;\\n for (int i = 1; i <= n; i++) cin >> x[i];\\n vector ans;\\n ans.clear();\\n for (int i = 1; i <= n; i++) {\\n if (x[i] % 2 != i % 2) {\\n cout << \\\"-1\\\\n\\\";\\n return;\\n }\\n }\\n cout << (n - 1) \\/ 2 * 5 << \\\"\\\\n\\\";\\n for (int i = n; i >= 2; i -= 2) {\\n int posx, posy;\\n for (int j = 1; j <= n; j++) {\\n if (x[j] == i) posx = j;\\n }\\n cout << posx << \\\" \\\";\\n reverse(x + 1, x + posx + 1);\\n for (int j = 1; j <= n; j++)\\n if (x[j] == i - 1) posy = j;\\n cout << posy - 1 << \\\" \\\" << posy + 1 << \\\" \\\" << 3 << \\\" \\\" << i << \\\" \\\";\\n reverse(x + 1, x + posy);\\n reverse(x + 1, x + posy + 2);\\n reverse(x + 1, x + 4);\\n reverse(x + 1, x + i + 1);\\n }\\n cout << \\\"\\\\n\\\";\\n}\\nsigned main() {\\n cin >> T;\\n while (T--) solve();\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Being stuck at home, Ray became extremely bored. To pass time, he asks Lord Omkar to use his time bending power: Infinity Clock! However, Lord Omkar will only listen to mortals who can solve the following problem:\\n\\nYou are given an array a of n integers. You are also given an integer k. Lord Omkar wants you to do k operations with this array.\\n\\nDefine one operation as the following: \\n\\n 1. Set d to be the maximum value of your array. \\n 2. For every i from 1 to n, replace a_{i} with d-a_{i}. \\n\\n\\n\\nThe goal is to predict the contents in the array after k operations. Please help Ray determine what the final sequence will look like!\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of cases t (1 ≤ t ≤ 100). Description of the test cases follows.\\n\\nThe first line of each test case contains two integers n and k (1 ≤ n ≤ 2 ⋅ 10^5, 1 ≤ k ≤ 10^{18}) – the length of your array and the number of operations to perform.\\n\\nThe second line of each test case contains n integers a_{1},a_{2},...,a_{n} (-10^9 ≤ a_{i} ≤ 10^9) – the initial contents of your array.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each case, print the final version of array a after k operations described above.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n2 1\\n-199 192\\n5 19\\n5 -1 4 2 0\\n1 2\\n69\\n\\n\\nOutput\\n\\n\\n391 0\\n0 6 1 3 5\\n0\\n\\nNote\\n\\nIn the first test case the array changes as follows:\\n\\n * Initially, the array is [-199, 192]. d = 192.\\n\\n * After the operation, the array becomes [d-(-199), d-192] = [391, 0].\",\"targets\":\"t = int(input())\\nfor _ in range(t):\\n n,k = map(int,input().split())\\n arr = list(map(int,input().split()))\\n mx = max(arr)\\n for i in range(n):\\n arr[i] = mx - arr[i]\\n mx = max(arr)\\n even = []\\n for i in range(n):\\n even.append(mx - arr[i])\\n odd = []\\n mx = max(even)\\n for i in range(n):\\n odd.append(mx - even[i])\\n if k%2:\\n print(*odd)\\n else:\\n print(*even)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nPolycarp is working on a new operating system called BerOS. He asks you to help with implementation of a file suggestion feature.\\n\\nThere are n files on hard drive and their names are f_1, f_2, ..., f_n. Any file name contains between 1 and 8 characters, inclusive. All file names are unique.\\n\\nThe file suggestion feature handles queries, each represented by a string s. For each query s it should count number of files containing s as a substring (i.e. some continuous segment of characters in a file name equals s) and suggest any such file name.\\n\\nFor example, if file names are \\\"read.me\\\", \\\"hosts\\\", \\\"ops\\\", and \\\"beros.18\\\", and the query is \\\"os\\\", the number of matched files is 2 (two file names contain \\\"os\\\" as a substring) and suggested file name can be either \\\"hosts\\\" or \\\"beros.18\\\".\\n\\nInput\\n\\nThe first line of the input contains integer n (1 ≤ n ≤ 10000) — the total number of files.\\n\\nThe following n lines contain file names, one per line. The i-th line contains f_i — the name of the i-th file. Each file name contains between 1 and 8 characters, inclusive. File names contain only lowercase Latin letters, digits and dot characters ('.'). Any sequence of valid characters can be a file name (for example, in BerOS \\\".\\\", \\\"..\\\" and \\\"...\\\" are valid file names). All file names are unique.\\n\\nThe following line contains integer q (1 ≤ q ≤ 50000) — the total number of queries.\\n\\nThe following q lines contain queries s_1, s_2, ..., s_q, one per line. Each s_j has length between 1 and 8 characters, inclusive. It contains only lowercase Latin letters, digits and dot characters ('.').\\n\\nOutput\\n\\nPrint q lines, one per query. The j-th line should contain the response on the j-th query — two values c_j and t_j, where\\n\\n * c_j is the number of matched files for the j-th query, \\n * t_j is the name of any file matched by the j-th query. If there is no such file, print a single character '-' instead. If there are multiple matched files, print any. \\n\\nExample\\n\\nInput\\n\\n4\\ntest\\ncontests\\ntest.\\n.test\\n6\\nts\\n.\\nst.\\n.test\\ncontes.\\nst\\n\\n\\nOutput\\n\\n1 contests\\n2...\",\"targets\":\"#include \\nstd::map c;\\nstd::map t;\\nint main(int argc, char *argv[]) {\\n std::ios::sync_with_stdio(0);\\n std::cin.tie(0);\\n std::cout.tie(0);\\n int n;\\n std::cin >> n;\\n for (int i = 0; i < n; i++) {\\n std::string f;\\n std::cin >> f;\\n int flen = f.length();\\n for (int i = 0; i < flen; i++) {\\n for (int j = 0; j < flen - i; j++) {\\n std::string fsub = f.substr(i, j + 1);\\n if (t[fsub] != f) {\\n t[fsub] = f;\\n c[fsub]++;\\n }\\n }\\n }\\n }\\n int q;\\n std::cin >> q;\\n for (int i = 0; i < q; i++) {\\n std::string s;\\n std::cin >> s;\\n std::cout << c[s] << \\\" \\\";\\n if (c[s] == 0) {\\n std::cout << \\\"-\\\" << std::endl;\\n } else {\\n std::cout << t[s] << std::endl;\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"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.\",\"targets\":\"#include \\nusing namespace std;\\nvoid _print(long long 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.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}\\ninline long long mod(long long x) {\\n return (x % 1000000007 + 1000000007) % 1000000007;\\n}\\ninline long long add(long long a, long long b) { return mod(mod(a) + mod(b)); }\\ninline long long sub(long long a, long long b) {\\n return mod(mod(a) - mod(b) + 1000000007);\\n}\\ninline long long mul(long long a, long long b) { return mod(mod(a) * mod(b)); }\\ninline long long power(long long a, long long p) {\\n long long r = 1;\\n while (p) {\\n if (p & 1) r = mul(r, a);\\n a = mul(a, a);\\n p >>= 1;\\n }\\n return r;\\n}\\ninline long long modInv(long long a) { return power(a, 1000000007 - 2); }\\ninline long long divi(long long a, long long b) { return mul(a, modInv(b)); }\\ninline long long fact(long long a) {\\n long long r = 1;\\n while (a) {\\n r = mul(r, a);\\n a--;\\n }\\n return r;\\n}\\ninline long long ncr(long long n, long long r) {\\n return mul(mul(fact(n), modInv(fact(n - r))), modInv(fact(r)));\\n}\\ninline long long gcd(long...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in PYTHON3?\\nAn 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= i:\\n return 0\\n while left + 1 < right:\\n m = (left + right) \\/\\/ 2\\n if portal[m][0] < i:\\n left = m\\n else:\\n right = m\\n return right\\n\\n\\nN = 998244353\\nn = int(input())\\nportal = []\\nfor _ in range(n):\\n portal.append(list(map(int, input().split())))\\nM = portal[-1][0] + 1\\nfor i in range(n):\\n portal[i].append(find(portal[i][1]))\\ntime = [0] * n\\nsum_time = [0] * (n + 1)\\nfor j in range(n):\\n time[j] = portal[j][0] - portal[j][1]\\n time[j] += sum_time[j] - sum_time[portal[j][3]]\\n time[j] %= N\\n sum_time[j + 1] = time[j] + sum_time[j]\\n sum_time[j + 1] %= N\\nt = portal[-1][0] + 1\\nfor i in range(n):\\n if portal[i][2]:\\n t += time[i]\\nprint(t % N)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"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\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\ntemplate \\nvoid chkMax(T &x, T y) {\\n if (y > x) x = y;\\n}\\ntemplate \\nvoid chkMin(T &x, T y) {\\n if (y < x) x = y;\\n}\\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') x = x * 10 + (s ^ 48), s = getchar();\\n x *= f;\\n}\\nconst int N = 1e6 + 5;\\nint n, a[N], p0[N];\\nvoid inline prework() {\\n int n = 1e6;\\n for (int i = 2; i <= n; i++) {\\n for (int j = i; j <= n; j += i)\\n if (!p0[j]) p0[j] = i;\\n }\\n}\\nvector > e[N];\\nchar g[N];\\nint s[N], top, sum[N];\\nvector > q[N];\\nvector > G;\\nvoid inline work(vector > &t) {\\n int m = t.size();\\n if (!m) return;\\n G.clear();\\n G.push_back(make_pair(0, 0));\\n for (int i = 0; i < m; i++) G.push_back(t[i]);\\n for (int i = 1; i <= m; i++) {\\n sum[i] = G[i].first + sum[i - 1];\\n }\\n top = 0;\\n for (int i = m; i >= 0; i--) {\\n while (top && sum[s[top]] >= sum[i]) top--;\\n if (s[top]) {\\n q[G[i].second + 1].push_back(make_pair(G[s[top]].second, 1));\\n if (i != m)\\n q[G[i + 1].second + 1].push_back(make_pair(G[s[top]].second, -1));\\n }\\n s[++top] = i;\\n }\\n}\\nmultiset S;\\nint main() {\\n prework();\\n read(n);\\n for (int i = 1; i <= n; i++) read(a[i]);\\n scanf(\\\"%s\\\", g + 1);\\n for (int i = 1; i <= n; i++) {\\n int x = a[i];\\n int w = g[i] == '*' ? 1 : -1;\\n while (x > 1) {\\n int v = p0[x], c = 0;\\n while (x % v == 0) x \\/= v, c++;\\n e[v].push_back(make_pair(w * c, i));\\n }\\n }\\n long long ans = 0;\\n for (int i = 1; i <= 1000000; i++) work(e[i]);\\n for (int i = 1; i <= n; i++) {\\n for (pair u : q[i]) {\\n if (u.second == 1)\\n S.insert(u.first);\\n else\\n S.erase(S.find(u.first));\\n }\\n int lim = n;\\n if (S.size()) lim = *S.begin() - 1;\\n if (i <= lim) ans += lim - i + 1;\\n }\\n printf(\\\"%lld\\\\n\\\", ans);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"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.\\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 b = False\\n k = sum(a)\\n for i in range(2,k\\/\\/2+1):\\n if k%i==0:\\n b = True\\n break\\n if b:\\n print(n)\\n for i in range(1,n+1):\\n print(i,end=' ')\\n else:\\n print(n-1)\\n for i in range(n):\\n if not b:\\n if a[i]%2==1:\\n b = True \\n else:\\n print(i+1,end = ' ')\\n else:\\n print(i+1,end = ' ')\\n print('')\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nLittle Petya very much likes rectangular tables that consist of characters \\\"0\\\" and \\\"1\\\". Recently he has received one such table as a gift from his mother. The table contained n rows and m columns. The rows are numbered from top to bottom from 1 to n, the columns are numbered from the left to the right from 1 to m. Petya immediately decided to find the longest cool cycle whatever it takes.\\n\\nA cycle is a sequence of pairwise distinct cells where each two consecutive cells have a common side; besides, the first cell has a common side with the last cell. A cycle is called cool if it fulfills all the following conditions simultaneously: \\n\\n * The cycle entirely consists of the cells that contain \\\"1\\\". \\n * Each cell that belongs to the cycle, has a common side with exactly two other cells that belong to the cycle. \\n * Each cell of the table that contains \\\"1\\\" either belongs to the cycle or is positioned outside of it (see definition below). \\n\\n\\n\\nTo define the notion of \\\"outside\\\" formally, let's draw a cycle on a plane. Let each cell of the cycle (i, j) (i is the row number, j is the column number) correspond to the point (i, j) on the coordinate plane. Let a straight line segment join each pair of points that correspond to the cells belonging to the cycle and sharing a side. Thus, we will get a closed polyline that has no self-intersections and self-touches. The polyline divides the plane into two connected parts: the part of an infinite area and the part of a finite area. It is considered that cell (r, c) lies outside of the cycle if it does not belong to the cycle and the corresponding point on the plane with coordinates (r, c) lies in the part with the infinite area.\\n\\nHelp Petya to find the length of the longest cool cycle in the table. The cycle length is defined as the number of cells that belong to the cycle.\\n\\nInput\\n\\nThe first line contains two integers n and m (1 ≤ n, m ≤ 1000) — the number of rows and columns in the table, respectively. Each of the following n lines contains m characters. Each character can...\",\"targets\":\"#include \\nusing namespace std;\\nconst int MAXN = 1003;\\nint n, m, u;\\nchar a[MAXN][MAXN];\\nint d[MAXN][MAXN];\\nint cnt, f[MAXN * MAXN], g[MAXN][MAXN];\\nqueue > q;\\nvector > v;\\nint addf(int x, int y) {\\n if (x < 1 || n < x || y < 1 || m < y || a[x][y] == '0' || d[x][y]) return 0;\\n d[x][y] = cnt;\\n q.push(make_pair(x, y));\\n return 0;\\n}\\nint adds(int x, int y) {\\n if (x < 1 || n < x || y < 1 || m < y) {\\n u++;\\n return 0;\\n }\\n if (a[x][y] == '1') {\\n if (f[d[x][y]] != cnt) u++, f[d[x][y]] = cnt;\\n if (g[x][y] != cnt) g[x][y] = cnt, v.push_back(make_pair(x, y));\\n return 0;\\n }\\n if (d[x][y]) return 0;\\n d[x][y] = -1;\\n q.push(make_pair(x, y));\\n return 0;\\n}\\nint main() {\\n scanf(\\\"%d %d\\\\n\\\", &n, &m);\\n for (int i = 1; i <= n; i++) gets(a[i] + 1);\\n for (int i = 1; i <= n; i++)\\n for (int j = 1; j <= m; j++)\\n if (d[i][j] == 0 && a[i][j] == '1') {\\n cnt++;\\n addf(i, j);\\n while (q.size()) {\\n int x = q.front().first, y = q.front().second;\\n q.pop();\\n for (int dx = -1; dx <= 1; dx++)\\n for (int dy = -1 + (dx != 0); dy <= 1; dy += 2)\\n addf(x + dx, y + dy);\\n }\\n }\\n int ans = 0;\\n for (int i = 1; i <= n - 1; i++)\\n for (int j = 1; j <= m - 1; j++)\\n if (a[i][j] == '1' && a[i][j + 1] == '1' && a[i + 1][j] == '1' &&\\n a[i + 1][j + 1] == '1')\\n ans = 4;\\n for (int i = 1; i <= n; i++)\\n for (int j = 1; j <= m; j++)\\n if (a[i][j] == '0' && d[i][j] == 0) {\\n u = 0;\\n v.clear();\\n cnt++;\\n adds(i, j);\\n while (q.size()) {\\n int x = q.front().first, y = q.front().second;\\n q.pop();\\n for (int dx = -1; dx <= 1; dx++)\\n for (int dy = -1; dy <= 1; dy++) adds(x + dx, y + dy);\\n }\\n if (u > 1) continue;\\n for (int i = 0; i < v.size(); i++) g[v[i].first][v[i].second] = 0;\\n for (int i = 0; i < v.size(); i++)\\n for (int dx = -1; dx <= 1; dx++)\\n for (int dy = -1 + (dx !=...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"It is reported that the 2050 Conference will be held in Yunqi Town in Hangzhou from April 23 to 25, including theme forums, morning jogging, camping and so on.\\n\\nThe relationship between the n volunteers of the 2050 Conference can be represented by a tree (a connected undirected graph with n vertices and n-1 edges). The n vertices of the tree corresponds to the n volunteers and are numbered by 1,2,…, n.\\n\\nWe define the distance between two volunteers i and j, dis(i,j) as the number of edges on the shortest path from vertex i to vertex j on the tree. dis(i,j)=0 whenever i=j.\\n\\nSome of the volunteers can attend the on-site reunion while others cannot. If for some volunteer x and nonnegative integer r, all volunteers whose distance to x is no more than r can attend the on-site reunion, a forum with radius r can take place. The level of the on-site reunion is defined as the maximum possible radius of any forum that can take place.\\n\\nAssume that each volunteer can attend the on-site reunion with probability 1\\/2 and these events are independent. Output the expected level of the on-site reunion. When no volunteer can attend, the level is defined as -1. When all volunteers can attend, the level is defined as n. \\n\\nInput\\n\\nThe first line contains a single integer n (2≤ n≤ 300) denoting the number of volunteers.\\n\\nEach of the next n-1 lines contains two integers a and b denoting an edge between vertex a and vertex b.\\n\\nOutput\\n\\nOutput the expected level modulo 998 244 353.\\n\\nFormally, let M = 998 244 353. It can be shown that the answer can be expressed as an irreducible fraction p\\/q, where p and q are integers and q not ≡ 0 \\\\pmod{M}. Output the integer equal to p ⋅ q^{-1} mod M. In other words, output such an integer x that 0 ≤ x < M and x ⋅ q ≡ p \\\\pmod{M}.\\n\\nExamples\\n\\nInput\\n\\n\\n3\\n1 2\\n2 3\\n\\n\\nOutput\\n\\n\\n499122177\\n\\n\\nInput\\n\\n\\n5\\n1 2\\n2 3\\n3 4\\n3 5\\n\\n\\nOutput\\n\\n\\n249561089\\n\\n\\nInput\\n\\n\\n10\\n1 2\\n2 3\\n3 4\\n4 5\\n5 6\\n6 7\\n7 8\\n8 9\\n9 10\\n\\n\\nOutput\\n\\n\\n821796866\\n\\nNote\\n\\nFor the first example, the following table shows all possible outcomes. yes means the volunteer...\\\":\",\"targets\":\"#include \\nusing namespace std;\\n#define erorp(x) cout<<#x<<\\\"={\\\"<<(x.F)<<\\\" , \\\"<=(1<\\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\":\"#from math import *\\n#from bisect import *\\n#from collections import *\\n#from random import *\\n#from decimal import *\\\"\\\"\\\"\\n#from heapq import *\\nimport sys\\ninput=sys.stdin.readline\\ndef inp():\\n return int(input())\\ndef st1():\\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={'R':'B','B':'R'}\\nwhile(t):\\n t-=1\\n n=inp()\\n a=lis()\\n if(a[-1]==0):\\n print(*[i for i in range(1,n+2)])\\n continue\\n else:\\n if(a[0]==1):\\n print(n+1,end=' ')\\n print(*[i for i in range(1,n+1)])\\n else:\\n have=1\\n for i in range(n):\\n if(a[i]==0):\\n print(have,end=' ')\\n have+=1\\n else:\\n print(n+1,end=' ')\\n print(*[i for i in range(have,n+1)])\\n break\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"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.\\nimpor\",\"targets\":\"t java.util.*;\\nimport java.io.*;\\n\\npublic class Main {\\n public static void main(String args[]) {new Main().run();}\\n\\n FastReader in = new FastReader();\\n PrintWriter out = new PrintWriter(System.out);\\n void run() {\\n work();\\n out.flush();\\n }\\n long mod=1000000007;\\n long gcd(long a,long b) {\\n return a==0?b:gcd(b%a,a);\\n }\\n long inf=Long.MAX_VALUE\\/3;\\n void work() {\\n int n=ni(),m=ni();\\n int[][] A=new int[n][2];\\n for(int i=0;ilen){\\n for(int j=i;jlen){\\n for(int j=pre[idx];ji)cur--;\\n if(j+sum=(r+A[idx][0])%sum&&r2 TX = new TreeMap<>(), TY = new TreeMap<>();\\n\\t\\tfor (int i : rep(N))\\n\\t\\t\\tTX.put(X[i], i);\\n\\t\\tfor (int i : rep(M))\\n\\t\\t\\tTY.put(Y[i], i);\\n\\t\\t\\n\\t\\tlong res = 0, C = 0;\\n\\t\\tint j = 0;\\n\\t\\t\\n\\t\\tfor (int i : rep(K)) {\\n\\t\\t\\tint x = PX[i][0];\\n\\t\\t\\tif (x == X[j])\\n\\t\\t\\t\\tcontinue;\\n\\t\\t\\telse if (x < X[j+1])\\n\\t\\t\\t\\t++C;\\n\\t\\t\\telse {\\n\\t\\t\\t\\tres += C * C;\\n\\t\\t\\t\\tC = 0; j = TX.floorEntry(x).getValue(); \\n\\t\\t\\t\\tif (x > X[j])\\n\\t\\t\\t\\t\\tC = 1;\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\t\\n\\t\\tres += C * C;\\n\\t\\tC = 0; j = 0;\\n\\t\\tfor (int i : rep(K)) {\\n\\t\\t\\tint y = PY[i][1];\\n\\t\\t\\tif (y == Y[j])\\n\\t\\t\\t\\tcontinue;\\n\\t\\t\\telse if (y < Y[j+1])\\n\\t\\t\\t\\t++C;\\n\\t\\t\\telse {\\n\\t\\t\\t\\tres += C * C;\\n\\t\\t\\t\\tC = 0; j = TY.floorEntry(y).getValue();\\n\\t\\t\\t\\tif (y > Y[j])\\n\\t\\t\\t\\t\\tC = 1;\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\t\\n\\t\\tres += C * C;\\n\\t\\tint x = 0; C = 0; j = 0;\\n\\t\\tfor (int i : rep(K))\\n\\t\\t\\tif (PX[i][0] == x) {\\n\\t\\t\\t\\tint y = PX[i][1];\\n\\t\\t\\t\\tif (y == Y[j])\\n\\t\\t\\t\\t\\tcontinue;\\n\\t\\t\\t\\telse if (y < Y[j+1])\\n\\t\\t\\t\\t\\t++C;\\n\\t\\t\\t\\telse {\\n\\t\\t\\t\\t\\tres -= C * C;\\n\\t\\t\\t\\t\\tC = 0; j = TY.floorEntry(y).getValue();\\n\\t\\t\\t\\t\\tif (y > Y[j])\\n\\t\\t\\t\\t\\t\\tC = 1;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\telse if (PX[i][0] > x) {\\n\\t\\t\\t\\tres -= C * C; \\n\\t\\t\\t\\tC = 0; j = 0;\\n\\t\\t\\t\\tx = TX.ceilingKey(PX[i][0]);\\n\\t\\t\\t\\tif (PX[i][0] == x) {\\n\\t\\t\\t\\t\\tj = TY.floorEntry(PX[i][1]).getValue();\\n\\t\\t\\t\\t\\tif (PX[i][1] > Y[j])\\n\\t\\t\\t\\t\\t\\tC = 1;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\n\\t\\tres -= C * C;\\n\\t\\tint y = 0; C = 0; j = 0;\\n\\t\\tfor (int i : rep(K))\\n\\t\\t\\tif (PY[i][1] == y) {\\n\\t\\t\\t\\tx = PY[i][0];\\n\\t\\t\\t\\tif (x == X[j])\\n\\t\\t\\t\\t\\tcontinue;\\n\\t\\t\\t\\telse if (x < X[j+1])\\n\\t\\t\\t\\t\\t++C;\\n\\t\\t\\t\\telse {\\n\\t\\t\\t\\t\\tres -= C * C;\\n\\t\\t\\t\\t\\tC = 0; j = TX.floorEntry(x).getValue();\\n\\t\\t\\t\\t\\tif (x > X[j])\\n\\t\\t\\t\\t\\t\\tC = 1;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\telse if (PY[i][1] > y) {\\n\\t\\t\\t\\tres -= C * C;\\n\\t\\t\\t\\tC = 0; j = 0;\\n\\t\\t\\t\\ty = TY.ceilingKey(PY[i][1]);\\n\\t\\t\\t\\tif (PY[i][1] == y) {\\n\\t\\t\\t\\t\\tj = TX.floorEntry(PY[i][0]).getValue();\\n\\t\\t\\t\\t\\tif (PY[i][0] > X[j])\\n\\t\\t\\t\\t\\t\\tC = 1;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\n\\t\\tres -= C * C;\\n\\t\\tres \\/=...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Once little Vasya read an article in a magazine on how to make beautiful handmade garland from colored paper. Vasya immediately went to the store and bought n colored sheets of paper, the area of each sheet is 1 square meter.\\n\\nThe garland must consist of exactly m pieces of colored paper of arbitrary area, each piece should be of a certain color. To make the garland, Vasya can arbitrarily cut his existing colored sheets into pieces. Vasya is not obliged to use all the sheets to make the garland.\\n\\nVasya wants the garland to be as attractive as possible, so he wants to maximize the total area of ​​m pieces of paper in the garland. Calculate what the maximum total area of ​​the pieces of paper in the garland Vasya can get.\\n\\nInput\\n\\nThe first line contains a non-empty sequence of n (1 ≤ n ≤ 1000) small English letters (\\\"a\\\"...\\\"z\\\"). Each letter means that Vasya has a sheet of paper of the corresponding color.\\n\\nThe second line contains a non-empty sequence of m (1 ≤ m ≤ 1000) small English letters that correspond to the colors of the pieces of paper in the garland that Vasya wants to make.\\n\\nOutput\\n\\nPrint an integer that is the maximum possible total area of the pieces of paper in the garland Vasya wants to get or -1, if it is impossible to make the garland from the sheets he's got. It is guaranteed that the answer is always an integer.\\n\\nExamples\\n\\nInput\\n\\naaabbac\\naabbccac\\n\\n\\nOutput\\n\\n6\\n\\n\\nInput\\n\\na\\nz\\n\\n\\nOutput\\n\\n-1\\n\\nNote\\n\\nIn the first test sample Vasya can make an garland of area 6: he can use both sheets of color b, three (but not four) sheets of color a and cut a single sheet of color c in three, for example, equal pieces. Vasya can use the resulting pieces to make a garland of area 6.\\n\\nIn the second test sample Vasya cannot make a garland at all — he doesn't have a sheet of color z.\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n string a, b;\\n int i, j, t1, t2, ans = 0;\\n cin >> a >> b;\\n for (i = 0; i < 26; i++) {\\n t1 = t2 = 0;\\n for (j = 0; j < a.size(); j++) t1 += a[j] == 'a' + i;\\n for (j = 0; j < b.size(); j++) t2 += b[j] == 'a' + i;\\n if (t2 && !t1) {\\n ans = -1;\\n break;\\n }\\n ans += min(t1, t2);\\n }\\n cout << ans << endl;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"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;\\ninline long long read() {\\n long long x = 0;\\n bool flag = 1;\\n char ch = getchar();\\n while (ch < '0' || ch > '9') {\\n if (ch == '-') flag = 0;\\n ch = getchar();\\n }\\n while (ch >= '0' && ch <= '9') {\\n x = (x << 1) + (x << 3) + ch - '0';\\n ch = getchar();\\n }\\n return flag ? x : ~(x - 1);\\n}\\ninline void write(long long x) {\\n if (x > 9) write(x \\/ 10);\\n putchar(x % 10 + '0');\\n}\\nconst long long N = 1e6 + 10;\\nlong long n, ans, a[N];\\nlong long prime[N], mp[N], cnt;\\nlong long stk[N], top, pre[N], w[N];\\nbool is_prime[N];\\nvector vec[N];\\ninline void sieve(long long x) {\\n for (long long i = 2; i <= x; i++) {\\n if (!is_prime[i]) prime[++cnt] = mp[i] = i;\\n for (long long j = 1; prime[j] <= x \\/ i; j++) {\\n is_prime[i * prime[j]] = true;\\n mp[i * prime[j]] = prime[j];\\n if (i % prime[j] == 0) break;\\n }\\n }\\n}\\nsigned main() {\\n sieve(1000000);\\n n = read();\\n for (long long i = 1; i <= n; i++) a[i] = read();\\n for (long long i = 1; i <= n; i++) {\\n char ch = getchar();\\n while (ch != '*' && ch != '\\/') ch = getchar();\\n if (ch == '*') {\\n while (a[i] > 1) {\\n long long p = mp[a[i]];\\n vec[p].push_back(i);\\n a[i] \\/= p;\\n }\\n pre[i] = i;\\n } else {\\n pre[i] = i;\\n while (a[i] > 1) {\\n long long p = mp[a[i]];\\n if (vec[p].empty())\\n pre[i] = -1;\\n else\\n pre[i] = min(pre[i], vec[p].back()), vec[p].pop_back();\\n a[i] \\/= p;\\n }\\n }\\n }\\n for (long long i = n; i >= 1; i--) {\\n long long nw = 1;\\n while (top && pre[i] <= stk[top]) nw += w[top], top--;\\n stk[++top] = pre[i], w[top] = nw;\\n if (i == pre[i]) ans += nw;\\n }\\n write(ans), putchar('\\\\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?\\nYou 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...\",\"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 int n;\\n cin >> n;\\n vector arr(n);\\n for (int I = 0; I < n; I++) cin >> arr[I];\\n cin >> s;\\n priority_queue, greater> blues;\\n priority_queue, greater> reds;\\n for (int I = 0; I < n; I++) {\\n if (s[I] == 'B') {\\n blues.push(arr[I]);\\n } else {\\n reds.push(arr[I]);\\n }\\n }\\n bool flag = true;\\n for (int I = 1; I < n + 1; I++) {\\n if (blues.size() and blues.top() >= I) {\\n blues.pop();\\n } else {\\n if (reds.size() and reds.top() <= I) {\\n reds.pop();\\n } else {\\n flag = false;\\n }\\n }\\n }\\n if (flag) {\\n cout << \\\"YES\\\" << endl;\\n } else {\\n cout << \\\"NO\\\" << endl;\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"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...\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(0);\\n int t;\\n cin >> t;\\n while (t--) {\\n int n, k;\\n cin >> n >> k;\\n vector pa, na;\\n int ma = 0;\\n for (int i = 0; i < n; i++) {\\n int a;\\n cin >> a;\\n if (a > 0) pa.push_back(a);\\n if (a < 0) na.push_back(-a);\\n ma = max(ma, abs(a));\\n }\\n sort(pa.begin(), pa.end());\\n sort(na.begin(), na.end());\\n long long sol = -ma;\\n for (int i = pa.size() - 1; i >= 0; i -= k) {\\n sol += 2 * pa[i];\\n }\\n for (int i = na.size() - 1; i >= 0; i -= k) {\\n sol += 2 * na[i];\\n }\\n cout << sol << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"An architect, Devunky, who lives in Water Deven, has been asked to renovate an old large hospital.\\n\\nIn some countries, people don't want to use numbers that are disliked as numerophobia (4 and 9 are famous in Japan). However, the room numbers in this hospital were numbered from 1 regardless of the number of numerophobia.\\n\\nMr. Devunky, who was worried about it, renumbered the room with the numbers excluding \\\"4\\\" and \\\"6\\\", which are the numerophobia of Water Devon, before all the equipment and beds were replaced. However, since the replacement work was planned with the old room number, it is necessary to convert the old room number to the new room number to ensure that the rest of the work is done. Mr. Devunky, who is not good at calculations, is surprised to notice this.\\n\\nFor such Mr. Devunky, please create a program that inputs the old room number and outputs the corresponding new room number.\\n\\nThe correspondence table of room numbers up to the 15th is as follows.\\n\\nOld room number | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15\\n--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |- -| --- | --- | ---\\nNew room number | 1 | 2 | 3 | 5 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 15 | 17 | 18 | 19\\n\\n\\n\\n\\nInput\\n\\nA sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. For each dataset, the integer n (1 ≤ n ≤ 1,000,000,000) representing the old room number is given on one line.\\n\\nThe number of datasets does not exceed 30000.\\n\\nOutput\\n\\nOutputs the new room number on one line for each input dataset.\\n\\nExample\\n\\nInput\\n\\n15\\n100\\n1000000000\\n3\\n0\\n\\n\\nOutput\\n\\n19\\n155\\n9358757000\\n3\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include\\nint i,j;\\nint k[10];\\nint ck;\\nint n;\\n\\nint main(){\\n\\twhile(1){\\n\\t\\tscanf(\\\"%d\\\",&n);\\n\\t\\tif(n==0)return 0;\\n\\t\\tck=0;\\n\\t\\twhile(n>=1){\\n\\t\\t\\tif(n%8<=3)k[ck++]=n%8;\\n\\t\\t\\telse if(n%8<=4)k[ck++]=n%8+1;\\n\\t\\t\\telse k[ck++]=n%8+2;\\n\\t\\t\\tn\\/=8;\\n\\t\\t}\\n\\t\\tfor(i=ck-1;i>=0;i--){\\n\\t\\t\\tprintf(\\\"%d\\\",k[i]);\\n\\t\\t}\\n\\t\\tprintf(\\\"\\\\n\\\");\\n\\t}\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nTwo 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\",\"targets\":\"#include \\nusing namespace std;\\ntemplate \\nvoid read(T &t) {\\n t = 0;\\n char ch = getchar();\\n int f = 1;\\n while (ch < '0' || ch > '9') {\\n if (ch == '-') f = -1;\\n ch = getchar();\\n }\\n do {\\n (t *= 10) += ch - '0';\\n ch = getchar();\\n } while ('0' <= ch && ch <= '9');\\n t *= f;\\n}\\ntemplate \\nvoid write(T t) {\\n if (t < 0) {\\n putchar('-');\\n write(-t);\\n return;\\n }\\n if (t > 9) write(t \\/ 10);\\n putchar('0' + t % 10);\\n}\\ntemplate \\nvoid writeln(T t) {\\n write(t);\\n puts(\\\"\\\");\\n}\\nconst int INF = 1e9;\\nconst int maxn = (2e5) + 10;\\nint n, m, X;\\nlong long ans;\\nint a[maxn], b[maxn], na[maxn], nb[maxn];\\nint s[maxn], tot, L[maxn], R[maxn];\\nint st[maxn][20], lg[maxn];\\nint query(int l, int r) {\\n int j = lg[r - l + 1];\\n return max(st[l][j], st[r - (1 << j) + 1][j]);\\n}\\nvoid solve(int n, int *a, int *na) {\\n for (int i = 2; i <= n; i++) lg[i] = lg[i >> 1] + 1;\\n for (int i = 1; i <= n; i++) st[i][0] = a[i];\\n for (int i = 1; i <= 19; i++)\\n for (int j = 1; j + (1 << i) - 1 <= n; j++)\\n st[j][i] = max(st[j][i - 1], st[j + (1 << (i - 1))][i - 1]);\\n tot = 0;\\n for (int i = 1; i <= n; i++) {\\n while (tot && a[s[tot]] > a[i]) tot--;\\n L[i] = s[tot];\\n s[++tot] = i;\\n }\\n tot = 0;\\n for (int i = n; i >= 1; i--) {\\n while (tot && a[s[tot]] >= a[i]) tot--;\\n R[i] = s[tot];\\n s[++tot] = i;\\n }\\n for (int i = 1; i <= n; i++) {\\n na[i] = INF;\\n if (L[i]) na[i] = query(L[i], i);\\n if (R[i]) na[i] = min(na[i], query(i, R[i]));\\n }\\n}\\nint id[maxn], id2[maxn];\\nbool cmp(int x, int y) { return a[x] < a[y]; }\\nbool cmp2(int x, int y) { return nb[x] < nb[y]; }\\nnamespace Seg {\\nint tr[maxn];\\nvoid add(int x) {\\n for (; x < maxn; x += x & (-x)) tr[x]++;\\n}\\nint query(int x) {\\n int res = 0;\\n for (; x; x -= x & (-x)) res += tr[x];\\n return res;\\n}\\nint query(int l, int r) { return query(r) - query(l - 1); }\\n}; \\/\\/ namespace Seg\\nint main() {\\n read(n), read(m), read(X);\\n for (int i = 1; i <= n; i++) read(a[i]);\\n for (int i = 1; i <= m; i++) read(b[i]);\\n solve(n,...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"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 JAVA.\",\"targets\":\"import java.io.BufferedWriter;\\nimport java.io.IOException;\\nimport java.io.InputStream;\\nimport java.io.OutputStream;\\nimport java.io.OutputStreamWriter;\\nimport java.io.PrintWriter;\\nimport java.io.Writer;\\nimport java.util.Arrays;\\nimport java.util.InputMismatchException;\\nimport java.util.*;\\nimport java.io.*;\\nimport java.math.*;\\npublic class Main\\n \\n{\\n public static long pow(long a, long b)\\n {\\n long result=1;\\n while(b>0)\\n {\\n if (b % 2 != 0)\\n {\\n result=(result*a);\\n b--;\\n } \\n a=(a*a);\\n b \\/= 2;\\n } \\n return result;\\n }\\n public static long fact(long num)\\n {\\n long fact=1;\\n\\t\\t\\t\\tint i=0;\\n for(i=1; i<=num; i++)\\n {\\n fact=fact*i;\\n }\\n return fact;\\n }\\n public static long gcd(long a, long b)\\n {\\n if (a == 0)\\n return b;\\n return gcd(b%a, a);\\n }\\n \\n public static long lcm(int a,int b)\\n {\\n return a * (b \\/ gcd(a, b));\\n }\\n public static long sum(int h)\\n {\\n return (h*(h+1)\\/2);\\n }\\n\\t\\t\\tpublic static void dfs(int parent,boolean[] visited)\\n\\t\\t\\t{\\n\\t\\t\\t\\tArrayList arr=new ArrayList();\\n\\t\\t\\t\\tarr=graph.get(parent);\\n\\t\\t\\t\\tvisited[parent]=true;\\n\\t\\t\\t\\tfor(int i=0;i> graph;\\n\\t\\t\\tstatic InputReader in=new InputReader(System.in);\\n \\tstatic OutputWriter out=new OutputWriter(System.out);\\n \\tpublic static long Long()\\n\\t\\t\\t{\\n\\t\\t\\t\\tString s=in.String();\\n\\t\\t\\t\\treturn Long.parseLong(s);\\n\\t\\t\\t}\\n\\t\\t\\tpublic static void pln(String...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"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 check(double h, double r) {\\n if (h >= r \\/ 2 * sqrt(3))\\n return 3;\\n else if (h >= (r \\/ 2))\\n return 2;\\n else\\n return 1;\\n}\\nint main() {\\n double r, h0, h;\\n cin >> r >> h0;\\n long res1, res2;\\n res1 = res2 = 0;\\n h = h0;\\n res1 = ((int)(h \\/ r)) * 2;\\n h -= res1 \\/ 2 * r;\\n res1 += check(h, r);\\n h = h0;\\n if (h <= r + r \\/ 2 * sqrt(3)) {\\n cout << res1;\\n return 0;\\n }\\n int i = (int)((h - r) \\/ (r \\/ 2 * sqrt(3)));\\n if (i >= 1)\\n res2 = (i \\/ 2 + 1) * 2 + (i + 1) \\/ 2;\\n else\\n i = 0;\\n h -= r + i * r \\/ 2 * sqrt(3);\\n res2 += check(h, r);\\n cout << max(res1, res2);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"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\":\"import itertools as _itertools\\nimport sys as _sys\\n\\n\\ndef which_rods_should_remove_to_make_machine_charged_correctly(rods, queries):\\n rods = list(rods)\\n rods = [+x if i % 2 == 0 else -x for i, x in enumerate(rods)]\\n prefix_sums = tuple(_itertools.accumulate(rods))\\n for query in queries:\\n yield tuple(_process_query(query, prefix_sums))\\n\\n\\ndef _process_query(query, prefix_sums):\\n def get_prefix_sum(i):\\n return prefix_sums[i] if i >= 0 else 0\\n \\n l, r = query\\n sum_before_prefix = get_prefix_sum(l - 1)\\n \\n initial_sum = get_prefix_sum(r) - sum_before_prefix\\n if initial_sum == 0:\\n return\\n if (initial_sum - 1) % 2 != 0:\\n yield from _process_query((l, r-1), prefix_sums)\\n yield r\\n return\\n \\n def get_sum_by_deletion(i):\\n sum_before_deletion = get_prefix_sum(i - 1) - sum_before_prefix\\n sum_after_deletion = get_prefix_sum(r) - get_prefix_sum(i)\\n return sum_before_deletion - sum_after_deletion\\n \\n first_sum = get_sum_by_deletion(r)\\n if first_sum == 0:\\n yield r\\n return\\n \\n min_i_to_del = l\\n max_i_to_del = r\\n while min_i_to_del != max_i_to_del:\\n i = (min_i_to_del + max_i_to_del) \\/\\/ 2\\n current_sum = get_sum_by_deletion(i)\\n if current_sum * first_sum < 0: # signs differ and both nonzero\\n min_i_to_del = i + 1\\n else:\\n max_i_to_del = i\\n i_to_del = min_i_to_del\\n \\n yield i_to_del\\n\\n\\ndef _main():\\n input_lines = iter(_sys.stdin.read().splitlines())\\n output = []\\n \\n [tests_n] = _read_ints(next(input_lines))\\n for i_test in range(tests_n):\\n [rods_n, queries_n] = _read_ints(next(input_lines))\\n rods = next(input_lines)\\n assert len(rods) == rods_n and set(rods).issubset({'+', '-'})\\n rods = [+1 if ch == '+' else -1 for ch in rods]\\n queries = [_read_query(next(input_lines)) for i_query in range(queries_n)]\\n results = which_rods_should_remove_to_make_machine_charged_correctly(rods, queries)\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Devu wants to decorate his garden with flowers. He has purchased n boxes, where the i-th box contains fi flowers. All flowers in a single box are of the same color (hence they are indistinguishable). Also, no two boxes have flowers of the same color.\\n\\nNow Devu wants to select exactly s flowers from the boxes to decorate his garden. Devu would like to know, in how many different ways can he select the flowers from each box? Since this number may be very large, he asks you to find the number modulo (109 + 7). \\n\\nDevu considers two ways different if there is at least one box from which different number of flowers are selected in these two ways.\\n\\nInput\\n\\nThe first line of input contains two space-separated integers n and s (1 ≤ n ≤ 20, 0 ≤ s ≤ 1014).\\n\\nThe second line contains n space-separated integers f1, f2, ... fn (0 ≤ fi ≤ 1012).\\n\\nOutput\\n\\nOutput a single integer — the number of ways in which Devu can select the flowers modulo (109 + 7).\\n\\nExamples\\n\\nInput\\n\\n2 3\\n1 3\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n2 4\\n2 2\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\n3 5\\n1 3 2\\n\\n\\nOutput\\n\\n3\\n\\nNote\\n\\nSample 1. There are two ways of selecting 3 flowers: {1, 2} and {0, 3}.\\n\\nSample 2. There is only one way of selecting 4 flowers: {2, 2}.\\n\\nSample 3. There are three ways of selecting 5 flowers: {1, 2, 2}, {0, 3, 2}, and {1, 3, 1}.\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nlong long s, a[22], b[22] = {1};\\nint n, ans;\\nlong long bin(long long a, int n) {\\n long long ans = 1;\\n while (n) {\\n if (n & 1) ans *= a, ans %= 1000000007;\\n a *= a, a %= 1000000007;\\n n >>= 1;\\n }\\n return ans;\\n}\\nvoid f(int pos, long long s, int cnt) {\\n if (pos > n) {\\n long long calc = 1;\\n if (s < n) return;\\n for (long long i = s - n + 1; i <= s - 1; i++)\\n calc *= (i % 1000000007), calc %= 1000000007;\\n calc *= b[n - 1], calc %= 1000000007;\\n if (cnt & 1)\\n ans = ans - calc + 1000000007;\\n else\\n ans = ans + calc;\\n if (ans >= 1000000007) ans -= 1000000007;\\n return;\\n }\\n f(pos + 1, s, cnt);\\n f(pos + 1, s - a[pos], cnt + 1);\\n}\\nint main() {\\n scanf(\\\"%d%I64d\\\", &n, &s);\\n long long fa = 1;\\n for (int i = 1; i <= n; i++)\\n fa *= i, fa %= 1000000007, b[i] = bin(fa, 1000000007 - 2);\\n s += n;\\n for (int i = 1; i <= n; i++) scanf(\\\"%I64d\\\", &a[i]), a[i]++;\\n f(1, s, 0);\\n for (long long i = 1; i <= 1000000000; i++) i = i;\\n printf(\\\"%d\\\", ans);\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"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...\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nvector> vals[2000005];\\nint32_t main() {\\n ios::sync_with_stdio(0);\\n cin.tie(0);\\n long long t;\\n cin >> t;\\n while (t--) {\\n long long n;\\n cin >> n;\\n pair a[n];\\n pair op[n];\\n long long mi[n];\\n for (long long i = 0; i < n; i++) {\\n cin >> a[i].first >> a[i].second;\\n op[i].first = a[i].first;\\n op[i].second = a[i].second;\\n cin >> mi[i];\\n }\\n long long rx[n];\\n long long taken[n];\\n memset(taken, 0, sizeof(taken));\\n for (long long i = 0; i < n; i++) {\\n long long ll = max((long long)(0), mi[i] - a[i].second);\\n long long rr = min(a[i].first, mi[i]);\\n taken[i] += ll;\\n rr -= ll;\\n a[i].first -= ll;\\n a[i].second -= (mi[i] - ll);\\n rx[i] = rr;\\n }\\n set s;\\n for (long long i = 0; i < n; i++) {\\n auto x = a[i];\\n s.insert(x.first + x.second);\\n vals[x.first + x.second].push_back({x.first, i});\\n }\\n long long fina = 0;\\n for (auto x : s) {\\n sort(vals[x].begin(), vals[x].end());\\n auto vv = vals[x];\\n long long maxa = 0;\\n long long optim_start = 0;\\n long long optim_end = 0;\\n long long z = vals[x].size();\\n long long r = 0;\\n for (long long i = 0; i < z; i++) {\\n long long l = i;\\n if (i < r) {\\n continue;\\n }\\n r = max(r, i);\\n while (r < z && vv[r].first - (rx[vv[r].second]) <= vv[l].first) {\\n r++;\\n }\\n for (long long i = l; i < r; i++) {\\n taken[vv[i].second] += (vv[i].first - vv[l].first);\\n }\\n }\\n fina += (z - maxa + 1);\\n }\\n set> lol;\\n for (long long i = 0; i < n; i++) {\\n lol.insert({op[i].first - taken[i], op[i].second + taken[i] - mi[i]});\\n }\\n cout << lol.size() << \\\"\\\\n\\\";\\n ;\\n for (long long i = 0; i < n; i++) {\\n auto x = taken[i];\\n cout << x << \\\" \\\" << mi[i] - x << \\\"\\\\n\\\";\\n }\\n for (auto x : s) {\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in PYTHON3?\\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\":\"for _ in range(int(input())):\\n q = int(input())\\n a = input()\\n b = input()\\n f = \\\"YES\\\"\\n for i in range(q):\\n if a[i] == b[i] and a[i] == '1':\\n f = \\\"NO\\\"\\n break\\n print(f)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in PYTHON3?\\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 sys\\n# for reading a string call input().strip()\\ninput = sys.stdin.buffer.readline\\n\\ndef solve():\\n indices = list(range(N * M))\\n indices.sort(key=lambda i: A[i])\\n indexOf = {}\\n for i, val in enumerate(indices):\\n indexOf[val] = i\\n indices.sort(key=lambda i: (A[i], indexOf[i] \\/\\/ M, -i))\\n ans = 0\\n row = [0] * M\\n for i in range(N):\\n for j in range(M):\\n row[j] = indices[i * M + j]\\n # print(row)\\n for j in range(M):\\n for k in range(j):\\n if row[k] < row[j]:\\n ans += 1\\n\\n return ans\\n\\ntest_cases = int(input())\\nfor test_case in range(test_cases):\\n N, M = map(int, input().split())\\n A = list(map(int, input().split()))\\n print(solve())\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 solution for \\\"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\":\"def solve():\\n # put code here\\n arr = [int(v) for v in input().split()]\\n a,b,c,d = arr[:4]\\n\\n if a+b == c:\\n print(a,b,d)\\n else:\\n print(a,b,c)\\n\\nt = int(input())\\nfor _ in range(t):\\n solve()\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A and B are preparing themselves for programming contests.\\n\\nB loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.\\n\\nInitially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake.\\n\\nHowever, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared — the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change.\\n\\nCan you help B find out exactly what two errors he corrected?\\n\\nInput\\n\\nThe first line of the input contains integer n (3 ≤ n ≤ 105) — the initial number of compilation errors.\\n\\nThe second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the errors the compiler displayed for the first time. \\n\\nThe third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 — the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one. \\n\\nThe fourth line contains n - 2 space-separated integers с1, с2, ..., сn - 2 — the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one. \\n\\nOutput\\n\\nPrint two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively. \\n\\nExamples\\n\\nInput\\n\\n5\\n1 5 8 123 7\\n123 7 5 1\\n5 1 7\\n\\n\\nOutput\\n\\n8\\n123\\n\\n\\nInput\\n\\n6\\n1 4 3 3 5 7\\n3 7 5 4 3\\n4 3 7 5\\n\\n\\nOutput\\n\\n1\\n3\\n\\nNote\\n\\nIn the first test sample B first corrects the error number 8, then the error number 123.\\n\\nIn the second test sample B first corrects the error...\\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.util.HashMap;\\nimport java.util.Map;\\n\\npublic class Z519BHASH {\\n\\n\\tpublic static void main(String[] args) throws NumberFormatException, IOException { \\n\\t\\tZ519BHASH z = new Z519BHASH();\\n\\t\\tString[] niz = z.glavnaMetoda();\\n\\t\\tispis(niz);\\n\\t}\\n\\t\\n\\tpublic String[] glavnaMetoda() throws NumberFormatException, IOException { \\n\\t\\t\\n\\t\\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\\n\\t\\tint t = Integer.parseInt(br.readLine());\\n\\t\\tString[] nizIspis = new String[2];\\n\\t\\t\\n\\t\\tHashMap mapa = new HashMap();\\n\\t\\tHashMap mapa2 = new HashMap();\\n\\t\\tHashMap mapa3 = new HashMap();\\n\\t\\tString[] linija = br.readLine().split(\\\" \\\");\\n\\t\\tString[] linija2 = br.readLine().split(\\\" \\\");\\n\\t\\tString[] linija3 = br.readLine().split(\\\" \\\");\\n\\t\\t\\n\\t\\tmapa = dodajUMapu(mapa, linija);\\n\\t\\tmapa2 = dodajUMapu(mapa2, linija2);\\n\\t\\tmapa3 = dodajUMapu(mapa3, linija3);\\n\\t\\t\\n\\t\\tnizIspis[0] = ispitajMape(mapa, mapa2);\\n\\t\\tnizIspis[1] = ispitajMape(mapa2, mapa3);\\n\\t\\treturn nizIspis;\\n\\t}\\n\\t\\n\\tpublic String toString(char[] linija) { \\n\\t\\tString rez =\\\"\\\";\\n\\t\\tfor(int i=0; i dodajUMapu(HashMap mapa, String[] linija) {\\n\\t\\tfor(String c : linija) {\\n\\t\\t\\tif(!mapa.containsKey(c)) {\\n\\t\\t\\t\\tmapa.put(c, 1);\\n\\t\\t\\t}\\n\\t\\t\\telse { \\n\\t\\t\\t\\tmapa.put(c, mapa.get(c)+1);\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\treturn mapa;\\n\\t}\\n\\tpublic String ispitajMape(HashMap mapa1,HashMap mapa2) {\\n\\t\\t\\n\\t\\tString c = \\\" \\\";\\n\\t\\tfor (Map.Entry entry : mapa1.entrySet()) {\\n\\t\\t\\tif(mapa2.containsKey(entry.getKey())) {\\n\\t\\t\\t\\tint value = mapa2.get(entry.getKey());\\n\\t\\t\\t\\tif((int)entry.getValue() != value) {\\n\\t\\t\\t\\t\\tc = (String) entry.getKey();\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\telse { \\n\\t\\t\\t\\t\\tcontinue;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\telse {\\n\\t\\t\\t\\tc =...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nLet's define a function f(x) (x is a positive integer) as follows: write all digits of the decimal representation of x backwards, then get rid of the leading zeroes. For example, f(321) = 123, f(120) = 21, f(1000000) = 1, f(111) = 111.\\n\\nLet's define another function g(x) = (x)\\/(f(f(x))) (x is a positive integer as well).\\n\\nYour task is the following: for the given positive integer n, calculate the number of different values of g(x) among all numbers x such that 1 ≤ x ≤ n.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 100) — the number of test cases.\\n\\nEach test case consists of one line containing one integer n (1 ≤ n < 10^{100}). This integer is given without leading zeroes.\\n\\nOutput\\n\\nFor each test case, print one integer — the number of different values of the function g(x), if x can be any integer from [1, n].\\n\\nExample\\n\\nInput\\n\\n\\n5\\n4\\n37\\n998244353\\n1000000007\\n12345678901337426966631415\\n\\n\\nOutput\\n\\n\\n1\\n2\\n9\\n10\\n26\\n\\nNote\\n\\nExplanations for the two first test cases of the example:\\n\\n 1. if n = 4, then for every integer x such that 1 ≤ x ≤ n, (x)\\/(f(f(x))) = 1; \\n 2. if n = 37, then for some integers x such that 1 ≤ x ≤ n, (x)\\/(f(f(x))) = 1 (for example, if x = 23, f(f(x)) = 23,(x)\\/(f(f(x))) = 1); and for other values of x, (x)\\/(f(f(x))) = 10 (for example, if x = 30, f(f(x)) = 3, (x)\\/(f(f(x))) = 10). So, there are two different values of g(x).\",\"targets\":\"#include \\nusing namespace std;\\n#define ll long long \\n#define ld long double\\n#define pb push_back\\n#define endl \\\"\\\\n\\\"\\n#define ff first\\n#define ss second\\n#define inp(a) int a; cin>>a;\\n#define inpa(a,n) vectora(n+1); FOR(i,1,n) cin>>a[i];\\n#define PI 3.141592653589793238\\n#define vec(x) vector\\n#define pii pair\\n#define mem(a,b) memset(a, b, sizeof a)\\n#define FOR(i,j,n) for(int i= j; i<=n; i++)\\n#define CASE int t; cin>>t; while(t--)\\n#define prec(n) fixed<>s;\\n\\n\\tcout << s.length() << endl;\\n\\n}\\n\\n\\n\\nint32_t main(){\\n\\t#ifndef ONLINE_JUDGE \\n\\t\\tfreopen (\\\"input.txt\\\",\\\"r\\\",stdin);\\n\\t\\tfreopen (\\\"output.txt\\\",\\\"w\\\",stdout);\\n\\t#endif\\t\\n\\t ios::sync_with_stdio(0); \\n\\t cin.tie(0); cout.tie(0);\\n\\tCASE{\\n\\t\\tsolve();\\n\\n\\t}\\n\\n\\t\\/\\/cerr<<\\\"Time : \\\"<<1000*(ld)clock()\\/(ld)CLOCKS_PER_SEC<<\\\"ms\\\\n\\\";\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A TV show called \\\"Guess a number!\\\" is gathering popularity. The whole Berland, the old and the young, are watching the show.\\n\\nThe rules are simple. The host thinks of an integer y and the participants guess it by asking questions to the host. There are four types of acceptable questions:\\n\\n * Is it true that y is strictly larger than number x? \\n * Is it true that y is strictly smaller than number x? \\n * Is it true that y is larger than or equal to number x? \\n * Is it true that y is smaller than or equal to number x? \\n\\n\\n\\nOn each question the host answers truthfully, \\\"yes\\\" or \\\"no\\\".\\n\\nGiven the sequence of questions and answers, find any integer value of y that meets the criteria of all answers. If there isn't such value, print \\\"Impossible\\\".\\n\\nInput\\n\\nThe first line of the input contains a single integer n (1 ≤ n ≤ 10000) — the number of questions (and answers). Next n lines each contain one question and one answer to it. The format of each line is like that: \\\"sign x answer\\\", where the sign is:\\n\\n * \\\">\\\" (for the first type queries), \\n * \\\"<\\\" (for the second type queries), \\n * \\\">=\\\" (for the third type queries), \\n * \\\"<=\\\" (for the fourth type queries). \\n\\n\\n\\nAll values of x are integer and meet the inequation - 109 ≤ x ≤ 109. The answer is an English letter \\\"Y\\\" (for \\\"yes\\\") or \\\"N\\\" (for \\\"no\\\").\\n\\nConsequtive elements in lines are separated by a single space.\\n\\nOutput\\n\\nPrint any of such integers y, that the answers to all the queries are correct. The printed number y must meet the inequation - 2·109 ≤ y ≤ 2·109. If there are many answers, print any of them. If such value doesn't exist, print word \\\"Impossible\\\" (without the quotes).\\n\\nExamples\\n\\nInput\\n\\n4\\n>= 1 Y\\n< 3 N\\n<= -3 N\\n> 55 N\\n\\n\\nOutput\\n\\n17\\n\\n\\nInput\\n\\n2\\n> 100 Y\\n< -100 Y\\n\\n\\nOutput\\n\\nImpossible\",\"targets\":\"#include \\nusing namespace std;\\nconst int INF = 1e9;\\nmap match;\\nint l, r;\\nvoid gao(int id, int x) {\\n if (id == 0) r = min(r, x - 1);\\n if (id == 1) l = max(l, x);\\n if (id == 2) l = max(l, x + 1);\\n if (id == 3) r = min(r, x);\\n}\\nvoid init() {\\n match[\\\"<\\\"] = 0;\\n match[\\\">=\\\"] = 1;\\n match[\\\">\\\"] = 2;\\n match[\\\"<=\\\"] = 3;\\n l = -2 * INF;\\n r = 2 * INF;\\n}\\nint main() {\\n init();\\n int n;\\n scanf(\\\"%d\\\", &n);\\n int flag = 1;\\n for (int i = 0; i < n; i++) {\\n char op[3];\\n scanf(\\\"%s\\\", op);\\n int x;\\n scanf(\\\"%d\\\", &x);\\n char yes_no[2];\\n scanf(\\\"%s\\\", yes_no);\\n if (flag) {\\n gao(match[op] ^ (yes_no[0] == 'N'), x);\\n if (l > r) {\\n flag = 0;\\n }\\n }\\n }\\n if (flag) {\\n printf(\\\"%d\\\\n\\\", l);\\n } else {\\n printf(\\\"Impossible\\\\n\\\");\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nMoamen 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].\",\"targets\":\"#include \\nusing namespace std;\\nconst int Inf = 0x3f3f3f3f;\\nconst long long Lnf = 0x3f3f3f3f3f3f3f3f;\\ntemplate \\ninline T Min(T a, T b) {\\n return a < b ? a : b;\\n}\\ntemplate \\ninline T Max(T a, T b) {\\n return a > b ? a : b;\\n}\\ntemplate \\ninline T Abs(T x) {\\n return x > 0 ? x : -x;\\n}\\ntemplate \\ninline T GetMin(T tmp[], int l, int r) {\\n T res = Inf;\\n for (int i = l; i <= r; i++) res = min(res, tmp[i]);\\n return res;\\n}\\ntemplate \\ninline T GetMax(T tmp[], int l, int r) {\\n T res = -Inf;\\n for (int i = l; i <= r; i++) res = max(res, tmp[i]);\\n return res;\\n}\\ntemplate \\ninline T GetSum(T tmp[], int l, int r, int mod) {\\n long long sum = 0;\\n for (int i = l; i <= r; i++)\\n if (mod == -1)\\n sum += tmp[i];\\n else\\n sum = (sum + tmp) % mod;\\n return sum;\\n}\\ntemplate \\ninline void GetFrac(T tmp[], int l, int r, int mod) {\\n tmp[l - 1] = 1;\\n for (int i = l; i <= r; i++) tmp[i] = (tmp[i - 1] * i) % mod;\\n}\\ntemplate \\nvoid Print(T tmp[], int l, int r, int type) {\\n if (type == 1)\\n for (int i = l; i <= r; i++) cout << tmp[i] << ' ';\\n if (type == 2)\\n for (int i = l; i <= r; i++) cout << tmp[i];\\n if (type == 3)\\n for (int i = l; i <= r; i++) cout << tmp[i] << '\\\\n';\\n}\\ntemplate \\nvoid GetPrime(T prime[], bool vis[], int up, int &top) {\\n top = 0;\\n for (int i = 2; i <= up; i++) {\\n if (!vis[i]) prime[++top] = i;\\n for (int j = 1; j <= top && i * prime[j] <= up; j++) {\\n vis[i * prime[j]] = true;\\n if (i % prime[j] == 0) break;\\n }\\n }\\n}\\nvoid checkf(bool flag, string Y, string N) {\\n cout << ((flag == true) ? Y : N) << '\\\\n';\\n}\\nlong long qpow(long long x, long long p, long long mod) {\\n long long base = x, res = 1 % mod;\\n while (p != 0) {\\n if (p & 1) res = (res * base) % mod;\\n p >>= 1;\\n base = (base * base) % mod;\\n }\\n return res;\\n}\\nconst int Mod = 1e9 + 7;\\nconst int base = 131;\\nconst int maxn1 = 5e5 + 5;\\nconst int maxn2 = 5000 + 5;\\nconst int maxn3 = 500 + 5;\\nconst int len...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nInaka has a disc, the circumference of which is n units. The circumference is equally divided by n points numbered clockwise from 1 to n, such that points i and i + 1 (1 ≤ i < n) are adjacent, and so are points n and 1.\\n\\nThere are m straight segments on the disc, the endpoints of which are all among the aforementioned n points.\\n\\nInaka wants to know if her image is rotationally symmetrical, i.e. if there is an integer k (1 ≤ k < n), such that if all segments are rotated clockwise around the center of the circle by k units, the new image will be the same as the original one.\\n\\nInput\\n\\nThe first line contains two space-separated integers n and m (2 ≤ n ≤ 100 000, 1 ≤ m ≤ 200 000) — the number of points and the number of segments, respectively.\\n\\nThe i-th of the following m lines contains two space-separated integers a_i and b_i (1 ≤ a_i, b_i ≤ n, a_i ≠ b_i) that describe a segment connecting points a_i and b_i.\\n\\nIt is guaranteed that no segments coincide.\\n\\nOutput\\n\\nOutput one line — \\\"Yes\\\" if the image is rotationally symmetrical, and \\\"No\\\" otherwise (both excluding quotation marks).\\n\\nYou can output each letter in any case (upper or lower).\\n\\nExamples\\n\\nInput\\n\\n\\n12 6\\n1 3\\n3 7\\n5 7\\n7 11\\n9 11\\n11 3\\n\\n\\nOutput\\n\\n\\nYes\\n\\n\\nInput\\n\\n\\n9 6\\n4 5\\n5 6\\n7 8\\n8 9\\n1 2\\n2 3\\n\\n\\nOutput\\n\\n\\nYes\\n\\n\\nInput\\n\\n\\n10 3\\n1 2\\n3 2\\n7 2\\n\\n\\nOutput\\n\\n\\nNo\\n\\n\\nInput\\n\\n\\n10 2\\n1 6\\n2 7\\n\\n\\nOutput\\n\\n\\nYes\\n\\nNote\\n\\nThe first two examples are illustrated below. Both images become the same as their respective original ones after a clockwise rotation of 120 degrees around the center.\\n\\n\",\"targets\":\"#include \\nusing namespace std;\\nvoid print(long long int a[], long long int n) {\\n for (long long int i = 0; i < n; i++) {\\n cout << a[i] << \\\" \\\";\\n }\\n cout << endl;\\n}\\nlong long int m(long long int x) { return x % 1000000007; }\\nlong long int gcd(long long int a, long long int b) {\\n if (a == 0) return b;\\n return gcd(b % a, a);\\n}\\nlong long int p(long long int a, long long int b) {\\n if (b == 0) return 1;\\n long long int t = p(a, b \\/ 2);\\n if (b % 2 == 0)\\n return t * t;\\n else\\n return a * t * t;\\n}\\nlong long int spf[10000000] = {0};\\nvoid seive() {\\n for (long long int i = 2; i < 100009; i += 2) spf[i] = 2;\\n for (long long int i = 2; i < 100009; i++) {\\n if (spf[i] != 0) {\\n continue;\\n }\\n spf[i] = i;\\n for (long long int j = i; j * i < 100009; j++) {\\n if (spf[j * i] == 0) {\\n spf[j * i] = i;\\n }\\n }\\n }\\n}\\nvector get_p(long long int x) {\\n vector v;\\n if (x == 0 || x == 1) {\\n return v;\\n }\\n while (x > 1) {\\n v.push_back(spf[x]);\\n long long int y = spf[x];\\n while (x % y == 0) {\\n x = x \\/ y;\\n if (x == 1) {\\n break;\\n }\\n }\\n }\\n return v;\\n}\\nsigned main() {\\n seive();\\n long long int n, m;\\n cin >> n >> m;\\n vector vv;\\n vv = get_p(n);\\n vector > v;\\n for (long long int i = 0; i < m; i++) {\\n long long int x, y;\\n cin >> x >> y;\\n v.push_back({min(x, y), max(x, y)});\\n }\\n sort(v.begin(), v.end());\\n long long int u = 0;\\n for (long long int i = 0; i < vv.size(); i++) {\\n long long int x = n \\/ vv[i];\\n vector > vi;\\n long long int uu = 0;\\n for (long long int j = 0; j < m; j++) {\\n long long int y = (v[j].first - 1 + x) % n + 1;\\n long long int z = (v[j].second - 1 + x) % n + 1;\\n vi.push_back({min(y, z), max(y, z)});\\n }\\n sort(vi.begin(), vi.end());\\n for (long long int j = 0; j < m; j++) {\\n if (v[j].first != vi[j].first || v[j].second != vi[j].second) {\\n uu = 1;\\n ...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"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\":\"import java.io.*;\\nimport java.util.*;\\n\\npublic class Solution {\\n\\n \\/* -------------------------------------- Main Start ----------------------------------- *\\/\\n public static void main(String[] args) throws IOException {\\n FastReader fs = new FastReader();\\n StringBuilder sb = new StringBuilder();\\n int t = Integer.parseInt(fs.nextLine().trim());\\n while (t-- > 0) {\\n int n = fs.nextInt();\\n char[] enemy = fs.nextLine().toCharArray();\\n char[] player = fs.nextLine().toCharArray();\\n int count = 0;\\n int[] visited = new int[n];\\n Arrays.fill(visited, -1);\\n for (int i = 0; i < n; i++) {\\n if (enemy[i] == '0' && player[i] == '1') {\\n visited[i] = 1;\\n count++;\\n }\\n }\\n for (int i = n - 1; i >= 0; i--) {\\n if (player[i] == '1' && enemy[i] == '1') {\\n if (i + 1 < n && enemy[i + 1] == '1' && visited[i + 1] == -1) {\\n visited[i + 1] = 1;\\n count++;\\n } else if (i - 1 >= 0 && enemy[i - 1] == '1' && visited[i - 1] == -1) {\\n visited[i - 1] = 1;\\n count++;\\n }\\n }\\n }\\n System.out.println(count);\\n }\\n }\\n\\n \\/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- \\n \\n StringBuilder sb = new StringBuilder();\\n sb.append(x + \\\"\\\\n\\\");\\n \\n Collections.sort(arr, (a, b) -> Integer.compare(a[0], b[0]))\\n arr.toArray(new int[arr.size()][])\\n \\n *\\/\\n private static final int MOD_1 = 1000000000 + 7;\\n\\n static class FastReader {\\n\\n BufferedReader br;\\n StringTokenizer st;\\n\\n public FastReader() throws IOException {\\n br = new BufferedReader(new InputStreamReader(System.in));\\n }\\n\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"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} 0){\\n int n = in.nextInt() ;\\n int a[][] = new int[n][5] ;\\n\\n for (int i = 0; i a[i][j]){\\n cnt++ ;\\n }\\n if (cnt >= 3)better = i ;\\n }\\n }\\n for (int i = 0; i a[i][j]){\\n cnt++ ;\\n }\\n }\\n if (cnt >=3){\\n System.out.println(-1);\\n continue outer;\\n }\\n }\\n System.out.println(better+1);\\n\\n\\n }\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n out.flush();\\n out.close();\\n\\n }\\n \\/\\/ catch (Exception e){\\n \\/\\/ return;\\n \\/\\/ }\\n \\/\\/\\n \\/\\/ }\\n\\n static long gcd(long a, long b) {\\n return (b == 0) ? a : gcd(b, a % b);\\n }\\n\\n static int gcd(int a, int b) {\\n return (b == 0) ? a :...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Alice and Bob are playing a game on a line with n cells. There are n cells labeled from 1 through n. For each i from 1 to n-1, cells i and i+1 are adjacent.\\n\\nAlice initially has a token on some cell on the line, and Bob tries to guess where it is. \\n\\nBob guesses a sequence of line cell numbers x_1, x_2, …, x_k in order. In the i-th question, Bob asks Alice if her token is currently on cell x_i. That is, Alice can answer either \\\"YES\\\" or \\\"NO\\\" to each Bob's question.\\n\\nAt most one time in this process, before or after answering a question, Alice is allowed to move her token from her current cell to some adjacent cell. Alice acted in such a way that she was able to answer \\\"NO\\\" to all of Bob's questions.\\n\\nNote that Alice can even move her token before answering the first question or after answering the last question. Alice can also choose to not move at all.\\n\\nYou are given n and Bob's questions x_1, …, x_k. You would like to count the number of scenarios that let Alice answer \\\"NO\\\" to all of Bob's questions. \\n\\nLet (a,b) denote a scenario where Alice starts at cell a and ends at cell b. Two scenarios (a_i, b_i) and (a_j, b_j) are different if a_i ≠ a_j or b_i ≠ b_j.\\n\\nInput\\n\\nThe first line contains two integers n and k (1 ≤ n,k ≤ 10^5) — the number of cells and the number of questions Bob asked.\\n\\nThe second line contains k integers x_1, x_2, …, x_k (1 ≤ x_i ≤ n) — Bob's questions.\\n\\nOutput\\n\\nPrint a single integer, the number of scenarios that let Alice answer \\\"NO\\\" to all of Bob's questions.\\n\\nExamples\\n\\nInput\\n\\n\\n5 3\\n5 1 4\\n\\n\\nOutput\\n\\n\\n9\\n\\n\\nInput\\n\\n\\n4 8\\n1 2 3 4 4 3 2 1\\n\\n\\nOutput\\n\\n\\n0\\n\\n\\nInput\\n\\n\\n100000 1\\n42\\n\\n\\nOutput\\n\\n\\n299997\\n\\nNote\\n\\nThe notation (i,j) denotes a scenario where Alice starts at cell i and ends at cell j.\\n\\nIn the first example, the valid scenarios are (1, 2), (2, 1), (2, 2), (2, 3), (3, 2), (3, 3), (3, 4), (4, 3), (4, 5). For example, (3,4) is valid since Alice can start at cell 3, stay there for the first three questions, then move to cell 4 after the last question. \\n\\n(4,5) is valid since Alice can start at cell 4,...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int n, k, count = 0;\\n cin >> n >> k;\\n if (n == 1) {\\n cout << \\\"0\\\";\\n return 0;\\n }\\n bool vis[n + 1];\\n bool f[n + 1], b[n + 1];\\n memset(vis, false, (n + 1) * sizeof(vis[0]));\\n memset(f, false, (n + 1) * sizeof(vis[0]));\\n memset(b, false, (n + 1) * sizeof(vis[0]));\\n for (int i = 0; i < k; i++) {\\n int temp;\\n cin >> temp;\\n if (temp > 1)\\n if (vis[temp - 1] == true && b[temp] == false) {\\n count++;\\n b[temp] = true;\\n }\\n if (temp < n)\\n if (vis[temp + 1] == true && f[temp] == false) {\\n count++;\\n f[temp] = true;\\n }\\n if (vis[temp] == false) {\\n vis[temp] = true;\\n count++;\\n }\\n }\\n cout << (n * 3) - 2 - count;\\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.\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cout.tie(0);\\n cin.tie(0);\\n short a, b;\\n string c;\\n cin >> a;\\n while (cin >> c) {\\n a = b = 0;\\n for (char &i : c) i == '1' ? a++ : b++;\\n cout << (min(a, b) % 2 ? \\\"DA\\\\n\\\" : \\\"NET\\\\n\\\");\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"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\\nSolve the task in CPP.\",\"targets\":\"#include \\n#pragma GCC optimize(2)\\n#pragma GCC optimize(3)\\n#pragma GCC optimize(\\\"Ofast\\\")\\n#pragma GCC optimize(\\\"inline\\\")\\n#pragma GCC optimize(\\\"-fgcse\\\")\\n#pragma GCC optimize(\\\"-fgcse-lm\\\")\\n#pragma GCC optimize(\\\"-fipa-sra\\\")\\n#pragma GCC optimize(\\\"-ftree-pre\\\")\\n#pragma GCC optimize(\\\"-ftree-vrp\\\")\\n#pragma GCC optimize(\\\"-fpeephole2\\\")\\n#pragma GCC optimize(\\\"-ffast-math\\\")\\n#pragma GCC optimize(\\\"-fsched-spec\\\")\\n#pragma GCC optimize(\\\"unroll-loops\\\")\\n#pragma GCC optimize(\\\"-falign-jumps\\\")\\n#pragma GCC optimize(\\\"-falign-loops\\\")\\n#pragma GCC optimize(\\\"-falign-labels\\\")\\n#pragma GCC optimize(\\\"-fdevirtualize\\\")\\n#pragma GCC optimize(\\\"-fcaller-saves\\\")\\n#pragma GCC optimize(\\\"-fcrossjumping\\\")\\n#pragma GCC optimize(\\\"-fthread-jumps\\\")\\n#pragma GCC optimize(\\\"-funroll-loops\\\")\\n#pragma GCC optimize(\\\"-fwhole-program\\\")\\n#pragma GCC optimize(\\\"-freorder-blocks\\\")\\n#pragma GCC optimize(\\\"-fschedule-insns\\\")\\n#pragma GCC optimize(\\\"inline-functions\\\")\\n#pragma GCC optimize(\\\"-ftree-tail-merge\\\")\\n#pragma GCC optimize(\\\"-fschedule-insns2\\\")\\n#pragma GCC optimize(\\\"-fstrict-aliasing\\\")\\n#pragma GCC optimize(\\\"-fstrict-overflow\\\")\\n#pragma GCC optimize(\\\"-falign-functions\\\")\\n#pragma GCC optimize(\\\"-fcse-skip-blocks\\\")\\n#pragma GCC optimize(\\\"-fcse-follow-jumps\\\")\\n#pragma GCC optimize(\\\"-fsched-interblock\\\")\\n#pragma GCC optimize(\\\"-fpartial-inlining\\\")\\n#pragma GCC optimize(\\\"no-stack-protector\\\")\\n#pragma GCC optimize(\\\"-freorder-functions\\\")\\n#pragma GCC optimize(\\\"-findirect-inlining\\\")\\n#pragma GCC optimize(\\\"-fhoist-adjacent-loads\\\")\\n#pragma GCC optimize(\\\"-frerun-cse-after-loop\\\")\\n#pragma GCC optimize(\\\"inline-small-functions\\\")\\n#pragma GCC optimize(\\\"-finline-small-functions\\\")\\n#pragma GCC optimize(\\\"-ftree-switch-conversion\\\")\\n#pragma GCC optimize(\\\"-foptimize-sibling-calls\\\")\\n#pragma GCC optimize(\\\"-fexpensive-optimizations\\\")\\n#pragma GCC optimize(\\\"-funsafe-loop-optimizations\\\")\\n#pragma GCC optimize(\\\"inline-functions-called-once\\\")\\n#pragma GCC optimize(\\\"-fdelete-null-pointer-checks\\\")\\nusing namespace std;\\nlong long n, hf;\\nbool g[50][50];\\ninline void addedge(long long from, long long to) {\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"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.\\nimpor\",\"targets\":\"t java.util.*;\\nimport java.io.*;\\nimport java.math.*;\\n\\npublic class Coder {\\n static int n,k;\\n static long a[];\\n static StringBuffer str=new StringBuffer();\\n\\n static void solve() {\\n int l=Math.max(0, n-200);\\n long ans=Long.MIN_VALUE;\\n for(int i=l;i0) {\\n String s[]=bf.readLine().trim().split(\\\"\\\\\\\\s+\\\");\\n n=Integer.parseInt(s[0]);\\n k=Integer.parseInt(s[1]);\\n a=new long[n];\\n s=bf.readLine().trim().split(\\\"\\\\\\\\s+\\\");\\n for(int i=0;i\\nconst int N = 505;\\nconst int p = 998244353;\\nlong long a[N][N];\\nlong long b[N][N];\\nlong long c[N][N];\\nint main() {\\n std::ios::sync_with_stdio(false);\\n std::cin.tie(nullptr);\\n for (int i = 0; i <= 500; i++) {\\n c[i][0] = 1;\\n for (int j = 1; j <= i; j++) c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % p;\\n }\\n for (int i = 1; i <= 500; i++) {\\n b[i][1] = i;\\n for (int j = 2; j <= 500; j++) b[i][j] = b[i][j - 1] * i % p;\\n }\\n for (int i = 1; i <= 500; i++) {\\n a[i][1] = i;\\n for (int j = 2; j <= i; j++)\\n for (long long k = j, x = 1; k; k--, x = x * (j - 1) % p)\\n a[i][j] = (a[i][j] + a[i - j + 1][k] * c[j][j - k] % p * x) % p;\\n }\\n int n, m;\\n while (std::cin >> n >> m) std::cout << (b[m][n] - a[m][n] + p) % p << '\\\\n';\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"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.\\nUsing java can you solve the prior task?\",\"targets\":\"import java.io.OutputStream;\\nimport java.io.IOException;\\nimport java.io.InputStream;\\nimport java.io.OutputStream;\\nimport java.io.PrintStream;\\nimport java.io.IOException;\\nimport java.lang.reflect.Field;\\nimport java.nio.charset.StandardCharsets;\\nimport java.io.UncheckedIOException;\\nimport java.io.Closeable;\\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) throws Exception {\\n Thread thread = new Thread(null, new TaskAdapter(), \\\"\\\", 1 << 29);\\n thread.start();\\n thread.join();\\n }\\n\\n static class TaskAdapter implements Runnable {\\n @Override\\n public void run() {\\n InputStream inputStream = System.in;\\n OutputStream outputStream = System.out;\\n FastInput in = new FastInput(inputStream);\\n FastOutput out = new FastOutput(outputStream);\\n CCompressedBracketSequence solver = new CCompressedBracketSequence();\\n solver.solve(1, in, out);\\n out.close();\\n }\\n }\\n\\n static class CCompressedBracketSequence {\\n Debug debug = new Debug(false);\\n\\n public void solve(int testNumber, FastInput in, FastOutput out) {\\n int n = in.ri();\\n long[] c = in.rl(n);\\n long ans = 0;\\n for (int i = 0; i < n; i++) {\\n if (i % 2 == 1) {\\n continue;\\n }\\n long l = 1;\\n long r = c[i];\\n long local = 0;\\n for (int j = i + 1; j < n && r >= 0; j++) {\\n if (j % 2 == 0) {\\n l += c[j];\\n r += c[j];\\n } else {\\n l -= c[j];\\n r -= c[j];\\n if (l <= 0) {\\n if (r >= 0) {\\n local += -l + 1;\\n } else {\\n local += r - l + 1;\\n ...\",\"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...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nvoid read(vector &a) {\\n for (long long i = 0; i < a.size(); i++) cin >> a[i];\\n}\\nvoid read(vector &a) {\\n for (long long i = 0; i < a.size(); i++) cin >> a[i];\\n}\\nbool intersect(pair c, pair d) {\\n if (c.first > d.first) swap(c, d);\\n return c.second > d.first and c.second < d.second;\\n}\\nvoid solve() {\\n long long n, k;\\n cin >> n >> k;\\n vector> a;\\n vector used(2 * n + 1, false);\\n for (long long i = 0; i < k; i++) {\\n long long x, y;\\n cin >> x >> y;\\n if (x < y)\\n a.push_back({x, y});\\n else\\n a.push_back({y, x});\\n used[x] = used[y] = true;\\n }\\n vector left;\\n for (long long i = 1; i <= 2 * n; i++) {\\n if (!used[i]) left.push_back(i);\\n }\\n for (long long i = 0; i < n - k; i++) {\\n a.push_back({left[i], left[n - k + i]});\\n }\\n long long ans = 0;\\n for (long long i = 0; i < n; i++) {\\n for (long long j = i + 1; j < n; j++) {\\n if (intersect(a[i], a[j])) ans++;\\n }\\n }\\n cout << ans << \\\"\\\\n\\\";\\n}\\nint32_t main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n long long t = 1;\\n cin >> t;\\n while (t--) {\\n solve();\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"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...\",\"targets\":\"testn = input()\\n\\ntests = []\\n\\nfor n in range(0,int(testn)):\\n tests += [input()]\\n\\ndef check_done(s1,s2,k1,k2):\\n return (s1 > s2 + k2) or (s2 > s1 + k1)\\n\\ndef odd(n):\\n return (n % 2) != 0\\n\\ndef t1 (test):\\n s1 = 0\\n s2 = 0\\n k1 = 5\\n k2 = 5\\n n = 1\\n for x in test:\\n if odd(n):\\n if x == \\\"1\\\" or x == \\\"?\\\":\\n s1 += 1\\n k1 += -1\\n else:\\n k1 += -1\\n else:\\n if x == \\\"1\\\":\\n s2 += 1\\n k2 += -1\\n else:\\n k2 += -1\\n if check_done(s1,s2,k1,k2) == True:\\n return n\\n n += 1\\n return 10\\n\\ndef t2 (test):\\n s1 = 0\\n s2 = 0\\n k1 = 5\\n k2 = 5\\n n = 1\\n for x in test:\\n if odd(n):\\n if x == \\\"1\\\":\\n s1 += 1\\n k1 += -1\\n else:\\n k1 += -1\\n else:\\n if x == \\\"1\\\" or x == \\\"?\\\":\\n s2 += 1\\n k2 += -1\\n else:\\n k2 += -1\\n if check_done(s1,s2,k1,k2) == True:\\n return n\\n n += 1\\n return 10\\n\\nfor test in tests:\\n print (min([t1(test),t2(test)]))\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"AtCoder currently hosts three types of contests: ABC, ARC, and AGC. As the number of users has grown, in order to meet the needs of more users, AtCoder has decided to increase the number of contests to 26 types, from AAC to AZC. For convenience, we number these 26 types as type 1 through type 26. AtCoder wants to schedule contests for D days so that user satisfaction is as high as possible. For every day, AtCoder will hold exactly one contest, and each contest will end on that day. The satisfaction is calculated as follows.\\n\\n* The satisfaction at the beginning of day 1 is 0. Satisfaction can be negative.\\n* Holding contests increases satisfaction. The amount of increase will vary depending on a variety of factors. Specifically, we know in advance that holding a contest of type i on day d will increase the satisfaction by s_{d,i}.\\n* If a particular type of contest is not held for a while, the satisfaction decreases. Each contest type i has an integer c_i, and at the end of each day d=1,2,...,D, the satisfaction decreases as follows. Let \\\\mathrm{last}(d,i) be the last day before day d (including d) on which a contest of type i was held. If contests of type i have never been held yet, we define \\\\mathrm{last}(d,i)=0. At the end of day d, the satisfaction decreases by \\\\sum _{i=1}^{26}c_i \\\\times (d-\\\\mathrm{last}(d,i)).\\n\\n\\n\\nPlease schedule contests on behalf of AtCoder. If the satisfaction at the end of day D is S, you will get a score of \\\\max(10^6 + S, 0). There are 50 test cases, and the score of a submission is the total scores for each test case. You can make submissions multiple times, and the highest score among your submissions will be your score.\\n\\nConstraints\\n\\n* D = 365\\n* Each c_i is an integer satisfying 0\\\\leq c_i \\\\leq 100.\\n* Each s_{d,i} is an integer satisfying 0\\\\leq s_{d,i} \\\\leq 20000.\\n\\nInput\\n\\nInput is given from Standard Input in the following format:\\n\\n\\nD\\nc_1 c_2 \\\\cdots c_{26}\\ns_{1,1} s_{1,2} \\\\cdots s_{1,26}\\n\\\\vdots\\ns_{D,1} s_{D,2} \\\\cdots s_{D,26}\\n\\n\\nOutput\\n\\nLet t_d (1\\\\leq t_d \\\\leq 26) be the type of the...\\nSolve the task in CPP.\",\"targets\":\"#include\\nusing namespace std;\\n\\nint main() {\\n int n;\\n cin >> n;\\n int c[26], s[n][26];\\n for (int i = 0; i < 26; ++i)\\n cin >> c[i];\\n for (int i = 0; i < n; ++i)\\n for (int j = 0; j < 26; ++j)\\n cin >> s[i][j];\\n for (int i = 0; i < n - 1; ++i)\\n cout << distance(s[i], max_element(s[i], s[i] + 26)) + 1 << endl;\\n cout << distance(s[n-1], max_element(s[n-1], s[n-1] + 26)) + 1;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"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) =...\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nvoid solve() {\\n int n;\\n cin >> n;\\n vector elements(n);\\n for (auto &i : elements) {\\n cin >> i;\\n }\\n double m = *max_element(elements.begin(), elements.end());\\n for (auto &i : elements) {\\n i \\/= (n - 1);\\n }\\n double s = accumulate(elements.begin(), elements.end(), 0.0);\\n s -= m \\/ (n - 1);\\n std::fixed(cout);\\n cout.precision(10);\\n cout << (m + s) << endl;\\n}\\nint main() {\\n iostream::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n int t;\\n cin >> t;\\n for (int i = 0; i < t; ++i) {\\n solve();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Duff is in love with lovely numbers! A positive integer x is called lovely if and only if there is no such positive integer a > 1 such that a2 is a divisor of x.\\n\\n\\n\\nMalek has a number store! In his store, he has only divisors of positive integer n (and he has all of them). As a birthday present, Malek wants to give her a lovely number from his store. He wants this number to be as big as possible.\\n\\nMalek always had issues in math, so he asked for your help. Please tell him what is the biggest lovely number in his store.\\n\\nInput\\n\\nThe first and only line of input contains one integer, n (1 ≤ n ≤ 1012).\\n\\nOutput\\n\\nPrint the answer in one line.\\n\\nExamples\\n\\nInput\\n\\n10\\n\\n\\nOutput\\n\\n10\\n\\n\\nInput\\n\\n12\\n\\n\\nOutput\\n\\n6\\n\\nNote\\n\\nIn first sample case, there are numbers 1, 2, 5 and 10 in the shop. 10 isn't divisible by any perfect square, so 10 is lovely.\\n\\nIn second sample case, there are numbers 1, 2, 3, 4, 6 and 12 in the shop. 12 is divisible by 4 = 22, so 12 is not lovely, while 6 is indeed lovely.\",\"targets\":\"n = int(input())\\ni = 2\\nwhile i * i <= n:\\n while n % (i * i) == 0:\\n n \\/= i\\n i += 1\\nprint n\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nOnce a walrus professor Plato asked his programming students to perform the following practical task. \\n\\nThe students had to implement such a data structure that would support a convex hull on some set of points S. The input to the program had q queries of two types: \\n\\n1. Add a point with coordinates (x, y) into the set S. Note that in this case the convex hull of S could have changed, and could have remained the same. \\n\\n2. Say whether a point with coordinates (x, y) belongs to an area limited by the convex hull, including the border. \\n\\nAll the students coped with the task. What about you?\\n\\nInput\\n\\nThe first line contains an integer q (4 ≤ q ≤ 105). \\n\\nThen follow q lines in the following way: \\\"t x y\\\", where t is the query type (1 or 2), and (x, y) are the coordinates of the point ( - 106 ≤ x, y ≤ 106, x and y are integers). \\n\\nThere is at least one query of type 2.\\n\\nIt is guaranteed that the three queries of the first type follow first and the points given in the queries form a non-degenerative triangle. Also all the points added in S are distinct.\\n\\nOutput\\n\\nFor each query of the second type print one string containing \\\"YES\\\", if the point lies inside the convex hull or on its border. Otherwise, print \\\"NO\\\".\\n\\nExamples\\n\\nInput\\n\\n8\\n1 0 0\\n1 2 0\\n1 2 2\\n2 1 0\\n1 0 2\\n2 1 1\\n2 2 1\\n2 20 -1\\n\\n\\nOutput\\n\\nYES\\nYES\\nYES\\nNO\",\"targets\":\"#include \\nusing namespace std;\\ninline int read() {\\n int w = 0, x = 0;\\n char c = getchar();\\n while (!isdigit(c)) w |= c == '-', c = getchar();\\n while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar();\\n return w ? -x : x;\\n}\\nnamespace star {\\nconst int maxn = 2e5 + 10;\\nint n;\\nstruct vec {\\n int x, y;\\n vec(int _x = 0, int _y = 0) : x(_x), y(_y) {}\\n vec(pair a) : x(a.first), y(a.second) {}\\n vec operator+(const vec &a) const { return vec(x + a.x, y + a.y); }\\n vec operator-(const vec &a) const { return vec(x - a.x, y - a.y); }\\n} e[maxn];\\ninline long long cp(vec a, vec b) { return 1ll * a.x * b.y - 1ll * a.y * b.x; }\\nmap convex[2];\\nmap::iterator l, r, l2, r2;\\ninline bool query(map &q, int x, int y) {\\n if (q.empty() or x < q.begin()->first or q.rbegin()->first < x) return false;\\n if (q.find(x) != q.end()) return y >= q[x];\\n l = r = q.lower_bound(x), --l;\\n return cp(vec(*r) - vec(*l), vec(x, y) - vec(*l)) >= 0;\\n}\\ninline void insert(map &q, int x, int y) {\\n if (query(q, x, y)) return;\\n q[x] = y;\\n r = q.upper_bound(x);\\n if (r != q.end()) {\\n r2 = r, ++r2;\\n while (r2 != q.end())\\n if (cp(vec(*r2) - vec(x, y), vec(*r) - vec(x, y)) >= 0)\\n q.erase(r), r = r2, ++r2;\\n else\\n break;\\n }\\n l = q.lower_bound(x);\\n if (l == q.begin()) return;\\n --l;\\n if (l == q.begin()) return;\\n l2 = l, --l2;\\n while (l != q.begin())\\n if (cp(vec(x, y) - vec(*l2), vec(*l) - vec(*l2)) >= 0)\\n q.erase(l), l = l2, l2--;\\n else\\n break;\\n}\\ninline void work() {\\n n = read();\\n for (int x, y, i = 1; i <= n; i++)\\n if (read() == 1)\\n x = read(), y = read(), insert(convex[0], x, y), insert(convex[1], x, -y);\\n else\\n x = read(), y = read(),\\n puts(query(convex[0], x, y) & query(convex[1], x, -y) ? \\\"YES\\\" : \\\"NO\\\");\\n}\\n} \\/\\/ namespace star\\nsigned main() {\\n star::work();\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A robber has attempted to rob a bank but failed to complete his task. However, he had managed to open all the safes.\\n\\nOleg the bank client loves money (who doesn't), and decides to take advantage of this failed robbery and steal some money from the safes. There are many safes arranged in a line, where the i-th safe from the left is called safe i. There are n banknotes left in all the safes in total. The i-th banknote is in safe xi. Oleg is now at safe a. There are two security guards, one of which guards the safe b such that b < a, i.e. the first guard is to the left of Oleg. The other guard guards the safe c so that c > a, i.e. he is to the right of Oleg.\\n\\nThe two guards are very lazy, so they do not move. In every second, Oleg can either take all the banknotes from the current safe or move to any of the neighboring safes. However, he cannot visit any safe that is guarded by security guards at any time, becaues he might be charged for stealing. Determine the maximum amount of banknotes Oleg can gather.\\n\\nInput\\n\\nThe first line of input contains three space-separated integers, a, b and c (1 ≤ b < a < c ≤ 109), denoting the positions of Oleg, the first security guard and the second security guard, respectively.\\n\\nThe next line of input contains a single integer n (1 ≤ n ≤ 105), denoting the number of banknotes.\\n\\nThe next line of input contains n space-separated integers x1, x2, ..., xn (1 ≤ xi ≤ 109), denoting that the i-th banknote is located in the xi-th safe. Note that xi are not guaranteed to be distinct.\\n\\nOutput\\n\\nOutput a single integer: the maximum number of banknotes Oleg can take.\\n\\nExamples\\n\\nInput\\n\\n5 3 7\\n8\\n4 7 5 5 3 6 2 8\\n\\n\\nOutput\\n\\n4\\n\\n\\nInput\\n\\n6 5 7\\n5\\n1 5 7 92 3\\n\\n\\nOutput\\n\\n0\\n\\nNote\\n\\nIn the first example Oleg can take the banknotes in positions 4, 5, 6 (note that there are 2 banknotes at position 5). Oleg can't take the banknotes in safes 7 and 8 because he can't run into the second security guard. Similarly, Oleg cannot take the banknotes at positions 3 and 2 because he can't run into the first security...\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.util.Scanner;\\n\\n\\npublic class test {\\n\\npublic static void main(String[] args){\\n\\tScanner sc=new Scanner(System.in);\\n\\tlong a=sc.nextLong();\\n\\tlong b=sc.nextLong();\\n\\tlong c=sc.nextLong();\\n\\tlong d=sc.nextLong();\\n\\tlong h=0;\\n\\tfor(int i=0;ib&&z\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nvoid solve() {\\n int n, m;\\n cin >> n >> m;\\n vector arr(n);\\n unordered_map map;\\n for (int i{0}; i < n; i++) {\\n cin >> arr[i];\\n map[arr[i]] = i;\\n }\\n auto cmp{[](string &s1, string &s2) {\\n for (int i{0}; i < s1.length(); i++)\\n if (s1[i] != s2[i]) {\\n if (i % 2 != 0)\\n return s1[i] > s2[i];\\n else\\n return s1[i] < s2[i];\\n }\\n return s1 == s2;\\n }};\\n sort(arr.begin(), arr.end(), cmp);\\n for (auto &s : arr) cout << map[s] + 1 << ' ';\\n}\\nint main() {\\n solve();\\n cout << '\\\\n';\\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...\",\"targets\":\"sr=lambda: input()\\nir=lambda: int(sr())\\nlr=lambda: list(map(int, sr().split()))\\n\\n# dr=lambda: float(sr())\\n# dlr=lambda: list(map(float, 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 n=ir()\\n LR=[lr() for i in range(n)]\\n LR.sort(key=lambda x: x[1]-x[0])\\n\\n data=[0]*(n+1)\\n def add(k, x):\\n while k<=n:\\n data[k]+=x\\n k+=k & -k\\n def get(k):\\n s=0\\n while k:\\n s+=data[k]\\n k-=k & -k\\n return s\\n N0=2**(n-1).bit_length()\\n def lower_bound(x):\\n w=i=0\\n k=N0\\n while k:\\n if i+k<=n and w+data[i+k]<=x:\\n w+=data[i+k]\\n i+=k\\n k>>=1\\n return i+1\\n\\n for num in range(n):\\n add(num+1, 1)\\n ans=[]\\n for l,r in LR:\\n min_num = lower_bound(get(l-1))\\n ans.append([l,r,min_num])\\n add(min_num, -1)\\n for l,r,x in ans:\\n print(l,r,x)\\n print()\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"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).\\nUsing python can you solve the prior task?\",\"targets\":\"n,m=map(int,raw_input().split())\\nans=0\\nwhile (n+m)>=3 and n>=1 and m>=1:\\n if n>=m:\\n if n>=2 and m>=1:\\n ans+=1\\n n-=2\\n m-=1\\n else:\\n if m>=2 and n>=1:\\n ans+=1\\n m-=2\\n n-=1\\nprint ans\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?\\n\\nThe book contains a single string of characters \\\"a\\\", \\\"b\\\" and \\\"c\\\". It has been pointed out that no two consecutive characters are the same. It has also been conjectured that the string contains an unusually long subsequence that reads the same from both sides. \\n\\nHelp Alice verify this by finding such subsequence that contains at least half of the characters of the original string, rounded down. Note that you don't have to maximise the length of it.\\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) characters.\\n\\nInput\\n\\nThe input consists of a single string s (2 ≤ |s| ≤ 10^6). The string s consists only of characters \\\"a\\\", \\\"b\\\", \\\"c\\\". It is guaranteed that no two consecutive characters are equal.\\n\\nOutput\\n\\nOutput a palindrome t that is a subsequence of s and |t| ≥ ⌊ (|s|)\\/(2) ⌋.\\n\\nIf there are multiple solutions, you may print any of them. You don't have to maximise the length of t.\\n\\nIf there are no solutions, output a string \\\"IMPOSSIBLE\\\" (quotes for clarity).\\n\\nExamples\\n\\nInput\\n\\n\\ncacbac\\n\\n\\nOutput\\n\\n\\naba\\n\\n\\nInput\\n\\n\\nabc\\n\\n\\nOutput\\n\\n\\na\\n\\n\\nInput\\n\\n\\ncbacacacbcbababacbcb\\n\\n\\nOutput\\n\\n\\ncbaaacbcaaabc\\n\\nNote\\n\\nIn the first example, other valid answers include \\\"cacac\\\", \\\"caac\\\", \\\"aca\\\" and \\\"ccc\\\". \\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 Egor Kulikov (egor@egork.net)\\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 TaskE solver = new TaskE();\\n solver.solve(1, in, out);\\n out.close();\\n }\\n\\n static class TaskE {\\n public void solve(int testNumber, InputReader in, OutputWriter out) {\\n String s = in.readString();\\n int l = 0;\\n int r = s.length() - 1;\\n boolean[] include = new boolean[s.length()];\\n while (l <= r) {\\n if (s.charAt(l) == s.charAt(r)) {\\n include[l] = true;\\n include[r] = true;\\n l++;\\n r--;\\n } else if (s.charAt(l) == s.charAt(r - 1)) {\\n include[l] = true;\\n include[r - 1] = true;\\n l++;\\n r -= 2;\\n } else if (s.charAt(l + 1) == s.charAt(r)) {\\n include[l + 1] = true;\\n include[r] = true;\\n l += 2;\\n r--;\\n } else {\\n include[l + 1] = true;\\n include[r - 1] = true;\\n l += 2;\\n r -= 2;\\n }\\n }\\n StringBuilder answer = new StringBuilder();\\n for (int i = 0; i < s.length(); i++) {\\n if (include[i]) {\\n ...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"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 =...\\nSolve the task in CPP.\",\"targets\":\"#include \\nconst long long int sz = 2 * 1e5 + 5;\\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 k;\\n cin >> k;\\n string s;\\n cin >> s;\\n long long int c = 0;\\n char ch;\\n map m;\\n long long int a[21] = {11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47,\\n 53, 59, 61, 67, 71, 73, 89, 83, 89, 97};\\n for (auto it : s) {\\n if ((it) == '1' || it == '4' || it == '6' || it == '8' || it == '9') {\\n ch = it;\\n c++;\\n }\\n m[it]++;\\n }\\n if (c) {\\n cout << 1 << \\\"\\\\n\\\";\\n cout << ch << \\\"\\\\n\\\";\\n } else if (m['2'] > 1) {\\n cout << 2 << \\\"\\\\n\\\";\\n cout << 22 << \\\"\\\\n\\\";\\n } else if (m['3'] > 1) {\\n cout << 2 << \\\"\\\\n\\\";\\n cout << 33 << \\\"\\\\n\\\";\\n } else if (m['5'] > 1) {\\n cout << 2 << \\\"\\\\n\\\";\\n cout << 55 << \\\"\\\\n\\\";\\n } else if (m['7'] > 1) {\\n cout << 2 << \\\"\\\\n\\\";\\n cout << 77 << \\\"\\\\n\\\";\\n } else {\\n long long int ans = -1;\\n for (long long int i = 0; i < k; i++) {\\n for (long long int j = i + 1; j < k; j++) {\\n long long int num = (s[i] - '0') * 10 + s[j] - '0';\\n if (!binary_search(a, a + 21, num)) {\\n ans = num;\\n break;\\n }\\n }\\n if (ans != -1) break;\\n }\\n cout << 2 << \\\"\\\\n\\\";\\n cout << ans << \\\"\\\\n\\\";\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"This is an interactive problem. The only difference between the easy and hard version is the limit on number of questions.\\n\\nThere are n players labelled from 1 to n. It is guaranteed that n is a multiple of 3.\\n\\nAmong them, there are k impostors and n-k crewmates. The number of impostors, k, is not given to you. It is guaranteed that n\\/3 < k < 2n\\/3.\\n\\nIn each question, you can choose three distinct integers a, b, c (1 ≤ a, b, c ≤ n) and ask: \\\"Among the players labelled a, b and c, are there more impostors or more crewmates?\\\" You will be given the integer 0 if there are more impostors than crewmates, and 1 otherwise.\\n\\nFind the number of impostors k and the indices of players that are impostors after asking at most n+6 questions.\\n\\nThe jury is adaptive, which means the indices of impostors may not be fixed beforehand and can depend on your questions. It is guaranteed that there is at least one set of impostors which fulfills the constraints and the answers to your questions at any 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 and only line of each test case contains a single integer n (6 ≤ n < 10^4, n is a multiple of 3) — the number of players.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^4.\\n\\nInteraction\\n\\nFor each test case, the interaction starts with reading n.\\n\\nThen you are allowed to make at most n+6 questions in the following way:\\n\\n\\\"? a b c\\\" (1 ≤ a, b, c ≤ n, a, b and c are pairwise distinct).\\n\\nAfter each one, you should read an integer r, which is equal to 0 if there are more impostors than crewmates among players labelled a, b and c, and equal to 1 otherwise.\\n\\nAnswer -1 instead of 0 or 1 means that you made an invalid query. Exit immediately after receiving -1 and you will see Wrong answer verdict. Otherwise you can get an arbitrary verdict because your solution will continue to read from a closed stream.\\n\\nWhen you have found the indices of all...\\nimpor\",\"targets\":\"t java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.util.StringTokenizer;\\n\\npublic class d2 {\\n\\tpublic static void main(String[] args) {\\n\\t\\tscan=new FastScanner();\\n\\t\\tint t=scan.nextInt();\\n\\t\\tfor(int tt=0;tt=lo&&crewmate<=hi)||(imposter>=lo&&imposter<=hi)) {\\n\\t\\t\\t\\t\\tfor(int x=lo;x<=hi;x++) {\\n\\t\\t\\t\\t\\t\\tif(x==crewmate||x==imposter) continue;\\n\\t\\t\\t\\t\\t\\tint r=q(x,crewmate,imposter);\\n\\t\\t\\t\\t\\t\\tif(r==-1) return;\\n\\t\\t\\t\\t\\t\\tisImposter[x]=(r==0);\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\telse if(groupType[i]==0) {\\n\\t\\t\\t\\t\\t\\/\\/imposter group\\n\\t\\t\\t\\t\\tint r=q(lo,lo+1,crewmate);\\n\\t\\t\\t\\t\\tif(r==-1) return;\\n\\t\\t\\t\\t\\tif(r==0) {\\n\\t\\t\\t\\t\\t\\t\\/\\/they are both imposters (and lo+2 may or may not be)\\n\\t\\t\\t\\t\\t\\tisImposter[lo]=isImposter[lo+1]=true;\\n\\t\\t\\t\\t\\t\\tr=q(imposter,crewmate,lo+2);\\n\\t\\t\\t\\t\\t\\tif(r==-1) continue;\\n\\t\\t\\t\\t\\t\\tisImposter[lo+2]=(r==0);\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\telse {\\n\\t\\t\\t\\t\\t\\t\\/\\/exactly one of them is an imposter and lo+2 is an imposter\\n\\t\\t\\t\\t\\t\\tisImposter[lo+2]=true;\\n\\t\\t\\t\\t\\t\\tr=q(imposter,crewmate,lo);\\n\\t\\t\\t\\t\\t\\tif(r==-1) continue;\\n\\t\\t\\t\\t\\t\\tif(r==0) isImposter[lo]=true;\\n\\t\\t\\t\\t\\t\\telse isImposter[lo+1]=true;\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\telse {\\n\\t\\t\\t\\t\\t\\/\\/crewmate group\\n\\t\\t\\t\\t\\tint r=q(lo,lo+1,imposter);\\n\\t\\t\\t\\t\\tif(r==-1) return;\\n\\t\\t\\t\\t\\tif(r==1) {\\n\\t\\t\\t\\t\\t\\t\\/\\/they are both...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"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...\\nSolve the task in JAVA.\",\"targets\":\"import java.util.*;\\n\\npublic class PoisonedDagger{\\n\\tpublic static void main(String args[]){\\n\\t\\tScanner sc = new Scanner(System.in);\\n\\t\\tint test = sc.nextInt();\\n\\t\\twhile(test-- > 0){\\n\\t\\t\\tint n = sc.nextInt();\\n long h = sc.nextLong();\\n long arr [] = new long[n];\\n \\/\\/ Initialise the array.\\n for(int i = 0;i < n;i ++){\\n arr[i] = sc.nextInt();\\n }\\n long low = 1;\\n long high = h;\\n long ans = 0;\\n while(low <= high){\\n long mid = (low +high)\\/2;\\n\\n if(isPossible(arr,mid, h)){\\n ans = mid;\\n high = mid - 1;\\n }\\n else{\\n low = mid + 1;\\n }\\n }\\n System.out.println(ans);\\t\\t\\n }\\n sc.close();\\n\\t}\\n public static boolean isPossible(long arr[], long mid, long h){\\n long count = 0;\\n for(int i = 1 ; i < arr.length;i++){\\n count = arr[i] - arr[i-1] >= mid ? count + mid: count + (arr[i] - arr[i-1]);\\n }\\n count+= mid;\\n if(count>= h) return true;\\n return false;\\n }\\n\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"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\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nlong double eps = 1e-12, X = 1.0;\\nlong long nCr(long long n, long long r) {\\n if (r > n) return 0;\\n if (r == 1) return n;\\n if (r == 2) return n * (n - 1) \\/ 2;\\n if (r == 3) return n * (n - 1) * (n - 2) \\/ 6;\\n return 0;\\n}\\nlong double fun(int m, int n) {\\n int r = n - m;\\n long double a = 0, b = 0;\\n if (r >= 3) a = nCr(r, 3) * X \\/ nCr(n, 3);\\n if (r >= 2 and m >= 1) {\\n long double p = (nCr(r, 2) * X * m \\/ nCr(n, 3));\\n p *= (X \\/ 2);\\n b = p;\\n }\\n return X - (a + b);\\n}\\nint main() {\\n int n;\\n long double p;\\n cin >> n >> p;\\n for (int i = 0; i <= n; i++) {\\n if (abs(fun(i, n)) + eps >= p) {\\n cout << i;\\n return 0;\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nFor some time the program of rounding numbers that had been developed by the Codeforces participants during one of the previous rounds, helped the citizens of Far Far Away to convert numbers into a more easily readable format. However, as time went by, the economy of the Far Far Away developed and the scale of operations grew. So the King ordered to found the Bank of Far Far Away and very soon even the rounding didn't help to quickly determine even the order of the numbers involved in operations. Besides, rounding a number to an integer wasn't very convenient as a bank needed to operate with all numbers with accuracy of up to 0.01, and not up to an integer.\\n\\nThe King issued yet another order: to introduce financial format to represent numbers denoting amounts of money. The formal rules of storing a number in the financial format are as follows: \\n\\n * A number contains the integer part and the fractional part. The two parts are separated with a character \\\".\\\" (decimal point). \\n * To make digits in the integer part of a number easier to read, they are split into groups of three digits, starting from the least significant ones. The groups are separated with the character \\\",\\\" (comma). For example, if the integer part of a number equals 12345678, then it will be stored in the financial format as 12,345,678 \\n * In the financial format a number's fractional part should contain exactly two digits. So, if the initial number (the number that is converted into the financial format) contains less than two digits in the fractional part (or contains no digits at all), it is complemented with zeros until its length equals 2. If the fractional part contains more than two digits, the extra digits are simply discarded (they are not rounded: see sample tests). \\n * When a number is stored in the financial format, the minus sign is not written. Instead, if the initial number had the minus sign, the result is written in round brackets. \\n * Please keep in mind that the bank of Far Far Away operates using an exotic foreign...\",\"targets\":\"#include \\nusing namespace std;\\nint main(void) {\\n string s;\\n cin >> s;\\n bool f = false;\\n int y = 3;\\n string w = s;\\n if (s.find('.') != -1) {\\n w = w.substr(s.find('.') + 1);\\n s = s.substr(0, s.find('.'));\\n if (s[0] == '-') {\\n f = true;\\n s.erase(0, 1);\\n }\\n if (s.size() > 3) {\\n reverse(s.begin(), s.end());\\n int t = s.size();\\n int i = 0;\\n while (t > 3) {\\n s.insert(i + 3, \\\",\\\");\\n i = i + 4;\\n t -= 3;\\n }\\n reverse(s.begin(), s.end());\\n if (w.size() < 2 && !f) {\\n cout << \\\"$\\\" << s << \\\".\\\" << w << \\\"0\\\";\\n } else if (w.size() >= 2 && !f) {\\n cout << \\\"$\\\" << s << \\\".\\\" << w.substr(0, 2);\\n } else if (w.size() >= 2 && f) {\\n cout << \\\"(\\\"\\n << \\\"$\\\" << s << \\\".\\\" << w.substr(0, 2) << \\\")\\\";\\n } else if (w.size() < 2 && f) {\\n cout << \\\"(\\\"\\n << \\\"$\\\" << s << \\\".\\\" << w << \\\"0\\\"\\n << \\\")\\\";\\n }\\n } else {\\n if (w.size() < 2 && !f) {\\n cout << \\\"$\\\" << s << \\\".\\\" << w << \\\"0\\\";\\n } else if (w.size() >= 2 && !f) {\\n cout << \\\"$\\\" << s << \\\".\\\" << w.substr(0, 2);\\n } else if (w.size() >= 2 && f) {\\n cout << \\\"(\\\"\\n << \\\"$\\\" << s << \\\".\\\" << w.substr(0, 2) << \\\")\\\";\\n } else if (w.size() < 2 && f) {\\n cout << \\\"(\\\"\\n << \\\"$\\\" << s << \\\".\\\" << w << \\\"0\\\"\\n << \\\")\\\";\\n }\\n }\\n } else {\\n if (s[0] == '-') {\\n f = true;\\n s.erase(0, 1);\\n }\\n if (s.size() > 3) {\\n reverse(s.begin(), s.end());\\n int t = s.size();\\n int i = 0;\\n while (t > 3) {\\n s.insert(i + 3, \\\",\\\");\\n i = i + 4;\\n t -= 3;\\n }\\n reverse(s.begin(), s.end());\\n if (w.size() < 2 && !f) {\\n cout << \\\"$\\\" << s << \\\".\\\"\\n << \\\"0\\\"\\n << \\\"0\\\";\\n } else if (w.size() >= 2 && !f) {\\n cout << \\\"$\\\" << s << \\\".\\\"\\n << \\\"00\\\";\\n } else if (w.size() >= 2 && f) {\\n cout << \\\"(\\\"\\n << \\\"$\\\" << s << \\\".\\\"\\n << \\\"00\\\"\\n << \\\")\\\";\\n } else if (w.size() <...\",\"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...\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 2e5 + 5;\\nlong long n, m;\\nlong long a[N], b[N], w[N];\\nlong long ans[N];\\nvoid solve() {\\n map > id;\\n cin >> n;\\n for (int i = 1; i <= n; i++) ans[i] = 0;\\n for (int i = 1; i <= n; i++) {\\n cin >> a[i] >> b[i] >> w[i];\\n id[a[i] + b[i] - w[i]].push_back(i);\\n }\\n long long tot = 0;\\n for (auto x : id) {\\n vector p = x.second;\\n sort(p.begin(), p.end(), [&](int x, int y) {\\n return (a[x] - max(0ll, w[x] - b[x])) < (a[y] - max(0ll, w[y] - b[y]));\\n });\\n long long M = -1e9;\\n for (auto i : p) {\\n if (a[i] - M > min(a[i], w[i])) {\\n tot++;\\n ans[i] = max(0ll, w[i] - b[i]);\\n M = a[i] - ans[i];\\n } else\\n ans[i] = a[i] - M;\\n }\\n }\\n cout << tot << '\\\\n';\\n for (int i = 1; i <= n; i++) cout << ans[i] << ' ' << w[i] - ans[i] << '\\\\n';\\n}\\nint main() {\\n ios::sync_with_stdio(false), cin.tie(0);\\n int t;\\n cin >> t;\\n while (t--) {\\n solve();\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"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\":\"\\/* 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. *\\/\\n public class solution\\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 {\\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 \\n \\n catch (IOException e) {\\n e.printStackTrace();\\n }\\n return str;\\n }\\n }\\n\\tpublic static void main (String[] args) throws java.lang.Exception\\n\\t{\\n\\t\\/\\/ your code goes here\\n\\t \\tOutputStream outputStream =System.out;\\n PrintWriter out =new PrintWriter(outputStream);\\n\\t\\tFastReader s = new FastReader();\\n int t = s.nextInt();\\n \\n while(t-->0){\\n int n = s.nextInt();\\n String str = s.nextLine();\\n char[] chars = str.toCharArray();\\n if(n==1){\\n if(chars[0]=='?'){\\n str = \\\"R\\\";\\n }\\n }else{\\n for(int i = 0;i\\nusing namespace std;\\nlong long mod = 1e9 + 7, inf = 1e18;\\nvoid solve() {\\n long long n;\\n cin >> n;\\n vector cc(n);\\n vector> aa(n);\\n for (long long i = 0; i < n; ++i) {\\n cin >> cc[i];\\n aa[i].resize(cc[i]);\\n for (long long j = cc[i] - 1; j >= 0; --j) cin >> aa[i][j];\\n }\\n long long m;\\n cin >> m;\\n vector> bb(m, vector(n));\\n for (long long i = 0; i < m; ++i)\\n for (long long j = 0; j < n; ++j) {\\n cin >> bb[i][j];\\n bb[i][j] = cc[j] - bb[i][j];\\n }\\n sort(bb.begin(), bb.end());\\n bb.push_back(cc);\\n if (m == 0) {\\n for (long long i = 0; i < n; ++i) cout << cc[i] << \\\" \\\";\\n cout << \\\"\\\\n\\\";\\n return;\\n }\\n if (bb[0] != vector(n, 0)) {\\n for (long long i = 0; i < n; ++i) cout << cc[i] << \\\" \\\";\\n cout << \\\"\\\\n\\\";\\n return;\\n }\\n vector our_build;\\n long long ans = 0;\\n for (long long l = 0; l < m; ++l) {\\n vector v1 = bb[l], v2 = bb[l + 1];\\n long long ind_dif = n;\\n for (long long i = 0; i < n; ++i)\\n if (v1[i] != v2[i]) ind_dif = min(i, ind_dif);\\n vector cur_build = v1;\\n cur_build[ind_dif] = v1[ind_dif] + 1;\\n for (long long i = ind_dif + 1; i < n; ++i) cur_build[i] = 0;\\n for (long long i = ind_dif; i < n; ++i) {\\n if (cur_build == v2 || cur_build[i] >= cc[i]) {\\n --cur_build[i];\\n if (i + 1 < n) cur_build[i + 1] = v1[i + 1] + 1;\\n continue;\\n }\\n long long cur_sum = 0;\\n for (long long j = 0; j < n; ++j) cur_sum += aa[j][cur_build[j]];\\n if (ans < cur_sum) {\\n ans = cur_sum;\\n our_build = cur_build;\\n }\\n --cur_build[i];\\n if (i + 1 < n) cur_build[i + 1] = v1[i + 1] + 1;\\n }\\n }\\n for (long long i = 0; i < n; ++i) cout << cc[i] - our_build[i] << \\\" \\\";\\n}\\nsigned main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n long long t = 1;\\n while (t--) solve();\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"After finishing eating her bun, Alyona came up with two integers n and m. She decided to write down two columns of integers — the first column containing integers from 1 to n and the second containing integers from 1 to m. Now the girl wants to count how many pairs of integers she can choose, one from the first column and the other from the second column, such that their sum is divisible by 5.\\n\\nFormally, Alyona wants to count the number of pairs of integers (x, y) such that 1 ≤ x ≤ n, 1 ≤ y ≤ m and equals 0.\\n\\nAs usual, Alyona has some troubles and asks you to help.\\n\\nInput\\n\\nThe only line of the input contains two integers n and m (1 ≤ n, m ≤ 1 000 000).\\n\\nOutput\\n\\nPrint the only integer — the number of pairs of integers (x, y) such that 1 ≤ x ≤ n, 1 ≤ y ≤ m and (x + y) is divisible by 5.\\n\\nExamples\\n\\nInput\\n\\n6 12\\n\\n\\nOutput\\n\\n14\\n\\n\\nInput\\n\\n11 14\\n\\n\\nOutput\\n\\n31\\n\\n\\nInput\\n\\n1 5\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\n3 8\\n\\n\\nOutput\\n\\n5\\n\\n\\nInput\\n\\n5 7\\n\\n\\nOutput\\n\\n7\\n\\n\\nInput\\n\\n21 21\\n\\n\\nOutput\\n\\n88\\n\\nNote\\n\\nFollowing pairs are suitable in the first sample case: \\n\\n * for x = 1 fits y equal to 4 or 9; \\n * for x = 2 fits y equal to 3 or 8; \\n * for x = 3 fits y equal to 2, 7 or 12; \\n * for x = 4 fits y equal to 1, 6 or 11; \\n * for x = 5 fits y equal to 5 or 10; \\n * for x = 6 fits y equal to 4 or 9. \\n\\n\\n\\nOnly the pair (1, 4) is suitable in the third sample case.\\nUsing python3 can you solve the prior task?\",\"targets\":\"a,b=map(int,input().split())\\nsum=0\\nsum+=a*int(b\\/5)\\nsum+=int(a\\/5)* (b % 5)\\nif a%5+b%5>=5:\\n sum+=(a%5+b%5)%5+1\\nprint(sum)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"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\\nSolve the task in PYTHON3.\",\"targets\":\"import math\\nn=int(input())\\nfor i in range(n):\\n s=int(input())\\n a=(s**(1\\/2))\\n b=(s**(1\\/3))\\n c=(s**(1\\/6))\\n b1=math.ceil(b)\\n b2=int(b)\\n c1=math.ceil(c)\\n c2=int(c)\\n if(b1**3==s):\\n k=int(a)+b1\\n else:\\n k=int(a)+b2\\n if(c1**6==s):\\n k=k-c1\\n else:\\n k=k-c2\\n print(k)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nLet'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;\\nsigned main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(nullptr);\\n long long T = 1;\\n while (T--) {\\n long long n, m;\\n cin >> n >> m;\\n string s;\\n cin >> s;\\n char a[3] = {'a', 'b', 'c'};\\n long long cost[6][n + 1];\\n memset(cost, 0, sizeof(cost));\\n long long k = 0;\\n do {\\n for (long long i = 0; i < n; i++) {\\n if (s[i] != a[i % 3]) {\\n cost[k][i + 1]++;\\n }\\n cost[k][i + 1] += cost[k][i];\\n }\\n k++;\\n } while (next_permutation(a, a + 3));\\n while (m--) {\\n long long l, r;\\n cin >> l >> r;\\n long long ans = 1e9;\\n for (long long i = 0; i < k; i++) {\\n ans = min(ans, cost[i][r] - cost[i][l - 1]);\\n }\\n cout << ans << '\\\\n';\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in PYTHON3?\\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\":\"from sys import stdin\\ninput=stdin.readline\\nrn=lambda:int(input())\\nrns=lambda:map(int,input().split())\\nrl=lambda:list(map(int,input().split()))\\nrs=lambda:input().strip()\\nYN=lambda x:print('YES') if x else print('NO')\\nmod=10**9+7\\n\\nfor _ in range(rn()):\\n n=rn()\\n a=rl()\\n ans=[]\\n def solve(b):\\n ans=[]\\n for i in range(0,len(b),2):\\n ans.append(-b[i+1])\\n ans.append(b[i])\\n return ans\\n if n%2==0:\\n ans=solve(a)\\n else:\\n x,b,c=a[:3]\\n l=len({x, b, c})\\n if l==3:\\n pre = [b-c,c-x,x-b]\\n elif l==1:\\n pre = [1,1,-2]\\n else:\\n if x==b:\\n pre=[x,c-x,-x]\\n elif x==c:\\n pre=[x,-x,b-x]\\n else:\\n pre=[-b,b,x-b]\\n ans=pre+solve(a[3:])\\n print(*ans)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP 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\":\"#include \\nusing namespace std;\\nconst int N = 1e5 + 10;\\nconst int M = 998244353;\\nlong long n, m;\\nlong long ans, cnt;\\nlong long aa[N];\\nlong long kpow(long long a, long long b) {\\n long long temp = 1;\\n while (b) {\\n if (b & 1) temp = temp * a % M;\\n a = a * a % M;\\n b >>= 1;\\n }\\n return temp;\\n}\\nint main() {\\n int t = 1;\\n cin >> t;\\n while (t--) {\\n cin >> n;\\n ans = to_string(n).length() + 1;\\n string s, ss;\\n s = to_string(n);\\n for (long long k = 1; k < (1ll << 62); k <<= 1) {\\n cnt = 0;\\n int i = 0, j = 0;\\n ss = to_string(k);\\n while (i < s.length() && j < ss.length()) {\\n if (s[i] == ss[j])\\n i++, j++;\\n else {\\n i++;\\n cnt++;\\n }\\n }\\n if (i < s.length()) cnt += s.length() - i;\\n if (j < ss.length()) cnt += ss.length() - j;\\n ans = min(ans, cnt);\\n }\\n cout << ans << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Everyone knows the famous detective Sherlock. He has been handed over a new case of \\\"The Abominable Bride\\\". Each night she kills N people but to irritate \\nSherlock she leaves exactly one people. The way she kills the people is somewhat strange. She makes 1 to N people stand in a line and starts killing \\nthem. But, in the line when she kills the first person, there's time for the person standing next in line to run away at the end of the line.Again she kills the first \\nperson and the second one next to him runs to the last of the line. In this way after killing, there is exactly one person standing in the line who is saved and he \\nruns to Sherlock to explain the situation each night. Help Sherlock find out the person that will be saved at the end of the massacre.\\n\\nConstraints and Example\\nInput:\\n5\\n2\\n4\\n6\\n9\\n12\\n\\nOutput:\\n2\\n4\\n4\\n2\\n8\\n\\n\\nExplanation\\n\\nFor the 2nd test case, she kills 1 and 2 goes at the end of line i.e., 3 4 2. Then she kills 3rd and 4th goes at the end of line i.e. 2 4. Then she kills 2 and \\nultimately 4th is the lone survivour.\\nUsing python can you solve the prior task?\",\"targets\":\"t=int(raw_input())\\nfor i in range(t):\\n n=int(raw_input())\\n x=bin(n)[2:]\\n x=len(x)-1\\n x2=pow(2,x)\\n ans=2*(n-x2)\\n if ans==0:\\n print x2\\n else:\\n print ans\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nHasan loves playing games and has recently discovered a game called TopScore. In this soccer-like game there are p players doing penalty shoot-outs. Winner is the one who scores the most. In case of ties, one of the top-scorers will be declared as the winner randomly with equal probability.\\n\\nThey have just finished the game and now are waiting for the result. But there's a tiny problem! The judges have lost the paper of scores! Fortunately they have calculated sum of the scores before they get lost and also for some of the players they have remembered a lower bound on how much they scored. However, the information about the bounds is private, so Hasan only got to know his bound.\\n\\nAccording to the available data, he knows that his score is at least r and sum of the scores is s.\\n\\nThus the final state of the game can be represented in form of sequence of p integers a_1, a_2, ..., a_p (0 ≤ a_i) — player's scores. Hasan is player number 1, so a_1 ≥ r. Also a_1 + a_2 + ... + a_p = s. Two states are considered different if there exists some position i such that the value of a_i differs in these states. \\n\\nOnce again, Hasan doesn't know the exact scores (he doesn't know his exact score as well). So he considers each of the final states to be equally probable to achieve.\\n\\nHelp Hasan find the probability of him winning.\\n\\nIt can be shown that it is in the form of P\\/Q where P and Q are non-negative integers and Q ≠ 0, P ≤ Q. Report the value of P ⋅ Q^{-1} \\\\pmod {998244353}.\\n\\nInput\\n\\nThe only line contains three integers p, s and r (1 ≤ p ≤ 100, 0 ≤ r ≤ s ≤ 5000) — the number of players, the sum of scores of all players and Hasan's score, respectively.\\n\\nOutput\\n\\nPrint a single integer — the probability of Hasan winning.\\n\\nIt can be shown that it is in the form of P\\/Q where P and Q are non-negative integers and Q ≠ 0, P ≤ Q. Report the value of P ⋅ Q^{-1} \\\\pmod {998244353}.\\n\\nExamples\\n\\nInput\\n\\n2 6 3\\n\\n\\nOutput\\n\\n124780545\\n\\n\\nInput\\n\\n5 20 11\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\n10 30 10\\n\\n\\nOutput\\n\\n85932500\\n\\nNote\\n\\nIn the first example Hasan can score...\",\"targets\":\"#include \\nusing namespace std;\\nconst int INF = 0x3f3f3f3f, N = 5500, mod = 998244353;\\nint r, p, s, ans;\\nint C[N][N];\\nint read() {\\n int ret = 0, f = 1;\\n char c = getchar();\\n while (!isdigit(c)) {\\n if (c == '-') f = 0;\\n c = getchar();\\n }\\n while (isdigit(c)) ret = ret * 10 + (c ^ 48), c = getchar();\\n return f ? ret : -ret;\\n}\\nint qpow(int x, int y) {\\n int res = 1;\\n for (; y; y >>= 1, x = (long long)x * x % mod)\\n if (y & 1) res = (long long)res * x % mod;\\n return res;\\n}\\nint up(int &x, int y) {\\n x += y;\\n if (x >= mod) x -= mod;\\n if (x < 0) x += mod;\\n}\\nint upm(int x) { return x >= mod ? x - mod : x; }\\nvoid initC() {\\n for (int i = 0; i < N; ++i) {\\n C[i][0] = C[i][i] = 1;\\n for (int j = 1; j < i; ++j) C[i][j] = upm(C[i - 1][j] + C[i - 1][j - 1]);\\n }\\n}\\nint solve(int n, int k, int s) {\\n if (!n) return !s;\\n int res = 0;\\n for (int i = 0; i <= n && i * (k + 1) <= s; ++i)\\n up(res, (long long)(i & 1 ? -1 : 1) * C[n + s - i * (k + 1) - 1][n - 1] *\\n C[n][i] % mod);\\n return res;\\n}\\nint main() {\\n initC();\\n scanf(\\\"%d%d%d\\\", &p, &s, &r);\\n for (int i = r; i <= s; ++i)\\n for (int j = 1; j <= p && i * j <= s; ++j)\\n up(ans, (long long)qpow(j, mod - 2) * solve(p - j, i - 1, s - i * j) %\\n mod * C[p - 1][j - 1] % mod);\\n printf(\\\"%d\\\\n\\\", (long long)ans * qpow(C[p + s - r - 1][p - 1], mod - 2) % mod);\\n return 0;\\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).\\nimpor\",\"targets\":\"t java.util.*;\\nimport java.lang.*;\\nimport java.io.*;\\npublic class Codechef\\n{\\n\\tpublic static void main (String[] args) throws java.lang.Exception\\n\\t{\\n\\tScanner sc = new Scanner (System.in);\\n\\tint n = sc.nextInt();\\n\\twhile(n>0)\\n\\t{ \\n\\t int c1=0;\\n\\t int k = sc.nextInt();\\n\\t String A= sc.next();\\n\\t String B= sc.next();\\n\\t char[] a = A.toCharArray();\\n\\t char[] b = B.toCharArray();\\n\\t \\n\\t for(int i=1;i\\nusing namespace std;\\nstruct day {\\n int d, h;\\n} days[100005];\\nint main() {\\n int n, m, i, j, k;\\n cin >> n >> m;\\n for (i = 1; i <= m; i++) {\\n scanf(\\\"%d%d\\\", &days[i].d, &days[i].h);\\n if (i > 1 && abs(days[i].h - days[i - 1].h) > days[i].d - days[i - 1].d) {\\n puts(\\\"IMPOSSIBLE\\\");\\n return 0;\\n }\\n }\\n int maxn = 0;\\n for (i = 1; i < m; i++) {\\n int d = days[i + 1].d - days[i].d;\\n d -= abs(days[i + 1].h - days[i].h);\\n int t = max(days[i + 1].h, days[i].h) + d \\/ 2;\\n maxn = max(maxn, t);\\n }\\n maxn = max(maxn, days[1].d - 1 + days[1].h);\\n maxn = max(maxn, n - days[m].d + days[m].h);\\n cout << maxn << endl;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"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...\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nlong long int gcd(long long int a, long long int b) {\\n if (a == 0) return b;\\n return gcd(b % a, a);\\n}\\nlong long int lcm(long long int a, long long int b) {\\n return (max(a, b) \\/ gcd(a, b)) * min(a, b);\\n}\\nvoid build() {}\\nlong long int modexp(long long int base, long long int exponent,\\n long long int modulus) {\\n if (modulus == 1) return 0;\\n long long int result = 1;\\n base = base % modulus;\\n while (exponent > 0) {\\n if (exponent % 2 == 1) {\\n result = (result * base) % modulus;\\n }\\n exponent = exponent >> 1;\\n base = (base * base) % modulus;\\n }\\n return result;\\n}\\nlong long int dis(int a, int b, int x, int y) {\\n return pow(abs(a - x), 2) + pow(abs(b - y), 2);\\n}\\nint main() {\\n ios::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n ;\\n build();\\n int n;\\n cin >> n;\\n int r1, c1, r2, c2;\\n cin >> r1 >> c1 >> r2 >> c2;\\n string s[n];\\n r1--;\\n c1--;\\n r2--;\\n c2--;\\n for (int i = 0; i < n; i++) cin >> s[i];\\n queue> q;\\n q.push(make_pair(r1, c1));\\n bool visited[n][n];\\n for (int i = 0; i < n; i++) {\\n for (int j = 0; j < n; j++) visited[i][j] = 0;\\n }\\n visited[r1][c1] = 1;\\n vector> st;\\n while (!q.empty()) {\\n pair x = q.front();\\n q.pop();\\n if (x.first + 1 < n && !visited[x.first + 1][x.second] &&\\n s[x.first + 1][x.second] == '0') {\\n q.push(make_pair(x.first + 1, x.second));\\n visited[x.first + 1][x.second] = 1;\\n }\\n if (x.first - 1 >= 0 && !visited[x.first - 1][x.second] &&\\n s[x.first - 1][x.second] == '0') {\\n visited[x.first - 1][x.second] = 1;\\n q.push(make_pair(x.first - 1, x.second));\\n }\\n if (x.second + 1 < n && !visited[x.first][x.second + 1] &&\\n s[x.first][x.second + 1] == '0') {\\n visited[x.first][x.second + 1] = 1;\\n q.push(make_pair(x.first, x.second + 1));\\n }\\n if (x.second - 1 >= 0 && !visited[x.first][x.second - 1] &&\\n s[x.first][x.second - 1] == '0') {\\n visited[x.first][x.second - 1] = 1;\\n ...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"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\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nstring to_string(string s) { return '\\\"' + s + '\\\"'; }\\nstring to_string(const char* s) { return to_string((string)s); }\\nstring to_string(bool b) { return (b ? \\\"true\\\" : \\\"false\\\"); }\\ntemplate \\nstring to_string(pair p) {\\n return \\\"(\\\" + to_string(p.first) + \\\", \\\" + to_string(p.second) + \\\")\\\";\\n}\\ntemplate \\nstring to_string(A v) {\\n bool first = true;\\n string res = \\\"{\\\";\\n for (const auto& x : v) {\\n if (!first) {\\n res += \\\", \\\";\\n }\\n first = false;\\n res += to_string(x);\\n }\\n res += \\\"}\\\";\\n return res;\\n}\\nvoid debug_out() { cerr << endl; }\\ntemplate \\nvoid debug_out(Head H, Tail... T) {\\n cerr << \\\" \\\" << to_string(H);\\n debug_out(T...);\\n}\\ntemplate \\nvoid dout(string name, int idx, T arg) {\\n cerr << name << \\\" = \\\" << to_string(arg);\\n}\\ntemplate \\nvoid dout(string names, int idx, T1 arg, T2... args) {\\n cerr << names.substr(0, names.find(',')) << \\\" = \\\" << to_string(arg) << \\\", \\\";\\n dout(names.substr(names.find(',') + 2), idx + 1, args...);\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(0);\\n int tt;\\n cin >> tt;\\n int qq = 0;\\n while (tt--) {\\n ++qq;\\n int n, m, k;\\n cin >> n >> m >> k;\\n vector> a(n, vector(m, -1));\\n bool ok = true;\\n int z = 0;\\n if (n % 2 == 1) {\\n for (int i = 0; i < m \\/ 2; i++) {\\n if (k == 0) {\\n ok = false;\\n break;\\n }\\n a[n - 1][2 * i] = (n - 1 + i) % 2;\\n a[n - 1][2 * i + 1] = (n - 1 + i) % 2;\\n --k;\\n }\\n }\\n if (k % 2) {\\n ok = false;\\n }\\n if (!ok) {\\n cout << \\\"NO\\\" << '\\\\n';\\n continue;\\n }\\n for (int j = 0; j < m \\/ 2; j++) {\\n if (k == 0) {\\n break;\\n }\\n for (int i = 0; i < (n \\/ 2) * 2; i++) {\\n a[i][2 * j] = (i + j) % 2;\\n a[i][2 * j + 1] = (i + j) % 2;\\n --k;\\n if (k == 0) {\\n break;\\n }\\n }\\n }\\n if (k > 0) {\\n ok = false;\\n }\\n if...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"A boy Bob likes to draw. Not long ago he bought a rectangular graph (checked) sheet with n rows and m columns. Bob shaded some of the squares on the sheet. Having seen his masterpiece, he decided to share it with his elder brother, who lives in Flatland. Now Bob has to send his picture by post, but because of the world economic crisis and high oil prices, he wants to send his creation, but to spend as little money as possible. For each sent square of paper (no matter whether it is shaded or not) Bob has to pay 3.14 burles. Please, help Bob cut out of his masterpiece a rectangle of the minimum cost, that will contain all the shaded squares. The rectangle's sides should be parallel to the sheet's sides.\\n\\nInput\\n\\nThe first line of the input data contains numbers n and m (1 ≤ n, m ≤ 50), n — amount of lines, and m — amount of columns on Bob's sheet. The following n lines contain m characters each. Character «.» stands for a non-shaded square on the sheet, and «*» — for a shaded square. It is guaranteed that Bob has shaded at least one square.\\n\\nOutput\\n\\nOutput the required rectangle of the minimum cost. Study the output data in the sample tests to understand the output format better.\\n\\nExamples\\n\\nInput\\n\\n6 7\\n.......\\n..***..\\n..*....\\n..***..\\n..*....\\n..***..\\n\\n\\nOutput\\n\\n***\\n*..\\n***\\n*..\\n***\\n\\n\\nInput\\n\\n3 3\\n***\\n*.*\\n***\\n\\n\\nOutput\\n\\n***\\n*.*\\n***\\\":\",\"targets\":\"#include \\nint main() {\\n int n(0), m(0);\\n scanf(\\\"%d %d\\\\n\\\", &n, &m);\\n std::vector> drawing(n, std::vector(m, '0'));\\n int startRow(n), endRow(0), startCol(m), endCol(0);\\n for (int row = 0; row < n; row++) {\\n for (int col = 0; col < m; col++) {\\n char temp('0');\\n scanf(\\\"%c\\\", &temp);\\n drawing[row][col] = temp;\\n if (temp == '*') {\\n if (row < startRow) {\\n startRow = row;\\n }\\n if (row > endRow) {\\n endRow = row;\\n }\\n if (col < startCol) {\\n startCol = col;\\n }\\n if (col > endCol) {\\n endCol = col;\\n }\\n }\\n }\\n scanf(\\\"\\\\n\\\");\\n }\\n for (int row = startRow; row <= endRow; row++) {\\n for (int col = startCol; col <= endCol; col++) {\\n printf(\\\"%c\\\", drawing[row][col]);\\n }\\n puts(\\\"\\\");\\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 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\":\"import sys\\ninput = sys.stdin.readline\\nt = int(input())\\nfor _ in range(t):\\n a, b = list(map(int, input().split()))\\n res = []\\n if (a+b)%2 == 0:\\n minval = (a+b)\\/\\/2 - min(a, b)\\n maxval = (a+b)\\/\\/2 + min(a, b)\\n for i in range(minval, maxval+1):\\n if i%2 == minval%2:\\n res.append(str(i))\\n if (a+b)%2 == 1:\\n minval = (a+b)\\/\\/2 - min(a, b)\\n maxval = (a+b)\\/\\/2 + min(a, b) + 1\\n for i in range(minval, maxval+1):\\n res.append(str(i))\\n print(len(res))\\n print(' '.join(res))\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 solution for \\\"It is the hard version of the problem. The difference is that in this version, there are 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\\nHowever, there are n special nodes in the tree, colors of which are already chosen.\\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 line contains the integers k (1 ≤ k ≤ 60) — the number of levels in the perfect binary tree you need to color.\\n\\nThe second line contains the integer n (1 ≤ n ≤ min(2^k - 1, 2000)) — the number of nodes, colors of which are already chosen.\\n\\nThe next n lines contains integer v (1 ≤ v ≤ 2^k - 1) and string s — the index of the node and the color of the node (s is one of the white, yellow, green, blue, red and orange).\\n\\nIt is guaranteed that each node v appears in the input...\\\":\",\"targets\":\"k = int(input());n = int(input());l = [1];m = 10 ** 9 + 7\\nfor i in range(k - 1):l.append((16 * l[-1] ** 2) % m)\\ncounts = {};ind = {'white' : 0, 'green' : 1, 'red' : 2, 'yellow' : 3, 'blue' : 4, 'orange' : 5};given = {}\\nfor i in range(n):v, c = input().split();v = int(v);c = ind[c];given[v] = c\\ndef count(k,i,counts,color=None):\\n\\tif i in counts:\\n\\t\\treturn None\\n\\tm=10**9+7\\n\\tif 2*i not in counts and 2*i+1 not in counts:\\n\\t\\tlayer = len(bin(i))-2\\n\\t\\tif color is None:\\n\\t\\t\\tcounts[i] = [l[k-layer]]*6\\n\\t\\telse:\\n\\t\\t\\tcounts[i] = [0]*6\\n\\t\\t\\tcounts[i][color] = l[k-layer]\\n\\telif 2*i in counts and 2*i+1 in counts:\\n\\t\\tleft = counts[2*i]\\n\\t\\tright = counts[2*i+1]\\n\\t\\tnew = [0]*6\\n\\t\\tfor _ in range(6):\\n\\t\\t\\ttotleft = sum(left)-left[_]-left[(_+3)%6]\\n\\t\\t\\ttotright = sum(right)-right[_]-right[(_+3)%6]\\n\\t\\t\\tif color is None or _==color:\\n\\t\\t\\t\\tnew[_] = (totleft*totright)%m\\n\\t\\tcounts[i] = new\\n\\telse:\\n\\t\\tlayer = len(bin(i))-2\\n\\t\\tif 2*i in counts:\\n\\t\\t\\tleft = counts[2*i]\\n\\t\\t\\tright = [l[k-layer-1]]*6\\n\\t\\telse:\\n\\t\\t\\tleft = counts[2*i+1]\\n\\t\\t\\tright = [l[k-layer-1]]*6\\n\\t\\tnew = [0]*6\\n\\t\\tfor _ in range(6):\\n\\t\\t\\ttotleft = sum(left)-left[_]-left[(_+3)%6]\\n\\t\\t\\ttotright = sum(right)-right[_]-right[(_+3)%6]\\n\\t\\t\\tif color is None or _==color:\\n\\t\\t\\t\\tnew[_] = (totleft*totright)%m\\n\\t\\tcounts[i] = new\\n\\nbits = k\\nwhile bits > 0:\\n\\tfor guy in list(counts.keys()):\\n\\t\\tif len(bin(guy)) == bits + 3:color = given[guy \\/\\/ 2] if guy \\/\\/ 2 in given else None;count(k, guy\\/\\/2, counts, color)\\n\\tfor guy in given:\\n\\t\\tif len(bin(guy)) == bits + 2:count(k, guy, counts, given[guy])\\n\\tbits -= 1\\nprint(sum(counts[1]) % m)\",\"language\":\"python\",\"split\":\"test\",\"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\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nusing ll = long long;\\nconst int MOD = 1000000007;\\nconst int MOD2 = 998244353;\\nconst int INF = 1 << 30;\\nconst ll INF2 = (ll)1 << 60;\\nvoid scan(int& a) { scanf(\\\"%d\\\", &a); }\\nvoid scan(long long& a) { scanf(\\\"%lld\\\", &a); }\\ntemplate \\nvoid scan(pair& p) {\\n scan(p.first);\\n scan(p.second);\\n}\\ntemplate \\nvoid scan(T& a) {\\n cin >> a;\\n}\\ntemplate \\nvoid scan(vector& vec) {\\n for (auto&& it : vec) scan(it);\\n}\\nvoid in() {}\\ntemplate \\nvoid in(Head& head, Tail&... tail) {\\n scan(head);\\n in(tail...);\\n}\\nvoid print(const int& a) { printf(\\\"%d\\\", a); }\\nvoid print(const long long& a) { printf(\\\"%lld\\\", a); }\\nvoid print(const double& a) { printf(\\\"%.15lf\\\", a); }\\ntemplate \\nvoid print(const pair& p) {\\n print(p.first);\\n putchar(' ');\\n print(p.second);\\n}\\ntemplate \\nvoid print(const T& a) {\\n cout << a;\\n}\\ntemplate \\nvoid print(const vector& vec) {\\n if (vec.empty()) return;\\n print(vec[0]);\\n for (auto it = vec.begin(); ++it != vec.end();) {\\n putchar(' ');\\n print(*it);\\n }\\n}\\nvoid out() { putchar('\\\\n'); }\\ntemplate \\nvoid out(const T& t) {\\n print(t);\\n putchar('\\\\n');\\n}\\ntemplate \\nvoid out(const Head& head, const Tail&... tail) {\\n print(head);\\n putchar(' ');\\n out(tail...);\\n}\\ntemplate \\nvoid dprint(const T& a) {\\n cerr << a;\\n}\\ntemplate \\nvoid dprint(const vector& vec) {\\n if (vec.empty()) return;\\n cerr << vec[0];\\n for (auto it = vec.begin(); ++it != vec.end();) {\\n cerr << \\\" \\\" << *it;\\n }\\n}\\nvoid debug() { cerr << endl; }\\ntemplate \\nvoid debug(const T& t) {\\n dprint(t);\\n cerr << endl;\\n}\\ntemplate \\nvoid debug(const Head& head, const Tail&... tail) {\\n dprint(head);\\n cerr << \\\" \\\";\\n debug(tail...);\\n}\\nll intpow(ll a, ll b) {\\n ll ans = 1;\\n while (b) {\\n if (b & 1) ans *= a;\\n a *= a;\\n b \\/= 2;\\n }\\n return ans;\\n}\\nll modpow(ll a, ll b, ll p) {\\n ll ans = 1;\\n while (b) {\\n if (b & 1)...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"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 JAVA.\",\"targets\":\"import java.util.*;\\npublic class Main{\\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 {\\n solve1();\\n }\\n }\\n static void solve1() {\\n long n = sc.nextLong();\\n if(n <= 6){\\n System.out.println(15);\\n return;\\n }\\n if(n % 2 == 1)\\n n ++;\\n long res = n * 25 \\/ 10;\\n System.out.println(res);\\n\\n }\\n static void solve2(){\\n int W = sc.nextInt();\\n int H = sc.nextInt();\\n int x1 = sc.nextInt();\\n int y1 = sc.nextInt();\\n int x2 = sc.nextInt();\\n int y2 = sc.nextInt();\\n int w = sc.nextInt();\\n int h= sc.nextInt();\\n if(w * 2 > W && h * 2 > H){\\n System.out.println(-1);\\n \\/\\/continue;\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"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 CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int p, k, s, x, y, i;\\n int n, m, a, b, div;\\n int costo1, costo2, costo3, menor;\\n cin >> n >> m >> a >> b;\\n costo1 = a * n;\\n div = n \\/ m;\\n costo2 = div * b;\\n div = n % m;\\n costo2 = costo2 + (div * a);\\n if (costo1 < costo2)\\n menor = costo1;\\n else\\n menor = costo2;\\n for (i = 1; i < 1000; i++) {\\n if (i * m <= n) {\\n costo3 = i * m;\\n div = n - costo3;\\n costo3 *= b;\\n costo3 = costo3 + (div * a);\\n if (costo3 < menor) menor = costo3;\\n }\\n }\\n div = n \\/ m;\\n if (div * m < n) div++;\\n costo3 = div * b;\\n if (costo3 < menor) menor = costo3;\\n cout << menor << endl;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"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 CPP.\",\"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\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"'In Boolean logic, a formula is in conjunctive normal form (CNF) or clausal normal form if it is a conjunction of clauses, where a clause is a disjunction of literals' (cited from https:\\/\\/en.wikipedia.org\\/wiki\\/Conjunctive_normal_form)\\n\\nIn the other words, CNF is a formula of type , where & represents a logical \\\"AND\\\" (conjunction), represents a logical \\\"OR\\\" (disjunction), and vij are some boolean variables or their negations. Each statement in brackets is called a clause, and vij are called literals.\\n\\nYou are given a CNF containing variables x1, ..., xm and their negations. We know that each variable occurs in at most two clauses (with negation and without negation in total). Your task is to determine whether this CNF is satisfiable, that is, whether there are such values of variables where the CNF value is true. If CNF is satisfiable, then you also need to determine the values of the variables at which the CNF is true. \\n\\nIt is guaranteed that each variable occurs at most once in each clause.\\n\\nInput\\n\\nThe first line contains integers n and m (1 ≤ n, m ≤ 2·105) — the number of clauses and the number variables, correspondingly.\\n\\nNext n lines contain the descriptions of each clause. The i-th line first contains first number ki (ki ≥ 1) — the number of literals in the i-th clauses. Then follow space-separated literals vij (1 ≤ |vij| ≤ m). A literal that corresponds to vij is x|vij| either with negation, if vij is negative, or without negation otherwise.\\n\\nOutput\\n\\nIf CNF is not satisfiable, print a single line \\\"NO\\\" (without the quotes), otherwise print two strings: string \\\"YES\\\" (without the quotes), and then a string of m numbers zero or one — the values of variables in satisfying assignment in the order from x1 to xm.\\n\\nExamples\\n\\nInput\\n\\n2 2\\n2 1 -2\\n2 2 -1\\n\\n\\nOutput\\n\\nYES\\n11\\n\\n\\nInput\\n\\n4 3\\n1 1\\n1 2\\n3 -1 -2 3\\n1 -3\\n\\n\\nOutput\\n\\nNO\\n\\n\\nInput\\n\\n5 6\\n2 1 2\\n3 1 -2 3\\n4 -3 5 4 6\\n2 -6 -4\\n1 5\\n\\n\\nOutput\\n\\nYES\\n100010\\n\\nNote\\n\\nIn the first sample test formula is . One of possible answer is x1 = TRUE, x2 = TRUE.\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nconst int maxn = 200200;\\nint n, m, k, x, C, C1, C2, val[maxn];\\nvector g[maxn], h[maxn], v[maxn], tc;\\nbool vis[maxn], vis2[maxn], mark[maxn], c[maxn];\\nint abs(int V) { return max(V, -V); }\\nvoid dfs(int V) {\\n vis[V] = true;\\n for (int i = 0; i < v[V].size(); i++)\\n if (!vis2[abs(v[V][i])]) {\\n vis2[abs(v[V][i])] = true;\\n if (v[V][i] < 0) {\\n C1 = g[-v[V][i]][0], C2 = g[-v[V][i]][1];\\n if (C1 != V)\\n C = C1;\\n else\\n C = C2;\\n if (!vis[C])\\n dfs(C);\\n else\\n c[C] = true;\\n } else {\\n C1 = h[v[V][i]][0], C2 = h[v[V][i]][1];\\n if (C1 != V)\\n C = C1;\\n else\\n C = C2;\\n if (!vis[C])\\n dfs(C);\\n else\\n c[C] = true;\\n }\\n }\\n}\\nvoid dfs2(int V) {\\n mark[V] = true;\\n for (int i = 0; i < v[V].size(); i++)\\n if (!val[abs(v[V][i])]) {\\n if (v[V][i] < 0) {\\n val[-v[V][i]] = 1, C1 = g[-v[V][i]][0], C2 = g[-v[V][i]][1];\\n if (C1 != V)\\n C = C1;\\n else\\n C = C2;\\n if (!mark[C]) dfs2(C);\\n } else {\\n val[v[V][i]] = -1, C1 = h[v[V][i]][0], C2 = h[v[V][i]][1];\\n C = (C1 * (C1 != V)) + (C2 * (C2 != V));\\n if (C1 != V)\\n C = C1;\\n else\\n C = C2;\\n if (!mark[C]) dfs2(C);\\n }\\n }\\n}\\nint main() {\\n scanf(\\\"%d%d\\\", &m, &n);\\n for (int i = 0; i < m; i++) {\\n scanf(\\\"%d\\\", &k);\\n for (int j = 0; j < k; j++) {\\n scanf(\\\"%d\\\", &x);\\n v[i].push_back(x);\\n if (x < 0)\\n h[-x].push_back(i);\\n else\\n g[x].push_back(i);\\n }\\n }\\n for (int i = 1; i <= n; i++)\\n if ((!g[i].size()) != (!h[i].size()))\\n if (g[i].size()) {\\n val[i] = 1;\\n for (int j = 0; j < g[i].size(); j++)\\n if (!mark[g[i][j]]) {\\n mark[g[i][j]] = true;\\n tc.push_back(g[i][j]);\\n }\\n } else {\\n val[i] = -1;\\n for (int j = 0; j < h[i].size(); j++)\\n if (!mark[h[i][j]]) {\\n ...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A never-ending, fast-changing and dream-like world unfolds, as the secret door opens.\\n\\nA world is an unordered graph G, in whose vertex set V(G) there are two special vertices s(G) and t(G). An initial world has vertex set {s(G), t(G)} and an edge between them.\\n\\nA total of n changes took place in an initial world. In each change, a new vertex w is added into V(G), an existing edge (u, v) is chosen, and two edges (u, w) and (v, w) are added into E(G). Note that it's possible that some edges are chosen in more than one change.\\n\\nIt's known that the capacity of the minimum s-t cut of the resulting graph is m, that is, at least m edges need to be removed in order to make s(G) and t(G) disconnected.\\n\\nCount the number of non-similar worlds that can be built under the constraints, modulo 109 + 7. We define two worlds similar, if they are isomorphic and there is isomorphism in which the s and t vertices are not relabelled. Formally, two worlds G and H are considered similar, if there is a bijection between their vertex sets , such that: \\n\\n * f(s(G)) = s(H); \\n * f(t(G)) = t(H); \\n * Two vertices u and v of G are adjacent in G if and only if f(u) and f(v) are adjacent in H. \\n\\nInput\\n\\nThe first and only line of input contains two space-separated integers n, m (1 ≤ n, m ≤ 50) — the number of operations performed and the minimum cut, respectively.\\n\\nOutput\\n\\nOutput one integer — the number of non-similar worlds that can be built, modulo 109 + 7.\\n\\nExamples\\n\\nInput\\n\\n3 2\\n\\n\\nOutput\\n\\n6\\n\\n\\nInput\\n\\n4 4\\n\\n\\nOutput\\n\\n3\\n\\n\\nInput\\n\\n7 3\\n\\n\\nOutput\\n\\n1196\\n\\n\\nInput\\n\\n31 8\\n\\n\\nOutput\\n\\n64921457\\n\\nNote\\n\\nIn the first example, the following 6 worlds are pairwise non-similar and satisfy the constraints, with s(G) marked in green, t(G) marked in blue, and one of their minimum cuts in light blue.\\n\\n\\n\\nIn the second example, the following 3 worlds satisfy the constraints.\\n\\n\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\ntemplate \\ninline void read(T &x) {\\n x = 0;\\n char c = getchar();\\n bool flag = false;\\n while (!isdigit(c)) {\\n if (c == '-') flag = true;\\n c = getchar();\\n }\\n while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar();\\n if (flag) x = -x;\\n}\\nusing namespace std;\\nconst int P = 1e9 + 7;\\ninline long long quickpow(long long x, int k) {\\n long long res = 1;\\n while (k) {\\n if (k & 1) res = res * x % P;\\n x = x * x % P;\\n k >>= 1;\\n }\\n return res;\\n}\\nint n, m;\\nlong long jie[57], jieni[57];\\ninline void init() {\\n const int up = max(n, m) + 3;\\n jie[0] = jieni[0] = 1;\\n for (int i = 1; i <= up; ++i) jie[i] = jie[i - 1] * i % P;\\n jieni[up] = quickpow(jie[up], P - 2);\\n for (int i = up - 1; i; --i) jieni[i] = jieni[i + 1] * (i + 1) % P;\\n}\\nlong long f[57][57], g[57][57];\\ninline void calc_g(int i) {\\n for (int j = 1; j <= n + 1; ++j) {\\n for (int k = 0; k < i; ++k) {\\n int l = i - k - 1;\\n for (int a = j; a <= n + 1; ++a) {\\n g[i][j] = (g[i][j] + f[k][a] * f[l][j]) % P;\\n if (a != j) g[i][j] = (g[i][j] + f[k][j] * f[l][a]) % P;\\n }\\n }\\n }\\n}\\nint main() {\\n read(n), read(m);\\n init();\\n if (m > n + 1) return puts(\\\"0\\\"), 0;\\n f[0][1] = 1;\\n for (int k = 1; k <= n; ++k) {\\n calc_g(k);\\n for (int l = 1; l <= n + 1; ++l) {\\n for (int i = n; i; --i) {\\n for (int j = n + 1; j; --j) {\\n long long tmp = 1;\\n for (int c = 1; c * l <= j && k * c <= i; ++c) {\\n tmp = tmp * (g[k][l] + c - 1) % P;\\n f[i][j] =\\n (f[i][j] + tmp * jieni[c] % P * f[i - k * c][j - l * c]) % P;\\n }\\n }\\n }\\n }\\n }\\n long long res = f[n][m];\\n printf(\\\"%lld\\\\n\\\", (res % P + P) % P);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"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...\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nusing lint = long long;\\nusing pint = pair;\\nusing plint = pair;\\nstruct fast_ios {\\n fast_ios() {\\n cin.tie(nullptr), ios::sync_with_stdio(false),\\n cout << fixed << setprecision(20);\\n };\\n} fast_ios_;\\ntemplate \\nvoid ndarray(vector &vec, const V &val, int len) {\\n vec.assign(len, val);\\n}\\ntemplate \\nvoid ndarray(vector &vec, const V &val, int len, Args... args) {\\n vec.resize(len),\\n for_each(begin(vec), end(vec), [&](T &v) { ndarray(v, val, args...); });\\n}\\ntemplate \\nbool chmax(T &m, const T q) {\\n return m < q ? (m = q, true) : false;\\n}\\ntemplate \\nbool chmin(T &m, const T q) {\\n return m > q ? (m = q, true) : false;\\n}\\nint floor_lg(long long x) { return x <= 0 ? -1 : 63 - __builtin_clzll(x); }\\ntemplate \\npair operator+(const pair &l, const pair &r) {\\n return make_pair(l.first + r.first, l.second + r.second);\\n}\\ntemplate \\npair operator-(const pair &l, const pair &r) {\\n return make_pair(l.first - r.first, l.second - r.second);\\n}\\ntemplate \\nvector sort_unique(vector vec) {\\n sort(vec.begin(), vec.end()),\\n vec.erase(unique(vec.begin(), vec.end()), vec.end());\\n return vec;\\n}\\ntemplate \\nint arglb(const std::vector &v, const T &x) {\\n return std::distance(v.begin(), std::lower_bound(v.begin(), v.end(), x));\\n}\\ntemplate \\nint argub(const std::vector &v, const T &x) {\\n return std::distance(v.begin(), std::upper_bound(v.begin(), v.end(), x));\\n}\\ntemplate \\nistream &operator>>(istream &is, vector &vec) {\\n for (auto &v : vec) is >> v;\\n return is;\\n}\\ntemplate \\nostream &operator<<(ostream &os, const vector &vec) {\\n os << '[';\\n for (auto v : vec) os << v << ',';\\n os << ']';\\n return os;\\n}\\ntemplate \\nostream &operator<<(ostream &os, const array...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"AtCoDeer the deer recently bought three paint cans. The color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c. Here, the color of each paint can is represented by an integer between 1 and 100, inclusive.\\n\\nSince he is forgetful, he might have bought more than one paint can in the same color. Count the number of different kinds of colors of these paint cans and tell him.\\n\\nConstraints\\n\\n* 1≦a,b,c≦100\\n\\nInput\\n\\nThe input is given from Standard Input in the following format:\\n\\n\\na b c\\n\\n\\nOutput\\n\\nPrint the number of different kinds of colors of the paint cans.\\n\\nExamples\\n\\nInput\\n\\n3 1 4\\n\\n\\nOutput\\n\\n3\\n\\n\\nInput\\n\\n3 3 33\\n\\n\\nOutput\\n\\n2\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.util.*;\\n\\npublic class Main {\\n\\t public static void main(String args[]){\\n \\tScanner scan = new Scanner(System.in);\\n \\n int a = scan.nextInt();\\n int b = scan.nextInt();\\n int c = scan.nextInt();\\n int cnt = 0;\\n \\n if( a == b && a == c )cnt = 1;\\n \\n else if( a == b || a == c || b == c)cnt = 2;\\n \\n else cnt = 3;\\n \\n System.out.println(cnt);\\n\\t }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"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;\\ntemplate \\nT gcd(T a, T b) {\\n return (b == 0 ? a : gcd(b, a % b));\\n}\\nint gi() {\\n int a;\\n scanf(\\\"%d\\\", &a);\\n return a;\\n}\\nlong long gli() {\\n long long a;\\n scanf(\\\"%I64d\\\", &a);\\n return a;\\n}\\nint cases() {\\n static int t = gi();\\n return t--;\\n}\\nchar g[500][504];\\nint r[500][500];\\nint n, m;\\nvoid st(int i, int j, int w) {\\n if (i < 0 || i >= n || j < 0 || j >= m || g[i][j] == 'X' || r[i][j]) return;\\n r[i][j] = w;\\n for (int ii = 0; ii < 3; ii++)\\n for (int jj = 0; jj < 3; jj++) st(i + ii - 1, j + jj - 1, w);\\n if (i - 2 >= 0 && g[i - 1][j] == 'X' && g[i - 1][j - 1] == 'X')\\n st(i - 2, j, 5 - w);\\n if (i + 2 < n && g[i + 1][j] == 'X' && g[i + 1][j + 1] == 'X')\\n st(i + 2, j, 5 - w);\\n if (j - 2 >= 0 && g[i][j - 1] == 'X' && g[i - 1][j - 1] == 'X')\\n st(i, j - 2, 5 - w);\\n if (j + 2 < m && g[i][j + 1] == 'X' && g[i + 1][j + 1] == 'X')\\n st(i, j + 2, 5 - w);\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n n = gi();\\n m = gi();\\n for (int i = 0; i < n; i++) scanf(\\\"%s\\\", g[i]);\\n for (int i = 0; i < n; i++)\\n for (int j = 0; j < m; j++)\\n if (g[i][j] == 'X') {\\n int c = 0;\\n if (g[i - 1][j] == '.') c++;\\n if (g[i + 1][j] == '.') c++;\\n if (g[i][j - 1] == '.') c++;\\n if (g[i][j + 1] == '.') c++;\\n if (c % 2) {\\n printf(\\\"NO\\\\n\\\");\\n return 0;\\n }\\n }\\n st(0, 0, 1);\\n for (int i = 1; i < n; i += 2)\\n for (int j = 0; j < m; j++)\\n if (g[i][j] == '.') r[i][j] = 5 - r[i][j];\\n printf(\\\"YES\\\\n\\\");\\n for (int i = 0; i < n; i++)\\n for (int j = 0; j < m; j++)\\n printf(\\\"%d%c\\\",\\n r[i][j] ? r[i][j]\\n : r[i - 1][j] + r[i + 1][j] + r[i][j - 1] + r[i][j + 1],\\n j == m - 1 ? '\\\\n' : ' ');\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"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\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst int MaxN = 200 * 1000;\\nconst int MaxVal = 300 * 1000 + 1;\\nstruct MyPair {\\n int first;\\n long long second;\\n};\\nMyPair tCountSum[4 * MaxVal];\\nMyPair CountSumNumbers(int v, int tl, int tr, int l, int r) {\\n if (l > r) return {0, 0};\\n if (l == tl && r == tr) {\\n return tCountSum[v];\\n }\\n int mid = (tl + tr) \\/ 2;\\n auto left = CountSumNumbers(v * 2, tl, mid, l, min(r, mid));\\n auto right = CountSumNumbers(v * 2 + 1, mid + 1, tr, max(l, mid + 1), r);\\n return {left.first + right.first, left.second + right.second};\\n}\\nint CountNumbers(int l, int r) {\\n if (l > r) return 0;\\n l = max(l, 0);\\n r = min(r, MaxVal - 1);\\n return CountSumNumbers(1, 0, MaxVal - 1, l, r).first;\\n}\\nlong long SumNumbers(int l, int r) {\\n if (l > r) return 0;\\n l = max(l, 0);\\n r = min(r, MaxVal - 1);\\n return CountSumNumbers(1, 0, MaxVal - 1, l, r).second;\\n}\\nMyPair CountSumNumbers(int l, int r) {\\n if (l > r) return {0, 0};\\n l = max(l, 0);\\n r = min(r, MaxVal - 1);\\n return CountSumNumbers(1, 0, MaxVal - 1, l, r);\\n}\\nvoid AddNumber(int v, int tl, int tr, int val) {\\n if (tl == tr) {\\n tCountSum[v].first++;\\n tCountSum[v].second += val;\\n return;\\n }\\n int mid = (tl + tr) \\/ 2;\\n if (val <= mid) {\\n AddNumber(v * 2, tl, mid, val);\\n } else {\\n AddNumber(v * 2 + 1, mid + 1, tr, val);\\n }\\n tCountSum[v].first = tCountSum[v * 2].first + tCountSum[v * 2 + 1].first;\\n tCountSum[v].second = tCountSum[v * 2].second + tCountSum[v * 2 + 1].second;\\n}\\nvoid AddNumber(int x) { AddNumber(1, 0, MaxVal - 1, x); }\\nMyPair tCountSumForward[4 * MaxVal];\\nMyPair tAddForward[4 * MaxVal];\\nvoid push(int v) {\\n if (tAddForward[v].first != 0 || tAddForward[v].second != 0) {\\n if (v * 2 < 4 * MaxVal) {\\n tAddForward[v * 2].first += tAddForward[v].first;\\n tAddForward[v * 2].second += tAddForward[v].second;\\n }\\n if (v * 2 + 1 < 4 * MaxVal) {\\n tAddForward[v * 2 + 1].first += tAddForward[v].first;\\n tAddForward[v * 2 + 1].second += tAddForward[v].second;\\n }\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nLittle Petya likes numbers a lot. He found that number 123 in base 16 consists of two digits: the first is 7 and the second is 11. So the sum of digits of 123 in base 16 is equal to 18.\\n\\nNow he wonders what is an average value of sum of digits of the number A written in all bases from 2 to A - 1.\\n\\nNote that all computations should be done in base 10. You should find the result as an irreducible fraction, written in base 10.\\n\\nInput\\n\\nInput contains one integer number A (3 ≤ A ≤ 1000).\\n\\nOutput\\n\\nOutput should contain required average value in format «X\\/Y», where X is the numerator and Y is the denominator.\\n\\nExamples\\n\\nInput\\n\\n5\\n\\n\\nOutput\\n\\n7\\/3\\n\\n\\nInput\\n\\n3\\n\\n\\nOutput\\n\\n2\\/1\\n\\nNote\\n\\nIn the first sample number 5 written in all bases from 2 to 4 looks so: 101, 12, 11. Sums of digits are 2, 3 and 2, respectively.\",\"targets\":\"#include \\nusing namespace std;\\nint gcd(int a, int b) { return b ? gcd(b, a % b) : a; }\\nint s(int a, int b) {\\n int ret = 0;\\n while (a) {\\n ret += a % b;\\n a \\/= b;\\n }\\n return ret;\\n}\\nint main() {\\n int a;\\n cin >> a;\\n int sum = 0;\\n for (int i = 2; i < a; ++i) sum += s(a, i);\\n a -= 2;\\n int g = gcd(a, sum);\\n sum \\/= g, a \\/= g;\\n cout << sum << '\\/' << a << endl;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"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...\\nfrom\",\"targets\":\"sys import stdin\\ninp = stdin.readline\\n\\n\\nt = int(inp())\\n\\nfor _ in range(t):\\n m, n = map(int, inp().split())\\n arr = [int(x) for x in inp().split()]\\n count = 0\\n s = []\\n\\n for i in range(n):\\n s.append(arr[i])\\n s.sort()\\n count += s.index(arr[i])\\n\\n print(count)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"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\":\"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\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"This is the easy version of the problem. The only difference from the hard version is that in this version all coordinates are even.\\n\\nThere are n fence-posts at distinct coordinates on a plane. It is guaranteed that no three fence posts lie on the same line.\\n\\nThere are an infinite number of cows on the plane, one at every point with integer coordinates.\\n\\nGregor is a member of the Illuminati, and wants to build a triangular fence, connecting 3 distinct existing fence posts. A cow strictly inside the fence is said to be enclosed. If there are an odd number of enclosed cows and the area of the fence is an integer, the fence is said to be interesting.\\n\\nFind the number of interesting fences.\\n\\nInput\\n\\nThe first line contains the integer n (3 ≤ n ≤ 6000), the number of fence posts which Gregor can choose to form the vertices of a fence.\\n\\nEach of the next n line contains two integers x and y (0 ≤ x,y ≤ 10^7, x and y are even), where (x,y) is the coordinate of a fence post. All fence posts lie at distinct coordinates. No three fence posts are on the same line.\\n\\nOutput\\n\\nPrint a single integer, the number of interesting fences. Two fences are considered different if they are constructed with a different set of three fence posts.\\n\\nExamples\\n\\nInput\\n\\n\\n3\\n0 0\\n2 0\\n0 4\\n\\n\\nOutput\\n\\n\\n1\\n\\n\\nInput\\n\\n\\n5\\n0 0\\n2 16\\n30 14\\n4 6\\n2 10\\n\\n\\nOutput\\n\\n\\n3\\n\\nNote\\n\\nIn the first example, there is only 1 fence. That fence is interesting since its area is 4 and there is 1 enclosed cow, marked in red.\\n\\n\\n\\nIn the second example, there are 3 interesting fences. \\n\\n * (0,0) — (30,14) — (2,10) \\n * (2,16) — (30,14) — (2,10) \\n * (30,14) — (4,6) — (2,10) \\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\ntemplate \\nusing minpq = priority_queue, greater>;\\nconst long long MOD = 1000000007LL;\\nint ni() {\\n int x;\\n cin >> x;\\n return x;\\n}\\nlong long nl() {\\n long long x;\\n cin >> x;\\n return x;\\n}\\ndouble nd() {\\n double x;\\n cin >> x;\\n return x;\\n}\\nstring next() {\\n string x;\\n cin >> x;\\n return x;\\n}\\nlong long choose(long long n, long long k) {\\n if (n < k) return 0LL;\\n if (k == 2)\\n return n * (n - 1) \\/ 2;\\n else\\n return n * (n - 1) * (n - 2) \\/ 6;\\n}\\nint boundary(int x1, int y1, int x2, int y2) {\\n if (x1 == x2 && y1 == y2)\\n return 0;\\n else\\n return 2;\\n}\\nint main() {\\n ios::sync_with_stdio(false);\\n cin.tie(0);\\n int N = ni();\\n long long cnt[2][2];\\n for (int i = 0; i < (2); i++)\\n for (int j = 0; j < (2); j++) {\\n cnt[i][j] = 0LL;\\n }\\n for (int i = 0; i < (N); i++) {\\n int x = ni();\\n int y = ni();\\n cnt[(x % 4) \\/ 2][(y % 4) \\/ 2] += 1;\\n }\\n long long ans = 0;\\n for (int s1 = 0; s1 < 4; s1++) {\\n for (int s2 = s1; s2 < 4; s2++) {\\n for (int s3 = s2; s3 < 4; s3++) {\\n int x1 = s1 \\/ 2;\\n int y1 = s1 % 2;\\n int x2 = s2 \\/ 2;\\n int y2 = s2 % 2;\\n int x3 = s3 \\/ 2;\\n int y3 = s3 % 2;\\n int b1 = boundary(x1, y1, x2, y2);\\n int b2 = boundary(x1, y1, x3, y3);\\n int b3 = boundary(x2, y2, x3, y3);\\n int B = (b1 + b2 + b3) % 4;\\n if (B == 0) {\\n if (s1 == s2 && s2 == s3) {\\n ans += choose(cnt[x1][y1], 3);\\n } else if (s1 == s2) {\\n ans += choose(cnt[x1][y1], 2) * cnt[x3][y3];\\n } else if (s2 == s3) {\\n ans += choose(cnt[x2][y2], 2) * cnt[x1][y1];\\n }\\n }\\n }\\n }\\n }\\n cout << ans << '\\\\n';\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nTheofanis has a string s_1 s_2 ... s_n and a character c. He wants to make all characters of the string equal to c using the minimum number of operations.\\n\\nIn one operation he can choose a number x (1 ≤ x ≤ n) and for every position i, where i is not divisible by x, replace s_i with c. \\n\\nFind the minimum number of operations required to make all the characters equal to c and the x-s that he should use in his operations.\\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 the integer n (3 ≤ n ≤ 3 ⋅ 10^5) and a lowercase Latin letter c — the length of the string s and the character the resulting string should consist of.\\n\\nThe second line of each test case contains a string s of lowercase Latin letters — the initial string.\\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, firstly print one integer m — the minimum number of operations required to make all the characters equal to c.\\n\\nNext, print m integers x_1, x_2, ..., x_m (1 ≤ x_j ≤ n) — the x-s that should be used in the order they are given.\\n\\nIt can be proved that under given constraints, an answer always exists. If there are multiple answers, print any.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n4 a\\naaaa\\n4 a\\nbaaa\\n4 b\\nbzyx\\n\\n\\nOutput\\n\\n\\n0\\n1\\n2\\n2 \\n2 3\\n\\nNote\\n\\nLet's describe what happens in the third test case: \\n\\n 1. x_1 = 2: we choose all positions that are not divisible by 2 and replace them, i. e. bzyx → bzbx; \\n 2. x_2 = 3: we choose all positions that are not divisible by 3 and replace them, i. e. bzbx → bbbb.\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.util.*;\\n\\npublic class CF5 {\\n public static void main(String[] args) {\\n FastScanner sc=new FastScanner();\\n int T=sc.nextInt();\\n for (int xx=0; xxn) {\\n y=true;\\n ans=i;\\n break;\\n }\\n }\\n if (y) {\\n System.out.println(1);\\n System.out.println(ans);\\n }\\n else {\\n System.out.println(2);\\n System.out.println(n+\\\" \\\"+ (n-1));\\n }\\n }\\n }\\n }\\n\\n static int gcd (int n, int m){\\n if (m==0) return n;\\n else return gcd(m, n%m);\\n }\\n static class Pair{\\n int x,y;\\n public Pair(int x, int y){\\n this.x = x;\\n this.y = y;\\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 ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"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.\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nstring dtb(long long a) {\\n string s = \\\"\\\";\\n for (long long i = 63; i >= 0; i--) {\\n if (a & (1LL << i))\\n s += '1';\\n else\\n s += '0';\\n }\\n return s;\\n}\\nvoid solve() {\\n long long a, b;\\n cin >> a >> b;\\n long long len = a;\\n long long ini, q;\\n if (a % 4 == 0) {\\n ini = 0;\\n q = ini ^ b;\\n if (ini == b)\\n cout << len;\\n else {\\n if (q == a)\\n cout << len + 2 << '\\\\n';\\n else\\n cout << len + 1 << '\\\\n';\\n }\\n } else if (a % 4 == 1) {\\n ini = a - 1;\\n q = ini ^ b;\\n if (ini == b)\\n cout << len;\\n else {\\n if (q == a)\\n cout << len + 2;\\n else\\n cout << len + 1;\\n }\\n } else if (a % 4 == 2) {\\n ini = 1;\\n q = ini ^ b;\\n if (ini == b)\\n cout << len;\\n else {\\n if (q == a)\\n cout << len + 2;\\n else\\n cout << len + 1;\\n }\\n } else {\\n ini = a;\\n q = ini ^ b;\\n if (ini == b)\\n cout << len;\\n else {\\n if (q == a)\\n cout << len + 2;\\n else\\n cout << len + 1;\\n }\\n }\\n cout << '\\\\n';\\n}\\nint32_t main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\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?\\nMr. Kitayuta's garden is planted with n bamboos. (Bamboos are tall, fast-growing tropical plants with hollow stems.) At the moment, the height of the i-th bamboo is hi meters, and it grows ai meters at the end of each day. \\n\\nActually, Mr. Kitayuta hates these bamboos. He once attempted to cut them down, but failed because their stems are too hard. Mr. Kitayuta have not given up, however. He has crafted Magical Hammer with his intelligence to drive them into the ground.\\n\\nHe can use Magical Hammer at most k times during each day, due to his limited Magic Power. Each time he beat a bamboo with Magical Hammer, its height decreases by p meters. If the height would become negative by this change, it will become 0 meters instead (it does not disappear). In other words, if a bamboo whose height is h meters is beaten with Magical Hammer, its new height will be max(0, h - p) meters. It is possible to beat the same bamboo more than once in a day.\\n\\nMr. Kitayuta will fight the bamboos for m days, starting today. His purpose is to minimize the height of the tallest bamboo after m days (that is, m iterations of \\\"Mr. Kitayuta beats the bamboos and then they grow\\\"). Find the lowest possible height of the tallest bamboo after m days.\\n\\nInput\\n\\nThe first line of the input contains four space-separated integers n, m, k and p (1 ≤ n ≤ 105, 1 ≤ m ≤ 5000, 1 ≤ k ≤ 10, 1 ≤ p ≤ 109). They represent the number of the bamboos in Mr. Kitayuta's garden, the duration of Mr. Kitayuta's fight in days, the maximum number of times that Mr. Kitayuta beat the bamboos during each day, and the power of Magic Hammer, respectively.\\n\\nThe following n lines describe the properties of the bamboos. The i-th of them (1 ≤ i ≤ n) contains two space-separated integers hi and ai (0 ≤ hi ≤ 109, 1 ≤ ai ≤ 109), denoting the initial height and the growth rate of the i-th bamboo, respectively.\\n\\nOutput\\n\\nPrint the lowest possible height of the tallest bamboo after m days.\\n\\nExamples\\n\\nInput\\n\\n3 1 2 5\\n10 10\\n10 10\\n15 2\\n\\n\\nOutput\\n\\n17\\n\\n\\nInput\\n\\n2 10 10 1000000000\\n0 10\\n0...\",\"targets\":\"#include \\nusing namespace std;\\nlong long mx[100010];\\nint h[100010], a[100010], b[5010], n, m, k, p;\\nbool check(long long mid) {\\n long long s = 0;\\n for (int i = 1; i <= n; i++) s += max(0ll, (mx[i] - mid + p - 1) \\/ p);\\n if (s > m * k) return 0;\\n memset(b, 0, sizeof(b));\\n for (int i = 1; i <= n; i++) {\\n if (mx[i] <= mid) continue;\\n for (long long t = (mx[i] - mid - 1) % p + 1; t <= mx[i] - mid; t += p)\\n if (t <= h[i])\\n b[0]++;\\n else if (t > mx[i] - a[i])\\n return 0;\\n else\\n b[(t - h[i] + a[i] - 1) \\/ a[i]]++;\\n }\\n int res = 0;\\n for (int i = 0; i < m; i++) {\\n res += b[i];\\n res = max(0, res - k);\\n }\\n return res == 0;\\n}\\nint main() {\\n scanf(\\\"%d%d%d%d\\\", &n, &m, &k, &p);\\n long long l = 0, r = 0;\\n for (int i = 1; i <= n; i++) {\\n scanf(\\\"%d%d\\\", &h[i], &a[i]);\\n mx[i] = 1ll * a[i] * m + h[i];\\n r = max(r, mx[i]);\\n }\\n long long ans = r;\\n while (l <= r) {\\n long long mid = (l + r) \\/ 2;\\n if (check(mid)) {\\n ans = mid;\\n r = mid - 1;\\n } else\\n l = mid + 1;\\n }\\n printf(\\\"%lld\\\", ans);\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"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...\\ndef c\",\"targets\":\"olors(N, K, arr):\\n arr.sort()\\n # Every color should have same value\\n count = 1\\n curr = 1\\n req = [arr[0]]\\n for i in range(1, N):\\n if arr[i][0] == arr[i - 1][0]:\\n curr += 1\\n if curr <= K:\\n count += 1\\n req.append(arr[i])\\n else:\\n curr = 1\\n count += 1\\n req.append(arr[i])\\n del arr\\n # print(count)\\n # count is the no. of favourable elements\\n # count \\/\\/ K elements in each color\\n color_count = [0] * (K + 1)\\n color = [0] * N\\n for i in range(len(req)):\\n if (i + 1) % K == 0 and color_count[K] + 1 <= count \\/\\/ K:\\n color[req[i][1]] = K\\n color_count[K] += 1\\n else:\\n if color_count[(i + 1) % K] + 1 <= count \\/\\/ K:\\n color[req[i][1]] = (i + 1) % K\\n color_count[(i + 1) % K] += 1\\n return color\\n\\n\\nt = int(input())\\nfor _ in range(t):\\n n, k = map(int, input().split())\\n arr = [[int(x), i] for i, x in enumerate(input().split())]\\n print(*colors(n, k, arr))\",\"language\":\"python\",\"split\":\"valid\",\"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...\\n#incl\",\"targets\":\"ude \\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, i, j, k, flag = 0;\\n cin >> n;\\n int a[n][5];\\n for (i = 0; i < n; i++) {\\n for (j = 0; j < 5; j++) cin >> a[i][j];\\n }\\n for (i = 0; i < 5; i++) {\\n for (j = i + 1; j < 5; j++) {\\n int x = 0, y = 0, z = 0;\\n for (k = 0; k < n; k++) {\\n if (a[k][i] == 1) x++;\\n if (a[k][j] == 1) y++;\\n if (a[k][i] == 1 and a[k][j] == 1) z++;\\n }\\n if (x >= n \\/ 2 and y >= n \\/ 2 and (x + y - z) >= n) {\\n flag = 1;\\n }\\n }\\n }\\n if (flag)\\n cout << \\\"YES\\\\n\\\";\\n else\\n cout << \\\"NO\\\\n\\\";\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Athenaeus has just finished creating his latest musical composition and will present it tomorrow to the people of Athens. Unfortunately, the melody is rather dull and highly likely won't be met with a warm reception. \\n\\nHis song consists of n notes, which we will treat as positive integers. The diversity of a song is the number of different notes it contains. As a patron of music, Euterpe watches over composers and guides them throughout the process of creating new melodies. She decided to help Athenaeus by changing his song to make it more diverse.\\n\\nBeing a minor goddess, she cannot arbitrarily change the song. Instead, for each of the n notes in the song, she can either leave it as it is or increase it by 1.\\n\\nGiven the song as a sequence of integers describing the notes, find out the maximal, achievable diversity.\\n\\nInput\\n\\nThe input consists of multiple test cases. The first line contains an integer t (1 ≤ t ≤ 10 000) — the number of test cases. Then t test cases follow, each one is described in two lines.\\n\\nIn the first line of each test case there is a single integer n (1 ≤ n ≤ 10^5) denoting the length of the song. The next line contains a sequence of n integers x_1, x_2, …, x_n (1 ≤ x_1 ≤ x_2 ≤ … ≤ x_n ≤ 2 ⋅ n), describing the song.\\n\\nThe sum of n over all test cases does not exceed 10^5.\\n\\nOutput\\n\\nFor each test case, you should output a single line containing precisely one integer, the maximal diversity of the song, i.e. the maximal possible number of different elements in the final sequence.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n6\\n1 2 2 2 5 6\\n2\\n4 4\\n6\\n1 1 3 4 4 5\\n1\\n1\\n6\\n1 1 1 2 2 2\\n\\n\\nOutput\\n\\n\\n5\\n2\\n6\\n1\\n3\\n\\nNote\\n\\nIn the first test case, Euterpe can increase the second, fifth and sixth element to obtain the sequence 1, \\\\underline{3}, 2, 2, \\\\underline{6}, \\\\underline{7}, which has 5 different elements (increased elements are underlined).\\n\\nIn the second test case, Euterpe can increase the first element to obtain the sequence \\\\underline{5}, 4, which has 2 different elements.\\n\\nIn the third test case, Euterpe can increase the second,...\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\n#define ln long long\\n\\nln myfn(vector arr)\\n{\\n ln ans = 0 , x = -1;\\n int n = arr.size();\\n int j=0;\\n\\n for(j=0;j>t;\\n while(t--)\\n {\\n int n;\\n cin >> n;\\n \\n vector arr(n);\\n \\n for(int i=0; i>arr[i];\\n \\n cout << myfn(arr);\\n cout << endl;\\n }\\n return 0;\\n }\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"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). \\nSolve the task in PYTHON3.\",\"targets\":\"testcases=int(input())\\nfor tc in range(testcases):\\n \\n a,b=list(map(int,input().split()))\\n if a==b and a==0:\\n print(0)\\n continue\\n if a==b:\\n print(1)\\n continue\\n elif ((abs(a-b)%2)==0):\\n print(2)\\n else:\\n print(-1)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 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\":\"import io,os\\nimport sys\\n\\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\\n\\n\\n \\n\\n\\n\\n\\ndef main(t):\\n\\n\\n n = int(input())\\n arr = list(map(int,input().split()))\\n \\n m = 2*max(arr)+1\\n\\n\\n dp = [2147483647]*(m)\\n dp[arr[0]] = arr[0]\\n\\n for i in range(1,n):\\n newdp = [2147483647]*m\\n for j in range(m):\\n nextj = max(j-arr[i],0)\\n newdp[nextj] = min( newdp[nextj], dp[j]+ max(arr[i]-j,0) )\\n\\n\\n if j+arr[i]\\nusing namespace std;\\nusing namespace std::chrono;\\nusing ll = long long;\\nusing db = long double;\\nusing str = string;\\nusing pi = pair;\\nusing pl = pair;\\nusing pd = pair;\\nusing vi = vector;\\nusing vl = vector;\\nusing vd = vector;\\nusing vpi = vector;\\nusing vpl = vector;\\nusing vpd = vector;\\nconst int MX = 2e5 + 5;\\nconst int MOD = 1e9 + 7;\\nconst ll INF = 1e18;\\nconst db PI = acos((db)-1);\\nconst int xd[4] = {1, 0, -1, 0}, yd[4] = {0, 1, 0, -1};\\nmt19937 rng((uint32_t)steady_clock::now().time_since_epoch().count());\\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 \\nT first_true(T lo, T hi, func first) {\\n hi++;\\n assert(lo <= hi);\\n while (lo < hi) {\\n T mid = lo + (hi - lo) \\/ 2;\\n first(mid) ? hi = mid : lo = mid + 1;\\n }\\n return lo;\\n}\\ntemplate \\nT last_true(T lo, T hi, func first) {\\n lo--;\\n assert(lo <= hi);\\n while (lo < hi) {\\n T mid = lo + (hi - lo + 1) \\/ 2;\\n first(mid) ? lo = mid : hi = mid - 1;\\n }\\n return lo;\\n}\\ntemplate \\nvoid remove_duplicates(vector& v) {\\n sort((v).begin(), (v).end());\\n v.erase(unique((v).begin(), (v).end()), end(v));\\n}\\nvoid setIO(str S = \\\"\\\") {\\n cin.tie(nullptr)->sync_with_stdio(false);\\n cout << fixed << setprecision(15);\\n if ((int)((S).size()) > 0) {\\n freopen(S.c_str(), \\\"r\\\", stdin);\\n freopen(S.c_str(), \\\"w\\\", stdout);\\n }\\n}\\nnamespace factorizer {\\nbool is_prime(int64_t 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 (int64_t i = 5; i * i <= n; i += 6)\\n if (n % i == 0 || n % (i + 2) == 0) return false;\\n return true;\\n}\\nstd::bitset<15000105> prime;\\nvoid sieve(int n) {\\n prime.set();\\n prime[0] = prime[1] = false;\\n for (int64_t p = 2; p * p <= n; ++p) {\\n if (prime[p]) {\\n for (int64_t i = p * p; i <= n; i += p) {\\n prime[i] = false;\\n }\\n }\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"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.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.util.*;\\n\\n\\npublic class javacp{\\n\\n\\n static FastReader fs=new FastReader();\\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 int[] inputIntArray(int n){\\n int[] arr = new int[n];\\n for(int i=0;i al = new ArrayList<>();\\n for(int val : arr){\\n al.add(val);\\n }\\n\\n Collections.sort(al);\\n for(int i=0;i{\\n int vertex;\\n long wt;\\n int edgeno;\\n\\n Pair(int vertex , long wt , int edgeno){\\n this.vertex = vertex;\\n this.wt = wt;\\n this.edgeno = edgeno;\\n }\\n\\n public int compareTo(Pair pair){\\n if(this.wt>pair.wt) return 1;\\n else if(this.wt < pair.wt) return -1;\\n else return...\",\"language\":\"python\",\"split\":\"valid\",\"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;\\nconst double PI = 3.14159265358979323846;\\nconst long long MOD = 1000000007, OO = 0x3f3f3f3f;\\nint dx[] = {0, 1, 0, -1};\\nint dy[] = {1, 0, -1, 0};\\nvoid init() {\\n cin.tie(0);\\n cin.sync_with_stdio(0);\\n}\\nlong long power(long long a, long long b, long long mod) {\\n if (!b) return 1ll;\\n if (b == 1) return a % mod;\\n long long r = power(a, b \\/ 2ll, mod) % mod;\\n if (b % 2ll)\\n return ((r * (a % mod) % mod) * r) % mod;\\n else\\n return (r * r) % mod;\\n}\\nlong long nCr(long long n, long long m) {\\n return (m == 0) ? 1 : n * nCr(n - 1, m - 1) \\/ m;\\n}\\nbool checkDivisibility(long long n, int digit) {\\n return (digit == 0 || (digit != 0 && n % digit == 0));\\n}\\nbool allDigitsDivide(long long n) {\\n long long temp = n;\\n while (temp > 0) {\\n long long digit = temp % 10;\\n if (!(checkDivisibility(n, digit))) return false;\\n temp \\/= 10;\\n }\\n return true;\\n}\\nbool comp2(long long a, long long b) { return a > b; }\\nint gcd(long long a, long long b) {\\n if (b == 0) return a;\\n return gcd(b, a % b);\\n}\\nint lcm(int a, int b) { return (a \\/ gcd(a, b)) * b; }\\nint power2(int a, unsigned int n, int p) {\\n int res = 1;\\n a = a % p;\\n while (n > 0) {\\n if (n & 1) res = (res * a) % p;\\n n = n >> 1;\\n a = (a * a) % p;\\n }\\n return res;\\n}\\nbool isPrime(unsigned int n, int k) {\\n if (n <= 1 || n == 4) return false;\\n if (n <= 3) return true;\\n while (k > 0) {\\n int a = 2 + rand() % (n - 4);\\n if (gcd(n, a) != 1) return false;\\n if (power2(a, n - 1, n) != 1) return false;\\n k--;\\n }\\n return true;\\n}\\nvector primes;\\nvoid SieveOfEratosthenes(int n) {\\n vector prime(n + 1, true);\\n for (int p = 2; p * p <= n; p++) {\\n if (prime[p] == true) {\\n for (int i = p * p; i <= n; i += p) prime[i] = false;\\n }\\n }\\n for (int p = 2; p <= n; p++)\\n if (prime[p]) primes.push_back(p);\\n}\\nconst long long N = 1e5 + 5;\\nvoid TLE() {\\n int n;\\n cin >> n;\\n vector a(n);\\n for (int i = 0; i < n; i++) {\\n cin >> a[i];\\n }\\n sort((a).begin(), (a).end());\\n int mn = a[0];\\n int...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"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.\\nUsing python3 can you solve the prior task?\",\"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)\\n#from 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 = int(input())\\n\\talist = get_int_list()\\n\\n\\tdef slow_solve():\\n\\t\\ts = []\\n\\t\\tfor idx, a in enumerate(alist):\\n\\t\\t\\tif idx%2:\\n\\t\\t\\t\\ts.extend([')']*a)\\n\\t\\t\\telse:\\n\\t\\t\\t\\ts.extend(['(']*a)\\n\\t\\tdbp(s)\\n\\t\\tcount = 0\\n\\t\\tls = len(s)\\n\\t\\tfor w in range(2, ls+1, 2):\\n\\t\\t\\tfor i in range(ls-w+1):\\t\\t\\t\\n\\t\\t\\t\\th = 0\\n\\t\\t\\t\\tok = True\\n\\t\\t\\t\\tsub = s[i:i+w]\\n\\t\\t\\t\\tfor c in sub:\\n\\t\\t\\t\\t\\th += 1 if c == '(' else -1\\n\\t\\t\\t\\t\\tif h < 0:\\n\\t\\t\\t\\t\\t\\tok = False\\n\\t\\t\\t\\t\\t\\tbreak\\n\\t\\t\\t\\tif ok and h == 0:\\n\\t\\t\\t\\t\\tcount += 1\\n\\t\\t\\t\\t\\tdbp(i, i+w-1, ''.join(sub), count) # 0-idx, r-inc\\n\\t\\treturn count\\n\\n\\tdef regret_solve():\\n\\t\\tbasecount = strkcount = 0\\n\\t\\tlefts = 0\\n\\t\\thstk = [[0, 0]]\\n\\t\\t#dbp('pre:', locals())\\n\\t\\tfor i in range(0, n-1, 2):\\n\\t\\t\\tl, r = alist[i:i+2]\\n\\t\\t\\tlefts += l\\n\\t\\t\\tbasecount += min(lefts, r)\\n\\t\\t\\tlefts -= r\\n\\t\\t\\twhile hstk and hstk[-1][0] > lefts:\\n\\t\\t\\t\\th, strk = hstk.pop()\\n\\t\\t\\t\\tstrkcount += strk\\n\\t\\t\\tif hstk and hstk[-1][0] == lefts:\\n\\t\\t\\t\\tstrkcount += hstk[-1][1]\\n\\t\\t\\t\\thstk[-1][1] += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif hstk:\\n\\t\\t\\t\\t\\t#dbp('sus')\\n\\t\\t\\t\\t\\thstk.append([lefts, 1])\\n\\n\\t\\t\\tif lefts < 0:\\n\\t\\t\\t\\tlefts = 0\\n\\t\\t\\tif not hstk:\\n\\t\\t\\t\\thstk = [[lefts, 0]]\\n\\t\\t\\t#dbp('post:', locals())\\n\\t\\t#dbp('base:', basecount, 'strkcount:', strkcount)\\n\\t\\treturn basecount+strkcount\\n\\n\\n\\t#sr = slow_solve()\\n\\tr = regret_solve()\\n\\t#dbp('results:', sr, r)\\n\\t#assert(sr ==...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Ayush, Ashish and Vivek are busy preparing a new problem for the next Codeforces round and need help checking if their test cases are valid.\\n\\nEach test case consists of an integer n and two arrays a and b, of size n. If after some (possibly zero) operations described below, array a can be transformed into array b, the input is said to be valid. Otherwise, it is invalid.\\n\\nAn operation on array a is: \\n\\n * select an integer k (1 ≤ k ≤ ⌊n\\/2⌋) \\n * swap the prefix of length k with the suffix of length k \\n\\n\\n\\nFor example, if array a initially is \\\\{1, 2, 3, 4, 5, 6\\\\}, after performing an operation with k = 2, it is transformed into \\\\{5, 6, 3, 4, 1, 2\\\\}.\\n\\nGiven the set of test cases, help them determine if each one is valid or invalid.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 500) — the number of test cases. The description of each test case is as follows.\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 500) — the size of the arrays.\\n\\nThe second line of each test case contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — elements of array a.\\n\\nThe third line of each test case contains n integers b_1, b_2, ..., b_n (1 ≤ b_i ≤ 10^9) — elements of array b.\\n\\nOutput\\n\\nFor each test case, print \\\"Yes\\\" if the given input is valid. Otherwise print \\\"No\\\".\\n\\nYou may print the answer in any case.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n2\\n1 2\\n2 1\\n3\\n1 2 3\\n1 2 3\\n3\\n1 2 4\\n1 3 4\\n4\\n1 2 3 2\\n3 1 2 2\\n3\\n1 2 3\\n1 3 2\\n\\n\\nOutput\\n\\n\\nyes\\nyes\\nNo\\nyes\\nNo\\n\\nNote\\n\\nFor the first test case, we can swap prefix a[1:1] with suffix a[2:2] to get a=[2, 1].\\n\\nFor the second test case, a is already equal to b.\\n\\nFor the third test case, it is impossible since we cannot obtain 3 in a.\\n\\nFor the fourth test case, we can first swap prefix a[1:1] with suffix a[4:4] to obtain a=[2, 2, 3, 1]. Now we can swap prefix a[1:2] with suffix a[3:4] to obtain a=[3, 1, 2, 2].\\n\\nFor the fifth test case, it is impossible to convert a to b.\\nSolve the task in PYTHON3.\",\"targets\":\"'''\\n Auther: ghoshashis545 Ashis Ghosh\\n College: jalpaiguri Govt Enggineering College\\n Date:09\\/06\\/2020\\n\\n'''\\nfrom os import path\\nimport sys\\nfrom functools import cmp_to_key as ctk\\nfrom collections import deque,defaultdict as dd \\nfrom bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right\\nfrom itertools import permutations\\nfrom datetime import datetime\\nfrom math import ceil,sqrt,log,gcd\\ndef ii():return int(input())\\ndef si():return input()\\ndef mi():return map(int,input().split())\\ndef li():return list(mi())\\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': 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#mod=998244353\\ninf = float(\\\"inf\\\")\\nvow=['a','e','i','o','u']\\ndx,dy=[-1,1,0,0],[0,0,1,-1]\\n\\n \\n\\n \\n \\n \\n \\ndef solve():\\n \\n \\n for _ in range(ii()):\\n \\n n=ii()\\n a=li()\\n b=li()\\n f=1\\n if(n%2 and a[n\\/\\/2]!=b[n\\/\\/2]):\\n f=0\\n m={}\\n for i in range(n\\/\\/2):\\n x=[min(a[i],a[n-i-1]),max(a[i],a[n-i-1])]\\n x=tuple(x)\\n if x not in m:\\n m[x]=0\\n m[x]+=1\\n for i in range(n\\/\\/2):\\n x=[min(b[i],b[n-i-1]),max(b[i],b[n-i-1])]\\n x=tuple(x)\\n if x not in m or m[x]==0:\\n f=0\\n break\\n m[x]-=1\\n print(\\\"Yes\\\" if f else \\\"No\\\")\\n \\n \\n \\n \\n \\n \\n \\n \\n \\nif __name__ ==\\\"__main__\\\":\\n solve()\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Aaron is a vicious criminal. He has repeatedly committed crimes (2 shoplifting, 16 peeping, 256 underwear thieves, 65,536 escapes), but has continued to escape from the police with his extraordinary physical abilities. Bruce is a police officer. Although he does not have outstanding athletic ability, he enjoys photography and has the skill to publish his photographs in magazines.\\n\\nOne day Bruce came to take a picture in the mountains. Then I happened to find Aaron's hideout. As Bruce chased Aaron, who escaped, they fell into a pit and wandered into ancient ruins.\\n\\nThe ancient ruins consist of several rooms and passages connecting the rooms. When there are M rooms in the ancient ruins, the rooms in the ruins are numbered from 0 to M-1 respectively.\\n\\nAaron thought that it might expire while he was escaping, so he moved through the ruins so that he could continue to escape for the longest time when Bruce moved optimally. Bruce wants to photograph Aaron quickly, so he moves through the ruins so that Bruce can be photographed the fastest when Aaron moves optimally.\\n\\nAaron and Bruce act in turn. The first is Aaron's turn. In each turn, you can move to or stay in one of the adjacent rooms. When Aaron and Bruce enter the same room, Bruce shall photograph Aaron.\\n\\nFind out how long it will take Bruce to shoot Aaron. Time is expressed in terms of the number of turns, and when both Aaron and Bruce have acted once, it is counted as one turn.\\n\\nFor example, in the situation shown in Fig. 5, if Aaron escapes to room 5, Bruce will reach it in 4 turns, but if Aaron escapes to room 7, Bruce will take 5 turns to reach it. For Aaron, the answer is 5 turns because he can escape for the longest time by escaping to room 7.\\n\\nAn example where Aaron can continue to escape for 5 turns.\\n---\\nFigure 5: An example where Aaron keeps escaping for 5 turns.\\n\\nAlso, in the situation shown in Fig. 6, Aaron can escape forever by moving the room away from Bruce.\\n\\nAn example of Aaron being able to escape forever.\\n---\\nFigure 6: An example of Aaron...\\nSolve the task in CPP.\",\"targets\":\"#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n\\nusing namespace std;\\n\\n#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)\\n#define REP(i,n) FOR(i,0,n)\\n#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)\\n\\ntemplate void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<\\\" \\\"; cerr<= 0 && y >= 0 && x < W && y < H); }\\n\\ntypedef long long ll;\\nconst int INF = 100000000;\\nconst double EPS = 1e-8;\\nconst int MOD = 1000000007;\\nint dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};\\nint dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};\\nint memo[50][50][2];\\nint dfs(int a, int b, int turn, const vector< vector >& G){\\n if(memo[a][b][turn] != -1) return memo[a][b][turn];\\n if(a == b) return memo[a][b][turn] = 0;\\n memo[a][b][turn] = INF;\\n if(turn == 0){\\n \\/\\/ Aaron - escape\\n int res = dfs(a, b, turn ^ 1, G);\\n FORIT(u, G[a]){\\n int next = dfs(*u, b, turn ^ 1, G);\\n res = max(res, next);\\n }\\n return memo[a][b][turn] = res;\\n }else{\\n \\/\\/ Bruce - chase\\n int res = 1 + dfs(a, b, turn ^ 1, G);\\n FORIT(u, G[b]){\\n int next = dfs(a, *u, turn ^ 1, G);\\n res = min(res, 1 + next);\\n }\\n return memo[a][b][turn] = res;\\n }\\n}\\n\\nint main(){\\n int T; cin >> T;\\n while(T--){\\n int N; cin >> N;\\n vector< vector > G(N);\\n REP(i, N)REP(j, N){\\n int t; cin >> t;\\n if(t) G[i].push_back(j);\\n }\\n REP(i, N) G[i].push_back(i);\\n int sa, sb;\\n cin >> sa >> sb;\\n \\/\\/memset(memo, -1, sizeof(memo));\\n \\/\\/int ans = dfs(a, b, 0, G);\\n int dp[50][50][2] = {};\\n memset(dp, -1, sizeof(dp));\\n REP(i, N) dp[i][i][0] = 0;\\n REP(iter, 1000){\\n for(int a = 0; a < N; a++){\\n for(int b = 0; b < N; b++){\\n if(a == b) continue;\\n dp[a][b][0] = -1;\\n REP(i, G[a].size()){\\n ...\",\"language\":\"python\",\"split\":\"train\",\"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....\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\ninline long long read() {\\n char ch = getchar();\\n long long p = 1, data = 0;\\n while (ch < '0' || ch > '9') {\\n if (ch == '-') p = -1;\\n ch = getchar();\\n }\\n while (ch >= '0' && ch <= '9') {\\n data = data * 10 + (ch ^ 48);\\n ch = getchar();\\n }\\n return p * data;\\n}\\ninline long long qpow(long long a, long long b) {\\n long long r = 1;\\n while (b) {\\n if (b & 1) r = a * r;\\n a = a * a;\\n b >>= 1;\\n }\\n return r;\\n}\\nvoid exgcd(long long a, long long b, long long &x, long long &y) {\\n if (!b)\\n x = 1, y = 0;\\n else {\\n exgcd(b, a % b, y, x);\\n y -= x * (a \\/ b);\\n }\\n}\\nconst int mod = 1e9 + 7, maxn = 5e5 + 5;\\nchar s[maxn];\\nint pos[27], mp[27], cnt[27], num[27];\\nint main() {\\n int T = read();\\n while (T--) {\\n scanf(\\\"%s\\\", s + 1);\\n memset(mp, 0, sizeof mp);\\n memset(pos, 0, sizeof pos);\\n memset(cnt, 0, sizeof cnt);\\n memset(num, 0, sizeof num);\\n int n = strlen(s + 1);\\n int tot = 0, ok = 1, len = 0;\\n for (int i = n; i >= 1; i--) {\\n if (!mp[s[i] - 'a']) mp[s[i] - 'a'] = ++tot;\\n cnt[s[i] - 'a']++;\\n }\\n for (int i = 0; i < 26; i++)\\n if (mp[i]) {\\n pos[i] = tot - mp[i] + 1;\\n if (cnt[i] % pos[i]) {\\n ok = 0;\\n break;\\n }\\n len += cnt[i] \\/ pos[i];\\n }\\n if (!ok) {\\n puts(\\\"-1\\\");\\n continue;\\n }\\n string ans = \\\"\\\", p = \\\"\\\";\\n for (int i = 1; i <= n; i++) {\\n int t = 1;\\n num[s[i] - 'a']++;\\n for (int j = 0; j < 26 && t; j++)\\n if (pos[j] && num[j] < cnt[j] \\/ pos[j]) t = 0;\\n ans += s[i];\\n if (t) break;\\n }\\n int m = ans.length();\\n for (int i = 1; i <= tot; i++)\\n for (int j = 0; j < m; j++)\\n if (pos[ans[j] - 'a'] >= i) p += ans[j];\\n if (p.length() == n) {\\n for (int i = 1; i <= n && ok; i++)\\n if (p[i - 1] != s[i]) ok = 0;\\n } else\\n ok = 0;\\n string tp = \\\"\\\";\\n for (int i = 1; i <= tot; i++)\\n for (int j = 0; j < 26; j++)\\n if (pos[j] == i) {\\n tp += (char)('a' + j);\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (x, y) coordinate system.\\n\\nWe are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells.\\n\\n\\n\\n\\nOriginally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side):\\n\\n\\n\\n\\nIn the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point.\\n\\nYour task is to write a program which reads a sequence of points of fall (x, y) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density.\\n\\nYou may assume that the paper always consists of 10 × 10, and 0 ≤ x < 10, 0 ≤ y < 10.\\n\\n\\n\\nInput\\n\\n\\nx1,y1,s1\\nx2,y2,s2\\n:\\n:\\n\\n\\n(xi, yi) represents the position of the i-th drop and si denotes its size. The number of drops is less than or equal to 50.\\n\\nOutput\\n\\nPrint the number of cells whose density value is 0 in first line.\\nPrint the maximum value of density in the second line.\\n\\nExample\\n\\nInput\\n\\n2,5,3\\n3,6,1\\n3,4,2\\n4,5,2\\n3,6,3\\n2,4,1\\n\\n\\nOutput\\n\\n77\\n5\\\":\",\"targets\":\"#include\\nusing namespace std;\\n\\nint main() {\\n\\tint x, y, c;\\n\\tint cnt = 0;\\n\\tint max=0;\\n\\tint map[10][10];\\n\\tint dx[] = { 0, -1, 1, 0, -1, 1, -1, 1, 0, -2, 2, 0 };\\n\\tint dy[] = { -1, 0, 0, 1, -1, -1, 1, 1, -2, 0, 0, 2 };\\n\\tfor (int i = 0; i < 10; ++i) {\\n\\t\\tfor (int j = 0; j < 10; ++j) {\\n\\t\\t\\tmap[i][j] = 0;\\n\\t\\t}\\n\\t}\\n\\twhile (scanf(\\\"%d,%d,%d\\\", &x, &y, &c) != EOF) {\\n\\t\\tmap[y][x]++;\\n\\t\\tfor (int i = 0; i < c * 4; ++i) {\\n\\t\\t\\tint mx = dx[i] + x;\\n\\t\\t\\tint my = dy[i] + y;\\n\\t\\t\\tif (mx >= 0 && mx < 10 && my >= 0 && my < 10) {\\n\\t\\t\\t\\tmap[my][mx]++;\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\tfor (int i = 0; i < 10; ++i) {\\n\\t\\tfor (int j = 0; j < 10; ++j) {\\n\\t\\t\\tif(max 0)\\n B.go();\\n out.flush();\\n}\\n\\n\\/\\/ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Code Starts <<<<<<<<<<<<<<<<<<<<<<<<<<<<< \\/\\/\\nstatic int mod=(int)1e9+7;\\nstatic class helper{\\n\\tint x;int y;int z;\\n\\thelper(int x,int y,int z){\\n\\t\\tthis.x=x;\\n\\t\\tthis.y=y;\\n\\t\\tthis.z=z;\\n\\t}\\n\\n}\\nstatic boolean check(int x,int y ,int n,int m) {\\n\\tif(x<0||y<0||x>=n||y>=m) {\\n\\t\\treturn false;\\n\\t}\\n\\treturn true;\\n}\\nstatic void go() throws Exception {\\nint n=sc.nextInt();\\nint m=sc.nextInt();\\n\\/\\/ beautiful problem using the property of xor a^b=c also then a^c=b.\\nint ans=0;\\nint p=m+1;\\n\\tfor(int j=31;j>=0 && n0) {\\n\\t\\t\\tans|=1<0 && (p&(1<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Code Ends <<<<<<<<<<<<<<<<<<<<<<<<<<<<< \\/\\/\\n\\n\\nstatic long gcd(long a,long b){\\n if(b==0){\\n return a;\\n }return gcd(b,a%b);\\n}\\nstatic long fact[];\\nstatic long invfact[];\\nstatic long ncr(int n,int k) {\\n\\tif(k<0||k>n) {\\n\\t\\treturn 0;\\n\\t}\\n\\tlong x=fact[n]%mod;\\n\\tlong y=invfact[k]%mod;\\n\\tlong yy=invfact[n-k]%mod;\\n\\tlong ans=(x*y)%mod;\\n\\tans=(ans*yy)%mod;\\n\\treturn ans;\\n}\\nstatic int prime[]=new int[40006];\\nstatic void sieve() {\\n\\tArrays.fill(prime, 1);\\n\\tprime[0]=0;\\n\\tprime[1]=0;\\n\\tfor(int i=2;i*i<=40005;i++) {\\n\\t\\tif(prime[i]==1) {\\n\\t\\tfor(int j=i*i;j<=40005;j+=i) {\\n\\t\\t\\tprime[j]=0;\\n\\t\\t}\\n\\t\\t}\\n\\t}\\n\\t\\n\\/\\/\\tfor(int i=1;i<1000005;i++) {prime[i]=prime[i]+prime[i-1];}\\n}\\nstatic void sort(long [] a) {\\n ArrayList aa = new ArrayList<>();\\n for (long i : a) {\\n aa.add(i);\\n }Collections.sort(aa); for (int i = 0; i < a.length; i++)\\n a[i] = aa.get(i);\\t }\\nstatic void sort(int [] a) {\\n ArrayList aa = new ArrayList<>();\\n for (int i : a) {\\n aa.add(i);\\n }...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given a strictly convex polygon with n vertices.\\n\\nYou will make k cuts that meet the following conditions: \\n\\n * each cut is a segment that connects two different nonadjacent vertices; \\n * two cuts can intersect only at vertices of the polygon. \\n\\n\\n\\nYour task is to maximize the area of the smallest region that will be formed by the polygon and those k cuts.\\n\\nInput\\n\\nThe first line contains two integers n, k (3 ≤ n ≤ 200, 0 ≤ k ≤ n-3).\\n\\nThe following n lines describe vertices of the polygon in anticlockwise direction. The i-th line contains two integers x_i, y_i (|x_i|, |y_i| ≤ 10^8) — the coordinates of the i-th vertex.\\n\\nIt is guaranteed that the polygon is convex and that no two adjacent sides are parallel.\\n\\nOutput\\n\\nPrint one integer: the maximum possible area of the smallest region after making k cuts multiplied by 2.\\n\\nExamples\\n\\nInput\\n\\n\\n8 4\\n-2 -4\\n2 -2\\n4 2\\n1 5\\n0 5\\n-4 4\\n-5 0\\n-5 -1\\n\\n\\nOutput\\n\\n\\n11\\n\\n\\nInput\\n\\n\\n6 3\\n2 -2\\n2 -1\\n1 2\\n0 2\\n-2 1\\n-1 0\\n\\n\\nOutput\\n\\n\\n3\\n\\nNote\\n\\nIn the first example, it's optimal to make cuts between the following pairs of vertices: \\n\\n * (-2, -4) and (4, 2), \\n * (-2, -4) and (1, 5), \\n * (-5, -1) and (1, 5), \\n * (-5, 0) and (0, 5). \\n\\n Points (-5, -1), (1, 5), (0, 5), (-5, 0) determine the smallest region with double area of 11. \\n\\nIn the second example, it's optimal to make cuts between the following pairs of vertices: \\n\\n * (2, -1) and (0, 2), \\n * (2, -1) and (1, 0), \\n * (-1, 0) and (0, 2). \\n\\n Points (2, -2), (2, -1), (-1, 0) determine one of the smallest regions with double area of 3. \\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nconst int IINF = 0x3f3f3f3f;\\nconst long long LINF = 0x3f3f3f3f3f3f3f3fLL;\\nconst double DINF = numeric_limits::infinity();\\nconst double DNAN = numeric_limits::quiet_NaN();\\nconst double EPS = 1e-9;\\nconst double PI = acos((double)-1.0);\\nconst int DX[] = {1, 0, -1, 0, 1, -1, 1, -1};\\nconst int DY[] = {0, 1, 0, -1, 1, -1, -1, 1};\\nlong long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }\\nlong long sqr(long long x) { return x * x; }\\nlong long sqr(int x) { return (long long)x * x; }\\ndouble sqr(double x) { return x * x; }\\nmt19937 mmtw(960172);\\nlong long rnd(long long x, long long y) {\\n static uniform_int_distribution d;\\n return d(mmtw) % (y - x + 1) + x;\\n}\\ntemplate \\nT& updMin(T& a, M const& b) {\\n if (b < a) a = b;\\n return a;\\n}\\ntemplate \\nT& updMax(T& a, M const& b) {\\n if (a < b) a = b;\\n return a;\\n}\\nlong long divFloor(long long a, long long b) {\\n if (b < 0) {\\n a = -a;\\n b = -b;\\n }\\n return a >= 0 ? a \\/ b : (a - b + 1) \\/ b;\\n}\\nlong long divCeil(long long a, long long b) {\\n if (b < 0) {\\n a = -a;\\n b = -b;\\n }\\n return a >= 0 ? (a + b - 1) \\/ b : a \\/ b;\\n}\\nlong long divFloorS(long long a, long long b) {\\n if (b < 0) {\\n a = -a;\\n b = -b;\\n }\\n return a >= 0 ? (a + b - 1) \\/ b - 1 : a \\/ b - 1;\\n}\\nlong long divCeilS(long long a, long long b) {\\n if (b < 0) {\\n a = -a;\\n b = -b;\\n }\\n return a >= 0 ? a \\/ b + 1 : (a - b + 1) \\/ b + 1;\\n}\\ntemplate \\nV getOrDef(map const& a, K const& k, V const& def = V()) {\\n auto it = a.find(k);\\n return it == a.end() ? def : it->second;\\n}\\ntemplate \\nV getOrDef(unordered_map const& a, K const& k, V const& def = V()) {\\n auto it = a.find(k);\\n return it == a.end() ? def : it->second;\\n}\\ntemplate \\nistream& operator>>(istream& in, pair& p) {\\n return in >> p.first >> p.second;\\n}\\ntemplate \\nostream& operator<<(ostream& out, pair...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 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\":\"from collections import defaultdict\\nfor i in range(int(input())):\\n n,k = map(int,input().split())\\n s = list(map(int,input().split()))\\n # print(sorted(s))\\n mp = defaultdict(list)\\n for j in range(n):\\n mp[s[j]].append(j)\\n s[j] = 0\\n # print(s)\\n m = 1\\n dic = {}\\n mn_occ = int(1e9)\\n for val in mp.values():\\n m = m%k\\n if m == 0:\\n m = k\\n temp_ln = len(val)\\n mx = min(k,temp_ln)\\n # print(val,m)\\n for i in range(mx):\\n m = m%k\\n if m == 0:\\n m = k\\n s[val[i]] = m\\n dic[m] = dic.get(m,0) + 1\\n m+=1\\n for val in dic.values():\\n mn_occ = min(mn_occ,val)\\n # print(dic)\\n # print(*s)\\n # print(mn_occ)\\n for idx in range(n):\\n # print(s[idx])\\n if (dic.get(s[idx],-1) > mn_occ):\\n # print(dic[s[idx]])\\n dic[s[idx]] = dic[s[idx]] - 1\\n s[idx] = 0\\n\\n # print(set(s))\\n # print(dic)\\n # for i in set(s):\\n # print(s.count(i),end =\\\" \\\")\\n # print()\\n print(*s)\\n # print(ans\\/\\/k)\",\"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...\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int t;\\n cin >> t;\\n while (t--) {\\n string s;\\n cin >> s;\\n int count1 = 0, count2 = 0, unknown1 = 0, unknown2 = 0;\\n for (int i = 0; i < s.length(); i++) {\\n int remaining = 9 - i, remaining1, remaining2;\\n if (i % 2 == 0) {\\n s[i] == '1' ? count1++ : s[i] == '?' && unknown1++;\\n remaining1 = remaining \\/ 2;\\n remaining2 = remaining - remaining1;\\n } else {\\n s[i] == '1' ? count2++ : s[i] == '?' && unknown2++;\\n remaining2 = remaining \\/ 2;\\n remaining1 = remaining - remaining2;\\n }\\n if (count1 + unknown1 > count2 + remaining2) {\\n cout << i + 1 << '\\\\n';\\n break;\\n } else if (count2 + unknown2 > count1 + remaining1) {\\n cout << i + 1 << '\\\\n';\\n break;\\n }\\n if (i == 9) {\\n cout << 10 << '\\\\n';\\n }\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Acacius is studying strings theory. Today he came with the following problem.\\n\\nYou are given a string s of length n consisting of lowercase English letters and question marks. It is possible to replace question marks with lowercase English letters in such a way that a string \\\"abacaba\\\" occurs as a substring in a resulting string exactly once?\\n\\nEach question mark should be replaced with exactly one lowercase English letter. For example, string \\\"a?b?c\\\" can be transformed into strings \\\"aabbc\\\" and \\\"azbzc\\\", but can't be transformed into strings \\\"aabc\\\", \\\"a?bbc\\\" and \\\"babbc\\\".\\n\\nOccurrence of a string t of length m in the string s of length n as a substring is a index i (1 ≤ i ≤ n - m + 1) such that string s[i..i+m-1] consisting of m consecutive symbols of s starting from i-th equals to string t. For example string \\\"ababa\\\" has two occurrences of a string \\\"aba\\\" as a substring with i = 1 and i = 3, but there are no occurrences of a string \\\"aba\\\" in the string \\\"acba\\\" as a substring.\\n\\nPlease help Acacius to check if it is possible to replace all question marks with lowercase English letters in such a way that a string \\\"abacaba\\\" occurs as a substring in a resulting string exactly once.\\n\\nInput\\n\\nFirst line of input contains an integer T (1 ≤ T ≤ 5000), number of test cases. T pairs of lines with test case descriptions follow.\\n\\nThe first line of a test case description contains a single integer n (7 ≤ n ≤ 50), length of a string s.\\n\\nThe second line of a test case description contains string s of length n consisting of lowercase English letters and question marks.\\n\\nOutput\\n\\nFor each test case output an answer for it.\\n\\nIn case if there is no way to replace question marks in string s with a lowercase English letters in such a way that there is exactly one occurrence of a string \\\"abacaba\\\" in the resulting string as a substring output \\\"No\\\".\\n\\nOtherwise output \\\"Yes\\\" and in the next line output a resulting string consisting of n lowercase English letters. If there are multiple possible strings, output any.\\n\\nYou may print every letter in...\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"r=\\\"abacaba\\\"\\ndef count(s):\\n a=[0]\\n a+=[s[i] for i in range(6)]\\n out=0\\n z=0\\n for i in range(n-6):\\n a.pop(0)\\n a.append(s[i+6])\\n for j in range(7):\\n if(a[j]==r[j]):\\n z+=1\\n if(z==7):\\n out+=1\\n z=0\\n return out\\ndef make(s):\\n for j in range(len(s)):\\n if(s[j]==\\\"?\\\"):\\n s[j]=\\\"x\\\"\\n return s \\n \\nfor _ in range(int(input())):\\n n=int(input())\\n w=input()\\n s=[i for i in w]\\n \\n if(count(s)>1):\\n print(\\\"No\\\")\\n elif(count==1):\\n print(\\\"YES\\\")\\n s=make(s)\\n print(''.join(s))\\n else: \\n temp=0\\n a=[0]\\n poss=0\\n a+=[s[i] for i in range(6)]\\n for i in range(n-6):\\n a.pop(0)\\n a.append(s[i+6])\\n for j in range(7):\\n if(a[j]==r[j] or a[j]==\\\"?\\\"):\\n temp+=1\\n if(temp==7):\\n S=[i for i in s]\\n for j in range(7):\\n S[i+j]=r[j]\\n S=make(S) \\n if(count(S)==1):\\n print(\\\"YES\\\")\\n print(''.join(S))\\n poss=1\\n break\\n temp=0\\n if(poss==0):\\n print(\\\"NO\\\")\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"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...\",\"targets\":\"import java.text.DecimalFormat;\\nimport java.util.*;\\nimport java.io.*;\\n\\npublic class Main {\\n\\n static long startTime = System.currentTimeMillis();\\n\\n \\/\\/ for global initializations and methods starts here\\n\\n \\/\\/ global initialisations and methods end here\\n\\n static void run() {\\n boolean tc = true;\\n AdityaFastIO r = new AdityaFastIO();\\n \\/\\/FastReader r = new FastReader();\\n\\n try (OutputStream out = new BufferedOutputStream(System.out)) {\\n\\n \\/\\/long startTime = System.currentTimeMillis();\\n\\n int testcases = tc ? r.ni() : 1;\\n int tcCounter = 1;\\n \\/\\/ Hold Here Sparky------------------->>>\\n \\/\\/ Solution Starts Here\\n\\n start:\\n while (testcases-- > 0) {\\n\\n long W = r.nl();\\n long H = r.nl();\\n\\n long x1 = r.nl();\\n long y1 = r.nl();\\n\\n long x2 = r.nl();\\n long y2 = r.nl();\\n\\n long w = r.nl();\\n long h = r.nl();\\n\\n DecimalFormat df = new DecimalFormat(\\\"0.000000000\\\");\\n long ans = 0;\\n if (h <= Math.max(H - y2, y1) || w <= Math.max(W - x2, x1))\\n out.write((df.format(ans) + \\\" \\\").getBytes());\\n else {\\n if ((h + (y2 - y1)) <= H) {\\n if ((w + (x2 - x1)) > W) {\\n long max1 = Math.max(H - y2, y1);\\n ans = h - max1;\\n out.write((df.format(ans) + \\\" \\\").getBytes());\\n } else {\\n long max1 = Math.max(x1, W - x2);\\n long max2 = Math.max(y1, H - y2);\\n ans = Math.min(w - max1, h - max2);\\n out.write((df.format(ans) + \\\" \\\").getBytes());\\n }\\n } else {\\n if ((w + (x2 - x1)) <= W) {\\n ans = w - Math.max(x1, W - x2);\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A tournament is a directed graph without self-loops in which every pair of vertexes is connected by exactly one directed edge. That is, for any two vertexes u and v (u ≠ v) exists either an edge going from u to v, or an edge from v to u.\\n\\nYou are given a tournament consisting of n vertexes. Your task is to find there a cycle of length three.\\n\\nInput\\n\\nThe first line contains an integer n (1 ≤ n ≤ 5000). Next n lines contain the adjacency matrix A of the graph (without spaces). Ai, j = 1 if the graph has an edge going from vertex i to vertex j, otherwise Ai, j = 0. Ai, j stands for the j-th character in the i-th line.\\n\\nIt is guaranteed that the given graph is a tournament, that is, Ai, i = 0, Ai, j ≠ Aj, i (1 ≤ i, j ≤ n, i ≠ j).\\n\\nOutput\\n\\nPrint three distinct vertexes of the graph a1, a2, a3 (1 ≤ ai ≤ n), such that Aa1, a2 = Aa2, a3 = Aa3, a1 = 1, or \\\"-1\\\", if a cycle whose length equals three does not exist. \\n\\nIf there are several solutions, print any of them.\\n\\nExamples\\n\\nInput\\n\\n5\\n00100\\n10000\\n01001\\n11101\\n11000\\n\\n\\nOutput\\n\\n1 3 2 \\n\\nInput\\n\\n5\\n01111\\n00000\\n01000\\n01100\\n01110\\n\\n\\nOutput\\n\\n-1\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.lang.*;\\nimport java.math.BigInteger;\\nimport java.io.*;\\nimport java.util.*;\\n\\npublic class Solution implements Runnable{\\n public static BufferedReader br;\\n public static PrintWriter out;\\n public static StringTokenizer stk;\\n public static boolean isStream = true;\\n\\n public static void main(String[] args) throws IOException {\\n \\tif (isStream) {\\n br = new BufferedReader(new InputStreamReader(System.in));\\n } else {\\n br = new BufferedReader(new FileReader(\\\"in.txt\\\"));\\n }\\n out = new PrintWriter(System.out);\\n new Thread(new Solution()).start();\\n }\\n\\n public void loadLine() {\\n try {\\n stk = new StringTokenizer(br.readLine());\\n } catch (IOException e) {\\n e.printStackTrace();\\n }\\n }\\n\\n public String nextLine() {\\n try {\\n return br.readLine();\\n } catch (IOException e) {\\n e.printStackTrace();\\n return \\\"\\\";\\n }\\n }\\n\\n public String nextWord() {\\n while (stk==null||!stk.hasMoreTokens()) loadLine();\\n return stk.nextToken();\\n }\\n\\n public Integer nextInt() {\\n while (stk==null||!stk.hasMoreTokens()) loadLine();\\n return Integer.valueOf(stk.nextToken());\\n }\\n\\n public Long nextLong() {\\n while (stk==null||!stk.hasMoreTokens()) loadLine();\\n return Long.valueOf(stk.nextToken());\\n }\\n\\n public Double nextDouble() {\\n while (stk==null||!stk.hasMoreTokens()) loadLine();\\n return Double.valueOf(stk.nextToken());\\n }\\n \\n public Float nextFloat() {\\n while (stk==null||!stk.hasMoreTokens()) loadLine();\\n return Float.valueOf(stk.nextToken());\\n }\\n \\n boolean[][] map;\\n int[] c;\\n int cv = -1;\\n int n;\\n ArrayList cyc;\\n \\n boolean dfs(int a) {\\n \\tc[a] = 1;\\n \\tfor (int i = 0; i < n; i++) {\\n \\t\\tif (map[a][i]) {\\n \\t\\t\\tif (c[i] == 0) {\\n \\t\\t\\t\\tboolean res = dfs(i);\\n \\t\\t\\t\\tif (res) {\\n \\t\\t\\t\\t\\tcyc.add(i);\\n \\t\\t\\t\\t\\tif (cv != a) {\\n\\t \\t\\t\\t\\t\\t\\n\\t ...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Jury picked a polynomial f(x) = a_0 + a_1 ⋅ x + a_2 ⋅ x^2 + ... + a_k ⋅ x^k. k ≤ 10 and all a_i are integer numbers and 0 ≤ a_i < 10^6 + 3. It's guaranteed that there is at least one i such that a_i > 0.\\n\\nNow jury wants you to find such an integer x_0 that f(x_0) ≡ 0 mod (10^6 + 3) or report that there is not such x_0.\\n\\nYou can ask no more than 50 queries: you ask value x_q and jury tells you value f(x_q) mod (10^6 + 3).\\n\\nNote that printing the answer doesn't count as a query.\\n\\nInteraction\\n\\nTo ask a question, print \\\"? x_q\\\" (0 ≤ x_q < 10^6 + 3). The judge will respond with a single integer f(x_q) mod (10^6 + 3). If you ever get a result of −1 (because you printed an invalid query), exit immediately to avoid getting other verdicts.\\n\\nAfter printing 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\\nWhen you are ready to answer, print \\\"! x_0\\\" where x_0 is the answer or -1 if there is no such x_0.\\n\\nYou can ask at most 50 questions per test case.\\n\\nHack Format\\n\\nTo hack, use the following format.\\n\\nThe only line should contain 11 integers a_0, a_1, ..., a_{10} (0 ≤ a_i < 10^6 + 3, max_{0 ≤ i ≤ 10}{a_i} > 0) — corresponding coefficients of the polynomial.\\n\\nExamples\\n\\nInput\\n\\n\\n \\n1000002\\n\\n0\\n\\n\\nOutput\\n\\n\\n? 0\\n\\n? 1\\n\\n! 1\\n\\nInput\\n\\n\\n \\n5\\n\\n2\\n\\n1\\n\\n\\n\\nOutput\\n\\n\\n? 2\\n\\n? 1\\n\\n? 0\\n\\n! -1\\n\\nNote\\n\\nThe polynomial in the first sample is 1000002 + x^2.\\n\\nThe polynomial in the second sample is 1 + x^2.\\\":\",\"targets\":\"#include \\nusing namespace std;\\nconst long long MOD = 1e6 + 3;\\nlong long a[305][305];\\nlong long quick_pow(long long x, long long a) {\\n long long ans = 1;\\n while (a) {\\n if (a & 1) ans = ans * x % MOD;\\n x = x * x % MOD;\\n a >>= 1;\\n }\\n return ans;\\n}\\nint main() {\\n for (int i = 0; i <= 10; i++) {\\n printf(\\\"? %d\\\\n\\\", i);\\n fflush(stdout);\\n int v;\\n scanf(\\\"%d\\\", &v);\\n a[i][0] = 1;\\n for (int j = 1; j <= 10; j++) a[i][j] = a[i][j - 1] * i % MOD;\\n a[i][11] = v;\\n }\\n for (int i = 0; i <= 10; i++) {\\n int now = i;\\n for (int j = i; j <= 10; j++) {\\n if (a[j][i]) {\\n now = j;\\n break;\\n }\\n }\\n for (int j = i; j <= 11; j++) swap(a[now][j], a[i][j]);\\n for (int j = i + 1; j <= 10; j++) {\\n long long v = quick_pow(a[i][i], MOD - 2) * a[j][i] % MOD;\\n for (int k = i; k <= 11; k++)\\n a[j][k] = (a[j][k] + MOD - a[i][k] * v % MOD) % MOD;\\n }\\n }\\n for (int i = 10; i >= 0; i--) {\\n long long v = quick_pow(a[i][i], MOD - 2);\\n a[i][11] = a[i][11] * v;\\n a[i][i] = 1;\\n for (int j = i - 1; j >= 0; j--)\\n a[j][11] = (a[j][11] + MOD - a[i][11] * a[j][i] % MOD) % MOD;\\n }\\n for (int v = 0; v <= 1000002; v++) {\\n long long ans = 0, pow = 1;\\n for (int j = 0; j <= 10; j++) {\\n ans += a[j][11] * pow % MOD;\\n pow = pow * v % MOD;\\n }\\n ans %= MOD;\\n if (ans == 0) {\\n printf(\\\"! %d\\\\n\\\", v);\\n return 0;\\n }\\n }\\n printf(\\\"! -1\\\\n\\\");\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"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\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst long long inf = INT_MAX, df = 2e6 + 7;\\nlong long i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a[df], b[df],\\n vis[df], ans;\\npriority_queue que[df];\\ninline long long read() {\\n long long x = 0, y = 1;\\n char ch = getchar();\\n while (ch > '9' || ch < '0') ch = getchar();\\n while (ch >= '0' && ch <= '9')\\n x = (x << 3) + (x << 1) + ch - '0', ch = getchar();\\n return x * y;\\n}\\nint main() {\\n n = read(), m = read();\\n for (long long i = (1); i <= (m); i++) {\\n a[i] = read(), b[i] = read(), que[a[i]].push(a[i] + b[i]);\\n }\\n long long fir = 0;\\n for (long long i = (1); i <= (n); i++) {\\n if (!fir) {\\n for (i = 1; que[i].empty(); ++i)\\n ;\\n fir = 1;\\n }\\n long long maxr = que[i].top(), ty = 0;\\n for (long long j = (i + 1); j <= (que[i].top()); j++) {\\n if (!que[j].empty()) {\\n if (maxr < que[j].top()) {\\n ty = j, maxr = que[j].top();\\n }\\n }\\n }\\n vis[i] = 1;\\n ans++;\\n if (maxr > que[i].top()) {\\n i = ty - 1;\\n } else {\\n for (i = que[i].top() + 1; que[i].empty(); i++)\\n ;\\n i--;\\n }\\n }\\n printf(\\\"%lld\\\\n\\\", m - ans);\\n for (long long i = (1); i <= (m); i++) {\\n if (vis[a[i]]) {\\n if (a[i] + b[i] != que[a[i]].top()) {\\n printf(\\\"%lld \\\", i);\\n } else\\n vis[a[i]] = 0;\\n } else\\n printf(\\\"%lld \\\", i);\\n }\\n return puts(\\\"\\\"), 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"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. \\n \\/\\/pa\",\"targets\":\"ckage eround101;\\n\\nimport java.util.*;\\nimport java.io.*;\\nimport java.lang.*;\\nimport java.util.StringTokenizer;\\n\\npublic class Solution {\\n\\n static HritikScanner sc = new HritikScanner();\\n static PrintWriter pw = new PrintWriter(System.out, true);\\n final static int MOD = 1000000007;\\n\\n public static void main(String[] args) {\\n\\n int t = ni();\\n while (t-- > 0) {\\n solve();\\n }\\n }\\n\\n static void solve() {\\n int n = ni();\\n int[] arr = nextIntArray(n);\\n Arrays.sort(arr);\\n Map map = new HashMap<>();\\n for(int i = 0; i< n; i++)\\n {\\n map.put(arr[i], map.getOrDefault(arr[i], 0)+1);\\n }\\n Stack stk = new Stack<>();\\n long[] dp = new long[n+1];\\n long[] ans = new long[n+1];\\n \\/\\/Arrays.fill(ans, -1);\\n int ind = n+1;\\n for(int i = 0; i <= n; i++)\\n {\\n if(map.containsKey(i))\\n {\\n ans[i] = map.get(i);\\n }\\n if(i > 0)\\n {\\n \\/\\/ System.out.println(Arrays.toString(dp));\\n if(!map.containsKey(i-1))\\n {\\n int p = Arrays.binarySearch(arr, i-1);\\n p = -p-1;\\n \\/\\/pl(i+\\\" \\\"+p+\\\" \\\"+(i-1));\\n if(p <= i-1)\\n {\\n ans[i] = -1;\\n ind = i;\\n break;\\n }\\n else\\n {\\n if(stk.isEmpty())\\n {\\n ans[i] = -1;\\n ind = i;\\n break;\\n }\\n else{\\n int top = stk.pop();\\n dp[i] += (i-1) - top;\\n }\\n }\\n }\\n dp[i] += dp[i-1];\\n }\\n ans[i] += dp[i];\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A penguin Rocher has n sticks. He has exactly one stick with length i for all 1 ≤ i ≤ n.\\n\\nHe can connect some sticks. If he connects two sticks that have lengths a and b, he gets one stick with length a + b. Two sticks, that were used in the operation disappear from his set and the new connected stick appears in his set and can be used for the next connections.\\n\\nHe wants to create the maximum number of sticks that have the same length. It is not necessary to make all sticks have the same length, some sticks can have the other length. How many sticks with the equal length he can create?\\n\\nInput\\n\\nThe input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases. Next t lines contain descriptions of test cases.\\n\\nFor each test case, the only line contains a single integer n (1 ≤ n ≤ 10^{9}).\\n\\nOutput\\n\\nFor each test case, print a single integer — the answer to the problem.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n1\\n2\\n3\\n4\\n\\n\\nOutput\\n\\n\\n1\\n1\\n2\\n2\\n\\nNote\\n\\nIn the third case, he can connect two sticks with lengths 1 and 2 and he will get one stick with length 3. So, he will have two sticks with lengths 3.\\n\\nIn the fourth case, he can connect two sticks with lengths 1 and 3 and he will get one stick with length 4. After that, he will have three sticks with lengths \\\\{2, 4, 4\\\\}, so two sticks have the same length, and one stick has the other length.\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"#!\\/usr\\/bin\\/env python3\\nnb_cases = int(input())\\n\\nfor case in range(nb_cases):\\n n = int(input())\\n print((n+1)\\/\\/2)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"According to rules of the Berland fashion, a jacket should be fastened by all the buttons except only one, but not necessarily it should be the last one. Also if the jacket has only one button, it should be fastened, so the jacket will not swinging open.\\n\\nYou are given a jacket with n buttons. Determine if it is fastened in a right way.\\n\\nInput\\n\\nThe first line contains integer n (1 ≤ n ≤ 1000) — the number of buttons on the jacket.\\n\\nThe second line contains n integers ai (0 ≤ ai ≤ 1). The number ai = 0 if the i-th button is not fastened. Otherwise ai = 1.\\n\\nOutput\\n\\nIn the only line print the word \\\"YES\\\" if the jacket is fastened in a right way. Otherwise print the word \\\"NO\\\".\\n\\nExamples\\n\\nInput\\n\\n3\\n1 0 1\\n\\n\\nOutput\\n\\nYES\\n\\n\\nInput\\n\\n3\\n1 0 0\\n\\n\\nOutput\\n\\nNO\",\"targets\":\"def solution():\\n input()\\n l = input().strip().split()\\n if len(l) == 1:\\n print('YES' if l[0] == '1' else 'NO')\\n return\\n print('YES' if l.count('0') == 1 else 'NO')\\n\\nsolution()\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"After seeing the \\\"ALL YOUR BASE ARE BELONG TO US\\\" meme for the first time, numbers X and Y realised that they have different bases, which complicated their relations.\\n\\nYou're given a number X represented in base bx and a number Y represented in base by. Compare those two numbers.\\n\\nInput\\n\\nThe first line of the input contains two space-separated integers n and bx (1 ≤ n ≤ 10, 2 ≤ bx ≤ 40), where n is the number of digits in the bx-based representation of X. \\n\\nThe second line contains n space-separated integers x1, x2, ..., xn (0 ≤ xi < bx) — the digits of X. They are given in the order from the most significant digit to the least significant one.\\n\\nThe following two lines describe Y in the same way: the third line contains two space-separated integers m and by (1 ≤ m ≤ 10, 2 ≤ by ≤ 40, bx ≠ by), where m is the number of digits in the by-based representation of Y, and the fourth line contains m space-separated integers y1, y2, ..., ym (0 ≤ yi < by) — the digits of Y.\\n\\nThere will be no leading zeroes. Both X and Y will be positive. All digits of both numbers are given in the standard decimal numeral system.\\n\\nOutput\\n\\nOutput a single character (quotes for clarity): \\n\\n * '<' if X < Y\\n * '>' if X > Y\\n * '=' if X = Y\\n\\nExamples\\n\\nInput\\n\\n6 2\\n1 0 1 1 1 1\\n2 10\\n4 7\\n\\n\\nOutput\\n\\n=\\n\\n\\nInput\\n\\n3 3\\n1 0 2\\n2 5\\n2 4\\n\\n\\nOutput\\n\\n<\\n\\n\\nInput\\n\\n7 16\\n15 15 4 0 0 7 10\\n7 9\\n4 8 0 3 1 5 0\\n\\n\\nOutput\\n\\n>\\n\\nNote\\n\\nIn the first sample, X = 1011112 = 4710 = Y.\\n\\nIn the second sample, X = 1023 = 215 and Y = 245 = 1123, thus X < Y.\\n\\nIn the third sample, and Y = 48031509. We may notice that X starts with much larger digits and bx is much larger than by, so X is clearly larger than Y.\",\"targets\":\"#include \\nusing namespace std;\\nlong long Deci(int arr[], int base, int n) {\\n long long power = 1;\\n long long num = 0;\\n for (int i = n - 1; i >= 0; i--) {\\n num += arr[i] * power;\\n power = power * base;\\n }\\n return num;\\n}\\nint main() {\\n int n, m, x, y;\\n cin >> n >> x;\\n int arr[n + 3];\\n for (int i = 0; i < n; i++) {\\n cin >> arr[i];\\n }\\n cin >> m >> y;\\n int brr[m + 3];\\n for (int i = 0; i < m; i++) {\\n cin >> brr[i];\\n }\\n long long X = Deci(arr, x, n);\\n long long Y = Deci(brr, y, m);\\n if (X < Y)\\n cout << \\\"<\\\\n\\\";\\n else if (X > Y)\\n cout << \\\">\\\\n\\\";\\n else\\n cout << \\\"=\\\\n\\\";\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nIn Omkar's last class of math, he learned about the least common multiple, or LCM. LCM(a, b) is the smallest positive integer x which is divisible by both a and b.\\n\\nOmkar, having a laudably curious mind, immediately thought of a problem involving the LCM operation: given an integer n, find positive integers a and b such that a + b = n and LCM(a, b) is the minimum value possible.\\n\\nCan you help Omkar solve his ludicrously challenging math problem?\\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\\nEach test case consists of a single integer n (2 ≤ n ≤ 10^{9}).\\n\\nOutput\\n\\nFor each test case, output two positive integers a and b, such that a + b = n and LCM(a, b) is the minimum possible.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n4\\n6\\n9\\n\\n\\nOutput\\n\\n\\n2 2\\n3 3\\n3 6\\n\\nNote\\n\\nFor the first test case, the numbers we can choose are 1, 3 or 2, 2. LCM(1, 3) = 3 and LCM(2, 2) = 2, so we output 2 \\\\ 2.\\n\\nFor the second test case, the numbers we can choose are 1, 5, 2, 4, or 3, 3. LCM(1, 5) = 5, LCM(2, 4) = 4, and LCM(3, 3) = 3, so we output 3 \\\\ 3.\\n\\nFor the third test case, LCM(3, 6) = 6. It can be shown that there are no other pairs of numbers which sum to 9 that have a lower LCM.\",\"targets\":\"#include \\nusing namespace std;\\ntemplate \\nbool umin(T &a, T b) {\\n return a > b ? (a = b, true) : false;\\n}\\ntemplate \\nbool umax(T &a, T b) {\\n return a < b ? (a = b, true) : false;\\n}\\ntemplate \\nbool compare(T x, U y) {\\n return (abs(x - y) <= 1e-9);\\n}\\nvoid solve() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n int n;\\n cin >> n;\\n int ans = 1;\\n for (int i = 2; i * i <= n; i++) {\\n if (n % i == 0) {\\n ans = max(ans, n \\/ i);\\n }\\n }\\n cout << ans << \\\" \\\" << n - ans;\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n int t;\\n cin >> t;\\n while (t--) {\\n solve();\\n cout << \\\"\\\\n\\\";\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"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\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.util.*;\\nimport java.lang.*;\\nimport java.io.*;\\n\\npublic class Practice2 {\\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() {\\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\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/Input\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\nstatic void Input(){\\n \\n try {\\n FileOutputStream output=new FileOutputStream(\\\"output2.txt\\\");\\n PrintStream out=new PrintStream(output);\\n \\/\\/Diverting the output stream into file \\\"temp.out\\\".Comment the below line to use console\\n System.setOut(out);\\n \\n InputStream input=new FileInputStream(\\\"input.txt\\\");\\n \\/\\/Diverting the input stream into file \\\"temp.in\\\".Comment the below line to use console\\n System.setIn(input);\\n \\n } catch (FileNotFoundException e) {\\n e.printStackTrace();\\n }\\n}\\n\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\nstatic class Node{\\n Node arr[];\\n int data;\\n Node(int n,int data){\\n arr=new Node[n];\\n this.data=data;\\n }\\n}\\nstatic void inorder(Node node){\\n if(node==null){\\n return;\\n }\\n int c=node.arr.length;\\n for(int i=0;i\\nusing namespace std;\\nvoid FAST_IO(string filein = \\\"\\\", string fileout = \\\"\\\", string fileerr = \\\"\\\") {\\n if (fopen(filein.c_str(), \\\"r\\\")) {\\n freopen(filein.c_str(), \\\"r\\\", stdin);\\n freopen(fileout.c_str(), \\\"w\\\", stdout);\\n }\\n cin.tie(0), cout.tie(0)->sync_with_stdio(0);\\n}\\nvoid Hollwo_Pelw();\\nsigned main() {\\n FAST_IO(\\\"hollwo_pelw.inp\\\", \\\"hollwo_pelw.out\\\");\\n int testcases = 1;\\n for (int test = 1; test <= testcases; test++) {\\n Hollwo_Pelw();\\n }\\n return 0;\\n}\\nconst int N = 2e5 + 5, mod = 1e9 + 7;\\ntemplate \\nstruct mod_int {\\n int v;\\n mod_int(long long _v = 0) : v(norm(_v)) {}\\n inline int norm(long long a) { return a < 0 ? a % mod + mod : a % mod; }\\n mod_int neg() const { return v == 0 ? 0 : mod - v; }\\n template \\n explicit operator T() const {\\n return v;\\n }\\n mod_int operator-() const { return neg(); }\\n mod_int operator+() const { return mod_int(*this); }\\n mod_int& operator--() {\\n if (v == 0) v = mod;\\n --v;\\n return *this;\\n }\\n friend mod_int operator--(mod_int& a, int) {\\n mod_int r = a;\\n --a;\\n return r;\\n }\\n mod_int& operator++() {\\n ++v;\\n if (v == mod) v = 0;\\n return *this;\\n }\\n friend mod_int operator++(mod_int& a, int) {\\n mod_int r = a;\\n ++a;\\n return r;\\n }\\n friend inline mod_int operator+(mod_int a, const mod_int& b) {\\n return a += b;\\n }\\n mod_int& operator+=(const mod_int& oth) {\\n if ((v += oth.v) >= mod) v -= mod;\\n return *this;\\n }\\n friend inline mod_int operator-(mod_int a, const mod_int& b) {\\n return a -= b;\\n }\\n mod_int& operator-=(const mod_int& oth) {\\n if ((v -= oth.v) < 0) v += mod;\\n return *this;\\n }\\n friend inline mod_int operator*(mod_int a, const mod_int& b) {\\n return a *= b;\\n }\\n mod_int& operator*=(const mod_int& oth) {\\n return *this = norm(1ll * v * oth.v);\\n }\\n mod_int pow(long long b) const {\\n mod_int a = *this, r = 1;\\n while (b) {\\n if (b & 1) r *= a;\\n b >>= 1;\\n a *= a;\\n }\\n return r;\\n }\\n mod_int inv() const { return pow(mod - 2); }\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in PYTHON3?\\n\\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,...\",\"targets\":\"import sys\\nimport io, os\\ninput = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\\n\\nn,q=map(int,input().split())\\nA=list(map(int,input().split()))\\nB=list(map(int,input().split()))\\n\\nC=[A[i]-B[i] for i in range(n)]\\n\\nS=[0]\\nfor c in C:\\n S.append(S[-1]+c)\\n\\nLEN=len(S)+1\\nSparse_table0 = [S]\\n\\nfor i in range(LEN.bit_length()-1):\\n j = 1<\\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;\\nmap m;\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n int q, k;\\n long long int u, v, w;\\n cin >> q;\\n while (q--) {\\n cin >> k;\\n if (k == 1) {\\n cin >> u >> v >> w;\\n while (u != v) {\\n if (u == v) break;\\n if (u > v && u > 1) {\\n while (u > v) {\\n m[u] += w;\\n u = u \\/ 2;\\n }\\n } else if (v > u) {\\n while (v > u) {\\n m[v] += w;\\n v = v \\/ 2;\\n }\\n }\\n }\\n } else {\\n cin >> u >> v;\\n long long int ans = 0;\\n while (u != v) {\\n if (u > v) {\\n while (u > v) {\\n ans += m[u];\\n u = u \\/ 2;\\n }\\n } else {\\n while (v > u) {\\n ans += m[v];\\n v = v \\/ 2;\\n }\\n }\\n if (u == v) break;\\n }\\n cout << ans << endl;\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Among Johnny's numerous hobbies, there are two seemingly harmless ones: applying bitwise operations and sneaking into his dad's office. As it is usually the case with small children, Johnny is unaware that combining these two activities can get him in a lot of trouble.\\n\\nThere is a set S containing very important numbers on his dad's desk. The minute Johnny heard about it, he decided that it's a good idea to choose a positive integer k and replace each element s of the set S with s ⊕ k (⊕ denotes the [exclusive or](https:\\/\\/en.wikipedia.org\\/wiki\\/Exclusive_or#Computer_science) operation). \\n\\nHelp him choose such k that Johnny's dad will not see any difference after his son is done playing (i.e. Johnny will get the same set as before playing). It is possible that no such number exists. It is also possible that there are many of them. In such a case, output the smallest one. Note that the order of elements in a set doesn't matter, i.e. set \\\\{1, 2, 3\\\\} equals to set \\\\{2, 1, 3\\\\}.\\n\\nFormally, find the smallest positive integer k such that \\\\\\\\{s ⊕ k | s ∈ S\\\\} = S or report that there is no such number.\\n\\nFor example, if S = \\\\{1, 3, 4\\\\} and k = 2, new set will be equal to \\\\{3, 1, 6\\\\}. If S = \\\\{0, 1, 2, 3\\\\} and k = 1, after playing set will stay the same.\\n\\nInput\\n\\nIn the first line of input, there is a single integer t (1 ≤ t ≤ 1024), the number of test cases. In the next lines, t test cases follow. Each of them consists of two lines. \\n\\nIn the first line there is a single integer n (1 ≤ n ≤ 1024) denoting the number of elements in set S. Second line consists of n distinct integers s_i (0 ≤ s_i < 1024), elements of S.\\n\\nIt is guaranteed that the sum of n over all test cases will not exceed 1024.\\n\\nOutput\\n\\nPrint t lines; i-th line should contain the answer to the i-th test case, the minimal positive integer k satisfying the conditions or -1 if no such k exists.\\n\\nExample\\n\\nInput\\n\\n\\n6\\n4\\n1 0 2 3\\n6\\n10 7 14 8 3 12\\n2\\n0 2\\n3\\n1 2 3\\n6\\n1 4 6 10 11 12\\n2\\n0 1023\\n\\n\\nOutput\\n\\n\\n1\\n4\\n2\\n-1\\n-1\\n1023\\n\\nNote\\n\\nIn the first test case, the answer is 1 because...\\nimpor\",\"targets\":\"t java.util.*;\\nimport java.io.*;\\n\\npublic class Main {\\n\\tpublic static void main(String[] args) {\\n\\t\\tScanner sc = new Scanner(System.in);\\n\\t\\tSet S = new HashSet<>();\\n\\t\\tSet T = new HashSet<>();\\n\\t\\tint t = sc.nextInt();\\n\\t\\twhile (t-- > 0) {\\n\\t\\t\\tint n = sc.nextInt();\\n\\t\\t\\tS.clear();\\n\\n\\t\\t\\tfor (int i = 0; i < n; i++) {\\n\\t\\t\\t\\tint s = sc.nextInt();\\n\\t\\t\\t\\tS.add(s);\\n\\t\\t\\t}\\n\\n\\t\\t\\tboolean success = false;\\n\\t\\t\\tfor (int i = 1; i <= 2049; i++) {\\n\\t\\t\\t\\tT.clear();\\n\\t\\t\\t\\tboolean ok = true;\\n\\t\\t\\t\\tfor (int s : S) {\\n\\t\\t\\t\\t\\tif (!S.contains(s ^ i)) {\\n\\t\\t\\t\\t\\t\\tok = false;\\n\\t\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\tT.add(s ^ i);\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tif (ok && T.size() == S.size()) {\\n\\t\\t\\t\\t\\tSystem.out.println(i);\\n\\t\\t\\t\\t\\tsuccess = true;\\n\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\tif (!success) System.out.println(-1);\\n\\t\\t}\\n\\t}\\n}\",\"language\":\"python\",\"split\":\"train\",\"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...]\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nvoid tarea() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n int t;\\n cin >> t;\\n while (t--) {\\n long long n, k;\\n cin >> n >> k;\\n long long p = 1, i = 0, ans = 0;\\n while (k) {\\n if (k % 2 == 1) {\\n p = 1;\\n for (long long j = 0; j < i; j++) {\\n p *= n;\\n p %= 1000000007;\\n }\\n ans += (p % 1000000007);\\n ans %= 1000000007;\\n k \\/= 2;\\n } else {\\n k \\/= 2;\\n }\\n i++;\\n }\\n cout << ans % 1000000007 << endl;\\n }\\n return;\\n}\\nint main() {\\n tarea();\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"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\":\"\\/\\/package contest.CodeforcesRound752;\\n\\nimport java.io.*;\\nimport java.util.*;\\n\\n\\/***********************\\n @oj: codeforces\\n @id: hitwanyang\\n @email: 296866643@qq.com\\n @date: 2021\\/10\\/31 0:20\\n @url: https:\\/\\/codeforc.es\\/contest\\/1604\\/problem\\/B\\n ***********************\\/\\npublic class B1604 {\\n\\n InputStream is;\\n FastWriter out;\\n String INPUT = \\\"\\\";\\n\\n \\/\\/提交时注意需要注释掉首行package\\n \\/\\/基础类型数组例如long[]使用Arrays排序容易TLE,可以替换成Long[]\\n \\/\\/int 最大值2**31-1,2147483647;\\n \\/\\/尽量使用long类型,避免int计算的数据溢出\\n \\/\\/String尽量不要用+号来,可能会出现TLE,推荐用StringBuffer\\n \\/\\/注意对象类型Long,Integer相等使用equals代替== !!!\\n void solve() {\\n int t = ni();\\n for (; t > 0; t--) {\\n go();\\n }\\n }\\n\\n void go() {\\n int n = ni();\\n int[] a = new int[n];\\n for (int i = 0; i < n; i++) {\\n a[i] = ni();\\n }\\n if (n == 1) {\\n out.println(\\\"NO\\\");\\n return;\\n }\\n if (n % 2 == 0) {\\n out.println(\\\"YES\\\");\\n } else {\\n for (int i = 1; i < n; i++) {\\n if (a[i] <= a[i - 1]) {\\n out.println(\\\"YES\\\");\\n return;\\n }\\n }\\n out.println(\\\"NO\\\");\\n }\\n }\\n\\n void run() throws Exception {\\n is = System.in;\\n out = new FastWriter(System.out);\\n\\n long s = System.currentTimeMillis();\\n solve();\\n out.flush();\\n \\/\\/debug log\\n \\/\\/tr(System.currentTimeMillis() - s + \\\"ms\\\");\\n }\\n\\n public static void main(String[] args) throws Exception {\\n new B1604().run();\\n }\\n\\n private byte[] inbuf = new byte[1024];\\n public int lenbuf = 0, ptrbuf = 0;\\n\\n private int readByte() {\\n if (lenbuf == -1) {\\n throw new InputMismatchException();\\n }\\n if (ptrbuf >= lenbuf) {\\n ptrbuf = 0;\\n try {\\n lenbuf = is.read(inbuf);\\n } catch (IOException e) {\\n throw new InputMismatchException();\\n }\\n if (lenbuf <= 0) {\\n return -1;\\n...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given a tree consisting of n vertices. Recall that a tree is an undirected connected acyclic graph. The given tree is rooted at the vertex 1.\\n\\nYou have to process q queries. In each query, you are given a vertex of the tree v and an integer k.\\n\\nTo process a query, you may delete any vertices from the tree in any order, except for the root and the vertex v. When a vertex is deleted, its children become the children of its parent. You have to process a query in such a way that maximizes the value of c(v) - m ⋅ k (where c(v) is the resulting number of children of the vertex v, and m is the number of vertices you have deleted). Print the maximum possible value you can obtain.\\n\\nThe queries are independent: the changes you make to the tree while processing a query don't affect the tree in other queries.\\n\\nInput\\n\\nThe first line contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of vertices in the tree.\\n\\nThen n-1 lines follow, the i-th of them contains two integers x_i and y_i (1 ≤ x_i, y_i ≤ n; x_i ≠ y_i) — the endpoints of the i-th edge. These edges form a tree.\\n\\nThe next line contains one integer q (1 ≤ q ≤ 2 ⋅ 10^5) — the number of queries.\\n\\nThen q lines follow, the j-th of them contains two integers v_j and k_j (1 ≤ v_j ≤ n; 0 ≤ k_j ≤ 2 ⋅ 10^5) — the parameters of the j-th query.\\n\\nOutput\\n\\nFor each query, print one integer — the maximum value of c(v) - m ⋅ k you can achieve.\\n\\nExample\\n\\nInput\\n\\n\\n8\\n6 7\\n3 2\\n8 3\\n5 7\\n7 4\\n7 1\\n7 3\\n6\\n1 0\\n1 2\\n1 3\\n7 1\\n5 0\\n7 200000\\n\\n\\nOutput\\n\\n\\n5\\n2\\n1\\n4\\n0\\n4\\n\\nNote\\n\\nThe tree in the first example is shown in the following picture:\\n\\n\\n\\nAnswers to the queries are obtained as follows:\\n\\n 1. v=1,k=0: you can delete vertices 7 and 3, so the vertex 1 has 5 children (vertices 2, 4, 5, 6, and 8), and the score is 5 - 2 ⋅ 0 = 5; \\n 2. v=1,k=2: you can delete the vertex 7, so the vertex 1 has 4 children (vertices 3, 4, 5, and 6), and the score is 4 - 1 ⋅ 2 = 2. \\n 3. v=1,k=3: you shouldn't delete any vertices, so the vertex 1 has only one child (vertex 7), and the score is 1 - 0 ⋅ 3 = 1; \\n ...\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nvector get_parents(const vector>& adj, int root) {\\n int n = adj.size();\\n vector parents(n, -1);\\n stack> st;\\n st.emplace(root, -1);\\n while (!st.empty()) {\\n int node = st.top().first;\\n parents[node] = st.top().second;\\n st.pop();\\n for (int i : adj[node]) {\\n if (i != parents[node]) {\\n st.emplace(i, node);\\n }\\n }\\n }\\n return parents;\\n}\\nvector> get_children(const vector& parents) {\\n int n = parents.size();\\n vector> children(n);\\n for (int i = 0; i < n; ++i) {\\n if (parents[i] >= 0) {\\n children[parents[i]].push_back(i);\\n }\\n }\\n return children;\\n}\\nvector get_depth(const vector>& children, int root) {\\n int n = children.size();\\n vector depth(n);\\n vector q(1, root);\\n int d = 0;\\n while (!q.empty()) {\\n vector q2;\\n for (int i : q) {\\n depth[i] = d;\\n for (int j : children[i]) {\\n q2.push_back(j);\\n }\\n }\\n q2.swap(q);\\n d++;\\n }\\n return depth;\\n}\\nvector get_order(const vector>& children, int root) {\\n int N = children.size();\\n vector order(N);\\n int idx = 0;\\n stack> st;\\n st.emplace(true, root);\\n while (!st.empty()) {\\n bool b = st.top().first;\\n int node = st.top().second;\\n st.pop();\\n if (b) {\\n st.emplace(false, node);\\n for (int ch : children[node]) {\\n st.emplace(true, ch);\\n }\\n } else {\\n order[idx++] = node;\\n }\\n }\\n assert(idx == N);\\n return order;\\n}\\nvector calculate_small_dp(const vector>& children,\\n const vector& order, int k) {\\n int n = children.size();\\n vector dp(n, 0);\\n for (int i : order) {\\n for (int ch : children[i]) {\\n dp[i] += max(dp[ch] - k, 1);\\n }\\n }\\n return dp;\\n}\\nint& chmax(int& x, int y) {\\n if (y > x) x = y;\\n return x;\\n}\\nvector solve(const vector>& adj, const vector& v,\\n const...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"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\\nSolve the task in PYTHON3.\",\"targets\":\"n = int(input())\\nL = []\\nfor i in range(1, n + 1):\\n L.append(i)\\n\\nif(n == 1 or n == 2):\\n print(\\\"1\\\")\\n print(\\\"1\\\")\\nelif(n == 3):\\n print(\\\"2\\\")\\n print(\\\"1\\\" + \\\" \\\" + \\\"3\\\")\\nelif(n == 4):\\n print(\\\"4\\\")\\n print(\\\"3\\\" + \\\" \\\" + \\\"1\\\" + \\\" \\\" + \\\"4\\\" + \\\" \\\" + \\\"2\\\")\\nelse:\\n odd = []\\n even = []\\n for i in L:\\n if(i & 1):\\n odd.append(i)\\n else:\\n even.append(i)\\n\\n nums = odd + even\\n print(len(nums))\\n print(' '.join(map(str, nums)))\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"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\",\"targets\":\"#include \\nusing namespace std;\\nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\\nconst long long maxn = 2e6 + 5, mod = 998244353, inf = 1e9;\\nconst long double pi = 4 * atan(1.0), eps = 1e-9;\\nvoid solve();\\nsigned main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n ;\\n long long tc = 1;\\n for (long long test = (long long)(1); test <= (long long)(tc); ++test) {\\n solve();\\n }\\n return 0;\\n}\\nlong long pw[maxn];\\nmap, long long> g;\\nlong long n, m, q;\\nlong long cntr;\\nlong long cntc;\\nlong long fixr2[maxn][2];\\nlong long fixc2[maxn][2];\\nlong long sfixr, sfixc;\\nlong long bfixr, bfixc;\\nlong long fix[2];\\nlong long di[] = {-1, 0, 1, 0};\\nlong long dj[] = {0, 1, 0, -1};\\nvoid solve() {\\n pw[0] = 1;\\n for (long long i = (long long)(1); i <= (long long)(maxn - 1); ++i)\\n pw[i] = pw[i - 1] * 2 % mod;\\n cin >> n >> m >> q;\\n for (long long i = (long long)(1); i <= (long long)(q); ++i) {\\n long long a, b, s;\\n cin >> a >> b >> s;\\n if (g.count({a, b})) {\\n sfixr -= (fixr2[a][0] or fixr2[a][1]);\\n sfixc -= (fixc2[b][0] or fixc2[b][1]);\\n bfixr -= (fixr2[a][0] and fixr2[a][1]);\\n bfixc -= (fixc2[b][0] and fixc2[b][1]);\\n fixr2[a][(b & 1) ^ g[{a, b}]]--;\\n fixc2[b][(a & 1) ^ g[{a, b}]]--;\\n sfixr += (fixr2[a][0] or fixr2[a][1]);\\n sfixc += (fixc2[b][0] or fixc2[b][1]);\\n bfixr += (fixr2[a][0] and fixr2[a][1]);\\n bfixc += (fixc2[b][0] and fixc2[b][1]);\\n for (long long dir = (long long)(0); dir <= (long long)(3); ++dir) {\\n long long ti = a + di[dir];\\n long long tj = b + dj[dir];\\n if (ti == a)\\n cntr -= (g.count({ti, tj}) and g[{ti, tj}] == g[{a, b}]);\\n else\\n cntc -= (g.count({ti, tj}) and g[{ti, tj}] == g[{a, b}]);\\n }\\n fix[(a + b & 1) ^ g[{a, b}]]--;\\n g.erase({a, b});\\n }\\n if (s >= 0) {\\n g[{a, b}] = s;\\n fix[(a + b & 1) ^ g[{a, b}]]++;\\n for (long long dir = (long long)(0); dir <= (long long)(3); ++dir) {\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP 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\":\"#include \\nusing namespace std;\\nconst int N = 1e5 + 100, inf = 0x3f3f3f3f, mod = 1e9 + 7, M = 1e6 + 1000;\\nconst long long INF = 0x3f3f3f3f3f3f3f3f;\\nlong long sp(long long a, long long b, long long d) {\\n if (!b) return 1;\\n return b % 2 ? sp(a * a, b \\/ 2, d) * a % d : sp(a * a, b \\/ 2, d);\\n}\\nlong long sp1(long long a, long long b) {\\n if (!b) return 1;\\n return b % 2 ? sp1(a * a, b \\/ 2) * a : sp1(a * a, b \\/ 2);\\n}\\nlong long lowbit(long long x) { return x & (-x); }\\nlong long exgcd(long long a, long long b, long long &x, long long &y) {\\n if (!b) {\\n x = 1;\\n y = 0;\\n return a;\\n } else {\\n long long d = exgcd(b, a % b, y, x);\\n y -= (a \\/ b) * x;\\n return d;\\n }\\n}\\nlong long t, n;\\nchar str[N];\\nlong long ck(char s) {\\n long long l = 1, r = n, x = 0;\\n while (l <= r) {\\n if (str[l] == str[r]) {\\n l++;\\n r--;\\n } else {\\n if (str[l] == s) {\\n l++;\\n x++;\\n } else if (str[r] == s) {\\n r--;\\n x++;\\n } else {\\n return -1;\\n }\\n }\\n }\\n return x;\\n}\\nint main() {\\n cin >> t;\\n while (t--) {\\n scanf(\\\"%lld%s\\\", &n, str + 1);\\n long long ans = -1;\\n for (int i = 0; i <= 25; i++) {\\n char s = i + 'a';\\n long long x = ck(s);\\n if (x == -1) continue;\\n if (ans == -1 || ans > x) ans = x;\\n }\\n cout << ans << endl;\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"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...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nint T, n, m, a[300010], t[300010], p[300010], v[300010], rk[300010];\\nvector ans;\\nint main() {\\n scanf(\\\"%d\\\", &T);\\n while (T--) {\\n scanf(\\\"%d%d\\\", &n, &m);\\n ans.clear();\\n for (int i = 0; i < n; i++) v[i] = t[i] = 0;\\n for (int i = 0; i < n; i++) scanf(\\\"%d\\\", &a[i]), rk[--a[i]] = i;\\n for (int i = 0; i < n; i++) t[(rk[i] - i + n) % n]++;\\n for (int k = 0; k < n; k++) {\\n if (t[k] + (n - t[k]) \\/ 2 < n - m) continue;\\n for (int i = 0; i < n; i++) v[i] = 0;\\n int s = 0;\\n for (int i = 0; i < n; i++)\\n if (!v[i]) {\\n s++;\\n int now = i;\\n while (!v[now]) v[now] = 1, now = rk[(now - k + n) % n];\\n }\\n if (s >= n - m) ans.push_back(k);\\n }\\n int sz = ans.size();\\n printf(\\\"%d \\\", sz);\\n for (int i = 0; i < sz; i++) printf(\\\"%d \\\", ans[i]);\\n printf(\\\"\\\\n\\\");\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"One day Petya got a birthday present from his mom: a book called \\\"The Legends and Myths of Graph Theory\\\". From this book Petya learned about a hydra graph.\\n\\nA non-oriented graph is a hydra, if it has a structure, shown on the figure below. Namely, there are two nodes u and v connected by an edge, they are the hydra's chest and stomach, correspondingly. The chest is connected with h nodes, which are the hydra's heads. The stomach is connected with t nodes, which are the hydra's tails. Note that the hydra is a tree, consisting of h + t + 2 nodes.\\n\\n\\n\\nAlso, Petya's got a non-directed graph G, consisting of n nodes and m edges. Petya got this graph as a last year birthday present from his mom. Graph G contains no self-loops or multiple edges.\\n\\nNow Petya wants to find a hydra in graph G. Or else, to make sure that the graph doesn't have a hydra.\\n\\nInput\\n\\nThe first line contains four integers n, m, h, t (1 ≤ n, m ≤ 105, 1 ≤ h, t ≤ 100) — the number of nodes and edges in graph G, and the number of a hydra's heads and tails.\\n\\nNext m lines contain the description of the edges of graph G. The i-th of these lines contains two integers ai and bi (1 ≤ ai, bi ≤ n, a ≠ b) — the numbers of the nodes, connected by the i-th edge.\\n\\nIt is guaranteed that graph G contains no self-loops and multiple edges. Consider the nodes of graph G numbered with integers from 1 to n.\\n\\nOutput\\n\\nIf graph G has no hydra, print \\\"NO\\\" (without the quotes).\\n\\nOtherwise, in the first line print \\\"YES\\\" (without the quotes). In the second line print two integers — the numbers of nodes u and v. In the third line print h numbers — the numbers of the nodes that are the heads. In the fourth line print t numbers — the numbers of the nodes that are the tails. All printed numbers should be distinct.\\n\\nIf there are multiple possible answers, you are allowed to print any of them.\\n\\nExamples\\n\\nInput\\n\\n9 12 2 3\\n1 2\\n2 3\\n1 3\\n1 4\\n2 5\\n4 5\\n4 6\\n6 5\\n6 7\\n7 5\\n8 7\\n9 1\\n\\n\\nOutput\\n\\nYES\\n4 1\\n5 6 \\n9 3 2 \\n\\n\\nInput\\n\\n7 10 3 3\\n1 2\\n2 3\\n1 3\\n1 4\\n2 5\\n4 5\\n4 6\\n6 5\\n6 7\\n7...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint n, m, h, t, i, j, a[100005], b[100005], head, tail, lhead, ltail, k;\\nint u[100005];\\nvector g[100005];\\nvoid Init() {\\n scanf(\\\"%d%d%d%d\\\", &n, &m, &h, &t);\\n for (i = 0; i < m; i++) {\\n scanf(\\\"%d%d\\\", &a[i], &b[i]);\\n g[a[i]].push_back(b[i]);\\n g[b[i]].push_back(a[i]);\\n }\\n}\\nvoid print(int x, int y) {\\n printf(\\\"YES\\\\n\\\");\\n printf(\\\"%d %d\\\\n\\\", x, y);\\n int H, T;\\n T = H = 0;\\n for (i = 0; i < g[x].size(); i++) {\\n if (g[x][i] == y) continue;\\n if (u[g[x][i]] == 1) {\\n printf(\\\"%d \\\", g[x][i]);\\n u[g[x][i]] = 0;\\n H++;\\n }\\n if (H == h) break;\\n }\\n if (H != h) {\\n for (i = 0; i < g[x].size(); i++) {\\n if (g[x][i] == y) continue;\\n if (u[g[x][i]] == 2) {\\n printf(\\\"%d \\\", g[x][i]);\\n u[g[x][i]] = 0;\\n H++;\\n }\\n if (H == h) break;\\n }\\n }\\n printf(\\\"\\\\n\\\");\\n for (i = 0; i < g[y].size(); i++) {\\n if (g[y][i] == x) continue;\\n if (u[g[y][i]] != 0) {\\n printf(\\\"%d \\\", g[y][i]);\\n u[g[y][i]] = 0;\\n T++;\\n }\\n if (T == t) break;\\n }\\n printf(\\\"\\\\n\\\");\\n}\\nvoid solve() {\\n for (i = 0; i < m; i++) {\\n head = a[i];\\n tail = b[i];\\n if (g[head].size() > h && g[tail].size() > t) {\\n k = 0;\\n lhead = min((int)g[head].size(), 210);\\n for (j = 0; j < lhead; j++) {\\n if (g[head][j] == tail) continue;\\n u[g[head][j]]++;\\n k++;\\n }\\n ltail = min((int)g[tail].size(), 210);\\n for (j = 0; j < ltail; j++) {\\n if (g[tail][j] == head) continue;\\n if (u[g[tail][j]] == 0) {\\n k++;\\n }\\n u[g[tail][j]]++;\\n }\\n if (k >= h + t) {\\n print(head, tail);\\n exit(0);\\n }\\n for (j = 0; j < lhead; j++) {\\n u[g[head][j]] = 0;\\n }\\n for (j = 0; j < ltail; j++) {\\n u[g[tail][j]] = 0;\\n }\\n }\\n head = b[i];\\n tail = a[i];\\n if (g[head].size() > h && g[tail].size() > t) {\\n k = 0;\\n lhead = min((int)g[head].size(), 210);\\n for (j = 0; j < lhead; j++) {\\n if (g[head][j] == tail)...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular string meets the certain rules.\\n\\nIn this task, a pattern will be a string consisting of small English letters and question marks ('?'). The question mark in the pattern is a metacharacter that denotes an arbitrary small letter of the English alphabet. We will assume that a string matches the pattern if we can transform the string into the pattern by replacing the question marks by the appropriate characters. For example, string aba matches patterns: ???, ??a, a?a, aba.\\n\\nProgrammers that work for the R1 company love puzzling each other (and themselves) with riddles. One of them is as follows: you are given n patterns of the same length, you need to find a pattern that contains as few question marks as possible, and intersects with each of the given patterns. Two patterns intersect if there is a string that matches both the first and the second pattern. Can you solve this riddle?\\n\\nInput\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 105) — the number of patterns. Next n lines contain the patterns.\\n\\nIt is guaranteed that the patterns can only consist of small English letters and symbols '?'. All patterns are non-empty and have the same length. The total length of all the patterns does not exceed 105 characters.\\n\\nOutput\\n\\nIn a single line print the answer to the problem — the pattern with the minimal number of signs '?', which intersects with each of the given ones. If there are several answers, print any of them.\\n\\nExamples\\n\\nInput\\n\\n2\\n?ab\\n??b\\n\\n\\nOutput\\n\\nxab\\n\\n\\nInput\\n\\n2\\na\\nb\\n\\n\\nOutput\\n\\n?\\n\\n\\nInput\\n\\n1\\n?a?b\\n\\n\\nOutput\\n\\ncacb\\n\\nNote\\n\\nConsider the first example. Pattern xab intersects with each of the given patterns. Pattern ??? also intersects with each of the given patterns, but it contains more question signs, hence it is not an optimal answer. Clearly, xab is the optimal answer,...\\nSolve the task in CPP.\",\"targets\":\"#include \\nint main(void) {\\n int n, i, j, l;\\n char a[100001], b[100001];\\n scanf(\\\"%d\\\", &n);\\n scanf(\\\"%s\\\", &a);\\n l = strlen(a);\\n for (i = 0; i < l; i++) {\\n b[i] = a[i];\\n }\\n for (i = 1; i < n; i++) {\\n scanf(\\\"%s\\\", &a);\\n for (j = 0; j < l; j++) {\\n if (b[j] == '?') {\\n b[j] = a[j];\\n } else if (a[j] != b[j] && b[j] != '?' && a[j] != '?') {\\n b[j] = 'A';\\n } else if (a[j] != b[j] && a[j] == '?') {\\n b[j] = b[j];\\n }\\n }\\n }\\n for (i = 0; i < l; i++) {\\n if (b[i] == '?') {\\n printf(\\\"x\\\");\\n } else if (b[i] == 'A') {\\n printf(\\\"?\\\");\\n } else {\\n printf(\\\"%c\\\", b[i]);\\n }\\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 CPP?\\nB: Parentheses Number\\n\\nproblem\\n\\nDefine the correct parenthesis string as follows:\\n\\n* The empty string is the correct parenthesis string\\n* For the correct parenthesis string S, `(` S `)` is the correct parenthesis string\\n* For correct parentheses S, T ST is the correct parentheses\\n\\n\\n\\nHere, the permutations are associated with the correct parentheses according to the following rules.\\n\\n* When the i-th closing brace corresponds to the j-th opening brace, the i-th value in the sequence is j.\\n\\n\\n\\nGiven a permutation of length n, P = (p_1, p_2, $ \\\\ ldots $, p_n), restore the corresponding parenthesis string.\\n\\nHowever, if the parenthesis string corresponding to the permutation does not exist, output `: (`.\\n\\nInput format\\n\\n\\nn\\np_1 p_2 $ \\\\ ldots $ p_n\\n\\n\\nThe number of permutations n is given in the first row.\\n\\nPermutations p_1, p_2, $ \\\\ ldots $, p_i, $ \\\\ ldots $, p_n are given in the second row, separated by blanks.\\n\\nConstraint\\n\\n* 1 \\\\ leq n \\\\ leq 10 ^ 5\\n* 1 \\\\ leq p_i \\\\ leq n\\n* All inputs are integers.\\n* P = (p_1, p_2, $ \\\\ ldots $, p_n) is a permutation.\\n\\n\\n\\nOutput format\\n\\nOutput the parenthesized string corresponding to the permutation.\\n\\nPrint `: (` if such a parenthesis string does not exist.\\n\\nInput example 1\\n\\n\\n2\\ntwenty one\\n\\n\\nOutput example 1\\n\\n\\n(())\\n\\nInput example 2\\n\\n\\nTen\\n1 2 3 4 5 6 7 8 9 10\\n\\n\\nOutput example 2\\n\\n\\n() () () () () () () () () ()\\n\\nInput example 3\\n\\n\\n3\\n3 1 2\\n\\n\\nOutput example 3\\n\\n\\n:(\\n\\n\\n\\n\\n\\nExample\\n\\nInput\\n\\n2\\n2 1\\n\\n\\nOutput\\n\\n(())\",\"targets\":\"#include \\n\\nusing namespace std;\\n\\ntypedef long long ll;\\ntypedef vector vi;\\ntypedef vector vl;\\ntypedef pair pii;\\ntypedef pair pll;\\n\\ntypedef int _loop_int;\\n#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)\\n#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)\\n#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)\\n\\n#define DEBUG(x) cout<<#x<<\\\": \\\"< P;\\n\\nint n;\\nint p[125252];\\nchar s[252521];\\n\\nint main(){\\n scanf(\\\"%d\\\",&n);\\n REP(i,n)scanf(\\\"%d\\\",p+i);\\n int it = 0;\\n int cnt = 0;\\n stack S;\\n REP(i,n){\\n while(S.empty() || S.top() < p[i]){\\n s[it++] = '(';\\n S.push(++cnt);\\n }\\n if(S.top() != p[i]){\\n puts(\\\":(\\\"); return 0;\\n }\\n S.pop();\\n s[it++] = ')';\\n }\\n if(S.size() > 0){\\n puts(\\\":(\\\"); return 0;\\n }else{\\n puts(s);\\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?\\nPetya recieved a gift of a string s with length up to 105 characters for his birthday. He took two more empty strings t and u and decided to play a game. This game has two possible moves:\\n\\n * Extract the first character of s and append t with this character. \\n * Extract the last character of t and append u with this character. \\n\\n\\n\\nPetya wants to get strings s and t empty and string u lexicographically minimal.\\n\\nYou should write a program that will help Petya win the game.\\n\\nInput\\n\\nFirst line contains non-empty string s (1 ≤ |s| ≤ 105), consisting of lowercase English letters.\\n\\nOutput\\n\\nPrint resulting string u.\\n\\nExamples\\n\\nInput\\n\\ncab\\n\\n\\nOutput\\n\\nabc\\n\\n\\nInput\\n\\nacdb\\n\\n\\nOutput\\n\\nabdc\",\"targets\":\"#include \\nusing namespace std;\\nconst long double pi = 3.1415926535897932385;\\nconst long double E = 2.71828182845904523536;\\nconst long long mod = 1e9 + 7;\\nconst long long eps = 1e-15;\\nconst long long inf = 1e15;\\nint frq[500];\\nset se;\\nqueue q;\\nvector v;\\nvector ans;\\nint main() {\\n string s;\\n cin >> s;\\n int n = s.length();\\n for (int i = 0; i < n; i++) {\\n frq[s[i]]++;\\n q.push(s[i]);\\n se.insert(s[i]);\\n }\\n for (auto c : se) {\\n while (v.size() && v.back() <= c) {\\n ans.push_back(v.back());\\n v.pop_back();\\n }\\n while (frq[c] && q.size()) {\\n char x = q.front();\\n q.pop();\\n frq[x]--;\\n if (x == c)\\n ans.push_back(c);\\n else\\n v.push_back(x);\\n }\\n }\\n for (auto x : ans) cout << x;\\n reverse(v.begin(), v.end());\\n for (auto x : v) cout << x;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"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;\\nconst int N = 2e5 + 5;\\nstruct dish {\\n long long a;\\n long long b;\\n};\\nstruct dish a[N];\\nlong long b[N], c[N];\\nbool cmp1(struct dish a, struct dish b) { return a.a < b.a; }\\nvoid solve() {\\n long long flag = 0, need;\\n long long n, m, sum1 = 0, sum2 = 0, i;\\n scanf(\\\"%lld%lld\\\", &n, &m);\\n for (i = 1; i <= n; ++i) {\\n scanf(\\\"%lld%lld\\\", &a[i].a, &a[i].b);\\n sum1 += a[i].a;\\n sum2 += a[i].b;\\n b[i] = c[i] = 0;\\n }\\n if (sum1 < sum2) {\\n swap(sum1, sum2);\\n for (i = 1; i <= n; ++i) swap(a[i].a, a[i].b);\\n flag = 1;\\n }\\n need = sum1 - sum2;\\n for (i = 1; i <= n; ++i) {\\n if (a[i].a >= m) {\\n a[i].a -= m;\\n b[i] = m;\\n c[i] = 0;\\n need = need - m;\\n } else {\\n b[i] = a[i].a;\\n c[i] = m - a[i].a;\\n a[i].a = 0;\\n a[i].b = a[i].b - c[i];\\n need = need - b[i] + c[i];\\n }\\n }\\n if (need < -1) {\\n long long g = (0 - need) \\/ 2;\\n for (i = 1; i <= n; ++i) {\\n if (a[i].b) {\\n int can = min(min(b[i], a[i].b), g);\\n b[i] = b[i] - can;\\n a[i].b = a[i].b - can;\\n c[i] = c[i] + can;\\n g = g - can;\\n need = need + 2 * can;\\n }\\n if (g == 0) break;\\n }\\n }\\n if (need < 0)\\n printf(\\\"%lld\\\\n\\\", -1 * need);\\n else\\n printf(\\\"%lld\\\\n\\\", need);\\n for (i = 1; i <= n; ++i) {\\n if (flag == 0)\\n printf(\\\"%lld %lld\\\\n\\\", b[i], c[i]);\\n else\\n printf(\\\"%lld %lld\\\\n\\\", c[i], b[i]);\\n }\\n}\\nint main() {\\n int t;\\n scanf(\\\"%d\\\", &t);\\n while (t--) {\\n solve();\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"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. \\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nlong long arr[200000];\\nstruct product {\\n long long a, b;\\n};\\nbool compare(product m, product n) { return m.b < n.b; }\\nlong long fast_mod(long long a, long long b, long long mod) {\\n long long r = 1;\\n a %= mod;\\n while (b) {\\n if (b & 1) r = (r * a) % mod;\\n a = (a * a) % mod;\\n b >>= 1;\\n }\\n return r;\\n}\\nbool isSushu(int x) {\\n if (x == 1) return false;\\n for (int i = 2; i <= ceil(sqrt(x)) && i < x; i++)\\n if (x % i == 0) return false;\\n return true;\\n}\\nconst long long mod = 31607;\\nint main() {\\n int t = 1;\\n while (t-- > 0) {\\n int n, m, sum[6][300000];\\n string s[6];\\n s[0] = \\\"abc\\\";\\n s[1] = \\\"acb\\\";\\n s[2] = \\\"bac\\\";\\n s[3] = \\\"bca\\\";\\n s[4] = \\\"cab\\\";\\n s[5] = \\\"cba\\\";\\n string ss;\\n cin >> n >> m >> ss;\\n for (int i = 0; i < n; i++) {\\n char ch = ss[i];\\n for (int j = 0; j < 6; j++)\\n sum[j][i] = (i > 0 ? sum[j][i - 1] : 0) + (ch == s[j][i % 3] ? 0 : 1);\\n }\\n for (int i = 0; i < m; i++) {\\n int l, r, ans;\\n cin >> l >> r;\\n l--;\\n r--;\\n ans = r - l + 1;\\n for (int j = 0; j < 6; j++)\\n ans = min(ans, (sum[j][r] - (l > 0 ? sum[j][l - 1] : 0)));\\n cout << ans << endl;\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"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 =...\\nSolve the task in JAVA.\",\"targets\":\"import java.util.*;\\npublic class Zlatan{\\n public static boolean isPrime(int n)\\n {\\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 {\\n if (n % i == 0)\\n return false;\\n }\\n return true;\\n }\\n public static void main(String[]arg){\\n Scanner in =new Scanner(System.in);\\n int t=in.nextInt();\\n while(t-->0){\\n int k=in.nextInt();\\n String n=in.next();\\n int arr[]=new int[9];\\n for(int j=0;j0||arr[3]>0||arr[5]>0||arr[7]>0||arr[8]>0){\\n System.out.println(\\\"1\\\");\\n if(arr[3]>0) System.out.println(\\\"4\\\");\\n else if(arr[5]>0) System.out.println(\\\"6\\\");\\n else if(arr[7]>0) System.out.println(\\\"8\\\");\\n else if(arr[8]>0) System.out.println(\\\"9\\\");\\n else if(arr[0]>0) System.out.println(\\\"1\\\");\\n }\\n else{\\n System.out.println(\\\"2\\\");\\n if(arr[1]>1) System.out.println(\\\"22\\\");\\n else if(arr[2]>1) System.out.println(\\\"33\\\");\\n else if(arr[4]>1) System.out.println(\\\"55\\\");\\n else if(arr[6]>1) System.out.println(\\\"77\\\");\\n else{\\n String copy=\\\"\\\";\\n for(int j=0;jj){ System.out.println(\\\"22\\\");break;}\\n else if(copy.lastIndexOf(\\\"5\\\")>j){ System.out.println(\\\"25\\\");break;}\\n else if(copy.lastIndexOf(\\\"7\\\")>j){ System.out.println(\\\"27\\\");break;}\\n }\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"During a recent research Berland scientists found out that there were n cities in Ancient Berland, joined by two-way paths. Any two cities are joined by no more than one path. No path joins a city with itself. According to a well-known tradition, the road network was built so that it would be impossible to choose three cities from each of which one can get to any other one directly. That is, there was no cycle exactly as long as 3. Unfortunately, the road map has not been preserved till nowadays. Now the scientists are interested how much developed a country Ancient Berland was. Help them - find, what maximal number of roads could be in the country. You also have to restore any of the possible road maps.\\n\\nInput\\n\\nThe first line contains an integer n (1 ≤ n ≤ 100) — the number of cities in Berland.\\n\\nOutput\\n\\nOn the first line must be printed number m — the maximal number of roads in Berland. Then print m lines containing two numbers each — the numbers of cities that the given road joins. The cities are numbered with integers from 1 to n. If there are several variants of solving the problem, print any of them.\\n\\nExamples\\n\\nInput\\n\\n3\\n\\n\\nOutput\\n\\n2\\n1 2\\n2 3\\n\\n\\nInput\\n\\n4\\n\\n\\nOutput\\n\\n4\\n1 2\\n2 3\\n3 4\\n4 1\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nint main() {\\n int i, j, n;\\n while (cin >> n) {\\n if (n & 1)\\n printf(\\\"%d\\\\n\\\", (n \\/ 2) * (n + 1) \\/ 2);\\n else\\n printf(\\\"%d\\\\n\\\", (n * n) \\/ 4);\\n for (i = 1; i <= n \\/ 2; i++)\\n for (j = n \\/ 2 + 1; j <= n; j++) printf(\\\"%d %d\\\\n\\\", i, j);\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"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\":\"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 a,b = M()\\n c,d = M()\\n\\n if len(str(a)) + b > len(str(c)) + d:\\n print(\\\">\\\")\\n return\\n elif len(str(a)) + b < len(str(c)) + d:\\n print(\\\"<\\\")\\n return\\n else:\\n m =len(str(a))\\n n = len(str(c))\\n if m == n:\\n if a > c:\\n print(\\\">\\\")\\n return\\n elif a < c:\\n print(\\\"<\\\")\\n return\\n else:\\n print(\\\"=\\\")\\n\\n return\\n if m > n:\\n c *= 10**(m-n)\\n # print(len(str(a)), len(str(c)))\\n if a > c:\\n print(\\\">\\\")\\n return\\n elif a < c:\\n print(\\\"<\\\")\\n return\\n else:\\n print(\\\"=\\\")\\n return\\n elif m < n:\\n a *= 10**(n-m)\\n # print(len(str(a)), len(str(c)))\\n if a > c:\\n print(\\\">\\\")\\n return\\n elif a < c:\\n print(\\\"<\\\")\\n return\\n else:\\n print(\\\"=\\\")\\n return\\nfor _ in range(I()):\\n solve()\",\"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...\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"from collections import *\\nimport sys\\nimport io, os\\nimport math\\nfrom heapq import *\\ngcd = math.gcd\\nsqrt = math.sqrt\\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\\n\\n\\n\\n\\ndef main():\\n t = int(input())\\n for _ in range(t):\\n input()\\n arr=list(map(int, input().split()))\\n m=arr[0]\\n n=arr[1]\\n p=[0]*m\\n for i in range(m):\\n p[i]=list(map(int, input().split()))\\n f=[]\\n for i in range(n):\\n l=[]\\n for j in range(m):\\n l.append((p[j][i],j))\\n l.sort(reverse=True)\\n f.append(l)\\n perm=[0]*(m+1)\\n mi=10**12\\n for i in range(n):\\n perm[f[i][0][1]]=1\\n mi=min(f[i][0][0],mi)\\n if(sum(perm)!=n):\\n print(mi)\\n continue\\n for i in range(m):\\n for j in range(n):\\n p[i][j]=(p[i][j],j)\\n p[i].sort(reverse=True)\\n ma=0\\n for i in range(m):\\n a=p[i][0][1]\\n b=p[i][1][1]\\n ans=min(p[i][0][0],p[i][1][0])\\n for j in range(n):\\n if(j==a or j==b):\\n continue\\n ans=min(ans,f[j][0][0])\\n ma=max(ma,ans)\\n print(ma)\\nmain()\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nNN is an experienced internet user and that means he spends a lot of time on the social media. Once he found the following image on the Net, which asked him to compare the sizes of inner circles:\\n\\n\\n\\nIt turned out that the circles are equal. NN was very surprised by this fact, so he decided to create a similar picture himself.\\n\\nHe managed to calculate the number of outer circles n and the radius of the inner circle r. NN thinks that, using this information, you can exactly determine the radius of the outer circles R so that the inner circle touches all of the outer ones externally and each pair of neighboring outer circles also touches each other. While NN tried very hard to guess the required radius, he didn't manage to do that. \\n\\nHelp NN find the required radius for building the required picture.\\n\\nInput\\n\\nThe first and the only line of the input file contains two numbers n and r (3 ≤ n ≤ 100, 1 ≤ r ≤ 100) — the number of the outer circles and the radius of the inner circle respectively.\\n\\nOutput\\n\\nOutput a single number R — the radius of the outer circle required for building the required picture. \\n\\nYour answer will be accepted if its relative or absolute error does not exceed 10^{-6}.\\n\\nFormally, if your answer is a and the jury's answer is b. Your answer is accepted if and only when (|a-b|)\\/(max(1, |b|)) ≤ 10^{-6}.\\n\\nExamples\\n\\nInput\\n\\n3 1\\n\\n\\nOutput\\n\\n6.4641016\\n\\n\\nInput\\n\\n6 1\\n\\n\\nOutput\\n\\n1.0000000\\n\\n\\nInput\\n\\n100 100\\n\\n\\nOutput\\n\\n3.2429391\",\"targets\":\"#include \\nusing namespace std;\\nvoid ti() {}\\nint main() {\\n ti();\\n int n, r;\\n cin >> n >> r;\\n double x = sin((double)3.14159265 \\/ n);\\n double r1 = (double)(r * (x + 1)) \\/ (1 - x);\\n cout << setprecision(8) << (r1 - r) \\/ 2.0 << endl;\\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?\\nA 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;\\nconst long long int inf = LLONG_MAX;\\nint p[2005], s[2005];\\nint main() {\\n int n;\\n cin >> n;\\n int a[n + 5];\\n p[0] = s[0] = 0;\\n for (long long int i = 1; i <= n; i++) {\\n cin >> a[i];\\n p[i] = p[i - 1] + (a[i] == 1);\\n s[i] = s[i - 1] + (a[i] == 2);\\n }\\n s[n + 1] = s[n];\\n if (n == 1) {\\n cout << 1;\\n return 0;\\n }\\n int ans = 1;\\n for (long long int i = 1; i <= n; i++) {\\n int ct1 = 0, ct2 = 0;\\n for (long long int j = i; j <= n; j++) {\\n if (a[j] == 2)\\n ct2 = ct2 + 1;\\n else\\n ct1 = max(ct1, ct2) + 1;\\n ans = max(ans, p[i - 1] + s[n] - s[j] + max(ct1, ct2));\\n }\\n }\\n cout << ans;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Comrade Dujikov is busy choosing artists for Timofey's birthday and is recieving calls from Taymyr from Ilia-alpinist.\\n\\nIlia-alpinist calls every n minutes, i.e. in minutes n, 2n, 3n and so on. Artists come to the comrade every m minutes, i.e. in minutes m, 2m, 3m and so on. The day is z minutes long, i.e. the day consists of minutes 1, 2, ..., z. How many artists should be killed so that there are no artists in the room when Ilia calls? Consider that a call and a talk with an artist take exactly one minute.\\n\\nInput\\n\\nThe only string contains three integers — n, m and z (1 ≤ n, m, z ≤ 104).\\n\\nOutput\\n\\nPrint single integer — the minimum number of artists that should be killed so that there are no artists in the room when Ilia calls.\\n\\nExamples\\n\\nInput\\n\\n1 1 10\\n\\n\\nOutput\\n\\n10\\n\\n\\nInput\\n\\n1 2 5\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n2 3 9\\n\\n\\nOutput\\n\\n1\\n\\nNote\\n\\nTaymyr is a place in the north of Russia.\\n\\nIn the first test the artists come each minute, as well as the calls, so we need to kill all of them.\\n\\nIn the second test we need to kill artists which come on the second and the fourth minutes.\\n\\nIn the third test — only the artist which comes on the sixth minute. \\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.util.*;\\nimport java.math.*;\\npublic class nit{\\n public static void main(String[] args) {\\n Scanner sc=new Scanner(System.in);\\n int n=sc.nextInt();\\n int m=sc.nextInt();\\n int z=sc.nextInt();\\n ArrayList l=new ArrayList<>();\\n int b=1;\\n while(m*b<=z){\\n int f=m*b;\\n l.add(f);\\n b++;\\n }\\n b=1;\\n int count=0;\\n while(n*b<=z){\\n int f=n*b;\\n if(l.contains(f)){\\n \\/\\/int index=l.indexOf(f);\\n \\/\\/l.remove(index);\\n count++;\\n }\\n b++;\\n }\\n \\n System.out.println(count);\\n \\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"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.util.*;\\nimport java.io.*;\\nimport java.math.BigInteger;\\n \\npublic class code{\\n \\n static class Reader\\n {\\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(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 {\\n if (c == '\\\\n')\\n break;\\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 boolean neg = (c == '-');\\n if (neg)\\n c = read();\\n do\\n {\\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 }\\n while ((c = read()) >= '0' && c <= '9');\\n if (neg)\\n return -ret;\\n return ret;\\n }\\n \\n public double...\",\"language\":\"python\",\"split\":\"test\",\"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...\\n\\nfor\",\"targets\":\"i in range(int(input())):\\n a = input().split()\\n n = int(a[0])\\n v = int(a[1])\\n for b in range(1):\\n\\n if n%2 == 0:\\n if v%4 == 0:\\n print(n)\\n break\\n if v%4 == 1:\\n print(n-v)\\n if v%4 == 2:\\n print(n+1)\\n if v%4 == 3:\\n print(n+1+v) \\n \\n \\n else:\\n if v%4 == 0:\\n print(n)\\n break\\n if v%4 == 1:\\n print(n+v)\\n if v%4 == 2:\\n print(n-1)\\n if v%4 == 3:\\n print(n-1-v)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nThe 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), cin.tie(0), cout.tie(0);\\n long long TT, n, x, r;\\n cin >> TT;\\n while (TT--) {\\n cin >> x >> n;\\n if (n % 4 == 0)\\n r = 0;\\n else if (n % 4 == 1)\\n r = -n;\\n else if (n % 4 == 2)\\n r = 1;\\n else\\n r = (n \\/ 4 + 1) * 4;\\n if (abs(x) % 2 == 1) r = -r;\\n cout << x + r << '\\\\n';\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Dilku and Bhopu live in Artland. Dilku loves Bhopu and he writes a message : \\n“iloveyou”\\non paper and wishes to send it to Bhopu. As Dilku is busy making an artwork, he asks his friend Raj to send the message to Bhopu. However Raj has a condition that he may add\\/remove some characters and jumble the letters of the message.\\nAs Bhopu understands Dilku, she can read “iloveyou” from the message if all the characters of the string “iloveyou” are in the message received by her. Bhopu is happy if she can read “iloveyou” from the message. Otherwise, she is sad. Tell whether Bhopu is happy or sad.\\n\\nInput\\nInput contains a string S, where S is the message received by Bhopu. String S consists of only lowercase letters.\\n\\nOutput\\nOutput “happy” if Bhopu is happy and “sad” if Bhopu is sad.\\n\\nConstraints\\n1 ≤ |S| ≤ 100\\nWhere |S| denotes length of message string S\\n\\nExample\\nInput 1:\\niloveyou\\n\\nOutput 1:\\nhappy\\n\\nInput 2:\\nulrvysioqjifo\\n\\nOutput 2:\\nsad\\n\\nInput 3:\\nabcvleouioydef\\n\\nOutput 3:\\nhappy\",\"targets\":\"inp,ans,ph=set(raw_input()),['sad','happy'],set('iloveyou')\\nprint ans[len(inp.intersection(ph)) == len(ph)]\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nFrodo 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;\\nconst long long mod = 1e9 + 7;\\nconst unsigned long long INF = 1e9;\\nvoid fast() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n}\\nint binaryToDecimal(long long n) {\\n int num = (n);\\n int dec_value = 0;\\n int base = 1;\\n int temp = num;\\n while (temp) {\\n int last_digit = temp % 10;\\n temp = temp \\/ 10;\\n dec_value += last_digit * base;\\n base = base * 2;\\n }\\n return dec_value;\\n}\\nbool isprime(int n) {\\n if (n <= 1) return false;\\n for (int i = 2; i < n; i++)\\n if (n % i == 0) return false;\\n return true;\\n}\\nbool areBracketsBalanced(string expr) {\\n stack s;\\n char x;\\n for (int i = 0; i < expr.length(); i++) {\\n if (expr[i] == '(' || expr[i] == '[' || expr[i] == '{') {\\n s.push(expr[i]);\\n continue;\\n }\\n if (s.empty()) return false;\\n switch (expr[i]) {\\n case ')':\\n x = s.top();\\n s.pop();\\n if (x == '{' || x == '[') return false;\\n break;\\n case '}':\\n x = s.top();\\n s.pop();\\n if (x == '(' || x == '[') return false;\\n break;\\n case ']':\\n x = s.top();\\n s.pop();\\n if (x == '(' || x == '{') return false;\\n break;\\n }\\n }\\n return (s.empty());\\n}\\nlong long merge(long long arr[], long long l, long long mid, long long r) {\\n long long inv = 0;\\n long long n1 = mid - l + 1;\\n long long n2 = r - mid;\\n long long a[n1];\\n long long b[n2];\\n for (long long i = 0; i < n1; i++) a[i] = arr[l + i];\\n for (long long i = 0; i < n2; i++) b[i] = arr[mid + i + 1];\\n long long i = 0, j = 0, k = l;\\n while (i < n1 && j < n2) {\\n if (a[i] <= b[j]) {\\n arr[k] = a[i];\\n k++;\\n i++;\\n } else {\\n arr[k] = b[j];\\n inv += n1 - i;\\n k++;\\n j++;\\n }\\n }\\n while (i < n1) {\\n arr[k] = a[i];\\n k++;\\n i++;\\n }\\n while (j < n2) {\\n arr[k] = b[j];\\n k++;\\n j++;\\n }\\n return inv;\\n}\\nlong long mergeSort(long long arr[], long long l, long long r) {\\n long long inv = 0;\\n if (l < r) {\\n long long mid = (l + r) \\/...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP 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\":\"#include \\nusing namespace std;\\nint main() {\\n int T;\\n scanf(\\\"%d\\\", &T);\\n while (T--) {\\n int N;\\n scanf(\\\"%d\\\", &N);\\n if (N < 20)\\n for (int i = 0; i < N; ++i) putchar('a' + i);\\n else {\\n if (N & 1) {\\n putchar('c');\\n --N;\\n }\\n for (int i = 0; i < N \\/ 2; ++i) putchar('a');\\n putchar('b');\\n for (int i = 1; i < N \\/ 2; ++i) putchar('a');\\n }\\n puts(\\\"\\\");\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"During cleaning the coast, Alice found n piles of stones. The i-th pile has a_i stones.\\n\\nPiles i and i + 1 are neighbouring for all 1 ≤ i ≤ n - 1. If pile i becomes empty, piles i - 1 and i + 1 doesn't become neighbouring.\\n\\nAlice is too lazy to remove these stones, so she asked you to take this duty. She allowed you to do only the following operation: \\n\\n * Select two neighboring piles and, if both of them are not empty, remove one stone from each of them. \\n\\n\\n\\nAlice understands that sometimes it's impossible to remove all stones with the given operation, so she allowed you to use the following superability: \\n\\n * Before the start of cleaning, you can select two neighboring piles and swap them. \\n\\n\\n\\nDetermine, if it is possible to remove all stones using the superability not more than once.\\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 the single integer n (2 ≤ n ≤ 2 ⋅ 10^5) — the number of piles.\\n\\nThe second line of each test case contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — the number of stones in each pile.\\n\\nIt is guaranteed that the total sum of n over all test cases doesn't exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print YES or NO — is it possible to remove all stones using the superability not more than once or not.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n3\\n1 2 1\\n3\\n1 1 2\\n5\\n2 2 2 1 3\\n5\\n2100 1900 1600 3000 1600\\n2\\n2443 2445\\n\\n\\nOutput\\n\\n\\nYES\\nYES\\nYES\\nYES\\nNO\\n\\nNote\\n\\nIn the first test case, you can remove all stones without using a superability: [1, 2, 1] → [1, 1, 0] → [0, 0, 0].\\n\\nIn the second test case, you can apply superability to the second and the third piles and then act like in the first testcase.\\n\\nIn the third test case, you can apply superability to the fourth and the fifth piles, thus getting a = [2, 2, 2, 3, 1].\\n\\nIn the fourth test case, you can apply superability to the first and the second piles, thus getting a = [1900, 2100, 1600, 3000, 1600].\\ndef c\",\"targets\":\"an_clean(case):\\n cur_num = case[0]\\n for i in range(1, len(case)):\\n next_num = case[i] - cur_num\\n if next_num < 0: return False\\n cur_num = next_num\\n return (True if cur_num == 0 else False)\\nfor t in range(int(input())):\\n n = int(input());aa = [int(x) for x in input().split()]; fwd = {};have_printed = False;bwd = {}\\n for i in range(len(aa)):\\n ai = aa[i]\\n if i == 0: fwd[i] = ai\\n else:\\n next_val = ai - fwd[i-1]\\n if next_val < 0: break\\n fwd[i] = next_val \\n for i in range(len(aa)-1, -1, -1):\\n ai = aa[i]\\n if i == len(aa)-1: bwd[i] = ai\\n else:\\n next_val = ai - bwd[i+1]\\n if next_val < 0: break\\n bwd[i] = next_val\\n if len(bwd) == len(aa) and bwd[0] == 0:print(\\\"YES\\\"); continue \\n for i in range(len(aa)-1):\\n swap_pos = (i, i+1)\\n if i == 0: case = [aa[i+1], aa[i], bwd.get(i+2, -1)]\\n elif i+1 == len(aa)-1: case = [fwd.get(i-1, -1), aa[i+1], aa[i]]\\n else: case = [fwd.get(i-1, -1), aa[i+1], aa[i], bwd.get(i+2, -1)]\\n if case[0] < 0 or case[-1] < 0: continue\\n if can_clean(case): print(\\\"YES\\\"); have_printed = True; break\\n if not have_printed: print(\\\"NO\\\")\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nEverybody 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;\\nconst int N = 53, M = N * N, mod = 1e9 + 7;\\ntemplate \\nvoid rd(T &x) {\\n int ch = getchar();\\n x = 0;\\n for (; ch < '0' || ch > '9'; ch = getchar())\\n ;\\n for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';\\n}\\nvoid qmo(int &x) { x += x >> 31 & mod; }\\nint n, m, id[N][N], x[M], y[M], l[M], q[N << 1], fr, re, dp[N << 1][N][2];\\nvector a[M];\\nstruct Node {\\n int to, l;\\n bool st, ed;\\n Node(int _a = 0, int _b = 0, bool _c = 0, bool _d = 0)\\n : to(_a), l(_b), st(_c), ed(_d) {}\\n};\\nvector pt[N];\\nint main() {\\n rd(n);\\n rd(m);\\n for (int i = 1; i <= m; ++i) {\\n rd(x[i]);\\n rd(y[i]);\\n rd(l[i]);\\n a[i].resize(l[i]);\\n id[x[i]][y[i]] = i;\\n for (int j = 0; j < l[i]; ++j) rd(a[i][j]);\\n }\\n for (int i = 1, p, e; i <= m; ++i) {\\n for (p = 0; p + 1 < l[i]; ++p)\\n if (a[i][p] == x[i] && a[i][p + 1] == y[i]) break;\\n if (!l[i])\\n pt[x[i]].emplace_back(y[i], 1, 0, 0);\\n else if (p + 1 < l[i]) {\\n q[re = 0] = x[i];\\n for (int j = p - 1; ~j; --j) q[++re] = a[i][j];\\n for (fr = 0; fr < re && (e = id[q[fr + 1]][q[fr]]) && re <= (n << 1);\\n ++fr)\\n for (int j = l[e] - 1; ~j && re <= (n << 1); --j) q[++re] = a[e][j];\\n if (fr < re) continue;\\n int St = q[re], Le = re + 1;\\n q[re = 0] = y[i];\\n for (int j = p + 2; j < l[i]; ++j) q[++re] = a[i][j];\\n for (fr = 0; fr < re && (e = id[q[fr]][q[fr + 1]]) && re <= (n << 1);\\n ++fr)\\n for (int j = 0; j < l[e] && re <= (n << 1); ++j) q[++re] = a[e][j];\\n if (fr == re) pt[St].emplace_back(q[re], Le + re, 1, 1);\\n } else if (a[i][0] == y[i]) {\\n q[re = 0] = y[i];\\n for (int j = 1; j < l[i]; ++j) q[++re] = a[i][j];\\n for (fr = 0; fr < re && (e = id[q[fr]][q[fr + 1]]) && re <= (n << 1);\\n ++fr)\\n for (int j = 0; j < l[e] && re <= (n << 1); ++j) q[++re] = a[e][j];\\n if (fr == re) pt[x[i]].emplace_back(q[re], re + 1, 0, 1);\\n } else if (a[i][l[i] - 1] == x[i]) {\\n q[re = 0] =...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"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). \\nimpor\",\"targets\":\"t java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.io.OutputStreamWriter;\\nimport java.io.PrintWriter;\\nimport java.util.StringTokenizer;\\n\\npublic class A_A_Variety_of_Operations {\\n\\n static Scanner in=new Scanner();\\n \\n static PrintWriter out=new PrintWriter( new OutputStreamWriter(System.out) );\\n \\n static int testCases;\\n \\n static long c,d;\\n \\n static void solve(){\\n \\n if(c==d && c!=0){\\n \\n out.println(1);\\n out.flush();\\n \\n }else if(c==d && c==0 ){\\n \\n out.println(0);\\n out.flush();\\n \\n }else if( (c+d)%2==0 ){\\n \\n out.println(2);\\n out.flush();\\n \\n }else{\\n \\n out.println(-1);\\n out.flush();\\n \\n }\\n \\n }\\n \\n public static void main(String[] amit) throws IOException {\\n \\n testCases=in.nextInt();\\n \\n for(int t=0;t\\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...\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"# ------------------- fast io --------------------\\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# ------------------- fast io --------------------\\nfrom math import ceil\\n\\n\\ndef prod(a, mod=10 ** 9 + 7):\\n ans = 1\\n for each in a:\\n ans = (ans * each) % mod\\n return ans\\n\\n\\ndef gcd(x, y):\\n while y:\\n x, y = y, x % y\\n return x\\n\\n\\ndef lcm(a, b):...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Denis 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...\\nSolve the task in JAVA.\",\"targets\":\"import java.util.*;\\n\\npublic class C {\\n public static void main(String[] args) {\\n Scanner in = new Scanner(System.in);\\n int tests = in.nextInt();\\n for(int t=0; t positions = new HashMap<>();\\n for(int i=0; i\\n\\nThe truth is that investors have no idea how to efficiently evaluate the startup, so they are going to pick some k random distinct weeks li and give them to managers of the startup. For each li they should pick some ri ≥ li and report maximum number of visitors and minimum revenue during this period.\\n\\nThen, investors will calculate the potential of the startup for each of these ranges and take minimum value of p(li, ri) as the total evaluation grade of the startup. Assuming that managers of the startup always report the optimal values of ri for some particular li, i.e., the value such that the resulting grade of the startup is maximized, what is the expected resulting grade of the startup? \\n\\nInput\\n\\nThe first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 1 000 000).\\n\\nThe second line contains n integers vi (1 ≤ vi ≤ 107) — the number of unique visitors during each week.\\n\\nThe third line contains n integers ci (1 ≤ ci ≤ 107) —the revenue for each week.\\n\\nOutput\\n\\nPrint a single real value — the expected grade of the startup. 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 2\\n3 2 1\\n300 200 300\\n\\n\\nOutput\\n\\n133.3333333\\n\\nNote\\n\\nConsider the first sample.\\n\\nIf the investors ask for li = 1 onwards, startup will choose ri = 1, such that max number of visitors is 3 and minimum revenue is 300. Thus, potential in this case is min(3·100, 300) = 300.\\n\\nIf the...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint k, n, a[(int)(1e6 + 10)], b[(int)(1e6 + 10)], ans[(int)(1e6 + 10)], logn, l,\\n r;\\nint mxrmq[(int)(1e6 + 10)][20], mnrmq[(int)(1e6 + 10)][20];\\nvoid init() {\\n logn = log2(n);\\n for (int i = 1; i <= logn; i++)\\n for (int j = 1; j <= n; j++) {\\n mnrmq[j][i] =\\n min(mnrmq[j][i - 1], mnrmq[min(n, j + (1 << (i - 1)))][i - 1]);\\n mxrmq[j][i] =\\n max(mxrmq[j][i - 1], mxrmq[min(n, j + (1 << (i - 1)))][i - 1]);\\n }\\n}\\nint mnq(int l, int r) {\\n int logg = log2(r - l + 1);\\n return min(mnrmq[l][logg], mnrmq[r - (1 << logg) + 1][logg]);\\n}\\nint mxq(int l, int r) {\\n int logg = log2(r - l + 1);\\n return max(mxrmq[l][logg], mxrmq[r - (1 << logg) + 1][logg]);\\n}\\nint solve(int l, int r) {\\n int bas = l;\\n int son = r;\\n while (bas + 1 < son) {\\n int ort = (bas + son) \\/ 2;\\n if (mnq(l, ort) >= mxq(l, ort))\\n bas = ort;\\n else\\n son = ort;\\n }\\n if (bas == n) return min(mxq(l, bas), mnq(l, bas));\\n return max(min(mxq(l, bas), mnq(l, bas)),\\n min(mxq(l, bas + 1), mnq(l, bas + 1)));\\n}\\nint main() {\\n cin >> n >> k;\\n for (int i = 1; i <= n; i++) {\\n scanf(\\\"%d\\\", &a[i]);\\n a[i] *= 100;\\n mxrmq[i][0] = a[i];\\n }\\n for (int i = 1; i <= n; i++) {\\n scanf(\\\"%d\\\", &b[i]);\\n mnrmq[i][0] = b[i];\\n }\\n init();\\n for (int i = 1; i <= n; i++) ans[i] = solve(i, n);\\n sort(ans + 1, ans + n + 1);\\n reverse(ans + 1, ans + n + 1);\\n double x = 1.0 * k \\/ n;\\n double sum = 0;\\n for (int i = n; i >= k; i--) {\\n sum += ans[i] * x;\\n x \\/= (double)(i - 1) \\/ (i - k);\\n }\\n printf(\\\"%.12lf\\\\n\\\", sum);\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"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.\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"import sys\\ninput=sys.stdin.buffer.readline\\n\\ndef f(n,m,i):\\n if i<0:\\n return 0\\n if i==0:\\n if m&1:\\n return 2\\n elif n&1:\\n return 0\\n else:\\n return 1\\n if (n>>i)&1:\\n if (m>>i)&1:\\n x=f(n,m,i-1)\\n if x==(1<>i)&1:\\n x=f(n,m,i-1)\\n return (1< a * c * e) {\\n out.println(\\\"Ron\\\");\\n } else {\\n out.println(\\\"Hermione\\\");\\n }\\n in.close();\\n out.close();\\n } \\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"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...\\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 int n, k;\\n cin >> n >> k;\\n int arr[n];\\n for (int i = 1; i <= n; i++) cin >> arr[i];\\n int dp[n + 1][n + 1];\\n for (int i = 0; i <= n; i++)\\n for (int j = 0; j <= n; j++) dp[i][j] = 0;\\n for (int i = 0; i < n; i++) {\\n for (int j = 0; j <= i; j++) {\\n dp[i + 1][j] = max(dp[i][j], dp[i + 1][j]);\\n if (arr[i + 1] == j + 1)\\n dp[i + 1][j + 1] = max(dp[i + 1][j + 1], 1 + dp[i][j]);\\n else\\n dp[i + 1][j + 1] = max(dp[i][j], dp[i + 1][j + 1]);\\n }\\n }\\n int ans = -1;\\n for (int j = n; j >= 0; j--) {\\n if (dp[n][j] >= k) {\\n ans = n - j;\\n break;\\n }\\n }\\n cout << ans << \\\"\\\\n\\\";\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alice and Bob are playing a game. The game involves splitting up game pieces into two teams. There are n pieces, and the i-th piece has a strength pi.\\n\\nThe way to split up game pieces is split into several steps:\\n\\n 1. First, Alice will split the pieces into two different groups A and B. This can be seen as writing the assignment of teams of a piece in an n character string, where each character is A or B. \\n 2. Bob will then choose an arbitrary prefix or suffix of the string, and flip each character in that suffix (i.e. change A to B and B to A). He can do this step at most once. \\n 3. Alice will get all the pieces marked A and Bob will get all the pieces marked B. \\n\\n\\n\\nThe strength of a player is then the sum of strengths of the pieces in the group.\\n\\nGiven Alice's initial split into two teams, help Bob determine an optimal strategy. Return the maximum strength he can achieve.\\n\\nInput\\n\\nThe first line contains integer n (1 ≤ n ≤ 5·105) — the number of game pieces.\\n\\nThe second line contains n integers pi (1 ≤ pi ≤ 109) — the strength of the i-th piece.\\n\\nThe third line contains n characters A or B — the assignment of teams after the first step (after Alice's step).\\n\\nOutput\\n\\nPrint the only integer a — the maximum strength Bob can achieve.\\n\\nExamples\\n\\nInput\\n\\n5\\n1 2 3 4 5\\nABABA\\n\\n\\nOutput\\n\\n11\\n\\n\\nInput\\n\\n5\\n1 2 3 4 5\\nAAAAA\\n\\n\\nOutput\\n\\n15\\n\\n\\nInput\\n\\n1\\n1\\nB\\n\\n\\nOutput\\n\\n1\\n\\nNote\\n\\nIn the first sample Bob should flip the suffix of length one.\\n\\nIn the second sample Bob should flip the prefix or the suffix (here it is the same) of length 5.\\n\\nIn the third sample Bob should do nothing.\\nUsing java can you solve the prior task?\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\n\\npublic class AliceBobTwoTeams {\\n\\t\\n\\tboolean debugging = false;\\n\\t\\n\\tScanner in;\\n\\tBufferedReader br;\\n\\tStringTokenizer st;\\n\\tStringBuilder sb;\\n\\t\\n\\tint n;\\n\\tlong max, s;\\n\\tchar[] set;\\n\\tlong[][] sum; \\n\\t\\n\\tpublic AliceBobTwoTeams() {\\n\\t\\tin = new Scanner(System.in);\\n\\t\\t\\n\\t\\tn = in.nextInt();\\n\\t\\tsum = new long[2][n];\\n\\t\\tmax = 0; s = 0;\\n\\t\\t\\n\\t\\tfor (int i = 0; i < n; i++) {\\n\\t\\t\\tsum[0][i] = sum[1][i] = in.nextInt();\\n\\t\\t}\\n\\t\\tin.nextLine();\\n\\t\\t\\n\\t\\tset = in.nextLine().toCharArray();\\n\\t\\t\\n\\t\\tfor (int i = 0; i < n; i++) {\\n\\t\\t\\tif (set[i] == 'B') {\\n\\t\\t\\t\\ts += sum[0][i];\\n\\t\\t\\t\\tsum[0][i] = sum[1][i] *= -1;\\n\\t\\t\\t\\t\\n\\t\\t\\t}\\n\\t\\t\\t\\n\\t\\t}\\n\\t\\t\\n\\t\\tif (debugging) {\\n\\t\\t\\tSystem.out.printf(\\\"\\\\tValues: %s\\\\n\\\", Arrays.toString(sum[0]));\\n\\t\\t}\\n\\t\\t\\n\\t\\tmax = Math.max(max, sum[0][0]);\\n\\t\\tmax = Math.max(max, sum[1][n - 1]);\\n\\t\\tfor (int i = 1; i < n; i++) {\\n\\t\\t\\tsum[0][i] += sum[0][i - 1];\\n\\t\\t\\tsum[1][n - i - 1] += sum[1][n - i];\\n\\t\\t\\t\\n\\t\\t\\tif (debugging) {\\n\\t\\t\\t\\tSystem.out.printf(\\\"\\\\tSum[%d][%d] = %d\\\\t\\\", 0, i, sum[0][i]);\\n\\t\\t\\t\\tSystem.out.printf(\\\"Sum[%d][%d] = %d\\\\n\\\", 1, (n - i - 1), sum[1][n - i]);\\n\\t\\t\\t}\\n\\t\\t\\t\\n\\t\\t\\tmax = Math.max(max, sum[0][i]);\\n\\t\\t\\tmax = Math.max(max, sum[1][n - i - 1]);\\n\\t\\t}\\n\\t\\t\\n\\t\\tSystem.out.println(s + max);\\n\\t\\t\\n\\t\\tin.close();\\n\\t}\\n\\t\\n\\tpublic static void main(String[] args) {\\n\\t\\tnew AliceBobTwoTeams();\\n\\t}\\n\\t\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"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...\\nUsing python3 can you solve the prior task?\",\"targets\":\"t=int(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\":\"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.\\nUsing python3 can you solve the prior task?\",\"targets\":\"t=int(input())\\nfor _ in range(t):\\n a,b,c=map(int,input().split())\\n temp=a*1+b*2+c*3\\n if(temp%2==0):\\n print(\\\"0\\\")\\n else:\\n print(\\\"1\\\")\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"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\\nn = i\",\"targets\":\"nt(raw_input())\\na = map(int, raw_input().split(' '))\\nif sum(a) == 0:\\n print 0\\nelse:\\n l = a.index(1)\\n r = len(a) - 1 - list(reversed(a)).index(1)\\n ans = 1\\n cur = 0\\n for i in range(l, r + 1):\\n if a[i] == 0:\\n cur += 1\\n else:\\n ans *= cur + 1\\n cur = 0\\n print ans\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 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\":\"import sys\\nimport time\\ninput = sys.stdin.readline\\ndef main():\\n t = int(input())\\n for _ in range(t):\\n s = input().strip()\\n d = {}\\n rev = []\\n for i in s:\\n if i not in d:\\n d[i]=1\\n else:\\n d[i]+=1\\n for i in s[::-1]:\\n if i not in rev:\\n rev.append(i)\\n num = len(rev)\\n first_count = [0]*num\\n end = 0\\n for i in range(len(rev)):\\n if d[rev[i]]%(num-i)!=0:\\n end=1\\n else:\\n first_count[i] = d[rev[i]]\\/\\/(num-i)\\n if end:\\n print(-1)\\n continue\\n guess = s[:sum(first_count)]\\n letters = ''.join(rev)[::-1]\\n check = guess\\n temp = guess\\n for i in letters:\\n temp = temp.replace(i, '')\\n check += temp\\n if s == check:\\n print(guess+' '+letters)\\n else:\\n print(-1)\\nmain()\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"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\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nvoid solve() {\\n string s;\\n cin >> s;\\n long long int l = 0, r = 0;\\n for (long long int f = 0; f < s.length(); f++) {\\n if (f % 2) {\\n l *= 10;\\n l += s[f] - '0';\\n } else {\\n r *= 10;\\n r += s[f] - '0';\\n }\\n }\\n cout << (l + 1) * (r + 1) - 2;\\n cout << \\\"\\\\n\\\";\\n}\\nint32_t main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n long long int tt;\\n cin >> tt;\\n long long int ll = 1;\\n while (tt--) {\\n solve();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?\\n\\nThe book contains a single string of characters \\\"a\\\", \\\"b\\\" and \\\"c\\\". It has been pointed out that no two consecutive characters are the same. It has also been conjectured that the string contains an unusually long subsequence that reads the same from both sides. \\n\\nHelp Alice verify this by finding such subsequence that contains at least half of the characters of the original string, rounded down. Note that you don't have to maximise the length of it.\\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) characters.\\n\\nInput\\n\\nThe input consists of a single string s (2 ≤ |s| ≤ 10^6). The string s consists only of characters \\\"a\\\", \\\"b\\\", \\\"c\\\". It is guaranteed that no two consecutive characters are equal.\\n\\nOutput\\n\\nOutput a palindrome t that is a subsequence of s and |t| ≥ ⌊ (|s|)\\/(2) ⌋.\\n\\nIf there are multiple solutions, you may print any of them. You don't have to maximise the length of t.\\n\\nIf there are no solutions, output a string \\\"IMPOSSIBLE\\\" (quotes for clarity).\\n\\nExamples\\n\\nInput\\n\\n\\ncacbac\\n\\n\\nOutput\\n\\n\\naba\\n\\n\\nInput\\n\\n\\nabc\\n\\n\\nOutput\\n\\n\\na\\n\\n\\nInput\\n\\n\\ncbacacacbcbababacbcb\\n\\n\\nOutput\\n\\n\\ncbaaacbcaaabc\\n\\nNote\\n\\nIn the first example, other valid answers include \\\"cacac\\\", \\\"caac\\\", \\\"aca\\\" and \\\"ccc\\\".\",\"targets\":\"#!\\/usr\\/bin\\/python3\\n\\nfrom array import array\\nimport math\\nimport sys\\n\\n\\nDEBUG = False\\n\\n\\ndef inp():\\n return sys.stdin.readline().rstrip()\\n\\n\\ndef dprint(*value, sep=' ', end='\\\\n'):\\n if DEBUG:\\n print(*value, sep=sep, end=end)\\n\\n\\ndef solve(S):\\n N = len(S)\\n\\n la = array('i', [0] * (N + 2))\\n ra = array('i', [0] * (N + 2))\\n lb = array('i', [0] * (N + 2))\\n rb = array('i', [0] * (N + 2))\\n lc = array('i', [0] * (N + 2))\\n rc = array('i', [0] * (N + 2))\\n\\n la[N + 1] = N\\n ra[0] = -1\\n lb[N + 1] = N\\n rb[0] = -1\\n lc[N + 1] = N\\n rc[0] = -1\\n\\n for i in range(N - 1, -1, -1):\\n if S[i] == 'a':\\n la[i + 1] = i\\n else:\\n la[i + 1] = la[i + 2]\\n\\n if S[i] == 'b':\\n lb[i + 1] = i\\n else:\\n lb[i + 1] = lb[i + 2]\\n\\n if S[i] == 'c':\\n lc[i + 1] = i\\n else:\\n lc[i + 1] = lc[i + 2]\\n\\n for i in range(N):\\n if S[i] == 'a':\\n ra[i + 1] = i\\n else:\\n ra[i + 1] = ra[i]\\n\\n if S[i] == 'b':\\n rb[i + 1] = i\\n else:\\n rb[i + 1] = rb[i]\\n\\n if S[i] == 'c':\\n rc[i + 1] = i\\n else:\\n rc[i + 1] = rc[i]\\n\\n dprint('lc', lc)\\n dprint('rc', rc)\\n\\n rep = []\\n mid = []\\n\\n li = 0\\n ri = N\\n\\n while li < ri:\\n dprint(li, ri)\\n if ri - li == 1:\\n mid.append(S[li])\\n break\\n\\n al = la[li + 1]\\n ar = ra[ri] + 1\\n bl = lb[li + 1]\\n br = rb[ri] + 1\\n cl = lc[li + 1]\\n cr = rc[ri] + 1\\n\\n da = ar - al\\n db = br - bl\\n dc = cr - cl\\n dm = max(da, db, dc)\\n\\n dprint('clcr', cl, cr)\\n\\n if dm == da:\\n if da > 1:\\n rep.append('a')\\n else:\\n mid.append('a')\\n li = al + 1\\n ri = ar - 1\\n elif dm == db:\\n if db > 1:\\n rep.append('b')\\n else:\\n mid.append('b')\\n li = bl + 1\\n ri = br - 1\\n...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nA star is a figure of the following type: an asterisk character '*' in the center of the figure and four rays (to the left, right, top, bottom) of the same positive length. The size of a star is the length of its rays. The size of a star must be a positive number (i.e. rays of length 0 are not allowed).\\n\\nLet's consider empty cells are denoted by '.', then the following figures are stars:\\n\\n The leftmost figure is a star of size 1, the middle figure is a star of size 2 and the rightmost figure is a star of size 3.\\n\\nYou are given a rectangular grid of size n × m consisting only of asterisks '*' and periods (dots) '.'. Rows are numbered from 1 to n, columns are numbered from 1 to m. Your task is to draw this grid using any number of stars or find out that it is impossible. Stars can intersect, overlap or even coincide with each other. The number of stars in the output can't exceed n ⋅ m. Each star should be completely inside the grid. You can use stars of same and arbitrary sizes.\\n\\nIn this problem, you do not need to minimize the number of stars. Just find any way to draw the given grid with at most n ⋅ m stars.\\n\\nInput\\n\\nThe first line of the input contains two integers n and m (3 ≤ n, m ≤ 1000) — the sizes of the given grid.\\n\\nThe next n lines contains m characters each, the i-th line describes the i-th row of the grid. It is guaranteed that grid consists of characters '*' and '.' only.\\n\\nOutput\\n\\nIf it is impossible to draw the given grid using stars only, print \\\"-1\\\".\\n\\nOtherwise in the first line print one integer k (0 ≤ k ≤ n ⋅ m) — the number of stars needed to draw the given grid. The next k lines should contain three integers each — x_j, y_j and s_j, where x_j is the row index of the central star character, y_j is the column index of the central star character and s_j is the size of the star. Each star should be completely inside the grid.\\n\\nExamples\\n\\nInput\\n\\n6 8\\n....*...\\n...**...\\n..*****.\\n...**...\\n....*...\\n........\\n\\n\\nOutput\\n\\n3\\n3 4 1\\n3 5 2\\n3 5 1\\n\\n\\nInput\\n\\n5 5\\n.*...\\n****.\\n.****\\n..**.\\n.....\\n\\n\\nOutput\\n\\n3\\n2 2...\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 1e3 + 7, LOG = (1 << 12);\\nbool A[N][N], Row[N][LOG], Col[N][LOG];\\nint U[N][N], D[N][N], R[N][N], L[N][N];\\nvector, int> > Result;\\nint n, m, p = 1;\\nint GetMin(int x, int y) {\\n return min(U[x][y], min(D[x][y], min(R[x][y], L[x][y])));\\n}\\nbool Can(int x, int y) { return GetMin(x, y) > 1; }\\nvoid UpdateRow(int L, int R, int row) {\\n while (L < R) {\\n if (L & 1) Row[row][L++] = true;\\n if (R & 1) Row[row][--R] = true;\\n L >>= 1;\\n R >>= 1;\\n }\\n}\\nvoid UpdateCol(int L, int R, int col) {\\n while (L < R) {\\n if (L & 1) Col[col][L++] = true;\\n if (R & 1) Col[col][--R] = true;\\n L >>= 1;\\n R >>= 1;\\n }\\n}\\nvoid Draw(int x, int y) {\\n int mini = GetMin(x, y);\\n UpdateRow(y - mini + p, y - 1 + mini + p, x);\\n UpdateCol(x - mini + p, x - 1 + mini + p, y);\\n Result.push_back({{x, y}, mini - 1});\\n}\\nbool GetRow(int row, int v) {\\n bool result = false;\\n while (v) {\\n result |= Row[row][v];\\n v >>= 1;\\n }\\n return result;\\n}\\nbool GetCol(int col, int v) {\\n bool result = false;\\n while (v) {\\n result |= Col[col][v];\\n v >>= 1;\\n }\\n return result;\\n}\\nbool Equals() {\\n for (int i = 1; i <= n; ++i)\\n for (int j = 1; j <= m; ++j)\\n if (A[i][j] != (GetCol(j, i - 1 + p) | GetRow(i, j - 1 + p)))\\n return false;\\n return true;\\n}\\nvoid Read() {\\n scanf(\\\"%d %d\\\", &n, &m);\\n for (int i = 1; i <= n; ++i)\\n for (int j = 1; j <= m; ++j) {\\n char c;\\n scanf(\\\" %c\\\", &c);\\n if (c == '*') A[i][j] = true;\\n }\\n}\\nvoid Prepare() {\\n for (int i = 1; i <= n; ++i)\\n for (int j = 1; j <= m; ++j)\\n if (A[i][j])\\n U[i][j] = U[i - 1][j] + 1;\\n else\\n U[i][j] = 0;\\n for (int i = n; i > 0; --i)\\n for (int j = 1; j <= m; ++j)\\n if (A[i][j])\\n D[i][j] = D[i + 1][j] + 1;\\n else\\n D[i][j] = 0;\\n for (int i = 1; i <= n; ++i)\\n for (int j = 1; j <= m; ++j)\\n if (A[i][j])\\n L[i][j] = L[i][j - 1] + 1;\\n else\\n L[i][j] = 0;\\n for (int i = 1; i <= n; ++i)\\n for (int j = m; j > 0;...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Being a nonconformist, Volodya is displeased with the current state of things, particularly with the order of natural numbers (natural number is positive integer number). He is determined to rearrange them. But there are too many natural numbers, so Volodya decided to start with the first n. He writes down the following sequence of numbers: firstly all odd integers from 1 to n (in ascending order), then all even integers from 1 to n (also in ascending order). Help our hero to find out which number will stand at the position number k.\\n\\nInput\\n\\nThe only line of input contains integers n and k (1 ≤ k ≤ n ≤ 1012).\\n\\nPlease, do not use 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\\nOutput\\n\\nPrint the number that will stand at the position number k after Volodya's manipulations.\\n\\nExamples\\n\\nInput\\n\\n10 3\\n\\n\\nOutput\\n\\n5\\n\\nInput\\n\\n7 7\\n\\n\\nOutput\\n\\n6\\n\\nNote\\n\\nIn the first sample Volodya's sequence will look like this: {1, 3, 5, 7, 9, 2, 4, 6, 8, 10}. The third place in the sequence is therefore occupied by the number 5.\",\"targets\":\"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Sat Dec 14 00:10:39 2019\\n\\n@author: Zheng Jiajia\\n\\\"\\\"\\\"\\n\\nn,s=map(int,input().split())\\n\\nif n%2==0:\\n mid=n\\/2\\nelse:\\n mid=n\\/\\/2+1\\n#9 5\\n#8 4\\n#7 4\\n#6 3\\n\\nif s>mid:\\n p=s-mid\\n print(int(2*p))\\nelse:\\n print(int(2*s-1))\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"As 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.\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.util.Scanner;\\n\\npublic class LoveTraingle {\\n\\n\\tpublic static void main(String[] args) {\\n\\t\\tScanner sc = new Scanner(System.in);\\n\\t\\tint num = sc.nextInt();\\n\\t\\tint[] array = new int[10000];\\n\\t\\t\\n\\t\\tfor(int i = 1; i <= num; i++){\\n\\t\\t\\tarray[i] = sc.nextInt();\\n\\t\\t}\\n\\t\\tfor(int i = 1; i <= num; i++){\\n\\t\\t\\tif (array[array[array[i]]] == i) {\\n\\t\\t\\t\\tSystem.out.println(\\\"YES\\\");\\n\\t\\t\\t\\treturn;\\n\\t\\t\\t}\\t\\n\\t\\t}\\n\\t\\tSystem.out.println(\\\"NO\\\");\\n\\t}\\n\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"DZY has a sequence a, consisting of n integers.\\n\\nWe'll call a sequence ai, ai + 1, ..., aj (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.\\n\\nYour task is to find the longest subsegment of a, such that it is possible to change at most one number (change one number to any integer you want) from the subsegment to make the subsegment strictly increasing.\\n\\nYou only need to output the length of the subsegment you find.\\n\\nInput\\n\\nThe first line contains integer n (1 ≤ n ≤ 105). The next line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109).\\n\\nOutput\\n\\nIn a single line print the answer to the problem — the maximum length of the required subsegment.\\n\\nExamples\\n\\nInput\\n\\n6\\n7 2 3 1 5 6\\n\\n\\nOutput\\n\\n5\\n\\nNote\\n\\nYou can choose subsegment a2, a3, a4, a5, a6 and change its 3rd element (that is a4) to 4.\\nUsing python3 can you solve the prior task?\",\"targets\":\"#codeforces\\nn=int(input())\\na=list(map(int,input().split()))\\nfr=[0]*(n)\\nbck=[0]*(n)\\nfr[0]=1\\nbck[n-1]=1\\nans=1\\nif n==1:\\n print(ans)\\nelse:\\n for i in range(1,n):\\n if a[i]<=a[i-1]:\\n fr[i]=1\\n else:\\n fr[i]+=fr[i-1]+1\\n for i in range(n-2,-1,-1):\\n if a[i]>=a[i+1]:\\n bck[i]=1\\n else:\\n bck[i]+=bck[i+1]+1\\n ans=max(fr)\\n ans=max(bck[1]+1,ans)\\n ans=max(ans,fr[n-2]+1)\\n for i in range(1,n-1):\\n if i+1=0:\\n if a[i+1]-a[i-1]>1:\\n ans=max(fr[i-1]+bck[i+1]+1,ans)\\n else:\\n ans=max(fr[i-1]+1,ans)\\n ans=max(bck[i+1]+1,ans)\\n print(ans)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"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...\\nimpor\",\"targets\":\"t java.io.*;\\nimport java.util.*;\\n\\npublic class A {\\n \\n\\tpublic static void main(String[] args) {\\n\\/\\/ \\t try {\\n\\/\\/ \\t\\t\\tSystem.setIn(new FileInputStream(\\\"input.txt\\\"));\\n\\/\\/ \\t\\t\\tSystem.setOut(new PrintStream(new FileOutputStream(\\\"output.txt\\\")));\\n\\/\\/ \\t\\t} catch (Exception e) {\\n\\/\\/ \\t\\t\\tSystem.err.println(\\\"Error\\\");\\n\\/\\/ \\t\\t}\\n\\t\\t\\/\\/ Scanner sc = new Scanner(System.in);\\n\\t\\t\\/\\/ int t=sc.nextInt();\\n\\t\\t\\/\\/ t=1;\\n\\t\\tSolver s=new Solver();\\n\\t\\ts.solve();\\n\\t\\t\\n\\t}\\n}\\n\\nclass Solver{\\n\\tScanner sc;\\n Solver(){\\n \\tsc = new Scanner(System.in);\\n }\\n \\n \\n \\n void func(){\\n \\t\\n \\tString s=sc.next();\\n \\tint arr[]=new int[26];\\n \\tint ans=0;\\n \\t\\/\\/ int n=sc.nextInt();\\n \\tfor(int i=0;i2)?2:arr[i];\\n cnt\\/=2;\\n\\n\\n \\t\\n \\t\\n System.out.println(cnt);\\n\\n }\\n\\n void solve(){\\n \\tint t=sc.nextInt();\\n \\t\\/\\/ int t=1;\\n \\twhile(t>0){\\n\\t\\t\\tt--;\\n\\t\\t\\tfunc();\\n\\t\\t}\\n }\\n\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"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;\\nconst int MOD = 1e9 + 7;\\nconst int N = 2e5 + 5;\\nstruct dish {\\n int a, b, pos;\\n};\\nint t, n, m;\\ndish c[N], ans[N];\\nbool cmp(dish x, dish y) { return x.a < y.a; }\\nbool cmp2(dish x, dish y) { return x.pos < y.pos; }\\nvoid solve() {\\n long long res = 0;\\n for (int i = 1; i <= n; ++i) {\\n int k = c[i].a - m;\\n if (k >= 0)\\n res += c[i].b - k;\\n else\\n res += c[i].b + k;\\n }\\n if (res <= 0) {\\n cout << -res << '\\\\n';\\n for (int i = 1; i <= n; ++i) {\\n int k = c[i].a - m;\\n int d = c[i].b + (k >= 0 ? 0 : k);\\n ans[i].a = c[i].a - max(k, 0);\\n ans[i].b = c[i].b - d;\\n ans[i].pos = c[i].pos;\\n }\\n sort(ans + 1, ans + 1 + n, cmp2);\\n for (int i = 1; i <= n; ++i) cout << ans[i].a << ' ' << ans[i].b << '\\\\n';\\n return;\\n }\\n for (int i = 1; i <= n; ++i) {\\n int k = c[i].a - m;\\n int d = c[i].b + (k >= 0 ? 0 : k);\\n ans[i].pos = c[i].pos;\\n ans[i].a = max(0, k);\\n ans[i].b = d;\\n int x = min({res \\/ 2, (long long)d, 0LL + c[i].a - ans[i].a});\\n ans[i].a += x;\\n ans[i].b -= x;\\n ans[i].a = c[i].a - ans[i].a;\\n ans[i].b = c[i].b - ans[i].b;\\n res -= x * 2;\\n }\\n sort(ans + 1, ans + 1 + n, cmp2);\\n cout << abs(res) << '\\\\n';\\n for (int i = 1; i <= n; ++i) cout << ans[i].a << ' ' << ans[i].b << '\\\\n';\\n}\\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 >> m;\\n for (int i = 1; i <= n; ++i) {\\n cin >> c[i].a >> c[i].b;\\n c[i].pos = i;\\n }\\n sort(c + 1, c + 1 + n, cmp);\\n solve();\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\n\\n\\nInput\\n\\nThe input contains a single integer a (0 ≤ a ≤ 63).\\n\\nOutput\\n\\nOutput a single number.\\n\\nExamples\\n\\nInput\\n\\n\\n2\\n\\n\\nOutput\\n\\n\\n2\\n\\n\\nInput\\n\\n\\n5\\n\\n\\nOutput\\n\\n\\n24\\n\\n\\nInput\\n\\n\\n35\\n\\n\\nOutput\\n\\n\\n50\",\"targets\":\"#include \\nusing namespace std;\\nlong long m, t, i, n, j;\\nint main() {\\n ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);\\n long long a[6] = {0};\\n cin >> n;\\n i = 0;\\n while (i < 6) {\\n a[i] = n % 2;\\n n \\/= 2;\\n i++;\\n }\\n cout << a[0] * pow(2, 4) + a[1] * pow(2, 1) + a[2] * pow(2, 3) +\\n a[3] * pow(2, 2) + a[4] + a[5] * pow(2, 5);\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Being a programmer, you like arrays a lot. For your birthday, your friends have given you an array a consisting of n distinct integers.\\n\\nUnfortunately, the size of a is too small. You want a bigger array! Your friends agree to give you a bigger array, but only if you are able to answer the following question correctly: is it possible to sort the array a (in increasing order) by reversing exactly one segment of a? See definitions of segment and reversing in the notes.\\n\\nInput\\n\\nThe first line of the input contains an integer n (1 ≤ n ≤ 105) — the size of array a.\\n\\nThe second line contains n distinct space-separated integers: a[1], a[2], ..., a[n] (1 ≤ a[i] ≤ 109).\\n\\nOutput\\n\\nPrint \\\"yes\\\" or \\\"no\\\" (without quotes), depending on the answer.\\n\\nIf your answer is \\\"yes\\\", then also print two space-separated integers denoting start and end (start must not be greater than end) indices of the segment to be reversed. If there are multiple ways of selecting these indices, print any of them.\\n\\nExamples\\n\\nInput\\n\\n3\\n3 2 1\\n\\n\\nOutput\\n\\nyes\\n1 3\\n\\n\\nInput\\n\\n4\\n2 1 3 4\\n\\n\\nOutput\\n\\nyes\\n1 2\\n\\n\\nInput\\n\\n4\\n3 1 2 4\\n\\n\\nOutput\\n\\nno\\n\\n\\nInput\\n\\n2\\n1 2\\n\\n\\nOutput\\n\\nyes\\n1 1\\n\\nNote\\n\\nSample 1. You can reverse the entire array to get [1, 2, 3], which is sorted.\\n\\nSample 3. No segment can be reversed such that the array will be sorted.\\n\\nDefinitions\\n\\nA segment [l, r] of array a is the sequence a[l], a[l + 1], ..., a[r].\\n\\nIf you have an array a of size n and you reverse its segment [l, r], the array will become:\\n\\na[1], a[2], ..., a[l - 2], a[l - 1], a[r], a[r - 1], ..., a[l + 1], a[l], a[r + 1], a[r + 2], ..., a[n - 1], a[n].\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n ios::sync_with_stdio(false);\\n const int N = 100100;\\n int n, a[N];\\n cin >> n;\\n for (int i = 0; i < n; i++) {\\n cin >> a[i];\\n }\\n int l1 = 0, l2 = 0;\\n bool desc = false;\\n for (int i = 1; i < n; i++) {\\n if (!desc && a[i] < a[i - 1]) {\\n desc = true;\\n l1 = i - 1;\\n }\\n if (desc && a[i] > a[i - 1]) {\\n desc = false;\\n l2 = i - 1;\\n break;\\n }\\n }\\n if (desc) {\\n l2 = n - 1;\\n }\\n reverse(a + l1, a + l2 + 1);\\n bool yes = true;\\n for (int i = 1; i < n; i++) {\\n if (a[i - 1] > a[i]) {\\n yes = false;\\n break;\\n }\\n }\\n if (yes) {\\n cout << \\\"yes\\\\n\\\" << l1 + 1 << \\\" \\\" << l2 + 1 << endl;\\n } else {\\n cout << \\\"no\\\" << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"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...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nconstexpr int maxn = 1e3 + 10, lim = 1e9;\\nint query(const int x, const int y) {\\n int res = 0;\\n std::cout << \\\"? \\\" << x << \\\" \\\" << y << std::endl;\\n std::cin >> res;\\n if (res == -1) std::exit(-1);\\n return res;\\n}\\nvoid answer(const int x1, const int y1, const int x2, const int y2) {\\n std::cout << \\\"! \\\" << x1 << \\\" \\\" << y1 << \\\" \\\" << x2 << \\\" \\\" << y2 << std::endl;\\n std::exit(0);\\n}\\nvoid solve() {\\n const auto p = query(lim, 1), q = query(lim, lim), d = q - p,\\n b = (d + lim) \\/ 2, y = lim - b, t = query(lim, y);\\n int l = 1, r = y, mi = -1;\\n while (l <= r) {\\n const auto mid = (l + r) >> 1;\\n if (query(lim, mid) == t)\\n mi = mid, r = mid - 1;\\n else\\n l = mid + 1;\\n }\\n const auto mx = lim + 1 - mi - d;\\n assert(mi <= mx);\\n answer(1 + query(1, mi), mi, lim - query(lim, mi), mx);\\n}\\nint main() {\\n int t = 1;\\n for (auto REPN_lIM = t, REPN = 1; REPN <= REPN_lIM; REPN++) solve();\\n return (0 - 0);\\n}\",\"language\":\"python\",\"split\":\"test\",\"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...\\nSolve the task in PYTHON3.\",\"targets\":\"for _ in range(int(input())):\\n n = int(input())\\n arr = list(map(int, input().split()))\\n if n % 2 == 0:\\n print('YES')\\n continue\\n ok = False\\n for i in range(1, n):\\n if arr[i] <= arr[i - 1]:\\n ok = True\\n if ok:\\n print('YES')\\n else:\\n print('NO')\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"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 uint = unsigned int;\\nusing cat = long long;\\nusing dbl = long double;\\nconstexpr dbl pi = 3.14159265358979323846;\\nusing namespace std;\\ntemplate \\nT abs(T x) {\\n return (x < 0) ? (-x) : x;\\n}\\ncat gcd(cat a, cat b) {\\n if (a > b) swap(a, b);\\n while (a) {\\n cat c = b % a;\\n b = a;\\n a = c;\\n }\\n return b;\\n}\\ncat pw(cat a, cat e, cat mod) {\\n if (e <= 0) return 1;\\n cat x = pw(a, e \\/ 2, mod);\\n x = x * x % mod;\\n return (e & 1) ? x * a % mod : x;\\n}\\ntemplate \\nclass fin {\\n vector node_val;\\n int lastone(int x) { return x & (x ^ (x - 1)); }\\n\\n public:\\n fin(int N, T init_val) { node_val.resize(N + 10, init_val); }\\n void put(int pos, T val) {\\n for (int i = pos + 1; i < (int)node_val.size(); i += lastone(i))\\n node_val[i] += val;\\n }\\n T get(int pos) {\\n T ret = 0;\\n for (int i = pos + 1; i > 0; i -= lastone(i)) ret += node_val[i];\\n return ret;\\n }\\n};\\nstruct edge {\\n int val, u, v;\\n};\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n cout << fixed << setprecision(12);\\n int N, K, MX = 1000000;\\n cin >> N >> K;\\n vector A(1 << N);\\n for (int i = 0; i < (1 << N); i++) cin >> A[i];\\n vector use_b(1 << N, 0), id(1 << N, -1), V(2 * K);\\n int ans = 0;\\n vector E;\\n E.reserve((1 << (N - 1)) * N);\\n for (int i = 0; i < (1 << N); i++)\\n for (int j = 0; j < N; j++)\\n if ((i >> j) & 1)\\n E.push_back(\\n edge{.val = A[i] + A[i ^ (1 << j)], .u = i, .v = i ^ (1 << j)});\\n vector n_val(2 * MX + 1, 0);\\n for (int i = 0; i < (int)E.size(); i++) n_val[E[i].val]++;\\n vector cur_pos(2 * MX + 2, 0);\\n for (int i = 1; i <= 2 * MX + 1; i++)\\n cur_pos[i] = cur_pos[i - 1] + n_val[i - 1];\\n int min_good_val = 0;\\n while (cur_pos[min_good_val] < (N << (N - 1)) - 2 * N * K) min_good_val++;\\n vector Es((1 << (N - 1)) * N);\\n for (int i = 0; i < (1 << (N - 1)) * N; i++)\\n if (E[i].val >= min_good_val) Es[cur_pos[E[i].val]++] = E[i];\\n E = Es;\\n for (int k = 0; k < K; k++) {\\n vector...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"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\":\"\\/*package whatever \\/\\/do not write package name here *\\/\\n\\nimport java.io.*;\\nimport java.util.*;\\n\\npublic class GFG {\\n public static Scanner scn=new Scanner(System.in);\\n\\tpublic static void main (String[] args) {\\n\\t\\tint t=scn.nextInt();\\n\\t\\twhile(t-->0)\\n\\t\\t{\\n\\t\\t int k=scn.nextInt();\\n\\t\\t int n=k-2;\\n\\t\\t StringBuilder sb=new StringBuilder();\\n\\t\\t for(int i=0;i\\nusing namespace std;\\nconst int N = 100010;\\nint n, x, cnt;\\nint res[N], st[N];\\nbool cmp(pair a, pair b) { return a.first >= b.first; }\\nvoid solve() {\\n scanf(\\\"%d\\\", &n);\\n cnt = 0;\\n memset(res, 0, sizeof res);\\n memset(st, 0, sizeof st);\\n pair a[N], b[N];\\n for (int i = 1; i <= n; i++) {\\n scanf(\\\"%d\\\", &x);\\n a[i] = {x, i};\\n }\\n for (int i = 1; i <= n; i++) {\\n scanf(\\\"%d\\\", &x);\\n b[i] = {x, i};\\n }\\n sort(a + 1, a + n + 1, cmp);\\n sort(b + 1, b + n + 1, cmp);\\n for (int i = 1; i <= n; i++) {\\n if (!st[a[i].second]) cnt++;\\n st[a[i].second]++;\\n if (!st[a[i].second]) cnt--;\\n if (!st[b[i].second]) cnt++;\\n st[b[i].second]--;\\n if (!st[b[i].second]) cnt--;\\n res[b[i].second] = 1, res[a[i].second] = 1;\\n if (cnt == 0) break;\\n }\\n for (int i = 1; i <= n; i++) printf(\\\"%d\\\", res[i]);\\n puts(\\\" \\\");\\n}\\nint main() {\\n int t;\\n scanf(\\\"%d\\\", &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?\\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 < … \\nlong long a[10100];\\nint main() {\\n int t;\\n int n;\\n scanf(\\\"%d\\\", &t);\\n while (t--) {\\n scanf(\\\"%d\\\", &n);\\n a[0] = 2;\\n int j = 0;\\n for (int i = 1; j < n; i++) {\\n if (i > a[j] && i % a[j] != 0) {\\n a[j + 1] = i;\\n j++;\\n }\\n }\\n for (int i = 0; i < n; i++) printf(\\\"%d \\\", a[i]);\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"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 \\ntemplate \\ninline T read() {\\n T r = 0, f = 0;\\n char c;\\n while (!isdigit(c = getchar())) f |= (c == '-');\\n while (isdigit(c)) r = (r << 1) + (r << 3) + (c ^ 48), c = getchar();\\n return f ? -r : r;\\n}\\ninline char getc() {\\n char c;\\n while (!isalpha(c = getchar()))\\n ;\\n return c;\\n}\\ntemplate \\ninline T abs(T a) {\\n return a < 0 ? -a : a;\\n}\\ntemplate \\ninline T min(T a, T b) {\\n return a < b ? a : b;\\n}\\ntemplate \\ninline T max(T a, T b) {\\n return a > b ? a : b;\\n}\\ninline long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }\\ninline long long lcm(long long a, long long b) { return a \\/ gcd(a, b) * b; }\\ninline long long qpow(long long a, int b, int MOD = 1000000007) {\\n long long ans = 1;\\n for (; b; b >>= 1) {\\n if (b & 1) (ans *= a) %= MOD;\\n (a *= a) %= MOD;\\n }\\n return ans;\\n}\\nstruct Z {\\n int x;\\n inline int val() const { return x; }\\n inline int inv() const { return qpow(x, 1000000007 - 2); }\\n Z(int x = 0) : x(x) {}\\n Z operator-() const {\\n return Z((1000000007 - x >= 1000000007 ? 1000000007 - x - 1000000007\\n : 1000000007 - x));\\n }\\n Z &operator+=(const Z &z) {\\n x = (x + z.x >= 1000000007 ? x + z.x - 1000000007 : x + z.x);\\n return *this;\\n }\\n Z &operator-=(const Z &z) {\\n x = (x - z.x < 0 ? x - z.x + 1000000007 : x - z.x);\\n return *this;\\n }\\n Z &operator*=(const Z &z) {\\n x = 1ll * x * z.x % 1000000007;\\n return *this;\\n }\\n Z &operator\\/=(const Z &z) {\\n x = 1ll * x * z.inv() % 1000000007;\\n return *this;\\n }\\n Z operator+(const Z &z) const {\\n return Z((x + z.x >= 1000000007 ? x + z.x - 1000000007 : x + z.x));\\n }\\n Z operator-(const Z &z) const {\\n return Z((x - z.x < 0 ? x - z.x + 1000000007 : x - z.x));\\n }\\n Z operator*(const Z &z) const { return Z(1ll * x * z.x % 1000000007); }\\n Z operator\\/(const Z &z) const { return Z(1ll * x * z.inv() % 1000000007); }\\n};\\ntemplate \\nstruct Hash {\\n struct E {\\n Tt v;\\n int w, nxt;\\n E() {}\\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...\\nSolve the task in CPP.\",\"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 W, H, x1, y1, x2, y2, w, h, ans = INT_MAX, a = 0;\\n cin >> W >> H >> x1 >> y1 >> x2 >> y2 >> w >> h;\\n if (x2 - x1 + w <= W) {\\n ans = min(ans, max(a, w - x1));\\n ans = min(ans, max(a, x2 - (W - w)));\\n }\\n if (y2 - y1 + h <= H) {\\n ans = min(ans, max(a, h - y1));\\n ans = min(ans, max(a, y2 - (H - h)));\\n }\\n if (ans == INT_MAX)\\n cout << -1;\\n else\\n cout << fixed << setprecision(9) << (double)ans;\\n cout << endl;\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Fedya studies in a gymnasium. Fedya's maths hometask is to calculate the following expression:\\n\\n(1n + 2n + 3n + 4n) mod 5\\n\\nfor given value of n. Fedya managed to complete the task. Can you? Note that given number n can be extremely large (e.g. it can exceed any integer type of your programming language).\\n\\nInput\\n\\nThe single line contains a single integer n (0 ≤ n ≤ 10105). The number doesn't contain any leading zeroes.\\n\\nOutput\\n\\nPrint the value of the expression without leading zeros.\\n\\nExamples\\n\\nInput\\n\\n4\\n\\n\\nOutput\\n\\n4\\n\\n\\nInput\\n\\n124356983594583453458888889\\n\\n\\nOutput\\n\\n0\\n\\nNote\\n\\nOperation x mod y means taking remainder after division x by y.\\n\\nNote to the first sample:\\n\\n\\n\\n\\nimp\",\"targets\":\"ort java.util.Scanner;\\n\\npublic class B {\\n\\n\\tstatic int N,M;\\n\\tpublic static void main(String[] args) {\\n\\t\\tScanner sc=new Scanner(System.in);\\n\\t\\tString s =sc.next();\\n\\t\\tint a=0;\\n\\t\\tif(s.length()>=5){\\n\\t\\t\\ta = Integer.parseInt(s.substring(s.length()-2));\\n\\t\\t} else {\\n\\t\\t\\ta = Integer.parseInt(s);\\n\\t\\t}\\n\\t\\tif(a%4==0){\\n\\t\\t\\tSystem.out.println(4);\\n\\t\\t} else {\\n\\t\\t\\tSystem.out.println(0);\\n\\t\\t}\\n\\t\\t\\n\\/\\/\\t\\tfor(int i=0;i<20;i++){\\n\\/\\/\\t\\t\\tlong b = 0;\\n\\/\\/\\t\\t\\tb += (long)Math.pow(1, i);\\n\\/\\/\\t\\t\\tb += (long)Math.pow(2, i);\\n\\/\\/\\t\\t\\tb += (long)Math.pow(3, i);\\n\\/\\/\\t\\t\\tb += (long)Math.pow(4, i);\\n\\/\\/\\t\\t\\tSystem.out.println(i+\\\" \\\"+(b%5));\\n\\/\\/\\t\\t}\\n\\t}\\n\\tstatic int NI(){\\n\\t\\ttry {\\n\\t\\t\\tint c=System.in.read(),r=0;\\n\\t\\t\\tfor(;c!='-'&&(c<'0'||'9'\\nusing namespace std;\\nconst int N = 3003, mod = 1e9 + 7;\\nint n, a[N], dp[N][N], f[N][N];\\nvector s[N];\\nvoid Main() {\\n cin >> n;\\n for (int i = (1); i <= (n); ++i) s[i].clear();\\n for (int i = (1); i <= (n); ++i) cin >> a[i], s[a[i]].push_back(i);\\n for (int i = (1); i <= (n); ++i)\\n for (int j = (i); j <= (n); ++j) dp[i][j] = f[i][j] = 1e9;\\n for (int i = (1); i <= (n); ++i)\\n for (int j = i; j <= n && a[j] == a[i]; j += 1) dp[i][j] = f[i][j] = 0;\\n for (int len = (2); len <= (n); ++len)\\n for (int l = (1); l <= (n - len + 1); ++l) {\\n int r = l + len - 1;\\n dp[l][r] = dp[l][r - 1] + (a[r] != a[r - 1]);\\n for (const int &t : s[a[r]])\\n if (l <= t && t < r) f[l][r] = min(f[l][r], f[l][t] + f[t + 1][r]);\\n dp[l][r] = min(dp[l][r], f[l][r]);\\n f[l][r] = min(f[l][r], dp[l][r - 1] + (a[r] != a[r - 1]));\\n }\\n cout << dp[1][n] << \\\"\\\\n\\\";\\n}\\nint main() {\\n ios::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n int T;\\n cin >> T;\\n while (T--) Main();\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A bitstring is a string consisting only of the characters 0 and 1. A bitstring is called k-balanced if every substring of size k of this bitstring has an equal amount of 0 and 1 characters (k\\/2 of each).\\n\\nYou are given an integer k and a string s which is composed only of characters 0, 1, and ?. You need to determine whether you can make a k-balanced bitstring by replacing every ? characters in s with either 0 or 1.\\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\\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 k (2 ≤ k ≤ n ≤ 3 ⋅ 10^5, k is even) — the length of the string and the parameter for a balanced bitstring.\\n\\nThe next line contains the string s (|s| = n). It is given that s consists of only 0, 1, and ?.\\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 YES if we can replace every ? in s with 0 or 1 such that the resulting bitstring is k-balanced, or NO if it is not possible.\\n\\nExample\\n\\nInput\\n\\n\\n9\\n6 4\\n100110\\n3 2\\n1?1\\n3 2\\n1?0\\n4 4\\n????\\n7 4\\n1?0??1?\\n10 10\\n11??11??11\\n4 2\\n1??1\\n4 4\\n?0?0\\n6 2\\n????00\\n\\n\\nOutput\\n\\n\\nYES\\nYES\\nNO\\nYES\\nYES\\nNO\\nNO\\nYES\\nNO\\n\\nNote\\n\\nFor the first test case, the string is already a 4-balanced bitstring.\\n\\nFor the second test case, the string can be transformed into 101.\\n\\nFor the fourth test case, the string can be transformed into 0110.\\n\\nFor the fifth test case, the string can be transformed into 1100110.\\nUsing python3 can you solve the prior task?\",\"targets\":\"t = int(input())\\n\\nwhile t:\\n t -= 1\\n n, k = input().split()\\n n, k = int(n), int(k)\\n s = input()\\n s = [c for c in s]\\n\\n # print(s)\\n\\n ans = True\\n\\n for i in range(0, k):\\n chars = set()\\n\\n for j in range(i, n, k):\\n chars.add(s[j])\\n\\n if ('1' in chars) and ('0' in chars):\\n ans = False\\n break\\n\\n if '1' in chars:\\n s[i] = '1'\\n\\n if '0' in chars:\\n s[i] = '0'\\n\\n if not ans:\\n print(\\\"NO\\\")\\n continue\\n\\n c0, c1, cq = 0, 0, 0\\n\\n for i in range(0, k):\\n c0 += s[i] == '0'\\n c1 += s[i] == '1'\\n cq += s[i] == '?'\\n\\n m, n = (cq + c1 - c0)\\/2, (cq - c1 + c0)\\/2\\n\\n if (m%1 or n%1):\\n print(\\\"NO\\\")\\n continue\\n\\n if m < 0 or n < 0:\\n print(\\\"NO\\\")\\n continue\\n\\n print(\\\"YES\\\")\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Anu has created her own function f: f(x, y) = (x | y) - y where | denotes the [bitwise OR operation](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#OR). For example, f(11, 6) = (11|6) - 6 = 15 - 6 = 9. It can be proved that for any nonnegative numbers x and y value of f(x, y) is also nonnegative. \\n\\nShe would like to research more about this function and has created multiple problems for herself. But she isn't able to solve all of them and needs your help. Here is one of these problems.\\n\\nA value of an array [a_1, a_2, ..., a_n] is defined as f(f(... f(f(a_1, a_2), a_3), ... a_{n-1}), a_n) (see notes). You are given an array with not necessarily distinct elements. How should you reorder its elements so that the value of the array is maximal possible?\\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 ≤ 10^9). Elements of the array are not guaranteed to be different.\\n\\nOutput\\n\\nOutput n integers, the reordering of the array with maximum value. If there are multiple answers, print any.\\n\\nExamples\\n\\nInput\\n\\n\\n4\\n4 0 11 6\\n\\n\\nOutput\\n\\n\\n11 6 4 0\\n\\nInput\\n\\n\\n1\\n13\\n\\n\\nOutput\\n\\n\\n13 \\n\\nNote\\n\\nIn the first testcase, value of the array [11, 6, 4, 0] is f(f(f(11, 6), 4), 0) = f(f(9, 4), 0) = f(9, 0) = 9.\\n\\n[11, 4, 0, 6] is also a valid answer.\\nSolve the task in PYTHON3.\",\"targets\":\"\\\"\\\"\\\"\\n Template written to be used by Python Programmers.\\n Use at your own risk!!!!\\n Owned by adi0311(rating - 1989 at CodeChef and 1435 at CodeForces).\\n\\\"\\\"\\\"\\n\\nfrom sys import *\\nfrom bisect import bisect_left as bl, bisect_right as br, bisect # Binary Search alternative\\nfrom math import *\\nfrom time import clock as cl # To get the running time of a program\\nfrom itertools import zip_longest as zl # zl(x, y) return [(x[0], y[0]), ...]\\nfrom itertools import groupby as gb # gb(x, y)\\nfrom itertools import combinations as comb # comb(x, y) return [all subsets of x with len == y]\\nfrom itertools import combinations_with_replacement as cwr\\nfrom collections import defaultdict as dd # defaultdict() Free of KeyError.\\nfrom collections import deque as dq # deque(list) append(), appendleft(), pop(), popleft() - O(1)\\nfrom collections import Counter as c # Counter(list) return a dict with {key: count}\\n# setrecursionlimit(2*pow(10, 6))\\n# stdin = open(\\\"input.txt\\\", \\\"r\\\")\\n# stdout = open(\\\"output.txt\\\", \\\"w\\\")\\nmod = pow(10, 9) + 7\\nmod2 = 998244353\\n# def data(): return stdin.readline().strip()\\n# def out(var): stdout.write(var)\\ndef data(): return input()\\ndef l(): return list(sp())\\ndef sl(): return list(ssp())\\ndef sp(): return map(int, data().split())\\ndef ssp(): return map(str, data().split())\\ndef l1d(n, val=0): return [val for i in range(n)]\\ndef l2d(n, m, val=0): return [[val for i in range(n)] for j in range(m)]\\ndef decimalToBinary(n):\\n return bin(n).replace(\\\"0b\\\", \\\"\\\")\\n\\n\\nn = int(data())\\narr = l()\\narr = sorted(arr)\\narr = arr[::-1]\\ndeci = list()\\nk = len(decimalToBinary(arr[0]))\\ndp = dd(int)\\nfor i in arr:\\n deci.append(decimalToBinary(i))\\nfor i in deci:\\n j = k-1\\n for m in i[::-1]:\\n if m == '1':\\n dp[j] += 1\\n j -= 1\\nres = -1\\nfor i in range(n):\\n ans = \\\"\\\"\\n p = k-1\\n for j in range(len(deci[i])-1, -1, -1):\\n if dp[p] == 1 and deci[i][j] == \\\"1\\\":\\n ans = \\\"1\\\" + ans\\n else:\\n ans = \\\"0\\\" + ans\\n p -= 1\\n if int(ans, 2) > res:\\n res =...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"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). \\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst double pi = 3.14159265358979323846;\\nconst int MOD = 1e9 + 7;\\nlong long mod_pow(long long a, long long n, long long mod) {\\n long long res = 1;\\n while (n) {\\n if (n & 1) res = (res * a) % mod;\\n n \\/= 2;\\n a = (a * a) % mod;\\n }\\n return res;\\n}\\nint gcd(int a, int b) {\\n if (!a) return b;\\n return gcd(b % a, a);\\n}\\nbool primenumber(int number) {\\n for (int i(2); i <= sqrt(number); ++i) {\\n if (number % i == 0) return false;\\n }\\n return true;\\n}\\nint main() {\\n long long t;\\n cin >> t;\\n while (t != 0) {\\n int a, b;\\n cin >> a >> b;\\n int sum = a + b;\\n if (a == 0 && b == 0) {\\n cout << \\\"0\\\" << endl;\\n } else if (a == b) {\\n cout << \\\"1\\\" << endl;\\n } else if (sum % 2 == 0) {\\n cout << \\\"2\\\" << endl;\\n } else {\\n cout << \\\"-1\\\" << endl;\\n }\\n t--;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"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 PYTHON3.\",\"targets\":\"n,f=map(int,input().split())\\nl=[0]*(n+1)\\nfor i in range(f):\\n x,y = map(int,input().split())\\n l[min(x,y)]+=1\\n \\nq=int(input())\\nans=0\\nfor i in range(1,n+1):\\n if(l[i]==0):\\n ans+=1\\nfor i in range(q):\\n temp=list(map(int,input().split()))\\n if(temp[0]==1):\\n l[min(temp[1],temp[2])]+=1\\n if(l[min(temp[1],temp[2])]==1):\\n ans-=1\\n elif(temp[0]==2 ):\\n l[min(temp[1],temp[2])]-=1\\n if(l[min(temp[1],temp[2])]==0):\\n ans+=1\\n else:\\n print(ans)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in PYTHON3?\\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\":\"import os,sys;from io import BytesIO, IOBase\\nBUFSIZE = 8192\\nclass FastIO(IOBase):\\n newlines = 0\\n def __init__(self, file):\\n self._fd = file.fileno();self.buffer = BytesIO();self.writable = \\\"x\\\" in file.mode or \\\"r\\\" not in file.mode;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:break\\n ptr = self.buffer.tell();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:b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE));self.newlines = b.count(b\\\"\\\\n\\\") + (not b);ptr = self.buffer.tell();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:os.write(self._fd, self.buffer.getvalue());self.buffer.truncate(0), self.buffer.seek(0)\\nclass IOWrapper(IOBase):\\n def __init__(self, file):\\n self.buffer = FastIO(file);self.flush = self.buffer.flush;self.writable = self.buffer.writable;self.write = lambda s: self.buffer.write(s.encode(\\\"ascii\\\"));self.read = lambda: self.buffer.read().decode(\\\"ascii\\\");self.readline = lambda: self.buffer.readline().decode(\\\"ascii\\\")\\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\\ntry:sys.stdin,sys.stdout=open('in.txt','r'),open('out.txt','w')\\nexcept:pass\\nii1=lambda:int(sys.stdin.readline().strip()) # for interger\\nis1=lambda:sys.stdin.readline().strip() # for str\\niia=lambda:list(map(int,sys.stdin.readline().strip().split())) # for List[int]\\nisa=lambda:sys.stdin.readline().strip().split() # for List[str]\\nmod=int(1e9 + 7);\\nfrom math import inf \\nfrom collections import defaultdict as dd\\n# from math import *\\n# from collections import *;\\n# from collections import deque as dq \\n# from string import ascii_lowercase,ascii_uppercase\\n# from functools import...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alexey recently held a programming contest for students from Berland. n students participated in a contest, i-th of them solved ai problems. Now he wants to award some contestants. Alexey can award the students with diplomas of three different degrees. Each student either will receive one diploma of some degree, or won't receive any diplomas at all. Let cntx be the number of students that are awarded with diplomas of degree x (1 ≤ x ≤ 3). The following conditions must hold:\\n\\n * For each x (1 ≤ x ≤ 3) cntx > 0; \\n * For any two degrees x and y cntx ≤ 2·cnty. \\n\\n\\n\\nOf course, there are a lot of ways to distribute the diplomas. Let bi be the degree of diploma i-th student will receive (or - 1 if i-th student won't receive any diplomas). Also for any x such that 1 ≤ x ≤ 3 let cx be the maximum number of problems solved by a student that receives a diploma of degree x, and dx be the minimum number of problems solved by a student that receives a diploma of degree x. Alexey wants to distribute the diplomas in such a way that:\\n\\n 1. If student i solved more problems than student j, then he has to be awarded not worse than student j (it's impossible that student j receives a diploma and i doesn't receive any, and also it's impossible that both of them receive a diploma, but bj < bi); \\n 2. d1 - c2 is maximum possible; \\n 3. Among all ways that maximize the previous expression, d2 - c3 is maximum possible; \\n 4. Among all ways that correspond to the two previous conditions, d3 - c - 1 is maximum possible, where c - 1 is the maximum number of problems solved by a student that doesn't receive any diploma (or 0 if each student is awarded with some diploma). \\n\\n\\n\\nHelp Alexey to find a way to award the contestants!\\n\\nInput\\n\\nThe first line contains one integer number n (3 ≤ n ≤ 3000).\\n\\nThe second line contains n integer numbers a1, a2, ..., an (1 ≤ ai ≤ 5000).\\n\\nOutput\\n\\nOutput n numbers. i-th number must be equal to the degree of diploma i-th contestant will receive (or - 1 if he doesn't receive any diploma).\\n\\nIf there are...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nconst int N = 3005;\\nint n, ST[N][14];\\nstruct pb {\\n int a, id, res;\\n} a[N];\\nbool cmpa(pb a, pb b) { return a.a > b.a; }\\nbool cmpid(pb a, pb b) { return a.id < b.id; }\\nint calc(int i) { return a[i].a - a[i + 1].a; }\\nint Query(int L, int R) {\\n if (L > R) return -1;\\n int d = log(R - L + 1) \\/ log(2.0);\\n int a = ST[L + (1 << d) - 1][d], b = ST[R][d];\\n return calc(a) > calc(b) ? a : b;\\n}\\nint main() {\\n scanf(\\\"%d\\\", &n);\\n for (int i = 1; i <= n; i++) scanf(\\\"%d\\\", &a[i]), a[i].id = i;\\n sort(a + 1, a + n + 1, cmpa);\\n a[n + 1].a = 0;\\n for (int i = 1; i <= n; i++) {\\n ST[i][0] = i;\\n for (int j = 1; j <= 12; j++) {\\n ST[i][j] = ST[i][j - 1];\\n if (i - (1 << (j - 1)) > 0 &&\\n calc(ST[i - (1 << (j - 1))][j - 1]) > calc(ST[i][j]))\\n ST[i][j] = ST[i - (1 << (j - 1))][j - 1];\\n }\\n }\\n int d1 = -1, d2 = -1, d3 = -1;\\n for (int i = 1; i <= n; i++)\\n for (int j = 1; i + j <= n; j++) {\\n if (i > 2 * j || j > 2 * i) continue;\\n int dd1 = i, dd2 = i + j,\\n dd3 = Query(dd2 + max((i + 1) \\/ 2, (j + 1) \\/ 2),\\n min(dd2 + min(i * 2, j * 2), n));\\n int k = dd3 - dd2;\\n if (dd3 == -1 || k < 1) continue;\\n if (d1 == -1 || calc(dd1) > calc(d1) ||\\n (calc(dd1) == calc(d1) &&\\n (calc(dd2) > calc(d2) ||\\n (calc(dd2) == calc(d2) && calc(dd3) > calc(d3)))))\\n d1 = dd1, d2 = dd2, d3 = dd3;\\n }\\n for (int i = 1; i <= d1; i++) a[i].res = 1;\\n for (int i = d1 + 1; i <= d2; i++) a[i].res = 2;\\n for (int i = d2 + 1; i <= d3; i++) a[i].res = 3;\\n for (int i = d3 + 1; i <= n; i++) a[i].res = -1;\\n sort(a + 1, a + n + 1, cmpid);\\n for (int i = 1; i <= n; i++) printf(\\\"%d \\\", a[i].res);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"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 java can you solve the prior task?\",\"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\\t\\tsieve();\\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 int k=sc.ni();\\n\\t String s=sc.next();\\n\\t HashSet set=new HashSet<>();\\n\\t set.add(1);set.add(4);set.add(6);set.add(8);set.add(9);\\n\\t for(int i=0;i>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 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...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"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.\\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 for (long long int k = 1; k <= t; k++) {\\n long long int n;\\n cin >> n;\\n string s;\\n cin >> s;\\n long long int ans = 0;\\n for (long long int i = 0; i < n; i++) {\\n if (s[i] != '0') {\\n ans = ans + (s[i] - '0');\\n if (i != n - 1) ans++;\\n }\\n }\\n cout << ans << \\\"\\\\n\\\";\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of n high school students numbered from 1 to n. Initially, each student i is on position i. Each student i is characterized by two numbers — a_i and b_i. Dissatisfaction of the person i equals the product of a_i by the number of people standing to the left of his position, add the product b_i by the number of people standing to the right of his position. Formally, the dissatisfaction of the student i, which is on the position j, equals a_i ⋅ (j-1) + b_i ⋅ (n-j).\\n\\nThe director entrusted Stas with the task: rearrange the people in the queue so that minimize the total dissatisfaction.\\n\\nAlthough Stas is able to solve such problems, this was not given to him. He turned for help to you.\\n\\nInput\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 10^5) — the number of people in the queue.\\n\\nEach of the following n lines contains two integers a_i and b_i (1 ≤ a_i, b_i ≤ 10^8) — the characteristic of the student i, initially on the position i.\\n\\nOutput\\n\\nOutput one integer — minimum total dissatisfaction which can be achieved by rearranging people in the queue.\\n\\nExamples\\n\\nInput\\n\\n\\n3\\n4 2\\n2 3\\n6 1\\n\\n\\nOutput\\n\\n\\n12\\n\\nInput\\n\\n\\n4\\n2 4\\n3 3\\n7 1\\n2 3\\n\\n\\nOutput\\n\\n\\n25\\n\\nInput\\n\\n\\n10\\n5 10\\n12 4\\n31 45\\n20 55\\n30 17\\n29 30\\n41 32\\n7 1\\n5 5\\n3 15\\n\\n\\nOutput\\n\\n\\n1423\\n\\nNote\\n\\nIn the first example it is optimal to put people in this order: (3, 1, 2). The first person is in the position of 2, then his dissatisfaction will be equal to 4 ⋅ 1+2 ⋅ 1=6. The second person is in the position of 3, his dissatisfaction will be equal to 2 ⋅ 2+3 ⋅ 0=4. The third person is in the position of 1, his dissatisfaction will be equal to 6 ⋅ 0+1 ⋅ 2=2. The total dissatisfaction will be 12.\\n\\nIn the second example, you need to put people in this order: (3, 2, 4, 1). The total dissatisfaction will be 25.\\nimpor\",\"targets\":\"t java.math.BigInteger;\\nimport java.util.*;\\nimport static java.lang.Math.*;\\n\\npublic class Test {\\n\\n\\n public static void main(String... args) {\\n Scanner in = new Scanner(System.in);\\n int n = in.nextInt();\\n long sum = 0, s2 = 0;\\n Pair a[] = new Pair[n];\\n\\n TreeSet h = new TreeSet<>();\\n\\n for(int i = 0; iLong.compare(p1.y, p2.y));\\n long dp[] = new long[n];\\n\\n for(int i = n-1; i>-1; i--){\\n dp[i] = a[n-i-1].y;\\n s2+=dp[i]*(i+1);\\n }\\n\\n System.out.print(sum+s2);\\n\\n }\\n\\n static class Pair{\\n long x, y;\\n Pair(long a, long b){\\n x = a; y = b;\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in PYTHON3?\\nYou 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.\",\"targets\":\"def getarray():\\n return list(map(int,input().split()))\\n\\ndef getints():\\n return map(int,input().split())\\n\\ndef getint():\\n return int(input())\\n\\n\\ndef solve():\\n n = getint()\\n s = input()\\n ops = 0 \\n # print(s)\\n for k in range(n-1):\\n i = s[k]\\n if int(i) > 0:\\n ops += int(i) + 1 \\n if int(s[-1]) > 0:\\n # print(s[-1])\\n ops += int(s[-1])\\n print(ops)\\n\\nfor t in range(getint()):\\n solve()\",\"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 strictly convex polygon with n vertices.\\n\\nYou will make k cuts that meet the following conditions: \\n\\n * each cut is a segment that connects two different nonadjacent vertices; \\n * two cuts can intersect only at vertices of the polygon. \\n\\n\\n\\nYour task is to maximize the area of the smallest region that will be formed by the polygon and those k cuts.\\n\\nInput\\n\\nThe first line contains two integers n, k (3 ≤ n ≤ 200, 0 ≤ k ≤ n-3).\\n\\nThe following n lines describe vertices of the polygon in anticlockwise direction. The i-th line contains two integers x_i, y_i (|x_i|, |y_i| ≤ 10^8) — the coordinates of the i-th vertex.\\n\\nIt is guaranteed that the polygon is convex and that no two adjacent sides are parallel.\\n\\nOutput\\n\\nPrint one integer: the maximum possible area of the smallest region after making k cuts multiplied by 2.\\n\\nExamples\\n\\nInput\\n\\n\\n8 4\\n-2 -4\\n2 -2\\n4 2\\n1 5\\n0 5\\n-4 4\\n-5 0\\n-5 -1\\n\\n\\nOutput\\n\\n\\n11\\n\\n\\nInput\\n\\n\\n6 3\\n2 -2\\n2 -1\\n1 2\\n0 2\\n-2 1\\n-1 0\\n\\n\\nOutput\\n\\n\\n3\\n\\nNote\\n\\nIn the first example, it's optimal to make cuts between the following pairs of vertices: \\n\\n * (-2, -4) and (4, 2), \\n * (-2, -4) and (1, 5), \\n * (-5, -1) and (1, 5), \\n * (-5, 0) and (0, 5). \\n\\n Points (-5, -1), (1, 5), (0, 5), (-5, 0) determine the smallest region with double area of 11. \\n\\nIn the second example, it's optimal to make cuts between the following pairs of vertices: \\n\\n * (2, -1) and (0, 2), \\n * (2, -1) and (1, 0), \\n * (-1, 0) and (0, 2). \\n\\n Points (2, -2), (2, -1), (-1, 0) determine one of the smallest regions with double area of 3.\",\"targets\":\"#include \\nusing namespace std;\\ninline long long read() {\\n long long x = 0, f = 1;\\n char c = getchar();\\n while ((c < '0' || c > '9') && (c != '-')) c = getchar();\\n if (c == '-') f = -1, c = getchar();\\n while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();\\n return x * f;\\n}\\nconst int N = 410;\\nint n, m;\\npair p[N];\\npair f[N][N];\\ninline pair operator-(pair a, pair b) {\\n return make_pair(a.first - b.first, a.second - b.second);\\n}\\ninline long long cross(pair a, pair b) {\\n return 1ll * a.first * b.second - 1ll * a.second * b.first;\\n}\\ninline long long S(pair x, pair y, pair z) {\\n return abs(cross(y - x, z - x));\\n}\\ninline bool check(long long x) {\\n for (int i = (1); i <= (n); i++)\\n for (int j = (i + 2); j <= (i + n - 1); j++) f[i][j] = make_pair(0, 0);\\n for (int len = (3); len <= (n); len++) {\\n for (int i = (1); i <= (n); i++) {\\n int j = i + len - 1;\\n for (int k = (i + 1); k <= (j - 1); k++) {\\n int a = f[i][k].first + f[k][j].first;\\n long long b = f[i][k].second + f[k][j].second + S(p[i], p[k], p[j]);\\n if (b >= x) b = 0, ++a;\\n if (a > f[i][j].first || (a == f[i][j].first && b > f[i][j].second))\\n f[i][j] = make_pair(a, b);\\n }\\n }\\n }\\n for (int i = (1); i <= (n); i++)\\n if (f[i][i + n - 1].first >= m + 1) return 1;\\n return 0;\\n}\\nint main() {\\n n = read(), m = read();\\n for (int i = (1); i <= (n); i++)\\n p[i].first = read(), p[i].second = read(), p[i + n] = p[i];\\n long long l = 1, r = 8e16, ret = 0;\\n while (l <= r) {\\n long long mid = l + r >> 1;\\n if (check(mid))\\n ret = mid, l = mid + 1;\\n else\\n r = mid - 1;\\n }\\n printf(\\\"%lld\\\\n\\\", ret);\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"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...\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\ntemplate \\nvoid _R(T &x) {\\n cin >> x;\\n}\\nvoid _R(int &x) { scanf(\\\"%d\\\", &x); }\\nvoid _R(long long &x) {\\n long long t;\\n scanf(\\\"%lld\\\", &t);\\n x = t;\\n}\\nvoid _R(unsigned long long &x) { scanf(\\\"%llu\\\", &x); }\\nvoid _R(double &x) { scanf(\\\"%lf\\\", &x); }\\nvoid _R(char &x) { scanf(\\\" %c\\\", &x); }\\nvoid _R(char *x) { scanf(\\\"%s\\\", x); }\\nvoid R() {}\\ntemplate \\nvoid R(T &head, U &...tail) {\\n _R(head);\\n R(tail...);\\n}\\ntemplate \\nvoid _W(const T &x) {\\n cout << x;\\n}\\nvoid _W(const int &x) { printf(\\\"%d\\\", x); }\\nvoid _W(const long long &x) {\\n long long t = x;\\n printf(\\\"%lld\\\", t);\\n}\\nvoid _W(const double &x) { printf(\\\"%.16f\\\", x); }\\nvoid _W(const char &x) { putchar(x); }\\nvoid _W(const char *x) { printf(\\\"%s\\\", x); }\\ntemplate \\nvoid _W(const pair &x) {\\n _W(x.first);\\n putchar(' ');\\n _W(x.second);\\n}\\ntemplate \\nvoid _W(const vector &x) {\\n for (auto i = x.begin(); i != x.end(); _W(*i++))\\n if (i != x.cbegin()) putchar(' ');\\n}\\nvoid W() {}\\ntemplate \\nvoid W(const T &head, const U &...tail) {\\n _W(head);\\n putchar(sizeof...(tail) ? ' ' : '\\\\n');\\n W(tail...);\\n}\\nconst int MOD = 1e9 + 7, mod = 998244353;\\nlong long qpow(long long a, long long b) {\\n long long res = 1;\\n a %= MOD;\\n assert(b >= 0);\\n for (; b; b >>= 1) {\\n if (b & 1) res = res * a % MOD;\\n a = a * a % MOD;\\n }\\n return res;\\n}\\nconst int MAXN = 2e4 + 10, MAXM = 4e4 + 10;\\nconst int INF = INT_MAX, SINF = 0x3f3f3f3f;\\nconst long long llINF = LLONG_MAX, SLINF = 0x3f3f3f3f3f3f3f3f;\\nconst int inv2 = (MOD + 1) \\/ 2;\\nconst int Lim = 1 << 20;\\nstruct MCMF {\\n const long long SLINF = 0x3f3f3f3f3f3f3f3f;\\n struct Edge {\\n int u, v;\\n long long flow, cap, cost;\\n int next;\\n };\\n int e_ptr = 1, S = 0, T = 1, head[MAXN + 10];\\n Edge E[(MAXM + 10) << 1];\\n long long MaxFlow = 0;\\n long long dist[MAXN + 10], MinCost = 0, delta;\\n int inq[MAXN + 10], done[MAXN + 10], n;\\n bool vis[MAXN + 10];\\n void add_edge(int u, int v, long long cap, long long cost) {\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"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\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int t;\\n long long int n;\\n cin >> t;\\n while (t--) {\\n cin >> n;\\n long long int ans;\\n if (n <= 6)\\n cout << 15 << endl;\\n else if (n <= 8)\\n cout << 20 << endl;\\n else if (n <= 10)\\n cout << 25 << endl;\\n else {\\n ans = 5 * ((n + 1) \\/ 2);\\n cout << ans << endl;\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"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 long long MAX_N = 3e5 + 7;\\nconst long long MOD = 998244353;\\nlong long n;\\nlong long deg[MAX_N], fac[MAX_N];\\nlong long f_pow(long long base, long long b, long long mod) {\\n long long res = 1;\\n while (b) {\\n if (b & 1) res = res * base % mod;\\n base = base * base % mod;\\n b >>= 1;\\n }\\n return res;\\n}\\nnamespace NTT {\\nconst long long MAX_N = 3e6 + 7;\\nconst long long MOD = 998244353;\\nconst long long G = 3;\\nlong long rev[MAX_N];\\nlong long f[MAX_N], g[MAX_N];\\nlong long n, m;\\nvector> p;\\nstruct Poly {\\n long long n;\\n vector p;\\n Poly(vector _p = {}, long long _n = 0) : n(_n) {\\n n = _p.size();\\n p.resize(n);\\n for (long long i = 0; i < n; ++i) p[i] = _p[i];\\n }\\n bool operator<(const Poly &a) const { return n > a.n; }\\n};\\nvoid ntt(long long *a, long long n, long long dft) {\\n for (long long i = 0; i < n; i++) {\\n if (i < rev[i]) swap(a[i], a[rev[i]]);\\n }\\n for (long long i = 1; i < n; i <<= 1) {\\n long long wn = f_pow(G, (MOD - 1) \\/ (i << 1), MOD);\\n if (dft < 0) wn = f_pow(wn, MOD - 2, MOD);\\n for (long long j = 0; j < n; j += (i << 1)) {\\n long long wnk = 1;\\n for (long long k = j; k < j + i; k++) {\\n long long a1 = a[k], a2 = a[k + i];\\n a[k] = (a1 + wnk * a2 % MOD) % MOD;\\n a[k + i] = (a1 - wnk * a2 % MOD) % MOD;\\n wnk = wnk * wn % MOD;\\n }\\n }\\n }\\n if (dft == -1) {\\n long long inv = f_pow(n, MOD - 2, MOD);\\n for (long long i = 0; i < n; i++) a[i] = a[i] * inv % MOD;\\n }\\n}\\nvector merge(const vector &F,\\n const vector &G) {\\n n = F.size() - 1, m = G.size() - 1;\\n long long N = 1, p = 0;\\n while (N < (m + n + 1)) N <<= 1, ++p;\\n for (long long i = 0; i < N; ++i) rev[i] = f[i] = g[i] = 0;\\n for (long long i = 0; i < N; ++i)\\n rev[i] = ((rev[i >> 1] >> 1) | ((i & 1) << (p - 1)));\\n for (long long i = 0; i <= n; ++i) f[i] = F[i];\\n for (long long i = 0; i <= m; ++i) g[i] = G[i];\\n ntt(f, N, 1), ntt(g, N, 1);\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"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 \\nconst double PI = 3.1415926535897932384626433;\\nconst int KL = 1e5 + 10;\\nconst long long MOD = 998244353;\\nusing namespace std;\\nint add(int x, int y) {\\n x += y;\\n if (x >= MOD) x -= MOD;\\n return x;\\n}\\nint mul(int x, int y) { return x * 1LL * y % MOD; }\\nint sub(int x, int y) {\\n x -= y;\\n if (x < 0) x += MOD;\\n return x;\\n}\\nint poow(int x, int y) {\\n if (y == 0) return 1;\\n int ret = poow(x, y \\/ 2);\\n ret = mul(ret, ret);\\n if (y & 1) ret = mul(ret, x);\\n return ret;\\n}\\nint fact[50], inv[50];\\nvoid init() {\\n fact[0] = 1;\\n for (int i = 1; i < 50; i++) {\\n fact[i] = mul(i, fact[i - 1]);\\n }\\n for (int i = 0; i < 50; i++) {\\n inv[i] = poow(fact[i], MOD - 2);\\n }\\n}\\nint C(int x, int y) {\\n if (y > x) return 0;\\n return mul(fact[x], mul(inv[y], inv[x - y]));\\n}\\nint n, cnt[23][27], pw[25];\\nchar str[KL];\\nstring t;\\nint dp[2][(1 << 23)];\\nint d[(1 << 23)], c[(1 << 23)];\\nvector> vec[26];\\nint main() {\\n pw[0] = 1;\\n for (int i = 1; i <= 23; i++) pw[i] = 2 * pw[i - 1];\\n scanf(\\\"%d\\\", &n);\\n for (int i = 0; i < n; i++) {\\n scanf(\\\"%s\\\", str);\\n t = str;\\n for (int j = 0; j < t.size(); j++) {\\n cnt[i][t[j] - 'a']++;\\n }\\n }\\n for (int i = 0; i < 26; i++) {\\n vec[i].push_back({-1, -1});\\n for (int j = 0; j < n; j++) {\\n vec[i].push_back({cnt[j][i], j});\\n }\\n sort(vec[i].begin(), vec[i].end());\\n }\\n dp[0][pw[n] - 1] = 1;\\n for (int i = 0; i < 26; i++) {\\n for (int mask = 1; mask < pw[n]; mask++) {\\n if (dp[0][mask] == 0) continue;\\n int nwmask = mask;\\n for (int j = 1; j < vec[i].size(); j++) {\\n dp[1][nwmask] =\\n add(dp[1][nwmask],\\n mul(vec[i][j].first - vec[i][j - 1].first, dp[0][mask]));\\n if ((nwmask & pw[vec[i][j].second])) nwmask ^= pw[vec[i][j].second];\\n }\\n }\\n for (int mask = 1; mask < pw[n]; mask++) {\\n dp[0][mask] = dp[1][mask];\\n dp[1][mask] = 0;\\n }\\n }\\n int sum = 0;\\n for (int mask = 0; mask < pw[n]; mask++)\\n c[mask] = dp[0][mask], sum = add(sum, c[mask]);\\n for (int j = 0; j <...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"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...\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"# from collections import defaultdict\\n# from functools import cmp_to_key\\n\\ndef solve(n, me, enemy):\\n cnt = 0\\n goal = [0]*n\\n for i in range(n):\\n if me[i] == '1':\\n if i > 0 and enemy[i-1] == '1' and goal[i-1] == 0:\\n goal[i-1] = 1\\n cnt += 1\\n elif enemy[i] == '0' and goal[i] == 0:\\n goal[i] = 1\\n cnt += 1\\n elif i < n-1 and enemy[i+1] == '1' and goal[i+1] == 0:\\n goal[i+1] = 1\\n cnt += 1\\n return cnt\\n\\ndef main():\\n ans = []\\n t = int(input())\\n for _ in range(t):\\n n = int(input())\\n enemy = input()\\n me = input()\\n ans.append(solve(n, me, enemy))\\n for a in ans:\\n print(a)\\n\\n\\nif __name__ == '__main__':\\n main()\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"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\\nSolve the task in PYTHON3.\",\"targets\":\"inp=lambda:map(int,input().split())\\nn,t=inp()\\n\\ns=list(input())\\n\\n\\nfor j in range(t):\\n i=0\\n while(i\\nusing namespace std;\\n\\n#ifdef DEBUG\\n#define display(x) cerr << #x << \\\" = \\\" << x << endl;\\n#define eprintf(...) fprintf(stderr, __VA_ARGS__)\\n#else\\n#define display(x) {}\\n#define eprintf(...) do {} while(0)\\n#endif\\n\\ntemplate bool chmin(T &a, const T &b) { return a > b ? a = b, true : false; }\\ntemplate bool chmax(T &a, const T &b) { return a < b ? a = b, true : false; }\\ntemplate\\nostream& operator << (ostream& out, const vector &v) {\\n\\tint n = v.size();\\n\\tout << \\\"{\\\";\\n\\tfor(int i = 0; i < n; ++i) {\\n\\t\\tif(i) out << \\\", \\\";\\n\\t\\tout << v[i];\\n\\t}\\n\\treturn out << \\\"}\\\";\\n}\\ntemplate\\nostream& operator << (ostream& out, const pair &v) {\\n\\treturn out << \\\"(\\\" << v.first << \\\", \\\" << v.second << \\\")\\\";\\n}\\n\\ntypedef long long LL;\\n\\nconst int maxN = (1 << 18) + 5;\\nconst LL P = 1000000007;\\nint n, h, p[maxN];\\n\\nLL val[maxN];\\n\\nLL prod = 1, sum = 0;\\nvoid mark(int u, LL coef) {\\n\\tcoef = coef * u % P;\\n\\tif(u < n \\/ 2) {\\n\\t\\tmark(u * 2, coef);\\n\\t\\tmark(u * 2 + 1, coef);\\n\\t} else {\\n\\t\\tint x = p[u];\\n\\t\\twhile(x) {\\n\\t\\t\\tval[x] = (val[x] + coef) % P;\\n\\t\\t\\tcoef = coef * x % P;\\n\\t\\t\\tx \\/= 2;\\n\\t\\t}\\n\\t}\\n}\\nLL count(int u, LL coef) {\\n\\tcoef = coef * u % P;\\n\\tif(u < n \\/ 2) {\\n\\t\\treturn (count(u * 2, coef) + count(u * 2 + 1, coef)) % P;\\n\\t} else {\\n\\t\\tint x = p[u];\\n\\t\\tLL sum = 0, ref = 0;\\n\\t\\twhile(x) {\\n\\t\\t\\t\\/\\/ ref = ref * x % P;\\n\\t\\t\\tcoef = coef * x % P;\\n\\t\\t\\t(sum += val[x] * coef - val[x] * coef % P * x % P * (x \\/ 2)) %= P;\\n\\t\\t\\t\\/\\/ (ref += (val[x] * coef - ref) % P * x) %= P;\\n\\t\\t\\tx \\/= 2;\\n\\t\\t}\\n\\t\\treturn (sum + P) % P;\\n\\t}\\n}\\nvoid unmark(int u) {\\n\\tif(u < n \\/ 2) {\\n\\t\\tunmark(u * 2);\\n\\t\\tunmark(u * 2 + 1);\\n\\t} else {\\n\\t\\tint x = p[u];\\n\\t\\twhile(x) {\\n\\t\\t\\tval[x] = 0;\\n\\t\\t\\tx \\/= 2;\\n\\t\\t}\\n\\t}\\n}\\nLL ans = 0;\\nvoid dfs(int u) {\\n\\tif(u < n \\/ 2) {\\n\\t\\tmark(u * 2, u);\\n\\t\\t(ans += count(u * 2 + 1, 1)) %= P;\\n\\t\\tunmark(u * 2);\\n\\t\\tdfs(u * 2);\\n\\t\\tdfs(u * 2 + 1);\\n\\t}\\n}\\n\\nint main() {\\n#ifndef LOCAL\\n\\tios::sync_with_stdio(false);\\n\\tcin.tie(0); cout.tie(0);\\n#endif\\n\\tcin >> h;\\n\\tn = (1 << h);\\n\\tfor(int i = n \\/ 2; i < n; ++i) cin >> p[i], p[i] += n \\/ 2 - 1;\\n\\tmemset(val, 0,...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"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\":\"def newFunction():\\n new_String = input()\\n print(new_String[0].upper() + new_String[1:len(new_String)])\\n\\nnewFunction()\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Allen is hosting a formal dinner party. 2n people come to the event in n pairs (couples). After a night of fun, Allen wants to line everyone up for a final picture. The 2n people line up, but Allen doesn't like the ordering. Allen prefers if each pair occupies adjacent positions in the line, as this makes the picture more aesthetic.\\n\\nHelp Allen find the minimum number of swaps of adjacent positions he must perform to make it so that each couple occupies adjacent positions in the line.\\n\\nInput\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 100), the number of pairs of people.\\n\\nThe second line contains 2n integers a_1, a_2, ..., a_{2n}. For each i with 1 ≤ i ≤ n, i appears exactly twice. If a_j = a_k = i, that means that the j-th and k-th people in the line form a couple.\\n\\nOutput\\n\\nOutput a single integer, representing the minimum number of adjacent swaps needed to line the people up so that each pair occupies adjacent positions.\\n\\nExamples\\n\\nInput\\n\\n4\\n1 1 2 3 3 2 4 4\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n3\\n1 1 2 2 3 3\\n\\n\\nOutput\\n\\n0\\n\\n\\nInput\\n\\n3\\n3 1 2 3 1 2\\n\\n\\nOutput\\n\\n3\\n\\nNote\\n\\nIn the first sample case, we can transform 1 1 2 3 3 2 4 4 → 1 1 2 3 2 3 4 4 → 1 1 2 2 3 3 4 4 in two steps. Note that the sequence 1 1 2 3 3 2 4 4 → 1 1 3 2 3 2 4 4 → 1 1 3 3 2 2 4 4 also works in the same number of steps.\\n\\nThe second sample case already satisfies the constraints; therefore we need 0 swaps.\\\":\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 105;\\nint n, a[N * 2], ans, m;\\nint main() {\\n scanf(\\\"%d\\\", &n), m = n << 1;\\n for (int i = 1; i <= m; i++) scanf(\\\"%d\\\", a + i);\\n for (int i = 1, j; i <= m; i++)\\n if (a[i]) {\\n for (j = i + 1; a[j] != a[i]; j++) ans += (a[j] > 0);\\n a[j] = 0;\\n }\\n printf(\\\"%d\\\\n\\\", ans);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"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.\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nconst int INF = 0x3f3f3f3f;\\nconst double eps = 1e-6;\\nconst double PI = acos(-1.0);\\ninline long long read() {\\n char ch;\\n long long x = 0;\\n bool f = true;\\n for (ch = getchar(); !isdigit(ch); ch = getchar())\\n if (ch == '-') f ^= f;\\n for (; isdigit(ch); ch = getchar()) x = (x << 3) + (x << 1) + ch - 48;\\n return f ? x : -x;\\n}\\nconst int N = 1010;\\nchar ch[N][N];\\nint h[N * N], e[2 * N * N], ne[2 * N * N], idx;\\nint ans[N][N];\\nvoid add(int a, int b) {\\n e[++idx] = b;\\n ne[idx] = h[a];\\n h[a] = idx;\\n}\\nvoid dfs(int u, int res) {\\n if (ans[u \\/ N][u % N]) return;\\n int t = (res == 1 ? 4 : 1);\\n ans[u \\/ N][u % N] = res;\\n for (int i = h[u]; i; i = ne[i]) {\\n int j = e[i];\\n dfs(j, t);\\n }\\n}\\nint z(int x, int y) { return x * N + y; }\\nint dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};\\nvoid solve() {\\n int n = read(), m = read();\\n for (int i = 1; i <= n; i++) cin >> (ch[i] + 1);\\n for (int i = 1; i <= n; i++)\\n for (int j = 1; j <= m; j++)\\n if (ch[i][j] == 'X') {\\n vector vs;\\n for (int k = 0; k < 4; k++) {\\n if (ch[i + dx[k]][j + dy[k]] != '.') continue;\\n vs.push_back(z(i + dx[k], j + dy[k]));\\n }\\n if (vs.size() % 2 == 1) return printf(\\\"NO\\\\n\\\"), void(0);\\n for (int k = 0; k < vs.size(); k += 2)\\n add(vs[k], vs[k + 1]), add(vs[k + 1], vs[k]);\\n }\\n for (int i = 1; i <= n; i++)\\n for (int j = 1; j <= m; j++) {\\n if (ch[i][j] == 'X') continue;\\n if (ans[i][j]) continue;\\n dfs(z(i, j), 1);\\n }\\n cout << \\\"YES\\\\n\\\";\\n for (int i = 1; i <= n; i++) {\\n for (int j = 1; j <= m; j++) {\\n if (ch[i][j] == 'X')\\n for (int k = 0; k < 4; k++)\\n if (ch[i + dx[k]][j + dy[k]] == '.')\\n ans[i][j] += ans[i + dx[k]][j + dy[k]];\\n cout << ans[i][j] << \\\" \\\";\\n }\\n cout << \\\"\\\\n\\\";\\n }\\n}\\nint main() {\\n int T = 1;\\n while (T--) solve();\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\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\":\"#include \\n#pragma GCC optimize(\\\"O3\\\")\\n#pragma GCC target(\\\"sse4\\\")\\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());\\nconst int MOD = 1000000007;\\nconst char nl = '\\\\n';\\nconst int MX = 100001;\\nvoid ap_99() {\\n freopen(\\\"input.txt\\\", \\\"r\\\", stdin);\\n freopen(\\\"output.txt\\\", \\\"w\\\", stdout);\\n}\\nvoid solve() {\\n int n;\\n cin >> n;\\n vector v;\\n long double sum = 0;\\n for (int i = 0; i < (n); i++) {\\n int t;\\n cin >> t;\\n sum += t;\\n v.push_back(t);\\n }\\n sort(v.begin(), v.end());\\n reverse(v.begin(), v.end());\\n long double avg = 0;\\n long double sum1 = 0;\\n long double sum2 = 0;\\n long double mx = -2000000001;\\n for (int i = 0; i < (n - 1); i++) {\\n sum1 += v[i];\\n sum2 = sum - sum1;\\n avg = sum1 \\/ (i + 1) + sum2 \\/ (n - i - 1);\\n if (avg > mx) {\\n mx = avg;\\n }\\n }\\n cout << fixed << setprecision(12) << mx;\\n cout << '\\\\n';\\n}\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n int T = 1;\\n cin >> T;\\n while (T--) {\\n solve();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA 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 java.io.*;\\nimport java.util.*;\\n\\npublic class new1{\\n\\t\\n\\t\\n\\tpublic static void main(String[] args) throws IOException{\\n \\tBufferedWriter output = new BufferedWriter(new OutputStreamWriter(System.out));\\n\\t\\tFastReader s = new FastReader();\\n\\t\\tint t = s.nextInt();\\n \\tfor(int z = 0; z < t; z++) {\\n \\t\\tint n = s.nextInt();\\n \\t\\tTreeSet ts= new TreeSet();\\n \\t\\tHashMap map = new HashMap();\\n \\t\\tint[] arr = new int[n + 1];\\n \\t\\tfor(int i = 0; i < n; i++) {\\n \\t\\t\\tint val = s.nextInt();\\n \\t\\t\\tif(val <= n && arr[val] == 0) arr[val] = 1;\\n \\t\\t\\telse {\\n\\t \\t\\t\\tif(ts.contains(val)) {\\n\\t \\t\\t\\t\\tmap.put(val, map.get(val) + 1);\\n\\t \\t\\t\\t}\\n\\t \\t\\t\\telse {\\n\\t \\t\\t\\t\\tts.add(val);\\n\\t \\t\\t\\t\\tmap.put(val, 1);\\n\\t \\t\\t\\t}\\n \\t\\t\\t}\\n \\t\\t}\\n \\t\\tboolean pos= true;\\n \\t\\tint count = 0;\\n \\t\\tfor(int i = 1; i <= n; i++) {\\n \\t\\t\\tif(arr[i] == 1) continue;\\n \\t\\t\\telse {\\n \\t\\t\\t\\tif(ts.last() <= 2 * i) {\\n \\t\\t\\t\\t\\tpos = false; break;\\n \\t\\t\\t\\t}\\n \\t\\t\\t\\tint v1 = ts.higher(2 * i);\\n \\t\\t\\t\\tint fr = map.get(v1) - 1;\\n \\t\\t\\t\\tif(fr == 0) {\\n \\t\\t\\t\\t\\tts.remove(v1);\\n \\t\\t\\t\\t\\tmap.remove(v1);\\n \\t\\t\\t\\t}\\n \\t\\t\\t\\telse map.put(v1, fr);\\n \\t\\t\\t\\tcount++;\\n \\t\\t\\t}\\n \\t\\t}\\n \\t\\tif(!ts.isEmpty()) pos= false;\\n \\t\\tif(!pos) System.out.println(-1);\\n \\t\\telse System.out.println(count);\\n \\t\\t\\n \\t\\t\\n \\t\\t\\n \\t\\t\\n \\t}\\n \\t\\/\\/output.flush();\\n\\n }\\n}\\n\\n\\nclass 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 \\n public int nextInt() {\\n return Integer.parseInt(next());\\n }\\n \\n long nextLong() {\\n return Long.parseLong(next());\\n }\\n \\n double nextDouble() {\\n return...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"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...\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.io.*;\\nimport java.util.Arrays;\\nimport java.util.Random;\\nimport java.util.StringTokenizer;\\n\\npublic class Main {\\n\\n static InputReader sc = new InputReader(System.in);\\n static PrintWriter out = new PrintWriter(System.out);\\n\\n public static void main(String[] args) throws IOException {\\n\\n int t = sc.nextInt();\\n\\n while (t-- > 0) {\\n int n = sc.nextInt();\\n\\n int[] A = new int[n];\\n\\n int operation = 0;\\n boolean odd = false;\\n boolean sorted = true;\\n\\n for (int i = 0; i < n; i++) {\\n A[i] = sc.nextInt();\\n if (i != 0) {\\n if (A[i - 1] > A[i]) {\\n sorted = false;\\n }\\n }\\n }\\n\\n while (!sorted) {\\n sorted = true;\\n for(int i = 0 ; i < n - 1; i++){\\n if(A[i] > A[i + 1]){\\n sorted = false;\\n if(odd && i % 2 == 1 || !odd && i % 2 == 0){\\n swap(i, i + 1, A);\\n }\\n }\\n\\n }\\n if(sorted){\\n break;\\n }\\n odd = !odd;\\n operation++;\\n }\\n out.println(operation);\\n\\n }\\n out.flush();\\n out.close();\\n }\\n static void swap(int i, int j, int[] A){\\n int temp = A[i];\\n A[i] = A[j];\\n A[j] = temp;\\n }\\n\\n static class InputReader {\\n BufferedReader reader;\\n StringTokenizer tokenizer;\\n\\n public InputReader(InputStream stream) {\\n reader = new BufferedReader(new InputStreamReader(stream), 32768);\\n tokenizer = null;\\n }\\n\\n\\n String next() {\\n while (tokenizer == null || !tokenizer.hasMoreTokens()) {\\n try {\\n tokenizer = new StringTokenizer(reader.readLine());\\n } catch (IOException e) {\\n throw new...\",\"language\":\"python\",\"split\":\"valid\",\"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...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\ntemplate \\nbool chmax(T &x, const T &y) {\\n return (x < y) ? (x = y, true) : false;\\n};\\ntemplate \\nbool chmin(T &x, const T &y) {\\n return (x > y) ? (x = y, true) : false;\\n};\\nconstexpr long long int MOD = 10;\\nconstexpr long long int INF = 2e18;\\nint main() {\\n int t;\\n cin >> t;\\n while (t--) {\\n int n, m;\\n cin >> n >> m;\\n vector p(n);\\n for (long long int i = 0; i < (n); i++) cin >> p[i], p[i]--;\\n vector cnt(n, 0);\\n for (long long int i = 0; i < (n); i++) {\\n cnt[(p[i] - i + n) % n]++;\\n }\\n vector ans;\\n for (long long int i = 0; i < (n); i++) {\\n if (n - cnt[i] <= m) {\\n ans.push_back((-i + n) % n);\\n } else if (n - cnt[i] <= m * 2) {\\n int x = 0;\\n vector q(n);\\n for (long long int j = 0; j < (n); j++) q[j] = p[(j - i + n) % n];\\n vector f(n, 0);\\n for (long long int j = 0; j < (n); j++) {\\n if (f[j] == 0) {\\n int now = j;\\n while (f[now] == 0) {\\n f[now] = 1;\\n now = q[now];\\n x++;\\n }\\n x--;\\n }\\n }\\n if (x <= m) ans.push_back((-i + n) % n);\\n }\\n }\\n sort(ans.begin(), ans.end());\\n cout << ans.size();\\n for (auto i : ans) cout << \\\" \\\" << i;\\n cout << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"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 PYTHON3.\",\"targets\":\"import math\\nt = int(input())\\nfor test in range(t):\\n\\tn = int(input())\\n\\ta = input()\\n\\tb = input()\\n\\tif(a == b):\\n\\t\\tprint(0)\\n\\telse:\\n\\t\\tonesA = 0\\n\\t\\tonesB = 0\\n\\t\\tsame = 0\\n\\t\\tdifferent = 0\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif(a[i]=='1'):\\n\\t\\t\\t\\tonesA += 1\\n\\t\\t\\tif(b[i]=='1'):\\n\\t\\t\\t\\tonesB += 1\\n\\t\\t\\tif(a[i]=='1' and b[i]=='1'):\\n\\t\\t\\t\\tsame += 1\\n\\t\\t\\tif((a[i]=='1' and b[i]=='0') or (a[i]=='0' and b[i]=='1')):\\n\\t\\t\\t\\tdifferent += 1\\n\\t\\tbest = float('inf')\\n\\t\\tif(onesA==onesB):\\n\\t\\t\\tbest = min(best,2*(onesA-same))\\n\\t\\tif(onesB==n-onesA+1):\\n\\t\\t\\tif(same>0):\\n\\t\\t\\t\\tbest = min(best,2*(same-1) + 1)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tbest = min(best,1)\\n\\t\\tif(onesA==n-onesB+1):\\n\\t\\t\\tif(same>0):\\n\\t\\t\\t\\tbest = min(best,2*(same-1) + 1)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tbest = min(best,1)\\n\\t\\t\\n\\t\\tif(best == float('inf')):\\n\\t\\t\\tprint(-1)\\n\\t\\telse:\\n\\t\\t\\tprint(best)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Let's arrange a deck of cards. Your task is to sort totally n cards. A card consists of a part of a suit (S, H, C or D) and an number. Write a program which sorts such cards based on the following pseudocode:\\n\\n\\nPartition(A, p, r)\\n1 x = A[r]\\n2 i = p-1\\n3 for j = p to r-1\\n4 do if A[j] <= x\\n5 then i = i+1\\n6 exchange A[i] and A[j]\\n7 exchange A[i+1] and A[r]\\n8 return i+1\\n\\n\\nQuicksort(A, p, r)\\n1 if p < r\\n2 then q = Partition(A, p, r)\\n3 run Quicksort(A, p, q-1)\\n4 run Quicksort(A, q+1, r)\\n\\n\\nHere, A is an array which represents a deck of cards and comparison operations are performed based on the numbers.\\n\\nYour program should also report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).\\n\\nConstraints\\n\\n* 1 ≤ n ≤ 100,000\\n* 1 ≤ the number of a card ≤ 109\\n* There are no identical card in the input\\n\\nInput\\n\\nThe first line contains an integer n, the number of cards.\\n\\nn cards are given in the following lines. Each card is given in a line and represented by a pair of a character and an integer separated by a single space.\\n\\nOutput\\n\\nIn the first line, print the stability (\\\"Stable\\\" or \\\"Not stable\\\") of this output.\\n\\nIn the following lines, print the arranged cards in the same manner of that of the input.\\n\\nExamples\\n\\nInput\\n\\n6\\nD 3\\nH 2\\nD 1\\nS 3\\nD 2\\nC 1\\n\\n\\nOutput\\n\\nNot stable\\nD 1\\nC 1\\nD 2\\nH 2\\nD 3\\nS 3\\n\\n\\nInput\\n\\n2\\nS 1\\nH 1\\n\\n\\nOutput\\n\\nStable\\nS 1\\nH 1\\\":\",\"targets\":\"#include \\n#include \\nusing namespace std;\\n\\nstruct Card{\\n char a;\\n int b;\\n};\\n\\nbool compare_as_ints(Card i, Card j)\\n{\\n return (i.b>n;\\n\\n Card A[100000], B[100000];\\n for(int i=0; i>A[i].a>>A[i].b;\\n B[i]=A[i];\\n }\\n\\n quickSort(A, 0, n-1);\\n stable_sort(B, B+n, compare_as_ints);\\n int checker=0;\\n for(int i=0; i\\n\\nusing namespace std;\\n\\nusing int64 = long long;\\n\\nint main() {\\n int X, Y;\\n cin >> X >> Y;\\n cout << abs(X - Y) << endl;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Polycarp is very fond of playing the game Minesweeper. Recently he found a similar game and there are such rules.\\n\\nThere are mines on the field, for each the coordinates of its location are known (x_i, y_i). Each mine has a lifetime in seconds, after which it will explode. After the explosion, the mine also detonates all mines vertically and horizontally at a distance of k (two perpendicular lines). As a result, we get an explosion on the field in the form of a \\\"plus\\\" symbol ('+'). Thus, one explosion can cause new explosions, and so on.\\n\\nAlso, Polycarp can detonate anyone mine every second, starting from zero seconds. After that, a chain reaction of explosions also takes place. Mines explode instantly and also instantly detonate other mines according to the rules described above.\\n\\nPolycarp wants to set a new record and asks you to help him calculate in what minimum number of seconds all mines can be detonated.\\n\\nInput\\n\\nThe first line of the input contains an integer t (1 ≤ t ≤ 10^4) — the number of test cases in the test.\\n\\nAn empty line is written in front of each test suite.\\n\\nNext comes a line that contains integers n and k (1 ≤ n ≤ 2 ⋅ 10^5, 0 ≤ k ≤ 10^9) — the number of mines and the distance that hit by mines during the explosion, respectively.\\n\\nThen n lines follow, the i-th of which describes the x and y coordinates of the i-th mine and the time until its explosion (-10^9 ≤ x, y ≤ 10^9, 0 ≤ timer ≤ 10^9). It is guaranteed that all mines have different coordinates.\\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\\nPrint t lines, each of the lines must contain the answer to the corresponding set of input data — the minimum number of seconds it takes to explode all the mines.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n\\n5 0\\n0 0 1\\n0 1 4\\n1 0 2\\n1 1 3\\n2 2 9\\n\\n5 2\\n0 0 1\\n0 1 4\\n1 0 2\\n1 1 3\\n2 2 9\\n\\n6 1\\n1 -1 3\\n0 -1 9\\n0 1 7\\n-1 0 1\\n-1 1 9\\n-1 -1 7\\n\\n\\nOutput\\n\\n\\n2\\n1\\n0\\n\\nNote\\n\\n Picture from examples\\n\\nFirst example: \\n\\n * 0 second: we explode a mine at the cell (2, 2), it does not...\",\"targets\":\"#include \\nusing namespace std;\\nconst long long mod = 1e9 + 7;\\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 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 mod_add(long long a, long long b) {\\n a = a % mod;\\n b = b % mod;\\n return (((a + b) % mod) + 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 ceil_div(long long a, long long b) {\\n return a % b == 0 ? a \\/ b : a \\/ b + 1;\\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}\\nvector parent, rnk;\\nvoid make_set(long long n) {\\n long long i;\\n rnk.assign(n + 1, 0);\\n parent.assign(n + 1, 0);\\n for (i = 1; i <= n; i++) {\\n parent[i] = i;\\n }\\n}\\nlong long find_set(long long u) {\\n if (parent[u] == u) return u;\\n return parent[u] = find_set(parent[u]);\\n}\\nbool union_set(long long u, long long v) {\\n u = find_set(u);\\n v = find_set(v);\\n if (u == v) return false;\\n if (rnk[u] < rnk[v]) swap(u, v);\\n parent[v] = u;\\n if (rnk[v] == rnk[u]) rnk[u]++;\\n return true;\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n long long t, n, i, j, ans, temp, sum, k;\\n string sans;\\n t = 1;\\n cin >> t;\\n while (t--) {\\n sans = \\\"NO\\\";\\n ans = temp = sum = 0;\\n cin >> n >> k;\\n make_set(n);\\n map>> x_to_y;\\n map>> y_to_x;\\n vector x(n + 1, 0), y(n + 1, 0), timer(n + 1, 0);\\n for (i = 1; i <= n; i++) {\\n cin >> x[i] >> y[i] >> timer[i];\\n x_to_y[x[i]].insert({y[i], i});\\n y_to_x[y[i]].insert({x[i], i});\\n }\\n for (i = 1; i <= n; i++) {\\n auto it = x_to_y[x[i]].upper_bound(make_pair(y[i], 1000000000000000005));\\n if (it != x_to_y[x[i]].end() and...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"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 PYTHON3.\",\"targets\":\"t=int(input())\\nfor i in range(t):\\n s=input()\\n l=len(s)\\n if l%2==0:\\n if s[0:l\\/\\/2]==s[l\\/\\/2:l]:\\n print('YES')\\n else:\\n print(\\\"NO\\\")\\n else:\\n print('NO')\",\"language\":\"python\",\"split\":\"test\",\"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...\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nconst int M = 2 * 1e5 + 10;\\nstruct node {\\n int zms[27], maxn, len;\\n char gxM;\\n char mxC;\\n};\\nint nw;\\nbool cmp(node x, node y) {\\n return 2 * x.zms[nw] - x.len > 2 * y.zms[nw] - y.len;\\n}\\nnode a[2 * M + 10];\\nint n;\\nint zmM[27];\\nint mxS[27];\\nint main() {\\n int t;\\n scanf(\\\"%d\\\", &t);\\n while (t--) {\\n int n;\\n scanf(\\\"%d\\\", &n);\\n memset(zmM, 0, sizeof zmM);\\n for (int i = 1; i <= n; i++) {\\n for (int j = 0; j < 27; j++) a[i].zms[j] = 0;\\n a[i].maxn = 0;\\n a[i].gxM = '\\\\0';\\n }\\n char ch[2 * M + 1];\\n for (int i = 1; i <= n; i++) {\\n scanf(\\\"%s\\\", ch + 1);\\n a[i].len = strlen(ch + 1);\\n for (int j = 1; j <= a[i].len; j++) {\\n a[i].zms[ch[j] - 'a']++;\\n if (a[i].maxn < a[i].zms[ch[j] - 'a']) {\\n a[i].maxn = a[i].zms[ch[j] - 'a'];\\n a[i].mxC = ch[j] - 'a';\\n }\\n if (a[i].zms[ch[j] - 'a'] * 2 > a[i].len) a[i].gxM = ch[j];\\n }\\n if (a[i].gxM != '\\\\0') {\\n zmM[a[i].gxM - 'a']++;\\n }\\n }\\n int summ = 0;\\n int ans = 0;\\n int maxn = 0;\\n for (nw = 0; nw < 26; nw++) {\\n summ = 0;\\n ans = 0;\\n if (zmM[nw] == 0) continue;\\n sort(a + 1, a + n + 1, cmp);\\n for (int i = 1; i <= n; i++) {\\n summ += (2 * a[i].zms[nw] - a[i].len);\\n if (summ <= 0) break;\\n ans++;\\n }\\n maxn = max(ans, maxn);\\n }\\n printf(\\\"%d\\\\n\\\", maxn);\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nBob 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}...\",\"targets\":\"#include \\nusing namespace std;\\nmap, int> mp;\\nqueue > q, q1;\\nint read() {\\n char ch = getchar();\\n int f = 0, x = 1;\\n while (ch < '0' || ch > '9') {\\n if (ch == '-') x = -1;\\n ch = getchar();\\n }\\n while (ch >= '0' && ch <= '9') {\\n f = (f << 1) + (f << 3) + ch - '0';\\n ch = getchar();\\n }\\n return f * x;\\n}\\nint a[1005], b[2005], c[2005], d[2005];\\nint main() {\\n int n = read();\\n for (int i = 1; i <= n; i++) {\\n a[i] = read(), b[i] = read();\\n }\\n for (int i = 1; i <= n; i++) {\\n int x = read(), y = read();\\n mp[pair(x, y)] = i;\\n c[i] = x;\\n d[i] = y;\\n }\\n for (int i = 1; i <= n; i++) {\\n int plax = a[1] + c[i], play = b[1] + d[i];\\n bool ac = 1;\\n for (int j = 1; j <= n; j++) {\\n if (!mp[pair(plax - a[j], play - b[j])]) {\\n ac = 0;\\n break;\\n }\\n }\\n if (ac) {\\n cout << plax << \\\" \\\" << play << endl;\\n return 0;\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA 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\":\"import java.util.*;\\nimport java.io.*;\\n\\npublic class s {\\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 public static void main(String[] args) throws IOException{\\n FastReader fast = new FastReader();\\n int t = fast.nextInt();\\n while(t-->0){\\n int n = fast.nextInt();\\n int k = fast.nextInt();\\n int[] arr = new int[n];\\n for(int i = 0 ; i < n ; i++)\\n arr[i] = fast.nextInt();\\n HashMap> map = new HashMap<>();\\n for(int i = 0 ; i());\\n map.get(arr[i]).add(i);\\n\\n }\\n\\n int[] ans = new int[n];\\n\\n ArrayList remaining = new ArrayList<>();\\n\\n for(Map.Entry> pair:map.entrySet())\\n {\\n if(pair.getValue().size()>=k)\\n {\\n for(int i = 1;i <= k; i++)\\n {\\n ans[pair.getValue().get(i-1)] = i;\\n }\\n }else{\\n remaining.addAll(pair.getValue());\\n }\\n }\\n\\n int size = remaining.size()%k;\\n for(int i = 0 ;imaxSq:\\n maxSq=sq\\n maxX=start\\n maxY=i-1\\nprint(maxSq, s[maxX:maxY], sep='\\\\n')\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"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\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\n\\npublic class G {\\n public static short[] getCnt(char[] s) {\\n short[] cnt = new short[26];\\n for (char c : s) {\\n cnt[c - 'a']++;\\n }\\n return cnt;\\n }\\n\\n static final int mod = 998244353;\\n\\n static int[] ans;\\n static int[] exact;\\n\\n\\/\\/ public static long getAns(int mask, int i) {\\n\\/\\/ if (i == -1) {\\n\\/\\/ int k = Integer.bitCount(mask);\\n\\/\\/ return ((k % 2 == 1 ? 1 : -1) * exact[mask]);\\n\\/\\/ }\\n\\/\\/ return ans[mask][i];\\n\\/\\/ }\\n\\n public static void main(String[] args) throws Exception {\\n Scanner sc = new Scanner(System.in);\\n PrintWriter pw = new PrintWriter(System.out);\\n int n = sc.nextInt();\\n char[][] s = new char[n][];\\n short[][] cnt = new short[1 << n][];\\n for (int i = 0; i < n; i++) {\\n s[i] = sc.next().toCharArray();\\n cnt[1 << i] = getCnt(s[i]);\\n }\\n exact = new int[1 << n];\\n for (int i = 1; i < 1 << n; i++) {\\n int lsb = i & -i;\\n if (lsb == i)\\n continue;\\n int nxt = i ^ lsb;\\n cnt[i] = cnt[lsb].clone();\\n for (int j = 0; j < 26; j++) {\\n cnt[i][j] = (short) Math.min(cnt[i][j], cnt[nxt][j]);\\n }\\n }\\n for (int i = 1; i < 1 << n; i++) {\\n exact[i] = 1;\\n for (int j = 0; j < 26; j++) {\\n exact[i] = (int) (1l * exact[i] * (cnt[i][j] + 1) % mod);\\n }\\n }\\n cnt = null;\\n ans = new int[1 << n];\\n for (int i = 0; i < (1 << n); ++i) {\\n ans[i] = (Integer.bitCount(i) % 2 == 0 ? -1 : 1) * exact[i];\\n }\\n for (int i = 0; i < n; ++i)\\n for (int mask = 0; mask < (1 << n); ++mask) {\\n if ((mask & (1 << i)) != 0) {\\n ans[mask] = (ans[mask] + ans[mask ^ (1 << i)]) % mod;\\n }\\n }\\n\\/\\/ for (int mask = 0; mask < (1 << n); ++mask) {\\n\\/\\/ for (int i = 0; i <...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nOne day in the IT lesson Anna and Maria learned about the lexicographic order.\\n\\nString x is lexicographically less than string y, if either x is a prefix of y (and x ≠ y), or there exists such i (1 ≤ i ≤ min(|x|, |y|)), that xi < yi, and for any j (1 ≤ j < i) xj = yj. Here |a| denotes the length of the string a. The lexicographic comparison of strings is implemented by operator < in modern programming languages​​.\\n\\nThe teacher gave Anna and Maria homework. She gave them a string of length n. They should write out all substrings of the given string, including the whole initial string, and the equal substrings (for example, one should write out the following substrings from the string \\\"aab\\\": \\\"a\\\", \\\"a\\\", \\\"aa\\\", \\\"ab\\\", \\\"aab\\\", \\\"b\\\"). The resulting strings should be sorted in the lexicographical order. The cunning teacher doesn't want to check all these strings. That's why she said to find only the k-th string from the list. Help Anna and Maria do the homework.\\n\\nInput\\n\\nThe first line contains a non-empty string that only consists of small Latin letters (\\\"a\\\"-\\\"z\\\"), whose length does not exceed 105. The second line contains the only integer k (1 ≤ k ≤ 105).\\n\\nOutput\\n\\nPrint the string Anna and Maria need — the k-th (in the lexicographical order) substring of the given string. If the total number of substrings is less than k, print a string saying \\\"No such line.\\\" (without the quotes).\\n\\nExamples\\n\\nInput\\n\\naa\\n2\\n\\n\\nOutput\\n\\na\\n\\n\\nInput\\n\\nabc\\n5\\n\\n\\nOutput\\n\\nbc\\n\\n\\nInput\\n\\nabab\\n7\\n\\n\\nOutput\\n\\nb\\n\\nNote\\n\\nIn the second sample before string \\\"bc\\\" follow strings \\\"a\\\", \\\"ab\\\", \\\"abc\\\", \\\"b\\\".\",\"targets\":\"#include \\nusing namespace std;\\nchar T[100010];\\nint n;\\nint RA[100010], tempRA[100010];\\nint SA[100010], tempSA[100010];\\nint c[100010];\\nvoid countingSort(int k) {\\n int i, sum, maxi = max(300, n);\\n memset(c, 0, sizeof c);\\n for (i = 0; i < n; i++) c[i + k < n ? RA[i + k] : 0]++;\\n for (i = sum = 0; i < maxi; i++) {\\n int t = c[i];\\n c[i] = sum;\\n sum += t;\\n }\\n for (i = 0; i < n; i++)\\n tempSA[c[SA[i] + k < n ? RA[SA[i] + k] : 0]++] = SA[i];\\n for (i = 0; i < n; i++) SA[i] = tempSA[i];\\n}\\nvoid constructSA() {\\n int i, k, r;\\n for (i = 0; i < n; i++) RA[i] = T[i];\\n for (i = 0; i < n; i++) SA[i] = i;\\n for (k = 1; k < n; k <<= 1) {\\n countingSort(k);\\n countingSort(0);\\n tempRA[SA[0]] = r = 0;\\n for (i = 1; i < n; i++)\\n tempRA[SA[i]] =\\n (RA[SA[i]] == RA[SA[i - 1]] && RA[SA[i] + k] == RA[SA[i - 1] + k])\\n ? r\\n : ++r;\\n for (i = 0; i < n; i++) RA[i] = tempRA[i];\\n if (RA[SA[n - 1]] == n - 1) break;\\n }\\n}\\nint Phi[100010];\\nint PLCP[100010];\\nint LCP[100010];\\nvoid computeLCP() {\\n int i, L;\\n Phi[SA[0]] = -1;\\n for (i = 1; i < n; i++) Phi[SA[i]] = SA[i - 1];\\n for (i = L = 0; i < n; i++) {\\n if (Phi[i] == -1) {\\n PLCP[i] = 0;\\n continue;\\n }\\n while (T[i + L] == T[Phi[i] + L]) L++;\\n PLCP[i] = L;\\n L = max(L - 1, 0);\\n }\\n for (i = 0; i < n; i++) LCP[i] = PLCP[SA[i]];\\n}\\nint main() {\\n n = (int)strlen(gets(T));\\n long long v = n;\\n T[n++] = '$';\\n long long k;\\n cin >> k;\\n if (k > (v * (v - 1) \\/ 2) + v) {\\n cout << \\\"No such line.\\\";\\n }\\n constructSA();\\n computeLCP();\\n int r = 0;\\n int a[100000 + 2];\\n memset(a, 0, sizeof a);\\n for (int i = 1; i < n; i++) {\\n for (int j = a[i]; j + SA[i] < n - 1; j++) {\\n int l = i;\\n while (true) {\\n r++;\\n a[l]++;\\n if (r == k) {\\n for (int k = SA[l]; k <= SA[l] + j; k++) cout << T[k];\\n return 0;\\n }\\n if (l < n - 1 && LCP[l + 1] >= j + 1) {\\n l++;\\n } else\\n break;\\n }\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of n high school students numbered from 1 to n. Initially, each student i is on position i. Each student i is characterized by two numbers — a_i and b_i. Dissatisfaction of the person i equals the product of a_i by the number of people standing to the left of his position, add the product b_i by the number of people standing to the right of his position. Formally, the dissatisfaction of the student i, which is on the position j, equals a_i ⋅ (j-1) + b_i ⋅ (n-j).\\n\\nThe director entrusted Stas with the task: rearrange the people in the queue so that minimize the total dissatisfaction.\\n\\nAlthough Stas is able to solve such problems, this was not given to him. He turned for help to you.\\n\\nInput\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 10^5) — the number of people in the queue.\\n\\nEach of the following n lines contains two integers a_i and b_i (1 ≤ a_i, b_i ≤ 10^8) — the characteristic of the student i, initially on the position i.\\n\\nOutput\\n\\nOutput one integer — minimum total dissatisfaction which can be achieved by rearranging people in the queue.\\n\\nExamples\\n\\nInput\\n\\n\\n3\\n4 2\\n2 3\\n6 1\\n\\n\\nOutput\\n\\n\\n12\\n\\nInput\\n\\n\\n4\\n2 4\\n3 3\\n7 1\\n2 3\\n\\n\\nOutput\\n\\n\\n25\\n\\nInput\\n\\n\\n10\\n5 10\\n12 4\\n31 45\\n20 55\\n30 17\\n29 30\\n41 32\\n7 1\\n5 5\\n3 15\\n\\n\\nOutput\\n\\n\\n1423\\n\\nNote\\n\\nIn the first example it is optimal to put people in this order: (3, 1, 2). The first person is in the position of 2, then his dissatisfaction will be equal to 4 ⋅ 1+2 ⋅ 1=6. The second person is in the position of 3, his dissatisfaction will be equal to 2 ⋅ 2+3 ⋅ 0=4. The third person is in the position of 1, his dissatisfaction will be equal to 6 ⋅ 0+1 ⋅ 2=2. The total dissatisfaction will be 12.\\n\\nIn the second example, you need to put people in this order: (3, 2, 4, 1). The total dissatisfaction will be 25.\\\":\",\"targets\":\"#include \\nusing namespace std;\\nbool op(pair &x, pair &y) {\\n return (x.first - x.second > y.first - y.second);\\n}\\nint main() {\\n int n;\\n long long cnt = 0;\\n pair p[100005];\\n cin >> n;\\n n--;\\n for (int i = 0; i <= n; i++) cin >> p[i].first >> p[i].second;\\n sort(p, p + n + 1, op);\\n for (int i = 0; i <= n; i++)\\n cnt += 1LL * i * p[i].first + 1LL * (n - i) * p[i].second;\\n cout << cnt << \\\"\\\\n\\\";\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Another dull quarantine day was going by when BThero decided to start researching matrices of size n × m. The rows are numerated 1 through n from top to bottom, and the columns are numerated 1 through m from left to right. The cell in the i-th row and j-th column is denoted as (i, j).\\n\\nFor each cell (i, j) BThero had two values: \\n\\n 1. The cost of the cell, which is a single positive integer. \\n 2. The direction of the cell, which is one of characters L, R, D, U. Those characters correspond to transitions to adjacent cells (i, j - 1), (i, j + 1), (i + 1, j) or (i - 1, j), respectively. No transition pointed outside of the matrix. \\n\\n\\n\\nLet us call a cell (i_2, j_2) reachable from (i_1, j_1), if, starting from (i_1, j_1) and repeatedly moving to the adjacent cell according to our current direction, we will, sooner or later, visit (i_2, j_2). \\n\\nBThero decided to create another matrix from the existing two. For a cell (i, j), let us denote S_{i, j} as a set of all reachable cells from it (including (i, j) itself). Then, the value at the cell (i, j) in the new matrix will be equal to the sum of costs of all cells in S_{i, j}. \\n\\nAfter quickly computing the new matrix, BThero immediately sent it to his friends. However, he did not save any of the initial matrices! Help him to restore any two valid matrices, which produce the current one.\\n\\nInput\\n\\nThe first line of input file contains a single integer T (1 ≤ T ≤ 100) denoting the number of test cases. The description of T test cases follows.\\n\\nFirst line of a test case contains two integers n and m (1 ≤ n ⋅ m ≤ 10^5).\\n\\nEach of the following n lines contain exactly m integers — the elements of the produced matrix. Each element belongs to the segment [2, 10^9].\\n\\nIt is guaranteed that ∑{(n ⋅ m)} over all test cases does not exceed 10^5.\\n\\nOutput\\n\\nFor each test case, if an answer does not exist, print a single word NO. Otherwise, print YES and both matrices in the same format as in the input.\\n\\n * The first matrix should be the cost matrix and the second matrix should be the...\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing std::queue;\\nusing std::vector;\\nconst int N = 100005;\\nnamespace FLOW {\\nconst int M = 2000005;\\nstruct edge {\\n int to, nxt, fl;\\n} e[M];\\nint n, S, T, head[N], dis[N], iter[N], top;\\ninline void init(void) {\\n std::fill(head + 1, head + n + 1, 0);\\n top = 1;\\n}\\ninline void adde(int x, int y, int fl) {\\n e[++top] = edge{y, head[x], fl};\\n head[x] = top;\\n}\\ninline void add(int x, int y, int fl) {\\n adde(x, y, fl);\\n adde(y, x, 0);\\n}\\nvoid bfs(void) {\\n static queue q;\\n std::fill(dis + 1, dis + n + 1, -1);\\n while (!q.empty()) q.pop();\\n q.push(S);\\n dis[S] = 0;\\n while (!q.empty()) {\\n int u = q.front();\\n q.pop();\\n for (int i = head[u]; i; i = e[i].nxt)\\n if (e[i].fl) {\\n int v = e[i].to;\\n if (dis[v] == -1) {\\n dis[v] = dis[u] + 1;\\n if (v == T) return;\\n q.push(v);\\n }\\n }\\n }\\n}\\nint dfs(int u, int fl) {\\n if (u == T) return fl;\\n int ret = 0;\\n for (int &i = iter[u]; i; i = e[i].nxt)\\n if (e[i].fl) {\\n int v = e[i].to;\\n if (dis[v] != dis[u] + 1) continue;\\n int s = dfs(v, std::min(fl, e[i].fl));\\n fl -= s, ret += s, e[i].fl -= s, e[i ^ 1].fl += s;\\n if (!fl) break;\\n }\\n return ret;\\n}\\nint dinic(int nn, int s, int t) {\\n n = nn, S = s, T = t;\\n int ret = 0;\\n while (1) {\\n bfs();\\n if (dis[t] == -1) break;\\n std::copy(head, head + n + 1, iter);\\n ret += dfs(s, 0x3f3f3f3f);\\n }\\n return ret;\\n}\\n} \\/\\/ namespace FLOW\\nusing FLOW::add;\\nusing FLOW::dinic;\\nusing FLOW::e;\\nusing FLOW::head;\\nusing FLOW::init;\\nusing FLOW::top;\\nint T, n, m, s, t, rs, rt, nm, n1m, val[N], vis[N], cnt, rid[N], cr;\\nint ansval[N];\\nchar ans[N], _Fc[5] = \\\"LRUD\\\";\\nint id[N];\\ninline int gid(int x, int y) { return (x - 1) * m + y; }\\ninline int L(int x) {\\n if (m == 1 || x % m == 1) return 0;\\n return x - 1;\\n}\\ninline int R(int x) {\\n if (m == 1 || x % m == 0) return 0;\\n return x + 1;\\n}\\ninline int U(int x) { return x <= m ? 0 : x - m; }\\ninline int D(int x) { return x > n1m ? 0 : x + m; }\\nint (*_F[4])(int) = {L, R, U, D};\\nint...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"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...\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nusing ll = long long;\\nusing ld = double;\\nusing pi = pair;\\nusing pl = pair;\\nusing pd = pair;\\nusing cd = complex;\\nusing vcd = vector;\\nusing vi = vector;\\nusing vl = vector;\\nusing vd = vector;\\nusing vs = vector;\\nusing vpi = vector;\\nusing vpl = vector;\\nusing vpd = vector;\\ntemplate \\nusing min_pq = priority_queue, greater >;\\ntemplate \\ninline int ckmin(T& a, const T& val) {\\n return val < a ? a = val, 1 : 0;\\n}\\ntemplate \\ninline int ckmax(T& a, const T& val) {\\n return a < val ? a = val, 1 : 0;\\n}\\ntemplate \\nvoid remDup(vector& v) {\\n sort(v.begin(), v.end());\\n v.erase(unique(v.begin(), v.end()), end(v));\\n}\\nconstexpr int pct(int x) { return __builtin_popcount(x); }\\nconstexpr int bits(int x) { return x == 0 ? 0 : 31 - __builtin_clz(x); }\\nconstexpr int p2(int x) { return 1 << x; }\\nconstexpr int msk2(int x) { return p2(x) - 1; }\\nll ceilDiv(ll a, ll b) { return a \\/ b + ((a ^ b) > 0 && a % b); }\\nll floorDiv(ll a, ll b) { return a \\/ b - ((a ^ b) < 0 && a % b); }\\nvoid setPrec(int x) { cout << fixed << setprecision(x); }\\nstring to_string(char c) { return string(1, c); }\\nstring to_string(const char* s) { return (string)s; }\\nstring to_string(string s) { return s; }\\nstring to_string(bool b) { return to_string((int)b); }\\ntemplate \\nstring to_string(complex c) {\\n stringstream ss;\\n ss << c;\\n return ss.str();\\n}\\ntemplate \\nusing V = vector;\\nstring to_string(V v) {\\n string res = \\\"{\\\";\\n for (int i = (0); i <= (int((v).size()) - 1); i++) res += char('0' + v[i]);\\n res += \\\"}\\\";\\n return res;\\n}\\ntemplate \\nstring to_string(bitset b) {\\n string res = \\\"\\\";\\n for (int i = (0); i <= (int((b).size()) - 1); i++) res += char('0' + b[i]);\\n return res;\\n}\\ntemplate \\nstring to_string(pair p);\\ntemplate \\nstring to_string(T v) {\\n bool fst = 1;\\n string res = \\\"\\\";\\n for (const auto& x : v) {\\n if (!fst) res += \\\"...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"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 JAVA.\",\"targets\":\"import java.util.*;\\nimport static java.lang.Math.toIntExact;\\n\\npublic class Cherry {\\n public static void main(String[] args) {\\n Scanner sc = new Scanner(System.in);\\n long k = sc.nextLong();\\n\\n for (int i=0; ia[i]?a[i]:min;\\n }\\n return min;\\n }\\n\\n public static...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"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\":\"from sys import *\\nfrom bisect import bisect_left\\ninput = lambda:stdin.readline()\\n\\nint_arr = lambda : list(map(int,stdin.readline().strip().split()))\\nstr_arr = lambda :list(map(str,stdin.readline().split()))\\nget_str = lambda : map(str,stdin.readline().strip().split())\\nget_int = lambda: map(int,stdin.readline().strip().split())\\nget_float = lambda : map(float,stdin.readline().strip().split())\\n\\n\\nmod = 1000000007\\nsetrecursionlimit(1000)\\n\\nfor _ in range(int(input())):\\n n = int(input())\\n s = str(input())[:-1]\\n\\n t = ''.join(sorted(s))\\n ct = 0\\n for i in range(n):\\n if s[i] != t[i]:\\n ct += 1\\n print(ct)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"An n × n table a is defined as follows:\\n\\n * The first row and the first column contain ones, that is: ai, 1 = a1, i = 1 for all i = 1, 2, ..., n. \\n * Each of the remaining numbers in the table is equal to the sum of the number above it and the number to the left of it. In other words, the remaining elements are defined by the formula ai, j = ai - 1, j + ai, j - 1. \\n\\n\\n\\nThese conditions define all the values in the table.\\n\\nYou are given a number n. You need to determine the maximum value in the n × n table defined by the rules above.\\n\\nInput\\n\\nThe only line of input contains a positive integer n (1 ≤ n ≤ 10) — the number of rows and columns of the table.\\n\\nOutput\\n\\nPrint a single line containing a positive integer m — the maximum value in the table.\\n\\nExamples\\n\\nInput\\n\\n1\\n\\n\\nOutput\\n\\n1\\n\\nInput\\n\\n5\\n\\n\\nOutput\\n\\n70\\n\\nNote\\n\\nIn the second test the rows of the table look as follows: \\n\\n{1, 1, 1, 1, 1}, {1, 2, 3, 4, 5}, {1, 3, 6, 10, 15}, {1, 4, 10, 20, 35}, {1, 5, 15, 35, 70}.\\nUsing python3 can you solve the prior task?\",\"targets\":\"def answer(a, b):\\n\\tif a == 1 or b == 1:\\n\\t\\treturn 1\\n\\telse:\\n\\t\\treturn answer(a-1, b) + answer(a, b-1)\\n\\nstart = int(input())\\nprint(answer(start, start))\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"After their adventure with the magic mirror Kay and Gerda have returned home and sometimes give free ice cream to kids in the summer.\\n\\nAt the start of the day they have x ice cream packs. Since the ice cream is free, people start standing in the queue before Kay and Gerda's house even in the night. Each person in the queue wants either to take several ice cream packs for himself and his friends or to give several ice cream packs to Kay and Gerda (carriers that bring ice cream have to stand in the same queue).\\n\\nIf a carrier with d ice cream packs comes to the house, then Kay and Gerda take all his packs. If a child who wants to take d ice cream packs comes to the house, then Kay and Gerda will give him d packs if they have enough ice cream, otherwise the child will get no ice cream at all and will leave in distress.\\n\\nKay wants to find the amount of ice cream they will have after all people will leave from the queue, and Gerda wants to find the number of distressed kids.\\n\\nInput\\n\\nThe first line contains two space-separated integers n and x (1 ≤ n ≤ 1000, 0 ≤ x ≤ 109).\\n\\nEach of the next n lines contains a character '+' or '-', and an integer di, separated by a space (1 ≤ di ≤ 109). Record \\\"+ di\\\" in i-th line means that a carrier with di ice cream packs occupies i-th place from the start of the queue, and record \\\"- di\\\" means that a child who wants to take di packs stands in i-th place.\\n\\nOutput\\n\\nPrint two space-separated integers — number of ice cream packs left after all operations, and number of kids that left the house in distress.\\n\\nExamples\\n\\nInput\\n\\n5 7\\n+ 5\\n- 10\\n- 20\\n+ 40\\n- 20\\n\\n\\nOutput\\n\\n22 1\\n\\n\\nInput\\n\\n5 17\\n- 16\\n- 2\\n- 98\\n+ 100\\n- 98\\n\\n\\nOutput\\n\\n3 2\\n\\nNote\\n\\nConsider the first sample.\\n\\n 1. Initially Kay and Gerda have 7 packs of ice cream. \\n 2. Carrier brings 5 more, so now they have 12 packs. \\n 3. A kid asks for 10 packs and receives them. There are only 2 packs remaining. \\n 4. Another kid asks for 20 packs. Kay and Gerda do not have them, so the kid goes away distressed. \\n 5. Carrier bring 40 packs, now Kay and...\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nconst long long OO = (long long)1e17;\\nconst int MX = (int)1e6 + 1;\\nconst int mod = (int)1e9 + 7;\\nconst double EPS = 1e-6;\\nconst double PI = 3.1415926;\\nint main(void) {\\n ios_base::sync_with_stdio(0);\\n long long n, x;\\n while (cin >> n >> x) {\\n int cnt = 0;\\n for (int i = 0; i < n; i++) {\\n char sg;\\n int val;\\n cin >> sg >> val;\\n if (sg == '+')\\n x += val;\\n else {\\n if (x < val) {\\n cnt++;\\n } else {\\n x -= val;\\n }\\n }\\n }\\n cout << x << \\\" \\\" << cnt << \\\"\\\\n\\\";\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"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].\\\":\",\"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 static long Modpow(long a,long p,long m){long res=1;while(p>0){if((p&1)!=0){res=(res*a)%m;}p >>=1;a=(a*a)%m;}return res;}\\n static long Modmul(long a,long b,long m){return ((a%m)*(b%m))%m;}\\n static long ModInv(long a,long m){return Modpow(a,m-2,m);}\\n static long nck(int n,int r,long m){if(r>n){return 0l;}return Modmul(f[n],ModInv(Modmul(f[n-r],f[r],m),m),m);}\\n static long[] f;\\n public static void main(String args[]){\\n FastReader sc=new FastReader();\\n int t=sc.nextInt();\\n while(t-->0){\\n long mod=1000000007;\\n int n=sc.nextInt();\\n int k=sc.nextInt();\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"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;\\nint a[100001];\\nint b[100001];\\nint ans[100001];\\nint main() {\\n ios::sync_with_stdio(false);\\n cin.tie(0);\\n int t;\\n cin >> t;\\n while (t--) {\\n int i, n;\\n cin >> n;\\n for (i = 1; i <= n; ++i) cin >> a[i], ans[i] = 0;\\n for (i = 1; i <= n; ++i) cin >> b[i];\\n if (1 == n)\\n cout << \\\"1\\\\n\\\";\\n else {\\n vector > v;\\n set > st;\\n for (i = 1; i <= n; ++i) v.push_back({a[i], i});\\n sort(v.begin(), v.end());\\n for (i = 0; i < n - 1; ++i) {\\n int ix = v[i].second;\\n st.insert({b[ix], i});\\n }\\n int mn = b[v[i].second];\\n int l = n - 1, r = n;\\n while (st.size()) {\\n while (st.lower_bound({mn, 0}) != st.end()) {\\n auto it = st.lower_bound({mn, 0});\\n l = min(l, it->second);\\n st.erase(it);\\n }\\n if (l == r) break;\\n for (i = l; i < r; ++i) {\\n int ix = v[i].second;\\n mn = min(mn, b[ix]);\\n }\\n r = l;\\n }\\n for (i = l; i < n; ++i) {\\n int ix = v[i].second;\\n ans[ix] = 1;\\n }\\n for (i = 1; i <= n; ++i) cout << ans[i];\\n cout << \\\"\\\\n\\\";\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"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 CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 100;\\nchar str[N];\\nchar ans[N][N];\\nvoid ac() {\\n int n;\\n cin >> n;\\n cin >> str + 1;\\n vector v;\\n for (int i = 1; i <= n; i++) {\\n if (str[i] == '1') {\\n for (int j = 1; j <= n; j++) {\\n ans[i][j] = '=';\\n }\\n } else {\\n for (int j = 1; j <= n; j++) {\\n ans[i][j] = '=';\\n }\\n v.push_back(i);\\n }\\n }\\n if (v.size() == 1 || v.size() == 2) {\\n cout << \\\"NO\\\" << endl;\\n return;\\n }\\n cout << \\\"YES\\\" << endl;\\n int siz = v.size();\\n for (int i = 0; i < siz; i++) {\\n if (i == siz - 1) {\\n ans[v[i]][v[0]] = '+';\\n ans[v[0]][v[i]] = '-';\\n } else {\\n int ying = v[i];\\n int shu = v[i + 1];\\n ans[ying][shu] = '+';\\n ans[shu][ying] = '-';\\n }\\n }\\n for (int i = 1; i <= n; i++) {\\n ans[i][i] = 'X';\\n }\\n for (int j = 1; j <= n; j++) {\\n for (int k = 1; k <= n; k++) {\\n cout << ans[j][k];\\n }\\n cout << endl;\\n }\\n}\\nsigned main() {\\n int t;\\n ios::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n cin >> t;\\n for (int i = 1; i <= t; i++) ac();\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\n'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 \\nusing namespace std;\\ntemplate \\nvoid _dbg(const char *sdbg, TH h) {\\n cerr << sdbg << '=' << h << endl;\\n}\\ntemplate \\nvoid _dbg(const char *sdbg, TH h, TA... a) {\\n while (*sdbg != ',') cerr << *sdbg++;\\n cerr << '=' << h << ',';\\n _dbg(sdbg + 1, a...);\\n}\\ntemplate \\nostream &operator<<(ostream &os, vector V) {\\n os << \\\"[\\\";\\n for (auto vv : V) os << vv << \\\",\\\";\\n return os << \\\"]\\\";\\n}\\ntemplate \\nostream &operator<<(ostream &os, pair P) {\\n return os << \\\"(\\\" << P.first << \\\",\\\" << P.second << \\\")\\\";\\n}\\nusing ll = long long;\\nusing ld = long double;\\nusing uint = unsigned int;\\nusing ull = unsigned long long;\\ntemplate \\nusing pair2 = pair;\\nusing pii = pair;\\nusing pli = pair;\\nusing pll = pair;\\nusing vi = vector;\\nusing vii = vector;\\nmt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());\\ntemplate \\nvoid ps(T x) {\\n cout << x << \\\"\\\\n\\\";\\n}\\ntemplate \\nvoid ps_vec(T a) {\\n for (int i = 0; i < a.size(); ++i) {\\n if (i) cout << \\\" \\\";\\n cout << a[i];\\n }\\n cout << \\\"\\\\n\\\";\\n}\\nconst int md = 1e9 + 7;\\nconst int dir[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};\\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}\\nvoid setIO(string s) {\\n ios_base::sync_with_stdio(false);\\n cin.tie(0);\\n freopen((s + \\\".in\\\").c_str(), \\\"r\\\", stdin);\\n freopen((s + \\\".out\\\").c_str(), \\\"w\\\", stdout);\\n}\\nconst int maxn = 1e6 + 10;\\nvi fa, g;\\nstruct Edge {\\n int x, y, z;\\n};\\nint find(int x) {\\n if (x == fa[x])\\n return x;\\n else {\\n int fx = fa[x];\\n fa[x] = find(fa[x]);\\n g[x] = g[x] ^ g[fx];\\n return fa[x];\\n }\\n}\\nvoid task() {\\n int n, m;\\n cin >> n >> m;\\n fa = vi(n + 1);\\n g = vi(n + 1);\\n vector edge;\\n for (int i = 1; i <= n; ++i) fa[i] = i, g[i] = 0;\\n for (int i = 0; i < n - 1; ++i) {\\n int x, y, z;\\n cin >> x >> y >> z;\\n edge.push_back({x, y, z});\\n if (z...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"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,...\\\":\",\"targets\":\"#include \\nint t, n, m, book[100010];\\nint main() {\\n scanf(\\\"%d\\\", &t);\\n while (t--) {\\n scanf(\\\"%d%d\\\", &n, &m);\\n for (int i = 1; i <= n; i++) book[i] = 0;\\n for (int i = 1; i <= m; i++) {\\n int a, b, c;\\n scanf(\\\"%d%d%d\\\", &a, &b, &c);\\n book[b] = 1;\\n }\\n for (int i = 1; i <= n; i++)\\n if (!book[i]) {\\n for (int j = 1; j <= n; j++)\\n if (i != j) printf(\\\"%d %d\\\\n\\\", i, j);\\n break;\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"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\",\"targets\":\"n=int(input())\\nn1=\\\"I hate\\\"\\nn2=\\\"I love\\\"\\nl=[]\\nfor i in range(1,n+1):\\n if i&1:\\n l.append(n1)\\n else:\\n l.append(n2)\\nl=' that '.join(l)\\nprint(l+' '+\\\"it\\\")\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"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...\",\"targets\":\"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 if w * h > (W * H - (x2 - x1) * (y2 - y1)) or (w + (x2 - x1) > W and h + (y2 - y1) > H):\\n print(-1)\\n else:\\n maxH = max(y1, H - y2)\\n maxW = max(x1, W - x2)\\n if maxH == 0 and maxW == 0 or maxH >= h or maxW >= w:\\n print(0)\\n elif maxW == 0 or x1 + W - x2 < w:\\n print(h - maxH)\\n elif maxH == 0 or y1 + H - y2 < h:\\n print(w - maxW)\\n else:\\n print(min(h - maxH, w - maxW))\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"ATMs of a well-known bank of a small country are arranged so that they can not give any amount of money requested by the user. Due to the limited size of the bill dispenser (the device that is directly giving money from an ATM) and some peculiarities of the ATM structure, you can get at most k bills from it, and the bills may be of at most two distinct denominations.\\n\\nFor example, if a country uses bills with denominations 10, 50, 100, 500, 1000 and 5000 burles, then at k = 20 such ATM can give sums 100 000 burles and 96 000 burles, but it cannot give sums 99 000 and 101 000 burles.\\n\\nLet's suppose that the country uses bills of n distinct denominations, and the ATM that you are using has an unlimited number of bills of each type. You know that during the day you will need to withdraw a certain amount of cash q times. You know that when the ATM has multiple ways to give money, it chooses the one which requires the minimum number of bills, or displays an error message if it cannot be done. Determine the result of each of the q of requests for cash withdrawal.\\n\\nInput\\n\\nThe first line contains two integers n, k (1 ≤ n ≤ 5000, 1 ≤ k ≤ 20).\\n\\nThe next line contains n space-separated integers ai (1 ≤ ai ≤ 107) — the denominations of the bills that are used in the country. Numbers ai follow in the strictly increasing order.\\n\\nThe next line contains integer q (1 ≤ q ≤ 20) — the number of requests for cash withdrawal that you will make.\\n\\nThe next q lines contain numbers xi (1 ≤ xi ≤ 2·108) — the sums of money in burles that you are going to withdraw from the ATM.\\n\\nOutput\\n\\nFor each request for cash withdrawal print on a single line the minimum number of bills it can be done, or print - 1, if it is impossible to get the corresponding sum.\\n\\nExamples\\n\\nInput\\n\\n6 20\\n10 50 100 500 1000 5000\\n8\\n4200\\n100000\\n95000\\n96000\\n99000\\n10100\\n2015\\n9950\\n\\n\\nOutput\\n\\n6\\n20\\n19\\n20\\n-1\\n3\\n-1\\n-1\\n\\n\\nInput\\n\\n5 2\\n1 2 3 5 8\\n8\\n1\\n3\\n5\\n7\\n9\\n11\\n13\\n15\\n\\n\\nOutput\\n\\n1\\n1\\n1\\n2\\n2\\n2\\n2\\n-1\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint n, k, q;\\nint a[100000];\\npair b[100000];\\nint main() {\\n cin >> n >> k;\\n for (int i = 0; i < n; i++) {\\n cin >> a[i];\\n for (int j = 0; j < k; j++) b[i * k + j] = make_pair(a[i] * (j + 1), j + 1);\\n }\\n sort(b, b + n * k);\\n int x, l, r, m, ans;\\n cin >> q;\\n for (int i = 0; i < q; i++) {\\n cin >> x;\\n ans = 2000000000;\\n for (int j = 0; j < n * k; j++) {\\n if (b[j].first == x) {\\n if (b[j].second < ans) ans = b[j].second;\\n } else {\\n l = 0;\\n r = n * k - 1;\\n while (l < r) {\\n m = (l + r) \\/ 2;\\n if (b[m].first + b[j].first < x)\\n l = m + 1;\\n else\\n r = m;\\n }\\n if (b[l].first + b[j].first == x && b[l].second + b[j].second < ans &&\\n b[l].second + b[j].second <= k)\\n ans = b[l].second + b[j].second;\\n }\\n }\\n if (ans == 2000000000)\\n cout << -1 << endl;\\n else\\n cout << ans << 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 JAVA?\\nYou 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.*;\\nimport java.io.*;\\npublic class A_Cherry{\\n public static void main(String[] args) throws IOException{\\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\\n int t=Integer.parseInt(br.readLine());\\n while(t>0){\\n int n=Integer.parseInt(br.readLine());\\n long ar[]=new long[n];\\n\\n String []s=br.readLine().split(\\\" \\\");\\n long max=0;\\n long maxvalu=0;\\n for(int i=0;imax) max=var;\\n }\\n \\n System.out.println(max);\\n \\n t--;\\n }\\n \\n }\\n \\n }\",\"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',...\\nUsing python3 can you solve the prior task?\",\"targets\":\"from itertools import product, combinations\\nfrom math import sqrt, gcd, ceil\\n\\nINF = int(1e9 + 1)\\n\\n\\nif __name__ == '__main__':\\n for _ in range(int(input())):\\n n, m = map(int, input().split())\\n s = input()\\n x = 0\\n y = 0\\n xmin, xmax, ymin, ymax = 0, 0, 0, 0\\n breaked = False\\n for i in range(len(s)):\\n el = s[i]\\n if el == 'L':\\n x -= 1\\n elif el == 'R':\\n x += 1\\n elif el == 'U':\\n y += 1\\n elif el == 'D':\\n y -= 1\\n if x < xmin:\\n xmin = x\\n t = 1\\n elif x > xmax:\\n xmax = x\\n t = 2\\n elif y < ymin:\\n ymin = y\\n t = 3\\n elif y > ymax:\\n ymax = y\\n t = 4\\n if ymax - ymin >= n or xmax - xmin >= m:\\n breaked = True\\n break\\n if breaked:\\n if t == 1:\\n xmin += 1\\n elif t == 2:\\n xmax -= 1\\n elif t == 3:\\n ymin += 1\\n else:\\n ymax -= 1\\n print(1 + ymax, m - xmax)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"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\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int t, k, i = 1, j = 1, a[1000];\\n while (i <= 1000) {\\n if (j % 10 != 3 && j % 3 != 0) {\\n a[i] = j;\\n i++;\\n }\\n j++;\\n }\\n cin >> t;\\n for (i = 0; i < t; i++) {\\n cin >> k;\\n cout << a[k] << endl;\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Emuskald is a well-known illusionist. One of his trademark tricks involves a set of magical boxes. The essence of the trick is in packing the boxes inside other boxes.\\n\\nFrom the top view each magical box looks like a square with side length equal to 2k (k is an integer, k ≥ 0) units. A magical box v can be put inside a magical box u, if side length of v is strictly less than the side length of u. In particular, Emuskald can put 4 boxes of side length 2k - 1 into one box of side length 2k, or as in the following figure:\\n\\n\\n\\nEmuskald is about to go on tour performing around the world, and needs to pack his magical boxes for the trip. He has decided that the best way to pack them would be inside another magical box, but magical boxes are quite expensive to make. Help him find the smallest magical box that can fit all his boxes.\\n\\nInput\\n\\nThe first line of input contains an integer n (1 ≤ n ≤ 105), the number of different sizes of boxes Emuskald has. Each of following n lines contains two integers ki and ai (0 ≤ ki ≤ 109, 1 ≤ ai ≤ 109), which means that Emuskald has ai boxes with side length 2ki. It is guaranteed that all of ki are distinct.\\n\\nOutput\\n\\nOutput a single integer p, such that the smallest magical box that can contain all of Emuskald’s boxes has side length 2p.\\n\\nExamples\\n\\nInput\\n\\n2\\n0 3\\n1 5\\n\\n\\nOutput\\n\\n3\\n\\n\\nInput\\n\\n1\\n0 4\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\n2\\n1 10\\n2 2\\n\\n\\nOutput\\n\\n3\\n\\nNote\\n\\nPicture explanation. If we have 3 boxes with side length 2 and 5 boxes with side length 1, then we can put all these boxes inside a box with side length 4, for example, as shown in the picture.\\n\\nIn the second test case, we can put all four small boxes into a box with side length 2.\\nSolve the task in JAVA.\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\n\\nimport static java.lang.Math.*;\\nimport static java.util.Arrays.fill;\\nimport static java.util.Arrays.sort;\\nimport static java.util.Arrays.binarySearch;;\\n\\npublic class Main {\\n\\t\\/\\/ AltSTU1\\n\\tpublic static void main(String[] args) {\\n\\t\\ttry {\\n\\t\\t\\tlong timeStamp1 = System.currentTimeMillis();\\n\\t\\t\\t\\n\\t\\t\\ttry {\\n\\t\\t\\t\\tif (new File(\\\"input.txt\\\").exists()) {\\n\\t\\t\\t\\t\\tSystem.setIn(new FileInputStream(\\\"input.txt\\\"));\\n\\t\\t\\t\\t}\\n\\t\\t\\t} catch (Exception e) {\\n\\t\\t\\t}\\n\\t\\t\\t\\t\\n\\t\\t\\tnew Main().run();\\n\\t\\t\\tlong timeStamp2 = System.currentTimeMillis();\\n\\t\\t} catch (IOException e) {\\n\\t\\t\\te.printStackTrace();\\n\\t\\t}\\n\\t}\\n\\n\\tBufferedReader in;\\n\\tPrintWriter out;\\n\\tStringTokenizer st = new StringTokenizer(\\\"\\\");\\n\\t\\n\\t\\n\\tvoid run() throws IOException {\\n\\t\\tin = new BufferedReader(new InputStreamReader(System.in));\\n\\t\\tout = new PrintWriter(System.out);\\n\\t\\tsolve();\\n\\t\\tout.close();\\n\\t\\tin.close();\\n\\t}\\n\\t\\n\\t\\n\\tvoid solve() throws IOException {\\n\\t\\tint n = nextInt();\\n\\t\\tlong ans = 0;\\n\\t\\tfor(int i = 0; i < n; i++){\\n\\t\\t\\tlong sz = nextLong();\\n\\t\\t\\tlong cnt = nextLong();\\n\\t\\t\\tlong cur = 1;\\n\\t\\t\\tlong deg = 0;\\n\\t\\t\\twhile(cur < cnt){\\n\\t\\t\\t\\tcur *= 4L;\\n\\t\\t\\t\\tdeg++;\\n\\t\\t\\t}\\n\\t\\t\\tdeg = max(deg, 1);\\n\\t\\t\\tans = max(ans, deg + sz);\\n\\t\\t}\\n\\t\\tout.println(ans);\\n\\t}\\n\\t\\n\\t\\t\\n\\t\\n\\tString nextToken() throws IOException {\\n\\t\\twhile (!st.hasMoreTokens())\\n\\t\\t\\tst = new StringTokenizer(in.readLine());\\n\\t\\treturn st.nextToken();\\n\\t}\\n\\t\\n\\tint nextInt() throws IOException {\\n\\t\\treturn Integer.parseInt(nextToken());\\n\\t}\\n\\t\\n\\tlong nextLong() throws IOException {\\n\\t\\treturn Long.parseLong(nextToken());\\n\\t}\\n\\t\\n\\tdouble nextDouble() throws IOException {\\n\\t\\treturn Double.parseDouble(nextToken());\\n\\t}\\n\\t\\n\\tString nextLine() throws IOException {\\n\\t\\tst = new StringTokenizer(\\\"\\\");\\n\\t\\treturn in.readLine();\\n\\t}\\n\\t\\n\\tboolean EOF() throws IOException {\\n\\t\\twhile (!st.hasMoreTokens()) {\\n\\t\\t\\tString s = in.readLine();\\n\\t\\t\\tif (s == null)\\n\\t\\t\\t\\treturn true;\\n\\t\\t\\tst = new StringTokenizer(s);\\n\\t\\t}\\n\\t\\treturn false;\\n\\t}\\n\\t\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given a permutation p of n elements. A permutation of n elements is an array of length n containing each integer from 1 to n exactly once. For example, [1, 2, 3] and [4, 3, 5, 1, 2] are permutations, but [1, 2, 4] and [4, 3, 2, 1, 2] are not permutations. You should perform q queries.\\n\\nThere are two types of queries:\\n\\n * 1 x y — swap p_x and p_y. \\n * 2 i k — print the number that i will become if we assign i = p_i k times. \\n\\nInput\\n\\nThe first line contains two integers n and q (1 ≤ n, q ≤ 10^5).\\n\\nThe second line contains n integers p_1, p_2, ..., p_n.\\n\\nEach of the next q lines contains three integers. The first integer is t (1 ≤ t ≤ 2) — type of query. If t = 1, then the next two integers are x and y (1 ≤ x, y ≤ n; x ≠ y) — first-type query. If t = 2, then the next two integers are i and k (1 ≤ i, k ≤ n) — second-type query.\\n\\nIt is guaranteed that there is at least one second-type query.\\n\\nOutput\\n\\nFor every second-type query, print one integer in a new line — answer to this query.\\n\\nExamples\\n\\nInput\\n\\n\\n5 4\\n5 3 4 2 1\\n2 3 1\\n2 1 2\\n1 1 3\\n2 1 2\\n\\n\\nOutput\\n\\n\\n4\\n1\\n2\\n\\n\\nInput\\n\\n\\n5 9\\n2 3 5 1 4\\n2 3 5\\n2 5 5\\n2 5 1\\n2 5 3\\n2 5 4\\n1 5 4\\n2 5 3\\n2 2 5\\n2 5 1\\n\\n\\nOutput\\n\\n\\n3\\n5\\n4\\n2\\n3\\n3\\n3\\n1\\n\\nNote\\n\\nIn the first example p = \\\\{5, 3, 4, 2, 1\\\\}. \\n\\nThe first query is to print p_3. The answer is 4.\\n\\nThe second query is to print p_{p_1}. The answer is 1.\\n\\nThe third query is to swap p_1 and p_3. Now p = \\\\{4, 3, 5, 2, 1\\\\}.\\n\\nThe fourth query is to print p_{p_1}. The answer is 2.\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nint i, j, k, n, m, t, x, y, z;\\nint l[100500], r[100500], l300[100500], r300[100500], k2;\\nvoid work(int x) {\\n for (i = 1, k = x; i < 150; i++) k = l[k];\\n k2 = r[x];\\n for (i = 1; i <= 150; i++) {\\n r300[k] = k2;\\n l300[k2] = k;\\n k = r[k];\\n k2 = r[k2];\\n }\\n}\\nint main() {\\n ios::sync_with_stdio(0);\\n cin >> n >> t;\\n for (i = 1; i <= n; i++) cin >> r[i], l[r[i]] = i;\\n for (i = 1; i <= n; i++) {\\n for (j = 1, k = i; j <= 150; j++) k = r[k];\\n r300[i] = k;\\n l300[k] = i;\\n }\\n while (t--) {\\n cin >> x >> y >> z;\\n if (x == 1) {\\n swap(r[y], r[z]);\\n l[r[y]] = y;\\n l[r[z]] = z;\\n work(y);\\n work(z);\\n } else {\\n while (z > 150) y = r300[y], z -= 150;\\n while (z) y = r[y], z--;\\n cout << y << '\\\\n';\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"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 \\nconst int U = 1000002;\\nconst int N = 150005;\\nconst int P = 80000;\\nint n, a[N], q, idx[U];\\nbool notp[U];\\nint p[P], tot;\\nstd::vector divs[U];\\nint uset[N + P];\\nint find(int x) { return x == uset[x] ? x : uset[x] = find(uset[x]); }\\nstd::set> connect;\\nsigned main() {\\n scanf(\\\"%d%d\\\", &n, &q);\\n for (int i = 1; i <= n; i++) scanf(\\\"%d\\\", a + i), idx[a[i]] = i;\\n notp[1] = 1;\\n for (int i = 2; i < U; i++) {\\n if (!notp[i]) p[++tot] = i;\\n for (int j = 1; j <= tot && i * p[j] < U; j++) {\\n notp[i * p[j]] = 1;\\n if (i % p[j] == 0) break;\\n }\\n }\\n for (int i = 1; i <= tot; i++)\\n for (int j = p[i]; j < U; j += p[i]) divs[j].push_back(i);\\n for (int i = 1; i < n + P; i++) uset[i] = i;\\n for (int i = 1; i <= n; i++)\\n for (auto x : divs[a[i]]) uset[find(i)] = find(n + x);\\n for (int i = 1; i <= n; i++) {\\n for (auto x : divs[a[i]])\\n for (auto y : divs[a[i] + 1]) connect.emplace(find(x + n), find(y + n));\\n for (auto x : divs[a[i] + 1])\\n for (auto y : divs[a[i] + 1]) connect.emplace(find(x + n), find(y + n));\\n }\\n while (q--) {\\n int s, t;\\n scanf(\\\"%d%d\\\", &s, &t);\\n if (find(s) == find(t))\\n puts(\\\"0\\\");\\n else if (connect.count(std::make_pair(find(s), find(t))))\\n puts(\\\"1\\\");\\n else if (connect.count(std::make_pair(find(t), find(s))))\\n puts(\\\"1\\\");\\n else\\n puts(\\\"2\\\");\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"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}$$$.\",\"targets\":\"#include \\nusing namespace std;\\nvector res;\\nconst int N = 3E5 + 7;\\nlong long pre[10][2];\\nlong long dp[20][2];\\nint a[20];\\nint cnt[12];\\npriority_queue > q;\\nvoid solve() {\\n int s, n;\\n res.clear();\\n while (!q.empty()) q.pop();\\n memset(cnt, 0, sizeof(cnt));\\n scanf(\\\"%d%d\\\", &s, &n);\\n int sum = 0, m = s;\\n while (m) {\\n sum += m % 10;\\n m \\/= 10;\\n }\\n int u = n, o = 1, k = s;\\n while (u && k) {\\n if (k % 10) {\\n if (o == 1)\\n res.push_back(1);\\n else\\n q.push({1, -o});\\n k--;\\n u--;\\n } else {\\n k \\/= 10;\\n o *= 10;\\n }\\n }\\n if (u == 0) {\\n while (!q.empty()) {\\n res.push_back(-q.top().second);\\n q.pop();\\n }\\n for (int i = 0; i < res.size(); i++) {\\n if (i != res.size() - 1)\\n printf(\\\"%d \\\", res[i]);\\n else\\n printf(\\\"%d\\\\n\\\", res[i] + k * o);\\n }\\n return;\\n }\\n while (u) {\\n auto y = q.top();\\n q.pop();\\n if (y.first == 1) {\\n int r = -y.second, w = -y.second \\/ 10;\\n r -= w;\\n if (r != 1)\\n q.push({9, -r});\\n else\\n res.push_back(r);\\n if (w != 1)\\n q.push({1, -w});\\n else\\n res.push_back(w);\\n } else {\\n int w = -y.second \\/ y.first;\\n int r = -y.second - w;\\n if (w != 1)\\n q.push({1, -w});\\n else\\n res.push_back(w);\\n if (r != 1)\\n q.push({y.first - 1, -r});\\n else\\n res.push_back(r);\\n }\\n u--;\\n }\\n for (int i = 0; i < res.size(); i++) printf(\\\"%d \\\", res[i]);\\n while (!q.empty()) {\\n printf(\\\"%d \\\", -q.top().second);\\n q.pop();\\n }\\n printf(\\\"\\\\n\\\");\\n}\\nint main() {\\n int t;\\n scanf(\\\"%d\\\", &t);\\n while (t--) {\\n solve();\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"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 \\nusing namespace std;\\nlong long int gcd(long long int a, long long int b) {\\n if (!b) return a;\\n return gcd(b, a % b);\\n}\\nlong long int power(long long int x, long long int y, long long int p) {\\n long long int res = 1;\\n x %= p;\\n while (y > 0) {\\n if (y & 1) res = (res * x) % p;\\n y = y >> 1;\\n x = (x * x) % p;\\n }\\n return res;\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n long long int t;\\n cin >> t;\\n long long int temp[101] = {0};\\n temp[1] = 1;\\n for (long long int i = 2; i * i <= 100; i++) {\\n if (!temp[i]) {\\n for (long long int j = 2; i * j <= 100; j++) {\\n temp[i * j] = 1;\\n }\\n }\\n }\\n vector check;\\n for (long long int i = 1; i <= 100; i++) {\\n if (temp[i]) {\\n string c = to_string(i);\\n check.push_back(c);\\n }\\n }\\n long long int m = check.size();\\n while (t--) {\\n long long int n;\\n cin >> n;\\n string a;\\n cin >> a;\\n long long int e = 0;\\n for (long long int iter = 0; iter < m && e == 0; iter++) {\\n string curr = check[iter];\\n long long int j = 0, i;\\n for (i = 0; i < curr.length() && j < n; i++) {\\n while (j < n && a[j] != curr[i]) {\\n j++;\\n }\\n if (j == n) {\\n break;\\n }\\n j++;\\n }\\n if (i == curr.length()) {\\n cout << curr.length() << endl << curr << endl;\\n e = 1;\\n break;\\n }\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Arya has n opponents in the school. Each day he will fight with all opponents who are present this day. His opponents have some fighting plan that guarantees they will win, but implementing this plan requires presence of them all. That means if one day at least one of Arya's opponents is absent at the school, then Arya will beat all present opponents. Otherwise, if all opponents are present, then they will beat Arya.\\n\\nFor each opponent Arya knows his schedule — whether or not he is going to present on each particular day. Tell him the maximum number of consecutive days that he will beat all present opponents.\\n\\nNote, that if some day there are no opponents present, Arya still considers he beats all the present opponents.\\n\\nInput\\n\\nThe first line of the input contains two integers n and d (1 ≤ n, d ≤ 100) — the number of opponents and the number of days, respectively.\\n\\nThe i-th of the following d lines contains a string of length n consisting of characters '0' and '1'. The j-th character of this string is '0' if the j-th opponent is going to be absent on the i-th day.\\n\\nOutput\\n\\nPrint the only integer — the maximum number of consecutive days that Arya will beat all present opponents.\\n\\nExamples\\n\\nInput\\n\\n2 2\\n10\\n00\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n4 1\\n0100\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\n4 5\\n1101\\n1111\\n0110\\n1011\\n1111\\n\\n\\nOutput\\n\\n2\\n\\nNote\\n\\nIn the first and the second samples, Arya will beat all present opponents each of the d days.\\n\\nIn the third sample, Arya will beat his opponents on days 1, 3 and 4 and his opponents will beat him on days 2 and 5. Thus, the maximum number of consecutive winning days is 2, which happens on days 3 and 4.\\nSolve the task in PYTHON3.\",\"targets\":\"n,d=map(int,input().split())\\np=[]\\nc=0\\nfor i in range(d):\\n a=str(input())\\n o=a.count('1')\\n if(o a, i.e. he is to the right of Oleg.\\n\\nThe two guards are very lazy, so they do not move. In every second, Oleg can either take all the banknotes from the current safe or move to any of the neighboring safes. However, he cannot visit any safe that is guarded by security guards at any time, becaues he might be charged for stealing. Determine the maximum amount of banknotes Oleg can gather.\\n\\nInput\\n\\nThe first line of input contains three space-separated integers, a, b and c (1 ≤ b < a < c ≤ 109), denoting the positions of Oleg, the first security guard and the second security guard, respectively.\\n\\nThe next line of input contains a single integer n (1 ≤ n ≤ 105), denoting the number of banknotes.\\n\\nThe next line of input contains n space-separated integers x1, x2, ..., xn (1 ≤ xi ≤ 109), denoting that the i-th banknote is located in the xi-th safe. Note that xi are not guaranteed to be distinct.\\n\\nOutput\\n\\nOutput a single integer: the maximum number of banknotes Oleg can take.\\n\\nExamples\\n\\nInput\\n\\n5 3 7\\n8\\n4 7 5 5 3 6 2 8\\n\\n\\nOutput\\n\\n4\\n\\n\\nInput\\n\\n6 5 7\\n5\\n1 5 7 92 3\\n\\n\\nOutput\\n\\n0\\n\\nNote\\n\\nIn the first example Oleg can take the banknotes in positions 4, 5, 6 (note that there are 2 banknotes at position 5). Oleg can't take the banknotes in safes 7 and 8 because he can't run into the second security guard. Similarly, Oleg cannot take the banknotes at positions 3 and 2 because he can't run into the first security...\\nimpor\",\"targets\":\"t java.util.ArrayList;\\nimport java.util.Arrays;\\nimport java.util.LinkedList;\\nimport java.util.Queue;\\nimport java.io.BufferedReader;\\nimport java.io.FileReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.util.StringTokenizer;\\nimport java.util.Random;\\nimport java.io.FileWriter;\\nimport java.io.PrintWriter;\\n\\/*\\n Solution Created: 04:43:36 29\\/02\\/2020\\n Custom Competitive programming helper.\\n*\\/\\npublic class Main {\\n\\tpublic static void solve(Reader in, Writer out) {\\n\\t\\tint a = in.nextInt(), b = in.nextInt(), c = in.nextInt();\\n\\t\\tint n = in.nextInt();\\n\\t\\tint ans = 0;\\n\\t\\tfor(int i = 0; i con[];\\n\\tprivate boolean[] visited;\\n\\n\\tpublic Graph(int n) {\\n\\t\\tcon = new ArrayList[n];\\n\\t\\tfor (int i = 0; i < n; ++i)\\n\\t\\t\\tcon[i] = new ArrayList();\\n\\t\\tvisited = new boolean[n];\\n\\t}\\n\\n\\tpublic void reset() {\\n\\t\\tArrays.fill(visited, false);\\n\\t}\\n\\n\\tpublic void addEdge(int v, int w) {\\n\\t\\tcon[v].add(w);\\n\\t}\\n\\n\\tpublic void dfs(int cur) {\\n\\t\\tvisited[cur] = true;\\n\\t\\tfor (Integer v : con[cur]) {\\n\\t\\t\\tif (!visited[v]) {\\n\\t\\t\\t\\tdfs(v);\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n\\tpublic void bfs(int cur) {\\n\\t\\tQueue q = new LinkedList<>();\\n\\t\\tq.add(cur);\\n\\t\\tvisited[cur] = true;\\n\\t\\twhile (!q.isEmpty()) {\\n\\t\\t\\tcur = q.poll();\\n\\t\\t\\tfor (Integer v : con[cur]) {\\n\\t\\t\\t\\tif (!visited[v]) {\\n\\t\\t\\t\\t\\tvisited[v] = true;\\n\\t\\t\\t\\t\\tq.add(v);\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n}\\n\\nstatic class Reader {\\n\\tstatic BufferedReader br;\\n\\tstatic StringTokenizer st;\\n\\tprivate int charIdx = 0;\\n\\tprivate String s;\\n\\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++)\\n\\t\\t\\ta[i] = nextInt();\\n\\t\\treturn...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"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.\\nimpor\",\"targets\":\"t java.io.DataInputStream;\\nimport java.io.FileInputStream;\\nimport java.io.IOException;\\nimport java.util.AbstractMap;\\nimport java.util.Comparator;\\nimport java.util.HashMap;\\nimport java.util.Map;\\nimport java.util.Map.Entry;\\nimport java.util.PriorityQueue;\\nimport java.util.*;\\nimport java.io.*;\\n\\n\\/\\/ Java Template Pramod Hosahalli...\\n@SuppressWarnings(\\\"unused\\\")\\npublic class Solution {\\n\\n\\tstatic FastReader in = new FastReader();\\n\\t\\/\\/static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));\\n\\tstatic int mod = 1000000007;\\n\\n\\tprivate static void go() throws Exception{\\n\\t\\tint n = in.ni();\\n\\t\\tlong[] a = new long[n];\\n\\t\\tlong[] b = new long[n-1];\\n\\t\\t\\n\\t\\tfor(int i = 0; i < n; i++){\\n\\t\\t\\ta[i] = in.nl();\\n\\t\\t\\tif(i > 0) b[i-1] = Math.abs(a[i] - a[i-1]);\\n\\t\\t}\\n\\t\\t\\n\\t\\tif(n == 1){\\n\\t\\t\\tprint(1, \\\"1\\\");\\n\\t\\t\\treturn;\\n\\t\\t}\\n\\n\\t\\tlong[][] f = SparseTable.precompute(b);\\n\\t\\tint maxima = 1;\\t\\t\\n\\t\\tfor(int j = 0; j < b.length; j++){\\n\\t\\t\\tif(f[0][j] == 1)continue;\\n\\t\\t\\tlong g = -1;\\n\\t\\t\\tint curr = j;\\n\\t\\t\\tfor(int p = f.length-1; p >= 0; p--){\\n\\t\\t\\t\\tif(curr == b.length)break;\\n\\t\\t\\t\\tif(f[p][curr] > 1 && (g == -1 || gcd(g, f[p][curr]) > 1)){\\n\\t\\t\\t\\t\\tif(g == -1) g = f[p][curr];\\n\\t\\t\\t\\t\\telse g = gcd(g, f[p][curr]);\\n\\t\\t\\t\\t\\tcurr = curr + (1 << p);\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\tmaxima = Math.max(maxima, curr - j + 1);\\n\\t\\t}\\n\\t\\tprint(1, maxima+\\\"\\\");\\n }\\n\\n\\tpublic static void main(String[] args) throws Exception {\\n\\t\\tint t = in.ni();\\n \\/\\/int t = pi(in.readLine());\\n\\t\\tfor(int _i = 1; _i <= t; _i++){\\n\\t\\t\\tgo();\\n\\t\\t}\\n\\t\\tin.close();\\n\\t}\\n\\n\\tstatic long mul(long a, long b) {\\n\\t\\treturn ((a % mod) * (b % mod)) % mod;\\n\\t}\\n\\n\\tstatic class FastReader {\\n\\t\\tfinal private int BUFFER_SIZE = 1 << 16;\\n\\t\\tprivate DataInputStream din;\\n\\t\\tprivate byte[] buffer;\\n\\t\\tprivate int bufferPointer, bytesRead;\\n\\n\\t\\tpublic FastReader() {\\n\\t\\t\\tdin = new DataInputStream(System.in);\\n\\t\\t\\tbuffer = new byte[BUFFER_SIZE];\\n\\t\\t\\tbufferPointer = bytesRead = 0;\\n\\t\\t}\\n\\n\\t\\tpublic FastReader(String file_name) throws IOException {\\n\\t\\t\\tdin = new DataInputStream(new FileInputStream(file_name));\\n\\t\\t\\tbuffer = new byte[BUFFER_SIZE];\\n\\t\\t\\tbufferPointer = bytesRead =...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alice 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\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\ntemplate \\ninline void cmin(T &x, T y) {\\n x = (x < y ? x : y);\\n}\\ntemplate \\ninline void cmax(T &x, T y) {\\n x = (x > y ? x : y);\\n}\\nchar buf[100000], *p1(buf), *p2(buf);\\ninline long long read() {\\n long long x = 0, f = 1;\\n char ch =\\n (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)\\n ? EOF\\n : *p1++);\\n while (!isdigit(ch)) {\\n if (ch == '-') f = 0;\\n ch = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)\\n ? EOF\\n : *p1++);\\n }\\n while (isdigit(ch)) {\\n x = (x << 1) + (x << 3) + (ch ^ 48);\\n ch = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)\\n ? EOF\\n : *p1++);\\n }\\n return f ? x : -x;\\n}\\nconst long long N = 2e5 + 1;\\nconst long long INF = 1e9 + 7;\\nlong long n, a[N];\\ninline void input() {\\n n = read();\\n for (long long i = 1; i <= n; i++) a[i] = read();\\n return;\\n}\\nbool dfs(const long long op, long long lef, long long rig, long long x,\\n long long y) {\\n if (lef == rig) return op;\\n if (x == 0 && y == 0) return op ^ 1;\\n if (a[lef] >= a[rig] && (x & 1)) return op;\\n if (a[rig] >= a[lef] && (y & 1)) return op;\\n if (a[lef] < a[rig]) return dfs(op ^ 1, lef + 1, rig, x - 1, y);\\n if (a[rig] < a[lef]) return dfs(op ^ 1, lef, rig - 1, x, y - 1);\\n if (a[lef] == a[rig]) return op ^ 1;\\n}\\ninline void work() {\\n long long lef = 1, rig = n, lt = 1, rt = 1;\\n while (a[lef] < a[lef + 1] && lef < n) lt++, lef++;\\n while (a[rig] < a[rig - 1] && rig > 1) rt++, rig--;\\n puts(dfs(0, 1, n, lt, rt) ? \\\"Bob\\\" : \\\"Alice\\\");\\n return;\\n}\\ninline void solve() {\\n input();\\n work();\\n return;\\n}\\nint main() {\\n solve();\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"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\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"def test():\\n #n = int(input(\\\"\\\"))\\n #a = list(map(int, input().split(\\\"\\\")))\\n t = int(input())\\n for _ in range(t):\\n d = [0, 0, 0]\\n s = input()\\n for c in s:\\n if c == 'A':\\n d[0] += 1\\n elif c == 'B':\\n d[1] += 1\\n else:\\n d[2] += 1\\n if d[0] + d[2] == d[1]:\\n print('YES')\\n else:\\n print('NO')\\n \\ntest()\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"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;\\nint N, arr[200005], l, r, x;\\nstring s;\\nbool lb, rb;\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cin >> N;\\n for (int i = 0; i < N; ++i) {\\n cin >> arr[i];\\n }\\n sort(arr, arr + N);\\n cin >> s;\\n lb = rb = s[0] == 'L';\\n for (int i = 1; i < N; ++i) {\\n x += s[i] != s[i - 1];\\n }\\n l = r = N - x - 1;\\n cout << arr[N - x - 1] << \\\" \\\" << s[0] << endl;\\n for (int i = 1; i < N; ++i) {\\n if (s[i] != s[i - 1]) {\\n cout << arr[++r] << \\\" \\\" << (\\\"RL\\\"[rb ^= 1]) << endl;\\n } else {\\n cout << arr[--l] << \\\" \\\" << (\\\"RL\\\"[lb ^= 1]) << endl;\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"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 cpp can you solve the prior task?\",\"targets\":\"#include \\n#pragma warning(disable : 4996)\\nusing namespace std;\\nint t, n, p, c[200005], d[200005];\\nlong long a[200005], b[200005], ans;\\nmap mm;\\ninline void updatec(int x) {\\n for (; x <= p; x += (x & -x)) ++c[x];\\n return;\\n}\\ninline int getc(int x) {\\n int res = 0;\\n for (; x; x -= (x & -x)) res += c[x];\\n return res;\\n}\\ninline void updated(int x) {\\n for (; x; x -= (x & -x)) ++d[x];\\n return;\\n}\\ninline int getd(int x) {\\n int res = 0;\\n for (; x <= p; x += (x & -x)) res += d[x];\\n return res;\\n}\\nint main() {\\n std::ios::sync_with_stdio(false);\\n std::cin.tie(0);\\n cin >> t;\\n while (t--) {\\n ans = p = 0;\\n mm.clear();\\n cin >> n;\\n memset(c, 0, sizeof c), memset(d, 0, sizeof d);\\n for (int i = 1; i <= n; i++) cin >> a[i], b[i] = a[i];\\n sort(b + 1, b + n + 1);\\n for (int i = 1; i <= n; i++)\\n if (!mm[b[i]]) mm[b[i]] = ++p;\\n for (int i = 1; i <= n; i++) {\\n if (getc(mm[a[i]] - 1) < getd(mm[a[i]] + 1)) {\\n ans += getc(mm[a[i]] - 1);\\n } else {\\n ans += getd(mm[a[i]] + 1);\\n }\\n updatec(mm[a[i]]), updated(mm[a[i]]);\\n }\\n cout << ans << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"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...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n long long n, m, sum = 0;\\n cin >> n;\\n std::vector h(n);\\n for (long long i = 0; i < n; i++) {\\n cin >> h[i];\\n sum += h[i];\\n }\\n sort(h.begin(), h.end());\\n cin >> m;\\n while (m--) {\\n long long x, y;\\n cin >> x >> y;\\n long long cost = 0;\\n auto idx = lower_bound(h.begin(), h.end(), x);\\n if (idx == h.end()) {\\n cost = x - h[n - 1];\\n if (sum - h[n - 1] - y < 0) cost += y - sum + h[n - 1];\\n cout << cost << endl;\\n continue;\\n }\\n if (*idx == x) {\\n cost = max((long long)0, y - sum + *idx);\\n std::cout << cost << std::endl;\\n continue;\\n }\\n cost = max((long long)0, y - sum + *idx);\\n if (idx == h.begin()) {\\n std::cout << cost << std::endl;\\n continue;\\n }\\n long long cost2 = 0;\\n --idx;\\n cost2 = x - *idx;\\n cost2 += max((long long)0, y - sum + *idx);\\n cost = min(cost, cost2);\\n cout << cost << endl;\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Alice and Bob have received three big piles of candies as a gift. Now they want to divide these candies as fair as possible. To do this, Alice takes one pile of candies, then Bob takes one of the other two piles. The last pile is split between Alice and Bob as they want: for example, it is possible that Alice takes the whole pile, and Bob gets nothing from it.\\n\\nAfter taking the candies from the piles, if Alice has more candies than Bob, she discards some candies so that the number of candies she has is equal to the number of candies Bob has. Of course, Bob does the same if he has more candies.\\n\\nAlice and Bob want to have as many candies as possible, and they plan the process of dividing candies accordingly. Please calculate the maximum number of candies Alice can have after this division process (of course, Bob will have the same number of candies).\\n\\nYou have to answer q independent queries.\\n\\nLet's see the following example: [1, 3, 4]. Then Alice can choose the third pile, Bob can take the second pile, and then the only candy from the first pile goes to Bob — then Alice has 4 candies, and Bob has 4 candies.\\n\\nAnother example is [1, 10, 100]. Then Alice can choose the second pile, Bob can choose the first pile, and candies from the third pile can be divided in such a way that Bob takes 54 candies, and Alice takes 46 candies. Now Bob has 55 candies, and Alice has 56 candies, so she has to discard one candy — and after that, she has 55 candies too.\\n\\nInput\\n\\nThe first line of the input contains one integer q (1 ≤ q ≤ 1000) — the number of queries. Then q queries follow.\\n\\nThe only line of the query contains three integers a, b and c (1 ≤ a, b, c ≤ 10^{16}) — the number of candies in the first, second and third piles correspondingly.\\n\\nOutput\\n\\nPrint q lines. The i-th line should contain the answer for the i-th query — the maximum number of candies Alice can have after the division, if both Alice and Bob act optimally (of course, Bob will have the same number of candies).\\n\\nExample\\n\\nInput\\n\\n\\n4\\n1 3 4\\n1 10...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int t;\\n cin >> t;\\n while (t--) {\\n long long a, b, c;\\n cin >> a >> b >> c;\\n long long sum = a + b + c;\\n if (sum % 2 == 0) {\\n cout << sum \\/ 2 << \\\"\\\\n\\\";\\n } else {\\n cout << (sum - 1) \\/ 2 << \\\"\\\\n\\\";\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"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 \\n#pragma GCC optimize(\\\"unroll-loops\\\")\\nusing namespace std;\\nconstexpr int N = 3e3;\\nuint16_t a[N], lst[N], nxt[N], cnxt[20], 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 = 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 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 }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Decimal numbers are a common notation system currently in use and use ten symbols 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 to represent all numbers.\\n\\nBinary numbers are a popular notation in the computer world and use two symbols, 0 and 1, to represent all numbers.\\n\\nOnly the four numbers 0, 1, 2, and 3 are used in quaternary numbers. In quaternary numbers, when the number is incremented from 0, it will be carried to the next digit when it reaches 4. Therefore, the decimal number 4 is carried to the expression \\\"10\\\".\\n\\nDecimal | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | ...\\n--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |- ---\\nBinary | 0 | 1 | 10 | 11 | 100 | 101 | 110 | 111 | 1000 | 101 | 1010 | ...\\nQuadrant | 0 | 1 | 2 | 3 | 10 | 11 | 12 | 13 | 20 | 21 | 22 | ...\\n\\n\\n\\nIn Hawaii, fish and taro were counted between fingers in the old days, so it seems that they used quaternary numbers instead of decimal numbers.\\n\\nCreate a program that converts the integer n input in decimal to decimal and outputs it.\\n\\n\\n\\nInput\\n\\nA sequence of multiple datasets is given as input. The end of the input is indicated by a single line of -1. One integer n (0 ≤ n ≤ 1000000) is given on one row for each dataset.\\n\\nThe number of datasets does not exceed 2000.\\n\\nOutput\\n\\nThe result of conversion to quaternary number for each input data set is output on one line.\\n\\nExample\\n\\nInput\\n\\n7\\n4\\n0\\n12\\n10\\n10000\\n-1\\n\\n\\nOutput\\n\\n13\\n10\\n0\\n30\\n22\\n2130100\\n#incl\",\"targets\":\"ude \\n\\nint main() {\\n int n, i;\\n int digits[20];\\n while (1) {\\n scanf(\\\"%d\\\", &n);\\n if (n < 0) {\\n return 0;\\n }\\n if (n == 0) {\\n puts(\\\"0\\\");\\n continue;\\n }\\n for (i = 0; n > 0; ++i) {\\n digits[i] = n % 4;\\n n \\/= 4;\\n }\\n while (i > 0) {\\n printf(\\\"%d\\\", digits[i - 1]);\\n --i;\\n }\\n puts(\\\"\\\");\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A subsequence of a string S is a string that can be obtained by deleting zero or more characters from S without changing the order of the remaining characters. For example, `arc`, `artistic` and (an empty string) are all subsequences of `artistic`; `abc` and `ci` are not.\\n\\nYou are given a string A consisting of lowercase English letters. Find the shortest string among the strings consisting of lowercase English letters that are not subsequences of A. If there are more than one such string, find the lexicographically smallest one among them.\\n\\nConstraints\\n\\n* 1 \\\\leq |A| \\\\leq 2 \\\\times 10^5\\n* A consists of lowercase English letters.\\n\\nInput\\n\\nInput is given from Standard Input in the following format:\\n\\n\\nA\\n\\n\\nOutput\\n\\nPrint the lexicographically smallest string among the shortest strings consisting of lowercase English letters that are not subsequences of A.\\n\\nExamples\\n\\nInput\\n\\natcoderregularcontest\\n\\n\\nOutput\\n\\nb\\n\\n\\nInput\\n\\nabcdefghijklmnopqrstuvwxyz\\n\\n\\nOutput\\n\\naa\\n\\n\\nInput\\n\\nfrqnvhydscshfcgdemurlfrutcpzhopfotpifgepnqjxupnskapziurswqazdwnwbgdhyktfyhqqxpoidfhjdakoxraiedxskywuepzfniuyskxiyjpjlxuqnfgmnjcvtlpnclfkpervxmdbvrbrdn\\n\\n\\nOutput\\n\\naca\\nUsing python3 can you solve the prior task?\",\"targets\":\"import os\\nimport sys\\n\\nif os.getenv(\\\"LOCAL\\\"):\\n sys.stdin = open(\\\"_in.txt\\\", \\\"r\\\")\\n\\nsys.setrecursionlimit(2147483647)\\nINF = float(\\\"inf\\\")\\nIINF = 10 ** 18\\nMOD = 10 ** 9 + 7\\n\\nS = sys.stdin.readline().rstrip()\\nA = [ord(c) - ord('a') for c in S]\\nN = len(S)\\n\\n# 答えの文字列の長さ\\nl = 0\\n# その文字以降で、何文字までの任意文字列を作れるか\\nlengths = [0] * N\\ncounts = [0] * 26\\nfor i, a in reversed(list(enumerate(A))):\\n counts[a] += 1\\n lengths[i] = l\\n if min(counts) == 1:\\n counts = [0] * 26\\n l += 1\\nans_size = l + 1\\n\\n# 文字ごとの次のインデックス\\ngraph = [[-1] * 26 for _ in range(N)]\\npos = [-1] * 26\\nfor i, a in reversed(list(enumerate(A))):\\n graph[i] = pos[:]\\n pos[a] = i\\ninitials = pos\\n\\n\\ndef solve(size, i=None):\\n # i 番目から始まり、長さ size である、部分列でない文字列\\n if i is None:\\n pos = initials\\n else:\\n pos = graph[i]\\n\\n if size == 1:\\n return chr(pos.index(-1) + ord('a'))\\n\\n size -= 1\\n for ci, i in enumerate(pos):\\n if lengths[i] < size:\\n c = chr(ci + ord('a'))\\n return c + solve(size, i)\\n assert False\\n\\n\\nprint(solve(ans_size))\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"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] \\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nint n, i, j, a[100001], b[515], c[515], k;\\nint main() {\\n scanf(\\\"%d\\\", &n);\\n for (i = 1; i <= n; i = i + 1) scanf(\\\"%d\\\", &a[i]);\\n for (i = 1; i <= 511; i = i + 1) b[i] = 99999999;\\n for (i = 1; i <= n; i = i + 1) {\\n b[a[i]] = min(b[a[i]], a[i]);\\n for (j = 0; j <= 511; j = j + 1) {\\n if (b[j] < a[i] && b[j] != 99999999) b[j ^ a[i]] = min(b[j ^ a[i]], a[i]);\\n }\\n }\\n for (i = 0; i <= 511; i = i + 1)\\n if (b[i] != 99999999) c[++k] = i;\\n printf(\\\"%d\\\\n\\\", k);\\n for (i = 1; i <= k; i = i + 1) printf(\\\"%d \\\", c[i]);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"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;\\nint main() {\\n ios::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n int t;\\n cin >> t;\\n while (t--) {\\n int n;\\n cin >> n;\\n string a1;\\n string a2;\\n cin >> a1;\\n cin >> a2;\\n int sum = 0;\\n int check = 2;\\n for (int i = 0; i < n; i++) {\\n if ((a1[i] == '0' && a2[i] == '1') || (a2[i] == '0' && a1[i] == '1')) {\\n sum += 2;\\n check = 2;\\n } else if ((a1[i] == '0' && a2[i] == '0')) {\\n if (check == 1) {\\n sum += 2;\\n check = 3;\\n } else {\\n sum++;\\n check = 0;\\n }\\n } else if (a1[i] == '1' && a2[i] == '1') {\\n if (check == 0) {\\n sum++;\\n check = 3;\\n } else\\n check = 1;\\n }\\n }\\n cout << sum << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"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...\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\ntemplate \\ninline bool mnto(T& a, T b) {\\n return a > b ? a = b, 1 : 0;\\n}\\ntemplate \\ninline bool mxto(T& a, T b) {\\n return a < b ? a = b, 1 : 0;\\n}\\nint t;\\nint a, b;\\nvector ans;\\nint main() {\\n scanf(\\\"%d\\\", &t);\\n while (t--) {\\n scanf(\\\"%d%d\\\", &a, &b);\\n if (a > b) swap(a, b);\\n int n = a + b;\\n ans.clear();\\n for (int i = 0; i < a + 1; i++) {\\n int k = 2 * i + n \\/ 2 - a;\\n if (k < 0 || k > n) continue;\\n ans.push_back(k);\\n }\\n if (n % 2 == 1) {\\n for (int i = 0; i < a + 1; i++) {\\n int k = 2 * i + (n + 1) \\/ 2 - a;\\n if (k < 0 || k > n) continue;\\n ans.push_back(k);\\n }\\n }\\n sort(ans.begin(), ans.end());\\n printf(\\\"%d\\\\n\\\", (int)ans.size());\\n for (int i : ans) {\\n printf(\\\"%d \\\", i);\\n }\\n printf(\\\"\\\\n\\\");\\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 JAVA?\\nMonocarp 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.\",\"targets\":\"import java.io.OutputStream;\\nimport java.io.IOException;\\nimport java.io.InputStream;\\nimport java.io.PrintWriter;\\nimport java.io.BufferedReader;\\nimport java.io.InputStreamReader;\\nimport java.util.*;\\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 solve(in, out);\\n out.close();\\n }\\n\\n static String reverse(String s) {\\n return (new StringBuilder(s)).reverse().toString();\\n }\\n\\n static void sieveOfEratosthenes(int n, int factors[], ArrayList ar) \\n { \\n factors[1]=1;\\n int p;\\n for(p = 2; p*p <=n; p++) \\n { \\n if(factors[p] == 0) \\n { \\n ar.add(p);\\n factors[p]=p;\\n for(int i = p*p; i <= n; i += p) \\n if(factors[i]==0)\\n factors[i] = p; \\n } \\n } \\n for(;p<=n;p++){\\n if(factors[p] == 0) \\n { \\n factors[p] = p;\\n ar.add(p);\\n } \\n }\\n }\\n\\n static void sort(int ar[]) {\\n int n = ar.length;\\n ArrayList a = new ArrayList<>();\\n for (int i = 0; i < n; i++)\\n a.add(ar[i]);\\n Collections.sort(a);\\n for (int i = 0; i < n; i++)\\n ar[i] = a.get(i);\\n }\\n\\n static void sort1(long ar[]) {\\n int n = ar.length;\\n ArrayList a = new ArrayList<>();\\n for (int i = 0; i < n; i++)\\n a.add(ar[i]);\\n Collections.sort(a);\\n for (int i = 0; i < n; i++)\\n ar[i] = a.get(i);\\n }\\n\\n static void sort2(char ar[]) {\\n int n = ar.length;\\n ArrayList a = new ArrayList<>();\\n for (int i = 0; i < n; i++)\\n a.add(ar[i]);\\n Collections.sort(a);\\n for (int i = 0; i < n; i++)\\n ar[i] = a.get(i);\\n }\\n\\n...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"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 CPP.\",\"targets\":\"#include \\nusing namespace std;\\nvoid solve() {\\n long long n;\\n cin >> n;\\n vector> a, ans(n), like, not_like;\\n for (long long i = 0; i < n; i++) {\\n long long x;\\n cin >> x;\\n a.push_back(make_pair(x, i));\\n }\\n string s;\\n cin >> s;\\n for (int i = 0; i < s.size(); i++)\\n if (s[i] == '1') like.push_back(make_pair(a[i].first, a[i].second));\\n for (int i = 0; i < s.size(); i++)\\n if (s[i] == '0') not_like.push_back(make_pair(a[i].first, a[i].second));\\n sort(like.rbegin(), like.rend());\\n sort(not_like.rbegin(), not_like.rend());\\n long long t = n;\\n for (auto i : like) {\\n ans[i.second].first = t;\\n --t;\\n }\\n for (auto i : not_like) {\\n ans[i.second].first = t;\\n --t;\\n }\\n for (auto i : ans) cout << i.first << \\\" \\\";\\n cout << \\\"\\\\n\\\";\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n long long 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\":\"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).\\nUsing python3 can you solve the prior task?\",\"targets\":\"n,m =[int(x) for x in input().split()]\\nres = 0\\nwhile(n>0 and m>0 and n+m>=3):\\n if m > n:\\n \\n m -= 2\\n n -= 1\\n else:\\n m -= 1\\n n -= 2\\n res += 1\\nprint(res)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in PYTHON3?\\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 < … Points (-5, -1), (1, 5), (0, 5), (-5, 0) determine the smallest region with double area of 11. \\n\\nIn the second example, it's optimal to make cuts between the following pairs of vertices: \\n\\n * (2, -1) and (0, 2), \\n * (2, -1) and (1, 0), \\n * (-1, 0) and (0, 2). \\n\\n Points (2, -2), (2, -1), (-1, 0) determine one of the smallest regions with double area of 3. \\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nusing ll = long long;\\nstruct P {\\n ll x, y;\\n P(ll xx = 0, ll yy = 0) { x = xx, y = yy; }\\n P operator-(P r) { return P(x - r.x, y - r.y); }\\n} p[205];\\nll Cross(P A, P B) { return A.x * B.y - A.y * B.x; }\\npair dp[205][205];\\nint n, t;\\nint main() {\\n ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);\\n cin >> n >> t;\\n for (int i = 1; i <= n; i += 1) {\\n cin >> p[i].x >> p[i].y;\\n }\\n ll lo = -1e18, hi = 1e18, ans = -1e18;\\n while (hi >= lo) {\\n ll mid = lo + hi >> 1;\\n for (int len = 2; len <= n; len += 1) {\\n for (int l = 1; l + len - 1 <= n; l += 1) {\\n int r = l + len - 1;\\n if (len == 2)\\n dp[l][r] = make_pair(0, 0);\\n else {\\n dp[l][r] = make_pair(-1000000000, 0);\\n for (int k = l + 1; k < r; k += 1) {\\n int nk = dp[l][k].first + dp[k][r].first;\\n ll area = dp[l][k].second + dp[k][r].second +\\n abs(Cross(p[l] - p[r], p[k] - p[r]));\\n if (area >= mid) {\\n area = 0;\\n nk += 1;\\n }\\n dp[l][r] = max(dp[l][r], make_pair(nk, area));\\n }\\n }\\n }\\n }\\n if (dp[1][n].first >= t + 1) {\\n lo = mid + 1;\\n ans = mid;\\n } else\\n hi = mid - 1;\\n }\\n cout << ans << endl;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Let n be a positive integer. Let a, b, c be nonnegative integers such that a + b + c = n.\\n\\nAlice and Bob are gonna play rock-paper-scissors n times. Alice knows the sequences of hands that Bob will play. However, Alice has to play rock a times, paper b times, and scissors c times.\\n\\nAlice wins if she beats Bob in at least ⌈ n\\/2 ⌉ (n\\/2 rounded up to the nearest integer) hands, otherwise Alice loses.\\n\\nNote that in rock-paper-scissors:\\n\\n * rock beats scissors; \\n * paper beats rock; \\n * scissors beat paper. \\n\\n\\n\\nThe task is, given the sequence of hands that Bob will play, and the numbers a, b, c, determine whether or not Alice can win. And if so, find any possible sequence of hands that Alice can use to win.\\n\\nIf there are multiple answers, print any of them.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases.\\n\\nThen, t testcases follow, each consisting of three lines: \\n\\n * The first line contains a single integer n (1 ≤ n ≤ 100). \\n * The second line contains three integers, a, b, c (0 ≤ a, b, c ≤ n). It is guaranteed that a + b + c = n. \\n * The third line contains a string s of length n. s is made up of only 'R', 'P', and 'S'. The i-th character is 'R' if for his i-th Bob plays rock, 'P' if paper, and 'S' if scissors. \\n\\nOutput\\n\\nFor each testcase: \\n\\n * If Alice cannot win, print \\\"NO\\\" (without the quotes). \\n * Otherwise, print \\\"YES\\\" (without the quotes). Also, print a string t of length n made up of only 'R', 'P', and 'S' — a sequence of hands that Alice can use to win. t must contain exactly a 'R's, b 'P's, and c 'S's. \\n * If there are multiple answers, print any of them. \\n\\n\\n\\nThe \\\"YES\\\" \\/ \\\"NO\\\" part of the output is case-insensitive (i.e. \\\"yEs\\\", \\\"no\\\" or \\\"YEs\\\" are all valid answers). Note that 'R', 'P' and 'S' are case-sensitive.\\n\\nExample\\n\\nInput\\n\\n\\n2\\n3\\n1 1 1\\nRPS\\n3\\n3 0 0\\nRPS\\n\\n\\nOutput\\n\\n\\nYES\\nPSR\\nNO\\n\\nNote\\n\\nIn the first testcase, in the first hand, Alice plays paper and Bob plays rock, so Alice beats Bob. In the second hand, Alice plays scissors and Bob plays paper, so Alice...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int T, n, r, p, sc, win;\\n char s[105], t[105];\\n scanf(\\\"%d\\\", &T);\\n while (T--) {\\n win = 0;\\n scanf(\\\"%d%d%d%d%s\\\", &n, &r, &p, &sc, s);\\n for (int i = 0; i < n; ++i) t[i] = '-';\\n t[n] = '\\\\0';\\n for (int i = 0; i < n; ++i) {\\n if (s[i] == 'R') {\\n if (p > 0) t[i] = 'P', --p, ++win;\\n } else if (s[i] == 'P') {\\n if (sc > 0) t[i] = 'S', --sc, ++win;\\n } else if (s[i] == 'S') {\\n if (r > 0) t[i] = 'R', --r, ++win;\\n }\\n }\\n for (int i = 0; i < n; ++i) {\\n if (t[i] != '-')\\n continue;\\n else if (r > 0)\\n t[i] = 'R', --r;\\n else if (p > 0)\\n t[i] = 'P', --p;\\n else\\n t[i] = 'S', --sc;\\n }\\n if (win >= (n + 1) \\/ 2) {\\n printf(\\\"YES\\\\n\\\");\\n printf(\\\"%s\\\\n\\\", t);\\n } else {\\n printf(\\\"NO\\\\n\\\");\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nGiven are an integer K and integers a_1,\\\\dots, a_K. Determine whether a sequence P satisfying below exists. If it exists, find the lexicographically smallest such sequence.\\n\\n* Every term in P is an integer between 1 and K (inclusive).\\n* For each i=1,\\\\dots, K, P contains a_i occurrences of i.\\n* For each term in P, there is a contiguous subsequence of length K that contains that term and is a permutation of 1,\\\\dots, K.\\n\\nConstraints\\n\\n* 1 \\\\leq K \\\\leq 100\\n* 1 \\\\leq a_i \\\\leq 1000 \\\\quad (1\\\\leq i\\\\leq K)\\n* a_1 + \\\\dots + a_K\\\\leq 1000\\n* All values in input are integers.\\n\\nInput\\n\\nInput is given from Standard Input in the following format:\\n\\n\\nK\\na_1 a_2 \\\\dots a_K\\n\\n\\nOutput\\n\\nIf there is no sequence satisfying the conditions, print `-1`. Otherwise, print the lexicographically smallest sequence satisfying the conditions.\\n\\nExamples\\n\\nInput\\n\\n3\\n2 4 3\\n\\n\\nOutput\\n\\n2 1 3 2 2 3 1 2 3\\n\\n\\nInput\\n\\n4\\n3 2 3 2\\n\\n\\nOutput\\n\\n1 2 3 4 1 3 1 2 4 3\\n\\n\\nInput\\n\\n5\\n3 1 4 1 5\\n\\n\\nOutput\\n\\n-1\",\"targets\":\"#include \\n\\nusing namespace std;\\n\\nconst int MX = 100, MP = 100000;\\n\\nint k, c[MX], p[MP], lastPos[MX];\\n\\nbool check(int a, int b, int n) {\\n\\tfor (int i = 0; i < k; i++)\\n\\t\\tfor (int j = 0; j < k; j++) {\\n\\t\\t\\tif (i == j) continue;\\n\\t\\t\\t\\n\\t\\t\\tint cntI = c[i];\\n\\t\\t\\tint cntJ = c[j];\\n\\t\\t\\t\\n\\t\\t\\tif (lastPos[i] >= b) {\\n\\t\\t\\t\\t\\/\\/ need to cover last 'i'\\n\\t\\t\\t\\t\\n\\t\\t\\t\\tif (lastPos[j] >= a) {\\n\\t\\t\\t\\t\\t\\/\\/ last 'j' can be used to cover last 'i'\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\telse {\\n\\t\\t\\t\\t\\t\\/\\/ last 'j' can not be used anymore\\n\\t\\t\\t\\t\\tcntI++;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\t\\n\\t\\t\\tif (lastPos[j] > lastPos[i] && lastPos[j] >= a) {\\n\\t\\t\\t\\t\\/\\/ can use last 'j' to cover the next 'i'\\n\\t\\t\\t\\tcntI--;\\n\\t\\t\\t}\\n\\t\\t\\t\\n\\t\\t\\tif (cntI > 2 * cntJ) {\\n\\/\\/\\t\\t\\t\\tprintf(\\\"\\\\t%d %d %d -> %d %d | %d %d\\\\n\\\", a, b, n, i + 1, j + 1, cntI, cntJ);\\n\\t\\t\\t\\treturn false;\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\n\\treturn true;\\n}\\n\\npair append(int a, int b, int n, int x) {\\n\\tp[n] = x;\\n\\tc[x]--;\\n\\ta = max(lastPos[x] + 1, a);\\n\\tlastPos[x] = n;\\n\\tn++;\\n\\t\\n\\tif (n - a == k) {\\n\\t\\ta++;\\n\\t\\tb = n;\\n\\t}\\n\\t\\n\\treturn {a, b};\\n}\\n\\nbool tryAppend(int a, int b, int n, int x) {\\n\\tint xPos = lastPos[x];\\n\\t\\n\\tif (xPos >= b) return false;\\n\\t\\n\\tint aa, bb;\\n\\ttie(aa, bb) = append(a, b, n, x);\\n\\t\\n\\tbool res = check(aa, bb, n + 1);\\n\\t\\n\\tlastPos[x] = xPos;\\n\\tc[x]++;\\n\\t\\n\\treturn res;\\n}\\n\\nint main() {\\n\\tignore = scanf(\\\"%d\\\", &k);\\n\\tfor (int i = 0; i < k; i++) ignore = scanf(\\\"%d\\\", c + i);\\n\\t\\n\\tfill(lastPos, lastPos + k, -1);\\n\\t\\n\\tif (check(0, 0, 0) == false) {\\n\\t\\tprintf(\\\"%d\\\\n\\\", -1);\\n\\t\\t\\n\\t\\treturn 0;\\n\\t}\\n\\t\\n\\tint a = 0, b = 0, n = 0;\\n\\twhile (*max_element(c, c + k) > 0) {\\n\\t\\tint x = 0;\\n\\t\\twhile (x < k && tryAppend(a, b, n, x) == false) x++;\\n\\t\\t\\n\\t\\tif (x == k) {\\n\\t\\t\\tprintf(\\\"Fail\\\\n\\\");\\n\\t\\t\\treturn 0;\\n\\t\\t}\\n\\t\\t\\n\\t\\ttie(a, b) = append(a, b, n, x);\\n\\t\\tn++;\\n\\t\\t\\n\\t\\tprintf(\\\"%d \\\", x + 1);\\n\\t}\\n\\t\\n\\tprintf(\\\"\\\\n\\\");\\n\\t\\n\\treturn 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"As you know, an undirected connected graph with n nodes and n - 1 edges is called a tree. You are given an integer d and a tree consisting of n nodes. Each node i has a value ai associated with it.\\n\\nWe call a set S of tree nodes valid if following conditions are satisfied:\\n\\n 1. S is non-empty.\\n 2. S is connected. In other words, if nodes u and v are in S, then all nodes lying on the simple path between u and v should also be presented in S.\\n 3. .\\n\\n\\n\\nYour task is to count the number of valid sets. Since the result can be very large, you must print its remainder modulo 1000000007 (109 + 7).\\n\\nInput\\n\\nThe first line contains two space-separated integers d (0 ≤ d ≤ 2000) and n (1 ≤ n ≤ 2000).\\n\\nThe second line contains n space-separated positive integers a1, a2, ..., an(1 ≤ ai ≤ 2000).\\n\\nThen the next n - 1 line each contain pair of integers u and v (1 ≤ u, v ≤ n) denoting that there is an edge between u and v. It is guaranteed that these edges form a tree.\\n\\nOutput\\n\\nPrint the number of valid sets modulo 1000000007.\\n\\nExamples\\n\\nInput\\n\\n1 4\\n2 1 3 2\\n1 2\\n1 3\\n3 4\\n\\n\\nOutput\\n\\n8\\n\\n\\nInput\\n\\n0 3\\n1 2 3\\n1 2\\n2 3\\n\\n\\nOutput\\n\\n3\\n\\n\\nInput\\n\\n4 8\\n7 8 7 5 4 6 4 10\\n1 6\\n1 2\\n5 8\\n1 3\\n3 5\\n6 7\\n3 4\\n\\n\\nOutput\\n\\n41\\n\\nNote\\n\\nIn the first sample, there are exactly 8 valid sets: {1}, {2}, {3}, {4}, {1, 2}, {1, 3}, {3, 4} and {1, 3, 4}. Set {1, 2, 3, 4} is not valid, because the third condition isn't satisfied. Set {1, 4} satisfies the third condition, but conflicts with the second condition.\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst int MAX = 2005, MOD = 1e9 + 7;\\nint n, d, C[MAX];\\nvector G[MAX];\\nlong long dfs(int nod, int p, int val, int ni) {\\n if (C[nod] < val || C[nod] > val + d || (C[nod] == val && nod < ni)) return 1;\\n long long ans = 1;\\n for (int i = 0; i < G[nod].size(); i++) {\\n int newn = G[nod][i];\\n if (newn == p) continue;\\n ans = (ans * (dfs(newn, nod, val, ni))) % MOD;\\n }\\n return ans + 1;\\n}\\nint main() {\\n scanf(\\\"%d%d\\\", &d, &n);\\n for (int i = 1; i <= n; i++) scanf(\\\"%d\\\", &C[i]);\\n for (int i = 1; i < n; i++) {\\n int a, b;\\n scanf(\\\"%d%d\\\", &a, &b);\\n G[a].push_back(b);\\n G[b].push_back(a);\\n }\\n long long sol = 0;\\n for (int i = 1; i <= n; i++) {\\n sol = (sol + dfs(i, -1, C[i], i)) % MOD;\\n sol = (sol - 1 + MOD) % MOD;\\n }\\n printf(\\\"%I64d\\\\n\\\", sol);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"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...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nlong long gcd(long long a, long long b) {\\n if (b == 0) return a;\\n return gcd(b, a % b);\\n}\\nvector> dir = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};\\nlong long mod = 1e9 + 7;\\nvoid solve() {\\n long long x, y;\\n cin >> x >> y;\\n string ans, a = to_string(x), s = to_string(y);\\n reverse(a.begin(), a.end()), reverse(s.begin(), s.end());\\n long long j = 0;\\n for (long long i = 0; i < a.size(); i++) {\\n if (a[i] > s[j]) {\\n long long c = a[i] - '0';\\n string temp;\\n if (j + 1 < s.size())\\n temp = s.substr(j, 2);\\n else {\\n cout << -1 << endl;\\n return;\\n }\\n reverse(temp.begin(), temp.end());\\n long long d = stoll(temp);\\n if (d - c > 9 || d - c < 0) {\\n cout << -1 << endl;\\n return;\\n }\\n ans.push_back(d - c + '0');\\n j += 2;\\n } else {\\n ans.push_back(s[j] - a[i] + '0');\\n j++;\\n }\\n }\\n if (j < s.size()) ans += s.substr(j);\\n reverse(ans.begin(), ans.end());\\n cout << stoll(ans) << endl;\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n ;\\n long long test = 1;\\n cin >> test;\\n while (test--) solve();\\n}\",\"language\":\"python\",\"split\":\"test\",\"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 \\nusing namespace std;\\nconst double eps = 1e-6;\\nint N;\\ndouble P;\\nbool check(int m) {\\n double x = double(N * (N - 1) * (N - 2)) \\/ 6.0;\\n double y = double(m * (m - 1) * (m - 2) \\/ 6) +\\n double(m * (m - 1) * (N - m) \\/ 2) +\\n double(m * (N - m) * (N - m - 1) \\/ 2) * 0.5;\\n double p = y \\/ x;\\n return (p >= P || fabs(P - p) <= eps);\\n}\\nint main() {\\n ios::sync_with_stdio(false);\\n cin.tie(0);\\n cin >> N >> P;\\n int l = 0, r = N;\\n int ans = l;\\n while (l <= r) {\\n int mid = (l + r) >> 1;\\n if (check(mid)) {\\n ans = mid;\\n r = mid - 1;\\n } else {\\n l = mid + 1;\\n }\\n }\\n cout << ans << '\\\\n';\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A sequence a0, a1, ..., at - 1 is called increasing if ai - 1 < ai for each i: 0 < i < t.\\n\\nYou are given a sequence b0, b1, ..., bn - 1 and a positive integer d. In each move you may choose one element of the given sequence and add d to it. What is the least number of moves required to make the given sequence increasing?\\n\\nInput\\n\\nThe first line of the input contains two integer numbers n and d (2 ≤ n ≤ 2000, 1 ≤ d ≤ 106). The second line contains space separated sequence b0, b1, ..., bn - 1 (1 ≤ bi ≤ 106).\\n\\nOutput\\n\\nOutput the minimal number of moves needed to make the sequence increasing.\\n\\nExamples\\n\\nInput\\n\\n4 2\\n1 3 3 2\\n\\n\\nOutput\\n\\n3\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nlong n, m, ar[20000], ans;\\nint main() {\\n cin >> n >> m;\\n for (int i = 1; i <= n; i++) cin >> ar[i];\\n for (int i = 2; i <= n; i++) {\\n long q = ar[i - 1] - ar[i] + 1;\\n if (q < 0)\\n continue;\\n else {\\n long t = q \\/ m + (q % m > 0);\\n ar[i] += t * m;\\n ans += t;\\n }\\n }\\n cout << ans << endl;\\n cin.get();\\n cin.get();\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\\n\\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\\n\\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \\n\\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \\n\\nInput\\n\\nThe first line contains integer n (1 ≤ n ≤ 106) — the number of compartments in the carriage. The second line contains n integers a1, a2, ..., an showing how many students ride in each compartment (0 ≤ ai ≤ 4). It is guaranteed that at least one student is riding in the train.\\n\\nOutput\\n\\nIf no sequence of swapping seats with other people leads to the desired result, print number \\\"-1\\\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\\n\\nExamples\\n\\nInput\\n\\n5\\n1 2 2 4 3\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n3\\n4 1 1\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n4\\n0 3 0 4\\n\\n\\nOutput\\n\\n0\\\":\",\"targets\":\"#include \\nint ans[4];\\nint main() {\\n int n;\\n scanf(\\\"%d\\\", &n);\\n int t;\\n int t1, t2;\\n int sum = 0;\\n for (int i = 1; i <= n; i++) {\\n scanf(\\\"%d\\\", &t);\\n if (t) ans[t]++;\\n }\\n for (int i = 1; i <= 4; i++) sum += i * ans[i];\\n if (sum < 3 || sum == 5) {\\n printf(\\\"-1\\\\n\\\");\\n return 0;\\n }\\n int tmp = 0;\\n while (ans[1] && ans[2]) {\\n ans[1]--;\\n ans[2]--;\\n ans[3]++;\\n tmp++;\\n }\\n if (ans[1] > 0) {\\n tmp += ans[1] - ans[1] \\/ 3;\\n if (ans[1] == 1 && ans[3] == 0) tmp++;\\n }\\n if (ans[2] > 0) {\\n tmp += ans[2] \\/ 3 * 2;\\n if (ans[2] % 3 == 1)\\n tmp++;\\n else if (ans[2] % 3 == 2)\\n tmp += 2;\\n if (ans[2] % 3 == 1 && ans[4] == 0) tmp++;\\n }\\n printf(\\\"%d\\\\n\\\", tmp);\\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 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\",\"targets\":\"#include \\n#pragma GCC optimize(\\\"Ofast\\\")\\n#pragma GCC target(\\\"avx2\\\")\\nusing namespace std;\\nvector sieve;\\nvector fact_dp;\\nlong long power(long long base, long long exponent, long long modulo_factor);\\nlong long modInverse(long long n, long long p);\\nlong long combinate(long long n, long long r, long long modulo_factor);\\nlong long gcd(long long num1, long long num2);\\nlong long lcm(long long num1, long long num2);\\nvoid seive(long long limit);\\nvector get_factors(int num);\\nlong long factorial(long long num, long long mod);\\nvoid solve();\\nbool doubleequal(double a, double b) {\\n if (abs(a - b) < 1e-9) return true;\\n return false;\\n}\\nlong long power(long long base, long long exponent, long long modulo_factor) {\\n long long x = base, y = exponent, p = modulo_factor;\\n long long res = 1;\\n x = x % p;\\n while (y > 0) {\\n if (y & 1) res = (res * x) % p;\\n y = y >> 1;\\n x = (x * x) % p;\\n }\\n return res;\\n}\\nlong long modInverse(long long n, long long p) { return power(n, p - 2, p); }\\nlong long combinate(long long n, long long r, long long modulo_factor) {\\n long long p = modulo_factor;\\n if (n < r) return 0;\\n if (r == 0) return 1;\\n return (factorial(n, p) * modInverse(factorial(r, p), p) % p *\\n modInverse(factorial(n - r, p), p) % p) %\\n p;\\n}\\nlong long permutate(long long n, long long r, long long modulo_factor) {\\n long long p = modulo_factor;\\n if (r == 0) return 1;\\n return (factorial(n, p) * modInverse(factorial(n - r, p), p)) % p;\\n}\\nlong long gcd(long long num1, long long num2) {\\n if (num1 == 0 || num2 == 0) return max(num1, num2);\\n if (num1 > num2) return gcd(num2, num1 % num2);\\n return gcd(num1, num2 % num1);\\n}\\nlong long lcm(long long num1, long long num2) {\\n return (num1 * num2) \\/ gcd(num1, num2);\\n}\\nvoid seive(long long limit) {\\n long long arr[limit + 1];\\n for (long long i = 0; i <= limit; i++) arr[i] = 0;\\n for (long long i = 2; i <= limit; i++) {\\n if (arr[i] == 0) {\\n ::sieve.push_back(i);\\n for (long long ptr = i * i; ptr <= limit; ptr...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Andrii is good in Math, but not in Programming. He is asking you to solve following problem: Given an integer number N and two sets of integer A and B. Let set A contain all numbers from 1 to N and set B contain all numbers from N + 1 to 2N. Multiset C contains all sums a + b such that a belongs to A and b belongs to B. Note that multiset may contain several elements with the same values. For example, if N equals to three, then A = {1, 2, 3}, B = {4, 5, 6} and C = {5, 6, 6, 7, 7, 7, 8, 8, 9}. Andrii has M queries about multiset C. Every query is defined by a single integer q. Andrii wants to know the number of times q is contained in C. For example, number 6 is contained two times, 1 is not contained in C at all. \\nPlease, help Andrii to answer all the queries.\\n \\n\\nInput\\n\\nThe first line of the input contains two integers N and M. Each of the next M line contains one integer q, the query asked by Andrii.\\n \\n\\nOutput\\nOutput the answer for each query in separate lines as in example.\\n \\n\\nConstraints\\n\\n1 ≤ N ≤ 10^9\\n1 ≤ M ≤ 10^5\\n1 ≤ q ≤ 3N\\n\\n \\n\\nExample\\nInput:\\n3 5\\n6\\n2\\n9\\n7\\n5\\nOutput:\\n2\\n0\\n1\\n3\\n1\\nUsing python can you solve the prior task?\",\"targets\":\"#!\\/usr\\/bin\\/env python\\nimport sys\\nfrom collections import defaultdict\\n\\ndef multiset(A, B):\\n ret = []\\n for a in A:\\n for b in B:\\n ret.append(a+b)\\n ret.sort()\\n return ret\\n\\ndef counts(A):\\n ret = defaultdict(lambda: 0)\\n for a in A:\\n ret[a] += 1\\n return sorted(ret.items())\\n\\n#ranges:\\n# N + 2 to 2N + 1: val - N - 1\\n# 2N + 2 to 3N: N - (val - 2N - 1)\\n\\ndef solve(N, val):\\n if val >= N + 2 and val <= 2 * N + 1:\\n return val - N - 1\\n elif val >= 2 * N + 2 and val <= 3 * N:\\n return 3 * N + 1 - val\\n else:\\n return 0\\n\\nif __name__ == '__main__':\\n N, M = map(int, sys.stdin.readline().strip().split())\\n for m in xrange(M):\\n val = int(sys.stdin.readline().strip())\\n print solve(N, val)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"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\\n# imp\",\"targets\":\"ort collections\\n# import random\\n# import math\\n# from collections import defaultdict\\n# import itertools\\n# from sys import stdin, stdout\\nimport sys\\n# import operator\\n# from decimal import Decimal\\n\\n# sys.setrecursionlimit(10**6)\\n\\np2D = lambda x: print(*x, sep=\\\"\\\\n\\\")\\ndef II(): return int(sys.stdin.buffer.readline())\\ndef MI(): return map(int, sys.stdin.buffer.readline().split())\\ndef LI(): return list(map(int, sys.stdin.buffer.readline().split()))\\ndef LLI(rows_number): return [LI() for _ in range(rows_number)]\\ndef BI(): return sys.stdin.buffer.readline().rstrip()\\ndef SI(): return sys.stdin.buffer.readline().rstrip().decode()\\ndef li(): return [int(i) for i in input().split()]\\ndef lli(rows): return [li() for _ in range(rows)]\\ndef si(): return input()\\ndef ii(): return int(input())\\ndef ins(): return input().split()\\n\\n\\ndef solve():\\n m = II();a = []\\n for i in range(2): a.append(LI())\\n t1 = [0];t3 = [0]; tt = []\\n for i in range(m - 1): t1.append(t1[-1] + a[0][-1 - i])\\n t1.reverse()\\n for i in range(m - 1): t3.append(t3[-1] + a[1][i])\\n for i in range(m): tt.append(max(t3[i], t1[i]))\\n return min(tt) if len(tt) > 0 else 0\\n\\ndef main():\\n #for _ in range(II()):\\n for _ in range(II()):\\n sys.stdout.write(str(solve()) + \\\"\\\\n\\\")\\n\\n\\n # z += str(ans) + '\\\\n'\\n # print(len(ans), ' '.join(map(str, ans)), sep='\\\\n')\\n # stdout.write(z)\\n\\n\\n# for interactive problems\\n# print(\\\"? {} {}\\\".format(l,m), flush=True)\\n# or print this after each print statement\\n# sys.stdout.flush()\\n\\n\\nif __name__ == \\\"__main__\\\":\\n main()\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Pasha has two hamsters: Arthur and Alexander. Pasha put n apples in front of them. Pasha knows which apples Arthur likes. Similarly, Pasha knows which apples Alexander likes. Pasha doesn't want any conflict between the hamsters (as they may like the same apple), so he decided to distribute the apples between the hamsters on his own. He is going to give some apples to Arthur and some apples to Alexander. It doesn't matter how many apples each hamster gets but it is important that each hamster gets only the apples he likes. It is possible that somebody doesn't get any apples.\\n\\nHelp Pasha distribute all the apples between the hamsters. Note that Pasha wants to distribute all the apples, not just some of them.\\n\\nInput\\n\\nThe first line contains integers n, a, b (1 ≤ n ≤ 100; 1 ≤ a, b ≤ n) — the number of apples Pasha has, the number of apples Arthur likes and the number of apples Alexander likes, correspondingly.\\n\\nThe next line contains a distinct integers — the numbers of the apples Arthur likes. The next line contains b distinct integers — the numbers of the apples Alexander likes.\\n\\nAssume that the apples are numbered from 1 to n. The input is such that the answer exists.\\n\\nOutput\\n\\nPrint n characters, each of them equals either 1 or 2. If the i-h character equals 1, then the i-th apple should be given to Arthur, otherwise it should be given to Alexander. If there are multiple correct answers, you are allowed to print any of them.\\n\\nExamples\\n\\nInput\\n\\n4 2 3\\n1 2\\n2 3 4\\n\\n\\nOutput\\n\\n1 1 2 2\\n\\n\\nInput\\n\\n5 5 2\\n3 4 1 2 5\\n2 3\\n\\n\\nOutput\\n\\n1 1 1 1 1\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int n, a, b, i, j, c[102], d[102], flag;\\n while (cin >> n >> a >> b) {\\n flag = 0;\\n for (i = 1; i <= a; i++) cin >> c[i];\\n for (j = 1; j <= b; j++) cin >> d[j];\\n for (i = 1; i <= n; i++) {\\n for (j = 1; j <= a; j++)\\n if (c[j] == i) {\\n cout << \\\"1\\\"\\n << \\\" \\\";\\n flag = 1;\\n break;\\n }\\n if (flag == 1) {\\n flag = 0;\\n continue;\\n }\\n for (j = 1; j <= b; j++)\\n if (d[j] == i) {\\n cout << \\\"2\\\"\\n << \\\" \\\";\\n flag = 1;\\n break;\\n }\\n flag = 0;\\n }\\n cout << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Chef and Roma are playing a game. Rules of the game are quite simple.\\nInitially there are N piles of stones on the table.\\nIn each turn, a player can choose one pile and remove it from the table.\\nEach player want to maximize the total number of stones removed by him.\\nChef takes the first turn.\\n\\n\\nPlease tell Chef the maximum number of stones he can remove assuming that both players play optimally.\\n\\nInput\\nThe first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.\\nThe first line of each test case contains a single integer N denoting the number of piles.\\nThe second line contains N space separated integers A1, A2, ..., AN denoting the number of stones in each pile.\\n\\nOutput\\nFor each test case, output a single line containg the maximum number of stones that Chef can remove.\\n\\nConstraints\\n\\n1 ≤ Ai ≤ 10^9\\nExample\\n\\nInput:\\n2\\n3\\n1 2 3\\n3\\n1 2 1\\n\\nOutput:\\n4\\n3\\nSolve the task in PYTHON.\",\"targets\":\"#This Is an Important Message that is meaningless. \\nfor i in range(0,int(raw_input())):\\n\\tn=int(raw_input())\\n\\tl=list(map(int,raw_input().split()))\\n\\tl.sort()\\n\\tprint sum(l[len(l)-1::-2])\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"DLS and JLS are bored with a Math lesson. In order to entertain themselves, DLS took a sheet of paper and drew n distinct lines, given by equations y = x + p_i for some distinct p_1, p_2, …, p_n.\\n\\nThen JLS drew on the same paper sheet m distinct lines given by equations y = -x + q_i for some distinct q_1, q_2, …, q_m.\\n\\nDLS and JLS are interested in counting how many line pairs have integer intersection points, i.e. points with both coordinates that are integers. Unfortunately, the lesson will end up soon, so DLS and JLS are asking for your help.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 1000), the number of test cases in the input. Then follow the test case descriptions.\\n\\nThe first line of a test case contains an integer n (1 ≤ n ≤ 10^5), the number of lines drawn by DLS.\\n\\nThe second line of a test case contains n distinct integers p_i (0 ≤ p_i ≤ 10^9) describing the lines drawn by DLS. The integer p_i describes a line given by the equation y = x + p_i.\\n\\nThe third line of a test case contains an integer m (1 ≤ m ≤ 10^5), the number of lines drawn by JLS.\\n\\nThe fourth line of a test case contains m distinct integers q_i (0 ≤ q_i ≤ 10^9) describing the lines drawn by JLS. The integer q_i describes a line given by the equation y = -x + q_i.\\n\\nThe sum of the values of n over all test cases in the input does not exceed 10^5. Similarly, the sum of the values of m over all test cases in the input does not exceed 10^5.\\n\\nIn hacks it is allowed to use only one test case in the input, so t=1 should be satisfied.\\n\\nOutput\\n\\nFor each test case in the input print a single integer — the number of line pairs with integer intersection points. \\n\\nExample\\n\\nInput\\n\\n\\n3\\n3\\n1 3 2\\n2\\n0 3\\n1\\n1\\n1\\n1\\n1\\n2\\n1\\n1\\n\\n\\nOutput\\n\\n\\n3\\n1\\n0\\n\\nNote\\n\\nThe picture shows the lines from the first test case of the example. Black circles denote intersection points with integer coordinates.\\n\\n\\nUsing python3 can you solve the prior task?\",\"targets\":\"import math\\nfor t in range(int(input())):\\n n = int(input())\\n p=[int(i) for i in input().strip().split()]\\n m = int(input())\\n q=[int(i) for i in input().strip().split()]\\n c_o_p = 0\\n c_e_p = 0\\n c_o_q = 0\\n c_e_q = 0\\n for i in p:\\n if i%2==0:\\n c_e_p += 1\\n else:\\n c_o_p+=1\\n for i in q:\\n if i%2==0:\\n c_e_q += 1\\n else:\\n c_o_q+=1\\n s=c_o_p*c_o_q+c_e_p*c_e_q\\n print(s)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"One common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can represent a sound file as an array of n non-negative integers.\\n\\nIf there are exactly K distinct values in the array, then we need k = ⌈ log_{2} K ⌉ bits to store each value. It then takes nk bits to store the whole file.\\n\\nTo reduce the memory consumption we need to apply some compression. One common way is to reduce the number of possible intensity values. We choose two integers l ≤ r, and after that all intensity values are changed in the following way: if the intensity value is within the range [l;r], we don't change it. If it is less than l, we change it to l; if it is greater than r, we change it to r. You can see that we lose some low and some high intensities.\\n\\nYour task is to apply this compression in such a way that the file fits onto a disk of size I bytes, and the number of changed elements in the array is minimal possible.\\n\\nWe remind you that 1 byte contains 8 bits.\\n\\nk = ⌈ log_{2} K ⌉ is the smallest integer such that K ≤ 2^{k}. In particular, if K = 1, then k = 0.\\n\\nInput\\n\\nThe first line contains two integers n and I (1 ≤ n ≤ 4 ⋅ 10^{5}, 1 ≤ I ≤ 10^{8}) — the length of the array and the size of the disk in bytes, respectively.\\n\\nThe next line contains n integers a_{i} (0 ≤ a_{i} ≤ 10^{9}) — the array denoting the sound file.\\n\\nOutput\\n\\nPrint a single integer — the minimal possible number of changed elements.\\n\\nExamples\\n\\nInput\\n\\n\\n6 1\\n2 1 2 3 4 3\\n\\n\\nOutput\\n\\n\\n2\\n\\n\\nInput\\n\\n\\n6 2\\n2 1 2 3 4 3\\n\\n\\nOutput\\n\\n\\n0\\n\\n\\nInput\\n\\n\\n6 1\\n1 1 2 2 3 3\\n\\n\\nOutput\\n\\n\\n2\\n\\nNote\\n\\nIn the first example we can choose l=2, r=3. The array becomes 2 2 2 3 3 3, the number of distinct elements is K=2, and the sound file fits onto the disk. Only two values are changed.\\n\\nIn the second example the disk is larger, so the initial file fits it and no changes are required.\\n\\nIn the third example we have to change both 1s or both 3s.\\\":\",\"targets\":\"#include \\n#pragma GCC optimize(\\\"Ofast\\\")\\n#pragma GCC target(\\\"avx,avx2,fma\\\")\\n#pragma GCC optimization(\\\"O3\\\")\\n#pragma GCC optimization(\\\"unroll-loops\\\")\\nusing namespace std;\\nconst int mod = (int)1e9 + 7;\\nconst int N = 1e5 + 10;\\nconst long long inf = -1e17;\\nstruct event {\\n long long a, b, c, d;\\n};\\nvoid solve() {\\n long long n, bit;\\n cin >> n >> bit;\\n vector a(n);\\n long long k = 8 * bit;\\n k = k \\/ n;\\n for (int i = 0; i < n; i++) {\\n cin >> a[i];\\n }\\n long long z = k;\\n k = 1;\\n while (z--) {\\n k = k * 2LL;\\n if (k > n) {\\n cout << 0;\\n return;\\n }\\n }\\n sort(a.begin(), a.end());\\n long long cnt = 0, res = 0;\\n int j = 0;\\n for (int i = 0; i < n; i++) {\\n while (j < n && cnt < k) {\\n cnt++;\\n int pp = j;\\n while (pp < n && a[pp] == a[j]) pp++;\\n j = pp;\\n }\\n long long rr = j - i;\\n res = max(res, rr);\\n int k = i;\\n while (k < n && a[k] == a[i]) k++;\\n cnt--;\\n i = k - 1;\\n }\\n cout << n - res;\\n}\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n solve();\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"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\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nchar buf[1 << 21], *p1 = buf, *p2 = buf;\\ninline int read() {\\n char c =\\n (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2)\\n ? EOF\\n : *p1++);\\n int x = 0;\\n bool f = 0;\\n for (; !isdigit(c);\\n c = (p1 == p2 &&\\n (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2)\\n ? EOF\\n : *p1++))\\n f ^= !(c ^ 45);\\n for (; isdigit(c);\\n c = (p1 == p2 &&\\n (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2)\\n ? EOF\\n : *p1++))\\n x = (x << 1) + (x << 3) + (c ^ 48);\\n if (f) x = -x;\\n return x;\\n}\\nconst int mod = 998244353, _G = 3, N = 1 << 20;\\ninline int qpow(int x, int y = mod - 2) {\\n int res = 1;\\n for (; y; x = (long long)x * x % mod, y >>= 1)\\n if (y & 1) res = (long long)res * x % mod;\\n return res;\\n}\\nint rt[N], mg[N], Lim;\\nint fac[N], ifac[N], inv[N];\\nvoid init(int x) {\\n fac[0] = ifac[0] = inv[1] = 1;\\n for (int i = (2); i <= (x); ++i)\\n inv[i] = (long long)(mod - mod \\/ i) * inv[mod % i] % mod;\\n for (int i = (1); i <= (x); ++i)\\n fac[i] = (long long)fac[i - 1] * i % mod,\\n ifac[i] = (long long)ifac[i - 1] * inv[i] % mod;\\n}\\nint C(int x, int y) {\\n return x < y || y < 0 ? 0\\n : (long long)fac[x] * ifac[y] % mod * ifac[x - y] % mod;\\n}\\nvoid Pinit(int x) {\\n for (Lim = 1; Lim <= x; Lim <<= 1)\\n ;\\n int w = qpow(_G, (mod - 1) \\/ Lim);\\n mg[0] = 1;\\n for (int i = (1); i <= (Lim - 1); ++i) mg[i] = (long long)mg[i - 1] * w % mod;\\n for (int i = 1; i < Lim; i <<= 1) {\\n int sG = qpow(_G, (mod - 1) \\/ (i << 1));\\n rt[i] = 1;\\n for (int j = (i + 1); j <= (i * 2 - 1); ++j)\\n rt[j] = (long long)rt[j - 1] * sG % mod;\\n }\\n}\\nint rev[N], a[N], b[N];\\nvoid dft(int *a, int n, int op) {\\n for (int i = (0); i <= (n - 1); ++i)\\n rev[i] = (rev[i >> 1] >> 1) | ((i & 1) * (n >> 1));\\n for (int i = (0); i <= (n - 1); ++i)\\n if (i < rev[i]) a[i] ^= a[rev[i]] ^= a[i] ^= a[rev[i]];\\n for (int i =...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nOne winter evening the Hedgehog was relaxing at home in his cozy armchair and clicking through the TV channels. Stumbled on an issue of «TopShop», the Hedgehog was about to change the channel when all of a sudden he was stopped by an advertisement of a new wondrous invention.\\n\\nActually, a vacuum cleaner was advertised there. It was called Marvellous Vacuum and it doesn't even need a human to operate it while it cleans! The vacuum cleaner can move around the flat on its own: it moves in some direction and if it hits an obstacle there, it automatically chooses a new direction. Sooner or later this vacuum cleaner will travel through all the room and clean it all. Having remembered how much time the Hedgehog spends every time on cleaning (surely, no less than a half of the day), he got eager to buy this wonder.\\n\\nHowever, the Hedgehog quickly understood that the cleaner has at least one weak point: it won't clean well in the room's corners because it often won't able to reach the corner due to its shape. To estimate how serious is this drawback in practice, the Hedgehog asked you to write for him the corresponding program.\\n\\nYou will be given the cleaner's shape in the top view. We will consider only the cases when the vacuum cleaner is represented as a convex polygon. The room is some infinitely large rectangle. We consider one corner of this room and want to find such a rotation of the vacuum cleaner so that it, being pushed into this corner, will leave the minimum possible area in the corner uncovered.\\n\\nInput\\n\\nThe first line contains an integer N which represents the number of vertices of the vacuum cleaner's polygon (3 ≤ N ≤ 4·104). Then follow N lines each containing two numbers — the coordinates of a vertex of the polygon. All the coordinates are integer and their absolute values do not exceed 106.\\n\\nIt is guaranteed that the given polygon is nondegenerate and convex (no three points lie on the same line). The polygon vertices are given in a clockwise or counter-clockwise direction.\\n\\nOutput\\n\\nPrint the minimum...\",\"targets\":\"#include \\nusing namespace std;\\nint n;\\nstruct vec {\\n double x, y;\\n vec to(vec u) {\\n vec ret;\\n ret.x = u.x - x;\\n ret.y = u.y - y;\\n return ret;\\n }\\n double dotprod(vec u) { return u.x * x + u.y * y; }\\n double len() { return sqrt(x * x + y * y); }\\n} P[100001];\\ndouble SS[100001];\\nint main() {\\n ios::sync_with_stdio(false);\\n cout << fixed << setprecision(10);\\n cin >> n;\\n double ans = 1e20;\\n for (int i = n; i >= 1; i--) cin >> P[i].x >> P[i].y;\\n for (int i = n + 1; i <= n + n; i++) P[i] = P[i - n];\\n SS[0] = 0;\\n SS[1] = 0;\\n for (int i = 2; i <= n + n; i++)\\n SS[i] = SS[i - 1] + 0.5 * (P[i].x * P[i - 1].y - P[i].y * P[i - 1].x);\\n int cur = 2;\\n for (int i = 1; i <= n; i++) {\\n vec dir = P[i].to(P[i + 1]);\\n while (dir.dotprod(P[i].to(P[cur + 1])) >= dir.dotprod(P[i].to(P[cur])))\\n cur++;\\n if (cur == i + 1) ans = 0;\\n if (cur >= n + n) break;\\n double S = (P[i].to(P[cur])).len();\\n double X = dir.dotprod(P[i].to(P[cur])) \\/ dir.len();\\n double Y = sqrt(S * S - X * X);\\n double D = SS[cur] - SS[i];\\n D += 0.5 * (P[i].x * P[cur].y - P[i].y * P[cur].x);\\n D = abs(D);\\n ans = min(ans, max(abs(X * Y) \\/ 2 - D, 0.000));\\n }\\n for (int i = 1; i <= n \\/ 2; i++) swap(P[i], P[n + 1 - i]);\\n for (int i = n + 1; i <= n + n; i++) P[i] = P[i - n];\\n SS[0] = 0;\\n SS[1] = 0;\\n for (int i = 2; i <= n + n; i++)\\n SS[i] = SS[i - 1] + 0.5 * (P[i].x * P[i - 1].y - P[i].y * P[i - 1].x);\\n cur = 2;\\n for (int i = 1; i <= n; i++) {\\n vec dir = P[i].to(P[i + 1]);\\n while (dir.dotprod(P[i].to(P[cur + 1])) >= dir.dotprod(P[i].to(P[cur])))\\n cur++;\\n if (cur == i + 1) ans = 0;\\n if (cur >= n + n) break;\\n double S = (P[i].to(P[cur])).len();\\n double X = dir.dotprod(P[i].to(P[cur])) \\/ dir.len();\\n double Y = sqrt(S * S - X * X);\\n double D = SS[cur] - SS[i];\\n D += 0.5 * (P[i].x * P[cur].y - P[i].y * P[cur].x);\\n D = abs(D);\\n ans = min(ans, max(abs(X * Y) \\/ 2 - D, 0.000));\\n }\\n cout << ans << endl;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"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→...\\nimpor\",\"targets\":\"t 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.nio.fs.RegistryFileTypeDetector;\\n\\n\\n \\npublic class Codeforces {\\n\\tstatic int mod= 1000000007;\\n\\t\\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\\t\\n\\t\\touter:while(t-->0) {\\n\\t\\t\\tint n=fs.nextInt();\\n\\t\\t\\tchar arr[]=fs.next().toCharArray();\\n\\t\\t\\tchar brr[]=fs.next().toCharArray();\\n\\t\\t\\tint ans=mod+2;\\n\\t\\t\\tans=Math.min(ans, find(arr,brr));\\n\\t\\t\\tfor(int i=0;i=mod) out.println(-1);\\n\\t\\t\\telse out.println(ans);\\n\\t\\t}\\n\\t\\t\\n\\t\\t\\n\\t\\tout.close();\\n\\t\\t\\n\\t}\\n\\tstatic int find(char arr[],char brr[]) {\\n\\t\\tint a=0, b=0; \\/\\/ a= 01 , b= 10\\n\\t\\tfor(int i=0;i>1;\\n\\t\\t}\\n\\t\\treturn res;\\n\\t}\\n\\tstatic int gcd(int a,int 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++)...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"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...\\n\\/\\/pac\",\"targets\":\"kage round365;\\nimport java.io.ByteArrayInputStream;\\nimport java.io.IOException;\\nimport java.io.InputStream;\\nimport java.io.PrintWriter;\\nimport java.util.Arrays;\\nimport java.util.InputMismatchException;\\n\\npublic class C {\\n\\tInputStream is;\\n\\tPrintWriter out;\\n\\tString INPUT = \\\"\\\";\\n\\t\\n\\tvoid solve()\\n\\t{\\n\\t\\tint n = ni();\\n\\t\\tlong w = ni(), v = ni(), u = ni();\\n\\t\\tlong[][] co = new long[n][];\\n\\t\\tfor(int i = 0;i < n;i++){\\n\\t\\t\\tco[i] = new long[]{ni(), ni()};\\n\\t\\t}\\n\\t\\t\\/\\/ y=u\\/v*(x-a)\\n\\t\\t\\/\\/ x-a = y*v\\/u\\n\\t\\t\\/\\/ a = x-y*v\\/u\\n\\t\\tboolean minus = false;\\n\\t\\tboolean plus = false;\\n\\t\\tdouble min = Double.POSITIVE_INFINITY;\\n\\t\\tdouble max = Double.NEGATIVE_INFINITY;\\n\\t\\tfor(int i = 0;i < n;i++){\\n\\t\\t\\tlong anum = co[i][0]*u-co[i][1]*v;\\n\\t\\t\\tlong bnum = u;\\n\\t\\t\\tif(anum < 0){\\n\\t\\t\\t\\tminus = true;\\n\\t\\t\\t}\\n\\t\\t\\tif(anum > 0){\\n\\t\\t\\t\\tplus = true;\\n\\t\\t\\t}\\n\\t\\t\\tmin = Math.min(min, (double)anum\\/bnum);\\n\\t\\t\\tmax = Math.max(max, (double)anum\\/bnum);\\n\\t\\t}\\n\\t\\tif(minus && plus){\\n\\t\\t\\tout.printf(\\\"%.14f\\\\n\\\", (double)w\\/u+max\\/v);\\n\\t\\t}else{\\n\\t\\t\\tout.printf(\\\"%.14f\\\\n\\\", (double)w\\/u);\\n\\t\\t}\\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 PrintWriter(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 C().run(); }\\n\\t\\n\\tprivate byte[] inbuf = new byte[1024];\\n\\tprivate 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...\",\"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...\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\n\\npublic class E_1566 {\\n\\t\\n\\tstatic ArrayList[] adjList;\\n\\tstatic boolean[] vis;\\n\\tstatic boolean[] leaf;\\n\\t\\n\\tpublic static int dfs(int u) {\\n\\t\\tvis[u] = true;\\n\\t\\tif(adjList[u].size() == 1 && u != 0) {\\n\\t\\t\\tleaf[u] = true;\\n\\t\\t\\treturn 1;\\n\\t\\t}\\n\\t\\t\\n\\t\\tint ans = 0;\\n\\t\\tint cntbuds = 0, cntleaf = 0;\\n\\t\\tfor(int v : adjList[u])\\n\\t\\t\\tif(!vis[v]) {\\n\\t\\t\\t\\tint x = dfs(v);\\n\\t\\t\\t\\tans += x;\\n\\t\\t\\t\\tif(leaf[v])\\n\\t\\t\\t\\t\\tcntleaf++;\\n\\t\\t\\t\\telse\\n\\t\\t\\t\\t\\tcntbuds++;\\n\\t\\t\\t}\\n\\t\\t\\t\\t\\n\\t\\tif(cntleaf == 0)\\n\\t\\t\\tleaf[u] = true;\\n\\t\\t\\n\\t\\tif(cntleaf == 0)\\n\\t\\t\\treturn ans - cntbuds + 1;\\n\\t\\telse\\n\\t\\t\\treturn ans - cntbuds;\\n\\t\\t\\n\\t}\\n\\t\\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 t = sc.nextInt();\\n\\t\\twhile(t-->0) {\\n\\t\\t\\tint n = sc.nextInt();\\n\\t\\t\\tadjList = new ArrayList[n];\\n\\t\\t\\tfor(int i = 0; i < n; i++)\\n\\t\\t\\t\\tadjList[i] = new ArrayList();\\n\\t\\t\\tfor(int i = 0; i < n - 1; i++) {\\n\\t\\t\\t\\tint u = sc.nextInt() - 1, v = sc.nextInt() - 1;\\n\\t\\t\\t\\tadjList[u].add(v);\\n\\t\\t\\t\\tadjList[v].add(u);\\n\\t\\t\\t}\\n\\t\\t\\t\\n\\t\\t\\tvis = new boolean[n];\\n\\t\\t\\tleaf = new boolean[n];\\n\\t\\t\\tpw.println(dfs(0));\\n\\t\\t}\\n\\t\\t\\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[]...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nLet us consider sets of positive integers less than or equal to n. Note that all elements of a set are different. Also note that the order of elements doesn't matter, that is, both {3, 5, 9} and {5, 9, 3} mean the same set.\\n\\nSpecifying the number of set elements and their sum to be k and s, respectively, sets satisfying the conditions are limited. When n = 9, k = 3 and s = 23, {6, 8, 9} is the only such set. There may be more than one such set, in general, however. When n = 9, k = 3 and s = 22, both {5, 8, 9} and {6, 7, 9} are possible.\\n\\nYou have to write a program that calculates the number of the sets that satisfy the given conditions.\\n\\n\\n\\nInput\\n\\nThe input consists of multiple datasets. The number of datasets does not exceed 100.\\n\\nEach of the datasets has three integers n, k and s in one line, separated by a space. You may assume 1 ≤ n ≤ 20, 1 ≤ k ≤ 10 and 1 ≤ s ≤ 155.\\n\\nThe end of the input is indicated by a line containing three zeros.\\n\\nOutput\\n\\nThe output for each dataset should be a line containing a single integer that gives the number of the sets that satisfy the conditions. No other characters should appear in the output.\\n\\nYou can assume that the number of sets does not exceed 231 - 1.\\n\\nExample\\n\\nInput\\n\\n9 3 23\\n9 3 22\\n10 3 28\\n16 10 107\\n20 8 102\\n20 10 105\\n20 10 155\\n3 4 3\\n4 2 11\\n0 0 0\\n\\n\\nOutput\\n\\n1\\n2\\n0\\n20\\n1542\\n5448\\n1\\n0\\n0\",\"targets\":\"#include\\nusing namespace std;\\nusing lli = long long int;\\n\\nlli dfs(int n, int k, int s, int sum = 0, int prev = 0, int depth = 0){\\n if(s < sum)return 0;\\n if(depth == k) return sum == s;\\n lli res = 0;\\n for (int i = prev + 1; i <= n; i++) {\\n res += dfs(n, k, s, sum + i, i, depth + 1);\\n }\\n return res;\\n}\\n\\nint main(){\\n int n, k, s;\\n while(std::cin >> n >> k >> s, n){\\n std::cout << dfs(n, k, s) << std::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?\\nOne important contest will take place on the most famous programming platform (Topforces) very soon!\\n\\nThe authors have a pool of n problems and should choose at most three of them into this contest. The prettiness of the i-th problem is a_i. The authors have to compose the most pretty contest (in other words, the cumulative prettinesses of chosen problems should be maximum possible).\\n\\nBut there is one important thing in the contest preparation: because of some superstitions of authors, the prettinesses of problems cannot divide each other. In other words, if the prettinesses of chosen problems are x, y, z, then x should be divisible by neither y, nor z, y should be divisible by neither x, nor z and z should be divisible by neither x, nor y. If the prettinesses of chosen problems are x and y then neither x should be divisible by y nor y should be divisible by x. Any contest composed from one problem is considered good.\\n\\nYour task is to find out the maximum possible total prettiness of the contest composed of at most three problems from the given pool.\\n\\nYou have to answer q independent queries.\\n\\nIf you are Python programmer, consider using PyPy instead of Python when you submit your code.\\n\\nInput\\n\\nThe first line of the input contains one integer q (1 ≤ q ≤ 2 ⋅ 10^5) — the number of queries.\\n\\nThe first line of the query contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of problems.\\n\\nThe second line of the query contains n integers a_1, a_2, ..., a_n (2 ≤ a_i ≤ 2 ⋅ 10^5), where a_i is the prettiness of the i-th problem.\\n\\nIt is guaranteed that the sum of n over all queries does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each query print one integer — the maximum possible cumulative prettiness of the contest composed of at most three problems from the given pool of problems in the query.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n4\\n5 6 15 30\\n4\\n10 6 30 15\\n3\\n3 4 6\\n\\n\\nOutput\\n\\n\\n30\\n31\\n10\",\"targets\":\"#include \\nusing namespace std;\\nconst double pi = acos(-1.0);\\nint q;\\nint n;\\nint a[200010];\\nint main() {\\n cin >> q;\\n while (q--) {\\n scanf(\\\"%d\\\", &n);\\n for (int i = 0; i < n; i++) {\\n scanf(\\\"%d\\\", a + i);\\n }\\n sort(a, a + n);\\n int pick[4];\\n int pi = 0;\\n int sum = 0;\\n for (int i = n - 1; i >= 0; i--) {\\n bool ok = true;\\n for (int j = 0; j < pi; j++) {\\n if (pick[j] % a[i] == 0) {\\n ok = false;\\n }\\n }\\n if (ok) {\\n pick[pi++] = a[i];\\n sum += a[i];\\n if (pi == 3) {\\n break;\\n }\\n }\\n }\\n if (a[n - 1] % 2 == 0 && a[n - 1] % 3 == 0 && a[n - 1] % 5 == 0) {\\n int d2 = false;\\n int d3 = false;\\n int d5 = false;\\n for (int i = 0; i < n; i++) {\\n if (a[i] == a[n - 1] \\/ 2) {\\n d2 = true;\\n }\\n if (a[i] == a[n - 1] \\/ 3) {\\n d3 = true;\\n }\\n if (a[i] == a[n - 1] \\/ 5) {\\n d5 = true;\\n }\\n }\\n if (d2 && d3 && d5) {\\n sum = max(sum, a[n - 1] \\/ 2 + a[n - 1] \\/ 3 + a[n - 1] \\/ 5);\\n }\\n }\\n printf(\\\"%d\\\\n\\\", sum);\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"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 \\nusing namespace std;\\ntemplate \\ninline void read(T &f) {\\n f = 0;\\n T fu = 1;\\n char c = getchar();\\n while (c < '0' || c > '9') {\\n if (c == '-') fu = -1;\\n c = getchar();\\n }\\n while (c >= '0' && c <= '9') {\\n f = (f << 3) + (f << 1) + (c & 15);\\n c = getchar();\\n }\\n f *= fu;\\n}\\ntemplate \\nvoid print(T x) {\\n if (x < 0) putchar('-'), x = -x;\\n if (x < 10)\\n putchar(x + 48);\\n else\\n print(x \\/ 10), putchar(x % 10 + 48);\\n}\\ntemplate \\nvoid print(T x, char t) {\\n print(x);\\n putchar(t);\\n}\\nconst int N = 55, M = 7777;\\nchar c[N];\\nint isp[M + 5], val[N];\\nint T, n;\\nbool check(int x) {\\n for (int i = 2; i * i <= x; i++) {\\n if (x % i == 0) return 0;\\n }\\n return 1;\\n}\\nint main() {\\n for (int i = 2; i <= M; i++) isp[i] = check(i);\\n read(T);\\n while (T--) {\\n read(n);\\n scanf(\\\"%s\\\", c + 1);\\n for (int i = 1; i <= M; i++) {\\n if (isp[i]) continue;\\n int len = 0, tmp = i;\\n while (tmp) {\\n val[++len] = tmp % 10;\\n tmp \\/= 10;\\n }\\n reverse(val + 1, val + len + 1);\\n int pos = 1;\\n for (int j = 1; j <= n; j++) {\\n if (c[j] - '0' == val[pos]) ++pos;\\n if (pos == len + 1) break;\\n }\\n if (pos == len + 1) {\\n print(len, '\\\\n');\\n print(i, '\\\\n');\\n break;\\n }\\n }\\n }\\n return 0;\\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...\\nUsing python3 can you solve the prior task?\",\"targets\":\"from itertools import groupby\\nfor _ in range(int(input())):\\n n = int(input())\\n o = input()\\n p = input()\\n\\n op = list(zip(o,p))\\n \\n ans = 0; i = 0\\n while i _ \\n# | _\\/\\\\------____ ((| |))\\n# | `--' | \\n# ____|_ ___| |___.' \\n# \\/_\\/_____\\/____\\/_______|\\n# I am here to guard this code, woof!\\n# '''\\n\\n\\n\\nimport sys\\nfrom sys import stdin, stdout\\nfrom math import ceil, floor, sqrt, log, log2, log10\\nfrom collections import Counter\\n \\nint_max = float('inf')\\nint_min = -(float('inf'))\\nmod = 10**9 + 7\\nANS = []\\n# infile = open(sys.argv[1], \\\"r\\\")\\n# input = infile.readline\\ninput = stdin.readline\\n \\ndef solve():\\n pass\\n \\nt = int(input())\\n# t = 1\\n \\nfor i in range(t):\\n # n = int(input())\\n # n, k = map(int, input().split())\\n # arr = list(map(int, input().split()))\\n # arr = list(input())\\n s = input().strip()\\n\\n n = len(s)\\n if n%2 == 1:\\n print(\\\"NO\\\")\\n continue\\n if s[:n\\/\\/2] == s[n\\/\\/2: n]:\\n print(\\\"YES\\\")\\n else:\\n print('NO')\\n\\n# print('\\\\n'.join(ANS))\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Ayush, Ashish and Vivek are busy preparing a new problem for the next Codeforces round and need help checking if their test cases are valid.\\n\\nEach test case consists of an integer n and two arrays a and b, of size n. If after some (possibly zero) operations described below, array a can be transformed into array b, the input is said to be valid. Otherwise, it is invalid.\\n\\nAn operation on array a is: \\n\\n * select an integer k (1 ≤ k ≤ ⌊n\\/2⌋) \\n * swap the prefix of length k with the suffix of length k \\n\\n\\n\\nFor example, if array a initially is \\\\{1, 2, 3, 4, 5, 6\\\\}, after performing an operation with k = 2, it is transformed into \\\\{5, 6, 3, 4, 1, 2\\\\}.\\n\\nGiven the set of test cases, help them determine if each one is valid or invalid.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 500) — the number of test cases. The description of each test case is as follows.\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 500) — the size of the arrays.\\n\\nThe second line of each test case contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — elements of array a.\\n\\nThe third line of each test case contains n integers b_1, b_2, ..., b_n (1 ≤ b_i ≤ 10^9) — elements of array b.\\n\\nOutput\\n\\nFor each test case, print \\\"Yes\\\" if the given input is valid. Otherwise print \\\"No\\\".\\n\\nYou may print the answer in any case.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n2\\n1 2\\n2 1\\n3\\n1 2 3\\n1 2 3\\n3\\n1 2 4\\n1 3 4\\n4\\n1 2 3 2\\n3 1 2 2\\n3\\n1 2 3\\n1 3 2\\n\\n\\nOutput\\n\\n\\nyes\\nyes\\nNo\\nyes\\nNo\\n\\nNote\\n\\nFor the first test case, we can swap prefix a[1:1] with suffix a[2:2] to get a=[2, 1].\\n\\nFor the second test case, a is already equal to b.\\n\\nFor the third test case, it is impossible since we cannot obtain 3 in a.\\n\\nFor the fourth test case, we can first swap prefix a[1:1] with suffix a[4:4] to obtain a=[2, 2, 3, 1]. Now we can swap prefix a[1:2] with suffix a[3:4] to obtain a=[3, 1, 2, 2].\\n\\nFor the fifth test case, it is impossible to convert a to b.\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nconst long long N = 1000005;\\nlong long a[N], b[N], n, t;\\nbool solve() {\\n cin >> n;\\n for (long long i = 1; i <= n; i++) cin >> a[i];\\n for (long long i = 1; i <= n; i++) cin >> b[i];\\n multiset> s, t;\\n for (long long i = 1; i <= n \\/ 2; i++)\\n s.insert({min(a[i], a[n - i + 1]), max(a[i], a[n - i + 1])});\\n for (long long i = 1; i <= n \\/ 2; i++)\\n t.insert({min(b[i], b[n - i + 1]), max(b[i], b[n - i + 1])});\\n if (n & 1) {\\n if (a[(n + 1) \\/ 2] != b[(n + 1) \\/ 2]) return false;\\n }\\n for (auto its = s.begin(), itt = t.begin(); its != s.end() && itt != t.end();\\n its++, itt++) {\\n if (*its != *itt) return false;\\n }\\n return true;\\n}\\nsigned main() {\\n ios::sync_with_stdio(false);\\n long long t;\\n cin >> t;\\n while (t--) {\\n if (solve()) {\\n puts(\\\"Yes\\\");\\n } else {\\n puts(\\\"No\\\");\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"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\",\"targets\":\"#include \\nusing namespace std;\\nbool chkmin(int &a, int b) { return b < a ? a = b, 1 : 0; }\\nbool chkmax(int &a, int b) { return b > a ? a = b, 1 : 0; }\\ninline int read() {\\n int x = 0, fh = 1;\\n char ch = getchar();\\n for (; !isdigit(ch); ch = getchar())\\n if (ch == '-') fh = -1;\\n for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ '0');\\n return x * fh;\\n}\\nint n;\\ndouble p;\\nint main() {\\n cin >> n >> p;\\n int l = 0, r = n, now = n;\\n int npo3 = n * (n - 1) * (n - 2) \\/ 6;\\n while (l <= r) {\\n int mid = (l + r) >> 1;\\n double p2 = (n - mid) * mid * (mid - 1) \\/ 2. \\/ npo3;\\n double p1 = (n - mid) * (n - mid - 1) * mid \\/ 2. \\/ npo3;\\n double p3 = mid * (mid - 1) * (mid - 2) \\/ 6. \\/ npo3;\\n double p0 = (n - mid) * (n - mid - 1) * (n - mid - 2) \\/ 6. \\/ npo3;\\n double win = p3 + p2 + p1 \\/ 2;\\n if (win >= p - 1e-9) {\\n now = mid;\\n r = mid - 1;\\n } else {\\n l = mid + 1;\\n }\\n }\\n cout << now << endl;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"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}$$$.\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint xm[4] = {-1, 1, 0, 0};\\nint ym[4] = {0, 0, -1, 1};\\nconst int MOD = 1e9 + 7;\\nconst int MAXN = 5e5 + 5;\\nconst long long POW = 9973;\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n int t;\\n cin >> t;\\n while (t--) {\\n long long second, n;\\n cin >> second >> n;\\n long long temp = second;\\n long long rem = second;\\n vector v;\\n while (second) {\\n v.push_back(second % 10);\\n second \\/= 10;\\n }\\n vector ans;\\n long long p10 = 1;\\n for (long long i = 1; i < v.size(); i++) p10 *= 10;\\n for (long long i = v.size() - 1; i >= 0; i--) {\\n for (long long j = 10 * n; j >= 0; j--) {\\n if (rem - j * p10 >= 0 && j + (rem - (j * p10)) >= n - ans.size()) {\\n vector cnt(n, 0);\\n rem -= j * p10;\\n int q = j;\\n while (ans.size() < n) {\\n if (q) {\\n ans.push_back(p10);\\n q--;\\n cnt[ans.size() - 1]++;\\n } else\\n break;\\n }\\n for (int i = 0; i < ans.size(); i++) {\\n if (q) {\\n int ad = min(9 - cnt[i], q);\\n ans[i] += ad * p10;\\n q -= ad;\\n }\\n }\\n break;\\n }\\n }\\n p10 \\/= 10;\\n }\\n for (auto i : ans) cout << i << \\\" \\\";\\n ;\\n cout << \\\"\\\\n\\\";\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nA 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\",\"targets\":\"#include \\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());\\nconst long long mod = 998244353;\\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}\\nint main() {\\n cin.tie(0)->sync_with_stdio(0);\\n cin.exceptions(cin.failbit);\\n int n, m, k;\\n cin >> n >> m >> k;\\n vector e(2, 1);\\n map, int> prev;\\n vector > row(n, vector(2, 1)), col(m, vector(2, 1));\\n vector rcnt(3), ccnt(3);\\n rcnt[2] = n;\\n ccnt[2] = m;\\n for (int i = (0); i < (k); ++i) {\\n int x, y, t;\\n cin >> x >> y >> t;\\n --x;\\n --y;\\n if (prev.count(make_pair(x, y))) {\\n int par = ((x + y) & 1) ^ prev[make_pair(x, y)];\\n ++e[par ^ 1];\\n int rowpar = ((y & 1) ^ prev[make_pair(x, y)]);\\n ++row[x][rowpar ^ 1];\\n if (row[x][rowpar ^ 1] == 1 && row[x][rowpar] < 1) {\\n --rcnt[0];\\n ++rcnt[1];\\n } else if (row[x][rowpar ^ 1] == 1 && row[x][rowpar] == 1) {\\n --rcnt[1];\\n ++rcnt[2];\\n }\\n int colpar = ((x & 1) ^ prev[make_pair(x, y)]);\\n ++col[y][colpar ^ 1];\\n if (col[y][colpar ^ 1] == 1 && col[y][colpar] < 1) {\\n --ccnt[0];\\n ++ccnt[1];\\n } else if (col[y][colpar ^ 1] == 1 && col[y][colpar] == 1) {\\n --ccnt[1];\\n ++ccnt[2];\\n }\\n prev.erase(make_pair(x, y));\\n }\\n if (t == 0) {\\n prev[make_pair(x, y)] = 0;\\n } else if (t == 1) {\\n prev[make_pair(x, y)] = 1;\\n }\\n if (t != -1) {\\n int par = ((x + y) & 1) ^ prev[make_pair(x, y)];\\n --e[par ^ 1];\\n int rowpar = ((y & 1) ^ prev[make_pair(x, y)]);\\n row[x][rowpar ^ 1]--;\\n int colpar = ((x & 1) ^ prev[make_pair(x, y)]);\\n col[y][colpar ^ 1]--;\\n if (row[x][rowpar ^ 1] == 0 && row[x][rowpar] < 1)...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"YouKn0wWho has an integer sequence a_1, a_2, …, a_n. He will perform the following operation until the sequence becomes empty: select an index i such that 1 ≤ i ≤ |a| and a_i is not divisible by (i + 1), and erase this element from the sequence. Here |a| is the length of sequence a at the moment of operation. Note that the sequence a changes and the next operation is performed on this changed sequence.\\n\\nFor example, if a=[3,5,4,5], then he can select i = 2, because a_2 = 5 is not divisible by i+1 = 3. After this operation the sequence is [3,4,5].\\n\\nHelp YouKn0wWho determine if it is possible to erase the whole sequence using the aforementioned operation.\\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 (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 doesn't exceed 3 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print \\\"YES\\\" (without quotes) if it is possible to erase the whole sequence using the aforementioned operation, print \\\"NO\\\" (without quotes) otherwise. You can print each letter in any register (upper or lower).\\n\\nExample\\n\\nInput\\n\\n\\n5\\n3\\n1 2 3\\n1\\n2\\n2\\n7 7\\n10\\n384836991 191890310 576823355 782177068 404011431 818008580 954291757 160449218 155374934 840594328\\n8\\n6 69 696 69696 696969 6969696 69696969 696969696\\n\\n\\nOutput\\n\\n\\nYES\\nNO\\nYES\\nYES\\nNO\\n\\nNote\\n\\nIn the first test case, YouKn0wWho can perform the following operations (the erased elements are underlined): [1, \\\\underline{2}, 3] → [\\\\underline{1}, 3] → [\\\\underline{3}] → [ ].\\n\\nIn the second test case, it is impossible to erase the sequence as i can only be 1, and when i=1, a_1 = 2 is divisible by i + 1 = 2.\\nUsing python3 can you solve the prior task?\",\"targets\":\"from sys import stdin\\ninput = stdin.readline\\n\\nfor _ in range(int(input())):\\n n = int(input())\\n l = list(map(int,input().split()))\\n ans = \\\"YES\\\"\\n for i in range(n):\\n for factor in range(i+2,1,-1):\\n if l[i]%factor:\\n break\\n else:\\n ans=\\\"NO\\\"\\n break\\n print(ans)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 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\":\"import heapq;import sys;import math;from collections import deque;from bisect import bisect_left,bisect_right;I=sys.stdin.readline;II=lambda :int(I());IN=lambda x:map(int,x.split());FN=lambda x:map(float,x.split());L=lambda x:list(IN(x));M=1000000007;P=print;T=True;F=False\\nfor _ in range(II()):\\n\\tn,m,k=IN(I())\\n\\tif(n&1==0 and m&1==0):\\n\\t\\tif(k&1==1):\\n\\t\\t\\tprint(\\\"No\\\")\\n\\t\\telse:\\n\\t\\t\\tprint(\\\"yes\\\")\\n\\telif(n&1==0):\\n\\t\\tap=(m-1)*(n\\/\\/2)\\n\\t\\tif(k&1==0 and k<=ap):\\n\\t\\t\\tprint(\\\"yes\\\")\\n\\t\\telse:\\n\\t\\t\\tprint(\\\"NO\\\")\\n\\telse:\\n\\t\\tap=k-m\\/\\/2\\n\\t\\tif(ap>=0 and ap&1==0):\\n\\t\\t\\tprint(\\\"YEs\\\")\\n\\t\\telse:\\n\\t\\t\\tprint(\\\"NO\\\")\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"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 JAVA.\",\"targets\":\"import java.util.Scanner;\\n\\npublic class luntik_and_Concerts {\\n public static void main(String[] args) {\\n Scanner in = new Scanner(System.in);\\n int t = in.nextInt();\\n while (t-- > 0) {\\n int a ,b,c;\\n a = in.nextInt();\\n b = in.nextInt();\\n c = in.nextInt();\\n int summation = (1*a)+(2*b)+(3*c);\\n if(summation %2==0){\\n System.out.println(\\\"0\\\");\\n continue;\\n }\\n else{\\n System.out.println(\\\"1\\\");\\n continue;\\n }\\n \\n }\\/\\/taking input\\n \\/**\\/\\/\\/alternate input method\\n\\n }\\n }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Ayoub thinks that he is a very smart person, so he created a function f(s), where s is a binary string (a string which contains only symbols \\\"0\\\" and \\\"1\\\"). The function f(s) is equal to the number of substrings in the string s that contains at least one symbol, that is equal to \\\"1\\\".\\n\\nMore formally, f(s) is equal to the number of pairs of integers (l, r), such that 1 ≤ l ≤ r ≤ |s| (where |s| is equal to the length of string s), such that at least one of the symbols s_l, s_{l+1}, …, s_r is equal to \\\"1\\\". \\n\\nFor example, if s = \\\"01010\\\" then f(s) = 12, because there are 12 such pairs (l, r): (1, 2), (1, 3), (1, 4), (1, 5), (2, 2), (2, 3), (2, 4), (2, 5), (3, 4), (3, 5), (4, 4), (4, 5).\\n\\nAyoub also thinks that he is smarter than Mahmoud so he gave him two integers n and m and asked him this problem. For all binary strings s of length n which contains exactly m symbols equal to \\\"1\\\", find the maximum value of f(s).\\n\\nMahmoud couldn't solve the problem so he asked you for help. 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^5) — the number of test cases. The description of the test cases follows.\\n\\nThe only line for each test case contains two integers n, m (1 ≤ n ≤ 10^{9}, 0 ≤ m ≤ n) — the length of the string and the number of symbols equal to \\\"1\\\" in it.\\n\\nOutput\\n\\nFor every test case print one integer number — the maximum value of f(s) over all strings s of length n, which has exactly m symbols, equal to \\\"1\\\".\\n\\nExample\\n\\nInput\\n\\n\\n5\\n3 1\\n3 2\\n3 3\\n4 0\\n5 2\\n\\n\\nOutput\\n\\n\\n4\\n5\\n6\\n0\\n12\\n\\nNote\\n\\nIn the first test case, there exists only 3 strings of length 3, which has exactly 1 symbol, equal to \\\"1\\\". These strings are: s_1 = \\\"100\\\", s_2 = \\\"010\\\", s_3 = \\\"001\\\". The values of f for them are: f(s_1) = 3, f(s_2) = 4, f(s_3) = 3, so the maximum value is 4 and the answer is 4.\\n\\nIn the second test case, the string s with the maximum value is \\\"101\\\".\\n\\nIn the third test case, the string s with the maximum value is \\\"111\\\".\\n\\nIn the fourth test case, the only string s of length...\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\nimport java.lang.*;\\n\\n\\npublic class C1 implements Runnable\\n{\\n @Override\\n public void run() {\\n InputReader in = new InputReader(System.in);\\n PrintWriter w = new PrintWriter(System.out);\\n int q = in.nextInt(); \\/\\/ Scanner has functions to read ints, longs, strings, chars, etc.\\n for (int i = 0; i < q; i++) {\\n int a = in.nextInt();\\n int b = in.nextInt();\\n\\n w.println(getRes(a, b));\\n }\\n w.flush();\\n w.close();\\n }\\n\\n private static long getRes(int n, int m) {\\n\\n long sum = combo(n);\\n\\n int dis = n - m;\\n \\/\\/the distance will be divide into m + 1 parts;\\n \\/\\/System.out.println(m + 1);\\n int each = dis \\/ (m + 1);\\n if (each == 0) {\\n return sum - (n - m);\\n }\\n int mod = dis % (m + 1);\\n return sum - ((long) mod) * combo(each + 1) - ((long) m + 1 - mod) * combo(each);\\n }\\n\\n private static long combo(int a) {\\n return ((long) a) * (a - 1) \\/ 2 + a;\\n }\\n\\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...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Captain Flint and his crew keep heading to a savage shore of Byteland for several months already, drinking rum and telling stories. In such moments uncle Bogdan often remembers his nephew Denis. Today, he has told a story about how Denis helped him to come up with an interesting problem and asked the crew to solve it.\\n\\nIn the beginning, uncle Bogdan wrote on a board a positive integer x consisting of n digits. After that, he wiped out x and wrote integer k instead, which was the concatenation of binary representations of digits x consists of (without leading zeroes). For example, let x = 729, then k = 111101001 (since 7 = 111, 2 = 10, 9 = 1001).\\n\\nAfter some time, uncle Bogdan understood that he doesn't know what to do with k and asked Denis to help. Denis decided to wipe last n digits of k and named the new number as r.\\n\\nAs a result, Denis proposed to find such integer x of length n that r (as number) is maximum possible. If there are multiple valid x then Denis is interested in the minimum one.\\n\\nAll crew members, including captain Flint himself, easily solved the task. All, except cabin boy Kostya, who was too drunk to think straight. But what about you?\\n\\nNote: in this task, we compare integers (x or k) as numbers (despite what representations they are written in), so 729 < 1999 or 111 < 1000.\\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 test case. The one and only line of each test case contains the single integer n (1 ≤ n ≤ 10^5) — the length of the integer x you need to find.\\n\\nIt's guaranteed that the sum of n from all test cases doesn't exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print the minimum integer x of length n such that obtained by Denis number r is maximum possible.\\n\\nExample\\n\\nInput\\n\\n\\n2\\n1\\n3\\n\\n\\nOutput\\n\\n\\n8\\n998\\n\\nNote\\n\\nIn the second test case (with n = 3), if uncle Bogdan had x = 998 then k = 100110011000. Denis (by wiping last n = 3 digits) will obtain r = 100110011.\\n\\nIt can be proved that the 100110011 is...\\nUsing python3 can you solve the prior task?\",\"targets\":\"for _ in range(int(input())):\\n n=int(input())\\n temp=n\\n ans=''\\n cnt=0\\n ans1='8'*(n\\/\\/4)\\n cnt+=(n\\/\\/4)\\n if n%4!=0:\\n ans1+='8'\\n cnt+=1\\n ans='9'*(n-cnt)\\n print(ans+ans1)\",\"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.\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"n = int(input())\\nfor i in range(n):\\n k=int(input())\\n arr=list(map(int,input().split()))\\n all=sum(arr)\\n left=all%k\\n if left==0:\\n print('0')\\n else:\\n print('1')\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"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\\\":\",\"targets\":\"#include \\nusing namespace std;\\nlong long mod = 998244353;\\nvoid __print(int32_t 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 long long 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 long long n;\\n string str;\\n cin >> n >> str;\\n vector t2;\\n for (long long i = 0; i < n; i++) {\\n if (str[i] == '2') t2.push_back(i);\\n }\\n if (t2.size() == 2 || t2.size() == 1) {\\n cout << \\\"NO\\\\n\\\";\\n return;\\n }\\n vector> ans(n, vector(n, '='));\\n for (long long i = 0; i < t2.size(); i++) {\\n long long f = t2[i];\\n long long s = t2[(i + 1) % t2.size()];\\n ans[f][s] = '+';\\n ans[s][f] = '-';\\n }\\n for (long long i = 0; i < n; i++) ans[i][i] = 'X';\\n cout << \\\"YES\\\\n\\\";\\n for (auto &i : ans) {\\n for (auto j : i) {\\n cout << j;\\n }\\n cout << endl;\\n }\\n}\\nint32_t main() {\\n ios::sync_with_stdio(0);\\n cin.tie(0);\\n long long t = 1;\\n cin >> t;\\n for (long long i = 1; i <= t; i++) {\\n solve();\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Bessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However, Bessie is sure that there is a secret message hidden inside.\\n\\nThe text is a string s of lowercase Latin letters. She considers a string t as hidden in string s if t exists as a subsequence of s whose indices form an arithmetic progression. For example, the string aab is hidden in string aaabb because it occurs at indices 1, 3, and 5, which form an arithmetic progression with a common difference of 2. Bessie thinks that any hidden string that occurs the most times is the secret message. Two occurrences of a subsequence of S are distinct if the sets of indices are different. Help her find the number of occurrences of the secret message!\\n\\nFor example, in the string aaabb, a is hidden 3 times, b is hidden 2 times, ab is hidden 6 times, aa is hidden 3 times, bb is hidden 1 time, aab is hidden 2 times, aaa is hidden 1 time, abb is hidden 1 time, aaab is hidden 1 time, aabb is hidden 1 time, and aaabb is hidden 1 time. The number of occurrences of the secret message is 6.\\n\\nInput\\n\\nThe first line contains a string s of lowercase Latin letters (1 ≤ |s| ≤ 10^5) — the text that Bessie intercepted.\\n\\nOutput\\n\\nOutput a single integer — the number of occurrences of the secret message.\\n\\nExamples\\n\\nInput\\n\\n\\naaabb\\n\\n\\nOutput\\n\\n\\n6\\n\\n\\nInput\\n\\n\\nusaco\\n\\n\\nOutput\\n\\n\\n1\\n\\n\\nInput\\n\\n\\nlol\\n\\n\\nOutput\\n\\n\\n2\\n\\nNote\\n\\nIn the first example, these are all the hidden strings and their indice sets: \\n\\n * a occurs at (1), (2), (3) \\n * b occurs at (4), (5) \\n * ab occurs at (1,4), (1,5), (2,4), (2,5), (3,4), (3,5) \\n * aa occurs at (1,2), (1,3), (2,3) \\n * bb occurs at (4,5) \\n * aab occurs at (1,3,5), (2,3,4) \\n * aaa occurs at (1,2,3) \\n * abb occurs at (3,4,5) \\n * aaab occurs at (1,2,3,4) \\n * aabb occurs at (2,3,4,5) \\n * aaabb occurs at (1,2,3,4,5) \\n\\nNote that all the sets of indices are arithmetic progressions.\\n\\nIn the second example, no hidden string occurs more than once.\\n\\nIn the third example, the hidden string is the letter l.\\nUsing python3 can you solve the prior task?\",\"targets\":\"s = input()\\ncnt = [0] * 702\\nfor i in range(len(s)):\\n x = ord(s[i]) - 97\\n for j in range(26):\\n cnt[26 + 26 * j + x] += cnt[j]\\n cnt[x] += 1\\nprint(max(cnt))\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Let's assume that we have a pair of numbers (a, b). We can get a new pair (a + b, b) or (a, a + b) from the given pair in a single step.\\n\\nLet the initial pair of numbers be (1,1). Your task is to find number k, that is, the least number of steps needed to transform (1,1) into the pair where at least one number equals n.\\n\\nInput\\n\\nThe input contains the only integer n (1 ≤ n ≤ 106).\\n\\nOutput\\n\\nPrint the only integer k.\\n\\nExamples\\n\\nInput\\n\\n5\\n\\n\\nOutput\\n\\n3\\n\\n\\nInput\\n\\n1\\n\\n\\nOutput\\n\\n0\\n\\nNote\\n\\nThe pair (1,1) can be transformed into a pair containing 5 in three moves: (1,1) → (1,2) → (3,2) → (5,2).\\\":\",\"targets\":\"#include \\nusing namespace std;\\nconst long double eps = 1e-9;\\nconst long double pi = acos(-1.0);\\nint gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }\\nint xabs(int a) { return a > 0 ? a : -a; }\\nint main() {\\n int a = 1, b = 1;\\n int n;\\n cin >> n;\\n if (n == 1) {\\n cout << 0;\\n return 0;\\n }\\n vector s;\\n for (int i = 1; i < n; i++) {\\n if (gcd(n, i) == 1) {\\n s.push_back(i);\\n }\\n }\\n int res = 0;\\n int mi = 1000000000;\\n long long moi = 1000000000;\\n int nn = n;\\n for (int i = 0; i < s.size(); i++) {\\n res = s[i];\\n long long cnt = 0;\\n n = nn;\\n while (res != n) {\\n if (res > n)\\n res -= n;\\n else\\n n -= res;\\n cnt++;\\n }\\n moi = min(cnt, moi);\\n }\\n cout << moi;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alice has a cute cat. To keep her cat fit, Alice wants to design an exercising walk for her cat! \\n\\nInitially, Alice's cat is located in a cell (x,y) of an infinite grid. According to Alice's theory, cat needs to move: \\n\\n * exactly a steps left: from (u,v) to (u-1,v); \\n * exactly b steps right: from (u,v) to (u+1,v); \\n * exactly c steps down: from (u,v) to (u,v-1); \\n * exactly d steps up: from (u,v) to (u,v+1). \\n\\n\\n\\nNote that the moves can be performed in an arbitrary order. For example, if the cat has to move 1 step left, 3 steps right and 2 steps down, then the walk right, down, left, right, right, down is valid.\\n\\nAlice, however, is worrying that her cat might get lost if it moves far away from her. So she hopes that her cat is always in the area [x_1,x_2]× [y_1,y_2], i.e. for every cat's position (u,v) of a walk x_1 ≤ u ≤ x_2 and y_1 ≤ v ≤ y_2 holds.\\n\\nAlso, note that the cat can visit the same cell multiple times.\\n\\nCan you help Alice find out if there exists a walk satisfying her wishes?\\n\\nFormally, the walk should contain exactly a+b+c+d unit moves (a to the left, b to the right, c to the down, d to the up). Alice can do the moves in any order. Her current position (u, v) should always satisfy the constraints: x_1 ≤ u ≤ x_2, y_1 ≤ v ≤ y_2. The staring point is (x, y).\\n\\nYou are required to answer t test cases independently.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^3) — the number of testcases. \\n\\nThe first line of each test case contains four integers a, b, c, d (0 ≤ a,b,c,d ≤ 10^8, a+b+c+d ≥ 1).\\n\\nThe second line of the test case contains six integers x, y, x_1, y_1, x_2, y_2 (-10^8 ≤ x_1≤ x ≤ x_2 ≤ 10^8, -10^8 ≤ y_1 ≤ y ≤ y_2 ≤ 10^8).\\n\\nOutput\\n\\nFor each test case, output \\\"YES\\\" in a separate line, if there exists a walk satisfying her wishes. Otherwise, output \\\"NO\\\" in a separate line. \\n\\nYou can print each letter in any case (upper or lower).\\n\\nExample\\n\\nInput\\n\\n\\n6\\n3 2 2 2\\n0 0 -2 -2 2 2\\n3 1 4 1\\n0 0 -1 -1 1 1\\n1 1 1 1\\n1 1 1 1 1 1\\n0 0 0 1\\n0 0 0 0 0 1\\n5 1 1 1\\n0 0 -100 -100 0 100\\n1 1 5 1\\n0 0...\\nSolve the task in PYTHON3.\",\"targets\":\"import sys\\ninput = sys.stdin.readline\\nt = int(input())\\nfor _ in range(t):\\n a, b, cc, dd = map(int, input().split())\\n x, y, l, d, r, u = map(int, input().split())\\n x += b - a\\n y += dd - cc\\n #print(x, y)\\n if x in range(l, r + 1) and (y in range(d, u + 1)):\\n if a + b > 0 and (l == r):\\n print(\\\"NO\\\")\\n continue\\n if cc + dd > 0 and (d == u):\\n print(\\\"NO\\\")\\n continue\\n print(\\\"YES\\\")\\n else:\\n print(\\\"NO\\\")\",\"language\":\"python\",\"split\":\"train\",\"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...\\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.io.BufferedWriter;\\nimport java.util.InputMismatchException;\\nimport java.io.IOException;\\nimport java.io.Writer;\\nimport java.io.OutputStreamWriter;\\nimport java.util.Comparator;\\nimport java.io.InputStream;\\n\\n\\/**\\n * Built using CHelper plug-in\\n * Actual solution is at the top\\n *\\n * @author Akshay Mishra\\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 CInterestingStory solver = new CInterestingStory();\\n solver.solve(1, in, out);\\n out.close();\\n }\\n\\n static class CInterestingStory {\\n public void solve(int testNumber, InputReader in, OutputWriter out) {\\n int test = in.nextInt();\\n for (int tt = 0; tt < test; tt++) {\\n int n = in.nextInt();\\n CInterestingStory.Pair a[] = new CInterestingStory.Pair[n];\\n CInterestingStory.Pair b[] = new CInterestingStory.Pair[n];\\n CInterestingStory.Pair c[] = new CInterestingStory.Pair[n];\\n CInterestingStory.Pair d[] = new CInterestingStory.Pair[n];\\n CInterestingStory.Pair e[] = new CInterestingStory.Pair[n];\\n for (int i = 0; i < n; i++) {\\n String str = in.next();\\n char arr[] = str.toCharArray();\\n int size = arr.length;\\n int cnt1 = 0, cnt2 = 0, cnt3 = 0, cnt4 = 0, cnt5 = 0;\\n for (int j = 0; j < size; j++) {\\n if (arr[j] == 'a') {\\n cnt1++;\\n } else if (arr[j] == 'b') {\\n cnt2++;\\n } else if (arr[j] == 'c') {\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 solution for \\\"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.\\\":\",\"targets\":\"for x in range(int(input())):\\n a = input()\\n b = int(input())\\n c = str(b)\\n d = 0\\n length = 0\\n for i in range(len(c)):\\n d += int(c[i])\\n if int(c[i]) != 0:\\n length += 1\\n if int(c[len(c)-1]) == 0:\\n print(d + length)\\n else:\\n print(d + length-1)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"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.\",\"targets\":\"for _ in range(int(input())):\\n n = int(input())\\n l = list(map(int, input().split()))\\n even = []\\n odd = []\\n for i in range(2*n):\\n if l[i] % 2 == 0:\\n even.append([l[i], i+1])\\n else:\\n odd.append([l[i], i+1])\\n \\n if len(even) % 2 != 0:\\n even.pop()\\n odd.pop()\\n else:\\n if len(even) >= 2:\\n even.pop()\\n even.pop()\\n else:\\n odd.pop()\\n odd.pop()\\n \\n for i in range(1, len(even), 2):\\n print(even[i-1][1], even[i][1])\\n \\n for i in range(1, len(odd), 2):\\n print(odd[i-1][1], odd[i][1])\",\"language\":\"python\",\"split\":\"train\",\"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...\\n#!\\/us\",\"targets\":\"r\\/bin\\/env python\\nfrom __future__ import division, print_function\\n\\nimport os\\nimport sys\\nfrom io import BytesIO, IOBase\\n\\nif sys.version_info[0] < 3:\\n from __builtin__ import xrange as range\\n from future_builtins import ascii, filter, hex, map, oct, zip\\n\\ndef solve(n, a, c):\\n x = list(range(n))\\n x.sort(key=lambda x:(c[x], a[x]))\\n for i in range(n):\\n if (a[x[i]] > i + 1 and c[x[i]] == 'R') or\\\\\\n (a[x[i]] < i + 1 and c[x[i]] == 'B'):\\n return 'NO'\\n return 'YES'\\n\\ndef main():\\n t = int(input())\\n for _ in range(t):\\n n = int(input())\\n a = [int(x) for x in input().split()]\\n c = list(input())\\n print(solve(n, a, c))\\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 ...\",\"language\":\"python\",\"split\":\"test\",\"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...\\nUsing python can you solve the prior task?\",\"targets\":\"from itertools import combinations\\nfor _ in xrange(input()):\\n n = input()\\n m = [map(int, raw_input().split()) for _ in xrange(n)]\\n z = zip(*m)\\n g = [x for x in z if sum(x) >= n \\/ 2]\\n if len(g) < 2:\\n print \\\"NO\\\"\\n continue\\n ans = \\\"NO\\\"\\n for x, y in combinations(g, 2):\\n t = 0\\n for i in xrange(n):\\n if x[i] + y[i] >= 1:\\n t += 1\\n if t == n:\\n ans = \\\"YES\\\"\\n break\\n print ans\",\"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\\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.\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 3000;\\nint a[N];\\nvoid solve() {\\n int n;\\n scanf(\\\"%d\\\", &n);\\n for (int i = 1; i <= n; ++i) {\\n scanf(\\\"%d\\\", a + i);\\n }\\n vector ans;\\n for (int i = n; i >= 3; i -= 2) {\\n for (int j = 1; j <= i; ++j) {\\n if (a[j] == i) {\\n if (j & 1) {\\n reverse(a + 1, a + j + 1);\\n ans.push_back(j);\\n break;\\n } else {\\n printf(\\\"-1\\\\n\\\");\\n return;\\n }\\n }\\n }\\n for (int j = 1; j <= i; ++j) {\\n if (a[j] == i - 1) {\\n if (~j & 1) {\\n reverse(a + 1, a + j);\\n ans.push_back(j - 1);\\n break;\\n } else {\\n printf(\\\"-1\\\\n\\\");\\n return;\\n }\\n }\\n }\\n reverse(a + 1, a + i + 1);\\n ans.push_back(i);\\n for (int j = 1; j <= i; ++j) {\\n if (a[j] == i) {\\n reverse(a + 1, a + j + 1);\\n ans.push_back(j);\\n break;\\n }\\n }\\n reverse(a + 1, a + i + 1);\\n ans.push_back(i);\\n }\\n int sz = ans.size();\\n printf(\\\"%d\\\\n\\\", sz);\\n for (int i = 0; i < sz; ++i) {\\n printf(\\\"%d%c\\\", ans[i], i < sz - 1 ? ' ' : '\\\\n');\\n }\\n}\\nint main() {\\n int T;\\n scanf(\\\"%d\\\", &T);\\n while (T--) solve();\\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. He will perform the following operation until the sequence becomes empty: select an index i such that 1 ≤ i ≤ |a| and a_i is not divisible by (i + 1), and erase this element from the sequence. Here |a| is the length of sequence a at the moment of operation. Note that the sequence a changes and the next operation is performed on this changed sequence.\\n\\nFor example, if a=[3,5,4,5], then he can select i = 2, because a_2 = 5 is not divisible by i+1 = 3. After this operation the sequence is [3,4,5].\\n\\nHelp YouKn0wWho determine if it is possible to erase the whole sequence using the aforementioned operation.\\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 (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 doesn't exceed 3 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print \\\"YES\\\" (without quotes) if it is possible to erase the whole sequence using the aforementioned operation, print \\\"NO\\\" (without quotes) otherwise. You can print each letter in any register (upper or lower).\\n\\nExample\\n\\nInput\\n\\n\\n5\\n3\\n1 2 3\\n1\\n2\\n2\\n7 7\\n10\\n384836991 191890310 576823355 782177068 404011431 818008580 954291757 160449218 155374934 840594328\\n8\\n6 69 696 69696 696969 6969696 69696969 696969696\\n\\n\\nOutput\\n\\n\\nYES\\nNO\\nYES\\nYES\\nNO\\n\\nNote\\n\\nIn the first test case, YouKn0wWho can perform the following operations (the erased elements are underlined): [1, \\\\underline{2}, 3] → [\\\\underline{1}, 3] → [\\\\underline{3}] → [ ].\\n\\nIn the second test case, it is impossible to erase the sequence as i can only be 1, and when i=1, a_1 = 2 is divisible by i + 1 = 2.\",\"targets\":\"import java.util.*;\\nimport java.lang.*;\\nimport java.io.*;\\n\\npublic class Main\\n{\\n\\tPrintWriter out = new PrintWriter(System.out);\\n\\tBufferedReader in = new BufferedReader(new InputStreamReader(System.in));\\n StringTokenizer tok = new StringTokenizer(\\\"\\\");\\n String next() throws IOException {\\n if (!tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine()); }\\n return tok.nextToken();\\n }\\n int ni() throws IOException { return Integer.parseInt(next()); }\\n long nl() throws IOException { return Long.parseLong(next()); }\\n \\n long mod=1000000007;\\n \\n void solve() throws IOException {\\n for (int tc=ni();tc>0;tc--) {\\n int n=ni();\\n long div=1;\\n int[]A=new int[n+1];\\n for (int i=1;i<=n;i++) A[i]=ni();\\n \\n boolean f=true;\\n for (int i=1;i<=n;i++) {\\n long g=gcd(div,i+1);\\n div=(div\\/g)*(i+1);\\n if (A[i]%div==0) { f=false; break; }\\n }\\n \\n if (f) out.println(\\\"YES\\\");\\n else out.println(\\\"NO\\\");\\n }\\n out.flush();\\n }\\n \\n int gcd(int a,int b) { return(b==0?a:gcd(b,a%b)); }\\n long gcd(long a,long b) { return(b==0?a:gcd(b,a%b)); }\\n long mp(long a,long p) { long r=1; while(p>0) { if ((p&1)==1) r=(r*a)%mod; p>>=1; a=(a*a)%mod; } return r; }\\n \\n public static void main(String[] args) throws IOException {\\n new Main().solve();\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 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\":\"# \\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\n# \\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/ PYTHON IS THE BEST \\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\n# \\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\nimport sys,os,io\\nfrom sys import stdin\\nimport math \\nfrom collections import defaultdict\\nfrom heapq import heappush, heappop, heapify\\nfrom bisect import bisect_left , bisect_right\\nfrom io import BytesIO, IOBase\\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\\n\\n\\nalphabets = list('abcdefghijklmnopqrstuvwxyz')\\n\\n\\n\\n#for deep...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Karlsson has recently discovered a huge stock of berry jam jars in the basement of the house. More specifically, there were 2n jars of strawberry and blueberry jam.\\n\\nAll the 2n jars are arranged in a row. The stairs to the basement are exactly in the middle of that row. So when Karlsson enters the basement, he sees exactly n jars to his left and n jars to his right.\\n\\nFor example, the basement might look like this:\\n\\n\\n\\nBeing the starightforward man he is, he immediately starts eating the jam. In one minute he chooses to empty either the first non-empty jar to his left or the first non-empty jar to his right.\\n\\nFinally, Karlsson decided that at the end the amount of full strawberry and blueberry jam jars should become the same.\\n\\nFor example, this might be the result:\\n\\n He has eaten 1 jar to his left and then 5 jars to his right. There remained exactly 3 full jars of both strawberry and blueberry jam.\\n\\nJars are numbered from 1 to 2n from left to right, so Karlsson initially stands between jars n and n+1.\\n\\nWhat is the minimum number of jars Karlsson is required to empty so that an equal number of full strawberry and blueberry jam jars is left?\\n\\nYour program should answer t independent test cases.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 1000) — the number of test cases.\\n\\nThe first line of each test case contains a single integer n (1 ≤ n ≤ 10^5).\\n\\nThe second line of each test case contains 2n integers a_1, a_2, ..., a_{2n} (1 ≤ a_i ≤ 2) — a_i=1 means that the i-th jar from the left is a strawberry jam jar and a_i=2 means that it is a blueberry jam jar.\\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 the answer to it — the minimum number of jars Karlsson is required to empty so that an equal number of full strawberry and blueberry jam jars is left.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n6\\n1 1 1 2 2 1 2 1 2 1 1 2\\n2\\n1 2 1 2\\n3\\n1 1 1 1 1 1\\n2\\n2 1 1 1\\n\\n\\nOutput\\n\\n\\n6\\n0\\n6\\n2\\n\\nNote\\n\\nThe picture from the statement describes the first test case.\\n\\nIn the...\\\":\",\"targets\":\"#include \\nusing namespace std;\\ntemplate \\nbool umin(T& a, T b) {\\n if (a > b) {\\n a = b;\\n return 1;\\n }\\n return 0;\\n}\\ntemplate \\nbool umax(T& a, T b) {\\n if (a < b) {\\n a = b;\\n return 1;\\n }\\n return 0;\\n}\\nint pre[200009], suf[200009], dp[200009], arr[200009];\\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 int x;\\n scanf(\\\"%d\\\", &x);\\n pre[i] = pre[i - 1];\\n if (x == 1)\\n pre[i]++;\\n else\\n pre[i]--;\\n }\\n for (int i = 1; i <= n; i++) {\\n scanf(\\\"%d\\\", &arr[i]);\\n if (arr[i] == 2) arr[i] = -1;\\n }\\n dp[n] = n + 1;\\n suf[n + 1] = 0;\\n for (int i = n; i >= 1; i--) {\\n suf[i] = suf[i + 1] + arr[i];\\n dp[suf[i] + n] = i;\\n }\\n int ans = 0;\\n for (int i = 0; i <= n; i++)\\n if (dp[-pre[i] + n]) umax(ans, i + (n - dp[-pre[i] + n] + 1));\\n printf(\\\"%d\\\\n\\\", 2 * n - ans);\\n for (int i = 0; i <= 2 * n; i++) dp[i] = 0;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"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.\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint a[100010];\\nint b[100010];\\nbool IN(int x) { return x >= -10000 && x <= 10000; }\\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(\\\"%d\\\", &a[i]);\\n }\\n if (n % 2 == 0) {\\n for (int i = 1; i <= n; i += 2) {\\n b[i] = a[i + 1], b[i + 1] = -a[i];\\n }\\n } else {\\n for (int i = 4; i <= n; i += 2) {\\n b[i] = a[i + 1], b[i + 1] = -a[i];\\n }\\n int t1 = a[1] < 0, t2 = a[2] < 0, t3 = a[3] < 0;\\n a[1] = abs(a[1]), a[2] = abs(a[2]), a[3] = abs(a[3]);\\n if (a[1] == a[2] && a[2] == a[3])\\n b[1] = 1, b[2] = 1, b[3] = -2;\\n else {\\n int flag = 0;\\n if (a[1] == a[2]) flag = 1, swap(a[2], a[3]);\\n assert(a[1] != a[2]);\\n if (IN(a[1] + a[2]))\\n b[1] = 1, b[2] = 1;\\n else\\n assert(IN(a[1] - a[2])), b[1] = 1, b[2] = -1;\\n int sum = a[1] * b[1] + a[2] * b[2];\\n b[3] = -sum, b[1] *= a[3], b[2] *= a[3];\\n if (flag) swap(a[2], a[3]), swap(b[2], b[3]);\\n }\\n if (t1) b[1] *= -1;\\n if (t2) b[2] *= -1;\\n if (t3) b[3] *= -1;\\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\":\"soltask\",\"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\":\"#!\\/usr\\/bin\\/env python\\nfrom __future__ import division, print_function\\n\\nimport os\\nimport sys\\nfrom io import BytesIO, IOBase\\n\\nif sys.version_info[0] < 3:\\n from __builtin__ import xrange as range\\n from future_builtins import ascii, filter, hex, map, oct, zip\\n\\n\\ndef main():\\n t = int(input())\\n\\n for _ in range(t):\\n s = input()\\n one = sorted([len(i) for i in s.split('0')], reverse=True)\\n\\n alice = 0\\n bob = 0\\n\\n for i, j in enumerate(one):\\n if i % 2 == 0:\\n alice += j\\n else:\\n bob += j\\n\\n print(alice)\\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:...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"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 CPP.\",\"targets\":\"#include \\nusing namespace std;\\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 * b \\/ gcd(a, b); }\\nbool cmp(pair p1, pair p2) {\\n if (p1.second == p2.second) return p1.first < p2.first;\\n return p1.second < p2.second;\\n}\\nlong long solve(long long a, long long b, long long k) {\\n if (a % k == 0) return (b \\/ k - a \\/ k + 1);\\n return b \\/ k - a \\/ k;\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n long long t = 1;\\n cin >> t;\\n long long ar[1001];\\n long long i = 1, j = 1;\\n while (j < 1001) {\\n if (((i % 3) != 0) && ((i % 10) != 3)) ar[j++] = i;\\n i++;\\n }\\n while (t--) {\\n long long k;\\n cin >> k;\\n cout << ar[k] << \\\"\\\\n\\\";\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA 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 00) {\\n\\t\\t\\tif((y&1)==1)\\n\\t\\t\\t\\tres=res*x%M;\\n\\t\\t\\tx=x*x%M;\\n\\t\\t\\ty >>= 1;\\n\\t\\t}\\n\\t\\treturn res;\\n\\t}\\n\\tstatic class RMQ {\\n\\t\\tint n, lg;\\n\\t\\tint lift[][];\\n\\t\\tpublic RMQ(int n) {\\n\\t\\t\\tthis.n = n;\\n\\t\\t\\tlg = (int)(Math.log(n)\\/Math.log(2)) + 1;\\n\\t\\t\\tlift = new int[n][lg];\\n\\t\\t}\\n\\t\\t\\n\\t\\tpublic void build(int a[]) {\\n\\t\\t\\tassert(a.length==n);\\n\\t\\t\\tfor(int i = 0; i < n; ++i) {\\n\\t\\t\\t\\tlift[i][0]=a[i];\\n\\t\\t\\t}\\n\\t\\t\\tfor(int step = 1; (1<\\nusing namespace std;\\nint main() {\\n ios::sync_with_stdio(0);\\n cin.tie(0);\\n long long t = 0;\\n cin >> t;\\n while (t--) {\\n long long n = 0;\\n cin >> n;\\n long long ans = 0;\\n string x;\\n cin >> x;\\n for (int i = 0; i < x.length() - 1; i++) {\\n if (x[i] != '0') ans = ans + 1 + (x[i] - '0');\\n }\\n ans += (x[x.length() - 1] - '0');\\n cout << ans << '\\\\n';\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A tuple of positive integers {x1, x2, ..., xk} is called simple if for all pairs of positive integers (i, j) (1 ≤ i < j ≤ k), xi + xj is a prime.\\n\\nYou are given an array a with n positive integers a1, a2, ..., an (not necessary distinct). You want to find a simple subset of the array a with the maximum size.\\n\\nA prime number (or a prime) is a natural number greater than 1 that has no positive divisors other than 1 and itself.\\n\\nLet's define a subset of the array a as a tuple that can be obtained from a by removing some (possibly all) elements of it.\\n\\nInput\\n\\nThe first line contains integer n (1 ≤ n ≤ 1000) — the number of integers in the array a.\\n\\nThe second line contains n integers ai (1 ≤ ai ≤ 106) — the elements of the array a.\\n\\nOutput\\n\\nOn the first line print integer m — the maximum possible size of simple subset of a.\\n\\nOn the second line print m integers bl — the elements of the simple subset of the array a with the maximum size.\\n\\nIf there is more than one solution you can print any of them. You can print the elements of the subset in any order.\\n\\nExamples\\n\\nInput\\n\\n2\\n2 3\\n\\n\\nOutput\\n\\n2\\n3 2\\n\\n\\nInput\\n\\n2\\n2 2\\n\\n\\nOutput\\n\\n1\\n2\\n\\n\\nInput\\n\\n3\\n2 1 1\\n\\n\\nOutput\\n\\n3\\n1 1 2\\n\\n\\nInput\\n\\n2\\n83 14\\n\\n\\nOutput\\n\\n2\\n14 83\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int n;\\n cin >> n;\\n vector a(n);\\n long long max_ = 0;\\n for (int i = 0; i < n; i++) {\\n cin >> a[i];\\n max_ = max(max_, a[i]);\\n }\\n vector era(2 * max_ + 1);\\n fill(era.begin(), era.end(), true);\\n for (long long i = 2; i < era.size(); i++) {\\n if (era[i]) {\\n for (long long j = i * i; j < era.size(); j += i) {\\n era[j] = false;\\n }\\n }\\n }\\n vector > results;\\n vector v(1);\\n vector best;\\n long long y = 0;\\n bool flag;\\n vector help;\\n for (int i = 0; i < n; i++) {\\n v[0] = a[i];\\n results.push_back(v);\\n if (1 > best.size()) {\\n best = v;\\n }\\n y = results.size();\\n for (long long j = 0; j < y - 1; j++) {\\n flag = true;\\n for (long long k = 0; k < results[j].size(); k++) {\\n if (!era[results[j][k] + a[i]]) {\\n flag = false;\\n break;\\n }\\n if (results[j][k] == a[i]) {\\n results[j].push_back(a[i]);\\n if (results[j].size() > best.size()) {\\n best = results[j];\\n }\\n flag = false;\\n break;\\n }\\n }\\n if (flag) {\\n help = results[j];\\n help.push_back(a[i]);\\n results.push_back(help);\\n if (help.size() > best.size()) {\\n best = help;\\n }\\n }\\n }\\n }\\n cout << best.size() << endl;\\n for (long long i = 0; i < best.size(); i++) {\\n cout << best[i] << \\\" \\\";\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Bitwise exclusive OR (or bitwise addition modulo two) is a binary operation which is equivalent to applying logical exclusive OR to every pair of bits located on the same positions in binary notation of operands. In other words, a binary digit of the result is equal to 1 if and only if bits on the respective positions in the operands are different.\\n\\nFor example, if X = 10910 = 11011012, Y = 4110 = 1010012, then: \\n\\nX xor Y = 6810 = 10001002. \\n\\nWrite a program, which takes two non-negative integers A and B as an input and finds two non-negative integers X and Y, which satisfy the following conditions: \\n\\n * A = X + Y\\n * B = X xor Y, where xor is bitwise exclusive or. \\n * X is the smallest number among all numbers for which the first two conditions are true. \\n\\nInput\\n\\nThe first line contains integer number A and the second line contains integer number B (0 ≤ A, B ≤ 264 - 1).\\n\\nOutput\\n\\nThe only output line should contain two integer non-negative numbers X and Y. Print the only number -1 if there is no answer.\\n\\nExamples\\n\\nInput\\n\\n142\\n76\\n\\n\\nOutput\\n\\n33 109\\na = i\",\"targets\":\"nput()\\nb = input()\\nx = (max(a,b) - min(a,b))\\/2\\nif (a+b)%2==0:\\n print x, a-x\\nelse :\\n print -1\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"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...\\nUsing python3 can you solve the prior task?\",\"targets\":\"t = int(input())\\nfor _ in range(t):\\n n = int(input())\\n l = list(map(int, input().split()))\\n temp = []\\n for i in range(n):\\n if l[i] == -1:\\n if i == 0:\\n if l[i+1] != -1:\\n temp.append(l[i+1])\\n elif i == n-1:\\n if l[i-1] != -1:\\n temp.append(l[i-1])\\n else:\\n if l[i-1] != -1:\\n temp.append(l[i-1])\\n if l[i+1] != -1:\\n temp.append(l[i+1])\\n temp = list(set(temp))\\n temp.sort()\\n if len(temp) == 0:\\n k = 42\\n else:\\n k = (temp[0]+temp[-1])\\/\\/2\\n #print(k)\\n l_ = [0]*n\\n for i in range(n):\\n if l[i] == -1:\\n l_[i] = k\\n else:\\n l_[i] = l[i]\\n m = 0\\n for i in range(n-1):\\n m = max(m, abs(l_[i+1]-l_[i]))\\n print(m, k)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"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\\nSolve the task 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 m=input.nextInt();\\n int k=input.nextInt();\\n int arr[][]=new int[n][m];\\n char ch[]=new char[26];\\n for(int i=0;i<26;i++)\\n {\\n ch[i]=(char)(i+'a');\\n }\\n if(n%2!=0)\\n {\\n int x=m\\/2;\\n if(k 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...\\nimpor\",\"targets\":\"t java.util.*;\\npublic class B {\\n \\/\\/ static long mod = (long)Math.pow(10,9)+7;\\n\\tstatic Scanner sc = null;\\n\\/\\/ \\tstatic int n;\\n\\/\\/ \\tstatic Map> map;\\n\\/\\/ \\tstatic boolean visited[];\\n\\/\\/ \\tstatic long val[];\\n\\/\\/ \\tstatic long dis[];\\n\\/\\/ \\tstatic long dp[][];\\n\\/\\/ \\tstatic int N = 2*(int)Math.pow(10,5)+5;\\n\\/\\/ \\tstatic int max = Integer.MAX_VALUE;\\n\\/\\/ \\tstatic int K = 1001;\\npublic static void main(String[] args){\\n\\t\\/\\/System.out.println(\\\"Enter :\\\");\\n\\tsc = new Scanner(System.in);\\n int t = sc.nextInt();\\n while(t-->0){\\n int a = sc.nextInt();\\n int b = sc.nextInt();\\n int sum = a+b;\\n ArrayList ar = new ArrayList<>();\\n if(sum%2==0){\\n \\t int n1 = sum\\/2;\\n for(int i=0;i<=n1;i++) {\\n \\t int won = a-i;\\n \\t if(won<0 || won>n1)\\n \\t\\t continue;\\n \\t int brea = n1-i+won;\\n \\t ar.add(brea);\\n }\\n }\\n else{\\n int n1 = sum\\/2;\\n int n2 = sum\\/2+1;\\n for(int i=0;i<=n1;i++) {\\n \\t int won = a-i;\\n \\t if(won<0 || won>n2)\\n \\t\\t continue;\\n \\t int brea = n1-i+won;\\n \\t ar.add(brea);\\n }\\n for(int i=0;i<=n2;i++) {\\n \\t int won = a-i;\\n \\t if(won<0 || won>n1)\\n \\t\\t continue;\\n \\t int brea = n2-i+won;\\n \\t ar.add( brea); \\n }\\n }\\n Collections.sort(ar);\\n System.out.println(ar.size());\\n for(Integer j : ar)\\n System.out.print(j+\\\" \\\");\\n System.out.println();\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Drazil created a following problem about putting 1 × 2 tiles into an n × m grid:\\n\\n\\\"There is a grid with some cells that are empty and some cells that are occupied. You should use 1 × 2 tiles to cover all empty cells and no two tiles should cover each other. And you should print a solution about how to do it.\\\"\\n\\nBut Drazil doesn't like to write special checking program for this task. His friend, Varda advised him: \\\"how about asking contestant only to print the solution when it exists and it is unique? Otherwise contestant may print 'Not unique' \\\".\\n\\nDrazil found that the constraints for this task may be much larger than for the original task!\\n\\nCan you solve this new problem?\\n\\nNote that you should print 'Not unique' either when there exists no solution or when there exists several different solutions for the original task.\\n\\nInput\\n\\nThe first line contains two integers n and m (1 ≤ n, m ≤ 2000).\\n\\nThe following n lines describe the grid rows. Character '.' denotes an empty cell, and the character '*' denotes a cell that is occupied.\\n\\nOutput\\n\\nIf there is no solution or the solution is not unique, you should print the string \\\"Not unique\\\".\\n\\nOtherwise you should print how to cover all empty cells with 1 × 2 tiles. Use characters \\\"<>\\\" to denote horizontal tiles and characters \\\"^v\\\" to denote vertical tiles. Refer to the sample test for the output format example.\\n\\nExamples\\n\\nInput\\n\\n3 3\\n...\\n.*.\\n...\\n\\n\\nOutput\\n\\nNot unique\\n\\n\\nInput\\n\\n4 4\\n..**\\n*...\\n*.**\\n....\\n\\n\\nOutput\\n\\n<>**\\n*^<>\\n*v**\\n<><>\\n\\n\\nInput\\n\\n2 4\\n*..*\\n....\\n\\n\\nOutput\\n\\n*<>*\\n<><>\\n\\n\\nInput\\n\\n1 1\\n.\\n\\n\\nOutput\\n\\nNot unique\\n\\n\\nInput\\n\\n1 1\\n*\\n\\n\\nOutput\\n\\n*\\n\\nNote\\n\\nIn the first case, there are indeed two solutions:\\n \\n \\n \\n <>^ \\n ^*v \\n v<> \\n \\n\\nand\\n \\n \\n \\n ^<> \\n v*^ \\n <>v \\n \\n\\nso the answer is \\\"Not unique\\\".\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 2005;\\nint n, m;\\nchar g[N][N], ans[N][N];\\nint dg[N][N];\\nint dx[4] = {0, 0, 1, -1};\\nint dy[4] = {1, -1, 0, 0};\\nchar c_cur[4] = {'<', '>', '^', 'v'};\\nchar c_nx[4] = {'>', '<', 'v', '^'};\\nstruct cell {\\n int x, y;\\n cell() {}\\n cell(int x, int y) : x(x), y(y) {}\\n cell operator+(cell a) { return cell(x + a.x, y + a.y); }\\n bool valid() {\\n if (x >= 0 && x < n && y >= 0 && y < m && g[x][y] == '.') return true;\\n return false;\\n }\\n};\\nqueue q;\\nvoid bfs() {\\n while (!q.empty()) {\\n cell cur = q.front();\\n q.pop();\\n if (!dg[cur.x][cur.y]) continue;\\n for (int i = 0; i < 4; i++) {\\n cell nx = cur + cell(dx[i], dy[i]);\\n if (nx.valid() && dg[nx.x][nx.y] > 0) {\\n ans[cur.x][cur.y] = c_cur[i];\\n ans[nx.x][nx.y] = c_nx[i];\\n dg[cur.x][cur.y] = 0;\\n dg[nx.x][nx.y] = 0;\\n for (int j = 0; j < 4; j++) {\\n cell adj = nx + cell(dx[j], dy[j]);\\n if (adj.valid() && dg[adj.x][adj.y] > 1) {\\n dg[adj.x][adj.y]--;\\n if (dg[adj.x][adj.y] == 1) q.push(adj);\\n }\\n }\\n break;\\n }\\n }\\n }\\n}\\nint main() {\\n scanf(\\\" %d %d\\\", &n, &m);\\n for (int i = 0; i < n; i++) {\\n for (int j = 0; j < m; j++) {\\n scanf(\\\" %c\\\", &g[i][j]);\\n ans[i][j] = g[i][j];\\n }\\n }\\n for (int i = 0; i < n; i++) {\\n for (int j = 0; j < m; j++) {\\n if (g[i][j] == '.') {\\n for (int k = 0; k < 4; k++) {\\n if (cell(i + dx[k], j + dy[k]).valid()) dg[i][j]++;\\n }\\n if (dg[i][j] == 1) q.push(cell(i, j));\\n if (!dg[i][j]) {\\n printf(\\\"Not unique\\\\n\\\");\\n return 0;\\n }\\n }\\n }\\n }\\n bfs();\\n bool ok = true;\\n for (int i = 0; ok && i < n; i++) {\\n for (int j = 0; ok && j < m; j++) {\\n if (dg[i][j]) ok = false;\\n }\\n }\\n if (ok) {\\n for (int i = 0; i < n; i++) {\\n for (int j = 0; j < m; j++) {\\n printf(\\\"%c\\\", ans[i][j]);\\n }\\n printf(\\\"\\\\n\\\");\\n }\\n } else {\\n printf(\\\"Not unique\\\\n\\\");\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Andrewid the Android is a galaxy-famous detective. He is now investigating a case of frauds who make fake copies of the famous Stolp's gears, puzzles that are as famous as the Rubik's cube once was.\\n\\nIts most important components are a button and a line of n similar gears. Each gear has n teeth containing all numbers from 0 to n - 1 in the counter-clockwise order. When you push a button, the first gear rotates clockwise, then the second gear rotates counter-clockwise, the the third gear rotates clockwise an so on.\\n\\nBesides, each gear has exactly one active tooth. When a gear turns, a new active tooth is the one following after the current active tooth according to the direction of the rotation. For example, if n = 5, and the active tooth is the one containing number 0, then clockwise rotation makes the tooth with number 1 active, or the counter-clockwise rotating makes the tooth number 4 active.\\n\\nAndrewid remembers that the real puzzle has the following property: you can push the button multiple times in such a way that in the end the numbers on the active teeth of the gears from first to last form sequence 0, 1, 2, ..., n - 1. Write a program that determines whether the given puzzle is real or fake.\\n\\nInput\\n\\nThe first line contains integer n (1 ≤ n ≤ 1000) — the number of gears.\\n\\nThe second line contains n digits a1, a2, ..., an (0 ≤ ai ≤ n - 1) — the sequence of active teeth: the active tooth of the i-th gear contains number ai.\\n\\nOutput\\n\\nIn a single line print \\\"Yes\\\" (without the quotes), if the given Stolp's gears puzzle is real, and \\\"No\\\" (without the quotes) otherwise.\\n\\nExamples\\n\\nInput\\n\\n3\\n1 0 0\\n\\n\\nOutput\\n\\nYes\\n\\n\\nInput\\n\\n5\\n4 2 1 4 3\\n\\n\\nOutput\\n\\nYes\\n\\n\\nInput\\n\\n4\\n0 2 3 1\\n\\n\\nOutput\\n\\nNo\\n\\nNote\\n\\nIn the first sample test when you push the button for the first time, the sequence of active teeth will be 2 2 1, when you push it for the second time, you get 0 1 2.\\nimpor\",\"targets\":\"t java.io.BufferedWriter;\\nimport java.io.IOException;\\nimport java.io.InputStream;\\nimport java.io.OutputStream;\\nimport java.io.OutputStreamWriter;\\nimport java.io.PrintWriter;\\nimport java.util.*;\\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 int n = in.readInt();\\n int[] a = new int[n];\\n for(int i = 0; i < n; ++i)\\n a[i] = in.readInt();\\n int[] d = new int[n];\\n for(int i = 0; i < n; ++i){\\n if(i%2 == 0){\\n if(a[i] < i){\\n d[i] = n - i + a[i];\\n }\\n else{\\n d[i] = a[i] - i;\\n }\\n }\\n else{\\n d[i] = i - 0;\\n if(a[i] < n && a[i] > i){\\n d[i] += n - a[i];\\n }\\n else{\\n d[i] -= a[i];\\n }\\n }\\n }\\n \\/\\/for(int i = 0; i < n; ++i){\\n \\/\\/ out.println(d[i]);\\n \\/\\/}\\n int ans = 1;\\n for(int i = 1; i < n; ++i){\\n if(d[i] != d[i-1]){\\n ans = 0;\\n break;\\n }\\n }\\n if(ans == 1){\\n out.println(\\\"Yes\\\");\\n }\\n else{\\n out.println(\\\"No\\\");\\n }\\n out.close();\\n }\\n}\\n\\nclass 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\\n public InputReader(InputStream stream) {\\n ...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"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\":\"t=int(input())\\ns=input()\\nl=list(set(s.lower()))\\nif(len(l)==26):\\n print(\\\"YES\\\")\\nelse:\\n print(\\\"NO\\\")\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"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 N = 2e5 + 5;\\nint n, tr[N];\\nint lowbit(int x) { return x & (-x); }\\nvoid update(int x, int t) {\\n for (int i = x; i <= n; i += lowbit(i)) tr[i] = max(tr[i], t);\\n}\\nint ask(int x) {\\n int ans = 0;\\n for (int i = x; i > 0; i -= lowbit(i)) ans = max(ans, tr[i]);\\n return ans;\\n}\\nset e[N];\\nint main() {\\n scanf(\\\"%d\\\", &n);\\n for (int i = 1, x; i <= n; i++) {\\n scanf(\\\"%d\\\", &x);\\n int j = i - x;\\n if (j >= 0 && j <= i - 1) e[j].insert(x);\\n }\\n for (int i = 0; i <= n; i++) {\\n for (auto x : e[i]) {\\n int j = ask(x - 1);\\n update(x, j + 1);\\n }\\n }\\n printf(\\\"%d\\\", ask(n));\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"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].\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nconst double pi = acos(-1);\\nlong long binpow(long long a, long long b) {\\n long long res = 1;\\n while (b != 0) {\\n if (b & 1) res *= a;\\n a *= a;\\n b >>= 1;\\n }\\n return res;\\n}\\nusing namespace std;\\nlong long l, r, mid, n;\\nvector a;\\nbool check() {\\n vector temp = a;\\n for (int i = n - 1; i >= 2; i--) {\\n if (temp[i] < mid) return 0;\\n long long dif = temp[i] - mid, d = min(dif \\/ 3, a[i] \\/ 3);\\n temp[i] -= (3 * d), temp[i - 1] += d, temp[i - 2] += (2 * d);\\n }\\n for (int i = 0; i < n; i++) {\\n if (temp[i] < mid) return 0;\\n }\\n return 1;\\n}\\nvoid solve() {\\n while (l <= r) {\\n mid = (l + r) \\/ 2;\\n if (check())\\n l = mid + 1;\\n else\\n r = mid - 1;\\n }\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n int z = 1;\\n cin >> z;\\n for (int i = 1; i < z + 1; i++) {\\n cin >> n;\\n a.clear();\\n a.resize(n);\\n for (int i = 0; i < n; i++) cin >> a[i];\\n l = 1, r = 1e9 + 2;\\n solve();\\n cout << r << \\\"\\\\n\\\";\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"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;\\nvoid solve() {\\n int n;\\n cin >> n;\\n vector arr(n);\\n for (auto &x : arr) cin >> x;\\n int height = 1;\\n for (int i = 0; i < n; i++) {\\n if (i > 0 and !arr[i - 1] and !arr[i]) {\\n cout << -1 << '\\\\n';\\n return;\\n }\\n height += arr[i] + (i > 0 and arr[i] and arr[i - 1] ? 4 : 0);\\n }\\n cout << height << endl;\\n}\\nint main(int argc, char const *argv[]) {\\n int tc;\\n cin >> tc;\\n while (tc--) {\\n solve();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"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.\\nSolve the task in PYTHON3.\",\"targets\":\"t = int(input())\\n\\nfor i in range(t):\\n n = int(input())\\n \\n c1 = (n\\/\\/3) + 1\\n c2 = n\\/\\/3\\n \\n if n%3==0:\\n c1 = c1-1\\n \\n a = c1 + (2*c2)\\n \\n if a!=n:\\n c1 = c1-1\\n c2 = c2+1\\n else:\\n pass\\n \\n a = c1 + (2*c2)\\n\\n if a==n and abs(c1-c2) >=0 :\\n print(c1,c2)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"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 JAVA.\",\"targets\":\"\\/*\\n * Everything is Hard \\n * Before Easy \\n * Jai Mata Dii \\n *\\/ \\n \\nimport java.util.*;\\nimport java.io.*; \\n \\npublic class Main {\\n\\tstatic class FastReader{ BufferedReader br;StringTokenizer st;public FastReader(){br = new BufferedReader(new InputStreamReader(System.in));}String next(){while (st == null || !st.hasMoreElements()){try{st = new StringTokenizer(br.readLine());}catch (IOException e){e.printStackTrace();}}return st.nextToken();}int nextInt(){ return Integer.parseInt(next());}long nextLong(){return Long.parseLong(next());}double nextDouble(){return Double.parseDouble(next());}String nextLine(){String str = \\\"\\\"; try{str = br.readLine(); } catch (IOException e) {e.printStackTrace();} return str; }} \\n\\tstatic long mod = (long)(1e9+7); \\n\\/\\/\\t static long mod = 998244353; \\n\\/\\/\\t static Scanner sc = new Scanner(System.in); \\n\\tstatic FastReader sc = new FastReader(); \\n\\tstatic PrintWriter out = new PrintWriter(System.out);\\n\\tpublic static void main (String[] args) {\\n\\t\\tint ttt = 1;\\n\\t\\tttt = sc.nextInt();\\n\\t\\tz :for(int tc=1;tc<=ttt;tc++){\\n\\t\\t\\tint n = sc.nextInt();\\n\\t\\t\\tint m = sc.nextInt();\\n\\t\\t\\tlong a[][] = new long[n][m];\\n\\t\\t\\tfor(int i=0;im1) {\\n\\t\\t\\t\\t\\t\\tm2 = m1;\\n\\t\\t\\t\\t\\t\\tm1 = a[i][j];\\n\\t\\t\\t\\t\\t\\tk2=k1;\\n\\t\\t\\t\\t\\t\\tk1=j;\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\telse if(a[i][j]>m2) {\\n\\t\\t\\t\\t\\t\\tm2 = a[i][j];\\n\\t\\t\\t\\t\\t\\tk2=j;\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tif(Math.min(m1, m2)>min) {\\n\\t\\t\\t\\t\\tmin = Math.min(m2, m1);\\n\\t\\t\\t\\t\\tf1 = k1; f2 = k2;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\tlong max[] = new long[m];\\n\\t\\t\\tfor(int i=0;i0){if(b%2 == 0){a = (a*a)%mod;b \\/= 2;}else{ret =...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"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.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\\tfinal static long inf = (long)1e18;\\n\\tstatic void solve() throws IOException {\\n\\t\\tint n = readInt();\\n\\t\\tlong psa[][] = new long[3][n + 1];\\n\\t\\tfor (int i = 1; i <= 2; ++i)\\n\\t\\t\\tfor (int j = 1; j <= n; ++j)\\n\\t\\t\\t\\tpsa[i][j] = psa[i][j - 1] + readInt();\\n\\t\\tlong ans = inf;\\n\\t\\tfor (int i = 1; i <= n; ++i)\\n\\t\\t\\tans = Math.min(ans, Math.max(psa[2][i - 1], psa[1][n] - psa[1][i]));\\n\\t\\tpr.println(ans);\\n\\t}\\n\\tpublic static void main(String[] args) throws IOException {\\n\\t\\t\\/\\/solve();\\n\\t\\tfor (int t = readInt(); t > 0; --t) solve();\\n\\t\\tpr.close();\\n\\t}\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"You are given a matrix, consisting of n rows and m columns. The rows are numbered top to bottom, the columns are numbered left to right.\\n\\nEach cell of the matrix can be either free or locked.\\n\\nLet's call a path in the matrix a staircase if it: \\n\\n * starts and ends in the free cell; \\n * visits only free cells; \\n * has one of the two following structures: \\n 1. the second cell is 1 to the right from the first one, the third cell is 1 to the bottom from the second one, the fourth cell is 1 to the right from the third one, and so on; \\n 2. the second cell is 1 to the bottom from the first one, the third cell is 1 to the right from the second one, the fourth cell is 1 to the bottom from the third one, and so on. \\n\\n\\n\\nIn particular, a path, consisting of a single cell, is considered to be a staircase.\\n\\nHere are some examples of staircases:\\n\\n\\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\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n cin.tie(0)->sync_with_stdio(0);\\n cin.exceptions(ios::badbit | ios::failbit);\\n int n, m, qn;\\n cin >> n >> m >> qn;\\n vector> state(n, vector(m));\\n vector> notfree(n + m + 10);\\n int delta = m + 5;\\n for (auto i = -2; i <= n + 2; ++i) {\\n for (auto j = -2; j <= m + 2; ++j) {\\n notfree[i - j + delta].insert(i);\\n }\\n }\\n 42;\\n long long res = 0;\\n auto calc = [&](int i, int j) -> long long {\\n 42;\\n 42;\\n 42;\\n 42;\\n 42;\\n 42;\\n long long res = -1;\\n auto temp = notfree[i - j + delta].lower_bound(i);\\n int x = *temp - i;\\n int rx = i - *prev(temp);\\n 42;\\n {\\n auto it = notfree[i - j - 1 + delta].lower_bound(i);\\n 42;\\n int y = *it - i;\\n int p = x <= y ? 2 * x : 2 * y + 1;\\n int ry = i - 1 - *prev(it);\\n int q = rx <= ry ? 2 * rx : 2 * ry + 1;\\n 42;\\n res += 1LL * p * q;\\n }\\n {\\n auto it = notfree[i - j + 1 + delta].lower_bound(i + 1);\\n 42;\\n int y = *it - i - 1;\\n int p = x <= y ? 2 * x : 2 * y + 1;\\n int ry = i - *prev(it);\\n int q = rx <= ry ? 2 * rx : 2 * ry + 1;\\n 42;\\n res += 1LL * p * q;\\n }\\n 42;\\n return res;\\n };\\n auto flip = [&](int i, int j) -> void {\\n if (state[i][j]) {\\n res -= calc(i, j);\\n state[i][j] ^= 1;\\n notfree[i - j + delta].insert(i);\\n } else {\\n state[i][j] ^= 1;\\n notfree[i - j + delta].erase(i);\\n res += calc(i, j);\\n }\\n };\\n for (auto i = 0; i < n; ++i) {\\n for (auto j = 0; j < m; ++j) {\\n flip(i, j);\\n }\\n }\\n 42;\\n for (auto qi = 0; qi < qn; ++qi) {\\n int i, j;\\n cin >> i >> j, --i, --j;\\n flip(i, j);\\n cout << res << \\\"\\\\n\\\";\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"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.\\nSolve the task in JAVA.\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\n\\npublic class MyCpClass{\\n public static void main(String []args) throws IOException{\\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\\n StringBuilder sb = new StringBuilder();\\n \\n int Test = Integer.parseInt(br.readLine().trim());\\n while(Test-- > 0){\\n String S = br.readLine().trim();\\n String T = br.readLine().trim();\\n \\n Map mp = new TreeMap<>();\\n for(int i=0; i et : mp.entrySet()){\\n if(et.getKey() != T.charAt(2))\\n ans += expand(et.getKey(), et.getValue());\\n }\\n int ind = 0;\\n for(ind = 0; ind et : mp.entrySet())\\n ans += expand(et.getKey(), et.getValue());\\n }\\n sb.append(ans + \\\"\\\\n\\\");\\n }\\n System.out.println(sb);\\n }\\n public static String expand(char ch, int occur){\\n String res = \\\"\\\";\\n while(occur > 0){\\n res += ch;\\n occur--;\\n }\\n return res;\\n }\\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.\\nUsing java can you solve the prior task?\",\"targets\":\"\\/\\/ package Codeforce.cf741;\\n\\nimport java.io.PrintWriter;\\nimport java.util.*;\\n\\npublic class A {\\n \\/\\/ MUST SEE BEFORE SUBMISSION\\n\\/\\/ check whether int part would overflow or not, especially when it is a * b!!!!\\n\\/\\/ check if top down dp would cause overflow or not !!!!!!!!!!!!!!!!!!!!!!\\n\\/\\/ ------------consider only if you running into mistake--------\\n\\/\\/ consider all the edge cases such as k > 0 or k >= 0\\n\\/\\/ consider some edge case such as extreme situation\\n\\/\\/ when you swap forward, think more about the stop condition!!!!!!\\n public static void main(String[] args) {\\n Scanner sc = new Scanner(System.in);\\n PrintWriter pw = new PrintWriter(System.out);\\n int t = sc.nextInt();\\n\\/\\/ int t = 1;\\n for (int i = 0; i < t; i++) {\\n solve(sc, pw);\\n }\\n pw.close();\\n }\\n\\n static void solve(Scanner in, PrintWriter out){\\n int l = in.nextInt(), r = in.nextInt();\\n if ((r - (r - 1) \\/ 2) < l){\\n out.println((r % l));\\n }else{\\n out.println((r - 1) \\/ 2);\\n }\\n }\\n static int mod(int l, int r){\\n int max = 0;\\n for (int i = l; i <= r; i++) {\\n for(int j = i; j <= r; j++){\\n max = Math.max(max, j % i);\\n }\\n }\\n return max;\\n }\\n static int md(int l, int r){\\n if ((r - (r - 1) \\/ 2) < l){\\n return (r % l);\\n }else{\\n return (r - 1) \\/ 2;\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"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.\",\"targets\":\"for _ in range(int(input())):\\n n = int(input())\\n a = list(map(int, input().split()))\\n b, i = [0 for _ in range(n)], 0\\n if n % 2 == 1:\\n if a[0] == -a[1]:\\n b[0:3] = [2*a[2], a[2], -a[0]]\\n else:\\n b[0:3] = [a[2], a[2], -a[0] - a[1]]\\n i = 3\\n\\n altre, skipped = {}, set()\\n for j in range(i, n):\\n if abs(a[j]) in altre:\\n other = altre[abs(a[j])]\\n altre.pop(abs(a[j]))\\n if a[j] == a[other]:\\n b[j], b[other] = 1, -1\\n else:\\n b[j], b[other] = 1, 1\\n\\n skipped.add(j)\\n skipped.add(other)\\n else:\\n altre[abs(a[j])] = j\\n\\n while i < n:\\n if i in skipped:\\n i += 1\\n else:\\n nou_i = i+1\\n while nou_i in skipped:\\n nou_i += 1\\n b[i] = a[nou_i]\\n b[nou_i] = -a[i]\\n i = nou_i+1\\n\\n assert 0 not in b # 0 in b!!!\\n print(' '.join(str(v) for v in b))\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A witch named Marie lived deep in a remote forest. Since she is a witch, she magically covers everything she needs to live, such as food, water, and fuel.\\n\\nHer magic is activated by drawing a magic circle using some magical stones and strings. This magic circle is drawn by placing stones and tying several pairs of stones together. However, the string must not be loose. In addition, no string (except at both ends) should touch any other string or stone. Of course, you can't put multiple stones in the same place. As long as this restriction is adhered to, there are no restrictions on the positional relationship between stones or the length of the string. Also, the stone is small enough to be treated as a point, and the string is thin enough to be treated as a line segment. Moreover, she does not tie the same pair of stones with more than one string, nor does she tie both ends of a string to the same stone.\\n\\nMarie initially painted a magic circle by pasting stones on the flat walls of her house. However, she soon realized that there was a magic circle that she could never create. After a while, she devised a way to determine if the magic circle could be created on a flat wall, a two-dimensional plane. A magic circle cannot be created on a two-dimensional plane if it contains, and only then, the following parts:\\n\\nMagic Square\\n| | Magic Square\\n\\n--- | --- | ---\\nFigure 1 Complete graph with 5 vertices\\n| | Figure 2 Complete bipartite graph with 3 or 3 vertices\\n\\n\\n\\n\\nTo draw such a magic circle, she devised the magic of fixing the stone in the air. In three-dimensional space, these magic circles can also be drawn. On the contrary, she found that any magic circle could be drawn in three-dimensional space.\\n\\nNow, the problem is from here. One day Marie decides to create a magic circle of footlights at the front door of her house. However, she had already set up various magic circles in the narrow entrance, so she had to draw the magic circle of the footlights on the one-dimensional straight line, which is the only space...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include\\n#include\\n#include\\n#include\\n#include\\n#include\\n\\nusing namespace std;\\n\\n#define int long long\\n#define rep(i,n) for(int i = 0; i < (n); i++)\\n#define INF ((long long)1e18)\\n#define MOD ((int)1e9+7)\\n#define endl \\\"\\\\n\\\"\\n\\n#define yn(f) ((f)?\\\"yes\\\":\\\"no\\\")\\n#define YN(f) ((f)?\\\"YES\\\":\\\"NO\\\")\\n\\n#define MAX\\n\\nsigned main(){\\n\\t\\/\\/ cin.tie(0);\\n\\t\\/\\/ ios::sync_with_stdio(false);\\n\\t\\/\\/ cout<> graph;\\n\\t\\tvector used;\\n\\t\\t\\n\\t\\tcin>>n>>m;\\n\\t\\t\\n\\t\\tif(!n && !m) break;\\n\\t\\t\\n\\t\\tgraph.resize(n+1);\\n\\t\\tused.resize(n+1);\\n\\t\\t\\/\\/ for(int y : used){\\n\\t\\t\\t\\/\\/ cout<<\\\"used \\\"<>u>>v;\\n\\t\\t\\tgraph[u].push_back(v);\\n\\t\\t\\tgraph[v].push_back(u);\\n\\t\\t}\\n\\t\\t\\n\\t\\tfor(int i = 1; i <= n; i++){\\/\\/cout< 2){\\n\\t\\t\\t\\tflag = false;\\n\\t\\t\\t\\tbreak;\\n\\t\\t\\t} else if(graph[i].size() == 1 && used[i] == false){\\n\\t\\t\\t\\tint n = graph[i][0];\\n\\t\\t\\t\\tused[i] = true;\\n\\t\\t\\t\\t\\n\\t\\t\\t\\t\\/\\/ cout<<\\\" AA \\\"< 2){\\n\\t\\t\\t\\t\\t\\tflag = false;\\n\\t\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t\\t} else if(graph[n].size() == 2){\\n\\t\\t\\t\\t\\t\\tif(used[graph[n][0]] == false){\\n\\t\\t\\t\\t\\t\\t\\tused[n] = true;\\n\\t\\t\\t\\t\\t\\t\\tn = graph[n][0];\\n\\t\\t\\t\\t\\t\\t} else if(used[graph[n][1]] == false){\\n\\t\\t\\t\\t\\t\\t\\tused[n] = true;\\n\\t\\t\\t\\t\\t\\t\\tn = graph[n][1];\\n\\t\\t\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\t\\t\\tflag = false;\\n\\t\\t\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t} else if(graph[n].size() == 1){\\n\\t\\t\\t\\t\\t\\tused[n] = true;\\n\\t\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\n\\t\\t\\t\\tif(flag == false) break;\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\t\\/\\/ cout<<\\\"END\\\"<\\n\\nIn the second example, there are 3 interesting fences. \\n\\n * (0,0) — (30,14) — (2,10) \\n * (2,16) — (30,14) — (2,10) \\n * (30,14) — (4,6) — (2,10) \\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nusing LL = long long;\\nconst int mo = 1e9 + 7;\\nconst int maxn = 2e5 + 5;\\nnamespace MF {\\nLL qpow(LL a, LL b) {\\n LL ans = 1;\\n a %= mo;\\n while (b) {\\n if (b & 1) {\\n ans = ans * a % mo;\\n }\\n b >>= 1;\\n a = a * a % mo;\\n }\\n return ans;\\n}\\nLL fac[maxn];\\nLL inv[maxn];\\nvoid init() {\\n fac[0] = fac[1] = inv[0] = inv[1] = 1;\\n for (int i = 2; i < maxn; i++) {\\n fac[i] = fac[i - 1] * i % mo;\\n }\\n for (int i = 2; i < maxn; i++) {\\n inv[i] = (mo - mo \\/ i) * inv[mo % i] % mo;\\n }\\n for (int i = 2; i < maxn; i++) {\\n inv[i] = inv[i - 1] * inv[i] % mo;\\n }\\n}\\nLL C(int n, int m) {\\n if (n < m) {\\n return 0;\\n }\\n return fac[n] * inv[m] % mo * inv[n - m] % mo;\\n}\\n}; \\/\\/ namespace MF\\nint f(int x, int y) {\\n if (x == 0 && y == 0) {\\n return 0;\\n }\\n return 1;\\n}\\nLL C(int n, int m) {\\n if (n < m) {\\n return 0;\\n }\\n if (m == 0) {\\n return 1;\\n } else if (m == 1) {\\n return n;\\n } else if (m == 2) {\\n return (LL)n * (n - 1) \\/ 2;\\n }\\n return (LL)n * (n - 1) * (n - 2) \\/ 6;\\n}\\nint main() {\\n int n;\\n scanf(\\\"%d\\\", &n);\\n int num[4] = {0};\\n int x, y;\\n for (int i = 0; i < n; i++) {\\n scanf(\\\"%d%d\\\", &x, &y);\\n x >>= 1;\\n y >>= 1;\\n int now = (x % 2) * 2 + (y % 2);\\n num[now]++;\\n }\\n LL ans = 0;\\n for (int i = 0; i < 4; i++) {\\n for (int j = i; j < 4; j++) {\\n for (int k = j; k < 4; k++) {\\n int x1 = i \\/ 2, y1 = i % 2;\\n int x2 = j \\/ 2, y2 = j % 2;\\n int x3 = k \\/ 2, y3 = k % 2;\\n if (f(abs(x2 - x1), abs(y2 - y1)) + f(abs(x3 - x1), abs(y3 - y1)) +\\n f(abs(x3 - x2), abs(y3 - y2)) &\\n 1) {\\n continue;\\n }\\n int now[4] = {0};\\n now[i]++;\\n now[j]++;\\n now[k]++;\\n LL tmp = 1;\\n for (int u = 0; u < 4; u++) {\\n tmp *= C(num[u], now[u]);\\n }\\n ans += tmp;\\n }\\n }\\n }\\n printf(\\\"%lld\\\\n\\\", ans);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"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\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.util.*;\\npublic class Life_of_a_Flower {\\n\\n\\tpublic static void main(String[] args) {\\n\\t\\tScanner Scan = new Scanner(System.in);\\n\\t\\t\\n\\n\\t\\tint t = Scan.nextInt();\\n\\t\\t\\n\\t\\tfor(int i=0; i0) {\\n\\t\\t\\t\\t if(flower[j]==0 && flower[j-1]==0) {\\n\\t\\t\\t\\t\\t\\tk=-1;\\n\\t\\t\\t\\t\\t\\tbreak;}\\n\\t\\t\\t\\t if(flower[j]==1 && flower[j-1]==1)\\n\\t\\t\\t\\t\\t k+=5;\\n\\t\\t\\t\\t else if(flower[j]==1 && flower[j-1]!=1)\\n\\t\\t\\t\\t\\t k++;\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\telse\\n\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\tif(flower[j]==1)\\n\\t\\t\\t\\t\\t\\tk++;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\tSystem.out.println(k);\\n\\t\\t}\\n\\t\\t\\t\\n\\t}\\n\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"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\\nSolve the task in CPP.\",\"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, vector(C));\\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 vector intersection(C, 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\":\"soltask\",\"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 PYTHON3.\",\"targets\":\"t = int(input())\\n\\nfor _ in range(t):\\n W,H = map(int,input().split())\\n x1,y1,x2,y2 = map(int,input().split())\\n w,h = map(int,input().split())\\n\\n if x2-x1+w<=W or y2-y1+h<=H:\\n ans1 = float(\\\"inf\\\")\\n ans2 = float(\\\"inf\\\")\\n if x2-x1+w<=W:\\n ans1 = min(max(0,w-x1),max(0,x2-W+w))\\n\\n if y2-y1+h<=H:\\n ans2 = min(max(0,h-y1),max(0,y2-H+h))\\n\\n ans = min(ans1,ans2)\\n print(\\\"%.9f\\\" %ans)\\n\\n else:\\n print(-1)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"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\":\"from collections import defaultdict\\n\\nimport math\\ndef ncr(n,m):\\n\\treturn math.factorial(n)\\/\\/((math.factorial(m)*math.factorial(n-m)))\\n\\ndef gcd(n,m):\\n\\treturn math.gcd(n,m)\\n\\n\\n\\n\\ndef foo(n,d,c):\\n\\tdiv=n\\/\\/d\\n\\tif(n%d==0):\\n\\t\\treturn c*div\\n\\treturn c*(div+1)\\n\\n\\n\\nt=int(input())\\nfor t1 in range(0,t):\\n\\tn=int(input())\\n\\tans=(max(6,n+1)\\/\\/2) *5\\n\\tprint(ans)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"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...]\\nSolve the task in PYTHON3.\",\"targets\":\"from 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 = float('inf')\\nmod = 10 ** 9 + 7\\ndef yn(a): print(\\\"YES\\\" if a else \\\"NO\\\")\\nceil = lambda a, b: (a + b - 1) \\/\\/ b\\nt=int(input())\\nfor i in range(t):\\n n,k=[int(i) for i in input().split()]\\n bina=bin(k)[2:][::-1]\\n suma=0\\n for i in range(len(bina)):\\n if bina[i]=='1':\\n suma+=pow(n,i,mod)\\n suma%=mod\\n print(suma)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"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...\",\"targets\":\"#include \\nusing namespace std;\\nconst int E5 = 1e5;\\nconst int E6 = 1e6;\\nconst int E7 = 1e7;\\nconst int E9 = 1e9;\\nconst int N = 107;\\nconst long long INF = 1e18;\\nconst double PI = 3.14159265358979;\\nconst long long mod = E9 + 7;\\nint a[N], ans[N];\\nvector up[N], down[N];\\nbool us[N];\\nvoid dfs(int v, int dire, int w) {\\n us[v] = 1;\\n a[v] = w;\\n if (dire == 2) {\\n dfs(v, 1, w);\\n dfs(v, 0, w);\\n } else if (dire == 1) {\\n for (auto to : up[v]) {\\n if (!us[to]) dfs(to, 1, w + 1);\\n }\\n } else {\\n for (auto to : down[v]) {\\n dfs(to, 0, w - 1);\\n }\\n }\\n}\\nint main() {\\n int n, pos = 0, mn = 0;\\n cin >> n;\\n for (int i = 1; i <= n; ++i) {\\n cout << \\\"? \\\";\\n int pos = 0;\\n for (int j = 1; j <= n; ++j) {\\n if (j == i) {\\n cout << 2 << ' ';\\n continue;\\n }\\n cout << 1 << ' ';\\n }\\n cout << endl;\\n int x;\\n cin >> x;\\n if (i != x) {\\n up[i].push_back(x);\\n down[x].push_back(i);\\n }\\n cout << \\\"? \\\";\\n for (int j = 1; j <= n; ++j) {\\n if (j == i) {\\n cout << 1 << ' ';\\n continue;\\n }\\n cout << 2 << ' ';\\n }\\n cout << endl;\\n cin >> x;\\n if (!x) mn = x;\\n if (i != x) {\\n up[x].push_back(i);\\n down[i].push_back(x);\\n }\\n }\\n dfs(mn, 1, 0);\\n cout << \\\"! \\\";\\n for (int i = 1; i <= n; ++i) {\\n cout << a[i] << ' ';\\n }\\n cout << endl;\\n return 0;\\n}\",\"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()(())\",\"targets\":\"#include \\nusing namespace std;\\nvoid problem() {\\n int testcases;\\n cin >> testcases;\\n while (testcases--) {\\n int number;\\n cin >> number;\\n string siva = \\\"\\\";\\n for (int i = 0; i < number; i++) {\\n siva += \\\"()\\\";\\n }\\n int l = 2 * number;\\n cout << siva << \\\"\\\\n\\\";\\n for (int i = 1; i < number; i++) {\\n char t = siva[i];\\n siva[i] = siva[l - i - 1];\\n siva[l - i - 1] = t;\\n cout << siva << \\\"\\\\n\\\";\\n }\\n }\\n}\\nint main() { problem(); }\",\"language\":\"python\",\"split\":\"valid\",\"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...\\nSolve the task in PYTHON3.\",\"targets\":\"def printResult():\\n for i in range(n, 0, -1):\\n if f[n][i] >= k:\\n print(n - i)\\n return\\n print(-1)\\n\\nif __name__ == '__main__':\\n test = int(input())\\n for _ in range(test):\\n n, k = map(int, input().split())\\n a = list(map(int, input().split()))\\n a = [0] + a\\n f = [[0 for _ in range(n + 1)] for _ in range(n + 1)]\\n for i in range(1, n + 1):\\n for j in range(1, i + 1):\\n f[i][j] = f[i - 1][j]\\n if a[i] == j:\\n f[i][j] = max(f[i][j], f[i - 1][j - 1] + 1)\\n else:\\n f[i][j] = max(f[i][j], f[i - 1][j - 1])\\n printResult()\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"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 cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nint a[200050];\\nint main() {\\n int t;\\n cin >> t;\\n while (t--) {\\n long long n, k;\\n cin >> n >> k;\\n int m = max((long long)1, n - 2 * k);\\n for (int i = 1; i <= n; i++) {\\n cin >> a[i];\\n }\\n long long ans = 2 - k * (a[1] | a[2]);\\n for (int i = m; i < n; i++) {\\n for (int j = i + 1; j <= n; j++)\\n ans = max(ans, (long long)i * j - (long long)k * (a[i] | a[j]));\\n }\\n cout << ans << endl;\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"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.\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"a=int(input())\\nfor i in range(a):\\n arr=[int(a) for a in input().split()]\\n n=int(arr[0])\\n m=int(arr[1])\\n k=int(arr[2])\\n if(n==1 and m==0):\\n if 0\\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;\\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, k;\\n cin >> n >> k;\\n vector> edges;\\n unordered_set seen;\\n for (int i = 0; i < k; i++) {\\n int u, v;\\n cin >> u >> v;\\n u--;\\n v--;\\n if (u > v) swap(u, v);\\n edges.push_back(make_pair(u, v));\\n seen.insert(u);\\n seen.insert(v);\\n }\\n vector rem;\\n for (int i = 0; i < 2 * n; i++) {\\n if (seen.count(i) == 0) rem.push_back(i);\\n }\\n int skp = (int)(rem).size() \\/ 2;\\n for (int i = 0; i < n - k; i++) {\\n edges.push_back(make_pair(rem[i], rem[i + skp]));\\n }\\n int out = 0;\\n for (int i = 0; i < n; i++)\\n for (int j = i + 1; j < n; j++) {\\n if (edges[i].first < edges[j].first &&\\n edges[j].first < edges[i].second) {\\n if (edges[j].second > edges[i].second) out++;\\n } else if (edges[i].first < edges[j].first &&\\n edges[i].second < edges[j].first) {\\n if (edges[j].second < edges[i].second &&\\n edges[j].second < edges[i].second)\\n out++;\\n } else if (edges[i].first > edges[j].first) {\\n if (edges[i].first < edges[j].second &&\\n edges[j].second < edges[i].second)\\n out++;\\n }\\n }\\n cout << out << endl;\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Hiking club \\\"Up the hill\\\" just returned from a walk. Now they are trying to remember which hills they've just walked through.\\n\\nIt is known that there were N stops, all on different integer heights between 1 and N kilometers (inclusive) above the sea level. On the first day they've traveled from the first stop to the second stop, on the second day they've traveled from the second to the third and so on, and on the last day they've traveled from the stop N - 1 to the stop N and successfully finished their expedition.\\n\\nThey are trying to find out which heights were their stops located at. They have an entry in a travel journal specifying how many days did they travel up the hill, and how many days did they walk down the hill.\\n\\nHelp them by suggesting some possible stop heights satisfying numbers from the travel journal.\\n\\nInput\\n\\nIn the first line there is an integer non-negative number A denoting the number of days of climbing up the hill. Second line contains an integer non-negative number B — the number of days of walking down the hill (A + B + 1 = N, 1 ≤ N ≤ 100 000).\\n\\nOutput\\n\\nOutput N space-separated distinct integers from 1 to N inclusive, denoting possible heights of the stops in order of visiting.\\n\\nExamples\\n\\nInput\\n\\n0\\n1\\n\\n\\nOutput\\n\\n2 1 \\n\\n\\nInput\\n\\n2\\n1\\n\\nOutput\\n\\n1 3 4 2\\\":\",\"targets\":\"#include \\nusing namespace std;\\nconst double Pi = acos((double)-1);\\nconst double Eps = 1E-6;\\nint read() {\\n int $x;\\n scanf(\\\"%d\\\", &$x);\\n return $x;\\n}\\nlong long sqr(long long $x) { return $x * $x; }\\nint x[100000], N, A, B;\\nint main() {\\n A = read(), B = read();\\n N = A + B + 1;\\n x[0] = 1;\\n int i = 0, t;\\n t = 1;\\n while (A--) x[++i] = ++t;\\n t = 1;\\n while (B--) x[++i] = --t;\\n for (i = 0; i < N; ++i) printf(\\\"%d \\\", x[i] - t + 1);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"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 *...\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconstexpr long long N = 10005;\\nconstexpr long long D = 200;\\nconstexpr long double EPS = 1e-7;\\nofstream fout;\\nifstream fin;\\nlong long n, m, sz, k;\\nint fl;\\nlong long gr(int a, int b) {\\n cout << \\\"or \\\" << a + 1 << \\\" \\\" << b + 1 << \\\"\\\\n\\\" << flush;\\n long long c;\\n cin >> c;\\n return c;\\n}\\nlong long ga(int a, int b) {\\n cout << \\\"and \\\" << a + 1 << \\\" \\\" << b + 1 << \\\"\\\\n\\\" << flush;\\n long long c;\\n cin >> c;\\n return c;\\n}\\nvoid solve() {\\n long long a, b, c;\\n cin >> n >> k;\\n vector v(n);\\n {\\n long long i1 = ga(0, 1);\\n long long i2 = ga(2, 1);\\n long long i3 = ga(0, 2);\\n long long s1 = gr(0, 1);\\n long long s2 = gr(2, 1);\\n long long s3 = gr(0, 2);\\n v[0] = ((s1 | s2) ^ s2) | i1 | i3;\\n v[1] = (s1 - v[0] + i1);\\n v[2] = (s3 - v[0] + i3);\\n for (int i = (3); i < (n); i++) {\\n a = ga(0, i);\\n b = gr(0, i);\\n v[i] = (b - v[0] + a);\\n }\\n sort(v.begin(), v.end());\\n cout << \\\"finish \\\" << v[k - 1] << \\\"\\\\n\\\";\\n }\\n}\\nsigned main(int argc, char *argv[]) {\\n ios::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n cout.precision(14);\\n cout.fixed;\\n int t = 1;\\n srand(time(0));\\n fin.open(\\\"input.txt\\\");\\n fout.open(\\\"output.txt\\\");\\n fout.precision(14);\\n fout.fixed;\\n int y = 0;\\n while (t--) {\\n solve();\\n }\\n fout.close();\\n fin.close();\\n}\",\"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.\\nSolve the task in JAVA.\",\"targets\":\"import java.io.*;\\nimport java.math.*;\\nimport java.security.*;\\nimport java.text.*;\\nimport java.util.*;\\nimport java.util.concurrent.*;\\nimport java.util.regex.*;\\n\\n\\n\\npublic class broz {\\n\\t\\n\\t\\n\\n\\t\\n\\tpublic static void main(String[] args) throws IOException {\\n\\t\\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\\n\\t\\tString [] str = br.readLine().split(\\\" \\\");\\n\\t\\tint n = Integer.parseInt(str[0]);\\n\\t\\tint k = Integer.parseInt(str[1]);\\n\\t\\tString arr = br.readLine();\\n\\t\\tint i=0,brojac=0;\\n\\t\\tint glavenflag=0;\\n\\t\\twhile (i= 2) \\n {\\n System.out.println(res);\\n return;\\n }\\n }\\n System.out.println(res);\\n }\\n\\n static int gcd (int a, int b) {\\n if (b == 0) {\\n return a;\\n }\\n return gcd(b, a%b);\\n }\\n\\n static void pa(int arr[]) {\\n System.out.println(Arrays.toString(arr));\\n }\\n static void pa(String arr[]) {\\n System.out.println(Arrays.toString(arr));\\n }\\n\\n static int[] sieve(int n) {\\n int prime[] = new int[n];\\n Arrays.fill(prime, 1);\\n for (int i = 2; i < n; i++) {\\n if (prime[i] == 1) {\\n for (int j = i*i; i <= n; j+=i) {\\n prime[i] = 0;\\n }\\n }\\n }\\n return prime;\\n }\\n\\n static class FastReader {\\n BufferedReader br;\\n StringTokenizer st;\\n public FastReader()\\n {\\n br = new BufferedReader(\\n new InputStreamReader(System.in));\\n }\\n public String next() {\\n while (st == null || !st.hasMoreElements()) {\\n try {\\n st = new StringTokenizer(br.readLine());\\n }\\n catch...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Everything got unclear to us in a far away constellation Tau Ceti. Specifically, the Taucetians choose names to their children in a very peculiar manner.\\n\\nTwo young parents abac and bbad think what name to give to their first-born child. They decided that the name will be the permutation of letters of string s. To keep up with the neighbours, they decided to call the baby so that the name was lexicographically strictly larger than the neighbour's son's name t.\\n\\nOn the other hand, they suspect that a name tax will be introduced shortly. According to it, the Taucetians with lexicographically larger names will pay larger taxes. That's the reason abac and bbad want to call the newborn so that the name was lexicographically strictly larger than name t and lexicographically minimum at that.\\n\\nThe lexicographical order of strings is the order we are all used to, the \\\"dictionary\\\" order. Such comparison is used in all modern programming languages to compare strings. Formally, a string p of length n is lexicographically less than string q of length m, if one of the two statements is correct:\\n\\n * n < m, and p is the beginning (prefix) of string q (for example, \\\"aba\\\" is less than string \\\"abaa\\\"), \\n * p1 = q1, p2 = q2, ..., pk - 1 = qk - 1, pk < qk for some k (1 ≤ k ≤ min(n, m)), here characters in strings are numbered starting from 1. \\n\\n\\n\\nWrite a program that, given string s and the heighbours' child's name t determines the string that is the result of permutation of letters in s. The string should be lexicographically strictly more than t and also, lexicographically minimum.\\n\\nInput\\n\\nThe first line contains a non-empty string s (1 ≤ |s| ≤ 5000), where |s| is its length. The second line contains a non-empty string t (1 ≤ |t| ≤ 5000), where |t| is its length. Both strings consist of lowercase Latin letters.\\n\\nOutput\\n\\nPrint the sought name or -1 if it doesn't exist.\\n\\nExamples\\n\\nInput\\n\\naad\\naac\\n\\n\\nOutput\\n\\naad\\n\\n\\nInput\\n\\nabad\\nbob\\n\\n\\nOutput\\n\\ndaab\\n\\n\\nInput\\n\\nabc\\ndefg\\n\\n\\nOutput\\n\\n-1\\n\\n\\nInput\\n\\nczaaab\\nabcdef\\n\\n\\nOutput\\n\\nabczaa\\n\\nNote\\n\\nIn the...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nchar s[5005], s1[5005];\\nint a[26], b[26];\\nint main() {\\n scanf(\\\"%s\\\", s);\\n ;\\n getchar();\\n scanf(\\\"%s\\\", s1);\\n ;\\n int n = strlen(s), m = strlen(s1);\\n for (int i = 0; i <= n - 1; ++i) {\\n a[s[i] - 'a']++;\\n }\\n for (int i = 0; i <= m - 1; ++i) {\\n b[s1[i] - 'a']++;\\n }\\n int cc = 0, ee = 0;\\n for (int i = 0; i <= 25; ++i) {\\n if (a[i] < b[i])\\n cc = 1;\\n else if (a[i] > b[i])\\n ee = 1;\\n }\\n if (cc == 0) {\\n if (ee == 0) {\\n int dd = 0;\\n for (int i = 0; i <= m - 2; ++i) {\\n if (s1[i] < s1[i + 1]) dd = 1;\\n }\\n if (dd == 0) {\\n printf(\\\"-1\\\\n\\\");\\n return 0;\\n }\\n } else {\\n for (int i = 0; i <= 25; ++i) {\\n a[i] -= b[i];\\n }\\n printf(\\\"%s\\\", s1);\\n for (int i = 0; i <= 25; ++i) {\\n while (a[i]) {\\n printf(\\\"%c\\\", i + 'a');\\n a[i]--;\\n }\\n }\\n printf(\\\"\\\\n\\\");\\n return 0;\\n }\\n }\\n int biaoji = -1;\\n for (int i = 0; i <= min(n - 1, m - 1); ++i) {\\n for (int j = s1[i] - 'a' + 1; j <= 25; ++j) {\\n if (a[j] > 0) biaoji = i;\\n }\\n if (a[s1[i] - 'a'] == 0) {\\n break;\\n }\\n a[s1[i] - 'a']--;\\n }\\n if (biaoji == -1) {\\n printf(\\\"-1\\\\n\\\");\\n return 0;\\n }\\n for (int i = 0; i <= 25; ++i) a[i] = 0;\\n for (int i = 0; i <= n - 1; ++i) {\\n a[s[i] - 'a']++;\\n }\\n for (int i = 0; i <= biaoji - 1; ++i) {\\n printf(\\\"%c\\\", s1[i]);\\n a[s1[i] - 'a']--;\\n }\\n for (int i = s1[biaoji] - 'a' + 1; i <= 25; ++i) {\\n if (a[i] > 0) {\\n printf(\\\"%c\\\", i + 'a');\\n a[i]--;\\n break;\\n }\\n }\\n for (int i = biaoji + 1; i <= n - 1; ++i) {\\n for (int j = 0; j <= 25; ++j) {\\n while (a[j]) {\\n printf(\\\"%c\\\", j + 'a');\\n a[j]--;\\n }\\n }\\n }\\n printf(\\\"\\\\n\\\");\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Bob is a farmer. He has a large pasture with many sheep. Recently, he has lost some of them due to wolf attacks. He thus decided to place some shepherd dogs in such a way that all his sheep are protected.\\n\\nThe pasture is a rectangle consisting of R × C cells. Each cell is either empty, contains a sheep, a wolf or a dog. Sheep and dogs always stay in place, but wolves can roam freely around the pasture, by repeatedly moving to the left, right, up or down to a neighboring cell. When a wolf enters a cell with a sheep, it consumes it. However, no wolf can enter a cell with a dog.\\n\\nInitially there are no dogs. Place dogs onto the pasture in such a way that no wolf can reach any sheep, or determine that it is impossible. Note that since you have many dogs, you do not need to minimize their number. \\n\\nInput\\n\\nFirst line contains two integers R (1 ≤ R ≤ 500) and C (1 ≤ C ≤ 500), denoting the number of rows and the numbers of columns respectively.\\n\\nEach of the following R lines is a string consisting of exactly C characters, representing one row of the pasture. Here, 'S' means a sheep, 'W' a wolf and '.' an empty cell.\\n\\nOutput\\n\\nIf it is impossible to protect all sheep, output a single line with the word \\\"No\\\".\\n\\nOtherwise, output a line with the word \\\"Yes\\\". Then print R lines, representing the pasture after placing dogs. Again, 'S' means a sheep, 'W' a wolf, 'D' is a dog and '.' an empty space. You are not allowed to move, remove or add a sheep or a wolf.\\n\\nIf there are multiple solutions, you may print any of them. You don't have to minimize the number of dogs.\\n\\nExamples\\n\\nInput\\n\\n6 6\\n..S...\\n..S.W.\\n.S....\\n..W...\\n...W..\\n......\\n\\n\\nOutput\\n\\nYes\\n..SD..\\n..SDW.\\n.SD...\\n.DW...\\nDD.W..\\n......\\n\\n\\nInput\\n\\n1 2\\nSW\\n\\n\\nOutput\\n\\nNo\\n\\n\\nInput\\n\\n5 5\\n.S...\\n...S.\\nS....\\n...S.\\n.S...\\n\\n\\nOutput\\n\\nYes\\n.S...\\n...S.\\nS.D..\\n...S.\\n.S...\\n\\nNote\\n\\nIn the first example, we can split the pasture into two halves, one containing wolves and one containing sheep. Note that the sheep at (2,1) is safe, as wolves cannot move diagonally.\\n\\nIn the second example, there are no empty...\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n char t[501][501];\\n int r, c;\\n cin >> r >> c;\\n for (int i = 0; i < r; i++) {\\n for (int j = 0; j < c; j++) {\\n cin >> t[i][j];\\n if (t[i][j] == '.') t[i][j] = 'D';\\n }\\n }\\n for (int i = 0; i < r; i++) {\\n for (int j = 0; j < c; j++) {\\n if (t[i][j] == 'W') {\\n if (t[i + 1][j] == 'S' || t[i - 1][j] == 'S' || t[i][j - 1] == 'S' ||\\n t[i][j + 1] == 'S') {\\n cout << \\\"No\\\";\\n return 0;\\n }\\n }\\n }\\n }\\n cout << \\\"Yes\\\" << endl;\\n for (int i = 0; i < r; i++) {\\n for (int j = 0; j < c; j++) {\\n cout << t[i][j];\\n }\\n cout << endl;\\n }\\n}\",\"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...\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nconst long long MOD = 1e9 + 7;\\nvoid solve(long long t) {\\n long long n;\\n cin >> n;\\n vector ls(n);\\n for (auto& x : ls) cin >> x;\\n string s;\\n cin >> s;\\n vector bl{};\\n vector rd{};\\n for (long long i = 0; i < n; i++) {\\n if (s[i] == 'R')\\n rd.push_back(ls[i]);\\n else\\n bl.push_back(ls[i]);\\n }\\n sort(bl.begin(), bl.end());\\n sort(rd.begin(), rd.end());\\n bl = {bl.rbegin(), bl.rend()};\\n long long idRed = 0;\\n vector curRed{};\\n for (long long i = 1; i <= n; i++) {\\n while (!bl.empty() && bl.back() < i) bl.pop_back();\\n if (!bl.empty()) {\\n bl.pop_back();\\n continue;\\n }\\n while (idRed < (long long)rd.size() && rd[idRed] <= i) {\\n curRed.push_back(rd[idRed]);\\n idRed++;\\n }\\n if (!curRed.empty()) {\\n curRed.pop_back();\\n continue;\\n }\\n cout << \\\"NO\\\\n\\\";\\n return;\\n }\\n cout << \\\"YES\\\\n\\\";\\n}\\nsigned main() {\\n bool multi = true;\\n if (multi) {\\n long long t;\\n cin >> t;\\n for (long long i = 0; i < t; i++) solve(i + 1);\\n } else {\\n solve(1);\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"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.\\nUsing python3 can you solve the prior task?\",\"targets\":\"m,k=map(int,input().split())\\na=list(map(int,input().split()))\\nz=0\\nfor t in a:\\n if t>0 and t>=a[k-1]:z+=1\\nprint(z)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Again, there are hard times in Berland! Many towns have such tensions that even civil war is possible. \\n\\nThere are n towns in Reberland, some pairs of which connected by two-way roads. It is not guaranteed that it is possible to reach one town from any other town using these roads. \\n\\nTowns s and t announce the final break of any relationship and intend to rule out the possibility of moving between them by the roads. Now possibly it is needed to close several roads so that moving from s to t using roads becomes impossible. Each town agrees to spend money on closing no more than one road, therefore, the total number of closed roads will be no more than two.\\n\\nHelp them find set of no more than two roads such that there will be no way between s and t after closing these roads. For each road the budget required for its closure was estimated. Among all sets find such that the total budget for the closure of a set of roads is minimum.\\n\\nInput\\n\\nThe first line of the input contains two integers n and m (2 ≤ n ≤ 1000, 0 ≤ m ≤ 30 000) — the number of towns in Berland and the number of roads.\\n\\nThe second line contains integers s and t (1 ≤ s, t ≤ n, s ≠ t) — indices of towns which break up the relationships.\\n\\nThen follow m lines, each of them contains three integers xi, yi and wi (1 ≤ xi, yi ≤ n, 1 ≤ wi ≤ 109) — indices of towns connected by the i-th road, and the budget on its closure.\\n\\nAll roads are bidirectional. It is allowed that the pair of towns is connected by more than one road. Roads that connect the city to itself are allowed. \\n\\nOutput\\n\\nIn the first line print the minimum budget required to break up the relations between s and t, if it is allowed to close no more than two roads.\\n\\nIn the second line print the value c (0 ≤ c ≤ 2) — the number of roads to be closed in the found solution.\\n\\nIn the third line print in any order c diverse integers from 1 to m — indices of closed roads. Consider that the roads are numbered from 1 to m in the order they appear in the input. \\n\\nIf it is impossible to make towns s and t...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nconst int maxn = 1010;\\nconst int maxm = 3e4 + 10;\\nconst int INF = 2e9 + 10;\\nint n, m;\\nint s, t;\\nint a[maxm], b[maxm], w[maxm];\\nvector g[maxn];\\nint cnt, dfn[maxn], low[maxn];\\nvector eg;\\nbool vis[maxn];\\nvector path;\\nvoid init() {\\n cnt = 0;\\n eg.clear();\\n path.clear();\\n memset(dfn, 0, sizeof(dfn));\\n memset(low, 0, sizeof(low));\\n memset(vis, 0, sizeof(vis));\\n}\\nvoid tarjain(int u, int pa, int ban) {\\n dfn[u] = low[u] = ++cnt;\\n bool one = true;\\n for (auto i : g[u])\\n if (i != ban) {\\n int v = a[i] + b[i] - u;\\n if (v == pa && one) {\\n one = false;\\n continue;\\n }\\n if (!dfn[v]) {\\n tarjain(v, u, ban);\\n low[u] = min(low[u], low[v]);\\n if (low[v] > dfn[u]) eg.push_back(i);\\n } else {\\n low[u] = min(low[u], dfn[v]);\\n }\\n }\\n}\\nbool get_path(int u, int ban) {\\n vis[u] = true;\\n if (u == t) return true;\\n for (auto i : g[u])\\n if (i != ban) {\\n int v = a[i] + b[i] - u;\\n if (vis[v]) continue;\\n path.push_back(i);\\n if (get_path(v, ban)) return true;\\n path.pop_back();\\n }\\n return false;\\n}\\nint main() {\\n cin >> n >> m >> s >> t;\\n for (int i = 1; i <= m; i++) {\\n scanf(\\\"%d%d%d\\\", &a[i], &b[i], &w[i]);\\n if (a[i] == b[i]) continue;\\n g[a[i]].push_back(i);\\n g[b[i]].push_back(i);\\n }\\n int ans = INF, one, two;\\n if (!get_path(s, -1)) return 0 * puts(\\\"0\\\\n0\\\");\\n vector pp(path);\\n for (auto i : pp) {\\n init();\\n tarjain(s, -1, i);\\n if (!get_path(s, i)) {\\n if (ans > w[i]) {\\n ans = w[i];\\n one = i;\\n two = -1;\\n }\\n } else {\\n set st;\\n for (auto x : path) st.insert(x);\\n for (auto j : eg)\\n if (st.count(j) && ans > w[i] + w[j]) {\\n ans = w[i] + w[j];\\n one = i;\\n two = j;\\n }\\n }\\n }\\n if (ans == INF) return 0 * puts(\\\"-1\\\");\\n printf(\\\"%d\\\\n%d\\\\n\\\", ans, 1 + (two > 0));\\n if (two > 0) return 0 * printf(\\\"%d %d\\\\n\\\", one, two);\\n return 0 * printf(\\\"%d\\\\n\\\", one);\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"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...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nstatic const int edge = 1000 * 1000 * 1000;\\nint main() {\\n ios::sync_with_stdio(false);\\n cout << \\\"? 1 1\\\" << endl;\\n int a;\\n cin >> a;\\n cout << \\\"? 1000000000 1\\\" << endl;\\n int b;\\n cin >> b;\\n cout << \\\"? 1 1000000000\\\" << endl;\\n int c;\\n cin >> c;\\n cout << \\\"? 1000000000 1000000000\\\" << endl;\\n int d;\\n cin >> d;\\n int mid = (1 + a + edge - b) \\/ 2;\\n auto ask = [&](int x) {\\n if (x < 0 || x > edge) return 2 * edge + 5;\\n cout << \\\"? \\\" << x << \\\" 1\\\" << endl;\\n int y;\\n cin >> y;\\n return y;\\n };\\n int y1 = min({ask(mid - 1), ask(mid), ask(mid + 1)}) + 1;\\n int x1 = (a + 2) - y1;\\n int x2 = edge - b + (y1 - 1);\\n int y2 = edge - c + (x1 - 1);\\n cout << \\\"! \\\" << x1 << \\\" \\\" << y1 << \\\" \\\" << x2 << \\\" \\\" << y2 << endl;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"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 PYTHON3.\",\"targets\":\"def op():\\n n = int(input())\\n a = [int(i) for i in input().split()]\\n colors = list(input())\\n blue = []\\n red = []\\n for i in range(n):\\n if colors[i]=='B':\\n blue.append(a[i])\\n else:\\n red.append(a[i])\\n blue.sort()\\n red.sort()\\n for i in range(len(blue)):\\n if blue[i]<=i:\\n return \\\"No\\\"\\n m = n\\n n = len(red)\\n for i in range(n):\\n if red[n-i-1]>m-i:\\n return \\\"No\\\"\\n return \\\"Yes\\\"\\no = []\\nfor i in range(int(input())):\\n o.append(op())\\nfor i in o:\\n print(i)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Create a program that inputs the test result data of the visual acuity test and outputs the number of people who apply to each judgment based on the following visual acuity judgment table for each of the left and right eyesight.\\n\\nJudgment | Sight\\n--- | ---\\nA | 1.1 or above\\nB | 0.6 or more and less than 1.1\\nC | 0.2 or more and less than 0.6\\nD | less than 0.2\\n\\n\\n\\n\\nInput\\n\\nThe input is given in the following format:\\n\\n\\nl1 r1\\nl2 r2\\nl3 r3\\n::\\n::\\n\\n\\nOn line i, the real number li, which represents the left visual acuity of the i-th person, and the real number ri, which represents the right visual acuity, are given, separated by blanks. However, visual acuity is 0.1 or more and 2.0 or less, and is given in 0.1 increments.\\n\\nThe number of lines of input does not exceed 40.\\n\\nOutput\\n\\nPlease output the judgment table in the following format.\\n\\nLine 1 Left eyesight is the number of people A Right eyesight is the number of people (separated by blanks)\\n2nd line The number of people whose left eyesight is B The number of people whose right eyesight is B (separated by blanks)\\n3rd line The number of people whose left eyesight is C\\n4th line Number of people with left eyesight D Number of people with right eyesight D (separated by blanks)\\n\\nExample\\n\\nInput\\n\\n1.0 1.2\\n0.8 1.5\\n1.2 0.7\\n2.0 2.0\\n\\n\\nOutput\\n\\n2 3\\n2 1\\n0 0\\n0 0\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\n\\n#define FOR(i,a,b) for(int i=(a);i<(b);i++)\\n#define REP(i,n) FOR(i,0,n)\\n#define INF (1<<29)\\n\\nint main() {\\n\\tdouble rank[4] = {INF, 1.1, 0.6, 0.2};\\n\\t\\n\\tdouble in[2];\\n\\tint ans[2][4] = {};\\n\\twhile (cin >> in[0] >> in[1]) {\\n\\t\\tREP(i, 2) {\\n\\t\\t\\tint g = 0;\\n\\t\\t\\tREP(j, 4) if (in[i] < rank[j]) g++;\\n\\t\\t\\tans[i][g - 1]++;\\n\\t\\t}\\n\\t}\\n\\t\\n\\tREP(i, 4) printf(\\\"%d %d\\\\n\\\", ans[0][i], ans[1][i]);\\n\\treturn 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Monocarp is the coach of the Berland State University programming teams. He decided to compose a problemset for a training session for his teams.\\n\\nMonocarp has n problems that none of his students have seen yet. The i-th problem has a topic a_i (an integer from 1 to n) and a difficulty b_i (an integer from 1 to n). All problems are different, that is, there are no two tasks that have the same topic and difficulty at the same time.\\n\\nMonocarp decided to select exactly 3 problems from n problems for the problemset. The problems should satisfy at least one of two conditions (possibly, both):\\n\\n * the topics of all three selected problems are different; \\n * the difficulties of all three selected problems are different. \\n\\n\\n\\nYour task is to determine the number of ways to select three problems for the problemset.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 50000) — the number of testcases.\\n\\nThe first line of each testcase contains an integer n (3 ≤ n ≤ 2 ⋅ 10^5) — the number of problems that Monocarp have.\\n\\nIn the i-th of the following n lines, there are two integers a_i and b_i (1 ≤ a_i, b_i ≤ n) — the topic and the difficulty of the i-th problem.\\n\\nIt is guaranteed that there are no two problems that have the same topic and difficulty at the same time.\\n\\nThe sum of n over all testcases doesn't exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nPrint the number of ways to select three training problems that meet either of the requirements described in the statement.\\n\\nExample\\n\\nInput\\n\\n\\n2\\n4\\n2 4\\n3 4\\n2 1\\n1 3\\n5\\n1 5\\n2 4\\n3 3\\n4 2\\n5 1\\n\\n\\nOutput\\n\\n\\n3\\n10\\n\\nNote\\n\\nIn the first example, you can take the following sets of three problems:\\n\\n * problems 1, 2, 4; \\n * problems 1, 3, 4; \\n * problems 2, 3, 4. \\n\\n\\n\\nThus, the number of ways is equal to three.\\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 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][2];\\n int top[]=new int[n+1];\\n int bottom[]=new int[n+1];\\n ArrayList arr[]=new ArrayList[n+1];\\n for(int i=1;i<=n;i++) arr[i]=new ArrayList<>();\\n for(int i=0;i\\nusing namespace std;\\nint main() {\\n int t;\\n cin >> t;\\n while (t--) {\\n int n;\\n cin >> n;\\n int A[n];\\n long long int sum = 0;\\n for (int i = 0; i < n; i++) {\\n cin >> A[i];\\n sum += A[i];\\n }\\n double mean = ((double)sum) \\/ n;\\n if (ceil(mean) == mean) {\\n cout << \\\"0\\\\n\\\";\\n } else {\\n cout << \\\"1\\\\n\\\";\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"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). \\nUsing python3 can you solve the prior task?\",\"targets\":\"for _ in range(int(input())):\\n c,d = map(int,input().split())\\n if (c==0 and d==0):\\n print(0)\\n \\n \\n elif (c==d):\\n print(1)\\n elif (abs(c-d)==1):\\n print(-1)\\n \\n \\n else:\\n p = abs(c-d)\\n if p%2==0:\\n print(2)\\n else:\\n print(-1)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Consider the decimal presentation of an integer. Let's call a number d-magic if digit d appears in decimal presentation of the number on even positions and nowhere else.\\n\\nFor example, the numbers 1727374, 17, 1 are 7-magic but 77, 7, 123, 34, 71 are not 7-magic. On the other hand the number 7 is 0-magic, 123 is 2-magic, 34 is 4-magic and 71 is 1-magic.\\n\\nFind the number of d-magic numbers in the segment [a, b] that are multiple of m. Because the answer can be very huge you should only find its value modulo 109 + 7 (so you should find the remainder after dividing by 109 + 7).\\n\\nInput\\n\\nThe first line contains two integers m, d (1 ≤ m ≤ 2000, 0 ≤ d ≤ 9) — the parameters from the problem statement.\\n\\nThe second line contains positive integer a in decimal presentation (without leading zeroes).\\n\\nThe third line contains positive integer b in decimal presentation (without leading zeroes).\\n\\nIt is guaranteed that a ≤ b, the number of digits in a and b are the same and don't exceed 2000.\\n\\nOutput\\n\\nPrint the only integer a — the remainder after dividing by 109 + 7 of the number of d-magic numbers in segment [a, b] that are multiple of m.\\n\\nExamples\\n\\nInput\\n\\n2 6\\n10\\n99\\n\\n\\nOutput\\n\\n8\\n\\n\\nInput\\n\\n2 0\\n1\\n9\\n\\n\\nOutput\\n\\n4\\n\\n\\nInput\\n\\n19 7\\n1000\\n9999\\n\\n\\nOutput\\n\\n6\\n\\nNote\\n\\nThe numbers from the answer of the first example are 16, 26, 36, 46, 56, 76, 86 and 96.\\n\\nThe numbers from the answer of the second example are 2, 4, 6 and 8.\\n\\nThe numbers from the answer of the third example are 1767, 2717, 5757, 6707, 8797 and 9747.\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\n \\n\\/**\\n *\\n * @author umang\\n *\\/\\n \\npublic class D628 {\\n \\n public static int mod = (int) (1e9+7);\\n public static long[][][] dp;\\n public static int m;\\n public static int d;\\n \\n public static long solve(String s,int index,int smaller,int mod1){\\n \\n if(index==s.length()){\\n if(mod1==0)return 1;\\n return 0;\\n }\\n if(dp[index][smaller][mod1]!=-1)\\n return dp[index][smaller][mod1];\\n else{\\n int limit=9;\\n \\n if(smaller!=0)\\n limit=(int)(s.charAt(index)-'0');\\n long init_count=0;\\n \\n for(int i=0;i<=limit;i++){\\n \\n if((index&1)==0 && i==d) continue;\\n if((index&1)!=0 && i!=d) continue;\\n \\/\\/System.out.println(\\\" \\\"+index+\\\" \\\"+i);\\n int ns;\\n if(i<(int)(s.charAt(index)-'0')) ns=0;\\n else ns=smaller;\\n init_count+=solve(s, index+1, ns,(mod1*10+i)%m);\\n init_count%=mod;\\n }\\n dp[index][smaller][mod1]=init_count;\\n return init_count;\\n }\\n }\\n \\n public static boolean isGood(String s){\\n int r=0;\\n \\n for(int i=0;i 1 && B < N){\\n int[] list = new int[B];\\n int[] rem = new int[N-B];\\n for(int i = 0, j = 0, k = 0; i< N; i++)\\n if(((mask>>i)&1)==1)\\n list[j++] = A[i];\\n else rem[k++] = A[i];\\n for(int sign = 0; sign < 1<<(B-1); sign++){\\n int sum = list[0];\\n for(int i = 0; i< B-1; i++){\\n if(((sign>>i)&1)==1)sum -= list[i+1];\\n else sum += list[i+1];\\n }\\n for(int x:rem)if(Math.abs(sum) == x)yes = true;\\n }\\n }\\n }\\n pn(yes?\\\"YES\\\":\\\"NO\\\");\\n }\\n \\/\\/SOLUTION END\\n void hold(boolean b)throws Exception{if(!b)throw new Exception(\\\"Hold right there, Sparky!\\\");}\\n void exit(boolean b){if(!b)System.exit(0);}\\n static void dbg(Object... o){System.err.println(Arrays.deepToString(o));}\\n final long IINF = (long)1e17;\\n final int INF = (int)1e9+2;\\n DecimalFormat df = new DecimalFormat(\\\"0.00000000000\\\");\\n double PI = 3.141592653589793238462643383279502884197169399, eps = 1e-8;\\n static boolean multipleTC = true, memory = true, fileIO = false;\\n FastReader in;PrintWriter out;\\n void run() throws Exception{\\n long ct = System.currentTimeMillis();\\n if (fileIO) {\\n in = new FastReader(\\\"\\\");\\n out = new PrintWriter(\\\"\\\");\\n } else {\\n in = new...\",\"language\":\"python\",\"split\":\"valid\",\"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.\\nThe above is tricky. Write me a correct solution 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\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Berland annual chess tournament is coming!\\n\\nOrganizers have gathered 2·n chess players who should be divided into two teams with n people each. The first team is sponsored by BerOil and the second team is sponsored by BerMobile. Obviously, organizers should guarantee the win for the team of BerOil.\\n\\nThus, organizers should divide all 2·n players into two teams with n people each in such a way that the first team always wins.\\n\\nEvery chess player has its rating ri. It is known that chess player with the greater rating always wins the player with the lower rating. If their ratings are equal then any of the players can win.\\n\\nAfter teams assignment there will come a drawing to form n pairs of opponents: in each pair there is a player from the first team and a player from the second team. Every chess player should be in exactly one pair. Every pair plays once. The drawing is totally random.\\n\\nIs it possible to divide all 2·n players into two teams with n people each so that the player from the first team in every pair wins regardless of the results of the drawing?\\n\\nInput\\n\\nThe first line contains one integer n (1 ≤ n ≤ 100).\\n\\nThe second line contains 2·n integers a1, a2, ... a2n (1 ≤ ai ≤ 1000).\\n\\nOutput\\n\\nIf it's possible to divide all 2·n players into two teams with n people each so that the player from the first team in every pair wins regardless of the results of the drawing, then print \\\"YES\\\". Otherwise print \\\"NO\\\".\\n\\nExamples\\n\\nInput\\n\\n2\\n1 3 2 4\\n\\n\\nOutput\\n\\nYES\\n\\n\\nInput\\n\\n1\\n3 3\\n\\n\\nOutput\\n\\nNO\\nUsing python3 can you solve the prior task?\",\"targets\":\"def main():\\n n = int(input())\\n data = input().split(' ')\\n rates = [int(i) for i in data]\\n print(distribution(n, rates))\\n\\n\\ndef distribution(count, rates):\\n rates.sort(reverse=True)\\n if rates[count - 1] > rates[count]:\\n return 'YES'\\n return 'NO'\\n\\n\\nmain()\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"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\":\"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Wed Apr 15 17:39:13 2020\\n\\n@author: pena\\n\\\"\\\"\\\"\\n\\n# -*- coding: utf-8 -*- 0 0 0 1 1 sm = 2, mn = 0.2 \\n\\\"\\\"\\\"\\nCreated on Fri Apr 3 17:34:50 2020\\n\\n@author: pena\\n\\\"\\\"\\\"\\nimport sys\\nimport math\\n\\ndef solve(s):\\n ans = (s+1) \\/\\/ 10\\n return ans\\n\\nt = int(input())\\n\\nfor i in range(t):\\n #[a,b] = [int(x) for x in input().split()]\\n s = int(input())\\n print(solve(s))\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nGiven is a string S consisting of `0` and `1`. Find the number of strings, modulo 998244353, that can result from applying the following operation on S between 0 and K times (inclusive):\\n\\n* Choose a pair of integers i, j (1\\\\leq i < j\\\\leq |S|) such that the i-th and j-th characters of S are `0` and `1`, respectively. Remove the j-th character from S and insert it to the immediate left of the i-th character.\\n\\nConstraints\\n\\n* 1 \\\\leq |S| \\\\leq 300\\n* 0 \\\\leq K \\\\leq 10^9\\n* S consists of `0` and `1`.\\n\\nInput\\n\\nInput is given from Standard Input in the following format:\\n\\n\\nS K\\n\\n\\nOutput\\n\\nFind the number of strings, modulo 998244353, that can result from applying the operation on S between 0 and K times (inclusive).\\n\\nExamples\\n\\nInput\\n\\n0101 1\\n\\n\\nOutput\\n\\n4\\n\\n\\nInput\\n\\n01100110 2\\n\\n\\nOutput\\n\\n14\\n\\n\\nInput\\n\\n1101010010101101110111100011011111011000111101110101010010101010101 20\\n\\n\\nOutput\\n\\n113434815\",\"targets\":\"#include\\n#include\\n#include\\nusing namespace std;\\ntypedef long long ll;\\ntypedef pair pll;\\n#define rep(i,n) for(int i=0;i>S>>K;\\n\\tll n=0,a[N];\\n\\tll cnt=0;\\n\\trep(i,S.size()){\\n\\t\\tif(S[i]=='0'){\\n\\t\\t\\ta[++n]=cnt;\\n\\t\\t\\tcnt=0;\\n\\t\\t}\\n\\t\\telse{\\n\\t\\t\\tcnt++;\\n\\t\\t}\\n\\t}\\n\\ta[++n]=cnt;\\n\\tchmin(K,(ll)310);\\n\\trep(i,N)rep(j,N)rep(k,N)dp[i][j][k]=0;\\n\\tdp[0][0][0]=1;\\n\\tfor(ll i=1;i<=n;i++){\\n\\t\\tll cs1[N][N],cs2[N][N];\\n\\t\\trep(j,N)for(ll k=0;k<=K;k++){\\n\\t\\t\\tif(j-1>=0&&k-1>=0){\\n\\t\\t\\t\\tcs1[j][k]=cs1[j-1][k-1];\\n\\t\\t\\t}\\n\\t\\t\\telse{\\n\\t\\t\\t\\tcs1[j][k]=0;\\n\\t\\t\\t}\\n\\t\\t\\tpl(cs1[j][k],dp[i-1][j][k]);\\n\\t\\t\\tpl(dp[i][j][k],cs1[j][k]);\\n\\t\\t\\t\\/*for(ll s=0;j-s>=0&&k-s>=0;s++){\\n\\t\\t\\t\\tpl(dp[i][j][k],dp[i-1][j-s][k-s]);\\n\\t\\t\\t}*\\/\\n\\t\\t}\\n\\t\\tfor(ll j=N-1;j>=0;j--)for(ll k=0;k<=K;k++){\\n\\t\\t\\tif(j+2\\nusing namespace std;\\nbool minimize(long long &x, long long y) {\\n if (x > y) {\\n x = y;\\n return true;\\n };\\n return false;\\n}\\nbool maximize(long long &x, long long y) {\\n if (x < y) {\\n x = y;\\n return true;\\n };\\n return false;\\n}\\nconst int LOG = 20;\\nconst int INF = 1e9 + 7;\\nconst long long LNF = 1e18 + 7;\\nconst int mod = 1e9 + 7;\\nlong long a[200100];\\nlong long f[200100] = {0};\\nlong long b[200100] = {0};\\nlong long c[200100] = {0};\\nlong long s = 0;\\nlong long k = 0;\\nlong long n;\\nvoid write() {\\n memset(f, 0, sizeof(f));\\n s = 0, k = 0;\\n cin >> n;\\n for (int i = 1; i <= n; i++) {\\n cin >> a[i];\\n f[a[i]]++;\\n }\\n b[0] = f[0];\\n for (int i = 1; i <= n; i++) {\\n b[i] = b[i - 1] + f[i];\\n }\\n}\\nvoid solve() {\\n cout << b[0] << \\\" \\\";\\n long long cnt = 0;\\n long long d = 0;\\n c[0] = 0;\\n stack p;\\n while (!p.empty()) p.pop();\\n long long L = -1;\\n for (int i = 1; i <= n; i++) {\\n if (b[i - 1] < i) {\\n for (int j = i; j <= n; j++) cout << -1 << \\\" \\\";\\n cout << \\\"\\\\n\\\";\\n return;\\n }\\n cout << f[i] + k - s << \\\" \\\";\\n if (f[i] == 0) {\\n k += i;\\n d++;\\n for (int j = L + 1; j < i; j++) {\\n for (int z = 1; z < f[j]; z++) {\\n p.push(j);\\n }\\n }\\n if (p.empty()) {\\n for (int j = i + 1; j <= n; j++) cout << -1 << \\\" \\\";\\n cout << \\\"\\\\n\\\";\\n return;\\n }\\n s += p.top();\\n p.pop();\\n L = i;\\n }\\n }\\n cout << \\\"\\\\n\\\";\\n}\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n if (fopen(\\\"txt\\\"\\n \\\".inp\\\",\\n \\\"r\\\")) {\\n freopen(\\n \\\"txt\\\"\\n \\\".inp\\\",\\n \\\"r\\\", stdin);\\n freopen(\\n \\\"txt\\\"\\n \\\".out\\\",\\n \\\"w\\\", stdout);\\n }\\n int t;\\n cin >> t;\\n while (t--) {\\n write();\\n solve();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"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 \\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\ntemplate \\ninline bool mnto(T& a, T b) {\\n return a > b ? a = b, 1 : 0;\\n}\\ntemplate \\ninline bool mxto(T& a, T b) {\\n return a < b ? a = b, 1 : 0;\\n}\\nint n;\\nint lp[1000005];\\nlong long hsh[1000005];\\nvector primes;\\nmap mp;\\nint main() {\\n mt19937_64 rnd(234901);\\n scanf(\\\"%d\\\", &n);\\n for (int i = 2; i < n + 1; i++) {\\n if (lp[i] == 0) {\\n lp[i] = i;\\n hsh[i] = rnd();\\n primes.push_back(i);\\n };\\n for (int j = 0; j < primes.size() && primes[j] <= lp[i] &&\\n (long long)primes[j] * i <= n;\\n j++) {\\n int x = primes[j] * i;\\n lp[x] = primes[j];\\n hsh[x] = hsh[primes[j]] ^ hsh[i];\\n ;\\n }\\n }\\n long long tot = 0;\\n for (int i = 2; i < n + 1; i++) {\\n hsh[i] ^= hsh[i - 1];\\n tot ^= hsh[i];\\n mp[hsh[i]] = i;\\n ;\\n };\\n if (tot == 0) {\\n printf(\\\"%d\\\\n\\\", n);\\n for (int i = 1; i < n + 1; i++) {\\n printf(\\\"%d \\\", i);\\n }\\n printf(\\\"\\\\n\\\");\\n return 0;\\n }\\n for (int i = 1; i < n + 1; i++) {\\n if ((tot ^ hsh[i]) == 0) {\\n printf(\\\"%d\\\\n\\\", n - 1);\\n for (int j = 1; j < n + 1; j++) {\\n if (j == i) continue;\\n printf(\\\"%d \\\", j);\\n }\\n printf(\\\"\\\\n\\\");\\n return 0;\\n }\\n }\\n for (int i = 1; i < n + 1; i++) {\\n if (mp[tot ^ hsh[i]]) {\\n assert(tot ^ hsh[i] ^ hsh[mp[tot ^ hsh[i]]] == 0);\\n printf(\\\"%d\\\\n\\\", n - 2);\\n for (int j = 1; j < n + 1; j++) {\\n if (j == i || j == mp[tot ^ hsh[i]]) continue;\\n printf(\\\"%d \\\", j);\\n }\\n printf(\\\"\\\\n\\\");\\n return 0;\\n }\\n }\\n printf(\\\"%d\\\\n\\\", n - 3);\\n for (int i = 1; i < n + 1; i++) {\\n if (i == 2 || i == (n - 1) \\/ 2 || i == n) continue;\\n printf(\\\"%d \\\", i);\\n }\\n printf(\\\"\\\\n\\\");\\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?\\nThe 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...\",\"targets\":\"#include \\nusing namespace std;\\nusing ll = long long;\\nusing pii = pair;\\nconst int N = (int)2e5 + 5;\\nint _ = 1;\\nint n, m, k;\\nvoid work() {\\n scanf(\\\"%d%d%d\\\", &n, &m, &k);\\n int num = n \\/ m + (n % m != 0);\\n int sum = num * (n % m);\\n priority_queue, greater > q;\\n for (int i = 1; i <= n; i++) q.push({0, i});\\n while (k--) {\\n vector app;\\n for (int i = 1; i <= sum; i++) {\\n if (i % num == 1) printf(\\\"%d \\\", num);\\n pii node = q.top();\\n q.pop();\\n printf(\\\"%d \\\", node.second);\\n app.push_back({node.first + 1, node.second});\\n if (i % num == 0) printf(\\\"\\\\n\\\");\\n }\\n for (int i = 1; !q.empty(); i++) {\\n if (i % (n \\/ m) == 1) printf(\\\"%d \\\", n \\/ m);\\n if (i % (n \\/ m) == 0) printf(\\\"\\\\n\\\");\\n pii node = q.top();\\n q.pop();\\n printf(\\\"%d \\\", node.second);\\n app.push_back({node.first, node.second});\\n }\\n for (auto i : app) q.push(i);\\n }\\n printf(\\\"\\\\n\\\");\\n}\\nint main() {\\n scanf(\\\"%d\\\", &_);\\n while (_--) {\\n work();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"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.\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nint32_t seed;\\nmt19937 rng(seed = chrono::steady_clock::now().time_since_epoch().count());\\ninline int32_t rnd(int32_t l = 0, int32_t r = INT_MAX) {\\n return uniform_int_distribution(l, r)(rng);\\n}\\ntemplate \\nostream& operator<<(ostream& out, const pair& a) {\\n return out << \\\"(\\\" << a.first << \\\" , \\\" << a.second << \\\")\\\";\\n}\\ntemplate \\nostream& operator<<(ostream& out, const vector& a) {\\n out << \\\"[\\\";\\n for (const auto& i : a) out << i << \\\" , \\\";\\n return out << \\\"]\\\";\\n}\\ntemplate \\nostream& operator<<(ostream& out, const set& a) {\\n out << \\\"{\\\";\\n for (const auto& i : a) out << i << \\\" , \\\";\\n return out << \\\"}\\\";\\n}\\ntemplate \\nostream& operator<<(ostream& out, const map& a) {\\n out << \\\"<\\\";\\n for (const auto& i : a) out << i << \\\" , \\\";\\n return out << \\\">\\\";\\n}\\ntemplate \\ntypename enable_if::type, char>::value,\\n ostream&>::type\\noperator<<(ostream& out, T (&a)[N]) {\\n out << '[';\\n for (size_t i = 0; i < N; ++i) out << a[i] << \\\" , \\\";\\n out << ']';\\n return out;\\n}\\nsigned main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n int32_t n, i, first = 0;\\n cin >> n;\\n vector a(n), b(n), o, e;\\n for (i = 0; i < n; i++) {\\n cin >> a[i];\\n b[i] = a[i] \\/ 2;\\n first += b[i];\\n if (a[i] & 1) {\\n if (a[i] > 0) {\\n o.push_back(i);\\n } else {\\n e.push_back(i);\\n }\\n }\\n }\\n if (first > 0) {\\n for (i = 0; i < e.size() && first; i++, first--) b[e[i]]--;\\n } else if (first < 0) {\\n for (i = 0; i < o.size() && first; i++, first++) b[o[i]]++;\\n }\\n for (i = 0; i < n; i++) cout << b[i] << \\\"\\\\n\\\";\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"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 python3 can you solve the prior task?\",\"targets\":\"import sys\\ninput = lambda: sys.stdin.readline().strip()\\n\\n# sys.stdin = open('input.txt', 'r')\\n# sys.stdout = open('output.txt', 'w')\\n\\ndef solve():\\n n = int(input())\\n arr = list(map(int, input().split()))\\n res = 0\\n brr = sorted(arr)\\n p = 1\\n while arr!=brr:\\n if p:\\n for i in range(0,n,2):\\n arr[i:i+2] = sorted(arr[i:i+2])\\n else:\\n for i in range(1,n,2):\\n arr[i:i+2] = sorted(arr[i:i+2])\\n p ^= 1\\n res += 1\\n return res\\n\\nfor _ in range(int(input())):\\n print(solve())\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Appleman has a tree with n vertices. Some of the vertices (at least one) are colored black and other vertices are colored white.\\n\\nConsider a set consisting of k (0 ≤ k < n) edges of Appleman's tree. If Appleman deletes these edges from the tree, then it will split into (k + 1) parts. Note, that each part will be a tree with colored vertices.\\n\\nNow Appleman wonders, what is the number of sets splitting the tree in such a way that each resulting part will have exactly one black vertex? Find this number modulo 1000000007 (109 + 7).\\n\\nInput\\n\\nThe first line contains an integer n (2 ≤ n ≤ 105) — the number of tree vertices. \\n\\nThe second line contains the description of the tree: n - 1 integers p0, p1, ..., pn - 2 (0 ≤ pi ≤ i). Where pi means that there is an edge connecting vertex (i + 1) of the tree and vertex pi. Consider tree vertices are numbered from 0 to n - 1.\\n\\nThe third line contains the description of the colors of the vertices: n integers x0, x1, ..., xn - 1 (xi is either 0 or 1). If xi is equal to 1, vertex i is colored black. Otherwise, vertex i is colored white.\\n\\nOutput\\n\\nOutput a single integer — the number of ways to split the tree modulo 1000000007 (109 + 7).\\n\\nExamples\\n\\nInput\\n\\n3\\n0 0\\n0 1 1\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n6\\n0 1 1 0 4\\n1 1 0 0 1 0\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\n10\\n0 1 2 1 4 4 4 0 8\\n0 0 0 1 0 1 1 0 0 1\\n\\n\\nOutput\\n\\n27\\\":\",\"targets\":\"#include \\n#pragma GCC optimize(\\\"O2\\\")\\nusing namespace std;\\nconst int MAXN = 1e6 + 10;\\nconst long long MOD = 1e9 + 7;\\nconst long long MOD2 = 998244353;\\nconst long long INF = 8e18;\\nconst int LOG = 22;\\nlong long pw(long long a, long long b, long long mod) {\\n return (!b ? 1\\n : (b & 1 ? (a * pw(a * a % mod, b \\/ 2, mod)) % mod\\n : pw(a * a % mod, b \\/ 2, mod)));\\n}\\nlong long dp[2][MAXN];\\nint x[MAXN];\\nvector G[MAXN];\\nvoid DFS(int v, int par) {\\n dp[0][v] = 1;\\n dp[1][v] = 0;\\n for (auto u : G[v]) {\\n if (u == par) {\\n continue;\\n }\\n DFS(u, v);\\n dp[1][v] = (dp[1][v] * dp[0][u]) % MOD;\\n dp[1][v] = (dp[1][v] + dp[1][u] * dp[0][v]) % MOD;\\n dp[0][v] = (dp[0][v] * dp[0][u]) % MOD;\\n }\\n if (x[v]) {\\n dp[1][v] = dp[0][v];\\n } else {\\n dp[0][v] = (dp[0][v] + dp[1][v]) % MOD;\\n }\\n}\\nint main() {\\n ios::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n ;\\n int n;\\n cin >> n;\\n for (int i = 1; i < n; i++) {\\n int a;\\n cin >> a;\\n G[a].push_back(i);\\n G[i].push_back(a);\\n }\\n for (int i = 0; i < n; i++) {\\n cin >> x[i];\\n }\\n DFS(0, -1);\\n cout << dp[1][0] << \\\"\\\\n\\\";\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"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\":\"w=input()\\ng=input()\\nx=g.count(\\\"D\\\")\\nc=g.count(\\\"A\\\")\\nif (g.count(\\\"D\\\")>g.count(\\\"A\\\")):\\n print('Danik')\\nelif (g.count(\\\"D\\\") num_two) {\\n return i - 1;\\n }\\n }\\n return 0;\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"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;\\nconst int INF = 0x3f3f3f3f;\\nconst int MAXN = 2e5 + 1;\\nint n, a[MAXN];\\nbool c[MAXN];\\nint main() {\\n scanf(\\\"%d\\\", &n);\\n for (int i = 1; i <= n; ++i) scanf(\\\"%d\\\", &a[i]);\\n for (int i = 1; i <= n; ++i) {\\n char c_;\\n cin >> c_;\\n c[i] = (c_ == 'R');\\n }\\n int cnt = 0;\\n for (int i = 2; i <= n; ++i) cnt += c[i] == c[i - 1];\\n sort(a + 1, a + 1 + n);\\n int l = cnt, r = cnt + 1;\\n int pw;\\n for (int i = 1; i <= n; ++i) {\\n int j = i;\\n while (j < n && c[j + 1] == c[i]) ++j;\\n printf(\\\"%d %c\\\\n\\\", a[r++], \\\"LR\\\"[c[i]]);\\n if (i == 1) pw = c[i];\\n for (int k = i + 1; k <= j; ++k) {\\n pw ^= 1;\\n printf(\\\"%d %c\\\\n\\\", a[l--], \\\"LR\\\"[pw]);\\n }\\n i = j;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A plane is flying at a constant height of h meters above the ground surface. Let's consider that it is flying from the point (-10^9, h) to the point (10^9, h) parallel with Ox axis.\\n\\nA glider is inside the plane, ready to start his flight at any moment (for the sake of simplicity let's consider that he may start only when the plane's coordinates are integers). After jumping from the plane, he will fly in the same direction as the plane, parallel to Ox axis, covering a unit of distance every second. Naturally, he will also descend; thus his second coordinate will decrease by one unit every second.\\n\\nThere are ascending air flows on certain segments, each such segment is characterized by two numbers x_1 and x_2 (x_1 < x_2) representing its endpoints. No two segments share any common points. When the glider is inside one of such segments, he doesn't descend, so his second coordinate stays the same each second. The glider still flies along Ox axis, covering one unit of distance every second. \\n\\n If the glider jumps out at 1, he will stop at 10. Otherwise, if he jumps out at 2, he will stop at 12.\\n\\nDetermine the maximum distance along Ox axis from the point where the glider's flight starts to the point where his flight ends if the glider can choose any integer coordinate to jump from the plane and start his flight. After touching the ground the glider stops altogether, so he cannot glide through an ascending airflow segment if his second coordinate is 0.\\n\\nInput\\n\\nThe first line contains two integers n and h (1 ≤ n ≤ 2⋅10^{5}, 1 ≤ h ≤ 10^{9}) — the number of ascending air flow segments and the altitude at which the plane is flying, respectively.\\n\\nEach of the next n lines contains two integers x_{i1} and x_{i2} (1 ≤ x_{i1} < x_{i2} ≤ 10^{9}) — the endpoints of the i-th ascending air flow segment. No two segments intersect, and they are given in ascending order.\\n\\nOutput\\n\\nPrint one integer — the maximum distance along Ox axis that the glider can fly from the point where he jumps off the plane to the point where he...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nint n, h;\\nint s[200010][2];\\nint main() {\\n int a, b, res, ans;\\n scanf(\\\"%d%d\\\", &n, &h);\\n for (int i = 1; i <= n; i++) scanf(\\\"%d%d\\\", &s[i][0], &s[i][1]);\\n a = 1;\\n b = 1;\\n res = h;\\n while (b < n) {\\n if (res > s[b + 1][0] - s[b][1]) {\\n res -= s[b + 1][0] - s[b][1];\\n b++;\\n } else\\n break;\\n }\\n ans = s[b][1] - s[a][0] + res;\\n while (a <= n && b < n) {\\n a++;\\n res += s[a][0] - s[a - 1][1];\\n while (b < n) {\\n if (res > s[b + 1][0] - s[b][1]) {\\n res -= s[b + 1][0] - s[b][1];\\n b++;\\n } else\\n break;\\n }\\n ans = max(ans, s[b][1] - s[a][0] + res);\\n }\\n ans = max(ans, s[b][1] - s[a][0] + res);\\n printf(\\\"%d\\\\n\\\", ans);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"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...\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\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-4;\\nconst double PI = 3.1415926535897932;\\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};\\nModInt a[15];\\nModInt adj[15][15];\\nModInt p[16384];\\nModInt h[14][16384];\\nint n;\\nModInt g(int x, int y) {\\n ModInt ans = 1;\\n for (int i = 0; i < (n); ++i) {\\n if (x >> i & 1) {\\n ans *= h[i][y];\\n }\\n }\\n return ans;\\n}\\nint main() {\\n scanf(\\\"%d\\\", &(n));\\n for (int i = 0; i < (n); ++i) {\\n int xx;\\n scanf(\\\"%d\\\", &xx);\\n a[i] = xx;\\n }\\n for (int i = 0; i < (n); ++i) {\\n for (int j = 0; j < (n); ++j) {\\n if (i == j) continue;\\n adj[i][j] = a[i] \\/ (a[i] + a[j]);\\n }\\n }\\n int bmax = 1 << n;\\n for (int i = 0; i < (n); ++i) {\\n for (int bm = 0; bm < (bmax); ++bm) {\\n h[i][bm] = 1;\\n for (int bi = 0; bi < (n); ++bi) {\\n if (bm >> bi & 1) {\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"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\":\"import java.io.*;\\nimport java.util.Arrays;\\nimport java.util.Locale;\\nimport java.util.StringTokenizer;\\n\\npublic class A {\\n\\n private void solve() {\\n int t = ri();\\n while(t-- > 0) {\\n String s = rs(), T = rs();\\n char[] chars = s.toCharArray();\\n Arrays.sort(chars);\\n int lastIndex = -1;\\n for(int i = 0; i < chars.length; i++) {\\n if(chars[i] == 'c') lastIndex = i;\\n }\\n if(T.equals(\\\"abc\\\")) {\\n if(s.contains(\\\"a\\\") && s.contains(\\\"b\\\") && s.contains(\\\"c\\\"))\\n for (int i = 0; i < chars.length; i++) {\\n if (lastIndex == -1 || chars[lastIndex] != 'c' || lastIndex <= i) break;\\n if (chars[i] == 'b') {\\n chars[i] = 'c';\\n chars[lastIndex] = 'b';\\n lastIndex--;\\n }\\n }\\n }\\n out.println(new String(chars));\\n }\\n }\\n\\n \\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\n\\n long sqrtLong(long x) {\\n long root = (long) Math.sqrt(x);\\n while (root * root > x) --root;\\n while ((root + 1) * (root + 1) <= x) ++root;\\n return root;\\n }\\n\\n int gcd(int a, int b) {\\n if (b == 0)\\n return a;\\n else\\n return gcd(b, a % b);\\n }\\n\\n int lcm(int a, int b) {\\n return a \\/ gcd(a, b) * b;\\n }\\n\\n int phi(int n) {\\n int result = n;\\n for (int i = 2; i * i <= n; ++i)\\n if (n % i == 0) {\\n while (n % i == 0)\\n n \\/= i;\\n result -= result \\/ i;\\n }\\n if (n > 1)\\n result -= result \\/ n;\\n return result;\\n }\\n\\n int factmod(int n, int p) {\\n int res = 1;\\n while (n > 1) {\\n res = (res * ((n \\/ p) % 2 == 1 ? p - 1 : 1)) % p;\\n for (int i = 2; i <= n % p; ++i)\\n res = (res * i) % p;\\n n \\/= p;\\n }\\n return res % p;\\n...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"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 < … =0 and j>=0):\\n if int(s[i]) - int(a[j])>=0:\\n ans = ans + str(int(s[i]) - int(a[j]))\\n i = i-1\\n j = j-1\\n elif i-1>=0:\\n if 0<=(int(s[i-1:i+1]) - int(a[j]))<=9:\\n ans = ans + str(int(s[i-1:i+1]) - int(a[j]))\\n i = i-2\\n j = j-1\\n else:\\n check = 0\\n break\\n else:\\n check = 0\\n break\\n while(i>=0):\\n ans = ans + s[i]\\n i = i-1\\n \\n if i != -1 or j != -1:\\n check = 0\\n \\n if check:\\n ans = int(ans[::-1])\\n print(ans)\\n else:\\n print(-1)\",\"language\":\"python\",\"split\":\"test\",\"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.InputStreamReader;\\nimport java.io.PrintWriter;\\nimport java.util.StringTokenizer;\\n\\npublic class taskc {\\n\\tpublic static void main(String[] args) {\\n\\t\\tFastScanner in = new FastScanner();\\n\\t\\tPrintWriter out = new PrintWriter(System.out);\\n\\t\\tint n = in.nextInt();\\n\\t\\tlong a[] = new long[n];\\n\\t\\tfor (int i = 0; i < n; i++) {\\n\\t\\t\\ta[i] = in.nextLong();\\n\\t\\t}\\n\\t\\tlong b[][] = new long[n][n];\\n\\t\\tlong mn[][] = new long[n][n];\\n\\t\\tfor (int i = 0; i < n; i++) {\\n\\t\\t\\tlong sum = a[i] * (i % 2 == 0 ? 1L : -1L);\\n\\t\\t\\tlong min = sum;\\n\\t\\t\\tfor (int j = i + 1; j < n; j++) {\\n\\t\\t\\t\\tsum += a[j] * (j % 2 == 0 ? 1L : -1L);\\n\\t\\t\\t\\tmin = Math.min(min, sum);\\n\\t\\t\\t\\tb[i][j] = sum;\\n\\t\\t\\t\\tmn[i][j] = min;\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\tlong ans = 0;\\n\\t\\tfor (int i = 0; i < n; i++) {\\n\\t\\t\\tfor (int j = i + 1; j < n; j++) {\\n\\t\\t\\t\\tif (i % 2 == 0 && j % 2 == 1) {\\n\\t\\t\\t\\t\\tlong mid = (i + 1 < j - 1 ? b[i + 1][j - 1] : 0L);\\n\\t\\t\\t\\t\\tlong mid_min = (i + 1 < j - 1 ? mn[i + 1][j - 1] : 0L);\\n\\t\\t\\t\\t\\t\\/\\/ use x from left to make x + mid_min >= 0 && x + mid - y = 0;\\n\\t\\t\\t\\t\\tlong from_x = Math.max(1, -mid_min), to_x = a[i];\\n\\t\\t\\t\\t\\tif (from_x > to_x) {\\n\\t\\t\\t\\t\\t\\tcontinue;\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\tlong from_y = Math.max(1, from_x + mid);\\n\\t\\t\\t\\t\\tlong to_y = Math.min(a[j], to_x + mid);\\n\\t\\t\\t\\t\\tif (from_y <= to_y) {\\n\\t\\t\\t\\t\\t\\tans += to_y - from_y + 1;\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\tout.println(ans);\\n\\t\\tout.flush();\\n\\t}\\n\\n\\tstatic class FastScanner {\\n\\t\\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\\n\\t\\tStringTokenizer tok = new StringTokenizer(\\\"\\\");\\n\\t\\tString next() {\\n\\t\\t\\twhile(!tok.hasMoreTokens()) {\\n\\t\\t\\t\\ttry {\\n\\t\\t\\t\\t\\ttok = new StringTokenizer(br.readLine());\\n\\t\\t\\t\\t} catch (Exception e) {\\n\\t\\t\\t\\t\\te.printStackTrace();\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\treturn tok.nextToken();\\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\\tfloat nextFloat() {\\n\\t\\t\\treturn Float.parseFloat(next());\\n\\t\\t}\\n\\t\\tdouble nextDouble() {\\n\\t\\t\\treturn Double.parseDouble(next());\\n\\t\\t}\\n\\t}\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 solution for \\\"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\\\":\",\"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\\nsys.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):\\n visited_nodes.add(nodes)\\n for neighbour in self.graph[nodes]:\\n if neighbour not in visited_nodes:\\n self.dfs_utility(neighbour, visited_nodes)\\n\\n def dfs(self, node):\\n Visited = set()\\n self.dfs_utility(i, Visited)\\n\\n def bfs(self, node, f_node):\\n count = float(\\\"inf\\\")\\n visited = set()\\n level = 0\\n if node not in visited:\\n queue.append([node, level])\\n visited.add(node)\\n flag = 0\\n while queue:\\n parent = queue.popleft()\\n if parent[0] == f_node:\\n flag = 1\\n count = min(count, parent[1])\\n level = parent[1] + 1\\n for item in self.graph[parent[0]]:\\n if item not in visited:\\n queue.append([item, level])\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"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 long long n;\\n cin >> n;\\n vector masv;\\n long long x;\\n for (long long i = 0; i < n; i++) {\\n cin >> x;\\n masv.push_back(x);\\n }\\n vector mast;\\n for (long long i = 0; i < n; i++) {\\n cin >> x;\\n mast.push_back(x);\\n }\\n priority_queue mas;\\n long long s;\\n long long z;\\n z = 0;\\n for (long long i = 0; i < n; i++) {\\n s = 0;\\n mas.push((masv[i] + z) * (-1));\\n while ((mas.size() > 0) && (mas.top() * (-1) < mast[i] + z)) {\\n s = s + mas.top() * (-1) - z;\\n mas.pop();\\n }\\n s = s + mas.size() * mast[i];\\n z = z + mast[i];\\n cout << s << \\\" \\\";\\n }\\n cin >> n;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"ATMs of a well-known bank of a small country are arranged so that they can not give any amount of money requested by the user. Due to the limited size of the bill dispenser (the device that is directly giving money from an ATM) and some peculiarities of the ATM structure, you can get at most k bills from it, and the bills may be of at most two distinct denominations.\\n\\nFor example, if a country uses bills with denominations 10, 50, 100, 500, 1000 and 5000 burles, then at k = 20 such ATM can give sums 100 000 burles and 96 000 burles, but it cannot give sums 99 000 and 101 000 burles.\\n\\nLet's suppose that the country uses bills of n distinct denominations, and the ATM that you are using has an unlimited number of bills of each type. You know that during the day you will need to withdraw a certain amount of cash q times. You know that when the ATM has multiple ways to give money, it chooses the one which requires the minimum number of bills, or displays an error message if it cannot be done. Determine the result of each of the q of requests for cash withdrawal.\\n\\nInput\\n\\nThe first line contains two integers n, k (1 ≤ n ≤ 5000, 1 ≤ k ≤ 20).\\n\\nThe next line contains n space-separated integers ai (1 ≤ ai ≤ 107) — the denominations of the bills that are used in the country. Numbers ai follow in the strictly increasing order.\\n\\nThe next line contains integer q (1 ≤ q ≤ 20) — the number of requests for cash withdrawal that you will make.\\n\\nThe next q lines contain numbers xi (1 ≤ xi ≤ 2·108) — the sums of money in burles that you are going to withdraw from the ATM.\\n\\nOutput\\n\\nFor each request for cash withdrawal print on a single line the minimum number of bills it can be done, or print - 1, if it is impossible to get the corresponding sum.\\n\\nExamples\\n\\nInput\\n\\n6 20\\n10 50 100 500 1000 5000\\n8\\n4200\\n100000\\n95000\\n96000\\n99000\\n10100\\n2015\\n9950\\n\\n\\nOutput\\n\\n6\\n20\\n19\\n20\\n-1\\n3\\n-1\\n-1\\n\\n\\nInput\\n\\n5 2\\n1 2 3 5 8\\n8\\n1\\n3\\n5\\n7\\n9\\n11\\n13\\n15\\n\\n\\nOutput\\n\\n1\\n1\\n1\\n2\\n2\\n2\\n2\\n-1\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nint a[5005];\\nint n, k, q;\\nmap judge;\\nint main() {\\n int x;\\n scanf(\\\"%d%d\\\", &n, &k);\\n for (int i = 0; i < n; i++) {\\n scanf(\\\"%d\\\", a + i);\\n judge[a[i]] = 1;\\n }\\n scanf(\\\"%d\\\", &q);\\n while (q--) {\\n int ans = 1000000000;\\n scanf(\\\"%d\\\", &x);\\n for (int i = 0; i < n; ++i)\\n for (int j = 0; j <= k; ++j) {\\n if (x == a[i] * j) ans = min(ans, j);\\n if (x < a[i] * j) break;\\n for (int jj = 1; jj <= k - j; ++jj)\\n if ((x - a[i] * j) % jj == 0 && judge.count((x - a[i] * j) \\/ jj))\\n ans = min(ans, j + jj);\\n }\\n if (ans <= k)\\n printf(\\\"%d\\\\n\\\", ans);\\n else\\n puts(\\\"-1\\\");\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Luntik came out for a morning stroll and found an array a of length n. He calculated the sum s of the elements of the array (s= ∑_{i=1}^{n} a_i). Luntik calls a subsequence of the array a nearly full if the sum of the numbers in that subsequence is equal to s-1.\\n\\nLuntik really wants to know the number of nearly full subsequences of the array a. But he needs to come home so he asks you to solve that problem!\\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\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases. The next 2 ⋅ t lines contain descriptions 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 ≤ 60) — the length of the array.\\n\\nThe second line contains n integers a_1, a_2, …, a_n (0 ≤ a_i ≤ 10^9) — the elements of the array a.\\n\\nOutput\\n\\nFor each test case print the number of nearly full subsequences of the array.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n5\\n1 2 3 4 5\\n2\\n1000 1000\\n2\\n1 0\\n5\\n3 0 2 1 1\\n5\\n2 1 0 3 0\\n\\n\\nOutput\\n\\n\\n1\\n0\\n2\\n4\\n4\\n\\nNote\\n\\nIn the first test case, s=1+2+3+4+5=15, only (2,3,4,5) is a nearly full subsequence among all subsequences, the sum in it is equal to 2+3+4+5=14=15-1.\\n\\nIn the second test case, there are no nearly full subsequences.\\n\\nIn the third test case, s=1+0=1, the nearly full subsequences are (0) and () (the sum of an empty subsequence is 0).\\nSolve the task 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, i, j, cnt0, cnt1;\\n cin >> n;\\n long long int a[n];\\n for (i = 0; i < n; i++) {\\n cin >> a[i];\\n }\\n cnt0 = count(a, a + n, 0);\\n cnt1 = count(a, a + n, 1);\\n long long int p = pow(2, cnt0);\\n cout << p * cnt1 << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A sequence a_1,a_2,... ,a_n is said to be \\/\\\\\\/\\\\\\/\\\\\\/ when the following conditions are satisfied:\\n\\n* For each i = 1,2,..., n-2, a_i = a_{i+2}.\\n* Exactly two different numbers appear in the sequence.\\n\\n\\n\\nYou are given a sequence v_1,v_2,...,v_n whose length is even. We would like to make this sequence \\/\\\\\\/\\\\\\/\\\\\\/ by replacing some of its elements. Find the minimum number of elements that needs to be replaced.\\n\\nConstraints\\n\\n* 2 \\\\leq n \\\\leq 10^5\\n* n is even.\\n* 1 \\\\leq v_i \\\\leq 10^5\\n* v_i is an integer.\\n\\nInput\\n\\nInput is given from Standard Input in the following format:\\n\\n\\nn\\nv_1 v_2 ... v_n\\n\\n\\nOutput\\n\\nPrint the minimum number of elements that needs to be replaced.\\n\\nExamples\\n\\nInput\\n\\n4\\n3 1 3 2\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\n6\\n105 119 105 119 105 119\\n\\n\\nOutput\\n\\n0\\n\\n\\nInput\\n\\n4\\n1 1 1 1\\n\\n\\nOutput\\n\\n2\\nSolve the task in JAVA.\",\"targets\":\"import java.util.*;\\n\\npublic class Main {\\n public static void main(String[] args) throws Exception {\\n Scanner sc = new Scanner(System.in);\\n int n = sc.nextInt();\\n TreeMap oddmap = new TreeMap(Comparator.reverseOrder());\\n TreeMap evenmap = new TreeMap(Comparator.reverseOrder());\\n for(int i = 0; i < n; i++){\\n int a = sc.nextInt();\\n if(i % 2 == 0){\\n if(evenmap.containsKey(a)){\\n evenmap.put(a,evenmap.get(a)+1);\\n }else{\\n evenmap.put(a,1);\\n }\\n }else{\\n if(oddmap.containsKey(a)){\\n oddmap.put(a,oddmap.get(a)+1);\\n }else{\\n oddmap.put(a,1);\\n }\\n }\\n }\\n PriorityQueue odd = new PriorityQueue<>();\\n PriorityQueue even = new PriorityQueue<>();\\n for(Map.Entry e : oddmap.entrySet()){\\n odd.add(new Point(e.getKey(), e.getValue()));\\n }\\n for(Map.Entry e : evenmap.entrySet()){\\n even.add(new Point(e.getKey(), e.getValue()));\\n }\\n Point odd1 = odd.poll();\\n Point even1 = even.poll();\\n if(odd1.key != even1.key){\\n System.out.println(n - odd1.value - even1.value);\\n }else{\\n int odd2 = odd.size() != 0 ? odd.poll().value : 0;\\n int even2 = even.size() != 0 ? even.poll().value : 0;\\n System.out.println(Math.min(n - odd1.value - even2 , n - odd2 - even1.value));\\n }\\n }\\n}\\n\\nclass Point implements Comparable{\\n int key,value;\\n public Point(int k, int v){\\n this.key = k;\\n this.value = v;\\n }\\n \\n public int compareTo(Point p){\\n if(this.value > p.value){\\n return -1;\\n }else if(this.value < p.value){\\n return 1;\\n }\\n return 0;\\n }\\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\\nfrom\",\"targets\":\"math import floor, gcd,sqrt,ceil\\nfrom collections import Counter, defaultdict\\nfrom heapq import heapify,heappop,heappush\\ndef main():\\n for _ in range(int(input())):\\n n,m,k=map(int,input().split())\\n chaiye=n*m\\/\\/2\\n if(n%2==0 and m%2==0 and k%2!=1):\\n print(\\\"YES\\\")\\n elif(m==1 and k>0):\\n print(\\\"NO\\\")\\n elif(n==1 and n*m\\/\\/2-k>0):\\n print(\\\"NO\\\")\\n elif(n==2 and k%2==1):\\n print(\\\"NO\\\")\\n elif(m==2 and (n*m\\/\\/2-k)%2==1):\\n print(\\\"NO\\\")\\n elif(n%2==0 and k%2==1):\\n print(\\\"NO\\\")\\n elif(m%2==0 and (n*m\\/\\/2-k)%2==1):\\n print(\\\"NO\\\")\\n elif(m%2==1 and k<=n*(m-1)\\/\\/2 ):\\n print(\\\"YES\\\")\\n elif(n%2==1 and n*m\\/\\/2-k<=(n-1)*m\\/\\/2):\\n print(\\\"YES\\\")\\n else:\\n print(\\\"NO\\\")\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n \\n\\n\\n\\n\\n\\n\\n \\n \\n \\n\\n\\n \\n \\nmain()\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A permutation of length k is a sequence of k integers from 1 to k containing each integer exactly once. For example, the sequence [3, 1, 2] is a permutation of length 3.\\n\\nWhen Neko was five, he thought of an array a of n positive integers and a permutation p of length n - 1. Then, he performed the following:\\n\\n * Constructed an array b of length n-1, where b_i = min(a_i, a_{i+1}). \\n * Constructed an array c of length n-1, where c_i = max(a_i, a_{i+1}). \\n * Constructed an array b' of length n-1, where b'_i = b_{p_i}. \\n * Constructed an array c' of length n-1, where c'_i = c_{p_i}. \\n\\n\\n\\nFor example, if the array a was [3, 4, 6, 5, 7] and permutation p was [2, 4, 1, 3], then Neko would have constructed the following arrays:\\n\\n * b = [3, 4, 5, 5] \\n * c = [4, 6, 6, 7] \\n * b' = [4, 5, 3, 5] \\n * c' = [6, 7, 4, 6] \\n\\n\\n\\nThen, he wrote two arrays b' and c' on a piece of paper and forgot about it. 14 years later, when he was cleaning up his room, he discovered this old piece of paper with two arrays b' and c' written on it. However he can't remember the array a and permutation p he used.\\n\\nIn case Neko made a mistake and there is no array a and permutation p resulting in such b' and c', print -1. Otherwise, help him recover any possible array a. \\n\\nInput\\n\\nThe first line contains an integer n (2 ≤ n ≤ 10^5) — the number of elements in array a.\\n\\nThe second line contains n-1 integers b'_1, b'_2, …, b'_{n-1} (1 ≤ b'_i ≤ 10^9).\\n\\nThe third line contains n-1 integers c'_1, c'_2, …, c'_{n-1} (1 ≤ c'_i ≤ 10^9).\\n\\nOutput\\n\\nIf Neko made a mistake and there is no array a and a permutation p leading to the b' and c', print -1. Otherwise, print n positive integers a_i (1 ≤ a_i ≤ 10^9), denoting the elements of the array a.\\n\\nIf there are multiple possible solutions, print any of them. \\n\\nExamples\\n\\nInput\\n\\n\\n5\\n4 5 3 5\\n6 7 4 6\\n\\n\\nOutput\\n\\n\\n3 4 6 5 7 \\n\\n\\nInput\\n\\n\\n3\\n2 4\\n3 2\\n\\n\\nOutput\\n\\n\\n-1\\n\\n\\nInput\\n\\n\\n8\\n2 3 1 1 2 4 3\\n3 4 4 2 5 5 4\\n\\n\\nOutput\\n\\n\\n3 4 5 2 1 4 3 2 \\n\\nNote\\n\\nThe first example is explained is the problem statement.\\n\\nIn the third example, for a...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nconst int N = 2e5 + 10, INF = 0x3f3f3f3f;\\nconst long long mod = 1e9 + 7;\\nconst double eps = 1e-10, Pi = 2 * acos(0);\\nlong long LINF = 1LL << 60;\\nint n, m;\\nstruct NODE {\\n int v, id;\\n};\\nint e[N], d[N], cnt, num;\\nint a[N], b[N], vis[N], val[N];\\nstack S;\\nqueue G[N];\\nmap mp;\\nvoid dfs(int u) {\\n while (!G[u].empty()) {\\n NODE cur = G[u].front();\\n G[u].pop();\\n if (e[cur.id] == 0) continue;\\n e[cur.id] = 0;\\n dfs(cur.v);\\n }\\n S.push(val[u]);\\n}\\nvoid solve() {\\n scanf(\\\"%d\\\", &n);\\n for (int i = 1; i < n; i++) scanf(\\\"%d\\\", &a[i]);\\n for (int i = 1; i < n; i++) scanf(\\\"%d\\\", &b[i]);\\n int cnte = 0, flag = 0;\\n for (int i = 1; i < n; i++) {\\n int u = a[i], v = b[i];\\n if (u > v) {\\n flag = 1;\\n break;\\n }\\n if (!mp[u]) mp[u] = ++cnt, val[cnt] = u;\\n if (!mp[v]) mp[v] = ++cnt, val[cnt] = v;\\n e[++cnte] = 1;\\n d[mp[u]]++;\\n d[mp[v]]++;\\n G[mp[u]].push((NODE){mp[v], cnte});\\n G[mp[v]].push((NODE){mp[u], cnte});\\n }\\n int cntOdd = 0, s = 1;\\n for (int i = 1; i <= cnt; i++) {\\n if (d[i] % 2) {\\n cntOdd++;\\n s = i;\\n }\\n }\\n if ((cntOdd == 2 || cntOdd == 0) && !flag) {\\n dfs(s);\\n if (S.size() != n)\\n printf(\\\"-1\\\\n\\\");\\n else {\\n while (!S.empty()) {\\n printf(\\\"%d \\\", S.top());\\n S.pop();\\n }\\n printf(\\\"\\\\n\\\");\\n }\\n } else\\n printf(\\\"-1\\\\n\\\");\\n}\\nint main() {\\n int ce, c = 1, flag = 1;\\n solve();\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"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. \\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst int Mod = (int)1e9 + 7;\\nlong long qpow(long long a, int b) {\\n long long ret = 1;\\n long long tmp = a;\\n while (b > 0) {\\n if (b & 1) {\\n ret *= tmp;\\n ret %= Mod;\\n }\\n tmp *= tmp;\\n tmp %= Mod;\\n b >>= 1;\\n }\\n return ret;\\n}\\nconst int N = 1011111;\\nint main() {\\n ios ::sync_with_stdio(false);\\n int p, k;\\n cin >> p >> k;\\n if (k == 0) {\\n cout << qpow(p, p - 1) << '\\\\n';\\n return 0;\\n } else if (k == 1) {\\n cout << qpow(p, p) << '\\\\n';\\n return 0;\\n }\\n int cnt = 1;\\n for (long long i = k; i != 1; i = i * k % p) cnt++;\\n cout << qpow(p, (p - 1) \\/ cnt) << '\\\\n';\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"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#incl\",\"targets\":\"ude \\nusing namespace std;\\nlong long pre[200005][20];\\nint32_t main() {\\n for (long long i = 1; i <= 200000; i++) {\\n for (long long j = 0; j < 20; j++) {\\n pre[i][j] = pre[i - 1][j];\\n if ((i & (1 << j))) {\\n ++pre[i][j];\\n }\\n }\\n }\\n long long t;\\n cin >> t;\\n while (t--) {\\n long long l, r;\\n cin >> l >> r;\\n long long ans = 0;\\n for (long long i = 0; i < 20; i++) {\\n ans = max(ans, pre[r][i] - pre[l - 1][i]);\\n }\\n cout << r - l + 1 - ans << '\\\\n';\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\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\":\"import java.io.OutputStream;\\nimport java.io.IOException;\\nimport java.io.InputStream;\\nimport java.io.PrintWriter;\\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 *\\/\\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 D1DvestiDvadtsatOdinProstayaVersiya solver = new D1DvestiDvadtsatOdinProstayaVersiya();\\n int testCount = Integer.parseInt(in.next());\\n for (int i = 1; i <= testCount; i++)\\n solver.solve(i, in, out);\\n out.close();\\n }\\n\\n static class D1DvestiDvadtsatOdinProstayaVersiya {\\n public void solve(int testNumber, InputReader in, PrintWriter out) {\\n int n = in.nextInt();\\n int q = in.nextInt();\\n String s = in.next();\\n int[] cum = new int[n + 1];\\n for (int i = 0; i < s.length(); i++) {\\n cum[i] = (i == 0 ? 0 : cum[i - 1]);\\n if ((s.charAt(i) == '+' && i % 2 == 0) ||\\n (s.charAt(i) == '-' && i % 2 == 1)) {\\n cum[i] += 1;\\n } else {\\n cum[i] -= 1;\\n }\\n }\\n for (int i = 0; i < q; i++) {\\n int l = in.nextInt() - 1;\\n int r = in.nextInt() - 1;\\n int val = cum[r] - (l == 0 ? 0 : cum[l - 1]);\\n if (val == 0) {\\n out.println(0);\\n } else if (val % 2 == 0) {\\n out.println(2);\\n } else {\\n out.println(1);\\n }\\n }\\n }\\n\\n }\\n\\n static class InputReader {\\n private static final int BUFFER_LENGTH = 1 << 10;\\n private InputStream stream;\\n private byte[] buf = new...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Let's call a positive integer good if there is no digit 0 in its decimal representation.\\n\\nFor an array of a good numbers a, one found out that the sum of some two neighboring elements is equal to x (i.e. x = a_i + a_{i + 1} for some i). x had turned out to be a good number as well.\\n\\nThen the elements of the array a were written out one after another without separators into one string s. For example, if a = [12, 5, 6, 133], then s = 1256133.\\n\\nYou are given a string s and a number x. Your task is to determine the positions in the string that correspond to the adjacent elements of the array that have sum x. If there are several possible answers, you can print any of them.\\n\\nInput\\n\\nThe first line contains the string s (2 ≤ |s| ≤ 5 ⋅ 10^5).\\n\\nThe second line contains an integer x (2 ≤ x < 10^{200000}).\\n\\nAn additional constraint on the input: the answer always exists, i.e you can always select two adjacent substrings of the string s so that if you convert these substrings to integers, their sum is equal to x.\\n\\nOutput\\n\\nIn the first line, print two integers l_1, r_1, meaning that the first term of the sum (a_i) is in the string s from position l_1 to position r_1.\\n\\nIn the second line, print two integers l_2, r_2, meaning that the second term of the sum (a_{i + 1}) is in the string s from position l_2 to position r_2.\\n\\nExamples\\n\\nInput\\n\\n\\n1256133\\n17\\n\\n\\nOutput\\n\\n\\n1 2\\n3 3\\n\\n\\nInput\\n\\n\\n9544715561\\n525\\n\\n\\nOutput\\n\\n\\n2 3\\n4 6\\n\\n\\nInput\\n\\n\\n239923\\n5\\n\\n\\nOutput\\n\\n\\n1 1\\n2 2\\n\\n\\nInput\\n\\n\\n1218633757639\\n976272\\n\\n\\nOutput\\n\\n\\n2 7\\n8 13\\n\\nNote\\n\\nIn the first example s[1;2] = 12 and s[3;3] = 5, 12+5=17.\\n\\nIn the second example s[2;3] = 54 and s[4;6] = 471, 54+471=525.\\n\\nIn the third example s[1;1] = 2 and s[2;2] = 3, 2+3=5.\\n\\nIn the fourth example s[2;7] = 218633 and s[8;13] = 757639, 218633+757639=976272.\\\":\",\"targets\":\"#include \\nusing namespace std;\\nconst long double eps = 1e-9;\\nconst int inf = (1 << 30) - 1;\\nconst long long inf64 = (1LL << 62) - 1;\\nconst long double pi = acos(-1);\\ntemplate \\ninline T abs(T x) {\\n return x < 0 ? -x : x;\\n}\\ntemplate \\ninline T sqr(T x) {\\n return x * x;\\n}\\ntemplate \\ninline bool umx(T1& a, T2 b) {\\n if (a < b) {\\n a = b;\\n return 1;\\n }\\n return 0;\\n}\\ntemplate \\ninline bool umn(T1& a, T2 b) {\\n if (b < a) {\\n a = b;\\n return 1;\\n }\\n return 0;\\n}\\nconst int MINP = 1000 * 1000 * 1000 - 1000;\\nconst int CNTP = 8;\\nvector p;\\nbool IsPrime(int x) {\\n for (int i = 2; i * i <= x; ++i) {\\n if (x % i == 0) {\\n return false;\\n }\\n }\\n return true;\\n}\\nvector ZFunction(const string& s) {\\n int n = ((int)(s).size());\\n vector z(n);\\n z[0] = n;\\n int ind = -1;\\n for (int i = int(1); i < int(n); ++i) {\\n if (ind != -1) {\\n umx(z[i], min(ind + z[ind] - i, z[i - ind]));\\n }\\n while (i + z[i] < n && s[z[i]] == s[i + z[i]]) {\\n ++z[i];\\n }\\n if (ind == -1 || ind + z[ind] < i + z[i]) {\\n ind = i;\\n }\\n }\\n return z;\\n}\\nvector x_mod;\\nvector> pow_10;\\nvector> s_pref_mod;\\nvector SubMod(int l, int r) {\\n vector res(((int)(p).size()));\\n for (int i = int(0); i < int(((int)(p).size())); ++i) {\\n res[i] = (s_pref_mod[i][r + 1] -\\n pow_10[i][r - l + 1] * (long long)s_pref_mod[i][l]) %\\n p[i];\\n res[i] = (res[i] < 0 ? res[i] + p[i] : res[i]);\\n }\\n return res;\\n}\\nstring Sum(const string& a, const string& b) {\\n string res = \\\"\\\";\\n int add = 0;\\n for (int i = int(0); i < int(max(((int)(a).size()), ((int)(b).size())));\\n ++i) {\\n if (i < ((int)(a).size())) {\\n add += a[((int)(a).size()) - i - 1] - '0';\\n }\\n if (i < ((int)(b).size())) {\\n add += b[((int)(b).size()) - i - 1] - '0';\\n }\\n res.push_back('0' + add % 10);\\n add \\/= 10;\\n }\\n if (add > 0) {\\n res.push_back('0' + add);\\n }\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Codeforces user' handle color depends on his rating — it is red if his rating is greater or equal to 2400; it is orange if his rating is less than 2400 but greater or equal to 2200, etc. Each time participant takes part in a rated contest, his rating is changed depending on his performance.\\n\\nAnton wants the color of his handle to become red. He considers his performance in the rated contest to be good if he outscored some participant, whose handle was colored red before the contest and his rating has increased after it.\\n\\nAnton has written a program that analyses contest results and determines whether he performed good or not. Are you able to do the same?\\n\\nInput\\n\\nThe first line of the input contains a single integer n (1 ≤ n ≤ 100) — the number of participants Anton has outscored in this contest .\\n\\nThe next n lines describe participants results: the i-th of them consists of a participant handle namei and two integers beforei and afteri ( - 4000 ≤ beforei, afteri ≤ 4000) — participant's rating before and after the contest, respectively. Each handle is a non-empty string, consisting of no more than 10 characters, which might be lowercase and uppercase English letters, digits, characters «_» and «-» characters.\\n\\nIt is guaranteed that all handles are distinct.\\n\\nOutput\\n\\nPrint «YES» (quotes for clarity), if Anton has performed good in the contest and «NO» (quotes for clarity) otherwise.\\n\\nExamples\\n\\nInput\\n\\n3\\nBurunduk1 2526 2537\\nBudAlNik 2084 2214\\nsubscriber 2833 2749\\n\\n\\nOutput\\n\\nYES\\n\\nInput\\n\\n3\\nApplejack 2400 2400\\nFluttershy 2390 2431\\nPinkie_Pie -2500 -2450\\n\\n\\nOutput\\n\\nNO\\n\\nNote\\n\\nIn the first sample, Anton has outscored user with handle Burunduk1, whose handle was colored red before the contest and his rating has increased after the contest.\\n\\nIn the second sample, Applejack's rating has not increased after the contest, while both Fluttershy's and Pinkie_Pie's handles were not colored red before the contest.\\n# cod\",\"targets\":\"ing=utf8\\n\\nif __name__ == '__main__':\\n n = int(input())\\n flag = False\\n for i in range(n):\\n name, before, after = str(input()).split()\\n before = int(before)\\n after = int(after)\\n if after > before >= 2400:\\n flag = True\\n if flag:\\n print('YES')\\n else:\\n print('NO')\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Petya has a rooted tree with an integer written on each vertex. The vertex 1 is the root. You are to answer some questions about the tree.\\n\\nA tree is a connected graph without cycles. A rooted tree has a special vertex called the root. The parent of a node v is the next vertex on the shortest path from v to the root.\\n\\nEach question is defined by three integers v, l, and k. To get the answer to the question, you need to perform the following steps: \\n\\n * First, write down the sequence of all integers written on the shortest path from the vertex v to the root (including those written in the v and the root). \\n * Count the number of times each integer occurs. Remove all integers with less than l occurrences. \\n * Replace the sequence, removing all duplicates and ordering the elements by the number of occurrences in the original list in increasing order. In case of a tie, you can choose the order of these elements arbitrary. \\n * The answer to the question is the k-th number in the remaining sequence. Note that the answer is not always uniquely determined, because there could be several orderings. Also, it is possible that the length of the sequence on this step is less than k, in this case the answer is -1. \\n\\n\\n\\nFor example, if the sequence of integers on the path from v to the root is [2, 2, 1, 7, 1, 1, 4, 4, 4, 4], l = 2 and k = 2, then the answer is 1.\\n\\nPlease answer all questions about the tree.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^6). Description of the test cases follows.\\n\\nThe first line of each test case contains two integers n, q (1 ≤ n, q ≤ 10^6) — the number of vertices in the tree and the number of questions.\\n\\nThe second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ n), where a_i is the number written on the i-th vertex.\\n\\nThe third line contains n-1 integers p_2, p_3, …, p_n (1 ≤ p_i ≤ n), where p_i is the parent of node i. It's guaranteed that the values p define a correct tree.\\n\\nEach of the next q lines contains three...\\nimpor\",\"targets\":\"t java.io.*;\\nimport java.util.*;\\n\\npublic class Main {\\n\\n\\tprivate static class Query {\\n\\t\\tint v;\\n\\t\\tint l;\\n\\t\\tint k;\\n\\t\\tint ans;\\n\\t\\tint idx;\\n\\t\\tQuery(Scanner sc, int idx) throws Exception {\\n\\t\\t\\tthis.v = sc.nextInt();\\n\\t\\t\\tthis.l = sc.nextInt();\\n\\t\\t\\tthis.k = sc.nextInt();\\n\\t\\t\\tthis.idx = idx;\\n\\t\\t}\\n\\t}\\n\\t\\n\\tprivate static void increment(int val, int[] perm, int[] perm_inv,\\n\\t\\t\\t\\t\\t\\t\\t\\t int[] lb, int[] count) {\\n\\t\\tint dst_index = lb[count[val]+1]-1;\\n\\t\\tint src_index = perm_inv[val];\\n\\t\\t\\n\\t\\tint temp = perm[src_index];\\n\\t\\tperm[src_index] = perm[dst_index];\\n\\t\\tperm[dst_index] = temp;\\n\\t\\t\\n\\t\\tperm_inv[perm[src_index]] = src_index;\\n\\t\\tperm_inv[perm[dst_index]] = dst_index;\\n\\t\\t\\n\\t\\tlb[count[val]+1]--;\\n\\t\\tcount[val]++;\\n\\t\\t\\n\\t\\t\\n\\t}\\n\\t\\n\\t\\n\\t\\n\\tprivate static void decrement(int val, int[] perm, int[] perm_inv,\\n\\t\\t\\t int[] lb, int[] count) {\\n\\t\\tint dst_index = lb[count[val]];\\n\\t\\tint src_index = perm_inv[val];\\n\\t\\t\\n\\t\\tint temp = perm[src_index];\\n\\t\\tperm[src_index] = perm[dst_index];\\n\\t\\tperm[dst_index] = temp;\\n\\t\\t\\n\\t\\tperm_inv[perm[src_index]] = src_index;\\n\\t\\tperm_inv[perm[dst_index]] = dst_index;\\n\\t\\t\\n\\t\\tlb[count[val]]++;\\n\\t\\tcount[val]--;\\n\\t\\t\\n\\t\\t\\n\\t}\\n\\t\\n\\tprivate static void dfs(int v, List[] graph, int[] A,\\n\\t\\t\\t\\t\\t\\t\\tint[] perm, int[] perm_inv, int[] lb, int[] count,\\n\\t\\t\\t\\t\\t\\t\\tList[] queries, int N, int[] P) {\\n\\t\\tList traversal = new ArrayList<>();\\n\\t\\ttraversal.add(v);\\n\\t\\tint[] children_visited = new int[N+1];\\n\\t\\t\\n\\t\\twhile (!traversal.isEmpty()) {\\n\\t\\t\\tv = traversal.remove(traversal.size()-1);\\n\\t\\t\\t\\n\\t\\t\\tif (children_visited[v] == 0) {\\n\\t\\t\\t\\tif (P[v] != 0) {\\n\\t\\t\\t\\t\\ttraversal.add(P[v]);\\n\\t\\t\\t\\t\\tchildren_visited[P[v]]++;\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tincrement(A[v], perm, perm_inv, lb, count);\\n\\t\\t\\t\\t\\n\\t\\t\\t\\tfor (final Query q : queries[v]) {\\n\\t\\t\\t\\t\\tif (lb[q.l] + q.k - 1 > N) {\\n\\t\\t\\t\\t\\t\\tq.ans = -1;\\n\\t\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\t\\tq.ans = perm[lb[q.l] + q.k - 1];\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\n\\t\\t\\t\\tfor (final Integer child : graph[v]) {\\n\\t\\t\\t\\t\\ttraversal.add(child);\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\n\\t\\t\\tif (P[v] != 0 && children_visited[v] == graph[v].size()) {\\n\\t\\t\\t\\tdecrement(A[v], perm, perm_inv, lb, count);\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\t\\n\\tstatic class Scanner {\\n\\t\\tScanner(InputStream...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"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.\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"t=int(input())\\nwhile(t):\\n n,k=map(int,input().split())\\n l=list(map(int,input().split()))\\n c=0\\n z=list(l)\\n z.sort()\\n d={}\\n for i in range(n):\\n d[z[i]]=i+1\\n temp=0\\n if n==1:\\n print(\\\"YES\\\")\\n else:\\n i=0\\n e={}\\n for i in range(n-1):\\n w=d[l[i+1]]-d[l[i]]\\n if w!=1:\\n # print(l[i],l[i+1])\\n c+=1\\n if c+1<=k:\\n print(\\\"YES\\\")\\n else:\\n print(\\\"NO\\\")\\n # print(c)\\n\\n t-=1\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"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...\\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(0);\\n cout.tie(0);\\n int test = 1;\\n cin >> test;\\n while (test--) {\\n long long int n, m;\\n cin >> n >> m;\\n long long int sum1 = 0, sum2 = 0;\\n long long int a[n], b[n], mina[n], mi = 0;\\n for (int i = 0; i < n; i++) {\\n cin >> a[i] >> b[i];\\n sum1 += a[i];\\n sum2 += b[i];\\n mina[i] = max(0LL, m - b[i]);\\n mi += mina[i];\\n a[i] = min(a[i], m);\\n }\\n long long int ans = sum1 - sum2 + (n * m);\\n long long int x = ans - 2LL * mi;\\n for (int i = 0; i < n; i++) {\\n if (x <= 0) break;\\n long long int temp = min(2LL * (a[i] - mina[i]), x);\\n temp \\/= 2;\\n mina[i] += temp;\\n x -= 2LL * temp;\\n }\\n cout << abs(x) << \\\"\\\\n\\\";\\n for (int i = 0; i < n; i++) cout << mina[i] << \\\" \\\" << m - mina[i] << \\\"\\\\n\\\";\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Given is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \\\\leq i \\\\leq N - 1) connects Vertex a_i and b_i.\\n\\nEach of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0.\\n\\nNow, the following Q operations will be performed:\\n\\n* Operation j (1 \\\\leq j \\\\leq Q): Increment by x_j the counter on every vertex contained in the subtree rooted at Vertex p_j.\\n\\n\\n\\nFind the value of the counter on each vertex after all operations.\\n\\nConstraints\\n\\n* 2 \\\\leq N \\\\leq 2 \\\\times 10^5\\n* 1 \\\\leq Q \\\\leq 2 \\\\times 10^5\\n* 1 \\\\leq a_i < b_i \\\\leq N\\n* 1 \\\\leq p_j \\\\leq N\\n* 1 \\\\leq x_j \\\\leq 10^4\\n* The given graph is a tree.\\n* All values in input are integers.\\n\\nInput\\n\\nInput is given from Standard Input in the following format:\\n\\n\\nN Q\\na_1 b_1\\n:\\na_{N-1} b_{N-1}\\np_1 x_1\\n:\\np_Q x_Q\\n\\n\\nOutput\\n\\nPrint the values of the counters on Vertex 1, 2, \\\\ldots, N after all operations, in this order, with spaces in between.\\n\\nExamples\\n\\nInput\\n\\n4 3\\n1 2\\n2 3\\n2 4\\n2 10\\n1 100\\n3 1\\n\\n\\nOutput\\n\\n100 110 111 110\\n\\n\\nInput\\n\\n6 2\\n1 2\\n1 3\\n2 4\\n3 6\\n2 5\\n1 10\\n1 10\\n\\n\\nOutput\\n\\n20 20 20 20 20 20\\\":\",\"targets\":\"#include \\n#include \\nusing namespace std;\\n\\nvectorto[200005];\\nvectorans;\\n\\nvoid dfs (int v, int p = -1){\\n\\tfor(int u: to[v]){\\n\\t\\tif(u == p)continue;\\n\\t\\tans[u] += ans[v];\\n\\t\\tdfs(u, v);\\n\\t}\\n}\\n\\nint main(){\\n\\t\\/*intput*\\/\\n\\tint n, q;\\tcin >> n >> q;\\n\\tfor(int i = 0; i < n -1; i++){\\n\\t\\tint a, b;\\n\\t\\tcin >> a >> b;\\n\\t\\t--a; --b;\\n\\t\\tto[a].push_back(b);\\n\\t\\tto[b].push_back(a);\\n\\t}\\n\\tans.resize(n);\\n\\tfor(int i = 0; i < q; i++){\\n\\t\\tint p, x;\\n\\t\\tcin >> p >> x;\\n\\t\\t--p;\\n\\t\\tans[p] += x;\\n\\t}\\n\\t\\/*calculaiton*\\/\\n\\tdfs(0);\\n\\t\\/*output*\\/\\n\\tfor(int i =0; i < n; i++){\\n\\t\\tcout << ans[i] << endl;\\n\\t}\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"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...]\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst long long int mod = 1e9 + 7;\\nvector arr(62);\\nvoid calc() {\\n arr[0] = 1;\\n for (int i = 1; i < 62; i++) {\\n arr[i] = arr[i - 1] * 2;\\n }\\n}\\nlong long int power(long long int a, long long int b) {\\n long long int ans = 1;\\n while (b > 0) {\\n if (b % 2) ans = (ans * a) % mod;\\n b \\/= 2;\\n a = (a * a) % mod;\\n }\\n return ans;\\n}\\nvoid test_case() {\\n long long int n, k;\\n cin >> n >> k;\\n long long int ans = 0;\\n while (k > 0) {\\n int index = lower_bound(arr.begin(), arr.end(), k) - arr.begin();\\n if (arr[index] != k) index--;\\n k -= arr[index];\\n ans += power(n, index);\\n ans %= mod;\\n }\\n cout << ans << endl;\\n}\\nint main() {\\n int T;\\n cin >> T;\\n while (T--) {\\n calc();\\n test_case();\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Cengiz recently learned Fibonacci numbers and now he is studying different algorithms to find them. After getting bored of reading them, he came with his own new type of numbers that he named XORinacci numbers. He defined them as follows: \\n\\n * f(0) = a; \\n * f(1) = b; \\n * f(n) = f(n-1) ⊕ f(n-2) when n > 1, where ⊕ denotes the [bitwise XOR operation](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#XOR). \\n\\n\\n\\nYou are given three integers a, b, and n, calculate f(n).\\n\\nYou have to answer for T independent test cases.\\n\\nInput\\n\\nThe input contains one or more independent test cases.\\n\\nThe first line of input contains a single integer T (1 ≤ T ≤ 10^3), the number of test cases.\\n\\nEach of the T following lines contains three space-separated integers a, b, and n (0 ≤ a, b, n ≤ 10^9) respectively.\\n\\nOutput\\n\\nFor each test case, output f(n).\\n\\nExample\\n\\nInput\\n\\n\\n3\\n3 4 2\\n4 5 0\\n325 265 1231232\\n\\n\\nOutput\\n\\n\\n7\\n4\\n76\\n\\nNote\\n\\nIn the first example, f(2) = f(0) ⊕ f(1) = 3 ⊕ 4 = 7.\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\n\\n\\npublic class A1208{\\n\\tpublic static void main(String args[])throws IOException{\\n\\t\\tScanner sc=new Scanner(new BufferedReader(new InputStreamReader(System.in)));\\n\\t\\tPrintWriter pw=new PrintWriter(System.out);\\n\\t\\tint t=sc.nextInt();\\n\\t\\twhile(t--!=0){\\n\\t\\t\\tlong a=sc.nextLong();\\t\\t\\tlong b=sc.nextLong();\\t\\t\\n\\t\\t\\tlong n=sc.nextLong();\\n\\t\\t\\tif(n%3==0)\\n\\t\\t\\t\\tpw.println(a);\\n\\t\\t\\telse if(n%3==1)\\n\\t\\t\\t\\tpw.println(b);\\n\\t\\t\\telse\\n\\t\\t\\t\\tpw.println(a^b);\\n\\t\\t}\\n\\t\\tpw.close();\\n\\t}\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Indiana Jones found ancient Aztec catacombs containing a golden idol. The catacombs consists of n caves. Each pair of caves is connected with a two-way corridor that can be opened or closed. The entrance to the catacombs is in the cave 1, the idol and the exit are in the cave n.\\n\\nWhen Indiana goes from a cave x to a cave y using an open corridor, all corridors connected to the cave x change their state: all open corridors become closed, all closed corridors become open. Indiana wants to go from cave 1 to cave n going through as small number of corridors as possible. Help him find the optimal path, or determine that it is impossible to get out of catacombs.\\n\\nInput\\n\\nThe first line contains two integers n and m (2 ≤ n ≤ 3⋅ 10^5, 0 ≤ m ≤ 3 ⋅ 10^5) — the number of caves and the number of open corridors at the initial moment.\\n\\nThe next m lines describe the open corridors. The i-th of these lines contains two integers u_i and v_i (1 ≤ u_i, v_i ≤ n, u_i ≠ v_i) — the caves connected by the i-th open corridor. It is guaranteed that each unordered pair of caves is presented at most once.\\n\\nOutput\\n\\nIf there is a path to exit, in the first line print a single integer k — the minimum number of corridors Indians should pass through (1 ≤ k ≤ 10^6). In the second line print k+1 integers x_0, …, x_k — the number of caves in the order Indiana should visit them. The sequence x_0, …, x_k should satisfy the following:\\n\\n * x_0 = 1, x_k = n;\\n * for each i from 1 to k the corridor from x_{i - 1} to x_i should be open at the moment Indiana walks along this corridor.\\n\\n\\n\\nIf there is no path, print a single integer -1.\\n\\nWe can show that if there is a path, there is a path consisting of no more than 10^6 corridors.\\n\\nExamples\\n\\nInput\\n\\n4 4\\n1 2\\n2 3\\n1 3\\n3 4\\n\\n\\nOutput\\n\\n2\\n1 3 4 \\n\\n\\nInput\\n\\n4 2\\n1 2\\n2 3\\n\\n\\nOutput\\n\\n4\\n1 2 3 1 4 \\\":\",\"targets\":\"#include \\nusing namespace std;\\nconst int maxn = 3e5 + 7;\\nint d[maxn], n, m, ans[17], tr[maxn];\\nbool inv[maxn];\\nvector adj[maxn], can;\\nvoid bfs(int s) {\\n queue q;\\n q.push(s);\\n memset(d, 0, sizeof d);\\n d[s] = 1, d[1] = 1;\\n while (q.size()) {\\n int u = q.front();\\n q.pop();\\n for (auto v : adj[u])\\n if (!d[v]) tr[v] = u, d[v] = d[u] + 1, q.push(v);\\n }\\n}\\nvoid enter() {\\n ios_base::sync_with_stdio(), cin.tie(0), cout.tie(0);\\n cin >> n >> m;\\n while (m--) {\\n int u, v;\\n cin >> u >> v;\\n adj[u].push_back(v), adj[v].push_back(u);\\n }\\n}\\nvoid case1() {\\n m = 0;\\n while (n) ans[++m] = n, n = tr[n];\\n cout << m - 1 << \\\"\\\\n\\\";\\n for (int i = m; i >= 1; --i) cout << ans[i] << \\\" \\\";\\n}\\nvoid solve() {\\n bool ok = 0;\\n bfs(1);\\n if (d[n]) {\\n if (d[n] <= 4) {\\n case1();\\n return;\\n }\\n ok = 1;\\n }\\n for (int i = 1; i <= n; ++i)\\n if (d[i] == 3) {\\n cout << 4 << \\\"\\\\n\\\"\\n << 1 << \\\" \\\" << tr[i] << \\\" \\\" << i << \\\" \\\" << 1 << \\\" \\\" << n << \\\"\\\\n\\\";\\n return;\\n }\\n for (auto v : adj[n]) inv[v] = 1;\\n for (auto v : adj[1])\\n if (!inv[v]) can.push_back(v);\\n srand(time(0));\\n while (can.size()) {\\n int r = rand() % can.size();\\n int v = can[r];\\n can[r] = can.back();\\n can.pop_back();\\n bfs(v);\\n for (int i = 2; i <= n; ++i)\\n if (d[i] == 3) {\\n cout << 5 << \\\"\\\\n\\\"\\n << 1 << \\\" \\\" << v << \\\" \\\" << tr[i] << \\\" \\\" << i << \\\" \\\" << v << \\\" \\\"\\n << n << \\\"\\\\n\\\";\\n return;\\n }\\n }\\n if (ok) case1();\\n puts(\\\"-1\\\");\\n}\\nint main() {\\n enter();\\n solve();\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"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}s):\\n t=i\\n for i in range(m):\\n if(t!=i):\\n f=0\\n s=0\\n for j in range(5):\\n if(d[i][j]s):\\n print(-1)\\n return\\n print(1+t)\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\ndef...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"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\":\"#include \\n#pragma GCC target(\\\"avx2\\\")\\n#pragma GCC optimization(\\\"O3\\\")\\n#pragma GCC optimization(\\\"unroll-loops\\\")\\nusing namespace std;\\nconst char $ = '$';\\nlong long temp = 0;\\nconst long long mod = 1e9 + 7;\\nvoid solve() {\\n long long k;\\n cin >> k;\\n long long ans = 6;\\n long long pow = 1;\\n for (long long i = 0; i < k; i++) {\\n pow *= 2;\\n pow %= (mod - 1);\\n }\\n long long a = pow - 2;\\n for (long long i = 0; i < a \\/ 10; i++) {\\n ans *= 1048576;\\n ans %= mod;\\n }\\n for (long long i = 0; i < a % 10; i++) {\\n ans *= 4;\\n ans %= mod;\\n }\\n cout << ans;\\n}\\nsigned main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n solve();\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nA 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\\nConsider a permutation p of length n, we build a graph of size n using it as follows: \\n\\n * For every 1 ≤ i ≤ n, find the largest j such that 1 ≤ j < i and p_j > p_i, and add an undirected edge between node i and node j \\n * For every 1 ≤ i ≤ n, find the smallest j such that i < j ≤ n and p_j > p_i, and add an undirected edge between node i and node j \\n\\n\\n\\nIn cases where no such j exists, we make no edges. Also, note that we make edges between the corresponding indices, not the values at those indices.\\n\\nFor clarity, consider as an example n = 4, and p = [3,1,4,2]; here, the edges of the graph are (1,3),(2,1),(2,3),(4,3).\\n\\nA permutation p is cyclic if the graph built using p has at least one simple cycle. \\n\\nGiven n, find the number of cyclic permutations of length n. Since the number may be very large, output it modulo 10^9+7.\\n\\nPlease refer to the Notes section for the formal definition of a simple cycle\\n\\nInput\\n\\nThe first and only line contains a single integer n (3 ≤ n ≤ 10^6).\\n\\nOutput\\n\\nOutput a single integer 0 ≤ x < 10^9+7, the number of cyclic permutations of length n modulo 10^9+7.\\n\\nExamples\\n\\nInput\\n\\n\\n4\\n\\n\\nOutput\\n\\n\\n16\\n\\nInput\\n\\n\\n583291\\n\\n\\nOutput\\n\\n\\n135712853\\n\\nNote\\n\\nThere are 16 cyclic permutations for n = 4. [4,2,1,3] is one such permutation, having a cycle of length four: 4 → 3 → 2 → 1 → 4.\\n\\nNodes v_1, v_2, …, v_k form a simple cycle if the following conditions hold: \\n\\n * k ≥ 3. \\n * v_i ≠ v_j for any pair of indices i and j. (1 ≤ i < j ≤ k) \\n * v_i and v_{i+1} share an edge for all i (1 ≤ i < k), and v_1 and v_k share an edge.\",\"targets\":\"#include \\nusing namespace std;\\nlong long power(long long a, long long b, long long m) {\\n a %= m;\\n long long res = 1;\\n while (b > 0) {\\n if (b & 1) res = res * a % m;\\n a = a * a % m;\\n b >>= 1;\\n }\\n return res % 1000000007;\\n}\\nlong long modInverse(long long n, long long p) {\\n return power(n, p - 2, 1000000007);\\n}\\nlong long nCrModPFermat(long long n, long long r, long long p) {\\n if (r == 0) return 1;\\n long long fac[n + 1];\\n fac[0] = 1;\\n for (long long x = 1; x <= n; x++)\\n fac[x] = ((x % 1000000007) * ((long long)(fac[x - 1]) % 1000000007)) %\\n 1000000007;\\n return ((long long)(((long long)fac[n] * modInverse(fac[r], p)) %\\n 1000000007) %\\n p * modInverse(fac[n - r], p) % p) %\\n p;\\n}\\nsigned main() {\\n long long n;\\n cin >> n;\\n map fact;\\n fact[1] = 1;\\n fact[0] = 1;\\n for (long long x = 2; x <= n; x++) {\\n fact[x] = ((x % 1000000007) * ((long long)(fact[x - 1]) % 1000000007)) %\\n 1000000007;\\n }\\n long long ans = 0;\\n cout << (((fact[n] + 1000000007) % 1000000007) -\\n ((power(2, n - 1, 1000000007) % 1000000007) % 1000000007) +\\n 1000000007) %\\n 1000000007\\n << \\\"\\\\n\\\";\\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...\\nSolve the task in PYTHON3.\",\"targets\":\"import sys,os.path\\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\\\")\\nif __name__ == '__main__':\\n if(os.path.exists('input.txt')):\\n sys.stdin = open(\\\"input.txt\\\",\\\"r\\\")\\n sys.stdout = open(\\\"output.txt\\\",\\\"w\\\")\\n for _ in range(int(input())):\\n n = int(input())\\n a = list(map(int,input().split()))\\n ans = 0\\n for i in range(n):\\n ok...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Let's call a positive integer good if there is no digit 0 in its decimal representation.\\n\\nFor an array of a good numbers a, one found out that the sum of some two neighboring elements is equal to x (i.e. x = a_i + a_{i + 1} for some i). x had turned out to be a good number as well.\\n\\nThen the elements of the array a were written out one after another without separators into one string s. For example, if a = [12, 5, 6, 133], then s = 1256133.\\n\\nYou are given a string s and a number x. Your task is to determine the positions in the string that correspond to the adjacent elements of the array that have sum x. If there are several possible answers, you can print any of them.\\n\\nInput\\n\\nThe first line contains the string s (2 ≤ |s| ≤ 5 ⋅ 10^5).\\n\\nThe second line contains an integer x (2 ≤ x < 10^{200000}).\\n\\nAn additional constraint on the input: the answer always exists, i.e you can always select two adjacent substrings of the string s so that if you convert these substrings to integers, their sum is equal to x.\\n\\nOutput\\n\\nIn the first line, print two integers l_1, r_1, meaning that the first term of the sum (a_i) is in the string s from position l_1 to position r_1.\\n\\nIn the second line, print two integers l_2, r_2, meaning that the second term of the sum (a_{i + 1}) is in the string s from position l_2 to position r_2.\\n\\nExamples\\n\\nInput\\n\\n\\n1256133\\n17\\n\\n\\nOutput\\n\\n\\n1 2\\n3 3\\n\\n\\nInput\\n\\n\\n9544715561\\n525\\n\\n\\nOutput\\n\\n\\n2 3\\n4 6\\n\\n\\nInput\\n\\n\\n239923\\n5\\n\\n\\nOutput\\n\\n\\n1 1\\n2 2\\n\\n\\nInput\\n\\n\\n1218633757639\\n976272\\n\\n\\nOutput\\n\\n\\n2 7\\n8 13\\n\\nNote\\n\\nIn the first example s[1;2] = 12 and s[3;3] = 5, 12+5=17.\\n\\nIn the second example s[2;3] = 54 and s[4;6] = 471, 54+471=525.\\n\\nIn the third example s[1;1] = 2 and s[2;2] = 3, 2+3=5.\\n\\nIn the fourth example s[2;7] = 218633 and s[8;13] = 757639, 218633+757639=976272.\\n#incl\",\"targets\":\"ude \\n#pragma GCC optimize(3)\\n#pragma GCC optimize(\\\"Ofast\\\")\\nusing namespace std;\\nconst int N = 5e5 + 5;\\nconst int M = 2e5 + 5;\\nint LA, LB;\\nint prime[5], pre[N][5];\\nint T[M][5], S[N][5];\\nchar A[N], B[M];\\nvoid Init() {\\n prime[0] = 1000000007;\\n prime[1] = 1000000009;\\n prime[2] = 1000000021;\\n prime[3] = 1004535809;\\n prime[4] = 1000010801;\\n}\\ninline int GetA(int x, int y, int id, int p) {\\n return (S[y][id] - (long long)S[x - 1][id] * pre[y - x + 1][id] % p + p) % p;\\n}\\ninline int GetB(int x, int y, int id, int p) {\\n return (T[y][id] - (long long)T[x - 1][id] * pre[y - x + 1][id] % p + p) % p;\\n}\\nvoid check(int l, int r, int x, int y) {\\n if (l < 1 || l > r || r > LA || x < 1 || x > y || y > LA) {\\n return;\\n }\\n for (int i = 0; i < 5; ++i) {\\n int p = prime[i];\\n int A = GetA(l, r, i, p), B = GetA(x, y, i, p);\\n if ((A + B) % p != T[LB][i]) {\\n return;\\n }\\n }\\n printf(\\\"%d %d\\\\n%d %d\\\", l, r, x, y);\\n exit(0);\\n}\\nbool equal(int x, int y, int L) {\\n for (int id = 0; id < 5; ++id) {\\n long long p = prime[id];\\n if (GetA(x, x + L - 1, id, p) != GetB(y, y + L - 1, id, p)) {\\n return 0;\\n }\\n }\\n return 1;\\n}\\nint main() {\\n Init();\\n scanf(\\\"%s %s\\\", A + 1, B + 1);\\n LA = strlen(A + 1);\\n LB = strlen(B + 1);\\n for (int i = 0; i < 5; ++i) {\\n int p = prime[i];\\n pre[0][i] = 1;\\n for (int j = 1; j <= LB; ++j) {\\n T[j][i] = ((long long)T[j - 1][i] * 10 + B[j] - '0') % p;\\n }\\n for (int j = 1; j <= LA; ++j) {\\n pre[j][i] = ((long long)pre[j - 1][i] * 10) % p;\\n S[j][i] = ((long long)S[j - 1][i] * 10 + A[j] - '0') % p;\\n }\\n }\\n for (int i = LB; i <= LA - LB + 2; ++i) {\\n check(i - LB + 1, i - 1, i, i + LB - 2);\\n }\\n for (int i = 2; i <= LA - LB + 1; ++i) {\\n int step = 1, x = 0;\\n while (step) {\\n if (x + step <= LB && equal(i + x, x + 1, step)) {\\n x += step, step <<= 1;\\n } else {\\n step >>= 1;\\n }\\n }\\n check(i - LB + x, i - 1, i, i + LB - 1);\\n check(i - LB + x + 1, i - 1, i, i + LB - 1);\\n }\\n for (int i = LB + 1; i <= LA;...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"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\":\"#include \\nusing namespace std;\\nint32_t main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n long long tt = 1;\\n cin >> tt;\\n while (tt--) {\\n long long n;\\n cin >> n;\\n long long a[n];\\n for (long long i = 0; i < n; i++) {\\n cin >> a[i];\\n }\\n if (a[0] == 1) {\\n cout << n + 1 << \\\" \\\";\\n for (long long i = 1; i <= n; i++) {\\n cout << i << \\\" \\\";\\n }\\n cout << '\\\\n';\\n } else {\\n long long j;\\n for (j = 0; j < n; j++) {\\n if (a[j] == 1) break;\\n }\\n if (j == n) {\\n for (long long i = 1; i <= n; i++) {\\n cout << i << \\\" \\\";\\n }\\n cout << n + 1 << '\\\\n';\\n } else {\\n for (long long i = 1; i <= j; i++) {\\n cout << i << \\\" \\\";\\n }\\n cout << n + 1 << \\\" \\\";\\n for (long long i = j + 1; i <= n; i++) {\\n cout << i << \\\" \\\";\\n }\\n cout << '\\\\n';\\n }\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"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\":\"import java.math.BigInteger;\\nimport java.util.ArrayList;\\nimport java.util.Arrays;\\nimport java.util.Collections;\\nimport java.util.HashSet;\\nimport java.util.List;\\nimport java.util.Set;\\nimport java.util.Stack;\\n\\npublic class Main {\\n static long MOD = 998244353l;\\n int min = Integer.MAX_VALUE;\\n boolean re = false;\\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 List list = new ArrayList();\\n Set set = new HashSet();\\n for (long i = 1; i * i <= 1000000000; i++) {\\n set.add(i * i);\\n }\\n for (long i = 1; i * i * i <= 1000000000; i++) {\\n set.add(i * i * i);\\n }\\n \\/\\/ pw.println(set.size());\\n for (Long l : set) {\\n list.add(l);\\n }\\n Collections.sort(list);\\n for (int times = 0; times < t; times++) {\\n long a = sc.nextLong();\\n long s = sc.nextLong();\\n StringBuffer sb = new StringBuffer();\\n boolean ok = true;\\n while (a > 0) {\\n if (a % 10 <= s % 10) {\\n sb.append((s % 10 - a % 10));\\n a = a \\/ 10;\\n s = s \\/ 10;\\n } else {\\n long temp = s % 100;\\n if (temp >= 20 || temp < 10) {\\n pw.println(-1);\\n ok = false;\\n break;\\n }\\n if (temp - a >= 10) {\\n pw.println(-1);\\n ok =...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"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.util.*;\\n\\n public class codechef {\\n\\n\\t\\tstatic String ans = \\\"NO\\\";\\t \\n\\t public static void main(String[] args) {\\n Scanner sc = new Scanner(System.in);\\n while(sc.hasNext()) {\\n\\n\\t int t = sc.nextInt();\\n\\t while(t-->0) {\\n String s = sc.next();\\n String s1 = sc.next();\\n for(int i = 0; i=0 && j+1 < s1.length() && s.charAt(i-1) == s1.charAt(j+1) ) {\\n\\tsolve(s, s1, i-1, j+1, false);\\n}\\n\\n\\n \\n \\n\\t\\t\\n\\t}\\n\\n \\n }\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"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.\",\"targets\":\"import sys\\ninputfn = sys.stdin.readline\\n\\nt = int(inputfn())\\nfor i in range(t):\\n\\ttotal = 0\\n\\tpiles = inputfn().split(\\\" \\\")\\n\\tpiles[0] = int(piles[0])\\n\\tpiles[1] = int(piles[1])\\n\\tpiles[2] = int(piles[2])\\n\\tif 2 * piles[1] <= piles[2]:\\n\\t\\tprint(3 * piles[1])\\n\\t\\tcontinue\\n\\ttotal += piles[2] \\/\\/ 2\\n\\tpiles[1] -= piles[2] \\/\\/ 2\\n\\ttotal += min(piles[0], piles[1] \\/\\/ 2)\\n\\tprint(3 * total)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"n towns are arranged in a circle sequentially. The towns are numbered from 1 to n in clockwise order. In the i-th town, there lives a singer with a repertoire of a_i minutes for each i ∈ [1, n].\\n\\nEach singer visited all n towns in clockwise order, starting with the town he lives in, and gave exactly one concert in each town. In addition, in each town, the i-th singer got inspired and came up with a song that lasts a_i minutes. The song was added to his repertoire so that he could perform it in the rest of the cities.\\n\\nHence, for the i-th singer, the concert in the i-th town will last a_i minutes, in the (i + 1)-th town the concert will last 2 ⋅ a_i minutes, ..., in the ((i + k) mod n + 1)-th town the duration of the concert will be (k + 2) ⋅ a_i, ..., in the town ((i + n - 2) mod n + 1) — n ⋅ a_i minutes.\\n\\nYou are given an array of b integer numbers, where b_i is the total duration of concerts in the i-th town. Reconstruct any correct sequence of positive integers a or say that it is impossible.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10^3) — the number of test cases. Then the test cases follow.\\n\\nEach test case consists of two lines. The first line contains a single integer n (1 ≤ n ≤ 4 ⋅ 10^4) — the number of cities. The second line contains n integers b_1, b_2, ..., b_n (1 ≤ b_i ≤ 10^{9}) — the total duration of concerts in i-th city.\\n\\nThe sum of n over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print the answer as follows:\\n\\nIf there is no suitable sequence a, print NO. Otherwise, on the first line print YES, on the next line print the sequence a_1, a_2, ..., a_n of n integers, where a_i (1 ≤ a_i ≤ 10^{9}) is the initial duration of repertoire of the i-th singer. If there are multiple answers, print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n12 16 14\\n1\\n1\\n3\\n1 2 3\\n6\\n81 75 75 93 93 87\\n\\n\\nOutput\\n\\n\\nYES\\n3 1 3 \\nYES\\n1 \\nNO\\nYES\\n5 5 4 1 4 5 \\n\\nNote\\n\\nLet's consider the 1-st test case of the example:\\n\\n 1. the 1-st singer in the 1-st city will give a concert for 3 minutes, in the 2-nd —...\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\nimport java.util.ArrayList;\\nimport java.util.Arrays.*;\\nimport java.util.Map.Entry;\\nimport java.util.stream.IntStream;\\nimport java.util.stream.LongStream;\\n\\nimport static java.util.Collections.*;\\nimport static java.lang.Integer.parseInt;\\nimport static java.lang.Math.*;\\nimport static java.lang.String.format;\\nimport static java.util.Arrays.*;\\n\\npublic class CC {\\n @SuppressWarnings(\\\"all\\\")\\n private static final int[][] GRID_DIRECTION_4 = { { 1, 0 }, { -1, 0 }, { 0, 1 }, { 0, -1 } };\\n @SuppressWarnings(\\\"all\\\")\\n private static final int[][] GRID_DIRECTION_ALL = { { 1, 0 }, { -1, 0 }, { 0, 1 }, { 0, -1 }, { 1, 1 }, { -1, 1 },\\n { 1, -1 }, { -1, -1 } };\\n static final int SCAN_LINE_LENGTH = 1_000_002;\\n private static final boolean thread = false;\\n @SuppressWarnings(\\\"all\\\")\\n static final boolean HAS_TEST_CASES = (1 == 1) ? true : false;\\n\\n @SuppressWarnings(\\\"all\\\")\\n private static ArrayList adj[], v = new ArrayList<>();\\n static long gcd = 1;\\n static HashMap pos;\\n static int n, e[][], vis[], m, b[], a[];\\n\\n @SuppressWarnings(\\\"unchecked\\\")\\n static void solve() throws Exception {\\n n = ni();\\n a = na(n);\\n if (n == 1) {\\n pn(\\\"YES\\\");\\n pn(a[0]);\\n return;\\n }\\n long[] ans = new long[n];\\n long sum = 0;\\n for (int i = 0; i < ans.length; i++) {\\n sum += a[i];\\n }\\n if (sum % (n * (n + 1l) \\/ 2) != 0) {\\n pn(\\\"NO\\\");\\n return;\\n }\\n long s = sum \\/ (n * (n + 1l) \\/ 2);\\n for (int i = 0; i < ans.length; i++) {\\n ans[i] = -a[i] + a[(i + n - 1) % n] + s;\\n if (ans[i] % n != 0 || ans[i] < 1) {\\n pn(\\\"NO\\\");\\n return;\\n }\\n ans[i] \\/= n;\\n\\n }\\n pn(\\\"YES\\\");\\n pn(ans);\\n }\\n\\n public static void main(final String[] args) throws Exception {\\n if (!thread) {\\n final int TEST_CASES = HAS_TEST_CASES ?...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"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\\nimpor\",\"targets\":\"t java.io.*;\\nimport java.util.*;\\n\\npublic class B {\\n public static void main(String[] args) {\\n Pre.compute();\\n for (int t = IO.getInt(), i = 0; i < t; i++)\\n new SolB().solve();\\n IO.close();\\n }\\n}\\n\\nclass SolB {\\n\\n int n;\\n\\n SolB() {\\n n = IO.getInt();\\n }\\n\\n void solve() {\\n IO.writer.println(bins(Pre.nums, n)+1);\\n }\\n\\n int bins(int[] nums, int v) {\\n int l = 0, r = nums.length-1;\\n while (l < r) {\\n if (l == r-1) {\\n if (v >= nums[r])\\n l = r;\\n else\\n r = l;\\n continue;\\n }\\n int mid = (l + r) \\/ 2;\\n if (nums[mid] > v)\\n r = mid;\\n else\\n l = mid;\\n }\\n return l;\\n }\\n}\\n\\nclass Pre {\\n static int[] nums;\\n\\n static void compute() {\\n \\n Set set = new TreeSet<>();\\n for (int i = 1; i < Math.sqrt(Constants.MAX_N)+1; i++)\\n set.add(i*i);\\n for (int i = 2; i < 1001; i++)\\n set.add(i*i*i);\\n List list = new ArrayList<>(set);\\n nums = new int[list.size()];\\n for (int i = 0; i < list.size(); i++)\\n nums[i] = list.get(i);\\n }\\n}\\n\\nclass Constants {\\n public static final int MAX_N = 1000000009;\\n}\\n\\nclass IO {\\n public static final PrintWriter writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));\\n \\n private static byte[] bytes = new byte[1<<15];\\n private static int i, n;\\n \\n private static StringTokenizer tokens;\\n \\n private static byte getByte() {\\n if (i == n) {\\n i = 0;\\n n = 0;\\n try {\\n n = System.in.read(bytes);\\n } catch (IOException e) {}\\n }\\n return i < n ? bytes[i++] : 0;\\n }\\n \\n private static byte skip() {\\n byte c = getByte();\\n while (c <= ' ')\\n c = getByte();\\n return c;\\n }\\n \\n public static int getInt() {\\n int a =...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alice and Bob are controlling a robot. They each have one switch that controls the robot.\\nAlice started holding down her button A second after the start-up of the robot, and released her button B second after the start-up.\\nBob started holding down his button C second after the start-up, and released his button D second after the start-up.\\nFor how many seconds both Alice and Bob were holding down their buttons?\\n\\nConstraints\\n\\n* 0≤A\\nusing namespace std;\\n\\nint main() {\\n int a,b,c,d;\\n cin >> a >> b >> c >> d;\\n cout << max(0, min(b,d)-max(a,c)) << '\\\\n';\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Dreamoon wants to climb up a stair of n steps. He can climb 1 or 2 steps at each move. Dreamoon wants the number of moves to be a multiple of an integer m. \\n\\nWhat is the minimal number of moves making him climb to the top of the stairs that satisfies his condition?\\n\\nInput\\n\\nThe single line contains two space separated integers n, m (0 < n ≤ 10000, 1 < m ≤ 10).\\n\\nOutput\\n\\nPrint a single integer — the minimal number of moves being a multiple of m. If there is no way he can climb satisfying condition print - 1 instead.\\n\\nExamples\\n\\nInput\\n\\n10 2\\n\\n\\nOutput\\n\\n6\\n\\n\\nInput\\n\\n3 5\\n\\n\\nOutput\\n\\n-1\\n\\nNote\\n\\nFor the first sample, Dreamoon could climb in 6 moves with following sequence of steps: {2, 2, 2, 2, 1, 1}.\\n\\nFor the second sample, there are only three valid sequence of steps {2, 1}, {1, 2}, {1, 1, 1} with 2, 2, and 3 steps respectively. All these numbers are not multiples of 5.\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"import math\\nn,m=map(int,input().split())\\nif m>n:\\n print(-1)\\nelse:\\n mn=int(math.ceil(n\\/2))\\n for i in range(mn,n+1,1):\\n if i%m==0:\\n print(i)\\n break\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"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...\\n#incl\",\"targets\":\"ude \\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 long long ar[n];\\n for (int i = 0; i < n; i++) cin >> ar[i];\\n sort(ar, ar + n);\\n long long ans = ar[0];\\n for (int i = 1; i < n; i++) {\\n ans = max(ans, ar[i] - ar[i - 1]);\\n }\\n cout << ans << \\\"\\\\n\\\";\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"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.\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n ios::sync_with_stdio(false);\\n cin.tie(0);\\n int t;\\n cin >> t;\\n while (t--) {\\n int n;\\n cin >> n;\\n if (n == 1) {\\n cout << 'a' << '\\\\n';\\n continue;\\n }\\n for (int i = 1; i <= n \\/ 2; ++i) {\\n cout << 'a';\\n }\\n if (n & 1) {\\n cout << \\\"yz\\\";\\n } else {\\n cout << 'z';\\n }\\n for (int i = 1; i <= n \\/ 2 - 1; ++i) {\\n cout << 'a';\\n }\\n cout << '\\\\n';\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.\\n\\nA bar of chocolate can be presented as an n × n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are numbered from top to bottom. Let's call the anti-diagonal to be a diagonal that goes the lower left corner to the upper right corner of the table. First Andrewid eats all the pieces lying below the anti-diagonal. Then he performs the following q actions with the remaining triangular part: first, he chooses a piece on the anti-diagonal and either direction 'up' or 'left', and then he begins to eat all the pieces starting from the selected cell, moving in the selected direction until he reaches the already eaten piece or chocolate bar edge.\\n\\nAfter each action, he wants to know how many pieces he ate as a result of this action.\\n\\nInput\\n\\nThe first line contains integers n (1 ≤ n ≤ 109) and q (1 ≤ q ≤ 2·105) — the size of the chocolate bar and the number of actions.\\n\\nNext q lines contain the descriptions of the actions: the i-th of them contains numbers xi and yi (1 ≤ xi, yi ≤ n, xi + yi = n + 1) — the numbers of the column and row of the chosen cell and the character that represents the direction (L — left, U — up).\\n\\nOutput\\n\\nPrint q lines, the i-th of them should contain the number of eaten pieces as a result of the i-th action.\\n\\nExamples\\n\\nInput\\n\\n6 5\\n3 4 U\\n6 1 L\\n2 5 L\\n1 6 U\\n4 3 U\\n\\n\\nOutput\\n\\n4\\n3\\n2\\n1\\n2\\n\\n\\nInput\\n\\n10 6\\n2 9 U\\n10 1 U\\n1 10 U\\n8 3 L\\n10 1 L\\n6 5 U\\n\\n\\nOutput\\n\\n9\\n1\\n10\\n6\\n0\\n2\\n\\nNote\\n\\nPictures to the sample tests:\\n\\n\\n\\nThe pieces that were eaten in the same action are painted the same color. The pieces lying on the anti-diagonal contain the numbers of the action as a result of which these pieces were eaten.\\n\\nIn the second sample test the Andrewid tries to start eating chocolate for the second time during his fifth action, starting from the cell at the intersection of the 10-th column and the 1-st...\\nUsing java can you solve the prior task?\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.File;\\nimport java.io.FileInputStream;\\nimport java.io.FileNotFoundException;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.io.PrintWriter;\\nimport java.util.Arrays;\\nimport java.util.HashSet;\\nimport java.util.StringTokenizer;\\nimport java.util.TreeMap;\\nimport java.util.TreeSet;\\n\\npublic class E556 {\\n\\n public static void main(String[] args) throws IOException {\\n initReader();\\n int n = nextInt();\\n int q = nextInt();\\n\\n TreeSet set = new TreeSet();\\n TreeSet row = new TreeSet();\\n set.add(new Value(0, 0, 0));\\n set.add(new Value(n + 1, 0, 0));\\n PrintWriter writer = new PrintWriter(System.out);\\n for (int i = 0; i < q; ++i) {\\n int a = nextInt();\\n int b = nextInt();\\n String d = next();\\n if (d.equals(\\\"U\\\")) {\\n Value temp = new Value(a - 1, 0, 0);\\n Value higher = set.higher(temp);\\n if (higher.colIndex == a) {\\n writer.println(0);\\n continue;\\n }\\n\\n int z = higher.colIndex - a + higher.colHeight;\\n writer.println(z);\\n temp.colIndex = a;\\n temp.colHeight = z;\\n set.add(temp);\\n } else {\\n Value temp = new Value(a + 1, 0, 0);\\n Value higher = set.lower(temp);\\n if (higher.colIndex == a) {\\n writer.println(0);\\n continue;\\n }\\n\\n int z = a - higher.colIndex + higher.rowLong;\\n writer.println(z);\\n temp.colIndex = a;\\n temp.rowLong = z;\\n set.add(temp);\\n }\\n }\\n \\/\\/ System.out.println(time);\\n\\n writer.close();\\n\\n }\\n\\n static BufferedReader reader;\\n static StringTokenizer tokenizer;\\n\\n public static void initReader() throws FileNotFoundException {\\n \\/\\/...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"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.\",\"targets\":\"I=lambda:[*map(int,input().split())]\\nfor _ in[0]*I()[0]:\\n\\tn,k=I();a=sorted(I());p=[0];b=1<<50\\n\\tfor i in range(1,n):p.append(p[-1]+a[i])\\n\\tfor i in range(n):b=min(max(0,a[0]-(k-p[-1-i])\\/\\/(i+1))+i,b)\\n\\tprint(b)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"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] \\n#!\\/us\",\"targets\":\"r\\/bin\\/env python\\n\\nfrom __future__ import division, print_function\\nimport os\\nimport sys\\nfrom io import BytesIO, IOBase\\n#from functools import reduce\\n\\nimport math\\n#import random\\n#import bisect\\n#import collections\\n#import heapq\\n\\n#mod=(10**9)+7\\n\\nif sys.version_info[0] < 3:\\n from __builtin__ import xrange as range\\n from future_builtins import ascii, filter, hex, map, oct, zip\\n\\n# n=int(input())\\n# arr = list (map(int, input().split()))\\n\\ndef main():\\n def solve():\\n n,s=(map(int, input().split()))\\n if n==1:\\n return s\\n if n\\/\\/2>s:\\n return 0\\n if n&1:\\n median=math.ceil(n\\/2)\\n else:\\n median=(n\\/\\/2)+1\\n\\n x=s\\/\\/median\\n\\n return x\\n\\n t = int(input())\\n for i in range(t):\\n print(solve())\\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 =...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"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\\nSolve the task in PYTHON3.\",\"targets\":\"import sys\\ninput = sys.stdin.readline\\n\\nT = int(input())\\nresult = []\\n\\nfor _ in range(T):\\n raw_keyboard = input()[:-1]\\n word = input()[:-1]\\n t = 0\\n\\n if len(word) == 1:\\n result.append(str(0))\\n continue\\n\\n key_map = {}\\n for i, k in enumerate(raw_keyboard):\\n key_map[k] = i + 1\\n\\n for i in range(len(word)-1):\\n t += abs(key_map[word[i]] - key_map[word[i+1]])\\n result.append(str(t))\\n\\nprint('\\\\n'.join(result))\",\"language\":\"python\",\"split\":\"test\",\"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. \\nimpor\",\"targets\":\"t sys\\ninput=sys.stdin\\noutput=sys.stdout\\n\\ninputs=input.readline().strip().split()\\nN=int(inputs[0])\\nM=int(inputs[1])\\nS=input.readline().strip()\\nSL=['abc', 'acb', 'bac', 'bca', 'cab', 'cba']\\nCL=[[0]*(N+1) for x in range(6)]\\n\\n#def check_beautiful(substring):\\n # total=len(substring)\\n # for i in SL:\\n # subtotal=0\\n # count=0\\n # for j in range(len(substring)):\\n # if substring[j] != i[count]:\\n # subtotal+=1 \\n # count=(count+1) % 3\\n # if subtotal < total:\\n # total=subtotal\\n # return total\\n \\nfor i in range(6):\\n subtotal=0\\n substring=SL[i]\\n subCL=CL[i]\\n for j in range(N):\\n if S[j] != substring[j % 3]:\\n subtotal+=1\\n subCL[j+1]=subtotal\\n\\nfor i in range(M):\\n y=input.readline().strip().split()\\n start=int(y[0])\\n end=int(y[1])\\n total=N\\n for j in range(6):\\n a=CL[j][end]-CL[j][start-1]\\n if a\\nusing namespace std;\\nconst int N = 5e5 + 10;\\nint a[N], b[N], d[N], id[N];\\nvector c[N];\\nint main() {\\n ios::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n int t;\\n cin >> t;\\n while (t--) {\\n int n, m;\\n cin >> n >> m;\\n for (int i = 1; i <= n * m; i++) {\\n cin >> a[i];\\n b[i] = a[i];\\n }\\n sort(a + 1, a + 1 + m * n);\\n int num = unique(a + 1, a + 1 + m * n) - a - 1;\\n for (int i = 1; i <= num; i++) {\\n c[i].clear();\\n }\\n for (int i = 1; i <= n * m; i++) {\\n int tt = lower_bound(a + 1, a + 1 + num, b[i]) - a;\\n c[tt].push_back(i);\\n }\\n int ans = 0, now = 1;\\n for (int i = 1; i <= num; i++) {\\n int len = (m - (now - 1) % m);\\n if (c[i].size() > len) {\\n for (int j = now; j <= m; j++) {\\n id[(j - 1) % m + 1] = c[i][now - j + len - 1];\\n }\\n for (int j = now; j <= m; j++) {\\n for (int k = 1; k < now; k++) {\\n if (id[k] < id[j]) ans++;\\n }\\n }\\n int mm = c[i].size(), st;\\n st = mm;\\n mm -= len;\\n mm %= m;\\n now = mm + 1;\\n for (int j = 1; j <= mm; j++) {\\n id[j] = c[i][st - j];\\n }\\n } else {\\n int mm = c[i].size();\\n for (int j = now; j < now + mm; j++) {\\n id[(j - 1) % m + 1] = c[i][mm - (j - now + 1)];\\n }\\n for (int j = now; j < now + mm; j++) {\\n for (int k = 1; k < now; k++) {\\n if (id[k] < id[j]) ans++;\\n }\\n }\\n now += mm;\\n now = (now - 1) % m + 1;\\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\":\"Can you solve the below in CPP?\\nOne way to create a task is to learn from life. You can choose some experience in real life, formalize it and then you will get a new task.\\n\\nLet's think about a scene in real life: there are lots of people waiting in front of the elevator, each person wants to go to a certain floor. We can formalize it in the following way. We have n people standing on the first floor, the i-th person wants to go to the fi-th floor. Unfortunately, there is only one elevator and its capacity equal to k (that is at most k people can use it simultaneously). Initially the elevator is located on the first floor. The elevator needs |a - b| seconds to move from the a-th floor to the b-th floor (we don't count the time the people need to get on and off the elevator).\\n\\nWhat is the minimal number of seconds that is needed to transport all the people to the corresponding floors and then return the elevator to the first floor?\\n\\nInput\\n\\nThe first line contains two integers n and k (1 ≤ n, k ≤ 2000) — the number of people and the maximal capacity of the elevator.\\n\\nThe next line contains n integers: f1, f2, ..., fn (2 ≤ fi ≤ 2000), where fi denotes the target floor of the i-th person.\\n\\nOutput\\n\\nOutput a single integer — the minimal time needed to achieve the goal.\\n\\nExamples\\n\\nInput\\n\\n3 2\\n2 3 4\\n\\n\\nOutput\\n\\n8\\n\\n\\nInput\\n\\n4 2\\n50 100 50 100\\n\\n\\nOutput\\n\\n296\\n\\n\\nInput\\n\\n10 3\\n2 2 2 2 2 2 2 2 2 2\\n\\n\\nOutput\\n\\n8\\n\\nNote\\n\\nIn first sample, an optimal solution is: \\n\\n 1. The elevator takes up person #1 and person #2. \\n 2. It goes to the 2nd floor. \\n 3. Both people go out of the elevator. \\n 4. The elevator goes back to the 1st floor. \\n 5. Then the elevator takes up person #3. \\n 6. And it goes to the 2nd floor. \\n 7. It picks up person #2. \\n 8. Then it goes to the 3rd floor. \\n 9. Person #2 goes out. \\n 10. Then it goes to the 4th floor, where person #3 goes out. \\n 11. The elevator goes back to the 1st floor.\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int n, k;\\n cin >> n >> k;\\n int a[n];\\n for (int i = 0; i < n; i++) cin >> a[i];\\n sort(a, a + n);\\n int tot = 0;\\n for (int i = n - 1; i >= 0; i -= k) tot += 2 * (a[i] - 1);\\n cout << tot;\\n}\",\"language\":\"python\",\"split\":\"train\",\"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.\\n[prin\",\"targets\":\"t((int(input())+1)\\/\\/10) for _ in range(int(input()))]\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"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.\\nUsing python3 can you solve the prior task?\",\"targets\":\"from sys import stdin\\ninput = stdin.readline\\n\\ndef add(x , y):return ((x%mod) + (y%mod))%mod\\ndef sub(x , y):return (x - y + mod)%mod\\n\\n\\ndef answer():\\n\\n dp = [0]*(n + 1)\\n prefix = [0]*(n + 2)\\n\\n dp[n] = 1\\n\\n for i in range(n , 0 , -1):\\n\\n dp[i] = add(dp[i] , prefix[i + 1])\\n\\n j = 2\\n while(i*j <= n):\\n\\n dp[i] = add(dp[i] , prefix[i*j])\\n if((j*i + j) <= n):dp[i] = sub(dp[i] , prefix[j*i + j])\\n j += 1\\n\\n \\n prefix[i] = add(prefix[i + 1] , dp[i])\\n\\n return dp[1]\\n\\n \\n \\n\\nfor T in range(1):\\n\\n n , mod = map(int,input().split())\\n\\n print(answer())\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"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\":\"#include \\nusing namespace std;\\nint main() {\\n int test;\\n cin >> test;\\n while (test--) {\\n string str;\\n cin >> str;\\n int n = str.length();\\n if (n % 2 != 0) {\\n cout << \\\"NO\\\" << endl;\\n } else {\\n int i = n \\/ 2 - 1, j = n - 1;\\n while (i >= 0 && j >= n \\/ 2) {\\n if (str[i] != str[j]) {\\n cout << \\\"NO\\\" << endl;\\n break;\\n }\\n i--;\\n j--;\\n }\\n if (i == -1 && j == n \\/ 2 - 1) {\\n cout << \\\"YES\\\" << endl;\\n }\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"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 \\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 ans=[]\\n dic={}\\n for i in A:\\n if i in dic:\\n dic[i]+=1\\n else:\\n dic[i]=1\\n ans.append(i)\\n print(*ans)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"During the quarantine, Sicromoft has more free time to create the new functions in \\\"Celex-2021\\\". The developers made a new function GAZ-GIZ, which infinitely fills an infinite table to the right and down from the upper left corner as follows:\\n\\n The cell with coordinates (x, y) is at the intersection of x-th row and y-th column. Upper left cell (1,1) contains an integer 1.\\n\\nThe developers of the SUM function don't sleep either. Because of the boredom, they teamed up with the developers of the RAND function, so they added the ability to calculate the sum on an arbitrary path from one cell to another, moving down or right. Formally, from the cell (x,y) in one step you can move to the cell (x+1, y) or (x, y+1). \\n\\nAfter another Dinwows update, Levian started to study \\\"Celex-2021\\\" (because he wants to be an accountant!). After filling in the table with the GAZ-GIZ function, he asked you to calculate the quantity of possible different amounts on the path from a given cell (x_1, y_1) to another given cell (x_2, y_2), if you can only move one cell down or right.\\n\\nFormally, consider all the paths from the cell (x_1, y_1) to cell (x_2, y_2) such that each next cell in the path is located either to the down or to the right of the previous one. Calculate the number of different sums of elements for all such paths.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 57179) — the number of test cases.\\n\\nEach of the following t lines contains four natural numbers x_1, y_1, x_2, y_2 (1 ≤ x_1 ≤ x_2 ≤ 10^9, 1 ≤ y_1 ≤ y_2 ≤ 10^9) — coordinates of the start and the end cells. \\n\\nOutput\\n\\nFor each test case, in a separate line, print the number of possible different sums on the way from the start cell to the end cell.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n1 1 2 2\\n1 2 2 4\\n179 1 179 100000\\n5 7 5 7\\n\\n\\nOutput\\n\\n\\n2\\n3\\n1\\n1\\n\\nNote\\n\\nIn the first test case there are two possible sums: 1+2+5=8 and 1+3+5=9. \\n\\/* pa\",\"targets\":\"ckage 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 Main\\n{\\n\\tpublic static void main (String[] args) throws java.lang.Exception\\n\\t{\\n\\t\\n\\tBufferedReader bf = new BufferedReader(new InputStreamReader(System.in));\\n\\tint t=Integer.parseInt(bf.readLine());\\n\\twhile(t-->0)\\n\\t{\\n\\t String []s=bf.readLine().split(\\\" \\\");\\n\\t int x1=Integer.parseInt(s[0]);\\n\\t int y1=Integer.parseInt(s[1]);\\n\\t int x2=Integer.parseInt(s[2]);\\n\\t int y2=Integer.parseInt(s[3]);\\n\\t \\n\\t int x=x2-x1;\\n\\t int y=y2-y1;\\n\\t long z=(x*1L*y)+0L+1;\\n\\t System.out.println(z);\\n\\t \\n\\t}\\n\\t\\n\\t}\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"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.\\n\\nOn the current level, the hero got into a system of n caves numbered from 1 to n, and m tunnels between them. Each tunnel connects two distinct caves. Any two caves are connected with at most one tunnel. Any cave can be reached from any other cave by moving via tunnels.\\n\\nThe hero starts the level in cave 1, and every other cave contains a monster.\\n\\nThe hero can move between caves via tunnels. If the hero leaves a cave and enters a tunnel, he must finish his movement and arrive at the opposite end of the tunnel.\\n\\nThe hero can use each tunnel to move in both directions. However, the hero can not use the same tunnel twice in a row. Formally, if the hero has just moved from cave i to cave j via a tunnel, he can not head back to cave i immediately after, but he can head to any other cave connected to cave j with a tunnel.\\n\\nIt is known that at least two tunnels come out of every cave, thus, the hero will never find himself in a dead end even considering the above requirement.\\n\\nTo pass the level, the hero must beat the monsters in all the caves. When the hero enters a cave for the first time, he will have to fight the monster in it. The hero can beat the monster in cave i if and only if the hero's power is strictly greater than a_i. In case of beating the monster, the hero's power increases by b_i. If the hero can't beat the monster he's fighting, the game ends and the player loses.\\n\\nAfter the hero beats the monster in cave i, all subsequent visits to cave i won't have any consequences: the cave won't have any monsters, and the hero's power won't change either.\\n\\nFind the smallest possible power the hero must start the level with to be able to beat all the monsters and pass the level.\\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 two integers n and m (3 ≤ n ≤ 1000; n ≤ m...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nint n, m, a[1005], b[1005];\\nlong long ans, NowD;\\nvector vec[1005];\\nbool Reach[1005], vis[1005];\\nlong long dis[1005];\\nint From[1005];\\nbool check(long long x) {\\n queue Q;\\n for (int i = 1; i <= n; i++) {\\n if (Reach[i]) {\\n dis[i] = x;\\n vis[i] = true;\\n Q.push(i);\\n From[i] = 0;\\n } else {\\n dis[i] = 0;\\n From[i] = 0;\\n vis[i] = false;\\n }\\n }\\n while (!Q.empty()) {\\n int Now = Q.front();\\n Q.pop();\\n if (!Reach[Now]) {\\n for (auto &p : vec[Now]) {\\n if (p == From[Now]) continue;\\n if (vis[p]) return true;\\n if (a[p] >= dis[Now]) continue;\\n vis[p] = true;\\n dis[p] = dis[Now] + b[p];\\n Q.push(p);\\n From[p] = Now;\\n }\\n } else {\\n for (auto &p : vec[Now]) {\\n if (vis[p] || a[p] >= dis[Now]) continue;\\n vis[p] = true;\\n dis[p] = dis[Now] + b[p];\\n Q.push(p);\\n From[p] = Now;\\n }\\n }\\n }\\n return false;\\n}\\nvoid GetR(int x) {\\n while (From[x] != 0) {\\n if (!Reach[x]) {\\n Reach[x] = true;\\n NowD += b[x];\\n }\\n x = From[x];\\n }\\n}\\nvoid bfs(long long x) {\\n queue Q;\\n for (int i = 1; i <= n; i++) {\\n if (Reach[i]) {\\n dis[i] = x;\\n vis[i] = true;\\n From[i] = 0;\\n Q.push(i);\\n } else {\\n dis[i] = 0;\\n From[i] = 0;\\n vis[i] = false;\\n }\\n }\\n while (!Q.empty()) {\\n int Now = Q.front();\\n Q.pop();\\n if (!Reach[Now]) {\\n for (auto &p : vec[Now]) {\\n if (p == From[Now]) continue;\\n if (vis[p]) {\\n GetR(Now);\\n if (!Reach[p]) GetR(p);\\n return;\\n }\\n if (a[p] >= dis[Now]) continue;\\n vis[p] = true;\\n dis[p] = dis[Now] + b[p];\\n Q.push(p);\\n From[p] = Now;\\n }\\n } else {\\n for (auto &p : vec[Now]) {\\n if (vis[p] || a[p] >= dis[Now]) continue;\\n vis[p] = true;\\n dis[p] = dis[Now] + b[p];\\n From[p] = Now;\\n Q.push(p);\\n }\\n }\\n }\\n}\\nint main() {\\n int t;\\n scanf(\\\"%d\\\",...\",\"language\":\"python\",\"split\":\"valid\",\"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\":\"k,n,w = list(map(int,input().split(\\\" \\\")))\\ntotal = 0\\nfor i in range(1,w+1):\\n total += k*i\\n\\nif total > n:\\n print(total - n)\\nelse:\\n print(0)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"Monocarp is the coach of the Berland State University programming teams. He decided to compose a problemset for a training session for his teams.\\n\\nMonocarp has n problems that none of his students have seen yet. The i-th problem has a topic a_i (an integer from 1 to n) and a difficulty b_i (an integer from 1 to n). All problems are different, that is, there are no two tasks that have the same topic and difficulty at the same time.\\n\\nMonocarp decided to select exactly 3 problems from n problems for the problemset. The problems should satisfy at least one of two conditions (possibly, both):\\n\\n * the topics of all three selected problems are different; \\n * the difficulties of all three selected problems are different. \\n\\n\\n\\nYour task is to determine the number of ways to select three problems for the problemset.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 50000) — the number of testcases.\\n\\nThe first line of each testcase contains an integer n (3 ≤ n ≤ 2 ⋅ 10^5) — the number of problems that Monocarp have.\\n\\nIn the i-th of the following n lines, there are two integers a_i and b_i (1 ≤ a_i, b_i ≤ n) — the topic and the difficulty of the i-th problem.\\n\\nIt is guaranteed that there are no two problems that have the same topic and difficulty at the same time.\\n\\nThe sum of n over all testcases doesn't exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nPrint the number of ways to select three training problems that meet either of the requirements described in the statement.\\n\\nExample\\n\\nInput\\n\\n\\n2\\n4\\n2 4\\n3 4\\n2 1\\n1 3\\n5\\n1 5\\n2 4\\n3 3\\n4 2\\n5 1\\n\\n\\nOutput\\n\\n\\n3\\n10\\n\\nNote\\n\\nIn the first example, you can take the following sets of three problems:\\n\\n * problems 1, 2, 4; \\n * problems 1, 3, 4; \\n * problems 2, 3, 4. \\n\\n\\n\\nThus, the number of ways is equal to three.\\\":\",\"targets\":\"import 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.util.InputMismatchException;\\nimport java.io.IOException;\\nimport java.util.Random;\\nimport java.util.ArrayList;\\nimport java.util.Map;\\nimport java.io.Writer;\\nimport java.util.Map.Entry;\\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 *\\/\\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 DTrainingSession solver = new DTrainingSession();\\n solver.solve(1, in, out);\\n out.close();\\n }\\n\\n static class DTrainingSession {\\n public void solve(int testNumber, InputReader in, OutputWriter out) {\\n var tc = in.nextInt();\\n for (int i = 0; i < tc; i++) {\\n solution(i, in, out);\\n }\\n }\\n\\n void solution(int testNumber, InputReader in, OutputWriter out) {\\n int n = in.nextInt();\\n EzIntIntHashMap s = new EzIntIntHashMap();\\n EzIntIntHashMap d = new EzIntIntHashMap();\\n ArrayList pp = new ArrayList<>();\\n for (int i = 0; i < n; i++) {\\n var a = in.nextInt();\\n var b = in.nextInt();\\n s.put(a, s.get(a) + 1);\\n d.put(b, d.get(b) + 1);\\n pp.add(new EzIntIntPair(a, b));\\n }\\n long combos = BinomialCoefficient.nCr4(n, 3);\\n for (var xx : pp) {\\n \\/\\/ for every one, what combos, (not including myself) do I block out?\\n combos -= (long) (s.get(xx.first) - 1) * (long) (d.get(xx.second) - 1);\\n }\\n out.println(combos);\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Description\\nYou are given two strings S and T, such that length of S is greater than the length of T.\\nThen a substring of S is defined as a sequence of characters which appear consecutively in S.\\n\\nFind the total number of distinct substrings of M such that T is a substring of M\\n\\nInput Format\\nOne line containing strings S and T separated by a space.\\n\\nOutput Format\\nOne line containing the number of distinct substrings of M such that T is a substring of M\\n\\nInput Limits:\\n0 < Length(S), Length(T) < 100\\n\\nSAMPLE INPUT\\nabcc c\\n\\nSAMPLE OUTPUT\\n6\\n\\nExplanation\\n\\nSuppose the string S is abcc. Then the distinct substrings of S are\\na, b, c, ab, bc, cc, abc, bcc, abcc\",\"targets\":\"def get_unique_substrings(inputstr, uniqsubstrs):\\n uniqsubstrs.add(inputstr)\\n \\n i,j = 0,0\\n #u[j]=inputstr\\n length = len(inputstr)\\n while i < length:\\n substr1 = inputstr[i:]\\n j = len(substr1)\\n k = j\\n while k >= 1:\\n substr2 = substr1[:k]\\n #print(substr2)\\n if substr2 not in uniqsubstrs:\\n uniqsubstrs.add(substr2)\\n #j+=1\\n #u[j]=substr2\\n \\n k -= 1\\n i +=1\\ns1,s2=raw_input().split() \\nallunique_substr = set(s1)\\nget_unique_substrings(s1, allunique_substr)\\nc=0\\ns=list(allunique_substr)\\n#print s\\nfor i in range(len(s)):\\n\\tif s2 in s[i]:\\n\\t\\tc+=1\\n\\t\\t \\nprint c\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alice and Bob have a tree (undirected acyclic connected graph). There are ai chocolates waiting to be picked up in the i-th vertex of the tree. First, they choose two different vertices as their starting positions (Alice chooses first) and take all the chocolates contained in them.\\n\\nThen, they alternate their moves, selecting one vertex at a time and collecting all chocolates from this node. To make things more interesting, they decided that one can select a vertex only if he\\/she selected a vertex adjacent to that one at his\\/her previous turn and this vertex has not been already chosen by any of them during other move.\\n\\nIf at any moment one of them is not able to select the node that satisfy all the rules, he\\/she will skip his turns and let the other person pick chocolates as long as he\\/she can. This goes on until both of them cannot pick chocolates any further.\\n\\nDue to their greed for chocolates, they want to collect as many chocolates as possible. However, as they are friends they only care about the total number of chocolates they obtain together. What is the maximum total number of chocolates they may pick?\\n\\nInput\\n\\nThe first line of the input contains the single integer n (2 ≤ n ≤ 100 000) — the number of vertices in the tree.\\n\\nThe second line contains n integers ai (1 ≤ ai ≤ 109), i-th of these numbers stands for the number of chocolates stored at the node i.\\n\\nThen follow n - 1 lines that describe the tree. Each of them contains two integers ui and vi (1 ≤ ui, vi ≤ n) — indices of vertices connected by the i-th edge.\\n\\nOutput\\n\\nPrint the number of chocolates Alice and Bob can collect together if they behave optimally.\\n\\nExamples\\n\\nInput\\n\\n9\\n1 2 3 4 5 6 7 8 9\\n1 2\\n1 3\\n1 4\\n1 5\\n1 6\\n1 7\\n1 8\\n1 9\\n\\n\\nOutput\\n\\n25\\n\\n\\nInput\\n\\n2\\n20 10\\n1 2\\n\\n\\nOutput\\n\\n30\\n\\nNote\\n\\nIn the first sample, Alice may start at the vertex 9 and Bob at vertex 8. Alice will select vertex 1 and Bob has no options now. Alice selects the vertex 7 and they both stop.\\n\\nIn the second sample, both of them will pick either of the nodes alternately.\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint n;\\nint a[101010];\\nlong long f[101010], g[101010];\\nstruct edge {\\n int to, nxt;\\n} ed[202020];\\nint edcnt = 0;\\nint hd[101010];\\ninline void adde(int u, int v) {\\n ed[++edcnt] = {v, hd[u]};\\n hd[u] = edcnt;\\n}\\nvoid dfs(int u, int fa) {\\n f[u] = a[u];\\n long long a1 = 0, a2 = 0;\\n for (int id = hd[u]; id; id = ed[id].nxt) {\\n int v = ed[id].to;\\n if (v == fa) continue;\\n dfs(v, u);\\n if (f[v] >= a1) {\\n a2 = a1;\\n a1 = f[v];\\n } else if (f[v] >= a2) {\\n a2 = f[v];\\n }\\n g[u] = max(g[v], g[u]);\\n }\\n f[u] += a1;\\n g[u] = max(g[u], a[u] + a1 + a2);\\n}\\nlong long ans = 0;\\nvoid dfs2(int u, int fa, long long upf, long long upg) {\\n ans = max(ans, upg + g[u]);\\n multiset fs, gs;\\n fs.insert(upf);\\n gs.insert(upg);\\n for (int id = hd[u]; id; id = ed[id].nxt) {\\n int v = ed[id].to;\\n if (v == fa) continue;\\n fs.insert(f[v]);\\n gs.insert(g[v]);\\n }\\n for (int id = hd[u]; id; id = ed[id].nxt) {\\n int v = ed[id].to;\\n if (v == fa) continue;\\n fs.erase(fs.find(f[v]));\\n gs.erase(gs.find(g[v]));\\n long long vf = *fs.rbegin() + a[u], vg = *gs.rbegin();\\n long long newg = vf;\\n if (fs.size() > 1) {\\n auto it = fs.rbegin();\\n it++;\\n newg += *it;\\n }\\n vg = max(vg, newg);\\n dfs2(v, u, vf, vg);\\n fs.insert(f[v]);\\n gs.insert(g[v]);\\n }\\n}\\nint main() {\\n scanf(\\\"%d\\\", &n);\\n for (int i = 1; i <= n; ++i) scanf(\\\"%d\\\", &a[i]);\\n for (int i = 1, u, v; i < n; ++i)\\n scanf(\\\"%d%d\\\", &u, &v), adde(u, v), adde(v, u);\\n dfs(1, 1);\\n dfs2(1, 1, 0, 0);\\n printf(\\\"%lld\\\\n\\\", ans);\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"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 JAVA.\",\"targets\":\"import java.util.Scanner;\\n\\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 String s = sc.next();\\n char[][] ans = new char[n][n];\\n int[] wins = new int[n];\\n for(int i = 0 ; i < n ; i++) {\\n for (int j = 0 ; j < n ;j++) {\\n if(ans[i][j] != '+' && ans[i][j] !='X'&& ans[i][j] != '-' && ans[i][j] != '=' ) {\\n if (i == j) {\\n ans[i][j] = 'X';\\n } else if (s.charAt(i) == '1' && s.charAt(j) == '1') {\\n ans[i][j] = '=';\\n } else if (s.charAt(i) == '1' && s.charAt(j) == '2') {\\n ans[i][j] = '+';\\n ans[j][i] = '-';\\n wins[i]++;\\n } else if (s.charAt(i) == '2' && s.charAt(j) == '1') {\\n ans[i][j] = '-';\\n ans[j][i] = '+';\\n wins[j]++;\\n }\\n\\n }\\n\\n }\\n }\\n\\n for (int i = 0; i 0) {\\n ans[j][i] = '+';\\n ans[i][j] = '-';\\n wins[j]++;\\n }else {\\n wins[i]++;\\n ans[i][j] = '+';\\n ans[j][i] = '-';\\n }\\n }\\n }\\n }\\n\\n boolean res = true;\\n for (int i = 0; i \\n\\nAs mentioned previously William really likes playing video games. In one of his favorite games, the player character is in a universe where every planet is designated by a binary number from 0 to 2^n - 1. On each planet, there are gates that allow the player to move from planet i to planet j if the binary representations of i and j differ in exactly one bit.\\n\\nWilliam wants to test you and see how you can handle processing the following queries in this game universe:\\n\\n * Destroy planets with numbers from l to r inclusively. These planets cannot be moved to anymore.\\n * Figure out if it is possible to reach planet b from planet a using some number of planetary gates. It is guaranteed that the planets a and b are not destroyed. \\n\\nInput\\n\\nThe first line contains two integers n, m (1 ≤ n ≤ 50, 1 ≤ m ≤ 5 ⋅ 10^4), which are the number of bits in binary representation of each planets' designation and the number of queries, respectively.\\n\\nEach of the next m lines contains a query of two types:\\n\\nblock l r — query for destruction of planets with numbers from l to r inclusively (0 ≤ l ≤ r < 2^n). It's guaranteed that no planet will be destroyed twice.\\n\\nask a b — query for reachability between planets a and b (0 ≤ a, b < 2^n). It's guaranteed that planets a and b hasn't been destroyed yet.\\n\\nOutput\\n\\nFor each query of type ask you must output \\\"1\\\" in a new line, if it is possible to reach planet b from planet a and \\\"0\\\" otherwise (without quotation marks).\\n\\nExamples\\n\\nInput\\n\\n\\n3 3\\nask 0 7\\nblock 3 6\\nask 0 7\\n\\n\\nOutput\\n\\n\\n1\\n0\\n\\n\\nInput\\n\\n\\n6 10\\nblock 12 26\\nask 44 63\\nblock 32 46\\nask 1 54\\nblock 27 30\\nask 10 31\\nask 11 31\\nask 49 31\\nblock 31 31\\nask 2 51\\n\\n\\nOutput\\n\\n\\n1\\n1\\n0\\n0\\n1\\n0\\n\\nNote\\n\\nThe first example test can be visualized in the following way:\\n\\n\\n\\nResponse to a query ask 0 7 is positive.\\n\\nNext after query block 3 6 the graph will look the following way (destroyed vertices are highlighted):\\n\\n\\n\\nResponse to a query ask 0 7 is negative, since any path from vertex 0 to vertex 7 must go through one of the destroyed vertices.\\\":\",\"targets\":\"#include \\nusing namespace std;\\nconst int c = 50005, c2 = 5000000;\\nint n, m, bl, cs = 1, cnt;\\nlong long po[52];\\nvector p;\\nvector > kerd[c];\\nvector > el[c];\\nvector ans;\\nint bal[c2], jobb[c2], id[c2], t[c2], ki[c2];\\nvoid add(int a, long long l, long long r, long long x, long long y) {\\n if (x >= r || l >= y) {\\n return;\\n }\\n if (x <= l && r <= y) {\\n id[a] = ++cnt;\\n t[a] = bl;\\n return;\\n }\\n if (!bal[a]) {\\n bal[a] = ++cs;\\n }\\n if (!jobb[a]) {\\n jobb[a] = ++cs;\\n }\\n long long mid = (l + r) \\/ 2;\\n add(bal[a], l, mid, x, y);\\n add(jobb[a], mid, r, x, y);\\n}\\nvoid add(long long x, long long y) {\\n if (x > y) {\\n return;\\n }\\n add(1, 0, po[n], x, y + 1);\\n}\\nvoid dfs(int a, int b, int dif, int l) {\\n if (id[a] && id[b]) {\\n if (a != b) {\\n el[min(t[a], t[b])].push_back({id[a], id[b]});\\n }\\n return;\\n }\\n if (l == dif) {\\n return dfs(bal[a], jobb[b], dif, l - 1);\\n }\\n int a1 = (bal[a] ? bal[a] : a), a2 = (jobb[a] ? jobb[a] : a),\\n b1 = (bal[b] ? bal[b] : b), b2 = (jobb[b] ? jobb[b] : b);\\n dfs(a1, b1, dif, l - 1);\\n dfs(a2, b2, dif, l - 1);\\n}\\nint holvan(int a) { return (ki[a] ? ki[a] = holvan(ki[a]) : a); }\\nvoid unio(int a, int b) {\\n a = holvan(a), b = holvan(b);\\n if (a != b) {\\n ki[a] = b;\\n }\\n}\\nint ker(int a, int l, long long val) {\\n if (id[a]) {\\n return id[a];\\n }\\n int kov = ((val & po[l]) ? jobb[a] : bal[a]);\\n return ker(kov, l - 1, val);\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin >> n >> m;\\n po[0] = 1;\\n for (int i = 1; i <= n; i++) {\\n po[i] = po[i - 1] * 2;\\n }\\n p.push_back(-1), p.push_back(po[n]);\\n for (int i = 1; i <= m; i++) {\\n string s;\\n long long x, y;\\n cin >> s >> x >> y;\\n if (s == \\\"block\\\") {\\n bl++;\\n add(x, y);\\n p.push_back(x), p.push_back(y);\\n } else {\\n kerd[bl].push_back({x, y});\\n }\\n }\\n bl++;\\n sort(p.begin(), p.end());\\n for (int i = 0; i < p.size(); i += 2) {\\n add(p[i] + 1, p[i + 1] - 1);\\n }\\n for (int i = 0; i < n; i++) {\\n...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Akari has n kinds of flowers, one of each kind.\\n\\nShe is going to choose one or more of these flowers to make a bouquet.\\n\\nHowever, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b.\\n\\nHow many different bouquets are there that Akari can make?\\n\\nFind the count modulo (10^9 + 7).\\n\\nHere, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.\\n\\nConstraints\\n\\n* All values in input are integers.\\n* 2 \\\\leq n \\\\leq 10^9\\n* 1 \\\\leq a < b \\\\leq \\\\textrm{min}(n, 2 \\\\times 10^5)\\n\\nInput\\n\\nInput is given from Standard Input in the following format:\\n\\n\\nn a b\\n\\n\\nOutput\\n\\nPrint the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print `0`.)\\n\\nExamples\\n\\nInput\\n\\n4 1 3\\n\\n\\nOutput\\n\\n7\\n\\n\\nInput\\n\\n1000000000 141421 173205\\n\\n\\nOutput\\n\\n34076506\",\"targets\":\"import math\\nn,a,b = [int(i) for i in input().split()]\\nmod = 10**9+7\\n \\ndef comb(n,k):\\n ans = 1\\n for i in range(k):\\n ans = ans*(n-i)%mod\\n for i in range(1,k+1):\\n ans = ans*pow(i,mod-2,mod)%mod\\n return ans\\n\\nprint((pow(2,n,mod)-1-comb(n,a)-comb(n,b))%mod)\\n# print(comb(n,a))\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nPolycarp has n coins, the value of the i-th coin is a_i. It is guaranteed that all the values are integer powers of 2 (i.e. a_i = 2^d for some non-negative integer number d).\\n\\nPolycarp wants to know answers on q queries. The j-th query is described as integer number b_j. The answer to the query is the minimum number of coins that is necessary to obtain the value b_j using some subset of coins (Polycarp can use only coins he has). If Polycarp can't obtain the value b_j, the answer to the j-th query is -1.\\n\\nThe queries are independent (the answer on the query doesn't affect Polycarp's coins).\\n\\nInput\\n\\nThe first line of the input contains two integers n and q (1 ≤ n, q ≤ 2 ⋅ 10^5) — the number of coins and the number of queries.\\n\\nThe second line of the input contains n integers a_1, a_2, ..., a_n — values of coins (1 ≤ a_i ≤ 2 ⋅ 10^9). It is guaranteed that all a_i are integer powers of 2 (i.e. a_i = 2^d for some non-negative integer number d).\\n\\nThe next q lines contain one integer each. The j-th line contains one integer b_j — the value of the j-th query (1 ≤ b_j ≤ 10^9).\\n\\nOutput\\n\\nPrint q integers ans_j. The j-th integer must be equal to the answer on the j-th query. If Polycarp can't obtain the value b_j the answer to the j-th query is -1.\\n\\nExample\\n\\nInput\\n\\n5 4\\n2 4 8 2 4\\n8\\n5\\n14\\n10\\n\\n\\nOutput\\n\\n1\\n-1\\n3\\n2\",\"targets\":\"#include \\nusing namespace std;\\nconst long long MOD = 1e9 + 7;\\nconst long double PI = 4 * atan((long double)1);\\nconst long long INF = 1e18;\\nconst long long NINF = -1e18;\\nlong long get_hash(string s) {\\n long long N = 1000001;\\n long long base[N], A = 11, MD = 1110111110111;\\n base[0] = 1;\\n for (long long i = (1); i < (N); ++i) base[i] = (base[i - 1] * A) % MD;\\n long long hs = 0;\\n for (long long i = (0); i < (s.size()); ++i) {\\n hs += (s[i] * base[i]);\\n hs %= MD;\\n }\\n return hs;\\n}\\nlong long power(long long a, long long n) {\\n long long res = 1;\\n while (n) {\\n if (n % 2) res *= a;\\n a *= a;\\n n \\/= 2;\\n }\\n return res;\\n}\\nvector vec_splitter(string s) {\\n s += ',';\\n vector res;\\n while (!s.empty()) {\\n res.push_back(s.substr(0, s.find(',')));\\n s = s.substr(s.find(',') + 1);\\n }\\n return res;\\n}\\nvoid debug_out(vector __attribute__((unused)) args,\\n __attribute__((unused)) long long idx,\\n __attribute__((unused)) long long LINE_NUM) {\\n cerr << endl;\\n}\\ntemplate \\nvoid debug_out(vector args, long long idx, long long LINE_NUM, Head H,\\n Tail... T) {\\n if (idx > 0)\\n cerr << \\\", \\\";\\n else\\n cerr << \\\"Line(\\\" << LINE_NUM << \\\") \\\";\\n stringstream ss;\\n ss << H;\\n cerr << args[idx] << \\\" = \\\" << ss.str();\\n debug_out(args, idx + 1, LINE_NUM, T...);\\n}\\nint32_t main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n ;\\n long long n, q;\\n cin >> n >> q;\\n long long a[n];\\n map mpa;\\n for (long long i = (0); i < (n); ++i) {\\n cin >> a[i];\\n mpa[a[i]]++;\\n }\\n while (q--) {\\n long long b;\\n cin >> b;\\n long long cnt = 0;\\n auto it = mpa.end();\\n it--;\\n while (b > 0) {\\n long long x = it->first;\\n long long y = it->second;\\n long long z = x * y;\\n if (z <= b) {\\n cnt += y;\\n b -= z;\\n } else {\\n long long u = b \\/ x;\\n b -= u * x;\\n cnt += u;\\n }\\n if (it == mpa.begin()) break;\\n ...\",\"language\":\"python\",\"split\":\"train\",\"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\\\".\",\"targets\":\"T = int(input())\\nfor _ in range(T):\\n n = int(input())\\n s = input()\\n\\n try:\\n i = s.index('ab')\\n except:\\n try:\\n i = s.index('ba')\\n except:\\n i = -1\\n\\n if i != -1:\\n l, r = i + 1, i + 3\\n print(\\\"{} {}\\\".format(i + 1, i + 2))\\n else:\\n print(\\\"-1 -1\\\")\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"\\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\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nconst long long INF = 0x3f3f3f3f3f3f3f3f;\\nconst int mo = 998244353;\\nconst int inv2 = 499122177;\\nconst double jzm = 0.9995;\\nconst int zero = 5000;\\nconst int orG = 3, invG = 332748118;\\nconst double Pi = acos(-1.0);\\nconst double eps = 1e-3;\\ntemplate \\n_T Fabs(_T x) {\\n return x < 0 ? -x : x;\\n}\\ntemplate \\nvoid read(_T &x) {\\n _T f = 1;\\n x = 0;\\n char s = getchar();\\n while (s > '9' || s < '0') {\\n if (s == '-') f = -1;\\n s = getchar();\\n }\\n while ('0' <= s && s <= '9') {\\n x = (x << 3) + (x << 1) + (s ^ 48);\\n s = getchar();\\n }\\n x *= f;\\n}\\ntemplate \\nvoid print(_T x) {\\n if (x < 0) {\\n x = (~x) + 1;\\n putchar('-');\\n }\\n if (x > 9) print(x \\/ 10);\\n putchar(x % 10 + '0');\\n}\\nlong long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }\\nint add(int x, int y, int p) { return x + y < p ? x + y : x + y - p; }\\nvoid Add(int &x, int y, int p) { x = add(x, y, p); }\\nint qkpow(int a, int s, int p) {\\n int t = 1;\\n while (s) {\\n if (s & 1LL) t = 1ll * a * t % p;\\n a = 1ll * a * a % p;\\n s >>= 1LL;\\n }\\n return t;\\n}\\nint n, k, d[55], mp[55][55], t[55], fa[55], tota, totb, deg[55], summ, ans,\\n ord[55][55], sta[55], stak;\\nbool cho[55][55], tmp[55][55], ap[55][55], fg[55];\\nstruct edge {\\n int u, v, w;\\n} a[2505], b[2505];\\nbool cmp(edge x, edge y) { return x.w < y.w; }\\nbool cmp1(int x, int y) { return t[x] < t[y]; }\\ndouble Rand() {\\n return 1.0 * (rand() * RAND_MAX + rand()) \\/ (RAND_MAX * RAND_MAX);\\n}\\nvoid makeSet(int x) {\\n for (int i = 1; i <= x; i++) fa[i] = i;\\n}\\nint findSet(int x) { return fa[x] == x ? x : fa[x] = findSet(fa[x]); }\\nvoid unionSet(int a, int b) {\\n int u = findSet(a), v = findSet(b);\\n if (u != v) fa[u] = v;\\n}\\nvoid work(int x) {\\n for (int i = 1; i <= n; i++) {\\n if (ord[x][i] <= k && !fg[findSet(ord[x][i])]) continue;\\n if (ord[x][i] <= k && deg[ord[x][i]] == d[ord[x][i]]) continue;\\n unionSet(ord[x][i], x);\\n tmp[min(ord[x][i], x)][max(ord[x][i], x)] = 1;\\n deg[ord[x][i]]++;\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"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 PYTHON.\",\"targets\":\"import sys\\nraw_input = iter(sys.stdin.read().splitlines()).next\\n\\ndef solution():\\n n, a, b = map(int, raw_input().split())\\n if abs(a-b) > 1 or a+b+2 > n:\\n return -1\\n result = range(1, n+1)\\n c = max(a, b)\\n for i in xrange((a == b), n, 2):\\n if not c:\\n break\\n result[i], result[i+1] = result[i+1], result[i]\\n c -= 1\\n return \\\" \\\".join(map(lambda x: str(n+1-x if a > b else x), result))\\n\\nfor case in xrange(int(raw_input())):\\n print '%s' % solution()\",\"language\":\"python\",\"split\":\"test\",\"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.\\nUsing python3 can you solve the prior task?\",\"targets\":\"t = int(input())\\nfor _ in range(t):\\n n = int(input())\\n arr = list(map(int, input().split()))\\n mx = 0\\n for i in range(n - 1):\\n mx = max(mx, arr[i] * arr[i + 1])\\n print(mx)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A divisor tree is a rooted tree that meets the following conditions: \\n\\n * Each vertex of the tree contains a positive integer number. \\n * The numbers written in the leaves of the tree are prime numbers. \\n * For any inner vertex, the number within it is equal to the product of the numbers written in its children. \\n\\n\\n\\nManao has n distinct integers a1, a2, ..., an. He tries to build a divisor tree which contains each of these numbers. That is, for each ai, there should be at least one vertex in the tree which contains ai. Manao loves compact style, but his trees are too large. Help Manao determine the minimum possible number of vertices in the divisor tree sought.\\n\\nInput\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 8). The second line contains n distinct space-separated integers ai (2 ≤ ai ≤ 1012).\\n\\nOutput\\n\\nPrint a single integer — the minimum number of vertices in the divisor tree that contains each of the numbers ai.\\n\\nExamples\\n\\nInput\\n\\n2\\n6 10\\n\\n\\nOutput\\n\\n7\\n\\n\\nInput\\n\\n4\\n6 72 8 4\\n\\n\\nOutput\\n\\n12\\n\\n\\nInput\\n\\n1\\n7\\n\\n\\nOutput\\n\\n1\\n\\nNote\\n\\nSample 1. The smallest divisor tree looks this way: \\n\\nSample 2. In this case you can build the following divisor tree: \\n\\nSample 3. Note that the tree can consist of a single vertex.\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nlong long getint() {\\n long long _x = 0, _tmp = 1;\\n char _tc = getchar();\\n while ((_tc < '0' || _tc > '9') && _tc != '-') _tc = getchar();\\n if (_tc == '-') _tc = getchar(), _tmp = -1;\\n while (_tc >= '0' && _tc <= '9') _x *= 10, _x += (_tc - '0'), _tc = getchar();\\n return _x * _tmp;\\n}\\nlong long mypow(long long _a, long long _x, long long _mod) {\\n if (_x == 0) return 1ll;\\n long long _tmp = mypow(_a, _x \\/ 2, _mod);\\n _tmp = (_tmp * _tmp) % _mod;\\n if (_x & 1) _tmp = (_tmp * _a) % _mod;\\n return _tmp;\\n}\\nbool equal(double _x, double _y) { return _x > _y - 1e-9 && _x < _y + 1e-9; }\\nint __ = 1, cs;\\nlong long n, a[9], f[9];\\nbool p[1000010];\\nvector pset;\\nvoid build() {\\n for (long long i = 2; i < 1000010; i++)\\n if (!p[i]) {\\n pset.push_back(i);\\n for (long long j = 1000010 \\/ i; j >= i; j--) p[i * j] = true;\\n }\\n}\\nvoid init() {\\n n = getint();\\n for (int i = 0; i < n; i++) a[i] = getint();\\n sort(a, a + n);\\n for (int i = 0; i < n; i++) {\\n long long ta = a[i];\\n for (long long j = 0; j < (int)pset.size() && pset[j] * pset[j] <= a[i];\\n j++)\\n while (ta % pset[j] == 0) f[i]++, ta \\/= pset[j];\\n if (ta > 1) f[i]++;\\n }\\n}\\nlong long ans;\\nvoid DFS(long long idx, long long cnt, long long bonus) {\\n if (idx < 0) {\\n ans = min(ans, cnt + (bonus > 1));\\n return;\\n }\\n if (f[idx] > 1) cnt++;\\n DFS(idx - 1, cnt + f[idx], bonus + 1);\\n for (int i = n - 1; i > idx; i--)\\n if (a[i] % a[idx] == 0) {\\n a[i] \\/= a[idx];\\n DFS(idx - 1, cnt, bonus);\\n a[i] *= a[idx];\\n }\\n}\\nvoid solve() {\\n ans = 1023456789ll;\\n DFS(n - 1, 0, 0);\\n cout << ans << endl;\\n}\\nint main() {\\n build();\\n while (__--) {\\n init();\\n solve();\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"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].\\nUsing python can you solve the prior task?\",\"targets\":\"from __future__ import division, print_function\\n\\nimport os,sys\\nfrom io import BytesIO, IOBase\\n\\nif sys.version_info[0] < 3:\\n from __builtin__ import xrange as range\\n from future_builtins import ascii, filter, hex, map, oct, zip\\n\\nfrom bisect import bisect_left as lower_bound, bisect_right as upper_bound \\ndef so(): return int(input())\\ndef st(): return input()\\ndef mj(): return map(int,input().strip().split(\\\" \\\"))\\ndef msj(): return (map(str,input().strip().split(\\\" \\\")))\\ndef le(): return list(map(int,input().split()))\\ndef rc(): return map(float,input().split())\\ndef lebe():return list(map(int, input()))\\n\\ndef dmain():\\n sys.setrecursionlimit(1000000)\\n threading.stack_size(1024000)\\n thread = threading.Thread(target=main)\\n thread.start()\\ndef joro(L):\\n return(''.join(map(str, L)))\\n\\n\\ndef decimalToBinary(n): return bin(n).replace(\\\"0b\\\",\\\"\\\")\\n\\n\\ndef isprime(n):\\n for i in range(2,int(n**0.5)+1):\\n if n%i==0:\\n return False\\n return True\\ndef npr(n, r):\\n return factorial(n) \\/\\/ factorial(n - r) if n >= r else 0\\n \\n \\n\\n \\n \\n \\ndef lower_bound(li, num):\\n answer = -1\\n start = 0\\n end = len(li) - 1\\n \\n while (start <= end):\\n middle = (end + start) \\/\\/ 2\\n if li[middle] >= num:\\n answer = middle\\n end = middle - 1\\n else:\\n start = middle + 1\\n return answer # min index where x is not less than num\\n \\n \\ndef upper_bound(li, num):\\n answer = -1\\n start = 0\\n end = len(li) - 1\\n \\n while (start <= end):\\n middle = (end + start) \\/\\/ 2\\n \\n if li[middle] <= num:\\n answer = middle\\n start = middle + 1\\n \\n else:\\n end = middle - 1\\n return answer # max index where x is not greater than num\\ndef tir(a,b,c):\\n if(0==c):\\n return 1\\n if(len(a)<=b):\\n return 0\\n \\n if(c!=-1):\\n return (tir(a,1+b,c+a[b]) or tir(a,b+1,c-a[b]) or tir(a,1+b,c)) \\n \\n \\n else:\\n return (tir(a,1+b,a[b]) or tir(a,b+1,-a[b]) or tir(a,1+b,-1))\\nhoi=int(2**20) \\n...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"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 JAVA.\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.io.PrintWriter;\\nimport java.util.*;\\n\\npublic class CodeForces {\\n static reader input = new reader();\\n static PrintWriter output = new PrintWriter(System.out);\\n\\n public static void main(String[] args) throws IOException {\\n \\/*\\n BufferedReader bf = new BufferedReader(new FileReader(\\\"input.txt\\\"));\\n PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(\\\"output.txt\\\")));\\n StringTokenizer stk= new StringTokenizer(bf.readLine());;\\n int n=Integer.parseInt(stk.nextToken());\\n *\\/\\n E();\\n output.close();\\n }\\n\\n public static void A(){\\n\\n }\\n\\n public static void B(){\\n\\n }\\n\\n public static void C(){\\n\\n }\\n\\n public static void D(){\\n\\n }\\n\\n public static void E(){\\n int T=input.nextInt();\\n for(int i=0;icount=new HashMap<>();\\n HashMapindex=new HashMap<>();\\n int n=t.length();\\n for(int j=0;jsorted=new ArrayList<>();\\n for(Map.Entryx: index.entrySet()){\\n sorted.add(new Pair(x.getKey(),x.getValue()));\\n }\\n Collections.sort(sorted, Comparator.comparingInt(p -> p.cnt));\\n StringBuilder order=new StringBuilder(\\\"\\\");\\n for(Pair x:sorted)\\n order.append(x.ch);\\n int totallen=0;\\n for(int j=0;jn)\\n output.println(-1);\\n else{\\n StringBuilder s=new StringBuilder(t.substring(0,totallen));\\n StringBuilder temp=new StringBuilder(\\\"\\\");\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\n\\n\\nAs mentioned previously William really likes playing video games. In one of his favorite games, the player character is in a universe where every planet is designated by a binary number from 0 to 2^n - 1. On each planet, there are gates that allow the player to move from planet i to planet j if the binary representations of i and j differ in exactly one bit.\\n\\nWilliam wants to test you and see how you can handle processing the following queries in this game universe:\\n\\n * Destroy planets with numbers from l to r inclusively. These planets cannot be moved to anymore.\\n * Figure out if it is possible to reach planet b from planet a using some number of planetary gates. It is guaranteed that the planets a and b are not destroyed. \\n\\nInput\\n\\nThe first line contains two integers n, m (1 ≤ n ≤ 50, 1 ≤ m ≤ 5 ⋅ 10^4), which are the number of bits in binary representation of each planets' designation and the number of queries, respectively.\\n\\nEach of the next m lines contains a query of two types:\\n\\nblock l r — query for destruction of planets with numbers from l to r inclusively (0 ≤ l ≤ r < 2^n). It's guaranteed that no planet will be destroyed twice.\\n\\nask a b — query for reachability between planets a and b (0 ≤ a, b < 2^n). It's guaranteed that planets a and b hasn't been destroyed yet.\\n\\nOutput\\n\\nFor each query of type ask you must output \\\"1\\\" in a new line, if it is possible to reach planet b from planet a and \\\"0\\\" otherwise (without quotation marks).\\n\\nExamples\\n\\nInput\\n\\n\\n3 3\\nask 0 7\\nblock 3 6\\nask 0 7\\n\\n\\nOutput\\n\\n\\n1\\n0\\n\\n\\nInput\\n\\n\\n6 10\\nblock 12 26\\nask 44 63\\nblock 32 46\\nask 1 54\\nblock 27 30\\nask 10 31\\nask 11 31\\nask 49 31\\nblock 31 31\\nask 2 51\\n\\n\\nOutput\\n\\n\\n1\\n1\\n0\\n0\\n1\\n0\\n\\nNote\\n\\nThe first example test can be visualized in the following way:\\n\\n\\n\\nResponse to a query ask 0 7 is positive.\\n\\nNext after query block 3 6 the graph will look the following way (destroyed vertices are highlighted):\\n\\n\\n\\nResponse to a query ask 0 7 is negative, since any path from vertex 0 to vertex 7 must go through one of the destroyed vertices.\",\"targets\":\"#include \\nusing namespace std;\\nconst int maxn = 5e4 + 5;\\nlong long l[maxn], r[maxn];\\nint op[maxn], root, id[maxn * 100], tot, idtot, ls[maxn * 100], rs[maxn * 100],\\n ban[maxn * 100], fa[maxn * 100], n;\\nvector has[maxn], g[maxn * 100];\\nvoid add(int &rt, long long l, long long r, long long ql, long long qr) {\\n if (!rt) rt = ++tot;\\n if (l >= ql && r <= qr) {\\n id[rt] = ++idtot;\\n return;\\n }\\n long long mid = l + r >> 1;\\n if (ql <= mid) add(ls[rt], l, mid, ql, qr);\\n if (qr >= mid + 1) add(rs[rt], mid + 1, r, ql, qr);\\n}\\nvoid getedge(int L, int R, int cur, int limt) {\\n if (!L || !R) return;\\n if (cur > limt) {\\n getedge(ls[L], ls[R], cur - 1, limt);\\n getedge(rs[L], rs[R], cur - 1, limt);\\n return;\\n }\\n if (cur == limt) {\\n getedge(ls[L], rs[R], cur - 1, limt);\\n return;\\n }\\n if (id[L] && id[R]) {\\n g[id[L]].push_back(id[R]);\\n g[id[R]].push_back(id[L]);\\n return;\\n }\\n if (id[L]) {\\n getedge(L, ls[R], cur - 1, limt);\\n getedge(L, rs[R], cur - 1, limt);\\n return;\\n }\\n if (id[R]) {\\n getedge(ls[L], R, cur - 1, limt);\\n getedge(rs[L], R, cur - 1, limt);\\n return;\\n }\\n getedge(ls[L], ls[R], cur - 1, limt);\\n getedge(rs[L], rs[R], cur - 1, limt);\\n}\\nvoid getpoint(int rt, long long l, long long r, int i, long long ql,\\n long long qr) {\\n if (l >= ql && r <= qr) {\\n has[i].push_back(id[rt]);\\n ban[id[rt]] = 1;\\n return;\\n }\\n long long mid = l + r >> 1;\\n if (ql <= mid) getpoint(ls[rt], l, mid, i, ql, qr);\\n if (qr >= mid + 1) getpoint(rs[rt], mid + 1, r, i, ql, qr);\\n}\\nint fd(int rt) { return rt == fa[rt] ? rt : (fa[rt] = fd(fa[rt])); }\\nvoid merge(int u, int v) {\\n if (fd(u) == fd(v)) return;\\n fa[fd(u)] = fd(v);\\n}\\nvoid insert(int x) {\\n fa[x] = x;\\n for (auto u : g[x]) {\\n if (fa[u]) merge(x, u);\\n }\\n}\\nint getbl(long long x) {\\n int u = root;\\n if (id[u]) return id[u];\\n for (int i = n - 1; i >= 0; --i) {\\n if ((x >> i) & 1) {\\n u = rs[u];\\n } else\\n u = ls[u];\\n if (id[u]) return id[u];\\n }\\n}\\nint main() {\\n int m;\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"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\":\"import java.util.*;\\npublic class A_Robot_Cleaner{\\n public static void main(String [] args){\\n\\n Scanner sc = new Scanner(System.in);\\n int t=sc.nextInt();\\n while(t-->0){\\n int n=sc.nextInt();\\n int m=sc.nextInt();\\n int x1=sc.nextInt();\\n int y1=sc.nextInt();\\n int x2=sc.nextInt();\\n int y2=sc.nextInt();\\n int res=0,r=1,d=1;\\n while(true){\\n \\n if(x1==x2 || y1==y2){\\n break;\\n } if(y1+d > m || y1+d <1){\\n d*=-1;\\n } if(x1+r > n || x1+r < 1){\\n r*=-1;\\n }\\n x1+=r;\\n y1+=d;\\n res++;\\n }\\n System.out.println(res);\\n }\\n sc.close();\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Every evening Vitalya sets n alarm clocks to wake up tomorrow. Every alarm clock rings during exactly one minute and is characterized by one integer ai — number of minute after midnight in which it rings. Every alarm clock begins ringing at the beginning of the minute and rings during whole minute. \\n\\nVitalya will definitely wake up if during some m consecutive minutes at least k alarm clocks will begin ringing. Pay attention that Vitalya considers only alarm clocks which begin ringing during given period of time. He doesn't consider alarm clocks which started ringing before given period of time and continues ringing during given period of time.\\n\\nVitalya is so tired that he wants to sleep all day long and not to wake up. Find out minimal number of alarm clocks Vitalya should turn off to sleep all next day. Now all alarm clocks are turned on. \\n\\nInput\\n\\nFirst line contains three integers n, m and k (1 ≤ k ≤ n ≤ 2·105, 1 ≤ m ≤ 106) — number of alarm clocks, and conditions of Vitalya's waking up. \\n\\nSecond line contains sequence of distinct integers a1, a2, ..., an (1 ≤ ai ≤ 106) in which ai equals minute on which i-th alarm clock will ring. Numbers are given in arbitrary order. Vitalya lives in a Berland in which day lasts for 106 minutes. \\n\\nOutput\\n\\nOutput minimal number of alarm clocks that Vitalya should turn off to sleep all next day long.\\n\\nExamples\\n\\nInput\\n\\n3 3 2\\n3 5 1\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\n5 10 3\\n12 8 18 25 1\\n\\n\\nOutput\\n\\n0\\n\\n\\nInput\\n\\n7 7 2\\n7 3 4 1 6 5 2\\n\\n\\nOutput\\n\\n6\\n\\n\\nInput\\n\\n2 2 2\\n1 3\\n\\n\\nOutput\\n\\n0\\n\\nNote\\n\\nIn first example Vitalya should turn off first alarm clock which rings at minute 3.\\n\\nIn second example Vitalya shouldn't turn off any alarm clock because there are no interval of 10 consequence minutes in which 3 alarm clocks will ring.\\n\\nIn third example Vitalya should turn off any 6 alarm clocks.\\nSolve the task in PYTHON.\",\"targets\":\"c = lambda:map(int, raw_input().split())\\nn, m, k = c()\\na = [0] + sorted(c())\\nd = [0] + [1] * n\\nj, b, t = 0, 0, 0\\nfor i in range(1, n + 1):\\n\\twhile a[i] - a[j] >= m:\\n\\t\\tb -= d[j]\\n\\t\\tj += 1\\n\\tb += 1\\n\\tif b >= k:\\n\\t\\tt += 1\\n\\t\\tb -= 1\\n\\t\\td[i] = 0\\nprint t\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"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...\",\"targets\":\"# cook your code here\\nimport os\\nimport sys\\nfrom math import ceil, floor, sqrt, gcd, factorial\\nfrom io import BytesIO, IOBase\\nfrom collections import Counter\\n\\nBUFSIZE = 8192\\n\\ndef main():\\n for _ in range(int(input())):\\n W,H=map(int,input().split())\\n x1,y1,x2,y2=map(int,input().split())\\n width=abs(x2-x1);height=abs(y2-y1)\\n w,h=map(int,input().split())\\n \\n ans = 0\\n if W-width=h:\\n if H-y2>=h:values.append(0)\\n else:values.append(down)\\n if y1>=h:values.append(0)\\n else:values.append(up)\\n \\n if W-width>=w:\\n if W-x2>=w:values.append(0)\\n else:values.append(left)\\n if x1>=w:values.append(0)\\n else:values.append(right)\\n \\n ans=min(values)\\n print('%.6f'%ans)\\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 ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"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.\",\"targets\":\"#include \\nusing namespace std;\\nvoid debug(vector v) {\\n for (int i = 0; i < v.size(); i++) {\\n cout << v[i] << \\\" \\\";\\n }\\n cout << endl;\\n}\\nusing namespace std;\\nconst int N = 3e5 + 5;\\nint ar[N];\\nvoid solve(int a, int b) {\\n int ans = ar[a];\\n if (ans == b) {\\n cout << a << endl;\\n return;\\n }\\n if ((ans ^ a) == b) {\\n cout << a + 2 << endl;\\n return;\\n } else {\\n cout << a + 1 << endl;\\n }\\n}\\nint main() {\\n ios::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n for (int i = 1; i < N; i++) {\\n ar[i] = ar[i - 1] ^ (i - 1);\\n }\\n int t;\\n cin >> t;\\n while (t > 0) {\\n int a, b;\\n cin >> a >> b;\\n solve(a, b);\\n t--;\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"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.HashSet;\\nimport java.util.Scanner;\\n\\npublic class CodeForces {\\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\\/\\/ int square=(int)Math.sqrt(n);\\n\\/\\/ int cube=(int)Math.cbrt(n);\\n\\/\\/ int sixth=(int)Math.pow(n,1.0\\/6.0);\\n\\/\\/ System.out.println(sixth);\\n\\/\\/ System.out.println(square+cube-sixth);\\n HashSets=new HashSet<>();\\n for (int i = 1; i*i <=n ; i++) {\\n s.add(i*i);\\n }\\n for (int i = 1; i*i*i <=n ; i++) {\\n s.add(i*i*i);\\n }\\n System.out.println(s.size());\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Bizon the Champion is called the Champion for a reason. \\n\\nBizon the Champion has recently got a present — a new glass cupboard with n shelves and he decided to put all his presents there. All the presents can be divided into two types: medals and cups. Bizon the Champion has a1 first prize cups, a2 second prize cups and a3 third prize cups. Besides, he has b1 first prize medals, b2 second prize medals and b3 third prize medals. \\n\\nNaturally, the rewards in the cupboard must look good, that's why Bizon the Champion decided to follow the rules:\\n\\n * any shelf cannot contain both cups and medals at the same time; \\n * no shelf can contain more than five cups; \\n * no shelf can have more than ten medals. \\n\\n\\n\\nHelp Bizon the Champion find out if we can put all the rewards so that all the conditions are fulfilled.\\n\\nInput\\n\\nThe first line contains integers a1, a2 and a3 (0 ≤ a1, a2, a3 ≤ 100). The second line contains integers b1, b2 and b3 (0 ≤ b1, b2, b3 ≤ 100). The third line contains integer n (1 ≤ n ≤ 100).\\n\\nThe numbers in the lines are separated by single spaces.\\n\\nOutput\\n\\nPrint \\\"YES\\\" (without the quotes) if all the rewards can be put on the shelves in the described manner. Otherwise, print \\\"NO\\\" (without the quotes).\\n\\nExamples\\n\\nInput\\n\\n1 1 1\\n1 1 1\\n4\\n\\n\\nOutput\\n\\nYES\\n\\n\\nInput\\n\\n1 1 3\\n2 3 4\\n2\\n\\n\\nOutput\\n\\nYES\\n\\n\\nInput\\n\\n1 0 0\\n1 0 0\\n1\\n\\n\\nOutput\\n\\nNO\\nimpor\",\"targets\":\"t math\\na=input().split()\\nb=input().split()\\nn=int(input())\\n\\nc=int(a[0])+int(a[1])+int(a[2])\\n\\nm=int(b[0])+int(b[1])+int(b[2])\\n\\n\\nnumC=math.ceil(c\\/5)\\n\\nnumM=math.ceil(m\\/10)\\n\\n#print(numC,numM)\\n\\nif numC+numM <=n:\\n print('YES')\\n \\nelse:\\n print('NO')\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\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 java.io.*;\\nimport java.util.*;\\nimport java.text.*;\\nimport java.math.*;\\n\\npublic class Main {\\n static class pair implements Comparable{\\n int val, index;\\n pair(int v, int i){\\n val = v;\\n index = i;\\n }\\n @Override\\n public int compareTo(pair that){\\n if(this.val == that.val)\\n return this.index - that.index;\\n return Integer.compare(this.val, that.val);\\n }\\n }\\n\\tpublic static void main(String[] args) throws IOException{\\n\\t\\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\\n StringBuilder sb = new StringBuilder();\\n\\t\\tint t = Integer.parseInt(br.readLine());\\n while(t-- > 0){\\n StringTokenizer st = new StringTokenizer(br.readLine());\\n int n = Integer.parseInt(st.nextToken());\\n int m = Integer.parseInt(st.nextToken());\\n st = new StringTokenizer(br.readLine());\\n int ar[] = new int[n*m];\\n for(int i = 0; i < n*m; i++){\\n ar[i] = Integer.parseInt(st.nextToken());\\n }\\n pair sorted[] = new pair[n*m];\\n for(int i = 0; i < n*m; i++)\\n sorted[i] = new pair(ar[i], i);\\n Arrays.sort(sorted);\\n int index = 0;\\n HashMap> map = new HashMap<>();\\n for(int i = 0; i < n; i++){\\n ArrayList l = new ArrayList<>();\\n for(int j = 0; j < m; j++){\\n l.add(sorted[index++]);\\n }\\n Collections.sort(l, (a, b) -> {\\n return a.index - b.index;\\n \\n });\\n map.put(i, l);\\n }\\n int count = 0;\\n for(int i = 0; i < n; i++){\\n HashMap filled = new HashMap<>();\\n \\/\\/ for(pair p: map.get(i))\\n \\/\\/ System.out.print(p.val + \\\" \\\" + p.index + \\\" \\\");\\n \\/\\/ System.out.println();\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A matrix of size n × m is called nice, if all rows and columns of the matrix are palindromes. A sequence of integers (a_1, a_2, ... , a_k) is a palindrome, if for any integer i (1 ≤ i ≤ k) the equality a_i = a_{k - i + 1} holds.\\n\\nSasha owns a matrix a of size n × m. In one operation he can increase or decrease any number in the matrix by one. Sasha wants to make the matrix nice. He is interested what is the minimum number of operations he needs.\\n\\nHelp him!\\n\\nInput\\n\\nThe first line contains a single integer t — the number of test cases (1 ≤ t ≤ 10). The t tests follow.\\n\\nThe first line of each test contains two integers n and m (1 ≤ n, m ≤ 100) — the size of the matrix.\\n\\nEach of the next n lines contains m integers a_{i, j} (0 ≤ a_{i, j} ≤ 10^9) — the elements of the matrix.\\n\\nOutput\\n\\nFor each test output the smallest number of operations required to make the matrix nice.\\n\\nExample\\n\\nInput\\n\\n\\n2\\n4 2\\n4 2\\n2 4\\n4 2\\n2 4\\n3 4\\n1 2 3 4\\n5 6 7 8\\n9 10 11 18\\n\\n\\nOutput\\n\\n\\n8\\n42\\n\\nNote\\n\\nIn the first test case we can, for example, obtain the following nice matrix in 8 operations:\\n \\n \\n \\n 2 2 \\n 4 4 \\n 4 4 \\n 2 2 \\n \\n\\nIn the second test case we can, for example, obtain the following nice matrix in 42 operations:\\n \\n \\n \\n 5 6 6 5 \\n 6 6 6 6 \\n 5 6 6 5 \\n \\nSolve the task in JAVA.\",\"targets\":\"import java.io.IOException;\\nimport java.io.InputStream;\\nimport java.util.*;\\n\\npublic class B {\\n\\tpublic static void main (String[] args) throws java.lang.Exception {\\n InputReader in = new InputReader(System.in);\\n int t = in.readInt();\\n while(t-->0) {\\n \\tint n = in.readInt();int m = in.readInt();\\n \\tint [][]nums = new int[n][m];\\n \\tfor(int i=0;i l = new ArrayList();\\n \\t\\t\\t\\t\\tl.add(p);\\n \\t\\t\\t\\t\\tl.add(r);\\n \\t\\t\\t\\t\\tCollections.sort(l);\\n \\t\\t\\t\\t\\tavg = l.get(l.size()\\/2);\\n \\t\\t\\t\\t\\tcount+= Math.abs(avg-p)+Math.abs(avg-r);\\n \\t\\t\\t\\t}\\n \\t\\t\\t} else {\\n \\t\\t\\t\\tif(n-j-1==j) {\\n \\t\\t\\t\\t\\tList l = new ArrayList();\\n \\t\\t\\t\\t\\tl.add(p);\\n \\t\\t\\t\\t\\tl.add(q);\\n \\t\\t\\t\\t\\tCollections.sort(l);\\n \\t\\t\\t\\t\\tavg = l.get(l.size()\\/2);\\n \\t\\t\\t\\t\\tcount+= Math.abs(avg-p)+Math.abs(avg-q);\\n \\t\\t\\t\\t} else {\\n \\t\\t\\t\\t\\tList l = new ArrayList();\\n \\t\\t\\t\\t\\tl.add(p);\\n \\t\\t\\t\\t\\tl.add(q);\\n \\t\\t\\t\\t\\tl.add(r);\\n \\t\\t\\t\\t\\tl.add(s);\\n \\t\\t\\t\\t\\tCollections.sort(l);\\n \\t\\t\\t\\t\\tavg = l.get(l.size()\\/2);\\n \\t\\t\\t\\t\\tcount+= Math.abs(avg-p)+Math.abs(avg-r)+Math.abs(avg-s)+Math.abs(avg-q);\\n \\t\\t\\t\\t}\\n \\t\\t\\t}\\n \\t\\t}\\n \\t}\\n \\tSystem.out.println(count);\\n }\\n\\t}\\n\\t\\n\\t\\n\\tstatic class InputReader {\\n\\t private...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"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\":\"#include \\nconst int inf = 0x3f3f3f3f;\\nconst int N = 1e8 + 10;\\nusing namespace std;\\nint a, b, c;\\nint main() {\\n int t;\\n cin >> t;\\n while (t--) {\\n cin >> a >> b >> c;\\n int z = abs(a - b) + 1;\\n int minn = min(a, b);\\n int maxn = max(a, b);\\n if (a == 1 && b == 2 || a == 2 && b == 1) {\\n if (c == 1)\\n cout << \\\"2\\\" << endl;\\n else if (c == 2)\\n cout << \\\"1\\\" << endl;\\n else\\n cout << \\\"-1\\\" << endl;\\n } else {\\n if (((z <= minn || z >= maxn) && minn != 1) || (c > z * 2 - 2)) {\\n cout << \\\"-1\\\" << endl;\\n continue;\\n }\\n if (c >= z)\\n cout << c - z + 1 << endl;\\n else\\n cout << c - 1 + z << endl;\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"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\\\".\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.io.IOException;\\nimport java.lang.reflect.Array;\\nimport java.util.*;\\nimport java.util.stream.*;\\nimport java.lang.Math.*;\\nimport java.util.Map.*;\\n\\npublic class Test {\\n public static final void main(String[] args)\\n {\\n Scanner sc = new Scanner(System.in);\\n int te=sc.nextInt();\\n while(te-- > 0)\\n {\\n int n = sc.nextInt();\\n String s = sc.next();\\n Solve worker = new Solve();\\n worker.solve(n,s);\\n }\\n }\\n}\\n\\nclass Solve {\\n public void solve(int n,String s)\\n {\\n int f=0;\\n for(int i=0;i {\\n public Integer a,b;\\n public Pair(Integer a,Integer b){\\n this.a=a;\\n this.b=b;\\n }\\n public int compareTo(Pair p)\\n {\\n if(this.a==p.a)\\n return p.b-this.b;\\n return p.a-this.a;\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"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,...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nlong long int s1_size, s2_size, f_size, c_size;\\nlong long int area(long long int base, long long int top) { return base * top; }\\nlong long int solve(long long int rectx, long long int recty,\\n vector s1, vector s2,\\n vector f, vector c) {\\n sort(s1.begin(), s1.end());\\n sort(s2.begin(), s2.end());\\n sort(f.begin(), f.end());\\n sort(c.begin(), c.end());\\n long long int ans[4];\\n long long int bottom = s1[0];\\n long long int top = s1[s1_size - 1];\\n ans[0] = area(abs(bottom - top), recty);\\n bottom = s2[0];\\n top = s2[s2_size - 1];\\n ans[1] = area(abs(bottom - top), recty);\\n bottom = f[0];\\n top = f[f_size - 1];\\n ans[2] = area(abs(bottom - top), rectx);\\n bottom = c[0];\\n top = c[c_size - 1];\\n ans[3] = area(abs(bottom - top), rectx);\\n sort(ans, ans + 4);\\n return ans[3];\\n}\\nint main() {\\n long long int length, t;\\n cin >> length;\\n long long int ans[length];\\n vector s1;\\n vector s2;\\n vector f;\\n vector c;\\n for (long long int index = 0; index < length; index++) {\\n f.clear();\\n c.clear();\\n s2.clear();\\n s1.clear();\\n long long int rectx, recty;\\n cin >> rectx >> recty;\\n cin >> s1_size;\\n for (long long int i = 0; i < s1_size; i++) {\\n cin >> t;\\n s1.push_back(t);\\n }\\n cin >> s2_size;\\n for (long long int i = 0; i < s2_size; i++) {\\n cin >> t;\\n s2.push_back(t);\\n }\\n cin >> f_size;\\n for (long long int i = 0; i < f_size; i++) {\\n cin >> t;\\n f.push_back(t);\\n }\\n cin >> c_size;\\n for (long long int i = 0; i < c_size; i++) {\\n cin >> t;\\n c.push_back(t);\\n }\\n ans[index] = solve(rectx, recty, s1, s2, f, c);\\n }\\n for (long long int i = 0; i < length; i++) {\\n cout << ans[i] << \\\"\\\\n\\\";\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"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\":\"\\/*package whatever \\/\\/do not write package name here\\nJAIKARA SHERAWALI DA BOl SACHE DARBAR KI JAI \\nJAI BHOLENAATH HAR HAR MAHADEV\\nRohit Kumar\\nNIT JAMSHEDPUR\\n*\\/\\nimport java.util.*;\\nimport java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.util.Scanner;\\nimport java.util.StringTokenizer;\\nimport java.util.TreeMap;\\nimport java.util.TreeSet;\\n\\npublic class Main {\\n static class FastReader {\\n BufferedReader br;\\n StringTokenizer st;\\n\\n public FastReader() {\\n br = new BufferedReader(new\\n 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 static int getIndex(int i, int N) {\\n i = i % N;\\n i = (i + N) % N;\\n return i;\\n }\\n\\n static int getDist(int i, int j, int N) {\\n int dist, swap;\\n if (i > j) {\\n swap = i;\\n i = j;\\n j = swap;\\n }\\n dist = j - i;\\n int x = N - j - 1;\\n dist = Math.min(dist, x + i+1);\\n return dist;\\n }\\n void sieveOfEratosthenes(int n)\\n {\\n boolean prime[] = new boolean[n+1];\\n for(int i=0;i<=n;i++)\\n prime[i] = true;\\n \\n for(int p = 2; p*p <=n; p++)\\n {\\n ...\",\"language\":\"python\",\"split\":\"test\",\"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\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nvoid solve() {\\n long long n, i, j;\\n string s, s1;\\n cin >> s >> s1;\\n long long sum = 0;\\n for (i = 1; i <= s1.length() - 1; i++) {\\n char aa, bb;\\n aa = s1[i];\\n bb = s1[i - 1];\\n long long a, b;\\n a = s.find(aa);\\n b = s.find(bb);\\n sum += abs(a - b);\\n }\\n cout << sum << endl;\\n ;\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(0), cout.tie(0);\\n long long t;\\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\":\"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 sys import stdin, stdout\\n\\nraw_input = input\\nxrange = range\\n\\nraw_input = lambda: stdin.readline().rstrip()\\ninput = lambda: int(raw_input())\\nI=lambda: map(int, raw_input().split())\\n\\ndef f(l, r):\\n\\tglobal pprefix, prefix, p\\n\\txl = sign(g(l))\\n\\tif xl == 0:\\n\\t\\treturn l\\n\\txr = sign(g(r))\\n\\tif xr == 0:\\n\\t\\treturn r\\n\\tl1 = l\\n\\tr1 = r\\n\\twhile True:\\n\\t\\tm = (r1+l1)\\/\\/2\\n\\t\\tx = sign(g(m))\\n\\t\\tif x==0:\\n\\t\\t\\treturn m\\n\\t\\tif x!=xl:\\n\\t\\t\\tr1 = m\\n\\t\\telif x!=xr:\\n\\t\\t\\tl1 = m\\n\\t\\t\\ndef sign(n):\\n\\tif n>0:\\n\\t\\treturn 1\\n\\telif n<0:\\n\\t\\treturn -1\\n\\telse:\\n\\t\\treturn 0\\n\\t\\t\\n\\t\\ndef g(i):\\n\\tglobal pprefix, p\\n\\treturn p + pprefix[i]\\n\\t# return prefix[i-1] - prefix[l-1] - prefix[r] + prefix[i] \\n\\nt = input()\\nfor _ in xrange(t):\\n\\tn,q = I()\\n\\ts = raw_input()\\n\\tprefix = [0]\\n\\tpprefix = [0]\\n\\tc = 0\\n\\tprevC = 0\\n\\tfor i in xrange(n):\\n\\t\\tif i%2:\\n\\t\\t\\tif s[i]=='-':\\n\\t\\t\\t\\tc += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tc -= 1\\n\\t\\telse:\\n\\t\\t\\tif s[i]=='+':\\n\\t\\t\\t\\tc += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tc -= 1\\n\\t\\tprefix.append(c)\\n\\t\\tpprefix.append(c+prevC)\\n\\t\\tprevC = c\\n\\tfor _ in xrange(q):\\n\\t\\ta,b = I()\\n\\t\\tw = prefix[b]-prefix[a-1]\\n\\t\\tif w==0:\\n\\t\\t\\tstdout.write('0\\\\n')\\n\\t\\telif (b-a)%2==0:\\n\\t\\t\\tstdout.write('1\\\\n')\\n\\t\\t\\tl = a\\n\\t\\t\\tr = b\\n\\t\\t\\tp = -(prefix[l-1] + prefix[r])\\n\\t\\t\\ty = f(l, r)\\n\\t\\t\\tstdout.write(str(y)+'\\\\n')\\n\\t\\telse:\\n\\t\\t\\tstdout.write('2\\\\n')\\n\\t\\t\\tl = a\\n\\t\\t\\tr = b-1\\n\\t\\t\\tp = -(prefix[l-1] + prefix[r])\\n\\t\\t\\ty = f(l, r)\\n\\t\\t\\tstdout.write(str(y)+' '+str(b)+'\\\\n')\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Ashish and Vivek play a game on a matrix consisting of n rows and m columns, where they take turns claiming cells. Unclaimed cells are represented by 0, while claimed cells are represented by 1. The initial state of the matrix is given. There can be some claimed cells in the initial state.\\n\\nIn each turn, a player must claim a cell. A cell may be claimed if it is unclaimed and does not share a row or column with any other already claimed cells. When a player is unable to make a move, he loses and the game ends.\\n\\nIf Ashish and Vivek take turns to move and Ashish goes first, determine the winner of the game if both of them are playing optimally.\\n\\nOptimal play between two players means that both players choose the best possible strategy to achieve the best possible outcome for themselves.\\n\\nInput\\n\\nThe first line consists of a single integer t (1 ≤ t ≤ 50) — the number of test cases. The description of the test cases follows.\\n\\nThe first line of each test case consists of two space-separated integers n, m (1 ≤ n, m ≤ 50) — the number of rows and columns in the matrix.\\n\\nThe following n lines consist of m integers each, the j-th integer on the i-th line denoting a_{i,j} (a_{i,j} ∈ \\\\{0, 1\\\\}).\\n\\nOutput\\n\\nFor each test case if Ashish wins the game print \\\"Ashish\\\" otherwise print \\\"Vivek\\\" (without quotes).\\n\\nExample\\n\\nInput\\n\\n\\n4\\n2 2\\n0 0\\n0 0\\n2 2\\n0 0\\n0 1\\n2 3\\n1 0 1\\n1 1 0\\n3 3\\n1 0 0\\n0 0 0\\n1 0 0\\n\\n\\nOutput\\n\\n\\nVivek\\nAshish\\nVivek\\nAshish\\n\\nNote\\n\\nFor the first case: One possible scenario could be: Ashish claims cell (1, 1), Vivek then claims cell (2, 2). Ashish can neither claim cell (1, 2), nor cell (2, 1) as cells (1, 1) and (2, 2) are already claimed. Thus Ashish loses. It can be shown that no matter what Ashish plays in this case, Vivek will win. \\n\\nFor the second case: Ashish claims cell (1, 1), the only cell that can be claimed in the first move. After that Vivek has no moves left.\\n\\nFor the third case: Ashish cannot make a move, so Vivek wins.\\n\\nFor the fourth case: If Ashish claims cell (2, 3), Vivek will have no moves left.\\nUsing python3 can you solve the prior task?\",\"targets\":\"import sys\\ninput = lambda:sys.stdin.readline().strip()\\nt = int(input())\\nwhile t:\\n t-=1\\n n,m = map(int,input().split())\\n mat = []\\n for i in range(n):\\n mat.append(list(map(int,input().split())))\\n o_r = 0\\n o_c = 0\\n for i in range(n):\\n if mat[i].count(1)>0:\\n o_r+=1\\n for j in range(m):\\n val = 0\\n for i in range(n):\\n if mat[i][j]==1:\\n val+=1\\n if val:\\n o_c+=1\\n pre = min(n-o_r,m-o_c)\\n if pre%2==0:\\n print(\\\"Vivek\\\")\\n else:\\n print(\\\"Ashish\\\")\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nOne warm and sunny day king Copa decided to visit the shooting gallery, located at the Central Park, and try to win the main prize — big pink plush panda. The king is not good at shooting, so he invited you to help him.\\n\\nThe shooting gallery is an infinite vertical plane with Cartesian coordinate system on it. The targets are points on this plane. Each target is described by it's coordinates xi, and yi, by the time of it's appearance ti and by the number pi, which gives the probability that Copa hits this target if he aims at it.\\n\\nA target appears and disappears instantly, so Copa can hit the target only if at the moment ti his gun sight aimed at (xi, yi). Speed of movement of the gun sight on the plane is equal to 1. Copa knows all the information about the targets beforehand (remember, he is a king!). He wants to play in the optimal way, which maximizes the expected value of the amount of hit targets. He can aim at any target at the moment 0.\\n\\nInput\\n\\nThe first line contains integer n (1 ≤ n ≤ 1000) — amount of targets in the shooting gallery. Then n lines follow, each describing one target. Each description consists of four numbers xi, yi, ti, pi (where xi, yi, ti — integers, - 1000 ≤ xi, yi ≤ 1000, 0 ≤ ti ≤ 109, real number pi is given with no more than 6 digits after the decimal point, 0 ≤ pi ≤ 1). No two targets may be at the same point.\\n\\nOutput\\n\\nOutput the maximum expected value of the amount of targets that was shot by the king. Your answer will be accepted if it differs from the correct answer by not more than 10 - 6.\\n\\nExamples\\n\\nInput\\n\\n1\\n0 0 0 0.5\\n\\n\\nOutput\\n\\n0.5000000000\\n\\n\\nInput\\n\\n2\\n0 0 0 0.6\\n5 0 5 0.7\\n\\n\\nOutput\\n\\n1.3000000000\",\"targets\":\"#include \\nusing namespace std;\\nconst int MAX_N = 1000;\\nstruct Target {\\n int x, y, t;\\n double p;\\n Target() {}\\n Target(int _x, int _y, int _t, double _p) : x(_x), y(_y), t(_t), p(_p) {}\\n bool operator<(const Target &g) const { return t < g.t; }\\n void read() { scanf(\\\"%d%d%d%lf\\\", &x, &y, &t, &p); }\\n int d2(const Target &g) const {\\n int dx = g.x - x, dy = g.y - y;\\n return dx * dx + dy * dy;\\n }\\n long long dt2(const Target &g) const {\\n long long dt = g.t - t;\\n return dt * dt;\\n }\\n};\\nTarget gs[MAX_N];\\ndouble dp[MAX_N];\\ninline void setmax(double &a, double b) {\\n if (a < b) a = b;\\n}\\nint main() {\\n int n;\\n scanf(\\\"%d\\\", &n);\\n for (int i = 0; i < n; i++) gs[i].read();\\n sort(gs, gs + n);\\n for (int i = 0; i < n; i++) {\\n Target &gi = gs[i];\\n dp[i] = gi.p;\\n for (int j = i - 1; j >= 0; j--)\\n if (gi.d2(gs[j]) <= gi.dt2(gs[j])) setmax(dp[i], dp[j] + gi.p);\\n }\\n double maxd = 0.0;\\n for (int i = 0; i < n; i++) setmax(maxd, dp[i]);\\n printf(\\\"%.10lf\\\\n\\\", maxd);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"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...\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\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 -...\",\"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...\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nvector get_divisors(int num) {\\n vector divisors(1, 1);\\n for (int i = 2; (i * i) <= num; ++i) {\\n if ((num % i) == 0) {\\n divisors.push_back(i);\\n int other = num \\/ i;\\n if (other > i) {\\n divisors.push_back(other);\\n }\\n }\\n }\\n if (num > 1) {\\n divisors.push_back(num);\\n }\\n return divisors;\\n}\\nvector solve(const vector& a) {\\n int n = a.size();\\n vector can(n + 1, 0);\\n int tot = 0;\\n for (int bi = 0; bi < 30; ++bi) {\\n int cnt = 0;\\n for (int x : a) {\\n cnt += (x >> bi) & 1;\\n }\\n if (cnt == 0) continue;\\n tot++;\\n vector divisors = get_divisors(cnt);\\n for (int d : get_divisors(cnt)) {\\n can[d]++;\\n }\\n }\\n vector ans;\\n for (int i = 1; i <= n; ++i) {\\n if (can[i] == tot) {\\n ans.push_back(i);\\n }\\n }\\n return ans;\\n}\\nvoid test_case() {\\n int n;\\n cin >> n;\\n vector a(n);\\n for (int i = 0; i < n; ++i) {\\n cin >> a[i];\\n }\\n vector ans = solve(a);\\n for (int i = 0; i < int(ans.size()); ++i) {\\n if (i > 0) cout << \\\" \\\";\\n cout << ans[i];\\n }\\n cout << \\\"\\\\n\\\";\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n int t;\\n cin >> t;\\n for (int i = 0; i < t; ++i) {\\n test_case();\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"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 java.io.*;\\nimport java.math.*;\\nimport java.util.*;\\n\\n\\/\\/ @author : Dinosparton \\n\\npublic class test {\\n\\t \\n\\t static class Pair{ \\n\\t\\t long x;\\n\\t\\t long y;\\n\\t\\t \\n\\t\\t Pair(long x,long y){ \\n\\t\\t\\t this.x = x;\\n\\t\\t\\t this.y = y;\\n\\t\\t\\t \\n\\t\\t }\\n\\t }\\n\\t static class Duo{\\n\\t\\t int x;\\n\\t\\t String s;\\n\\t\\t \\n\\t\\t Duo(int x,String s){\\n\\t\\t\\t this.x = x;\\n\\t\\t\\t this.s = s;\\n\\t\\t }\\n\\t }\\n\\t \\n\\t static class Sort implements Comparator\\n\\t {\\n\\n\\t @Override\\n\\t public int compare(Pair a, Pair b)\\n\\t {\\n\\t if(a.x!=b.x)\\n\\t {\\n\\t return (int)(a.x - b.x);\\n\\t }\\n\\t else\\n\\t {\\n\\t return (int)(a.y-b.y);\\n\\t }\\n\\t }\\n\\t }\\n\\t \\n\\t static class Compare { \\n\\t\\t \\n\\t\\t void compare(Pair arr[], int n) \\n\\t\\t { \\n\\t\\t \\/\\/ Comparator to sort the pair according to second element \\n\\t\\t Arrays.sort(arr, new Comparator() { \\n\\t\\t @Override public int compare(Pair p1, Pair p2) \\n\\t\\t { \\n\\t\\t \\tif(p1.x!=p2.x) {\\n\\t\\t return (int)(p1.x - p2.x); \\n\\t\\t \\t}\\n\\t\\t \\telse { \\n\\t\\t \\t\\treturn (int)(p1.y - p2.y);\\n\\t\\t \\t}\\n\\t\\t } \\n\\t\\t }); \\n\\t\\t \\n\\/\\/\\t\\t for (int i = 0; i < n; i++) { \\n\\/\\/\\t\\t System.out.print(arr[i].x + \\\" \\\" + arr[i].y + \\\" \\\"); \\n\\/\\/\\t\\t } \\n\\/\\/\\t\\t System.out.println(); \\n\\t\\t } \\n\\t\\t} \\n\\t \\n\\t static class Scanner {\\n\\t BufferedReader br;\\n\\t StringTokenizer st;\\n\\t \\n\\t public Scanner()\\n\\t {\\n\\t br = new BufferedReader(\\n\\t new InputStreamReader(System.in));\\n\\t }\\n\\t \\n\\t String next()\\n\\t {\\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 \\n\\t int nextInt() { return Integer.parseInt(next()); }\\n\\t \\n\\t...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Divide Cake into Five\\n\\nSegtree is a quintuplet tutor. Today is Christmas Eve, so I'm trying to divide the round cake into five equal parts for the quintuplets.\\n\\nThe cake is divided into $ N $ pieces from the center in a fan shape, $ i $ th and $ i + 1 $ th ($ 1 \\\\ leq i \\\\ leq N -1 $), $ N $ th and $ 1 $ The second piece is next to each other.\\n\\nThe size of the $ i $ th piece is $ A_i $. If the sum of the sizes of all the pieces is $ S $, then $ S $ is guaranteed to be a multiple of $ 5 $ for all inputs.\\n\\nGiven a non-negative integer $ Y $. How to divide a cake into quintuplets that meet the following conditions is called \\\"cake quintet\\\".\\n\\n* Everyone takes one or more pieces.\\n* The pieces each take in the cake are connected. In other words, when the pieces are grouped by the taker, there is no set of pieces in the same group that cannot be reached repeatedly by moving to the same group and adjacent pieces.\\n* There is no piece that no one takes.\\n* For everyone, if the size of the piece to be taken is $ X $, it always satisfies $ X + Y \\\\ geq S \\/ 5 $.\\n\\n\\n\\nFind out how many different ways to divide the cake so that it becomes \\\"five equal parts of the cake\\\".\\n\\ninput\\n\\nInput is given from standard input in the following format.\\n\\n\\n$ N $ $ Y $\\n$ A_1 $ $ A_2 $ $ \\\\ ldots $ $ A_N $\\n\\n\\noutput\\n\\nPlease output the number according to how to divide the cake so that it becomes \\\"five equal parts of the cake\\\".\\n\\nHowever, insert a line break at the end.\\n\\nConstraint\\n\\n* $ 5 \\\\ leq N \\\\ leq 300 $\\n* $ 1 \\\\ leq A_i \\\\ leq 10 ^ 9 $\\n* $ 0 \\\\ leq Y \\\\ leq 10 ^ 9 $\\n* All inputs are integers.\\n\\n\\n\\nInput example 1\\n\\n\\n5 0\\n1 1 1 1 1\\n\\n\\nOutput example 1\\n\\n\\n1\\n\\n\\nInput example 2\\n\\n\\n10 27\\n3 1 4 1 5 9 2 6 5 4\\n\\n\\nOutput example 2\\n\\n\\n252\\n\\n\\n\\n\\n\\n\\nExample\\n\\nInput\\n\\n5 0\\n1 1 1 1 1\\n\\n\\nOutput\\n\\n1\",\"targets\":\"#include \\n#define rep(i,n)for(int i=0;i<(n);i++)\\nusing namespace std;\\ntypedef long long ll;\\ntypedef pairP;\\n\\nconst int INF=0x3f3f3f3f;\\nconst ll INFL=0x3f3f3f3f3f3f3f3f;\\nconst int MOD=1000000007;\\n\\nll sum[320];\\nll dp[320][5][320];\\n\\nint main(){\\n\\tint n,y;cin>>n>>y;\\n\\tdequea;\\n\\tll S=0;\\n\\trep(i,n){\\n\\t\\tint b;scanf(\\\"%d\\\",&b);\\n\\t\\ta.push_back(b);\\n\\t\\tS+=b;\\n\\t}\\n\\tll ans=0;\\n\\trep(i,n){\\n\\t\\tmemset(dp,0,sizeof(dp));\\n\\t\\tmemset(sum,0,sizeof(sum));\\n\\t\\trep(j,a.size()){\\n\\t\\t\\tsum[j+1]=sum[j]+a[j];\\n\\t\\t}\\n\\t\\tdp[0][0][0]=1;\\n\\t\\trep(j,a.size())rep(k,5)rep(t,j+1){\\n\\t\\t\\tif(dp[j][k][t]==0)continue;\\n\\t\\t\\tll s=sum[j+1]-sum[t];\\n\\t\\t\\tif((s+y)*5>=S&&k<4){\\n\\t\\t\\t\\tdp[j+1][k+1][j+1]+=dp[j][k][t];\\n\\t\\t\\t}\\n\\t\\t\\tdp[j+1][k][t]+=dp[j][k][t];\\n\\t\\t}\\n\\t\\tll T=0;\\n\\t\\trep(t,a.size()){\\n\\t\\t\\tll s=sum[a.size()]-sum[t];\\n\\t\\t\\tif((s+y)*5>=S)(T+=dp[a.size()][4][t]);\\n\\t\\t}\\n\\t\\t\\/\\/~ cerr<\\nusing namespace std;\\ntemplate \\nlong long binpow(T a, T n) {\\n long long ans = 1;\\n while (n > 0) {\\n if (n & 1) ans *= a;\\n a *= a;\\n n >>= 1;\\n }\\n return ans;\\n}\\ntemplate \\nT gcd(const T &a, const T &b) {}\\ntemplate \\nT lcm(const T &a, const T &b) {}\\nvoid fileio(std::string a) {\\n freopen((a + \\\".in\\\").c_str(), \\\"r\\\", stdin);\\n freopen((a + \\\".out\\\").c_str(), \\\"w\\\", stdout);\\n}\\nint gcd(int a, int b) {\\n while (b != 0) swap(b, a %= b);\\n return a;\\n}\\nint lcm(int a, int b) { return a \\/ gcd(a, b) * b; }\\nvoid solve() {\\n int n;\\n cin >> n;\\n cout << 2 << \\\" \\\" << n - 1 << endl;\\n}\\nint32_t main() {\\n ios::sync_with_stdio();\\n cin.tie(NULL);\\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\":\"CPP solution for \\\"A tree is a connected undirected graph with n - 1 edges, where n denotes the number of vertices. Vertices are numbered 1 through n.\\n\\nLimak is a little polar bear. His bear family prepares a New Year tree every year. One year ago their tree was more awesome than usually. Thus, they decided to prepare the same tree in the next year. Limak was responsible for remembering that tree.\\n\\nIt would be hard to remember a whole tree. Limak decided to describe it in his notebook instead. He took a pen and wrote n - 1 lines, each with two integers — indices of two vertices connected by an edge.\\n\\nNow, the New Year is just around the corner and Limak is asked to reconstruct that tree. Of course, there is a problem. He was a very little bear a year ago, and he didn't know digits and the alphabet, so he just replaced each digit with a question mark — the only character he knew. That means, for any vertex index in his notes he knows only the number of digits in it. At least he knows there were no leading zeroes.\\n\\nLimak doesn't want to disappoint everyone. Please, take his notes and reconstruct a New Year tree. Find any tree matching Limak's records and print its edges in any order. It's also possible that Limak made a mistake and there is no suitable tree – in this case print \\\"-1\\\" (without the quotes).\\n\\nInput\\n\\nThe first line contains a single integer n (2 ≤ n ≤ 200 000) — the number of vertices.\\n\\nEach of the next n - 1 lines contains two space-separated non-empty strings, both consisting of questions marks only. No string has more characters than the number of digits in n.\\n\\nOutput\\n\\nIf there is no tree matching Limak's records, print the only line with \\\"-1\\\" (without the quotes).\\n\\nOtherwise, describe any tree matching Limak's notes. Print n - 1 lines, each with two space-separated integers – indices of vertices connected by an edge. You can print edges in any order.\\n\\nExamples\\n\\nInput\\n\\n12\\n? ?\\n? ?\\n? ?\\n? ??\\n?? ?\\n?? ??\\n? ??\\n? ?\\n? ?\\n? ?\\n? ?\\n\\n\\nOutput\\n\\n3 1\\n1 6\\n9 1\\n2 10\\n1 7\\n8 1\\n1 4\\n1 10\\n5 1\\n10 11\\n12 1\\n\\n\\nInput\\n\\n12\\n?? ??\\n? ?\\n? ?\\n? ??\\n??...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nconst int maxn = 15;\\ninline int gs() {\\n char c = getchar();\\n while (c != '?') c = getchar();\\n int sum = 0;\\n while (c == '?') c = getchar(), ++sum;\\n return sum;\\n}\\nint n, m, p[maxn], cnt[maxn], in[maxn], e[maxn][maxn];\\nvector > ans;\\nint check() {\\n for (int s = 1; s < (1 << m) - 1; ++s) {\\n int sum = 0;\\n for (int i = 1; i <= m; ++i)\\n for (int j = i; j <= m; ++j)\\n if (((s >> (i - 1)) & 1) || ((s >> (j - 1)) & 1)) sum += e[i][j];\\n for (int i = 1; i <= m && sum >= 0; ++i)\\n if ((s >> (i - 1)) & 1) sum -= cnt[i];\\n if (sum < 0) return 0;\\n }\\n return 1;\\n}\\nint main() {\\n scanf(\\\"%d\\\", &n);\\n m = log10(n) + 1;\\n p[1] = 1;\\n for (int i = 2; i <= m; ++i) p[i] = p[i - 1] * 10;\\n for (int x, y, i = 1; i < n; ++i)\\n x = gs(), y = gs(), ++e[x][y], e[y][x] += x != y;\\n for (int i = 1; i < m; ++i) cnt[i] = p[i + 1] - p[i];\\n cnt[m] = n - p[m] + 1;\\n if (!check()) return puts(\\\"-1\\\"), 0;\\n ++p[1];\\n in[1] = 1;\\n --cnt[1];\\n int ecnt = 0;\\n while (ecnt < n - 1) {\\n for (int i = 1; i <= m; ++i) {\\n if (!in[i]) continue;\\n for (int j = 1; j <= m; ++j) {\\n if (!cnt[j] || !e[i][j]) continue;\\n --cnt[j];\\n --e[i][j];\\n e[j][i] -= i != j;\\n if (check())\\n ans.emplace_back(p[i] - 1, p[j]), ++p[j], in[j] = 1, ++ecnt;\\n else\\n ++cnt[j], ++e[i][j], e[j][i] += i != j;\\n }\\n }\\n }\\n for (pair e : ans) printf(\\\"%d %d\\\\n\\\", e.first, e.second);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\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\":\"import java.io.*; \\/\\/PrintWriter\\nimport java.math.*; \\/\\/BigInteger, BigDecimal\\nimport java.util.*; \\/\\/StringTokenizer, ArrayList\\n\\n\\npublic class R734_Div3_C\\n{\\t\\n\\tFastReader in;\\n\\tPrintWriter out;\\n\\t\\n\\tpublic static void main(String[] args) {\\n\\t\\tnew R734_Div3_C().run();\\n\\t}\\n\\t\\n\\tvoid run()\\n\\t{\\t\\t\\n\\t\\tin = new FastReader(System.in);\\n\\t\\tout = new PrintWriter(System.out);\\n\\t\\tsolve();\\n\\t\\tout.close();\\n\\t}\\n\\t\\n\\tvoid solve()\\n\\t{\\n\\t\\tint t = in.nextInt();\\n\\t\\tfor (int T = 0; T < t; T++) {\\n\\t\\t\\tint n = in.nextInt();\\n\\t\\t\\tint k = in.nextInt();\\n\\t\\t\\t\\n\\t\\t\\tint[] a = new int[n];\\n\\t\\t\\tint[] c = new int[n];\\n\\t\\t\\tHashMap hm = new HashMap<>();\\n\\t\\t\\t\\n\\t\\t\\tint cnt = 0;\\n\\t\\t\\tArrayList u = new ArrayList<>();\\n\\t\\t\\t\\n\\t\\t\\tArrayList[] al = new ArrayList[n+1]; \\n\\t\\t\\tfor (int i=0;i<=n;i++) al[i] = new ArrayList();\\n\\t\\t\\t\\n\\t\\t\\tfor (int i = 0; i < n; i++) {\\t\\t\\t\\t\\n\\t\\t\\t\\ta[i] = in.nextInt();\\n\\t\\t\\t\\tif (hm.containsKey(a[i])) {\\n\\t\\t\\t\\t\\tcnt = hm.get(a[i]) + 1;\\t\\n\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\tcnt = 1;\\n\\t\\t\\t\\t\\tu.add(a[i]);\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\thm.put(a[i], cnt);\\n\\t\\t\\t\\tal[a[i]].add(i);\\n\\t\\t\\t}\\n\\t\\t\\t\\n\\t\\t\\tint tot = 0, empty = 0;\\n\\t\\t\\tint color = 1, placed = 0;\\n\\t\\t\\tfor (int x : u) {\\n\\t\\t\\t\\tint num = hm.get(x);\\n\\t\\t\\t\\tif (num > k) {\\n\\t\\t\\t\\t\\tempty += (num - k);\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\ttot = n - empty;\\n\\t\\t\\ttot = (tot \\/ k) * k;\\n\\t\\t\\t\\/\\/out.println(tot);\\n\\t\\t\\t\\n\\t\\t\\tfor (int x : u) {\\n\\t\\t\\t\\tint num = hm.get(x);\\n\\t\\t\\t\\tfor (int i = 0; i < num && i < k && placed < tot; i++) {\\n\\t\\t\\t\\t\\tc[al[x].get(i)] = color;\\n\\t\\t\\t\\t\\tplaced++;\\n\\t\\t\\t\\t\\tcolor++;\\n\\t\\t\\t\\t\\tif (color > k) color = 1;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\t\\n\\t\\t\\tfor (int i = 0; i < n; i++) {\\n\\t\\t\\t\\tout.print(c[i] + \\\" \\\");\\t\\t\\t\\t\\t\\n\\t\\t\\t}\\n\\t\\t\\tout.println();\\n\\t\\t}\\n\\t}\\n\\n\\t\\/\\/-----------------------------------------------------\\n\\tvoid runWithFiles() {\\n\\t\\tin = new FastReader(new File(\\\"input.txt\\\"));\\n\\t\\ttry {\\n\\t\\t\\tout = new PrintWriter(new File(\\\"output.txt\\\"));\\n\\t\\t} \\n\\t\\tcatch (FileNotFoundException e) {\\n\\t\\t\\te.printStackTrace();\\n\\t\\t}\\n\\t\\tsolve();\\n\\t\\tout.close();\\n\\t}\\n\\t\\n\\tclass FastReader\\n\\t{\\n\\t BufferedReader br;\\n\\t StringTokenizer tokenizer;\\n\\t \\n\\t public FastReader(InputStream stream)\\n\\t {\\n\\t br = new BufferedReader(new...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"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;\\nconst long long maxn = 2004;\\nlong long n, m;\\nlong long a[maxn];\\nstring s;\\nlong long kq;\\nvoid btr(long long x) {\\n if (x == 11) {\\n long long c[2];\\n c[1] = 0;\\n c[0] = 0;\\n for (long long i = 1; i <= 10; i++) {\\n c[i % 2] += a[i];\\n long long m1 = (10 - i) \\/ 2, m2 = (10 - i + 1) \\/ 2;\\n if (c[0] > c[1] + m1 || c[1] > c[0] + m2) {\\n kq = min(kq, i);\\n break;\\n }\\n }\\n return;\\n } else {\\n if (s[x] != '?') {\\n a[x] = s[x] - 48;\\n btr(x + 1);\\n } else {\\n for (long long i = 0; i <= 1; i++) {\\n a[x] = i;\\n btr(x + 1);\\n }\\n }\\n }\\n}\\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 cin >> s;\\n s = \\\" \\\" + s;\\n kq = 10;\\n btr(1);\\n cout << kq << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"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\\nLet p be any permutation of length n. We define the fingerprint F(p) of p as the sorted array of sums of adjacent elements in p. More formally,\\n\\n$$$F(p)=sort([p_1+p_2,p_2+p_3,…,p_{n-1}+p_n]).$$$\\n\\nFor example, if n=4 and p=[1,4,2,3], then the fingerprint is given by F(p)=sort([1+4,4+2,2+3])=sort([5,6,5])=[5,5,6].\\n\\nYou are given a permutation p of length n. Your task is to find a different permutation p' with the same fingerprint. Two permutations p and p' are considered different if there is some index i such that p_i ≠ p'_i.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 668). Description of the test cases follows.\\n\\nThe first line of each test case contains a single integer n (2≤ n≤ 100) — the length of the permutation.\\n\\nThe second line of each test case contains n integers p_1,…,p_n (1≤ p_i≤ n). It is guaranteed that p is a permutation.\\n\\nOutput\\n\\nFor each test case, output n integers p'_1,…, p'_n — a permutation such that p'≠ p and F(p')=F(p).\\n\\nWe can prove that for every permutation satisfying the input constraints, a solution exists.\\n\\nIf there are multiple solutions, you may output any.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n2\\n1 2\\n6\\n2 1 6 5 4 3\\n5\\n2 4 3 1 5\\n\\n\\nOutput\\n\\n\\n2 1\\n1 2 5 6 3 4\\n3 1 5 2 4\\n\\nNote\\n\\nIn the first test case, F(p)=sort([1+2])=[3].\\n\\nAnd F(p')=sort([2+1])=[3].\\n\\nIn the second test case, F(p)=sort([2+1,1+6,6+5,5+4,4+3])=sort([3,7,11,9,7])=[3,7,7,9,11].\\n\\nAnd F(p')=sort([1+2,2+5,5+6,6+3,3+4])=sort([3,7,11,9,7])=[3,7,7,9,11].\\n\\nIn the third test case, F(p)=sort([2+4,4+3,3+1,1+5])=sort([6,7,4,6])=[4,6,6,7].\\n\\nAnd F(p')=sort([3+1,1+5,5+2,2+4])=sort([4,6,7,6])=[4,6,6,7].\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"import math\\nt=int(input())\\nfor w in range(t):\\n n=int(input())\\n l=[int(i) for i in input().split()]\\n print(*(reversed(l)))\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A lot of people associate Logo programming language with turtle graphics. In this case the turtle moves along the straight line and accepts commands \\\"T\\\" (\\\"turn around\\\") and \\\"F\\\" (\\\"move 1 unit forward\\\").\\n\\nYou are given a list of commands that will be given to the turtle. You have to change exactly n commands from the list (one command can be changed several times). How far from the starting point can the turtle move after it follows all the commands of the modified list?\\n\\nInput\\n\\nThe first line of input contains a string commands — the original list of commands. The string commands contains between 1 and 100 characters, inclusive, and contains only characters \\\"T\\\" and \\\"F\\\".\\n\\nThe second line contains an integer n (1 ≤ n ≤ 50) — the number of commands you have to change in the list.\\n\\nOutput\\n\\nOutput the maximum distance from the starting point to the ending point of the turtle's path. The ending point of the turtle's path is turtle's coordinate after it follows all the commands of the modified list.\\n\\nExamples\\n\\nInput\\n\\nFT\\n1\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\nFFFTFFF\\n2\\n\\n\\nOutput\\n\\n6\\n\\nNote\\n\\nIn the first example the best option is to change the second command (\\\"T\\\") to \\\"F\\\" — this way the turtle will cover a distance of 2 units.\\n\\nIn the second example you have to change two commands. One of the ways to cover maximal distance of 6 units is to change the fourth command and first or last one.\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst double PI = acos(-1);\\nconst double eps = 1e-9;\\nconst int inf = 2000000000;\\nconst long long infLL = 9000000000000000000;\\ninline bool checkBit(long long n, int i) { return n & (1LL << i); }\\ninline long long setBit(long long n, int i) {\\n return n | (1LL << i);\\n ;\\n}\\ninline long long resetBit(long long n, int i) { return n & (~(1LL << i)); }\\ninline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }\\ninline bool isLeapYear(long long year) {\\n return (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0);\\n}\\ninline void normal(long long &a) {\\n a %= (long long)1e18;\\n (a < 0) && (a += (long long)1e18);\\n}\\ninline long long modMul(long long a, long long b) {\\n a %= (long long)1e18, b %= (long long)1e18;\\n normal(a), normal(b);\\n return (a * b) % (long long)1e18;\\n}\\ninline long long modAdd(long long a, long long b) {\\n a %= (long long)1e18, b %= (long long)1e18;\\n normal(a), normal(b);\\n return (a + b) % (long long)1e18;\\n}\\ninline long long modSub(long long a, long long b) {\\n a %= (long long)1e18, b %= (long long)1e18;\\n normal(a), normal(b);\\n a -= b;\\n normal(a);\\n return a;\\n}\\ninline long long modPow(long long b, long long p) {\\n long long r = 1;\\n while (p) {\\n if (p & 1) r *= b;\\n b *= b;\\n p >>= 1;\\n }\\n return r;\\n}\\ninline long long modInverse(long long a) {\\n return modPow(a, (long long)1e18 - 2);\\n}\\ninline long long modDiv(long long a, long long b) {\\n return modMul(a, modInverse(b));\\n}\\nint dp[110][300][2][55], n, len;\\nint dx[2] = {1, -1};\\nstring s;\\nint func(int idx, int pos, int ori, int use) {\\n if (use > n) return 0;\\n if (idx == len) {\\n if (use == n) return abs(pos - 150);\\n return 0;\\n }\\n int &ret = dp[idx][pos][ori][use];\\n if (ret != -1) return ret;\\n ret = 0;\\n if (s[idx] == 'T') {\\n for (int i = use; i <= n; ++i) {\\n if ((i - use) & 1)\\n ret = max(ret, func(idx + 1, pos + dx[ori], ori, i));\\n else\\n ret = max(ret, func(idx + 1, pos, 1 - ori, i));\\n }\\n } else {\\n for (int i = use; i <= n; ++i) {\\n if ((i...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"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\",\"targets\":\"s = input().split()\\na, b = s[0], s[1]\\nprint(int(a) + int(b[::-1]))\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"E869120 found a chest which is likely to contain treasure.\\nHowever, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters.\\nHe also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`.\\n\\nOne more thing he found is a sheet of paper with the following facts written on it:\\n\\n* Condition 1: The string S contains a string T as a contiguous substring.\\n* Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1.\\n\\n\\n\\nPrint the string S.\\nIf such a string does not exist, print `UNRESTORABLE`.\\n\\nConstraints\\n\\n* 1 \\\\leq |S'|, |T| \\\\leq 50\\n* S' consists of lowercase English letters and `?`.\\n* T consists of lowercase English letters.\\n\\nInput\\n\\nInput is given from Standard Input in the following format:\\n\\n\\nS\\nT'\\n\\n\\nOutput\\n\\nPrint the string S.\\nIf such a string does not exist, print `UNRESTORABLE` instead.\\n\\nExamples\\n\\nInput\\n\\n?tc????\\ncoder\\n\\n\\nOutput\\n\\natcoder\\n\\n\\nInput\\n\\n??p??d??\\nabc\\n\\n\\nOutput\\n\\nUNRESTORABLE\\nimpor\",\"targets\":\"t java.util.Scanner;\\npublic class Main {\\n\\tpublic static void main(String[] args) throws Exception{\\n\\t\\tScanner stdIn=new Scanner(System.in);\\n\\t\\tString S=stdIn.next();\\n\\t\\tString T=stdIn.next();\\n\\t\\tchar s[]=new char[S.length()];\\n\\t\\tchar t[]=new char[T.length()];\\n\\t\\tchar u[]=new char[S.length()];\\n\\t\\tint slen=S.length(),tlen=T.length();\\n\\t\\tint z=slen,y=0,x=0,v=slen-1,fin=0;\\n\\t\\twhile(z>0){\\n\\t\\t\\ts[y]=S.charAt(z-1);\\n\\t\\t\\ty++;\\n\\t\\t\\tz--;\\n\\t\\t}z=tlen;y=0;\\n\\t\\twhile(z>0){\\n\\t\\t\\tt[y]=T.charAt(z-1);\\n\\t\\t\\ty++;\\n\\t\\t\\tz--;\\n\\t\\t}z=0;y=0;\\n\\t\\twhile(z<(slen-tlen)+1){\\n\\t\\t\\twhile(y 2n) the non-window seats are occupied:\\n\\n1-st row left non-window seat, 1-st row right non-window seat, ... , n-th row left non-window seat, n-th row right non-window seat.\\n\\nAll the passengers go to a single final destination. In the final destination, the passengers get off in the given order.\\n\\n1-st row left non-window seat, 1-st row left window seat, 1-st row right non-window seat, 1-st row right window seat, ... , n-th row left non-window seat, n-th row left window seat, n-th row right non-window seat, n-th row right window seat.\\n\\n The seating for n = 9 and m = 36.\\n\\nYou are given the values n and m. Output m numbers from 1 to m, the order in which the passengers will get off the bus.\\n\\nInput\\n\\nThe only line contains two integers, n and m (1 ≤ n ≤ 100, 1 ≤ m ≤ 4n) — the number of pairs of rows and the number of passengers.\\n\\nOutput\\n\\nPrint m distinct integers from 1 to m — the order in which the passengers will get off the bus.\\n\\nExamples\\n\\nInput\\n\\n2 7\\n\\n\\nOutput\\n\\n5 1 6 2 7 3 4\\n\\n\\nInput\\n\\n9 36\\n\\n\\nOutput\\n\\n19 1 20 2 21 3 22 4 23 5 24 6 25 7 26 8 27 9 28 10 29 11 30 12 31 13 32 14 33 15 34 16 35 17 36 18\",\"targets\":\"var n,m;\\nn_m= readline().split(' ').map(x=>+x);\\nn=n_m[0];\\nm=n_m[1];\\n\\n\\/\\/load('js\\/B. Seating On Bus.js');\\n\\nvar IN=(2*n-1)+2;\\/\\/IN=middle_seat_start;\\nvar Side=IN-1;\\/\\/Side=side_seat_end\\n\\/\\/print(IN,Side);\\nvar cnt=0;\\nfor(i=IN,j=1;;i++,j++){\\n \\n if(i<=m) {\\n print(i);\\n cnt++;\\n }\\n if(j<=m && j<=Side){\\n print(j);\\n cnt++;\\n }\\n if(cnt==m)\\n break;\\n \\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"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...\\nSolve the task 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.io.BufferedWriter;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.util.StringTokenizer;\\nimport java.io.Writer;\\nimport java.io.OutputStreamWriter;\\nimport java.io.BufferedReader;\\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 OutputWriter out = new OutputWriter(outputStream);\\n ECrazyRobot solver = new ECrazyRobot();\\n int testCount = Integer.parseInt(in.next());\\n for (int i = 1; i <= testCount; i++)\\n solver.solve(i, in, out);\\n out.close();\\n }\\n\\n static class ECrazyRobot {\\n int n;\\n int m;\\n char[][] arr;\\n int[] dx = {1, -1, 0, 0, 1, 1, -1, -1, 0};\\n int[] dy = {0, 0, 1, -1, 1, -1, 1, -1, 0};\\n boolean[][] dp;\\n boolean[][] vis;\\n\\n public void solve(int testNumber, InputReader in, OutputWriter out) {\\n n = in.nextInt();\\n m = in.nextInt();\\n arr = in.nextCharMatrix(n, m);\\n dp = new boolean[n][m];\\n vis = new boolean[n][m];\\n for (int i = 0; i < n; i++) {\\n for (int j = 0; j < m; j++) {\\n if (arr[i][j] == 'L') {\\n vis[i][j] = true;\\n for (int k = 0; k < 4; k++) {\\n int r = i + dx[k];\\n int c = j + dy[k];\\n if (!valid(r, c)) continue;\\n if (arr[r][c] == '.') go(r, c);\\n }\\n }\\n }\\n\\n }\\n\\n\\n for (int i = 0; i < n; i++) {\\n for (int j = 0; j < m; j++) {\\n\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"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...\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"import sys\\ninput = sys.stdin.readline\\n\\nfor _ in range(int(input())):\\n X, Y = map(int, input().split())\\n ans = float(\\\"inf\\\")\\n x1, y1, x2, y2 = map(int, input().split())\\n x, y = map(int, input().split())\\n ans = float(\\\"inf\\\")\\n if x1 < x and y1 < y:\\n dx, dy = x - x1, y - y1\\n if x2 + dx <= X:\\n ans = min(ans, dx)\\n if y2 + dy <= Y:\\n ans = min(ans, dy)\\n else:\\n ans = 0\\n if x2 > X - x and y1 < y:\\n dx, dy = x2 - (X - x), y - y1\\n if x1 - dx >= 0:\\n ans = min(ans, dx)\\n if y2 + dy <= Y:\\n ans = min(ans, dy)\\n else:\\n ans = 0\\n if x1 < x and y2 > Y - y:\\n dx, dy = x - x1, y2 - (Y - y)\\n if x2 + dx <= X:\\n ans = min(ans, dx)\\n if y1 - dy >= 0:\\n ans = min(ans, dy)\\n else:\\n ans = 0\\n if x2 > X - x and y2 > Y - y:\\n dx, dy = x2 - (X - x), y2 - (Y - y)\\n if x1 - dx >= 0:\\n ans = min(ans, dx)\\n if y1 - dy >= 0:\\n ans = min(ans, dy)\\n print(ans if ans < float(\\\"inf\\\") else -1)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"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}= 3:\\n cur = i\\n\\n for i in range(n):\\n b = 0\\n for j in range(5):\\n if matrix[i][j] < matrix[cur][j]:\\n b+=1\\n\\n if b >= 3:\\n print(-1)\\n return\\n\\n print(cur+1)\\n\\nt = int(input())\\n\\nfor _ in range(t):\\n solve()\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"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 \\nSolve the task in PYTHON3.\",\"targets\":\"t=int(input())\\nwhile t>0:\\n n=int(input())\\n z=int(n)\\n b=list()\\n f=input()\\n g=f.split()\\n for i in range(2*n):\\n if b.count(g[i])==0:\\n b.append(g[i])\\n n-=1\\n if n==0:\\n break\\n for j in b:\\n print(j,end=\\\" \\\")\\n t=t-1\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"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...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nlong long int mod = 998244353;\\nlong long int max(long long int a, long long int b) {\\n if (a >= b) return a;\\n return b;\\n}\\nlong long int min(long long int a, long long int b) {\\n if (a <= b) return a;\\n return b;\\n}\\nlong long int power(long long int x, long long int y, long long int p) {\\n long long int res = 1;\\n x = x % p;\\n while (y > 0) {\\n if (y & 1) res = (res * x) % p;\\n y = y >> 1;\\n x = (x * x) % p;\\n }\\n return res;\\n}\\nlong long int modInverse(long long int n, long long int p) {\\n return power(n, p - 2, p);\\n}\\nlong long int nCrModPFermat(long long int n, long long int r, long long int p) {\\n if (n < r) return 0;\\n if (r == 0) return 1;\\n long long int fac[n + 1];\\n fac[0] = 1;\\n for (long long int i = 1; i <= n; i++) fac[i] = (fac[i - 1] * i) % p;\\n return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) %\\n p;\\n}\\nbool compare(vector a, vector b) {\\n if (a[0] == b[0]) return a[1] > b[1];\\n return a[0] == b[0];\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n long long int t = 1;\\n cin >> t;\\n while (t--) {\\n long long int n;\\n cin >> n;\\n vector > arr(n);\\n set > s;\\n for (long long int i = 0; i < n; i++) {\\n long long int u, v;\\n cin >> u >> v;\\n arr[i] = {u, v};\\n s.insert({u, v});\\n }\\n for (long long int i = 0; i < n; i++) {\\n long long int l = arr[i][0];\\n long long int r = arr[i][1];\\n if (l == r) {\\n cout << l << \\\" \\\" << r << \\\" \\\" << l << \\\"\\\\n\\\";\\n continue;\\n }\\n if (s.find({l + 1, r}) != s.end()) {\\n cout << l << \\\" \\\" << r << \\\" \\\" << l << \\\"\\\\n\\\";\\n continue;\\n } else if (s.find({l, r - 1}) != s.end()) {\\n cout << l << \\\" \\\" << r << \\\" \\\" << r << \\\"\\\\n\\\";\\n continue;\\n }\\n for (long long int d = l + 1; d < r; d++) {\\n bool a = false;\\n bool b = false;\\n if (d - 1 == l)\\n a = true;\\n else {\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given a sequence a of length n consisting of 0s and 1s.\\n\\nYou can perform the following operation on this sequence: \\n\\n * Pick an index i from 1 to n-2 (inclusive). \\n * Change all of a_{i}, a_{i+1}, a_{i+2} to a_{i} ⊕ a_{i+1} ⊕ a_{i+2} simultaneously, where ⊕ denotes the [bitwise XOR operation](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#XOR)\\n\\nFind a sequence of at most n operations that changes all elements of a to 0s or report that it's impossible.\\n\\nWe can prove that if there exists a sequence of operations of any length that changes all elements of a to 0s, then there is also such a sequence of length not greater than n.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^4).\\n\\nThe first line of each test case contains a single integer n (3 ≤ n ≤ 2⋅10^5) — the length of a.\\n\\nThe second line of each test case contains n integers a_1, a_2, …, a_n (a_i = 0 or a_i = 1) — elements of 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, do the following: \\n\\n * if there is no way of making all the elements of a equal to 0 after performing the above operation some number of times, print \\\"NO\\\". \\n * otherwise, in the first line print \\\"YES\\\", in the second line print k (0 ≤ k ≤ n) — the number of operations that you want to perform on a, and in the third line print a sequence b_1, b_2, ..., b_k (1 ≤ b_i ≤ n - 2) — the indices on which the operation should be applied. \\n\\n\\n\\nIf there are multiple solutions, you may print any.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n3\\n0 0 0\\n5\\n1 1 1 1 0\\n4\\n1 0 0 1\\n\\n\\nOutput\\n\\n\\nYES\\n0\\nYES\\n2\\n3 1\\nNO\\n\\nNote\\n\\nIn the first example, the sequence contains only 0s so we don't need to change anything.\\n\\nIn the second example, we can transform [1, 1, 1, 1, 0] to [1, 1, 0, 0, 0] and then to [0, 0, 0, 0, 0] by performing the operation on the third element of a and then on the first element of a.\\n\\nIn the third example, no matter whether we first perform the operation on the first or on the second element...\\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 m) {\\n if (y == 0) return 1;\\n long long int p = power(x, y \\/ 2, m) % m;\\n p = (p * p) % m;\\n return (y % 2 == 0) ? p : (x * p) % m;\\n}\\nvector Fac(1, 1), Mod_Inv(1, 1);\\nint Last_Index = 0;\\nlong long int nCr(long long int n, long long int r, long long int m) {\\n if (n < 0 || r < 0) return 0;\\n if (r > n) return 0;\\n if (n > Last_Index) {\\n for (long long int i = Last_Index + 1; i <= n; ++i) {\\n Fac.push_back(Fac[i - 1] * i);\\n Fac[i] %= m;\\n Mod_Inv.push_back(power(Fac[i], m - 2, m));\\n }\\n Last_Index = n;\\n }\\n return (((Fac[n] * Mod_Inv[r]) % m) * Mod_Inv[n - r]) % m;\\n}\\nlong long int gcd(long long int a, long long int b) {\\n return (b ? gcd(b, a % b) : a);\\n}\\nint Google_Test;\\nvoid solve() {\\n long long int n;\\n cin >> n;\\n vector v(n);\\n for (long long int i = 0; i < n; ++i) cin >> v[i];\\n long long int cnt = 0;\\n vector cntl(n);\\n cnt = 0;\\n for (long long int i = 0; i < n; ++i) {\\n if (v[i]) ++cnt;\\n cntl[i] = cnt;\\n }\\n vector ans;\\n {\\n queue q;\\n long long int z = 0;\\n for (long long int i = 0; i < n; ++i) {\\n if (v[i] == 1)\\n q.push(i);\\n else\\n z++;\\n }\\n while (!q.empty()) {\\n long long int index = q.front();\\n q.pop();\\n if (index - 2 >= 0 && v[index - 2] == 0 && v[index - 1] == 0 && z > 2 &&\\n cntl[index - 2] % 2) {\\n ans.push_back(index - 2);\\n v[index - 1] = 1;\\n v[index - 2] = 1;\\n z -= 2;\\n q.push(index - 1);\\n q.push(index - 2);\\n }\\n if (index + 2 < n && v[index + 2] == 0 && v[index + 1] == 0 && z > 2 &&\\n cntl[index] % 2) {\\n ans.push_back(index);\\n v[index + 1] = 1;\\n v[index + 2] = 1;\\n z -= 2;\\n q.push(index + 1);\\n q.push(index + 2);\\n }\\n }\\n }\\n queue q;\\n for (long long int i = 0; i < n; ++i) {\\n if (v[i] == 0)...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"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.\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\n\\npublic class ArrayDifferentiation implements Runnable {\\n\\n void solve() {\\n int t = ri();\\n outer: while (t-- > 0) {\\n int n = ri();\\n int[] arr = iArr(n);\\n for (int i = 0; i < n; i++) {\\n arr[i] = ri();\\n }\\n\\n\\/\\/ if (n == 1 && ) {\\n\\/\\/ println(\\\"YES\\\");\\n\\/\\/ continue;\\n\\/\\/ }\\n int sum = 0;\\n Set set = new HashSet();\\n for (int i = 0; i < (1 << n); i++) {\\n \\/\\/ Go through all the subsets possible\\n sum = 0;\\n for (int j = 0; j < n; j++) {\\n if ((i & (1 << j)) != 0) {\\n sum += arr[j];\\n }\\n }\\n if (set.contains(sum)) {\\n \\/\\/ It is possible to make sequence\\n println(\\\"YES\\\");\\n continue outer;\\n }\\n set.add(sum);\\n }\\n println(\\\"NO\\\");\\n }\\n }\\n\\n \\/************************************************************************************************************************************************\\/\\n public static void main(String[] args) throws IOException {\\n new Thread(null, new ArrayDifferentiation(), \\\"1\\\").start();\\n }\\n\\n static PrintWriter out = new PrintWriter(System.out);\\n static Reader read = new Reader();\\n static StringBuilder sbr = new StringBuilder();\\n static int mod = (int) 1e9 + 7;\\n static int dmax = Integer.MAX_VALUE;\\n static long lmax = Long.MAX_VALUE;\\n static int dmin = Integer.MIN_VALUE;\\n static long lmin = Long.MIN_VALUE;\\n static int[] dprimes = new int[] { 1, 11, 101, 1087, 99991, 100001, 1000003, 15485863, 999999937 };\\n\\n @Override\\n public void run() {\\n solve();\\n out.close();\\n }\\n\\n static class Reader {\\n private byte[] buf = new byte[1024];\\n private int index;\\n private InputStream in;\\n private int total;\\n\\n public Reader() {\\n in = System.in;\\n }\\n\\n public int scan() throws IOException {\\n if (total <...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"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\":\"\\/*Everything is Hard \\n * Before Easy \\n * Jai Mata Dii \\n *\\/ \\n \\nimport java.util.*;\\nimport java.io.*; \\n \\npublic class Main {\\n\\tstatic class FastReader{ BufferedReader br;StringTokenizer st;public FastReader(){br = new BufferedReader(new InputStreamReader(System.in));}String next(){while (st == null || !st.hasMoreElements()){try{st = new StringTokenizer(br.readLine());}catch (IOException e){e.printStackTrace();}}return st.nextToken();}int nextInt(){ return Integer.parseInt(next());}long nextLong(){return Long.parseLong(next());}double nextDouble(){return Double.parseDouble(next());}String nextLine(){String str = \\\"\\\"; try{str = br.readLine(); } catch (IOException e) {e.printStackTrace();} return str; }} \\n\\tstatic long mod = (long)(1e9+7); \\n\\t\\/\\/ static long mod = 998244353; \\n\\/\\/\\t static Scanner sc = new Scanner(System.in); \\n\\tstatic FastReader sc = new FastReader(); \\n\\tstatic PrintWriter out = new PrintWriter(System.out);\\n\\tpublic static void main (String[] args) { \\n\\t\\tint ttt = 1;\\n\\t\\tttt = sc.nextInt();\\n\\t\\tz :for(int tc=1;tc<=ttt;tc++){\\n\\t\\t\\tlong a = sc.nextLong();\\n\\t\\t\\tlong b = sc.nextLong();\\n\\t\\t\\tlong c = sc.nextLong();\\n\\t\\t\\tif(a>b) {\\n\\t\\t\\t\\tlong temp = a;\\n\\t\\t\\t\\ta = b;\\n\\t\\t\\t\\tb = temp;\\n\\t\\t\\t}\\n\\/\\/\\t\\t\\tif(a0){if(b%2 == 0){a = (a*a)%mod;b \\/= 2;}else{ret = (ret*a)%mod;b--;}}return ret%mod;}\\n\\tstatic long gcd(long a,long b){if(b==0) return a; return gcd(b,a%b); } \\n\\tprivate static void...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A new delivery of clothing has arrived today to the clothing store. This delivery consists of a ties, b scarves, c vests and d jackets.\\n\\nThe store does not sell single clothing items — instead, it sells suits of two types:\\n\\n * a suit of the first type consists of one tie and one jacket; \\n * a suit of the second type consists of one scarf, one vest and one jacket. \\n\\n\\n\\nEach suit of the first type costs e coins, and each suit of the second type costs f coins.\\n\\nCalculate the maximum possible cost of a set of suits that can be composed from the delivered clothing items. Note that one item cannot be used in more than one suit (though some items may be left unused).\\n\\nInput\\n\\nThe first line contains one integer a (1 ≤ a ≤ 100 000) — the number of ties.\\n\\nThe second line contains one integer b (1 ≤ b ≤ 100 000) — the number of scarves.\\n\\nThe third line contains one integer c (1 ≤ c ≤ 100 000) — the number of vests.\\n\\nThe fourth line contains one integer d (1 ≤ d ≤ 100 000) — the number of jackets.\\n\\nThe fifth line contains one integer e (1 ≤ e ≤ 1 000) — the cost of one suit of the first type.\\n\\nThe sixth line contains one integer f (1 ≤ f ≤ 1 000) — the cost of one suit of the second type.\\n\\nOutput\\n\\nPrint one integer — the maximum total cost of some set of suits that can be composed from the delivered items. \\n\\nExamples\\n\\nInput\\n\\n\\n4\\n5\\n6\\n3\\n1\\n2\\n\\n\\nOutput\\n\\n\\n6\\n\\n\\nInput\\n\\n\\n12\\n11\\n13\\n20\\n4\\n6\\n\\n\\nOutput\\n\\n\\n102\\n\\n\\nInput\\n\\n\\n17\\n14\\n5\\n21\\n15\\n17\\n\\n\\nOutput\\n\\n\\n325\\n\\nNote\\n\\nIt is possible to compose three suits of the second type in the first example, and their total cost will be 6. Since all jackets will be used, it's impossible to add anything to this set.\\n\\nThe best course of action in the second example is to compose nine suits of the first type and eleven suits of the second type. The total cost is 9 ⋅ 4 + 11 ⋅ 6 = 102.\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"ties, scarves, vests, jackets, first_cost ,second_cost = [int(input()) for _ in range(6)]\\n\\nif second_cost > first_cost:\\n second = min(scarves,vests, jackets)\\n first = min(jackets-second, ties)\\nelse:\\n first = min(jackets, ties)\\n second = min(scarves,vests, jackets-first)\\n\\nout = first * first_cost + second * second_cost\\n\\nprint(out)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Dima came to the horse land. There are n horses living in the land. Each horse in the horse land has several enemies (enmity is a symmetric relationship). The horse land isn't very hostile, so the number of enemies of each horse is at most 3.\\n\\nRight now the horse land is going through an election campaign. So the horses trusted Dima to split them into two parts. At that the horses want the following condition to hold: a horse shouldn't have more than one enemy in its party.\\n\\nHelp Dima split the horses into parties. Note that one of the parties can turn out to be empty.\\n\\nInput\\n\\nThe first line contains two integers n, m — the number of horses in the horse land and the number of enemy pairs.\\n\\nNext m lines define the enemy pairs. The i-th line contains integers ai, bi (1 ≤ ai, bi ≤ n; ai ≠ bi), which mean that horse ai is the enemy of horse bi.\\n\\nConsider the horses indexed in some way from 1 to n. It is guaranteed that each horse has at most three enemies. No pair of enemies occurs more than once in the input.\\n\\nOutput\\n\\nPrint a line, consisting of n characters: the i-th character of the line must equal \\\"0\\\", if the horse number i needs to go to the first party, otherwise this character should equal \\\"1\\\".\\n\\nIf there isn't a way to divide the horses as required, print -1.\\n\\nExamples\\n\\nInput\\n\\n3 3\\n1 2\\n3 2\\n3 1\\n\\n\\nOutput\\n\\n100\\n\\n\\nInput\\n\\n2 1\\n2 1\\n\\n\\nOutput\\n\\n00\\n\\n\\nInput\\n\\n10 6\\n1 2\\n1 3\\n1 4\\n2 3\\n2 4\\n3 4\\n\\n\\nOutput\\n\\n0110000000\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nconst int maxi = 1000 * 100 * 3 + 100;\\nbool mark[maxi];\\nvector dosh[maxi];\\nint main() {\\n int n, m;\\n cin >> n >> m;\\n for (int i = 1; i <= m; i++) {\\n int k, p;\\n cin >> k >> p;\\n dosh[k].push_back(p);\\n dosh[p].push_back(k);\\n }\\n for (int q = 1; q <= 10; q++)\\n for (int i = 1; i <= n; i++) {\\n int p = dosh[i].size();\\n for (int j = 0; j < dosh[i].size(); j++) p -= mark[dosh[i][j]];\\n if (p > 1)\\n mark[i] = 1;\\n else\\n mark[i] = 0;\\n }\\n for (int i = 1; i <= n; i++) cout << mark[i];\\n cout << endl;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"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\":\"#include \\n#pragma GCC optimize(2, 3, \\\"Ofast\\\")\\nusing namespace std;\\nconst long long INF = 1e18 + 100;\\nconst long long NINF = -INF;\\nconst int inf = 1e8;\\nconst int MOD = 998244353;\\nconst int mod = 1000000007;\\nconst int ninf = -mod;\\nlong long mul(long long a, long long b) {\\n return ((a % mod) * (b % mod)) % mod;\\n}\\nlong long tri(long long a, long long b, long long c) {\\n return mul(mul(a, b), c);\\n}\\nlong long binPow(long long a, long long b, long long mod) {\\n if (b == 0) return 1;\\n long long ans = binPow(a, b \\/ 2, mod);\\n if (b & 1) {\\n return tri(ans, ans, a);\\n }\\n return mul(ans, ans);\\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}\\ntemplate \\nvoid ckmin(T1 &a, T2 b) {\\n if (a > b) a = b;\\n}\\ntemplate \\nvoid ckmax(T1 &a, T2 b) {\\n if (a < b) a = b;\\n}\\nvoid solve() {\\n int n, a, b, i, j, f = 1, t = 1;\\n cin >> n >> a >> b;\\n if (a + b + 2 > n || abs(a - b) > 1) {\\n cout << -1 << \\\"\\\\n\\\";\\n return;\\n }\\n if (a == b) {\\n t = 0;\\n if (a == 0)...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Example\\n\\nInput\\n\\n201\\n\\n\\nOutput\\n\\n701\",\"targets\":\"#include \\n#include \\n#include \\n#include \\n#include \\nusing namespace std;\\nusing ll = long long;\\n\\nint main() {\\n string s;\\n cin >> s;\\n ll old = 0;\\n ll tenN = 1;\\n for(int i=0; i v={0, 1, 2, 3, 4, 5, 6, 7, 8, 9};\\n ll res = 0, memo = 0;\\n do {\\n ll t = 0;\\n for(int i=0; i 0:\\n if digs[d_place] >= 1:\\n digs[d_place] -= 1\\n digs[d_place-1] += 10\\n c_required -=9\\n if d_place>1:\\n d_place -=1\\n else:\\n d_place += 1\\n #print(digs)\\n place = 0 \\n ans = []\\n cur_total = 0\\n while len(ans)< n-1:\\n if digs[place]>0:\\n ans.append(10**place)\\n digs[place]-=1\\n cur_total+=10**place\\n else:\\n place +=1\\n ans.append(s-cur_total)\\n print(*ans)\\nq=nn()\\nfor _ in range(q):\\n solve()\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"An array of integers p_1, p_2, ..., p_n is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3, 1, 2], [1], [1, 2, 3, 4, 5] and [4, 3, 1, 2]. The following arrays are not permutations: [2], [1, 1], [2, 3, 4].\\n\\nPolycarp invented a really cool permutation p_1, p_2, ..., p_n of length n. It is very disappointing, but he forgot this permutation. He only remembers the array q_1, q_2, ..., q_{n-1} of length n-1, where q_i=p_{i+1}-p_i.\\n\\nGiven n and q=q_1, q_2, ..., q_{n-1}, help Polycarp restore the invented permutation.\\n\\nInput\\n\\nThe first line contains the integer n (2 ≤ n ≤ 2⋅10^5) — the length of the permutation to restore. The second line contains n-1 integers q_1, q_2, ..., q_{n-1} (-n < q_i < n).\\n\\nOutput\\n\\nPrint the integer -1 if there is no such permutation of length n which corresponds to the given array q. Otherwise, if it exists, print p_1, p_2, ..., p_n. Print any such permutation if there are many of them.\\n\\nExamples\\n\\nInput\\n\\n\\n3\\n-2 1\\n\\n\\nOutput\\n\\n\\n3 1 2 \\n\\nInput\\n\\n\\n5\\n1 1 1 1\\n\\n\\nOutput\\n\\n\\n1 2 3 4 5 \\n\\nInput\\n\\n\\n4\\n-1 2 2\\n\\n\\nOutput\\n\\n\\n-1\\nUsing python3 can you solve the prior task?\",\"targets\":\"n = int(input())\\nq = list(map(int, input().split()))\\n\\n_min = 0\\na = [0] * n\\nfor i in range(n-1):\\n a[i+1] = a[i] + q[i]\\n if a[i+1] < _min:\\n _min = a[i+1]\\n\\ndif = 1 - _min\\nfor i in range(n):\\n a[i] += dif\\n\\nb = list(map(str, a))\\nfor i in range(n):\\n while i + 1 != a[i]:\\n if not 0 <= a[i] - 1 < len(a):\\n print(-1)\\n exit()\\n if a[a[i] - 1] == a[i]:\\n print(-1)\\n exit()\\n a[a[i] - 1], a[i] = a[i], a[a[i] - 1]\\n\\nprint(' '.join(b))\",\"language\":\"python\",\"split\":\"train\",\"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 < … \\nusing namespace std;\\nint xm[4] = {-1, 1, 0, 0};\\nint ym[4] = {0, 0, -1, 1};\\nconst int MOD = 1e9 + 7;\\nconst int MAXN = 5e5 + 5;\\nconst long long POW = 9973;\\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;\\n cin >> n;\\n for (int i = 0; i < n; i++) cout << i + 2 << \\\" \\\";\\n cout << \\\"\\\\n\\\";\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"After you had helped George and Alex to move in the dorm, they went to help their friend Fedor play a new computer game «Call of Soldiers 3».\\n\\nThe game has (m + 1) players and n types of soldiers in total. Players «Call of Soldiers 3» are numbered form 1 to (m + 1). Types of soldiers are numbered from 0 to n - 1. Each player has an army. Army of the i-th player can be described by non-negative integer xi. Consider binary representation of xi: if the j-th bit of number xi equal to one, then the army of the i-th player has soldiers of the j-th type. \\n\\nFedor is the (m + 1)-th player of the game. He assume that two players can become friends if their armies differ in at most k types of soldiers (in other words, binary representations of the corresponding numbers differ in at most k bits). Help Fedor and count how many players can become his friends.\\n\\nInput\\n\\nThe first line contains three integers n, m, k (1 ≤ k ≤ n ≤ 20; 1 ≤ m ≤ 1000).\\n\\nThe i-th of the next (m + 1) lines contains a single integer xi (1 ≤ xi ≤ 2n - 1), that describes the i-th player's army. We remind you that Fedor is the (m + 1)-th player.\\n\\nOutput\\n\\nPrint a single integer — the number of Fedor's potential friends.\\n\\nExamples\\n\\nInput\\n\\n7 3 1\\n8\\n5\\n111\\n17\\n\\n\\nOutput\\n\\n0\\n\\n\\nInput\\n\\n3 3 3\\n1\\n2\\n3\\n4\\n\\n\\nOutput\\n\\n3\",\"targets\":\"n, m, k = map(int, raw_input().split())\\nt = 0\\na = []\\nfor _ in range(m+1):\\n\\ta.append(int(raw_input()))\\n\\nfor i in range(m):\\n\\n\\tt += 1 if '{0:b}'.format(a[-1]^a[i]).count('1') <= k else 0\\n\\nprint t\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in PYTHON3?\\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\":\"from sys import stdin, stdout\\nimport math\\nfrom itertools import permutations, combinations\\nfrom collections import defaultdict\\nfrom collections import Counter\\nfrom bisect import bisect_left\\nimport sys\\nfrom queue import PriorityQueue\\nimport operator as op\\nfrom functools import reduce\\nimport re\\n# ======================================================================================\\nmod = 1000000007\\niinp = lambda: int(sys.stdin.readline())\\ninp = lambda: sys.stdin.readline().strip()\\nstrl = lambda: list(inp().strip().split(\\\" \\\"))\\nintl = lambda: list(map(int, inp().split(\\\" \\\")))\\nmint = lambda: map(int, inp().split())\\nflol = lambda: list(map(float, inp().split(\\\" \\\")))\\nflush = lambda: sys.stdout.flush()\\n# ==========================================================================================\\n\\n\\n\\ndef myCode():\\n n = iinp()\\n s = input()\\n ans = 0\\n for i in [\\\"1\\\",\\\"4\\\",\\\"6\\\",\\\"8\\\",\\\"9\\\"]:\\n if i in s:\\n ans = int(i)\\n if ans:\\n print(1)\\n print(ans)\\n return\\n arr = [\\\"23\\\",\\\"53\\\",\\\"37\\\",\\\"73\\\"]\\n for i in range(len(s)):\\n for j in range(i+1,len(s)):\\n if s[i]+s[j] not in arr:\\n ans = int(s[i]+s[j])\\n break\\n\\n print(2)\\n print(ans)\\n return\\n\\n\\n\\n\\ndef main():\\n for t in range(iinp()):\\n myCode()\\n \\nif __name__ == '__main__':\\n main()\\n\\n \\n\\n\\n\\n\\n# cook your dish here\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"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.\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nusing ll = long long;\\nusing pi = pair;\\nusing vi = vector;\\nusing ld = long double;\\nconst int MAXN = (int)2e6 + 239;\\nconst int MOD = (int)998244353;\\nvoid solve() {\\n int n;\\n cin >> n;\\n if (n == 1)\\n cout << 'a';\\n else if (n % 2 == 0) {\\n for (int i = 0; i < (n - 1) \\/ 2; i++) cout << 'a';\\n cout << 'b';\\n for (int i = 0; i < (n - 1) \\/ 2 + 1; i++) cout << 'a';\\n } else {\\n for (int i = 0; i < (n - 2) \\/ 2; i++) cout << 'a';\\n cout << \\\"bc\\\";\\n for (int i = 0; i < (n - 2) \\/ 2 + 1; i++) cout << 'a';\\n }\\n cout << endl;\\n}\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n int t;\\n cin >> t;\\n while (t--) solve();\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"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\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nusing ll = long long;\\nusing pii = pair;\\nconst double EPS = 1e-9;\\nconst long long INF = 1e18;\\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}\\ntemplate \\nvoid debug_out(string s, T t) {\\n cout << \\\"[\\\" << s << \\\": \\\" << t << \\\"]\\\\n\\\";\\n}\\ntemplate \\nvoid debug_out(string s, T t, U... u) {\\n long long w = 0, c = 0;\\n while (w < (long long)s.size()) {\\n if (s[w] == '(') c++;\\n if (s[w] == ')') c--;\\n if (!c and s[w] == ',') break;\\n w++;\\n }\\n cout << \\\"[\\\" << s.substr(0, w) << \\\": \\\" << t << \\\"] \\\";\\n debug_out(s.substr(w + 2, (long long)s.size() - w - 1), u...);\\n}\\nconst long long N = 1e6 + 5;\\nvector idx[105];\\nint32_t main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n long long n, k;\\n cin >> n >> k;\\n vector c(n * k + 1), prev(n * k + 1), done(n + 1);\\n vector ans(n + 1);\\n for (long long i = 1; i <= n * k; i++) cin >> c[i], idx[c[i]].push_back(i);\\n bool flg = 1;\\n while (true) {\\n bool found = 0;\\n for (long long &x : prev) x = 0;\\n for (long long i = 1; i <= n * k; i++) {\\n if (!done[c[i]]) {\\n if (prev[c[i]] > 0) {\\n done[c[i]] = 1, ans[c[i]].first = prev[c[i]], ans[c[i]].second = i,\\n found = 1;\\n for (long long &x : prev) x = 0;\\n } else\\n prev[c[i]] = i;\\n }\\n }\\n if (!found) break;\\n }\\n for (long long i = 1; i <= n; i++)\\n cout << ans[i].first << \\\" \\\" << ans[i].second << \\\"\\\\n\\\";\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"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...\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 15;\\nconst long long mod = 1e9 + 7;\\nint n;\\nint a[N], g[1 << N | 1], f[1 << N | 1];\\nint inv[N][N];\\nint Pop(int x) {\\n int c = 0;\\n while (x) c++, x -= x & -x;\\n return c;\\n}\\nint ksm(int a, int p) {\\n int ans = 1;\\n for (; p; p >>= 1, a = 1ll * a * a % mod)\\n if (p & 1) ans = 1ll * ans * a % mod;\\n return ans;\\n}\\nint main() {\\n scanf(\\\"%d\\\", &n);\\n for (int i = 1; i <= n; i++) scanf(\\\"%d\\\", a + i);\\n for (int i = 1; i <= n; i++)\\n for (int j = 1; j <= n; j++) inv[i][j] = ksm(a[i] + a[j], mod - 2);\\n for (int sta = 1; sta < 1 << n; sta++) {\\n g[sta] = 1;\\n for (int i = 1; i <= n; i++) {\\n if (!(sta & (1 << (i - 1)))) continue;\\n for (int j = 1; j <= n; j++) {\\n if ((sta & (1 << (j - 1)))) continue;\\n g[sta] = 1ll * g[sta] * a[i] % mod * inv[i][j] % mod;\\n }\\n }\\n }\\n for (int S = 1; S < 1 << n; S++) {\\n f[S] = mod - g[S];\\n for (int T = S; T; T = (T - 1) & S) {\\n int iv = 1;\\n for (int i = 1; i <= n; i++) {\\n if (!(S & (1 << i - 1) && !(T & (1 << i - 1)))) continue;\\n for (int j = 1; j <= n; j++) {\\n if (!(T & (1 << j - 1))) continue;\\n iv = 1ll * a[i] * inv[i][j] % mod * iv % mod;\\n }\\n }\\n f[S] = (f[S] + 1ll * f[T] * g[S ^ T] % mod * ksm(iv, mod - 2)) % mod;\\n }\\n f[S] = mod - f[S];\\n }\\n int ans = 0;\\n for (int S = 1; S < 1 << n; S++) ans = (ans + 1ll * Pop(S) * f[S]) % mod;\\n printf(\\\"%d\\\\n\\\", ans);\\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?\\nDr. Sato, a botanist, invented a number of special fertilizers for seedlings. When you give the fertilizer to the seedlings, the size of the seedlings changes in a blink of an eye. However, it was found that fertilizer has the following side effects.\\n\\n* The size of the seedlings does not change with the fertilizer given the first time.\\n* From the second time onward, the seedlings will be affected by the combination of the fertilizer given at that time and the fertilizer given immediately before. Saplings may grow if they have a positive effect, and shrink if they have a negative effect.\\n\\n\\n\\nAs a test, Dr. Sato said that for three types of fertilizers (fertilizers 1, 2, and 3), seedling growth was achieved by combining the fertilizer given at a certain point (this fertilizer) and the fertilizer given immediately before (previous fertilizer). We investigated the degree and created the following \\\"growth table\\\".\\n\\nThe first row of the table on the right is the number of the fertilizer given this time, and the first column is the number of the fertilizer given immediately before. Other numbers indicate the growth rate (ratio of post-growth to pre-growth size) of seedlings due to the combination of the fertilizer given immediately before and the fertilizer given this time. A growth rate of> 1.0 indicates that the sapling grows, and a growth rate of <1.0 indicates that the sapling shrinks. For example, fertilizer 1 followed by fertilizer 2 triples the size of the sapling, but fertilizer 1 followed by fertilizer 3 reduces the size of the sapling in half.\\n\\n| \\n--- | ---\\n\\n\\n\\nIf the number of fertilizers given to the seedlings is limited, which fertilizer should be given and in what order to grow the seedlings as large as possible? The \\\"Growth Table\\\" will tell you the answer. As an example, if you give the fertilizers shown in the table above only three times, the seedlings will grow the most if you give them in the order of fertilizer 3 → fertilizer 1 → fertilizer 2 as shown below.\\n\\n\\n\\n\\n* The size of the...\",\"targets\":\"#include\\n#include\\nusing namespace std;\\n\\nint main(){\\n\\tint n, m;\\n\\tdouble dp[101][101], hiryou[101][101];\\n\\twhile(cin >>n >>m){\\n\\t\\tif(n == 0 && m == 0) break;\\n\\t\\tfor(int i = 0; i < n; i++){\\n\\t\\t\\tfor(int j = 0; j < n; j++){\\n\\t\\t\\t\\tcin >>hiryou[i][j];\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\tfor(int i = 0; i < n; i++){\\n\\t\\t\\tdp[0][i] = 1.0;\\n\\t\\t}\\n\\t\\tfor(int i = 1; i < m; i++){\\n\\t\\t\\tfor(int j = 0; j < n; j++){\\n\\t\\t\\t\\tdp[i][j] = 0.0;\\n\\t\\t\\t\\tfor(int k = 0; k < n; k++){\\n\\t\\t\\t\\t\\tif(dp[i - 1][k] * hiryou[k][j] > dp[i][j]) dp[i][j] = dp[i - 1][k] * hiryou[k][j];\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\t\\/\\/for(int i = 0; i < n; i++){\\n\\t\\t\\/\\/\\tfor(int j = 0; j < m; j++){\\n\\t\\t\\/\\/\\t\\tprintf(\\\"%5.5f \\\", dp[j][i]);\\n\\t\\t\\/\\/\\t}\\n\\t\\t\\/\\/\\tcout < ans) ans = dp[m - 1][i];\\n\\t\\t}\\n\\t\\tprintf(\\\"%.2f\\\\n\\\", ans);\\n\\t}\\n\\treturn 0;\\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...\\nSolve the task in JAVA.\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\nimport static java.lang.Math.max;\\nimport static java.lang.Math.min;\\nimport static java.lang.Math.abs;\\nimport java.math.*;\\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 \\n static class Solver {\\n \\tstatic boolean check(int n,long[] a,long v,long mid) {\\n \\t\\tlong ans=0;\\n \\t\\tans+=mid;\\n \\t\\tfor(int i=1;i ans)return false;\\n \\t\\telse return true;\\n \\t}\\n \\tSolver() {\\n \\t\\tint n = s.nextInt();\\n \\t\\tlong h = s.nextLong();\\n \\t\\tlong[] a = new long[n];\\n \\t\\tfor(int i=0;i\\nusing namespace std;\\nint main() {\\n string s;\\n int p, q;\\n cin >> p >> q;\\n cin >> s;\\n int n = s.length();\\n vector > v1, v2;\\n int x = 0, y = 0;\\n for (int i = 0; i < n; i++) {\\n v1.push_back(make_pair(x, y));\\n if (x == p && y == q) {\\n cout << \\\"Yes\\\";\\n return 0;\\n }\\n if (s[i] == 'R') {\\n x++;\\n } else if (s[i] == 'L') {\\n x--;\\n } else if (s[i] == 'U') {\\n y++;\\n } else {\\n y--;\\n }\\n }\\n for (int i = 0; i < n; i++) {\\n v2.push_back(make_pair(x, y));\\n if (x == p && y == q) {\\n cout << \\\"Yes\\\";\\n return 0;\\n }\\n if (s[i] == 'R') {\\n x++;\\n } else if (s[i] == 'L') {\\n x--;\\n } else if (s[i] == 'U') {\\n y++;\\n } else {\\n y--;\\n }\\n }\\n for (int i = 0; i < n; i++) {\\n int j = v2[i].first - v1[i].first;\\n int k = v2[i].second - v1[i].second;\\n int e = p - v1[i].first;\\n int r = q - v1[i].second;\\n if (j == 0 && k == 0) {\\n if (e == 0 && r == 0) {\\n cout << \\\"Yes\\\";\\n return 0;\\n }\\n } else if (j == 0) {\\n if ((r \\/ k > 0) && (r % k == 0) && v2[i].first == p) {\\n cout << \\\"Yes\\\";\\n return 0;\\n }\\n } else if (k == 0) {\\n if ((e \\/ j > 0) && (e % j == 0) && v1[i].second == q) {\\n cout << \\\"Yes\\\";\\n return 0;\\n }\\n } else if ((e \\/ j > 0) && (e % j == 0) && (r \\/ k > 0) && (r % k == 0) &&\\n e \\/ j == r \\/ k) {\\n cout << \\\"Yes\\\";\\n return 0;\\n }\\n }\\n cout << \\\"No\\\";\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"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.\",\"targets\":\"import java.util.*;\\nimport java.lang.*;\\nimport java.io.*;\\nimport java.math.BigInteger;\\nimport java.io.BufferedReader;\\nimport java.io.BufferedWriter;\\nimport java.io.DataInputStream;\\nimport java.io.FileInputStream;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.io.OutputStreamWriter;\\nimport java.math.BigInteger;\\nimport java.util.List;\\nimport java.util.Map;\\nimport java.util.Map.Entry;\\nimport java.util.ArrayList;\\nimport java.util.Arrays;\\nimport java.util.Collections;\\nimport java.util.Comparator;\\nimport java.util.HashMap;\\nimport java.util.HashSet;\\nimport java.util.Iterator;\\npublic class h\\n{\\t\\tpublic static int mod=1000000007;\\n\\t static class Reader {\\n\\t\\t \\n\\t final private int BUFFER_SIZE = 1 << 16;\\n\\t private DataInputStream din;\\n\\t private byte[] buffer;\\n\\t private int bufferPointer, bytesRead;\\n\\t \\n\\t public Reader()\\n\\t {\\n\\t din = new DataInputStream(System.in);\\n\\t buffer = new byte[BUFFER_SIZE];\\n\\t bufferPointer = bytesRead = 0;\\n\\t }\\n\\t \\n\\t public Reader(String file_name) throws IOException\\n\\t {\\n\\t din = new DataInputStream(\\n\\t new FileInputStream(file_name));\\n\\t buffer = new byte[BUFFER_SIZE];\\n\\t bufferPointer = bytesRead = 0;\\n\\t }\\n\\t \\n\\t public String readLine() throws IOException\\n\\t {\\n\\t byte[] buf = new byte[64]; \\/\\/ line length\\n\\t int cnt = 0, c;\\n\\t while ((c = read()) != -1) {\\n\\t if (c == '\\\\n') {\\n\\t if (cnt != 0) {\\n\\t break;\\n\\t }\\n\\t else {\\n\\t continue;\\n\\t }\\n\\t }\\n\\t buf[cnt++] = (byte)c;\\n\\t }\\n\\t return new String(buf, 0, cnt);\\n\\t }\\n\\t \\n\\t public int nextInt() throws IOException\\n\\t {\\n\\t int ret = 0;\\n\\t byte c = read();\\n\\t while (c <= ' ') {\\n\\t c = read();\\n\\t }\\n\\t ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Amr bought a new video game \\\"Guess Your Way Out!\\\". The goal of the game is to find an exit from the maze that looks like a perfect binary tree of height h. The player is initially standing at the root of the tree and the exit from the tree is located at some leaf node. \\n\\nLet's index all the leaf nodes from the left to the right from 1 to 2h. The exit is located at some node n where 1 ≤ n ≤ 2h, the player doesn't know where the exit is so he has to guess his way out!\\n\\nAmr follows simple algorithm to choose the path. Let's consider infinite command string \\\"LRLRLRLRL...\\\" (consisting of alternating characters 'L' and 'R'). Amr sequentially executes the characters of the string using following rules:\\n\\n * Character 'L' means \\\"go to the left child of the current node\\\"; \\n * Character 'R' means \\\"go to the right child of the current node\\\"; \\n * If the destination node is already visited, Amr skips current command, otherwise he moves to the destination node; \\n * If Amr skipped two consecutive commands, he goes back to the parent of the current node before executing next command; \\n * If he reached a leaf node that is not the exit, he returns to the parent of the current node; \\n * If he reaches an exit, the game is finished. \\n\\n\\n\\nNow Amr wonders, if he follows this algorithm, how many nodes he is going to visit before reaching the exit?\\n\\nInput\\n\\nInput consists of two integers h, n (1 ≤ h ≤ 50, 1 ≤ n ≤ 2h).\\n\\nOutput\\n\\nOutput a single integer representing the number of nodes (excluding the exit node) Amr is going to visit before reaching the exit by following this algorithm.\\n\\nExamples\\n\\nInput\\n\\n1 2\\n\\n\\nOutput\\n\\n2\\n\\nInput\\n\\n2 3\\n\\n\\nOutput\\n\\n5\\n\\nInput\\n\\n3 6\\n\\n\\nOutput\\n\\n10\\n\\nInput\\n\\n10 1024\\n\\n\\nOutput\\n\\n2046\\n\\nNote\\n\\nA perfect binary tree of height h is a binary tree consisting of h + 1 levels. Level 0 consists of a single node called root, level h consists of 2h nodes called leaves. Each node that is not a leaf has exactly two children, left and right one. \\n\\nFollowing picture illustrates the sample test number 3. Nodes are labeled according to...\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.util.Scanner;\\n\\npublic class Guess{\\n\\tpublic static int depth(long n){\\n\\t\\treturn Long.toBinaryString(n).length() - 1;\\n\\t}\\n\\t\\n\\tpublic static void main(String[] args){\\n\\t\\tScanner in = new Scanner(System.in);\\n\\t\\tint h = in.nextInt();\\n\\t\\tlong n = in.nextLong(), v = 0;\\n\\t\\tn += (1L << h) - 1L;\\n\\t\\twhile (n != 1){\\n\\t\\t\\tif (n % 4L == 1 || n % 4L == 2){ \\/\\/ends with 01 or 10\\n\\t\\t\\t\\tv += 1L;\\n\\t\\t\\t}else{\\n\\t\\t\\t\\tv += (1L << (h - depth(n) + 1));\\n\\t\\t\\t}\\n\\t\\t\\tn >>= 1;\\n\\t\\t}\\n\\t\\tSystem.out.println(v);\\n\\t}\\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\\nUsing python3 can you solve the prior task?\",\"targets\":\"t=int(input())\\nimport math\\nfor i in range(t):\\n n=int(input())\\n l=list(map(int,input().split()))\\n oddpos=[]\\n evenpos=[]\\n flag1,flag2=0,0\\n ans=0\\n for j in range(0,len(l),2):\\n evenpos.append(l[j])\\n for j in range(1,len(l),2):\\n oddpos.append(l[j])\\n def gcd (a,b):\\n if (b == 0):\\n return a\\n else:\\n return gcd (b, a % b)\\n resodd = oddpos[0]\\n reseven = evenpos[0]\\n for c in oddpos[1::]:\\n resodd = gcd(resodd , c)\\n for c in evenpos[1::]:\\n reseven = gcd(reseven , c)\\n if resodd!=1:\\n for j in range(len(evenpos)):\\n if evenpos[j]%resodd==0:\\n flag1=1\\n if flag1==0:\\n ans=resodd\\n if reseven!=1:\\n for j in range(len(oddpos)):\\n if oddpos[j]%reseven==0:\\n flag2=1\\n if flag2==0:\\n ans=reseven\\n print (ans)\",\"language\":\"python\",\"split\":\"test\",\"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\":\"#include \\nusing namespace std;\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n int t;\\n cin >> t;\\n while (t--) {\\n int n, k;\\n cin >> n >> k;\\n vector > lines;\\n set s;\\n for (int i = 0; i < 2 * n; i++) {\\n s.insert(i + 1);\\n }\\n for (int i = 0; i < k; i++) {\\n int a, b;\\n cin >> a >> b;\\n lines.emplace_back(a, b);\\n s.erase(a);\\n s.erase(b);\\n }\\n vector v(s.begin(), s.end());\\n for (int i = 0; i < (int)v.size() \\/ 2; i++) {\\n lines.emplace_back(v[i], v[i + (int)v.size() \\/ 2]);\\n }\\n auto comp = [&](pair &a, pair &b) {\\n if (a.second < a.first) swap(a.first, a.second);\\n if (b.second < b.first) swap(b.first, b.second);\\n if (a.second < b.first) return false;\\n if (a.first > b.second) return false;\\n if (a.first < b.first && a.second > b.second) return false;\\n if (a.first > b.first && a.second < b.second) return false;\\n return true;\\n };\\n int ans = 0;\\n for (int i = 0; i < (int)lines.size(); i++) {\\n for (int j = 0; j < i; j++) {\\n ans += comp(lines[i], lines[j]);\\n }\\n }\\n cout << ans << \\\"\\\\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 CPP?\\nLittle girl Tanya is learning how to decrease a number by one, but she does it wrong with a number consisting of two or more digits. Tanya subtracts one from a number by the following algorithm:\\n\\n * if the last digit of the number is non-zero, she decreases the number by one; \\n * if the last digit of the number is zero, she divides the number by 10 (i.e. removes the last digit). \\n\\n\\n\\nYou are given an integer number n. Tanya will subtract one from it k times. Your task is to print the result after all k subtractions.\\n\\nIt is guaranteed that the result will be positive integer number.\\n\\nInput\\n\\nThe first line of the input contains two integer numbers n and k (2 ≤ n ≤ 10^9, 1 ≤ k ≤ 50) — the number from which Tanya will subtract and the number of subtractions correspondingly.\\n\\nOutput\\n\\nPrint one integer number — the result of the decreasing n by one k times.\\n\\nIt is guaranteed that the result will be positive integer number. \\n\\nExamples\\n\\nInput\\n\\n512 4\\n\\n\\nOutput\\n\\n50\\n\\n\\nInput\\n\\n1000000000 9\\n\\n\\nOutput\\n\\n1\\n\\nNote\\n\\nThe first example corresponds to the following sequence: 512 → 511 → 510 → 51 → 50.\",\"targets\":\"#include \\nint main() {\\n long n;\\n int k;\\n scanf(\\\"%ld%d\\\", &n, &k);\\n for (int i = 0; i < k; i++) {\\n if (n % 10 == 0)\\n n \\/= 10;\\n else\\n n -= 1;\\n }\\n printf(\\\"%ld\\\", n);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"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\":\"#include \\nusing namespace std;\\nconst int tam = 1005;\\nint P1[tam];\\nint P2[tam];\\nint _find1(int x) {\\n if (P1[x] == x) return x;\\n return _find1(P1[x]);\\n}\\nint _find2(int x) {\\n if (P2[x] == x) return x;\\n return _find2(P2[x]);\\n}\\nvoid _union1(int x, int y) {\\n x = _find1(x), y = _find1(y);\\n P1[x] = y;\\n}\\nvoid _union2(int x, int y) {\\n x = _find2(x), y = _find2(y);\\n P2[x] = y;\\n}\\nint main() {\\n int n, m1, m2, a, b;\\n cin >> n >> m1 >> m2;\\n for (int i = 1; i <= n; i++) P1[i] = P2[i] = i;\\n for (int i = 0; i < m1; i++) {\\n cin >> a >> b;\\n _union1(a, b);\\n }\\n for (int i = 0; i < m2; i++) {\\n cin >> a >> b;\\n _union2(a, b);\\n }\\n vector > res;\\n for (int i = 1; i <= n; i++) {\\n for (int l = i + 1; l <= n; l++) {\\n if (_find1(i) == _find1(l)) continue;\\n if (_find2(i) == _find2(l)) continue;\\n _union1(i, l);\\n _union2(i, l);\\n res.push_back({i, l});\\n }\\n }\\n cout << res.size() << endl;\\n for (int i = 0; i < res.size(); i++) {\\n cout << res[i].first << \\\" \\\" << res[i].second << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"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.\",\"targets\":\"\\/*\\n \\\"Everything in the universe is balanced. Every disappointment\\n you face in life will be balanced by something good for you!\\n Keep going, never give up.\\\"\\n\\n*\\/\\n\\n\\n\\nimport java.util.*;\\nimport java.lang.*;\\nimport java.io.*;\\n\\npublic class Solution {\\n public static void main(String[] args) throws java.lang.Exception {\\n out = new PrintWriter(new BufferedOutputStream(System.out));\\n sc = new FastReader();\\n\\n int test = sc.nextInt();\\n for (int t = 0; t < test; t++) {\\n solve();\\n }\\n out.close();\\n }\\n\\n private static void solve() {\\n int n = sc.nextInt();\\n boolean[] visited = new boolean[n + 1];\\n List extra = new ArrayList<>();\\n for (int i = 0; i < n; i++) {\\n int val = sc.nextInt();\\n if (val <= n && !visited[val]) {\\n visited[val] = true;\\n }else {\\n extra.add(val);\\n }\\n }\\n Collections.sort(extra);\\n List remaining = new ArrayList<>();\\n for (int i = 1; i <= n; i++) {\\n if (!visited[i]) {\\n remaining.add(i);\\n }\\n }\\n for (int i = 0; i < remaining.size(); i++) {\\n int a = extra.get(i);\\n int b = remaining.get(i);\\n if (a % (a - b) != b) {\\n out.println(-1);\\n return;\\n }\\n }\\n out.println(remaining.size());\\n }\\n\\n public static FastReader sc;\\n public static PrintWriter out;\\n static class FastReader\\n {\\n BufferedReader br;\\n StringTokenizer str;\\n\\n public FastReader()\\n {\\n br = new BufferedReader(new\\n InputStreamReader(System.in));\\n }\\n\\n String next()\\n {\\n while (str == null || !str.hasMoreElements())\\n {\\n try\\n {\\n str = new StringTokenizer(br.readLine());\\n }\\n catch...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"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.\\n\\nimpo\",\"targets\":\"rt java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.util.Scanner;\\n\\npublic class CountDown {\\n public static void main(String[] args) throws IOException {\\n \\n \\tBufferedReader in = new BufferedReader(new InputStreamReader(System.in));\\n\\t\\t\\tint t = Integer.parseInt(in.readLine());\\n while(t-->0){\\n \\tint n = Integer.parseInt(in.readLine());\\n long arr[] = new long[n];\\n int cnt=0,nonz=0,sum=0;\\n \\n String s= in.readLine();\\n \\n \\n for(int i=0;i=0;i--){\\n if(s.charAt(i)!= '0' && cnt!=nonz){\\n cnt++;\\n }\\n }\\n \\n cnt+=sum;\\n \\n System.out.println(cnt);\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"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 if len(s) & 1 or s.count('B') != len(s) \\/\\/ 2:\\n print('NO')\\n else:\\n print('YES')\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"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\\nn = i\",\"targets\":\"nt(input())\\nB = [0,0,0]\\n\\nfor i in range(n):\\n A = input().split()\\n A = [int(i) for i in A]\\n B = [A[i]+B[i] for i in range(0,3)]\\nif B==[0,0,0]:\\n print(\\\"YES\\\")\\nelse:\\n print(\\\"NO\\\")\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nYou 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\":\"#include \\nusing namespace std;\\nusing ll = long long;\\nconst int N = 2e5 + 5, inf = 2e9 + 7;\\nconst ll INF = 1e18, mod = 1e9 + 7, P = 6547;\\nvoid solve() {\\n int n;\\n cin >> n;\\n if (n == 1) {\\n cout << \\\"a\\\\n\\\";\\n return;\\n }\\n if (n % 2 == 0) {\\n for (int i = 1; i < n \\/ 2; i++) {\\n cout << 'a';\\n }\\n cout << 'b';\\n for (int i = 1; i <= n \\/ 2; i++) {\\n cout << 'a';\\n }\\n cout << '\\\\n';\\n return;\\n } else {\\n n--;\\n for (int i = 1; i < n \\/ 2; i++) {\\n cout << 'a';\\n }\\n cout << 'b';\\n for (int i = 1; i <= n \\/ 2; i++) {\\n cout << 'a';\\n }\\n cout << 'c';\\n cout << '\\\\n';\\n return;\\n }\\n}\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n int tt = 1;\\n cin >> tt;\\n while (tt--) {\\n solve();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"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→...\\nSolve the task in PYTHON3.\",\"targets\":\"from collections import deque\\n\\nt = int(input())\\nfor _ in range(t):\\n n = int(input())\\n s1 = input()\\n s2 = input()\\n a,b,c,d = 0,0,0,0 # 10,01,11,00\\n for i in range(n):\\n if s1[i] == \\\"1\\\":\\n if s2[i] == \\\"0\\\":\\n a += 1\\n else:\\n c += 1\\n else:\\n if s2[i] == \\\"1\\\":\\n b += 1\\n else:\\n d += 1\\n start = (a,b,c,d)\\n if a == 0 and b == 0:\\n print(0)\\n else:\\n solved = False\\n visited = set([start])\\n bfs = deque([start])\\n dist = {start:0}\\n while bfs:\\n now = bfs.popleft()\\n if now[0] > 0:\\n new = (now[3]+1,now[2],now[1],now[0]-1)\\n if not new in visited:\\n dist[new] = dist[now]+1\\n bfs.append(new)\\n visited.add(new)\\n if new[0] == 0 and new[1] == 0:\\n print(dist[new])\\n solved = True\\n break\\n if now[2] > 0:\\n new = (now[3],now[2]-1,now[1]+1,now[0])\\n if not new in visited:\\n dist[new] = dist[now]+1\\n bfs.append(new)\\n visited.add(new)\\n if new[0] == 0 and new[1] == 0:\\n print(dist[new])\\n solved = True\\n break\\n if not solved:\\n print(-1)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Caisa solved the problem with the sugar and now he is on the way back to home. \\n\\nCaisa is playing a mobile game during his path. There are (n + 1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (i > 0) has height hi. The goal of the game is to reach n-th pylon, and the only move the player can do is to jump from the current pylon (let's denote its number as k) to the next one (its number will be k + 1). When the player have made such a move, its energy increases by hk - hk + 1 (if this value is negative the player loses energy). The player must have non-negative amount of energy at any moment of the time. \\n\\nInitially Caisa stand at 0 pylon and has 0 energy. The game provides a special opportunity: one can pay a single dollar and increase the height of anyone pylon by one. Caisa may use that opportunity several times, but he doesn't want to spend too much money. What is the minimal amount of money he must paid to reach the goal of the game?\\n\\nInput\\n\\nThe first line contains integer n (1 ≤ n ≤ 105). The next line contains n integers h1, h2, ..., hn (1 ≤ hi ≤ 105) representing the heights of the pylons.\\n\\nOutput\\n\\nPrint a single number representing the minimum number of dollars paid by Caisa.\\n\\nExamples\\n\\nInput\\n\\n5\\n3 4 3 2 4\\n\\n\\nOutput\\n\\n4\\n\\n\\nInput\\n\\n3\\n4 4 4\\n\\n\\nOutput\\n\\n4\\n\\nNote\\n\\nIn the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon.\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"n=int(input())\\nl=list(map(int,input().split()))\\ncost=0\\nenergy=0\\nl.insert(0,0)\\nfor i in range(n):\\n if l[i]=l[i+1]-l[i]:\\n energy-=l[i+1]-l[i]\\n else:\\n cost+=(l[i+1]-l[i])-energy\\n energy=0\\n else:\\n energy+=(l[i]-l[i+1])\\nprint(cost)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 solution for \\\"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\":\"import sys\\n\\ndef get_int():\\n return int(input())\\n\\ndef get_ints():\\n return map(int, sys.stdin.readline().strip().split())\\n\\ndef get_list():\\n return list(map(int, sys,sys.stdin.readline().strip().split()))\\n\\ndef get_string():\\n return sys.stdin.readline().strip()\\n\\ndef solve(s, keyboard):\\n indexOf = {}\\n for i, c in enumerate(keyboard):\\n indexOf[c] = i\\n result = 0\\n for i in range(1, len(s)):\\n result += abs(indexOf[s[i]] - indexOf[s[i-1]])\\n return result\\n\\nif __name__ == \\\"__main__\\\":\\n t = get_int()\\n while t:\\n keyboard = get_string()\\n s = get_string()\\n print(solve(s, keyboard))\\n t -= 1\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"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;\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n long long int t;\\n cin >> t;\\n while (t--) {\\n long long int a, b;\\n cin >> a >> b;\\n if (a == b) {\\n if (a == 0)\\n cout << 0 << \\\"\\\\n\\\";\\n else\\n cout << 1 << \\\"\\\\n\\\";\\n } else if (abs(a - b) % 2 == 0)\\n cout << 2 << \\\"\\\\n\\\";\\n else\\n cout << -1 << \\\"\\\\n\\\";\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"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...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint mx = 1e9;\\nmap, int> mp;\\nint ask(int a, int b) {\\n cout << \\\"? \\\" << a << ' ' << b << endl;\\n int x;\\n cin >> x;\\n return mp[{a, b}] = x;\\n}\\nint main() {\\n int in = ask(1, 1);\\n int w = 1;\\n for (int j = 33; j >= 0; j--) {\\n long long len = (1LL << j);\\n if (w + len <= mx) {\\n int g = ask(w + len, 1);\\n if (in - g == len) {\\n w += len;\\n in = g;\\n }\\n }\\n }\\n cout << \\\"in\\\"\\n << \\\": \\\" << in << endl;\\n ;\\n int e, f, g, h;\\n e = in;\\n f = ask(1, e + 1);\\n g = ask(mx, e + 1);\\n h = ask(mx - g, mx);\\n cout << \\\"! \\\" << f + 1 << ' ' << e + 1 << ' ' << mx - g << ' ' << mx - h\\n << endl;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"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\\nSolve the task in PYTHON.\",\"targets\":\"st = raw_input()\\nst_two = ''\\nif (ord(st[0]) >96 ):\\n st_two = st_two + chr(ord(st[0]) - 32) + st[1:]\\nelse:\\n st_two = st\\nprint (st_two)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"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\\\".\\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;\\npublic class Main{ \\n public static void main (String[] args){\\n FastReader s = new FastReader();\\n int t=1;t=s.ni();\\n for(int test=1;test<=t;test++){int n=s.ni();\\n String S=s.nextLine();\\n if(S.contains(\\\"a\\\")&&S.contains(\\\"b\\\"))\\n for(int i=0;i 0:\\n v = a[i]\\n if v != x:\\n print(v,x)\\n count -= 1\\n i += 1\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A newspaper is published in Walrusland. Its heading is s1, it consists of lowercase Latin letters. Fangy the little walrus wants to buy several such newspapers, cut out their headings, glue them one to another in order to get one big string. After that walrus erase several letters from this string in order to get a new word s2. It is considered that when Fangy erases some letter, there's no whitespace formed instead of the letter. That is, the string remains unbroken and it still only consists of lowercase Latin letters.\\n\\nFor example, the heading is \\\"abc\\\". If we take two such headings and glue them one to the other one, we get \\\"abcabc\\\". If we erase the letters on positions 1 and 5, we get a word \\\"bcac\\\".\\n\\nWhich least number of newspaper headings s1 will Fangy need to glue them, erase several letters and get word s2?\\n\\nInput\\n\\nThe input data contain two lines. The first line contain the heading s1, the second line contains the word s2. The lines only consist of lowercase Latin letters (1 ≤ |s1| ≤ 104, 1 ≤ |s2| ≤ 106).\\n\\nOutput\\n\\nIf it is impossible to get the word s2 in the above-described manner, print \\\"-1\\\" (without the quotes). Otherwise, print the least number of newspaper headings s1, which Fangy will need to receive the word s2.\\n\\nExamples\\n\\nInput\\n\\nabc\\nxyz\\n\\n\\nOutput\\n\\n-1\\n\\n\\nInput\\n\\nabcd\\ndabc\\n\\n\\nOutput\\n\\n2\",\"targets\":\"s1 = raw_input()\\ns2 = raw_input()\\nl = len(s1)\\nv = [[] for i in range(0,l + 10)]\\ncur = [-1] * 26\\nfor i in range(0, l):\\n v[i] = cur[:]\\n cur[ord(s1[i]) - ord('a')] = i\\nv[l] = cur[:]\\nc = l\\ntot = 1\\nfor i in range(len(s2) - 1, -1, -1):\\n c = v[c][ord(s2[i]) - ord('a')]\\n if (c == -1):\\n c = v[l][ord(s2[i]) - ord('a')]\\n tot += 1\\n if (c == -1):\\n tot = -1\\n break\\nprint(tot)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Bear Limak likes watching sports on TV. He is going to watch a game today. The game lasts 90 minutes and there are no breaks.\\n\\nEach minute can be either interesting or boring. If 15 consecutive minutes are boring then Limak immediately turns TV off.\\n\\nYou know that there will be n interesting minutes t1, t2, ..., tn. Your task is to calculate for how many minutes Limak will watch the game.\\n\\nInput\\n\\nThe first line of the input contains one integer n (1 ≤ n ≤ 90) — the number of interesting minutes.\\n\\nThe second line contains n integers t1, t2, ..., tn (1 ≤ t1 < t2 < ... tn ≤ 90), given in the increasing order.\\n\\nOutput\\n\\nPrint the number of minutes Limak will watch the game.\\n\\nExamples\\n\\nInput\\n\\n3\\n7 20 88\\n\\n\\nOutput\\n\\n35\\n\\n\\nInput\\n\\n9\\n16 20 30 40 50 60 70 80 90\\n\\n\\nOutput\\n\\n15\\n\\n\\nInput\\n\\n9\\n15 20 30 40 50 60 70 80 90\\n\\n\\nOutput\\n\\n90\\n\\nNote\\n\\nIn the first sample, minutes 21, 22, ..., 35 are all boring and thus Limak will turn TV off immediately after the 35-th minute. So, he would watch the game for 35 minutes.\\n\\nIn the second sample, the first 15 minutes are boring.\\n\\nIn the third sample, there are no consecutive 15 boring minutes. So, Limak will watch the whole game.\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int n, last = 0, x;\\n ;\\n cin >> n;\\n for (int i = 0; i < n; i++) {\\n cin >> x;\\n if (x - last > 15) {\\n break;\\n } else\\n last = x;\\n }\\n cout << min(last + 15, 90);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is a string x = sk1sk2... sk|x| (1 ≤ k1 < k2 < ... < k|x| ≤ |s|).\\n\\nYou've got two strings — s and t. Let's consider all subsequences of string s, coinciding with string t. Is it true that each character of string s occurs in at least one of these subsequences? In other words, is it true that for all i (1 ≤ i ≤ |s|), there is such subsequence x = sk1sk2... sk|x| of string s, that x = t and for some j (1 ≤ j ≤ |x|) kj = i.\\n\\nInput\\n\\nThe first line contains string s, the second line contains string t. Each line consists only of lowercase English letters. The given strings are non-empty, the length of each string does not exceed 2·105.\\n\\nOutput\\n\\nPrint \\\"Yes\\\" (without the quotes), if each character of the string s occurs in at least one of the described subsequences, or \\\"No\\\" (without the quotes) otherwise.\\n\\nExamples\\n\\nInput\\n\\nabab\\nab\\n\\n\\nOutput\\n\\nYes\\n\\n\\nInput\\n\\nabacaba\\naba\\n\\n\\nOutput\\n\\nNo\\n\\n\\nInput\\n\\nabc\\nba\\n\\n\\nOutput\\n\\nNo\\n\\nNote\\n\\nIn the first sample string t can occur in the string s as a subsequence in three ways: abab, abab and abab. In these occurrences each character of string s occurs at least once.\\n\\nIn the second sample the 4-th character of the string s doesn't occur in any occurrence of string t.\\n\\nIn the third sample there is no occurrence of string t in string s.\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint strt[200010] = {0};\\nint ed[200010];\\nint cnt[200010][26] = {0};\\nint main() {\\n cin.sync_with_stdio(false);\\n string s, t;\\n cin >> s >> t;\\n int n = s.size(), m = t.size();\\n s = \\\"$\\\" + s + \\\"$\\\";\\n t = \\\"$\\\" + t + \\\"$\\\";\\n for (int i = 1; i <= n; i++) {\\n if (s[i] == t[strt[i - 1] + 1]) {\\n strt[i] = strt[i - 1] + 1;\\n } else\\n strt[i] = strt[i - 1];\\n }\\n ed[n + 1] = m + 1;\\n for (int i = n; i > 0; i--) {\\n if (s[i] == t[ed[i + 1] - 1])\\n ed[i] = ed[i + 1] - 1;\\n else\\n ed[i] = ed[i + 1];\\n }\\n for (int i = 1; i <= m; i++) {\\n for (int j = 0; j < 26; j++) {\\n cnt[i][j] = cnt[i - 1][j];\\n }\\n cnt[i][(t[i] - 'a')]++;\\n }\\n for (int i = 1; i <= n; i++) {\\n int x = strt[i - 1], y = ed[i + 1];\\n if (x < (y - 2)) {\\n cout << \\\"No\\\" << endl;\\n return 0;\\n }\\n int w;\\n if (x == m) x--;\\n if (y == 1)\\n w = cnt[x + 1][(s[i] - 'a')];\\n else\\n w = cnt[x + 1][(s[i] - 'a')] - cnt[y - 2][s[i] - 'a'];\\n if (!w) {\\n cout << \\\"No\\\" << endl;\\n return 0;\\n }\\n }\\n cout << \\\"Yes\\\" << endl;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nFrog Gorf is traveling through Swamp kingdom. Unfortunately, after a poor jump, he fell into a well of n meters depth. Now Gorf is on the bottom of the well and has a long way up.\\n\\nThe surface of the well's walls vary in quality: somewhere they are slippery, but somewhere have convenient ledges. In other words, if Gorf is on x meters below ground level, then in one jump he can go up on any integer distance from 0 to a_x meters inclusive. (Note that Gorf can't jump down, only up).\\n\\nUnfortunately, Gorf has to take a break after each jump (including jump on 0 meters). And after jumping up to position x meters below ground level, he'll slip exactly b_x meters down while resting.\\n\\nCalculate the minimum number of jumps Gorf needs to reach ground level.\\n\\nInput\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 300 000) — the depth of the well.\\n\\nThe second line contains n integers a_1, a_2, …, a_n (0 ≤ a_i ≤ i), where a_i is the maximum height Gorf can jump from i meters below ground level.\\n\\nThe third line contains n integers b_1, b_2, …, b_n (0 ≤ b_i ≤ n - i), where b_i is the distance Gorf will slip down if he takes a break on i meters below ground level.\\n\\nOutput\\n\\nIf Gorf can't reach ground level, print -1. Otherwise, firstly print integer k — the minimum possible number of jumps.\\n\\nThen print the sequence d_1,\\\\,d_2, …,\\\\,d_k where d_j is the depth Gorf'll reach after the j-th jump, but before he'll slip down during the break. Ground level is equal to 0.\\n\\nIf there are multiple answers, print any of them.\\n\\nExamples\\n\\nInput\\n\\n\\n3\\n0 2 2\\n1 1 0\\n\\n\\nOutput\\n\\n\\n2\\n1 0 \\n\\n\\nInput\\n\\n\\n2\\n1 1\\n1 0\\n\\n\\nOutput\\n\\n\\n-1\\n\\n\\nInput\\n\\n\\n10\\n0 1 2 3 5 5 6 7 8 5\\n9 8 7 1 5 4 3 2 0 0\\n\\n\\nOutput\\n\\n\\n3\\n9 4 0 \\n\\nNote\\n\\nIn the first example, Gorf is on the bottom of the well and jump to the height 1 meter below ground level. After that he slip down by meter and stays on height 2 meters below ground level. Now, from here, he can reach ground level in one jump.\\n\\nIn the second example, Gorf can jump to one meter below ground level, but will slip down back to the bottom of...\",\"targets\":\"#include \\nusing namespace std;\\nset st;\\nlong long lst[3010000];\\nlong long shit[3010000];\\nlong long vis[3010000];\\nlong long a[3010000];\\nlong long b[3010000];\\nlong long n;\\nlong long BFS(long long now) {\\n queue q;\\n q.push(now);\\n q.push(0);\\n while (!q.empty()) {\\n long long t = q.front();\\n q.pop();\\n long long num = q.front();\\n q.pop();\\n if (t - a[t] <= 0) {\\n lst[0] = t;\\n return num + 1;\\n }\\n vector vt;\\n vt.clear();\\n for (set::iterator it = st.lower_bound(t - a[t]); it != st.end();\\n it++) {\\n long long ed = *it;\\n vt.push_back(ed);\\n long long fk = ed + b[ed];\\n if (vis[fk] == 0) {\\n shit[fk] = ed;\\n q.push(fk);\\n q.push(num + 1);\\n lst[fk] = t;\\n vis[fk] = 1;\\n }\\n }\\n for (long long i = 0; i < vt.size(); i++) {\\n st.erase(vt[i]);\\n }\\n }\\n return -1;\\n}\\nvoid dfs(long long now) {\\n if (now == n) return;\\n dfs(lst[now]);\\n if (now == 0) {\\n printf(\\\"0\\\");\\n } else\\n printf(\\\"%lld \\\", shit[now]);\\n}\\nsigned main() {\\n scanf(\\\"%lld\\\", &n);\\n for (long long i = 1; i <= n; i++) {\\n st.insert(i);\\n }\\n for (long long i = 1; i <= n; i++) {\\n scanf(\\\"%lld\\\", &a[i]);\\n }\\n for (long long i = 1; i <= n; i++) {\\n scanf(\\\"%lld\\\", &b[i]);\\n }\\n long long ans = BFS(n);\\n if (ans == -1) {\\n printf(\\\"%lld\\\", ans);\\n } else {\\n printf(\\\"%lld\\\\n\\\", ans);\\n dfs(0);\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\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\":\"#include \\nusing namespace std;\\nbool isBitSet(int x, int i) { return x & (1 << i); }\\nint main() {\\n ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);\\n int t;\\n cin >> t;\\n while (t--) {\\n int n, m;\\n cin >> n >> m;\\n int k = 0;\\n for (int i = 30; i >= 0; i--) {\\n if (isBitSet(m + 1, i)) {\\n if (!isBitSet(n, i)) k |= (1 << i);\\n } else {\\n if (isBitSet(n, i)) break;\\n }\\n }\\n cout << k << \\\"\\\\n\\\";\\n }\\n cerr << \\\"Run time: \\\" << fixed << setprecision(3)\\n << (double)clock() \\/ CLOCKS_PER_SEC << \\\"s\\\" << endl;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"An array of integers p_1, p_2, ..., p_n is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3, 1, 2], [1], [1, 2, 3, 4, 5] and [4, 3, 1, 2]. The following arrays are not permutations: [2], [1, 1], [2, 3, 4].\\n\\nPolycarp invented a really cool permutation p_1, p_2, ..., p_n of length n. It is very disappointing, but he forgot this permutation. He only remembers the array q_1, q_2, ..., q_{n-1} of length n-1, where q_i=p_{i+1}-p_i.\\n\\nGiven n and q=q_1, q_2, ..., q_{n-1}, help Polycarp restore the invented permutation.\\n\\nInput\\n\\nThe first line contains the integer n (2 ≤ n ≤ 2⋅10^5) — the length of the permutation to restore. The second line contains n-1 integers q_1, q_2, ..., q_{n-1} (-n < q_i < n).\\n\\nOutput\\n\\nPrint the integer -1 if there is no such permutation of length n which corresponds to the given array q. Otherwise, if it exists, print p_1, p_2, ..., p_n. Print any such permutation if there are many of them.\\n\\nExamples\\n\\nInput\\n\\n\\n3\\n-2 1\\n\\n\\nOutput\\n\\n\\n3 1 2 \\n\\nInput\\n\\n\\n5\\n1 1 1 1\\n\\n\\nOutput\\n\\n\\n1 2 3 4 5 \\n\\nInput\\n\\n\\n4\\n-1 2 2\\n\\n\\nOutput\\n\\n\\n-1\\nSolve the task in PYTHON3.\",\"targets\":\"n=int(input())\\nq=list(map(int,input().split()))\\na=[0]*(n-1)\\na[0]=q[0]\\nfor i in range(1,n-1):\\n a[i]=a[i-1]+q[i]\\nsum2=sum(a)\\nsum1=(n*(n+1))\\/\\/2\\nx=(sum1-sum2)\\/\\/n\\nans=[]\\nans.append(x)\\nfor i in range(n-1):\\n ans.append(x+a[i])\\nb=list(set(ans))\\nif min(ans)<1 or max(ans)>n or b!= ans:\\n print(-1)\\n \\nelse:\\n print(*ans)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Every true king during his life must conquer the world, hold the Codeforces world finals, win pink panda in the shooting gallery and travel all over his kingdom.\\n\\nKing Copa has already done the first three things. Now he just needs to travel all over the kingdom. The kingdom is an infinite plane with Cartesian coordinate system on it. Every city is a point on this plane. There are n cities in the kingdom at points with coordinates (x1, 0), (x2, 0), ..., (xn, 0), and there is one city at point (xn + 1, yn + 1). \\n\\nKing starts his journey in the city number k. Your task is to find such route for the king, which visits all cities (in any order) and has minimum possible length. It is allowed to visit a city twice. The king can end his journey in any city. Between any pair of cities there is a direct road with length equal to the distance between the corresponding points. No two cities may be located at the same point.\\n\\nInput\\n\\nThe first line contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ n + 1) — amount of cities and index of the starting city. The second line contains n + 1 numbers xi. The third line contains yn + 1. All coordinates are integers and do not exceed 106 by absolute value. No two cities coincide.\\n\\nOutput\\n\\nOutput the minimum possible length of the journey. Your answer must have relative or absolute error less than 10 - 6.\\n\\nExamples\\n\\nInput\\n\\n3 1\\n0 1 2 1\\n1\\n\\n\\nOutput\\n\\n3.41421356237309490000\\n\\nInput\\n\\n3 1\\n1 0 2 1\\n1\\n\\n\\nOutput\\n\\n3.82842712474619030000\\n\\nInput\\n\\n4 5\\n0 5 -1 -5 2\\n3\\n\\n\\nOutput\\n\\n14.24264068711928400000\\\":\",\"targets\":\"#include \\nusing namespace std;\\nconst int maxn = 100005;\\nint n, k;\\ndouble newtag, a[maxn], ans, y;\\ndouble d(int l) { return sqrt((a[l] - a[n + 1]) * (a[l] - a[n + 1]) + y * y); }\\ndouble cal1(int l, int r) { return a[r] - a[l] + min(d(l), d(r)); }\\ndouble cal2(int l, int r) {\\n return a[r] - a[l] +\\n min(d(l) + fabs(newtag - a[r]), d(r) + fabs(newtag - a[l]));\\n}\\nint main() {\\n cin >> n >> k;\\n for (int i(1); i <= n + 1; i++) scanf(\\\"%lf\\\", &a[i]);\\n scanf(\\\"%lf\\\", &y);\\n newtag = a[k];\\n sort(a + 1, a + n + 1);\\n if (k == n + 1) {\\n double ans = cal1(1, n);\\n printf(\\\"%.8lf\\\\n\\\", ans);\\n } else {\\n double ans = cal2(1, n);\\n for (int i(1); i < n; i++)\\n ans = min(ans,\\n min(cal1(1, i) + cal2(i + 1, n), cal2(1, i) + cal1(i + 1, n)));\\n printf(\\\"%.8lf\\\\n\\\", ans);\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in PYTHON3?\\nn 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;...\",\"targets\":\"md = 998244353\\n\\n\\nT = int(input())\\nfor t in range(T):\\n n = int(input())\\n arr = list(map(int, input().split()))\\n m = max(arr)\\n mc = arr.count(m)\\n mcc = arr.count(m-1)\\n ans, sub=1,1\\n for i in range(1, n+1):\\n ans = (ans*i)%md\\n if i!=mcc+1:\\n sub = (sub*i)%md\\n \\n if mc == 1:\\n ans = (ans - sub + md)%md\\n print(ans)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"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.\\\":\",\"targets\":\"import java.io.*;\\nimport java.lang.reflect.Array;\\nimport java.util.*;\\n\\npublic class Main {\\n\\n static class Pair {\\n int l, r;\\n\\n public Pair(int l, int r) {\\n this.l = l;\\n this.r = r;\\n }\\n }\\n\\n static long mod = (long) 1e9 + 7;\\n\\n public static final double PI = 3.141592653589793d;\\n\\n public static void main(String[] args) throws IOException {\\n InputStream inputStream = System.in;\\n OutputStream outputStream = System.out;\\n InputReader in = new InputReader(inputStream);\\n OutputWriter out = new OutputWriter(outputStream);\\n TaskC solver = new TaskC();\\n solver.solve(1, in, out);\\n out.close();\\n }\\n\\n static class TaskC\\n {\\n public static void solve(int testNumber, InputReader in, OutputWriter out)\\n {\\n int t=in.readInt();\\n while(t-->0)\\n {\\n int n=in.readInt();\\n int a=0,b=0,c=0;\\n c=1;\\n a=n-3;\\n b=2;\\n while(CP.gcd(a,b)!=1)\\n {\\n --a;\\n ++b;\\n }\\n out.printLine(a+\\\" \\\"+b+\\\" \\\"+c);\\n }\\n }\\n }\\n\\n static class InputReader {\\n private InputStream stream;\\n private byte[] buf = new byte[1024];\\n private int curChar;\\n private int numChars;\\n private InputReader.SpaceCharFilter filter;\\n\\n public InputReader(InputStream stream) {\\n this.stream = stream;\\n }\\n\\n public int read() {\\n if (numChars == -1) {\\n throw new InputMismatchException();\\n }\\n if (curChar >= numChars) {\\n curChar = 0;\\n try {\\n numChars = stream.read(buf);\\n } catch (IOException e) {\\n throw new InputMismatchException();\\n }\\n if (numChars <= 0) {\\n return -1;\\n }\\n }\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"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\",\"targets\":\"import java.util.*;\\npublic class Main {\\n public static void main(String args[]) {\\n Scanner sc = new Scanner(System.in);\\n int n = sc.nextInt();\\n int m = sc.nextInt();\\n boolean found = false;\\n while(!found) {\\n n++;\\n found = prime(n);\\n }\\n System.out.println(n == m ? \\\"YES\\\" : \\\"NO\\\");\\n }\\n public static boolean prime(int n) {\\n if(n == 3)\\n return true;\\n if(n % 2 == 0 || n % 3 == 0)\\n return false;\\n for(int i=2; i<=n\\/2; i++) {\\n if(n % i == 0 || n % (i+2) == 0)\\n return false;\\n }\\n return true;\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"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 +...\",\"targets\":\"#include \\nusing namespace std;\\ntemplate \\nvoid print(vector a) {\\n int n = a.size();\\n for (long long i = 0; i < n; ++i) {\\n cout << a[i] << (i == n - 1 ? \\\"\\\\n\\\" : \\\" \\\");\\n }\\n}\\nint sum_vector(vector v) { return accumulate(v.begin(), v.end(), 0); }\\nvoid sort_vector(vector &v) { sort(v.begin(), v.end()); }\\nvoid sort_comp(vector &v, bool func(int, int)) {\\n sort(v.begin(), v.end(), func);\\n}\\nbool comp0(array a, array b) {\\n if (a[0] == b[0]) {\\n return a[1] < b[1];\\n }\\n return a[0] < b[0];\\n}\\nbool comp1(array a, array b) {\\n if (a[1] == b[1]) {\\n return a[0] < b[0];\\n }\\n return a[1] < b[1];\\n}\\nstruct CustomCompare {\\n bool operator()(pair lhs, pair rhs) {\\n return lhs.first > rhs.first;\\n }\\n};\\nlong long gcd(long long a, long long b) {\\n a = abs(a);\\n b = abs(b);\\n while (a) {\\n long long temp = a;\\n a = b % a;\\n b = temp;\\n }\\n return abs(b);\\n}\\nlong long lcm(long long a, long long b) { return (a * b) \\/ gcd(a, b); }\\nstring binary(long long num) {\\n string ans = \\\"\\\";\\n do {\\n ans = to_string(num % 2) + ans;\\n num \\/= 2;\\n } while (num);\\n return ans;\\n}\\nconst int mxn = 5e5 + 7;\\nconst int d = 18;\\nconst int mill = 1e6 + 3;\\nconst long long mod = 1e9 + 7;\\nlong long pwr(long long num, long long p) {\\n num %= mod;\\n num += mod;\\n num %= mod;\\n long long res = 1;\\n while (p > 0) {\\n if (p & 1) res = (res * num) % mod;\\n num = (num * num) % mod;\\n p \\/= 2;\\n }\\n return res;\\n}\\nlong long inverse(long long num) { return pwr(num, mod - 2); }\\nlong long get_rand(long long n) { return ((rand() << 15) + rand()) % n; }\\nvoid solve() {\\n long long n, m, orb, ocb, rd, cd, p;\\n cin >> n >> m >> orb >> ocb >> rd >> cd >> p;\\n long long rb = orb;\\n long long cb = ocb;\\n long long ans = 0;\\n long long vx = 1;\\n long long vy = 1;\\n long long tim = 0;\\n vector v;\\n if (rb + vx > n || rb + vx <= 0) {\\n vx = -vx;\\n }\\n if (cb + vy > m || cb + vy <= 0) {\\n vy = -vy;\\n }\\n long long ovx = vx;\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nBob really likes playing with arrays of numbers. That's why for his birthday, his friends bought him a really interesting machine – an array beautifier. \\n\\nThe array beautifier takes an array A consisting of N integers, and it outputs a new array B of length N that it constructed based on the array given to it. The array beautifier constructs the new array in the following way: it takes two numbers at different indices from the original array and writes their sum to the end of the new array. It does this step N times - resulting in an output array of length N. During this process, the machine can take the same index multiple times in different steps. \\n\\nBob was very excited about the gift that his friends gave him, so he put his favorite array in the machine. However, when the machine finished, Bob was not happy with the resulting array. He misses his favorite array very much, and hopes to get it back. \\n\\nGiven the array that the machine outputted, help Bob find an array that could be the original array that he put in the machine. Sometimes the machine makes mistakes, so it is possible that no appropriate input array exists for the array it has outputted. In such case, let Bob know that his array is forever lost.\\n\\nInput\\n\\nThe first line contains one positive integer N (2 ≤ N ≤ 10^3) – the length of Bob's array.\\n\\nThe second line contains N integers B_1, B_2, ..., B_N (1 ≤ B_i ≤ 10^6) – the elements of the array the machine outputted.\\n\\nOutput\\n\\nIf an appropriate input array exists, print \\\"YES\\\", followed by the input array A_1, A_2, ..., A_N (-10^9 ≤ A_i ≤ 10^9) in the next line. Otherwise, print \\\"NO\\\".\\n\\nExamples\\n\\nInput\\n\\n\\n2\\n5 5\\n\\n\\nOutput\\n\\n\\nYES\\n2 3\\n\\n\\nInput\\n\\n\\n3\\n1 2 3\\n\\n\\nOutput\\n\\n\\nYES\\n0 1 2\\n\\n\\nInput\\n\\n\\n3\\n2 4 5\\n\\n\\nOutput\\n\\n\\nNO\\n\\n\\nInput\\n\\n\\n4\\n1 3 5 7\\n\\n\\nOutput\\n\\n\\nYES\\n6 -3 4 1\",\"targets\":\"#include \\nusing namespace std;\\nint n, t[1005];\\nbool ps;\\nmap m;\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin >> n;\\n for (int i = 1; i <= n; i++) {\\n cin >> t[i];\\n if (t[i] % 2 == 0) {\\n ps = 1;\\n }\\n }\\n sort(t + 1, t + n + 1);\\n if (n == 2 && t[1] != t[2] ||\\n n == 3 && (t[1] + t[2] + t[3]) % 2 && t[1] != t[2] && t[2] != t[3]) {\\n cout << \\\"NO\\\\n\\\";\\n return 0;\\n }\\n for (int i = 1; i < n; i++) {\\n if (t[i] == t[i + 1]) {\\n cout << \\\"YES\\\\n\\\";\\n cout << 0 << \\\" \\\";\\n for (int j = 1; j <= n; j++) {\\n if (i != j) {\\n cout << t[j] << \\\" \\\";\\n }\\n }\\n return 0;\\n }\\n }\\n if (ps) {\\n for (int i = 2; i <= n; i++) {\\n if (t[i] % 2 == 0) {\\n swap(t[i], t[1]);\\n }\\n }\\n if (t[2] % 2 != t[3] % 2) {\\n if (t[2] % 2 == t[4] % 2) {\\n swap(t[3], t[4]);\\n } else {\\n swap(t[2], t[4]);\\n }\\n }\\n int sum = (t[1] + t[2] + t[3]) \\/ 2, ert = sum - t[1];\\n cout << \\\"YES\\\\n\\\";\\n cout << sum - t[1] << \\\" \\\" << sum - t[2] << \\\" \\\" << sum - t[3] << \\\" \\\";\\n for (int i = 4; i <= n; i++) {\\n cout << t[i] - ert << \\\" \\\";\\n }\\n cout << \\\"\\\\n\\\";\\n return 0;\\n }\\n int n2 = min(n, 26), db = n2 \\/ 2;\\n for (int i = 0; i < (1 << n2); i++) {\\n if (__builtin_popcount(i) == db) {\\n int sum = 0;\\n for (int j = 0; j < n2; j++) {\\n if (i & (1 << j)) {\\n sum += t[j + 1];\\n }\\n }\\n if (m.find(sum) != m.end()) {\\n int x = m[sum], y = i, koz = x & y;\\n x -= koz, y -= koz;\\n vector xx, yy, xy;\\n for (int i = 0; i < n2; i++) {\\n if (x & (1 << i)) {\\n xx.push_back(t[i + 1]);\\n }\\n if (y & (1 << i)) {\\n yy.push_back(t[i + 1]);\\n }\\n }\\n for (int i = 0; i < xx.size(); i++) {\\n xy.push_back(xx[i]), xy.push_back(yy[i]);\\n }\\n int el = 0;\\n cout << \\\"YES\\\\n\\\";\\n cout << el << \\\" \\\";\\n for (int i = 1; i < xy.size(); i++) {\\n cout << xy[i] - el << \\\" \\\";\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Given is an integer x that is greater than or equal to 0, and less than or equal to 1. Output 1 if x is equal to 0, or 0 if x is equal to 1.\\n\\nConstraints\\n\\n* 0 \\\\leq x \\\\leq 1\\n* x is an integer\\n\\nInput\\n\\nInput is given from Standard Input in the following format:\\n\\n\\nx\\n\\n\\nOutput\\n\\nPrint 1 if x is equal to 0, or 0 if x is equal to 1.\\n\\nExamples\\n\\nInput\\n\\n1\\n\\n\\nOutput\\n\\n0\\n\\n\\nInput\\n\\n0\\n\\n\\nOutput\\n\\n1\\\":\",\"targets\":\"#include\\nusing namespace std;\\nint main()\\n {\\n int a;\\n cin>>a;\\n cout< hs=new HashSet<>();\\n\\/\\/PriorityQueue pq=new PriorityQueue<>();\\n\\/\\/HashMap hm=new HashMap<>();\\n\\/\\/ArrayList lt=new ArrayList<>();\\n static long mod=1000_000_007;\\n\\n \\/\\/Must Do dry Run Before submitting soln. and think also about corner testcases will be passed or not.\\n public static void solve1() throws Exception{\\n InputStreamReader ip=new InputStreamReader(System.in);\\n BufferedReader br = new BufferedReader(ip);\\n int t = Integer.parseInt(br.readLine());\\n StringBuilder asb=new StringBuilder();\\n\\t\\t\\n while(t-->0){\\n \\/\\/ int n =Integer.parseInt(br.readLine());\\n \\/\\/ String[] strs=(br.readLine()).trim().split(\\\" \\\");\\n \\/\\/ int n=Integer.parseInt(strs[0]),k=Integer.parseInt(strs[1]),r=Integer.parseInt(strs[2]),s=Integer.parseInt(strs[3]);\\n String str=(br.readLine()).trim();\\n \\/\\/ int[] arr=new int[n];\\n \\/\\/ for(int i=0;i2){ ct0=2; } \\/\\/ 01010\\n\\n asb.append(ct0+\\\"\\\\n\\\");\\n\\n }\\n\\n System.out.println(asb);\\n }\\n\\n \\n\\/\\/******************************************************************************************************************** *\\/\\n public static void main(String[] args) throws Exception{\\n solve1();\\n \\n }\\n\\n public static void solve2() throws Exception{\\n InputStreamReader ip=new InputStreamReader(System.in);\\n BufferedReader br = new BufferedReader(ip);\\n int t = Integer.parseInt(br.readLine());\\n StringBuilder asb=new StringBuilder();\\n\\t\\t\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\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\":\"import 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 Roy\\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 D1DominoEasyVersion solver = new D1DominoEasyVersion();\\n solver.solve(1, in, out);\\n out.close();\\n }\\n\\n static class D1DominoEasyVersion {\\n private boolean found;\\n\\n private void solveEvenXEvenMatrix(int dominoes) {\\n \\/\\/~ if the matrix is: even x even\\n \\/\\/~ then it is enough to check the number of dominoes are even or not\\n if (dominoes % 2 == 0) found = true;\\n }\\n\\n public void solve(int testNumber, InputReader in, OutputWriter out) {\\n int tc = in.readInteger();\\n for (int cs = 1; cs <= tc; ++cs) {\\n int n = in.readInteger();\\n int m = in.readInteger();\\n int k = in.readInteger();\\n\\n found = false;\\n if (n % 2 == 0 && m % 2 == 0) {\\/\\/~ even x even matrix\\n solveEvenXEvenMatrix(k);\\n } else if (n % 2 == 0 && m % 2 == 1) {\\/\\/~ even x odd matrix\\n int maxPossibleHorizons = (m * n) \\/ 2 - (n \\/ 2);\\n\\n if (k <= maxPossibleHorizons) {\\/\\/~ k should not be > maxPossibleHorizons\\n solveEvenXEvenMatrix(k);\\n }\\n } else if (n % 2 == 1 && m % 2 == 0) { \\/\\/~ odd x even matrix\\n int leastHorizons = m \\/ 2;\\n if (k >=...\",\"language\":\"python\",\"split\":\"valid\",\"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;\\nint t, n;\\nstring s;\\nint main() {\\n cin >> t;\\n while (t--) {\\n cin >> n;\\n int i, k;\\n vector vec(n);\\n vector> diff(5, vector(n, 0));\\n for (i = 0; i < n; i++) {\\n cin >> vec[i];\\n for (auto j : vec[i]) {\\n for (k = 97; k < 102; k++) {\\n if (j == k)\\n diff[k - 97][i]++;\\n else\\n diff[k - 97][i]--;\\n }\\n }\\n }\\n int m = 0;\\n for (i = 0; i < 5; i++) {\\n int sum = 0;\\n sort(diff[i].begin(), diff[i].end(), greater());\\n for (k = 0; k < n; k++) {\\n if (sum + diff[i][k] > 0) {\\n sum += diff[i][k];\\n } else {\\n m = max(k, m);\\n break;\\n }\\n }\\n if (k == n) m = n;\\n }\\n cout << m << \\\"\\\\n\\\";\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 solution for \\\"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...\\\":\",\"targets\":\"from heapq import heapify,heappush,heappop,heappushpop\\nfrom collections import defaultdict as dd, deque as dq,Counter as C\\nfrom math import factorial as f ,ceil,gcd,sqrt,log\\nfrom bisect import bisect_left as bl ,bisect_right as br\\nfrom itertools import combinations as c,permutations as p\\nfrom math import factorial as f ,ceil,gcd,sqrt,log\\nfrom sys import stdin\\ninput = stdin.readline\\nmp = lambda : map(int,input().split())\\nit = lambda: int(input())\\nls = lambda : list(input().strip().split())\\nmt = lambda r : [ ls() for _ in range(r)]\\nlcm = lambda a,b : (a*b)\\/\\/gcd(a,b)\\n\\nfor _ in range(it()):\\n\\ta = it()\\n\\tb = list(mp())\\n\\tb.sort()\\n\\tb = dq(b)\\n\\ttot =0\\n\\tmx = b[0]\\n\\twhile b:\\n\\t\\tk = b.popleft()\\n\\t\\ttot+=k\\n\\t\\tif b:\\n\\t\\t\\tmx = max(b[0]-tot,mx)\\n\\t\\t\\tb[0]-=tot\\n\\tprint(mx)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"In Berland prime numbers are fashionable — the respectable citizens dwell only on the floors with numbers that are prime numbers. The numismatists value particularly high the coins with prime nominal values. All the prime days are announced holidays!\\n\\nYet even this is not enough to make the Berland people happy. On the main street of the capital stand n houses, numbered from 1 to n. The government decided to paint every house a color so that the sum of the numbers of the houses painted every color is a prime number.\\n\\nHowever it turned out that not all the citizens approve of this decision — many of them protest because they don't want many colored houses on the capital's main street. That's why it is decided to use the minimal possible number of colors. The houses don't have to be painted consecutively, but every one of n houses should be painted some color. The one-colored houses should not stand consecutively, any way of painting is acceptable.\\n\\nThere are no more than 5 hours left before the start of painting, help the government find the way when the sum of house numbers for every color is a prime number and the number of used colors is minimal. \\n\\nInput\\n\\nThe single input line contains an integer n (2 ≤ n ≤ 6000) — the number of houses on the main streets of the capital.\\n\\nOutput\\n\\nPrint the sequence of n numbers, where the i-th number stands for the number of color for house number i. Number the colors consecutively starting from 1. Any painting order is allowed. If there are several solutions to that problem, print any of them. If there's no such way of painting print the single number -1.\\n\\nExamples\\n\\nInput\\n\\n8\\n\\nOutput\\n\\n1 2 2 1 1 1 1 2\\\":\",\"targets\":\"#include \\nusing namespace std;\\nconst int maxn = 6002 * 3000;\\nint prime[maxn], flag[maxn], a[maxn \\/ 3000], cnt = 0;\\nvoid get_prime() {\\n for (int i = 2; i < maxn; i++) {\\n if (!flag[i]) {\\n prime[cnt++] = i;\\n }\\n for (int j = 0; j < cnt && i * prime[j] < maxn; j++) {\\n flag[prime[j] * i] = true;\\n if (i % prime[j] == 0) break;\\n }\\n }\\n}\\nvoid goldbach(int s) {\\n for (int i = 2; (i << 1) <= s; i++) {\\n if (!flag[i] && !flag[s - i]) {\\n a[i] = 2;\\n return;\\n }\\n }\\n}\\nint main() {\\n int n, s;\\n scanf(\\\"%d\\\", &n);\\n for (int i = 1; i <= n; i++) a[i] = 1;\\n s = (n * (n + 1)) >> 1;\\n get_prime();\\n if (flag[s]) {\\n if (s % 2 == 0) {\\n goldbach(s);\\n } else if (!flag[s - 2]) {\\n a[2] = 2;\\n } else {\\n a[3] = 3;\\n goldbach(s - 3);\\n }\\n }\\n for (int i = 1; i <= n; i++) printf(\\\"%d%s\\\", a[i], 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 JAVA?\\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 java.util.*;\\nimport java.io.*;\\npublic class Test{\\n public static int count(String s, char let)\\n {\\n int res = 0;\\n for(int i=0; i 1), where q is some integer. \\n\\n\\n\\nRight now Gena has a piece of paper with sequence b, consisting of n integers. Help Gena, find there the longest subsequence of integers that is an almost arithmetical progression.\\n\\nSequence s1, s2, ..., sk is a subsequence of sequence b1, b2, ..., bn, if there is such increasing sequence of indexes i1, i2, ..., ik (1 ≤ i1 < i2 < ... < ik ≤ n), that bij = sj. In other words, sequence s can be obtained from b by crossing out some elements.\\n\\nInput\\n\\nThe first line contains integer n (1 ≤ n ≤ 4000). The next line contains n integers b1, b2, ..., bn (1 ≤ bi ≤ 106).\\n\\nOutput\\n\\nPrint a single integer — the length of the required longest subsequence.\\n\\nExamples\\n\\nInput\\n\\n2\\n3 5\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n4\\n10 20 10 30\\n\\n\\nOutput\\n\\n3\\n\\nNote\\n\\nIn the first test the sequence actually is the suitable subsequence. \\n\\nIn the second test the following subsequence fits: 10, 20, 10.\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint n, a[4000], num[1000000], i, pr[4000][4000], j, d[4000][4000], san, ans = 1;\\nvector last(4000, -1);\\nint main() {\\n cin >> n;\\n for (i = 0; i < n; i++) {\\n cin >> a[i];\\n if (num[a[i] - 1])\\n a[i] = num[a[i] - 1];\\n else {\\n num[a[i] - 1] = ++san;\\n a[i] = san;\\n }\\n }\\n for (i = 0; i < n; i++) {\\n for (j = 0; j < 4000; j++) pr[j][i] = last[j];\\n last[a[i] - 1] = i;\\n }\\n for (i = 1; i < n; i++)\\n for (j = 0; j < i; j++) {\\n if (pr[a[i] - 1][j] != -1)\\n d[i][j] = d[j][pr[a[i] - 1][j]] + 1;\\n else\\n d[i][j] = 2;\\n if (d[i][j] > ans) ans = d[i][j];\\n }\\n cout << ans;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"You are given a tree consisting of n vertices. Recall that a tree is an undirected connected acyclic graph. The given tree is rooted at the vertex 1.\\n\\nYou have to process q queries. In each query, you are given a vertex of the tree v and an integer k.\\n\\nTo process a query, you may delete any vertices from the tree in any order, except for the root and the vertex v. When a vertex is deleted, its children become the children of its parent. You have to process a query in such a way that maximizes the value of c(v) - m ⋅ k (where c(v) is the resulting number of children of the vertex v, and m is the number of vertices you have deleted). Print the maximum possible value you can obtain.\\n\\nThe queries are independent: the changes you make to the tree while processing a query don't affect the tree in other queries.\\n\\nInput\\n\\nThe first line contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of vertices in the tree.\\n\\nThen n-1 lines follow, the i-th of them contains two integers x_i and y_i (1 ≤ x_i, y_i ≤ n; x_i ≠ y_i) — the endpoints of the i-th edge. These edges form a tree.\\n\\nThe next line contains one integer q (1 ≤ q ≤ 2 ⋅ 10^5) — the number of queries.\\n\\nThen q lines follow, the j-th of them contains two integers v_j and k_j (1 ≤ v_j ≤ n; 0 ≤ k_j ≤ 2 ⋅ 10^5) — the parameters of the j-th query.\\n\\nOutput\\n\\nFor each query, print one integer — the maximum value of c(v) - m ⋅ k you can achieve.\\n\\nExample\\n\\nInput\\n\\n\\n8\\n6 7\\n3 2\\n8 3\\n5 7\\n7 4\\n7 1\\n7 3\\n6\\n1 0\\n1 2\\n1 3\\n7 1\\n5 0\\n7 200000\\n\\n\\nOutput\\n\\n\\n5\\n2\\n1\\n4\\n0\\n4\\n\\nNote\\n\\nThe tree in the first example is shown in the following picture:\\n\\n\\n\\nAnswers to the queries are obtained as follows:\\n\\n 1. v=1,k=0: you can delete vertices 7 and 3, so the vertex 1 has 5 children (vertices 2, 4, 5, 6, and 8), and the score is 5 - 2 ⋅ 0 = 5; \\n 2. v=1,k=2: you can delete the vertex 7, so the vertex 1 has 4 children (vertices 3, 4, 5, and 6), and the score is 4 - 1 ⋅ 2 = 2. \\n 3. v=1,k=3: you shouldn't delete any vertices, so the vertex 1 has only one child (vertex 7), and the score is 1 - 0 ⋅ 3 = 1; \\n ...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 2e5 + 10;\\nint n, m;\\nvector V[N];\\nint fa[N], siz[N], er[N];\\nint son[N];\\nint ans[N];\\nvector > q[N];\\nvoid dfs1(int x) {\\n siz[x] = 1;\\n er[x] = 0;\\n for (int i = 0; i < V[x].size(); ++i) {\\n if (V[x][i] != fa[x]) {\\n fa[V[x][i]] = x;\\n dfs1(V[x][i]);\\n siz[x] += siz[V[x][i]];\\n ++er[x];\\n }\\n }\\n return;\\n}\\nint lim[N];\\nint F[23][N], cha[23][N];\\nvoid dfs2(int x, int cs) {\\n int y;\\n son[x] = 0;\\n for (int i = 0; i < V[x].size(); ++i) {\\n y = V[x][i];\\n if (y == fa[x]) continue;\\n if (siz[y] > siz[son[x]]) {\\n son[x] = y;\\n }\\n }\\n if (!son[x]) {\\n lim[x] = 0;\\n F[cs][0] = 1;\\n for (int i = 0; i < q[x].size(); ++i) {\\n ans[q[x][i].second] = 0;\\n }\\n return;\\n }\\n dfs2(son[x], cs);\\n int L = lim[son[x]];\\n cha[cs][lim[son[x]] + 1]++;\\n for (int i = 0; i < V[x].size(); ++i) {\\n y = V[x][i];\\n if (y == fa[x] || y == son[x]) continue;\\n dfs2(y, cs + 1);\\n while (L < lim[y]) {\\n ++L;\\n F[cs][L] = 0;\\n }\\n for (int j = 0; j <= lim[y]; ++j) {\\n F[cs][j] += F[cs + 1][j];\\n }\\n cha[cs][lim[y] + 1]++;\\n }\\n int hhh = 0;\\n for (int j = 0; j <= L; ++j) {\\n hhh += cha[cs][j];\\n F[cs][j] += hhh;\\n }\\n for (int i = 0; i < q[x].size(); ++i) {\\n if (q[x][i].first > L) {\\n ans[q[x][i].second] = er[x];\\n } else {\\n ans[q[x][i].second] = F[cs][q[x][i].first];\\n }\\n }\\n if (er[x] > L) {\\n lim[x] = er[x];\\n for (int j = L + 1; j <= er[x]; ++j) {\\n F[cs][j] = er[x];\\n }\\n } else {\\n lim[x] = L;\\n }\\n while (lim[x] > 0 && F[cs][lim[x]] - lim[x] < 1) {\\n lim[x]--;\\n }\\n for (int j = 0; j <= lim[x]; ++j) {\\n F[cs][j] -= j;\\n if (F[cs][j] < 1) F[cs][j] = 1;\\n }\\n cha[cs][lim[son[x]] + 1]--;\\n for (int i = 0; i < V[x].size(); ++i) {\\n y = V[x][i];\\n if (y == fa[x] || y == son[x]) continue;\\n cha[cs][lim[y] + 1]--;\\n }\\n return;\\n}\\nint main() {\\n int u, v;\\n scanf(\\\"%d\\\", &n);\\n for (int i = 1; i < n; ++i) {\\n scanf(\\\"%d%d\\\", &u, &v);\\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...\\n\\n\\nimp\",\"targets\":\"ort java.util.*;\\nimport java.lang.*;\\nimport java.io.*;\\n\\n\\n\\/* Name of the class has to be \\\"Main\\\" only if the class is public. *\\/\\npublic class Pupil\\n{\\n \\n\\t\\n static FastReader sc = new FastReader();\\n\\n\\tpublic static void main (String[] args) throws java.lang.Exception\\n\\t{\\n\\t \\t\\n\\t\\/\\/ your code goes here\\n int t=sc.nextInt();\\n while(t>0){\\n\\n long n=sc.nextLong();\\n long m=sc.nextLong();\\n long rb=sc.nextLong();\\n long cb=sc.nextLong();\\n long rd=sc.nextLong();\\n long cd=sc.nextLong();\\n\\nlong ans=0;\\nlong a1=1;\\nlong a2=1;\\n while(true)\\n {\\n \\t if(rb==rd || cb==cd)\\n \\t {\\n \\t\\t break;\\n \\t }\\n \\t if(rb+a1>n || rb+a1<1)\\n \\t {\\n \\t\\t a1=a1*-1;\\n \\t }\\n \\t if(cb+a2>m || cb+a2<1)\\n \\t {\\n \\t\\t a2=a2*-1;\\n \\t\\t \\n \\t }\\n \\t\\t rb=rb+a1;\\n \\t\\t cb=cb+a2;\\n \\t\\t ans++;\\n \\t \\n }\\nSystem.out.println(ans);\\n\\n\\n\\n\\n\\n t--;\\n }\\n\\n \\n\\n \\n \\n \\n\\t\\t}\\n\\t\\n\\t\\n\\t\\n\\t\\n\\t\\/\\/\\tFAST I\\/O\\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() {...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"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 JAVA.\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\n\\nimport static java.lang.Math.abs;\\n\\n\\npublic class Main {\\n long M = 1000000007;\\n boolean multiCase = true;\\n\\n private void preparation() {\\n\\n }\\n\\n private void solve() throws Exception {\\n rf();rf();\\n int m = ri();\\n int n = ri();\\n int [][] p = new int[m][n];\\n for(int i = 0; i < m; i++){\\n rf();\\n for(int j = 0; j < n; j++){\\n p[i][j] = ri();\\n }\\n }\\n int [] ans = Arrays.copyOf(p[0], n);\\n for(int i = 1; i < m; i++){\\n for(int j = 0; j < n; j++){\\n ans[j] = max(ans[j], p[i][j]);\\n }\\n }\\n if(m <= n - 1){\\n addAns(min(ans));\\n return ;\\n }else{\\n int res = 0;\\n for(int i = 0; i < n; i++){\\n for(int j = i + 1; j < n; j++){\\n if(i == j){\\n continue;\\n }\\n int x = 0;\\n for(int k = 0; k < m; k++){\\n x = max(x, min(p[k][i], p[k][j]));\\n }\\n for(int k = 0; k < n; k++){\\n if(k == i || k == j){\\n continue;\\n }\\n x = min(ans[k], x);\\n }\\n res = max(x, res);\\n }\\n }\\n addAns(res);\\n }\\n }\\n\\n private void clear() {\\n\\n }\\n\\n private void run() throws Exception {\\n\\n int T = 1;\\n if (multiCase) {\\n rf();\\n T = ri();\\n }\\n\\n preparation();\\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 ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alice and Bob are playing a game on a line with n cells. There are n cells labeled from 1 through n. For each i from 1 to n-1, cells i and i+1 are adjacent.\\n\\nAlice initially has a token on some cell on the line, and Bob tries to guess where it is. \\n\\nBob guesses a sequence of line cell numbers x_1, x_2, …, x_k in order. In the i-th question, Bob asks Alice if her token is currently on cell x_i. That is, Alice can answer either \\\"YES\\\" or \\\"NO\\\" to each Bob's question.\\n\\nAt most one time in this process, before or after answering a question, Alice is allowed to move her token from her current cell to some adjacent cell. Alice acted in such a way that she was able to answer \\\"NO\\\" to all of Bob's questions.\\n\\nNote that Alice can even move her token before answering the first question or after answering the last question. Alice can also choose to not move at all.\\n\\nYou are given n and Bob's questions x_1, …, x_k. You would like to count the number of scenarios that let Alice answer \\\"NO\\\" to all of Bob's questions. \\n\\nLet (a,b) denote a scenario where Alice starts at cell a and ends at cell b. Two scenarios (a_i, b_i) and (a_j, b_j) are different if a_i ≠ a_j or b_i ≠ b_j.\\n\\nInput\\n\\nThe first line contains two integers n and k (1 ≤ n,k ≤ 10^5) — the number of cells and the number of questions Bob asked.\\n\\nThe second line contains k integers x_1, x_2, …, x_k (1 ≤ x_i ≤ n) — Bob's questions.\\n\\nOutput\\n\\nPrint a single integer, the number of scenarios that let Alice answer \\\"NO\\\" to all of Bob's questions.\\n\\nExamples\\n\\nInput\\n\\n\\n5 3\\n5 1 4\\n\\n\\nOutput\\n\\n\\n9\\n\\n\\nInput\\n\\n\\n4 8\\n1 2 3 4 4 3 2 1\\n\\n\\nOutput\\n\\n\\n0\\n\\n\\nInput\\n\\n\\n100000 1\\n42\\n\\n\\nOutput\\n\\n\\n299997\\n\\nNote\\n\\nThe notation (i,j) denotes a scenario where Alice starts at cell i and ends at cell j.\\n\\nIn the first example, the valid scenarios are (1, 2), (2, 1), (2, 2), (2, 3), (3, 2), (3, 3), (3, 4), (4, 3), (4, 5). For example, (3,4) is valid since Alice can start at cell 3, stay there for the first three questions, then move to cell 4 after the last question. \\n\\n(4,5) is valid since Alice can start at cell 4,...\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\nimport static java.lang.Math.*;\\npublic class MainS {\\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\\n public static void main(String[] args) {\\n Thread t = new Thread(null, new O(), \\\"Integer.MAX_VALUE\\\", 100000000);\\n t.start();\\n }\\n\\n static class O implements Runnable {\\n public void run() {\\n try {\\n magic();\\n } catch (Exception e) {\\n e.printStackTrace();\\n System.exit(1);\\n }\\n }\\n }\\n\\n public 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() {\\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 static void magic() throws IOException {\\n reader = new FastReader();\\n writer = new PrintWriter(System.out, true);\\n int n = reader.nextInt(), k = reader.nextInt();\\n int min_pos[] = new int[n+1];\\n int max_pos[] = new int[n+1];\\n Arrays.fill(min_pos, -1);\\n Arrays.fill(max_pos, -1);\\n for(int...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"AtCoDeer the deer has N square tiles. The tiles are numbered 1 through N, and the number given to each tile is written on one side of the tile. Also, each corner of each tile is painted in one of the 1000 colors, which are represented by the integers 0 between 999. The top-left, top-right, bottom-right and bottom-left corner of the tile with the number i are painted in color C_{i,0}, C_{i,1}, C_{i,2} and C_{i,3}, respectively, when seen in the direction of the number written on the tile (See Figure 1).\\n\\n\\n\\nFigure 1: The correspondence between the colors of a tile and the input\\n\\nAtCoDeer is constructing a cube using six of these tiles, under the following conditions:\\n\\n* For each tile, the side with the number must face outward.\\n* For each vertex of the cube, the three corners of the tiles that forms it must all be painted in the same color.\\n\\n\\n\\nHelp him by finding the number of the different cubes that can be constructed under the conditions. Since each tile has a number written on it, two cubes are considered different if the set of the used tiles are different, or the tiles are used in different directions, even if the formation of the colors are the same. (Each tile can be used in one of the four directions, obtained by 90° rotations.) Two cubes are considered the same only if rotating one in the three dimensional space can obtain an exact copy of the other, including the directions of the tiles.\\n\\n\\n\\nFigure 2: The four directions of a tile\\n\\nConstraints\\n\\n* 6≦N≦400\\n* 0≦C_{i,j}≦999 (1≦i≦N , 0≦j≦3)\\n\\nInput\\n\\nThe input is given from Standard Input in the following format:\\n\\n\\nN\\nC_{1,0} C_{1,1} C_{1,2} C_{1,3}\\nC_{2,0} C_{2,1} C_{2,2} C_{2,3}\\n:\\nC_{N,0} C_{N,1} C_{N,2} C_{N,3}\\n\\n\\nOutput\\n\\nPrint the number of the different cubes that can be constructed under the conditions.\\n\\nExamples\\n\\nInput\\n\\n6\\n0 1 2 3\\n0 4 6 1\\n1 6 7 2\\n2 7 5 3\\n6 4 5 7\\n4 0 3 5\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\n8\\n0 0 0 0\\n0 0 1 1\\n0 1 0 1\\n0 1 1 0\\n1 0 0 1\\n1 0 1 0\\n1 1 0 0\\n1 1 1 1\\n\\n\\nOutput\\n\\n144\\n\\n\\nInput\\n\\n6\\n0 0 0 0\\n0 0 0 0\\n0 0 0 0\\n0 0 0 0\\n0 0 0 0\\n0 0 0 0\\n\\n\\nOutput\\n\\n122880\\nUsing python3 can you solve the prior task?\",\"targets\":\"import sys\\nfrom collections import Counter\\nreadline = sys.stdin.readline\\n\\ndef compress(L):\\n L2 = list(set(L))\\n L2.sort()\\n C = {v : k for k, v in enumerate(L2, 1)}\\n return L2, C\\n\\ndef order(a, b, c, d):\\n if a == b == c == d:\\n return 4\\n if a == c and b == d:\\n return 2\\n return 1\\n\\n\\nlimit = 5\\ncalc = [[None]*limit for _ in range(limit*400)]\\nfor i in range(limit*400):\\n calc[i][1] = i\\n for j in range(2, limit):\\n calc[i][j] = calc[i][j-1]*(i-j+1)\\npp = [[pow(i, j) for j in range(10)] for i in range(10)]\\n\\nN = int(readline())\\nC = [tuple(map(int, readline().split())) for _ in range(N)]\\nD = Counter()\\n\\n\\n\\nRot = []\\nfor i in range(N):\\n a, b, c, d = C[i]\\n Rot.append((a, b, c, d))\\n Rot.append((d, a, b, c))\\n Rot.append((c, d, a, b))\\n Rot.append((b, c, d, a))\\nLc, Cr = compress(Rot)\\nLc = [None] + Lc\\nCc = []\\n\\nOd = Counter()\\nBase = Counter()\\nD = Counter()\\nfor i in range(N):\\n a, b, c, d = C[i]\\n a, b, c, d = min((a, b, c, d), (b, c, d, a), (c, d, a, b), (d, a, b, c))\\n od = order(a, b, c, d)\\n r1 = Cr[(a, b, c, d)]\\n r2 = Cr[(b, c, d, a)]\\n r3 = Cr[(c, d, a, b)]\\n r4 = Cr[(d, a, b, c)]\\n Base[r1] = r1\\n Base[r2] = r1\\n Base[r3] = r1\\n Base[r4] = r1\\n Od[r1] = od\\n Od[r2] = od\\n Od[r3] = od\\n Od[r4] = od\\n Cc.append((r1, r2, r3, r4))\\n D[r1] += 1\\n\\n\\nans = 0\\nfor i in range(N):\\n D[Cc[i][0]] -= 1\\n a, b, c, d = Lc[Cc[i][0]]\\n for j in range(i+1, N):\\n D[Cc[j][0]] -= 1\\n for idx in range(4):\\n e, f, g, h = Lc[Cc[j][idx]]\\n E = Counter()\\n r1 = (b, e, h, c)\\n if r1 not in Cr:\\n continue\\n r1 = Base[Cr[r1]]\\n r2 = (a, f, e, b)\\n if r2 not in Cr:\\n continue\\n r2 = Base[Cr[r2]]\\n r3 = (d, g, f, a)\\n if r3 not in Cr:\\n continue\\n r3 = Base[Cr[r3]]\\n r4 = (c, h, g, d)\\n if r4 not in Cr:\\n continue\\n r4 = Base[Cr[r4]]\\n \\n ...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"n towns are arranged in a circle sequentially. The towns are numbered from 1 to n in clockwise order. In the i-th town, there lives a singer with a repertoire of a_i minutes for each i ∈ [1, n].\\n\\nEach singer visited all n towns in clockwise order, starting with the town he lives in, and gave exactly one concert in each town. In addition, in each town, the i-th singer got inspired and came up with a song that lasts a_i minutes. The song was added to his repertoire so that he could perform it in the rest of the cities.\\n\\nHence, for the i-th singer, the concert in the i-th town will last a_i minutes, in the (i + 1)-th town the concert will last 2 ⋅ a_i minutes, ..., in the ((i + k) mod n + 1)-th town the duration of the concert will be (k + 2) ⋅ a_i, ..., in the town ((i + n - 2) mod n + 1) — n ⋅ a_i minutes.\\n\\nYou are given an array of b integer numbers, where b_i is the total duration of concerts in the i-th town. Reconstruct any correct sequence of positive integers a or say that it is impossible.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10^3) — the number of test cases. Then the test cases follow.\\n\\nEach test case consists of two lines. The first line contains a single integer n (1 ≤ n ≤ 4 ⋅ 10^4) — the number of cities. The second line contains n integers b_1, b_2, ..., b_n (1 ≤ b_i ≤ 10^{9}) — the total duration of concerts in i-th city.\\n\\nThe sum of n over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print the answer as follows:\\n\\nIf there is no suitable sequence a, print NO. Otherwise, on the first line print YES, on the next line print the sequence a_1, a_2, ..., a_n of n integers, where a_i (1 ≤ a_i ≤ 10^{9}) is the initial duration of repertoire of the i-th singer. If there are multiple answers, print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n12 16 14\\n1\\n1\\n3\\n1 2 3\\n6\\n81 75 75 93 93 87\\n\\n\\nOutput\\n\\n\\nYES\\n3 1 3 \\nYES\\n1 \\nNO\\nYES\\n5 5 4 1 4 5 \\n\\nNote\\n\\nLet's consider the 1-st test case of the example:\\n\\n 1. the 1-st singer in the 1-st city will give a concert for 3 minutes, in the 2-nd —...\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\n\\npublic class Solution {\\n \\n public static void main(String[] args) throws IOException {\\n\\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\\n\\n int t = Integer.parseInt(br.readLine());\\n\\n BufferedWriter output = new BufferedWriter(new OutputStreamWriter(System.out));\\n\\n StringTokenizer st;\\n\\n while (t-- > 0) {\\n\\n int n = Integer.parseInt(br.readLine());\\n\\n st = new StringTokenizer(br.readLine());\\n\\n int arr[] = new int[n];\\n long arr2[] = new long[n];\\n\\n long sumb = 0;\\n for(int i = 0; i < n; i++)\\n {\\n int e = Integer.parseInt(st.nextToken());\\n arr[i] = e;\\n sumb+=e;\\n }\\n\\n long suma = 0;\\n long nt = n * (n+1);\\n nt\\/=2;\\n\\n if(sumb % nt != 0)\\n {\\n output.write(\\\"NO\\\\n\\\");\\n continue;\\n }\\n\\n suma = sumb \\/ nt;\\n\\n int flag = 0;\\n \\n for(int i = 0; i < n; i++)\\n {\\n long diff = arr[i] - arr[(i+1) % n] + suma;\\n if(diff % n != 0 || diff <= 0)\\n flag = 1;\\n \\n arr2[(i+1) % n] = diff \\/ n;\\n }\\n\\n if(flag == 1)\\n {\\n output.write(\\\"NO\\\\n\\\");\\n continue;\\n }\\n\\n output.write(\\\"YES\\\\n\\\");\\n for(long i : arr2)\\n output.write(i + \\\" \\\");\\n\\n output.write(\\\"\\\\n\\\");\\n\\n\\n\\n\\n \\/\\/ int k = Integer.parseInt(st.nextToken());\\n\\n \\/\\/ char arr[] = br.readLine().toCharArray();\\n\\n \\/\\/ output.write();\\n \\/\\/ int n = Integer.parseInt(st.nextToken());\\n\\n \\/\\/ HashMap map = new HashMap();\\n\\n \\/\\/ if\\n \\/\\/ output.write(\\\"YES\\\\n\\\");\\n \\/\\/ else\\n \\/\\/ output.write(\\\"NO\\\\n\\\");\\n\\n \\/\\/ long a =...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alyona has recently bought a miniature fridge that can be represented as a matrix with h rows and 2 columns. Initially there is only one shelf at the bottom of the fridge, but Alyona can install arbitrary number of shelves inside the fridge between any two rows. A shelf is two cells wide, does not occupy any space but separates the inside of the fridge to the lower and upper part.\\n\\n An example of a fridge with h = 7 and two shelves. The shelves are shown in black. The picture corresponds to the first example.\\n\\nAlyona has n bottles of milk that she wants to put in the fridge. The i-th bottle is a_i cells tall and 1 cell wide. She can put a bottle on some shelf if the corresponding space above the shelf is at least as tall as the bottle. She can not put a bottle on top of another bottle (if there is no shelf between them). Two bottles can not share a cell.\\n\\nAlyona is interested in the largest integer k such that she can put bottles 1, 2, ..., k in the fridge at the same time. Find this largest k.\\n\\nInput\\n\\nThe first line contains two integers n and h (1 ≤ n ≤ 10^3, 1 ≤ h ≤ 10^9) — the number of bottles and the height of the fridge.\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ h) — the heights of the bottles.\\n\\nOutput\\n\\nPrint the single integer k — the maximum integer such that Alyona can put the bottles 1, 2, ..., k in the fridge at the same time. If Alyona can put all bottles in the fridge, print n. It is easy to see that Alyona can always put at least one bottle in the fridge.\\n\\nExamples\\n\\nInput\\n\\n\\n5 7\\n2 3 5 4 1\\n\\n\\nOutput\\n\\n\\n3\\n\\n\\nInput\\n\\n\\n10 10\\n9 1 1 1 1 1 1 1 1 1\\n\\n\\nOutput\\n\\n\\n4\\n\\n\\nInput\\n\\n\\n5 10\\n3 1 4 2 4\\n\\n\\nOutput\\n\\n\\n5\\n\\nNote\\n\\nOne of optimal locations in the first example is shown on the picture in the statement.\\n\\nOne of optimal locations in the second example is shown on the picture below.\\n\\n\\n\\nOne of optimal locations in the third example is shown on the picture below.\\n\\n\\n\\nimpo\",\"targets\":\"rt java.io.*;\\nimport java.util.*;\\npublic class Main{\\n static StreamTokenizer in=new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));\\n static int inf=1<<30;\\n public static void main(String args[])throws Exception{\\n int n=getInt();\\n int m=getInt();\\n int arr[]=new int[n];\\n int ans=-1;\\n for(int i=0;i 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 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 str1 = raw_input()\\n lis1 = list(str1)\\n #print(lis1)\\n mat1 = [[x,lis1.count(x)] for x in set(lis1)]\\n for i in range(len(mat1)):\\n if mat1[i][1] > 2:\\n mat1[i][1] = 2\\n ssu = 0\\n for i in range(len(mat1)):\\n ssu += mat1[i][1]\\n print(ssu\\/2)\",\"language\":\"python\",\"split\":\"valid\",\"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\":\"\\/\\/ हर हर महादेव\\nimport java.util.*;\\nimport java.lang.*;\\nimport java.io.*;\\nimport java.math.BigInteger;\\nimport java.text.DecimalFormat;\\n\\npublic final class Solution {\\n\\n static int inf = Integer.MAX_VALUE;\\n static long mod = 1000000000 + 7;\\n \\n static void ne(Scanner sc, BufferedWriter op) throws Exception {\\n int n=sc.nextInt();\\n String one=sc.next();\\n String two=sc.next();\\n int _10=0;\\n int _00=0;\\n int _11=0;\\n int _01=0;\\n for(int i=0;i 0)\\n return true;\\n else\\n return false;\\n }\\n \\n static int gcd(int a, int b)\\n {\\n if (a == 0)\\n return b; \\n return gcd(b % a, a); \\n }\\n \\n\\n public static void main(String[] args) throws Exception {\\n BufferedWriter op = new BufferedWriter(new OutputStreamWriter(System.out));\\n \\/\\/ Reader sc = new Reader();\\n Scanner sc= new Scanner(System.in);\\n int t = sc.nextInt();\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"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...\\nSolve the task in JAVA.\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\n\\npublic class AbsentRemainder {\\n public static void main(String[] args) throws IOException {\\n FastIO fr = new FastIO();\\n PrintWriter pr = new PrintWriter(new OutputStreamWriter(System.out));\\n int t = fr.nextInt();\\n\\n StringBuilder sb = new StringBuilder();\\n\\n while (t-- > 0) {\\n int n = fr.nextInt();\\n\\n int[] arr = new int[n];\\n\\n int min = Integer.MAX_VALUE;\\n\\n for (int i = 0; i < arr.length; i++) {\\n arr[i] = fr.nextInt();\\n min = Math.min(min, arr[i]);\\n }\\n\\n int req = (int) Math.floor(n\\/2);\\n\\n for (int i = 0; i < arr.length && req > 0; i++) {\\n if (arr[i] != min) {\\n req--;\\n sb.append(arr[i] + \\\" \\\" + min + '\\\\n'); \\n }\\n }\\n }\\n\\n pr.println(sb.toString().trim());\\n pr.close();\\n }\\n\\n static class Pair {\\n int x, y;\\n\\n public Pair(int x, int y) {\\n this.x = x;\\n this.y = y;\\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 int[len2];\\n\\n \\/\\/ push to copies\\n for (int i = 0; i < L.length; i++)\\n L[i] = arr[l + i];\\n for (int i = 0; i < R.length; i++) {\\n R[i] = arr[m + 1 + i];\\n }\\n\\n \\/\\/ fill in new array\\n int i = 0, j = 0;\\n int k = l;\\n while (i < len1 && j < len2) {\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A big company decided to launch a new series of rectangular displays, and decided that the display must have exactly n pixels. \\n\\nYour task is to determine the size of the rectangular display — the number of lines (rows) of pixels a and the number of columns of pixels b, so that:\\n\\n * there are exactly n pixels on the display; \\n * the number of rows does not exceed the number of columns, it means a ≤ b; \\n * the difference b - a is as small as possible. \\n\\nInput\\n\\nThe first line contains the positive integer n (1 ≤ n ≤ 106) — the number of pixels display should have.\\n\\nOutput\\n\\nPrint two integers — the number of rows and columns on the display. \\n\\nExamples\\n\\nInput\\n\\n8\\n\\n\\nOutput\\n\\n2 4\\n\\n\\nInput\\n\\n64\\n\\n\\nOutput\\n\\n8 8\\n\\n\\nInput\\n\\n5\\n\\n\\nOutput\\n\\n1 5\\n\\n\\nInput\\n\\n999999\\n\\n\\nOutput\\n\\n999 1001\\n\\nNote\\n\\nIn the first example the minimum possible difference equals 2, so on the display should be 2 rows of 4 pixels.\\n\\nIn the second example the minimum possible difference equals 0, so on the display should be 8 rows of 8 pixels.\\n\\nIn the third example the minimum possible difference equals 4, so on the display should be 1 row of 5 pixels.\\n#!\\/us\",\"targets\":\"r\\/bin\\/python\\nimport math\\n\\nn = input()\\nn = int(n)\\n\\na = {}\\nb = []\\nfor i in range (1,math.ceil(n\\/2) + 1):\\n if n % i == 0:\\n a[i] = int(n\\/i)\\n\\nb = a.keys()\\nb = list(b)\\n\\nl = len(b)\\nm = 10000000000000000\\nindex = 0\\nfor i in range(0,l):\\n t = b[i]\\n n = abs(t - a[t])\\n if n < m:\\n index = t\\n m = n\\n\\nif index > a[index]:\\n index = a[index]\\nprint ('%d %d' %(index,a[index]))\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"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',...\\nSolve the task 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\":\"soltask\",\"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.\",\"targets\":\"#include \\nusing namespace std;\\nvoid solve() {\\n int n;\\n cin >> n;\\n int s = 0;\\n int p = -1;\\n for (int i = 0; i < n; i++) {\\n int x;\\n cin >> x;\\n if (x % 2) p = i;\\n s += x;\\n }\\n for (int i = 2; i < s; i++) {\\n if (s % i == 0) {\\n s = 2;\\n p = -1;\\n }\\n }\\n if (s % 2)\\n cout << n - 1;\\n else\\n cout << n;\\n cout << '\\\\n';\\n for (int i = 0; i < n; i++) {\\n if (i == p) continue;\\n cout << i + 1 << \\\" \\\";\\n }\\n cout << '\\\\n';\\n}\\nsigned main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n int t;\\n cin >> t;\\n while (t--) solve();\\n}\",\"language\":\"python\",\"split\":\"test\",\"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.\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\n\\npublic class Program{\\n static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\\n static PrintWriter pw = new PrintWriter(System.out);\\n static StringTokenizer st = new StringTokenizer(\\\"\\\");\\n static int T, N, a[];\\n static boolean ok;\\n static void dfs(int i, int sum){\\n if(sum == a[N-1]){\\n ok = true;\\n return;\\n }\\n if(ok || i == N-1) return;\\n dfs(i+1, sum);\\n if(ok) return;\\n dfs(i+1, sum + a[i]);\\n if(ok) return;\\n dfs(i+1, sum - a[i]);\\n }\\n public static void main(String args[]) throws IOException{\\n T = nexti();\\n while(T-- > 0){\\n N = nexti();\\n a = new int[N];\\n for(int i = 0; i < N; i++) a[i] = nexti();\\n ok = false;\\n for(int i = 0; i < N; i++){\\n dfs(0, 0);\\n int tmp = a[i];\\n a[i] = a[N-1];\\n a[N-1] = tmp;\\n }\\n pw.println((ok ? \\\"YES\\\" : \\\"NO\\\"));\\n }\\n br.close(); pw.close();\\n }\\n static String next() throws IOException{\\n while(!st.hasMoreTokens()) st = new StringTokenizer(br.readLine());\\n return st.nextToken();\\n }\\n static int nexti() throws IOException{\\n return Integer.parseInt(next());\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"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\\\":\",\"targets\":\"#include \\nusing namespace std;\\nconst char nl = '\\\\n';\\nconst long long inf = 1e9 + 10;\\nconst long long inf2 = 1e18 + 99LL;\\nconst long double inf3 = 1e17;\\nconst long long mod = 1e9 + 7, mod2 = 998244353;\\nconst long double eps = 1e-9;\\nconst bool local = false;\\nconst int logn = 17, maxn = 101, maxm = 200001, maxn2 = 3;\\nvector g[maxn], d, a[maxn];\\nvoid dfs(int v, int p, int cd = 0) {\\n d[cd]++;\\n for (int x : g[v]) {\\n if (x == p) continue;\\n dfs(x, v, cd + 1);\\n }\\n}\\nvoid solve() {\\n int n, k;\\n cin >> n >> k;\\n for (int i = 0; i < n; i++) g[i].clear();\\n for (int i = 0; i < n - 1; i++) {\\n int ta, b;\\n cin >> ta >> b;\\n ta--;\\n b--;\\n g[ta].push_back(b);\\n g[b].push_back(ta);\\n }\\n if (k == 2) {\\n cout << n * (n - 1) \\/ 2 << nl;\\n return;\\n }\\n long long ans = 0;\\n for (int v = 0; v < n; v++) {\\n if ((int)((g[v]).size()) < k) continue;\\n for (int i = 0; i < n; i++) a[i].clear();\\n for (int x : g[v]) {\\n d.assign(n, 0);\\n dfs(x, v);\\n for (int j = 0; j < n; j++) {\\n if (d[j] == 0) break;\\n a[j].push_back(d[j]);\\n }\\n }\\n for (int i = 0; i < n; i++) {\\n if ((int)((a[i]).size()) < k) break;\\n vector> dp((int)((a[i]).size()) + 1,\\n vector(k + 1));\\n dp[0][0] = 1;\\n for (int j = 1; j <= (int)((a[i]).size()); j++) {\\n dp[j][0] = dp[j - 1][0];\\n for (int tk = 1; tk <= k; tk++) {\\n dp[j][tk] = dp[j - 1][tk - 1] * a[i][j - 1] + dp[j - 1][tk];\\n dp[j][tk] %= mod;\\n }\\n }\\n ans += dp.back().back();\\n ans %= mod;\\n }\\n }\\n cout << ans << nl;\\n}\\nint main() {\\n ios::sync_with_stdio(false);\\n cin.tie(NULL);\\n ;\\n int t;\\n cin >> t;\\n while (t--) solve();\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"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.*;\\n\\npublic class CodeForces_1598C {\\n public static void main(String[] args) {\\n Scanner sc = new Scanner(System.in);\\n int numberOfTestCases = sc.nextInt();\\n while (numberOfTestCases-- > 0) {\\n int n = sc.nextInt();\\n int data[] = new int[n];\\n long sum = 0;\\n Map> map = new TreeMap>();\\n for (int i = 0; i < n; i++) {\\n data[i] = sc.nextInt();\\n sum += data[i];\\n if (!map.containsKey(data[i])) {\\n map.put(data[i], new ArrayList<>());\\n }\\n map.get(data[i]).add(i);\\n }\\n if ((2 * sum) % n != 0) {\\n System.out.println(\\\"0\\\");\\n continue;\\n }\\n long temp = (2 * sum) \\/ n;\\n long ans = 0;\\n for (int i = 0; i < n; i++) {\\n int requiredSum = (int) (temp - data[i]);\\n if (map.containsKey(requiredSum)) {\\n List tempList = map.get((int) (temp - data[i]));\\n ans += tempList.size();\\n if (data[i] == requiredSum) {\\n ans--;\\n }\\n }\\n\\n }\\n System.out.println(ans\\/2);\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Broken crypto generator\\n\\nJAG (Japanese Alumni Group) is a mysterious organization composed of many programmers, and in order to enter the building where the headquarters of this organization is located, it is necessary to solve the ciphertext generated by a certain machine every time. This ciphertext consists of the symbols'+','-','[',']' and the uppercase alphabet, and is represented by defined by the following BNF.\\n\\n\\n :: = | \\n :: = |'['']'\\n :: ='+' |'-' |\\n'A' |'B' |'C' |'D' |'E' |'F' |'G' |'H' |'I' |'J' |'K' |'L' |'M '|\\n'N' |'O' |'P' |'Q' |'R' |'S' |'T' |'U' |'V' |'W' |'X' |'Y' |'Z '\\n\\nHere, each symbol has the following meaning.\\n\\n* + (Character): Represents the alphabet following that character (provided that the alphabet following'Z'is'A')\\n*-(Character): Represents the alphabet before that character (provided that the alphabet before'A'is'Z')\\n* [(Character string)]: Represents a character string that is horizontally inverted.\\n\\n\\n\\nHowever, the machine that generates this ciphertext is currently out of order, and some letters of the alphabet in the ciphertext may be broken and unreadable. Unreadable characters are tentatively represented as'?'. As a result of the investigation, it was found that the method of filling the broken characters is such that the decrypted character string is the smallest in the dictionary order among the possible character strings after decoding. Your job is to decrypt this ciphertext correctly.\\n\\nInput\\n\\nThe input consists of multiple datasets. Each dataset consists of one line containing a string in which some uppercase letters have been replaced with ‘?’ In the ciphertext defined by BNF above. You can assume that the length of each string is less than $ 80 $. You can also assume that the number of'?' In each dataset is greater than or equal to $ 0 $ and less than or equal to $ 3 $.\\n\\nThe end of the input is represented by a line containing only one character,'.'.\\n\\nOutput\\n\\nFor each data set,...\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\n#define REP(i,n) for(int i=0; i<(int)(n); ++i)\\n\\nusing namespace std;\\nint k;\\nstring s;\\nvoid pass(char c) {\\n assert(s[k++] == c);\\n}\\nstring str();\\nstring letter();\\nstring cipher() {\\n string res;\\n while(k < s.size() && s[k] != ']') {\\n res += str();\\n }\\n if(k < s.size()) {\\n pass(']');\\n }\\n return res;\\n}\\n\\nstring str() {\\n if(s[k] == '[') {\\n pass('[');\\n string t = cipher();\\n reverse(t.begin(), t.end());\\n return t;\\n }\\n return letter();\\n}\\n\\nstring letter() {\\n int add = 0;\\n while(!('A' <= s[k] && s[k] <= 'Z') && s[k] != '?') {\\n if(s[k] == '+') {\\n add += 1;\\n } else if(s[k] == '-') {\\n add -= 1;\\n } else {\\n assert(false);\\n }\\n k++;\\n }\\n string t = s.substr(k, 1);\\n pass(t[0]);\\n if(t[0] != '?') {\\n t[0] = (t[0] - 'A' + add + 26 * 1000) % 26 + 'A';\\n }\\n return t;\\n}\\n\\nint main(){\\n while(cin >> s && s != \\\".\\\") {\\n k = 0;\\n string t = cipher();\\n for(char& c : t) if(c == '?') c = 'A';\\n cout << t << endl;\\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?\\nFacetook is a well known social network website, and it will launch a new feature called Facetook Priority Wall. This feature will sort all posts from your friends according to the priority factor (it will be described).\\n\\nThis priority factor will be affected by three types of actions: \\n\\n * 1. \\\"X posted on Y's wall\\\" (15 points), \\n * 2. \\\"X commented on Y's post\\\" (10 points), \\n * 3. \\\"X likes Y's post\\\" (5 points). \\n\\n\\n\\nX and Y will be two distinct names. And each action will increase the priority factor between X and Y (and vice versa) by the above value of points (the priority factor between X and Y is the same as the priority factor between Y and X).\\n\\nYou will be given n actions with the above format (without the action number and the number of points), and you have to print all the distinct names in these actions sorted according to the priority factor with you.\\n\\nInput\\n\\nThe first line contains your name. The second line contains an integer n, which is the number of actions (1 ≤ n ≤ 100). Then n lines follow, it is guaranteed that each one contains exactly 1 action in the format given above. There is exactly one space between each two words in a line, and there are no extra spaces. All the letters are lowercase. All names in the input will consist of at least 1 letter and at most 10 small Latin letters.\\n\\nOutput\\n\\nPrint m lines, where m is the number of distinct names in the input (excluding yourself). Each line should contain just 1 name. The names should be sorted according to the priority factor with you in the descending order (the highest priority factor should come first). If two or more names have the same priority factor, print them in the alphabetical (lexicographical) order.\\n\\nNote, that you should output all the names that are present in the input data (excluding yourself), even if that person has a zero priority factor.\\n\\nThe lexicographical comparison is performed by the standard \\\"<\\\" operator in modern programming languages. The line a is lexicographically smaller than the line b, if either a is the...\",\"targets\":\"#include \\nusing namespace std;\\nstring change(string s) {\\n string tmp = \\\"\\\";\\n for (int i = 0; i < s.size(); i++) {\\n string cur = \\\"\\\";\\n cur += s[i];\\n cur += s[i + 1];\\n if (cur == \\\"'s\\\") break;\\n tmp += s[i];\\n }\\n return tmp;\\n}\\nbool cmp(pair p1, pair p2) {\\n if (p1.second != p2.second) return p1.second > p2.second;\\n return p1.first < p2.first;\\n}\\nint main() {\\n string me;\\n cin >> me;\\n int n;\\n cin >> n;\\n cin.ignore();\\n string s;\\n vector > ans;\\n map cnt;\\n while (n--) {\\n getline(cin, s);\\n vector tmp;\\n string cur = \\\"\\\";\\n for (int i = 0; i < s.size(); i++) {\\n if (s[i] == ' ') {\\n tmp.push_back(cur);\\n cur = \\\"\\\";\\n continue;\\n }\\n cur += s[i];\\n }\\n tmp.push_back(cur);\\n if (tmp[1] == \\\"posted\\\" || tmp[1] == \\\"commented\\\") {\\n if (cnt.find(tmp[0]) == cnt.end()) cnt[tmp[0]] = 0;\\n string str = change(tmp[3]);\\n if (cnt.find(str) == cnt.end()) cnt[str] = 0;\\n if (tmp[1] == \\\"posted\\\") {\\n if (tmp[0] == me) cnt[str] += 15;\\n if (str == me) cnt[tmp[0]] += 15;\\n }\\n if (tmp[1] == \\\"commented\\\") {\\n if (tmp[0] == me) cnt[str] += 10;\\n if (str == me) cnt[tmp[0]] += 10;\\n }\\n } else if (tmp[1] == \\\"likes\\\") {\\n if (cnt.find(tmp[0]) == cnt.end()) cnt[tmp[0]] = 0;\\n string str = change(tmp[2]);\\n if (cnt.find(str) == cnt.end()) cnt[str] = 0;\\n if (tmp[0] == me) cnt[str] += 5;\\n if (str == me) cnt[tmp[0]] += 5;\\n }\\n }\\n map::iterator it;\\n for (it = cnt.begin(); it != cnt.end(); it++)\\n ans.push_back(make_pair(it->first, it->second));\\n sort(ans.begin(), ans.end(), cmp);\\n for (int i = 0; i < ans.size(); i++) {\\n if (ans[i].first == me) continue;\\n cout << ans[i].first << \\\"\\\\n\\\";\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"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\\nUsing java can you solve the prior task?\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\n\\npublic class Codeforces\\n{\\n public static void main(String args[])throws Exception\\n {\\n BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));\\n StringBuilder sb=new StringBuilder();\\n String s[]=bu.readLine().split(\\\" \\\");\\n int n=Integer.parseInt(s[0]),m=Integer.parseInt(s[1]);\\n st=new int[4*m]; l=new int[4*m];\\n\\n int i,j,a[][]=new int[n][3];\\n PriorityQueue pq=new PriorityQueue<>(new Comparator() {\\n @Override\\n public int compare(int[] o1, int[] o2) {\\n if(o1[2]>o2[2]) return 1;\\n else return -1;\\n }});\\n for(i=0;i0)\\n {\\n ans=Math.min(ans,a[i][2]-a[l][2]);\\n update(0,m-1,a[l][0],a[l][1],-1,0);\\n l++;\\n }\\n if(query(0,m-1,0,m-2,0)>0) ans=Math.min(ans,a[i][2]-a[l][2]);\\n }\\n System.out.print(ans);\\n }\\n\\n static int l[],st[];\\n static void update(int ss,int se,int us,int ue,int v,int n)\\n {\\n if(l[n]!=0)\\n {\\n st[n]+=l[n];\\n if(ss!=se) {l[2*n+1]+=l[n]; l[2*n+2]+=l[n];}\\n l[n]=0;\\n }\\n\\n if(ss>se || ss>ue || se=se)\\n {\\n st[n]+=v;\\n if(ss!=se) {l[2*n+1]+=v; l[2*n+2]+=v;}\\n return;\\n }\\n\\n int m=(ss+se)\\/2;\\n update(ss,m,us,ue,v,2*n+1);\\n update(m+1,se,us,ue,v,2*n+2);\\n st[n]=Math.min(st[2*n+1],st[2*n+2]);\\n }\\n\\n static int query(int ss,int se,int qs,int qe,int n)\\n {\\n if(l[n]!=0)\\n {\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"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.\",\"targets\":\"n=int(input())\\nfor _ in range(n):\\n s=input()\\n ab=s.count('ab')\\n ba=s.count('ba')\\n #print(ab,ba)\\n if ab==ba:\\n print(s)\\n else:\\n if s[0]=='a':\\n x='b'\\n y=s[1:]\\n else:\\n x='a'\\n y=s[1:]\\n print(x+y)\\n '''\\n elif if abs(ab-ba)==1:\\n if ab>ba:\\n x=0\\n y=0\\n for i in range(n-1):\\n print(s[i],'all')\\n if s[i]=='a' and s[i+1]=='b':\\n x+=1\\n elif s[i]=='b' and s[i+1]=='a':\\n y+=1\\n elif ba>ab:\\n x=0\\n y=0\\n for i in range(n-1):\\n print(s[i],'all')\\n if s[i]=='a' and s[i+1]=='b':\\n x+=1\\n elif s[i]=='b' and s[i+1]=='a':\\n y+=1\\n else:\\n x=0\\n y=0\\n for i in range(n-1):\\n print(s[i],'all')\\n if s[i]=='a' and s[i+1]=='b':\\n x+=1\\n elif s[i]=='b' and s[i+1]=='a':\\n y+=1\\n if x==y:\\n pass\\n else:\\n '''\",\"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 JAVA.\",\"targets\":\"import java.util.*;\\nimport java.lang.*;\\nimport java.io.*;\\nimport java.awt.*;\\n\\n\\/*AUTHOR - SHIVAM GUPTA *\\/\\n\\n\\/\\/ U KNOW THAT IF THIS DAY WILL BE URS THEN NO ONE CAN DEFEAT U HERE ,JUst keep faith in ur strengths .................................................. \\n\\/\\/ ASCII = 48 + i ;\\/\\/ 2^28 = 268,435,456 > 2* 10^8 \\/\\/ log 10 base 2 = 3.3219 \\n\\/\\/ odd:: (x^2+1)\\/2 , (x^2-1)\\/2 ; x>=3\\/\\/ even:: (x^2\\/4)+1 ,(x^2\\/4)-1 x >=4 \\n\\/\\/ FOR ANY ODD NO N : N,N-1,N-2,ALL ARE PAIRWISE COPRIME,THEIR COMBINED LCM IS PRODUCT OF ALL THESE NOS\\n\\/\\/ two consecutive odds are always coprime to each other, two consecutive even have always gcd = 2 ;\\n\\n\\/\\/ Rectangle r = new Rectangle(int x , int y,int widht,int height) \\n\\/\\/Creates a rect. with bottom left cordinates as (x, y) and top right as ((x+width),(y+height))\\n\\n\\/\\/BY DEFAULT Priority Queue is MIN in nature in java\\n\\/\\/to use as max , just push with negative sign and change sign after removal \\n\\n\\/\\/ We can make a sieve of max size 1e7 .(no time or space issue) \\n\\/\\/ In 1e7 starting nos we have about 66*1e4 prime nos\\n\\/\\/ In 1e6 starting nos we have about 78,498 prime nos\\n\\n public class Main\\n \\/\\/public class Solution\\n{\\n static PrintWriter out;\\n \\n\\tstatic class FastReader{\\n\\t\\tBufferedReader br;\\n\\t\\tStringTokenizer st;\\n\\t\\tpublic FastReader(){\\n\\t\\t\\tbr=new BufferedReader(new InputStreamReader(System.in));\\n\\t\\t\\tout=new PrintWriter(System.out);\\n\\t\\t}\\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}\\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\\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\\tdouble nextDouble(){\\n\\t\\t\\treturn Double.parseDouble(next());\\n\\t\\t}\\n\\t\\tString nextLine(){\\n\\t\\t\\tString str = \\\"\\\";\\n\\t\\t\\ttry{\\n\\t\\t\\t\\tstr=br.readLine();\\n\\t\\t\\t}\\n\\t\\t\\tcatch(IOException e){\\n\\t\\t\\t\\te.printStackTrace();\\n\\t\\t\\t}\\n\\t\\t\\treturn str;\\n\\t\\t}\\n\\t}\\n\\t\\n\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\n public static int...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A new delivery of clothing has arrived today to the clothing store. This delivery consists of a ties, b scarves, c vests and d jackets.\\n\\nThe store does not sell single clothing items — instead, it sells suits of two types:\\n\\n * a suit of the first type consists of one tie and one jacket; \\n * a suit of the second type consists of one scarf, one vest and one jacket. \\n\\n\\n\\nEach suit of the first type costs e coins, and each suit of the second type costs f coins.\\n\\nCalculate the maximum possible cost of a set of suits that can be composed from the delivered clothing items. Note that one item cannot be used in more than one suit (though some items may be left unused).\\n\\nInput\\n\\nThe first line contains one integer a (1 ≤ a ≤ 100 000) — the number of ties.\\n\\nThe second line contains one integer b (1 ≤ b ≤ 100 000) — the number of scarves.\\n\\nThe third line contains one integer c (1 ≤ c ≤ 100 000) — the number of vests.\\n\\nThe fourth line contains one integer d (1 ≤ d ≤ 100 000) — the number of jackets.\\n\\nThe fifth line contains one integer e (1 ≤ e ≤ 1 000) — the cost of one suit of the first type.\\n\\nThe sixth line contains one integer f (1 ≤ f ≤ 1 000) — the cost of one suit of the second type.\\n\\nOutput\\n\\nPrint one integer — the maximum total cost of some set of suits that can be composed from the delivered items. \\n\\nExamples\\n\\nInput\\n\\n\\n4\\n5\\n6\\n3\\n1\\n2\\n\\n\\nOutput\\n\\n\\n6\\n\\n\\nInput\\n\\n\\n12\\n11\\n13\\n20\\n4\\n6\\n\\n\\nOutput\\n\\n\\n102\\n\\n\\nInput\\n\\n\\n17\\n14\\n5\\n21\\n15\\n17\\n\\n\\nOutput\\n\\n\\n325\\n\\nNote\\n\\nIt is possible to compose three suits of the second type in the first example, and their total cost will be 6. Since all jackets will be used, it's impossible to add anything to this set.\\n\\nThe best course of action in the second example is to compose nine suits of the first type and eleven suits of the second type. The total cost is 9 ⋅ 4 + 11 ⋅ 6 = 102.\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"#from statistics import median\\n#import collections\\n#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]\\n# from math import gcd\\n# from itertools import combinations,permutations,accumulate, product # (string,3) 3回\\n# #from collections import deque\\n# from collections import deque,defaultdict,Counter\\n# import decimal\\n# import re\\n# import math\\n# import bisect\\n# import heapq\\n#\\n#\\n#\\n# pythonで無理なときは、pypyでやると正解するかも!!\\n#\\n#\\n# my_round_int = lambda x:np.round((x*2 + 1)\\/\\/2)\\n# 四捨五入g\\n#\\n# インデックス系\\n# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);\\n# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);\\n#\\n#\\nimport sys\\nsys.setrecursionlimit(10000000)\\nmod = 10**9 + 7\\n#mod = 9982443453\\n#mod = 998244353\\nINF = float('inf')\\nfrom sys import stdin\\nreadline = stdin.readline\\ndef readInts():\\n return list(map(int,readline().split()))\\ndef readTuples():\\n return tuple(map(int,readline().split()))\\ndef I():\\n return int(readline())\\na = I()\\nb = I()\\nc = I()\\nd = I()\\ne = I()\\nf = I()\\nif e >= f:\\n first = min(a,d)\\n a -= first; d -= first\\n second = min(b,c,d)\\n print(first * e + second * f)\\nelse:\\n second = min(b,c,d)\\n b -= second; c -= second; d -= second;\\n first = min(a,d)\\n print(first * e + second * f)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\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\":\"#include \\nusing namespace std;\\nconst int MAXN = 305;\\nint a[MAXN * MAXN], bit[MAXN * MAXN], x[MAXN][MAXN], n, m;\\npair b[MAXN * MAXN];\\nint baris(int x) { return (x + m - 1) \\/ m; }\\nvoid update(int now, int val) {\\n for (int i = now; i <= n * m; i += (i & (-i))) bit[i] += val;\\n}\\nint query(int now) {\\n int ret = 0;\\n for (int i = now; i > 0; i -= (i & (-i))) ret += bit[i];\\n return ret;\\n}\\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 cin >> n >> m;\\n for (int i = 1; i <= n * m; i++) {\\n cin >> a[i];\\n b[i] = {a[i], i};\\n }\\n sort(b + 1, b + n * m + 1);\\n int last = 1;\\n for (int i = 1; i <= n * m; i++) {\\n if (i == n * m || b[i].first != b[i + 1].first) {\\n vector v;\\n int last2 = last;\\n for (int j = last; j <= i; j++) {\\n v.push_back(b[j].second);\\n if (j == i || baris(j) != baris(j + 1)) {\\n sort(v.begin(), v.end());\\n reverse(v.begin(), v.end());\\n for (int k = last2; k <= j; k++) {\\n int col = k - (baris(k) - 1) * m;\\n x[baris(k)][col] = v[k - last2];\\n }\\n last2 = j + 1;\\n v.clear();\\n }\\n }\\n last = i + 1;\\n }\\n }\\n long long ans = 0;\\n for (int i = 1; i <= n; i++) {\\n for (int j = 1; j <= m; j++) {\\n ans += query(x[i][j] - 1);\\n update(x[i][j], 1);\\n }\\n for (int j = 1; j <= m; j++) {\\n update(x[i][j], -1);\\n }\\n }\\n cout << ans << '\\\\n';\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"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\":\"import java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.util.StringTokenizer;\\n\\npublic class Solution3 {\\n static StringBuilder sb;\\n public static void main(String[] args) throws IOException {\\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\\n sb = new StringBuilder();\\n int T = Integer.parseInt(br.readLine());\\n for (int i = 0; i < T; i++) {\\n \\/\\/algorithms\\n StringTokenizer st = new StringTokenizer(br.readLine());\\n int a = Integer.parseInt(st.nextToken());\\n int b = Integer.parseInt(st.nextToken());\\n int c = Integer.parseInt(st.nextToken());\\n sb.append(solve(a,b,c)+\\\"\\\\n\\\");\\n }\\n System.out.println(sb);\\n }\\n\\n static private int solve(int a, int b, int key) {\\n int numA, numB;\\n if (a > b) {\\n numA = b;\\n numB = a;\\n }else {\\n numA = a;\\n numB = b;\\n }\\n int size = (numB - numA) * 2;\\n if (numB <= size && key <= size) {\\n return ((key + numB - numA - 1) % size) + 1;\\n }\\n else {\\n return -1;\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"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\\nSolve the task in PYTHON3.\",\"targets\":\"import math\\ncases = int(input())\\nwhile cases!=0:\\n cases-=1\\n k = int(input())\\n def nextPerfectSquare(N):\\n nextN = math.floor(math.sqrt(N)) + 1\\n return nextN\\n def checkperfectsquare(x):\\n \\n # If ceil and floor are equal\\n # the number is a perfect\\n # square\\n if (math.ceil(math.sqrt(x)) ==\\n math.floor(math.sqrt(x))):\\n return True\\n else:\\n return False\\n if checkperfectsquare(k):\\n print(int(math.sqrt(k)),1,sep=' ')\\n elif k > nextPerfectSquare(k)**2 - nextPerfectSquare(k):\\n print(nextPerfectSquare(k),nextPerfectSquare(k)**2 - k+1,sep=' ')\\n else:\\n print(k-(nextPerfectSquare(k)-1)**2,nextPerfectSquare(k),sep=\\\" \\\")\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"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...\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\nimport static java.lang.Math.*;\\n\\npublic class Main {\\n public static void main(String[]args) throws IOException {\\n int T = sc.nextInt();\\n while(T-- > 0){\\n int a = sc.nextInt(), b = sc.nextInt();\\n int tt = a + b, na = (tt + 1) >> 1, nb = tt >> 1;\\n Set l = new TreeSet<>();\\n for(int i = max(0, a - nb), k = min(a, na); i <= k; i++){\\n int bk = a + na - 2 * i;\\n l.add(bk);\\n l.add(tt - bk);\\n }\\n System.out.println(l.size());\\n for(int e : l){\\n System.out.print(e);\\n System.out.print(\\\" \\\");\\n }\\n System.out.println();\\n }\\n }\\n}\\nclass sc {\\n static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));\\n static StringTokenizer tokenizer = new StringTokenizer(\\\"\\\");\\n static String nextLine() throws IOException{\\n return reader.readLine();\\n }\\n static String next() throws IOException {\\n while (!tokenizer.hasMoreTokens()) {\\n tokenizer = new StringTokenizer(reader.readLine());\\n }\\n return tokenizer.nextToken();\\n }\\n static int nextInt() throws IOException {\\n return Integer.parseInt(next());\\n }\\n static double nextDouble() throws IOException {\\n return Double.parseDouble(next());\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"As many of you know, we have two major calendar systems used in Japan today. One of them is Gregorian calendar which is widely used across the world. It is also known as “Western calendar” in Japan.\\n\\nThe other calendar system is era-based calendar, or so-called “Japanese calendar.” This system comes from ancient Chinese systems. Recently in Japan it has been a common way to associate dates with the Emperors. In the era-based system, we represent a year with an era name given at the time a new Emperor assumes the throne. If the era name is “A”, the first regnal year will be “A 1”, the second year will be “A 2”, and so forth.\\n\\nSince we have two different calendar systems, it is often needed to convert the date in one calendar system to the other. In this problem, you are asked to write a program that converts western year to era-based year, given a database that contains association between several western years and era-based years.\\n\\nFor the simplicity, you can assume the following:\\n\\n1. A new era always begins on January 1st of the corresponding Gregorian year.\\n2. The first year of an era is described as 1.\\n3. There is no year in which more than one era switch takes place.\\n\\n\\n\\nPlease note that, however, the database you will see may be incomplete. In other words, some era that existed in the history may be missing from your data. So you will also have to detect the cases where you cannot determine exactly which era the given year belongs to.\\n\\n\\n\\nInput\\n\\nThe input contains multiple test cases. Each test case has the following format:\\n\\nN Q\\nEraName1 EraBasedYear1 WesternYear1\\n.\\n.\\n.\\nEraNameN EraBasedYearN WesternYearN\\nQuery1 .\\n.\\n.\\nQueryQ\\n\\nThe first line of the input contains two positive integers N and Q (1 ≤ N ≤ 1000, 1 ≤ Q ≤ 1000). N is the number of database entries, and Q is the number of queries.\\n\\nEach of the following N lines has three components: era name, era-based year number and the corresponding western year (1 ≤ EraBasedYeari ≤ WesternYeari ≤ 109 ). Each of era names consist of at most 16 Roman alphabet...\\nUsing python3 can you solve the prior task?\",\"targets\":\"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 \\/ 10**10\\nmod = 998244353\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n rr = []\\n\\n dd = [(1,1),(1,0),(0,1),(0,-1),(-1,0),(-1,-1)]\\n\\n while True:\\n n,q = LI()\\n if n == 0 and q == 0:\\n break\\n a = [LS() for _ in range(n)]\\n a = [[_[0],int(_[1]),int(_[2])] for _ in a]\\n b = [I() for _ in range(q)]\\n for c in b:\\n r = 'Unknown'\\n for l,e,w in a:\\n if w-e < c <= w:\\n r = '{} {}'.format(l, e-w+c)\\n rr.append(r)\\n\\n return '\\\\n'.join(map(str, rr))\\n\\n\\nprint(main())\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"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...\",\"targets\":\"#include \\nusing namespace std;\\ntemplate \\nostream& operator<<(ostream& out, const pair& a) {\\n return out << \\\"(\\\" << a.first << \\\", \\\" << a.second << \\\")\\\";\\n}\\ntemplate \\nostream& operator<<(ostream& out, const vector& v) {\\n out << \\\"[\\\";\\n for (int i = 0; i < v.size(); i++) {\\n if (i) out << \\\", \\\";\\n out << v[i];\\n }\\n return out << \\\"]\\\";\\n}\\nvoid deb(istream_iterator it) {}\\ntemplate \\nvoid deb(istream_iterator it, T a, Args... args) {\\n cout << *it << \\\" = \\\" << a << ' ';\\n deb(++it, args...);\\n}\\nint Set(int n, int pos) { return 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)); }\\nmt19937 mt_rand(\\n chrono::high_resolution_clock::now().time_since_epoch().count());\\nconst int N = 5002;\\nconst int M = 1000006;\\nvoid solve() {\\n int n;\\n cin >> n;\\n vector > a(n);\\n set > st;\\n for (int i = 0; i < n; i++) {\\n cin >> a[i].first >> a[i].second;\\n st.insert({a[i].first, a[i].second});\\n }\\n for (int i = 0; i < n; i++) {\\n if (a[i].first == a[i].second) {\\n cout << a[i].first << ' ' << a[i].second << ' ' << a[i].second << '\\\\n';\\n continue;\\n }\\n for (int j = a[i].first; j <= a[i].second; j++) {\\n vector > v;\\n if (a[i].first <= j - 1) v.emplace_back(a[i].first, j - 1);\\n if (j + 1 <= a[i].second) v.emplace_back(j + 1, a[i].second);\\n if (v.size() == 1 && st.find(v[0]) != st.end()) {\\n cout << a[i].first << ' ' << a[i].second << ' ' << j << '\\\\n';\\n break;\\n } else if (st.find(v[0]) != st.end() && st.find(v[1]) != st.end()) {\\n cout << a[i].first << ' ' << a[i].second << ' ' << j << '\\\\n';\\n break;\\n }\\n }\\n }\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n int q = 1;\\n cin >> q;\\n for (int kase = 1; kase <= q; kase++) {\\n solve();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"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\\nSolve the task in JAVA.\",\"targets\":\"import java.io.*;\\nimport java.math.*;\\nimport java.util.*;\\n\\n\\n\\/\\/ @author : Dinosparton \\n\\npublic class test {\\n\\t \\n\\t static class Pair{ \\n\\t\\t long x;\\n\\t\\t long y;\\n\\t\\t \\n\\t\\t Pair(long x,long y){ \\n\\t\\t\\t this.x = x;\\n\\t\\t\\t this.y = y;\\n\\t\\t\\t \\n\\t\\t }\\n\\t }\\n\\t \\n\\t static class Sort implements Comparator\\n\\t {\\n\\n\\t @Override\\n\\t public int compare(Pair a, Pair b)\\n\\t {\\n\\t if(a.x!=b.x)\\n\\t {\\n\\t return (int)(a.x - b.x);\\n\\t }\\n\\t else\\n\\t {\\n\\t return (int)(a.y-b.y);\\n\\t }\\n\\t }\\n\\t }\\n\\t \\n\\t static class Compare { \\n\\t\\t \\n\\t\\t void compare(Pair arr[], int n) \\n\\t\\t { \\n\\t\\t \\/\\/ Comparator to sort the pair according to second element \\n\\t\\t Arrays.sort(arr, new Comparator() { \\n\\t\\t @Override public int compare(Pair p1, Pair p2) \\n\\t\\t { \\n\\t\\t \\tif(p1.x!=p2.x) {\\n\\t\\t return (int)(p1.x - p2.x); \\n\\t\\t \\t}\\n\\t\\t \\telse { \\n\\t\\t \\t\\treturn (int)(p1.y - p2.y);\\n\\t\\t \\t}\\n\\t\\t } \\n\\t\\t }); \\n\\t\\t \\n\\/\\/\\t\\t for (int i = 0; i < n; i++) { \\n\\/\\/\\t\\t System.out.print(arr[i].x + \\\" \\\" + arr[i].y + \\\" \\\"); \\n\\/\\/\\t\\t } \\n\\/\\/\\t\\t System.out.println(); \\n\\t\\t } \\n\\t\\t} \\n\\t \\n\\t static class Scanner {\\n\\t BufferedReader br;\\n\\t StringTokenizer st;\\n\\t \\n\\t public Scanner()\\n\\t {\\n\\t br = new BufferedReader(\\n\\t new InputStreamReader(System.in));\\n\\t }\\n\\t \\n\\t String next()\\n\\t {\\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 \\n\\t int nextInt() { return Integer.parseInt(next()); }\\n\\t \\n\\t long nextLong() { return Long.parseLong(next()); }\\n\\t \\n\\t double nextDouble()\\n\\t {\\n\\t return...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in PYTHON3?\\nYou 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\":\"import bisect\\nimport collections\\nimport copy\\nimport fractions\\nimport functools\\nimport heapq\\nimport math\\nimport random\\nimport sys\\n\\n\\ndef _p(str):\\n sys.stdout.write(str+'\\\\n')\\ndef _i():\\n return sys.stdin.readline()\\n\\ndef steps_needed(i, D, A):\\n orig_i = i\\n\\n visited = set()\\n zero_seen = False\\n while True:\\n if i in visited:\\n break\\n visited.add(i)\\n if A[i] == 0:\\n zero_seen = True\\n break\\n i += D\\n i %= len(A)\\n\\n if not zero_seen:\\n return -1\\n\\n i = orig_i\\n zeroes_visited = set()\\n steps, max_steps = 0, 0\\n while True:\\n if i in zeroes_visited:\\n return max(steps, max_steps)\\n if A[i] == 0:\\n zeroes_visited.add(i)\\n max_steps = max(steps, max_steps)\\n steps = 0\\n if A[i] == 1:\\n steps += 1\\n\\n i += D\\n i %= len(A)\\n\\nif __name__ == '__main__':\\n\\n T = int(_i())\\n\\n for t in range(T):\\n N, D = tuple(map(int, _i().split()))\\n A = list(map(int, _i().split()))\\n\\n GCD = math.gcd(N, D)\\n ring_size = N \\/\\/ GCD\\n\\n steps_by_ring = [steps_needed(i, D, A) for i in range(GCD)]\\n if any(st == -1 for st in steps_by_ring):\\n _p('-1')\\n else:\\n _p(str(max(steps_by_ring)))\\n\\n sys.stdout.flush()\",\"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;\\nbool F(long long a, long long b) {\\n long long c = (a + b) \\/ 2;\\n return (c % a) == (b % c);\\n}\\nvoid SMF() {\\n long long a, b;\\n cin >> a >> b;\\n if (a > b) {\\n cout << a + b << \\\"\\\\n\\\";\\n return;\\n }\\n if (a == b) {\\n cout << a << \\\"\\\\n\\\";\\n return;\\n }\\n cout << b - (((a + b) \\/ 2) % a) << \\\"\\\\n\\\";\\n}\\nint main() {\\n long long CT = 1;\\n cin >> CT;\\n while (CT--) SMF();\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Filled with optimism, Hyunuk will host a conference about how great this new year will be!\\n\\nThe conference will have n lectures. Hyunuk has two candidate venues a and b. For each of the n lectures, the speaker specified two time intervals [sa_i, ea_i] (sa_i ≤ ea_i) and [sb_i, eb_i] (sb_i ≤ eb_i). If the conference is situated in venue a, the lecture will be held from sa_i to ea_i, and if the conference is situated in venue b, the lecture will be held from sb_i to eb_i. Hyunuk will choose one of these venues and all lectures will be held at that venue.\\n\\nTwo lectures are said to overlap if they share any point in time in common. Formally, a lecture held in interval [x, y] overlaps with a lecture held in interval [u, v] if and only if max(x, u) ≤ min(y, v).\\n\\nWe say that a participant can attend a subset s of the lectures if the lectures in s do not pairwise overlap (i.e. no two lectures overlap). Note that the possibility of attending may depend on whether Hyunuk selected venue a or venue b to hold the conference.\\n\\nA subset of lectures s is said to be venue-sensitive if, for one of the venues, the participant can attend s, but for the other venue, the participant cannot attend s.\\n\\nA venue-sensitive set is problematic for a participant who is interested in attending the lectures in s because the participant cannot be sure whether the lecture times will overlap. Hyunuk will be happy if and only if there are no venue-sensitive sets. Determine whether Hyunuk will be happy.\\n\\nInput\\n\\nThe first line contains an integer n (1 ≤ n ≤ 100 000), the number of lectures held in the conference.\\n\\nEach of the next n lines contains four integers sa_i, ea_i, sb_i, eb_i (1 ≤ sa_i, ea_i, sb_i, eb_i ≤ 10^9, sa_i ≤ ea_i, sb_i ≤ eb_i).\\n\\nOutput\\n\\nPrint \\\"YES\\\" if Hyunuk will be happy. Print \\\"NO\\\" otherwise.\\n\\nYou can print each letter in any case (upper or lower).\\n\\nExamples\\n\\nInput\\n\\n\\n2\\n1 2 3 6\\n3 4 7 8\\n\\n\\nOutput\\n\\n\\nYES\\n\\n\\nInput\\n\\n\\n3\\n1 3 2 4\\n4 5 6 7\\n3 4 5 5\\n\\n\\nOutput\\n\\n\\nNO\\n\\n\\nInput\\n\\n\\n6\\n1 5 2 9\\n2 4 5 8\\n3 6 7 11\\n7 10 12 16\\n8 11 13 17\\n9 12 14...\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nconst int mod = 1e9 + 7;\\nconst int maxn = 1e5 + 5;\\nint M;\\nstruct Bit {\\n int f[maxn * 4];\\n void add(int x) {\\n while (x <= M) {\\n f[x]++;\\n x += x & (-x);\\n }\\n }\\n int qry(int x) {\\n int res = 0;\\n while (x > 0) {\\n res += f[x];\\n x -= x & (-x);\\n }\\n return res;\\n }\\n void init() { memset(f, 0, sizeof(f)); }\\n} stl, edl, str, edr;\\nstruct lect {\\n int sa, ea, sb, eb;\\n} F[maxn];\\nvector w;\\nvector g[maxn * 4];\\nint c0[maxn], c1[maxn], c2[maxn];\\nint main() {\\n int n;\\n scanf(\\\"%d\\\", &n);\\n for (int i = 1; i <= n; ++i) {\\n scanf(\\\"%d%d%d%d\\\", &F[i].sa, &F[i].ea, &F[i].sb, &F[i].eb);\\n w.push_back(F[i].sa);\\n w.push_back(F[i].ea);\\n w.push_back(F[i].sb);\\n w.push_back(F[i].eb);\\n }\\n sort(w.begin(), w.end());\\n w.erase(unique(w.begin(), w.end()), w.end());\\n M = w.size();\\n for (int i = 1; i <= n; ++i) {\\n F[i].sa = lower_bound(w.begin(), w.end(), F[i].sa) - w.begin() + 1;\\n F[i].ea = lower_bound(w.begin(), w.end(), F[i].ea) - w.begin() + 1;\\n F[i].sb = lower_bound(w.begin(), w.end(), F[i].sb) - w.begin() + 1;\\n F[i].eb = lower_bound(w.begin(), w.end(), F[i].eb) - w.begin() + 1;\\n }\\n for (int i = 1; i <= n; ++i) {\\n g[F[i].sa].push_back(-i);\\n g[F[i].ea].push_back(i);\\n }\\n for (int i = 1; i <= M; ++i) {\\n for (auto e : g[i]) {\\n if (e < 0) {\\n int x = edl.qry(F[-e].eb) - stl.qry(F[-e].sb - 1);\\n c2[-e] -= x;\\n }\\n }\\n for (auto e : g[i]) {\\n if (e < 0) {\\n edr.add(F[-e].sb);\\n str.add(F[-e].eb);\\n } else {\\n edl.add(F[e].sb);\\n stl.add(F[e].eb);\\n }\\n }\\n for (auto e : g[i]) {\\n if (e > 0) {\\n int x = edr.qry(F[e].eb) - str.qry(F[e].sb - 1);\\n c2[e] += x;\\n }\\n }\\n }\\n stl.init();\\n edl.init();\\n str.init();\\n edr.init();\\n for (int i = 1; i <= n; ++i) {\\n edl.add(F[i].sa);\\n stl.add(F[i].ea);\\n edr.add(F[i].sb);\\n str.add(F[i].eb);\\n }\\n for (int i = 1; i <= n; ++i) {\\n c0[i] = edl.qry(F[i].ea) - stl.qry(F[i].sa -...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A median in an array with the length of n is an element which occupies position number after we sort the elements in the non-decreasing order (the array elements are numbered starting with 1). A median of an array (2, 6, 1, 2, 3) is the number 2, and a median of array (0, 96, 17, 23) — the number 17.\\n\\nWe define an expression as the integer part of dividing number a by number b.\\n\\nOne day Vasya showed Petya an array consisting of n integers and suggested finding the array's median. Petya didn't even look at the array and said that it equals x. Petya is a very honest boy, so he decided to add several numbers to the given array so that the median of the resulting array would be equal to x.\\n\\nPetya can add any integers from 1 to 105 to the array, including the same numbers. Of course, he can add nothing to the array. If a number is added multiple times, then we should consider it the number of times it occurs. It is not allowed to delete of change initial numbers of the array. \\n\\nWhile Petya is busy distracting Vasya, your task is to find the minimum number of elements he will need.\\n\\nInput\\n\\nThe first input line contains two space-separated integers n and x (1 ≤ n ≤ 500, 1 ≤ x ≤ 105) — the initial array's length and the required median's value. The second line contains n space-separated numbers — the initial array. The elements of the array are integers from 1 to 105. The array elements are not necessarily different.\\n\\nOutput\\n\\nPrint the only integer — the minimum number of elements Petya needs to add to the array so that its median equals x.\\n\\nExamples\\n\\nInput\\n\\n3 10\\n10 20 30\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\n3 4\\n1 2 3\\n\\n\\nOutput\\n\\n4\\n\\nNote\\n\\nIn the first sample we can add number 9 to array (10, 20, 30). The resulting array (9, 10, 20, 30) will have a median in position , that is, 10.\\n\\nIn the second sample you should add numbers 4, 5, 5, 5. The resulting array has median equal to 4.\\nUsing python can you solve the prior task?\",\"targets\":\"I=lambda:map(int,raw_input().split())\\nn,x=I()\\na=sorted(I())\\nl=3*[0]\\nfor i in a: l[cmp(i,x)]+=1\\nk=a[(n-1)\\/2]\\nprint 2*l[2]-n+1 if kx else 0\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nMike is a bartender at Rico's bar. At Rico's, they put beer glasses in a special shelf. There are n kinds of beer at Rico's numbered from 1 to n. i-th kind of beer has ai milliliters of foam on it.\\n\\n\\n\\nMaxim is Mike's boss. Today he told Mike to perform q queries. Initially the shelf is empty. In each request, Maxim gives him a number x. If beer number x is already in the shelf, then Mike should remove it from the shelf, otherwise he should put it in the shelf.\\n\\nAfter each query, Mike should tell him the score of the shelf. Bears are geeks. So they think that the score of a shelf is the number of pairs (i, j) of glasses in the shelf such that i < j and where is the greatest common divisor of numbers a and b.\\n\\nMike is tired. So he asked you to help him in performing these requests.\\n\\nInput\\n\\nThe first line of input contains numbers n and q (1 ≤ n, q ≤ 2 × 105), the number of different kinds of beer and number of queries.\\n\\nThe next line contains n space separated integers, a1, a2, ... , an (1 ≤ ai ≤ 5 × 105), the height of foam in top of each kind of beer.\\n\\nThe next q lines contain the queries. Each query consists of a single integer integer x (1 ≤ x ≤ n), the index of a beer that should be added or removed from the shelf.\\n\\nOutput\\n\\nFor each query, print the answer for that query in one line.\\n\\nExamples\\n\\nInput\\n\\n5 6\\n1 2 3 4 6\\n1\\n2\\n3\\n4\\n5\\n1\\n\\n\\nOutput\\n\\n0\\n1\\n3\\n5\\n6\\n2\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 200010;\\nconst int W = 500010;\\nint n, q, a[N], p[W], ptot, mu[W], cnt[W];\\nbool np[W], vis[N];\\nlong long ans;\\nvoid add(int x, bool y) {\\n if (y) {\\n ans += mu[x] * (cnt[x] * 2 + 1);\\n ++cnt[x];\\n } else {\\n ans -= mu[x] * (cnt[x] * 2 - 1);\\n --cnt[x];\\n }\\n}\\nvoid modify(int x, bool y) {\\n if (x == 1) {\\n if (y)\\n --ans;\\n else\\n ++ans;\\n }\\n for (int i = 1; i * i <= x; ++i) {\\n if (x % i == 0) {\\n add(i, y);\\n if (i * i != x) add(x \\/ i, y);\\n }\\n }\\n}\\nint main() {\\n mu[1] = 1;\\n for (int i = 2; i < W; ++i) {\\n if (!np[i]) {\\n p[++ptot] = i;\\n mu[i] = -1;\\n }\\n for (int j = 1; j <= ptot && i * p[j] < W; ++j) {\\n int x = i * p[j];\\n np[x] = true;\\n if (i % p[j])\\n mu[x] = -mu[i];\\n else\\n break;\\n }\\n }\\n scanf(\\\"%d%d\\\", &n, &q);\\n for (int i = 1; i <= n; ++i) scanf(\\\"%d\\\", a + i);\\n while (q--) {\\n int x;\\n scanf(\\\"%d\\\", &x);\\n modify(a[x], vis[x] ^= 1);\\n printf(\\\"%I64d\\\\n\\\", ans \\/ 2);\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"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...\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nconst int inf = 1 << 30;\\nconst long long mod = 1e9 + 7;\\nconst long long linf = 1e18;\\nconst double EPS = 1e-10;\\nconst double pi = acos(-1);\\ntemplate \\nvoid chmin(T& x, T y) {\\n if (x > y) x = y;\\n}\\ntemplate \\nvoid chmax(T& x, T y) {\\n if (x < y) x = y;\\n}\\nvoid solve() {\\n int n;\\n cin >> n;\\n vector a(n);\\n for (int i = 0; i < n; i++) cin >> a[i];\\n sort(a.begin(), a.end());\\n for (int i = 1; i <= n \\/ 2; i++) {\\n cout << a[i] << \\\" \\\" << a[0] << endl;\\n }\\n}\\nint main() {\\n cin.tie(nullptr);\\n ios_base::sync_with_stdio(false);\\n cout << fixed << setprecision(20);\\n int t;\\n cin >> t;\\n while (t--) {\\n solve();\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"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.util.*;\\nimport java.io.*;\\n\\npublic class D_1582 {\\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 t = sc.nextInt();\\n\\t\\twhile(t-->0) {\\n\\t\\t\\tint n = sc.nextInt();\\n\\t\\t\\tint[] a = sc.nextIntArray(n);\\n\\t\\t\\t\\n\\t\\t\\tArrayList[] list = new ArrayList[(int)2e4+1];\\n\\t\\t\\tfor(int i = 0; i < list.length; i++)\\n\\t\\t\\t\\tlist[i] = new ArrayList<>();\\n\\t\\t\\t\\n\\t\\t\\tfor(int i = 0; i < n; i++)\\n\\t\\t\\t\\tlist[a[i] + (int)1e4].add(i);\\n\\t\\t\\t\\n\\t\\t\\tArrayList ones = new ArrayList<>();\\n\\t\\t\\tfor(int i = 0; i < list.length; i++)\\n\\t\\t\\t\\tif(list[i].size() == 1) {\\n\\t\\t\\t\\t\\tfor(int j : list[i])\\n\\t\\t\\t\\t\\t\\tones.add(j);\\n\\t\\t\\t\\t\\tlist[i] = new ArrayList<>();\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\n\\t\\t\\tif(ones.size() == 1) {\\n\\t\\t\\t\\tfor(int i = 0; i < list.length; i++) {\\n\\t\\t\\t\\t\\tif(list[i].size() == 2) {\\n\\t\\t\\t\\t\\t\\tfor(int j : list[i])\\n\\t\\t\\t\\t\\t\\t\\tones.add(j);\\n\\t\\t\\t\\t\\t\\tlist[i] = new ArrayList<>();\\n\\t\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t\\t} else if(list[i].size() > 2) {\\n\\t\\t\\t\\t\\t\\tint x = list[i].get(list[i].size() - 1);\\n\\t\\t\\t\\t\\t\\tones.add(x);\\n\\t\\t\\t\\t\\t\\tlist[i].remove(list[i].size() - 1);\\n\\t\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\t\\n\\t\\t\\tint[] b = new int[n];\\n\\t\\t\\tint index = 0;\\n\\t\\t\\tif(ones.size() % 2 == 1) {\\n\\t\\t\\t\\tint x = ones.get(0), y = ones.get(1), z = ones.get(2);\\n\\t\\t\\t\\tb[x] = 2 * a[y] * a[z];\\n\\t\\t\\t\\tb[y] = -1 * a[x] * a[z];\\n\\t\\t\\t\\tb[z] = -1 * a[x] * a[y];\\n\\t\\t\\t\\tindex = 3;\\n\\t\\t\\t}\\n\\t\\t\\tfor(int i = index; i < ones.size(); i += 2) {\\n\\t\\t\\t\\tint x = ones.get(i), y = ones.get(i + 1);\\n\\t\\t\\t\\tb[x] = a[y];\\n\\t\\t\\t\\tb[y] = -1 * a[x];\\n\\t\\t\\t}\\n\\t\\t\\tfor(int i = 0; i < list.length; i++) {\\n\\t\\t\\t\\tif(list[i].size() > 0) {\\n\\t\\t\\t\\t\\tfor(int j = 0; j < list[i].size() - 1; j++)\\n\\t\\t\\t\\t\\t\\tb[list[i].get(j)] = 1;\\n\\t\\t\\t\\t\\tb[list[i].get(list[i].size() - 1)] = -1 * (list[i].size() - 1);\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\t\\n\\t\\t\\tfor(int i = 0; i < n; i++)\\n\\t\\t\\t\\tpw.print(b[i] + (i == n - 1 ? \\\"\\\\n\\\" : \\\" \\\"));\\n\\t\\t}\\n\\t\\t\\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...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"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.\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\nimport java.math.BigInteger;\\n \\npublic class code{\\n \\n static class Reader\\n {\\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(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 {\\n if (c == '\\\\n')\\n break;\\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 boolean neg = (c == '-');\\n if (neg)\\n c = read();\\n do\\n {\\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 }\\n while ((c = read()) >= '0' && c <= '9');\\n if (neg)\\n return -ret;\\n return ret;\\n }\\n \\n public double...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"As everyone knows, bears love fish. But Mike is a strange bear; He hates fish! The even more strange thing about him is he has an infinite number of blue and red fish. \\n\\n\\n\\nHe has marked n distinct points in the plane. i-th point is point (xi, yi). He wants to put exactly one fish in each of these points such that the difference between the number of red fish and the blue fish on each horizontal or vertical line is at most 1.\\n\\nHe can't find a way to perform that! Please help him.\\n\\nInput\\n\\nThe first line of input contains integer n (1 ≤ n ≤ 2 × 105).\\n\\nThe next n lines contain the information about the points, i-th line contains two integers xi and yi (1 ≤ xi, yi ≤ 2 × 105), the i-th point coordinates.\\n\\nIt is guaranteed that there is at least one valid answer.\\n\\nOutput\\n\\nPrint the answer as a sequence of n characters 'r' (for red) or 'b' (for blue) where i-th character denotes the color of the fish in the i-th point.\\n\\nExamples\\n\\nInput\\n\\n4\\n1 1\\n1 2\\n2 1\\n2 2\\n\\n\\nOutput\\n\\nbrrb\\n\\n\\nInput\\n\\n3\\n1 1\\n1 2\\n2 1\\n\\n\\nOutput\\n\\nbrr\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nconst int MAXN = 1 << 19;\\nconst int MAXC = 1 << 18;\\nstruct edge {\\n int v;\\n int id;\\n bool rev;\\n edge(int a, int b, bool c) : v(a), id(b), rev(c) {}\\n};\\nvector g[MAXN];\\nint color[MAXN];\\nbool vis[MAXN];\\nbool path[MAXN];\\nint edgePos[MAXN];\\nint diff[MAXN];\\nvoid addEdge(int x, int y, int id) {\\n g[x].push_back(edge(y, id, false));\\n g[y].push_back(edge(x, id, true));\\n}\\nvoid markEdge(const edge& e, bool reversed = false) {\\n color[e.id] = ((e.rev != reversed) ? -1 : 1);\\n}\\nint colorCycleDfs(int u) {\\n int backTarget = -1;\\n path[u] = true;\\n for (int& i = edgePos[u]; i < g[u].size(); ++i) {\\n const edge& e = g[u][i];\\n if (!vis[e.id]) {\\n vis[e.id] = true;\\n if (path[e.v]) {\\n markEdge(e);\\n backTarget = e.v;\\n break;\\n }\\n int back = colorCycleDfs(e.v);\\n if (back >= 0) {\\n markEdge(e);\\n if (back != u) {\\n backTarget = back;\\n break;\\n }\\n }\\n }\\n }\\n path[u] = false;\\n return backTarget;\\n}\\nvoid treeDfs(int u) {\\n if (vis[u]) return;\\n vis[u] = true;\\n for (int i = 0; i < g[u].size(); ++i) {\\n const edge& e = g[u][i];\\n if (!vis[e.v] && color[e.id] == 0) {\\n if (diff[u] > 0) {\\n diff[u]--;\\n diff[e.v]++;\\n markEdge(e, true);\\n } else {\\n diff[u]++;\\n diff[e.v]--;\\n markEdge(e);\\n }\\n treeDfs(e.v);\\n }\\n }\\n}\\nint main() {\\n ios::sync_with_stdio(false);\\n int n;\\n cin >> n;\\n set vs;\\n for (int i = 0; i < n; ++i) {\\n int x, y;\\n cin >> x >> y;\\n y += MAXC;\\n vs.insert(x);\\n vs.insert(y);\\n addEdge(x, y, i);\\n }\\n for (int s : vs) colorCycleDfs(s);\\n memset(vis, 0, sizeof(vis));\\n for (int s : vs) {\\n if (!vis[s]) treeDfs(s);\\n }\\n for (int i = 0; i < n; ++i)\\n cout << (color[i] == 1 ? 'r' : (color[i] == -1 ? 'b' : '?'));\\n cout << endl;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP 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\":\"#include \\nusing namespace std;\\nconst long long N = 22;\\nconst long long M = 1e6 + 11;\\nconst long long big = 1e17;\\nconst long long hsh2 = 1964325029;\\nconst long long mod = 1e9 + 7;\\nconst double EPS = 1e-9;\\nconst long long block = 1e14;\\nconst long long shift = 2e3;\\nconst double pi = acos(-1.0);\\nmt19937 bruh(chrono::steady_clock::now().time_since_epoch().count());\\nlong long t;\\nint main() {\\n ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);\\n cin >> t;\\n while (t--) {\\n string a;\\n cin >> a;\\n long long d[3] = {0};\\n for (auto u : a) d[u - 'A']++;\\n cout << (d[0] + d[2] == d[1] ? \\\"YES\\\\n\\\" : \\\"No\\\\n\\\");\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"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...\\nUsing python3 can you solve the prior task?\",\"targets\":\"from sys import stdin\\nimport math\\n\\n\\ndef main():\\n t = int(stdin.readline())\\n for i in range(t):\\n x = stdin.readline().split()\\n n = int(x[0])\\n h = int(x[1])\\n # print(i,n,h)\\n arr = stdin.readline().split()\\n for j in range(n):\\n arr[j] = int(arr[j])\\n arr.append(int(1e40))\\n if n == 1:\\n print(h)\\n continue\\n l = 0\\n r = int(1e18)+1\\n while r-l>1:\\n dmg = 0\\n mid = (r+l) \\/\\/ 2\\n for j in range(n):\\n tmp = arr[j+1] - arr[j]\\n dmg += min(tmp, mid)\\n if dmg < h:\\n l = mid\\n else:\\n r = mid\\n print(r)\\n return\\n\\nmain()\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nYelisey 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...\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.File;\\nimport java.io.FileInputStream;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.io.PrintStream;\\nimport java.io.PrintWriter;\\nimport java.time.Duration;\\nimport java.time.Instant;\\nimport java.util.ArrayList;\\nimport java.util.Arrays;\\nimport java.util.Collections;\\nimport java.util.StringTokenizer;\\nimport static java.lang.Math.min;\\nimport static java.lang.Math.max;\\nimport static java.lang.Math.abs;\\n\\n@SuppressWarnings(\\\"unused\\\")\\npublic class D {\\n\\tstatic boolean DEBUG = false;\\n\\n\\tpublic static void main(String[] args) throws IOException {\\n\\t\\tInstant start = Instant.now();\\n\\t\\tif (args.length == 2) {\\n\\t\\t\\tSystem.setIn(new FileInputStream(new File(\\\"D:\\\\\\\\program\\\\\\\\javaCPEclipse\\\\\\\\CodeForces\\\\\\\\src\\\\\\\\input.txt\\\")));\\n\\t\\t\\t\\/\\/ System.setOut(new PrintStream(new File(\\\"output.txt\\\")));\\n\\t\\t\\tSystem.setErr(new PrintStream(new File(\\\"D:\\\\\\\\program\\\\\\\\javaCPEclipse\\\\\\\\CodeForces\\\\\\\\src\\\\\\\\error.txt\\\")));\\n\\t\\t\\tDEBUG = true;\\n\\t\\t}\\n\\t\\tReader fs = new Reader();\\n\\t\\tPrintWriter pw = new PrintWriter(System.out);\\n\\t\\tint t = fs.nextInt();\\n\\t\\twhile (t-- > 0) {\\n\\t\\t\\tint n = fs.nextInt();\\n\\t\\t\\tArrayLista = new ArrayList();\\n\\t\\t\\tfor(int i = 0 ; i < n ; i++) {\\n\\t\\t\\t\\ta.add(fs.nextInt());\\n\\t\\t\\t}\\n\\t\\t\\tCollections.sort(a);\\n\\t\\t\\tLazySegTree lst = new LazySegTree(n);\\n\\t\\t\\tfor(int i = 0 ; i < n ; i++) {\\n\\t\\t\\t\\tlst.update(i, i, a.get(i));\\n\\t\\t\\t}\\n\\t\\t\\tint ans= Integer.MIN_VALUE;\\n\\t\\t\\tfor(int i = 0 ; i < n; i++) {\\n\\t\\t\\t\\tint temp = lst.query(i, n-1);\\n\\t\\t\\t\\tans = max(ans, temp);\\n\\t\\t\\t\\tlst.update(i+1, n-1, -temp);\\n\\t\\t\\t}\\n\\t\\t\\tpw.println(ans);\\n\\t\\t}\\n\\t\\tInstant end = Instant.now();\\n\\t\\tif (DEBUG) {\\n\\t\\t\\tpw.println(Duration.between(start, end));\\n\\t\\t}\\n\\t\\tpw.close();\\n\\t}\\n\\n\\tpublic static void print(long a, long b, long c, PrintWriter pw) {\\n\\t\\tpw.println(a + \\\" \\\" + b + \\\" \\\" + c);\\n\\t\\treturn;\\n\\t}\\n\\n\\tstatic class Reader {\\n\\t\\tBufferedReader br;\\n\\t\\tStringTokenizer st;\\n\\n\\t\\tpublic Reader() {\\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...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"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.\\n#incl\",\"targets\":\"ude \\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 << endl;\\n}\\ntemplate \\nvoid __f(const char* names, Arg1&& arg1, Args&&... args) {\\n int64_t 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 (((int64_t)(s).size())) {\\n freopen((s + \\\".in\\\").c_str(), \\\"r\\\", stdin);\\n freopen((s + \\\".out\\\").c_str(), \\\"w\\\", stdout);\\n }\\n}\\nconst int64_t dx[] = {1, -1, 0, 0};\\nconst int64_t dy[] = {0, 0, 1, -1};\\nconst int64_t N = 500;\\nvector g[N * N], color(N*N, -1);\\n;\\nvector vis(N* N, false);\\nvoid end() {\\n cout << \\\"NO\\\";\\n exit(0);\\n}\\nint64_t id(pair p) { return N * p.first + p.second; };\\nint64_t...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.\\n\\nb4ab979900ed647703389d4349eb84ee.png\\n\\nConstraints\\n\\n* x and y are integers.\\n* 1 ≤ x < y ≤ 12\\n\\nInput\\n\\nInput is given from Standard Input in the following format:\\n\\n\\nx y\\n\\n\\nOutput\\n\\nIf x and y belong to the same group, print `Yes`; otherwise, print `No`.\\n\\nExamples\\n\\nInput\\n\\n1 3\\n\\n\\nOutput\\n\\nYes\\n\\n\\nInput\\n\\n2 4\\n\\n\\nOutput\\n\\nNo\\nUsing python3 can you solve the prior task?\",\"targets\":\"g=[1,3,1,2,1,2,1,1,2,1,2,1]\\na,b=map(int,input().split())\\nprint(\\\"Yes\\\" if g[a-1] == g[b-1] else \\\"No\\\")\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"In the city of Nevermore, there are 10^8 streets and 10^8 avenues, both numbered from 0 to 10^8-1. All streets run straight from west to east, and all avenues run straight from south to north. The distance between neighboring streets and between neighboring avenues is exactly 100 meters.\\n\\nEvery street intersects every avenue. Every intersection can be described by pair (x, y), where x is avenue ID and y is street ID.\\n\\nThere are N fountains in the city, situated at intersections (X_i, Y_i). Unlike normal intersections, there's a circle with radius 10 meters centered at the intersection, and there are no road parts inside this circle.\\n\\nThe picture below shows an example of how a part of the city with roads and fountains may look like.\\n\\n1f931bf0c98ec6f07e612b0282cdb094.png\\n\\nCity governors don't like encountering more than one fountain while moving along the same road. Therefore, every street contains at most one fountain on it, as well as every avenue.\\n\\nCitizens can move along streets, avenues and fountain perimeters. What is the shortest distance one needs to cover in order to get from intersection (x_1, y_1) to intersection (x_2, y_2)?\\n\\nConstraints\\n\\n* 0 \\\\leq x_1, y_1, x_2, y_2 < 10^8\\n* 1 \\\\leq N \\\\leq 200,000\\n* 0 \\\\leq X_i, Y_i < 10^8\\n* X_i \\\\neq X_j for i \\\\neq j\\n* Y_i \\\\neq Y_j for i \\\\neq j\\n* Intersections (x_1, y_1) and (x_2, y_2) are different and don't contain fountains.\\n* All input values are integers.\\n\\nInput\\n\\nInput is given from Standard Input in the following format:\\n\\n\\nx_1 y_1 x_2 y_2\\nN\\nX_1 Y_1\\nX_2 Y_2\\n:\\nX_N Y_N\\n\\n\\nOutput\\n\\nPrint the shortest possible distance one needs to cover in order to get from intersection (x_1, y_1) to intersection (x_2, y_2), in meters. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{-11}.\\n\\nExamples\\n\\nInput\\n\\n1 1 6 5\\n3\\n3 2\\n5 3\\n2 4\\n\\n\\nOutput\\n\\n891.415926535897938\\n\\n\\nInput\\n\\n3 5 6 4\\n3\\n3 2\\n5 3\\n2 4\\n\\n\\nOutput\\n\\n400.000000000000000\\n\\n\\nInput\\n\\n4 2 2 2\\n3\\n3 2\\n5 3\\n2 4\\n\\n\\nOutput\\n\\n211.415926535897938\\\":\",\"targets\":\"#include\\n#define mp(a,b) make_pair((a),(b))\\n#define pii pair\\n\\/\\/#define pdd pair\\n#define pll pair\\n#define pb(x) push_back(x)\\n#define x first\\n#define y second\\n#define sqr(x) ((x)*(x))\\n#define EPS 1e-8\\n#define mii map\\n#define MEM(x) memset(x,0,sizeof(x))\\n#define MEMS(x) memset(x,-1,sizeof(x))\\n#define N 500005\\n\\/\\/#define M 1000005\\n#define pi 3.14159265358979323846 \\n#define cpdd const pdd\\n#define hash Hash\\n#define list List\\nusing namespace std;\\ntypedef long long LL;\\nusing namespace std;\\nchar c[200005];\\nint main(){\\n\\tint x1,y1,x2,y2;\\n\\tscanf(\\\"%d %d %d %d\\\",&x1,&y1,&x2,&y2);\\n\\tdouble sub=20-pi*5;\\n\\tdouble add=pi*10-20;\\n\\tif(x2y2){\\n\\t\\ty1=-y1;\\n\\t\\ty2=-y2;\\n\\t\\tfor(int i=0;i v;\\n\\tv.pb(-1e9);\\n\\t{\\n\\t\\tint i;\\n\\t\\tfor(i=0;i=x1)\\n\\t\\tbreak;\\n\\t\\tfor(;iy2)\\n\\t\\t\\tcontinue;\\n\\t\\t\\tif(v.back()min(y2-y1,x2-x1)){\\n\\t\\t\\/\\/printf(\\\"%d %d\\\\n\\\",tot,y2-y1);\\n\\t\\tans+=-sub*min(y2-y1,x2-x1)+add;\\n\\t}\\n\\telse{\\n\\t\\tans-=sub*(tot);\\n\\t}\\n\\tprintf(\\\"%.15lf\\\\n\\\",ans);\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nThe 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\":\"import java.util.*;\\nimport java.io.*;\\npublic class E {\\n\\n\\tpublic static void main(String[] args) {\\n\\t\\tFastScanner sc = new FastScanner();\\n\\t\\tStringBuilder sb = new StringBuilder();\\n\\t\\t\\tint n = sc.nextInt();\\n\\t\\t\\tint k = sc.nextInt();\\n\\t\\t\\tint[] p = new int[n];\\n\\t\\t\\tArrays.fill(p, -1);\\n\\t\\t\\tint[][] res = new int[n][2];\\n\\t\\t\\tfor(int i = 0; i < n; i++) {\\n\\t\\t\\t\\tArrays.fill(res[i], -1);\\n\\t\\t\\t}\\n\\t\\t\\tint iter = ceil(n, k);\\n\\t\\t\\tfor(int i = 0; i < n*k; i++) {\\n\\t\\t\\t\\tint c = sc.nextInt()-1;\\n\\t\\t\\t\\tif(p[c] >= 0 && res[c][0] < 0) {\\n\\t\\t\\t\\t\\tres[c][0] = p[c];\\n\\t\\t\\t\\t\\tres[c][1] = i;\\n\\t\\t\\t\\t\\titer--;\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tif(iter == 0) {\\n\\t\\t\\t\\t\\tArrays.fill(p, -1);\\n\\t\\t\\t\\t\\titer = ceil(n, k);\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\telse {\\n\\t\\t\\t\\t\\tp[c] = i;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\tfor(int i = 0; i < n; i++) {\\n\\t\\t\\t\\tsb.append(String.format(\\\"%d %d\\\\n\\\", res[i][0]+1, res[i][1]+1));\\n\\t\\t\\t}\\n\\t\\tPrintWriter pw = new PrintWriter(System.out);\\n\\t\\tpw.println(sb.toString().trim());\\n\\t\\tpw.flush();\\n\\t}\\n\\tstatic int ceil(int n, int k) {\\n\\t\\tint res = n \\/ (k-1);\\n\\t\\tif(n % (k-1) != 0) res++;\\n\\t\\treturn res;\\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\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"It is a complicated version of problem F1. 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 ≤ 10).\\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\\n6\\n2021 3\\n177890 2\\n34512 3\\n724533 4\\n998244353 1\\n12345678 10\\n\\n\\nOutput\\n\\n\\n2021\\n181111\\n34533\\n724542\\n999999999\\n12345678\\nimpor\",\"targets\":\"t itertools\\nfrom sys import maxsize, stdout, stdin,stderr\\nmod = int(1e9+7)\\nimport sys\\ndef I(): return int(stdin.readline())\\ndef lint(): return [int(x) for x in stdin.readline().split()]\\ndef S(): return list(map(str,input().strip()))\\ndef grid(r, c): return [lint() for i in range(r)]\\nfrom collections import defaultdict, Counter, deque\\nimport math\\nimport heapq\\nfrom heapq import heappop , heappush\\nimport bisect\\nfrom itertools import groupby\\nfrom itertools import permutations as comb\\ndef gcd(a,b): \\n while b:\\n a %= b\\n tmp = a\\n a = b\\n b = tmp\\n \\n return a\\n \\ndef lcm(a,b): \\n return a \\/\\/ gcd(a, b) * b\\n \\ndef check_prime(n):\\n for i in range(2, int(n ** (1 \\/ 2)) + 1):\\n if not n % i:\\n return False\\n return True\\n\\ndef nCr(n, r):\\n \\n return (fact(n) \\/\\/ (fact(r)\\n * fact(n - r)))\\n \\n# Returns factorial of n\\ndef fact(n):\\n \\n res = 1\\n \\n for i in range(2, n+1):\\n res = res * i\\n \\n return res\\ndef primefactors(n):\\n num=0\\n \\n while n % 2 == 0:\\n num+=1\\n n = n \\/ 2\\n \\n for i in range(3,int(math.sqrt(n))+1,2):\\n \\n \\n while n % i== 0:\\n num+=1\\n n = n \\/\\/ i\\n \\n \\n if n > 2:\\n num+=1\\n return num\\n'''\\ndef iter_ds(src):\\n store=[src]\\n while len(store):\\n tmp=store.pop()\\n if not vis[tmp]:\\n vis[tmp]=True\\n for j in ar[tmp]:\\n store.append(j)\\n'''\\ndef ask(a):\\n print('? {}'.format(a),flush=True)\\n n=I()\\n \\n return n\\ndef linear_sieve(n):\\n is_composite=[False]*n\\n prime=[]\\n for i in range(2,n):\\n if not is_composite[i]:\\n prime.append(i)\\n for j in prime:\\n is_composite[i*j]=True\\n if i%prime==0:\\n break\\n return prime\\n \\ndef dfs(i,p,d):\\n \\n a,tmp=0,0\\n for j in d[i]:\\n if j!=p:\\n a+=1\\n tmp+=dfs(j,i)\\n \\n if a==0:\\n return 0\\n \\n return tmp\\/a + 1 \\ndef primeFactors(n):\\n l=[]\\n \\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"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\":\"#!\\/usr\\/bin\\/env python\\nfrom __future__ import division, print_function\\n\\nimport os\\nimport sys\\nfrom io import BytesIO, IOBase\\n\\nif sys.version_info[0] < 3:\\n from __builtin__ import xrange as range\\n from future_builtins import ascii, filter, hex, map, oct, zip\\n\\n\\ndef main():\\n t = int(input())\\n\\n for _ in range(t):\\n m = int(input())\\n a1 = [int(ai1) for ai1 in input().split()]\\n a2 = [int(ai2) for ai2 in input().split()]\\n\\n pref_a1 = [0] * (m + 1)\\n pref_a2 = [0] * (m + 1)\\n for i in range(m):\\n pref_a1[i + 1] = pref_a1[i] + a1[i]\\n pref_a2[i + 1] = pref_a2[i] + a2[i]\\n\\n sol = float('inf')\\n for i in range(m):\\n sol = min(sol, max(\\n pref_a1[-1] - pref_a1[i + 1],\\n pref_a2[i],\\n ))\\n\\n print(sol)\\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...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"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\":\"\\/\\/package Codeforces.Round749Div1_2;\\n\\nimport java.io.*;\\nimport java.util.*;\\n\\npublic class D {\\n public static void main(String[] args) throws IOException {\\n Soumit sc = new Soumit();\\n\\n int n = sc.nextInt();\\n int[] arr = new int[n];\\n int[] query = new int[n];\\n\\n \\/\\/find the last index\\n for(int i=1;i<=n;i++){\\n StringBuilder sb = new StringBuilder();\\n sb.append(\\\"? \\\");\\n for(int j=1;j0){\\n arr[n-1] = n+1-i;\\n break;\\n }\\n }\\n\\n if(arr[n-1]==0)\\n arr[n-1] = 1;\\n\\n for(int i=n;i>=1;i--){\\n StringBuilder sb = new StringBuilder();\\n sb.append(\\\"? \\\");\\n for(int j=1;j0){\\n arr[input-1] = n+1-i;\\n }\\n }\\n\\n for(int i=0;i a=new Stack();\\n\\t\\tint count=0;\\n\\t\\tif(sequence.charAt(0)=='('){\\n\\t\\ta.push(sequence.charAt(0));\\n\\t\\tcount++;}\\n\\t\\tint i=1;\\n\\t\\twhile(!a.isEmpty()||contains(sequence,i)){\\n\\t\\t\\tif(i==sequence.length())\\n\\t\\t\\t\\tbreak;\\n\\t\\t\\tif(sequence.charAt(i)=='('){\\n\\t\\t\\t\\ta.push('(');\\n\\t\\t\\t\\tcount++;}\\n\\t\\t\\telse{ \\n\\t\\t\\t\\tif(!a.isEmpty()){ \\n\\t\\t\\t\\tcount++; \\n\\t\\t\\t\\ta.pop();}\\n\\t\\t\\t}\\n\\t\\t\\t\\n\\t\\ti++;\\n\\t\\tif(i==sequence.length())\\n\\t\\t\\tbreak;\\n\\t\\t}\\n\\t\\tif(a.isEmpty())\\n\\tSystem.out.println(count);\\n\\t\\telse if(a.size()>=1)\\n\\t\\t\\tSystem.out.println(count-a.size());\\n\\t\\telse System.out.println(0);\\n\\t\\n}\\n\\n\\tprivate static boolean contains(String sequence, int i) {\\n\\t\\tfor(int j=i;j\\nusing namespace std;\\nlong long pow2(long long i) { return 1LL << i; }\\nlong long topbit(signed t) { return t == 0 ? -1 : 31 - __builtin_clz(t); }\\nlong long topbit(long long t) { return t == 0 ? -1 : 63 - __builtin_clzll(t); }\\nlong long lowbit(signed a) { return a == 0 ? 32 : __builtin_ctz(a); }\\nlong long lowbit(long long a) { return a == 0 ? 64 : __builtin_ctzll(a); }\\nlong long allbit(long long n) { return (1LL << n) - 1; }\\nlong long popcount(signed t) { return __builtin_popcount(t); }\\nlong long popcount(long long t) { return __builtin_popcountll(t); }\\nbool ispow2(long long i) { return i && (i & -i) == i; }\\ntemplate \\nT POW(T x, long long n) {\\n T res = 1;\\n for (; n; n >>= 1, x *= x)\\n if (n & 1) res *= x;\\n return res;\\n}\\ninline long long max(long long x, long long y) { return (x < y) ? y : x; }\\ninline long long min(long long x, long long y) { return (x < y) ? x : y; }\\ninline long long read() {\\n register long long a = 0, po = 1;\\n char ch = getchar();\\n while (!isdigit(ch) && ch != '-') ch = getchar();\\n if (ch == '-') po = -1, ch = getchar();\\n while (isdigit(ch)) a = (a << 1) + (a << 3) + ch - 48, ch = getchar();\\n return a * po;\\n}\\nvoid write(long long x) {\\n if (x < 0) putchar('-'), x = -x;\\n if (x > 9) write(x \\/ 10);\\n putchar(x % 10 + '0');\\n return;\\n}\\nlong long gcd(long long x, long long y) {\\n while (x % y) {\\n long long temp = x % y;\\n x = y, y = temp;\\n }\\n return y;\\n}\\nlong long mgml(long long a, long long b, long long mod) {\\n long long temp = 1;\\n while (b) {\\n if (b % 2) {\\n temp = temp * a % mod;\\n }\\n a = a * a % mod;\\n b \\/= 2;\\n }\\n return temp;\\n}\\nlong long exgcd(long long a, long long b, long long &x, long long &y) {\\n long long ret, tmp;\\n if (!b) {\\n x = 1;\\n y = 0;\\n return a;\\n }\\n ret = exgcd(b, a % b, x, y);\\n tmp = x;\\n x = y;\\n y = tmp - a \\/ b * y;\\n return ret;\\n}\\nlong long lcm(long long x, long long y) { return (x * y) \\/ gcd(x, y); }\\nlong long fac[100009], inv[100009], MXNC = 100005;\\nlong long mod = 1000000007;\\nvoid init() {\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"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 CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst long long INF = 1e9 + 7;\\nconst long long MOD = 998244353;\\nconst long long inf = INF * INF;\\nconst long long mod = MOD;\\nconst long long MAX = 1000010;\\nconst long double PI = acos(-1.0);\\nsigned main() {\\n long long n, k;\\n cin >> n >> k;\\n vector a(n), b(n);\\n for (long long i = (0); i < (n - 1); i++) {\\n cout << \\\"and \\\" << 1 << ' ' << i + 2 << '\\\\n';\\n cin >> a[i + 1];\\n cout << \\\"or \\\" << 1 << ' ' << i + 2 << '\\\\n';\\n cin >> b[i + 1];\\n }\\n long long d;\\n cout << \\\"and 2 3\\\" << '\\\\n';\\n cin >> d;\\n vector c(n);\\n long long an = a[1], o = b[1];\\n for (long long i = (1); i < (n); i++) {\\n an |= a[i];\\n o &= b[i];\\n }\\n for (long long j = (0); j < (32); j++) {\\n if ((1 << j) & o) {\\n if ((an & (1 << j)))\\n c[0] += (1 << j);\\n else if (((1 << j) & d) == 0)\\n c[0] += (1 << j);\\n }\\n }\\n for (long long i = (1); i < (n); i++) {\\n c[i] = (b[i] - a[i]) ^ c[0];\\n }\\n sort(c.begin(), c.end());\\n cout << \\\"finish \\\" << c[k - 1] << '\\\\n';\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"C --Dowsing Machine\\n\\nStory\\n\\nPeople make noise with X and Y, but the coming era will be \\\"D\\\". \\\"Paklin Monster D\\\" is a very popular game in which \\\"D people\\\" search for treasure using the \\\"D machine\\\" developed by the secret society \\\"R team\\\".\\n\\nIn this game, the person D in the square with the grid map repeatedly moves to the adjacent squares up, down, left, and right, aiming to reach the square where the treasure exists. There is only one square on the map where the treasure exists. Since the square where the treasure exists has not been clarified, I would like to use the D machine to narrow down the squares where the treasure exists and then move to the square where the treasure exists.\\n\\nWhen using the D machine, it shows the reaction to multiple squares including the square where the treasure exists. The reaction is expressed based on the square where the D person was when using the D machine. However, the D-machine can be broken, and when using the D-machine, it may react to squares where treasure cannot exist. Also, since there is a wall square on the map that D person cannot move, it may not be possible to move to the square where the treasure exists. Person D used the D machine in various squares and observed the reaction. Can the person of D reach the square where the treasure exists?\\n\\nProblem\\n\\nConsider a two-dimensional lattice with height h and width w. A cell t_ {i, j} is represented by one of the following characters:\\n\\n* \\\".\\\": Indicates that it is passable. There may be treasure in this square.\\n* \\\"#\\\": Indicates that there is a wall and it is impassable. There are no treasures in this square.\\n* \\\"D\\\": It means that it is passable and there is a person of D. There may be treasure in this square.\\n\\n\\n\\nPerson D can move to a passable square adjacent to the top, bottom, left, and right.\\n\\nThe D-machine shows the reaction to any mass set in the two-dimensional lattice as shown in the figure, depending on the position used. Each rectangle in the figure below is a square with radii r_1, r_2, ..., r_d. A square radius...\\n#incl\",\"targets\":\"ude\\nusing namespace std;\\n#define int long long\\nsigned main(){\\n int h,w,d,n;\\n cin>>h>>w>>d>>n;\\n string s[h];\\n for(int i=0;i>s[i];\\n int r[d];\\n for(int i=0;i>r[i];\\n \\/\\/for(int i=0;i>x>>y>>t;\\n for(int i=0;i P;\\n queue

q;\\n int dp[h][w];\\n memset(dp,-1,sizeof(dp));\\n dp[sy][sx]=0;\\n q.push(P(sy,sx));\\n while(!q.empty()){\\n P p=q.front();q.pop();\\n int y=p.first,x=p.second;\\n \\/\\/cout<\\nusing namespace std;\\nvector > a, b;\\nvector edg[100005];\\nbool vis[100005];\\nvoid dfs(int u) {\\n vis[u] = 1;\\n for (int i = 0; i < edg[u].size(); i++) {\\n int v = edg[u][i];\\n if (!vis[v]) dfs(v);\\n }\\n}\\nvoid reset(int n) {\\n a.clear();\\n b.clear();\\n for (int i = 0; i < n; i++) {\\n edg[i].clear();\\n vis[i] = 0;\\n }\\n}\\nint main() {\\n int t, n;\\n cin >> t;\\n while (t--) {\\n cin >> n;\\n for (int i = 0; i < n; i++) {\\n int x;\\n cin >> x;\\n a.push_back({x, i});\\n }\\n for (int i = 0; i < n; i++) {\\n int x;\\n cin >> x;\\n b.push_back({x, i});\\n }\\n sort(a.begin(), a.end());\\n reverse(a.begin(), a.end());\\n sort(b.begin(), b.end());\\n reverse(b.begin(), b.end());\\n for (int i = 1; i < a.size(); i++) {\\n edg[a[i].second].push_back(a[i - 1].second);\\n edg[b[i].second].push_back(b[i - 1].second);\\n }\\n dfs(a[0].second);\\n dfs(b[0].second);\\n for (int i = 0; i < n; i++) cout << vis[i];\\n cout << endl;\\n reset(n);\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"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;\\nconst long long N = 1e5 + 5;\\nconst long long Inf = 1e18;\\nlong long n, m, a[N], b[N];\\ninline long long read() {\\n long long x = 0;\\n char ch = getchar();\\n bool f = 0;\\n while (ch > '9' || ch < '0') {\\n if (ch == '-') f = 1;\\n ch = getchar();\\n }\\n while (ch >= '0' && ch <= '9') {\\n x = (x << 1) + (x << 3) + ch - '0';\\n ch = getchar();\\n }\\n return f ? -x : x;\\n}\\nint main() {\\n long long t = read();\\n a[0] = b[0] = -1;\\n while (t--) {\\n n = read(), m = read();\\n for (long long i = 1; i <= n; ++i) a[i] = b[i] = read();\\n sort(b + 1, b + 1 + n);\\n map h;\\n for (long long i = 1; i <= n; ++i) h[b[i]] = i;\\n for (long long i = 1; i <= n; ++i) a[i] = h[a[i]];\\n long long cnt = 0;\\n for (long long i = 1; i <= n; ++i) {\\n if (a[i] == a[i - 1] + 1) continue;\\n ++cnt;\\n }\\n if (m >= cnt) {\\n puts(\\\"Yes\\\");\\n } else {\\n puts(\\\"No\\\");\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Andrewid the Android is a galaxy-famous detective. In his free time he likes to think about strings containing zeros and ones.\\n\\nOnce he thought about a string of length n consisting of zeroes and ones. Consider the following operation: we choose any two adjacent positions in the string, and if one them contains 0, and the other contains 1, then we are allowed to remove these two digits from the string, obtaining a string of length n - 2 as a result.\\n\\nNow Andreid thinks about what is the minimum length of the string that can remain after applying the described operation several times (possibly, zero)? Help him to calculate this number.\\n\\nInput\\n\\nFirst line of the input contains a single integer n (1 ≤ n ≤ 2·105), the length of the string that Andreid has.\\n\\nThe second line contains the string of length n consisting only from zeros and ones.\\n\\nOutput\\n\\nOutput the minimum length of the string that may remain after applying the described operations several times.\\n\\nExamples\\n\\nInput\\n\\n4\\n1100\\n\\n\\nOutput\\n\\n0\\n\\n\\nInput\\n\\n5\\n01010\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\n8\\n11101111\\n\\n\\nOutput\\n\\n6\\n\\nNote\\n\\nIn the first sample test it is possible to change the string like the following: .\\n\\nIn the second sample test it is possible to change the string like the following: .\\n\\nIn the third sample test it is possible to change the string like the following: .\",\"targets\":\"n=int(input())\\nA=input()\\nd={'1':0,'0':0}\\nfor val in A:\\n if val in d:\\n d[val] += 1\\nx=list(d.values())\\nMin=min(x)\\nprint(n-2*Min)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"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\\\":\",\"targets\":\"#include \\nclass mint {\\n public:\\n unsigned int v;\\n mint(unsigned int _v = 0) : v(_v) {}\\n mint operator+(const mint &x) const {\\n unsigned int r = v + x.v;\\n if (r >= 998244353) r -= 998244353;\\n return r;\\n }\\n mint &operator+=(const mint &x) {\\n *this = *this + x;\\n return *this;\\n }\\n mint operator*(const mint &x) const {\\n unsigned int r = (unsigned long long int)v * x.v % 998244353;\\n return r;\\n }\\n mint &operator*=(const mint &x) {\\n *this = *this * x;\\n return *this;\\n }\\n operator unsigned int() const { return v; }\\n};\\nmint comb[2048][2048];\\nmint dp[2048][128], td[128], tdi[128];\\nint a[2048];\\nint main() {\\n for (int i = 0; i < 2048; ++i) {\\n comb[i][0] = 1;\\n for (int j = 1; j < i; ++j)\\n comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];\\n }\\n int n, m;\\n scanf(\\\"%d%d\\\", &n, &m);\\n for (int i = 0; i < n; ++i) scanf(\\\"%d\\\", &a[i]);\\n dp[0][0] = 1;\\n int ba = 0;\\n int rb = 1;\\n for (int i = 0; i < n; ++i) {\\n int nx = std::max(ba, std::max(0, a[i] - m));\\n int de = nx - ba;\\n int rn = std::max(0, a[i] + m + 1 - nx);\\n int mn = std::min(std::max(0, rb - de), rn);\\n memset(td, 0, sizeof(td));\\n for (int j = i; j >= 0; --j) {\\n mint ca = 0;\\n memcpy(tdi, td, sizeof(tdi));\\n memset(td, 0, sizeof(td));\\n for (int k = 0; k < de; ++k) ca += dp[j][k];\\n for (int k = 0; k < mn; ++k) {\\n tdi[k] += ca;\\n tdi[k] += dp[j][k + de] * (mint)(j - (nx + k) + 1);\\n td[k] = dp[j][k + de] * (mint)j;\\n ca += dp[j][k + de];\\n }\\n for (int k = mn; k < rn; ++k) tdi[k] += ca;\\n memcpy(dp[j + 1], tdi, sizeof(dp[j + 1]));\\n }\\n memcpy(dp[0], td, sizeof(dp[0]));\\n ba = nx;\\n rb = rn;\\n for (int j = 0; j <= n; ++j)\\n for (int k = 0; k < rb; ++k)\\n if (n + 1 - (ba + k) >= 0 && j - (ba + k) >= 0) 0;\\n }\\n mint ans;\\n for (int i = 0; i <= n; ++i)\\n for (int j = 0; j < rb; ++j)\\n if (n + 1 - (ba + j) >= 0 && i - (ba + j) >= 0)\\n ans += dp[i][j] * comb[n + 1 - (ba + j)][i - (ba + j)];\\n printf(\\\"%d\\\\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...\\nUsing python3 can you solve the prior task?\",\"targets\":\"a = int(input())\\nfor i in range(a):\\n n , m, rb, cb, rd, cd = map(int, input().split())\\n rk=1\\n ck=1\\n t=0\\n while True:\\n if rd==rb or cb==cd:\\n break\\n if rb==n or rd==0:\\n rk*=-1\\n if cb==m or cd==0:\\n ck*=-1\\n rb+=rk\\n cb+=ck\\n t+=1\\n print(t)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"\\n\\nTo monitor cryptocurrency exchange rates trader William invented a wonderful device consisting of n lights arranged in a row. The device functions in the following way:\\n\\nInitially, all lights on William's device are turned off. At the beginning of a new iteration the device randomly, with a uniform distribution, picks a light that is turned off and turns it on, telling William which cryptocurrency he should invest in. After this iteration if any k consecutive lights contain more than one turned on light, then the device finishes working.\\n\\nWilliam doesn't like uncertainty, so he wants you to calculate the expected value of the number of lights that are turned on in the device after it finishes working.\\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 only line for each test case contains two integers n and k (2 ≤ k ≤ n ≤ 10^5), which are the total number of lights and the length of subsegment of lights that are being checked, respectively.\\n\\nOutput\\n\\nFor each test case print the answer, modulo 10^9+7. \\n\\nFormally, let M = 10^9+7. It can be shown that the answer can be expressed as an irreducible fraction p\\/q, where p and q are integers and q not ≡ 0 \\\\pmod{M}. Output the integer equal to p ⋅ q^{-1} mod M. In other words, output such an integer x that 0 ≤ x < M and x ⋅ q ≡ p \\\\pmod{M}.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n3 2\\n15 2\\n40 15\\n\\n\\nOutput\\n\\n\\n333333338\\n141946947\\n329622137\\n\\nNote\\n\\nExplanation of the first sample test case:\\n\\nLet's write out all possible sequences of light toggles, which will make the device complete its operation:\\n\\n 1. (1, 2) — 2 lights are turned on \\n 2. (1, 3, 2) — 3 lights are turned on \\n 3. (2, 1) — 2 lights are turned on \\n 4. (2, 3) — 2 lights are turned on \\n 5. (3, 2) — 2 lights are turned on \\n 6. (3, 1, 2) — 3 lights are turned on \\n\\n\\n\\nThen the final expected value will be equal to 2\\/6 + 3\\/6 + 2\\/6 + 2\\/6 + 2\\/6 + 3\\/6 = 14\\/6 = 7\\/3. \\n\\nThen the required output will be 333333338, since...\\nSolve the task in PYTHON3.\",\"targets\":\"from __future__ import division, print_function\\nimport sys, collections, math, itertools, random, bisect\\nINF = sys.maxsize\\ndef get_ints(): return map(int, input().strip().split())\\ndef get_array(): return list(map(int, input().strip().split()))\\nmod = 1000000007\\nMOD = 998244353\\n\\n#-----------------------------------------------------------------------------------------------------------------------------------\\n\\ndef solve():\\n mod = 10 ** 9 + 7\\n N = 10 ** 5\\n F, iF = [0] * (N + 1), [0] * (N + 1)\\n F[0] = 1\\n for i in range(1, N + 1):\\n F[i] = F[i - 1] * i % mod\\n iF[-1] = pow(F[-1], mod - 2, mod)\\n for i in range(N - 1, -1, -1):\\n iF[i] = iF[i + 1] * (i + 1) % mod\\n \\n def cal(n, k):\\n if k < 0 or k > n: return 0\\n return F[n] * iF[k] * iF[n - k] % mod\\n \\n for _ in range(int(input())):\\n n, k = map(int, input().split())\\n ans = 1\\n x = 1\\n while n - (k - 1) * (x - 1) >= x:\\n ans = (ans + cal(n - (k - 1) * (x - 1), x) * pow(cal(n, x), mod - 2, mod)) % mod\\n x += 1\\n print(ans%mod)\\n\\n#-----------------------------------------------------------------------------------------------------------------------------------\\n\\ndef main():\\n\\tsolve()\\n\\n# Region of fastio, don't change\\n\\npy2 = round(0.5)\\nif py2:\\n from future_builtins import ascii, filter, hex, map, oct, zip\\n\\n range = xrange\\n\\nimport os, sys\\nfrom io import IOBase, BytesIO\\n\\nBUFSIZE = 8192\\n\\n\\nclass FastIO(BytesIO):\\n newlines = 0\\n\\n def __init__(self, file):\\n self._file = file\\n self._fd = file.fileno()\\n self.writable = \\\"x\\\" in file.mode or \\\"w\\\" in file.mode\\n self.write = super(FastIO, self).write if self.writable else None\\n\\n def _fill(self):\\n s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\\n self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])\\n return s\\n\\n def read(self):\\n while self._fill(): pass\\n return super(FastIO, self).read()\\n\\n def readline(self):\\n ...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"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...\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\n \\npublic class D2 {\\n\\t\\n\\tstatic class Point implements Comparable{\\n\\t\\tint x; \\/\\/ row\\n\\t\\tint y; \\/\\/ col\\n\\t\\tint val;\\n\\t\\tpublic Point(int a,int b,int c){\\n\\t\\t\\tthis.x=a;\\n\\t\\t\\tthis.y=b;\\n\\t\\t\\tthis.val=c;\\n\\t\\t}\\n\\t\\tpublic int compareTo(Point o) {\\n\\t\\t\\t\\/\\/ positive - current obj > o\\n\\t\\t\\t\\/\\/ ascending - (cur,o) , descending - (o,cur)\\n\\t\\t\\tif(this.x!=o.x) {\\n\\t\\t\\t\\treturn Integer.compare(this.x, o.x);\\n\\t\\t\\t}\\n\\t\\t\\treturn Integer.compare(o.y,this.y);\\n\\t\\t}\\n\\t\\t\\n\\t}\\n\\t\\n public static void main(String[] args)\\n {\\n \\tFastScanner sc=new FastScanner();\\n \\tint t=sc.nextInt();\\n \\tPrintWriter pw=new PrintWriter(System.out);\\n \\twhile(t-->0) {\\n \\t\\tint n=sc.nextInt();\\n \\t\\tint m=sc.nextInt();\\n \\t\\tint[] a=sc.readArray(n*m);\\n \\t\\tint[] sorted=a.clone();\\n \\t\\tArrays.sort(sorted);\\n \\t\\tint[][] grid=new int[n][m];\\n \\t\\tint idx=0;\\n \\t\\tfor(int i=0;i> map=new HashMap<>();\\n \\t\\tfor(int i=0;i());\\n \\t\\t\\t\\t}\\n \\t\\t\\t\\tmap.get(grid[i][j]).add(p);\\n \\t\\t\\t}\\n \\t\\t}\\n \\t\\tlong ans=0;\\n \\t\\tboolean[][] used=new boolean[n][m];\\n \\t\\tfor(int i:a) {\\n \\t\\t\\tPoint cur=map.get(i).remove();\\n \\t\\t\\tused[cur.x][cur.y]=true;\\n \\t\\t\\tfor(int j=0;j 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#pragma GCC optimize(\\\"O3\\\")\\n#pragma GCC target(\\\"avx,avx2,fma\\\")\\n#pragma GCC optimization(\\\"unroll-loops\\\")\\nusing namespace std;\\ntemplate \\nbool mycomp(T x, T y) {\\n return (x == y);\\n}\\nbool paircomp(const pair &x,\\n const pair &y) {\\n return x.second < y.second;\\n}\\nmultiset ms;\\nvoid solve() {\\n ms.clear();\\n long long int flag = 0;\\n long long int n, m, k;\\n cin >> n >> m >> k;\\n if (n % 2) {\\n flag = 1;\\n k = (n * m) \\/ 2 - k;\\n swap(n, m);\\n }\\n char sp[n][m];\\n if (k % 2 == 0) {\\n if ((n * (m \\/ 2)) >= k)\\n cout << \\\"YES\\\";\\n else {\\n cout << \\\"NO\\\";\\n cout << '\\\\n';\\n return;\\n }\\n } else {\\n cout << \\\"NO\\\";\\n cout << '\\\\n';\\n return;\\n }\\n cout << '\\\\n';\\n long long int dom = n;\\n long long int r = k;\\n while (r) {\\n long long int j = min(r, n);\\n ms.insert(j);\\n r -= j;\\n }\\n long long int c = 0;\\n long long int op = 0;\\n for (auto &p : ms) {\\n op++;\\n long long int ins = 0;\\n for (long long int i = 0; i <= p - 1; i++) {\\n ins++;\\n if (ins % 2) {\\n if (op % 2)\\n sp[i][c] = sp[i][c + 1] = 'a';\\n else\\n sp[i][c] = sp[i][c + 1] = 'c';\\n } else {\\n if (op % 2)\\n sp[i][c] = sp[i][c + 1] = 'b';\\n else\\n sp[i][c] = sp[i][c + 1] = 'd';\\n }\\n }\\n ins = 0;\\n for (long long int i = p; i < n - 1; i += 2) {\\n ins++;\\n if (ins % 2) {\\n if (op % 2) {\\n sp[i][c] = sp[i + 1][c] = 'e';\\n sp[i][c + 1] = sp[i + 1][c + 1] = 'f';\\n } else {\\n sp[i][c] = sp[i + 1][c] = 'i';\\n sp[i][c + 1] = sp[i + 1][c + 1] = 'j';\\n }\\n } else {\\n if (op % 2) {\\n sp[i][c] = sp[i + 1][c] = 'g';\\n sp[i][c + 1] = sp[i + 1][c + 1] = 'h';\\n } else {\\n sp[i][c] = sp[i + 1][c] = 'k';\\n sp[i][c + 1] = sp[i + 1][c + 1] = 'l';\\n }\\n }\\n }\\n c += 2;\\n }\\n op = 0;\\n while (c <= m - 1) {\\n op++;\\n long long...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Mrs. Hudson hasn't made her famous pancakes for quite a while and finally she decided to make them again. She has learned m new recipes recently and she can't wait to try them. Those recipes are based on n special spices. Mrs. Hudson has these spices in the kitchen lying in jars numbered with integers from 0 to n - 1 (each spice lies in an individual jar). Each jar also has the price of the corresponding spice inscribed — some integer ai.\\n\\nWe know three values for the i-th pancake recipe: di, si, ci. Here di and ci are integers, and si is the pattern of some integer written in the numeral system with radix di. The pattern contains digits, Latin letters (to denote digits larger than nine) and question marks. Number x in the di-base numeral system matches the pattern si, if we can replace question marks in the pattern with digits and letters so that we obtain number x (leading zeroes aren't taken into consideration when performing the comparison). More formally: each question mark should be replaced by exactly one digit or exactly one letter. If after we replace all question marks we get a number with leading zeroes, we can delete these zeroes. For example, number 40A9875 in the 11-base numeral system matches the pattern \\\"??4??987?\\\", and number 4A9875 does not.\\n\\nTo make the pancakes by the i-th recipe, Mrs. Hudson should take all jars with numbers whose representation in the di-base numeral system matches the pattern si. The control number of the recipe (zi) is defined as the sum of number ci and the product of prices of all taken jars. More formally: (where j is all such numbers whose representation in the di-base numeral system matches the pattern si).\\n\\nMrs. Hudson isn't as interested in the control numbers as she is in their minimum prime divisors. Your task is: for each recipe i find the minimum prime divisor of number zi. If this divisor exceeds 100, then you do not have to find it, print -1.\\n\\nInput\\n\\nThe first line contains the single integer n (1 ≤ n ≤ 104). The second line contains...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nconst int S = 13;\\nconst int Full = (1 << S) - 1;\\nint prime[50] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41,\\n 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97},\\n tot = 25;\\nchar block[800][1 << S][25];\\nint mm[10010][26], to[100000];\\nunsigned long long all[15][15][16][200];\\nunsigned long long tmp[200];\\nint tmp2[25];\\nint ans[25];\\nint key(char c) {\\n if (c >= '0' && c <= '9') return c - '0';\\n return c - 'A' + 10;\\n}\\nint main() {\\n int n;\\n scanf(\\\"%d\\\", &n);\\n for (int i = 0; i < n; i++) {\\n long long x;\\n scanf(\\\"%lld\\\", &x);\\n for (int j = 0; j < tot; j++) {\\n mm[i][j] = x % prime[j];\\n }\\n }\\n for (int i = 0; i < S; i++) {\\n to[1 << i] = i;\\n }\\n for (int i = 0; i < n; i += S) {\\n int s = min(S, n - i);\\n for (int j = 0; j < 25; j++) {\\n block[i \\/ S][0][j] = 1;\\n }\\n for (int mask = 1; mask < (1 << s); mask++) {\\n int lowbit = mask & -mask;\\n for (int j = 0; j < 25; j++) {\\n block[i \\/ S][mask][j] =\\n block[i \\/ S][mask - lowbit][j] * mm[i + to[lowbit]][j] % prime[j];\\n }\\n }\\n }\\n for (int d = 2; d <= 16; d++) {\\n int pw = 1;\\n for (int j = 0; pw < n; j++, pw *= d) {\\n for (int i = 0; i < n; i++) {\\n int val = 0, len = 0, x = i, cnt = 0;\\n while (x) {\\n if (j == cnt) val = x % d;\\n x \\/= d, len++, cnt++;\\n }\\n all[d - 2][j][val][i \\/ (4 * S)] |= 1ull << (i % (4 * S));\\n }\\n }\\n }\\n int q;\\n scanf(\\\"%d\\\", &q);\\n while (q--) {\\n int d;\\n char s[50];\\n long long a;\\n scanf(\\\"%d\\\", &d);\\n scanf(\\\"%s\\\", s), scanf(\\\"%lld\\\", &a);\\n int m = strlen(s);\\n for (int j = 0; j < tot; j++) {\\n ans[j] = a % prime[j];\\n }\\n for (int j = 0; j <= ((n - 1) \\/ (4 * S)); j++) {\\n tmp[j] = (1ull << 4 * S) - 1;\\n }\\n long long pw = 1;\\n for (int i = m - 1; i >= 0; i--) {\\n if (pw >= n) {\\n if (s[i] != '?' && s[i] != '0') {\\n for (int j = 0; j <= ((n - 1) \\/ (4 * S)); j++) {\\n tmp[j] = 0;\\n }\\n }\\n ...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"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.\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nmt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());\\nmt19937 rnf(2106);\\nconst int N = 200005;\\nint n;\\nint a[N];\\nchar s[N];\\npair ans[N];\\nvoid solv() {\\n cin >> n;\\n for (int i = 1; i <= n; ++i) cin >> a[i];\\n cin >> (s + 1);\\n sort(a + 1, a + n + 1);\\n deque l, r;\\n for (int i = 1; i <= n; ++i) {\\n if (i % 2 == n % 2)\\n r.push_back(a[i]);\\n else\\n l.push_back(a[i]);\\n }\\n if (s[n] == 'L') swap(l, r);\\n for (int i = n; i > 1; --i) {\\n if (s[i] == 'R') {\\n if (s[i - 1] == 'R') {\\n if (i % 2 == 0) {\\n ans[i] = make_pair(l.front(), 'L');\\n l.pop_front();\\n } else {\\n ans[i] = make_pair(r.front(), 'R');\\n r.pop_front();\\n }\\n } else {\\n ans[i] = make_pair(r.back(), 'R');\\n r.pop_back();\\n }\\n } else {\\n if (s[i - 1] == 'L') {\\n if (i % 2 == 0) {\\n ans[i] = make_pair(r.front(), 'R');\\n r.pop_front();\\n } else {\\n ans[i] = make_pair(l.front(), 'L');\\n l.pop_front();\\n }\\n } else {\\n ans[i] = make_pair(l.back(), 'L');\\n l.pop_back();\\n }\\n }\\n }\\n if (!r.empty())\\n ans[1] = make_pair(r.back(), 'R');\\n else if (!l.empty())\\n ans[1] = make_pair(l.back(), 'L');\\n else\\n assert(false);\\n for (int i = 1; i <= n; ++i)\\n cout << ans[i].first << ' ' << ans[i].second << \\\"\\\\n\\\";\\n}\\nint main() {\\n ios_base::sync_with_stdio(false), cin.tie(0);\\n int tt = 1;\\n while (tt--) solv();\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"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). \\nUsing java can you solve the prior task?\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\n\\npublic class A {\\n\\n\\tpublic static void main(String[] args) throws IOException {\\n\\t\\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\\n\\t\\tPrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));\\n\\t\\t\\n\\t\\tint T = Integer.parseInt(br.readLine());\\n\\t\\t\\n\\t\\tfor (int cases = 0; cases < T; cases++) {\\n\\t\\t\\tStringTokenizer st = new StringTokenizer(br.readLine());\\n\\t\\t\\tint c = Integer.parseInt(st.nextToken());\\n\\t\\t\\tint d = Integer.parseInt(st.nextToken());\\n\\t\\t\\t\\n\\t\\t\\tif (c%2 != d%2) {\\n\\t\\t\\t\\tpw.println(-1);\\n\\t\\t\\t} else if (c == 0 && c == d) {\\n\\t\\t\\t\\tpw.println(0);\\n\\t\\t\\t} else if (c == d) pw.println(1);\\n\\t\\t\\telse pw.println(2);\\n\\t\\t}\\n\\t\\tpw.close();\\n\\t}\\n\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"n towns are arranged in a circle sequentially. The towns are numbered from 1 to n in clockwise order. In the i-th town, there lives a singer with a repertoire of a_i minutes for each i ∈ [1, n].\\n\\nEach singer visited all n towns in clockwise order, starting with the town he lives in, and gave exactly one concert in each town. In addition, in each town, the i-th singer got inspired and came up with a song that lasts a_i minutes. The song was added to his repertoire so that he could perform it in the rest of the cities.\\n\\nHence, for the i-th singer, the concert in the i-th town will last a_i minutes, in the (i + 1)-th town the concert will last 2 ⋅ a_i minutes, ..., in the ((i + k) mod n + 1)-th town the duration of the concert will be (k + 2) ⋅ a_i, ..., in the town ((i + n - 2) mod n + 1) — n ⋅ a_i minutes.\\n\\nYou are given an array of b integer numbers, where b_i is the total duration of concerts in the i-th town. Reconstruct any correct sequence of positive integers a or say that it is impossible.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10^3) — the number of test cases. Then the test cases follow.\\n\\nEach test case consists of two lines. The first line contains a single integer n (1 ≤ n ≤ 4 ⋅ 10^4) — the number of cities. The second line contains n integers b_1, b_2, ..., b_n (1 ≤ b_i ≤ 10^{9}) — the total duration of concerts in i-th city.\\n\\nThe sum of n over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print the answer as follows:\\n\\nIf there is no suitable sequence a, print NO. Otherwise, on the first line print YES, on the next line print the sequence a_1, a_2, ..., a_n of n integers, where a_i (1 ≤ a_i ≤ 10^{9}) is the initial duration of repertoire of the i-th singer. If there are multiple answers, print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n12 16 14\\n1\\n1\\n3\\n1 2 3\\n6\\n81 75 75 93 93 87\\n\\n\\nOutput\\n\\n\\nYES\\n3 1 3 \\nYES\\n1 \\nNO\\nYES\\n5 5 4 1 4 5 \\n\\nNote\\n\\nLet's consider the 1-st test case of the example:\\n\\n 1. the 1-st singer in the 1-st city will give a concert for 3 minutes, in the 2-nd —...\\nSolve the task in PYTHON3.\",\"targets\":\"import sys\\nread=sys.stdin.buffer.read;readline=sys.stdin.buffer.readline;input=lambda:sys.stdin.readline().rstrip()\\nimport bisect,string,math,time,functools,random,fractions\\nfrom bisect import*\\nfrom heapq import heappush,heappop,heapify\\nfrom collections import deque,defaultdict,Counter\\nfrom itertools import permutations,combinations,groupby\\nrep=range;R=range\\ndef I():return int(input())\\ndef LI():return [int(i) for i in input().split()]\\ndef SLI():return sorted([int(i) for i in input().split()])\\ndef LI_():return [int(i)-1 for i in input().split()]\\ndef S_():return input()\\ndef IS():return input().split()\\ndef LS():return [i for i in input().split()]\\ndef NI(n):return [int(input()) for i in range(n)]\\ndef NI_(n):return [int(input())-1 for i in range(n)]\\ndef NLI(n):return [[int(i) for i in input().split()] for i in range(n)]\\ndef NLI_(n):return [[int(i)-1 for i in input().split()] for i in range(n)]\\ndef StoLI():return [ord(i)-97 for i in input()]\\ndef ItoS(n):return chr(n+97)\\ndef LtoS(ls):return ''.join([chr(i+97) for i in ls])\\ndef RLI(n=8,a=1,b=10):return [random.randint(a,b)for i in range(n)]\\ndef RI(a=1,b=10):return random.randint(a,b)\\ndef INP():\\n N=10\\n n=random.randint(2,N)\\n mn=1\\n mx=5\\n a=[random.randint(mn,mx) for i in range(n)]\\n s=[random.randint(mn,mx) for i in range(n)]\\n return (n,a,s)\\ndef Rtest(T):\\n case,err=0,0\\n for i in range(T):\\n inp=INP()\\n a1=naive(*inp)\\n a2=solve(*inp)\\n if a1!=a2:\\n x,y=a1\\n z,w=a2\\n cm=Comb(max(x,z))\\n if cm.comb(x,y)==cm.comb(z,w):\\n case+=1\\n continue\\n print(inp)\\n print('naive',a1)\\n print('solve',a2)\\n err+=1\\n case+=1\\n print('Tested',case,'case with',err,'errors')\\ndef GI(V,E,ls=None,Directed=False,index=1):\\n org_inp=[];g=[[] for i in range(V)]\\n FromStdin=True if ls==None else False\\n for i in range(E):\\n if FromStdin:\\n inp=LI()\\n org_inp.append(inp)\\n else:\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A sequence a_1,a_2,... ,a_n is said to be \\/\\\\\\/\\\\\\/\\\\\\/ when the following conditions are satisfied:\\n\\n* For each i = 1,2,..., n-2, a_i = a_{i+2}.\\n* Exactly two different numbers appear in the sequence.\\n\\n\\n\\nYou are given a sequence v_1,v_2,...,v_n whose length is even. We would like to make this sequence \\/\\\\\\/\\\\\\/\\\\\\/ by replacing some of its elements. Find the minimum number of elements that needs to be replaced.\\n\\nConstraints\\n\\n* 2 \\\\leq n \\\\leq 10^5\\n* n is even.\\n* 1 \\\\leq v_i \\\\leq 10^5\\n* v_i is an integer.\\n\\nInput\\n\\nInput is given from Standard Input in the following format:\\n\\n\\nn\\nv_1 v_2 ... v_n\\n\\n\\nOutput\\n\\nPrint the minimum number of elements that needs to be replaced.\\n\\nExamples\\n\\nInput\\n\\n4\\n3 1 3 2\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\n6\\n105 119 105 119 105 119\\n\\n\\nOutput\\n\\n0\\n\\n\\nInput\\n\\n4\\n1 1 1 1\\n\\n\\nOutput\\n\\n2\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\n#include \\n#include \\n\\nusing namespace std;\\n\\nint main(void) {\\n\\tint num, i = 0, aa, bb, as = 0, bs = 0, an, bn, ans;\\n\\tcin >> num;\\n\\tvector a(100001, 0), b(100001, 0);\\n\\tfor (; i < (num >> 1); i++) {\\n\\t\\tscanf(\\\"%d%d\\\", &aa, &bb);\\n\\t\\ta[aa]++;\\n\\t\\tb[bb]++;\\n\\t}\\n\\tfor (aa = 0, bb = 0, i = 0; i < 100000; i++) {\\n\\t\\tif (aa < a[i]) {\\n\\t\\t\\tas = aa;\\n\\t\\t\\taa = a[i];\\n\\t\\t\\tan = i;\\n\\t\\t}\\n\\t\\telse if (as < a[i])\\n\\t\\t\\tas = a[i];\\n\\t\\tif (bb < b[i]) {\\n\\t\\t\\tbs = bb;\\n\\t\\t\\tbb = b[i];\\n\\t\\t\\tbn = i;\\n\\t\\t}\\n\\t\\telse if (bs < b[i])\\n\\t\\t\\tbs = b[i];\\n\\t}\\n\\tif (an == bn)\\n\\t\\tans = max(aa + bs, bb + as);\\n\\telse\\n\\t\\tans = aa + bb;\\n\\tprintf(\\\"%d\\\\n\\\", num - ans);\\n\\treturn 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"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\",\"targets\":\"from math import ceil\\na = list(i**2 for i in range(1,31624))\\nfor t in range(int(input())):\\n k = int(input())\\n for b in a:\\n if(b < k):\\n continue\\n else:\\n p2 = b\\n break\\n p1 = a[(a.index(p2)) - 1]\\n ind = ceil((p1+p2)\\/2)\\n if(k==1):\\n print(1, 1)\\n elif(k==ind):\\n print(int(p2**0.5), int(p2**0.5))\\n elif(k\\nusing namespace std;\\nint a[55], b[55];\\nvoid solve() {\\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 vector, int> > ans;\\n for (int i = 0; i < n; i++) {\\n if (a[i] != b[i]) {\\n for (int j = i + 1; j < n; j++) {\\n if (a[j] == b[i]) {\\n int num = a[j];\\n ans.push_back(make_pair(make_pair(i + 1, j + 1), j - i));\\n for (int k = j; k > i; k--) {\\n a[k] = a[k - 1];\\n }\\n a[i] = a[j];\\n }\\n }\\n }\\n }\\n cout << ans.size() << endl;\\n for (auto i : ans) {\\n cout << i.first.first << ' ' << i.first.second << ' ' << i.second << endl;\\n }\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n int t;\\n cin >> t;\\n while (t--) {\\n solve();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"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...\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"import sys;input=sys.stdin.readline\\n# from bisect import bisect\\n# from collections import defaultdict\\n# from itertools import accumulate\\n# from decimal import *\\n# import math\\n# getcontext().prec = 50\\n# s = input().strip()\\n# n = int(input())\\n# lis = list(map(int,input().split()))\\n# x,y = map(int,input().split())\\n# chars = 'abcdefghijklmnopqrstuvwxyz'\\n# import heapq\\n# def gcd(a,b):\\n# return gcd (b, a % b) if b else a\\n\\ndef solve():\\n n,k = map(int,input().split())\\n points = []\\n missed = [i+1 for i in range(n*2)]\\n for _ in range(k):\\n x,y = map(int,input().split())\\n start = min(x,y)\\n end = max(x,y)\\n points.append([start,end])\\n missed.remove(start)\\n missed.remove(end)\\n m_len = len(missed)\\n for i in range(m_len\\/\\/2):\\n points.append([missed[i],missed[i+(m_len\\/\\/2)]])\\n count = 0\\n points= sorted(points,key=lambda x: x[0])\\n starts = [point[0] for point in points]\\n ends = [point[1] for point in points]\\n for i in range(n):\\n for j in range(n):\\n if(i == j):\\n continue\\n if(points[i][0] < points[j][0] and points[j][0] < points[i][1] and points[i][1] < points[j][1]):\\n count += 1 \\n print(count)\\n\\n \\nfor _ in range(int(input())):\\n solve()\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"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\",\"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\":\"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.\",\"targets\":\"import java.util.Scanner;\\npublic class close_gap {\\n public static void main(String args[]){\\n Scanner read=new Scanner(System.in);\\n int test=read.nextInt();\\n for(int i=0;i\\nusing namespace std;\\nconst long long maxn = 2e6 + 15, inf = 2e9, lg = 26, M = 1e9 + 7;\\nint main() {\\n int n, ans = 0, l = 1, r, lindex, rindex, cnt = 0;\\n string s[2] = {\\\"Alice\\\", \\\"Bob\\\"};\\n cin >> n;\\n r = n;\\n int a[n + 2];\\n for (int i = 1; i < n + 1; i++) cin >> a[i];\\n a[0] = a[n + 1] = -1;\\n for (int i = 1; i < n + 1; i++) {\\n if (a[i] <= a[i - 1]) {\\n lindex = i - 1;\\n break;\\n }\\n }\\n for (int i = n; i > 0; i--) {\\n if (a[i] >= a[i - 1]) {\\n rindex = i;\\n break;\\n }\\n }\\n if (n == 1) {\\n cout << \\\"Alice\\\";\\n return 0;\\n }\\n while (true) {\\n if ((a[l] >= a[r] && (lindex - l + 1) % 2) ||\\n (a[r] >= a[l] && (r - rindex + 1) % 2)) {\\n cout << s[ans];\\n break;\\n }\\n if (a[l] == a[r]) {\\n ans = 1 - ans;\\n cout << s[ans];\\n break;\\n }\\n if (a[l] < a[r]) {\\n while (a[l] < a[r] && l < lindex) {\\n l++;\\n ans = 1 - ans;\\n }\\n } else {\\n while (a[r] < a[l] && r > rindex) {\\n r--;\\n ans = 1 - ans;\\n }\\n }\\n if (l == lindex) {\\n ans = ((r - rindex + 1) % 2) - ans;\\n cout << s[abs(ans)];\\n break;\\n }\\n if (r == rindex) {\\n ans = ((lindex - l + 1) % 2) - ans;\\n cout << s[abs(ans)];\\n break;\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Devu and his brother love each other a lot. As they are super geeks, they only like to play with arrays. They are given two arrays a and b by their father. The array a is given to Devu and b to his brother. \\n\\nAs Devu is really a naughty kid, he wants the minimum value of his array a should be at least as much as the maximum value of his brother's array b. \\n\\nNow you have to help Devu in achieving this condition. You can perform multiple operations on the arrays. In a single operation, you are allowed to decrease or increase any element of any of the arrays by 1. Note that you are allowed to apply the operation on any index of the array multiple times.\\n\\nYou need to find minimum number of operations required to satisfy Devu's condition so that the brothers can play peacefully without fighting. \\n\\nInput\\n\\nThe first line contains two space-separated integers n, m (1 ≤ n, m ≤ 105). The second line will contain n space-separated integers representing content of the array a (1 ≤ ai ≤ 109). The third line will contain m space-separated integers representing content of the array b (1 ≤ bi ≤ 109).\\n\\nOutput\\n\\nYou need to output a single integer representing the minimum number of operations needed to satisfy Devu's condition.\\n\\nExamples\\n\\nInput\\n\\n2 2\\n2 3\\n3 5\\n\\n\\nOutput\\n\\n3\\n\\n\\nInput\\n\\n3 2\\n1 2 3\\n3 4\\n\\n\\nOutput\\n\\n4\\n\\n\\nInput\\n\\n3 2\\n4 5 6\\n1 2\\n\\n\\nOutput\\n\\n0\\n\\nNote\\n\\nIn example 1, you can increase a1 by 1 and decrease b2 by 1 and then again decrease b2 by 1. Now array a will be [3; 3] and array b will also be [3; 3]. Here minimum element of a is at least as large as maximum element of b. So minimum number of operations needed to satisfy Devu's condition are 3.\\n\\nIn example 3, you don't need to do any operation, Devu's condition is already satisfied.\",\"targets\":\"\\/\\/package codeforces;\\n\\nimport java.util.Arrays;\\nimport java.util.Collections;\\nimport java.util.Scanner;\\n\\n\\/**\\n * Created by nitin.s on 23\\/03\\/16.\\n *\\/\\npublic class DevuAndHisBrother {\\n public static void main(String[] args) {\\n Scanner in = new Scanner(System.in);\\n int n = in.nextInt(), m = in.nextInt();\\n Long[] arr = new Long[n + 1];\\n Long[] brr = new Long[m + 1];\\n for(int i = 0; i < n; ++i) arr[i] = in.nextLong();\\n for(int i = 0; i < m; ++i) brr[i] = in.nextLong();\\n arr[n] = 1000000001L;\\n brr[m] = 0L;\\n Arrays.sort(arr);\\n Arrays.sort(brr, Collections.reverseOrder());\\n long i = 0;\\n while(true) {\\n if(arr[(int)i] >= brr[(int)i]) {\\n break;\\n }\\n ++i;\\n }\\n long sum1 = 0, sum2 = 0;\\n for(long j = 0; j < i; ++j) {\\n sum1 = sum1 + arr[(int)j];\\n sum2 = sum2 + brr[(int)j];\\n }\\n System.out.println(sum2 - sum1);\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"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 JAVA.\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\n\\npublic class q3 {\\n public static void main(String[] args) throws Exception {\\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\\n BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));\\n \\n int tests = Integer.parseInt(br.readLine());\\n\\n for (int test = 1;test <= tests;test++) {\\n String[] parts = br.readLine().split(\\\" \\\");\\n int n = Integer.parseInt(parts[0]);\\n\\n String[] arr = new String[2];\\n for(int i = 0;i < 2;i++){\\n arr[i] = br.readLine();\\n }\\n\\n int ans = 0,i = 0,co = 0,cz = 0;\\n while(i < n){\\n if(arr[0].charAt(i) == '0') cz++;\\n else co++;\\n\\n if(arr[1].charAt(i) == '0') cz++;\\n else co++;\\n\\n if(cz > 0 && co > 0){\\n ans += 2;\\n cz = 0;\\n co = 0;\\n }else if(cz > 0){\\n if(i + 1 < n && arr[0].charAt(i + 1) == '1' && arr[1].charAt(i + 1) == '1'){\\n\\n }else{\\n ans++;\\n cz = 0;\\n co = 0;\\n }\\n }\\n\\n i++;\\n }\\n out.write(ans + \\\"\\\\n\\\");\\n }\\n out.flush();\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"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\\n\\ndef\",\"targets\":\"main():\\n s=input()\\n n=len(s)\\n ans=\\\"\\\"\\n for i in range(0,n,2):\\n ans+=s[i]\\n n1=int(ans)\\n ans=\\\"\\\"\\n for i in range(1,n,2):\\n ans+=s[i]\\n if ans==\\\"\\\":\\n ans=\\\"0\\\"\\n n2=int(ans)\\n ans=(n1+1)*(n2+1)-2\\n print(ans)\\n\\n\\nif __name__==\\\"__main__\\\":\\n t=1\\n t=int(input())\\n for ii in range(t):\\n main()\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"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.Scanner;\\n\\n\\/**\\n *\\n * @author eslam\\n *\\/\\npublic class Banknotes {\\n\\n \\/**\\n * @param args the command line arguments\\n *\\/\\n public static void main(String[] args) {\\n Scanner input = new Scanner(System.in);\\n int t = input.nextInt();\\n for (int i = 0; i < t; i++) {\\n int n = input.nextInt();\\n long k = input.nextInt();\\n long ans = 0;\\n long num = 0;\\n long a[] = new long[n];\\n for (int j = 0; j < n; j++) {\\n int x = input.nextInt();\\n a[j] = (long) Math.pow(10, x);\\n }\\n for (int j = 0; j < n-1; j++) {\\n long x = (a[j+1]-a[j])\\/a[j];\\n long d = (k+1)-num;\\n ans+=Math.min(x, d)*a[j];\\n num+=Math.min(d, x);\\n }\\n ans+=((k+1)-num)*a[n-1];\\n System.out.println(ans);\\n }\\n }\\n \\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Note 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 ≤ 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.\\nimpor\",\"targets\":\"t sys\\nfrom io import BytesIO, IOBase\\nimport os\\n\\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, **kwargs):\\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\\n\\n###########################################################################################\\n\\n\\ndef inp():\\n return sys.stdin.readline().strip()\\n\\n\\ndef map_inp(v_type):\\n return map(v_type, inp().split())\\n\\n\\ndef list_inp(v_type):\\n return...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"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 cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n long long n, m, l, r, curr = 0;\\n string s;\\n cin >> n >> m;\\n cin >> s;\\n vector > pre(6, vector(n + 1));\\n string t = \\\"abc\\\";\\n do {\\n for (long long i = 0; i < n; i++)\\n pre[curr][i + 1] = pre[curr][i] + (s.at(i) != t.at(i % 3));\\n curr++;\\n } while (next_permutation(t.begin(), t.end()));\\n for (long long i = 0; i < m; i++) {\\n cin >> l >> r;\\n long long ans = n;\\n for (long long i = 0; i < 6; i++) ans = min(ans, pre[i][r] - pre[i][l - 1]);\\n cout << ans << endl;\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"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,...\",\"targets\":\"#include \\nusing namespace std;\\nconst long long int N = 5e5 + 5;\\nlong long int pre[N];\\npair tree[4 * N];\\nlong long int inf = 1e18 + 5;\\nvoid build(long long int node, long long int start, long long int end) {\\n if (start == end) {\\n tree[node] = {pre[start], pre[start]};\\n return;\\n }\\n long long int mid = (start + end) \\/ 2;\\n build(node * 2, start, mid);\\n build(node * 2 + 1, mid + 1, end);\\n tree[node].first = max(tree[node * 2].first, tree[node * 2 + 1].first);\\n tree[node].second = min(tree[node * 2].second, tree[node * 2 + 1].second);\\n}\\npair get(long long int node, long long int start,\\n long long int end, long long int l,\\n long long int r) {\\n if (start > end || start > r || end < l) return {-inf, inf};\\n if (start >= l && end <= r) return tree[node];\\n long long int mid = (start + end) \\/ 2;\\n auto a = get(node * 2, start, mid, l, r);\\n auto b = get(node * 2 + 1, mid + 1, end, l, r);\\n pair res;\\n res.first = max(a.first, b.first);\\n res.second = min(a.second, b.second);\\n return res;\\n}\\nsigned main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n long long int n, q;\\n cin >> n >> q;\\n long long int a[n + 1];\\n long long int b[n + 1];\\n for (long long int i = 1; i <= n; i++) cin >> a[i];\\n for (long long int i = 1; i <= n; i++) {\\n cin >> b[i];\\n pre[i] = pre[i - 1] + b[i] - a[i];\\n }\\n build(1, 1, n);\\n while (q--) {\\n long long int l, r;\\n cin >> l >> r;\\n if (pre[l - 1] != pre[r]) {\\n cout << \\\"-1\\\\n\\\";\\n continue;\\n }\\n auto g = get(1, 1, n, l, r);\\n if (g.second < pre[l - 1]) {\\n cout << \\\"-1\\\\n\\\";\\n continue;\\n }\\n cout << g.first - pre[l - 1] << \\\"\\\\n\\\";\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"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\\nimpor\",\"targets\":\"t java.util.Scanner;\\n\\npublic class Disliikes {\\n public static void main(String[] args) {\\n Scanner sc=new Scanner(System.in);\\n\\n int t=sc.nextInt();\\n\\/\\/\\n\\/\\/ int[] a=new int[1001];\\n\\/\\/\\n\\/\\/\\n\\/\\/ int k=0;\\n\\/\\/\\n\\/\\/ for(int i=1;i<=15000;i++)\\n\\/\\/ {\\n\\/\\/ if(k>=1000)\\n\\/\\/ {\\n\\/\\/ break;\\n\\/\\/ }\\n\\/\\/ if(i%3!=0&&i%10!=3)\\n\\/\\/ {\\n\\/\\/ a[k++]=i;\\n\\/\\/ }\\n\\/\\/ }\\n\\n while (t-->0)\\n {\\n int n=sc.nextInt();\\n\\n int k=0;\\n\\n for(int i=1;i<=15000;i++)\\n {\\n if(k==n)\\n {\\n System.out.println(i-1);\\n break;\\n }\\n if(i%3!=0&&i%10!=3)\\n {\\n k++;\\n }\\n }\\n \\/\\/ System.out.println(a[n-1]);\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Dwarfs have planted a very interesting plant, which is a triangle directed \\\"upwards\\\". This plant has an amusing feature. After one year a triangle plant directed \\\"upwards\\\" divides into four triangle plants: three of them will point \\\"upwards\\\" and one will point \\\"downwards\\\". After another year, each triangle plant divides into four triangle plants: three of them will be directed in the same direction as the parent plant, and one of them will be directed in the opposite direction. Then each year the process repeats. The figure below illustrates this process.\\n\\n\\n\\nHelp the dwarfs find out how many triangle plants that point \\\"upwards\\\" will be in n years.\\n\\nInput\\n\\nThe first line contains a single integer n (0 ≤ n ≤ 1018) — the number of full years when the plant grew.\\n\\nPlease do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specifier.\\n\\nOutput\\n\\nPrint a single integer — the remainder of dividing the number of plants that will point \\\"upwards\\\" in n years by 1000000007 (109 + 7).\\n\\nExamples\\n\\nInput\\n\\n1\\n\\n\\nOutput\\n\\n3\\n\\n\\nInput\\n\\n2\\n\\n\\nOutput\\n\\n10\\n\\nNote\\n\\nThe first test sample corresponds to the second triangle on the figure in the statement. The second test sample corresponds to the third one.\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\nimport java.lang.Math.*;\\npublic class tri\\n{\\n public static void main(String args[])throws Exception\\n {\\n Scanner in=new Scanner(System.in);\\n PrintWriter pw=new PrintWriter(System.out);\\n long n=in.nextLong();\\n if(n==0)\\n pw.println(1);\\n else\\n {\\n long a=decrypt(2,n-1,1000000007);\\n long b=decrypt(2,n,1000000007);\\n long ans=((a*(b+1)))%1000000007;\\n pw.println(ans);\\n }\\n pw.flush();\\n }\\n public static long decrypt(long a,long b,long n)\\n {\\n long res=1;\\n while(b>0)\\n {\\n if (b % 2==1) { res = (res * a) % n; }\\n\\n a = (a * a) % n;\\n b \\/= 2;\\n\\n }\\n return res; \\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 distinct elements and an integer k. Each element in the array is a non-negative integer not exceeding 2^k-1.\\n\\nLet's define the XOR distance for a number x as the value of \\n\\n$$$f(x) = min_{i = 1}^{n} min_{j = i + 1}^{n} |(a_i ⊕ x) - (a_j ⊕ x)|,$$$\\n\\nwhere ⊕ denotes [the bitwise XOR operation](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#XOR).\\n\\nFor every integer x from 0 to 2^k-1, you have to calculate f(x).\\n\\nInput\\n\\nThe first line contains two integers n and k (1 ≤ k ≤ 19; 2 ≤ n ≤ 2^k).\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (0 ≤ a_i ≤ 2^k-1). All these integers are distinct.\\n\\nOutput\\n\\nPrint 2^k integers. The i-th of them should be equal to f(i-1).\\n\\nExamples\\n\\nInput\\n\\n\\n3 3\\n6 0 3\\n\\n\\nOutput\\n\\n\\n3 1 1 2 2 1 1 3 \\n\\n\\nInput\\n\\n\\n3 4\\n13 4 2\\n\\n\\nOutput\\n\\n\\n2 2 6 6 3 1 2 2 2 2 1 3 6 6 2 2 \\n\\nNote\\n\\nConsider the first example:\\n\\n * for x = 0, if we apply bitwise XOR to the elements of the array with x, we get the array [6, 0, 3], and the minimum absolute difference of two elements is 3; \\n * for x = 1, if we apply bitwise XOR to the elements of the array with x, we get the array [7, 1, 2], and the minimum absolute difference of two elements is 1; \\n * for x = 2, if we apply bitwise XOR to the elements of the array with x, we get the array [4, 2, 1], and the minimum absolute difference of two elements is 1; \\n * for x = 3, if we apply bitwise XOR to the elements of the array with x, we get the array [5, 3, 0], and the minimum absolute difference of two elements is 2; \\n * for x = 4, if we apply bitwise XOR to the elements of the array with x, we get the array [2, 4, 7], and the minimum absolute difference of two elements is 2; \\n * for x = 5, if we apply bitwise XOR to the elements of the array with x, we get the array [3, 5, 6], and the minimum absolute difference of two elements is 1; \\n * for x = 6, if we apply bitwise XOR to the elements of the array with x, we get the array [0, 6, 5], and the minimum absolute difference of two elements is 1; \\n * for x = 7, if we apply...\\nSolve the task in CPP.\",\"targets\":\"#include \\nint getbit(long long x, int y) { return (x >> y) & 1; }\\nlong long getoff(long long x, int y) { return x ^ ((1ll) << y); }\\nusing namespace std;\\nstruct node {\\n int diff, ma, mi;\\n node *c[2];\\n node() {\\n diff = 2e9;\\n ma = -1e9;\\n mi = 1e9;\\n c[0] = nullptr;\\n c[1] = nullptr;\\n }\\n};\\nnode *trie = new node;\\nint n, k, f[2000010];\\nvoid calc(node *u, int depth) {\\n u->ma = -1e9;\\n u->mi = 1e9;\\n u->diff = 2e9;\\n u->ma = max(u->c[0]->ma, (1 << depth) + u->c[1]->ma);\\n u->mi = min(u->c[0]->mi, (1 << depth) + u->c[1]->mi);\\n if (u->ma < 0) u->ma = -1e9;\\n if (u->c[0]->ma != -1e9 && u->c[0]->ma != u->ma)\\n u->mi = min(u->mi, u->c[0]->ma);\\n int f1 = u->c[1]->mi;\\n if (f1 == 1e9 && u->c[1]->ma != -1e9) f1 = u->c[1]->ma;\\n int f2 = u->c[0]->ma;\\n if (f2 == -1e9 && u->c[0]->mi != 1e9) f2 = u->c[0]->mi;\\n u->diff = min(u->c[0]->diff, u->c[1]->diff);\\n u->diff = min(u->diff, f1 - f2 + (1 << depth));\\n}\\nvoid build(node *u, int depth) {\\n if (depth == -1) return;\\n u->c[0] = new node;\\n u->c[1] = new node;\\n build(u->c[0], depth - 1);\\n build(u->c[1], depth - 1);\\n}\\nvoid add(node *u, int L, int x, int depth) {\\n if (depth == -1) {\\n u->ma = x - L;\\n return;\\n }\\n int kt = getbit(x, depth);\\n if (kt == 0)\\n add(u->c[kt], L, x, depth - 1);\\n else\\n add(u->c[kt], L + (1 << depth), x, depth - 1);\\n calc(u, depth);\\n}\\nvoid update(node *u, int depth, int stop) {\\n if (depth == stop) {\\n swap(u->c[0], u->c[1]);\\n calc(u, depth);\\n return;\\n }\\n update(u->c[0], depth - 1, stop);\\n update(u->c[1], depth - 1, stop);\\n calc(u, depth);\\n}\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n cin >> n >> k;\\n build(trie, k - 1);\\n for (int i = 1; i <= n; ++i) {\\n int x;\\n cin >> x;\\n add(trie, 0, x, k - 1);\\n }\\n vector lvt;\\n lvt.emplace_back(0);\\n for (int q = 1; q <= k; ++q) {\\n int sz = lvt.size();\\n while (sz--) lvt.emplace_back(lvt[sz] * 2 + 1);\\n for (int i = 0; i < (1 << (q - 1)); ++i) lvt[i] <<= 1;\\n }\\n vector vt;\\n int pos;\\n for (int i...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Bandits appeared in the city! One of them is trying to catch as many citizens as he can.\\n\\nThe city consists of n squares connected by n-1 roads in such a way that it is possible to reach any square from any other square. The square number 1 is the main square.\\n\\nAfter Sunday walk all the roads were changed to one-way roads in such a way that it is possible to reach any square from the main square.\\n\\nAt the moment when the bandit appeared on the main square there were a_i citizens on the i-th square. Now the following process will begin. First, each citizen that is currently on a square with some outgoing one-way roads chooses one of such roads and moves along it to another square. Then the bandit chooses one of the one-way roads outgoing from the square he is located and moves along it. The process is repeated until the bandit is located on a square with no outgoing roads. The bandit catches all the citizens on that square.\\n\\nThe bandit wants to catch as many citizens as possible; the citizens want to minimize the number of caught people. The bandit and the citizens know positions of all citizens at any time, the citizens can cooperate. If both sides act optimally, how many citizens will be caught?\\n\\nInput\\n\\nThe first line contains a single integer n — the number of squares in the city (2 ≤ n ≤ 2⋅10^5).\\n\\nThe second line contains n-1 integers p_2, p_3 ... p_n meaning that there is a one-way road from the square p_i to the square i (1 ≤ p_i < i). \\n\\nThe third line contains n integers a_1, a_2, ..., a_n — the number of citizens on each square initially (0 ≤ a_i ≤ 10^9).\\n\\nOutput\\n\\nPrint a single integer — the number of citizens the bandit will catch if both sides act optimally.\\n\\nExamples\\n\\nInput\\n\\n\\n3\\n1 1\\n3 1 2\\n\\n\\nOutput\\n\\n\\n3\\n\\n\\nInput\\n\\n\\n3\\n1 1\\n3 1 3\\n\\n\\nOutput\\n\\n\\n4\\n\\nNote\\n\\nIn the first example the citizens on the square 1 can split into two groups 2 + 1, so that the second and on the third squares will have 3 citizens each.\\n\\nIn the second example no matter how citizens act the bandit can catch at least 4 citizens.\",\"targets\":\"#include \\nusing namespace std;\\nconst long long MOD = 1e9 + 7;\\nconst long long INF = 1e9 + 9;\\nconst long long N = 500500;\\nlong long p[N], a[N], leaves[N], sum[N];\\nvector adj[N];\\nvoid dfs(long long src, long long p) {\\n sum[src] += a[src];\\n bool leaf = true;\\n for (auto z : adj[src]) {\\n if (z != p) {\\n leaf = false;\\n dfs(z, src);\\n leaves[src] += leaves[z];\\n sum[src] += sum[z];\\n }\\n }\\n if (leaf) {\\n leaves[src]++;\\n }\\n}\\nsigned main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(0);\\n long long n;\\n cin >> n;\\n for (long long i = 2; i <= n; i++) {\\n cin >> p[i];\\n adj[i].push_back(p[i]);\\n adj[p[i]].push_back(i);\\n }\\n for (long long i = 1; i <= n; i++) cin >> a[i];\\n dfs(1, -1);\\n long long ans = 0;\\n for (long long i = 1; i <= n; i++) {\\n ans = max(ans, (sum[i] + leaves[i] - 1) \\/ leaves[i]);\\n }\\n cout << ans;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"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.\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"from fractions import Fraction\\nfrom collections import defaultdict\\nimport math\\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)\\n\\n\\ndef input(): return sys.stdin.readline().rstrip(\\\"\\\\r\\\\n\\\")\\n#----------------------------------------Code Starts Here--------------------------------------------#\\n\\n\\nt = int(input())\\nfor _ in range(t):\\n n = int(input())\\n l = list(map(int, input().split()))\\n p = list(map(int, input().split()))\\n ss =...\",\"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 PYTHON3.\",\"targets\":\"l=[]\\nt=1\\nwhile len(l)!=1000:\\n if list(str(t))[len(list(str(t)))-1]!=\\\"3\\\" and t%3!=0:\\n #print(\\\"k\\\")\\n l.append(t)\\n t+=1\\n#print(l)\\nfor _ in range(0,int(input())):\\n a=int(input())\\n #b=list(map(int,input().split()))\\n print(l[a-1])\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nThe 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\":\"#include \\nusing namespace std;\\nconst int N = 1e6 + 5;\\nint get() {\\n char c = getchar();\\n while (c != '.' && c != 'X') c = getchar();\\n return c == 'X';\\n}\\nint read() {\\n int s = 0;\\n char c = getchar(), lc = '+';\\n while (c < '0' || '9' < c) lc = c, c = getchar();\\n while ('0' <= c && c <= '9') s = s * 10 + c - '0', c = getchar();\\n return lc == '-' ? -s : s;\\n}\\nvoid write(int x) {\\n if (x < 0) putchar('-'), x = -x;\\n if (x < 10)\\n putchar(x + '0');\\n else\\n write(x \\/ 10), putchar(x % 10 + '0');\\n}\\nvoid print(int x, char c = '\\\\n') {\\n write(x);\\n putchar(c);\\n}\\nvector a[N];\\nint sum1[N], sum2[N], sum[N];\\nsigned main(signed Goodbye, char *Wangang[]) {\\n (void)Goodbye, (void)Wangang;\\n int n = read(), m = read();\\n for (int i = 1; i <= n; i++) a[i].resize(m + 1);\\n for (int i = 1; i <= n; i++)\\n for (int j = 1; j <= m; j++) a[i][j] = get();\\n for (int i = 1; i < n; i++)\\n for (int j = 2; j <= m; j++)\\n if (a[i][j] && a[i + 1][j - 1]) sum[j]++;\\n for (int j = 2; j <= m; j++) sum[j] += sum[j - 1];\\n int Q = read();\\n while (Q--) {\\n int l = read(), r = read();\\n int ans = sum[r] - sum[l];\\n puts(ans ? \\\"NO\\\" : \\\"YES\\\");\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"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.util.*;\\npublic class Solution {\\n\\tpublic static void main(String[] args) throws IOException \\n\\t{ \\n\\t\\tFastScanner f= new FastScanner(); \\n\\t\\tint ttt=1;\\n\\t\\tttt=f.nextInt();\\n\\t\\tPrintWriter out=new PrintWriter(System.out);\\n\\t\\touter: for(int tt=0;tt r=new PriorityQueue<>();\\n\\t\\t\\tPriorityQueue b=new PriorityQueue<>();\\n\\t\\t\\tfor(int i=0;icurr) {\\n\\t\\t\\t\\t\\tflag=false;\\n\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\telse {\\n\\t\\t\\t\\t\\tcurr--;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\t\\n\\t\\t\\tcurr=1;\\n\\t\\t\\twhile(!b.isEmpty()) {\\n\\t\\t\\t\\tint now=b.poll();\\n\\t\\t\\t\\tif(now q = new ArrayList<>();\\n for (int i: p) q.add( i);\\n Collections.sort(q);\\n for (int i = 0; i < p.length; i++) p[i] = q.get(i);\\n }\\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\\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\\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.\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\ninline int read() {\\n register int s = 0, f = 0;\\n register char ch = getchar();\\n while (!isdigit(ch)) {\\n f |= (ch == '-');\\n ch = getchar();\\n }\\n while (isdigit(ch)) {\\n s = (s << 1) + (s << 3) + (ch ^ 48);\\n ch = getchar();\\n }\\n return f ? -s : s;\\n}\\ninline void write(int x) {\\n if (x < 0) {\\n putchar('-');\\n x = -x;\\n }\\n if (x > 9) {\\n write(x \\/ 10);\\n }\\n putchar(x % 10 + '0');\\n}\\nlong long a[1005], n, ans;\\nsigned main() {\\n cin >> n;\\n for (auto i = 1; i <= n; i += 1) {\\n cin >> a[i];\\n }\\n for (auto i = 1; i <= n; i += 2) {\\n long long sum = 0;\\n long long mn = a[i] - 1;\\n for (auto j = i + 1; j <= n; j += 2) {\\n sum += a[j - 1];\\n sum -= a[j];\\n if (sum < 0) {\\n ans += min(a[j] + sum + 1, mn + 1);\\n break;\\n } else {\\n ans += min(a[j], max(0LL, mn - sum + 1));\\n if (j == i + 1) {\\n mn = min(a[i], sum);\\n } else {\\n mn = min(mn, sum);\\n }\\n }\\n }\\n }\\n cout << ans;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"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}\\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 long long int arr[n][5];\\n for (int i = 0; i < n; i++) {\\n for (int j = 0; j < 5; j++) cin >> arr[i][j];\\n }\\n int best = 0;\\n for (int i = 1; i < n; i++) {\\n int first = 0;\\n for (int j = 0; j < 5; j++) {\\n if (arr[i][j] > arr[best][j]) first++;\\n }\\n if (first < 3) best = i;\\n }\\n int ans = best;\\n bool temp = true;\\n for (int i = 0; i < n; i++) {\\n if (i == ans) continue;\\n int first = 0;\\n for (int j = 0; j < 5; j++) {\\n if (arr[i][j] > arr[ans][j]) first++;\\n }\\n if (first < 3) {\\n temp = false;\\n break;\\n }\\n }\\n if (!temp)\\n cout << -1 << \\\"\\\\n\\\";\\n else\\n cout << ans + 1 << \\\"\\\\n\\\";\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alice is the leader of the State Refactoring Party, and she is about to become the prime minister. \\n\\nThe elections have just taken place. There are n parties, numbered from 1 to n. The i-th party has received a_i seats in the parliament.\\n\\nAlice's party has number 1. In order to become the prime minister, she needs to build a coalition, consisting of her party and possibly some other parties. There are two conditions she needs to fulfil: \\n\\n * The total number of seats of all parties in the coalition must be a strict majority of all the seats, i.e. it must have strictly more than half of the seats. For example, if the parliament has 200 (or 201) seats, then the majority is 101 or more seats. \\n * Alice's party must have at least 2 times more seats than any other party in the coalition. For example, to invite a party with 50 seats, Alice's party must have at least 100 seats. \\n\\n\\n\\nFor example, if n=4 and a=[51, 25, 99, 25] (note that Alice'a party has 51 seats), then the following set [a_1=51, a_2=25, a_4=25] can create a coalition since both conditions will be satisfied. However, the following sets will not create a coalition:\\n\\n * [a_2=25, a_3=99, a_4=25] since Alice's party is not there; \\n * [a_1=51, a_2=25] since coalition should have a strict majority; \\n * [a_1=51, a_2=25, a_3=99] since Alice's party should have at least 2 times more seats than any other party in the coalition. \\n\\n\\n\\nAlice does not have to minimise the number of parties in a coalition. If she wants, she can invite as many parties as she wants (as long as the conditions are satisfied). If Alice's party has enough people to create a coalition on her own, she can invite no parties.\\n\\nNote that Alice can either invite a party as a whole or not at all. It is not possible to invite only some of the deputies (seats) from another party. In other words, if Alice invites a party, she invites all its deputies.\\n\\nFind and print any suitable coalition.\\n\\nInput\\n\\nThe first line contains a single integer n (2 ≤ n ≤ 100) — the number of parties.\\n\\nThe second...\\n#impo\",\"targets\":\"rt resource\\n#resource.setrlimit(resource.RLIMIT_STACK, [0x100000000, resource.RLIM_INFINITY])\\nimport sys\\nimport threading\\n#threading.Thread(target=main).start()\\nthreading.stack_size(2**26)\\nsys.setrecursionlimit(10**6)\\nmod=10**9+7\\n#print mod\\n#fact=[1]\\n#for i in range(1,100001):\\n# fact.append((fact[-1]*i)%mod)\\n#ifact=[0]*100001\\n#ifact[100000]=pow(fact[100000],mod-2,mod)\\n#for i in range(100000,0,-1):\\n# ifact[i-1]=(i*ifact[i])%mod\\nfrom sys import stdin, stdout\\nimport bisect\\nfrom bisect import bisect_left as bl #c++ lowerbound bl(array,element)\\nfrom bisect import bisect_right as br #c++ upperbound\\n#import itertools\\nimport collections\\nimport math\\nimport heapq\\n#from random import randint as rn\\n#from Queue import Queue as Q\\ndef modinv(n,p):\\n return pow(n,p-2,p)\\ndef ncr(n,r,p): #for using this uncomment the lines calculating fact and ifact\\n t=((fact[n])*((ifact[r]*ifact[n-r])%p))%p\\n return t\\ndef ain(): #takes array as input\\n return map(int,sin().split())\\ndef sin(): #takes string as input\\n return stdin.readline().strip()\\ndef GCD(x,y):\\n while(y):\\n x, y = y, x % y\\n return x\\ndef isprime(x):\\n if(x==1):\\n return False\\n elif(x<4):\\n return True\\n for i in range(2,int(math.sqrt(x))+1):\\n if(x%i==0):\\n return False\\n return True\\n\\\"\\\"\\\"*******************************************************\\\"\\\"\\\"\\nn=input()\\na=ain()\\nw=[\\\"1\\\"]\\ns=a[0]\\nr=sum(a)-a[0]\\nfor i in range(1,n):\\n if((a[i]*2)<=a[0]):\\n s+=a[i]\\n w.append(str(i+1))\\n r-=a[i]\\nif(s>r):\\n print len(w)\\n print \\\" \\\".join(w)\\nelse:\\n print 0\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"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.\\n\\nimpo\",\"targets\":\"rt java.io.BufferedReader;\\nimport java.io.InputStreamReader;\\nimport java.util.*;\\n\\npublic class Solution {\\n\\n public static void main(String... args) throws Exception {\\n Scanner scan = new Scanner(System.in);\\n int t = scan.nextInt();\\n \\/\\/ int t=1;\\n while (t-- > 0) {\\n solve(scan);\\n }\\n }\\n\\n public static void solve(Scanner scan) {\\n int a = scan.nextInt();\\n int p1 = scan.nextInt();\\n int b = scan.nextInt();\\n int p2 = scan.nextInt();\\n int x = a;\\n while (x > 0) {\\n x \\/= 10;\\n p1++;\\n }\\n x = b;\\n while (x > 0) {\\n x \\/= 10;\\n p2++;\\n }\\n if (p1 == p2) {\\n while (a < 1000000) {\\n a *= 10;\\n }\\n while (b < 1000000) {\\n b *= 10;\\n }\\n if (a == b) {\\n System.out.println('=');\\n } else {\\n System.out.println(a < b ? \\\"<\\\" : \\\">\\\");\\n }\\n } else {\\n System.out.println(p1 > p2 ? \\\">\\\" : \\\"<\\\");\\n }\\n\\n }\\n\\n static void shuffleArray(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 int randomPos = i + rnd.nextInt(n - i);\\n arr[i] = arr[randomPos];\\n arr[randomPos] = tmp;\\n }\\n }\\n\\n public static long LCM(long a, long b) {\\n return (a * b) \\/ GCD(a, b);\\n }\\n\\n public static long GCD(long a, long b) {\\n if (b == 0)\\n return a;\\n return GCD(b, a % b);\\n }\\n\\n}\",\"language\":\"python\",\"split\":\"test\",\"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 CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 1e6 + 5;\\nint n, m;\\nstruct Seg {\\n int l, r, w;\\n bool operator<(const Seg& t) const { return w < t.w; }\\n} seg[N];\\nstruct Node {\\n int l, r;\\n int x, tag;\\n} tr[N << 2];\\nvoid pushup(int u) { tr[u].x = min(tr[u << 1].x, tr[u << 1 | 1].x); }\\nvoid pushdown(int u) {\\n auto &root = tr[u], &left = tr[u << 1], &right = tr[u << 1 | 1];\\n int tag = root.tag;\\n if (tag) {\\n left.x += tag;\\n left.tag += tag;\\n right.x += tag;\\n right.tag += tag;\\n root.tag = 0;\\n }\\n}\\nvoid build(int u, int l, int r) {\\n tr[u] = {l, r, 0, 0};\\n if (l == r) return;\\n int mid = l + r >> 1;\\n build(u << 1, l, mid);\\n build(u << 1 | 1, mid + 1, r);\\n pushup(u);\\n}\\nvoid add(int u, int l, int r, int x) {\\n if (l <= tr[u].l && r >= tr[u].r) {\\n tr[u].x += x;\\n tr[u].tag += x;\\n return;\\n }\\n int mid = tr[u].l + tr[u].r >> 1;\\n pushdown(u);\\n if (l <= mid) add(u << 1, l, r, x);\\n if (r > mid) add(u << 1 | 1, l, r, x);\\n pushup(u);\\n}\\nint ask(int u, int l, int r) {\\n if (l <= tr[u].l && r >= tr[u].r) return tr[u].x;\\n pushdown(u);\\n int ans = INT_MAX;\\n int mid = tr[u].l + tr[u].r >> 1;\\n if (l <= mid) ans = min(ans, ask(u << 1, l, r));\\n if (r > mid) ans = min(ans, ask(u << 1 | 1, l, r));\\n return ans;\\n}\\nint main() {\\n ios::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n cin >> n >> m;\\n for (int i = 0; i < n; ++i) {\\n cin >> seg[i].l >> seg[i].r >> seg[i].w;\\n seg[i].r--;\\n }\\n m--;\\n build(1, 1, m);\\n sort(seg, seg + n);\\n int ans = INT_MAX;\\n for (int l = 0, r = 0; r < n; ++r) {\\n add(1, seg[r].l, seg[r].r, 1);\\n if (ask(1, 1, m) == 0) continue;\\n ans = min(ans, seg[r].w - seg[l].w);\\n while (l <= r && ask(1, 1, m) > 0) {\\n add(1, seg[l].l, seg[l].r, -1);\\n ++l;\\n if (ask(1, 1, m) > 0) ans = min(ans, seg[r].w - seg[l].w);\\n }\\n }\\n cout << ans;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"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...\",\"targets\":\"import java.util.Scanner;\\n\\npublic class shubhAm {\\n\\n public static void main(String[] args) {\\n Scanner sc=new Scanner(System.in);\\n int t=sc.nextInt();\\n for(int i=0;ires)\\n res=temp-j;\\n }\\n System.out.println(res);\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"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 MOD = 998244353;\\nvoid chkmax(long long &a, long long b) {\\n if (a < b) a = b;\\n}\\nvoid chkmin(long long &a, long long b) {\\n if (a > b) a = b;\\n}\\nlong long qpow(long long d, long long z) {\\n long long res = 1;\\n for (; z; z >>= 1) {\\n if (z & 1) res = res * d % MOD;\\n d = d * d % MOD;\\n }\\n return res;\\n}\\nint n;\\nint d[200005];\\nvoid solve() {\\n scanf(\\\"%d\\\", &n);\\n int Max = 0;\\n for (int i = 1; i <= n; i++) {\\n scanf(\\\"%d\\\", &d[i]);\\n if (Max < d[i]) Max = d[i];\\n }\\n int cM0 = 0, cM1 = 0;\\n for (int i = 1; i <= n; i++) {\\n if (d[i] == Max)\\n cM0++;\\n else if (d[i] + 1 == Max)\\n cM1++;\\n }\\n long long ff = 1;\\n for (int i = 1; i <= n; i++) ff = ff * i % MOD;\\n assert(cM0 >= 1);\\n if (cM0 >= 2) {\\n long long ans = 1;\\n for (int i = 1; i <= n; i++) ans = ans * i % MOD;\\n printf(\\\"%lld\\\\n\\\", ans);\\n } else if (cM1 == 0) {\\n printf(\\\"0\\\\n\\\");\\n } else {\\n long long ans = 1;\\n for (int i = 0; i < cM1 + 1; i++) ans = ans * (n - i) % MOD;\\n for (int i = 1; i <= n - cM1 - 1; i++) ans = ans * i % MOD;\\n ans = ans * qpow(cM1 + 1, MOD - 2) % MOD;\\n ans = (ff - ans + MOD) % MOD;\\n printf(\\\"%lld\\\\n\\\", ans);\\n }\\n return;\\n}\\nint main() {\\n int t;\\n scanf(\\\"%d\\\", &t);\\n while (t--) solve();\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"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\\nusing namespace std;\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n int t;\\n cin >> t;\\n long long a[100000];\\n long long p = 1;\\n long long l = 1000000000 + 7;\\n for (int i = 0; i < 100000; i++) {\\n p = p * (2 * i + 1) % l;\\n if (i > 0) p = p * (2 * i + 2) % l;\\n a[i] = p;\\n }\\n for (; t > 0; t--) {\\n long n;\\n cin >> n;\\n cout << a[n - 1] << \\\"\\\\n\\\";\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"It's another Start[c]up finals, and that means there is pizza to order for the onsite contestants. There are only 2 types of pizza (obviously not, but let's just pretend for the sake of the problem), and all pizzas contain exactly S slices.\\n\\nIt is known that the i-th contestant will eat si slices of pizza, and gain ai happiness for each slice of type 1 pizza they eat, and bi happiness for each slice of type 2 pizza they eat. We can order any number of type 1 and type 2 pizzas, but we want to buy the minimum possible number of pizzas for all of the contestants to be able to eat their required number of slices. Given that restriction, what is the maximum possible total happiness that can be achieved?\\n\\nInput\\n\\nThe first line of input will contain integers N and S (1 ≤ N ≤ 105, 1 ≤ S ≤ 105), the number of contestants and the number of slices per pizza, respectively. N lines follow.\\n\\nThe i-th such line contains integers si, ai, and bi (1 ≤ si ≤ 105, 1 ≤ ai ≤ 105, 1 ≤ bi ≤ 105), the number of slices the i-th contestant will eat, the happiness they will gain from each type 1 slice they eat, and the happiness they will gain from each type 2 slice they eat, respectively.\\n\\nOutput\\n\\nPrint the maximum total happiness that can be achieved.\\n\\nExamples\\n\\nInput\\n\\n3 12\\n3 5 7\\n4 6 7\\n5 9 5\\n\\n\\nOutput\\n\\n84\\n\\n\\nInput\\n\\n6 10\\n7 4 7\\n5 8 8\\n12 5 8\\n6 11 6\\n3 3 7\\n5 9 6\\n\\n\\nOutput\\n\\n314\\n\\nNote\\n\\nIn the first example, you only need to buy one pizza. If you buy a type 1 pizza, the total happiness will be 3·5 + 4·6 + 5·9 = 84, and if you buy a type 2 pizza, the total happiness will be 3·7 + 4·7 + 5·5 = 74.\\\":\",\"targets\":\"#include \\nusing namespace std;\\nvector > a, b;\\nlong long n, s, ans, na, nb, ta, tb, i, j;\\nlong long s1, a1, b1;\\npair k;\\nint main() {\\n cin >> n >> s;\\n for (i = 0; i < n; i++) {\\n cin >> s1 >> a1 >> b1;\\n if (a1 > b1) {\\n ans += s1 * a1;\\n na += s1;\\n k.first = a1 - b1;\\n k.second = s1;\\n a.push_back(k);\\n } else {\\n ans += s1 * b1;\\n nb += s1;\\n k.first = b1 - a1;\\n k.second = s1;\\n b.push_back(k);\\n }\\n }\\n na %= s;\\n nb %= s;\\n if (na + nb > s) {\\n cout << ans;\\n return 0;\\n }\\n sort(a.begin(), a.end());\\n sort(b.begin(), b.end());\\n for (i = 0; na; i++) {\\n ta += min(na, a[i].second) * a[i].first;\\n na -= min(na, a[i].second);\\n }\\n for (i = 0; nb; i++) {\\n tb += min(nb, b[i].second) * b[i].first;\\n nb -= min(nb, b[i].second);\\n }\\n ans -= min(ta, tb);\\n cout << ans;\\n}\",\"language\":\"python\",\"split\":\"train\",\"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...\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int t;\\n cin >> t;\\n while (t--) {\\n long long n, x;\\n cin >> n;\\n long long ans = 0;\\n for (int i = 1; i <= n; i++) {\\n cin >> x;\\n if (x > i) ans = max(ans, abs(x - i));\\n }\\n cout << ans << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"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 \\nSolve the task in PYTHON.\",\"targets\":\"n = int(raw_input())\\ndig = [ord(c) - ord('0') for c in str(n)]\\nm = max(dig)\\nl = [''.join(['1' if d > i else '0' for d in dig]).lstrip('0') for i in range(m)]\\nprint m\\nprint ' '.join(l)\\nassert sum(int(x) for x in l) == n\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"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;\\nint main() {\\n int t;\\n cin >> t;\\n while (t--) {\\n string s;\\n queue q;\\n cin >> s;\\n int n = s.size();\\n if (n % 2 == 0) {\\n int cond = 0;\\n int i;\\n for (i = 0; i < n \\/ 2; i++) {\\n q.push(s[i]);\\n }\\n for (; i < n; i++) {\\n if (q.front() == s[i]) {\\n q.pop();\\n } else {\\n cond = 1;\\n break;\\n }\\n }\\n if (cond == 1) {\\n cout << \\\"NO\\\" << endl;\\n } else {\\n cout << \\\"YES\\\" << endl;\\n }\\n } else {\\n cout << \\\"NO\\\" << endl;\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in PYTHON?\\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\":\"from __future__ import division,print_function\\nfrom heapq import*\\nimport sys\\nle = sys.__stdin__.read().split(\\\"\\\\n\\\")[::-1]\\naf=[]\\nfor zorg in range(int(le.pop())):\\n n=int(le.pop())\\n l= list(map(int,le.pop().split()))\\n \\\"\\\"\\\"pref=[0]\\n for k in l:\\n pref.append(pref[-1]+k)\\n af.append(max(pref[k]\\/k+(pref[-1]-pref[k])\\/(n-k) for k in range(1,n)))\\\"\\\"\\\"\\n ma=max(l)\\n s=(sum(l)-ma)\\/(n-1)\\n af.append(ma+s)\\nprint(\\\"\\\\n\\\".join(map(str,af)))\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"After a long journey, the super-space-time immigrant ship carrying you finally discovered a planet that seems to be habitable. The planet, named JOI, is a harsh planet with three types of terrain, \\\"Jungle,\\\" \\\"Ocean,\\\" and \\\"Ice,\\\" as the name implies. A simple survey created a map of the area around the planned residence. The planned place of residence has a rectangular shape of M km north-south and N km east-west, and is divided into square sections of 1 km square. There are MN compartments in total, and the compartments in the p-th row from the north and the q-th column from the west are represented by (p, q). The northwest corner section is (1, 1) and the southeast corner section is (M, N). The terrain of each section is one of \\\"jungle\\\", \\\"sea\\\", and \\\"ice\\\". \\\"Jungle\\\" is represented by J, \\\"sea\\\" is represented by O, and \\\"ice\\\" is represented by one letter I.\\n\\nNow, in making a detailed migration plan, I decided to investigate how many sections of \\\"jungle,\\\" \\\"sea,\\\" and \\\"ice\\\" are included in the rectangular area at K.\\n\\n\\n\\ninput\\n\\nRead the following input from standard input.\\n\\n* The integers M and N are written on the first line, separated by blanks, indicating that the planned residence is M km north-south and N km east-west.\\n* The integer K is written on the second line, which indicates the number of regions to be investigated.\\n* The following M line contains information on the planned residence. The second line of i + (1 ≤ i ≤ M) contains an N-character string consisting of J, O, and I that represents the information of the N section located on the i-th line from the north of the planned residence. ..\\n* The following K line describes the area to be investigated. On the second line of j + M + (1 ≤ j ≤ K), the positive integers aj, bj, cj, and dj representing the jth region are written with blanks as delimiters. (aj, bj) represents the northwest corner section of the survey area, and (cj, dj) represents the southeast corner section of the survey area. However, aj, bj, cj, and dj satisfy 1 ≤ aj ≤ cj ≤ M, 1 ≤ bj ≤ dj ≤...\\nSolve the task in CPP.\",\"targets\":\"#include \\n#include\\n#include\\n#include\\nusing namespace std;\\nint main(){\\n\\tint m, n,kk;\\n\\tcin >> m >> n>>kk;\\n\\tvector > t(m, vector(n));\\n\\tstring s = \\\"JOI\\\";\\n\\tfor (int i = 0; i < m; i++) {\\n\\t\\tstring u;\\n\\t\\tcin >> u;\\n\\t\\tfor (int j = 0; j < n; j++) {\\n\\t\\t\\tchar x = u[j];\\n\\t\\t\\tfor (int k = 0; k < 3; k++) {\\n\\t\\t\\t\\tif (x == s[k]) {\\n\\t\\t\\t\\t\\tt[i][j] = k;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\tvector > > joi(m+1, vector >(n+1,vector(3,0)));\\n\\tfor (int i = 1; i <= m; i++) {\\n\\t\\tfor (int j = 1; j <= n; j++) {\\n\\t\\t\\tfor (int k = 0; k < 3; k++) {\\n\\t\\t\\t\\tjoi[i][j][k] = joi[i - 1][j][k] + joi[i][j - 1][k] - joi[i - 1][j - 1][k];\\n\\t\\t\\t}\\n\\t\\t\\tjoi[i][j][t[i-1][j-1]]++;\\n\\t\\t}\\n\\t}\\n\\tvector > ans(kk,vector (3));\\n\\tfor (int i = 0; i < kk; i++) {\\n\\t\\tint a, b, c, d;\\n\\t\\tcin >> a >> b >> c >> d;\\n\\t\\tfor (int k = 0; k < 3; k++) {\\n\\t\\t ans[i][k]=joi[c][d][k] - joi[c][b - 1][k] - joi[a - 1][d][k] + joi[a - 1][b - 1][k];\\n\\t\\t}\\n\\t}\\n\\tfor(int i=0;i 0) {\\n long n = sc.nextLong();\\n if(n%2!=0)n++;\\n System.out.println(n<6?15:(n \\/ 2) * 5);\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nPetya 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\",\"targets\":\"#include \\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, long long suc = 1) {\\n cout << x;\\n if (suc == 1)\\n cout << '\\\\n';\\n else\\n cout << ' ';\\n}\\ntemplate \\nvoid print(const vector &v, long long suc = 1) {\\n for (long long i = 0; i < v.size(); i++)\\n print(v[i], i == (long long)(v.size()) - 1 ? suc : 2);\\n}\\nlong long x[20000];\\nchar s[20][10004];\\nstruct node {\\n long long x, id;\\n bool operator<(const node &b) const { return x < b.x; }\\n} a[20000];\\nlong long anss[20000];\\nsigned main() {\\n long long t;\\n cin >> t;\\n while (t--) {\\n long long n, m;\\n cin >> n >> m;\\n for (long long i = 1; i <= n; ++i) cin >> x[i];\\n for (long long i = 1; i <= n; ++i) {\\n cin >> (s[i] + 1);\\n }\\n long long ans = -1;\\n for (long long i = 0; i < 1 << n; ++i) {\\n long long res = 0;\\n for (long long j = 1; j <= m; ++j) a[j].x = 0, a[j].id = j;\\n for (long long j = 0; j < n; ++j) {\\n if (!(i >> j & 1)) {\\n res += x[j + 1];\\n for (long long k = 1; k <= m; ++k) {\\n if (s[j + 1][k] == '1') a[k].x -= 1;\\n }\\n } else {\\n res -= x[j + 1];\\n for (long long k = 1; k <= m; ++k) {\\n if (s[j + 1][k] == '1') a[k].x += 1;\\n }\\n }\\n }\\n sort(a + 1, a + 1 + m);\\n for (long long j = 1; j <= m; ++j) {\\n res += j * a[j].x;\\n }\\n if (ans < res) {\\n ans = res;\\n for (long long j = 1; j <= m; ++j) {\\n anss[a[j].id] = j;\\n }\\n }\\n }\\n for (long long i = 1; i <= m; ++i) cout << anss[i] << \\\" \\\";\\n cout << endl;\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nThe 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;\\nvoid solve() {\\n long long x, n;\\n cin >> x >> n;\\n int pp = n % 4;\\n long long z;\\n if (pp == 0)\\n z = 0;\\n else if (pp == 1)\\n z = -n;\\n else if (pp == 2)\\n z = 1;\\n else\\n z = n + 1;\\n long long dre = x % 2 == 0 ? 1 : -1;\\n x += dre * z;\\n cout << x << endl;\\n}\\nint main() {\\n ios::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n cin.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\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nThree 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!\",\"targets\":\"#include \\nusing namespace std;\\nlong long MOD = 1000000007;\\nstatic inline long long safe_mod(long long a) {\\n long long res = a % MOD;\\n if (res < 0) res += MOD;\\n return res;\\n}\\nstatic inline tuple mult(tuple a,\\n tuple b) {\\n auto [a0, a1] = a;\\n auto [b0, b1] = b;\\n return {safe_mod((a0 * b0) - (a1 * b1)),\\n safe_mod(a0 * b1 + a1 * b0 - a1 * b1)};\\n}\\nstatic inline tuple diff(tuple a,\\n tuple b) {\\n return {safe_mod(get<0>(a) - get<0>(b)), safe_mod(get<1>(a) - get<1>(b))};\\n}\\nstatic inline tuple add(tuple a,\\n tuple b) {\\n return {(get<0>(a) + get<0>(b)) % MOD, (get<1>(a) + get<1>(b)) % MOD};\\n}\\nstatic inline vector> divide(\\n vector> p, tuple c) {\\n int n = p.size();\\n vector> r(n - 1);\\n for (int i = n - 1; i >= 1; i--) {\\n r[i - 1] = p[i];\\n p[i - 1] = diff(p[i - 1], mult(p[i], c));\\n }\\n return r;\\n}\\nint main(void) {\\n ios::sync_with_stdio(0);\\n cin.tie(0);\\n cout << fixed << setprecision(14);\\n int n, q;\\n cin >> n >> q;\\n vector coeffs(3 * n + 4, 1);\\n vector inv(3 * n + 4, 1);\\n for (int i = 2; i < 3 * n + 4; i++) {\\n inv[i] = MOD - (MOD \\/ i) * inv[MOD % i] % MOD;\\n }\\n for (long long i = 1; i < 3 * n + 4; i++) {\\n coeffs[i] = (((coeffs[i - 1] * (3 * n + 4 - i)) % MOD) * inv[i]) % MOD;\\n if (coeffs[i] < 0) cout << \\\"OOOOOO \\\" << i << \\\" \\\" << coeffs[i] << \\\"\\\\n\\\";\\n }\\n vector e_poly_1(3 * n + 4), e_poly_e(3 * n + 4),\\n e2_poly_1(3 * n + 4), e2_poly_e(3 * n + 4);\\n for (int i = 0; i < 3 * n + 4; i++) {\\n if (i % 3 == 0) {\\n e_poly_1[i] = coeffs[i];\\n e_poly_e[i] = 0;\\n e2_poly_1[i] = coeffs[i];\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"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\":\"\\/* 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. *\\/\\n public class solution\\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 {\\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 \\n \\n catch (IOException e) {\\n e.printStackTrace();\\n }\\n return str;\\n }\\n }\\n\\tpublic static void main (String[] args) throws java.lang.Exception\\n\\t{\\n\\t\\/\\/ your code goes here\\n\\t \\tOutputStream outputStream =System.out;\\n PrintWriter out =new PrintWriter(outputStream);\\n\\t\\tFastReader s = new FastReader();\\n int t = s.nextInt();\\n \\n while(t-->0){\\n long n = s.nextLong();\\n long l = -n+1;\\n long r = n;\\n out.println(l+\\\" \\\"+r);\\n }\\n out.close();\\n\\t}\\n\\n }\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Duff is addicted to meat! Malek wants to keep her happy for n days. In order to be happy in i-th day, she needs to eat exactly ai kilograms of meat.\\n\\n\\n\\nThere is a big shop uptown and Malek wants to buy meat for her from there. In i-th day, they sell meat for pi dollars per kilogram. Malek knows all numbers a1, ..., an and p1, ..., pn. In each day, he can buy arbitrary amount of meat, also he can keep some meat he has for the future.\\n\\nMalek is a little tired from cooking meat, so he asked for your help. Help him to minimize the total money he spends to keep Duff happy for n days. \\n\\nInput\\n\\nThe first line of input contains integer n (1 ≤ n ≤ 105), the number of days.\\n\\nIn the next n lines, i-th line contains two integers ai and pi (1 ≤ ai, pi ≤ 100), the amount of meat Duff needs and the cost of meat in that day.\\n\\nOutput\\n\\nPrint the minimum money needed to keep Duff happy for n days, in one line.\\n\\nExamples\\n\\nInput\\n\\n3\\n1 3\\n2 2\\n3 1\\n\\n\\nOutput\\n\\n10\\n\\n\\nInput\\n\\n3\\n1 3\\n2 1\\n3 2\\n\\n\\nOutput\\n\\n8\\n\\nNote\\n\\nIn the first sample case: An optimal way would be to buy 1 kg on the first day, 2 kg on the second day and 3 kg on the third day.\\n\\nIn the second sample case: An optimal way would be to buy 1 kg on the first day and 5 kg (needed meat for the second and third day) on the second day.\\nUsing python3 can you solve the prior task?\",\"targets\":\"#declaring two empty lists here.\\n\\ndaily_need_of_meat = []\\ndaily_price = []\\n\\n\\n# now taking input of number of days or n\\ntotal_days = int(input())\\n\\n#now taking input of daily need and every day price for n days\\nfor i in range(total_days):\\n need, price = input().split()\\n need = int(need)\\n price = int(price)\\n daily_need_of_meat.append(need)\\n daily_price.append(price)\\n\\n#declaring minimum\\n\\nminimum = 120\\n\\n#now doing the magic here\\nfor i in range(total_days):\\n if daily_price[i] < minimum:\\n minimum = daily_price[i]\\n else:\\n daily_price[i] = minimum\\n\\n#now declaring optimal variable\\n\\noptimal = 0\\n\\nfor i in range(total_days):\\n optimal += (daily_price[i] * daily_need_of_meat[i])\\n\\nprint(optimal)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Omkar is creating a mosaic using colored square tiles, which he places in an n × n grid. When the mosaic is complete, each cell in the grid will have either a glaucous or sinoper tile. However, currently he has only placed tiles in some cells. \\n\\nA completed mosaic will be a mastapeece if and only if each tile is adjacent to exactly 2 tiles of the same color (2 tiles are adjacent if they share a side.) Omkar wants to fill the rest of the tiles so that the mosaic becomes a mastapeece. Now he is wondering, is the way to do this unique, and if it is, what is it?\\n\\nInput\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 2000).\\n\\nThen follow n lines with n characters in each line. The i-th character in the j-th line corresponds to the cell in row i and column j of the grid, and will be S if Omkar has placed a sinoper tile in this cell, G if Omkar has placed a glaucous tile, . if it's empty. \\n\\nOutput\\n\\nOn the first line, print UNIQUE if there is a unique way to get a mastapeece, NONE if Omkar cannot create any, and MULTIPLE if there is more than one way to do so. All letters must be uppercase.\\n\\nIf you print UNIQUE, then print n additional lines with n characters in each line, such that the i-th character in the j^{th} line is S if the tile in row i and column j of the mastapeece is sinoper, and G if it is glaucous. \\n\\nExamples\\n\\nInput\\n\\n\\n4\\nS...\\n..G.\\n....\\n...S\\n\\n\\nOutput\\n\\n\\nMULTIPLE\\n\\n\\nInput\\n\\n\\n6\\nS.....\\n....G.\\n..S...\\n.....S\\n....G.\\nG.....\\n\\n\\nOutput\\n\\n\\nNONE\\n\\n\\nInput\\n\\n\\n10\\n.S....S...\\n..........\\n...SSS....\\n..........\\n..........\\n...GS.....\\n....G...G.\\n..........\\n......G...\\n..........\\n\\n\\nOutput\\n\\n\\nUNIQUE\\nSSSSSSSSSS\\nSGGGGGGGGS\\nSGSSSSSSGS\\nSGSGGGGSGS\\nSGSGSSGSGS\\nSGSGSSGSGS\\nSGSGGGGSGS\\nSGSSSSSSGS\\nSGGGGGGGGS\\nSSSSSSSSSS\\n\\n\\nInput\\n\\n\\n1\\n.\\n\\n\\nOutput\\n\\n\\nNONE\\n\\nNote\\n\\nFor the first test case, Omkar can make the mastapeeces\\n\\nSSSS\\n\\nSGGS\\n\\nSGGS\\n\\nSSSS\\n\\nand \\n\\nSSGG\\n\\nSSGG\\n\\nGGSS\\n\\nGGSS.\\n\\nFor the second test case, it can be proven that it is impossible for Omkar to add tiles to create a mastapeece.\\n\\nFor the third case, it can be proven that the given mastapeece is the...\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nmt19937_64 rng(time(0));\\nconst double PI = acos(-1.L);\\nconst int mn = 2e3 + 10;\\nconst int SIZE = 600;\\nconst int BLOCKS = mn \\/ SIZE + 10;\\nconst long long mod = 1e9 + 7;\\nstring g[mn];\\nint a[mn][mn], b[mn][mn];\\nint c[mn];\\nint main() {\\n cin.tie(0);\\n cin.sync_with_stdio(0);\\n int n;\\n cin >> n;\\n for (int i = 0; i < n; i++) cin >> g[i];\\n if (n % 2 == 1) {\\n printf(\\\"NONE\\\\n\\\");\\n return 0;\\n }\\n for (int i = 0; i < n; i++) {\\n if (i % 2 == 0) {\\n for (int j = 0; j <= i; j++) {\\n a[i - j][j] = i \\/ 2;\\n b[i - j][j] = (j ^ (i \\/ 2)) & 1;\\n }\\n } else {\\n for (int j = 0; j <= i; j++) {\\n b[i - j][j] = (i % 4 == 3);\\n a[i - j][j] = max(i \\/ 2 - j, j - i \\/ 2 - 1);\\n }\\n }\\n }\\n for (int i = 0; i < n; i++)\\n for (int j = n - i; j < n; j++) {\\n a[i][j] = a[n - 1 - i][n - 1 - j];\\n b[i][j] = b[n - 1 - i][n - 1 - j];\\n }\\n memset(c, -1, sizeof(c));\\n for (int i = 0; i < n; i++)\\n for (int j = 0; j < n; j++) {\\n if (g[i][j] == '.') continue;\\n int val = (g[i][j] == 'S') ^ b[i][j];\\n if (c[a[i][j]] != -1 && c[a[i][j]] != val) {\\n printf(\\\"NONE\\\\n\\\");\\n return 0;\\n }\\n c[a[i][j]] = val;\\n }\\n for (int i = 0; i < n \\/ 2; i++)\\n if (c[i] == -1) {\\n printf(\\\"MULTIPLE\\\\n\\\");\\n return 0;\\n }\\n printf(\\\"UNIQUE\\\\n\\\");\\n for (int i = 0; i < n; i++) {\\n for (int j = 0; j < n; j++) {\\n printf(\\\"%c\\\", (c[a[i][j]] ^ b[i][j]) ? 'S' : 'G');\\n }\\n printf(\\\"\\\\n\\\");\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"C: AA グラフ (AA Graph)\\n\\nProblem\\n\\nGiven a graph as an ASCII Art (AA), please print the length of shortest paths from the vertex s to the vertex t. The AA of the graph satisfies the following constraints.\\n\\nA vertex is represented by an uppercase alphabet and symbols `o` in 8 neighbors as follows.\\n\\n\\nooo\\noAo\\nooo\\n\\n\\nHorizontal edges and vertical edges are represented by symbols `-` and `|`, respectively. Lengths of all edges are 1, that is, it do not depends on the number of continuous symbols `-` or `|`. All edges do not cross each other, and all vertices do not overlap and touch each other.\\n\\nFor each vertex, outgoing edges are at most 1 for each directions top, bottom, left, and right. Each edge is connected to a symbol `o` that is adjacent to an uppercase alphabet in 4 neighbors as follows.\\n\\n\\n..|..\\n.ooo.\\n-oAo-\\n.ooo.\\n..|..\\n\\n\\nTherefore, for example, following inputs are not given.\\n\\n\\n..........\\n.ooo..ooo.\\n.oAo..oBo.\\n.ooo--ooo.\\n..........\\n\\n\\n(Edges do not satisfies the constraint about their position.)\\n\\n\\noooooo\\noAooBo\\noooooo\\n\\n\\n(Two vertices are adjacent each other.)\\n\\nInput Format\\n\\n\\nH W s t\\na_1\\n$\\\\vdots$\\na_H\\n\\n\\n* In line 1, two integers H and W, and two characters s and t are given. H and W is the width and height of the AA, respectively. s and t is the start and end vertices, respectively. They are given in separating by en spaces.\\n* In line 1 + i where 1 \\\\leq i \\\\leq H, the string representing line i of the AA is given.\\n\\n\\n\\nConstraints\\n\\n* 3 \\\\leq H, W \\\\leq 50\\n* s and t are selected by uppercase alphabets from `A` to `Z`, and s \\\\neq t.\\n* a_i (1 \\\\leq i \\\\leq H) consists of uppercase alphabets and symbols `o`, `-`, `|`, and `.`.\\n* Each uppercase alphabet occurs at most once in the AA.\\n* It is guaranteed that there are two vertices representing s and t.\\n* The AA represents a connected graph.\\n\\n\\n\\nOutput Format\\n\\nPrint the length of the shortest paths from s to t in one line.\\n\\nExample 1\\n\\n\\n14 16 A...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\n\\nconst int INF = 1e9;\\n\\nint main()\\n{\\n\\tint H, W;\\n\\tchar sc, tc;\\n\\tcin >> H >> W >> sc >> tc;\\n\\tint s = sc - 'A', t = tc - 'A';\\n\\tvector S(H);\\n\\tvector> G(26);\\n\\tfor (int i = 0; i < H; i++) {\\n\\t\\tcin >> S[i];\\n\\t}\\n\\tfor (int i = 0; i < H; i++) {\\n\\t\\tfor (int j = 0; j < W; j++) {\\n\\t\\t\\tif (S[i][j] == '-') {\\n\\t\\t\\t\\tint u = S[i][j - 2] - 'A';\\n\\t\\t\\t\\tint p = j;\\n\\t\\t\\t\\twhile (S[i][p] == '-') {\\n\\t\\t\\t\\t\\tS[i][p] = '.';\\n\\t\\t\\t\\t\\tp++;\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tint v = S[i][p + 1] - 'A';\\n\\t\\t\\t\\tG[u].push_back(v);\\n\\t\\t\\t\\tG[v].push_back(u);\\n\\t\\t\\t}\\n\\t\\t\\tif (S[i][j] == '|') {\\n\\t\\t\\t\\tint u = S[i - 2][j] - 'A';\\n\\t\\t\\t\\tint p = i;\\n\\t\\t\\t\\twhile (S[p][j] == '|') {\\n\\t\\t\\t\\t\\tS[p][j] = '.';\\n\\t\\t\\t\\t\\tp++;\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tint v = S[p + 1][j] - 'A';\\n\\t\\t\\t\\tG[u].push_back(v);\\n\\t\\t\\t\\tG[v].push_back(u);\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\tqueue q;\\n\\tvector d(26, INF);\\n\\tq.push(s);\\n\\td[s] = 0;\\n\\twhile (!q.empty()) {\\n\\t\\tauto v = q.front(); q.pop();\\n\\t\\tfor (auto to : G[v]) if (d[to] == INF) {\\n\\t\\t\\tq.push(to);\\n\\t\\t\\td[to] = d[v] + 1;\\n\\t\\t}\\n\\t}\\n\\tcout << d[t] << endl;\\n\\treturn 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"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\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 1e5 + 5;\\nint n, k;\\nint64_t to_i64(string s) {\\n int64_t ret = 0;\\n for (char ch : s) ret = ret * 10 + (ch - '0');\\n return ret;\\n}\\nint64_t get(string l, string r) {\\n set s;\\n string ret = l;\\n for (char ch : l) s.insert(ch);\\n if (s.size() > k) return INT_MAX;\\n if (r.empty()) return to_i64(ret);\\n if (r[0] == '9') return INT_MAX;\\n auto it = s.upper_bound(r[0]);\\n if (it == s.end() && s.size() == k) return INT_MAX;\\n if (s.size() < k) s.insert(r[0] + 1);\\n ret += *s.upper_bound(r[0]);\\n set t = s;\\n t.insert('0');\\n if (t.size() <= k) s = t;\\n while (ret.size() < l.size() + r.size()) ret += *s.begin();\\n ;\\n return to_i64(ret);\\n}\\nvoid solve(int Case) {\\n scanf(\\\"%d %d\\\", &n, &k);\\n string s = to_string(n);\\n ;\\n int64_t ans = INT_MAX;\\n ans = min(ans, get(\\\"\\\", s));\\n ans = min(ans, get(s, \\\"\\\"));\\n for (int i = 1; i <= s.size() - 1; ++i)\\n ans = min(ans, get(s.substr(0, i), s.substr(i, s.size() - i)));\\n if (k >= 2) {\\n int64_t tmp = 1;\\n while (tmp < n) tmp *= 10;\\n ans = min(ans, tmp);\\n }\\n printf(\\\"%lld\\\\n\\\", ans);\\n}\\nint main() {\\n int T = 1;\\n scanf(\\\"%d\\\", &T);\\n for (int t = 1; t <= T; ++t) solve(t);\\n return 0;\\n}\",\"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...\\nUsing python3 can you solve the prior task?\",\"targets\":\"t = int(input())\\nwhile t:\\n n = int(input())\\n s = \\\"\\\"\\n a = list(map(str, input().split()))\\n for i in range(len(a) - 1):\\n if a[i][1] != a[i + 1][0]:\\n s += a[i]\\n else:\\n s += a[i][0]\\n s += a[len(a)-1]\\n if len(s) < n:\\n s += \\\"a\\\"\\n print(s)\\n t -= 1\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in PYTHON3?\\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 math,sys;input=sys.stdin.readline;S=lambda:input().rstrip();I=lambda:int(S());M=lambda:map(int,S().split());L=lambda:list(M());mod1=1000000007;mod2=998244353\\nfrom collections import Counter\\nfor _ in range(I()):\\n\\tn=I();a=L();ans,buffer=[],[];cnt=Counter(a);cost=flag=0\\n\\tfor i in range(n+1):\\n\\t\\tans.append(cost+cnt[i])\\n\\t\\tif i==n:break\\n\\t\\tif cnt[i]==0:\\n\\t\\t\\tif not buffer:flag=1;break\\n\\t\\t\\tcost+=i-buffer.pop()\\n\\t\\telse:\\n\\t\\t\\tbuffer+=[i]*(cnt[i]-1)\\n\\tif flag==1:ans=ans+[-1]*(n+1-len(ans))\\n\\tprint(*ans)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"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.\\\":\",\"targets\":\"#include \\nusing namespace std;\\nconst long long MAXN = 200005;\\nconst long long K = 24;\\nlong long st[MAXN][K + 1];\\nlong long LOG[MAXN];\\nlong long gcd(long long a, long long b) {\\n if (b == 0) return a;\\n return gcd(b, a % b);\\n}\\nlong long query(long long L, long long R) {\\n long long j = LOG[R - L + 1];\\n return gcd(st[L][j], st[R - (1 << j) + 1][j]);\\n}\\nvoid solve() {\\n long long n;\\n cin >> n;\\n vector v(n);\\n for (auto &i : v) cin >> i;\\n if (n == 1) {\\n cout << 1 << \\\"\\\\n\\\";\\n return;\\n }\\n long long m = n - 1;\\n vector diff(m);\\n for (long long i = 0; i < m; i++) diff[i] = abs(v[i + 1] - v[i]);\\n for (long long i = 0; i < m; i++) st[i][0] = diff[i];\\n for (long long j = 1; j <= K; j++) {\\n for (long long i = 0; i + (1 << j) <= m; i++) {\\n st[i][j] = gcd(st[i][j - 1], st[i + (1 << (j - 1))][j - 1]);\\n }\\n }\\n long long j = 0;\\n long long ans = 1;\\n for (long long i = 0; i < m; i++) {\\n while (j <= i && query(j, i) == 1) j++;\\n ans = max(ans, i - j + 2);\\n }\\n cout << ans << \\\"\\\\n\\\";\\n}\\nint32_t main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n LOG[1] = 0;\\n for (long long i = 2; i < MAXN; i++) LOG[i] = LOG[i \\/ 2] + 1;\\n long long tc;\\n tc = 1;\\n cin >> tc;\\n while (tc--) {\\n solve();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Mr. Chanek has an integer represented by a string s. Zero or more digits have been erased and are denoted by the character _. There are also zero or more digits marked by the character X, meaning they're the same digit.\\n\\nMr. Chanek wants to count the number of possible integer s, where s is divisible by 25. Of course, s must not contain any leading zero. He can replace the character _ with any digit. He can also replace the character X with any digit, but it must be the same for every character X.\\n\\nAs a note, a leading zero is any 0 digit that comes before the first nonzero digit in a number string in positional notation. For example, 0025 has two leading zeroes. An exception is the integer zero, (0 has no leading zero, but 0000 has three leading zeroes).\\n\\nInput\\n\\nOne line containing the string s (1 ≤ |s| ≤ 8). The string s consists of the characters 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, _, and X.\\n\\nOutput\\n\\nOutput an integer denoting the number of possible integer s.\\n\\nExamples\\n\\nInput\\n\\n\\n25\\n\\n\\nOutput\\n\\n\\n1\\n\\n\\nInput\\n\\n\\n_00\\n\\n\\nOutput\\n\\n\\n9\\n\\n\\nInput\\n\\n\\n_XX\\n\\n\\nOutput\\n\\n\\n9\\n\\n\\nInput\\n\\n\\n0\\n\\n\\nOutput\\n\\n\\n1\\n\\n\\nInput\\n\\n\\n0_25\\n\\n\\nOutput\\n\\n\\n0\\n\\nNote\\n\\nIn the first example, the only possible s is 25.\\n\\nIn the second and third example, s ∈ \\\\{100, 200,300,400,500,600,700,800,900\\\\}.\\n\\nIn the fifth example, all possible s will have at least one leading zero.\\\":\",\"targets\":\"#include \\n#pragma GCC optimize(\\\"Ofast\\\")\\nusing namespace std;\\nmt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());\\nlong long int myRand(long long int B) { return (unsigned long long)rng() % B; }\\nint main() {\\n cin.tie(nullptr);\\n ios::sync_with_stdio(false);\\n string s;\\n cin >> s;\\n int n = s.size();\\n vector v(n, '0');\\n if (n > 1) v[0] = '1';\\n int res = 0;\\n while (1) {\\n bool f = false;\\n if (n == 1) {\\n if (v[0] == '0') f = true;\\n } else {\\n if (v[n - 2] == '0' and v[n - 1] == '0' and n > 2)\\n f = true;\\n else if (v[n - 2] == '2' and v[n - 1] == '5')\\n f = true;\\n else if (v[n - 2] == '5' and v[n - 1] == '0')\\n f = true;\\n else if (v[n - 2] == '7' and v[n - 1] == '5')\\n f = true;\\n }\\n if (f) {\\n char x = '.';\\n bool ok = true;\\n for (int i = 0; i < n; i++) {\\n if (s[i] == '_')\\n continue;\\n else if (s[i] == 'X') {\\n if (x == '.')\\n x = v[i];\\n else {\\n if (x != v[i]) ok = false;\\n }\\n } else if (s[i] != v[i])\\n ok = false;\\n }\\n if (ok) res++;\\n }\\n bool ed = true;\\n for (int i = n - 1; i >= 0; i--) {\\n if (v[i] == '9') {\\n v[i] = '0';\\n } else {\\n v[i]++;\\n ed = false;\\n break;\\n }\\n }\\n if (ed) break;\\n }\\n cout << res << endl;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"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.\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\n\\npublic class Main {\\n public static void main(String[] args) throws IOException {\\n int t = nextInt();\\n for (int i = 0; i < t; i++) {\\n long a = nextLong();\\n long b = nextLong();\\n long c = nextLong();\\n long m = nextLong();\\n long[]ans = new long[3];\\n ans[0] = a;\\n ans[1] = b;\\n ans[2] = c;\\n Arrays.sort(ans);\\n long y = a + b + c;\\n if (m + 3 <= a + b + c && m + 1 >= Math.max(0, ans[2] - ans[1] - ans[0])) {\\n out.println(\\\"YES\\\");\\n }else {\\n out.println(\\\"NO\\\");\\n }\\n }\\n out.close();\\n }\\n\\n static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\\n static PrintWriter out = new PrintWriter(System.out);\\n static StringTokenizer in = new StringTokenizer(\\\"\\\");\\n\\n\\n public static String nextToken() throws IOException {\\n while (!in.hasMoreTokens()) {\\n in = new StringTokenizer(br.readLine());\\n }\\n return in.nextToken();\\n }\\n\\n public static int nextInt() throws IOException {\\n return Integer.parseInt(nextToken());\\n }\\n\\n public static long nextLong() throws IOException {\\n return Long.parseLong(nextToken());\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nA tree is an undirected connected graph without cycles. The distance between two vertices is the number of edges in a simple path between them.\\n\\nLimak is a little polar bear. He lives in a tree that consists of n vertices, numbered 1 through n.\\n\\nLimak recently learned how to jump. He can jump from a vertex to any vertex within distance at most k.\\n\\nFor a pair of vertices (s, t) we define f(s, t) as the minimum number of jumps Limak needs to get from s to t. Your task is to find the sum of f(s, t) over all pairs of vertices (s, t) such that s < t.\\n\\nInput\\n\\nThe first line of the input contains two integers n and k (2 ≤ n ≤ 200 000, 1 ≤ k ≤ 5) — the number of vertices in the tree and the maximum allowed jump distance respectively.\\n\\nThe next n - 1 lines describe edges in the tree. The i-th of those lines contains two integers ai and bi (1 ≤ ai, bi ≤ n) — the indices on vertices connected with i-th edge.\\n\\nIt's guaranteed that the given edges form a tree.\\n\\nOutput\\n\\nPrint one integer, denoting the sum of f(s, t) over all pairs of vertices (s, t) such that s < t.\\n\\nExamples\\n\\nInput\\n\\n6 2\\n1 2\\n1 3\\n2 4\\n2 5\\n4 6\\n\\n\\nOutput\\n\\n20\\n\\n\\nInput\\n\\n13 3\\n1 2\\n3 2\\n4 2\\n5 2\\n3 6\\n10 6\\n6 7\\n6 13\\n5 8\\n5 9\\n9 11\\n11 12\\n\\n\\nOutput\\n\\n114\\n\\n\\nInput\\n\\n3 5\\n2 1\\n3 1\\n\\n\\nOutput\\n\\n3\\n\\nNote\\n\\nIn the first sample, the given tree has 6 vertices and it's displayed on the drawing below. Limak can jump to any vertex within distance at most 2. For example, from the vertex 5 he can jump to any of vertices: 1, 2 and 4 (well, he can also jump to the vertex 5 itself).\\n\\n\\n\\nThere are pairs of vertices (s, t) such that s < t. For 5 of those pairs Limak would need two jumps: (1, 6), (3, 4), (3, 5), (3, 6), (5, 6). For other 10 pairs one jump is enough. So, the answer is 5·2 + 10·1 = 20.\\n\\nIn the third sample, Limak can jump between every two vertices directly. There are 3 pairs of vertices (s < t), so the answer is 3·1 = 3.\",\"targets\":\"#include \\nusing namespace std;\\nstruct mydfs {\\n int k;\\n vector> *padj;\\n array, 5> precomputedAdder;\\n vector subtreeSize;\\n vector> subtreeRemainders;\\n uint64_t ktimesans;\\n int maxnode;\\n void init(vector> &adj, int maxnodein, int kin) {\\n maxnode = maxnodein;\\n k = kin;\\n ktimesans = 0;\\n padj = &adj;\\n subtreeSize.clear();\\n subtreeSize.resize(maxnode + 1, 0);\\n subtreeRemainders.clear();\\n subtreeRemainders.resize(maxnode + 1);\\n for (int i = 0; i <= maxnode; i++) {\\n subtreeRemainders[i].resize(5, 0);\\n }\\n for (int i = 0; i < k; i++) {\\n for (int j = 0; j < k; j++) {\\n precomputedAdder[i][j] =\\n ((i + j + 1) % k == 0) ? 0 : k - ((i + j + 1) % k);\\n }\\n }\\n }\\n uint64_t dfs(int n, int p) {\\n for (auto nn : (*padj)[n]) {\\n if (nn == p) continue;\\n dfs(nn, n);\\n for (int i = 0; i < k; i++) {\\n for (int j = 0; j < k; j++) {\\n ktimesans += (uint64_t)precomputedAdder[i][j] *\\n (uint64_t)subtreeRemainders[n][i] *\\n (uint64_t)subtreeRemainders[nn][j];\\n }\\n }\\n for (int j = 0; j < k; j++) {\\n ktimesans += (uint64_t)precomputedAdder[0][j] *\\n (uint64_t)subtreeRemainders[nn][j];\\n }\\n for (int j = 0; j < k; j++) {\\n if (j + 1 == k) {\\n subtreeRemainders[n][0] += subtreeRemainders[nn][j];\\n } else {\\n subtreeRemainders[n][j + 1] += subtreeRemainders[nn][j];\\n }\\n }\\n subtreeSize[n] += subtreeSize[nn];\\n }\\n subtreeSize[n] += 1;\\n subtreeRemainders[n][0] += 1;\\n ktimesans +=\\n (uint64_t)subtreeSize[n] * (uint64_t)(maxnode - subtreeSize[n]);\\n return ktimesans;\\n }\\n};\\nvoid solve() {\\n int n, k;\\n cin >> n >> k;\\n vector> adj(n + 1);\\n int x, y;\\n for (int i = 0; i < n - 1; i++) {\\n cin >> x >> y;\\n adj[x].push_back(y);\\n adj[y].push_back(x);\\n }\\n mydfs d;\\n d.init(adj, n, k);\\n uint64_t ans = d.dfs(1,...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"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.\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nbool prime(long long int n) {\\n for (long long int i = 2; i < n; i++) {\\n if (n % i == 0) return false;\\n }\\n return true;\\n}\\nsigned main() {\\n long long int t;\\n cin >> t;\\n while (t--) {\\n long long int n;\\n cin >> n;\\n long long int a[n];\\n long long int sum = 0;\\n for (long long int i = 0; i < (n); ++i) {\\n cin >> a[i];\\n sum += a[i];\\n }\\n long long int ans = -1;\\n if (prime(sum)) {\\n cout << n - 1 << \\\"\\\\n\\\";\\n long long int cnt = 0;\\n for (long long int i = 0; i < (n); ++i) {\\n if (a[i] % 2 == 0)\\n cout << i + 1 << \\\" \\\";\\n else if (cnt >= 1)\\n cout << i + 1 << \\\" \\\";\\n else\\n cnt++;\\n }\\n cout << \\\"\\\\n\\\";\\n } else {\\n cout << n << \\\"\\\\n\\\";\\n for (long long int i = 0; i < (n); ++i) cout << i + 1 << \\\" \\\";\\n cout << \\\"\\\\n\\\";\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"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\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nint test(string str) {\\n int len = str.length();\\n int a = 0, b = 0, c = 0;\\n for (int i = 0; i < len; i++) {\\n if (str[i] == 'A')\\n a += 1;\\n else if (str[i] == 'B')\\n b += 1;\\n else if (str[i] == 'C')\\n c += 1;\\n }\\n if (a <= b && b - a == c) return 1;\\n return 0;\\n}\\nint main() {\\n int t;\\n cin >> t;\\n string s;\\n while (t--) {\\n cin >> s;\\n if (test(s))\\n cout << \\\"YES\\\" << endl;\\n else\\n cout << \\\"NO\\\" << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"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\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"n = int(input())\\nt = 1\\nfor i in range(1, n):\\n t = (t + i - 1) % n + 1\\n print(str(t), end=' ')\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"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;\\nusing ull = unsigned long long;\\nusing ll = long long;\\nconst int N = 2001, MOD = 1e9 + 7;\\nint t, n, k, a[N], dp[N][N];\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(0), cout.tie(0);\\n cin >> t;\\n while (t--) {\\n cin >> n >> k;\\n for (int i = 0; i < n; ++i) {\\n cin >> a[i];\\n }\\n for (int i = 0; i <= n; ++i) {\\n fill(dp[i], dp[i] + n + 1, -1);\\n }\\n dp[0][0] = 0;\\n for (int i = 0; i < n; ++i) {\\n for (int j = 0; j <= i; ++j) {\\n if (dp[i][j] == -1) continue;\\n dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);\\n dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + (j + 1 == a[i]));\\n }\\n }\\n int ans = -1;\\n for (int i = n; i > 0; --i) {\\n if (dp[n][i] >= k) {\\n ans = n - i;\\n break;\\n }\\n }\\n cout << ans << '\\\\n';\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"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\\nimpor\",\"targets\":\"t java.util.Scanner;\\n\\npublic class Main {\\n\\n\\tpublic static void main(String[] args) {\\n\\t\\ttry (Scanner scanner = new Scanner(System.in)) {\\n\\t\\t\\tint a = scanner.nextInt(), b = scanner.nextInt(), t = scanner.nextInt();\\n\\t\\t\\tSystem.out.println(t \\/ a * b);\\n\\t\\t}\\n\\t}\\n}\",\"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...\\nUsing java can you solve the prior task?\",\"targets\":\"import java.util.*;\\n import java.lang.*;\\n import java.io.*;\\n\\npublic class B_Odd_Grasshopper\\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 }\\n static void sieveOfEratosthenes(int n)\\n {\\n prime = new boolean[n + 1];\\n for (int i = 0; i <= n; i++)\\n prime[i] = true;\\n prime[0]=false;\\n if(1<=n)\\n prime[1]=false;\\n for (int p = 2; p * p <= n; p++)\\n {\\n \\n if (prime[p] == true)\\n {\\n \\n for (int i = p * p; i <= n; i += p)\\n prime[i] = false;\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A set of points on a plane is called good, if for any two points at least one of the three conditions is true:\\n\\n * those two points lie on same horizontal line; \\n * those two points lie on same vertical line; \\n * the rectangle, with corners in these two points, contains inside or on its borders at least one point of the set, other than these two. We mean here a rectangle with sides parallel to coordinates' axes, the so-called bounding box of the two points.\\n\\n\\n\\nYou are given a set consisting of n points on a plane. Find any good superset of the given set whose size would not exceed 2·105 points.\\n\\nInput\\n\\nThe first line contains an integer n (1 ≤ n ≤ 104) — the number of points in the initial set. Next n lines describe the set's points. Each line contains two integers xi and yi ( - 109 ≤ xi, yi ≤ 109) — a corresponding point's coordinates. It is guaranteed that all the points are different.\\n\\nOutput\\n\\nPrint on the first line the number of points m (n ≤ m ≤ 2·105) in a good superset, print on next m lines the points. The absolute value of the points' coordinates should not exceed 109. Note that you should not minimize m, it is enough to find any good superset of the given set, whose size does not exceed 2·105.\\n\\nAll points in the superset should have integer coordinates.\\n\\nExamples\\n\\nInput\\n\\n2\\n1 1\\n2 2\\n\\n\\nOutput\\n\\n3\\n1 1\\n2 2\\n1 2\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nlong long n;\\nvector > ans;\\nvector > v;\\nvoid solve(long long x, long long y) {\\n long long mid = (x + y) >> 1;\\n if (x == y) {\\n ans.push_back(v[x]);\\n return;\\n }\\n for (long long i = x; i <= y; i++) {\\n ans.push_back(make_pair(v[mid].first, v[i].second));\\n }\\n solve(x, mid);\\n solve(mid + 1, y);\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n cin >> n;\\n for (long long i = 1; i <= n; i++) {\\n long long x, y;\\n cin >> x >> y;\\n v.push_back(make_pair(x, y));\\n }\\n sort(v.begin(), v.end());\\n solve(0, n - 1);\\n sort(ans.begin(), ans.end());\\n long long sz = unique(ans.begin(), ans.end()) - ans.begin();\\n ans.resize(sz);\\n cout << ans.size() << endl;\\n for (auto &i : ans) {\\n cout << i.first << \\\" \\\" << i.second << \\\"\\\\n\\\";\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA 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} 0) {\\n\\t\\t\\tint n=sc.nextInt();\\n\\t\\t\\t\\n\\t\\t\\tint arr[][] = new int[n][5];\\n\\t\\t\\t\\n\\t\\t\\tfor(int i=0;i set=new HashSet<>();\\n\\t\\t\\tfor(int i=0;i li = new ArrayList<>();\\n\\t\\t\\t\\tfor(int i:set) {\\n\\t\\t\\t\\t\\tli.add(i);\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tfor(int i=0;iarr[li.get(i+1)][j]) {\\n\\t\\t\\t\\t\\t\\t\\ts++;\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\telse {\\n\\t\\t\\t\\t\\t\\t\\tf++;\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\tif(s>f) {\\n\\t\\t\\t\\t\\t\\tset.remove(li.get(i));\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\telse {\\n\\t\\t\\t\\t\\t\\tset.remove(li.get(i+1));\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\n\\t\\t\\t}\\n\\t\\t\\tint temp=-1;\\n\\t\\t\\tfor(int i:set) {\\n\\t\\t\\t\\ttemp=i;\\n\\t\\t\\t}\\n\\t\\t\\tboolean check=true;\\n\\t\\t\\tfor(int i=0;iarr[temp][j]) {\\n\\t\\t\\t\\t\\t\\ts++;\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\telse {\\n\\t\\t\\t\\t\\t\\tf++;\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tif(f l = new ArrayList<>();\\n\\t\\tfor (int i : a)\\n\\t\\t\\tl.add(i);\\n\\t\\tCollections.sort(l);\\n\\t\\tfor (int i = 0; i < a.length; i++)\\n\\t\\t\\ta[i] = l.get(i);\\n\\t}\\n\\n\\tstatic long ncr(int n, int r, long p) {\\n\\t\\tif (r > n)\\n\\t\\t\\treturn 0l;\\n\\t\\tif (r > n - r)\\n\\t\\t\\tr = n - r;\\n\\n\\t\\tlong C[] = new long[r + 1];\\n\\n\\t\\tC[0] = 1;\\n\\n\\t\\tfor (int i = 1; i <= n; i++) {\\n\\n\\t\\t\\tfor (int j = Math.min(i, r); j > 0; j--)\\n\\t\\t\\t\\tC[j] = (C[j] + C[j - 1]) % p;\\n\\t\\t}\\n\\t\\treturn C[r] %...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"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 CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n long long t = 1;\\n cin >> t;\\n while (t--) {\\n long long n;\\n cin >> n;\\n string s;\\n string res = \\\"\\\";\\n vector v;\\n for (long long i = 0; i < n - 2; i++) {\\n cin >> s;\\n v.push_back(s);\\n }\\n for (long long i = 0; i < n - 3; i++) {\\n if (v[i][1] != v[i + 1][0]) {\\n string temp = \\\"\\\";\\n temp += v[i][1];\\n temp += v[i + 1][0];\\n v.insert(v.begin() + i + 1, temp);\\n break;\\n }\\n }\\n res += v[0];\\n for (long long i = 1; i < v.size(); i++) {\\n res += v[i][1];\\n }\\n if (res.size() != n) res += \\\"a\\\";\\n cout << res << \\\"\\\\n\\\";\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Companies always have a lot of equipment, furniture and other things. All of them should be tracked. To do this, there is an inventory number assigned with each item. It is much easier to create a database by using those numbers and keep the track of everything.\\n\\nDuring an audit, you were surprised to find out that the items are not numbered sequentially, and some items even share the same inventory number! There is an urgent need to fix it. You have chosen to make the numbers of the items sequential, starting with 1. Changing a number is quite a time-consuming process, and you would like to make maximum use of the current numbering.\\n\\nYou have been given information on current inventory numbers for n items in the company. Renumber items so that their inventory numbers form a permutation of numbers from 1 to n by changing the number of as few items as possible. Let us remind you that a set of n numbers forms a permutation if all the numbers are in the range from 1 to n, and no two numbers are equal.\\n\\nInput\\n\\nThe first line contains a single integer n — the number of items (1 ≤ n ≤ 105).\\n\\nThe second line contains n numbers a1, a2, ..., an (1 ≤ ai ≤ 105) — the initial inventory numbers of the items.\\n\\nOutput\\n\\nPrint n numbers — the final inventory numbers of the items in the order they occur in the input. If there are multiple possible answers, you may print any of them.\\n\\nExamples\\n\\nInput\\n\\n3\\n1 3 2\\n\\n\\nOutput\\n\\n1 3 2 \\n\\n\\nInput\\n\\n4\\n2 2 3 3\\n\\n\\nOutput\\n\\n2 1 3 4 \\n\\n\\nInput\\n\\n1\\n2\\n\\n\\nOutput\\n\\n1 \\n\\nNote\\n\\nIn the first test the numeration is already a permutation, so there is no need to change anything.\\n\\nIn the second test there are two pairs of equal numbers, in each pair you need to replace one number.\\n\\nIn the third test you need to replace 2 by 1, as the numbering should start from one.\",\"targets\":\"import sys\\nimport string\\n\\nfrom collections import Counter, defaultdict\\nfrom math import fsum, sqrt, gcd, ceil, factorial\\nfrom operator import add\\n\\ninf = float(\\\"inf\\\")\\n# input = sys.stdin.readline\\nflush = lambda: sys.stdout.flush\\ncomb = lambda x, y: (factorial(x) \\/\\/ factorial(y)) \\/\\/ factorial(x - y)\\n\\n\\n# inputs\\n# ip = lambda : input().rstrip()\\nip = lambda: input()\\nii = lambda: int(input())\\nr = lambda: map(int, input().split())\\nrr = lambda: list(r())\\n\\n\\nn = ii()\\narr = rr()\\nx = Counter(arr)\\nneed = set(list(range(1, n + 1)))\\nfor i in x.keys():\\n try:\\n need.remove(i)\\n except:\\n pass\\n# print(need)\\nfor i, j in enumerate(arr):\\n if x[j] > 1 or j > n:\\n x[j] -= 1\\n c = next(iter(need))\\n arr[i] = c\\n need.remove(c)\\n\\nprint(*arr)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"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\",\"targets\":\"#include \\nusing namespace std;\\nlong long power(long long b, long long e, long long m) {\\n if (e == 0) return 1;\\n if (e & 1) return b * power(b * b % m, e \\/ 2, m) % m;\\n return power(b * b % m, e \\/ 2, m);\\n}\\nlong long power(long long b, long long e) {\\n if (e == 0) return 1;\\n if (e & 1) return b * power(b * b, e \\/ 2);\\n return power(b * b, e \\/ 2);\\n}\\nint a[1001] = {0};\\nvoid hack(int pp) {\\n int n;\\n cin >> n;\\n if (a[0] == 0) {\\n int t = 0;\\n int k = 1;\\n while (t <= 1000) {\\n if (k % 3 != 0 & (k % 10) != 3) {\\n a[t] = k;\\n t++;\\n }\\n k++;\\n }\\n }\\n cout << a[n - 1] << \\\"\\\\n\\\";\\n}\\nint main() {\\n int t = 1;\\n cin >> t;\\n int l = 0;\\n while (t--) {\\n hack(l);\\n l++;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"Luntik came out for a morning stroll and found an array a of length n. He calculated the sum s of the elements of the array (s= ∑_{i=1}^{n} a_i). Luntik calls a subsequence of the array a nearly full if the sum of the numbers in that subsequence is equal to s-1.\\n\\nLuntik really wants to know the number of nearly full subsequences of the array a. But he needs to come home so he asks you to solve that problem!\\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\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases. The next 2 ⋅ t lines contain descriptions 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 ≤ 60) — the length of the array.\\n\\nThe second line contains n integers a_1, a_2, …, a_n (0 ≤ a_i ≤ 10^9) — the elements of the array a.\\n\\nOutput\\n\\nFor each test case print the number of nearly full subsequences of the array.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n5\\n1 2 3 4 5\\n2\\n1000 1000\\n2\\n1 0\\n5\\n3 0 2 1 1\\n5\\n2 1 0 3 0\\n\\n\\nOutput\\n\\n\\n1\\n0\\n2\\n4\\n4\\n\\nNote\\n\\nIn the first test case, s=1+2+3+4+5=15, only (2,3,4,5) is a nearly full subsequence among all subsequences, the sum in it is equal to 2+3+4+5=14=15-1.\\n\\nIn the second test case, there are no nearly full subsequences.\\n\\nIn the third test case, s=1+0=1, the nearly full subsequences are (0) and () (the sum of an empty subsequence is 0).\\\":\",\"targets\":\"\\/*\\n @@ @@ @@@@@@@@@ @@ @ @ @ @@@@@@@@@ @ @ @@@@@@@@@ @\\n @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @@\\n @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @@ @\\n @ @ @ @ @ @ @ @ @ @ @@@@@@@@@ @@@@@@@@@ @ @ @ \\n @ @ @ @ @ @ @ @ @ @ @ @ @ @\\n @ @ @ @ @ @ @ @ @ @ @ @ @ @\\n @ @ @@@@@@@@@ @ @@ @@@@@@@@@ @@@@@@@@@ @ @@@@@@@@@ @@@@@@@\\n*\\/\\n \\nimport java.util.*;\\nimport java.io.*;\\nimport java.math.*;\\npublic class codeforces\\n{\\n \\/\\/ File Input\\/Output\\n \\n \\/*public static void main(String args[])throws IOException\\n {\\n File file = new File(\\\"input.txt\\\");\\n Scanner sc = new Scanner(file);\\n FileWriter fw = new FileWriter(\\\"output.txt\\\");\\n fw.write(\\\"___\\\");\\n fw.close();\\n }*\\/\\n \\n \\n \\/\\/ Standard Input\\/Output\\n \\n public static void main(String args[])\\n {\\n Scanner sc=new Scanner(System.in);\\n int t=sc.nextInt();\\n while(t-- > 0)\\n {\\n int n=sc.nextInt();\\n int arr[]=new int[n];\\n int i,c0=0,c1=0;\\n for(i=0;i 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...\\nimpor\",\"targets\":\"t 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\\n# python codesforces210710.py < input.txt\\n\\nt = int(raw_input())\\nfor zz in range(t):\\n #n = int(raw_input())\\n str1 = raw_input()\\n a, b = str1.split()\\n #str2 = raw_input()\\n #ls = str2.split(' ')\\n a = int(a)\\n b = int(b)\\n dif = abs(a - b)\\n mmia = dif\\/2\\n ls = []\\n if (a+b) % 2 == 1:\\n ung = 1\\n else:\\n ung = 2\\n for i in range(mmia, (a + b - mmia + 1), ung):\\n ls.append(i)\\n print(len(ls))\\n ls = map(str, ls)\\n str3 = ' '.join(ls)\\n print(str3)\",\"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\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.io.*;\\nimport java.util.*;\\nimport static java.lang.Math.*;\\n\\n\\npublic class MainC {\\n static class InputReader {\\n public BufferedReader reader;\\n public StringTokenizer tokenizer;\\n public InputReader(InputStream stream) {\\n reader = new BufferedReader(new InputStreamReader(stream), 32768);\\n tokenizer = null;\\n }\\n public String next() {\\n while (tokenizer == null || !tokenizer.hasMoreTokens()) {\\n try {\\n tokenizer = new StringTokenizer(reader.readLine());\\n } catch (IOException e) {\\n throw new RuntimeException(e);\\n }\\n }\\n return tokenizer.nextToken();\\n }\\n public int nextInt() {\\n return Integer.parseInt(next());\\n }\\n public long nextLong() {\\n return Long.parseLong(next());\\n }\\n public boolean hasNext() {\\n try {\\n String string = reader.readLine();\\n if (string == null) {\\n return false;\\n }\\n tokenizer = new StringTokenizer(string);\\n return tokenizer.hasMoreTokens();\\n } catch (IOException e) {\\n return false;\\n }\\n }\\n }\\n static InputReader in = new InputReader(System.in);\\n static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));\\n static void ini() {\\n for (int i = 1; i < 32000; i++) {\\n pow[i] = i * i;\\n }\\n }\\n static int[] pow = new int[32000];\\n static String yes = \\\"YES\\\";\\n static String no = \\\"NO\\\";\\n static int ipInf = Integer.MAX_VALUE-5;\\n static int inInf = Integer.MIN_VALUE+5;\\n static long lpInf = Long.MAX_VALUE - 5;\\n static long lnInf = Long.MIN_VALUE + 5;\\n\\n public static void main(String[] args) {\\n int t = in.nextInt();\\n ini();\\n while (t -- > 0) {\\n solve();\\n }\\n out.close();\\n }\\n static void solve() {\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Bob recently read about bitwise operations used in computers: AND, OR and XOR. He have studied their properties and invented a new game.\\n\\nInitially, Bob chooses integer m, bit depth of the game, which means that all numbers in the game will consist of m bits. Then he asks Peter to choose some m-bit number. After that, Bob computes the values of n variables. Each variable is assigned either a constant m-bit number or result of bitwise operation. Operands of the operation may be either variables defined before, or the number, chosen by Peter. After that, Peter's score equals to the sum of all variable values.\\n\\nBob wants to know, what number Peter needs to choose to get the minimum possible score, and what number he needs to choose to get the maximum possible score. In both cases, if there are several ways to get the same score, find the minimum number, which he can choose.\\n\\nInput\\n\\nThe first line contains two integers n and m, the number of variables and bit depth, respectively (1 ≤ n ≤ 5000; 1 ≤ m ≤ 1000). \\n\\nThe following n lines contain descriptions of the variables. Each line describes exactly one variable. Description has the following format: name of a new variable, space, sign \\\":=\\\", space, followed by one of:\\n\\n 1. Binary number of exactly m bits. \\n 2. The first operand, space, bitwise operation (\\\"AND\\\", \\\"OR\\\" or \\\"XOR\\\"), space, the second operand. Each operand is either the name of variable defined before or symbol '?', indicating the number chosen by Peter. \\n\\n\\n\\nVariable names are strings consisting of lowercase Latin letters with length at most 10. All variable names are different.\\n\\nOutput\\n\\nIn the first line output the minimum number that should be chosen by Peter, to make the sum of all variable values minimum possible, in the second line output the minimum number that should be chosen by Peter, to make the sum of all variable values maximum possible. Both numbers should be printed as m-bit binary numbers.\\n\\nExamples\\n\\nInput\\n\\n3 3\\na := 101\\nb := 011\\nc := ? XOR b\\n\\n\\nOutput\\n\\n011\\n100\\n\\n\\nInput\\n\\n5 1\\na := 1\\nbb :=...\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nconst int NMax = 5e3 + 5;\\nconst int MMax = 1e3 + 5;\\nint N, M;\\nchar input[NMax][MMax + 101];\\nshort bit[NMax][MMax][2];\\nchar solMin[MMax], solMax[MMax];\\nmap ID;\\nstruct elem {\\n bool known;\\n int op1, op2;\\n char tor;\\n} v[NMax];\\nint compute(int, int, int);\\nint main() {\\n cin >> N >> M;\\n cin.getline(input[0], MMax + 100);\\n for (int i = 1; i <= N; ++i) {\\n cin.getline(input[i] + 1, MMax + 100);\\n string name = \\\"\\\";\\n int j = 1;\\n while ('a' <= input[i][j] && input[i][j] <= 'z') {\\n name += input[i][j++];\\n }\\n ID[name] = i;\\n }\\n for (int i = 1; i <= N; ++i) {\\n int j = 1;\\n while (input[i][j] != '=') {\\n ++j;\\n }\\n j += 2;\\n if (input[i][j] == '0' || input[i][j] == '1') {\\n v[i].known = true;\\n for (int k = 1; k <= M; ++k) {\\n bit[i][k][0] = bit[i][k][1] = input[i][j] - '0' + 1;\\n ++j;\\n }\\n } else {\\n string str;\\n if (input[i][j] == '?') {\\n v[i].op1 = -1;\\n ++j;\\n } else {\\n str = \\\"\\\";\\n while ('a' <= input[i][j] && input[i][j] <= 'z') {\\n str += input[i][j];\\n ++j;\\n }\\n v[i].op1 = ID[str];\\n }\\n ++j;\\n if (input[i][j] == 'A') {\\n v[i].tor = '&';\\n j += 3;\\n } else if (input[i][j] == 'O') {\\n v[i].tor = '|';\\n j += 2;\\n } else {\\n v[i].tor = '^';\\n j += 3;\\n }\\n ++j;\\n if (input[i][j] == '?') {\\n v[i].op2 = -1;\\n } else {\\n str = \\\"\\\";\\n while ('a' <= input[i][j] && input[i][j] <= 'z') {\\n str += input[i][j];\\n ++j;\\n }\\n v[i].op2 = ID[str];\\n }\\n }\\n }\\n for (int b = 1; b <= M; ++b) {\\n int nr1By1 = 0, nr1By0 = 0;\\n for (int i = 1; i <= N; ++i) {\\n nr1By1 += compute(i, b, 1);\\n nr1By0 += compute(i, b, 0);\\n }\\n if (nr1By1 > nr1By0) {\\n solMax[b] = '1';\\n } else {\\n solMax[b] = '0';\\n }\\n if (nr1By1 < nr1By0) {\\n solMin[b] = '1';\\n } else {\\n solMin[b] = '0';\\n }\\n }\\n ...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A camera you have accidentally left in a desert has taken an interesting photo. The photo has a resolution of n pixels width, and each column of this photo is all white or all black. Thus, we can represent the photo as a sequence of n zeros and ones, where 0 means that the corresponding column is all white, and 1 means that the corresponding column is black.\\n\\nYou think that this photo can contain a zebra. In this case the whole photo should consist of several (possibly, only one) alternating black and white stripes of equal width. For example, the photo [0, 0, 0, 1, 1, 1, 0, 0, 0] can be a photo of zebra, while the photo [0, 0, 0, 1, 1, 1, 1] can not, because the width of the black stripe is 3, while the width of the white stripe is 4. Can the given photo be a photo of zebra or not?\\n\\nInput\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 100 000) — the width of the photo.\\n\\nThe second line contains a sequence of integers a1, a2, ..., an (0 ≤ ai ≤ 1) — the description of the photo. If ai is zero, the i-th column is all black. If ai is one, then the i-th column is all white.\\n\\nOutput\\n\\nIf the photo can be a photo of zebra, print \\\"YES\\\" (without quotes). Otherwise, print \\\"NO\\\".\\n\\nYou can print each letter in any case (upper or lower).\\n\\nExamples\\n\\nInput\\n\\n9\\n0 0 0 1 1 1 0 0 0\\n\\n\\nOutput\\n\\nYES\\n\\n\\nInput\\n\\n7\\n0 0 0 1 1 1 1\\n\\n\\nOutput\\n\\nNO\\n\\n\\nInput\\n\\n5\\n1 1 1 1 1\\n\\n\\nOutput\\n\\nYES\\n\\n\\nInput\\n\\n8\\n1 1 1 0 0 0 1 1\\n\\n\\nOutput\\n\\nNO\\n\\n\\nInput\\n\\n9\\n1 1 0 1 1 0 1 1 0\\n\\n\\nOutput\\n\\nNO\\n\\nNote\\n\\nThe first two examples are described in the statements.\\n\\nIn the third example all pixels are white, so the photo can be a photo of zebra.\\n\\nIn the fourth example the width of the first stripe is equal to three (white color), the width of the second stripe is equal to three (black), and the width of the third stripe is equal to two (white). Thus, not all stripes have equal length, so this photo is not a photo of zebra.\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nint n;\\nint a[111111], b[111111], ch[111111], be = 0, che = 0, bec = 0, chec = 0;\\nint main() {\\n int i;\\n scanf(\\\"%d\\\", &n);\\n for (i = 0; i < n; i++) {\\n scanf(\\\"%d\\\", &a[i]);\\n }\\n if (a[0] == 1)\\n be++;\\n else\\n che++;\\n for (i = 1; i < n; i++) {\\n if (a[i] == 1)\\n be++;\\n else\\n che++;\\n if (a[i] != a[i - 1]) {\\n if (a[i - 1] == 1)\\n b[be] = 1, be = 0;\\n else\\n ch[che] = 1, che = 0;\\n }\\n }\\n if (a[n - 1] == 1)\\n b[be] = 1;\\n else\\n ch[che] = 1;\\n if (n == 1)\\n printf(\\\"YES \\\\n\\\");\\n else {\\n int h = 0, h1 = 0;\\n for (i = 1; i <= 100000; i++) {\\n if ((b[i] == 0 && ch[i] == 1) || (b[i] == 1 && ch[i] == 0)) h1++;\\n if (b[i] == 1 && ch[i] == 1) {\\n h++;\\n }\\n }\\n if ((h == 1 && h1 == 0) || (h == 0 && h1 == 1))\\n printf(\\\"YES \\\\n\\\");\\n else\\n printf(\\\"NO \\\\n\\\");\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Duff is one if the heads of Mafia in her country, Andarz Gu. Andarz Gu has n cities (numbered from 1 to n) connected by m bidirectional roads (numbered by 1 to m).\\n\\nEach road has a destructing time, and a color. i-th road connects cities vi and ui and its color is ci and its destructing time is ti.\\n\\nMafia wants to destruct a matching in Andarz Gu. A matching is a subset of roads such that no two roads in this subset has common endpoint. They can destruct these roads in parallel, i. e. the total destruction time is a maximum over destruction times of all selected roads.\\n\\n\\n\\nThey want two conditions to be satisfied:\\n\\n 1. The remaining roads form a proper coloring. \\n 2. Destructing time of this matching is minimized. \\n\\n\\n\\nThe remaining roads after destructing this matching form a proper coloring if and only if no two roads of the same color have same endpoint, or, in the other words, edges of each color should form a matching.\\n\\nThere is no programmer in Mafia. That's why Duff asked for your help. Please help her and determine which matching to destruct in order to satisfied those conditions (or state that this is not possible).\\n\\nInput\\n\\nThe first line of input contains two integers n and m (2 ≤ n ≤ 5 × 104 and 1 ≤ m ≤ 5 × 104), number of cities and number of roads in the country.\\n\\nThe next m lines contain the the roads. i - th of them contains four integers vi, ui, ci and ti (1 ≤ vi, ui ≤ n, vi ≠ ui and 1 ≤ ci, ti ≤ 109 for each 1 ≤ i ≤ m).\\n\\nOutput\\n\\nIn the first line of input, print \\\"Yes\\\" (without quotes) if satisfying the first condition is possible and \\\"No\\\" (without quotes) otherwise.\\n\\nIf it is possible, then you have to print two integers t and k in the second line, the minimum destructing time and the number of roads in the matching ().\\n\\nIn the third line print k distinct integers separated by spaces, indices of the roads in the matching in any order. Roads are numbered starting from one in order of their appearance in the input.\\n\\nIf there's more than one solution, print any of...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint n, m;\\nint v[50101], u[50101];\\nint c[50101], t[50101];\\nvector> sgr[301010][2];\\nmap gr[50101];\\nint pred[50101];\\nint vis[301010][2];\\nint ind;\\nint ord[301010];\\nint chk[301010];\\nconst int INF = 1010101010;\\nint dfs(int x, int sty, int ti, int tmp = 1) {\\n if (vis[x][sty]) return 1;\\n vis[x][sty] = tmp;\\n if (sty) {\\n if (vis[(x + 3 * m) % (6 * m)][sty] == tmp) return 0;\\n if (x < 3 * m)\\n chk[x % (3 * m)] = 1;\\n else\\n chk[x % (3 * m)] = 2;\\n }\\n for (auto y : sgr[x][sty]) {\\n if (y.second > ti) {\\n if (!dfs(y.first, sty, ti, tmp)) {\\n return 0;\\n }\\n }\\n }\\n if (!sty) ord[ind++] = x;\\n return 1;\\n}\\nint check(int ti) {\\n for (int i = 0; i < 6 * m; i++) {\\n chk[i] = 0;\\n for (int j = 0; j < 2; j++) vis[i][j] = 0;\\n }\\n ind = 0;\\n for (int i = 6 * m - 1; i >= 0; i--) dfs(i, 0, ti);\\n for (int i = 6 * m - 1; i >= 0; i--) {\\n if (!dfs(ord[i], 1, ti, i + 1)) return 0;\\n }\\n return 1;\\n}\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cin >> n >> m;\\n int fail = 0;\\n for (int i = 0; i < m; i++) {\\n cin >> v[i] >> u[i] >> c[i] >> t[i];\\n if (gr[v[i]].count(c[i]))\\n gr[v[i]][c[i]]++;\\n else\\n gr[v[i]][c[i]] = 1;\\n if (gr[u[i]].count(c[i]))\\n gr[u[i]][c[i]]++;\\n else\\n gr[u[i]][c[i]] = 1;\\n if (max(gr[v[i]][c[i]], gr[u[i]][c[i]]) > 2) fail = 1;\\n }\\n if (fail) {\\n cout << \\\"No\\\\n\\\";\\n return 0;\\n }\\n for (int i = 1; i <= n; i++) gr[i].clear();\\n for (int i = 0; i < m; i++) {\\n if (gr[v[i]].count(c[i])) {\\n int j = gr[v[i]][c[i]];\\n sgr[i + 3 * m][0].push_back(make_pair(j, INF));\\n sgr[j + 3 * m][0].push_back(make_pair(i, INF));\\n sgr[i][1].push_back(make_pair(j + 3 * m, INF));\\n sgr[j][1].push_back(make_pair(i + 3 * m, INF));\\n } else\\n gr[v[i]][c[i]] = i;\\n if (gr[u[i]].count(c[i])) {\\n int j = gr[u[i]][c[i]];\\n sgr[i + 3 * m][0].push_back(make_pair(j, INF));\\n sgr[j + 3 * m][0].push_back(make_pair(i, INF));\\n ...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"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()(())\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"cnt=int(input())\\nfor _ in range(cnt):\\n s=int(input())\\n for i in range(s):\\n ss='('*(s-1)+')'*i+'('+')'*(s-i)\\n print(ss)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"Luntik came out for a morning stroll and found an array a of length n. He calculated the sum s of the elements of the array (s= ∑_{i=1}^{n} a_i). Luntik calls a subsequence of the array a nearly full if the sum of the numbers in that subsequence is equal to s-1.\\n\\nLuntik really wants to know the number of nearly full subsequences of the array a. But he needs to come home so he asks you to solve that problem!\\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\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases. The next 2 ⋅ t lines contain descriptions 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 ≤ 60) — the length of the array.\\n\\nThe second line contains n integers a_1, a_2, …, a_n (0 ≤ a_i ≤ 10^9) — the elements of the array a.\\n\\nOutput\\n\\nFor each test case print the number of nearly full subsequences of the array.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n5\\n1 2 3 4 5\\n2\\n1000 1000\\n2\\n1 0\\n5\\n3 0 2 1 1\\n5\\n2 1 0 3 0\\n\\n\\nOutput\\n\\n\\n1\\n0\\n2\\n4\\n4\\n\\nNote\\n\\nIn the first test case, s=1+2+3+4+5=15, only (2,3,4,5) is a nearly full subsequence among all subsequences, the sum in it is equal to 2+3+4+5=14=15-1.\\n\\nIn the second test case, there are no nearly full subsequences.\\n\\nIn the third test case, s=1+0=1, the nearly full subsequences are (0) and () (the sum of an empty subsequence is 0).\\\":\",\"targets\":\"import java.io.*;\\nimport java.util.StringTokenizer;\\n\\npublic class Main {\\n\\t\\n\\tstatic BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\\n\\tstatic PrintWriter pw = new PrintWriter(System.out);\\n\\t\\n\\tpublic static void main(String[] args) throws IOException {\\n\\t\\tStringTokenizer st;\\n\\t\\tshort t = Short.parseShort(br.readLine());\\n\\t\\tbyte n, ones, zeros;\\n\\t\\t\\n\\t\\tfor (short i=0; i\\nusing namespace std;\\nconst int N = 2e5 + 5;\\nint a[N], b[N], eat_a[N], eat_b[N];\\nint main() {\\n int T;\\n scanf(\\\"%d\\\", &T);\\n while (T--) {\\n int n, m;\\n scanf(\\\"%d %d\\\", &n, &m);\\n long long suma = 0, sumb = 0;\\n for (int i = 1; i <= n; ++i) {\\n scanf(\\\"%d %d\\\", &a[i], &b[i]);\\n int eat = min(a[i], m);\\n eat_a[i] = eat;\\n eat_b[i] = m - eat;\\n suma += a[i] - eat_a[i];\\n sumb += b[i] - eat_b[i];\\n }\\n for (int i = 1; i <= n && sumb - suma >= 2; ++i) {\\n long long tmp =\\n min((sumb - suma) \\/ 2, (long long)min(eat_a[i], b[i] - eat_b[i]));\\n eat_a[i] -= tmp;\\n eat_b[i] += tmp;\\n suma += tmp;\\n sumb -= tmp;\\n }\\n printf(\\\"%lld\\\\n\\\", abs(suma - sumb));\\n for (int i = 1; i <= n; ++i) printf(\\\"%d %d\\\\n\\\", eat_a[i], eat_b[i]);\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"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...\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"n = int(input())\\nl = list(map(int,input().split()))\\n\\nx = l.index(max(l))\\n\\nl=l[::-1]\\ny = l.index(min(l))\\ny=n-y-1\\nif(x>y):\\n print((x-1)+(n-y)-1)\\nelse:\\n print((x-1)+(n-y))\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"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...\\nUsing python3 can you solve the prior task?\",\"targets\":\"import sys\\ninput = sys.stdin.readline\\n \\n# Observation is :- both left and up cells are not filled\\n# -> (j)\\n# | (i)\\n# \\\\ \\/\\n# \\\\\\/\\n# ...X(i,j)\\n# ..X.(i+1,j-1)\\nn,m=map(int,input().split())\\ns = [input() for i in range(n)]\\n# calculating the prefix sum of X[i][j]=='X' and X[i+1][j-1]=='X'\\nf = [0,0]\\nacc=0\\n\\n\\nfor j in range(1,m):\\n for i in range(n-1):\\n \\n if s[i][j]=='X' and s[i+1][j-1]=='X':\\n acc+=1\\n break\\n f.append(acc)\\nk=int(input())\\nfor i in range(k):\\n a,b=map(int,input().split())\\n print(\\\"YES\\\" if f[b]-f[a]==0 else \\\"NO\\\")\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"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.\",\"targets\":\"t = int(input())\\nfor i in range(t):\\n n = int(input())\\n s = input()\\n if s.count('8') == 0:\\n print('NO')\\n elif s[0] == '8' and n == 11:\\n print('YES')\\n elif n - s.index('8') >= 11:\\n print('YES')\\n else:\\n print('NO')\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"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\":\"for _ in range(int(input())):\\n n=int(input())\\n a=list(map(int,input().split()))\\n z=[]\\n for i in a:\\n if i not in z:\\n z.append(i)\\n print(*z)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"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.\\nUsing python3 can you solve the prior task?\",\"targets\":\"for _ in range(int(input())):\\n a=list(input())\\n if(a[0]==a[-1]):a=a\\n elif(a[0]=='b'):a[0]='a'\\n else:a[-1]='a'\\n print(''.join(a))\",\"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...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\n#pragma GCC optimize(\\\"Ofast\\\")\\n#pragma GCC target(\\\"avx,avx2,fma\\\")\\n#pragma GCC optimization(\\\"unroll-loops\\\")\\nusing namespace std;\\nconst int maxn = 2e6 + 6;\\nconst int inf = 0x3f3f3f3f;\\nconst int mod = 1e9 + 7;\\nconst int N = 2e3 + 3;\\nlong long qpow(long long x, long long y) {\\n long long ans = 1;\\n x %= mod;\\n while (y) {\\n if (y & 1) ans = ans * x % mod;\\n x = x * x % mod;\\n y >>= 1;\\n }\\n return ans;\\n}\\nint n, k;\\nint a[maxn];\\nint ask(vector& c) {\\n printf(\\\"?\\\");\\n for (int i : c) printf(\\\" %d\\\", i);\\n puts(\\\"\\\");\\n fflush(stdout);\\n int k;\\n scanf(\\\"%d\\\", &k);\\n return k;\\n}\\nint main() {\\n scanf(\\\"%d\\\", &n);\\n for (int i = 2; i <= n; i++) {\\n vector c;\\n for (int j = 1; j < n; j++) c.push_back(1);\\n c.push_back(i);\\n k = ask(c);\\n if (k == 0) {\\n a[n] = n + 2 - i;\\n break;\\n }\\n }\\n if (a[n] == 0) a[n] = 1;\\n for (int i = 1; i <= n; i++)\\n if (i != a[n]) {\\n int x, y;\\n if (a[n] + n - i >= 1 && a[n] + n - i <= n) {\\n x = n;\\n y = a[n] + n - i;\\n } else {\\n x = 1;\\n y = a[n] + 1 - i;\\n }\\n vector c;\\n for (int j = 1; j < n; j++) c.push_back(y);\\n c.push_back(x);\\n int k = ask(c);\\n a[k] = i;\\n }\\n printf(\\\"!\\\");\\n for (int i = 1; i <= n; i++) printf(\\\" %d\\\", a[i]);\\n puts(\\\"\\\");\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"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\":\"i,n,w=map(int,input().split(\\\" \\\"))\\nsum=(w*(i+i*w))\\/2\\nif(sum-n<0):\\n print(0)\\nelse:\\n print(int(sum-n))\",\"language\":\"python\",\"split\":\"train\",\"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...\\nSolve the task in PYTHON3.\",\"targets\":\"t = int(input())\\n\\ndef aux(a):\\n\\n a = sorted(a,key= lambda x : x[0]-x[1], reverse= True)\\n if a[0][0]<=a[0][1]:\\n return 0\\n \\n res = 1\\n cur_sum = a[0][0]\\n rem_sum = a[0][1]\\n\\n #print(a)\\n for i in range(1,len(a)):\\n\\n if cur_sum+a[i][0] > rem_sum+a[i][1]:\\n cur_sum+=a[i][0]\\n rem_sum+=a[i][1]\\n res+=1\\n \\n return res\\n\\nfor _ in range(t):\\n\\n n = int(input())\\n\\n words = []\\n\\n\\n for i in range(n):\\n words.append(input())\\n \\n hash_words =[]\\n\\n for word in words:\\n h_word = [0,0,0,0,0]\\n\\n for j in range(len(word)):\\n h_word[ord(word[j])-ord('a')]+=1\\n \\n hash_words.append(h_word)\\n\\n res = 0\\n\\n \\n\\n\\n for i in range(5):\\n a = []\\n for j in range(n):\\n\\n a.append((hash_words[j][i],sum(hash_words[j])-hash_words[j][i]))\\n \\n cur_res = aux(a)\\n\\n #print(cur_res)\\n res = max(cur_res,res)\\n \\n print(res)\\n # for i in range(5):\\n\\n # cur_res = 0\\n # idx = -1\\n\\n # cur_sum = 0\\n # cur_rem_sum = 0\\n # for j in range(n):\\n\\n # if hash_words[j][i]> (sum(hash_words[j])-hash_words[j][i]):\\n # cur_res+=1\\n # cur_sum = hash_words[j][i]\\n # cur_rem_sum = sum(hash_words[j])-cur_sum\\n # idx = i\\n \\n # if cur_res!=0:\\n\\n # for j in range(n):\\n\\n # if j !=idx:\\n\\n # if cur_sum+hash_words[j]>cur_rem_sum+(sum(hash_words[j])-hash_words[j][i]):\\n # cur_sum+=hash_words[j]\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Create a program that outputs the surface area S of a square cone with a height of h, with a square with one side x as the base. However, assume that the line segment connecting the apex and the center of the base is orthogonal to the base. Also, x and h are positive integers less than or equal to 100.\\n\\nInput\\n\\nGiven multiple datasets. Each dataset is given in the following format:\\n\\n\\nx\\nh\\n\\n\\nWhen both x and h are 0, it indicates the end of input.\\n\\n\\n\\nOutput\\n\\nOutput S (real number) on one line for each data set. The output may contain an error of 0.00001 or less.\\n\\nExample\\n\\nInput\\n\\n6\\n4\\n7\\n9\\n0\\n0\\n\\n\\nOutput\\n\\n96.000000\\n184.192455\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include\\n#include\\nusing namespace std;\\nint main(){\\n\\tint x,h;\\n\\twhile(scanf(\\\"%d%d\\\",&x,&h),x||h){\\n\\t\\tprintf(\\\"%.5f\\\\n\\\",x*(x+sqrt(x*x\\/4.+h*h)*2));\\n\\t}\\n\\treturn 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"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, math\\n#sys.setrecursionlimit(10**6)\\nINF = float('inf')\\nmod = 10**9 + 7\\n#mod = 998244353\\ninput = lambda: sys.stdin.readline().rstrip()\\nli = lambda: list(map(int, input().split()))\\n\\nt = int(input())\\n\\ndef check(x, N, H):\\n for i in range(N-1):\\n H -= min(A[i+1] - A[i], x)\\n H -= x\\n return H <= 0\\n\\n\\nfor _ in range(t):\\n N, H = li()\\n A = li()\\n\\n ok = 10 ** 18 + 1\\n ng = -1\\n while ok - ng > 1:\\n mid = (ok + ng) \\/\\/ 2\\n if check(mid, N, H):\\n ok = mid\\n else:\\n ng = mid\\n print(ok)\",\"language\":\"python\",\"split\":\"test\",\"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;\\nint N = (int)2e5 + 5;\\nint pre[20][(int)2e5 + 5];\\nint main() {\\n for (int i = 0; i < 20; i++) {\\n int cnt = 0;\\n for (int j = 1; j < N; j++) {\\n pre[i][j] = pre[i][j - 1];\\n if (!((j >> i) & 1)) pre[i][j]++;\\n }\\n }\\n int t;\\n cin >> t;\\n while (t--) {\\n int l, r;\\n cin >> l >> r;\\n int res = r - l + 1;\\n for (int i = 0; i < 20; i++) res = min(res, pre[i][r] - pre[i][l - 1]);\\n cout << res << \\\"\\\\n\\\";\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"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.\",\"targets\":\"# -----------------FAST IO-------------------------\\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\\n# sys.stdin = open('input.txt', 'r')\\n# sys.stdout = open('output.txt', 'w')\\n# sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\\n# input = lambda: sys.stdin.readline().rstrip(\\\"\\\\r\\\\n\\\")\\n\\n#---------------------------------------------------\\n\\nimport math\\nfrom collections import Counter\\nfrom itertools import permutations\\nfrom itertools import combinations\\n\\n\\n'''def is_prime(n):\\n j=2\\n while...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"As Will is stuck in the Upside Down, he can still communicate with his mom, Joyce, through the Christmas lights (he can turn them on and off with his mind). He can't directly tell his mom where he is, because the monster that took him to the Upside Down will know and relocate him. \\n\\n\\n\\nThus, he came up with a puzzle to tell his mom his coordinates. His coordinates are the answer to the following problem.\\n\\nA string consisting only of parentheses ('(' and ')') is called a bracket sequence. Some bracket sequence are called correct bracket sequences. More formally:\\n\\n * Empty string is a correct bracket sequence. \\n * if s is a correct bracket sequence, then (s) is also a correct bracket sequence. \\n * if s and t are correct bracket sequences, then st (concatenation of s and t) is also a correct bracket sequence. \\n\\n\\n\\nA string consisting of parentheses and question marks ('?') is called pretty if and only if there's a way to replace each question mark with either '(' or ')' such that the resulting string is a non-empty correct bracket sequence.\\n\\nWill gave his mom a string s consisting of parentheses and question marks (using Morse code through the lights) and his coordinates are the number of pairs of integers (l, r) such that 1 ≤ l ≤ r ≤ |s| and the string slsl + 1... sr is pretty, where si is i-th character of s.\\n\\nJoyce doesn't know anything about bracket sequences, so she asked for your help.\\n\\nInput\\n\\nThe first and only line of input contains string s, consisting only of characters '(', ')' and '?' (2 ≤ |s| ≤ 5000).\\n\\nOutput\\n\\nPrint the answer to Will's puzzle in the first and only line of output.\\n\\nExamples\\n\\nInput\\n\\n((?))\\n\\n\\nOutput\\n\\n4\\n\\n\\nInput\\n\\n??()??\\n\\n\\nOutput\\n\\n7\\n\\nNote\\n\\nFor the first sample testcase, the pretty substrings of s are:\\n\\n 1. \\\"(?\\\" which can be transformed to \\\"()\\\". \\n 2. \\\"?)\\\" which can be transformed to \\\"()\\\". \\n 3. \\\"((?)\\\" which can be transformed to \\\"(())\\\". \\n 4. \\\"(?))\\\" which can be transformed to \\\"(())\\\". \\n\\n\\n\\nFor the second sample testcase, the pretty substrings of s are:\\n\\n 1. \\\"??\\\" which can be...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst int Nmax = 1e6 + 7;\\nint n;\\nint ans;\\nchar s[5005];\\nint main() {\\n scanf(\\\"%s\\\", s);\\n n = strlen(s);\\n for (int i = 0; i < n; i++) {\\n int last = 0;\\n int now = 0;\\n for (int j = i; j < n; j++) {\\n if (s[j] == '(')\\n now++;\\n else if (s[j] == ')') {\\n if (now)\\n now--;\\n else if (last)\\n last--, now++;\\n else\\n break;\\n } else {\\n if (now)\\n now--, last++;\\n else\\n now++;\\n }\\n if (!now) ans++;\\n }\\n }\\n printf(\\\"%d\\\\n\\\", ans);\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"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...\",\"targets\":\"#include \\nusing namespace std;\\nconst long long maxn = 2e5 + 50;\\nlong long n, dp[maxn], k, a[maxn], b[maxn], tp[maxn];\\nvoid solve() {\\n for (long long i = 1; i <= n; i++) b[i] = i - a[i];\\n long long pos = 1, ans = 1e18;\\n for (long long i = 1; i <= n; i++) {\\n dp[i] = (b[i] >= 0);\\n for (long long j = 1; j <= i - 1; j++) {\\n if (b[i] >= 0 and a[i] > a[j] and b[j] <= b[i]) {\\n dp[i] = max(dp[i], dp[j] + 1);\\n }\\n }\\n if (dp[i] >= k and b[i] >= 0) {\\n ans = min(ans, b[i]);\\n }\\n }\\n if (ans != 1e18)\\n cout << ans << '\\\\n';\\n else\\n cout << -1 << '\\\\n';\\n}\\nvoid input() {\\n cin >> n >> k;\\n for (long long i = 1; i <= n; i++) cin >> a[i], dp[i] = 0;\\n}\\nsigned main() {\\n ios_base::sync_with_stdio(false), cin.tie(0);\\n ;\\n long long tt;\\n cin >> tt;\\n while (tt--) {\\n input();\\n solve();\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"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...\\nUsing python3 can you solve the prior task?\",\"targets\":\"t=int(input())\\n\\nfor i in range (t) :\\n r=''\\n n=int(input())\\n ch=str(input()) \\n l=ch.split()\\n p=0\\n if n>3 :\\n for i in range (n-3) :\\n \\n r=r+l[i][0]\\n if l[i][1]!=l[i+1][0]:\\n p+=1\\n r=r+l[i][1]\\n if p==0 :\\n print(r+l[n-3]+'b')\\n \\n else :\\n print(r+l[n-3]) \\n else:\\n g=ch[0]+ch\\n print(g)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given a sequence a of length n consisting of 0s and 1s.\\n\\nYou can perform the following operation on this sequence: \\n\\n * Pick an index i from 1 to n-2 (inclusive). \\n * Change all of a_{i}, a_{i+1}, a_{i+2} to a_{i} ⊕ a_{i+1} ⊕ a_{i+2} simultaneously, where ⊕ denotes the [bitwise XOR operation](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#XOR)\\n\\nFind a sequence of at most n operations that changes all elements of a to 0s or report that it's impossible.\\n\\nWe can prove that if there exists a sequence of operations of any length that changes all elements of a to 0s, then there is also such a sequence of length not greater than n.\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^4).\\n\\nThe first line of each test case contains a single integer n (3 ≤ n ≤ 2⋅10^5) — the length of a.\\n\\nThe second line of each test case contains n integers a_1, a_2, …, a_n (a_i = 0 or a_i = 1) — elements of 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, do the following: \\n\\n * if there is no way of making all the elements of a equal to 0 after performing the above operation some number of times, print \\\"NO\\\". \\n * otherwise, in the first line print \\\"YES\\\", in the second line print k (0 ≤ k ≤ n) — the number of operations that you want to perform on a, and in the third line print a sequence b_1, b_2, ..., b_k (1 ≤ b_i ≤ n - 2) — the indices on which the operation should be applied. \\n\\n\\n\\nIf there are multiple solutions, you may print any.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n3\\n0 0 0\\n5\\n1 1 1 1 0\\n4\\n1 0 0 1\\n\\n\\nOutput\\n\\n\\nYES\\n0\\nYES\\n2\\n3 1\\nNO\\n\\nNote\\n\\nIn the first example, the sequence contains only 0s so we don't need to change anything.\\n\\nIn the second example, we can transform [1, 1, 1, 1, 0] to [1, 1, 0, 0, 0] and then to [0, 0, 0, 0, 0] by performing the operation on the third element of a and then on the first element of a.\\n\\nIn the third example, no matter whether we first perform the operation on the first or on the second element...\",\"targets\":\"import sys,io,os\\ntry:Z=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\\nexcept:Z=lambda:sys.stdin.readline().encode()\\nY=lambda:map(int,Z().split())\\nadd=lambda x:x+1\\n\\ndef f(n,a):\\n m=f=1;c=g=0;x=n;xc=0;z=[]\\n for i in range(n):\\n #print(m,c,f,g,x,xc,z)\\n if a[i]==m:c+=1\\n else:\\n if m==1:\\n if c&1==0:\\n for j in range(c\\/\\/2):z.append(i-2*j-2)\\n if f:f=g=0\\n else:g=1;x=i;xc=c\\n c=1\\n else:\\n if g:\\n if c&1==0:\\n if f:\\n for j in range(x-1,i-2,2):z.append(j)\\n c=i+1\\n else:\\n for j in range(x-xc-1,x-3,2):z.append(j)\\n for j in range(x-2,i-3,2):z.append(j)\\n z.append(i-2)\\n for j in range(i-4,x-3,-2):z.append(j)\\n c=g=0\\n else:\\n if f:f=0\\n for j in range(x-1,i-3,2):z.append(j)\\n z.append(i-2)\\n for j in range(i-4,x-2,-2):z.append(j)\\n for j in range(x-3,x-xc-1,-2):z.append(j)\\n c=g=0\\n else:\\n if f:f=0\\n c=1\\n m=a[i]\\n if g or (m and (c&1 or c==n)):return 0,[]\\n if m:\\n for j in range(n-c-1,n-2,2):z.append(j)\\n return 1,z\\n\\nO=[]\\nfor _ in range(int(Z())):\\n b,z=f(int(Z()),[*Y()])\\n if b:\\n O.append(\\\"YES\\\");O.append(str(len(z)))\\n if z:O.append(' '.join(map(str,map(add,z))))\\n else:O.append(\\\"NO\\\")\\nprint('\\\\n'.join(O))\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the horizontal range of [b,b+W], as shown in the following figure:\\n\\n\\n\\nAtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.\\n\\nConstraints\\n\\n* All input values are integers.\\n* 1≤W≤10^5\\n* 1≤a,b≤10^5\\n\\nInput\\n\\nThe input is given from Standard Input in the following format:\\n\\n\\nW a b\\n\\n\\nOutput\\n\\nPrint the minimum distance the second rectangle needs to be moved.\\n\\nExamples\\n\\nInput\\n\\n3 2 6\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\n3 1 3\\n\\n\\nOutput\\n\\n0\\n\\n\\nInput\\n\\n5 10 1\\n\\n\\nOutput\\n\\n4\\\":\",\"targets\":\"#include\\nusing namespace std;\\nint main(){\\n int w,l1,l2;cin>>w>>l1>>l2;if(l1>l2) swap(l1,l2);\\n int r1=l1+w,r2=l2+w;\\n cout<\\nusing namespace std;\\nint main(void) {\\n int n, m, h, s, sh;\\n scanf(\\\"%d %d %d\\\", &n, &m, &h);\\n h--;\\n s = sh = 0;\\n for (int(i) = 0; (i) < ((m)); (i)++) {\\n int t;\\n scanf(\\\"%d\\\", &t);\\n if (i == h)\\n sh = t;\\n else\\n s += t;\\n }\\n if (s + sh < n) {\\n printf(\\\"-1.0\\\\n\\\");\\n return (0);\\n }\\n sh--;\\n double p = 1.0;\\n for (int(i) = 0; (i) < ((n - 1)); (i)++) {\\n p *= (double)(s - i) \\/ (double)(s + sh - i);\\n }\\n printf(\\\"%.12lf\\\\n\\\", 1.0 - p);\\n return (0);\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Bob really likes playing with arrays of numbers. That's why for his birthday, his friends bought him a really interesting machine – an array beautifier. \\n\\nThe array beautifier takes an array A consisting of N integers, and it outputs a new array B of length N that it constructed based on the array given to it. The array beautifier constructs the new array in the following way: it takes two numbers at different indices from the original array and writes their sum to the end of the new array. It does this step N times - resulting in an output array of length N. During this process, the machine can take the same index multiple times in different steps. \\n\\nBob was very excited about the gift that his friends gave him, so he put his favorite array in the machine. However, when the machine finished, Bob was not happy with the resulting array. He misses his favorite array very much, and hopes to get it back. \\n\\nGiven the array that the machine outputted, help Bob find an array that could be the original array that he put in the machine. Sometimes the machine makes mistakes, so it is possible that no appropriate input array exists for the array it has outputted. In such case, let Bob know that his array is forever lost.\\n\\nInput\\n\\nThe first line contains one positive integer N (2 ≤ N ≤ 10^3) – the length of Bob's array.\\n\\nThe second line contains N integers B_1, B_2, ..., B_N (1 ≤ B_i ≤ 10^6) – the elements of the array the machine outputted.\\n\\nOutput\\n\\nIf an appropriate input array exists, print \\\"YES\\\", followed by the input array A_1, A_2, ..., A_N (-10^9 ≤ A_i ≤ 10^9) in the next line. Otherwise, print \\\"NO\\\".\\n\\nExamples\\n\\nInput\\n\\n\\n2\\n5 5\\n\\n\\nOutput\\n\\n\\nYES\\n2 3\\n\\n\\nInput\\n\\n\\n3\\n1 2 3\\n\\n\\nOutput\\n\\n\\nYES\\n0 1 2\\n\\n\\nInput\\n\\n\\n3\\n2 4 5\\n\\n\\nOutput\\n\\n\\nNO\\n\\n\\nInput\\n\\n\\n4\\n1 3 5 7\\n\\n\\nOutput\\n\\n\\nYES\\n6 -3 4 1\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nconst int Inf = 0x3f3f3f3f;\\nint N;\\nint b[200005], ans[200005];\\nvector ji, ou;\\nint tmp[30000005];\\nint sm[20005], sn[20005];\\nvoid solve(vector &s) {\\n int n = ((int)(s).size());\\n int n1 = n >> 1, n2 = n - n1;\\n for (int i = 0; i < (1 << n1); ++i) {\\n int ss = 0;\\n for (int j = 0; j < n1; ++j)\\n if ((i >> j) & 1) ss += s[j];\\n sm[i] = ss;\\n }\\n for (int i = 0; i < (1 << n2); ++i) {\\n int ss = 0;\\n for (int j = 0; j < n2; ++j)\\n if ((i >> j) & 1) ss += s[j + n1];\\n sn[i] = ss;\\n }\\n int m1 = -1, m2 = -1;\\n memset(tmp, -1, sizeof(tmp));\\n for (int j = 0; j < (1 << n); ++j)\\n if (__builtin_popcount(j) == n1) {\\n int ss = sm[j & ((1 << n1) - 1)] + sn[j >> n1];\\n if (~tmp[ss]) {\\n m1 = tmp[ss], m2 = j;\\n break;\\n }\\n tmp[ss] = j;\\n }\\n if (!~m1) puts(\\\"NO\\\"), exit(0);\\n int an = m1 & m2;\\n m1 ^= an;\\n m2 ^= an;\\n vector res, s1, s2;\\n for (int i = 0; i < n; ++i)\\n if ((m1 >> i) & 1) s1.push_back(s[i]);\\n for (int i = 0; i < n; ++i)\\n if ((m2 >> i) & 1) s2.push_back(s[i]);\\n for (int i = 0; i < ((int)(s1).size()); ++i)\\n res.push_back(s1[i]), res.push_back(s2[i]);\\n int lst = 0;\\n ans[1] = 0;\\n for (int i = 0; i < ((int)(res).size()) - 1; ++i)\\n ans[i + 2] = res[i] - lst, lst = ans[i + 2];\\n int ptr = ((int)(res).size());\\n for (int i = 0; i < n; ++i)\\n if (!((m1 >> i) & 1) && !((m2 >> i) & 1)) ans[++ptr] = s[i] - ans[1];\\n}\\nint main() {\\n scanf(\\\"%d\\\", &N);\\n for (int i = 1; i <= N; ++i) {\\n scanf(\\\"%d\\\", b + i);\\n ((b[i] & 1) ? ji : ou).push_back(b[i]);\\n }\\n if (((int)(ou).size())) {\\n int a, b, c;\\n if (((int)(ou).size()) >= 3)\\n tie(a, b, c) = make_tuple(ou[0], ou[1], ou[2]);\\n else if (((int)(ji).size()) >= 2)\\n tie(a, b, c) = make_tuple(ou[0], ji[0], ji[1]);\\n else\\n return puts(\\\"NO\\\"), 0;\\n ans[1] = (a - b + c) >> 1;\\n ans[2] = a - ans[1];\\n ans[3] = c - ans[1];\\n int ptr = 3;\\n if (((int)(ou).size()) >= 3) {\\n for (int i = 3; i < ((int)(ou).size()); ++i)...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nAndrew and Eugene are playing a game. Initially, Andrew has string s, consisting of digits. Eugene sends Andrew multiple queries of type \\\"di → ti\\\", that means \\\"replace all digits di in string s with substrings equal to ti\\\". For example, if s = 123123, then query \\\"2 → 00\\\" transforms s to 10031003, and query \\\"3 → \\\" (\\\"replace 3 by an empty string\\\") transforms it to s = 1212. After all the queries Eugene asks Andrew to find the remainder after division of number with decimal representation equal to s by 1000000007 (109 + 7). When you represent s as a decimal number, please ignore the leading zeroes; also if s is an empty string, then it's assumed that the number equals to zero.\\n\\nAndrew got tired of processing Eugene's requests manually and he asked you to write a program for that. Help him!\\n\\nInput\\n\\nThe first line contains string s (1 ≤ |s| ≤ 105), consisting of digits — the string before processing all the requests.\\n\\nThe second line contains a single integer n (0 ≤ n ≤ 105) — the number of queries.\\n\\nThe next n lines contain the descriptions of the queries. The i-th query is described by string \\\"di->ti\\\", where di is exactly one digit (from 0 to 9), ti is a string consisting of digits (ti can be an empty string). The sum of lengths of ti for all queries doesn't exceed 105. The queries are written in the order in which they need to be performed.\\n\\nOutput\\n\\nPrint a single integer — remainder of division of the resulting number by 1000000007 (109 + 7).\\n\\nExamples\\n\\nInput\\n\\n123123\\n1\\n2->00\\n\\n\\nOutput\\n\\n10031003\\n\\n\\nInput\\n\\n123123\\n1\\n3->\\n\\n\\nOutput\\n\\n1212\\n\\n\\nInput\\n\\n222\\n2\\n2->0\\n0->7\\n\\n\\nOutput\\n\\n777\\n\\n\\nInput\\n\\n1000000008\\n0\\n\\n\\nOutput\\n\\n1\\n\\nNote\\n\\nNote that the leading zeroes are not removed from string s after the replacement (you can see it in the third sample).\",\"targets\":\"#include \\nusing namespace ::std;\\nuint64_t mod = 1000000007;\\nuint64_t power(uint64_t x, uint64_t y, uint64_t p) {\\n if (y == 0) return (1 % p);\\n if (y == 1) return (x % p);\\n uint64_t t = power(x, y \\/ 2, p);\\n t = (t * t) % p;\\n if (y % 2) t = (t * x) % p;\\n return t;\\n}\\nint main() {\\n string str;\\n cin >> str;\\n int n;\\n cin >> n;\\n vector trans(n, \\\"\\\");\\n for (int i = 0; i < n; i++) cin >> trans[i];\\n vector val(10, 0);\\n vector len(10, 0);\\n for (int i = 0; i < 10; i++) {\\n val[i] = i;\\n len[i] = 1;\\n }\\n for (int i = n - 1; i >= 0; i--) {\\n int d = trans[i][0] - '0';\\n if (trans[i].size() == 3) {\\n val[d] = 0;\\n len[d] = 0;\\n continue;\\n }\\n string s = trans[i].substr(3);\\n uint64_t x = 0;\\n uint64_t y = 0;\\n for (int j = s.size() - 1; j >= 0; j--) {\\n int d1 = s[j] - '0';\\n y = (y + val[d1] * power(10, x, mod)) % mod;\\n x = (x + len[d1]) % (mod - 1);\\n }\\n val[d] = y;\\n len[d] = x;\\n }\\n uint64_t ans = 0;\\n uint64_t tm = 0;\\n for (int i = str.size() - 1; i >= 0; i--) {\\n int d = str[i] - '0';\\n ans = (ans + val[d] * power(10, tm, mod)) % mod;\\n tm = (tm + len[d]) % (mod - 1);\\n }\\n std::cout << ans << std::endl;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Bash has set out on a journey to become the greatest Pokemon master. To get his first Pokemon, he went to Professor Zulu's Lab. Since Bash is Professor Zulu's favourite student, Zulu allows him to take as many Pokemon from his lab as he pleases.\\n\\nBut Zulu warns him that a group of k > 1 Pokemon with strengths {s1, s2, s3, ..., sk} tend to fight among each other if gcd(s1, s2, s3, ..., sk) = 1 (see notes for gcd definition).\\n\\nBash, being smart, does not want his Pokemon to fight among each other. However, he also wants to maximize the number of Pokemon he takes from the lab. Can you help Bash find out the maximum number of Pokemon he can take? \\n\\nNote: A Pokemon cannot fight with itself.\\n\\nInput\\n\\nThe input consists of two lines.\\n\\nThe first line contains an integer n (1 ≤ n ≤ 105), the number of Pokemon in the lab.\\n\\nThe next line contains n space separated integers, where the i-th of them denotes si (1 ≤ si ≤ 105), the strength of the i-th Pokemon.\\n\\nOutput\\n\\nPrint single integer — the maximum number of Pokemons Bash can take.\\n\\nExamples\\n\\nInput\\n\\n3\\n2 3 4\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n5\\n2 3 4 6 7\\n\\n\\nOutput\\n\\n3\\n\\nNote\\n\\ngcd (greatest common divisor) of positive integers set {a1, a2, ..., an} is the maximum positive integer that divides all the integers {a1, a2, ..., an}.\\n\\nIn the first sample, we can take Pokemons with strengths {2, 4} since gcd(2, 4) = 2.\\n\\nIn the second sample, we can take Pokemons with strengths {2, 4, 6}, and there is no larger group with gcd ≠ 1.\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nconst int MAXN = 1e5 + 5;\\nbool seive[MAXN + 4];\\nint m[MAXN];\\nvector > g(MAXN + 4);\\nvoid func() {\\n for (int i = 2; i <= MAXN; i++)\\n if (!seive[i])\\n for (int j = 2; j * i <= MAXN; j++) {\\n seive[i * j] = true;\\n g[i * j].push_back(i);\\n }\\n for (int i = 2; i <= MAXN; i++) {\\n if (!seive[i]) g[i].push_back(i);\\n }\\n}\\nint main() {\\n func();\\n int n;\\n cin >> n;\\n vector a(n);\\n for (int i = 0; i < n; i++) scanf(\\\"%d\\\", &a[i]);\\n for (int i = 0; i < n; i++)\\n for (int j = 0; j < g[a[i]].size(); j++) {\\n m[g[a[i]][j]]++;\\n }\\n int ans = 0;\\n for (int i = 0; i < MAXN; i++) ans = max(ans, m[i]);\\n cout << max(1, ans);\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"As a tradition, every year before IOI all the members of Natalia Fan Club are invited to Malek Dance Club to have a fun night together. Malek Dance Club has 2n members and coincidentally Natalia Fan Club also has 2n members. Each member of MDC is assigned a unique id i from 0 to 2n - 1. The same holds for each member of NFC.\\n\\nOne of the parts of this tradition is one by one dance, where each member of MDC dances with a member of NFC. A dance pair is a pair of numbers (a, b) such that member a from MDC dances with member b from NFC.\\n\\nThe complexity of a pairs' assignment is the number of pairs of dancing pairs (a, b) and (c, d) such that a < c and b > d.\\n\\nYou are given a binary number of length n named x. We know that member i from MDC dances with member from NFC. Your task is to calculate the complexity of this assignment modulo 1000000007 (109 + 7).\\n\\nExpression denotes applying «XOR» to numbers x and y. This operation exists in all modern programming languages, for example, in C++ and Java it denotes as «^», in Pascal — «xor».\\n\\nInput\\n\\nThe first line of input contains a binary number x of lenght n, (1 ≤ n ≤ 100).\\n\\nThis number may contain leading zeros.\\n\\nOutput\\n\\nPrint the complexity of the given dance assignent modulo 1000000007 (109 + 7).\\n\\nExamples\\n\\nInput\\n\\n11\\n\\n\\nOutput\\n\\n6\\n\\n\\nInput\\n\\n01\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n1\\n\\n\\nOutput\\n\\n1\",\"targets\":\"import java.util.Calendar;\\nimport java.util.Scanner;\\n\\n\\/**\\n *\\n * @author Javi\\n *\\/\\npublic class MalekDanceClub {\\n private static final int MODULO = 1000000007;\\n\\n public static void main(String[] args) {\\n Scanner in = new Scanner(System.in);\\n String[] input = in.nextLine().split(\\\" \\\");\\n String binaryEntry = input[0];\\n \\n int res = 0;\\n for (int i = 0; i < binaryEntry.length(); i++) {\\n char entryC = binaryEntry.charAt(binaryEntry.length() - i - 1);\\n if(entryC == '1') {\\n int tmpProduct = modularPower(binaryEntry.length() - 1 + i);\\n res += tmpProduct;\\n if(res > MODULO) {\\n res = res % MODULO;\\n }\\n }\\n }\\n \\n System.out.println(res);\\n in.close();\\n }\\n \\n private static long fastMethod(String binaryEntry) {\\n int res = 0;\\n for (int i = 0; i < binaryEntry.length(); i++) {\\n char entryC = binaryEntry.charAt(binaryEntry.length() - i - 1);\\n if(entryC == '1') {\\n int tmpProduct = modularPower(binaryEntry.length() - 1 + i);\\n res += tmpProduct;\\n if(res > MODULO) {\\n res = res % MODULO;\\n }\\n }\\n } \\n return res;\\n }\\n \\n private static long slowMethod(String binaryEntry) {\\n int modPower = modularPower(binaryEntry.length() - 1);\\n int modEntry = modularEntry(binaryEntry);\\n long modProduct = modularProduct(modEntry, modPower);\\n return modProduct;\\n }\\n\\n private static int modularPower(int n) {\\n int res = 1;\\n for (int i = 0; i < n; i++) {\\n res = res * 2;\\n if (res > MODULO) {\\n res = res % MODULO;\\n }\\n }\\n return res;\\n }\\n\\n private static int modularEntry(String number) {\\n int accCount = 1;\\n int res = 0;\\n for (int i = number.length() - 1; i >= 0; i--) {\\n char...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"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 \\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nusing ull = uint64_t;\\nusing ll = int64_t;\\nusing ld = long double;\\nusing pii = pair;\\nint main() {\\n ios::sync_with_stdio(false);\\n cin.tie(nullptr);\\n int ttt;\\n cin >> ttt;\\n while (ttt--) {\\n int n, m;\\n cin >> n >> m;\\n vector x(n);\\n for (int i = 0; i < n; ++i) cin >> x[i];\\n vector v(n);\\n for (int i = 0; i < n; ++i) cin >> v[i];\\n ll ans = -1e18;\\n vector ansp;\\n vector coeff;\\n vector assignment;\\n vector> counter(2 * n + 1);\\n for (int mask = 0; mask < (1 << n); ++mask) {\\n ll sum = 0;\\n coeff.assign(m, 0);\\n assignment.assign(m, 0);\\n for (int i = 0; i <= 2 * n; ++i) counter[i].clear();\\n for (int i = 0; i < n; ++i) {\\n bool inv = (mask & (1 << i));\\n sum += inv ? x[i] : -x[i];\\n for (int j = 0; j < m; ++j) {\\n if (v[i][j] == '1') {\\n coeff[j] += inv ? -1 : 1;\\n }\\n }\\n }\\n for (int j = 0; j < m; ++j) counter[coeff[j] + n].push_back(j);\\n int permi = 0;\\n for (int i = 0; i <= 2 * n; ++i) {\\n for (int j : counter[i]) {\\n assignment[j] = ++permi;\\n sum += coeff[j] * (ll)permi;\\n }\\n }\\n if (sum > ans) ans = sum, ansp = assignment;\\n }\\n for (int i : ansp) {\\n cout << i << ' ';\\n }\\n cout << '\\\\n';\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given two positive integers x and y. You can perform the following operation with x: write it in its binary form without leading zeros, add 0 or 1 to the right of it, reverse the binary form and turn it into a decimal number which is assigned as the new value of x.\\n\\nFor example: \\n\\n * 34 can be turned into 81 via one operation: the binary form of 34 is 100010, if you add 1, reverse it and remove leading zeros, you will get 1010001, which is the binary form of 81. \\n * 34 can be turned into 17 via one operation: the binary form of 34 is 100010, if you add 0, reverse it and remove leading zeros, you will get 10001, which is the binary form of 17. \\n * 81 can be turned into 69 via one operation: the binary form of 81 is 1010001, if you add 0, reverse it and remove leading zeros, you will get 1000101, which is the binary form of 69. \\n * 34 can be turned into 69 via two operations: first you turn 34 into 81 and then 81 into 69. \\n\\n\\n\\nYour task is to find out whether x can be turned into y after a certain number of operations (possibly zero).\\n\\nInput\\n\\nThe only line of the input contains two integers x and y (1 ≤ x, y ≤ 10^{18}).\\n\\nOutput\\n\\nPrint YES if you can make x equal to y and NO if you can't.\\n\\nExamples\\n\\nInput\\n\\n\\n3 3\\n\\n\\nOutput\\n\\n\\nYES\\n\\n\\nInput\\n\\n\\n7 4\\n\\n\\nOutput\\n\\n\\nNO\\n\\n\\nInput\\n\\n\\n2 8\\n\\n\\nOutput\\n\\n\\nNO\\n\\n\\nInput\\n\\n\\n34 69\\n\\n\\nOutput\\n\\n\\nYES\\n\\n\\nInput\\n\\n\\n8935891487501725 71487131900013807\\n\\n\\nOutput\\n\\n\\nYES\\n\\nNote\\n\\nIn the first example, you don't even need to do anything.\\n\\nThe fourth example is described in the statement.\",\"targets\":\"#include \\nusing namespace std;\\nvector fun(long long x) {\\n vector v;\\n while (x) {\\n v.push_back(x % 2);\\n x \\/= 2;\\n }\\n reverse(v.begin(), v.end());\\n return v;\\n}\\nint main() {\\n int t = 1, fac = 1;\\n while (t--) {\\n long long n, i, x, y;\\n vector v1, v2;\\n cin >> x >> y;\\n map, int> mp;\\n v1 = fun(x);\\n v2 = fun(y);\\n queue > q;\\n q.push(v1);\\n mp[v1] = 1;\\n while (!q.empty()) {\\n vector v = q.front();\\n q.pop();\\n if (v.size() >= 100) continue;\\n vector v3 = v;\\n v3.push_back(0);\\n while (v3[v3.size() - 1] == 0) v3.pop_back();\\n reverse(v3.begin(), v3.end());\\n if (mp[v3] == 0) {\\n mp[v3] = 1;\\n q.push(v3);\\n }\\n v3 = v;\\n v3.push_back(1);\\n reverse(v3.begin(), v3.end());\\n if (mp[v3] == 0) {\\n mp[v3] = 1;\\n q.push(v3);\\n }\\n }\\n if (mp[v2])\\n cout << \\\"YES\\\" << endl;\\n else\\n cout << \\\"NO\\\" << endl;\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"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;\\nconst long long MOD = 1e9 + 7;\\nconst int N = 128;\\nint t, n, k;\\nint cnt[N];\\nbool vis[N];\\nlong long dp[N][N];\\nvector path[N];\\nlong long calc(int, int);\\nint main() {\\n int a, b;\\n scanf(\\\"%d\\\", &t);\\n while (t--) {\\n scanf(\\\"%d %d\\\", &n, &k);\\n for (int i = 0; i <= n; i++) path[i].clear();\\n for (int i = 1; i < n; i++) {\\n scanf(\\\"%d %d\\\", &a, &b);\\n path[a].push_back(b);\\n path[b].push_back(a);\\n }\\n if (k == 2) {\\n printf(\\\"%lld\\\\n\\\", (n - 1ll) * n \\/ 2 % MOD);\\n continue;\\n }\\n long long ans = 0;\\n for (int root = 1; root <= n; root++) {\\n memset(vis, false, sizeof(vis));\\n vis[root] = true;\\n int size = path[root].size();\\n vector> layer;\\n for (int i = 0; i < size; i++) {\\n int son = path[root][i];\\n layer.emplace_back(son, i);\\n cnt[i] = 1;\\n vis[son] = true;\\n }\\n while (!layer.empty()) {\\n ans = (ans + calc(size, k)) % MOD;\\n vector> newLayer;\\n for (auto node : layer) {\\n cnt[node.second]--;\\n for (auto son : path[node.first]) {\\n if (vis[son]) continue;\\n vis[son] = true;\\n cnt[node.second]++;\\n newLayer.emplace_back(son, node.second);\\n }\\n }\\n layer = newLayer;\\n }\\n }\\n printf(\\\"%lld\\\\n\\\", ans);\\n }\\n return 0;\\n}\\nlong long calc(int x, int y) {\\n memset(dp, 0, sizeof(dp));\\n dp[0][0] = 1;\\n for (int i = 0; i < x; i++)\\n for (int j = 0; j <= y; j++) {\\n dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;\\n dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j] * cnt[i] % MOD) % MOD;\\n }\\n return dp[x][y];\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 solution for \\\"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\":\"for _ in range(int(input())):\\n x1,p1=map(int,input().split())\\n x2,p2=map(int,input().split())\\n m = min(p1,p2)\\n p1-=m\\n p2-=m\\n for i in range(p1):\\n x1*=10\\n if x2x1:\\n break\\n if x1>x2:\\n print('>')\\n elif x1==x2:\\n print('=')\\n else:\\n print('<')\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"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.*;\\n\\npublic class Tree\\n{\\n static class pair\\n {\\n int x, y, k;\\n pair(int x, int y, int k)\\n {\\n this.x = x;\\n this.y = y;\\n this.k = k;\\n }\\n }\\n\\n public static void main(String[] args)\\n {\\n Scanner sc = new Scanner(System.in);\\n int t = sc.nextInt();\\n while(t-->0)\\n {\\n int n = sc.nextInt();\\n long a[] = new long[n];\\n for(int i=0; i list = new ArrayList<>();\\n for (int i = 1; i < n; i++)\\n {\\n long cur = a[i];\\n int j = i - 1;\\n while (j >= 0 && a[j] > cur)\\n {\\n a[j + 1] = a[j];\\n j--;\\n }\\n if(j!=i-1)\\n {\\n k++;\\n list.add(new pair(j+2, i+1, i-j-1));\\n }\\n a[j + 1] = cur;\\n }\\n System.out.println(k);\\n for(pair p: list)\\n {\\n System.out.println(p.x + \\\" \\\" + p.y + \\\" \\\" + p.k);\\n }\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"On an endless checkered sheet of paper, n cells are chosen and colored in three colors, where n is divisible by 3. It turns out that there are exactly n\\/3 marked cells of each of three colors! \\n\\nFind the largest such k that it's possible to choose k\\/3 cells of each color, remove all other marked cells, and then select three rectangles with sides parallel to the grid lines so that the following conditions hold:\\n\\n * No two rectangles can intersect (but they can share a part of the boundary). In other words, the area of intersection of any two of these rectangles must be 0.\\n * The i-th rectangle contains all the chosen cells of the i-th color and no chosen cells of other colors, for i = 1, 2, 3. \\n\\nInput\\n\\nThe first line of the input contains a single integer n — the number of the marked cells (3 ≤ n ≤ 10^5, n is divisible by 3).\\n\\nThe i-th of the following n lines contains three integers x_i, y_i, c_i (|x_i|,|y_i| ≤ 10^9; 1 ≤ c_i ≤ 3), where (x_i, y_i) are the coordinates of the i-th marked cell and c_i is its color.\\n\\nIt's guaranteed that all cells (x_i, y_i) in the input are distinct, and that there are exactly n\\/3 cells of each color.\\n\\nOutput\\n\\nOutput a single integer k — the largest number of cells you can leave.\\n\\nExamples\\n\\nInput\\n\\n\\n9\\n2 3 1\\n4 1 2\\n2 1 3\\n3 4 1\\n5 3 2\\n4 4 3\\n2 4 1\\n5 2 2\\n3 5 3\\n\\n\\nOutput\\n\\n\\n6\\n\\n\\nInput\\n\\n\\n3\\n1 1 1\\n2 2 2\\n3 3 3\\n\\n\\nOutput\\n\\n\\n3\\n\\nNote\\n\\nIn the first sample, it's possible to leave 6 cells with indexes 1, 5, 6, 7, 8, 9.\\n\\nIn the second sample, it's possible to leave 3 cells with indexes 1, 2, 3.\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nnamespace jyy {\\nconst int mod = 998244353, N = 400010;\\nconst double eps = 1e-8;\\ninline int read() {\\n static int x = 0, f = 1;\\n x = 0, f = 1;\\n static char ch = getchar();\\n while (ch < '0' || ch > '9') {\\n (ch == '-') ? f *= -1 : f;\\n ch = getchar();\\n }\\n while (ch >= '0' && ch <= '9') x = x * 10 + int(ch - 48), ch = getchar();\\n return x * f;\\n}\\ninline void fw(int x) {\\n if (x < 0) putchar('-'), x = -x;\\n x >= 10 ? fw(x \\/ 10), 1 : 0;\\n putchar(char(x % 10 + 48));\\n}\\ninline int qmo(int x) { return x + ((x >> 31) & mod); }\\ninline int ksm(int x, int y) {\\n int tmp = 1;\\n for (; y; y >>= 1, x = 1ll * x * x % mod)\\n if (y & 1) tmp = 1ll * tmp * x % mod;\\n return tmp;\\n}\\ninline int inv(int x) { return ksm(x, mod - 2); }\\nint tot, head[N], fa[N];\\nstruct edge {\\n int to, next;\\n} dat[N * 2];\\nvoid add_edge(int x, int y) { dat[++tot] = (edge){y, head[x]}, head[x] = tot; }\\ninline int find(int x) { return fa[x] ? fa[x] = find(fa[x]) : x; }\\ninline int merge(int x, int y) {\\n return find(x) != find(y) ? fa[find(x)] = find(y), 0 : 1;\\n}\\ninline int low(int x) { return x & -x; }\\nint ifac[N], fac[N];\\ninline void init(int x) {\\n fac[0] = ifac[0] = 1;\\n for (int i = 1; i <= x; i++) fac[i] = 1ll * fac[i - 1] * i % mod;\\n ifac[x] = inv(fac[x]);\\n for (int i = x - 1; i >= 1; i--) ifac[i] = 1ll * ifac[i + 1] * (i + 1) % mod;\\n}\\ninline int C(int x, int y) {\\n return (x < y || y < 0 || x < 0)\\n ? 0\\n : 1ll * fac[x] * ifac[y] % mod * ifac[x - y] % mod;\\n}\\n} \\/\\/ namespace jyy\\nusing namespace jyy;\\nint a[N], n, b[N], c[N], p[N], cnt, val[N];\\nvector v1[4][N], v2[4][N];\\nint do11(int mid) {\\n int num = 0, now = 0;\\n for (int i = 1; i <= cnt; i++) {\\n now = i + 1;\\n num += v1[p[1]][i].size();\\n if (num >= mid) break;\\n }\\n if (now > cnt) return 0;\\n int hh = now;\\n num = 0;\\n for (int i = now; i <= cnt; i++) {\\n now = i + 1;\\n num += v1[p[2]][i].size();\\n if (num >= mid) break;\\n }\\n if (now > cnt) return 0;\\n num = 0;\\n for (int i = now; i <= cnt; i++) num...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Amidakuji is a traditional method of lottery in Japan.\\n\\nTo make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 [cm], and the endpoints of the horizontal lines must be at 1, 2, 3, ..., or H [cm] from the top of a vertical line.\\n\\nA valid amidakuji is an amidakuji that satisfies the following conditions:\\n\\n* No two horizontal lines share an endpoint.\\n* The two endpoints of each horizontal lines must be at the same height.\\n* A horizontal line must connect adjacent vertical lines.\\n\\n\\n\\n\\n\\nFind the number of the valid amidakuji that satisfy the following condition, modulo 1\\\\ 000\\\\ 000\\\\ 007: if we trace the path from the top of the leftmost vertical line to the bottom, always following horizontal lines when we encounter them, we reach the bottom of the K-th vertical line from the left.\\n\\nFor example, in the following amidakuji, we will reach the bottom of the fourth vertical line from the left.\\n\\n\\n\\nConstraints\\n\\n* H is an integer between 1 and 100 (inclusive).\\n* W is an integer between 1 and 8 (inclusive).\\n* K is an integer between 1 and W (inclusive).\\n\\nInput\\n\\nInput is given from Standard Input in the following format:\\n\\n\\nH W K\\n\\n\\nOutput\\n\\nPrint the number of the amidakuji that satisfy the condition, modulo 1\\\\ 000\\\\ 000\\\\ 007.\\n\\nExamples\\n\\nInput\\n\\n1 3 2\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\n1 3 1\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n2 3 3\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\n2 3 1\\n\\n\\nOutput\\n\\n5\\n\\n\\nInput\\n\\n7 1 1\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\n15 8 5\\n\\n\\nOutput\\n\\n437760187\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include\\nusing namespace std;\\n\\n#define int long long\\n#define rep(i,n) for(int i=0;i<(n);i++)\\n#define repf(i,j,n) for(int i=(j);i<(n);i++)\\n#define repe(i,j,n) for(int i=(j);i<=(n);i++)\\n\\nint fibary[20];\\nint dp[10][110];\\nint mod=1e9+7;\\n\\nint fib(int a){\\n\\tif(a<=0)return 1;\\n\\tif (fibary[a]>0)return fibary[a];\\n\\telse return fibary[a]=fib(a-1)+fib(a-2);\\n}\\n\\nsigned main(){\\n\\tint h,w,k;cin>>h>>w>>k;\\t\\n\\tfill(fibary,fibary+10,-1);\\n\\tfibary[0]=1;fibary[1]=1;\\n\\t\\n\\tfill(dp[0],dp[10],0);\\n\\tdp[0][0]=1;\\n\\t\\t\\n\\trep(j,h+1)rep(i,w){\\n\\t(dp[i][j+1]+=dp[i][j]*fib(w-i-1)*fib(i))%=mod;\\n\\tif(i>0)(dp[i][j+1]+=dp[i-1][j]*fib(w-i-1)*fib(i-1))%=mod;\\n\\tif(i\\n\\nAs mentioned previously William really likes playing video games. In one of his favorite games, the player character is in a universe where every planet is designated by a binary number from 0 to 2^n - 1. On each planet, there are gates that allow the player to move from planet i to planet j if the binary representations of i and j differ in exactly one bit.\\n\\nWilliam wants to test you and see how you can handle processing the following queries in this game universe:\\n\\n * Destroy planets with numbers from l to r inclusively. These planets cannot be moved to anymore.\\n * Figure out if it is possible to reach planet b from planet a using some number of planetary gates. It is guaranteed that the planets a and b are not destroyed. \\n\\nInput\\n\\nThe first line contains two integers n, m (1 ≤ n ≤ 50, 1 ≤ m ≤ 5 ⋅ 10^4), which are the number of bits in binary representation of each planets' designation and the number of queries, respectively.\\n\\nEach of the next m lines contains a query of two types:\\n\\nblock l r — query for destruction of planets with numbers from l to r inclusively (0 ≤ l ≤ r < 2^n). It's guaranteed that no planet will be destroyed twice.\\n\\nask a b — query for reachability between planets a and b (0 ≤ a, b < 2^n). It's guaranteed that planets a and b hasn't been destroyed yet.\\n\\nOutput\\n\\nFor each query of type ask you must output \\\"1\\\" in a new line, if it is possible to reach planet b from planet a and \\\"0\\\" otherwise (without quotation marks).\\n\\nExamples\\n\\nInput\\n\\n\\n3 3\\nask 0 7\\nblock 3 6\\nask 0 7\\n\\n\\nOutput\\n\\n\\n1\\n0\\n\\n\\nInput\\n\\n\\n6 10\\nblock 12 26\\nask 44 63\\nblock 32 46\\nask 1 54\\nblock 27 30\\nask 10 31\\nask 11 31\\nask 49 31\\nblock 31 31\\nask 2 51\\n\\n\\nOutput\\n\\n\\n1\\n1\\n0\\n0\\n1\\n0\\n\\nNote\\n\\nThe first example test can be visualized in the following way:\\n\\n\\n\\nResponse to a query ask 0 7 is positive.\\n\\nNext after query block 3 6 the graph will look the following way (destroyed vertices are highlighted):\\n\\n\\n\\nResponse to a query ask 0 7 is negative, since any path from vertex 0 to vertex 7 must go through one of the destroyed vertices.\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint n, m, k = 0;\\nlong long b[200010];\\nint fa[200010], ans[50010];\\nvector E[200010];\\nbool ban[200010];\\nchar s[10];\\nstruct ask {\\n int ty;\\n long long l, r;\\n} q[50010];\\nint find(int u) { return u == fa[u] ? u : fa[u] = find(fa[u]); }\\nvoid merge(int u, int v) { u = find(u), v = find(v), fa[u] = v; }\\nvoid ins(int u) {\\n for (int v : E[u])\\n if (!ban[v]) merge(u, v);\\n}\\nint main() {\\n scanf(\\\"%d%d\\\", &n, &m);\\n for (int i = 1; i <= n; i++) scanf(\\\"%d\\\", &n);\\n for (int i = 1; i <= m; i++) {\\n scanf(\\\"%s%lld%lld\\\", s + 1, &q[i].l, &q[i].r);\\n q[i].ty = s[1] == 'a';\\n if (!q[i].ty) b[++k] = q[i].l, b[++k] = q[i].r + 1;\\n }\\n b[++k] = 1ll << n, b[++k] = 0;\\n sort(b + 1, b + k + 1);\\n int o = k;\\n for (int i = 1; i < o; i++) {\\n long long l = b[i], r = b[i + 1] - 1,\\n x = 1ll << (63 - __builtin_clzll(l ^ r));\\n if (l >= r) continue;\\n b[++k] = ((l \\/ x) * x) | x;\\n }\\n sort(b + 1, b + k + 1);\\n k = unique(b + 1, b + k + 1) - b - 2;\\n for (int i = 0; i < n; i++)\\n for (int p = 0; p < 2; p++)\\n for (int j = 1, l = 1; j <= k; j++) {\\n if (((b[j] >> i) & 1) == p) {\\n while ((b[j] ^ (1ll << i)) >= b[l + 1]) l++;\\n if (l != j) E[l].push_back(j), E[j].push_back(l);\\n }\\n }\\n for (int i = 1; i <= m; i++) {\\n q[i].l = upper_bound(b + 1, b + k + 1, q[i].l) - b - 1;\\n q[i].r = upper_bound(b + 1, b + k + 1, q[i].r) - b - 1;\\n if (!q[i].ty)\\n for (int j = q[i].l; j <= q[i].r; j++) ban[j] = 1;\\n }\\n iota(fa + 1, fa + k + 1, 1);\\n for (int i = 1; i <= k; i++)\\n if (!ban[i]) ins(i);\\n for (int i = m; i >= 1; i--) {\\n if (!q[i].ty)\\n for (int j = q[i].l; j <= q[i].r; j++) ban[j] = 0, ins(j);\\n else\\n ans[i] = find(q[i].l) == find(q[i].r);\\n }\\n for (int i = 1; i <= m; i++)\\n if (q[i].ty) printf(\\\"%d\\\\n\\\", ans[i]);\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in PYTHON3?\\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\":\"t = int(input())\\nfor i in range(t):\\n n = int(input())\\n players = input()\\n list_2 = []\\n for j, player in enumerate(players):\\n if player == '2':\\n list_2.append(j)\\n \\n if len(list_2) == 1 or len(list_2) == 2:\\n print(\\\"NO\\\")\\n else:\\n print(\\\"YES\\\")\\n games = [[\\\"=\\\" for x in range(n)] for x in range(n)]\\n for j in range(n):\\n games[j][j] = \\\"X\\\"\\n for j, two in enumerate(list_2):\\n other = j+1\\n if j+1 == len(list_2):\\n other = 0\\n games[two][list_2[other]] = '+'\\n games[list_2[other]][two] = '-'\\n print(\\\"\\\\n\\\".join([\\\"\\\".join(l) for l in games]))\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"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.*;\\nimport static java.lang.Math.*;\\n\\npublic class Practice {\\n\\n\\tstatic Scanner scn = new Scanner(System.in);\\n\\tstatic StringBuilder sb = new StringBuilder();\\n\\tstatic PrintWriter out = new PrintWriter(System.out);\\n\\n\\tpublic static void main(String[] HastaLaVistaLa) {\\n\\t\\t\\/\\/ int t = 1;\\n\\t\\tint t = scn.nextInt();\\n\\t\\tfor(int tests = 0; tests < t; tests++) solve();\\n\\t\\tout.println(sb);\\n\\t\\tout.close();\\n\\t}\\t\\n\\tpublic static void solve() {\\n\\t\\tint n = scn.nextInt(), m = scn.nextInt(), k = scn.nextInt();\\n\\t\\tchar[][] ch = new char[n][m];\\n\\t\\tfor(int i = 0; i < n; i++) ch[i] = scn.next().toCharArray();\\n\\t\\tboolean[][] vis = new boolean[n][m];\\n\\t\\tfor(int i = n - 1; i >= 0; i--) {\\n\\t\\t\\tfor(int j = m - 1; j >= 0; j--) {\\n\\t\\t\\t\\tif(ch[i][j] == '.') continue;\\n\\t\\t\\t\\tint counter = 0; \\/\\/ number of * at both sides\\n\\t\\t\\t\\tint nX = i - 1, nLY = j - 1, nRY = j + 1; \\n\\t\\t\\t\\twhile (c(nX, n) && c(nLY, m) && c(nRY, m) && ch[nX][nLY] == '*' && ch[nX][nRY] == '*') {\\n\\t\\t\\t\\t\\tcounter++;\\n\\t\\t\\t\\t\\tnX--;\\n\\t\\t\\t\\t\\tnLY--;\\n\\t\\t\\t\\t\\tnRY++;\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\/\\/ System.out.println(\\\"at index \\\" + i + \\\" \\\" + j + \\\" -> \\\" + counter);\\n\\t\\t\\t\\tif(!vis[i][j]) {\\n\\t\\t\\t\\t\\tif(counter < k) {\\n\\t\\t\\t\\t\\t\\t\\/\\/ not possible\\n\\t\\t\\t\\t\\t\\tsb.append(\\\"NO\\\\n\\\");\\n\\t\\t\\t\\t\\t\\treturn;\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\tvis[i][j] = true;\\t\\n\\t\\t\\t\\t\\tnX = i - 1; nLY = j - 1; nRY = j + 1; \\n\\t\\t\\t\\t\\tfor(int p = 1; p <= counter; p++) {\\n\\t\\t\\t\\t\\t\\tvis[nX][nLY] = true;\\n\\t\\t\\t\\t\\t\\tvis[nX][nRY] = true;\\n\\t\\t\\t\\t\\t\\tnX--;\\n\\t\\t\\t\\t\\t\\tnLY--;\\n\\t\\t\\t\\t\\t\\tnRY++;\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}else {\\n\\t\\t\\t\\t\\tif(counter >= k) {\\n\\t\\t\\t\\t\\t\\tvis[i][j] = true;\\n\\t\\t\\t\\t\\t\\tnX = i - 1; nLY = j - 1; nRY = j + 1; \\n\\t\\t\\t\\t\\t\\tfor(int p = 1; p <= counter; p++) {\\n\\t\\t\\t\\t\\t\\t\\tvis[nX][nLY] = true;\\n\\t\\t\\t\\t\\t\\t\\tvis[nX][nRY] = true;\\n\\t\\t\\t\\t\\t\\t\\tnX--;\\n\\t\\t\\t\\t\\t\\t\\tnLY--;\\n\\t\\t\\t\\t\\t\\t\\tnRY++;\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t}\\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 < m; j++) {\\n\\t\\t\\t\\tif(!vis[i][j] && ch[i][j] == '*') {\\n\\t\\t\\t\\t\\t\\/\\/ not possible\\n\\t\\t\\t\\t\\tsb.append(\\\"NO\\\\n\\\");\\n\\t\\t\\t\\t\\treturn;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\tsb.append(\\\"YES\\\\n\\\");\\n\\t}\\n\\tpublic static boolean c(int x, int n) {\\n\\t\\treturn x >= 0 && x < n;\\n\\t}\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"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;\\nvoid solve() {\\n long long n, k;\\n cin >> n >> k;\\n set s;\\n for (long long i = 0; i < n * 2; ++i) s.insert(i);\\n vector> p;\\n for (long long i = 0; i < k; ++i) {\\n long long x, y;\\n cin >> x >> y;\\n if (x > y) swap(x, y);\\n p.push_back({x - 1, y - 1});\\n s.erase(x - 1);\\n s.erase(y - 1);\\n }\\n vector ost;\\n for (long long i : s) ost.push_back(i);\\n for (long long i = 0; i < n - k; ++i) p.push_back({ost[i], ost[i + n - k]});\\n long long res = 0;\\n for (long long i = 0; i < n; ++i)\\n for (long long j = 0; j < n; ++j) {\\n if (p[i].first < p[j].first && p[i].second > p[j].first &&\\n p[i].second < p[j].second)\\n res++;\\n }\\n cout << res << \\\"\\\\n\\\";\\n}\\nint32_t main() {\\n long long t = 1;\\n cin >> t;\\n while (t--) solve();\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"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.\\\":\",\"targets\":\"#include \\nusing namespace std;\\ntemplate \\nstruct ModInt {\\n int64_t x;\\n ModInt() : x(0) {}\\n ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}\\n ModInt &operator+=(const ModInt &p) {\\n if ((x += p.x) >= mod) x -= mod;\\n return *this;\\n }\\n ModInt &operator-=(const ModInt &p) {\\n if ((x += mod - p.x) >= mod) x -= mod;\\n return *this;\\n }\\n ModInt &operator*=(const ModInt &p) {\\n x = int64_t(int64_t(1) * x * p.x % mod);\\n return *this;\\n }\\n ModInt &operator\\/=(const ModInt &p) {\\n *this *= p.inverse();\\n return *this;\\n }\\n ModInt operator-() const { return ModInt(-x); }\\n ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }\\n ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }\\n ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }\\n ModInt operator\\/(const ModInt &p) const { return ModInt(*this) \\/= p; }\\n bool operator==(const ModInt &p) const { return x == p.x; }\\n bool operator!=(const ModInt &p) const { return x != p.x; }\\n ModInt inverse() const {\\n int64_t a = x, b = mod, u = 1, v = 0, t;\\n while (b > 0) {\\n t = a \\/ b;\\n swap(a -= t * b, b);\\n swap(u -= t * v, v);\\n }\\n return ModInt(u);\\n }\\n ModInt power(int64_t n) const {\\n ModInt ret(1), mul(x);\\n while (n > 0) {\\n if (n & 1) ret *= mul;\\n mul *= mul;\\n n >>= 1;\\n }\\n return ret;\\n }\\n friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; }\\n friend istream &operator>>(istream &is, ModInt &a) {\\n int64_t t;\\n is >> t;\\n a = ModInt(t);\\n return (is);\\n }\\n static int64_t get_mod() { return mod; }\\n};\\nconst int64_t mod = 998244353;\\nusing Mint = ModInt;\\nint32_t main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n cout.tie(0);\\n int64_t n, k;\\n cin >> n >> k;\\n string s;\\n cin >> s;\\n if (k == 0) {\\n cout << 1;\\n return 0;\\n }\\n vector f(n + 1);\\n f[0] = 1;\\n for (int64_t i = 1; i <= n; i++) {\\n f[i] = f[i - 1] * Mint(i);\\n }\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Being a nonconformist, Volodya is displeased with the current state of things, particularly with the order of natural numbers (natural number is positive integer number). He is determined to rearrange them. But there are too many natural numbers, so Volodya decided to start with the first n. He writes down the following sequence of numbers: firstly all odd integers from 1 to n (in ascending order), then all even integers from 1 to n (also in ascending order). Help our hero to find out which number will stand at the position number k.\\n\\nInput\\n\\nThe only line of input contains integers n and k (1 ≤ k ≤ n ≤ 1012).\\n\\nPlease, do not use 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\\nOutput\\n\\nPrint the number that will stand at the position number k after Volodya's manipulations.\\n\\nExamples\\n\\nInput\\n\\n10 3\\n\\n\\nOutput\\n\\n5\\n\\nInput\\n\\n7 7\\n\\n\\nOutput\\n\\n6\\n\\nNote\\n\\nIn the first sample Volodya's sequence will look like this: {1, 3, 5, 7, 9, 2, 4, 6, 8, 10}. The third place in the sequence is therefore occupied by the number 5.\\nSolve the task in PYTHON3.\",\"targets\":\"limit,hasil = map(int, input().split())\\nkondisi = \\\"\\\"\\nif limit%2== 0:\\n tengah = limit\\/2\\nelse:\\n tengah = (limit+1)\\/2\\n\\nif hasil > tengah :\\n kondisi = \\\"genap\\\"\\nelse:\\n kondisi = \\\"ganjil\\\"\\n\\nif kondisi == \\\"ganjil\\\":\\n print(int(1+(hasil-1)*2))\\nelse:\\n print(int(2+(hasil-tengah-1)*2))\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A sequence of n non-negative integers (n ≥ 2) a_1, a_2, ..., a_n is called good if for all i from 1 to n-1 the following condition holds true: $$$a_1 \\\\: \\\\& \\\\: a_2 \\\\: \\\\& \\\\: ... \\\\: \\\\& \\\\: a_i = a_{i+1} \\\\: \\\\& \\\\: a_{i+2} \\\\: \\\\& \\\\: ... \\\\: \\\\& \\\\: a_n, where \\\\&$$$ denotes the [bitwise AND operation](https:\\/\\/en.wikipedia.org\\/wiki\\/Bitwise_operation#AND).\\n\\nYou are given an array a of size n (n ≥ 2). Find the number of permutations p of numbers ranging from 1 to n, for which the sequence a_{p_1}, a_{p_2}, ... ,a_{p_n} is good. Since this number can be large, output it modulo 10^9+7.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 10^4), denoting the number of test cases.\\n\\nThe first line of each test case contains a single integer n (2 ≤ n ≤ 2 ⋅ 10^5) — the size of the array.\\n\\nThe second line of each test case contains n integers a_1, a_2, …, a_n (0 ≤ a_i ≤ 10^9) — the elements of the array.\\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, where the i-th line contains the number of good permutations in the i-th test case modulo 10^9 + 7.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n1 1 1\\n5\\n1 2 3 4 5\\n5\\n0 2 0 3 0\\n4\\n1 3 5 1\\n\\n\\nOutput\\n\\n\\n6\\n0\\n36\\n4\\n\\nNote\\n\\nIn the first test case, since all the numbers are equal, whatever permutation we take, the sequence is good. There are a total of 6 permutations possible with numbers from 1 to 3: [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1].\\n\\nIn the second test case, it can be proved that no permutation exists for which the sequence is good.\\n\\nIn the third test case, there are a total of 36 permutations for which the sequence is good. One of them is the permutation [1,5,4,2,3] which results in the sequence s=[0,0,3,2,0]. This is a good sequence because \\n\\n * s_1 = s_2 \\\\: \\\\& \\\\: s_3 \\\\: \\\\& \\\\: s_4 \\\\: \\\\& \\\\: s_5 = 0, \\n * s_1 \\\\: \\\\& \\\\: s_2 = s_3 \\\\: \\\\& \\\\: s_4 \\\\: \\\\& \\\\: s_5 = 0, \\n * s_1 \\\\: \\\\& \\\\: s_2 \\\\: \\\\& \\\\: s_3 = s_4 \\\\: \\\\& \\\\: s_5 = 0, \\n * s_1 \\\\: \\\\& \\\\: s_2 \\\\: \\\\& \\\\: s_3 \\\\: \\\\& \\\\: s_4 = s_5 = 0. \\nSolve the task in PYTHON3.\",\"targets\":\"import sys\\nfrom collections import deque, defaultdict\\nfrom itertools import permutations\\n\\nmd = 10 ** 9 + 7\\n# sys.stdin = open(\\\"input.txt\\\", \\\"r\\\")\\nf = [1] * (2 * 10 ** 5+7)\\nfor j in range(1, 2 * 10 ** 5+3):\\n f[j] = ((f[j - 1] % md * (j + 1) % md)) % md\\n\\nt = int(input())\\nfor i in range(t):\\n n = int(input())\\n d = list(map(int, input().split()))\\n p = d[0]\\n for i in d:\\n p &= i\\n t = 0\\n for j in d:\\n if j == p:\\n t += 1\\n print(((t * (t - 1)) % md) * (f[n - 3] % md) % md)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"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...\\nt=int\",\"targets\":\"(input())\\nfor i in range(0,t):\\n\\tn=int(input())\\n\\tL=list(map(str,input().split()))\\n\\tif(n==3):\\n\\t\\ts=L[0]+\\\"a\\\"\\n\\t\\tprint(s)\\n\\telse:\\n\\t\\ts=L[0][0]\\n\\t\\tj=1\\n\\t\\twhile(j\\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\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nlong long denom = 1e9 + 7;\\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(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n long long t = 1;\\n while (t-- > 0) {\\n long long n, m, q;\\n cin >> n >> m >> q;\\n vector> isBlocked(n, vector(m, false));\\n vector> move = {{0, 1}, {1, 0}};\\n vector>> hor;\\n unordered_map>>>\\n horIdx;\\n for (long long j = (0); j < (m - 1); j++) {\\n long long x = 0, y = j, k = 0;\\n long long firstIndex = hor.size();\\n vector> path;\\n while (x < n && y < m) {\\n horIdx[x][y].push_back({firstIndex, path.size()});\\n path.push_back({x, y});\\n x += move[k].first;\\n y += move[k].second;\\n k = (k + 1) % 2;\\n }\\n hor.push_back(path);\\n }\\n vector> horBlocked(hor.size());\\n vector>> ver;\\n unordered_map>>>\\n verIdx;\\n for (long long i = (0); i < (n - 1); i++) {\\n long long x = i, y = 0, k = 1;\\n long long firstIndex = ver.size();\\n vector> path;\\n while (x < n && y < m) {\\n verIdx[x][y].push_back({firstIndex, path.size()});\\n path.push_back({x, y});\\n x += move[k].first;\\n y += move[k].second;\\n k = (k + 1) % 2;\\n }\\n ver.push_back(path);\\n }\\n vector> verBlocked(ver.size());\\n long long total = 0;\\n for (auto& a : hor) {\\n long long c = a.size();\\n total += c * (c + 1) \\/ 2;\\n }\\n for (auto& a : ver) {\\n long long c = a.size();\\n...\",\"language\":\"python\",\"split\":\"test\",\"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].\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"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\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Leonid wants to become a glass carver (the person who creates beautiful artworks by cutting the glass). He already has a rectangular w mm × h mm sheet of glass, a diamond glass cutter and lots of enthusiasm. What he lacks is understanding of what to carve and how.\\n\\nIn order not to waste time, he decided to practice the technique of carving. To do this, he makes vertical and horizontal cuts through the entire sheet. This process results in making smaller rectangular fragments of glass. Leonid does not move the newly made glass fragments. In particular, a cut divides each fragment of glass that it goes through into smaller fragments.\\n\\nAfter each cut Leonid tries to determine what area the largest of the currently available glass fragments has. Since there appear more and more fragments, this question takes him more and more time and distracts him from the fascinating process.\\n\\nLeonid offers to divide the labor — he will cut glass, and you will calculate the area of the maximum fragment after each cut. Do you agree?\\n\\nInput\\n\\nThe first line contains three integers w, h, n (2 ≤ w, h ≤ 200 000, 1 ≤ n ≤ 200 000).\\n\\nNext n lines contain the descriptions of the cuts. Each description has the form H y or V x. In the first case Leonid makes the horizontal cut at the distance y millimeters (1 ≤ y ≤ h - 1) from the lower edge of the original sheet of glass. In the second case Leonid makes a vertical cut at distance x (1 ≤ x ≤ w - 1) millimeters from the left edge of the original sheet of glass. It is guaranteed that Leonid won't make two identical cuts.\\n\\nOutput\\n\\nAfter each cut print on a single line the area of the maximum available glass fragment in mm2.\\n\\nExamples\\n\\nInput\\n\\n4 3 4\\nH 2\\nV 2\\nV 3\\nV 1\\n\\n\\nOutput\\n\\n8\\n4\\n4\\n2\\n\\n\\nInput\\n\\n7 6 5\\nH 4\\nV 3\\nV 5\\nH 2\\nV 1\\n\\n\\nOutput\\n\\n28\\n16\\n12\\n6\\n4\\n\\nNote\\n\\nPicture for the first sample test: \\n\\n Picture for the second sample test: \\\":\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n long w, h, n;\\n scanf(\\\"%ld %ld %ld\\\", &w, &h, &n);\\n getchar();\\n set V, H;\\n multiset Vd, Hd;\\n V.insert(0);\\n V.insert(h);\\n H.insert(0);\\n H.insert(w);\\n Vd.insert(h);\\n Hd.insert(w);\\n for (long t = 0; t < n; ++t) {\\n char c = getchar();\\n long pos;\\n scanf(\\\" %ld\\\", &pos);\\n getchar();\\n if (c == 'H') {\\n V.insert(pos);\\n auto p = V.find(pos);\\n auto l = p, r = p;\\n --l;\\n ++r;\\n Vd.insert(*p - *l);\\n Vd.insert(*r - *p);\\n Vd.erase(Vd.find(*r - *l));\\n } else {\\n H.insert(pos);\\n auto p = H.find(pos);\\n auto l = p, r = p;\\n --l;\\n ++r;\\n Hd.insert(*p - *l);\\n Hd.insert(*r - *p);\\n Hd.erase(Hd.find(*r - *l));\\n }\\n long long res = ((long long)(*Vd.rbegin())) * (*Hd.rbegin());\\n printf(\\\"%I64d\\\\n\\\", res);\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"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,...\",\"targets\":\"#include \\nint T, n, m;\\nbool vis[300005];\\nsigned main() {\\n int i, a, b, c;\\n scanf(\\\"%d\\\", &T);\\n while (T--) {\\n scanf(\\\"%d%d\\\", &n, &m);\\n for (i = 1; i <= m; ++i) scanf(\\\"%d%d%d\\\", &a, &b, &c), vis[b] = true;\\n for (i = 1; i <= n; ++i) {\\n if (vis[i]) continue;\\n b = i;\\n for (i = 1; i <= n; ++i)\\n if (i != b) printf(\\\"%d %d\\\\n\\\", i, b);\\n break;\\n }\\n for (i = 1; i <= n; ++i) vis[i] = false;\\n printf(\\\"\\\\n\\\");\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"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.\\nimpor\",\"targets\":\"t os\\nimport sys\\nfrom io import BytesIO, IOBase\\nBUFSIZE = 8192\\nclass FastIO(IOBase):\\n\\tnewlines = 0\\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\\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\\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\\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)\\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\\\")\\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\\ninput = lambda: sys.stdin.readline().rstrip(\\\"\\\\r\\\\n\\\")\\nfor _ in range(int(input())):\\n\\ta1,a2=map(str,input().split())\\n\\tb1,b2=map(str,input().split())\\n\\tx=len(a1)+int(a2)\\n\\ty=len(b1)+int(b2)\\n\\tif x>y:\\n\\t\\tprint(\\\">\\\")\\n\\telif x=len(a1):\\n\\t\\t\\t\\tcurr_a=0\\n\\t\\t\\telse:\\n\\t\\t\\t\\tcurr_a=int(a1[i])\\n\\t\\t\\tif i>=len(b1):\\n\\t\\t\\t\\tcurr_b=0\\n\\t\\t\\telse:\\n\\t\\t\\t\\tcurr_b=int(b1[i])\\n\\t\\t\\tif curr_acurr_b:\\n\\t\\t\\t\\tver=True\\n\\t\\t\\t\\tbreak\\n\\t\\tif ver:\\n\\t\\t\\tif greater:\\n\\t\\t\\t\\tprint(\\\">\\\")\\n\\t\\t\\telse:\\n\\t\\t\\t\\tprint(\\\"<\\\")\\n\\t\\telse:\\n\\t\\t\\tprint(\\\"=\\\")\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nYou 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.\",\"targets\":\"#include \\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 ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"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\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.util.*;\\nimport java.lang.*;\\nimport java.io.*;\\n\\npublic class main {\\n\\tpublic static void main(String[] args) throws Exception {\\n\\t\\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\\n\\t\\tint t = Integer.parseInt(br.readLine());\\n\\t\\t\\n\\t\\tfor(int i=0;i\\nusing namespace std;\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n int n, i, flag = 0;\\n cin >> n;\\n int arr[n + 1];\\n for (i = 1; i <= n; i++) {\\n cin >> arr[i];\\n }\\n int k = 0;\\n while (flag == 0) {\\n for (i = 1; i <= n; i++) {\\n if (arr[i] - k <= 0) {\\n flag = i;\\n break;\\n }\\n k++;\\n }\\n }\\n cout << flag << '\\\\n';\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"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\\n\\nimpo\",\"targets\":\"rt java.util.HashMap;\\nimport java.util.Map;\\nimport java.util.Scanner;\\n\\npublic class ProblemA {\\n\\tpublic static void main(String [] args) {\\n\\t\\t\\t\\n\\t\\tScanner scanner = new Scanner(System.in);\\n\\t\\t\\n\\t\\tint tests = scanner.nextInt();\\n\\t\\t\\n\\t\\tfor(int t = 0; t < tests; t++) {\\n\\t\\t\\t\\n\\t\\t\\tMap map = new HashMap();\\n\\t\\t\\t\\n\\t\\t\\tString s = scanner.next();\\n\\t\\t\\tString ta = scanner.next();\\n\\t\\t\\t\\n\\t\\t\\tfor(int i = 0; i < s.length(); i++) {\\n\\t\\t\\t\\tmap.put(s.charAt(i), i+1);\\n\\t\\t\\t}\\n\\t\\t\\t\\n\\t\\t\\tint sum = 0;\\n\\t\\t\\t\\n\\t\\t\\tif(ta.length() < 2) {\\n\\t\\t\\t\\tSystem.out.println(sum);\\n\\t\\t\\t}else {\\n\\t\\t\\t\\tfor(int i = 1; i < ta.length(); i++) {\\n\\t\\t\\t\\t\\tif(ta.charAt(i) != ta.charAt(i - 1) ) {\\n\\t\\t\\t\\t\\t\\tsum+= Math.abs( map.get(ta.charAt(i)) - map.get(ta.charAt(i - 1)) );\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tSystem.out.println(sum);\\n\\t\\t\\t}\\n\\t\\t\\t\\n\\t\\t\\t\\n\\t\\t}\\n\\t\\t\\n\\t\\tscanner.close();\\n\\t}\\n\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"You are given a tree consisting of n vertices. Recall that a tree is an undirected connected acyclic graph. The given tree is rooted at the vertex 1.\\n\\nYou have to process q queries. In each query, you are given a vertex of the tree v and an integer k.\\n\\nTo process a query, you may delete any vertices from the tree in any order, except for the root and the vertex v. When a vertex is deleted, its children become the children of its parent. You have to process a query in such a way that maximizes the value of c(v) - m ⋅ k (where c(v) is the resulting number of children of the vertex v, and m is the number of vertices you have deleted). Print the maximum possible value you can obtain.\\n\\nThe queries are independent: the changes you make to the tree while processing a query don't affect the tree in other queries.\\n\\nInput\\n\\nThe first line contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of vertices in the tree.\\n\\nThen n-1 lines follow, the i-th of them contains two integers x_i and y_i (1 ≤ x_i, y_i ≤ n; x_i ≠ y_i) — the endpoints of the i-th edge. These edges form a tree.\\n\\nThe next line contains one integer q (1 ≤ q ≤ 2 ⋅ 10^5) — the number of queries.\\n\\nThen q lines follow, the j-th of them contains two integers v_j and k_j (1 ≤ v_j ≤ n; 0 ≤ k_j ≤ 2 ⋅ 10^5) — the parameters of the j-th query.\\n\\nOutput\\n\\nFor each query, print one integer — the maximum value of c(v) - m ⋅ k you can achieve.\\n\\nExample\\n\\nInput\\n\\n\\n8\\n6 7\\n3 2\\n8 3\\n5 7\\n7 4\\n7 1\\n7 3\\n6\\n1 0\\n1 2\\n1 3\\n7 1\\n5 0\\n7 200000\\n\\n\\nOutput\\n\\n\\n5\\n2\\n1\\n4\\n0\\n4\\n\\nNote\\n\\nThe tree in the first example is shown in the following picture:\\n\\n\\n\\nAnswers to the queries are obtained as follows:\\n\\n 1. v=1,k=0: you can delete vertices 7 and 3, so the vertex 1 has 5 children (vertices 2, 4, 5, 6, and 8), and the score is 5 - 2 ⋅ 0 = 5; \\n 2. v=1,k=2: you can delete the vertex 7, so the vertex 1 has 4 children (vertices 3, 4, 5, and 6), and the score is 4 - 1 ⋅ 2 = 2. \\n 3. v=1,k=3: you shouldn't delete any vertices, so the vertex 1 has only one child (vertex 7), and the score is 1 - 0 ⋅ 3 = 1; \\n ...\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 2e5 + 10;\\nint n, m;\\nvector V[N];\\nint fa[N], siz[N], er[N];\\nint son[N];\\nint ans[N];\\nvector > q[N];\\nvoid dfs1(int x) {\\n siz[x] = 1;\\n er[x] = 0;\\n for (int i = 0; i < V[x].size(); ++i) {\\n if (V[x][i] != fa[x]) {\\n fa[V[x][i]] = x;\\n dfs1(V[x][i]);\\n siz[x] += siz[V[x][i]];\\n ++er[x];\\n }\\n }\\n return;\\n}\\nint lim[N];\\nint F[23][N], cha[23][N];\\nvoid dfs2(int x, int cs) {\\n int y;\\n son[x] = 0;\\n for (int i = 0; i < V[x].size(); ++i) {\\n y = V[x][i];\\n if (y == fa[x]) continue;\\n if (siz[y] > siz[son[x]]) {\\n son[x] = y;\\n }\\n }\\n if (!son[x]) {\\n lim[x] = 0;\\n F[cs][0] = 1;\\n for (int i = 0; i < q[x].size(); ++i) {\\n ans[q[x][i].second] = 0;\\n }\\n return;\\n }\\n dfs2(son[x], cs);\\n int L = lim[son[x]];\\n cha[cs][lim[son[x]] + 1]++;\\n for (int i = 0; i < V[x].size(); ++i) {\\n y = V[x][i];\\n if (y == fa[x] || y == son[x]) continue;\\n dfs2(y, cs + 1);\\n while (L < lim[y]) {\\n ++L;\\n F[cs][L] = 0;\\n }\\n for (int j = 0; j <= lim[y]; ++j) {\\n F[cs][j] += F[cs + 1][j];\\n }\\n cha[cs][lim[y] + 1]++;\\n }\\n int hhh = 0;\\n for (int j = 0; j <= L; ++j) {\\n hhh += cha[cs][j];\\n F[cs][j] += hhh;\\n }\\n for (int i = 0; i < q[x].size(); ++i) {\\n if (q[x][i].first > L) {\\n ans[q[x][i].second] = er[x];\\n } else {\\n ans[q[x][i].second] = F[cs][q[x][i].first];\\n }\\n }\\n if (er[x] > L) {\\n lim[x] = er[x];\\n for (int j = L + 1; j <= er[x]; ++j) {\\n F[cs][j] = er[x];\\n }\\n } else {\\n lim[x] = L;\\n }\\n while (lim[x] > 0 && F[cs][lim[x]] - lim[x] < 1) {\\n lim[x]--;\\n }\\n for (int j = 0; j <= lim[x]; ++j) {\\n F[cs][j] -= j;\\n if (F[cs][j] < 1) F[cs][j] = 1;\\n }\\n cha[cs][lim[son[x]] + 1]--;\\n for (int i = 0; i < V[x].size(); ++i) {\\n y = V[x][i];\\n if (y == fa[x] || y == son[x]) continue;\\n cha[cs][lim[y] + 1]--;\\n }\\n return;\\n}\\nint main() {\\n int u, v;\\n scanf(\\\"%d\\\", &n);\\n for (int i = 1; i < n; ++i) {\\n scanf(\\\"%d%d\\\", &u, &v);\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"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. \\nSolve the task in JAVA.\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.util.*;\\n\\npublic class Main\\n{\\n private static String line;\\n private static int indexLine;\\n\\n public static void readLine(BufferedReader reader) throws IOException\\n {\\n line = reader.readLine();\\n indexLine = 0;\\n }\\n\\n public static int readInt()\\n {\\n int x = 0;\\n\\n while (indexLine < line.length() && line.charAt(indexLine) >= '0' && line.charAt(indexLine) <= '9') {\\n\\n x = x * 10 + line.charAt(indexLine) - 48;\\n\\n indexLine++;\\n }\\n\\n indexLine++;\\n\\n return x;\\n }\\n\\n public static long readLong()\\n {\\n long x = 0;\\n\\n while (indexLine < line.length() && line.charAt(indexLine) >= '0' && line.charAt(indexLine) <= '9') {\\n\\n x = x * 10 + line.charAt(indexLine) - 48;\\n\\n indexLine++;\\n }\\n\\n return x;\\n }\\n\\n private static final int mod = (int)(1e6 + 3);\\n\\n public static void main(String[] args) throws IOException\\n {\\n new Main();\\n }\\n\\n public int compute(int[] div, int x)\\n {\\n return x - div[x] + 1;\\n }\\n\\n public Main() throws IOException\\n {\\n Scanner in = new Scanner(System.in);\\n\\n int n = in.nextInt();\\n\\n int[] div = new int[n + 1];\\n\\n for (int i = 2; i <= n; i++)\\n if (div[i] == 0) {\\n\\n for (int j = i + i; j <= n; j += i)\\n div[j] = Math.max(div[j], i);\\n\\n div[i] = 1;\\n\\n }\\n\\n int sol = (int)2e9;\\n\\n for (int i = n - div[n] + 1; i <= n; i++)\\n sol = Math.min(sol, compute(div, i));\\n\\n System.out.println(sol);\\n }\\n\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nMr. Kitayuta has kindly given you a string s consisting of lowercase English letters. You are asked to insert exactly n lowercase English letters into s to make it a palindrome. (A palindrome is a string that reads the same forward and backward. For example, \\\"noon\\\", \\\"testset\\\" and \\\"a\\\" are all palindromes, while \\\"test\\\" and \\\"kitayuta\\\" are not.) You can choose any n lowercase English letters, and insert each of them to any position of s, possibly to the beginning or the end of s. You have to insert exactly n letters even if it is possible to turn s into a palindrome by inserting less than n letters.\\n\\nFind the number of the palindromes that can be obtained in this way, modulo 10007.\\n\\nInput\\n\\nThe first line contains a string s (1 ≤ |s| ≤ 200). Each character in s is a lowercase English letter.\\n\\nThe second line contains an integer n (1 ≤ n ≤ 109).\\n\\nOutput\\n\\nPrint the number of the palindromes that can be obtained, modulo 10007.\\n\\nExamples\\n\\nInput\\n\\nrevive\\n1\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\nadd\\n2\\n\\n\\nOutput\\n\\n28\\n\\nNote\\n\\nFor the first sample, you can obtain the palindrome \\\"reviver\\\" by inserting 'r' to the end of \\\"revive\\\".\\n\\nFor the second sample, the following 28 palindromes can be obtained: \\\"adada\\\", \\\"adbda\\\", ..., \\\"adzda\\\", \\\"dadad\\\" and \\\"ddadd\\\".\",\"targets\":\"#include \\nconst int MN = 400 + 5, P = 10007;\\nusing namespace std;\\ntemplate \\ninline T& IN(T& in) {\\n in = 0;\\n char c = getchar();\\n int f = 1;\\n while (!isdigit(c)) {\\n if (c == '-') f = -1;\\n c = getchar();\\n }\\n while (isdigit(c)) in = in * 10 + c - '0', c = getchar();\\n return in *= f;\\n}\\nint n, m, N, ans;\\nchar c[MN];\\nint f[210][210][210];\\nstruct mat {\\n int a[MN][MN];\\n mat() { memset(a, 0, sizeof a); }\\n} sum, res, tmp;\\nvoid mul(mat& ans, const mat x, const mat y) {\\n for (int i = 1; i <= N; i++)\\n for (int j = i; j <= N; j++) {\\n int tmp = 0;\\n for (int k = i; k <= j; k++) tmp = (tmp + x.a[i][k] * y.a[k][j]) % P;\\n ans.a[i][j] = tmp;\\n }\\n}\\nvoid qp(int b) {\\n while (b) {\\n if (b & 1) mul(res, res, sum);\\n mul(sum, sum, sum);\\n b >>= 1;\\n }\\n}\\nint calc(int l, int r, int x) {\\n int& u = f[x][l][r];\\n if (u != -1) return u;\\n u = 0;\\n if (l == r) return u = x == 0;\\n if (c[l] == c[r]) {\\n if (l + 1 == r) return u = x == 0;\\n return u = calc(l + 1, r - 1, x);\\n }\\n if (x > 0) return u = (calc(l + 1, r, x - 1) + calc(l, r - 1, x - 1)) % P;\\n return u;\\n}\\nvoid input() {\\n memset(f, -1, sizeof f);\\n scanf(\\\"%s\\\", c + 1);\\n IN(n);\\n m = strlen(c + 1);\\n n += m;\\n int a = m - 1, b = (m + 1) \\/ 2, c = b, l = n + 1 >> 1;\\n N = a + b + c;\\n for (int i = 1; i <= a; ++i) sum.a[i][i] = 24, sum.a[i][i + 1] = 1;\\n for (int i = a + 1; i <= a + b; ++i) sum.a[i][i] = 25, sum.a[i][i + b] = 1;\\n for (int i = a + 1; i < a + b; ++i) sum.a[i][i + 1] = 1;\\n for (int i = a + b + 1; i <= a + b + c; ++i) sum.a[i][i] = 26;\\n for (int i = 1; i <= a + b + c; ++i) res.a[i][i] = 1;\\n tmp = sum, qp(l - 1);\\n mul(tmp, res, tmp);\\n for (int i = 0, l = n + 1 >> 1; i <= a; ++i) {\\n int j = (m - i + 1) \\/ 2, k = l - i - j;\\n if (k < 0) continue;\\n int sum = calc(1, m, i);\\n ans = (ans + sum * tmp.a[a - i + 1][a + j + b] % P) % P;\\n if ((n & 1) && (m - i & 1 ^ 1))\\n ans = (ans - sum * res.a[a - i + 1][a + j] % P + P) % P;\\n }\\n printf(\\\"%d\\\\n\\\", ans);\\n}\\nint main() {\\n input();\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Every day Ruslan tried to count sheep to fall asleep, but this didn't help. Now he has found a more interesting thing to do. First, he thinks of some set of circles on a plane, and then tries to choose a beautiful set of points, such that there is at least one point from the set inside or on the border of each of the imagined circles.\\n\\nYesterday Ruslan tried to solve this problem for the case when the set of points is considered beautiful if it is given as (xt = f(t), yt = g(t)), where argument t takes all integer values from 0 to 50. Moreover, f(t) and g(t) should be correct functions.\\n\\nAssume that w(t) and h(t) are some correct functions, and c is an integer ranging from 0 to 50. The function s(t) is correct if it's obtained by one of the following rules: \\n\\n 1. s(t) = abs(w(t)), where abs(x) means taking the absolute value of a number x, i.e. |x|;\\n 2. s(t) = (w(t) + h(t));\\n 3. s(t) = (w(t) - h(t));\\n 4. s(t) = (w(t) * h(t)), where * means multiplication, i.e. (w(t)·h(t));\\n 5. s(t) = c;\\n 6. s(t) = t;\\n\\n\\n\\nYesterday Ruslan thought on and on, but he could not cope with the task. Now he asks you to write a program that computes the appropriate f(t) and g(t) for any set of at most 50 circles.\\n\\nIn each of the functions f(t) and g(t) you are allowed to use no more than 50 multiplications. The length of any function should not exceed 100·n characters. The function should not contain spaces.\\n\\nRuslan can't keep big numbers in his memory, so you should choose f(t) and g(t), such that for all integer t from 0 to 50 value of f(t) and g(t) and all the intermediate calculations won't exceed 109 by their absolute value.\\n\\nInput\\n\\nThe first line of the input contains number n (1 ≤ n ≤ 50) — the number of circles Ruslan thinks of. Next follow n lines, each of them containing three integers xi, yi and ri (0 ≤ xi, yi ≤ 50, 2 ≤ ri ≤ 50) — the coordinates of the center and the raduis of the i-th circle.\\n\\nOutput\\n\\nIn the first line print a correct function f(t). In the second line print a correct function g(t). The set of the...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint x[77], y[77], r[77];\\nint main() {\\n int n;\\n scanf(\\\"%d\\\", &n);\\n for (int i = 1; i <= n; i++) scanf(\\\"%d%d%d\\\", x + i, y + i, r + i);\\n for (int i = 1; i < n; i++) printf(\\\"(\\\");\\n for (int i = 1; i <= n; i++) {\\n if (i > 1) printf(\\\"+\\\");\\n printf(\\\"(%d*((1-abs((t-%d)))+abs((abs((t-%d))-1))))\\\", x[i] \\/ 2, i, i);\\n if (i > 1) printf(\\\")\\\");\\n }\\n puts(\\\"\\\");\\n for (int i = 1; i < n; i++) printf(\\\"(\\\");\\n for (int i = 1; i <= n; i++) {\\n if (i > 1) printf(\\\"+\\\");\\n printf(\\\"(%d*((1-abs((t-%d)))+abs((abs((t-%d))-1))))\\\", y[i] \\/ 2, i, i);\\n if (i > 1) printf(\\\")\\\");\\n }\\n puts(\\\"\\\");\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"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...\\n\\/\\/ Do\",\"targets\":\"n't place your source in a package\\n\\n\\nimport javax.swing.*;\\nimport java.lang.reflect.Array;\\nimport java.text.DecimalFormat;\\nimport java.util.*;\\nimport java.lang.*;\\nimport java.io.*;\\nimport java.math.*;\\nimport java.util.stream.Stream;\\n\\n\\n\\n\\/\\/ Please name your class Main\\npublic class Main {\\n static FastScanner fs=new FastScanner();\\n static class FastScanner {\\n BufferedReader br=new BufferedReader(new InputStreamReader(System.in));\\n StringTokenizer st=new StringTokenizer(\\\"\\\");\\n public String next() {\\n while (!st.hasMoreElements())\\n try {\\n st=new StringTokenizer(br.readLine());\\n } catch (IOException e) {\\n e.printStackTrace();\\n }\\n return st.nextToken();\\n }\\n int Int() {\\n return Integer.parseInt(next());\\n }\\n\\n long Long() {\\n return Long.parseLong(next());\\n }\\n\\n String Str(){\\n return next();\\n }\\n }\\n\\n\\n public static void main (String[] args) throws java.lang.Exception {\\n PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));\\n \\/\\/reading \\/writing file\\n \\/\\/Scanner sc=new Scanner(new File(\\\"input.txt\\\"));\\n \\/\\/PrintWriter pr=new PrintWriter(\\\"output.txt\\\");\\n\\n\\n int T=Int();\\n for(int t=0;t\\n#pragma GCC optimize(\\\"Ofast\\\")\\nusing namespace std;\\nvoid debug() { cerr << \\\"\\\\n\\\"; }\\ntemplate \\nvoid debug(H h, T... t) {\\n cerr << h;\\n if (sizeof...(t)) cerr << \\\", \\\";\\n debug(t...);\\n}\\nmt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());\\nconst int N = 1e5 + 5, K = 18, mod = 998244353, INF = 1e9 + 5;\\nlong long dp[K][N];\\nint sito[N], phi[N];\\nlong long sum[N];\\nlong long Cost(int l, int r) {\\n long long ans = 0;\\n while (r >= l * 1ll * l) {\\n ans += sum[r \\/ l];\\n l++;\\n }\\n int k = r \\/ l;\\n for (; k >= 1; k--) {\\n int m = r \\/ k;\\n ans += (m - l + 1) * sum[k];\\n l = m + 1;\\n }\\n return ans;\\n}\\nint n;\\nlong long cost2(int l, int r) { return Cost(n + 1 - r, n + 1 - l); }\\nvoid prop(int l, int r, int a, int b, int k) {\\n int m = (l + r) \\/ 2, skad = m;\\n dp[k][m] = dp[k - 1][m];\\n long long C = Cost(a, m);\\n for (int i = a; i <= b && i < m; i++) {\\n C -= sum[m \\/ i];\\n if (dp[k - 1][i] + C < dp[k][m]) {\\n skad = i;\\n dp[k][m] = dp[k - 1][i] + C;\\n }\\n }\\n if (m > l) prop(l, m - 1, a, skad, k);\\n if (m < r) prop(m + 1, r, skad, b, k);\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n ;\\n sum[1] = 1;\\n for (int i = 2; i < N; i++) {\\n if (sito[i] == 0) {\\n for (int j = 1; j * i < N; j++) {\\n sito[j * i] = i;\\n }\\n }\\n phi[i] = 1;\\n int k = i;\\n while (k > 1) {\\n int p = sito[k];\\n phi[i] *= p - 1;\\n k \\/= p;\\n while (k % p == 0) {\\n k \\/= p;\\n phi[i] *= p;\\n }\\n }\\n sum[i] = sum[i - 1] + phi[i];\\n }\\n for (int i = 1; i < N; i++) {\\n dp[0][i] = Cost(1, i);\\n }\\n for (int i = 1; i < K; i++) {\\n prop(1, N - 1, 1, N - 1, i);\\n }\\n int t;\\n cin >> t;\\n while (t--) {\\n int k;\\n cin >> n >> k;\\n if (k >= K || (1 << k) > n)\\n cout << n << \\\"\\\\n\\\";\\n else {\\n cout << dp[k - 1][n] << \\\"\\\\n\\\";\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Autumn came late to the kingdom of Far Far Away. The harvest was exuberant and it is now time to get ready for the winter. As most people celebrate the Harvest festival, Simon the Caretaker tries to solve a very non-trivial task of how to find place for the agricultural equipment in the warehouse.\\n\\nHe's got problems with some particularly large piece of equipment, which is, of course, turboplows. The problem is that when a turboplow is stored, it takes up not some simply rectangular space. It takes up a T-shaped space like on one of the four pictures below (here character \\\"#\\\" stands for the space occupied by the turboplow and character \\\".\\\" stands for the free space):\\n \\n \\n ### ..# .#. #.. \\n .#. ### .#. ### \\n .#. ..# ### #.. \\n \\n\\nSimon faced a quite natural challenge: placing in the given n × m cells warehouse the maximum number of turboplows. As one stores the turboplows, he can rotate them in any manner (so that they take up the space like on one of the four pictures above). However, two turboplows cannot \\\"overlap\\\", that is, they cannot share the same cell in the warehouse.\\n\\nSimon feels that he alone cannot find the optimal way of positioning the plugs in the warehouse that would maximize their quantity. Can you help him?\\n\\nInput\\n\\nThe only line contains two space-separated integers n and m — the sizes of the warehouse (1 ≤ n, m ≤ 9).\\n\\nOutput\\n\\nIn the first line print the maximum number of turboplows that can be positioned in the warehouse. In each of the next n lines print m characters. Use \\\".\\\" (dot) to mark empty space and use successive capital Latin letters (\\\"A\\\" for the first turboplow, \\\"B\\\" for the second one and so on until you reach the number of turboplows in your scheme) to mark place for the corresponding turboplows considering that they are positioned in the optimal manner in the warehouse. The order in which you number places for the turboplows does not matter. If there are several optimal solutions for a warehouse of the given size,...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nint getint() {\\n unsigned int c;\\n int x = 0;\\n while (((c = getchar()) - '0') >= 10) {\\n if (c == '-') return -getint();\\n if (!~c) exit(0);\\n }\\n do {\\n x = (x << 3) + (x << 1) + (c - '0');\\n } while (((c = getchar()) - '0') < 10);\\n return x;\\n}\\nchar a1[] = \\\"### ..# .#. #..\\\";\\nchar a2[] = \\\".#. ### .#. ###\\\";\\nchar a3[] = \\\".#. ..# ### #..\\\";\\nvector px[4], py[4];\\nint n, m, grid[10][10], mx, res[10][10];\\nvoid solve(int x, int y, int curr) {\\n if (y >= m) {\\n solve(x + 1, 0, curr);\\n return;\\n }\\n if (x >= n) {\\n if (curr > mx) mx = curr, memcpy(res, grid, sizeof(res));\\n return;\\n }\\n int i, j, k, d, tmp[10][10], nx, ny;\\n int mxPossible = 0;\\n for (i = y; i < m; i++)\\n if (grid[x][i] == 0) mxPossible++;\\n for (i = x; i < n; i++)\\n for (j = 0; j < m; j++)\\n if (grid[i][j] == 0) mxPossible++;\\n mxPossible \\/= 5;\\n if (mxPossible + curr <= mx) return;\\n memcpy(tmp, grid, sizeof(tmp));\\n for (d = 0; d < 4; d++) {\\n bool canPlace = 1;\\n memcpy(grid, tmp, sizeof(tmp));\\n for (i = 0; i < px[d].size(); i++) {\\n nx = x + px[d][i];\\n ny = y + py[d][i];\\n if (nx >= n or ny >= m or grid[nx][ny]) {\\n canPlace = 0;\\n break;\\n }\\n grid[nx][ny] = curr + 1;\\n }\\n if (canPlace) {\\n solve(x, y + 1, curr + 1);\\n }\\n }\\n memcpy(grid, tmp, sizeof(tmp));\\n solve(x, y + 1, curr);\\n}\\nint main() {\\n int i, j, tcc, tc = 1 << 28;\\n for (i = 0; i < 4; i++) {\\n for (j = 0; j < 3; j++)\\n if (a1[i * 4 + j] == '#') px[i].push_back(0), py[i].push_back(j);\\n for (j = 0; j < 3; j++)\\n if (a2[i * 4 + j] == '#') px[i].push_back(1), py[i].push_back(j);\\n for (j = 0; j < 3; j++)\\n if (a3[i * 4 + j] == '#') px[i].push_back(2), py[i].push_back(j);\\n }\\n for (tcc = 0; tcc < tc; tcc++) {\\n n = getint(), m = getint(), mx = 0;\\n if (n == 9 and m == 9) {\\n puts(\\\"13\\\");\\n puts(\\n \\\"AAA.BCCC.\\\\n.ABBB.CD.\\\\n.AE.BFCD.\\\\nEEEFFFDDD\\\\nG.E.HFIII\\\\nGGGJHHHI.\\\"\\n \\\"\\\\nGK.JHL.IM\\\\n.KJJJLMMM\\\\nKKK.LLL.M\\\\n\\\");\\n continue;\\n ...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"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...\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStream;\\nimport java.io.InputStreamReader;\\nimport java.io.OutputStream;\\nimport java.io.PrintWriter;\\nimport java.util.StringTokenizer;\\n\\npublic class Main {\\n\\t\\n\\tstatic long totalCost = 0;\\n\\tstatic int[] size;\\n\\tstatic int[] level;\\n\\tstatic int[][] biDist;\\n\\t\\n\\tpublic static void main(String[] args) {\\n\\t\\tInputStream inputStream = System.in;\\n OutputStream outputStream = System.out;\\n InputReader in = new InputReader(inputStream);\\n PrintWriter out = new PrintWriter(outputStream);\\n solve(in, out);\\n out.close();\\n\\t}\\n\\t\\n\\tprivate static void solve(InputReader in, PrintWriter out) {\\n\\t\\tint t = in.nextInt();\\n\\t\\twhile (t-- > 0) {\\n\\t\\t\\tint n = in.nextInt();\\n\\t\\t\\tboolean isRe = false;\\n\\t\\t\\tint last = Integer.MIN_VALUE;\\n\\t\\t\\tfor (int i = 0; i < n; i++) {\\n\\t\\t\\t\\tint num = in.nextInt();\\n\\t\\t\\t\\tif (num <= last) {\\n\\t\\t\\t\\t\\tisRe = true;\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tlast = num;\\n\\t\\t\\t}\\n\\t\\t\\tout.println(isRe || n % 2 == 0 ? \\\"YES\\\" : \\\"NO\\\");\\n\\t\\t}\\n\\t\\t\\n\\t}\\t\\n\\n\\tstatic class InputReader {\\n public BufferedReader reader;\\n public StringTokenizer tokenizer;\\n \\n public InputReader(InputStream stream) {\\n reader = new BufferedReader(new InputStreamReader(stream), 32768);\\n tokenizer = null;\\n }\\n \\n public String next() {\\n while (tokenizer == null || !tokenizer.hasMoreTokens()) {\\n try {\\n tokenizer = new StringTokenizer(reader.readLine());\\n } catch (IOException e) {\\n throw new RuntimeException(e);\\n }\\n }\\n return tokenizer.nextToken();\\n }\\n \\n public int nextInt() {\\n return Integer.parseInt(next());\\n }\\n \\n public long nextLong() {\\n return Long.parseLong(next());\\n }\\n \\n }\\n\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"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.\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int t;\\n cin >> t;\\n while (t--) {\\n long long int x;\\n cin >> x;\\n if (x - x \\/ 10 * 10 == 9)\\n cout << x \\/ 10 + 1 << endl;\\n else\\n cout << x \\/ 10 << endl;\\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?\\nA bracket sequence is a string that is one of the following:\\n\\n1. An empty string;\\n2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ;\\n3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B \\/\\n\\n\\n\\nGiven are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?\\n\\nConstraints\\n\\n* 1 \\\\leq N \\\\leq 10^6\\n* The total length of the strings S_i is at most 10^6.\\n* S_i is a non-empty string consisting of `(` and `)`.\\n\\nInput\\n\\nInput is given from Standard Input in the following format:\\n\\n\\nN\\nS_1\\n:\\nS_N\\n\\n\\nOutput\\n\\nIf a bracket sequence can be formed by concatenating all the N strings in some order, print `Yes`; otherwise, print `No`.\\n\\nExamples\\n\\nInput\\n\\n2\\n)\\n(()\\n\\n\\nOutput\\n\\nYes\\n\\n\\nInput\\n\\n2\\n)(\\n()\\n\\n\\nOutput\\n\\nNo\\n\\n\\nInput\\n\\n4\\n((()))\\n((((((\\n))))))\\n()()()\\n\\n\\nOutput\\n\\nYes\\n\\n\\nInput\\n\\n3\\n(((\\n)\\n)\\n\\n\\nOutput\\n\\nNo\",\"targets\":\"#include \\nusing namespace std;\\n#define rep(i, n) for (int i = 0; i < (int)(n); i++)\\ntypedef long long ll;\\ntypedef pairP;\\n\\nint main(){\\n ll N;\\n cin>>N;\\n vector

Sup;\\n vector

Sdown;\\n rep(i,N){\\n \\tstring s;\\n \\tcin>>s;\\n ll total=0,mini=0;\\n rep(j,s.size()){\\n if(s[j]=='('){total++;}\\n else{total--;}\\n mini=min(mini,total);\\n }\\n if(total>=0){Sup.push_back(P(mini,total));}\\n else{Sdown.push_back(P(mini-total,-total));}\\n }\\n sort(Sup.begin(),Sup.end());\\n reverse(Sup.begin(),Sup.end());\\n \\n sort(Sdown.begin(),Sdown.end());\\n reverse(Sdown.begin(),Sdown.end());\\n \\n int flag=0;\\n ll sum1=0;\\n ll sum2=0;\\n rep(i,Sup.size()){\\n \\tif(Sup[i].first<0&&sum1+Sup[i].first<0){flag=1;}\\n \\telse{sum1+=Sup[i].second;}\\n if(sum1<0){flag=1;}\\n }\\n rep(i,Sdown.size()){\\n \\tif(Sdown[i].first<0&&sum2+Sdown[i].first<0){flag=1;}\\n \\telse{sum2+=Sdown[i].second;}\\n if(sum2<0){flag=1;}\\n }\\n if(sum1!=sum2){flag=1;}\\n if(flag==1){cout<<\\\"No\\\";}\\n if(flag==0){cout<<\\\"Yes\\\";}\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"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\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst long long Mod = 998244353;\\nint n, m, k;\\nint cnt[2][1000100][2];\\nmap, bool> mp;\\nint cntno[2], cntyes[2];\\nlong long pow2[1000100];\\nint cntcorner[2];\\nvoid add(int tp, int x, int pos, int val) {\\n cnt[tp][x][pos] += val;\\n if ((val > 0 && cnt[tp][x][pos] == 1) || (val < 0 && cnt[tp][x][pos] == 0)) {\\n if (cnt[tp][x][pos ^ 1] == 0)\\n cntyes[tp] -= val;\\n else\\n cntno[tp] += val;\\n }\\n}\\nint main() {\\n pow2[0] = 1;\\n for (int i = 1; i <= 1000000; i++) pow2[i] = pow2[i - 1] * 2LL % Mod;\\n ios::sync_with_stdio(false);\\n cin >> n >> m >> k;\\n cntyes[0] = m, cntyes[1] = n;\\n for (int i = 0; i < k; i++) {\\n int x, y, tp;\\n cin >> x >> y >> tp;\\n x--, y--;\\n pair p = make_pair(x, y);\\n if (tp < 0) {\\n if (mp.count(p)) {\\n add(0, y, (mp[p] ^ x) & 1, -1);\\n add(1, x, (mp[p] ^ y) & 1, -1);\\n cntcorner[(x ^ y ^ mp[p]) & 1]--;\\n mp.erase(p);\\n }\\n } else {\\n if (mp.count(p)) {\\n add(0, y, (mp[p] ^ x) & 1, -1);\\n add(1, x, (mp[p] ^ y) & 1, -1);\\n cntcorner[(x ^ y ^ mp[p]) & 1]--;\\n }\\n mp[p] = tp;\\n add(0, y, (mp[p] ^ x) & 1, 1);\\n add(1, x, (mp[p] ^ y) & 1, 1);\\n cntcorner[(x ^ y ^ mp[p]) & 1]++;\\n }\\n long long ans = 0;\\n if (!cntno[0]) ans = (ans + pow2[cntyes[0]]) % Mod;\\n if (!cntno[1]) ans = (ans + pow2[cntyes[1]]) % Mod;\\n ans = (ans + Mod - !cntcorner[0] - !cntcorner[1]) % Mod;\\n cout << ans << endl;\\n }\\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 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\\nThe above is tricky. Write me a correct solution in CPP.\",\"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\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"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...\\nSolve the task in PYTHON3.\",\"targets\":\"# region fastio\\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# endregion\\n\\n\\ndef intArr():\\n return map(int, input().split())\\n\\n\\ndef In():\\n return int(input())\\n\\n\\ndef func():\\n a,b=intArr()\\n ans=set()\\n n=a+b\\n serve_2=n\\/\\/2\\n serve_1=n-serve_2\\n for i in range(serve_1+1):\\n\\n if 0<=a+i-serve_1<=serve_2:\\n ans.add(2*i+a-serve_1)\\n \\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"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}\\nusing namespace std;\\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(long double t) { cerr << t; }\\nvoid _print(double t) { cerr << t; }\\nvoid _print(unsigned long long 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.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 \\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}\\nbool revsort(long long a, long long b) { return a > b; }\\nconst int N = 2e5 + 5;\\nvoid solve() {\\n int n;\\n cin >> n;\\n vector> a(n, vector(5));\\n for (int i = 0; i < n; ++i) {\\n for (int j = 0; j < 5; j++) {\\n int x;\\n cin >> x;\\n a[i][j] = x;\\n }\\n }\\n int max = 0;\\n for (int i = 1; i < n; ++i) {\\n int cnt = 0;\\n for (int j = 0; j < 5; j++) {\\n if (a[i][j] < a[max][j]) cnt++;\\n }\\n if (cnt >= 3) max = i;\\n }\\n int i;\\n int res = -1;\\n for (i = 0; i < n; ++i) {\\n int cnt = 0;\\n if (i != max) {\\n for (int j = 0; j < 5; j++) {\\n if (a[i][j] < a[max][j])...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Devu and his brother love each other a lot. As they are super geeks, they only like to play with arrays. They are given two arrays a and b by their father. The array a is given to Devu and b to his brother. \\n\\nAs Devu is really a naughty kid, he wants the minimum value of his array a should be at least as much as the maximum value of his brother's array b. \\n\\nNow you have to help Devu in achieving this condition. You can perform multiple operations on the arrays. In a single operation, you are allowed to decrease or increase any element of any of the arrays by 1. Note that you are allowed to apply the operation on any index of the array multiple times.\\n\\nYou need to find minimum number of operations required to satisfy Devu's condition so that the brothers can play peacefully without fighting. \\n\\nInput\\n\\nThe first line contains two space-separated integers n, m (1 ≤ n, m ≤ 105). The second line will contain n space-separated integers representing content of the array a (1 ≤ ai ≤ 109). The third line will contain m space-separated integers representing content of the array b (1 ≤ bi ≤ 109).\\n\\nOutput\\n\\nYou need to output a single integer representing the minimum number of operations needed to satisfy Devu's condition.\\n\\nExamples\\n\\nInput\\n\\n2 2\\n2 3\\n3 5\\n\\n\\nOutput\\n\\n3\\n\\n\\nInput\\n\\n3 2\\n1 2 3\\n3 4\\n\\n\\nOutput\\n\\n4\\n\\n\\nInput\\n\\n3 2\\n4 5 6\\n1 2\\n\\n\\nOutput\\n\\n0\\n\\nNote\\n\\nIn example 1, you can increase a1 by 1 and decrease b2 by 1 and then again decrease b2 by 1. Now array a will be [3; 3] and array b will also be [3; 3]. Here minimum element of a is at least as large as maximum element of b. So minimum number of operations needed to satisfy Devu's condition are 3.\\n\\nIn example 3, you don't need to do any operation, Devu's condition is already satisfied. \\n## Au\",\"targets\":\"thor: Gilberto A. dos Santos\\n## Website: http:\\/\\/codeforces.com\\/problemset\\/problem\\/439\\/D\\n\\nn, m = map(int, raw_input().split(\\\" \\\"))\\n\\na = map(int, raw_input().split(\\\" \\\"))\\nb = map(int, raw_input().split(\\\" \\\"))\\n\\na.sort(reverse=True)\\nb.sort()\\n\\nmaxB = b[len(b) - 1]\\n\\na = filter(lambda x: x < maxB, a)\\n\\nans = 0\\nwhile a and b and a[-1] < b[-1]:\\n ans += b.pop() - a.pop()\\nprint ans\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"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;\\nvoid read(int &x) {\\n x = 0;\\n int f = 1;\\n char ch = getchar();\\n for (; !isdigit(ch); ch = getchar())\\n if (ch == '-') f = -f;\\n for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';\\n x *= f;\\n}\\nvoid print(int x) {\\n if (x < 0) putchar('-'), x = -x;\\n if (!x) return;\\n print(x \\/ 10), putchar(x % 10 + 48);\\n}\\nvoid write(int x) {\\n if (!x)\\n putchar('0');\\n else\\n print(x);\\n putchar('\\\\n');\\n}\\nconst int maxn = 4e5 + 10;\\nconst int inf = 1e9;\\nconst double eps = 1e-8;\\nconst int mod = 998244353;\\nint n, m, a[maxn], t[maxn << 2], N = 4e5;\\nvoid build(int p, int l, int r) {\\n if (l == r) return t[p] = 1, void();\\n build(p << 1, l, ((l + r) >> 1)), build(p << 1 | 1, ((l + r) >> 1) + 1, r);\\n t[p] = t[p << 1] + t[p << 1 | 1];\\n}\\nvoid fuck(int p, int l, int r, int x) {\\n if (l == r) return t[p] ^= 1, void();\\n if (x <= ((l + r) >> 1))\\n fuck(p << 1, l, ((l + r) >> 1), x);\\n else\\n fuck(p << 1 | 1, ((l + r) >> 1) + 1, r, x);\\n t[p] = t[p << 1] + t[p << 1 | 1];\\n}\\nint find(int p, int l, int r, int k) {\\n if (l == r) return l;\\n if (t[p << 1] >= k)\\n return find(p << 1, l, ((l + r) >> 1), k);\\n else\\n return find(p << 1 | 1, ((l + r) >> 1) + 1, r, k - t[p << 1]);\\n}\\nint sta[maxn], top, fac[maxn], ifac[maxn];\\nint qpow(int a, int x) {\\n int res = 1;\\n for (; x; x >>= 1, a = 1ll * a * a % mod)\\n if (x & 1) res = 1ll * res * a % mod;\\n return res;\\n}\\nvoid prepare() {\\n fac[0] = ifac[0] = 1;\\n for (int i = 1; i <= N; i++) fac[i] = 1ll * fac[i - 1] * i % mod;\\n ifac[N] = qpow(fac[N], mod - 2);\\n for (int i = N - 1; i; i--) ifac[i] = 1ll * ifac[i + 1] * (i + 1) % mod;\\n}\\nint c(int a, int b) { return 1ll * fac[a] * ifac[b] % mod * ifac[a - b] % mod; }\\nvoid solve() {\\n read(n), read(m);\\n int cnt = 0, ans = 0;\\n for (int i = 1; i <= m; i++) read(a[i]), read(a[i]);\\n for (int i = m; i; i--) {\\n int x = find(1, 1, N, a[i]), nxt = find(1, 1, N, a[i] + 1);\\n fuck(1, 1, N, x), sta[++top] = x;\\n if (nxt == x + 1) cnt++;\\n }\\n while (top) fuck(1, 1, N, sta[top--]);\\n ans =...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"During the lunch break all n Berland State University students lined up in the food court. However, it turned out that the food court, too, has a lunch break and it temporarily stopped working.\\n\\nStanding in a queue that isn't being served is so boring! So, each of the students wrote down the number of the student ID of the student that stands in line directly in front of him, and the student that stands in line directly behind him. If no one stands before or after a student (that is, he is the first one or the last one), then he writes down number 0 instead (in Berland State University student IDs are numerated from 1).\\n\\nAfter that, all the students went about their business. When they returned, they found out that restoring the queue is not such an easy task.\\n\\nHelp the students to restore the state of the queue by the numbers of the student ID's of their neighbors in the queue.\\n\\nInput\\n\\nThe first line contains integer n (2 ≤ n ≤ 2·105) — the number of students in the queue. \\n\\nThen n lines follow, i-th line contains the pair of integers ai, bi (0 ≤ ai, bi ≤ 106), where ai is the ID number of a person in front of a student and bi is the ID number of a person behind a student. The lines are given in the arbitrary order. Value 0 is given instead of a neighbor's ID number if the neighbor doesn't exist.\\n\\nThe ID numbers of all students are distinct. It is guaranteed that the records correspond too the queue where all the students stand in some order.\\n\\nOutput\\n\\nPrint a sequence of n integers x1, x2, ..., xn — the sequence of ID numbers of all the students in the order they go in the queue from the first student to the last one.\\n\\nExamples\\n\\nInput\\n\\n4\\n92 31\\n0 7\\n31 0\\n7 141\\n\\n\\nOutput\\n\\n92 7 31 141 \\n\\nNote\\n\\nThe picture illustrates the queue for the first sample.\\n\\n\\n#incl\",\"targets\":\"ude \\nconst int N = 1000005;\\nint mark[N], cnt1[N], cnt2[N];\\nint main() {\\n int n;\\n while (scanf(\\\"%d\\\", &n) != EOF) {\\n memset(cnt1, 0, sizeof(cnt1));\\n memset(cnt2, 0, sizeof(cnt2));\\n for (int i = 1; i <= n; i++) {\\n int x, y;\\n scanf(\\\"%d%d\\\", &x, &y);\\n mark[x] = y;\\n cnt1[x]++;\\n cnt2[y]++;\\n }\\n int temp2 = mark[0], temp1;\\n for (int i = 1; i <= 1000000; i++) {\\n if (cnt1[i] == 1 && cnt2[i] == 0) {\\n temp1 = i;\\n break;\\n }\\n }\\n while (temp1 != 0) {\\n printf(\\\"%d \\\", temp1);\\n int k = temp1;\\n temp1 = temp2;\\n temp2 = mark[k];\\n }\\n printf(\\\"\\\\n\\\");\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nOne day Om Nom found a thread with n beads of different colors. He decided to cut the first several beads from this thread to make a bead necklace and present it to his girlfriend Om Nelly.\\n\\n\\n\\nOm Nom knows that his girlfriend loves beautiful patterns. That's why he wants the beads on the necklace to form a regular pattern. A sequence of beads S is regular if it can be represented as S = A + B + A + B + A + ... + A + B + A, where A and B are some bead sequences, \\\" + \\\" is the concatenation of sequences, there are exactly 2k + 1 summands in this sum, among which there are k + 1 \\\"A\\\" summands and k \\\"B\\\" summands that follow in alternating order. Om Nelly knows that her friend is an eager mathematician, so she doesn't mind if A or B is an empty sequence.\\n\\nHelp Om Nom determine in which ways he can cut off the first several beads from the found thread (at least one; probably, all) so that they form a regular pattern. When Om Nom cuts off the beads, he doesn't change their order.\\n\\nInput\\n\\nThe first line contains two integers n, k (1 ≤ n, k ≤ 1 000 000) — the number of beads on the thread that Om Nom found and number k from the definition of the regular sequence above.\\n\\nThe second line contains the sequence of n lowercase Latin letters that represent the colors of the beads. Each color corresponds to a single letter.\\n\\nOutput\\n\\nPrint a string consisting of n zeroes and ones. Position i (1 ≤ i ≤ n) must contain either number one if the first i beads on the thread form a regular sequence, or a zero otherwise.\\n\\nExamples\\n\\nInput\\n\\n7 2\\nbcabcab\\n\\n\\nOutput\\n\\n0000011\\n\\nInput\\n\\n21 2\\nababaababaababaababaa\\n\\n\\nOutput\\n\\n000110000111111000011\\n\\nNote\\n\\nIn the first sample test a regular sequence is both a sequence of the first 6 beads (we can take A = \\\"\\\", B = \\\"bca\\\"), and a sequence of the first 7 beads (we can take A = \\\"b\\\", B = \\\"ca\\\").\\n\\nIn the second sample test, for example, a sequence of the first 13 beads is regular, if we take A = \\\"aba\\\", B = \\\"ba\\\".\",\"targets\":\"#include \\nusing namespace std;\\nlong long power(long long x, long long y, long long mod) {\\n if (y < 0) return power(power(x, mod - 2, mod), -y, mod);\\n long long res = 1;\\n while (y) {\\n if (y & 1) res = res * x % mod;\\n y >>= 1;\\n x = x * x % mod;\\n }\\n return res;\\n}\\nint N, K, p[1000100];\\nchar S[1000100];\\nint main() {\\n scanf(\\\"%d%d%s\\\", &N, &K, S + 1);\\n int j = 0;\\n if (K == 1)\\n putchar('1');\\n else\\n putchar('0');\\n for (int i = (int)2; i <= (int)N; ++i) {\\n while (j && S[i] != S[j + 1]) j = p[j];\\n if (S[i] == S[j + 1]) j++;\\n p[i] = j;\\n int t = i - p[i];\\n int w = i % t;\\n int o = i \\/ t \\/ K;\\n t *= o;\\n w = i % t;\\n if (i <= (long long)(K + 1) * t && i >= (long long)t * K &&\\n (K > 1 && p[w + t] >= w || !w) ||\\n K == 1)\\n putchar('1');\\n else\\n putchar('0');\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"An array of integers p_1, p_2, ..., p_n is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3, 1, 2], [1], [1, 2, 3, 4, 5] and [4, 3, 1, 2]. The following arrays are not permutations: [2], [1, 1], [2, 3, 4].\\n\\nPolycarp invented a really cool permutation p_1, p_2, ..., p_n of length n. It is very disappointing, but he forgot this permutation. He only remembers the array q_1, q_2, ..., q_{n-1} of length n-1, where q_i=p_{i+1}-p_i.\\n\\nGiven n and q=q_1, q_2, ..., q_{n-1}, help Polycarp restore the invented permutation.\\n\\nInput\\n\\nThe first line contains the integer n (2 ≤ n ≤ 2⋅10^5) — the length of the permutation to restore. The second line contains n-1 integers q_1, q_2, ..., q_{n-1} (-n < q_i < n).\\n\\nOutput\\n\\nPrint the integer -1 if there is no such permutation of length n which corresponds to the given array q. Otherwise, if it exists, print p_1, p_2, ..., p_n. Print any such permutation if there are many of them.\\n\\nExamples\\n\\nInput\\n\\n\\n3\\n-2 1\\n\\n\\nOutput\\n\\n\\n3 1 2 \\n\\nInput\\n\\n\\n5\\n1 1 1 1\\n\\n\\nOutput\\n\\n\\n1 2 3 4 5 \\n\\nInput\\n\\n\\n4\\n-1 2 2\\n\\n\\nOutput\\n\\n\\n-1\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"from collections import Counter\\nn=int(input())\\nli=list(map(int,input().split()))\\nli=[0]+li\\nfor i in range(1,n):\\n li[i]+=li[i-1]\\nm1=max(li)\\nm2=min(li)\\na=n-m1\\nb=1-m2\\nli2=[]\\nif a!=b:\\n print(\\\"-1\\\")\\nelse:\\n dic=Counter(li)\\n for (c,d) in dic.items():\\n if d>1:\\n print(\\\"-1\\\")\\n break\\n else:\\n for i in li:\\n print(a+i,end=\\\" \\\")\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"\\n\\nInput\\n\\nThe input contains a single floating-point number x with exactly 6 decimal places (0 < x < 5).\\n\\nOutput\\n\\nOutput two integers separated by a single space. Each integer should be between 1 and 10, inclusive. If several solutions exist, output any of them. Solution will exist for all tests.\\n\\nExamples\\n\\nInput\\n\\n1.200000\\n\\n\\nOutput\\n\\n3 2\\n\\n\\nInput\\n\\n2.572479\\n\\n\\nOutput\\n\\n10 3\\n\\n\\nInput\\n\\n4.024922\\n\\n\\nOutput\\n\\n9 9\",\"targets\":\"#include \\nusing namespace std;\\nconst double eps = 1e-6;\\ndouble r;\\nint main() {\\n scanf(\\\"%lf\\\", &r);\\n for (int a = 1; a <= 10; ++a) {\\n for (int h = 1; h <= 10; ++h) {\\n double area = (a \\/ 2.0 * h);\\n double bot = sqrt(a * a \\/ 4.0 + h * h);\\n double tmp = area \\/ bot;\\n if (fabs(tmp - r) < eps) {\\n printf(\\\"%d %d\\\\n\\\", a, h);\\n return 0;\\n }\\n }\\n }\\n}\",\"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] \\nimpor\",\"targets\":\"t 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()] == temp )...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"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 PYTHON3.\",\"targets\":\"for q in range(int(input())):\\n k=int(input())\\n i=0\\n while k>0:\\n k-=1\\n i+=1\\n while i%3==0 or i%10==3:\\n i+=1\\n print(i)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"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\\nUsing python3 can you solve the prior task?\",\"targets\":\"for _ in range(int(input())):\\n n=int(input())\\n c1=1\\n c2=1\\n i=0\\n a=0\\n b=0\\n while(n):\\n r=int(n%10)\\n if(int(i%2)==0):\\n a=(r*c1)+a\\n c1*=10\\n else:\\n b=(r*c2)+b\\n c2*=10\\n n=int(n\\/10)\\n i+=1\\n print(((a+1)*(b+1))-2)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"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...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nint main() {\\n int t;\\n cin >> t;\\n while (t--) {\\n int n, m;\\n cin >> n >> m;\\n int ra, ca, rb, cb, x = 1, y = 1, ans = 0;\\n cin >> ra >> ca >> rb >> cb;\\n while (ra != rb && ca != cb) {\\n if ((x > 0 && ra == n) || (x < 0 && ra == 1)) {\\n x *= -1;\\n }\\n if ((y < 0 && ca == 1) || (y > 0 && ca == m)) {\\n y *= -1;\\n }\\n ra += x;\\n ca += y;\\n ans++;\\n }\\n cout << ans << \\\"\\\\n\\\";\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Let's define a number ebne (even but not even) if and only if its sum of digits is divisible by 2 but the number itself is not divisible by 2. For example, 13, 1227, 185217 are ebne numbers, while 12, 2, 177013, 265918 are not. If you're still unsure what ebne numbers are, you can look at the sample notes for more clarification.\\n\\nYou are given a non-negative integer s, consisting of n digits. You can delete some digits (they are not necessary consecutive\\/successive) to make the given number ebne. You cannot change the order of the digits, that is, after deleting the digits the remaining digits collapse. The resulting number shouldn't contain leading zeros. You can delete any number of digits between 0 (do not delete any digits at all) and n-1.\\n\\nFor example, if you are given s=222373204424185217171912 then one of possible ways to make it ebne is: 222373204424185217171912 → 2237344218521717191. The sum of digits of 2237344218521717191 is equal to 70 and is divisible by 2, but number itself is not divisible by 2: it means that the resulting number is ebne.\\n\\nFind any resulting number that is ebne. If it's impossible to create an ebne number from the given number report about it.\\n\\nInput\\n\\nThe input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 1000) — 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 (1 ≤ n ≤ 3000) — the number of digits in the original number.\\n\\nThe second line of each test case contains a non-negative integer number s, consisting of n digits.\\n\\nIt is guaranteed that s does not contain leading zeros and the sum of n over all test cases does not exceed 3000.\\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 an ebne number, print \\\"-1\\\" (without quotes);\\n * Otherwise, print the resulting number after deleting some, possibly zero, but not all digits. This number should be ebne. If there are multiple answers, you...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nvector factors(long long int n) {\\n vector arr;\\n for (int i = 1; i <= sqrt(n); i++) {\\n if (n % i == 0) {\\n if (n \\/ i == i)\\n arr.push_back(i);\\n else {\\n arr.push_back(i);\\n arr.push_back(n \\/ i);\\n }\\n }\\n }\\n sort(arr.begin(), arr.end());\\n return arr;\\n}\\nlong long int mult(long long int a, long long int b) {\\n return (1LL * a * b) % (unsigned long long int)(double)(1e9 + 7);\\n}\\nlong long int power(long long int a, long long int b) {\\n if (b == 0) return 1;\\n if (b & 1) return mult(a, power(a, b - 1));\\n long long int res = power(a, b \\/ 2);\\n return mult(res, res);\\n}\\nint main() {\\n cout << fixed << setprecision(20);\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n ;\\n long long int t, n;\\n string s;\\n cin >> t;\\n while (t--) {\\n cin >> n >> s;\\n long long int odd = 0;\\n string ans;\\n bool flag = 0;\\n for (auto i = 0; i < n; i++) {\\n long long int temp = s[i] - '0';\\n if (temp % 2 == 1) {\\n odd++;\\n ans += s[i];\\n }\\n if (odd >= 2) {\\n flag = 1;\\n break;\\n }\\n }\\n if (flag)\\n cout << ans << endl;\\n else\\n cout << \\\"-1\\\" << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA 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\":\"import java.util.*;\\n\\n\\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\\tArrayList x = new ArrayList<>();\\n\\t\\t\\t\\tint n = sc.nextInt();\\n\\t\\t\\t\\tint m = sc.nextInt();\\n\\t\\t\\t\\tfor( int i =0; i< m*n ;i++) {\\n\\t\\t\\t\\t\\tpair pr = new pair();\\n\\t\\t\\t\\t\\tpr.idx = i+1;\\n\\t\\t\\t\\t\\tpr.val = sc.nextInt();\\n\\t\\t\\t\\t\\tx.add(pr);\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tCollections.sort(x);\\n\\/\\/\\t\\t\\t\\tint arr[] = new int[m*n];\\n\\/\\/\\t\\t\\t\\tfor( int i= 0; i< m*n ;i++) {\\n\\/\\/\\t\\t\\t\\t\\tarr[ x.get(i).idx-1] = i+1;\\n\\/\\/\\t\\t\\t\\t}\\n\\/\\/\\t\\t\\t\\tfor( pair y : x) {\\n\\/\\/\\t\\t\\t\\t\\tout.print(y.idx+ \\\" \\\");\\n\\/\\/\\t\\t\\t\\t}\\n\\/\\/\\t\\t\\t\\tout.println();\\n\\/\\/\\t\\t\\t\\tfor(int y : arr) {\\n\\/\\/\\t\\t\\t\\t\\tout.print(y+ \\\" \\\");\\n\\/\\/\\t\\t\\t\\t}\\n\\/\\/\\t\\t\\t\\tout.println();\\n\\t\\t\\t\\tlong sum = 0;\\n\\/\\/\\t\\t\\t\\tfor( pair pr : x) {\\n\\/\\/\\t\\t\\t\\t\\tout.print( pr.idx + \\\" \\\");\\n\\/\\/\\t\\t\\t\\t}\\n\\/\\/\\t\\t\\t\\tout.println();\\n\\t\\t\\t\\t\\/\\/out.flush();\\n\\/\\/\\t\\t\\t\\tint a[] = new int[m*n];\\n\\/\\/\\t\\t\\t\\tfor( int i = 0; i[] mat= new ArrayList[n];\\n\\/\\/\\t\\t\\t\\tfor( int i =0 ;i < n; i++) {\\n\\/\\/\\t\\t\\t\\t\\tmat[i] = new ArrayList<>();\\n\\/\\/\\t\\t\\t\\t}\\n\\/\\/\\t\\t\\t\\tfor( int i =0 ; i< m*n ;i++) {\\n\\/\\/\\t\\t\\t\\t\\t\\/\\/ row = arr[i]\\/m\\n\\/\\/\\t\\t\\t\\t\\tint col = 0;\\n\\/\\/\\t\\t\\t\\t\\tint row= 0;\\n\\/\\/\\t\\t\\t\\t\\tint temp = arr[i];\\n\\/\\/\\t\\t\\t\\t\\tif( temp% m == 0) {\\n\\/\\/\\t\\t\\t\\t\\t\\tcol = m-1;\\n\\/\\/\\t\\t\\t\\t\\t}\\n\\/\\/\\t\\t\\t\\t\\telse {\\n\\/\\/\\t\\t\\t\\t\\t\\tcol = temp%m - 1;\\n\\/\\/\\t\\t\\t\\t\\t}\\n\\/\\/\\t\\t\\t\\t\\trow = (temp-1)\\/m + 1;\\n\\/\\/\\t\\t\\t\\t\\tmat[row-1].add(col, i);\\n\\/\\/\\t\\t\\t\\t}\\n\\t\\t\\t\\tint i = 0 ;\\n\\t\\t\\t\\tint j = m-1;\\n\\t\\t\\t\\twhile( n-- > 0) {\\n\\t\\t\\t\\t\\tArrayList h = new ArrayList<>();\\n\\t\\t\\t\\t\\tfor( int k = i ; k<= j ; k++) {\\n\\t\\t\\t\\t\\t\\th.add(x.get(k));\\n\\t\\t\\t\\t\\t}\\n\\/\\/\\t\\t\\t\\t\\tfor( pair pr : h) {\\n\\/\\/\\t\\t\\t\\t\\t\\tout.print( pr.idx + \\\" \\\");\\n\\/\\/\\t\\t\\t\\t\\t}\\n\\/\\/\\t\\t\\t\\t\\tout.println();\\n\\t\\t\\t\\t\\t\\/\\/out.flush();\\n\\t\\t\\t\\t\\tCollections.sort(h , new sort());\\n\\t\\t\\t\\t\\tsum+=solve( h , m);\\n\\t\\t\\t\\t\\ti+=m;\\n\\t\\t\\t\\t\\tj+=m;\\n\\t\\t\\t\\t}\\n\\/\\/\\t\\t\\t\\tint i = 0;\\n\\/\\/\\t\\t\\t\\tint j = m-1;\\n\\/\\/\\t\\t\\t\\twhile( n-- > 0) {\\n\\/\\/\\t\\t\\t\\t\\tsum+=solve( arr , i , j...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Polycarp is very fond of playing the game Minesweeper. Recently he found a similar game and there are such rules.\\n\\nThere are mines on the field, for each the coordinates of its location are known (x_i, y_i). Each mine has a lifetime in seconds, after which it will explode. After the explosion, the mine also detonates all mines vertically and horizontally at a distance of k (two perpendicular lines). As a result, we get an explosion on the field in the form of a \\\"plus\\\" symbol ('+'). Thus, one explosion can cause new explosions, and so on.\\n\\nAlso, Polycarp can detonate anyone mine every second, starting from zero seconds. After that, a chain reaction of explosions also takes place. Mines explode instantly and also instantly detonate other mines according to the rules described above.\\n\\nPolycarp wants to set a new record and asks you to help him calculate in what minimum number of seconds all mines can be detonated.\\n\\nInput\\n\\nThe first line of the input contains an integer t (1 ≤ t ≤ 10^4) — the number of test cases in the test.\\n\\nAn empty line is written in front of each test suite.\\n\\nNext comes a line that contains integers n and k (1 ≤ n ≤ 2 ⋅ 10^5, 0 ≤ k ≤ 10^9) — the number of mines and the distance that hit by mines during the explosion, respectively.\\n\\nThen n lines follow, the i-th of which describes the x and y coordinates of the i-th mine and the time until its explosion (-10^9 ≤ x, y ≤ 10^9, 0 ≤ timer ≤ 10^9). It is guaranteed that all mines have different coordinates.\\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\\nPrint t lines, each of the lines must contain the answer to the corresponding set of input data — the minimum number of seconds it takes to explode all the mines.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n\\n5 0\\n0 0 1\\n0 1 4\\n1 0 2\\n1 1 3\\n2 2 9\\n\\n5 2\\n0 0 1\\n0 1 4\\n1 0 2\\n1 1 3\\n2 2 9\\n\\n6 1\\n1 -1 3\\n0 -1 9\\n0 1 7\\n-1 0 1\\n-1 1 9\\n-1 -1 7\\n\\n\\nOutput\\n\\n\\n2\\n1\\n0\\n\\nNote\\n\\n Picture from examples\\n\\nFirst example: \\n\\n * 0 second: we explode a mine at the cell (2, 2), it does not...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nusing ll = long long;\\nusing pll = pair;\\nusing str = string;\\nusing vll = vector;\\nusing pll = pair;\\nusing ld = long double;\\nconst ld PI = acos(-1);\\n#pragma GCC optimize(\\\"Ofast\\\")\\n#pragma GCC target(\\\"avx,avx2,fma\\\")\\n#pragma GCC optimization(\\\"unroll-loops\\\")\\nll gcd(ll a, ll b) {\\n if (b == 0) return a;\\n return gcd(b, a % b);\\n}\\nmt19937 rnd(31313121);\\nstr Y = \\\"YES\\\\n\\\";\\nstr N = \\\"NO\\\\n\\\";\\nconst ll INF = 2e18 + 10;\\nconst ll Mod = 1e9 + 7;\\nconst ll Maxn = 2e5 + 10;\\nvll gr[Maxn];\\nbool used[Maxn];\\nll tim[Maxn];\\nvoid dfs(ll v, ll &vl) {\\n used[v] = true;\\n vl = min(vl, tim[v]);\\n for (ll adj : gr[v]) {\\n if (!used[adj]) dfs(adj, vl);\\n }\\n}\\nvoid solve() {\\n map> x;\\n map> y;\\n ll n, k;\\n cin >> n >> k;\\n for (ll i = 0; i < n; ++i) gr[i].clear();\\n fill(used, used + n, false);\\n for (ll i = 0; i < n; ++i) {\\n ll xx, yy;\\n ll t;\\n cin >> xx >> yy;\\n cin >> t;\\n x[xx].push_back({yy, i});\\n y[yy].push_back({xx, i});\\n tim[i] = t;\\n }\\n for (auto [id, xs] : x) {\\n sort(((xs).begin()), ((xs).end()));\\n for (ll i = 0; i < (ll)xs.size() - 1; ++i) {\\n if (xs[i + 1].first - xs[i].first <= k) {\\n gr[xs[i + 1].second].push_back(xs[i].second);\\n gr[xs[i].second].push_back(xs[i + 1].second);\\n }\\n }\\n }\\n for (auto [id, ys] : y) {\\n sort(((ys).begin()), ((ys).end()));\\n for (ll i = 0; i < (ll)ys.size() - 1; ++i) {\\n if (ys[i + 1].first - ys[i].first <= k) {\\n gr[ys[i + 1].second].push_back(ys[i].second);\\n gr[ys[i].second].push_back(ys[i + 1].second);\\n }\\n }\\n }\\n vll es;\\n for (ll i = 0; i < n; ++i) {\\n if (!used[i]) {\\n ll v = INF;\\n dfs(i, v);\\n es.push_back(v);\\n }\\n }\\n sort(((es).begin()), ((es).end()));\\n deque q;\\n for (ll el : es) q.push_back(el);\\n ll ans = 0;\\n while ((ll)q.size()) {\\n while ((ll)q.size() && q.front() == ans) q.pop_front();\\n if ((ll)q.size()) {\\n q.pop_back();\\n }\\n ++ans;\\n }\\n cout << ans - 1 << '\\\\n';\\n}\\nint main()...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nTheofanis 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\":\"import java.util.*; import java.io.*; import java.math.*;\\npublic class Main{\\n\\t\\/\\/見なくていいよ ここから------------------------------------------\\n\\tstatic class InputIterator{\\n\\t\\tArrayList inputLine = new ArrayList<>(buf);\\n\\t\\tint index = 0; int max; String read;\\n\\t\\tInputIterator(){\\n\\t\\t\\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\\n\\t\\t\\ttry{\\n\\t\\t\\t\\twhile((read = br.readLine()) != null){\\n\\t\\t\\t\\t\\tinputLine.addAll(Arrays.asList(read.split(\\\" \\\")));\\n\\t\\t\\t\\t}\\n\\t\\t\\t}catch(IOException e){}\\n\\t\\t\\tmax = inputLine.size();\\n\\t\\t}\\n\\t\\tboolean hasNext(){return (index < max);}\\n\\t\\tString next(){\\n\\t\\t\\tif(hasNext()){\\n\\t\\t\\t\\treturn inputLine.get(index++);\\n\\t\\t\\t}else{\\n\\t\\t\\t\\tthrow new IndexOutOfBoundsException(\\\"There is no more input\\\");\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\t\\/\\/入力バッファサイズのつもり。入力点数(スペース区切りでの要素数)が100万を超える場合はバッファサイズを100万にすること\\n\\tstatic int buf = 1024;\\n\\tstatic HashMap CONVSTR = new HashMap<>();\\n\\tstatic InputIterator ii = new InputIterator();\\/\\/This class cannot be used in reactive problem.\\n\\tstatic PrintWriter out = new PrintWriter(System.out);\\n\\tstatic void flush(){out.flush();}\\n\\tstatic void myout(Object t){out.println(t);}\\n\\tstatic void myerr(Object t){System.err.print(\\\"debug:\\\");System.err.println(t);}\\n\\tstatic String next(){return ii.next();}\\n\\tstatic boolean hasNext(){return ii.hasNext();}\\n\\tstatic int nextInt(){return Integer.parseInt(next());}\\n\\tstatic long nextLong(){return Long.parseLong(next());}\\n\\tstatic double nextDouble(){return Double.parseDouble(next());}\\n\\tstatic ArrayList nextCharArray(){return myconv(next(), 0);}\\n\\tstatic ArrayList nextStrArray(int size){\\n\\t\\tArrayList ret = new ArrayList<>(size);\\n\\t\\tfor(int i = 0; i < size; i++){\\n\\t\\t\\tret.add(next());\\n\\t\\t}\\n\\t\\treturn ret;\\n\\t}\\n\\tstatic ArrayList nextIntArray(int size){\\n\\t\\tArrayList ret = new ArrayList<>(size);\\n\\t\\tfor(int i = 0; i < size; i++){\\n\\t\\t\\tret.add(Integer.parseInt(next()));\\n\\t\\t}\\n\\t\\treturn ret;\\n\\t}\\n\\tstatic ArrayList nextLongArray(int size){\\n\\t\\tArrayList ret = new ArrayList<>(size);\\n\\t\\tfor(int i = 0; i < size;...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alice has recently received an array a_1, a_2, ..., a_n for her birthday! She is very proud of her array, and when she showed her friend Bob the array, he was very happy with her present too!\\n\\nHowever, soon Bob became curious, and as any sane friend would do, asked Alice to perform q operations of two types on her array:\\n\\n * 1 x y: update the element a_x to y (set a_x = y). \\n * 2 l r: calculate how many non-decreasing subarrays exist within the subarray [a_l, a_{l+1}, ..., a_r]. More formally, count the number of pairs of integers (p,q) such that l ≤ p ≤ q ≤ r and a_p ≤ a_{p+1} ≤ ... ≤ a_{q-1} ≤ a_q. \\n\\n\\n\\nHelp Alice answer Bob's queries!\\n\\nInput\\n\\nThe first line contains two integers n and q (1 ≤ n, q ≤ 2 ⋅ 10^5) — the size of the array, and the number of queries, respectively.\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — the elements of Alice's array.\\n\\nThe next q lines consist of three integers each. The first integer of the i-th line is t_i, the operation being performed on the i-th step (t_i = 1 or t_i = 2).\\n\\nIf t_i = 1, the next two integers are x_i and y_i (1 ≤ x_i ≤ n; 1 ≤ y_i ≤ 10^9), updating the element at position x_i to y_i (setting a_{x_i} = y_i).\\n\\nIf t_i = 2, the next two integers are l_i and r_i (1 ≤ l_i ≤ r_i ≤ n), the two indices Bob asks Alice about for the i-th query.\\n\\nIt's guaranteed that there is at least one operation of the second type.\\n\\nOutput\\n\\nFor each query of type 2, print a single integer, the answer to the query.\\n\\nExample\\n\\nInput\\n\\n\\n5 6\\n3 1 4 1 5\\n2 2 5\\n2 1 3\\n1 4 4\\n2 2 5\\n1 2 6\\n2 2 5\\n\\n\\nOutput\\n\\n\\n6\\n4\\n10\\n7\\n\\nNote\\n\\nFor the first query, l = 2 and r = 5, and the non-decreasing subarrays [p,q] are [2,2], [3,3], [4,4], [5,5], [2,3] and [4,5].\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst int inf = 0x3f3f3f3f;\\nconst double eps = 1e-8;\\nconst int N = 2e5 + 10;\\nstruct Node {\\n int l, r;\\n long long sum;\\n int lv, rv;\\n int llen, rlen;\\n} tr[N * 4];\\nint a[N];\\nint n, m;\\nvoid pushup(Node& u, Node& l, Node& r) {\\n u.sum = l.sum + r.sum;\\n u.lv = l.lv, u.rv = r.rv;\\n u.llen = l.llen, u.rlen = r.rlen;\\n if (l.rv <= r.lv) {\\n u.sum += (long long)l.rlen * r.llen;\\n if (l.llen == l.r - l.l + 1) u.llen += r.llen;\\n if (r.rlen == r.r - r.l + 1) u.rlen += l.rlen;\\n }\\n}\\nvoid pushup(int u) { pushup(tr[u], tr[u << 1], tr[u << 1 | 1]); }\\nvoid build(int u, int l, int r) {\\n tr[u] = {l, r};\\n if (l == r) {\\n tr[u].sum = 1ll;\\n tr[u].lv = tr[u].rv = a[l];\\n tr[u].llen = tr[u].rlen = 1;\\n return;\\n }\\n int mid = l + r >> 1;\\n build(u << 1, l, mid);\\n build(u << 1 | 1, mid + 1, r);\\n pushup(u);\\n}\\nvoid modify(int u, int pos, int val) {\\n if (tr[u].l == tr[u].r) {\\n tr[u].sum = 1;\\n tr[u].lv = tr[u].rv = val;\\n tr[u].llen = tr[u].rlen = 1;\\n return;\\n }\\n int mid = tr[u].l + tr[u].r >> 1;\\n if (pos <= mid)\\n modify(u << 1, pos, val);\\n else\\n modify(u << 1 | 1, pos, val);\\n pushup(u);\\n}\\nNode query(int u, int l, int r) {\\n if (tr[u].l >= l && tr[u].r <= r) return tr[u];\\n int mid = tr[u].l + tr[u].r >> 1;\\n if (r <= mid)\\n return query(u << 1, l, r);\\n else if (l > mid)\\n return query(u << 1 | 1, l, r);\\n Node ans = {0}, L = {0}, R = {0};\\n L = query(u << 1, l, r);\\n R = query(u << 1 | 1, l, r);\\n pushup(ans, L, R);\\n return ans;\\n}\\nint main() {\\n scanf(\\\"%d%d\\\", &n, &m);\\n for (int i = 1; i <= n; ++i) scanf(\\\"%d\\\", &a[i]);\\n build(1, 1, n);\\n while (m--) {\\n int op, a, b;\\n scanf(\\\"%d%d%d\\\", &op, &a, &b);\\n if (op == 1)\\n modify(1, a, b);\\n else {\\n printf(\\\"%lld\\\\n\\\", query(1, a, b).sum);\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nMonocarp 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 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 double x1, p1;\\n cin >> x1 >> p1;\\n double x2, p2;\\n cin >> x2 >> p2;\\n double temp1 = log10(x1 \\/ x2) + p1 - p2;\\n if (temp1 < 0) {\\n cout << '<' << '\\\\n';\\n } else if (temp1 > 0) {\\n cout << '>' << '\\\\n';\\n } else {\\n cout << '=' << '\\\\n';\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"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\":\"from collections import defaultdict as dd\\nimport math\\nimport sys\\ninput=sys.stdin.readline\\ndef nn():\\n return int(input())\\n \\ndef li():\\n return list(input())\\n \\ndef mi():\\n return map(int, input().split())\\n \\ndef lm():\\n return list(map(int, input().split()))\\n \\n \\n \\ndef solve():\\n n, m = mi()\\n d= input()\\n running= [0]\\n tot=0\\n for i in range(n):\\n if i%2==0 and d[i]=='+':\\n tot+=1\\n if i%2==0 and d[i]=='-':\\n tot-=1\\n if i%2==1 and d[i]=='+':\\n tot-=1\\n if i%2==1 and d[i]=='-':\\n tot+=1\\n running.append(tot)\\n #print(running)\\n for i in range(m):\\n l, r = mi()\\n length = r-l + 1\\n s = running[r] - running[l-1]\\n if s==0:\\n print(0)\\n elif length%2==0:\\n print(2)\\n else:\\n print(1)\\nq=nn()\\nfor _ in range(q):\\n solve()\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"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...\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"for _ in range(int(input())):\\n n=int(input())\\n l=list(map(int,input().split()))\\n l.sort()\\n c=n\\/\\/2\\n i=1\\n while(c):\\n print(l[i],l[0])\\n i+=1\\n c-=1\",\"language\":\"python\",\"split\":\"test\",\"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.\",\"targets\":\"def fun(i, j, memo, breakPoint):\\n for k in range(i, j):\\n if memo[k] >= 2:\\n breakPoint.append(k)\\n \\nfor _ in range(int(input())):\\n n = int(input())\\n arr = list(map(int, input().split()))\\n memo = {i:0 for i in range(n+2)}\\n for i in arr:\\n memo[i] += 1\\n mex = 0\\n for i in range(n+1):\\n if memo[i] == 0:\\n mex = i\\n break\\n ans = []\\n breakPoint = [-1]\\n fun(0,mex, memo, breakPoint)\\n for i in range(n+1):\\n if mex >= i:\\n ans.append(memo[i])\\n else:\\n # print(i, memo[i], mex)\\n bp = breakPoint[-1]\\n if bp != -1:\\n if memo[i]:\\n x = ans[mex]\\n x += (mex-bp)\\n x += memo[i]\\n ans.append(x)\\n else:\\n x = ans[mex]\\n x += (mex-bp)\\n memo[bp] -= 1\\n if memo[bp] == 1:\\n breakPoint.pop()\\n memo[mex] += 1\\n fun(mex, i, memo, breakPoint)\\n mex = i\\n memo[i] = 0\\n ans.append(x)\\n \\n else:\\n ans.append(-1)\\n \\n print(' '.join(map(str,ans)))\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"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.\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int T, a, b, c, m, x;\\n cin >> T;\\n while (T--) {\\n cin >> a >> b >> c >> m;\\n x = ((a > 1) ? a - 1 : 0) + ((b > 1) ? b - 1 : 0) + ((c > 1) ? c - 1 : 0);\\n if (x < m) {\\n cout << \\\"NO\\\" << endl;\\n continue;\\n }\\n if (x == m) {\\n cout << \\\"Yes\\\" << endl;\\n continue;\\n }\\n int A, B, C;\\n A = max(max(a, b), c);\\n B = a + b + c - A - min(min(a, b), c);\\n C = min(min(a, b), c);\\n if (A - B - C - 1 > m)\\n cout << \\\"No\\\" << endl;\\n else\\n cout << \\\"Yes\\\" << endl;\\n }\\n return 0;\\n}\",\"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\\nSolve the task in PYTHON3.\",\"targets\":\"n = int(input())\\nmod = 10**9 + 7\\nx = pow(2, n) - 1\\n\\nres = (6*pow(4, x-1, mod))%mod\\nprint(res)\",\"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\\\".\\n# inp\",\"targets\":\"ut = open( 'file.txt' ).readline\\n\\nfor _ in range( int( input() ) ):\\n \\n ss = input().strip()\\n# print(ss)\\n n = len(ss)\\n ans = ''\\n for i in range(0 , n , 2):\\n ans += ss[i]\\n \\n# print(ss)\\n ans += ss[-1]\\n print(ans)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Constraints\\n\\n* 1 ≤ |V| ≤ 100\\n* 0 ≤ |E| ≤ 9900\\n* -2 × 107 ≤ di ≤ 2 × 107\\n* There are no parallel edges\\n* There are no self-loops\\n\\nInput\\n\\nAn edge-weighted graph G (V, E).\\n\\n\\n|V| |E|\\ns0 t0 d0\\ns1 t1 d1\\n:\\ns|E|-1 t|E|-1 d|E|-1\\n\\n\\n|V| is the number of vertices and |E| is the number of edges in G. The graph vertices are named with the numbers 0, 1,..., |V|-1 respectively.\\n\\nsi and ti represent source and target vertices of i-th edge (directed) and di represents the cost of the i-th edge.\\n\\nOutput\\n\\nIf the graph contains a negative cycle (a cycle whose sum of edge costs is a negative value), print\\n\\n\\nNEGATIVE CYCLE\\n\\n\\nin a line.\\n\\nOtherwise, print\\n\\n\\nD0,0 D0,1 ... D0,|V|-1\\nD1,0 D1,1 ... D1,|V|-1\\n:\\nD|V|-1,0 D1,1 ... D|V|-1,|V|-1\\n\\n\\nThe output consists of |V| lines. For each ith line, print the cost of the shortest path from vertex i to each vertex j (j = 0, 1, ... |V|-1) respectively. If there is no path from vertex i to vertex j, print \\\"INF\\\". Print a space between the costs.\\n\\nExamples\\n\\nInput\\n\\n4 6\\n0 1 1\\n0 2 5\\n1 2 2\\n1 3 4\\n2 3 1\\n3 2 7\\n\\n\\nOutput\\n\\n0 1 3 4\\nINF 0 2 3\\nINF INF 0 1\\nINF INF 7 0\\n\\n\\nInput\\n\\n4 6\\n0 1 1\\n0 2 -5\\n1 2 2\\n1 3 4\\n2 3 1\\n3 2 7\\n\\n\\nOutput\\n\\n0 1 -5 -4\\nINF 0 2 3\\nINF INF 0 1\\nINF INF 7 0\\n\\n\\nInput\\n\\n4 6\\n0 1 1\\n0 2 5\\n1 2 2\\n1 3 4\\n2 3 1\\n3 2 -7\\n\\n\\nOutput\\n\\nNEGATIVE CYCLE\\nSolve the task in PYTHON3.\",\"targets\":\"import sys\\nimport bisect\\nimport math\\nread = sys.stdin.read\\nreadline = sys.stdin.readline\\nreadlines = sys.stdin.readlines\\nfrom operator import itemgetter\\ninf=10**20\\nv,e=map(int,readline().split())\\n#print(v,e)\\nd=[[inf for j in range(v)] for i in range(v)]\\nfor i in range(v):\\n d[i][i]=0\\nfor i in range(e):\\n a,b,c=map(int,readline().split())\\n d[a][b]=c\\n\\nfor k in range(v):\\n for i in range(v):\\n for j in range(v):\\n d[i][j]=min(d[i][j],d[i][k]+d[k][j])\\nng=0\\nfor i in range(v):\\n if d[i][i]<0:\\n ng=1\\n break\\n#print(d[2])\\n\\nif ng:\\n print(\\\"NEGATIVE CYCLE\\\")\\nelse:\\n for i in range(v):\\n ans=\\\"\\\"\\n for j in range(v):\\n if d[i][j]>2e9:\\n ans+=\\\"INF\\\"+\\\" \\\"\\n else:\\n ans+=str(d[i][j])+\\\" \\\"\\n print(ans.rstrip())\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nn towns are arranged in a circle sequentially. The towns are numbered from 1 to n in clockwise order. In the i-th town, there lives a singer with a repertoire of a_i minutes for each i ∈ [1, n].\\n\\nEach singer visited all n towns in clockwise order, starting with the town he lives in, and gave exactly one concert in each town. In addition, in each town, the i-th singer got inspired and came up with a song that lasts a_i minutes. The song was added to his repertoire so that he could perform it in the rest of the cities.\\n\\nHence, for the i-th singer, the concert in the i-th town will last a_i minutes, in the (i + 1)-th town the concert will last 2 ⋅ a_i minutes, ..., in the ((i + k) mod n + 1)-th town the duration of the concert will be (k + 2) ⋅ a_i, ..., in the town ((i + n - 2) mod n + 1) — n ⋅ a_i minutes.\\n\\nYou are given an array of b integer numbers, where b_i is the total duration of concerts in the i-th town. Reconstruct any correct sequence of positive integers a or say that it is impossible.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 10^3) — the number of test cases. Then the test cases follow.\\n\\nEach test case consists of two lines. The first line contains a single integer n (1 ≤ n ≤ 4 ⋅ 10^4) — the number of cities. The second line contains n integers b_1, b_2, ..., b_n (1 ≤ b_i ≤ 10^{9}) — the total duration of concerts in i-th city.\\n\\nThe sum of n over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print the answer as follows:\\n\\nIf there is no suitable sequence a, print NO. Otherwise, on the first line print YES, on the next line print the sequence a_1, a_2, ..., a_n of n integers, where a_i (1 ≤ a_i ≤ 10^{9}) is the initial duration of repertoire of the i-th singer. If there are multiple answers, print any of them.\\n\\nExample\\n\\nInput\\n\\n\\n4\\n3\\n12 16 14\\n1\\n1\\n3\\n1 2 3\\n6\\n81 75 75 93 93 87\\n\\n\\nOutput\\n\\n\\nYES\\n3 1 3 \\nYES\\n1 \\nNO\\nYES\\n5 5 4 1 4 5 \\n\\nNote\\n\\nLet's consider the 1-st test case of the example:\\n\\n 1. the 1-st singer in the 1-st city will give a concert for 3 minutes, in the 2-nd —...\",\"targets\":\"#include \\n#pragma GCC target(\\\"avx2\\\")\\n#pragma GCC optimization(\\\"O3\\\")\\n#pragma GCC optimization(\\\"unroll-loops\\\")\\nusing namespace std;\\nconst int MAXN = 4e4 + 2;\\nint t, n;\\nlong long int a[MAXN];\\nlong long int b[MAXN];\\nlong long int sum;\\nbool flag;\\nint main() {\\n ios::sync_with_stdio(0);\\n cin.tie(0);\\n cin >> t;\\n for (int i = 0; i < t; i++) {\\n cin >> n;\\n sum = 0;\\n flag = false;\\n for (int j = 0; j < n; j++) {\\n cin >> b[j];\\n sum += b[j];\\n }\\n if (sum % ((n + 1) * n \\/ 2))\\n cout << \\\"NO\\\"\\n << \\\"\\\\n\\\";\\n else {\\n sum = sum \\/ ((n + 1) * n \\/ 2);\\n for (int j = 0; j < n; j++) {\\n if ((b[j] - b[(j + 1) % n] + sum) % n ||\\n (b[j] - b[(j + 1) % n] + sum) <= 0) {\\n cout << \\\"NO\\\"\\n << \\\"\\\\n\\\";\\n flag = true;\\n break;\\n }\\n a[j] = (b[j] - b[(j + 1) % n] + sum) \\/ n;\\n }\\n if (!flag) {\\n cout << \\\"YES\\\"\\n << \\\"\\\\n\\\";\\n cout << a[n - 1] << \\\" \\\";\\n for (int j = 0; j < n - 1; j++) {\\n cout << a[j] << \\\" \\\";\\n }\\n cout << \\\"\\\\n\\\";\\n }\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"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.\\nSolve the task in JAVA.\",\"targets\":\"\\/*\\nstream Butter!\\neggyHide eggyVengeance\\nI need U\\nxiao rerun when\\n *\\/\\nimport static java.lang.Math.*;\\nimport java.util.*;\\nimport java.io.*;\\nimport java.math.*;\\n\\npublic class x1559E2\\n{\\n static final long MOD = 998244353L;\\n public static void main(String hi[]) throws Exception\\n {\\n BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));\\n StringTokenizer st = new StringTokenizer(infile.readLine());\\n int N = Integer.parseInt(st.nextToken());\\n int M = Integer.parseInt(st.nextToken());\\n int[] left = new int[N];\\n int[] right = new int[N];\\n for(int i=0; i < N; i++)\\n {\\n st = new StringTokenizer(infile.readLine());\\n left[i] = Integer.parseInt(st.nextToken());\\n right[i] = Integer.parseInt(st.nextToken());\\n }\\n long[] ways = new long[M+1];\\n outer:for(int v=1; v <= M; v++)\\n {\\n int CAP = M\\/v;\\n long[] dp = new long[CAP+1];\\n dp[0] = 1L;\\n for(int t=0; t < N; t++)\\n {\\n int min = Integer.MAX_VALUE;\\n int max = 0;\\n for(int i=v; i <= right[t]; i+=v)\\n if(i >= left[t])\\n {\\n min = min(min, i\\/v);\\n max = i\\/v;\\n }\\n if(min == Integer.MAX_VALUE)\\n continue outer;\\n long[] psums = new long[CAP+1];\\n psums[0] = dp[0];\\n for(int i=1; i <= CAP; i++)\\n {\\n psums[i] = psums[i-1]+dp[i];\\n if(psums[i] >= MOD)\\n psums[i] -= MOD;\\n }\\n long[] next = new long[CAP+1];\\n for(int i=min; i <= CAP; i++)\\n {\\n int r = i-min;\\n int l = max(0, i-max);\\n next[i] = psums[r];\\n if(l > 0)\\n next[i] -= psums[l-1];\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"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 CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n ios::sync_with_stdio(false);\\n int t;\\n cin >> t;\\n while (t--) {\\n int n;\\n cin >> n;\\n vector> a(n);\\n for (auto& pair : a) {\\n cin >> pair.second;\\n pair.first = 0;\\n for (int i = 0; i < pair.second; i++) {\\n int j;\\n cin >> j;\\n pair.first = max(pair.first, static_cast(j + 1 - i));\\n }\\n }\\n sort(begin(a), end(a));\\n int64_t min_power = a[0].first;\\n int64_t power = min_power;\\n int64_t beaten = 0;\\n for (auto& pair : a) {\\n if (pair.first >= power) {\\n min_power = pair.first - beaten;\\n power = pair.first;\\n }\\n power += pair.second;\\n beaten += pair.second;\\n }\\n cout << min_power << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A class of students wrote a multiple-choice test.\\n\\nThere are n students in the class. The test had m questions, each of them had 5 possible answers (A, B, C, D or E). There is exactly one correct answer for each question. The correct answer for question i worth a_i points. Incorrect answers are graded with zero points.\\n\\nThe students remember what answers they gave on the exam, but they don't know what are the correct answers. They are very optimistic, so they want to know what is the maximum possible total score of all students in the class. \\n\\nInput\\n\\nThe first line contains integers n and m (1 ≤ n, m ≤ 1000) — the number of students in the class and the number of questions in the test.\\n\\nEach of the next n lines contains string s_i (|s_i| = m), describing an answer of the i-th student. The j-th character represents the student answer (A, B, C, D or E) on the j-th question.\\n\\nThe last line contains m integers a_1, a_2, …, a_m (1 ≤ a_i ≤ 1000) — the number of points for the correct answer for every question.\\n\\nOutput\\n\\nPrint a single integer — the maximum possible total score of the class.\\n\\nExamples\\n\\nInput\\n\\n\\n2 4\\nABCD\\nABCE\\n1 2 3 4\\n\\n\\nOutput\\n\\n\\n16\\n\\nInput\\n\\n\\n3 3\\nABC\\nBCD\\nCDE\\n5 4 12\\n\\n\\nOutput\\n\\n\\n21\\n\\nNote\\n\\nIn the first example, one of the most optimal test answers is \\\"ABCD\\\", this way the total number of points will be 16.\\n\\nIn the second example, one of the most optimal test answers is \\\"CCC\\\", this way each question will be answered by exactly one student and the total number of points is 5 + 4 + 12 = 21.\",\"targets\":\"import java.io.BufferedOutputStream;\\nimport java.io.BufferedReader;\\nimport java.io.DataInputStream;\\nimport java.io.FileInputStream;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.io.PrintWriter;\\nimport java.math.BigInteger;\\nimport java.util.ArrayList;\\nimport java.util.Collections;\\nimport java.util.HashMap;\\nimport java.util.HashSet;\\nimport java.util.Scanner;\\nimport java.util.StringTokenizer;\\nimport java.util.TreeMap;\\n\\npublic class wef {\\n\\tpublic static class FastReader {\\n\\t\\tBufferedReader br;\\n\\t\\tStringTokenizer st;\\n\\t\\t\\/\\/it reads the data about the specified point and divide the data about it ,it is quite fast\\n\\t\\t\\/\\/than using direct \\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.hasMoreTokens()) {\\n\\t\\t\\t\\ttry {\\n\\t\\t\\t\\t\\tst = new StringTokenizer(br.readLine());\\n\\t\\t\\t\\t} catch (Exception r) {\\n\\t\\t\\t\\t\\tr.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());\\/\\/converts string to integer\\n\\t\\t}\\n \\n\\t\\tdouble nextDouble() {\\n\\t\\t\\treturn Double.parseDouble(next());\\n\\t\\t}\\n \\n\\t\\tlong nextLong() {\\n\\t\\t\\treturn Long.parseLong(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 (Exception r) {\\n\\t\\t\\t\\tr.printStackTrace();\\n\\t\\t\\t}\\n\\t\\t\\treturn str;\\n\\t\\t}\\n\\t}\\n\\t\\n\\tpublic static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));\\n \\n\\t static int lowerBound(ArrayList list, int length, long val) {\\n int low = 0;\\n int high = length;\\n while (low < high) {\\n final int mid = (low + high) \\/ 2;\\n if (val <= list.get(mid)) {\\n high = mid;\\n } else {\\n low = mid + 1;\\n }\\n }\\n return low;\\n }\\n\\tpublic static void main(String[] args) throws IOException {\\n\\t\\t\\/\\/ TODO Auto-generated method stub\\nFastReader in=new FastReader();\\nHashSetset=new HashSet();\\nArrayListlist=new...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"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.io.*;\\nimport java.util.*;\\nimport java.lang.*;\\nimport static java.lang.Math.*;\\n\\n\\/\\/ Sachin_2961 submission \\/\\/\\npublic class Codeforces {\\n\\n public void solve() {\\n long l = fs.nLong(), r = fs.nLong();\\n if( l == r){\\n out.println(\\\"0\\\");\\n return;\\n }\\n if(2*l > r ){\\n long ans = r%l;\\n out.println(ans);\\n return;\\n }\\n long ans = r\\/2 - (r%2==0?1:0);\\n out.println(ans);\\n }\\n static boolean multipleTestCase = true; static FastScanner fs; static PrintWriter out;\\n public void run(){\\n fs = new FastScanner();\\n out = new PrintWriter(System.out);\\n\\n int tc = (multipleTestCase)?fs.nInt():1;\\n while (tc-->0)solve();\\n out.flush();\\n out.close();\\n }\\n public static void main(String[]args){\\n try{\\n new Codeforces().run();\\n }catch (Exception e){\\n e.printStackTrace();\\n }\\n\\n }\\n static class FastScanner {\\n BufferedReader br=new BufferedReader(new InputStreamReader(System.in));\\n StringTokenizer st=new StringTokenizer(\\\"\\\");\\n String n() {\\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 String Line()\\n {\\n String str = \\\"\\\";\\n try\\n {\\n str = br.readLine();\\n }catch (IOException e)\\n {\\n e.printStackTrace();\\n }\\n return str;\\n }\\n int nInt() {return Integer.parseInt(n()); }\\n long nLong() {return Long.parseLong(n());}\\n double nDouble(){return Double.parseDouble(n());}\\n int[]aI(int n){\\n int[]ar = new int[n];\\n for(int i=0;i\\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\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\npair operator+(pair a, pair b) {\\n return {a.first + b.first, a.second + b.second};\\n}\\nbool operator<(pair a, pair b) {\\n return a.first < b.first && a.second < b.second;\\n}\\nbool operator>=(pair a, pair b) {\\n return a.first >= b.first && a.second >= b.second;\\n}\\nint steps(pair cur, vector> &board,\\n vector> &dir, int p) {\\n int ans = 0;\\n pair low = {0, 0}, high = {board.size(), board[0].size()};\\n do {\\n ++ans;\\n cur = cur + dir[p];\\n p = (p + 1) % dir.size();\\n } while (cur >= low && cur < high && board[cur.first][cur.second]);\\n return ans;\\n}\\nint main() {\\n ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);\\n int n, m, q;\\n cin >> n >> m >> q;\\n long long total = 0;\\n vector> board(n, vector(m, 1));\\n for (int i = 0; i < n; ++i)\\n for (int j = 0; j < m; ++j)\\n total += min(i + 1, j) + min(i, j + 1) + 2 * min(i, j) + 1;\\n vector> m1 = {{-1, 0}, {0, -1}};\\n vector> m2 = {{0, 1}, {1, 0}};\\n for (int x, y, aux = 0; q--; aux = 0) {\\n cin >> x >> y, --x, --y;\\n for (int k = 0; k < m1.size(); ++k)\\n aux += steps({x, y}, board, m1, k) * steps({x, y}, board, m2, k);\\n total += (board[x][y] ? -aux + 1 : aux - 1);\\n board[x][y] = !board[x][y];\\n cout << total << '\\\\n';\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Monocarp wants to draw four line segments on a sheet of paper. He wants the i-th segment to have its length equal to a_i (1 ≤ i ≤ 4). These segments can intersect with each other, and each segment should be either horizontal or vertical.\\n\\nMonocarp wants to draw the segments in such a way that they enclose a rectangular space, and the area of that rectangular space should be maximum possible.\\n\\nFor example, if Monocarp wants to draw four segments with lengths 1, 2, 3 and 4, he can do it the following way:\\n\\n Here, Monocarp has drawn segments AB (with length 1), CD (with length 2), BC (with length 3) and EF (with length 4). He got a rectangle ABCF with area equal to 3 that is enclosed by the segments.\\n\\nCalculate the maximum area of a rectangle Monocarp can enclose with four segments.\\n\\nInput\\n\\nThe first line contains one integer t (1 ≤ t ≤ 3 ⋅ 10^4) — the number of test cases.\\n\\nEach test case consists of a single line containing four integers a_1, a_2, a_3, a_4 (1 ≤ a_i ≤ 10^4) — the lengths of the segments Monocarp wants to draw.\\n\\nOutput\\n\\nFor each test case, print one integer — the maximum area of a rectangle Monocarp can enclose with four segments (it can be shown that the answer is always an integer).\\n\\nExample\\n\\nInput\\n\\n\\n4\\n1 2 3 4\\n5 5 5 5\\n3 1 4 1\\n100 20 20 100\\n\\n\\nOutput\\n\\n\\n3\\n25\\n3\\n2000\\n\\nNote\\n\\nThe first test case of the example is described in the statement.\\n\\nFor the second test case, Monocarp can draw the segments AB, BC, CD and DA as follows:\\n\\n Here, Monocarp has drawn segments AB (with length 5), BC (with length 5), CD (with length 5) and DA (with length 5). He got a rectangle ABCD with area equal to 25 that is enclosed by the segments.\\\":\",\"targets\":\"#include\\n#define lld long long int\\n#define ulld unsigned long long int\\ntypedef long long ll;\\nusing namespace std;\\nvoid solve(){\\n lld n;\\n lld arr[4];\\n cin>>arr[0]>>arr[1]>>arr[2]>>arr[3];\\n sort(arr,arr+4);\\n cout<>t;\\n while(t--)\\n { \\n solve();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"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 JAVA.\",\"targets\":\"import java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.util.*;\\n\\n\\tpublic class practice{\\n\\t\\tpublic static void main(String[] args){\\n\\t\\t\\tFastScanner r = new FastScanner();\\t\\t\\t\\t\\t\\n\\t\\t\\tint t = r.i() ,n,m;\\n\\t\\t\\tpair[] ar;\\n\\t\\t\\tpair[][] arr;\\n\\t\\t\\tint count,te;\\n\\t\\t\\tStringBuffer ans = new StringBuffer(\\\"\\\");\\n\\t\\t\\twhile(t-->0) {\\n\\t\\t\\t\\tn = r.i();\\n\\t\\t\\t\\tm = r.i();\\n\\t\\t\\t\\tar = new pair[n*m];\\n\\t\\t\\t\\tfor(int i=0;i() {\\n\\t\\t\\t\\t\\tpublic int compare(pair x, pair y) {\\n\\t\\t\\t\\t\\t\\treturn x.a -y.a;\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t});\\n\\t\\t\\t\\t\\n\\t\\t\\t\\tte=0;\\n\\t\\t\\t\\tarr = new pair[n][m];\\n\\t\\t\\t\\tfor(int i=0;i void p(T s) {\\n\\t\\t\\tSystem.out.println(s);\\n\\t\\t}\\n\\t\\t\\n\\t\\tstatic void p() {\\n\\t\\t\\tSystem.out.println();\\n\\t\\t}\\t\\t\\n\\t\\tstatic void pn(T s) {\\n\\t\\t\\tSystem.out.print(s);\\n\\t\\t}\\n\\n\\t}\\n\\t\\t\\n\\n\\tclass pair implements Comparable{\\n\\t\\tint a, b;\\n\\t\\tpair(int a, int b){\\n\\t\\t\\tthis.a=a;\\n\\t\\t\\tthis.b=b;;\\n\\t\\t}\\n\\t\\t\\n\\t\\tpublic String toString() {\\n\\t\\t\\treturn \\\"[\\\" +a + \\\" \\\" + b + \\\"]\\\";\\n\\t\\t}\\n\\t\\tpublic int compareTo(pair x) {\\n\\t\\t\\tif(this.a == x.a)\\n\\t\\t\\t\\treturn x.b-this.b;\\n\\t\\t\\treturn this.a -x.a;\\n\\t\\t}\\n\\t}\\n\\tclass FastScanner {\\n\\t BufferedReader br=new BufferedReader(new InputStreamReader(System.in));\\n\\t StringTokenizer st=new StringTokenizer(\\\"\\\");\\n\\t String n() {\\n\\t while (!st.hasMoreTokens())\\n\\t try {\\n\\t st=new StringTokenizer(br.readLine());\\n\\t } catch (IOException e) {\\n\\t e.printStackTrace();\\n\\t }\\n\\t return st.nextToken();\\n\\t }\\n\\t int[]...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"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 python3 can you solve the prior task?\",\"targets\":\"from math import ceil\\na = list(i**2 for i in range(1,31624))\\nfor t in range(int(input())):\\n k = int(input())\\n for b in a:\\n if(b < k):\\n continue\\n else:\\n p2 = b\\n break\\n p1 = a[(a.index(p2)) - 1]\\n ind = ceil((p1+p2)\\/2)\\n if(k==1):\\n print(1, 1)\\n elif(k==ind):\\n print(int(p2**0.5), int(p2**0.5))\\n elif(k 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 JAVA.\",\"targets\":\"import java.util.*;\\nimport java.lang.*;\\nimport java.io.*;\\n\\npublic class Main\\n{\\n static long mod = (int)1e9+7;\\n \\/\\/ static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));\\n\\tpublic static void main (String[] args) throws java.lang.Exception\\n\\t{\\n\\t\\tFastReader sc =new FastReader();\\n\\t\\t\\n\\t int t=sc.nextInt();\\n\\t \\n\\t \\/\\/ int t=1;\\n\\t \\n\\t while(t-->0)\\n\\t {\\n\\t int n = sc.nextInt();\\n\\t int arr[] = sc.readArray(n);\\n\\t int maxi = 0;\\n\\t int ind = -1;\\n\\t for(int i=0;i= maxi)\\n\\t {\\n\\t maxi = arr[i];\\n\\t ind = i;\\n\\t }\\n\\t }\\n\\t int store = arr[n - 1];\\n\\t int ans = 0;\\n\\t \\n\\t for(int i=n-1;i>=0;i--)\\n\\t {\\n\\t if(store == maxi)\\n\\t {\\n\\t break;\\n\\t }\\n\\t else\\n\\t {\\n\\t if(arr[i] > store)\\n\\t {\\n\\t store = arr[i];\\n\\t ans++;\\n\\t }\\n\\t }\\n\\t }\\n\\t System.out.println(ans);\\n\\t }\\n\\t \\n\\t}\\n\\t\\n\\t\\n\\t\\n\\t\\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 float nextFloat()\\n {\\n return Float.parseFloat(next());\\n }\\n \\n String nextLine()\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of n stations, enumerated from 1 through n. The train occupies one station at a time and travels around the network of stations in a circular manner. More precisely, the immediate station that the train will visit after station i is station i+1 if 1 ≤ i < n or station 1 if i = n. It takes the train 1 second to travel to its next station as described.\\n\\nBob gave Alice a fun task before he left: to deliver m candies that are initially at some stations to their independent destinations using the train. The candies are enumerated from 1 through m. Candy i (1 ≤ i ≤ m), now at station a_i, should be delivered to station b_i (a_i ≠ b_i).\\n\\n The blue numbers on the candies correspond to b_i values. The image corresponds to the 1-st example.\\n\\nThe train has infinite capacity, and it is possible to load off any number of candies at a station. However, only at most one candy can be loaded from a station onto the train before it leaves the station. You can choose any candy at this station. The time it takes to move the candies is negligible.\\n\\nNow, Alice wonders how much time is needed for the train to deliver all candies. Your task is to find, for each station, the minimum time the train would need to deliver all the candies were it to start from there.\\n\\nInput\\n\\nThe first line contains two space-separated integers n and m (2 ≤ n ≤ 5 000; 1 ≤ m ≤ 20 000) — the number of stations and the number of candies, respectively.\\n\\nThe i-th of the following m lines contains two space-separated integers a_i and b_i (1 ≤ a_i, b_i ≤ n; a_i ≠ b_i) — the station that initially contains candy i and the destination station of the candy, respectively.\\n\\nOutput\\n\\nIn the first and only line, print n space-separated integers, the i-th of which is the minimum time, in seconds, the train would need to deliver all the candies were it to start from station i.\\n\\nExamples\\n\\nInput\\n\\n\\n5 7\\n2 4\\n5 1\\n2 3\\n3 4\\n4 1\\n5 3\\n3 5\\n\\n\\nOutput\\n\\n\\n10 9 10 10 9 \\n\\n\\nInput\\n\\n\\n2...\",\"targets\":\"#include \\nusing namespace std;\\nlong long gcd(long long a, long long b) { return !a ? b : gcd(b % a, a); }\\nint ans[5001], n, dist[5001], k[5001];\\nint dst(int a, int b) { return b >= a ? b - a : n - a + b; }\\nbool pr(int a, int b) {\\n if (b > a)\\n return b - a < dst(a, dist[a]);\\n else\\n return n - a + b < dst(a, dist[a]);\\n}\\nint main() {\\n cout.tie(0), cin.tie(0), ios_base::sync_with_stdio(0);\\n int m, i, j, x, y;\\n cin >> n >> m;\\n for (i = 0; i < m; i++) {\\n cin >> x >> y;\\n k[x]++;\\n if (!dist[x] || pr(x, y)) dist[x] = y;\\n }\\n for (i = 1; i <= n; i++) {\\n for (j = 1; j <= n; j++) {\\n if (!k[j]) continue;\\n ans[i] = max(ans[i], dst(i, j) + n * (k[j] - 1) + dst(j, dist[j]));\\n }\\n }\\n for (i = 1; i <= n; i++) cout << ans[i] << ' ';\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"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 \\n#pragma GCC optimize(\\\"Ofast\\\")\\n#pragma GCC target(\\\"avx,avx2,fma\\\")\\n#pragma GCC optimization(\\\"O3\\\")\\n#pragma GCC optimization(\\\"unroll-loops\\\")\\nusing namespace std;\\nconst int mod = 1e9 + 7;\\nconst int N = 1e6 + 10;\\nconst long long inf = 1e18;\\nconst int maxm = 1005;\\nvector> matrix(maxm, vector(maxm));\\nstruct event {\\n int x, y, size;\\n};\\nint dx[] = {1, 0, -1, 0};\\nint dy[] = {0, -1, 0, 1};\\nstruct myComp {\\n constexpr bool operator()(pair const& a,\\n pair const& b) const noexcept {\\n return a.first < b.first;\\n }\\n};\\nclass even {\\n public:\\n int a, b, c, ind;\\n};\\nlong long poww(long long a, long long b, long long m) {\\n if (b == 0) return 1ll;\\n if (b % 2 == 1) return a * poww(a, b - 1, m) % m;\\n long long rs = poww(a, b \\/ 2, m);\\n rs = rs * rs % m;\\n return rs;\\n}\\nlong long fact[N];\\nlong long ncr(long long n, long long r) {\\n long long num = fact[n];\\n long long deno = fact[n - r] * fact[r] % mod;\\n deno = poww(deno, mod - 2, mod);\\n num = num * deno;\\n num = num % mod;\\n return num;\\n}\\nvector parent(N), st(N);\\nvoid set_parent() {\\n for (int i = 0; i < N; i++) parent[i] = i, st[i] = 1;\\n}\\nint find_parent(int v) {\\n if (parent[v] == v)\\n return v;\\n else\\n return parent[v] = find_parent(parent[v]);\\n}\\nint x = 1;\\nvoid union_set(int a, int b) {\\n int temp = a;\\n if (a == b) return;\\n a = find_parent(a);\\n b = find_parent(b);\\n if (a == b) {\\n x = temp;\\n return;\\n }\\n if (st[a] < st[b]) swap(a, b);\\n st[a] += st[b];\\n parent[b] = a;\\n}\\nconst int maxx = 1e7 + 10;\\nvector spf(maxx, -1);\\nvoid sieve() {\\n spf[1] = 1;\\n for (long long i = 2; i * i < maxx; i++) {\\n if (spf[i] == -1) {\\n spf[i] = i;\\n for (long long j = i * i; j < maxx; j += i) {\\n if (spf[j] == -1) spf[j] = i;\\n }\\n }\\n }\\n}\\nbool ok(int mid, int n, int m) {\\n int res = 0;\\n for (int i = 0; i < 32; i++) {\\n if (mid & (1 << i)) {\\n if (n & (1 << i)) {\\n } else\\n res += 1 << i;\\n } else {\\n if (n & (1 << i)) res += 1...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"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.\\\":\",\"targets\":\"#include \\nusing namespace std;\\nconst long long MAXN = 2e5 + 5;\\nconst long long SQRTN = 1003;\\nconst long long LOGN = 22;\\nconst double PI = acos(-1);\\nconst long long INF = 1e18;\\nconst long long MOD = 1e9 + 7;\\nconst long long FMOD = 998244353;\\nconst double eps = 1e-9;\\nvoid __print(long long x) { cerr << x; }\\nvoid __print(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 long long 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}\\nmt19937 RNG(chrono::steady_clock::now().time_since_epoch().count());\\ntemplate \\nT gcd(T a, T b) {\\n if (b == 0) return a;\\n a %= b;\\n return gcd(b, a);\\n}\\ntemplate \\nT lcm(T a, T b) {\\n return (a * (b \\/ gcd(a, b)));\\n}\\nlong long add(long long a, long long b, long long c = MOD) {\\n long long res = a + b;\\n return (res >= c ? res % c : res);\\n}\\nlong long sub(long long a, long long b, long long c = MOD) {\\n long long res;\\n if (abs(a - b) < c)\\n res = a - b;\\n else\\n res = (a - b) % c;\\n return (res < 0 ? res + c : res);\\n}\\nlong long mul(long long a, long long b, long long c = MOD) {\\n long long res = (long long)a * b;\\n return (res >= c ? res % c : res);\\n}\\nlong long muln(long long a, long long b,...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"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\\nSolve the task in PYTHON.\",\"targets\":\"from __future__ import division\\nimport sys\\ninput = sys.stdin.readline\\nimport math\\nfrom math import sqrt, floor, ceil\\nfrom collections import Counter\\nfrom copy import deepcopy as dc\\n# from statistics import median, mean\\n\\n\\n############ ---- Input Functions ---- ############\\ndef inp():\\n return(int(input()))\\ndef inlt():\\n return(list(map(int,input().split())))\\ndef insr():\\n s = input()\\n return(list(s[:len(s) - 1]))\\ndef invr():\\n return(map(int,input().split()))\\ndef insr2():\\n s = input()\\n return(s.split(\\\" \\\"))\\n\\ndef prime_factorization(n):\\n\\n if n == 1:\\n return [1]\\n\\n ans=[]\\n i = 2\\n cap = sqrt(n)\\n while i <= cap:\\n if n % i == 0:\\n ans.append(i)\\n n = n\\/\\/i\\n cap=sqrt(n)\\n else:\\n i += 1\\n if n > 1:\\n ans.append(n)\\n return ans\\n\\ndef binomial(n, k):\\n if n == 1 or n == k:\\n return 1\\n\\n if k > n:\\n return 0 \\n else:\\n a = math.factorial(n)\\n b = math.factorial(k)\\n c = math.factorial(n-k)\\n div = a \\/\\/ (b * c)\\n return div\\n\\ndef small_divisor(n):\\n\\n if n % 2 == 0:\\n return 2\\n\\n i = 3\\n while i*i <= n:\\n if n%i == 0:\\n return i\\n i += 2\\n\\n return n \\n\\n\\nn = inp()\\narr1 = invr()\\narr2 = invr()\\n\\ndp = [[0]*3 for i in range(n)]\\n\\ndp[-1][0] = 0\\ndp[-1][1] = 0\\ndp[-1][2] = 0\\n\\n#0-not choosing anyone\\\\\\n#1 - choosing from top row\\n#2 - choosing from bottom row\\n\\ndp[0][0] = 0\\ndp[0][1] = arr1[0]\\ndp[0][2] = arr2[0]\\n\\nfor i in range(1,n):\\n\\n dp[i][0] = max(dp[i-1][0],dp[i-1][1],dp[i-1][2])\\n\\n dp[i][1] = arr1[i] + max(dp[i-1][0],dp[i-1][2])\\n dp[i][2] = arr2[i] + max(dp[i-1][0],dp[i-1][1])\\n\\nprint max(dp[n-1][0], dp[n-1][1], dp[n-1][2])\",\"language\":\"python\",\"split\":\"train\",\"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...\\nUsing python3 can you solve the prior task?\",\"targets\":\"for i in range(int(input())):\\n a=input()\\n a=list(a)\\n total=0\\n box=[]\\n for i in a:\\n if i not in box:\\n box.append(i)\\n x=min(2,a.count(i))\\n total+=x\\n\\n print(total\\/\\/2)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nOn an endless checkered sheet of paper, n cells are chosen and colored in three colors, where n is divisible by 3. It turns out that there are exactly n\\/3 marked cells of each of three colors! \\n\\nFind the largest such k that it's possible to choose k\\/3 cells of each color, remove all other marked cells, and then select three rectangles with sides parallel to the grid lines so that the following conditions hold:\\n\\n * No two rectangles can intersect (but they can share a part of the boundary). In other words, the area of intersection of any two of these rectangles must be 0.\\n * The i-th rectangle contains all the chosen cells of the i-th color and no chosen cells of other colors, for i = 1, 2, 3. \\n\\nInput\\n\\nThe first line of the input contains a single integer n — the number of the marked cells (3 ≤ n ≤ 10^5, n is divisible by 3).\\n\\nThe i-th of the following n lines contains three integers x_i, y_i, c_i (|x_i|,|y_i| ≤ 10^9; 1 ≤ c_i ≤ 3), where (x_i, y_i) are the coordinates of the i-th marked cell and c_i is its color.\\n\\nIt's guaranteed that all cells (x_i, y_i) in the input are distinct, and that there are exactly n\\/3 cells of each color.\\n\\nOutput\\n\\nOutput a single integer k — the largest number of cells you can leave.\\n\\nExamples\\n\\nInput\\n\\n\\n9\\n2 3 1\\n4 1 2\\n2 1 3\\n3 4 1\\n5 3 2\\n4 4 3\\n2 4 1\\n5 2 2\\n3 5 3\\n\\n\\nOutput\\n\\n\\n6\\n\\n\\nInput\\n\\n\\n3\\n1 1 1\\n2 2 2\\n3 3 3\\n\\n\\nOutput\\n\\n\\n3\\n\\nNote\\n\\nIn the first sample, it's possible to leave 6 cells with indexes 1, 5, 6, 7, 8, 9.\\n\\nIn the second sample, it's possible to leave 3 cells with indexes 1, 2, 3.\",\"targets\":\"#include \\nusing namespace std;\\nint n, X[100005], Y[100005], C[100005];\\nint ax[100005], ay[100005], ix, iy;\\nstruct Nod {\\n int x, y, c;\\n Nod(int _x = 0, int _y = 0, int _c = 0) : x(_x), y(_y), c(_c) {}\\n} dx[100005], dy[100005];\\ninline bool cmpx(const Nod &a, const Nod &b) { return a.x < b.x; }\\ninline bool cmpy(const Nod &a, const Nod &b) { return a.y < b.y; }\\nint getx(int i, int x, int v) {\\n while (i && i <= n && dx[i].x == x) i += v;\\n return i > n ? 0 : i;\\n}\\nint prex(int st, int c, int k) {\\n if (!st) return 0;\\n for (int i = st; i >= 1; --i)\\n if (dx[i].c == c) {\\n if (!(--k)) return i;\\n }\\n return 0;\\n}\\nint nxtx(int st, int c, int k) {\\n if (!st) return 0;\\n for (int i = st; i <= n; ++i)\\n if (dx[i].c == c) {\\n if (!(--k)) return i;\\n }\\n return 0;\\n}\\nint gety(int i, int y, int v) {\\n while (i && i <= n && dy[i].y == y) i += v;\\n return i > n ? 0 : i;\\n}\\nint prey(int st, int c, int k) {\\n if (!st) return 0;\\n for (int i = st; i >= 1; --i)\\n if (dy[i].c == c) {\\n if (!(--k)) return i;\\n }\\n return 0;\\n}\\nint nxty(int st, int c, int k) {\\n if (!st) return 0;\\n for (int i = st; i <= n; ++i)\\n if (dy[i].c == c) {\\n if (!(--k)) return i;\\n }\\n return 0;\\n}\\nbool Judge(int c1, int c2, int c3, int k) {\\n int p, lft, lx, ly;\\n p = 1;\\n p = nxtx(p, c1, k);\\n p = getx(p, dx[p].x, 1);\\n p = nxtx(p, c2, k);\\n p = getx(p, dx[p].x, 1);\\n p = nxtx(p, c3, k);\\n if (p) return true;\\n p = 1;\\n p = nxty(p, c1, k);\\n p = gety(p, dy[p].y, 1);\\n p = nxty(p, c2, k);\\n p = gety(p, dy[p].y, 1);\\n p = nxty(p, c3, k);\\n if (p) return true;\\n lft = k;\\n for (int i = 1; i <= n; ++i)\\n if (dx[i].c == c1) {\\n if (!(--lft)) {\\n lx = dx[i].x;\\n break;\\n }\\n }\\n lft = k;\\n for (int i = 1; i <= n; ++i)\\n if (dy[i].c == c2 && dy[i].x > lx) {\\n if (!(--lft)) {\\n ly = dy[i].y;\\n break;\\n }\\n }\\n if (!lft) {\\n lft = k;\\n for (int i = 1; i <= n; ++i)\\n if (dy[i].c == c3 && dy[i].x > lx && dy[i].y > ly) {\\n if (!(--lft)) break;\\n }\\n if...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"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...\\nUsing python3 can you solve the prior task?\",\"targets\":\"t = int(input().strip())\\n\\ndef breaks(serves, won):\\n bs = []\\n for i in range(won+1):\\n bs.append(serves-i+(won-i))\\n return bs\\n\\nfor _ in range(t):\\n a, b = list(map(int, input().strip().split()))\\n games = a+b\\n mini = min(a,b)\\n bs = []\\n half = games\\/\\/2\\n bs.extend(breaks(half, mini))\\n if games%2==1:\\n half += 1\\n bs.extend(breaks(half, mini))\\n bs.sort()\\n print(len(bs))\\n print(*bs)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"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\":\"import java.util.*;\\nimport java.io.*;\\npublic class Sol{\\n \\n\\/* \\n->check n=1, int overflow , array bounds , all possibilites(dont stuck on 1 approach)\\n->Problem = Observation(constraints(m<=n\\/3 or k<=min(100,n)) \\n + Thinking + Technique (seg_tree,binary lift,rmq,bipart,dp,connected comp etc)\\n->solve or leave it (- tutorial improves you in minimal way -)\\n*\\/\\n \\npublic static void main (String []args) {\\n\\/\\/precomp();\\n\\nint times=ni();while(times-->0){solve();}out.close();}\\n\\nstatic void solve() {\\n int A=26;\\n char cc[]=in.nextLine().toCharArray();\\nint n = cc.length;\\n\\t\\t\\tint[] kk = new int[A];\\n\\t\\t\\tint cnt = 0;\\n\\t\\t\\tfor (int i = 0; i < n; i++) {\\n\\t\\t\\t\\tint a = cc[i] - 'a';\\n\\t\\t\\t\\tif (kk[a]++ == 0)\\n\\t\\t\\t\\t\\tcnt++;\\n\\t\\t\\t}\\n\\t\\t\\tchar[] rem = new char[cnt];\\n\\t\\t\\tint m = 0;\\n\\t\\t\\tboolean[] used = new boolean[A];\\n\\t\\t\\tfor (int d = cnt, i = n - 1; i >= 0; i--) {\\n\\t\\t\\t\\tint a = cc[i] - 'a';\\n\\t\\t\\t\\tif (used[a])\\n\\t\\t\\t\\t\\tcontinue;\\n\\t\\t\\t\\tused[a] = true;\\n\\t\\t\\t\\tif (kk[a] % d != 0) {\\n\\t\\t\\t\\t\\tout.println(-1);\\n\\t\\t\\t\\t\\treturn;\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tm += kk[a] \\/= d;\\n\\t\\t\\t\\trem[--d] = cc[i];\\n\\t\\t\\t}\\n\\t\\t\\tfor (int r = 1, i = 0, j = m; r < cnt; r++) {\\n\\t\\t\\t\\tint a = rem[r - 1] - 'a';\\n\\t\\t\\t\\tused[a] = false;\\n\\t\\t\\t\\tfor(int j_=j;i 0)\\n {\\n if((y&1)==1)\\n res = (res*x)%mod;\\n y >>= 1;\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"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.\",\"targets\":\"n,k=input().split(' ')\\nn=int(n)\\nk=int(k)\\npoints=input();\\npoints=points.split(' ')\\ncount=0\\nfor i in range(0,n):\\n if int(points[k-1])<=int(points[i]) and int(points[i])!=0:\\n count=count+1\\nprint(count)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in PYTHON3?\\nThe 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 bisect import bisect_left\\nn, k = map(int, input().split())\\nc = list(map(int, input().split()))\\na = [[] for _ in range(n)]\\nfor i in range(n * k):\\n a[c[i] - 1].append(i)\\nt = -1\\nd = [0] * n\\ncnt = 0\\nresa = [0] * n\\nresb = [0] * n\\nwhile cnt < n:\\n mi = 10000\\n mj = -1\\n midx = 0\\n for j in range(n):\\n if d[j] == 0:\\n idx = bisect_left(a[j], t)\\n if idx < k - 1:\\n if mi > a[j][idx + 1]:\\n mi = a[j][idx + 1]\\n mj = j\\n midx = idx\\n if mj == -1:\\n t = -1\\n else:\\n resa[mj] = a[mj][midx] + 1\\n resb[mj] = a[mj][midx + 1] + 1\\n cnt += 1\\n d[mj] = 1\\n t = mi\\nfor i in range(n):\\n print(resa[i], resb[i])\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"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.\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nconst int maxn = 2e5 + 10;\\nconst int bc = 450;\\nint n, m, bl;\\nint x[maxn], y[maxn];\\nint d[maxn];\\nint d2[bc][bc];\\nint ans[maxn], be[maxn];\\nvoid block_update(int p, int id, int v) {\\n int t = x[id] + y[id];\\n int l = (p + x[id]) % t, r = (p - 1) % t;\\n if (l <= r) {\\n for (int i = l; i <= r; ++i) d2[t][i] += v;\\n } else {\\n for (int i = 0; i <= r; ++i) d2[t][i] += v;\\n for (int i = l; i < t; ++i) d2[t][i] += v;\\n }\\n}\\nint block_query(int p) {\\n int sum = 0;\\n for (int i = 2; i <= bl; ++i) sum += d2[i][p % i];\\n return sum;\\n}\\nint main() {\\n ios::sync_with_stdio(false);\\n cin.tie(NULL);\\n cin >> n >> m;\\n bl = min((int)sqrt(m) + 1, bc);\\n for (int i = (1); i <= (int)(n); ++i) cin >> x[i] >> y[i];\\n for (int i = (1); i <= (int)(m); ++i) {\\n int op, k;\\n cin >> op >> k;\\n if (op == 1) {\\n if (x[k] + y[k] >= bl) {\\n for (int j = i + x[k]; j <= m; j += x[k] + y[k]) {\\n ++d[j];\\n if (j + y[k] <= m) --d[j + y[k]];\\n }\\n } else\\n block_update(i, k, 1);\\n be[k] = i;\\n } else {\\n if (x[k] + y[k] >= bl) {\\n for (int j = be[k] + x[k]; j <= m; j += x[k] + y[k]) {\\n if (j <= i && j + y[k] > i) {\\n --d[i];\\n if (j + y[k] <= m) ++d[j + y[k]];\\n } else if (j > i) {\\n --d[j];\\n if (j + y[k] <= m) ++d[j + y[k]];\\n }\\n }\\n } else\\n block_update(be[k], k, -1);\\n }\\n ans[i] = block_query(i);\\n }\\n for (int i = (1); i <= (int)(m); ++i) {\\n d[i] += d[i - 1];\\n printf(\\\"%d\\\\n\\\", d[i] + ans[i]);\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"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 00){\\n long n=sc.nextLong();\\n \\n System.out.println(CountPermutations(n));\\n }\\n }static long CountPermutations(long n)\\n {\\n long result=1;\\n long min=(long)1e9+7;\\n long k=2*n;\\n for(long i=k;i>=3;i--)\\n {\\n result=((result*i)% min);\\n }\\n result=result%min;\\n return result;\\n \\n }\\n \\n \\n \\n \\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Luntik came out for a morning stroll and found an array a of length n. He calculated the sum s of the elements of the array (s= ∑_{i=1}^{n} a_i). Luntik calls a subsequence of the array a nearly full if the sum of the numbers in that subsequence is equal to s-1.\\n\\nLuntik really wants to know the number of nearly full subsequences of the array a. But he needs to come home so he asks you to solve that problem!\\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\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases. The next 2 ⋅ t lines contain descriptions 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 ≤ 60) — the length of the array.\\n\\nThe second line contains n integers a_1, a_2, …, a_n (0 ≤ a_i ≤ 10^9) — the elements of the array a.\\n\\nOutput\\n\\nFor each test case print the number of nearly full subsequences of the array.\\n\\nExample\\n\\nInput\\n\\n\\n5\\n5\\n1 2 3 4 5\\n2\\n1000 1000\\n2\\n1 0\\n5\\n3 0 2 1 1\\n5\\n2 1 0 3 0\\n\\n\\nOutput\\n\\n\\n1\\n0\\n2\\n4\\n4\\n\\nNote\\n\\nIn the first test case, s=1+2+3+4+5=15, only (2,3,4,5) is a nearly full subsequence among all subsequences, the sum in it is equal to 2+3+4+5=14=15-1.\\n\\nIn the second test case, there are no nearly full subsequences.\\n\\nIn the third test case, s=1+0=1, the nearly full subsequences are (0) and () (the sum of an empty subsequence is 0).\\nUsing python3 can you solve the prior task?\",\"targets\":\"import math\\nt=int(input())\\nwhile(t>0):\\n t-=1\\n n=int(input())\\n l=list(map(int,input().split()))\\n #a,b,c=map(int,input().split())\\n zero=l.count(0)\\n one=l.count(1)\\n print((1<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 CPP.\",\"targets\":\"#include \\nusing namespace std;\\nusing ll = long long;\\nconst ll mod = 1e9 + 7;\\nll fac[1000001];\\nvoid pre() {\\n fac[0] = fac[1] = 1;\\n for (int i = 2; i <= 1000001; i++) {\\n fac[i] = (fac[i - 1] * 1LL * i) % mod;\\n }\\n}\\nll binpower(ll a, ll n) {\\n ll res = 1;\\n while (n) {\\n if (n % 2) res = (res * 1LL * a) % mod;\\n n \\/= 2;\\n a = (a * 1LL * a) % mod;\\n }\\n return res;\\n}\\nll nCrmod(ll n, ll r) {\\n ll res = fac[n];\\n res = (res * 1LL * binpower(fac[r], mod - 2)) % mod;\\n res = (res * 1LL * binpower(fac[n - r], mod - 2)) % mod;\\n return res;\\n}\\nlong long ncr(int n, int r) {\\n if (r > n - r) r = n - r;\\n long long ans = 1;\\n int i;\\n for (i = 1; i <= r; i++) {\\n ans *= n - r + i;\\n ans \\/= i;\\n }\\n return ans;\\n}\\nll modexp(ll a, ll b, ll m) {\\n if (b == 0) return 1;\\n if (b % 2 == 0) {\\n ll y = modexp(a, b \\/ 2, m);\\n return (y * y) % m;\\n } else {\\n return ((a % m) * modexp(a, b - 1, m)) % m;\\n }\\n}\\nll modinv(ll a, ll m) { return modexp(a, m - 2, m); }\\nvoid SieveOfEratosthenes(ll n) {\\n bool prime[n + 1];\\n memset(prime, true, sizeof(prime));\\n for (ll p = 2; p * p <= n; p++) {\\n if (prime[p] == true) {\\n for (ll i = p * p; i <= n; i += p) prime[i] = false;\\n }\\n }\\n for (ll p = 2; p <= n; p++)\\n if (prime[p]) cout << p << \\\" \\\";\\n}\\nvector Centroid(vector g[], int n) {\\n vector centroid;\\n vector sz(n + 1);\\n function dfs = [&](int u, int prev) {\\n sz[u] = 1;\\n bool is_centroid = true;\\n for (auto v : g[u])\\n if (v != prev) {\\n dfs(v, u);\\n sz[u] += sz[v];\\n if (sz[v] > n \\/ 2) is_centroid = false;\\n }\\n if (n - sz[u] > n \\/ 2) is_centroid = false;\\n if (is_centroid) centroid.push_back(u);\\n };\\n dfs(1, 0);\\n return centroid;\\n}\\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 vector a(n);\\n for (int i = 0; i < n; i++) cin >> a[i];\\n string s;\\n cin >> s;\\n vector> dis, lik;\\n for (int i = 0; i < n; i++) {\\n...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"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()(())\\nSolve the task in PYTHON3.\",\"targets\":\"t = int(input())\\nfor i in range(t):\\n si = int(input())\\n for j in range(si):\\n print(\\\"(\\\",end=\\\"\\\")\\n for k in range(j):\\n print(\\\"(\\\",end=\\\"\\\")\\n for l in range(j):\\n print(\\\")\\\",end=\\\"\\\")\\n print(\\\")\\\",end=\\\"\\\")\\n for m in range(si-1-j):\\n print(\\\"()\\\",end=\\\"\\\")\\n print()\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"In this problem you have to simulate the workflow of one-thread server. There are n queries to process, the i-th will be received at moment ti and needs to be processed for di units of time. All ti are guaranteed to be distinct.\\n\\nWhen a query appears server may react in three possible ways: \\n\\n 1. If server is free and query queue is empty, then server immediately starts to process this query. \\n 2. If server is busy and there are less than b queries in the queue, then new query is added to the end of the queue. \\n 3. If server is busy and there are already b queries pending in the queue, then new query is just rejected and will never be processed. \\n\\n\\n\\nAs soon as server finished to process some query, it picks new one from the queue (if it's not empty, of course). If a new query comes at some moment x, and the server finishes to process another query at exactly the same moment, we consider that first query is picked from the queue and only then new query appears.\\n\\nFor each query find the moment when the server will finish to process it or print -1 if this query will be rejected.\\n\\nInput\\n\\nThe first line of the input contains two integers n and b (1 ≤ n, b ≤ 200 000) — the number of queries and the maximum possible size of the query queue.\\n\\nThen follow n lines with queries descriptions (in chronological order). Each description consists of two integers ti and di (1 ≤ ti, di ≤ 109), where ti is the moment of time when the i-th query appears and di is the time server needs to process it. It is guaranteed that ti - 1 < ti for all i > 1.\\n\\nOutput\\n\\nPrint the sequence of n integers e1, e2, ..., en, where ei is the moment the server will finish to process the i-th query (queries are numbered in the order they appear in the input) or - 1 if the corresponding query will be rejected.\\n\\nExamples\\n\\nInput\\n\\n5 1\\n2 9\\n4 8\\n10 9\\n15 2\\n19 1\\n\\n\\nOutput\\n\\n11 19 -1 21 22 \\n\\n\\nInput\\n\\n4 1\\n2 8\\n4 8\\n10 9\\n15 2\\n\\n\\nOutput\\n\\n10 18 27 -1 \\n\\nNote\\n\\nConsider the first sample. \\n\\n 1. The server will start to process first query at the moment 2 and will finish...\\\":\",\"targets\":\"#include \\ntemplate \\nclass IntegerIterator\\n : public std::iterator {\\n public:\\n explicit IntegerIterator(int value) : value(value) {}\\n IntegerIterator& operator++() {\\n ++value;\\n return *this;\\n }\\n IntegerIterator operator++(int) {\\n IntegerIterator copy = *this;\\n ++value;\\n return copy;\\n }\\n IntegerIterator& operator--() {\\n --value;\\n return *this;\\n }\\n IntegerIterator operator--(int) {\\n IntegerIterator copy = *this;\\n --value;\\n return copy;\\n }\\n T operator*() const { return value; }\\n bool operator==(IntegerIterator rhs) { return value == rhs.value; }\\n bool operator!=(IntegerIterator rhs) { return !(*this == rhs); }\\n\\n private:\\n T value;\\n};\\ntemplate \\nclass IntegerRange {\\n public:\\n IntegerRange(T begin, T end) : begin_(begin), end_(end) { ; }\\n IntegerIterator begin() const { return IntegerIterator(begin_); }\\n IntegerIterator end() const { return IntegerIterator(end_); }\\n\\n private:\\n T begin_;\\n T end_;\\n};\\ntemplate \\nclass ReversedIntegerRange {\\n public:\\n ReversedIntegerRange(T begin, T end) : begin_(begin), end_(end) { ; }\\n std::reverse_iterator> begin() const {\\n return std::reverse_iterator>(\\n IntegerIterator(begin_));\\n }\\n std::reverse_iterator> end() const {\\n return std::reverse_iterator>(IntegerIterator(end_));\\n }\\n\\n private:\\n T begin_;\\n T end_;\\n};\\ntemplate \\nIntegerRange range(T to) {\\n return IntegerRange(0, to);\\n}\\ntemplate \\nIntegerRange range(T from, T to) {\\n return IntegerRange(from, to);\\n}\\ntemplate \\nIntegerRange inclusiveRange(T to) {\\n return IntegerRange(0, to + 1);\\n}\\ntemplate \\nIntegerRange inclusiveRange(T from, T to) {\\n return IntegerRange(from, to + 1);\\n}\\ntemplate \\nReversedIntegerRange downrange(T from) {\\n return ReversedIntegerRange(from, 0);\\n}\\ntemplate...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"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\\nUsing python3 can you solve the prior task?\",\"targets\":\"k,n,w = list(map(int,input().split()))\\nl = []\\nfor i in range(1,w+1):\\n l.append(i*k)\\na = sum(l)\\nif a > n:\\n print(a-n)\\nelse:\\n print(\\\"0\\\")\",\"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 java can you solve the prior task?\",\"targets\":\"import static java.lang.Math.max;\\nimport static java.lang.Math.min;\\nimport static java.lang.Math.abs;\\nimport static java.lang.System.out;\\nimport java.util.*;\\nimport java.io.*;\\nimport java.math.*;\\nimport java.util.Arrays;\\nimport java.util.Collections;\\n\\npublic class a747\\n{\\n\\tpublic static void main(String args[]) throws IOException\\n\\t{\\n\\t \\/\\/ long start = System.currentTimeMillis();\\t\\t\\n\\t\\tint u = 0;\\n\\t\\tBufferedReader br = new BufferedReader( new InputStreamReader(System.in));\\n\\t\\t\\/\\/ System.out.println(\\\"Enter t\\\");\\n\\t\\tint t = Integer.parseInt(br.readLine());\\n\\t\\tdo\\n\\t\\t{\\n\\t\\t\\t\\n\\t\\t\\t\\/\\/ System.out.println(\\\"Enter n\\\");\\n\\t\\t\\tlong n = Long.parseLong(br.readLine());\\n\\t\\t\\tif(n%2 ==1)\\n\\t\\t\\t{\\n\\t\\t\\t\\tSystem.out.println((n-1)\\/2 +\\\" \\\"+(n+1)\\/2);\\n\\t\\t\\t}\\n\\t\\t\\telse\\n\\t\\t\\t{\\n\\t\\t\\t\\tlong k = n;\\n\\t\\t\\t\\tint a = 1;\\n\\t\\t\\t\\twhile(k%2 == 0)\\n\\t\\t\\t\\t{\\n \\n a++;\\n k = k\\/2;\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tlong alpha =(long)Math.pow(2,a) -1;\\n\\t\\t\\t\\tlong d = n\\/(long)Math.pow(2,a-1);\\n\\t\\t\\t\\tlong l = (d - alpha)\\/2;\\n\\t\\t\\t\\tlong r = l + alpha;\\n\\n\\n\\t\\t\\t System.out.println(l+\\\" \\\"+r);\\n\\t\\t\\t}\\n\\n\\t\\t\\t\\n\\t\\t\\t\\n\\t\\t\\t\\n\\n\\n\\n \\n u++;\\n \\n }\\n while(u 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.lang.*;\\nimport java.io.*;\\n\\npublic class solution\\n{\\n public static int color(String n){ \\n HashMap map=new HashMap<>(); \\n char ch[]=n.toCharArray();\\n int l=ch.length;\\n for(char c:ch){\\n if(map.containsKey(c)==false){\\n map.put(c,1);\\n }\\n else{\\n int p=map.get(c);\\n p++;\\n map.put(c,p);\\n }\\n }\\n int cnt=0;\\n for(int k:map.values()){\\n if(k==1){\\n cnt++;\\n }\\n }\\n if(l==1 || l==2){\\n return l-1;\\n }\\n return cnt\\/2+map.size()-cnt;\\n }\\n\\tpublic static void main (String[] args) throws java.lang.Exception\\n\\t{\\n\\t\\tScanner sc=new Scanner(System.in);\\n\\t\\tint t=sc.nextInt();\\n\\t\\twhile(t-->0){\\n\\t\\t String n=sc.next();\\n\\t\\t int k=color(n);\\n\\t\\t System.out.println(k);;\\n\\t\\t}\\n\\t}\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 solution for \\\"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\\\":\",\"targets\":\"def ii(): return int(input())\\ndef si(): return input()\\ndef mi(): return map(int,input().split())\\ndef msi(): return map(str,input().split())\\ndef li(): return list(mi())\\n\\nt=ii()\\nfor _ in range(t):\\n n=si()\\n a=int('0'+''.join([n[i] for i in range(0,len(n),2)]))\\n b=int('0'+''.join([n[i] for i in range(1,len(n),2)]))\\n \\n print((a+1)*(b+1)-2)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Ayoub had an array a of integers of size n and this array had two interesting properties: \\n\\n * All the integers in the array were between l and r (inclusive). \\n * The sum of all the elements was divisible by 3. \\n\\n\\n\\nUnfortunately, Ayoub has lost his array, but he remembers the size of the array n and the numbers l and r, so he asked you to find the number of ways to restore the array. \\n\\nSince the answer could be very large, print it modulo 10^9 + 7 (i.e. the remainder when dividing by 10^9 + 7). In case there are no satisfying arrays (Ayoub has a wrong memory), print 0.\\n\\nInput\\n\\nThe first and only line contains three integers n, l and r (1 ≤ n ≤ 2 ⋅ 10^5 , 1 ≤ l ≤ r ≤ 10^9) — the size of the lost array and the range of numbers in the array.\\n\\nOutput\\n\\nPrint the remainder when dividing by 10^9 + 7 the number of ways to restore the array.\\n\\nExamples\\n\\nInput\\n\\n\\n2 1 3\\n\\n\\nOutput\\n\\n\\n3\\n\\n\\nInput\\n\\n\\n3 2 2\\n\\n\\nOutput\\n\\n\\n1\\n\\n\\nInput\\n\\n\\n9 9 99\\n\\n\\nOutput\\n\\n\\n711426616\\n\\nNote\\n\\nIn the first example, the possible arrays are : [1,2], [2,1], [3, 3].\\n\\nIn the second example, the only possible array is [2, 2, 2].\\nSolve the task in JAVA.\",\"targets\":\"import java.util.*;\\nimport java.awt.List;\\nimport java.io.*;\\nimport java.lang.*;\\nimport java.lang.reflect.Array;\\npublic class c3 \\n{\\n\\n\\t\\n\\tpublic static int mod = (int)Math.pow(10, 9) + 7;\\n \\n public static void main(String[] args)\\n {\\n InputReader in = new InputReader(System.in);\\n PrintWriter pw = new PrintWriter(System.out);\\n\\n \\/\\/ Code starts..\\n\\n \\n \\n int n = in.nextInt();\\n int l = in.nextInt();\\n int r = in.nextInt();\\n \\n int dif = r - l+1;\\n \\n int one = dif\\/3;\\n int two = dif\\/3;\\n int thr = dif \\/3 ;\\n \\n int tmp = l + (dif\\/3)*3 ;\\n for(int i=0; i\\nusing namespace std;\\nconst long long mod = 998244353;\\nint main() {\\n ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);\\n int _;\\n cin >> _;\\n while (_--) {\\n int n;\\n cin >> n;\\n int ans = 0;\\n for (int i = 1; i <= n; i++) {\\n char c;\\n cin >> c;\\n int x = c - '0';\\n if (i == n && x) {\\n ans += x;\\n break;\\n }\\n if (x) ans += x + 1;\\n }\\n cout << ans << '\\\\n';\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"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...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nvoid print(vector > &v) {\\n for (long long i = 0; i < v.size(); i++) {\\n cout << v[i].first << \\\" \\\" << v[i].second << endl;\\n }\\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};\\nvoid v_sort(vector &v, long long a = 0) {\\n if (a == 0)\\n sort(v.begin(), v.end());\\n else\\n sort(v.begin(), v.end(), greater());\\n}\\nvoid print(vector v) {\\n for (long long i = 0; i < (long long)v.size(); i++) {\\n cout << v[i] << \\\" \\\";\\n }\\n cout << endl;\\n}\\nvoid print(vector > &v) {\\n for (long long i = 0; i < (long long)v.size(); i++) {\\n print(v[i]);\\n }\\n}\\nvoid Array(long long n, vector &v) {\\n v.clear();\\n v.resize(n);\\n for (long long i = 0; i < n; i++) {\\n cin >> v[i];\\n }\\n}\\nvoid Array_1(long long n, vector &v) {\\n v.clear();\\n v.resize(n + 1);\\n for (long long i = 1; i <= n; i++) {\\n cin >> v[i];\\n }\\n}\\nvoid tree_edges(long long n, vector > &adj) {\\n adj.resize(n + 1);\\n for (long long i = 0; i < n - 1; i++) {\\n long long a;\\n long long b;\\n cin >> a >> b;\\n adj[a].push_back(b);\\n adj[b].push_back(a);\\n }\\n}\\nvoid Matrix(long long n, long long m, vector > &v,\\n long long second = 0) {\\n v.resize(n);\\n for (long long i = 0; i < n; i++) {\\n v[i].resize(m);\\n for (long long j = 0; j < m; j++) {\\n cin >> v[i][j];\\n }\\n }\\n}\\nvoid here(long long i = 0) { cout << \\\"here \\\" << i << endl; }\\nbool is_odd(long long n) { return n % 2; }\\nbool is_even(long long n) { return !is_odd(n); }\\nlong long nc2(long long n) {\\n if (n == 1) return 0;\\n if (is_even(n)) {\\n return (n \\/ 2)...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Monocarp is the coach of the Berland State University programming teams. He decided to compose a problemset for a training session for his teams.\\n\\nMonocarp has n problems that none of his students have seen yet. The i-th problem has a topic a_i (an integer from 1 to n) and a difficulty b_i (an integer from 1 to n). All problems are different, that is, there are no two tasks that have the same topic and difficulty at the same time.\\n\\nMonocarp decided to select exactly 3 problems from n problems for the problemset. The problems should satisfy at least one of two conditions (possibly, both):\\n\\n * the topics of all three selected problems are different; \\n * the difficulties of all three selected problems are different. \\n\\n\\n\\nYour task is to determine the number of ways to select three problems for the problemset.\\n\\nInput\\n\\nThe first line contains a single integer t (1 ≤ t ≤ 50000) — the number of testcases.\\n\\nThe first line of each testcase contains an integer n (3 ≤ n ≤ 2 ⋅ 10^5) — the number of problems that Monocarp have.\\n\\nIn the i-th of the following n lines, there are two integers a_i and b_i (1 ≤ a_i, b_i ≤ n) — the topic and the difficulty of the i-th problem.\\n\\nIt is guaranteed that there are no two problems that have the same topic and difficulty at the same time.\\n\\nThe sum of n over all testcases doesn't exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nPrint the number of ways to select three training problems that meet either of the requirements described in the statement.\\n\\nExample\\n\\nInput\\n\\n\\n2\\n4\\n2 4\\n3 4\\n2 1\\n1 3\\n5\\n1 5\\n2 4\\n3 3\\n4 2\\n5 1\\n\\n\\nOutput\\n\\n\\n3\\n10\\n\\nNote\\n\\nIn the first example, you can take the following sets of three problems:\\n\\n * problems 1, 2, 4; \\n * problems 1, 3, 4; \\n * problems 2, 3, 4. \\n\\n\\n\\nThus, the number of ways is equal to three.\",\"targets\":\"#include \\nusing namespace std;\\nlong long row[200010], col[200010], ans, n;\\nint x[200010], y[200010], visx[200010], visy[200010];\\nint main() {\\n int T, i;\\n cin >> T;\\n while (T--) {\\n scanf(\\\"%d\\\", &n);\\n for (i = 1; i <= n; i++) {\\n scanf(\\\"%d%d\\\", &x[i], &y[i]);\\n row[x[i]]++;\\n col[y[i]]++;\\n }\\n ans = 1ll * n * (n - 1) * (n - 2) \\/ 6;\\n long long s1;\\n s1 = 0;\\n for (i = 1; i <= n; i++) {\\n s1 += 1ll * (row[x[i]] - 1) * (col[y[i]] - 1);\\n }\\n cout << ans - s1 << endl;\\n for (i = 1; i <= n; i++) {\\n row[x[i]] = col[y[i]] = visx[x[i]] = visy[y[i]] = 0;\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"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).\",\"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 int n;\\n cin >> n;\\n int flag = 0;\\n char f[n];\\n char s[n];\\n for (int i = 0; i < n; i++) {\\n cin >> f[i];\\n }\\n for (int i = 0; i < n; i++) {\\n cin >> s[i];\\n }\\n for (int i = 0; i < n; i++) {\\n if (f[i] == '1' && s[i] == '1') {\\n flag = 1;\\n }\\n }\\n if (flag) {\\n cout << \\\"NO\\\" << endl;\\n } else {\\n cout << \\\"YES\\\" << endl;\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"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...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\ntemplate \\nvoid emilia_mata_tenshi(const char *s, T l, T r) {\\n cerr << \\\"\\\\e[1;33m\\\" << s << \\\" = [\\\";\\n while (l != r) {\\n cerr << *l;\\n cerr << (++l == r ? ']' : ',');\\n }\\n cerr << \\\"\\\\e[0m\\\\n\\\";\\n}\\nusing ll = int64_t;\\nusing ull = uint64_t;\\nusing ld = long double;\\nusing uint = uint32_t;\\nconst double EPS = 1e-7;\\nconst int INF = 0x3F3F3F3F;\\nconst ll LINF = 4611686018427387903;\\nconst int MOD = 1e9 + 7;\\nstatic int Lamy_is_cute = []() {\\n ios::sync_with_stdio(0);\\n cin.tie(NULL);\\n return 48763;\\n}();\\nsigned main() {\\n int t;\\n cin >> t;\\n while (t--) {\\n int n, m, k;\\n cin >> n >> m >> k;\\n int it = 0;\\n while (k--) {\\n for (int i = 0; i < n % m; i++) {\\n cout << n \\/ m + 1 << ' ';\\n for (int j = 0; j < n \\/ m + 1; j++)\\n cout << (it + 1) << \\\" \\\\n\\\"[j == n \\/ m], it = (it + 1) % n;\\n }\\n int g = it;\\n for (int i = 0; i < m - n % m; i++) {\\n cout << n \\/ m << ' ';\\n for (int j = 0; j < n \\/ m; j++)\\n cout << (g + 1) << \\\" \\\\n\\\"[j == n \\/ m - 1], g = (g + 1) % n;\\n }\\n }\\n cout << '\\\\n';\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"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\":\"for _ in range(int(input())):\\n n = int(input())\\n nums = input().split()\\n nums[0] = int(nums[0])\\n maxx = 0\\n for i in range(1, n):\\n num = int(nums[i])\\n nums[i] = num\\n maxx = max(maxx, num * nums[i - 1])\\n print(maxx)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Theofanis has a string s_1 s_2 ... s_n and a character c. He wants to make all characters of the string equal to c using the minimum number of operations.\\n\\nIn one operation he can choose a number x (1 ≤ x ≤ n) and for every position i, where i is not divisible by x, replace s_i with c. \\n\\nFind the minimum number of operations required to make all the characters equal to c and the x-s that he should use in his operations.\\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 the integer n (3 ≤ n ≤ 3 ⋅ 10^5) and a lowercase Latin letter c — the length of the string s and the character the resulting string should consist of.\\n\\nThe second line of each test case contains a string s of lowercase Latin letters — the initial string.\\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, firstly print one integer m — the minimum number of operations required to make all the characters equal to c.\\n\\nNext, print m integers x_1, x_2, ..., x_m (1 ≤ x_j ≤ n) — the x-s that should be used in the order they are given.\\n\\nIt can be proved that under given constraints, an answer always exists. If there are multiple answers, print any.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n4 a\\naaaa\\n4 a\\nbaaa\\n4 b\\nbzyx\\n\\n\\nOutput\\n\\n\\n0\\n1\\n2\\n2 \\n2 3\\n\\nNote\\n\\nLet's describe what happens in the third test case: \\n\\n 1. x_1 = 2: we choose all positions that are not divisible by 2 and replace them, i. e. bzyx → bzbx; \\n 2. x_2 = 3: we choose all positions that are not divisible by 3 and replace them, i. e. bzbx → bbbb.\",\"targets\":\"from sys import stdin \\nfrom bisect import bisect\\nfor _ in range(int(stdin.readline())):\\n inp=list(input().split())\\n s=input()\\n n=int(inp[0])\\n c=inp[1] \\n ans=0\\n for i in range(n):\\n if s[i]!=c:\\n ans=1 \\n break \\n if ans==0:\\n print(ans) \\n else:\\n ans=None\\n for i in range(n):\\n if (i+1)*2>n and s[i]==c:\\n ans=i+1 \\n break \\n if ans!=None:\\n print(1)\\n print(ans)\\n else:\\n print(2)\\n print(n-1,n)\",\"language\":\"python\",\"split\":\"test\",\"template\":\"descsol\",\"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\",\"targets\":\"import java.io.BufferedOutputStream;\\nimport java.io.BufferedReader;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.io.PrintWriter;\\nimport java.util.Scanner;\\nimport java.util.StringTokenizer;\\npublic class cf {\\n\\n static FastScanner sc = new FastScanner();\\n static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));\\n static Scanner scc = 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 int k = 1;\\n int a = sc.nextInt();\\n if(a == 1){\\n k++;\\n }\\n for (int i = 1; i < n; i++) {\\n int b = sc.nextInt();\\n if(k == -1){\\n continue;\\n }\\n if(b == 1){\\n k++;\\n }\\n if(b == 0 && a == 0){\\n k = -1;\\n }\\n if(b == 1 && a == 1){\\n k+=4;\\n }\\n a = b;\\n }\\n System.out.println(k);\\n }\\n }\\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 return st.nextToken();\\n }\\n \\n int nextInt() {\\n return Integer.parseInt(next());\\n }\\n int[] readArray(int n) {\\n int[] a=new int[n];\\n for (int i=0; i\\nusing namespace std;\\nint N;\\nint A[200201];\\nint dp[200201];\\nint seg[530000];\\nint Update(int idx, int val, int n, int l, int r) {\\n if (r < idx || idx < l) return seg[n];\\n if (l == r) return seg[n] = max(seg[n], val);\\n int mid = l + r >> 1;\\n return seg[n] = max(Update(idx, val, n << 1, l, mid),\\n Update(idx, val, n << 1 | 1, mid + 1, r));\\n}\\nint Query(int L, int R, int n, int l, int r) {\\n if (r < L || R < l) return 0;\\n if (L <= l && r <= R) return seg[n];\\n int mid = l + r >> 1;\\n return max(Query(L, R, n << 1, l, mid), Query(L, R, n << 1 | 1, mid + 1, r));\\n}\\nint Delete(int idx, int n, int l, int r) {\\n if (r < idx || idx < l) return seg[n];\\n if (l == r) return seg[n] = 0;\\n int mid = l + r >> 1;\\n return seg[n] = max(Delete(idx, n << 1, l, mid),\\n Delete(idx, n << 1 | 1, mid + 1, r));\\n}\\nvoid dnc(int L, int R) {\\n if (L == R) {\\n dp[L] = max(dp[L], 1);\\n return;\\n }\\n int mid = L + R >> 1;\\n dnc(L, mid);\\n vector > u, q;\\n for (int i = L; i <= mid; i++)\\n if (A[i] <= i) u.push_back({i - A[i], A[i], dp[i]});\\n for (int i = mid + 1; i <= R; i++)\\n if (A[i] <= i) q.push_back({i - A[i] + 1, A[i], i});\\n sort(u.begin(), u.end());\\n sort(q.begin(), q.end());\\n int j = 0;\\n for (auto [a, b, i] : q) {\\n while (j < u.size() && u[j][0] < a) {\\n Update(u[j][1], u[j][2], 1, 1, 200000);\\n j++;\\n }\\n dp[i] = max(dp[i], Query(1, b - 1, 1, 1, 200000) + 1);\\n }\\n for (auto [a, b, x] : u) Delete(b, 1, 1, 200000);\\n dnc(mid + 1, R);\\n}\\nint main() {\\n ios::sync_with_stdio(0);\\n cin.tie(0);\\n cin.exceptions(ios::badbit | ios::failbit);\\n cin >> N;\\n for (int i = 1; i <= N; i++) cin >> A[i];\\n dnc(1, N);\\n int res = 0;\\n for (int i = 1; i <= N; i++) {\\n if (A[i] <= i) res = max(res, dp[i]);\\n }\\n cout << res << \\\"\\\\n\\\";\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"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 \\\":\",\"targets\":\"#include \\nusing namespace std;\\nusing ld = long double;\\nusing ll = long long;\\nusing vi = vector;\\nusing vvi = vector;\\nusing vll = vector;\\nusing vvll = vector;\\nusing vb = vector;\\nusing vvb = vector;\\nusing vd = vector;\\nusing vs = vector;\\nusing pii = pair;\\nusing pll = pair;\\nusing pdd = pair;\\nusing vpii = vector;\\nusing vpll = vector;\\nusing vpdd = vector;\\ntemplate \\nvoid ckmin(T &a, const T &b) {\\n a = min(a, b);\\n}\\ntemplate \\nvoid ckmax(T &a, const T &b) {\\n a = max(a, b);\\n}\\nmt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());\\nnamespace __input {\\ntemplate \\nvoid re(pair &p);\\ntemplate \\nvoid re(vector &a);\\ntemplate \\nvoid re(array &a);\\ntemplate \\nvoid re(T &x) {\\n cin >> x;\\n}\\nvoid re(double &x) {\\n string t;\\n re(t);\\n x = stod(t);\\n}\\ntemplate \\nvoid re(Arg &first, Args &...rest) {\\n re(first);\\n re(rest...);\\n}\\ntemplate \\nvoid re(pair &p) {\\n re(p.f, p.s);\\n}\\ntemplate \\nvoid re(vector &a) {\\n for (int i = 0; i < int((a).size()); i++) re(a[i]);\\n}\\ntemplate \\nvoid re(array &a) {\\n for (int i = 0; i < SZ; i++) re(a[i]);\\n}\\n} \\/\\/ namespace __input\\nusing namespace __input;\\nnamespace __output {\\ntemplate \\nstruct is_outputtable {\\n template \\n static constexpr decltype(declval() << declval(),\\n bool())\\n test(int) {\\n return true;\\n }\\n template \\n static constexpr bool test(...) {\\n return false;\\n }\\n static constexpr bool value = test(int());\\n};\\ntemplate <\\n class T, typename V = decltype(declval().begin()),\\n typename second = typename enable_if::value, bool>::type>\\nvoid pr(const T &x);\\ntemplate () << declval())>\\nvoid pr(const T...\",\"language\":\"python\",\"split\":\"test\",\"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...\\nSolve the task in JAVA.\",\"targets\":\"import java.util.*;\\nimport java.lang.*;\\nimport java.io.*;\\nimport java.math.BigInteger;\\nimport java.io.BufferedReader;\\nimport java.io.BufferedWriter;\\nimport java.io.DataInputStream;\\nimport java.io.FileInputStream;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.io.OutputStreamWriter;\\nimport java.math.BigInteger;\\nimport java.util.List;\\nimport java.util.Map;\\nimport java.util.ArrayList;\\nimport java.util.Arrays;\\nimport java.util.Collections;\\nimport java.util.Comparator;\\nimport java.util.HashMap;\\nimport java.util.HashSet;\\nimport java.util.Iterator;\\npublic class third\\n{\\t\\n\\t static class Reader {\\n\\t\\t \\n\\t final private int BUFFER_SIZE = 1 << 16;\\n\\t private DataInputStream din;\\n\\t private byte[] buffer;\\n\\t private int bufferPointer, bytesRead;\\n\\t \\n\\t public Reader()\\n\\t {\\n\\t din = new DataInputStream(System.in);\\n\\t buffer = new byte[BUFFER_SIZE];\\n\\t bufferPointer = bytesRead = 0;\\n\\t }\\n\\t \\n\\t public Reader(String file_name) throws IOException\\n\\t {\\n\\t din = new DataInputStream(\\n\\t new FileInputStream(file_name));\\n\\t buffer = new byte[BUFFER_SIZE];\\n\\t bufferPointer = bytesRead = 0;\\n\\t }\\n\\t \\n\\t public String readLine() throws IOException\\n\\t {\\n\\t byte[] buf = new byte[64]; \\/\\/ line length\\n\\t int cnt = 0, c;\\n\\t while ((c = read()) != -1) {\\n\\t if (c == '\\\\n') {\\n\\t if (cnt != 0) {\\n\\t break;\\n\\t }\\n\\t else {\\n\\t continue;\\n\\t }\\n\\t }\\n\\t buf[cnt++] = (byte)c;\\n\\t }\\n\\t return new String(buf, 0, cnt);\\n\\t }\\n\\t \\n\\t public int nextInt() throws IOException\\n\\t {\\n\\t int ret = 0;\\n\\t byte c = read();\\n\\t while (c <= ' ') {\\n\\t c = read();\\n\\t }\\n\\t boolean neg = (c == '-');\\n\\t if (neg)\\n\\t ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Captain Flint and his crew keep heading to a savage shore of Byteland for several months already, drinking rum and telling stories. In such moments uncle Bogdan often remembers his nephew Denis. Today, he has told a story about how Denis helped him to come up with an interesting problem and asked the crew to solve it.\\n\\nIn the beginning, uncle Bogdan wrote on a board a positive integer x consisting of n digits. After that, he wiped out x and wrote integer k instead, which was the concatenation of binary representations of digits x consists of (without leading zeroes). For example, let x = 729, then k = 111101001 (since 7 = 111, 2 = 10, 9 = 1001).\\n\\nAfter some time, uncle Bogdan understood that he doesn't know what to do with k and asked Denis to help. Denis decided to wipe last n digits of k and named the new number as r.\\n\\nAs a result, Denis proposed to find such integer x of length n that r (as number) is maximum possible. If there are multiple valid x then Denis is interested in the minimum one.\\n\\nAll crew members, including captain Flint himself, easily solved the task. All, except cabin boy Kostya, who was too drunk to think straight. But what about you?\\n\\nNote: in this task, we compare integers (x or k) as numbers (despite what representations they are written in), so 729 < 1999 or 111 < 1000.\\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 test case. The one and only line of each test case contains the single integer n (1 ≤ n ≤ 10^5) — the length of the integer x you need to find.\\n\\nIt's guaranteed that the sum of n from all test cases doesn't exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each test case, print the minimum integer x of length n such that obtained by Denis number r is maximum possible.\\n\\nExample\\n\\nInput\\n\\n\\n2\\n1\\n3\\n\\n\\nOutput\\n\\n\\n8\\n998\\n\\nNote\\n\\nIn the second test case (with n = 3), if uncle Bogdan had x = 998 then k = 100110011000. Denis (by wiping last n = 3 digits) will obtain r = 100110011.\\n\\nIt can be proved that the 100110011 is...\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n int t;\\n cin >> t;\\n while (t--) {\\n int n;\\n cin >> n;\\n int countn = n \\/ 4;\\n if (n % 4 != 0) countn++;\\n for (int i = 1; i <= n - countn; i++) cout << \\\"9\\\";\\n for (int i = 1; i <= countn; i++) cout << \\\"8\\\";\\n cout << endl;\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 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\":\"\\\"\\\"\\\"\\nID: happyn61\\nLANG: PYTHON3\\nPROB: loan\\n\\\"\\\"\\\"\\nfrom itertools import product\\nimport itertools\\nimport math\\n#from collections import defaultdict\\nimport sys\\nimport heapq\\nfrom collections import deque\\nMOD=1000000000007\\n#fin = open ('loan.in', 'r')\\n#fout = open ('loan.out', 'w')\\n#print(dic[\\\"4734\\\"])\\ndef find(parent,i):\\n\\n\\n if parent[i] != i: \\n parent[i]=find(parent,parent[i]) \\n return parent[i] \\n\\n # A utility function to do union of two subsets \\ndef union(parent,rank,xx,yy): \\n x=find(parent,xx)\\n y=find(parent,yy)\\n if rank[x]>rank[y]:\\n parent[y]=x\\n elif rank[y]>rank[x]:\\n parent[x]=y\\n else:\\n parent[y]=x\\n rank[x]+=1\\nans=0\\n#NK=sys.stdin.readline().strip().split()\\nK=int(sys.stdin.readline().strip())\\n#N=int(NK[0])\\n#K=int(NK[1])\\n#M=int(NK[2])\\n#ol=list(map(int,sys.stdin.readline().strip().split()))\\n#d={0:0,1:0}\\n\\nx=0\\ny=0\\n\\n#d={\\\"N\\\":(0,1),\\\"S\\\":(0,-1),\\\"W\\\":(-1,0),\\\"E\\\":(1,0)}\\nfor _ in range(K):\\n s=sys.stdin.readline().strip()\\n t=sys.stdin.readline().strip()\\n F=False\\n for i in range(1,len(s)+1):\\n ss=s[:i]+s[:i-1][::-1]\\n #print(t,ss)\\n if t in ss:\\n F=True\\n break\\n if F:\\n print(\\\"YES\\\")\\n else:\\n print(\\\"NO\\\")\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"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.\\nSolve the task in PYTHON3.\",\"targets\":\"# Problem A\\nt = int(input())\\nfor test in range(t):\\n n = int(input())\\n a = list(map(int, input().split()))\\n count_1 = a.count(1)\\n if count_1 <= n\\/2:\\n a_ = [num for num in a if num == 0]\\n else:\\n a_ = [num for num in a if num == 1]\\n if len(a_) % 2 != 0:\\n del a_[0]\\n print(len(a_))\\n print(*a_)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"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...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nusing LL = long long;\\nusing ULL = unsigned long long;\\nusing VI = vector;\\nusing VL = vector;\\nusing PII = pair;\\nusing PLL = pair;\\nvoid dout() { cerr << endl; }\\ntemplate \\nvoid dout(Head H, Tail... T) {\\n cerr << H << ' ';\\n dout(T...);\\n}\\nconst int MAX = 1 << 10;\\nint a[MAX][MAX];\\nint main() {\\n ios::sync_with_stdio(false);\\n cin.tie(0);\\n int k, n;\\n cin >> n >> k;\\n int pw = 1, c = 0;\\n while (pw < n) {\\n pw *= k;\\n c++;\\n }\\n for (int i = (0); i < (n); ++i) {\\n int x = i;\\n for (int j = (0); j < (c); ++j) {\\n a[i][j] = x % k;\\n x \\/= k;\\n }\\n }\\n cout << c << \\\"\\\\n\\\";\\n for (int i = (0); i < (n); ++i) {\\n for (int j = (i + 1); j < (n); ++j) {\\n int col = 0;\\n while (a[i][col] >= a[j][col]) col++;\\n cout << col + 1 << \\\" \\\";\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"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...\\nUsing java can you solve the prior task?\",\"targets\":\"import java.util.Arrays;\\nimport java.util.Scanner;\\nimport static java.lang.Integer.min;\\n\\npublic class problemB {\\n static Scanner input = new Scanner(System.in);\\n static void solve() {\\n int n = input.nextInt();\\n int k = input.nextInt();\\n int[] a = new int[n];\\n Integer[] id = new Integer[n];\\n int[] c = new int[n];\\n for(int i=0; i a[x]-a[y]);\\n int col = 1;\\n int[] cache = new int[k];\\n for(int i=0; i0) {\\n solve();\\n --test;\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"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 JAVA.\",\"targets\":\"import java.util.*;\\nimport java.lang.*;\\nimport java.io.*;\\n\\npublic class Main {\\n\\tpublic static void main(String[] args) {\\n\\t\\tScanner cin = new Scanner(System.in);\\n\\t\\tint t = cin.nextInt();\\n\\t\\twhile (t > 0) {\\n\\t\\t\\tString word = cin.next();\\n\\t\\t\\tif (word.length() % 2 != 0) {\\n\\t\\t\\t\\tSystem.out.println(\\\"NO\\\");\\n\\t\\t\\t} else if (word.substring(0, (word.length() \\/ 2))\\n\\t\\t\\t\\t\\t.equals(word.substring((word.length() \\/ 2), word.length()))) {\\n\\t\\t\\t\\tSystem.out.println(\\\"YES\\\");\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tSystem.out.println(\\\"NO\\\");\\n\\t\\t\\t}\\n\\n\\t\\t\\tt--;\\n\\t\\t}\\n\\t}\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"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.PrintWriter;\\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 T = Integer.parseInt(sc.next());\\n for(int t = 0; t < T; t++){\\n int n = Integer.parseInt(sc.next());\\n String s1 = sc.next();\\n String s2 = sc.next();\\n var a = new int[n];\\n var b = new int[n];\\n for(int i = 0; i < n; i++){\\n if(s1.charAt(i) == '1'){\\n a[i] = 1;\\n }\\n if(s2.charAt(i) == '1'){\\n b[i] = 1;\\n }\\n }\\n \\n int countA = 0;\\n int countB = 0;\\n for(int i = 0; i < n; i++){\\n if(a[i] == 1){\\n countA++;\\n }\\n if(b[i] == 1){\\n countB++;\\n }\\n }\\n \\n if((countA == 0 && countB != 0) || (countA != countB && (n - countA + 1) != countB)){\\n pw.println(-1);\\n continue;\\n }\\n \\n int ans = Integer.MAX_VALUE;\\n \\n int count = 0;\\n if(countA == countB){\\n for(int i = 0; i < n; i++){\\n if(a[i] != b[i]){\\n count++;\\n }\\n }\\n ans = count;\\n }\\n \\n if((n - countA + 1) == countB){\\n int index = 0;\\n for(int i = 0; i < n; i++){\\n if(a[i] == 1){\\n index = i;\\n break;\\n }\\n }\\n for(int i = 0; i < n; i++){\\n if(a[i] == 1 && b[i] == 1){\\n index = i;\\n break;\\n }\\n }\\n for(int i = 0; i < n; i++){\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nYelisey 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...\",\"targets\":\"import java.io.*;\\nimport java.math.*;\\nimport java.util.*;\\n\\npublic class Main {\\n\\tstatic int mod=1000000007;\\n\\tstatic MyScanner sc = new MyScanner();\\n\\tstatic Output out = new Output();\\n\\tpublic static void main(String[] args) {\\n\\t\\tint t=sc.nextInt();\\n\\t\\tfor (int i=0;i() {\\n @Override\\n public int compare(int[] first, int[] second) {\\n if(first[columnIndex] > second[columnIndex]) return 1;\\n else return -1;\\n }\\n });\\n\\t}\\n\\t\\n\\t\\/\\/2d sort\\n\\/\\/\\tstatic void sort(int[][] arr){\\n\\/\\/\\t\\tmergesort(arr,0,arr.length-1);\\n\\/\\/\\t}\\n\\/\\/\\tstatic void sort(int[][] arr,int startIndex,int endIndex){\\n\\/\\/\\t\\tmergesort(arr,startIndex,endIndex);\\n\\/\\/\\t}\\n\\/\\/\\n\\/\\/\\tstatic void mergesort(int[][] arr,int b,int e) {\\n\\/\\/\\t\\tif(b g[];\\n\\tstatic long mod=(long)1e9+7,INF=Long.MAX_VALUE;\\n\\tstatic boolean set[]; \\n\\tstatic int par[],tot[],partial[];\\n\\tstatic int Days[],P[][];\\n\\tstatic int dp[][],sum=0,size[];\\n\\tstatic int seg[],col[];\\n\\tstatic ArrayList A;\\n\\t\\/\\/\\tstatic HashSet set;\\n\\t\\/\\/\\tstatic node1 seg[];\\n\\t\\/\\/static pair moves[]= {new pair(-1,0),new pair(1,0), new pair(0,-1), new pair(0,1)};\\n\\tpublic static void main(String args[])throws IOException\\n\\t{\\t\\n\\t\\tint T=i();\\n\\t\\twhile(T-->0)\\n\\t\\t{\\n\\t\\t\\tlong N=l(),K=l();\\n\\t\\t\\t\\n\\t\\t\\tlong s=0;\\n\\t\\t\\tlong pow=1L;\\n\\t\\t\\twhile(K>0)\\n\\t\\t\\t{\\n\\t\\t\\t\\tif((K&1)!=0)\\n\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\ts+=pow;\\n\\t\\t\\t\\t\\ts%=mod;\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tpow=(pow*N)%mod;\\n\\t\\t\\t\\tK>>=1;\\n\\t\\t\\t}\\n\\t\\t\\tans.append(s+\\\"\\\\n\\\");\\n\\t\\t}\\n\\t\\tout.println(ans);\\n\\t\\tout.close();\\n\\t}\\n\\t\\n\\tstatic void update(char X[][],int min[][],int i,int j,int N,int M,int d)\\n\\t{\\n\\t\\tint x=i,y=j;\\n\\t\\tint t=d+1;\\n\\t\\twhile(t-->0 && i>=0 && j>=0 && X[i][j]=='*')\\n\\t\\t{\\n\\t\\t\\tmin[i][j]=Math.max(min[i][j],d);\\n\\t\\t\\ti--;\\n\\t\\t\\tj--;\\n\\t\\t}\\n\\t\\ti=x;\\n\\t\\tj=y;\\n\\t\\tt=d+1;\\n\\t\\twhile(t-->0 && i>=0 && j set=new HashSet<>();\\n\\t\\tfor(char ch:order.toCharArray())\\n\\t\\t{\\n\\t\\t\\tset.add(ch);\\n\\t\\t\\tfor(int i=0; i\\nusing namespace std;\\nconst int Max_N = 2e5, Max_Q = 2e5, Max = (1e9) + 7;\\nconst long long Mod = (1e9) + 7;\\nint n, q, a[Max_N + 5], K[3] = {2, 3, 4}, C[30][30];\\nlong long sum[Max_N + 5], sM[3][Max_N + 5], P[30][Max_N + 5];\\nlong long Mul(int x, int y) {\\n long long ans = 1;\\n for (; y; y >>= 1, x = 1ll * x * x % Mod)\\n if (y & 1) ans = ans * x % Mod;\\n return ans;\\n}\\nint main() {\\n srand(time(0));\\n int t = (1ll * rand() * 100000 + rand()) % Max;\\n scanf(\\\"%d%d\\\", &n, &q);\\n for (int i = 1; i <= n; i++) scanf(\\\"%d\\\", &a[i]);\\n for (int i = 1; i <= n; i++) a[i] = (1ll * a[i] + t) % Mod;\\n for (int i = 1; i <= n; i++) sum[i] = (sum[i - 1] + a[i]) % Mod;\\n for (int i = 1; i <= n; i++)\\n for (int j = 0; j < 3; j++)\\n sM[j][i] = (sM[j][i - 1] + Mul(a[i], K[j])) % Mod;\\n for (int i = 0; i <= K[2]; i++)\\n for (int j = 0; j <= n; j++)\\n P[i][j] = ((j ? P[i][j - 1] : 0) + Mul(j, i)) % Mod;\\n C[0][0] = 1;\\n for (int i = 1; i <= K[2]; i++) {\\n C[i][0] = 1;\\n for (int j = 1; j <= i; j++)\\n C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % Mod;\\n }\\n for (; q--;) {\\n int l, r, d;\\n scanf(\\\"%d%d%d\\\", &l, &r, &d);\\n int len = r - l + 1;\\n long long tot = (sum[r] - sum[l - 1] + Mod) % Mod;\\n long long fir = (tot - 1ll * (len - 1) * len \\/ 2 % Mod * d % Mod + Mod) %\\n Mod * Mul(len, Mod - 2) % Mod;\\n long long ans = 0;\\n int flg = 0;\\n for (int j = 0; j < 3; j++) {\\n ans = 0;\\n for (int k = 0; k <= K[j]; k++)\\n ans = (ans + 1ll * C[K[j]][k] * Mul(fir, K[j] - k) % Mod * Mul(d, k) %\\n Mod * P[k][len - 1] % Mod) %\\n Mod;\\n if (ans != (sM[j][r] - sM[j][l - 1] + Mod) % Mod) flg |= 1;\\n }\\n if (!flg)\\n puts(\\\"Yes\\\");\\n else\\n puts(\\\"No\\\");\\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 PYTHON3?\\nYou 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...\",\"targets\":\"for t in range(int(input())):\\n n= int(input())\\n lis = list(map(int, input().split()))\\n s=input()\\n red=[]\\n blue=[]\\n for i in range(n):\\n if s[i] == \\\"R\\\":\\n red.append(lis[i])\\n else:\\n blue.append(lis[i])\\n red.sort()\\n blue.sort()\\n r_pointer=b_pointer=0\\n val=1\\n flag=0\\n #print(red,blue,n)\\n while (r_pointer= val:\\n b_pointer+=1\\n elif r_pointer\\nusing namespace std;\\nconst int MAXN = 1e5 + 5;\\nconst int INF = 1e9 + 7;\\nconst int mod = 1e9 + 7;\\nint T, n;\\nchar s[MAXN];\\nchar a[66][66];\\nint stc[MAXN], sc = 0;\\nint read() {\\n int s = 0, f = 0;\\n char ch = getchar();\\n while (!isdigit(ch)) f |= (ch == '-'), ch = getchar();\\n while (isdigit(ch)) s = (s << 1) + (s << 3) + ch - '0', ch = getchar();\\n return f ? -s : s;\\n}\\nint main() {\\n T = read();\\n while (T--) {\\n n = read();\\n cin >> s + 1;\\n int x = 0, y = 0, z = 0;\\n sc = 0;\\n for (int i = 1; i <= n; ++i) {\\n if (s[i] == '2') {\\n if (x && y && !z) z = i;\\n if (x && !y) y = i;\\n if (!x) x = i;\\n stc[++sc] = i;\\n }\\n }\\n if (!x && !y && !z) {\\n puts(\\\"YES\\\");\\n for (int i = 1; i <= n; ++i) {\\n for (int j = 1; j <= n; ++j) {\\n if (i != j)\\n printf(\\\"=\\\");\\n else\\n printf(\\\"X\\\");\\n }\\n puts(\\\"\\\");\\n }\\n continue;\\n }\\n if (x && !z) {\\n puts(\\\"NO\\\");\\n continue;\\n }\\n if (x && y && z) {\\n puts(\\\"YES\\\");\\n for (int i = 1; i <= n; ++i)\\n for (int j = 1; j <= n; ++j) a[i][j] = '=';\\n for (int i = 1; i <= n; ++i) a[i][i] = 'X';\\n stc[sc + 1] = stc[1];\\n for (int i = 1; i <= sc; ++i) {\\n a[stc[i]][stc[i + 1]] = '+';\\n a[stc[i + 1]][stc[i]] = '-';\\n }\\n for (int i = 1; i <= n; ++i) {\\n for (int j = 1; j <= n; ++j) {\\n printf(\\\"%c\\\", a[i][j]);\\n }\\n puts(\\\"\\\");\\n }\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nOn the 228-th international Uzhlyandian Wars strategic game tournament teams from each country are called. The teams should consist of 5 participants.\\n\\nThe team of Uzhlyandia will consist of soldiers, because there are no gamers.\\n\\nMasha is a new minister of defense and gaming. The prime duty of the minister is to calculate the efficiency of the Uzhlandian army. The army consists of n soldiers standing in a row, enumerated from 1 to n. For each soldier we know his skill in Uzhlyandian Wars: the i-th soldier's skill is ai.\\n\\nIt was decided that the team will consist of three players and two assistants. The skills of players should be same, and the assistants' skills should not be greater than the players' skill. Moreover, it is important for Masha that one of the assistants should stand in the row to the left of the players, and the other one should stand in the row to the right of the players. Formally, a team is five soldiers with indexes i, j, k, l, p, such that 1 ≤ i < j < k < l < p ≤ n and ai ≤ aj = ak = al ≥ ap. \\n\\nThe efficiency of the army is the number of different teams Masha can choose. Two teams are considered different if there is such i such that the i-th soldier is a member of one team, but not a member of the other team.\\n\\nInitially, all players are able to be players. For some reasons, sometimes some soldiers become unable to be players. Sometimes some soldiers, that were unable to be players, become able to be players. At any time any soldier is able to be an assistant. Masha wants to control the efficiency of the army, so she asked you to tell her the number of different possible teams modulo 1000000007 (109 + 7) after each change. \\n\\nInput\\n\\nThe first line contains single integer n (1 ≤ n ≤ 105) — the number of soldiers in Uzhlyandia.\\n\\nThe second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the soldiers' skills.\\n\\nThe third line contains single integer m (1 ≤ m ≤ 105) — the number of changes.\\n\\nThe next m lines contain the changes, each change is described with two integers t and x (1...\",\"targets\":\"#include \\nusing namespace std;\\nconst int maxn = 500010, inf = 1e9, mod = 1e9 + 7;\\nstruct poi {\\n int czl[3][3], l, r;\\n} tree[maxn * 8];\\nint n, c, m, x, y, z, tot, len;\\nlong long ans;\\nint a[maxn], b[maxn], sz[maxn], zb[maxn], yb[maxn], root[maxn];\\nvoid read(int &k) {\\n int f = 1;\\n k = 0;\\n char c = getchar();\\n while (c < '0' || c > '9') c == '-' && (f = -1), c = getchar();\\n while (c <= '9' && c >= '0') k = k * 10 + c - '0', c = getchar();\\n k *= f;\\n}\\nint lowbit(int x) { return x & -x; }\\nvoid add(int x, int y) {\\n for (; x <= c; x += lowbit(x)) sz[x] += y;\\n}\\nint find(int x) {\\n int sum = 0;\\n for (; x; x -= lowbit(x)) sum += sz[x];\\n return sum;\\n}\\nvoid update(int x) {\\n int l = tree[x].l, r = tree[x].r;\\n tree[x].czl[0][0] = tree[l].czl[0][0] + tree[r].czl[0][0];\\n tree[x].czl[1][1] = tree[l].czl[1][1] + tree[r].czl[1][1];\\n tree[x].czl[2][2] = tree[l].czl[2][2] + tree[r].czl[2][2];\\n tree[x].czl[0][1] = (tree[l].czl[0][1] + tree[r].czl[0][1] +\\n 1ll * tree[l].czl[0][0] * tree[r].czl[1][1]) %\\n mod;\\n tree[x].czl[1][2] = (tree[l].czl[1][2] + tree[r].czl[1][2] +\\n 1ll * tree[l].czl[1][1] * tree[r].czl[2][2]) %\\n mod;\\n tree[x].czl[0][2] = (tree[l].czl[0][2] + tree[r].czl[0][2] +\\n 1ll * tree[l].czl[0][1] * tree[r].czl[2][2] +\\n 1ll * tree[l].czl[0][0] * tree[r].czl[1][2]) %\\n mod;\\n}\\nvoid gs(int x, int l, int r, int delta, int ty) {\\n if (l == r) {\\n if (ty == 1)\\n tree[x].czl[0][0] = tree[x].czl[1][1] = tree[x].czl[2][2] = 0;\\n else\\n tree[x].czl[0][0] = zb[delta], tree[x].czl[1][1] = 1,\\n tree[x].czl[2][2] = yb[delta];\\n return;\\n }\\n int mid = (l + r) >> 1;\\n if (mid >= delta) {\\n if (!tree[x].l) tree[x].l = ++tot;\\n gs(tree[x].l, l, mid, delta, ty);\\n }\\n if (mid < delta) {\\n if (!tree[x].r) tree[x].r = ++tot;\\n gs(tree[x].r, mid + 1, r, delta, ty);\\n }\\n update(x);\\n}\\nint main() {\\n read(n);\\n for (int i = 1; i <= n; i++)...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nInnovation technologies are on a victorious march around the planet. They integrate into all spheres of human activity!\\n\\nA restaurant called \\\"Dijkstra's Place\\\" has started thinking about optimizing the booking system. \\n\\nThere are n booking requests received by now. Each request is characterized by two numbers: ci and pi — the size of the group of visitors who will come via this request and the total sum of money they will spend in the restaurant, correspondingly.\\n\\nWe know that for each request, all ci people want to sit at the same table and are going to spend the whole evening in the restaurant, from the opening moment at 18:00 to the closing moment.\\n\\nUnfortunately, there only are k tables in the restaurant. For each table, we know ri — the maximum number of people who can sit at it. A table can have only people from the same group sitting at it. If you cannot find a large enough table for the whole group, then all visitors leave and naturally, pay nothing.\\n\\nYour task is: given the tables and the requests, decide which requests to accept and which requests to decline so that the money paid by the happy and full visitors was maximum.\\n\\nInput\\n\\nThe first line of the input contains integer n (1 ≤ n ≤ 1000) — the number of requests from visitors. Then n lines follow. Each line contains two integers: ci, pi (1 ≤ ci, pi ≤ 1000) — the size of the group of visitors who will come by the i-th request and the total sum of money they will pay when they visit the restaurant, correspondingly.\\n\\nThe next line contains integer k (1 ≤ k ≤ 1000) — the number of tables in the restaurant. The last line contains k space-separated integers: r1, r2, ..., rk (1 ≤ ri ≤ 1000) — the maximum number of people that can sit at each table.\\n\\nOutput\\n\\nIn the first line print two integers: m, s — the number of accepted requests and the total money you get from these requests, correspondingly.\\n\\nThen print m lines — each line must contain two space-separated integers: the number of the accepted request and the number of the table to seat people who...\",\"targets\":\"#include \\nusing namespace std;\\nstruct c {\\n long long m, p, id;\\n};\\nbool comp(c a, c b) {\\n if (a.m != b.m) return a.m > b.m;\\n return a.p < b.p;\\n}\\nint main() {\\n long long n, k;\\n cin >> n;\\n vector v(n);\\n long long j = 0;\\n for (auto &i : v) cin >> i.p >> i.m, i.id = ++j;\\n cin >> k;\\n j = 0;\\n vector> t(k);\\n for (auto &i : t) cin >> i.first, i.second = ++j;\\n sort(v.begin(), v.end(), comp);\\n sort(t.begin(), t.end());\\n vector> ans;\\n long long tot = 0;\\n map used;\\n for (auto i : v) {\\n for (auto j : t) {\\n if (j.first >= i.p && used[j.second] == 0) {\\n used[j.second] = 1;\\n tot += i.m;\\n ans.push_back({i.id, j.second});\\n break;\\n }\\n }\\n }\\n cout << ans.size() << \\\" \\\" << tot << \\\"\\\\n\\\";\\n for (auto i : ans) cout << i.first << \\\" \\\" << i.second << \\\"\\\\n\\\";\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 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\":\"for _ in range(int(input())):\\n c,d = list(map(int, input().split()))\\n \\n if abs(c-d)%2 == 1:\\n print(-1)\\n elif c==0 and d==0:\\n print(0)\\n elif c == 0 or d == 0:\\n print(2)\\n elif c == d:\\n print(1)\\n else:\\n print(2)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"\\\"Search\\\" is an operation to obtain the desired information from a large amount of information. Familiar examples include \\\"finding your own exam number from a large number of exam numbers\\\" when announcing your success, or \\\"finding Taro Aizu's phone number\\\" from your phone book. This search operation is also widely used in the computer field.\\n\\n\\n\\n\\nThere are many ways to search. Consider a search method that can be used when the data to be searched is arranged in ascending (or largest) order.\\n\\nUsing the magnitude relationship between the value located in the center of the data string arranged in ascending order (or in descending order) and the target value, the first half is set as the search range or the second half is searched from the value located in the center. There is a way to narrow down the search range by deciding whether to make it a range. The procedure is as follows.\\n\\n1. The entire column of data is the scope of the search.\\n2. Examine the value located in the center of the search range.\\n3. If the desired value matches the centered value, the search ends.\\n4. If it is smaller than the target value and the value located in the center, the first half is the search range, and if it is larger, the second half is the search range and returns to 2.\\n\\n\\n\\nThe following is an example of the search method described above. The desired value in this example is 51. Each piece of data is numbered (index), which starts at 0.\\n\\n\\n\\n\\n\\n\\nStep 1: Initially, the search range is the entire number 0-6.\\n\\nStep 2: Find the value in the center of the search range. However, the \\\"centered value\\\" is the value at the position of the number obtained by dividing (the number on the left side + the number on the right side) by 2. In other words, in this case, (0 + 6) ÷ 2 is calculated, and the value (36) at number 3 is the value located in the center.\\n\\nStep 3: Compare the desired value (51) with the centrally located value (36).\\n\\nStep 4: From the result of step 3, the target value is larger than the value located in the center, so the...\\nSolve the task in CPP.\",\"targets\":\"#include\\nusing namespace std;\\n\\nint n,k;\\nint* a;\\n\\nint binary_search(){\\n\\tint l=0,r=n-1;\\n\\tint ans = 0;\\n\\twhile(l<=r){\\n\\t\\tint m = (l+r)\\/2;\\n\\t\\tif(ans++,k == a[m])\\n\\t\\t\\tbreak;\\n\\t\\telse if(k>a[m])\\n\\t\\t\\tl = m+1;\\n\\t\\telse\\n\\t\\t\\tr = m-1;\\n\\t}\\n\\treturn ans;\\n}\\n\\nint main(){\\n\\twhile(true){\\n\\t\\tcin >> n;\\n\\t\\tif(!n)\\n\\t\\t\\treturn 0;\\n\\t\\ta = new int[n];\\n\\t\\tfor(int i=0; i> a[i];\\n\\t\\tcin >> k;\\n\\t\\tcout << binary_search() << endl;\\n\\t\\tdelete[] a;\\n\\t}\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nCQXYM 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;\\nusing ll = long long;\\nusing ull = unsigned long long;\\nusing ld = long double;\\nconstexpr int pct(int x) { return __builtin_popcount(x); }\\nconstexpr int pct(long long x) { return __builtin_popcountll(x); }\\nconstexpr int bits(int x) { return x == 0 ? 0 : 31 - __builtin_clz(x); }\\nconstexpr int bits(long long x) { return x == 0 ? 0 : 63 - __builtin_clzll(x); }\\nconstexpr int p2(int x) { return 1 << x; }\\nconstexpr int msk2(int x) { return p2(x) - 1; }\\ntemplate \\nT ipow(T a, U p) {\\n T ans = 1;\\n assert(p >= 0);\\n for (; p; p \\/= 2, a *= a)\\n if (p & 1) ans *= a;\\n return ans;\\n}\\ntemplate \\nT ipow(T a, U p, T m) {\\n T ans = 1;\\n assert(p >= 0);\\n for (; p; p \\/= 2, a = (a * a) % m)\\n if (p & 1) ans = (ans * a) % m;\\n return ans;\\n}\\ntemplate \\nT fstTrue(T lo, T hi, U f) {\\n hi++;\\n assert(lo <= hi);\\n while (lo < hi) {\\n T mid = lo + (hi - lo) \\/ 2;\\n f(mid) ? hi = mid : lo = mid + 1;\\n }\\n return lo;\\n}\\ntemplate \\nT lstTrue(T lo, T hi, U f) {\\n lo--;\\n assert(lo <= hi);\\n while (lo < hi) {\\n T mid = lo + (hi - lo + 1) \\/ 2;\\n f(mid) ? lo = mid : hi = mid - 1;\\n }\\n return lo;\\n}\\ntemplate \\nT sum(vector &v) {\\n if (v.empty()) return 0LL;\\n T sum = v[0];\\n for (int i = 1; i < (int)v.size(); i++) {\\n sum += v[i];\\n }\\n return sum;\\n}\\ntemplate \\nF posmod(F a, F b) {\\n return ((a % b) + b) % b;\\n}\\ntemplate \\nstruct Point {\\n F x, y;\\n Point() : x(0), y(0) {}\\n Point(const F &cx, const F &cy) : x(cx), y(cy) {}\\n};\\ntemplate \\nF ceildiv(F a, F d) {\\n F res = a \\/ d;\\n if (res * d != a) res += 1 & ((a < 0) ^ (d > 0));\\n return res;\\n}\\ntemplate \\nF sq(F a) {\\n return a * a;\\n}\\nlong long inv(long long a, long long b) {\\n return 1 < a ? b - inv(b % a, a) * b \\/ a : 1;\\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}\\nint dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1,...\",\"language\":\"python\",\"split\":\"test\",\"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 CPP.\",\"targets\":\"#include \\nusing namespace std;\\nvoid solve() {\\n int n;\\n cin >> n;\\n vector w(n);\\n for (int i = 0; i < n; i++) cin >> w[i];\\n vector> dp(n + 1, vector(2001, 2000));\\n dp[0][0] = 0;\\n for (int i = 0; i < n; i++)\\n for (int j = 0; j <= 2000; j++)\\n if (dp[i][j] != 2000) {\\n if (j + w[i] <= 2000)\\n dp[i + 1][j + w[i]] =\\n min(dp[i + 1][j + w[i]], max(dp[i][j], j + w[i]));\\n if (j - w[i] >= 0)\\n dp[i + 1][j - w[i]] =\\n min(dp[i + 1][j - w[i]], max(dp[i][j], j - w[i]));\\n else\\n dp[i + 1][0] = min(dp[i + 1][0], dp[i][j] + w[i] - j);\\n }\\n int ans = 2000;\\n for (int j = 0; j <= 2000; j++) ans = min(ans, dp[n][j]);\\n cout << ans << endl;\\n}\\nsigned main() {\\n int T = 1;\\n cin >> T;\\n while (T--) solve();\\n return 0;\\n}\",\"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.\\nUsing python3 can you solve the prior task?\",\"targets\":\"# SHRi GANESHA author: Kunal Verma #\\n\\nimport os\\nimport random\\nimport sys\\n\\nfrom itertools import *\\n\\nfrom io import BytesIO, IOBase\\n\\n\\ndef lcm(a, b):\\n return (a * b) \\/\\/ gcd(a, b)\\n\\n\\n'''\\n mod = 10 ** 9 + 7\\n fac = [1]\\n for i in range(1, 2 * 10 ** 5 + 1):\\n fac.append((fac[-1] * i) % mod)\\n fac_in = [pow(fac[-1], mod - 2, mod)]\\n for i in range(2 * 10 ** 5, 0, -1):\\n fac_in.append((fac_in[-1] * i) % mod)\\n fac_in.reverse()\\n def comb(a, b):\\n if a < b:\\n return 0\\n return (fac[a] * fac_in[b] * fac_in[a - b]) % mod\\n'''\\n\\n\\n# MAXN = 10000004\\n# spf = [0 for i in range(MAXN)]\\n# adj = [[] for i in range(MAXN)]\\ndef sieve():\\n global spf, adj, MAXN\\n spf[1] = 1\\n for i in range(2, MAXN):\\n spf[i] = i\\n\\n for i in range(2, MAXN):\\n if i * i > MAXN:\\n break\\n if (spf[i] == i):\\n for j in range(i * i, MAXN, i):\\n if (spf[j] == j):\\n spf[j] = i\\n\\n\\ndef getdistinctFactorization(n):\\n global adj, spf, MAXN\\n for i in range(1, n + 1):\\n index = 1\\n x = i\\n if (x != 1):\\n adj[i].append(spf[x])\\n x = x \\/\\/ spf[x]\\n while (x != 1):\\n if (adj[i][index - 1] != spf[x]):\\n adj[i].append(spf[x])\\n index += 1\\n x = x \\/\\/ spf[x]\\n\\n\\ndef printDivisors(n):\\n i = 2\\n z = [1, n]\\n while i <= sqrt(n):\\n if (n % i == 0):\\n if (n \\/ i == i):\\n z.append(i)\\n else:\\n z.append(i)\\n z.append(n \\/\\/ i)\\n i = i + 1\\n return z\\n\\n\\ndef create(n, x, f):\\n pq = len(bin(n)[2:])\\n if f == 0:\\n tt = min\\n else:\\n tt = max\\n dp = [[inf] * n for _ in range(pq)]\\n dp[0] = x\\n for i in range(1, pq):\\n for j in range(n - (1 << i) + 1):\\n dp[i][j] = tt(dp[i - 1][j], dp[i - 1][j + (1 << (i - 1))])\\n return dp\\n\\n\\ndef enquiry(l, r, dp, f):\\n if l > r:\\n return inf if not f else -inf\\n if f == 1:\\n tt = max\\n else:\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"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.\\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.util.Arrays;\\nimport java.util.StringTokenizer;\\n\\npublic class C {\\n\\n\\n private int[] a;\\n private int[] next;\\n int[][] cnt;\\n\\n int count(int l0, int r0) {\\n if (cnt[l0][r0] != -1) {\\n return cnt[l0][r0];\\n }\\n int l = l0;\\n int r = r0;\\n int to = a[l];\\n while (l < r && a[l] == to) {\\n l++;\\n }\\n while (l < r && a[r - 1] == to) {\\n r--;\\n }\\n if (l == r) {\\n return cnt[l0][r0] = 0;\\n }\\n int best = count(l, r) + 1;\\n int x = l - 1;\\n while (next[x] < r) {\\n best = Math.min(best, count(l, next[x]) + 1 + count(next[x], r));\\n x = next[x];\\n }\\n\\/\\/ System.err.println(l0 + \\\" \\\" + r0 + \\\" \\\" + Arrays.toString(Arrays.copyOfRange(a, l0, r0)) + \\\" -> \\\" + best);\\n return cnt[l0][r0] = best;\\n }\\n\\n void solve() {\\n int n = nextInt();\\n a = new int[n];\\n int[] last = new int[n];\\n next = new int[n];\\n cnt = new int[n + 1][n + 1];\\n for (int[] x : cnt) {\\n Arrays.fill(x, -1);\\n }\\n Arrays.fill(last, -1);\\n Arrays.fill(next, Integer.MAX_VALUE \\/ 2);\\n for (int i = 0; i < n; i++) {\\n a[i] = nextInt() - 1;\\n if (last[a[i]] != -1) {\\n next[last[a[i]]] = i;\\n }\\n last[a[i]] = i;\\n }\\n out.println(count(0, n));\\n\\n }\\n\\n\\n BufferedReader br;\\n StringTokenizer st;\\n PrintWriter out;\\n\\n String next() {\\n while (st == null || !st.hasMoreTokens()) {\\n try {\\n st = new StringTokenizer(br.readLine());\\n } catch (IOException e) {\\n e.printStackTrace();\\n System.exit(1);\\n }\\n\\n }\\n return st.nextToken();\\n }\\n\\n int nextInt() {\\n return Integer.parseInt(next());\\n }\\n\\n void run() {\\n br = new...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"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;...\\nUsing java can you solve the prior task?\",\"targets\":\"\\/*\\n Author : Akshat Jindal\\n from NIT Jalandhar , Punjab , India\\n JAI MATA DI\\n *\\/\\nimport java.util.*;\\n\\n\\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...\",\"language\":\"python\",\"split\":\"valid\",\"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.\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(0);\\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 auto solve = [&]() {\\n for (int i = 0; i < n - 1; ++i)\\n if (a[i + 1].second != a[i].second + 1) --k;\\n return k > 0;\\n };\\n if (solve())\\n cout << \\\"YES\\\\n\\\";\\n else\\n cout << \\\"NO\\\\n\\\";\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"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 solve() {\\n int n;\\n cin >> n;\\n int j;\\n cout << 2 << \\\" \\\";\\n for (int i = 1; i < n; i++) {\\n cout << i + 2 << \\\" \\\";\\n }\\n cout << endl;\\n}\\nint main() {\\n int t;\\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\":\"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.\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\n#pragma GCC optimize(\\\"Ofast\\\")\\nusing namespace std;\\nunsigned long long int bigMod(unsigned long long int b,\\n unsigned long long int p,\\n unsigned long long int m) {\\n b = b % m;\\n if (p == 0)\\n return 1;\\n else if (p % 2 == 0)\\n return ((unsigned long long int)pow(bigMod(b, p \\/ 2, m), 2)) % m;\\n else\\n return ((unsigned long long int)pow(bigMod(b, (p - 1) \\/ 2, m), 2) * b) % m;\\n}\\nunsigned long long int nCr(unsigned long long int n, unsigned long long int r) {\\n unsigned long long int ans = 1;\\n if (r >= n - r) {\\n for (unsigned long long int i = r + 1; i <= n; i++) {\\n ans = ans * i;\\n }\\n for (unsigned long long int i = 1; i <= n - r; i++) {\\n ans = ans \\/ i;\\n }\\n } else {\\n for (unsigned long long int i = n - r + 1; i <= n; i++) {\\n ans = ans * i;\\n }\\n for (unsigned long long int i = 1; i <= r; i++) {\\n ans = ans \\/ i;\\n }\\n }\\n return ans;\\n}\\nunsigned long long int fib(unsigned long long int a) {\\n const long double root5 = sqrt(5);\\n const long double root5plus1div2 = (root5 + 1) \\/ 2;\\n return round(pow(root5plus1div2, a) \\/ root5);\\n}\\nunsigned long long int gcd(unsigned long long int a, unsigned long long int b) {\\n if (b == 0)\\n return a;\\n else\\n return gcd(b, a % b);\\n}\\nunsigned long long int lcm(unsigned long long int a, unsigned long long int b) {\\n return ((a * b) \\/ gcd(a, b));\\n}\\nbool isPrime(unsigned long long int a) {\\n if (a % 2 == 0) return false;\\n for (int i = 3; i <= sqrt(a); i += 2) {\\n if (a % i == 0) return false;\\n }\\n return true;\\n}\\nbool isComposite(unsigned long long int a) {\\n if (isPrime(a))\\n return false;\\n else\\n return true;\\n}\\nbool coPrime(unsigned long long int a, unsigned long long int b) {\\n if (gcd(a, b) == 1)\\n return true;\\n else\\n return false;\\n}\\nlong double toRadian(long double deg) { return (deg * acos(-1) \\/ 180); }\\nunsigned long long int strToInt(string a) {\\n int len = a.length();\\n int power = 0;\\n unsigned long long int tot = 0;\\n for (int i...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in PYTHON3?\\nPolycarp 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\":\"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"Untitled31.ipynb\\n\\nAutomatically generated by Colaboratory.\\n\\nOriginal file is located at\\n https:\\/\\/colab.research.google.com\\/drive\\/1KIMGKtysGvCh5fHWDLeypumcdNdgMbs-\\n\\\"\\\"\\\"\\n\\nimport math \\nt=int(input())\\nfor i in range(t):\\n n=int(input())\\n s=math.sqrt(n)\\n if s==int(s):\\n print(int(s),1)\\n else:\\n k=int(s)\\n x=n-(k*k)\\n if x>k+1:\\n a=k+1\\n b=1+((k+1)*(k+1)-n)\\n else:\\n a=(n-(k*k))\\n\\n b=k+1\\n print(a,b)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Find \\\\displaystyle{\\\\sum_{a=1}^{K}\\\\sum_{b=1}^{K}\\\\sum_{c=1}^{K} \\\\gcd(a,b,c)}.\\n\\nHere \\\\gcd(a,b,c) denotes the greatest common divisor of a, b, and c.\\n\\nConstraints\\n\\n* 1 \\\\leq K \\\\leq 200\\n* K is an integer.\\n\\nInput\\n\\nInput is given from Standard Input in the following format:\\n\\n\\nK\\n\\n\\nOutput\\n\\nPrint the value of \\\\displaystyle{\\\\sum_{a=1}^{K}\\\\sum_{b=1}^{K}\\\\sum_{c=1}^{K} \\\\gcd(a,b,c)}.\\n\\nExamples\\n\\nInput\\n\\n2\\n\\n\\nOutput\\n\\n9\\n\\n\\nInput\\n\\n200\\n\\n\\nOutput\\n\\n10813692\\nUsing python3 can you solve the prior task?\",\"targets\":\"import math\\n \\nN=int(input())\\n \\nA = 0\\nfor i in range(1,N+1):\\n for j in range(1,N+1):\\n for k in range(1,N+1):\\n A += math.gcd(math.gcd(i,j),k)\\n\\nprint(A)\",\"language\":\"python\",\"split\":\"train\",\"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\":\"def main():\\n n = int(input())\\n vectors = [list(map(int, input().split())) for _ in range(n)]\\n vector_sum = list(map(sum, zip(*vectors)))\\n if (vector_sum[0] == 0) and (vector_sum[1] == 0) and (vector_sum[2] == 0):\\n print('YES')\\n else:\\n print('NO')\\n\\nif __name__ == '__main__':\\n main()\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Comrade Dujikov is busy choosing artists for Timofey's birthday and is recieving calls from Taymyr from Ilia-alpinist.\\n\\nIlia-alpinist calls every n minutes, i.e. in minutes n, 2n, 3n and so on. Artists come to the comrade every m minutes, i.e. in minutes m, 2m, 3m and so on. The day is z minutes long, i.e. the day consists of minutes 1, 2, ..., z. How many artists should be killed so that there are no artists in the room when Ilia calls? Consider that a call and a talk with an artist take exactly one minute.\\n\\nInput\\n\\nThe only string contains three integers — n, m and z (1 ≤ n, m, z ≤ 104).\\n\\nOutput\\n\\nPrint single integer — the minimum number of artists that should be killed so that there are no artists in the room when Ilia calls.\\n\\nExamples\\n\\nInput\\n\\n1 1 10\\n\\n\\nOutput\\n\\n10\\n\\n\\nInput\\n\\n1 2 5\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n2 3 9\\n\\n\\nOutput\\n\\n1\\n\\nNote\\n\\nTaymyr is a place in the north of Russia.\\n\\nIn the first test the artists come each minute, as well as the calls, so we need to kill all of them.\\n\\nIn the second test we need to kill artists which come on the second and the fourth minutes.\\n\\nIn the third test — only the artist which comes on the sixth minute. \\nfrom\",\"targets\":\"math import gcd\\nn,m,z = map(int,input().split())\\nh = gcd(n,m)\\nf = (n*m\\/\\/h)\\nprint(z\\/\\/f)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"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.*;\\nimport java.util.*;\\nimport java.io.BufferedReader;\\nimport java.io.FileReader;\\nimport java.io.IOException;\\nimport static java.lang.Math.*;\\nimport java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.util.Scanner;\\nimport java.util.StringTokenizer;\\nimport java.util.zip.ZipError;\\n\\n\\nimport java.io.InputStreamReader;\\nimport java.util.StringTokenizer;\\n\\npublic class Solution {\\n\\n static int MOD = 998244353;\\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\\n \\n\\tpublic static void main(String[] args)throws IOException {\\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\\n FastReader s = new FastReader();\\n int t = s.nextInt();\\n for(int i = 0; i < t; i++ ){\\n int n = s.nextInt();\\n int m = s.nextInt();\\n int[] arr = new int[m];\\n for(int j = 0; j < m; j++){\\n arr[j] = s.nextInt();\\n }\\n solve(m ,arr);\\n }\\n }\\n\\n\\n static void solve(int n, int[] arr){\\n int...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"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\":\"import math\\nt = int(input())\\nfor _ in range(t):\\n n = int(input())\\n s = list(input())\\n color = 'B'\\n count=0\\n if s.count(\\\"?\\\")==0:\\n print(\\\"\\\".join(s))\\n continue\\n for i in range(n):\\n if s[i]=='?':\\n count+=1\\n #print(count)\\n\\n elif s[i]=='B' and count:\\n color = 'R'\\n for j in range(i-1,i-count-1,-1):\\n s[j] = color\\n if color =='R':\\n color = 'B'\\n else:\\n color = 'R'\\n count=0\\n #print(\\\"\\\".join(s))\\n elif s[i]=='R' and count:\\n color = 'B'\\n for j in range(i - 1, i - count - 1, -1):\\n s[j] = color\\n if color == 'R':\\n color = 'B'\\n else:\\n color = 'R'\\n count=0\\n #print(\\\"\\\".join(s))\\n if i==(n-1) and count:\\n if s[i-count] == 'B':\\n color = 'R'\\n else :\\n color = 'B'\\n for j in range(i-count+1,i+1):\\n s[j] = color\\n if color == 'R':\\n color = 'B'\\n else:\\n color = 'R'\\n count=0\\n #print(\\\"\\\".join(s))\\n\\n print(\\\"\\\".join(s))\\n #print()\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"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.\",\"targets\":\"#include \\nusing namespace std;\\nvoid solve() {\\n int n;\\n scanf(\\\"%d\\\", &n);\\n vector a(n);\\n map cnt;\\n for (int i = 0; i < n; i++) {\\n scanf(\\\"%d\\\", &a[i]);\\n cnt[a[i]]++;\\n }\\n long long sum = accumulate(a.begin(), a.end(), 0ll);\\n if ((2 * sum) % n != 0) {\\n puts(\\\"0\\\");\\n return;\\n }\\n long long need = (2 * sum) \\/ n;\\n long long ans = 0;\\n for (int i = 0; i < n; i++) {\\n int a1 = a[i];\\n int a2 = need - a1;\\n if (cnt.count(a2)) ans += cnt[a2];\\n if (a1 == a2) ans -= 1;\\n }\\n printf(\\\"%lld\\\\n\\\", ans \\/ 2);\\n}\\nint main() {\\n int t;\\n scanf(\\\"%d\\\", &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\":\"Ivan 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...\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"n = int(input())\\narr = [list(map(int, input().split())) for i in range(n)]\\nm = int(input())\\nblock = list(tuple(map(int, input().split())) for i in range(m))\\ns = set(block)\\nma = 0\\nans = []\\nif tuple(len(a)-1 for a in arr) not in s:\\n print(*[len(a)-1 for a in arr])\\n exit()\\nfor a1 in block:\\n a = list(a1)\\n for i in range(n):\\n if a[i] > 1:\\n a[i] -= 1\\n if tuple(a) not in s:\\n k = sum(arr[i][a[i]] for i in range(n))\\n if k > ma:\\n ma = k\\n ans = a[:]\\n a[i] += 1\\n\\nprint(*ans)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"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\":\"import java.io.*;\\nimport java.util.*;\\n\\npublic class E {\\n static class FastReader {\\n BufferedReader br;\\n StringTokenizer st;\\n\\n public FastReader() {\\n br = new BufferedReader(new\\n 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 static FastReader s = new FastReader();\\n static PrintWriter out = new PrintWriter(System.out);\\n\\n private static int[] rai(int n) {\\n int[] arr = new int[n];\\n for (int i = 0; i < n; i++) {\\n arr[i] = s.nextInt();\\n }\\n return arr;\\n }\\n\\n private static int[][] rai(int n, int m) {\\n int[][] arr = new int[n][m];\\n for (int i = 0; i < n; i++) {\\n for (int j = 0; j < m; j++) {\\n arr[i][j] = s.nextInt();\\n }\\n }\\n return arr;\\n }\\n\\n private static long[] ral(int n) {\\n long[] arr = new long[n];\\n for (int i = 0; i < n; i++) {\\n arr[i] = s.nextLong();\\n }\\n return arr;\\n }\\n\\n private static long[][] ral(int n, int m) {\\n long[][] arr = new long[n][m];\\n for (int i = 0; i < n; i++) {\\n for (int j = 0; j < m; j++) {\\n arr[i][j] = s.nextLong();\\n }\\n }\\n...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"After returning from the army Makes received a gift — an array a consisting of n positive integer numbers. He hadn't been solving problems for a long time, so he became interested to answer a particular question: how many triples of indices (i, j, k) (i < j < k), such that ai·aj·ak is minimum possible, are there in the array? Help him with it!\\n\\nInput\\n\\nThe first line of input contains a positive integer number n (3 ≤ n ≤ 105) — the number of elements in array a. The second line contains n positive integer numbers ai (1 ≤ ai ≤ 109) — the elements of a given array.\\n\\nOutput\\n\\nPrint one number — the quantity of triples (i, j, k) such that i, j and k are pairwise distinct and ai·aj·ak is minimum possible.\\n\\nExamples\\n\\nInput\\n\\n4\\n1 1 1 1\\n\\n\\nOutput\\n\\n4\\n\\n\\nInput\\n\\n5\\n1 3 2 3 4\\n\\n\\nOutput\\n\\n2\\n\\n\\nInput\\n\\n6\\n1 3 3 1 3 2\\n\\n\\nOutput\\n\\n1\\n\\nNote\\n\\nIn the first example Makes always chooses three ones out of four, and the number of ways to choose them is 4.\\n\\nIn the second example a triple of numbers (1, 2, 3) is chosen (numbers, not indices). Since there are two ways to choose an element 3, then the answer is 2.\\n\\nIn the third example a triple of numbers (1, 1, 2) is chosen, and there's only one way to choose indices.\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"from math import factorial as f\\ninput()\\na=sorted(input().split(),key=int)\\nx,y=a.count(a[2]),a[:3].count(a[2])\\nprint(f(x)\\/\\/(f(y)*f(x-y)))\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA 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\":\"import java.io.*;\\nimport java.math.BigInteger;\\nimport java.util.*;\\n\\npublic class Main {\\n static int MOD = 1000000007;\\n\\n \\/\\/ After writing solution, quick scan for:\\n \\/\\/ array out of bounds\\n \\/\\/ special cases e.g. n=1?\\n \\/\\/ npe, particularly in maps\\n \\/\\/\\n \\/\\/ Big numbers arithmetic bugs:\\n \\/\\/ int overflow\\n \\/\\/ sorting, or taking max, after MOD\\n void solve() throws IOException {\\n int T = ri();\\n for (int Ti = 0; Ti < T; Ti++) {\\n int n = ri();\\n int[] a = ril(n);\\n if (n % 2 == 0) {\\n pw.println(\\\"YES\\\");\\n continue;\\n }\\n boolean done = false;\\n for (int i = 1; !done && i < n; i++) {\\n if (a[i] <= a[i-1]) {\\n pw.println(\\\"YES\\\");\\n done = true;\\n }\\n }\\n if (done) continue;\\n pw.println(\\\"NO\\\");\\n }\\n }\\n \\/\\/ IMPORTANT\\n \\/\\/ DID YOU CHECK THE COMMON MISTAKES ABOVE?\\n\\n \\/\\/ Template code below\\n\\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\\n PrintWriter pw = new PrintWriter(System.out);\\n\\n public static void main(String[] args) throws IOException {\\n Main m = new Main();\\n m.solve();\\n m.close();\\n }\\n\\n void close() throws IOException {\\n pw.flush();\\n pw.close();\\n br.close();\\n }\\n\\n int ri() throws IOException {\\n return Integer.parseInt(br.readLine().trim());\\n }\\n\\n long rl() throws IOException {\\n return Long.parseLong(br.readLine().trim());\\n }\\n\\n int[] ril(int n) throws IOException {\\n int[] nums = new int[n];\\n int c = 0;\\n for (int i = 0; i < n; i++) {\\n int sign = 1;\\n c = br.read();\\n int x = 0;\\n if (c == '-') {\\n sign = -1;\\n c = br.read();\\n }\\n while (c >= '0' && c <= '9') {\\n x = x * 10 + c - '0';\\n c = br.read();\\n }\\n ...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"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). \\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.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 *\\/\\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 AOperatsiiBivayutRaznie solver = new AOperatsiiBivayutRaznie();\\n int testCount = Integer.parseInt(in.next());\\n for (int i = 1; i <= testCount; i++)\\n solver.solve(i, in, out);\\n out.close();\\n }\\n\\n static class AOperatsiiBivayutRaznie {\\n public void solve(int testNumber, InputReader in, PrintWriter out) {\\n int a = in.nextInt();\\n int b = in.nextInt();\\n if (a == 0 && b == 0) {\\n out.println(0);\\n return;\\n }\\n if (a == b) {\\n out.println(1);\\n return;\\n }\\n if (Math.abs(a - b) % 2 == 1) {\\n out.println(-1);\\n } else {\\n out.println(2);\\n }\\n }\\n\\n }\\n\\n static class InputReader {\\n private static final int BUFFER_LENGTH = 1 << 10;\\n private InputStream stream;\\n private byte[] buf = new byte[BUFFER_LENGTH];\\n private int curChar;\\n private int numChars;\\n\\n public InputReader(InputStream stream) {\\n this.stream = stream;\\n }\\n\\n private int nextC() {\\n if (numChars == -1) {\\n throw new InputMismatchException();\\n }\\n if (curChar >= numChars) {\\n curChar = 0;\\n try {\\n numChars = stream.read(buf);\\n } catch (IOException e) {\\n throw new InputMismatchException();\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A string s of length n can be encrypted by the following algorithm:\\n\\n * iterate over all divisors of n in decreasing order (i.e. from n to 1), \\n * for each divisor d, reverse the substring s[1 ... d] (i.e. the substring which starts at position 1 and ends at position d). \\n\\n\\n\\nFor example, the above algorithm applied to the string s=\\\"codeforces\\\" leads to the following changes: \\\"codeforces\\\" → \\\"secrofedoc\\\" → \\\"orcesfedoc\\\" → \\\"rocesfedoc\\\" → \\\"rocesfedoc\\\" (obviously, the last reverse operation doesn't change the string because d=1).\\n\\nYou are given the encrypted string t. Your task is to decrypt this string, i.e., to find a string s such that the above algorithm results in string t. It can be proven that this string s always exists and is unique.\\n\\nInput\\n\\nThe first line of input consists of a single integer n (1 ≤ n ≤ 100) — the length of the string t. The second line of input consists of the string t. The length of t is n, and it consists only of lowercase Latin letters.\\n\\nOutput\\n\\nPrint a string s such that the above algorithm results in t.\\n\\nExamples\\n\\nInput\\n\\n10\\nrocesfedoc\\n\\n\\nOutput\\n\\ncodeforces\\n\\n\\nInput\\n\\n16\\nplmaetwoxesisiht\\n\\n\\nOutput\\n\\nthisisexampletwo\\n\\n\\nInput\\n\\n1\\nz\\n\\n\\nOutput\\n\\nz\\n\\nNote\\n\\nThe first example is described in the problem statement.\\nUsing python3 can you solve the prior task?\",\"targets\":\"# Codeforces Round #490 (Div. 3)\\nimport collections\\nfrom functools import cmp_to_key\\n#key=cmp_to_key(lambda x,y: 1 if x not in y else -1 )\\nimport math\\nimport sys\\ndef getIntList():\\n return list(map(int, input().split())) \\n\\nimport bisect \\ntry :\\n import numpy\\n dprint = print\\n dprint('debug mode')\\nexcept ModuleNotFoundError:\\n def dprint(*args, **kwargs):\\n pass\\ndef makePair(z):\\n return [(z[i], z[i+1]) for i in range(0,len(z),2) ]\\n\\n \\nN, = getIntList()\\n\\ns = input()\\ns = list(s)\\nfor d in range(2,N+1):\\n if N %d !=0: continue\\n dprint(d)\\n \\n x = s[ : d]\\n x.reverse()\\n s[ : d] = x\\n dprint(s)\\nprint(''.join(s) )\",\"language\":\"python\",\"split\":\"train\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Berland State University invites people from all over the world as guest students. You can come to the capital of Berland and study with the best teachers in the country.\\n\\nBerland State University works every day of the week, but classes for guest students are held on the following schedule. You know the sequence of seven integers a_1, a_2, ..., a_7 (a_i = 0 or a_i = 1):\\n\\n * a_1=1 if and only if there are classes for guest students on Sundays; \\n * a_2=1 if and only if there are classes for guest students on Mondays; \\n * ... \\n * a_7=1 if and only if there are classes for guest students on Saturdays. \\n\\n\\n\\nThe classes for guest students are held in at least one day of a week.\\n\\nYou want to visit the capital of Berland and spend the minimum number of days in it to study k days as a guest student in Berland State University. Write a program to find the length of the shortest continuous period of days to stay in the capital to study exactly k days as a guest student.\\n\\nInput\\n\\nThe first line of the input contains integer t (1 ≤ t ≤ 10 000) — the number of test cases to process. For each test case independently solve the problem and print the answer. \\n\\nEach test case consists of two lines. The first of them contains integer k (1 ≤ k ≤ 10^8) — the required number of days to study as a guest student. The second line contains exactly seven integers a_1, a_2, ..., a_7 (a_i = 0 or a_i = 1) where a_i=1 if and only if classes for guest students are held on the i-th day of a week.\\n\\nOutput\\n\\nPrint t lines, the i-th line should contain the answer for the i-th test case — the length of the shortest continuous period of days you need to stay to study exactly k days as a guest student.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n2\\n0 1 0 0 0 0 0\\n100000000\\n1 0 0 0 1 0 1\\n1\\n1 0 0 0 0 0 0\\n\\n\\nOutput\\n\\n\\n8\\n233333332\\n1\\n\\nNote\\n\\nIn the first test case you must arrive to the capital of Berland on Monday, have classes on this day, spend a week until next Monday and have classes on the next Monday. In total you need to spend 8 days in the capital of Berland.\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nvoid sol() {\\n int k;\\n int a[7], day = 0, b[7];\\n cin >> k;\\n int ans = 7 * k;\\n for (int &i : a) cin >> i, day += i;\\n for (int i = 0; i < 7; ++i) {\\n if (!a[i]) continue;\\n int cnt = 0;\\n for (int j = 1; j <= 7; ++j) {\\n if (a[(i + j - 1) % 7]) {\\n ++cnt;\\n b[cnt] = j;\\n }\\n }\\n int tmp = (k - 1) \\/ day;\\n ans = min(ans, tmp * 7 + b[k - tmp * day]);\\n }\\n cout << ans << '\\\\n';\\n}\\nint main() {\\n int t;\\n cin >> t;\\n while (t--) {\\n sol();\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.\\n\\nIn one second, Genos is able to choose exactly one continuous substring of colored gemstones that is a palindrome and remove it from the line. After the substring is removed, the remaining gemstones shift to form a solid line again. What is the minimum number of seconds needed to destroy the entire line?\\n\\nLet us remind, that the string (or substring) is called palindrome, if it reads same backwards or forward. In our case this means the color of the first gemstone is equal to the color of the last one, the color of the second gemstone is equal to the color of the next to last and so on.\\n\\nInput\\n\\nThe first line of input contains a single integer n (1 ≤ n ≤ 500) — the number of gemstones.\\n\\nThe second line contains n space-separated integers, the i-th of which is ci (1 ≤ ci ≤ n) — the color of the i-th gemstone in a line.\\n\\nOutput\\n\\nPrint a single integer — the minimum number of seconds needed to destroy the entire line.\\n\\nExamples\\n\\nInput\\n\\n3\\n1 2 1\\n\\n\\nOutput\\n\\n1\\n\\n\\nInput\\n\\n3\\n1 2 3\\n\\n\\nOutput\\n\\n3\\n\\n\\nInput\\n\\n7\\n1 4 4 2 3 2 1\\n\\n\\nOutput\\n\\n2\\n\\nNote\\n\\nIn the first sample, Genos can destroy the entire line in one second.\\n\\nIn the second sample, Genos can only destroy one gemstone at a time, so destroying three gemstones takes three seconds.\\n\\nIn the third sample, to achieve the optimal time of two seconds, destroy palindrome 4 4 first and then destroy palindrome 1 2 3 2 1.\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint n;\\nint a[505];\\nint dp[505][505];\\nint solve(int l, int r) {\\n if (l >= r) return 1;\\n if (dp[l][r] != -1) return dp[l][r];\\n dp[l][r] = 1e9;\\n if (a[l] == a[r]) dp[l][r] = solve(l + 1, r - 1);\\n for (int i = l; i < r; i++)\\n dp[l][r] = min(dp[l][r], solve(l, i) + solve(i + 1, r));\\n return dp[l][r];\\n}\\nint main() {\\n scanf(\\\"%d\\\", &n);\\n for (int i = 1; i <= n; i++) scanf(\\\"%d\\\", &a[i]);\\n memset(dp, -1, sizeof(dp));\\n printf(\\\"%d\\\\n\\\", solve(1, n));\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"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\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"n=int(input())\\nxd=[]\\nyd=[]\\nzd=[]\\nfor i in range(n):\\n x,y,z=map(int,input().split())\\n xd+=[x]\\n yd+=[y]\\n zd+=[z]\\nif(sum(xd)!=0 or sum(yd)!=0 or sum(zd)!=0):\\n print(\\\"NO\\\")\\nelse:\\n print(\\\"YES\\\")\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nMojtaba and Arpa are playing a game. They have a list of n numbers in the game.\\n\\nIn a player's turn, he chooses a number pk (where p is a prime number and k is a positive integer) such that pk divides at least one number in the list. For each number in the list divisible by pk, call it x, the player will delete x and add to the list. The player who can not make a valid choice of p and k loses.\\n\\nMojtaba starts the game and the players alternatively make moves. Determine which one of players will be the winner if both players play optimally.\\n\\nInput\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 100) — the number of elements in the list.\\n\\nThe second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the elements of the list.\\n\\nOutput\\n\\nIf Mojtaba wins, print \\\"Mojtaba\\\", otherwise print \\\"Arpa\\\" (without quotes).\\n\\nYou can print each letter in any case (upper or lower).\\n\\nExamples\\n\\nInput\\n\\n4\\n1 1 1 1\\n\\n\\nOutput\\n\\nArpa\\n\\n\\nInput\\n\\n4\\n1 1 17 17\\n\\n\\nOutput\\n\\nMojtaba\\n\\n\\nInput\\n\\n4\\n1 1 17 289\\n\\n\\nOutput\\n\\nArpa\\n\\n\\nInput\\n\\n5\\n1 2 3 4 5\\n\\n\\nOutput\\n\\nArpa\\n\\nNote\\n\\nIn the first sample test, Mojtaba can't move.\\n\\nIn the second sample test, Mojtaba chooses p = 17 and k = 1, then the list changes to [1, 1, 1, 1].\\n\\nIn the third sample test, if Mojtaba chooses p = 17 and k = 1, then Arpa chooses p = 17 and k = 1 and wins, if Mojtaba chooses p = 17 and k = 2, then Arpa chooses p = 17 and k = 1 and wins.\",\"targets\":\"#include \\nusing namespace std;\\nunordered_map p;\\nmap dp;\\nint grundy(int x) {\\n if (dp[x]) return dp[x];\\n set s;\\n for (int i = 1; i <= 30; i++) {\\n int a = ((x >> i));\\n if (a) s.insert(grundy(a | (x & ((1 << i) - 1))));\\n }\\n int v = 0;\\n while (s.count(v)) {\\n v++;\\n }\\n dp[x] = v;\\n return v;\\n}\\nint main() {\\n std::ios::sync_with_stdio(false);\\n ;\\n int n;\\n std::cin >> n;\\n for (int i = 0; i < n; i++) {\\n int x;\\n std::cin >> x;\\n for (int j = 2; j * j <= x; j++) {\\n int ctr = 0;\\n while (x % j == 0) {\\n ctr++;\\n x \\/= j;\\n }\\n if (ctr) p[j] |= (1 << ctr);\\n }\\n if (x != 1) {\\n p[x] |= (2);\\n }\\n }\\n int ans = 0;\\n for (auto it : p) {\\n ans ^= (grundy(it.second));\\n }\\n if (ans)\\n std::cout << \\\"Mojtaba\\\" << endl;\\n else {\\n std::cout << \\\"Arpa\\\" << endl;\\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\\nUsing java can you solve the prior task?\",\"targets\":\"import java.util.*;\\nimport java.io.*;\\nimport java.math.*;\\n\\npublic class cf {\\n\\tstatic PrintWriter pw = new PrintWriter(System.out);\\n\\n\\tpublic static void main(String[] args) throws IOException, InterruptedException {\\n\\t\\tScanner sc = new Scanner(System.in);\\n\\t\\tint t = sc.nextInt();\\n\\t\\tarrl = new ArrayList<>();\\n\\t\\tgen(new HashSet<>(), \\\"\\\");\\n\\t\\tTreeSet ts = new TreeSet<>();\\n\\t\\tfor (String s : arrl) {\\n\\t\\t\\tif (s.length() != 0)\\n\\t\\t\\t\\tts.add(Integer.parseInt(s));\\n\\t\\t}\\n\\t\\tts.pollFirst();\\n\\t\\tts.add((int) 1e9);\\n\\/\\/\\t\\tpw.println(ts);\\n\\/\\/\\t\\tpw.println(ts.size());\\n\\t\\twhile (t-- > 0) {\\n\\t\\t\\tint n = sc.nextInt(), k = sc.nextInt();\\n\\t\\t\\tif (k == 1) {\\n\\t\\t\\t\\tString x = n + \\\"\\\";\\n\\t\\t\\t\\tint y = x.charAt(0) - '0';\\n\\t\\t\\t\\tint c = 0;\\n\\t\\t\\t\\tfor (int i = 0; i < x.length(); i++) {\\n\\t\\t\\t\\t\\tif (x.charAt(i) > x.charAt(0)) {\\n\\t\\t\\t\\t\\t\\tc = 1;\\n\\t\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\tif (x.charAt(i) < x.charAt(0)) {\\n\\t\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tif (c == 1) {\\n\\t\\t\\t\\t\\tfor (int i = 0; i < x.length(); i++) {\\n\\t\\t\\t\\t\\t\\tpw.print(y + 1);\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\tfor (int i = 0; i < x.length(); i++) {\\n\\t\\t\\t\\t\\t\\tpw.print(y);\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tpw.println();\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tpw.println(ts.ceiling(n));\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\tpw.close();\\n\\t}\\n\\n\\tstatic boolean chk(int x) {\\n\\t\\tString s = x + \\\"\\\";\\n\\t\\tHashSet hs = new HashSet<>();\\n\\t\\tfor (int i = 0; i < s.length(); i++) {\\n\\t\\t\\ths.add(s.charAt(i) - '0');\\n\\t\\t}\\n\\t\\treturn hs.size() <= 2;\\n\\t}\\n\\n\\tstatic ArrayList arrl;\\n\\n\\tstatic void gen(HashSet hs, String cur) {\\n\\t\\tarrl.add(cur);\\n\\t\\tif (cur.length() == 9) {\\n\\t\\t\\treturn;\\n\\t\\t}\\n\\t\\tfor (int j = 0; j < 10; j++) {\\n\\t\\t\\tString x = cur;\\n\\t\\t\\tHashSet h = (HashSet) hs.clone();\\n\\t\\t\\tif (h.contains(j)) {\\n\\t\\t\\t\\tgen(h, x + j);\\n\\t\\t\\t} else {\\n\\t\\t\\t\\th.add(j);\\n\\t\\t\\t\\tif (h.size() <= 2)\\n\\t\\t\\t\\t\\tgen(h, x + j);\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n\\tpublic static class tuble implements Comparable {\\n\\t\\tint x;\\n\\t\\tint y;\\n\\t\\tint z;\\n\\n\\t\\tpublic tuble(int x, int y, int z) {\\n\\t\\t\\tthis.x = x;\\n\\t\\t\\tthis.y = y;\\n\\t\\t\\tthis.z = z;\\n\\t\\t}\\n\\n\\t\\tpublic String toString() {\\n\\t\\t\\treturn x + \\\" \\\" + y + \\\" \\\" + z;\\n\\t\\t}\\n\\n\\t\\tpublic int compareTo(tuble other) {\\n\\t\\t\\tif (this.x == other.x) {\\n\\t\\t\\t\\tif (this.y ==...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"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 java can you solve the prior task?\",\"targets\":\"\\/*\\n \\\"Everything in the universe is balanced. Every disappointment\\n you face in life will be balanced by something good for you!\\n Keep going, never give up.\\\"\\n*\\/\\n\\nimport java.util.*;\\nimport java.lang.*;\\nimport java.io.*;\\n\\npublic class Codechef {\\n static Map> graph = new HashMap<>();\\n static int minLeaves;\\n public static void main(String[] args) throws java.lang.Exception {\\n out = new PrintWriter(new BufferedOutputStream(System.out));\\n sc = new FastReader();\\n\\n int test = sc.nextInt();\\n for (int t = 0; t < test; t++) {\\n solve();\\n }\\n out.close();\\n }\\n\\n private static void solve() {\\n graph.clear();\\n int n = sc.nextInt();\\n for (int i = 1; i <= n; i++) {\\n graph.put(i, new ArrayList<>());\\n }\\n for (int i = 1; i < n; i++) {\\n int u = sc.nextInt();\\n int v = sc.nextInt();\\n graph.get(u).add(v);\\n graph.get(v).add(u);\\n }\\n minLeaves = 1;\\n dfs(1, 0);\\n out.println(minLeaves);\\n }\\n\\n private static int dfs(int currNode, int parent) {\\n int count = 0;\\n for (int adjacent : graph.get(currNode)) {\\n if (adjacent != parent) {\\n count += dfs(adjacent, currNode);\\n }\\n }\\n minLeaves += Math.max(0, count - 1);\\n return count == 0 ? 1 : 0;\\n }\\n\\n public static FastReader sc;\\n public static PrintWriter out;\\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 ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"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 PYTHON3.\",\"targets\":\"import os,sys;from io import BytesIO, IOBase\\nBUFSIZE = 8192\\nclass FastIO(IOBase):\\n newlines = 0\\n def __init__(self, file):\\n self._fd = file.fileno();self.buffer = BytesIO();self.writable = \\\"x\\\" in file.mode or \\\"r\\\" not in file.mode;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:break\\n ptr = self.buffer.tell();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:b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE));self.newlines = b.count(b\\\"\\\\n\\\") + (not b);ptr = self.buffer.tell();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:os.write(self._fd, self.buffer.getvalue());self.buffer.truncate(0), self.buffer.seek(0)\\nclass IOWrapper(IOBase):\\n def __init__(self, file):\\n self.buffer = FastIO(file);self.flush = self.buffer.flush;self.writable = self.buffer.writable;self.write = lambda s: self.buffer.write(s.encode(\\\"ascii\\\"));self.read = lambda: self.buffer.read().decode(\\\"ascii\\\");self.readline = lambda: self.buffer.readline().decode(\\\"ascii\\\")\\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\\ntry:sys.stdin,sys.stdout=open('in.txt','r'),open('out.txt','w')\\nexcept:pass\\nii1=lambda:int(sys.stdin.readline().strip()) # for interger\\nis1=lambda:sys.stdin.readline().strip() # for str\\niia=lambda:list(map(int,sys.stdin.readline().strip().split())) # for List[int]\\nisa=lambda:sys.stdin.readline().strip().split() # for List[str]\\nmod=int(1e9 + 7);\\nfrom math import inf \\nfrom collections import defaultdict as dd\\n# from math import *\\n# from collections import *;\\n# from collections import deque as dq \\n# from string import ascii_lowercase,ascii_uppercase\\n# from functools import...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"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\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"\\/\\/package comp_738; \\n\\nimport java.util.*;\\npublic class MochaAndDianaEasy {\\n\\n\\tpublic static void main(String[] args) {\\n\\t\\tScanner s = new Scanner(System.in);\\n\\t\\tint N=s.nextInt(), m1=s.nextInt(), m2=s.nextInt();\\n\\t\\t\\n\\/\\/\\t\\tboolean[][] mochaForest = new boolean[N+1][N+1];\\n\\/\\/\\t\\tboolean[][] danialForest = new boolean[N+1][N+1];\\n\\t\\tint[] mochaParent = new int[N+1];\\n\\t\\tint[] danialParent = new int[N+1];\\n\\t\\t\\n\\/\\/\\t\\tArrays.fill(mochaParent, -1);\\n\\/\\/\\t\\tArrays.fill(danialParent, -1);\\n\\t\\t\\n\\t\\tfor(int i=0; i result = new ArrayList<>(); \\n\\t\\t\\n\\t\\tfor(int i=1; i{\\n\\t\\tint a, b, i;\\n\\t\\tpublic Pair(int x, int y, int z) {\\n\\t\\t\\ta=x;\\n\\t\\t\\tb=y;\\n\\t\\t\\ti=z;\\n\\t\\t}\\n\\t\\tpublic int compareTo(Pair o) {\\n\\t\\t\\tif (i == o.i) return 0;\\n\\t\\t\\treturn a-o.a; \\n\\t\\t}\\n\\t\\t\\n\\t}\\n\\t\\n\\tstatic int[] ans;\\n\\t\\n\\tstatic void solve(int[]a , int[] b) {\\n\\t\\tint n=a.length;\\n\\t\\tPair[] p = new Pair[n];\\n\\t\\tfor (int i = 0; i < n; i++) p[i] = new Pair(a[i], b[i], i);\\n\\t\\tArrays.sort(p);\\n\\t\\tlong[] sufmax = new long[n];\\n\\t\\tArrays.fill(sufmax, Long.MIN_VALUE\\/30);\\n\\t\\tfor (int i = n-1; i >= 0; i--) {\\n\\t\\t\\tif (i==n-1) sufmax[i] = p[i].b;\\n\\t\\t\\telse sufmax[i] = max(sufmax[i+1], p[i].b);\\n\\t\\t}\\n\\t\\t\\/\\/for (int i = 0; i < n; i++) out.println(p[i].a + \\\" \\\" + p[i].b);\\n\\t\\t\\n\\t\\tlong max = 0;\\n\\t\\tfor (int i = 0; i < n; i++) {\\n\\t\\t\\tmax = max(p[i].b, max);\\n\\t\\t\\tif (i == n-1) ans[p[i].i] = 1;\\n\\t\\t\\telse {\\n\\t\\t\\t\\tSystem.out.println(max + \\\" \\\" + sufmax[i+1]);\\n\\t\\t\\t\\tif (max > sufmax[i+1]) ans[p[i].i] = 1;\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\t\\n\\tstatic TreeSet ts;\\n\\tstatic TreeSet ts2;\\n\\t\\n\\tstatic void solve2(int maxa, int maxb) {\\n\\t\\t\\/\\/ ts = (a,b), ts2 = (b,a)\\n\\t\\tint na = maxa;\\n\\t\\tint nb = maxb;\\n\\t\\tTreeSet remove = new TreeSet();\\n\\t\\twhile (ts.size() > 0 && ts.last().a >= maxa) {\\n\\t\\t\\tnb = min(nb,ts.last().b);\\n\\t\\t\\tans[ts.last().i]=1;\\n\\t\\t\\tremove.add(ts.pollLast());\\n\\t\\t}\\n\\t\\twhile (ts2.size() > 0 && ts2.last().a >= maxb) \\n\\t\\t{\\n\\t\\t\\tna = min(na,ts2.last().b);\\n\\t\\t\\tans[ts2.last().i]=1;\\n\\t\\t\\tremove.add(ts2.pollLast());\\n\\t\\t}\\n\\t\\tif (na == maxa && nb == maxb) return;\\n\\t\\tsolve2(na,nb);\\n\\t\\t\\n\\t}\\n\\t\\n\\tpublic static void main(String[] args) throws IOException{\\n\\t\\t\\/\\/ br = new BufferedReader(new FileReader(\\\".in\\\"));\\n\\t\\t\\/\\/ out = new PrintWriter(new FileWriter(\\\".out\\\"));\\n\\t\\t\\/\\/ new Thread(null, new (), \\\"fisa balls\\\", 1<<28).start();\\n\\t\\t\\n\\t\\tint t =readInt();\\n\\t\\twhile(t-->0) {\\n\\t\\t\\tint n =readInt();\\n\\t\\t\\tint[] a = new int[n];\\n\\t\\t\\tint[] b = new int[n];\\n\\t\\t\\tans = new int[n];\\n\\t\\t\\tfor (int i = 0; i < n; i++) a[i]=readInt();\\n\\t\\t\\tfor (int i = 0; i < n; i++) b[i]=readInt();\\n\\t\\t\\tint maxa = 0;\\n\\t\\t\\tint maxb = 0;\\n\\t\\t\\tfor (int i = 0; i < n;...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"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;\\nvoid solve() {\\n long long n;\\n cin >> n;\\n string s;\\n cin >> s;\\n for (long long i = n \\/ 2; i < n; i++) {\\n if (s[i] == '0') {\\n cout << 1 << ' ' << (i + 1) << ' ' << 1 << ' ' << i << '\\\\n';\\n return;\\n }\\n }\\n if (s[n \\/ 2 - 1] == '0') {\\n cout << n \\/ 2 << ' ' << n << ' ' << n \\/ 2 + 1 << ' ' << n << ' ' << '\\\\n';\\n } else {\\n cout << n \\/ 2 << ' ' << n - 1 << ' ' << n \\/ 2 + 1 << ' ' << n << '\\\\n';\\n }\\n}\\nint32_t main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n long long t;\\n cin >> t;\\n while (t--) solve();\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 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\":\"for _ in range(int(input())):\\n k = int(input())\\n n = 1\\n cnt = 0\\n while (k - n > 0):\\n k -= n\\n n += 2\\n cnt += 1\\n if k == cnt + 1:\\n print(cnt + 1, cnt + 1)\\n elif k > cnt + 1:\\n\\n print(cnt + 1, cnt - (k - cnt - 2))\\n else:\\n print(k, cnt + 1)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"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...\\n#incl\",\"targets\":\"ude \\n#pragma GCC optimize(\\\"Ofast\\\")\\n#pragma GCC optimize(\\\"unroll-loops\\\")\\n#pragma GCC target( \\\\\\n \\\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native\\\")\\nusing namespace std;\\nconst long long N = 2e6 + 5;\\nconst long long M = 70;\\nconst long long SZ = 450;\\nconst long long mod = 1e9 + 7;\\nconst long long inf = 0x3f3f3f3f3f3f3f3f;\\nlong long read() {\\n long long x = 0, f = 1;\\n char ch = getchar();\\n while (ch > '9' || ch < '0') {\\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}\\nvoid write(long long x) {\\n if (x < 0) {\\n putchar('-');\\n x = -x;\\n }\\n if (x >= 10) write(x \\/ 10);\\n putchar(x % 10 + '0');\\n}\\nlong long ksm(long long x, long long y = mod - 2, long long z = mod) {\\n long long ret = 1;\\n while (y) {\\n if (y & 1) ret = (ret * x) % z;\\n x = (x * x) % z;\\n y >>= 1;\\n }\\n return ret;\\n}\\nlong long inv[N], fac[N], ifc[N];\\nvoid Init(long long n) {\\n inv[1] = 1;\\n for (long long i = 2; i <= n; i++)\\n inv[i] = inv[mod % i] * (mod - mod \\/ i) % mod;\\n fac[0] = 1;\\n for (long long i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % mod;\\n ifc[0] = 1;\\n for (long long i = 1; i <= n; i++) ifc[i] = ifc[i - 1] * inv[i] % mod;\\n}\\nlong long C(long long n, long long m) {\\n if (m < 0 || m > n) return 0;\\n return fac[n] * ifc[m] % mod * ifc[n - m] % mod;\\n}\\nvoid add(long long &x, long long y) {\\n x += y;\\n if (x >= mod) x -= mod;\\n}\\nlong long n;\\nvector T[N];\\nlong long Fa[N], hs[N];\\nvoid dfs(long long u, long long fa) {\\n hs[u] = 0;\\n Fa[u] = fa;\\n for (long long v : T[u]) {\\n if (v == fa) continue;\\n dfs(v, u);\\n hs[u] += !hs[v];\\n }\\n}\\nlong long solve() {\\n long long ans = hs[1], f = hs[1];\\n for (long long i = 2; i <= n; i++)\\n if (hs[i]) {\\n if (f)\\n ans += hs[i] - 1;\\n else\\n f = 1, ans += hs[i];\\n }\\n return ans;\\n}\\nsigned main() {\\n long long JYZ;\\n JYZ = read();\\n while (JYZ--) {\\n n = read();\\n for (long long i = 1; i <= n; i++) T[i].clear();\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Alice has recently received an array a_1, a_2, ..., a_n for her birthday! She is very proud of her array, and when she showed her friend Bob the array, he was very happy with her present too!\\n\\nHowever, soon Bob became curious, and as any sane friend would do, asked Alice to perform q operations of two types on her array:\\n\\n * 1 x y: update the element a_x to y (set a_x = y). \\n * 2 l r: calculate how many non-decreasing subarrays exist within the subarray [a_l, a_{l+1}, ..., a_r]. More formally, count the number of pairs of integers (p,q) such that l ≤ p ≤ q ≤ r and a_p ≤ a_{p+1} ≤ ... ≤ a_{q-1} ≤ a_q. \\n\\n\\n\\nHelp Alice answer Bob's queries!\\n\\nInput\\n\\nThe first line contains two integers n and q (1 ≤ n, q ≤ 2 ⋅ 10^5) — the size of the array, and the number of queries, respectively.\\n\\nThe second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — the elements of Alice's array.\\n\\nThe next q lines consist of three integers each. The first integer of the i-th line is t_i, the operation being performed on the i-th step (t_i = 1 or t_i = 2).\\n\\nIf t_i = 1, the next two integers are x_i and y_i (1 ≤ x_i ≤ n; 1 ≤ y_i ≤ 10^9), updating the element at position x_i to y_i (setting a_{x_i} = y_i).\\n\\nIf t_i = 2, the next two integers are l_i and r_i (1 ≤ l_i ≤ r_i ≤ n), the two indices Bob asks Alice about for the i-th query.\\n\\nIt's guaranteed that there is at least one operation of the second type.\\n\\nOutput\\n\\nFor each query of type 2, print a single integer, the answer to the query.\\n\\nExample\\n\\nInput\\n\\n\\n5 6\\n3 1 4 1 5\\n2 2 5\\n2 1 3\\n1 4 4\\n2 2 5\\n1 2 6\\n2 2 5\\n\\n\\nOutput\\n\\n\\n6\\n4\\n10\\n7\\n\\nNote\\n\\nFor the first query, l = 2 and r = 5, and the non-decreasing subarrays [p,q] are [2,2], [3,3], [4,4], [5,5], [2,3] and [4,5].\",\"targets\":\"#include \\n#pragma GCC optimize(\\\"Ofast\\\")\\n#pragma GCC target(\\\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx\\\")\\nusing namespace std;\\nstruct node {\\n long long pref = 0;\\n long long suf = 0;\\n long long dp = 0;\\n node() {}\\n};\\nlong long sz = 1 << 20;\\nvector tree(2 * sz - 1, node());\\nvector a(sz);\\nvoid change(long long id, long long l, long long r, long long i, long long x) {\\n if (r - l == 1) {\\n a[i] = x;\\n tree[id].pref = 1;\\n tree[id].suf = 1;\\n tree[id].dp = 1;\\n return;\\n }\\n long long mid = (l + r) \\/ 2;\\n if (i < mid)\\n change(id * 2 + 1, l, mid, i, x);\\n else\\n change(id * 2 + 2, mid, r, i, x);\\n long long suf = tree[id * 2 + 1].suf;\\n long long pref = tree[id * 2 + 2].pref;\\n if (a[mid - 1] <= a[mid])\\n tree[id].dp = tree[id * 2 + 1].dp - suf * (suf + 1) \\/ 2 +\\n tree[id * 2 + 2].dp - pref * (pref + 1) \\/ 2 +\\n (suf + pref) * (suf + pref + 1) \\/ 2;\\n else {\\n tree[id].dp = tree[id * 2 + 1].dp + tree[id * 2 + 2].dp;\\n }\\n if (tree[id * 2 + 1].pref == mid - l and a[mid - 1] <= a[mid])\\n tree[id].pref = mid - l + pref;\\n else\\n tree[id].pref = tree[id * 2 + 1].pref;\\n if (tree[id * 2 + 2].suf == r - mid and a[mid] >= a[mid - 1])\\n tree[id].suf = r - mid + suf;\\n else\\n tree[id].suf = tree[id * 2 + 2].suf;\\n}\\nnode getsum(long long id, long long l, long long r, long long lq,\\n long long rq) {\\n if (l >= rq or r <= lq) return node();\\n if (lq <= l and r <= rq) return tree[id];\\n long long mid = (l + r) \\/ 2;\\n node x = getsum(id * 2 + 1, l, mid, lq, rq);\\n node y = getsum(id * 2 + 2, mid, r, lq, rq);\\n if (x.dp == 0) return y;\\n if (y.dp == 0) return x;\\n node c = node();\\n long long suf = x.suf;\\n long long pref = y.pref;\\n if (a[mid - 1] <= a[mid]) {\\n c.dp = x.dp - suf * (suf + 1) \\/ 2 + y.dp - pref * (pref + 1) \\/ 2 +\\n (suf + pref) * (suf + pref + 1) \\/ 2;\\n } else {\\n c.dp = x.dp + y.dp;\\n }\\n if (x.pref == mid - max(lq, l) and a[mid - 1] <= a[mid])\\n c.pref = mid - max(lq, l) + pref;\\n else\\n c.pref =...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"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\\\":\",\"targets\":\"#include \\nusing std::vector;\\nint ans[500005];\\nint p[300005];\\nstruct Edge {\\n int u, v, w;\\n int id;\\n Edge() {}\\n Edge(int u, int v, int w) : u(u), v(v), w(w) {}\\n};\\nEdge e[500005];\\nvector node[300005];\\nvector edge[500005];\\nvector tEdge[500005];\\nint main() {\\n int st = 18;\\n int n, q;\\n scanf(\\\"%d%d\\\", &n, &q);\\n std::function find = [&](int u) {\\n return p[u] == u ? u : (p[u] = find(p[u]));\\n };\\n for (int i = 1; i <= n; i++) {\\n p[i] = i;\\n }\\n for (int i = 1; i <= q; i++) {\\n int u, v, w;\\n scanf(\\\"%d%d%d\\\", &u, &v, &w);\\n int x = find(u), y = find(v);\\n if (x != y) {\\n p[y] = x;\\n ans[i] = 1;\\n }\\n Edge now;\\n now.u = u, now.v = v, now.w = w, now.id = i;\\n e[i] = now;\\n }\\n for (int i = 1; i <= q; i++) {\\n if (ans[i]) {\\n int p = find(e[i].u);\\n tEdge[p].push_back(e[i]);\\n } else {\\n int p = find(e[i].u);\\n edge[p].push_back(e[i]);\\n }\\n }\\n for (int i = 1; i <= n; i++) {\\n int u = find(i);\\n node[u].push_back(i);\\n }\\n auto getPos = [&](int c, vector& a) {\\n int L = 0, R = a.size() - 1;\\n int res = -1;\\n while (L <= R) {\\n int M = (L + R) \\/ 2;\\n if (c <= a[M]) {\\n res = M;\\n R = M - 1;\\n } else\\n L = M + 1;\\n }\\n return res + 1;\\n };\\n auto solve = [&](int c) {\\n vector& a = node[c];\\n int size = a.size();\\n std::sort(a.begin(), a.end());\\n for (Edge& e : edge[c]) {\\n e.u = getPos(e.u, node[c]);\\n e.v = getPos(e.v, node[c]);\\n }\\n vector> g(size + 1);\\n for (Edge& e : tEdge[c]) {\\n e.u = getPos(e.u, node[c]);\\n e.v = getPos(e.v, node[c]);\\n g[e.u].push_back(Edge(e.u, e.v, e.w));\\n g[e.v].push_back(Edge(e.v, e.u, e.w));\\n }\\n vector vis(size + 1, 0);\\n vector in(size + 1, 0), out(size + 1, 0);\\n vector xSum(size + 1, 0);\\n vector> fa(size + 1, vector(st + 1, 0));\\n int tot = 0;\\n std::function dfs = [&](int u) {\\n in[u] = ++tot;\\n for (Edge edge : g[u])...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"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...\",\"targets\":\"#!\\/usr\\/bin\\/env python3\\n# from typing import *\\n\\nimport sys\\nimport io\\nimport math\\nimport collections\\nimport decimal\\nimport itertools\\nimport bisect\\nimport heapq\\n\\n\\ndef input():\\n return sys.stdin.readline()[:-1]\\n\\n\\n# sys.setrecursionlimit(1000000)\\n\\n# _INPUT = \\\"\\\"\\\"1\\n# 2 9\\n# 1 3 3 3 3 3 1 1 3 1 3 1 1 3 3 1 1 3\\n# \\\"\\\"\\\"\\n# sys.stdin = io.StringIO(_INPUT)\\n\\nINF = 10**10\\n\\n\\nclass BIT:\\n def __init__(self, n):\\n self.size = n\\n self.data = [0] * (n+1)\\n # self.depth = n.bit_length()\\n def add(self, i, x):\\n while i <= self.size:\\n self.data[i] += x\\n i += i & -i\\n def get_sum(self, i):\\n s = 0\\n while i > 0:\\n s += self.data[i]\\n i -= i & -i\\n return s\\n def get_rsum(self, l, r):\\n \\\"\\\"\\\"\\n [l, r] の sum\\n \\\"\\\"\\\"\\n return self.get_sum(r) - self.get_sum(l-1)\\n\\n\\ndef solve(N, M, A):\\n\\n L = []\\n for i in range(N*M):\\n L.append((A[i], i))\\n L.sort(key=lambda x: (x[0], -x[1]))\\n\\n Person = collections.defaultdict(list)\\n A1 = sorted(A)\\n SeatAssign = collections.defaultdict(list)\\n for i in range(N*M):\\n Person[A[i]].append(i)\\n SeatAssign[A1[i]].append(i)\\n\\n for l in SeatAssign.values():\\n l.sort(key=lambda i: (i\\/\\/M, -(i%M)), reverse=True)\\n\\n Seat = [-1] * (N*M)\\n k = 0\\n for k in range(N*M):\\n a, i = L[k]\\n Seat[i] = k\\n\\n for a in Person:\\n for i in Person[a]:\\n s = SeatAssign[a].pop()\\n Seat[i] = s\\n \\n bit = [BIT(N*M+1) for _ in range(N)]\\n score = 0\\n for i in range(N*M):\\n s = Seat[i]+1\\n score += bit[Seat[i]\\/\\/M].get_sum(s)\\n bit[Seat[i]\\/\\/M].add(s, 1)\\n \\n # I = [[0] * M for _ in range(N)]\\n # for i in range(N*M):\\n # s = Seat[i]\\n # I[s\\/\\/M][s%M] = i\\n # for i in range(N):\\n # print(*I[i])\\n return score\\n\\n\\nT0 = int(input())\\nfor _ in range(T0):\\n N, M = map(int, input().split())\\n A = list(map(int, input().split()))\\n print(solve(N, M, A))\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nPolycarp 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.*;\\nimport java.lang.*;\\nimport java.io.*;\\npublic class cf1 {\\n public static void main(String[] args) throws java.lang.Exception {\\n Scanner sc = new Scanner(System.in);\\n int t = sc.nextInt();\\n while (t-- > 0) {\\n ArrayList l= new ArrayList<>();\\n for(int i=0;i<7;i++)\\n l.add(sc.nextInt());\\n \\/\\/System.out.print(l);\\n int third=0;\\n for(int i=2;i<7;i++)\\n {\\n int sum=l.get(0)+l.get(i);\\n int sum1=l.get(1)+l.get(i);\\n int total=l.get(0)+l.get(1)+l.get(i);\\n if(l.contains(sum) && l.contains(sum1) && l.get(6)==(total))\\n {third=i; break;}\\n }\\n System.out.print(l.get(0)+\\\" \\\"+l.get(1)+\\\" \\\"+l.get(third));\\n System.out.println();\\n }\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"Janusz is a businessman. He owns a company \\\"Januszex\\\", which produces games for teenagers. Last hit of Januszex was a cool one-person game \\\"Make it one\\\". The player is given a sequence of n integers a_i.\\n\\nIt is allowed to select any subset of them, and the score is equal to the greatest common divisor of selected elements. The goal is to take as little elements as it is possible, getting the score 1. Now Janusz wonders, for given sequence, how much elements should the player choose?\\n\\nInput\\n\\nThe first line contains an only integer n (1 ≤ n ≤ 300 000) — the number of integers in the sequence.\\n\\nThe second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 300 000).\\n\\nOutput\\n\\nIf there is no subset of the given sequence with gcd equal to 1, output -1.\\n\\nOtherwise, output exactly one integer — the size of the smallest subset with gcd equal to 1.\\n\\nExamples\\n\\nInput\\n\\n3\\n10 6 15\\n\\n\\nOutput\\n\\n3\\n\\n\\nInput\\n\\n3\\n2 4 6\\n\\n\\nOutput\\n\\n-1\\n\\n\\nInput\\n\\n7\\n30 60 21 42 70 15 30\\n\\n\\nOutput\\n\\n3\\n\\nNote\\n\\nIn the first example, selecting a subset of all numbers gives a gcd of 1 and for all smaller subsets the gcd is greater than 1.\\n\\nIn the second example, for all subsets of numbers the gcd is at least 2. \\\":\",\"targets\":\"#include \\nusing namespace std;\\nlong long MOD = 1e9 + 7;\\nlong long dp[8][300001];\\nlong long f[300001];\\nlong long invf[300001];\\nbool has[300001];\\nlong long choose(long long a, long long b) {\\n if (a < b) return 0;\\n if (a == b) return 1;\\n return f[a] * invf[a - b] % MOD * invf[b] % MOD;\\n}\\nlong long mpow(long long a, long long b) {\\n if (b == 0) return 1;\\n if (b == 1) return a % MOD;\\n long long half = mpow(a, b \\/ 2);\\n if (b & 1) return half * half % MOD * a % MOD;\\n return half * half % MOD;\\n}\\nlong long inv(long long x) { return mpow(x, MOD - 2); }\\nint n;\\nvector PRIMES = {\\n 1000000007, 1000000009, 1000000021, 1000000033, 1000000087, 1000000093,\\n 1000000097, 1000000103, 1000000123, 1000000181, 1000000207, 1000000223,\\n 1000000241, 1000000271, 1000000289, 1000000297, 1000000321, 1000000349,\\n 1000000363, 1000000403, 1000000409, 1000000411, 1000000427, 1000000433,\\n 1000000439, 1000000447, 1000000453, 1000000459, 1000000483};\\nint mult[300001];\\nint main() {\\n cout << setprecision(10);\\n ios::sync_with_stdio(0);\\n cin.tie(0);\\n shuffle(PRIMES.begin(), PRIMES.end(), default_random_engine((int)time(0)));\\n MOD = PRIMES[0];\\n f[1] = 1;\\n for (int i = 2; i <= 300000; i++) f[i] = f[i - 1] * i % MOD;\\n for (int i = 1; i <= 300000; i++) invf[i] = inv(f[i]);\\n cin >> n;\\n for (int i = 1; i <= n; i++) {\\n int x;\\n cin >> x;\\n has[x] = 1;\\n }\\n for (int i = 1; i <= 300000; i++)\\n for (int j = i; j <= 300000; j += i) mult[i] += has[j];\\n int ret = 8;\\n for (int i = 1; i <= 7; i++)\\n for (int j = 300000; j >= 1; j--) {\\n dp[i][j] += choose(mult[j], i);\\n if (dp[i][j] == 0) continue;\\n for (int k = j + j; k <= 300000; k += j)\\n dp[i][j] = (dp[i][j] - dp[i][k] + MOD) % MOD;\\n if (dp[i][j] > 0 && j == 1) ret = min(ret, i);\\n }\\n if (ret == 8)\\n cout << -1 << '\\\\n';\\n else\\n cout << ret << '\\\\n';\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A new delivery of clothing has arrived today to the clothing store. This delivery consists of a ties, b scarves, c vests and d jackets.\\n\\nThe store does not sell single clothing items — instead, it sells suits of two types:\\n\\n * a suit of the first type consists of one tie and one jacket; \\n * a suit of the second type consists of one scarf, one vest and one jacket. \\n\\n\\n\\nEach suit of the first type costs e coins, and each suit of the second type costs f coins.\\n\\nCalculate the maximum possible cost of a set of suits that can be composed from the delivered clothing items. Note that one item cannot be used in more than one suit (though some items may be left unused).\\n\\nInput\\n\\nThe first line contains one integer a (1 ≤ a ≤ 100 000) — the number of ties.\\n\\nThe second line contains one integer b (1 ≤ b ≤ 100 000) — the number of scarves.\\n\\nThe third line contains one integer c (1 ≤ c ≤ 100 000) — the number of vests.\\n\\nThe fourth line contains one integer d (1 ≤ d ≤ 100 000) — the number of jackets.\\n\\nThe fifth line contains one integer e (1 ≤ e ≤ 1 000) — the cost of one suit of the first type.\\n\\nThe sixth line contains one integer f (1 ≤ f ≤ 1 000) — the cost of one suit of the second type.\\n\\nOutput\\n\\nPrint one integer — the maximum total cost of some set of suits that can be composed from the delivered items. \\n\\nExamples\\n\\nInput\\n\\n\\n4\\n5\\n6\\n3\\n1\\n2\\n\\n\\nOutput\\n\\n\\n6\\n\\n\\nInput\\n\\n\\n12\\n11\\n13\\n20\\n4\\n6\\n\\n\\nOutput\\n\\n\\n102\\n\\n\\nInput\\n\\n\\n17\\n14\\n5\\n21\\n15\\n17\\n\\n\\nOutput\\n\\n\\n325\\n\\nNote\\n\\nIt is possible to compose three suits of the second type in the first example, and their total cost will be 6. Since all jackets will be used, it's impossible to add anything to this set.\\n\\nThe best course of action in the second example is to compose nine suits of the first type and eleven suits of the second type. The total cost is 9 ⋅ 4 + 11 ⋅ 6 = 102.\\na = i\",\"targets\":\"nt(input())\\nb = int(input())\\nc = int(input())\\nd = int(input())\\ne = int(input())\\nf = int(input())\\n\\n\\nfirst = min(a, d) # 12\\nsecond = min(b, c, d) # 11\\n\\nmax_val = second * f\\nmax_val += max(0, min(a, d - second))*e\\n\\nmax2val = first * e\\nmax2val += max(0, min(b, c , d-first))*f\\n\\nprint(max(max2val, max_val))\",\"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...\\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) {\\n long long res = 1;\\n x = x % 1000000007;\\n while (y > 0) {\\n if (y & 1) res = (res * x) % 1000000007;\\n y = y >> 1;\\n x = (x * x) % 1000000007;\\n }\\n return res % 1000000007;\\n}\\nlong long inv(long long n) { return power(n, 1000000007 - 2) % 1000000007; }\\nlong long isprime(long long n) {\\n if (n < 2) return 0;\\n long long i;\\n for (i = 2; i * i <= n; i++)\\n if (n % i == 0) return 0;\\n return 1;\\n}\\nvoid solve() {\\n long long ans = 1e18;\\n string s;\\n long long n;\\n cin >> n >> s;\\n for (char ch = 'a'; ch <= 'z'; ch++) {\\n long long i = 0, j = n - 1;\\n long long moves = 0;\\n long long ok = 1;\\n while (i < j) {\\n if (s[i] == s[j]) {\\n i++, j--;\\n } else if (s[i] == ch) {\\n i++;\\n moves++;\\n } else if (s[j] == ch) {\\n j--;\\n moves++;\\n } else {\\n ok = 0;\\n break;\\n }\\n }\\n if (ok) {\\n ans = min(ans, moves);\\n }\\n }\\n if (ans > n) ans = -1;\\n cout << ans << \\\"\\\\n\\\";\\n}\\nint32_t main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n long long t = 1;\\n long long tc = 0;\\n cin >> t;\\n while (t--) {\\n tc++;\\n solve();\\n }\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"It is a complicated version of problem F1. 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 ≤ 10).\\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\\n6\\n2021 3\\n177890 2\\n34512 3\\n724533 4\\n998244353 1\\n12345678 10\\n\\n\\nOutput\\n\\n\\n2021\\n181111\\n34533\\n724542\\n999999999\\n12345678\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst int N = 100005;\\nint t, n, k, st[30], vis[32];\\nint main() {\\n scanf(\\\"%lld\\\", &t);\\n while (t--) {\\n scanf(\\\"%d%d\\\", &n, &k);\\n st[0] = 0;\\n while (n) st[++st[0]] = n % 10, n \\/= 10;\\n memset(vis, 0, sizeof(vis));\\n while (1) {\\n int status = 0, num = 0;\\n for (register int i = 1; i <= st[0]; ++i)\\n if (st[i] >= 10) st[i] = 0, st[i + 1]++;\\n for (register int i = st[0]; i >= 1; --i) {\\n num += !(status >> st[i] & 1);\\n status |= 1 << st[i];\\n if (num > k) {\\n ++st[i];\\n for (register int j = 1; j <= i - 1; ++j) st[j] = 0;\\n break;\\n }\\n }\\n if (num <= k) {\\n for (register int i = st[0]; i >= 1; --i) printf(\\\"%d\\\", st[i]);\\n puts(\\\"\\\");\\n break;\\n }\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 solution for \\\"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\":\"I=input\\nexec(int(I())*\\\"I();print('YNEOS'[int(I(),2)&int(I(),2)>0::2]);\\\")\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"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.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 long pre[]=new long[n];\\n long sum=0;\\n for(int i=0;i=R[y])\\n {\\n a[i]=L[x];\\n x++;\\n }\\n else\\n {\\n a[i]=R[y];\\n y++;\\n }\\n }\\n }\\n static class FastReader\\n {\\n BufferedReader br;\\n StringTokenizer st;\\n public FastReader()\\n ...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"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 cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\ntemplate \\nT gcd(T a, T b) {\\n return b == 0 ? a : gcd(b, a % b);\\n}\\nconst int INF = 0x3f3f3f3f;\\nvoid solve() {\\n int n, i = 1, p = 1;\\n cin >> n;\\n while (1) {\\n if ((n - i) <= 0) {\\n if (n <= p) {\\n cout << n << \\\" \\\" << p << '\\\\n';\\n return;\\n } else {\\n cout << p << \\\" \\\" << 2 * p - n << '\\\\n';\\n return;\\n }\\n }\\n n = n - i;\\n i = i + 2;\\n p++;\\n }\\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\":\"valid\",\"template\":\"priortask\",\"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.\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nvoid seive(long long);\\nbool cmp(long long, long long);\\nvector prime(200002, true);\\nvoid solve() {\\n long long n, i, j, k;\\n cin >> n;\\n long long arr[n];\\n for (i = 0; i < n; i++) {\\n cin >> arr[i];\\n }\\n if (n == 2) {\\n cout << arr[0] * arr[1] << endl;\\n return;\\n }\\n long long maximum = INT_MIN, prod = 1, second = 0;\\n for (i = 0; i < n; i++) {\\n if (i == 0) {\\n prod = max(prod, arr[i] * arr[i + 1]);\\n } else if (i == n - 1) {\\n prod = max(prod, arr[i] * arr[i - 1]);\\n } else {\\n prod = max(prod, max(arr[i - 1] * arr[i], arr[i + 1] * arr[i]));\\n }\\n }\\n cout << prod << endl;\\n}\\nint32_t main() {\\n ios::sync_with_stdio(false);\\n cin.tie(0);\\n cout.tie(0);\\n long long t = 1;\\n cin >> t;\\n while (t--) {\\n solve();\\n }\\n return 0;\\n}\\nvoid seive(long long mx) {\\n prime[0] = prime[1] = false;\\n for (long long i = 2; i * i <= mx; i++) {\\n if (prime[i]) {\\n for (long long j = i * i; j <= mx; j += i) {\\n prime[j] = false;\\n }\\n }\\n }\\n}\\nbool cmp(long long x, long long y) {\\n if (x > y)\\n return true;\\n else\\n return false;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"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.\",\"targets\":\"T=int(input())\\nfor t in range(T):\\n n=int(input())\\n x=n\\/\\/3\\n c1=x\\n c2=x\\n if n%3==1:\\n c1+=1\\n elif n%3==2:\\n c2+=1\\n print(c1,c2)\",\"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.\\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;\\nint32_t main() {\\n long long int t;\\n cin >> t;\\n while (t--) {\\n string s;\\n cin >> s;\\n long long int count = 0;\\n long long int max_ans = 2;\\n if (s[0] == '0') count++;\\n for (long long int i = 1; i < s.length(); i++)\\n if (s[i] == '0' && s[i - 1] == '1') count++;\\n cout << min(max_ans, count) << endl;\\n }\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A sequence a = [a_1, a_2, …, a_l] of length l has an ascent if there exists a pair of indices (i, j) such that 1 ≤ i < j ≤ l and a_i < a_j. For example, the sequence [0, 2, 0, 2, 0] has an ascent because of the pair (1, 4), but the sequence [4, 3, 3, 3, 1] doesn't have an ascent.\\n\\nLet's call a concatenation of sequences p and q the sequence that is obtained by writing down sequences p and q one right after another without changing the order. For example, the concatenation of the [0, 2, 0, 2, 0] and [4, 3, 3, 3, 1] is the sequence [0, 2, 0, 2, 0, 4, 3, 3, 3, 1]. The concatenation of sequences p and q is denoted as p+q.\\n\\nGyeonggeun thinks that sequences with ascents bring luck. Therefore, he wants to make many such sequences for the new year. Gyeonggeun has n sequences s_1, s_2, …, s_n which may have different lengths. \\n\\nGyeonggeun will consider all n^2 pairs of sequences s_x and s_y (1 ≤ x, y ≤ n), and will check if its concatenation s_x + s_y has an ascent. Note that he may select the same sequence twice, and the order of selection matters.\\n\\nPlease count the number of pairs (x, y) of sequences s_1, s_2, …, s_n whose concatenation s_x + s_y contains an ascent.\\n\\nInput\\n\\nThe first line contains the number n (1 ≤ n ≤ 100 000) denoting the number of sequences.\\n\\nThe next n lines contain the number l_i (1 ≤ l_i) denoting the length of s_i, followed by l_i integers s_{i, 1}, s_{i, 2}, …, s_{i, l_i} (0 ≤ s_{i, j} ≤ 10^6) denoting the sequence s_i. \\n\\nIt is guaranteed that the sum of all l_i does not exceed 100 000.\\n\\nOutput\\n\\nPrint a single integer, the number of pairs of sequences whose concatenation has an ascent.\\n\\nExamples\\n\\nInput\\n\\n\\n5\\n1 1\\n1 1\\n1 2\\n1 4\\n1 3\\n\\n\\nOutput\\n\\n\\n9\\n\\n\\nInput\\n\\n\\n3\\n4 2 0 2 0\\n6 9 9 8 8 7 7\\n1 6\\n\\n\\nOutput\\n\\n\\n7\\n\\n\\nInput\\n\\n\\n10\\n3 62 24 39\\n1 17\\n1 99\\n1 60\\n1 64\\n1 30\\n2 79 29\\n2 20 73\\n2 85 37\\n1 100\\n\\n\\nOutput\\n\\n\\n72\\n\\nNote\\n\\nFor the first example, the following 9 arrays have an ascent: [1, 2], [1, 2], [1, 3], [1, 3], [1, 4], [1, 4], [2, 3], [2, 4], [3, 4]. Arrays with the same contents are counted as their occurences.\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nlong long int n, l, i, j;\\nlong long int st, en, md;\\nvector naStart, naEnd;\\nlong long int bs(long long int val) {\\n st = 0;\\n en = naStart.size() - 1;\\n if (naStart[st] > val) {\\n return naStart.size();\\n }\\n if (naStart[en] <= val) {\\n return 0;\\n }\\n while (en > st + 1) {\\n md = (st + en) \\/ 2;\\n if (naStart[md] > val) {\\n en = md;\\n } else {\\n st = md;\\n }\\n }\\n return naStart.size() - en;\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n cin >> n;\\n long long int ct = 0;\\n vector ascend(n, false);\\n for (i = 0; i < n; i++) {\\n cin >> l;\\n vector a(l);\\n for (j = 0; j < l; j++) {\\n cin >> a[j];\\n if (j > 0 && a[j] > a[j - 1]) {\\n ascend[i] = true;\\n }\\n }\\n if (!ascend[i]) {\\n naStart.push_back(a[0]);\\n naEnd.push_back(a[l - 1]);\\n }\\n }\\n i = 0;\\n j = n;\\n while (i < n) {\\n if (ascend[i]) {\\n ct += 2 * j - 1;\\n j--;\\n }\\n i++;\\n }\\n sort(naStart.begin(), naStart.end());\\n sort(naEnd.begin(), naEnd.end());\\n for (i = 0; i < naEnd.size(); i++) {\\n ct += bs(naEnd[i]);\\n }\\n cout << ct;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"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 python3 can you solve the prior task?\",\"targets\":\"for i in range(int(input())):\\n n = int(input())\\n if n%3 == 2:\\n x, y = 0, 1\\n elif n%3 == 1:\\n x, y = 1, 0\\n else:\\n x = y = 0\\n print((n-n%3)\\/\\/3 + x, (n-n%3)\\/\\/3 + y)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A car number in Berland consists of exactly n digits. A number is called beautiful if it has at least k equal digits. Vasya wants to change the digits in his car's number so that the number became beautiful. To replace one of n digits Vasya has to pay the sum of money, equal to the absolute difference between the old digit and the new one.\\n\\nHelp Vasya: find the minimum sum of money he should pay to make the number of his car beautiful. You should also find the resulting beautiful number. If there are several such numbers, then print the lexicographically minimum one.\\n\\nInput\\n\\nThe first line contains two space-separated integers n and k (2 ≤ n ≤ 104, 2 ≤ k ≤ n) which represent how many digits the number has and how many equal digits a beautiful number should have. The second line consists of n digits. It describes the old number of Vasya's car. It is guaranteed that the number contains no spaces and only contains digits.\\n\\nOutput\\n\\nOn the first line print the minimum sum of money Vasya needs to change the number. On the second line print the car's new number. If there are several solutions, print the lexicographically minimum one.\\n\\nExamples\\n\\nInput\\n\\n6 5\\n898196\\n\\n\\nOutput\\n\\n4\\n888188\\n\\n\\nInput\\n\\n3 2\\n533\\n\\n\\nOutput\\n\\n0\\n533\\n\\n\\nInput\\n\\n10 6\\n0001112223\\n\\n\\nOutput\\n\\n3\\n0000002223\\n\\nNote\\n\\nIn the first sample replacing the second digit with an \\\"8\\\" costs |9 - 8| = 1. Replacing the fifth digit with an \\\"8\\\" costs the same. Replacing the sixth digit costs |6 - 8| = 2. As a result, Vasya will pay 1 + 1 + 2 = 4 for a beautiful number \\\"888188\\\".\\n\\nThe lexicographical comparison of strings is performed by the < operator in modern programming languages. The string x is lexicographically smaller than the string y, if there exists such i (1 ≤ i ≤ n), that xi < yi, and for any j (1 ≤ j < i) xj = yj. The strings compared in this problem will always have the length n.\\nThe above is tricky. Write me a correct solution in PYTHON.\",\"targets\":\"def update(newCost, newNum):\\n\\t\\tglobal cost, ans\\n\\t\\tif cost > newCost:\\n\\t\\t\\t\\tcost, ans = newCost, newNum\\n\\t\\tif cost == newCost and newNum <= ans:\\n\\t\\t\\t\\tcost, ans = newCost, newNum\\n\\nn, k = map(int, raw_input().split())\\npresented = [0 for i in range(10)]\\ncost, ans = 10 ** 9, \\\"9\\\" * n\\nnum = raw_input()\\nfor x in num:\\n\\t\\tpresented[int(x)] += 1\\nfor digit in range(10): # what digits are of quantity >= k\\n\\t\\td = str(digit)\\n\\t\\tneed = k - presented[digit]\\n\\t\\tcurCost, cn = 0, num\\n\\t\\ti = 0\\n\\t\\tfor difference in range(1, 10):\\n\\t\\t\\t\\tif need <= 0: break\\n\\t\\t\\t\\tfor pos in range(n):\\n\\t\\t\\t\\t\\t\\tif need <= 0: break\\n\\t\\t\\t\\t\\t\\tif int(cn[pos]) - digit == difference:\\n\\t\\t\\t\\t\\t\\t\\t\\tcn = cn[:pos] + d + cn[pos + 1:]\\n\\t\\t\\t\\t\\t\\t\\t\\tcurCost += difference\\n\\t\\t\\t\\t\\t\\t\\t\\tneed -= 1\\n\\t\\t\\t\\tfor pos in range(n - 1, -1, -1):\\n\\t\\t\\t\\t\\t\\tif need <= 0: break\\n\\t\\t\\t\\t\\t\\tif int(cn[pos]) - digit == -difference:\\n\\t\\t\\t\\t\\t\\t\\t\\tcn = cn[:pos] + d + cn[pos + 1:]\\n\\t\\t\\t\\t\\t\\t\\t\\tcurCost += difference\\n\\t\\t\\t\\t\\t\\t\\t\\tneed -= 1\\n\\t\\tupdate(curCost, cn)\\nprint(cost)\\nprint(ans)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in JAVA?\\nAs 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\":\"import java.io.*;\\nimport java.util.*;\\npublic class Solution{\\n public static void main (String[] args) throws java.lang.Exception {\\n \\/\\/int t=1;\\n int t = sc.nextInt();\\n while (t-->0) {\\n int n = sc.nextInt();\\n String str = sc.nextLine();\\n char[] arr = str.toCharArray();\\n int index=-1;\\n for(int i=0; i0){\\n if(n%2==0) s1+='B'; \\n else s1+='R';\\n }\\n System.out.println(s1);\\n }else {\\n for(int i=index; i>=1; i--){\\n if (arr[i] == 'R' && arr[i - 1] == '?') {\\n arr[i - 1] = 'B';\\n } else if (arr[i] == 'B' && arr[i - 1] == '?') {\\n arr[i - 1] = 'R';\\n }\\n }\\n for (int i = index; i < n - 1; i++) {\\n if (arr[i] == 'R' && arr[i + 1] == '?') {\\n arr[i + 1] = 'B';\\n } else if (arr[i] == 'B' && arr[i + 1] == '?') {\\n arr[i + 1] = 'R';\\n }\\n }\\n String ans = new String(arr);\\n System.out.println(ans);\\n }\\n }\\n }\\n \\/\\/ I\\/O\\n public static FastReader sc = new FastReader();\\n public static BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));\\n\\n static class FastReader {\\n BufferedReader br; StringTokenizer st;\\n public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); }\\n String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } }return st.nextToken(); }\\n int nextInt() {\\n return...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"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...]\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint32_t main() {\\n ios::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, k;\\n cin >> n >> k;\\n long long pwr = 1;\\n long long ans = 0;\\n long long MOD = 1000000007;\\n for (long long j = 0; j < 31; j++) {\\n if (k & (1 << j)) ans = (ans + pwr) % MOD;\\n pwr *= n;\\n pwr = pwr % MOD;\\n }\\n cout << ans << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"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 \\nusing ll = long long;\\nusing namespace std;\\nvoid solve() {\\n ll a, b;\\n cin >> a >> b;\\n a \\/= 2, b \\/= 2;\\n if (a > b)\\n cout << 2 * (a + b) << '\\\\n';\\n else if (a == b)\\n cout << 2 * a << '\\\\n';\\n else\\n cout << (2 * b - b % a) << '\\\\n';\\n}\\nint main() {\\n cin.tie(0)->sync_with_stdio(0), cout.tie(0);\\n ll t = 1;\\n cin >> t;\\n while (t--) solve();\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"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\\\":\",\"targets\":\"import java.io.OutputStream;\\nimport java.io.IOException;\\nimport java.io.InputStream;\\nimport java.io.PrintWriter;\\nimport java.util.Arrays;\\nimport java.util.StringTokenizer;\\nimport java.io.IOException;\\nimport java.io.BufferedReader;\\nimport java.io.FileReader;\\nimport java.io.InputStreamReader;\\nimport java.io.InputStream;\\n\\n\\/**\\n * Built using CHelper plug-in\\n * Actual solution is at the top\\n *\\n * @author Khater\\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 CCarryingConundrum solver = new CCarryingConundrum();\\n solver.solve(1, in, out);\\n out.close();\\n }\\n\\n static class CCarryingConundrum {\\n long[][][] dp;\\n char[] arr;\\n int n;\\n\\n public void solve(int testNumber, Scanner sc, PrintWriter pw) {\\n int t = 1;\\n t = sc.nextInt();\\n while (t-- > 0) {\\n arr = sc.nextLine().toCharArray();\\n n = arr.length;\\n dp = new long[n + 1][10][10];\\n for (long[][] x : dp) for (long[] y : x) Arrays.fill(y, -1);\\n pw.println(solve(0, 0, 0) - 2);\\n }\\n\\n }\\n\\n long solve(int i, int now, int nxt) {\\n if (i == n) {\\n return now == 0 && nxt == 0 ? 1 : 0;\\n }\\n if (dp[i][now][nxt] != -1) return dp[i][now][nxt];\\n long ans = 0;\\n for (int x = 0; x < 10; x++) {\\n for (int y = 0; y < 10; y++) {\\n if ((x + y + now) % 10 == arr[n - 1 - i] - '0')\\n ans += solve(i + 1, nxt, (x + y + now) >= 10 ? 1 : 0);\\n }\\n }\\n return dp[i][now][nxt] = ans;\\n }\\n\\n }\\n\\n static class Scanner {\\n StringTokenizer st;\\n BufferedReader br;\\n\\n public Scanner(FileReader r) {\\n br = new...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"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\":\"#include \\n#pragma GCC optimize(\\\"Ofast\\\")\\n#pragma GCC target(\\\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma\\\")\\n#pragma GCC optimize(\\\"unroll-loops\\\")\\nusing namespace std;\\nlong long MOD = 998244353;\\ndouble eps = 1e-12;\\nint main() {\\n ios_base::sync_with_stdio(0);\\n cin.tie(0);\\n long long t;\\n cin >> t;\\n while (t--) {\\n long long n;\\n cin >> n;\\n cout << 1 - n << \\\" \\\" << n << \\\"\\\\n\\\";\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"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\":\"t = int(input())\\nfor _ in range(t):\\n a, b = map(int, input().split())\\n memo = {}\\n lower, upper = (a+b) \\/\\/ 2, (a+b+1) \\/\\/ 2\\n for y in range(b+1):\\n x1 = a + y - upper\\n x2 = lower + y - b\\n if x1 == x2 and a >= x1 >= 0:\\n memo[int(x1+y)] = True\\n\\n x1 = a + y - lower\\n x2 = upper + y - b\\n if x1 == x2 and a >= x1 >= 0:\\n memo[int(x1 + y)] = True\\n\\n ans = memo.keys()\\n print(len(ans))\\n for a in ans:\\n print(a, end=\\\" \\\")\\n print()\",\"language\":\"python\",\"split\":\"valid\",\"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;\\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};\\nint32_t main() {\\n long long t;\\n cin >> t;\\n while (t--) {\\n long long n;\\n cin >> n;\\n long long r = n \\/ 3;\\n long long b = r;\\n if (n % 3 == 2)\\n b += 1;\\n else if (n % 3 == 1)\\n r += 1;\\n cout << r << \\\" \\\" << b << \\\"\\\\n\\\";\\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 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;\\ninline bool isdigit(char& ch) { return ch >= '0' && ch <= '9'; }\\ntemplate \\nvoid read(T& x) {\\n x = 0;\\n long long f = 1;\\n char ch = getchar();\\n for (; !isdigit(ch); ch = getchar())\\n if (ch == '-') f = -1;\\n for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';\\n x *= f;\\n}\\ntemplate \\ninline void write(T x) {\\n if (x == 0) {\\n putchar('0');\\n return;\\n }\\n if (x < 0) {\\n putchar('-');\\n x = -x;\\n }\\n int _stk[65], _top = 0;\\n for (; x; x \\/= 10) _stk[++_top] = x % 10 + 48;\\n for (; _top; _top--) putchar(_stk[_top]);\\n}\\nconst int MAXN = 1e5 + 10;\\nconst int mod = 998244353;\\nint f[MAXN], ans[MAXN], n, flag;\\nvector g[MAXN];\\nvoid dfs(int u, int fa, int d) {\\n if (!flag) return;\\n for (auto v : g[u]) {\\n if (v == fa) continue;\\n dfs(v, u, d);\\n }\\n if (f[u] % d == 0)\\n f[fa]++;\\n else {\\n if (fa) f[u]++;\\n if (f[u] % d != 0) flag = 0;\\n }\\n if (!flag) return;\\n}\\nint main() {\\n ios::sync_with_stdio(false);\\n cin.tie(nullptr);\\n cout.tie(nullptr);\\n int T;\\n cin >> T;\\n while (T--) {\\n cin >> n;\\n for (int i = (int)(1); i < (int)(n); i++) {\\n int u, v;\\n cin >> u >> v;\\n g[u].push_back(v);\\n g[v].push_back(u);\\n }\\n ans[1] = 1;\\n for (int i = (int)(1); i < (int)(n); i++)\\n ans[1] = (1ll * ans[1] + ans[1]) % mod;\\n for (int d = (int)(2); d < (int)(n + 1); d++) {\\n if ((n - 1) % d == 0) {\\n flag = 1;\\n dfs(1, 0, d);\\n ans[d] = flag;\\n for (int i = (int)(1); i < (int)(n + 1); i++) f[i] = 0;\\n }\\n }\\n for (int i = n; i >= 1; --i) {\\n for (int j = i + i; j <= n; j += i) ans[i] = (ans[i] - ans[j]) % mod;\\n }\\n for (int i = (int)(1); i < (int)(n + 1); i++) {\\n ans[i] = (ans[i] % mod + mod) % mod;\\n cout << ans[i] << ' ';\\n }\\n cout << '\\\\n';\\n for (int i = (int)(1); i < (int)(n + 1); i++) g[i].clear(), ans[i] = 0;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"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...\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"import java.util.*;\\n\\npublic class test{\\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 int n = sc.nextInt();\\n Integer arr[] = new Integer[n];\\n for(int i=0;i\\n#pragma GCC target(\\\"avx2\\\")\\n#pragma GCC optimize(\\\"Ofast\\\")\\n#pragma GCC optimize(\\\"unroll-loops\\\")\\nusing namespace std;\\nint way[100005][9];\\nint mem[(1 << (9 + 2))];\\nint p[100005];\\nint rev[100005];\\nvoid upd(int x) {\\n int grv = (1 << (9 + 1));\\n int tg = x;\\n for (int i = 0; i <= (1 << (9 - 1)); i++) {\\n mem[grv + i] = tg;\\n tg = p[tg];\\n }\\n tg = x;\\n for (int i = 0; i <= (1 << (9 - 1)); i++) {\\n for (int j = 0; j < 9; j++) {\\n way[tg][j] = mem[grv + (1 << j)];\\n }\\n tg = rev[tg];\\n grv--;\\n mem[grv] = tg;\\n }\\n}\\nint main() {\\n ios::sync_with_stdio(false);\\n cin.tie(nullptr);\\n int n, q;\\n cin >> n >> q;\\n for (int i = 0; i < n; i++) {\\n cin >> p[i];\\n p[i]--;\\n rev[p[i]] = i;\\n }\\n for (int i = 0; i < n; i++) {\\n int tg = i, np = 0;\\n for (int j = 1; j <= (1 << (9 - 1)); j++) {\\n tg = p[tg];\\n if (j == (1 << np)) {\\n way[i][np] = tg;\\n np++;\\n }\\n }\\n }\\n while (q > 0) {\\n q--;\\n int t, x, y;\\n cin >> t >> x >> y;\\n if (t == 1) {\\n x--;\\n y--;\\n swap(p[x], p[y]);\\n rev[p[x]] = x;\\n rev[p[y]] = y;\\n upd(x);\\n upd(y);\\n } else {\\n x--;\\n int res = x;\\n int cp = 9 - 1;\\n while (y > 0) {\\n while (y < (1 << cp)) {\\n cp--;\\n }\\n y -= (1 << cp);\\n res = way[res][cp];\\n }\\n cout << res + 1 << '\\\\n';\\n }\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Barney is standing in a bar and starring at a pretty girl. He wants to shoot her with his heart arrow but he needs to know the distance between him and the girl to make his shot accurate.\\n\\n\\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\":\"def main():\\n\\ts = input()\\n\\tprint(solver(s))\\n\\ndef solver(s):\\n\\t(baseS, expS) = s.split('e')\\n\\texp = int(expS)\\n\\tnS = baseS[:firstTrailingZero(baseS)]\\n\\tif len(nS) - 2 > exp:\\n\\t\\tnS = nS[0] + nS[2:exp + 2] + \\\\\\n\\t\\t'.' + nS[exp + 2:]\\n\\t\\t#if len(baseS) - 2 != exp:\\n\\t\\t\\t#nS += '.' + baseS[exp + 2:]\\n\\t\\t\\n\\t\\t#(wholePart, decPart) = nS.split('.')\\n\\t\\t#if decPart == '0' * len(decPart):\\n\\t\\t#\\treturn wholePart\\n\\t\\t#else:\\n\\t\\t#\\treturn nS\\n\\telse:\\n\\t\\tnS = nS[0] + nS[2:] + \\\\\\n\\t\\t'0' * (exp - len(nS) + 2)\\n\\treturn nS\\n\\n\\ndef firstTrailingZero(s):\\n\\tindex = len(s) - 1\\n\\twhile s[index] == '0':\\n\\t\\tindex -= 1\\n\\treturn index + 1\\n\\n#print(firstTrailingZero(\\\"10.20\\\"), 1)\\n\\n# print(solver(\\\"8.549e2\\\"))\\n# print(solver(\\\"8.549e3\\\"))\\n# print(solver(\\\"0.33e0\\\"))\\n# print(solver(\\\"1.31e1\\\"))\\n# print(solver(\\\"8.25983e5\\\"))\\n# print(solver(\\\"8.25e5\\\"))\\n# print(solver(\\\"4.28522890224373996236468418851564462623381500262405e30\\\"))\\n# print(solver(\\\"1.0e0\\\"))\\n# print(solver(\\\"1.020e1\\\"))\\n\\nmain()\",\"language\":\"python\",\"split\":\"train\",\"template\":\"soltask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A string S of an odd length is said to be a strong palindrome if and only if all of the following conditions are satisfied:\\n\\n* S is a palindrome.\\n* Let N be the length of S. The string formed by the 1-st through ((N-1)\\/2)-th characters of S is a palindrome.\\n* The string consisting of the (N+3)\\/2-st through N-th characters of S is a palindrome.\\n\\n\\n\\nDetermine whether S is a strong palindrome.\\n\\nConstraints\\n\\n* S consists of lowercase English letters.\\n* The length of S is an odd number between 3 and 99 (inclusive).\\n\\nInput\\n\\nInput is given from Standard Input in the following format:\\n\\n\\nS\\n\\n\\nOutput\\n\\nIf S is a strong palindrome, print `Yes`; otherwise, print `No`.\\n\\nExamples\\n\\nInput\\n\\nakasaka\\n\\n\\nOutput\\n\\nYes\\n\\n\\nInput\\n\\nlevel\\n\\n\\nOutput\\n\\nNo\\n\\n\\nInput\\n\\natcoder\\n\\n\\nOutput\\n\\nNo\\ns=inp\",\"targets\":\"ut()\\nn=len(s)\\nans='Yes'\\n\\nif s[:(n-1)\\/\\/2] != s[(n+1)\\/\\/2:] or s[:(n-1)\\/\\/2] != s[(n-3)\\/\\/2::-1]:\\n ans='No'\\n\\nprint(ans)\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Everybody knows that opposites attract. That is the key principle of the \\\"Perfect Matching\\\" dating agency. The \\\"Perfect Matching\\\" matchmakers have classified each registered customer by his interests and assigned to the i-th client number ti ( - 10 ≤ ti ≤ 10). Of course, one number can be assigned to any number of customers.\\n\\n\\\"Perfect Matching\\\" wants to advertise its services and publish the number of opposite couples, that is, the couples who have opposite values of t. Each couple consists of exactly two clients. The customer can be included in a couple an arbitrary number of times. Help the agency and write the program that will find the sought number by the given sequence t1, t2, ..., tn. For example, if t = (1, - 1, 1, - 1), then any two elements ti and tj form a couple if i and j have different parity. Consequently, in this case the sought number equals 4.\\n\\nOf course, a client can't form a couple with him\\/herself.\\n\\nInput\\n\\nThe first line of the input data contains an integer n (1 ≤ n ≤ 105) which represents the number of registered clients of the \\\"Couple Matching\\\". The second line contains a sequence of integers t1, t2, ..., tn ( - 10 ≤ ti ≤ 10), ti — is the parameter of the i-th customer that has been assigned to the customer by the result of the analysis of his interests.\\n\\nOutput\\n\\nPrint the number of couples of customs with opposite t. The opposite number for x is number - x (0 is opposite to itself). Couples that only differ in the clients' order are considered the same.\\n\\nNote that the answer to the problem can be large enough, so you must use the 64-bit integer type for calculations. Please, do not use the %lld specificator to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specificator.\\n\\nExamples\\n\\nInput\\n\\n5\\n-3 3 0 0 3\\n\\n\\nOutput\\n\\n3\\n\\n\\nInput\\n\\n3\\n0 0 0\\n\\n\\nOutput\\n\\n3\\n\\nNote\\n\\nIn the first sample the couples of opposite clients are: (1,2), (1,5) и (3,4).\\n\\nIn the second sample any couple of clients is opposite.\\nimpor\",\"targets\":\"t sys\\ncnt=[0]*30\\nn=int(sys.stdin.readline())\\nlist=map(int,sys.stdin.readline().split(' '))\\nfor i in list:\\n\\tcnt[i+10]+=1;\\nres=0\\nfor i in range(0,11):\\n\\tif i==10:\\n\\t\\tres+=(cnt[i]*(cnt[i]-1))\\/2\\n\\telse:\\n\\t\\tres+=cnt[i]*cnt[20-i]\\nprint res\",\"language\":\"python\",\"split\":\"train\",\"template\":\"contsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nA 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\",\"targets\":\"#include \\nusing namespace std;\\ntemplate \\nT max3(T a, T b, T c) {\\n return max(a, max(b, c));\\n}\\ntemplate \\nT max4(T a, T b, T c, T d) {\\n return max(max(a, d), max(b, c));\\n}\\ntemplate \\nT min3(T a, T b, T c) {\\n return min(a, min(b, c));\\n}\\ntemplate \\nT min4(T a, T b, T c, T d) {\\n return min(min(a, d), min(b, c));\\n}\\ntemplate \\nT binex(T a, T b, T mod) {\\n T ans = 1;\\n a %= mod;\\n while (b > 0) {\\n if (b & 1) {\\n ans *= a;\\n ans %= mod;\\n }\\n a *= a;\\n a %= mod;\\n b >>= 1;\\n }\\n return ans;\\n}\\ntemplate \\nostream& operator<<(ostream& os, vector a) {\\n for (auto x : a) {\\n os << x << \\\" \\\";\\n }\\n return os;\\n}\\ntemplate \\nostream& operator<<(ostream& os, set a) {\\n for (auto x : a) {\\n os << x << \\\" \\\";\\n }\\n return os;\\n}\\ntemplate \\nostream& operator<<(ostream& os, multiset a) {\\n for (auto x : a) {\\n os << x << \\\" \\\";\\n }\\n return os;\\n}\\ntemplate \\nostream& operator<<(ostream& os, pair a) {\\n os << \\\"| \\\";\\n os << a.first << \\\", \\\" << a.second << \\\" \\\";\\n return os << \\\"|\\\";\\n}\\ntemplate \\nostream& operator<<(ostream& os, tuple a) {\\n os << \\\"| \\\" << (get<0>(a)) << \\\", \\\" << (get<1>(a)) << \\\", \\\" << (get<2>(a))\\n << \\\"|\\\";\\n return os;\\n}\\nvoid precomp() {}\\nvoid solve() {\\n int64_t n, k;\\n cin >> n >> k;\\n vector> edges(n + 1);\\n for (int64_t i = 0; i < n - 1; i++) {\\n int64_t a, b;\\n cin >> a >> b;\\n edges[a].push_back(b);\\n edges[b].push_back(a);\\n }\\n if (k == 2) {\\n cout << ((n * (n - 1)) \\/ 2) % int64_t(1000000007) << \\\"\\\\n\\\";\\n return;\\n }\\n int64_t fans = 0;\\n for (int64_t i = 1; i <= n; i++) {\\n int64_t root = i;\\n vector vis(n + 1, false);\\n vis[root] = true;\\n vector> cnt;\\n int64_t maxaa = 0;\\n for (auto x : edges[root]) {\\n queue sto;\\n sto.push(x);\\n vis[x] = true;\\n vector depth(n + 1, -1);\\n int64_t maxa = 0;\\n depth[x] = 0;\\n while...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"A new delivery of clothing has arrived today to the clothing store. This delivery consists of a ties, b scarves, c vests and d jackets.\\n\\nThe store does not sell single clothing items — instead, it sells suits of two types:\\n\\n * a suit of the first type consists of one tie and one jacket; \\n * a suit of the second type consists of one scarf, one vest and one jacket. \\n\\n\\n\\nEach suit of the first type costs e coins, and each suit of the second type costs f coins.\\n\\nCalculate the maximum possible cost of a set of suits that can be composed from the delivered clothing items. Note that one item cannot be used in more than one suit (though some items may be left unused).\\n\\nInput\\n\\nThe first line contains one integer a (1 ≤ a ≤ 100 000) — the number of ties.\\n\\nThe second line contains one integer b (1 ≤ b ≤ 100 000) — the number of scarves.\\n\\nThe third line contains one integer c (1 ≤ c ≤ 100 000) — the number of vests.\\n\\nThe fourth line contains one integer d (1 ≤ d ≤ 100 000) — the number of jackets.\\n\\nThe fifth line contains one integer e (1 ≤ e ≤ 1 000) — the cost of one suit of the first type.\\n\\nThe sixth line contains one integer f (1 ≤ f ≤ 1 000) — the cost of one suit of the second type.\\n\\nOutput\\n\\nPrint one integer — the maximum total cost of some set of suits that can be composed from the delivered items. \\n\\nExamples\\n\\nInput\\n\\n\\n4\\n5\\n6\\n3\\n1\\n2\\n\\n\\nOutput\\n\\n\\n6\\n\\n\\nInput\\n\\n\\n12\\n11\\n13\\n20\\n4\\n6\\n\\n\\nOutput\\n\\n\\n102\\n\\n\\nInput\\n\\n\\n17\\n14\\n5\\n21\\n15\\n17\\n\\n\\nOutput\\n\\n\\n325\\n\\nNote\\n\\nIt is possible to compose three suits of the second type in the first example, and their total cost will be 6. Since all jackets will be used, it's impossible to add anything to this set.\\n\\nThe best course of action in the second example is to compose nine suits of the first type and eleven suits of the second type. The total cost is 9 ⋅ 4 + 11 ⋅ 6 = 102.\",\"targets\":\"import java.util.*;\\n\\npublic class Main {\\n\\n public static void main(String[] args) {\\n\\t\\n\\t Scanner sc = new Scanner(System.in);\\n\\t \\n\\t\\tint a = sc.nextInt();\\n\\t\\t\\n\\t\\tint b = sc.nextInt();\\n\\t\\t\\n\\t\\tint c=sc.nextInt();\\n\\t\\t\\n\\t\\tint d=sc.nextInt();\\n\\t\\t\\n\\t\\tint e=sc.nextInt();\\n\\t\\t\\n\\t\\tint f=sc.nextInt();\\n\\t\\t\\n\\t\\tint first=Math.min(a,d)*e;\\n\\t\\t\\n\\t\\tint second = Math.min(b, Math.min(c, d))*f;\\n\\t\\t\\n\\t\\tint total=0;\\n\\t\\t\\n\\t\\tif(e>f) {\\n\\t\\t\\t\\n\\t\\t\\ttotal+=first;\\n\\t\\t\\t\\n\\t\\t\\td-=Math.min(a, d);\\n\\t\\t\\t\\n\\t\\t\\ttotal+=Math.min(b, Math.min(c, d))*f;\\n\\t\\t}\\n\\t\\t\\n\\t\\telse {\\n\\t\\t\\t\\n\\t\\t\\ttotal+=second;\\n\\t\\t\\t\\n\\t\\t\\td-=Math.min(b, Math.min(c, d));\\n\\t\\t\\t\\n\\t\\t\\ttotal+=Math.min(a, d)*e;\\n\\t\\t}\\n\\t\\t\\n\\t\\tSystem.out.println(total);\\n\\t \\n\\t \\n \\n\\t sc.close();\\n\\t \\n System.exit(0);\\n \\n }\\n\\n\\n public static int fibon (int n) {\\n\\t \\n\\t if (n<=1) {\\n\\t\\t \\n\\t\\t return n;\\n\\t }\\n\\t int [] array = new int [n+1];\\n\\t array[0] = 0 ; array[1]= 1;\\n\\t for (int i = 2; i <= n; i++) {\\n\\t\\tarray[i] = array [i-2] + array[i-1];\\n\\t}\\n\\t \\n\\treturn array[n];\\n\\t \\n }\\n \\n \\n\\tpublic static int sumofdigits(int n) \\n { \\n int sum = 0; \\n \\n while (n != 0) \\n { \\n sum = sum + n % 10; \\n n = n\\/10; \\n } \\n \\n return sum; \\n} \\n\\n public static int reversedigits(int num) \\n { \\n int rev_num = 0; \\n while(num > 0) \\n { \\n rev_num = rev_num * 10 + num % 10; \\n num = num \\/ 10; \\n } \\n return rev_num; \\n } \\n\\tpublic static int binarysearch(int arr[], int l, int r, int x) \\n { \\n\\t\\t\\n if (r >= l) { \\n int mid = l + (r - l) \\/ 2; \\n if (arr[mid] == x) \\n return mid; \\n if (arr[mid] > x) \\n return binarysearch(arr, l, mid - 1, x); \\n return binarysearch(arr, mid + 1, r, x); \\n } \\n return -1; \\n }\\n\\t\\t\\n\\tpublic static long gcd(long a, long b)\\n\\t {\\n\\t if (a == 0)\\n\\t return b; \\n\\t return gcd(b % a, a); \\n\\t }\\n\\t\\n\\t public static long lcm (long a, long b)\\n\\t {\\n\\t return (a \\/ gcd(a, b)) * b;\\n\\t }\\n\\t \\n\\t public static void rangeofprimenumber(int a, int b) \\n\\t { \\n\\t ...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\nA 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\":\"#include \\nusing namespace std;\\nint main() {\\n int t;\\n cin >> t;\\n while (t--) {\\n long long w, h;\\n cin >> w >> h;\\n long long max1 = 0;\\n for (int i = 0; i < 4; i++) {\\n int k;\\n cin >> k;\\n vector a(k);\\n for (auto &x : a) {\\n cin >> x;\\n }\\n if (i == 0 || i == 1) {\\n if ((a[k - 1] - a[0]) * h > max1) {\\n max1 = (a[k - 1] - a[0]) * h;\\n }\\n } else if (i == 2 || i == 3) {\\n if ((a[k - 1] - a[0]) * w > max1) {\\n max1 = (a[k - 1] - a[0]) * w;\\n }\\n }\\n }\\n cout << max1 << '\\\\n';\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"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...\\nThe above is tricky. Write me a correct solution in PYTHON3.\",\"targets\":\"# Author: Uday Gupta\\n\\n\\ndef make_reachable(x, y):\\n stack = []\\n stack.append((x, y))\\n\\n while len(stack):\\n s = stack[-1]\\n stack.pop()\\n i = s[0]\\n j = s[1]\\n\\n if reachable_table[i][j] == 0:\\n reachable_table[i][j] = 1\\n if i + 1 < n and grid[i + 1][j] == 'B':\\n if reachable_table[i + 1][j] == 0:\\n stack.append((i + 1,j))\\n if i - 1 >= 0 and grid[i - 1][j] == 'B':\\n if reachable_table[i - 1][j] == 0:\\n stack.append((i - 1, j))\\n if j + 1 < m and grid[i][j + 1] == 'B':\\n if reachable_table[i][j + 1] == 0:\\n stack.append((i,j + 1))\\n if j - 1 >= 0 and grid[i][j - 1] == 'B':\\n if reachable_table[i][j - 1] == 0:\\n stack.append((i,j - 1))\\n\\n\\nn, m = list(map(int, input().split()))\\n\\ngrid = []\\nfor i in range(n):\\n l = input()\\n u = []\\n for j in range(m):\\n if l[j] == '#':\\n u.append('B')\\n else:\\n u.append('W')\\n\\n grid.append(u)\\n\\nwhite_column = 0\\nwhite_row = 0\\nfor i in range(n):\\n row = grid[i]\\n if 'B' in row:\\n continue\\n else:\\n white_row = 1\\n\\nfor j in range(m):\\n col = []\\n for i in range(n):\\n col.append(grid[i][j])\\n if 'B' in col:\\n continue\\n else:\\n white_column = 1\\n\\nif (white_row == 1 and white_column == 0) or (white_row == 0 and white_column == 1):\\n print(-1)\\n exit()\\n\\nif n == 1:\\n white_present = 0\\n black_present = 0\\n\\n for i in range(m):\\n if grid[0][i] == 'B':\\n black_present = 1\\n if grid[0][i] == 'W':\\n white_present = 1\\n if black_present == 1 and white_present == 1:\\n print(-1)\\n exit()\\n elif black_present == 0 and white_present == 1:\\n print(0)\\n exit()\\n elif black_present == 1 and white_present == 0:\\n print(m)\\n exit()\\n\\nelif m == 1:\\n white_present = 0\\n black_present = 0\\n for i in range(n):\\n if grid[i][0] == 'B':\\n black_present = 1\\n ...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"abovesol\",\"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...\\nThe above is tricky. Write me a correct solution in JAVA.\",\"targets\":\"\\/*==========================================================================\\n* \\tAUTHOR: RonWonWon\\n* \\tCREATED: 29.10.2021 20:01:58 \\n\\/*==========================================================================*\\/\\nimport java.io.*;\\nimport java.util.*;\\n\\npublic class B {\\n\\t\\n\\tpublic static void main(String[] args) throws IOException {\\n\\t\\t\\/*\\n in.ini();\\n PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(\\\"output.txt\\\")));\\n *\\/\\n long startTime = System.nanoTime();\\n int t = in.nextInt(), T = 1; \\n while(t-->0) { \\n long n = in.nextLong(), k = in.nextLong();\\n long cur = 0, comp = 1;\\n while(comp=n) out.println(cur);\\n else{\\n \\tout.println(cur + (n-comp+k-1)\\/k);\\n }\\n \\t\\t\\/\\/out.println(\\\"Case #\\\"+T+\\\": \\\"+ans); T++;\\n }\\n \\/*\\n startTime = System.nanoTime() - startTime;\\n System.err.println(\\\"Time: \\\"+(startTime\\/1000000));\\n *\\/\\n out.flush();\\n\\t}\\n\\t\\n\\tstatic FastScanner in = new FastScanner();\\n static PrintWriter out = new PrintWriter(System.out);\\n\\tstatic int oo = Integer.MAX_VALUE;\\n\\tstatic long ooo = Long.MAX_VALUE;\\n\\t\\n\\tstatic class FastScanner {\\n\\t\\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\\n\\t\\tStringTokenizer st = new StringTokenizer(\\\"\\\");\\n\\t\\t\\n\\t\\tvoid ini() throws FileNotFoundException {\\n\\t\\t\\tbr = new BufferedReader(new FileReader(\\\"input.txt\\\"));\\n\\t\\t}\\n\\t\\t\\n\\t\\tString next() {\\n\\t\\t\\twhile(!st.hasMoreTokens())\\n\\t\\t\\t\\ttry { st = new StringTokenizer(br.readLine()); }\\n\\t\\t\\t\\tcatch(IOException e) {}\\n\\t\\t\\treturn st.nextToken();\\n\\t\\t}\\n\\t\\t\\n\\t\\tString nextLine(){\\n\\t\\t\\ttry{ return br.readLine(); } \\n\\t\\t\\tcatch(IOException e) { } return \\\"\\\";\\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;i\\nusing namespace std;\\nint N, i, j, k, A[500001], ans = 0;\\nint main() {\\n scanf(\\\"%d\\\", &N);\\n for (int l = 0; l < N; l++) scanf(\\\"%d\\\", &A[l]);\\n i = 1;\\n while (i < N - 1) {\\n j = k = i;\\n while (j < N - 1 && A[j] != A[j - 1] && A[j] != A[j + 1]) j++;\\n if ((j - i) % 2 == 0) {\\n while (k < i + (j - i) \\/ 2) A[k++] = A[i - 1];\\n while (k < j) A[k++] = A[j];\\n } else {\\n while (k < j) A[k++] = A[j];\\n }\\n ans = max(ans, (j - i) \\/ 2 + ((j - i) % 2 == 1 ? 1 : 0));\\n i = j + 1;\\n }\\n printf(\\\"%d\\\\n\\\", ans);\\n for (int i = 0; i < N; i++) printf(\\\"%d \\\", A[i]);\\n printf(\\\"\\\\n\\\");\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Being stuck at home, Ray became extremely bored. To pass time, he asks Lord Omkar to use his time bending power: Infinity Clock! However, Lord Omkar will only listen to mortals who can solve the following problem:\\n\\nYou are given an array a of n integers. You are also given an integer k. Lord Omkar wants you to do k operations with this array.\\n\\nDefine one operation as the following: \\n\\n 1. Set d to be the maximum value of your array. \\n 2. For every i from 1 to n, replace a_{i} with d-a_{i}. \\n\\n\\n\\nThe goal is to predict the contents in the array after k operations. Please help Ray determine what the final sequence will look like!\\n\\nInput\\n\\nEach test contains multiple test cases. The first line contains the number of cases t (1 ≤ t ≤ 100). Description of the test cases follows.\\n\\nThe first line of each test case contains two integers n and k (1 ≤ n ≤ 2 ⋅ 10^5, 1 ≤ k ≤ 10^{18}) – the length of your array and the number of operations to perform.\\n\\nThe second line of each test case contains n integers a_{1},a_{2},...,a_{n} (-10^9 ≤ a_{i} ≤ 10^9) – the initial contents of your array.\\n\\nIt is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.\\n\\nOutput\\n\\nFor each case, print the final version of array a after k operations described above.\\n\\nExample\\n\\nInput\\n\\n\\n3\\n2 1\\n-199 192\\n5 19\\n5 -1 4 2 0\\n1 2\\n69\\n\\n\\nOutput\\n\\n\\n391 0\\n0 6 1 3 5\\n0\\n\\nNote\\n\\nIn the first test case the array changes as follows:\\n\\n * Initially, the array is [-199, 192]. d = 192.\\n\\n * After the operation, the array becomes [d-(-199), d-192] = [391, 0].\",\"targets\":\"import java.io.OutputStream;\\nimport java.io.IOException;\\nimport java.io.InputStream;\\nimport java.io.OutputStream;\\nimport java.io.PrintWriter;\\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 BOmkarAndInfinityClock solver = new BOmkarAndInfinityClock();\\n int testCount = Integer.parseInt(in.next());\\n for (int i = 1; i <= testCount; i++)\\n solver.solve(i, in, out);\\n out.close();\\n }\\n\\n static class BOmkarAndInfinityClock {\\n public void solve(int testNumber, InputReader in, OutputWriter out) {\\n int n = in.nextInt();\\n long k = in.nextLong();\\n int[] a = in.readIntArray(n);\\n\\n int max = ArrayUtils.max(a);\\n for (int i = 0; i < n; i++) {\\n a[i] = max - a[i];\\n }\\n k--;\\n int fmax = ArrayUtils.max(a);\\n\\n boolean reverse = k % 2 == 1L;\\n if (reverse) {\\n for (int i = 0; i < n; i++) {\\n a[i] = fmax - a[i];\\n }\\n }\\n\\n out.println(a);\\n }\\n\\n }\\n\\n static class OutputWriter extends PrintWriter {\\n public OutputWriter(OutputStream outputStream) {\\n super(outputStream);\\n }\\n\\n public OutputWriter(Writer writer) {\\n super(writer);\\n }\\n\\n public OutputWriter(String filename) throws FileNotFoundException {\\n super(filename);\\n }\\n\\n public void println(int[] array) {\\n for (int i =...\",\"language\":\"python\",\"split\":\"train\",\"template\":\"descsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Dasha decided to have a rest after solving the problem. She had been ready to start her favourite activity — origami, but remembered the puzzle that she could not solve. \\n\\n\\n\\nThe tree is a non-oriented connected graph without cycles. In particular, there always are n - 1 edges in a tree with n vertices.\\n\\nThe puzzle is to position the vertices at the points of the Cartesian plane with integral coordinates, so that the segments between the vertices connected by edges are parallel to the coordinate axes. Also, the intersection of segments is allowed only at their ends. Distinct vertices should be placed at different points. \\n\\nHelp Dasha to find any suitable way to position the tree vertices on the plane.\\n\\nIt is guaranteed that if it is possible to position the tree vertices on the plane without violating the condition which is given above, then you can do it by using points with integral coordinates which don't exceed 1018 in absolute value.\\n\\nInput\\n\\nThe first line contains single integer n (1 ≤ n ≤ 30) — the number of vertices in the tree. \\n\\nEach of next n - 1 lines contains two integers ui, vi (1 ≤ ui, vi ≤ n) that mean that the i-th edge of the tree connects vertices ui and vi.\\n\\nIt is guaranteed that the described graph is a tree.\\n\\nOutput\\n\\nIf the puzzle doesn't have a solution then in the only line print \\\"NO\\\".\\n\\nOtherwise, the first line should contain \\\"YES\\\". The next n lines should contain the pair of integers xi, yi (|xi|, |yi| ≤ 1018) — the coordinates of the point which corresponds to the i-th vertex of the tree.\\n\\nIf there are several solutions, print any of them. \\n\\nExamples\\n\\nInput\\n\\n7\\n1 2\\n1 3\\n2 4\\n2 5\\n3 6\\n3 7\\n\\nOutput\\n\\nYES\\n0 0\\n1 0\\n0 1\\n2 0\\n1 -1\\n-1 1\\n0 2\\n\\nInput\\n\\n6\\n1 2\\n2 3\\n2 4\\n2 5\\n2 6\\n\\n\\nOutput\\n\\nNO\\n\\n\\nInput\\n\\n4\\n1 2\\n2 3\\n3 4\\n\\nOutput\\n\\nYES\\n3 3\\n4 3\\n5 3\\n6 3\\n\\nNote\\n\\nIn the first sample one of the possible positions of tree is: \\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nconst int fx[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};\\nvector g[50];\\nlong long x[50], y[50];\\nint in[50], n, i;\\nvoid dfs(int now, int lst, int wtf, long long dis) {\\n int jj = 0;\\n for (int ii = 0; ii < g[now].size(); ii++)\\n if (g[now][ii] != lst) {\\n if (jj == wtf) jj++;\\n x[g[now][ii]] = x[now] + dis * fx[jj][0];\\n y[g[now][ii]] = y[now] + dis * fx[jj][1];\\n dfs(g[now][ii], now, (jj + 2) & 3, dis \\/ 2 - 1);\\n jj++;\\n }\\n}\\nint main() {\\n scanf(\\\"%d\\\", &n);\\n for (i = 1; i < n; i++) {\\n int x, y;\\n scanf(\\\"%d%d\\\", &x, &y);\\n g[x].push_back(y);\\n g[y].push_back(x);\\n in[x]++;\\n in[y]++;\\n }\\n for (i = 1; i <= n; i++)\\n if (in[i] > 4) {\\n puts(\\\"NO\\\");\\n return 0;\\n }\\n dfs(1, 0, -1, 1000000000000000LL);\\n puts(\\\"YES\\\");\\n for (i = 1; i <= n; i++) printf(\\\"%lld %lld\\\\n\\\", x[i], y[i]);\\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?\\nCQXYM 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::sync_with_stdio(0);\\n cin.tie(0);\\n srand(chrono::high_resolution_clock::now().time_since_epoch().count());\\n int t;\\n cin >> t;\\n while (t--) {\\n long long n;\\n cin >> n;\\n long long ans = 2 * n;\\n long long sum = 1;\\n for (int i = ans; i > 2; i--) {\\n sum *= i;\\n sum %= 1000000007;\\n }\\n cout << sum << \\\"\\\\n\\\";\\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→...\\n#incl\",\"targets\":\"ude \\nusing namespace std;\\nvoid _print(long long int 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.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}\\nlong long int add(long long int x, long long int y) {\\n long long int ans = x + y;\\n return (ans >= 1000000007 ? ans - 1000000007 : ans);\\n}\\nlong long int sub(long long int x, long long int y) {\\n long long int ans = x - y;\\n return (ans < 0 ? ans + 1000000007 : ans);\\n}\\nlong long int mul(long long int x, long long int y) {\\n long long int ans = x * y;\\n return (ans >= 1000000007 ? ans % 1000000007 : ans);\\n}\\nvoid solve() {}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n srand(time(NULL));\\n long long int t;\\n cin >> t;\\n while (t--) {\\n int n;\\n cin >> n;\\n string a, b;\\n cin >> a >> b;\\n int x = 0, y = 0, x1 = 0, y1 = 0;\\n for (long long int i = 0; i < n; ++i)\\n if (a[i] == b[i]) {\\n x++;\\n if (a[i] == '1') x1++;\\n } else {\\n y++;\\n if (a[i] == '1') y1++;\\n }\\n int ans = INT_MAX;\\n if (x...\",\"language\":\"python\",\"split\":\"test\",\"template\":\"contsol\",\"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\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nvoid _debug() { cerr << '\\\\n'; }\\ntemplate \\nvoid _debug(A a, B... b) {\\n cerr << a << ' ', _debug(b...);\\n}\\nconst int oo = 2000000000;\\nconst int mod = 1e9 + 7;\\nlong long fp(long long v, long long x) {\\n long long res = 1;\\n while (x) {\\n if (x & 1) res = res * v % mod;\\n v = v * v % mod;\\n x >>= 1;\\n }\\n return res % mod;\\n}\\nvoid solve() {\\n long long h;\\n cin >> h;\\n long long sum = 0;\\n sum = (1ll << h) - 2;\\n long long ans = fp(4, sum) % mod;\\n ans = ans * 6 % mod;\\n cout << ans << '\\\\n';\\n}\\nint main() {\\n ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);\\n ;\\n int t;\\n t = 1;\\n while (t--) solve();\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Omkar is creating a mosaic using colored square tiles, which he places in an n × n grid. When the mosaic is complete, each cell in the grid will have either a glaucous or sinoper tile. However, currently he has only placed tiles in some cells. \\n\\nA completed mosaic will be a mastapeece if and only if each tile is adjacent to exactly 2 tiles of the same color (2 tiles are adjacent if they share a side.) Omkar wants to fill the rest of the tiles so that the mosaic becomes a mastapeece. Now he is wondering, is the way to do this unique, and if it is, what is it?\\n\\nInput\\n\\nThe first line contains a single integer n (1 ≤ n ≤ 2000).\\n\\nThen follow n lines with n characters in each line. The i-th character in the j-th line corresponds to the cell in row i and column j of the grid, and will be S if Omkar has placed a sinoper tile in this cell, G if Omkar has placed a glaucous tile, . if it's empty. \\n\\nOutput\\n\\nOn the first line, print UNIQUE if there is a unique way to get a mastapeece, NONE if Omkar cannot create any, and MULTIPLE if there is more than one way to do so. All letters must be uppercase.\\n\\nIf you print UNIQUE, then print n additional lines with n characters in each line, such that the i-th character in the j^{th} line is S if the tile in row i and column j of the mastapeece is sinoper, and G if it is glaucous. \\n\\nExamples\\n\\nInput\\n\\n\\n4\\nS...\\n..G.\\n....\\n...S\\n\\n\\nOutput\\n\\n\\nMULTIPLE\\n\\n\\nInput\\n\\n\\n6\\nS.....\\n....G.\\n..S...\\n.....S\\n....G.\\nG.....\\n\\n\\nOutput\\n\\n\\nNONE\\n\\n\\nInput\\n\\n\\n10\\n.S....S...\\n..........\\n...SSS....\\n..........\\n..........\\n...GS.....\\n....G...G.\\n..........\\n......G...\\n..........\\n\\n\\nOutput\\n\\n\\nUNIQUE\\nSSSSSSSSSS\\nSGGGGGGGGS\\nSGSSSSSSGS\\nSGSGGGGSGS\\nSGSGSSGSGS\\nSGSGSSGSGS\\nSGSGGGGSGS\\nSGSSSSSSGS\\nSGGGGGGGGS\\nSSSSSSSSSS\\n\\n\\nInput\\n\\n\\n1\\n.\\n\\n\\nOutput\\n\\n\\nNONE\\n\\nNote\\n\\nFor the first test case, Omkar can make the mastapeeces\\n\\nSSSS\\n\\nSGGS\\n\\nSGGS\\n\\nSSSS\\n\\nand \\n\\nSSGG\\n\\nSSGG\\n\\nGGSS\\n\\nGGSS.\\n\\nFor the second test case, it can be proven that it is impossible for Omkar to add tiles to create a mastapeece.\\n\\nFor the third case, it can be proven that the given mastapeece is the...\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nint n, a[100005][2];\\nchar s[2005][2005];\\nint main() {\\n scanf(\\\"%d\\\", &n);\\n for (int i = 1; i <= n; i++) scanf(\\\"%s\\\", s[i] + 1);\\n if (n % 2) {\\n printf(\\\"NONE\\\\n\\\");\\n return 0;\\n }\\n for (int i = 1; i <= n; i++)\\n for (int j = 1; j <= n; j++)\\n if (s[i][j] != '.') {\\n int u = (s[i][j] == 'G'), p = -1;\\n u ^= min(min(i - 1, j - 1), min(n - i, n - j)) & 1;\\n if ((i + j) % 2) {\\n int nw = i - j;\\n if (nw < 0) nw = -nw;\\n p = (nw + 1) \\/ 2;\\n } else {\\n int nw = i + j;\\n if (nw <= n)\\n p = nw \\/ 2;\\n else\\n p = n + 1 - nw \\/ 2;\\n }\\n a[p][u] = 1;\\n }\\n for (int i = 1; i <= n \\/ 2; i++)\\n if (a[i][0] && a[i][1]) {\\n printf(\\\"NONE\\\\n\\\");\\n return 0;\\n }\\n for (int i = 1; i <= n \\/ 2; i++)\\n if (!a[i][0] && !a[i][1]) {\\n printf(\\\"MULTIPLE\\\\n\\\");\\n return 0;\\n }\\n printf(\\\"UNIQUE\\\\n\\\");\\n for (int i = 1; i <= n; i++) {\\n for (int j = 1; j <= n; j++) {\\n int u = 0, p = -1;\\n u ^= min(min(i - 1, j - 1), min(n - i, n - j)) & 1;\\n if ((i + j) % 2) {\\n int nw = i - j;\\n if (nw < 0) nw = -nw;\\n p = (nw + 1) \\/ 2;\\n } else {\\n int nw = i + j;\\n if (nw <= n)\\n p = nw \\/ 2;\\n else\\n p = n + 1 - nw \\/ 2;\\n }\\n u ^= a[p][1];\\n printf(\\\"%c\\\", u ? 'G' : 'S');\\n }\\n printf(\\\"\\\\n\\\");\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON 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\":\"for _ in range(input()):\\n n=input()\\n if n<=6:\\n print 15\\n continue\\n if n%6==0:\\n print n\\/6*15\\n elif n%6==1 or n%6==2:\\n print n\\/6*15+5\\n elif n%6==4 or n%6==3:\\n print n\\/6*15+10\\n else:\\n print n\\/6*15+15\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"solfor\",\"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\\nSolve the task in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nconst int P = 998244353;\\nint dp[103][2003], tp[103][2003], R[2003], TR[2003], N, K, A[2003];\\nint upd(int x) { return x + (x >> 31 & P); }\\nint add(int x, int y) { return upd(x + y - P); }\\nint sub(int x, int y) { return upd(x - y); }\\nint main() {\\n cin >> N >> K;\\n for (int i = 1; i <= N; ++i) cin >> A[i];\\n for (int i = A[N] - K; i <= A[N] + K; ++i)\\n if (i >= 0 && i <= N) dp[i + K - A[N]][1] = 1;\\n A[0] = -K;\\n for (int i = 1; i <= N; ++i)\\n if (A[i] - K > i || A[i - 1] - A[i] > 2 * K) {\\n cout << 0;\\n return 0;\\n }\\n for (int i = N; i; --i) {\\n memset(tp, 0, sizeof(tp));\\n for (int j = 0; j <= 2 * K; ++j)\\n if (A[i] + j - K >= A[i - 1] - K && A[i] + j - K <= A[i - 1] + K) {\\n int pos = A[i] + j - K - A[i - 1] + K;\\n for (int l = 0; l <= N + 1; ++l)\\n if (dp[j][l])\\n tp[pos][l] = (tp[pos][l] + 1ll * dp[j][l] * (N + 1 - l)) % P;\\n }\\n memset(R, 0, sizeof(R));\\n for (int t = A[i] + K - 1; t >= A[i - 1] - K; --t) {\\n for (int j = N + 1; ~j; --j)\\n if (R[j]) R[j + 1] = sub(R[j + 1], R[j]);\\n if (t + 1 >= A[i] - K)\\n for (int j = 0; j <= N + 1; ++j)\\n R[j] = add(R[j], dp[t + 1 - A[i] + K][j]);\\n if (t <= A[i - 1] + K)\\n for (int j = 0; j <= N + 1; ++j)\\n tp[t - A[i - 1] + K][j + 1] = add(tp[t - A[i - 1] + K][j + 1], R[j]);\\n }\\n memcpy(dp, tp, sizeof(dp));\\n bool flg = 0;\\n for (int i = 0; i <= 2 * K; ++i)\\n for (int j = 0; j <= N + 1; ++j) flg |= dp[i][j] != 0;\\n if (!flg) {\\n cout << 0;\\n return 0;\\n }\\n }\\n int sum = 0;\\n for (int i = 0; i <= N + 1; ++i) sum = (sum + dp[2 * K][i]) % P;\\n cout << sum;\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"soltask\",\"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\":\"# cook your dish here\\nimport sys,math\\n# from itertools import groupby\\n# input = sys.stdin.buffer.readline\\n\\n\\n\\nfor _ in range(int(input())):\\n n,m =[int(c) for c in input().split()]\\n ans = 0\\n origarr=[int(c) for c in input().split()]\\n ar = [(origarr[i],i) for i in range(len(origarr))]\\n ar.sort(key = lambda x: (x[0],x[1]))\\n\\n ar = [i for j,i in ar]\\n # print(ar)\\n finalarr =[]\\n for i in range(n):\\n k = i*(m)\\n finalarr.append(ar[k:k+m])\\n\\n # for i in finalarr:\\n # print(i)\\n \\n for arr in finalarr:\\n for i in range(len(arr)):\\n for j in range(i+1,len(arr)):\\n if (arr[j] > arr[i]) and (origarr[arr[i]] != origarr[arr[j]]):\\n ans+=1\\n\\n # print(\\\"ans........\\\",ans) \\n print(ans)\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"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 \\ntemplate \\nbool chkmax(T &x, T y) {\\n return x < y ? x = y, true : false;\\n}\\ntemplate \\nbool chkmin(T &x, T y) {\\n return x > y ? x = y, true : false;\\n}\\nusing namespace std;\\nlong long ksm(long long a, long long b) {\\n if (!b) return 1;\\n long long ns = ksm(a, b >> 1);\\n ns = ns * ns % 1000000007;\\n if (b & 1) ns = ns * a % 1000000007;\\n return ns;\\n}\\nint n, m, k, N, deg[55], d[55][55], par[55];\\nvector> E, e, e2;\\nint findPar(int x) {\\n if (par[x] == x)\\n return x;\\n else\\n return par[x] = findPar(par[x]);\\n}\\nint matroid_intersection(int n, vector> w,\\n vector> w2) {\\n vector used(n);\\n for (auto &x : w) x[0] = -x[0];\\n for (auto &x : w2) x[0] = -x[0];\\n int m = w2.size();\\n auto find_path = [&]() {\\n vector> g(n + 2);\\n for (int j = 0; j < n; ++j)\\n if (used[j]) {\\n vector cdeg(N, 0);\\n used[j] = false;\\n for (int i = 0; i < N; i++) par[i] = i;\\n for (int i = 0; i < n; i++)\\n if (used[i]) {\\n int u = w[i][1], v = w[i][2];\\n cdeg[u]++, cdeg[v]++;\\n par[findPar(u)] = findPar(v);\\n }\\n for (int i = 0; i < m; i++) {\\n int u = w2[i][1], v = w2[i][2];\\n cdeg[u]++, cdeg[v]++;\\n par[findPar(u)] = findPar(v);\\n }\\n for (int i = 0; i < n; ++i)\\n if (!used[i] && i != j) {\\n int u = w[i][1], v = w[i][2];\\n cdeg[u] += 1;\\n cdeg[v] += 1;\\n bool w = true;\\n for (int r = 0; r < k; r++) w &= cdeg[r] <= deg[r];\\n cdeg[u] -= 1;\\n cdeg[v] -= 1;\\n if (w) g[i].push_back(j);\\n if (findPar(u) != findPar(v)) g[j].push_back(i);\\n }\\n used[j] = true;\\n }\\n vector cdeg(N, 0);\\n for (int i = 0; i < N; i++) par[i] = i;\\n for (int i = 0; i < n; i++)\\n if (used[i]) {\\n int u = w[i][1], v = w[i][2];\\n cdeg[u]++, cdeg[v]++;\\n par[findPar(u)] =...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in PYTHON3?\\nYouKn0wWho 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\":\"t=int(input())\\n\\nfor _ in range(t):\\n\\n n = int(input())\\n s = str(input())\\n array = [int(i) for i in s.split()]\\n\\n if (n%2)==0:\\n print(\\\"YES\\\")\\n continue\\n\\n #! At this point if the array isn't sorted -> PRINT YES\\n is_sorted = True\\n for i in range(1,n):\\n if (array[i]>array[i-1]):\\n continue\\n else:\\n is_sorted = False\\n break\\n \\n if (not is_sorted):\\n print(\\\"YES\\\")\\n continue\\n\\n #! Now we know that the array is sorted & odd in length therefore print NO\\n print(\\\"NO\\\")\",\"language\":\"python\",\"split\":\"test\",\"template\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"PYTHON3 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\":\"for _ in range(int(input())):\\n n = int(input())\\n a = list(map(int, input()))\\n b = list(map(int, input()))\\n a1 = a.count(1)\\n a0 = a.count(0)\\n b1 = b.count(1)\\n b0 = b.count(0)\\n ans = 0\\n if a1 != b1 or a0 != b0:\\n if a1 == 0:\\n print(-1)\\n continue\\n j = a.index(1)\\n for i in range(n):\\n if a[i] and b[i]:\\n j = i\\n for i in range(n):\\n if i != j:\\n a[i] = 1-a[i]\\n ans += 1\\n a1 = a.count(1)\\n a0 = a.count(0)\\n if a1 != b1 or a0 != b0:\\n print(-1)\\n continue\\n for i in range(n):\\n ans += (a[i] != b[i])\\n ans2 = float(\\\"inf\\\")\\n if 1 in a:\\n j = a.index(1)\\n ans2 = 1\\n for i in range(n):\\n if a[i] and b[i]:\\n j = i\\n for i in range(n):\\n if i != j:\\n a[i] = 1-a[i]\\n for i in range(n):\\n ans2 += (a[i] != b[i])\\n a1 = a.count(1)\\n a0 = a.count(0)\\n if a1 != b1 or a0 != b0:\\n ans2 = float(\\\"inf\\\")\\n print(min(ans, ans2))\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"Can you solve the below in CPP?\\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\":\"#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\":\"langsol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"CPP solution for \\\"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...\\\":\",\"targets\":\"#include \\nusing namespace std;\\nint a[100001];\\nvoid read(int &x) {\\n x = 0;\\n int f = 1;\\n char c = getchar();\\n while (!isdigit(c)) {\\n if (c == '-') f = -1;\\n c = getchar();\\n }\\n while (isdigit(c)) {\\n x = x * 10 + c - '0';\\n c = getchar();\\n }\\n x *= f;\\n}\\nint main() {\\n int n;\\n read(n);\\n for (int i = 1; i <= n; ++i) read(a[i]);\\n sort(a + 1, a + n + 1);\\n if (a[n] - a[1] <= 1) {\\n printf(\\\"%d\\\\n\\\", n);\\n for (int i = 1; i <= n; ++i) printf(\\\"%d \\\", a[i]);\\n return 0;\\n }\\n int s1 = 0, s2 = 0, s3 = 0;\\n for (int i = 1; i <= n; ++i) {\\n if (a[i] == a[1])\\n s1++;\\n else if (a[i] == a[n])\\n s3++;\\n else\\n s2++;\\n }\\n int t = min(s1, s3), k = s2 \\/ 2;\\n int m = a[1];\\n if (t > k) {\\n for (int i = 1; i <= t; ++i) a[i] = m + 1;\\n for (int i = 1; i <= t; ++i) a[n - i + 1] = m + 1;\\n printf(\\\"%d\\\\n\\\", n - t * 2);\\n for (int i = 1; i <= n; ++i) printf(\\\"%d \\\", a[i]);\\n } else {\\n for (int i = 1; i <= k; ++i) a[s1 + i * 2 - 1] = m, a[s1 + i * 2] = m + 2;\\n printf(\\\"%d\\\\n\\\", n - k * 2);\\n for (int i = 1; i <= n; ++i) printf(\\\"%d \\\", a[i]);\\n }\\n}\",\"language\":\"python\",\"split\":\"train\",\"template\":\"solfor\",\"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\":\"import java.io.IOException;\\nimport java.io.InputStreamReader;\\nimport java.io.BufferedReader;\\nimport java.util.StringTokenizer;\\nimport java.util.Arrays;\\nimport java.io.*;\\n\\npublic class A {\\n\\n public static void main(String[] args){\\n FastIO fio = new FastIO();\\n int T = fio.nextInt();\\n for (int tt = 0; tt < T; tt++) {\\n int n = fio.nextInt();\\n int[] a = fio.readArray(n);\\n int c = 0;\\n int i = 1;\\n boolean swapped1 = true;\\n boolean swapped2 = true;\\n while(swapped1 || swapped2) {\\n c++;\\n if(i % 2 == 1) {\\n swapped1 = false;\\n for (int j = 0; j < n - 2; j+=2) {\\n if(a[j] > a[j+1]) {\\n int t = a[j];\\n a[j] = a[j+1];\\n a[j+1] = t;\\n swapped1 = true;\\n }\\n }\\n } else {\\n swapped2 = false;\\n for (int j = 1; j < n - 1; j+=2) {\\n if(a[j] > a[j+1]) {\\n int t = a[j];\\n a[j] = a[j+1];\\n a[j+1] = t;\\n swapped2 = true;\\n }\\n }\\n }\\n i++;\\n }\\n c--;\\n fio.println(--c);\\n }\\n fio.close();\\n }\\n \\/**\\n * Fast I\\/O\\n * @source https:\\/\\/www.geeksforgeeks.org\\/fast-io-in-java-in-competitive-programming\\/\\n *\\/\\n static class FastIO extends PrintWriter { \\n BufferedReader br; \\n StringTokenizer st;\\n\\n public FastIO() { \\n super(new BufferedOutputStream(System.out)); \\n br = new BufferedReader(new InputStreamReader(System.in));\\n }\\n\\n String next() { \\n while (st == null || !st.hasMoreElements()) { \\n try {st = new StringTokenizer(br.readLine());}\\n catch (IOException e) {e.printStackTrace();}\\n }\\n return st.nextToken(); \\n } \\n\\n int nextInt() {return Integer.parseInt(next());}\\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\\n long nextLong() {return Long.parseLong(next());}\\n\\n long[] readLArray(int n) {\\n long[] a = new...\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"descsol\",\"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\\nUsing cpp can you solve the prior task?\",\"targets\":\"#include \\nusing namespace std;\\nint main() {\\n ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);\\n int t;\\n cin >> t;\\n while (t--) {\\n string s;\\n cin >> s;\\n string ans;\\n cin >> ans;\\n int val = 0;\\n char temp = 'a';\\n int pos = 0;\\n for (int i = 0; i < s.size(); i++) {\\n if (s[i] == ans[0]) {\\n pos = i + 1;\\n break;\\n }\\n }\\n for (int i = 1; i < ans.size(); i++) {\\n temp = ans[i];\\n for (int j = 0; j < s.size(); j++) {\\n if (s[j] == temp) {\\n val = val + abs(j + 1 - pos);\\n pos = j + 1;\\n break;\\n }\\n }\\n }\\n cout << val << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"priortask\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n" "{\"inputs\":\"JAVA solution for \\\"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\":\"\\/\\/\\/\\/solution at bottom \\nimport java.util.*;\\nimport java.lang.*;\\nimport java.io.*;\\nimport java.math.*;\\n\\n public class test\\n{\\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[][] tdiarr(int m , int n){\\n int[][] a = new int[m][n];\\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\\nThe above is tricky. Write me a correct solution in CPP.\",\"targets\":\"#include \\nusing namespace std;\\nvoid abhasg(long long int t) {\\n string num, x1, x2;\\n cin >> num;\\n long long int n = num.length(), i;\\n if (n == 1) {\\n cout << stoi(num) - 1 << endl;\\n return;\\n }\\n for (i = 0; i < n; i++) {\\n if (i % 2)\\n x1.push_back(num[i]);\\n else\\n x2.push_back(num[i]);\\n }\\n long long int n1 = stoi(x1), n2 = stoi(x2);\\n cout << (n1 + 1) * (n2 + 1) - 2 << endl;\\n}\\nsigned main() {\\n long long int t;\\n cin >> t;\\n while (t--) {\\n abhasg(t);\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"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 = 1e4 + 5;\\nint a[MAXN];\\nint dp[MAXN][2005];\\nbool check(int n, int len) {\\n for (int i = 0; i <= n; ++i) {\\n for (int j = 0; j <= len; ++j) {\\n if (i == 0)\\n dp[i][j] = 1;\\n else\\n dp[i][j] = 0;\\n }\\n }\\n for (int i = 1; i <= n; ++i) {\\n for (int j = 0; j <= len; ++j) {\\n if (dp[i - 1][j]) {\\n if (j + a[i] <= len) dp[i][j + a[i]] = 1;\\n if (j - a[i] >= 0) dp[i][j - a[i]] = 1;\\n }\\n }\\n }\\n for (int j = 0; j <= len; ++j)\\n if (dp[n][j]) return true;\\n return false;\\n}\\nint main() {\\n int n, t;\\n cin >> t;\\n while (t--) {\\n cin >> n;\\n for (int i = 1; i <= n; ++i) cin >> a[i];\\n int l = 0, r = 2000;\\n while (l < r) {\\n int mid = (l + r) >> 1;\\n if (check(n, mid))\\n r = mid;\\n else\\n l = mid + 1;\\n }\\n cout << r << endl;\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"test\",\"template\":\"solfor\",\"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 CPP.\",\"targets\":\"#include \\n#pragma GCC optimization(\\\"O3\\\")\\n#pragma GCC optimize(\\\"Ofast\\\")\\n#pragma GCC target(\\\"avx,avx2,fma\\\")\\n#pragma GCC target(\\\"sse4.2\\\")\\nusing namespace std;\\ntemplate \\nistream &operator>>(istream &in, vector &v) {\\n for (auto &i : v) cin >> i;\\n return in;\\n}\\ntemplate \\nostream &operator<<(ostream &out, vector &v) {\\n for (auto &i : v) cout << i << \\\" \\\";\\n return out;\\n}\\nvoid solve() {\\n long long int i, j, n, a, b, c, d, m, k, sum = 0, ans = 0, cnt = 0, r = 0,\\n e = 0, x = 0, y = 0;\\n string str, s1, om, s;\\n map mp, mp1;\\n set st;\\n cin >> n;\\n x = n \\/ 3;\\n y = n - (n) \\/ 3;\\n if (y % 2) y++;\\n y \\/= 2;\\n if (x + 2 * y == n)\\n cout << x << \\\" \\\" << y << \\\"\\\\n\\\";\\n else\\n cout << y << \\\" \\\" << x << \\\"\\\\n\\\";\\n}\\nint main() {\\n ios_base::sync_with_stdio(false);\\n cin.tie(NULL);\\n cout.tie(NULL);\\n ;\\n long long int tc;\\n cin >> tc;\\n while (tc--) {\\n solve();\\n }\\n return 0;\\n}\",\"language\":\"python\",\"split\":\"valid\",\"template\":\"abovesol\",\"dataset\":\"teven\\/code_contests\",\"config\":null}\n"