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
fe9673c7403cf30af249fda92bc32c27
train_001.jsonl
1532938500
There is an array with n elements a1, a2, ..., an and the number x.In one operation you can select some i (1 ≀ i ≀ n) and replace element ai with ai & x, where & denotes the bitwise and operation.You want the array to have at least two equal elements after applying some operations (possibly, none). In other wor...
256 megabytes
import java.io.PrintWriter; import java.util.Scanner; /** * Created by Minology on 07:42 SA */ public class B { public static void main(String[] args){ Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); Task solver = new Task(); out.print(solver.s...
Java
["4 3\n1 2 3 7", "2 228\n1 1", "3 7\n1 2 3"]
1 second
["1", "0", "-1"]
NoteIn the first example one can apply the operation to the last element of the array. That replaces 7 with 3, so we achieve the goal in one move.In the second example the array already has two equal elements.In the third example applying the operation won't change the array at all, so it is impossible to make some pai...
Java 8
standard input
[ "greedy" ]
f4bb0b8f285b0c8cbaf469964505cc56
The first line contains integers n and x (2 ≀ n ≀ 100 000, 1 ≀ x ≀ 100 000), number of elements in the array and the number to and with. The second line contains n integers ai (1 ≀ ai ≀ 100 000), the elements of the array.
1,200
Print a single integer denoting the minimal number of operations to do, or -1, if it is impossible.
standard output
PASSED
ac7a202955843db38109b1e71e4a377a
train_001.jsonl
1532938500
There is an array with n elements a1, a2, ..., an and the number x.In one operation you can select some i (1 ≀ i ≀ n) and replace element ai with ai & x, where & denotes the bitwise and operation.You want the array to have at least two equal elements after applying some operations (possibly, none). In other wor...
256 megabytes
import java.io.*; import java.util.NoSuchElementException; public class Main_1013B { private static Scanner sc; private static Printer pr; private static void solve() { int n = sc.nextInt(); int x = sc.nextInt(); int[] a = sc.nextIntArray(n); int[] cnt = new int[100_000 + 1]; for (int e : a) { cnt...
Java
["4 3\n1 2 3 7", "2 228\n1 1", "3 7\n1 2 3"]
1 second
["1", "0", "-1"]
NoteIn the first example one can apply the operation to the last element of the array. That replaces 7 with 3, so we achieve the goal in one move.In the second example the array already has two equal elements.In the third example applying the operation won't change the array at all, so it is impossible to make some pai...
Java 8
standard input
[ "greedy" ]
f4bb0b8f285b0c8cbaf469964505cc56
The first line contains integers n and x (2 ≀ n ≀ 100 000, 1 ≀ x ≀ 100 000), number of elements in the array and the number to and with. The second line contains n integers ai (1 ≀ ai ≀ 100 000), the elements of the array.
1,200
Print a single integer denoting the minimal number of operations to do, or -1, if it is impossible.
standard output
PASSED
445e660204167410c1fd227aa048db94
train_001.jsonl
1490803500
Masha really loves algebra. On the last lesson, her strict teacher Dvastan gave she new exercise.You are given geometric progression b defined by two integers b1 and q. Remind that a geometric progression is a sequence of integers b1, b2, b3, ..., where for each i > 1 the respective term satisfies the condition bi =...
256 megabytes
import java.io.*; import java.util.*; public class ProblemB { static class OutputWriter { private final PrintWriter writer; public OutputWriter(OutputStream outputStream) { writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter(Writer writer) { this....
Java
["3 2 30 4\n6 14 25 48", "123 1 2143435 4\n123 11 -5453 141245", "123 1 2143435 4\n54343 -13 6 124"]
1 second
["3", "0", "inf"]
NoteIn the first sample case, Masha will write integers 3, 12, 24. Progression term 6 will be skipped because it is a "bad" integer. Terms bigger than 24 won't be written because they exceed l by absolute value.In the second case, Masha won't write any number because all terms are equal 123 and this is a "bad" integer....
Java 8
standard input
[ "implementation", "brute force", "math" ]
749c290c48272a53e2e79730dab0538e
The first line of input contains four integers b1, q, l, m (-109 ≀ b1, q ≀ 109, 1 ≀ l ≀ 109, 1 ≀ m ≀ 105)Β β€” the initial term and the common ratio of progression, absolute value of maximal number that can be written on the board and the number of "bad" integers, respectively. The second line contains m distinct integers...
1,700
Print the only integer, meaning the number of progression terms that will be written on the board if it is finite, or "inf" (without quotes) otherwise.
standard output
PASSED
9211f5c7a6be9e6919c8fe2ff26889f4
train_001.jsonl
1490803500
Masha really loves algebra. On the last lesson, her strict teacher Dvastan gave she new exercise.You are given geometric progression b defined by two integers b1 and q. Remind that a geometric progression is a sequence of integers b1, b2, b3, ..., where for each i > 1 the respective term satisfies the condition bi =...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Arrays; import java.util.Collect...
Java
["3 2 30 4\n6 14 25 48", "123 1 2143435 4\n123 11 -5453 141245", "123 1 2143435 4\n54343 -13 6 124"]
1 second
["3", "0", "inf"]
NoteIn the first sample case, Masha will write integers 3, 12, 24. Progression term 6 will be skipped because it is a "bad" integer. Terms bigger than 24 won't be written because they exceed l by absolute value.In the second case, Masha won't write any number because all terms are equal 123 and this is a "bad" integer....
Java 8
standard input
[ "implementation", "brute force", "math" ]
749c290c48272a53e2e79730dab0538e
The first line of input contains four integers b1, q, l, m (-109 ≀ b1, q ≀ 109, 1 ≀ l ≀ 109, 1 ≀ m ≀ 105)Β β€” the initial term and the common ratio of progression, absolute value of maximal number that can be written on the board and the number of "bad" integers, respectively. The second line contains m distinct integers...
1,700
Print the only integer, meaning the number of progression terms that will be written on the board if it is finite, or "inf" (without quotes) otherwise.
standard output
PASSED
a8611be365a6b2a77cc1d1ab814a20ef
train_001.jsonl
1490803500
Masha really loves algebra. On the last lesson, her strict teacher Dvastan gave she new exercise.You are given geometric progression b defined by two integers b1 and q. Remind that a geometric progression is a sequence of integers b1, b2, b3, ..., where for each i > 1 the respective term satisfies the condition bi =...
256 megabytes
import java.util.HashSet; import java.util.Scanner; import java.io.PrintWriter; /* * Examples input 3 2 30 4 6 14 25 48 output 3 input 123 1 2143435 4 123 11 -5453 141245 output 0 input 123 1 2143435 4 54343 -13 6 124 output inf */ public class P789B_Masha_and_geometric_depression { private static PrintWriter pw...
Java
["3 2 30 4\n6 14 25 48", "123 1 2143435 4\n123 11 -5453 141245", "123 1 2143435 4\n54343 -13 6 124"]
1 second
["3", "0", "inf"]
NoteIn the first sample case, Masha will write integers 3, 12, 24. Progression term 6 will be skipped because it is a "bad" integer. Terms bigger than 24 won't be written because they exceed l by absolute value.In the second case, Masha won't write any number because all terms are equal 123 and this is a "bad" integer....
Java 8
standard input
[ "implementation", "brute force", "math" ]
749c290c48272a53e2e79730dab0538e
The first line of input contains four integers b1, q, l, m (-109 ≀ b1, q ≀ 109, 1 ≀ l ≀ 109, 1 ≀ m ≀ 105)Β β€” the initial term and the common ratio of progression, absolute value of maximal number that can be written on the board and the number of "bad" integers, respectively. The second line contains m distinct integers...
1,700
Print the only integer, meaning the number of progression terms that will be written on the board if it is finite, or "inf" (without quotes) otherwise.
standard output
PASSED
7579ff2347e0f4da266ec573de68f8c0
train_001.jsonl
1490803500
Masha really loves algebra. On the last lesson, her strict teacher Dvastan gave she new exercise.You are given geometric progression b defined by two integers b1 and q. Remind that a geometric progression is a sequence of integers b1, b2, b3, ..., where for each i > 1 the respective term satisfies the condition bi =...
256 megabytes
import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Scanner; /** * Created by n1k1t4 on 07.04.17. */ public class CF407_2 { private static int firstElement; private static int multiplier; private static int maxSequenceValue; private...
Java
["3 2 30 4\n6 14 25 48", "123 1 2143435 4\n123 11 -5453 141245", "123 1 2143435 4\n54343 -13 6 124"]
1 second
["3", "0", "inf"]
NoteIn the first sample case, Masha will write integers 3, 12, 24. Progression term 6 will be skipped because it is a "bad" integer. Terms bigger than 24 won't be written because they exceed l by absolute value.In the second case, Masha won't write any number because all terms are equal 123 and this is a "bad" integer....
Java 8
standard input
[ "implementation", "brute force", "math" ]
749c290c48272a53e2e79730dab0538e
The first line of input contains four integers b1, q, l, m (-109 ≀ b1, q ≀ 109, 1 ≀ l ≀ 109, 1 ≀ m ≀ 105)Β β€” the initial term and the common ratio of progression, absolute value of maximal number that can be written on the board and the number of "bad" integers, respectively. The second line contains m distinct integers...
1,700
Print the only integer, meaning the number of progression terms that will be written on the board if it is finite, or "inf" (without quotes) otherwise.
standard output
PASSED
0082707ed62636b4ca4fc7f22050e7ba
train_001.jsonl
1490803500
Masha really loves algebra. On the last lesson, her strict teacher Dvastan gave she new exercise.You are given geometric progression b defined by two integers b1 and q. Remind that a geometric progression is a sequence of integers b1, b2, b3, ..., where for each i > 1 the respective term satisfies the condition bi =...
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.HashSet; import java.util.StringTokenizer; public class B { public static void main(String[] args) throws IOException{ Scanner...
Java
["3 2 30 4\n6 14 25 48", "123 1 2143435 4\n123 11 -5453 141245", "123 1 2143435 4\n54343 -13 6 124"]
1 second
["3", "0", "inf"]
NoteIn the first sample case, Masha will write integers 3, 12, 24. Progression term 6 will be skipped because it is a "bad" integer. Terms bigger than 24 won't be written because they exceed l by absolute value.In the second case, Masha won't write any number because all terms are equal 123 and this is a "bad" integer....
Java 8
standard input
[ "implementation", "brute force", "math" ]
749c290c48272a53e2e79730dab0538e
The first line of input contains four integers b1, q, l, m (-109 ≀ b1, q ≀ 109, 1 ≀ l ≀ 109, 1 ≀ m ≀ 105)Β β€” the initial term and the common ratio of progression, absolute value of maximal number that can be written on the board and the number of "bad" integers, respectively. The second line contains m distinct integers...
1,700
Print the only integer, meaning the number of progression terms that will be written on the board if it is finite, or "inf" (without quotes) otherwise.
standard output
PASSED
3c7efde5fdb03325f8557a8e8b3f1e1b
train_001.jsonl
1490803500
Masha really loves algebra. On the last lesson, her strict teacher Dvastan gave she new exercise.You are given geometric progression b defined by two integers b1 and q. Remind that a geometric progression is a sequence of integers b1, b2, b3, ..., where for each i > 1 the respective term satisfies the condition bi =...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.TreeSet; public class B { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); long b = sc.nextL...
Java
["3 2 30 4\n6 14 25 48", "123 1 2143435 4\n123 11 -5453 141245", "123 1 2143435 4\n54343 -13 6 124"]
1 second
["3", "0", "inf"]
NoteIn the first sample case, Masha will write integers 3, 12, 24. Progression term 6 will be skipped because it is a "bad" integer. Terms bigger than 24 won't be written because they exceed l by absolute value.In the second case, Masha won't write any number because all terms are equal 123 and this is a "bad" integer....
Java 8
standard input
[ "implementation", "brute force", "math" ]
749c290c48272a53e2e79730dab0538e
The first line of input contains four integers b1, q, l, m (-109 ≀ b1, q ≀ 109, 1 ≀ l ≀ 109, 1 ≀ m ≀ 105)Β β€” the initial term and the common ratio of progression, absolute value of maximal number that can be written on the board and the number of "bad" integers, respectively. The second line contains m distinct integers...
1,700
Print the only integer, meaning the number of progression terms that will be written on the board if it is finite, or "inf" (without quotes) otherwise.
standard output
PASSED
2a823be59eb762e47f2f630b13a358ef
train_001.jsonl
1490803500
Masha really loves algebra. On the last lesson, her strict teacher Dvastan gave she new exercise.You are given geometric progression b defined by two integers b1 and q. Remind that a geometric progression is a sequence of integers b1, b2, b3, ..., where for each i > 1 the respective term satisfies the condition bi =...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.HashSet; import java.util.Scanner; import java.util.StringTokenizer; public class b { public static void main(String[] args) { Scanner in = new Scanner(System.in); long b1 ...
Java
["3 2 30 4\n6 14 25 48", "123 1 2143435 4\n123 11 -5453 141245", "123 1 2143435 4\n54343 -13 6 124"]
1 second
["3", "0", "inf"]
NoteIn the first sample case, Masha will write integers 3, 12, 24. Progression term 6 will be skipped because it is a "bad" integer. Terms bigger than 24 won't be written because they exceed l by absolute value.In the second case, Masha won't write any number because all terms are equal 123 and this is a "bad" integer....
Java 8
standard input
[ "implementation", "brute force", "math" ]
749c290c48272a53e2e79730dab0538e
The first line of input contains four integers b1, q, l, m (-109 ≀ b1, q ≀ 109, 1 ≀ l ≀ 109, 1 ≀ m ≀ 105)Β β€” the initial term and the common ratio of progression, absolute value of maximal number that can be written on the board and the number of "bad" integers, respectively. The second line contains m distinct integers...
1,700
Print the only integer, meaning the number of progression terms that will be written on the board if it is finite, or "inf" (without quotes) otherwise.
standard output
PASSED
9b259119d366a760442cb1ac2800f7d5
train_001.jsonl
1490803500
Masha really loves algebra. On the last lesson, her strict teacher Dvastan gave she new exercise.You are given geometric progression b defined by two integers b1 and q. Remind that a geometric progression is a sequence of integers b1, b2, b3, ..., where for each i > 1 the respective term satisfies the condition bi =...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.HashMap; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author P...
Java
["3 2 30 4\n6 14 25 48", "123 1 2143435 4\n123 11 -5453 141245", "123 1 2143435 4\n54343 -13 6 124"]
1 second
["3", "0", "inf"]
NoteIn the first sample case, Masha will write integers 3, 12, 24. Progression term 6 will be skipped because it is a "bad" integer. Terms bigger than 24 won't be written because they exceed l by absolute value.In the second case, Masha won't write any number because all terms are equal 123 and this is a "bad" integer....
Java 8
standard input
[ "implementation", "brute force", "math" ]
749c290c48272a53e2e79730dab0538e
The first line of input contains four integers b1, q, l, m (-109 ≀ b1, q ≀ 109, 1 ≀ l ≀ 109, 1 ≀ m ≀ 105)Β β€” the initial term and the common ratio of progression, absolute value of maximal number that can be written on the board and the number of "bad" integers, respectively. The second line contains m distinct integers...
1,700
Print the only integer, meaning the number of progression terms that will be written on the board if it is finite, or "inf" (without quotes) otherwise.
standard output
PASSED
98328e924f48a9233b445b212fe8b210
train_001.jsonl
1490803500
Masha really loves algebra. On the last lesson, her strict teacher Dvastan gave she new exercise.You are given geometric progression b defined by two integers b1 and q. Remind that a geometric progression is a sequence of integers b1, b2, b3, ..., where for each i > 1 the respective term satisfies the condition bi =...
256 megabytes
import java.io.InputStream; import java.io.BufferedReader; import java.io.PrintWriter; import java.io.InputStreamReader; import java.io.IOException; import java.io.BufferedWriter; import java.io.OutputStreamWriter; import java.math.BigInteger; import java.math.BigDecimal; import java.util.*; import java.util.stream.Str...
Java
["3 2 30 4\n6 14 25 48", "123 1 2143435 4\n123 11 -5453 141245", "123 1 2143435 4\n54343 -13 6 124"]
1 second
["3", "0", "inf"]
NoteIn the first sample case, Masha will write integers 3, 12, 24. Progression term 6 will be skipped because it is a "bad" integer. Terms bigger than 24 won't be written because they exceed l by absolute value.In the second case, Masha won't write any number because all terms are equal 123 and this is a "bad" integer....
Java 8
standard input
[ "implementation", "brute force", "math" ]
749c290c48272a53e2e79730dab0538e
The first line of input contains four integers b1, q, l, m (-109 ≀ b1, q ≀ 109, 1 ≀ l ≀ 109, 1 ≀ m ≀ 105)Β β€” the initial term and the common ratio of progression, absolute value of maximal number that can be written on the board and the number of "bad" integers, respectively. The second line contains m distinct integers...
1,700
Print the only integer, meaning the number of progression terms that will be written on the board if it is finite, or "inf" (without quotes) otherwise.
standard output
PASSED
d305b0033513d0ddd4e70ce2c63729ac
train_001.jsonl
1490803500
Masha really loves algebra. On the last lesson, her strict teacher Dvastan gave she new exercise.You are given geometric progression b defined by two integers b1 and q. Remind that a geometric progression is a sequence of integers b1, b2, b3, ..., where for each i > 1 the respective term satisfies the condition bi =...
256 megabytes
import java.util.Arrays; import java.util.HashMap; import java.util.PriorityQueue; import java.util.Scanner; public class Problem2 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long b1 = sc.nextLong(); long q = sc.nextLong(); long l = sc.nextLong(); int m = sc.nextInt(...
Java
["3 2 30 4\n6 14 25 48", "123 1 2143435 4\n123 11 -5453 141245", "123 1 2143435 4\n54343 -13 6 124"]
1 second
["3", "0", "inf"]
NoteIn the first sample case, Masha will write integers 3, 12, 24. Progression term 6 will be skipped because it is a "bad" integer. Terms bigger than 24 won't be written because they exceed l by absolute value.In the second case, Masha won't write any number because all terms are equal 123 and this is a "bad" integer....
Java 8
standard input
[ "implementation", "brute force", "math" ]
749c290c48272a53e2e79730dab0538e
The first line of input contains four integers b1, q, l, m (-109 ≀ b1, q ≀ 109, 1 ≀ l ≀ 109, 1 ≀ m ≀ 105)Β β€” the initial term and the common ratio of progression, absolute value of maximal number that can be written on the board and the number of "bad" integers, respectively. The second line contains m distinct integers...
1,700
Print the only integer, meaning the number of progression terms that will be written on the board if it is finite, or "inf" (without quotes) otherwise.
standard output
PASSED
c4f12964e6e2ba67b45e07f972bd2949
train_001.jsonl
1490803500
Masha really loves algebra. On the last lesson, her strict teacher Dvastan gave she new exercise.You are given geometric progression b defined by two integers b1 and q. Remind that a geometric progression is a sequence of integers b1, b2, b3, ..., where for each i > 1 the respective term satisfies the condition bi =...
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.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Balajiganapathi */ public class Main { public static void main(Strin...
Java
["3 2 30 4\n6 14 25 48", "123 1 2143435 4\n123 11 -5453 141245", "123 1 2143435 4\n54343 -13 6 124"]
1 second
["3", "0", "inf"]
NoteIn the first sample case, Masha will write integers 3, 12, 24. Progression term 6 will be skipped because it is a "bad" integer. Terms bigger than 24 won't be written because they exceed l by absolute value.In the second case, Masha won't write any number because all terms are equal 123 and this is a "bad" integer....
Java 8
standard input
[ "implementation", "brute force", "math" ]
749c290c48272a53e2e79730dab0538e
The first line of input contains four integers b1, q, l, m (-109 ≀ b1, q ≀ 109, 1 ≀ l ≀ 109, 1 ≀ m ≀ 105)Β β€” the initial term and the common ratio of progression, absolute value of maximal number that can be written on the board and the number of "bad" integers, respectively. The second line contains m distinct integers...
1,700
Print the only integer, meaning the number of progression terms that will be written on the board if it is finite, or "inf" (without quotes) otherwise.
standard output
PASSED
ac7e95d7145ddccad25177acd057d841
train_001.jsonl
1490803500
Masha really loves algebra. On the last lesson, her strict teacher Dvastan gave she new exercise.You are given geometric progression b defined by two integers b1 and q. Remind that a geometric progression is a sequence of integers b1, b2, b3, ..., where for each i > 1 the respective term satisfies the condition bi =...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintStream; import java.util.HashSet; import java.util.Set; import java.util.StringTokenizer; /** */ public class Main789B { public static void main(String[] args) { FastScanne...
Java
["3 2 30 4\n6 14 25 48", "123 1 2143435 4\n123 11 -5453 141245", "123 1 2143435 4\n54343 -13 6 124"]
1 second
["3", "0", "inf"]
NoteIn the first sample case, Masha will write integers 3, 12, 24. Progression term 6 will be skipped because it is a "bad" integer. Terms bigger than 24 won't be written because they exceed l by absolute value.In the second case, Masha won't write any number because all terms are equal 123 and this is a "bad" integer....
Java 8
standard input
[ "implementation", "brute force", "math" ]
749c290c48272a53e2e79730dab0538e
The first line of input contains four integers b1, q, l, m (-109 ≀ b1, q ≀ 109, 1 ≀ l ≀ 109, 1 ≀ m ≀ 105)Β β€” the initial term and the common ratio of progression, absolute value of maximal number that can be written on the board and the number of "bad" integers, respectively. The second line contains m distinct integers...
1,700
Print the only integer, meaning the number of progression terms that will be written on the board if it is finite, or "inf" (without quotes) otherwise.
standard output
PASSED
d7118f4bda06d065df27f421abe14104
train_001.jsonl
1490803500
Masha really loves algebra. On the last lesson, her strict teacher Dvastan gave she new exercise.You are given geometric progression b defined by two integers b1 and q. Remind that a geometric progression is a sequence of integers b1, b2, b3, ..., where for each i > 1 the respective term satisfies the condition bi =...
256 megabytes
import java.io.*; import java.util.*; import java.util.Map.Entry; import static java.lang.Math.*; public class Main { // :( public static void solve(FastScanner in, BufferedWriter out) throws IOException { long b = in.nextInt(), q = in.nextInt(), l = abs(in.nextInt()), m = in.nextInt(); Ha...
Java
["3 2 30 4\n6 14 25 48", "123 1 2143435 4\n123 11 -5453 141245", "123 1 2143435 4\n54343 -13 6 124"]
1 second
["3", "0", "inf"]
NoteIn the first sample case, Masha will write integers 3, 12, 24. Progression term 6 will be skipped because it is a "bad" integer. Terms bigger than 24 won't be written because they exceed l by absolute value.In the second case, Masha won't write any number because all terms are equal 123 and this is a "bad" integer....
Java 8
standard input
[ "implementation", "brute force", "math" ]
749c290c48272a53e2e79730dab0538e
The first line of input contains four integers b1, q, l, m (-109 ≀ b1, q ≀ 109, 1 ≀ l ≀ 109, 1 ≀ m ≀ 105)Β β€” the initial term and the common ratio of progression, absolute value of maximal number that can be written on the board and the number of "bad" integers, respectively. The second line contains m distinct integers...
1,700
Print the only integer, meaning the number of progression terms that will be written on the board if it is finite, or "inf" (without quotes) otherwise.
standard output
PASSED
b275fabbfc322a0a9545b6cc2d590647
train_001.jsonl
1302609600
You are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points.
256 megabytes
import java.io.*; import java.math.*; import java.util.*; /** * @author Alexey Safronov (safronov.aa@gmail.com) */ public class E { private InputReader in; private PrintWriter out; private void solve() { int n = in.readInt(); long[] xg = new long[10001]; long[] xl = new long[10001]; long[] yg = new lo...
Java
["4\n1 1\n-1 -1\n1 -1\n-1 1"]
1 second
["32"]
null
Java 6
standard input
[ "implementation", "math" ]
9bd6fea892857d7c94ebce4d4cd46d30
The first line of input contains one integer number N (1 ≀ N ≀ 100 000) β€” the number of points. Each of the following N lines contain two integer numbers X and Y ( - 10 000 ≀ X, Y ≀ 10 000) β€” the coordinates of points. Two or more points may coincide.
1,700
The only line of output should contain the required sum of squares of distances between all pairs of points.
standard output
PASSED
c7172b85bbd88fae5385253804453c4d
train_001.jsonl
1302609600
You are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points.
256 megabytes
import java.util.*; import java.math.*; public class E { public static void main(String[] args) { new E(); } public E() { int N = nextInt(); BigInteger sumx = BigInteger.ZERO; BigInteger sumy = BigInteger.ZERO; vect[] vs = new vect[N]; for (int i=0; i...
Java
["4\n1 1\n-1 -1\n1 -1\n-1 1"]
1 second
["32"]
null
Java 6
standard input
[ "implementation", "math" ]
9bd6fea892857d7c94ebce4d4cd46d30
The first line of input contains one integer number N (1 ≀ N ≀ 100 000) β€” the number of points. Each of the following N lines contain two integer numbers X and Y ( - 10 000 ≀ X, Y ≀ 10 000) β€” the coordinates of points. Two or more points may coincide.
1,700
The only line of output should contain the required sum of squares of distances between all pairs of points.
standard output
PASSED
98a281e71273bf186a22560fa37c2f15
train_001.jsonl
1302609600
You are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points.
256 megabytes
import java.util.Scanner; public class E { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); long ans = 0; long X = 0; long Y = 0; for (int i = 0; i < n; i++) { long x = in.nextLong(); long y...
Java
["4\n1 1\n-1 -1\n1 -1\n-1 1"]
1 second
["32"]
null
Java 6
standard input
[ "implementation", "math" ]
9bd6fea892857d7c94ebce4d4cd46d30
The first line of input contains one integer number N (1 ≀ N ≀ 100 000) β€” the number of points. Each of the following N lines contain two integer numbers X and Y ( - 10 000 ≀ X, Y ≀ 10 000) β€” the coordinates of points. Two or more points may coincide.
1,700
The only line of output should contain the required sum of squares of distances between all pairs of points.
standard output
PASSED
ce3e1a315aef486cc1ccb1eec8422707
train_001.jsonl
1302609600
You are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points.
256 megabytes
import java.util.Scanner; import java.math.BigInteger; public class Main { public static void main(String[] args) { new Main().start(); } private void start() { Scanner in = new Scanner(System.in); int n = in.nextInt(); int x[] = new int[n]; int y[] = new int[n]; long sx = 0; long sy = 0; BigInteg...
Java
["4\n1 1\n-1 -1\n1 -1\n-1 1"]
1 second
["32"]
null
Java 6
standard input
[ "implementation", "math" ]
9bd6fea892857d7c94ebce4d4cd46d30
The first line of input contains one integer number N (1 ≀ N ≀ 100 000) β€” the number of points. Each of the following N lines contain two integer numbers X and Y ( - 10 000 ≀ X, Y ≀ 10 000) β€” the coordinates of points. Two or more points may coincide.
1,700
The only line of output should contain the required sum of squares of distances between all pairs of points.
standard output
PASSED
5dfeee134a72ffed32db9c54268f0abb
train_001.jsonl
1302609600
You are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points.
256 megabytes
import java.util.*; import java.lang.*; import java.math.*; public class anuj { public static void main(String args[]) { Scanner c=new Scanner(System.in); int n=c.nextInt(); int num[]=new int[20010]; Arrays.fill(num,0); int X[]=new int[n]; int Y[]=new int[n]; for(int i=0;i<n;i++) { X[i]=c.nex...
Java
["4\n1 1\n-1 -1\n1 -1\n-1 1"]
1 second
["32"]
null
Java 6
standard input
[ "implementation", "math" ]
9bd6fea892857d7c94ebce4d4cd46d30
The first line of input contains one integer number N (1 ≀ N ≀ 100 000) β€” the number of points. Each of the following N lines contain two integer numbers X and Y ( - 10 000 ≀ X, Y ≀ 10 000) β€” the coordinates of points. Two or more points may coincide.
1,700
The only line of output should contain the required sum of squares of distances between all pairs of points.
standard output
PASSED
9e9ce612c98a59532600973bf3e8e852
train_001.jsonl
1302609600
You are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points.
256 megabytes
import java.util.*; import java.lang.*; import java.math.*; public class anuj { public static void main(String args[]) { Scanner c=new Scanner(System.in); int n=c.nextInt(); int num[]=new int[20010]; Arrays.fill(num,0); int X[]=new int[n]; ...
Java
["4\n1 1\n-1 -1\n1 -1\n-1 1"]
1 second
["32"]
null
Java 6
standard input
[ "implementation", "math" ]
9bd6fea892857d7c94ebce4d4cd46d30
The first line of input contains one integer number N (1 ≀ N ≀ 100 000) β€” the number of points. Each of the following N lines contain two integer numbers X and Y ( - 10 000 ≀ X, Y ≀ 10 000) β€” the coordinates of points. Two or more points may coincide.
1,700
The only line of output should contain the required sum of squares of distances between all pairs of points.
standard output
PASSED
fa5dd9cf0a26dbbf54bc44b84f3f2e5d
train_001.jsonl
1302609600
You are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; import java.util.*; public class Points implements Runnable { private void solve() throws IOException { int n = nextInt(); long x = 0, x2 = 0, y...
Java
["4\n1 1\n-1 -1\n1 -1\n-1 1"]
1 second
["32"]
null
Java 6
standard input
[ "implementation", "math" ]
9bd6fea892857d7c94ebce4d4cd46d30
The first line of input contains one integer number N (1 ≀ N ≀ 100 000) β€” the number of points. Each of the following N lines contain two integer numbers X and Y ( - 10 000 ≀ X, Y ≀ 10 000) β€” the coordinates of points. Two or more points may coincide.
1,700
The only line of output should contain the required sum of squares of distances between all pairs of points.
standard output
PASSED
cc26d433b9cbd71769b56052f50c62a6
train_001.jsonl
1302609600
You are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points.
256 megabytes
import java.io.*; import java.util.HashSet; public class Points { static class Parser { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; public Parser(InputStream in) { din = ne...
Java
["4\n1 1\n-1 -1\n1 -1\n-1 1"]
1 second
["32"]
null
Java 6
standard input
[ "implementation", "math" ]
9bd6fea892857d7c94ebce4d4cd46d30
The first line of input contains one integer number N (1 ≀ N ≀ 100 000) β€” the number of points. Each of the following N lines contain two integer numbers X and Y ( - 10 000 ≀ X, Y ≀ 10 000) β€” the coordinates of points. Two or more points may coincide.
1,700
The only line of output should contain the required sum of squares of distances between all pairs of points.
standard output
PASSED
4592f02cb6ef30d6de59aa8e3950d2e1
train_001.jsonl
1302609600
You are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points.
256 megabytes
//package ukr; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; public class E { static BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer...
Java
["4\n1 1\n-1 -1\n1 -1\n-1 1"]
1 second
["32"]
null
Java 6
standard input
[ "implementation", "math" ]
9bd6fea892857d7c94ebce4d4cd46d30
The first line of input contains one integer number N (1 ≀ N ≀ 100 000) β€” the number of points. Each of the following N lines contain two integer numbers X and Y ( - 10 000 ≀ X, Y ≀ 10 000) β€” the coordinates of points. Two or more points may coincide.
1,700
The only line of output should contain the required sum of squares of distances between all pairs of points.
standard output
PASSED
2342aa3616d679419713fa6233c955d7
train_001.jsonl
1302609600
You are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points.
256 megabytes
import java.awt.Point; import java.io.*; import java.math.BigInteger; import java.util.*; import static java.lang.Math.*; public class ProblemE_UA { final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE")!=null; BufferedReader in; PrintWriter out; StringTokenizer tok = new StringTokenizer(""); void ...
Java
["4\n1 1\n-1 -1\n1 -1\n-1 1"]
1 second
["32"]
null
Java 6
standard input
[ "implementation", "math" ]
9bd6fea892857d7c94ebce4d4cd46d30
The first line of input contains one integer number N (1 ≀ N ≀ 100 000) β€” the number of points. Each of the following N lines contain two integer numbers X and Y ( - 10 000 ≀ X, Y ≀ 10 000) β€” the coordinates of points. Two or more points may coincide.
1,700
The only line of output should contain the required sum of squares of distances between all pairs of points.
standard output
PASSED
c665fa3af47b0311b21e39e561fc4988
train_001.jsonl
1302609600
You are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points.
256 megabytes
import java.io.*; /** * All-Ukrainian School Olympiad in Informatics, D * @author Roman Kosenko <madkite@gmail.com> */ public class Points { public static void main(String[] args) throws IOException { FastScanner scanner = new FastScanner(!Boolean.parseBoolean(System.getProperty("ONLINE_JUDGE")) ? new FileInputS...
Java
["4\n1 1\n-1 -1\n1 -1\n-1 1"]
1 second
["32"]
null
Java 6
standard input
[ "implementation", "math" ]
9bd6fea892857d7c94ebce4d4cd46d30
The first line of input contains one integer number N (1 ≀ N ≀ 100 000) β€” the number of points. Each of the following N lines contain two integer numbers X and Y ( - 10 000 ≀ X, Y ≀ 10 000) β€” the coordinates of points. Two or more points may coincide.
1,700
The only line of output should contain the required sum of squares of distances between all pairs of points.
standard output
PASSED
5d6335d08a8cab3b1ba1ec1a644fddb9
train_001.jsonl
1302609600
You are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points.
256 megabytes
import java.io.*; /** * All-Ukrainian School Olympiad in Informatics, D * @author Roman Kosenko <madkite@gmail.com> */ public class Points { public static void main(String[] args) throws IOException { if(!Boolean.parseBoolean(System.getProperty("ONLINE_JUDGE"))) System.setIn(new FileInputStream(new File("inpu...
Java
["4\n1 1\n-1 -1\n1 -1\n-1 1"]
1 second
["32"]
null
Java 6
standard input
[ "implementation", "math" ]
9bd6fea892857d7c94ebce4d4cd46d30
The first line of input contains one integer number N (1 ≀ N ≀ 100 000) β€” the number of points. Each of the following N lines contain two integer numbers X and Y ( - 10 000 ≀ X, Y ≀ 10 000) β€” the coordinates of points. Two or more points may coincide.
1,700
The only line of output should contain the required sum of squares of distances between all pairs of points.
standard output
PASSED
522cf047acefd9278fd3b71b18b136d2
train_001.jsonl
1302609600
You are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points.
256 megabytes
import java.io.*; /** * All-Ukrainian School Olympiad in Informatics, D * @author Roman Kosenko <madkite@gmail.com> */ public class Points { public static void main(String[] args) throws IOException { FastScanner scanner = new FastScanner(!Boolean.parseBoolean(System.getProperty("ONLINE_JUDGE")) ? new FileInputS...
Java
["4\n1 1\n-1 -1\n1 -1\n-1 1"]
1 second
["32"]
null
Java 6
standard input
[ "implementation", "math" ]
9bd6fea892857d7c94ebce4d4cd46d30
The first line of input contains one integer number N (1 ≀ N ≀ 100 000) β€” the number of points. Each of the following N lines contain two integer numbers X and Y ( - 10 000 ≀ X, Y ≀ 10 000) β€” the coordinates of points. Two or more points may coincide.
1,700
The only line of output should contain the required sum of squares of distances between all pairs of points.
standard output
PASSED
19240bb5fde983d2c336db7911548c1f
train_001.jsonl
1302609600
You are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points.
256 megabytes
import java.io.*; import java.util.*; /** * All-Ukrainian School Olympiad in Informatics, E * @author Roman Kosenko <madkite@gmail.com> */ public class Points { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer....
Java
["4\n1 1\n-1 -1\n1 -1\n-1 1"]
1 second
["32"]
null
Java 6
standard input
[ "implementation", "math" ]
9bd6fea892857d7c94ebce4d4cd46d30
The first line of input contains one integer number N (1 ≀ N ≀ 100 000) β€” the number of points. Each of the following N lines contain two integer numbers X and Y ( - 10 000 ≀ X, Y ≀ 10 000) β€” the coordinates of points. Two or more points may coincide.
1,700
The only line of output should contain the required sum of squares of distances between all pairs of points.
standard output
PASSED
44f027d6a4e9937e918f4d2379abc2e4
train_001.jsonl
1302609600
You are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points.
256 megabytes
import java.io.*; import java.util.*; /** * All-Ukrainian School Olympiad in Informatics, E * @author Roman Kosenko <madkite@gmail.com> */ public class Points { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer....
Java
["4\n1 1\n-1 -1\n1 -1\n-1 1"]
1 second
["32"]
null
Java 6
standard input
[ "implementation", "math" ]
9bd6fea892857d7c94ebce4d4cd46d30
The first line of input contains one integer number N (1 ≀ N ≀ 100 000) β€” the number of points. Each of the following N lines contain two integer numbers X and Y ( - 10 000 ≀ X, Y ≀ 10 000) β€” the coordinates of points. Two or more points may coincide.
1,700
The only line of output should contain the required sum of squares of distances between all pairs of points.
standard output
PASSED
393d93747545826f8abf22b3020deed0
train_001.jsonl
1302609600
You are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points.
256 megabytes
import java.io.*; /** * All-Ukrainian School Olympiad in Informatics, E * @author Roman Kosenko <madkite@gmail.com> */ public class Points { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine...
Java
["4\n1 1\n-1 -1\n1 -1\n-1 1"]
1 second
["32"]
null
Java 6
standard input
[ "implementation", "math" ]
9bd6fea892857d7c94ebce4d4cd46d30
The first line of input contains one integer number N (1 ≀ N ≀ 100 000) β€” the number of points. Each of the following N lines contain two integer numbers X and Y ( - 10 000 ≀ X, Y ≀ 10 000) β€” the coordinates of points. Two or more points may coincide.
1,700
The only line of output should contain the required sum of squares of distances between all pairs of points.
standard output
PASSED
129bfde797a5a54093d3305739872216
train_001.jsonl
1302609600
You are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points.
256 megabytes
import java.util.*; /** * Created by IntelliJ IDEA. * User: piyushd * Date: 3/29/11 * Time: 7:56 PM * To change this template use File | Settings | File Templates. */ public class TaskE { void run(){ int N = nextInt(); long[] x = new long[N]; long[] y = new long[N]; for(int ...
Java
["4\n1 1\n-1 -1\n1 -1\n-1 1"]
1 second
["32"]
null
Java 6
standard input
[ "implementation", "math" ]
9bd6fea892857d7c94ebce4d4cd46d30
The first line of input contains one integer number N (1 ≀ N ≀ 100 000) β€” the number of points. Each of the following N lines contain two integer numbers X and Y ( - 10 000 ≀ X, Y ≀ 10 000) β€” the coordinates of points. Two or more points may coincide.
1,700
The only line of output should contain the required sum of squares of distances between all pairs of points.
standard output
PASSED
68779ac18a4fb5d415161b8bc87ccace
train_001.jsonl
1302609600
You are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points.
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.fill; import static java.util.Arrays.binarySearch; import static java.util.Arrays.sort; public class Main { public static void main(String[] args) throws IOException { new Thread(null, new Runnable() { ...
Java
["4\n1 1\n-1 -1\n1 -1\n-1 1"]
1 second
["32"]
null
Java 6
standard input
[ "implementation", "math" ]
9bd6fea892857d7c94ebce4d4cd46d30
The first line of input contains one integer number N (1 ≀ N ≀ 100 000) β€” the number of points. Each of the following N lines contain two integer numbers X and Y ( - 10 000 ≀ X, Y ≀ 10 000) β€” the coordinates of points. Two or more points may coincide.
1,700
The only line of output should contain the required sum of squares of distances between all pairs of points.
standard output
PASSED
9de8f47060f04ca954cec6eacd01b60b
train_001.jsonl
1302609600
You are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points.
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.StreamTokenizer; public class Main { private static StreamTokenizer in; private static PrintWriter out; private static BufferedReader inB; private static int nextInt() throws Exception{ ...
Java
["4\n1 1\n-1 -1\n1 -1\n-1 1"]
1 second
["32"]
null
Java 6
standard input
[ "implementation", "math" ]
9bd6fea892857d7c94ebce4d4cd46d30
The first line of input contains one integer number N (1 ≀ N ≀ 100 000) β€” the number of points. Each of the following N lines contain two integer numbers X and Y ( - 10 000 ≀ X, Y ≀ 10 000) β€” the coordinates of points. Two or more points may coincide.
1,700
The only line of output should contain the required sum of squares of distances between all pairs of points.
standard output
PASSED
ca85856313e085274a276ce850cc3711
train_001.jsonl
1481992500
Hongcow is ruler of the world. As ruler of the world, he wants to make it easier for people to travel by road within their own countries.The world can be modeled as an undirected graph with n nodes and m edges. k of the nodes are home to the governments of the k countries that make up the world.There is at most one edg...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Random; import java.util.StringTokenizer; import java.util.List; import java.util.Collections; public class A { private static ...
Java
["4 1 2\n1 3\n1 2", "3 3 1\n2\n1 2\n1 3\n2 3"]
2 seconds
["2", "0"]
NoteFor the first sample test, the graph looks like this: Vertices 1 and 3 are special. The optimal solution is to connect vertex 4 to vertices 1 and 2. This adds a total of 2 edges. We cannot add any more edges, since vertices 1 and 3 cannot have any path between them.For the second sample test, the graph looks lik...
Java 11
standard input
[ "dfs and similar", "graphs" ]
6cf43241b14e4d41ad5b36572f3b3663
The first line of input will contain three integers n, m and k (1 ≀ n ≀ 1 000, 0 ≀ m ≀ 100 000, 1 ≀ k ≀ n)Β β€” the number of vertices and edges in the graph, and the number of vertices that are homes of the government. The next line of input will contain k integers c1, c2, ..., ck (1 ≀ ci ≀ n). These integers will be pa...
1,500
Output a single integer, the maximum number of edges Hongcow can add to the graph while keeping it stable.
standard output
PASSED
81958f893e99a3de83fa3a865686c892
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class CO_519D { static int imax=Integer.MAX_VALUE,imin=Integer.MIN_VALUE; static long lmax=Long.MAX_VALUE,lmin=Long.MIN_VALUE; public static void main (String[] args) throws java.lang.Exception { // Scanner scan=new Scanner(System.in); InputRea...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 8
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≀ xi ≀ 105) β€” the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase lettersβ€” the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
b7893fb1543f7b6e47114b11e3782a92
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
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.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Pr...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 8
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≀ xi ≀ 105) β€” the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase lettersβ€” the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
6f49ed099e639d821617e9a1341873b1
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.HashMap; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author P...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 8
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≀ xi ≀ 105) β€” the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase lettersβ€” the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
8f1cea7f0a33416c9424db3bc4aae6bb
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
256 megabytes
import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class D { int[] waits = new int[26]; char[] s; int[] lengthsOfCharacters = new int[26]; long[][] mem = new long[26][100000]; public static void main(String[] args) { Scanner scanner = new Scanner(System.in); D d = new D(); ...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 8
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≀ xi ≀ 105) β€” the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase lettersβ€” the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
bf21ade5c949a4c406eb701f373acd1b
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
256 megabytes
import java.io.*; import java.util.*; public class D { FastScanner in; PrintWriter out; int i = 0, j = 0; void solve() { /**************START**************/ int[] x = new int[26]; HashMap<Long, Integer>[] map = (HashMap<Long, Integer>[]) new HashMap[26]; for (i = 0; i < 26; i++) { x[i] = in.nextInt...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 8
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≀ xi ≀ 105) β€” the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase lettersβ€” the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
6bd8617a59f774712f99272f7dd6e609
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
256 megabytes
import java.util.ArrayList; import java.util.HashMap; import java.util.Scanner; import java.util.StringTokenizer; public class A_And_B_And_Interesting_Substrings { public static void main(String [] args) { Scanner sc=new Scanner (System.in); int [] weights=new int [26]; HashMap<Long, Integer> [] arr=new HashMa...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 8
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≀ xi ≀ 105) β€” the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase lettersβ€” the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
7da798a00f80f022bee577f9d12c8531
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
256 megabytes
import java.io.*; import java.util.*; public class Sol2{ public static HashMap<Long, Long> mp = new HashMap<>(); public static int dp[][] = new int[100001][26]; public static void main(String[] args) throws IOException{ FastScanner sc = new FastScanner(); int alph[] = new int[26]; for(int i=0; i<26; i++) { ...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 8
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≀ xi ≀ 105) β€” the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase lettersβ€” the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
104703c05133e83ff684060831e0ba1f
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { InputReader in = new InputReader(); PrintWriter out = new PrintWriter(System.out); int t = 1; Solver s = new Solver(); for (int i = 1; i <= t; i++) { s.solve(i, in,...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 8
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≀ xi ≀ 105) β€” the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase lettersβ€” the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
85e40b8fc5efd897e097ec886c7d17a1
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class Main { public static void main(String[] args) throws IOException { InputReader in = new InputReader(System.in); PrintWriter pw = new PrintWriter(System.out); int b[]=in.nextIntArray(26); String s=in.readString()...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 8
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≀ xi ≀ 105) β€” the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase lettersβ€” the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
d7812a97ce18c2e1fa2b61673a97aa13
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; import java.util.HashMap; /** * Built using CHelper plug-in * Actual solution is at the top * * @author zodiacLeo */ public class Main { public static void main(String[] a...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 8
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≀ xi ≀ 105) β€” the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase lettersβ€” the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
475c7ad2d606055d32863cd1a65ea0e2
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class Main { public void solve() throws IOException{ int[] aa = new int[26]; for(int i = 0; i < 26; i++){ aa[i] = in.nextInt(); } char[] cc = in.next().toCharArray(); int n = cc.length; ...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 8
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≀ xi ≀ 105) β€” the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase lettersβ€” the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
0bd359ab55efbb4836ab523d051e1225
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
256 megabytes
import java.io.IOException; import java.util.InputMismatchException; import java.util.HashMap; import java.io.OutputStream; import java.io.PrintWriter; import java.math.BigInteger; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author Walker */ public class Main { ...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 8
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≀ xi ≀ 105) β€” the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase lettersβ€” the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
3fbade6cd95c805605bbb84c98dc2dcd
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.HashMap; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.io.BufferedReader; import java.io.InputStream; /** * Built using CHelpe...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 8
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≀ xi ≀ 105) β€” the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase lettersβ€” the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
bade5adef8028fb4ed7422b373e74d85
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.HashMap; import java.util.Map; public class AandBandInterestingSubstrings { public static void main(String[] args) throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.i...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 8
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≀ xi ≀ 105) β€” the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase lettersβ€” the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
278933db8258a3382e85043fe3bbf1fe
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.HashMap; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.StringTokenizer; import java.io.BufferedReader; import java.io.InputStream; /** * Built using CHelpe...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 8
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≀ xi ≀ 105) β€” the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase lettersβ€” the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
6f93b72e76b235cbd0307d3e79a7f558
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
256 megabytes
import java.awt.*; import java.io.*; import java.util.*; public class Abc { public static void main(String[] args) throws IOException { FastReader sc = new FastReader(); int arr[]=new int[26]; for (int i=0;i<26;i++)arr[i]=sc.nextInt(); String s=sc.next(); Map<Long,Integer> m...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 8
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≀ xi ≀ 105) β€” the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase lettersβ€” the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
bbb84f41e7d9ffc5eaa14d702be6fe00
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
256 megabytes
import java.util.HashMap; import java.util.Scanner; public class A_and_B_and_Interesting_Strings { public static void main(String[] args) { Scanner scn = new Scanner(System.in); int[] arr = new int[26]; for (int i = 0; i < 26; i++) { arr[i] = scn.nextInt(); } String s = scn.next(); long mod = 26515411...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 8
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≀ xi ≀ 105) β€” the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase lettersβ€” the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
f2c8964b4014340b2cd789e375c0f809
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
256 megabytes
import java.util.HashMap; import java.util.Scanner; public class D519xx { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] w = new int[26]; /*create an array of maps, each map denotes a character *<sum of the weights of all the previous lett...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 8
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≀ xi ≀ 105) β€” the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase lettersβ€” the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
632147b0319e7e2c77b6866683afe1bf
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.util.*; import java.lang.*; import static java.lang.Math.*; public class Main implements Runnable { public static void main(String[] args) { new Thread(null, new Main(), "Check2", 1 << 28).start();// to increse stack size in java } void ...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 8
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≀ xi ≀ 105) β€” the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase lettersβ€” the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
2889827ad5994a4e713e99086d520021
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
256 megabytes
import java.io.*; import java.util.*; public class practice519d { public static void main(String[] args) throws Exception { // BufferedReader f = new BufferedReader(new FileReader (new File("sample.txt"))); // PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("sample.txt"))); // StringToken...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 8
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≀ xi ≀ 105) β€” the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase lettersβ€” the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
d2023e0273bb09a3cf8e7df1ee8635cd
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
256 megabytes
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap; import java.util.StringTokenizer; public class D_Int...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 8
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≀ xi ≀ 105) β€” the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase lettersβ€” the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
214c2ed225119046c90ca0c871ca0143
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.TreeMap; public class CF294D { public static void main(String[] args) throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer strt...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 8
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≀ xi ≀ 105) β€” the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase lettersβ€” the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
966c765075dfdc64875b25f006f1f5ba
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
256 megabytes
import java.io.*; import java.util.*; public class AB { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] inp = br.readLine().split(" "); int[] weight = new int[26]; HashMap<Long,Integer>[] hm = new HashMap[26]; ...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 8
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≀ xi ≀ 105) β€” the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase lettersβ€” the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
fec9df1cbf44e8562915f88827a8459a
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.HashMap; import java.util.Map; import java.util.StringTokenizer; import java.util.TreeMap; public class Powers2 { static class...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 8
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≀ xi ≀ 105) β€” the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase lettersβ€” the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
e50da62d780e3df6e636e459874df69f
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
256 megabytes
import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; public class Main { static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 8
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≀ xi ≀ 105) β€” the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase lettersβ€” the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
3278e489fc01471dabc1e6bb1efb37d4
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
256 megabytes
import java.util.function.BiFunction; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.util.NoSuchElementException; import java.math.BigInteger; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.io.IOException; import java.io.InputStream; impo...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 8
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≀ xi ≀ 105) β€” the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase lettersβ€” the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
d1150ea18457e5f5470b279e02aff105
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
256 megabytes
import java.util.function.BiFunction; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.util.NoSuchElementException; import java.util.stream.Stream; import java.math.BigInteger; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.util.stream.IntS...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 8
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≀ xi ≀ 105) β€” the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase lettersβ€” the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
538e19f74f6eaa404021916d4825f899
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
256 megabytes
import java.io.*; import java.util.*; public class D519 { static FastReader in = null; static PrintWriter out = null; public static void solve() { int[] x = new int[26]; for(int i=0; i<26; i++) x[i] = in.nextInt(); char[] s = in.next().toCharArray(); int n = s.length; ...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 8
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≀ xi ≀ 105) β€” the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase lettersβ€” the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
3500305f499c7c8a6950de5634aa2ff0
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
256 megabytes
/** * Created by ankeet on 11/29/16. */ import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.HashMap; import java.util.StringTokenizer; public class D519 { static FastReader in = null; static PrintWriter out = null; pu...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 8
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≀ xi ≀ 105) β€” the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase lettersβ€” the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
44c10fda7c42a62bdf147e9b29478af5
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
256 megabytes
/** * DA-IICT * Author : Savaliya Sagar */ import java.io.*; import java.math.*; import java.util.*; public class D519 { InputStream is; PrintWriter out; int v[]; char c[]; long pre[]; HashMap<Long, Integer> h[] = new HashMap[26]; void solve() { v = na(26); c = ns().toCharArray(); int n = c.length; ...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 8
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≀ xi ≀ 105) β€” the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase lettersβ€” the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
8da9fd930107c3b8c48e6d85f1b5bafc
train_001.jsonl
1382715000
Dima liked the present he got from Inna very much. He liked the present he got from Seryozha even more. Dima felt so grateful to Inna about the present that he decided to buy her n hares. Inna was very happy. She lined up the hares in a row, numbered them from 1 to n from left to right and started feeding them with car...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class DynamicProgramming { static int[] a,b,c; static int n; static int[][] dp; public static void main(String[] args) { Scanner sc=new Scanner(System.in); n=sc.nextInt(); a=new int[n+1]; b=new int[n+1]; c=new int[n+1]; for(int i=1;i<=n;i...
Java
["4\n1 2 3 4\n4 3 2 1\n0 1 1 0", "7\n8 5 7 6 1 8 9\n2 7 9 5 4 3 1\n2 3 3 4 1 1 3", "3\n1 1 1\n1 2 1\n1 1 1"]
2 seconds
["13", "44", "4"]
null
Java 7
standard input
[ "dp", "greedy" ]
99cf10673cb275ad3b90bcd3757ecd47
The first line of the input contains integer n (1 ≀ n ≀ 3000) β€” the number of hares. Then three lines follow, each line has n integers. The first line contains integers a1 a2 ... an. The second line contains b1, b2, ..., bn. The third line contains c1, c2, ..., cn. The following limits are fulfilled: 0 ≀ ai, bi, ci ≀ 1...
1,800
In a single line, print the maximum possible total joy of the hares Inna can get by feeding them.
standard output
PASSED
aec8940bc3244fee069bcbe3bb7fe87b
train_001.jsonl
1382715000
Dima liked the present he got from Inna very much. He liked the present he got from Seryozha even more. Dima felt so grateful to Inna about the present that he decided to buy her n hares. Inna was very happy. She lined up the hares in a row, numbered them from 1 to n from left to right and started feeding them with car...
256 megabytes
//package round208; import java.io.*; import java.util.*; public class ProblemD { private static final boolean DEBUG = true; private static final String INPUT_FILE = "input.txt"; private static final String OUTPUT_FILE = "output.txt"; public static void main(String[] args) { try { ...
Java
["4\n1 2 3 4\n4 3 2 1\n0 1 1 0", "7\n8 5 7 6 1 8 9\n2 7 9 5 4 3 1\n2 3 3 4 1 1 3", "3\n1 1 1\n1 2 1\n1 1 1"]
2 seconds
["13", "44", "4"]
null
Java 7
standard input
[ "dp", "greedy" ]
99cf10673cb275ad3b90bcd3757ecd47
The first line of the input contains integer n (1 ≀ n ≀ 3000) β€” the number of hares. Then three lines follow, each line has n integers. The first line contains integers a1 a2 ... an. The second line contains b1, b2, ..., bn. The third line contains c1, c2, ..., cn. The following limits are fulfilled: 0 ≀ ai, bi, ci ≀ 1...
1,800
In a single line, print the maximum possible total joy of the hares Inna can get by feeding them.
standard output
PASSED
d476f02f24ccc3fec96f2c8748d5e5fa
train_001.jsonl
1382715000
Dima liked the present he got from Inna very much. He liked the present he got from Seryozha even more. Dima felt so grateful to Inna about the present that he decided to buy her n hares. Inna was very happy. She lined up the hares in a row, numbered them from 1 to n from left to right and started feeding them with car...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.Collection; import java.util.Locale; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { ne...
Java
["4\n1 2 3 4\n4 3 2 1\n0 1 1 0", "7\n8 5 7 6 1 8 9\n2 7 9 5 4 3 1\n2 3 3 4 1 1 3", "3\n1 1 1\n1 2 1\n1 1 1"]
2 seconds
["13", "44", "4"]
null
Java 7
standard input
[ "dp", "greedy" ]
99cf10673cb275ad3b90bcd3757ecd47
The first line of the input contains integer n (1 ≀ n ≀ 3000) β€” the number of hares. Then three lines follow, each line has n integers. The first line contains integers a1 a2 ... an. The second line contains b1, b2, ..., bn. The third line contains c1, c2, ..., cn. The following limits are fulfilled: 0 ≀ ai, bi, ci ≀ 1...
1,800
In a single line, print the maximum possible total joy of the hares Inna can get by feeding them.
standard output
PASSED
61e5aafb2fcacbc743c642bbb6b906c3
train_001.jsonl
1382715000
Dima liked the present he got from Inna very much. He liked the present he got from Seryozha even more. Dima felt so grateful to Inna about the present that he decided to buy her n hares. Inna was very happy. She lined up the hares in a row, numbered them from 1 to n from left to right and started feeding them with car...
256 megabytes
import java.math.BigInteger; import java.util.*; import static java.util.Arrays.sort; public class Main{ public static int max(int a,int b){ return a>b?a:b; } public static void main(String args[]){ Scanner cin=new Scanner(System.in); int n; int maxn=3010; int a[]=n...
Java
["4\n1 2 3 4\n4 3 2 1\n0 1 1 0", "7\n8 5 7 6 1 8 9\n2 7 9 5 4 3 1\n2 3 3 4 1 1 3", "3\n1 1 1\n1 2 1\n1 1 1"]
2 seconds
["13", "44", "4"]
null
Java 7
standard input
[ "dp", "greedy" ]
99cf10673cb275ad3b90bcd3757ecd47
The first line of the input contains integer n (1 ≀ n ≀ 3000) β€” the number of hares. Then three lines follow, each line has n integers. The first line contains integers a1 a2 ... an. The second line contains b1, b2, ..., bn. The third line contains c1, c2, ..., cn. The following limits are fulfilled: 0 ≀ ai, bi, ci ≀ 1...
1,800
In a single line, print the maximum possible total joy of the hares Inna can get by feeding them.
standard output
PASSED
6133c9512098a7e5cfa89f754780de5a
train_001.jsonl
1382715000
Dima liked the present he got from Inna very much. He liked the present he got from Seryozha even more. Dima felt so grateful to Inna about the present that he decided to buy her n hares. Inna was very happy. She lined up the hares in a row, numbered them from 1 to n from left to right and started feeding them with car...
256 megabytes
//package codeforces; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.PriorityQueue; import java.util.StringTokenizer; public class D { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); PrintW...
Java
["4\n1 2 3 4\n4 3 2 1\n0 1 1 0", "7\n8 5 7 6 1 8 9\n2 7 9 5 4 3 1\n2 3 3 4 1 1 3", "3\n1 1 1\n1 2 1\n1 1 1"]
2 seconds
["13", "44", "4"]
null
Java 7
standard input
[ "dp", "greedy" ]
99cf10673cb275ad3b90bcd3757ecd47
The first line of the input contains integer n (1 ≀ n ≀ 3000) β€” the number of hares. Then three lines follow, each line has n integers. The first line contains integers a1 a2 ... an. The second line contains b1, b2, ..., bn. The third line contains c1, c2, ..., cn. The following limits are fulfilled: 0 ≀ ai, bi, ci ≀ 1...
1,800
In a single line, print the maximum possible total joy of the hares Inna can get by feeding them.
standard output
PASSED
f0f3603b731a370e14cc7b9df4d3ecfd
train_001.jsonl
1382715000
Dima liked the present he got from Inna very much. He liked the present he got from Seryozha even more. Dima felt so grateful to Inna about the present that he decided to buy her n hares. Inna was very happy. She lined up the hares in a row, numbered them from 1 to n from left to right and started feeding them with car...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.Queue; import java.util.concurrent.ArrayBlockingQueue; public class ProblemD { static final long MOD = 1000000007; public static void main(String[] args...
Java
["4\n1 2 3 4\n4 3 2 1\n0 1 1 0", "7\n8 5 7 6 1 8 9\n2 7 9 5 4 3 1\n2 3 3 4 1 1 3", "3\n1 1 1\n1 2 1\n1 1 1"]
2 seconds
["13", "44", "4"]
null
Java 7
standard input
[ "dp", "greedy" ]
99cf10673cb275ad3b90bcd3757ecd47
The first line of the input contains integer n (1 ≀ n ≀ 3000) β€” the number of hares. Then three lines follow, each line has n integers. The first line contains integers a1 a2 ... an. The second line contains b1, b2, ..., bn. The third line contains c1, c2, ..., cn. The following limits are fulfilled: 0 ≀ ai, bi, ci ≀ 1...
1,800
In a single line, print the maximum possible total joy of the hares Inna can get by feeding them.
standard output
PASSED
6d690cf5448855203f5bf84a5c0289e0
train_001.jsonl
1382715000
Dima liked the present he got from Inna very much. He liked the present he got from Seryozha even more. Dima felt so grateful to Inna about the present that he decided to buy her n hares. Inna was very happy. She lined up the hares in a row, numbered them from 1 to n from left to right and started feeding them with car...
256 megabytes
import java.io.*; import java.util.*; public class D { public static void main(String[] args) { new D().run(); } void solve() throws IOException { int n = ni(); long a[] = nla(n); long b[] = nla(n); long c[] = nla(n); long d[] = new long[n + 1]; lon...
Java
["4\n1 2 3 4\n4 3 2 1\n0 1 1 0", "7\n8 5 7 6 1 8 9\n2 7 9 5 4 3 1\n2 3 3 4 1 1 3", "3\n1 1 1\n1 2 1\n1 1 1"]
2 seconds
["13", "44", "4"]
null
Java 7
standard input
[ "dp", "greedy" ]
99cf10673cb275ad3b90bcd3757ecd47
The first line of the input contains integer n (1 ≀ n ≀ 3000) β€” the number of hares. Then three lines follow, each line has n integers. The first line contains integers a1 a2 ... an. The second line contains b1, b2, ..., bn. The third line contains c1, c2, ..., cn. The following limits are fulfilled: 0 ≀ ai, bi, ci ≀ 1...
1,800
In a single line, print the maximum possible total joy of the hares Inna can get by feeding them.
standard output
PASSED
3cd0fa62a07c069edbf184729b14afb0
train_001.jsonl
1382715000
Dima liked the present he got from Inna very much. He liked the present he got from Seryozha even more. Dima felt so grateful to Inna about the present that he decided to buy her n hares. Inna was very happy. She lined up the hares in a row, numbered them from 1 to n from left to right and started feeding them with car...
256 megabytes
import java.io.*; import static java.math.BigInteger.*; import static java.util.Arrays.*; import java.math.*; import java.util.*; public class Solution { public static void main(String[] args) throws Exception{ new Sol().sol(); } } class Sol { BufferedReader in; PrintWriter out; StringTokenizer st; String ne...
Java
["4\n1 2 3 4\n4 3 2 1\n0 1 1 0", "7\n8 5 7 6 1 8 9\n2 7 9 5 4 3 1\n2 3 3 4 1 1 3", "3\n1 1 1\n1 2 1\n1 1 1"]
2 seconds
["13", "44", "4"]
null
Java 7
standard input
[ "dp", "greedy" ]
99cf10673cb275ad3b90bcd3757ecd47
The first line of the input contains integer n (1 ≀ n ≀ 3000) β€” the number of hares. Then three lines follow, each line has n integers. The first line contains integers a1 a2 ... an. The second line contains b1, b2, ..., bn. The third line contains c1, c2, ..., cn. The following limits are fulfilled: 0 ≀ ai, bi, ci ≀ 1...
1,800
In a single line, print the maximum possible total joy of the hares Inna can get by feeding them.
standard output
PASSED
b3977e8d051dff0f703c90e2ca4294f6
train_001.jsonl
1382715000
Dima liked the present he got from Inna very much. He liked the present he got from Seryozha even more. Dima felt so grateful to Inna about the present that he decided to buy her n hares. Inna was very happy. She lined up the hares in a row, numbered them from 1 to n from left to right and started feeding them with car...
256 megabytes
import java.io.*; import static java.math.BigInteger.*; import static java.util.Arrays.*; import java.math.*; import java.util.*; public class Solution { public static void main(String[] args) throws Exception{ new Sol().sol(); } } class Sol { BufferedReader in; PrintWriter out; StringTokenizer st; String ne...
Java
["4\n1 2 3 4\n4 3 2 1\n0 1 1 0", "7\n8 5 7 6 1 8 9\n2 7 9 5 4 3 1\n2 3 3 4 1 1 3", "3\n1 1 1\n1 2 1\n1 1 1"]
2 seconds
["13", "44", "4"]
null
Java 7
standard input
[ "dp", "greedy" ]
99cf10673cb275ad3b90bcd3757ecd47
The first line of the input contains integer n (1 ≀ n ≀ 3000) β€” the number of hares. Then three lines follow, each line has n integers. The first line contains integers a1 a2 ... an. The second line contains b1, b2, ..., bn. The third line contains c1, c2, ..., cn. The following limits are fulfilled: 0 ≀ ai, bi, ci ≀ 1...
1,800
In a single line, print the maximum possible total joy of the hares Inna can get by feeding them.
standard output
PASSED
da7da18668432dfcdcf1f27ad50cf5f5
train_001.jsonl
1382715000
Dima liked the present he got from Inna very much. He liked the present he got from Seryozha even more. Dima felt so grateful to Inna about the present that he decided to buy her n hares. Inna was very happy. She lined up the hares in a row, numbered them from 1 to n from left to right and started feeding them with car...
256 megabytes
//package round208; 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 D3 { InputStream is; PrintWriter out; String INPUT = ""; void solve() { int n = ni(); in...
Java
["4\n1 2 3 4\n4 3 2 1\n0 1 1 0", "7\n8 5 7 6 1 8 9\n2 7 9 5 4 3 1\n2 3 3 4 1 1 3", "3\n1 1 1\n1 2 1\n1 1 1"]
2 seconds
["13", "44", "4"]
null
Java 7
standard input
[ "dp", "greedy" ]
99cf10673cb275ad3b90bcd3757ecd47
The first line of the input contains integer n (1 ≀ n ≀ 3000) β€” the number of hares. Then three lines follow, each line has n integers. The first line contains integers a1 a2 ... an. The second line contains b1, b2, ..., bn. The third line contains c1, c2, ..., cn. The following limits are fulfilled: 0 ≀ ai, bi, ci ≀ 1...
1,800
In a single line, print the maximum possible total joy of the hares Inna can get by feeding them.
standard output
PASSED
2f5052ad3745541fb5e86acc05192050
train_001.jsonl
1382715000
Dima liked the present he got from Inna very much. He liked the present he got from Seryozha even more. Dima felt so grateful to Inna about the present that he decided to buy her n hares. Inna was very happy. She lined up the hares in a row, numbered them from 1 to n from left to right and started feeding them with car...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class D { static int[] bothHung, oneHung, noHung; static int[][] dp; // pState 0 = hungry, 1=full public static int solve(int idx, int pState) { if (idx == bothHung.length - 1) { ...
Java
["4\n1 2 3 4\n4 3 2 1\n0 1 1 0", "7\n8 5 7 6 1 8 9\n2 7 9 5 4 3 1\n2 3 3 4 1 1 3", "3\n1 1 1\n1 2 1\n1 1 1"]
2 seconds
["13", "44", "4"]
null
Java 7
standard input
[ "dp", "greedy" ]
99cf10673cb275ad3b90bcd3757ecd47
The first line of the input contains integer n (1 ≀ n ≀ 3000) β€” the number of hares. Then three lines follow, each line has n integers. The first line contains integers a1 a2 ... an. The second line contains b1, b2, ..., bn. The third line contains c1, c2, ..., cn. The following limits are fulfilled: 0 ≀ ai, bi, ci ≀ 1...
1,800
In a single line, print the maximum possible total joy of the hares Inna can get by feeding them.
standard output
PASSED
53cdcb8e302b9d113be487b4311fe27d
train_001.jsonl
1382715000
Dima liked the present he got from Inna very much. He liked the present he got from Seryozha even more. Dima felt so grateful to Inna about the present that he decided to buy her n hares. Inna was very happy. She lined up the hares in a row, numbered them from 1 to n from left to right and started feeding them with car...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class D358 { static int n; static int[][] v, memo; public static void main(String[] args) { Scanner sc = new Scanner(System.in); n = sc.nextInt(); v = new int[3][n]; for (int j = 0; j < 3; j++) for ...
Java
["4\n1 2 3 4\n4 3 2 1\n0 1 1 0", "7\n8 5 7 6 1 8 9\n2 7 9 5 4 3 1\n2 3 3 4 1 1 3", "3\n1 1 1\n1 2 1\n1 1 1"]
2 seconds
["13", "44", "4"]
null
Java 7
standard input
[ "dp", "greedy" ]
99cf10673cb275ad3b90bcd3757ecd47
The first line of the input contains integer n (1 ≀ n ≀ 3000) β€” the number of hares. Then three lines follow, each line has n integers. The first line contains integers a1 a2 ... an. The second line contains b1, b2, ..., bn. The third line contains c1, c2, ..., cn. The following limits are fulfilled: 0 ≀ ai, bi, ci ≀ 1...
1,800
In a single line, print the maximum possible total joy of the hares Inna can get by feeding them.
standard output
PASSED
b7352cccc7734997204a18f43ce73f64
train_001.jsonl
1382715000
Dima liked the present he got from Inna very much. He liked the present he got from Seryozha even more. Dima felt so grateful to Inna about the present that he decided to buy her n hares. Inna was very happy. She lined up the hares in a row, numbered them from 1 to n from left to right and started feeding them with car...
256 megabytes
import java.util.Scanner; import static java.lang.Math.max; /** * @author artyom */ public class DimaAndHares { private static int n; private static int[] a, b, c; private static int[][] dp; public static void main(String args[]) { Scanner sc = new Scanner(System.in); n = sc.nextInt...
Java
["4\n1 2 3 4\n4 3 2 1\n0 1 1 0", "7\n8 5 7 6 1 8 9\n2 7 9 5 4 3 1\n2 3 3 4 1 1 3", "3\n1 1 1\n1 2 1\n1 1 1"]
2 seconds
["13", "44", "4"]
null
Java 7
standard input
[ "dp", "greedy" ]
99cf10673cb275ad3b90bcd3757ecd47
The first line of the input contains integer n (1 ≀ n ≀ 3000) β€” the number of hares. Then three lines follow, each line has n integers. The first line contains integers a1 a2 ... an. The second line contains b1, b2, ..., bn. The third line contains c1, c2, ..., cn. The following limits are fulfilled: 0 ≀ ai, bi, ci ≀ 1...
1,800
In a single line, print the maximum possible total joy of the hares Inna can get by feeding them.
standard output
PASSED
0417c111840fbdbc93cc6f4e611cf77e
train_001.jsonl
1382715000
Dima liked the present he got from Inna very much. He liked the present he got from Seryozha even more. Dima felt so grateful to Inna about the present that he decided to buy her n hares. Inna was very happy. She lined up the hares in a row, numbered them from 1 to n from left to right and started feeding them with car...
256 megabytes
import java.util.*; import java.io.*; public class Main implements Runnable { int[] a, b, c; int N; int[][] dp; public void solve() throws IOException { N = nextInt(); a = new int[N]; b = new int[N]; c = new int[N]; dp = new int[N][2]; for (int i = 0; ...
Java
["4\n1 2 3 4\n4 3 2 1\n0 1 1 0", "7\n8 5 7 6 1 8 9\n2 7 9 5 4 3 1\n2 3 3 4 1 1 3", "3\n1 1 1\n1 2 1\n1 1 1"]
2 seconds
["13", "44", "4"]
null
Java 7
standard input
[ "dp", "greedy" ]
99cf10673cb275ad3b90bcd3757ecd47
The first line of the input contains integer n (1 ≀ n ≀ 3000) β€” the number of hares. Then three lines follow, each line has n integers. The first line contains integers a1 a2 ... an. The second line contains b1, b2, ..., bn. The third line contains c1, c2, ..., cn. The following limits are fulfilled: 0 ≀ ai, bi, ci ≀ 1...
1,800
In a single line, print the maximum possible total joy of the hares Inna can get by feeding them.
standard output
PASSED
73c56720ce5d95f2494429f3dffa507e
train_001.jsonl
1382715000
Dima liked the present he got from Inna very much. He liked the present he got from Seryozha even more. Dima felt so grateful to Inna about the present that he decided to buy her n hares. Inna was very happy. She lined up the hares in a row, numbered them from 1 to n from left to right and started feeding them with car...
256 megabytes
import java.util.*; import java.io.*; public class Main implements Runnable { int[] a, b, c; int N; int[][] dp; public void solve() throws IOException { N = nextInt(); a = new int[N]; b = new int[N]; c = new int[N]; dp = new int[N][2]; for (int i = 0; ...
Java
["4\n1 2 3 4\n4 3 2 1\n0 1 1 0", "7\n8 5 7 6 1 8 9\n2 7 9 5 4 3 1\n2 3 3 4 1 1 3", "3\n1 1 1\n1 2 1\n1 1 1"]
2 seconds
["13", "44", "4"]
null
Java 7
standard input
[ "dp", "greedy" ]
99cf10673cb275ad3b90bcd3757ecd47
The first line of the input contains integer n (1 ≀ n ≀ 3000) β€” the number of hares. Then three lines follow, each line has n integers. The first line contains integers a1 a2 ... an. The second line contains b1, b2, ..., bn. The third line contains c1, c2, ..., cn. The following limits are fulfilled: 0 ≀ ai, bi, ci ≀ 1...
1,800
In a single line, print the maximum possible total joy of the hares Inna can get by feeding them.
standard output
PASSED
71cb8fbe6894435ce6ec61e00dd66c56
train_001.jsonl
1382715000
Dima liked the present he got from Inna very much. He liked the present he got from Seryozha even more. Dima felt so grateful to Inna about the present that he decided to buy her n hares. Inna was very happy. She lined up the hares in a row, numbered them from 1 to n from left to right and started feeding them with car...
256 megabytes
import java.util.Scanner; public class HappyHares { /** * @param args */ public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int m[][] = new int[n][3]; for(int i = 0; i < n; i++){ m[i][0] = in.nextInt(); } for(int i = 0; i < n; i++){ m[i][1] = i...
Java
["4\n1 2 3 4\n4 3 2 1\n0 1 1 0", "7\n8 5 7 6 1 8 9\n2 7 9 5 4 3 1\n2 3 3 4 1 1 3", "3\n1 1 1\n1 2 1\n1 1 1"]
2 seconds
["13", "44", "4"]
null
Java 7
standard input
[ "dp", "greedy" ]
99cf10673cb275ad3b90bcd3757ecd47
The first line of the input contains integer n (1 ≀ n ≀ 3000) β€” the number of hares. Then three lines follow, each line has n integers. The first line contains integers a1 a2 ... an. The second line contains b1, b2, ..., bn. The third line contains c1, c2, ..., cn. The following limits are fulfilled: 0 ≀ ai, bi, ci ≀ 1...
1,800
In a single line, print the maximum possible total joy of the hares Inna can get by feeding them.
standard output
PASSED
7e45fd409a3c6ce3153e5ea654ad41a6
train_001.jsonl
1382715000
Dima liked the present he got from Inna very much. He liked the present he got from Seryozha even more. Dima felt so grateful to Inna about the present that he decided to buy her n hares. Inna was very happy. She lined up the hares in a row, numbered them from 1 to n from left to right and started feeding them with car...
256 megabytes
/** * Created with IntelliJ IDEA. * User: flevix * Date: 25.10.13 * Time: 19:26 */ import java.io.*; import java.util.*; public class D { FastScanner in; PrintWriter out; public void solve() throws IOException { int n = in.nextInt(); int[] a = new int[n]; for (int i = 0; i <...
Java
["4\n1 2 3 4\n4 3 2 1\n0 1 1 0", "7\n8 5 7 6 1 8 9\n2 7 9 5 4 3 1\n2 3 3 4 1 1 3", "3\n1 1 1\n1 2 1\n1 1 1"]
2 seconds
["13", "44", "4"]
null
Java 7
standard input
[ "dp", "greedy" ]
99cf10673cb275ad3b90bcd3757ecd47
The first line of the input contains integer n (1 ≀ n ≀ 3000) β€” the number of hares. Then three lines follow, each line has n integers. The first line contains integers a1 a2 ... an. The second line contains b1, b2, ..., bn. The third line contains c1, c2, ..., cn. The following limits are fulfilled: 0 ≀ ai, bi, ci ≀ 1...
1,800
In a single line, print the maximum possible total joy of the hares Inna can get by feeding them.
standard output
PASSED
fb992f23ec09a1b2430291a653668f0d
train_001.jsonl
1561136700
This morning Tolik has understood that while he was sleeping he had invented an incredible problem which will be a perfect fit for Codeforces! But, as a "Discuss tasks" project hasn't been born yet (in English, well), he decides to test a problem and asks his uncle.After a long time thinking, Tolik's uncle hasn't any i...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.util.InputMismatchException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * ...
Java
["2 3", "1 1"]
1 second
["1 1\n1 3\n1 2\n2 2\n2 3\n2 1", "1 1"]
NoteThe vectors from the first example in the order of making jumps are $$$(0, 2), (0, -1), (1, 0), (0, 1), (0, -2)$$$.
Java 11
standard input
[ "constructive algorithms" ]
cc67015b9615f150aa06f7b8ed7e3152
The first and only line contains two positive integers $$$n, m$$$ ($$$1 \leq n \cdot m \leq 10^{6}$$$)Β β€” the number of rows and columns of the field respectively.
1,800
Print "-1" (without quotes) if it is impossible to visit every cell exactly once. Else print $$$n \cdot m$$$ pairs of integers, $$$i$$$-th from them should contain two integers $$$x_i, y_i$$$ ($$$1 \leq x_i \leq n, 1 \leq y_i \leq m$$$)Β β€” cells of the field in order of visiting, so that all of them are distinct and vec...
standard output
PASSED
ac96e6a32b956df7b9e9960636a0a142
train_001.jsonl
1561136700
This morning Tolik has understood that while he was sleeping he had invented an incredible problem which will be a perfect fit for Codeforces! But, as a "Discuss tasks" project hasn't been born yet (in English, well), he decides to test a problem and asks his uncle.After a long time thinking, Tolik's uncle hasn't any i...
256 megabytes
import java.util.*; import java.io.*; import java.math.BigInteger; public class Mamo { static long mod=1000000007; static Reader in=new Reader(); static List<Integer >G[]; static long a[],p[],xp[],xv[]; static StringBuilder Sd=new StringBuilder(),Sl=new StringBuilder(); public static void main...
Java
["2 3", "1 1"]
1 second
["1 1\n1 3\n1 2\n2 2\n2 3\n2 1", "1 1"]
NoteThe vectors from the first example in the order of making jumps are $$$(0, 2), (0, -1), (1, 0), (0, 1), (0, -2)$$$.
Java 11
standard input
[ "constructive algorithms" ]
cc67015b9615f150aa06f7b8ed7e3152
The first and only line contains two positive integers $$$n, m$$$ ($$$1 \leq n \cdot m \leq 10^{6}$$$)Β β€” the number of rows and columns of the field respectively.
1,800
Print "-1" (without quotes) if it is impossible to visit every cell exactly once. Else print $$$n \cdot m$$$ pairs of integers, $$$i$$$-th from them should contain two integers $$$x_i, y_i$$$ ($$$1 \leq x_i \leq n, 1 \leq y_i \leq m$$$)Β β€” cells of the field in order of visiting, so that all of them are distinct and vec...
standard output
PASSED
2a6975ba8846300c9853d59059313c25
train_001.jsonl
1452789300
Programmer Rostislav got seriously interested in the Link/Cut Tree data structure, which is based on Splay trees. Specifically, he is now studying the expose procedure.Unfortunately, Rostislav is unable to understand the definition of this procedure, so he decided to ask programmer Serezha to help him. Serezha agreed t...
256 megabytes
import java.util.*; import java.io.*; public class marcose { public static void main(String [] args)throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); long l = Long.parseLong(st.nextToken()); long r = Long.parseLong(s...
Java
["1 10 2", "2 4 5"]
2 seconds
["1 2 4 8", "-1"]
NoteNote to the first sample: numbers 20 = 1, 21 = 2, 22 = 4, 23 = 8 lie within the specified range. The number 24 = 16 is greater then 10, thus it shouldn't be printed.
Java 8
standard input
[ "implementation", "brute force" ]
8fcec28fb4d165eb58f829c03e6b31d1
The first line of the input contains three space-separated integers l, r and k (1 ≀ l ≀ r ≀ 1018, 2 ≀ k ≀ 109).
1,500
Print all powers of number k, that lie within range from l to r in the increasing order. If there are no such numbers, print "-1" (without the quotes).
standard output
PASSED
5d9129bbbe1673d4bc3099953ebf2c3e
train_001.jsonl
1452789300
Programmer Rostislav got seriously interested in the Link/Cut Tree data structure, which is based on Splay trees. Specifically, he is now studying the expose procedure.Unfortunately, Rostislav is unable to understand the definition of this procedure, so he decided to ask programmer Serezha to help him. Serezha agreed t...
256 megabytes
import java.util.Scanner; import java.math.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long r,k,l; r = sc.nextLong(); k =sc.nextLong(); l = sc.nextLong(); int p = 0; boolean T = false; p = (int) (Math.log10(k)/Math.log10(l)); ...
Java
["1 10 2", "2 4 5"]
2 seconds
["1 2 4 8", "-1"]
NoteNote to the first sample: numbers 20 = 1, 21 = 2, 22 = 4, 23 = 8 lie within the specified range. The number 24 = 16 is greater then 10, thus it shouldn't be printed.
Java 8
standard input
[ "implementation", "brute force" ]
8fcec28fb4d165eb58f829c03e6b31d1
The first line of the input contains three space-separated integers l, r and k (1 ≀ l ≀ r ≀ 1018, 2 ≀ k ≀ 109).
1,500
Print all powers of number k, that lie within range from l to r in the increasing order. If there are no such numbers, print "-1" (without the quotes).
standard output
PASSED
baf3e18264fc334b32134e555a5c8268
train_001.jsonl
1452789300
Programmer Rostislav got seriously interested in the Link/Cut Tree data structure, which is based on Splay trees. Specifically, he is now studying the expose procedure.Unfortunately, Rostislav is unable to understand the definition of this procedure, so he decided to ask programmer Serezha to help him. Serezha agreed t...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Scanner; public class A { public static void main(String[] args) throws NumberFormatException, IOException { BufferedRead...
Java
["1 10 2", "2 4 5"]
2 seconds
["1 2 4 8", "-1"]
NoteNote to the first sample: numbers 20 = 1, 21 = 2, 22 = 4, 23 = 8 lie within the specified range. The number 24 = 16 is greater then 10, thus it shouldn't be printed.
Java 8
standard input
[ "implementation", "brute force" ]
8fcec28fb4d165eb58f829c03e6b31d1
The first line of the input contains three space-separated integers l, r and k (1 ≀ l ≀ r ≀ 1018, 2 ≀ k ≀ 109).
1,500
Print all powers of number k, that lie within range from l to r in the increasing order. If there are no such numbers, print "-1" (without the quotes).
standard output
PASSED
949b202834891af90a8df7e6b59887f2
train_001.jsonl
1452789300
Programmer Rostislav got seriously interested in the Link/Cut Tree data structure, which is based on Splay trees. Specifically, he is now studying the expose procedure.Unfortunately, Rostislav is unable to understand the definition of this procedure, so he decided to ask programmer Serezha to help him. Serezha agreed t...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.Locale; public class Main { public static void main(String[] args) throws IOException { Locale.setDefault(Locale.US); Buff...
Java
["1 10 2", "2 4 5"]
2 seconds
["1 2 4 8", "-1"]
NoteNote to the first sample: numbers 20 = 1, 21 = 2, 22 = 4, 23 = 8 lie within the specified range. The number 24 = 16 is greater then 10, thus it shouldn't be printed.
Java 8
standard input
[ "implementation", "brute force" ]
8fcec28fb4d165eb58f829c03e6b31d1
The first line of the input contains three space-separated integers l, r and k (1 ≀ l ≀ r ≀ 1018, 2 ≀ k ≀ 109).
1,500
Print all powers of number k, that lie within range from l to r in the increasing order. If there are no such numbers, print "-1" (without the quotes).
standard output
PASSED
e858436c42133d5776eaf3749d0be2f8
train_001.jsonl
1452789300
Programmer Rostislav got seriously interested in the Link/Cut Tree data structure, which is based on Splay trees. Specifically, he is now studying the expose procedure.Unfortunately, Rostislav is unable to understand the definition of this procedure, so he decided to ask programmer Serezha to help him. Serezha agreed t...
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 Main { public static void main (String[] args) throws java.lang.Exception { Scanner sc = new Scanner(System.in); long ...
Java
["1 10 2", "2 4 5"]
2 seconds
["1 2 4 8", "-1"]
NoteNote to the first sample: numbers 20 = 1, 21 = 2, 22 = 4, 23 = 8 lie within the specified range. The number 24 = 16 is greater then 10, thus it shouldn't be printed.
Java 8
standard input
[ "implementation", "brute force" ]
8fcec28fb4d165eb58f829c03e6b31d1
The first line of the input contains three space-separated integers l, r and k (1 ≀ l ≀ r ≀ 1018, 2 ≀ k ≀ 109).
1,500
Print all powers of number k, that lie within range from l to r in the increasing order. If there are no such numbers, print "-1" (without the quotes).
standard output
PASSED
b5c9ebec8427af57f13d3a57ccaf98ec
train_001.jsonl
1452789300
Programmer Rostislav got seriously interested in the Link/Cut Tree data structure, which is based on Splay trees. Specifically, he is now studying the expose procedure.Unfortunately, Rostislav is unable to understand the definition of this procedure, so he decided to ask programmer Serezha to help him. Serezha agreed t...
256 megabytes
/* * Code Author: Jayesh Udhani * Dhirubhai Ambani Institute of Information and Communication Technology (DA-IICT ,Gandhinagar) * 2nd Year ICT BTECH student */ import java.io.*; import java.math.BigInteger; import java.util.*; public class Main { public static void main(String args[]) { InputReader in = new In...
Java
["1 10 2", "2 4 5"]
2 seconds
["1 2 4 8", "-1"]
NoteNote to the first sample: numbers 20 = 1, 21 = 2, 22 = 4, 23 = 8 lie within the specified range. The number 24 = 16 is greater then 10, thus it shouldn't be printed.
Java 8
standard input
[ "implementation", "brute force" ]
8fcec28fb4d165eb58f829c03e6b31d1
The first line of the input contains three space-separated integers l, r and k (1 ≀ l ≀ r ≀ 1018, 2 ≀ k ≀ 109).
1,500
Print all powers of number k, that lie within range from l to r in the increasing order. If there are no such numbers, print "-1" (without the quotes).
standard output
PASSED
6a559cecb244e3cab85f01bae950dc0f
train_001.jsonl
1452789300
Programmer Rostislav got seriously interested in the Link/Cut Tree data structure, which is based on Splay trees. Specifically, he is now studying the expose procedure.Unfortunately, Rostislav is unable to understand the definition of this procedure, so he decided to ask programmer Serezha to help him. Serezha agreed t...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class Div2_339_A { public static void main(String[] args) throws IOException { BufferedInputStream bis = new BufferedInputStream(System.in); BufferedReader br = new BufferedReader(new InputStreamReader(bis)); String line; ...
Java
["1 10 2", "2 4 5"]
2 seconds
["1 2 4 8", "-1"]
NoteNote to the first sample: numbers 20 = 1, 21 = 2, 22 = 4, 23 = 8 lie within the specified range. The number 24 = 16 is greater then 10, thus it shouldn't be printed.
Java 8
standard input
[ "implementation", "brute force" ]
8fcec28fb4d165eb58f829c03e6b31d1
The first line of the input contains three space-separated integers l, r and k (1 ≀ l ≀ r ≀ 1018, 2 ≀ k ≀ 109).
1,500
Print all powers of number k, that lie within range from l to r in the increasing order. If there are no such numbers, print "-1" (without the quotes).
standard output
PASSED
0dcfa82acb325ae1adf5f6eb05d297a7
train_001.jsonl
1452789300
Programmer Rostislav got seriously interested in the Link/Cut Tree data structure, which is based on Splay trees. Specifically, he is now studying the expose procedure.Unfortunately, Rostislav is unable to understand the definition of this procedure, so he decided to ask programmer Serezha to help him. Serezha agreed t...
256 megabytes
import java.math.*; import java.io.*; import java.util.*; public class Main{ public static void main(String[] args) { BigInteger r,bi1, bi2, bi3,bb; int n=0; Scanner in = new Scanner(System.in); bi1 = new BigInteger(in.next()); bi2 = new BigInteger(in.next()); bi3 = new BigIn...
Java
["1 10 2", "2 4 5"]
2 seconds
["1 2 4 8", "-1"]
NoteNote to the first sample: numbers 20 = 1, 21 = 2, 22 = 4, 23 = 8 lie within the specified range. The number 24 = 16 is greater then 10, thus it shouldn't be printed.
Java 8
standard input
[ "implementation", "brute force" ]
8fcec28fb4d165eb58f829c03e6b31d1
The first line of the input contains three space-separated integers l, r and k (1 ≀ l ≀ r ≀ 1018, 2 ≀ k ≀ 109).
1,500
Print all powers of number k, that lie within range from l to r in the increasing order. If there are no such numbers, print "-1" (without the quotes).
standard output
PASSED
c18af7864f12912c86dfee1643936ad8
train_001.jsonl
1452789300
Programmer Rostislav got seriously interested in the Link/Cut Tree data structure, which is based on Splay trees. Specifically, he is now studying the expose procedure.Unfortunately, Rostislav is unable to understand the definition of this procedure, so he decided to ask programmer Serezha to help him. Serezha agreed t...
256 megabytes
//package DIV2; import java.io.*; import java.math.*; import java.util.*; public class link_cut_tree { public static void main(String[] args){ Scanner sc=new Scanner(System.in); BigInteger l=sc.nextBigInteger(); BigInteger r=sc.nextBigInteger(); BigInteger k=sc.nextBigInteger(); int fnd=0; int i=0; //i=0; BigIn...
Java
["1 10 2", "2 4 5"]
2 seconds
["1 2 4 8", "-1"]
NoteNote to the first sample: numbers 20 = 1, 21 = 2, 22 = 4, 23 = 8 lie within the specified range. The number 24 = 16 is greater then 10, thus it shouldn't be printed.
Java 8
standard input
[ "implementation", "brute force" ]
8fcec28fb4d165eb58f829c03e6b31d1
The first line of the input contains three space-separated integers l, r and k (1 ≀ l ≀ r ≀ 1018, 2 ≀ k ≀ 109).
1,500
Print all powers of number k, that lie within range from l to r in the increasing order. If there are no such numbers, print "-1" (without the quotes).
standard output
PASSED
9d60fd02186d5bca76fde57c736dca8f
train_001.jsonl
1452789300
Programmer Rostislav got seriously interested in the Link/Cut Tree data structure, which is based on Splay trees. Specifically, he is now studying the expose procedure.Unfortunately, Rostislav is unable to understand the definition of this procedure, so he decided to ask programmer Serezha to help him. Serezha agreed t...
256 megabytes
import java.math.BigInteger; import java.util.Scanner; public class TreeCut { public static int numCase = 0; public static Scanner in; private static void solveProblem() { long l = in.nextLong(); long r = in.nextLong(); int k = in.nextInt(); boolean found = false; ...
Java
["1 10 2", "2 4 5"]
2 seconds
["1 2 4 8", "-1"]
NoteNote to the first sample: numbers 20 = 1, 21 = 2, 22 = 4, 23 = 8 lie within the specified range. The number 24 = 16 is greater then 10, thus it shouldn't be printed.
Java 8
standard input
[ "implementation", "brute force" ]
8fcec28fb4d165eb58f829c03e6b31d1
The first line of the input contains three space-separated integers l, r and k (1 ≀ l ≀ r ≀ 1018, 2 ≀ k ≀ 109).
1,500
Print all powers of number k, that lie within range from l to r in the increasing order. If there are no such numbers, print "-1" (without the quotes).
standard output
PASSED
253025aa22e34c648a8bb17aeb9324e8
train_001.jsonl
1452789300
Programmer Rostislav got seriously interested in the Link/Cut Tree data structure, which is based on Splay trees. Specifically, he is now studying the expose procedure.Unfortunately, Rostislav is unable to understand the definition of this procedure, so he decided to ask programmer Serezha to help him. Serezha agreed t...
256 megabytes
import java.math.BigInteger; import java.util.Scanner; public class LinkTrees { public static void main(String[] args) { Scanner scan = new Scanner(System.in); BigInteger l = scan.nextBigInteger(); BigInteger r = scan.nextBigInteger(); BigInteger k = scan.nextBigInteger(); boolean check = false; BigIntege...
Java
["1 10 2", "2 4 5"]
2 seconds
["1 2 4 8", "-1"]
NoteNote to the first sample: numbers 20 = 1, 21 = 2, 22 = 4, 23 = 8 lie within the specified range. The number 24 = 16 is greater then 10, thus it shouldn't be printed.
Java 8
standard input
[ "implementation", "brute force" ]
8fcec28fb4d165eb58f829c03e6b31d1
The first line of the input contains three space-separated integers l, r and k (1 ≀ l ≀ r ≀ 1018, 2 ≀ k ≀ 109).
1,500
Print all powers of number k, that lie within range from l to r in the increasing order. If there are no such numbers, print "-1" (without the quotes).
standard output
PASSED
56eec1ae0249d215d69a9d658db55b84
train_001.jsonl
1452789300
Programmer Rostislav got seriously interested in the Link/Cut Tree data structure, which is based on Splay trees. Specifically, he is now studying the expose procedure.Unfortunately, Rostislav is unable to understand the definition of this procedure, so he decided to ask programmer Serezha to help him. Serezha agreed t...
256 megabytes
import java.math.BigInteger; import java.util.Scanner; public class LinkcutTree { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner input = new Scanner(System.in); BigInteger l = input.nextBigInteger(); BigInteger r = input.nextBigInteger(); Big...
Java
["1 10 2", "2 4 5"]
2 seconds
["1 2 4 8", "-1"]
NoteNote to the first sample: numbers 20 = 1, 21 = 2, 22 = 4, 23 = 8 lie within the specified range. The number 24 = 16 is greater then 10, thus it shouldn't be printed.
Java 8
standard input
[ "implementation", "brute force" ]
8fcec28fb4d165eb58f829c03e6b31d1
The first line of the input contains three space-separated integers l, r and k (1 ≀ l ≀ r ≀ 1018, 2 ≀ k ≀ 109).
1,500
Print all powers of number k, that lie within range from l to r in the increasing order. If there are no such numbers, print "-1" (without the quotes).
standard output
PASSED
911af90aa3fc925cc6adefb4a77dba9e
train_001.jsonl
1452789300
Programmer Rostislav got seriously interested in the Link/Cut Tree data structure, which is based on Splay trees. Specifically, he is now studying the expose procedure.Unfortunately, Rostislav is unable to understand the definition of this procedure, so he decided to ask programmer Serezha to help him. Serezha agreed t...
256 megabytes
import java.util.Scanner; public class A614 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long l = sc.nextLong(); long r = sc.nextLong(); int k = sc.nextInt(); long n = 1; long last = 0; while (n < l && n>last) { last = n; n *= k; if (n/k != last) { Syst...
Java
["1 10 2", "2 4 5"]
2 seconds
["1 2 4 8", "-1"]
NoteNote to the first sample: numbers 20 = 1, 21 = 2, 22 = 4, 23 = 8 lie within the specified range. The number 24 = 16 is greater then 10, thus it shouldn't be printed.
Java 8
standard input
[ "implementation", "brute force" ]
8fcec28fb4d165eb58f829c03e6b31d1
The first line of the input contains three space-separated integers l, r and k (1 ≀ l ≀ r ≀ 1018, 2 ≀ k ≀ 109).
1,500
Print all powers of number k, that lie within range from l to r in the increasing order. If there are no such numbers, print "-1" (without the quotes).
standard output
PASSED
6af4129d5d5c763e77146098b128da89
train_001.jsonl
1452789300
Programmer Rostislav got seriously interested in the Link/Cut Tree data structure, which is based on Splay trees. Specifically, he is now studying the expose procedure.Unfortunately, Rostislav is unable to understand the definition of this procedure, so he decided to ask programmer Serezha to help him. Serezha agreed t...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.StringTokenizer; public class LinkCutTree { public static void main(String[] args) throws IOException { MyScanner sc ...
Java
["1 10 2", "2 4 5"]
2 seconds
["1 2 4 8", "-1"]
NoteNote to the first sample: numbers 20 = 1, 21 = 2, 22 = 4, 23 = 8 lie within the specified range. The number 24 = 16 is greater then 10, thus it shouldn't be printed.
Java 8
standard input
[ "implementation", "brute force" ]
8fcec28fb4d165eb58f829c03e6b31d1
The first line of the input contains three space-separated integers l, r and k (1 ≀ l ≀ r ≀ 1018, 2 ≀ k ≀ 109).
1,500
Print all powers of number k, that lie within range from l to r in the increasing order. If there are no such numbers, print "-1" (without the quotes).
standard output
PASSED
5c842e9f840a46a7109013d8dd659d44
train_001.jsonl
1456683000
A factory produces thimbles in bulk. Typically, it can produce up to a thimbles a day. However, some of the machinery is defective, so it can currently only produce b thimbles each day. The factory intends to choose a k-day period to do maintenance and construction; it cannot produce any thimbles during this time, but ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.StringTokenizer; /** * Created by Anna on 01.04.2016. */ public class Template { StringTokenizer st; BufferedReader in; PrintWriter out; ...
Java
["5 2 2 1 8\n1 1 2\n1 5 3\n1 2 1\n2 2\n1 4 2\n1 3 2\n2 1\n2 3", "5 4 10 1 6\n1 1 5\n1 5 5\n1 3 2\n1 5 2\n2 1\n2 2"]
4 seconds
["3\n6\n4", "7\n1"]
NoteConsider the first sample.We produce up to 1 thimble a day currently and will produce up to 2 thimbles a day after repairs. Repairs take 2 days.For the first question, we are able to fill 1 order on day 1, no orders on days 2 and 3 since we are repairing, no orders on day 4 since no thimbles have been ordered for t...
Java 8
standard input
[ "data structures" ]
d256f8cf105b08624eee21dd76a6ad3d
The first line contains five integers n, k, a, b, and q (1 ≀ k ≀ n ≀ 200 000, 1 ≀ b &lt; a ≀ 10 000, 1 ≀ q ≀ 200 000)Β β€” the number of days, the length of the repair time, the production rates of the factory, and the number of updates, respectively. The next q lines contain the descriptions of the queries. Each query is...
1,700
For each query of the second type, print a line containing a single integer β€” the maximum number of orders that the factory can fill over all n days.
standard output
PASSED
3ddefd2c284b0b1419a312c35af43986
train_001.jsonl
1456683000
A factory produces thimbles in bulk. Typically, it can produce up to a thimbles a day. However, some of the machinery is defective, so it can currently only produce b thimbles each day. The factory intends to choose a k-day period to do maintenance and construction; it cannot produce any thimbles during this time, but ...
256 megabytes
/** * Created by Anna on 14.03.2016. */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class TaskD { StringTokenizer st; PrintWriter out; BufferedReader in; public static void main(Str...
Java
["5 2 2 1 8\n1 1 2\n1 5 3\n1 2 1\n2 2\n1 4 2\n1 3 2\n2 1\n2 3", "5 4 10 1 6\n1 1 5\n1 5 5\n1 3 2\n1 5 2\n2 1\n2 2"]
4 seconds
["3\n6\n4", "7\n1"]
NoteConsider the first sample.We produce up to 1 thimble a day currently and will produce up to 2 thimbles a day after repairs. Repairs take 2 days.For the first question, we are able to fill 1 order on day 1, no orders on days 2 and 3 since we are repairing, no orders on day 4 since no thimbles have been ordered for t...
Java 8
standard input
[ "data structures" ]
d256f8cf105b08624eee21dd76a6ad3d
The first line contains five integers n, k, a, b, and q (1 ≀ k ≀ n ≀ 200 000, 1 ≀ b &lt; a ≀ 10 000, 1 ≀ q ≀ 200 000)Β β€” the number of days, the length of the repair time, the production rates of the factory, and the number of updates, respectively. The next q lines contain the descriptions of the queries. Each query is...
1,700
For each query of the second type, print a line containing a single integer β€” the maximum number of orders that the factory can fill over all n days.
standard output