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
749a7d824e7ad2e8fa6234c3bbd24aea
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ import java.util.*; import java.io.*; /** * * @author TRUE */ public class Main { public static void main(String[] args) { ...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
05696eb7ce4485cc1d9941a015e42d60
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
78484e5d6fe5630dc1b8ccc54440bd08
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.awt.List; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections;...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
a9a59b5e71396017aa4ba14584e3dcfb
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Codechef { public static void main (String[] args) throws java.lang.Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String s; s = br.readLine(); ...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
45c609f61ae476a88375ab4325ca3033
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class Main { public static class FastReader { BufferedReader br; StringTokenizer root; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (root == null || !root....
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
e739ec1ebb996e3c8a82a5b13b5b304d
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.StringTokenizer; public class CF205_Queue { static char c[]; static int n; static ...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
a808615eaa1186fee77ee29486b3ed58
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String [] args)throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String str = br.readLine(); int max = 0; int pos = str.length(); for(int i = 0;i < str.length();i++){ if(str.charAt(i) == 'F...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
37881032c313b706981f112642b522e3
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class Template implements Runnable { BufferedReader in; PrintWriter out; StringTokenizer tok = new StringTokenizer(""); void init() throws FileNotFoundException { try { in = new BufferedReader(new FileReader...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
e929274e94f144c78e7ce300f04ccd7f
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Queue_353D { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); char[] s = sc.next().toCharArray()...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
bb07d925c56db152f8185b3d57258f47
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Queue_353D { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); char[] s = sc.next().toCharArray()...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
cb88049fc55f7aef5845ba35fb89b496
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.util.*; import java.io.*; public class D { Reader in; PrintWriter out; int i = 0, j = 0; void solve() { //START// char[] cc = in.next().toCharArray(); int cnt = 0, max = 0, del = 0; for (i = 0; i < cc.length; i++) { if (cc[i...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
c84e82cbb2502c289a1c4c53dab4d2d1
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.text.DecimalFormat; import java.text.NumberFormat; public class Main { int mod = 1000000007; public void solve() throws IOException{ char[] s = in.next().toCharArray(); int m = 0; int ans = 0; for(int i ...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
9ba9e06c0efd2694037513b5f61ced17
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
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.util.ArrayList; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @autho...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
722c6d23a1786d35570b4ed5b2606feb
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
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. */ /** * * @author dipankar12 */ import java.io.*; import java.util.*; public class r205d { public static void main(String args[])...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
fa2c3560fa390c544bede60e021e5b33
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main (String[] args)throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String s = in.readLine(); int n = s.length(); int count = 0; int last = 0; int...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
701e889e972511b9981d20b268467f97
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class _35_Queue { public static void main(String[] args) { Scanner scn = new Scanner(System.in); String s = scn.next(); int time = 0; int updated = 0; int v = 0; int sl = 0; while (sl < s.length()) { if (s.charAt(sl) == 'F') { break; ...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
dd49953ad742d119d28f6eb739ea4beb
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
// ONE DAY, YOU WILL BE BEYOND THE REACH OF SPACE AND TIME. // // UNTIL THEN, STAY LOW AND CODE HARD. // // Author :- Saurabh// //BIT MESRA, RANCHI// import java.io.*; import java.util.*; import java.util.Queue; import static java.lang.Math.*; public class DQueue { static void Bolo_Jai_Mata_Di() { char c...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
9737b4962b21826cb6f3d3cb6d81ddad
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.util.*; import java.lang.*; import java.math.*; import java.io.*; /* spar5h */ public class cf4 implements Runnable{ static void bfc(int x) { char[] ch = Integer.toBinaryString(x).toCharArray(); int n = ch.length; char[] a = new char[n]; for(int i = 0; i < n; i++) a[i] = ch[i];...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
3a2654bca9dc63b6870eb0079d1ac9e4
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.io.*; import java.util.*; public class D implements Runnable{ public static void main (String[] args) {new Thread(null, new D(), "_cf", 1 << 28).start();} public void run() { FastScanner fs = new FastScanner(); PrintWriter out = new PrintWriter(System.out); System.err.println("Go!"); char[] str...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
7a2ed4282c2d60c6149a1b568f282897
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
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
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
a2dea75536bedc08d451cf4f6db13296
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
/* Keep solving problems. */ import java.util.*; import java.io.*; public class CFA { BufferedReader br; PrintWriter out; StringTokenizer st; boolean eof; private static final long MOD = 1000L * 1000L * 1000L + 7; private static final int[] dx = {0, -1, 0, 1}; private static final int[] dy...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
75c66f0274229a5555fb9cee79155d45
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
//package c205; import java.util.Scanner; public class q4 { public static void main(String args[]) { Scanner s=new Scanner(System.in); String in=s.nextLine(); int []ans=new int[in.length()]; int[] m=new int[in.length()]; int[] w=new int[in.length()]; int max=0...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
723acc48a9381c6eeb0459b01f250ff6
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.util.*; import java.io.*; public class codeforces { static long n; static int m; public static void main(String args[]) { Scanner sc=new Scanner(System.in); String s=sc.next(); int counter=0; int store=0,sum=-1; for(int i=0;i<s.length();i++) { ...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
5475e36e8637bbff1dd309211949803d
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.util.*; import java.io.*; import static java.lang.System.in; public class Main { public static void main(String[] args)throws IOException { Scanner sc = new Scanner(System.in); char[] s = sc.next().toCharArray(); long ans = 0, man = 0; for(char w:s){ if(w=='M...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
b920e974400f11d29077322fdbeee3b2
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
/** * Created by Martin on 2/5/2017. */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; import java.io.PrintWriter; public class Main { public static void main(String[]args) throws IOException { Buffe...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
4340c8af6f52c52ea8584f901ab88e51
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.io.*; import java.util.*; public class ProblemD { InputReader in; PrintWriter out; void solve() { String s = in.next(); int mCount = 0; int wait = 0; int ans = 0; for (int i = 0; i < s.length(); i++) { if (s.charAt(i) == 'M') { mC...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
277cf0eb073e87c226b7fa784fbb475f
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import javafx.scene.layout.Priority; import java.io.*; import java.lang.reflect.Array; import java.net.Inet4Address; import java.util.*; import java.lang.*; import java.util.HashMap; import java.util.PriorityQueue; public class templ implements Runnable{ static class pair implements Comparable { int f; ...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
0c6eb7e37a8891d3d56e2e0b56485a8e
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
// package Practice.CF347; import java.io.*; import java.util.*; public class CF353D { static FastReader s; static PrintWriter out; static String INPUT = "MFMMMMMF\n"; public static void main(String[] args) { long time = System.currentTimeMillis(); boolean oj = System.getProperty("ONLI...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
478daefb9c979ffc06a24fb179ddf077
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.util.*; public class P353D { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String line = sc.next(); int N = line.length(); int[] dp = new int[N]; int k; for (k = 0; k < N; k++) { if (line.charAt(k) == 'F') { ...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 6
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
8fcb273a1cfe0de810d7637e4049537b
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.util.LinkedList; import java.util.Scanner; public class B { public static void main(String[] args) { Scanner in = new Scanner(System.in); char[] s = in.next().toCharArray(); int last = 0; int i = 0; int m = 0; while (i<s.length&&s[i] == 'F'){ i++; last--; m--; } for (; i < s.lengt...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 6
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
cd93f90596c461d588992af88c10dc3e
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Queue { public static void main(String[] args) throws IOException{ BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader(System.in)); ...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 6
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
3322c7e34e7a51f6604da4fa57fa8d58
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; public class D { public static void main(String[] args)throws Exception{ // TODO Auto-generated method stub new D().run(); } int[] getArray(String line){ String[] array=line.split(" "); int[] res=new int[...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 6
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
9b5ab20069306f378c1eb7e744016af1
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class R205D { BufferedReader reader; StringTokenizer tokenizer; PrintWriter out; public void solve() throws IOException { ...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 6
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
af3ce332cf1d23501b72de71a54e1354
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String str = scan.nextLine(); int m = 0; int n = 0; int i = 0; while (str.charAt(i) == 'F') { i++; if (str.length() ...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 6
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
d6024f4a32a3ced909ce0fb735ac6ed3
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.io.*; import java.util.*; public class B { public static void main(String[] args) { new B().run(); } float[] x; float[] y; float[][] d; int n; long count = 0; private void solve() throws Exception { String input = in.readLine(); char[] chs = input.toCharArray(); //in.close(); in...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 6
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
f34fb35982cd16a921c80ee23da86f5f
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.util.*; public class d { public static void main(String[] args) { Scanner input = new Scanner(System.in); String s = input.next(); int n = s.length(); int ms = 0, totms = 0, res = 0, max = 0, totfs = 0, last = 0; for(int i = 0; i<n; i++) { char c = s.charAt(i); if(c =...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 6
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
1f965387abce4c56990e2fad6d7e2bea
train_003.jsonl
1305299400
Valery is very interested in magic. Magic attracts him so much that he sees it everywhere. He explains any strange and weird phenomenon through intervention of supernatural forces. But who would have thought that even in a regular array of numbers Valera manages to see something beautiful and magical.Valera absolutely ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(in.readLine()); in...
Java
["4\n2 1 1 4", "5\n-2 -2 -2 0 1"]
2 seconds
["5", "8"]
NoteNotes to sample tests:Magical subarrays are shown with pairs of indices [a;b] of the beginning and the end.In the first sample: [1;1], [2;2], [3;3], [4;4], [2;3].In the second sample: [1;1], [2;2], [3;3], [4;4], [5;5], [1;2], [2;3], [1;3].
Java 7
standard input
[ "combinatorics", "implementation" ]
0b229ddf583949d43d6f1728e38c3cad
The first line of the input data contains an integer n (1 ≀ n ≀ 105). The second line contains an array of original integers a1, a2, ..., an ( - 109 ≀ ai ≀ 109).
1,300
Print on the single line the answer to the problem: the amount of subarrays, which are magical. Please do not use the %lld specificator to read or write 64-bit numbers in C++. It is recommended to use cin, cout streams (you can also use the %I64d specificator).
standard output
PASSED
ed95d5f5270db243db89d90b15054662
train_003.jsonl
1305299400
Valery is very interested in magic. Magic attracts him so much that he sees it everywhere. He explains any strange and weird phenomenon through intervention of supernatural forces. But who would have thought that even in a regular array of numbers Valera manages to see something beautiful and magical.Valera absolutely ...
256 megabytes
/* * @author Sane */ import java.util.*; import java.util.Scanner; import java.io.File; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.FileWriter; import java.io.FileOutputStream; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.OutputStreamWriter; impor...
Java
["4\n2 1 1 4", "5\n-2 -2 -2 0 1"]
2 seconds
["5", "8"]
NoteNotes to sample tests:Magical subarrays are shown with pairs of indices [a;b] of the beginning and the end.In the first sample: [1;1], [2;2], [3;3], [4;4], [2;3].In the second sample: [1;1], [2;2], [3;3], [4;4], [5;5], [1;2], [2;3], [1;3].
Java 7
standard input
[ "combinatorics", "implementation" ]
0b229ddf583949d43d6f1728e38c3cad
The first line of the input data contains an integer n (1 ≀ n ≀ 105). The second line contains an array of original integers a1, a2, ..., an ( - 109 ≀ ai ≀ 109).
1,300
Print on the single line the answer to the problem: the amount of subarrays, which are magical. Please do not use the %lld specificator to read or write 64-bit numbers in C++. It is recommended to use cin, cout streams (you can also use the %I64d specificator).
standard output
PASSED
558babac2bd56d0386fea40599d06138
train_003.jsonl
1305299400
Valery is very interested in magic. Magic attracts him so much that he sees it everywhere. He explains any strange and weird phenomenon through intervention of supernatural forces. But who would have thought that even in a regular array of numbers Valera manages to see something beautiful and magical.Valera absolutely ...
256 megabytes
import java.util.*; import java.io.*; public class Main{ BufferedReader in; StringTokenizer str = null; PrintWriter out; private String next() throws Exception{ while (str == null || !str.hasMoreElements()) str = new StringTokenizer(in.readLine()); return str.nextToken(); } ...
Java
["4\n2 1 1 4", "5\n-2 -2 -2 0 1"]
2 seconds
["5", "8"]
NoteNotes to sample tests:Magical subarrays are shown with pairs of indices [a;b] of the beginning and the end.In the first sample: [1;1], [2;2], [3;3], [4;4], [2;3].In the second sample: [1;1], [2;2], [3;3], [4;4], [5;5], [1;2], [2;3], [1;3].
Java 7
standard input
[ "combinatorics", "implementation" ]
0b229ddf583949d43d6f1728e38c3cad
The first line of the input data contains an integer n (1 ≀ n ≀ 105). The second line contains an array of original integers a1, a2, ..., an ( - 109 ≀ ai ≀ 109).
1,300
Print on the single line the answer to the problem: the amount of subarrays, which are magical. Please do not use the %lld specificator to read or write 64-bit numbers in C++. It is recommended to use cin, cout streams (you can also use the %I64d specificator).
standard output
PASSED
969290e8aff56b7f76bc15fa0f458a41
train_003.jsonl
1305299400
Valery is very interested in magic. Magic attracts him so much that he sees it everywhere. He explains any strange and weird phenomenon through intervention of supernatural forces. But who would have thought that even in a regular array of numbers Valera manages to see something beautiful and magical.Valera absolutely ...
256 megabytes
import java.util.Scanner; public class MagicArray { public static void main(String[] args) { Scanner flujo = new Scanner(System.in); int a = flujo.nextInt(); int[] arr = new int[a]; long cont = 0; arr[0] = flujo.nextInt(); int act = arr[0]; long oc = 1; for (int i = 1; i < a; i++) { arr[i] = flujo....
Java
["4\n2 1 1 4", "5\n-2 -2 -2 0 1"]
2 seconds
["5", "8"]
NoteNotes to sample tests:Magical subarrays are shown with pairs of indices [a;b] of the beginning and the end.In the first sample: [1;1], [2;2], [3;3], [4;4], [2;3].In the second sample: [1;1], [2;2], [3;3], [4;4], [5;5], [1;2], [2;3], [1;3].
Java 7
standard input
[ "combinatorics", "implementation" ]
0b229ddf583949d43d6f1728e38c3cad
The first line of the input data contains an integer n (1 ≀ n ≀ 105). The second line contains an array of original integers a1, a2, ..., an ( - 109 ≀ ai ≀ 109).
1,300
Print on the single line the answer to the problem: the amount of subarrays, which are magical. Please do not use the %lld specificator to read or write 64-bit numbers in C++. It is recommended to use cin, cout streams (you can also use the %I64d specificator).
standard output
PASSED
84f70f43be01090817d5cbe474b1c64c
train_003.jsonl
1305299400
Valery is very interested in magic. Magic attracts him so much that he sees it everywhere. He explains any strange and weird phenomenon through intervention of supernatural forces. But who would have thought that even in a regular array of numbers Valera manages to see something beautiful and magical.Valera absolutely ...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner flujo = new Scanner(System.in); int a = flujo.nextInt(); int[] arr = new int[a]; long cont = 0; arr[0] = flujo.nextInt(); int act = arr[0]; long oc = 1; for ...
Java
["4\n2 1 1 4", "5\n-2 -2 -2 0 1"]
2 seconds
["5", "8"]
NoteNotes to sample tests:Magical subarrays are shown with pairs of indices [a;b] of the beginning and the end.In the first sample: [1;1], [2;2], [3;3], [4;4], [2;3].In the second sample: [1;1], [2;2], [3;3], [4;4], [5;5], [1;2], [2;3], [1;3].
Java 7
standard input
[ "combinatorics", "implementation" ]
0b229ddf583949d43d6f1728e38c3cad
The first line of the input data contains an integer n (1 ≀ n ≀ 105). The second line contains an array of original integers a1, a2, ..., an ( - 109 ≀ ai ≀ 109).
1,300
Print on the single line the answer to the problem: the amount of subarrays, which are magical. Please do not use the %lld specificator to read or write 64-bit numbers in C++. It is recommended to use cin, cout streams (you can also use the %I64d specificator).
standard output
PASSED
87dc91c885051526eec21fb770a17510
train_003.jsonl
1305299400
Valery is very interested in magic. Magic attracts him so much that he sees it everywhere. He explains any strange and weird phenomenon through intervention of supernatural forces. But who would have thought that even in a regular array of numbers Valera manages to see something beautiful and magical.Valera absolutely ...
256 megabytes
import java.awt.geom.Ellipse2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.PrintWriter; import java.util.*; import java.math.*; import java.io.InputStream; public class main { static final long mod = 1000000007; public static void main(String[] args) { InputReader ...
Java
["4\n2 1 1 4", "5\n-2 -2 -2 0 1"]
2 seconds
["5", "8"]
NoteNotes to sample tests:Magical subarrays are shown with pairs of indices [a;b] of the beginning and the end.In the first sample: [1;1], [2;2], [3;3], [4;4], [2;3].In the second sample: [1;1], [2;2], [3;3], [4;4], [5;5], [1;2], [2;3], [1;3].
Java 7
standard input
[ "combinatorics", "implementation" ]
0b229ddf583949d43d6f1728e38c3cad
The first line of the input data contains an integer n (1 ≀ n ≀ 105). The second line contains an array of original integers a1, a2, ..., an ( - 109 ≀ ai ≀ 109).
1,300
Print on the single line the answer to the problem: the amount of subarrays, which are magical. Please do not use the %lld specificator to read or write 64-bit numbers in C++. It is recommended to use cin, cout streams (you can also use the %I64d specificator).
standard output
PASSED
6ef7b964cb840a72434638eef1f8b4d1
train_003.jsonl
1305299400
Valery is very interested in magic. Magic attracts him so much that he sees it everywhere. He explains any strange and weird phenomenon through intervention of supernatural forces. But who would have thought that even in a regular array of numbers Valera manages to see something beautiful and magical.Valera absolutely ...
256 megabytes
//package codeforces; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.StreamTokenizer; public class CodeForces { public static void main(String[] args) throws FileNotFoundEx...
Java
["4\n2 1 1 4", "5\n-2 -2 -2 0 1"]
2 seconds
["5", "8"]
NoteNotes to sample tests:Magical subarrays are shown with pairs of indices [a;b] of the beginning and the end.In the first sample: [1;1], [2;2], [3;3], [4;4], [2;3].In the second sample: [1;1], [2;2], [3;3], [4;4], [5;5], [1;2], [2;3], [1;3].
Java 7
standard input
[ "combinatorics", "implementation" ]
0b229ddf583949d43d6f1728e38c3cad
The first line of the input data contains an integer n (1 ≀ n ≀ 105). The second line contains an array of original integers a1, a2, ..., an ( - 109 ≀ ai ≀ 109).
1,300
Print on the single line the answer to the problem: the amount of subarrays, which are magical. Please do not use the %lld specificator to read or write 64-bit numbers in C++. It is recommended to use cin, cout streams (you can also use the %I64d specificator).
standard output
PASSED
215bf5c2414c3b0b4c7bd8fbbf186454
train_003.jsonl
1305299400
Valery is very interested in magic. Magic attracts him so much that he sees it everywhere. He explains any strange and weird phenomenon through intervention of supernatural forces. But who would have thought that even in a regular array of numbers Valera manages to see something beautiful and magical.Valera absolutely ...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class Solution { private BufferedReader in; private PrintWriter out; private StringTokenizer st; public String next() throws Exception { if (st == null || !st.hasMoreElements()) { st = new StringTokenizer(in.readLine...
Java
["4\n2 1 1 4", "5\n-2 -2 -2 0 1"]
2 seconds
["5", "8"]
NoteNotes to sample tests:Magical subarrays are shown with pairs of indices [a;b] of the beginning and the end.In the first sample: [1;1], [2;2], [3;3], [4;4], [2;3].In the second sample: [1;1], [2;2], [3;3], [4;4], [5;5], [1;2], [2;3], [1;3].
Java 7
standard input
[ "combinatorics", "implementation" ]
0b229ddf583949d43d6f1728e38c3cad
The first line of the input data contains an integer n (1 ≀ n ≀ 105). The second line contains an array of original integers a1, a2, ..., an ( - 109 ≀ ai ≀ 109).
1,300
Print on the single line the answer to the problem: the amount of subarrays, which are magical. Please do not use the %lld specificator to read or write 64-bit numbers in C++. It is recommended to use cin, cout streams (you can also use the %I64d specificator).
standard output
PASSED
d14124cca5e70f4dd8ec0e81288e23aa
train_003.jsonl
1305299400
Valery is very interested in magic. Magic attracts him so much that he sees it everywhere. He explains any strange and weird phenomenon through intervention of supernatural forces. But who would have thought that even in a regular array of numbers Valera manages to see something beautiful and magical.Valera absolutely ...
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.util.Arrays; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author nas...
Java
["4\n2 1 1 4", "5\n-2 -2 -2 0 1"]
2 seconds
["5", "8"]
NoteNotes to sample tests:Magical subarrays are shown with pairs of indices [a;b] of the beginning and the end.In the first sample: [1;1], [2;2], [3;3], [4;4], [2;3].In the second sample: [1;1], [2;2], [3;3], [4;4], [5;5], [1;2], [2;3], [1;3].
Java 7
standard input
[ "combinatorics", "implementation" ]
0b229ddf583949d43d6f1728e38c3cad
The first line of the input data contains an integer n (1 ≀ n ≀ 105). The second line contains an array of original integers a1, a2, ..., an ( - 109 ≀ ai ≀ 109).
1,300
Print on the single line the answer to the problem: the amount of subarrays, which are magical. Please do not use the %lld specificator to read or write 64-bit numbers in C++. It is recommended to use cin, cout streams (you can also use the %I64d specificator).
standard output
PASSED
55c46398acab75ca6b2d2d44586595de
train_003.jsonl
1305299400
Valery is very interested in magic. Magic attracts him so much that he sees it everywhere. He explains any strange and weird phenomenon through intervention of supernatural forces. But who would have thought that even in a regular array of numbers Valera manages to see something beautiful and magical.Valera absolutely ...
256 megabytes
import java.util.*; import static java.lang.Math.*; import java.awt.Point; import java.io.*; public class A { static Scanner sc = new Scanner(new BufferedInputStream(System.in)); public static void main(String[] args) { int n = ni(); long[] a = new long[n]; for (int i = 0; i < n; i++) a[i] = nl(); long l...
Java
["4\n2 1 1 4", "5\n-2 -2 -2 0 1"]
2 seconds
["5", "8"]
NoteNotes to sample tests:Magical subarrays are shown with pairs of indices [a;b] of the beginning and the end.In the first sample: [1;1], [2;2], [3;3], [4;4], [2;3].In the second sample: [1;1], [2;2], [3;3], [4;4], [5;5], [1;2], [2;3], [1;3].
Java 7
standard input
[ "combinatorics", "implementation" ]
0b229ddf583949d43d6f1728e38c3cad
The first line of the input data contains an integer n (1 ≀ n ≀ 105). The second line contains an array of original integers a1, a2, ..., an ( - 109 ≀ ai ≀ 109).
1,300
Print on the single line the answer to the problem: the amount of subarrays, which are magical. Please do not use the %lld specificator to read or write 64-bit numbers in C++. It is recommended to use cin, cout streams (you can also use the %I64d specificator).
standard output
PASSED
fa74e4d131e55ae8bc46c830de500efa
train_003.jsonl
1305299400
Valery is very interested in magic. Magic attracts him so much that he sees it everywhere. He explains any strange and weird phenomenon through intervention of supernatural forces. But who would have thought that even in a regular array of numbers Valera manages to see something beautiful and magical.Valera absolutely ...
256 megabytes
import java.io.BufferedInputStream; import java.io.IOException; import java.io.PrintWriter; import java.math.BigInteger; 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.InputMismatchExcep...
Java
["4\n2 1 1 4", "5\n-2 -2 -2 0 1"]
2 seconds
["5", "8"]
NoteNotes to sample tests:Magical subarrays are shown with pairs of indices [a;b] of the beginning and the end.In the first sample: [1;1], [2;2], [3;3], [4;4], [2;3].In the second sample: [1;1], [2;2], [3;3], [4;4], [5;5], [1;2], [2;3], [1;3].
Java 7
standard input
[ "combinatorics", "implementation" ]
0b229ddf583949d43d6f1728e38c3cad
The first line of the input data contains an integer n (1 ≀ n ≀ 105). The second line contains an array of original integers a1, a2, ..., an ( - 109 ≀ ai ≀ 109).
1,300
Print on the single line the answer to the problem: the amount of subarrays, which are magical. Please do not use the %lld specificator to read or write 64-bit numbers in C++. It is recommended to use cin, cout streams (you can also use the %I64d specificator).
standard output
PASSED
93c56392201b7f5dc9c6deab3e4a6c5a
train_003.jsonl
1427387400
Pasha got a very beautiful string s for his birthday, the string consists of lowercase Latin letters. The letters in the string are numbered from 1 to |s| from left to right, where |s| is the length of the given string.Pasha didn't like his present very much so he decided to change it. After his birthday Pasha spent m ...
256 megabytes
import java.util.Scanner; public class B { public static void main(String[] args) { Scanner in = new Scanner(System.in); String str = in.nextLine(); if (str == null || str.isEmpty()) { System.out.println(str); return; } char[] chars = str.toCharArra...
Java
["abcdef\n1\n2", "vwxyz\n2\n2 2", "abcdef\n3\n1 2 3"]
2 seconds
["aedcbf", "vwxyz", "fbdcea"]
null
Java 8
standard input
[ "constructive algorithms", "greedy", "math", "strings" ]
9d46ae53e6dc8dc54f732ec93a82ded3
The first line of the input contains Pasha's string s of length from 2 to 2Β·105 characters, consisting of lowercase Latin letters. The second line contains a single integer m (1 ≀ m ≀ 105)Β β€”Β  the number of days when Pasha changed his string. The third line contains m space-separated elements ai (1 ≀ ai; 2Β·ai ≀ |s|)Β β€”Β t...
1,400
In the first line of the output print what Pasha's string s will look like after m days.
standard output
PASSED
cec429a7f0c40539d26a3d71a0136453
train_003.jsonl
1427387400
Pasha got a very beautiful string s for his birthday, the string consists of lowercase Latin letters. The letters in the string are numbered from 1 to |s| from left to right, where |s| is the length of the given string.Pasha didn't like his present very much so he decided to change it. After his birthday Pasha spent m ...
256 megabytes
import java.io.*; import java.util.*; public class B { public static void main(String[] args)throws IOException { BufferedReader ob = new BufferedReader(new InputStreamReader(System.in)); StringBuffer sb=new StringBuffer(); char s[]=ob.readLine().toCharArray(); int m=Integer.parseInt(ob.readLine()); ...
Java
["abcdef\n1\n2", "vwxyz\n2\n2 2", "abcdef\n3\n1 2 3"]
2 seconds
["aedcbf", "vwxyz", "fbdcea"]
null
Java 8
standard input
[ "constructive algorithms", "greedy", "math", "strings" ]
9d46ae53e6dc8dc54f732ec93a82ded3
The first line of the input contains Pasha's string s of length from 2 to 2Β·105 characters, consisting of lowercase Latin letters. The second line contains a single integer m (1 ≀ m ≀ 105)Β β€”Β  the number of days when Pasha changed his string. The third line contains m space-separated elements ai (1 ≀ ai; 2Β·ai ≀ |s|)Β β€”Β t...
1,400
In the first line of the output print what Pasha's string s will look like after m days.
standard output
PASSED
b01b613595871c4d13029eebf23ba77d
train_003.jsonl
1427387400
Pasha got a very beautiful string s for his birthday, the string consists of lowercase Latin letters. The letters in the string are numbered from 1 to |s| from left to right, where |s| is the length of the given string.Pasha didn't like his present very much so he decided to change it. After his birthday Pasha spent m ...
256 megabytes
//package merofeev.contests.codeforces.rnd297; import java.util.Scanner; import java.util.stream.Stream; /** * @author m-erofeev * @since 26.03.15 */ public class B { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String str = scanner.nextLine(); String days = sca...
Java
["abcdef\n1\n2", "vwxyz\n2\n2 2", "abcdef\n3\n1 2 3"]
2 seconds
["aedcbf", "vwxyz", "fbdcea"]
null
Java 8
standard input
[ "constructive algorithms", "greedy", "math", "strings" ]
9d46ae53e6dc8dc54f732ec93a82ded3
The first line of the input contains Pasha's string s of length from 2 to 2Β·105 characters, consisting of lowercase Latin letters. The second line contains a single integer m (1 ≀ m ≀ 105)Β β€”Β  the number of days when Pasha changed his string. The third line contains m space-separated elements ai (1 ≀ ai; 2Β·ai ≀ |s|)Β β€”Β t...
1,400
In the first line of the output print what Pasha's string s will look like after m days.
standard output
PASSED
a810f77bac92af31f34faa0baf1794f3
train_003.jsonl
1427387400
Pasha got a very beautiful string s for his birthday, the string consists of lowercase Latin letters. The letters in the string are numbered from 1 to |s| from left to right, where |s| is the length of the given string.Pasha didn't like his present very much so he decided to change it. After his birthday Pasha spent m ...
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. */ /** * * @author Alex */ import java.io.*; import java.util.*; public class JavaApplication2 { /** * @param args the command li...
Java
["abcdef\n1\n2", "vwxyz\n2\n2 2", "abcdef\n3\n1 2 3"]
2 seconds
["aedcbf", "vwxyz", "fbdcea"]
null
Java 8
standard input
[ "constructive algorithms", "greedy", "math", "strings" ]
9d46ae53e6dc8dc54f732ec93a82ded3
The first line of the input contains Pasha's string s of length from 2 to 2Β·105 characters, consisting of lowercase Latin letters. The second line contains a single integer m (1 ≀ m ≀ 105)Β β€”Β  the number of days when Pasha changed his string. The third line contains m space-separated elements ai (1 ≀ ai; 2Β·ai ≀ |s|)Β β€”Β t...
1,400
In the first line of the output print what Pasha's string s will look like after m days.
standard output
PASSED
020c0874c85488d063e25c50333885b3
train_003.jsonl
1427387400
Pasha got a very beautiful string s for his birthday, the string consists of lowercase Latin letters. The letters in the string are numbered from 1 to |s| from left to right, where |s| is the length of the given string.Pasha didn't like his present very much so he decided to change it. After his birthday Pasha spent m ...
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. */ /** * * @author Alex */ import java.util.Scanner; public class JavaApplication2 { /** * @param args the command line arguments...
Java
["abcdef\n1\n2", "vwxyz\n2\n2 2", "abcdef\n3\n1 2 3"]
2 seconds
["aedcbf", "vwxyz", "fbdcea"]
null
Java 8
standard input
[ "constructive algorithms", "greedy", "math", "strings" ]
9d46ae53e6dc8dc54f732ec93a82ded3
The first line of the input contains Pasha's string s of length from 2 to 2Β·105 characters, consisting of lowercase Latin letters. The second line contains a single integer m (1 ≀ m ≀ 105)Β β€”Β  the number of days when Pasha changed his string. The third line contains m space-separated elements ai (1 ≀ ai; 2Β·ai ≀ |s|)Β β€”Β t...
1,400
In the first line of the output print what Pasha's string s will look like after m days.
standard output
PASSED
3ac60a37e8e3c9e0acc8fabf067bcf34
train_003.jsonl
1427387400
Pasha got a very beautiful string s for his birthday, the string consists of lowercase Latin letters. The letters in the string are numbered from 1 to |s| from left to right, where |s| is the length of the given string.Pasha didn't like his present very much so he decided to change it. After his birthday Pasha spent m ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.Arrays; import java.util.StringTokenizer; //////////////////////////////////////////////////////////////////////////////////...
Java
["abcdef\n1\n2", "vwxyz\n2\n2 2", "abcdef\n3\n1 2 3"]
2 seconds
["aedcbf", "vwxyz", "fbdcea"]
null
Java 8
standard input
[ "constructive algorithms", "greedy", "math", "strings" ]
9d46ae53e6dc8dc54f732ec93a82ded3
The first line of the input contains Pasha's string s of length from 2 to 2Β·105 characters, consisting of lowercase Latin letters. The second line contains a single integer m (1 ≀ m ≀ 105)Β β€”Β  the number of days when Pasha changed his string. The third line contains m space-separated elements ai (1 ≀ ai; 2Β·ai ≀ |s|)Β β€”Β t...
1,400
In the first line of the output print what Pasha's string s will look like after m days.
standard output
PASSED
38e5d93ed9f0353a869a07ecd597ace4
train_003.jsonl
1427387400
Pasha got a very beautiful string s for his birthday, the string consists of lowercase Latin letters. The letters in the string are numbered from 1 to |s| from left to right, where |s| is the length of the given string.Pasha didn't like his present very much so he decided to change it. After his birthday Pasha spent m ...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); String s = sc.nextLine(); int days = sc.nextInt(); int length = s.length(); int[] ar = new int[length]; for(int i=0;i<days;i++){ int index = sc.nextIn...
Java
["abcdef\n1\n2", "vwxyz\n2\n2 2", "abcdef\n3\n1 2 3"]
2 seconds
["aedcbf", "vwxyz", "fbdcea"]
null
Java 8
standard input
[ "constructive algorithms", "greedy", "math", "strings" ]
9d46ae53e6dc8dc54f732ec93a82ded3
The first line of the input contains Pasha's string s of length from 2 to 2Β·105 characters, consisting of lowercase Latin letters. The second line contains a single integer m (1 ≀ m ≀ 105)Β β€”Β  the number of days when Pasha changed his string. The third line contains m space-separated elements ai (1 ≀ ai; 2Β·ai ≀ |s|)Β β€”Β t...
1,400
In the first line of the output print what Pasha's string s will look like after m days.
standard output
PASSED
4756d1477712af5e27d05f36e2a444e9
train_003.jsonl
1560955500
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exactly one symbol).For example, as a result of typing the word "hello", the followi...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class Email { static Scanner sc = new Scanner(System.in); static PrintWriter pw = new PrintWriter(System.out), pw2 = new PrintWriter(System.out); public static void main(String[] args) throws IOException { int q=sc.nextInt(); ...
Java
["4\nhello\nhello\nhello\nhelloo\nhello\nhlllloo\nhello\nhelo", "5\naa\nbb\ncodeforces\ncodeforce\npolycarp\npoolycarpp\naaaa\naaaab\nabcdefghijklmnopqrstuvwxyz\nzabcdefghijklmnopqrstuvwxyz"]
3 seconds
["YES\nYES\nNO\nNO", "NO\nNO\nYES\nNO\nNO"]
null
Java 8
standard input
[ "implementation", "strings" ]
6709c8078cd29e69cf1be285071b2527
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) β€” the number of pairs to check. Further input contains $$$n$$$ descriptions of pairs. The first line of each description contains a single non-empty word $$$s$$$ consisting of lowercase Latin letters. The second line of the description co...
1,200
Output $$$n$$$ lines. In the $$$i$$$-th line for the $$$i$$$-th pair of words $$$s$$$ and $$$t$$$ print YES if the word $$$t$$$ could be printed by typing the word $$$s$$$. Otherwise, print NO.
standard output
PASSED
db64cfb471b6b953b6cc59e4b7b56c09
train_003.jsonl
1560955500
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exactly one symbol).For example, as a result of typing the word "hello", the followi...
256 megabytes
import java.util.*; public class Main{ public static void main(String [] args){ Scanner in = new Scanner(System.in); int n = in.nextInt(); l: for(int i=0;i<n;i++){ String a = in.next(); String b = in.next(); if(a.length()>b.length()){ System.out.println("NO"); ...
Java
["4\nhello\nhello\nhello\nhelloo\nhello\nhlllloo\nhello\nhelo", "5\naa\nbb\ncodeforces\ncodeforce\npolycarp\npoolycarpp\naaaa\naaaab\nabcdefghijklmnopqrstuvwxyz\nzabcdefghijklmnopqrstuvwxyz"]
3 seconds
["YES\nYES\nNO\nNO", "NO\nNO\nYES\nNO\nNO"]
null
Java 8
standard input
[ "implementation", "strings" ]
6709c8078cd29e69cf1be285071b2527
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) β€” the number of pairs to check. Further input contains $$$n$$$ descriptions of pairs. The first line of each description contains a single non-empty word $$$s$$$ consisting of lowercase Latin letters. The second line of the description co...
1,200
Output $$$n$$$ lines. In the $$$i$$$-th line for the $$$i$$$-th pair of words $$$s$$$ and $$$t$$$ print YES if the word $$$t$$$ could be printed by typing the word $$$s$$$. Otherwise, print NO.
standard output
PASSED
c9e68484c5cc36168d9dfae556c20e91
train_003.jsonl
1560955500
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exactly one symbol).For example, as a result of typing the word "hello", the followi...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class AA{ public static void main(String[] args){ InputStream inputStream = System.in; InputReader in = new InputReader(inputStream); OutputStream outputStream = System.out; ...
Java
["4\nhello\nhello\nhello\nhelloo\nhello\nhlllloo\nhello\nhelo", "5\naa\nbb\ncodeforces\ncodeforce\npolycarp\npoolycarpp\naaaa\naaaab\nabcdefghijklmnopqrstuvwxyz\nzabcdefghijklmnopqrstuvwxyz"]
3 seconds
["YES\nYES\nNO\nNO", "NO\nNO\nYES\nNO\nNO"]
null
Java 8
standard input
[ "implementation", "strings" ]
6709c8078cd29e69cf1be285071b2527
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) β€” the number of pairs to check. Further input contains $$$n$$$ descriptions of pairs. The first line of each description contains a single non-empty word $$$s$$$ consisting of lowercase Latin letters. The second line of the description co...
1,200
Output $$$n$$$ lines. In the $$$i$$$-th line for the $$$i$$$-th pair of words $$$s$$$ and $$$t$$$ print YES if the word $$$t$$$ could be printed by typing the word $$$s$$$. Otherwise, print NO.
standard output
PASSED
e2e2a3fda49f96596f4ab90a4fea2405
train_003.jsonl
1560955500
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exactly one symbol).For example, as a result of typing the word "hello", the followi...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.HashMap; import java.util.TreeMap; import java.util.Map; ...
Java
["4\nhello\nhello\nhello\nhelloo\nhello\nhlllloo\nhello\nhelo", "5\naa\nbb\ncodeforces\ncodeforce\npolycarp\npoolycarpp\naaaa\naaaab\nabcdefghijklmnopqrstuvwxyz\nzabcdefghijklmnopqrstuvwxyz"]
3 seconds
["YES\nYES\nNO\nNO", "NO\nNO\nYES\nNO\nNO"]
null
Java 8
standard input
[ "implementation", "strings" ]
6709c8078cd29e69cf1be285071b2527
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) β€” the number of pairs to check. Further input contains $$$n$$$ descriptions of pairs. The first line of each description contains a single non-empty word $$$s$$$ consisting of lowercase Latin letters. The second line of the description co...
1,200
Output $$$n$$$ lines. In the $$$i$$$-th line for the $$$i$$$-th pair of words $$$s$$$ and $$$t$$$ print YES if the word $$$t$$$ could be printed by typing the word $$$s$$$. Otherwise, print NO.
standard output
PASSED
aee71b054f23839cfb46ebfd0f4705f3
train_003.jsonl
1560955500
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exactly one symbol).For example, as a result of typing the word "hello", the followi...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
Java
["4\nhello\nhello\nhello\nhelloo\nhello\nhlllloo\nhello\nhelo", "5\naa\nbb\ncodeforces\ncodeforce\npolycarp\npoolycarpp\naaaa\naaaab\nabcdefghijklmnopqrstuvwxyz\nzabcdefghijklmnopqrstuvwxyz"]
3 seconds
["YES\nYES\nNO\nNO", "NO\nNO\nYES\nNO\nNO"]
null
Java 8
standard input
[ "implementation", "strings" ]
6709c8078cd29e69cf1be285071b2527
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) β€” the number of pairs to check. Further input contains $$$n$$$ descriptions of pairs. The first line of each description contains a single non-empty word $$$s$$$ consisting of lowercase Latin letters. The second line of the description co...
1,200
Output $$$n$$$ lines. In the $$$i$$$-th line for the $$$i$$$-th pair of words $$$s$$$ and $$$t$$$ print YES if the word $$$t$$$ could be printed by typing the word $$$s$$$. Otherwise, print NO.
standard output
PASSED
472bb4c245e8f5771caf35287bf09b36
train_003.jsonl
1560955500
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exactly one symbol).For example, as a result of typing the word "hello", the followi...
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
["4\nhello\nhello\nhello\nhelloo\nhello\nhlllloo\nhello\nhelo", "5\naa\nbb\ncodeforces\ncodeforce\npolycarp\npoolycarpp\naaaa\naaaab\nabcdefghijklmnopqrstuvwxyz\nzabcdefghijklmnopqrstuvwxyz"]
3 seconds
["YES\nYES\nNO\nNO", "NO\nNO\nYES\nNO\nNO"]
null
Java 8
standard input
[ "implementation", "strings" ]
6709c8078cd29e69cf1be285071b2527
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) β€” the number of pairs to check. Further input contains $$$n$$$ descriptions of pairs. The first line of each description contains a single non-empty word $$$s$$$ consisting of lowercase Latin letters. The second line of the description co...
1,200
Output $$$n$$$ lines. In the $$$i$$$-th line for the $$$i$$$-th pair of words $$$s$$$ and $$$t$$$ print YES if the word $$$t$$$ could be printed by typing the word $$$s$$$. Otherwise, print NO.
standard output
PASSED
e773f9c569e680e6e28379b9fcd32d4c
train_003.jsonl
1560955500
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exactly one symbol).For example, as a result of typing the word "hello", the followi...
256 megabytes
/*package whatever //do not write package name here */ import java.io.*; import java.util.*; public class GFG { static Scanner sc=new Scanner(System.in); public static void main (String[] args) { int T=sc.nextInt(); while(T>0){ T--; String a=sc.next(); String b=sc.next(); int i=0,j=0,fl...
Java
["4\nhello\nhello\nhello\nhelloo\nhello\nhlllloo\nhello\nhelo", "5\naa\nbb\ncodeforces\ncodeforce\npolycarp\npoolycarpp\naaaa\naaaab\nabcdefghijklmnopqrstuvwxyz\nzabcdefghijklmnopqrstuvwxyz"]
3 seconds
["YES\nYES\nNO\nNO", "NO\nNO\nYES\nNO\nNO"]
null
Java 8
standard input
[ "implementation", "strings" ]
6709c8078cd29e69cf1be285071b2527
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) β€” the number of pairs to check. Further input contains $$$n$$$ descriptions of pairs. The first line of each description contains a single non-empty word $$$s$$$ consisting of lowercase Latin letters. The second line of the description co...
1,200
Output $$$n$$$ lines. In the $$$i$$$-th line for the $$$i$$$-th pair of words $$$s$$$ and $$$t$$$ print YES if the word $$$t$$$ could be printed by typing the word $$$s$$$. Otherwise, print NO.
standard output
PASSED
19076f82d7fe7dab7ca6f0e79b19a279
train_003.jsonl
1560955500
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exactly one symbol).For example, as a result of typing the word "hello", the followi...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.lang.*; import static java.lang.Math.*; public class Main implements Runnable { static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numCha...
Java
["4\nhello\nhello\nhello\nhelloo\nhello\nhlllloo\nhello\nhelo", "5\naa\nbb\ncodeforces\ncodeforce\npolycarp\npoolycarpp\naaaa\naaaab\nabcdefghijklmnopqrstuvwxyz\nzabcdefghijklmnopqrstuvwxyz"]
3 seconds
["YES\nYES\nNO\nNO", "NO\nNO\nYES\nNO\nNO"]
null
Java 8
standard input
[ "implementation", "strings" ]
6709c8078cd29e69cf1be285071b2527
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) β€” the number of pairs to check. Further input contains $$$n$$$ descriptions of pairs. The first line of each description contains a single non-empty word $$$s$$$ consisting of lowercase Latin letters. The second line of the description co...
1,200
Output $$$n$$$ lines. In the $$$i$$$-th line for the $$$i$$$-th pair of words $$$s$$$ and $$$t$$$ print YES if the word $$$t$$$ could be printed by typing the word $$$s$$$. Otherwise, print NO.
standard output
PASSED
0d6e6e7f809c67c666e7f6a1818fafd0
train_003.jsonl
1560955500
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exactly one symbol).For example, as a result of typing the word "hello", the followi...
256 megabytes
import java.io.*; import java.util.*; public class Codeforces { public static void main(String[] args) throws IOException { BufferedReader bf=new BufferedReader(new InputStreamReader(System.in)); int t=Integer.parseInt(bf.readLine()); String[] outputs=new String[t]; for(int i=0;i<t;i++) ...
Java
["4\nhello\nhello\nhello\nhelloo\nhello\nhlllloo\nhello\nhelo", "5\naa\nbb\ncodeforces\ncodeforce\npolycarp\npoolycarpp\naaaa\naaaab\nabcdefghijklmnopqrstuvwxyz\nzabcdefghijklmnopqrstuvwxyz"]
3 seconds
["YES\nYES\nNO\nNO", "NO\nNO\nYES\nNO\nNO"]
null
Java 8
standard input
[ "implementation", "strings" ]
6709c8078cd29e69cf1be285071b2527
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) β€” the number of pairs to check. Further input contains $$$n$$$ descriptions of pairs. The first line of each description contains a single non-empty word $$$s$$$ consisting of lowercase Latin letters. The second line of the description co...
1,200
Output $$$n$$$ lines. In the $$$i$$$-th line for the $$$i$$$-th pair of words $$$s$$$ and $$$t$$$ print YES if the word $$$t$$$ could be printed by typing the word $$$s$$$. Otherwise, print NO.
standard output
PASSED
0a209327ee41acf0310f596fb2117360
train_003.jsonl
1560955500
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exactly one symbol).For example, as a result of typing the word "hello", the followi...
256 megabytes
import java.util.*; import java.io.*; import java.lang.*; public class Main{ public static void main(String[] args){ Scanner in = new Scanner(System.in); int n= in.nextInt(); for(int i=0;i<n;i++){ String str1 = in.next(); String str2 = in.next(); int k=0,flag =...
Java
["4\nhello\nhello\nhello\nhelloo\nhello\nhlllloo\nhello\nhelo", "5\naa\nbb\ncodeforces\ncodeforce\npolycarp\npoolycarpp\naaaa\naaaab\nabcdefghijklmnopqrstuvwxyz\nzabcdefghijklmnopqrstuvwxyz"]
3 seconds
["YES\nYES\nNO\nNO", "NO\nNO\nYES\nNO\nNO"]
null
Java 8
standard input
[ "implementation", "strings" ]
6709c8078cd29e69cf1be285071b2527
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) β€” the number of pairs to check. Further input contains $$$n$$$ descriptions of pairs. The first line of each description contains a single non-empty word $$$s$$$ consisting of lowercase Latin letters. The second line of the description co...
1,200
Output $$$n$$$ lines. In the $$$i$$$-th line for the $$$i$$$-th pair of words $$$s$$$ and $$$t$$$ print YES if the word $$$t$$$ could be printed by typing the word $$$s$$$. Otherwise, print NO.
standard output
PASSED
ef23e24c51a5534f3855a809f44435c2
train_003.jsonl
1560955500
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exactly one symbol).For example, as a result of typing the word "hello", the followi...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author caoash */ public class Mai...
Java
["4\nhello\nhello\nhello\nhelloo\nhello\nhlllloo\nhello\nhelo", "5\naa\nbb\ncodeforces\ncodeforce\npolycarp\npoolycarpp\naaaa\naaaab\nabcdefghijklmnopqrstuvwxyz\nzabcdefghijklmnopqrstuvwxyz"]
3 seconds
["YES\nYES\nNO\nNO", "NO\nNO\nYES\nNO\nNO"]
null
Java 8
standard input
[ "implementation", "strings" ]
6709c8078cd29e69cf1be285071b2527
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) β€” the number of pairs to check. Further input contains $$$n$$$ descriptions of pairs. The first line of each description contains a single non-empty word $$$s$$$ consisting of lowercase Latin letters. The second line of the description co...
1,200
Output $$$n$$$ lines. In the $$$i$$$-th line for the $$$i$$$-th pair of words $$$s$$$ and $$$t$$$ print YES if the word $$$t$$$ could be printed by typing the word $$$s$$$. Otherwise, print NO.
standard output
PASSED
24d8169257ac12fdc5dfca97d80f4ca9
train_003.jsonl
1560955500
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exactly one symbol).For example, as a result of typing the word "hello", the followi...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; public class B { public static void main(String[] arg) throws IOException{ Reader.init(System.in); int n=Reader.nextInt(); while(n-->0) { String a1=Read...
Java
["4\nhello\nhello\nhello\nhelloo\nhello\nhlllloo\nhello\nhelo", "5\naa\nbb\ncodeforces\ncodeforce\npolycarp\npoolycarpp\naaaa\naaaab\nabcdefghijklmnopqrstuvwxyz\nzabcdefghijklmnopqrstuvwxyz"]
3 seconds
["YES\nYES\nNO\nNO", "NO\nNO\nYES\nNO\nNO"]
null
Java 8
standard input
[ "implementation", "strings" ]
6709c8078cd29e69cf1be285071b2527
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) β€” the number of pairs to check. Further input contains $$$n$$$ descriptions of pairs. The first line of each description contains a single non-empty word $$$s$$$ consisting of lowercase Latin letters. The second line of the description co...
1,200
Output $$$n$$$ lines. In the $$$i$$$-th line for the $$$i$$$-th pair of words $$$s$$$ and $$$t$$$ print YES if the word $$$t$$$ could be printed by typing the word $$$s$$$. Otherwise, print NO.
standard output
PASSED
2d66a7f43d7857be3a1307e3e6d29e2d
train_003.jsonl
1560955500
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exactly one symbol).For example, as a result of typing the word "hello", the followi...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); InputReader.OutputWriter out = new Inpu...
Java
["4\nhello\nhello\nhello\nhelloo\nhello\nhlllloo\nhello\nhelo", "5\naa\nbb\ncodeforces\ncodeforce\npolycarp\npoolycarpp\naaaa\naaaab\nabcdefghijklmnopqrstuvwxyz\nzabcdefghijklmnopqrstuvwxyz"]
3 seconds
["YES\nYES\nNO\nNO", "NO\nNO\nYES\nNO\nNO"]
null
Java 8
standard input
[ "implementation", "strings" ]
6709c8078cd29e69cf1be285071b2527
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) β€” the number of pairs to check. Further input contains $$$n$$$ descriptions of pairs. The first line of each description contains a single non-empty word $$$s$$$ consisting of lowercase Latin letters. The second line of the description co...
1,200
Output $$$n$$$ lines. In the $$$i$$$-th line for the $$$i$$$-th pair of words $$$s$$$ and $$$t$$$ print YES if the word $$$t$$$ could be printed by typing the word $$$s$$$. Otherwise, print NO.
standard output
PASSED
7b96dbba47413cf27a0f757f33ad1e6b
train_003.jsonl
1560955500
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exactly one symbol).For example, as a result of typing the word "hello", the followi...
256 megabytes
import java.io.*; import java.util.*; public class Main { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } Stri...
Java
["4\nhello\nhello\nhello\nhelloo\nhello\nhlllloo\nhello\nhelo", "5\naa\nbb\ncodeforces\ncodeforce\npolycarp\npoolycarpp\naaaa\naaaab\nabcdefghijklmnopqrstuvwxyz\nzabcdefghijklmnopqrstuvwxyz"]
3 seconds
["YES\nYES\nNO\nNO", "NO\nNO\nYES\nNO\nNO"]
null
Java 8
standard input
[ "implementation", "strings" ]
6709c8078cd29e69cf1be285071b2527
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) β€” the number of pairs to check. Further input contains $$$n$$$ descriptions of pairs. The first line of each description contains a single non-empty word $$$s$$$ consisting of lowercase Latin letters. The second line of the description co...
1,200
Output $$$n$$$ lines. In the $$$i$$$-th line for the $$$i$$$-th pair of words $$$s$$$ and $$$t$$$ print YES if the word $$$t$$$ could be printed by typing the word $$$s$$$. Otherwise, print NO.
standard output
PASSED
514122b59f22b398a2c2497b230183a1
train_003.jsonl
1560955500
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exactly one symbol).For example, as a result of typing the word "hello", the followi...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; import java.util.stream.Collectors; import java.util.regex.*; public class Program { private static PrintWriter out; private static <T> void mprintln(T ... ar){ for(T i: ar) out.print(i + " "); out.println(); } ...
Java
["4\nhello\nhello\nhello\nhelloo\nhello\nhlllloo\nhello\nhelo", "5\naa\nbb\ncodeforces\ncodeforce\npolycarp\npoolycarpp\naaaa\naaaab\nabcdefghijklmnopqrstuvwxyz\nzabcdefghijklmnopqrstuvwxyz"]
3 seconds
["YES\nYES\nNO\nNO", "NO\nNO\nYES\nNO\nNO"]
null
Java 8
standard input
[ "implementation", "strings" ]
6709c8078cd29e69cf1be285071b2527
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) β€” the number of pairs to check. Further input contains $$$n$$$ descriptions of pairs. The first line of each description contains a single non-empty word $$$s$$$ consisting of lowercase Latin letters. The second line of the description co...
1,200
Output $$$n$$$ lines. In the $$$i$$$-th line for the $$$i$$$-th pair of words $$$s$$$ and $$$t$$$ print YES if the word $$$t$$$ could be printed by typing the word $$$s$$$. Otherwise, print NO.
standard output
PASSED
e1c5576b83eae828b165b3829b905b0a
train_003.jsonl
1560955500
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exactly one symbol).For example, as a result of typing the word "hello", the followi...
256 megabytes
//package com.company; //import java.io.file.Paths; import java.util.*; public class Main { public static void main(String[] args) { // write your code here Scanner s=new Scanner(System.in); int n=s.nextInt(); while(n-->0){ char[] a=s.next().toCharArray(); char[] b=s.next().to...
Java
["4\nhello\nhello\nhello\nhelloo\nhello\nhlllloo\nhello\nhelo", "5\naa\nbb\ncodeforces\ncodeforce\npolycarp\npoolycarpp\naaaa\naaaab\nabcdefghijklmnopqrstuvwxyz\nzabcdefghijklmnopqrstuvwxyz"]
3 seconds
["YES\nYES\nNO\nNO", "NO\nNO\nYES\nNO\nNO"]
null
Java 8
standard input
[ "implementation", "strings" ]
6709c8078cd29e69cf1be285071b2527
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) β€” the number of pairs to check. Further input contains $$$n$$$ descriptions of pairs. The first line of each description contains a single non-empty word $$$s$$$ consisting of lowercase Latin letters. The second line of the description co...
1,200
Output $$$n$$$ lines. In the $$$i$$$-th line for the $$$i$$$-th pair of words $$$s$$$ and $$$t$$$ print YES if the word $$$t$$$ could be printed by typing the word $$$s$$$. Otherwise, print NO.
standard output
PASSED
cbdc0eab9c40c829c80fc1d07656b7be
train_003.jsonl
1560955500
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exactly one symbol).For example, as a result of typing the word "hello", the followi...
256 megabytes
import java.io.*; import java.util.*; public class R568B { public static void main(String[] args) { JS scan = new JS(); int t = scan.nextInt(); PrintWriter out = new PrintWriter(System.out); loop:while(t-->0){ String a = scan.next(); String b = scan.next(); if(b.length()<a.length()){ System.out.p...
Java
["4\nhello\nhello\nhello\nhelloo\nhello\nhlllloo\nhello\nhelo", "5\naa\nbb\ncodeforces\ncodeforce\npolycarp\npoolycarpp\naaaa\naaaab\nabcdefghijklmnopqrstuvwxyz\nzabcdefghijklmnopqrstuvwxyz"]
3 seconds
["YES\nYES\nNO\nNO", "NO\nNO\nYES\nNO\nNO"]
null
Java 8
standard input
[ "implementation", "strings" ]
6709c8078cd29e69cf1be285071b2527
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) β€” the number of pairs to check. Further input contains $$$n$$$ descriptions of pairs. The first line of each description contains a single non-empty word $$$s$$$ consisting of lowercase Latin letters. The second line of the description co...
1,200
Output $$$n$$$ lines. In the $$$i$$$-th line for the $$$i$$$-th pair of words $$$s$$$ and $$$t$$$ print YES if the word $$$t$$$ could be printed by typing the word $$$s$$$. Otherwise, print NO.
standard output
PASSED
bf91e439b1efbc49a72d8b25dd5673d7
train_003.jsonl
1560955500
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exactly one symbol).For example, as a result of typing the word "hello", the followi...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; public class B { public static void main(String[] args) throws IOException { Reader2.init(System.in); int Testcases=Reader2.nextInt(); while(Testcases!=0) {...
Java
["4\nhello\nhello\nhello\nhelloo\nhello\nhlllloo\nhello\nhelo", "5\naa\nbb\ncodeforces\ncodeforce\npolycarp\npoolycarpp\naaaa\naaaab\nabcdefghijklmnopqrstuvwxyz\nzabcdefghijklmnopqrstuvwxyz"]
3 seconds
["YES\nYES\nNO\nNO", "NO\nNO\nYES\nNO\nNO"]
null
Java 8
standard input
[ "implementation", "strings" ]
6709c8078cd29e69cf1be285071b2527
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) β€” the number of pairs to check. Further input contains $$$n$$$ descriptions of pairs. The first line of each description contains a single non-empty word $$$s$$$ consisting of lowercase Latin letters. The second line of the description co...
1,200
Output $$$n$$$ lines. In the $$$i$$$-th line for the $$$i$$$-th pair of words $$$s$$$ and $$$t$$$ print YES if the word $$$t$$$ could be printed by typing the word $$$s$$$. Otherwise, print NO.
standard output
PASSED
241ebd933ae6eea61070b99970bf83bd
train_003.jsonl
1560955500
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exactly one symbol).For example, as a result of typing the word "hello", the followi...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); int N = Integer.parseInt(reader.readLine()); ...
Java
["4\nhello\nhello\nhello\nhelloo\nhello\nhlllloo\nhello\nhelo", "5\naa\nbb\ncodeforces\ncodeforce\npolycarp\npoolycarpp\naaaa\naaaab\nabcdefghijklmnopqrstuvwxyz\nzabcdefghijklmnopqrstuvwxyz"]
3 seconds
["YES\nYES\nNO\nNO", "NO\nNO\nYES\nNO\nNO"]
null
Java 8
standard input
[ "implementation", "strings" ]
6709c8078cd29e69cf1be285071b2527
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) β€” the number of pairs to check. Further input contains $$$n$$$ descriptions of pairs. The first line of each description contains a single non-empty word $$$s$$$ consisting of lowercase Latin letters. The second line of the description co...
1,200
Output $$$n$$$ lines. In the $$$i$$$-th line for the $$$i$$$-th pair of words $$$s$$$ and $$$t$$$ print YES if the word $$$t$$$ could be printed by typing the word $$$s$$$. Otherwise, print NO.
standard output
PASSED
4a4270135d9adf830dc1994031291464
train_003.jsonl
1560955500
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exactly one symbol).For example, as a result of typing the word "hello", the followi...
256 megabytes
import java.util.*; public class q2568 { public static void main(String ... args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); String res[]=new String[n]; for(int i=0;i<n;i++) { String s1=sc.next(); String s2=sc.next(); if(s1==null && s2==null) { res[i]="YES"; continue; } ...
Java
["4\nhello\nhello\nhello\nhelloo\nhello\nhlllloo\nhello\nhelo", "5\naa\nbb\ncodeforces\ncodeforce\npolycarp\npoolycarpp\naaaa\naaaab\nabcdefghijklmnopqrstuvwxyz\nzabcdefghijklmnopqrstuvwxyz"]
3 seconds
["YES\nYES\nNO\nNO", "NO\nNO\nYES\nNO\nNO"]
null
Java 8
standard input
[ "implementation", "strings" ]
6709c8078cd29e69cf1be285071b2527
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) β€” the number of pairs to check. Further input contains $$$n$$$ descriptions of pairs. The first line of each description contains a single non-empty word $$$s$$$ consisting of lowercase Latin letters. The second line of the description co...
1,200
Output $$$n$$$ lines. In the $$$i$$$-th line for the $$$i$$$-th pair of words $$$s$$$ and $$$t$$$ print YES if the word $$$t$$$ could be printed by typing the word $$$s$$$. Otherwise, print NO.
standard output
PASSED
b595c16add7edd920b9335fc8e681a56
train_003.jsonl
1560955500
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exactly one symbol).For example, as a result of typing the word "hello", the followi...
256 megabytes
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; import java.util.*; import java.lang.StringBuilder; public class codech...
Java
["4\nhello\nhello\nhello\nhelloo\nhello\nhlllloo\nhello\nhelo", "5\naa\nbb\ncodeforces\ncodeforce\npolycarp\npoolycarpp\naaaa\naaaab\nabcdefghijklmnopqrstuvwxyz\nzabcdefghijklmnopqrstuvwxyz"]
3 seconds
["YES\nYES\nNO\nNO", "NO\nNO\nYES\nNO\nNO"]
null
Java 8
standard input
[ "implementation", "strings" ]
6709c8078cd29e69cf1be285071b2527
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) β€” the number of pairs to check. Further input contains $$$n$$$ descriptions of pairs. The first line of each description contains a single non-empty word $$$s$$$ consisting of lowercase Latin letters. The second line of the description co...
1,200
Output $$$n$$$ lines. In the $$$i$$$-th line for the $$$i$$$-th pair of words $$$s$$$ and $$$t$$$ print YES if the word $$$t$$$ could be printed by typing the word $$$s$$$. Otherwise, print NO.
standard output
PASSED
78f7ce3c638ac8cb05d5432976eedae2
train_003.jsonl
1560955500
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exactly one symbol).For example, as a result of typing the word "hello", the followi...
256 megabytes
// 21/8/20 10:40 AM Aug 2020 import java.util.*; public class _1185B { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t-- > 0) { String s1=sc.next(); String s2=sc.next(); boolean check=true; ...
Java
["4\nhello\nhello\nhello\nhelloo\nhello\nhlllloo\nhello\nhelo", "5\naa\nbb\ncodeforces\ncodeforce\npolycarp\npoolycarpp\naaaa\naaaab\nabcdefghijklmnopqrstuvwxyz\nzabcdefghijklmnopqrstuvwxyz"]
3 seconds
["YES\nYES\nNO\nNO", "NO\nNO\nYES\nNO\nNO"]
null
Java 8
standard input
[ "implementation", "strings" ]
6709c8078cd29e69cf1be285071b2527
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) β€” the number of pairs to check. Further input contains $$$n$$$ descriptions of pairs. The first line of each description contains a single non-empty word $$$s$$$ consisting of lowercase Latin letters. The second line of the description co...
1,200
Output $$$n$$$ lines. In the $$$i$$$-th line for the $$$i$$$-th pair of words $$$s$$$ and $$$t$$$ print YES if the word $$$t$$$ could be printed by typing the word $$$s$$$. Otherwise, print NO.
standard output
PASSED
8a7dcf4092c45d1b608b056a0b99603d
train_003.jsonl
1560955500
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exactly one symbol).For example, as a result of typing the word "hello", the followi...
256 megabytes
import java.util.Scanner; public class ProblemB { public static void main(String [] args) { Scanner scanner = new Scanner(System.in); int a = scanner.nextInt(); for(int i = 0; i < a; i++) { String s = scanner.next(); String z = scanner.next(); int k = 0; char cur = s.charAt(0); char la...
Java
["4\nhello\nhello\nhello\nhelloo\nhello\nhlllloo\nhello\nhelo", "5\naa\nbb\ncodeforces\ncodeforce\npolycarp\npoolycarpp\naaaa\naaaab\nabcdefghijklmnopqrstuvwxyz\nzabcdefghijklmnopqrstuvwxyz"]
3 seconds
["YES\nYES\nNO\nNO", "NO\nNO\nYES\nNO\nNO"]
null
Java 8
standard input
[ "implementation", "strings" ]
6709c8078cd29e69cf1be285071b2527
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) β€” the number of pairs to check. Further input contains $$$n$$$ descriptions of pairs. The first line of each description contains a single non-empty word $$$s$$$ consisting of lowercase Latin letters. The second line of the description co...
1,200
Output $$$n$$$ lines. In the $$$i$$$-th line for the $$$i$$$-th pair of words $$$s$$$ and $$$t$$$ print YES if the word $$$t$$$ could be printed by typing the word $$$s$$$. Otherwise, print NO.
standard output
PASSED
86d316995b8126c4cd63747c6bc7bc2d
train_003.jsonl
1560955500
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exactly one symbol).For example, as a result of typing the word "hello", the followi...
256 megabytes
import java.util.Scanner; public final class EmailFromPolycarp { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); for (int i = 0; i < n; ++i) { boolean works = true; String correct = in.next(); String incorrect = in.next(); int correctIndex = 0;...
Java
["4\nhello\nhello\nhello\nhelloo\nhello\nhlllloo\nhello\nhelo", "5\naa\nbb\ncodeforces\ncodeforce\npolycarp\npoolycarpp\naaaa\naaaab\nabcdefghijklmnopqrstuvwxyz\nzabcdefghijklmnopqrstuvwxyz"]
3 seconds
["YES\nYES\nNO\nNO", "NO\nNO\nYES\nNO\nNO"]
null
Java 8
standard input
[ "implementation", "strings" ]
6709c8078cd29e69cf1be285071b2527
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) β€” the number of pairs to check. Further input contains $$$n$$$ descriptions of pairs. The first line of each description contains a single non-empty word $$$s$$$ consisting of lowercase Latin letters. The second line of the description co...
1,200
Output $$$n$$$ lines. In the $$$i$$$-th line for the $$$i$$$-th pair of words $$$s$$$ and $$$t$$$ print YES if the word $$$t$$$ could be printed by typing the word $$$s$$$. Otherwise, print NO.
standard output
PASSED
10c6ec3825ef7f356c6913c853cb77fe
train_003.jsonl
1560955500
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exactly one symbol).For example, as a result of typing the word "hello", the followi...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.StringTokenizer; public class pre214 { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new Buffe...
Java
["4\nhello\nhello\nhello\nhelloo\nhello\nhlllloo\nhello\nhelo", "5\naa\nbb\ncodeforces\ncodeforce\npolycarp\npoolycarpp\naaaa\naaaab\nabcdefghijklmnopqrstuvwxyz\nzabcdefghijklmnopqrstuvwxyz"]
3 seconds
["YES\nYES\nNO\nNO", "NO\nNO\nYES\nNO\nNO"]
null
Java 8
standard input
[ "implementation", "strings" ]
6709c8078cd29e69cf1be285071b2527
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) β€” the number of pairs to check. Further input contains $$$n$$$ descriptions of pairs. The first line of each description contains a single non-empty word $$$s$$$ consisting of lowercase Latin letters. The second line of the description co...
1,200
Output $$$n$$$ lines. In the $$$i$$$-th line for the $$$i$$$-th pair of words $$$s$$$ and $$$t$$$ print YES if the word $$$t$$$ could be printed by typing the word $$$s$$$. Otherwise, print NO.
standard output
PASSED
4c41bd92acdc41d5bda557a3cc02b5bd
train_003.jsonl
1560955500
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exactly one symbol).For example, as a result of typing the word "hello", the followi...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
Java
["4\nhello\nhello\nhello\nhelloo\nhello\nhlllloo\nhello\nhelo", "5\naa\nbb\ncodeforces\ncodeforce\npolycarp\npoolycarpp\naaaa\naaaab\nabcdefghijklmnopqrstuvwxyz\nzabcdefghijklmnopqrstuvwxyz"]
3 seconds
["YES\nYES\nNO\nNO", "NO\nNO\nYES\nNO\nNO"]
null
Java 8
standard input
[ "implementation", "strings" ]
6709c8078cd29e69cf1be285071b2527
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) β€” the number of pairs to check. Further input contains $$$n$$$ descriptions of pairs. The first line of each description contains a single non-empty word $$$s$$$ consisting of lowercase Latin letters. The second line of the description co...
1,200
Output $$$n$$$ lines. In the $$$i$$$-th line for the $$$i$$$-th pair of words $$$s$$$ and $$$t$$$ print YES if the word $$$t$$$ could be printed by typing the word $$$s$$$. Otherwise, print NO.
standard output
PASSED
8e9dd39fb081a2097304cc4c844ff1d2
train_003.jsonl
1560955500
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exactly one symbol).For example, as a result of typing the word "hello", the followi...
256 megabytes
import java.util.*; import java.io.*; public class Exam { public static long mod = (long) Math.pow(10, 9)+7 ; public static InputReader sc = new InputReader(System.in); public static PrintWriter pw = new PrintWriter(System.out); public static int check2(int b4,int b3,int b2,int b1,String a[],String s,int x,int y...
Java
["4\nhello\nhello\nhello\nhelloo\nhello\nhlllloo\nhello\nhelo", "5\naa\nbb\ncodeforces\ncodeforce\npolycarp\npoolycarpp\naaaa\naaaab\nabcdefghijklmnopqrstuvwxyz\nzabcdefghijklmnopqrstuvwxyz"]
3 seconds
["YES\nYES\nNO\nNO", "NO\nNO\nYES\nNO\nNO"]
null
Java 8
standard input
[ "implementation", "strings" ]
6709c8078cd29e69cf1be285071b2527
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) β€” the number of pairs to check. Further input contains $$$n$$$ descriptions of pairs. The first line of each description contains a single non-empty word $$$s$$$ consisting of lowercase Latin letters. The second line of the description co...
1,200
Output $$$n$$$ lines. In the $$$i$$$-th line for the $$$i$$$-th pair of words $$$s$$$ and $$$t$$$ print YES if the word $$$t$$$ could be printed by typing the word $$$s$$$. Otherwise, print NO.
standard output
PASSED
1e98351bf0db011d93e3e99e0ea4c75a
train_003.jsonl
1560955500
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exactly one symbol).For example, as a result of typing the word "hello", the followi...
256 megabytes
import javax.swing.*; import java.io.*; import java.math.BigDecimal; import java.math.BigInteger; import java.util.*; import java.util.concurrent.LinkedBlockingQueue; public class Main { private static AWriter writer = new AWriter(System.out); private static AReader reader = new AReader(System.in); private...
Java
["4\nhello\nhello\nhello\nhelloo\nhello\nhlllloo\nhello\nhelo", "5\naa\nbb\ncodeforces\ncodeforce\npolycarp\npoolycarpp\naaaa\naaaab\nabcdefghijklmnopqrstuvwxyz\nzabcdefghijklmnopqrstuvwxyz"]
3 seconds
["YES\nYES\nNO\nNO", "NO\nNO\nYES\nNO\nNO"]
null
Java 8
standard input
[ "implementation", "strings" ]
6709c8078cd29e69cf1be285071b2527
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) β€” the number of pairs to check. Further input contains $$$n$$$ descriptions of pairs. The first line of each description contains a single non-empty word $$$s$$$ consisting of lowercase Latin letters. The second line of the description co...
1,200
Output $$$n$$$ lines. In the $$$i$$$-th line for the $$$i$$$-th pair of words $$$s$$$ and $$$t$$$ print YES if the word $$$t$$$ could be printed by typing the word $$$s$$$. Otherwise, print NO.
standard output
PASSED
99795d864d742bc0938573609c041a87
train_003.jsonl
1409061600
Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choose k cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards. Formally, for each Toastman's card i you should calculate how much Toastman's cards have the letter equal to letter on i...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Map; import java.util.StringTokenizer; import java.util.TreeMap; public class CF_462_B_APPLEMAN_AND_CARD_GAME { public static void main(String[] args) thr...
Java
["15 10\nDZFDFZDFDDDDDDF", "6 4\nYJSNPI"]
1 second
["82", "4"]
NoteIn the first test example Toastman can choose nine cards with letter D and one additional card with any letter. For each card with D he will get 9 coins and for the additional card he will get 1 coin.
Java 8
standard input
[ "greedy" ]
480defc596ee5bc800ea569fd76dc584
The first line contains two integers n and k (1 ≀ k ≀ n ≀ 105). The next line contains n uppercase letters without spaces β€” the i-th letter describes the i-th card of the Appleman.
1,300
Print a single integer – the answer to the problem.
standard output
PASSED
ef550d61e5c5b4e1cf67ce0389984947
train_003.jsonl
1409061600
Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choose k cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards. Formally, for each Toastman's card i you should calculate how much Toastman's cards have the letter equal to letter on i...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class B462 { public static void main(String args[]){ Scanner in = new Scanner(System.in); int n=in.nextInt(); long k= in.nextInt(); String s=in.next(); long a[]=new long[30]; for(int i=0;i<n;i++){ a[s.charAt(i)-'A']++; } Arrays.sort(a); ...
Java
["15 10\nDZFDFZDFDDDDDDF", "6 4\nYJSNPI"]
1 second
["82", "4"]
NoteIn the first test example Toastman can choose nine cards with letter D and one additional card with any letter. For each card with D he will get 9 coins and for the additional card he will get 1 coin.
Java 8
standard input
[ "greedy" ]
480defc596ee5bc800ea569fd76dc584
The first line contains two integers n and k (1 ≀ k ≀ n ≀ 105). The next line contains n uppercase letters without spaces β€” the i-th letter describes the i-th card of the Appleman.
1,300
Print a single integer – the answer to the problem.
standard output
PASSED
0cd45b6c5213da55484e5c7ac093f98d
train_003.jsonl
1409061600
Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choose k cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards. Formally, for each Toastman's card i you should calculate how much Toastman's cards have the letter equal to letter on i...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class mmm { static class InputReader { public BufferedReader br; public StringTokenizer token; public InputReader(InputStream stream) { br=new BufferedReader(new InputStreamReader(stream),32768); ...
Java
["15 10\nDZFDFZDFDDDDDDF", "6 4\nYJSNPI"]
1 second
["82", "4"]
NoteIn the first test example Toastman can choose nine cards with letter D and one additional card with any letter. For each card with D he will get 9 coins and for the additional card he will get 1 coin.
Java 8
standard input
[ "greedy" ]
480defc596ee5bc800ea569fd76dc584
The first line contains two integers n and k (1 ≀ k ≀ n ≀ 105). The next line contains n uppercase letters without spaces β€” the i-th letter describes the i-th card of the Appleman.
1,300
Print a single integer – the answer to the problem.
standard output
PASSED
c358339dbac036c3745d25d3a809430d
train_003.jsonl
1409061600
Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choose k cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards. Formally, for each Toastman's card i you should calculate how much Toastman's cards have the letter equal to letter on i...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.PriorityQueue; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.io.BufferedReader; import java.util.Comparator; import java.io.Inpu...
Java
["15 10\nDZFDFZDFDDDDDDF", "6 4\nYJSNPI"]
1 second
["82", "4"]
NoteIn the first test example Toastman can choose nine cards with letter D and one additional card with any letter. For each card with D he will get 9 coins and for the additional card he will get 1 coin.
Java 8
standard input
[ "greedy" ]
480defc596ee5bc800ea569fd76dc584
The first line contains two integers n and k (1 ≀ k ≀ n ≀ 105). The next line contains n uppercase letters without spaces β€” the i-th letter describes the i-th card of the Appleman.
1,300
Print a single integer – the answer to the problem.
standard output
PASSED
d3ed4e8e8fbcde8dbfa4a8e61e5f70b7
train_003.jsonl
1409061600
Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choose k cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards. Formally, for each Toastman's card i you should calculate how much Toastman's cards have the letter equal to letter on i...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.PriorityQueue; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.io.BufferedReader; import java.util.Comparator; import java.io.Inpu...
Java
["15 10\nDZFDFZDFDDDDDDF", "6 4\nYJSNPI"]
1 second
["82", "4"]
NoteIn the first test example Toastman can choose nine cards with letter D and one additional card with any letter. For each card with D he will get 9 coins and for the additional card he will get 1 coin.
Java 8
standard input
[ "greedy" ]
480defc596ee5bc800ea569fd76dc584
The first line contains two integers n and k (1 ≀ k ≀ n ≀ 105). The next line contains n uppercase letters without spaces β€” the i-th letter describes the i-th card of the Appleman.
1,300
Print a single integer – the answer to the problem.
standard output
PASSED
9a3e7d96aaaaea6bd4d5bcb58642c113
train_003.jsonl
1409061600
Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choose k cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards. Formally, for each Toastman's card i you should calculate how much Toastman's cards have the letter equal to letter on i...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class Code462B { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ...
Java
["15 10\nDZFDFZDFDDDDDDF", "6 4\nYJSNPI"]
1 second
["82", "4"]
NoteIn the first test example Toastman can choose nine cards with letter D and one additional card with any letter. For each card with D he will get 9 coins and for the additional card he will get 1 coin.
Java 8
standard input
[ "greedy" ]
480defc596ee5bc800ea569fd76dc584
The first line contains two integers n and k (1 ≀ k ≀ n ≀ 105). The next line contains n uppercase letters without spaces β€” the i-th letter describes the i-th card of the Appleman.
1,300
Print a single integer – the answer to the problem.
standard output
PASSED
ec625e578da493ac5daa42dc61b54f3d
train_003.jsonl
1409061600
Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choose k cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards. Formally, for each Toastman's card i you should calculate how much Toastman's cards have the letter equal to letter on i...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class B462 { public static void main(String args[]){ Scanner in = new Scanner(System.in); int n=in.nextInt(); long k= in.nextInt(); String s=in.next(); long a[]=new long[30]; for(int i=0;i<n;i++){ a[s.charAt(i)-'A']++; } Arrays.sort(a); ...
Java
["15 10\nDZFDFZDFDDDDDDF", "6 4\nYJSNPI"]
1 second
["82", "4"]
NoteIn the first test example Toastman can choose nine cards with letter D and one additional card with any letter. For each card with D he will get 9 coins and for the additional card he will get 1 coin.
Java 8
standard input
[ "greedy" ]
480defc596ee5bc800ea569fd76dc584
The first line contains two integers n and k (1 ≀ k ≀ n ≀ 105). The next line contains n uppercase letters without spaces β€” the i-th letter describes the i-th card of the Appleman.
1,300
Print a single integer – the answer to the problem.
standard output
PASSED
d2f981517edb3f59cdbf04cbd1610f68
train_003.jsonl
1409061600
Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choose k cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards. Formally, for each Toastman's card i you should calculate how much Toastman's cards have the letter equal to letter on i...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; import java.util.ArrayList; import java.util.Scanner; public class main { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new ...
Java
["15 10\nDZFDFZDFDDDDDDF", "6 4\nYJSNPI"]
1 second
["82", "4"]
NoteIn the first test example Toastman can choose nine cards with letter D and one additional card with any letter. For each card with D he will get 9 coins and for the additional card he will get 1 coin.
Java 8
standard input
[ "greedy" ]
480defc596ee5bc800ea569fd76dc584
The first line contains two integers n and k (1 ≀ k ≀ n ≀ 105). The next line contains n uppercase letters without spaces β€” the i-th letter describes the i-th card of the Appleman.
1,300
Print a single integer – the answer to the problem.
standard output
PASSED
8caf4ab6fc5be4052d8b2bdf2c75eb4b
train_003.jsonl
1409061600
Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choose k cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards. Formally, for each Toastman's card i you should calculate how much Toastman's cards have the letter equal to letter on i...
256 megabytes
import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.Scanner; public class CF462B { public static void main(String[] args) { // TODO Auto-generated method stub Scanner in = new Scanner(System.in); String [] na = in.nextLine().split(" "); int n = Integer.parseInt(...
Java
["15 10\nDZFDFZDFDDDDDDF", "6 4\nYJSNPI"]
1 second
["82", "4"]
NoteIn the first test example Toastman can choose nine cards with letter D and one additional card with any letter. For each card with D he will get 9 coins and for the additional card he will get 1 coin.
Java 8
standard input
[ "greedy" ]
480defc596ee5bc800ea569fd76dc584
The first line contains two integers n and k (1 ≀ k ≀ n ≀ 105). The next line contains n uppercase letters without spaces β€” the i-th letter describes the i-th card of the Appleman.
1,300
Print a single integer – the answer to the problem.
standard output
PASSED
ef547fc2db291038acc03b6030848b4a
train_003.jsonl
1409061600
Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choose k cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards. Formally, for each Toastman's card i you should calculate how much Toastman's cards have the letter equal to letter on i...
256 megabytes
import java.util.Arrays; import java.util.Comparator; import java.util.Map; import java.util.Map.Entry; import java.util.Scanner; import java.util.TreeMap; public class Tree { static int[] dx = {-1, 1, 0, 0}; static int[] dy = {0, 0, 1, -1}; public static void main(String[] args) { Scanner in = new Scanne...
Java
["15 10\nDZFDFZDFDDDDDDF", "6 4\nYJSNPI"]
1 second
["82", "4"]
NoteIn the first test example Toastman can choose nine cards with letter D and one additional card with any letter. For each card with D he will get 9 coins and for the additional card he will get 1 coin.
Java 8
standard input
[ "greedy" ]
480defc596ee5bc800ea569fd76dc584
The first line contains two integers n and k (1 ≀ k ≀ n ≀ 105). The next line contains n uppercase letters without spaces β€” the i-th letter describes the i-th card of the Appleman.
1,300
Print a single integer – the answer to the problem.
standard output
PASSED
1ac49ed945e4809ed6a7b006e27f37e2
train_003.jsonl
1409061600
Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choose k cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards. Formally, for each Toastman's card i you should calculate how much Toastman's cards have the letter equal to letter on i...
256 megabytes
import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Scanner; public class Cards { public static void main(String[] args){ Scanner scanner = new Scanner(System.in); String[] nInput = scanner.n...
Java
["15 10\nDZFDFZDFDDDDDDF", "6 4\nYJSNPI"]
1 second
["82", "4"]
NoteIn the first test example Toastman can choose nine cards with letter D and one additional card with any letter. For each card with D he will get 9 coins and for the additional card he will get 1 coin.
Java 8
standard input
[ "greedy" ]
480defc596ee5bc800ea569fd76dc584
The first line contains two integers n and k (1 ≀ k ≀ n ≀ 105). The next line contains n uppercase letters without spaces β€” the i-th letter describes the i-th card of the Appleman.
1,300
Print a single integer – the answer to the problem.
standard output
PASSED
dbee6c5efffa88e479d4744a1321e669
train_003.jsonl
1409061600
Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choose k cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards. Formally, for each Toastman's card i you should calculate how much Toastman's cards have the letter equal to letter on i...
256 megabytes
import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Scanner; public class Cards { public static void main(String[] args){ Scanner scanner = new Scanner(System.in); String[] nInput = scanner.n...
Java
["15 10\nDZFDFZDFDDDDDDF", "6 4\nYJSNPI"]
1 second
["82", "4"]
NoteIn the first test example Toastman can choose nine cards with letter D and one additional card with any letter. For each card with D he will get 9 coins and for the additional card he will get 1 coin.
Java 8
standard input
[ "greedy" ]
480defc596ee5bc800ea569fd76dc584
The first line contains two integers n and k (1 ≀ k ≀ n ≀ 105). The next line contains n uppercase letters without spaces β€” the i-th letter describes the i-th card of the Appleman.
1,300
Print a single integer – the answer to the problem.
standard output
PASSED
c2130d1a50bab2d38f3a0bf76f9a994e
train_003.jsonl
1409061600
Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choose k cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards. Formally, for each Toastman's card i you should calculate how much Toastman's cards have the letter equal to letter on i...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner input = new Scanner(System.in); long n = input.nextInt(); long k = input.nextInt(); String s =input.next(); long res=0; char arr[]=s.toCharArray(); long freq[] = new long[(i...
Java
["15 10\nDZFDFZDFDDDDDDF", "6 4\nYJSNPI"]
1 second
["82", "4"]
NoteIn the first test example Toastman can choose nine cards with letter D and one additional card with any letter. For each card with D he will get 9 coins and for the additional card he will get 1 coin.
Java 8
standard input
[ "greedy" ]
480defc596ee5bc800ea569fd76dc584
The first line contains two integers n and k (1 ≀ k ≀ n ≀ 105). The next line contains n uppercase letters without spaces β€” the i-th letter describes the i-th card of the Appleman.
1,300
Print a single integer – the answer to the problem.
standard output
PASSED
07b7453796a988acdd1314f589cbcac3
train_003.jsonl
1409061600
Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choose k cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards. Formally, for each Toastman's card i you should calculate how much Toastman's cards have the letter equal to letter on i...
256 megabytes
import java.util.Scanner; import java.util.Collections; import java.util.Arrays; public class C462B { public static void main(String[] args) { Scanner in = new Scanner(System.in); long n, k; n = in.nextLong(); k = in.nextLong(); String str; str = in.next(); lo...
Java
["15 10\nDZFDFZDFDDDDDDF", "6 4\nYJSNPI"]
1 second
["82", "4"]
NoteIn the first test example Toastman can choose nine cards with letter D and one additional card with any letter. For each card with D he will get 9 coins and for the additional card he will get 1 coin.
Java 8
standard input
[ "greedy" ]
480defc596ee5bc800ea569fd76dc584
The first line contains two integers n and k (1 ≀ k ≀ n ≀ 105). The next line contains n uppercase letters without spaces β€” the i-th letter describes the i-th card of the Appleman.
1,300
Print a single integer – the answer to the problem.
standard output
PASSED
a4ad94d7aea7f1a9f0e3284e9e87c693
train_003.jsonl
1409061600
Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choose k cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards. Formally, for each Toastman's card i you should calculate how much Toastman's cards have the letter equal to letter on i...
256 megabytes
import java.util.Scanner; import java.util.Collections; import java.util.Arrays; public class C462B { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n, k; n = in.nextInt(); k = in.nextInt(); String str; str = in.next(); long ...
Java
["15 10\nDZFDFZDFDDDDDDF", "6 4\nYJSNPI"]
1 second
["82", "4"]
NoteIn the first test example Toastman can choose nine cards with letter D and one additional card with any letter. For each card with D he will get 9 coins and for the additional card he will get 1 coin.
Java 8
standard input
[ "greedy" ]
480defc596ee5bc800ea569fd76dc584
The first line contains two integers n and k (1 ≀ k ≀ n ≀ 105). The next line contains n uppercase letters without spaces β€” the i-th letter describes the i-th card of the Appleman.
1,300
Print a single integer – the answer to the problem.
standard output
PASSED
5aa4591e9810766ae963cb58d728e72f
train_003.jsonl
1409061600
Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choose k cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards. Formally, for each Toastman's card i you should calculate how much Toastman's cards have the letter equal to letter on i...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; import java.util.*; /** * Created by spss on 1/11/16. */ public class Problem462B { public static class MyScanner{ static BufferedReader br; static StringTokenizer st; ...
Java
["15 10\nDZFDFZDFDDDDDDF", "6 4\nYJSNPI"]
1 second
["82", "4"]
NoteIn the first test example Toastman can choose nine cards with letter D and one additional card with any letter. For each card with D he will get 9 coins and for the additional card he will get 1 coin.
Java 8
standard input
[ "greedy" ]
480defc596ee5bc800ea569fd76dc584
The first line contains two integers n and k (1 ≀ k ≀ n ≀ 105). The next line contains n uppercase letters without spaces β€” the i-th letter describes the i-th card of the Appleman.
1,300
Print a single integer – the answer to the problem.
standard output
PASSED
abd7572a9eaa350428726ac5de8b2e5c
train_003.jsonl
1409061600
Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choose k cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards. Formally, for each Toastman's card i you should calculate how much Toastman's cards have the letter equal to letter on i...
256 megabytes
import java.util.Scanner; public class B462 { static Scanner sc = new Scanner(System.in); static int n, k, ind; static long ans, cur; static String s; static int[] a; public static void main(String[] args) { n = sc.nextInt(); k = sc.nextInt(); s = sc.next(); a = new int[26]; for (int i = 0; i < s.le...
Java
["15 10\nDZFDFZDFDDDDDDF", "6 4\nYJSNPI"]
1 second
["82", "4"]
NoteIn the first test example Toastman can choose nine cards with letter D and one additional card with any letter. For each card with D he will get 9 coins and for the additional card he will get 1 coin.
Java 8
standard input
[ "greedy" ]
480defc596ee5bc800ea569fd76dc584
The first line contains two integers n and k (1 ≀ k ≀ n ≀ 105). The next line contains n uppercase letters without spaces β€” the i-th letter describes the i-th card of the Appleman.
1,300
Print a single integer – the answer to the problem.
standard output
PASSED
aaec09a0ce70ec1faf36a43fcbc44277
train_003.jsonl
1409061600
Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choose k cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards. Formally, for each Toastman's card i you should calculate how much Toastman's cards have the letter equal to letter on i...
256 megabytes
import java.util.*; public class codfo { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(), k = s.nextInt(); String st = s.next(); int count[] = new int[26]; for (int i = 0; i < st.length(); i++) { int index = st.c...
Java
["15 10\nDZFDFZDFDDDDDDF", "6 4\nYJSNPI"]
1 second
["82", "4"]
NoteIn the first test example Toastman can choose nine cards with letter D and one additional card with any letter. For each card with D he will get 9 coins and for the additional card he will get 1 coin.
Java 8
standard input
[ "greedy" ]
480defc596ee5bc800ea569fd76dc584
The first line contains two integers n and k (1 ≀ k ≀ n ≀ 105). The next line contains n uppercase letters without spaces β€” the i-th letter describes the i-th card of the Appleman.
1,300
Print a single integer – the answer to the problem.
standard output