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 | 3e0712a96b294d710bcd493c8847559e | 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;
public class infinite {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
sc.nextLine();
while(t-->0){
String s = sc.nextLine();
String q = sc.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 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 | bf4833018c43a7c90e34dadac230d1f7 | 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.util.Arrays;
public class vanita {
public static void main(String[] args){
Scanner in =new Scanner(System.in);
int cases = in.nextInt();
boolean infinite = false;
boolean other = false;
boolean test = false;
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 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 | 01cb0d9fd3667585dfa75e33fcf87132 | 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 MyClass {
public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
long x=sc.nextLong();
String c=sc.nextLine();
for(int i=0;i<x;i++){
String s=sc.nextLine();
String t=sc.nextLine();
//System.out.print... | 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 | 9c4338b9271fa489b48b61f4d77803c3 | 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.lang.*;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class A_769 {
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 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 | 5cb530ecc9b043bdcbf37d4095460062 | 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 CodeForces {
public static void main(String[] args) throws FileNotFoundException {
FastScanner fs = new FastScanner();
int tt = fs.nextInt();
while(tt-- > 0) {
String a = fs.next(), b = fs.next();
int count1 = 0;
for(int i = 0; i < a.l... | 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 | fddcc9a675beae740fd52cf36aacd4dc | 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.File;
import java.io.FileInputStream;
import java.security.KeyPair;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.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 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 | 23d72981b6758c53393810c5afcf298a | 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.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Random;
import java.util.Scanner;
public class Practice {
public static void main(String[] args) {
Scanner sc=new Scanner(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 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 | 071abf083cf5ef9831c06b7a8e216060 | 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 temp{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t>0){
String s=sc.next();
String r=sc.next();
if(r.equals("a"))
System.out.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 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 | a12e7b5367227ca07df445af20838fb8 | 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.*;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
for(int casesTot = scan.nextInt(), cases =1;cases<=casesTot;cases++){
String str = scan.next();
String sub = scan.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 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 | e7c9ddef50117434b0c4f45132a1689b | 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.BigInteger;
import java.util.*;
import java.lang.System;
import static java.lang.System.out;
import static java.lang.System.setOut;
public class CodeForces {
public static void main(String[] args) {
FastReader fastReader = 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 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 | 0617689a8f639c60502f35b52ff1ca79 | 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.BigInteger;
import java.util.*;
public class Test {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
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 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 | 657a4634c303cd4e5d9383755d1c2b9c | 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 {
static ArrayList<Integer> palindromes;
static int dp[][];
static int mod = 1000000007;
static boolean containA (String s){
int n = s.length();
for(int i = 0;i<n;i++){
if(s.charAt(i)=='a'){
return true;
}
}
return false;
}
... | 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 | ab2ca27075da217843ffe10d27ccfecf | 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 HackerRankpractice;
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.*;
import java.util.regex.*;
import java.util.stream.*;
import javax.lang.model.util.ElementScanner6;
import javax.sou... | 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 | 9bc6eca57338d130a30d84ab7d7f3593 | 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.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
public class Solution implements Runnable {
public void solve() throws Exception {
int cse = sc.nextInt();
... | 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 | 9fe79972e87fcb95b4d762ebc4d3e633 | 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 {
public static long c(long n, long k) {
long r = 1;
k = Math.min(k, n - k);
for (int i = 1; i <= k; i++) {
r *= n--;
r/=i;
}
return r;
}
public static long fac(long n) {
return n == 0 ? 1 : n * fac(n - 1);
}
publi... | 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 | 77702ebf3a4f942c445148a677cc4602 | 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 codechef; // 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 Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
try {
Scanner sc=new Scanner... | 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 | a540f88498456a3b1edbf247047109ac | 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 IOException {
Reader sc = new Reader();
PrintWriter out = new PrintWriter(System.out);
int t = sc.nextInt();
while(t-- > 0) {
String s1 = sc.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 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 | ebcb02ca4f84898679b8e1e6ac642170 | 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 | // Problem: C. Infinite Replacement
// Contest: Codeforces - Codeforces Round #786 (Div. 3)
// URL: https://codeforces.com/contest/1674/problem/C
// Memory Limit: 256 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)
import java.util.*;
public class Mytemplate {
static 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 | 783ddbaf25f029b587b920be995dd0c5 | 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 {
// For fast input output
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
try {
br = new BufferedReader(
new FileReader("input.rtf... | 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 | 14cdc7db31ad5b1c380ffcadc462f167 | 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_Infinite_Replacement {
public static void main(String[] args) {
MyScanner sc = new MyScanner();
out = new PrintWriter(new BufferedOutputStream(System.out));
int tc = sc.nextInt();
while (tc-- > 0) {
String s = sc.next(), t = sc.next();
if (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 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 | 484ae6f68f39c7d38842ded17b8fe026 | 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.HashSet;
import java.util.Set;
import java.util.StringTokenizer;
public class C {
static FastScanner sc;
static PrintWriter pw;
static class FastScanner... | 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 | 0c53a1b5e14e55b182adc0d462c769a1 | 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 = 1000_000_007;
static long mod1 = 998244353;
static boolean memory = true;
static FastScanner f;
static PrintWriter pw;
static double eps = 1e-6;
static int oo = (int) 1e9;
static boolean fileIO = false... | 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 | 02a06a8e4e24abae3c387818eeaa808f | 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[])
{
int i,j,k,t,n;
Scanner sc=new Scanner(System.in);
t=sc.nextInt();
while(t-->0)
{
String s=sc.next();
String x=sc.next();
int len1=s.length();
int len2=x.length();
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 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 | 3851fe9ee8d5ce8e8c757270547432d0 | 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 javafx.util.*;
public class Main
{
static PrintWriter out = new PrintWriter(System.out);
static FastReader in = new FastReader();
static int INF = Integer.MAX_VALUE;
static int NINF = Integer.MIN_VALUE;
static long mod = 1000000007l;
pu... | 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 | 6151d17ce5de32c5bb48c8dcf60fb48e | 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 {
public static void main(String[] args) throws IOException {
InputStreamReader is = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(is);
Scanner sc = new Scanner(System.in);
//int test_case =... | 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 | f472a085c60c840ab91bf9201beb8198 | 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 kriti;
import java.math.*;
import java.io.*;
import java.util.*;
public class A
{
static PrintWriter out = new PrintWriter(System.out);
static StringBuilder ans=new StringBuilder();
static FastReader in=new FastReader();
public static void main(String args[])throws IOExceptio... | 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 | 8d6cfb781b528b742c70f1d5d265d26e | 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 dict
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
sc.nextLine();
while(t-->0)
{
int flag=0,m=0,n=0;
String a=sc.nextLine();
String b=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 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 | 7b7a1ebfd92b5aa795be0b4a2f6c9f11 | 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.text.*;
import java.math.*;
import java.util.regex.*;
import java.lang.*;
public class Main{
static FastReader in;
static PrintWriter o;
public static void solve() throws Exception {
int t1 = in.nextInt();
while (t1-- > 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 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 | 8497620b16de0ec998884401caa01da6 | 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;
import java.math.BigDecimal;
public class C {
public static void main(String args[]){
FScanner in = new FScanner();
PrintWriter out = new PrintWriter(System.out);
int t = in.nextInt();
m: while(t-->0) {
String s1=in.next(),s2=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 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 | fd2d04532f176160d382612ba477163b | 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 | /*############################################################################################################
########################################## >>>> Diaa12360 <<<< ###############################################
########################################### Just Nothing #####################################... | 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 | d90abb2af85cc697c44137f419197068 | 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 {
static final int MOD = 1000000007;
static InputReader in = new InputReader(System.in);
static BufferOutput out = new BufferOutput();
public static void main(String[] args) {
for(int i = in.nextInt();i>0;i--) {
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 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 | feda162eafe2620472e03213daf8d9ab | 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 Codeforces786_3 {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int t=input.nextInt();
for(int i=0;i<t;i++){
String s= input.next();
String s1= input.next();
int flag=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 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 | 6799f34688dd43d6ad6b23faba4a20cc | 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 | /*
!!!!Hello World,Prakhar here!!!!
codechef handle prakhar_3011
codeforces handle prakhar_30
trying to get good at CP
PEACE OUT.........
*/
/*
*/
import java.io.*;
import java.util.*;
public class C {
public static void main(String[] args) {
FastScanner sc = new FastScanner();
... | 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 | aeec31fa4e33337d2cb2f22edbd021ef | 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.*;
import java.lang.Math;
import java.util.StringTokenizer;
public class C {
public static void main(String[] args) {
int t;
String str;
char 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 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 | 8a7a530a41c49502ef0aceeb8aaac30c | 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 A10 {
public static void main(String[] args)throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(System.out);
int q = Integer.parseInt(br.readLine());
while(q-->0) {
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 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 | bdc07162775a6857b0d646847ba045eb | 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.datatransfer.StringSelection;
import java.util.*;
import javax.management.Query;
import java.io.*;
public class practice {
static String s;
static int n,k;
static int[] a;
static long[][] memo;
static HashMap<Long,Integer>hm;
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 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 | 45a4bacbc8b3dcb4d7d32211fbb17d38 | 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 long fact(int n,int a){
if(a==0)
return 1;
long x = fact(n,a/2);
x = x*x;
if(a%2==1)
x = x*n;
return x;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System... | 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 | c6c141c0d22d515722dc34cd0ee9d29c | 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 practice;
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(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 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 | b4756fbc7084b7eb94fb53ae91d1cdad | 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) {
new C().run();
}
BufferedReader br;
PrintWriter out;
long mod = (long) (1e9 + 7), inf = (long) (3e18);
class pair {
int F, S;
pair(int f, int 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 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 | b9fe914fa12b7564ee72883b5eee0b3d | 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.*;
import java.math.*;
public class abhinandan6065_Test {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
StringBuilder sb = new StringBuilder();
int quary = sc.nextInt();
while (q... | 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 | 7b7aaae87abb91bd7c0cf7d43fd762b7 | 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.File;
import java.io.FileReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Solution {
static PrintWriter pw;
static FastScanner s;
public static void main(String[] arg... | 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 | b756d7e47cfac543c4d3c618ed612229 | 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 CP;
import java.util.*;
public class Practice {
static long pow(long a,long b){
if(b==0)
return 1;
long ans=0L;
if(b%2==0){
long val = pow(a,b/2);
ans+=val*val;
}else{
long val=pow(a,b/2);
ans+=val*v... | 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 | 99ff3aedb28fb072c9e6bf6f32862bd8 | 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.StringTokenizer;
import java.util.*;
import static java.lang.System.out;
import static java.lang.Math.*;
public class pre273 {
static class FastReader {
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 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 | c250e5813f1c6e7fc70dd9b47257fd32 | 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 Solution {
public static void main(String args[]) {
Scanner scan = new Scanner(System.in);
int t = scan.nextInt();
while(t-->0) {
String a = scan.next();
String b = scan.next();
int n = a.length();
if(a.length() == 0) {
System.out.println(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 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 | f58740e5d0d40f8de7a2af2f54886df2 | 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.BigInteger;
import java.util.*;
import java.util.Map.Entry;
public class Main {
//static int [] arr;
//static boolean prime[] = new boolean[1000];
//static int l;
//static String s; static StringBuilder sb;
//static HashSet<L> hs;
//static HashSet<Long> hs =... | 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 | 8e08b33951b59cdeac07d3d07377faa1 | 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_Infinite_Replacement {
public static void main(String[] args) {
FastReader in = new FastReader();
PrintWriter out = new PrintWriter(System.out);
// try {
// out = new PrintWriter("output.txt");
// } catch (Exc... | 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 | 1d869682ce6a36f1a6f4e15aa5c84570 | 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 static java.lang.System.out;
import java.util.*;
import java.io.*;
import java.math.*;
public class Main
{
static FastScanner scan = new FastScanner();
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 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 | 1cbc234e77d742c6086ef586c70e3fad | 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.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class Main {
public Main() {
FastScanner input = new FastScanner(System.in);
StringBuild... | 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 | 6b06773f573be2736ea401fd3b4639c6 | 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 {
/*
static int parent[];
static int rank[];
static int dy[] = new int[]{1,-1,0,0};
static int dx[] = new int[]{0,0,1,-1};
*/
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int t = Integer.parseInt(sc.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 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 | 8013be0436a1fad696dfe5eb5b542dca | 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.lang.reflect.Array;
public class CodeForces {
class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
try {
br = new BufferedReader(new FileReader("input.txt"));
... | 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 | 31fb5ae5108ce87b13a10a7ee84cad0e | 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 com.company;
import java.util.*;
import java.io.*;
public class InfiniteReplacement {
private static long solve(String s, String t) {
if(t.equals("a")) return 1;
else if(t.contains("a")) return -1;
return (long)Math.pow(2, s.length());
}
public static void main(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 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 | c9679f807f049e6653f0a44ec969f1c9 | 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.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;
public class Cf22 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int k = sc.nextInt();
for(int i =0;i<k;i++) {
String a = 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 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 | 55ba231b9f82d74645de8e86097c96d8 | 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 sc = new Scanner (System.in);
int n = sc.nextInt();
while (n-- > 0) {
String str = sc.next();
String t = sc.next();
String ans = "";
int as = 0;
for (int i = 0 ;i < t.le... | 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 | 740aad71a14676cc1c75a9b66e393b96 | 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 {
public static PrintWriter out;
public static void main(String[] args)throws IOException{
Scanner sc=new Scanner();
out=new PrintWriter(System.out);
int t=sc.nextInt();
while(t-->0) {
String str=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 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 | fcd850f3afbfa5b0ad684591d80575a4 | 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.StringTokenizer;
import java.util.*;
public class Solution{
public static void main(String args[]){
FastReader sc = new FastReader();
int t = sc.nextInt();
StringBuilder sb ... | 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 | 6cf566c54b78ee82f64ef2267b897e88 | 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: Atuer
*/
public class Main
{
// ==== Solve Code ====//
static int INF = 2000000010;
public static void csh()
{
}
public static void main(String[] args) throws IOException
{
// csh();
int t = in.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 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 | 5a8cb9449dc70a72fa2da3a8f8dfef64 | 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: Atuer
*/
public class Main
{
// ==== Solve Code ====//
static int INF = 2000000010;
public static void csh()
{
}
public static void main(String[] args) throws IOException
{
// csh();
int t = in.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 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 | 7237b5f893275ee25acf93af9dcd73da | 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.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util... | 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 | 4aecaf3774037da127f56cab02be34c3 | 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.HashMap;
import java.util.HashSet;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// write your code h
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
// String[] arr = new String[651];
// for(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 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 | 4c63b39343253345e8ca5fcbc2c617e4 | 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 org.w3c.dom.ls.LSOutput;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int t = scan.nextInt();
while(t-- != 0){
String first = scan.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 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 | 13a0a0177f0efb6c705419b651fa75ee | 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 | //---#ON_MY_WAY---
//---#THE_SILENT_ONE---
import static java.lang.Math.*;
import java.io.*;
import java.math.*;
import java.util.*;
public class C {
static FastReader x = new FastReader();
static OutputStream outputStream = System.out;
static PrintWriter out = new PrintWriter(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 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 | 14b9eb4af5e9b7653243cf1abd4214a0 | 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;
/**
* @author Sabirov Jahongir
**/
public class Other {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
int test = cin.nextInt();
while (test -- > 0)
{
String first = cin.next();
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 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 | 36b58d1fc422df78a8f9a73934d8b9e8 | 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.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.*;
import java.lang.*;
import java.io.*;
public class codeforces_round_786_C {
static BufferedReade... | 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 | 342a8988cc29471592174d80181a432e | 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 CodeforcesRound786Div3;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class C {
public static void main(String[] args) {
FastReader fr = new FastReader();
int t = fr.nextInt();
w... | 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 | eac630acac4266bc9cb9a5bd86dff1fe | 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 Codeforces {
public static long power(int x, int y) {
long temp;
if (y == 0)
return 1;
if (y == 1)
return x;
temp = power(x, y / 2);
if (y % 2 == 0)
return temp * temp;
else
... | 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 | c04e207bc599d86b84b3f18c1fc92db0 | 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 {
public static void main(String[] args) {
// try {
// System.setIn(new FileInputStream("input.txt"));
// System.setOut(new PrintStream(new FileOutputStream("output.txt")));
// } catch (Exception e) {
// System.err.println("Error");
// }... | 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 | db2847fb94b88f80e58df33216072e81 | 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.PrintWriter;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
/*
*
1
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
b
*/
public class C {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
PrintWrit... | 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 | c9b263cb24bf8816b6ce834dff16d99f | 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.lang.*;
import java.math.BigInteger;
public class C_Infinite_Replacement {
static Scanner scn = new Scanner(System.in);
public static void iamganduwhocodes() {
String str1 = scn.next();
String str2 = scn.next();
long size = 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 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 | 321f70a18069127ac2155b47233ed876 | 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 Main2 {
static void solve() {
Scanner scan = new Scanner(System.in);
int t = scan.nextInt();
for (int i = 0; i < t; i++) {
// int a = scan.nextInt();
String s = scan.next();
String ss = scan.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 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 | fc0f38bf6d93f7006c7f9dbe64b3b726 | 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.util.*;
public class C {
public static long solve(Scanner sc) {
String s = sc.next();
String t = sc.next();
if (t.equals("a"))
return 1;
boolean bool = false;
int cnt = 0;
for (int i = 0; i < 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 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 | f93684e3a6437f43e57e12b23b567445 | 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 boolean prime[] = new boolean[1000001];
static Set<Long> cubes=new HashSet<>();
static
{
long N = 1000000000000L;
//
//
// for(int i=1;i*i<=n;i++)
// {
// long... | 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 | 2a1eb75d984b0ba57025fa4b771f8331 | 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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class C {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public 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 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 | c7b11463515c3eddec908352d7e3fa31 | 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 codechef; // 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 Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
BufferedReader br = new Buff... | 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 | 05c620610bcc4f104654a84e8e1e9ae7 | 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);
long tt = sc.nextLong();
while (tt-- > 0) {
String s = sc.next();
String t = sc.next();
long a = 0;
for (int i = 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 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 | f79139488929ba2abc596bc6ab136d2d | 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 ProbC {
public static void main(String[] args) throws IOException{
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
int cases = Integer.parseInt(bf.readLine());
for(int 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 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 | b6b31fee15ef1b162988507f60a3ca57 | 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.*;
import java.lang.Math.*;
public class Main {
static int fact(int i){
int ans = 1;
while(i!=0) {
ans *= i;
i--;
}
return ans;
}
public static void main(String[] args) 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 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 | 774de8429a1a9e25ce4872bc7d369063 | 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.util.function.DoubleToLongFunction;
public class Codeforces786{
static long mod = 1000000007L;
static MyScanner sc = new MyScanner();
static void solve() {
int x = sc.nextInt();
int y = sc.nextInt();
if(y%x!=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 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 | 08ebc0f06b7f01de6c3be2ef754d774f | 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 codechef; // 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 Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc = new Scanner(Syst... | 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 | fff0e57b8567c84dfbb74bc3020aff86 | 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 javax.swing.*;
import java.lang.reflect.Array;
import java.text.DecimalFormat;
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
import java.util.stream.Stream;
// Please name your class Main
public class Main {
static FastScanner fs=new FastScanner();
... | 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 | 15df75704eaad5d5e487fb63f5047336 | 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 InfiniteReplacement {
public static void main(String[] args) {
try {
FastReader in = new FastReader();
PrintWriter out = new PrintWriter(System.out);
int testcases = in.nextInt();
while (testcases-- > 0) {
String s = in.next(), t = 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 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 | d46ffdd74442878eb5d521ce72471a12 | 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.util.StringTokenizer;
public class InfReplacement implements Runnable {
public static void main(String [] args) {
new Thread(null, new InfReplacement(), "whatever", 1<<26).start();
}
public void run() {
FastScanner scanner = new F... | 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 | 0693a4ea5ad0ec3d3093256c321a01c3 | 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 {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
... | 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 | bcb9f15d067f5b3b63bde9872f5aaa6b | 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 C {
private static FastReader fr;
private static OutputStream out;
private static int mod = (int)(1e9+7);
private void solve() {
int t = fr.nextInt();
while(t-- > 0) {
int len = fr.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 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 | 757642d34a3397d70882e270064a90ca | 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 Main
{
public static void main(String args[])
{
FastScanner input = new FastScanner();
int tc = input.nextInt();
work:
while (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 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 | 48ee089bf10b7793017801305bb04ae9 | 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 {
public static int INF = 0x3f3f3f3f;
public static int mod = 1000000007;
public static int mod9 = 998244353;
public static void main(String args[]){
try {
PrintWriter o = new PrintWriter(System.out);
bool... | 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 | f0e24477c260ab5650a6ca6a896352ca | 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 MyClass{
public static void main(String[] args){
Scanner sc= new Scanner(System.in);
int n = sc.nextInt();
while(n > 0){
n--;
String s = sc.next();
String t = sc.next();
int s_a = s.length(), t_len = ... | 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 | c8dac4a1edd483cdbdfb97b5316aead9 | 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 Solution{
public static double getCombination(int m,int n){//C(n,m)=m!/(m-n)!n!
double c=1;
if(n==0||n==m){
return c;
}
int p=n;
for(int i=m-n+1;i<=m;i++){
c*=i;
while(c>=p&&p>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 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 | fa7fcdbaa3ee6645ea9ba956c759571e | 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 proj {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
sc.nextLine();
String s, t;
for(int i = 0; i <n;i++){
s = sc.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 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 | 3d01d59347ef1bce1f469dd5bdc11407 | 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.util.Map.Entry;
public class Main{
static long mod=(long)1e9+7;
static class FastReader{
BufferedReader br;
StringTokenizer st;
public FastReader(){
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 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 | 4b111500f3339cfdb874c4916bace1fa | 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.PrintWriter;
import java.util.*;
public class Main{
static int mod = (int)1e9+7;
static PrintWriter out;
static String[] memo;
... | 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 | f4f118ec32078ec2a02d9108118fcd18 | 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.*;
import java.util.*;
import java.io.*;
// You have that in you, you can do it........
public class Codeforces {
static FScanner sc = new FScanner();
static PrintWriter out = new PrintWriter(System.out);
static final Random random = new Random();
static long mod = 1000000007L;... | 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 | 888bc41e2b8f2544e67163d3a54e7810 | 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 sc=new Scanner(System.in);
int tt=sc.nextInt();
while (tt-->0){
String s=sc.next();
String t=sc.next();
int 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 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 | 4f009bd93cb08c85140cb8d218b03e41 | 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 CodeForces {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int t = s.nextInt();
while (t-- > 0) {
String str = s.next();
String T = s.next();
if (T.length() == 1 && T.cha... | 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 | cad6833b15e69e9c64095cdaadb22369 | 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 codechef; // 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 Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here... | 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 | 3bc771a5736c6184d3c404406da6d4be | 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 {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static PrintWriter out = new PrintWriter(System.out);
static StringTokenizer st = new StringTokenizer("");
static String next() 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 | 80522ca1f50e9cfecf790d6c268155cc | 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 implements Runnable {
BufferedReader in;
PrintWriter out;
StringTokenizer tok = new StringTokenizer("");
public static void main(String[] args) {
new Thread(null, new Main(), "", 256 * (1L << 20)).start();
}
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 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 | 069fb755ec5abbb05848e8bf38f9e159 | 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.concurrent.TimeUnit;
import java.io.*;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
public class C_Infinite_Replacement{
public static void solve(){
}
public static void main(String args[])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 | 37afc2cd78566b5ea67b0a9aa6033148 | 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 javafx.scene.control.Label;
public class C_Infinite_Replacement{
static Scanner sc = new Scanner(System.in);
// @Harshit Maurya
public static void reverse(int[] arr, int l, int r) {
int d = (r - l + 1) / 2;
for (int i = 0; i < d; i++) {
int t = arr[l + i];
ar... | 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 | b34719c4f429235c71a4004891eec4b5 | train_107.jsonl | 1651502100 | You are given three arrays $$$a$$$, $$$b$$$ and $$$c$$$. Initially, array $$$a$$$ consists of $$$n$$$ elements, arrays $$$b$$$ and $$$c$$$ are empty.You are performing the following algorithm that consists of two steps: Step $$$1$$$: while $$$a$$$ is not empty, you take the last element from $$$a$$$ and move it in th... | 256 megabytes | import java.util.Arrays;
import java.util.Scanner;
public class ABCSort {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
for (int i = 0; i < n; i++) {
int test = s.nextInt();
int[] a = new int[test];
... | Java | ["3\n\n4\n\n3 1 5 3\n\n3\n\n3 2 1\n\n1\n\n7331"] | 2 seconds | ["YES\nNO\nYES"] | NoteIn the first test case, we can do the following for $$$a = [3, 1, 5, 3]$$$:Step $$$1$$$: $$$a$$$$$$[3, 1, 5, 3]$$$$$$\Rightarrow$$$$$$[3, 1, 5]$$$$$$\Rightarrow$$$$$$[3, 1]$$$$$$\Rightarrow$$$$$$[3]$$$$$$\Rightarrow$$$$$$[]$$$$$$b$$$$$$[]$$$$$$[\underline{3}]$$$$$$[3, \underline{5}]$$$$$$[3, \underline{1}, 5]$$$$$$... | Java 17 | standard input | [
"constructive algorithms",
"implementation",
"sortings"
] | 95b35c53028ed0565684713a93910860 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the length of array $$$a$$$. The second line of each test case contains $$$n$$$... | 1,200 | For each test, print YES (case-insensitive), if you can make array $$$c$$$ sorted in non-decreasing order. Otherwise, print NO (case-insensitive). | standard output | |
PASSED | d3b3acf4e1ecfa5bed900cde34e07931 | train_107.jsonl | 1651502100 | You are given three arrays $$$a$$$, $$$b$$$ and $$$c$$$. Initially, array $$$a$$$ consists of $$$n$$$ elements, arrays $$$b$$$ and $$$c$$$ are empty.You are performing the following algorithm that consists of two steps: Step $$$1$$$: while $$$a$$$ is not empty, you take the last element from $$$a$$$ and move it in th... | 256 megabytes | import java.util.Arrays;
import java.util.Scanner;
public class ABCSort {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
for (int i = 0; i < n; i++) {
int test = s.nextInt();
int[] a = new int[test];
... | Java | ["3\n\n4\n\n3 1 5 3\n\n3\n\n3 2 1\n\n1\n\n7331"] | 2 seconds | ["YES\nNO\nYES"] | NoteIn the first test case, we can do the following for $$$a = [3, 1, 5, 3]$$$:Step $$$1$$$: $$$a$$$$$$[3, 1, 5, 3]$$$$$$\Rightarrow$$$$$$[3, 1, 5]$$$$$$\Rightarrow$$$$$$[3, 1]$$$$$$\Rightarrow$$$$$$[3]$$$$$$\Rightarrow$$$$$$[]$$$$$$b$$$$$$[]$$$$$$[\underline{3}]$$$$$$[3, \underline{5}]$$$$$$[3, \underline{1}, 5]$$$$$$... | Java 17 | standard input | [
"constructive algorithms",
"implementation",
"sortings"
] | 95b35c53028ed0565684713a93910860 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Next $$$t$$$ cases follow. The first line of each test case contains the single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the length of array $$$a$$$. The second line of each test case contains $$$n$$$... | 1,200 | For each test, print YES (case-insensitive), if you can make array $$$c$$$ sorted in non-decreasing order. Otherwise, print NO (case-insensitive). | standard output |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.