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
a5adf45cf30aef8f66e5d15a4e353bde
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; public class D1136 { public st...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
5e6693d686b3fe272cf5f44dda37beea
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
import java.util.*; import java.io.*; public class natsya { static class InputReader { private InputStream stream; private byte[] inbuf = new byte[1024]; private int lenbuf = 0; private int ptrbuf = 0; public InputReader(InputStream stream) { this.stream = s...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
a26e5fc7cd92f14a3cd5b1708bfa955c
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
import java.io.*; import java.util.*; public class D { public static void main(String[] args) { InputReader in = new InputReader(System.in); PrintWriter out = new PrintWriter(System.out); Solver solver = new Solver(); solver.solve(in, out); out.close(); } private s...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
b66432d0a965696033884d3f4aad4da9
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; public class D1136 { static class Scanner { ...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
2f1d658f0f2fa1e93449d8bb59252cbc
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class Main { static InputReader in = new InputReader(System.in); static PrintWriter out = new PrintWriter(System.out); static int oo = (int)1e9; // static long oo = (long)1e15; static int mod = 1_000_000_007; // static int mod = 998...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
86267c183a1aff2f808c0eede8d7d702
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
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.Collections...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
783c661fee81c11d11f83673c8a8c0d0
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Set; import java.io.IOException; import java.io.InputStreamReader; import java.io.FileNotFoundException; import java.io.File; import java.util.ArrayList; import ...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
670c2bdbc9eed2354bb39c25bea2e20d
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
//package que_b; import java.io.*; import java.util.*; public class utkarsh { InputStream is; PrintWriter out; long mod = (long)(1e9 + 7), inf = (long)(3e18); void solve() { int n = ni(), m = ni(); int a[] = new int[n]; for(int i = 0; i < n; i++) a[i] = ni() - 1; ...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
ebf53956d81734afa3715ff0f1924d61
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; import java.util.LinkedList; import java.util.ArrayList; import java.util.Queue; import java.util.Stack; import java.util.StringTokenizer; public class Main { public static void main(String[] args) { Reader in = new Reader(); ...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
63e321a47a8d4a4406aba487a812e0e4
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; import java.util.LinkedList; import java.util.ArrayList; import java.util.Queue; import java.util.Stack; import java.util.StringTokenizer; public class Main { public static void main(String[] args) { Reader in = new Reader(); ...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
17ab6f8c01fba6fda66d89da4c65786c
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; /** * @author anurag.y * @since 13/02/19. */ public class Main { private static InputReader...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
df423e8fcd6b4f24cce575107891902f
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
import java.util.*; import java.io.*; public class D { public static void main(String[] args) { FastScanner scanner = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int N = scanner.nextInt(); int M = scanner.nextInt(); int[] q = new int[N]; ArrayLi...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
7d09300cf4ed629f9bfdc2c5f158aa56
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
import java.util.*; import java.math.*; // **** D. Nastya Is Buying Lunch **** public class D { static char [] in = new char [10000]; static long HF = 300001L; public static void main (String [] arg) throws Throwable { int n = nextInt(); int m = nextInt(); int [] LINE = new int [n]; //int [] LINEPOS = new ...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
81b3329b0e899c8ee03c46a0c5b69a22
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
// No sorceries shall previal. // import java.util.Scanner; import java.io.PrintWriter; import java.util.*; import java.util.Arrays; public class InVoker { public static void main(String args[]) { Scanner inp = new Scanner(System.in); PrintWriter ou...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
48570a0a603e30c8876bc48ee6c6f3e0
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.HashSet; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.io.InputStream...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
ade1fc89a3fb43fed2748026a44de30b
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
import java.io.*; import java.util.*; import java.lang.*; public class nastyalunch{ static class Node{ Node next; int data ; Node(){ next=null; data=0; } } static class Graph{ Node start; Node last; int size; Graph(){ start=null; last=null; size=0; } } public static void main(Strin...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
e3a55695e1de2ab293bfc3de44acaef3
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.HashSet; import java.util.Iterator; public class Solve4 { public static void main(String[] args) throws ...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
2a7150c929f4097fa0ad4faed1e07281
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
//package que_b; import java.io.*; import java.util.*; public class utkarsh { InputStream is; PrintWriter out; long mod = (long)(1e9 + 7), inf = (long)(3e18); void solve() { int n = ni(), m = ni(); int a[] = new int[n]; for(int i = 0; i < n; i++) a[i] = ni() - 1; ...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
21328fec54c3b40a3c6b012778d6bbca
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Set; import java.util.HashMap; import java.io.IOException; import java.io.InputStreamReader; import java.util.HashSet; import java.util.StringTokenizer; import java.util.Map; import java.io....
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
c4b851ca956d1d8e3e526a8be2758539
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
import java.io.*; import java.util.*; public class p1136d { public static void main(String[] args)throws IOException { InputReader in = new InputReader(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); int m = in.nextInt(); int arr[] = new int[n]; for(...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
dab7bb48fcc36cf69615b8be91d46282
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
import java.io.*; import java.util.*; public class p1136d { public static void main(String[] args)throws IOException { InputReader in = new InputReader(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); int m = in.nextInt(); int arr[] = new int[n]; for(...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
4030900ef51b887f3568d4777e5e3f47
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
import java.io.*; import java.util.*; public class CF1136D { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int n = Integer.parseInt(st.nextToken()); int m = Integer....
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
c4afe5f0a1de6d53e901bd6b879adac2
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
import java.io.*; import java.util.*; import java.util.function.Function; public class MainD { static int N, M; static int[] P; static int[] U, V; public static void main(String[] args) { FastScanner sc = new FastScanner(System.in); N = sc.nextInt(); M = sc.nextInt(); ...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
0dfd40b8dd06aa95ace50474acab5682
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class D { void solve() throws IOException { int n=nextInt(); int m=nextInt(); int[] p=new int[n]; for(int i=0;i<n;i++)p[i]=nextInt() - 1; HashSet<Integer>[] s=new HashSet[n]; HashSet<Integer> q=new HashSet<>(); fo...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
67e40792e7b931da8a071f89731c06e1
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.List; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.util.LinkedList; import java.io.InputStreamReader; import java.io.InputStream; ...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
bae44418dc0eccaeefdbba6b9d2fddbf
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.util.Set; import java.util.HashMap; import java.util.InputMismatchException; import java.io.IOException; impor...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
6ed87b95c8e495f136c17c483a083018
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Deque; import java.util.HashSet; import java.util.List; import java.util.Set; public class Main { private static void solve() { int n = ni(); int m = ni(); int[] a = na(n); for (int i = 0; i < n; i ++) { a[i] --; }...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
d254be87b72d69defa43847486e106ed
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.HashSet; import java.util.Vector; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Stack; impor...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
74ab5ada4ca20c9311e98b4ca8c9eba8
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.HashSet; import java.util.StringTokenizer; import java.util.Set; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /**...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
03b5f90c755b641433d29382150ac8cc
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
import jdk.nashorn.internal.runtime.regexp.joni.exception.ValueException; import java.io.*; import java.util.*; public class E1066 { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader inp = new InputReader(inpu...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
303b5062392a8fce330bd3eda83b6cc3
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
import java.util.*; import java.io.*; public class Main implements Runnable{ FastScanner sc; PrintWriter pw; final class FastScanner { BufferedReader br; StringTokenizer st; public FastScanner() { try { br = new BufferedReader(new InputStreamReader(Syste...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
039cdeaecca1ab38e900aa3f9efcf40d
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class bhaa { InputStream is; PrintWriter o; /////////////////// CODED++ BY++ ++ ++ ++ BHAVYA++ ARORA++ ++ ++ ++ FROM++ JAYPEE++ INSTITUTE++ OF++ INFORMATION++ TECHNOLOGY++ //////////////// ////...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
e319268716f9931fee708fa63e6ad424
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
import java.io.*; import java.util.*; public class D { // ------------------------ public static void main(String[] args) { MyScanner sc = new MyScanner(); out = new PrintWriter(new BufferedOutputStream(System.out)); // ------------------------ int n=sc.nextInt(),m=sc.nextInt(); int[]p=new int[n]; for(i...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
7410966a37c4993fea4147243d7de37f
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.util.Collections; import java.util.ArrayList; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
dd31b4735ef3adb2f5a386af3e8761d0
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
import java.io.*; import java.util.*; public class B { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(); PrintWriter out = new PrintWriter(System.out); int n=sc.nextInt(),m=sc.nextInt(); int []p=new int [n]; ArrayList<Integer>[]adj=new ArrayList[n]; for(int i=0;i<n;i...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
65dcb51c82adc9ac74ba02493e9c319e
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
import java.io.*; import java.util.*; public class Main { class Pair implements Comparable<Pair> { public long first; public Pair(long first, long second) { this.first = first; this.second = second; } public long second; @Override publ...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
fbba985683f96443226ccf680ca69034
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
import java.io.*; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import java.util.Scanner; /** * <a href="http://codeforces.com/contests/1136">Codeforces Round #546 (Div. 2)</a> (2019-03-12T00:35:00+08:00) * * @author Klnsyf-Sun */ public class Main { static void solve() th...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
623e5aaae97ba573c6bdc91b4d753ce4
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
import java.util.ArrayList; import java.util.Scanner; public class D { static ArrayList adj[]; public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int m = in.nextInt(); int mas[] = new int[n]; int func[] = new int[n]; ...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
4251273d4f8752f873fe6d3a0b3085fd
train_001.jsonl
1552322100
At the big break Nastya came to the school dining room. There are $$$n$$$ pupils in the school, numbered from $$$1$$$ to $$$n$$$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she ...
256 megabytes
import java.io.*; import java.util.*; public class D { PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); // Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in))); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); ...
Java
["2 1\n1 2\n1 2", "3 3\n3 1 2\n1 2\n3 1\n3 2", "5 2\n3 1 5 4 2\n5 2\n5 4"]
2 seconds
["1", "2", "1"]
NoteIn the first example Nastya can just change places with the first pupil in the queue.Optimal sequence of changes in the second example is change places for pupils with numbers $$$1$$$ and $$$3$$$. change places for pupils with numbers $$$3$$$ and $$$2$$$. change places for pupils with numbers $$$1$$$ and $$$2$$...
Java 8
standard input
[ "greedy" ]
1716b35de299e88c891ba71f9c368b51
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 3 \cdot 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$) — the number of pupils in the queue and number of pairs of pupils such that the first one agrees to change places with the second one if the first is directly in front of the second. The sec...
1,800
Print a single integer — the number of places in queue she can move forward.
standard output
PASSED
1316627ceb778a6156b7ebcd4c126979
train_001.jsonl
1575038100
You have three piles of candies: red, green and blue candies: the first pile contains only red candies and there are $$$r$$$ candies in it, the second pile contains only green candies and there are $$$g$$$ candies in it, the third pile contains only blue candies and there are $$$b$$$ candies in it. Each day Tanya ea...
256 megabytes
import java.util.*; import java.io.*; public class Main{ public static int calculate(int a, int b, int c){ if(b + c <= a) return b + c; if((a ^ b) == 0) return (b - c) + (c >> 1) * 3 + (c & 1); return (a + b + c) / 2; ...
Java
["6\n1 1 1\n1 2 1\n4 1 1\n7 4 10\n8 1 4\n8 2 8"]
1 second
["1\n2\n2\n10\n5\n9"]
NoteIn the first example, Tanya can eat candies for one day only. She can eat any pair of candies this day because all of them have different colors.In the second example, Tanya can eat candies for two days. For example, she can eat red and green candies on the first day, and green and blue candies on the second day.In...
Java 8
standard input
[ "math" ]
1f29461c42665523d0a4d56b13f7e480
The first line contains integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a separate line of the input. It contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^8$$$) — the number of red, green and blue ca...
1,100
Print $$$t$$$ integers: the $$$i$$$-th printed integer is the answer on the $$$i$$$-th test case in the input.
standard output
PASSED
9b59e1a958c2b9d943d598c8d36658c4
train_001.jsonl
1575038100
You have three piles of candies: red, green and blue candies: the first pile contains only red candies and there are $$$r$$$ candies in it, the second pile contains only green candies and there are $$$g$$$ candies in it, the third pile contains only blue candies and there are $$$b$$$ candies in it. Each day Tanya ea...
256 megabytes
import java.util.*; import java.io.*; public class Main{ public static int calculate(int a, int b, int c){ if(b + c <= a) return b + c; return (a + b + c) / 2; } public static void main(String[] args) throws Exception{ Bu...
Java
["6\n1 1 1\n1 2 1\n4 1 1\n7 4 10\n8 1 4\n8 2 8"]
1 second
["1\n2\n2\n10\n5\n9"]
NoteIn the first example, Tanya can eat candies for one day only. She can eat any pair of candies this day because all of them have different colors.In the second example, Tanya can eat candies for two days. For example, she can eat red and green candies on the first day, and green and blue candies on the second day.In...
Java 8
standard input
[ "math" ]
1f29461c42665523d0a4d56b13f7e480
The first line contains integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a separate line of the input. It contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^8$$$) — the number of red, green and blue ca...
1,100
Print $$$t$$$ integers: the $$$i$$$-th printed integer is the answer on the $$$i$$$-th test case in the input.
standard output
PASSED
cdef4966a483a5f4853f930a2355cdcc
train_001.jsonl
1575038100
You have three piles of candies: red, green and blue candies: the first pile contains only red candies and there are $$$r$$$ candies in it, the second pile contains only green candies and there are $$$g$$$ candies in it, the third pile contains only blue candies and there are $$$b$$$ candies in it. Each day Tanya ea...
256 megabytes
import java.util.*; import java.io.*; public class MyClass { public static void main(String args[]) { FastReader sc = new FastReader(); int t = sc.nextInt(); while(t-->0){ long a[] = new long[3]; for(int i=0;i<3;i++){ a[i]=sc.nextLong(); } Arra...
Java
["6\n1 1 1\n1 2 1\n4 1 1\n7 4 10\n8 1 4\n8 2 8"]
1 second
["1\n2\n2\n10\n5\n9"]
NoteIn the first example, Tanya can eat candies for one day only. She can eat any pair of candies this day because all of them have different colors.In the second example, Tanya can eat candies for two days. For example, she can eat red and green candies on the first day, and green and blue candies on the second day.In...
Java 8
standard input
[ "math" ]
1f29461c42665523d0a4d56b13f7e480
The first line contains integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a separate line of the input. It contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^8$$$) — the number of red, green and blue ca...
1,100
Print $$$t$$$ integers: the $$$i$$$-th printed integer is the answer on the $$$i$$$-th test case in the input.
standard output
PASSED
4d9cb92c86b6dd98a9eee588a9cb182c
train_001.jsonl
1575038100
You have three piles of candies: red, green and blue candies: the first pile contains only red candies and there are $$$r$$$ candies in it, the second pile contains only green candies and there are $$$g$$$ candies in it, the third pile contains only blue candies and there are $$$b$$$ candies in it. Each day Tanya ea...
256 megabytes
/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Ideone { public static void main (String[] args) throws java.lang.Exception { // your code goes here Scanner sc=new Sc...
Java
["6\n1 1 1\n1 2 1\n4 1 1\n7 4 10\n8 1 4\n8 2 8"]
1 second
["1\n2\n2\n10\n5\n9"]
NoteIn the first example, Tanya can eat candies for one day only. She can eat any pair of candies this day because all of them have different colors.In the second example, Tanya can eat candies for two days. For example, she can eat red and green candies on the first day, and green and blue candies on the second day.In...
Java 8
standard input
[ "math" ]
1f29461c42665523d0a4d56b13f7e480
The first line contains integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a separate line of the input. It contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^8$$$) — the number of red, green and blue ca...
1,100
Print $$$t$$$ integers: the $$$i$$$-th printed integer is the answer on the $$$i$$$-th test case in the input.
standard output
PASSED
119c06c1b56b5ea49fc726564f64e55c
train_001.jsonl
1575038100
You have three piles of candies: red, green and blue candies: the first pile contains only red candies and there are $$$r$$$ candies in it, the second pile contains only green candies and there are $$$g$$$ candies in it, the third pile contains only blue candies and there are $$$b$$$ candies in it. Each day Tanya ea...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; import java.util.StringTokenizer; import java.io.PrintWriter; import java.io.*; import java.util.stream.Collectors.*; import java.lang.*; import static java.util.stream.Collectors.*; import static java...
Java
["6\n1 1 1\n1 2 1\n4 1 1\n7 4 10\n8 1 4\n8 2 8"]
1 second
["1\n2\n2\n10\n5\n9"]
NoteIn the first example, Tanya can eat candies for one day only. She can eat any pair of candies this day because all of them have different colors.In the second example, Tanya can eat candies for two days. For example, she can eat red and green candies on the first day, and green and blue candies on the second day.In...
Java 8
standard input
[ "math" ]
1f29461c42665523d0a4d56b13f7e480
The first line contains integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a separate line of the input. It contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^8$$$) — the number of red, green and blue ca...
1,100
Print $$$t$$$ integers: the $$$i$$$-th printed integer is the answer on the $$$i$$$-th test case in the input.
standard output
PASSED
b6727413cbe2579891a4129a69b6499e
train_001.jsonl
1575038100
You have three piles of candies: red, green and blue candies: the first pile contains only red candies and there are $$$r$$$ candies in it, the second pile contains only green candies and there are $$$g$$$ candies in it, the third pile contains only blue candies and there are $$$b$$$ candies in it. Each day Tanya ea...
256 megabytes
import java.io.*; import java.lang.*; import java.util.*; public class Codeforces { public static void main (String[] args) { Scanner sc=new Scanner(System.in); int t =sc.nextInt(); while(t-->0) { int i; int a[]=new int [3]; for(i=0;i<3;i++) a[i]=sc.ne...
Java
["6\n1 1 1\n1 2 1\n4 1 1\n7 4 10\n8 1 4\n8 2 8"]
1 second
["1\n2\n2\n10\n5\n9"]
NoteIn the first example, Tanya can eat candies for one day only. She can eat any pair of candies this day because all of them have different colors.In the second example, Tanya can eat candies for two days. For example, she can eat red and green candies on the first day, and green and blue candies on the second day.In...
Java 8
standard input
[ "math" ]
1f29461c42665523d0a4d56b13f7e480
The first line contains integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a separate line of the input. It contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^8$$$) — the number of red, green and blue ca...
1,100
Print $$$t$$$ integers: the $$$i$$$-th printed integer is the answer on the $$$i$$$-th test case in the input.
standard output
PASSED
10e98df3cd0df25172b494e541fe8212
train_001.jsonl
1575038100
You have three piles of candies: red, green and blue candies: the first pile contains only red candies and there are $$$r$$$ candies in it, the second pile contains only green candies and there are $$$g$$$ candies in it, the third pile contains only blue candies and there are $$$b$$$ candies in it. Each day Tanya ea...
256 megabytes
import java.io.*; import java.util.Arrays; public class SweetProblem { public static void main(String[] args){ try{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int cases = Integer.parseInt(br.readLine()); int[] arr = new int[3]; ...
Java
["6\n1 1 1\n1 2 1\n4 1 1\n7 4 10\n8 1 4\n8 2 8"]
1 second
["1\n2\n2\n10\n5\n9"]
NoteIn the first example, Tanya can eat candies for one day only. She can eat any pair of candies this day because all of them have different colors.In the second example, Tanya can eat candies for two days. For example, she can eat red and green candies on the first day, and green and blue candies on the second day.In...
Java 8
standard input
[ "math" ]
1f29461c42665523d0a4d56b13f7e480
The first line contains integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a separate line of the input. It contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^8$$$) — the number of red, green and blue ca...
1,100
Print $$$t$$$ integers: the $$$i$$$-th printed integer is the answer on the $$$i$$$-th test case in the input.
standard output
PASSED
0b90ba746411abcf56cb17d7a277b8b4
train_001.jsonl
1575038100
You have three piles of candies: red, green and blue candies: the first pile contains only red candies and there are $$$r$$$ candies in it, the second pile contains only green candies and there are $$$g$$$ candies in it, the third pile contains only blue candies and there are $$$b$$$ candies in it. Each day Tanya ea...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.StringTokenizer; public class SweetProblem { static class FastReader4 { BufferedReader br; StringToken...
Java
["6\n1 1 1\n1 2 1\n4 1 1\n7 4 10\n8 1 4\n8 2 8"]
1 second
["1\n2\n2\n10\n5\n9"]
NoteIn the first example, Tanya can eat candies for one day only. She can eat any pair of candies this day because all of them have different colors.In the second example, Tanya can eat candies for two days. For example, she can eat red and green candies on the first day, and green and blue candies on the second day.In...
Java 8
standard input
[ "math" ]
1f29461c42665523d0a4d56b13f7e480
The first line contains integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a separate line of the input. It contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^8$$$) — the number of red, green and blue ca...
1,100
Print $$$t$$$ integers: the $$$i$$$-th printed integer is the answer on the $$$i$$$-th test case in the input.
standard output
PASSED
097d52f6c5c65f1df865cda89a973d99
train_001.jsonl
1575038100
You have three piles of candies: red, green and blue candies: the first pile contains only red candies and there are $$$r$$$ candies in it, the second pile contains only green candies and there are $$$g$$$ candies in it, the third pile contains only blue candies and there are $$$b$$$ candies in it. Each day Tanya ea...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void solve(InputReader in) { int n = 3; int a[] = new int[n]; for(int i =0 ; i<n; i++) a[i] = in.readInt(); Arrays.sort(a); if(a[2] >= a[0] + a[1]) { System.out.println(a[0] + a[1]); return; } System.out.println((a...
Java
["6\n1 1 1\n1 2 1\n4 1 1\n7 4 10\n8 1 4\n8 2 8"]
1 second
["1\n2\n2\n10\n5\n9"]
NoteIn the first example, Tanya can eat candies for one day only. She can eat any pair of candies this day because all of them have different colors.In the second example, Tanya can eat candies for two days. For example, she can eat red and green candies on the first day, and green and blue candies on the second day.In...
Java 8
standard input
[ "math" ]
1f29461c42665523d0a4d56b13f7e480
The first line contains integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a separate line of the input. It contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^8$$$) — the number of red, green and blue ca...
1,100
Print $$$t$$$ integers: the $$$i$$$-th printed integer is the answer on the $$$i$$$-th test case in the input.
standard output
PASSED
a3f60b978524b16464fd3b930c2174f9
train_001.jsonl
1575038100
You have three piles of candies: red, green and blue candies: the first pile contains only red candies and there are $$$r$$$ candies in it, the second pile contains only green candies and there are $$$g$$$ candies in it, the third pile contains only blue candies and there are $$$b$$$ candies in it. Each day Tanya ea...
256 megabytes
import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Integer t = Integer.parseInt(sc.nextLine()); for (int i = 0; i < t; i++) { ...
Java
["6\n1 1 1\n1 2 1\n4 1 1\n7 4 10\n8 1 4\n8 2 8"]
1 second
["1\n2\n2\n10\n5\n9"]
NoteIn the first example, Tanya can eat candies for one day only. She can eat any pair of candies this day because all of them have different colors.In the second example, Tanya can eat candies for two days. For example, she can eat red and green candies on the first day, and green and blue candies on the second day.In...
Java 8
standard input
[ "math" ]
1f29461c42665523d0a4d56b13f7e480
The first line contains integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a separate line of the input. It contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^8$$$) — the number of red, green and blue ca...
1,100
Print $$$t$$$ integers: the $$$i$$$-th printed integer is the answer on the $$$i$$$-th test case in the input.
standard output
PASSED
90d06d8c691e58eedc61018a456e8892
train_001.jsonl
1575038100
You have three piles of candies: red, green and blue candies: the first pile contains only red candies and there are $$$r$$$ candies in it, the second pile contains only green candies and there are $$$g$$$ candies in it, the third pile contains only blue candies and there are $$$b$$$ candies in it. Each day Tanya ea...
256 megabytes
import java.util.*; public class Main { public static void main(String args[]) { Scanner ob = new Scanner(System.in); int N = ob.nextInt(); for(int n = 1; n <= N; n++) { int max = -1, sum = 0, x; for(int i = 0; i < 3; i++) { x = ob.nextInt(); ...
Java
["6\n1 1 1\n1 2 1\n4 1 1\n7 4 10\n8 1 4\n8 2 8"]
1 second
["1\n2\n2\n10\n5\n9"]
NoteIn the first example, Tanya can eat candies for one day only. She can eat any pair of candies this day because all of them have different colors.In the second example, Tanya can eat candies for two days. For example, she can eat red and green candies on the first day, and green and blue candies on the second day.In...
Java 8
standard input
[ "math" ]
1f29461c42665523d0a4d56b13f7e480
The first line contains integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a separate line of the input. It contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^8$$$) — the number of red, green and blue ca...
1,100
Print $$$t$$$ integers: the $$$i$$$-th printed integer is the answer on the $$$i$$$-th test case in the input.
standard output
PASSED
bbaa92f38318781edb5c3c7e1b574259
train_001.jsonl
1575038100
You have three piles of candies: red, green and blue candies: the first pile contains only red candies and there are $$$r$$$ candies in it, the second pile contains only green candies and there are $$$g$$$ candies in it, the third pile contains only blue candies and there are $$$b$$$ candies in it. Each day Tanya ea...
256 megabytes
import java.io.*; import java.util.*; public class CF { public static void main(String[] args) throws IOException { int n = nextInt(); for (int i = 0; i < n; i++) { int r = nextInt(); int g = nextInt(); int b = nextInt(); int[] a = {r, g, b}; ...
Java
["6\n1 1 1\n1 2 1\n4 1 1\n7 4 10\n8 1 4\n8 2 8"]
1 second
["1\n2\n2\n10\n5\n9"]
NoteIn the first example, Tanya can eat candies for one day only. She can eat any pair of candies this day because all of them have different colors.In the second example, Tanya can eat candies for two days. For example, she can eat red and green candies on the first day, and green and blue candies on the second day.In...
Java 8
standard input
[ "math" ]
1f29461c42665523d0a4d56b13f7e480
The first line contains integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a separate line of the input. It contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^8$$$) — the number of red, green and blue ca...
1,100
Print $$$t$$$ integers: the $$$i$$$-th printed integer is the answer on the $$$i$$$-th test case in the input.
standard output
PASSED
f525c7f28637ddebeed1ad2daa1f9ba7
train_001.jsonl
1575038100
You have three piles of candies: red, green and blue candies: the first pile contains only red candies and there are $$$r$$$ candies in it, the second pile contains only green candies and there are $$$g$$$ candies in it, the third pile contains only blue candies and there are $$$b$$$ candies in it. Each day Tanya ea...
256 megabytes
// @uthor -: puneet // TimeStamp -: 6:58 PM - 27/11/19 import java.io.*; import java.math.BigInteger; import java.util.*; public class EduQ1 implements Runnable { public void solve() { int t=in.ni(); while(t-->0){ int[] arr=in.intarr(3); Arrays.sort(arr); // i...
Java
["6\n1 1 1\n1 2 1\n4 1 1\n7 4 10\n8 1 4\n8 2 8"]
1 second
["1\n2\n2\n10\n5\n9"]
NoteIn the first example, Tanya can eat candies for one day only. She can eat any pair of candies this day because all of them have different colors.In the second example, Tanya can eat candies for two days. For example, she can eat red and green candies on the first day, and green and blue candies on the second day.In...
Java 8
standard input
[ "math" ]
1f29461c42665523d0a4d56b13f7e480
The first line contains integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a separate line of the input. It contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^8$$$) — the number of red, green and blue ca...
1,100
Print $$$t$$$ integers: the $$$i$$$-th printed integer is the answer on the $$$i$$$-th test case in the input.
standard output
PASSED
3fb6b5093f34737cfef6e41e05e546f9
train_001.jsonl
1575038100
You have three piles of candies: red, green and blue candies: the first pile contains only red candies and there are $$$r$$$ candies in it, the second pile contains only green candies and there are $$$g$$$ candies in it, the third pile contains only blue candies and there are $$$b$$$ candies in it. Each day Tanya ea...
256 megabytes
import java.io.*; import java.util.*; public class C324C { private static StringTokenizer st; public static void nextLine(BufferedReader br) throws IOException { st = new StringTokenizer(br.readLine()); } public static int nextInt() { return Integer.parseInt(st.nextToken(...
Java
["6\n1 1 1\n1 2 1\n4 1 1\n7 4 10\n8 1 4\n8 2 8"]
1 second
["1\n2\n2\n10\n5\n9"]
NoteIn the first example, Tanya can eat candies for one day only. She can eat any pair of candies this day because all of them have different colors.In the second example, Tanya can eat candies for two days. For example, she can eat red and green candies on the first day, and green and blue candies on the second day.In...
Java 8
standard input
[ "math" ]
1f29461c42665523d0a4d56b13f7e480
The first line contains integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a separate line of the input. It contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^8$$$) — the number of red, green and blue ca...
1,100
Print $$$t$$$ integers: the $$$i$$$-th printed integer is the answer on the $$$i$$$-th test case in the input.
standard output
PASSED
3f484cc5006c3da35fcbad328e4e8329
train_001.jsonl
1575038100
You have three piles of candies: red, green and blue candies: the first pile contains only red candies and there are $$$r$$$ candies in it, the second pile contains only green candies and there are $$$g$$$ candies in it, the third pile contains only blue candies and there are $$$b$$$ candies in it. Each day Tanya ea...
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
["6\n1 1 1\n1 2 1\n4 1 1\n7 4 10\n8 1 4\n8 2 8"]
1 second
["1\n2\n2\n10\n5\n9"]
NoteIn the first example, Tanya can eat candies for one day only. She can eat any pair of candies this day because all of them have different colors.In the second example, Tanya can eat candies for two days. For example, she can eat red and green candies on the first day, and green and blue candies on the second day.In...
Java 8
standard input
[ "math" ]
1f29461c42665523d0a4d56b13f7e480
The first line contains integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a separate line of the input. It contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^8$$$) — the number of red, green and blue ca...
1,100
Print $$$t$$$ integers: the $$$i$$$-th printed integer is the answer on the $$$i$$$-th test case in the input.
standard output
PASSED
5692edd147f509c4ce0ede6cc05d2774
train_001.jsonl
1575038100
You have three piles of candies: red, green and blue candies: the first pile contains only red candies and there are $$$r$$$ candies in it, the second pile contains only green candies and there are $$$g$$$ candies in it, the third pile contains only blue candies and there are $$$b$$$ candies in it. Each day Tanya ea...
256 megabytes
import java.io.IOException; import java.io.PrintWriter; import java.util.*; public class contest { public static void main(String[] args) throws IOException{ Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int t = sc.nextInt(); while(t-->0) { int a = sc.nextInt(); i...
Java
["6\n1 1 1\n1 2 1\n4 1 1\n7 4 10\n8 1 4\n8 2 8"]
1 second
["1\n2\n2\n10\n5\n9"]
NoteIn the first example, Tanya can eat candies for one day only. She can eat any pair of candies this day because all of them have different colors.In the second example, Tanya can eat candies for two days. For example, she can eat red and green candies on the first day, and green and blue candies on the second day.In...
Java 8
standard input
[ "math" ]
1f29461c42665523d0a4d56b13f7e480
The first line contains integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a separate line of the input. It contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^8$$$) — the number of red, green and blue ca...
1,100
Print $$$t$$$ integers: the $$$i$$$-th printed integer is the answer on the $$$i$$$-th test case in the input.
standard output
PASSED
630c9b77600c6fbe67e9c5d8446cc9fd
train_001.jsonl
1575038100
You have three piles of candies: red, green and blue candies: the first pile contains only red candies and there are $$$r$$$ candies in it, the second pile contains only green candies and there are $$$g$$$ candies in it, the third pile contains only blue candies and there are $$$b$$$ candies in it. Each day Tanya ea...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; import static java.lang.Math.max; import static java.lang.Math.min; public class SweetProblem { static BufferedReader br; static StringTokenizer st = new S...
Java
["6\n1 1 1\n1 2 1\n4 1 1\n7 4 10\n8 1 4\n8 2 8"]
1 second
["1\n2\n2\n10\n5\n9"]
NoteIn the first example, Tanya can eat candies for one day only. She can eat any pair of candies this day because all of them have different colors.In the second example, Tanya can eat candies for two days. For example, she can eat red and green candies on the first day, and green and blue candies on the second day.In...
Java 8
standard input
[ "math" ]
1f29461c42665523d0a4d56b13f7e480
The first line contains integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a separate line of the input. It contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^8$$$) — the number of red, green and blue ca...
1,100
Print $$$t$$$ integers: the $$$i$$$-th printed integer is the answer on the $$$i$$$-th test case in the input.
standard output
PASSED
99d053cca6451fb1cef6054b5dff968f
train_001.jsonl
1575038100
You have three piles of candies: red, green and blue candies: the first pile contains only red candies and there are $$$r$$$ candies in it, the second pile contains only green candies and there are $$$g$$$ candies in it, the third pile contains only blue candies and there are $$$b$$$ candies in it. Each day Tanya ea...
256 megabytes
import java.util.*; import java.io.*; public class practice { public static void main(String[] args) throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int t=Integer.parseInt(br.readLine()); while(t-- !=0) { int[]arr=new int[3]; String str=br.readLine(); String...
Java
["6\n1 1 1\n1 2 1\n4 1 1\n7 4 10\n8 1 4\n8 2 8"]
1 second
["1\n2\n2\n10\n5\n9"]
NoteIn the first example, Tanya can eat candies for one day only. She can eat any pair of candies this day because all of them have different colors.In the second example, Tanya can eat candies for two days. For example, she can eat red and green candies on the first day, and green and blue candies on the second day.In...
Java 8
standard input
[ "math" ]
1f29461c42665523d0a4d56b13f7e480
The first line contains integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a separate line of the input. It contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^8$$$) — the number of red, green and blue ca...
1,100
Print $$$t$$$ integers: the $$$i$$$-th printed integer is the answer on the $$$i$$$-th test case in the input.
standard output
PASSED
f935af318743141110bb3072f70c6930
train_001.jsonl
1575038100
You have three piles of candies: red, green and blue candies: the first pile contains only red candies and there are $$$r$$$ candies in it, the second pile contains only green candies and there are $$$g$$$ candies in it, the third pile contains only blue candies and there are $$$b$$$ candies in it. Each day Tanya ea...
256 megabytes
import java.util.*; public class Main{ public static void main (String args[]){ // write your dream! Twinkle! Scanner in = new Scanner(System.in); int test= in.nextInt(); while (test --!=0){ int r=in.nextInt(),g=in.nextInt(),b=in.nextInt(); int sum = r+g+b; int m = Math.max(r, Math.max(g, ...
Java
["6\n1 1 1\n1 2 1\n4 1 1\n7 4 10\n8 1 4\n8 2 8"]
1 second
["1\n2\n2\n10\n5\n9"]
NoteIn the first example, Tanya can eat candies for one day only. She can eat any pair of candies this day because all of them have different colors.In the second example, Tanya can eat candies for two days. For example, she can eat red and green candies on the first day, and green and blue candies on the second day.In...
Java 8
standard input
[ "math" ]
1f29461c42665523d0a4d56b13f7e480
The first line contains integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a separate line of the input. It contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^8$$$) — the number of red, green and blue ca...
1,100
Print $$$t$$$ integers: the $$$i$$$-th printed integer is the answer on the $$$i$$$-th test case in the input.
standard output
PASSED
76936ae759c4dc9fde3bdf7ab99647c7
train_001.jsonl
1575038100
You have three piles of candies: red, green and blue candies: the first pile contains only red candies and there are $$$r$$$ candies in it, the second pile contains only green candies and there are $$$g$$$ candies in it, the third pile contains only blue candies and there are $$$b$$$ candies in it. Each day Tanya ea...
256 megabytes
import java.util.*; public class problemA { public static void main(String[] args) { Scanner s=new Scanner(System.in); int t=s.nextInt(); while(t!=0){ int[] a=new int[3]; int i; for(i=0;i<3;i++){ a[i]=s.nextInt(); } Arrays.sort(a); int cnt=0; if(a[2]>a[1]+a[0]){ ...
Java
["6\n1 1 1\n1 2 1\n4 1 1\n7 4 10\n8 1 4\n8 2 8"]
1 second
["1\n2\n2\n10\n5\n9"]
NoteIn the first example, Tanya can eat candies for one day only. She can eat any pair of candies this day because all of them have different colors.In the second example, Tanya can eat candies for two days. For example, she can eat red and green candies on the first day, and green and blue candies on the second day.In...
Java 8
standard input
[ "math" ]
1f29461c42665523d0a4d56b13f7e480
The first line contains integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a separate line of the input. It contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^8$$$) — the number of red, green and blue ca...
1,100
Print $$$t$$$ integers: the $$$i$$$-th printed integer is the answer on the $$$i$$$-th test case in the input.
standard output
PASSED
a4f71244b6682732a5a1a16d7d9fde4f
train_001.jsonl
1575038100
You have three piles of candies: red, green and blue candies: the first pile contains only red candies and there are $$$r$$$ candies in it, the second pile contains only green candies and there are $$$g$$$ candies in it, the third pile contains only blue candies and there are $$$b$$$ candies in it. Each day Tanya ea...
256 megabytes
//package codeforces.round603div2; import java.io.*; import java.util.*; public class SweetProblem { public static void main(String[] args) { // try { // FastScanner in = new FastScanner(new FileInputStream("src/input.in")); // PrintWriter out = new PrintWriter(new FileOutputStream("s...
Java
["6\n1 1 1\n1 2 1\n4 1 1\n7 4 10\n8 1 4\n8 2 8"]
1 second
["1\n2\n2\n10\n5\n9"]
NoteIn the first example, Tanya can eat candies for one day only. She can eat any pair of candies this day because all of them have different colors.In the second example, Tanya can eat candies for two days. For example, she can eat red and green candies on the first day, and green and blue candies on the second day.In...
Java 8
standard input
[ "math" ]
1f29461c42665523d0a4d56b13f7e480
The first line contains integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a separate line of the input. It contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^8$$$) — the number of red, green and blue ca...
1,100
Print $$$t$$$ integers: the $$$i$$$-th printed integer is the answer on the $$$i$$$-th test case in the input.
standard output
PASSED
790510045ddb405e4523c59b3a52338d
train_001.jsonl
1575038100
You have three piles of candies: red, green and blue candies: the first pile contains only red candies and there are $$$r$$$ candies in it, the second pile contains only green candies and there are $$$g$$$ candies in it, the third pile contains only blue candies and there are $$$b$$$ candies in it. Each day Tanya ea...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.FilterInputStream; import java.io.BufferedInputStream; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author J...
Java
["6\n1 1 1\n1 2 1\n4 1 1\n7 4 10\n8 1 4\n8 2 8"]
1 second
["1\n2\n2\n10\n5\n9"]
NoteIn the first example, Tanya can eat candies for one day only. She can eat any pair of candies this day because all of them have different colors.In the second example, Tanya can eat candies for two days. For example, she can eat red and green candies on the first day, and green and blue candies on the second day.In...
Java 8
standard input
[ "math" ]
1f29461c42665523d0a4d56b13f7e480
The first line contains integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a separate line of the input. It contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^8$$$) — the number of red, green and blue ca...
1,100
Print $$$t$$$ integers: the $$$i$$$-th printed integer is the answer on the $$$i$$$-th test case in the input.
standard output
PASSED
676ab2601578579aa26b77ead2cd833e
train_001.jsonl
1575038100
You have three piles of candies: red, green and blue candies: the first pile contains only red candies and there are $$$r$$$ candies in it, the second pile contains only green candies and there are $$$g$$$ candies in it, the third pile contains only blue candies and there are $$$b$$$ candies in it. Each day Tanya ea...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class p603A { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while (t-->0){ int a[]=new int[3]; for (int i=0;i<3;i++) { a[i] = sc.nextInt(); ...
Java
["6\n1 1 1\n1 2 1\n4 1 1\n7 4 10\n8 1 4\n8 2 8"]
1 second
["1\n2\n2\n10\n5\n9"]
NoteIn the first example, Tanya can eat candies for one day only. She can eat any pair of candies this day because all of them have different colors.In the second example, Tanya can eat candies for two days. For example, she can eat red and green candies on the first day, and green and blue candies on the second day.In...
Java 8
standard input
[ "math" ]
1f29461c42665523d0a4d56b13f7e480
The first line contains integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a separate line of the input. It contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^8$$$) — the number of red, green and blue ca...
1,100
Print $$$t$$$ integers: the $$$i$$$-th printed integer is the answer on the $$$i$$$-th test case in the input.
standard output
PASSED
a9af52dbbc51d6cfe21d586b5ee2bea0
train_001.jsonl
1575038100
You have three piles of candies: red, green and blue candies: the first pile contains only red candies and there are $$$r$$$ candies in it, the second pile contains only green candies and there are $$$g$$$ candies in it, the third pile contains only blue candies and there are $$$b$$$ candies in it. Each day Tanya ea...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class que1 { public static void main(String[] args) { Scanner scn = new Scanner(System.in); int n = scn.nextInt(); for (int i = 1; i <= n; i++) { int[] arr = new int[3]; for (int l = 0; l < arr.length; l++) { arr[l] = scn.nextInt(); } Ar...
Java
["6\n1 1 1\n1 2 1\n4 1 1\n7 4 10\n8 1 4\n8 2 8"]
1 second
["1\n2\n2\n10\n5\n9"]
NoteIn the first example, Tanya can eat candies for one day only. She can eat any pair of candies this day because all of them have different colors.In the second example, Tanya can eat candies for two days. For example, she can eat red and green candies on the first day, and green and blue candies on the second day.In...
Java 8
standard input
[ "math" ]
1f29461c42665523d0a4d56b13f7e480
The first line contains integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a separate line of the input. It contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^8$$$) — the number of red, green and blue ca...
1,100
Print $$$t$$$ integers: the $$$i$$$-th printed integer is the answer on the $$$i$$$-th test case in the input.
standard output
PASSED
5a083bcaeeb9a836a285b902ddee513b
train_001.jsonl
1575038100
You have three piles of candies: red, green and blue candies: the first pile contains only red candies and there are $$$r$$$ candies in it, the second pile contains only green candies and there are $$$g$$$ candies in it, the third pile contains only blue candies and there are $$$b$$$ candies in it. Each day Tanya ea...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class SweetProblem { public static void main(String args[]) { Scanner scan = new Scanner(System.in); int t = scan.nextInt(); while (t-- > 0) { int[] a = new int[3]; for (int i = 0; i < 3; i++) { ...
Java
["6\n1 1 1\n1 2 1\n4 1 1\n7 4 10\n8 1 4\n8 2 8"]
1 second
["1\n2\n2\n10\n5\n9"]
NoteIn the first example, Tanya can eat candies for one day only. She can eat any pair of candies this day because all of them have different colors.In the second example, Tanya can eat candies for two days. For example, she can eat red and green candies on the first day, and green and blue candies on the second day.In...
Java 8
standard input
[ "math" ]
1f29461c42665523d0a4d56b13f7e480
The first line contains integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a separate line of the input. It contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^8$$$) — the number of red, green and blue ca...
1,100
Print $$$t$$$ integers: the $$$i$$$-th printed integer is the answer on the $$$i$$$-th test case in the input.
standard output
PASSED
c39afa459642ecfff4c1a648603dd211
train_001.jsonl
1575038100
You have three piles of candies: red, green and blue candies: the first pile contains only red candies and there are $$$r$$$ candies in it, the second pile contains only green candies and there are $$$g$$$ candies in it, the third pile contains only blue candies and there are $$$b$$$ candies in it. Each day Tanya ea...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper...
Java
["6\n1 1 1\n1 2 1\n4 1 1\n7 4 10\n8 1 4\n8 2 8"]
1 second
["1\n2\n2\n10\n5\n9"]
NoteIn the first example, Tanya can eat candies for one day only. She can eat any pair of candies this day because all of them have different colors.In the second example, Tanya can eat candies for two days. For example, she can eat red and green candies on the first day, and green and blue candies on the second day.In...
Java 8
standard input
[ "math" ]
1f29461c42665523d0a4d56b13f7e480
The first line contains integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a separate line of the input. It contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^8$$$) — the number of red, green and blue ca...
1,100
Print $$$t$$$ integers: the $$$i$$$-th printed integer is the answer on the $$$i$$$-th test case in the input.
standard output
PASSED
c3afc44cf98cff99fa16290eecc920a9
train_001.jsonl
1575038100
You have three piles of candies: red, green and blue candies: the first pile contains only red candies and there are $$$r$$$ candies in it, the second pile contains only green candies and there are $$$g$$$ candies in it, the third pile contains only blue candies and there are $$$b$$$ candies in it. Each day Tanya ea...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper...
Java
["6\n1 1 1\n1 2 1\n4 1 1\n7 4 10\n8 1 4\n8 2 8"]
1 second
["1\n2\n2\n10\n5\n9"]
NoteIn the first example, Tanya can eat candies for one day only. She can eat any pair of candies this day because all of them have different colors.In the second example, Tanya can eat candies for two days. For example, she can eat red and green candies on the first day, and green and blue candies on the second day.In...
Java 8
standard input
[ "math" ]
1f29461c42665523d0a4d56b13f7e480
The first line contains integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given as a separate line of the input. It contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^8$$$) — the number of red, green and blue ca...
1,100
Print $$$t$$$ integers: the $$$i$$$-th printed integer is the answer on the $$$i$$$-th test case in the input.
standard output
PASSED
1ef4b4449cc9e86bfd810ab43884a0d7
train_001.jsonl
1432312200
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x &gt; 1, such that n is divisible by x and replacing n with n / x. Whe...
256 megabytes
import java.io.*; import java.util.*; public class Main { static class Scan { private byte[] buf=new byte[1024]; private int index; private InputStream in; private int total; public Scan() { in=System.in; } public int scan()throws IOExcept...
Java
["2\n3 1\n6 3"]
3 seconds
["2\n5"]
null
Java 11
standard input
[ "dp", "constructive algorithms", "number theory", "math" ]
79d26192a25cd51d27e916adeb97f9d0
First line of input consists of single integer t (1 ≤ t ≤ 1 000 000) denoting number of games soldiers play. Then follow t lines, each contains pair of integers a and b (1 ≤ b ≤ a ≤ 5 000 000) defining the value of n for a game.
1,700
For each game output a maximum score that the second soldier can get.
standard output
PASSED
d6c6e5740b2ad8978e5aebb2f30bd84b
train_001.jsonl
1432312200
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x &gt; 1, such that n is divisible by x and replacing n with n / x. Whe...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class SoldierAndNumberGame { InputStream is; PrintWriter pw; String INPUT = ""; int MAXN = 5000001; long factors[] = new long[MAXN]; void...
Java
["2\n3 1\n6 3"]
3 seconds
["2\n5"]
null
Java 11
standard input
[ "dp", "constructive algorithms", "number theory", "math" ]
79d26192a25cd51d27e916adeb97f9d0
First line of input consists of single integer t (1 ≤ t ≤ 1 000 000) denoting number of games soldiers play. Then follow t lines, each contains pair of integers a and b (1 ≤ b ≤ a ≤ 5 000 000) defining the value of n for a game.
1,700
For each game output a maximum score that the second soldier can get.
standard output
PASSED
fb5ae4e95bf8de09d7bc52ec5ef1fb7a
train_001.jsonl
1432312200
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x &gt; 1, such that n is divisible by x and replacing n with n / x. Whe...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class Solution { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new Buffered...
Java
["2\n3 1\n6 3"]
3 seconds
["2\n5"]
null
Java 11
standard input
[ "dp", "constructive algorithms", "number theory", "math" ]
79d26192a25cd51d27e916adeb97f9d0
First line of input consists of single integer t (1 ≤ t ≤ 1 000 000) denoting number of games soldiers play. Then follow t lines, each contains pair of integers a and b (1 ≤ b ≤ a ≤ 5 000 000) defining the value of n for a game.
1,700
For each game output a maximum score that the second soldier can get.
standard output
PASSED
f34e4942bec4d70d80727214fc1bc84a
train_001.jsonl
1432312200
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x &gt; 1, such that n is divisible by x and replacing n with n / x. Whe...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.*; public class cf546d { public static void main(String[] args) throws IOException { int buf[] = new int[5000005], x[] = new int[5000005], pre[] = new int[5000005]; for(int i = 1; i <= 5000000; ++...
Java
["2\n3 1\n6 3"]
3 seconds
["2\n5"]
null
Java 11
standard input
[ "dp", "constructive algorithms", "number theory", "math" ]
79d26192a25cd51d27e916adeb97f9d0
First line of input consists of single integer t (1 ≤ t ≤ 1 000 000) denoting number of games soldiers play. Then follow t lines, each contains pair of integers a and b (1 ≤ b ≤ a ≤ 5 000 000) defining the value of n for a game.
1,700
For each game output a maximum score that the second soldier can get.
standard output
PASSED
5ab25ac67f054a00e6f5df23be304bb4
train_001.jsonl
1432312200
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x &gt; 1, such that n is divisible by x and replacing n with n / x. Whe...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.*; // same sol but better sieve given by editorial public class cf546d_2 { public static void main(String[] args) throws IOException { int div[] = new int[5000005], x[] = new int[5000005], pre[] = new in...
Java
["2\n3 1\n6 3"]
3 seconds
["2\n5"]
null
Java 11
standard input
[ "dp", "constructive algorithms", "number theory", "math" ]
79d26192a25cd51d27e916adeb97f9d0
First line of input consists of single integer t (1 ≤ t ≤ 1 000 000) denoting number of games soldiers play. Then follow t lines, each contains pair of integers a and b (1 ≤ b ≤ a ≤ 5 000 000) defining the value of n for a game.
1,700
For each game output a maximum score that the second soldier can get.
standard output
PASSED
d69c3e7c6373778af1bb31241c2d78ce
train_001.jsonl
1432312200
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x &gt; 1, such that n is divisible by x and replacing n with n / x. Whe...
256 megabytes
import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class Main { InputStream is; PrintWriter out; String INPUT = ""; void solve() { int glo = (5*(int)1e6); int prime...
Java
["2\n3 1\n6 3"]
3 seconds
["2\n5"]
null
Java 11
standard input
[ "dp", "constructive algorithms", "number theory", "math" ]
79d26192a25cd51d27e916adeb97f9d0
First line of input consists of single integer t (1 ≤ t ≤ 1 000 000) denoting number of games soldiers play. Then follow t lines, each contains pair of integers a and b (1 ≤ b ≤ a ≤ 5 000 000) defining the value of n for a game.
1,700
For each game output a maximum score that the second soldier can get.
standard output
PASSED
af3c35c18339d850a3a374d5dabafd5b
train_001.jsonl
1432312200
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x &gt; 1, such that n is divisible by x and replacing n with n / x. Whe...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Problem304D { public static void main(String[] args) throws Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); PrintWriter writer = new...
Java
["2\n3 1\n6 3"]
3 seconds
["2\n5"]
null
Java 11
standard input
[ "dp", "constructive algorithms", "number theory", "math" ]
79d26192a25cd51d27e916adeb97f9d0
First line of input consists of single integer t (1 ≤ t ≤ 1 000 000) denoting number of games soldiers play. Then follow t lines, each contains pair of integers a and b (1 ≤ b ≤ a ≤ 5 000 000) defining the value of n for a game.
1,700
For each game output a maximum score that the second soldier can get.
standard output
PASSED
33090f846c52e9b186af8a6a8efad021
train_001.jsonl
1432312200
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x &gt; 1, such that n is divisible by x and replacing n with n / x. Whe...
256 megabytes
import java.io.*; import java.util.*; public class SoldierNumberGame { public static void main(String[] args)throws Exception{ BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); PrintWriter writer = new PrintWriter(System.out); // BufferedReader reader = new Buffer...
Java
["2\n3 1\n6 3"]
3 seconds
["2\n5"]
null
Java 11
standard input
[ "dp", "constructive algorithms", "number theory", "math" ]
79d26192a25cd51d27e916adeb97f9d0
First line of input consists of single integer t (1 ≤ t ≤ 1 000 000) denoting number of games soldiers play. Then follow t lines, each contains pair of integers a and b (1 ≤ b ≤ a ≤ 5 000 000) defining the value of n for a game.
1,700
For each game output a maximum score that the second soldier can get.
standard output
PASSED
fb012ccd38476409ca9ac1c5cb81eaf2
train_001.jsonl
1432312200
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x &gt; 1, such that n is divisible by x and replacing n with n / x. Whe...
256 megabytes
import java.awt.*; import java.awt.List; import java.io.*; import java.util.*; import java.util.concurrent.BrokenBarrierException; import javax.net.ssl.SSLEngineResult; import javax.swing.*; import javax.swing.text.html.MinimalHTMLWriter; import static java.lang.Math.abs; import static java.lang.Math.max; import stat...
Java
["2\n3 1\n6 3"]
3 seconds
["2\n5"]
null
Java 11
standard input
[ "dp", "constructive algorithms", "number theory", "math" ]
79d26192a25cd51d27e916adeb97f9d0
First line of input consists of single integer t (1 ≤ t ≤ 1 000 000) denoting number of games soldiers play. Then follow t lines, each contains pair of integers a and b (1 ≤ b ≤ a ≤ 5 000 000) defining the value of n for a game.
1,700
For each game output a maximum score that the second soldier can get.
standard output
PASSED
c92102512556fe2c651f5dafcd9b7195
train_001.jsonl
1432312200
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x &gt; 1, such that n is divisible by x and replacing n with n / x. Whe...
256 megabytes
import java.io.*; import java.util.*; public class Main { static class PairComparator implements Comparator<Pair> { @Override public int compare(Pair x, Pair y) { if (x.val < y.val) return -1; if (x.val > y.val) return 1; if (x.val == y.val) { if (x.ind < y.ind) return -1; if (x.ind...
Java
["2\n3 1\n6 3"]
3 seconds
["2\n5"]
null
Java 11
standard input
[ "dp", "constructive algorithms", "number theory", "math" ]
79d26192a25cd51d27e916adeb97f9d0
First line of input consists of single integer t (1 ≤ t ≤ 1 000 000) denoting number of games soldiers play. Then follow t lines, each contains pair of integers a and b (1 ≤ b ≤ a ≤ 5 000 000) defining the value of n for a game.
1,700
For each game output a maximum score that the second soldier can get.
standard output
PASSED
f8b0efcb6083d99e93173cc7ecf7956e
train_001.jsonl
1557671700
$$$n$$$ boys and $$$m$$$ girls came to the party. Each boy presented each girl some integer number of sweets (possibly zero). All boys are numbered with integers from $$$1$$$ to $$$n$$$ and all girls are numbered with integers from $$$1$$$ to $$$m$$$. For all $$$1 \leq i \leq n$$$ the minimal number of sweets, which $$...
256 megabytes
import java.util.*; public class Solution { public static void main(String []args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int b[] = new int[n]; int g[] = new int[m]; for(int i =...
Java
["3 2\n1 2 1\n3 4", "2 2\n0 1\n1 0", "2 3\n1 0\n1 1 2"]
1 second
["12", "-1", "4"]
NoteIn the first test, the minimal total number of sweets, which boys could have presented is equal to $$$12$$$. This can be possible, for example, if the first boy presented $$$1$$$ and $$$4$$$ sweets, the second boy presented $$$3$$$ and $$$2$$$ sweets and the third boy presented $$$1$$$ and $$$1$$$ sweets for the fi...
Java 11
standard input
[ "greedy", "constructive algorithms", "two pointers", "math", "implementation", "sortings", "binary search" ]
4b4c7e7d9d5c45c8635b403bae997891
The first line contains two integers $$$n$$$ and $$$m$$$, separated with space — the number of boys and girls, respectively ($$$2 \leq n, m \leq 100\,000$$$). The second line contains $$$n$$$ integers $$$b_1, \ldots, b_n$$$, separated by spaces — $$$b_i$$$ is equal to the minimal number of sweets, which $$$i$$$-th boy ...
1,500
If the described situation is impossible, print $$$-1$$$. In another case, print the minimal total number of sweets, which boys could have presented and all conditions could have satisfied.
standard output
PASSED
550fca51171f3076fc6b529bbb25a74b
train_001.jsonl
1557671700
$$$n$$$ boys and $$$m$$$ girls came to the party. Each boy presented each girl some integer number of sweets (possibly zero). All boys are numbered with integers from $$$1$$$ to $$$n$$$ and all girls are numbered with integers from $$$1$$$ to $$$m$$$. For all $$$1 \leq i \leq n$$$ the minimal number of sweets, which $$...
256 megabytes
import java.io.*; import java.util.*; public class Main{ static void main() throws Exception{ int n=sc.nextInt(),m=sc.nextInt(); PriorityQueue<Integer>pq=new PriorityQueue<>(Collections.reverseOrder()); for(int i=0;i<n;i++) { int min=sc.nextInt(); pq.add(min); } int maxOfMins=pq.peek(); long ans=...
Java
["3 2\n1 2 1\n3 4", "2 2\n0 1\n1 0", "2 3\n1 0\n1 1 2"]
1 second
["12", "-1", "4"]
NoteIn the first test, the minimal total number of sweets, which boys could have presented is equal to $$$12$$$. This can be possible, for example, if the first boy presented $$$1$$$ and $$$4$$$ sweets, the second boy presented $$$3$$$ and $$$2$$$ sweets and the third boy presented $$$1$$$ and $$$1$$$ sweets for the fi...
Java 11
standard input
[ "greedy", "constructive algorithms", "two pointers", "math", "implementation", "sortings", "binary search" ]
4b4c7e7d9d5c45c8635b403bae997891
The first line contains two integers $$$n$$$ and $$$m$$$, separated with space — the number of boys and girls, respectively ($$$2 \leq n, m \leq 100\,000$$$). The second line contains $$$n$$$ integers $$$b_1, \ldots, b_n$$$, separated by spaces — $$$b_i$$$ is equal to the minimal number of sweets, which $$$i$$$-th boy ...
1,500
If the described situation is impossible, print $$$-1$$$. In another case, print the minimal total number of sweets, which boys could have presented and all conditions could have satisfied.
standard output
PASSED
21d7076d65a7e3a51276dfd1cae6763a
train_001.jsonl
1557671700
$$$n$$$ boys and $$$m$$$ girls came to the party. Each boy presented each girl some integer number of sweets (possibly zero). All boys are numbered with integers from $$$1$$$ to $$$n$$$ and all girls are numbered with integers from $$$1$$$ to $$$m$$$. For all $$$1 \leq i \leq n$$$ the minimal number of sweets, which $$...
256 megabytes
import java.util.*; import java.io.*; public class A559 { public static void main(String[] args) { MyScanner sc = new MyScanner(); PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); int n = sc.nextInt(); int m = sc.nextInt(); long [] b = new long[n]; lo...
Java
["3 2\n1 2 1\n3 4", "2 2\n0 1\n1 0", "2 3\n1 0\n1 1 2"]
1 second
["12", "-1", "4"]
NoteIn the first test, the minimal total number of sweets, which boys could have presented is equal to $$$12$$$. This can be possible, for example, if the first boy presented $$$1$$$ and $$$4$$$ sweets, the second boy presented $$$3$$$ and $$$2$$$ sweets and the third boy presented $$$1$$$ and $$$1$$$ sweets for the fi...
Java 11
standard input
[ "greedy", "constructive algorithms", "two pointers", "math", "implementation", "sortings", "binary search" ]
4b4c7e7d9d5c45c8635b403bae997891
The first line contains two integers $$$n$$$ and $$$m$$$, separated with space — the number of boys and girls, respectively ($$$2 \leq n, m \leq 100\,000$$$). The second line contains $$$n$$$ integers $$$b_1, \ldots, b_n$$$, separated by spaces — $$$b_i$$$ is equal to the minimal number of sweets, which $$$i$$$-th boy ...
1,500
If the described situation is impossible, print $$$-1$$$. In another case, print the minimal total number of sweets, which boys could have presented and all conditions could have satisfied.
standard output
PASSED
c2ca68db90a354db145b4e01074660e2
train_001.jsonl
1557671700
$$$n$$$ boys and $$$m$$$ girls came to the party. Each boy presented each girl some integer number of sweets (possibly zero). All boys are numbered with integers from $$$1$$$ to $$$n$$$ and all girls are numbered with integers from $$$1$$$ to $$$m$$$. For all $$$1 \leq i \leq n$$$ the minimal number of sweets, which $$...
256 megabytes
import java.io.*; import java.util.*; public class Main { static class PairComparator implements Comparator<Pair> { @Override public int compare(Pair x, Pair y) { if (x.val < y.val)return -1; if (x.val > y.val)return 1; if (x.val == y.val){ if (x.ind < y.ind)return -1; if (x.ind > y.ind)return 1;...
Java
["3 2\n1 2 1\n3 4", "2 2\n0 1\n1 0", "2 3\n1 0\n1 1 2"]
1 second
["12", "-1", "4"]
NoteIn the first test, the minimal total number of sweets, which boys could have presented is equal to $$$12$$$. This can be possible, for example, if the first boy presented $$$1$$$ and $$$4$$$ sweets, the second boy presented $$$3$$$ and $$$2$$$ sweets and the third boy presented $$$1$$$ and $$$1$$$ sweets for the fi...
Java 11
standard input
[ "greedy", "constructive algorithms", "two pointers", "math", "implementation", "sortings", "binary search" ]
4b4c7e7d9d5c45c8635b403bae997891
The first line contains two integers $$$n$$$ and $$$m$$$, separated with space — the number of boys and girls, respectively ($$$2 \leq n, m \leq 100\,000$$$). The second line contains $$$n$$$ integers $$$b_1, \ldots, b_n$$$, separated by spaces — $$$b_i$$$ is equal to the minimal number of sweets, which $$$i$$$-th boy ...
1,500
If the described situation is impossible, print $$$-1$$$. In another case, print the minimal total number of sweets, which boys could have presented and all conditions could have satisfied.
standard output
PASSED
c2b77c4ae5062f8424895001eebfdeb4
train_001.jsonl
1489851300
Bear Limak examines a social network. Its main functionality is that two members can become friends (then they can talk with each other and share funny pictures).There are n members, numbered 1 through n. m pairs of members are friends. Of course, a member can't be a friend with themselves.Let A-B denote that members A...
256 megabytes
import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Writer; import java.util.Arrays; import java.util.InputMismatchException; import java.util.*; import java.io.*; im...
Java
["4 3\n1 3\n3 4\n1 4", "4 4\n3 1\n2 3\n3 4\n1 2", "10 4\n4 3\n5 10\n8 9\n1 2", "3 2\n1 2\n2 3"]
1 second
["YES", "NO", "YES", "NO"]
NoteThe drawings below show the situation in the first sample (on the left) and in the second sample (on the right). Each edge represents two members that are friends. The answer is "NO" in the second sample because members (2, 3) are friends and members (3, 4) are friends, while members (2, 4) are not.
Java 8
standard input
[ "dsu", "dfs and similar", "graphs" ]
1173d89dd3af27b46e579cdeb2cfdfe5
The first line of the input contain two integers n and m (3 ≤ n ≤ 150 000, ) — the number of members and the number of pairs of members that are friends. The i-th of the next m lines contains two distinct integers ai and bi (1 ≤ ai, bi ≤ n, ai ≠ bi). Members ai and bi are friends with each other. No pair of members wil...
1,500
If the given network is reasonable, print "YES" in a single line (without the quotes). Otherwise, print "NO" in a single line (without the quotes).
standard output
PASSED
3341057e96f435642f1f1570b1296bbb
train_001.jsonl
1489851300
Bear Limak examines a social network. Its main functionality is that two members can become friends (then they can talk with each other and share funny pictures).There are n members, numbered 1 through n. m pairs of members are friends. Of course, a member can't be a friend with themselves.Let A-B denote that members A...
256 megabytes
import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Writer; import java.util.Arrays; import java.util.InputMismatchException; import java.util.*; import java.io.*; im...
Java
["4 3\n1 3\n3 4\n1 4", "4 4\n3 1\n2 3\n3 4\n1 2", "10 4\n4 3\n5 10\n8 9\n1 2", "3 2\n1 2\n2 3"]
1 second
["YES", "NO", "YES", "NO"]
NoteThe drawings below show the situation in the first sample (on the left) and in the second sample (on the right). Each edge represents two members that are friends. The answer is "NO" in the second sample because members (2, 3) are friends and members (3, 4) are friends, while members (2, 4) are not.
Java 8
standard input
[ "dsu", "dfs and similar", "graphs" ]
1173d89dd3af27b46e579cdeb2cfdfe5
The first line of the input contain two integers n and m (3 ≤ n ≤ 150 000, ) — the number of members and the number of pairs of members that are friends. The i-th of the next m lines contains two distinct integers ai and bi (1 ≤ ai, bi ≤ n, ai ≠ bi). Members ai and bi are friends with each other. No pair of members wil...
1,500
If the given network is reasonable, print "YES" in a single line (without the quotes). Otherwise, print "NO" in a single line (without the quotes).
standard output
PASSED
ed6f04d946c7b401236d2d3338b6c61c
train_001.jsonl
1489851300
Bear Limak examines a social network. Its main functionality is that two members can become friends (then they can talk with each other and share funny pictures).There are n members, numbered 1 through n. m pairs of members are friends. Of course, a member can't be a friend with themselves.Let A-B denote that members A...
256 megabytes
import java.io.*; import java.util.*; public class A771 { public static void main(String args[])throws IOException { Reader sc=new Reader(); int n=sc.nextInt(); int m=sc.nextInt(); HashMap<Integer,HashSet<Integer>> map=new HashMap<>(); int size[]=new int[n+1]; fo...
Java
["4 3\n1 3\n3 4\n1 4", "4 4\n3 1\n2 3\n3 4\n1 2", "10 4\n4 3\n5 10\n8 9\n1 2", "3 2\n1 2\n2 3"]
1 second
["YES", "NO", "YES", "NO"]
NoteThe drawings below show the situation in the first sample (on the left) and in the second sample (on the right). Each edge represents two members that are friends. The answer is "NO" in the second sample because members (2, 3) are friends and members (3, 4) are friends, while members (2, 4) are not.
Java 8
standard input
[ "dsu", "dfs and similar", "graphs" ]
1173d89dd3af27b46e579cdeb2cfdfe5
The first line of the input contain two integers n and m (3 ≤ n ≤ 150 000, ) — the number of members and the number of pairs of members that are friends. The i-th of the next m lines contains two distinct integers ai and bi (1 ≤ ai, bi ≤ n, ai ≠ bi). Members ai and bi are friends with each other. No pair of members wil...
1,500
If the given network is reasonable, print "YES" in a single line (without the quotes). Otherwise, print "NO" in a single line (without the quotes).
standard output
PASSED
6e32c19b820f226d0524486b45f92e56
train_001.jsonl
1489851300
Bear Limak examines a social network. Its main functionality is that two members can become friends (then they can talk with each other and share funny pictures).There are n members, numbered 1 through n. m pairs of members are friends. Of course, a member can't be a friend with themselves.Let A-B denote that members A...
256 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.StringTokenizer; public class Main { static class Graph { private int V;// No. of vertices private ...
Java
["4 3\n1 3\n3 4\n1 4", "4 4\n3 1\n2 3\n3 4\n1 2", "10 4\n4 3\n5 10\n8 9\n1 2", "3 2\n1 2\n2 3"]
1 second
["YES", "NO", "YES", "NO"]
NoteThe drawings below show the situation in the first sample (on the left) and in the second sample (on the right). Each edge represents two members that are friends. The answer is "NO" in the second sample because members (2, 3) are friends and members (3, 4) are friends, while members (2, 4) are not.
Java 8
standard input
[ "dsu", "dfs and similar", "graphs" ]
1173d89dd3af27b46e579cdeb2cfdfe5
The first line of the input contain two integers n and m (3 ≤ n ≤ 150 000, ) — the number of members and the number of pairs of members that are friends. The i-th of the next m lines contains two distinct integers ai and bi (1 ≤ ai, bi ≤ n, ai ≠ bi). Members ai and bi are friends with each other. No pair of members wil...
1,500
If the given network is reasonable, print "YES" in a single line (without the quotes). Otherwise, print "NO" in a single line (without the quotes).
standard output
PASSED
08f9f490144e692adc1844342e31f6a6
train_001.jsonl
1489851300
Bear Limak examines a social network. Its main functionality is that two members can become friends (then they can talk with each other and share funny pictures).There are n members, numbered 1 through n. m pairs of members are friends. Of course, a member can't be a friend with themselves.Let A-B denote that members A...
256 megabytes
import java.io.*; import java.util.*; public class A771 { static int n, m; static List<Integer>[] graph; static boolean[] visited; static List<List<Integer>> finallist; static List<Integer> list; public static void main(String[] args) throws IOException { BufferedReader br = new Buffere...
Java
["4 3\n1 3\n3 4\n1 4", "4 4\n3 1\n2 3\n3 4\n1 2", "10 4\n4 3\n5 10\n8 9\n1 2", "3 2\n1 2\n2 3"]
1 second
["YES", "NO", "YES", "NO"]
NoteThe drawings below show the situation in the first sample (on the left) and in the second sample (on the right). Each edge represents two members that are friends. The answer is "NO" in the second sample because members (2, 3) are friends and members (3, 4) are friends, while members (2, 4) are not.
Java 8
standard input
[ "dsu", "dfs and similar", "graphs" ]
1173d89dd3af27b46e579cdeb2cfdfe5
The first line of the input contain two integers n and m (3 ≤ n ≤ 150 000, ) — the number of members and the number of pairs of members that are friends. The i-th of the next m lines contains two distinct integers ai and bi (1 ≤ ai, bi ≤ n, ai ≠ bi). Members ai and bi are friends with each other. No pair of members wil...
1,500
If the given network is reasonable, print "YES" in a single line (without the quotes). Otherwise, print "NO" in a single line (without the quotes).
standard output
PASSED
1677239788cc966b416690edcb478cf8
train_001.jsonl
1489851300
Bear Limak examines a social network. Its main functionality is that two members can become friends (then they can talk with each other and share funny pictures).There are n members, numbered 1 through n. m pairs of members are friends. Of course, a member can't be a friend with themselves.Let A-B denote that members A...
256 megabytes
import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.*; public class B { InputStream is; PrintWriter out; String INPUT = ""; void solve() { int n = ni(), m = ni(); HashSet<Integer>[] graph = (HashSet<Integer>[]) new HashSet...
Java
["4 3\n1 3\n3 4\n1 4", "4 4\n3 1\n2 3\n3 4\n1 2", "10 4\n4 3\n5 10\n8 9\n1 2", "3 2\n1 2\n2 3"]
1 second
["YES", "NO", "YES", "NO"]
NoteThe drawings below show the situation in the first sample (on the left) and in the second sample (on the right). Each edge represents two members that are friends. The answer is "NO" in the second sample because members (2, 3) are friends and members (3, 4) are friends, while members (2, 4) are not.
Java 8
standard input
[ "dsu", "dfs and similar", "graphs" ]
1173d89dd3af27b46e579cdeb2cfdfe5
The first line of the input contain two integers n and m (3 ≤ n ≤ 150 000, ) — the number of members and the number of pairs of members that are friends. The i-th of the next m lines contains two distinct integers ai and bi (1 ≤ ai, bi ≤ n, ai ≠ bi). Members ai and bi are friends with each other. No pair of members wil...
1,500
If the given network is reasonable, print "YES" in a single line (without the quotes). Otherwise, print "NO" in a single line (without the quotes).
standard output
PASSED
a37a7141095e54564ad2ecec6a853212
train_001.jsonl
1489851300
Bear Limak examines a social network. Its main functionality is that two members can become friends (then they can talk with each other and share funny pictures).There are n members, numbered 1 through n. m pairs of members are friends. Of course, a member can't be a friend with themselves.Let A-B denote that members A...
256 megabytes
/* HARSH KHATRI DA-IICT */ import java.io.*; import java.util.*; import java.lang.*; import java.util.Scanner; import java.util.Arrays; import java.util.List; import java.util.ArrayList; public class CF771A { static FasterScanner in = new FasterScanner(); static int ...
Java
["4 3\n1 3\n3 4\n1 4", "4 4\n3 1\n2 3\n3 4\n1 2", "10 4\n4 3\n5 10\n8 9\n1 2", "3 2\n1 2\n2 3"]
1 second
["YES", "NO", "YES", "NO"]
NoteThe drawings below show the situation in the first sample (on the left) and in the second sample (on the right). Each edge represents two members that are friends. The answer is "NO" in the second sample because members (2, 3) are friends and members (3, 4) are friends, while members (2, 4) are not.
Java 8
standard input
[ "dsu", "dfs and similar", "graphs" ]
1173d89dd3af27b46e579cdeb2cfdfe5
The first line of the input contain two integers n and m (3 ≤ n ≤ 150 000, ) — the number of members and the number of pairs of members that are friends. The i-th of the next m lines contains two distinct integers ai and bi (1 ≤ ai, bi ≤ n, ai ≠ bi). Members ai and bi are friends with each other. No pair of members wil...
1,500
If the given network is reasonable, print "YES" in a single line (without the quotes). Otherwise, print "NO" in a single line (without the quotes).
standard output
PASSED
eea835f0aa1addfff542ef0d86edb0ac
train_001.jsonl
1489851300
Bear Limak examines a social network. Its main functionality is that two members can become friends (then they can talk with each other and share funny pictures).There are n members, numbered 1 through n. m pairs of members are friends. Of course, a member can't be a friend with themselves.Let A-B denote that members A...
256 megabytes
import java.util.*; import java.io.*; public class Test { public static long numberOfVertices=0,numberOfEdges=0; public static boolean[] visited; public static LinkedList<Integer>[] adj; public static void main(String[] args) { boolean possible=true; int x,y; FastReader scan=new ...
Java
["4 3\n1 3\n3 4\n1 4", "4 4\n3 1\n2 3\n3 4\n1 2", "10 4\n4 3\n5 10\n8 9\n1 2", "3 2\n1 2\n2 3"]
1 second
["YES", "NO", "YES", "NO"]
NoteThe drawings below show the situation in the first sample (on the left) and in the second sample (on the right). Each edge represents two members that are friends. The answer is "NO" in the second sample because members (2, 3) are friends and members (3, 4) are friends, while members (2, 4) are not.
Java 8
standard input
[ "dsu", "dfs and similar", "graphs" ]
1173d89dd3af27b46e579cdeb2cfdfe5
The first line of the input contain two integers n and m (3 ≤ n ≤ 150 000, ) — the number of members and the number of pairs of members that are friends. The i-th of the next m lines contains two distinct integers ai and bi (1 ≤ ai, bi ≤ n, ai ≠ bi). Members ai and bi are friends with each other. No pair of members wil...
1,500
If the given network is reasonable, print "YES" in a single line (without the quotes). Otherwise, print "NO" in a single line (without the quotes).
standard output
PASSED
36cd34eee05cac09a576e3b487ff3e46
train_001.jsonl
1489851300
Bear Limak examines a social network. Its main functionality is that two members can become friends (then they can talk with each other and share funny pictures).There are n members, numbered 1 through n. m pairs of members are friends. Of course, a member can't be a friend with themselves.Let A-B denote that members A...
256 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.*; import java.util.*; public class Main { static int N = 150005; static int[] f = new int[N]; static int[] s = new int[N]; stat...
Java
["4 3\n1 3\n3 4\n1 4", "4 4\n3 1\n2 3\n3 4\n1 2", "10 4\n4 3\n5 10\n8 9\n1 2", "3 2\n1 2\n2 3"]
1 second
["YES", "NO", "YES", "NO"]
NoteThe drawings below show the situation in the first sample (on the left) and in the second sample (on the right). Each edge represents two members that are friends. The answer is "NO" in the second sample because members (2, 3) are friends and members (3, 4) are friends, while members (2, 4) are not.
Java 8
standard input
[ "dsu", "dfs and similar", "graphs" ]
1173d89dd3af27b46e579cdeb2cfdfe5
The first line of the input contain two integers n and m (3 ≤ n ≤ 150 000, ) — the number of members and the number of pairs of members that are friends. The i-th of the next m lines contains two distinct integers ai and bi (1 ≤ ai, bi ≤ n, ai ≠ bi). Members ai and bi are friends with each other. No pair of members wil...
1,500
If the given network is reasonable, print "YES" in a single line (without the quotes). Otherwise, print "NO" in a single line (without the quotes).
standard output
PASSED
4139f32d3293b67fa1b7389da9f6804b
train_001.jsonl
1305299400
On an IT lesson Valera studied data compression. The teacher told about a new method, which we shall now describe to you.Let {a1, a2, ..., an} be the given sequence of lines needed to be compressed. Here and below we shall assume that all lines are of the same length and consist only of the digits 0 and 1. Let's define...
256 megabytes
import java.util.NavigableSet; import java.util.Map; import java.util.Collections; import java.util.HashMap; import java.util.InputMismatchException; import java.math.BigInteger; import java.util.*; import java.util.Collection; import java.util.ArrayList; import java.util.List; import java.util.Comparator; import java....
Java
["3\n01\n10\n01", "4\n000\n111\n110\n001", "5\n10101\n01010\n11111\n01000\n10010"]
2 seconds
["4", "8", "17"]
NoteDetailed answers to the tests: The best option is to make one of the subsequences empty, and the second one equal to the whole given sequence. |f(01, 10, 01)| = |f(f(01, 10), 01)| = |f(010, 01)| = |0101| = 4. The best option is: b = {000, 001}, c = {111, 110}. S = |f(000, 001)| + |f(111, 110)| = |0001| + |1110| =...
Java 8
standard input
[ "dp", "bitmasks" ]
d65ca3fb4853031304cb829c3cda3462
The first line of input data contains an integer n — the number of strings (1 ≤ n ≤ 2·105). Then on n lines follow elements of the sequence — strings whose lengths are from 1 to 20 characters, consisting only of digits 0 and 1. The i + 1-th input line contains the i-th element of the sequence. Elements of the sequence ...
2,800
Print a single number — the minimum possible value of S.
standard output
PASSED
31b2b2ddb834b8141c95a1c0d7667800
train_001.jsonl
1305299400
On an IT lesson Valera studied data compression. The teacher told about a new method, which we shall now describe to you.Let {a1, a2, ..., an} be the given sequence of lines needed to be compressed. Here and below we shall assume that all lines are of the same length and consist only of the digits 0 and 1. Let's define...
256 megabytes
import java.util.*; import static java.lang.Math.*; public class E { public static void main(String[] args){ Scanner in = new Scanner(System.in); N = in.nextInt(); int[] V = new int[N]; K = -1; for(int i = 0; i < N;i++){ String s = in.next(); K = s.length(); V[i] = Integer.valueOf(s, 2); } cost ...
Java
["3\n01\n10\n01", "4\n000\n111\n110\n001", "5\n10101\n01010\n11111\n01000\n10010"]
2 seconds
["4", "8", "17"]
NoteDetailed answers to the tests: The best option is to make one of the subsequences empty, and the second one equal to the whole given sequence. |f(01, 10, 01)| = |f(f(01, 10), 01)| = |f(010, 01)| = |0101| = 4. The best option is: b = {000, 001}, c = {111, 110}. S = |f(000, 001)| + |f(111, 110)| = |0001| + |1110| =...
Java 6
standard input
[ "dp", "bitmasks" ]
d65ca3fb4853031304cb829c3cda3462
The first line of input data contains an integer n — the number of strings (1 ≤ n ≤ 2·105). Then on n lines follow elements of the sequence — strings whose lengths are from 1 to 20 characters, consisting only of digits 0 and 1. The i + 1-th input line contains the i-th element of the sequence. Elements of the sequence ...
2,800
Print a single number — the minimum possible value of S.
standard output
PASSED
569114371381cac7e541a1e2dc7cd90b
train_001.jsonl
1305299400
On an IT lesson Valera studied data compression. The teacher told about a new method, which we shall now describe to you.Let {a1, a2, ..., an} be the given sequence of lines needed to be compressed. Here and below we shall assume that all lines are of the same length and consist only of the digits 0 and 1. Let's define...
256 megabytes
import java.util.NavigableSet; import java.util.Map; import java.util.Collections; import java.util.HashMap; import java.util.InputMismatchException; import java.math.BigInteger; import java.util.*; import java.util.Collection; import java.util.ArrayList; import java.util.List; import java.util.Comparator; import java....
Java
["3\n01\n10\n01", "4\n000\n111\n110\n001", "5\n10101\n01010\n11111\n01000\n10010"]
2 seconds
["4", "8", "17"]
NoteDetailed answers to the tests: The best option is to make one of the subsequences empty, and the second one equal to the whole given sequence. |f(01, 10, 01)| = |f(f(01, 10), 01)| = |f(010, 01)| = |0101| = 4. The best option is: b = {000, 001}, c = {111, 110}. S = |f(000, 001)| + |f(111, 110)| = |0001| + |1110| =...
Java 6
standard input
[ "dp", "bitmasks" ]
d65ca3fb4853031304cb829c3cda3462
The first line of input data contains an integer n — the number of strings (1 ≤ n ≤ 2·105). Then on n lines follow elements of the sequence — strings whose lengths are from 1 to 20 characters, consisting only of digits 0 and 1. The i + 1-th input line contains the i-th element of the sequence. Elements of the sequence ...
2,800
Print a single number — the minimum possible value of S.
standard output
PASSED
906eaa3fafeb63fb27045e3c2bf80206
train_001.jsonl
1305299400
On an IT lesson Valera studied data compression. The teacher told about a new method, which we shall now describe to you.Let {a1, a2, ..., an} be the given sequence of lines needed to be compressed. Here and below we shall assume that all lines are of the same length and consist only of the digits 0 and 1. Let's define...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; import java.text.*; import java.util.Random; public class Main { static int res; static int n,prefix[][],suffix[][]; static int f[][],a[],L,sum[]; public static void put(int id,int best) { if (id>=0)res = Math.min(res, best+sum[...
Java
["3\n01\n10\n01", "4\n000\n111\n110\n001", "5\n10101\n01010\n11111\n01000\n10010"]
2 seconds
["4", "8", "17"]
NoteDetailed answers to the tests: The best option is to make one of the subsequences empty, and the second one equal to the whole given sequence. |f(01, 10, 01)| = |f(f(01, 10), 01)| = |f(010, 01)| = |0101| = 4. The best option is: b = {000, 001}, c = {111, 110}. S = |f(000, 001)| + |f(111, 110)| = |0001| + |1110| =...
Java 6
standard input
[ "dp", "bitmasks" ]
d65ca3fb4853031304cb829c3cda3462
The first line of input data contains an integer n — the number of strings (1 ≤ n ≤ 2·105). Then on n lines follow elements of the sequence — strings whose lengths are from 1 to 20 characters, consisting only of digits 0 and 1. The i + 1-th input line contains the i-th element of the sequence. Elements of the sequence ...
2,800
Print a single number — the minimum possible value of S.
standard output
PASSED
265d9f0e5cd3b57adb70d49eff037c90
train_001.jsonl
1305299400
On an IT lesson Valera studied data compression. The teacher told about a new method, which we shall now describe to you.Let {a1, a2, ..., an} be the given sequence of lines needed to be compressed. Here and below we shall assume that all lines are of the same length and consist only of the digits 0 and 1. Let's define...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; public class E implements Runnable { final int INF = 1 << 30; int m; int[] a; private void solve() throws ...
Java
["3\n01\n10\n01", "4\n000\n111\n110\n001", "5\n10101\n01010\n11111\n01000\n10010"]
2 seconds
["4", "8", "17"]
NoteDetailed answers to the tests: The best option is to make one of the subsequences empty, and the second one equal to the whole given sequence. |f(01, 10, 01)| = |f(f(01, 10), 01)| = |f(010, 01)| = |0101| = 4. The best option is: b = {000, 001}, c = {111, 110}. S = |f(000, 001)| + |f(111, 110)| = |0001| + |1110| =...
Java 6
standard input
[ "dp", "bitmasks" ]
d65ca3fb4853031304cb829c3cda3462
The first line of input data contains an integer n — the number of strings (1 ≤ n ≤ 2·105). Then on n lines follow elements of the sequence — strings whose lengths are from 1 to 20 characters, consisting only of digits 0 and 1. The i + 1-th input line contains the i-th element of the sequence. Elements of the sequence ...
2,800
Print a single number — the minimum possible value of S.
standard output
PASSED
282a49bed26b3614fac8489c11615e7c
train_001.jsonl
1439483400
The country of Byalechinsk is running elections involving n candidates. The country consists of m cities. We know how many people in each city voted for each candidate.The electoral system in the country is pretty unusual. At the first stage of elections the votes are counted for each city: it is assumed that in each c...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Main { public static void main(String[] args) { //int a[] = new int[1000000000]; Scanner in = new Scanner(System.in); int n = in.nextInt(); int m = in.nextInt(); int cit[] = new int[n]; int v[][] = new int[m][n]; for(int...
Java
["3 3\n1 2 3\n2 3 1\n1 2 1", "3 4\n10 10 3\n5 1 6\n2 2 2\n1 5 7"]
1 second
["2", "1"]
NoteNote to the first sample test. At the first stage city 1 chosen candidate 3, city 2 chosen candidate 2, city 3 chosen candidate 2. The winner is candidate 2, he gained 2 votes.Note to the second sample test. At the first stage in city 1 candidates 1 and 2 got the same maximum number of votes, but candidate 1 has a ...
Java 8
standard input
[ "implementation" ]
b20e98f2ea0eb48f790dcc5dd39344d3
The first line of the input contains two integers n, m (1 ≤ n, m ≤ 100) — the number of candidates and of cities, respectively. Each of the next m lines contains n non-negative integers, the j-th number in the i-th line aij (1 ≤ j ≤ n, 1 ≤ i ≤ m, 0 ≤ aij ≤ 109) denotes the number of votes for candidate j in city i. It ...
1,100
Print a single number — the index of the candidate who won the elections. The candidates are indexed starting from one.
standard output
PASSED
949b87986c3c957d053bbf6bfc57fb0d
train_001.jsonl
1439483400
The country of Byalechinsk is running elections involving n candidates. The country consists of m cities. We know how many people in each city voted for each candidate.The electoral system in the country is pretty unusual. At the first stage of elections the votes are counted for each city: it is assumed that in each c...
256 megabytes
import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class ATM { public static void main(String[] args) { Scanner s = new Scanner(System.in); long candidates = s.nextLong(); long cities = s.nextLong(); long winnerIndex = 1; Map<Long, Integer> finalList = new HashMap<>(); for (i...
Java
["3 3\n1 2 3\n2 3 1\n1 2 1", "3 4\n10 10 3\n5 1 6\n2 2 2\n1 5 7"]
1 second
["2", "1"]
NoteNote to the first sample test. At the first stage city 1 chosen candidate 3, city 2 chosen candidate 2, city 3 chosen candidate 2. The winner is candidate 2, he gained 2 votes.Note to the second sample test. At the first stage in city 1 candidates 1 and 2 got the same maximum number of votes, but candidate 1 has a ...
Java 8
standard input
[ "implementation" ]
b20e98f2ea0eb48f790dcc5dd39344d3
The first line of the input contains two integers n, m (1 ≤ n, m ≤ 100) — the number of candidates and of cities, respectively. Each of the next m lines contains n non-negative integers, the j-th number in the i-th line aij (1 ≤ j ≤ n, 1 ≤ i ≤ m, 0 ≤ aij ≤ 109) denotes the number of votes for candidate j in city i. It ...
1,100
Print a single number — the index of the candidate who won the elections. The candidates are indexed starting from one.
standard output
PASSED
d8e612d2d8a384dda972d5a6a45705c2
train_001.jsonl
1439483400
The country of Byalechinsk is running elections involving n candidates. The country consists of m cities. We know how many people in each city voted for each candidate.The electoral system in the country is pretty unusual. At the first stage of elections the votes are counted for each city: it is assumed that in each c...
256 megabytes
import java.util.Arrays; import java.util.HashMap; import java.util.Scanner; public class ProblemA { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int m = s.nextInt(); int[] wins = new int[n]; Arrays.fill(wins, 0); ...
Java
["3 3\n1 2 3\n2 3 1\n1 2 1", "3 4\n10 10 3\n5 1 6\n2 2 2\n1 5 7"]
1 second
["2", "1"]
NoteNote to the first sample test. At the first stage city 1 chosen candidate 3, city 2 chosen candidate 2, city 3 chosen candidate 2. The winner is candidate 2, he gained 2 votes.Note to the second sample test. At the first stage in city 1 candidates 1 and 2 got the same maximum number of votes, but candidate 1 has a ...
Java 8
standard input
[ "implementation" ]
b20e98f2ea0eb48f790dcc5dd39344d3
The first line of the input contains two integers n, m (1 ≤ n, m ≤ 100) — the number of candidates and of cities, respectively. Each of the next m lines contains n non-negative integers, the j-th number in the i-th line aij (1 ≤ j ≤ n, 1 ≤ i ≤ m, 0 ≤ aij ≤ 109) denotes the number of votes for candidate j in city i. It ...
1,100
Print a single number — the index of the candidate who won the elections. The candidates are indexed starting from one.
standard output
PASSED
9c16bb9aec6a34dd3c576600dcb92e9e
train_001.jsonl
1439483400
The country of Byalechinsk is running elections involving n candidates. The country consists of m cities. We know how many people in each city voted for each candidate.The electoral system in the country is pretty unusual. At the first stage of elections the votes are counted for each city: it is assumed that in each c...
256 megabytes
import java.util.Scanner; public class Vibori { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int m = in.nextInt(); int[] kandidat = new int[n]; int max = -1; int [] WinnerOfCity = new int[m]; int [] KandidatScores = new int[n + 1]; int winner = ...
Java
["3 3\n1 2 3\n2 3 1\n1 2 1", "3 4\n10 10 3\n5 1 6\n2 2 2\n1 5 7"]
1 second
["2", "1"]
NoteNote to the first sample test. At the first stage city 1 chosen candidate 3, city 2 chosen candidate 2, city 3 chosen candidate 2. The winner is candidate 2, he gained 2 votes.Note to the second sample test. At the first stage in city 1 candidates 1 and 2 got the same maximum number of votes, but candidate 1 has a ...
Java 8
standard input
[ "implementation" ]
b20e98f2ea0eb48f790dcc5dd39344d3
The first line of the input contains two integers n, m (1 ≤ n, m ≤ 100) — the number of candidates and of cities, respectively. Each of the next m lines contains n non-negative integers, the j-th number in the i-th line aij (1 ≤ j ≤ n, 1 ≤ i ≤ m, 0 ≤ aij ≤ 109) denotes the number of votes for candidate j in city i. It ...
1,100
Print a single number — the index of the candidate who won the elections. The candidates are indexed starting from one.
standard output
PASSED
ae5a307e5497a2202f236855e0c57707
train_001.jsonl
1439483400
The country of Byalechinsk is running elections involving n candidates. The country consists of m cities. We know how many people in each city voted for each candidate.The electoral system in the country is pretty unusual. At the first stage of elections the votes are counted for each city: it is assumed that in each c...
256 megabytes
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner scan = new Scanner(System.in); int people = scan.nextInt(), k=0, city = scan.nextInt(), max = -1; int[] winner = new int[people]; for(int i=0; i<city; i++){ for(int j=0; j<people...
Java
["3 3\n1 2 3\n2 3 1\n1 2 1", "3 4\n10 10 3\n5 1 6\n2 2 2\n1 5 7"]
1 second
["2", "1"]
NoteNote to the first sample test. At the first stage city 1 chosen candidate 3, city 2 chosen candidate 2, city 3 chosen candidate 2. The winner is candidate 2, he gained 2 votes.Note to the second sample test. At the first stage in city 1 candidates 1 and 2 got the same maximum number of votes, but candidate 1 has a ...
Java 8
standard input
[ "implementation" ]
b20e98f2ea0eb48f790dcc5dd39344d3
The first line of the input contains two integers n, m (1 ≤ n, m ≤ 100) — the number of candidates and of cities, respectively. Each of the next m lines contains n non-negative integers, the j-th number in the i-th line aij (1 ≤ j ≤ n, 1 ≤ i ≤ m, 0 ≤ aij ≤ 109) denotes the number of votes for candidate j in city i. It ...
1,100
Print a single number — the index of the candidate who won the elections. The candidates are indexed starting from one.
standard output
PASSED
e252d32ee1119db78aeda98d5c9d08f8
train_001.jsonl
1439483400
The country of Byalechinsk is running elections involving n candidates. The country consists of m cities. We know how many people in each city voted for each candidate.The electoral system in the country is pretty unusual. At the first stage of elections the votes are counted for each city: it is assumed that in each c...
256 megabytes
/*input 3 3 0 1 0 0 0 1 0 0 0 */ import java.io.*; import java.util.*; public class Main { public static void main(String []args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = br.readLine(); StringTokenizer srt = new StringTok...
Java
["3 3\n1 2 3\n2 3 1\n1 2 1", "3 4\n10 10 3\n5 1 6\n2 2 2\n1 5 7"]
1 second
["2", "1"]
NoteNote to the first sample test. At the first stage city 1 chosen candidate 3, city 2 chosen candidate 2, city 3 chosen candidate 2. The winner is candidate 2, he gained 2 votes.Note to the second sample test. At the first stage in city 1 candidates 1 and 2 got the same maximum number of votes, but candidate 1 has a ...
Java 8
standard input
[ "implementation" ]
b20e98f2ea0eb48f790dcc5dd39344d3
The first line of the input contains two integers n, m (1 ≤ n, m ≤ 100) — the number of candidates and of cities, respectively. Each of the next m lines contains n non-negative integers, the j-th number in the i-th line aij (1 ≤ j ≤ n, 1 ≤ i ≤ m, 0 ≤ aij ≤ 109) denotes the number of votes for candidate j in city i. It ...
1,100
Print a single number — the index of the candidate who won the elections. The candidates are indexed starting from one.
standard output