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
ba9f639cdd2361ea58e377d5487309ce
train_000.jsonl
1570545300
The string $$$t_1t_2 \dots t_k$$$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.Here are some e...
256 megabytes
/*Author: Satyajeet Singh, Delhi Technological University*/ import java.io.*; import java.util.*; import java.text.*; import java.lang.*; import java.math.*; public class Main{ /*********************************************Constants******************************************/ static PrintWrite...
Java
["5\nAABBB", "3\nAAA", "7\nAAABABB"]
2 seconds
["6", "3", "15"]
NoteIn the first test case there are six good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_4$$$, $$$s_1 \dots s_5$$$, $$$s_3 \dots s_4$$$, $$$s_3 \dots s_5$$$ and $$$s_4 \dots s_5$$$.In the second test case there are three good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_3$$$ and $$$s_2 \dots s_3$$$.
Java 8
standard input
[ "dp", "combinatorics", "binary search", "strings" ]
3eb23b7824d06b86be72c70b969be166
The first line contains one integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains the string $$$s$$$, consisting of letters A and B.
1,900
Print one integer — the number of good substrings of string $$$s$$$.
standard output
PASSED
60f9af8c5fa68407cd6ac88f493fa91c
train_000.jsonl
1570545300
The string $$$t_1t_2 \dots t_k$$$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.Here are some e...
256 megabytes
import java.io.*; import java.util.StringTokenizer; import java.util.*; public class Solution { private static final long mod = 1000000007; static int ans = 0; public static void main(String args[]) throws Exception { FastScanner sc = new FastScanner(); PrintWriter out=new PrintWriter(Syst...
Java
["5\nAABBB", "3\nAAA", "7\nAAABABB"]
2 seconds
["6", "3", "15"]
NoteIn the first test case there are six good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_4$$$, $$$s_1 \dots s_5$$$, $$$s_3 \dots s_4$$$, $$$s_3 \dots s_5$$$ and $$$s_4 \dots s_5$$$.In the second test case there are three good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_3$$$ and $$$s_2 \dots s_3$$$.
Java 8
standard input
[ "dp", "combinatorics", "binary search", "strings" ]
3eb23b7824d06b86be72c70b969be166
The first line contains one integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains the string $$$s$$$, consisting of letters A and B.
1,900
Print one integer — the number of good substrings of string $$$s$$$.
standard output
PASSED
59dc62173288c8c96bbcce576f7af201
train_000.jsonl
1570545300
The string $$$t_1t_2 \dots t_k$$$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.Here are some e...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); // number of chars in string scan.nextLine(); String s = scan.nextLine(); // input string String lastChar = "x"; // character just previous i...
Java
["5\nAABBB", "3\nAAA", "7\nAAABABB"]
2 seconds
["6", "3", "15"]
NoteIn the first test case there are six good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_4$$$, $$$s_1 \dots s_5$$$, $$$s_3 \dots s_4$$$, $$$s_3 \dots s_5$$$ and $$$s_4 \dots s_5$$$.In the second test case there are three good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_3$$$ and $$$s_2 \dots s_3$$$.
Java 8
standard input
[ "dp", "combinatorics", "binary search", "strings" ]
3eb23b7824d06b86be72c70b969be166
The first line contains one integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains the string $$$s$$$, consisting of letters A and B.
1,900
Print one integer — the number of good substrings of string $$$s$$$.
standard output
PASSED
7d468df60059e961358c69f16ad6cefc
train_000.jsonl
1570545300
The string $$$t_1t_2 \dots t_k$$$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.Here are some e...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; public class F { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); PrintWriter writer = ne...
Java
["5\nAABBB", "3\nAAA", "7\nAAABABB"]
2 seconds
["6", "3", "15"]
NoteIn the first test case there are six good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_4$$$, $$$s_1 \dots s_5$$$, $$$s_3 \dots s_4$$$, $$$s_3 \dots s_5$$$ and $$$s_4 \dots s_5$$$.In the second test case there are three good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_3$$$ and $$$s_2 \dots s_3$$$.
Java 8
standard input
[ "dp", "combinatorics", "binary search", "strings" ]
3eb23b7824d06b86be72c70b969be166
The first line contains one integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains the string $$$s$$$, consisting of letters A and B.
1,900
Print one integer — the number of good substrings of string $$$s$$$.
standard output
PASSED
0e133b64647be82a59dcf8a67b9f5343
train_000.jsonl
1570545300
The string $$$t_1t_2 \dots t_k$$$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.Here are some e...
256 megabytes
import java.io.*; import java.util.ArrayList; import java.util.StringTokenizer; public class mainD { public static PrintWriter out = new PrintWriter(System.out); public static FastScanner enter = new FastScanner(System.in); public static void main(String[] args) throws IOException { solve(); ...
Java
["5\nAABBB", "3\nAAA", "7\nAAABABB"]
2 seconds
["6", "3", "15"]
NoteIn the first test case there are six good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_4$$$, $$$s_1 \dots s_5$$$, $$$s_3 \dots s_4$$$, $$$s_3 \dots s_5$$$ and $$$s_4 \dots s_5$$$.In the second test case there are three good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_3$$$ and $$$s_2 \dots s_3$$$.
Java 8
standard input
[ "dp", "combinatorics", "binary search", "strings" ]
3eb23b7824d06b86be72c70b969be166
The first line contains one integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains the string $$$s$$$, consisting of letters A and B.
1,900
Print one integer — the number of good substrings of string $$$s$$$.
standard output
PASSED
9cc586e8d1d1cabd2392edab8afd0458
train_000.jsonl
1570545300
The string $$$t_1t_2 \dots t_k$$$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.Here are some e...
256 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.*; public class wef { public static class FastReader { BufferedReader br; StringTokenizer st; //it reads the data about the specified poin...
Java
["5\nAABBB", "3\nAAA", "7\nAAABABB"]
2 seconds
["6", "3", "15"]
NoteIn the first test case there are six good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_4$$$, $$$s_1 \dots s_5$$$, $$$s_3 \dots s_4$$$, $$$s_3 \dots s_5$$$ and $$$s_4 \dots s_5$$$.In the second test case there are three good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_3$$$ and $$$s_2 \dots s_3$$$.
Java 8
standard input
[ "dp", "combinatorics", "binary search", "strings" ]
3eb23b7824d06b86be72c70b969be166
The first line contains one integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains the string $$$s$$$, consisting of letters A and B.
1,900
Print one integer — the number of good substrings of string $$$s$$$.
standard output
PASSED
0be15917cbbf0f616b394fc399311163
train_000.jsonl
1570545300
The string $$$t_1t_2 \dots t_k$$$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.Here are some e...
256 megabytes
import java.io.*; import java.util.*; public class Sol2{ public static void main(String[] args) throws IOException{ FastScanner sc = new FastScanner(); PrintWriter out = new PrintWriter(System.out); TreeSet<Long> idx = new TreeSet<>(); long n= sc.nextLong(); String str = sc.nextToken(); long arr[] = new lo...
Java
["5\nAABBB", "3\nAAA", "7\nAAABABB"]
2 seconds
["6", "3", "15"]
NoteIn the first test case there are six good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_4$$$, $$$s_1 \dots s_5$$$, $$$s_3 \dots s_4$$$, $$$s_3 \dots s_5$$$ and $$$s_4 \dots s_5$$$.In the second test case there are three good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_3$$$ and $$$s_2 \dots s_3$$$.
Java 8
standard input
[ "dp", "combinatorics", "binary search", "strings" ]
3eb23b7824d06b86be72c70b969be166
The first line contains one integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains the string $$$s$$$, consisting of letters A and B.
1,900
Print one integer — the number of good substrings of string $$$s$$$.
standard output
PASSED
5855ea5bdc90b4832c7e5bf673c88915
train_000.jsonl
1570545300
The string $$$t_1t_2 \dots t_k$$$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.Here are some e...
256 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.StringTokenizer; public class EducationalRound74D { public static void solve() { long n=s.nextInt(); String str = s.next(); long ans = (...
Java
["5\nAABBB", "3\nAAA", "7\nAAABABB"]
2 seconds
["6", "3", "15"]
NoteIn the first test case there are six good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_4$$$, $$$s_1 \dots s_5$$$, $$$s_3 \dots s_4$$$, $$$s_3 \dots s_5$$$ and $$$s_4 \dots s_5$$$.In the second test case there are three good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_3$$$ and $$$s_2 \dots s_3$$$.
Java 8
standard input
[ "dp", "combinatorics", "binary search", "strings" ]
3eb23b7824d06b86be72c70b969be166
The first line contains one integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains the string $$$s$$$, consisting of letters A and B.
1,900
Print one integer — the number of good substrings of string $$$s$$$.
standard output
PASSED
a03c72f00b68f246d87a925e6628c0dd
train_000.jsonl
1570545300
The string $$$t_1t_2 \dots t_k$$$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.Here are some e...
256 megabytes
import java.util.*; import java.io.*; public class ABString { public static void main(String[] args) { Scanner sc = new Scanner(System.in); //BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); //StringTokenizer st = new StringTokenizer(br.readLine()); //Print...
Java
["5\nAABBB", "3\nAAA", "7\nAAABABB"]
2 seconds
["6", "3", "15"]
NoteIn the first test case there are six good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_4$$$, $$$s_1 \dots s_5$$$, $$$s_3 \dots s_4$$$, $$$s_3 \dots s_5$$$ and $$$s_4 \dots s_5$$$.In the second test case there are three good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_3$$$ and $$$s_2 \dots s_3$$$.
Java 8
standard input
[ "dp", "combinatorics", "binary search", "strings" ]
3eb23b7824d06b86be72c70b969be166
The first line contains one integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains the string $$$s$$$, consisting of letters A and B.
1,900
Print one integer — the number of good substrings of string $$$s$$$.
standard output
PASSED
167b0c7fbcd2d1d23e034b8d8ae33478
train_000.jsonl
1570545300
The string $$$t_1t_2 \dots t_k$$$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.Here are some e...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class Main { //static final long MOD = 998244353; static final int MOD = 1000000007; static boolean[] visited; public static void main(String[] args) throws IOException { FastScanner sc = new FastScanner(); int N = sc.nextInt(); ...
Java
["5\nAABBB", "3\nAAA", "7\nAAABABB"]
2 seconds
["6", "3", "15"]
NoteIn the first test case there are six good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_4$$$, $$$s_1 \dots s_5$$$, $$$s_3 \dots s_4$$$, $$$s_3 \dots s_5$$$ and $$$s_4 \dots s_5$$$.In the second test case there are three good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_3$$$ and $$$s_2 \dots s_3$$$.
Java 8
standard input
[ "dp", "combinatorics", "binary search", "strings" ]
3eb23b7824d06b86be72c70b969be166
The first line contains one integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains the string $$$s$$$, consisting of letters A and B.
1,900
Print one integer — the number of good substrings of string $$$s$$$.
standard output
PASSED
a0059059e50c5f87df01a4b2c921641b
train_000.jsonl
1570545300
The string $$$t_1t_2 \dots t_k$$$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.Here are some e...
256 megabytes
/* If you want to aim high, aim high Don't let that studying and grades consume you Just live life young ****************************** If I'm the sun, you're the moon Because when I go up, you go down ******************************* */ import java.util.*; import java.io.*; public class D { public static v...
Java
["5\nAABBB", "3\nAAA", "7\nAAABABB"]
2 seconds
["6", "3", "15"]
NoteIn the first test case there are six good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_4$$$, $$$s_1 \dots s_5$$$, $$$s_3 \dots s_4$$$, $$$s_3 \dots s_5$$$ and $$$s_4 \dots s_5$$$.In the second test case there are three good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_3$$$ and $$$s_2 \dots s_3$$$.
Java 8
standard input
[ "dp", "combinatorics", "binary search", "strings" ]
3eb23b7824d06b86be72c70b969be166
The first line contains one integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains the string $$$s$$$, consisting of letters A and B.
1,900
Print one integer — the number of good substrings of string $$$s$$$.
standard output
PASSED
5f23ac202b177cfa23d604d0c4feff54
train_000.jsonl
1570545300
The string $$$t_1t_2 \dots t_k$$$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.Here are some e...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
Java
["5\nAABBB", "3\nAAA", "7\nAAABABB"]
2 seconds
["6", "3", "15"]
NoteIn the first test case there are six good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_4$$$, $$$s_1 \dots s_5$$$, $$$s_3 \dots s_4$$$, $$$s_3 \dots s_5$$$ and $$$s_4 \dots s_5$$$.In the second test case there are three good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_3$$$ and $$$s_2 \dots s_3$$$.
Java 8
standard input
[ "dp", "combinatorics", "binary search", "strings" ]
3eb23b7824d06b86be72c70b969be166
The first line contains one integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains the string $$$s$$$, consisting of letters A and B.
1,900
Print one integer — the number of good substrings of string $$$s$$$.
standard output
PASSED
226ab9dde8c2e52f84709b5f4c819f05
train_000.jsonl
1570545300
The string $$$t_1t_2 \dots t_k$$$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.Here are some e...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; public class D { public static void main(String[] args) throws Exception { //Scanner in = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); BufferedReader br = new BufferedReader(new InputStreamReader...
Java
["5\nAABBB", "3\nAAA", "7\nAAABABB"]
2 seconds
["6", "3", "15"]
NoteIn the first test case there are six good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_4$$$, $$$s_1 \dots s_5$$$, $$$s_3 \dots s_4$$$, $$$s_3 \dots s_5$$$ and $$$s_4 \dots s_5$$$.In the second test case there are three good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_3$$$ and $$$s_2 \dots s_3$$$.
Java 8
standard input
[ "dp", "combinatorics", "binary search", "strings" ]
3eb23b7824d06b86be72c70b969be166
The first line contains one integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains the string $$$s$$$, consisting of letters A and B.
1,900
Print one integer — the number of good substrings of string $$$s$$$.
standard output
PASSED
737af43ef13cd76fb2c98fcd6a9cc354
train_000.jsonl
1570545300
The string $$$t_1t_2 \dots t_k$$$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.Here are some e...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.FilterInputStream; import java.io.BufferedInputStream; import java.io.InputStream; /** * @author khokharnikunj8 */ public class Main { public static void main(String[] args) { ...
Java
["5\nAABBB", "3\nAAA", "7\nAAABABB"]
2 seconds
["6", "3", "15"]
NoteIn the first test case there are six good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_4$$$, $$$s_1 \dots s_5$$$, $$$s_3 \dots s_4$$$, $$$s_3 \dots s_5$$$ and $$$s_4 \dots s_5$$$.In the second test case there are three good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_3$$$ and $$$s_2 \dots s_3$$$.
Java 8
standard input
[ "dp", "combinatorics", "binary search", "strings" ]
3eb23b7824d06b86be72c70b969be166
The first line contains one integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains the string $$$s$$$, consisting of letters A and B.
1,900
Print one integer — the number of good substrings of string $$$s$$$.
standard output
PASSED
eba70b8f18b9e44fe4f887cad96220ff
train_000.jsonl
1570545300
The string $$$t_1t_2 \dots t_k$$$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.Here are some e...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; /** * Created by Katushka on 19.10.2019. */ public class ABString { public static void main(String[] args) { InputReader in = new InputReader(System....
Java
["5\nAABBB", "3\nAAA", "7\nAAABABB"]
2 seconds
["6", "3", "15"]
NoteIn the first test case there are six good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_4$$$, $$$s_1 \dots s_5$$$, $$$s_3 \dots s_4$$$, $$$s_3 \dots s_5$$$ and $$$s_4 \dots s_5$$$.In the second test case there are three good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_3$$$ and $$$s_2 \dots s_3$$$.
Java 8
standard input
[ "dp", "combinatorics", "binary search", "strings" ]
3eb23b7824d06b86be72c70b969be166
The first line contains one integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains the string $$$s$$$, consisting of letters A and B.
1,900
Print one integer — the number of good substrings of string $$$s$$$.
standard output
PASSED
4af33990c718f96feb853db8b7711406
train_000.jsonl
1570545300
The string $$$t_1t_2 \dots t_k$$$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.Here are some e...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Main { PrintWriter out = new PrintWriter(System.out); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer tok = new StringTokenizer(""); String next() throws IOException { if (!tok.hasMoreToke...
Java
["5\nAABBB", "3\nAAA", "7\nAAABABB"]
2 seconds
["6", "3", "15"]
NoteIn the first test case there are six good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_4$$$, $$$s_1 \dots s_5$$$, $$$s_3 \dots s_4$$$, $$$s_3 \dots s_5$$$ and $$$s_4 \dots s_5$$$.In the second test case there are three good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_3$$$ and $$$s_2 \dots s_3$$$.
Java 8
standard input
[ "dp", "combinatorics", "binary search", "strings" ]
3eb23b7824d06b86be72c70b969be166
The first line contains one integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains the string $$$s$$$, consisting of letters A and B.
1,900
Print one integer — the number of good substrings of string $$$s$$$.
standard output
PASSED
246e47c199bb424dd29b382298632209
train_000.jsonl
1570545300
The string $$$t_1t_2 \dots t_k$$$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.Here are some e...
256 megabytes
// $_Hardik_Dobariya import java.io.*; import java.math.BigDecimal; import java.math.BigInteger; import java.math.RoundingMode; import java.util.*; import java.util.Map.Entry; public class Main { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; private ...
Java
["5\nAABBB", "3\nAAA", "7\nAAABABB"]
2 seconds
["6", "3", "15"]
NoteIn the first test case there are six good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_4$$$, $$$s_1 \dots s_5$$$, $$$s_3 \dots s_4$$$, $$$s_3 \dots s_5$$$ and $$$s_4 \dots s_5$$$.In the second test case there are three good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_3$$$ and $$$s_2 \dots s_3$$$.
Java 8
standard input
[ "dp", "combinatorics", "binary search", "strings" ]
3eb23b7824d06b86be72c70b969be166
The first line contains one integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains the string $$$s$$$, consisting of letters A and B.
1,900
Print one integer — the number of good substrings of string $$$s$$$.
standard output
PASSED
81f22ae55c69c939e88871949adefb82
train_000.jsonl
1570545300
The string $$$t_1t_2 \dots t_k$$$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.Here are some e...
256 megabytes
// Working program using Reader Class import java.io.BufferedReader; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Scanner; import java.util.StringTokenizer; import java.util.TreeSet; publ...
Java
["5\nAABBB", "3\nAAA", "7\nAAABABB"]
2 seconds
["6", "3", "15"]
NoteIn the first test case there are six good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_4$$$, $$$s_1 \dots s_5$$$, $$$s_3 \dots s_4$$$, $$$s_3 \dots s_5$$$ and $$$s_4 \dots s_5$$$.In the second test case there are three good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_3$$$ and $$$s_2 \dots s_3$$$.
Java 8
standard input
[ "dp", "combinatorics", "binary search", "strings" ]
3eb23b7824d06b86be72c70b969be166
The first line contains one integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains the string $$$s$$$, consisting of letters A and B.
1,900
Print one integer — the number of good substrings of string $$$s$$$.
standard output
PASSED
883eb30e9f00ae3638e80f9411e280ca
train_000.jsonl
1570545300
The string $$$t_1t_2 \dots t_k$$$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.Here are some e...
256 megabytes
import java.util.*; public class D { public static void main(String[] args) { Scanner sc = new Scanner (System.in); long n = sc.nextLong(); String s = sc.next(); long bad = 0L; int currentIndex = 1; for (int i = 1; i < n; i++) { if (s.charAt(i) == s.charA...
Java
["5\nAABBB", "3\nAAA", "7\nAAABABB"]
2 seconds
["6", "3", "15"]
NoteIn the first test case there are six good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_4$$$, $$$s_1 \dots s_5$$$, $$$s_3 \dots s_4$$$, $$$s_3 \dots s_5$$$ and $$$s_4 \dots s_5$$$.In the second test case there are three good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_3$$$ and $$$s_2 \dots s_3$$$.
Java 8
standard input
[ "dp", "combinatorics", "binary search", "strings" ]
3eb23b7824d06b86be72c70b969be166
The first line contains one integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains the string $$$s$$$, consisting of letters A and B.
1,900
Print one integer — the number of good substrings of string $$$s$$$.
standard output
PASSED
3492c608886c4f666441b486095c5a00
train_000.jsonl
1570545300
The string $$$t_1t_2 \dots t_k$$$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.Here are some e...
256 megabytes
/** * @author Juan Sebastian Beltran Rojas * @mail jsbeltran.valhalla@gmail.com * @veredict * @url * @category * @date **/ import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; import java.util.stream.IntStream; import java.util.stream.LongStream; import static java.lang.In...
Java
["5\nAABBB", "3\nAAA", "7\nAAABABB"]
2 seconds
["6", "3", "15"]
NoteIn the first test case there are six good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_4$$$, $$$s_1 \dots s_5$$$, $$$s_3 \dots s_4$$$, $$$s_3 \dots s_5$$$ and $$$s_4 \dots s_5$$$.In the second test case there are three good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_3$$$ and $$$s_2 \dots s_3$$$.
Java 8
standard input
[ "dp", "combinatorics", "binary search", "strings" ]
3eb23b7824d06b86be72c70b969be166
The first line contains one integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains the string $$$s$$$, consisting of letters A and B.
1,900
Print one integer — the number of good substrings of string $$$s$$$.
standard output
PASSED
aa84e98142761190ad813c522329de88
train_000.jsonl
1570545300
The string $$$t_1t_2 \dots t_k$$$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.Here are some e...
256 megabytes
/*package whatever //do not write package name here */ import java.util.*; import java.io.*; public class GFG { public static void main (String[] args) { Scanner sc = new Scanner(System.in); long n = sc.nextLong(); sc.nextLine(); long res = (n*(n-1))/2; char[] S = sc.nextLine().toCharArray(); //System.out...
Java
["5\nAABBB", "3\nAAA", "7\nAAABABB"]
2 seconds
["6", "3", "15"]
NoteIn the first test case there are six good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_4$$$, $$$s_1 \dots s_5$$$, $$$s_3 \dots s_4$$$, $$$s_3 \dots s_5$$$ and $$$s_4 \dots s_5$$$.In the second test case there are three good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_3$$$ and $$$s_2 \dots s_3$$$.
Java 8
standard input
[ "dp", "combinatorics", "binary search", "strings" ]
3eb23b7824d06b86be72c70b969be166
The first line contains one integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains the string $$$s$$$, consisting of letters A and B.
1,900
Print one integer — the number of good substrings of string $$$s$$$.
standard output
PASSED
c81eec1e05fba83dff8838d976b015ab
train_000.jsonl
1570545300
The string $$$t_1t_2 \dots t_k$$$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.Here are some e...
256 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.*; public class wef { public static class FastReader { BufferedReader br; StringTokenizer st; //it reads the data about the specified poi...
Java
["5\nAABBB", "3\nAAA", "7\nAAABABB"]
2 seconds
["6", "3", "15"]
NoteIn the first test case there are six good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_4$$$, $$$s_1 \dots s_5$$$, $$$s_3 \dots s_4$$$, $$$s_3 \dots s_5$$$ and $$$s_4 \dots s_5$$$.In the second test case there are three good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_3$$$ and $$$s_2 \dots s_3$$$.
Java 8
standard input
[ "dp", "combinatorics", "binary search", "strings" ]
3eb23b7824d06b86be72c70b969be166
The first line contains one integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains the string $$$s$$$, consisting of letters A and B.
1,900
Print one integer — the number of good substrings of string $$$s$$$.
standard output
PASSED
b21f4f249c5d3de29de97ec3595282b3
train_000.jsonl
1570545300
The string $$$t_1t_2 \dots t_k$$$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.Here are some e...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.LinkedList; import java.util.Queue; import java.util.StringTokenizer; public class Test { public ...
Java
["5\nAABBB", "3\nAAA", "7\nAAABABB"]
2 seconds
["6", "3", "15"]
NoteIn the first test case there are six good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_4$$$, $$$s_1 \dots s_5$$$, $$$s_3 \dots s_4$$$, $$$s_3 \dots s_5$$$ and $$$s_4 \dots s_5$$$.In the second test case there are three good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_3$$$ and $$$s_2 \dots s_3$$$.
Java 8
standard input
[ "dp", "combinatorics", "binary search", "strings" ]
3eb23b7824d06b86be72c70b969be166
The first line contains one integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains the string $$$s$$$, consisting of letters A and B.
1,900
Print one integer — the number of good substrings of string $$$s$$$.
standard output
PASSED
1ade32d3285dbf7107433f5c052b3a7e
train_000.jsonl
1570545300
The string $$$t_1t_2 \dots t_k$$$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.Here are some e...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solu...
Java
["5\nAABBB", "3\nAAA", "7\nAAABABB"]
2 seconds
["6", "3", "15"]
NoteIn the first test case there are six good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_4$$$, $$$s_1 \dots s_5$$$, $$$s_3 \dots s_4$$$, $$$s_3 \dots s_5$$$ and $$$s_4 \dots s_5$$$.In the second test case there are three good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_3$$$ and $$$s_2 \dots s_3$$$.
Java 8
standard input
[ "dp", "combinatorics", "binary search", "strings" ]
3eb23b7824d06b86be72c70b969be166
The first line contains one integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains the string $$$s$$$, consisting of letters A and B.
1,900
Print one integer — the number of good substrings of string $$$s$$$.
standard output
PASSED
1804d2604300a8e3ba51d67285c37190
train_000.jsonl
1570545300
The string $$$t_1t_2 \dots t_k$$$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.Here are some e...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solu...
Java
["5\nAABBB", "3\nAAA", "7\nAAABABB"]
2 seconds
["6", "3", "15"]
NoteIn the first test case there are six good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_4$$$, $$$s_1 \dots s_5$$$, $$$s_3 \dots s_4$$$, $$$s_3 \dots s_5$$$ and $$$s_4 \dots s_5$$$.In the second test case there are three good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_3$$$ and $$$s_2 \dots s_3$$$.
Java 8
standard input
[ "dp", "combinatorics", "binary search", "strings" ]
3eb23b7824d06b86be72c70b969be166
The first line contains one integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains the string $$$s$$$, consisting of letters A and B.
1,900
Print one integer — the number of good substrings of string $$$s$$$.
standard output
PASSED
f463473e0509ddf1009561469e658b5e
train_000.jsonl
1570545300
The string $$$t_1t_2 \dots t_k$$$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.Here are some e...
256 megabytes
import java.util.*; import java.io.*; import java.math.BigInteger; public class Main { static final int mod = (int)1e9+7; public static void main(String[] args) throws Exception { FastReader in = new FastReader(); PrintWriter out = new PrintWriter(System.out); long n = in.nextInt(); char[] s = in.next().to...
Java
["5\nAABBB", "3\nAAA", "7\nAAABABB"]
2 seconds
["6", "3", "15"]
NoteIn the first test case there are six good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_4$$$, $$$s_1 \dots s_5$$$, $$$s_3 \dots s_4$$$, $$$s_3 \dots s_5$$$ and $$$s_4 \dots s_5$$$.In the second test case there are three good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_3$$$ and $$$s_2 \dots s_3$$$.
Java 8
standard input
[ "dp", "combinatorics", "binary search", "strings" ]
3eb23b7824d06b86be72c70b969be166
The first line contains one integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains the string $$$s$$$, consisting of letters A and B.
1,900
Print one integer — the number of good substrings of string $$$s$$$.
standard output
PASSED
a56a4888a1ff15a5bd29cfa7224d1249
train_000.jsonl
1570545300
The string $$$t_1t_2 \dots t_k$$$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.Here are some e...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader rd = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); int n = Integer.parseInt(rd.readLine()); Strin...
Java
["5\nAABBB", "3\nAAA", "7\nAAABABB"]
2 seconds
["6", "3", "15"]
NoteIn the first test case there are six good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_4$$$, $$$s_1 \dots s_5$$$, $$$s_3 \dots s_4$$$, $$$s_3 \dots s_5$$$ and $$$s_4 \dots s_5$$$.In the second test case there are three good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_3$$$ and $$$s_2 \dots s_3$$$.
Java 8
standard input
[ "dp", "combinatorics", "binary search", "strings" ]
3eb23b7824d06b86be72c70b969be166
The first line contains one integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains the string $$$s$$$, consisting of letters A and B.
1,900
Print one integer — the number of good substrings of string $$$s$$$.
standard output
PASSED
ff324a48952fddc9297b70c4e31cadc2
train_000.jsonl
1570545300
The string $$$t_1t_2 \dots t_k$$$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.Here are some e...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; public class Main2 { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); String s = br.readLine(); long res = ((long)n)*(n-1...
Java
["5\nAABBB", "3\nAAA", "7\nAAABABB"]
2 seconds
["6", "3", "15"]
NoteIn the first test case there are six good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_4$$$, $$$s_1 \dots s_5$$$, $$$s_3 \dots s_4$$$, $$$s_3 \dots s_5$$$ and $$$s_4 \dots s_5$$$.In the second test case there are three good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_3$$$ and $$$s_2 \dots s_3$$$.
Java 8
standard input
[ "dp", "combinatorics", "binary search", "strings" ]
3eb23b7824d06b86be72c70b969be166
The first line contains one integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains the string $$$s$$$, consisting of letters A and B.
1,900
Print one integer — the number of good substrings of string $$$s$$$.
standard output
PASSED
e01d5bb0d75ace07f594a644a4461aa8
train_000.jsonl
1570545300
The string $$$t_1t_2 \dots t_k$$$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.Here are some e...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); String s=sc.next(); long ans=0,ls=0; for(int i=1;i<=n;i++) { if(i==1||s.charAt(i-1)==s.charAt(i-2)) {ls++;ans+=i-1-(ls<i?1:0);} else { ans+=i-1-l...
Java
["5\nAABBB", "3\nAAA", "7\nAAABABB"]
2 seconds
["6", "3", "15"]
NoteIn the first test case there are six good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_4$$$, $$$s_1 \dots s_5$$$, $$$s_3 \dots s_4$$$, $$$s_3 \dots s_5$$$ and $$$s_4 \dots s_5$$$.In the second test case there are three good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_3$$$ and $$$s_2 \dots s_3$$$.
Java 8
standard input
[ "dp", "combinatorics", "binary search", "strings" ]
3eb23b7824d06b86be72c70b969be166
The first line contains one integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains the string $$$s$$$, consisting of letters A and B.
1,900
Print one integer — the number of good substrings of string $$$s$$$.
standard output
PASSED
e864fe681f3237cad92fe498c59bc0ae
train_000.jsonl
1570545300
The string $$$t_1t_2 \dots t_k$$$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.Here are some e...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String args[]) {new Main().run();} FastReader in = new FastReader(); PrintWriter out = new PrintWriter(System.out); void run(){ work(); out.flush(); } long mod=1000000007; long gcd(long a,long b) { return b==0?a:gcd(b,a%b);...
Java
["5\nAABBB", "3\nAAA", "7\nAAABABB"]
2 seconds
["6", "3", "15"]
NoteIn the first test case there are six good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_4$$$, $$$s_1 \dots s_5$$$, $$$s_3 \dots s_4$$$, $$$s_3 \dots s_5$$$ and $$$s_4 \dots s_5$$$.In the second test case there are three good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_3$$$ and $$$s_2 \dots s_3$$$.
Java 8
standard input
[ "dp", "combinatorics", "binary search", "strings" ]
3eb23b7824d06b86be72c70b969be166
The first line contains one integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains the string $$$s$$$, consisting of letters A and B.
1,900
Print one integer — the number of good substrings of string $$$s$$$.
standard output
PASSED
ae4554cc4fc15ef3783d4d8055954074
train_000.jsonl
1570545300
The string $$$t_1t_2 \dots t_k$$$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.Here are some e...
256 megabytes
import java.util.*; import java.util.Map.Entry; import java.math.*; import java.io.*; public class Main { public static void main(String[] args) throws FileNotFoundException { // InputReader in = new InputReader(System.in); // Scanner in = new Scanner(System.in); Scanner in = new Scanner(new BufferedReader(new...
Java
["5\nAABBB", "3\nAAA", "7\nAAABABB"]
2 seconds
["6", "3", "15"]
NoteIn the first test case there are six good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_4$$$, $$$s_1 \dots s_5$$$, $$$s_3 \dots s_4$$$, $$$s_3 \dots s_5$$$ and $$$s_4 \dots s_5$$$.In the second test case there are three good substrings: $$$s_1 \dots s_2$$$, $$$s_1 \dots s_3$$$ and $$$s_2 \dots s_3$$$.
Java 8
standard input
[ "dp", "combinatorics", "binary search", "strings" ]
3eb23b7824d06b86be72c70b969be166
The first line contains one integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains the string $$$s$$$, consisting of letters A and B.
1,900
Print one integer — the number of good substrings of string $$$s$$$.
standard output
PASSED
eed5fe8560c222db7aaff9955e9abf85
train_000.jsonl
1511449500
Vova promised himself that he would never play computer games... But recently Firestorm — a well-known game developing company — published their newest game, World of Farcraft, and it became really popular. Of course, Vova started playing it.Now he tries to solve a quest. The task is to come to a settlement named Overc...
256 megabytes
import java.io.IOException; import java.io.InputStreamReader; import java.io.BufferedReader; import java.util.*; import java.math.*; import java.io.*; import java.text.*; import java.math.BigInteger; public class Main { //Life's a bitch public static boolean[] sieve(long n) { boolean[] prime = n...
Java
["5 2\n2 5 3 4 8\n1 4\n4 5", "10 0\n1 2 3 4 5 6 7 8 9 10", "10 5\n1 6 2 7 3 8 4 9 5 10\n1 2\n3 4\n5 6\n7 8\n9 10"]
2 seconds
["10", "55", "15"]
NoteIn the first example the best decision is to bribe the first character (he will spread the rumor to fourth character, and the fourth one will spread it to fifth). Also Vova has to bribe the second and the third characters, so they know the rumor.In the second example Vova has to bribe everyone.In the third example ...
Java 11
standard input
[ "dfs and similar", "greedy", "graphs" ]
9329cb499f003aa71c6f51556bcc7b05
The first line contains two integer numbers n and m (1 ≤ n ≤ 105, 0 ≤ m ≤ 105) — the number of characters in Overcity and the number of pairs of friends. The second line contains n integer numbers ci (0 ≤ ci ≤ 109) — the amount of gold i-th character asks to start spreading the rumor. Then m lines follow, each containi...
1,300
Print one number — the minimum amount of gold Vova has to spend in order to finish the quest.
standard output
PASSED
5ce87625b7298f68b1161689779995c6
train_000.jsonl
1511449500
Vova promised himself that he would never play computer games... But recently Firestorm — a well-known game developing company — published their newest game, World of Farcraft, and it became really popular. Of course, Vova started playing it.Now he tries to solve a quest. The task is to come to a settlement named Overc...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class C { static MyScanner in = new MyScanner(); static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static StringTokeniz...
Java
["5 2\n2 5 3 4 8\n1 4\n4 5", "10 0\n1 2 3 4 5 6 7 8 9 10", "10 5\n1 6 2 7 3 8 4 9 5 10\n1 2\n3 4\n5 6\n7 8\n9 10"]
2 seconds
["10", "55", "15"]
NoteIn the first example the best decision is to bribe the first character (he will spread the rumor to fourth character, and the fourth one will spread it to fifth). Also Vova has to bribe the second and the third characters, so they know the rumor.In the second example Vova has to bribe everyone.In the third example ...
Java 11
standard input
[ "dfs and similar", "greedy", "graphs" ]
9329cb499f003aa71c6f51556bcc7b05
The first line contains two integer numbers n and m (1 ≤ n ≤ 105, 0 ≤ m ≤ 105) — the number of characters in Overcity and the number of pairs of friends. The second line contains n integer numbers ci (0 ≤ ci ≤ 109) — the amount of gold i-th character asks to start spreading the rumor. Then m lines follow, each containi...
1,300
Print one number — the minimum amount of gold Vova has to spend in order to finish the quest.
standard output
PASSED
c2aeb189b393ba2132e6eaae90326310
train_000.jsonl
1511449500
Vova promised himself that he would never play computer games... But recently Firestorm — a well-known game developing company — published their newest game, World of Farcraft, and it became really popular. Of course, Vova started playing it.Now he tries to solve a quest. The task is to come to a settlement named Overc...
256 megabytes
import java.util.*; public class solution { static int n, m, curr; static long answer; static ArrayList<Integer>[] adj; static int[] cost; static boolean[] vis; public static void main(String[] args) { answer = 0; Scanner console = new Scanner(System.in); n = console....
Java
["5 2\n2 5 3 4 8\n1 4\n4 5", "10 0\n1 2 3 4 5 6 7 8 9 10", "10 5\n1 6 2 7 3 8 4 9 5 10\n1 2\n3 4\n5 6\n7 8\n9 10"]
2 seconds
["10", "55", "15"]
NoteIn the first example the best decision is to bribe the first character (he will spread the rumor to fourth character, and the fourth one will spread it to fifth). Also Vova has to bribe the second and the third characters, so they know the rumor.In the second example Vova has to bribe everyone.In the third example ...
Java 11
standard input
[ "dfs and similar", "greedy", "graphs" ]
9329cb499f003aa71c6f51556bcc7b05
The first line contains two integer numbers n and m (1 ≤ n ≤ 105, 0 ≤ m ≤ 105) — the number of characters in Overcity and the number of pairs of friends. The second line contains n integer numbers ci (0 ≤ ci ≤ 109) — the amount of gold i-th character asks to start spreading the rumor. Then m lines follow, each containi...
1,300
Print one number — the minimum amount of gold Vova has to spend in order to finish the quest.
standard output
PASSED
905aeb3ec12dbb279bc2a88ae47f0315
train_000.jsonl
1511449500
Vova promised himself that he would never play computer games... But recently Firestorm — a well-known game developing company — published their newest game, World of Farcraft, and it became really popular. Of course, Vova started playing it.Now he tries to solve a quest. The task is to come to a settlement named Overc...
256 megabytes
// package endsem; import java.util.*; import java.lang.Math; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class Cf_two { static class graph_dfs{ int num_vert; List<Integer> adjList[]; int[] vis; graph_dfs(int num_vert){ th...
Java
["5 2\n2 5 3 4 8\n1 4\n4 5", "10 0\n1 2 3 4 5 6 7 8 9 10", "10 5\n1 6 2 7 3 8 4 9 5 10\n1 2\n3 4\n5 6\n7 8\n9 10"]
2 seconds
["10", "55", "15"]
NoteIn the first example the best decision is to bribe the first character (he will spread the rumor to fourth character, and the fourth one will spread it to fifth). Also Vova has to bribe the second and the third characters, so they know the rumor.In the second example Vova has to bribe everyone.In the third example ...
Java 11
standard input
[ "dfs and similar", "greedy", "graphs" ]
9329cb499f003aa71c6f51556bcc7b05
The first line contains two integer numbers n and m (1 ≤ n ≤ 105, 0 ≤ m ≤ 105) — the number of characters in Overcity and the number of pairs of friends. The second line contains n integer numbers ci (0 ≤ ci ≤ 109) — the amount of gold i-th character asks to start spreading the rumor. Then m lines follow, each containi...
1,300
Print one number — the minimum amount of gold Vova has to spend in order to finish the quest.
standard output
PASSED
abfb4ecb0cd02dac973fef0cf3f38bb7
train_000.jsonl
1511449500
Vova promised himself that he would never play computer games... But recently Firestorm — a well-known game developing company — published their newest game, World of Farcraft, and it became really popular. Of course, Vova started playing it.Now he tries to solve a quest. The task is to come to a settlement named Overc...
256 megabytes
import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); int N=sc.nextInt(); int m=sc.nextInt(); int[] arr=new int[N+1]; for(int i=1;i<=N;i++){ arr[i]=sc.nextInt(); } Map<Integer,List<Integer...
Java
["5 2\n2 5 3 4 8\n1 4\n4 5", "10 0\n1 2 3 4 5 6 7 8 9 10", "10 5\n1 6 2 7 3 8 4 9 5 10\n1 2\n3 4\n5 6\n7 8\n9 10"]
2 seconds
["10", "55", "15"]
NoteIn the first example the best decision is to bribe the first character (he will spread the rumor to fourth character, and the fourth one will spread it to fifth). Also Vova has to bribe the second and the third characters, so they know the rumor.In the second example Vova has to bribe everyone.In the third example ...
Java 11
standard input
[ "dfs and similar", "greedy", "graphs" ]
9329cb499f003aa71c6f51556bcc7b05
The first line contains two integer numbers n and m (1 ≤ n ≤ 105, 0 ≤ m ≤ 105) — the number of characters in Overcity and the number of pairs of friends. The second line contains n integer numbers ci (0 ≤ ci ≤ 109) — the amount of gold i-th character asks to start spreading the rumor. Then m lines follow, each containi...
1,300
Print one number — the minimum amount of gold Vova has to spend in order to finish the quest.
standard output
PASSED
e502ce3c7c4ff433ba7d96d80e8d783a
train_000.jsonl
1511449500
Vova promised himself that he would never play computer games... But recently Firestorm — a well-known game developing company — published their newest game, World of Farcraft, and it became really popular. Of course, Vova started playing it.Now he tries to solve a quest. The task is to come to a settlement named Overc...
256 megabytes
// package com.company.codeforces; import java.io.*; import java.util.*; public class Solution { static int mod = (int) 1e9 + 7; static int val[]; static boolean vis[]; static ArrayList<Integer> graph[]; static long ans=0; public static void main(String[] args) { Scanner input = n...
Java
["5 2\n2 5 3 4 8\n1 4\n4 5", "10 0\n1 2 3 4 5 6 7 8 9 10", "10 5\n1 6 2 7 3 8 4 9 5 10\n1 2\n3 4\n5 6\n7 8\n9 10"]
2 seconds
["10", "55", "15"]
NoteIn the first example the best decision is to bribe the first character (he will spread the rumor to fourth character, and the fourth one will spread it to fifth). Also Vova has to bribe the second and the third characters, so they know the rumor.In the second example Vova has to bribe everyone.In the third example ...
Java 11
standard input
[ "dfs and similar", "greedy", "graphs" ]
9329cb499f003aa71c6f51556bcc7b05
The first line contains two integer numbers n and m (1 ≤ n ≤ 105, 0 ≤ m ≤ 105) — the number of characters in Overcity and the number of pairs of friends. The second line contains n integer numbers ci (0 ≤ ci ≤ 109) — the amount of gold i-th character asks to start spreading the rumor. Then m lines follow, each containi...
1,300
Print one number — the minimum amount of gold Vova has to spend in order to finish the quest.
standard output
PASSED
cd4e3b5a80f2f36ef911150033178899
train_000.jsonl
1529591700
You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. Polycarp wants to remove exactly $$$k$$$ characters ($$$k \le n$$$) from the string $$$s$$$. Polycarp uses the following algorithm $$$k$$$ times: if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, oth...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class Main { private static Scanner sc; private static Printer pr; private static long aLong=(long)(Math.pow(10,9)+7); private static void solve() throws IOException { int n = sc.nextInt(); int k=sc.nextInt(); ...
Java
["15 3\ncccaabababaccbc", "15 9\ncccaabababaccbc", "1 1\nu"]
2 seconds
["cccbbabaccbc", "cccccc", ""]
null
Java 8
standard input
[ "implementation" ]
9f095a5f5b39d8c2f99c4162f2d7c5ff
The first line of input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 4 \cdot 10^5$$$) — the length of the string and the number of letters Polycarp will remove. The second line contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.
1,200
Print the string that will be obtained from $$$s$$$ after Polycarp removes exactly $$$k$$$ letters using the above algorithm $$$k$$$ times. If the resulting string is empty, print nothing. It is allowed to print nothing or an empty line (line break).
standard output
PASSED
71699000f453874e339bf70e4e20eb3a
train_000.jsonl
1529591700
You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. Polycarp wants to remove exactly $$$k$$$ characters ($$$k \le n$$$) from the string $$$s$$$. Polycarp uses the following algorithm $$$k$$$ times: if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, oth...
256 megabytes
import java.io.InputStream; public class Sport_Coding { static IO io=new IO(System.in); static int n, k; static String s; static boolean[] ar; public static void main(String[] args)throws Exception { n = io.nextInt(); k = io.nextInt(); s = io.next(); ar = new boolean...
Java
["15 3\ncccaabababaccbc", "15 9\ncccaabababaccbc", "1 1\nu"]
2 seconds
["cccbbabaccbc", "cccccc", ""]
null
Java 8
standard input
[ "implementation" ]
9f095a5f5b39d8c2f99c4162f2d7c5ff
The first line of input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 4 \cdot 10^5$$$) — the length of the string and the number of letters Polycarp will remove. The second line contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.
1,200
Print the string that will be obtained from $$$s$$$ after Polycarp removes exactly $$$k$$$ letters using the above algorithm $$$k$$$ times. If the resulting string is empty, print nothing. It is allowed to print nothing or an empty line (line break).
standard output
PASSED
bca621e247346e1cecb5a2478ab42bcc
train_000.jsonl
1529591700
You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. Polycarp wants to remove exactly $$$k$$$ characters ($$$k \le n$$$) from the string $$$s$$$. Polycarp uses the following algorithm $$$k$$$ times: if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, oth...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n=sc.nextInt(); int k=sc.nextInt(); String s=sc.next(); StringBuffer sb = new StringBuffer(); int[] freq=new int[26]; for(int i=0;i<n;i++) { freq[s.charAt(i)-'a']++; } int ...
Java
["15 3\ncccaabababaccbc", "15 9\ncccaabababaccbc", "1 1\nu"]
2 seconds
["cccbbabaccbc", "cccccc", ""]
null
Java 8
standard input
[ "implementation" ]
9f095a5f5b39d8c2f99c4162f2d7c5ff
The first line of input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 4 \cdot 10^5$$$) — the length of the string and the number of letters Polycarp will remove. The second line contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.
1,200
Print the string that will be obtained from $$$s$$$ after Polycarp removes exactly $$$k$$$ letters using the above algorithm $$$k$$$ times. If the resulting string is empty, print nothing. It is allowed to print nothing or an empty line (line break).
standard output
PASSED
773d3ea1096c424bc239006b16a7524e
train_000.jsonl
1529591700
You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. Polycarp wants to remove exactly $$$k$$$ characters ($$$k \le n$$$) from the string $$$s$$$. Polycarp uses the following algorithm $$$k$$$ times: if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, oth...
256 megabytes
//package math_codet; import java.io.*; import java.util.*; public class lets_do { public static void main(String[] args) { InputReader in=new InputReader(System.in); StringBuffer str=new StringBuffer(); int n=in.nextInt(); int k=in.nextInt(); String s=in.next(); ...
Java
["15 3\ncccaabababaccbc", "15 9\ncccaabababaccbc", "1 1\nu"]
2 seconds
["cccbbabaccbc", "cccccc", ""]
null
Java 8
standard input
[ "implementation" ]
9f095a5f5b39d8c2f99c4162f2d7c5ff
The first line of input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 4 \cdot 10^5$$$) — the length of the string and the number of letters Polycarp will remove. The second line contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.
1,200
Print the string that will be obtained from $$$s$$$ after Polycarp removes exactly $$$k$$$ letters using the above algorithm $$$k$$$ times. If the resulting string is empty, print nothing. It is allowed to print nothing or an empty line (line break).
standard output
PASSED
d2e926f279343e8999515dcf13edbd62
train_000.jsonl
1529591700
You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. Polycarp wants to remove exactly $$$k$$$ characters ($$$k \le n$$$) from the string $$$s$$$. Polycarp uses the following algorithm $$$k$$$ times: if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, oth...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; /** * * @author thachlp */ public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application l...
Java
["15 3\ncccaabababaccbc", "15 9\ncccaabababaccbc", "1 1\nu"]
2 seconds
["cccbbabaccbc", "cccccc", ""]
null
Java 8
standard input
[ "implementation" ]
9f095a5f5b39d8c2f99c4162f2d7c5ff
The first line of input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 4 \cdot 10^5$$$) — the length of the string and the number of letters Polycarp will remove. The second line contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.
1,200
Print the string that will be obtained from $$$s$$$ after Polycarp removes exactly $$$k$$$ letters using the above algorithm $$$k$$$ times. If the resulting string is empty, print nothing. It is allowed to print nothing or an empty line (line break).
standard output
PASSED
1518947832ccfce52f8bdd9ddb239d85
train_000.jsonl
1529591700
You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. Polycarp wants to remove exactly $$$k$$$ characters ($$$k \le n$$$) from the string $$$s$$$. Polycarp uses the following algorithm $$$k$$$ times: if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, oth...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.*; public class alphabeticRemovals { static class FastReader { StringTokenizer st; BufferedReader br; public FastReader(InputStream s) { br = n...
Java
["15 3\ncccaabababaccbc", "15 9\ncccaabababaccbc", "1 1\nu"]
2 seconds
["cccbbabaccbc", "cccccc", ""]
null
Java 8
standard input
[ "implementation" ]
9f095a5f5b39d8c2f99c4162f2d7c5ff
The first line of input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 4 \cdot 10^5$$$) — the length of the string and the number of letters Polycarp will remove. The second line contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.
1,200
Print the string that will be obtained from $$$s$$$ after Polycarp removes exactly $$$k$$$ letters using the above algorithm $$$k$$$ times. If the resulting string is empty, print nothing. It is allowed to print nothing or an empty line (line break).
standard output
PASSED
966e676418e6cfa101787d681da83d75
train_000.jsonl
1529591700
You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. Polycarp wants to remove exactly $$$k$$$ characters ($$$k \le n$$$) from the string $$$s$$$. Polycarp uses the following algorithm $$$k$$$ times: if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, oth...
256 megabytes
//package com.prituladima.codeforce.contests.contest999; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; /** * Created by prituladima on 6/23/18. */ public class C { private static class Staff { public Staff(c...
Java
["15 3\ncccaabababaccbc", "15 9\ncccaabababaccbc", "1 1\nu"]
2 seconds
["cccbbabaccbc", "cccccc", ""]
null
Java 8
standard input
[ "implementation" ]
9f095a5f5b39d8c2f99c4162f2d7c5ff
The first line of input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 4 \cdot 10^5$$$) — the length of the string and the number of letters Polycarp will remove. The second line contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.
1,200
Print the string that will be obtained from $$$s$$$ after Polycarp removes exactly $$$k$$$ letters using the above algorithm $$$k$$$ times. If the resulting string is empty, print nothing. It is allowed to print nothing or an empty line (line break).
standard output
PASSED
3a7bb8f4e97cebae76bc4dddaaab7005
train_000.jsonl
1529591700
You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. Polycarp wants to remove exactly $$$k$$$ characters ($$$k \le n$$$) from the string $$$s$$$. Polycarp uses the following algorithm $$$k$$$ times: if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, oth...
256 megabytes
import java.util.*; public class asd { public static void main(String args[]) { Scanner s=new Scanner(System.in); int n=s.nextInt(); int k=s.nextInt(); String str=s.next(); int arr[]=new int[26]; for(int i=0;i<str.length();i++) { char ch=str.ch...
Java
["15 3\ncccaabababaccbc", "15 9\ncccaabababaccbc", "1 1\nu"]
2 seconds
["cccbbabaccbc", "cccccc", ""]
null
Java 8
standard input
[ "implementation" ]
9f095a5f5b39d8c2f99c4162f2d7c5ff
The first line of input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 4 \cdot 10^5$$$) — the length of the string and the number of letters Polycarp will remove. The second line contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.
1,200
Print the string that will be obtained from $$$s$$$ after Polycarp removes exactly $$$k$$$ letters using the above algorithm $$$k$$$ times. If the resulting string is empty, print nothing. It is allowed to print nothing or an empty line (line break).
standard output
PASSED
f3b921f1387b659c3cb2dffab37e8bd5
train_000.jsonl
1529591700
You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. Polycarp wants to remove exactly $$$k$$$ characters ($$$k \le n$$$) from the string $$$s$$$. Polycarp uses the following algorithm $$$k$$$ times: if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, oth...
256 megabytes
import java.util.Scanner; public class Alp { public static void main(String [] args) { Scanner in = new Scanner(System.in); int [] alph = new int[26]; int [] toDel = new int[26]; in.nextInt(); int z = in.nextInt(); char [] word = in.next().toCharArray(); for(char w:word) { alph[w-'a']++; }...
Java
["15 3\ncccaabababaccbc", "15 9\ncccaabababaccbc", "1 1\nu"]
2 seconds
["cccbbabaccbc", "cccccc", ""]
null
Java 8
standard input
[ "implementation" ]
9f095a5f5b39d8c2f99c4162f2d7c5ff
The first line of input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 4 \cdot 10^5$$$) — the length of the string and the number of letters Polycarp will remove. The second line contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.
1,200
Print the string that will be obtained from $$$s$$$ after Polycarp removes exactly $$$k$$$ letters using the above algorithm $$$k$$$ times. If the resulting string is empty, print nothing. It is allowed to print nothing or an empty line (line break).
standard output
PASSED
5e83249d5ca6a576a6e3d4e41b3d5c30
train_000.jsonl
1529591700
You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. Polycarp wants to remove exactly $$$k$$$ characters ($$$k \le n$$$) from the string $$$s$$$. Polycarp uses the following algorithm $$$k$$$ times: if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, oth...
256 megabytes
import java.util.Scanner; public class Ex03_2 { private static int[] array = new int[26]; // count private static int visit[]; public static void main(String args[]) { Scanner sc = new Scanner(System.in); int s = sc.nextInt(); int k = sc.nextInt(); String temp = sc.next()...
Java
["15 3\ncccaabababaccbc", "15 9\ncccaabababaccbc", "1 1\nu"]
2 seconds
["cccbbabaccbc", "cccccc", ""]
null
Java 8
standard input
[ "implementation" ]
9f095a5f5b39d8c2f99c4162f2d7c5ff
The first line of input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 4 \cdot 10^5$$$) — the length of the string and the number of letters Polycarp will remove. The second line contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.
1,200
Print the string that will be obtained from $$$s$$$ after Polycarp removes exactly $$$k$$$ letters using the above algorithm $$$k$$$ times. If the resulting string is empty, print nothing. It is allowed to print nothing or an empty line (line break).
standard output
PASSED
c908f8a052dab3e084ca121a7044c96a
train_000.jsonl
1529591700
You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. Polycarp wants to remove exactly $$$k$$$ characters ($$$k \le n$$$) from the string $$$s$$$. Polycarp uses the following algorithm $$$k$$$ times: if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, oth...
256 megabytes
import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.*; public class Main { private static Reader r; private static boolean flag[]; public static void main(String[] args) throws Exception { r = new Reader(); r.readLine(); int n...
Java
["15 3\ncccaabababaccbc", "15 9\ncccaabababaccbc", "1 1\nu"]
2 seconds
["cccbbabaccbc", "cccccc", ""]
null
Java 8
standard input
[ "implementation" ]
9f095a5f5b39d8c2f99c4162f2d7c5ff
The first line of input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 4 \cdot 10^5$$$) — the length of the string and the number of letters Polycarp will remove. The second line contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.
1,200
Print the string that will be obtained from $$$s$$$ after Polycarp removes exactly $$$k$$$ letters using the above algorithm $$$k$$$ times. If the resulting string is empty, print nothing. It is allowed to print nothing or an empty line (line break).
standard output
PASSED
7326f1659dcd2cfd084f98fde7cc2ca3
train_000.jsonl
1529591700
You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. Polycarp wants to remove exactly $$$k$$$ characters ($$$k \le n$$$) from the string $$$s$$$. Polycarp uses the following algorithm $$$k$$$ times: if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, oth...
256 megabytes
import java.util.Scanner; public class C999 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(), k = in.nextInt(), i, upTo = -1, toRemove = 0; int[] sortedS = new int[26]; String s = in.next(), result = ""; for(i = 0; i < n; i++) sortedS[s.charAt(i)...
Java
["15 3\ncccaabababaccbc", "15 9\ncccaabababaccbc", "1 1\nu"]
2 seconds
["cccbbabaccbc", "cccccc", ""]
null
Java 8
standard input
[ "implementation" ]
9f095a5f5b39d8c2f99c4162f2d7c5ff
The first line of input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 4 \cdot 10^5$$$) — the length of the string and the number of letters Polycarp will remove. The second line contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.
1,200
Print the string that will be obtained from $$$s$$$ after Polycarp removes exactly $$$k$$$ letters using the above algorithm $$$k$$$ times. If the resulting string is empty, print nothing. It is allowed to print nothing or an empty line (line break).
standard output
PASSED
b5165c621be1869ec1ec739c650cd21e
train_000.jsonl
1529591700
You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. Polycarp wants to remove exactly $$$k$$$ characters ($$$k \le n$$$) from the string $$$s$$$. Polycarp uses the following algorithm $$$k$$$ times: if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, oth...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class bhaa { InputStream is; PrintWriter o; /////////////////// CODED++ BY++ ++ ++ ++ BHAVYA++ ARORA++ ++ ++ ++ FROM++ JAYPEE++ INSTITUTE++ OF++ INFORMATION++ TECHNOLOGY++ //////////////// ////...
Java
["15 3\ncccaabababaccbc", "15 9\ncccaabababaccbc", "1 1\nu"]
2 seconds
["cccbbabaccbc", "cccccc", ""]
null
Java 8
standard input
[ "implementation" ]
9f095a5f5b39d8c2f99c4162f2d7c5ff
The first line of input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 4 \cdot 10^5$$$) — the length of the string and the number of letters Polycarp will remove. The second line contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.
1,200
Print the string that will be obtained from $$$s$$$ after Polycarp removes exactly $$$k$$$ letters using the above algorithm $$$k$$$ times. If the resulting string is empty, print nothing. It is allowed to print nothing or an empty line (line break).
standard output
PASSED
730584f04b985621e5e1031542e3c2b5
train_000.jsonl
1529591700
You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. Polycarp wants to remove exactly $$$k$$$ characters ($$$k \le n$$$) from the string $$$s$$$. Polycarp uses the following algorithm $$$k$$$ times: if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, oth...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); StringBuilder sb = new StringBuilder(); int tab[] = new int[26]; int n = sc.nextInt(); int k = sc.nextInt(); sc.nextLine(); String s = sc.nextL...
Java
["15 3\ncccaabababaccbc", "15 9\ncccaabababaccbc", "1 1\nu"]
2 seconds
["cccbbabaccbc", "cccccc", ""]
null
Java 8
standard input
[ "implementation" ]
9f095a5f5b39d8c2f99c4162f2d7c5ff
The first line of input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 4 \cdot 10^5$$$) — the length of the string and the number of letters Polycarp will remove. The second line contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.
1,200
Print the string that will be obtained from $$$s$$$ after Polycarp removes exactly $$$k$$$ letters using the above algorithm $$$k$$$ times. If the resulting string is empty, print nothing. It is allowed to print nothing or an empty line (line break).
standard output
PASSED
043933debdfdfd045506a900d85f6fc1
train_000.jsonl
1529591700
You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. Polycarp wants to remove exactly $$$k$$$ characters ($$$k \le n$$$) from the string $$$s$$$. Polycarp uses the following algorithm $$$k$$$ times: if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, oth...
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.util.*; public class Main { String fileName = ""; ////////////////////// SOLUTION SOLUTION SOLUTION ////////////////////////////// int INF = Integer.MAX_VALUE; void solve() throws IOException { int n = readInt(); ...
Java
["15 3\ncccaabababaccbc", "15 9\ncccaabababaccbc", "1 1\nu"]
2 seconds
["cccbbabaccbc", "cccccc", ""]
null
Java 8
standard input
[ "implementation" ]
9f095a5f5b39d8c2f99c4162f2d7c5ff
The first line of input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 4 \cdot 10^5$$$) — the length of the string and the number of letters Polycarp will remove. The second line contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.
1,200
Print the string that will be obtained from $$$s$$$ after Polycarp removes exactly $$$k$$$ letters using the above algorithm $$$k$$$ times. If the resulting string is empty, print nothing. It is allowed to print nothing or an empty line (line break).
standard output
PASSED
2b5143680010d7cc2bc3d887af803ad5
train_000.jsonl
1529591700
You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. Polycarp wants to remove exactly $$$k$$$ characters ($$$k \le n$$$) from the string $$$s$$$. Polycarp uses the following algorithm $$$k$$$ times: if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, oth...
256 megabytes
import java.util.*; import java.io.*; public class Reverse { static BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); static BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(System.out)); static StringTokenizer st=null; static String next() { while(st==null |...
Java
["15 3\ncccaabababaccbc", "15 9\ncccaabababaccbc", "1 1\nu"]
2 seconds
["cccbbabaccbc", "cccccc", ""]
null
Java 8
standard input
[ "implementation" ]
9f095a5f5b39d8c2f99c4162f2d7c5ff
The first line of input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 4 \cdot 10^5$$$) — the length of the string and the number of letters Polycarp will remove. The second line contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.
1,200
Print the string that will be obtained from $$$s$$$ after Polycarp removes exactly $$$k$$$ letters using the above algorithm $$$k$$$ times. If the resulting string is empty, print nothing. It is allowed to print nothing or an empty line (line break).
standard output
PASSED
da20a5048cec41db2b624f2f8f829437
train_000.jsonl
1529591700
You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. Polycarp wants to remove exactly $$$k$$$ characters ($$$k \le n$$$) from the string $$$s$$$. Polycarp uses the following algorithm $$$k$$$ times: if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, oth...
256 megabytes
import java.util.*; import java.util.regex.Pattern; public class Q2 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int i,n,k,c=0,temp=0; n=sc.nextInt(); k=sc.nextInt(); String s=sc.next(); int aa[]=new int[26]; int bb[]=new int[...
Java
["15 3\ncccaabababaccbc", "15 9\ncccaabababaccbc", "1 1\nu"]
2 seconds
["cccbbabaccbc", "cccccc", ""]
null
Java 8
standard input
[ "implementation" ]
9f095a5f5b39d8c2f99c4162f2d7c5ff
The first line of input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 4 \cdot 10^5$$$) — the length of the string and the number of letters Polycarp will remove. The second line contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.
1,200
Print the string that will be obtained from $$$s$$$ after Polycarp removes exactly $$$k$$$ letters using the above algorithm $$$k$$$ times. If the resulting string is empty, print nothing. It is allowed to print nothing or an empty line (line break).
standard output
PASSED
6d61e14852cf5a69eeaec5d243eab200
train_000.jsonl
1529591700
You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. Polycarp wants to remove exactly $$$k$$$ characters ($$$k \le n$$$) from the string $$$s$$$. Polycarp uses the following algorithm $$$k$$$ times: if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, oth...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.nio.CharBuffer; import java.util.Map; import java.util.StringTokenizer; import java.util.TreeMap; import java.util.TreeSet; publi...
Java
["15 3\ncccaabababaccbc", "15 9\ncccaabababaccbc", "1 1\nu"]
2 seconds
["cccbbabaccbc", "cccccc", ""]
null
Java 8
standard input
[ "implementation" ]
9f095a5f5b39d8c2f99c4162f2d7c5ff
The first line of input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 4 \cdot 10^5$$$) — the length of the string and the number of letters Polycarp will remove. The second line contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.
1,200
Print the string that will be obtained from $$$s$$$ after Polycarp removes exactly $$$k$$$ letters using the above algorithm $$$k$$$ times. If the resulting string is empty, print nothing. It is allowed to print nothing or an empty line (line break).
standard output
PASSED
0adfcbc668d4f390df2467cda8c8abc2
train_000.jsonl
1529591700
You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. Polycarp wants to remove exactly $$$k$$$ characters ($$$k \le n$$$) from the string $$$s$$$. Polycarp uses the following algorithm $$$k$$$ times: if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, oth...
256 megabytes
//package pr_2; import java.util.*; import java.io.*; public class rep { public static void main(String[] args) throws IOException { Scanner scan = new Scanner(System.in); int N = scan.nextInt(), k = scan.nextInt(), f = k; char[] arr = scan.next().toCharArray(); int [] count = new int[26]; for(int i=0; ...
Java
["15 3\ncccaabababaccbc", "15 9\ncccaabababaccbc", "1 1\nu"]
2 seconds
["cccbbabaccbc", "cccccc", ""]
null
Java 8
standard input
[ "implementation" ]
9f095a5f5b39d8c2f99c4162f2d7c5ff
The first line of input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 4 \cdot 10^5$$$) — the length of the string and the number of letters Polycarp will remove. The second line contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.
1,200
Print the string that will be obtained from $$$s$$$ after Polycarp removes exactly $$$k$$$ letters using the above algorithm $$$k$$$ times. If the resulting string is empty, print nothing. It is allowed to print nothing or an empty line (line break).
standard output
PASSED
7528ff5e751a8da737e05ba728dfa4d6
train_000.jsonl
1529591700
You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. Polycarp wants to remove exactly $$$k$$$ characters ($$$k \le n$$$) from the string $$$s$$$. Polycarp uses the following algorithm $$$k$$$ times: if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, oth...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class Div3 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); Prin...
Java
["15 3\ncccaabababaccbc", "15 9\ncccaabababaccbc", "1 1\nu"]
2 seconds
["cccbbabaccbc", "cccccc", ""]
null
Java 8
standard input
[ "implementation" ]
9f095a5f5b39d8c2f99c4162f2d7c5ff
The first line of input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 4 \cdot 10^5$$$) — the length of the string and the number of letters Polycarp will remove. The second line contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.
1,200
Print the string that will be obtained from $$$s$$$ after Polycarp removes exactly $$$k$$$ letters using the above algorithm $$$k$$$ times. If the resulting string is empty, print nothing. It is allowed to print nothing or an empty line (line break).
standard output
PASSED
fe8088e88eeff0362520f25d61f24aa9
train_000.jsonl
1529591700
You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. Polycarp wants to remove exactly $$$k$$$ characters ($$$k \le n$$$) from the string $$$s$$$. Polycarp uses the following algorithm $$$k$$$ times: if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, oth...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); int count=0; String s = sc.next(); char c[] = s.toCharArray(); for(char i='a';i<='z';i++){ ...
Java
["15 3\ncccaabababaccbc", "15 9\ncccaabababaccbc", "1 1\nu"]
2 seconds
["cccbbabaccbc", "cccccc", ""]
null
Java 8
standard input
[ "implementation" ]
9f095a5f5b39d8c2f99c4162f2d7c5ff
The first line of input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 4 \cdot 10^5$$$) — the length of the string and the number of letters Polycarp will remove. The second line contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.
1,200
Print the string that will be obtained from $$$s$$$ after Polycarp removes exactly $$$k$$$ letters using the above algorithm $$$k$$$ times. If the resulting string is empty, print nothing. It is allowed to print nothing or an empty line (line break).
standard output
PASSED
e738f81175e7fd2b5231a619afede6e7
train_000.jsonl
1384102800
Levko loves strings of length n, consisting of lowercase English letters, very much. He has one such string s. For each string t of length n, Levko defines its beauty relative to s as the number of pairs of indexes i, j (1 ≤ i ≤ j ≤ n), such that substring t[i..j] is lexicographically larger than substring s[i..j].The ...
256 megabytes
import java.text.DecimalFormat; import java.util.*; import java.io.*; public class Main { private static final int mod = 1000000007; private static char [] S; private static int [] less; private static int n,K; private static Integer [] [] [] dp; private static int add(int a,int b) { ...
Java
["2 2\nyz", "2 3\nyx", "4 7\nabcd"]
1 second
["26", "2", "21962"]
null
Java 8
standard input
[ "dp", "combinatorics" ]
6acc6ab9e60eceebb85f41dc0aea9cf4
The first line contains two integers n and k (1 ≤ n ≤ 2000, 0 ≤ k ≤ 2000). The second line contains a non-empty string s of length n. String s consists only of lowercase English letters.
2,500
Print a single number — the answer to the problem modulo 1000000007 (109 + 7).
standard output
PASSED
328e580333e785c936f2af574be80638
train_000.jsonl
1384156800
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" co...
256 megabytes
import java.util.*; public class CF363D2C { public static void main(String args[])throws Exception { Scanner sc=new Scanner(System.in); char ch[]=sc.next().toCharArray(); int len=ch.length; int ar[]=new int[len]; int k=0; int j=0;//it points to the location from w...
Java
["helloo", "woooooow"]
1 second
["hello", "woow"]
NoteThe second valid answer to the test from the statement is "heloo".
Java 8
standard input
[ "implementation", "greedy" ]
31d803d886c47fe681bdcfbe6c74f090
The single line of the input contains word s, its length is from 1 to 200000 characters. The given word s consists of lowercase English letters.
1,400
Print such word t that it doesn't contain any typos described in the problem statement and is obtained from s by deleting the least number of letters. If there are multiple solutions, print any of them.
standard output
PASSED
b6386d094522c7a940a23c965e3d4b15
train_000.jsonl
1384156800
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" co...
256 megabytes
import java.util.Scanner; /** * * @author elshamey */ public class Examples { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here Scanner scan = new Scanner(System.in); //aabbaabbaabbaabbaabbaabbccccc...
Java
["helloo", "woooooow"]
1 second
["hello", "woow"]
NoteThe second valid answer to the test from the statement is "heloo".
Java 8
standard input
[ "implementation", "greedy" ]
31d803d886c47fe681bdcfbe6c74f090
The single line of the input contains word s, its length is from 1 to 200000 characters. The given word s consists of lowercase English letters.
1,400
Print such word t that it doesn't contain any typos described in the problem statement and is obtained from s by deleting the least number of letters. If there are multiple solutions, print any of them.
standard output
PASSED
f3ab875c70e095e1e63d009efcd85f4a
train_000.jsonl
1384156800
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" co...
256 megabytes
import java.util.*; public class practice { public static void main(String[] args) { Scanner scn=new Scanner(System.in); char a ,b='@',c='/',d='>'; String s=scn.next(); for(int i=0;i<s.length();i++){ a=s.charAt(i); if(!((a==b&&b==c)||(a==b&&c==d))){ System.out.print(a); d=c; c=b; ...
Java
["helloo", "woooooow"]
1 second
["hello", "woow"]
NoteThe second valid answer to the test from the statement is "heloo".
Java 8
standard input
[ "implementation", "greedy" ]
31d803d886c47fe681bdcfbe6c74f090
The single line of the input contains word s, its length is from 1 to 200000 characters. The given word s consists of lowercase English letters.
1,400
Print such word t that it doesn't contain any typos described in the problem statement and is obtained from s by deleting the least number of letters. If there are multiple solutions, print any of them.
standard output
PASSED
222d516aa6211992e6c4ce0e19a6598b
train_000.jsonl
1384156800
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" co...
256 megabytes
import java.util.Scanner; import java.io.*; import java.util.*; import java.math.*; import java.lang.*; import static java.lang.Math.*; public class TestClass //implements Runnable { int x,y; public TestClass(int x,int y) { this.x=x; this.y=y; } public static void main(String args[]) throws Exception {/* ...
Java
["helloo", "woooooow"]
1 second
["hello", "woow"]
NoteThe second valid answer to the test from the statement is "heloo".
Java 8
standard input
[ "implementation", "greedy" ]
31d803d886c47fe681bdcfbe6c74f090
The single line of the input contains word s, its length is from 1 to 200000 characters. The given word s consists of lowercase English letters.
1,400
Print such word t that it doesn't contain any typos described in the problem statement and is obtained from s by deleting the least number of letters. If there are multiple solutions, print any of them.
standard output
PASSED
29bbf1806a01c12daf99841621dd89b1
train_000.jsonl
1384156800
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" co...
256 megabytes
import java.util.*; import java.lang.*; import java.math.*; public class main { public static void woof(String str) { char [] star = str.toCharArray(); StringBuilder f = new StringBuilder(); int en; for (int i = 0; i < str.length(); i++) { en= f.length(); ...
Java
["helloo", "woooooow"]
1 second
["hello", "woow"]
NoteThe second valid answer to the test from the statement is "heloo".
Java 8
standard input
[ "implementation", "greedy" ]
31d803d886c47fe681bdcfbe6c74f090
The single line of the input contains word s, its length is from 1 to 200000 characters. The given word s consists of lowercase English letters.
1,400
Print such word t that it doesn't contain any typos described in the problem statement and is obtained from s by deleting the least number of letters. If there are multiple solutions, print any of them.
standard output
PASSED
ad24bf7621060c8ef40fb5284d9e751b
train_000.jsonl
1384156800
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" co...
256 megabytes
import java.io.*; import java.util.*; public class fixing_typos { public boolean lastThreeSame(String ss, int i, String ans) { if ((ss.charAt(i)==(ans.charAt(i-1)))&&(ss.charAt(i-2)==( ss.charAt(i-1)))) return(true); else return(false); } public boolean twinSame(String ss, int i) { if ((ss.charAt(...
Java
["helloo", "woooooow"]
1 second
["hello", "woow"]
NoteThe second valid answer to the test from the statement is "heloo".
Java 8
standard input
[ "implementation", "greedy" ]
31d803d886c47fe681bdcfbe6c74f090
The single line of the input contains word s, its length is from 1 to 200000 characters. The given word s consists of lowercase English letters.
1,400
Print such word t that it doesn't contain any typos described in the problem statement and is obtained from s by deleting the least number of letters. If there are multiple solutions, print any of them.
standard output
PASSED
9275b6062e623e5be2f2c42170b7a925
train_000.jsonl
1384156800
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" co...
256 megabytes
import java.util.ArrayList; import java.util.Scanner; public class FixingTypos { static int getnum(char ch) { String str = "abcdefghijklmnopqrstuvwxyz"; return str.indexOf(ch); } public static void main(String[] args) { Scanner s = new Scanner(System.in); String str = s.next(); char ch[] = str.toCharArr...
Java
["helloo", "woooooow"]
1 second
["hello", "woow"]
NoteThe second valid answer to the test from the statement is "heloo".
Java 8
standard input
[ "implementation", "greedy" ]
31d803d886c47fe681bdcfbe6c74f090
The single line of the input contains word s, its length is from 1 to 200000 characters. The given word s consists of lowercase English letters.
1,400
Print such word t that it doesn't contain any typos described in the problem statement and is obtained from s by deleting the least number of letters. If there are multiple solutions, print any of them.
standard output
PASSED
b92010f374ba773a5caba0f5f39f6845
train_000.jsonl
1384156800
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" co...
256 megabytes
import java.util.Scanner; public class Fixingtypos2 { public static void main(String[] args) { // TODO Auto-generated method stub Scanner s = new Scanner(System.in); String str = s.next(); char ch[] = str.toCharArray(); StringBuilder sb = new StringBuilder(); char cc = ch[0]; sb.append(ch[0]); int t...
Java
["helloo", "woooooow"]
1 second
["hello", "woow"]
NoteThe second valid answer to the test from the statement is "heloo".
Java 8
standard input
[ "implementation", "greedy" ]
31d803d886c47fe681bdcfbe6c74f090
The single line of the input contains word s, its length is from 1 to 200000 characters. The given word s consists of lowercase English letters.
1,400
Print such word t that it doesn't contain any typos described in the problem statement and is obtained from s by deleting the least number of letters. If there are multiple solutions, print any of them.
standard output
PASSED
0ebc486d18d0bd7e39e66ac2c6e64312
train_000.jsonl
1384156800
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" co...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.LinkedList; public class Main { public String fix(String word) { if (word.length() < 3) { return word; } StringBuilder res = new StringBuilder(word.length()); Li...
Java
["helloo", "woooooow"]
1 second
["hello", "woow"]
NoteThe second valid answer to the test from the statement is "heloo".
Java 6
standard input
[ "implementation", "greedy" ]
31d803d886c47fe681bdcfbe6c74f090
The single line of the input contains word s, its length is from 1 to 200000 characters. The given word s consists of lowercase English letters.
1,400
Print such word t that it doesn't contain any typos described in the problem statement and is obtained from s by deleting the least number of letters. If there are multiple solutions, print any of them.
standard output
PASSED
a7a39176e25e2389f5b04fd04bfb96ce
train_000.jsonl
1384156800
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" co...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author a.bogdanov */ public class FixTypos { public static void main(String[] args) throws IOException { ...
Java
["helloo", "woooooow"]
1 second
["hello", "woow"]
NoteThe second valid answer to the test from the statement is "heloo".
Java 6
standard input
[ "implementation", "greedy" ]
31d803d886c47fe681bdcfbe6c74f090
The single line of the input contains word s, its length is from 1 to 200000 characters. The given word s consists of lowercase English letters.
1,400
Print such word t that it doesn't contain any typos described in the problem statement and is obtained from s by deleting the least number of letters. If there are multiple solutions, print any of them.
standard output
PASSED
233edf55f9f883ee6cc6fe60d473ce78
train_000.jsonl
1384156800
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" co...
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public stat...
Java
["helloo", "woooooow"]
1 second
["hello", "woow"]
NoteThe second valid answer to the test from the statement is "heloo".
Java 6
standard input
[ "implementation", "greedy" ]
31d803d886c47fe681bdcfbe6c74f090
The single line of the input contains word s, its length is from 1 to 200000 characters. The given word s consists of lowercase English letters.
1,400
Print such word t that it doesn't contain any typos described in the problem statement and is obtained from s by deleting the least number of letters. If there are multiple solutions, print any of them.
standard output
PASSED
9e5f487280002c61e8a9719a486a7a00
train_000.jsonl
1384156800
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" co...
256 megabytes
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class T363C { public void solve(String s) { int n = s.length(); char[] ch = new char[n]; int[] idx = new int...
Java
["helloo", "woooooow"]
1 second
["hello", "woow"]
NoteThe second valid answer to the test from the statement is "heloo".
Java 6
standard input
[ "implementation", "greedy" ]
31d803d886c47fe681bdcfbe6c74f090
The single line of the input contains word s, its length is from 1 to 200000 characters. The given word s consists of lowercase English letters.
1,400
Print such word t that it doesn't contain any typos described in the problem statement and is obtained from s by deleting the least number of letters. If there are multiple solutions, print any of them.
standard output
PASSED
947f3f1c2aa679aef10c5eb9f6aea2f7
train_000.jsonl
1384156800
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" co...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Scanner; public class FixingTypos { static Scanner input = new Scanner(new BufferedReader(new InputStreamReader(System.in))); public static void main(String[] args) { String text = input.next(); int n = text...
Java
["helloo", "woooooow"]
1 second
["hello", "woow"]
NoteThe second valid answer to the test from the statement is "heloo".
Java 6
standard input
[ "implementation", "greedy" ]
31d803d886c47fe681bdcfbe6c74f090
The single line of the input contains word s, its length is from 1 to 200000 characters. The given word s consists of lowercase English letters.
1,400
Print such word t that it doesn't contain any typos described in the problem statement and is obtained from s by deleting the least number of letters. If there are multiple solutions, print any of them.
standard output
PASSED
588115673e0c63310649e8a0d7cb964e
train_000.jsonl
1384156800
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" co...
256 megabytes
import java.awt.*; import java.awt.event.*; import java.awt.geom.*; import java.io.*; import java.math.*; import java.text.*; import java.util.*; /* br = new BufferedReader(new FileReader("input.txt")); pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt"))); br = new BufferedReader(new InputStreamRead...
Java
["helloo", "woooooow"]
1 second
["hello", "woow"]
NoteThe second valid answer to the test from the statement is "heloo".
Java 6
standard input
[ "implementation", "greedy" ]
31d803d886c47fe681bdcfbe6c74f090
The single line of the input contains word s, its length is from 1 to 200000 characters. The given word s consists of lowercase English letters.
1,400
Print such word t that it doesn't contain any typos described in the problem statement and is obtained from s by deleting the least number of letters. If there are multiple solutions, print any of them.
standard output
PASSED
feb6bf71f8f4e48e1fce670644843f2c
train_000.jsonl
1384156800
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" co...
256 megabytes
import java.util.Scanner; public class Opechatki { public static void main(String[] args) { Scanner sc = new Scanner(System.in); StringBuilder sb = new StringBuilder(); StringBuilder sbresult = new StringBuilder(); String a = ""; a = sc.next(); if (!a.equals("x")) { sb.append(a); char pre =...
Java
["helloo", "woooooow"]
1 second
["hello", "woow"]
NoteThe second valid answer to the test from the statement is "heloo".
Java 6
standard input
[ "implementation", "greedy" ]
31d803d886c47fe681bdcfbe6c74f090
The single line of the input contains word s, its length is from 1 to 200000 characters. The given word s consists of lowercase English letters.
1,400
Print such word t that it doesn't contain any typos described in the problem statement and is obtained from s by deleting the least number of letters. If there are multiple solutions, print any of them.
standard output
PASSED
47231d4337c8afcf7077daceb156c8a7
train_000.jsonl
1384156800
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" co...
256 megabytes
import java.io.*; import java.util.*; public class C implements Runnable { private void solve() throws IOException { char[] c = nextToken().toCharArray(); boolean[] f = new boolean[c.length]; int cnt = 0; for (int i = 2; i < c.length; i++) { if (c[i - 2] == c[i - 1] && c[i - 1] == c[i]) { f[i] = true;...
Java
["helloo", "woooooow"]
1 second
["hello", "woow"]
NoteThe second valid answer to the test from the statement is "heloo".
Java 6
standard input
[ "implementation", "greedy" ]
31d803d886c47fe681bdcfbe6c74f090
The single line of the input contains word s, its length is from 1 to 200000 characters. The given word s consists of lowercase English letters.
1,400
Print such word t that it doesn't contain any typos described in the problem statement and is obtained from s by deleting the least number of letters. If there are multiple solutions, print any of them.
standard output
PASSED
6e99e5d2bb0d25f68d462ed00645c750
train_000.jsonl
1384156800
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" co...
256 megabytes
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ import java.util.Scanner; /** * * @author aaa */ public class newsolution { public static void main(String[] args) { ...
Java
["helloo", "woooooow"]
1 second
["hello", "woow"]
NoteThe second valid answer to the test from the statement is "heloo".
Java 6
standard input
[ "implementation", "greedy" ]
31d803d886c47fe681bdcfbe6c74f090
The single line of the input contains word s, its length is from 1 to 200000 characters. The given word s consists of lowercase English letters.
1,400
Print such word t that it doesn't contain any typos described in the problem statement and is obtained from s by deleting the least number of letters. If there are multiple solutions, print any of them.
standard output
PASSED
47de2aeed021eddb7db773754f489e43
train_000.jsonl
1384156800
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" co...
256 megabytes
import java.util.*; public class Main{ public static void main(String[] args) throws Exception{ Scanner a = new Scanner(System.in); char[] stack; String s=a.next(); int len=s.length(); stack = new char[len]; int index=0; for(int i=0;i<len;i++){ if(i...
Java
["helloo", "woooooow"]
1 second
["hello", "woow"]
NoteThe second valid answer to the test from the statement is "heloo".
Java 6
standard input
[ "implementation", "greedy" ]
31d803d886c47fe681bdcfbe6c74f090
The single line of the input contains word s, its length is from 1 to 200000 characters. The given word s consists of lowercase English letters.
1,400
Print such word t that it doesn't contain any typos described in the problem statement and is obtained from s by deleting the least number of letters. If there are multiple solutions, print any of them.
standard output
PASSED
fc90f42ce871817875d8ecf6d4f23492
train_000.jsonl
1384156800
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" co...
256 megabytes
import java.util.*; public class Typo { public static void main(String[] args) { Scanner in = new Scanner(System.in); String line = in.nextLine(); char last1, last2; boolean reduce21 = false; int l = line.length(); if(l <= 2) { System.out.println(line); return;...
Java
["helloo", "woooooow"]
1 second
["hello", "woow"]
NoteThe second valid answer to the test from the statement is "heloo".
Java 6
standard input
[ "implementation", "greedy" ]
31d803d886c47fe681bdcfbe6c74f090
The single line of the input contains word s, its length is from 1 to 200000 characters. The given word s consists of lowercase English letters.
1,400
Print such word t that it doesn't contain any typos described in the problem statement and is obtained from s by deleting the least number of letters. If there are multiple solutions, print any of them.
standard output
PASSED
b8ef06b2f6d8921c305311a4b506a576
train_000.jsonl
1384156800
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" co...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; /** * Created by 875k on 12/26/13. */ public class CF211C { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String str...
Java
["helloo", "woooooow"]
1 second
["hello", "woow"]
NoteThe second valid answer to the test from the statement is "heloo".
Java 6
standard input
[ "implementation", "greedy" ]
31d803d886c47fe681bdcfbe6c74f090
The single line of the input contains word s, its length is from 1 to 200000 characters. The given word s consists of lowercase English letters.
1,400
Print such word t that it doesn't contain any typos described in the problem statement and is obtained from s by deleting the least number of letters. If there are multiple solutions, print any of them.
standard output
PASSED
5b8d338e979ce8031375bdf0b8798283
train_000.jsonl
1384156800
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" co...
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.Scanner; import java.util.Stack; public class C211C { public void solve() throws IOException { Scanner sc = new Scanner(System.in); ...
Java
["helloo", "woooooow"]
1 second
["hello", "woow"]
NoteThe second valid answer to the test from the statement is "heloo".
Java 6
standard input
[ "implementation", "greedy" ]
31d803d886c47fe681bdcfbe6c74f090
The single line of the input contains word s, its length is from 1 to 200000 characters. The given word s consists of lowercase English letters.
1,400
Print such word t that it doesn't contain any typos described in the problem statement and is obtained from s by deleting the least number of letters. If there are multiple solutions, print any of them.
standard output
PASSED
f26e32c67e00008a66be7a57f8c94cc6
train_000.jsonl
1384156800
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" co...
256 megabytes
import java.io.PrintWriter; import java.util.*; public class c { public static void main(String[] args) { Scanner input = new Scanner(System.in); String s = input.next(); int n = s.length(); PrintWriter out = new PrintWriter(System.out); ArrayList<Character> list = new ArrayList<Character>(); fo...
Java
["helloo", "woooooow"]
1 second
["hello", "woow"]
NoteThe second valid answer to the test from the statement is "heloo".
Java 6
standard input
[ "implementation", "greedy" ]
31d803d886c47fe681bdcfbe6c74f090
The single line of the input contains word s, its length is from 1 to 200000 characters. The given word s consists of lowercase English letters.
1,400
Print such word t that it doesn't contain any typos described in the problem statement and is obtained from s by deleting the least number of letters. If there are multiple solutions, print any of them.
standard output
PASSED
c37f4d212be4aaa7f81c53c27a040ea3
train_000.jsonl
1384156800
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" co...
256 megabytes
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.ArrayList; import java.util.Locale; import java.util.StringTokenizer...
Java
["helloo", "woooooow"]
1 second
["hello", "woow"]
NoteThe second valid answer to the test from the statement is "heloo".
Java 6
standard input
[ "implementation", "greedy" ]
31d803d886c47fe681bdcfbe6c74f090
The single line of the input contains word s, its length is from 1 to 200000 characters. The given word s consists of lowercase English letters.
1,400
Print such word t that it doesn't contain any typos described in the problem statement and is obtained from s by deleting the least number of letters. If there are multiple solutions, print any of them.
standard output
PASSED
7eb54dd058023dc24558acd8dc762ead
train_000.jsonl
1384156800
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" co...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class Main implements Runnable{ private static String filename; public static void main(String[] args) { if (args.length > 0 && args[0].equals("f")) filename = "input.txt"; else filename = ""; new Thread(new Main()).start();...
Java
["helloo", "woooooow"]
1 second
["hello", "woow"]
NoteThe second valid answer to the test from the statement is "heloo".
Java 6
standard input
[ "implementation", "greedy" ]
31d803d886c47fe681bdcfbe6c74f090
The single line of the input contains word s, its length is from 1 to 200000 characters. The given word s consists of lowercase English letters.
1,400
Print such word t that it doesn't contain any typos described in the problem statement and is obtained from s by deleting the least number of letters. If there are multiple solutions, print any of them.
standard output
PASSED
42b593abd2cd59d234f82c3ff3ca6765
train_000.jsonl
1384156800
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" co...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; public class Test { public static void main(String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); char[] letters = br.readLine().toCharArray(); boolean[] toRemove = new bool...
Java
["helloo", "woooooow"]
1 second
["hello", "woow"]
NoteThe second valid answer to the test from the statement is "heloo".
Java 6
standard input
[ "implementation", "greedy" ]
31d803d886c47fe681bdcfbe6c74f090
The single line of the input contains word s, its length is from 1 to 200000 characters. The given word s consists of lowercase English letters.
1,400
Print such word t that it doesn't contain any typos described in the problem statement and is obtained from s by deleting the least number of letters. If there are multiple solutions, print any of them.
standard output
PASSED
78e4d935feece21317afdf63c389b478
train_000.jsonl
1384156800
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" co...
256 megabytes
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.StringTokenizer; /** * * 28691 28312 * * @author pttrung */ public class C { // public static long x, y, gcd; public static in...
Java
["helloo", "woooooow"]
1 second
["hello", "woow"]
NoteThe second valid answer to the test from the statement is "heloo".
Java 6
standard input
[ "implementation", "greedy" ]
31d803d886c47fe681bdcfbe6c74f090
The single line of the input contains word s, its length is from 1 to 200000 characters. The given word s consists of lowercase English letters.
1,400
Print such word t that it doesn't contain any typos described in the problem statement and is obtained from s by deleting the least number of letters. If there are multiple solutions, print any of them.
standard output
PASSED
2da980667b3e36b6631b555cfcb1c5d9
train_000.jsonl
1384156800
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" co...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; public class Main { public static void main(String[] args) throws IOException { FastScanner s = new FastScanner(System.in); String word = s.nextString(); char array[] = word.toCharArray(); ArrayList<...
Java
["helloo", "woooooow"]
1 second
["hello", "woow"]
NoteThe second valid answer to the test from the statement is "heloo".
Java 6
standard input
[ "implementation", "greedy" ]
31d803d886c47fe681bdcfbe6c74f090
The single line of the input contains word s, its length is from 1 to 200000 characters. The given word s consists of lowercase English letters.
1,400
Print such word t that it doesn't contain any typos described in the problem statement and is obtained from s by deleting the least number of letters. If there are multiple solutions, print any of them.
standard output
PASSED
15ac5c2d4ca6a05e01bc1ff3175e6104
train_000.jsonl
1384156800
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" co...
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.Hashtable; import java.util.LinkedList; impor...
Java
["helloo", "woooooow"]
1 second
["hello", "woow"]
NoteThe second valid answer to the test from the statement is "heloo".
Java 6
standard input
[ "implementation", "greedy" ]
31d803d886c47fe681bdcfbe6c74f090
The single line of the input contains word s, its length is from 1 to 200000 characters. The given word s consists of lowercase English letters.
1,400
Print such word t that it doesn't contain any typos described in the problem statement and is obtained from s by deleting the least number of letters. If there are multiple solutions, print any of them.
standard output
PASSED
37da96b044ad6fcc2f87b37b5ff4b692
train_000.jsonl
1397749200
One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into n teams and played several matches, two teams could not play against each other more than once.The appointed Judge was the most experienced member — Pavel. But since he was the wise...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Locale; import java.util.StringTokenizer; public class Main { public static void main(String[] args)...
Java
["3 1"]
1 second
["3\n1 2\n2 3\n3 1"]
null
Java 7
standard input
[ "constructive algorithms", "implementation", "graphs" ]
14570079152bbf6c439bfceef9816f7e
The first line contains two integers — n and k (1 ≤ n, k ≤ 1000).
1,400
In the first line print an integer m — number of the played games. The following m lines should contain the information about all the matches, one match per line. The i-th line should contain two integers ai and bi (1 ≤ ai, bi ≤ n; ai ≠ bi). The numbers ai and bi mean, that in the i-th match the team with number ai won...
standard output
PASSED
943112566a2f2364db95e26d78d0c90b
train_000.jsonl
1397749200
One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into n teams and played several matches, two teams could not play against each other more than once.The appointed Judge was the most experienced member — Pavel. But since he was the wise...
256 megabytes
import static java.lang.Math.*; import static java.lang.System.currentTimeMillis; import static java.lang.System.exit; import static java.lang.System.arraycopy; import static java.util.Arrays.sort; import static java.util.Arrays.binarySearch; import static java.util.Arrays.fill; import java.util.*; import java.io.*; p...
Java
["3 1"]
1 second
["3\n1 2\n2 3\n3 1"]
null
Java 7
standard input
[ "constructive algorithms", "implementation", "graphs" ]
14570079152bbf6c439bfceef9816f7e
The first line contains two integers — n and k (1 ≤ n, k ≤ 1000).
1,400
In the first line print an integer m — number of the played games. The following m lines should contain the information about all the matches, one match per line. The i-th line should contain two integers ai and bi (1 ≤ ai, bi ≤ n; ai ≠ bi). The numbers ai and bi mean, that in the i-th match the team with number ai won...
standard output
PASSED
1e918cb8e3932698a3bc4798929955da
train_000.jsonl
1397749200
One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into n teams and played several matches, two teams could not play against each other more than once.The appointed Judge was the most experienced member — Pavel. But since he was the wise...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.*; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; Out...
Java
["3 1"]
1 second
["3\n1 2\n2 3\n3 1"]
null
Java 7
standard input
[ "constructive algorithms", "implementation", "graphs" ]
14570079152bbf6c439bfceef9816f7e
The first line contains two integers — n and k (1 ≤ n, k ≤ 1000).
1,400
In the first line print an integer m — number of the played games. The following m lines should contain the information about all the matches, one match per line. The i-th line should contain two integers ai and bi (1 ≤ ai, bi ≤ n; ai ≠ bi). The numbers ai and bi mean, that in the i-th match the team with number ai won...
standard output
PASSED
6bd6751c2a2eba3bb545342c9cfe6b6c
train_000.jsonl
1397749200
One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into n teams and played several matches, two teams could not play against each other more than once.The appointed Judge was the most experienced member — Pavel. But since he was the wise...
256 megabytes
import java.io.PrintStream; import java.util.Scanner; /** * Created by Poison. */ public class Football { private static int teamsCount; private static int winsCount; private static final String SPACE = " "; private static final char ENDL = '\n'; public static void main(String[] args) { ...
Java
["3 1"]
1 second
["3\n1 2\n2 3\n3 1"]
null
Java 7
standard input
[ "constructive algorithms", "implementation", "graphs" ]
14570079152bbf6c439bfceef9816f7e
The first line contains two integers — n and k (1 ≤ n, k ≤ 1000).
1,400
In the first line print an integer m — number of the played games. The following m lines should contain the information about all the matches, one match per line. The i-th line should contain two integers ai and bi (1 ≤ ai, bi ≤ n; ai ≠ bi). The numbers ai and bi mean, that in the i-th match the team with number ai won...
standard output
PASSED
bfc51239ca9715fc6e0c7d215fd01cfe
train_000.jsonl
1397749200
One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into n teams and played several matches, two teams could not play against each other more than once.The appointed Judge was the most experienced member — Pavel. But since he was the wise...
256 megabytes
import java.io.IOException; import java.io.InputStreamReader; import java.util.InputMismatchException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the to...
Java
["3 1"]
1 second
["3\n1 2\n2 3\n3 1"]
null
Java 7
standard input
[ "constructive algorithms", "implementation", "graphs" ]
14570079152bbf6c439bfceef9816f7e
The first line contains two integers — n and k (1 ≤ n, k ≤ 1000).
1,400
In the first line print an integer m — number of the played games. The following m lines should contain the information about all the matches, one match per line. The i-th line should contain two integers ai and bi (1 ≤ ai, bi ≤ n; ai ≠ bi). The numbers ai and bi mean, that in the i-th match the team with number ai won...
standard output
PASSED
57e50d633c492568307e160e53269d5f
train_000.jsonl
1397749200
One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into n teams and played several matches, two teams could not play against each other more than once.The appointed Judge was the most experienced member — Pavel. But since he was the wise...
256 megabytes
import java.io.*; import java.util.*; public class Main implements Runnable { public void _main() throws IOException { int n = nextInt(); int k = nextInt(); if (k > (n - 1) / 2) { out.println(-1); return; } out.println(n * k); for (int i = 0; i < n; i++) { for (int j = 0; j < k; j++) { int a...
Java
["3 1"]
1 second
["3\n1 2\n2 3\n3 1"]
null
Java 7
standard input
[ "constructive algorithms", "implementation", "graphs" ]
14570079152bbf6c439bfceef9816f7e
The first line contains two integers — n and k (1 ≤ n, k ≤ 1000).
1,400
In the first line print an integer m — number of the played games. The following m lines should contain the information about all the matches, one match per line. The i-th line should contain two integers ai and bi (1 ≤ ai, bi ≤ n; ai ≠ bi). The numbers ai and bi mean, that in the i-th match the team with number ai won...
standard output
PASSED
5bfa5c6445232d684b0ed33d648c29a3
train_000.jsonl
1397749200
One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into n teams and played several matches, two teams could not play against each other more than once.The appointed Judge was the most experienced member — Pavel. But since he was the wise...
256 megabytes
import java.io.*; import java.util.*; public class GPL implements Runnable { public static void main(String[] args) { new Thread(new GPL()).run(); } BufferedReader br; StringTokenizer in; PrintWriter out; public String nextToken() throws IOException { while (in == null || !in....
Java
["3 1"]
1 second
["3\n1 2\n2 3\n3 1"]
null
Java 7
standard input
[ "constructive algorithms", "implementation", "graphs" ]
14570079152bbf6c439bfceef9816f7e
The first line contains two integers — n and k (1 ≤ n, k ≤ 1000).
1,400
In the first line print an integer m — number of the played games. The following m lines should contain the information about all the matches, one match per line. The i-th line should contain two integers ai and bi (1 ≤ ai, bi ≤ n; ai ≠ bi). The numbers ai and bi mean, that in the i-th match the team with number ai won...
standard output
PASSED
9db1561215a4519d7a71147cbc68a307
train_000.jsonl
1397749200
One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into n teams and played several matches, two teams could not play against each other more than once.The appointed Judge was the most experienced member — Pavel. But since he was the wise...
256 megabytes
//package rcc.warmup; 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 A { InputStream is; PrintWriter out; String INPUT = ""; void solve() { int n = ni(), K =...
Java
["3 1"]
1 second
["3\n1 2\n2 3\n3 1"]
null
Java 7
standard input
[ "constructive algorithms", "implementation", "graphs" ]
14570079152bbf6c439bfceef9816f7e
The first line contains two integers — n and k (1 ≤ n, k ≤ 1000).
1,400
In the first line print an integer m — number of the played games. The following m lines should contain the information about all the matches, one match per line. The i-th line should contain two integers ai and bi (1 ≤ ai, bi ≤ n; ai ≠ bi). The numbers ai and bi mean, that in the i-th match the team with number ai won...
standard output
PASSED
d16c328f1b1ffbfb2a5a25dab0bb0499
train_000.jsonl
1397749200
One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into n teams and played several matches, two teams could not play against each other more than once.The appointed Judge was the most experienced member — Pavel. But since he was the wise...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Comparator; import java.util.Deque; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList;...
Java
["3 1"]
1 second
["3\n1 2\n2 3\n3 1"]
null
Java 7
standard input
[ "constructive algorithms", "implementation", "graphs" ]
14570079152bbf6c439bfceef9816f7e
The first line contains two integers — n and k (1 ≤ n, k ≤ 1000).
1,400
In the first line print an integer m — number of the played games. The following m lines should contain the information about all the matches, one match per line. The i-th line should contain two integers ai and bi (1 ≤ ai, bi ≤ n; ai ≠ bi). The numbers ai and bi mean, that in the i-th match the team with number ai won...
standard output
PASSED
2bed15c1ea2643e27dcdaf4bc566591b
train_000.jsonl
1397749200
One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into n teams and played several matches, two teams could not play against each other more than once.The appointed Judge was the most experienced member — Pavel. But since he was the wise...
256 megabytes
//package main; import java.util.*; import java.io.*; import java.math.BigInteger; public class Main { FastScanner scan; PrintWriter out; BufferedReader in; static BigInteger fact(BigInteger b) { BigInteger p =BigInteger.ONE; for (BigInteger i = BigInteger.ONE; i.compareTo(b.add(Big...
Java
["3 1"]
1 second
["3\n1 2\n2 3\n3 1"]
null
Java 7
standard input
[ "constructive algorithms", "implementation", "graphs" ]
14570079152bbf6c439bfceef9816f7e
The first line contains two integers — n and k (1 ≤ n, k ≤ 1000).
1,400
In the first line print an integer m — number of the played games. The following m lines should contain the information about all the matches, one match per line. The i-th line should contain two integers ai and bi (1 ≤ ai, bi ≤ n; ai ≠ bi). The numbers ai and bi mean, that in the i-th match the team with number ai won...
standard output
PASSED
7c8e83fb706a64c98e5a9b5ff4bbe555
train_000.jsonl
1397749200
One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into n teams and played several matches, two teams could not play against each other more than once.The appointed Judge was the most experienced member — Pavel. But since he was the wise...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.PrintWriter; import java.io.Writer; import java.math.BigInteger; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author Shamir14 (lordamir14@gmail.com) */ public class Main { public static void...
Java
["3 1"]
1 second
["3\n1 2\n2 3\n3 1"]
null
Java 7
standard input
[ "constructive algorithms", "implementation", "graphs" ]
14570079152bbf6c439bfceef9816f7e
The first line contains two integers — n and k (1 ≤ n, k ≤ 1000).
1,400
In the first line print an integer m — number of the played games. The following m lines should contain the information about all the matches, one match per line. The i-th line should contain two integers ai and bi (1 ≤ ai, bi ≤ n; ai ≠ bi). The numbers ai and bi mean, that in the i-th match the team with number ai won...
standard output
PASSED
4988384f63f2c00b14e23d55bb3f1e1b
train_000.jsonl
1397749200
One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into n teams and played several matches, two teams could not play against each other more than once.The appointed Judge was the most experienced member — Pavel. But since he was the wise...
256 megabytes
import java.io.*; import java.util.*; public class C418A { private static StringTokenizer st; public static void nextLine(BufferedReader br) throws IOException { st = new StringTokenizer(br.readLine()); } public static int nextInt() { return Integer.parseInt(st.nextToken(...
Java
["3 1"]
1 second
["3\n1 2\n2 3\n3 1"]
null
Java 7
standard input
[ "constructive algorithms", "implementation", "graphs" ]
14570079152bbf6c439bfceef9816f7e
The first line contains two integers — n and k (1 ≤ n, k ≤ 1000).
1,400
In the first line print an integer m — number of the played games. The following m lines should contain the information about all the matches, one match per line. The i-th line should contain two integers ai and bi (1 ≤ ai, bi ≤ n; ai ≠ bi). The numbers ai and bi mean, that in the i-th match the team with number ai won...
standard output
PASSED
c55ed7363006af5859c4d25810decaa1
train_000.jsonl
1397749200
One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into n teams and played several matches, two teams could not play against each other more than once.The appointed Judge was the most experienced member — Pavel. But since he was the wise...
256 megabytes
import java.io.*; import java.util.*; public class Task{ public static void main(String[] args) throws IOException{ new Task().run(); } StreamTokenizer in; Scanner ins; PrintWriter out; int nextInt() throws IOException{ in.nextToken(); return (int)in.nval;...
Java
["3 1"]
1 second
["3\n1 2\n2 3\n3 1"]
null
Java 7
standard input
[ "constructive algorithms", "implementation", "graphs" ]
14570079152bbf6c439bfceef9816f7e
The first line contains two integers — n and k (1 ≤ n, k ≤ 1000).
1,400
In the first line print an integer m — number of the played games. The following m lines should contain the information about all the matches, one match per line. The i-th line should contain two integers ai and bi (1 ≤ ai, bi ≤ n; ai ≠ bi). The numbers ai and bi mean, that in the i-th match the team with number ai won...
standard output