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 | 28de88116a4d6e471405d13195bbd645 | train_000.jsonl | 1542033300 | You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.You have to remove at most one (i.e. zero or one) character of this string in such a way that the string you obtain will be lexicographically smallest among all strings that can be obtained using this operation.String $$$s = s_1 s_2 \dots s_n$... | 256 megabytes |
import java.io.*;
import java.util.*;
public class Educational_Codeforces_Round_54_A {
public static void main(String[] args) {
InputReader reader = new InputReader(System.in);
int number = reader.nextInt();
String result = "", s = reader.next();
char[] arr = s.toCharArray();
boolean check = false;
for ... | Java | ["3\naaa", "5\nabcda"] | 1 second | ["aa", "abca"] | NoteIn the first example you can remove any character of $$$s$$$ to obtain the string "aa".In the second example "abca" < "abcd" < "abcda" < "abda" < "acda" < "bcda". | Java 8 | standard input | [
"greedy",
"strings"
] | c01fc2cb6efc7eef290be12015f8d920 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the length of $$$s$$$. The second line of the input contains exactly $$$n$$$ lowercase Latin letters — the string $$$s$$$. | 1,200 | Print one string — the smallest possible lexicographically string that can be obtained by removing at most one character from the string $$$s$$$. | standard output | |
PASSED | 701108101873be916944bfeef9d68c34 | train_000.jsonl | 1542033300 | You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.You have to remove at most one (i.e. zero or one) character of this string in such a way that the string you obtain will be lexicographically smallest among all strings that can be obtained using this operation.String $$$s = s_1 s_2 \dots s_n$... | 256 megabytes | /**
* 8
* rkqggsab
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int length = Integer.parseInt(br.read... | Java | ["3\naaa", "5\nabcda"] | 1 second | ["aa", "abca"] | NoteIn the first example you can remove any character of $$$s$$$ to obtain the string "aa".In the second example "abca" < "abcd" < "abcda" < "abda" < "acda" < "bcda". | Java 8 | standard input | [
"greedy",
"strings"
] | c01fc2cb6efc7eef290be12015f8d920 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the length of $$$s$$$. The second line of the input contains exactly $$$n$$$ lowercase Latin letters — the string $$$s$$$. | 1,200 | Print one string — the smallest possible lexicographically string that can be obtained by removing at most one character from the string $$$s$$$. | standard output | |
PASSED | 12d975abbb277190da08db2bc21e6eff | train_000.jsonl | 1542033300 | You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.You have to remove at most one (i.e. zero or one) character of this string in such a way that the string you obtain will be lexicographically smallest among all strings that can be obtained using this operation.String $$$s = s_1 s_2 \dots s_n$... | 256 megabytes | import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
public class Main {
public static void main(String[] args) throws IOException {
InputReader scan = new InputReader();
int n = scan.nextInt();
String in = scan.next();
boolean found = false;
for (int i = 0; i < n-1; i++) {
... | Java | ["3\naaa", "5\nabcda"] | 1 second | ["aa", "abca"] | NoteIn the first example you can remove any character of $$$s$$$ to obtain the string "aa".In the second example "abca" < "abcd" < "abcda" < "abda" < "acda" < "bcda". | Java 8 | standard input | [
"greedy",
"strings"
] | c01fc2cb6efc7eef290be12015f8d920 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the length of $$$s$$$. The second line of the input contains exactly $$$n$$$ lowercase Latin letters — the string $$$s$$$. | 1,200 | Print one string — the smallest possible lexicographically string that can be obtained by removing at most one character from the string $$$s$$$. | standard output | |
PASSED | 68722ed906a4212ed030ef1d8d5cb4d3 | train_000.jsonl | 1542033300 | You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.You have to remove at most one (i.e. zero or one) character of this string in such a way that the string you obtain will be lexicographically smallest among all strings that can be obtained using this operation.String $$$s = s_1 s_2 \dots s_n$... | 256 megabytes | import java.util.Scanner;
public class MinimizingTheSreing {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scn = new Scanner(System.in);
int N = scn.nextInt();
String s = scn.next();
if (N == 1) {
if (s.charAt(0) != 'a') {
System.out.println("a");
} else {
... | Java | ["3\naaa", "5\nabcda"] | 1 second | ["aa", "abca"] | NoteIn the first example you can remove any character of $$$s$$$ to obtain the string "aa".In the second example "abca" < "abcd" < "abcda" < "abda" < "acda" < "bcda". | Java 8 | standard input | [
"greedy",
"strings"
] | c01fc2cb6efc7eef290be12015f8d920 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the length of $$$s$$$. The second line of the input contains exactly $$$n$$$ lowercase Latin letters — the string $$$s$$$. | 1,200 | Print one string — the smallest possible lexicographically string that can be obtained by removing at most one character from the string $$$s$$$. | standard output | |
PASSED | 5a26aff6161834a0084359dc7aebe917 | train_000.jsonl | 1542033300 | You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.You have to remove at most one (i.e. zero or one) character of this string in such a way that the string you obtain will be lexicographically smallest among all strings that can be obtained using this operation.String $$$s = s_1 s_2 \dots s_n$... | 256 megabytes | import java.util.*;
import java.lang.Math;
public class A {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
sc.nextLine();
boolean open = true;
char[] arr = sc.nextLine().toCharArray();
for (int i=0; i... | Java | ["3\naaa", "5\nabcda"] | 1 second | ["aa", "abca"] | NoteIn the first example you can remove any character of $$$s$$$ to obtain the string "aa".In the second example "abca" < "abcd" < "abcda" < "abda" < "acda" < "bcda". | Java 8 | standard input | [
"greedy",
"strings"
] | c01fc2cb6efc7eef290be12015f8d920 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the length of $$$s$$$. The second line of the input contains exactly $$$n$$$ lowercase Latin letters — the string $$$s$$$. | 1,200 | Print one string — the smallest possible lexicographically string that can be obtained by removing at most one character from the string $$$s$$$. | standard output | |
PASSED | f307899a8c25995bcd09c2c1ed7c1816 | train_000.jsonl | 1542033300 | You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.You have to remove at most one (i.e. zero or one) character of this string in such a way that the string you obtain will be lexicographically smallest among all strings that can be obtained using this operation.String $$$s = s_1 s_2 \dots s_n$... | 256 megabytes |
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
int t = in.nextInt();
in.nextLine();
String s = in.nextLine();
StringBuilder temp = new... | Java | ["3\naaa", "5\nabcda"] | 1 second | ["aa", "abca"] | NoteIn the first example you can remove any character of $$$s$$$ to obtain the string "aa".In the second example "abca" < "abcd" < "abcda" < "abda" < "acda" < "bcda". | Java 8 | standard input | [
"greedy",
"strings"
] | c01fc2cb6efc7eef290be12015f8d920 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the length of $$$s$$$. The second line of the input contains exactly $$$n$$$ lowercase Latin letters — the string $$$s$$$. | 1,200 | Print one string — the smallest possible lexicographically string that can be obtained by removing at most one character from the string $$$s$$$. | standard output | |
PASSED | 368275f317ae54e1be78dc375c03978a | train_000.jsonl | 1542033300 | You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.You have to remove at most one (i.e. zero or one) character of this string in such a way that the string you obtain will be lexicographically smallest among all strings that can be obtained using this operation.String $$$s = s_1 s_2 \dots s_n$... | 256 megabytes | import java.util.*;
import java.io.*;
public class a{
static Scanner sc=new Scanner(System.in);
public static void main(String [] args){
int n=sc.nextInt();
String s=sc.next();
StringBuilder ss=new StringBuilder("");
boolean found=false;
for(int i=0;i<n-1;i++){
... | Java | ["3\naaa", "5\nabcda"] | 1 second | ["aa", "abca"] | NoteIn the first example you can remove any character of $$$s$$$ to obtain the string "aa".In the second example "abca" < "abcd" < "abcda" < "abda" < "acda" < "bcda". | Java 8 | standard input | [
"greedy",
"strings"
] | c01fc2cb6efc7eef290be12015f8d920 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the length of $$$s$$$. The second line of the input contains exactly $$$n$$$ lowercase Latin letters — the string $$$s$$$. | 1,200 | Print one string — the smallest possible lexicographically string that can be obtained by removing at most one character from the string $$$s$$$. | standard output | |
PASSED | 81f200cc30c00464a973aa4e3349dddb | train_000.jsonl | 1542033300 | You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.You have to remove at most one (i.e. zero or one) character of this string in such a way that the string you obtain will be lexicographically smallest among all strings that can be obtained using this operation.String $$$s = s_1 s_2 \dots s_n$... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner();
PrintWriter pw = new PrintWriter(Sy... | Java | ["3\naaa", "5\nabcda"] | 1 second | ["aa", "abca"] | NoteIn the first example you can remove any character of $$$s$$$ to obtain the string "aa".In the second example "abca" < "abcd" < "abcda" < "abda" < "acda" < "bcda". | Java 8 | standard input | [
"greedy",
"strings"
] | c01fc2cb6efc7eef290be12015f8d920 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the length of $$$s$$$. The second line of the input contains exactly $$$n$$$ lowercase Latin letters — the string $$$s$$$. | 1,200 | Print one string — the smallest possible lexicographically string that can be obtained by removing at most one character from the string $$$s$$$. | standard output | |
PASSED | 5de4a73f6c329d5d1d44bbbca838dfc3 | train_000.jsonl | 1542033300 | You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.You have to remove at most one (i.e. zero or one) character of this string in such a way that the string you obtain will be lexicographically smallest among all strings that can be obtained using this operation.String $$$s = s_1 s_2 \dots s_n$... | 256 megabytes | import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int n = Integer.parseInt(sc.next());
String s = sc.next();
TreeSet set = new TreeSet();
for (int i = 0; i < s.length(); i++) {
set.add(s.charAt(... | Java | ["3\naaa", "5\nabcda"] | 1 second | ["aa", "abca"] | NoteIn the first example you can remove any character of $$$s$$$ to obtain the string "aa".In the second example "abca" < "abcd" < "abcda" < "abda" < "acda" < "bcda". | Java 8 | standard input | [
"greedy",
"strings"
] | c01fc2cb6efc7eef290be12015f8d920 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the length of $$$s$$$. The second line of the input contains exactly $$$n$$$ lowercase Latin letters — the string $$$s$$$. | 1,200 | Print one string — the smallest possible lexicographically string that can be obtained by removing at most one character from the string $$$s$$$. | standard output | |
PASSED | d577590a193743c551a67c3600d22226 | train_000.jsonl | 1542033300 | You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.You have to remove at most one (i.e. zero or one) character of this string in such a way that the string you obtain will be lexicographically smallest among all strings that can be obtained using this operation.String $$$s = s_1 s_2 \dots s_n$... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main (String[] args) {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
try {
int n = Integer.parseInt(reader.readLine());
... | Java | ["3\naaa", "5\nabcda"] | 1 second | ["aa", "abca"] | NoteIn the first example you can remove any character of $$$s$$$ to obtain the string "aa".In the second example "abca" < "abcd" < "abcda" < "abda" < "acda" < "bcda". | Java 8 | standard input | [
"greedy",
"strings"
] | c01fc2cb6efc7eef290be12015f8d920 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the length of $$$s$$$. The second line of the input contains exactly $$$n$$$ lowercase Latin letters — the string $$$s$$$. | 1,200 | Print one string — the smallest possible lexicographically string that can be obtained by removing at most one character from the string $$$s$$$. | standard output | |
PASSED | 5db3d482f0deba71abcd395d1512eddb | train_000.jsonl | 1542033300 | You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.You have to remove at most one (i.e. zero or one) character of this string in such a way that the string you obtain will be lexicographically smallest among all strings that can be obtained using this operation.String $$$s = s_1 s_2 \dots s_n$... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author Pranay2516
*/
public class... | Java | ["3\naaa", "5\nabcda"] | 1 second | ["aa", "abca"] | NoteIn the first example you can remove any character of $$$s$$$ to obtain the string "aa".In the second example "abca" < "abcd" < "abcda" < "abda" < "acda" < "bcda". | Java 8 | standard input | [
"greedy",
"strings"
] | c01fc2cb6efc7eef290be12015f8d920 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the length of $$$s$$$. The second line of the input contains exactly $$$n$$$ lowercase Latin letters — the string $$$s$$$. | 1,200 | Print one string — the smallest possible lexicographically string that can be obtained by removing at most one character from the string $$$s$$$. | standard output | |
PASSED | 23051ce585e203c4aa53baf4f87488d1 | train_000.jsonl | 1542033300 | You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.You have to remove at most one (i.e. zero or one) character of this string in such a way that the string you obtain will be lexicographically smallest among all strings that can be obtained using this operation.String $$$s = s_1 s_2 \dots s_n$... | 256 megabytes | import java.util.Scanner;
public class MinimizingTheString {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
String ns = sc.next();
for (int i = 0; i < n-1; i++) {
if (ns.charAt(i) > ns.charAt(i + 1)) {
System.out.println(ns.substring(0, i) + ns.subs... | Java | ["3\naaa", "5\nabcda"] | 1 second | ["aa", "abca"] | NoteIn the first example you can remove any character of $$$s$$$ to obtain the string "aa".In the second example "abca" < "abcd" < "abcda" < "abda" < "acda" < "bcda". | Java 8 | standard input | [
"greedy",
"strings"
] | c01fc2cb6efc7eef290be12015f8d920 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the length of $$$s$$$. The second line of the input contains exactly $$$n$$$ lowercase Latin letters — the string $$$s$$$. | 1,200 | Print one string — the smallest possible lexicographically string that can be obtained by removing at most one character from the string $$$s$$$. | standard output | |
PASSED | 02bbf70c2192d15179a0683783c21b3b | train_000.jsonl | 1542033300 | You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.You have to remove at most one (i.e. zero or one) character of this string in such a way that the string you obtain will be lexicographically smallest among all strings that can be obtained using this operation.String $$$s = s_1 s_2 \dots s_n$... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
public static int mod = 1000000007;
public static void solve(InputReader in) {
int n = in.readInt();
char s[] = in.readString().toCharArray();
int index = n-1;
for(int i = 0; i<n-1; i++) {
if(s[i] > s[i+1]) {
index = i;
break;
}
... | Java | ["3\naaa", "5\nabcda"] | 1 second | ["aa", "abca"] | NoteIn the first example you can remove any character of $$$s$$$ to obtain the string "aa".In the second example "abca" < "abcd" < "abcda" < "abda" < "acda" < "bcda". | Java 8 | standard input | [
"greedy",
"strings"
] | c01fc2cb6efc7eef290be12015f8d920 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the length of $$$s$$$. The second line of the input contains exactly $$$n$$$ lowercase Latin letters — the string $$$s$$$. | 1,200 | Print one string — the smallest possible lexicographically string that can be obtained by removing at most one character from the string $$$s$$$. | standard output | |
PASSED | 62e714cfbf0b07dbe2f950d92953356c | train_000.jsonl | 1542033300 | You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.You have to remove at most one (i.e. zero or one) character of this string in such a way that the string you obtain will be lexicographically smallest among all strings that can be obtained using this operation.String $$$s = s_1 s_2 \dots s_n$... | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
import static java.lang.Math.*;
public class Cf182 implements Runnable
{
static class InputReader
{
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
private SpaceCha... | Java | ["3\naaa", "5\nabcda"] | 1 second | ["aa", "abca"] | NoteIn the first example you can remove any character of $$$s$$$ to obtain the string "aa".In the second example "abca" < "abcd" < "abcda" < "abda" < "acda" < "bcda". | Java 8 | standard input | [
"greedy",
"strings"
] | c01fc2cb6efc7eef290be12015f8d920 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the length of $$$s$$$. The second line of the input contains exactly $$$n$$$ lowercase Latin letters — the string $$$s$$$. | 1,200 | Print one string — the smallest possible lexicographically string that can be obtained by removing at most one character from the string $$$s$$$. | standard output | |
PASSED | a7bb2f972336ed9b17e85afc0a7cdcc7 | train_000.jsonl | 1542033300 | You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.You have to remove at most one (i.e. zero or one) character of this string in such a way that the string you obtain will be lexicographically smallest among all strings that can be obtained using this operation.String $$$s = s_1 s_2 \dots s_n$... | 256 megabytes | import java.util.Scanner;
public class MinimizingTheString1076A {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
scan.nextLine();
String str = scan.nextLine();
StringBuilder temp = new StringBuilder(str);
int index = n-1;
for(int i... | Java | ["3\naaa", "5\nabcda"] | 1 second | ["aa", "abca"] | NoteIn the first example you can remove any character of $$$s$$$ to obtain the string "aa".In the second example "abca" < "abcd" < "abcda" < "abda" < "acda" < "bcda". | Java 8 | standard input | [
"greedy",
"strings"
] | c01fc2cb6efc7eef290be12015f8d920 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the length of $$$s$$$. The second line of the input contains exactly $$$n$$$ lowercase Latin letters — the string $$$s$$$. | 1,200 | Print one string — the smallest possible lexicographically string that can be obtained by removing at most one character from the string $$$s$$$. | standard output | |
PASSED | d0b80c06cca956d3ca5519ca8bba83e4 | train_000.jsonl | 1542033300 | You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.You have to remove at most one (i.e. zero or one) character of this string in such a way that the string you obtain will be lexicographically smallest among all strings that can be obtained using this operation.String $$$s = s_1 s_2 \dots s_n$... | 256 megabytes | import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
... | Java | ["3\naaa", "5\nabcda"] | 1 second | ["aa", "abca"] | NoteIn the first example you can remove any character of $$$s$$$ to obtain the string "aa".In the second example "abca" < "abcd" < "abcda" < "abda" < "acda" < "bcda". | Java 8 | standard input | [
"greedy",
"strings"
] | c01fc2cb6efc7eef290be12015f8d920 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the length of $$$s$$$. The second line of the input contains exactly $$$n$$$ lowercase Latin letters — the string $$$s$$$. | 1,200 | Print one string — the smallest possible lexicographically string that can be obtained by removing at most one character from the string $$$s$$$. | standard output | |
PASSED | 0faaf5151a4ce3d4005030d462c21506 | train_000.jsonl | 1542033300 | You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.You have to remove at most one (i.e. zero or one) character of this string in such a way that the string you obtain will be lexicographically smallest among all strings that can be obtained using this operation.String $$$s = s_1 s_2 \dots s_n$... | 256 megabytes | import java.util.Scanner;
public class Main {
//COmment
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
input.nextInt();
String full=input.next();
for(int x=1;x<full.length();x++){
if(full.charAt(x)<full.charAt(x-1)){
System.out.println(full.substring(0,x... | Java | ["3\naaa", "5\nabcda"] | 1 second | ["aa", "abca"] | NoteIn the first example you can remove any character of $$$s$$$ to obtain the string "aa".In the second example "abca" < "abcd" < "abcda" < "abda" < "acda" < "bcda". | Java 8 | standard input | [
"greedy",
"strings"
] | c01fc2cb6efc7eef290be12015f8d920 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the length of $$$s$$$. The second line of the input contains exactly $$$n$$$ lowercase Latin letters — the string $$$s$$$. | 1,200 | Print one string — the smallest possible lexicographically string that can be obtained by removing at most one character from the string $$$s$$$. | standard output | |
PASSED | b40aed0e26d6e0704ccfde9fb4e88db3 | train_000.jsonl | 1542033300 | You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.You have to remove at most one (i.e. zero or one) character of this string in such a way that the string you obtain will be lexicographically smallest among all strings that can be obtained using this operation.String $$$s = s_1 s_2 \dots s_n$... | 256 megabytes | import java.util.*;
import java.io.IOException;
public class aa
{
public static void main(String[]args)throws IOException
{ Scanner sc=new Scanner (System.in);
int n=sc.nextInt();
String s=sc.next();
String ns=""; char max='$';
for(int i=0;i<n-1;i++)
{
if(s.charAt(i)>s.charAt(i+1))
{max=s.... | Java | ["3\naaa", "5\nabcda"] | 1 second | ["aa", "abca"] | NoteIn the first example you can remove any character of $$$s$$$ to obtain the string "aa".In the second example "abca" < "abcd" < "abcda" < "abda" < "acda" < "bcda". | Java 8 | standard input | [
"greedy",
"strings"
] | c01fc2cb6efc7eef290be12015f8d920 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the length of $$$s$$$. The second line of the input contains exactly $$$n$$$ lowercase Latin letters — the string $$$s$$$. | 1,200 | Print one string — the smallest possible lexicographically string that can be obtained by removing at most one character from the string $$$s$$$. | standard output | |
PASSED | 6a4fdfeb2bf02e43bed7b3fa524f05b4 | train_000.jsonl | 1542033300 | You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.You have to remove at most one (i.e. zero or one) character of this string in such a way that the string you obtain will be lexicographically smallest among all strings that can be obtained using this operation.String $$$s = s_1 s_2 \dots s_n$... | 256 megabytes | import java.util.*;
import java.io.IOException;
public class againtwentyfive
{
public static void main(String[]args)throws IOException
{ Scanner sc=new Scanner (System.in);
int n=sc.nextInt();
String s=sc.next();
int c=0;
for(int i=0;i<n-1;i++)
{
if(s.charAt(i)>s.charAt(i+1))
{s=s.substrin... | Java | ["3\naaa", "5\nabcda"] | 1 second | ["aa", "abca"] | NoteIn the first example you can remove any character of $$$s$$$ to obtain the string "aa".In the second example "abca" < "abcd" < "abcda" < "abda" < "acda" < "bcda". | Java 8 | standard input | [
"greedy",
"strings"
] | c01fc2cb6efc7eef290be12015f8d920 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the length of $$$s$$$. The second line of the input contains exactly $$$n$$$ lowercase Latin letters — the string $$$s$$$. | 1,200 | Print one string — the smallest possible lexicographically string that can be obtained by removing at most one character from the string $$$s$$$. | standard output | |
PASSED | 2fcf338c29a45a6b058f74ae7a633022 | train_000.jsonl | 1542033300 | You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.You have to remove at most one (i.e. zero or one) character of this string in such a way that the string you obtain will be lexicographically smallest among all strings that can be obtained using this operation.String $$$s = s_1 s_2 \dots s_n$... | 256 megabytes | import java.util.*;
import java.io.IOException;
public class againtwentyfive
{
public static void main(String[]args)throws IOException
{ Scanner sc=new Scanner (System.in);
int n=sc.nextInt();
String s=sc.next();
int c=0;
for(int i=0;i<n-1;i++)
{
if(s.charAt(i)>s.charAt(i+1))
{s=s.substrin... | Java | ["3\naaa", "5\nabcda"] | 1 second | ["aa", "abca"] | NoteIn the first example you can remove any character of $$$s$$$ to obtain the string "aa".In the second example "abca" < "abcd" < "abcda" < "abda" < "acda" < "bcda". | Java 8 | standard input | [
"greedy",
"strings"
] | c01fc2cb6efc7eef290be12015f8d920 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the length of $$$s$$$. The second line of the input contains exactly $$$n$$$ lowercase Latin letters — the string $$$s$$$. | 1,200 | Print one string — the smallest possible lexicographically string that can be obtained by removing at most one character from the string $$$s$$$. | standard output | |
PASSED | 3838f5021e78037e827d7ed425818dec | train_000.jsonl | 1542033300 | You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.You have to remove at most one (i.e. zero or one) character of this string in such a way that the string you obtain will be lexicographically smallest among all strings that can be obtained using this operation.String $$$s = s_1 s_2 \dots s_n$... | 256 megabytes | import java.util.Scanner;
public class A {
public static void main(String[] args) {
Scanner jin = new Scanner(System.in);
jin.nextLine();
String str = jin.nextLine();
for (int i = 0; i < str.length() - 1; ++i) {
if (str.charAt(i) > str.charAt(i + 1)) {
System.out.println(str.substring(0, i) + str.subs... | Java | ["3\naaa", "5\nabcda"] | 1 second | ["aa", "abca"] | NoteIn the first example you can remove any character of $$$s$$$ to obtain the string "aa".In the second example "abca" < "abcd" < "abcda" < "abda" < "acda" < "bcda". | Java 8 | standard input | [
"greedy",
"strings"
] | c01fc2cb6efc7eef290be12015f8d920 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the length of $$$s$$$. The second line of the input contains exactly $$$n$$$ lowercase Latin letters — the string $$$s$$$. | 1,200 | Print one string — the smallest possible lexicographically string that can be obtained by removing at most one character from the string $$$s$$$. | standard output | |
PASSED | 5bfbb805c8798a9e12f26c1d812f7427 | train_000.jsonl | 1542033300 | You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.You have to remove at most one (i.e. zero or one) character of this string in such a way that the string you obtain will be lexicographically smallest among all strings that can be obtained using this operation.String $$$s = s_1 s_2 \dots s_n$... | 256 megabytes | import java.util.Scanner;
public class orffjab
{
public static void main(String[]args)
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
String s=sc.next();
int a=t-1;
int i=0;
while(i<t-1){
if((int)s.charAt(i)>(int)s.charAt(i+1)){
a=i;
break;
}
i++;
}
if(a==0){
System.out.p... | Java | ["3\naaa", "5\nabcda"] | 1 second | ["aa", "abca"] | NoteIn the first example you can remove any character of $$$s$$$ to obtain the string "aa".In the second example "abca" < "abcd" < "abcda" < "abda" < "acda" < "bcda". | Java 8 | standard input | [
"greedy",
"strings"
] | c01fc2cb6efc7eef290be12015f8d920 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the length of $$$s$$$. The second line of the input contains exactly $$$n$$$ lowercase Latin letters — the string $$$s$$$. | 1,200 | Print one string — the smallest possible lexicographically string that can be obtained by removing at most one character from the string $$$s$$$. | standard output | |
PASSED | 459d3f36523d1438b0c4829cdd6362e0 | train_000.jsonl | 1542033300 | You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.You have to remove at most one (i.e. zero or one) character of this string in such a way that the string you obtain will be lexicographically smallest among all strings that can be obtained using this operation.String $$$s = s_1 s_2 \dots s_n$... | 256 megabytes | import java.util.Scanner;
public class minimizingstring {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
String s = sc.next();
sc.close();
String ans = "";
for(int i = 0; i + 1 < n; i++) {
if(s.charAt(i) - s.charAt(i+1) > 0) {
ans = s.substri... | Java | ["3\naaa", "5\nabcda"] | 1 second | ["aa", "abca"] | NoteIn the first example you can remove any character of $$$s$$$ to obtain the string "aa".In the second example "abca" < "abcd" < "abcda" < "abda" < "acda" < "bcda". | Java 8 | standard input | [
"greedy",
"strings"
] | c01fc2cb6efc7eef290be12015f8d920 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the length of $$$s$$$. The second line of the input contains exactly $$$n$$$ lowercase Latin letters — the string $$$s$$$. | 1,200 | Print one string — the smallest possible lexicographically string that can be obtained by removing at most one character from the string $$$s$$$. | standard output | |
PASSED | bb76706c1617f8371dd77f6de43a5c77 | train_000.jsonl | 1542033300 | You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.You have to remove at most one (i.e. zero or one) character of this string in such a way that the string you obtain will be lexicographically smallest among all strings that can be obtained using this operation.String $$$s = s_1 s_2 \dots s_n$... | 256 megabytes | import java.io.*;
import java.util.*;
public class Towers {
public static void main(String args[]) {
Scanner input = new Scanner(System.in);
int n = input.nextInt();
String temp = input.nextLine();
String str = input.nextLine();
int to_delete = -1;
for ( int i = 0; i < ... | Java | ["3\naaa", "5\nabcda"] | 1 second | ["aa", "abca"] | NoteIn the first example you can remove any character of $$$s$$$ to obtain the string "aa".In the second example "abca" < "abcd" < "abcda" < "abda" < "acda" < "bcda". | Java 8 | standard input | [
"greedy",
"strings"
] | c01fc2cb6efc7eef290be12015f8d920 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the length of $$$s$$$. The second line of the input contains exactly $$$n$$$ lowercase Latin letters — the string $$$s$$$. | 1,200 | Print one string — the smallest possible lexicographically string that can be obtained by removing at most one character from the string $$$s$$$. | standard output | |
PASSED | e05a2cbc1df44a725c10b31a238f3c0b | train_000.jsonl | 1542033300 | You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.You have to remove at most one (i.e. zero or one) character of this string in such a way that the string you obtain will be lexicographically smallest among all strings that can be obtained using this operation.String $$$s = s_1 s_2 \dots s_n$... | 256 megabytes | import java.io.*;
import java.util.*;
public class MinimizeTheString
{
public static void main(String args[])throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(System.out);
int N = Integer.parseInt(br.readLine().trim());
String st =... | Java | ["3\naaa", "5\nabcda"] | 1 second | ["aa", "abca"] | NoteIn the first example you can remove any character of $$$s$$$ to obtain the string "aa".In the second example "abca" < "abcd" < "abcda" < "abda" < "acda" < "bcda". | Java 8 | standard input | [
"greedy",
"strings"
] | c01fc2cb6efc7eef290be12015f8d920 | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the length of $$$s$$$. The second line of the input contains exactly $$$n$$$ lowercase Latin letters — the string $$$s$$$. | 1,200 | Print one string — the smallest possible lexicographically string that can be obtained by removing at most one character from the string $$$s$$$. | standard output | |
PASSED | a79da74ac28f0c20909789c6f488b61b | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes | // Author: Param Singh <paramsingh258@gmail.com>
// Kefa and Park: http://codeforces.com/contest/580/problem/C
import java.io.*;
import java.util.*;
public class Kefa {
static class Node {
List<Node> children;
int id;
int num;
boolean cat;
int left, right;
Node() {
... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | 14582e854356d91cda08b0505e94592b | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes | import java.util.*;
public class Test {
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int m=sc.nextInt();
vertex[] v=new vertex[n];
for(int i=0;i<n;i++){
v[i]=new vertex(i,sc.nextInt());
}
for(int i=0;i<n-1;i++){
int a=sc.nextInt()-1;
int b=sc.nex... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | acd19cf84b46868d4701681a66751458 | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes | import java.lang.*;
import java.io.*;
import java.util.*;
public class Park {
public static void main(String[] args) throws java.lang.Exception {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
PrintWriter out = new PrintWriter(out... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | 050d41cd5b3c574b0b8875bec477442e | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.*;
public class C {
static int n;
static int m;
static boolean[] hasCat;
static List<Set<Integer>> graph;
static int answer;
public static void main(String[] args... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | 20c8ac2e8c33d88903e248148ce188a6 | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes | import java.io.*;
import java.util.*;
public class Solution {
private static int n, m, cnt;
private static boolean[] cat;
private static Map<Integer, List<Integer>> adjacency;
private static void dfs(int cur, int prev, int catCnt) {
if (cat[cur]) {
catCnt++;
if (catCnt... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | 921f8411b8dfc6474e1504f99e664164 | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes | import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Program {
static InputReader I = new InputReader(System.in);
static PrintWriter O = new PrintWriter(System.out);
static List<Integer>[] G;
static int[] isCat;
static int[] catCount;
static int m;
static int ans... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | 589004df5d4d659efa300c27ae56e8f3 | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class C {
private static class v {
boolean cat;
ArrayList<v> c = new ArrayList<>();
public v(boolean cat) {
this.cat = cat;
}
}
pr... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | 60c299066e09ab325d35a51b30fc4175 | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes | import java.io.*;
import java.util.ArrayList;
import java.util.Locale;
import java.util.StringTokenizer;
public class Main implements Runnable {
final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
BufferedReader in;
PrintWriter out;
StringTokenizer tok = new StringTokenizer("");
... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | 1c724218ccce85b1248c33436de34a55 | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes | import java.util.*;
import java.io.*;
public class Major {
static int decide[];
static ArrayList<Integer>list[];
static int ans = 0;
static boolean cont = true;
static boolean leaf[];
static int m;
static void dfs(int start,int tot,boolean visited[]){
visited[start] = true;
if(decide[start] == 1 && cont)tot++;
... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | 81fe9b644cfdef2f598f53f56502d109 | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes |
import java.awt.Point;
import java.io.BufferedOutputStream;
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.lang.reflect.Array;
import java.math.BigInteger;
import java.util.Arr... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | b9453821c983b4e3639e75d719bc485c | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes | import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;
public class Main {
public static int K = 0;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
boolean cats[] = new boolean[n];
LinkedList<Integer>[] ll ... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | 52d3d07c0bd2e50668d471545d62f81d | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes | import java.util.*;
public class C {
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
n = in.nextInt();
m = in.nextInt();
adj = new ArrayList[n];
for(int i = 0; i < n; i ++)
adj[i] = new ArrayList<Integer>();
cats = new boolean[n];
for(int i = 0; i < n; i ++)
cats[i] ... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | 82972d1c557ddb0496b53cb05a1552ca | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class Main {
static class... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | 59b3310e3f23c880942fb5bd1a981826 | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes | import java.io.*;
import java.util.*;
public class c2 {
BufferedReader br;
StringTokenizer in;
PrintWriter out;
public String nextToken() throws IOException {
while (in == null || !in.hasMoreTokens()) {
in = new StringTokenizer(br.readLine());
}
return in.nextToken();
}
public int nextInt() throws IOE... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | 7855da213d0a6f316082041ed57c6ca8 | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes | import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.Character.Subset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | b2cf343dd1276f36c892abadfd54f93f | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
/**
* Created by smalex on 22/09/15.
*/
public class P580C {
static BufferedReader in;
static StringTokenizer tok;
public static void main(String[] args) throws IOException {
in = new Buffered... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | bbb38e56dfd2595cb68fdebe668ba46d | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
import java.util.Map.Entry;
public class Main {
public static PrintWriter out;
public static void main(String args[]) {
MyScanner ... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | 1af064adeaf143e7ba53fafcbc4b3f5a | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Random;
import java.util.Stack;
import java.util.StringTokenizer;
public clas... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | 28d9be376841dba0b518737f339abb78 | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class Codeforces580C {
public static int leafCount(ArrayList<ArrayList<Integer>> tree, int rootParent, int root, int numCats, int maxCats, boolean[] hasCat... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | 7c27497657c61eb8e8493fc3e189c5a2 | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes |
import java.util.*;
import java.io.*;
public class Main {
public static int n,m,x,y,i,result;
public static boolean[] visited,catPresence;
public static ArrayList<Integer>[] adjacencyList;
public static ArrayList<Integer> leaves;
@SuppressWarnings("unchecked")
public static void main(String[] args) throws E... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | 457a97c8dc9aaa8b4df5743dcee4ce04 | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes | import java.util.*;
public class Solution{
static int count=0;
static void calc(int root,List<List<Integer>> adj,int par,int curr,int tag[],int m){
if(tag[root]==1)
curr++;
else{
if(curr>m)
return;
curr=0;
}
if(root!=... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | 52b2b64ef785f3416a927bfdf8167085 | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes | import java.io.*;
import java.math.*;
import java.util.*;
public class CF_580C_KefaAndPark
{
public static void main(String[] args) throws IOException
{
BufferedReader in = new BufferedReader( new InputStreamReader(System.in));
StringBuilder out = new StringBuilder("");
String line, lin... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | 457799abfbc84cb8a90338709928e5a7 | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.StringTokenizer;
public class Main {
static IO io;
static HashSet<Int... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | 4674799b6ed1ef153b1236334bfd50a6 | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class Main {
static int n,m,res=0;
static boolean[] cats;
static ArrayList<Integer>[] adj;
static boolean[] v;
static void dfs(int i,int cnt){
v[i]=true;
if(cnt>m)return;
boolean inside=false;
for(int j=0... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | be77abbe177b7cb739c7968db888ec30 | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
/**
*
* @author Hasan
*/
public class Main {
/**
* @param args the command line arguments
*/
... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | 67783248e59442df9b8531eaadc28aff | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;
public class C {
/**
* @param args
* @throws IOException
*/
public static void main(St... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | bd2d6b0dfb9c540513e78c72e3b30f6f | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes | //package codeforces;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class KefaAndPark
{
static boolean visited[];
static Vertex[] graph;
static int maxCats;
public static void main(String[] args) ... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | 9a634cdd09320b655df73a137f164930 | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.StringTokenizer;
public class Main
{
int n;
int threshold;
int layer[];
boolean visited[];
ArrayList<A... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | 01062a3e96ea4468492d27553176bfcb | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes | //package problems;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Vector;
public class Problems{
static int[] a = new int[100001], vis = new int[100001];
static ArrayList<Integer>[] G = new ArrayList[100001];
static int n, m, x, y, cnt;
public static void main (String[] ar... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | e6279e0c155b2d18d7d1584f10f73649 | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 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.util.Random;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
im... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | 6f475dfba2d0120e7c9b8b336c07f22d | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes | import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
public class C
{
/**
* Scanner class
*
* @author gouthamv... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | 2c7471a704306015903819d0563c4c3d | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes | import java.io.IOException;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class ACMSolution {
static class node{
public int color,con;
public in... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | 9be9f2b121a8818f5bc5710e63a601bd | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes | import java.io.IOException;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class ACMSolution {
static class node{
public int color,con;
public in... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | 1cbf0c7a154bfb281eff8125a277f5be | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes | import java.util.*;
public class KefaAndPark {
static int count = 0;
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
int n = Integer.parseInt(stdIn.next());
int k = Integer.parseInt(stdIn.next());
Vertex[] park = new Vertex[n+1];
for... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | 4ce00ff595ebed63d70571c6e1c39d90 | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;
public class KefaAndPark {
static int[] maxConsec, curConsec, visited;
static int ans;
static ArrayList<ArrayList<Integer>> adj;
static ArrayList... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | 267346349ea87bb3435cefa6d076ba55 | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes | import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Set;
import java.util.Map;
import java.util.List;
public class C321_Div2 {
static Map<Integer, List<Integer>> tree = new HashMap<Integer, List<Integer>>();
static Set<Integer> cats = new Hash... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | e66fb687b0bd178a4c2d7ecc93500f8c | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes |
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
public class C {
InputStream is;
PrintWriter out;
String INPUT = "12 3\n" +
"1... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | a22c76903301d558b52cb7782b61be49 | train_000.jsonl | 1442939400 | Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the verti... | 256 megabytes | import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
public class P580C {
private void run() {
int n = nextInt();
int m = nextInt();
Map<Integer, Boolean> vertexes ... | Java | ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"] | 2 seconds | ["2", "2"] | NoteLet us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if i... | Java 7 | standard input | [
"dfs and similar",
"trees",
"graphs"
] | 875e7048b7a254992b9f62b9365fcf9b | The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1... | 1,500 | A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats. | standard output | |
PASSED | 7c882db622d559fbf0cc1c2dc4ce57fb | train_000.jsonl | 1589286900 | Orac is studying number theory, and he is interested in the properties of divisors.For two positive integers $$$a$$$ and $$$b$$$, $$$a$$$ is a divisor of $$$b$$$ if and only if there exists an integer $$$c$$$, such that $$$a\cdot c=b$$$.For $$$n \ge 2$$$, we will denote as $$$f(n)$$$ the smallest positive divisor of $$... | 256 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.lang.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
Scanner sc=n... | Java | ["3\n5 1\n8 2\n3 4"] | 2 seconds | ["10\n12\n12"] | NoteIn the first query, $$$n=5$$$ and $$$k=1$$$. The divisors of $$$5$$$ are $$$1$$$ and $$$5$$$, the smallest one except $$$1$$$ is $$$5$$$. Therefore, the only operation adds $$$f(5)=5$$$ to $$$5$$$, and the result is $$$10$$$.In the second query, $$$n=8$$$ and $$$k=2$$$. The divisors of $$$8$$$ are $$$1,2,4,8$$$, wh... | Java 11 | standard input | [
"math"
] | 9fd9bc0a037b2948d60ac2bd5d57740f | The first line of the input is a single integer $$$t\ (1\le t\le 100)$$$: the number of times that Orac will ask you. Each of the next $$$t$$$ lines contains two positive integers $$$n,k\ (2\le n\le 10^6, 1\le k\le 10^9)$$$, corresponding to a query by Orac. It is guaranteed that the total sum of $$$n$$$ is at most $$$... | 900 | Print $$$t$$$ lines, the $$$i$$$-th of them should contain the final value of $$$n$$$ in the $$$i$$$-th query by Orac. | standard output | |
PASSED | a55da6cacdb54b14f58de38403dc34c7 | train_000.jsonl | 1589286900 | Orac is studying number theory, and he is interested in the properties of divisors.For two positive integers $$$a$$$ and $$$b$$$, $$$a$$$ is a divisor of $$$b$$$ if and only if there exists an integer $$$c$$$, such that $$$a\cdot c=b$$$.For $$$n \ge 2$$$, we will denote as $$$f(n)$$$ the smallest positive divisor of $$... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main
{
static PrintWriter out;
static class FastReader{
BufferedReader br;
StringTokenizer st;
public FastReader(){
br=new BufferedReader(new InputStreamReader(System.in));
out=new PrintWriter(System.out);
}
String next(){
while(st==nu... | Java | ["3\n5 1\n8 2\n3 4"] | 2 seconds | ["10\n12\n12"] | NoteIn the first query, $$$n=5$$$ and $$$k=1$$$. The divisors of $$$5$$$ are $$$1$$$ and $$$5$$$, the smallest one except $$$1$$$ is $$$5$$$. Therefore, the only operation adds $$$f(5)=5$$$ to $$$5$$$, and the result is $$$10$$$.In the second query, $$$n=8$$$ and $$$k=2$$$. The divisors of $$$8$$$ are $$$1,2,4,8$$$, wh... | Java 11 | standard input | [
"math"
] | 9fd9bc0a037b2948d60ac2bd5d57740f | The first line of the input is a single integer $$$t\ (1\le t\le 100)$$$: the number of times that Orac will ask you. Each of the next $$$t$$$ lines contains two positive integers $$$n,k\ (2\le n\le 10^6, 1\le k\le 10^9)$$$, corresponding to a query by Orac. It is guaranteed that the total sum of $$$n$$$ is at most $$$... | 900 | Print $$$t$$$ lines, the $$$i$$$-th of them should contain the final value of $$$n$$$ in the $$$i$$$-th query by Orac. | standard output | |
PASSED | 8349a3eb2f91e870eb7b5b2cd6e95801 | train_000.jsonl | 1589286900 | Orac is studying number theory, and he is interested in the properties of divisors.For two positive integers $$$a$$$ and $$$b$$$, $$$a$$$ is a divisor of $$$b$$$ if and only if there exists an integer $$$c$$$, such that $$$a\cdot c=b$$$.For $$$n \ge 2$$$, we will denote as $$$f(n)$$$ the smallest positive divisor of $$... | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
import static java.lang.Math.*;
public class Cf131 implements Runnable
{
static class InputReader
{
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int ... | Java | ["3\n5 1\n8 2\n3 4"] | 2 seconds | ["10\n12\n12"] | NoteIn the first query, $$$n=5$$$ and $$$k=1$$$. The divisors of $$$5$$$ are $$$1$$$ and $$$5$$$, the smallest one except $$$1$$$ is $$$5$$$. Therefore, the only operation adds $$$f(5)=5$$$ to $$$5$$$, and the result is $$$10$$$.In the second query, $$$n=8$$$ and $$$k=2$$$. The divisors of $$$8$$$ are $$$1,2,4,8$$$, wh... | Java 11 | standard input | [
"math"
] | 9fd9bc0a037b2948d60ac2bd5d57740f | The first line of the input is a single integer $$$t\ (1\le t\le 100)$$$: the number of times that Orac will ask you. Each of the next $$$t$$$ lines contains two positive integers $$$n,k\ (2\le n\le 10^6, 1\le k\le 10^9)$$$, corresponding to a query by Orac. It is guaranteed that the total sum of $$$n$$$ is at most $$$... | 900 | Print $$$t$$$ lines, the $$$i$$$-th of them should contain the final value of $$$n$$$ in the $$$i$$$-th query by Orac. | standard output | |
PASSED | 82247517dd3c7c0955451c785c8cdb6f | train_000.jsonl | 1589286900 | Orac is studying number theory, and he is interested in the properties of divisors.For two positive integers $$$a$$$ and $$$b$$$, $$$a$$$ is a divisor of $$$b$$$ if and only if there exists an integer $$$c$$$, such that $$$a\cdot c=b$$$.For $$$n \ge 2$$$, we will denote as $$$f(n)$$$ the smallest positive divisor of $$... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
static PrintWriter out;
static FastReader fr;
// make it false if Multiple test case is not in the question
final static boolean multipleTC = true;
// Global Variables
final static int MOD = (int) 1e9 + 7;
final static double INF = ... | Java | ["3\n5 1\n8 2\n3 4"] | 2 seconds | ["10\n12\n12"] | NoteIn the first query, $$$n=5$$$ and $$$k=1$$$. The divisors of $$$5$$$ are $$$1$$$ and $$$5$$$, the smallest one except $$$1$$$ is $$$5$$$. Therefore, the only operation adds $$$f(5)=5$$$ to $$$5$$$, and the result is $$$10$$$.In the second query, $$$n=8$$$ and $$$k=2$$$. The divisors of $$$8$$$ are $$$1,2,4,8$$$, wh... | Java 11 | standard input | [
"math"
] | 9fd9bc0a037b2948d60ac2bd5d57740f | The first line of the input is a single integer $$$t\ (1\le t\le 100)$$$: the number of times that Orac will ask you. Each of the next $$$t$$$ lines contains two positive integers $$$n,k\ (2\le n\le 10^6, 1\le k\le 10^9)$$$, corresponding to a query by Orac. It is guaranteed that the total sum of $$$n$$$ is at most $$$... | 900 | Print $$$t$$$ lines, the $$$i$$$-th of them should contain the final value of $$$n$$$ in the $$$i$$$-th query by Orac. | standard output | |
PASSED | 8795075de6c6ca493b8a68e76fce5eea | train_000.jsonl | 1589286900 | Orac is studying number theory, and he is interested in the properties of divisors.For two positive integers $$$a$$$ and $$$b$$$, $$$a$$$ is a divisor of $$$b$$$ if and only if there exists an integer $$$c$$$, such that $$$a\cdot c=b$$$.For $$$n \ge 2$$$, we will denote as $$$f(n)$$$ the smallest positive divisor of $$... | 256 megabytes | // Working program with FastReader
import java.io.*;
import java.util.*;
public class codeforces_1350A
{
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(new
InputStreamReader(System.in));
}
String next()
{
while (st == null || ... | Java | ["3\n5 1\n8 2\n3 4"] | 2 seconds | ["10\n12\n12"] | NoteIn the first query, $$$n=5$$$ and $$$k=1$$$. The divisors of $$$5$$$ are $$$1$$$ and $$$5$$$, the smallest one except $$$1$$$ is $$$5$$$. Therefore, the only operation adds $$$f(5)=5$$$ to $$$5$$$, and the result is $$$10$$$.In the second query, $$$n=8$$$ and $$$k=2$$$. The divisors of $$$8$$$ are $$$1,2,4,8$$$, wh... | Java 11 | standard input | [
"math"
] | 9fd9bc0a037b2948d60ac2bd5d57740f | The first line of the input is a single integer $$$t\ (1\le t\le 100)$$$: the number of times that Orac will ask you. Each of the next $$$t$$$ lines contains two positive integers $$$n,k\ (2\le n\le 10^6, 1\le k\le 10^9)$$$, corresponding to a query by Orac. It is guaranteed that the total sum of $$$n$$$ is at most $$$... | 900 | Print $$$t$$$ lines, the $$$i$$$-th of them should contain the final value of $$$n$$$ in the $$$i$$$-th query by Orac. | standard output | |
PASSED | 79339d7b7255dfd51e647bcc2932b102 | train_000.jsonl | 1589286900 | Orac is studying number theory, and he is interested in the properties of divisors.For two positive integers $$$a$$$ and $$$b$$$, $$$a$$$ is a divisor of $$$b$$$ if and only if there exists an integer $$$c$$$, such that $$$a\cdot c=b$$$.For $$$n \ge 2$$$, we will denote as $$$f(n)$$$ the smallest positive divisor of $$... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
static public class InputIterator{
ArrayList<String> inputLine = new ArrayList<String>(1024);
int index = 0;
int max;
InputIterator(){
BufferedReader br = new BufferedReader(new InputStreamReader(System... | Java | ["3\n5 1\n8 2\n3 4"] | 2 seconds | ["10\n12\n12"] | NoteIn the first query, $$$n=5$$$ and $$$k=1$$$. The divisors of $$$5$$$ are $$$1$$$ and $$$5$$$, the smallest one except $$$1$$$ is $$$5$$$. Therefore, the only operation adds $$$f(5)=5$$$ to $$$5$$$, and the result is $$$10$$$.In the second query, $$$n=8$$$ and $$$k=2$$$. The divisors of $$$8$$$ are $$$1,2,4,8$$$, wh... | Java 11 | standard input | [
"math"
] | 9fd9bc0a037b2948d60ac2bd5d57740f | The first line of the input is a single integer $$$t\ (1\le t\le 100)$$$: the number of times that Orac will ask you. Each of the next $$$t$$$ lines contains two positive integers $$$n,k\ (2\le n\le 10^6, 1\le k\le 10^9)$$$, corresponding to a query by Orac. It is guaranteed that the total sum of $$$n$$$ is at most $$$... | 900 | Print $$$t$$$ lines, the $$$i$$$-th of them should contain the final value of $$$n$$$ in the $$$i$$$-th query by Orac. | standard output | |
PASSED | 945406fce4f64754261d192bcb3a5698 | train_000.jsonl | 1589286900 | Orac is studying number theory, and he is interested in the properties of divisors.For two positive integers $$$a$$$ and $$$b$$$, $$$a$$$ is a divisor of $$$b$$$ if and only if there exists an integer $$$c$$$, such that $$$a\cdot c=b$$$.For $$$n \ge 2$$$, we will denote as $$$f(n)$$$ the smallest positive divisor of $$... | 256 megabytes | import java.util.*;
public class WaterMelon {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
int cases = Integer.parseInt(reader.nextLine());
for (int i = 0; i < cases; i++) {
String[] input = reader.nextLine().split(" ");
int n = ... | Java | ["3\n5 1\n8 2\n3 4"] | 2 seconds | ["10\n12\n12"] | NoteIn the first query, $$$n=5$$$ and $$$k=1$$$. The divisors of $$$5$$$ are $$$1$$$ and $$$5$$$, the smallest one except $$$1$$$ is $$$5$$$. Therefore, the only operation adds $$$f(5)=5$$$ to $$$5$$$, and the result is $$$10$$$.In the second query, $$$n=8$$$ and $$$k=2$$$. The divisors of $$$8$$$ are $$$1,2,4,8$$$, wh... | Java 11 | standard input | [
"math"
] | 9fd9bc0a037b2948d60ac2bd5d57740f | The first line of the input is a single integer $$$t\ (1\le t\le 100)$$$: the number of times that Orac will ask you. Each of the next $$$t$$$ lines contains two positive integers $$$n,k\ (2\le n\le 10^6, 1\le k\le 10^9)$$$, corresponding to a query by Orac. It is guaranteed that the total sum of $$$n$$$ is at most $$$... | 900 | Print $$$t$$$ lines, the $$$i$$$-th of them should contain the final value of $$$n$$$ in the $$$i$$$-th query by Orac. | standard output | |
PASSED | a7aab3e4cb1f1734ae1d470a8791cc35 | train_000.jsonl | 1589286900 | Orac is studying number theory, and he is interested in the properties of divisors.For two positive integers $$$a$$$ and $$$b$$$, $$$a$$$ is a divisor of $$$b$$$ if and only if there exists an integer $$$c$$$, such that $$$a\cdot c=b$$$.For $$$n \ge 2$$$, we will denote as $$$f(n)$$$ the smallest positive divisor of $$... | 256 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Test {
public static void main(String[] args) throws IOException {
BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
String test_numS=bf.readLine();
int test_num... | Java | ["3\n5 1\n8 2\n3 4"] | 2 seconds | ["10\n12\n12"] | NoteIn the first query, $$$n=5$$$ and $$$k=1$$$. The divisors of $$$5$$$ are $$$1$$$ and $$$5$$$, the smallest one except $$$1$$$ is $$$5$$$. Therefore, the only operation adds $$$f(5)=5$$$ to $$$5$$$, and the result is $$$10$$$.In the second query, $$$n=8$$$ and $$$k=2$$$. The divisors of $$$8$$$ are $$$1,2,4,8$$$, wh... | Java 11 | standard input | [
"math"
] | 9fd9bc0a037b2948d60ac2bd5d57740f | The first line of the input is a single integer $$$t\ (1\le t\le 100)$$$: the number of times that Orac will ask you. Each of the next $$$t$$$ lines contains two positive integers $$$n,k\ (2\le n\le 10^6, 1\le k\le 10^9)$$$, corresponding to a query by Orac. It is guaranteed that the total sum of $$$n$$$ is at most $$$... | 900 | Print $$$t$$$ lines, the $$$i$$$-th of them should contain the final value of $$$n$$$ in the $$$i$$$-th query by Orac. | standard output | |
PASSED | d81b1ea6ca137da5912c5a241933b74a | train_000.jsonl | 1589286900 | Orac is studying number theory, and he is interested in the properties of divisors.For two positive integers $$$a$$$ and $$$b$$$, $$$a$$$ is a divisor of $$$b$$$ if and only if there exists an integer $$$c$$$, such that $$$a\cdot c=b$$$.For $$$n \ge 2$$$, we will denote as $$$f(n)$$$ the smallest positive divisor of $$... | 256 megabytes |
//1350A-未完成
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Orac_and_Factors {
public static void main(String[] args) throws IOException {
BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
String test_numS=bf.readLine(... | Java | ["3\n5 1\n8 2\n3 4"] | 2 seconds | ["10\n12\n12"] | NoteIn the first query, $$$n=5$$$ and $$$k=1$$$. The divisors of $$$5$$$ are $$$1$$$ and $$$5$$$, the smallest one except $$$1$$$ is $$$5$$$. Therefore, the only operation adds $$$f(5)=5$$$ to $$$5$$$, and the result is $$$10$$$.In the second query, $$$n=8$$$ and $$$k=2$$$. The divisors of $$$8$$$ are $$$1,2,4,8$$$, wh... | Java 11 | standard input | [
"math"
] | 9fd9bc0a037b2948d60ac2bd5d57740f | The first line of the input is a single integer $$$t\ (1\le t\le 100)$$$: the number of times that Orac will ask you. Each of the next $$$t$$$ lines contains two positive integers $$$n,k\ (2\le n\le 10^6, 1\le k\le 10^9)$$$, corresponding to a query by Orac. It is guaranteed that the total sum of $$$n$$$ is at most $$$... | 900 | Print $$$t$$$ lines, the $$$i$$$-th of them should contain the final value of $$$n$$$ in the $$$i$$$-th query by Orac. | standard output | |
PASSED | 63ec102890fe3a9599cf00708eafdeb8 | train_000.jsonl | 1589286900 | Orac is studying number theory, and he is interested in the properties of divisors.For two positive integers $$$a$$$ and $$$b$$$, $$$a$$$ is a divisor of $$$b$$$ if and only if there exists an integer $$$c$$$, such that $$$a\cdot c=b$$$.For $$$n \ge 2$$$, we will denote as $$$f(n)$$$ the smallest positive divisor of $$... | 256 megabytes | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int t = Integer.parseInt(input.nextLine());
String[] numbers;
for(int i = 0;i < t;i++) {
numbers = input.nextLine().split("\\s");
i... | Java | ["3\n5 1\n8 2\n3 4"] | 2 seconds | ["10\n12\n12"] | NoteIn the first query, $$$n=5$$$ and $$$k=1$$$. The divisors of $$$5$$$ are $$$1$$$ and $$$5$$$, the smallest one except $$$1$$$ is $$$5$$$. Therefore, the only operation adds $$$f(5)=5$$$ to $$$5$$$, and the result is $$$10$$$.In the second query, $$$n=8$$$ and $$$k=2$$$. The divisors of $$$8$$$ are $$$1,2,4,8$$$, wh... | Java 11 | standard input | [
"math"
] | 9fd9bc0a037b2948d60ac2bd5d57740f | The first line of the input is a single integer $$$t\ (1\le t\le 100)$$$: the number of times that Orac will ask you. Each of the next $$$t$$$ lines contains two positive integers $$$n,k\ (2\le n\le 10^6, 1\le k\le 10^9)$$$, corresponding to a query by Orac. It is guaranteed that the total sum of $$$n$$$ is at most $$$... | 900 | Print $$$t$$$ lines, the $$$i$$$-th of them should contain the final value of $$$n$$$ in the $$$i$$$-th query by Orac. | standard output | |
PASSED | 7adb38e5b42827449bcd2897d12a0b86 | train_000.jsonl | 1589286900 | Orac is studying number theory, and he is interested in the properties of divisors.For two positive integers $$$a$$$ and $$$b$$$, $$$a$$$ is a divisor of $$$b$$$ if and only if there exists an integer $$$c$$$, such that $$$a\cdot c=b$$$.For $$$n \ge 2$$$, we will denote as $$$f(n)$$$ the smallest positive divisor of $$... | 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 k = sc.nextInt();
for(int i=2 ; i<=n ; i++){
i... | Java | ["3\n5 1\n8 2\n3 4"] | 2 seconds | ["10\n12\n12"] | NoteIn the first query, $$$n=5$$$ and $$$k=1$$$. The divisors of $$$5$$$ are $$$1$$$ and $$$5$$$, the smallest one except $$$1$$$ is $$$5$$$. Therefore, the only operation adds $$$f(5)=5$$$ to $$$5$$$, and the result is $$$10$$$.In the second query, $$$n=8$$$ and $$$k=2$$$. The divisors of $$$8$$$ are $$$1,2,4,8$$$, wh... | Java 11 | standard input | [
"math"
] | 9fd9bc0a037b2948d60ac2bd5d57740f | The first line of the input is a single integer $$$t\ (1\le t\le 100)$$$: the number of times that Orac will ask you. Each of the next $$$t$$$ lines contains two positive integers $$$n,k\ (2\le n\le 10^6, 1\le k\le 10^9)$$$, corresponding to a query by Orac. It is guaranteed that the total sum of $$$n$$$ is at most $$$... | 900 | Print $$$t$$$ lines, the $$$i$$$-th of them should contain the final value of $$$n$$$ in the $$$i$$$-th query by Orac. | standard output | |
PASSED | d0c828243410499d7cd6fe9dfeecb380 | train_000.jsonl | 1589286900 | Orac is studying number theory, and he is interested in the properties of divisors.For two positive integers $$$a$$$ and $$$b$$$, $$$a$$$ is a divisor of $$$b$$$ if and only if there exists an integer $$$c$$$, such that $$$a\cdot c=b$$$.For $$$n \ge 2$$$, we will denote as $$$f(n)$$$ the smallest positive divisor of $$... | 256 megabytes | import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.*;
public class Main {
static class Reader {
final private int BUFFER_SIZE = 1 << 16;
private DataInputStream din;
private byte[] buffer;
private int bufferPointer, bytesRead... | Java | ["3\n5 1\n8 2\n3 4"] | 2 seconds | ["10\n12\n12"] | NoteIn the first query, $$$n=5$$$ and $$$k=1$$$. The divisors of $$$5$$$ are $$$1$$$ and $$$5$$$, the smallest one except $$$1$$$ is $$$5$$$. Therefore, the only operation adds $$$f(5)=5$$$ to $$$5$$$, and the result is $$$10$$$.In the second query, $$$n=8$$$ and $$$k=2$$$. The divisors of $$$8$$$ are $$$1,2,4,8$$$, wh... | Java 11 | standard input | [
"math"
] | 9fd9bc0a037b2948d60ac2bd5d57740f | The first line of the input is a single integer $$$t\ (1\le t\le 100)$$$: the number of times that Orac will ask you. Each of the next $$$t$$$ lines contains two positive integers $$$n,k\ (2\le n\le 10^6, 1\le k\le 10^9)$$$, corresponding to a query by Orac. It is guaranteed that the total sum of $$$n$$$ is at most $$$... | 900 | Print $$$t$$$ lines, the $$$i$$$-th of them should contain the final value of $$$n$$$ in the $$$i$$$-th query by Orac. | standard output | |
PASSED | a437fbccc0931c00cba0d15a68969700 | train_000.jsonl | 1589286900 | Orac is studying number theory, and he is interested in the properties of divisors.For two positive integers $$$a$$$ and $$$b$$$, $$$a$$$ is a divisor of $$$b$$$ if and only if there exists an integer $$$c$$$, such that $$$a\cdot c=b$$$.For $$$n \ge 2$$$, we will denote as $$$f(n)$$$ the smallest positive divisor of $$... | 256 megabytes | import java.util.Scanner;
public class Factors {
private static Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
int cases = scanner.nextInt();
for (int c = 1; c <= cases; c++) {
solve();
}
}
private static void solve() {
... | Java | ["3\n5 1\n8 2\n3 4"] | 2 seconds | ["10\n12\n12"] | NoteIn the first query, $$$n=5$$$ and $$$k=1$$$. The divisors of $$$5$$$ are $$$1$$$ and $$$5$$$, the smallest one except $$$1$$$ is $$$5$$$. Therefore, the only operation adds $$$f(5)=5$$$ to $$$5$$$, and the result is $$$10$$$.In the second query, $$$n=8$$$ and $$$k=2$$$. The divisors of $$$8$$$ are $$$1,2,4,8$$$, wh... | Java 11 | standard input | [
"math"
] | 9fd9bc0a037b2948d60ac2bd5d57740f | The first line of the input is a single integer $$$t\ (1\le t\le 100)$$$: the number of times that Orac will ask you. Each of the next $$$t$$$ lines contains two positive integers $$$n,k\ (2\le n\le 10^6, 1\le k\le 10^9)$$$, corresponding to a query by Orac. It is guaranteed that the total sum of $$$n$$$ is at most $$$... | 900 | Print $$$t$$$ lines, the $$$i$$$-th of them should contain the final value of $$$n$$$ in the $$$i$$$-th query by Orac. | standard output | |
PASSED | 3bd33ca350db9005fc20cf6142f5d660 | train_000.jsonl | 1589286900 | Orac is studying number theory, and he is interested in the properties of divisors.For two positive integers $$$a$$$ and $$$b$$$, $$$a$$$ is a divisor of $$$b$$$ if and only if there exists an integer $$$c$$$, such that $$$a\cdot c=b$$$.For $$$n \ge 2$$$, we will denote as $$$f(n)$$$ the smallest positive divisor of $$... | 256 megabytes | /**
* @author egaeus
* @mail sebegaeusprogram@gmail.com
* @veredict
* @url
* @category
* @date
**/
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
import static java.lang.Integer.parseInt;
public class CFA {
public static void mai... | Java | ["3\n5 1\n8 2\n3 4"] | 2 seconds | ["10\n12\n12"] | NoteIn the first query, $$$n=5$$$ and $$$k=1$$$. The divisors of $$$5$$$ are $$$1$$$ and $$$5$$$, the smallest one except $$$1$$$ is $$$5$$$. Therefore, the only operation adds $$$f(5)=5$$$ to $$$5$$$, and the result is $$$10$$$.In the second query, $$$n=8$$$ and $$$k=2$$$. The divisors of $$$8$$$ are $$$1,2,4,8$$$, wh... | Java 11 | standard input | [
"math"
] | 9fd9bc0a037b2948d60ac2bd5d57740f | The first line of the input is a single integer $$$t\ (1\le t\le 100)$$$: the number of times that Orac will ask you. Each of the next $$$t$$$ lines contains two positive integers $$$n,k\ (2\le n\le 10^6, 1\le k\le 10^9)$$$, corresponding to a query by Orac. It is guaranteed that the total sum of $$$n$$$ is at most $$$... | 900 | Print $$$t$$$ lines, the $$$i$$$-th of them should contain the final value of $$$n$$$ in the $$$i$$$-th query by Orac. | standard output | |
PASSED | 69493e1e7861e1f13277ca95f84b70df | train_000.jsonl | 1589286900 | Orac is studying number theory, and he is interested in the properties of divisors.For two positive integers $$$a$$$ and $$$b$$$, $$$a$$$ is a divisor of $$$b$$$ if and only if there exists an integer $$$c$$$, such that $$$a\cdot c=b$$$.For $$$n \ge 2$$$, we will denote as $$$f(n)$$$ the smallest positive divisor of $$... | 256 megabytes | import java.util.Scanner;
public class OracAndFactors {
public static void main(String[] args) {
Scanner a = new Scanner(System.in);
int b = a.nextInt();
int [] fin = new int [b];
for(int c = 0; c < b; c++) {
int e = a.nextInt();
int g = a.nextInt();
int d=2;
while(e%d != 0) {
d++;
}
e =... | Java | ["3\n5 1\n8 2\n3 4"] | 2 seconds | ["10\n12\n12"] | NoteIn the first query, $$$n=5$$$ and $$$k=1$$$. The divisors of $$$5$$$ are $$$1$$$ and $$$5$$$, the smallest one except $$$1$$$ is $$$5$$$. Therefore, the only operation adds $$$f(5)=5$$$ to $$$5$$$, and the result is $$$10$$$.In the second query, $$$n=8$$$ and $$$k=2$$$. The divisors of $$$8$$$ are $$$1,2,4,8$$$, wh... | Java 11 | standard input | [
"math"
] | 9fd9bc0a037b2948d60ac2bd5d57740f | The first line of the input is a single integer $$$t\ (1\le t\le 100)$$$: the number of times that Orac will ask you. Each of the next $$$t$$$ lines contains two positive integers $$$n,k\ (2\le n\le 10^6, 1\le k\le 10^9)$$$, corresponding to a query by Orac. It is guaranteed that the total sum of $$$n$$$ is at most $$$... | 900 | Print $$$t$$$ lines, the $$$i$$$-th of them should contain the final value of $$$n$$$ in the $$$i$$$-th query by Orac. | standard output | |
PASSED | fce6219f84fa06ba79afb646d71e28c7 | train_000.jsonl | 1589286900 | Orac is studying number theory, and he is interested in the properties of divisors.For two positive integers $$$a$$$ and $$$b$$$, $$$a$$$ is a divisor of $$$b$$$ if and only if there exists an integer $$$c$$$, such that $$$a\cdot c=b$$$.For $$$n \ge 2$$$, we will denote as $$$f(n)$$$ the smallest positive divisor of $$... | 256 megabytes | import java.util.*;
import java.io.*;
public class Solution{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for(int i = 0; i < t; i++){
int n = sc.nextInt();
int k = sc.nextInt();
int current = 0;
if(n % 2 == 0){
current = k * 2 + n;
} e... | Java | ["3\n5 1\n8 2\n3 4"] | 2 seconds | ["10\n12\n12"] | NoteIn the first query, $$$n=5$$$ and $$$k=1$$$. The divisors of $$$5$$$ are $$$1$$$ and $$$5$$$, the smallest one except $$$1$$$ is $$$5$$$. Therefore, the only operation adds $$$f(5)=5$$$ to $$$5$$$, and the result is $$$10$$$.In the second query, $$$n=8$$$ and $$$k=2$$$. The divisors of $$$8$$$ are $$$1,2,4,8$$$, wh... | Java 11 | standard input | [
"math"
] | 9fd9bc0a037b2948d60ac2bd5d57740f | The first line of the input is a single integer $$$t\ (1\le t\le 100)$$$: the number of times that Orac will ask you. Each of the next $$$t$$$ lines contains two positive integers $$$n,k\ (2\le n\le 10^6, 1\le k\le 10^9)$$$, corresponding to a query by Orac. It is guaranteed that the total sum of $$$n$$$ is at most $$$... | 900 | Print $$$t$$$ lines, the $$$i$$$-th of them should contain the final value of $$$n$$$ in the $$$i$$$-th query by Orac. | standard output | |
PASSED | 2c018319cc65cbe8bfb417090b5c7e6a | train_000.jsonl | 1589286900 | Orac is studying number theory, and he is interested in the properties of divisors.For two positive integers $$$a$$$ and $$$b$$$, $$$a$$$ is a divisor of $$$b$$$ if and only if there exists an integer $$$c$$$, such that $$$a\cdot c=b$$$.For $$$n \ge 2$$$, we will denote as $$$f(n)$$$ the smallest positive divisor of $$... | 256 megabytes | import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class Main implements Runnable {
boolean multiple = true;
void solve() throws Exception {
long n = sc.nextLong();
long k = sc.nextLong();
if (n % 2 != 0) {
boolean bool = false;
for (l... | Java | ["3\n5 1\n8 2\n3 4"] | 2 seconds | ["10\n12\n12"] | NoteIn the first query, $$$n=5$$$ and $$$k=1$$$. The divisors of $$$5$$$ are $$$1$$$ and $$$5$$$, the smallest one except $$$1$$$ is $$$5$$$. Therefore, the only operation adds $$$f(5)=5$$$ to $$$5$$$, and the result is $$$10$$$.In the second query, $$$n=8$$$ and $$$k=2$$$. The divisors of $$$8$$$ are $$$1,2,4,8$$$, wh... | Java 11 | standard input | [
"math"
] | 9fd9bc0a037b2948d60ac2bd5d57740f | The first line of the input is a single integer $$$t\ (1\le t\le 100)$$$: the number of times that Orac will ask you. Each of the next $$$t$$$ lines contains two positive integers $$$n,k\ (2\le n\le 10^6, 1\le k\le 10^9)$$$, corresponding to a query by Orac. It is guaranteed that the total sum of $$$n$$$ is at most $$$... | 900 | Print $$$t$$$ lines, the $$$i$$$-th of them should contain the final value of $$$n$$$ in the $$$i$$$-th query by Orac. | standard output | |
PASSED | 2aa328649cc98cf02db023b6670ec435 | train_000.jsonl | 1589286900 | Orac is studying number theory, and he is interested in the properties of divisors.For two positive integers $$$a$$$ and $$$b$$$, $$$a$$$ is a divisor of $$$b$$$ if and only if there exists an integer $$$c$$$, such that $$$a\cdot c=b$$$.For $$$n \ge 2$$$, we will denote as $$$f(n)$$$ the smallest positive divisor of $$... | 256 megabytes | import java.util.Scanner;
import java.lang.Math;
public class A1350{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int test_cases = sc.nextInt();
int n,k,res=0,min;
while(test_cases > 0){
n = sc.nextInt();
//System.out.println("N is: " + n);
k = sc.nextInt();
/... | Java | ["3\n5 1\n8 2\n3 4"] | 2 seconds | ["10\n12\n12"] | NoteIn the first query, $$$n=5$$$ and $$$k=1$$$. The divisors of $$$5$$$ are $$$1$$$ and $$$5$$$, the smallest one except $$$1$$$ is $$$5$$$. Therefore, the only operation adds $$$f(5)=5$$$ to $$$5$$$, and the result is $$$10$$$.In the second query, $$$n=8$$$ and $$$k=2$$$. The divisors of $$$8$$$ are $$$1,2,4,8$$$, wh... | Java 11 | standard input | [
"math"
] | 9fd9bc0a037b2948d60ac2bd5d57740f | The first line of the input is a single integer $$$t\ (1\le t\le 100)$$$: the number of times that Orac will ask you. Each of the next $$$t$$$ lines contains two positive integers $$$n,k\ (2\le n\le 10^6, 1\le k\le 10^9)$$$, corresponding to a query by Orac. It is guaranteed that the total sum of $$$n$$$ is at most $$$... | 900 | Print $$$t$$$ lines, the $$$i$$$-th of them should contain the final value of $$$n$$$ in the $$$i$$$-th query by Orac. | standard output | |
PASSED | 646f4e763a8d759da5dab9260230449e | train_000.jsonl | 1589286900 | Orac is studying number theory, and he is interested in the properties of divisors.For two positive integers $$$a$$$ and $$$b$$$, $$$a$$$ is a divisor of $$$b$$$ if and only if there exists an integer $$$c$$$, such that $$$a\cdot c=b$$$.For $$$n \ge 2$$$, we will denote as $$$f(n)$$$ the smallest positive divisor of $$... | 256 megabytes | /**
* @author vivek
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.StringTokenizer;
public class Main {
private static void solveTC(int __) {
/* For Google */
// ans.append("Case #").append(__).append("... | Java | ["3\n5 1\n8 2\n3 4"] | 2 seconds | ["10\n12\n12"] | NoteIn the first query, $$$n=5$$$ and $$$k=1$$$. The divisors of $$$5$$$ are $$$1$$$ and $$$5$$$, the smallest one except $$$1$$$ is $$$5$$$. Therefore, the only operation adds $$$f(5)=5$$$ to $$$5$$$, and the result is $$$10$$$.In the second query, $$$n=8$$$ and $$$k=2$$$. The divisors of $$$8$$$ are $$$1,2,4,8$$$, wh... | Java 11 | standard input | [
"math"
] | 9fd9bc0a037b2948d60ac2bd5d57740f | The first line of the input is a single integer $$$t\ (1\le t\le 100)$$$: the number of times that Orac will ask you. Each of the next $$$t$$$ lines contains two positive integers $$$n,k\ (2\le n\le 10^6, 1\le k\le 10^9)$$$, corresponding to a query by Orac. It is guaranteed that the total sum of $$$n$$$ is at most $$$... | 900 | Print $$$t$$$ lines, the $$$i$$$-th of them should contain the final value of $$$n$$$ in the $$$i$$$-th query by Orac. | standard output | |
PASSED | ef5db6696992120ba3b66935e483d30c | train_000.jsonl | 1589286900 | Orac is studying number theory, and he is interested in the properties of divisors.For two positive integers $$$a$$$ and $$$b$$$, $$$a$$$ is a divisor of $$$b$$$ if and only if there exists an integer $$$c$$$, such that $$$a\cdot c=b$$$.For $$$n \ge 2$$$, we will denote as $$$f(n)$$$ the smallest positive divisor of $$... | 256 megabytes | import java.util.*;
public class Orac
{
public static void main(String args[])
{
Scanner scan=new Scanner(System.in);
int t=scan.nextInt();
while(t-->0)
{
long n=scan.nextInt();
long k=scan.nextInt();
for(int i=2;i<=n;i++)
{
if(n%i==0)
{
n=n+i;
break;
}
}
n=n+2*(k... | Java | ["3\n5 1\n8 2\n3 4"] | 2 seconds | ["10\n12\n12"] | NoteIn the first query, $$$n=5$$$ and $$$k=1$$$. The divisors of $$$5$$$ are $$$1$$$ and $$$5$$$, the smallest one except $$$1$$$ is $$$5$$$. Therefore, the only operation adds $$$f(5)=5$$$ to $$$5$$$, and the result is $$$10$$$.In the second query, $$$n=8$$$ and $$$k=2$$$. The divisors of $$$8$$$ are $$$1,2,4,8$$$, wh... | Java 11 | standard input | [
"math"
] | 9fd9bc0a037b2948d60ac2bd5d57740f | The first line of the input is a single integer $$$t\ (1\le t\le 100)$$$: the number of times that Orac will ask you. Each of the next $$$t$$$ lines contains two positive integers $$$n,k\ (2\le n\le 10^6, 1\le k\le 10^9)$$$, corresponding to a query by Orac. It is guaranteed that the total sum of $$$n$$$ is at most $$$... | 900 | Print $$$t$$$ lines, the $$$i$$$-th of them should contain the final value of $$$n$$$ in the $$$i$$$-th query by Orac. | standard output | |
PASSED | 51998996a3fc493da2c74fc8ec19ea05 | train_000.jsonl | 1589286900 | Orac is studying number theory, and he is interested in the properties of divisors.For two positive integers $$$a$$$ and $$$b$$$, $$$a$$$ is a divisor of $$$b$$$ if and only if there exists an integer $$$c$$$, such that $$$a\cdot c=b$$$.For $$$n \ge 2$$$, we will denote as $$$f(n)$$$ the smallest positive divisor of $$... | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
public class file
{
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
static INPUT sc = new INPUT(br);
static int INF ... | Java | ["3\n5 1\n8 2\n3 4"] | 2 seconds | ["10\n12\n12"] | NoteIn the first query, $$$n=5$$$ and $$$k=1$$$. The divisors of $$$5$$$ are $$$1$$$ and $$$5$$$, the smallest one except $$$1$$$ is $$$5$$$. Therefore, the only operation adds $$$f(5)=5$$$ to $$$5$$$, and the result is $$$10$$$.In the second query, $$$n=8$$$ and $$$k=2$$$. The divisors of $$$8$$$ are $$$1,2,4,8$$$, wh... | Java 11 | standard input | [
"math"
] | 9fd9bc0a037b2948d60ac2bd5d57740f | The first line of the input is a single integer $$$t\ (1\le t\le 100)$$$: the number of times that Orac will ask you. Each of the next $$$t$$$ lines contains two positive integers $$$n,k\ (2\le n\le 10^6, 1\le k\le 10^9)$$$, corresponding to a query by Orac. It is guaranteed that the total sum of $$$n$$$ is at most $$$... | 900 | Print $$$t$$$ lines, the $$$i$$$-th of them should contain the final value of $$$n$$$ in the $$$i$$$-th query by Orac. | standard output | |
PASSED | 894a6bf902449b4b76a8d9221a6ee232 | train_000.jsonl | 1589286900 | Orac is studying number theory, and he is interested in the properties of divisors.For two positive integers $$$a$$$ and $$$b$$$, $$$a$$$ is a divisor of $$$b$$$ if and only if there exists an integer $$$c$$$, such that $$$a\cdot c=b$$$.For $$$n \ge 2$$$, we will denote as $$$f(n)$$$ the smallest positive divisor of $$... | 256 megabytes | import java.util.*;
import java.util.Scanner;
// Working program with FastReader
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Solution {
static class FastReader
{
BufferedRea... | Java | ["3\n5 1\n8 2\n3 4"] | 2 seconds | ["10\n12\n12"] | NoteIn the first query, $$$n=5$$$ and $$$k=1$$$. The divisors of $$$5$$$ are $$$1$$$ and $$$5$$$, the smallest one except $$$1$$$ is $$$5$$$. Therefore, the only operation adds $$$f(5)=5$$$ to $$$5$$$, and the result is $$$10$$$.In the second query, $$$n=8$$$ and $$$k=2$$$. The divisors of $$$8$$$ are $$$1,2,4,8$$$, wh... | Java 11 | standard input | [
"math"
] | 9fd9bc0a037b2948d60ac2bd5d57740f | The first line of the input is a single integer $$$t\ (1\le t\le 100)$$$: the number of times that Orac will ask you. Each of the next $$$t$$$ lines contains two positive integers $$$n,k\ (2\le n\le 10^6, 1\le k\le 10^9)$$$, corresponding to a query by Orac. It is guaranteed that the total sum of $$$n$$$ is at most $$$... | 900 | Print $$$t$$$ lines, the $$$i$$$-th of them should contain the final value of $$$n$$$ in the $$$i$$$-th query by Orac. | standard output | |
PASSED | 87a9102337b9ff0d8296230deb28a72d | train_000.jsonl | 1589286900 | Orac is studying number theory, and he is interested in the properties of divisors.For two positive integers $$$a$$$ and $$$b$$$, $$$a$$$ is a divisor of $$$b$$$ if and only if there exists an integer $$$c$$$, such that $$$a\cdot c=b$$$.For $$$n \ge 2$$$, we will denote as $$$f(n)$$$ the smallest positive divisor of $$... | 256 megabytes | import java.io.*;
import java.util.*;
public class GFG {
static int div(int n){
int a=(int) Math.sqrt(n);
for(int i=2;i<=a;i++){
if(n%i==0){
return i;
}
}
return n;
}
public static void main (String[] args)throws Exception {
BufferedRea... | Java | ["3\n5 1\n8 2\n3 4"] | 2 seconds | ["10\n12\n12"] | NoteIn the first query, $$$n=5$$$ and $$$k=1$$$. The divisors of $$$5$$$ are $$$1$$$ and $$$5$$$, the smallest one except $$$1$$$ is $$$5$$$. Therefore, the only operation adds $$$f(5)=5$$$ to $$$5$$$, and the result is $$$10$$$.In the second query, $$$n=8$$$ and $$$k=2$$$. The divisors of $$$8$$$ are $$$1,2,4,8$$$, wh... | Java 11 | standard input | [
"math"
] | 9fd9bc0a037b2948d60ac2bd5d57740f | The first line of the input is a single integer $$$t\ (1\le t\le 100)$$$: the number of times that Orac will ask you. Each of the next $$$t$$$ lines contains two positive integers $$$n,k\ (2\le n\le 10^6, 1\le k\le 10^9)$$$, corresponding to a query by Orac. It is guaranteed that the total sum of $$$n$$$ is at most $$$... | 900 | Print $$$t$$$ lines, the $$$i$$$-th of them should contain the final value of $$$n$$$ in the $$$i$$$-th query by Orac. | standard output | |
PASSED | b735a0fca07ea4069b25ca35a9ef7713 | train_000.jsonl | 1589286900 | Orac is studying number theory, and he is interested in the properties of divisors.For two positive integers $$$a$$$ and $$$b$$$, $$$a$$$ is a divisor of $$$b$$$ if and only if there exists an integer $$$c$$$, such that $$$a\cdot c=b$$$.For $$$n \ge 2$$$, we will denote as $$$f(n)$$$ the smallest positive divisor of $$... | 256 megabytes | import java.util.*;
import java.io.*;
public class HelloWorld{
static class Reader
{
final private int BUFFER_SIZE = 1 << 16;
private DataInputStream din;
private byte[] buffer;
private int bufferPointer, bytesRead;
public Reader()
{
di... | Java | ["3\n5 1\n8 2\n3 4"] | 2 seconds | ["10\n12\n12"] | NoteIn the first query, $$$n=5$$$ and $$$k=1$$$. The divisors of $$$5$$$ are $$$1$$$ and $$$5$$$, the smallest one except $$$1$$$ is $$$5$$$. Therefore, the only operation adds $$$f(5)=5$$$ to $$$5$$$, and the result is $$$10$$$.In the second query, $$$n=8$$$ and $$$k=2$$$. The divisors of $$$8$$$ are $$$1,2,4,8$$$, wh... | Java 11 | standard input | [
"math"
] | 9fd9bc0a037b2948d60ac2bd5d57740f | The first line of the input is a single integer $$$t\ (1\le t\le 100)$$$: the number of times that Orac will ask you. Each of the next $$$t$$$ lines contains two positive integers $$$n,k\ (2\le n\le 10^6, 1\le k\le 10^9)$$$, corresponding to a query by Orac. It is guaranteed that the total sum of $$$n$$$ is at most $$$... | 900 | Print $$$t$$$ lines, the $$$i$$$-th of them should contain the final value of $$$n$$$ in the $$$i$$$-th query by Orac. | standard output | |
PASSED | 5c9de8e016f33a510115d0341cd0f366 | train_000.jsonl | 1536330900 | Vasya has two arrays $$$A$$$ and $$$B$$$ of lengths $$$n$$$ and $$$m$$$, respectively.He can perform the following operation arbitrary number of times (possibly zero): he takes some consecutive subsegment of the array and replaces it with a single element, equal to the sum of all elements on this subsegment. For exampl... | 256 megabytes | import java.io.*;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.*;
public class Solu {
static StringBuffer str = new StringBuffer();
static InputReader in = new InputReader(System.in);
static int mm=1000000007;
public static void main(String[] args) {
int... | Java | ["5\n11 2 3 5 7\n4\n11 7 3 7", "2\n1 2\n1\n100", "3\n1 2 3\n3\n1 2 3"] | 1 second | ["3", "-1", "3"] | null | Java 8 | standard input | [
"two pointers",
"greedy"
] | 8c36ab13ca1a4155cf97d0803aba11a3 | The first line contains a single integer $$$n~(1 \le n \le 3 \cdot 10^5)$$$ — the length of the first array. The second line contains $$$n$$$ integers $$$a_1, a_2, \cdots, a_n~(1 \le a_i \le 10^9)$$$ — elements of the array $$$A$$$. The third line contains a single integer $$$m~(1 \le m \le 3 \cdot 10^5)$$$ — the lengt... | 1,600 | Print a single integer — the maximum length of the resulting arrays after some operations were performed on arrays $$$A$$$ and $$$B$$$ in such a way that they became equal. If there is no way to make array equal, print "-1". | standard output | |
PASSED | c828a7af20e73c9d4caed2ad1ccceb51 | train_000.jsonl | 1536330900 | Vasya has two arrays $$$A$$$ and $$$B$$$ of lengths $$$n$$$ and $$$m$$$, respectively.He can perform the following operation arbitrary number of times (possibly zero): he takes some consecutive subsegment of the array and replaces it with a single element, equal to the sum of all elements on this subsegment. For exampl... | 256 megabytes | import java.util.Scanner;
public class D_50{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
long[] A = new long[n];
for (int i = 0 ; i < n ; i++) A[i] = sc.nextLong();
int m = sc.nextInt();
long[] B = new long[m];
for (int i = 0 ; i< m ; i++) B[i] = sc.... | Java | ["5\n11 2 3 5 7\n4\n11 7 3 7", "2\n1 2\n1\n100", "3\n1 2 3\n3\n1 2 3"] | 1 second | ["3", "-1", "3"] | null | Java 8 | standard input | [
"two pointers",
"greedy"
] | 8c36ab13ca1a4155cf97d0803aba11a3 | The first line contains a single integer $$$n~(1 \le n \le 3 \cdot 10^5)$$$ — the length of the first array. The second line contains $$$n$$$ integers $$$a_1, a_2, \cdots, a_n~(1 \le a_i \le 10^9)$$$ — elements of the array $$$A$$$. The third line contains a single integer $$$m~(1 \le m \le 3 \cdot 10^5)$$$ — the lengt... | 1,600 | Print a single integer — the maximum length of the resulting arrays after some operations were performed on arrays $$$A$$$ and $$$B$$$ in such a way that they became equal. If there is no way to make array equal, print "-1". | standard output | |
PASSED | 7c89228d35a6b980849eef4a924f87e3 | train_000.jsonl | 1536330900 | Vasya has two arrays $$$A$$$ and $$$B$$$ of lengths $$$n$$$ and $$$m$$$, respectively.He can perform the following operation arbitrary number of times (possibly zero): he takes some consecutive subsegment of the array and replaces it with a single element, equal to the sum of all elements on this subsegment. For exampl... | 256 megabytes | /*
javac d.java && java d
*/
import java.io.*;
import java.util.*;
public class d {
public static void main(String[] args) { new d(); }
FS in = new FS();
PrintWriter out = new PrintWriter(System.out);
int n, m;
int[] a, b;
long[] sa, sb;
d() {
n = in.nextInt();
a = new int[n];
for (int i = 0; i < n; i+... | Java | ["5\n11 2 3 5 7\n4\n11 7 3 7", "2\n1 2\n1\n100", "3\n1 2 3\n3\n1 2 3"] | 1 second | ["3", "-1", "3"] | null | Java 8 | standard input | [
"two pointers",
"greedy"
] | 8c36ab13ca1a4155cf97d0803aba11a3 | The first line contains a single integer $$$n~(1 \le n \le 3 \cdot 10^5)$$$ — the length of the first array. The second line contains $$$n$$$ integers $$$a_1, a_2, \cdots, a_n~(1 \le a_i \le 10^9)$$$ — elements of the array $$$A$$$. The third line contains a single integer $$$m~(1 \le m \le 3 \cdot 10^5)$$$ — the lengt... | 1,600 | Print a single integer — the maximum length of the resulting arrays after some operations were performed on arrays $$$A$$$ and $$$B$$$ in such a way that they became equal. If there is no way to make array equal, print "-1". | standard output | |
PASSED | 5030536d286e2a14830fbd200a4b6830 | train_000.jsonl | 1536330900 | Vasya has two arrays $$$A$$$ and $$$B$$$ of lengths $$$n$$$ and $$$m$$$, respectively.He can perform the following operation arbitrary number of times (possibly zero): he takes some consecutive subsegment of the array and replaces it with a single element, equal to the sum of all elements on this subsegment. For exampl... | 256 megabytes | import java.io.*;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
InputReader in = new InputReader(inputStream);
int n1 = in.nextInt();
int[] a = new int[n1];
for (i... | Java | ["5\n11 2 3 5 7\n4\n11 7 3 7", "2\n1 2\n1\n100", "3\n1 2 3\n3\n1 2 3"] | 1 second | ["3", "-1", "3"] | null | Java 8 | standard input | [
"two pointers",
"greedy"
] | 8c36ab13ca1a4155cf97d0803aba11a3 | The first line contains a single integer $$$n~(1 \le n \le 3 \cdot 10^5)$$$ — the length of the first array. The second line contains $$$n$$$ integers $$$a_1, a_2, \cdots, a_n~(1 \le a_i \le 10^9)$$$ — elements of the array $$$A$$$. The third line contains a single integer $$$m~(1 \le m \le 3 \cdot 10^5)$$$ — the lengt... | 1,600 | Print a single integer — the maximum length of the resulting arrays after some operations were performed on arrays $$$A$$$ and $$$B$$$ in such a way that they became equal. If there is no way to make array equal, print "-1". | standard output | |
PASSED | 768fdc6302eb83347007ec14bc665c84 | train_000.jsonl | 1536330900 | Vasya has two arrays $$$A$$$ and $$$B$$$ of lengths $$$n$$$ and $$$m$$$, respectively.He can perform the following operation arbitrary number of times (possibly zero): he takes some consecutive subsegment of the array and replaces it with a single element, equal to the sum of all elements on this subsegment. For exampl... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args)
{
InputReader in = new InputReader(System.in);
OutputWriter out = new OutputWriter(System.out);
int n = in.nextInt();
long[]a = new long[n];
for (int i =0;i<n;i++)
... | Java | ["5\n11 2 3 5 7\n4\n11 7 3 7", "2\n1 2\n1\n100", "3\n1 2 3\n3\n1 2 3"] | 1 second | ["3", "-1", "3"] | null | Java 8 | standard input | [
"two pointers",
"greedy"
] | 8c36ab13ca1a4155cf97d0803aba11a3 | The first line contains a single integer $$$n~(1 \le n \le 3 \cdot 10^5)$$$ — the length of the first array. The second line contains $$$n$$$ integers $$$a_1, a_2, \cdots, a_n~(1 \le a_i \le 10^9)$$$ — elements of the array $$$A$$$. The third line contains a single integer $$$m~(1 \le m \le 3 \cdot 10^5)$$$ — the lengt... | 1,600 | Print a single integer — the maximum length of the resulting arrays after some operations were performed on arrays $$$A$$$ and $$$B$$$ in such a way that they became equal. If there is no way to make array equal, print "-1". | standard output | |
PASSED | 3c70b3d9a3f26858e731d7a6ec43a3d0 | train_000.jsonl | 1536330900 | Vasya has two arrays $$$A$$$ and $$$B$$$ of lengths $$$n$$$ and $$$m$$$, respectively.He can perform the following operation arbitrary number of times (possibly zero): he takes some consecutive subsegment of the array and replaces it with a single element, equal to the sum of all elements on this subsegment. For exampl... | 256 megabytes | import java.util.*;
import java.io.*;
public class d {
public static void main(String[] args) {
InputReader in = new InputReader(System.in);
PrintWriter out = new PrintWriter(System.out);
solve(in, out);
out.close();
}
public static void solve(InputReader in, PrintWriter ou... | Java | ["5\n11 2 3 5 7\n4\n11 7 3 7", "2\n1 2\n1\n100", "3\n1 2 3\n3\n1 2 3"] | 1 second | ["3", "-1", "3"] | null | Java 8 | standard input | [
"two pointers",
"greedy"
] | 8c36ab13ca1a4155cf97d0803aba11a3 | The first line contains a single integer $$$n~(1 \le n \le 3 \cdot 10^5)$$$ — the length of the first array. The second line contains $$$n$$$ integers $$$a_1, a_2, \cdots, a_n~(1 \le a_i \le 10^9)$$$ — elements of the array $$$A$$$. The third line contains a single integer $$$m~(1 \le m \le 3 \cdot 10^5)$$$ — the lengt... | 1,600 | Print a single integer — the maximum length of the resulting arrays after some operations were performed on arrays $$$A$$$ and $$$B$$$ in such a way that they became equal. If there is no way to make array equal, print "-1". | standard output | |
PASSED | 678adcf4adfd414d75c05f7400537129 | train_000.jsonl | 1536330900 | Vasya has two arrays $$$A$$$ and $$$B$$$ of lengths $$$n$$$ and $$$m$$$, respectively.He can perform the following operation arbitrary number of times (possibly zero): he takes some consecutive subsegment of the array and replaces it with a single element, equal to the sum of all elements on this subsegment. For exampl... | 256 megabytes | import java.io.*;
import java.util.*;
public class Codeforces1036D {
public static void main(String[] args) {
MyScanner scanner = new MyScanner(System.in);
int n = scanner.nextInt();
int[] a = new int[n];
for(int i = 0; i < n; i++) {
a[i] = scanner.nextInt();
}
int m = scanner.nextInt();
int[] b = ne... | Java | ["5\n11 2 3 5 7\n4\n11 7 3 7", "2\n1 2\n1\n100", "3\n1 2 3\n3\n1 2 3"] | 1 second | ["3", "-1", "3"] | null | Java 8 | standard input | [
"two pointers",
"greedy"
] | 8c36ab13ca1a4155cf97d0803aba11a3 | The first line contains a single integer $$$n~(1 \le n \le 3 \cdot 10^5)$$$ — the length of the first array. The second line contains $$$n$$$ integers $$$a_1, a_2, \cdots, a_n~(1 \le a_i \le 10^9)$$$ — elements of the array $$$A$$$. The third line contains a single integer $$$m~(1 \le m \le 3 \cdot 10^5)$$$ — the lengt... | 1,600 | Print a single integer — the maximum length of the resulting arrays after some operations were performed on arrays $$$A$$$ and $$$B$$$ in such a way that they became equal. If there is no way to make array equal, print "-1". | standard output | |
PASSED | 91925fb0ef81ce23be7c78474dc51878 | train_000.jsonl | 1536330900 | Vasya has two arrays $$$A$$$ and $$$B$$$ of lengths $$$n$$$ and $$$m$$$, respectively.He can perform the following operation arbitrary number of times (possibly zero): he takes some consecutive subsegment of the array and replaces it with a single element, equal to the sum of all elements on this subsegment. For exampl... | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
static ArrayList<ArrayList<Integer>> list;
static HashSet<In... | Java | ["5\n11 2 3 5 7\n4\n11 7 3 7", "2\n1 2\n1\n100", "3\n1 2 3\n3\n1 2 3"] | 1 second | ["3", "-1", "3"] | null | Java 8 | standard input | [
"two pointers",
"greedy"
] | 8c36ab13ca1a4155cf97d0803aba11a3 | The first line contains a single integer $$$n~(1 \le n \le 3 \cdot 10^5)$$$ — the length of the first array. The second line contains $$$n$$$ integers $$$a_1, a_2, \cdots, a_n~(1 \le a_i \le 10^9)$$$ — elements of the array $$$A$$$. The third line contains a single integer $$$m~(1 \le m \le 3 \cdot 10^5)$$$ — the lengt... | 1,600 | Print a single integer — the maximum length of the resulting arrays after some operations were performed on arrays $$$A$$$ and $$$B$$$ in such a way that they became equal. If there is no way to make array equal, print "-1". | standard output | |
PASSED | 1923cedb887666fd45d85d024526ead0 | train_000.jsonl | 1536330900 | Vasya has two arrays $$$A$$$ and $$$B$$$ of lengths $$$n$$$ and $$$m$$$, respectively.He can perform the following operation arbitrary number of times (possibly zero): he takes some consecutive subsegment of the array and replaces it with a single element, equal to the sum of all elements on this subsegment. For exampl... | 256 megabytes | import java.io.*;
import java.util.*;
import java.lang.*;
import java.util.HashMap;
import java.util.PriorityQueue;
public class templ implements Runnable {
class pair
{
int v,val;
pair(int f,int s)
{
v=f;
val=s;
}
}
public static int M=1000000007;... | Java | ["5\n11 2 3 5 7\n4\n11 7 3 7", "2\n1 2\n1\n100", "3\n1 2 3\n3\n1 2 3"] | 1 second | ["3", "-1", "3"] | null | Java 8 | standard input | [
"two pointers",
"greedy"
] | 8c36ab13ca1a4155cf97d0803aba11a3 | The first line contains a single integer $$$n~(1 \le n \le 3 \cdot 10^5)$$$ — the length of the first array. The second line contains $$$n$$$ integers $$$a_1, a_2, \cdots, a_n~(1 \le a_i \le 10^9)$$$ — elements of the array $$$A$$$. The third line contains a single integer $$$m~(1 \le m \le 3 \cdot 10^5)$$$ — the lengt... | 1,600 | Print a single integer — the maximum length of the resulting arrays after some operations were performed on arrays $$$A$$$ and $$$B$$$ in such a way that they became equal. If there is no way to make array equal, print "-1". | standard output | |
PASSED | 999df59e00d064d39bb28bbadbd1c5e4 | train_000.jsonl | 1536330900 | Vasya has two arrays $$$A$$$ and $$$B$$$ of lengths $$$n$$$ and $$$m$$$, respectively.He can perform the following operation arbitrary number of times (possibly zero): he takes some consecutive subsegment of the array and replaces it with a single element, equal to the sum of all elements on this subsegment. For exampl... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
FastReader in = new FastReader();
int n = in.nextInt();
long[] an = new long[n+1];
for(int i=1 ;i<=n ;i++) an[i] = in.nextLong();
int m = in.nextInt();
long[] am = new ... | Java | ["5\n11 2 3 5 7\n4\n11 7 3 7", "2\n1 2\n1\n100", "3\n1 2 3\n3\n1 2 3"] | 1 second | ["3", "-1", "3"] | null | Java 8 | standard input | [
"two pointers",
"greedy"
] | 8c36ab13ca1a4155cf97d0803aba11a3 | The first line contains a single integer $$$n~(1 \le n \le 3 \cdot 10^5)$$$ — the length of the first array. The second line contains $$$n$$$ integers $$$a_1, a_2, \cdots, a_n~(1 \le a_i \le 10^9)$$$ — elements of the array $$$A$$$. The third line contains a single integer $$$m~(1 \le m \le 3 \cdot 10^5)$$$ — the lengt... | 1,600 | Print a single integer — the maximum length of the resulting arrays after some operations were performed on arrays $$$A$$$ and $$$B$$$ in such a way that they became equal. If there is no way to make array equal, print "-1". | standard output | |
PASSED | 4925a0c2d7fc86fc5601ce962407d72c | train_000.jsonl | 1536330900 | Vasya has two arrays $$$A$$$ and $$$B$$$ of lengths $$$n$$$ and $$$m$$$, respectively.He can perform the following operation arbitrary number of times (possibly zero): he takes some consecutive subsegment of the array and replaces it with a single element, equal to the sum of all elements on this subsegment. For exampl... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Input... | Java | ["5\n11 2 3 5 7\n4\n11 7 3 7", "2\n1 2\n1\n100", "3\n1 2 3\n3\n1 2 3"] | 1 second | ["3", "-1", "3"] | null | Java 8 | standard input | [
"two pointers",
"greedy"
] | 8c36ab13ca1a4155cf97d0803aba11a3 | The first line contains a single integer $$$n~(1 \le n \le 3 \cdot 10^5)$$$ — the length of the first array. The second line contains $$$n$$$ integers $$$a_1, a_2, \cdots, a_n~(1 \le a_i \le 10^9)$$$ — elements of the array $$$A$$$. The third line contains a single integer $$$m~(1 \le m \le 3 \cdot 10^5)$$$ — the lengt... | 1,600 | Print a single integer — the maximum length of the resulting arrays after some operations were performed on arrays $$$A$$$ and $$$B$$$ in such a way that they became equal. If there is no way to make array equal, print "-1". | standard output | |
PASSED | b545f819bf01790e17ef7b92303ba0cc | train_000.jsonl | 1536330900 | Vasya has two arrays $$$A$$$ and $$$B$$$ of lengths $$$n$$$ and $$$m$$$, respectively.He can perform the following operation arbitrary number of times (possibly zero): he takes some consecutive subsegment of the array and replaces it with a single element, equal to the sum of all elements on this subsegment. For exampl... | 256 megabytes | // package Practice2.CF1036;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
public class CF1036D {
public static void main(String[] args) throws Exception{
Reader s = new Reader(/*System.in*/);
int n... | Java | ["5\n11 2 3 5 7\n4\n11 7 3 7", "2\n1 2\n1\n100", "3\n1 2 3\n3\n1 2 3"] | 1 second | ["3", "-1", "3"] | null | Java 8 | standard input | [
"two pointers",
"greedy"
] | 8c36ab13ca1a4155cf97d0803aba11a3 | The first line contains a single integer $$$n~(1 \le n \le 3 \cdot 10^5)$$$ — the length of the first array. The second line contains $$$n$$$ integers $$$a_1, a_2, \cdots, a_n~(1 \le a_i \le 10^9)$$$ — elements of the array $$$A$$$. The third line contains a single integer $$$m~(1 \le m \le 3 \cdot 10^5)$$$ — the lengt... | 1,600 | Print a single integer — the maximum length of the resulting arrays after some operations were performed on arrays $$$A$$$ and $$$B$$$ in such a way that they became equal. If there is no way to make array equal, print "-1". | standard output | |
PASSED | ead86b68f32ee79216bf480ccdfbbad2 | train_000.jsonl | 1332516600 | A median in an array with the length of n is an element which occupies position number after we sort the elements in the non-decreasing order (the array elements are numbered starting with 1). A median of an array (2, 6, 1, 2, 3) is the number 2, and a median of array (0, 96, 17, 23) — the number 17.We define an expre... | 256 megabytes | import java.util.List;
import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
* @author codeKNIGHT
*/
publi... | Java | ["3 10\n10 20 30", "3 4\n1 2 3"] | 2 seconds | ["1", "4"] | NoteIn the first sample we can add number 9 to array (10, 20, 30). The resulting array (9, 10, 20, 30) will have a median in position , that is, 10.In the second sample you should add numbers 4, 5, 5, 5. The resulting array has median equal to 4. | Java 7 | standard input | [
"sortings",
"greedy",
"math"
] | 1a73bda2b9c2038d6ddf39918b90da61 | The first input line contains two space-separated integers n and x (1 ≤ n ≤ 500, 1 ≤ x ≤ 105) — the initial array's length and the required median's value. The second line contains n space-separated numbers — the initial array. The elements of the array are integers from 1 to 105. The array elements are not necessarily... | 1,500 | Print the only integer — the minimum number of elements Petya needs to add to the array so that its median equals x. | standard output |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.