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
1236a49bde8623744849ce94f9c6150d
train_109.jsonl
1636869900
You are given two arrays of integers $$$a_1, a_2, \ldots, a_n$$$ and $$$b_1, b_2, \ldots, b_n$$$.Let's define a transformation of the array $$$a$$$: Choose any non-negative integer $$$k$$$ such that $$$0 \le k \le n$$$. Choose $$$k$$$ distinct array indices $$$1 \le i_1 < i_2 < \ldots < i_k \le n$$$. Add $$...
256 megabytes
//---#ON_MY_WAY--- import static java.lang.Math.*; import java.io.*; import java.math.*; import java.util.*; public class apples { static class pair { int x, y; public pair(int a, int b) { x = a; y = b; } } static FastReader x = new FastReader(); static OutputStream outputStream = Sy...
Java
["3\n3\n-1 1 0\n0 0 2\n1\n0\n2\n5\n1 2 3 4 5\n1 2 3 4 5"]
1 second
["YES\nNO\nYES"]
NoteIn the first test case, we can make the following transformation: Choose $$$k = 2$$$. Choose $$$i_1 = 1$$$, $$$i_2 = 2$$$. Add $$$1$$$ to $$$a_1$$$ and $$$a_2$$$. The resulting array is $$$[0, 2, 0]$$$. Swap the elements on the second and third positions. In the second test case there is no suitable transformat...
Java 8
standard input
[ "greedy", "math", "sortings" ]
6ca98e655007bfb86f1039c9f096557e
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Descriptions of test cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of arrays $$$a$$$ and $$$b$$$. The second line of each test case contains $$$n$$$ ...
900
For each test case, print "YES" (without quotes) if it is possible to perform a transformation of the array $$$a$$$, so that the resulting array is equal to $$$b$$$. Print "NO" (without quotes) otherwise. You can print each letter in any case (upper or lower).
standard output
PASSED
56bfd26516a775ee0bdbc1e9e72607ed
train_109.jsonl
1636869900
You are given two arrays of integers $$$a_1, a_2, \ldots, a_n$$$ and $$$b_1, b_2, \ldots, b_n$$$.Let's define a transformation of the array $$$a$$$: Choose any non-negative integer $$$k$$$ such that $$$0 \le k \le n$$$. Choose $$$k$$$ distinct array indices $$$1 \le i_1 < i_2 < \ldots < i_k \le n$$$. Add $$...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; import java.util.*; public class codeforcesA{ static class FastReader { BufferedReader br; StringTokenizer st; pub...
Java
["3\n3\n-1 1 0\n0 0 2\n1\n0\n2\n5\n1 2 3 4 5\n1 2 3 4 5"]
1 second
["YES\nNO\nYES"]
NoteIn the first test case, we can make the following transformation: Choose $$$k = 2$$$. Choose $$$i_1 = 1$$$, $$$i_2 = 2$$$. Add $$$1$$$ to $$$a_1$$$ and $$$a_2$$$. The resulting array is $$$[0, 2, 0]$$$. Swap the elements on the second and third positions. In the second test case there is no suitable transformat...
Java 8
standard input
[ "greedy", "math", "sortings" ]
6ca98e655007bfb86f1039c9f096557e
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Descriptions of test cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of arrays $$$a$$$ and $$$b$$$. The second line of each test case contains $$$n$$$ ...
900
For each test case, print "YES" (without quotes) if it is possible to perform a transformation of the array $$$a$$$, so that the resulting array is equal to $$$b$$$. Print "NO" (without quotes) otherwise. You can print each letter in any case (upper or lower).
standard output
PASSED
dbe2e5678e8de835c8ac552801e7fa8e
train_109.jsonl
1636869900
You are given two arrays of integers $$$a_1, a_2, \ldots, a_n$$$ and $$$b_1, b_2, \ldots, b_n$$$.Let's define a transformation of the array $$$a$$$: Choose any non-negative integer $$$k$$$ such that $$$0 \le k \le n$$$. Choose $$$k$$$ distinct array indices $$$1 \le i_1 < i_2 < \ldots < i_k \le n$$$. Add $$...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); for (int test = 0; test < t; test++) { int n = in.nextInt(); int[] a = new int[n]; ...
Java
["3\n3\n-1 1 0\n0 0 2\n1\n0\n2\n5\n1 2 3 4 5\n1 2 3 4 5"]
1 second
["YES\nNO\nYES"]
NoteIn the first test case, we can make the following transformation: Choose $$$k = 2$$$. Choose $$$i_1 = 1$$$, $$$i_2 = 2$$$. Add $$$1$$$ to $$$a_1$$$ and $$$a_2$$$. The resulting array is $$$[0, 2, 0]$$$. Swap the elements on the second and third positions. In the second test case there is no suitable transformat...
Java 8
standard input
[ "greedy", "math", "sortings" ]
6ca98e655007bfb86f1039c9f096557e
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Descriptions of test cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of arrays $$$a$$$ and $$$b$$$. The second line of each test case contains $$$n$$$ ...
900
For each test case, print "YES" (without quotes) if it is possible to perform a transformation of the array $$$a$$$, so that the resulting array is equal to $$$b$$$. Print "NO" (without quotes) otherwise. You can print each letter in any case (upper or lower).
standard output
PASSED
b31073f749a7d5b5522e9de90e79a550
train_109.jsonl
1636869900
You are given two arrays of integers $$$a_1, a_2, \ldots, a_n$$$ and $$$b_1, b_2, \ldots, b_n$$$.Let's define a transformation of the array $$$a$$$: Choose any non-negative integer $$$k$$$ such that $$$0 \le k \le n$$$. Choose $$$k$$$ distinct array indices $$$1 \le i_1 &lt; i_2 &lt; \ldots &lt; i_k \le n$$$. Add $$...
256 megabytes
import java.util.*; import java.io.*; public class C { public static void main(String[] args) { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int t = sc.nextInt(); for (; t > 0; t--) { int n = sc.nextInt(); int[] a = new int[n]; int[] b = new int[n]; for (i...
Java
["3\n3\n-1 1 0\n0 0 2\n1\n0\n2\n5\n1 2 3 4 5\n1 2 3 4 5"]
1 second
["YES\nNO\nYES"]
NoteIn the first test case, we can make the following transformation: Choose $$$k = 2$$$. Choose $$$i_1 = 1$$$, $$$i_2 = 2$$$. Add $$$1$$$ to $$$a_1$$$ and $$$a_2$$$. The resulting array is $$$[0, 2, 0]$$$. Swap the elements on the second and third positions. In the second test case there is no suitable transformat...
Java 8
standard input
[ "greedy", "math", "sortings" ]
6ca98e655007bfb86f1039c9f096557e
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Descriptions of test cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of arrays $$$a$$$ and $$$b$$$. The second line of each test case contains $$$n$$$ ...
900
For each test case, print "YES" (without quotes) if it is possible to perform a transformation of the array $$$a$$$, so that the resulting array is equal to $$$b$$$. Print "NO" (without quotes) otherwise. You can print each letter in any case (upper or lower).
standard output
PASSED
bf70fd418dd799e800d2414d5f356669
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.io.DataInputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; public class Main { private static void run() throws IOException { int n, m; n = in.nextInt(); m = in.nextInt(); int size = n * m; int ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 17
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
239f0d4e77330e0bbd23f4baeac9fce4
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.Random; public class ColoringRectangles { public static void main(String[] args) { ContestScanner scanner = new ContestScanner(); int tests = scanner.nextInt(); for (int i = 0; i < tests; i++) { int n = scanner.nextInt(); int m = scanner.nextInt();...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
efcf0250bca7b8fec88945347fe62bad
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.Scanner; /** * * @author eslam */ public class JavaApplication1025 { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner input = new Scanner(System.in); int t = input.nextInt(); while(t-->0){ ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
9da79791713b628572d166f2f80fee7a
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.*; public class ColouringRectangle1584B { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); for(int test=1;test<=t;test++) { int n=sc.nextInt(); int m=sc.nextInt(); int mf=0,nf=0; if(m%3==0) { mf=(m...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
9b685d18809e6c0959046a4153d15152
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.io.*; import java.util.*; public class B_Coloring_Rectangles { public static void main(String args[]) throws IOException { Scanner sc = new Scanner(System.in); ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
3ed8bd41a458b1df1986da6dfc95a828
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
// ceil using integer division: ceil(x/y) = (x+y-1)/y import java.util.*; import java.lang.*; import java.io.*; public class practice { public static void main(String[] args) throws IOException { Reader.init(System.in); BufferedWriter output = new BufferedWriter( new Outp...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
d5093db1546cfbf2b726c5eca2034bb0
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.Scanner; public class ColoringRectangles { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t-- > 0) { int n = sc.nextInt(); int m = sc.nextInt(); if ((n * m) % 3 == 0)...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
dcab5e37aaba6265a142f5c6c187dbb6
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import static java.lang.Math.max; import static java.lang.Math.min; import static java.lang.Math.abs; import static java.lang.System.out; import java.io.*; import java.util.*; public class B_Coloring_Rectangles { public static void main(String[] args) { FastScanner fs=new FastScanner(); ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
c525e656acdcbf2f25474afcbe2436f4
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.*; import java.io.*; public class Hello { public static void main(String[] args) { Scanner in = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int t = in.nextInt(); for (int tt = 0; tt < t; tt++) { int a = in.next...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
d3891f9cf9effcdb9c642e06f3b42525
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import static java.lang.Math.max; import static java.lang.Math.min; import static java.lang.Math.abs; import java.util.*; import java.io.*; import java.math.*; public class B_Coloring_Rectangles { public static void main(String[] args) { OutputStream outputStream = System.out; Print...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
718b436bad5d92a02093f41628f2ed63
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import static java.lang.Math.max; import static java.lang.Math.min; import static java.lang.Math.abs; import java.util.*; import java.io.*; import java.math.*; public class B_Coloring_Rectangles { public static void main(String[] args) { OutputStream outputStream = System.out; Print...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
e8954f370fe6543005701e3028eb6b1b
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
/*LoudSilence*/ import java.io.*; import java.util.*; import static java.lang.Math.*; public class Solution { /*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ static FastScanne...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
6ae5fd653b31e7b34e8a2cd174c0b350
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import static java.lang.Integer.parseInt; import static java.lang.Long.parseLong; import static java.lang.Math.max; import static java.lang.System.exit; import static java.util.Arrays.fill; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter;...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
f900c362c065aae092e12c5b8a62bcee
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.*; import java.io.*; public class Solution{ static BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); static BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(System.out)); static StringTokenizer st; static final long mod=1000000007; publi...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
6f49d2624adb5c2f90763c3ff9adeffa
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.io.*; import java.util.*; public class Main { static Kattio io; static long mod = 998244353, inv2 = 499122177; static { io = new Kattio(); } public static void main(String[] args) throws IOException { int t = io.nextInt(); for (int i = 0; i < t; i++) { ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
1cfab349d51d57fa7ac87d6d2c2b1453
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for (int tc = 0; tc < t; ++tc) { int n = sc.nextInt(); int m = sc.nextInt(); System.out.println(solve(n, m)); } sc.close(); } ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
e25eeecb77c565be3fcd0761fd780fe7
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.Scanner; public class B1584 { private static Scanner sc = new Scanner(System.in); public static void main(String[] args) { long testCases; testCases = sc.nextLong(); for (int i = 0; i < testCases; i++) { long n = sc.nextLong(); long m ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
5e50c2cfa33a6f73ad86220cdad5f524
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Codechef { static class Pair { int i; int j; Pair(int i,int j) { ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
93b983d1f0836efe69cd226506fce1e3
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.*; public class Solution { public static void main(String... args) throws Exception { Scanner scan = new Scanner(System.in); int t = scan.nextInt(); while (t-- > 0) { solve(scan); } }...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
c689bdbc4e5faa1d5ec92f0f47faecf6
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.io.*; import java.util.*; public class Checking { static FastScanner fs; static FastWriter fw; static boolean checkOnlineJudge = System.getProperty("ONLINE_JUDGE") == null; private static final int[][] kdir = new int[][]{{-1, 2}, {-2, 1}, {-2, -1}, {-1, -2}, {1, -2}, {2, -1}, {2,...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
55c05caba9428f1309a434f8134f6271
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.io.*; import java.util.StringTokenizer; public class coloringRectangles { public static void main(String[] args) throws IOException { Reader r = new Reader(); int t = r.nextInt(); int[] answers = new int[t]; int min1, min2; int n, m; for (int i ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
46b209048f5c9a026128d61270d2f6e7
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.*; import java.io.*; public class practice { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(new BufferedWriter(new PrintWriter(System.out))); S...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
f858151e722fab8ac5d790cefcdb7317
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { FastReader sc = new FastReader(); PrintWriter writer = new PrintWriter(System.out); int t = sc.nextInt(); while(t-->0) { int n = sc.nextInt()...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
49193188df1a53a01739f028ccda373e
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.io.*; import java.lang.Math; import java.lang.reflect.Array; import java.util.*; import javax.swing.text.DefaultStyledDocument.ElementSpec; public final class Solution { static BufferedReader br = new BufferedReader( new InputStreamReader(System.in) ); static BufferedWriter bw = new B...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
68ee96f63c0502f693cef89ed38462c0
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.io.*; import java.util.*; public class Q1584B { static int mod = (int) (1e9 + 7); static void solve() { long n = l(); long m = l(); if((n*m)%3==0){ System.out.println((n*m)/3); }else{ System.out.println(((n*m)/3)+1); } ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
01d0c95a5dff87fe99efda8da8e8ab2e
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.Scanner; public class _1584B { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for (int i=1;i<=t;i++) { int n = sc.nextInt(); int m = sc.nextInt(); int prod = m*n; if(prod<8) { ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
52a5db41fb45a318a16aa803285ec505
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner scn = new Scanner(System.in); int t = scn.nextInt(); while(t-->0){ int n = scn.nextInt(); int m = scn.nextInt(); int ans = (int)Math.ceil((double) n*m/3); System....
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
e4cc91098eb4c7b9c0b4e1f64f588671
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.*; import java.io.*; public class c5{ static class Pair{ int first; int last; public Pair(int first , int last){ this.first = first; this.last = last; } public int getFirst(){ return first; }...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
ac2020ce6cc640ef4235a542c1db483c
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
//import java.lang.reflect.Array; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.Deque; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
f23a0d5d49449bc738c307bb55decb10
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; import java.util.Arrays; public class Main { static void merge(int[] a, int l, int mid, int r) { int p1 = l, p2 = mid + 1, size = r-l+1; ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
b9aa8b48a5866ea1e02b8e98fb929391
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
/****************************************************************************** Online Java Compiler. Code, Compile, Run and Debug java program online. Write your code in this editor and press "Run" button to execute it. *****************************************************...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
23228d34fb4c058d33688744b50ba531
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Main { public static void main (String[] args) throws java.lang.Exception { // your code goes here Scanner...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
47ac86feb6a47156e1889b99ef36a302
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class B { public static void main(String[] args) throws java.lang.Exception { try { FastReader sc = new FastReader(); int t = sc.nextInt(); u: while (t-- > 0) { int n = sc.nextInt(); int m=sc.nextInt(); if(n...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
8a6eb5d6794ccfb0b06d63bc60c5874c
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.*; public class Solution{ static Scanner sc = new Scanner(System.in); public static void main(String[] a) { int testCases = sc.nextInt(); long t1 = System.currentTimeMillis(); for(int i=1; i<=testCases; i++){ solve(); } if (Sy...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
ef6100ccf1f6385c83b172f5cd7a41bf
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Codeforces { static long mod = 1_000_000__007; public static void main(String[] args) { FastReader fastReader = new FastReader(); int t = fastReader.nextInt()...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
aa4c18f6cad740eff5bd62f4d3112c87
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.*; public class class355 { public static void main(String arg[]) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { int n=sc.nextInt(); int m=sc.nextInt(); int val=(int)Math.ceil((double)(n*m)/3); System.out.println(val); } } }
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
23175bfe3504a27270ef2142dff31b63
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class test{ public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader br = new BufferedReader(new InputSt...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
4b7aaf17ea1e93351e88a58e6e66be92
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.*; public class Main { static Scanner sc = new Scanner (System.in); public static void main(String[] args) { int test = sc.nextInt(); for ( int i=0; i<test; i++){ long a = sc.nextInt(); long b = sc.nextInt(); long c = a*b; ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
935231d5e3592369a7183bfe7dcbd3b9
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Codechef { public static void main (String[] args) throws java.lang.Exception { Scanner in = new Scanner(Syste...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
48fada63259b837611b4aff6b643df20
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
/*LoudSilence*/ import java.io.*; import java.util.*; import static java.lang.Math.*; public class Solution { /*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ static FastScanne...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
ca4a0aa270b65ab8730758686114f4be
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
// 🔥🔥🔥🔥 Author: Aman Bhatt (Codeforces Handle: bhattaman0001) 🔥🔥🔥🔥 // import java.io.*; import java.util.*; public class Practice extends PrintWriter { Practice() { super(System.out); } static Scanner sc = new Scanner(System.in); public static boolean isSquare(int n) { int sqrt ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
3e94e3bbac122b6c93046771f4c8a728
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.*; public class class355 { public static void main(String arg[]) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { int n=sc.nextInt(); int m=sc.nextInt(); int val=(int)Math.ceil((double)(n*m)/3); System.out.println(val); } } }
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
eefdaecac34584a5888ff142d03cbb62
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.*; import java.math.BigInteger; public class CodeforcesRound753 { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc= new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { int n=sc.nextInt(); int m=sc.nextInt(); ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
3d4e621b1d1cb324c51cfa43ce9f22a1
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
/*package whatever //do not write package name here */ import java.util.*; import java.io.*; public class main { public static void main (String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int i=0; while(i<n) { double a = in.nextInt(); ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
147637a0e58a0c53d72a1b72dfe84ae4
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
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 x = sc.nextInt(); int y = sc.nextInt(); int ans = (int)Math.ceil((x*y)/3....
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
c7789acd144370ee10246862f612bb82
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Main { public static void main (String[] args) throws java.lang.Exception { Scanner S=new Scanner(System.in);...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
de76b0977e5d8586520ba97f313f7faa
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
/* AUTHOR-> HARSHIT AGGARWAL CODEFORCES HANDLE-> @harshit_agg FROM-> MAHARAJA AGRASEN INSTITUE OF TECHNOLOGY >> YOU CAN DO THIS << */ import java.util.*; import java.io.*; public class colouringrectangles { public static void main(String[] args) throws Exception { int t = scn.nextInt(); ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
e861936a1a4dab772a0d3f15e107cc97
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner scn = new Scanner(System.in); int t = scn.nextInt(); for(int k=0;k<t;k++){ int n = scn.nextInt(); int m = scn.nextInt(); if(n%3==0){ ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
d377be849b5544ac61337dc9bd3685de
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.Scanner; public class B_Coloring_Rectangles{ public static void main(String[] args) { Scanner scan = new Scanner(System.in); int t = scan.nextInt(); while(t-->0){ int rowSize = scan.nextInt(); int columnSize = scan.nextInt(); i...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
ccbd13709835bf717f778370a8441561
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.io.IOException; import java.io.InputStreamReader; import java.io.BufferedReader; public class coloringRectangle { public static void main(String args[]) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); whil...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
6cda989a690a9c7d98e1cd06c393eb43
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
//1584B import java.util.*; public class Coloring_Rectangle { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); for(int i=1;i<=t;i++) { String s[]=(sc.next()+sc.nextLine()).split(" "); int n=Integer....
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
2ef514fd394d286fa56647c87c07e7be
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.*; import java.io.*; public class Main { static long mod = 1000000007; static long max ; static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); public static void main(String[] args) throws IOException { FastReader sc = new FastReader(); int t = sc.nextIn...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
ae2803fa1a3a02e241a8c9d0df0b305e
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.*; public class Test { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t-- != 0) { int n = sc.nextInt(); int m = sc.nextInt(); long area = (m * n); int ans...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
b759a48eaf0d33641338bdf68aff74da
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.*; import javax.swing.plaf.synth.SynthSplitPaneUI; import java.lang.*; public class B_Coloring_Rectangles{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0){ int n=sc.nextInt(); int m=sc.nextInt()...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
61cc599f5ecc75ac65154035000ab25a
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.*; public class Solution{ public static void main(String[] args){ Scanner in=new Scanner(System.in); int t=in.nextInt(); for(int i=0;i<t;i++){ int n=in.nextInt(); int m=in.nextInt(); if(n*m%3==0){ System.out.println(n*m/3); ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
699916d2256f4fd6b73eac073bbff800
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
7f712b467f9278c325cc12776dc6a733
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class Main { static BufferedReader rd = new BufferedReader(new InputStreamReader(System.in)); static BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(System.out)); static StringTokenizer tok; static StringBuilder ou...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
599a13db391ed07651df67aa3a54c3d8
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
//package currentContest; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Random; import java.util.StringTokeniz...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
3d2018054b5bd988e4d1546523f014db
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.*; import java.io.*; public class Practice { static boolean multipleTC = true; FastReader in; PrintWriter out; static int mod = 1000000007; public static void main(String[] args) throws Exception { new Practice().run(); } void run() throws Exception { in = new FastReader(); out = new P...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
6f8c849d9d5a9063fb7fe0f74d4032ee
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.io.*; public class MyClass { public static void main(String args[])throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int t=Integer.parseInt(br.readLine()); while(t-->0){ String s[]=br.readLine().split(" "); ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
d58305612e3f13b964ae5a5c08762681
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
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 x = sc.nextInt(); int y = sc.nextInt(); int ans = (int)Math.ceil((x*y)/...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
1f0cbadb2f93268a4e5a0674a3aa8fbe
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
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 x = sc.nextInt(); int y = sc.nextInt(); int ans = (int)Math.ceil((x*y)/3.0); ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
aa43c149ac48ab559ad9fc94daa8039e
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { int n=sc.nextInt(); int m=sc.nextInt(); if((n*m)...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
fca5f1b991801b3c4e217e7b84c1c6ba
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.math.BigInteger; import java.util.*; public class Main { static class Pair { int l,r; public Pair(int l,int r) { this.l=l; this.r=r; } } static int mod=1000000007; public ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
68f23a9834a1b23d18141679a3dc6ba5
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.HashMap; import java.util.Set; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.StringTokenizer; import java.util.TreeSet; public class B_Coloring_...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
8e55a10ea6e0ea8064043b37b7d89e41
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.io.*; import java.util.*; public class Solution { static PrintWriter out = new PrintWriter((System.out)); static Kioken sc = new Kioken(); public static void main(String[] args) { int t = 1; t = sc.nextInt(); while (t-- > 0) { solve(); } out.close(); } ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
2b107b05bf454ad42053f12d3843b52f
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.io.*; import java.util.Locale; import java.util.StringTokenizer; public class B { private void solve() { int n = readInt(); for (int i = 0; i < n; i++) { int height = readInt(); int width = readInt(); int square = height * width; ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
4f5e0298ad7e7ad662b5217ef6af49a6
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class GG { public static int vv(int a, int b){ if (b==1){ if (a%3==0) return a/3; else return a/3+1; } else { if (a==2 && b==2) return...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 11
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
9d0cdf5bb0eb953b73444d21f2744c46
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.*; import java.io.*; public class B { public static void main(String[] args) throws IOException { Reader sc = new Reader(); PrintWriter out = new PrintWriter(System.out); int t = sc.nextInt(); while(t-- > 0) { int n = sc.nextInt(), m = sc.nextInt(...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 8
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
3dcfab023ecc2cbbe1a740c85e4685d2
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.io.*; import java.util.*; public class A { public static long gcd(long a, long b) { return a == 0 ? b : gcd(b, a % b); } public static void print(int[] a) { PrintWriter out = new PrintWriter(System.out); for (int i = 0; i < a.length; i++) { out.print(a[i] + " "); } out.println...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 8
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
4fc93cf7a3b5591cb69b30d352e29b8f
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.*; public class ColoringRectrangle { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { int n=sc.nextInt(); int m=sc.nextInt(); System.out.println((int)Math.ceil((n*m)/3.0));...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 8
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
5b5d977e8e2ea26802ba98d8ab562d4b
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.*;import java.io.*;import java.math.*; public class CF1584B { static boolean memory = true; static long mod = 998244353; static long MOD = 1000000007; static void ruffleSort(int[] a) { int n = a.length; ArrayList<Integer> lst = new ArrayList<>(); ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 8
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
eec1da0b63ebc4ebf7847ea45dcf1913
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner s=new Scanner(System.in); int t=s.nextInt(); while(t-->0) { int n=s.nextInt(); int m=s.nextInt(); System.out.println(func(n,m)); } } public static int func(int n,int m) { if(n*m%3!=0) ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 8
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
25804f8d7a307669691290c3a87467e8
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.*; public class ColouringRectangles { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); int out[] = new int[t]; for(int i = 0; i<t; i++) { int n = sc.nextInt(); int m = sc.nextInt()...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 8
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
6b848e7085fdc2bed9765d337265acfe
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.*; public class ColouringRectangles { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); int out[] = new int[t]; for(int i = 0; i<t; i++) { int n = sc.nextInt(); int m = sc.nextInt()...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 8
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
57e8e823adb8cd9fee918e763f8aa10a
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static class Pair implements Comparable < Pair > { int d; int i; Pair(int d, int i) { this.d = d; this.i = i; } public int compareTo(Pair o) { return this.d - o.d; ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 8
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
1bb4111ce5d01aeb5d1400dfd2d05e56
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.Scanner; public class Problem1584B { public static Scanner scanner = new Scanner(System.in); public static void main(String[] args) { int tc = scanner.nextInt(); while (tc-->0) { int row = scanner.nextInt(); int column = scanner.nextInt(); ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 8
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
fc58f97c6c9b6a86aa1e3915bc9ae0de
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); while(t-- > 0){ String[] s = br.readLine().split(" "); ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 8
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
b3f9ee3a3ad26e0d93b105dff6c51ad8
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader( ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 8
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
04f4a86e51374003b5c2e7073101bb1e
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.*; import java.io.*; import java.math.BigInteger; //code by tishrah_ public class _practise { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 8
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
186f6db6009e88f04277cc5f13784135
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { new Thread(null, () -> new Main().run(), "1", 1 << 23).start(); } private void run() { FastReader scan = new FastReader(); PrintWriter out = new PrintWriter(System.out); ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 8
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
91d8e2d8644103de9fc39ff9ec2ad2b1
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
// package CP; import java.util.*; public class Practice { static long pow(long a, long b) { if (b == 0) { return 1; } long ans = 0L; if (b % 2 == 0) { long val = pow(a, b / 2); ans += val * val; } else { lo...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 8
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
591c970d3ad246c2e6e594e6983e9c0e
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.io.*; import java.util.*; public class ColoringRectangles { public static void main(String[] args) { new ColoringRectangles().run(); } BufferedReader br; PrintWriter out; long mod = (long) (1e9 + 7), inf = (long) (3e18); class pair { int F, S; ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 8
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
1dce5ae5d9c3c50d351c36f5d1dcfb33
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.*; public class practice2 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0){ long n=sc.nextInt(); long k=sc.nextInt(); System.out.println(((n*k)+2)/3); } } }...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 8
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
18fed8e5c9f2c4f78608f801e1876984
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.Scanner; public class ColoringRectangles { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(),x=0; for (int i=0;i<t;i++){ int n=sc.nextInt(),m=sc.nextInt(); x=n*m; if (x%3==0){ ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 8
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
68c99b22fd6078cf5a45cad80f957551
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.*; public class Solution{ static Scanner sc = new Scanner(System.in); public static void main(String args[]){ int t = sc.nextInt(); while(t-- > 0){ int n = sc.nextInt(), m = sc.nextInt(); if((n == 1 || n == 2) && (m == 1 || m == 2)){ ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 8
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
914de8934e48f688cd6dfca12470a849
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
/*package whatever //do not write package name here */ import java.io.*; import java.util.*; import java.lang.*; public class GFG { public static void main (String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); int i = 0; while (i< t){ double n = in.nextDouble(); ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 8
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
50817cd36bcd5506384448b090dd8103
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.Scanner; /** * * @author Acer */ public class ColoringRectangles { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int T = sc.nextInt(); while(T-- > 0){ int n = sc.nextInt(); int m = sc.nextInt(); ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 8
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
a5ae8d13ebb8630db702a19428e64d08
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
//---#ON_MY_WAY--- import static java.lang.Math.*; import java.io.*; import java.math.*; import java.util.*; public class apples { static class pair { int x, y; public pair(int a, int b) { x = a; y = b; } } static FastReader x = new FastReader(); static OutputStream outputStream = Sy...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 8
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
4dd61c38e3bf51bdcf269086ad52ebc9
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.io.*; import java.util.*; public class Coloring_Regtangles{ public static void main(String[] args) throws IOException{ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); for(int i = 0; i<N; i++){ int a = sc.nextInt(); int b = sc.nextInt()...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 8
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
5e4887030155f331dcd1e2597ba68927
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.util.Scanner; public class CodeForces_1584B { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int numTestcases = sc.nextInt(); while(numTestcases-->0){ int n = sc.nextInt(); int m = sc.nextInt(); if(m>n...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 8
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
59b37d6a490bdf68c0a34ace314c1b11
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.io.*; import java.util.*; import java.util.StringTokenizer; public class Coloring_Rectangles { static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; public Rea...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 8
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
d84b516dc6a883e7b3a61d029879b15c
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.io.*; import java.util.*; public class B { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int t = sc.nextInt(); while (t-- > 0) { int n = sc.nextInt(), m = sc.nextInt(); int nm = n*m; ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 8
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
2ed1049a124cf257ebe5100e103d2bb7
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.io.*; import java.util.*; public class B { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int t = sc.nextInt(); while (t-- > 0) { int n = sc.nextInt(), m = sc.nextInt(); out.println((in...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 8
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
2c4ed44d02196cb48162ce138e33e4ca
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.*; import java.lang.Math; import java.util.StringTokenizer; public class twentysix { public static void main(String[] args){ int a[][], b, t; String str; ...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 8
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output
PASSED
86f28cd367e46b2a925dc9646367187a
train_109.jsonl
1636869900
David was given a red checkered rectangle of size $$$n \times m$$$. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along the grid lines. He can do this operation as many times as he wants.As a result, he will get a set of rectangles. Recta...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class B { static FastScanner fs=new FastScanner(); static void solve() { int n=fs.nextInt(); int m=fs.nextInt(); long S=n*m+2; System.out.println(S/3); } p...
Java
["4\n1 3\n2 2\n2 5\n3 5"]
1 second
["1\n2\n4\n5"]
NoteThe following pictures show how the initial rectangle can be split and cells colored blue.In the first test case: In the second test case: In the third test case: In the fourth test case:
Java 8
standard input
[ "greedy", "math" ]
70a0b98f2bb12990a0fa46aaf13134af
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The next lines contain descriptions of test cases. The only line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n, m \leq 3 \cdot 10^4$$$, $$$n \cdot m \geq 2$$$).
1,000
For each test case print a single integer — the minimum number of cells David will have to paint blue.
standard output