exec_outcome stringclasses 1
value | code_uid stringlengths 32 32 | file_name stringclasses 111
values | prob_desc_created_at stringlengths 10 10 | prob_desc_description stringlengths 63 3.8k | prob_desc_memory_limit stringclasses 18
values | source_code stringlengths 117 65.5k | lang_cluster stringclasses 1
value | prob_desc_sample_inputs stringlengths 2 802 | prob_desc_time_limit stringclasses 27
values | prob_desc_sample_outputs stringlengths 2 796 | prob_desc_notes stringlengths 4 3k ⌀ | lang stringclasses 5
values | prob_desc_input_from stringclasses 3
values | tags listlengths 0 11 | src_uid stringlengths 32 32 | prob_desc_input_spec stringlengths 28 2.37k ⌀ | difficulty int64 -1 3.5k ⌀ | prob_desc_output_spec stringlengths 17 1.47k ⌀ | prob_desc_output_to stringclasses 3
values | hidden_unit_tests stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
PASSED | 51c65389219b231cf24403101ee18b13 | train_002.jsonl | 1526574900 | You're given a tree with $$$n$$$ vertices.Your task is to determine the maximum possible number of edges that can be removed in such a way that all the remaining connected components will have even size. | 256 megabytes | import java.io.*;
import java.util.*;
public class TaskC
{
public static void main(String[] args)
{
new TaskC(System.in, System.out);
}
static class Solver implements Runnable
{
int n, ctr, answer;
int[] ans;
boolean[] poss;
List<Integer> leaves;
Set<Integer>[] adj;
// BufferedReader in;
InputRe... | Java | ["4\n2 4\n4 1\n3 1", "3\n1 2\n1 3", "10\n7 1\n8 4\n8 10\n4 7\n6 5\n9 3\n3 5\n2 10\n2 5", "2\n1 2"] | 1 second | ["1", "-1", "4", "0"] | NoteIn the first example you can remove the edge between vertices $$$1$$$ and $$$4$$$. The graph after that will have two connected components with two vertices in each.In the second example you can't remove edges in such a way that all components have even number of vertices, so the answer is $$$-1$$$. | Java 8 | standard input | [
"dp",
"greedy",
"graphs",
"dfs and similar",
"trees"
] | 711896281f4beff55a8826771eeccb81 | The first line contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) denoting the size of the tree. The next $$$n - 1$$$ lines contain two integers $$$u$$$, $$$v$$$ ($$$1 \le u, v \le n$$$) each, describing the vertices connected by the $$$i$$$-th edge. It's guaranteed that the given edges form a tree. | 1,500 | Output a single integer $$$k$$$ — the maximum number of edges that can be removed to leave all connected components with even size, or $$$-1$$$ if it is impossible to remove edges in order to satisfy this property. | standard output | |
PASSED | f571db1515da281fbe348ede3815ed74 | train_002.jsonl | 1526574900 | You're given a tree with $$$n$$$ vertices.Your task is to determine the maximum possible number of edges that can be removed in such a way that all the remaining connected components will have even size. | 256 megabytes | import java.io.*;
import java.util.*;
public class A {
static final boolean stdin = true;
static final String filename = "";
static FastScanner br;
static PrintWriter pw;
public static void main(String[] args) throws IOException {
if (stdin) {
br = new FastScanner();
pw = new PrintWriter(new OutputStre... | Java | ["4\n2 4\n4 1\n3 1", "3\n1 2\n1 3", "10\n7 1\n8 4\n8 10\n4 7\n6 5\n9 3\n3 5\n2 10\n2 5", "2\n1 2"] | 1 second | ["1", "-1", "4", "0"] | NoteIn the first example you can remove the edge between vertices $$$1$$$ and $$$4$$$. The graph after that will have two connected components with two vertices in each.In the second example you can't remove edges in such a way that all components have even number of vertices, so the answer is $$$-1$$$. | Java 8 | standard input | [
"dp",
"greedy",
"graphs",
"dfs and similar",
"trees"
] | 711896281f4beff55a8826771eeccb81 | The first line contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) denoting the size of the tree. The next $$$n - 1$$$ lines contain two integers $$$u$$$, $$$v$$$ ($$$1 \le u, v \le n$$$) each, describing the vertices connected by the $$$i$$$-th edge. It's guaranteed that the given edges form a tree. | 1,500 | Output a single integer $$$k$$$ — the maximum number of edges that can be removed to leave all connected components with even size, or $$$-1$$$ if it is impossible to remove edges in order to satisfy this property. | standard output | |
PASSED | 87f63a672e8b736513c8fedf795ebe60 | train_002.jsonl | 1526574900 | You're given a tree with $$$n$$$ vertices.Your task is to determine the maximum possible number of edges that can be removed in such a way that all the remaining connected components will have even size. | 256 megabytes | import java.io.*;
import java.util.*;
public class A {
static final boolean stdin = true;
static final String filename = "";
static FastScanner br;
static PrintWriter pw;
public static void main(String[] args) throws IOException {
if (stdin) {
br = new FastScanner();
pw = new PrintWriter(new OutputStre... | Java | ["4\n2 4\n4 1\n3 1", "3\n1 2\n1 3", "10\n7 1\n8 4\n8 10\n4 7\n6 5\n9 3\n3 5\n2 10\n2 5", "2\n1 2"] | 1 second | ["1", "-1", "4", "0"] | NoteIn the first example you can remove the edge between vertices $$$1$$$ and $$$4$$$. The graph after that will have two connected components with two vertices in each.In the second example you can't remove edges in such a way that all components have even number of vertices, so the answer is $$$-1$$$. | Java 8 | standard input | [
"dp",
"greedy",
"graphs",
"dfs and similar",
"trees"
] | 711896281f4beff55a8826771eeccb81 | The first line contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) denoting the size of the tree. The next $$$n - 1$$$ lines contain two integers $$$u$$$, $$$v$$$ ($$$1 \le u, v \le n$$$) each, describing the vertices connected by the $$$i$$$-th edge. It's guaranteed that the given edges form a tree. | 1,500 | Output a single integer $$$k$$$ — the maximum number of edges that can be removed to leave all connected components with even size, or $$$-1$$$ if it is impossible to remove edges in order to satisfy this property. | standard output | |
PASSED | 904437a1fc7603da4565038f38f4c282 | train_002.jsonl | 1526574900 | You're given a tree with $$$n$$$ vertices.Your task is to determine the maximum possible number of edges that can be removed in such a way that all the remaining connected components will have even size. | 256 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class C982 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseI... | Java | ["4\n2 4\n4 1\n3 1", "3\n1 2\n1 3", "10\n7 1\n8 4\n8 10\n4 7\n6 5\n9 3\n3 5\n2 10\n2 5", "2\n1 2"] | 1 second | ["1", "-1", "4", "0"] | NoteIn the first example you can remove the edge between vertices $$$1$$$ and $$$4$$$. The graph after that will have two connected components with two vertices in each.In the second example you can't remove edges in such a way that all components have even number of vertices, so the answer is $$$-1$$$. | Java 8 | standard input | [
"dp",
"greedy",
"graphs",
"dfs and similar",
"trees"
] | 711896281f4beff55a8826771eeccb81 | The first line contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) denoting the size of the tree. The next $$$n - 1$$$ lines contain two integers $$$u$$$, $$$v$$$ ($$$1 \le u, v \le n$$$) each, describing the vertices connected by the $$$i$$$-th edge. It's guaranteed that the given edges form a tree. | 1,500 | Output a single integer $$$k$$$ — the maximum number of edges that can be removed to leave all connected components with even size, or $$$-1$$$ if it is impossible to remove edges in order to satisfy this property. | standard output | |
PASSED | 19b7e3dd7dfe15ff7bef9c47f951f2e6 | train_002.jsonl | 1286002800 | A star map in Berland is a checked field n × m squares. In each square there is or there is not a star. The favourite constellation of all Berland's astronomers is the constellation of the Cross. This constellation can be formed by any 5 stars so, that for some integer x (radius of the constellation) the following is t... | 256 megabytes | import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class d32 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int r = in.nextInt(), c = in.nextInt();
boolean[][] map = new boolean[r][c];
int idx = in.nextInt();
for (int i = 0; i < r; i++... | Java | ["5 6 1\n....*.\n...***\n....*.\n..*...\n.***..", "5 6 2\n....*.\n...***\n....*.\n..*...\n.***..", "7 7 2\n...*...\n.......\n...*...\n*.***.*\n...*...\n.......\n...*..."] | 2 seconds | ["2 5\n1 5\n3 5\n2 4\n2 6", "-1", "4 4\n1 4\n7 4\n4 1\n4 7"] | null | Java 7 | standard input | [
"implementation"
] | f13be8bcb3291ffcc555a268f421bf3a | The first line contains three integers n, m and k (1 ≤ n, m ≤ 300, 1 ≤ k ≤ 3·107) — height and width of the map and index of the required constellation respectively. The upper-left corner has coordinates (1, 1), and the lower-right — (n, m). Then there follow n lines, m characters each — description of the map. j-th ch... | 1,600 | If the number of the constellations is less than k, output -1. Otherwise output 5 lines, two integers each — coordinates of the required constellation. Output the stars in the following order: central, upper, lower, left, right. | standard output | |
PASSED | 229b624f45de9893616a4ee31ed63b27 | train_002.jsonl | 1286002800 | A star map in Berland is a checked field n × m squares. In each square there is or there is not a star. The favourite constellation of all Berland's astronomers is the constellation of the Cross. This constellation can be formed by any 5 stars so, that for some integer x (radius of the constellation) the following is t... | 256 megabytes | import java.util.List;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.Collections;
import java.io.InputStream;
/**
* Built using CHelper... | Java | ["5 6 1\n....*.\n...***\n....*.\n..*...\n.***..", "5 6 2\n....*.\n...***\n....*.\n..*...\n.***..", "7 7 2\n...*...\n.......\n...*...\n*.***.*\n...*...\n.......\n...*..."] | 2 seconds | ["2 5\n1 5\n3 5\n2 4\n2 6", "-1", "4 4\n1 4\n7 4\n4 1\n4 7"] | null | Java 7 | standard input | [
"implementation"
] | f13be8bcb3291ffcc555a268f421bf3a | The first line contains three integers n, m and k (1 ≤ n, m ≤ 300, 1 ≤ k ≤ 3·107) — height and width of the map and index of the required constellation respectively. The upper-left corner has coordinates (1, 1), and the lower-right — (n, m). Then there follow n lines, m characters each — description of the map. j-th ch... | 1,600 | If the number of the constellations is less than k, output -1. Otherwise output 5 lines, two integers each — coordinates of the required constellation. Output the stars in the following order: central, upper, lower, left, right. | standard output | |
PASSED | 8e3187bedad01ac87f677f22f62ab084 | train_002.jsonl | 1286002800 | A star map in Berland is a checked field n × m squares. In each square there is or there is not a star. The favourite constellation of all Berland's astronomers is the constellation of the Cross. This constellation can be formed by any 5 stars so, that for some integer x (radius of the constellation) the following is t... | 256 megabytes | import java.util.*;
import java.io.*;
public class P32D {
static class Con implements Comparable<Con> {
final int r, c, d;
Con(int r, int c, int d) {
this.r=r;
this.c=c;
this.d=d;
}
public int compareTo(Con that) {
if (d != that.d)
return Integer.compare(d,that.d);
if (r != that.r)
retur... | Java | ["5 6 1\n....*.\n...***\n....*.\n..*...\n.***..", "5 6 2\n....*.\n...***\n....*.\n..*...\n.***..", "7 7 2\n...*...\n.......\n...*...\n*.***.*\n...*...\n.......\n...*..."] | 2 seconds | ["2 5\n1 5\n3 5\n2 4\n2 6", "-1", "4 4\n1 4\n7 4\n4 1\n4 7"] | null | Java 7 | standard input | [
"implementation"
] | f13be8bcb3291ffcc555a268f421bf3a | The first line contains three integers n, m and k (1 ≤ n, m ≤ 300, 1 ≤ k ≤ 3·107) — height and width of the map and index of the required constellation respectively. The upper-left corner has coordinates (1, 1), and the lower-right — (n, m). Then there follow n lines, m characters each — description of the map. j-th ch... | 1,600 | If the number of the constellations is less than k, output -1. Otherwise output 5 lines, two integers each — coordinates of the required constellation. Output the stars in the following order: central, upper, lower, left, right. | standard output | |
PASSED | 50cc6e3a30f965834390b79b630fd0cf | train_002.jsonl | 1286002800 | A star map in Berland is a checked field n × m squares. In each square there is or there is not a star. The favourite constellation of all Berland's astronomers is the constellation of the Cross. This constellation can be formed by any 5 stars so, that for some integer x (radius of the constellation) the following is t... | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.*;
public class D implements Runnable {
BufferedReader in;
PrintWriter out;
StringTokenizer st;
Random rnd;
boolean[][] field;
final int[] dx = {-1, 1, 0, 0};
final int[] dy = {0, 0, -1, 1};
boolean check(int n, int m, int x, int y, int r) {
if(!fi... | Java | ["5 6 1\n....*.\n...***\n....*.\n..*...\n.***..", "5 6 2\n....*.\n...***\n....*.\n..*...\n.***..", "7 7 2\n...*...\n.......\n...*...\n*.***.*\n...*...\n.......\n...*..."] | 2 seconds | ["2 5\n1 5\n3 5\n2 4\n2 6", "-1", "4 4\n1 4\n7 4\n4 1\n4 7"] | null | Java 7 | standard input | [
"implementation"
] | f13be8bcb3291ffcc555a268f421bf3a | The first line contains three integers n, m and k (1 ≤ n, m ≤ 300, 1 ≤ k ≤ 3·107) — height and width of the map and index of the required constellation respectively. The upper-left corner has coordinates (1, 1), and the lower-right — (n, m). Then there follow n lines, m characters each — description of the map. j-th ch... | 1,600 | If the number of the constellations is less than k, output -1. Otherwise output 5 lines, two integers each — coordinates of the required constellation. Output the stars in the following order: central, upper, lower, left, right. | standard output | |
PASSED | f2e3b8420fc78812c15e9a155fba5645 | train_002.jsonl | 1286002800 | A star map in Berland is a checked field n × m squares. In each square there is or there is not a star. The favourite constellation of all Berland's astronomers is the constellation of the Cross. This constellation can be formed by any 5 stars so, that for some integer x (radius of the constellation) the following is t... | 256 megabytes | import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitS... | Java | ["5 6 1\n....*.\n...***\n....*.\n..*...\n.***..", "5 6 2\n....*.\n...***\n....*.\n..*...\n.***..", "7 7 2\n...*...\n.......\n...*...\n*.***.*\n...*...\n.......\n...*..."] | 2 seconds | ["2 5\n1 5\n3 5\n2 4\n2 6", "-1", "4 4\n1 4\n7 4\n4 1\n4 7"] | null | Java 7 | standard input | [
"implementation"
] | f13be8bcb3291ffcc555a268f421bf3a | The first line contains three integers n, m and k (1 ≤ n, m ≤ 300, 1 ≤ k ≤ 3·107) — height and width of the map and index of the required constellation respectively. The upper-left corner has coordinates (1, 1), and the lower-right — (n, m). Then there follow n lines, m characters each — description of the map. j-th ch... | 1,600 | If the number of the constellations is less than k, output -1. Otherwise output 5 lines, two integers each — coordinates of the required constellation. Output the stars in the following order: central, upper, lower, left, right. | standard output | |
PASSED | b7f333a4440c974dc85b9c93c02d5da4 | train_002.jsonl | 1286002800 | A star map in Berland is a checked field n × m squares. In each square there is or there is not a star. The favourite constellation of all Berland's astronomers is the constellation of the Cross. This constellation can be formed by any 5 stars so, that for some integer x (radius of the constellation) the following is t... | 256 megabytes | import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;
import java.io.*;
public class Main {
void solve() {
int n = sc.nextInt();
int m = sc.nextInt();
int k = sc.nextInt();
char[][] table = new char[n][m];
for (int i = 0; i < n; i++) table[i] = sc.next().toCharArray();
i... | Java | ["5 6 1\n....*.\n...***\n....*.\n..*...\n.***..", "5 6 2\n....*.\n...***\n....*.\n..*...\n.***..", "7 7 2\n...*...\n.......\n...*...\n*.***.*\n...*...\n.......\n...*..."] | 2 seconds | ["2 5\n1 5\n3 5\n2 4\n2 6", "-1", "4 4\n1 4\n7 4\n4 1\n4 7"] | null | Java 7 | standard input | [
"implementation"
] | f13be8bcb3291ffcc555a268f421bf3a | The first line contains three integers n, m and k (1 ≤ n, m ≤ 300, 1 ≤ k ≤ 3·107) — height and width of the map and index of the required constellation respectively. The upper-left corner has coordinates (1, 1), and the lower-right — (n, m). Then there follow n lines, m characters each — description of the map. j-th ch... | 1,600 | If the number of the constellations is less than k, output -1. Otherwise output 5 lines, two integers each — coordinates of the required constellation. Output the stars in the following order: central, upper, lower, left, right. | standard output | |
PASSED | db843ebd5bb87a74c87fd6f667d441fc | train_002.jsonl | 1286002800 | A star map in Berland is a checked field n × m squares. In each square there is or there is not a star. The favourite constellation of all Berland's astronomers is the constellation of the Cross. This constellation can be formed by any 5 stars so, that for some integer x (radius of the constellation) the following is t... | 256 megabytes | import java.util.*;
import java.math.*;
public class Main{
static int n,m;
public static void main(String[] args){
final int INF=1<<30;
Scanner input=new Scanner(System.in);
int n=input.nextInt();
int m=input.nextInt();
int k=input.nextInt();
char[][] a=new char[n+5][m+5];
int[] count=new int[310];
f... | Java | ["5 6 1\n....*.\n...***\n....*.\n..*...\n.***..", "5 6 2\n....*.\n...***\n....*.\n..*...\n.***..", "7 7 2\n...*...\n.......\n...*...\n*.***.*\n...*...\n.......\n...*..."] | 2 seconds | ["2 5\n1 5\n3 5\n2 4\n2 6", "-1", "4 4\n1 4\n7 4\n4 1\n4 7"] | null | Java 7 | standard input | [
"implementation"
] | f13be8bcb3291ffcc555a268f421bf3a | The first line contains three integers n, m and k (1 ≤ n, m ≤ 300, 1 ≤ k ≤ 3·107) — height and width of the map and index of the required constellation respectively. The upper-left corner has coordinates (1, 1), and the lower-right — (n, m). Then there follow n lines, m characters each — description of the map. j-th ch... | 1,600 | If the number of the constellations is less than k, output -1. Otherwise output 5 lines, two integers each — coordinates of the required constellation. Output the stars in the following order: central, upper, lower, left, right. | standard output | |
PASSED | 98b17231b8777e048d4ba5e4ec7d88bd | train_002.jsonl | 1286002800 | A star map in Berland is a checked field n × m squares. In each square there is or there is not a star. The favourite constellation of all Berland's astronomers is the constellation of the Cross. This constellation can be formed by any 5 stars so, that for some integer x (radius of the constellation) the following is t... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main
{
static boolean[][] map;
static int n,m,k;
public static boolean check ( int x, int y )
{
return x>=0 && x<n && y>=0 && y<m && map[x][y];
}
public static void main ( String[] args ) throws IOException
{
Scanner in=new... | Java | ["5 6 1\n....*.\n...***\n....*.\n..*...\n.***..", "5 6 2\n....*.\n...***\n....*.\n..*...\n.***..", "7 7 2\n...*...\n.......\n...*...\n*.***.*\n...*...\n.......\n...*..."] | 2 seconds | ["2 5\n1 5\n3 5\n2 4\n2 6", "-1", "4 4\n1 4\n7 4\n4 1\n4 7"] | null | Java 7 | standard input | [
"implementation"
] | f13be8bcb3291ffcc555a268f421bf3a | The first line contains three integers n, m and k (1 ≤ n, m ≤ 300, 1 ≤ k ≤ 3·107) — height and width of the map and index of the required constellation respectively. The upper-left corner has coordinates (1, 1), and the lower-right — (n, m). Then there follow n lines, m characters each — description of the map. j-th ch... | 1,600 | If the number of the constellations is less than k, output -1. Otherwise output 5 lines, two integers each — coordinates of the required constellation. Output the stars in the following order: central, upper, lower, left, right. | standard output | |
PASSED | f6a1e6375681196b8f7be1dea13d0c81 | train_002.jsonl | 1577198100 | Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes.The exam consists of $$$n$$$ problems that can be solved in $$$T$$$ minutes. Thus, the exam begins at time $$$0$$$ and ends at time $$$T$$$. Petya can leave the exam at a... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class d {
public static void main(String[] args) throws IOException {
// Scanner s = new Scanner(System.in);
BufferedReader s = new BufferedReader(new InputStreamReader(Syste... | Java | ["10\n3 5 1 3\n0 0 1\n2 1 4\n2 5 2 3\n1 0\n3 2\n1 20 2 4\n0\n16\n6 20 2 5\n1 1 0 1 0 0\n0 8 2 9 11 6\n4 16 3 6\n1 0 1 1\n8 3 5 6\n6 20 3 6\n0 1 0 0 1 0\n20 11 3 20 16 17\n7 17 1 6\n1 1 0 1 0 0 0\n1 7 0 11 10 15 10\n6 17 2 6\n0 0 1 0 0 1\n7 6 3 7 10 12\n5 17 2 5\n1 1 1 1 0\n17 11 10 6 4\n1 1 1 2\n0\n1"] | 2 seconds | ["3\n2\n1\n0\n1\n4\n0\n1\n2\n1"] | null | Java 11 | standard input | [
"two pointers",
"sortings",
"greedy"
] | 6c165390c7f9fee059ef197ef40ae64f | The first line contains the integer $$$m$$$ ($$$1 \le m \le 10^4$$$) — the number of test cases in the test. The next lines contain a description of $$$m$$$ test cases. The first line of each test case contains four integers $$$n, T, a, b$$$ ($$$2 \le n \le 2\cdot10^5$$$, $$$1 \le T \le 10^9$$$, $$$1 \le a < b \le ... | 1,800 | Print the answers to $$$m$$$ test cases. For each set, print a single integer — maximal number of points that he can receive, before leaving the exam. | standard output | |
PASSED | 3b483b0d606acd38bd1a14c516e7c80a | train_002.jsonl | 1577198100 | Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes.The exam consists of $$$n$$$ problems that can be solved in $$$T$$$ minutes. Thus, the exam begins at time $$$0$$$ and ends at time $$$T$$$. Petya can leave the exam at a... | 256 megabytes | import java.io.*;
import java.util.*;
public class Solution {
static class problem implements Comparable<problem>{
int mandatoryAfter;
boolean easy;
public problem(boolean easy, int mandatoryAfter) {
this.easy = easy;
this.mandatoryAfter = mandatoryAfter;
}
public problem() {}
@Override
public int compareTo... | Java | ["10\n3 5 1 3\n0 0 1\n2 1 4\n2 5 2 3\n1 0\n3 2\n1 20 2 4\n0\n16\n6 20 2 5\n1 1 0 1 0 0\n0 8 2 9 11 6\n4 16 3 6\n1 0 1 1\n8 3 5 6\n6 20 3 6\n0 1 0 0 1 0\n20 11 3 20 16 17\n7 17 1 6\n1 1 0 1 0 0 0\n1 7 0 11 10 15 10\n6 17 2 6\n0 0 1 0 0 1\n7 6 3 7 10 12\n5 17 2 5\n1 1 1 1 0\n17 11 10 6 4\n1 1 1 2\n0\n1"] | 2 seconds | ["3\n2\n1\n0\n1\n4\n0\n1\n2\n1"] | null | Java 11 | standard input | [
"two pointers",
"sortings",
"greedy"
] | 6c165390c7f9fee059ef197ef40ae64f | The first line contains the integer $$$m$$$ ($$$1 \le m \le 10^4$$$) — the number of test cases in the test. The next lines contain a description of $$$m$$$ test cases. The first line of each test case contains four integers $$$n, T, a, b$$$ ($$$2 \le n \le 2\cdot10^5$$$, $$$1 \le T \le 10^9$$$, $$$1 \le a < b \le ... | 1,800 | Print the answers to $$$m$$$ test cases. For each set, print a single integer — maximal number of points that he can receive, before leaving the exam. | standard output | |
PASSED | 2059fbaa9495d75ee1b8919ea7f1d9b5 | train_002.jsonl | 1577198100 | Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes.The exam consists of $$$n$$$ problems that can be solved in $$$T$$$ minutes. Thus, the exam begins at time $$$0$$$ and ends at time $$$T$$$. Petya can leave the exam at a... | 256 megabytes | import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
import static java.lang.Math.*;
public class Main {
int[] parent;
void run() throws IOException {
int q = nextInt();
while (q-- > 0) {
int n = nextInt();
long t = nextLong();
long a = nex... | Java | ["10\n3 5 1 3\n0 0 1\n2 1 4\n2 5 2 3\n1 0\n3 2\n1 20 2 4\n0\n16\n6 20 2 5\n1 1 0 1 0 0\n0 8 2 9 11 6\n4 16 3 6\n1 0 1 1\n8 3 5 6\n6 20 3 6\n0 1 0 0 1 0\n20 11 3 20 16 17\n7 17 1 6\n1 1 0 1 0 0 0\n1 7 0 11 10 15 10\n6 17 2 6\n0 0 1 0 0 1\n7 6 3 7 10 12\n5 17 2 5\n1 1 1 1 0\n17 11 10 6 4\n1 1 1 2\n0\n1"] | 2 seconds | ["3\n2\n1\n0\n1\n4\n0\n1\n2\n1"] | null | Java 11 | standard input | [
"two pointers",
"sortings",
"greedy"
] | 6c165390c7f9fee059ef197ef40ae64f | The first line contains the integer $$$m$$$ ($$$1 \le m \le 10^4$$$) — the number of test cases in the test. The next lines contain a description of $$$m$$$ test cases. The first line of each test case contains four integers $$$n, T, a, b$$$ ($$$2 \le n \le 2\cdot10^5$$$, $$$1 \le T \le 10^9$$$, $$$1 \le a < b \le ... | 1,800 | Print the answers to $$$m$$$ test cases. For each set, print a single integer — maximal number of points that he can receive, before leaving the exam. | standard output | |
PASSED | 6d640eceb2ee58595f29f28797b2cf2f | train_002.jsonl | 1557671700 | $$$n$$$ boys and $$$m$$$ girls came to the party. Each boy presented each girl some integer number of sweets (possibly zero). All boys are numbered with integers from $$$1$$$ to $$$n$$$ and all girls are numbered with integers from $$$1$$$ to $$$m$$$. For all $$$1 \leq i \leq n$$$ the minimal number of sweets, which $$... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import ... | Java | ["3 2\n1 2 1\n3 4", "2 2\n0 1\n1 0", "2 3\n1 0\n1 1 2"] | 1 second | ["12", "-1", "4"] | NoteIn the first test, the minimal total number of sweets, which boys could have presented is equal to $$$12$$$. This can be possible, for example, if the first boy presented $$$1$$$ and $$$4$$$ sweets, the second boy presented $$$3$$$ and $$$2$$$ sweets and the third boy presented $$$1$$$ and $$$1$$$ sweets for the fi... | Java 8 | standard input | [
"implementation",
"greedy",
"math"
] | 4b4c7e7d9d5c45c8635b403bae997891 | The first line contains two integers $$$n$$$ and $$$m$$$, separated with space — the number of boys and girls, respectively ($$$2 \leq n, m \leq 100\,000$$$). The second line contains $$$n$$$ integers $$$b_1, \ldots, b_n$$$, separated by spaces — $$$b_i$$$ is equal to the minimal number of sweets, which $$$i$$$-th boy ... | 1,500 | If the described situation is impossible, print $$$-1$$$. In another case, print the minimal total number of sweets, which boys could have presented and all conditions could have satisfied. | standard output | |
PASSED | 0eea504548f9f859d4454eed98517cce | train_002.jsonl | 1557671700 | $$$n$$$ boys and $$$m$$$ girls came to the party. Each boy presented each girl some integer number of sweets (possibly zero). All boys are numbered with integers from $$$1$$$ to $$$n$$$ and all girls are numbered with integers from $$$1$$$ to $$$m$$$. For all $$$1 \leq i \leq n$$$ the minimal number of sweets, which $$... | 256 megabytes | import javafx.scene.layout.Priority;
import java.io.*;
import java.lang.reflect.Array;
import java.net.Inet4Address;
import java.util.*;
import java.lang.*;
import java.util.HashMap;
import java.util.PriorityQueue;
public class templ implements Runnable {
static class pair implements Comparable
{
int f;... | Java | ["3 2\n1 2 1\n3 4", "2 2\n0 1\n1 0", "2 3\n1 0\n1 1 2"] | 1 second | ["12", "-1", "4"] | NoteIn the first test, the minimal total number of sweets, which boys could have presented is equal to $$$12$$$. This can be possible, for example, if the first boy presented $$$1$$$ and $$$4$$$ sweets, the second boy presented $$$3$$$ and $$$2$$$ sweets and the third boy presented $$$1$$$ and $$$1$$$ sweets for the fi... | Java 8 | standard input | [
"implementation",
"greedy",
"math"
] | 4b4c7e7d9d5c45c8635b403bae997891 | The first line contains two integers $$$n$$$ and $$$m$$$, separated with space — the number of boys and girls, respectively ($$$2 \leq n, m \leq 100\,000$$$). The second line contains $$$n$$$ integers $$$b_1, \ldots, b_n$$$, separated by spaces — $$$b_i$$$ is equal to the minimal number of sweets, which $$$i$$$-th boy ... | 1,500 | If the described situation is impossible, print $$$-1$$$. In another case, print the minimal total number of sweets, which boys could have presented and all conditions could have satisfied. | standard output | |
PASSED | 76651804c81f87267b198898e37e9988 | train_002.jsonl | 1557671700 | $$$n$$$ boys and $$$m$$$ girls came to the party. Each boy presented each girl some integer number of sweets (possibly zero). All boys are numbered with integers from $$$1$$$ to $$$n$$$ and all girls are numbered with integers from $$$1$$$ to $$$m$$$. For all $$$1 \leq i \leq n$$$ the minimal number of sweets, which $$... | 256 megabytes | import java.io.*;
import java.text.*;
import java.util.*;
import java.math.*;
public class template {
public static void main(String[] args) throws Exception {
new template().run();
}
public void run() throws Exception {
FastScanner f = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
int n ... | Java | ["3 2\n1 2 1\n3 4", "2 2\n0 1\n1 0", "2 3\n1 0\n1 1 2"] | 1 second | ["12", "-1", "4"] | NoteIn the first test, the minimal total number of sweets, which boys could have presented is equal to $$$12$$$. This can be possible, for example, if the first boy presented $$$1$$$ and $$$4$$$ sweets, the second boy presented $$$3$$$ and $$$2$$$ sweets and the third boy presented $$$1$$$ and $$$1$$$ sweets for the fi... | Java 8 | standard input | [
"implementation",
"greedy",
"math"
] | 4b4c7e7d9d5c45c8635b403bae997891 | The first line contains two integers $$$n$$$ and $$$m$$$, separated with space — the number of boys and girls, respectively ($$$2 \leq n, m \leq 100\,000$$$). The second line contains $$$n$$$ integers $$$b_1, \ldots, b_n$$$, separated by spaces — $$$b_i$$$ is equal to the minimal number of sweets, which $$$i$$$-th boy ... | 1,500 | If the described situation is impossible, print $$$-1$$$. In another case, print the minimal total number of sweets, which boys could have presented and all conditions could have satisfied. | standard output | |
PASSED | d727a88371ea1614c4032d2489c21cf9 | train_002.jsonl | 1557671700 | $$$n$$$ boys and $$$m$$$ girls came to the party. Each boy presented each girl some integer number of sweets (possibly zero). All boys are numbered with integers from $$$1$$$ to $$$n$$$ and all girls are numbered with integers from $$$1$$$ to $$$m$$$. For all $$$1 \leq i \leq n$$$ the minimal number of sweets, which $$... | 256 megabytes | import java.io.*;
import java.nio.CharBuffer;
import java.util.NoSuchElementException;
public class P1159C {
public static void main(String[] args) {
SimpleScanner scanner = new SimpleScanner(System.in);
PrintWriter writer = new PrintWriter(System.out);
int n = scanner.nextInt();
... | Java | ["3 2\n1 2 1\n3 4", "2 2\n0 1\n1 0", "2 3\n1 0\n1 1 2"] | 1 second | ["12", "-1", "4"] | NoteIn the first test, the minimal total number of sweets, which boys could have presented is equal to $$$12$$$. This can be possible, for example, if the first boy presented $$$1$$$ and $$$4$$$ sweets, the second boy presented $$$3$$$ and $$$2$$$ sweets and the third boy presented $$$1$$$ and $$$1$$$ sweets for the fi... | Java 8 | standard input | [
"implementation",
"greedy",
"math"
] | 4b4c7e7d9d5c45c8635b403bae997891 | The first line contains two integers $$$n$$$ and $$$m$$$, separated with space — the number of boys and girls, respectively ($$$2 \leq n, m \leq 100\,000$$$). The second line contains $$$n$$$ integers $$$b_1, \ldots, b_n$$$, separated by spaces — $$$b_i$$$ is equal to the minimal number of sweets, which $$$i$$$-th boy ... | 1,500 | If the described situation is impossible, print $$$-1$$$. In another case, print the minimal total number of sweets, which boys could have presented and all conditions could have satisfied. | standard output | |
PASSED | 853586af82e9b6d58721b1757a45b306 | train_002.jsonl | 1557671700 | $$$n$$$ boys and $$$m$$$ girls came to the party. Each boy presented each girl some integer number of sweets (possibly zero). All boys are numbered with integers from $$$1$$$ to $$$n$$$ and all girls are numbered with integers from $$$1$$$ to $$$m$$$. For all $$$1 \leq i \leq n$$$ the minimal number of sweets, which $$... | 256 megabytes | import java.io.*;
import java.nio.CharBuffer;
import java.util.NoSuchElementException;
public class P1159C {
public static void main(String[] args) {
SimpleScanner scanner = new SimpleScanner(System.in);
PrintWriter writer = new PrintWriter(System.out);
int n = scanner.nextInt();
... | Java | ["3 2\n1 2 1\n3 4", "2 2\n0 1\n1 0", "2 3\n1 0\n1 1 2"] | 1 second | ["12", "-1", "4"] | NoteIn the first test, the minimal total number of sweets, which boys could have presented is equal to $$$12$$$. This can be possible, for example, if the first boy presented $$$1$$$ and $$$4$$$ sweets, the second boy presented $$$3$$$ and $$$2$$$ sweets and the third boy presented $$$1$$$ and $$$1$$$ sweets for the fi... | Java 8 | standard input | [
"implementation",
"greedy",
"math"
] | 4b4c7e7d9d5c45c8635b403bae997891 | The first line contains two integers $$$n$$$ and $$$m$$$, separated with space — the number of boys and girls, respectively ($$$2 \leq n, m \leq 100\,000$$$). The second line contains $$$n$$$ integers $$$b_1, \ldots, b_n$$$, separated by spaces — $$$b_i$$$ is equal to the minimal number of sweets, which $$$i$$$-th boy ... | 1,500 | If the described situation is impossible, print $$$-1$$$. In another case, print the minimal total number of sweets, which boys could have presented and all conditions could have satisfied. | standard output | |
PASSED | 30d89447c2be00be493d57062874ee7a | train_002.jsonl | 1577457600 | Santa has to send presents to the kids. He has a large stack of $$$n$$$ presents, numbered from $$$1$$$ to $$$n$$$; the topmost present has number $$$a_1$$$, the next present is $$$a_2$$$, and so on; the bottom present has number $$$a_n$$$. All numbers are distinct.Santa has a list of $$$m$$$ distinct presents he has t... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
public static PrintStream out = new PrintStream(System.out);;
public static void main(String[] args){
FastScanner sc = new FastScanner();
int t = sc.nextInt();
while(t-- > 0){
int n = sc.nextInt(); //# in stack
i... | Java | ["2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n3 1"] | 1 second | ["5\n8"] | null | Java 8 | standard input | [
"data structures",
"implementation"
] | ad434880e047992d2c77e0fe0ce0976f | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then the test cases follow, each represented by three lines. The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m \le n \le 10^5$$$) — the number of presents in the stack and the number of presents Santa want... | 1,400 | For each test case print one integer — the minimum number of seconds which Santa has to spend sending presents, if he reorders the presents optimally each time he returns them into the stack. | standard output | |
PASSED | c22a2c56c32bef3064544e6793499150 | train_002.jsonl | 1577457600 | Santa has to send presents to the kids. He has a large stack of $$$n$$$ presents, numbered from $$$1$$$ to $$$n$$$; the topmost present has number $$$a_1$$$, the next present is $$$a_2$$$, and so on; the bottom present has number $$$a_n$$$. All numbers are distinct.Santa has a list of $$$m$$$ distinct presents he has t... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
public static PrintStream out = new PrintStream(System.out);;
public static void main(String[] args){
FastScanner sc = new FastScanner();
int t = sc.nextInt();
while(t-- > 0){
int n = sc.nextInt(); //# in stack
i... | Java | ["2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n3 1"] | 1 second | ["5\n8"] | null | Java 8 | standard input | [
"data structures",
"implementation"
] | ad434880e047992d2c77e0fe0ce0976f | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then the test cases follow, each represented by three lines. The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m \le n \le 10^5$$$) — the number of presents in the stack and the number of presents Santa want... | 1,400 | For each test case print one integer — the minimum number of seconds which Santa has to spend sending presents, if he reorders the presents optimally each time he returns them into the stack. | standard output | |
PASSED | aa652fcc57b43e23c67ebb05a730b7e1 | train_002.jsonl | 1577457600 | Santa has to send presents to the kids. He has a large stack of $$$n$$$ presents, numbered from $$$1$$$ to $$$n$$$; the topmost present has number $$$a_1$$$, the next present is $$$a_2$$$, and so on; the bottom present has number $$$a_n$$$. All numbers are distinct.Santa has a list of $$$m$$$ distinct presents he has t... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args)throws IOException {
InputReader in = new InputReader(System.in);
PrintWriter out = new PrintWriter(System.out);
int t = in.nextInt();
int n,m;
int depth[]; int val,maxdepth;
int minval;
... | Java | ["2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n3 1"] | 1 second | ["5\n8"] | null | Java 8 | standard input | [
"data structures",
"implementation"
] | ad434880e047992d2c77e0fe0ce0976f | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then the test cases follow, each represented by three lines. The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m \le n \le 10^5$$$) — the number of presents in the stack and the number of presents Santa want... | 1,400 | For each test case print one integer — the minimum number of seconds which Santa has to spend sending presents, if he reorders the presents optimally each time he returns them into the stack. | standard output | |
PASSED | 00ce858e3b258c2657648000073d88e8 | train_002.jsonl | 1577457600 | Santa has to send presents to the kids. He has a large stack of $$$n$$$ presents, numbered from $$$1$$$ to $$$n$$$; the topmost present has number $$$a_1$$$, the next present is $$$a_2$$$, and so on; the bottom present has number $$$a_n$$$. All numbers are distinct.Santa has a list of $$$m$$$ distinct presents he has t... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args)throws IOException {
InputReader in = new InputReader(System.in);
PrintWriter out = new PrintWriter(System.out);
int t = in.nextInt();
int n,m;
int depth[]; int val,maxdepth;
int minval;
... | Java | ["2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n3 1"] | 1 second | ["5\n8"] | null | Java 8 | standard input | [
"data structures",
"implementation"
] | ad434880e047992d2c77e0fe0ce0976f | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then the test cases follow, each represented by three lines. The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m \le n \le 10^5$$$) — the number of presents in the stack and the number of presents Santa want... | 1,400 | For each test case print one integer — the minimum number of seconds which Santa has to spend sending presents, if he reorders the presents optimally each time he returns them into the stack. | standard output | |
PASSED | 5c1e982dfc1930971876abd681619277 | train_002.jsonl | 1577457600 | Santa has to send presents to the kids. He has a large stack of $$$n$$$ presents, numbered from $$$1$$$ to $$$n$$$; the topmost present has number $$$a_1$$$, the next present is $$$a_2$$$, and so on; the bottom present has number $$$a_n$$$. All numbers are distinct.Santa has a list of $$$m$$$ distinct presents he has t... | 256 megabytes | // Don't place your source in a package
import java.util.*;
import java.lang.*;
import java.io.*;
// Please name your class Main
public class Main {
public static void main (String[] args) throws java.lang.Exception {
Scanner in = new Scanner(System.in);
int T =in.nextInt();
for(int t=0;t<T;t++){
int n=in... | Java | ["2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n3 1"] | 1 second | ["5\n8"] | null | Java 8 | standard input | [
"data structures",
"implementation"
] | ad434880e047992d2c77e0fe0ce0976f | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then the test cases follow, each represented by three lines. The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m \le n \le 10^5$$$) — the number of presents in the stack and the number of presents Santa want... | 1,400 | For each test case print one integer — the minimum number of seconds which Santa has to spend sending presents, if he reorders the presents optimally each time he returns them into the stack. | standard output | |
PASSED | 138f14c952bde8aa59945d39f20ca2d2 | train_002.jsonl | 1577457600 | Santa has to send presents to the kids. He has a large stack of $$$n$$$ presents, numbered from $$$1$$$ to $$$n$$$; the topmost present has number $$$a_1$$$, the next present is $$$a_2$$$, and so on; the bottom present has number $$$a_n$$$. All numbers are distinct.Santa has a list of $$$m$$$ distinct presents he has t... | 256 megabytes | import java.util.*;
import java.text.DecimalFormat;
import java.io.*;
public class FedorNewGame {
public static void main(String[] args) throws Exception{
// TODO Auto-generated method stub
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int t=Integer.parseInt(br.readLine());
while (t>... | Java | ["2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n3 1"] | 1 second | ["5\n8"] | null | Java 8 | standard input | [
"data structures",
"implementation"
] | ad434880e047992d2c77e0fe0ce0976f | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then the test cases follow, each represented by three lines. The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m \le n \le 10^5$$$) — the number of presents in the stack and the number of presents Santa want... | 1,400 | For each test case print one integer — the minimum number of seconds which Santa has to spend sending presents, if he reorders the presents optimally each time he returns them into the stack. | standard output | |
PASSED | b9577875431668d2a3b85655563205ad | train_002.jsonl | 1577457600 | Santa has to send presents to the kids. He has a large stack of $$$n$$$ presents, numbered from $$$1$$$ to $$$n$$$; the topmost present has number $$$a_1$$$, the next present is $$$a_2$$$, and so on; the bottom present has number $$$a_n$$$. All numbers are distinct.Santa has a list of $$$m$$$ distinct presents he has t... | 256 megabytes | import java.io.*;
import java.util.*;
public class Sol {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.nextInt();
... | Java | ["2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n3 1"] | 1 second | ["5\n8"] | null | Java 8 | standard input | [
"data structures",
"implementation"
] | ad434880e047992d2c77e0fe0ce0976f | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then the test cases follow, each represented by three lines. The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m \le n \le 10^5$$$) — the number of presents in the stack and the number of presents Santa want... | 1,400 | For each test case print one integer — the minimum number of seconds which Santa has to spend sending presents, if he reorders the presents optimally each time he returns them into the stack. | standard output | |
PASSED | 084e4972dfdc2961c8c4b2569dcef6da | train_002.jsonl | 1577457600 | Santa has to send presents to the kids. He has a large stack of $$$n$$$ presents, numbered from $$$1$$$ to $$$n$$$; the topmost present has number $$$a_1$$$, the next present is $$$a_2$$$, and so on; the bottom present has number $$$a_n$$$. All numbers are distinct.Santa has a list of $$$m$$$ distinct presents he has t... | 256 megabytes |
import java.util.*;
public class StackofPresents {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
for (int i = 0; i < t; i++) {
int n = in.nextInt();
int m = in.nextInt();
int[] pos = new int[n + 1];
... | Java | ["2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n3 1"] | 1 second | ["5\n8"] | null | Java 8 | standard input | [
"data structures",
"implementation"
] | ad434880e047992d2c77e0fe0ce0976f | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then the test cases follow, each represented by three lines. The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m \le n \le 10^5$$$) — the number of presents in the stack and the number of presents Santa want... | 1,400 | For each test case print one integer — the minimum number of seconds which Santa has to spend sending presents, if he reorders the presents optimally each time he returns them into the stack. | standard output | |
PASSED | af4fc12d8658f39f06daae8da6af72af | train_002.jsonl | 1577457600 | Santa has to send presents to the kids. He has a large stack of $$$n$$$ presents, numbered from $$$1$$$ to $$$n$$$; the topmost present has number $$$a_1$$$, the next present is $$$a_2$$$, and so on; the bottom present has number $$$a_n$$$. All numbers are distinct.Santa has a list of $$$m$$$ distinct presents he has t... | 256 megabytes | import java.io.*;
import java.util.*;
/**
* Only By Abhi_Valani
*/
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
PrintWriter out = new PrintW... | Java | ["2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n3 1"] | 1 second | ["5\n8"] | null | Java 8 | standard input | [
"data structures",
"implementation"
] | ad434880e047992d2c77e0fe0ce0976f | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then the test cases follow, each represented by three lines. The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m \le n \le 10^5$$$) — the number of presents in the stack and the number of presents Santa want... | 1,400 | For each test case print one integer — the minimum number of seconds which Santa has to spend sending presents, if he reorders the presents optimally each time he returns them into the stack. | standard output | |
PASSED | dc6c508cbcd9c93392ea988aed4def02 | train_002.jsonl | 1577457600 | Santa has to send presents to the kids. He has a large stack of $$$n$$$ presents, numbered from $$$1$$$ to $$$n$$$; the topmost present has number $$$a_1$$$, the next present is $$$a_2$$$, and so on; the bottom present has number $$$a_n$$$. All numbers are distinct.Santa has a list of $$$m$$$ distinct presents he has t... | 256 megabytes | import java.io.*;
import java.util.*;
import java.util.regex.*;
public class vk18
{
public static void main(String[]stp) throws Exception
{
Scanner scan=new Scanner(System.in);
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String []s;
long q=Integer.parse... | Java | ["2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n3 1"] | 1 second | ["5\n8"] | null | Java 8 | standard input | [
"data structures",
"implementation"
] | ad434880e047992d2c77e0fe0ce0976f | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then the test cases follow, each represented by three lines. The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m \le n \le 10^5$$$) — the number of presents in the stack and the number of presents Santa want... | 1,400 | For each test case print one integer — the minimum number of seconds which Santa has to spend sending presents, if he reorders the presents optimally each time he returns them into the stack. | standard output | |
PASSED | 496377a70fd2398b665ee4b15bd5590e | train_002.jsonl | 1577457600 | Santa has to send presents to the kids. He has a large stack of $$$n$$$ presents, numbered from $$$1$$$ to $$$n$$$; the topmost present has number $$$a_1$$$, the next present is $$$a_2$$$, and so on; the bottom present has number $$$a_n$$$. All numbers are distinct.Santa has a list of $$$m$$$ distinct presents he has t... | 256 megabytes | //package codeforces;
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.stream.Collectors;
import... | Java | ["2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n3 1"] | 1 second | ["5\n8"] | null | Java 8 | standard input | [
"data structures",
"implementation"
] | ad434880e047992d2c77e0fe0ce0976f | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then the test cases follow, each represented by three lines. The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m \le n \le 10^5$$$) — the number of presents in the stack and the number of presents Santa want... | 1,400 | For each test case print one integer — the minimum number of seconds which Santa has to spend sending presents, if he reorders the presents optimally each time he returns them into the stack. | standard output | |
PASSED | 6420ff063cdb8f8779bf086e3dfb6459 | train_002.jsonl | 1577457600 | Santa has to send presents to the kids. He has a large stack of $$$n$$$ presents, numbered from $$$1$$$ to $$$n$$$; the topmost present has number $$$a_1$$$, the next present is $$$a_2$$$, and so on; the bottom present has number $$$a_n$$$. All numbers are distinct.Santa has a list of $$$m$$$ distinct presents he has t... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
public class StackPresent {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStr... | Java | ["2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n3 1"] | 1 second | ["5\n8"] | null | Java 8 | standard input | [
"data structures",
"implementation"
] | ad434880e047992d2c77e0fe0ce0976f | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then the test cases follow, each represented by three lines. The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m \le n \le 10^5$$$) — the number of presents in the stack and the number of presents Santa want... | 1,400 | For each test case print one integer — the minimum number of seconds which Santa has to spend sending presents, if he reorders the presents optimally each time he returns them into the stack. | standard output | |
PASSED | 317be615aa968a67eaad05a41347658f | train_002.jsonl | 1577457600 | Santa has to send presents to the kids. He has a large stack of $$$n$$$ presents, numbered from $$$1$$$ to $$$n$$$; the topmost present has number $$$a_1$$$, the next present is $$$a_2$$$, and so on; the bottom present has number $$$a_n$$$. All numbers are distinct.Santa has a list of $$$m$$$ distinct presents he has t... | 256 megabytes | import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0)
{
int n=sc.nextInt();
int m=sc.nextInt();
int[] arr=new int[n];
int[] brr=new int[m];
HashSet<Integer> set=new HashSet();
for(int ... | Java | ["2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n3 1"] | 1 second | ["5\n8"] | null | Java 8 | standard input | [
"data structures",
"implementation"
] | ad434880e047992d2c77e0fe0ce0976f | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then the test cases follow, each represented by three lines. The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m \le n \le 10^5$$$) — the number of presents in the stack and the number of presents Santa want... | 1,400 | For each test case print one integer — the minimum number of seconds which Santa has to spend sending presents, if he reorders the presents optimally each time he returns them into the stack. | standard output | |
PASSED | 53e76371685b169e7c93676fd5e31ae3 | train_002.jsonl | 1577457600 | Santa has to send presents to the kids. He has a large stack of $$$n$$$ presents, numbered from $$$1$$$ to $$$n$$$; the topmost present has number $$$a_1$$$, the next present is $$$a_2$$$, and so on; the bottom present has number $$$a_n$$$. All numbers are distinct.Santa has a list of $$$m$$$ distinct presents he has t... | 256 megabytes | import java.util.*; import java.io.*;
public class Main{
public static void main(String[] args) throws Exception{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer stt;
int t=Integer.parseInt(br.readLine());
for(int i=0; i<t; i++){
st... | Java | ["2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n3 1"] | 1 second | ["5\n8"] | null | Java 8 | standard input | [
"data structures",
"implementation"
] | ad434880e047992d2c77e0fe0ce0976f | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then the test cases follow, each represented by three lines. The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m \le n \le 10^5$$$) — the number of presents in the stack and the number of presents Santa want... | 1,400 | For each test case print one integer — the minimum number of seconds which Santa has to spend sending presents, if he reorders the presents optimally each time he returns them into the stack. | standard output | |
PASSED | d33c13ac71b80312e761e76439367a87 | train_002.jsonl | 1577457600 | Santa has to send presents to the kids. He has a large stack of $$$n$$$ presents, numbered from $$$1$$$ to $$$n$$$; the topmost present has number $$$a_1$$$, the next present is $$$a_2$$$, and so on; the bottom present has number $$$a_n$$$. All numbers are distinct.Santa has a list of $$$m$$$ distinct presents he has t... | 256 megabytes | import java.util.*; import java.io.*;
public class Main{
public static void main(String[] args) throws Exception{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer stt;
int t=Integer.parseInt(br.readLine());
for(int i=0; i<t; i++){
Ha... | Java | ["2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n3 1"] | 1 second | ["5\n8"] | null | Java 8 | standard input | [
"data structures",
"implementation"
] | ad434880e047992d2c77e0fe0ce0976f | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then the test cases follow, each represented by three lines. The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m \le n \le 10^5$$$) — the number of presents in the stack and the number of presents Santa want... | 1,400 | For each test case print one integer — the minimum number of seconds which Santa has to spend sending presents, if he reorders the presents optimally each time he returns them into the stack. | standard output | |
PASSED | 4ea0c950756aeb325cc74fb3cb8c62ef | train_002.jsonl | 1577457600 | Santa has to send presents to the kids. He has a large stack of $$$n$$$ presents, numbered from $$$1$$$ to $$$n$$$; the topmost present has number $$$a_1$$$, the next present is $$$a_2$$$, and so on; the bottom present has number $$$a_n$$$. All numbers are distinct.Santa has a list of $$$m$$$ distinct presents he has t... | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
import static java.lang.Math.*;
public class MakingString implements Runnable
{
static class InputReader
{
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
pri... | Java | ["2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n3 1"] | 1 second | ["5\n8"] | null | Java 8 | standard input | [
"data structures",
"implementation"
] | ad434880e047992d2c77e0fe0ce0976f | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then the test cases follow, each represented by three lines. The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m \le n \le 10^5$$$) — the number of presents in the stack and the number of presents Santa want... | 1,400 | For each test case print one integer — the minimum number of seconds which Santa has to spend sending presents, if he reorders the presents optimally each time he returns them into the stack. | standard output | |
PASSED | 91e9f171116c7f4436ce4e5adea64451 | train_002.jsonl | 1577457600 | Santa has to send presents to the kids. He has a large stack of $$$n$$$ presents, numbered from $$$1$$$ to $$$n$$$; the topmost present has number $$$a_1$$$, the next present is $$$a_2$$$, and so on; the bottom present has number $$$a_n$$$. All numbers are distinct.Santa has a list of $$$m$$$ distinct presents he has t... | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
import static java.lang.Math.*;
public class MakingString implements Runnable
{
static class InputReader
{
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
pri... | Java | ["2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n3 1"] | 1 second | ["5\n8"] | null | Java 8 | standard input | [
"data structures",
"implementation"
] | ad434880e047992d2c77e0fe0ce0976f | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then the test cases follow, each represented by three lines. The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m \le n \le 10^5$$$) — the number of presents in the stack and the number of presents Santa want... | 1,400 | For each test case print one integer — the minimum number of seconds which Santa has to spend sending presents, if he reorders the presents optimally each time he returns them into the stack. | standard output | |
PASSED | 49ddce20aa3920f711a11808a0042b00 | train_002.jsonl | 1577457600 | Santa has to send presents to the kids. He has a large stack of $$$n$$$ presents, numbered from $$$1$$$ to $$$n$$$; the topmost present has number $$$a_1$$$, the next present is $$$a_2$$$, and so on; the bottom present has number $$$a_n$$$. All numbers are distinct.Santa has a list of $$$m$$$ distinct presents he has t... | 256 megabytes | import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
public static void main(String sp[])throws IOException{
FastReader sc = new FastReader();
int t = sc.nextInt();
while(t-->0){
int n = sc.nextInt(... | Java | ["2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n3 1"] | 1 second | ["5\n8"] | null | Java 8 | standard input | [
"data structures",
"implementation"
] | ad434880e047992d2c77e0fe0ce0976f | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then the test cases follow, each represented by three lines. The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m \le n \le 10^5$$$) — the number of presents in the stack and the number of presents Santa want... | 1,400 | For each test case print one integer — the minimum number of seconds which Santa has to spend sending presents, if he reorders the presents optimally each time he returns them into the stack. | standard output | |
PASSED | 7d99675228b9afd3b5e10d575b06548e | train_002.jsonl | 1577457600 | Santa has to send presents to the kids. He has a large stack of $$$n$$$ presents, numbered from $$$1$$$ to $$$n$$$; the topmost present has number $$$a_1$$$, the next present is $$$a_2$$$, and so on; the bottom present has number $$$a_n$$$. All numbers are distinct.Santa has a list of $$$m$$$ distinct presents he has t... | 256 megabytes | //package com.company;
import java.io.*;
import java.util.*;
import java.lang.*;
public class Main{
public static class FastReader {
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
private SpaceCharFilter filter;
... | Java | ["2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n3 1"] | 1 second | ["5\n8"] | null | Java 8 | standard input | [
"data structures",
"implementation"
] | ad434880e047992d2c77e0fe0ce0976f | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then the test cases follow, each represented by three lines. The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m \le n \le 10^5$$$) — the number of presents in the stack and the number of presents Santa want... | 1,400 | For each test case print one integer — the minimum number of seconds which Santa has to spend sending presents, if he reorders the presents optimally each time he returns them into the stack. | standard output | |
PASSED | cdf1e53bf15a198544f6d5e2d47f0478 | train_002.jsonl | 1577457600 | Santa has to send presents to the kids. He has a large stack of $$$n$$$ presents, numbered from $$$1$$$ to $$$n$$$; the topmost present has number $$$a_1$$$, the next present is $$$a_2$$$, and so on; the bottom present has number $$$a_n$$$. All numbers are distinct.Santa has a list of $$$m$$$ distinct presents he has t... | 256 megabytes | import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
/**
* Pick questions that you love and solve them with love, try to get AC in one
* go with cleanest code Just one thing to keep in mind th... | Java | ["2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n3 1"] | 1 second | ["5\n8"] | null | Java 8 | standard input | [
"data structures",
"implementation"
] | ad434880e047992d2c77e0fe0ce0976f | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then the test cases follow, each represented by three lines. The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m \le n \le 10^5$$$) — the number of presents in the stack and the number of presents Santa want... | 1,400 | For each test case print one integer — the minimum number of seconds which Santa has to spend sending presents, if he reorders the presents optimally each time he returns them into the stack. | standard output | |
PASSED | e3621690911a4f4a449029e3f986097f | train_002.jsonl | 1577457600 | Santa has to send presents to the kids. He has a large stack of $$$n$$$ presents, numbered from $$$1$$$ to $$$n$$$; the topmost present has number $$$a_1$$$, the next present is $$$a_2$$$, and so on; the bottom present has number $$$a_n$$$. All numbers are distinct.Santa has a list of $$$m$$$ distinct presents he has t... | 256 megabytes | import java.util.*;
import java.io.*;
import java.math.*;
public class A
{
static FastReader sc=new FastReader();
public static void main(String[] args)
{
//StringBuffer sb=new StringBuffer("");
int ttt=1;
ttt =i();
outer :while (ttt-- > 0)
{
... | Java | ["2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n3 1"] | 1 second | ["5\n8"] | null | Java 8 | standard input | [
"data structures",
"implementation"
] | ad434880e047992d2c77e0fe0ce0976f | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then the test cases follow, each represented by three lines. The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m \le n \le 10^5$$$) — the number of presents in the stack and the number of presents Santa want... | 1,400 | For each test case print one integer — the minimum number of seconds which Santa has to spend sending presents, if he reorders the presents optimally each time he returns them into the stack. | standard output | |
PASSED | 8a84e1b7b5afae27260e356c38facdba | train_002.jsonl | 1577457600 | Santa has to send presents to the kids. He has a large stack of $$$n$$$ presents, numbered from $$$1$$$ to $$$n$$$; the topmost present has number $$$a_1$$$, the next present is $$$a_2$$$, and so on; the bottom present has number $$$a_n$$$. All numbers are distinct.Santa has a list of $$$m$$$ distinct presents he has t... | 256 megabytes | import java.util.*;
import java.io.*;
public class C {
public static void main(String[] args) {
FastScanner sc = new FastScanner();
int T = sc.nextInt();
for(int t = 0; t < T; t++) {
int n = sc.nextInt();
int m = sc.nextInt();
int[] arr = new int[n];
long[] pos = new long[n];
for(int i = 0; i < n... | Java | ["2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n3 1"] | 1 second | ["5\n8"] | null | Java 8 | standard input | [
"data structures",
"implementation"
] | ad434880e047992d2c77e0fe0ce0976f | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then the test cases follow, each represented by three lines. The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m \le n \le 10^5$$$) — the number of presents in the stack and the number of presents Santa want... | 1,400 | For each test case print one integer — the minimum number of seconds which Santa has to spend sending presents, if he reorders the presents optimally each time he returns them into the stack. | standard output | |
PASSED | d1c9cff48c7c8d490402e69f96fe923b | train_002.jsonl | 1577457600 | Santa has to send presents to the kids. He has a large stack of $$$n$$$ presents, numbered from $$$1$$$ to $$$n$$$; the topmost present has number $$$a_1$$$, the next present is $$$a_2$$$, and so on; the bottom present has number $$$a_n$$$. All numbers are distinct.Santa has a list of $$$m$$$ distinct presents he has t... | 256 megabytes | import java.io.*;
import java.util.*;
import java.util.concurrent.ArrayBlockingQueue;
import java.lang.*;
import java.math.*;
import java.text.DecimalFormat;
import java.lang.reflect.Array;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
... | Java | ["2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n3 1"] | 1 second | ["5\n8"] | null | Java 8 | standard input | [
"data structures",
"implementation"
] | ad434880e047992d2c77e0fe0ce0976f | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then the test cases follow, each represented by three lines. The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m \le n \le 10^5$$$) — the number of presents in the stack and the number of presents Santa want... | 1,400 | For each test case print one integer — the minimum number of seconds which Santa has to spend sending presents, if he reorders the presents optimally each time he returns them into the stack. | standard output | |
PASSED | 66bb803418885ceb9200c758085ed850 | train_002.jsonl | 1577457600 | Santa has to send presents to the kids. He has a large stack of $$$n$$$ presents, numbered from $$$1$$$ to $$$n$$$; the topmost present has number $$$a_1$$$, the next present is $$$a_2$$$, and so on; the bottom present has number $$$a_n$$$. All numbers are distinct.Santa has a list of $$$m$$$ distinct presents he has t... | 256 megabytes | import java.util.*;
public class CodeForces {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
long t = scanner.nextLong();
while ((t-- != 0)) {
long n = scanner.nextLong();
long m = scanner.nextLong();
Map<Long, Long> m... | Java | ["2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n3 1"] | 1 second | ["5\n8"] | null | Java 8 | standard input | [
"data structures",
"implementation"
] | ad434880e047992d2c77e0fe0ce0976f | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then the test cases follow, each represented by three lines. The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m \le n \le 10^5$$$) — the number of presents in the stack and the number of presents Santa want... | 1,400 | For each test case print one integer — the minimum number of seconds which Santa has to spend sending presents, if he reorders the presents optimally each time he returns them into the stack. | standard output | |
PASSED | 4a31d5cbdb5d32f3dd77b16bb73ecf93 | train_002.jsonl | 1577457600 | Santa has to send presents to the kids. He has a large stack of $$$n$$$ presents, numbered from $$$1$$$ to $$$n$$$; the topmost present has number $$$a_1$$$, the next present is $$$a_2$$$, and so on; the bottom present has number $$$a_n$$$. All numbers are distinct.Santa has a list of $$$m$$$ distinct presents he has t... | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
public class A implements Runnable {
public void run() {
InputReader sc = new InputReader(System.in);
PrintWriter out = new PrintWriter(System.out);
int t=sc.nextInt();
while(t--!=0)
{
int n=sc.ne... | Java | ["2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n3 1"] | 1 second | ["5\n8"] | null | Java 8 | standard input | [
"data structures",
"implementation"
] | ad434880e047992d2c77e0fe0ce0976f | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then the test cases follow, each represented by three lines. The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m \le n \le 10^5$$$) — the number of presents in the stack and the number of presents Santa want... | 1,400 | For each test case print one integer — the minimum number of seconds which Santa has to spend sending presents, if he reorders the presents optimally each time he returns them into the stack. | standard output | |
PASSED | 915db44d8d7a578b805bf461ced153a2 | train_002.jsonl | 1577457600 | Santa has to send presents to the kids. He has a large stack of $$$n$$$ presents, numbered from $$$1$$$ to $$$n$$$; the topmost present has number $$$a_1$$$, the next present is $$$a_2$$$, and so on; the bottom present has number $$$a_n$$$. All numbers are distinct.Santa has a list of $$$m$$$ distinct presents he has t... | 256 megabytes | import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.InputMismatchException;
public class A {
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
InputReader s = new Inpu... | Java | ["2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n3 1"] | 1 second | ["5\n8"] | null | Java 8 | standard input | [
"data structures",
"implementation"
] | ad434880e047992d2c77e0fe0ce0976f | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then the test cases follow, each represented by three lines. The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m \le n \le 10^5$$$) — the number of presents in the stack and the number of presents Santa want... | 1,400 | For each test case print one integer — the minimum number of seconds which Santa has to spend sending presents, if he reorders the presents optimally each time he returns them into the stack. | standard output | |
PASSED | 78e260170716570628792963034afe99 | train_002.jsonl | 1577457600 | Santa has to send presents to the kids. He has a large stack of $$$n$$$ presents, numbered from $$$1$$$ to $$$n$$$; the topmost present has number $$$a_1$$$, the next present is $$$a_2$$$, and so on; the bottom present has number $$$a_n$$$. All numbers are distinct.Santa has a list of $$$m$$$ distinct presents he has t... | 256 megabytes | import java.util.*;
import java.io.*;;
public class E {
static ArrayList<Integer> primes; // generated by sieve
/*
* 1. Generating a list of prime factors of N
*/
static ArrayList<Long> primeFactors(long N) // O(sqrt(N) / ln sqrt(N))
{
ArrayList<Long> factors = new ArrayList<Long>(); // take abs(N) in case... | Java | ["2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n3 1"] | 1 second | ["5\n8"] | null | Java 8 | standard input | [
"data structures",
"implementation"
] | ad434880e047992d2c77e0fe0ce0976f | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then the test cases follow, each represented by three lines. The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m \le n \le 10^5$$$) — the number of presents in the stack and the number of presents Santa want... | 1,400 | For each test case print one integer — the minimum number of seconds which Santa has to spend sending presents, if he reorders the presents optimally each time he returns them into the stack. | standard output | |
PASSED | 09e9d8128ce7ac477891abfee8535220 | train_002.jsonl | 1577457600 | Santa has to send presents to the kids. He has a large stack of $$$n$$$ presents, numbered from $$$1$$$ to $$$n$$$; the topmost present has number $$$a_1$$$, the next present is $$$a_2$$$, and so on; the bottom present has number $$$a_n$$$. All numbers are distinct.Santa has a list of $$$m$$$ distinct presents he has t... | 256 megabytes | import java.util.*;
public class CF_1279_C {
public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0) {
int n=sc.nextInt();
int m=sc.nextInt();
int arr[]=new int[n];
int brr[]=new int[m];
... | Java | ["2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n3 1"] | 1 second | ["5\n8"] | null | Java 8 | standard input | [
"data structures",
"implementation"
] | ad434880e047992d2c77e0fe0ce0976f | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then the test cases follow, each represented by three lines. The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m \le n \le 10^5$$$) — the number of presents in the stack and the number of presents Santa want... | 1,400 | For each test case print one integer — the minimum number of seconds which Santa has to spend sending presents, if he reorders the presents optimally each time he returns them into the stack. | standard output | |
PASSED | 4d8a9a0dc0409f2851b0194bc31be426 | train_002.jsonl | 1577457600 | Santa has to send presents to the kids. He has a large stack of $$$n$$$ presents, numbered from $$$1$$$ to $$$n$$$; the topmost present has number $$$a_1$$$, the next present is $$$a_2$$$, and so on; the bottom present has number $$$a_n$$$. All numbers are distinct.Santa has a list of $$$m$$$ distinct presents he has t... | 256 megabytes | //package com.company;
import java.util.*;
public class Main {
static long solve(int[] a, int[] b) {
HashMap<Integer, Integer> positions = new HashMap<>();
for (int i = 0; i < a.length; i++) {
positions.put(a[i], i);
}
long result = 0;
int sent = 0;
in... | Java | ["2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n3 1"] | 1 second | ["5\n8"] | null | Java 8 | standard input | [
"data structures",
"implementation"
] | ad434880e047992d2c77e0fe0ce0976f | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then the test cases follow, each represented by three lines. The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m \le n \le 10^5$$$) — the number of presents in the stack and the number of presents Santa want... | 1,400 | For each test case print one integer — the minimum number of seconds which Santa has to spend sending presents, if he reorders the presents optimally each time he returns them into the stack. | standard output | |
PASSED | 75d147c60b20abb2eba7cc44f5eb172f | train_002.jsonl | 1577457600 | Santa has to send presents to the kids. He has a large stack of $$$n$$$ presents, numbered from $$$1$$$ to $$$n$$$; the topmost present has number $$$a_1$$$, the next present is $$$a_2$$$, and so on; the bottom present has number $$$a_n$$$. All numbers are distinct.Santa has a list of $$$m$$$ distinct presents he has t... | 256 megabytes | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Stream;
/**
* @author madi.sagimbeko... | Java | ["2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n3 1"] | 1 second | ["5\n8"] | null | Java 8 | standard input | [
"data structures",
"implementation"
] | ad434880e047992d2c77e0fe0ce0976f | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then the test cases follow, each represented by three lines. The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m \le n \le 10^5$$$) — the number of presents in the stack and the number of presents Santa want... | 1,400 | For each test case print one integer — the minimum number of seconds which Santa has to spend sending presents, if he reorders the presents optimally each time he returns them into the stack. | standard output | |
PASSED | cc70a58a998845580b004f697cab0cd9 | train_002.jsonl | 1577457600 | Santa has to send presents to the kids. He has a large stack of $$$n$$$ presents, numbered from $$$1$$$ to $$$n$$$; the topmost present has number $$$a_1$$$, the next present is $$$a_2$$$, and so on; the bottom present has number $$$a_n$$$. All numbers are distinct.Santa has a list of $$$m$$$ distinct presents he has t... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Comparator;
import java.util.Objects;
import java.util.StringTokenizer;
import java.util.TreeSet;
import java.util.function.B... | Java | ["2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n3 1"] | 1 second | ["5\n8"] | null | Java 8 | standard input | [
"data structures",
"implementation"
] | ad434880e047992d2c77e0fe0ce0976f | The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then the test cases follow, each represented by three lines. The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m \le n \le 10^5$$$) — the number of presents in the stack and the number of presents Santa want... | 1,400 | For each test case print one integer — the minimum number of seconds which Santa has to spend sending presents, if he reorders the presents optimally each time he returns them into the stack. | standard output | |
PASSED | f32d8edca030ba7075773bce7c9a36b4 | train_002.jsonl | 1453388400 | There are n pearls in a row. Let's enumerate them with integers from 1 to n from the left to the right. The pearl number i has the type ai.Let's call a sequence of consecutive pearls a segment. Let's call a segment good if it contains two pearls of the same type.Split the row of the pearls to the maximal number of good... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
/**
* Created by alex on 2/1/16.
* problem found at: http://codeforces.com/contest/620/problem/C
*/
public class PearlsInARow {
public static void main(String[] args... | Java | ["5\n1 2 3 4 1", "5\n1 2 3 4 5", "7\n1 2 1 3 1 2 1"] | 2 seconds | ["1\n1 5", "-1", "2\n1 3\n4 7"] | null | Java 8 | standard input | [
"greedy"
] | 4cacec219e4577b255ddf6d39d308e10 | The first line contains integer n (1 ≤ n ≤ 3·105) — the number of pearls in a row. The second line contains n integers ai (1 ≤ ai ≤ 109) – the type of the i-th pearl. | 1,500 | On the first line print integer k — the maximal number of segments in a partition of the row. Each of the next k lines should contain two integers lj, rj (1 ≤ lj ≤ rj ≤ n) — the number of the leftmost and the rightmost pearls in the j-th segment. Note you should print the correct partition of the row of the pearls, so ... | standard output | |
PASSED | 06a78defbcde150f9cc2b772f0c17d7f | train_002.jsonl | 1453388400 | There are n pearls in a row. Let's enumerate them with integers from 1 to n from the left to the right. The pearl number i has the type ai.Let's call a sequence of consecutive pearls a segment. Let's call a segment good if it contains two pearls of the same type.Split the row of the pearls to the maximal number of good... | 256 megabytes | import javafx.util.Pair;
import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
public class Main {
static Scanner in = new Scanner(System.in);
public static void main(String[] args) {
Set<Integer> st=null;
List<Pair<Integer, Integer>> ans = new ArrayList<>();
... | Java | ["5\n1 2 3 4 1", "5\n1 2 3 4 5", "7\n1 2 1 3 1 2 1"] | 2 seconds | ["1\n1 5", "-1", "2\n1 3\n4 7"] | null | Java 8 | standard input | [
"greedy"
] | 4cacec219e4577b255ddf6d39d308e10 | The first line contains integer n (1 ≤ n ≤ 3·105) — the number of pearls in a row. The second line contains n integers ai (1 ≤ ai ≤ 109) – the type of the i-th pearl. | 1,500 | On the first line print integer k — the maximal number of segments in a partition of the row. Each of the next k lines should contain two integers lj, rj (1 ≤ lj ≤ rj ≤ n) — the number of the leftmost and the rightmost pearls in the j-th segment. Note you should print the correct partition of the row of the pearls, so ... | standard output | |
PASSED | f01fb6fe739535407f844cacc07d72d5 | train_002.jsonl | 1453388400 | There are n pearls in a row. Let's enumerate them with integers from 1 to n from the left to the right. The pearl number i has the type ai.Let's call a sequence of consecutive pearls a segment. Let's call a segment good if it contains two pearls of the same type.Split the row of the pearls to the maximal number of good... | 256 megabytes | import java.util.*;
import java.io.*;
public class test
{
public static void main(String [] args)throws IOException
{InputStreamReader iy=new InputStreamReader(System.in);PrintWriter pw=new PrintWriter(System.out);
BufferedReader br=new BufferedReader(iy);
int n=Integer.parseInt(br.readLine());
... | Java | ["5\n1 2 3 4 1", "5\n1 2 3 4 5", "7\n1 2 1 3 1 2 1"] | 2 seconds | ["1\n1 5", "-1", "2\n1 3\n4 7"] | null | Java 8 | standard input | [
"greedy"
] | 4cacec219e4577b255ddf6d39d308e10 | The first line contains integer n (1 ≤ n ≤ 3·105) — the number of pearls in a row. The second line contains n integers ai (1 ≤ ai ≤ 109) – the type of the i-th pearl. | 1,500 | On the first line print integer k — the maximal number of segments in a partition of the row. Each of the next k lines should contain two integers lj, rj (1 ≤ lj ≤ rj ≤ n) — the number of the leftmost and the rightmost pearls in the j-th segment. Note you should print the correct partition of the row of the pearls, so ... | standard output | |
PASSED | e33ce0b4a933c6fe6d1d2ce6f3a814e7 | train_002.jsonl | 1453388400 | There are n pearls in a row. Let's enumerate them with integers from 1 to n from the left to the right. The pearl number i has the type ai.Let's call a sequence of consecutive pearls a segment. Let's call a segment good if it contains two pearls of the same type.Split the row of the pearls to the maximal number of good... | 256 megabytes | import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;
public class Main {
int[] a;
Set<Integer> set;
int[] ansl;
int[] ansr;
p... | Java | ["5\n1 2 3 4 1", "5\n1 2 3 4 5", "7\n1 2 1 3 1 2 1"] | 2 seconds | ["1\n1 5", "-1", "2\n1 3\n4 7"] | null | Java 8 | standard input | [
"greedy"
] | 4cacec219e4577b255ddf6d39d308e10 | The first line contains integer n (1 ≤ n ≤ 3·105) — the number of pearls in a row. The second line contains n integers ai (1 ≤ ai ≤ 109) – the type of the i-th pearl. | 1,500 | On the first line print integer k — the maximal number of segments in a partition of the row. Each of the next k lines should contain two integers lj, rj (1 ≤ lj ≤ rj ≤ n) — the number of the leftmost and the rightmost pearls in the j-th segment. Note you should print the correct partition of the row of the pearls, so ... | standard output | |
PASSED | 20c9399ba103a2131fd38d8cfd6e5b18 | train_002.jsonl | 1453388400 | There are n pearls in a row. Let's enumerate them with integers from 1 to n from the left to the right. The pearl number i has the type ai.Let's call a sequence of consecutive pearls a segment. Let's call a segment good if it contains two pearls of the same type.Split the row of the pearls to the maximal number of good... | 256 megabytes | import java.util.*;
public class C620 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int[][] indexes = new int [n][3];
int k = 0;
int indBegin = 0;
HashSet<Long> set = new HashSet<>();
for (int i = 0; i < n; i++) {
long a = scan.nextLong();... | Java | ["5\n1 2 3 4 1", "5\n1 2 3 4 5", "7\n1 2 1 3 1 2 1"] | 2 seconds | ["1\n1 5", "-1", "2\n1 3\n4 7"] | null | Java 8 | standard input | [
"greedy"
] | 4cacec219e4577b255ddf6d39d308e10 | The first line contains integer n (1 ≤ n ≤ 3·105) — the number of pearls in a row. The second line contains n integers ai (1 ≤ ai ≤ 109) – the type of the i-th pearl. | 1,500 | On the first line print integer k — the maximal number of segments in a partition of the row. Each of the next k lines should contain two integers lj, rj (1 ≤ lj ≤ rj ≤ n) — the number of the leftmost and the rightmost pearls in the j-th segment. Note you should print the correct partition of the row of the pearls, so ... | standard output | |
PASSED | 648b9bb560826d588feefc9b9b228c50 | train_002.jsonl | 1453388400 | There are n pearls in a row. Let's enumerate them with integers from 1 to n from the left to the right. The pearl number i has the type ai.Let's call a sequence of consecutive pearls a segment. Let's call a segment good if it contains two pearls of the same type.Split the row of the pearls to the maximal number of good... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java... | Java | ["5\n1 2 3 4 1", "5\n1 2 3 4 5", "7\n1 2 1 3 1 2 1"] | 2 seconds | ["1\n1 5", "-1", "2\n1 3\n4 7"] | null | Java 8 | standard input | [
"greedy"
] | 4cacec219e4577b255ddf6d39d308e10 | The first line contains integer n (1 ≤ n ≤ 3·105) — the number of pearls in a row. The second line contains n integers ai (1 ≤ ai ≤ 109) – the type of the i-th pearl. | 1,500 | On the first line print integer k — the maximal number of segments in a partition of the row. Each of the next k lines should contain two integers lj, rj (1 ≤ lj ≤ rj ≤ n) — the number of the leftmost and the rightmost pearls in the j-th segment. Note you should print the correct partition of the row of the pearls, so ... | standard output | |
PASSED | ca8ff6a6d513e6ec0b96738e2ae67961 | train_002.jsonl | 1453388400 | There are n pearls in a row. Let's enumerate them with integers from 1 to n from the left to the right. The pearl number i has the type ai.Let's call a sequence of consecutive pearls a segment. Let's call a segment good if it contains two pearls of the same type.Split the row of the pearls to the maximal number of good... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.lang.Integer;
impor... | Java | ["5\n1 2 3 4 1", "5\n1 2 3 4 5", "7\n1 2 1 3 1 2 1"] | 2 seconds | ["1\n1 5", "-1", "2\n1 3\n4 7"] | null | Java 8 | standard input | [
"greedy"
] | 4cacec219e4577b255ddf6d39d308e10 | The first line contains integer n (1 ≤ n ≤ 3·105) — the number of pearls in a row. The second line contains n integers ai (1 ≤ ai ≤ 109) – the type of the i-th pearl. | 1,500 | On the first line print integer k — the maximal number of segments in a partition of the row. Each of the next k lines should contain two integers lj, rj (1 ≤ lj ≤ rj ≤ n) — the number of the leftmost and the rightmost pearls in the j-th segment. Note you should print the correct partition of the row of the pearls, so ... | standard output | |
PASSED | 0fb1048bcd555330b4e206375897865a | train_002.jsonl | 1453388400 | There are n pearls in a row. Let's enumerate them with integers from 1 to n from the left to the right. The pearl number i has the type ai.Let's call a sequence of consecutive pearls a segment. Let's call a segment good if it contains two pearls of the same type.Split the row of the pearls to the maximal number of good... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.lang.Integer;
impor... | Java | ["5\n1 2 3 4 1", "5\n1 2 3 4 5", "7\n1 2 1 3 1 2 1"] | 2 seconds | ["1\n1 5", "-1", "2\n1 3\n4 7"] | null | Java 8 | standard input | [
"greedy"
] | 4cacec219e4577b255ddf6d39d308e10 | The first line contains integer n (1 ≤ n ≤ 3·105) — the number of pearls in a row. The second line contains n integers ai (1 ≤ ai ≤ 109) – the type of the i-th pearl. | 1,500 | On the first line print integer k — the maximal number of segments in a partition of the row. Each of the next k lines should contain two integers lj, rj (1 ≤ lj ≤ rj ≤ n) — the number of the leftmost and the rightmost pearls in the j-th segment. Note you should print the correct partition of the row of the pearls, so ... | standard output | |
PASSED | 70464f21f5125e2333878e830965aeee | train_002.jsonl | 1453388400 | There are n pearls in a row. Let's enumerate them with integers from 1 to n from the left to the right. The pearl number i has the type ai.Let's call a sequence of consecutive pearls a segment. Let's call a segment good if it contains two pearls of the same type.Split the row of the pearls to the maximal number of good... | 256 megabytes | import java.io.*;
import java.util.*;
public class Educational6B {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
PrintWriter writer=new PrintWriter(new OutputStreamWriter(System.out));
Set s=new HashSet();
int n=Integer... | Java | ["5\n1 2 3 4 1", "5\n1 2 3 4 5", "7\n1 2 1 3 1 2 1"] | 2 seconds | ["1\n1 5", "-1", "2\n1 3\n4 7"] | null | Java 8 | standard input | [
"greedy"
] | 4cacec219e4577b255ddf6d39d308e10 | The first line contains integer n (1 ≤ n ≤ 3·105) — the number of pearls in a row. The second line contains n integers ai (1 ≤ ai ≤ 109) – the type of the i-th pearl. | 1,500 | On the first line print integer k — the maximal number of segments in a partition of the row. Each of the next k lines should contain two integers lj, rj (1 ≤ lj ≤ rj ≤ n) — the number of the leftmost and the rightmost pearls in the j-th segment. Note you should print the correct partition of the row of the pearls, so ... | standard output | |
PASSED | c27b6398be964b48b696a3aa98f9f5a3 | train_002.jsonl | 1453388400 | There are n pearls in a row. Let's enumerate them with integers from 1 to n from the left to the right. The pearl number i has the type ai.Let's call a sequence of consecutive pearls a segment. Let's call a segment good if it contains two pearls of the same type.Split the row of the pearls to the maximal number of good... | 256 megabytes | import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class Educational6B {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
Set s=new HashSet();
int n=sc.nextInt();
int []num=new int[n];
int ans=0;
int len=s.size();
int [][... | Java | ["5\n1 2 3 4 1", "5\n1 2 3 4 5", "7\n1 2 1 3 1 2 1"] | 2 seconds | ["1\n1 5", "-1", "2\n1 3\n4 7"] | null | Java 8 | standard input | [
"greedy"
] | 4cacec219e4577b255ddf6d39d308e10 | The first line contains integer n (1 ≤ n ≤ 3·105) — the number of pearls in a row. The second line contains n integers ai (1 ≤ ai ≤ 109) – the type of the i-th pearl. | 1,500 | On the first line print integer k — the maximal number of segments in a partition of the row. Each of the next k lines should contain two integers lj, rj (1 ≤ lj ≤ rj ≤ n) — the number of the leftmost and the rightmost pearls in the j-th segment. Note you should print the correct partition of the row of the pearls, so ... | standard output | |
PASSED | 042409a15430f601e206b9a2af0f213c | train_002.jsonl | 1453388400 | There are n pearls in a row. Let's enumerate them with integers from 1 to n from the left to the right. The pearl number i has the type ai.Let's call a sequence of consecutive pearls a segment. Let's call a segment good if it contains two pearls of the same type.Split the row of the pearls to the maximal number of good... | 256 megabytes | import java.io.*;
import java.util.*;
public class Solution {
BufferedReader br;
PrintWriter out;
StringTokenizer st;
boolean eof;
static final int Mod = 1000000007;
static class Pair {
int x, y;
Pair(int _x, int _y) {
x = _x;
y = _y;
}
... | Java | ["5\n1 2 3 4 1", "5\n1 2 3 4 5", "7\n1 2 1 3 1 2 1"] | 2 seconds | ["1\n1 5", "-1", "2\n1 3\n4 7"] | null | Java 8 | standard input | [
"greedy"
] | 4cacec219e4577b255ddf6d39d308e10 | The first line contains integer n (1 ≤ n ≤ 3·105) — the number of pearls in a row. The second line contains n integers ai (1 ≤ ai ≤ 109) – the type of the i-th pearl. | 1,500 | On the first line print integer k — the maximal number of segments in a partition of the row. Each of the next k lines should contain two integers lj, rj (1 ≤ lj ≤ rj ≤ n) — the number of the leftmost and the rightmost pearls in the j-th segment. Note you should print the correct partition of the row of the pearls, so ... | standard output | |
PASSED | 7eeb561a7b22cdc49653be709bc31184 | train_002.jsonl | 1589466900 | You are given a garland consisting of $$$n$$$ lamps. States of the lamps are represented by the string $$$s$$$ of length $$$n$$$. The $$$i$$$-th character of the string $$$s_i$$$ equals '0' if the $$$i$$$-th lamp is turned off or '1' if the $$$i$$$-th lamp is turned on. You are also given a positive integer $$$k$$$.In ... | 256 megabytes | /**
* @author derrick20
*/
import java.io.*;
import java.util.*;
public class KGarland {
public static void main(String[] args) throws Exception {
FastScanner sc = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
int T = sc.nextInt();
while (T-->0) {
... | Java | ["6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n1\n1 1\n0"] | 1 second | ["1\n2\n5\n4\n0\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"brute force"
] | 8b28309055f13837eb1f51422fb91029 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 25~ 000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^6; 1 \le k \le n$$$) — the length of $$$s$$$ and the required period. The second l... | 1,900 | For each test case, print the answer — the minimum number of moves you need to make to obtain $$$k$$$-periodic garland from the given one. | standard output | |
PASSED | 0dae19fd052852807f0febd63a291349 | train_002.jsonl | 1589466900 | You are given a garland consisting of $$$n$$$ lamps. States of the lamps are represented by the string $$$s$$$ of length $$$n$$$. The $$$i$$$-th character of the string $$$s_i$$$ equals '0' if the $$$i$$$-th lamp is turned off or '1' if the $$$i$$$-th lamp is turned on. You are also given a positive integer $$$k$$$.In ... | 256 megabytes | import java.io.*;
import java.util.*;
public class CF1353E extends PrintWriter {
CF1353E() { super(System.out); }
Scanner sc = new Scanner(System.in);
public static void main(String[] $) {
CF1353E o = new CF1353E(); o.main(); o.flush();
}
void main() {
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.... | Java | ["6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n1\n1 1\n0"] | 1 second | ["1\n2\n5\n4\n0\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"brute force"
] | 8b28309055f13837eb1f51422fb91029 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 25~ 000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^6; 1 \le k \le n$$$) — the length of $$$s$$$ and the required period. The second l... | 1,900 | For each test case, print the answer — the minimum number of moves you need to make to obtain $$$k$$$-periodic garland from the given one. | standard output | |
PASSED | e7a75546e7febee1ce17f2a753df7708 | train_002.jsonl | 1589466900 | You are given a garland consisting of $$$n$$$ lamps. States of the lamps are represented by the string $$$s$$$ of length $$$n$$$. The $$$i$$$-th character of the string $$$s_i$$$ equals '0' if the $$$i$$$-th lamp is turned off or '1' if the $$$i$$$-th lamp is turned on. You are also given a positive integer $$$k$$$.In ... | 256 megabytes | import java.io.*;
import java.math.*;
import java.util.*;
public class Main{
static long MOD = 998244353L;
static long [] fac;
static int[][] dir = new int[][]{{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
static long lMax = 0x3f3f3f3f3f3f3f3fL;
static int iMax = 0x3f3f3f3f;
public static void main(Strin... | Java | ["6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n1\n1 1\n0"] | 1 second | ["1\n2\n5\n4\n0\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"brute force"
] | 8b28309055f13837eb1f51422fb91029 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 25~ 000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^6; 1 \le k \le n$$$) — the length of $$$s$$$ and the required period. The second l... | 1,900 | For each test case, print the answer — the minimum number of moves you need to make to obtain $$$k$$$-periodic garland from the given one. | standard output | |
PASSED | f4e40de4b2e678b31b9d02a6d6a49361 | train_002.jsonl | 1589466900 | You are given a garland consisting of $$$n$$$ lamps. States of the lamps are represented by the string $$$s$$$ of length $$$n$$$. The $$$i$$$-th character of the string $$$s_i$$$ equals '0' if the $$$i$$$-th lamp is turned off or '1' if the $$$i$$$-th lamp is turned on. You are also given a positive integer $$$k$$$.In ... | 256 megabytes | import java.util.*;
import java.io.*;
public class K_Periodic_Garlands {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
s... | Java | ["6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n1\n1 1\n0"] | 1 second | ["1\n2\n5\n4\n0\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"brute force"
] | 8b28309055f13837eb1f51422fb91029 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 25~ 000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^6; 1 \le k \le n$$$) — the length of $$$s$$$ and the required period. The second l... | 1,900 | For each test case, print the answer — the minimum number of moves you need to make to obtain $$$k$$$-periodic garland from the given one. | standard output | |
PASSED | 7c3e438c992d69b789f3016af296c362 | train_002.jsonl | 1589466900 | You are given a garland consisting of $$$n$$$ lamps. States of the lamps are represented by the string $$$s$$$ of length $$$n$$$. The $$$i$$$-th character of the string $$$s_i$$$ equals '0' if the $$$i$$$-th lamp is turned off or '1' if the $$$i$$$-th lamp is turned on. You are also given a positive integer $$$k$$$.In ... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main{
static void main() throws Exception{
int n=sc.nextInt(),k=sc.nextInt();
int zeros=0,ones=0;
char[]in=sc.nextLine().toCharArray();
for(char c:in) {
if(c=='0') {
zeros++;
}
else {
ones++;
}
}
int ans=ones;
int[]pref=new int[n];
... | Java | ["6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n1\n1 1\n0"] | 1 second | ["1\n2\n5\n4\n0\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"brute force"
] | 8b28309055f13837eb1f51422fb91029 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 25~ 000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^6; 1 \le k \le n$$$) — the length of $$$s$$$ and the required period. The second l... | 1,900 | For each test case, print the answer — the minimum number of moves you need to make to obtain $$$k$$$-periodic garland from the given one. | standard output | |
PASSED | 866d494de16845d44cc34328db3d5a12 | train_002.jsonl | 1589466900 | You are given a garland consisting of $$$n$$$ lamps. States of the lamps are represented by the string $$$s$$$ of length $$$n$$$. The $$$i$$$-th character of the string $$$s_i$$$ equals '0' if the $$$i$$$-th lamp is turned off or '1' if the $$$i$$$-th lamp is turned on. You are also given a positive integer $$$k$$$.In ... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;
... | Java | ["6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n1\n1 1\n0"] | 1 second | ["1\n2\n5\n4\n0\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"brute force"
] | 8b28309055f13837eb1f51422fb91029 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 25~ 000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^6; 1 \le k \le n$$$) — the length of $$$s$$$ and the required period. The second l... | 1,900 | For each test case, print the answer — the minimum number of moves you need to make to obtain $$$k$$$-periodic garland from the given one. | standard output | |
PASSED | 75f7a03bcc16fdf209a598d3dcb1edb6 | train_002.jsonl | 1589466900 | You are given a garland consisting of $$$n$$$ lamps. States of the lamps are represented by the string $$$s$$$ of length $$$n$$$. The $$$i$$$-th character of the string $$$s_i$$$ equals '0' if the $$$i$$$-th lamp is turned off or '1' if the $$$i$$$-th lamp is turned on. You are also given a positive integer $$$k$$$.In ... | 256 megabytes | /**
* @author egaeus
* @mail sebegaeusprogram@gmail.com
* @veredict
* @url
* @category
* @date
**/
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import static java.lang.Integer.parseInt;
public class CFE {
static char[] arr;
static int[] Q;
sta... | Java | ["6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n1\n1 1\n0"] | 1 second | ["1\n2\n5\n4\n0\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"brute force"
] | 8b28309055f13837eb1f51422fb91029 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 25~ 000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^6; 1 \le k \le n$$$) — the length of $$$s$$$ and the required period. The second l... | 1,900 | For each test case, print the answer — the minimum number of moves you need to make to obtain $$$k$$$-periodic garland from the given one. | standard output | |
PASSED | cb57b059c1b309ea9def46934782382f | train_002.jsonl | 1589466900 | You are given a garland consisting of $$$n$$$ lamps. States of the lamps are represented by the string $$$s$$$ of length $$$n$$$. The $$$i$$$-th character of the string $$$s_i$$$ equals '0' if the $$$i$$$-th lamp is turned off or '1' if the $$$i$$$-th lamp is turned on. You are also given a positive integer $$$k$$$.In ... | 256 megabytes |
import java.io.*;
import java.util.*;
/**
* @author Tran Anh Tai
* ProbE div 3 #642;
*/
public class KPeriodicGarland {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
... | Java | ["6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n1\n1 1\n0"] | 1 second | ["1\n2\n5\n4\n0\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"brute force"
] | 8b28309055f13837eb1f51422fb91029 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 25~ 000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^6; 1 \le k \le n$$$) — the length of $$$s$$$ and the required period. The second l... | 1,900 | For each test case, print the answer — the minimum number of moves you need to make to obtain $$$k$$$-periodic garland from the given one. | standard output | |
PASSED | 58dec083d1d25815b970b82a5e2e35da | train_002.jsonl | 1589466900 | You are given a garland consisting of $$$n$$$ lamps. States of the lamps are represented by the string $$$s$$$ of length $$$n$$$. The $$$i$$$-th character of the string $$$s_i$$$ equals '0' if the $$$i$$$-th lamp is turned off or '1' if the $$$i$$$-th lamp is turned on. You are also given a positive integer $$$k$$$.In ... | 256 megabytes |
// Problem: E. K-periodic Garland
// Contest: Codeforces - Codeforces Round #642 (Div. 3)
// URL: http://codeforces.com/problemset/problem/1353/E
// Memory Limit: 256 MB
// Time Limit: 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
import java.io.*;
import java.util.*;
public class Main {
... | Java | ["6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n1\n1 1\n0"] | 1 second | ["1\n2\n5\n4\n0\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"brute force"
] | 8b28309055f13837eb1f51422fb91029 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 25~ 000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^6; 1 \le k \le n$$$) — the length of $$$s$$$ and the required period. The second l... | 1,900 | For each test case, print the answer — the minimum number of moves you need to make to obtain $$$k$$$-periodic garland from the given one. | standard output | |
PASSED | 5fd611deac4596e07e69e50ade95b0d7 | train_002.jsonl | 1589466900 | You are given a garland consisting of $$$n$$$ lamps. States of the lamps are represented by the string $$$s$$$ of length $$$n$$$. The $$$i$$$-th character of the string $$$s_i$$$ equals '0' if the $$$i$$$-th lamp is turned off or '1' if the $$$i$$$-th lamp is turned on. You are also given a positive integer $$$k$$$.In ... | 256 megabytes | import java.io.*;
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
public class cf1353e_2 {
static BufferedReader __in;
static PrintWriter __out;
static StringTokenizer input;
public static void main(String[] args) throws IOException {
__in = new BufferedR... | Java | ["6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n1\n1 1\n0"] | 1 second | ["1\n2\n5\n4\n0\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"brute force"
] | 8b28309055f13837eb1f51422fb91029 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 25~ 000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^6; 1 \le k \le n$$$) — the length of $$$s$$$ and the required period. The second l... | 1,900 | For each test case, print the answer — the minimum number of moves you need to make to obtain $$$k$$$-periodic garland from the given one. | standard output | |
PASSED | 959eccf63451dae1861bf81b7f6f5393 | train_002.jsonl | 1589466900 | You are given a garland consisting of $$$n$$$ lamps. States of the lamps are represented by the string $$$s$$$ of length $$$n$$$. The $$$i$$$-th character of the string $$$s_i$$$ equals '0' if the $$$i$$$-th lamp is turned off or '1' if the $$$i$$$-th lamp is turned on. You are also given a positive integer $$$k$$$.In ... | 256 megabytes | import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.PriorityQueue;
import java.util.Scanner;
public class code11 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scn = new Scanner(System.in);
int t =... | Java | ["6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n1\n1 1\n0"] | 1 second | ["1\n2\n5\n4\n0\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"brute force"
] | 8b28309055f13837eb1f51422fb91029 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 25~ 000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^6; 1 \le k \le n$$$) — the length of $$$s$$$ and the required period. The second l... | 1,900 | For each test case, print the answer — the minimum number of moves you need to make to obtain $$$k$$$-periodic garland from the given one. | standard output | |
PASSED | 79a59f06b3351bdcef8e4c39b5b7f8f0 | train_002.jsonl | 1589466900 | You are given a garland consisting of $$$n$$$ lamps. States of the lamps are represented by the string $$$s$$$ of length $$$n$$$. The $$$i$$$-th character of the string $$$s_i$$$ equals '0' if the $$$i$$$-th lamp is turned off or '1' if the $$$i$$$-th lamp is turned on. You are also given a positive integer $$$k$$$.In ... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class d {
static BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
// static Scanner s=new Scanner(System.in);
public static void main(String[] args) throws IOExcep... | Java | ["6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n1\n1 1\n0"] | 1 second | ["1\n2\n5\n4\n0\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"brute force"
] | 8b28309055f13837eb1f51422fb91029 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 25~ 000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^6; 1 \le k \le n$$$) — the length of $$$s$$$ and the required period. The second l... | 1,900 | For each test case, print the answer — the minimum number of moves you need to make to obtain $$$k$$$-periodic garland from the given one. | standard output | |
PASSED | 2dc58915afcabf66a0a77d0bc66e94eb | train_002.jsonl | 1589466900 | You are given a garland consisting of $$$n$$$ lamps. States of the lamps are represented by the string $$$s$$$ of length $$$n$$$. The $$$i$$$-th character of the string $$$s_i$$$ equals '0' if the $$$i$$$-th lamp is turned off or '1' if the $$$i$$$-th lamp is turned on. You are also given a positive integer $$$k$$$.In ... | 256 megabytes | import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
static PrintWriter out = new PrintWriter(System.out);
static Reader in = new Reader();
public static void main(String[] args) throws IOException {
Main solver = new Main();
solver.solve();
out.flush();
... | Java | ["6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n1\n1 1\n0"] | 1 second | ["1\n2\n5\n4\n0\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"brute force"
] | 8b28309055f13837eb1f51422fb91029 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 25~ 000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^6; 1 \le k \le n$$$) — the length of $$$s$$$ and the required period. The second l... | 1,900 | For each test case, print the answer — the minimum number of moves you need to make to obtain $$$k$$$-periodic garland from the given one. | standard output | |
PASSED | 3601600cf8ff73f87836cd8f9ae2fa4c | train_002.jsonl | 1589466900 | You are given a garland consisting of $$$n$$$ lamps. States of the lamps are represented by the string $$$s$$$ of length $$$n$$$. The $$$i$$$-th character of the string $$$s_i$$$ equals '0' if the $$$i$$$-th lamp is turned off or '1' if the $$$i$$$-th lamp is turned on. You are also given a positive integer $$$k$$$.In ... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main
{
final int inf=(int)(1e9+1);
private void solve()throws IOException
{
int n=nextInt();
int k=nextInt();
String s=nextLine();
int a[]=new int[n+1];
for(int i=1;i<=n;i++)
a[i]=s.charAt(i-1)-'0';
int cum[]=new int[n+1];
for(int i=1;i<=n;i++)
c... | Java | ["6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n1\n1 1\n0"] | 1 second | ["1\n2\n5\n4\n0\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"brute force"
] | 8b28309055f13837eb1f51422fb91029 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 25~ 000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^6; 1 \le k \le n$$$) — the length of $$$s$$$ and the required period. The second l... | 1,900 | For each test case, print the answer — the minimum number of moves you need to make to obtain $$$k$$$-periodic garland from the given one. | standard output | |
PASSED | beee3f4d1ec8258bb290e308a0db81b7 | train_002.jsonl | 1589466900 | You are given a garland consisting of $$$n$$$ lamps. States of the lamps are represented by the string $$$s$$$ of length $$$n$$$. The $$$i$$$-th character of the string $$$s_i$$$ equals '0' if the $$$i$$$-th lamp is turned off or '1' if the $$$i$$$-th lamp is turned on. You are also given a positive integer $$$k$$$.In ... | 256 megabytes | import java.io.BufferedOutputStream;
import java.io.Closeable;
import java.io.DataInputStream;
import java.io.Flushable;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.fun... | Java | ["6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n1\n1 1\n0"] | 1 second | ["1\n2\n5\n4\n0\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"brute force"
] | 8b28309055f13837eb1f51422fb91029 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 25~ 000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^6; 1 \le k \le n$$$) — the length of $$$s$$$ and the required period. The second l... | 1,900 | For each test case, print the answer — the minimum number of moves you need to make to obtain $$$k$$$-periodic garland from the given one. | standard output | |
PASSED | e627a976f9507a0abbe7a89e2c4526f1 | train_002.jsonl | 1589466900 | You are given a garland consisting of $$$n$$$ lamps. States of the lamps are represented by the string $$$s$$$ of length $$$n$$$. The $$$i$$$-th character of the string $$$s_i$$$ equals '0' if the $$$i$$$-th lamp is turned off or '1' if the $$$i$$$-th lamp is turned on. You are also given a positive integer $$$k$$$.In ... | 256 megabytes | import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.math.*;
//Mann Shah [ DAIICT ].
//fast io
public class Main {
static long mod = (long) (1e9+7);
static long mm = (long)(1e9+6);
static long N = (long)(2*1e5);
static InputReader in;
static PrintWriter out;
static Debugger deb... | Java | ["6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n1\n1 1\n0"] | 1 second | ["1\n2\n5\n4\n0\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"brute force"
] | 8b28309055f13837eb1f51422fb91029 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 25~ 000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^6; 1 \le k \le n$$$) — the length of $$$s$$$ and the required period. The second l... | 1,900 | For each test case, print the answer — the minimum number of moves you need to make to obtain $$$k$$$-periodic garland from the given one. | standard output | |
PASSED | 5b552a26a2c901e40090d3799414a97c | train_002.jsonl | 1589466900 | You are given a garland consisting of $$$n$$$ lamps. States of the lamps are represented by the string $$$s$$$ of length $$$n$$$. The $$$i$$$-th character of the string $$$s_i$$$ equals '0' if the $$$i$$$-th lamp is turned off or '1' if the $$$i$$$-th lamp is turned on. You are also given a positive integer $$$k$$$.In ... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public clas... | Java | ["6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n1\n1 1\n0"] | 1 second | ["1\n2\n5\n4\n0\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"brute force"
] | 8b28309055f13837eb1f51422fb91029 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 25~ 000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^6; 1 \le k \le n$$$) — the length of $$$s$$$ and the required period. The second l... | 1,900 | For each test case, print the answer — the minimum number of moves you need to make to obtain $$$k$$$-periodic garland from the given one. | standard output | |
PASSED | 2d507bb117f01a0876395967ae4e80a6 | train_002.jsonl | 1589466900 | You are given a garland consisting of $$$n$$$ lamps. States of the lamps are represented by the string $$$s$$$ of length $$$n$$$. The $$$i$$$-th character of the string $$$s_i$$$ equals '0' if the $$$i$$$-th lamp is turned off or '1' if the $$$i$$$-th lamp is turned on. You are also given a positive integer $$$k$$$.In ... | 256 megabytes | import java.util.*;
import java.io.*;
public class E642
{
public static void main(String [] args)
{
MyScanner sc = new MyScanner();
PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
int t = sc.nextInt();
while (t > 0) {
int n = sc.nextInt(); int... | Java | ["6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n1\n1 1\n0"] | 1 second | ["1\n2\n5\n4\n0\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"brute force"
] | 8b28309055f13837eb1f51422fb91029 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 25~ 000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^6; 1 \le k \le n$$$) — the length of $$$s$$$ and the required period. The second l... | 1,900 | For each test case, print the answer — the minimum number of moves you need to make to obtain $$$k$$$-periodic garland from the given one. | standard output | |
PASSED | 67ef0800d49d76c42c7eace8d3aa767b | train_002.jsonl | 1589466900 | You are given a garland consisting of $$$n$$$ lamps. States of the lamps are represented by the string $$$s$$$ of length $$$n$$$. The $$$i$$$-th character of the string $$$s_i$$$ equals '0' if the $$$i$$$-th lamp is turned off or '1' if the $$$i$$$-th lamp is turned on. You are also given a positive integer $$$k$$$.In ... | 256 megabytes | import java.io.*;
import java.util.*;
public class Abc {
static int dp[];
static int ii,tot,i1;
static ArrayList<Integer> adj[];
static int pre[],suf[];
public static void main(String[] args) throws Exception {
FastReader sc = new FastReader();
int t=sc.nextInt();
StringBui... | Java | ["6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n1\n1 1\n0"] | 1 second | ["1\n2\n5\n4\n0\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"brute force"
] | 8b28309055f13837eb1f51422fb91029 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 25~ 000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^6; 1 \le k \le n$$$) — the length of $$$s$$$ and the required period. The second l... | 1,900 | For each test case, print the answer — the minimum number of moves you need to make to obtain $$$k$$$-periodic garland from the given one. | standard output | |
PASSED | e5fee14b91459aebfaab2c7a10cc6609 | train_002.jsonl | 1589466900 | You are given a garland consisting of $$$n$$$ lamps. States of the lamps are represented by the string $$$s$$$ of length $$$n$$$. The $$$i$$$-th character of the string $$$s_i$$$ equals '0' if the $$$i$$$-th lamp is turned off or '1' if the $$$i$$$-th lamp is turned on. You are also given a positive integer $$$k$$$.In ... | 256 megabytes | import java.io.*;
import java.util.*;
public class Q3 {
public static void main(String[] args) {
InputReader in = new InputReader();
PrintWriter out = new PrintWriter(System.out);
int t = in.nextInt();
while(t-->0){
int n =in.nextInt(),k=in.nextInt(),tot=0;
... | Java | ["6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n1\n1 1\n0"] | 1 second | ["1\n2\n5\n4\n0\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"brute force"
] | 8b28309055f13837eb1f51422fb91029 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 25~ 000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^6; 1 \le k \le n$$$) — the length of $$$s$$$ and the required period. The second l... | 1,900 | For each test case, print the answer — the minimum number of moves you need to make to obtain $$$k$$$-periodic garland from the given one. | standard output | |
PASSED | 066045f46287716419d22a7a98e280cf | train_002.jsonl | 1589466900 | You are given a garland consisting of $$$n$$$ lamps. States of the lamps are represented by the string $$$s$$$ of length $$$n$$$. The $$$i$$$-th character of the string $$$s_i$$$ equals '0' if the $$$i$$$-th lamp is turned off or '1' if the $$$i$$$-th lamp is turned on. You are also given a positive integer $$$k$$$.In ... | 256 megabytes | import java.io.*;
import java.util.*;
public class Q3 {
public static void main(String[] args) {
InputReader in = new InputReader();
PrintWriter out = new PrintWriter(System.out);
int t = in.nextInt();
while(t-->0){
int n =in.nextInt(),k=in.nextInt(),tot=0;
... | Java | ["6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n1\n1 1\n0"] | 1 second | ["1\n2\n5\n4\n0\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"brute force"
] | 8b28309055f13837eb1f51422fb91029 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 25~ 000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^6; 1 \le k \le n$$$) — the length of $$$s$$$ and the required period. The second l... | 1,900 | For each test case, print the answer — the minimum number of moves you need to make to obtain $$$k$$$-periodic garland from the given one. | standard output | |
PASSED | 75b8a78fce1cc6b50a541831c3533985 | train_002.jsonl | 1589466900 | You are given a garland consisting of $$$n$$$ lamps. States of the lamps are represented by the string $$$s$$$ of length $$$n$$$. The $$$i$$$-th character of the string $$$s_i$$$ equals '0' if the $$$i$$$-th lamp is turned off or '1' if the $$$i$$$-th lamp is turned on. You are also given a positive integer $$$k$$$.In ... | 256 megabytes |
import java.util.*;
public class Main
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
StringBuilder sb=new StringBuilder();
int t=sc.nextInt();
while(t-->0)
{
int n=sc.nextInt();
int k=sc.nextInt();
ArrayList<Integer> a[]=new ArrayLi... | Java | ["6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n1\n1 1\n0"] | 1 second | ["1\n2\n5\n4\n0\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"brute force"
] | 8b28309055f13837eb1f51422fb91029 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 25~ 000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^6; 1 \le k \le n$$$) — the length of $$$s$$$ and the required period. The second l... | 1,900 | For each test case, print the answer — the minimum number of moves you need to make to obtain $$$k$$$-periodic garland from the given one. | standard output | |
PASSED | 74e53143f4b6aca9984c3cb6ebaaecf6 | train_002.jsonl | 1589466900 | You are given a garland consisting of $$$n$$$ lamps. States of the lamps are represented by the string $$$s$$$ of length $$$n$$$. The $$$i$$$-th character of the string $$$s_i$$$ equals '0' if the $$$i$$$-th lamp is turned off or '1' if the $$$i$$$-th lamp is turned on. You are also given a positive integer $$$k$$$.In ... | 256 megabytes | //package round642;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
public class E {
InputStream is;
PrintWriter out;
String INPUT = "";
void solve()
{
for(int T = ni();T ... | Java | ["6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n1\n1 1\n0"] | 1 second | ["1\n2\n5\n4\n0\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"brute force"
] | 8b28309055f13837eb1f51422fb91029 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 25~ 000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^6; 1 \le k \le n$$$) — the length of $$$s$$$ and the required period. The second l... | 1,900 | For each test case, print the answer — the minimum number of moves you need to make to obtain $$$k$$$-periodic garland from the given one. | standard output | |
PASSED | e410fd1b460a7b888716c6da9fc00048 | train_002.jsonl | 1589466900 | You are given a garland consisting of $$$n$$$ lamps. States of the lamps are represented by the string $$$s$$$ of length $$$n$$$. The $$$i$$$-th character of the string $$$s_i$$$ equals '0' if the $$$i$$$-th lamp is turned off or '1' if the $$$i$$$-th lamp is turned on. You are also given a positive integer $$$k$$$.In ... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main{
static class InputReader {
private final InputStream stream;
private final byte[] buf = new byte[8192];
private int curChar, snumChars;
private SpaceCharFilter filter;
public InputReader(InputStream stream) {
... | Java | ["6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n1\n1 1\n0"] | 1 second | ["1\n2\n5\n4\n0\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"brute force"
] | 8b28309055f13837eb1f51422fb91029 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 25~ 000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^6; 1 \le k \le n$$$) — the length of $$$s$$$ and the required period. The second l... | 1,900 | For each test case, print the answer — the minimum number of moves you need to make to obtain $$$k$$$-periodic garland from the given one. | standard output | |
PASSED | 70f8c2c9941dfada16b03ee56a33a436 | train_002.jsonl | 1589466900 | You are given a garland consisting of $$$n$$$ lamps. States of the lamps are represented by the string $$$s$$$ of length $$$n$$$. The $$$i$$$-th character of the string $$$s_i$$$ equals '0' if the $$$i$$$-th lamp is turned off or '1' if the $$$i$$$-th lamp is turned on. You are also given a positive integer $$$k$$$.In ... | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{ public static void main (String[] args)throws IOException {
try{
//BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
Scanner sc ... | Java | ["6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n1\n1 1\n0"] | 1 second | ["1\n2\n5\n4\n0\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"brute force"
] | 8b28309055f13837eb1f51422fb91029 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 25~ 000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^6; 1 \le k \le n$$$) — the length of $$$s$$$ and the required period. The second l... | 1,900 | For each test case, print the answer — the minimum number of moves you need to make to obtain $$$k$$$-periodic garland from the given one. | standard output | |
PASSED | 3c6140058e43bebb5d50358418db8b39 | train_002.jsonl | 1589466900 | You are given a garland consisting of $$$n$$$ lamps. States of the lamps are represented by the string $$$s$$$ of length $$$n$$$. The $$$i$$$-th character of the string $$$s_i$$$ equals '0' if the $$$i$$$-th lamp is turned off or '1' if the $$$i$$$-th lamp is turned on. You are also given a positive integer $$$k$$$.In ... | 256 megabytes | import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
public class Task {
public static void main(String[] args) throws Exception {
new Task().go();
}
PrintWriter out;
Reader in;
BufferedReader br;
Task() throws IOException {
try {
//br = new Bu... | Java | ["6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n1\n1 1\n0"] | 1 second | ["1\n2\n5\n4\n0\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"brute force"
] | 8b28309055f13837eb1f51422fb91029 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 25~ 000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^6; 1 \le k \le n$$$) — the length of $$$s$$$ and the required period. The second l... | 1,900 | For each test case, print the answer — the minimum number of moves you need to make to obtain $$$k$$$-periodic garland from the given one. | standard output | |
PASSED | 3f0c7a3d61a74dd3eaa55f26a0874c29 | train_002.jsonl | 1589466900 | You are given a garland consisting of $$$n$$$ lamps. States of the lamps are represented by the string $$$s$$$ of length $$$n$$$. The $$$i$$$-th character of the string $$$s_i$$$ equals '0' if the $$$i$$$-th lamp is turned off or '1' if the $$$i$$$-th lamp is turned on. You are also given a positive integer $$$k$$$.In ... | 256 megabytes | /*
Author: Anthony Ngene
Created: 07/08/2020 - 07:49
*/
import java.io.*;
import java.util.*;
public class E {
// Light travels faster than sound. This is why some people appear bright until you hear them speak. - Alan Dundes
public static void main(String[] args) throws IOException {
in = new FastScanner... | Java | ["6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n1\n1 1\n0"] | 1 second | ["1\n2\n5\n4\n0\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"brute force"
] | 8b28309055f13837eb1f51422fb91029 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 25~ 000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^6; 1 \le k \le n$$$) — the length of $$$s$$$ and the required period. The second l... | 1,900 | For each test case, print the answer — the minimum number of moves you need to make to obtain $$$k$$$-periodic garland from the given one. | standard output | |
PASSED | 00d0b360e07b8c6fd2fbdf9c24380150 | train_002.jsonl | 1589466900 | You are given a garland consisting of $$$n$$$ lamps. States of the lamps are represented by the string $$$s$$$ of length $$$n$$$. The $$$i$$$-th character of the string $$$s_i$$$ equals '0' if the $$$i$$$-th lamp is turned off or '1' if the $$$i$$$-th lamp is turned on. You are also given a positive integer $$$k$$$.In ... | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.*;
public class Main {
static class node{
int a, b;
public node(int x, int y) {
a = x;
b = y;
}
}
static class Pair implements Comparable<Pair>{
int a;
int b;
// int ind;
// public Pair(int x, long y) {a = x;b=y;}
public Pair... | Java | ["6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n1\n1 1\n0"] | 1 second | ["1\n2\n5\n4\n0\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"brute force"
] | 8b28309055f13837eb1f51422fb91029 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 25~ 000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^6; 1 \le k \le n$$$) — the length of $$$s$$$ and the required period. The second l... | 1,900 | For each test case, print the answer — the minimum number of moves you need to make to obtain $$$k$$$-periodic garland from the given one. | standard output | |
PASSED | 6f809319b9950c753a96ffadedc1d11d | train_002.jsonl | 1589466900 | You are given a garland consisting of $$$n$$$ lamps. States of the lamps are represented by the string $$$s$$$ of length $$$n$$$. The $$$i$$$-th character of the string $$$s_i$$$ equals '0' if the $$$i$$$-th lamp is turned off or '1' if the $$$i$$$-th lamp is turned on. You are also given a positive integer $$$k$$$.In ... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Garland {
public static void main(String[] args) throws IOException {
new Garland().solve();
}
public void solve() throws IOExcept... | Java | ["6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n1\n1 1\n0"] | 1 second | ["1\n2\n5\n4\n0\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"brute force"
] | 8b28309055f13837eb1f51422fb91029 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 25~ 000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^6; 1 \le k \le n$$$) — the length of $$$s$$$ and the required period. The second l... | 1,900 | For each test case, print the answer — the minimum number of moves you need to make to obtain $$$k$$$-periodic garland from the given one. | standard output | |
PASSED | 810e90d916b192fe2bfb0b89a769c945 | train_002.jsonl | 1589466900 | You are given a garland consisting of $$$n$$$ lamps. States of the lamps are represented by the string $$$s$$$ of length $$$n$$$. The $$$i$$$-th character of the string $$$s_i$$$ equals '0' if the $$$i$$$-th lamp is turned off or '1' if the $$$i$$$-th lamp is turned on. You are also given a positive integer $$$k$$$.In ... | 256 megabytes | // package com.company.codeforces;
import java.util.Arrays;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int t=input.nextInt();
while (t-->0){
int n=input.nextInt();
int k=input.next... | Java | ["6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n1\n1 1\n0"] | 1 second | ["1\n2\n5\n4\n0\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"brute force"
] | 8b28309055f13837eb1f51422fb91029 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 25~ 000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^6; 1 \le k \le n$$$) — the length of $$$s$$$ and the required period. The second l... | 1,900 | For each test case, print the answer — the minimum number of moves you need to make to obtain $$$k$$$-periodic garland from the given one. | standard output | |
PASSED | d92ec94ec0d8a78e57bdc78b6da2410b | train_002.jsonl | 1326380700 | 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.He's got problems with... | 256 megabytes | import java.util.Scanner;
public class E
{
private static int res;
private static int n, m;
private static int [][] ret;
public static void main(String [] args)
{
Scanner in = new Scanner(System.in);
n = in.nextInt();
m = in.nextInt();
ret = new int[n][m];
... | Java | ["3 3", "5 6", "2 2"] | 3 seconds | ["1\nAAA\n.A.\n.A.", "4\nA..C..\nAAAC..\nABCCCD\n.B.DDD\nBBB..D", "0\n..\n.."] | null | Java 7 | standard input | [] | f29eba31c20246686b8427b7aeadd184 | The only line contains two space-separated integers n and m — the sizes of the warehouse (1 ≤ n, m ≤ 9). | 2,300 | In 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 turbop... | standard output | |
PASSED | 034a770596568f221b943f24d76b9fce | train_002.jsonl | 1326380700 | 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.He's got problems with... | 256 megabytes | import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
... | Java | ["3 3", "5 6", "2 2"] | 3 seconds | ["1\nAAA\n.A.\n.A.", "4\nA..C..\nAAAC..\nABCCCD\n.B.DDD\nBBB..D", "0\n..\n.."] | null | Java 7 | standard input | [] | f29eba31c20246686b8427b7aeadd184 | The only line contains two space-separated integers n and m — the sizes of the warehouse (1 ≤ n, m ≤ 9). | 2,300 | In 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 turbop... | standard output | |
PASSED | 0375c1831a2c9af39b9d08359a064e13 | train_002.jsonl | 1326380700 | 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.He's got problems with... | 256 megabytes | import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
... | Java | ["3 3", "5 6", "2 2"] | 3 seconds | ["1\nAAA\n.A.\n.A.", "4\nA..C..\nAAAC..\nABCCCD\n.B.DDD\nBBB..D", "0\n..\n.."] | null | Java 7 | standard input | [] | f29eba31c20246686b8427b7aeadd184 | The only line contains two space-separated integers n and m — the sizes of the warehouse (1 ≤ n, m ≤ 9). | 2,300 | In 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 turbop... | standard output | |
PASSED | 58d38f4c1293d6fae36d4ed8dd3e5fe2 | train_002.jsonl | 1504702500 | Ilya is sitting in a waiting area of Metropolis airport and is bored of looking at time table that shows again and again that his plane is delayed. So he took out a sheet of paper and decided to solve some problems.First Ilya has drawn a grid of size n × n and marked n squares on it, such that no two marked squares sha... | 512 megabytes |
import java.io.*;
import java.util.*;
import java.util.function.IntConsumer;
public class Solution {
static MyScanner sc;
private static PrintWriter out;
static long M = 1000000007;
public static void main(String[] s) throws Exception {
StringBuilder stringBuilder = new StringBuilder();
// ... | Java | ["2 3\n1 2\n1 1 1 1\n1 1 1 2\n1 1 2 2", "4 2\n1 3 2 4\n4 1 4 4\n1 1 2 3"] | 2 seconds | ["1\n1\n1", "3\n5"] | NoteThe first sample test has one beautiful rectangle that occupies the whole grid, therefore the answer to any query is 1.In the second sample test the first query rectangle intersects 3 beautiful rectangles, as shown on the picture below: There are 5 beautiful rectangles that intersect the second query rectangle, as... | Java 8 | standard input | [
"data structures"
] | bc834c0aa602a8ba789b676affb0b33a | The first line of input contains two integers n and q (2 ≤ n ≤ 200 000, 1 ≤ q ≤ 200 000) — the size of the grid and the number of query rectangles. The second line contains n integers p1, p2, ..., pn, separated by spaces (1 ≤ pi ≤ n, all pi are different), they specify grid squares marked by Ilya: in column i he has ma... | 2,100 | For each query rectangle output its beauty degree on a separate line. | standard output | |
PASSED | c7376ea9e2561b06cd277db52aace5c0 | train_002.jsonl | 1504702500 | Ilya is sitting in a waiting area of Metropolis airport and is bored of looking at time table that shows again and again that his plane is delayed. So he took out a sheet of paper and decided to solve some problems.First Ilya has drawn a grid of size n × n and marked n squares on it, such that no two marked squares sha... | 512 megabytes | // practice with rainboy
import java.io.*;
import java.util.*;
public class CF853C {
static long[] aa;
static int n, m;
static class V {
int i, j, h;
V(int i, int j, int h) {
this.i = i; this.j = j; this.h = h;
}
}
static V[] vv;
static int[] tt;
static void update(int i) {
while (i < n) {
tt[i]++... | Java | ["2 3\n1 2\n1 1 1 1\n1 1 1 2\n1 1 2 2", "4 2\n1 3 2 4\n4 1 4 4\n1 1 2 3"] | 2 seconds | ["1\n1\n1", "3\n5"] | NoteThe first sample test has one beautiful rectangle that occupies the whole grid, therefore the answer to any query is 1.In the second sample test the first query rectangle intersects 3 beautiful rectangles, as shown on the picture below: There are 5 beautiful rectangles that intersect the second query rectangle, as... | Java 8 | standard input | [
"data structures"
] | bc834c0aa602a8ba789b676affb0b33a | The first line of input contains two integers n and q (2 ≤ n ≤ 200 000, 1 ≤ q ≤ 200 000) — the size of the grid and the number of query rectangles. The second line contains n integers p1, p2, ..., pn, separated by spaces (1 ≤ pi ≤ n, all pi are different), they specify grid squares marked by Ilya: in column i he has ma... | 2,100 | For each query rectangle output its beauty degree on a separate line. | standard output | |
PASSED | 53d67f2ab1a3f547251609ec9d24b149 | train_002.jsonl | 1504702500 | Ilya is sitting in a waiting area of Metropolis airport and is bored of looking at time table that shows again and again that his plane is delayed. So he took out a sheet of paper and decided to solve some problems.First Ilya has drawn a grid of size n × n and marked n squares on it, such that no two marked squares sha... | 512 megabytes | import java.io.*;
import java.util.*;
/*
6 1
1 5 3 4 2 6
3 3 4 4
*/
public class C {
static InputStream is;
static long[] ans;
public static void main(String[] args) throws IOException {
is = System.in;
int n = ni();
int q = ni();
int[] p = new int[n];
int[] prev = new int[n];
for (int i = 0; i ... | Java | ["2 3\n1 2\n1 1 1 1\n1 1 1 2\n1 1 2 2", "4 2\n1 3 2 4\n4 1 4 4\n1 1 2 3"] | 2 seconds | ["1\n1\n1", "3\n5"] | NoteThe first sample test has one beautiful rectangle that occupies the whole grid, therefore the answer to any query is 1.In the second sample test the first query rectangle intersects 3 beautiful rectangles, as shown on the picture below: There are 5 beautiful rectangles that intersect the second query rectangle, as... | Java 8 | standard input | [
"data structures"
] | bc834c0aa602a8ba789b676affb0b33a | The first line of input contains two integers n and q (2 ≤ n ≤ 200 000, 1 ≤ q ≤ 200 000) — the size of the grid and the number of query rectangles. The second line contains n integers p1, p2, ..., pn, separated by spaces (1 ≤ pi ≤ n, all pi are different), they specify grid squares marked by Ilya: in column i he has ma... | 2,100 | For each query rectangle output its beauty degree on a separate line. | standard output | |
PASSED | d4001ee037e599d51a151fa225d75a94 | train_002.jsonl | 1504702500 | Ilya is sitting in a waiting area of Metropolis airport and is bored of looking at time table that shows again and again that his plane is delayed. So he took out a sheet of paper and decided to solve some problems.First Ilya has drawn a grid of size n × n and marked n squares on it, such that no two marked squares sha... | 512 megabytes | import java.io.*;
import java.math.*;
import java.util.*;
public class Boredom
{
InputStream in;
PrintWriter out;
long tree[];
int left[],right[];
int root[];
int MAX=(int)2e5+7;
int MAXN=25*((int)1e6);
int nnode=1;
void solve()
{
int n=ni();
int q=ni();
tree = new long[MAXN];
left = new i... | Java | ["2 3\n1 2\n1 1 1 1\n1 1 1 2\n1 1 2 2", "4 2\n1 3 2 4\n4 1 4 4\n1 1 2 3"] | 2 seconds | ["1\n1\n1", "3\n5"] | NoteThe first sample test has one beautiful rectangle that occupies the whole grid, therefore the answer to any query is 1.In the second sample test the first query rectangle intersects 3 beautiful rectangles, as shown on the picture below: There are 5 beautiful rectangles that intersect the second query rectangle, as... | Java 8 | standard input | [
"data structures"
] | bc834c0aa602a8ba789b676affb0b33a | The first line of input contains two integers n and q (2 ≤ n ≤ 200 000, 1 ≤ q ≤ 200 000) — the size of the grid and the number of query rectangles. The second line contains n integers p1, p2, ..., pn, separated by spaces (1 ≤ pi ≤ n, all pi are different), they specify grid squares marked by Ilya: in column i he has ma... | 2,100 | For each query rectangle output its beauty degree on a separate line. | standard output | |
PASSED | 65987494e6576704c2a2ae899572fe9b | train_002.jsonl | 1504702500 | Ilya is sitting in a waiting area of Metropolis airport and is bored of looking at time table that shows again and again that his plane is delayed. So he took out a sheet of paper and decided to solve some problems.First Ilya has drawn a grid of size n × n and marked n squares on it, such that no two marked squares sha... | 512 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOExcept... | Java | ["2 3\n1 2\n1 1 1 1\n1 1 1 2\n1 1 2 2", "4 2\n1 3 2 4\n4 1 4 4\n1 1 2 3"] | 2 seconds | ["1\n1\n1", "3\n5"] | NoteThe first sample test has one beautiful rectangle that occupies the whole grid, therefore the answer to any query is 1.In the second sample test the first query rectangle intersects 3 beautiful rectangles, as shown on the picture below: There are 5 beautiful rectangles that intersect the second query rectangle, as... | Java 8 | standard input | [
"data structures"
] | bc834c0aa602a8ba789b676affb0b33a | The first line of input contains two integers n and q (2 ≤ n ≤ 200 000, 1 ≤ q ≤ 200 000) — the size of the grid and the number of query rectangles. The second line contains n integers p1, p2, ..., pn, separated by spaces (1 ≤ pi ≤ n, all pi are different), they specify grid squares marked by Ilya: in column i he has ma... | 2,100 | For each query rectangle output its beauty degree on a separate line. | standard output |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.