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
5ab31cfb91d1a8e38e2765611d78ce58
train_002.jsonl
1490625300
There are n cities situated along the main road of Berland. Cities are represented by their coordinates — integer numbers a1, a2, ..., an. All coordinates are pairwise distinct.It is possible to get from one city to another only by bus. But all buses and roads are very old, so the Minister of Transport decided to build...
256 megabytes
import java.util.*; public class NewRoute { public static void main(String args[]) { Scanner ob=new Scanner(System.in); int n=ob.nextInt(); Long a[]=new Long[n]; for(int i=0;i<n;i++) a[i]=ob.nextLong(); Arrays.sort(a); int s=0; long min=Integer.MAX_VALUE; for(int i=0;i<n-1;i++) { if(Math.abs(...
Java
["4\n6 -3 0 4", "3\n-2 0 2"]
1 second
["2 1", "2 2"]
NoteIn the first example the distance between the first city and the fourth city is |4 - 6| = 2, and it is the only pair with this distance.
Java 8
standard input
[ "implementation", "sortings" ]
5f89678ae1deb1d9eaafaab55a64197f
The first line contains one integer number n (2 ≤ n ≤ 2·105). The second line contains n integer numbers a1, a2, ..., an ( - 109 ≤ ai ≤ 109). All numbers ai are pairwise distinct.
1,100
Print two integer numbers — the minimal distance and the quantity of pairs with this distance.
standard output
PASSED
f0d6a13f300821edb2a7ebb2eabcf0fa
train_002.jsonl
1490625300
There are n cities situated along the main road of Berland. Cities are represented by their coordinates — integer numbers a1, a2, ..., an. All coordinates are pairwise distinct.It is possible to get from one city to another only by bus. But all buses and roads are very old, so the Minister of Transport decided to build...
256 megabytes
//package TIM; import java.io.*; import java.lang.*; import java.math.*; import java.util.*; public class NewRoute { static Scanner input = new Scanner(System.in); static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static PrintWriter pw = new PrintWriter(System.out); p...
Java
["4\n6 -3 0 4", "3\n-2 0 2"]
1 second
["2 1", "2 2"]
NoteIn the first example the distance between the first city and the fourth city is |4 - 6| = 2, and it is the only pair with this distance.
Java 8
standard input
[ "implementation", "sortings" ]
5f89678ae1deb1d9eaafaab55a64197f
The first line contains one integer number n (2 ≤ n ≤ 2·105). The second line contains n integer numbers a1, a2, ..., an ( - 109 ≤ ai ≤ 109). All numbers ai are pairwise distinct.
1,100
Print two integer numbers — the minimal distance and the quantity of pairs with this distance.
standard output
PASSED
fad9b1316d167d8e0250c04e1329cc11
train_002.jsonl
1490625300
There are n cities situated along the main road of Berland. Cities are represented by their coordinates — integer numbers a1, a2, ..., an. All coordinates are pairwise distinct.It is possible to get from one city to another only by bus. But all buses and roads are very old, so the Minister of Transport decided to build...
256 megabytes
import java.util.*; public class NewRoute { public static void main(String args[]) { Scanner ob=new Scanner(System.in); int n=ob.nextInt(); Long a[]=new Long[n]; for(int i=0;i<n;i++) a[i]=ob.nextLong(); java.util.Arrays.sort(a); int s=0; long min=Integer.MAX_VALUE; for(int i=0;i<n-1;i++) { if...
Java
["4\n6 -3 0 4", "3\n-2 0 2"]
1 second
["2 1", "2 2"]
NoteIn the first example the distance between the first city and the fourth city is |4 - 6| = 2, and it is the only pair with this distance.
Java 8
standard input
[ "implementation", "sortings" ]
5f89678ae1deb1d9eaafaab55a64197f
The first line contains one integer number n (2 ≤ n ≤ 2·105). The second line contains n integer numbers a1, a2, ..., an ( - 109 ≤ ai ≤ 109). All numbers ai are pairwise distinct.
1,100
Print two integer numbers — the minimal distance and the quantity of pairs with this distance.
standard output
PASSED
c04880de7cb3faedd5b14fab0064ebc0
train_002.jsonl
1490625300
There are n cities situated along the main road of Berland. Cities are represented by their coordinates — integer numbers a1, a2, ..., an. All coordinates are pairwise distinct.It is possible to get from one city to another only by bus. But all buses and roads are very old, so the Minister of Transport decided to build...
256 megabytes
import java.io.*; import java.util.*; public class NewRoute { static Scanner input = new Scanner(System.in); static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static PrintWriter pw = new PrintWriter(System.out); public static void main(String args[]) { int n = i...
Java
["4\n6 -3 0 4", "3\n-2 0 2"]
1 second
["2 1", "2 2"]
NoteIn the first example the distance between the first city and the fourth city is |4 - 6| = 2, and it is the only pair with this distance.
Java 8
standard input
[ "implementation", "sortings" ]
5f89678ae1deb1d9eaafaab55a64197f
The first line contains one integer number n (2 ≤ n ≤ 2·105). The second line contains n integer numbers a1, a2, ..., an ( - 109 ≤ ai ≤ 109). All numbers ai are pairwise distinct.
1,100
Print two integer numbers — the minimal distance and the quantity of pairs with this distance.
standard output
PASSED
39ef8c3b274a1d66fefe2ac0940f2481
train_002.jsonl
1490625300
There are n cities situated along the main road of Berland. Cities are represented by their coordinates — integer numbers a1, a2, ..., an. All coordinates are pairwise distinct.It is possible to get from one city to another only by bus. But all buses and roads are very old, so the Minister of Transport decided to build...
256 megabytes
//package TIM; import java.io.*; import java.lang.*; import java.math.*; import java.util.*; public class Main { static Scanner input = new Scanner(System.in); static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static PrintWriter pw = new PrintWriter(System.out); publi...
Java
["4\n6 -3 0 4", "3\n-2 0 2"]
1 second
["2 1", "2 2"]
NoteIn the first example the distance between the first city and the fourth city is |4 - 6| = 2, and it is the only pair with this distance.
Java 8
standard input
[ "implementation", "sortings" ]
5f89678ae1deb1d9eaafaab55a64197f
The first line contains one integer number n (2 ≤ n ≤ 2·105). The second line contains n integer numbers a1, a2, ..., an ( - 109 ≤ ai ≤ 109). All numbers ai are pairwise distinct.
1,100
Print two integer numbers — the minimal distance and the quantity of pairs with this distance.
standard output
PASSED
768d6315a48ca240233b618deba60109
train_002.jsonl
1490625300
There are n cities situated along the main road of Berland. Cities are represented by their coordinates — integer numbers a1, a2, ..., an. All coordinates are pairwise distinct.It is possible to get from one city to another only by bus. But all buses and roads are very old, so the Minister of Transport decided to build...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); Integer[] a = new Integer[n]; for (int i = 0; i < n; i++) a[i] = sc.nextInt(); Arrays.sort(a); int min = Integer.MAX_VALUE; for (int ...
Java
["4\n6 -3 0 4", "3\n-2 0 2"]
1 second
["2 1", "2 2"]
NoteIn the first example the distance between the first city and the fourth city is |4 - 6| = 2, and it is the only pair with this distance.
Java 8
standard input
[ "implementation", "sortings" ]
5f89678ae1deb1d9eaafaab55a64197f
The first line contains one integer number n (2 ≤ n ≤ 2·105). The second line contains n integer numbers a1, a2, ..., an ( - 109 ≤ ai ≤ 109). All numbers ai are pairwise distinct.
1,100
Print two integer numbers — the minimal distance and the quantity of pairs with this distance.
standard output
PASSED
60d5800d4bc15eb332a2ecdc0af9a136
train_002.jsonl
1490625300
There are n cities situated along the main road of Berland. Cities are represented by their coordinates — integer numbers a1, a2, ..., an. All coordinates are pairwise distinct.It is possible to get from one city to another only by bus. But all buses and roads are very old, so the Minister of Transport decided to build...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; public class A{ public static void main(String[] args) { FastScanner scan = new FastScanner(); PrintWriter out = new PrintWriter(Syst...
Java
["4\n6 -3 0 4", "3\n-2 0 2"]
1 second
["2 1", "2 2"]
NoteIn the first example the distance between the first city and the fourth city is |4 - 6| = 2, and it is the only pair with this distance.
Java 8
standard input
[ "implementation", "sortings" ]
5f89678ae1deb1d9eaafaab55a64197f
The first line contains one integer number n (2 ≤ n ≤ 2·105). The second line contains n integer numbers a1, a2, ..., an ( - 109 ≤ ai ≤ 109). All numbers ai are pairwise distinct.
1,100
Print two integer numbers — the minimal distance and the quantity of pairs with this distance.
standard output
PASSED
23c9e0a4d958b9175b5c88b99e42affb
train_002.jsonl
1490625300
There are n cities situated along the main road of Berland. Cities are represented by their coordinates — integer numbers a1, a2, ..., an. All coordinates are pairwise distinct.It is possible to get from one city to another only by bus. But all buses and roads are very old, so the Minister of Transport decided to build...
256 megabytes
import java.io.*; import java.util.*; public class Main { static void sort(int arr[]){ int cnt[]=new int[(1<<16)+1]; int ys[]=new int[arr.length]; for(int j=0;j<=16;j+=16){ Arrays.fill(cnt,0); for(int x:arr){cnt[(x>>j&0xFFFF)+1]++;} for(int i=1;i<cnt.leng...
Java
["4\n6 -3 0 4", "3\n-2 0 2"]
1 second
["2 1", "2 2"]
NoteIn the first example the distance between the first city and the fourth city is |4 - 6| = 2, and it is the only pair with this distance.
Java 8
standard input
[ "implementation", "sortings" ]
5f89678ae1deb1d9eaafaab55a64197f
The first line contains one integer number n (2 ≤ n ≤ 2·105). The second line contains n integer numbers a1, a2, ..., an ( - 109 ≤ ai ≤ 109). All numbers ai are pairwise distinct.
1,100
Print two integer numbers — the minimal distance and the quantity of pairs with this distance.
standard output
PASSED
92d4cd9cc122b26a5ed2ff6efd98ebcf
train_002.jsonl
1490625300
There are n cities situated along the main road of Berland. Cities are represented by their coordinates — integer numbers a1, a2, ..., an. All coordinates are pairwise distinct.It is possible to get from one city to another only by bus. But all buses and roads are very old, so the Minister of Transport decided to build...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintStream; import java.util.PriorityQueue; import java.util.Scanner; public final class CodeForces792A { public static void main(final String... args) throws Exception { exec(new BufferedReader(new...
Java
["4\n6 -3 0 4", "3\n-2 0 2"]
1 second
["2 1", "2 2"]
NoteIn the first example the distance between the first city and the fourth city is |4 - 6| = 2, and it is the only pair with this distance.
Java 8
standard input
[ "implementation", "sortings" ]
5f89678ae1deb1d9eaafaab55a64197f
The first line contains one integer number n (2 ≤ n ≤ 2·105). The second line contains n integer numbers a1, a2, ..., an ( - 109 ≤ ai ≤ 109). All numbers ai are pairwise distinct.
1,100
Print two integer numbers — the minimal distance and the quantity of pairs with this distance.
standard output
PASSED
e509554af9e8bb23330872609926dfbf
train_002.jsonl
1490625300
There are n cities situated along the main road of Berland. Cities are represented by their coordinates — integer numbers a1, a2, ..., an. All coordinates are pairwise distinct.It is possible to get from one city to another only by bus. But all buses and roads are very old, so the Minister of Transport decided to build...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; public class A{ // test public static void main(String[] args) { FastScanner scan = new FastScanner(); PrintWriter out = new PrintWr...
Java
["4\n6 -3 0 4", "3\n-2 0 2"]
1 second
["2 1", "2 2"]
NoteIn the first example the distance between the first city and the fourth city is |4 - 6| = 2, and it is the only pair with this distance.
Java 8
standard input
[ "implementation", "sortings" ]
5f89678ae1deb1d9eaafaab55a64197f
The first line contains one integer number n (2 ≤ n ≤ 2·105). The second line contains n integer numbers a1, a2, ..., an ( - 109 ≤ ai ≤ 109). All numbers ai are pairwise distinct.
1,100
Print two integer numbers — the minimal distance and the quantity of pairs with this distance.
standard output
PASSED
4a6f2bd9b58ad5b32e7938f615d4d8f7
train_002.jsonl
1490625300
There are n cities situated along the main road of Berland. Cities are represented by their coordinates — integer numbers a1, a2, ..., an. All coordinates are pairwise distinct.It is possible to get from one city to another only by bus. But all buses and roads are very old, so the Minister of Transport decided to build...
256 megabytes
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; public class A { public static void main(String[] args) throws IOException { Reader in = new Reader(); PrintWr...
Java
["4\n6 -3 0 4", "3\n-2 0 2"]
1 second
["2 1", "2 2"]
NoteIn the first example the distance between the first city and the fourth city is |4 - 6| = 2, and it is the only pair with this distance.
Java 8
standard input
[ "implementation", "sortings" ]
5f89678ae1deb1d9eaafaab55a64197f
The first line contains one integer number n (2 ≤ n ≤ 2·105). The second line contains n integer numbers a1, a2, ..., an ( - 109 ≤ ai ≤ 109). All numbers ai are pairwise distinct.
1,100
Print two integer numbers — the minimal distance and the quantity of pairs with this distance.
standard output
PASSED
19f68fd709d90cfb94c45e4fa254025b
train_002.jsonl
1490625300
There are n cities situated along the main road of Berland. Cities are represented by their coordinates — integer numbers a1, a2, ..., an. All coordinates are pairwise distinct.It is possible to get from one city to another only by bus. But all buses and roads are very old, so the Minister of Transport decided to build...
256 megabytes
import java.io.BufferedReader; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection...
Java
["4\n6 -3 0 4", "3\n-2 0 2"]
1 second
["2 1", "2 2"]
NoteIn the first example the distance between the first city and the fourth city is |4 - 6| = 2, and it is the only pair with this distance.
Java 8
standard input
[ "implementation", "sortings" ]
5f89678ae1deb1d9eaafaab55a64197f
The first line contains one integer number n (2 ≤ n ≤ 2·105). The second line contains n integer numbers a1, a2, ..., an ( - 109 ≤ ai ≤ 109). All numbers ai are pairwise distinct.
1,100
Print two integer numbers — the minimal distance and the quantity of pairs with this distance.
standard output
PASSED
9e766e0a3dde03d99e67075028ae38e3
train_002.jsonl
1490625300
There are n cities situated along the main road of Berland. Cities are represented by their coordinates — integer numbers a1, a2, ..., an. All coordinates are pairwise distinct.It is possible to get from one city to another only by bus. But all buses and roads are very old, so the Minister of Transport decided to build...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; import java.util.HashMap; import java.util.StringTokenizer; import java.util.TreeMap; public class ECR18Div2A { public static void main(String[] args) { FastScanner in=new FastScanner(); int n=in.nextInt(); TreeMap<Intege...
Java
["4\n6 -3 0 4", "3\n-2 0 2"]
1 second
["2 1", "2 2"]
NoteIn the first example the distance between the first city and the fourth city is |4 - 6| = 2, and it is the only pair with this distance.
Java 8
standard input
[ "implementation", "sortings" ]
5f89678ae1deb1d9eaafaab55a64197f
The first line contains one integer number n (2 ≤ n ≤ 2·105). The second line contains n integer numbers a1, a2, ..., an ( - 109 ≤ ai ≤ 109). All numbers ai are pairwise distinct.
1,100
Print two integer numbers — the minimal distance and the quantity of pairs with this distance.
standard output
PASSED
2d8d45016bf65dce882626d3b64f8024
train_002.jsonl
1490625300
There are n cities situated along the main road of Berland. Cities are represented by their coordinates — integer numbers a1, a2, ..., an. All coordinates are pairwise distinct.It is possible to get from one city to another only by bus. But all buses and roads are very old, so the Minister of Transport decided to build...
256 megabytes
import java.util.Scanner; public class CodeForce11 { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); Long a[]=new Long[n]; for(int i=0;i<n;i++) a[i]=sc.nextLong(); java.util.Arrays.sort(a); int count=0; long min=Integer.MAX_VALUE; for(int i=0;i<n-1;i...
Java
["4\n6 -3 0 4", "3\n-2 0 2"]
1 second
["2 1", "2 2"]
NoteIn the first example the distance between the first city and the fourth city is |4 - 6| = 2, and it is the only pair with this distance.
Java 8
standard input
[ "implementation", "sortings" ]
5f89678ae1deb1d9eaafaab55a64197f
The first line contains one integer number n (2 ≤ n ≤ 2·105). The second line contains n integer numbers a1, a2, ..., an ( - 109 ≤ ai ≤ 109). All numbers ai are pairwise distinct.
1,100
Print two integer numbers — the minimal distance and the quantity of pairs with this distance.
standard output
PASSED
92bc7e11e72c57e354e6d779f12b7078
train_002.jsonl
1490625300
There are n cities situated along the main road of Berland. Cities are represented by their coordinates — integer numbers a1, a2, ..., an. All coordinates are pairwise distinct.It is possible to get from one city to another only by bus. But all buses and roads are very old, so the Minister of Transport decided to build...
256 megabytes
import java.util.Scanner; public class CodeForce11 { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); Long a[]=new Long[n]; for(int i=0;i<n;i++) a[i]=sc.nextLong(); java.util.Arrays.sort(a); int count=0; long min=Integer.MAX_VALUE; for(int i=0;i<n-1;i...
Java
["4\n6 -3 0 4", "3\n-2 0 2"]
1 second
["2 1", "2 2"]
NoteIn the first example the distance between the first city and the fourth city is |4 - 6| = 2, and it is the only pair with this distance.
Java 8
standard input
[ "implementation", "sortings" ]
5f89678ae1deb1d9eaafaab55a64197f
The first line contains one integer number n (2 ≤ n ≤ 2·105). The second line contains n integer numbers a1, a2, ..., an ( - 109 ≤ ai ≤ 109). All numbers ai are pairwise distinct.
1,100
Print two integer numbers — the minimal distance and the quantity of pairs with this distance.
standard output
PASSED
fda367a01a7c7e235f8fda23e1b5698b
train_002.jsonl
1490625300
There are n cities situated along the main road of Berland. Cities are represented by their coordinates — integer numbers a1, a2, ..., an. All coordinates are pairwise distinct.It is possible to get from one city to another only by bus. But all buses and roads are very old, so the Minister of Transport decided to build...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { new Main().solve(); } int inf = 2000000000; int mod = 1000000007; double eps = 0.0000000001; PrintWriter out; int n; int m; ArrayList<Integer>[] g = ne...
Java
["4\n6 -3 0 4", "3\n-2 0 2"]
1 second
["2 1", "2 2"]
NoteIn the first example the distance between the first city and the fourth city is |4 - 6| = 2, and it is the only pair with this distance.
Java 8
standard input
[ "implementation", "sortings" ]
5f89678ae1deb1d9eaafaab55a64197f
The first line contains one integer number n (2 ≤ n ≤ 2·105). The second line contains n integer numbers a1, a2, ..., an ( - 109 ≤ ai ≤ 109). All numbers ai are pairwise distinct.
1,100
Print two integer numbers — the minimal distance and the quantity of pairs with this distance.
standard output
PASSED
06df6ad4ede31bf7ef816af878a6b10a
train_002.jsonl
1490625300
There are n cities situated along the main road of Berland. Cities are represented by their coordinates — integer numbers a1, a2, ..., an. All coordinates are pairwise distinct.It is possible to get from one city to another only by bus. But all buses and roads are very old, so the Minister of Transport decided to build...
256 megabytes
import java.io.*; import java.math.*; import java.security.KeyStore.Entry; import java.util.*; public class TestClass { private static InputStream stream; private static byte[] buf = new byte[1024]; private static int curChar; private static int numChars; private static SpaceCharFilter filter; private static Prin...
Java
["4\n6 -3 0 4", "3\n-2 0 2"]
1 second
["2 1", "2 2"]
NoteIn the first example the distance between the first city and the fourth city is |4 - 6| = 2, and it is the only pair with this distance.
Java 8
standard input
[ "implementation", "sortings" ]
5f89678ae1deb1d9eaafaab55a64197f
The first line contains one integer number n (2 ≤ n ≤ 2·105). The second line contains n integer numbers a1, a2, ..., an ( - 109 ≤ ai ≤ 109). All numbers ai are pairwise distinct.
1,100
Print two integer numbers — the minimal distance and the quantity of pairs with this distance.
standard output
PASSED
5ddc43e2353b059f35357b53a92381f4
train_002.jsonl
1490625300
There are n cities situated along the main road of Berland. Cities are represented by their coordinates — integer numbers a1, a2, ..., an. All coordinates are pairwise distinct.It is possible to get from one city to another only by bus. But all buses and roads are very old, so the Minister of Transport decided to build...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; import java.util.Random; public class A { public static void main(String[] args) { // Scanner scan = new Scanner(System.in); InputReader in = new InputReader(System...
Java
["4\n6 -3 0 4", "3\n-2 0 2"]
1 second
["2 1", "2 2"]
NoteIn the first example the distance between the first city and the fourth city is |4 - 6| = 2, and it is the only pair with this distance.
Java 8
standard input
[ "implementation", "sortings" ]
5f89678ae1deb1d9eaafaab55a64197f
The first line contains one integer number n (2 ≤ n ≤ 2·105). The second line contains n integer numbers a1, a2, ..., an ( - 109 ≤ ai ≤ 109). All numbers ai are pairwise distinct.
1,100
Print two integer numbers — the minimal distance and the quantity of pairs with this distance.
standard output
PASSED
bed6292d04d3b2d76da1c077f711ebcb
train_002.jsonl
1490625300
There are n cities situated along the main road of Berland. Cities are represented by their coordinates — integer numbers a1, a2, ..., an. All coordinates are pairwise distinct.It is possible to get from one city to another only by bus. But all buses and roads are very old, so the Minister of Transport decided to build...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; import java.util.Random; public class A { public static void main(String[] args) { // Scanner scan = new Scanner(System.in); InputReader in = new InputReader(System...
Java
["4\n6 -3 0 4", "3\n-2 0 2"]
1 second
["2 1", "2 2"]
NoteIn the first example the distance between the first city and the fourth city is |4 - 6| = 2, and it is the only pair with this distance.
Java 8
standard input
[ "implementation", "sortings" ]
5f89678ae1deb1d9eaafaab55a64197f
The first line contains one integer number n (2 ≤ n ≤ 2·105). The second line contains n integer numbers a1, a2, ..., an ( - 109 ≤ ai ≤ 109). All numbers ai are pairwise distinct.
1,100
Print two integer numbers — the minimal distance and the quantity of pairs with this distance.
standard output
PASSED
f226faf7982609ffb9877a114e4e6f6c
train_002.jsonl
1490625300
There are n cities situated along the main road of Berland. Cities are represented by their coordinates — integer numbers a1, a2, ..., an. All coordinates are pairwise distinct.It is possible to get from one city to another only by bus. But all buses and roads are very old, so the Minister of Transport decided to build...
256 megabytes
import java.io.*; import java.util.*; public class A1008 { public static void main(String [] args) /*throws Exception*/ { InputStream inputReader = System.in; OutputStream outputReader = System.out; InputReader in = new InputReader(inputReader);//new InputReader(new FileInputStream(new File...
Java
["4\n6 -3 0 4", "3\n-2 0 2"]
1 second
["2 1", "2 2"]
NoteIn the first example the distance between the first city and the fourth city is |4 - 6| = 2, and it is the only pair with this distance.
Java 8
standard input
[ "implementation", "sortings" ]
5f89678ae1deb1d9eaafaab55a64197f
The first line contains one integer number n (2 ≤ n ≤ 2·105). The second line contains n integer numbers a1, a2, ..., an ( - 109 ≤ ai ≤ 109). All numbers ai are pairwise distinct.
1,100
Print two integer numbers — the minimal distance and the quantity of pairs with this distance.
standard output
PASSED
97e5b47f05e856f8485df243b6ba5426
train_002.jsonl
1490625300
There are n cities situated along the main road of Berland. Cities are represented by their coordinates — integer numbers a1, a2, ..., an. All coordinates are pairwise distinct.It is possible to get from one city to another only by bus. But all buses and roads are very old, so the Minister of Transport decided to build...
256 megabytes
//package com.rengu.AlgorithmTest; import java.io.*; import java.util.Arrays; import java.util.StringTokenizer; public class Main { FastScanner in; PrintWriter out; public void run() { in = new FastScanner(System.in); out = new PrintWriter(System.out); solve(); out.close();...
Java
["4\n6 -3 0 4", "3\n-2 0 2"]
1 second
["2 1", "2 2"]
NoteIn the first example the distance between the first city and the fourth city is |4 - 6| = 2, and it is the only pair with this distance.
Java 8
standard input
[ "implementation", "sortings" ]
5f89678ae1deb1d9eaafaab55a64197f
The first line contains one integer number n (2 ≤ n ≤ 2·105). The second line contains n integer numbers a1, a2, ..., an ( - 109 ≤ ai ≤ 109). All numbers ai are pairwise distinct.
1,100
Print two integer numbers — the minimal distance and the quantity of pairs with this distance.
standard output
PASSED
f5ab5da5c3bfea3d141a545cfa9fdbe0
train_002.jsonl
1490625300
There are n cities situated along the main road of Berland. Cities are represented by their coordinates — integer numbers a1, a2, ..., an. All coordinates are pairwise distinct.It is possible to get from one city to another only by bus. But all buses and roads are very old, so the Minister of Transport decided to build...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class a { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n =in.nextInt(); Long[] vs = new Long[n]; for(int i=0;i<n;i++) { vs[i] = in.nextLong(); } Arrays.sort(vs); long minAns = Long.MAX_VALUE; int cnt = 0;...
Java
["4\n6 -3 0 4", "3\n-2 0 2"]
1 second
["2 1", "2 2"]
NoteIn the first example the distance between the first city and the fourth city is |4 - 6| = 2, and it is the only pair with this distance.
Java 8
standard input
[ "implementation", "sortings" ]
5f89678ae1deb1d9eaafaab55a64197f
The first line contains one integer number n (2 ≤ n ≤ 2·105). The second line contains n integer numbers a1, a2, ..., an ( - 109 ≤ ai ≤ 109). All numbers ai are pairwise distinct.
1,100
Print two integer numbers — the minimal distance and the quantity of pairs with this distance.
standard output
PASSED
7169fb6685a602caa08079d461a95460
train_002.jsonl
1490625300
There are n cities situated along the main road of Berland. Cities are represented by their coordinates — integer numbers a1, a2, ..., an. All coordinates are pairwise distinct.It is possible to get from one city to another only by bus. But all buses and roads are very old, so the Minister of Transport decided to build...
256 megabytes
//package com.rengu.AlgorithmTest; import java.util.Arrays; import java.util.Scanner; public class Solution { public static void main(String[] args) { int n; Scanner input = new Scanner(System.in); n = input.nextInt(); Long arr[] = new Long[n]; for (int i = 0; i < n; i++) { arr[i] = input.nextLong(); ...
Java
["4\n6 -3 0 4", "3\n-2 0 2"]
1 second
["2 1", "2 2"]
NoteIn the first example the distance between the first city and the fourth city is |4 - 6| = 2, and it is the only pair with this distance.
Java 8
standard input
[ "implementation", "sortings" ]
5f89678ae1deb1d9eaafaab55a64197f
The first line contains one integer number n (2 ≤ n ≤ 2·105). The second line contains n integer numbers a1, a2, ..., an ( - 109 ≤ ai ≤ 109). All numbers ai are pairwise distinct.
1,100
Print two integer numbers — the minimal distance and the quantity of pairs with this distance.
standard output
PASSED
8db8569b27b25daf91a29926dcd2097d
train_002.jsonl
1490625300
There are n cities situated along the main road of Berland. Cities are represented by their coordinates — integer numbers a1, a2, ..., an. All coordinates are pairwise distinct.It is possible to get from one city to another only by bus. But all buses and roads are very old, so the Minister of Transport decided to build...
256 megabytes
//package com.rengu.AlgorithmTest; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap...
Java
["4\n6 -3 0 4", "3\n-2 0 2"]
1 second
["2 1", "2 2"]
NoteIn the first example the distance between the first city and the fourth city is |4 - 6| = 2, and it is the only pair with this distance.
Java 8
standard input
[ "implementation", "sortings" ]
5f89678ae1deb1d9eaafaab55a64197f
The first line contains one integer number n (2 ≤ n ≤ 2·105). The second line contains n integer numbers a1, a2, ..., an ( - 109 ≤ ai ≤ 109). All numbers ai are pairwise distinct.
1,100
Print two integer numbers — the minimal distance and the quantity of pairs with this distance.
standard output
PASSED
c81600304e94f294ead11df447648f3d
train_002.jsonl
1434645000
Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed triangles with the non-zero area.
512 megabytes
import java.util.TreeMap; import java.io.InputStream; import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.IOException; import java.util.Set; import java.util.StringTokenizer; /** * Built using CHelper plug-in * Actual solution is at...
Java
["4\n0 0\n1 1\n2 0\n2 2", "3\n0 0\n1 1\n2 0", "1\n1 1"]
4 seconds
["3", "1", "0"]
NoteNote to the first sample test. There are 3 triangles formed: (0, 0) - (1, 1) - (2, 0); (0, 0) - (2, 2) - (2, 0); (1, 1) - (2, 2) - (2, 0).Note to the second sample test. There is 1 triangle formed: (0, 0) - (1, 1) - (2, 0).Note to the third sample test. A single point doesn't form a single triangle.
Java 8
standard input
[ "geometry", "combinatorics", "math", "sortings", "data structures", "brute force" ]
d5913f8208efa1641f53caaee7624622
The first line contains integer n (1 ≤ n ≤ 2000) — the number of the points painted on the plane. Next n lines contain two integers each xi, yi ( - 100 ≤ xi, yi ≤ 100) — the coordinates of the i-th point. It is guaranteed that no two given points coincide.
1,900
In the first line print an integer — the number of triangles with the non-zero area among the painted points.
standard output
PASSED
997adde898ec11e5b5531367f4afdb4d
train_002.jsonl
1434645000
Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed triangles with the non-zero area.
512 megabytes
import javax.print.attribute.IntegerSyntax; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.*; public class Main { public static void solve1() { int n = IO.readInt(); int[] x = new int[n]; int[] y = new int[n]; for (int index = ...
Java
["4\n0 0\n1 1\n2 0\n2 2", "3\n0 0\n1 1\n2 0", "1\n1 1"]
4 seconds
["3", "1", "0"]
NoteNote to the first sample test. There are 3 triangles formed: (0, 0) - (1, 1) - (2, 0); (0, 0) - (2, 2) - (2, 0); (1, 1) - (2, 2) - (2, 0).Note to the second sample test. There is 1 triangle formed: (0, 0) - (1, 1) - (2, 0).Note to the third sample test. A single point doesn't form a single triangle.
Java 8
standard input
[ "geometry", "combinatorics", "math", "sortings", "data structures", "brute force" ]
d5913f8208efa1641f53caaee7624622
The first line contains integer n (1 ≤ n ≤ 2000) — the number of the points painted on the plane. Next n lines contain two integers each xi, yi ( - 100 ≤ xi, yi ≤ 100) — the coordinates of the i-th point. It is guaranteed that no two given points coincide.
1,900
In the first line print an integer — the number of triangles with the non-zero area among the painted points.
standard output
PASSED
1b052f5de89af0e6585a4458dfc0072c
train_002.jsonl
1434645000
Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed triangles with the non-zero area.
512 megabytes
// // Vanya.java // Created by Alister Estrada Cueto on 9/26/18. import java.util.*; public class Vanya{ public static void main(String[] args){ int[] x = new int[2505]; int[] y = new int[2505]; int[] a = new int[4100005]; Map<Long, Integer> hashmap = new HashMap<Long, Integer>(); Scanner sc = new Scann...
Java
["4\n0 0\n1 1\n2 0\n2 2", "3\n0 0\n1 1\n2 0", "1\n1 1"]
4 seconds
["3", "1", "0"]
NoteNote to the first sample test. There are 3 triangles formed: (0, 0) - (1, 1) - (2, 0); (0, 0) - (2, 2) - (2, 0); (1, 1) - (2, 2) - (2, 0).Note to the second sample test. There is 1 triangle formed: (0, 0) - (1, 1) - (2, 0).Note to the third sample test. A single point doesn't form a single triangle.
Java 8
standard input
[ "geometry", "combinatorics", "math", "sortings", "data structures", "brute force" ]
d5913f8208efa1641f53caaee7624622
The first line contains integer n (1 ≤ n ≤ 2000) — the number of the points painted on the plane. Next n lines contain two integers each xi, yi ( - 100 ≤ xi, yi ≤ 100) — the coordinates of the i-th point. It is guaranteed that no two given points coincide.
1,900
In the first line print an integer — the number of triangles with the non-zero area among the painted points.
standard output
PASSED
b101660159d98e02a49938b7577238d7
train_002.jsonl
1434645000
Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed triangles with the non-zero area.
512 megabytes
import java.io.IOException; import java.util.InputMismatchException; import java.util.Scanner; public class D { public static void main(String cd[]) { FasterScanner in=new FasterScanner(); int n=in.nextInt(); int x[]=new int[n]; int y[]=new int[n]; for(int i=0;i<n;i++)...
Java
["4\n0 0\n1 1\n2 0\n2 2", "3\n0 0\n1 1\n2 0", "1\n1 1"]
4 seconds
["3", "1", "0"]
NoteNote to the first sample test. There are 3 triangles formed: (0, 0) - (1, 1) - (2, 0); (0, 0) - (2, 2) - (2, 0); (1, 1) - (2, 2) - (2, 0).Note to the second sample test. There is 1 triangle formed: (0, 0) - (1, 1) - (2, 0).Note to the third sample test. A single point doesn't form a single triangle.
Java 8
standard input
[ "geometry", "combinatorics", "math", "sortings", "data structures", "brute force" ]
d5913f8208efa1641f53caaee7624622
The first line contains integer n (1 ≤ n ≤ 2000) — the number of the points painted on the plane. Next n lines contain two integers each xi, yi ( - 100 ≤ xi, yi ≤ 100) — the coordinates of the i-th point. It is guaranteed that no two given points coincide.
1,900
In the first line print an integer — the number of triangles with the non-zero area among the painted points.
standard output
PASSED
33fa04f047977bb792ebde11fd0cc930
train_002.jsonl
1434645000
Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed triangles with the non-zero area.
512 megabytes
import java.util.Scanner; public class P1 { public static void main(String [] args){ Scanner in = new Scanner(System.in); int n = in.nextInt(); double[] x = new double[n]; double[] y = new double[n]; double x1 = 0; double y1 = 0; double x2 = 0; double y2 = 0; double x3 = 0; double y3 =...
Java
["4\n0 0\n1 1\n2 0\n2 2", "3\n0 0\n1 1\n2 0", "1\n1 1"]
4 seconds
["3", "1", "0"]
NoteNote to the first sample test. There are 3 triangles formed: (0, 0) - (1, 1) - (2, 0); (0, 0) - (2, 2) - (2, 0); (1, 1) - (2, 2) - (2, 0).Note to the second sample test. There is 1 triangle formed: (0, 0) - (1, 1) - (2, 0).Note to the third sample test. A single point doesn't form a single triangle.
Java 8
standard input
[ "geometry", "combinatorics", "math", "sortings", "data structures", "brute force" ]
d5913f8208efa1641f53caaee7624622
The first line contains integer n (1 ≤ n ≤ 2000) — the number of the points painted on the plane. Next n lines contain two integers each xi, yi ( - 100 ≤ xi, yi ≤ 100) — the coordinates of the i-th point. It is guaranteed that no two given points coincide.
1,900
In the first line print an integer — the number of triangles with the non-zero area among the painted points.
standard output
PASSED
77c14919c0b78078f4fd7255590e13e6
train_002.jsonl
1434645000
Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed triangles with the non-zero area.
512 megabytes
import java.io.*; import java.util.*; public class CF { FastScanner in; PrintWriter out; class Point implements Comparable<Point> { int x, y; public Point(int x, int y) { super(); this.x = x; this.y = y; } @Override public int compareTo(Point o) { return Integer.signum(x * o.y - o.x * y); ...
Java
["4\n0 0\n1 1\n2 0\n2 2", "3\n0 0\n1 1\n2 0", "1\n1 1"]
4 seconds
["3", "1", "0"]
NoteNote to the first sample test. There are 3 triangles formed: (0, 0) - (1, 1) - (2, 0); (0, 0) - (2, 2) - (2, 0); (1, 1) - (2, 2) - (2, 0).Note to the second sample test. There is 1 triangle formed: (0, 0) - (1, 1) - (2, 0).Note to the third sample test. A single point doesn't form a single triangle.
Java 8
standard input
[ "geometry", "combinatorics", "math", "sortings", "data structures", "brute force" ]
d5913f8208efa1641f53caaee7624622
The first line contains integer n (1 ≤ n ≤ 2000) — the number of the points painted on the plane. Next n lines contain two integers each xi, yi ( - 100 ≤ xi, yi ≤ 100) — the coordinates of the i-th point. It is guaranteed that no two given points coincide.
1,900
In the first line print an integer — the number of triangles with the non-zero area among the painted points.
standard output
PASSED
eb5392cc3f9ea244dbe694748c6e9e05
train_002.jsonl
1434645000
Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed triangles with the non-zero area.
512 megabytes
import java.io.*; import java.util.*; public class CF { FastScanner in; PrintWriter out; void solve() { int n = in.nextInt(); int[] x = new int[n]; int[] y = new int[n]; for (int i = 0; i < n; i++) { x[i] = in.nextInt(); y[i] = in.nextInt(); } int ans = 0; for (int i = 0; i < n; i++) { int d...
Java
["4\n0 0\n1 1\n2 0\n2 2", "3\n0 0\n1 1\n2 0", "1\n1 1"]
4 seconds
["3", "1", "0"]
NoteNote to the first sample test. There are 3 triangles formed: (0, 0) - (1, 1) - (2, 0); (0, 0) - (2, 2) - (2, 0); (1, 1) - (2, 2) - (2, 0).Note to the second sample test. There is 1 triangle formed: (0, 0) - (1, 1) - (2, 0).Note to the third sample test. A single point doesn't form a single triangle.
Java 8
standard input
[ "geometry", "combinatorics", "math", "sortings", "data structures", "brute force" ]
d5913f8208efa1641f53caaee7624622
The first line contains integer n (1 ≤ n ≤ 2000) — the number of the points painted on the plane. Next n lines contain two integers each xi, yi ( - 100 ≤ xi, yi ≤ 100) — the coordinates of the i-th point. It is guaranteed that no two given points coincide.
1,900
In the first line print an integer — the number of triangles with the non-zero area among the painted points.
standard output
PASSED
a8da2a519d9445ab465bb2d2a2b8a657
train_002.jsonl
1434645000
Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed triangles with the non-zero area.
512 megabytes
import java.io.*; import java.util.*; public class CF { FastScanner in; PrintWriter out; class Point { int x, y; public Point(int x, int y) { super(); this.x = x; this.y = y; } } void solve() { int n = in.nextInt(); Point[] a = new Point[n]; for (int i = 0; i < n; i++) { a[i] = new Poi...
Java
["4\n0 0\n1 1\n2 0\n2 2", "3\n0 0\n1 1\n2 0", "1\n1 1"]
4 seconds
["3", "1", "0"]
NoteNote to the first sample test. There are 3 triangles formed: (0, 0) - (1, 1) - (2, 0); (0, 0) - (2, 2) - (2, 0); (1, 1) - (2, 2) - (2, 0).Note to the second sample test. There is 1 triangle formed: (0, 0) - (1, 1) - (2, 0).Note to the third sample test. A single point doesn't form a single triangle.
Java 8
standard input
[ "geometry", "combinatorics", "math", "sortings", "data structures", "brute force" ]
d5913f8208efa1641f53caaee7624622
The first line contains integer n (1 ≤ n ≤ 2000) — the number of the points painted on the plane. Next n lines contain two integers each xi, yi ( - 100 ≤ xi, yi ≤ 100) — the coordinates of the i-th point. It is guaranteed that no two given points coincide.
1,900
In the first line print an integer — the number of triangles with the non-zero area among the painted points.
standard output
PASSED
40e32939d8a12e41e539d275a8165168
train_002.jsonl
1434645000
Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed triangles with the non-zero area.
512 megabytes
import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class Vanya_Triangle { public static void main(String[] args) { // TODO Auto-generated method stub Scanner in=new Scanner(System.in); int num=in.nextInt(); int[][] points=new int[num][2]; for(int i=0;i<num;i++) { point...
Java
["4\n0 0\n1 1\n2 0\n2 2", "3\n0 0\n1 1\n2 0", "1\n1 1"]
4 seconds
["3", "1", "0"]
NoteNote to the first sample test. There are 3 triangles formed: (0, 0) - (1, 1) - (2, 0); (0, 0) - (2, 2) - (2, 0); (1, 1) - (2, 2) - (2, 0).Note to the second sample test. There is 1 triangle formed: (0, 0) - (1, 1) - (2, 0).Note to the third sample test. A single point doesn't form a single triangle.
Java 8
standard input
[ "geometry", "combinatorics", "math", "sortings", "data structures", "brute force" ]
d5913f8208efa1641f53caaee7624622
The first line contains integer n (1 ≤ n ≤ 2000) — the number of the points painted on the plane. Next n lines contain two integers each xi, yi ( - 100 ≤ xi, yi ≤ 100) — the coordinates of the i-th point. It is guaranteed that no two given points coincide.
1,900
In the first line print an integer — the number of triangles with the non-zero area among the painted points.
standard output
PASSED
3f2e1f72380d1422af0f30860927540e
train_002.jsonl
1434645000
Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed triangles with the non-zero area.
512 megabytes
import java.awt.Point; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import java.util.Scanner; public class MO { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); Point[] p = new Point[n]; for(int i=0; i<n; i++) ...
Java
["4\n0 0\n1 1\n2 0\n2 2", "3\n0 0\n1 1\n2 0", "1\n1 1"]
4 seconds
["3", "1", "0"]
NoteNote to the first sample test. There are 3 triangles formed: (0, 0) - (1, 1) - (2, 0); (0, 0) - (2, 2) - (2, 0); (1, 1) - (2, 2) - (2, 0).Note to the second sample test. There is 1 triangle formed: (0, 0) - (1, 1) - (2, 0).Note to the third sample test. A single point doesn't form a single triangle.
Java 8
standard input
[ "geometry", "combinatorics", "math", "sortings", "data structures", "brute force" ]
d5913f8208efa1641f53caaee7624622
The first line contains integer n (1 ≤ n ≤ 2000) — the number of the points painted on the plane. Next n lines contain two integers each xi, yi ( - 100 ≤ xi, yi ≤ 100) — the coordinates of the i-th point. It is guaranteed that no two given points coincide.
1,900
In the first line print an integer — the number of triangles with the non-zero area among the painted points.
standard output
PASSED
f89c8e407fa8d424af5d16f0f4a63688
train_002.jsonl
1434645000
Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed triangles with the non-zero area.
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.OutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.io.BufferedOutputStream; import java.util.StringTokenizer; import java.io.Wr...
Java
["4\n0 0\n1 1\n2 0\n2 2", "3\n0 0\n1 1\n2 0", "1\n1 1"]
4 seconds
["3", "1", "0"]
NoteNote to the first sample test. There are 3 triangles formed: (0, 0) - (1, 1) - (2, 0); (0, 0) - (2, 2) - (2, 0); (1, 1) - (2, 2) - (2, 0).Note to the second sample test. There is 1 triangle formed: (0, 0) - (1, 1) - (2, 0).Note to the third sample test. A single point doesn't form a single triangle.
Java 8
standard input
[ "geometry", "combinatorics", "math", "sortings", "data structures", "brute force" ]
d5913f8208efa1641f53caaee7624622
The first line contains integer n (1 ≤ n ≤ 2000) — the number of the points painted on the plane. Next n lines contain two integers each xi, yi ( - 100 ≤ xi, yi ≤ 100) — the coordinates of the i-th point. It is guaranteed that no two given points coincide.
1,900
In the first line print an integer — the number of triangles with the non-zero area among the painted points.
standard output
PASSED
5bff03d1d8d79229aff1014001c96c6d
train_002.jsonl
1434645000
Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed triangles with the non-zero area.
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap; import java.util.Map; public class Main { public static void main(String[] args) throws Exception { BufferedReader in = new BufferedR...
Java
["4\n0 0\n1 1\n2 0\n2 2", "3\n0 0\n1 1\n2 0", "1\n1 1"]
4 seconds
["3", "1", "0"]
NoteNote to the first sample test. There are 3 triangles formed: (0, 0) - (1, 1) - (2, 0); (0, 0) - (2, 2) - (2, 0); (1, 1) - (2, 2) - (2, 0).Note to the second sample test. There is 1 triangle formed: (0, 0) - (1, 1) - (2, 0).Note to the third sample test. A single point doesn't form a single triangle.
Java 8
standard input
[ "geometry", "combinatorics", "math", "sortings", "data structures", "brute force" ]
d5913f8208efa1641f53caaee7624622
The first line contains integer n (1 ≤ n ≤ 2000) — the number of the points painted on the plane. Next n lines contain two integers each xi, yi ( - 100 ≤ xi, yi ≤ 100) — the coordinates of the i-th point. It is guaranteed that no two given points coincide.
1,900
In the first line print an integer — the number of triangles with the non-zero area among the painted points.
standard output
PASSED
52f264eb9447bc9b7c82eaf9da4ae419
train_002.jsonl
1434645000
Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed triangles with the non-zero area.
512 megabytes
import java.util.*; import java.math.*; import java.io.*; import static java.lang.Math.*; import static java.util.Arrays.*; import static java.util.Collections.*; public class Main{ // ArrayList<Integer> lis = new ArrayList<Integer>(); // ArrayList<String> lis = new ArrayList<String>(); // PriorityQueue<P> que...
Java
["4\n0 0\n1 1\n2 0\n2 2", "3\n0 0\n1 1\n2 0", "1\n1 1"]
4 seconds
["3", "1", "0"]
NoteNote to the first sample test. There are 3 triangles formed: (0, 0) - (1, 1) - (2, 0); (0, 0) - (2, 2) - (2, 0); (1, 1) - (2, 2) - (2, 0).Note to the second sample test. There is 1 triangle formed: (0, 0) - (1, 1) - (2, 0).Note to the third sample test. A single point doesn't form a single triangle.
Java 8
standard input
[ "geometry", "combinatorics", "math", "sortings", "data structures", "brute force" ]
d5913f8208efa1641f53caaee7624622
The first line contains integer n (1 ≤ n ≤ 2000) — the number of the points painted on the plane. Next n lines contain two integers each xi, yi ( - 100 ≤ xi, yi ≤ 100) — the coordinates of the i-th point. It is guaranteed that no two given points coincide.
1,900
In the first line print an integer — the number of triangles with the non-zero area among the painted points.
standard output
PASSED
265b245d5110a40c19e4cd6e9675c8d8
train_002.jsonl
1434645000
Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed triangles with the non-zero area.
512 megabytes
// package CF; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; import java.util.TreeMap; public class D { public static void main(String[] args) throws Exc...
Java
["4\n0 0\n1 1\n2 0\n2 2", "3\n0 0\n1 1\n2 0", "1\n1 1"]
4 seconds
["3", "1", "0"]
NoteNote to the first sample test. There are 3 triangles formed: (0, 0) - (1, 1) - (2, 0); (0, 0) - (2, 2) - (2, 0); (1, 1) - (2, 2) - (2, 0).Note to the second sample test. There is 1 triangle formed: (0, 0) - (1, 1) - (2, 0).Note to the third sample test. A single point doesn't form a single triangle.
Java 8
standard input
[ "geometry", "combinatorics", "math", "sortings", "data structures", "brute force" ]
d5913f8208efa1641f53caaee7624622
The first line contains integer n (1 ≤ n ≤ 2000) — the number of the points painted on the plane. Next n lines contain two integers each xi, yi ( - 100 ≤ xi, yi ≤ 100) — the coordinates of the i-th point. It is guaranteed that no two given points coincide.
1,900
In the first line print an integer — the number of triangles with the non-zero area among the painted points.
standard output
PASSED
8540e873fd03aefc53fa5bb74e4c0cc2
train_002.jsonl
1434645000
Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed triangles with the non-zero area.
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.HashMap; import java.util.StringTokenizer; public class Main { static BufferedReader reader; static StringTokenizer tokenizer; static PrintWriter writer; static int nextInt() t...
Java
["4\n0 0\n1 1\n2 0\n2 2", "3\n0 0\n1 1\n2 0", "1\n1 1"]
4 seconds
["3", "1", "0"]
NoteNote to the first sample test. There are 3 triangles formed: (0, 0) - (1, 1) - (2, 0); (0, 0) - (2, 2) - (2, 0); (1, 1) - (2, 2) - (2, 0).Note to the second sample test. There is 1 triangle formed: (0, 0) - (1, 1) - (2, 0).Note to the third sample test. A single point doesn't form a single triangle.
Java 8
standard input
[ "geometry", "combinatorics", "math", "sortings", "data structures", "brute force" ]
d5913f8208efa1641f53caaee7624622
The first line contains integer n (1 ≤ n ≤ 2000) — the number of the points painted on the plane. Next n lines contain two integers each xi, yi ( - 100 ≤ xi, yi ≤ 100) — the coordinates of the i-th point. It is guaranteed that no two given points coincide.
1,900
In the first line print an integer — the number of triangles with the non-zero area among the painted points.
standard output
PASSED
8a8ac378db5d8e26d4efce30803997ae
train_002.jsonl
1434645000
Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed triangles with the non-zero area.
512 megabytes
import java.util.Arrays; import java.io.InputStream; import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Comparator; import java.io.IOException; import java.util.StringTokenizer; /** * Built using CHelper plug-in * Actual solution...
Java
["4\n0 0\n1 1\n2 0\n2 2", "3\n0 0\n1 1\n2 0", "1\n1 1"]
4 seconds
["3", "1", "0"]
NoteNote to the first sample test. There are 3 triangles formed: (0, 0) - (1, 1) - (2, 0); (0, 0) - (2, 2) - (2, 0); (1, 1) - (2, 2) - (2, 0).Note to the second sample test. There is 1 triangle formed: (0, 0) - (1, 1) - (2, 0).Note to the third sample test. A single point doesn't form a single triangle.
Java 8
standard input
[ "geometry", "combinatorics", "math", "sortings", "data structures", "brute force" ]
d5913f8208efa1641f53caaee7624622
The first line contains integer n (1 ≤ n ≤ 2000) — the number of the points painted on the plane. Next n lines contain two integers each xi, yi ( - 100 ≤ xi, yi ≤ 100) — the coordinates of the i-th point. It is guaranteed that no two given points coincide.
1,900
In the first line print an integer — the number of triangles with the non-zero area among the painted points.
standard output
PASSED
3bef387fcec632edd80074a133a3475a
train_002.jsonl
1434645000
Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed triangles with the non-zero area.
512 megabytes
import java.util.Arrays; import java.io.InputStream; import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Comparator; import java.io.IOException; import java.util.StringTokenizer; /** * Built using CHelper plug-in * Actual solution...
Java
["4\n0 0\n1 1\n2 0\n2 2", "3\n0 0\n1 1\n2 0", "1\n1 1"]
4 seconds
["3", "1", "0"]
NoteNote to the first sample test. There are 3 triangles formed: (0, 0) - (1, 1) - (2, 0); (0, 0) - (2, 2) - (2, 0); (1, 1) - (2, 2) - (2, 0).Note to the second sample test. There is 1 triangle formed: (0, 0) - (1, 1) - (2, 0).Note to the third sample test. A single point doesn't form a single triangle.
Java 8
standard input
[ "geometry", "combinatorics", "math", "sortings", "data structures", "brute force" ]
d5913f8208efa1641f53caaee7624622
The first line contains integer n (1 ≤ n ≤ 2000) — the number of the points painted on the plane. Next n lines contain two integers each xi, yi ( - 100 ≤ xi, yi ≤ 100) — the coordinates of the i-th point. It is guaranteed that no two given points coincide.
1,900
In the first line print an integer — the number of triangles with the non-zero area among the painted points.
standard output
PASSED
ec8451b68217dfa8c9e3f2f69388f2a9
train_002.jsonl
1434645000
Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed triangles with the non-zero area.
512 megabytes
import java.util.*; public class Ejercicio1{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] x = new int[2505]; int[] y = new int[2505]; sc.nextLine(); for (int i=0; i<n; i++){ x[i] = sc.nextInt(); y[i] = sc.nextInt(); } tria...
Java
["4\n0 0\n1 1\n2 0\n2 2", "3\n0 0\n1 1\n2 0", "1\n1 1"]
4 seconds
["3", "1", "0"]
NoteNote to the first sample test. There are 3 triangles formed: (0, 0) - (1, 1) - (2, 0); (0, 0) - (2, 2) - (2, 0); (1, 1) - (2, 2) - (2, 0).Note to the second sample test. There is 1 triangle formed: (0, 0) - (1, 1) - (2, 0).Note to the third sample test. A single point doesn't form a single triangle.
Java 8
standard input
[ "geometry", "combinatorics", "math", "sortings", "data structures", "brute force" ]
d5913f8208efa1641f53caaee7624622
The first line contains integer n (1 ≤ n ≤ 2000) — the number of the points painted on the plane. Next n lines contain two integers each xi, yi ( - 100 ≤ xi, yi ≤ 100) — the coordinates of the i-th point. It is guaranteed that no two given points coincide.
1,900
In the first line print an integer — the number of triangles with the non-zero area among the painted points.
standard output
PASSED
fb82e2f90c4a59d781c118242a98b3b6
train_002.jsonl
1434645000
Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed triangles with the non-zero area.
512 megabytes
import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.Scanner; public class Main { public void solve() { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int[] x = new int[N]; int[] y = new int[N]; for (int i = 0; i < N; i++) { x[i] = sc.nextIn...
Java
["4\n0 0\n1 1\n2 0\n2 2", "3\n0 0\n1 1\n2 0", "1\n1 1"]
4 seconds
["3", "1", "0"]
NoteNote to the first sample test. There are 3 triangles formed: (0, 0) - (1, 1) - (2, 0); (0, 0) - (2, 2) - (2, 0); (1, 1) - (2, 2) - (2, 0).Note to the second sample test. There is 1 triangle formed: (0, 0) - (1, 1) - (2, 0).Note to the third sample test. A single point doesn't form a single triangle.
Java 8
standard input
[ "geometry", "combinatorics", "math", "sortings", "data structures", "brute force" ]
d5913f8208efa1641f53caaee7624622
The first line contains integer n (1 ≤ n ≤ 2000) — the number of the points painted on the plane. Next n lines contain two integers each xi, yi ( - 100 ≤ xi, yi ≤ 100) — the coordinates of the i-th point. It is guaranteed that no two given points coincide.
1,900
In the first line print an integer — the number of triangles with the non-zero area among the painted points.
standard output
PASSED
fd5d78a412517d023f7319aaef29e693
train_002.jsonl
1434645000
Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed triangles with the non-zero area.
512 megabytes
import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; public class Main { private final double EPS = 1e-10; public void solve() { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int[] x = new int[N]; int[] y = new int[N]; for (int i = 0; i < N; i++) { x[i] = sc....
Java
["4\n0 0\n1 1\n2 0\n2 2", "3\n0 0\n1 1\n2 0", "1\n1 1"]
4 seconds
["3", "1", "0"]
NoteNote to the first sample test. There are 3 triangles formed: (0, 0) - (1, 1) - (2, 0); (0, 0) - (2, 2) - (2, 0); (1, 1) - (2, 2) - (2, 0).Note to the second sample test. There is 1 triangle formed: (0, 0) - (1, 1) - (2, 0).Note to the third sample test. A single point doesn't form a single triangle.
Java 8
standard input
[ "geometry", "combinatorics", "math", "sortings", "data structures", "brute force" ]
d5913f8208efa1641f53caaee7624622
The first line contains integer n (1 ≤ n ≤ 2000) — the number of the points painted on the plane. Next n lines contain two integers each xi, yi ( - 100 ≤ xi, yi ≤ 100) — the coordinates of the i-th point. It is guaranteed that no two given points coincide.
1,900
In the first line print an integer — the number of triangles with the non-zero area among the painted points.
standard output
PASSED
689d699e86bf2bd33b0a01c544f3ca1e
train_002.jsonl
1434645000
Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed triangles with the non-zero area.
512 megabytes
import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; public class Main { public void solve() { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int[] x = new int[N]; int[] y = new int[N]; for (int i = 0; i < N; i++) { x[i] = sc.nextInt(); y[i] = sc.nextInt(); } ...
Java
["4\n0 0\n1 1\n2 0\n2 2", "3\n0 0\n1 1\n2 0", "1\n1 1"]
4 seconds
["3", "1", "0"]
NoteNote to the first sample test. There are 3 triangles formed: (0, 0) - (1, 1) - (2, 0); (0, 0) - (2, 2) - (2, 0); (1, 1) - (2, 2) - (2, 0).Note to the second sample test. There is 1 triangle formed: (0, 0) - (1, 1) - (2, 0).Note to the third sample test. A single point doesn't form a single triangle.
Java 8
standard input
[ "geometry", "combinatorics", "math", "sortings", "data structures", "brute force" ]
d5913f8208efa1641f53caaee7624622
The first line contains integer n (1 ≤ n ≤ 2000) — the number of the points painted on the plane. Next n lines contain two integers each xi, yi ( - 100 ≤ xi, yi ≤ 100) — the coordinates of the i-th point. It is guaranteed that no two given points coincide.
1,900
In the first line print an integer — the number of triangles with the non-zero area among the painted points.
standard output
PASSED
e569f64f55a8f9845657ea1170a67fe8
train_002.jsonl
1434645000
Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed triangles with the non-zero area.
512 megabytes
import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; public class Main { public void solve() { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int[] x = new int[N]; int[] y = new int[N]; for (int i = 0; i < N; i++) { x[i] = sc.nextInt(); y[i] = sc.nextInt(); } ...
Java
["4\n0 0\n1 1\n2 0\n2 2", "3\n0 0\n1 1\n2 0", "1\n1 1"]
4 seconds
["3", "1", "0"]
NoteNote to the first sample test. There are 3 triangles formed: (0, 0) - (1, 1) - (2, 0); (0, 0) - (2, 2) - (2, 0); (1, 1) - (2, 2) - (2, 0).Note to the second sample test. There is 1 triangle formed: (0, 0) - (1, 1) - (2, 0).Note to the third sample test. A single point doesn't form a single triangle.
Java 8
standard input
[ "geometry", "combinatorics", "math", "sortings", "data structures", "brute force" ]
d5913f8208efa1641f53caaee7624622
The first line contains integer n (1 ≤ n ≤ 2000) — the number of the points painted on the plane. Next n lines contain two integers each xi, yi ( - 100 ≤ xi, yi ≤ 100) — the coordinates of the i-th point. It is guaranteed that no two given points coincide.
1,900
In the first line print an integer — the number of triangles with the non-zero area among the painted points.
standard output
PASSED
02c64ecbdc52a6406d0f580d9df5cd91
train_002.jsonl
1434645000
Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed triangles with the non-zero area.
512 megabytes
import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; public class Main { private final double EPS = 1e-10; public void solve() { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int[] x = new int[N]; int[] y = new int[N]; for (int i = 0; i < N; i++) { x[i] = sc....
Java
["4\n0 0\n1 1\n2 0\n2 2", "3\n0 0\n1 1\n2 0", "1\n1 1"]
4 seconds
["3", "1", "0"]
NoteNote to the first sample test. There are 3 triangles formed: (0, 0) - (1, 1) - (2, 0); (0, 0) - (2, 2) - (2, 0); (1, 1) - (2, 2) - (2, 0).Note to the second sample test. There is 1 triangle formed: (0, 0) - (1, 1) - (2, 0).Note to the third sample test. A single point doesn't form a single triangle.
Java 8
standard input
[ "geometry", "combinatorics", "math", "sortings", "data structures", "brute force" ]
d5913f8208efa1641f53caaee7624622
The first line contains integer n (1 ≤ n ≤ 2000) — the number of the points painted on the plane. Next n lines contain two integers each xi, yi ( - 100 ≤ xi, yi ≤ 100) — the coordinates of the i-th point. It is guaranteed that no two given points coincide.
1,900
In the first line print an integer — the number of triangles with the non-zero area among the painted points.
standard output
PASSED
1e3f1ff3e09c1a2007b1d4491906139f
train_002.jsonl
1434645000
Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed triangles with the non-zero area.
512 megabytes
import java.io.*; import java.util.Arrays; /** * Created by zhangliang on 15/9/18. */ public class Main { private static int[] xx; private static int[] yy; private static long ans; private static int[][] a = new int[440][440]; private static void input() throws IOException { Buffered...
Java
["4\n0 0\n1 1\n2 0\n2 2", "3\n0 0\n1 1\n2 0", "1\n1 1"]
4 seconds
["3", "1", "0"]
NoteNote to the first sample test. There are 3 triangles formed: (0, 0) - (1, 1) - (2, 0); (0, 0) - (2, 2) - (2, 0); (1, 1) - (2, 2) - (2, 0).Note to the second sample test. There is 1 triangle formed: (0, 0) - (1, 1) - (2, 0).Note to the third sample test. A single point doesn't form a single triangle.
Java 8
standard input
[ "geometry", "combinatorics", "math", "sortings", "data structures", "brute force" ]
d5913f8208efa1641f53caaee7624622
The first line contains integer n (1 ≤ n ≤ 2000) — the number of the points painted on the plane. Next n lines contain two integers each xi, yi ( - 100 ≤ xi, yi ≤ 100) — the coordinates of the i-th point. It is guaranteed that no two given points coincide.
1,900
In the first line print an integer — the number of triangles with the non-zero area among the painted points.
standard output
PASSED
391dfb318232fc6064b6da2f9b60912b
train_002.jsonl
1434645000
Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed triangles with the non-zero area.
512 megabytes
import java.io.*; import java.util.*; public class cf4 implements Runnable { public static final String taskname = cf4.class.getName(); public StringTokenizer strtok; public BufferedReader inr; public PrintWriter out; public static void main(String[] args) { new Thread(new cf4()).start(); } public void ru...
Java
["4\n0 0\n1 1\n2 0\n2 2", "3\n0 0\n1 1\n2 0", "1\n1 1"]
4 seconds
["3", "1", "0"]
NoteNote to the first sample test. There are 3 triangles formed: (0, 0) - (1, 1) - (2, 0); (0, 0) - (2, 2) - (2, 0); (1, 1) - (2, 2) - (2, 0).Note to the second sample test. There is 1 triangle formed: (0, 0) - (1, 1) - (2, 0).Note to the third sample test. A single point doesn't form a single triangle.
Java 8
standard input
[ "geometry", "combinatorics", "math", "sortings", "data structures", "brute force" ]
d5913f8208efa1641f53caaee7624622
The first line contains integer n (1 ≤ n ≤ 2000) — the number of the points painted on the plane. Next n lines contain two integers each xi, yi ( - 100 ≤ xi, yi ≤ 100) — the coordinates of the i-th point. It is guaranteed that no two given points coincide.
1,900
In the first line print an integer — the number of triangles with the non-zero area among the painted points.
standard output
PASSED
3b27ef7668fe339bbc38edc233781bd2
train_002.jsonl
1434645000
Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed triangles with the non-zero area.
512 megabytes
import java.io.*; import java.util.HashMap; import java.util.StringTokenizer; public class Main { static final double EPS = 1e-9; public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int ans = 0;...
Java
["4\n0 0\n1 1\n2 0\n2 2", "3\n0 0\n1 1\n2 0", "1\n1 1"]
4 seconds
["3", "1", "0"]
NoteNote to the first sample test. There are 3 triangles formed: (0, 0) - (1, 1) - (2, 0); (0, 0) - (2, 2) - (2, 0); (1, 1) - (2, 2) - (2, 0).Note to the second sample test. There is 1 triangle formed: (0, 0) - (1, 1) - (2, 0).Note to the third sample test. A single point doesn't form a single triangle.
Java 8
standard input
[ "geometry", "combinatorics", "math", "sortings", "data structures", "brute force" ]
d5913f8208efa1641f53caaee7624622
The first line contains integer n (1 ≤ n ≤ 2000) — the number of the points painted on the plane. Next n lines contain two integers each xi, yi ( - 100 ≤ xi, yi ≤ 100) — the coordinates of the i-th point. It is guaranteed that no two given points coincide.
1,900
In the first line print an integer — the number of triangles with the non-zero area among the painted points.
standard output
PASSED
2110f5cd18dd7fab9646f9ae200fafaa
train_002.jsonl
1434645000
Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed triangles with the non-zero area.
512 megabytes
import java.io.*; import java.util.StringTokenizer; import java.util.TreeMap; public class Main { static final double EPS = 1e-9; public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(S...
Java
["4\n0 0\n1 1\n2 0\n2 2", "3\n0 0\n1 1\n2 0", "1\n1 1"]
4 seconds
["3", "1", "0"]
NoteNote to the first sample test. There are 3 triangles formed: (0, 0) - (1, 1) - (2, 0); (0, 0) - (2, 2) - (2, 0); (1, 1) - (2, 2) - (2, 0).Note to the second sample test. There is 1 triangle formed: (0, 0) - (1, 1) - (2, 0).Note to the third sample test. A single point doesn't form a single triangle.
Java 8
standard input
[ "geometry", "combinatorics", "math", "sortings", "data structures", "brute force" ]
d5913f8208efa1641f53caaee7624622
The first line contains integer n (1 ≤ n ≤ 2000) — the number of the points painted on the plane. Next n lines contain two integers each xi, yi ( - 100 ≤ xi, yi ≤ 100) — the coordinates of the i-th point. It is guaranteed that no two given points coincide.
1,900
In the first line print an integer — the number of triangles with the non-zero area among the painted points.
standard output
PASSED
76a5bfb66ab77a7a303b8f4300d1da53
train_002.jsonl
1434645000
Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed triangles with the non-zero area.
512 megabytes
import java.io.*; import java.util.HashMap; import java.util.StringTokenizer; public class Main { static final double EPS = 1e-9; public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int ans = 0;...
Java
["4\n0 0\n1 1\n2 0\n2 2", "3\n0 0\n1 1\n2 0", "1\n1 1"]
4 seconds
["3", "1", "0"]
NoteNote to the first sample test. There are 3 triangles formed: (0, 0) - (1, 1) - (2, 0); (0, 0) - (2, 2) - (2, 0); (1, 1) - (2, 2) - (2, 0).Note to the second sample test. There is 1 triangle formed: (0, 0) - (1, 1) - (2, 0).Note to the third sample test. A single point doesn't form a single triangle.
Java 8
standard input
[ "geometry", "combinatorics", "math", "sortings", "data structures", "brute force" ]
d5913f8208efa1641f53caaee7624622
The first line contains integer n (1 ≤ n ≤ 2000) — the number of the points painted on the plane. Next n lines contain two integers each xi, yi ( - 100 ≤ xi, yi ≤ 100) — the coordinates of the i-th point. It is guaranteed that no two given points coincide.
1,900
In the first line print an integer — the number of triangles with the non-zero area among the painted points.
standard output
PASSED
16652a10947f0547b6345e4bd759a390
train_002.jsonl
1434645000
Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed triangles with the non-zero area.
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; /** * @author Don Li */ public class VanyaTriangles { void solve() { int n = in.nextInt(); int[] x = new int[n], y = new int[n]; for (...
Java
["4\n0 0\n1 1\n2 0\n2 2", "3\n0 0\n1 1\n2 0", "1\n1 1"]
4 seconds
["3", "1", "0"]
NoteNote to the first sample test. There are 3 triangles formed: (0, 0) - (1, 1) - (2, 0); (0, 0) - (2, 2) - (2, 0); (1, 1) - (2, 2) - (2, 0).Note to the second sample test. There is 1 triangle formed: (0, 0) - (1, 1) - (2, 0).Note to the third sample test. A single point doesn't form a single triangle.
Java 8
standard input
[ "geometry", "combinatorics", "math", "sortings", "data structures", "brute force" ]
d5913f8208efa1641f53caaee7624622
The first line contains integer n (1 ≤ n ≤ 2000) — the number of the points painted on the plane. Next n lines contain two integers each xi, yi ( - 100 ≤ xi, yi ≤ 100) — the coordinates of the i-th point. It is guaranteed that no two given points coincide.
1,900
In the first line print an integer — the number of triangles with the non-zero area among the painted points.
standard output
PASSED
fa32714a26fae49bf160ef2b68079099
train_002.jsonl
1434645000
Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed triangles with the non-zero area.
512 megabytes
import java.util.*; import java.io.*; /** * * @author usquare * */ public class ProblemA { public static int mod = (int) (1e9+7); public static InputReader in; public static PrintWriter out; public static void main(String[] args){ in = new InputReader(System.in); ...
Java
["4\n0 0\n1 1\n2 0\n2 2", "3\n0 0\n1 1\n2 0", "1\n1 1"]
4 seconds
["3", "1", "0"]
NoteNote to the first sample test. There are 3 triangles formed: (0, 0) - (1, 1) - (2, 0); (0, 0) - (2, 2) - (2, 0); (1, 1) - (2, 2) - (2, 0).Note to the second sample test. There is 1 triangle formed: (0, 0) - (1, 1) - (2, 0).Note to the third sample test. A single point doesn't form a single triangle.
Java 8
standard input
[ "geometry", "combinatorics", "math", "sortings", "data structures", "brute force" ]
d5913f8208efa1641f53caaee7624622
The first line contains integer n (1 ≤ n ≤ 2000) — the number of the points painted on the plane. Next n lines contain two integers each xi, yi ( - 100 ≤ xi, yi ≤ 100) — the coordinates of the i-th point. It is guaranteed that no two given points coincide.
1,900
In the first line print an integer — the number of triangles with the non-zero area among the painted points.
standard output
PASSED
0d273284d51b700963c81c88fb236f04
train_002.jsonl
1497710100
On the way to school, Karen became fixated on the puzzle game on her phone! The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.One move consists of choosing one row or column, and adding 1 to all of the cells in that row or column.To win ...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Java
["3 5\n2 2 2 3 2\n0 0 0 1 0\n1 1 1 2 1", "3 3\n0 0 0\n0 1 0\n0 0 0", "3 3\n1 1 1\n1 1 1\n1 1 1"]
2 seconds
["4\nrow 1\nrow 1\ncol 4\nrow 3", "-1", "3\nrow 1\nrow 2\nrow 3"]
NoteIn the first test case, Karen has a grid with 3 rows and 5 columns. She can perform the following 4 moves to beat the level: In the second test case, Karen has a grid with 3 rows and 3 columns. It is clear that it is impossible to beat the level; performing any move will create three 1s on the grid, but it is requ...
Java 8
standard input
[ "implementation", "greedy", "brute force" ]
b19ab2db46484f0c9b49cf261502bf64
The first line of input contains two integers, n and m (1 ≤ n, m ≤ 100), the number of rows and the number of columns in the grid, respectively. The next n lines each contain m integers. In particular, the j-th integer in the i-th of these rows contains gi, j (0 ≤ gi, j ≤ 500).
1,700
If there is an error and it is actually not possible to beat the level, output a single integer -1. Otherwise, on the first line, output a single integer k, the minimum number of moves necessary to beat the level. The next k lines should each contain one of the following, describing the moves in the order they must be ...
standard output
PASSED
d977c83dcf05ccbcb108391b993c3f60
train_002.jsonl
1497710100
On the way to school, Karen became fixated on the puzzle game on her phone! The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.One move consists of choosing one row or column, and adding 1 to all of the cells in that row or column.To win ...
512 megabytes
/* * DA-IICT * Author: Jugal Kalal */ import java.util.*; import java.io.*; import java.math.*; import java.text.DecimalFormat; public class HackerEarth{ static long MOD=(long)Math.pow(10,9)+7; public static void main(String args[]) { new Thread(null, new Runnable() { public void run() { ...
Java
["3 5\n2 2 2 3 2\n0 0 0 1 0\n1 1 1 2 1", "3 3\n0 0 0\n0 1 0\n0 0 0", "3 3\n1 1 1\n1 1 1\n1 1 1"]
2 seconds
["4\nrow 1\nrow 1\ncol 4\nrow 3", "-1", "3\nrow 1\nrow 2\nrow 3"]
NoteIn the first test case, Karen has a grid with 3 rows and 5 columns. She can perform the following 4 moves to beat the level: In the second test case, Karen has a grid with 3 rows and 3 columns. It is clear that it is impossible to beat the level; performing any move will create three 1s on the grid, but it is requ...
Java 8
standard input
[ "implementation", "greedy", "brute force" ]
b19ab2db46484f0c9b49cf261502bf64
The first line of input contains two integers, n and m (1 ≤ n, m ≤ 100), the number of rows and the number of columns in the grid, respectively. The next n lines each contain m integers. In particular, the j-th integer in the i-th of these rows contains gi, j (0 ≤ gi, j ≤ 500).
1,700
If there is an error and it is actually not possible to beat the level, output a single integer -1. Otherwise, on the first line, output a single integer k, the minimum number of moves necessary to beat the level. The next k lines should each contain one of the following, describing the moves in the order they must be ...
standard output
PASSED
7597296cb8db4b38bcc7264c0c75802e
train_002.jsonl
1497710100
On the way to school, Karen became fixated on the puzzle game on her phone! The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.One move consists of choosing one row or column, and adding 1 to all of the cells in that row or column.To win ...
512 megabytes
import java.util.*; import java.io.*; import java.lang.Math.*; public class MainA { public static int mod = 20000; public static long[] val; public static long[] arr; static int max = (int) 1e9 + 7; public static void main(String[] args) { InputReader in = new InputReader(System.in); PrintWriter out = ne...
Java
["3 5\n2 2 2 3 2\n0 0 0 1 0\n1 1 1 2 1", "3 3\n0 0 0\n0 1 0\n0 0 0", "3 3\n1 1 1\n1 1 1\n1 1 1"]
2 seconds
["4\nrow 1\nrow 1\ncol 4\nrow 3", "-1", "3\nrow 1\nrow 2\nrow 3"]
NoteIn the first test case, Karen has a grid with 3 rows and 5 columns. She can perform the following 4 moves to beat the level: In the second test case, Karen has a grid with 3 rows and 3 columns. It is clear that it is impossible to beat the level; performing any move will create three 1s on the grid, but it is requ...
Java 8
standard input
[ "implementation", "greedy", "brute force" ]
b19ab2db46484f0c9b49cf261502bf64
The first line of input contains two integers, n and m (1 ≤ n, m ≤ 100), the number of rows and the number of columns in the grid, respectively. The next n lines each contain m integers. In particular, the j-th integer in the i-th of these rows contains gi, j (0 ≤ gi, j ≤ 500).
1,700
If there is an error and it is actually not possible to beat the level, output a single integer -1. Otherwise, on the first line, output a single integer k, the minimum number of moves necessary to beat the level. The next k lines should each contain one of the following, describing the moves in the order they must be ...
standard output
PASSED
4a8fd27cd88e5a0aaeb4253a9e7fde15
train_002.jsonl
1497710100
On the way to school, Karen became fixated on the puzzle game on her phone! The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.One move consists of choosing one row or column, and adding 1 to all of the cells in that row or column.To win ...
512 megabytes
import java.io.*; import java.util.*; public class C { static StringBuilder st = new StringBuilder(); public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in) ; PrintWriter out = new PrintWriter(System.out) ; int n = sc.nextInt() , m = sc.nextInt() ; int []...
Java
["3 5\n2 2 2 3 2\n0 0 0 1 0\n1 1 1 2 1", "3 3\n0 0 0\n0 1 0\n0 0 0", "3 3\n1 1 1\n1 1 1\n1 1 1"]
2 seconds
["4\nrow 1\nrow 1\ncol 4\nrow 3", "-1", "3\nrow 1\nrow 2\nrow 3"]
NoteIn the first test case, Karen has a grid with 3 rows and 5 columns. She can perform the following 4 moves to beat the level: In the second test case, Karen has a grid with 3 rows and 3 columns. It is clear that it is impossible to beat the level; performing any move will create three 1s on the grid, but it is requ...
Java 8
standard input
[ "implementation", "greedy", "brute force" ]
b19ab2db46484f0c9b49cf261502bf64
The first line of input contains two integers, n and m (1 ≤ n, m ≤ 100), the number of rows and the number of columns in the grid, respectively. The next n lines each contain m integers. In particular, the j-th integer in the i-th of these rows contains gi, j (0 ≤ gi, j ≤ 500).
1,700
If there is an error and it is actually not possible to beat the level, output a single integer -1. Otherwise, on the first line, output a single integer k, the minimum number of moves necessary to beat the level. The next k lines should each contain one of the following, describing the moves in the order they must be ...
standard output
PASSED
74fb9fd78acbf53c4d906e13b4ada919
train_002.jsonl
1497710100
On the way to school, Karen became fixated on the puzzle game on her phone! The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.One move consists of choosing one row or column, and adding 1 to all of the cells in that row or column.To win ...
512 megabytes
import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class C_419 { InputStream is; PrintWriter out; int n; long a[]; private boolean oj = System.getProperty("ONLINE_JUDGE") != n...
Java
["3 5\n2 2 2 3 2\n0 0 0 1 0\n1 1 1 2 1", "3 3\n0 0 0\n0 1 0\n0 0 0", "3 3\n1 1 1\n1 1 1\n1 1 1"]
2 seconds
["4\nrow 1\nrow 1\ncol 4\nrow 3", "-1", "3\nrow 1\nrow 2\nrow 3"]
NoteIn the first test case, Karen has a grid with 3 rows and 5 columns. She can perform the following 4 moves to beat the level: In the second test case, Karen has a grid with 3 rows and 3 columns. It is clear that it is impossible to beat the level; performing any move will create three 1s on the grid, but it is requ...
Java 8
standard input
[ "implementation", "greedy", "brute force" ]
b19ab2db46484f0c9b49cf261502bf64
The first line of input contains two integers, n and m (1 ≤ n, m ≤ 100), the number of rows and the number of columns in the grid, respectively. The next n lines each contain m integers. In particular, the j-th integer in the i-th of these rows contains gi, j (0 ≤ gi, j ≤ 500).
1,700
If there is an error and it is actually not possible to beat the level, output a single integer -1. Otherwise, on the first line, output a single integer k, the minimum number of moves necessary to beat the level. The next k lines should each contain one of the following, describing the moves in the order they must be ...
standard output
PASSED
eb162d3485805962f0eb27c59a25780e
train_002.jsonl
1497710100
On the way to school, Karen became fixated on the puzzle game on her phone! The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.One move consists of choosing one row or column, and adding 1 to all of the cells in that row or column.To win ...
512 megabytes
import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class C { String INPUT = "3 2 4 91 94 92 97 97 99 92 94 93 97 95 96 90 10005"; public void solve(){ int n = ni(); i...
Java
["3 5\n2 2 2 3 2\n0 0 0 1 0\n1 1 1 2 1", "3 3\n0 0 0\n0 1 0\n0 0 0", "3 3\n1 1 1\n1 1 1\n1 1 1"]
2 seconds
["4\nrow 1\nrow 1\ncol 4\nrow 3", "-1", "3\nrow 1\nrow 2\nrow 3"]
NoteIn the first test case, Karen has a grid with 3 rows and 5 columns. She can perform the following 4 moves to beat the level: In the second test case, Karen has a grid with 3 rows and 3 columns. It is clear that it is impossible to beat the level; performing any move will create three 1s on the grid, but it is requ...
Java 8
standard input
[ "implementation", "greedy", "brute force" ]
b19ab2db46484f0c9b49cf261502bf64
The first line of input contains two integers, n and m (1 ≤ n, m ≤ 100), the number of rows and the number of columns in the grid, respectively. The next n lines each contain m integers. In particular, the j-th integer in the i-th of these rows contains gi, j (0 ≤ gi, j ≤ 500).
1,700
If there is an error and it is actually not possible to beat the level, output a single integer -1. Otherwise, on the first line, output a single integer k, the minimum number of moves necessary to beat the level. The next k lines should each contain one of the following, describing the moves in the order they must be ...
standard output
PASSED
0b0b38b733f36c4aa24b46554813b63f
train_002.jsonl
1497710100
On the way to school, Karen became fixated on the puzzle game on her phone! The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.One move consists of choosing one row or column, and adding 1 to all of the cells in that row or column.To win ...
512 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.NoSuchElementException; public class C { int N,M; int[][] G; public List<String> rowFirst(){ List<String> list = new ArrayList<>(); int[][] copy = new int[N...
Java
["3 5\n2 2 2 3 2\n0 0 0 1 0\n1 1 1 2 1", "3 3\n0 0 0\n0 1 0\n0 0 0", "3 3\n1 1 1\n1 1 1\n1 1 1"]
2 seconds
["4\nrow 1\nrow 1\ncol 4\nrow 3", "-1", "3\nrow 1\nrow 2\nrow 3"]
NoteIn the first test case, Karen has a grid with 3 rows and 5 columns. She can perform the following 4 moves to beat the level: In the second test case, Karen has a grid with 3 rows and 3 columns. It is clear that it is impossible to beat the level; performing any move will create three 1s on the grid, but it is requ...
Java 8
standard input
[ "implementation", "greedy", "brute force" ]
b19ab2db46484f0c9b49cf261502bf64
The first line of input contains two integers, n and m (1 ≤ n, m ≤ 100), the number of rows and the number of columns in the grid, respectively. The next n lines each contain m integers. In particular, the j-th integer in the i-th of these rows contains gi, j (0 ≤ gi, j ≤ 500).
1,700
If there is an error and it is actually not possible to beat the level, output a single integer -1. Otherwise, on the first line, output a single integer k, the minimum number of moves necessary to beat the level. The next k lines should each contain one of the following, describing the moves in the order they must be ...
standard output
PASSED
a7369ce3a608188c3c9644de31165b34
train_002.jsonl
1497710100
On the way to school, Karen became fixated on the puzzle game on her phone! The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.One move consists of choosing one row or column, and adding 1 to all of the cells in that row or column.To win ...
512 megabytes
import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; // atharva washimkar // Jun 17, 2017 public class CODEFORCES_816_C { static int N, M; static int[][]...
Java
["3 5\n2 2 2 3 2\n0 0 0 1 0\n1 1 1 2 1", "3 3\n0 0 0\n0 1 0\n0 0 0", "3 3\n1 1 1\n1 1 1\n1 1 1"]
2 seconds
["4\nrow 1\nrow 1\ncol 4\nrow 3", "-1", "3\nrow 1\nrow 2\nrow 3"]
NoteIn the first test case, Karen has a grid with 3 rows and 5 columns. She can perform the following 4 moves to beat the level: In the second test case, Karen has a grid with 3 rows and 3 columns. It is clear that it is impossible to beat the level; performing any move will create three 1s on the grid, but it is requ...
Java 8
standard input
[ "implementation", "greedy", "brute force" ]
b19ab2db46484f0c9b49cf261502bf64
The first line of input contains two integers, n and m (1 ≤ n, m ≤ 100), the number of rows and the number of columns in the grid, respectively. The next n lines each contain m integers. In particular, the j-th integer in the i-th of these rows contains gi, j (0 ≤ gi, j ≤ 500).
1,700
If there is an error and it is actually not possible to beat the level, output a single integer -1. Otherwise, on the first line, output a single integer k, the minimum number of moves necessary to beat the level. The next k lines should each contain one of the following, describing the moves in the order they must be ...
standard output
PASSED
5b49e144902b4d7b41ce2fc10e6363dd
train_002.jsonl
1497710100
On the way to school, Karen became fixated on the puzzle game on her phone! The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.One move consists of choosing one row or column, and adding 1 to all of the cells in that row or column.To win ...
512 megabytes
import com.sun.org.apache.bcel.internal.generic.ARRAYLENGTH; import java.lang.reflect.Array; import java.util.*; import java.io.*; import java.math.*; import java.lang.*; public class Main { private static FastReader sc = new FastReader(System.in); private static OutputWriter out = new OutputWriter(System.out...
Java
["3 5\n2 2 2 3 2\n0 0 0 1 0\n1 1 1 2 1", "3 3\n0 0 0\n0 1 0\n0 0 0", "3 3\n1 1 1\n1 1 1\n1 1 1"]
2 seconds
["4\nrow 1\nrow 1\ncol 4\nrow 3", "-1", "3\nrow 1\nrow 2\nrow 3"]
NoteIn the first test case, Karen has a grid with 3 rows and 5 columns. She can perform the following 4 moves to beat the level: In the second test case, Karen has a grid with 3 rows and 3 columns. It is clear that it is impossible to beat the level; performing any move will create three 1s on the grid, but it is requ...
Java 8
standard input
[ "implementation", "greedy", "brute force" ]
b19ab2db46484f0c9b49cf261502bf64
The first line of input contains two integers, n and m (1 ≤ n, m ≤ 100), the number of rows and the number of columns in the grid, respectively. The next n lines each contain m integers. In particular, the j-th integer in the i-th of these rows contains gi, j (0 ≤ gi, j ≤ 500).
1,700
If there is an error and it is actually not possible to beat the level, output a single integer -1. Otherwise, on the first line, output a single integer k, the minimum number of moves necessary to beat the level. The next k lines should each contain one of the following, describing the moves in the order they must be ...
standard output
PASSED
2b8e5b5fc6cd99cc00917ffdc9ddfa24
train_002.jsonl
1497710100
On the way to school, Karen became fixated on the puzzle game on her phone! The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.One move consists of choosing one row or column, and adding 1 to all of the cells in that row or column.To win ...
512 megabytes
import java.util.Arrays; import java.util.Scanner; /** * Created by Christy on 8/8/2017. */ public class KarenAndGame { public static void main (String[] args) { Scanner scan = new Scanner(System.in); int r = scan.nextInt(); int c = scan.nextInt(); int count = 0; StringB...
Java
["3 5\n2 2 2 3 2\n0 0 0 1 0\n1 1 1 2 1", "3 3\n0 0 0\n0 1 0\n0 0 0", "3 3\n1 1 1\n1 1 1\n1 1 1"]
2 seconds
["4\nrow 1\nrow 1\ncol 4\nrow 3", "-1", "3\nrow 1\nrow 2\nrow 3"]
NoteIn the first test case, Karen has a grid with 3 rows and 5 columns. She can perform the following 4 moves to beat the level: In the second test case, Karen has a grid with 3 rows and 3 columns. It is clear that it is impossible to beat the level; performing any move will create three 1s on the grid, but it is requ...
Java 8
standard input
[ "implementation", "greedy", "brute force" ]
b19ab2db46484f0c9b49cf261502bf64
The first line of input contains two integers, n and m (1 ≤ n, m ≤ 100), the number of rows and the number of columns in the grid, respectively. The next n lines each contain m integers. In particular, the j-th integer in the i-th of these rows contains gi, j (0 ≤ gi, j ≤ 500).
1,700
If there is an error and it is actually not possible to beat the level, output a single integer -1. Otherwise, on the first line, output a single integer k, the minimum number of moves necessary to beat the level. The next k lines should each contain one of the following, describing the moves in the order they must be ...
standard output
PASSED
7ef46f49926e9b8e00d656086517515b
train_002.jsonl
1497710100
On the way to school, Karen became fixated on the puzzle game on her phone! The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.One move consists of choosing one row or column, and adding 1 to all of the cells in that row or column.To win ...
512 megabytes
import java.util.*; import javax.swing.text.AbstractDocument.LeafElement; import java.io.*; import java.lang.*; import java.lang.Character.Subset; import java.math.*; public class cf3 { static class pair implements Comparable<pair> { Long x,y; pair(long x,long y) { this.x=x; this.y=y; } pub...
Java
["3 5\n2 2 2 3 2\n0 0 0 1 0\n1 1 1 2 1", "3 3\n0 0 0\n0 1 0\n0 0 0", "3 3\n1 1 1\n1 1 1\n1 1 1"]
2 seconds
["4\nrow 1\nrow 1\ncol 4\nrow 3", "-1", "3\nrow 1\nrow 2\nrow 3"]
NoteIn the first test case, Karen has a grid with 3 rows and 5 columns. She can perform the following 4 moves to beat the level: In the second test case, Karen has a grid with 3 rows and 3 columns. It is clear that it is impossible to beat the level; performing any move will create three 1s on the grid, but it is requ...
Java 8
standard input
[ "implementation", "greedy", "brute force" ]
b19ab2db46484f0c9b49cf261502bf64
The first line of input contains two integers, n and m (1 ≤ n, m ≤ 100), the number of rows and the number of columns in the grid, respectively. The next n lines each contain m integers. In particular, the j-th integer in the i-th of these rows contains gi, j (0 ≤ gi, j ≤ 500).
1,700
If there is an error and it is actually not possible to beat the level, output a single integer -1. Otherwise, on the first line, output a single integer k, the minimum number of moves necessary to beat the level. The next k lines should each contain one of the following, describing the moves in the order they must be ...
standard output
PASSED
473ba63a9383cc27b8116ba5e35552d6
train_002.jsonl
1497710100
On the way to school, Karen became fixated on the puzzle game on her phone! The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.One move consists of choosing one row or column, and adding 1 to all of the cells in that row or column.To win ...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; public class Main { static BufferedReader in; static PrintWriter out; static StringTokenizer buffer; ...
Java
["3 5\n2 2 2 3 2\n0 0 0 1 0\n1 1 1 2 1", "3 3\n0 0 0\n0 1 0\n0 0 0", "3 3\n1 1 1\n1 1 1\n1 1 1"]
2 seconds
["4\nrow 1\nrow 1\ncol 4\nrow 3", "-1", "3\nrow 1\nrow 2\nrow 3"]
NoteIn the first test case, Karen has a grid with 3 rows and 5 columns. She can perform the following 4 moves to beat the level: In the second test case, Karen has a grid with 3 rows and 3 columns. It is clear that it is impossible to beat the level; performing any move will create three 1s on the grid, but it is requ...
Java 8
standard input
[ "implementation", "greedy", "brute force" ]
b19ab2db46484f0c9b49cf261502bf64
The first line of input contains two integers, n and m (1 ≤ n, m ≤ 100), the number of rows and the number of columns in the grid, respectively. The next n lines each contain m integers. In particular, the j-th integer in the i-th of these rows contains gi, j (0 ≤ gi, j ≤ 500).
1,700
If there is an error and it is actually not possible to beat the level, output a single integer -1. Otherwise, on the first line, output a single integer k, the minimum number of moves necessary to beat the level. The next k lines should each contain one of the following, describing the moves in the order they must be ...
standard output
PASSED
36965b0f8eb293edc4a4d15d28a92170
train_002.jsonl
1497710100
On the way to school, Karen became fixated on the puzzle game on her phone! The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.One move consists of choosing one row or column, and adding 1 to all of the cells in that row or column.To win ...
512 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { FastScanner sc = new FastScanner(); PrintWriter pw = new PrintWriter(System.out); while (sc.hasNext()) { int n=sc.nextInt(); int m=sc.nextInt(); int[][]maze=new int[n][m]; for(int i=0;i<n;i++){ for(...
Java
["3 5\n2 2 2 3 2\n0 0 0 1 0\n1 1 1 2 1", "3 3\n0 0 0\n0 1 0\n0 0 0", "3 3\n1 1 1\n1 1 1\n1 1 1"]
2 seconds
["4\nrow 1\nrow 1\ncol 4\nrow 3", "-1", "3\nrow 1\nrow 2\nrow 3"]
NoteIn the first test case, Karen has a grid with 3 rows and 5 columns. She can perform the following 4 moves to beat the level: In the second test case, Karen has a grid with 3 rows and 3 columns. It is clear that it is impossible to beat the level; performing any move will create three 1s on the grid, but it is requ...
Java 8
standard input
[ "implementation", "greedy", "brute force" ]
b19ab2db46484f0c9b49cf261502bf64
The first line of input contains two integers, n and m (1 ≤ n, m ≤ 100), the number of rows and the number of columns in the grid, respectively. The next n lines each contain m integers. In particular, the j-th integer in the i-th of these rows contains gi, j (0 ≤ gi, j ≤ 500).
1,700
If there is an error and it is actually not possible to beat the level, output a single integer -1. Otherwise, on the first line, output a single integer k, the minimum number of moves necessary to beat the level. The next k lines should each contain one of the following, describing the moves in the order they must be ...
standard output
PASSED
8ba0cf591ed0abcd3943a6fac43eb817
train_002.jsonl
1497710100
On the way to school, Karen became fixated on the puzzle game on her phone! The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.One move consists of choosing one row or column, and adding 1 to all of the cells in that row or column.To win ...
512 megabytes
import java.util.*; public class q3 { public static void main (String[] args) throws java.lang.Exception { Scanner sc = new Scanner(System.in); int h = sc.nextInt(); int w = sc.nextInt(); int [][] g = new int[h][w]; int [] rmin = new int[h]; int [] cmin = new int[w]; int min = 501,sum = 0,rsum = 0,csum...
Java
["3 5\n2 2 2 3 2\n0 0 0 1 0\n1 1 1 2 1", "3 3\n0 0 0\n0 1 0\n0 0 0", "3 3\n1 1 1\n1 1 1\n1 1 1"]
2 seconds
["4\nrow 1\nrow 1\ncol 4\nrow 3", "-1", "3\nrow 1\nrow 2\nrow 3"]
NoteIn the first test case, Karen has a grid with 3 rows and 5 columns. She can perform the following 4 moves to beat the level: In the second test case, Karen has a grid with 3 rows and 3 columns. It is clear that it is impossible to beat the level; performing any move will create three 1s on the grid, but it is requ...
Java 8
standard input
[ "implementation", "greedy", "brute force" ]
b19ab2db46484f0c9b49cf261502bf64
The first line of input contains two integers, n and m (1 ≤ n, m ≤ 100), the number of rows and the number of columns in the grid, respectively. The next n lines each contain m integers. In particular, the j-th integer in the i-th of these rows contains gi, j (0 ≤ gi, j ≤ 500).
1,700
If there is an error and it is actually not possible to beat the level, output a single integer -1. Otherwise, on the first line, output a single integer k, the minimum number of moves necessary to beat the level. The next k lines should each contain one of the following, describing the moves in the order they must be ...
standard output
PASSED
dda7239685598ba065b1015bf6c480fd
train_002.jsonl
1497710100
On the way to school, Karen became fixated on the puzzle game on her phone! The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.One move consists of choosing one row or column, and adding 1 to all of the cells in that row or column.To win ...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; /** * * @author Don Li */ public class KarenGame2 { int INF = (int) 1e9; void solve() { ...
Java
["3 5\n2 2 2 3 2\n0 0 0 1 0\n1 1 1 2 1", "3 3\n0 0 0\n0 1 0\n0 0 0", "3 3\n1 1 1\n1 1 1\n1 1 1"]
2 seconds
["4\nrow 1\nrow 1\ncol 4\nrow 3", "-1", "3\nrow 1\nrow 2\nrow 3"]
NoteIn the first test case, Karen has a grid with 3 rows and 5 columns. She can perform the following 4 moves to beat the level: In the second test case, Karen has a grid with 3 rows and 3 columns. It is clear that it is impossible to beat the level; performing any move will create three 1s on the grid, but it is requ...
Java 8
standard input
[ "implementation", "greedy", "brute force" ]
b19ab2db46484f0c9b49cf261502bf64
The first line of input contains two integers, n and m (1 ≤ n, m ≤ 100), the number of rows and the number of columns in the grid, respectively. The next n lines each contain m integers. In particular, the j-th integer in the i-th of these rows contains gi, j (0 ≤ gi, j ≤ 500).
1,700
If there is an error and it is actually not possible to beat the level, output a single integer -1. Otherwise, on the first line, output a single integer k, the minimum number of moves necessary to beat the level. The next k lines should each contain one of the following, describing the moves in the order they must be ...
standard output
PASSED
a7a94b72be48d265530d86dbedc55a90
train_002.jsonl
1497710100
On the way to school, Karen became fixated on the puzzle game on her phone! The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.One move consists of choosing one row or column, and adding 1 to all of the cells in that row or column.To win ...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; /** * * @author Don Li */ public class KarenGame3 { int N = 110; int n, m; int[][] g; int[] row = new int[N], col = new int[N]; ...
Java
["3 5\n2 2 2 3 2\n0 0 0 1 0\n1 1 1 2 1", "3 3\n0 0 0\n0 1 0\n0 0 0", "3 3\n1 1 1\n1 1 1\n1 1 1"]
2 seconds
["4\nrow 1\nrow 1\ncol 4\nrow 3", "-1", "3\nrow 1\nrow 2\nrow 3"]
NoteIn the first test case, Karen has a grid with 3 rows and 5 columns. She can perform the following 4 moves to beat the level: In the second test case, Karen has a grid with 3 rows and 3 columns. It is clear that it is impossible to beat the level; performing any move will create three 1s on the grid, but it is requ...
Java 8
standard input
[ "implementation", "greedy", "brute force" ]
b19ab2db46484f0c9b49cf261502bf64
The first line of input contains two integers, n and m (1 ≤ n, m ≤ 100), the number of rows and the number of columns in the grid, respectively. The next n lines each contain m integers. In particular, the j-th integer in the i-th of these rows contains gi, j (0 ≤ gi, j ≤ 500).
1,700
If there is an error and it is actually not possible to beat the level, output a single integer -1. Otherwise, on the first line, output a single integer k, the minimum number of moves necessary to beat the level. The next k lines should each contain one of the following, describing the moves in the order they must be ...
standard output
PASSED
a7275fad90db089c8b288f5e17946860
train_002.jsonl
1497710100
On the way to school, Karen became fixated on the puzzle game on her phone! The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.One move consists of choosing one row or column, and adding 1 to all of the cells in that row or column.To win ...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.StringTokenizer; /** * @author Don Li */ public class KarenGame { void solve() { int n = in...
Java
["3 5\n2 2 2 3 2\n0 0 0 1 0\n1 1 1 2 1", "3 3\n0 0 0\n0 1 0\n0 0 0", "3 3\n1 1 1\n1 1 1\n1 1 1"]
2 seconds
["4\nrow 1\nrow 1\ncol 4\nrow 3", "-1", "3\nrow 1\nrow 2\nrow 3"]
NoteIn the first test case, Karen has a grid with 3 rows and 5 columns. She can perform the following 4 moves to beat the level: In the second test case, Karen has a grid with 3 rows and 3 columns. It is clear that it is impossible to beat the level; performing any move will create three 1s on the grid, but it is requ...
Java 8
standard input
[ "implementation", "greedy", "brute force" ]
b19ab2db46484f0c9b49cf261502bf64
The first line of input contains two integers, n and m (1 ≤ n, m ≤ 100), the number of rows and the number of columns in the grid, respectively. The next n lines each contain m integers. In particular, the j-th integer in the i-th of these rows contains gi, j (0 ≤ gi, j ≤ 500).
1,700
If there is an error and it is actually not possible to beat the level, output a single integer -1. Otherwise, on the first line, output a single integer k, the minimum number of moves necessary to beat the level. The next k lines should each contain one of the following, describing the moves in the order they must be ...
standard output
PASSED
8b4e709ef9b2dd0a810146730d6519e3
train_002.jsonl
1497710100
On the way to school, Karen became fixated on the puzzle game on her phone! The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.One move consists of choosing one row or column, and adding 1 to all of the cells in that row or column.To win ...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; /** * @author Don Li */ public class KarenGame3 { int N = 110; int n, m; int[][] g; int[] row = new int[N], col = new int[N]; ...
Java
["3 5\n2 2 2 3 2\n0 0 0 1 0\n1 1 1 2 1", "3 3\n0 0 0\n0 1 0\n0 0 0", "3 3\n1 1 1\n1 1 1\n1 1 1"]
2 seconds
["4\nrow 1\nrow 1\ncol 4\nrow 3", "-1", "3\nrow 1\nrow 2\nrow 3"]
NoteIn the first test case, Karen has a grid with 3 rows and 5 columns. She can perform the following 4 moves to beat the level: In the second test case, Karen has a grid with 3 rows and 3 columns. It is clear that it is impossible to beat the level; performing any move will create three 1s on the grid, but it is requ...
Java 8
standard input
[ "implementation", "greedy", "brute force" ]
b19ab2db46484f0c9b49cf261502bf64
The first line of input contains two integers, n and m (1 ≤ n, m ≤ 100), the number of rows and the number of columns in the grid, respectively. The next n lines each contain m integers. In particular, the j-th integer in the i-th of these rows contains gi, j (0 ≤ gi, j ≤ 500).
1,700
If there is an error and it is actually not possible to beat the level, output a single integer -1. Otherwise, on the first line, output a single integer k, the minimum number of moves necessary to beat the level. The next k lines should each contain one of the following, describing the moves in the order they must be ...
standard output
PASSED
78ff81da11da84c0d0bcb8325d67d901
train_002.jsonl
1497710100
On the way to school, Karen became fixated on the puzzle game on her phone! The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.One move consists of choosing one row or column, and adding 1 to all of the cells in that row or column.To win ...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import static java.lang.Math.*; import static java.util.Arrays.*; public class ProblemC3 { BufferedReader rd; ProblemC3() throws IOException { rd = new Buffe...
Java
["3 5\n2 2 2 3 2\n0 0 0 1 0\n1 1 1 2 1", "3 3\n0 0 0\n0 1 0\n0 0 0", "3 3\n1 1 1\n1 1 1\n1 1 1"]
2 seconds
["4\nrow 1\nrow 1\ncol 4\nrow 3", "-1", "3\nrow 1\nrow 2\nrow 3"]
NoteIn the first test case, Karen has a grid with 3 rows and 5 columns. She can perform the following 4 moves to beat the level: In the second test case, Karen has a grid with 3 rows and 3 columns. It is clear that it is impossible to beat the level; performing any move will create three 1s on the grid, but it is requ...
Java 8
standard input
[ "implementation", "greedy", "brute force" ]
b19ab2db46484f0c9b49cf261502bf64
The first line of input contains two integers, n and m (1 ≤ n, m ≤ 100), the number of rows and the number of columns in the grid, respectively. The next n lines each contain m integers. In particular, the j-th integer in the i-th of these rows contains gi, j (0 ≤ gi, j ≤ 500).
1,700
If there is an error and it is actually not possible to beat the level, output a single integer -1. Otherwise, on the first line, output a single integer k, the minimum number of moves necessary to beat the level. The next k lines should each contain one of the following, describing the moves in the order they must be ...
standard output
PASSED
c93f9b5b54cd0c321fbfa1bc862dd02b
train_002.jsonl
1497710100
On the way to school, Karen became fixated on the puzzle game on her phone! The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.One move consists of choosing one row or column, and adding 1 to all of the cells in that row or column.To win ...
512 megabytes
import java.io.*; import java.util.*; import java.math.*; /** * created by asheshvidyut on 17/06/17 **/ public class C { public static void main(String args[]) { try { InputReader in = new InputReader(System.in); BufferedWriter out = new BufferedWriter(new OutputStreamWriter(Syste...
Java
["3 5\n2 2 2 3 2\n0 0 0 1 0\n1 1 1 2 1", "3 3\n0 0 0\n0 1 0\n0 0 0", "3 3\n1 1 1\n1 1 1\n1 1 1"]
2 seconds
["4\nrow 1\nrow 1\ncol 4\nrow 3", "-1", "3\nrow 1\nrow 2\nrow 3"]
NoteIn the first test case, Karen has a grid with 3 rows and 5 columns. She can perform the following 4 moves to beat the level: In the second test case, Karen has a grid with 3 rows and 3 columns. It is clear that it is impossible to beat the level; performing any move will create three 1s on the grid, but it is requ...
Java 8
standard input
[ "implementation", "greedy", "brute force" ]
b19ab2db46484f0c9b49cf261502bf64
The first line of input contains two integers, n and m (1 ≤ n, m ≤ 100), the number of rows and the number of columns in the grid, respectively. The next n lines each contain m integers. In particular, the j-th integer in the i-th of these rows contains gi, j (0 ≤ gi, j ≤ 500).
1,700
If there is an error and it is actually not possible to beat the level, output a single integer -1. Otherwise, on the first line, output a single integer k, the minimum number of moves necessary to beat the level. The next k lines should each contain one of the following, describing the moves in the order they must be ...
standard output
PASSED
5764e5dac115aad7d05abd66c0cd5f49
train_002.jsonl
1497710100
On the way to school, Karen became fixated on the puzzle game on her phone! The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.One move consists of choosing one row or column, and adding 1 to all of the cells in that row or column.To win ...
512 megabytes
import java.util.ArrayList; import java.util.List; import java.util.Scanner; /** * Created by imahmoud on 5/13/17. */ public class C { public void solve(){ Scanner in = new Scanner(System.in); int N1 = in.nextInt(); int N2 = in.nextInt(); int[][] grid; int W,H; ...
Java
["3 5\n2 2 2 3 2\n0 0 0 1 0\n1 1 1 2 1", "3 3\n0 0 0\n0 1 0\n0 0 0", "3 3\n1 1 1\n1 1 1\n1 1 1"]
2 seconds
["4\nrow 1\nrow 1\ncol 4\nrow 3", "-1", "3\nrow 1\nrow 2\nrow 3"]
NoteIn the first test case, Karen has a grid with 3 rows and 5 columns. She can perform the following 4 moves to beat the level: In the second test case, Karen has a grid with 3 rows and 3 columns. It is clear that it is impossible to beat the level; performing any move will create three 1s on the grid, but it is requ...
Java 8
standard input
[ "implementation", "greedy", "brute force" ]
b19ab2db46484f0c9b49cf261502bf64
The first line of input contains two integers, n and m (1 ≤ n, m ≤ 100), the number of rows and the number of columns in the grid, respectively. The next n lines each contain m integers. In particular, the j-th integer in the i-th of these rows contains gi, j (0 ≤ gi, j ≤ 500).
1,700
If there is an error and it is actually not possible to beat the level, output a single integer -1. Otherwise, on the first line, output a single integer k, the minimum number of moves necessary to beat the level. The next k lines should each contain one of the following, describing the moves in the order they must be ...
standard output
PASSED
219c39e59dcbbbe4bdd2cc566e64d7d2
train_002.jsonl
1497710100
On the way to school, Karen became fixated on the puzzle game on her phone! The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.One move consists of choosing one row or column, and adding 1 to all of the cells in that row or column.To win ...
512 megabytes
//package cf816; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.util.ArrayList; import java.util.StringTokenizer; publ...
Java
["3 5\n2 2 2 3 2\n0 0 0 1 0\n1 1 1 2 1", "3 3\n0 0 0\n0 1 0\n0 0 0", "3 3\n1 1 1\n1 1 1\n1 1 1"]
2 seconds
["4\nrow 1\nrow 1\ncol 4\nrow 3", "-1", "3\nrow 1\nrow 2\nrow 3"]
NoteIn the first test case, Karen has a grid with 3 rows and 5 columns. She can perform the following 4 moves to beat the level: In the second test case, Karen has a grid with 3 rows and 3 columns. It is clear that it is impossible to beat the level; performing any move will create three 1s on the grid, but it is requ...
Java 8
standard input
[ "implementation", "greedy", "brute force" ]
b19ab2db46484f0c9b49cf261502bf64
The first line of input contains two integers, n and m (1 ≤ n, m ≤ 100), the number of rows and the number of columns in the grid, respectively. The next n lines each contain m integers. In particular, the j-th integer in the i-th of these rows contains gi, j (0 ≤ gi, j ≤ 500).
1,700
If there is an error and it is actually not possible to beat the level, output a single integer -1. Otherwise, on the first line, output a single integer k, the minimum number of moves necessary to beat the level. The next k lines should each contain one of the following, describing the moves in the order they must be ...
standard output
PASSED
4b67735a4cf134836995eaa4b9d2c395
train_002.jsonl
1508773500
One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain only letters "a" and the 2-nd contains only letters "b".Nikita wants to make the...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; /** * Built using CHelper plug-in Actual solution is at the top * * @author dima */ public class Main { public static void main(String[] args) { InputStream inputS...
Java
["abba", "bab"]
2 seconds
["4", "2"]
NoteIt the first sample the string is already beautiful.In the second sample he needs to delete one of "b" to make it beautiful.
Java 8
standard input
[ "dp", "brute force" ]
c768f3e52e562ae1fd47502a60dbadfe
The first line contains a non-empty string of length not greater than 5 000 containing only lowercase English letters "a" and "b".
1,500
Print a single integer — the maximum possible size of beautiful string Nikita can get.
standard output
PASSED
bc07fa8ca08eb169cf65eeb24858a320
train_002.jsonl
1508773500
One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain only letters "a" and the 2-nd contains only letters "b".Nikita wants to make the...
256 megabytes
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.UnsupportedEncodingException; import java.util.StringTokenizer; public class Main { ...
Java
["abba", "bab"]
2 seconds
["4", "2"]
NoteIt the first sample the string is already beautiful.In the second sample he needs to delete one of "b" to make it beautiful.
Java 8
standard input
[ "dp", "brute force" ]
c768f3e52e562ae1fd47502a60dbadfe
The first line contains a non-empty string of length not greater than 5 000 containing only lowercase English letters "a" and "b".
1,500
Print a single integer — the maximum possible size of beautiful string Nikita can get.
standard output
PASSED
2a8d7feb28ca29a49831d88738439c1c
train_002.jsonl
1508773500
One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain only letters "a" and the 2-nd contains only letters "b".Nikita wants to make the...
256 megabytes
import java.io.*; import java.util.*; public class C { public static void main(String args[])throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); StringBuilder out=new StringBuilder(""); StringTokenizer st; String s=br.readLine(); i...
Java
["abba", "bab"]
2 seconds
["4", "2"]
NoteIt the first sample the string is already beautiful.In the second sample he needs to delete one of "b" to make it beautiful.
Java 8
standard input
[ "dp", "brute force" ]
c768f3e52e562ae1fd47502a60dbadfe
The first line contains a non-empty string of length not greater than 5 000 containing only lowercase English letters "a" and "b".
1,500
Print a single integer — the maximum possible size of beautiful string Nikita can get.
standard output
PASSED
ef9825ba3e6bc2fbacad6557d66db90e
train_002.jsonl
1508773500
One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain only letters "a" and the 2-nd contains only letters "b".Nikita wants to make the...
256 megabytes
import java.io.*; import java.util.Arrays; import java.util.StringTokenizer; public class B { static String s; static int[][] dp; static int solve(int st, int i) { if(i == s.length() || st > 2) return 0; if(dp[st][i] != -1) return dp[st][i]; int req = st % 2...
Java
["abba", "bab"]
2 seconds
["4", "2"]
NoteIt the first sample the string is already beautiful.In the second sample he needs to delete one of "b" to make it beautiful.
Java 8
standard input
[ "dp", "brute force" ]
c768f3e52e562ae1fd47502a60dbadfe
The first line contains a non-empty string of length not greater than 5 000 containing only lowercase English letters "a" and "b".
1,500
Print a single integer — the maximum possible size of beautiful string Nikita can get.
standard output
PASSED
4c825ce67c3861a8a8bc3577fc64278b
train_002.jsonl
1508773500
One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain only letters "a" and the 2-nd contains only letters "b".Nikita wants to make the...
256 megabytes
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; import java.math.BigDecimal; import java.math.BigInteger; public class JavaApplication9 { //****************************************************************...
Java
["abba", "bab"]
2 seconds
["4", "2"]
NoteIt the first sample the string is already beautiful.In the second sample he needs to delete one of "b" to make it beautiful.
Java 8
standard input
[ "dp", "brute force" ]
c768f3e52e562ae1fd47502a60dbadfe
The first line contains a non-empty string of length not greater than 5 000 containing only lowercase English letters "a" and "b".
1,500
Print a single integer — the maximum possible size of beautiful string Nikita can get.
standard output
PASSED
5a995609966af6a4fe86386047e0840b
train_002.jsonl
1508773500
One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain only letters "a" and the 2-nd contains only letters "b".Nikita wants to make the...
256 megabytes
/** * DA-IICT * Author : PARTH PATEL */ import java.io.*; import java.math.*; import java.util.*; import static java.util.Arrays.fill; import static java.lang.Math.*; import static java.util.Arrays.sort; import static java.util.Collections.sort; public class B877 { public static int mod = 1000000007; static F...
Java
["abba", "bab"]
2 seconds
["4", "2"]
NoteIt the first sample the string is already beautiful.In the second sample he needs to delete one of "b" to make it beautiful.
Java 8
standard input
[ "dp", "brute force" ]
c768f3e52e562ae1fd47502a60dbadfe
The first line contains a non-empty string of length not greater than 5 000 containing only lowercase English letters "a" and "b".
1,500
Print a single integer — the maximum possible size of beautiful string Nikita can get.
standard output
PASSED
fe213929a515749c6f91eb51b81ac2a4
train_002.jsonl
1508773500
One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain only letters "a" and the 2-nd contains only letters "b".Nikita wants to make the...
256 megabytes
/** * DA-IICT * Author : PARTH PATEL */ import java.io.*; import java.math.*; import java.util.*; import static java.util.Arrays.fill; import static java.lang.Math.*; import static java.util.Arrays.sort; import static java.util.Collections.sort; public class B877 { public static int mod = 1000000007; static F...
Java
["abba", "bab"]
2 seconds
["4", "2"]
NoteIt the first sample the string is already beautiful.In the second sample he needs to delete one of "b" to make it beautiful.
Java 8
standard input
[ "dp", "brute force" ]
c768f3e52e562ae1fd47502a60dbadfe
The first line contains a non-empty string of length not greater than 5 000 containing only lowercase English letters "a" and "b".
1,500
Print a single integer — the maximum possible size of beautiful string Nikita can get.
standard output
PASSED
3de7b6c92476eb34c52bc11de1e3b50f
train_002.jsonl
1508773500
One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain only letters "a" and the 2-nd contains only letters "b".Nikita wants to make the...
256 megabytes
import java.util.*; import java.io.*; import java.lang.Math.*; public class MainA { static int mod = (int) 1e9 + 7; public static void main(String[] args) throws java.lang.Exception { InputReader in = new InputReader(System.in); PrintWriter out=new PrintWriter(System.out); String s=in.nextLine(); int ans...
Java
["abba", "bab"]
2 seconds
["4", "2"]
NoteIt the first sample the string is already beautiful.In the second sample he needs to delete one of "b" to make it beautiful.
Java 8
standard input
[ "dp", "brute force" ]
c768f3e52e562ae1fd47502a60dbadfe
The first line contains a non-empty string of length not greater than 5 000 containing only lowercase English letters "a" and "b".
1,500
Print a single integer — the maximum possible size of beautiful string Nikita can get.
standard output
PASSED
402b8a4f2202292ce93dd8c9f5b452ee
train_002.jsonl
1508773500
One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain only letters "a" and the 2-nd contains only letters "b".Nikita wants to make the...
256 megabytes
import java.util.*; public class Solution { public static void main(String [] args) { Scanner sc=new Scanner(System.in); String str=sc.nextLine(); int n=str.length(); int [] a=new int[n+1]; int [] b=new int[n+1]; int counta=0,countb=0,ans=0; for(int i=1;i<...
Java
["abba", "bab"]
2 seconds
["4", "2"]
NoteIt the first sample the string is already beautiful.In the second sample he needs to delete one of "b" to make it beautiful.
Java 8
standard input
[ "dp", "brute force" ]
c768f3e52e562ae1fd47502a60dbadfe
The first line contains a non-empty string of length not greater than 5 000 containing only lowercase English letters "a" and "b".
1,500
Print a single integer — the maximum possible size of beautiful string Nikita can get.
standard output
PASSED
1ed0927bd8dc01853116ef731f377276
train_002.jsonl
1508773500
One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain only letters "a" and the 2-nd contains only letters "b".Nikita wants to make the...
256 megabytes
import java.io.*; import java.util.*; public class B { static StringBuilder st = new StringBuilder(); static int [][] memo ; static char [] s ; static final int INF = (int) 1e9 ; static int n ; static int dp(int type , int idx) { if(type > 3) return -INF; if(idx == n) return 0 ; if(mem...
Java
["abba", "bab"]
2 seconds
["4", "2"]
NoteIt the first sample the string is already beautiful.In the second sample he needs to delete one of "b" to make it beautiful.
Java 8
standard input
[ "dp", "brute force" ]
c768f3e52e562ae1fd47502a60dbadfe
The first line contains a non-empty string of length not greater than 5 000 containing only lowercase English letters "a" and "b".
1,500
Print a single integer — the maximum possible size of beautiful string Nikita can get.
standard output
PASSED
90da0f868b5f7a57758b7603590ea365
train_002.jsonl
1508773500
One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain only letters "a" and the 2-nd contains only letters "b".Nikita wants to make the...
256 megabytes
import java.io.*; import java.util.*; public class B { static StringBuilder st = new StringBuilder(); public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); String str = sc.next(); int n = str.length() ; ...
Java
["abba", "bab"]
2 seconds
["4", "2"]
NoteIt the first sample the string is already beautiful.In the second sample he needs to delete one of "b" to make it beautiful.
Java 8
standard input
[ "dp", "brute force" ]
c768f3e52e562ae1fd47502a60dbadfe
The first line contains a non-empty string of length not greater than 5 000 containing only lowercase English letters "a" and "b".
1,500
Print a single integer — the maximum possible size of beautiful string Nikita can get.
standard output
PASSED
6cac5800c9c4615966ca62cac7c33cdc
train_002.jsonl
1508773500
One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain only letters "a" and the 2-nd contains only letters "b".Nikita wants to make the...
256 megabytes
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.lang.reflect.Array; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Col...
Java
["abba", "bab"]
2 seconds
["4", "2"]
NoteIt the first sample the string is already beautiful.In the second sample he needs to delete one of "b" to make it beautiful.
Java 8
standard input
[ "dp", "brute force" ]
c768f3e52e562ae1fd47502a60dbadfe
The first line contains a non-empty string of length not greater than 5 000 containing only lowercase English letters "a" and "b".
1,500
Print a single integer — the maximum possible size of beautiful string Nikita can get.
standard output
PASSED
82ad919146b261917bd613b2285e70e9
train_002.jsonl
1508773500
One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain only letters "a" and the 2-nd contains only letters "b".Nikita wants to make the...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class R442B { public static void main (String[] args) throws java.lang.Exception { InputReader in = new InputReader(System.in); PrintWriter w = new PrintWriter(System.out); String s = in.next(); int n = s.length(); ...
Java
["abba", "bab"]
2 seconds
["4", "2"]
NoteIt the first sample the string is already beautiful.In the second sample he needs to delete one of "b" to make it beautiful.
Java 8
standard input
[ "dp", "brute force" ]
c768f3e52e562ae1fd47502a60dbadfe
The first line contains a non-empty string of length not greater than 5 000 containing only lowercase English letters "a" and "b".
1,500
Print a single integer — the maximum possible size of beautiful string Nikita can get.
standard output
PASSED
ed28066d3a29e48a4fd2427cdab2cddd
train_002.jsonl
1508773500
One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain only letters "a" and the 2-nd contains only letters "b".Nikita wants to make the...
256 megabytes
import java.util.*; public class Nikita_and_string { public static void main(String args[]) { Scanner scan = new Scanner(System.in); String letters = scan.next(); int len = letters.length(); List<Integer> la = new ArrayList<>(); int laCount = 0;la.add(laCount); ...
Java
["abba", "bab"]
2 seconds
["4", "2"]
NoteIt the first sample the string is already beautiful.In the second sample he needs to delete one of "b" to make it beautiful.
Java 8
standard input
[ "dp", "brute force" ]
c768f3e52e562ae1fd47502a60dbadfe
The first line contains a non-empty string of length not greater than 5 000 containing only lowercase English letters "a" and "b".
1,500
Print a single integer — the maximum possible size of beautiful string Nikita can get.
standard output
PASSED
644773d635efcc6eca3452a9515a18c8
train_002.jsonl
1508773500
One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain only letters "a" and the 2-nd contains only letters "b".Nikita wants to make the...
256 megabytes
import java.util.*; public class Nikita_and_string { public static void main(String args[]) { Scanner scan = new Scanner(System.in); String letters = scan.next(); int len = letters.length(); int prefixA[] = new int[len+1]; int prefixB[] = new int[len+1]; ...
Java
["abba", "bab"]
2 seconds
["4", "2"]
NoteIt the first sample the string is already beautiful.In the second sample he needs to delete one of "b" to make it beautiful.
Java 8
standard input
[ "dp", "brute force" ]
c768f3e52e562ae1fd47502a60dbadfe
The first line contains a non-empty string of length not greater than 5 000 containing only lowercase English letters "a" and "b".
1,500
Print a single integer — the maximum possible size of beautiful string Nikita can get.
standard output
PASSED
52fe9e10fe0d6b84b6e54687c80b0514
train_002.jsonl
1508773500
One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain only letters "a" and the 2-nd contains only letters "b".Nikita wants to make the...
256 megabytes
import java.util.*; public class Nikita_and_string { public static void main(String args[]) { Scanner scan = new Scanner(System.in); String letters = scan.next(); int len = letters.length(); List<Integer> la = new ArrayList<>(); int laCount = 0;la.add(laCount); ...
Java
["abba", "bab"]
2 seconds
["4", "2"]
NoteIt the first sample the string is already beautiful.In the second sample he needs to delete one of "b" to make it beautiful.
Java 8
standard input
[ "dp", "brute force" ]
c768f3e52e562ae1fd47502a60dbadfe
The first line contains a non-empty string of length not greater than 5 000 containing only lowercase English letters "a" and "b".
1,500
Print a single integer — the maximum possible size of beautiful string Nikita can get.
standard output
PASSED
daa76997ff18e610278a46880b80ce81
train_002.jsonl
1508773500
One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain only letters "a" and the 2-nd contains only letters "b".Nikita wants to make the...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; public class B { static char[] arr; static int[][] dp; public static void main(String[] args) throws IOExcep...
Java
["abba", "bab"]
2 seconds
["4", "2"]
NoteIt the first sample the string is already beautiful.In the second sample he needs to delete one of "b" to make it beautiful.
Java 8
standard input
[ "dp", "brute force" ]
c768f3e52e562ae1fd47502a60dbadfe
The first line contains a non-empty string of length not greater than 5 000 containing only lowercase English letters "a" and "b".
1,500
Print a single integer — the maximum possible size of beautiful string Nikita can get.
standard output
PASSED
d0951a9b734eee16d548515868372e27
train_002.jsonl
1508773500
One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain only letters "a" and the 2-nd contains only letters "b".Nikita wants to make the...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; import java.util.stream.*; @SuppressWarnings("unchecked") public class P877B { int [] sa, sb; int count(int [] s, int i, int j) { return (s[j] - s[i]); } public void run() throws Exception { char [] s = next().toCharArray(); int n = s.len...
Java
["abba", "bab"]
2 seconds
["4", "2"]
NoteIt the first sample the string is already beautiful.In the second sample he needs to delete one of "b" to make it beautiful.
Java 8
standard input
[ "dp", "brute force" ]
c768f3e52e562ae1fd47502a60dbadfe
The first line contains a non-empty string of length not greater than 5 000 containing only lowercase English letters "a" and "b".
1,500
Print a single integer — the maximum possible size of beautiful string Nikita can get.
standard output
PASSED
0ca533a452b13686c7bd00fec54d3c0c
train_002.jsonl
1508773500
One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain only letters "a" and the 2-nd contains only letters "b".Nikita wants to make the...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class NikitaAndString { static class Section { boolean a; int length; } public static void main(String[] args) throws IOException { BufferedReader r = new BufferedReader(new InputStreamReader(System.in)); ...
Java
["abba", "bab"]
2 seconds
["4", "2"]
NoteIt the first sample the string is already beautiful.In the second sample he needs to delete one of "b" to make it beautiful.
Java 8
standard input
[ "dp", "brute force" ]
c768f3e52e562ae1fd47502a60dbadfe
The first line contains a non-empty string of length not greater than 5 000 containing only lowercase English letters "a" and "b".
1,500
Print a single integer — the maximum possible size of beautiful string Nikita can get.
standard output
PASSED
b6d90683da1321712b7811514e081029
train_002.jsonl
1508773500
One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain only letters "a" and the 2-nd contains only letters "b".Nikita wants to make the...
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.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.io.Writer; import java.io.OutputStreamW...
Java
["abba", "bab"]
2 seconds
["4", "2"]
NoteIt the first sample the string is already beautiful.In the second sample he needs to delete one of "b" to make it beautiful.
Java 8
standard input
[ "dp", "brute force" ]
c768f3e52e562ae1fd47502a60dbadfe
The first line contains a non-empty string of length not greater than 5 000 containing only lowercase English letters "a" and "b".
1,500
Print a single integer — the maximum possible size of beautiful string Nikita can get.
standard output
PASSED
dfd3d1f0409b087ad7ffe553a823d8e8
train_002.jsonl
1508773500
One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain only letters "a" and the 2-nd contains only letters "b".Nikita wants to make the...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class sol { private static int N; private static final int A = 1; private static final int B = 2; private static int[] values; private static int[] dpA; private static int[] dpB; public static void main(String[]...
Java
["abba", "bab"]
2 seconds
["4", "2"]
NoteIt the first sample the string is already beautiful.In the second sample he needs to delete one of "b" to make it beautiful.
Java 8
standard input
[ "dp", "brute force" ]
c768f3e52e562ae1fd47502a60dbadfe
The first line contains a non-empty string of length not greater than 5 000 containing only lowercase English letters "a" and "b".
1,500
Print a single integer — the maximum possible size of beautiful string Nikita can get.
standard output
PASSED
807dc32985ac7ea5e6d275037e9cec9e
train_002.jsonl
1508773500
One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain only letters "a" and the 2-nd contains only letters "b".Nikita wants to make the...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class sol { private static int N; private static final int A = 1; private static final int B = 2; private static int[] values; private static int[] dpA; private static int[] dpB; public static void main(String[]...
Java
["abba", "bab"]
2 seconds
["4", "2"]
NoteIt the first sample the string is already beautiful.In the second sample he needs to delete one of "b" to make it beautiful.
Java 8
standard input
[ "dp", "brute force" ]
c768f3e52e562ae1fd47502a60dbadfe
The first line contains a non-empty string of length not greater than 5 000 containing only lowercase English letters "a" and "b".
1,500
Print a single integer — the maximum possible size of beautiful string Nikita can get.
standard output
PASSED
e4434dd007ec915474759cc3e1f29cc6
train_002.jsonl
1508773500
One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain only letters "a" and the 2-nd contains only letters "b".Nikita wants to make the...
256 megabytes
import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class StringAndNikata { public static void main(String[] args) { String line=new Scanner(System.in).nextLine(); ArrayList<Integer> lengths=new ArrayList<Integer>(); int position=0; dp=new int[line.length()][3]; for (int i...
Java
["abba", "bab"]
2 seconds
["4", "2"]
NoteIt the first sample the string is already beautiful.In the second sample he needs to delete one of "b" to make it beautiful.
Java 8
standard input
[ "dp", "brute force" ]
c768f3e52e562ae1fd47502a60dbadfe
The first line contains a non-empty string of length not greater than 5 000 containing only lowercase English letters "a" and "b".
1,500
Print a single integer — the maximum possible size of beautiful string Nikita can get.
standard output
PASSED
a44d51233cfca412eeedefa5415ebde3
train_002.jsonl
1508773500
One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain only letters "a" and the 2-nd contains only letters "b".Nikita wants to make the...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; import java.util.*; import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.atomic.AtomicLong; import java.util.stream.Collectors; import java.util.stream.IntStream; import java.u...
Java
["abba", "bab"]
2 seconds
["4", "2"]
NoteIt the first sample the string is already beautiful.In the second sample he needs to delete one of "b" to make it beautiful.
Java 8
standard input
[ "dp", "brute force" ]
c768f3e52e562ae1fd47502a60dbadfe
The first line contains a non-empty string of length not greater than 5 000 containing only lowercase English letters "a" and "b".
1,500
Print a single integer — the maximum possible size of beautiful string Nikita can get.
standard output