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
ba7a20b0c01b51de95e4bf569eb8dc79
train_001.jsonl
1550586900
Let's call some square matrix with integer values in its cells palindromic if it doesn't change after the order of rows is reversed and it doesn't change after the order of columns is reversed.For example, the following matrices are palindromic: The following matrices are not palindromic because they change after the ...
256 megabytes
import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class V1Q3 { public static void main(String[] args) { Scanner s=new Scanner(System.in); int n=s.nextInt(); if(n==1){ int num=s.nextInt(); System.out.println("YES...
Java
["4\n1 8 8 1 2 2 2 2 2 2 2 2 1 8 8 1", "3\n1 1 1 1 1 3 3 3 3", "4\n1 2 1 9 8 4 3 8 8 3 4 8 9 2 1 1", "1\n10"]
2 seconds
["YES\n1 2 2 1\n8 2 2 8\n8 2 2 8\n1 2 2 1", "YES\n1 3 1\n3 1 3\n1 3 1", "NO", "YES\n10"]
NoteNote that there exist multiple answers for the first two examples.
Java 8
standard input
[ "constructive algorithms", "implementation" ]
20928dd8e512bee2d86c6611c5e76390
The first line contains one integer $$$n$$$ ($$$1 \le n \le 20$$$). The second line contains $$$n^2$$$ integers $$$a_1, a_2, \dots, a_{n^2}$$$ ($$$1 \le a_i \le 1000$$$) β€” the numbers to put into a matrix of $$$n$$$ rows and $$$n$$$ columns.
1,700
If it is possible to put all of the $$$n^2$$$ numbers into a matrix of $$$n$$$ rows and $$$n$$$ columns so that each number is used exactly once, each cell contains exactly one number and the resulting matrix is palindromic, then print "YES". Then print $$$n$$$ lines with $$$n$$$ space-separated numbers β€” the resulting...
standard output
PASSED
36b02e98137dc2dffc0407c67b1bd3ef
train_001.jsonl
1550586900
Let's call some square matrix with integer values in its cells palindromic if it doesn't change after the order of rows is reversed and it doesn't change after the order of columns is reversed.For example, the following matrices are palindromic: The following matrices are not palindromic because they change after the ...
256 megabytes
import java.util.*; import java.lang.*; import java.lang.reflect.Array; import java.io.*; //import javafx.util.Pair; import java.util.HashMap; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.Strin...
Java
["4\n1 8 8 1 2 2 2 2 2 2 2 2 1 8 8 1", "3\n1 1 1 1 1 3 3 3 3", "4\n1 2 1 9 8 4 3 8 8 3 4 8 9 2 1 1", "1\n10"]
2 seconds
["YES\n1 2 2 1\n8 2 2 8\n8 2 2 8\n1 2 2 1", "YES\n1 3 1\n3 1 3\n1 3 1", "NO", "YES\n10"]
NoteNote that there exist multiple answers for the first two examples.
Java 8
standard input
[ "constructive algorithms", "implementation" ]
20928dd8e512bee2d86c6611c5e76390
The first line contains one integer $$$n$$$ ($$$1 \le n \le 20$$$). The second line contains $$$n^2$$$ integers $$$a_1, a_2, \dots, a_{n^2}$$$ ($$$1 \le a_i \le 1000$$$) β€” the numbers to put into a matrix of $$$n$$$ rows and $$$n$$$ columns.
1,700
If it is possible to put all of the $$$n^2$$$ numbers into a matrix of $$$n$$$ rows and $$$n$$$ columns so that each number is used exactly once, each cell contains exactly one number and the resulting matrix is palindromic, then print "YES". Then print $$$n$$$ lines with $$$n$$$ space-separated numbers β€” the resulting...
standard output
PASSED
078115f703e2e35bc4ec2e5a99f9c419
train_001.jsonl
1479918900
Little Alyona is celebrating Happy Birthday! Her mother has an array of n flowers. Each flower has some mood, the mood of i-th flower is ai. The mood can be positive, zero or negative.Let's define a subarray as a segment of consecutive flowers. The mother suggested some set of subarrays. Alyona wants to choose several ...
256 megabytes
import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; public class Main { static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din...
Java
["5 4\n1 -2 1 3 -4\n1 2\n4 5\n3 4\n1 4", "4 3\n1 2 3 4\n1 3\n2 4\n1 1", "2 2\n-1 -2\n1 1\n1 2"]
2 seconds
["7", "16", "0"]
NoteThe first example is the situation described in the statements.In the second example Alyona should choose all subarrays.The third example has answer 0 because Alyona can choose none of the subarrays.
Java 8
standard input
[ "constructive algorithms" ]
6d7364048428c70e0e9b76ab1eb8cc34
The first line contains two integers n and m (1 ≀ n, m ≀ 100)Β β€” the number of flowers and the number of subarrays suggested by the mother. The second line contains the flowers moodsΒ β€” n integers a1, a2, ..., an ( - 100 ≀ ai ≀ 100). The next m lines contain the description of the subarrays suggested by the mother. The i...
1,200
Print single integerΒ β€” the maximum possible value added to the Alyona's happiness.
standard output
PASSED
154fed7bb633e67b055fbff93c822c98
train_001.jsonl
1479918900
Little Alyona is celebrating Happy Birthday! Her mother has an array of n flowers. Each flower has some mood, the mood of i-th flower is ai. The mood can be positive, zero or negative.Let's define a subarray as a segment of consecutive flowers. The mother suggested some set of subarrays. Alyona wants to choose several ...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int ar[] = new int[n+1]; int sum[] = new int[101]; sum[0] = 0; for(int i=1; i<=...
Java
["5 4\n1 -2 1 3 -4\n1 2\n4 5\n3 4\n1 4", "4 3\n1 2 3 4\n1 3\n2 4\n1 1", "2 2\n-1 -2\n1 1\n1 2"]
2 seconds
["7", "16", "0"]
NoteThe first example is the situation described in the statements.In the second example Alyona should choose all subarrays.The third example has answer 0 because Alyona can choose none of the subarrays.
Java 8
standard input
[ "constructive algorithms" ]
6d7364048428c70e0e9b76ab1eb8cc34
The first line contains two integers n and m (1 ≀ n, m ≀ 100)Β β€” the number of flowers and the number of subarrays suggested by the mother. The second line contains the flowers moodsΒ β€” n integers a1, a2, ..., an ( - 100 ≀ ai ≀ 100). The next m lines contain the description of the subarrays suggested by the mother. The i...
1,200
Print single integerΒ β€” the maximum possible value added to the Alyona's happiness.
standard output
PASSED
f7c48765f55545bfd18d49f9542d208d
train_001.jsonl
1479918900
Little Alyona is celebrating Happy Birthday! Her mother has an array of n flowers. Each flower has some mood, the mood of i-th flower is ai. The mood can be positive, zero or negative.Let's define a subarray as a segment of consecutive flowers. The mother suggested some set of subarrays. Alyona wants to choose several ...
256 megabytes
import java.io.*; import java.math.*; 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(); int[] arr = new int[n+1]; for(int i=1;i<=n;i++) arr[i] = sc.nextInt()...
Java
["5 4\n1 -2 1 3 -4\n1 2\n4 5\n3 4\n1 4", "4 3\n1 2 3 4\n1 3\n2 4\n1 1", "2 2\n-1 -2\n1 1\n1 2"]
2 seconds
["7", "16", "0"]
NoteThe first example is the situation described in the statements.In the second example Alyona should choose all subarrays.The third example has answer 0 because Alyona can choose none of the subarrays.
Java 8
standard input
[ "constructive algorithms" ]
6d7364048428c70e0e9b76ab1eb8cc34
The first line contains two integers n and m (1 ≀ n, m ≀ 100)Β β€” the number of flowers and the number of subarrays suggested by the mother. The second line contains the flowers moodsΒ β€” n integers a1, a2, ..., an ( - 100 ≀ ai ≀ 100). The next m lines contain the description of the subarrays suggested by the mother. The i...
1,200
Print single integerΒ β€” the maximum possible value added to the Alyona's happiness.
standard output
PASSED
fda0fa9cdedbc439949d71ec3820c47e
train_001.jsonl
1479918900
Little Alyona is celebrating Happy Birthday! Her mother has an array of n flowers. Each flower has some mood, the mood of i-th flower is ai. The mood can be positive, zero or negative.Let's define a subarray as a segment of consecutive flowers. The mother suggested some set of subarrays. Alyona wants to choose several ...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Main2B { static int n, m; static int[] moods; static int[] prefixSums; public static void main(String[] args) throws IOException { int total = 0; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st...
Java
["5 4\n1 -2 1 3 -4\n1 2\n4 5\n3 4\n1 4", "4 3\n1 2 3 4\n1 3\n2 4\n1 1", "2 2\n-1 -2\n1 1\n1 2"]
2 seconds
["7", "16", "0"]
NoteThe first example is the situation described in the statements.In the second example Alyona should choose all subarrays.The third example has answer 0 because Alyona can choose none of the subarrays.
Java 8
standard input
[ "constructive algorithms" ]
6d7364048428c70e0e9b76ab1eb8cc34
The first line contains two integers n and m (1 ≀ n, m ≀ 100)Β β€” the number of flowers and the number of subarrays suggested by the mother. The second line contains the flowers moodsΒ β€” n integers a1, a2, ..., an ( - 100 ≀ ai ≀ 100). The next m lines contain the description of the subarrays suggested by the mother. The i...
1,200
Print single integerΒ β€” the maximum possible value added to the Alyona's happiness.
standard output
PASSED
6bc222d45c59ca8e60e1a911f832aa4a
train_001.jsonl
1479918900
Little Alyona is celebrating Happy Birthday! Her mother has an array of n flowers. Each flower has some mood, the mood of i-th flower is ai. The mood can be positive, zero or negative.Let's define a subarray as a segment of consecutive flowers. The mother suggested some set of subarrays. Alyona wants to choose several ...
256 megabytes
import java.util.Scanner; /** * Created by yuchzhou on 11/27/16. */ public class B { int solve(int[] moods, int[][] subarrays) { int sum = 0; for (int[] subarray : subarrays) { int subarraySum = 0; for (int i = subarray[0]; i <= subarray[1]; ++i) { subarray...
Java
["5 4\n1 -2 1 3 -4\n1 2\n4 5\n3 4\n1 4", "4 3\n1 2 3 4\n1 3\n2 4\n1 1", "2 2\n-1 -2\n1 1\n1 2"]
2 seconds
["7", "16", "0"]
NoteThe first example is the situation described in the statements.In the second example Alyona should choose all subarrays.The third example has answer 0 because Alyona can choose none of the subarrays.
Java 8
standard input
[ "constructive algorithms" ]
6d7364048428c70e0e9b76ab1eb8cc34
The first line contains two integers n and m (1 ≀ n, m ≀ 100)Β β€” the number of flowers and the number of subarrays suggested by the mother. The second line contains the flowers moodsΒ β€” n integers a1, a2, ..., an ( - 100 ≀ ai ≀ 100). The next m lines contain the description of the subarrays suggested by the mother. The i...
1,200
Print single integerΒ β€” the maximum possible value added to the Alyona's happiness.
standard output
PASSED
720e71fc2d909115fdf1a79665e99817
train_001.jsonl
1479918900
Little Alyona is celebrating Happy Birthday! Her mother has an array of n flowers. Each flower has some mood, the mood of i-th flower is ai. The mood can be positive, zero or negative.Let's define a subarray as a segment of consecutive flowers. The mother suggested some set of subarrays. Alyona wants to choose several ...
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.HashMap; import java.util.HashSet; import java.util.StringTokenizer; public class A { static FastReader scan = new FastReader()...
Java
["5 4\n1 -2 1 3 -4\n1 2\n4 5\n3 4\n1 4", "4 3\n1 2 3 4\n1 3\n2 4\n1 1", "2 2\n-1 -2\n1 1\n1 2"]
2 seconds
["7", "16", "0"]
NoteThe first example is the situation described in the statements.In the second example Alyona should choose all subarrays.The third example has answer 0 because Alyona can choose none of the subarrays.
Java 8
standard input
[ "constructive algorithms" ]
6d7364048428c70e0e9b76ab1eb8cc34
The first line contains two integers n and m (1 ≀ n, m ≀ 100)Β β€” the number of flowers and the number of subarrays suggested by the mother. The second line contains the flowers moodsΒ β€” n integers a1, a2, ..., an ( - 100 ≀ ai ≀ 100). The next m lines contain the description of the subarrays suggested by the mother. The i...
1,200
Print single integerΒ β€” the maximum possible value added to the Alyona's happiness.
standard output
PASSED
5dda2dfa3fcd17fdf4004e26977c0ac3
train_001.jsonl
1479918900
Little Alyona is celebrating Happy Birthday! Her mother has an array of n flowers. Each flower has some mood, the mood of i-th flower is ai. The mood can be positive, zero or negative.Let's define a subarray as a segment of consecutive flowers. The mother suggested some set of subarrays. Alyona wants to choose several ...
256 megabytes
//package com.dcomplex; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { static int flowers[]; static BufferedReader getInput() { return new BufferedReader(new InputStreamReader(System.in)); } s...
Java
["5 4\n1 -2 1 3 -4\n1 2\n4 5\n3 4\n1 4", "4 3\n1 2 3 4\n1 3\n2 4\n1 1", "2 2\n-1 -2\n1 1\n1 2"]
2 seconds
["7", "16", "0"]
NoteThe first example is the situation described in the statements.In the second example Alyona should choose all subarrays.The third example has answer 0 because Alyona can choose none of the subarrays.
Java 8
standard input
[ "constructive algorithms" ]
6d7364048428c70e0e9b76ab1eb8cc34
The first line contains two integers n and m (1 ≀ n, m ≀ 100)Β β€” the number of flowers and the number of subarrays suggested by the mother. The second line contains the flowers moodsΒ β€” n integers a1, a2, ..., an ( - 100 ≀ ai ≀ 100). The next m lines contain the description of the subarrays suggested by the mother. The i...
1,200
Print single integerΒ β€” the maximum possible value added to the Alyona's happiness.
standard output
PASSED
67addb1ba3f4dcd5a62465cf45e5a3c4
train_001.jsonl
1479918900
Little Alyona is celebrating Happy Birthday! Her mother has an array of n flowers. Each flower has some mood, the mood of i-th flower is ai. The mood can be positive, zero or negative.Let's define a subarray as a segment of consecutive flowers. The mother suggested some set of subarrays. Alyona wants to choose several ...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; import java.util.HashMap; public class Main { static class Reader { private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public Reader() { this(System.in); }public Reader(InputStream is) { mIs = is;} ...
Java
["5 4\n1 -2 1 3 -4\n1 2\n4 5\n3 4\n1 4", "4 3\n1 2 3 4\n1 3\n2 4\n1 1", "2 2\n-1 -2\n1 1\n1 2"]
2 seconds
["7", "16", "0"]
NoteThe first example is the situation described in the statements.In the second example Alyona should choose all subarrays.The third example has answer 0 because Alyona can choose none of the subarrays.
Java 8
standard input
[ "constructive algorithms" ]
6d7364048428c70e0e9b76ab1eb8cc34
The first line contains two integers n and m (1 ≀ n, m ≀ 100)Β β€” the number of flowers and the number of subarrays suggested by the mother. The second line contains the flowers moodsΒ β€” n integers a1, a2, ..., an ( - 100 ≀ ai ≀ 100). The next m lines contain the description of the subarrays suggested by the mother. The i...
1,200
Print single integerΒ β€” the maximum possible value added to the Alyona's happiness.
standard output
PASSED
a2f10a489c694fb8dad35cdd0540ed0a
train_001.jsonl
1479918900
Little Alyona is celebrating Happy Birthday! Her mother has an array of n flowers. Each flower has some mood, the mood of i-th flower is ai. The mood can be positive, zero or negative.Let's define a subarray as a segment of consecutive flowers. The mother suggested some set of subarrays. Alyona wants to choose several ...
256 megabytes
import java.io.*; import java.util.*; public class codeforce { static Scanner sc = new Scanner(System.in); static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); //static PrintStream out=new PrintStream(System.out); public static int mod = 1000000007; public static void...
Java
["5 4\n1 -2 1 3 -4\n1 2\n4 5\n3 4\n1 4", "4 3\n1 2 3 4\n1 3\n2 4\n1 1", "2 2\n-1 -2\n1 1\n1 2"]
2 seconds
["7", "16", "0"]
NoteThe first example is the situation described in the statements.In the second example Alyona should choose all subarrays.The third example has answer 0 because Alyona can choose none of the subarrays.
Java 8
standard input
[ "constructive algorithms" ]
6d7364048428c70e0e9b76ab1eb8cc34
The first line contains two integers n and m (1 ≀ n, m ≀ 100)Β β€” the number of flowers and the number of subarrays suggested by the mother. The second line contains the flowers moodsΒ β€” n integers a1, a2, ..., an ( - 100 ≀ ai ≀ 100). The next m lines contain the description of the subarrays suggested by the mother. The i...
1,200
Print single integerΒ β€” the maximum possible value added to the Alyona's happiness.
standard output
PASSED
b5227a150ce79867e8f010898d64c0be
train_001.jsonl
1479918900
Little Alyona is celebrating Happy Birthday! Her mother has an array of n flowers. Each flower has some mood, the mood of i-th flower is ai. The mood can be positive, zero or negative.Let's define a subarray as a segment of consecutive flowers. The mother suggested some set of subarrays. Alyona wants to choose several ...
256 megabytes
import java.io.*; import java.util.*; public class alflow { public static void main(String args[])throws IOException { try { InputStreamReader is = new InputStreamReader(System.in); BufferedReader bf = new BufferedReader(is); String tokens[] = new String[2]; tokens = bf.readLine().split(" ");...
Java
["5 4\n1 -2 1 3 -4\n1 2\n4 5\n3 4\n1 4", "4 3\n1 2 3 4\n1 3\n2 4\n1 1", "2 2\n-1 -2\n1 1\n1 2"]
2 seconds
["7", "16", "0"]
NoteThe first example is the situation described in the statements.In the second example Alyona should choose all subarrays.The third example has answer 0 because Alyona can choose none of the subarrays.
Java 8
standard input
[ "constructive algorithms" ]
6d7364048428c70e0e9b76ab1eb8cc34
The first line contains two integers n and m (1 ≀ n, m ≀ 100)Β β€” the number of flowers and the number of subarrays suggested by the mother. The second line contains the flowers moodsΒ β€” n integers a1, a2, ..., an ( - 100 ≀ ai ≀ 100). The next m lines contain the description of the subarrays suggested by the mother. The i...
1,200
Print single integerΒ β€” the maximum possible value added to the Alyona's happiness.
standard output
PASSED
9b0acb048ac89030b222d39424ed4816
train_001.jsonl
1479918900
Little Alyona is celebrating Happy Birthday! Her mother has an array of n flowers. Each flower has some mood, the mood of i-th flower is ai. The mood can be positive, zero or negative.Let's define a subarray as a segment of consecutive flowers. The mother suggested some set of subarrays. Alyona wants to choose several ...
256 megabytes
import java.io.*; import java.text.*; import java.util.*; public class B { public static void main(String[] args) throws Exception { new B().run(); } public void run() throws Exception { FastScanner f = new FastScanner(); int n = f.nextInt(), m = f.nextInt(); long[][] sums = new long[n][n]; for(int i = 0;...
Java
["5 4\n1 -2 1 3 -4\n1 2\n4 5\n3 4\n1 4", "4 3\n1 2 3 4\n1 3\n2 4\n1 1", "2 2\n-1 -2\n1 1\n1 2"]
2 seconds
["7", "16", "0"]
NoteThe first example is the situation described in the statements.In the second example Alyona should choose all subarrays.The third example has answer 0 because Alyona can choose none of the subarrays.
Java 8
standard input
[ "constructive algorithms" ]
6d7364048428c70e0e9b76ab1eb8cc34
The first line contains two integers n and m (1 ≀ n, m ≀ 100)Β β€” the number of flowers and the number of subarrays suggested by the mother. The second line contains the flowers moodsΒ β€” n integers a1, a2, ..., an ( - 100 ≀ ai ≀ 100). The next m lines contain the description of the subarrays suggested by the mother. The i...
1,200
Print single integerΒ β€” the maximum possible value added to the Alyona's happiness.
standard output
PASSED
fe8c875d337b095c59cfe443ed0e4f64
train_001.jsonl
1479918900
Little Alyona is celebrating Happy Birthday! Her mother has an array of n flowers. Each flower has some mood, the mood of i-th flower is ai. The mood can be positive, zero or negative.Let's define a subarray as a segment of consecutive flowers. The mother suggested some set of subarrays. Alyona wants to choose several ...
256 megabytes
import java.util.Scanner; public class Class740B { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int x[] = new int[a]; int z[][] = new int[b][2]; for (int i = 0; i < a; i++) { x[i] = sc.nextInt(); } for (int i = 0; i < b; ...
Java
["5 4\n1 -2 1 3 -4\n1 2\n4 5\n3 4\n1 4", "4 3\n1 2 3 4\n1 3\n2 4\n1 1", "2 2\n-1 -2\n1 1\n1 2"]
2 seconds
["7", "16", "0"]
NoteThe first example is the situation described in the statements.In the second example Alyona should choose all subarrays.The third example has answer 0 because Alyona can choose none of the subarrays.
Java 8
standard input
[ "constructive algorithms" ]
6d7364048428c70e0e9b76ab1eb8cc34
The first line contains two integers n and m (1 ≀ n, m ≀ 100)Β β€” the number of flowers and the number of subarrays suggested by the mother. The second line contains the flowers moodsΒ β€” n integers a1, a2, ..., an ( - 100 ≀ ai ≀ 100). The next m lines contain the description of the subarrays suggested by the mother. The i...
1,200
Print single integerΒ β€” the maximum possible value added to the Alyona's happiness.
standard output
PASSED
c0d8605b5b7e2024daf2183f816120af
train_001.jsonl
1479918900
Little Alyona is celebrating Happy Birthday! Her mother has an array of n flowers. Each flower has some mood, the mood of i-th flower is ai. The mood can be positive, zero or negative.Let's define a subarray as a segment of consecutive flowers. The mother suggested some set of subarrays. Alyona wants to choose several ...
256 megabytes
import java.util.Scanner; public class alyona { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int m=sc.nextInt(); int a[]=new int[n]; for(int i=0;i<n;i++) { a[i]=sc.nextInt(); } int coun...
Java
["5 4\n1 -2 1 3 -4\n1 2\n4 5\n3 4\n1 4", "4 3\n1 2 3 4\n1 3\n2 4\n1 1", "2 2\n-1 -2\n1 1\n1 2"]
2 seconds
["7", "16", "0"]
NoteThe first example is the situation described in the statements.In the second example Alyona should choose all subarrays.The third example has answer 0 because Alyona can choose none of the subarrays.
Java 8
standard input
[ "constructive algorithms" ]
6d7364048428c70e0e9b76ab1eb8cc34
The first line contains two integers n and m (1 ≀ n, m ≀ 100)Β β€” the number of flowers and the number of subarrays suggested by the mother. The second line contains the flowers moodsΒ β€” n integers a1, a2, ..., an ( - 100 ≀ ai ≀ 100). The next m lines contain the description of the subarrays suggested by the mother. The i...
1,200
Print single integerΒ β€” the maximum possible value added to the Alyona's happiness.
standard output
PASSED
20d21f26c36a4a84c4b747668e8d8745
train_001.jsonl
1479918900
Little Alyona is celebrating Happy Birthday! Her mother has an array of n flowers. Each flower has some mood, the mood of i-th flower is ai. The mood can be positive, zero or negative.Let's define a subarray as a segment of consecutive flowers. The mother suggested some set of subarrays. Alyona wants to choose several ...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class CodeForces { private final BufferedReader reader; private final PrintWriter writer; private StringTokenizer tokenizer; private void solve() { int n = nextInt(); int m = nextInt(); int[] a = new int[...
Java
["5 4\n1 -2 1 3 -4\n1 2\n4 5\n3 4\n1 4", "4 3\n1 2 3 4\n1 3\n2 4\n1 1", "2 2\n-1 -2\n1 1\n1 2"]
2 seconds
["7", "16", "0"]
NoteThe first example is the situation described in the statements.In the second example Alyona should choose all subarrays.The third example has answer 0 because Alyona can choose none of the subarrays.
Java 8
standard input
[ "constructive algorithms" ]
6d7364048428c70e0e9b76ab1eb8cc34
The first line contains two integers n and m (1 ≀ n, m ≀ 100)Β β€” the number of flowers and the number of subarrays suggested by the mother. The second line contains the flowers moodsΒ β€” n integers a1, a2, ..., an ( - 100 ≀ ai ≀ 100). The next m lines contain the description of the subarrays suggested by the mother. The i...
1,200
Print single integerΒ β€” the maximum possible value added to the Alyona's happiness.
standard output
PASSED
7d06f3c0189fdd6852bf24b4c455bac8
train_001.jsonl
1479918900
Little Alyona is celebrating Happy Birthday! Her mother has an array of n flowers. Each flower has some mood, the mood of i-th flower is ai. The mood can be positive, zero or negative.Let's define a subarray as a segment of consecutive flowers. The mother suggested some set of subarrays. Alyona wants to choose several ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.InputStreamReader; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Queue; import java.util.StringTokenizer; import jav...
Java
["5 4\n1 -2 1 3 -4\n1 2\n4 5\n3 4\n1 4", "4 3\n1 2 3 4\n1 3\n2 4\n1 1", "2 2\n-1 -2\n1 1\n1 2"]
2 seconds
["7", "16", "0"]
NoteThe first example is the situation described in the statements.In the second example Alyona should choose all subarrays.The third example has answer 0 because Alyona can choose none of the subarrays.
Java 8
standard input
[ "constructive algorithms" ]
6d7364048428c70e0e9b76ab1eb8cc34
The first line contains two integers n and m (1 ≀ n, m ≀ 100)Β β€” the number of flowers and the number of subarrays suggested by the mother. The second line contains the flowers moodsΒ β€” n integers a1, a2, ..., an ( - 100 ≀ ai ≀ 100). The next m lines contain the description of the subarrays suggested by the mother. The i...
1,200
Print single integerΒ β€” the maximum possible value added to the Alyona's happiness.
standard output
PASSED
98da9c15ff45abb47b9923746fd4cb7e
train_001.jsonl
1479918900
Little Alyona is celebrating Happy Birthday! Her mother has an array of n flowers. Each flower has some mood, the mood of i-th flower is ai. The mood can be positive, zero or negative.Let's define a subarray as a segment of consecutive flowers. The mother suggested some set of subarrays. Alyona wants to choose several ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.PrintStream; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Mehul Sharma */ public class Main { public static void main(Strin...
Java
["5 4\n1 -2 1 3 -4\n1 2\n4 5\n3 4\n1 4", "4 3\n1 2 3 4\n1 3\n2 4\n1 1", "2 2\n-1 -2\n1 1\n1 2"]
2 seconds
["7", "16", "0"]
NoteThe first example is the situation described in the statements.In the second example Alyona should choose all subarrays.The third example has answer 0 because Alyona can choose none of the subarrays.
Java 8
standard input
[ "constructive algorithms" ]
6d7364048428c70e0e9b76ab1eb8cc34
The first line contains two integers n and m (1 ≀ n, m ≀ 100)Β β€” the number of flowers and the number of subarrays suggested by the mother. The second line contains the flowers moodsΒ β€” n integers a1, a2, ..., an ( - 100 ≀ ai ≀ 100). The next m lines contain the description of the subarrays suggested by the mother. The i...
1,200
Print single integerΒ β€” the maximum possible value added to the Alyona's happiness.
standard output
PASSED
032b3d714b68dafa0311e48fa1fe4fb3
train_001.jsonl
1479918900
Little Alyona is celebrating Happy Birthday! Her mother has an array of n flowers. Each flower has some mood, the mood of i-th flower is ai. The mood can be positive, zero or negative.Let's define a subarray as a segment of consecutive flowers. The mother suggested some set of subarrays. Alyona wants to choose several ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; public class B381 { public static void main(String[] args) { InputStre...
Java
["5 4\n1 -2 1 3 -4\n1 2\n4 5\n3 4\n1 4", "4 3\n1 2 3 4\n1 3\n2 4\n1 1", "2 2\n-1 -2\n1 1\n1 2"]
2 seconds
["7", "16", "0"]
NoteThe first example is the situation described in the statements.In the second example Alyona should choose all subarrays.The third example has answer 0 because Alyona can choose none of the subarrays.
Java 8
standard input
[ "constructive algorithms" ]
6d7364048428c70e0e9b76ab1eb8cc34
The first line contains two integers n and m (1 ≀ n, m ≀ 100)Β β€” the number of flowers and the number of subarrays suggested by the mother. The second line contains the flowers moodsΒ β€” n integers a1, a2, ..., an ( - 100 ≀ ai ≀ 100). The next m lines contain the description of the subarrays suggested by the mother. The i...
1,200
Print single integerΒ β€” the maximum possible value added to the Alyona's happiness.
standard output
PASSED
c81baa1d5c73348406b2f15f11f3430c
train_001.jsonl
1586961300
Writing light novels is the most important thing in Linova's life. Last night, Linova dreamed about a fantastic kingdom. She began to write a light novel for the kingdom as soon as she woke up, and of course, she is the queen of it.Β There are $$$n$$$ cities and $$$n-1$$$ two-way roads connecting pairs of cities in the ...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.lang.*; import static java.lang.Math.*; public class Solution implements Runnable { static class InputReader { private InputStream stream;private byte[] buf = new byte[1024]; private int curChar; private int numChars; private SpaceCha...
Java
["7 4\n1 2\n1 3\n1 4\n3 5\n3 6\n4 7", "4 1\n1 2\n1 3\n2 4", "8 5\n7 5\n1 7\n6 1\n3 7\n8 3\n2 1\n4 5"]
2 seconds
["7", "2", "9"]
NoteIn the first example, Linova can choose cities $$$2$$$, $$$5$$$, $$$6$$$, $$$7$$$ to develop industry, then the happiness of the envoy from city $$$2$$$ is $$$1$$$, the happiness of envoys from cities $$$5$$$, $$$6$$$, $$$7$$$ is $$$2$$$. The sum of happinesses is $$$7$$$, and it can be proved to be the maximum one...
Java 8
standard input
[ "dp", "greedy", "sortings", "dfs and similar", "trees" ]
47129977694cb371c7647cfd0db63d29
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2\le n\le 2 \cdot 10^5$$$, $$$1\le k&lt; n$$$) Β β€” the number of cities and industry cities respectively. Each of the next $$$n-1$$$ lines contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$), denoting there is a road connecting city $$$u$$$ and cit...
1,600
Print the only line containing a single integer Β β€” the maximum possible sum of happinesses of all envoys.
standard output
PASSED
147d646f79c83a62bb0553b2f6d68760
train_001.jsonl
1586961300
Writing light novels is the most important thing in Linova's life. Last night, Linova dreamed about a fantastic kingdom. She began to write a light novel for the kingdom as soon as she woke up, and of course, she is the queen of it.Β There are $$$n$$$ cities and $$$n-1$$$ two-way roads connecting pairs of cities in the ...
256 megabytes
import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.InputMismatc...
Java
["7 4\n1 2\n1 3\n1 4\n3 5\n3 6\n4 7", "4 1\n1 2\n1 3\n2 4", "8 5\n7 5\n1 7\n6 1\n3 7\n8 3\n2 1\n4 5"]
2 seconds
["7", "2", "9"]
NoteIn the first example, Linova can choose cities $$$2$$$, $$$5$$$, $$$6$$$, $$$7$$$ to develop industry, then the happiness of the envoy from city $$$2$$$ is $$$1$$$, the happiness of envoys from cities $$$5$$$, $$$6$$$, $$$7$$$ is $$$2$$$. The sum of happinesses is $$$7$$$, and it can be proved to be the maximum one...
Java 8
standard input
[ "dp", "greedy", "sortings", "dfs and similar", "trees" ]
47129977694cb371c7647cfd0db63d29
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2\le n\le 2 \cdot 10^5$$$, $$$1\le k&lt; n$$$) Β β€” the number of cities and industry cities respectively. Each of the next $$$n-1$$$ lines contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$), denoting there is a road connecting city $$$u$$$ and cit...
1,600
Print the only line containing a single integer Β β€” the maximum possible sum of happinesses of all envoys.
standard output
PASSED
bdab38b66563b6d66d00ce4d7849df13
train_001.jsonl
1586961300
Writing light novels is the most important thing in Linova's life. Last night, Linova dreamed about a fantastic kingdom. She began to write a light novel for the kingdom as soon as she woke up, and of course, she is the queen of it.Β There are $$$n$$$ cities and $$$n-1$$$ two-way roads connecting pairs of cities in the ...
256 megabytes
import java.util.*; import java.io.*; public class Main { private static int n, k; private static City[] cities; private static ArrayList<ArrayList<Integer>> edges; public static void main(String[] args) throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); Prin...
Java
["7 4\n1 2\n1 3\n1 4\n3 5\n3 6\n4 7", "4 1\n1 2\n1 3\n2 4", "8 5\n7 5\n1 7\n6 1\n3 7\n8 3\n2 1\n4 5"]
2 seconds
["7", "2", "9"]
NoteIn the first example, Linova can choose cities $$$2$$$, $$$5$$$, $$$6$$$, $$$7$$$ to develop industry, then the happiness of the envoy from city $$$2$$$ is $$$1$$$, the happiness of envoys from cities $$$5$$$, $$$6$$$, $$$7$$$ is $$$2$$$. The sum of happinesses is $$$7$$$, and it can be proved to be the maximum one...
Java 8
standard input
[ "dp", "greedy", "sortings", "dfs and similar", "trees" ]
47129977694cb371c7647cfd0db63d29
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2\le n\le 2 \cdot 10^5$$$, $$$1\le k&lt; n$$$) Β β€” the number of cities and industry cities respectively. Each of the next $$$n-1$$$ lines contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$), denoting there is a road connecting city $$$u$$$ and cit...
1,600
Print the only line containing a single integer Β β€” the maximum possible sum of happinesses of all envoys.
standard output
PASSED
19ff7de94b54c4ecbdbe0e1047c5cd84
train_001.jsonl
1586961300
Writing light novels is the most important thing in Linova's life. Last night, Linova dreamed about a fantastic kingdom. She began to write a light novel for the kingdom as soon as she woke up, and of course, she is the queen of it.Β There are $$$n$$$ cities and $$$n-1$$$ two-way roads connecting pairs of cities in the ...
256 megabytes
import java.io.*; import java.util.*; public class R635C_Post { public static void main(String[] args) throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringBuilder out = new StringBuilder(); StringTokenizer tok=new StringTokenizer(in.readLine());...
Java
["7 4\n1 2\n1 3\n1 4\n3 5\n3 6\n4 7", "4 1\n1 2\n1 3\n2 4", "8 5\n7 5\n1 7\n6 1\n3 7\n8 3\n2 1\n4 5"]
2 seconds
["7", "2", "9"]
NoteIn the first example, Linova can choose cities $$$2$$$, $$$5$$$, $$$6$$$, $$$7$$$ to develop industry, then the happiness of the envoy from city $$$2$$$ is $$$1$$$, the happiness of envoys from cities $$$5$$$, $$$6$$$, $$$7$$$ is $$$2$$$. The sum of happinesses is $$$7$$$, and it can be proved to be the maximum one...
Java 8
standard input
[ "dp", "greedy", "sortings", "dfs and similar", "trees" ]
47129977694cb371c7647cfd0db63d29
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2\le n\le 2 \cdot 10^5$$$, $$$1\le k&lt; n$$$) Β β€” the number of cities and industry cities respectively. Each of the next $$$n-1$$$ lines contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$), denoting there is a road connecting city $$$u$$$ and cit...
1,600
Print the only line containing a single integer Β β€” the maximum possible sum of happinesses of all envoys.
standard output
PASSED
917fdc41d0250873277511f3a49547d8
train_001.jsonl
1586961300
Writing light novels is the most important thing in Linova's life. Last night, Linova dreamed about a fantastic kingdom. She began to write a light novel for the kingdom as soon as she woke up, and of course, she is the queen of it.Β There are $$$n$$$ cities and $$$n-1$$$ two-way roads connecting pairs of cities in the ...
256 megabytes
import java.io.*; import java.util.*; public class R635C_Post { public static void main(String[] args) throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer tok=new StringTokenizer(in.readLine()); int N=Integer.parseInt(tok.nextToken()),...
Java
["7 4\n1 2\n1 3\n1 4\n3 5\n3 6\n4 7", "4 1\n1 2\n1 3\n2 4", "8 5\n7 5\n1 7\n6 1\n3 7\n8 3\n2 1\n4 5"]
2 seconds
["7", "2", "9"]
NoteIn the first example, Linova can choose cities $$$2$$$, $$$5$$$, $$$6$$$, $$$7$$$ to develop industry, then the happiness of the envoy from city $$$2$$$ is $$$1$$$, the happiness of envoys from cities $$$5$$$, $$$6$$$, $$$7$$$ is $$$2$$$. The sum of happinesses is $$$7$$$, and it can be proved to be the maximum one...
Java 8
standard input
[ "dp", "greedy", "sortings", "dfs and similar", "trees" ]
47129977694cb371c7647cfd0db63d29
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2\le n\le 2 \cdot 10^5$$$, $$$1\le k&lt; n$$$) Β β€” the number of cities and industry cities respectively. Each of the next $$$n-1$$$ lines contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$), denoting there is a road connecting city $$$u$$$ and cit...
1,600
Print the only line containing a single integer Β β€” the maximum possible sum of happinesses of all envoys.
standard output
PASSED
b878ae69a6feac5ba26ff11a40f9d6b1
train_001.jsonl
1586961300
Writing light novels is the most important thing in Linova's life. Last night, Linova dreamed about a fantastic kingdom. She began to write a light novel for the kingdom as soon as she woke up, and of course, she is the queen of it.Β There are $$$n$$$ cities and $$$n-1$$$ two-way roads connecting pairs of cities in the ...
256 megabytes
import java.io.*; import java.util.*; public class R635C_Post { public static void main(String[] args) throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer tok=new StringTokenizer(in.readLine()); int N=Integer.parseInt(tok.nextToken()),...
Java
["7 4\n1 2\n1 3\n1 4\n3 5\n3 6\n4 7", "4 1\n1 2\n1 3\n2 4", "8 5\n7 5\n1 7\n6 1\n3 7\n8 3\n2 1\n4 5"]
2 seconds
["7", "2", "9"]
NoteIn the first example, Linova can choose cities $$$2$$$, $$$5$$$, $$$6$$$, $$$7$$$ to develop industry, then the happiness of the envoy from city $$$2$$$ is $$$1$$$, the happiness of envoys from cities $$$5$$$, $$$6$$$, $$$7$$$ is $$$2$$$. The sum of happinesses is $$$7$$$, and it can be proved to be the maximum one...
Java 8
standard input
[ "dp", "greedy", "sortings", "dfs and similar", "trees" ]
47129977694cb371c7647cfd0db63d29
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2\le n\le 2 \cdot 10^5$$$, $$$1\le k&lt; n$$$) Β β€” the number of cities and industry cities respectively. Each of the next $$$n-1$$$ lines contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$), denoting there is a road connecting city $$$u$$$ and cit...
1,600
Print the only line containing a single integer Β β€” the maximum possible sum of happinesses of all envoys.
standard output
PASSED
c3f36730f416ef18acda920aee0ee18f
train_001.jsonl
1586961300
Writing light novels is the most important thing in Linova's life. Last night, Linova dreamed about a fantastic kingdom. She began to write a light novel for the kingdom as soon as she woke up, and of course, she is the queen of it.Β There are $$$n$$$ cities and $$$n-1$$$ two-way roads connecting pairs of cities in the ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.StringTokenizer; public class q3 { static int depth = 0; public static void main(String[] args) { FastReader s = new FastRead...
Java
["7 4\n1 2\n1 3\n1 4\n3 5\n3 6\n4 7", "4 1\n1 2\n1 3\n2 4", "8 5\n7 5\n1 7\n6 1\n3 7\n8 3\n2 1\n4 5"]
2 seconds
["7", "2", "9"]
NoteIn the first example, Linova can choose cities $$$2$$$, $$$5$$$, $$$6$$$, $$$7$$$ to develop industry, then the happiness of the envoy from city $$$2$$$ is $$$1$$$, the happiness of envoys from cities $$$5$$$, $$$6$$$, $$$7$$$ is $$$2$$$. The sum of happinesses is $$$7$$$, and it can be proved to be the maximum one...
Java 8
standard input
[ "dp", "greedy", "sortings", "dfs and similar", "trees" ]
47129977694cb371c7647cfd0db63d29
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2\le n\le 2 \cdot 10^5$$$, $$$1\le k&lt; n$$$) Β β€” the number of cities and industry cities respectively. Each of the next $$$n-1$$$ lines contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$), denoting there is a road connecting city $$$u$$$ and cit...
1,600
Print the only line containing a single integer Β β€” the maximum possible sum of happinesses of all envoys.
standard output
PASSED
f57985f33d004dede87cb59973a6b8eb
train_001.jsonl
1586961300
Writing light novels is the most important thing in Linova's life. Last night, Linova dreamed about a fantastic kingdom. She began to write a light novel for the kingdom as soon as she woke up, and of course, she is the queen of it.Β There are $$$n$$$ cities and $$$n-1$$$ two-way roads connecting pairs of cities in the ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; import java.util.ArrayList; import java.util.Queue; import java.util.LinkedList; public class Main { static int child[] ; static ArrayList<ArrayList<Integer>> grp...
Java
["7 4\n1 2\n1 3\n1 4\n3 5\n3 6\n4 7", "4 1\n1 2\n1 3\n2 4", "8 5\n7 5\n1 7\n6 1\n3 7\n8 3\n2 1\n4 5"]
2 seconds
["7", "2", "9"]
NoteIn the first example, Linova can choose cities $$$2$$$, $$$5$$$, $$$6$$$, $$$7$$$ to develop industry, then the happiness of the envoy from city $$$2$$$ is $$$1$$$, the happiness of envoys from cities $$$5$$$, $$$6$$$, $$$7$$$ is $$$2$$$. The sum of happinesses is $$$7$$$, and it can be proved to be the maximum one...
Java 8
standard input
[ "dp", "greedy", "sortings", "dfs and similar", "trees" ]
47129977694cb371c7647cfd0db63d29
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2\le n\le 2 \cdot 10^5$$$, $$$1\le k&lt; n$$$) Β β€” the number of cities and industry cities respectively. Each of the next $$$n-1$$$ lines contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$), denoting there is a road connecting city $$$u$$$ and cit...
1,600
Print the only line containing a single integer Β β€” the maximum possible sum of happinesses of all envoys.
standard output
PASSED
202fffb8072e545fd8e155eb43903390
train_001.jsonl
1586961300
Writing light novels is the most important thing in Linova's life. Last night, Linova dreamed about a fantastic kingdom. She began to write a light novel for the kingdom as soon as she woke up, and of course, she is the queen of it.Β There are $$$n$$$ cities and $$$n-1$$$ two-way roads connecting pairs of cities in the ...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class spoj { InputStream is; static PrintWriter out; static Integer level[]; static int down[]; static int dfs2(ArrayList<Integer> l[],int cur,int par,int root) { if(l[cur].size()==1 && cur!=root) { return 0; } fo...
Java
["7 4\n1 2\n1 3\n1 4\n3 5\n3 6\n4 7", "4 1\n1 2\n1 3\n2 4", "8 5\n7 5\n1 7\n6 1\n3 7\n8 3\n2 1\n4 5"]
2 seconds
["7", "2", "9"]
NoteIn the first example, Linova can choose cities $$$2$$$, $$$5$$$, $$$6$$$, $$$7$$$ to develop industry, then the happiness of the envoy from city $$$2$$$ is $$$1$$$, the happiness of envoys from cities $$$5$$$, $$$6$$$, $$$7$$$ is $$$2$$$. The sum of happinesses is $$$7$$$, and it can be proved to be the maximum one...
Java 8
standard input
[ "dp", "greedy", "sortings", "dfs and similar", "trees" ]
47129977694cb371c7647cfd0db63d29
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2\le n\le 2 \cdot 10^5$$$, $$$1\le k&lt; n$$$) Β β€” the number of cities and industry cities respectively. Each of the next $$$n-1$$$ lines contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$), denoting there is a road connecting city $$$u$$$ and cit...
1,600
Print the only line containing a single integer Β β€” the maximum possible sum of happinesses of all envoys.
standard output
PASSED
446b6e9b9157974162eec623d15adfd1
train_001.jsonl
1586961300
Writing light novels is the most important thing in Linova's life. Last night, Linova dreamed about a fantastic kingdom. She began to write a light novel for the kingdom as soon as she woke up, and of course, she is the queen of it.Β There are $$$n$$$ cities and $$$n-1$$$ two-way roads connecting pairs of cities in the ...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.lang.*; import static java.lang.Math.*; public class Main implements Runnable { static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; private SpaceCharFil...
Java
["7 4\n1 2\n1 3\n1 4\n3 5\n3 6\n4 7", "4 1\n1 2\n1 3\n2 4", "8 5\n7 5\n1 7\n6 1\n3 7\n8 3\n2 1\n4 5"]
2 seconds
["7", "2", "9"]
NoteIn the first example, Linova can choose cities $$$2$$$, $$$5$$$, $$$6$$$, $$$7$$$ to develop industry, then the happiness of the envoy from city $$$2$$$ is $$$1$$$, the happiness of envoys from cities $$$5$$$, $$$6$$$, $$$7$$$ is $$$2$$$. The sum of happinesses is $$$7$$$, and it can be proved to be the maximum one...
Java 8
standard input
[ "dp", "greedy", "sortings", "dfs and similar", "trees" ]
47129977694cb371c7647cfd0db63d29
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2\le n\le 2 \cdot 10^5$$$, $$$1\le k&lt; n$$$) Β β€” the number of cities and industry cities respectively. Each of the next $$$n-1$$$ lines contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$), denoting there is a road connecting city $$$u$$$ and cit...
1,600
Print the only line containing a single integer Β β€” the maximum possible sum of happinesses of all envoys.
standard output
PASSED
5200801545cd13b5e766b48a640aecb5
train_001.jsonl
1586961300
Writing light novels is the most important thing in Linova's life. Last night, Linova dreamed about a fantastic kingdom. She began to write a light novel for the kingdom as soon as she woke up, and of course, she is the queen of it.Β There are $$$n$$$ cities and $$$n-1$$$ two-way roads connecting pairs of cities in the ...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int k=sc.nextInt(); HashMap<Integer,ArrayList<Integer>> map=new HashMap<>(); for(int i=0;i<n-1;i++) { int x=sc.nextInt(); int y=...
Java
["7 4\n1 2\n1 3\n1 4\n3 5\n3 6\n4 7", "4 1\n1 2\n1 3\n2 4", "8 5\n7 5\n1 7\n6 1\n3 7\n8 3\n2 1\n4 5"]
2 seconds
["7", "2", "9"]
NoteIn the first example, Linova can choose cities $$$2$$$, $$$5$$$, $$$6$$$, $$$7$$$ to develop industry, then the happiness of the envoy from city $$$2$$$ is $$$1$$$, the happiness of envoys from cities $$$5$$$, $$$6$$$, $$$7$$$ is $$$2$$$. The sum of happinesses is $$$7$$$, and it can be proved to be the maximum one...
Java 8
standard input
[ "dp", "greedy", "sortings", "dfs and similar", "trees" ]
47129977694cb371c7647cfd0db63d29
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2\le n\le 2 \cdot 10^5$$$, $$$1\le k&lt; n$$$) Β β€” the number of cities and industry cities respectively. Each of the next $$$n-1$$$ lines contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$), denoting there is a road connecting city $$$u$$$ and cit...
1,600
Print the only line containing a single integer Β β€” the maximum possible sum of happinesses of all envoys.
standard output
PASSED
d2a8239378e298760325efccacab3d83
train_001.jsonl
1586961300
Writing light novels is the most important thing in Linova's life. Last night, Linova dreamed about a fantastic kingdom. She began to write a light novel for the kingdom as soon as she woke up, and of course, she is the queen of it.Β There are $$$n$$$ cities and $$$n-1$$$ two-way roads connecting pairs of cities in the ...
256 megabytes
import java.util.ArrayList; import java.util.Comparator; 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.TreeMap; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicL...
Java
["7 4\n1 2\n1 3\n1 4\n3 5\n3 6\n4 7", "4 1\n1 2\n1 3\n2 4", "8 5\n7 5\n1 7\n6 1\n3 7\n8 3\n2 1\n4 5"]
2 seconds
["7", "2", "9"]
NoteIn the first example, Linova can choose cities $$$2$$$, $$$5$$$, $$$6$$$, $$$7$$$ to develop industry, then the happiness of the envoy from city $$$2$$$ is $$$1$$$, the happiness of envoys from cities $$$5$$$, $$$6$$$, $$$7$$$ is $$$2$$$. The sum of happinesses is $$$7$$$, and it can be proved to be the maximum one...
Java 8
standard input
[ "dp", "greedy", "sortings", "dfs and similar", "trees" ]
47129977694cb371c7647cfd0db63d29
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2\le n\le 2 \cdot 10^5$$$, $$$1\le k&lt; n$$$) Β β€” the number of cities and industry cities respectively. Each of the next $$$n-1$$$ lines contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$), denoting there is a road connecting city $$$u$$$ and cit...
1,600
Print the only line containing a single integer Β β€” the maximum possible sum of happinesses of all envoys.
standard output
PASSED
03777ea688b0520f68916f68823c1554
train_001.jsonl
1586961300
Writing light novels is the most important thing in Linova's life. Last night, Linova dreamed about a fantastic kingdom. She began to write a light novel for the kingdom as soon as she woke up, and of course, she is the queen of it.Β There are $$$n$$$ cities and $$$n-1$$$ two-way roads connecting pairs of cities in the ...
256 megabytes
import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class ProblemC { public static void ez(int v) { used[v] = true; for (int i = 0; i < arr.get(v).size(); i++) { int v1 = arr.get(v).get(i); if (used[v1] == false) { len[v1] = len[v] + 1; ban[v]++; ez(v1); ban...
Java
["7 4\n1 2\n1 3\n1 4\n3 5\n3 6\n4 7", "4 1\n1 2\n1 3\n2 4", "8 5\n7 5\n1 7\n6 1\n3 7\n8 3\n2 1\n4 5"]
2 seconds
["7", "2", "9"]
NoteIn the first example, Linova can choose cities $$$2$$$, $$$5$$$, $$$6$$$, $$$7$$$ to develop industry, then the happiness of the envoy from city $$$2$$$ is $$$1$$$, the happiness of envoys from cities $$$5$$$, $$$6$$$, $$$7$$$ is $$$2$$$. The sum of happinesses is $$$7$$$, and it can be proved to be the maximum one...
Java 8
standard input
[ "dp", "greedy", "sortings", "dfs and similar", "trees" ]
47129977694cb371c7647cfd0db63d29
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2\le n\le 2 \cdot 10^5$$$, $$$1\le k&lt; n$$$) Β β€” the number of cities and industry cities respectively. Each of the next $$$n-1$$$ lines contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$), denoting there is a road connecting city $$$u$$$ and cit...
1,600
Print the only line containing a single integer Β β€” the maximum possible sum of happinesses of all envoys.
standard output
PASSED
f9f4b98ca524bed64709a30159066ff3
train_001.jsonl
1586961300
Writing light novels is the most important thing in Linova's life. Last night, Linova dreamed about a fantastic kingdom. She began to write a light novel for the kingdom as soon as she woke up, and of course, she is the queen of it.Β There are $$$n$$$ cities and $$$n-1$$$ two-way roads connecting pairs of cities in the ...
256 megabytes
/** * @author derrick20 */ import java.io.*; import java.util.*; public class LinovaKingdom { public static void main(String[] args) throws Exception { FastScanner sc = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int N = sc.nextInt(); int K = sc.nextInt(); ...
Java
["7 4\n1 2\n1 3\n1 4\n3 5\n3 6\n4 7", "4 1\n1 2\n1 3\n2 4", "8 5\n7 5\n1 7\n6 1\n3 7\n8 3\n2 1\n4 5"]
2 seconds
["7", "2", "9"]
NoteIn the first example, Linova can choose cities $$$2$$$, $$$5$$$, $$$6$$$, $$$7$$$ to develop industry, then the happiness of the envoy from city $$$2$$$ is $$$1$$$, the happiness of envoys from cities $$$5$$$, $$$6$$$, $$$7$$$ is $$$2$$$. The sum of happinesses is $$$7$$$, and it can be proved to be the maximum one...
Java 8
standard input
[ "dp", "greedy", "sortings", "dfs and similar", "trees" ]
47129977694cb371c7647cfd0db63d29
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2\le n\le 2 \cdot 10^5$$$, $$$1\le k&lt; n$$$) Β β€” the number of cities and industry cities respectively. Each of the next $$$n-1$$$ lines contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$), denoting there is a road connecting city $$$u$$$ and cit...
1,600
Print the only line containing a single integer Β β€” the maximum possible sum of happinesses of all envoys.
standard output
PASSED
0ba3f8e93c093b441bae82634897da21
train_001.jsonl
1586961300
Writing light novels is the most important thing in Linova's life. Last night, Linova dreamed about a fantastic kingdom. She began to write a light novel for the kingdom as soon as she woke up, and of course, she is the queen of it.Β There are $$$n$$$ cities and $$$n-1$$$ two-way roads connecting pairs of cities in the ...
256 megabytes
import java.util.*; import java.io.*; public class C { static final boolean stdin = true; static final String filename = ""; static FastScanner br; static PrintWriter pw; public static void main(String[] args) throws IOException { if (stdin) { br = new FastScanner(); pw = new PrintWriter(new OutputStre...
Java
["7 4\n1 2\n1 3\n1 4\n3 5\n3 6\n4 7", "4 1\n1 2\n1 3\n2 4", "8 5\n7 5\n1 7\n6 1\n3 7\n8 3\n2 1\n4 5"]
2 seconds
["7", "2", "9"]
NoteIn the first example, Linova can choose cities $$$2$$$, $$$5$$$, $$$6$$$, $$$7$$$ to develop industry, then the happiness of the envoy from city $$$2$$$ is $$$1$$$, the happiness of envoys from cities $$$5$$$, $$$6$$$, $$$7$$$ is $$$2$$$. The sum of happinesses is $$$7$$$, and it can be proved to be the maximum one...
Java 8
standard input
[ "dp", "greedy", "sortings", "dfs and similar", "trees" ]
47129977694cb371c7647cfd0db63d29
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2\le n\le 2 \cdot 10^5$$$, $$$1\le k&lt; n$$$) Β β€” the number of cities and industry cities respectively. Each of the next $$$n-1$$$ lines contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$), denoting there is a road connecting city $$$u$$$ and cit...
1,600
Print the only line containing a single integer Β β€” the maximum possible sum of happinesses of all envoys.
standard output
PASSED
fe6d7f1268fa83c85901b42d26adabf3
train_001.jsonl
1586961300
Writing light novels is the most important thing in Linova's life. Last night, Linova dreamed about a fantastic kingdom. She began to write a light novel for the kingdom as soon as she woke up, and of course, she is the queen of it.Β There are $$$n$$$ cities and $$$n-1$$$ two-way roads connecting pairs of cities in the ...
256 megabytes
import java.util.*; public class C635_PC { public static ArrayList<Integer>[] adj; public static int[] visit; public static int[] size; public static void main(String[] args) { // TODO Auto-generated method stub Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); adj = new A...
Java
["7 4\n1 2\n1 3\n1 4\n3 5\n3 6\n4 7", "4 1\n1 2\n1 3\n2 4", "8 5\n7 5\n1 7\n6 1\n3 7\n8 3\n2 1\n4 5"]
2 seconds
["7", "2", "9"]
NoteIn the first example, Linova can choose cities $$$2$$$, $$$5$$$, $$$6$$$, $$$7$$$ to develop industry, then the happiness of the envoy from city $$$2$$$ is $$$1$$$, the happiness of envoys from cities $$$5$$$, $$$6$$$, $$$7$$$ is $$$2$$$. The sum of happinesses is $$$7$$$, and it can be proved to be the maximum one...
Java 8
standard input
[ "dp", "greedy", "sortings", "dfs and similar", "trees" ]
47129977694cb371c7647cfd0db63d29
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2\le n\le 2 \cdot 10^5$$$, $$$1\le k&lt; n$$$) Β β€” the number of cities and industry cities respectively. Each of the next $$$n-1$$$ lines contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$), denoting there is a road connecting city $$$u$$$ and cit...
1,600
Print the only line containing a single integer Β β€” the maximum possible sum of happinesses of all envoys.
standard output
PASSED
55393d40e13224ae634c850dda69c2ac
train_001.jsonl
1586961300
Writing light novels is the most important thing in Linova's life. Last night, Linova dreamed about a fantastic kingdom. She began to write a light novel for the kingdom as soon as she woke up, and of course, she is the queen of it.Β There are $$$n$$$ cities and $$$n-1$$$ two-way roads connecting pairs of cities in the ...
256 megabytes
//package codeforces._635; import java.io.*; import java.lang.reflect.Array; import java.util.*; public class _635_C { public static void main (String[] args) throws Exception { String s = "7 4\n" + "1 2\n" + "1 3\n" + "1 4\n" + "3 5\n" + ...
Java
["7 4\n1 2\n1 3\n1 4\n3 5\n3 6\n4 7", "4 1\n1 2\n1 3\n2 4", "8 5\n7 5\n1 7\n6 1\n3 7\n8 3\n2 1\n4 5"]
2 seconds
["7", "2", "9"]
NoteIn the first example, Linova can choose cities $$$2$$$, $$$5$$$, $$$6$$$, $$$7$$$ to develop industry, then the happiness of the envoy from city $$$2$$$ is $$$1$$$, the happiness of envoys from cities $$$5$$$, $$$6$$$, $$$7$$$ is $$$2$$$. The sum of happinesses is $$$7$$$, and it can be proved to be the maximum one...
Java 8
standard input
[ "dp", "greedy", "sortings", "dfs and similar", "trees" ]
47129977694cb371c7647cfd0db63d29
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2\le n\le 2 \cdot 10^5$$$, $$$1\le k&lt; n$$$) Β β€” the number of cities and industry cities respectively. Each of the next $$$n-1$$$ lines contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$), denoting there is a road connecting city $$$u$$$ and cit...
1,600
Print the only line containing a single integer Β β€” the maximum possible sum of happinesses of all envoys.
standard output
PASSED
3ab132ab4068492182d5c977aad1e46e
train_001.jsonl
1586961300
Writing light novels is the most important thing in Linova's life. Last night, Linova dreamed about a fantastic kingdom. She began to write a light novel for the kingdom as soon as she woke up, and of course, she is the queen of it.Β There are $$$n$$$ cities and $$$n-1$$$ two-way roads connecting pairs of cities in the ...
256 megabytes
import java.io.*; import java.util.*; public class CodingLegacy { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; ScanReader in = new ScanReader(inputStream); PrintWriter out = new PrintWriter(outputStream); ...
Java
["7 4\n1 2\n1 3\n1 4\n3 5\n3 6\n4 7", "4 1\n1 2\n1 3\n2 4", "8 5\n7 5\n1 7\n6 1\n3 7\n8 3\n2 1\n4 5"]
2 seconds
["7", "2", "9"]
NoteIn the first example, Linova can choose cities $$$2$$$, $$$5$$$, $$$6$$$, $$$7$$$ to develop industry, then the happiness of the envoy from city $$$2$$$ is $$$1$$$, the happiness of envoys from cities $$$5$$$, $$$6$$$, $$$7$$$ is $$$2$$$. The sum of happinesses is $$$7$$$, and it can be proved to be the maximum one...
Java 8
standard input
[ "dp", "greedy", "sortings", "dfs and similar", "trees" ]
47129977694cb371c7647cfd0db63d29
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2\le n\le 2 \cdot 10^5$$$, $$$1\le k&lt; n$$$) Β β€” the number of cities and industry cities respectively. Each of the next $$$n-1$$$ lines contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$), denoting there is a road connecting city $$$u$$$ and cit...
1,600
Print the only line containing a single integer Β β€” the maximum possible sum of happinesses of all envoys.
standard output
PASSED
63bc4d84b94d287297da51a5a9e4e861
train_001.jsonl
1586961300
Writing light novels is the most important thing in Linova's life. Last night, Linova dreamed about a fantastic kingdom. She began to write a light novel for the kingdom as soon as she woke up, and of course, she is the queen of it.Β There are $$$n$$$ cities and $$$n-1$$$ two-way roads connecting pairs of cities in the ...
256 megabytes
import java.io.*; import java.util.*; import java.awt.*; public class C { BufferedReader in; PrintWriter ob; StringTokenizer st; public ArrayList<ArrayList<Integer>> gr; public PriorityQueue<Integer> pq; public boolean vis[]; public int level[]; public int subtree[]; public sta...
Java
["7 4\n1 2\n1 3\n1 4\n3 5\n3 6\n4 7", "4 1\n1 2\n1 3\n2 4", "8 5\n7 5\n1 7\n6 1\n3 7\n8 3\n2 1\n4 5"]
2 seconds
["7", "2", "9"]
NoteIn the first example, Linova can choose cities $$$2$$$, $$$5$$$, $$$6$$$, $$$7$$$ to develop industry, then the happiness of the envoy from city $$$2$$$ is $$$1$$$, the happiness of envoys from cities $$$5$$$, $$$6$$$, $$$7$$$ is $$$2$$$. The sum of happinesses is $$$7$$$, and it can be proved to be the maximum one...
Java 8
standard input
[ "dp", "greedy", "sortings", "dfs and similar", "trees" ]
47129977694cb371c7647cfd0db63d29
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2\le n\le 2 \cdot 10^5$$$, $$$1\le k&lt; n$$$) Β β€” the number of cities and industry cities respectively. Each of the next $$$n-1$$$ lines contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$), denoting there is a road connecting city $$$u$$$ and cit...
1,600
Print the only line containing a single integer Β β€” the maximum possible sum of happinesses of all envoys.
standard output
PASSED
72161c9ef4801ea085ef9a0e38b55279
train_001.jsonl
1586961300
Writing light novels is the most important thing in Linova's life. Last night, Linova dreamed about a fantastic kingdom. She began to write a light novel for the kingdom as soon as she woke up, and of course, she is the queen of it.Β There are $$$n$$$ cities and $$$n-1$$$ two-way roads connecting pairs of cities in the ...
256 megabytes
import java.io.*; import java.util.*; import java.awt.*; public class C { BufferedReader in; PrintWriter ob; StringTokenizer st; public ArrayList<ArrayList<Integer>> gr; public PriorityQueue<Integer> pq; public boolean vis[]; public int level[]; public int subtree[]; public sta...
Java
["7 4\n1 2\n1 3\n1 4\n3 5\n3 6\n4 7", "4 1\n1 2\n1 3\n2 4", "8 5\n7 5\n1 7\n6 1\n3 7\n8 3\n2 1\n4 5"]
2 seconds
["7", "2", "9"]
NoteIn the first example, Linova can choose cities $$$2$$$, $$$5$$$, $$$6$$$, $$$7$$$ to develop industry, then the happiness of the envoy from city $$$2$$$ is $$$1$$$, the happiness of envoys from cities $$$5$$$, $$$6$$$, $$$7$$$ is $$$2$$$. The sum of happinesses is $$$7$$$, and it can be proved to be the maximum one...
Java 8
standard input
[ "dp", "greedy", "sortings", "dfs and similar", "trees" ]
47129977694cb371c7647cfd0db63d29
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2\le n\le 2 \cdot 10^5$$$, $$$1\le k&lt; n$$$) Β β€” the number of cities and industry cities respectively. Each of the next $$$n-1$$$ lines contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$), denoting there is a road connecting city $$$u$$$ and cit...
1,600
Print the only line containing a single integer Β β€” the maximum possible sum of happinesses of all envoys.
standard output
PASSED
b49a2ad5f0e322b4961c1fb55d49903c
train_001.jsonl
1586961300
Writing light novels is the most important thing in Linova's life. Last night, Linova dreamed about a fantastic kingdom. She began to write a light novel for the kingdom as soon as she woke up, and of course, she is the queen of it.Β There are $$$n$$$ cities and $$$n-1$$$ two-way roads connecting pairs of cities in the ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class C { public static void main(String[] args) { class Graph { int V; // No. of vertices LinkedList<Integer> adj[]; //Adjacency Lists ...
Java
["7 4\n1 2\n1 3\n1 4\n3 5\n3 6\n4 7", "4 1\n1 2\n1 3\n2 4", "8 5\n7 5\n1 7\n6 1\n3 7\n8 3\n2 1\n4 5"]
2 seconds
["7", "2", "9"]
NoteIn the first example, Linova can choose cities $$$2$$$, $$$5$$$, $$$6$$$, $$$7$$$ to develop industry, then the happiness of the envoy from city $$$2$$$ is $$$1$$$, the happiness of envoys from cities $$$5$$$, $$$6$$$, $$$7$$$ is $$$2$$$. The sum of happinesses is $$$7$$$, and it can be proved to be the maximum one...
Java 8
standard input
[ "dp", "greedy", "sortings", "dfs and similar", "trees" ]
47129977694cb371c7647cfd0db63d29
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2\le n\le 2 \cdot 10^5$$$, $$$1\le k&lt; n$$$) Β β€” the number of cities and industry cities respectively. Each of the next $$$n-1$$$ lines contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$), denoting there is a road connecting city $$$u$$$ and cit...
1,600
Print the only line containing a single integer Β β€” the maximum possible sum of happinesses of all envoys.
standard output
PASSED
320415f28dde2743e2f662e1e16f9515
train_001.jsonl
1586961300
Writing light novels is the most important thing in Linova's life. Last night, Linova dreamed about a fantastic kingdom. She began to write a light novel for the kingdom as soon as she woke up, and of course, she is the queen of it.Β There are $$$n$$$ cities and $$$n-1$$$ two-way roads connecting pairs of cities in the ...
256 megabytes
/** * The author of the following code is - Dewansh Nigam * Username - dewanshnigam * Unstoppable Now. */ // The author of this Code is -> Dewansh Nigam // Username -> dewanshnigam import java.util.*; import java.io.*; public class CF1 { // cycle in a directed graph dfs. static InputReader in=new Inpu...
Java
["7 4\n1 2\n1 3\n1 4\n3 5\n3 6\n4 7", "4 1\n1 2\n1 3\n2 4", "8 5\n7 5\n1 7\n6 1\n3 7\n8 3\n2 1\n4 5"]
2 seconds
["7", "2", "9"]
NoteIn the first example, Linova can choose cities $$$2$$$, $$$5$$$, $$$6$$$, $$$7$$$ to develop industry, then the happiness of the envoy from city $$$2$$$ is $$$1$$$, the happiness of envoys from cities $$$5$$$, $$$6$$$, $$$7$$$ is $$$2$$$. The sum of happinesses is $$$7$$$, and it can be proved to be the maximum one...
Java 8
standard input
[ "dp", "greedy", "sortings", "dfs and similar", "trees" ]
47129977694cb371c7647cfd0db63d29
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2\le n\le 2 \cdot 10^5$$$, $$$1\le k&lt; n$$$) Β β€” the number of cities and industry cities respectively. Each of the next $$$n-1$$$ lines contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$), denoting there is a road connecting city $$$u$$$ and cit...
1,600
Print the only line containing a single integer Β β€” the maximum possible sum of happinesses of all envoys.
standard output
PASSED
4e4670f390db269558f9f7fec5d66145
train_001.jsonl
1489590300
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal faces. Icosahedron. Icosah...
256 megabytes
import java.io.*; import java.util.*; public class myclass{ public static void main(String args[]){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int ct=0; while(n>0){ String s=sc.next(); if(s.equals("Cube")){ ct+=6; } ...
Java
["4\nIcosahedron\nCube\nTetrahedron\nDodecahedron", "3\nDodecahedron\nOctahedron\nOctahedron"]
2 seconds
["42", "28"]
NoteIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.
Java 8
standard input
[ "implementation", "strings" ]
e6689123fefea251555e0e096f58f6d1
The first line of the input contains a single integer n (1 ≀ n ≀ 200 000)Β β€” the number of polyhedrons in Anton's collection. Each of the following n lines of the input contains a string siΒ β€” the name of the i-th polyhedron in Anton's collection. The string can look like this: "Tetrahedron" (without quotes), if the i-...
800
Output one numberΒ β€” the total number of faces in all the polyhedrons in Anton's collection.
standard output
PASSED
972a6f9429bd456028a35aaa08ba0d93
train_001.jsonl
1489590300
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal faces. Icosahedron. Icosah...
256 megabytes
// Problem number: 785A import java.util.Scanner; public class Anton { static int getFaceCount() { Scanner in = new Scanner(System.in); int total = in.nextInt(); in.nextLine(); int facesCount = 0; for(int i = 0; i < total; i++) { if(in.hasNextLine()) { ...
Java
["4\nIcosahedron\nCube\nTetrahedron\nDodecahedron", "3\nDodecahedron\nOctahedron\nOctahedron"]
2 seconds
["42", "28"]
NoteIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.
Java 8
standard input
[ "implementation", "strings" ]
e6689123fefea251555e0e096f58f6d1
The first line of the input contains a single integer n (1 ≀ n ≀ 200 000)Β β€” the number of polyhedrons in Anton's collection. Each of the following n lines of the input contains a string siΒ β€” the name of the i-th polyhedron in Anton's collection. The string can look like this: "Tetrahedron" (without quotes), if the i-...
800
Output one numberΒ β€” the total number of faces in all the polyhedrons in Anton's collection.
standard output
PASSED
71a595d0a3ef9b447630e5e46251cbfe
train_001.jsonl
1489590300
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal faces. Icosahedron. Icosah...
256 megabytes
import java.util.Scanner; public class MyClass { public static void main(String args[]) { Scanner sc =new Scanner (System.in); int n=sc.nextInt(); String m; int sum=0; for(int i=0;i<=n;i++){ m=sc.nextLine(); switch(m){ case"Tetrahedron":sum+=4;brea...
Java
["4\nIcosahedron\nCube\nTetrahedron\nDodecahedron", "3\nDodecahedron\nOctahedron\nOctahedron"]
2 seconds
["42", "28"]
NoteIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.
Java 8
standard input
[ "implementation", "strings" ]
e6689123fefea251555e0e096f58f6d1
The first line of the input contains a single integer n (1 ≀ n ≀ 200 000)Β β€” the number of polyhedrons in Anton's collection. Each of the following n lines of the input contains a string siΒ β€” the name of the i-th polyhedron in Anton's collection. The string can look like this: "Tetrahedron" (without quotes), if the i-...
800
Output one numberΒ β€” the total number of faces in all the polyhedrons in Anton's collection.
standard output
PASSED
41e38c1daa9eafe388947ae888739d60
train_001.jsonl
1489590300
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal faces. Icosahedron. Icosah...
256 megabytes
import java.util.*; public class Polyhedrons { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int sum = 0; int n = sc.nextInt(); for(int i=0; i<n; i++){ String in = sc.next(); if(in.equals("Tetrahedron...
Java
["4\nIcosahedron\nCube\nTetrahedron\nDodecahedron", "3\nDodecahedron\nOctahedron\nOctahedron"]
2 seconds
["42", "28"]
NoteIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.
Java 8
standard input
[ "implementation", "strings" ]
e6689123fefea251555e0e096f58f6d1
The first line of the input contains a single integer n (1 ≀ n ≀ 200 000)Β β€” the number of polyhedrons in Anton's collection. Each of the following n lines of the input contains a string siΒ β€” the name of the i-th polyhedron in Anton's collection. The string can look like this: "Tetrahedron" (without quotes), if the i-...
800
Output one numberΒ β€” the total number of faces in all the polyhedrons in Anton's collection.
standard output
PASSED
d71b7c165a4a41091788e3f88eaab353
train_001.jsonl
1489590300
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal faces. Icosahedron. Icosah...
256 megabytes
import java.util.*; public class Polyhedrons { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int sum = 0; int n = sc.nextInt(); for(int i=0; i<=n; i++){ String in = sc.nextLine(); if(in.equals("Tetrah...
Java
["4\nIcosahedron\nCube\nTetrahedron\nDodecahedron", "3\nDodecahedron\nOctahedron\nOctahedron"]
2 seconds
["42", "28"]
NoteIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.
Java 8
standard input
[ "implementation", "strings" ]
e6689123fefea251555e0e096f58f6d1
The first line of the input contains a single integer n (1 ≀ n ≀ 200 000)Β β€” the number of polyhedrons in Anton's collection. Each of the following n lines of the input contains a string siΒ β€” the name of the i-th polyhedron in Anton's collection. The string can look like this: "Tetrahedron" (without quotes), if the i-...
800
Output one numberΒ β€” the total number of faces in all the polyhedrons in Anton's collection.
standard output
PASSED
aba29959d5e95a200f75dca75dbe9222
train_001.jsonl
1489590300
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal faces. Icosahedron. Icosah...
256 megabytes
import java.util.Scanner; public class Anton_and_Polyhedrons { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int n; String vec[] = new String[21]; vec[4] = "Tetrahedron"; vec[6] = "Cube"; vec[8] = "Octahedron"; vec[12] = "Dodecahed...
Java
["4\nIcosahedron\nCube\nTetrahedron\nDodecahedron", "3\nDodecahedron\nOctahedron\nOctahedron"]
2 seconds
["42", "28"]
NoteIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.
Java 8
standard input
[ "implementation", "strings" ]
e6689123fefea251555e0e096f58f6d1
The first line of the input contains a single integer n (1 ≀ n ≀ 200 000)Β β€” the number of polyhedrons in Anton's collection. Each of the following n lines of the input contains a string siΒ β€” the name of the i-th polyhedron in Anton's collection. The string can look like this: "Tetrahedron" (without quotes), if the i-...
800
Output one numberΒ β€” the total number of faces in all the polyhedrons in Anton's collection.
standard output
PASSED
0a745994f5277f91ce1b5b041fe92f1f
train_001.jsonl
1489590300
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal faces. Icosahedron. Icosah...
256 megabytes
import java.util.Scanner; public class Anton_and_Polyhedrons { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int n; //String vec[] = new String[21]; /*vec[4] = "Tetrahedron"; vec[6] = "Cube"; vec[8] = "Octahedron"; vec[12] = "Dodec...
Java
["4\nIcosahedron\nCube\nTetrahedron\nDodecahedron", "3\nDodecahedron\nOctahedron\nOctahedron"]
2 seconds
["42", "28"]
NoteIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.
Java 8
standard input
[ "implementation", "strings" ]
e6689123fefea251555e0e096f58f6d1
The first line of the input contains a single integer n (1 ≀ n ≀ 200 000)Β β€” the number of polyhedrons in Anton's collection. Each of the following n lines of the input contains a string siΒ β€” the name of the i-th polyhedron in Anton's collection. The string can look like this: "Tetrahedron" (without quotes), if the i-...
800
Output one numberΒ β€” the total number of faces in all the polyhedrons in Anton's collection.
standard output
PASSED
b85c63041dfe816f53c51288d9e9b9bb
train_001.jsonl
1489590300
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal faces. Icosahedron. Icosah...
256 megabytes
import java.util.Scanner; public class AntonandPolyhedrons { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int sum = 0; for (int i = 0; i <= n; i++) { String polyhedron = scanner.nextLine(); ...
Java
["4\nIcosahedron\nCube\nTetrahedron\nDodecahedron", "3\nDodecahedron\nOctahedron\nOctahedron"]
2 seconds
["42", "28"]
NoteIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.
Java 8
standard input
[ "implementation", "strings" ]
e6689123fefea251555e0e096f58f6d1
The first line of the input contains a single integer n (1 ≀ n ≀ 200 000)Β β€” the number of polyhedrons in Anton's collection. Each of the following n lines of the input contains a string siΒ β€” the name of the i-th polyhedron in Anton's collection. The string can look like this: "Tetrahedron" (without quotes), if the i-...
800
Output one numberΒ β€” the total number of faces in all the polyhedrons in Anton's collection.
standard output
PASSED
4f311201a0a679f7140ed13055ce2b59
train_001.jsonl
1489590300
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal faces. Icosahedron. Icosah...
256 megabytes
import java.util.Scanner; public class Polyhedrons { public static void main(String args[]) { String[] arr =new String[5]; arr[0] = "Tetrahedron"; arr[1] = "Cube"; arr[2] = "Octahedron"; arr[3] = "Dodecahedron"; arr[4] = "Icosahedron"; int[] arrM = {4,6,8,12,20}; int n; Scanner s...
Java
["4\nIcosahedron\nCube\nTetrahedron\nDodecahedron", "3\nDodecahedron\nOctahedron\nOctahedron"]
2 seconds
["42", "28"]
NoteIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.
Java 8
standard input
[ "implementation", "strings" ]
e6689123fefea251555e0e096f58f6d1
The first line of the input contains a single integer n (1 ≀ n ≀ 200 000)Β β€” the number of polyhedrons in Anton's collection. Each of the following n lines of the input contains a string siΒ β€” the name of the i-th polyhedron in Anton's collection. The string can look like this: "Tetrahedron" (without quotes), if the i-...
800
Output one numberΒ β€” the total number of faces in all the polyhedrons in Anton's collection.
standard output
PASSED
9b05642c47452d843c470f620f119041
train_001.jsonl
1489590300
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal faces. Icosahedron. Icosah...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(), total = 0; String[] names = {"Tetrahedron", "Cube", "Octahedron", "Dodecahedron", "Icosahedron"}; int[] numFaces = {4, 6, 8, 12, 20}...
Java
["4\nIcosahedron\nCube\nTetrahedron\nDodecahedron", "3\nDodecahedron\nOctahedron\nOctahedron"]
2 seconds
["42", "28"]
NoteIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.
Java 8
standard input
[ "implementation", "strings" ]
e6689123fefea251555e0e096f58f6d1
The first line of the input contains a single integer n (1 ≀ n ≀ 200 000)Β β€” the number of polyhedrons in Anton's collection. Each of the following n lines of the input contains a string siΒ β€” the name of the i-th polyhedron in Anton's collection. The string can look like this: "Tetrahedron" (without quotes), if the i-...
800
Output one numberΒ β€” the total number of faces in all the polyhedrons in Anton's collection.
standard output
PASSED
c194f4160bc949f0b9676df36fb07dc9
train_001.jsonl
1489590300
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal faces. Icosahedron. Icosah...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int total = 0; while (n-- > 0) { String name = scanner.next(); switch (name) { case "Tetrahe...
Java
["4\nIcosahedron\nCube\nTetrahedron\nDodecahedron", "3\nDodecahedron\nOctahedron\nOctahedron"]
2 seconds
["42", "28"]
NoteIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.
Java 8
standard input
[ "implementation", "strings" ]
e6689123fefea251555e0e096f58f6d1
The first line of the input contains a single integer n (1 ≀ n ≀ 200 000)Β β€” the number of polyhedrons in Anton's collection. Each of the following n lines of the input contains a string siΒ β€” the name of the i-th polyhedron in Anton's collection. The string can look like this: "Tetrahedron" (without quotes), if the i-...
800
Output one numberΒ β€” the total number of faces in all the polyhedrons in Anton's collection.
standard output
PASSED
8fd1a463bed8d0c37e0720f6362c9e2f
train_001.jsonl
1489590300
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal faces. Icosahedron. Icosah...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); String[] names = {"Tetrahedron", "Cube", "Octahedron", "Dodecahedron", "Icosahedron"}; int[] numFaces = {4, 6, 8, 12, 20}; i...
Java
["4\nIcosahedron\nCube\nTetrahedron\nDodecahedron", "3\nDodecahedron\nOctahedron\nOctahedron"]
2 seconds
["42", "28"]
NoteIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.
Java 8
standard input
[ "implementation", "strings" ]
e6689123fefea251555e0e096f58f6d1
The first line of the input contains a single integer n (1 ≀ n ≀ 200 000)Β β€” the number of polyhedrons in Anton's collection. Each of the following n lines of the input contains a string siΒ β€” the name of the i-th polyhedron in Anton's collection. The string can look like this: "Tetrahedron" (without quotes), if the i-...
800
Output one numberΒ β€” the total number of faces in all the polyhedrons in Anton's collection.
standard output
PASSED
89427ac98d745a1edfdca6be2f91a04c
train_001.jsonl
1489590300
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal faces. Icosahedron. Icosah...
256 megabytes
import java.util.Scanner; public class task5 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int count = 0; for (int i = 0; i < n; i++) { String a = sc.next(); switch (a) { case "Tetrahedr...
Java
["4\nIcosahedron\nCube\nTetrahedron\nDodecahedron", "3\nDodecahedron\nOctahedron\nOctahedron"]
2 seconds
["42", "28"]
NoteIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.
Java 8
standard input
[ "implementation", "strings" ]
e6689123fefea251555e0e096f58f6d1
The first line of the input contains a single integer n (1 ≀ n ≀ 200 000)Β β€” the number of polyhedrons in Anton's collection. Each of the following n lines of the input contains a string siΒ β€” the name of the i-th polyhedron in Anton's collection. The string can look like this: "Tetrahedron" (without quotes), if the i-...
800
Output one numberΒ β€” the total number of faces in all the polyhedrons in Anton's collection.
standard output
PASSED
9255bd6c2c8a98d5df4c6f85b2b2b4fc
train_001.jsonl
1489590300
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal faces. Icosahedron. Icosah...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); scanner.nextLine(); String[] polyhedrons = new String[n]; int faceCounter = 0; for (int i = 0; i < n; ++i) { polyhedrons[i] = s...
Java
["4\nIcosahedron\nCube\nTetrahedron\nDodecahedron", "3\nDodecahedron\nOctahedron\nOctahedron"]
2 seconds
["42", "28"]
NoteIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.
Java 8
standard input
[ "implementation", "strings" ]
e6689123fefea251555e0e096f58f6d1
The first line of the input contains a single integer n (1 ≀ n ≀ 200 000)Β β€” the number of polyhedrons in Anton's collection. Each of the following n lines of the input contains a string siΒ β€” the name of the i-th polyhedron in Anton's collection. The string can look like this: "Tetrahedron" (without quotes), if the i-...
800
Output one numberΒ β€” the total number of faces in all the polyhedrons in Anton's collection.
standard output
PASSED
7a4ff005db256a0c7559773bdae4c650
train_001.jsonl
1489590300
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal faces. Icosahedron. Icosah...
256 megabytes
import java.util.Scanner; public class JavaApplication123 { public static void main(String[] args) { Scanner s=new Scanner(System.in); int k=s.nextInt();int sum=0; for (int i = 0; i < k+1; i++) { String s1=s.nextLine(); if(s1.equals("Cube")){sum+=6;} else if(s1.equals...
Java
["4\nIcosahedron\nCube\nTetrahedron\nDodecahedron", "3\nDodecahedron\nOctahedron\nOctahedron"]
2 seconds
["42", "28"]
NoteIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.
Java 8
standard input
[ "implementation", "strings" ]
e6689123fefea251555e0e096f58f6d1
The first line of the input contains a single integer n (1 ≀ n ≀ 200 000)Β β€” the number of polyhedrons in Anton's collection. Each of the following n lines of the input contains a string siΒ β€” the name of the i-th polyhedron in Anton's collection. The string can look like this: "Tetrahedron" (without quotes), if the i-...
800
Output one numberΒ β€” the total number of faces in all the polyhedrons in Anton's collection.
standard output
PASSED
24499ac5850127140254d1885e96e746
train_001.jsonl
1489590300
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal faces. Icosahedron. Icosah...
256 megabytes
import java.util.Scanner; public class JavaApplication123 { public static void main(String[] args) { Scanner s=new Scanner(System.in); int k=s.nextInt();int sum=0; for (int i = 0; i < k+1; i++) { String s1=s.nextLine(); if(s1.equals("Cube")) {sum+=6;} else if(...
Java
["4\nIcosahedron\nCube\nTetrahedron\nDodecahedron", "3\nDodecahedron\nOctahedron\nOctahedron"]
2 seconds
["42", "28"]
NoteIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.
Java 8
standard input
[ "implementation", "strings" ]
e6689123fefea251555e0e096f58f6d1
The first line of the input contains a single integer n (1 ≀ n ≀ 200 000)Β β€” the number of polyhedrons in Anton's collection. Each of the following n lines of the input contains a string siΒ β€” the name of the i-th polyhedron in Anton's collection. The string can look like this: "Tetrahedron" (without quotes), if the i-...
800
Output one numberΒ β€” the total number of faces in all the polyhedrons in Anton's collection.
standard output
PASSED
874afed3614c65fa9dca13c0fe160a41
train_001.jsonl
1489590300
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal faces. Icosahedron. Icosah...
256 megabytes
import java.util.*; public class polygons { public static void main(String[] args) { Scanner obj=new Scanner(System.in); int n=obj.nextInt(); int sum=0; String poly=""; for(int i=0;i<=n;i++) { poly=obj.nextLine(); if((poly).equals("Tetrahed...
Java
["4\nIcosahedron\nCube\nTetrahedron\nDodecahedron", "3\nDodecahedron\nOctahedron\nOctahedron"]
2 seconds
["42", "28"]
NoteIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.
Java 8
standard input
[ "implementation", "strings" ]
e6689123fefea251555e0e096f58f6d1
The first line of the input contains a single integer n (1 ≀ n ≀ 200 000)Β β€” the number of polyhedrons in Anton's collection. Each of the following n lines of the input contains a string siΒ β€” the name of the i-th polyhedron in Anton's collection. The string can look like this: "Tetrahedron" (without quotes), if the i-...
800
Output one numberΒ β€” the total number of faces in all the polyhedrons in Anton's collection.
standard output
PASSED
1e33c56b2b1121a6c8ec643f30cd2cdc
train_001.jsonl
1489590300
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal faces. Icosahedron. Icosah...
256 megabytes
import java.util.*; import java.io.*; /* Although copied but copying snippet does'nt Gurantee AC :-) ~~~~~~~~ ksj ~~~~~~~ */ //Did I need Public ??????????????/ public class Prob { public static int max = (int) (1e9+7); public static void main(String[] args) { new Thread(null ,new ...
Java
["4\nIcosahedron\nCube\nTetrahedron\nDodecahedron", "3\nDodecahedron\nOctahedron\nOctahedron"]
2 seconds
["42", "28"]
NoteIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.
Java 8
standard input
[ "implementation", "strings" ]
e6689123fefea251555e0e096f58f6d1
The first line of the input contains a single integer n (1 ≀ n ≀ 200 000)Β β€” the number of polyhedrons in Anton's collection. Each of the following n lines of the input contains a string siΒ β€” the name of the i-th polyhedron in Anton's collection. The string can look like this: "Tetrahedron" (without quotes), if the i-...
800
Output one numberΒ β€” the total number of faces in all the polyhedrons in Anton's collection.
standard output
PASSED
b40ab56c01e5fb80e30c32422017aee6
train_001.jsonl
1489590300
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal faces. Icosahedron. Icosah...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(f.readLine()); int ans = 0; ...
Java
["4\nIcosahedron\nCube\nTetrahedron\nDodecahedron", "3\nDodecahedron\nOctahedron\nOctahedron"]
2 seconds
["42", "28"]
NoteIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.
Java 8
standard input
[ "implementation", "strings" ]
e6689123fefea251555e0e096f58f6d1
The first line of the input contains a single integer n (1 ≀ n ≀ 200 000)Β β€” the number of polyhedrons in Anton's collection. Each of the following n lines of the input contains a string siΒ β€” the name of the i-th polyhedron in Anton's collection. The string can look like this: "Tetrahedron" (without quotes), if the i-...
800
Output one numberΒ β€” the total number of faces in all the polyhedrons in Anton's collection.
standard output
PASSED
66f219b7bacff0c756c24fa1609b73ea
train_001.jsonl
1489590300
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal faces. Icosahedron. Icosah...
256 megabytes
import java.util.*; public class Main { public static void main(String ar[]) { Scanner s=new Scanner(System.in); int n=s.nextInt(); s.nextLine(); int c=0; for(int i=0;i<n;i++) { String str=s.nextLine(); if(str.equals("Tetrahedron")) c=c+4; else if(str.equals("Cube")) c=c+6; else if(str.equals("Octahedron")) c=c+8; else...
Java
["4\nIcosahedron\nCube\nTetrahedron\nDodecahedron", "3\nDodecahedron\nOctahedron\nOctahedron"]
2 seconds
["42", "28"]
NoteIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.
Java 8
standard input
[ "implementation", "strings" ]
e6689123fefea251555e0e096f58f6d1
The first line of the input contains a single integer n (1 ≀ n ≀ 200 000)Β β€” the number of polyhedrons in Anton's collection. Each of the following n lines of the input contains a string siΒ β€” the name of the i-th polyhedron in Anton's collection. The string can look like this: "Tetrahedron" (without quotes), if the i-...
800
Output one numberΒ β€” the total number of faces in all the polyhedrons in Anton's collection.
standard output
PASSED
492272686b01c4815caa3b51b58cb203
train_001.jsonl
1489590300
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal faces. Icosahedron. Icosah...
256 megabytes
import java.util.*; public class codeForce { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); s.nextLine(); int number = 0; while(n!=0) { String input = s.nextLine(); switch(Character.toUpperCase(input.charAt(0))) { case 'T': number = number ...
Java
["4\nIcosahedron\nCube\nTetrahedron\nDodecahedron", "3\nDodecahedron\nOctahedron\nOctahedron"]
2 seconds
["42", "28"]
NoteIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.
Java 8
standard input
[ "implementation", "strings" ]
e6689123fefea251555e0e096f58f6d1
The first line of the input contains a single integer n (1 ≀ n ≀ 200 000)Β β€” the number of polyhedrons in Anton's collection. Each of the following n lines of the input contains a string siΒ β€” the name of the i-th polyhedron in Anton's collection. The string can look like this: "Tetrahedron" (without quotes), if the i-...
800
Output one numberΒ β€” the total number of faces in all the polyhedrons in Anton's collection.
standard output
PASSED
1530f12c07a32b1638e51d402a2997d8
train_001.jsonl
1489590300
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal faces. Icosahedron. Icosah...
256 megabytes
import java.util.*; import java.io.*; public class c1 { public static void main(String[] args) throws Exception{ Scanner in=new Scanner(System.in); long n=in.nextLong(); long sum=0; in.nextLine(); while(n!=0) { String s=in.nextLine(); if(s.equals("Tetrahedron")) ...
Java
["4\nIcosahedron\nCube\nTetrahedron\nDodecahedron", "3\nDodecahedron\nOctahedron\nOctahedron"]
2 seconds
["42", "28"]
NoteIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.
Java 8
standard input
[ "implementation", "strings" ]
e6689123fefea251555e0e096f58f6d1
The first line of the input contains a single integer n (1 ≀ n ≀ 200 000)Β β€” the number of polyhedrons in Anton's collection. Each of the following n lines of the input contains a string siΒ β€” the name of the i-th polyhedron in Anton's collection. The string can look like this: "Tetrahedron" (without quotes), if the i-...
800
Output one numberΒ β€” the total number of faces in all the polyhedrons in Anton's collection.
standard output
PASSED
d7cb61d1de48ef4f385aa8f685be9d57
train_001.jsonl
1489590300
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal faces. Icosahedron. Icosah...
256 megabytes
/****************************************************************************** Online Java Compiler. Code, Compile, Run and Debug java program online. Write your code in this editor and press "Run" button to execute it. *****************************************************...
Java
["4\nIcosahedron\nCube\nTetrahedron\nDodecahedron", "3\nDodecahedron\nOctahedron\nOctahedron"]
2 seconds
["42", "28"]
NoteIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.
Java 8
standard input
[ "implementation", "strings" ]
e6689123fefea251555e0e096f58f6d1
The first line of the input contains a single integer n (1 ≀ n ≀ 200 000)Β β€” the number of polyhedrons in Anton's collection. Each of the following n lines of the input contains a string siΒ β€” the name of the i-th polyhedron in Anton's collection. The string can look like this: "Tetrahedron" (without quotes), if the i-...
800
Output one numberΒ β€” the total number of faces in all the polyhedrons in Anton's collection.
standard output
PASSED
f3b33c2ad9b0a0fdd4e634bd8f81c9f3
train_001.jsonl
1489590300
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal faces. Icosahedron. Icosah...
256 megabytes
/****************************************************************************** Online Java Compiler. Code, Compile, Run and Debug java program online. Write your code in this editor and press "Run" button to execute it. *****************************************************...
Java
["4\nIcosahedron\nCube\nTetrahedron\nDodecahedron", "3\nDodecahedron\nOctahedron\nOctahedron"]
2 seconds
["42", "28"]
NoteIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.
Java 8
standard input
[ "implementation", "strings" ]
e6689123fefea251555e0e096f58f6d1
The first line of the input contains a single integer n (1 ≀ n ≀ 200 000)Β β€” the number of polyhedrons in Anton's collection. Each of the following n lines of the input contains a string siΒ β€” the name of the i-th polyhedron in Anton's collection. The string can look like this: "Tetrahedron" (without quotes), if the i-...
800
Output one numberΒ β€” the total number of faces in all the polyhedrons in Anton's collection.
standard output
PASSED
425456bc32b65148dcd2ec5dd7791338
train_001.jsonl
1489590300
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal faces. Icosahedron. Icosah...
256 megabytes
import java.util.Scanner; public class Homework { public static void main(String[] args) { int k = 0; Scanner in = new Scanner(System.in); int n = in.nextInt(); String[] names = new String[n]; for (int i = 0; i < n; i++) { names[i] = in.next(); } ...
Java
["4\nIcosahedron\nCube\nTetrahedron\nDodecahedron", "3\nDodecahedron\nOctahedron\nOctahedron"]
2 seconds
["42", "28"]
NoteIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.
Java 8
standard input
[ "implementation", "strings" ]
e6689123fefea251555e0e096f58f6d1
The first line of the input contains a single integer n (1 ≀ n ≀ 200 000)Β β€” the number of polyhedrons in Anton's collection. Each of the following n lines of the input contains a string siΒ β€” the name of the i-th polyhedron in Anton's collection. The string can look like this: "Tetrahedron" (without quotes), if the i-...
800
Output one numberΒ β€” the total number of faces in all the polyhedrons in Anton's collection.
standard output
PASSED
488433f4dc74f795a17afa77240b505d
train_001.jsonl
1489590300
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal faces. Icosahedron. Icosah...
256 megabytes
import java.util.Scanner; public class Homework { public static void main(String[] args) { int k = 0; Scanner in = new Scanner(System.in); int n = in.nextInt(); String[] names = new String[n]; for (int i = 0; i < n; i++) { names[i] = in.next(); } ...
Java
["4\nIcosahedron\nCube\nTetrahedron\nDodecahedron", "3\nDodecahedron\nOctahedron\nOctahedron"]
2 seconds
["42", "28"]
NoteIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.
Java 8
standard input
[ "implementation", "strings" ]
e6689123fefea251555e0e096f58f6d1
The first line of the input contains a single integer n (1 ≀ n ≀ 200 000)Β β€” the number of polyhedrons in Anton's collection. Each of the following n lines of the input contains a string siΒ β€” the name of the i-th polyhedron in Anton's collection. The string can look like this: "Tetrahedron" (without quotes), if the i-...
800
Output one numberΒ β€” the total number of faces in all the polyhedrons in Anton's collection.
standard output
PASSED
2d2e0930cd41c5005100c5b4d426af5e
train_001.jsonl
1489590300
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal faces. Icosahedron. Icosah...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; import java.math.*; import java.util.*; public class t1{ public static void main(String[] args) { Scanner scan=new Scanner(System.in); int n=scan.nextInt(); String[] ary=new String[n]; scan.nextLi...
Java
["4\nIcosahedron\nCube\nTetrahedron\nDodecahedron", "3\nDodecahedron\nOctahedron\nOctahedron"]
2 seconds
["42", "28"]
NoteIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.
Java 8
standard input
[ "implementation", "strings" ]
e6689123fefea251555e0e096f58f6d1
The first line of the input contains a single integer n (1 ≀ n ≀ 200 000)Β β€” the number of polyhedrons in Anton's collection. Each of the following n lines of the input contains a string siΒ β€” the name of the i-th polyhedron in Anton's collection. The string can look like this: "Tetrahedron" (without quotes), if the i-...
800
Output one numberΒ β€” the total number of faces in all the polyhedrons in Anton's collection.
standard output
PASSED
f12068ad802f53bc9e058603acc04a7e
train_001.jsonl
1489590300
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal faces. Icosahedron. Icosah...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; import java.math.*; import java.util.*; public class t1{ public static void main(String[] args) { Scanner scan=new Scanner(System.in); int n=scan.nextInt(); scan.nextLine(); int sum=0; int k=0; ...
Java
["4\nIcosahedron\nCube\nTetrahedron\nDodecahedron", "3\nDodecahedron\nOctahedron\nOctahedron"]
2 seconds
["42", "28"]
NoteIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.
Java 8
standard input
[ "implementation", "strings" ]
e6689123fefea251555e0e096f58f6d1
The first line of the input contains a single integer n (1 ≀ n ≀ 200 000)Β β€” the number of polyhedrons in Anton's collection. Each of the following n lines of the input contains a string siΒ β€” the name of the i-th polyhedron in Anton's collection. The string can look like this: "Tetrahedron" (without quotes), if the i-...
800
Output one numberΒ β€” the total number of faces in all the polyhedrons in Anton's collection.
standard output
PASSED
ace5ac2fdf7ec60396d65b699112239d
train_001.jsonl
1489590300
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal faces. Icosahedron. Icosah...
256 megabytes
import java.io.IOException; import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class Test { public static void main(String[] args) throws IOException { Map<String, Integer> map = new HashMap<String, Integer>(); map.put("Tetrahedron", 4); map.put("Cube", 6); map.put("Octahed...
Java
["4\nIcosahedron\nCube\nTetrahedron\nDodecahedron", "3\nDodecahedron\nOctahedron\nOctahedron"]
2 seconds
["42", "28"]
NoteIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.
Java 8
standard input
[ "implementation", "strings" ]
e6689123fefea251555e0e096f58f6d1
The first line of the input contains a single integer n (1 ≀ n ≀ 200 000)Β β€” the number of polyhedrons in Anton's collection. Each of the following n lines of the input contains a string siΒ β€” the name of the i-th polyhedron in Anton's collection. The string can look like this: "Tetrahedron" (without quotes), if the i-...
800
Output one numberΒ β€” the total number of faces in all the polyhedrons in Anton's collection.
standard output
PASSED
c4133a7b68668dd6de705e7236d766f9
train_001.jsonl
1489590300
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal faces. Icosahedron. Icosah...
256 megabytes
import java.io.*; import java.util.Scanner; public class Antonpoly { public static void main(String[] args) { // Scanner myObj = new Scanner(System.in); Scanner line = new Scanner(System.in); int n = line.nextInt(); int res = 0; for (int i = 0; i < n; i++) { ...
Java
["4\nIcosahedron\nCube\nTetrahedron\nDodecahedron", "3\nDodecahedron\nOctahedron\nOctahedron"]
2 seconds
["42", "28"]
NoteIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.
Java 8
standard input
[ "implementation", "strings" ]
e6689123fefea251555e0e096f58f6d1
The first line of the input contains a single integer n (1 ≀ n ≀ 200 000)Β β€” the number of polyhedrons in Anton's collection. Each of the following n lines of the input contains a string siΒ β€” the name of the i-th polyhedron in Anton's collection. The string can look like this: "Tetrahedron" (without quotes), if the i-...
800
Output one numberΒ β€” the total number of faces in all the polyhedrons in Anton's collection.
standard output
PASSED
c516ba2c03f7572c3e90639eecf911c2
train_001.jsonl
1489590300
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal faces. Icosahedron. Icosah...
256 megabytes
import java.util.*; public class Bob{ public static void main(String[] args){ Scanner in=new Scanner(System.in); int n=in.nextInt(); int sum=0; for(int i=0;i<n+1;i++) { String s=in.nextLine(); if(s.equals("Tetrahedron")){ sum=sum+4; } else if(s.equals("Cube")){ sum=sum+6; } else if(s.equals("Octahedron")) { sum=sum+8;...
Java
["4\nIcosahedron\nCube\nTetrahedron\nDodecahedron", "3\nDodecahedron\nOctahedron\nOctahedron"]
2 seconds
["42", "28"]
NoteIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.
Java 8
standard input
[ "implementation", "strings" ]
e6689123fefea251555e0e096f58f6d1
The first line of the input contains a single integer n (1 ≀ n ≀ 200 000)Β β€” the number of polyhedrons in Anton's collection. Each of the following n lines of the input contains a string siΒ β€” the name of the i-th polyhedron in Anton's collection. The string can look like this: "Tetrahedron" (without quotes), if the i-...
800
Output one numberΒ β€” the total number of faces in all the polyhedrons in Anton's collection.
standard output
PASSED
e33be340c3afdfabfdb3f5ecce944582
train_001.jsonl
1489590300
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal faces. Icosahedron. Icosah...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); int a = input.nextInt(); String temp; int result = 0; for (int i = 0; i < a; i++) { temp = input.next(); if (temp.equals("Tet...
Java
["4\nIcosahedron\nCube\nTetrahedron\nDodecahedron", "3\nDodecahedron\nOctahedron\nOctahedron"]
2 seconds
["42", "28"]
NoteIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.
Java 8
standard input
[ "implementation", "strings" ]
e6689123fefea251555e0e096f58f6d1
The first line of the input contains a single integer n (1 ≀ n ≀ 200 000)Β β€” the number of polyhedrons in Anton's collection. Each of the following n lines of the input contains a string siΒ β€” the name of the i-th polyhedron in Anton's collection. The string can look like this: "Tetrahedron" (without quotes), if the i-...
800
Output one numberΒ β€” the total number of faces in all the polyhedrons in Anton's collection.
standard output
PASSED
74cbcce371e2900461a073940ce9cbab
train_001.jsonl
1489590300
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal faces. Icosahedron. Icosah...
256 megabytes
import java.util.*; public class Solutions { public static void main(String[] args) { Scanner kbd = new Scanner(System.in); int n = kbd.nextInt(); int sum = 0; for (int i = 0; i < n; i++) { String P=kbd.next(); if(P.equals("Tetrahedron")) sum+=4; else if(P.equals("Cube")) sum+=6; else if(P....
Java
["4\nIcosahedron\nCube\nTetrahedron\nDodecahedron", "3\nDodecahedron\nOctahedron\nOctahedron"]
2 seconds
["42", "28"]
NoteIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.
Java 8
standard input
[ "implementation", "strings" ]
e6689123fefea251555e0e096f58f6d1
The first line of the input contains a single integer n (1 ≀ n ≀ 200 000)Β β€” the number of polyhedrons in Anton's collection. Each of the following n lines of the input contains a string siΒ β€” the name of the i-th polyhedron in Anton's collection. The string can look like this: "Tetrahedron" (without quotes), if the i-...
800
Output one numberΒ β€” the total number of faces in all the polyhedrons in Anton's collection.
standard output
PASSED
6ab6cfc5ec8e3204b6044f375fed3359
train_001.jsonl
1489590300
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal faces. Icosahedron. Icosah...
256 megabytes
import java.util.*; public class AntonAndPolyhedrons { public static void main(String[] args) { Scanner kbd = new Scanner(System.in); int n = kbd.nextInt(); int sum = 0; for (int i = 0; i < n; i++) { String P=kbd.next(); if(P.equals("Tetrahedron")) sum+=4; else if(P.equals("Cube")) sum+=6; ...
Java
["4\nIcosahedron\nCube\nTetrahedron\nDodecahedron", "3\nDodecahedron\nOctahedron\nOctahedron"]
2 seconds
["42", "28"]
NoteIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.
Java 8
standard input
[ "implementation", "strings" ]
e6689123fefea251555e0e096f58f6d1
The first line of the input contains a single integer n (1 ≀ n ≀ 200 000)Β β€” the number of polyhedrons in Anton's collection. Each of the following n lines of the input contains a string siΒ β€” the name of the i-th polyhedron in Anton's collection. The string can look like this: "Tetrahedron" (without quotes), if the i-...
800
Output one numberΒ β€” the total number of faces in all the polyhedrons in Anton's collection.
standard output
PASSED
50fbe7b2f90f5dce0aa24eecd3b2415a
train_001.jsonl
1506791100
You can perfectly predict the price of a certain stock for the next N days. You would like to profit on this knowledge, but only want to transact one share of stock per day. That is, each day you will either buy one share, sell one share, or do nothing. Initially you own zero shares, and you cannot sell shares when you...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class E_buyLowSellHigh { public static void main(String[] args) throws IOException { FastScanner sc = new FastScanner(System.in); PrintWriter pw = new PrintWriter(System.out); int n = sc.nextInt(); int[] arr =...
Java
["9\n10 5 4 7 9 12 6 2 10", "20\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4"]
2 seconds
["20", "41"]
NoteIn the first example, buy a share at 5, buy another at 4, sell one at 9 and another at 12. Then buy at 2 and sell at 10. The total profit is  - 5 - 4 + 9 + 12 - 2 + 10 = 20.
Java 11
standard input
[ "data structures", "greedy" ]
994bfacedc61a4a67c0997011cadb333
Input begins with an integer N (2 ≀ N ≀ 3Β·105), the number of days. Following this is a line with exactly N integers p1, p2, ..., pN (1 ≀ pi ≀ 106). The price of one share of stock on the i-th day is given by pi.
2,400
Print the maximum amount of money you can end up with at the end of N days.
standard output
PASSED
d2eaf915dcabc470cba4a33f2148a2f2
train_001.jsonl
1354807800
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ...
256 megabytes
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ import java.util.Scanner; /** * * @author master */ public class Main { /** * @param args the command line arguments ...
Java
["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"]
2 seconds
["4", "2", "1"]
NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}.
Java 8
standard input
[ "combinatorics", "binary search", "two pointers" ]
1f6491999bec55cb8d960181e830f4c8
The first line contains two integers: n and d (1 ≀ n ≀ 105;Β 1 ≀ d ≀ 109). The next line contains n integers x1, x2, ..., xn, their absolute value doesn't exceed 109 β€” the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase.
1,300
Print a single integer β€” the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
19bfa275df26511e3d3181e5f8a73f15
train_001.jsonl
1354807800
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ...
256 megabytes
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ import java.util.Scanner; /** * * @author master */ public class Main { /** * @param args the command line arguments ...
Java
["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"]
2 seconds
["4", "2", "1"]
NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}.
Java 8
standard input
[ "combinatorics", "binary search", "two pointers" ]
1f6491999bec55cb8d960181e830f4c8
The first line contains two integers: n and d (1 ≀ n ≀ 105;Β 1 ≀ d ≀ 109). The next line contains n integers x1, x2, ..., xn, their absolute value doesn't exceed 109 β€” the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase.
1,300
Print a single integer β€” the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
87ae50a044737a8b285c875a687d824c
train_001.jsonl
1354807800
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ...
256 megabytes
import java.io.*; import java.util.*; import java.lang.Math; public class Main{ static BufferedReader reader; static StringTokenizer tokenizer; static PrintWriter writer; static int nextInt() throws IOException { return Integer.parseInt(nextToken()); } static long nextLong() throws IOException { return Lon...
Java
["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"]
2 seconds
["4", "2", "1"]
NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}.
Java 8
standard input
[ "combinatorics", "binary search", "two pointers" ]
1f6491999bec55cb8d960181e830f4c8
The first line contains two integers: n and d (1 ≀ n ≀ 105;Β 1 ≀ d ≀ 109). The next line contains n integers x1, x2, ..., xn, their absolute value doesn't exceed 109 β€” the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase.
1,300
Print a single integer β€” the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
0bf7dd955d91a6358a61ab750cca9526
train_001.jsonl
1354807800
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static long bs (int[] arr, int i,int l, int h, int d){ if (h >= l) { int mid = (h+l) / 2; if(mid==arr.length-1) return mid; if(mid<arr.length-1){ if (arr[mid]-arr[i] <= d && arr[mid+1]-arr[i...
Java
["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"]
2 seconds
["4", "2", "1"]
NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}.
Java 8
standard input
[ "combinatorics", "binary search", "two pointers" ]
1f6491999bec55cb8d960181e830f4c8
The first line contains two integers: n and d (1 ≀ n ≀ 105;Β 1 ≀ d ≀ 109). The next line contains n integers x1, x2, ..., xn, their absolute value doesn't exceed 109 β€” the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase.
1,300
Print a single integer β€” the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
ca1798c2ca7038abb5efcbdeb600c881
train_001.jsonl
1354807800
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class loser { static class InputReader { public BufferedReader br; public StringTokenizer token; public InputReader(InputStream stream) { br=new BufferedReader(new InputStreamReader(stream),32768); ...
Java
["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"]
2 seconds
["4", "2", "1"]
NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}.
Java 8
standard input
[ "combinatorics", "binary search", "two pointers" ]
1f6491999bec55cb8d960181e830f4c8
The first line contains two integers: n and d (1 ≀ n ≀ 105;Β 1 ≀ d ≀ 109). The next line contains n integers x1, x2, ..., xn, their absolute value doesn't exceed 109 β€” the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase.
1,300
Print a single integer β€” the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
cf243a975e3ed866495b5183a4b14400
train_001.jsonl
1354807800
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ...
256 megabytes
import java.util.*; public class Solution{ public static void main(String arg[]) { Scanner io=new Scanner(System.in); int n=io.nextInt(),d=io.nextInt(); int arr[]=new int[n]; for(int i=0;i<n;i++) arr[i]=io.nextInt(); long count=0; int j=0; for...
Java
["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"]
2 seconds
["4", "2", "1"]
NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}.
Java 8
standard input
[ "combinatorics", "binary search", "two pointers" ]
1f6491999bec55cb8d960181e830f4c8
The first line contains two integers: n and d (1 ≀ n ≀ 105;Β 1 ≀ d ≀ 109). The next line contains n integers x1, x2, ..., xn, their absolute value doesn't exceed 109 β€” the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase.
1,300
Print a single integer β€” the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
26dc26b750938a3211047a463e2b54d2
train_001.jsonl
1354807800
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; impo...
Java
["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"]
2 seconds
["4", "2", "1"]
NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}.
Java 8
standard input
[ "combinatorics", "binary search", "two pointers" ]
1f6491999bec55cb8d960181e830f4c8
The first line contains two integers: n and d (1 ≀ n ≀ 105;Β 1 ≀ d ≀ 109). The next line contains n integers x1, x2, ..., xn, their absolute value doesn't exceed 109 β€” the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase.
1,300
Print a single integer β€” the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
e9923c3d243262d650c0552138479835
train_001.jsonl
1354807800
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Codechef { static PrintWriter out=new PrintWriter(System.out); static FastScanner in = new FastScanner(System.in); static class FastScanner {BufferedReader br;StringTokenizer stok;FastScanner(InputStream is) {br = new BufferedRead...
Java
["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"]
2 seconds
["4", "2", "1"]
NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}.
Java 8
standard input
[ "combinatorics", "binary search", "two pointers" ]
1f6491999bec55cb8d960181e830f4c8
The first line contains two integers: n and d (1 ≀ n ≀ 105;Β 1 ≀ d ≀ 109). The next line contains n integers x1, x2, ..., xn, their absolute value doesn't exceed 109 β€” the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase.
1,300
Print a single integer β€” the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
7176d417143f895c7f9523b107835cae
train_001.jsonl
1354807800
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ...
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
["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"]
2 seconds
["4", "2", "1"]
NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}.
Java 8
standard input
[ "combinatorics", "binary search", "two pointers" ]
1f6491999bec55cb8d960181e830f4c8
The first line contains two integers: n and d (1 ≀ n ≀ 105;Β 1 ≀ d ≀ 109). The next line contains n integers x1, x2, ..., xn, their absolute value doesn't exceed 109 β€” the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase.
1,300
Print a single integer β€” the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
63071f30656b324da15f81b60f12828d
train_001.jsonl
1354807800
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; import java.util.StringTokenizer; public class Main { static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st; static int n, d; ...
Java
["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"]
2 seconds
["4", "2", "1"]
NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}.
Java 8
standard input
[ "combinatorics", "binary search", "two pointers" ]
1f6491999bec55cb8d960181e830f4c8
The first line contains two integers: n and d (1 ≀ n ≀ 105;Β 1 ≀ d ≀ 109). The next line contains n integers x1, x2, ..., xn, their absolute value doesn't exceed 109 β€” the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase.
1,300
Print a single integer β€” the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
8f06b4506c123aeedec202578da6181c
train_001.jsonl
1354807800
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ...
256 megabytes
import java.awt.List; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.math.BigDecimal; import java.math.BigInteger; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java....
Java
["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"]
2 seconds
["4", "2", "1"]
NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}.
Java 8
standard input
[ "combinatorics", "binary search", "two pointers" ]
1f6491999bec55cb8d960181e830f4c8
The first line contains two integers: n and d (1 ≀ n ≀ 105;Β 1 ≀ d ≀ 109). The next line contains n integers x1, x2, ..., xn, their absolute value doesn't exceed 109 β€” the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase.
1,300
Print a single integer β€” the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
b9ca0326b700f6881e82c4621cddc4a6
train_001.jsonl
1545143700
Vova's family is building the Great Vova Wall (named by Vova himself). Vova's parents, grandparents, grand-grandparents contributed to it. Now it's totally up to Vova to put the finishing touches.The current state of the wall can be respresented by a sequence $$$a$$$ of $$$n$$$ integers, with $$$a_i$$$ being the height...
256 megabytes
import java.util.*; import java.io.*; public class d { public static void main(String[] Args) throws Exception { FastScanner sc = new FastScanner(System.in); PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); int n = sc.nextInt(); Node cur = null; Node head = null; int[] vals = new...
Java
["5\n2 1 1 2 5", "3\n4 5 3", "2\n10 10"]
2 seconds
["YES", "NO", "YES"]
NoteIn the first example Vova can put a brick on parts 2 and 3 to make the wall $$$[2, 2, 2, 2, 5]$$$ and then put 3 bricks on parts 1 and 2 and 3 bricks on parts 3 and 4 to make it $$$[5, 5, 5, 5, 5]$$$.In the second example Vova can put no bricks in the wall.In the third example the wall is already complete.
Java 8
standard input
[ "data structures", "implementation" ]
f73b832bbbfe688e378f3d693cfa23b8
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of parts in the wall. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) β€” the initial heights of the parts of the wall.
2,200
Print "YES" if Vova can complete the wall using any amount of bricks (possibly zero). Print "NO" otherwise.
standard output
PASSED
d22d7d023d435af5ead013f07d8d1191
train_001.jsonl
1545143700
Vova's family is building the Great Vova Wall (named by Vova himself). Vova's parents, grandparents, grand-grandparents contributed to it. Now it's totally up to Vova to put the finishing touches.The current state of the wall can be respresented by a sequence $$$a$$$ of $$$n$$$ integers, with $$$a_i$$$ being the height...
256 megabytes
import com.sun.org.apache.xpath.internal.SourceTree; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.util.*; import java.util.stream.IntStream; /** * Created by Mach on 15.12.2018. */ public class round56a { static boolean nores=false; static int maxC...
Java
["5\n2 1 1 2 5", "3\n4 5 3", "2\n10 10"]
2 seconds
["YES", "NO", "YES"]
NoteIn the first example Vova can put a brick on parts 2 and 3 to make the wall $$$[2, 2, 2, 2, 5]$$$ and then put 3 bricks on parts 1 and 2 and 3 bricks on parts 3 and 4 to make it $$$[5, 5, 5, 5, 5]$$$.In the second example Vova can put no bricks in the wall.In the third example the wall is already complete.
Java 8
standard input
[ "data structures", "implementation" ]
f73b832bbbfe688e378f3d693cfa23b8
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of parts in the wall. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) β€” the initial heights of the parts of the wall.
2,200
Print "YES" if Vova can complete the wall using any amount of bricks (possibly zero). Print "NO" otherwise.
standard output
PASSED
ecc2f1ced3bfbcb1d82d20892c3792d1
train_001.jsonl
1545143700
Vova's family is building the Great Vova Wall (named by Vova himself). Vova's parents, grandparents, grand-grandparents contributed to it. Now it's totally up to Vova to put the finishing touches.The current state of the wall can be respresented by a sequence $$$a$$$ of $$$n$$$ integers, with $$$a_i$$$ being the height...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.HashMap; im...
Java
["5\n2 1 1 2 5", "3\n4 5 3", "2\n10 10"]
2 seconds
["YES", "NO", "YES"]
NoteIn the first example Vova can put a brick on parts 2 and 3 to make the wall $$$[2, 2, 2, 2, 5]$$$ and then put 3 bricks on parts 1 and 2 and 3 bricks on parts 3 and 4 to make it $$$[5, 5, 5, 5, 5]$$$.In the second example Vova can put no bricks in the wall.In the third example the wall is already complete.
Java 8
standard input
[ "data structures", "implementation" ]
f73b832bbbfe688e378f3d693cfa23b8
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of parts in the wall. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) β€” the initial heights of the parts of the wall.
2,200
Print "YES" if Vova can complete the wall using any amount of bricks (possibly zero). Print "NO" otherwise.
standard output
PASSED
6312a2579ddd7c327616367d7a7ff2a4
train_001.jsonl
1545143700
Vova's family is building the Great Vova Wall (named by Vova himself). Vova's parents, grandparents, grand-grandparents contributed to it. Now it's totally up to Vova to put the finishing touches.The current state of the wall can be respresented by a sequence $$$a$$$ of $$$n$$$ integers, with $$$a_i$$$ being the height...
256 megabytes
//package codeforces; import java.util.Scanner; import java.util.Stack; /** * θ’«hackδΊ†, ζƒ³ζƒ³θ¦ζ€ŽδΉˆεš */ public class CF527_D3_E { public static void main(String ...args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int arr[] = new int[n]; for (int i = 0; i < n; i++) { arr[i] = in.nextInt(); ...
Java
["5\n2 1 1 2 5", "3\n4 5 3", "2\n10 10"]
2 seconds
["YES", "NO", "YES"]
NoteIn the first example Vova can put a brick on parts 2 and 3 to make the wall $$$[2, 2, 2, 2, 5]$$$ and then put 3 bricks on parts 1 and 2 and 3 bricks on parts 3 and 4 to make it $$$[5, 5, 5, 5, 5]$$$.In the second example Vova can put no bricks in the wall.In the third example the wall is already complete.
Java 8
standard input
[ "data structures", "implementation" ]
f73b832bbbfe688e378f3d693cfa23b8
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of parts in the wall. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) β€” the initial heights of the parts of the wall.
2,200
Print "YES" if Vova can complete the wall using any amount of bricks (possibly zero). Print "NO" otherwise.
standard output
PASSED
1eed65603656213f77012adb7b8420f7
train_001.jsonl
1596810900
This is an easier version of the problem E with smaller constraints.Twilight Sparkle has received a new task from Princess Celestia. This time she asked to decipher the ancient scroll containing important knowledge of pony origin.To hide the crucial information from evil eyes, pony elders cast a spell on the scroll. Th...
256 megabytes
import java.io.*; import java.lang.Math; import java.util.*; public class Main { public BufferedReader in; public PrintStream out; public boolean log_enabled = false; public boolean multiply_tests = false; public static boolean do_gen_test = false; public void gen_test() { ...
Java
["3\nabcd\nzaza\nataka", "4\ndfs\nbfs\nsms\nmms", "3\nabc\nbcd\na", "6\nlapochka\nkartyshka\nbigbabytape\nmorgenshtern\nssshhhiiittt\nqueen"]
1.5 seconds
["4", "8", "0", "2028"]
NoteNotice that the elders could have written an empty word (but they surely cast a spell on it so it holds a length $$$1$$$ now).
Java 8
standard input
[ "dp", "hashing", "string suffix structures", "implementation", "strings" ]
b27f6ae6fbad129758bba893f20b6df9
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$): the number of words in the scroll. The $$$i$$$-th of the next $$$n$$$ lines contains a string consisting of lowercase English letters: the $$$i$$$-th word in the scroll. The length of each word is more or equal than $$$1$$$. The sum of lengths ...
2,800
Print one integer: the number of ways to get a version of the original from the scroll modulo $$$10^9+7$$$.
standard output
PASSED
bdc8ce1029b4904c2221054b4d1c22cf
train_001.jsonl
1596810900
This is an easier version of the problem E with smaller constraints.Twilight Sparkle has received a new task from Princess Celestia. This time she asked to decipher the ancient scroll containing important knowledge of pony origin.To hide the crucial information from evil eyes, pony elders cast a spell on the scroll. Th...
256 megabytes
import java.io.*; import java.lang.Math; import java.util.*; public class Main { public BufferedReader in; public PrintStream out; public boolean log_enabled = false; public boolean multiply_tests = false; public static boolean do_gen_test = false; public void gen_test() { ...
Java
["3\nabcd\nzaza\nataka", "4\ndfs\nbfs\nsms\nmms", "3\nabc\nbcd\na", "6\nlapochka\nkartyshka\nbigbabytape\nmorgenshtern\nssshhhiiittt\nqueen"]
1.5 seconds
["4", "8", "0", "2028"]
NoteNotice that the elders could have written an empty word (but they surely cast a spell on it so it holds a length $$$1$$$ now).
Java 8
standard input
[ "dp", "hashing", "string suffix structures", "implementation", "strings" ]
b27f6ae6fbad129758bba893f20b6df9
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$): the number of words in the scroll. The $$$i$$$-th of the next $$$n$$$ lines contains a string consisting of lowercase English letters: the $$$i$$$-th word in the scroll. The length of each word is more or equal than $$$1$$$. The sum of lengths ...
2,800
Print one integer: the number of ways to get a version of the original from the scroll modulo $$$10^9+7$$$.
standard output
PASSED
c52090b7ec963d4ce63f993c9ea850ca
train_001.jsonl
1520583000
Oleg writes down the history of the days he lived. For each day he decides if it was good or bad. Oleg calls a non-empty sequence of days a zebra, if it starts with a bad day, ends with a bad day, and good and bad days are alternating in it. Let us denote bad days as 0 and good days as 1. Then, for example, sequences o...
512 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.util.TreeSet; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public clas...
Java
["0010100", "111"]
1 second
["3\n3 1 3 4\n3 2 5 6\n1 7", "-1"]
null
Java 8
standard input
[ "greedy" ]
37b34461876af7f2e845417268b55ffa
In the only line of input data there is a non-empty string s consisting of characters 0 and 1, which describes the history of Oleg's life. Its length (denoted as |s|) does not exceed 200 000 characters.
1,600
If there is a way to divide history into zebra subsequences, in the first line of output you should print an integer k (1 ≀ k ≀ |s|), the resulting number of subsequences. In the i-th of following k lines first print the integer li (1 ≀ li ≀ |s|), which is the length of the i-th subsequence, and then li indices of days...
standard output
PASSED
a3ebb5c8b6b0ebf4372e4739d425cc81
train_001.jsonl
1520583000
Oleg writes down the history of the days he lived. For each day he decides if it was good or bad. Oleg calls a non-empty sequence of days a zebra, if it starts with a bad day, ends with a bad day, and good and bad days are alternating in it. Let us denote bad days as 0 and good days as 1. Then, for example, sequences o...
512 megabytes
import java.io.*; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; public class A { FastScanner scanner; PrintWriter writer; void solve() throws IOException { scanner = new FastScanner(System.in); writer = new PrintWriter(System.out); String s ...
Java
["0010100", "111"]
1 second
["3\n3 1 3 4\n3 2 5 6\n1 7", "-1"]
null
Java 8
standard input
[ "greedy" ]
37b34461876af7f2e845417268b55ffa
In the only line of input data there is a non-empty string s consisting of characters 0 and 1, which describes the history of Oleg's life. Its length (denoted as |s|) does not exceed 200 000 characters.
1,600
If there is a way to divide history into zebra subsequences, in the first line of output you should print an integer k (1 ≀ k ≀ |s|), the resulting number of subsequences. In the i-th of following k lines first print the integer li (1 ≀ li ≀ |s|), which is the length of the i-th subsequence, and then li indices of days...
standard output
PASSED
f4d52b88cb9ac7eddf5060c198ff3bb3
train_001.jsonl
1520583000
Oleg writes down the history of the days he lived. For each day he decides if it was good or bad. Oleg calls a non-empty sequence of days a zebra, if it starts with a bad day, ends with a bad day, and good and bad days are alternating in it. Let us denote bad days as 0 and good days as 1. Then, for example, sequences o...
512 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); char[] s = sc.next().toCharArray(); ArrayList<ArrayList<Integer>> tZero = new Ar...
Java
["0010100", "111"]
1 second
["3\n3 1 3 4\n3 2 5 6\n1 7", "-1"]
null
Java 8
standard input
[ "greedy" ]
37b34461876af7f2e845417268b55ffa
In the only line of input data there is a non-empty string s consisting of characters 0 and 1, which describes the history of Oleg's life. Its length (denoted as |s|) does not exceed 200 000 characters.
1,600
If there is a way to divide history into zebra subsequences, in the first line of output you should print an integer k (1 ≀ k ≀ |s|), the resulting number of subsequences. In the i-th of following k lines first print the integer li (1 ≀ li ≀ |s|), which is the length of the i-th subsequence, and then li indices of days...
standard output
PASSED
a18b3373dd3bcc7254903f6f76d440ee
train_001.jsonl
1520583000
Oleg writes down the history of the days he lived. For each day he decides if it was good or bad. Oleg calls a non-empty sequence of days a zebra, if it starts with a bad day, ends with a bad day, and good and bad days are alternating in it. Let us denote bad days as 0 and good days as 1. Then, for example, sequences o...
512 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.LinkedList; public class ZebrasA469 { public static void main(String[] args) throws NumberFormatException, IOExcep...
Java
["0010100", "111"]
1 second
["3\n3 1 3 4\n3 2 5 6\n1 7", "-1"]
null
Java 8
standard input
[ "greedy" ]
37b34461876af7f2e845417268b55ffa
In the only line of input data there is a non-empty string s consisting of characters 0 and 1, which describes the history of Oleg's life. Its length (denoted as |s|) does not exceed 200 000 characters.
1,600
If there is a way to divide history into zebra subsequences, in the first line of output you should print an integer k (1 ≀ k ≀ |s|), the resulting number of subsequences. In the i-th of following k lines first print the integer li (1 ≀ li ≀ |s|), which is the length of the i-th subsequence, and then li indices of days...
standard output
PASSED
2ef940b06d74875bda56a0ecac9c6152
train_001.jsonl
1520583000
Oleg writes down the history of the days he lived. For each day he decides if it was good or bad. Oleg calls a non-empty sequence of days a zebra, if it starts with a bad day, ends with a bad day, and good and bad days are alternating in it. Let us denote bad days as 0 and good days as 1. Then, for example, sequences o...
512 megabytes
import java.io.*; import java.util.*; public class MainA { static final StdIn in = new StdIn(); static final PrintWriter out = new PrintWriter(System.out); public static void main(String[] args) { char[] s = in.next().toCharArray(); int n=s.length; //if(s[0]=='1') // fk(); List<Integer> s0 = new ArrayLi...
Java
["0010100", "111"]
1 second
["3\n3 1 3 4\n3 2 5 6\n1 7", "-1"]
null
Java 8
standard input
[ "greedy" ]
37b34461876af7f2e845417268b55ffa
In the only line of input data there is a non-empty string s consisting of characters 0 and 1, which describes the history of Oleg's life. Its length (denoted as |s|) does not exceed 200 000 characters.
1,600
If there is a way to divide history into zebra subsequences, in the first line of output you should print an integer k (1 ≀ k ≀ |s|), the resulting number of subsequences. In the i-th of following k lines first print the integer li (1 ≀ li ≀ |s|), which is the length of the i-th subsequence, and then li indices of days...
standard output
PASSED
7c9178cb572c89d1a9dd515e69a7e17e
train_001.jsonl
1520583000
Oleg writes down the history of the days he lived. For each day he decides if it was good or bad. Oleg calls a non-empty sequence of days a zebra, if it starts with a bad day, ends with a bad day, and good and bad days are alternating in it. Let us denote bad days as 0 and good days as 1. Then, for example, sequences o...
512 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Deque; impo...
Java
["0010100", "111"]
1 second
["3\n3 1 3 4\n3 2 5 6\n1 7", "-1"]
null
Java 8
standard input
[ "greedy" ]
37b34461876af7f2e845417268b55ffa
In the only line of input data there is a non-empty string s consisting of characters 0 and 1, which describes the history of Oleg's life. Its length (denoted as |s|) does not exceed 200 000 characters.
1,600
If there is a way to divide history into zebra subsequences, in the first line of output you should print an integer k (1 ≀ k ≀ |s|), the resulting number of subsequences. In the i-th of following k lines first print the integer li (1 ≀ li ≀ |s|), which is the length of the i-th subsequence, and then li indices of days...
standard output
PASSED
e4ff933394798379e7818581d584ee74
train_001.jsonl
1520583000
Oleg writes down the history of the days he lived. For each day he decides if it was good or bad. Oleg calls a non-empty sequence of days a zebra, if it starts with a bad day, ends with a bad day, and good and bad days are alternating in it. Let us denote bad days as 0 and good days as 1. Then, for example, sequences o...
512 megabytes
import java.io.BufferedWriter; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.Scanner; public class a949 { public static void main(String[] args) { Scanner in = new Scanner(System.in); char[] s = in.nextLine().toCharArray(); PrintWriter out = new Pri...
Java
["0010100", "111"]
1 second
["3\n3 1 3 4\n3 2 5 6\n1 7", "-1"]
null
Java 8
standard input
[ "greedy" ]
37b34461876af7f2e845417268b55ffa
In the only line of input data there is a non-empty string s consisting of characters 0 and 1, which describes the history of Oleg's life. Its length (denoted as |s|) does not exceed 200 000 characters.
1,600
If there is a way to divide history into zebra subsequences, in the first line of output you should print an integer k (1 ≀ k ≀ |s|), the resulting number of subsequences. In the i-th of following k lines first print the integer li (1 ≀ li ≀ |s|), which is the length of the i-th subsequence, and then li indices of days...
standard output