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
e910918169d3e8b8c7f7fad0a9d82266
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
import java.util.*; import java.io.*; import java.lang.*; public class Main { //-----------PrintWriter for faster output--------------------------------- public static PrintWriter out; public static int cnt; //-----------MyScanner class for faster input---------- public static class MySca...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 < a_2 < \dots < a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
1666a902e1b55803952ff801e78818c5
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner obj=new Scanner(System.in); int len=obj.nextInt(); while(len--!=0) { int n=obj.nextInt(); int k=obj.nextInt()+1; long ans=0; int[] a=n...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 < a_2 < \dots < a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
44a851a1769bd68b7ffc0e8ce5be063a
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class C { public static void main(String[] args) throws IOException { BufferedReader bf=new BufferedReader(new InputStreamReader(System.in)); int t=Integer.parseInt(bf.readLine()); wh...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 < a_2 < \dots < a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
b5d930105ed0fd6d5d9020a810a6fea1
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
import java.io.*; import java.util.*; public class Q1606C { static int mod = (int) (1e9 + 7); static void solve() { int n = i(); long k = l() + 1; long ans = 0; int[] arr = new int[n]; for (int i = 0; i < n; i++) { arr[i] = i(); } ...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 &lt; a_2 &lt; \dots &lt; a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
e211410e0790aefa36765f674a284296
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; import java.util.Arrays; import java.util.HashMap; import java.util.TreeSet; // public class Solution{ class Solution{ public static void main(String[] args){ FS sc = ne...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 &lt; a_2 &lt; \dots &lt; a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
0ccedc0cd3089eef3bd111ea726facc6
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
//package com.company; import java.util.*; import java.lang.*; import java.io.*; public class Rough_Work { public static void main(String[] args) throws IOException { new Rough_Work().TestCases(); } void TestCases() throws IOException{ sieveOfEratosthenes(1000000); int ...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 &lt; a_2 &lt; \dots &lt; a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
df8777409573e4d94062b58aa0d8504a
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
// import static java.lang.System.out; import static java.lang.Math.*; import static java.lang.System.*; import java.lang.reflect.Array; import java.util.*; import java.io.*; import java.math.*; public class Main { static FastReader sc; static long mod = ((long) 1e9) + 7; static long lmax=Lo...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 &lt; a_2 &lt; \dots &lt; a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
7ed52cec535f0a532be8758eef7d0cb7
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
import java.io.*; import java.util.*; public class Solution{ public static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader( new InputStreamReader(System.in)); } ...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 &lt; a_2 &lt; \dots &lt; a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
067bbf874f097637ab52405143745fa8
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
import java.io.*; import java.util.*; public class Main { private boolean oj = System.getProperty("ONLINE_JUDGE") != null; private FastWriter wr; private Reader rd; public final int MOD = 1000000007; /************************************************** FAST INPUT IMPLEMENTATION ***********...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 &lt; a_2 &lt; \dots &lt; a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
1a00dc2be8234dcff27c8ad4c13bea60
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
import java.io.BufferedReader; import java.io.*; import java.io.InputStreamReader; import java.util.Scanner; import java.util.*; public class Yoo { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new Buffe...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 &lt; a_2 &lt; \dots &lt; a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
9b184d197748ad0790cec29cf158eb35
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
//package codeforces; import java.util.*; public class BankNotes { public static void main(String [] args) { Scanner in =new Scanner (System.in); int t=in.nextInt(); while(t>0) { int n=in.nextInt(); long k=in.nextLong(); long ar[]= new long [n]; long min[]= new long [n]; for(int i=...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 &lt; a_2 &lt; \dots &lt; a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
98e88fb0e1011a6d8b9b174c7d782e5e
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.lang.Exception; public class Main{ static class FastReader{ BufferedReader br; StringTokenizer st; public FastReader(){ br=new Bu...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 &lt; a_2 &lt; \dots &lt; a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
9a7950e19795c68905e285770e325c0e
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
/* *** author: cypher70 */ import java.io.*; import java.util.*; import javax.management.Query; import javax.sound.sampled.SourceDataLine; public class sol { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new Buff...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 &lt; a_2 &lt; \dots &lt; a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
5bc2292713f4b663a65ee145ea938721
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
import java.io.*; import java.lang.Math; import java.lang.reflect.Array; import java.util.*; import javax.swing.text.DefaultStyledDocument.ElementSpec; public final class Solution { static BufferedReader br = new BufferedReader( new InputStreamReader(System.in) ); static BufferedWriter bw = new B...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 &lt; a_2 &lt; \dots &lt; a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
915d5f7edc65ed2b5f59a8bfac2d78fe
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
import java.util.*; import java.io.*; public class Practice { static boolean multipleTC = true; final static int mod2 = 1000000007; final static int mod = 998244353; final double E = 2.7182818284590452354; final double PI = 3.14159265358979323846; int MAX = 200001; void pre() throws Exception { } // All t...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 &lt; a_2 &lt; \dots &lt; a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
b12f201807272b85e76c2def1ce39e9a
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
import java.io.*; import java.util.*; public class Codeforces { static long M = 1000000007; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int cases = Integer.parseInt(br.readLine()); o:while(cases-- > 0) { Strin...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 &lt; a_2 &lt; \dots &lt; a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
1bed3d88c5d6f49305be71662927fffa
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
import java.io.*; import java.util.*; public class Main { static class JoinSet { int[] fa; JoinSet(int n) { fa = new int[n]; for (int i = 0; i < n; i++) fa[i] = i; } int find(int t) { if (t != fa[t]) fa[t] = find(fa[t]); retu...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 &lt; a_2 &lt; \dots &lt; a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
2f74ada9e177936134d64a317b82127f
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class a { static FastReader sc = new FastReader(); static PrintWriter out = new PrintWriter(System.out); static HashMap<Long,Integer> map; public static void main (String[] args) throws java.lang.Exception { int ...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 &lt; a_2 &lt; \dots &lt; a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
099b710a3ab5728154952df0e19b1433
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
import java.util.Scanner; import java.util.stream.IntStream; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for (int tc = 0; tc < t; ++tc) { int n = sc.nextInt(); int k = sc.nextInt(); int[] a = new int[n]; ...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 &lt; a_2 &lt; \dots &lt; a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
e17b9fb74601a235a74d08cf0fb11115
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class cses{ public static void main(String[] args) { int t = io.nextInt(); BigInteger[] answers = new BigInteger[t]; for (int i = 0; i < t; i++) { int n = io.nextInt(); int k = io.nex...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 &lt; a_2 &lt; \dots &lt; a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
b7ac4f2357bdca69b2c49aecdbedcf85
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
// Working program with FastReader import java.util.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.lang.*; public class C_Banknotes { static class FastReader { BufferedReader br; StringTokenizer st; ...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 &lt; a_2 &lt; \dots &lt; a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
77b5123f0916e9663d3ba078b376ccf4
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class firstpunch { public static void main(String[] args) { Scanner in=new Scanner(System.in);int t=in.nextInt(); while(t--!=0){ int n=in.nextInt();int k= in.nextInt(); int [] a=new int[n]; for(i...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 &lt; a_2 &lt; \dots &lt; a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
b2f2f03081398ad1f99a9f1caafb9c57
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
import java.io.*; import java.util.StringTokenizer; public class c1606C { private SimpleInputReader in; private SimpleOutputWriter out; public c1606C(Reader r, Writer w) { in = new SimpleInputReader(r); out = new SimpleOutputWriter(w); } public c1606C() { in...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 &lt; a_2 &lt; \dots &lt; a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
74e9a033d09caa6fccabe47781474b4a
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
import java.io.*; import java.util.*; public class C_Banknotes { static final int INT_MOD = (int) 1e9 + 7; static final long LONG_MOD = (long) 1e9 + 7; static final int INT_POSITIVE_INFINITY = Integer.MAX_VALUE; static final long LONG_POSITIVE_INFINITY = Long.MAX_VALUE; static final int INT_NEGATI...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 &lt; a_2 &lt; \dots &lt; a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
c1b6789779a24cf9553a56a7c1f4e86a
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
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 br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); ...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 &lt; a_2 &lt; \dots &lt; a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
3986d9934ed8e0e79abacdc7deabf435
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; import java.math.BigInteger; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 &lt; a_2 &lt; \dots &lt; a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
b82421652925820a10654800c985a66f
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
import java.util.*; import java.io.*; public class Main{ static final Random random=new Random(); static long mod=1000000007L; static HashMap<String,Integer>map=new HashMap<>(); static class FastReader{ BufferedReader br; StringTokenizer st; public FastReader(){ ...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 &lt; a_2 &lt; \dots &lt; a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
25a15a48c9fecc14c52a7ec9e95137e0
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
import java.io.*; import java.util.*; public class ComdeFormces { public static void main(String[] args) throws Exception{ // TODO Auto-generated method stub FastReader sc=new FastReader(); BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out)); int t=sc.nextInt(); ...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 &lt; a_2 &lt; \dots &lt; a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
d7e263a680d465144e4b8c37eb0a4fc2
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
import java.io.*; import java.util.*; public class Run { public static int mod = 1000000007; public static PrintWriter out = new PrintWriter(System.out); public static boolean testing = false; public static FastIO io; public static String input_file = "./input.txt"; static { ...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 &lt; a_2 &lt; \dots &lt; a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
f00c82bfe973d29ad418e4fa7ca9d94b
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
import java.util.*; import java.io.*; import java.time.*; import static java.lang.Math.*; @SuppressWarnings("unused") public class A { static boolean DEBUG = false; static Reader fs; static PrintWriter pw; static void solve() { int n = fs.nextInt(), k = fs.nextInt(); int a[] = fs.readArray(n); ...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 &lt; a_2 &lt; \dots &lt; a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
00afba17d6081eef8e7e827db3dd4dfe
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
import java.io.*; import java.util.*; /** * Provide prove of correctness before implementation. Implementation can cost a lot of time. * Anti test that prove that it's wrong. * <p> * Do not confuse i j k g indexes, upTo and length. Do extra methods!!! Write more informative names to simulation * <p> * Will progr...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 &lt; a_2 &lt; \dots &lt; a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
9af27ab3378af65fbe7bf7f3ad399469
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class firstpunch { public static void main(String[] args) { Scanner in=new Scanner(System.in);int t=in.nextInt(); while(t--!=0){ int n=in.nextInt();int k= in.nextInt(); int [] a=new int[n]; for(...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 &lt; a_2 &lt; \dots &lt; a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
fa9084fa88fb5db94bdaaa6b17184c01
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class firstpunch { public static void main(String[] args) { Scanner in=new Scanner(System.in);int t=in.nextInt(); while(t--!=0){ int n=in.nextInt();int k= in.nextInt(); int [] a=new int[n]; for(...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 &lt; a_2 &lt; \dots &lt; a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
f07b41208ce08a248dae8eb7e8ecb955
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
import java.io.*; import java.util.*; public class C { public static void main (String[] args) throws IOException { Kattio io = new Kattio(); int t = io.nextInt(); for (int ii=0; ii<t; ii++) { int n = io.nextInt(); long k = io.nextLong()+1; long ans = 0; boolean[] has = new boolean[30]; Arrays.fi...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 &lt; a_2 &lt; \dots &lt; a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
8649371c06039ab40c5b1793b020647e
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
import java.util.*; import java.io.*; public class Solution { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); BufferedWriter output = new Buffere...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 &lt; a_2 &lt; \dots &lt; a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
c222939d700d54a2497d3c0d461cfd0d
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
import java.io.*; import java.util.*; import javax.sound.midi.SysexMessage; import java.math.*; public class Main { // class Reader // { // final private int BUFFER_SIZE = 1 << 100000000; // private DataInputStream din; // private byte[] buffer; // private in...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 &lt; a_2 &lt; \dots &lt; a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
e839a58712deccfa67744a86304ea84a
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
import java.util.*; import java.io.*; public class Test { public static void main(String[] args) throws Exception { Scanner s = new Scanner(System.in); int t = s.nextInt(); for (int i = 0; i < t; i++) { ArrayList<Integer> options = new ArrayList<Integ...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 11
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 &lt; a_2 &lt; \dots &lt; a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
0349357c36b766a43da95df319d7a831
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.math.BigInteger; import java.util.*; public class main { public static void main(String[] args) throws Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); StringBuilder str = new Strin...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 17
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 &lt; a_2 &lt; \dots &lt; a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
5fd63f23e841b77b42d49e6c425b0f0a
train_108.jsonl
1635518100
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$.Let's denote $$$f(s)$$$ as the minimum number of banknotes required to represe...
256 megabytes
import java.util.*; import java.util.function.*; import java.io.*; // you can compare with output.txt and expected out public class RoundEdu116C { MyPrintWriter out; MyScanner in; // final static long FIXED_RANDOM; // static { // FIXED_RANDOM = System.currentTimeMillis(); // } final static String I...
Java
["4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9"]
2 seconds
["59\n778\n148999\n999999920999999999"]
null
Java 17
standard input
[ "greedy", "number theory" ]
e25e44b8f300d6be856df50bff8ff244
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10; 1 \le k \le 10^9$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 = a_1 &lt; a_2 &lt; \dots &lt; a...
1,400
For each test case, print one integer — the minimum positive number of burles $$$s$$$ that cannot be represented with $$$k$$$ or fewer banknotes.
standard output
PASSED
1c7cf861c1d191af8dea8324d4745754
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
// package com.company.Codeforces; import java.util.*; import java.lang.*; import java.io.*; public class scratch { public static void solve(){ String s = sc.next(); str.append(s.charAt(s.length()-1) + s.substring(1)); } static PrintWriter out; static StringBuilder str; static Sc...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 17
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
4e1678eb28bd052e175122aea1a1b47e
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.Scanner; import java.util.ArrayList; import java.util.Collections; import java.util.Arrays; import java.util.HashMap; public class Solution { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t!=0)...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 17
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
9e94832c713b06b20da42b3865536af6
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Question { public static String fun(String value){ if(value.length() <=1){ return value; } if(value.charAt(0) == value.charAt(value.length()-1)){ ...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 17
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
b7d6e60034fdb3d0ee531ee21aa425ed
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.*; public class P3 { public static void main (String[] args) throws java.lang.Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); sc.nextLine(); while(n>0) { String s = sc.nextLine(); int c1 = 0; int c2 = 0; char c []= s.toCharArray(); ...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 17
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
708efef6c5baa21c9c2d7ec2e73ae0d3
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.*; import java.util.function.*; import java.io.*; // you can compare with output.txt and expected out public class RoundEdu116A { MyPrintWriter out; MyScanner in; // final static long FIXED_RANDOM; // static { // FIXED_RANDOM = System.currentTimeMillis(); // } final static String I...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 17
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
38abd115183b39e4d698144e08e2dbe9
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.*; public class another { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int tc = sc.nextInt(); while(tc-- > 0){ String s = sc.next(); char[] arr= s.toCharArray(); int n = arr.length; i...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 17
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
a64ff094197527626fbf06c1c1a995a4
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.*; public class Main{ static Scanner s = new Scanner(System.in); public static void main(String[] args) { int t = s.nextInt(); while(t-->0){ String str= s.next(); StringBuffer sb = new StringBuffer(str); int count1 = 0; i...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 17
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
6e05efee2ba940717454cf80cd68c6ca
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.IOException; import java.io.InputStreamReader; import java.io.BufferedReader; import java.util.*; import java.math.*; import java.io.*; import java.text.*; import java.math.BigInteger; public class Main { public static void main(String[] args) throws IOException { Scanner sc...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
9baff1ff1172aef95bfdab894fd87c0b
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.IOException; import java.io.InputStreamReader; import java.io.BufferedReader; import java.util.*; import java.math.*; import java.io.*; import java.text.*; import java.math.BigInteger; public class Main { public static void main(String[] args) throws IOException { Scanner s=new Scanner...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
0ed9b0e0a1b0ecbe54283fe9514a56f8
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
/* ID: abdelra29 LANG: JAVA PROG: zerosum */ /* TO LEARN 2-euler tour */ /* TO SOLVE codeforces 722 kavi on pairing duty */ /* bit manipulation shit 1-Computer Systems: A Programmer's Perspective 2-hacke...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
97e0ca00b24d13e312f430fc8c8d4330
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Main { // -- static variables --- // static FastReader sc = new FastReader(); static PrintWriter out = new PrintWriter(System.out); static int mod = (int) 1000000007; public static void main(St...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
f4a3c4a307a4bf258df07c2e8983135f
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Main { // -- static variables --- // static FastReader sc = new FastReader(); static PrintWriter out = new PrintWriter(System.out); static int mod = (int) 1000000007; public static void main(St...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
18971804077612db29d413f33d539bb1
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.Scanner; public class ABBalance { private static final String ab = "ab"; private static final String ba = "ba"; private static final char a = 'a'; private static final char b = 'b'; private static final int i = 0; public static void main(String[] args){ S...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
dcb651bf24ca8d5f3f08cc06ed254154
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; import java.text.DecimalFormat; public class Main { private static class FastScanner { BufferedReader br; StringTokenizer st; public FastScanner() throws FileNotFoundException { if (System.getProperty("os.name").equals(...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
7408e4696b6fceb521d85a234e5df12d
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.Scanner; public class AB_Balance { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); sc.nextLine(); while(t-->0){ String s= sc.nextLine(); String ...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
00560b69a1cb85a77eb38996ca6519c3
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.ArrayList; import java.util.Scanner; public class test { public static ArrayList<ArrayList<int[]>> count (int n,String s){ ArrayList<int[]> posAB= new ArrayList<>(); ArrayList<int[]> posBA= new ArrayList<>(); String si=""; int[] arr = new int[2]; f...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
c13a9b2d8302dd48ec5936570f24c270
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.ArrayList; import java.util.Scanner; public class test { public static ArrayList<ArrayList<int[]>> count (int n,String s){ ArrayList<int[]> posAB= new ArrayList<>(); ArrayList<int[]> posBA= new ArrayList<>(); String si=""; int[] arr = new int[2]; f...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
572e7143eb58f56c9aa8a8300a1fd6d7
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.ArrayList; import java.util.Scanner; public class test { public static ArrayList<ArrayList<int[]>> count (int n,String s){ ArrayList<int[]> posAB= new ArrayList<>(); ArrayList<int[]> posBA= new ArrayList<>(); String si=""; int[] arr = new int[2]; f...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
0859d17d16673e990d0ca3e6f9bb6dd1
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; import java.lang.*; import static java.lang.Math.*; // Sachin_2961 submission // public class Codeforces { static void solve(){ char[]str = fs.n().toCharArray(); if(str[0] != str[str.length-1]){ str[0] = str...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
9b53e88d87d3b1a45678c3a555891bbe
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.Scanner; public class Con_116_Div_2_A_AB_Balance { // public static boolean isEqual (String temp){ // int ab_count = 0; // int ba_count = 0; // // for(int i = 0; i < temp.length(); i++){ // // for(int j = i + 1; j <= temp.length(); j++){ // // ...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
4013c6e85bd0a6ba668f632bebdb21d5
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.Scanner; public class Con_116_Div_2_A_AB_Balance { public static boolean isEqual (String temp){ int ab_count = 0; int ba_count = 0; for(int i = 0; i < temp.length(); i++){ for(int j = i + 1; j <= temp.length(); j++){ if(temp.subst...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
a66c739ebaab8bf11fd42691cf7459f3
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.Scanner; public class Con_116_Div_2_A_AB_Balance { public static boolean isEqual (String temp){ int ab_count = 0; int ba_count = 0; for(int i = 0; i < temp.length(); i++){ for(int j = i + 1; j <= temp.length(); j++){ if(temp.subst...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
02f16be45531a245a45c138cc8f6ded4
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.Scanner; public class Con_116_Div_2_A_AB_Balance { public static boolean isEqual (String temp){ int ab_count = 0; int ba_count = 0; for(int i = 0; i < temp.length(); i++){ for(int j = i + 1; j <= temp.length(); j++){ if(temp.subst...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
623f030891663d0edbd293620b44d40a
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.Scanner; public class abbalance { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-- > 0) { StringBuilder s = new StringBuilder(); s.append(sc.next()); if(s.charAt(0) != ...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
dcbc00ef8ad01c5aaf7bf11b2290d971
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.*; import java.util.*; import java.lang.*; import java.util.jar.JarEntry; public class TaskA { public static char reverse(char a){ if(a=='a') return 'b'; else return 'a'; } public static String getString(String s){ StringBuilder ans = new StringBuilder(); ...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
e3562ed531b7ca017a4908d642d2f660
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.*; import java.util.*; public class q1 { public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); public static void solve() throws Exception { StringBuilder str = new StringBuilder(br.readLine()); str.setCharAt(0,str.charAt(str.length() ...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
7e7d3f01c1e5670f9ada136ae8f36178
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.*; import java.util.*; public class q1 { public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); public static void solve() throws Exception { StringBuilder str = new StringBuilder(br.readLine()); int c = 1; for(int i = 0;i < st...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
a5b9bba9dbf51f6c71aae82b4fa5c9cd
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.Scanner; public class codeforcesround { public static Scanner read = new Scanner(System.in); public static void main(String[] args) { int t = Integer.parseInt(read.nextLine().trim()); while (t-- > 0) { solve(); } } private static void solve() { String s = read.nextLine();...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
01c1f8fc54606e73e15ad27a7d21ec75
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class B { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamRe...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
abf970325c7822ed3123b803deca2ed7
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.*; public class file { public static void main(String []args) { Scanner sc= new Scanner(System.in); int num = sc.nextInt()+1; String str[] = new String[num]; for (int i = 0; i < num; i++) { String input = sc.nextLine(); str[i] = input; } for (int i =...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
17cccb5275b1356281360abb3a96fcc3
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.StringTokenizer; /** * * @author eslam */ public class ABBalance { static class FastReader { BufferedReader br;...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
262b5394ca4e29de9100f505d76dbde9
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.Scanner; /** * * @author eslam */ public class ABBalance { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner input = new Scanner(System.in); int t = input.nextInt(); for (int i = 0; i < t; i++) {...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
4e01f6706e853b81a8908eee4620b967
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.Scanner; /** * * @author eslam */ public class ABBalance { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner input = new Scanner(System.in); int t = input.nextInt(); for (int i = 0; i < t; i++) {...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
b031aa52b8cbdbd5cfe7295391389fe4
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.StringTokenizer; /** * * @author eslam */ public class JavaApplication778 { static class FastReader { BufferedR...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
d5371bb68e048993a027c7fcc61196e2
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Main { static long mod = (int)1e9 + 7; // static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); public static void main (String[] args) throws java.lang.Exception { FastReader sc =new FastReader(); ...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
0f1541b8fa51c88d85b985e5163cc591
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Main { static long mod = (int)1e9+7; public static void main (String[] args) throws java.lang.Exception { FastReader sc =new FastReader(); int t=sc.nextInt(); // int t=1; while(t-->0...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
535402f0e8f8df1a58d96330ba4bd0a3
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.InterruptedIOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashSet; import java.util.List; import java.util.Scanner; import javax.swing.plaf.synth.SynthOptionPaneUI; public class Main { privat...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
c96503d68fb53090939bed5c2a4d32bb
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.InterruptedIOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashSet; import java.util.List; import java.util.Scanner; import javax.swing.plaf.synth.SynthOptionPaneUI; public class Main { privat...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
568e332e84fa72ca9239c52a05d3464c
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner scn = new Scanner(System.in); int t = scn.nextInt(); while(t-->0){ String s=scn.next(); s=s.substring(0, s.length()-1) + s.charAt(0); System.o...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
516e3aaa1885867cceff1ac30612d367
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException; import java.io.IOException;import java.io.InputStream;import java.io.PrintWriter; import java.security.AccessControlException;import java.util.ArrayList;import java.util.List; public class _A {static public void main(final String[]...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
0717822ca6d287de8ece162a7e9e41bb
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.StringTokenizer; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.lang.reflect.Array; import java.io.IOException; import java.io.BufferedReader; import java.io.BufferedWriter; import java.math.BigInteger; import java.util.Arrays; import java.util.Collections; i...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
4fd9a871d95dc76c89c42bd45cbddf3e
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.StringTokenizer; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.lang.reflect.Array; import java.io.IOException; import java.io.BufferedReader; import java.io.BufferedWriter; import java.math.BigInteger; import java.util.Arrays; import java.util.Collections; i...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
49e21e2b3f2276c147a8d52ce2f1aade
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
//package com.company; import java.util.Scanner; public class A { private static Scanner scanner = new Scanner(System.in); public static void main(String[] args) { int n = scanner.nextInt(); while(n-- > 0) { String s = scanner.next(); StringB...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
072b4d1ebf55d6bb79a87f5d7810d30e
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import static java.lang.Long.parseLong; //Make it Divisible by 25 //-00 //-25 //-50 //-75 public class Main { public static void main(String[] args) throws IOException, NumberFormatException { BufferedReader br ...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
8fa48aa54695197af55eaea0e2bbd3ca
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class div2 { static boolean a=false; public static void main(String[] args) throws IOException { Scanner sc=new Scanner(System.in); long t=sc.nextLong(); while(t-->0) { String s=sc.next(); int c1=0,c2=0; for(int i=0;i<s.length()-1;i+...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
8226f5e02317581d31911d6c5f8033d8
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.*; public class A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); StringBuilder str = new StringBuilder(); int t = sc.nextInt(); for (int xx = 0; xx < t; xx++) { String s = sc.next(); int ab =0; int ba =0; for(int i=0;i<s.length()-1;i++...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
91740ec7e928fc4fbe2c23fbb2af8a6e
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; public class _1606_A { private static final FastScanner in = new FastScanner(); private static final Pri...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
e28e7666bf57cdd718ba8d6b43b9a721
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.*; import java.util.Arrays; import java.util.Random; import java.util.StringTokenizer; public class codeforces_Edu116_A { private static void solve(FastIOAdapter io) { char[] c = io.next().toCharArray(); int ind = 0; while (!check(c)) { if (ind > 0) { ...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
21b6437fc3a3c9b28858b02898a575af
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; public class Main { static BufferedReader br; static BufferedWriter bw; static int getAB(String msg) { int count = 0; for(int i = 0; i < m...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
567199e24299b37668ab11a0fda28e00
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.StringTokenizer; public class ABBalance { private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); private static StringToken...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
6bb7883ecc9676ea1170082fc59f1430
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int t = scanner.nextInt(); while (t-- > 0 ){ String str = scanner.next(); if (str.charAt(0) == str.charAt(str.length() -1)) ...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
09866ae3aca16f1bab224b6671e20ead
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.*; import java.math.*; //import java.io.*; public class Experiment { static Scanner in=new Scanner(System.in); // static BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); public static void sort(int ar[],int l,int r) { if(l<r) { in...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
68b76e3eadca1d9403ef4878d76a453b
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.*; import java.util.*; public class Main { static class InputReader { BufferedReader reader; StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenizer = null; } String next() { // reads i...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
66104b9c7a513ca718af332f33747780
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class NewTemplate { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedRe...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
2f6c1640fcf929b6f1c79f1aef7e8c2c
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.*; import java.io.*; public class Main { // Graph // prefix sums //inputs public static void main(String args[])throws Exception{ Input sc=new Input(); precalcul...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
344ed01f076fc13d26bcde68a920e887
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int r = sc.nextInt(); for(int i=0;i<r;i++) { String t = sc.next(); char[] arr = t.toCharArray(); if (arr[0] !...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
483a02118e8fe305deaab96e0f8a53c1
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class Solution { static PrintWriter out; public static void main(String[] args) { FastReader in = new FastReader(); out = new PrintWrit...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
b21674d5f60ef3d161d04fbf56052ecb
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Main { static StringTokenizer tok; static BufferedReader br; static PrintWriter out; static int nextInt() throws IOException { ...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
aca6b7eb8cf88baddeaa43ae95bb129d
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Solution { public static void main(String[] args) { FastReader f = new FastReader(); int t = f.nextInt(); while (t-- > 0) { String str = f.nextLine(); if (str.charAt(0) != str.charAt(str...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
1ff8b7f3edba60bb610018ed564ee756
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class educational116A { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReade...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
bbc1c103d1ce28636517f04cc467799a
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.*; import java.util.Map; public class Sol{ public static void main(String args[]) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { char s[]=sc.next().toCharArray(); s[0]=s[s.length-1]; System.out.println(s); } } }
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 11
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output