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
9198a62be29a3f2b13ca1eab15cb0b82
train_002.jsonl
1590327300
Polycarp wants to buy exactly $$$n$$$ shovels. The shop sells packages with shovels. The store has $$$k$$$ types of packages: the package of the $$$i$$$-th type consists of exactly $$$i$$$ shovels ($$$1 \le i \le k$$$). The store has an infinite number of packages of each type.Polycarp wants to choose one type of packa...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner s = new Scanner(System.in); int t = s.nextInt(); while(t-- > 0){ int n = s.nextInt(); int k = s.nextInt(); if(k >= n) System.out.println(1); else{ int ans = n; int highest ...
Java
["5\n8 7\n8 1\n6 10\n999999733 999999732\n999999733 999999733"]
2 seconds
["2\n8\n1\n999999733\n1"]
NoteThe answer to the first test case was explained in the statement.In the second test case, there is only one way to buy $$$8$$$ shovels — $$$8$$$ packages of one shovel.In the third test case, you need to buy a $$$1$$$ package of $$$6$$$ shovels.
Java 8
standard input
[ "number theory", "math" ]
f00eb0452f5933103f1f77ef06473c6a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases in the input. Then, $$$t$$$ test cases follow, one per line. Each test case consists of two positive integers $$$n$$$ ($$$1 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$) — the number of shovels and the number of type...
1,300
Print $$$t$$$ answers to the test cases. Each answer is a positive integer — the minimum number of packages.
standard output
PASSED
cb43ea6277149443d138407db798be2f
train_002.jsonl
1590327300
Polycarp wants to buy exactly $$$n$$$ shovels. The shop sells packages with shovels. The store has $$$k$$$ types of packages: the package of the $$$i$$$-th type consists of exactly $$$i$$$ shovels ($$$1 \le i \le k$$$). The store has an infinite number of packages of each type.Polycarp wants to choose one type of packa...
256 megabytes
//package codeforces; //import codechef.HomeDelivery; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.LinkedList; import java.util.List; import java.util.Scanner; import java.util.StringTokenizer; public class BuyingShovels { public void printR(int a...
Java
["5\n8 7\n8 1\n6 10\n999999733 999999732\n999999733 999999733"]
2 seconds
["2\n8\n1\n999999733\n1"]
NoteThe answer to the first test case was explained in the statement.In the second test case, there is only one way to buy $$$8$$$ shovels — $$$8$$$ packages of one shovel.In the third test case, you need to buy a $$$1$$$ package of $$$6$$$ shovels.
Java 8
standard input
[ "number theory", "math" ]
f00eb0452f5933103f1f77ef06473c6a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases in the input. Then, $$$t$$$ test cases follow, one per line. Each test case consists of two positive integers $$$n$$$ ($$$1 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$) — the number of shovels and the number of type...
1,300
Print $$$t$$$ answers to the test cases. Each answer is a positive integer — the minimum number of packages.
standard output
PASSED
735cb573bed67b28679940ca9237f732
train_002.jsonl
1590327300
Polycarp wants to buy exactly $$$n$$$ shovels. The shop sells packages with shovels. The store has $$$k$$$ types of packages: the package of the $$$i$$$-th type consists of exactly $$$i$$$ shovels ($$$1 \le i \le k$$$). The store has an infinite number of packages of each type.Polycarp wants to choose one type of packa...
256 megabytes
import java.io.*; import java.util.Arrays; public class prog { public static void main(String[] args) throws IOException{ // TODO Auto-generated method stub BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(bf.readLine()); int flag=0; while(t>0) { Str...
Java
["5\n8 7\n8 1\n6 10\n999999733 999999732\n999999733 999999733"]
2 seconds
["2\n8\n1\n999999733\n1"]
NoteThe answer to the first test case was explained in the statement.In the second test case, there is only one way to buy $$$8$$$ shovels — $$$8$$$ packages of one shovel.In the third test case, you need to buy a $$$1$$$ package of $$$6$$$ shovels.
Java 8
standard input
[ "number theory", "math" ]
f00eb0452f5933103f1f77ef06473c6a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases in the input. Then, $$$t$$$ test cases follow, one per line. Each test case consists of two positive integers $$$n$$$ ($$$1 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$) — the number of shovels and the number of type...
1,300
Print $$$t$$$ answers to the test cases. Each answer is a positive integer — the minimum number of packages.
standard output
PASSED
576ff60ff9f87822dc21d430fd2d6a38
train_002.jsonl
1590327300
Polycarp wants to buy exactly $$$n$$$ shovels. The shop sells packages with shovels. The store has $$$k$$$ types of packages: the package of the $$$i$$$-th type consists of exactly $$$i$$$ shovels ($$$1 \le i \le k$$$). The store has an infinite number of packages of each type.Polycarp wants to choose one type of packa...
256 megabytes
import java.io.*; import java.util.Arrays; public class prog { public static void main(String[] args) throws IOException{ // TODO Auto-generated method stub BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(bf.readLine()); int flag=0; int index = 0; in...
Java
["5\n8 7\n8 1\n6 10\n999999733 999999732\n999999733 999999733"]
2 seconds
["2\n8\n1\n999999733\n1"]
NoteThe answer to the first test case was explained in the statement.In the second test case, there is only one way to buy $$$8$$$ shovels — $$$8$$$ packages of one shovel.In the third test case, you need to buy a $$$1$$$ package of $$$6$$$ shovels.
Java 8
standard input
[ "number theory", "math" ]
f00eb0452f5933103f1f77ef06473c6a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases in the input. Then, $$$t$$$ test cases follow, one per line. Each test case consists of two positive integers $$$n$$$ ($$$1 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$) — the number of shovels and the number of type...
1,300
Print $$$t$$$ answers to the test cases. Each answer is a positive integer — the minimum number of packages.
standard output
PASSED
9ac3d8ff99ab6e66fe54691af6a306a5
train_002.jsonl
1590327300
Polycarp wants to buy exactly $$$n$$$ shovels. The shop sells packages with shovels. The store has $$$k$$$ types of packages: the package of the $$$i$$$-th type consists of exactly $$$i$$$ shovels ($$$1 \le i \le k$$$). The store has an infinite number of packages of each type.Polycarp wants to choose one type of packa...
256 megabytes
import java.util.Scanner; public class buying_shovels_codeforces { public static void main(String args[]){ int t,n,k; Scanner sc=new Scanner(System.in); t=sc.nextInt(); for(int i=1;i<=t;i++){ n=sc.nextInt(); k=sc.nextInt(); int ans=n; ...
Java
["5\n8 7\n8 1\n6 10\n999999733 999999732\n999999733 999999733"]
2 seconds
["2\n8\n1\n999999733\n1"]
NoteThe answer to the first test case was explained in the statement.In the second test case, there is only one way to buy $$$8$$$ shovels — $$$8$$$ packages of one shovel.In the third test case, you need to buy a $$$1$$$ package of $$$6$$$ shovels.
Java 8
standard input
[ "number theory", "math" ]
f00eb0452f5933103f1f77ef06473c6a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases in the input. Then, $$$t$$$ test cases follow, one per line. Each test case consists of two positive integers $$$n$$$ ($$$1 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$) — the number of shovels and the number of type...
1,300
Print $$$t$$$ answers to the test cases. Each answer is a positive integer — the minimum number of packages.
standard output
PASSED
a8711807632ab0b27d847f7e81feeef4
train_002.jsonl
1590327300
Polycarp wants to buy exactly $$$n$$$ shovels. The shop sells packages with shovels. The store has $$$k$$$ types of packages: the package of the $$$i$$$-th type consists of exactly $$$i$$$ shovels ($$$1 \le i \le k$$$). The store has an infinite number of packages of each type.Polycarp wants to choose one type of packa...
256 megabytes
import java.util.*; public class solution{ public static long function(long n,long k){ long ans=n; if(n<=k){ return 1; }else if(n%k==0){ ans=n/k; }else{ long end=(long)Math.sqrt(n); end=Math.min(end,k); for(long i=2;i<=end;i++){ if(n%i==0 && n/i<=k) ans=Math.m...
Java
["5\n8 7\n8 1\n6 10\n999999733 999999732\n999999733 999999733"]
2 seconds
["2\n8\n1\n999999733\n1"]
NoteThe answer to the first test case was explained in the statement.In the second test case, there is only one way to buy $$$8$$$ shovels — $$$8$$$ packages of one shovel.In the third test case, you need to buy a $$$1$$$ package of $$$6$$$ shovels.
Java 8
standard input
[ "number theory", "math" ]
f00eb0452f5933103f1f77ef06473c6a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases in the input. Then, $$$t$$$ test cases follow, one per line. Each test case consists of two positive integers $$$n$$$ ($$$1 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$) — the number of shovels and the number of type...
1,300
Print $$$t$$$ answers to the test cases. Each answer is a positive integer — the minimum number of packages.
standard output
PASSED
6676132e80da2eb2f14f161c8ff9554c
train_002.jsonl
1590327300
Polycarp wants to buy exactly $$$n$$$ shovels. The shop sells packages with shovels. The store has $$$k$$$ types of packages: the package of the $$$i$$$-th type consists of exactly $$$i$$$ shovels ($$$1 \le i \le k$$$). The store has an infinite number of packages of each type.Polycarp wants to choose one type of packa...
256 megabytes
import java.io.*; import java.util.Scanner; import java.util.*; import java.lang.*; public class buyingshovels { public static void main(String[] args) throws IOException { Scanner sc=new Scanner (System.in); int t; t=sc.nextInt(); sc.nextLine(); int i; int a[]=ne...
Java
["5\n8 7\n8 1\n6 10\n999999733 999999732\n999999733 999999733"]
2 seconds
["2\n8\n1\n999999733\n1"]
NoteThe answer to the first test case was explained in the statement.In the second test case, there is only one way to buy $$$8$$$ shovels — $$$8$$$ packages of one shovel.In the third test case, you need to buy a $$$1$$$ package of $$$6$$$ shovels.
Java 8
standard input
[ "number theory", "math" ]
f00eb0452f5933103f1f77ef06473c6a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases in the input. Then, $$$t$$$ test cases follow, one per line. Each test case consists of two positive integers $$$n$$$ ($$$1 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$) — the number of shovels and the number of type...
1,300
Print $$$t$$$ answers to the test cases. Each answer is a positive integer — the minimum number of packages.
standard output
PASSED
959259d17dc3a125363ac30c4da550a5
train_002.jsonl
1590327300
Polycarp wants to buy exactly $$$n$$$ shovels. The shop sells packages with shovels. The store has $$$k$$$ types of packages: the package of the $$$i$$$-th type consists of exactly $$$i$$$ shovels ($$$1 \le i \le k$$$). The store has an infinite number of packages of each type.Polycarp wants to choose one type of packa...
256 megabytes
import java.util.Scanner; public class Buying_Shovels { public static void main(String[] args) { // TODO Auto-generated method stub Scanner scan = new Scanner(System.in); int t = scan.nextInt(); StringBuilder sb = new StringBuilder(); for(int i=0; i<t; i++) { int n = scan.nextInt(); i...
Java
["5\n8 7\n8 1\n6 10\n999999733 999999732\n999999733 999999733"]
2 seconds
["2\n8\n1\n999999733\n1"]
NoteThe answer to the first test case was explained in the statement.In the second test case, there is only one way to buy $$$8$$$ shovels — $$$8$$$ packages of one shovel.In the third test case, you need to buy a $$$1$$$ package of $$$6$$$ shovels.
Java 8
standard input
[ "number theory", "math" ]
f00eb0452f5933103f1f77ef06473c6a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases in the input. Then, $$$t$$$ test cases follow, one per line. Each test case consists of two positive integers $$$n$$$ ($$$1 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$) — the number of shovels and the number of type...
1,300
Print $$$t$$$ answers to the test cases. Each answer is a positive integer — the minimum number of packages.
standard output
PASSED
e68f6750f5c659200ecb7a87a01d384a
train_002.jsonl
1590327300
Polycarp wants to buy exactly $$$n$$$ shovels. The shop sells packages with shovels. The store has $$$k$$$ types of packages: the package of the $$$i$$$-th type consists of exactly $$$i$$$ shovels ($$$1 \le i \le k$$$). The store has an infinite number of packages of each type.Polycarp wants to choose one type of packa...
256 megabytes
import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; import java.util.Queue; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.Random; import java.io.FileWriter; import j...
Java
["5\n8 7\n8 1\n6 10\n999999733 999999732\n999999733 999999733"]
2 seconds
["2\n8\n1\n999999733\n1"]
NoteThe answer to the first test case was explained in the statement.In the second test case, there is only one way to buy $$$8$$$ shovels — $$$8$$$ packages of one shovel.In the third test case, you need to buy a $$$1$$$ package of $$$6$$$ shovels.
Java 8
standard input
[ "number theory", "math" ]
f00eb0452f5933103f1f77ef06473c6a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases in the input. Then, $$$t$$$ test cases follow, one per line. Each test case consists of two positive integers $$$n$$$ ($$$1 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$) — the number of shovels and the number of type...
1,300
Print $$$t$$$ answers to the test cases. Each answer is a positive integer — the minimum number of packages.
standard output
PASSED
95fe82533783aec2f86ac0fc827a1e2a
train_002.jsonl
1590327300
Polycarp wants to buy exactly $$$n$$$ shovels. The shop sells packages with shovels. The store has $$$k$$$ types of packages: the package of the $$$i$$$-th type consists of exactly $$$i$$$ shovels ($$$1 \le i \le k$$$). The store has an infinite number of packages of each type.Polycarp wants to choose one type of packa...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { private static void solve(BufferedReader in) throws IOException { int n, k, ans; String[] tokens = in.readLine().split(" "); n = Integer.parseInt((tokens[0])); k = Integer.parseInt((tokens[1])); ...
Java
["5\n8 7\n8 1\n6 10\n999999733 999999732\n999999733 999999733"]
2 seconds
["2\n8\n1\n999999733\n1"]
NoteThe answer to the first test case was explained in the statement.In the second test case, there is only one way to buy $$$8$$$ shovels — $$$8$$$ packages of one shovel.In the third test case, you need to buy a $$$1$$$ package of $$$6$$$ shovels.
Java 8
standard input
[ "number theory", "math" ]
f00eb0452f5933103f1f77ef06473c6a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases in the input. Then, $$$t$$$ test cases follow, one per line. Each test case consists of two positive integers $$$n$$$ ($$$1 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$) — the number of shovels and the number of type...
1,300
Print $$$t$$$ answers to the test cases. Each answer is a positive integer — the minimum number of packages.
standard output
PASSED
2e7e6bae22f83b6178ce7039543b3788
train_002.jsonl
1590327300
Polycarp wants to buy exactly $$$n$$$ shovels. The shop sells packages with shovels. The store has $$$k$$$ types of packages: the package of the $$$i$$$-th type consists of exactly $$$i$$$ shovels ($$$1 \le i \le k$$$). The store has an infinite number of packages of each type.Polycarp wants to choose one type of packa...
256 megabytes
import java.util.*; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-- > 0){ int n = sc.nextInt(); int k = sc.nextInt(); int ans = n; for(int j = 1; j*j <= n; j++){ ...
Java
["5\n8 7\n8 1\n6 10\n999999733 999999732\n999999733 999999733"]
2 seconds
["2\n8\n1\n999999733\n1"]
NoteThe answer to the first test case was explained in the statement.In the second test case, there is only one way to buy $$$8$$$ shovels — $$$8$$$ packages of one shovel.In the third test case, you need to buy a $$$1$$$ package of $$$6$$$ shovels.
Java 8
standard input
[ "number theory", "math" ]
f00eb0452f5933103f1f77ef06473c6a
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases in the input. Then, $$$t$$$ test cases follow, one per line. Each test case consists of two positive integers $$$n$$$ ($$$1 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$) — the number of shovels and the number of type...
1,300
Print $$$t$$$ answers to the test cases. Each answer is a positive integer — the minimum number of packages.
standard output
PASSED
e0594f505daae60fa9ca8ab4d5cb892b
train_002.jsonl
1439483400
Peppa the Pig was walking and walked into the forest. What a strange coincidence! The forest has the shape of a rectangle, consisting of n rows and m columns. We enumerate the rows of the rectangle from top to bottom with numbers from 1 to n, and the columns — from left to right with numbers from 1 to m. Let's denote t...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Java
["3 4\naaab\nbaaa\nabba"]
4 seconds
["3"]
NotePicture illustrating possibilities for the sample test.
Java 8
standard input
[ "dp", "combinatorics" ]
07fb2247b4b4ee5d3592fda21b814c7c
The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the height and width of the field. Each of the following n lines contains m lowercase English letters identifying the types of cells of the forest. Identical cells are represented by identical letters, different cells are represented by different letters.
2,300
Print a single integer — the number of beautiful paths modulo 109 + 7.
standard output
PASSED
6aa8262e8a99985a0bea3355e034b7f9
train_002.jsonl
1439483400
Peppa the Pig was walking and walked into the forest. What a strange coincidence! The forest has the shape of a rectangle, consisting of n rows and m columns. We enumerate the rows of the rectangle from top to bottom with numbers from 1 to n, and the columns — from left to right with numbers from 1 to m. Let's denote t...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; public class CF_316_E { private static int n, m; private static final long MOD = 1000000007; private static char[][] map; private static long[][][] DP; ...
Java
["3 4\naaab\nbaaa\nabba"]
4 seconds
["3"]
NotePicture illustrating possibilities for the sample test.
Java 8
standard input
[ "dp", "combinatorics" ]
07fb2247b4b4ee5d3592fda21b814c7c
The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the height and width of the field. Each of the following n lines contains m lowercase English letters identifying the types of cells of the forest. Identical cells are represented by identical letters, different cells are represented by different letters.
2,300
Print a single integer — the number of beautiful paths modulo 109 + 7.
standard output
PASSED
0601a009e982ae6b4a9e69b5dbaa095c
train_002.jsonl
1439483400
Peppa the Pig was walking and walked into the forest. What a strange coincidence! The forest has the shape of a rectangle, consisting of n rows and m columns. We enumerate the rows of the rectangle from top to bottom with numbers from 1 to n, and the columns — from left to right with numbers from 1 to m. Let's denote t...
256 megabytes
import java.io.*; import java.util.*; public class Main{ static void main() throws Exception{ int n=sc.nextInt(),m=sc.nextInt(); char[][]in=new char[n][m]; for(int i=0;i<n;i++)in[i]=sc.nextLine().toCharArray(); int mod=(int)1e9+7; int pathLen=n+m-1; ArrayList<int[]>[]dist=new ArrayList[n+m]; for(int i=0...
Java
["3 4\naaab\nbaaa\nabba"]
4 seconds
["3"]
NotePicture illustrating possibilities for the sample test.
Java 8
standard input
[ "dp", "combinatorics" ]
07fb2247b4b4ee5d3592fda21b814c7c
The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the height and width of the field. Each of the following n lines contains m lowercase English letters identifying the types of cells of the forest. Identical cells are represented by identical letters, different cells are represented by different letters.
2,300
Print a single integer — the number of beautiful paths modulo 109 + 7.
standard output
PASSED
c9f97c9d4e12f495430a53dd5af9d268
train_002.jsonl
1439483400
Peppa the Pig was walking and walked into the forest. What a strange coincidence! The forest has the shape of a rectangle, consisting of n rows and m columns. We enumerate the rows of the rectangle from top to bottom with numbers from 1 to n, and the columns — from left to right with numbers from 1 to m. Let's denote t...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.*; public class R316qE { public static void main(String args[]) { InputReader in = new InputReader(System.in); PrintWriter w = new PrintWriter(System.out); int n = in.nextInt(); int m = in.nextInt(); c...
Java
["3 4\naaab\nbaaa\nabba"]
4 seconds
["3"]
NotePicture illustrating possibilities for the sample test.
Java 8
standard input
[ "dp", "combinatorics" ]
07fb2247b4b4ee5d3592fda21b814c7c
The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the height and width of the field. Each of the following n lines contains m lowercase English letters identifying the types of cells of the forest. Identical cells are represented by identical letters, different cells are represented by different letters.
2,300
Print a single integer — the number of beautiful paths modulo 109 + 7.
standard output
PASSED
c41876bdf31d087de8ed31054b79f018
train_002.jsonl
1439483400
Peppa the Pig was walking and walked into the forest. What a strange coincidence! The forest has the shape of a rectangle, consisting of n rows and m columns. We enumerate the rows of the rectangle from top to bottom with numbers from 1 to n, and the columns — from left to right with numbers from 1 to m. Let's denote t...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.text.*; public class Main { //private static long startTime = System.currentTimeMillis(); static int n,m,mod=1000000007,diag_one_start,diag_two_start,diag_one_x,diag_one_y,diag_two_x,diag_two_y,offset1=1000000,offset2=1000; static int[][] grid; stat...
Java
["3 4\naaab\nbaaa\nabba"]
4 seconds
["3"]
NotePicture illustrating possibilities for the sample test.
Java 8
standard input
[ "dp", "combinatorics" ]
07fb2247b4b4ee5d3592fda21b814c7c
The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the height and width of the field. Each of the following n lines contains m lowercase English letters identifying the types of cells of the forest. Identical cells are represented by identical letters, different cells are represented by different letters.
2,300
Print a single integer — the number of beautiful paths modulo 109 + 7.
standard output
PASSED
28fca778d046413dc015baa9a217e433
train_002.jsonl
1439483400
Peppa the Pig was walking and walked into the forest. What a strange coincidence! The forest has the shape of a rectangle, consisting of n rows and m columns. We enumerate the rows of the rectangle from top to bottom with numbers from 1 to n, and the columns — from left to right with numbers from 1 to m. Let's denote t...
256 megabytes
import java.util.*; import java.io.*; public class PigPalindrome { static int [][][] dp = new int [2][510][510]; static char [][] a = new char [510][510]; static int mod = 1000000007; public static void main (String[] args) { Reader in = new Reader (); int n = in.nextInt(); int m = in.nextInt(); for(int ...
Java
["3 4\naaab\nbaaa\nabba"]
4 seconds
["3"]
NotePicture illustrating possibilities for the sample test.
Java 8
standard input
[ "dp", "combinatorics" ]
07fb2247b4b4ee5d3592fda21b814c7c
The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the height and width of the field. Each of the following n lines contains m lowercase English letters identifying the types of cells of the forest. Identical cells are represented by identical letters, different cells are represented by different letters.
2,300
Print a single integer — the number of beautiful paths modulo 109 + 7.
standard output
PASSED
afb808a7e225384267efb987f80a2a30
train_002.jsonl
1439483400
Peppa the Pig was walking and walked into the forest. What a strange coincidence! The forest has the shape of a rectangle, consisting of n rows and m columns. We enumerate the rows of the rectangle from top to bottom with numbers from 1 to n, and the columns — from left to right with numbers from 1 to m. Let's denote t...
256 megabytes
import java.io.PrintWriter; import java.util.Arrays; import java.util.Scanner; /** * Created by ringod on 10/21/15. */ public class Task { public static void main(String[] args) { Scanner sc = new Scanner(System.in); PrintWriter pr = new PrintWriter(System.out); Dp solver = new Dp(); ...
Java
["3 4\naaab\nbaaa\nabba"]
4 seconds
["3"]
NotePicture illustrating possibilities for the sample test.
Java 8
standard input
[ "dp", "combinatorics" ]
07fb2247b4b4ee5d3592fda21b814c7c
The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the height and width of the field. Each of the following n lines contains m lowercase English letters identifying the types of cells of the forest. Identical cells are represented by identical letters, different cells are represented by different letters.
2,300
Print a single integer — the number of beautiful paths modulo 109 + 7.
standard output
PASSED
fe4f35713ace827ff27805e0dde44744
train_002.jsonl
1439483400
Peppa the Pig was walking and walked into the forest. What a strange coincidence! The forest has the shape of a rectangle, consisting of n rows and m columns. We enumerate the rows of the rectangle from top to bottom with numbers from 1 to n, and the columns — from left to right with numbers from 1 to m. Let's denote t...
256 megabytes
import java.util.*; import java.io.*; public class CF570E { static final int MOD = (int) 1e9 + 7; static int[] d1 = {1, 0, 1, 0}; static int[] d2 = {0, 1, 0, 1}; static int[] d3 = {-1, -1, 0, 0}; static int[] d4 = {0, 0, -1, -1}; static int r, c, halfLength; static char[][] grid; public static void main(String...
Java
["3 4\naaab\nbaaa\nabba"]
4 seconds
["3"]
NotePicture illustrating possibilities for the sample test.
Java 8
standard input
[ "dp", "combinatorics" ]
07fb2247b4b4ee5d3592fda21b814c7c
The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the height and width of the field. Each of the following n lines contains m lowercase English letters identifying the types of cells of the forest. Identical cells are represented by identical letters, different cells are represented by different letters.
2,300
Print a single integer — the number of beautiful paths modulo 109 + 7.
standard output
PASSED
b27274950272ac57c84af78e69e6edbf
train_002.jsonl
1439483400
Peppa the Pig was walking and walked into the forest. What a strange coincidence! The forest has the shape of a rectangle, consisting of n rows and m columns. We enumerate the rows of the rectangle from top to bottom with numbers from 1 to n, and the columns — from left to right with numbers from 1 to m. Let's denote t...
256 megabytes
import java.util.*; import java.io.*; public class R316D2_E { public static PrintWriter outWriter; public static MyScanner sc; public static Long MOD = 1000000007L; public static void main(String[] args) { sc = new MyScanner(); outWriter = new PrintWriter(new BufferedOutputStream(Syst...
Java
["3 4\naaab\nbaaa\nabba"]
4 seconds
["3"]
NotePicture illustrating possibilities for the sample test.
Java 8
standard input
[ "dp", "combinatorics" ]
07fb2247b4b4ee5d3592fda21b814c7c
The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the height and width of the field. Each of the following n lines contains m lowercase English letters identifying the types of cells of the forest. Identical cells are represented by identical letters, different cells are represented by different letters.
2,300
Print a single integer — the number of beautiful paths modulo 109 + 7.
standard output
PASSED
93ed115777a5c28a668b5e73cfdba625
train_002.jsonl
1439483400
Peppa the Pig was walking and walked into the forest. What a strange coincidence! The forest has the shape of a rectangle, consisting of n rows and m columns. We enumerate the rows of the rectangle from top to bottom with numbers from 1 to n, and the columns — from left to right with numbers from 1 to m. Let's denote t...
256 megabytes
import java.util.*; import java.io.*; public class R316D2_E { public static PrintWriter outWriter; public static MyScanner sc; public static Long MOD = 1000000007L; public static void main(String[] args) { sc = new MyScanner(); outWriter = new PrintWriter(new BufferedOutputStream(Syst...
Java
["3 4\naaab\nbaaa\nabba"]
4 seconds
["3"]
NotePicture illustrating possibilities for the sample test.
Java 8
standard input
[ "dp", "combinatorics" ]
07fb2247b4b4ee5d3592fda21b814c7c
The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the height and width of the field. Each of the following n lines contains m lowercase English letters identifying the types of cells of the forest. Identical cells are represented by identical letters, different cells are represented by different letters.
2,300
Print a single integer — the number of beautiful paths modulo 109 + 7.
standard output
PASSED
0b51fd3ec7b48aab706a6708a89f4ff8
train_002.jsonl
1439483400
Peppa the Pig was walking and walked into the forest. What a strange coincidence! The forest has the shape of a rectangle, consisting of n rows and m columns. We enumerate the rows of the rectangle from top to bottom with numbers from 1 to n, and the columns — from left to right with numbers from 1 to m. Let's denote t...
256 megabytes
//package codeforcesround316; import java.io.*; import java.util.*; public class pigandpalindrome { public static void main(String[] args) throws Exception { //BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); //PrintWriter pw=new PrintWriter(System.out); //StringTo...
Java
["3 4\naaab\nbaaa\nabba"]
4 seconds
["3"]
NotePicture illustrating possibilities for the sample test.
Java 8
standard input
[ "dp", "combinatorics" ]
07fb2247b4b4ee5d3592fda21b814c7c
The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the height and width of the field. Each of the following n lines contains m lowercase English letters identifying the types of cells of the forest. Identical cells are represented by identical letters, different cells are represented by different letters.
2,300
Print a single integer — the number of beautiful paths modulo 109 + 7.
standard output
PASSED
eac09403ab9967c7c77ba685de556a54
train_002.jsonl
1439483400
Peppa the Pig was walking and walked into the forest. What a strange coincidence! The forest has the shape of a rectangle, consisting of n rows and m columns. We enumerate the rows of the rectangle from top to bottom with numbers from 1 to n, and the columns — from left to right with numbers from 1 to m. Let's denote t...
256 megabytes
//package codeforcesround316; import java.io.*; import java.util.*; public class pigandpalindrome { public static void main(String[] args) throws Exception { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw=new PrintWriter(System.out); StringTokenize...
Java
["3 4\naaab\nbaaa\nabba"]
4 seconds
["3"]
NotePicture illustrating possibilities for the sample test.
Java 8
standard input
[ "dp", "combinatorics" ]
07fb2247b4b4ee5d3592fda21b814c7c
The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the height and width of the field. Each of the following n lines contains m lowercase English letters identifying the types of cells of the forest. Identical cells are represented by identical letters, different cells are represented by different letters.
2,300
Print a single integer — the number of beautiful paths modulo 109 + 7.
standard output
PASSED
c0bfd821619b1dfa10bce9f20233d144
train_002.jsonl
1439483400
Peppa the Pig was walking and walked into the forest. What a strange coincidence! The forest has the shape of a rectangle, consisting of n rows and m columns. We enumerate the rows of the rectangle from top to bottom with numbers from 1 to n, and the columns — from left to right with numbers from 1 to m. Let's denote t...
256 megabytes
/** * Created by Aminul on 11/21/2018. */ import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.lang.reflect.Array; import java.util.Arrays; import java.util.InputMismatchException; public class CF570E_3 { public static void main(String[] args)throws Exception { ...
Java
["3 4\naaab\nbaaa\nabba"]
4 seconds
["3"]
NotePicture illustrating possibilities for the sample test.
Java 8
standard input
[ "dp", "combinatorics" ]
07fb2247b4b4ee5d3592fda21b814c7c
The first line contains two integers n, m (1 ≤ n, m ≤ 500) — the height and width of the field. Each of the following n lines contains m lowercase English letters identifying the types of cells of the forest. Identical cells are represented by identical letters, different cells are represented by different letters.
2,300
Print a single integer — the number of beautiful paths modulo 109 + 7.
standard output
PASSED
b9ca58456edb361cb19246892f7d5f9f
train_002.jsonl
1361719800
A little girl loves problems on trees very much. Here's one of them.A tree is an undirected connected graph, not containing cycles. The degree of node x in the tree is the number of nodes y of the tree, such that each of them is connected with node x by some edge of the tree. Let's consider a tree that consists of n no...
256 megabytes
import java.io.*; import java.util.*; public class Main{ static public class SegmentTree { // 1-based DS, OOP int N; int[] array, lazy; SegmentTree(int n) { N=n; array = new int[N+1]; lazy = new int[N<<2]; } void update_range(int i, int j, int val) // O(log n) { update_range(1,...
Java
["3 6\n1 2\n1 3\n0 3 1 2\n0 2 3 1\n0 1 5 2\n1 1\n1 2\n1 3", "6 11\n1 2\n2 5\n5 4\n1 6\n1 3\n0 3 1 3\n0 3 4 5\n0 2 1 4\n0 1 5 5\n0 4 6 2\n1 1\n1 2\n1 3\n1 4\n1 5\n1 6"]
2 seconds
["9\n9\n6", "11\n17\n11\n16\n17\n11"]
null
Java 11
standard input
[ "data structures", "trees", "graphs" ]
2399ea65e035a8bcd082342b9a6cc89d
The first line contains integers n (2 ≤ n ≤ 105) and q (1 ≤ q ≤ 105) — the number of tree nodes and the number of requests, correspondingly. Each of the next n  -  1 lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi), that show that there is an edge between nodes ui and vi. Each edge's description occurs i...
2,100
For each request to print the node value print an integer — the reply to the request.
standard output
PASSED
cf0bf86e7b69cf3520bd8cf413742304
train_002.jsonl
1432053000
Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately started imagining the choppers cutting wood. She imagined the situation that is described below.There are n trees located along the road at points with coordinates x1, x2, ..., xn. Each tr...
256 megabytes
import java.util.*; import java.io.*; import java.lang.*; import java.lang.reflect.Array; import java.math.*; import java.nio.file.Path; import java.util.stream.Collectors; import javafx.util.Pair; import javax.xml.transform.OutputKeys; import javax.xml.transform.Source; public class JavaApplication1 { static Bu...
Java
["5\n1 2\n2 1\n5 10\n10 9\n19 1", "5\n1 2\n2 1\n5 10\n10 9\n20 1"]
1 second
["3", "4"]
NoteIn the first sample you can fell the trees like that: fell the 1-st tree to the left — now it occupies segment [ - 1;1] fell the 2-nd tree to the right — now it occupies segment [2;3] leave the 3-rd tree — it occupies point 5 leave the 4-th tree — it occupies point 10 fell the 5-th tree to the right — now it ...
Java 8
standard input
[ "dp", "greedy" ]
a850dd88a67a6295823e70e2c5c857c9
The first line contains integer n (1 ≤ n ≤ 105) — the number of trees. Next n lines contain pairs of integers xi, hi (1 ≤ xi, hi ≤ 109) — the coordinate and the height of the і-th tree. The pairs are given in the order of ascending xi. No two trees are located at the point with the same coordinate.
1,500
Print a single number — the maximum number of trees that you can cut down by the given rules.
standard output
PASSED
d0553bff3fb59cf0bf5e5b0247fa590f
train_002.jsonl
1432053000
Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately started imagining the choppers cutting wood. She imagined the situation that is described below.There are n trees located along the road at points with coordinates x1, x2, ..., xn. Each tr...
256 megabytes
//package DynamicProgramming; import java.util.Scanner; public class M545C { public static Scanner enter = new Scanner(System.in); public static void main(String[] args) { int n=enter.nextInt(); long lastpoint=Integer.MIN_VALUE; int kolvo=0; int wanted=0; long lastmb=In...
Java
["5\n1 2\n2 1\n5 10\n10 9\n19 1", "5\n1 2\n2 1\n5 10\n10 9\n20 1"]
1 second
["3", "4"]
NoteIn the first sample you can fell the trees like that: fell the 1-st tree to the left — now it occupies segment [ - 1;1] fell the 2-nd tree to the right — now it occupies segment [2;3] leave the 3-rd tree — it occupies point 5 leave the 4-th tree — it occupies point 10 fell the 5-th tree to the right — now it ...
Java 8
standard input
[ "dp", "greedy" ]
a850dd88a67a6295823e70e2c5c857c9
The first line contains integer n (1 ≤ n ≤ 105) — the number of trees. Next n lines contain pairs of integers xi, hi (1 ≤ xi, hi ≤ 109) — the coordinate and the height of the і-th tree. The pairs are given in the order of ascending xi. No two trees are located at the point with the same coordinate.
1,500
Print a single number — the maximum number of trees that you can cut down by the given rules.
standard output
PASSED
a85562e76f10b01101d807278a075460
train_002.jsonl
1432053000
Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately started imagining the choppers cutting wood. She imagined the situation that is described below.There are n trees located along the road at points with coordinates x1, x2, ..., xn. Each tr...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class Main { static final long MOD = 1000000007L; static final int INF = 50000000; public static void main(String[] args) { FastScanner sc = new FastScanner(); PrintWriter pw = new PrintWriter(System.out); int N = sc.ni(); int[][] nums = ...
Java
["5\n1 2\n2 1\n5 10\n10 9\n19 1", "5\n1 2\n2 1\n5 10\n10 9\n20 1"]
1 second
["3", "4"]
NoteIn the first sample you can fell the trees like that: fell the 1-st tree to the left — now it occupies segment [ - 1;1] fell the 2-nd tree to the right — now it occupies segment [2;3] leave the 3-rd tree — it occupies point 5 leave the 4-th tree — it occupies point 10 fell the 5-th tree to the right — now it ...
Java 8
standard input
[ "dp", "greedy" ]
a850dd88a67a6295823e70e2c5c857c9
The first line contains integer n (1 ≤ n ≤ 105) — the number of trees. Next n lines contain pairs of integers xi, hi (1 ≤ xi, hi ≤ 109) — the coordinate and the height of the і-th tree. The pairs are given in the order of ascending xi. No two trees are located at the point with the same coordinate.
1,500
Print a single number — the maximum number of trees that you can cut down by the given rules.
standard output
PASSED
ba5dbbe229ef4b57a77f4b083dc18e69
train_002.jsonl
1432053000
Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately started imagining the choppers cutting wood. She imagined the situation that is described below.There are n trees located along the road at points with coordinates x1, x2, ..., xn. Each tr...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int numTrees = scan.nextInt(); int totalFell = 0; long thisCoord = scan.nextInt(); long thisHeight = scan.nextInt(); long lastRightMost = 0; boolean isFirst = true; for (int ...
Java
["5\n1 2\n2 1\n5 10\n10 9\n19 1", "5\n1 2\n2 1\n5 10\n10 9\n20 1"]
1 second
["3", "4"]
NoteIn the first sample you can fell the trees like that: fell the 1-st tree to the left — now it occupies segment [ - 1;1] fell the 2-nd tree to the right — now it occupies segment [2;3] leave the 3-rd tree — it occupies point 5 leave the 4-th tree — it occupies point 10 fell the 5-th tree to the right — now it ...
Java 8
standard input
[ "dp", "greedy" ]
a850dd88a67a6295823e70e2c5c857c9
The first line contains integer n (1 ≤ n ≤ 105) — the number of trees. Next n lines contain pairs of integers xi, hi (1 ≤ xi, hi ≤ 109) — the coordinate and the height of the і-th tree. The pairs are given in the order of ascending xi. No two trees are located at the point with the same coordinate.
1,500
Print a single number — the maximum number of trees that you can cut down by the given rules.
standard output
PASSED
7feb216aabea5518c4ac24cbd8bfb005
train_002.jsonl
1432053000
Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately started imagining the choppers cutting wood. She imagined the situation that is described below.There are n trees located along the road at points with coordinates x1, x2, ..., xn. Each tr...
256 megabytes
import java.util.Scanner; /** * Created by Kunaal on 10/21/17. */ public class Woodcutters { public static class Tree { int position; int height; Tree(int p, int h) { position = p; height = h; } } public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextI...
Java
["5\n1 2\n2 1\n5 10\n10 9\n19 1", "5\n1 2\n2 1\n5 10\n10 9\n20 1"]
1 second
["3", "4"]
NoteIn the first sample you can fell the trees like that: fell the 1-st tree to the left — now it occupies segment [ - 1;1] fell the 2-nd tree to the right — now it occupies segment [2;3] leave the 3-rd tree — it occupies point 5 leave the 4-th tree — it occupies point 10 fell the 5-th tree to the right — now it ...
Java 8
standard input
[ "dp", "greedy" ]
a850dd88a67a6295823e70e2c5c857c9
The first line contains integer n (1 ≤ n ≤ 105) — the number of trees. Next n lines contain pairs of integers xi, hi (1 ≤ xi, hi ≤ 109) — the coordinate and the height of the і-th tree. The pairs are given in the order of ascending xi. No two trees are located at the point with the same coordinate.
1,500
Print a single number — the maximum number of trees that you can cut down by the given rules.
standard output
PASSED
2e84b4bfcfdeb7e01d1c9051fda77fbf
train_002.jsonl
1432053000
Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately started imagining the choppers cutting wood. She imagined the situation that is described below.There are n trees located along the road at points with coordinates x1, x2, ..., xn. Each tr...
256 megabytes
import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.InputStream; import java.util.NoSuchElementException; import java.io.OutputStreamWriter; import java.math.BigInteger; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.io.IOException; /** *...
Java
["5\n1 2\n2 1\n5 10\n10 9\n19 1", "5\n1 2\n2 1\n5 10\n10 9\n20 1"]
1 second
["3", "4"]
NoteIn the first sample you can fell the trees like that: fell the 1-st tree to the left — now it occupies segment [ - 1;1] fell the 2-nd tree to the right — now it occupies segment [2;3] leave the 3-rd tree — it occupies point 5 leave the 4-th tree — it occupies point 10 fell the 5-th tree to the right — now it ...
Java 8
standard input
[ "dp", "greedy" ]
a850dd88a67a6295823e70e2c5c857c9
The first line contains integer n (1 ≤ n ≤ 105) — the number of trees. Next n lines contain pairs of integers xi, hi (1 ≤ xi, hi ≤ 109) — the coordinate and the height of the і-th tree. The pairs are given in the order of ascending xi. No two trees are located at the point with the same coordinate.
1,500
Print a single number — the maximum number of trees that you can cut down by the given rules.
standard output
PASSED
cb0616301371740604227d25275215a0
train_002.jsonl
1432053000
Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately started imagining the choppers cutting wood. She imagined the situation that is described below.There are n trees located along the road at points with coordinates x1, x2, ..., xn. Each tr...
256 megabytes
import java.util.Scanner; public class Main { static Scanner s = new Scanner(System.in); static int N = -1; static int[][] treeInfo = null; static int[][] process = null; public static void main(String[] args) { init(); solve(); } public static void init(){ N = s.nextInt(); treeInfo = new int[2][N]; ...
Java
["5\n1 2\n2 1\n5 10\n10 9\n19 1", "5\n1 2\n2 1\n5 10\n10 9\n20 1"]
1 second
["3", "4"]
NoteIn the first sample you can fell the trees like that: fell the 1-st tree to the left — now it occupies segment [ - 1;1] fell the 2-nd tree to the right — now it occupies segment [2;3] leave the 3-rd tree — it occupies point 5 leave the 4-th tree — it occupies point 10 fell the 5-th tree to the right — now it ...
Java 8
standard input
[ "dp", "greedy" ]
a850dd88a67a6295823e70e2c5c857c9
The first line contains integer n (1 ≤ n ≤ 105) — the number of trees. Next n lines contain pairs of integers xi, hi (1 ≤ xi, hi ≤ 109) — the coordinate and the height of the і-th tree. The pairs are given in the order of ascending xi. No two trees are located at the point with the same coordinate.
1,500
Print a single number — the maximum number of trees that you can cut down by the given rules.
standard output
PASSED
bca1211cc7aeccac61fd155173b70c0a
train_002.jsonl
1432053000
Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately started imagining the choppers cutting wood. She imagined the situation that is described below.There are n trees located along the road at points with coordinates x1, x2, ..., xn. Each tr...
256 megabytes
import java.util.*; import java.io.*; public class cf { private static final Scanner sc = new Scanner(new BufferedInputStream(System.in)); private static final PrintWriter pw = new PrintWriter(System.out, true); private static StringBuffer ans = new StringBuffer(); public static void main(String args[]) throws Exce...
Java
["5\n1 2\n2 1\n5 10\n10 9\n19 1", "5\n1 2\n2 1\n5 10\n10 9\n20 1"]
1 second
["3", "4"]
NoteIn the first sample you can fell the trees like that: fell the 1-st tree to the left — now it occupies segment [ - 1;1] fell the 2-nd tree to the right — now it occupies segment [2;3] leave the 3-rd tree — it occupies point 5 leave the 4-th tree — it occupies point 10 fell the 5-th tree to the right — now it ...
Java 8
standard input
[ "dp", "greedy" ]
a850dd88a67a6295823e70e2c5c857c9
The first line contains integer n (1 ≤ n ≤ 105) — the number of trees. Next n lines contain pairs of integers xi, hi (1 ≤ xi, hi ≤ 109) — the coordinate and the height of the і-th tree. The pairs are given in the order of ascending xi. No two trees are located at the point with the same coordinate.
1,500
Print a single number — the maximum number of trees that you can cut down by the given rules.
standard output
PASSED
f0d49728b880249fe11851d838b3ab9f
train_002.jsonl
1432053000
Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately started imagining the choppers cutting wood. She imagined the situation that is described below.There are n trees located along the road at points with coordinates x1, x2, ..., xn. Each tr...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Java
["5\n1 2\n2 1\n5 10\n10 9\n19 1", "5\n1 2\n2 1\n5 10\n10 9\n20 1"]
1 second
["3", "4"]
NoteIn the first sample you can fell the trees like that: fell the 1-st tree to the left — now it occupies segment [ - 1;1] fell the 2-nd tree to the right — now it occupies segment [2;3] leave the 3-rd tree — it occupies point 5 leave the 4-th tree — it occupies point 10 fell the 5-th tree to the right — now it ...
Java 8
standard input
[ "dp", "greedy" ]
a850dd88a67a6295823e70e2c5c857c9
The first line contains integer n (1 ≤ n ≤ 105) — the number of trees. Next n lines contain pairs of integers xi, hi (1 ≤ xi, hi ≤ 109) — the coordinate and the height of the і-th tree. The pairs are given in the order of ascending xi. No two trees are located at the point with the same coordinate.
1,500
Print a single number — the maximum number of trees that you can cut down by the given rules.
standard output
PASSED
ca406af5d1fb21a47b304c706d1eeaf2
train_002.jsonl
1432053000
Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately started imagining the choppers cutting wood. She imagined the situation that is described below.There are n trees located along the road at points with coordinates x1, x2, ..., xn. Each tr...
256 megabytes
import java.util.*; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; public class ...
Java
["5\n1 2\n2 1\n5 10\n10 9\n19 1", "5\n1 2\n2 1\n5 10\n10 9\n20 1"]
1 second
["3", "4"]
NoteIn the first sample you can fell the trees like that: fell the 1-st tree to the left — now it occupies segment [ - 1;1] fell the 2-nd tree to the right — now it occupies segment [2;3] leave the 3-rd tree — it occupies point 5 leave the 4-th tree — it occupies point 10 fell the 5-th tree to the right — now it ...
Java 8
standard input
[ "dp", "greedy" ]
a850dd88a67a6295823e70e2c5c857c9
The first line contains integer n (1 ≤ n ≤ 105) — the number of trees. Next n lines contain pairs of integers xi, hi (1 ≤ xi, hi ≤ 109) — the coordinate and the height of the і-th tree. The pairs are given in the order of ascending xi. No two trees are located at the point with the same coordinate.
1,500
Print a single number — the maximum number of trees that you can cut down by the given rules.
standard output
PASSED
e4bfd012975b99d3231e51b664289383
train_002.jsonl
1432053000
Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately started imagining the choppers cutting wood. She imagined the situation that is described below.There are n trees located along the road at points with coordinates x1, x2, ..., xn. Each tr...
256 megabytes
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ import java.util.*; import java.io.*; /** * * @author MR */ public class Code { /** * @param args the command line argumen...
Java
["5\n1 2\n2 1\n5 10\n10 9\n19 1", "5\n1 2\n2 1\n5 10\n10 9\n20 1"]
1 second
["3", "4"]
NoteIn the first sample you can fell the trees like that: fell the 1-st tree to the left — now it occupies segment [ - 1;1] fell the 2-nd tree to the right — now it occupies segment [2;3] leave the 3-rd tree — it occupies point 5 leave the 4-th tree — it occupies point 10 fell the 5-th tree to the right — now it ...
Java 8
standard input
[ "dp", "greedy" ]
a850dd88a67a6295823e70e2c5c857c9
The first line contains integer n (1 ≤ n ≤ 105) — the number of trees. Next n lines contain pairs of integers xi, hi (1 ≤ xi, hi ≤ 109) — the coordinate and the height of the і-th tree. The pairs are given in the order of ascending xi. No two trees are located at the point with the same coordinate.
1,500
Print a single number — the maximum number of trees that you can cut down by the given rules.
standard output
PASSED
9381510eb46e3415c63e9c5941f8ae7e
train_002.jsonl
1432053000
Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately started imagining the choppers cutting wood. She imagined the situation that is described below.There are n trees located along the road at points with coordinates x1, x2, ..., xn. Each tr...
256 megabytes
// All important imports import static java.lang.System.in; import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java...
Java
["5\n1 2\n2 1\n5 10\n10 9\n19 1", "5\n1 2\n2 1\n5 10\n10 9\n20 1"]
1 second
["3", "4"]
NoteIn the first sample you can fell the trees like that: fell the 1-st tree to the left — now it occupies segment [ - 1;1] fell the 2-nd tree to the right — now it occupies segment [2;3] leave the 3-rd tree — it occupies point 5 leave the 4-th tree — it occupies point 10 fell the 5-th tree to the right — now it ...
Java 8
standard input
[ "dp", "greedy" ]
a850dd88a67a6295823e70e2c5c857c9
The first line contains integer n (1 ≤ n ≤ 105) — the number of trees. Next n lines contain pairs of integers xi, hi (1 ≤ xi, hi ≤ 109) — the coordinate and the height of the і-th tree. The pairs are given in the order of ascending xi. No two trees are located at the point with the same coordinate.
1,500
Print a single number — the maximum number of trees that you can cut down by the given rules.
standard output
PASSED
ae1d5ecfb102bfd04a8cc06ea9b80e91
train_002.jsonl
1432053000
Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately started imagining the choppers cutting wood. She imagined the situation that is described below.There are n trees located along the road at points with coordinates x1, x2, ..., xn. Each tr...
256 megabytes
import java.util.Scanner; public class WoodCutter { public static void main(String[] args) { // TODO Auto-generated method stub long[] numberOfTree = new long[3]; long[] xCoordinate = new long[3]; // 입력 Scanner scanner = new Scanner(System.in); long number = scanner.nextLong(); long[] treeLocati...
Java
["5\n1 2\n2 1\n5 10\n10 9\n19 1", "5\n1 2\n2 1\n5 10\n10 9\n20 1"]
1 second
["3", "4"]
NoteIn the first sample you can fell the trees like that: fell the 1-st tree to the left — now it occupies segment [ - 1;1] fell the 2-nd tree to the right — now it occupies segment [2;3] leave the 3-rd tree — it occupies point 5 leave the 4-th tree — it occupies point 10 fell the 5-th tree to the right — now it ...
Java 8
standard input
[ "dp", "greedy" ]
a850dd88a67a6295823e70e2c5c857c9
The first line contains integer n (1 ≤ n ≤ 105) — the number of trees. Next n lines contain pairs of integers xi, hi (1 ≤ xi, hi ≤ 109) — the coordinate and the height of the і-th tree. The pairs are given in the order of ascending xi. No two trees are located at the point with the same coordinate.
1,500
Print a single number — the maximum number of trees that you can cut down by the given rules.
standard output
PASSED
1bc234c95370638cd7d3e008fa8087f5
train_002.jsonl
1432053000
Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately started imagining the choppers cutting wood. She imagined the situation that is described below.There are n trees located along the road at points with coordinates x1, x2, ..., xn. Each tr...
256 megabytes
import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { InputReader fi=new InputReader(System.in); int n=fi.nextInt(); int i,j,k; int x[]=new int[n]; int h[]=new int[n]; for (i=0;i<n;i++){ x[i]=fi.nextInt()...
Java
["5\n1 2\n2 1\n5 10\n10 9\n19 1", "5\n1 2\n2 1\n5 10\n10 9\n20 1"]
1 second
["3", "4"]
NoteIn the first sample you can fell the trees like that: fell the 1-st tree to the left — now it occupies segment [ - 1;1] fell the 2-nd tree to the right — now it occupies segment [2;3] leave the 3-rd tree — it occupies point 5 leave the 4-th tree — it occupies point 10 fell the 5-th tree to the right — now it ...
Java 8
standard input
[ "dp", "greedy" ]
a850dd88a67a6295823e70e2c5c857c9
The first line contains integer n (1 ≤ n ≤ 105) — the number of trees. Next n lines contain pairs of integers xi, hi (1 ≤ xi, hi ≤ 109) — the coordinate and the height of the і-th tree. The pairs are given in the order of ascending xi. No two trees are located at the point with the same coordinate.
1,500
Print a single number — the maximum number of trees that you can cut down by the given rules.
standard output
PASSED
653d31aab5863caaee6e5f4ca279f49d
train_002.jsonl
1432053000
Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately started imagining the choppers cutting wood. She imagined the situation that is described below.There are n trees located along the road at points with coordinates x1, x2, ..., xn. Each tr...
256 megabytes
import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { InputReader fi=new InputReader(System.in); int n=fi.nextInt(); int i,j,k; int x[]=new int[n]; int h[]=new int[n]; for (i=0;i<n;i++){ x[i]=fi.nextInt()...
Java
["5\n1 2\n2 1\n5 10\n10 9\n19 1", "5\n1 2\n2 1\n5 10\n10 9\n20 1"]
1 second
["3", "4"]
NoteIn the first sample you can fell the trees like that: fell the 1-st tree to the left — now it occupies segment [ - 1;1] fell the 2-nd tree to the right — now it occupies segment [2;3] leave the 3-rd tree — it occupies point 5 leave the 4-th tree — it occupies point 10 fell the 5-th tree to the right — now it ...
Java 8
standard input
[ "dp", "greedy" ]
a850dd88a67a6295823e70e2c5c857c9
The first line contains integer n (1 ≤ n ≤ 105) — the number of trees. Next n lines contain pairs of integers xi, hi (1 ≤ xi, hi ≤ 109) — the coordinate and the height of the і-th tree. The pairs are given in the order of ascending xi. No two trees are located at the point with the same coordinate.
1,500
Print a single number — the maximum number of trees that you can cut down by the given rules.
standard output
PASSED
6d08c2a55b1624d05de2ffa2104a8b52
train_002.jsonl
1432053000
Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately started imagining the choppers cutting wood. She imagined the situation that is described below.There are n trees located along the road at points with coordinates x1, x2, ..., xn. Each tr...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class C545 { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.valueOf(new StringT...
Java
["5\n1 2\n2 1\n5 10\n10 9\n19 1", "5\n1 2\n2 1\n5 10\n10 9\n20 1"]
1 second
["3", "4"]
NoteIn the first sample you can fell the trees like that: fell the 1-st tree to the left — now it occupies segment [ - 1;1] fell the 2-nd tree to the right — now it occupies segment [2;3] leave the 3-rd tree — it occupies point 5 leave the 4-th tree — it occupies point 10 fell the 5-th tree to the right — now it ...
Java 8
standard input
[ "dp", "greedy" ]
a850dd88a67a6295823e70e2c5c857c9
The first line contains integer n (1 ≤ n ≤ 105) — the number of trees. Next n lines contain pairs of integers xi, hi (1 ≤ xi, hi ≤ 109) — the coordinate and the height of the і-th tree. The pairs are given in the order of ascending xi. No two trees are located at the point with the same coordinate.
1,500
Print a single number — the maximum number of trees that you can cut down by the given rules.
standard output
PASSED
a203e5bf7a15ae04f6757c4a744be81e
train_002.jsonl
1432053000
Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately started imagining the choppers cutting wood. She imagined the situation that is described below.There are n trees located along the road at points with coordinates x1, x2, ..., xn. Each tr...
256 megabytes
import java.util.Scanner; public class Main { static Scanner s = new Scanner(System.in); static int N = -1; static int[][] treeInfo = null; static int[][] process = null; public static void main(String[] args) { init(); solve(); } public static void init(){ N = s.nextInt(); treeInfo = new int[2][N]; ...
Java
["5\n1 2\n2 1\n5 10\n10 9\n19 1", "5\n1 2\n2 1\n5 10\n10 9\n20 1"]
1 second
["3", "4"]
NoteIn the first sample you can fell the trees like that: fell the 1-st tree to the left — now it occupies segment [ - 1;1] fell the 2-nd tree to the right — now it occupies segment [2;3] leave the 3-rd tree — it occupies point 5 leave the 4-th tree — it occupies point 10 fell the 5-th tree to the right — now it ...
Java 8
standard input
[ "dp", "greedy" ]
a850dd88a67a6295823e70e2c5c857c9
The first line contains integer n (1 ≤ n ≤ 105) — the number of trees. Next n lines contain pairs of integers xi, hi (1 ≤ xi, hi ≤ 109) — the coordinate and the height of the і-th tree. The pairs are given in the order of ascending xi. No two trees are located at the point with the same coordinate.
1,500
Print a single number — the maximum number of trees that you can cut down by the given rules.
standard output
PASSED
892b1502ef6cb26dcbca1be968b1738f
train_002.jsonl
1432053000
Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately started imagining the choppers cutting wood. She imagined the situation that is described below.There are n trees located along the road at points with coordinates x1, x2, ..., xn. Each tr...
256 megabytes
import java.util.Scanner; public class Main { static Scanner s = new Scanner(System.in); static int N = -1; static int[][] treeInfo = null; static int[][] process = null; public static void main(String[] args) { init(); solve(); } public static void init(){ N = s.nextInt(); treeInfo = new int[2][N]; ...
Java
["5\n1 2\n2 1\n5 10\n10 9\n19 1", "5\n1 2\n2 1\n5 10\n10 9\n20 1"]
1 second
["3", "4"]
NoteIn the first sample you can fell the trees like that: fell the 1-st tree to the left — now it occupies segment [ - 1;1] fell the 2-nd tree to the right — now it occupies segment [2;3] leave the 3-rd tree — it occupies point 5 leave the 4-th tree — it occupies point 10 fell the 5-th tree to the right — now it ...
Java 8
standard input
[ "dp", "greedy" ]
a850dd88a67a6295823e70e2c5c857c9
The first line contains integer n (1 ≤ n ≤ 105) — the number of trees. Next n lines contain pairs of integers xi, hi (1 ≤ xi, hi ≤ 109) — the coordinate and the height of the і-th tree. The pairs are given in the order of ascending xi. No two trees are located at the point with the same coordinate.
1,500
Print a single number — the maximum number of trees that you can cut down by the given rules.
standard output
PASSED
a5379ea83869c6b31b6b54f8d243820b
train_002.jsonl
1432053000
Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately started imagining the choppers cutting wood. She imagined the situation that is described below.There are n trees located along the road at points with coordinates x1, x2, ..., xn. Each tr...
256 megabytes
import java.awt.*; import java.util.Scanner; public class Woodcutters { private static class Tuple { long x; long y; Tuple(long x, long y) { this.x = x; this.y = y; } } public static void main(String[] args) { Scanner in = new Scanner(Syste...
Java
["5\n1 2\n2 1\n5 10\n10 9\n19 1", "5\n1 2\n2 1\n5 10\n10 9\n20 1"]
1 second
["3", "4"]
NoteIn the first sample you can fell the trees like that: fell the 1-st tree to the left — now it occupies segment [ - 1;1] fell the 2-nd tree to the right — now it occupies segment [2;3] leave the 3-rd tree — it occupies point 5 leave the 4-th tree — it occupies point 10 fell the 5-th tree to the right — now it ...
Java 8
standard input
[ "dp", "greedy" ]
a850dd88a67a6295823e70e2c5c857c9
The first line contains integer n (1 ≤ n ≤ 105) — the number of trees. Next n lines contain pairs of integers xi, hi (1 ≤ xi, hi ≤ 109) — the coordinate and the height of the і-th tree. The pairs are given in the order of ascending xi. No two trees are located at the point with the same coordinate.
1,500
Print a single number — the maximum number of trees that you can cut down by the given rules.
standard output
PASSED
a9fb2374e3dd36675d83c705c9a77c4c
train_002.jsonl
1432053000
Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately started imagining the choppers cutting wood. She imagined the situation that is described below.There are n trees located along the road at points with coordinates x1, x2, ..., xn. Each tr...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.HashMap; import java.util.HashS...
Java
["5\n1 2\n2 1\n5 10\n10 9\n19 1", "5\n1 2\n2 1\n5 10\n10 9\n20 1"]
1 second
["3", "4"]
NoteIn the first sample you can fell the trees like that: fell the 1-st tree to the left — now it occupies segment [ - 1;1] fell the 2-nd tree to the right — now it occupies segment [2;3] leave the 3-rd tree — it occupies point 5 leave the 4-th tree — it occupies point 10 fell the 5-th tree to the right — now it ...
Java 8
standard input
[ "dp", "greedy" ]
a850dd88a67a6295823e70e2c5c857c9
The first line contains integer n (1 ≤ n ≤ 105) — the number of trees. Next n lines contain pairs of integers xi, hi (1 ≤ xi, hi ≤ 109) — the coordinate and the height of the і-th tree. The pairs are given in the order of ascending xi. No two trees are located at the point with the same coordinate.
1,500
Print a single number — the maximum number of trees that you can cut down by the given rules.
standard output
PASSED
9f29cd57a7c1f80cfef12fc86bd669ac
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import jav...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
30ee4768d0bd5008ac2fe9092d48f16b
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.io.PrintWriter; import java.util.Scanner; public class XeniaandBitOperations { private static int n, q; private static long[] arr; private static long[] segmentTree; private static void build(int node, int start, int end, boolean OR){ if(start == end){ segmentTree[node] = arr[start]; retu...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
83798544276cbdb04c7bda4aef94177f
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.util.InputMismatchException; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStre...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
3a7d44123fef78b63cb00fbb0da70a34
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; public class XeniaAndBitOperations { class SegmentTree { int tree[], arr[]; public SegmentTree(int sz, int arr[], int lv) { tree = new int[4 * sz]; this...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
539a6f724e4854a489527005bd64e920
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; public class Xenia { static int[] in; static int[] out; final static int IDENTITY = 0; static int HEIGHT = 0; public static void main(String[] args) throws IOException { BufferedReader stdin =...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
8a228acc48fe8c6e1215656ad2da272f
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.awt.*; import java.awt.event.*; import java.awt.geom.*; import java.io.*; import java.math.*; import java.text.*; import java.util.*; /* br = new BufferedReader(new FileReader("input.txt")); pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt"))); br = new BufferedReader(new InputStreamReade...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
d6a57747ac94b0216a058dfebfb9a80e
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; public class XeniaAndBitOperations { class SegmentTree { int tree[], arr[]; public SegmentTree(int sz, int arr[], int n) { tree = new int[4 * sz]; this....
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
54ca098ab49711905ce36039ce93e5c5
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class XeniaAndBitOperations { static class Node { int value; Node left, right, parent; public Node(i...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
95a5306e985ed67960aff7bb2e7f3c88
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.io.IOException; public class CFD { private static final int IN_BUFFER_SIZE = 1 << 16; private static final int OUT_BUFFER_SIZE = 1 << 16; private byte[] input = new byte[IN_BUFFER_SIZE]; private int ix = IN_BUFFER_SIZE; private int bytesRead = ix; private byte[] output = new byte[OUT_BUFFER_SIZE]; ...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
5f11db5ff97de76119f576a079188d5f
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.util.*; import java.io.*; public class Main{ BufferedReader in; StringTokenizer str = null; PrintWriter out; private String next() throws Exception{ if (str == null || !str.hasMoreElements()) str = new StringTokenizer(in.readLine()); return str.nextToken(); } ...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
e20f28399c3bd20a8b967c33abe96b4f
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class XeniaandBitOperations { public static class Node { int value; int sum; public Node(int v, int s) { value = v; sum = s; } } public static Node ...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
6936f1e511577b69c61cb25a0ac271b6
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class XeniaandBitOperations { public static class Node { int value; int sum; public Node(int v, int s) { value = v; sum = s; } } public static Node ...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
e71ad142a15d1c6ea0baaac9310a36b1
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Integer.*; import static java.lang.Math.*; public class Main{ static class SegmentTree{ private long[] valores; private int izq[], der[], cotas[][], c; private int[] cuentas; private int N, altura[]; private long...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
dee454985287e584b128d1ed559407b3
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class D { BufferedReader reader; StringTokenizer tokenizer; PrintWriter out; public void solve() throws IOException { int N = nextInt(); int M = n...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
6d4d5cd9ec111e3ca11df32ec7233adc
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; /** * @author Mohammad Al-Najjar * @since 11/13/2014 */ public class Main { public static void main(String[] args) throws IOException { BufferedReader r...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
db8c31221a8ea72d4d6f9bd9715ae032
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; public class Main { public BufferedReader...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
af31fccc02890ae70424ec5a1b6d298c
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.io.PrintWriter; import java.util.Scanner; public class D { static Scanner in; static int next() throws Exception {return in.nextInt();}; // static StreamTokenizer in; static int next() throws Exception {in.nextToken(); return (int) in.nval;} // static BufferedReader in; static PrintWriter out; ...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
24cf88ecfc55f102ac09a3c96cd27889
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; import java.util.Arrays; import java.util.PriorityQueue; import java.util.ArrayList; import java.io.OutputStreamWriter; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.OutputStream; import...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
7cabfd9e68acc66ddf599a5797b83d4a
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Scanner; public class Main { public static void main(String[] args) throws IOException { // System.out.println(4|5); // Scanner in = new Scanner(System.in); ...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
10c4b88eeaea53120ac428c4fd28e476
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.util.*; public class Main { static int[][] nums; public static void main(String[] args) { Scanner in = new Scanner(System.in); int N = in.nextInt(); int M = in.nextInt(); nums = new int[N+1][]; nums[0] = new int[1<<N]; for (int i=0; i<nums[0].length; i...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
7b86108614171f8e2f04af1644544604
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.HashMap; import java.util.StringTokenizer; public class Main {...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
67cb625096d3b31d1e70c07e61c7883f
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.util.*; import java.io.*; public class cfa { static long mod = 1000000009; public static void main(String[] args) throws IOException { // Scanner input = new Scanner(new File("input.txt")); // PrintWriter out = new PrintWriter(new File("output.txt")); input.init(System.in); ...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
6d86b1432f377dd48f208efa3e336bab
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class XeniaandBitOperations { static int[] tree; static int[] a; static void build(int x, int y, int node, int operation) { if (x == y) { tree[node] = ...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
8418ac0edf0d34e8e4b601cc03064a39
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class D { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { reader = new BufferedReader(new Inp...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
b294997b469962fef349423981da7b00
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.io.*; import java.util.*; public class BinaryAssignments { public static void main(String[] args) throws IOException { BufferedReader rd = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); StringTokenizer st = new StringTokenizer(rd.readLine()); n ...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
57b72eaadb737e92e53c680efc6ab69c
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.io.InputStreamReader; import java.io.PrintWriter; import static java.lang.Math.*; import java.util.ArrayList; import java.util.Scanner; /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author pttrung */ public class C { public static long...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
c4da9b051e4e3f5da3ff1be1bc3f57f4
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.io.*; import java.util.*; public class D { int[] segt, seq; int n, m; void update(int index, int lvl, int st, int end, int id, int val){ if(st==end){ segt[index]=val; return; } int mid = (st+end)>>1; if(id<=mid) update(index<<1, lvl+1, st, mid, id, val); else update(index<<1|1, lvl...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
afce597dd356beddd83e458d0078debe
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.io.*; import java.util.*; public class D { int[] segt, seq; int n, m; void update(int index, int lvl, int st, int end, int id, int val){ if(st==end){ segt[index]=val; return; } int mid = (st+end)>>1; if(id<=mid) update(index<<1, lvl+1, st, mid, id, val); else update(index<<1|1, ...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
eb2fbae8869c992bfb19a9ab7ba291a2
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.io.*; import java.util.*; import java.awt.geom.*; public class Main { static BufferedReader br = new BufferedReader( new InputStreamReader(System.in) ); static StringTokenizer st = new StringTokenizer(""); static String next() throws Exception { while ( !st.hasMoreTokens() ) st = new StringTokenizer( ...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
eab263f9e9ef4f6df3821bf45773d8cd
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.io.*; import java.util.*; import java.awt.geom.*; public class Main { static BufferedReader br = new BufferedReader( new InputStreamReader(System.in) ); static StringTokenizer st = new StringTokenizer(""); static String next() throws Exception { while ( !st.hasMoreTokens() ) st = new StringTokenizer( ...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
1571af25b9415346a9960b3a54e444f1
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.io.*; import java.util.*; public class CodeForces339D { int[] segmentTree, sequence; int n, m; void update(int index, int lvl, int st, int end, int id, int val) { if (st == end) { segmentTree[index] = val; return; } int mid = (st + end) >> 1; ...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
1b2f380c7c25b3e5a8bf452624b3a179
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.io.*; import java.util.Arrays; //import java.util.*; public class xeniabit { public static void update(int array[],int x1,int x2){ array[(array.length/2)+x1-1]=x2; } public static void or1(int array[],int start){ int a = start; while(a>(start)/2){ array[a...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
1449c48d360e1d2f0092d29782ba514b
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
//package round197; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class D { InputStream is; PrintWriter out; String INPUT = ""; void solve() { int n = ni(), m = ...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
f7dd8b08023413fdecf9f1c001ecf853
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.io.DataInputStream; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.LinkedList; import java.util.PriorityQueue; import java.util.Queue; import java.util.TreeSet; public class ProblemA1 { sta...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
f35a6c1a9469f5a1bd7243d6aaf5c5a6
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.util.Scanner; /** * User: maestro * Date: 13.09.13 * Time: 20:23 */ public class Main { static void countFor(long[][] array, int row, int col, int step) { long a = array[row - 1][col]; long b = array[row - 1][col + step]; array[row][col] = (row % 2 == 0) ? (a ^ b) : (a | b);...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
6137c14b141e14d1d9c566a1618396b8
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.Enumeration; import java.util.Iterator; import java.util.Properties; ...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
5a0ff505c1694b95bce9626175616f6d
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; import java.util.concurrent.ArrayBlockingQueue; import sun.security.provider.certpath.OCSP.RevocationStatus; public class D { String line; StringTokenizer inputParser; BufferedReader is; FileInputStream fstream; DataInputStream in; void openIn...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
c4f5a759a8c16b33c40557e8c10adcad
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.io.*; import java.util.*; public class fourth { static long fast_power(long a,long n,long m) { if(n==1) { return a%m; } if(n%2==1) { long power = fast_power(a,(n-1)/2,m)%m; return ((a%m) * ((power*power)%m))%m; } long power = fast_power(a,n/2,m)%m; return (power*power)%m; ...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
d3c69bde85dd3c3afc2a10f07b71df3a
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.io.*; import java.util.StringTokenizer; public class D { final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null; BufferedReader in; PrintWriter out; StringTokenizer tok = new StringTokenizer(""); void solve() throws IOException { int n = readInt(); int m = readInt...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
87408af0be49af67dca34697512f913e
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.util.Scanner; public class D { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); long[][] mas = new long[n + 1][]; ...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
ff98fd9f1ff112605f2be8d97af1578a
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class A { public static void main(String[] args) { Scanner in = new Scanner(System.in); int d = in.nextInt(); int n = (1 << d); int m = in.nextInt(); int[][] list = new int[d + 1][n]; for(int i = 0; i < n; i++) { list[0][i] = in.nextInt(); } ...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
5cc94e33c7dc3fe9ba8d89e9534251e1
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class D { private void solve() { Scanner sc = new Scanner(System.in); // Scanner sc = new Scanner( // "2 4\n" + // "1 6 3 5\n" + // "1 4\n" + // "3 4\n" + // "1 2\n" ...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
a838b79af1afb5d63f040fe92d540978
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.io.*; import java.util.*; public class R197_D2_D { public static void main(String[] args) throws Exception { InputReader in = new InputReader(System.in); int n = in.readInt(); int m = in.readInt(); int[][] all = new int[n + 1][1 << n]; for (int i = 0; i < (1 << ...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
6696d1bba195aaa0a47847e57c193243
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class D { private static int N; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
2274dae6ffe810f1cd906a6aef85c7c6
train_002.jsonl
1377531000
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.Namely, it takes several iterations to calculate value v. At the first iteration, Xenia ...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; import static java.lang.Math.*; @SuppressWarnings("unused") public class round197D { static BufferedReader br = new BufferedReader(new InputStreamReader( System.in)); sta...
Java
["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2"]
2 seconds
["1\n3\n3\n3"]
NoteFor more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation
Java 6
standard input
[ "data structures", "trees" ]
40d1ea98aa69865143d44432aed4dd7e
The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 105). The next line contains 2n integers a1, a2, ..., a2n (0 ≤ ai &lt; 230). Each of the next m lines contains queries. The i-th line contains integers pi, bi (1 ≤ pi ≤ 2n, 0 ≤ bi &lt; 230) — the i-th query.
1,700
Print m integers — the i-th integer denotes value v for sequence a after the i-th query.
standard output
PASSED
30e1001a1b3ac98c7672fcbce7fe0ca3
train_002.jsonl
1563636900
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?The book contains a single string of characters "a", "b"...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.InputMismatchException; import java.util.StringTokenizer; public class E { static class FastWriter { private final BufferedWriter bw; public FastWriter() { this.bw = new BufferedWriter(new OutputStreamWriter(System.out)); ...
Java
["cacbac", "abc", "cbacacacbcbababacbcb"]
1 second
["aba", "a", "cbaaacbcaaabc"]
NoteIn the first example, other valid answers include "cacac", "caac", "aca" and "ccc".
Java 8
standard input
[ "brute force", "constructive algorithms", "greedy", "strings" ]
3bebb50d1c2ef9f80e78715614f039d7
The input consists of a single string $$$s$$$ ($$$2 \leq |s| \leq 10^6$$$). The string $$$s$$$ consists only of characters "a", "b", "c". It is guaranteed that no two consecutive characters are equal.
1,900
Output a palindrome $$$t$$$ that is a subsequence of $$$s$$$ and $$$|t| \geq \lfloor \frac{|s|}{2} \rfloor$$$. If there are multiple solutions, you may print any of them. You don't have to maximise the length of $$$t$$$. If there are no solutions, output a string "IMPOSSIBLE" (quotes for clarity).
standard output
PASSED
56fbdd77eb6cc88c0b06ab1ab2b2bc76
train_002.jsonl
1563636900
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?The book contains a single string of characters "a", "b"...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Solution { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); String s = br.readLine(); int low=0,...
Java
["cacbac", "abc", "cbacacacbcbababacbcb"]
1 second
["aba", "a", "cbaaacbcaaabc"]
NoteIn the first example, other valid answers include "cacac", "caac", "aca" and "ccc".
Java 8
standard input
[ "brute force", "constructive algorithms", "greedy", "strings" ]
3bebb50d1c2ef9f80e78715614f039d7
The input consists of a single string $$$s$$$ ($$$2 \leq |s| \leq 10^6$$$). The string $$$s$$$ consists only of characters "a", "b", "c". It is guaranteed that no two consecutive characters are equal.
1,900
Output a palindrome $$$t$$$ that is a subsequence of $$$s$$$ and $$$|t| \geq \lfloor \frac{|s|}{2} \rfloor$$$. If there are multiple solutions, you may print any of them. You don't have to maximise the length of $$$t$$$. If there are no solutions, output a string "IMPOSSIBLE" (quotes for clarity).
standard output
PASSED
d37695630074e41fc7fdcc52e08afb09
train_002.jsonl
1563636900
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?The book contains a single string of characters "a", "b"...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Solution { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); String s = br.readLine(); int low=0,...
Java
["cacbac", "abc", "cbacacacbcbababacbcb"]
1 second
["aba", "a", "cbaaacbcaaabc"]
NoteIn the first example, other valid answers include "cacac", "caac", "aca" and "ccc".
Java 8
standard input
[ "brute force", "constructive algorithms", "greedy", "strings" ]
3bebb50d1c2ef9f80e78715614f039d7
The input consists of a single string $$$s$$$ ($$$2 \leq |s| \leq 10^6$$$). The string $$$s$$$ consists only of characters "a", "b", "c". It is guaranteed that no two consecutive characters are equal.
1,900
Output a palindrome $$$t$$$ that is a subsequence of $$$s$$$ and $$$|t| \geq \lfloor \frac{|s|}{2} \rfloor$$$. If there are multiple solutions, you may print any of them. You don't have to maximise the length of $$$t$$$. If there are no solutions, output a string "IMPOSSIBLE" (quotes for clarity).
standard output
PASSED
5301cdda616f7b65467a4d782a63d57e
train_002.jsonl
1563636900
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?The book contains a single string of characters "a", "b"...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class subsseqs { public static void main(String[] Args){ FastReader scan=new FastReader(); String s=scan.next(); int n=s.length(); boolean[] v=new boolean[n]; int req=n/2; int i=0; int j=n-1; ...
Java
["cacbac", "abc", "cbacacacbcbababacbcb"]
1 second
["aba", "a", "cbaaacbcaaabc"]
NoteIn the first example, other valid answers include "cacac", "caac", "aca" and "ccc".
Java 8
standard input
[ "brute force", "constructive algorithms", "greedy", "strings" ]
3bebb50d1c2ef9f80e78715614f039d7
The input consists of a single string $$$s$$$ ($$$2 \leq |s| \leq 10^6$$$). The string $$$s$$$ consists only of characters "a", "b", "c". It is guaranteed that no two consecutive characters are equal.
1,900
Output a palindrome $$$t$$$ that is a subsequence of $$$s$$$ and $$$|t| \geq \lfloor \frac{|s|}{2} \rfloor$$$. If there are multiple solutions, you may print any of them. You don't have to maximise the length of $$$t$$$. If there are no solutions, output a string "IMPOSSIBLE" (quotes for clarity).
standard output
PASSED
990e045c1688921ae0497168139e9961
train_002.jsonl
1563636900
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?The book contains a single string of characters "a", "b"...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); PrintWriter out = new PrintWriter(System.out); char [] s = sc.next().toCharArray() ; int l = 0 , r = s.length - 1 ; Stack<Char...
Java
["cacbac", "abc", "cbacacacbcbababacbcb"]
1 second
["aba", "a", "cbaaacbcaaabc"]
NoteIn the first example, other valid answers include "cacac", "caac", "aca" and "ccc".
Java 8
standard input
[ "brute force", "constructive algorithms", "greedy", "strings" ]
3bebb50d1c2ef9f80e78715614f039d7
The input consists of a single string $$$s$$$ ($$$2 \leq |s| \leq 10^6$$$). The string $$$s$$$ consists only of characters "a", "b", "c". It is guaranteed that no two consecutive characters are equal.
1,900
Output a palindrome $$$t$$$ that is a subsequence of $$$s$$$ and $$$|t| \geq \lfloor \frac{|s|}{2} \rfloor$$$. If there are multiple solutions, you may print any of them. You don't have to maximise the length of $$$t$$$. If there are no solutions, output a string "IMPOSSIBLE" (quotes for clarity).
standard output
PASSED
35943b8436b8b6cd02953efad1d82ab5
train_002.jsonl
1563636900
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?The book contains a single string of characters "a", "b"...
256 megabytes
import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; /** * Created by sourav.p on . */ public class SolveA { private static long mod = 998244353; public static void main(String[] args) { Scanner in = new Scanner(System.in); char str[] = in.next().toCharArray(); ...
Java
["cacbac", "abc", "cbacacacbcbababacbcb"]
1 second
["aba", "a", "cbaaacbcaaabc"]
NoteIn the first example, other valid answers include "cacac", "caac", "aca" and "ccc".
Java 8
standard input
[ "brute force", "constructive algorithms", "greedy", "strings" ]
3bebb50d1c2ef9f80e78715614f039d7
The input consists of a single string $$$s$$$ ($$$2 \leq |s| \leq 10^6$$$). The string $$$s$$$ consists only of characters "a", "b", "c". It is guaranteed that no two consecutive characters are equal.
1,900
Output a palindrome $$$t$$$ that is a subsequence of $$$s$$$ and $$$|t| \geq \lfloor \frac{|s|}{2} \rfloor$$$. If there are multiple solutions, you may print any of them. You don't have to maximise the length of $$$t$$$. If there are no solutions, output a string "IMPOSSIBLE" (quotes for clarity).
standard output
PASSED
d99a513bf1fda69301ad8a5508329e29
train_002.jsonl
1563636900
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?The book contains a single string of characters "a", "b"...
256 megabytes
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.InputStreamReader; import java.util.ArrayList; public class E1178 { public static void main(String[] args) throws Exception { // BufferedReader br = new BufferedReader(new FileReader("F:/books/input.txt"))...
Java
["cacbac", "abc", "cbacacacbcbababacbcb"]
1 second
["aba", "a", "cbaaacbcaaabc"]
NoteIn the first example, other valid answers include "cacac", "caac", "aca" and "ccc".
Java 8
standard input
[ "brute force", "constructive algorithms", "greedy", "strings" ]
3bebb50d1c2ef9f80e78715614f039d7
The input consists of a single string $$$s$$$ ($$$2 \leq |s| \leq 10^6$$$). The string $$$s$$$ consists only of characters "a", "b", "c". It is guaranteed that no two consecutive characters are equal.
1,900
Output a palindrome $$$t$$$ that is a subsequence of $$$s$$$ and $$$|t| \geq \lfloor \frac{|s|}{2} \rfloor$$$. If there are multiple solutions, you may print any of them. You don't have to maximise the length of $$$t$$$. If there are no solutions, output a string "IMPOSSIBLE" (quotes for clarity).
standard output
PASSED
ce86ca9e48cdec298fa3e3a940654f96
train_002.jsonl
1563636900
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?The book contains a single string of characters "a", "b"...
256 megabytes
import java.io.*; import java.util.*; public class TaskE { void run() { FastReader in = new FastReader(System.in); // FastReader in = new FastReader(new FileInputStream("input.txt")); PrintWriter out = new PrintWriter(System.out); // PrintWriter out = new PrintWriter(new FileOutputSt...
Java
["cacbac", "abc", "cbacacacbcbababacbcb"]
1 second
["aba", "a", "cbaaacbcaaabc"]
NoteIn the first example, other valid answers include "cacac", "caac", "aca" and "ccc".
Java 8
standard input
[ "brute force", "constructive algorithms", "greedy", "strings" ]
3bebb50d1c2ef9f80e78715614f039d7
The input consists of a single string $$$s$$$ ($$$2 \leq |s| \leq 10^6$$$). The string $$$s$$$ consists only of characters "a", "b", "c". It is guaranteed that no two consecutive characters are equal.
1,900
Output a palindrome $$$t$$$ that is a subsequence of $$$s$$$ and $$$|t| \geq \lfloor \frac{|s|}{2} \rfloor$$$. If there are multiple solutions, you may print any of them. You don't have to maximise the length of $$$t$$$. If there are no solutions, output a string "IMPOSSIBLE" (quotes for clarity).
standard output
PASSED
84d63c02f54424da01e81e779651b614
train_002.jsonl
1563636900
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?The book contains a single string of characters "a", "b"...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author nul...
Java
["cacbac", "abc", "cbacacacbcbababacbcb"]
1 second
["aba", "a", "cbaaacbcaaabc"]
NoteIn the first example, other valid answers include "cacac", "caac", "aca" and "ccc".
Java 8
standard input
[ "brute force", "constructive algorithms", "greedy", "strings" ]
3bebb50d1c2ef9f80e78715614f039d7
The input consists of a single string $$$s$$$ ($$$2 \leq |s| \leq 10^6$$$). The string $$$s$$$ consists only of characters "a", "b", "c". It is guaranteed that no two consecutive characters are equal.
1,900
Output a palindrome $$$t$$$ that is a subsequence of $$$s$$$ and $$$|t| \geq \lfloor \frac{|s|}{2} \rfloor$$$. If there are multiple solutions, you may print any of them. You don't have to maximise the length of $$$t$$$. If there are no solutions, output a string "IMPOSSIBLE" (quotes for clarity).
standard output
PASSED
c7039285a6f89bc941ce15e2525b875a
train_002.jsonl
1563636900
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?The book contains a single string of characters "a", "b"...
256 megabytes
import java.util.*; import java.io.*; public class EE { public static void main(String[] args) { FastScanner scanner = new FastScanner(); PrintWriter out = new PrintWriter(System.out); StringBuilder stringBuilder = new StringBuilder(); String input = scanner.next(); char[] s...
Java
["cacbac", "abc", "cbacacacbcbababacbcb"]
1 second
["aba", "a", "cbaaacbcaaabc"]
NoteIn the first example, other valid answers include "cacac", "caac", "aca" and "ccc".
Java 8
standard input
[ "brute force", "constructive algorithms", "greedy", "strings" ]
3bebb50d1c2ef9f80e78715614f039d7
The input consists of a single string $$$s$$$ ($$$2 \leq |s| \leq 10^6$$$). The string $$$s$$$ consists only of characters "a", "b", "c". It is guaranteed that no two consecutive characters are equal.
1,900
Output a palindrome $$$t$$$ that is a subsequence of $$$s$$$ and $$$|t| \geq \lfloor \frac{|s|}{2} \rfloor$$$. If there are multiple solutions, you may print any of them. You don't have to maximise the length of $$$t$$$. If there are no solutions, output a string "IMPOSSIBLE" (quotes for clarity).
standard output