description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
k1 = 0
for i in s:
if i == "1":
k1 += 1
k0 = 0
for i in s:
if i == "0":
k0 += 1
if i == "2":
break
ans = "0" * k0 + "1" * k1
i = 0
while i < len(s):
if s[i] == "2":
ans += "2"
i += 1
while i < len(s) and s[i] != "2":
if s[i] == "0":... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING ASSIGN VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR STRING VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input("")
num = 0
flag = False
for numero in s:
if numero == "1":
num += 1
if "2" not in s or "0" not in s:
s = "".join(sorted(s))
print(s)
quit()
for elemento in s:
if elemento == "0":
print("0", end="")
elif elemento == "2" and not flag == True:
for i in range(num):... | ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF STRING VAR STRING VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FOR VAR VAR IF VAR STRING EXPR FUNC_CALL VAR STRING STRING IF VAR STRING VAR NUMBER FOR VAR FUNC_CALL ... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
s1 = ""
c = 0
p = s.count("1")
s = s.replace("1", "")
for i in range(len(s)):
if s[i] == "1":
s1 += s[i]
s = s.replace(s[i], "3", 1)
elif s[i] == "0" and c == 0:
s1 += "0"
s = s.replace(s[i], "3", 1)
else:
c = 1
s2 = ""
s1 += "1" * p
for i in range(len(s))... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR STRING NUMBER IF VAR VAR STRING VAR NUMBER VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VA... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | n = list(input())
if "2" in n:
k = n.index("2")
new = "".join(n[k:])
grew = "".join(n[:k])
eazy = grew.count("0") * "0" + grew.count("1") * "1"
hard = new.count("1") * "1"
for el in new:
if el != "1":
hard += el
print(eazy + hard)
else:
grew = "".join(n)
eazy = gr... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL STRING VAR VAR ASSIGN VAR FUNC_CALL STRING VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR STRING STRING BIN_OP FUNC_CALL VAR STRING STRING ASSIGN VAR BIN_OP FUNC_CALL VAR STRING STRING FOR VAR VAR IF VAR STRING VAR... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input().strip()
if "2" not in s:
print("".join(sorted(s)))
exit()
z = s.index("2")
an = []
an.append("".join(sorted(s[:z])))
xx = s[z:].count("1")
an.append("1" * xx)
for i in range(z, len(s)):
if s[i] != "1":
an.append(s[i])
print("".join(an)) | ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF STRING VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR LIST EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP STRING VAR FOR VAR FUNC_CALL V... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
s = [int(i) for i in s]
s.reverse()
ans = [0] * len(s)
f = 0
r0, r1 = 0, 0
for i in s:
if i == 2:
while r0:
r0 -= 1
ans[f] = 0
f += 1
ans[f] = 2
f += 1
elif i == 1:
r1 += 1
else:
r0 += 1
while r1:
r1 -= 1
ans[f] ... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR IF VAR NUMBER WHILE VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NU... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | a = input()
ones = 0
for i in a:
if i == "1":
ones += 1
frontZeroes = 0
for i in a:
if i == "2":
break
if i == "0":
frontZeroes += 1
b = "0" * frontZeroes + "1" * ones
if a.count("2") > 0:
for i in range(a.index("2"), len(a)):
if a[i] != "1":
b += a[i]
print(b... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING IF VAR STRING VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR IF FUNC_CALL VAR STRING NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR STRING FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | n = input()
lenght = len(n)
if not "1" in n:
print(n)
elif not "2" in n:
zero = n.count("0")
string = ""
lenght -= zero
while zero:
zero -= 1
string += "0"
while lenght:
lenght -= 1
string += "1"
print(string)
elif not "0" in n:
zero = n.count("1")
str... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF STRING VAR EXPR FUNC_CALL VAR VAR IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR STRING VAR VAR WHILE VAR VAR NUMBER VAR STRING WHILE VAR VAR NUMBER VAR STRING EXPR FUNC_CALL VAR VAR IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR STRING VAR VA... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
count_ones = 0
for c in s:
if c == "1":
count_ones += 1
s = s.replace("1", "")
index = s.find("2")
if index == -1:
index = len(s)
ones = "1" * count_ones
new_string = s[:index] + ones + s[index:]
print(new_string) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = str(input())
s1 = ""
j = 0
k = 0
i = 0
l = 0
flag1 = 0
while i < len(s):
if s[i] == "2":
break
if s[i] == "0":
j += 1
elif s[i] == "1":
k += 1
i += 1
s1 += "0" * j + "1" * k
j = 0
k = 0
z1 = i
while i < len(s):
if s[i] == "2":
s1 += "2"
elif s[i] == "0":
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR NUMBER VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR ASSIGN VAR ... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | l = list(input())
s = l.count("1")
ls = []
for i in range(len(l)):
if l[i] == "1":
ls.append(i)
ls.sort(reverse=True)
for i in range(len(ls)):
del l[ls[i]]
set1 = set(l)
if "2" in set1:
m = l.index("2")
l1 = l[:m]
l2 = l[m:]
li = l1 + ["1"] * s + l2
print("".join(li))
else:
li = ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
answer = ""
p = 0
o = 1
for i in s:
if i == "1":
p = p + 1
for i in s:
if i == "0":
answer = answer + "0"
elif i == "2":
answer = answer + "1" * (o * p)
o = 0
answer = answer + "2"
answer = answer + "1" * (o * p)
print(answer) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING ASSIGN VAR BIN_OP VAR NUMBER FOR VAR VAR IF VAR STRING ASSIGN VAR BIN_OP VAR STRING IF VAR STRING ASSIGN VAR BIN_OP VAR BIN_OP STRING BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP V... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = list(map(int, input()))
try:
first_two = s.index(2)
start = sorted(s[:first_two])
end = []
for c in s[first_two:]:
if c == 1:
start.append(c)
else:
end.append(c)
sor = start + end
except:
sor = sorted(s)
print("".join(map(str, sor))) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST FOR VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR V... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = list(input())
ans = ""
t = False
cnt1 = 0
f2 = -1
pc = {"0": 0, "1": 0, "2": 0}
for i in range(len(s)):
if s[i] == "2":
t = True
if f2 == -1:
f2 = i
if not t:
pc[s[i]] += 1
if s[i] == "1" and t:
cnt1 += 1
if f2 == -1:
print("0" * pc["0"] + "1" * pc["1"])
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR IF VAR VAR VAR VAR NUMBER IF VAR VAR STRING VA... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | a = input()
count1 = 0
result = ""
for i in a:
if i == "1":
count1 += 1
else:
result += i
index = len(result) + 1
for i in range(len(result)):
if result[i] == "2":
index = i + 1
break
print(result[: index - 1] + "1" * count1 + result[index - 1 :]) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR VAR IF VAR STRING VAR NUMBER VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP STRING VAR VAR BIN_OP ... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | a = input()
s = ""
final = ""
count = 0
for i in a:
if i == "1":
count += 1
else:
s += i
s += "2"
i = s.find("2")
print(s[:i] + "1" * count + s[i:-1]) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER VAR VAR VAR STRING ASSIGN VAR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP STRING VAR VAR VAR NUMBER |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | temp = [int(x) for x in list(input())]
n = len(temp)
cnt1 = 0
cnt0 = 0
line = []
for i in temp:
if i == 1:
cnt1 += 1
else:
line.append(i)
k = len(line)
for i in range(len(line)):
if line[i] == 2:
k = i
break
cnt0 += 1
ans = [0] * cnt0 + [1] * cnt1 + line[k:]
print("".join... | ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIG... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
c1 = s.count("1")
cc = "1" * c1
if c1 == 0:
print(s)
elif s.count("2") == 0:
print("0" * s.count("0") + cc)
else:
ans = ""
for i in range(len(s)):
if s[i] != "1":
ans += s[i]
ind = ans.index("2")
ans1 = [ans[:ind], cc, ans[ind:]]
print("".join(ans1)) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP STRING VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING FUNC_CALL VAR STRING VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR VAR ASSIGN VAR FU... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = list(input())
a = []
k1 = 0
for i in range(len(s)):
if s[i] == "1":
k1 += 1
else:
a.append(s[i])
f = True
i = 0
a.append("a")
while i <= len(a):
if i == len(a) - 1 and f or a[i] == "2" and f:
f = False
for j in range(k1):
print(1, end="")
if i == len(a) - ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING WHILE VAR FUNC_CALL VAR VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR VAR STRING VAR... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | import sys
input = sys.stdin.readline
s = input().strip("\n")
b = []
c = 0
last = -1
for i in range(len(s)):
if s[i] == "1":
c += 1
else:
b.append(s[i])
if s[i] == "2" and last == -1:
last = len(b) - 1
if last != -1:
b = "".join(b[:last]) + "1" * c + "".join(b[last:])
el... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP BIN_... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | a = list(input())
a = [int(i) for i in a]
l = len(a)
i = 0
c = []
prev = 0
flag = False
b = []
fin = []
for i in a:
if i is 1 or flag is False and i is 0:
fin.append(i)
if i is 2:
flag = True
b.append(i)
if flag and i is 0:
b.append(i)
fin.sort()
print("".join([str(i) for i i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
a = []
cnt = 0
for x in s:
if x == "1":
cnt += 1
else:
a.append(x)
i = 0
while i < len(a) and a[i] == "0":
i += 1
print("0" * i + "1" * cnt + "".join(a[i:])) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR FUNC_CALL STRING VAR VAR |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = list(input())
tmp = ""
res = ""
if "0" not in s or "2" not in s:
res = "".join(sorted(s))
else:
ind = s.index("2")
res += "".join(sorted(s[:ind]))
ones = s[ind:].count("1")
res += ones * "1"
lst = [x for x in s[ind:] if x != "1"]
res += "".join(lst)
print(res) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING IF STRING VAR STRING VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR STRING VAR BIN_OP VAR STRING ASSIGN VAR VAR VAR VAR VAR VAR STRING VAR... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = str(input())
answer = []
ed_count = 0
prev_null = 0
prev_twos = 0
for el in s:
if el == "1":
ed_count += 1
elif el == "0":
if prev_null == 0:
if prev_twos != 0:
answer.append([2, prev_twos])
prev_twos = 0
prev_null += 1
else:
if... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR LIST NUMBER VAR ASSIG... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
a = ""
b = ""
for i in s:
if i == "1":
a += i
else:
b += i
n = b.find("2")
if n == -1:
ans = b + a
else:
ans = b[:n] + a + b[n:]
print(ans) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR VAR IF VAR STRING VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | u = list(map(int, input()))
n = len(u)
d0 = 0
d1 = 0
d2 = 0
dd0 = []
dd2 = []
m0 = 0
for i in range(n):
if u[i] == 1:
d1 += 1
elif u[i] == 0:
if dd2 == [] and d2 == 0:
m0 = 1
d0 += 1
if d2 != 0:
dd2.append(d2)
d2 = 0
else:
d2 += 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER IF VAR VAR NUMBER IF VAR LIST VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER IF VA... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
oneCnt = s.count("1")
sNo1s = s.replace("1", "")
oneStr = "1" * oneCnt
first2 = sNo1s.find("2")
if first2 < 0:
print(sNo1s + oneStr)
else:
print(sNo1s[:first2] + oneStr + sNo1s[first2:]) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | input_ = list(map(str, input().split("2")))
result = ""
z_counter = 0
z_list = []
o_counter = 0
for st in input_:
for s in st[:]:
if s == "1":
o_counter += 1
elif s == "0":
z_counter += 1
z_list.append(z_counter)
z_counter = 0
for i, z in enumerate(z_list):
result... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR BIN_OP STRING VAR IF VAR NU... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
t = "".join(c for c in s if c != "1")
i = (t + "2").find("2")
print(t[:i], "1" * s.count("1"), t[i:], sep="") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL STRING VAR VAR VAR VAR STRING ASSIGN VAR FUNC_CALL BIN_OP VAR STRING STRING EXPR FUNC_CALL VAR VAR VAR BIN_OP STRING FUNC_CALL VAR STRING VAR VAR STRING |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | n = input()
t = n.count("1")
n = n.replace("1", "")
if "2" in n:
r = n.index("2")
print("0" * r + "1" * t + n[r:])
else:
print("0" * n.count("0") + "1" * t) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING STRING IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING FUNC_CALL VAR STRING BIN_OP STRING VAR |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
oc = 0
zc = 0
id2 = len(s)
for i in range(len(s)):
if s[i] == "1":
oc += 1
for i in range(len(s)):
if s[i] == "0":
zc += 1
if s[i] == "2":
id2 = i
break
for i in range(zc):
print("0", end="")
for i in range(oc):
print("1", end="")
for i in range(id2, len(s... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING STRING ... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
x = ""
c = 0
for i in s:
if i != "1":
x += i
else:
c += 1
if len(x) == len(s):
print(s)
else:
z = x.find("2")
if z != -1:
for i in range(z):
print(x[i], end="")
print("1" * c + x[z:])
else:
print(x + "1" * c) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING VAR VA... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | inpt = input()
inp = list(str(inpt))
temp = []
for i in inp:
temp.append(int(i))
nums = temp[::-1]
countZero = 0
countOne = 0
res = []
for i in range(len(nums)):
if nums[i] == 0:
countZero += 1
elif nums[i] == 1:
countOne += 1
else:
res += [0] * countZero
res.append(2)
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER IF VAR VAR NUMBER VAR NUMBER VAR BIN_OP LIST... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = list(input())
ss = ""
cnt = [0, 0, 0]
i = 0
cnt = 0
while i != len(s) and s[i] in ["0", "1"]:
cnt += s[i] == "0"
i += 1
print("0" * cnt + "1" * s.count("1"), end="")
while i != len(s):
if s[i] in ["0", "2"]:
print(s[i], end="")
i += 1 | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR LIST NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR LIST STRING STRING VAR VAR VAR STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING FUNC_CALL VAR STRING STRING WHILE VAR FUNC_CALL... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
ind = 0
zeros = 0
ones = 0
while ind < len(s) and s[ind] != "2":
if s[ind] == "0":
zeros += 1
else:
ones += 1
ind += 1
suff = ""
while ind < len(s):
if s[ind] == "1":
ones += 1
else:
suff += s[ind]
ind += 1
print("0" * zeros + "1" * ones + suff) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR STRING IF VAR VAR STRING VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR STRING WHILE VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP STRING VA... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | n = list(map(str, list(input())))
a = ""
b = ""
for i in n:
if i == "1":
a += "1"
else:
b += i
n = b.find("2")
if n == -1:
print(b + a)
else:
print(b[:n] + a + b[n:]) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR VAR IF VAR STRING VAR STRING VAR VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
one = s.count("1")
if one == 0:
print(s)
exit()
ind = s.find("2")
ans = ""
for i in range(len(s)):
if i == ind:
ans += "1" * one
if s[i] == "1":
continue
ans += s[i]
if ind == -1:
ans += "1" * one
print(ans) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP STRING VAR IF VAR VAR STRING VAR VAR VAR IF VAR NUMBER VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | k = input()
a = k.count("1")
k = k.replace("1", "")
b = (k + "2").find("2")
k = k[:b] + "1" * a + k[b:]
print(k) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL BIN_OP VAR STRING STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP STRING VAR VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | a = input()
n = len(a)
s_zero = [0] * (n + 2)
if a[0] == "0":
s_zero[0] = 1
ans = ""
a += "2"
for i in range(1, n + 1):
if a[i] == "0":
s_zero[i] = s_zero[i - 1] + 1
else:
s_zero[i] = s_zero[i - 1]
pre = -1
two = 0
one = 0
zero = 0
for i in range(n + 1):
if a[i] == "2":
if pre ==... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER IF VAR NUMBER STRING ASSIGN VAR NUMBER NUMBER ASSIGN VAR STRING VAR STRING FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR STRING ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR BIN_OP V... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | t = str(input(""))
A = []
count = 0
s = ""
check = 0
j = 0
for i in range(len(t)):
if t[i] != "1":
s += t[i]
else:
count += 1
for i in range(len(s)):
if s[i] == "2":
j = i
break
else:
j = len(s)
k = j - 1
ans = s[0:j] + "1" * count + s[j:]
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASS... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
num_ones = s.count("1")
s = s.replace("1", "")
if "2" in s:
first_two = s.index("2")
s = s[0:first_two] + "1" * num_ones + s[first_two:]
else:
s += "1" * num_ones
print(s) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING STRING IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP STRING VAR VAR VAR VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR VAR |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
a = ""
s = s[::-1]
o = 0
z = 0
i = 0
while i != len(s):
if s[i] == "2":
a = a + "0" * z + "2"
z = 0
if s[i] == "0":
z += 1
if s[i] == "1":
o += 1
i += 1
a = a + "1" * o + "0" * z
a = a[::-1]
print(a) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP STRING VAR STRING ASSIGN VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR BIN... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | def main():
s = input()
if "1" in s:
t = s.replace("1", "")
u, v, *_ = t.split("2", 1) + ["*"]
print(u, "1" * (len(s) - len(t)), *(["2", v] if v != "*" else []), sep="")
else:
print(s)
main() | FUNC_DEF ASSIGN VAR FUNC_CALL VAR IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR VAR VAR BIN_OP FUNC_CALL VAR STRING NUMBER LIST STRING EXPR FUNC_CALL VAR VAR BIN_OP STRING BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR STRING LIST STRING VAR LIST STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | line = list(input())
count = 0
for i in range(len(line) - 1, -1, -1):
if line[i] == "1":
del line[i]
count += 1
try:
two = line.index("2")
newline = line[:two] + ["1"] * count + line[two:]
except:
newline = line + ["1"] * count
print(*newline, sep="") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR VAR STRING VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP LIST STRING VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP LIST STRING VAR EXPR FUNC_CALL VA... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | import sys
s = input()
cnt = 0
ans = []
for x in s:
if x == "1":
cnt += 1
else:
ans.append(x)
for i in range(len(ans)):
if ans[i] == "2":
break
else:
print("".join(ans) + "1" * cnt)
sys.exit()
print("".join(ans[:i]) + "1" * cnt + "".join(ans[i:])) | IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL STRING VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL STRING VA... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | def main():
s = input()
pos = s.find("2")
pos = len(s) if pos < 0 else pos
print("0" * s[:pos].count("0") + "1" * s.count("1") + s[pos:].replace("1", ""))
main() | FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP STRING FUNC_CALL VAR VAR STRING BIN_OP STRING FUNC_CALL VAR STRING FUNC_CALL VAR VAR STRING STRING EXPR FUNC_CALL VAR |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
prefix = ""
suffix = ""
middle = ""
seen2 = False
for c in s:
if c == "2":
seen2 = True
suffix += c
elif c == "1":
middle += c
elif seen2:
suffix += c
else:
prefix += c
print("%s%s%s" % (prefix, middle, suffix)) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING ASSIGN VAR NUMBER VAR VAR IF VAR STRING VAR VAR IF VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR VAR VAR |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | def main():
string = input()
chars = []
cnt = 0
for c in string:
if c != "1":
chars.append(c)
else:
cnt += 1
res = "".join(chars)
if "2" in string:
print(res[: res.find("2")] + "1" * cnt + res[res.find("2") :])
else:
print(res + "1" * c... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL STRING VAR IF STRING VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR FUNC_CALL VAR STRING BIN_OP STRING VAR VAR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP STRING V... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input().strip()
ones = s.count("1")
s = "".join(filter(lambda c: c != "1", s))
indx = s.find("2")
if indx == -1:
print(s + "1" * ones)
else:
print(s[:indx] + "1" * ones + s[indx:]) | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR STRING VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP STRING VAR VAR VAR |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | t = 1
for test in range(t):
n = list(input())
firstZeros = 0
onesCount = 0
for i in n:
if i == "1":
onesCount += 1
index = 0
for i in n:
if i == "0":
firstZeros += 1
elif i == "2":
break
index += 1
print("0" * firstZeros, en... | ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP STRING VAR STRING EXPR FUNC_CALL VAR BIN_OP STRING VAR STR... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
l, m, r = "", "", ""
for c in s:
if c == "1":
m += c
elif c == "2":
r += c
elif r == "":
l += c
else:
r += c
print(l + m + r) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR STRING STRING STRING FOR VAR VAR IF VAR STRING VAR VAR IF VAR STRING VAR VAR IF VAR STRING VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | a = [i for i in input()]
n = a.count("1")
b = [i for i in a if i != "1"]
if "2" in b:
x = b.index("2")
print("".join(b[:x]) + n * "1" + "".join(b[x:]))
else:
print("".join(b) + n * "1") | ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR VAR VAR VAR STRING IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL STRING VAR VAR BIN_OP VAR STRING FUNC_CALL STRING VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL STRING VAR BIN_OP VAR STRING |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
n = len(s)
t, e = 0, 0
r = ""
for i in range(n):
t += s[i] == "1"
for i in range(n):
if s[i] == "0":
r += "0"
elif s[i] == "2":
if not e:
r += "1" * t
t, e = 0, 1
r += "2"
if not e:
r += "1" * t
print(r) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR VAR VAR VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR STRING IF VAR VAR STRING IF VAR VAR BIN_OP STRING VAR ASSIGN VAR VAR NUMBER NUMBER VAR STRING IF VAR VAR BIN_OP STRING VAR EXP... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
s = list(s)
uns = 0
for n in s:
if n == "1":
uns += 1
aindanao = 1
for a in s:
if a == "2" and aindanao:
aindanao = 0
for i in range(uns):
print("1", end="")
if a != "1":
print(a, end="")
if aindanao:
aindanao = 0
for i in range(uns):
p... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING STRING IF VAR STRING EXPR FUNC_CALL VAR VAR STRING IF VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = list(str(input()))
s = [int(i) for i in s]
X = []
temp = []
for i in s:
if i != 2:
temp.append(i)
else:
X.append(temp)
temp = []
else:
X.append(temp)
ans = [[] for i in range(len(X))]
for j, x in enumerate(X):
for i in x:
if i == 1:
ans[0].append(1)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR FOR V... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = list(input())
for i in range(len(s)):
s[i] = int(s[i])
n = len(s)
ans = [i for i in s if i == 0 or i == 2]
c1 = sum([(1) for i in s if i == 1])
f2 = n
for i in range(len(ans)):
if ans[i] == 2:
f2 = i
break
ans1 = ans[:f2] + [(1) for i in range(c1)] + ans[f2:]
print("".join([str(i) for i in a... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
c = 0
l = len(s)
for i in range(len(s)):
if s[i] == "1":
c += 1
s = s.replace("1", "")
s1 = ""
if len(s) == 0:
s1 = c * "1"
print(s1)
exit(0)
for i in range(len(s)):
if s[i] == "2":
s1 = s1 + c * "1"
s1 += s[i:]
break
s1 += s[i]
if len(s1) != l:
s1... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR STRING IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CAL... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
l = ""
for x in s:
if x != "1":
l += x
two = s.count("2")
one = s.count("1")
ans = ""
if two > 0:
flag = 1
for i in range(len(l)):
if l[i] == "2" and flag == 1:
ans += "1" * one + "2"
flag = 0
else:
ans += l[i]
else:
ans = l
ans... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING FOR VAR VAR IF VAR STRING VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR STRING IF VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER VAR BIN_OP BIN_OP STRING VAR STRING ASSIGN VAR NUMBER VAR VA... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = list(input())
data = []
n = len(s)
for i in range(n):
s[i] = int(s[i])
cnt = 0
for some in s:
if some == 1:
cnt += 1
else:
data.append(some)
index = -1
for i in range(len(data)):
if data[i] == 2:
index = i
break
if index >= 0:
k = data[:index] + [(1) for _ in rang... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR IF V... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
ones = 0
a = []
for i in s:
if i == "1":
ones += 1
else:
a.append(i)
two = -1
for i in range(len(a)):
if a[i] == "2" and two == -1:
print(ones * "1", end="")
two = i
print(a[i], end="")
if two == -1:
print(ones * "1", end="") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR STRING STRING ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR VAR STRING IF VAR NUMBER EXPR FU... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
was2 = False
i = 0
am1 = 0
s1 = ""
for i in range(len(s)):
if s[i] == "1":
am1 += 1
for i in range(len(s)):
if s[i] == "2":
if not was2:
s1 += "1" * am1 + "2"
was2 = True
else:
s1 += "2"
if s[i] == "0":
s1 += "0"
if not was2:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR VAR BIN_OP BIN_OP STRING VAR STRING ASSIGN VAR NUMBER VAR STRING IF VAR VAR STRING VAR ST... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
n = 0
m = 0
h = ""
for i in range(len(s)):
if s[i] == "1":
m += 1
for i in range(len(s)):
if s[i] == "0":
n += 1
if s[i] == "2":
h += "0" * n + "1" * m + "2"
n = 0
m = 0
h += "0" * n + "1" * m
print(h) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR BIN_OP BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR STRING ASSIGN VAR NUMBER ASSIGN... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | string = input()
string = [x for x in string]
count_0 = []
count_1 = []
count_2 = []
counting_0 = 0
counting_1 = 0
counting_2 = 0
for number in string:
if number == "1":
counting_1 += 1
elif number == "0":
counting_0 += 1
else:
count_0.append(counting_0)
counting_0 = 0
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = list(input())
zeroes, ones, twos = s.count("0"), s.count("1"), s.count("2")
news = []
for i in range(len(s)):
if s[i] != "1":
news.append(s[i])
if not twos:
print("".join(news) + "1" * ones)
exit()
p = news.index("2")
newss = news[:p] + [str("1" * ones)] + news[p:]
print("".join(newss)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR VAR IF VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL STRING VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR ASSIGN ... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
m = len(s)
if "2" in s:
index = s.find("2")
s = "".join(list(sorted(list(s[:index])))) + s[index:].replace("1", "").rjust(
m - index, "1"
)
else:
s = "".join(list(sorted(list(s))))
print(s) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF STRING VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP FUNC_CALL STRING FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR STRING STRING BIN_OP VAR VAR STRING ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR V... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | def min_tr(s):
c = s.count("1")
if s[0] == "1" and s.count(s[0]) == len(s):
return s
if s.count("2") == 0:
return "".join(sorted(s))
new = ""
for i in range(len(s)):
if s[i] == "0":
new += "0"
elif s[i] == "2":
while c > 0:
new ... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER STRING FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR RETURN VAR IF FUNC_CALL VAR STRING NUMBER RETURN FUNC_CALL STRING FUNC_CALL VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR STRING IF VAR VAR STRING WHILE VAR NUMBER VAR STRIN... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | def main():
s = input()
index = s.find("2")
ones = 0
if index != -1:
for i in range(index, len(s)):
if s[i] == "1":
ones += 1
l = list(s[0:index])
l.sort()
tmp = "".join(l)
for i in range(ones):
tmp += "1"
l = list(s... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL STRING VAR FOR VAR FUNC_CALL VAR VAR VAR STRING ASSIGN VAR FUNC_CALL ... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | t = input()
t = t + "2"
Z = []
U = 0
c = 0
for i in t:
if i == "1":
U += 1
elif i == "0":
c += 1
else:
Z.append(c)
c = 0
for i in range(Z[0]):
print("0", end="")
for i in range(U):
print("1", end="")
for j in range(1, len(Z)):
print("2", end="")
for i in range... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING STRING FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | num = input()
length = len(num)
first_2 = num.find("2")
if first_2 == -1:
first_2 = length
zeros_before_first_two = num[:first_2].count("0")
ones = num.count("1")
print("0" * zeros_before_first_two, end="")
print("1" * ones, end="")
for i in range(first_2, length):
if num[i] != "1":
print(num[i], end=""... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR STRING ASSIGN VAR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP STRING VAR STRING EXPR FUNC_CALL VAR BIN_OP STRING VAR STRING FOR VAR FUNC_CALL VAR VAR VAR IF VAR VAR STRING E... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
z = ""
t = ""
o = ""
f = 0
for i in range(len(s)):
if s[i] == "0":
t += "0"
elif s[i] == "2":
t += "2"
else:
o += "1"
for i in range(len(t)):
if t[i] == "2":
t = t[:i] + o + t[i:]
f = 1
break
if f == 0:
t = t + o
print(t) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR STRING IF VAR VAR STRING VAR STRING VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR ... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | ans = []
seen = False
ones = 0
for c in input():
if c == "0":
if not seen:
print("0", end="")
else:
ans.append("0")
elif c == "1":
ones += 1
elif c == "2":
seen = True
ans.append("2")
print(*(["1"] * ones), sep="", end="")
print("".join(ans), e... | ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR IF VAR STRING IF VAR EXPR FUNC_CALL VAR STRING STRING EXPR FUNC_CALL VAR STRING IF VAR STRING VAR NUMBER IF VAR STRING ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP LIST STRING VAR STRING STRING EXPR FUNC_CALL VAR FUNC_CAL... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
ones = 0
o = []
first_two = -1
for i, x in enumerate(s):
if x == "0":
o.append(x)
elif x == "1":
ones += 1
else:
if first_two == -1:
first_two = len(o)
o.append(x)
if first_two == -1:
first_two = len(o)
one_str = "1" * ones
print("".join(o[:first_t... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING EXPR FUNC_CALL VAR VAR IF VAR STRING VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP STRING VAR EXPR FUNC_CAL... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
c1 = s.count("1")
if "2" not in s:
lens = len(s)
print("0" * (lens - c1) + "1" * c1)
else:
f2 = s.index("2")
s1 = s[:f2]
s2 = "".join(c for c in s[f2:] if c != "1")
c0 = s1.count("0")
print("0" * c0 + "1" * c1 + s2) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF STRING VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING BIN_OP VAR VAR BIN_OP STRING VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL STRING VAR VAR VAR VAR VAR STRING ASSIGN VAR FUNC_CALL VAR STRING EXPR FUNC... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
index = [0]
n = len(s)
zero = []
one = []
zo = 0
on = 0
for i in range(n):
if s[i] == "2" and i != 0:
index.append(i)
zero.append(zo)
one.append(on)
zo = 0
on = 0
elif s[i] == "0":
zo = zo + 1
elif s[i] == "1":
on = on + 1
if index[-1] != n... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR STRI... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
x1 = s.count("1")
if s.count("2") == 0:
print(s.count("0") * "0" + x1 * "1")
else:
x = s.index("2")
s1 = s[:x]
s2 = s[x:]
x0 = s1.count("0")
s2 = s2.replace("1", "")
print("0" * x0 + "1" * x1 + s2) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR STRING STRING BIN_OP VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING STRING EXPR FUNC_CA... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
n = len(s)
_0, _1, i = 0, 0, 0
while i < n and s[i] != "2":
if s[i] == "0":
_0 += 1
elif s[i] == "1":
_1 += 1
i += 1
front = "0" * _0 + "1" * _1
end = ""
for c in s[i:]:
if c == "1":
front += c
else:
end += c
print(front + end) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER WHILE VAR VAR VAR VAR STRING IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR ASSIGN VAR STRING FOR VAR VAR VAR IF VAR STRING VAR VAR VAR VAR EXPR FUNC_... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
x = s.count("1")
s = s.replace("1", "")
s = "1" * x + s
u = 0
z = 0
l = 0
ans = ""
for i in range(len(s)):
if s[i] == "2":
ans += "0" * z + "1" * u + "2"
z = 0
u = 0
elif s[i] == "1":
u += 1
elif s[i] == "0":
z += 1
ans += "0" * z + "1" * u
print(ans) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR BIN_OP BIN_OP STRING VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR ... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | def solve(s):
ones = s.count("1")
stripped = "".join([i for i in s if i != "1"])
for i in range(len(stripped)):
if stripped[i] == "2":
return stripped[:i] + "1" * ones + stripped[i:]
return stripped + "1" * ones
s = input().strip()
print(solve(s)) | FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL STRING VAR VAR VAR VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING RETURN BIN_OP BIN_OP VAR VAR BIN_OP STRING VAR VAR VAR RETURN BIN_OP VAR BIN_OP STRING VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
temp1 = ""
temp2 = ""
for x in s:
if x == "0" or x == "2":
temp1 += x
else:
temp2 += x
put = False
for i in range(len(temp1)):
if temp1[i] == "2":
temp1 = temp1[:i] + temp2 + temp1[i:]
put = True
break
if not put:
temp1 = temp1 + temp2
print(temp1) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR VAR IF VAR STRING VAR STRING VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
ones, s = s.count("1"), s.replace("1", "")
print(
s[: s.index("2")] + "1" * ones + s[s.index("2") :] if "2" in s else s + "1" * ones
) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING STRING EXPR FUNC_CALL VAR STRING VAR BIN_OP BIN_OP VAR FUNC_CALL VAR STRING BIN_OP STRING VAR VAR FUNC_CALL VAR STRING BIN_OP VAR BIN_OP STRING VAR |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
string = ""
c0 = 0
c1 = 0
c2 = 0
state = 0
p = 9999999
for i in range(len(s)):
if state == 0:
if s[i] == "1":
c1 += 1
elif s[i] == "0":
c0 += 1
else:
c2 += 1
for j in range(c0):
string += "0"
p = min(p, l... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VA... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
p = ""
c0, c1 = 0, 0
for i in range(len(s)):
if s[i] == "0":
c0 += 1
if s[i] == "1":
c1 += 1
if s[i] == "2":
p += "0" * c0 + "1" * c1 + "2"
c0, c1 = 0, 0
p += "0" * c0 + "1" * c1
if p.find("2") == -1:
print(p)
else:
c1 = 0
s2 = ""
for i in range(p.... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR BIN_OP BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR STRING ASSIGN VAR VAR NUMBER NUMBER VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | x = input()
x = x[::-1]
y = ["0"] * len(x)
ji = 0
ji1 = 0
flag = 0
for i in range(len(x)):
if x[i] == "1":
ji1 += 1
if x[i] == "2":
flag = 1
ji = max(ji, i - ji1)
y[ji] = "2"
if flag:
y = y[::-1]
for i in range(len(y)):
if y[i] == "2":
for j in range(j... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP LIST STRING FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR STRING ... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | ch = input()
p = ch.find("2")
if p == -1:
p = len(ch)
a = ch[0:p].count("0")
b = ch.count("1")
st = "0" * a + "1" * b + ch[p:].replace("1", "")
print(st) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR FUNC_CALL VAR VAR STRING STRING EXPR FUNC_CALL VAR VAR |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
cnt = 0
s1 = s2 = s3 = ""
flag = 0
for i in s:
if flag:
if i == "1":
cnt = cnt + 1
else:
s3 = s3 + i
elif i == "0":
s1 = s1 + i
elif i == "1":
cnt = cnt + 1
else:
s3 = i
flag = 1
for i in range(cnt):
s2 = s2 + "1"
pr... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR STRING ASSIGN VAR NUMBER FOR VAR VAR IF VAR IF VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR STRING ASSIGN VAR BIN_OP VAR VAR IF VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASS... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
n = len(s)
tp = ""
ans = ""
c0, c1, c2 = 0, 0, 0
for e in s:
if e == "1":
c1 = c1 + 1
elif e == "0":
c0 = c0 + 1
else:
c2 = c2 + 1
if c2 == 0:
r = "0" * c0 + "1" * c1
print(r)
else:
r = ""
z = s.index("2")
lp = s[:z]
qw = lp.count("0")
p = 0
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR VAR IF VAR STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING VAR BIN_OP STRING... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | fixed = set(["0", "2"])
def sort(ss):
out = []
count = 0
for a in ss:
if a in fixed:
out.append(a)
else:
count += 1
ind = 0
for a in out:
if a == "0":
ind += 1
continue
break
out.insert(ind, "".join(["1" for b in r... | ASSIGN VAR FUNC_CALL VAR LIST STRING STRING FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR FUNC_CALL STRING STRING VAR FUNC_CALL VAR VAR RETURN FUNC_CALL STRING VAR EXPR FUNC_CALL VAR FUNC_... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | def helper(s):
zero = s.count("0")
one = s.count("1")
two = s.count("2")
if zero == 0:
return "1" * one + "2" * two
elif one == 0:
return s
elif two == 0:
return "0" * zero + "1" * one
else:
l = ""
r = ""
f = False
for i in s:
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER RETURN BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR IF VAR NUMBER RETURN VAR IF VAR NUMBER RETURN BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR ... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | k = input()
l = list(k)
l.sort()
c = l.count("1")
s = ""
count = 0
one = 0
if c == 0:
print(k)
else:
for i in range(len(l)):
if k[i] == "0":
count += 1
elif k[i] == "2":
break
one = c + 0
maxi = count
for i in range(len(l)):
if l[i] == "0" and count > ... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN V... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | a = list(input())
n = len(a)
if "2" not in a or "0" not in a:
print("".join(sorted(a)))
else:
ind = a.index("2")
i = n - 1
ans = []
count = 0
while i >= ind:
if a[i] != "1":
ans.append(a[i])
else:
count += 1
i -= 1
ans = sorted(a[: i + 1] + ["1... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF STRING VAR STRING VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMB... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
pref = []
cnt1 = s.count("1")
s = s.replace("1", "")
i = 0
while i < len(s) and s[i] != "2":
i += 1
end = ""
if i != len(s):
end = s[i:]
s = s[:i] + "1" * cnt1 + end
print(s) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR STRING VAR NUMBER ASSIGN VAR STRING IF VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP STRING VAR VAR EXPR FUNC_CALL VAR ... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
l = len(s)
count_1 = s.count("1")
new_out = ""
red = "".join([c for c in s if c != "1"])
out = ""
try:
insert = red.index("2")
out = red[:insert] + "1" * count_1 + red[insert:]
except:
out = red + "1" * count_1
print(out) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR STRING ASSIGN VAR FUNC_CALL STRING VAR VAR VAR VAR STRING ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP STRING VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP STRING VAR EXPR FUNC_CALL V... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | st = input()
kol_1 = st.count("1")
stroka = []
lena = 0
for elem in st:
if elem != "1":
stroka += [elem]
lena += 1
i = 0
while i < lena and stroka[i] != "2":
i += 1
stroka = stroka[0:i] + ["1"] * kol_1 + stroka[i:]
print("".join(map(str, stroka))) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR LIST VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP LIST STRING VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR ... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = list(input())
s.append("2")
l = []
c = s.count("1")
f = 0
for i in range(len(s)):
if s[i] == "2" and f == 0:
for j in range(c):
l.append("1")
f = 1
l.append("2")
elif s[i] != "1":
l.append(s[i])
l = l[: len(s) - 1]
print("".join(l)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR VAR STRING EXPR F... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = input()
cnt1 = 0
ans = ""
for i in s:
if i != "1":
ans += i
else:
cnt1 += 1
f = 0
for i in range(len(ans)):
if ans[i] == "2":
ans = ans[0:i] + "1" * cnt1 + ans[i : len(ans)]
f += 1
break
if f == 0:
ans += "1" * cnt1
print(ans) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR VAR IF VAR STRING VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP STRING VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR NUMBER VAR BIN_OP STRING VAR EXPR FU... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = list(map(int, list(input())))
c = [0, 0, 0]
ans = list()
f = True
for el in s:
if el == 0 and c[2] > 0:
ans.append("0" * c[0])
if f:
ans.append("1" * s.count(1))
f = False
ans.append("2" * c[2])
c = [0, 0, 0]
if el != 1:
c[el] += 1
ans.append("... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP STRING VAR NUMBER IF VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER EX... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | def min_ternary_string(seq):
zero_two = [ch for ch in seq if ch != "1"]
ones = seq.count("1")
i = 0
while i < len(zero_two):
if zero_two[i] == "2":
break
i += 1
return "".join(zero_two[:i]) + "1" * ones + "".join(zero_two[i:])
print(min_ternary_string(input())) | FUNC_DEF ASSIGN VAR VAR VAR VAR VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER RETURN BIN_OP BIN_OP FUNC_CALL STRING VAR VAR BIN_OP STRING VAR FUNC_CALL STRING VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | def writeRestOfString(TS, result, indexOfFirstTwo):
size = len(TS)
for num in TS[indexOfFirstTwo:size]:
result += str(num)
return result
def removeAllOnesAfterFirstTwo(TS, indexOfFirstTwo):
i = indexOfFirstTwo
size = len(TS)
beginOfTS = TS[0:indexOfFirstTwo]
restOfTS = ""
while... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER VAR ASSIGN VAR STRING WHILE VAR VAR IF VAR VAR STRING VAR FUNC_CALL VAR VAR VAR VAR NUMBER RETURN BIN_OP VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUM... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = list(input())
one = 0
res = ""
for x in s:
if x == "1":
one += 1
else:
res += x
ans = -1
for i in range(len(res)):
if res[i] == "2":
ans = i
break
new_s = "1" * one
if ans == -1:
s = res + new_s
elif ans == 0:
s = new_s + res
else:
s = res[:ans] + new_s + res[... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR VAR IF VAR STRING VAR NUMBER VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR ASSIGN VAR BIN_OP STRING VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ... |
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | s = list(input())
count = 0
for i in range(len(s) - 1, -1, -1):
if s[i] == "1":
count += 1
del s[i]
try:
mark = s.index("2")
except:
mark = -1
if mark == -1:
s.extend(["1"] * count)
else:
s = s[:mark] + ["1"] * count + s[mark:]
print(*s, sep="") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR VAR STRING VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP LIST STRING VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP LIST STRING ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.