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 | 8a4cabc282ae6353ec5289faa059aaeb | train_002.jsonl | 1379691000 | It is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of n distinct integers. And then they take turns to make the following moves. During each move, either Alice or Bob (the player whose turn is the current) can choose two di... | 256 megabytes | import java.util.*;
import java.util.Map.Entry;
import java.io.*;
import java.awt.Point;
import java.math.BigInteger;
import static java.lang.Math.*;
public class Codeforces_Solution_C implements Runnable{
final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
BufferedReader in;
... | Java | ["2\n2 3", "2\n5 3", "3\n5 6 7"] | 2 seconds | ["Alice", "Alice", "Bob"] | NoteConsider the first test sample. Alice moves first, and the only move she can do is to choose 2 and 3, then to add 1 to the set. Next Bob moves, there is no valid move anymore, so the winner is Alice. | Java 6 | standard input | [
"number theory",
"games",
"math"
] | 3185ae6b4b681a10a21d02e67f08fd19 | The first line contains an integer n (2 ≤ n ≤ 100) — the initial number of elements in the set. The second line contains n distinct space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the elements of the set. | 1,600 | Print a single line with the winner's name. If Alice wins print "Alice", otherwise print "Bob" (without quotes). | standard output | |
PASSED | bd4901b128d6f3be8bfeed8dce5e5a1d | train_002.jsonl | 1379691000 | It is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of n distinct integers. And then they take turns to make the following moves. During each move, either Alice or Bob (the player whose turn is the current) can choose two di... | 256 megabytes | import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class C {
public static void main(String[] args) {
C solver = new C();
solver.solve();
}
private void solve() {
Scanner sc = new Scanner(System.in);
// sc = new Scanner("2\n" +
// ... | Java | ["2\n2 3", "2\n5 3", "3\n5 6 7"] | 2 seconds | ["Alice", "Alice", "Bob"] | NoteConsider the first test sample. Alice moves first, and the only move she can do is to choose 2 and 3, then to add 1 to the set. Next Bob moves, there is no valid move anymore, so the winner is Alice. | Java 6 | standard input | [
"number theory",
"games",
"math"
] | 3185ae6b4b681a10a21d02e67f08fd19 | The first line contains an integer n (2 ≤ n ≤ 100) — the initial number of elements in the set. The second line contains n distinct space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the elements of the set. | 1,600 | Print a single line with the winner's name. If Alice wins print "Alice", otherwise print "Bob" (without quotes). | standard output | |
PASSED | 5f2d8d218a14eeb825b969084d3205c7 | train_002.jsonl | 1379691000 | It is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of n distinct integers. And then they take turns to make the following moves. During each move, either Alice or Bob (the player whose turn is the current) can choose two di... | 256 megabytes | /* @@@@@@@@@@@@@@@@@@@@@@@
* @@@ Doston Akhmedov @@@
* @@@@@@@@@@@@@@@@@@@@@@@
*/
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Loc... | Java | ["2\n2 3", "2\n5 3", "3\n5 6 7"] | 2 seconds | ["Alice", "Alice", "Bob"] | NoteConsider the first test sample. Alice moves first, and the only move she can do is to choose 2 and 3, then to add 1 to the set. Next Bob moves, there is no valid move anymore, so the winner is Alice. | Java 6 | standard input | [
"number theory",
"games",
"math"
] | 3185ae6b4b681a10a21d02e67f08fd19 | The first line contains an integer n (2 ≤ n ≤ 100) — the initial number of elements in the set. The second line contains n distinct space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the elements of the set. | 1,600 | Print a single line with the winner's name. If Alice wins print "Alice", otherwise print "Bob" (without quotes). | standard output | |
PASSED | 59946c620ecdf99b70d7473e9174175b | train_002.jsonl | 1379691000 | It is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of n distinct integers. And then they take turns to make the following moves. During each move, either Alice or Bob (the player whose turn is the current) can choose two di... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class C {
static int gcd(int a, int b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
public static void main(String[] args) throws IOException... | Java | ["2\n2 3", "2\n5 3", "3\n5 6 7"] | 2 seconds | ["Alice", "Alice", "Bob"] | NoteConsider the first test sample. Alice moves first, and the only move she can do is to choose 2 and 3, then to add 1 to the set. Next Bob moves, there is no valid move anymore, so the winner is Alice. | Java 6 | standard input | [
"number theory",
"games",
"math"
] | 3185ae6b4b681a10a21d02e67f08fd19 | The first line contains an integer n (2 ≤ n ≤ 100) — the initial number of elements in the set. The second line contains n distinct space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the elements of the set. | 1,600 | Print a single line with the winner's name. If Alice wins print "Alice", otherwise print "Bob" (without quotes). | standard output | |
PASSED | 45fc299440af84429a65cd828626a296 | train_002.jsonl | 1379691000 | It is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of n distinct integers. And then they take turns to make the following moves. During each move, either Alice or Bob (the player whose turn is the current) can choose two di... | 256 megabytes | import java.util.Scanner;
public class Contest201_div2_q3__Alice_and_Bob
{
public static void main(String ... args) throws Exception
{
// long time = System.currentTimeMillis();
Scanner in = new Scanner(System.in);
int count = in.nextInt();
int max = 0;
... | Java | ["2\n2 3", "2\n5 3", "3\n5 6 7"] | 2 seconds | ["Alice", "Alice", "Bob"] | NoteConsider the first test sample. Alice moves first, and the only move she can do is to choose 2 and 3, then to add 1 to the set. Next Bob moves, there is no valid move anymore, so the winner is Alice. | Java 6 | standard input | [
"number theory",
"games",
"math"
] | 3185ae6b4b681a10a21d02e67f08fd19 | The first line contains an integer n (2 ≤ n ≤ 100) — the initial number of elements in the set. The second line contains n distinct space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the elements of the set. | 1,600 | Print a single line with the winner's name. If Alice wins print "Alice", otherwise print "Bob" (without quotes). | standard output | |
PASSED | 1a77c927a311d19951f8987fb8d14290 | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
static BufferedReader br ;
public static void main(String[] args) throws Exception{
// write your code here
input input = new input();
int n = input.in();
int x=0;int y=0;
x++;
x--;
y++;
... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | 84d834c958abc726a434c69b6f5e43fd | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes |
import java.util.*;
import java.io.*;
//Captain on duty!
public class Main {
static void compare(Main.pair a[], int n) {
Arrays.sort(a, new Comparator<Main.pair>() {
@Override
public int compare(Main.pair p1, Main.pair p2) {
return p1.f - p2.f;
}
... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | 75ac490ecce79e66da4ed16f3778381b | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes | import java.util.*;
public class MyClass {
public static void main(String args[]) {
Scanner s = new Scanner(System.in);
int n =s.nextInt();
int map[] = new int[n];
int cnt[] = new int[n];
int [] arr = new int[n];
int [] arr1 = new int[n];
for(int i... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | 2835f6815aef37067131eee77a783dc0 | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes | import java.util.*;
public class MyClass {
public static void main(String args[]) {
Scanner s = new Scanner(System.in);
int n =s.nextInt();
int map[] = new int[n];
int cnt[] = new int[n];
int [] arr = new int[n];
int [] arr1 = new int[n];
for(int i... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | 48cfe7ca87c6a916658dfcafc0c41bb7 | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes | import java.util.Scanner;
import java.util.HashMap;
public class codeforces1365C
{
public static void main(String[] args)
{
Scanner s = new Scanner(System.in);
int n=s.nextInt(),i,x,m=1,h;
int[] a = new int[n];
int[] b = new int[n];
for(i=0;i<n;i++)
a[s.nextInt()-1]=i;
for(i=0;i<n;i++... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | 51fc55927848dd84559f5dad36fb3a87 | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes | import java.util.Scanner;
public final class RatationMatching {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int a[] = new int[n];
for (int i = 0; i < n; i++) {
a[i] = sc.nextInt();
}
int pos[] = new ... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | 5cba2fea53e00bc44cf9a8d3183e8c7c | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes |
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int[] a = new int[n];
int[] b = new int[n];
int[] pozA = new int[n + 1];
... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | dfba24b9ad405791ca235c16541ea65a | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes | import java.util.*;
import java.io.*;
public class Sol {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
int N = sc.nextInt();... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | cb68fac90492268a5ecedceb3e6dec3a | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes | import java.util.*;
import java.io.*;
public class Sol {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
int N = sc.nextInt();... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | e7ace43522a28b38d302fbeba8c51dab | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main{
static class InputReader {
private final InputStream stream;
private final byte[] buf = new byte[8192];
private int curChar, snumChars;
private SpaceCharFilter filter;
public InputReader(InputStream stream) {
... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | 116f3787b75612beb67f38cab44a568e | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes | import java.io.*;
import java.util.*;
public class Round648C {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int numIndex = sc.nextInt();
int[] original = new int[numIndex];
for (int i = 0; i < numIndex; i++) {
int tempI = sc.nextInt()-1;
... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | 839c68c6aea8dc23b959e311f2fcdf2a | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
// File file = new File("input.txt");
// Scanner in = new Scanner(file);
// PrintWriter out = new PrintWriter(new FileWriter("output.txt"));
public static void main(String[] args) {
// Scanner in = new Scanner(System.in);
... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | f479db4a947a520e59a6c2b0dea50516 | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes | import java.util.*;
import java.io.*;
public class TestClass {
public static void main(String args[]) throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
ArrayList<Integer> arr1 = new ArrayList<>(n);
ArrayList<Integer> arr2... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | 3e7441bb06e64c4934f384592e4a4a97 | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes | import java.util.*;
import java.io.*;
public class TestClass {
public static void main(String args[]) throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
ArrayList<Integer> arr1 = new ArrayList<>(n);
ArrayList<Integer> arr2... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | cd8a5adb755f9de346c5ec8ba108c095 | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes | import java.util.*;
import java.io.*;
public class rotationmatching {
public static void main(String[]args)throws Exception{
Scanner sc = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int n = sc.nextInt();
ArrayList<Integer>list1 = new ArrayList<>();
... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | ef73ace0a2c4f9a8c4456b3ea386d0ae | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes | import java.util.*;
import java.io.*;
public class C{
private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
private static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
public static void main (String[] args) throws IOException{
int n = Integer.pa... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | d3d2905125a65a4d42736c3c74a25ed3 | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes | import java.util.Scanner;
public class Problem1365c {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] a = new int[n];
int[] b = new int[n];
for(int i = 0; i < n; i++) {
int x = sc.nextInt();
a[x... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | 0e791d52ec40cc2f959e27c52a3297de | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes | import java.util.Arrays;
import java.util.Scanner;
import javax.lang.model.util.ElementScanner6;
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int ans = 0;
int[] a = new int[n+1], b = new int[n+1];
... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | 0d1ae5c270b6f80d0fbc529f2d3fb736 | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class code {
public static void main(String[] args)throws IOException {
FastReader sc = new FastReader();
PrintWriter pw = new PrintWriter(System.out);
int n = sc.ne... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | 88218ffc3ba75b35fa2d562a078c8e56 | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes | import java.io.*;
import java.util.*;
public class MyClass {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == n... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | e6b60372f8c9eb5377033ff30df60639 | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes | import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int[] arrA = new int[n];
int[] arrB = new int[n];
HashMap<Integer,Integer> hashMap = new HashMap<>();
for(int i=0;i<n;i++){... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | 7d7211d2d1b1c6def4adbb986d511d92 | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes | // package com.ganesh.CodeForces.R648Div2;
import java.util.Scanner;
public class C {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] a = new int[n];
int[] b = new int[n];
int[] posA = new int[n+1];
int[] pos... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | 7d41c130117e677b73ba89a62fa5192e | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes |
//package cf;
import java.io.*;
import java.util.*;
public class fs {
static int p=1000000007;
public static void main(String[] args) throws Exception {
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(java.io.FileDescriptor.out), "ASCII"), 512);
FastReader sc... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | 4810bb8b815619680235a439919fbc0c | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
import static java.lang.Math.*;
public class Solution implements Runnable {
static class InputReader {
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
private SpaceCharF... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | 31049b4f5ecf63faa83b598a8480e76e | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes | import java.util.*;import java.io.*;import java.math.*;
public class RotationMatching
{
public static void process()throws IOException
{
int n = ni();
int[] a = nai(n);
int[] b = nai(n);
int[] p = new int[n+1];
int[] q = new int[n+1];
ArrayList<Integer> l1 = new A... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | f83969d64001f2310470b0206af275ce | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes | import java.util.*;import java.io.*;import java.math.*;
public class RotationMatching
{
public static void process()throws IOException
{
int n = ni();
int[] a = nai(n);
int[] b = nai(n);
int[] p = new int[n+1];
int[] q = new int[n+1];
int[] dp1 = new int[n+1];
... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | 929340c15bc6720d7d27fb3f8c3f1cda | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes | import java.util.*;
public class codeforces
{
public static void main(String[] args)
{
Scanner s=new Scanner(System.in);
int n=s.nextInt();
HashMap<Integer,Integer>map=new HashMap<>();
HashMap<Integer,Integer>map2=new HashMap<>();
for(int i=0;i<n;i++)
map.put(s.nextInt(),i);
for(int i=0;i<n;... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | 91e25e50160891d3a84ff31cec6da17c | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes | import java.io.*;
import java.util.*;
import java.lang.*;
public class Codechef {
PrintWriter out;
StringTokenizer st;
BufferedReader br;
class Pair implements Comparable<Pair>
{
int f;
int s;
Pair(int t, int r) {
f = t;
s = r;
}
public int compareTo(Pair p)
... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | 298e51de64ca2c69cbdb0923a0655039 | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 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.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.PriorityQueue;
import... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | 82cfa8fd234b9ffeba909c8aedeb1ce4 | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes | public class Main {
public static void main(String[] args) {
var s = new java.util.Scanner(System.in);
int n = s.nextInt();
int[] offset = new int[n];
int[] a = new int[n];
int[] pos = new int[n];
for (int i = 0; i < n; i++) a[i] = s.nextInt();
for (i... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | 5e96f055deffb0953a05b5da385bf742 | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes | import java.util.*;
import java.io.*;
public class C{
public static void main(String[] args) {
FastScanner sc = new FastScanner();
int n = sc.nextInt();
int[] a = new int[n];
int[] b = new int[n];
int max = 1;
HashMap<Integer, Integer> pos = new HashMap<>();
... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | a7f15736f3582b9ef95288843cfc1e36 | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes | import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.io.*;
public final class Solution {
public static int cost(int[] a, int[] b,int mid) {
int cnt=0;
for(int i=0;i<a.length;i++) {
if(a[i]==b[(i+mid)%b.length]) cnt++;
}
return cnt;
}
static double PI = 3.... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | a99b55d02085892374b7f8d71fc36062 | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
public final class C {
public static void main(String[] args) {
final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
final int n = in.nextInt();
in.nextLine();
... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | 3e1731e0b08fc0cfe66c82400bd35c23 | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes | import java.io.BufferedInputStream;
import java.util.Scanner;
public class ProblemC {
public static void main(String[] args) {
Scanner input = new Scanner(new BufferedInputStream(System.in));
int n = input.nextInt();
int[] a = new int[n];
int[] b = new int[n];
for (int i = ... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | 511daede13a7bcbf831985f5cd88aebc | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes |
import java.util.Arrays;
import java.util.Scanner;
public class sdsdsds
{
static int[] shi(int ar[])
{
int n=ar.length;
int a[]=new int[n];
for(int i=0;i<n-1;i++)
{
a[i]=ar[i+1];
}
a[n-1]=ar[0];
return a;
}
public static void main(String[] args) {... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | d7bbfd40dcff81b5f7ffac0d9993785f | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
static BufferedReader br ;
public static void main(String[] args) throws Exception{
// write your code here
input input = new input();
int n = input.in();
long a[] = new long[n];
long b[] = new long[n];
... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | 0b2ec7bc8d88af7b5f0ab3e255de746a | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
static BufferedReader br ;
public static void main(String[] args) throws Exception{
// write your code here
input input = new input();
int n = input.in();
long a[] = new long[n];
long b[] = new long[n];
... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | 717e417fd9c7ca09ada8ae6bbf12c678 | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes | import java.io.*;
import java.text.*;
import java.util.*;
import java.math.*;
public class template {
public static void main(String[] args) throws Exception {
new template().run();
}
public void run() throws Exception {
FastScanner f = new FastScanner();
PrintWriter out = new... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | 2aa6fbe2a30c5bf47e9dc607f0e36575 | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes |
import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public class q1 {
public static void main(String[] args) throws IOException {
Reader.init(System.in);
int n = Reader.nextInt();
TreeMap <Int... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | 5c5ba2469096065298ef4a9bade01ca5 | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes | import java.util.Scanner;
public class B {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] a = new int[n+1], cnt = new int[n+1];
for (int i = 1; i <= n; i++) {
int tmp = sc.nextInt();
a[tmp] = i;
cnt[i] = 0;
}
int ans = 0;
for (int i = 1... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | 424f1f790a2cb7289e48c425c93ebc92 | train_002.jsonl | 1591540500 | After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers... | 256 megabytes | import java.util.*;
public class Rotation
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int N = in.nextInt();
int max1 = 0,max2=0;
int[] B = new int[N];
HashMap<Integer,Integer> A = new HashMap<Integer,Integer>();
int[]... | Java | ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"] | 1 second | ["5", "1", "2"] | NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\{1, 2, 3, 4, 5\}$$$ and $$$\{1, 2, 3, 4, 5\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For ... | Java 11 | standard input | [
"data structures",
"constructive algorithms",
"implementation",
"greedy"
] | eb1bb862dc2b0094383192f6998891c5 | The first line of the input contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \le a_i \le n)$$$ — the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$... | 1,400 | Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times. | standard output | |
PASSED | 5584284f6f912d01a50f5793a7049f1d | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.util.Scanner;
public class B_26_Regular_Bracket_Sequence {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
String s = input.nextLine().trim();
int l, res;
l = res = 0;
for(int i = 0; i < s.length(); ++i){
char ch = s.charAt(i);
if(ch == '(')
++l;
else... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | 3de0f39105b56dac05b1181a4afaf7dd | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.util.*;
public class Myon
{
public static void main(String[] args)
{
new Myon().calc();
}
void calc()
{
String s = new Scanner(System.in).nextLine();
int ret = s.length();
int now = 0;
for (char c : s.toCharArray())
{
if (c ==... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | 34c0c7279d9ee2a699c78804cacc76a5 | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.util.Scanner;
public class regular {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String b =sc.nextLine();
char[] bc = b.toCharArray();
int rb=0,lb=0;
for (int i = 0; i < b.length(); i++) {
if (bc[i]=='(')
... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | e0d1282d68e929732f2eda0920fe057f | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
/**
*
(() )
()))
*
*
* */
public class B_Div2_26 {
public static void main(String[]arg) throws IOException
{
BufferedReader in = new BufferedReader(new InputStreamReader(System.... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | 9691ece673c64a2f1985a4167cc34007 | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
/**
*
(() )
()))
*
*
* */
public class B_Div2_26 {
public static void main(String[]arg) throws IOException
{
BufferedReader in = new BufferedReader(new InputStreamReader(System.... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | de60628a8eede900f495cbfa663a6df1 | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.util.*;
import java.io.*;
public class B26 {
class InputReader {
public BufferedReader reader;
public StringTokenizer tokenizer;
public InputReader(InputStream stream) {
reader = new BufferedReader(new InputStreamReader(stream));
tokenizer = null;
}
public InputReader() throws FileNotF... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | 50903792cc69764243c92cc678b89c92 | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String cad = br.readL... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | b267d0b654c2344c4c6079ea601cbe0c | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
public class Main{
public static void main(String[] args) throws IOException {
BufferedReader b = new BufferedReader(new InputStreamReader(System.in));
String cad = b.readLine... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | ddf50b677514ae700b15544e9526209e | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes |
import java.math.*;
import java.util.*;
public class q1 {
public static void main(String args[]){
Scanner s= new Scanner(System.in);
String x= s.next();
Stack<Character> st= new Stack();
for (int i = 0; i < x.length(); i++) {
if(st.empty()){st.push(x.charAt(i));}
... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | f9860c908349ef62c7c03cf3d76bb93d | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Stack;
/*... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | e60c541b7647d8d6e0b931b67b026349 | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.util.Stack;
public class B {
public static void main(String[] args) throws Exception {
int buf;
Stack<Integer> stack = new Stack<Integer>();
int c = 0;
while ((buf = System.in.read()) > 0) {
if (buf == 40) {
stack.push(0);
} else if (buf == 41) {
if (!stack.isEmpty()) {
stack.po... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | b76c270ac896d0415fd8af84988e59d7 | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes |
import java.util.Scanner;
import java.util.Stack;
public class BrKtSeq {
static int count = 0;
static Stack<Character> stk = new Stack<Character>();
public static void main(String[] args) {
Scanner inp = new Scanner(System.in);
String seq = inp.nextLine();
for (int i = 0; i < seq... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | 3cc01900ea7b6d3085e7f9df4c821344 | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | //package main;
import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
static StringTokenizer st;
static BufferedReader scan;
static PrintWriter out;
public static void main(String[] args) throws IOException{
// Scanner scanf = new Scanner(new File("input.txt"));
//PrintStream outf = new P... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | 79ca1780126a98f445e934bd84c6a58d | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Stack;
import java.util.StringTokenizer;
public class Solution {
static InputReader in = new InputReader(System.in);
public static void main(String[] args) {
String str = in.... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | 322d62a8f05ba19eb0911769bf2f69ae | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes |
import java.util.Scanner;
public class P26B {
public P26B() {
Scanner sc = new Scanner (System.in);
String par = sc.next();
sc.close();
int balance = 0;
int ok = 0;
for (int i = 0; i < par.length(); i++){
if (par.charAt(i) == '('){
... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | 838a98abe086ba7a8f824a970bc91c6d | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes |
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Stack;
import java.util.Vector;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String bracket = sc.next();
... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | e9183741cc7cfe2b61be71992999a3f4 | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.io.*;
import java.util.*;
public class bracket{
public static int atoi(String l){ return Integer.parseInt(l);}
public static void main(String kvjnfjv[]) throws Exception{
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
String l=br.readLine();
int max=0;
System.out.println... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | 4be479161ce43edae11ae739d00a3f2a | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.io.*;
import java.util.*;
public class j
{
public static void main(String a[])throws IOException
{
Scanner b=new Scanner(System.in);
int i,n,m=0,p=0;
String s;
s=b.next();
n=s.length();
for(i=0;i<n;i++)
{
if(((int)(s.charAt(i)))==41)
{
if(m==0)
p++;
else
m--;
}
else
m++;
}
System.out.print(n-m-p);
}
} | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | dde062bff4afb084b9eb3a6bf1fdafcb | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
public static StreamTokenizer in = new StreamTokenizer(System.in);
public static boolean bg = true;
public static void main(String[] args) throws Exception {
in = null;
LR in1 = new LR();
char[] l1 = in1.nx().toCharArray();
bo... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | 02577645f07ddf5f63615b45a61a1813 | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.Stack;
public class RegularBracketSequence26B {
public static void main(String [] args){
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader flujoE = n... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | 34f2cac7161f81a23b109a7ca01998d9 | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Stack;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new Pri... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | a828294ff6993809630a78033097f526 | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.EmptyStackException;
import java.util.Stack;
/**
*
* @author Mbt
*/
public class D {
public static void main(String[] args) throws IOException {
new Solver().solve();
}
}
class Solver{
... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | 4ceeb0200846a60e245dfbdf64cccdf7 | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
public class A {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String line = "";
StringBuilder out = new St... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | 5e73cb9e36ca83ad55dd8f7c0b292f2e | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
* @author Zyflair Griffane
*/
public ... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | c824a07e14991c95bfe9b84f60f188d9 | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.Stack;
public class RegularBracketSequence {
public static void main(String[] args) throws IOException {
BufferedReader br = new B... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | 3c747aa4ec53b66674aa7a38259da055 | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
static BufferedReader reader
= new BufferedReader(new InputStreamReader(System.in));
static StringBuilder out = new StringBuilder();
public static void main(String[] args){
solve();
return;
}
// the following... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | 10a0b7315ee4c577d4606f33fdda41ff | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.util.*;
public class SS8 {
public static void main(String [] args){
Scanner in = new Scanner(System.in);
String str = in.next();
int sum=0;
int answer=0;
for(int i=0;i<str.length();i++){
if(str.charAt(i)=='(')
sum++;
if(str.charAt(i)==')')
sum--;
if(sum>=0)
... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | 5592a13e04332cac4ddec868360ed895 | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes |
import java.util.Scanner;
import java.util.Stack;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
* @author Computragy
*/
public class RegularBracketSequence {
public static void main(String[] args) {
Scanner cs1 = new Scanner(System.in);
... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | 3c0d20a1c5984c5456a084fbb4f2c70f | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.io.*;
import java.util.Stack;
import java.util.StringTokenizer;
/**
*
* @author Prateep
*/
public class JavaApplication1 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
// TODO code application logic here
In... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | 183f31b6d7bdcb34eff076e4911091eb | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.io.*;
import java.util.Stack;
import java.util.StringTokenizer;
/**
*
* @author Prateep
*/
public class JavaApplication1 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
// TODO code application logic here
In... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | 06052653f6b66bcf15d575b6eb535023 | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import java.util.Scanner;
import java.util.Stack;
/**
*
* @author Lotus
*/
public class B26 {
public static void main(String[]args)
{
Scanner input = new Scanner(System.in);
String s = input... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | 1cd602ae5ec3da8e50c8eabe52c9d759 | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String s = in.next();
int count = 0;
ArrayDeque<Character> stack = new ArrayDeque<Character>();
for (int i = 0; i < s.length(); i++) {
if(s.charAt... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | 630c8a434184fda91366985f31a9cce8 | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes |
import java.util.Scanner;
import java.util.Stack;
public class main{
public static void main(String[] args){
Scanner s=new Scanner(System.in);
Stack <Character> st =new Stack();
int c=0;
String str = s.next();
for(int ... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | ee5366e526cc9863a48ca42dc55ac90f | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.util.*;
public class RegularBracketSequence {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
Stack<Character> stack = new Stack<Character>();
String s = in.next();
int ans = 0;
for(int i = 0; i < s.length(); i ++)
{
if(!stack.isEmpty() && stack.peek() == '(' &&... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | 2b60f050c83b322e1688d210f0950af9 | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes |
import java.awt.List;
import java.util.Scanner;
/**
*
* @author mina
*/
public class B {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
char[] permutation = new char[1000000];
int start=0,finis... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | dfda884792c9124b677afcf334fb794f | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Scanner;
public class B {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
String s = in.next();
int leftCnt = 0;
int pairs = ... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | e4e02fcbb2249707ed063c153921034d | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.nio.charset.Charset;
import java.util.*;
public class Main {
public static void main(String[] args)
{
Scanner sc= new Scanner(System.in);
int cont=0;
String ent= sc.nextLine();
Stack<Integer> pila= new Stack<Integer>();
int i=0;
while(i<ent.length())
{
if(ent.charAt(i)=='(')
{... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | ea04db1eb9e580a4a871ee99ab479e59 | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes |
import java.util.Scanner;
import java.util.Stack;
/*
* @author zezo
* date : Oct 26, 2014
*/
public class RegularBracketSequence {
public static void main(String[] args) throws Exception {
Scanner scanner = new Scanner(System.in);
char array[] = scanner.next().toCharArray();
Stack<Char... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | 58e225b5d3db00ea3e1010963c53ba31 | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes |
import java.util.Scanner;
import java.util.Stack;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
Stack<String> data = new Stack<>();
String s = in.next();
data.push(s.charAt(0) + "");
int i = 1;
int count=0;
... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | 8c5b9f3c29684f9bab1ef36620a26b75 | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.*;
public class Main1 {
public static void main(String[] args) throws IOException {
BufferedReader in;
StringBuilder out = new StringBuilder();
File file = new File("in");
if (file.exists())
in = new BufferedReader(new FileReader(file));
... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | 2ec1d23481fbcdb9ab27ac98ea1735d1 | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class B26 {
public static void main(String args[]){
Scanner in = new Scanner( System .in);
String tmp = in.next();
char a[] = tmp.toCharArray();
int ans = 0;
Queue<Character> q = new Linke... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | 78ee405d0aa8f8e1cd416fc463e70c6a | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.io.*;
import java.util.*;
public class RegularBracketSequence {
public static void main(String[] args) throws IOException {
BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
String str = f.readLine();
int count = 0;
int sub = 0;
for (int i ... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | 9a518f83b40e48b4ef0bf66197611623 | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
public class RegularBracketSequence {
public static void main(String []args)throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
Stack<Cha... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | d2fc2beca0213058ff7245318df9b421 | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
public class Main{
public static void main(String[] args) throws IOException {
BufferedReader b = new BufferedReader(new InputStreamReader(System.in));
String cad = b.readLin... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | 254a5441836803c8d83abee291bbdb0e | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.util.*;
import com.sun.org.apache.xml.internal.utils.CharKey;
public class Regular {
public static void main(String[] args){
Stack<String>x = new Stack<String>();
Scanner sc = new Scanner(System.in);
String s = sc.next();
int cont = 0;
for(int i = 0; i < s.length... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | 4f7f3c0603a64525594639f14c5367d1 | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.util.Scanner;
import java.util.Stack;
public class RegularBracketSequence {
public static void main(String[] args){
int count=0;
Scanner input =new Scanner(System.in);
Stack<Character> stack=new Stack<Character>();
String s=input.next();
for(int i=0;i<s.length();i++){
if(s.charAt(i)=='(... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | 82c88c08807ad0f99446b2f62c883f10 | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.util.*;
import java.io.*;
public class Codeforces {
static boolean graph[][];
public static void main(String[] args) throws IOException {
Reader.init(System.in);
char arr[] = Reader.next().toCharArray();
int n = arr.length, count = 0, x ... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | 91160cff74b90e7e91b4cdbab84baf9c | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.util.*;
import java.io.*;
public class Codeforces {
static boolean graph[][];
public static void main(String[] args) throws IOException {
Reader.init(System.in);
// char arr[] = Reader.next().toCharArray();
String line = Reader.next();
... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | c5d88e7228b7f7f19dc9cf0f4233d12e | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.util.*;
import java.io.*;
public class Codeforces {
static boolean graph[][];
public static void main(String[] args) throws IOException {
Reader.init(System.in);
char arr[] = Reader.next().toCharArray();
int n = arr.length, count = 0;
... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | 430d38a72a4adbc4a4eb0b08d4bc9573 | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes |
import java.util.*;
/**
* Created by omar on 3/24/16.
*/
public class main {
public static void main(String[] args) {
String input = new Scanner(System.in).nextLine();
int open = 0;
int close = 0;
for(int i=0; i<input.length(); i++) {
if(input.charAt(i) == '(') {
... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | 9777e3ea7f5c9481c9af73b36fc2d70f | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes |
import java.util.Scanner;
public class RegualrBracket {
/**
* @param args
*/
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String n = scan.next();
int countL = 0;
int countR = 0;
boolean found = false;
for (int i = 0... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | d70c4a5dc187a06591fa56863a2cca6b | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.util.*;
public class BRegularBracketSequence {
private static class Stack {
private int top, capacity;
private char[] a;
Stack(int n) {
capacity = n;
top = -1;
a = new char[capacity];
}
boolean push(char ch) {
to... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | 9907f6bfe11a92b0b1bd64ed1ceadfcf | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | //package codeforces;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.StreamTokenizer;
import java.util.Scanner;
public class CodeForces {
public void run() throws IOExcepti... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output | |
PASSED | 59dbaff07d16772609cfcea8242a38ec | train_002.jsonl | 1281970800 | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not.One day Johnny got bracket sequence. He decided to remove some o... | 256 megabytes | import java.io.*;
import java.util.*;
public final class regular_br_sq
{
static Scanner sc=new Scanner(System.in);
static PrintWriter out=new PrintWriter(System.out);
public static void main(String args[]) throws Exception
{
char[] a=sc.next().toCharArray();
List<Integer> list=new ArrayList<Integer>();
int ... | Java | ["(()))(", "((()())"] | 5 seconds | ["4", "6"] | null | Java 7 | standard input | [
"greedy"
] | 2ce2d0c4ac5e630bafad2127a1b589dd | Input consists of a single line with non-empty string of «(» and «)» characters. Its length does not exceed 106. | 1,400 | Output the maximum possible length of a regular bracket sequence. | standard output |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.