message stringlengths 2 23.8k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 97 109k | cluster float64 0 0 | __index_level_0__ int64 194 217k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
The Bitlandians are quite weird people. They do everything differently. They have a different alphabet so they have a different definition for a string.
A Bitlandish string is a string made only of characters "0" and "1".
BitHaval (the may... | instruction | 0 | 36,399 | 0 | 72,798 |
Tags: constructive algorithms, implementation, math
Correct Solution:
```
a = input()
b = input()
possible = True
if len(a) != len(b):
possible = False
elif a == b:
pass
else:
if list(a).count('1') == 0:
possible = False
if list(b).count('1') == 0:
possible = False # 00...00 and 00..... | output | 1 | 36,399 | 0 | 72,799 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The Bitlandians are quite weird people. They do everything differently. They have a different alphabet so they have a different definition for a string.
A Bitlandish string is a string made only of characters "0" and "1".
BitHaval (the may... | instruction | 0 | 36,400 | 0 | 72,800 |
Tags: constructive algorithms, implementation, math
Correct Solution:
```
for i1 in range(1):
s=input()
l=input()
if s==l:
print("YES")
elif len(s)==len(l) and s.count('1')!=0 and l.count('1')!=0:
print("YES")
else:
print("NO")
``` | output | 1 | 36,400 | 0 | 72,801 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The Bitlandians are quite weird people. They do everything differently. They have a different alphabet so they have a different definition for a string.
A Bitlandish string is a string made only of characters "0" and "1".
BitHaval (the may... | instruction | 0 | 36,401 | 0 | 72,802 |
Tags: constructive algorithms, implementation, math
Correct Solution:
```
a = input()
b = input()
if len(a) != len(b):
print('NO')
else:
if a == b:
print('YES')
elif '1' in a and '1' in b:
print('YES')
else:
print('NO')
``` | output | 1 | 36,401 | 0 | 72,803 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The Bitlandians are quite weird people. They do everything differently. They have a different alphabet so they have a different definition for a string.
A Bitlandish string is a string made onl... | instruction | 0 | 36,402 | 0 | 72,804 |
Yes | output | 1 | 36,402 | 0 | 72,805 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The Bitlandians are quite weird people. They do everything differently. They have a different alphabet so they have a different definition for a string.
A Bitlandish string is a string made onl... | instruction | 0 | 36,403 | 0 | 72,806 |
Yes | output | 1 | 36,403 | 0 | 72,807 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The Bitlandians are quite weird people. They do everything differently. They have a different alphabet so they have a different definition for a string.
A Bitlandish string is a string made onl... | instruction | 0 | 36,404 | 0 | 72,808 |
Yes | output | 1 | 36,404 | 0 | 72,809 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The Bitlandians are quite weird people. They do everything differently. They have a different alphabet so they have a different definition for a string.
A Bitlandish string is a string made onl... | instruction | 0 | 36,405 | 0 | 72,810 |
Yes | output | 1 | 36,405 | 0 | 72,811 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The Bitlandians are quite weird people. They do everything differently. They have a different alphabet so they have a different definition for a string.
A Bitlandish string is a string made onl... | instruction | 0 | 36,406 | 0 | 72,812 |
No | output | 1 | 36,406 | 0 | 72,813 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The Bitlandians are quite weird people. They do everything differently. They have a different alphabet so they have a different definition for a string.
A Bitlandish string is a string made onl... | instruction | 0 | 36,407 | 0 | 72,814 |
No | output | 1 | 36,407 | 0 | 72,815 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The Bitlandians are quite weird people. They do everything differently. They have a different alphabet so they have a different definition for a string.
A Bitlandish string is a string made onl... | instruction | 0 | 36,408 | 0 | 72,816 |
No | output | 1 | 36,408 | 0 | 72,817 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The Bitlandians are quite weird people. They do everything differently. They have a different alphabet so they have a different definition for a string.
A Bitlandish string is a string made onl... | instruction | 0 | 36,409 | 0 | 72,818 |
No | output | 1 | 36,409 | 0 | 72,819 |
Provide a correct Python 3 solution for this coding contest problem.
Let us consider the following operations on a string consisting of `A` and `B`:
1. Select a character in a string. If it is `A`, replace it with `BB`. If it is `B`, replace with `AA`.
2. Select a substring that is equal to either `AAA` or `BBB`, and... | instruction | 0 | 36,728 | 0 | 73,456 |
"Correct Solution:
```
import sys
input = sys.stdin.readline
S = input()
T = input()
q = int(input())
ls = len(S)
lt = len(T)
cs_s = [0] * (ls+1)
cs_t = [0] * (lt+1)
for i in range(ls):
tmp = 1 if S[i] == 'A' else -1
cs_s[i+1] = cs_s[i] + tmp
for i in range(lt):
tmp = 1 if T[i] == 'A' else -1
cs_t[i+1... | output | 1 | 36,728 | 0 | 73,457 |
Provide a correct Python 3 solution for this coding contest problem.
Let us consider the following operations on a string consisting of `A` and `B`:
1. Select a character in a string. If it is `A`, replace it with `BB`. If it is `B`, replace with `AA`.
2. Select a substring that is equal to either `AAA` or `BBB`, and... | instruction | 0 | 36,729 | 0 | 73,458 |
"Correct Solution:
```
s = input()
t = input()
ls = len(s)
lt = len(t)
sl = [0]*(ls+1)
tl = [0]*(lt+1)
for i in range(ls):
if s[i] == "A":
sl[i+1] = sl[i] + 1
else:
sl[i+1] = sl[i] + 2
for i in range(lt):
if t[i] == "A":
tl[i+1] = tl[i] + 1
else:
tl[i+1] = tl[i] + 2
for _ in range(int(input())):... | output | 1 | 36,729 | 0 | 73,459 |
Provide a correct Python 3 solution for this coding contest problem.
Let us consider the following operations on a string consisting of `A` and `B`:
1. Select a character in a string. If it is `A`, replace it with `BB`. If it is `B`, replace with `AA`.
2. Select a substring that is equal to either `AAA` or `BBB`, and... | instruction | 0 | 36,730 | 0 | 73,460 |
"Correct Solution:
```
S = input()
T = input()
cumsa = [0]
cumsb = [0]
for c in S:
cumsa.append(cumsa[-1] + int(c == 'A'))
cumsb.append(cumsb[-1] + int(c == 'B'))
cumta = [0]
cumtb = [0]
for c in T:
cumta.append(cumta[-1] + int(c == 'A'))
cumtb.append(cumtb[-1] + int(c == 'B'))
Q = int(input())
ans = ... | output | 1 | 36,730 | 0 | 73,461 |
Provide a correct Python 3 solution for this coding contest problem.
Let us consider the following operations on a string consisting of `A` and `B`:
1. Select a character in a string. If it is `A`, replace it with `BB`. If it is `B`, replace with `AA`.
2. Select a substring that is equal to either `AAA` or `BBB`, and... | instruction | 0 | 36,731 | 0 | 73,462 |
"Correct Solution:
```
import sys
from itertools import accumulate
def input():
return sys.stdin.readline().strip()
def acc(li, n):
res = [0] * (n + 1)
for i in range(n):
if li[i] == "A":
res[i + 1] = 1
elif li[i] == "B":
res[i + 1] = 2
return list(accumulate(... | output | 1 | 36,731 | 0 | 73,463 |
Provide a correct Python 3 solution for this coding contest problem.
Let us consider the following operations on a string consisting of `A` and `B`:
1. Select a character in a string. If it is `A`, replace it with `BB`. If it is `B`, replace with `AA`.
2. Select a substring that is equal to either `AAA` or `BBB`, and... | instruction | 0 | 36,732 | 0 | 73,464 |
"Correct Solution:
```
S = input()
T = input()
cumSA = [0] * (len(S) + 1)
cumSB = [0] * (len(S) + 1)
cumTA = [0] * (len(T) + 1)
cumTB = [0] * (len(T) + 1)
for i, s in enumerate(S, start=1):
cumSA[i] = cumSA[i - 1]
cumSB[i] = cumSB[i - 1]
if s == 'A':
cumSA[i] += 1
else:
cumSB[i] += 1
... | output | 1 | 36,732 | 0 | 73,465 |
Provide a correct Python 3 solution for this coding contest problem.
Let us consider the following operations on a string consisting of `A` and `B`:
1. Select a character in a string. If it is `A`, replace it with `BB`. If it is `B`, replace with `AA`.
2. Select a substring that is equal to either `AAA` or `BBB`, and... | instruction | 0 | 36,733 | 0 | 73,466 |
"Correct Solution:
```
from operator import add
import sys
input=sys.stdin.readline
class SegTree():
def __init__(self, N, e, operator_func=add):
self.e = e # 単位元
self.size = N
self.node = [self.e] * (2*N)
self.operator_func = operator_func # 処理(add or xor max minなど)
def set_l... | output | 1 | 36,733 | 0 | 73,467 |
Provide a correct Python 3 solution for this coding contest problem.
Let us consider the following operations on a string consisting of `A` and `B`:
1. Select a character in a string. If it is `A`, replace it with `BB`. If it is `B`, replace with `AA`.
2. Select a substring that is equal to either `AAA` or `BBB`, and... | instruction | 0 | 36,734 | 0 | 73,468 |
"Correct Solution:
```
S = input()
T = input()
q = int(input())
abcd = [[int(i) for i in input().split()] for _ in range(q)]
sdp = [(0, 0)]
tdp = [(0, 0)]
for s in S :
a, b = sdp[-1]
if s == 'A' :
sdp.append((a + 1, b))
else :
sdp.append((a, b + 1))
for t in T :
a, b = tdp[-1]
if t ... | output | 1 | 36,734 | 0 | 73,469 |
Provide a correct Python 3 solution for this coding contest problem.
Let us consider the following operations on a string consisting of `A` and `B`:
1. Select a character in a string. If it is `A`, replace it with `BB`. If it is `B`, replace with `AA`.
2. Select a substring that is equal to either `AAA` or `BBB`, and... | instruction | 0 | 36,735 | 0 | 73,470 |
"Correct Solution:
```
s=input()
t=input()
n=len(s)
m=len(t)
sl=[0]
for i in s:
sl.append(sl[-1])
if i=="A":sl[-1]+=1
else:sl[-1]+=2
sl[-1]%=3
tl=[0]
for i in t:
tl.append(tl[-1])
if i=="A":tl[-1]+=1
else:tl[-1]+=2
tl[-1]%=3
q=int(input())
for _ in range(q):
a,b,c,d=map(int,input().s... | output | 1 | 36,735 | 0 | 73,471 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let us consider the following operations on a string consisting of `A` and `B`:
1. Select a character in a string. If it is `A`, replace it with `BB`. If it is `B`, replace with `AA`.
2. Select... | instruction | 0 | 36,736 | 0 | 73,472 |
Yes | output | 1 | 36,736 | 0 | 73,473 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let us consider the following operations on a string consisting of `A` and `B`:
1. Select a character in a string. If it is `A`, replace it with `BB`. If it is `B`, replace with `AA`.
2. Select... | instruction | 0 | 36,737 | 0 | 73,474 |
Yes | output | 1 | 36,737 | 0 | 73,475 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let us consider the following operations on a string consisting of `A` and `B`:
1. Select a character in a string. If it is `A`, replace it with `BB`. If it is `B`, replace with `AA`.
2. Select... | instruction | 0 | 36,738 | 0 | 73,476 |
Yes | output | 1 | 36,738 | 0 | 73,477 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let us consider the following operations on a string consisting of `A` and `B`:
1. Select a character in a string. If it is `A`, replace it with `BB`. If it is `B`, replace with `AA`.
2. Select... | instruction | 0 | 36,739 | 0 | 73,478 |
Yes | output | 1 | 36,739 | 0 | 73,479 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let us consider the following operations on a string consisting of `A` and `B`:
1. Select a character in a string. If it is `A`, replace it with `BB`. If it is `B`, replace with `AA`.
2. Select... | instruction | 0 | 36,740 | 0 | 73,480 |
No | output | 1 | 36,740 | 0 | 73,481 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let us consider the following operations on a string consisting of `A` and `B`:
1. Select a character in a string. If it is `A`, replace it with `BB`. If it is `B`, replace with `AA`.
2. Select... | instruction | 0 | 36,741 | 0 | 73,482 |
No | output | 1 | 36,741 | 0 | 73,483 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let us consider the following operations on a string consisting of `A` and `B`:
1. Select a character in a string. If it is `A`, replace it with `BB`. If it is `B`, replace with `AA`.
2. Select... | instruction | 0 | 36,742 | 0 | 73,484 |
No | output | 1 | 36,742 | 0 | 73,485 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let us consider the following operations on a string consisting of `A` and `B`:
1. Select a character in a string. If it is `A`, replace it with `BB`. If it is `B`, replace with `AA`.
2. Select... | instruction | 0 | 36,743 | 0 | 73,486 |
No | output | 1 | 36,743 | 0 | 73,487 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two strings s and t. In a single move, you can choose any of two strings and delete the first (that is, the leftmost) character. After a move, the length of the string decreases by 1. You can't choose a string if it is empty.
... | instruction | 0 | 36,846 | 0 | 73,692 |
Tags: brute force, implementation, strings
Correct Solution:
```
a = input()[::-1]
b = input()[::-1]
k = 0
for i in range(min(len(a), len(b))):
if a[i] == b[i]:
k += 1
else:
break
print(len(a) + len(b) - 2 * k)
``` | output | 1 | 36,846 | 0 | 73,693 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two strings s and t. In a single move, you can choose any of two strings and delete the first (that is, the leftmost) character. After a move, the length of the string decreases by 1. You can't choose a string if it is empty.
... | instruction | 0 | 36,847 | 0 | 73,694 |
Tags: brute force, implementation, strings
Correct Solution:
```
a = input()
b = input()
la = len(a)
lb = len(b)
ans = 0
if la==0 or lb==0 :
print (la + lb)
elif(a[la-1]!=b[lb-1]):
print(la + lb)
else:
m = min(la,lb)
for i in range(m):
if a[la-i-1]==b[lb-i-1]:
ans = ans + 1
else:
break
... | output | 1 | 36,847 | 0 | 73,695 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two strings s and t. In a single move, you can choose any of two strings and delete the first (that is, the leftmost) character. After a move, the length of the string decreases by 1. You can't choose a string if it is empty.
... | instruction | 0 | 36,848 | 0 | 73,696 |
Tags: brute force, implementation, strings
Correct Solution:
```
a = input()
b = input()
count = -0
if a == b:
print(0)
else:
while count > -min(len(b), len(a)):
if a[count-1] == b[count-1]:
count -= 1
# print(count, a[-count - 1], b[-count - 1])
else:
# count... | output | 1 | 36,848 | 0 | 73,697 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two strings s and t. In a single move, you can choose any of two strings and delete the first (that is, the leftmost) character. After a move, the length of the string decreases by 1. You can't choose a string if it is empty.
... | instruction | 0 | 36,849 | 0 | 73,698 |
Tags: brute force, implementation, strings
Correct Solution:
```
import sys
input = sys.stdin.readline
s = input()
t = input()
ks = len(s) - 1
kt = len(t) - 1
cur = 0
while s[ks] == t[kt]:
cur += 1
ks -= 1
kt -= 1
if ks < 0 or kt < 0:
break
result = len(s) - 2*cur + len(t)
print(result)
``` | output | 1 | 36,849 | 0 | 73,699 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two strings s and t. In a single move, you can choose any of two strings and delete the first (that is, the leftmost) character. After a move, the length of the string decreases by 1. You can't choose a string if it is empty.
... | instruction | 0 | 36,850 | 0 | 73,700 |
Tags: brute force, implementation, strings
Correct Solution:
```
s,t=input(),input()
x,flag=min(len(s),len(t)),0
for i in range(1,x+1):
if s[-i]==t[-i]:
continue
else:
flag=1
break
if flag==0:
print(len(s)-i+len(t)-i)
else:
print((len(s)-(i-1))+(len(t)-(i-1)))
``` | output | 1 | 36,850 | 0 | 73,701 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two strings s and t. In a single move, you can choose any of two strings and delete the first (that is, the leftmost) character. After a move, the length of the string decreases by 1. You can't choose a string if it is empty.
... | instruction | 0 | 36,851 | 0 | 73,702 |
Tags: brute force, implementation, strings
Correct Solution:
```
a=list(input())
b=list(input())
a=a[::-1]
b=b[::-1]
i=0
while i<min(len(a),len(b)):
if a[i]==b[i]:
i+=1
else:
break
print(len(a)+len(b)-2*i)
``` | output | 1 | 36,851 | 0 | 73,703 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two strings s and t. In a single move, you can choose any of two strings and delete the first (that is, the leftmost) character. After a move, the length of the string decreases by 1. You can't choose a string if it is empty.
... | instruction | 0 | 36,852 | 0 | 73,704 |
Tags: brute force, implementation, strings
Correct Solution:
```
a = input()
b = input()
a_len,b_len = len(a), len(b)
len_Sum = a_len+b_len
counter = 0
for ind in range(-1,(min(a_len,b_len)*-1 -1),-1):
if a[ind] != b[ind]:
break
else:
counter+=2
print(len_Sum - counter)
``` | output | 1 | 36,852 | 0 | 73,705 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two strings s and t. In a single move, you can choose any of two strings and delete the first (that is, the leftmost) character. After a move, the length of the string decreases by 1. You can't choose a string if it is empty.
... | instruction | 0 | 36,853 | 0 | 73,706 |
Tags: brute force, implementation, strings
Correct Solution:
```
a=input()
b=input()
x=len(a)
y=len(b)
while x and y and a[x-1]==b[y-1]:
x-=1
y-=1
print(x+y)
``` | output | 1 | 36,853 | 0 | 73,707 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given two strings s and t. In a single move, you can choose any of two strings and delete the first (that is, the leftmost) character. After a move, the length of the string decreases by... | instruction | 0 | 36,854 | 0 | 73,708 |
Yes | output | 1 | 36,854 | 0 | 73,709 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given two strings s and t. In a single move, you can choose any of two strings and delete the first (that is, the leftmost) character. After a move, the length of the string decreases by... | instruction | 0 | 36,855 | 0 | 73,710 |
Yes | output | 1 | 36,855 | 0 | 73,711 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given two strings s and t. In a single move, you can choose any of two strings and delete the first (that is, the leftmost) character. After a move, the length of the string decreases by... | instruction | 0 | 36,856 | 0 | 73,712 |
Yes | output | 1 | 36,856 | 0 | 73,713 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given two strings s and t. In a single move, you can choose any of two strings and delete the first (that is, the leftmost) character. After a move, the length of the string decreases by... | instruction | 0 | 36,857 | 0 | 73,714 |
Yes | output | 1 | 36,857 | 0 | 73,715 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given two strings s and t. In a single move, you can choose any of two strings and delete the first (that is, the leftmost) character. After a move, the length of the string decreases by... | instruction | 0 | 36,858 | 0 | 73,716 |
No | output | 1 | 36,858 | 0 | 73,717 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given two strings s and t. In a single move, you can choose any of two strings and delete the first (that is, the leftmost) character. After a move, the length of the string decreases by... | instruction | 0 | 36,859 | 0 | 73,718 |
No | output | 1 | 36,859 | 0 | 73,719 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given two strings s and t. In a single move, you can choose any of two strings and delete the first (that is, the leftmost) character. After a move, the length of the string decreases by... | instruction | 0 | 36,860 | 0 | 73,720 |
No | output | 1 | 36,860 | 0 | 73,721 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given two strings s and t. In a single move, you can choose any of two strings and delete the first (that is, the leftmost) character. After a move, the length of the string decreases by... | instruction | 0 | 36,861 | 0 | 73,722 |
No | output | 1 | 36,861 | 0 | 73,723 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a string s consisting only of lowercase Latin letters.
You can rearrange all letters of this string as you wish. Your task is to obtain a good string by rearranging the letters of the given string or report that it is impossib... | instruction | 0 | 36,879 | 0 | 73,758 |
Tags: constructive algorithms, greedy, sortings, strings
Correct Solution:
```
def isPalindrome(word):
if word == word[::-1]:
return 1
else:
return 0
t=int(input())
for j in range(t):
a=list(input())
n=len(a)
half=n//2
if half!=1:
half+=1
for i in range(n-1):
... | output | 1 | 36,879 | 0 | 73,759 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a string s consisting only of lowercase Latin letters.
You can rearrange all letters of this string as you wish. Your task is to obtain a good string by rearranging the letters of the given string or report that it is impossib... | instruction | 0 | 36,880 | 0 | 73,760 |
Tags: constructive algorithms, greedy, sortings, strings
Correct Solution:
```
for i in range(int(input())):
a=input()
if len(set(a))==1:
print(-1)
else:
p=0
for j in range(0,len(a)//2):
if a[j]==a[len(a)-j-1]:
p+=1
if len(a)%2==0:
if p... | output | 1 | 36,880 | 0 | 73,761 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a string s consisting only of lowercase Latin letters.
You can rearrange all letters of this string as you wish. Your task is to obtain a good string by rearranging the letters of the given string or report that it is impossib... | instruction | 0 | 36,881 | 0 | 73,762 |
Tags: constructive algorithms, greedy, sortings, strings
Correct Solution:
```
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import random
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1)... | output | 1 | 36,881 | 0 | 73,763 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a string s consisting only of lowercase Latin letters.
You can rearrange all letters of this string as you wish. Your task is to obtain a good string by rearranging the letters of the given string or report that it is impossib... | instruction | 0 | 36,882 | 0 | 73,764 |
Tags: constructive algorithms, greedy, sortings, strings
Correct Solution:
```
for i in range(int(input())):
s = sorted(input())
print(-1 if s == s[::-1] else ''.join(s))
``` | output | 1 | 36,882 | 0 | 73,765 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a string s consisting only of lowercase Latin letters.
You can rearrange all letters of this string as you wish. Your task is to obtain a good string by rearranging the letters of the given string or report that it is impossib... | instruction | 0 | 36,883 | 0 | 73,766 |
Tags: constructive algorithms, greedy, sortings, strings
Correct Solution:
```
t=int(input())
for i in range(t):
n=input()
c=[]
count=0
for i in range(len(n)):
c.insert(i,n[i])
m=list(reversed(n))
if c!=m:
print(n)
else:
for i in range(len(n)-1):
if n... | output | 1 | 36,883 | 0 | 73,767 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a string s consisting only of lowercase Latin letters.
You can rearrange all letters of this string as you wish. Your task is to obtain a good string by rearranging the letters of the given string or report that it is impossib... | instruction | 0 | 36,884 | 0 | 73,768 |
Tags: constructive algorithms, greedy, sortings, strings
Correct Solution:
```
def is_pal(s):
for i in range(len(s)):
if s[i] != s[-(i+1)]:
return False
return True
t = int(input())
for tt in range(t):
s = input()
if is_pal(s):
s0 = s[0]
sw = 0
for i in range... | output | 1 | 36,884 | 0 | 73,769 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a string s consisting only of lowercase Latin letters.
You can rearrange all letters of this string as you wish. Your task is to obtain a good string by rearranging the letters of the given string or report that it is impossib... | instruction | 0 | 36,885 | 0 | 73,770 |
Tags: constructive algorithms, greedy, sortings, strings
Correct Solution:
```
#In the name of GOD!
t = int(input())
for i in range(t):
s = list(input())
s.sort()
if s[0] == s[-1]: print(-1)
else: print(''.join(s))
``` | output | 1 | 36,885 | 0 | 73,771 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.