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
1659313bc3370332dc38a0658b0ffd10
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; import java.util.*; public class codeforcesA{ static class FastReader { BufferedReader br; StringTokenizer st; pub...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
c13097d48590fd982f10e26d76ddb5b8
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class A_AB_Balance { static int M = 1_000_000_007; static final PrintWriter out =new PrintWriter(System.out); static final FastReader fs = new FastReader(); static boolean prime[]; public static void main (String[] ...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
5a9f9c6ff567c743818085756c866f75
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.*; import java.util.*; /* */ public class A{ static FastReader sc=null; public static void main(String[] args) { sc=new FastReader(); int t=sc.nextInt(); for(int tt=0;tt<t;tt++) { char a[]=sc.next().toCharArray(); int cnt=0,n=a.length,id=n-1; for(int i=...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
469998f8bc68b713ee655660a6674dae
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { //br = new BufferedReader(new FileReader("input.txt")); //out = new PrintWriter("output.txt"); int t = 1; t = nextInt(); while (t-- != 0) { ...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
06b5da61cce8f78b13223ca2280134c5
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; import java.math.BigInteger; /* Name of the class has to be "Main" only if the class is public. */ public class Codechef { public static int countFreq(String str, String txt) { int index...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
ff011256d4cea4ac9c5fbadafe3c52fa
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
//package 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 IOException ...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
c820220020e2677224d49026a63fea5f
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n=sc.nextInt(); char b[] = {'a','b'}; char c[] = {'b','a'}; for(int j=0;j<n;j++) { String str = sc.next(); char a[] = s...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
a5c48a8496879691fa592d933967dde2
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
//CP- MASS_2701 import java.util.*; import java.io.*; public class A_AB_Balance { static FastReader in=new FastReader(); static final Random random=new Random(); static long mod=1000000007L; static HashMap<String,Integer>map=new HashMap<>(); public static void main(String args[]) throw...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
163af23db6487100ae9e026f9c0f957f
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class A { public static void main(String[] args) { // TODO Auto-generated method stub FastScanner fs=new FastScanner(); int t=fs.nextInt(); ...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
6e6f683790aac55f7eb3ba3bb48517e2
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.lang.reflect.Array; import java.util.*; import java.io.*; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static void main(String[] args) { // write your code here PrintWriter out = new PrintWriter(System.out); FastReader sc...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
ac423678b3ccfd87138021544d6a2974
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { int z = nextInt(); for (int ggg = 0; ggg < z; ggg++) { String s = nextToken(); if (s.charAt(0) != s.charAt(s.length()-1)) s = s.substring(0, s.length()-1) + (s...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
0e29922f42e66d7f65c4c4891a238dad
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.awt.Container; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; import java.util.*; public class Main { public static boolean ch...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
6e7342e9fa37e9313747a268a8e28384
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.awt.Container; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; import java.util.*; public class Main { public static boolean ch...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
435c632af7f6379292d1425486d29b33
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.*; public class Contest_yandexA{ public static void main(String[] args) { Scanner input = new Scanner(System.in); int t = input.nextInt(); for(int tt = 0;tt<t;tt++){ String s = input.next(); int count1 = 0; int count2 = 0; for(int i = 0;i<s.length()-1;i++){ if(s.subst...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
988dcc61aea0439bc25272330905b980
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
/* * akshaygupta26 */ import java.io.*; import java.util.*; public class A { static long mod =(long)(1e9+7); public static void main(String[] args) { FastReader sc=new FastReader(); StringBuilder ans=new StringBuilder(); int test=sc.nextInt(); outer:while(test-->0) { String s=s...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
b394d1fc6a45c80e7820c16b32d3d6d7
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.*; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Scanner; public class Templ { static StreamTokenizer in; static int nextInt() throws IOException { in.nextToken(); return (int) in.nval; } public static void ma...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
9cf08a53e0e2bdacc2a39d0ba3e6f670
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Solution { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); whi...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
bedb9bc3da78e13534f2e9cac44bcbe7
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.*; import java.util.*; public class M { static Scanner scanner=new Scanner(System.in); static BufferedReader bf=new BufferedReader(new InputStreamReader(System.in)); public static void main(String[] args) throws IOException { int t=scanner.nextInt(); while(t-->0) { char a[]=scann...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
9b69af177b863beec6d5fd56f60318f2
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.*; import java.io.*; public class materialize { public static void main(String[] args) throws java.lang.Exception { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int t=Integer.parseInt(br.readLine()); while(t>0){ String s=br.r...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
4c31355e151d98ff1a5661c8e8fd5268
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.Scanner; public class AB_Balance { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int tc = Integer.parseInt(scanner.next()); while(tc-- > 0) { String s = scanner.next(); if(s.charAt(0) == s.charAt(s.length()-1))System.out.println(...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
bdd4701c5758bc27cf6d3a789a3bcda9
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.Scanner; public class AB_Balance { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int tc = Integer.parseInt(scanner.next()); while(tc-- > 0) { String s = scanner.next(); if(s.charAt(0) == s.charAt(s.length()-1))System.out.println(...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
e254ff1351b5273cdca7ed19fa6ea10b
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String s = ""; int ab = 0, ba = 0; for (int j = 0; j < n; j++) { s = sc.next(); ab = 0; ba ...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
7982913aa4fda10efac3794ca2e73468
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.sql.Time; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
bd90a6489cd2b5d8e1e5a8cb6e5e5657
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.PrintWriter; import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int tc = sc.nextInt(); while(tc-->0){ char[] arr = sc.next().toCharArr...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
310a4734222d629b1a73b7e78e55e13f
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.Scanner; public class main { public static void main(String[] args) { Scanner input = new Scanner (System.in); int n = input.nextInt(); while(n-->0) { int ab=0; int ba=0; String s = input.next(); char[] c = s.toCharArray(); for(int i=0; i<s.length()-1; i++) { ...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
eaea137893b1d12c361cd9c9e8b8a8a5
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Main { /* Checks if a string is empty ("") or null. */ public static boolean isEmpty(String s) { return s == null || s.length() == 0; } /* Counts how many times the substring appears in the larger string. */ ...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
53ce5c48a50747608770e0cecc0b18c7
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.*; public class bal { public static void main(String[] args) { Scanner s = new Scanner(System.in); int t = s.nextInt(); while(t-->0){ String str = s.next(); int one = abcount(str); int two = bacount(str); if(one == two...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
cd1772f4e490e958eb55fd924ba9568f
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.*; import java.util.*; public class P1 { public static void main(String[] args) { FastIO io = new FastIO(); int t = io.nextInt(); while (t --> 0) { String s = io.next(); if (s.charAt(0) == s.charAt(s.length()-1)) { io.println(s); } els...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
9ed3662eb16f65f1940be7e566dc16fb
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.Scanner; /** * Accomplished using the EduTools plugin by JetBrains https://plugins.jetbrains.com/plugin/10081-edutools * * To modify the template, go to Preferences -> Editor -> File and Code Templates -> Other */ public class Main { public static void main(String[] args) { Sca...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
93a1baba1ec3b4bea25bce838448aef5
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.*; public class A { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int t = scanner.nextInt(); String s; for (int i = 0; i < t; i++) { s = scanner.next(); System.out.println(solve(s)); } } private static String solve(String s) { ...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
f034aae9b57ec6611f6ace7c430be118
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws IOException { Scanner sc =new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int t = sc.nextInt(); while(t-->0){ String s= sc.next(); ...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
a41fc1eb6d75b909ed8b7049bccea7ef
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Codechef { public static void main(String[] args) throws java.lang.Exception { FastReader in = new FastReader(System.in); StringBuilder sb = new StringBuilder(); int t = 1; t = in.nextInt(); while (t > 0) { --t; ...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
07ca56c670b6edd665ec5a9ab54ef78a
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
// Piyush Nagpal import java.util.*; import java.io.*; public class C{ static int MOD=1000000007; static PrintWriter pw; static FastReader sc; static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { b...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
dc5b7cc32e63a7949f76eca58e8b3813
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
// Piyush Nagpal import java.util.*; import java.io.*; public class C{ static int MOD=1000000007; static PrintWriter pw; static FastReader sc; static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { b...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
903cf28d8f0b0ec3f83a3d7d444932dd
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.*; import java.io.*; public class a{ public static void main(String[] args){ JS scan = new JS(); PrintWriter out = new PrintWriter(System.out); int t = scan.nextInt(); for(int q = 1; q <= t; q++){ char[] s = scan.next().toCharArray(); ...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
ee28ad85d90452613f3bd1cdbe4ff0b0
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class CodeChef{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { StringBuilder sb=new StringBuilder(sc.next()); int ab=0; int ba=0; char last=sb.charAt(0); for(int i=1;...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
a0fed5d027495e0495716f914e455957
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Q129102021 { public static void main(String[] args) throws Exception { BufferedReader sc = new BufferedReader(new InputStreamReader(System.in)); int test=Integer.parseInt(sc.readLine()); while...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
66b1f33be0e2d6cc97e0ef1f2333db23
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.*; import java.io.*; public class A { public static void main(String[] args) { Scanner in = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int t = in.nextInt(); for (int tt = 0; tt < t; tt++) { char[] s = in.next().toCharA...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
bcd763fe9d0a473b13d3dd90e71864a8
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
//package contests.div2.edu116; import java.io.*; import java.util.Arrays; import java.util.HashMap; import java.util.StringTokenizer; public class A { static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); static int fasterScanner() { try { boolean in = false; ...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
bc4ff14c5c8d69a2307b1e4c9d022068
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; // System.out is a PrintStream import java.util.InputMismatchException; import java.util.ArrayDeque; public class A { private static int MOD = (int)1e9 + 7, mod = 99_82_44_353; private static double PI = 3.14159265358979323846...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
fe8de5cffbe72f5b3a5d1ae7d8c53da4
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.*; import java.util.Scanner; public class A { static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); static PrintWriter pr = new PrintWriter(new OutputStreamWriter(System.out)); static Scanner sc = new Scanner(System.in); public st...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
e2a2c3a1ff73158c8a418bfab9f03537
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class MyAnswer { static class FastScanner{ //10^5 -- .15 sec && 4*10^6 ---> .86 sec BufferedReader br; StringTokenizer st; public FastScanner(){ br = new BufferedReader(new InputStrea...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
ce0780e386825732f645ba6b12e7061e
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.*; public class Main { public static void main(String args[]) { // System.out.println("Hello World!"); Scanner scn = new Scanner(System.in); int n = scn.nextInt(); while(n-->0){ String str= scn.next(); solve(str); } } pub...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
f10f5eaf9457f422e3c2b7670c49cb84
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.*; import java.util.*; public class edu_116_a { public static void main(String args[]){ FScanner in = new FScanner(); PrintWriter out = new PrintWriter(System.out); int t = in.nextInt(); while(t-->0) { String s=in.next(); char ch[]=s.toCharArray(); int c=0; ...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
65978c919a3d1843398251e9b1d8f880
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import static java.lang.Math.*; import java.io.*; import java.math.*; import java.util.*; public class cf1 { static FastReader x = new FastReader(); static OutputStream outputStream = System.out; static PrintWriter out = new PrintWriter(outputStream); /*---------------------------------------CODE STARTS...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
15f607b861ccc73ddf9a9dc692f98f0e
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.*; import java.io.*; import java.math.BigInteger; //code by tishrah_ public class _practise { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
7b7991827caf2b3261929ce008021bb2
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class Main { static int i, j, k, n, m, t, y, x, sum = 0; static long mod = 998244353; static FastScanner fs = new FastScanner(); static PrintW...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
b1da2b8e13f0a8820837039951494403
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.*; import java.util.*; public class MainClass { public static void main(String[] args) { Reader in = new Reader(System.in); int t = in.nextInt(); StringBuilder stringBuilder = new StringBuilder(); while (t-- > 0) { String ss = in.next(); ...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
975334dd1f5e221461dd3435b9c8f81f
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.*; import java.util.*; import java.math.BigDecimal; import java.math.*; public class Main{ public static void main(String[] args) { TaskA solver = new TaskA(); // boolean[]prime=seive(3*100001); int t = in.nextInt(); for (int i = 1; i <= t ; i++...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
0fbdadfe2b4b7be2d1dd8eafcdac5ec1
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { int t = nextInt(); for (int i = 0; i < t; i++) { String s = nextToken(); int count1 = 0; int count2 = 0; for (int j = 0; j ...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
b72a8a500422dc158dc3134554c45d9e
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.*; import java.util.*; public final class Main { static PrintWriter out = new PrintWriter(System.out); static FastReader in = new FastReader(); static Pair[] moves = new Pair[]{new Pair(-1, 0), new Pair(0, 1), new Pair(1, 0), new Pair(0, -1)}; static int mod = (int) (1e9 + 7);...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
9d8096ec23fce571fe5b011b3eb35c3a
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
/*Everything is Hard * Before Easy * Jai Mata Dii */ import java.util.*; import java.io.*; public class Main { static class FastReader{ BufferedReader br;StringTokenizer st;public FastReader(){br = new BufferedReader(new InputStreamReader(System.in));}String next(){while (st == null || !st.hasMor...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
f001fdd66843f93143c2f5038119afce
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.*; import java.util.*; public class A { public static void main(String[] args)throws IOException { FastScanner scan = new FastScanner(); PrintWriter output = new PrintWriter(System.out); int t = scan.nextInt(); for(int tt = 0;tt<t;tt++) { char arr[] = scan.next().toCharArray(...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
00ae30d0364ff4b31f2863c6b2dce712
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.math.BigInteger; public final class A { static PrintWriter out = new PrintWriter(System.out); static StringBuilder ans=new StringBuilder(); static FastReader in=new FastReader(); static ArrayList<Integer> g[]; static long ...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
39da0c1f4f4f4cceeeb1011032d33e64
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
/** * check out my youtube channel sh0rkyboy * https://tinyurl.com/zdxe2y4z * I do screencasts, solutions, and other fun stuff in the future */ import java.util.*; import java.io.*; import static java.lang.Math.min; import static java.lang.Math.abs; import static java.lang.Math.max; public class EdA { ...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
b0678197385fd8485b58acb350aa7735
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for (int tc = 0; tc < t; ++tc) { String s = sc.next(); System.out.println(solve(s)); } sc.close(); } static String ...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
1f1228333a6dc6718e128cd33dc14591
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class balance { public static void main (String[] args) throws java.lang.Exception { try { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { String s=sc.next(); int n=s.length(); if(s.charA...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
d6a71b595fd59fb198d39f805f94e08a
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.math.BigInteger; import java.util.*; public class Main3 { public static void main(String[] args) throws IOException { int t =nextInt(); for (int i = 0; i < t; i++) { String s = nextToken(); if(s.charAt(...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
c947af0c3e3def495bcd412da8db4cd3
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.*; public class Test { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int T=sc.nextInt(); while(T-->0) { String s=sc.next(); char a[]=s.toCharArray(); if(a[0]!=a[a.length-1]) { a[0]=a[a.length-1]; } System.out.println(a); } } }
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
ecaaa50e26f001abc0f40d6b50c9413c
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.*; import java.io.*; public class Main { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { try { br = new BufferedReader( new FileReader("input.rtf")); PrintStrea...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
d15a707888d47c9abbcb47125b56c220
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.util.Scanner; public class A1606 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int T = in.nextInt(); for (int t=0; t<T; t++) { char[] S = in.next().toCharArray(); if (S[0] != S[S.length-1]) { S[...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
766be4a54cd192e1d81842b9302e6d50
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
//package com.company; import java.util.*; import static java.lang.Math.*; public class Practice { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-- > 0) { String s = sc.next(); int n = s.length(); ...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
88295852cce1bdfd3f5e4fc2bb31d913
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
/** * */ import java.util.Scanner; /** * @author rohithvazhathody * * */ public class ABBalance { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int test = sc.nextInt(); while (test-- > 0) { String s = sc.next(); int length = s.length(); if (s....
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
d7b72f648dc63acd4e6fd2012b41d058
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.*; import java.util.*; //import javafx.util.*; public class Main { static FastReader in = new FastReader(); public static void main(String args[])throws IOException { /* * star,rope,TPST * BS,LST,MS,MQ */ int t = i(); while(t-- > 0){ String s = in.nextL...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
75116d5a6c76a85ae3c12f21466fc812
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.lang.Math; import java.lang.String; import java.util.Arrays; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Scanner; import java.util.Collections; import java...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
9b8faad696051ac9fc4439ea7c4f5bad
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.*; import java.util.*; public class PracticeProblems { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); PrintWriter out = new P...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
8297d318e5fbedb6e3e3972ccb718e58
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.*; import java.util.*; public class temp { 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 s=sc.next(); ...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
08248d44c46d00ad02384fc7fd549c10
train_108.jsonl
1635518100
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters a and/or b.Let $$$\operatorname{AB}(s)$$$ be the number of occurrences of string ab in $$$s$$$ as a substring. Analogically, $$$\operatorname{BA}(s)$$$ is the number of occurrences of ba in $$$s$$$ as a substring.In one step, you can choose any i...
256 megabytes
import java.io.*; import java.util.*; public class ABBalance{ static long mod = 1000000007L; static MyScanner sc = new MyScanner(); static void solve() { String str = sc.next(); if(str.charAt(0)==str.charAt(str.length()-1)){ out.println(str); }else{ ...
Java
["4\nb\naabbbabaa\nabbb\nabbaab"]
2 seconds
["b\naabbbabaa\nbbbb\nabbaaa"]
NoteIn the first test case, both $$$\operatorname{AB}(s) = 0$$$ and $$$\operatorname{BA}(s) = 0$$$ (there are no occurrences of ab (ba) in b), so can leave $$$s$$$ untouched.In the second test case, $$$\operatorname{AB}(s) = 2$$$ and $$$\operatorname{BA}(s) = 2$$$, so you can leave $$$s$$$ untouched. In the third test ...
Java 8
standard input
[ "strings" ]
351ffff1dfe1bc1762f062f612463759
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 100$$$, where $$$|s|$$$ is the length of the string $$$s$$$), con...
900
For each test case, print the resulting string $$$s$$$ with $$$\operatorname{AB}(s) = \operatorname{BA}(s)$$$ you'll get making the minimum number of steps. If there are multiple answers, print any of them.
standard output
PASSED
2f56833589dd4077e84eb3b8156afe65
train_108.jsonl
1635518100
Berland State University has received a new update for the operating system. Initially it is installed only on the $$$1$$$-st computer.Update files should be copied to all $$$n$$$ computers. The computers are not connected to the internet, so the only way to transfer update files from one computer to another is to copy...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintStream; import java.io.PrintWriter; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; import java.util.StringToke...
Java
["4\n8 3\n6 6\n7 1\n1 1"]
2 seconds
["4\n3\n6\n0"]
NoteLet's consider the test cases of the example: $$$n=8$$$, $$$k=3$$$: during the first hour, we copy the update files from the computer $$$1$$$ to the computer $$$2$$$; during the second hour, we copy the update files from the computer $$$1$$$ to the computer $$$3$$$, and from the computer $$$2$$$ to the computer...
Java 8
standard input
[ "greedy", "implementation", "math" ]
5df6eb50ead22b498bea69bb84341c06
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Each test case consists of a single line that contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 10^{18}$$$) — the number of computers and the number of patch cables.
1,100
For each test case print one integer — the minimum number of hours required to copy the update files to all $$$n$$$ computers.
standard output
PASSED
85fe993698d3e663382fff0c1aca6c47
train_108.jsonl
1635518100
Berland State University has received a new update for the operating system. Initially it is installed only on the $$$1$$$-st computer.Update files should be copied to all $$$n$$$ computers. The computers are not connected to the internet, so the only way to transfer update files from one computer to another is to copy...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintStream; import java.io.PrintWriter; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; import java.util.StringToke...
Java
["4\n8 3\n6 6\n7 1\n1 1"]
2 seconds
["4\n3\n6\n0"]
NoteLet's consider the test cases of the example: $$$n=8$$$, $$$k=3$$$: during the first hour, we copy the update files from the computer $$$1$$$ to the computer $$$2$$$; during the second hour, we copy the update files from the computer $$$1$$$ to the computer $$$3$$$, and from the computer $$$2$$$ to the computer...
Java 8
standard input
[ "greedy", "implementation", "math" ]
5df6eb50ead22b498bea69bb84341c06
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Each test case consists of a single line that contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 10^{18}$$$) — the number of computers and the number of patch cables.
1,100
For each test case print one integer — the minimum number of hours required to copy the update files to all $$$n$$$ computers.
standard output
PASSED
e6eeeb9fc978dd466a3e104935027d96
train_108.jsonl
1635518100
Berland State University has received a new update for the operating system. Initially it is installed only on the $$$1$$$-st computer.Update files should be copied to all $$$n$$$ computers. The computers are not connected to the internet, so the only way to transfer update files from one computer to another is to copy...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintStream; import java.io.PrintWriter; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; import java.util.StringToke...
Java
["4\n8 3\n6 6\n7 1\n1 1"]
2 seconds
["4\n3\n6\n0"]
NoteLet's consider the test cases of the example: $$$n=8$$$, $$$k=3$$$: during the first hour, we copy the update files from the computer $$$1$$$ to the computer $$$2$$$; during the second hour, we copy the update files from the computer $$$1$$$ to the computer $$$3$$$, and from the computer $$$2$$$ to the computer...
Java 8
standard input
[ "greedy", "implementation", "math" ]
5df6eb50ead22b498bea69bb84341c06
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Each test case consists of a single line that contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 10^{18}$$$) — the number of computers and the number of patch cables.
1,100
For each test case print one integer — the minimum number of hours required to copy the update files to all $$$n$$$ computers.
standard output
PASSED
cd5244a255adb31b70b8e2f16393ae0a
train_108.jsonl
1635518100
Berland State University has received a new update for the operating system. Initially it is installed only on the $$$1$$$-st computer.Update files should be copied to all $$$n$$$ computers. The computers are not connected to the internet, so the only way to transfer update files from one computer to another is to copy...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintStream; import java.io.PrintWriter; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; import java.util.StringToke...
Java
["4\n8 3\n6 6\n7 1\n1 1"]
2 seconds
["4\n3\n6\n0"]
NoteLet's consider the test cases of the example: $$$n=8$$$, $$$k=3$$$: during the first hour, we copy the update files from the computer $$$1$$$ to the computer $$$2$$$; during the second hour, we copy the update files from the computer $$$1$$$ to the computer $$$3$$$, and from the computer $$$2$$$ to the computer...
Java 8
standard input
[ "greedy", "implementation", "math" ]
5df6eb50ead22b498bea69bb84341c06
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Each test case consists of a single line that contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 10^{18}$$$) — the number of computers and the number of patch cables.
1,100
For each test case print one integer — the minimum number of hours required to copy the update files to all $$$n$$$ computers.
standard output
PASSED
1a701a722c19f8a137c56c391c2f82be
train_108.jsonl
1635518100
Berland State University has received a new update for the operating system. Initially it is installed only on the $$$1$$$-st computer.Update files should be copied to all $$$n$$$ computers. The computers are not connected to the internet, so the only way to transfer update files from one computer to another is to copy...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintStream; import java.io.PrintWriter; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; import java.util.StringToke...
Java
["4\n8 3\n6 6\n7 1\n1 1"]
2 seconds
["4\n3\n6\n0"]
NoteLet's consider the test cases of the example: $$$n=8$$$, $$$k=3$$$: during the first hour, we copy the update files from the computer $$$1$$$ to the computer $$$2$$$; during the second hour, we copy the update files from the computer $$$1$$$ to the computer $$$3$$$, and from the computer $$$2$$$ to the computer...
Java 8
standard input
[ "greedy", "implementation", "math" ]
5df6eb50ead22b498bea69bb84341c06
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Each test case consists of a single line that contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 10^{18}$$$) — the number of computers and the number of patch cables.
1,100
For each test case print one integer — the minimum number of hours required to copy the update files to all $$$n$$$ computers.
standard output
PASSED
388c19ccd7bcd8881f407205503628cc
train_108.jsonl
1635518100
Berland State University has received a new update for the operating system. Initially it is installed only on the $$$1$$$-st computer.Update files should be copied to all $$$n$$$ computers. The computers are not connected to the internet, so the only way to transfer update files from one computer to another is to copy...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintStream; import java.io.PrintWriter; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; import java.util.StringToke...
Java
["4\n8 3\n6 6\n7 1\n1 1"]
2 seconds
["4\n3\n6\n0"]
NoteLet's consider the test cases of the example: $$$n=8$$$, $$$k=3$$$: during the first hour, we copy the update files from the computer $$$1$$$ to the computer $$$2$$$; during the second hour, we copy the update files from the computer $$$1$$$ to the computer $$$3$$$, and from the computer $$$2$$$ to the computer...
Java 8
standard input
[ "greedy", "implementation", "math" ]
5df6eb50ead22b498bea69bb84341c06
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Each test case consists of a single line that contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 10^{18}$$$) — the number of computers and the number of patch cables.
1,100
For each test case print one integer — the minimum number of hours required to copy the update files to all $$$n$$$ computers.
standard output
PASSED
25aabd10cae5a2b25dea106e05dd4dd5
train_108.jsonl
1635518100
Berland State University has received a new update for the operating system. Initially it is installed only on the $$$1$$$-st computer.Update files should be copied to all $$$n$$$ computers. The computers are not connected to the internet, so the only way to transfer update files from one computer to another is to copy...
256 megabytes
import java.util.*; import static java.lang.Math.*; import java.awt.Point; import java.io.*; public class Exercise { static Scanner sc = new Scanner(System.in); static public void solve() { long n = sc.nextLong(); long k = sc.nextLong(); long ans = 0; long cur = 1; while(cur < k...
Java
["4\n8 3\n6 6\n7 1\n1 1"]
2 seconds
["4\n3\n6\n0"]
NoteLet's consider the test cases of the example: $$$n=8$$$, $$$k=3$$$: during the first hour, we copy the update files from the computer $$$1$$$ to the computer $$$2$$$; during the second hour, we copy the update files from the computer $$$1$$$ to the computer $$$3$$$, and from the computer $$$2$$$ to the computer...
Java 8
standard input
[ "greedy", "implementation", "math" ]
5df6eb50ead22b498bea69bb84341c06
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Each test case consists of a single line that contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 10^{18}$$$) — the number of computers and the number of patch cables.
1,100
For each test case print one integer — the minimum number of hours required to copy the update files to all $$$n$$$ computers.
standard output
PASSED
f2a241f54f4bc2fa5c23bb8f89c9ec72
train_108.jsonl
1635518100
Berland State University has received a new update for the operating system. Initially it is installed only on the $$$1$$$-st computer.Update files should be copied to all $$$n$$$ computers. The computers are not connected to the internet, so the only way to transfer update files from one computer to another is to copy...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Java
["4\n8 3\n6 6\n7 1\n1 1"]
2 seconds
["4\n3\n6\n0"]
NoteLet's consider the test cases of the example: $$$n=8$$$, $$$k=3$$$: during the first hour, we copy the update files from the computer $$$1$$$ to the computer $$$2$$$; during the second hour, we copy the update files from the computer $$$1$$$ to the computer $$$3$$$, and from the computer $$$2$$$ to the computer...
Java 8
standard input
[ "greedy", "implementation", "math" ]
5df6eb50ead22b498bea69bb84341c06
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Each test case consists of a single line that contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 10^{18}$$$) — the number of computers and the number of patch cables.
1,100
For each test case print one integer — the minimum number of hours required to copy the update files to all $$$n$$$ computers.
standard output
PASSED
e7a4954049ce00b630a619980451cb24
train_108.jsonl
1635518100
Berland State University has received a new update for the operating system. Initially it is installed only on the $$$1$$$-st computer.Update files should be copied to all $$$n$$$ computers. The computers are not connected to the internet, so the only way to transfer update files from one computer to another is to copy...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; public class Training { public static void main(String[] args) throws IOException { Scanner sc =...
Java
["4\n8 3\n6 6\n7 1\n1 1"]
2 seconds
["4\n3\n6\n0"]
NoteLet's consider the test cases of the example: $$$n=8$$$, $$$k=3$$$: during the first hour, we copy the update files from the computer $$$1$$$ to the computer $$$2$$$; during the second hour, we copy the update files from the computer $$$1$$$ to the computer $$$3$$$, and from the computer $$$2$$$ to the computer...
Java 8
standard input
[ "greedy", "implementation", "math" ]
5df6eb50ead22b498bea69bb84341c06
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Each test case consists of a single line that contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 10^{18}$$$) — the number of computers and the number of patch cables.
1,100
For each test case print one integer — the minimum number of hours required to copy the update files to all $$$n$$$ computers.
standard output
PASSED
4bddb4c1adc92eef6dc24edb7556249f
train_108.jsonl
1635518100
Berland State University has received a new update for the operating system. Initially it is installed only on the $$$1$$$-st computer.Update files should be copied to all $$$n$$$ computers. The computers are not connected to the internet, so the only way to transfer update files from one computer to another is to copy...
256 megabytes
import java.io.*; import java.util.*; public class btry { //--------------------------INPUT READER--------------------------------// static class fs { public BufferedReader br; StringTokenizer st = new StringTokenizer(""); public fs() { this(System.in); } public fs(In...
Java
["4\n8 3\n6 6\n7 1\n1 1"]
2 seconds
["4\n3\n6\n0"]
NoteLet's consider the test cases of the example: $$$n=8$$$, $$$k=3$$$: during the first hour, we copy the update files from the computer $$$1$$$ to the computer $$$2$$$; during the second hour, we copy the update files from the computer $$$1$$$ to the computer $$$3$$$, and from the computer $$$2$$$ to the computer...
Java 8
standard input
[ "greedy", "implementation", "math" ]
5df6eb50ead22b498bea69bb84341c06
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Each test case consists of a single line that contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 10^{18}$$$) — the number of computers and the number of patch cables.
1,100
For each test case print one integer — the minimum number of hours required to copy the update files to all $$$n$$$ computers.
standard output
PASSED
dbaac6a493195a098cb1497353dea345
train_108.jsonl
1635518100
Berland State University has received a new update for the operating system. Initially it is installed only on the $$$1$$$-st computer.Update files should be copied to all $$$n$$$ computers. The computers are not connected to the internet, so the only way to transfer update files from one computer to another is to copy...
256 megabytes
import java.util.*; import java.io.*; public class UpdateFiles { public static void main(String[] args) throws IOException { BufferedReader infile = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter outfile = new BufferedWriter(new OutputStreamWriter(System.out)); ...
Java
["4\n8 3\n6 6\n7 1\n1 1"]
2 seconds
["4\n3\n6\n0"]
NoteLet's consider the test cases of the example: $$$n=8$$$, $$$k=3$$$: during the first hour, we copy the update files from the computer $$$1$$$ to the computer $$$2$$$; during the second hour, we copy the update files from the computer $$$1$$$ to the computer $$$3$$$, and from the computer $$$2$$$ to the computer...
Java 8
standard input
[ "greedy", "implementation", "math" ]
5df6eb50ead22b498bea69bb84341c06
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Each test case consists of a single line that contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 10^{18}$$$) — the number of computers and the number of patch cables.
1,100
For each test case print one integer — the minimum number of hours required to copy the update files to all $$$n$$$ computers.
standard output
PASSED
123ac16a0b6f7767d97ea8671c589a95
train_108.jsonl
1635518100
Berland State University has received a new update for the operating system. Initially it is installed only on the $$$1$$$-st computer.Update files should be copied to all $$$n$$$ computers. The computers are not connected to the internet, so the only way to transfer update files from one computer to another is to copy...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class Main { public static void main(String[] args) { FastReader scan = new FastReader(); PrintWriter out = new PrintWriter(System.out); Solution solve = new Solution(); int t = 1; t = sc...
Java
["4\n8 3\n6 6\n7 1\n1 1"]
2 seconds
["4\n3\n6\n0"]
NoteLet's consider the test cases of the example: $$$n=8$$$, $$$k=3$$$: during the first hour, we copy the update files from the computer $$$1$$$ to the computer $$$2$$$; during the second hour, we copy the update files from the computer $$$1$$$ to the computer $$$3$$$, and from the computer $$$2$$$ to the computer...
Java 8
standard input
[ "greedy", "implementation", "math" ]
5df6eb50ead22b498bea69bb84341c06
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Each test case consists of a single line that contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 10^{18}$$$) — the number of computers and the number of patch cables.
1,100
For each test case print one integer — the minimum number of hours required to copy the update files to all $$$n$$$ computers.
standard output
PASSED
e77d04332bc2292723b0dbf4f058d6a0
train_108.jsonl
1635518100
Berland State University has received a new update for the operating system. Initially it is installed only on the $$$1$$$-st computer.Update files should be copied to all $$$n$$$ computers. The computers are not connected to the internet, so the only way to transfer update files from one computer to another is to copy...
256 megabytes
/*##################################################### ################ >>>> Diaa12360 <<<< ################## ################ Just Nothing ################## ############ If You Need it, Fight For IT; ############ ####################.-. 1 5 9 2 .-.#################### ###################################...
Java
["4\n8 3\n6 6\n7 1\n1 1"]
2 seconds
["4\n3\n6\n0"]
NoteLet's consider the test cases of the example: $$$n=8$$$, $$$k=3$$$: during the first hour, we copy the update files from the computer $$$1$$$ to the computer $$$2$$$; during the second hour, we copy the update files from the computer $$$1$$$ to the computer $$$3$$$, and from the computer $$$2$$$ to the computer...
Java 8
standard input
[ "greedy", "implementation", "math" ]
5df6eb50ead22b498bea69bb84341c06
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Each test case consists of a single line that contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 10^{18}$$$) — the number of computers and the number of patch cables.
1,100
For each test case print one integer — the minimum number of hours required to copy the update files to all $$$n$$$ computers.
standard output
PASSED
ad0fd39e03105d1ee84e58b2491802fa
train_108.jsonl
1635518100
Berland State University has received a new update for the operating system. Initially it is installed only on the $$$1$$$-st computer.Update files should be copied to all $$$n$$$ computers. The computers are not connected to the internet, so the only way to transfer update files from one computer to another is to copy...
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.util.*; import java.lang.*; public class Solution{ static class Graph{ public static class Vertex{ HashMap<Integer,Integer> nb= new HashMap<>(); // for neighbours of each vertex } public static HashM...
Java
["4\n8 3\n6 6\n7 1\n1 1"]
2 seconds
["4\n3\n6\n0"]
NoteLet's consider the test cases of the example: $$$n=8$$$, $$$k=3$$$: during the first hour, we copy the update files from the computer $$$1$$$ to the computer $$$2$$$; during the second hour, we copy the update files from the computer $$$1$$$ to the computer $$$3$$$, and from the computer $$$2$$$ to the computer...
Java 8
standard input
[ "greedy", "implementation", "math" ]
5df6eb50ead22b498bea69bb84341c06
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Each test case consists of a single line that contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 10^{18}$$$) — the number of computers and the number of patch cables.
1,100
For each test case print one integer — the minimum number of hours required to copy the update files to all $$$n$$$ computers.
standard output
PASSED
634ea27b1b4f8f5ebfa5879763b5219b
train_108.jsonl
1635518100
Berland State University has received a new update for the operating system. Initially it is installed only on the $$$1$$$-st computer.Update files should be copied to all $$$n$$$ computers. The computers are not connected to the internet, so the only way to transfer update files from one computer to another is to copy...
256 megabytes
import java.util.*; import java.io.*; public class B { static StringBuilder sb; static long fact[]; static long mod = (long) (1e9 + 7); static int[] arr = { 0, 1, 11, 111, 1111, 11111, 111111, 1111111, 11111111, 111111111, 1111111111 }; static void solve(long n, long k) { if (k =...
Java
["4\n8 3\n6 6\n7 1\n1 1"]
2 seconds
["4\n3\n6\n0"]
NoteLet's consider the test cases of the example: $$$n=8$$$, $$$k=3$$$: during the first hour, we copy the update files from the computer $$$1$$$ to the computer $$$2$$$; during the second hour, we copy the update files from the computer $$$1$$$ to the computer $$$3$$$, and from the computer $$$2$$$ to the computer...
Java 8
standard input
[ "greedy", "implementation", "math" ]
5df6eb50ead22b498bea69bb84341c06
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Each test case consists of a single line that contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 10^{18}$$$) — the number of computers and the number of patch cables.
1,100
For each test case print one integer — the minimum number of hours required to copy the update files to all $$$n$$$ computers.
standard output
PASSED
25eeefba6e747e0d663dfba2e5c22732
train_108.jsonl
1635518100
Berland State University has received a new update for the operating system. Initially it is installed only on the $$$1$$$-st computer.Update files should be copied to all $$$n$$$ computers. The computers are not connected to the internet, so the only way to transfer update files from one computer to another is to copy...
256 megabytes
import java.util.Scanner; public class patch { public static void main(String[] args) { Scanner s = new Scanner(System.in); int t = s.nextInt(); while(t-->0){ long n = s.nextLong(); long k = s.nextLong(); if(k == 1){ System.out.p...
Java
["4\n8 3\n6 6\n7 1\n1 1"]
2 seconds
["4\n3\n6\n0"]
NoteLet's consider the test cases of the example: $$$n=8$$$, $$$k=3$$$: during the first hour, we copy the update files from the computer $$$1$$$ to the computer $$$2$$$; during the second hour, we copy the update files from the computer $$$1$$$ to the computer $$$3$$$, and from the computer $$$2$$$ to the computer...
Java 8
standard input
[ "greedy", "implementation", "math" ]
5df6eb50ead22b498bea69bb84341c06
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Each test case consists of a single line that contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 10^{18}$$$) — the number of computers and the number of patch cables.
1,100
For each test case print one integer — the minimum number of hours required to copy the update files to all $$$n$$$ computers.
standard output
PASSED
6796974a346f223465b3b84012ab7929
train_108.jsonl
1635518100
Berland State University has received a new update for the operating system. Initially it is installed only on the $$$1$$$-st computer.Update files should be copied to all $$$n$$$ computers. The computers are not connected to the internet, so the only way to transfer update files from one computer to another is to copy...
256 megabytes
import java.util.*; public class main { public static void main(String[] args) { Scanner scn = new Scanner(System.in); int t = scn.nextInt(); while (t-- > 0) { long n = scn.nextLong(); long k = scn.nextLong(); long val = 1; long cnt = 0; while (val < n) { ...
Java
["4\n8 3\n6 6\n7 1\n1 1"]
2 seconds
["4\n3\n6\n0"]
NoteLet's consider the test cases of the example: $$$n=8$$$, $$$k=3$$$: during the first hour, we copy the update files from the computer $$$1$$$ to the computer $$$2$$$; during the second hour, we copy the update files from the computer $$$1$$$ to the computer $$$3$$$, and from the computer $$$2$$$ to the computer...
Java 8
standard input
[ "greedy", "implementation", "math" ]
5df6eb50ead22b498bea69bb84341c06
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Each test case consists of a single line that contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 10^{18}$$$) — the number of computers and the number of patch cables.
1,100
For each test case print one integer — the minimum number of hours required to copy the update files to all $$$n$$$ computers.
standard output
PASSED
3d32b791434b44e679d308541101761b
train_108.jsonl
1635518100
Berland State University has received a new update for the operating system. Initially it is installed only on the $$$1$$$-st computer.Update files should be copied to all $$$n$$$ computers. The computers are not connected to the internet, so the only way to transfer update files from one computer to another is to copy...
256 megabytes
import java.io.*; import java.util.*; public class B { public static void main(String[] args) { FastReader in = new FastReader(); PrintWriter out = new PrintWriter(System.out); int T = in.nextInt(); for(int ttt = 1; ttt <= T; ttt++) { long n = in.nextLong(); ...
Java
["4\n8 3\n6 6\n7 1\n1 1"]
2 seconds
["4\n3\n6\n0"]
NoteLet's consider the test cases of the example: $$$n=8$$$, $$$k=3$$$: during the first hour, we copy the update files from the computer $$$1$$$ to the computer $$$2$$$; during the second hour, we copy the update files from the computer $$$1$$$ to the computer $$$3$$$, and from the computer $$$2$$$ to the computer...
Java 8
standard input
[ "greedy", "implementation", "math" ]
5df6eb50ead22b498bea69bb84341c06
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Each test case consists of a single line that contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 10^{18}$$$) — the number of computers and the number of patch cables.
1,100
For each test case print one integer — the minimum number of hours required to copy the update files to all $$$n$$$ computers.
standard output
PASSED
0964b9e63c4488688700ae9c06517c08
train_108.jsonl
1635518100
Berland State University has received a new update for the operating system. Initially it is installed only on the $$$1$$$-st computer.Update files should be copied to all $$$n$$$ computers. The computers are not connected to the internet, so the only way to transfer update files from one computer to another is to copy...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Main { static FastReader in; static PrintWriter out; static int bit(long n) { return (n == 0) ? 0 : (1 + bit(n & (n - 1))); } static void p(Object o) { out.print(o); } static void pn(Ob...
Java
["4\n8 3\n6 6\n7 1\n1 1"]
2 seconds
["4\n3\n6\n0"]
NoteLet's consider the test cases of the example: $$$n=8$$$, $$$k=3$$$: during the first hour, we copy the update files from the computer $$$1$$$ to the computer $$$2$$$; during the second hour, we copy the update files from the computer $$$1$$$ to the computer $$$3$$$, and from the computer $$$2$$$ to the computer...
Java 8
standard input
[ "greedy", "implementation", "math" ]
5df6eb50ead22b498bea69bb84341c06
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Each test case consists of a single line that contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 10^{18}$$$) — the number of computers and the number of patch cables.
1,100
For each test case print one integer — the minimum number of hours required to copy the update files to all $$$n$$$ computers.
standard output
PASSED
f8477260a4895297e07e7ac51707b09a
train_108.jsonl
1635518100
Berland State University has received a new update for the operating system. Initially it is installed only on the $$$1$$$-st computer.Update files should be copied to all $$$n$$$ computers. The computers are not connected to the internet, so the only way to transfer update files from one computer to another is to copy...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Deque; import java.util.HashMap; import java.util.H...
Java
["4\n8 3\n6 6\n7 1\n1 1"]
2 seconds
["4\n3\n6\n0"]
NoteLet's consider the test cases of the example: $$$n=8$$$, $$$k=3$$$: during the first hour, we copy the update files from the computer $$$1$$$ to the computer $$$2$$$; during the second hour, we copy the update files from the computer $$$1$$$ to the computer $$$3$$$, and from the computer $$$2$$$ to the computer...
Java 8
standard input
[ "greedy", "implementation", "math" ]
5df6eb50ead22b498bea69bb84341c06
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Each test case consists of a single line that contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 10^{18}$$$) — the number of computers and the number of patch cables.
1,100
For each test case print one integer — the minimum number of hours required to copy the update files to all $$$n$$$ computers.
standard output
PASSED
ccb19f2024caa5b42a5370c86d2e48c4
train_108.jsonl
1635518100
Berland State University has received a new update for the operating system. Initially it is installed only on the $$$1$$$-st computer.Update files should be copied to all $$$n$$$ computers. The computers are not connected to the internet, so the only way to transfer update files from one computer to another is to copy...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.StringTokenizer; public class Solve { static long MOD = 998244353L; static long INF = 1000_000_000_000_000L +...
Java
["4\n8 3\n6 6\n7 1\n1 1"]
2 seconds
["4\n3\n6\n0"]
NoteLet's consider the test cases of the example: $$$n=8$$$, $$$k=3$$$: during the first hour, we copy the update files from the computer $$$1$$$ to the computer $$$2$$$; during the second hour, we copy the update files from the computer $$$1$$$ to the computer $$$3$$$, and from the computer $$$2$$$ to the computer...
Java 8
standard input
[ "greedy", "implementation", "math" ]
5df6eb50ead22b498bea69bb84341c06
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Each test case consists of a single line that contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 10^{18}$$$) — the number of computers and the number of patch cables.
1,100
For each test case print one integer — the minimum number of hours required to copy the update files to all $$$n$$$ computers.
standard output
PASSED
07b2a4a912915d7048040073515e7dd5
train_108.jsonl
1635518100
Berland State University has received a new update for the operating system. Initially it is installed only on the $$$1$$$-st computer.Update files should be copied to all $$$n$$$ computers. The computers are not connected to the internet, so the only way to transfer update files from one computer to another is to copy...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String args[]) throws Exception { FastReader input=new FastReader(); PrintWriter out=new PrintWriter(System.out); int T=input.nextInt(); while (T-- > 0) { long n=input.nextL...
Java
["4\n8 3\n6 6\n7 1\n1 1"]
2 seconds
["4\n3\n6\n0"]
NoteLet's consider the test cases of the example: $$$n=8$$$, $$$k=3$$$: during the first hour, we copy the update files from the computer $$$1$$$ to the computer $$$2$$$; during the second hour, we copy the update files from the computer $$$1$$$ to the computer $$$3$$$, and from the computer $$$2$$$ to the computer...
Java 8
standard input
[ "greedy", "implementation", "math" ]
5df6eb50ead22b498bea69bb84341c06
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Each test case consists of a single line that contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 10^{18}$$$) — the number of computers and the number of patch cables.
1,100
For each test case print one integer — the minimum number of hours required to copy the update files to all $$$n$$$ computers.
standard output
PASSED
8eb4abff090da539280e06ab8bcae1b4
train_108.jsonl
1635518100
Berland State University has received a new update for the operating system. Initially it is installed only on the $$$1$$$-st computer.Update files should be copied to all $$$n$$$ computers. The computers are not connected to the internet, so the only way to transfer update files from one computer to another is to copy...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String args[]) throws Exception { FastReader input=new FastReader(); PrintWriter out=new PrintWriter(System.out); int T=input.nextInt(); while (T-- > 0) { long n=input.nextL...
Java
["4\n8 3\n6 6\n7 1\n1 1"]
2 seconds
["4\n3\n6\n0"]
NoteLet's consider the test cases of the example: $$$n=8$$$, $$$k=3$$$: during the first hour, we copy the update files from the computer $$$1$$$ to the computer $$$2$$$; during the second hour, we copy the update files from the computer $$$1$$$ to the computer $$$3$$$, and from the computer $$$2$$$ to the computer...
Java 8
standard input
[ "greedy", "implementation", "math" ]
5df6eb50ead22b498bea69bb84341c06
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Each test case consists of a single line that contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 10^{18}$$$) — the number of computers and the number of patch cables.
1,100
For each test case print one integer — the minimum number of hours required to copy the update files to all $$$n$$$ computers.
standard output
PASSED
4d26115a8ae3c7284e19e6dc68a574d5
train_108.jsonl
1635518100
Berland State University has received a new update for the operating system. Initially it is installed only on the $$$1$$$-st computer.Update files should be copied to all $$$n$$$ computers. The computers are not connected to the internet, so the only way to transfer update files from one computer to another is to copy...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws IOException { Scanner sc =new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int t = sc.nextInt(); while(t-->0){ long n= sc.nextLong(); ...
Java
["4\n8 3\n6 6\n7 1\n1 1"]
2 seconds
["4\n3\n6\n0"]
NoteLet's consider the test cases of the example: $$$n=8$$$, $$$k=3$$$: during the first hour, we copy the update files from the computer $$$1$$$ to the computer $$$2$$$; during the second hour, we copy the update files from the computer $$$1$$$ to the computer $$$3$$$, and from the computer $$$2$$$ to the computer...
Java 8
standard input
[ "greedy", "implementation", "math" ]
5df6eb50ead22b498bea69bb84341c06
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Each test case consists of a single line that contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 10^{18}$$$) — the number of computers and the number of patch cables.
1,100
For each test case print one integer — the minimum number of hours required to copy the update files to all $$$n$$$ computers.
standard output
PASSED
f4825ecc782f4f429066d8871f5067b6
train_108.jsonl
1635518100
Berland State University has received a new update for the operating system. Initially it is installed only on the $$$1$$$-st computer.Update files should be copied to all $$$n$$$ computers. The computers are not connected to the internet, so the only way to transfer update files from one computer to another is to copy...
256 megabytes
import java.util.*; import java.io.*; public class B1606{ static FastScanner fs = null; public static void main(String[] args) { fs = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int t = fs.nextInt(); while(t-->0){ long n = fs.nextLong(); long k = fs.nextLong();...
Java
["4\n8 3\n6 6\n7 1\n1 1"]
2 seconds
["4\n3\n6\n0"]
NoteLet's consider the test cases of the example: $$$n=8$$$, $$$k=3$$$: during the first hour, we copy the update files from the computer $$$1$$$ to the computer $$$2$$$; during the second hour, we copy the update files from the computer $$$1$$$ to the computer $$$3$$$, and from the computer $$$2$$$ to the computer...
Java 8
standard input
[ "greedy", "implementation", "math" ]
5df6eb50ead22b498bea69bb84341c06
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Each test case consists of a single line that contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 10^{18}$$$) — the number of computers and the number of patch cables.
1,100
For each test case print one integer — the minimum number of hours required to copy the update files to all $$$n$$$ computers.
standard output
PASSED
4a904a89726a93a6424f2f09e97dd381
train_108.jsonl
1635518100
Berland State University has received a new update for the operating system. Initially it is installed only on the $$$1$$$-st computer.Update files should be copied to all $$$n$$$ computers. The computers are not connected to the internet, so the only way to transfer update files from one computer to another is to copy...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class G { static PrintWriter out = new PrintWriter(System.out); static FastReader in=new FastReader(); public static void main(String args[...
Java
["4\n8 3\n6 6\n7 1\n1 1"]
2 seconds
["4\n3\n6\n0"]
NoteLet's consider the test cases of the example: $$$n=8$$$, $$$k=3$$$: during the first hour, we copy the update files from the computer $$$1$$$ to the computer $$$2$$$; during the second hour, we copy the update files from the computer $$$1$$$ to the computer $$$3$$$, and from the computer $$$2$$$ to the computer...
Java 8
standard input
[ "greedy", "implementation", "math" ]
5df6eb50ead22b498bea69bb84341c06
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Each test case consists of a single line that contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 10^{18}$$$) — the number of computers and the number of patch cables.
1,100
For each test case print one integer — the minimum number of hours required to copy the update files to all $$$n$$$ computers.
standard output
PASSED
89c830cfaaff91a6fafae615d124bb2c
train_108.jsonl
1635518100
Berland State University has received a new update for the operating system. Initially it is installed only on the $$$1$$$-st computer.Update files should be copied to all $$$n$$$ computers. The computers are not connected to the internet, so the only way to transfer update files from one computer to another is to copy...
256 megabytes
import java.util.*; import java.io.*; public class MyCpClass{ public static void main(String []args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder(); int T = Integer.parseInt(br.readLine()....
Java
["4\n8 3\n6 6\n7 1\n1 1"]
2 seconds
["4\n3\n6\n0"]
NoteLet's consider the test cases of the example: $$$n=8$$$, $$$k=3$$$: during the first hour, we copy the update files from the computer $$$1$$$ to the computer $$$2$$$; during the second hour, we copy the update files from the computer $$$1$$$ to the computer $$$3$$$, and from the computer $$$2$$$ to the computer...
Java 8
standard input
[ "greedy", "implementation", "math" ]
5df6eb50ead22b498bea69bb84341c06
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Each test case consists of a single line that contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 10^{18}$$$) — the number of computers and the number of patch cables.
1,100
For each test case print one integer — the minimum number of hours required to copy the update files to all $$$n$$$ computers.
standard output
PASSED
0dfaa1db8bb542f89f620d40edd4b96a
train_108.jsonl
1635518100
Berland State University has received a new update for the operating system. Initially it is installed only on the $$$1$$$-st computer.Update files should be copied to all $$$n$$$ computers. The computers are not connected to the internet, so the only way to transfer update files from one computer to another is to copy...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int T = sc.nextInt(); while (T-- > 0) { Long n = sc.nextLong(); Long k = sc.nextLong(); int t = get(k); int m...
Java
["4\n8 3\n6 6\n7 1\n1 1"]
2 seconds
["4\n3\n6\n0"]
NoteLet's consider the test cases of the example: $$$n=8$$$, $$$k=3$$$: during the first hour, we copy the update files from the computer $$$1$$$ to the computer $$$2$$$; during the second hour, we copy the update files from the computer $$$1$$$ to the computer $$$3$$$, and from the computer $$$2$$$ to the computer...
Java 8
standard input
[ "greedy", "implementation", "math" ]
5df6eb50ead22b498bea69bb84341c06
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Each test case consists of a single line that contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 10^{18}$$$) — the number of computers and the number of patch cables.
1,100
For each test case print one integer — the minimum number of hours required to copy the update files to all $$$n$$$ computers.
standard output
PASSED
d7fb7ad03415673c0cc70fde58fd8bdf
train_108.jsonl
1635518100
Berland State University has received a new update for the operating system. Initially it is installed only on the $$$1$$$-st computer.Update files should be copied to all $$$n$$$ computers. The computers are not connected to the internet, so the only way to transfer update files from one computer to another is to copy...
256 megabytes
// // Source code recreated from a .class file by IntelliJ IDEA // (powered by Fernflower decompiler) // import java.io.BufferedWriter; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.math.BigInteger; import java.util...
Java
["4\n8 3\n6 6\n7 1\n1 1"]
2 seconds
["4\n3\n6\n0"]
NoteLet's consider the test cases of the example: $$$n=8$$$, $$$k=3$$$: during the first hour, we copy the update files from the computer $$$1$$$ to the computer $$$2$$$; during the second hour, we copy the update files from the computer $$$1$$$ to the computer $$$3$$$, and from the computer $$$2$$$ to the computer...
Java 8
standard input
[ "greedy", "implementation", "math" ]
5df6eb50ead22b498bea69bb84341c06
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Each test case consists of a single line that contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 10^{18}$$$) — the number of computers and the number of patch cables.
1,100
For each test case print one integer — the minimum number of hours required to copy the update files to all $$$n$$$ computers.
standard output
PASSED
b090fa976f6adbeccdfff884cf633a52
train_108.jsonl
1635518100
Berland State University has received a new update for the operating system. Initially it is installed only on the $$$1$$$-st computer.Update files should be copied to all $$$n$$$ computers. The computers are not connected to the internet, so the only way to transfer update files from one computer to another is to copy...
256 megabytes
import java.util.*; import java.io.*; import java.math.BigInteger; //code by tishrah_ public class _practise { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next...
Java
["4\n8 3\n6 6\n7 1\n1 1"]
2 seconds
["4\n3\n6\n0"]
NoteLet's consider the test cases of the example: $$$n=8$$$, $$$k=3$$$: during the first hour, we copy the update files from the computer $$$1$$$ to the computer $$$2$$$; during the second hour, we copy the update files from the computer $$$1$$$ to the computer $$$3$$$, and from the computer $$$2$$$ to the computer...
Java 8
standard input
[ "greedy", "implementation", "math" ]
5df6eb50ead22b498bea69bb84341c06
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Each test case consists of a single line that contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 10^{18}$$$) — the number of computers and the number of patch cables.
1,100
For each test case print one integer — the minimum number of hours required to copy the update files to all $$$n$$$ computers.
standard output
PASSED
a939fbeaf020439ca54b599911f3a4a7
train_108.jsonl
1635518100
Berland State University has received a new update for the operating system. Initially it is installed only on the $$$1$$$-st computer.Update files should be copied to all $$$n$$$ computers. The computers are not connected to the internet, so the only way to transfer update files from one computer to another is to copy...
256 megabytes
import java.io.File; import java.io.FileNotFoundException; import java.math.BigInteger; import java.util.Scanner; public class UpdateFiles { static int corte(int n,int k){ double res = Math.log(k)/Math.log(2); System.err.println(res); return 0; } public static long copiar(...
Java
["4\n8 3\n6 6\n7 1\n1 1"]
2 seconds
["4\n3\n6\n0"]
NoteLet's consider the test cases of the example: $$$n=8$$$, $$$k=3$$$: during the first hour, we copy the update files from the computer $$$1$$$ to the computer $$$2$$$; during the second hour, we copy the update files from the computer $$$1$$$ to the computer $$$3$$$, and from the computer $$$2$$$ to the computer...
Java 8
standard input
[ "greedy", "implementation", "math" ]
5df6eb50ead22b498bea69bb84341c06
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Each test case consists of a single line that contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 10^{18}$$$) — the number of computers and the number of patch cables.
1,100
For each test case print one integer — the minimum number of hours required to copy the update files to all $$$n$$$ computers.
standard output
PASSED
31452c4536612e2822a4aaf9c76ab25b
train_108.jsonl
1635518100
Berland State University has received a new update for the operating system. Initially it is installed only on the $$$1$$$-st computer.Update files should be copied to all $$$n$$$ computers. The computers are not connected to the internet, so the only way to transfer update files from one computer to another is to copy...
256 megabytes
import java.util.Scanner; public class UF { public static void main(String[] args) { Scanner sc = new Scanner(System.in); for (int t = sc.nextInt(); t > 0; t--) { long N = sc.nextLong(); long K = sc.nextLong(); long now = 1; long time = 0; while (now < N) { ...
Java
["4\n8 3\n6 6\n7 1\n1 1"]
2 seconds
["4\n3\n6\n0"]
NoteLet's consider the test cases of the example: $$$n=8$$$, $$$k=3$$$: during the first hour, we copy the update files from the computer $$$1$$$ to the computer $$$2$$$; during the second hour, we copy the update files from the computer $$$1$$$ to the computer $$$3$$$, and from the computer $$$2$$$ to the computer...
Java 8
standard input
[ "greedy", "implementation", "math" ]
5df6eb50ead22b498bea69bb84341c06
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Each test case consists of a single line that contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 10^{18}$$$) — the number of computers and the number of patch cables.
1,100
For each test case print one integer — the minimum number of hours required to copy the update files to all $$$n$$$ computers.
standard output