description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | tests = int(input())
for i in range(tests):
length = int(input())
string = input()
mink = 1
minstring = string
for k in range(1, length + 1):
if (length - k) % 2 == 0:
if string[k - 1 :] + string[: k - 1][::-1] < minstring:
minstring = string[k - 1 :] + string[: k... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR ASSIGN ... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | import sys
def input():
return sys.stdin.readline().strip()
def iinput():
return int(input())
def rinput():
return map(int, sys.stdin.readline().strip().split())
def get_list():
return list(map(int, sys.stdin.readline().strip().split()))
t = iinput()
for _ in range(t):
n = iinput()
s =... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASS... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | import sys
input = sys.stdin.readline
def rev(s, n, k):
i = k - 1
cnt = n - i
return s[i:] + (s[:i] if cnt % 2 == 0 else s[:i][::-1])
t = int(input())
for _ in range(t):
n = int(input())
s = input().strip()
mn = 1
ss = rev(s, n, 1)
for k in range(2, n + 1):
cur = rev(s, n, k... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR RETURN BIN_OP VAR VAR BIN_OP VAR NUMBER NUMBER VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN ... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | def reverse(s):
return s[::-1]
for t in range(int(input())):
n = int(input())
s = input()
alls = []
for k in range(1, n + 1):
news = s[k - 1 :] + (
s[: k - 1] if (n - k + 1) % 2 == 0 else reverse(s[: k - 1])
)
alls.append((news, k))
s, k = min(alls)
prin... | FUNC_DEF RETURN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER NUMBER VAR BIN_OP VAR NUMBER FUNC... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | for _ in range(int(input())):
n = int(input())
a = list(input())
temp = a.copy()
test = a.copy()
i = 1
ans = 1
while i < n:
if ord(a[i]) <= ord(a[0]):
if (n - i) % 2 != 0:
j = 0
for k in range(i, n):
temp[j] = a[k]
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASS... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | t = input()
for _ in range(int(t)):
n = int(input())
s = input()
mn = 2000
ind = []
for i in range(n):
if ord(s[i]) < mn:
mn = ord(s[i])
k = i + 1
for i in range(n):
if ord(s[i]) == mn:
ind.append(i)
ans = "z" * n
for i in range(len(ind... | ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL V... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | t = int(input())
while t > 0:
n = int(input())
st = input()
l = []
l.append(st)
for k in range(2, n + 1):
if (n + 1 - k) % 2 != 0:
s = st[k - 1 : n] + st[0 : k - 1][::-1]
l.append(s)
else:
s = st[k - 1 : n] + st[0 : k - 1]
l.append(s)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR NUMBER BIN_OP... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | t = int(input())
def modify(string, pos, ln):
pr = string[pos - 1 : ln]
sf = string[0 : pos - 1]
if ln % 2 == pos % 2:
sf = "".join(reversed(sf))
return pr + sf
for _ in range(t):
n = int(input())
s = input()
ans = modify(s, 1, n)
best = 1
for k in range(2, n + 1):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR RETURN BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VA... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | for i in range(int(input())):
n = int(input())
s = input()
mns = s
ans = 1
ss = []
for m in range(1, n + 1):
k = m - 1
if (n - m + 1) % 2:
if s[k:] + s[:k][::-1] < mns:
mns = s[k:] + s[:k][::-1]
ans = m
elif mns > s[k:] + s[:k]:... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER IF BIN_OP VAR VAR VAR VAR NUMBER VA... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | import sys
input = sys.stdin.readline
t = int(input())
for you in range(t):
n = int(input())
s = input()
s = s[:-1]
ans = 0
mina = s
for i in range(n):
pref = s[:i]
suff = s[i:]
swaps = n - i
if swaps % 2:
z = suff + pref[::-1]
else:
... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER ASS... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | def solve():
n = int(input())
st = str(input())
minst = st
ans = 0
minchar = chr(ord("z") + 1)
for i in range(0, n + 1):
newst = st[i:] + str(st[0:i])[:: -1 if (n - i + 1) % 2 == 0 else 1]
if newst < minst:
minst = newst
ans = i
print(minst)
print(... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR STRING NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR FUNC_CALL VAR VAR NUMBER VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NU... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | t = int(input())
for i in range(t):
n = int(input())
s = input()
l = []
l.append(s)
for j in range(1, n):
l.append(s[j:] + s[:j])
if n % 2 == 1:
for j in range(2, n, 2):
t = l[j]
u = t[: n - j]
v = t[n - j :]
w = v[::-1]
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VA... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | kl = int(input())
for l in range(kl):
n = int(input())
s = str(input())
al = "abcdefghijklmnopqrstuvwxyz"
for i in range(26):
if s.find(al[i]) != -1:
f = al[i]
break
k = s.find(f)
ind = []
while k != -1:
ind = ind + [k]
k = s.find(f, k + 1)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST WHILE VAR NUMBER ASSIGN VAR BIN_OP... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | t = int(input())
def replace_k(s, k):
coef = len(s) - k + 1
if k == len(s):
return s[::-1]
return s[k - 1 :] + (s[: k - 1] if coef % 2 == 0 else s[: k - 1][::-1])
def solve(s):
min_s, res = s, 1
for k in range(1, len(s) + 1):
replaced = replace_k(s, k)
if min_s > replaced... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR RETURN VAR NUMBER RETURN BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | T = int(input())
for i in range(T):
t = int(input())
s = input()
if t == 1:
print(s)
print(1)
continue
mins = s[:]
winner = 1
for k in range(2, t):
if (t - k) % 2 == 0:
new = s[k - 1 :] + s[k - 2 :: -1]
else:
new = s[k - 1 :] + s[: ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR B... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | t = int(input())
for T in range(t):
n = int(input())
s = input()
k = 1
hh = len(s)
pp = ""
for i in range(1, n):
p = s[: i - 1]
dd = s[i - 1 :]
if (n - i) % 2 == 0:
p = p[::-1]
ff = dd + p
if len(pp) == 0 or pp > ff:
k = i
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR VAR NU... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | t = int(input())
for _ in range(t):
n = int(input())
s = input()
x = min(s)
c = []
for i in range(n):
if s[i] == x:
c.append(i)
q = "zzzzzzzzzzzzzzzzzzzzzzzzzzz"
m = 0
for i in c:
z = s[i:] + s[:i]
y = s[i:] + s[:i][::-1]
if (n - i) % 2 == 0:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR ... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | def main():
t = int(input())
while t:
t -= 1
n = input()
s = input()
ans = s
an = 1
for i in range(len(s)):
temp = s[i:]
temp1 = s[:i]
if len(s) - i & 1:
temp += temp1[::-1]
else:
temp... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR IF BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR VAR NUMBER VAR VAR IF VAR VAR ASSIGN VAR... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | from sys import stdin, stdout
def main():
from sys import stdin, stdout
for _ in range(int(stdin.readline())):
n = int(stdin.readline())
inp = stdin.readline().strip()
temp = list(inp)
temp.sort()
alpha = temp[0]
indices = []
for i in range(n):
... | FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VAR ASSIGN VA... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | for _ in range(int(input())):
n = int(input())
s = input()
m = min(s)
smallest = []
for i in range(n):
if s[i] == m:
smallest.append(i + 1)
d = {}
for i in smallest:
if i % 2 == 0 and n % 2 == 0 or i % 2 != 0 and n % 2 != 0:
t = s[: i - 1]
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR DICT FOR VAR VAR IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER BI... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | from sys import stdin, stdout
for _ in range(int(stdin.readline())):
n = int(stdin.readline())
s = stdin.readline()[:-1]
ans = s
k = 1
for i in range(1, n):
if (n - i) % 2 == 0:
if s[i:] + s[:i] < ans:
ans = s[i:] + s[:i]
k = i + 1
elif s[... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER IF BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER I... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | from sys import stdin
def func():
return
for _ in range(int(stdin.readline())):
n = int(stdin.readline())
s = stdin.readline().strip()
d = {(0): s}
for i in range(1, n):
m = s[i:]
if n % 2 != 0:
if i % 2 == 0:
rest = s[0:i][::-1]
else:
... | FUNC_DEF RETURN FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR V... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | t = int(input())
for r in range(t):
n = int(input())
y = input()
a = []
for i in range(n):
if (n - i) % 2 == 1:
a.append(y[i:] + y[:i][::-1])
else:
a.append(y[i:] + y[:i])
ans = 0
for i in range(n - 1):
if a[ans] > a[i + 1]:
ans = i + 1... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER F... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | t = int(input())
for _ in range(t):
n = int(input())
s = input()
ss = s + s
ans = [["", 0] for i in range(n)]
for i in range(1, n + 1):
if i % 2 == len(s) % 2:
ans[i - 1][0] = s[i - 1 :] + s[: i - 1][::-1]
else:
ans[i - 1][0] = s[i - 1 :] + s[: i - 1]
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR LIST STRING NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BI... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | def stringModification(n, string):
lexSmallest = string
ks = 1
for k in range(1, n + 1):
if (n - k) % 2 == 0:
stri = string[k - 1 :] + string[k - 2 :: -1]
else:
stri = string[k - 1 :] + string[: k - 1]
if stri < lexSmallest:
lexSmallest = stri
... | FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR RETURN VAR VAR ASSIG... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | T = int(input())
for _ in range(T):
n = int(input())
word = input()
minChar = ord("z") + 1
minIndex = n + 10
candidates = []
for i in range(n):
if ord(word[i]) < minChar:
minChar = ord(word[i])
candidates = [(word[i:], i)]
elif ord(word[i]) == minChar:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR STRING NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR L... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | q = int(input())
for rwer in range(q):
n = int(input())
s = input()
if n == 1:
print(s)
print(1)
else:
for k in range(1, n + 1):
if k == 1:
bestk = 1
bescik = s
else:
if (k - n) % 2 == 0:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER NU... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | def revrse(s):
return s[::-1]
def parity(n, k):
return True if n % 2 == 0 and k % 2 == 0 or n % 2 == 1 and k % 2 == 1 else False
for test in range(int(input())):
n = int(input())
s = input()
ans, ansk = s, 1
for k in range(2, n + 1):
c = s[k - 1 :]
if parity(n, k):
... | FUNC_DEF RETURN VAR NUMBER FUNC_DEF RETURN BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR N... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | import sys
def input():
return sys.stdin.readline().rstrip()
for _ in range(int(input())):
n = int(input())
s = input()
arr = []
for k in range(0, n):
if n % 2 == 0:
if k % 2 == 1:
ns = s[k:] + s[:k][::-1]
else:
ns = s[k:] + s[:k]
... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR BI... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | t = int(input())
for _ in range(t):
n = int(input())
string = input()
ind = 1
ans = string
if string[-1::-1] < string:
ans = min(string, string[-1::-1])
ind = n
if n % 2 == 0:
for i in range(1, n - 1):
if i % 2 == 0:
if (
st... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR VAR IF BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUM... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | def solve(inp):
n = len(inp)
mins = inp
mink = 0
for k in range(n):
s1 = inp[k:]
s2 = inp[0:k]
if len(s1) % 2 != 0:
s2 = s2[::-1]
if s1 + s2 < mins:
mins = s1 + s2
mink = k
return [mins, mink + 1]
t = int(input())
for i in range(t... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR NUMBER VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR RETURN LIST VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_C... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | t = int(input())
def op(s, k):
s2 = list(s)
if k < len(s):
s3 = s2[k - 1 :]
s4 = s2[0 : k - 1]
if len(s3) % 2 != 0:
s2 = s3 + s4[::-1]
else:
s2 = s3 + s4
return "".join([e for e in s2])
else:
return "".join([e for e in s2[::-1]])
fo... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR RETURN FUNC_CALL STRING VAR VAR VAR RETURN F... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | def solve():
n = int(input().strip())
s = input().strip()
def f(k):
if (n - k + 1) % 2 == 0:
return s[k - 1 :] + s[: k - 1]
return s[k - 1 :] + s[: k - 1][::-1]
res, k = min((f(i), i) for i in range(1, n + 1))
print(res)
print(k)
def main():
for _ in range(int... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER NUMBER RETURN BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER RETURN BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | t = int(input())
for i in range(t):
n = int(input())
stri = [i for i in input()]
z = ["z"] * 50002
count = 0
if n % 2 == 1:
for i in range(1, n + 1):
if i % 2 == 0:
s = stri[i - 1 :] + stri[: i - 1]
if s < z:
z = s
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST STRING NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | for i in range(int(input())):
n = int(input())
s = input()
if n == 1:
print(s)
print(n)
continue
s1 = ""
index = 0
l = []
for j in range(1, n + 1):
s2 = ""
s1 = s[j - 1 :]
s2 += s[0 : j - 1]
if len(s2) % 2 == 1 and n % 2 == 1 or n % 2 =... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR STRING ASSIGN VAR VAR BIN_OP VAR NUM... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | for _ in " " * int(input()):
a = int(input())
b = ["{"] + input().replace("", " ").split()
z = min(b)
ok = [0] * b.count(z)
j = 0
for i in range(1, a + 1):
if b[i] == z:
o = b[i:]
if a - i & 1 == 0:
o += b[1:i][::-1]
else:
... | FOR VAR BIN_OP STRING FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST STRING FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR ... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | def change(s, k):
temp = len(s) - k
if temp <= 0:
return s[::-1]
if (temp + 1) % 2 == 0:
return s[k - 1 :] + s[: k - 1]
else:
return s[k - 1 :] + s[: k - 1][::-1]
def solve(s, n):
l = {}
for i in range(1, n + 1):
t = change(s, i)
if t not in l:
... | FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR IF VAR NUMBER RETURN VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER RETURN BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER RETURN BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER AS... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | badStr = "z" * 5005
for _ in range(int(input())):
n = int(input())
s = input()
minStr = badStr
minK = float("inf")
for i in range(len(s)):
ops = n - i
currK = i + 1
if ops % 2 == 1:
new_str = s[i:] + s[:i][::-1]
else:
new_str = s[i:] + s[:i]
... | ASSIGN VAR BIN_OP STRING NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSI... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | for _ in range(int(input())):
n = int(input())
s = input()
k = 1
res = s
for j in range(1, n + 1):
mov = n - j + 1
t = s[: j - 1]
final = s[j - 1 :]
if mov % 2 == 0:
final += t
else:
final = final + t[::-1]
if res > final:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | def get_pos(in_str, len_0, sym):
pos = []
for i in range(len_0):
if sym == in_str[i]:
pos.append(i + 1)
return pos
def rev_str(in_str, len_0, k):
temp = list(in_str)
i, t = 0, len_0 - k + 1
k_even = k % 2
l_even = len_0 % 2
if k == 1:
return temp
elif k ... | FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER RETURN VAR IF VAR VAR RETURN FUNC_CALL VAR FU... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | from sys import stdin, stdout
t = int(stdin.readline().strip())
for _ in range(t):
n = int(stdin.readline().strip())
s = stdin.readline().strip()
all_str = []
for k in range(n):
pol = (n - k) % 2
if pol == 0:
all_str.append((s[k:] + s[:k], k + 1))
else:
a... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR NUMBER EXPR ... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | t = int(input())
while t > 0:
n = int(input())
s = input()
a = []
for i in range(n):
if i == n - 1:
a.append([s[::-1], i + 1])
continue
if (n - i) % 2 == 0:
l = s[i:n] + s[0:i]
elif i == 0:
l = s
else:
l = s[i:n]... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR LIST VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR NUMBER ... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | def reversesub(s, begin, end):
s1 = s[0:begin]
s2 = s[begin:end][::-1]
s3 = s[end:]
str = s1 + s2 + s3
if begin < end:
return str
else:
return str
def Problem(str, n):
out = []
for k in range(0, n):
t = str[0:k]
if (n - k) % 2 == 1:
t = t[::-... | FUNC_DEF ASSIGN VAR VAR NUMBER VAR ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF VAR VAR RETURN VAR RETURN VAR FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR NUMBER VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR BI... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | for _ in range(int(input())):
n = int(input())
s = input()
r = s[::-1]
min_s = s
ans = 1
for k in range(2, 1 + n):
tmp = s[k - 1 :]
if (n + k) % 2 == 1:
tmp += s[: k - 1]
else:
tmp += r[n - k + 1 :]
if min_s > tmp:
ans = k
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR VAR BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR VAR BIN_OP VAR NUMBER VAR VA... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | def sp(s, k):
n = len(s)
if (n - k + 1) % 2 == 0:
b = s[k - 1 : n] + s[0 : k - 1]
else:
b = s[k - 1 : n] + s[k - 2 :: -1]
return b
for t in range(int(input())):
l = int(input())
s = input()
ans = 1
an = s
for i in range(2, l + 1):
y = sp(s, i)
if y <... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL V... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | def checker(n, s):
ans1, ans2 = 1, s
for i in range(2, n + 1):
k = (
s[i - 1 :] + s[0 : i - 1][::-1]
if (n - i) % 2 == 0
else s[i - 1 :] + s[0 : i - 1]
)
if k < ans2:
ans2, ans1 = k, i
return ans2, ans1
for _ in range(int(input())):
... | FUNC_DEF ASSIGN VAR VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER NUMBER BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR VAR RETURN VAR VAR FOR VAR FUNC_CALL V... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | import sys
input = sys.stdin.readline
def rank_compare(x):
if x + k < LEN:
return (RANK[x] << 17) + RANK[x + k]
elif x < LEN:
return RANK[x] << 17
return -1
t = int(input())
for tests in range(t):
n = int(input())
S = tuple(input().strip())
MIN = min(S)
STLIST = []
f... | IMPORT ASSIGN VAR VAR FUNC_DEF IF BIN_OP VAR VAR VAR RETURN BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR IF VAR VAR RETURN BIN_OP VAR VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIG... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | import sys
input = sys.stdin.readline
for _ in range(int(input())):
n = int(input())
s = input().rstrip()
if n == 1:
print(s)
print(n)
continue
lst = [s]
for i in range(1, n):
if (i + n) % 2 == 0:
lst.append(s[i:] + s[:i])
else:
lst.ap... | IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | def reversed(strr, k):
for i in range(len(strr) - k + 1):
revd = strr[i : i + k][::-1]
strr = strr[:i] + revd + strr[i + k :]
return strr
hm = int(input())
for u in range(hm):
n = int(input())
s = input()
r = ""
x = s
c = 1
for i in range(n):
r = r + s[i:n]
... | FUNC_DEF FOR VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VA... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | t = int(input())
def Modify(sting, k):
array = list(sting)
if k % 2 == 0 and len(sting) % 2 == 0 or k % 2 == len(sting) % 2 == 1:
array2 = reversed(array[0 : k - 1])
array = array[k - 1 :]
array.extend(array2)
else:
array = array[k - 1 :] + array[0 : k - 1]
return "".jo... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VA... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | for _ in range(int(input())):
n = int(input())
s = input()
l = []
for i in range(1, n + 1):
p = []
for j in range(i - 1, n):
p.append(s[j])
ks = i - 2
q = n - i + 1
if q % 2 == 0:
k = 0
while k <= ks:
p.append(s[... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VA... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | def f():
n = int(input())
a = input()
mini = "z" * 5001
kp = 0
for k in range(1, len(a) + 1):
if (len(a) - k + 1) % 2 == 0:
s = a[k - 1 : len(a)] + a[0 : k - 1]
if s < mini:
mini = s
kp = k
else:
s = a[k - 1 : len(a)... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP STRING NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR NUMBER ... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | def v(string, k):
ops = len(string) - k
if ops % 2 == 1:
return string[k:] + string[:k][::-1]
return string[k:] + string[:k]
t = int(input())
for _ in range(t):
length = int(input())
to_modify = input()
modified_strings = [to_modify]
k = 1
while k <= length and v(to_modify, k) ... | FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER RETURN BIN_OP VAR VAR VAR VAR NUMBER RETURN BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST VAR ASSIGN VAR NUMBER WHILE VAR... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | from sys import stdin
MAX = 1005
def line():
return stdin.readline().strip()
def solve(s):
ans = []
sz = len(s)
for k in range(0, sz):
if (sz - k) % 2:
ans.append((s[k:] + s[:k][-1::-1], k + 1))
else:
ans.append((s[k:] + s[:k], k + 1))
ans.sort()
s, k... | ASSIGN VAR NUMBER FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | for _ in range(int(input())):
n = int(input())
l = input()
t = None
m = min(l)
k = 1
ans = []
for i in range(n):
if n - i & 1:
ans.append(l[i:] + l[0:i][::-1])
else:
ans.append(l[i:] + l[0:i])
m = min(ans)
print(m)
print(ans.index(m) + 1) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NONE ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CAL... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | for _ in range(int(input())):
n = int(input())
s = input()
r = list(s)
a = min(r)
mink = 1
wow = s
for i in range(n):
if r[i] == a:
temp = s[i:] + (s[:i] if (n - i) % 2 == 0 else s[:i][::-1])
if temp < wow:
wow = temp
mink = i +... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR VAR VAR ... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | def reverseString(s, begin, end):
return s[0:begin] + s[begin:end][::-1] + s[end:]
t = int(input())
for i in range(t):
n = int(input())
s = input()
m = s
index = 0
for i in range(n):
if (n - i) % 2 == 0:
c = s[i:] + s[:i]
else:
c = s[i:] + s[:i][::-1]
... | FUNC_DEF RETURN BIN_OP BIN_OP VAR NUMBER VAR VAR VAR VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | def calc(s, x, y):
ps = s[x:y:1]
ss = s[0:x:1]
if (y - x) % 2 != 0:
ss = ss[::-1]
sf = ps + ss
return sf
for _ in range(int(input())):
n = int(input())
s = str(input())
s1 = s
k = 1
for i in range(1, n + 1):
ts = calc(s, i, n)
if ts < s1:
s1 ... | FUNC_DEF ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN ... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | T = int(input())
for _ in range(T):
n = int(input())
s = input()
In = 0
ans = s
an = 1
for i in range(n):
In = s.index(s[i], In)
if (n - In) % 2 != 0:
a = s[In:]
b = s[:In]
b = b[::-1]
St = a + b
else:
St = s[In:... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | for _ in range(int(input())):
n = int(input())
s = input()
l = []
for i in range(n):
if (n - (i + 1) + 1) % 2 != 0:
s1 = s[i:n] + s[:i][::-1]
l.append([s1, i + 1])
else:
s1 = s[i:n] + s[:i]
l.append([s1, i + 1])
l.sort(key=lambda x: x[0... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR LIST VAR BIN_OP VAR NUMBER ASSIGN... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | t = int(input())
for i in range(t):
len = int(input())
s = input()
sl = sorted(s)[0]
ns = "z" * (len + 1)
min_x = len
for x in range(len):
if s[x] == sl:
if (len - x - 1) % 2 == 1:
ns_ = s[x:] + s[:x]
else:
ns_ = s[x:] + "".join(lis... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP STRING BIN_OP VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR IF BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER NUMBER ASS... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | t = int(input())
for i in range(t):
n = int(input())
s = input()
mk = 1
ms = ""
ms += s
for k in range(2, n + 1):
new = s[0 : k - 1]
if (n - k + 1) % 2 == 1:
new = new[::-1]
if ms > s[k - 1 : n] + new:
mk = k
ms = s[k - 1 : n] + new
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR STRING VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER NUMBER ASSIGN ... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | t = int(input())
for _ in range(t):
n = int(input())
s = input()
mini = min(s)
ans = s
ind = 0
for i in range(n):
if s[i] == mini:
temp = s[i:]
if (n - i) % 2 != 0:
temp += s[i - 1 :: -1]
else:
temp += s[:i]
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR VAR BIN_OP VAR NUMBER NUMB... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | t = int(input())
for i in range(t):
n = int(input())
s = str(input())
ans = ""
k_ans = 1
for j in range(n):
if ans == "":
ans = s[j:] + s[0:j][::-1]
else:
x = ""
if n % 2 != (j + 1) % 2:
x = s[j:] + s[0:j]
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR STRING ASSIGN VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR STRING IF BIN_OP VAR NUMBER BIN_OP BIN_OP ... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | from sys import stdin
input = stdin.readline
t = int(input())
for _ in range(t):
n = int(input())
e = n % 2
s = input().rstrip()
k = 1
smallest = s
for i in range(1, n):
if (e + i) % 2 == 0:
if s[i:n] + s[:i] < smallest:
smallest = s[i:n] + s[:i]
... | ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER IF BIN_OP VAR VAR VAR VAR VAR VA... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | t = int(input())
while t > 0:
t = t - 1
n = int(input())
s = input()
temp = []
for k in range(1, n + 1):
if (n - k + 1) % 2 == 0:
s1 = s[k - 1 :] + s[: k - 1]
else:
x = s[: k - 1]
y = x[::-1]
s1 = s[k - 1 :] + y
temp.append(s1)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR ... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | import sys
def gs(s, k):
n = len(s)
return s[k - 1 :] + (s[: k - 1] if (n - k) % 2 == 1 else s[: k - 1][::-1])
t = int(sys.stdin.readline())
for _ in range(t):
n = int(sys.stdin.readline())
s = sys.stdin.readline().strip()
km = min(range(1, n + 1), key=lambda k: gs(s, k))
print(gs(s, km))
... | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR RETURN BIN_OP VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FU... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | t = int(input())
for _ in range(t):
n = int(input())
s = input()
s = " " + s
L = list(s)
m = min(L[1:])
p = L[1:].count(m)
if p == n:
print(s[1:])
print("1")
else:
k = 0
f = ""
k = L[k + 1 :].index(m)
k += 1
te = L[1:k]
if (... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR S... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | import sys
INF = 10**10
def main():
global mini, ans
print = out.append
n = get_int()
st = input()
mini = st
ans = 1
def pre(k):
global mini, ans
a = st[: k - 1]
if (n - k + 1) % 2 != 0:
a = a[::-1]
s = st[k - 1 :] + a
if s < mini:
... | IMPORT ASSIGN VAR BIN_OP NUMBER NUMBER FUNC_DEF ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR VAR BIN_OP VAR NUMBER IF BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR IF VAR VAR AS... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | t = int(input())
while t > 0:
t -= 1
len = int(input())
s = input()
res = 1
sstr = s
for i in range(len):
ss = s[i:]
if len - i & 1 == 0:
ss = ss + s[0:i]
else:
ss = ss + "".join(reversed(s[0:i]))
if sstr > ss:
sstr = ss
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER VAR ASSIGN VAR BIN_OP VAR FUNC_CALL STR... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | def rds(s, n):
mi = s
a = 1
if n % 2 == 0:
for i in range(2, n + 1):
if i % 2 == 0:
qw = s[i - 1 :] + s[: i - 1][::-1]
if qw < mi:
mi = qw
a = i
else:
qw = s[i - 1 :] + s[: i - 1]
... | FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER IF ... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | t = int(input())
for loop in range(t):
n = int(input())
s = input()
lis = []
for k in range(1, n + 1):
temp = list(s[: k - 1])
if (n - k + 1) % 2 == 1:
temp.reverse()
ns = s[k - 1 :] + "".join(temp)
lis.append([ns, k])
lis.sort()
print(lis[0][0])
p... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR ASSIGN VA... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | for _ in range(int(input())):
n = int(input())
s = input()
c = "z"
for i in range(n):
c = min(c, s[i])
l = []
for i in range(n):
if s[i] == c:
l.append(i)
s1 = ""
s2 = s[:]
k = 0
for i in l:
s1 = s[i:]
t = s[:i]
if (n - i - 1) %... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR VAR ASSIGN VAR N... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | def main():
t = int(input())
for __ in range(t):
n = int(input())
s = input()
c = s
k = 1
for i in range(n):
temp = []
temp.append(s[i:])
if (n - i) % 2 == 0:
temp.append(s[0:i])
else:
for j i... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR NUMBER VAR FOR VAR... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | t = int(input())
for i in range(t):
n = int(input())
s = input()
b = sorted(s)
l = []
for i in range(len(s)):
if s[i] == b[0]:
l.append(i)
q = []
for i in range(len(l)):
if l[i] == n - 1:
q.append([s[::-1], n])
elif l[i] == 0:
q.app... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VA... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | tc = int(input())
for _ in range(tc):
n = int(input())
s = str(input())
ans = s
op = 0
for k in range(1, n):
t = ""
if n % 2 != k % 2:
t = s[k:] + s[0:k][::-1]
else:
t = s[k:] + s[0:k]
if t < ans:
ans = t
op = k
prin... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR STRING IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER ASSIGN... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | t = int(input())
for tt in range(t):
n = int(input())
s = input()
arr = []
for i in range(n):
if (n - i) % 2 == 0:
x = s[i:] + s[0:i]
arr.append((x, i + 1))
else:
x = s[i:] + s[0:i][::-1]
arr.append((x, i + 1))
x = s[::-1]
arr.appen... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR VAR NUMBER VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VA... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | t = int(input())
for _ in range(t):
n = int(input())
s = input()
store = []
store.append((s, 1))
store.append((s[::-1], n))
for k in range(1, n - 1):
first = s[k:]
second = s[:k]
total = n - k
if total % 2 == 1:
second = second[::-1]
store.appe... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | def aze(a, n):
sol = a
ans = 1
k = 2
while k < n + 1:
if (n - k + 1) % 2 == 0:
b = a[: k - 1]
else:
b = a[: k - 1]
b = b[::-1]
if a[k - 1 :] + b < sol:
sol = a[k - 1 :] + b
ans = k
k += 1
return sol, ans
t ... | FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR ASSIGN ... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | t = int(input())
while t:
t -= 1
n = int(input())
s = input().strip()
ans_k = 1
ans = s
for k in range(2, n + 1):
res = s[k - 1 :]
if len(res) % 2 != 0:
res += s[: k - 1][::-1]
else:
res += s[: k - 1]
if res < ans:
ans = res
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR VAR BIN_OP VAR NUMBER NUMBE... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | import sys
print = sys.stdout.write
for _ in range(int(input())):
n = int(input())
s = list(input())
x = min(s)
lis = []
for i in range(n):
if s[i] == x:
lis.append(i)
ss = s[:]
k = 1
for i in lis:
l = []
l.extend(s[i:])
if i % 2 == n % 2:
... | IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR LIST ... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | def main():
for _ in range(int(input())):
n = int(input())
s = input()
k = 1
ans = s
for i in range(1, n + 1):
if (len(s) - i + 1) % 2 == 0:
t = s[i:] + s[:i][::-1]
else:
t = s[i:] + s[:i]
if t < ans:
... | FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VA... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | def main(n, s):
res = 1
res_s = s
for k in range(1, n):
st = s[k:] + s[k - 1 :: -1][:: (-1) ** (n - k + 1)]
if st < res_s:
res_s = st
res = k + 1
return res_s, res
t = int(input())
for i in range(t):
n = int(input())
s = input()
print(*main(n, s), se... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER NUMBER BIN_OP NUMBER BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR F... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | t = int(input())
for _ in range(t):
n = int(input())
a = input()
ans = 122
for i in range(n):
ans = min(ans, ord(a[i]))
index = []
for i in range(n):
if ord(a[i]) == ans:
index = index + [i]
l = len(index)
i = 0
b = a[:]
vendam = n - index[0] + 2
i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR LIS... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | t = int(input())
while t > 0:
n = int(input())
s = input()
k = []
arr = []
for i in range(0, n):
s1 = s[i : n + 1]
s2 = s[0:i]
if n % 2 != 0 and i % 2 == 0:
s2 = s2[::-1]
elif n % 2 == 0 and i % 2 != 0:
s2 = s2[::-1]
k.append(s1 + s2)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER VAR IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMB... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | from sys import stdin, stdout
ke = int(stdin.readline())
s = [0] * ke
for gh in range(ke):
a = int(input())
b = "{" + input()
z = min(b)
ok = [0] * b.count(z)
j = 0
for i in range(1, a + 1):
if b[i] == z:
o = b[i:]
if a - i & 1 == 0:
o += b[1:i][:... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP STRING FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER I... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | for _ in range(int(input())):
n = int(input())
s = input()
ans = s
fans = 1
for i in range(1, n):
if i % 2 != n % 2:
d = s[i - 1 :] + s[: i - 1]
else:
d = s[i - 1 :] + s[: i - 1][::-1]
if d < ans:
ans = d
fans = i
if s[::-1]... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | I = input
for _ in [0] * int(I()):
n = int(I())
s = I()
print(*min((s[k:] + s[:k][:: ~n - k & 1 or -1], k + 1) for k in range(n)), sep="\n") | ASSIGN VAR VAR FOR VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR STRING |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | from sys import stdin
T = int(input())
for _ in range(T):
n = int(input())
s = input()
small = ord(s[0])
for letter in s:
if ord(letter) < small:
small = ord(letter)
small_ind = []
for i in range(n):
if ord(s[i]) == small:
small_ind.append(i)
compare ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | def reverse(string):
string = "".join(reversed(string))
return string
def f(s1, k):
sr = ""
sli = list(s1)
for i in range(0, len(s1) - k + 1):
s1 = s1[:i] + reverse(s1[i : i + k]) + s1[i + k :]
return s1
for _ in range(0, int(input())):
n = int(input())
s = input()
x = mi... | FUNC_DEF ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR NUMB... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | t = int(input())
while t != 0:
t -= 1
n = int(input())
s = input()
a = 0
for i in range(1, n):
if (
s[a:] + s[:a][:: -1 if (n - a) % 2 == 1 else 1]
> s[i:] + s[:i][:: -1 if (n - i) % 2 == 1 else 1]
):
a = i
print(f"{s[a:] + s[:a][::-1 if (n - a... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER NUMBER NUMBER BIN_OP VAR VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER NUM... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | t = int(input())
for _ in range(t):
n = int(input())
s = input()
if len(s) == 1:
print(s)
print(1)
continue
res = []
for k in range(0, n):
ss = s
if (n - k) % 2 == 1:
ss = ss[k:] + ss[:k][::-1]
else:
ss = ss[k:] + ss[:k]
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR ... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | from sys import stdin, stdout
input = stdin.readline
for _ in " " * int(input()):
n = int(input())
s = list(input())[:-1]
ans = list(s)
ind = 0
for k in range(n):
if (n - k) % 2:
st = s[k:] + s[:k][::-1]
else:
st = s[k:] + s[:k]
if st < ans:
... | ASSIGN VAR VAR FOR VAR BIN_OP STRING FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VA... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | import sys
num_inputs = int(sys.stdin.readline())
k_min = 1
def modify(input, k):
mid = input[0 : k - 1]
if (len(input) - k + 1) % 2 == 1:
mid = mid[::-1]
result = input[k - 1 :] + mid
return result
def LG_smaller(first, second):
assert len(first) == len(second), "length of two strings ... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR RETURN VAR FUNC_DEF FUNC_CALL VAR VAR FUNC_CALL VAR VAR STRING IF FUNC_CAL... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | f = input
t = int(f())
for _ in [0] * t:
n, s = int(f()), f()
print(
*min((s[k:] + s[:k][:: 1 - 2 * ((n - k) % 2)], k + 1) for k in range(n)),
sep="\n"
) | ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR BIN_OP NUMBER BIN_OP NUMBER BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR STRING |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | def get_mod(s, k):
n = len(s)
if k == 1:
return s
if k == n:
return list(reversed(s))
pfx = s[k - 1 :]
if (n - k) % 2:
return pfx + s[: k - 1]
return pfx + list(reversed(s[: k - 1]))
for _ in range(int(input())):
n = int(input())
s = list(input())
if len(set... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER RETURN VAR IF VAR VAR RETURN FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER RETURN BIN_OP VAR VAR BIN_OP VAR NUMBER RETURN BIN_OP VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VA... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | t = int(input())
for _ in range(t):
n = int(input())
s = input()
l = min(
[
(
s[i:] + s[:i][::-1] + "{:04d}".format(i)
if n - i & 1
else s[i:] + s[:i] + "{:04d}".format(i)
)
for i in range(n)
]
)
prin... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR VAR VAR NUMBER FUNC_CALL STRING VAR BIN_OP BIN_OP VAR VAR VAR VAR FUNC_CALL STRING VAR VAR FUNC_CALL VAR VAR EXPR F... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | from sys import stdin
for _ in range(int(stdin.readline())):
n = int(stdin.readline().strip("\n"))
st_input = list(stdin.readline().strip("\n"))
ans = st_input[:]
ans_k = 1
for k in range(1, n + 1):
s = st_input[:]
for i in range(n - k + 1):
s[i] = st_input[i + k - 1]
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR V... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | def solve():
n = int(input())
s = input()
best = None
best_k = None
for k in range(1, n + 1):
pre = s[k - 1 :]
after = s[: k - 1]
if (len(after) + n) % 2 == 1:
after = after[::-1]
current = pre + after
if best is None or current < best:
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NONE ASSIGN VAR NONE FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER IF BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR I... |
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t... | for _ in range(int(input())):
n = int(input())
s = input()
ans = 1
ansString = s
for i in range(n - 1):
temp = s[i:] + (s[:i] if (n - i) % 2 == 0 else s[:i][::-1])
if temp < ansString:
ans = i + 1
ansString = temp
temp = s[::-1]
if temp < ansString:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN V... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.