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
69fccfd48cfea061bbc4ef5acd4b73a6
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.*; public class a111 { public static void main(String []args) { Scanner s=new Scanner(System.in); int n=s.nextInt(); while(n-->0) { String t=s.next(); String s1=s.next(); if(s1.length()==1&&s1.charAt(0)=='a') { System.out.println(1); } else { int m=t.length(...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
a3b4d2f002fb2237623a1fe9632eef8c
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.*; import java.io.*; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; import java.math.BigInteger; public final class Main{ static class Reader { ...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
995a0f25da267c90c8e30734fec269f9
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.io.*; import java.util.*; /** * * @author eslam */ public class IceCave { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } Stri...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
2152c66b64e848b1afc60d9f86b8ac9c
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.*; public class practise { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int tt=sc.nextInt(); while(tt-->0){ String s=sc.next(); String t=sc.next(); if(t.length()==1){ if(t.charAt(0)...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
9de59c8429cda8dfe8652517f1dfb719
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.*; public class infinitereplacement{ public static void main(String[] args) throws Exception{ Scanner scn=new Scanner(System.in); int k=scn.nextInt(); while(k-->0){ String s=scn.next(),t=scn.next(); boolean afound=false; boolean others=false; b...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
8441d2aec4198a95883772d9383ef65d
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.*; public class InfiniteReplacement { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while (t-->0){ String s=sc.next(),p=sc.next(); Map<Character,Integer>mp=new HashMap<>(); for(int ...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
eb1f3d76603b08bcf97ffb5802c8e3e8
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); in.nextLine(); for (int i = 0; i < n; i++) { String s = in.nextLine(); String t = in.nextLine(); if(t.length() > 1 && t.contains("a")) { ...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
05d4ccbe966849a240ce7389bf94712d
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.io.*; import java.util.*; import java.math.BigInteger; public class Main { public static void main(String[] args) throws IOException { OutputStream outputStream = System.out; FastReader in = new FastReader(); PrintWriter out = new PrintWriter(outputStream); PROBLEM solver = new PROBLEM(); ...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
2a02e3703e4c455f51d2a21c3205ada9
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
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
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
199bbc238ff0503cea024f31b47a6879
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import static java.lang.Integer.parseInt; import static java.lang.Long.parseLong; import static java.lang.Math.max; import static java.lang.System.exit; import static java.util.Arrays.fill; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWri...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
27abe12506b8a74a32e58941218c1e02
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.lang.Math; import java.io.BufferedReader; import java.io.InputStreamReader; import java.lang.Math; public class st49 { public static void main(String[] args) throws java.lang.Exception{ InputStreamReader r=new InputStreamReader(System.in); BufferedReader br=new BufferedReader(r); int a=In...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
6b81ac75c06ec939114074832b538c02
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.HashSet; import java.util.Scanner; import java.util.Arrays; public class C_infinite_replacement { static long calc_str(String str1, String str2) { char[] ch = str2.toCharArray(); Arrays.sort(ch); if (ch[0] == 'a' && str2.length() > 1) return -1; ...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
7e8ebfbca458886d45367b418d860c48
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
//package MyPackage; import java.util.*; import java.io.*; public class A{ static class FastReader{ BufferedReader br; StringTokenizer st; public FastReader(){ br=new BufferedReader(new InputStreamReader(System.in)); } String next(){ whi...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
13a4245bbda8d446e11942466bce2c71
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
//package MyPackage; import java.util.*; import java.io.*; public class A{ static class FastReader{ BufferedReader br; StringTokenizer st; public FastReader(){ br=new BufferedReader(new InputStreamReader(System.in)); } String next(){ whi...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
615ee89eca557df76cccc98f8f3df12f
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.io.*; import java.util.*; public class Test{ static boolean palindrome(String s,int i,int j) { if(j==s.length())return false; while(i<j) { if(s.charAt(i)!=s.charAt(j))return false; i++;j--; } return true; } static int valid(String s,int i) { Stack<Character>st=new Stack<>()...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
74eb0cf7566db4398058966e6f5ee10f
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.Scanner; import java.lang.Math; public class InfiniteReplacement { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc=new Scanner(System.in); int test=sc.nextInt(); for(int i=0;i<test;i++) { String s=sc.next(); String t=sc.next(); if(...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
9f21f5fb4d9952c20d1fcc0fe51c4893
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.Scanner; public class problem3 { public static void main(String[] args) { Scanner sh = new Scanner(System.in); int t = sh.nextInt(); sh.nextLine(); while(t>0){ String s = sh.nextLine(); String a = sh.nextLine(); int numa = 0; ...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
7d4400fb208a87a73803385e156f7d2c
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.*; import java.io.*; public class A{ public static void main(String[] args) throws IOException,NumberFormatException{ try { FastScanner sc=new FastScanner(); PrintWriter out=new PrintWriter(System.out); int t=sc.nextInt(); while(t-->0) { char s[]=sc.next().toCha...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
1c69f79c916011d930f8ad1bb6e6075b
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.HashSet; import java.util.Hashtable; public class C_Infinite_Replacement { public static void main(String[] args) throws IOException { BufferedReader br = new Bu...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
3cfd33e06922b4d4d66b05078dd7cb41
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.awt.image.ImageProducer; import java.util.*; public class Solution { static class P { char chara; int c; public P(char chara, int c) { this.chara = chara; this.c = c; } } static boolean prime[] = new boolean[1000001...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
364a02120d6239f60ea25c263f1082df
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.*; public class Main{ public static void main(String[] argrs){ Scanner scan = new Scanner(System.in); int T = scan.nextInt(); while (T -- > 0){ String s = scan.next(); String t = scan.next(); if (t.equals("a")) { S...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
8814cf017222b1fc7d3c710ecc0af2b5
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.Scanner; public class E { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int q = scanner.nextInt(); scanner.nextLine(); for (int l = 0; l < q; l++) { String s = scanner.nextLine(); String t = sca...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
2c985b6e6fdcedbf7d569260263149fb
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.ArrayList; import java.util.Scanner; import java.util.Arrays; public class trial { public static void main(String[] args) { // TODO code application logic here Scanner read = new Scanner(System.in); int t = read.nextInt(); for (int i = 0; i < t; i++) { ...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
c314f5f4c6a6c7b17deff968a17efb6c
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.Scanner; public class testing{ public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); in.nextLine(); for(int w = 0; w < t; w++){ char[] ch = in.nextLine().toCharArray(); char[] x = in.next...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
53c49d565d5d39edd34acd2793d8d529
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.*; import java.util.Map.Entry; import java.io.*; public class c2{ static class Pair{ int first; int last; public Pair(int first , int last){ this.first = first; this.last = last; } public int getFirst(){ ...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
c3572e67ce028a3f83bbdfb44df3d069
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
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 void solve() { String a=in.next(); String t=in.next(); if(t.length()==1&&t.equals("a")){ ...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
ccbdd4be79903d7cd75698d8d5f71276
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; import java.util.ArrayList; import java.util.Arrays; import java.io.UncheckedIOException; import java.io.Closeable; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.HashSe...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
f48d8e6d3f7ffe1156c7c325dcf7bffc
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.Scanner; public class Problem10 { static long binpow(long a,long b) { if (b == 0) return 1; long res = binpow(a, b / 2); if (b % 2 != 0) return res * res * a; else return res * res; } public static void main(St...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
4b19c6dbb05466e3e8482da60705917e
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.util.*; public class diffstrings { public static void main (String[] args) throws IOException { PrintWriter pw = new PrintWriter(System.out); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
ccd8f1e808c60126d6b6508f22cb7b60
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
//some updates in import stuff import static java.lang.Math.max; import static java.lang.Math.min; import static java.lang.Math.abs; import java.util.*; import java.io.*; import java.math.*; //key points learned //max space ever that could be alloted in a program to pass in cf //int[][] prefixSum = new int[...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
d5b33ba3fc0dd0914e38c252c2fdc2d5
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.nio.charset.StandardCharsets; public class CF1674C { public static void main(String[] args) throws IOException { BufferedReader...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
866f6b4203bd4415dbef0cfe07f7f2a4
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.HashSet; public class InfiniteReplacement { // private static HashSet<String> hs = new HashSet<>(); public static void main(String[] args) throws Exception { var br = new BufferedReader(new InputStreamReader(System.in)); i...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
cb37a99ac59ea00c1c58df554e6cc431
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.io.*; import java.util.*; import java.lang.*; public class Codechef { static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; public Reader() { di...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
b8bc8377d6e86716595f88c2639afe47
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.io.*; import java.util.*; public class C { public static void main(String[] args) { FastScanner sc = new FastScanner(); PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); int T = sc.nextInt(); while (T-- > 0) { String s, t; ...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
e763b1b6a9f138454db4b3c139fba656
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.math.BigInteger; import java.util.Scanner; public class C { public static void main(String[] args) { Scanner go = new Scanner(System.in); int q = go.nextInt(); while (q-->0){ String s = go.next(); String t = go.next(); int co = 0; ...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
1d202ecc4a510493e96d24d794c57a9e
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.*; public class infinite_rep { public static void main(String args[]) { Scanner in = new Scanner(System.in); int t = in.nextInt(); for (int i = 0; i < t; i++) { String first_word = in.next(); String second_word = in.next(); if (second_word.length() == 1 && ((second_word.ch...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
d4e7f4a35155a7650c1314093389257b
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.*; public class test { public static void main(String argss[]) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for(int i=0;i<t;i++){ String s1 = sc.next(); String s2 = sc.next(); int x=s2.indexOf('a'); i...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
55d6b80baeb5a678910c91e2d8af3827
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Ideone { public static void main (String[] args) throws java.lang.Exception { Scanner in = new Scanner( Syste...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
c3a3d60a748734da41526c8b61f08ed4
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int x=sc.nextInt(); while(x-->0) { String s1=sc.next(); String s2=sc.next();int c=0; int a=s1.length();//System.out.println(a+" lllll"); char ch[]=s2.toCharArra...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
4a073bc371f4abacb2e09dc073a15a56
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.*; public class main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); int t = cin.nextInt(); while (t != 0) { String a = cin.next(); String b = cin.next(); int countA = 0; for (int i =...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
741fd6e871a58af959a6a8d6486124d3
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.*; public class Lol { //Hi my name is Vijay, My age is 27, My birthday is 17th Oct 1995. public static void main(String[] args) { Scanner sc = new Scanner(System.in); //System.out.println('c'-'a'); int t = sc.nextInt(); while (t-- > 0) { ...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
0b5642df2e79b1e5d382d22dad95244f
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t-- > 0) { String str = sc.next(); String s =sc.next(); long count = 0; for(...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
fcfabd8ab731126251f0f163e0bdb0ad
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Solution { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader( ...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
8864aca50faa67eb8dc001504415770e
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.HashSet; import java.util.StringTokenizer; public class cf1674C { // https://code...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
92b1110ba341323e0956f41bb05fbba8
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.*; import java.util.Scanner; public class temp { public static void main(String [] args){ Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0){ String x = sc.next(); String y = sc.next(); int count =0; ...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
6c3c32d64032a38188e2ef90bdf994aa
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.*; import java.lang.Math; import java.math.BigInteger; import java.nio.charset.StandardCharsets; public class C { public static void main(String[] args){ Scanner s = new Scanner(System.in); int q = Integer.parseInt(s.nextLine()); while(q>0){ String string1,strin...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
df4cfbb1e9b25786bb532115ae3b61b3
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
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 = 1005; boolean sieve[]; int pf[]; ArrayList<Intege...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
cd0a7ba3bc508068626fdbbb5dd21d37
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigDecimal; import java.math.BigInteger; import java.util.*; //import java.util.*; public class Solution { public static void main(String[] args) throws IOException { BufferedReader br = ...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
507e87904f46e2d8bdf39134adaaefb7
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.io.*; public class Solution { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); int q = Integer.parseInt(br.readLine()); ...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
e305545416105a85f4cb35b017dccacc
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.Scanner; public class Infinite_Replacement { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int q = sc.nextInt(); sc.nextLine(); while(q-- > 0) { String s = sc.nextLine(); String ...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
978edc2e659418f25db1f9b0fee4c602
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.*; public class HelloWorld{ public static void main(String []args){ Scanner sc=new Scanner(System.in); int m=sc.nextInt(); while(m-->0){ String s=sc.next(); String t=sc.next(); if(t.length()==1 && t.charAt(0)=='a'){ ...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
55d31ecf073a7305f1842d792f2538cf
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Solution { static long cal(int n) { return (1L << n); } public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); BufferedReader in = new BufferedReader(new InputStreamReader(System.in...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
069ab5bbfd7c04034e252c8683809fcc
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.*; import java.io.*; public class NewProgramJava { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); int T = sc.nextInt(); while (T>0){ T--; StringBuilder str1 = new StringBuilder(sc.next(...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
dbaee5de059b011828b80af29fac58c6
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
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
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
1d94fe5be74cf9e0484659dcabf8876b
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; import java.util.*; public class Main { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new Buf...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
2c0418802fe68c98a90d271470c4ab4e
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.lang.*; import java.io.*; import java.util.*; public class codeforces { static int max = Integer.MAX_VALUE, min = Integer.MIN_VALUE; long maxl = Long.MAX_VALUE, minl = Long.MIN_VALUE; static PrintWriter pw = new PrintWriter(System.out); static StringBuilder sb = new StringBuilder();...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
99cd94a4e0ac0eba939b7bc2757d8d42
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.*; public class three { public static int fac(int i) { if(i==0 || i==1) { return i; }else { return i*fac(i-1); } } public static void main(String[] args) { // TODO Auto-generated method stub Scanner key=new Scanner(System.in); int q=key.nextInt(); key.nextLine(); ...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
84aceda68504a88281a19d0e4d35c2d8
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.*; import java.io.*; public class Answer { public static void main(String[] args) { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int q = sc.nextInt(); outer: while(q-->0) { String s = sc.next(); String t = sc.next(); if(t.equals("a...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
c54f3bf4aaa292aec50d8509c62cbbbc
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Array; import java.util.*; import java.io.*; import java.io.BufferedWriter; import java.io.OutputStreamWriter; import java.io.Pri...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
0bd36f80d1bbab707ce39d76941d690c
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int count = scanner.nextInt(); while (count > 0) { String s = scanner.next(); String t = scanner.next(); if (t.equals("a"))...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
cfca4a79e8445adc5570e077431909b3
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.Scanner; public class InfiniteReplacement { public static void main(String[] args) { Scanner in = new Scanner(System.in); int z = in.nextInt(); for ( int p = 0; p < z; p++) { String s = in.next(); String t = in.next(); int test =...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
6e45c86e1c75d72d13d5582e2ea2ece0
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.io.*; import java.util.Scanner; import java.util.StringTokenizer; public class infiniteReplacement { public static void main(String[] args) throws IOException { Reader r = new Reader(); int t = r.nextInt(); String s, x; long[] answers = new long[t]; for...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
2f2a2e11817b6f4a22f87c22ae821a3b
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import static java.lang.Math.pow; public class haha { static class FastScanner { BufferedReader br = new BufferedRe...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
c859abbd617673e35d3d0b89e92f154f
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
///package solution; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class Solution implements Runnable { public void solve() throws Exception { int testCase = sc.nextInt(); while (testCase-- > 0) { String a = in.r...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
14fc23cd8d97b8c21484e432f77dd148
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.io.*; import java.util.*; import javax.management.openmbean.OpenDataException; public class Codeforces { final static int mod = 1000000007; final static String yes = "YES"; final static String no = "NO"; public static void main(String[] args) throws Exception { FastRead...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
2e04eb70cc87050bb2873be18425f739
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.*; import java.io.*; public class Solution { public static void main(String[] args) throws IOException { int t = sc.nextInt(); while (t-- > 0) { char[] s = sc.next().toCharArray(); char[] word = sc.next().toCharArray(); int count = 0; for (char ch : word) { if (ch =...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
dbe5b5d5b2e1dc7df5ed1e6bcc8fd411
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.*; import java.io.*; public class C { public static void main(String[] args) throws Exception { int q = sc.nextInt(); while (q-- > 0) { String s = sc.nextLine(); String t = sc.nextLine(); if (t.equals("a")) { pw.printl...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
8317f3811919a88398fe5d2f557a051a
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class InfiniteReplacement { public static void main(String[] args) { Scanner input =new Scanner (System.in); int t=input.nextInt(); for(int i=0;i<t;i++) { String s1=input.next(); String s2=input.ne...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
45b723caf25d14ab279d5e9af5412b88
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.*; import java.io.*; public class d3 { //static boolean[] visited; //static long min; public static void main (String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWriter(new...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
a5e870b87e8567ff6dd1aa241670fc6a
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.*; public class main { public static void main(String[] strgs) { Scanner sc=new Scanner(System.in); long[] power=new long[51]; power[1]=2; for(int i=2;i<=50;i++) { power[i]=power[i-1]*2; } int t=sc.nextInt(); while(t-- >0) { String sr=sc.next(); String tr=sc.next(...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
b2e176f17e206d20fbd396db9460aea8
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.io.*;import java.lang.*;import java.util.*; //* --> number of prime numbers less then or equal to x are --> x/ln(x) //* --> String concatenation using the + operator within a loop should be avoided. Since the String object is immutable, each call for concatenation will // result in a new String object ...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
1b8076b083261e9965541ed1e1e0ad53
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.*; import java.math.*; public class D { static boolean check(int i, int j, int n, int m,int arr[][]) { if(i<0 || i>=n || j<0 || j>=m) return false; if(arr[i][j]!=1) return false; return true; } public static void main(String[] args) { // TODO Auto-generated method s...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
52394345730e5ca24301a686e92e45e1
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.sort; public class Round12 { public static void main(String[] args) { FastReader fastRe...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
1d37368731aec015f1d203bbac93b5f8
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.io.*; import java.util.*; import java.math.BigInteger; public class Main { InputStream is; PrintWriter out = new PrintWriter(System.out); ; String INPUT = ""; void run() throws Exception { is = System.in; solve(); out.flush(); o...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
cf9ac78bc332d9b25341ede6ee959b23
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.io.*; import java.util.*; public class Main { static int mod = (int)1e9+7; static boolean[] prime = new boolean[10]; static int[][] dir1 = new int[][] {{0, 1}, {0, -1}, {1, 0}, {-1, 0}}; static int[][] dir2 = new int[][] {{0, 1}, {0, -1}, {1, 0}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1,...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
94b34e5a1fb52dea1b365314f5e9192f
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Codechef { public static void main (String[] args) throws java.lang.Exception { // your code goes here Scanner sc = new Scanner(System.in); int ti = sc.n...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
8e5dccdb0b0b142cf43c1b2113136bd0
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.io.*; import java.text.DecimalFormat; import java.util.*; public class Main { static class Pair { long a,b,c; public Pair(long a,long b,long c) { this.a=a; this.b=b; this.c=c; } // @Override // public ...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
b70ba0453798fda877762e4dd7f2713b
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.io.*; import java.text.DecimalFormat; import java.util.*; public class Main { static class Pair { long a,b,c; public Pair(long a,long b,long c) { this.a=a; this.b=b; this.c=c; } // @Override // public ...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
36f9d6bff3cf8ef3d4e90ffed6eb5628
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.*; import java.io.*; public class codeforce { public static void main(String[] args){ Scanner read = new Scanner(System.in); int test = read.nextInt(); while(test-->0){ String s = read.next(); String t = read.next(); int...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
9982752ed43d54d95e0f01a4735548dc
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.*; import java.io.*; public class Solution{ static class FastReader{ BufferedReader br; StringTokenizer st; public FastReader(){ br=new BufferedReader(new InputStreamReader(System.in)); } String next(){ while(st==null || !st.hasMoreTo...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
a10a28ea2a463fc986b786d136bb0f4a
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.io.*; import java.util.*; import javax.sound.sampled.SourceDataLine; public class infinite_replacement { public static void main(String[] args) { Scanner sc=new Scanner (System.in); int t= sc.nextInt(); sc.nextLine(); while(t>0){ String p= sc.nextLi...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
f566dba759fe68793b77764f5833d843
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.*; import java.math.*; public class C { static int MAX = 1000000007; static HashMap<Long, BigInteger> mem = new HashMap(); public static void main(String[] args) { Scanner sc = new Scanner(System.in); int test = sc.nextInt(); while (test-- > 0) { String s = sc.next()...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
3dad8601477f663823f5821a46ac21c4
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.Scanner; public class Main { static Scanner in = new Scanner(System.in); static String s, b; public static void main(String[] args) { int casesNumber = in.nextInt(); while (casesNumber-- != 0) { s = in.next(); b = in.next(); S...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
1fc66aa5825f4e23dd1aad05a231b169
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.Scanner; public class InfiniteReplacement { public static void main(String[] args) { Scanner in=new Scanner(System.in); int t= in.nextInt(); for(int i=0;i<t;i++){ String s=in.next(); String tt=in.next(); long x=tt.length(); ...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
5edad8e52c00cae199bfea730982f866
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.HashMap; import java.util.HashSet; import java.util.StringTokenizer; /* Name of the class has to be "Main" only if the class is public. */ public class C_Infinite_Replaceme...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
c53eedcde705d72e3ec9ec728f278066
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Random; import java.util.StringTokenizer; public class Solution { static ArrayList<String> list; public static void main(String[] args) { ...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
2e418c3f52b50f8fb735de64e44854c8
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; /* author : Multi-Thread */ public class C { //public class Main { // static int INF = 998244353; static int INF = (int) 1e9 + 7; static int MAX = Integer.MAX_VALUE; static int MIN = Integer.MIN_VALUE; public static void main(String[] a...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
1586ffb446fad1e36b85e41ecfad60c1
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
/* IF I HAD CHOICE, I WOULD HAVE BEEN A PIRATE, LOL XD ; _____________############# _____________##___________## ______________#____________# _______________#____________#_## _______________#__############### _____##############______________# _____##____________#_____################ ______#______##########...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
12f9ac7e4bf1836d3284d542157542b8
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.io.*; import java.util.*; public class C { void go() { String s = Reader.next(); String t = Reader.next(); int m = s.length(); int n = t.length(); long ans = 0; long[][] comb = new long[m + 1][m + 1]; comb[0][0] = 1; for(int i ...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
fdfc2af8f818f9b4f9cd31d53a8235c3
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; import java.util.Map.Entry; public class codeforces { static int mod = 1000000007; public static void main(String[] args) { FastReader sc = new FastReader(); ...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
dc8e5b7ebd82ddd7cf66bf2619530678
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
df780795f9b768a8d8c26a3a0bffea69
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.io.*; import java.util.*; public class Main2 { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; FastScanner in = new FastScanner(inputStream); FastPrinter out = new FastPrinter(outputStream); ...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
5eb82dc3b26d46035a84231f3508906d
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
// Jai Shree Ram ⛳⛳⛳ // Jai Bajrang Bali // Jai Saraswati maa // Har Har Mahadev // Thanks Kalash Shah :) import java.math.BigInteger; import java.util.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import static java.lang.Character.isUpperCase; public c...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
414be54c8508628ae3329a977703db90
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
/* JAIKARA SHERAWAALI DA BOLO SACHE DARBAR KI JAI HAR HAR MAHADEV JAI BHOLENAATH Rohit Kumar "Everything in the universe is balanced. Every disappointment you face in life will be balanced by something good for you! Keep going, never give up." ...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
ea494f8f372658e9496f21b1d8c76e28
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.io.*; import java.util.*; public class InfiniteReplacement { // For fast input output static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { try { br = new BufferedReader(new FileReader("input.txt")); PrintStream out = n...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
933480c35fb4b4b286cb841d012af1d0
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.Writer; import java.util.*; /* Name of the class has to be "Main" only if the class is public. */ public class codeforces{ static FastReader sc=new FastReader(); ...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 11
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
baefb84bd28a495c83392b6c6afab6c2
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(new BufferedInputStream(System.in)); int t = in.nextInt(); for (int i = 0; i < t; i++) { String s1 = in.next(), s2 = in.next(); boole...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 8
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
5e30ffe8a2e27e209b328a2e40734d72
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import static java.lang.Math.max; import static java.lang.Math.min; import static java.lang.Math.abs; import java.util.*; import java.io.*; import java.math.*; /** * * @Har_Har_Mahadev */ /** * Main , Solution , Remove Public */ public class C { public static void process() throws IOException ...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 8
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
9f6c1d9511dca5d35e6780903edcb5a6
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Scanner; public class InfiniteReplacement_1674C { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLi...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 8
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output
PASSED
e794dd65d15af2448a7bbf9f6ad6f522
train_107.jsonl
1651502100
You are given a string $$$s$$$, consisting only of Latin letters 'a', and a string $$$t$$$, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string $$$s$$$ with a string $$$t$$$. Note that after the replacement string $$$s$$$ might contain letters other than 'a'.You can perform a...
256 megabytes
import java.util.Scanner; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; import java.util.Arrays; public class Cv { //==========================Solution============================// public static voi...
Java
["3\n\naaaa\n\na\n\naa\n\nabc\n\na\n\nb"]
2 seconds
["1\n-1\n2"]
NoteIn the first example, you can replace any letter 'a' with the string "a", but that won't change the string. So no matter how many moves you make, you can't obtain a string other than the initial one.In the second example, you can replace the second letter 'a' with "abc". String $$$s$$$ becomes equal to "aabc". Then...
Java 8
standard input
[ "combinatorics", "implementation", "strings" ]
d6ac9ca9cc5dfd9f43f5f65ce226349e
The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of testcases. The first line of each testcase contains a non-empty string $$$s$$$, consisting only of Latin letters 'a'. The length of $$$s$$$ doesn't exceed $$$50$$$. The second line contains a non-empty string $$$t$$$, consisting o...
1,000
For each testcase, print the number of different strings $$$s$$$ that can be obtained after an arbitrary amount of moves (including zero). If the number is infinitely large, print -1. Otherwise, print the number.
standard output