description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
n = int(input()) for i in range(n): s = input() l = [] p = [] for i in s: if int(i) % 2 == 0: l.append(i) else: p.append(i) ans = "" x, y = 0, 0 t1 = len(l) t2 = len(p) while x < t1 and y < t2: if l[x] < p[y]: a = l[x] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL V...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
t = int(input()) for i in range(t): chet = "" nechet = "" s = input() for k in s: if int(k) % 2 == 0: chet += k else: nechet += k ch_ind = 0 nech_ind = 0 flag = True if len(chet) == 0: print(nechet) elif len(nechet) == 0: print(...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VA...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
def main(): answer = "" for query in range(int(input())): _num = input() even_digits = "" odd_digits = "" for letter in _num: if int(letter) % 2 == 0: even_digits += letter else: odd_digits += letter new_num = "" ...
FUNC_DEF ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR VAR VAR VAR ASSIGN VAR STRING ASSIGN VAR VAR NUMBER NUMBER WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR FUNC_CAL...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
for _ in range(int(input())): n = list(map(int, input())) e, o = [], [] for i in n: if i % 2: o.append(i) else: e.append(i) i, j = 0, 0 while i < len(e) and j < len(o): if e[i] < o[j]: print(e[i], end="") i += 1 else: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR VAR LIST LIST FOR VAR VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR EXPR FUNC_C...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
import sys INF = 10**9 sys.setrecursionlimit(10**8) n = int(input()) for i in range(n): s = input().rstrip() odds = [] evens = [] for ch in s: if int(ch) % 2 == 0: evens.append(int(ch)) else: odds.append(int(ch)) evens.append(INF) odds.append(INF) ans...
IMPORT ASSIGN VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
tests = int(input()) for _ in range(tests): s = input() ch = [] nech = [] for i in s: if int(i) % 2 == 0: ch.append(int(i)) else: nech.append(int(i)) ch.append(100000) nech.append(100000) l = 0 r = 0 for i in range(len(s)): if ch[l] < n...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
from sys import setrecursionlimit as SRL from sys import stdin SRL(10**7) rd = stdin.readline rrd = lambda: map(int, rd().strip().split()) q = int(input()) while q: s = list(map(str, input().strip())) i = 0 j = 0 ans = [] odd = [] even = [] for i in s: if (ord(i) - ord("0")) % 2: ...
EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FO...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
a = int(input()) while a > 0: odd = [] even = [] x = input() for i in x: if int(i) % 2 == 0: even.append(int(i)) else: odd.append(int(i)) i = 0 j = 0 while i < len(even) and j < len(odd): if even[i] < odd[j]: print(even[i], end="") ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL V...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
N = int(input()) def solve(): s = input() even_list = [] odd_list = [] acc = "" for i, c in enumerate(s): ci = int(c) if ci % 2 == 0: even_list.append(c) else: odd_list.append(c) even_ptr = 0 odd_ptr = 0 ans = [None for _ in s] ans_id...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR STRING FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NONE VAR VAR ASSI...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
t = int(input()) for _ in range(t): s = input() even = "" odd = "" for i in s: if int(i) % 2 == 0: even = even + i else: odd = odd + i i = 0 j = 0 n = len(even) m = len(odd) ans = "" while i < n and j < m: if int(even[i]) < int(odd[...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VA...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
import sys def I(): return sys.stdin.readline().rstrip() for _ in range(int(I())): e, o, a = [], [], [] for c in I(): x = ord(c) - ord("0") if x & 1: o.append(x) else: e.append(x) i, j = 0, 0 while i < len(o) or j < len(e): if i < len(o) an...
IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR LIST LIST LIST FOR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER WHILE VAR FUNC...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
for i in range(int(input())): a = [int(x) for x in list(input().strip())] odd = [] even = [] an = [] for j in a: if j % 2: odd.append(j) else: even.append(j) p, q = 0, 0 for j in range(len(a)): if p == len(odd): an = an + even[q:] ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF ...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
for tc in [0] * int(input()): s = input() l = [int(i) for i in s] o = [] e = [] for i in l: if i % 2 == 0: e.append(str(i)) else: o.append(str(i)) i = 0 j = 0 a = [] while i < len(o) and j < len(e): if e[j] < o[i]: a.append(...
FOR VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
def get_min(num_s): num_s = list(map(int, list(num_s))) os = list(filter(lambda x: x % 2, num_s)) es = list(filter(lambda x: not x % 2, num_s)) osz = len(os) esz = len(es) o_idx = 0 e_idx = 0 fl = [] while o_idx < osz and e_idx < esz: e = es[e_idx] o = os[o_idx] ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR VAR VAR ...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
import sys input = lambda: sys.stdin.readline().strip() t = int(input()) for i in range(t): ls = list(map(int, list(input()))) odd = [] even = [] for i in ls: if i % 2: odd.append(i) else: even.append(i) i = 0 j = 0 ans = [] while i < len(odd) and...
IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NU...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
for _ in range(int(input())): a = list(map(int, input().rstrip())) e, o, n = [], [], len(a) while a: z = a.pop() if z % 2: o.append(z) else: e.append(z) while e or o: if e and o: if e[-1] < o[-1]: a.append(e.pop()) ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR LIST LIST FUNC_CALL VAR VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR WHILE VAR VAR IF VAR VAR IF VAR NUMBER VAR NUMBER EXPR...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
T = int(input()) for t in range(T): inp = input().strip() oddlist = [] evenlist = [] for ch in inp: num = int(ch) if num % 2 == 0: evenlist.append(num) else: oddlist.append(num) n0 = len(evenlist) n1 = len(oddlist) out = "" i = 0 j = 0 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRI...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
from sys import stdin, stdout for i in stdin: q = int(i) break for i in stdin: i = list(map(int, i.strip())) A = [] E = [j for j in i if j % 2 == 0] O = [j for j in i if j % 2 == 1] a, b = 0, 0 while a + b != len(i): if a == len(E): A.append(O[b]) b += 1 ...
FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER WHILE BIN_OP VAR VAR FUNC_CALL VAR VAR IF VAR FUNC_CALL VAR VAR EXPR ...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
for t in range(int(input())): s = input() n = len(s) l = [int(j) for j in list(s)] o = [] e = [] for i in range(n): if l[i] % 2 == 0: e.append(l[i]) else: o.append(l[i]) i = 0 j = 0 ans = [(0) for i in range(n)] while i < len(o) and j < len...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASS...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
import sys readline = sys.stdin.readline read = sys.stdin.read ns = lambda: readline().rstrip() ni = lambda: int(readline().rstrip()) nm = lambda: map(int, readline().split()) nl = lambda: list(map(int, readline().split())) prn = lambda x: print(*x, sep="\n") def solve(): s = list(map(int, list(ns()))) od = ...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR STRING FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
t = int(input()) for _ in range(t): s = list(map(int, list(input()))) ans = [] l = len(s) arr = [[], []] for i in range(l): arr[s[i] % 2].append(s[i]) l = 0 r = 0 while l < len(arr[0]) and r < len(arr[1]): if arr[0][l] < arr[1][r]: ans.append(arr[0][l]) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST LIST LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WH...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
t = int(input()) for tc in range(t): s = [int(i) for i in list(input())] evens, odds = [], [] for i in range(len(s)): if s[i] % 2: odds.append(i) else: evens.append(i) if not len(evens) or not len(odds): print("".join([str(i) for i in s])) continue...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
for _ in range(int(input())): L = [int(x) for x in input()] N = len(L) E = [] O = [] for i in L: if i & 1: O.append(i) else: E.append(i) o = 0 e = 0 ans = [] for i in range(N): if o != len(O) and e != len(E): if O[o] < E[e]:...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VA...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
for _ in range(int(input())): s = input() e = [] o = [] for i in s: if int(i) % 2: o.append(int(i)) else: e.append(int(i)) o.reverse() e.reverse() ans = [] while e and o: if e[-1] < o[-1]: ans.append(e.pop()) else: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST WHILE VAR VAR IF VAR NUMBER VAR NUMBER...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
t = int(input()) a = [] for i in range(t): a.append(input()) for i in a: k = 0 s = "" c = [] d = [] for j in i: if j == "0" and k == 0: s += "0" else: if j != "0": k = 1 if int(j) % 2 == 0: c.append(int(j)) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF VAR STRING VAR NUMBER VAR STRING IF VAR STRING ASSIGN VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
t = int(input()) for i in range(t): a = input() odds = [c for c in a if int(c) % 2] evens = [c for c in a if not int(c) % 2] o = 0 e = 0 output = [] while o != len(odds) and e != len(evens): if odds[o] < evens[e]: output += odds[o] o += 1 else: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
t = int(input()) ks = [] for i in range(t): ks.append(input()) for i in range(t): tar = ks[i] gu = [] ki = [] l_t = len(tar) for m in range(l_t): i_m = int(tar[m]) if i_m % 2 == 0: gu.append(i_m) else: ki.append(i_m) ans = "" g_l = len(gu) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CAL...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
q = int(input()) for _ in range(q): a = list(map(int, list(input()))) even = [d for d in a if d % 2 == 0] odd = [d for d in a if d % 2] ei = 0 oi = 0 for d in a: if ei == len(even) or oi != len(odd) and even[ei] > odd[oi]: print(odd[oi], end="") oi += 1 el...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
q = int(input()) for _ in range(q): s0 = "" s1 = "" s = input() ans = "" for c in s: if ord(c) % 2 == 1: s1 = s1 + c else: s0 = s0 + c l0 = 0 l1 = 0 while len(s0) > l0 and len(s1) > l1: if s0[l0] > s1[l1]: ans = ans + s1[l1] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING FOR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR VAR FUNC_C...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
for _ in range(int(input())): s = input() a = [ [int(i) for i in s if int(i) % 2 == 0] + [10], [int(i) for i in s if int(i) % 2 == 1] + [10], ] i = j = 0 res = [] while not a[0][i] == a[1][j] == 10: if a[0][i] < a[1][j]: res.append(str(a[0][i])) i ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST BIN_OP FUNC_CALL VAR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER LIST NUMBER BIN_OP FUNC_CALL VAR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER LIST NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST WHILE VAR NUMBER VAR VA...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
queries = int(input()) for x in range(queries): num = input() oddlist = [] evenlist = [] result = "" oddindex = 0 evenindex = 0 for x in num: if int(x) % 2 == 0: evenlist.append(x) else: oddlist.append(x) a = len(evenlist) b = len(oddlist) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
import sys t = int(input()) for i in range(t): n = list(sys.stdin.readline())[:-1] odd = [] even = [] e = ["0", "2", "4", "6", "8"] for j in n: if j in e: even.append(j) else: odd.append(j) op = [] x = len(n) a = 0 b = 0 al = len(odd) ...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST STRING STRING STRING STRING STRING FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR ASSIG...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
t = int(input().rstrip()) for case in range(t): ss = input().rstrip() s = ss odd_lis, even_lis = [], [] for i in range(len(ss)): if ord(ss[i]) % 2: odd_lis.append(int(ss[i])) else: even_lis.append(int(ss[i])) ans = [] lim = len(odd_lis) lim_even = len(...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VA...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
def solve(): s = input() odd = "" even = "" for i in s: if int(i) % 2 == 1: even += i else: odd += i p_odd = 0 p_even = 0 ans = "" while p_odd != len(odd) and p_even != len(even): odd_digit = odd[p_odd] even_digit = even[p_even] ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
import sys input = sys.stdin.readline t = int(input()) for _ in range(t): a = input()[:-1] even, odd = [], [] for i in range(len(a)): num = int(a[i]) if num % 2 == 0: even.append(num) else: odd.append(num) even.append(100) odd.append(100) cnt_e, c...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXP...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
t = int(input()) for i in range(t): numbers = [int(j) for j in list(input())] even = [] odd = [] for j in numbers: if j % 2 == 0: even.append(j) else: odd.append(j) even.reverse() odd.reverse() ans = [] while even and odd: if even[len(even)...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST WHILE VAR VAR IF VAR B...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
for _ in range(int(input())): a = list(input()) odd = [] even = [] for elem in a: elem = int(elem) if elem % 2 == 0: even.append(elem) else: odd.append(elem) i = 0 j = 0 output = [] for _ in range(len(a)): if i == len(odd): ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL ...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
for _ in range(int(input())): s = input() le3 = len(s) l1 = [] l2 = [] for i in s: if int(i) % 2: l1.append(int(i)) else: l2.append(int(i)) c1 = 0 c2 = 0 ans = "" le1 = len(l1) le2 = len(l2) le = len(l1 + l2) while c1 < le1 and c2 <...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VA...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
for t in range(int(input())): str = input() even = [] odd = [] for i in str: if int(i) % 2 == 0: even.append(int(i)) else: odd.append(int(i)) even.append(100) odd.append(100) i = 0 j = 0 stack = [] while even[i] != odd[j]: if even[i...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMB...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
for t in range(int(input())): n = str(input()) n = list(n) even = [] odd = [] for i in range(len(n)): if int(n[i]) % 2 == 0: even.append(int(n[i])) else: odd.append(int(n[i])) el, ol = len(even), len(odd) i = 0 j = 0 ans = [] while i < el a...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR AS...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
for _ in range(int(input())): s = input() a, b = "", "" for i, c in enumerate(s): if int(c) % 2 == 0: a += c else: b += c ia, ib = 0, 0 ans = "" while ia < len(a) and ib < len(b): if a[ia] < b[ib]: ans += a[ia] ia += 1 ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR STRING STRING FOR VAR VAR FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR VAR VAR VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR STRING WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR VAR ...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
for _ in range(int(input())): a = input().strip() n = len(a) l1 = "" l0 = "" ans = "" for i in range(n): if int(a[i]) % 2 == 0: l0 += a[i] else: l1 += a[i] i, j = 0, 0 while i < len(l1) and j < len(l0): if int(l1[i]) < int(l0[j]): ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR NUMBER NUMBER WHILE VAR FUNC_CALL VAR VAR...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
t = int(input()) for k in range(0, t): s = input() l1 = "" l2 = "" for i in s: if int(i) % 2 == 0: l1 = l1 + i else: l2 = l2 + i out = "" i = 0 j = 0 len1 = len(l1) len2 = len(l2) if l1 == "": out = l2 elif l2 == "": out...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VA...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
for _ in range(int(input())): a = [int(i) for i in input()] even = [i for i in a if i % 2 == 0] odd = [i for i in a if i % 2 == 1] even.reverse() odd.reverse() new_a = [] while even and odd: if even[-1] < odd[-1]: new_a.append(even.pop()) else: new_a.a...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST WHILE VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR E...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
n = int(input()) for _ in range(n): num = [int(x) for x in input()] l_n = len(num) odd = [x for x in num if x & 1 == 1] even = [x for x in num if x & 1 == 0] oi, ei, lo, le = 0, 0, len(odd), len(even) for _ in range(l_n): if ei == le: print("".join(str(x) for x in odd[oi:])) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR NUMBER NUMBER FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FU...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
import sys input = sys.stdin.readline Q = int(input()) Query = [] for _ in range(Q): S = list(input().rstrip()) Query.append(S) for S in Query: L = len(S) A1 = [] A2 = [] for s in S: a = int(s) if a % 2 == 0: A1.append(a) else: A2.append(a) A1...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXP...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
t = int(input()) for i in range(t): chet = [] nechet = [] res = [] a = input() a = list(a) for j in a: j = int(j) if j % 2 == 0: chet.append(j) else: nechet.append(j) chet_pos = 0 nechet_pos = 0 while chet_pos < len(chet) and nechet_pos...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WH...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
import sys def oneLineArrayPrint(arr): print("".join([str(x) for x in arr])) input = lambda: sys.stdin.readline().rstrip("\r\n") t = int(input()) for _ in range(t): a = [int(x) for x in input()] n = len(a) odd = [] even = [] for x in a: if x % 2 == 1: odd.append(x) ...
IMPORT FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF BIN_OP VAR N...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
def parity(n): n = int(n) if n % 2 == 0: return "EVEN" else: return "ODD" def swap(n): even_lst = [] odd_lst = [] for i in n: if parity(i) == "EVEN": even_lst.append(i) else: odd_lst.append(i) out = [] o, e = 0, 0 ol = len(odd...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER RETURN STRING RETURN STRING FUNC_DEF ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
def patate(n, l): for k in range(n): m = l[k] new = [] for x in m: new.append(int(x)) pair = [] impair = [] for x in new: if x % 2 == 0: pair.append(x) else: impair.append(x) new = fusion(pair...
FUNC_DEF FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR STRING FOR VAR VAR VAR FUNC_CALL VAR VA...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
for _ in range(int(input())): n = input() e = [] o = [] for c in n: if c in "02468": e.append(c) else: o.append(c) e.reverse() o.reverse() arr = [] while e and o: if e[-1] < o[-1]: arr.append(e.pop()) else: a...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST WHILE VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL ...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
t = int(input()) for _ in range(t): s = input() e = "" o = "" for i in s: if int(i) % 2 == 0: e = e + i else: o = o + i ans = "" i = 0 j = 0 while i + j < len(s): if j < len(o) and i < len(e): if int(e[i]) < int(o[j]): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR FUNC_CALL VAR...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
ans = {} test = int(input()) for each in range(test): num = input() n = len(num) num = {i: int(num[i]) for i in range(n)} output = {} even = {} odd = {} even_count = 0 odd_count = 0 for i in range(n): if num[i] % 2 == 0: even[even_count] = num[i] even_...
ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VA...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
for t in range(int(input())): st = input() li = list(map(int, st)) n = len(li) odd = [] even = [] i = 0 while i < n: if li[i] % 2 == 0: even.append(li[i]) else: odd.append(li[i]) i = i + 1 od = 0 ev = 0 while od < len(odd) and ev < ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP V...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
def process_one(n_str): list_of_digits = [int(d) for d in n_str] odds = [x for x in list_of_digits if x % 2 == 1] evens = [x for x in list_of_digits if x % 2 == 0] i, j = 0, 0 new_i, new_j = 0, 0 result = [] while True: if i < len(odds) and j < len(evens): if odds[i] < ev...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR LIST WHILE NUMBER IF VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VA...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
t = int(input()) for _ in range(t): s = input() ans = "" e = [] o = [] for d in s: if ord(d) % 2 == 0: e.append(d) else: o.append(d) e.append("Ρ‘") o.append("Ρ‘") i = 0 j = 0 while e[i] != "Ρ‘" or o[j] != "Ρ‘": if ord(e[i]) < ord(o[j]):...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
t = int(input()) while t > 0: t -= 1 p = input() p = list(p) a = [] b = [] for i in range(len(p)): if int(p[i]) % 2: a.append(p[i]) else: b.append(p[i]) d = [(0) for i in range(len(p))] i = 0 j = 0 c = [] while i < len(a) and j < len(b)...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VA...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
n = int(input()) lst_of_cases = [] for i in range(n): case = str(input()) lst_of_cases.append(case) def divide(i, sp, sn): for j in i: if int(j) % 2 == 0: sp += j else: sn += j return sp, sn def unite(i, sp, sn, output): p = 0 n = 0 for j in range(...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FUNC_DEF FOR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR VAR VAR VAR RETURN VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VA...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
t = int(input()) while t: t -= 1 st = input() odd = [] even = [] for i in st: if int(i) % 2 == 1: odd.append(i) else: even.append(i) lodd = 0 leven = 0 a = len(odd) b = len(even) s = "" while lodd < a and leven < b: if odd[lodd]...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VA...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
t = int(input()) for i in range(t): a = input() aodd = "" aeven = "" out = "" po = 0 pe = 0 for i in a: if int(i) % 2 == 1: aodd += i else: aeven += i while po != len(aodd) or pe != len(aeven): if po == len(aodd): out += aeven[p...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR VAR VAR VAR WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR FUNC_CALL VAR...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
mans = "" for _ in range(int(input())): s = input() ev = "" od = "" for x in s: if x in "13579": od += x else: ev += x ans = "" uv = 0 ud = 0 while uv < len(ev) or ud < len(od): if uv == len(ev): ans += od[ud] ud += ...
ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR VAR IF VAR STRING VAR VAR VAR VAR ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR FUNC_CALL VAR VAR VAR VAR VAR VAR NUMB...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
for a in [input() for i in range(int(input()))]: a1, a2 = [], [] for ai in a: ai = int(ai) if ai % 2: a1 += [ai] else: a2 += [ai] l1, l2 = len(a1), len(a2) if l1 == 0 or l2 == 0: print(a) continue a = [] i, j = 0, 0 while i < l1...
FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR LIST LIST FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER VAR LIST VAR VAR LIST VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR VAR NUMBER NU...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
import sys input = sys.stdin.buffer.readline def process(S): evens = [] odds = [] even_digits = set(["0", "2", "4", "6", "8"]) odd_digits = set(["1", "3", "5", "7", "9"]) for c in S: c = chr(c) if c in even_digits: evens.append(c) elif c in odd_digits: ...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR LIST STRING STRING STRING STRING STRING ASSIGN VAR FUNC_CALL VAR LIST STRING STRING STRING STRING STRING FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST AS...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
def minimize(x): x = [int(i) for i in x] numbers = [[], []] for i in x: if multiplisity(i): numbers[0].append(i) else: numbers[1].append(i) result = [] count1 = 0 count2 = 0 while count1 != len(numbers[0]) and count2 != len(numbers[1]): if numb...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR LIST LIST LIST FOR VAR VAR IF FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR VAR NUMBER VAR EXPR F...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
n = int(input()) def canSwap(a, b): return not a % 2 == b % 2 for _ in range(n): number = [*map(int, list(input()))] oddDigits = [] evenDigits = [] for digit in number: oddDigits.append(digit) if digit % 2 != 0 else evenDigits.append(digit) oddPtr = 0 evenPtr = 0 number = [] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN BIN_OP VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR EXPR BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NU...
You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). For exa...
for _ in range(int(input())): s = str(input()) odd = [] even = [] ans = [] for i in s: if int(i) % 2 == 0: even.append(i) else: odd.append(i) a = 0 b = 0 if len(odd) == 0 or len(even) == 0: print(s) else: while a < len(odd) or b...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR N...
There is an array $a$ of length $n$. You may perform the following operation any number of times: Choose two indices $l$ and $r$ where $1 \le l < r \le n$ and $a_l = a_r$. Then, set $a[l \ldots r] = [a_{l+1}, a_{l+2}, \ldots, a_r, a_l]$. You are also given another array $b$ of length $n$ which is a permutation of $a$...
for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) c = [] d = [] for i in a: if len(c) == 0: c.append([i, 1]) elif i == c[-1][0]: c[-1][1] += 1 else: c.append([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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR LIST V...
There is an array $a$ of length $n$. You may perform the following operation any number of times: Choose two indices $l$ and $r$ where $1 \le l < r \le n$ and $a_l = a_r$. Then, set $a[l \ldots r] = [a_{l+1}, a_{l+2}, \ldots, a_r, a_l]$. You are also given another array $b$ of length $n$ which is a permutation of $a$...
import sys input = sys.stdin.readline rounds = int(input()) for ii in range(rounds): out = "YES" length = int(input()) arr1 = list(map(int, input().split())) arr2 = list(map(int, input().split())) seen = {} ind1 = length - 1 ind2 = length - 1 while ind1 >= 0 and ind2 >= 0: if in...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR BIN_OP VAR NUMB...
There is an array $a$ of length $n$. You may perform the following operation any number of times: Choose two indices $l$ and $r$ where $1 \le l < r \le n$ and $a_l = a_r$. Then, set $a[l \ldots r] = [a_{l+1}, a_{l+2}, \ldots, a_r, a_l]$. You are also given another array $b$ of length $n$ which is a permutation of $a$...
import sys def solve(): inp = sys.stdin.readline n = int(inp()) a = list(map(int, inp().split())) b = list(map(int, inp().split())) w = [0] * (n + 1) j = 0 for i in range(n): x = b[i] while j < n and a[j] != x: w[a[j]] += 1 j += 1 if j == n: ...
IMPORT FUNC_DEF ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR WHILE...
There is an array $a$ of length $n$. You may perform the following operation any number of times: Choose two indices $l$ and $r$ where $1 \le l < r \le n$ and $a_l = a_r$. Then, set $a[l \ldots r] = [a_{l+1}, a_{l+2}, \ldots, a_r, a_l]$. You are also given another array $b$ of length $n$ which is a permutation of $a$...
import sys input = sys.stdin.readline for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) d = {} j = n - 1 k = n - 1 e = 0 while j >= 0 and k >= 0: if b[j] == a[k]: k = k - 1 j = j - 1 ...
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 VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER A...
There is an array $a$ of length $n$. You may perform the following operation any number of times: Choose two indices $l$ and $r$ where $1 \le l < r \le n$ and $a_l = a_r$. Then, set $a[l \ldots r] = [a_{l+1}, a_{l+2}, \ldots, a_r, a_l]$. You are also given another array $b$ of length $n$ which is a permutation of $a$...
for _ in range(int(input())): n = int(input()) a, b = [*map(int, input().split())], [*map(int, input().split())] d = {} x, i, last = n - 1, n - 1, 0 while i > 0: if b[i] == a[x]: x -= 1 last = b[i] i -= 1 elif b[i] == last: d[b[i]] = d....
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER WHILE VAR NUMBER IF VAR VAR VAR VAR VAR NUMB...
There is an array $a$ of length $n$. You may perform the following operation any number of times: Choose two indices $l$ and $r$ where $1 \le l < r \le n$ and $a_l = a_r$. Then, set $a[l \ldots r] = [a_{l+1}, a_{l+2}, \ldots, a_r, a_l]$. You are also given another array $b$ of length $n$ which is a permutation of $a$...
def ss(a, b): d = {} n = len(a) i = n - 1 j = n - 1 if a[-1] != b[-1]: return "NO" while i >= 0 and j >= 0: if a[i] == b[j]: i -= 1 j -= 1 continue if b[j] == b[j + 1]: x = b[j] if x in d: d[x] +=...
FUNC_DEF ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER RETURN STRING WHILE VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ...
There is an array $a$ of length $n$. You may perform the following operation any number of times: Choose two indices $l$ and $r$ where $1 \le l < r \le n$ and $a_l = a_r$. Then, set $a[l \ldots r] = [a_{l+1}, a_{l+2}, \ldots, a_r, a_l]$. You are also given another array $b$ of length $n$ which is a permutation of $a$...
tc = int(input()) for _ in range(tc): n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) if n == 1: print("YES") continue check = [(0) for _ in range(n + 1)] i1, i2 = 0, 0 while i1 < n and i2 < n: if a[i1] != b[i2]: 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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP...
There is an array $a$ of length $n$. You may perform the following operation any number of times: Choose two indices $l$ and $r$ where $1 \le l < r \le n$ and $a_l = a_r$. Then, set $a[l \ldots r] = [a_{l+1}, a_{l+2}, \ldots, a_r, a_l]$. You are also given another array $b$ of length $n$ which is a permutation of $a$...
t = int(input()) for _ in range(t): n = int(input()) a = [int(i) for i in input().split()] b = [int(i) for i in input().split()] if n == 1: print("YES") continue s = [(0) for i in range(max(a) + 1)] i = n - 1 j = n - 1 flag = True while i >= 0 and j >= 0: whil...
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 VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR N...
There is an array $a$ of length $n$. You may perform the following operation any number of times: Choose two indices $l$ and $r$ where $1 \le l < r \le n$ and $a_l = a_r$. Then, set $a[l \ldots r] = [a_{l+1}, a_{l+2}, \ldots, a_r, a_l]$. You are also given another array $b$ of length $n$ which is a permutation of $a$...
for case in range(int(input())): n = int(input()) a = [int(j) for j in input().split()] b = [int(j) for j in input().split()] carry = {} try: i = 0 for j in range(n): while a[i] != b[j]: carry[a[i]] = carry.get(a[i], 0) + 1 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 VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR WHILE VAR VAR VAR VAR ASSIGN VAR VAR VAR BIN_OP FUNC_CALL...
There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote. Each of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions have opposite opinions o...
class lq(list): def __init__(self): self.value = [] self.lenght = 0 self.startPos = 0 self.maxLen = 50000 def append(self, item): self.value.append(item) self.lenght += 1 def pop(self): if self.startPos < self.maxLen: rv = self.value[sel...
CLASS_DEF VAR FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF EXPR FUNC_CALL VAR VAR VAR NUMBER FUNC_DEF IF VAR VAR ASSIGN VAR VAR VAR VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER LIST ASSIGN VAR NUMBER RETURN VAR ASSIGN VAR F...
There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote. Each of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions have opposite opinions o...
n = int(input()) s = input() u = [1] * n u1 = 0 u2 = 0 c1 = s.count("D") c2 = s.count("R") while c1 != 0 and c2 != 0: for i in range(n): if s[i] == "D": if u[i] == 1: if u1 > 0: u1 -= 1 u[i] -= 1 c1 -= 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING WHILE VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR VAR NUMBER IF VAR NUMBER VAR NUMBER VAR VAR...
There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote. Each of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions have opposite opinions o...
n = int(input()) v = input() v = [v[i] for i in range(n)] d = r = 0 while len(set(v) - set([0])) != 1: for j in range(n): i = v[j] if i == "D" and d < 0: d, v[j] = d + 1, 0 elif i == "R" and r < 0: r, v[j] = r + 1, 0 elif i == "D": r -= 1 e...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER WHILE FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR STRING VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER NUMBER I...
There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote. Each of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions have opposite opinions o...
n = int(input()) s = input() dd = 0 dr = 0 while len(s) > 1: t = "" cd = 0 cr = 0 for c in s: if c == "D": if dd > 0: dd -= 1 else: dr += 1 t += c cd += 1 elif dr > 0: dr -= 1 else...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING IF VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR VAR NUMBER...
There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote. Each of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions have opposite opinions o...
n = input() s = input() cD, cR, aD, aR = 0, 0, 0, 0 for i in s: if i == "D": aD += 1 else: aR += 1 while aD > 0 and aR > 0: x = "" for i in s: if i == "D": if cD > 0: cD -= 1 aD -= 1 else: cR += 1 ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER VAR NUMBER WHILE VAR NUMBER VAR NUMBER ASSIGN VAR STRING FOR VAR VAR IF VAR STRING IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR IF VAR STRING IF VAR NUMBER VAR NUMBER VAR N...
There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote. Each of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions have opposite opinions o...
read = lambda: map(int, input().split()) n = int(input()) s = input() * 3 n2 = n * 20 was = [0] * n ri = di = 1 while ri < n2 and s[ri % n] != "R": ri += 1 while di < n2 and s[di % n] != "D": di += 1 cnt = n i = 0 nx = [0] * n while cnt > 1: if di == i: di += 1 while di < n2 and (s[di % n] !...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR NUMBER WHILE VAR VAR VAR BIN_OP VAR VAR STRING VAR NUMBER WHILE VAR VAR VAR BIN_OP VAR VAR STRING VAR NUMBER AS...
There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote. Each of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions have opposite opinions o...
n = int(input()) vote_order = input() vote_order = [i for i in vote_order] d = 0 r = 0 set_with_del = set([0]) while len(set(vote_order) - set_with_del) != 1: for i in range(n): if vote_order[i] == "D": if d < 0: d += 1 vote_order[i] = 0 else: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR LIST NUMBER WHILE FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER IF...
There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote. Each of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions have opposite opinions o...
n = int(input()) a = [] for i in input(): a.append(i) r, d = 0, 0 was_r, was_d = True, True while True: if was_r and was_d: was_r, was_d = False, False else: break for i in range(len(a)): if a[i] == "R": was_r = True if r != 0: r -= 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER WHILE NUMBER IF VAR VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN V...
There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote. Each of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions have opposite opinions o...
input() a = list(input()) + [""] cnt = 0 while len(set(a)) == 3: for i, v in enumerate(a): if v == "D": if cnt < 0: a[i] = "" cnt += 1 if v == "R": if cnt > 0: a[i] = "" cnt -= 1 for ss in set(a): if ss: prin...
EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR LIST STRING ASSIGN VAR NUMBER WHILE FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING IF VAR NUMBER ASSIGN VAR VAR STRING VAR NUMBER IF VAR STRING IF VAR NUMBER ASSIGN VAR VAR STRING VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF...
There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote. Each of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions have opposite opinions o...
l = int(input()) a = input() b = set() p, q = a.count("D"), a.count("R") r, t = 0, 0 while p > 0 and q > 0: j = 0 while j < l: if j in b: j += 1 continue else: if a[j] == "D": if r > 0: b.add(j) r = r - 1...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER NUMBER WHILE VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR NUMBER IF VAR VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN V...
There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote. Each of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions have opposite opinions o...
n = int(input()) s = input() cd = 0 cr = 0 cntd = 0 cntr = 0 for i in range(n): if s[i] == "D": cntd += 1 else: cntr += 1 a = [1] * n while cntd and cntr: for i in range(n): if a[i]: if s[i] == "D": if cd == 0: cr += 1 e...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR WHILE VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR IF VAR VAR STRING IF VAR NUMBER V...
There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote. Each of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions have opposite opinions o...
amount = int(input()) people = list(input()) D = people.count("D") R = people.count("R") ignore = set() igR = 0 igD = 0 while True: for k in range(amount): if k not in ignore: if people[k] == "R" and igR > 0: igR -= 1 ignore.add(k) elif people[k] == "D...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR IF V...
There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote. Each of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions have opposite opinions o...
n = int(input()) s = input() ds = [] rs = [] for i in range(n): if s[i] == "R": rs += [i] else: ds += [i] while len(ds) != 0 and len(rs) != 0: ds2 = [] rs2 = [] num = 0 num2 = 0 while num < len(ds) and num2 < len(rs): if ds[num] > rs[num2]: rs2 += [rs[num2...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR LIST VAR VAR LIST VAR WHILE FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VA...
There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote. Each of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions have opposite opinions o...
n = int(input()) s = list(input()) + ["#"] d = r = 0 di = {} di["D"] = 0 di["R"] = 0 for i in range(n): di[s[i]] += 1 while di["D"] != 0 and di["R"] != 0: for i in range(n): if s[i] == "@": continue if s[i] == "D": if r < d: r = d while s[r % n...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR LIST STRING ASSIGN VAR VAR NUMBER ASSIGN VAR DICT ASSIGN VAR STRING NUMBER ASSIGN VAR STRING NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER WHILE VAR STRING NUMBER VAR STRING NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF V...
There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote. Each of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions have opposite opinions o...
import sys input = sys.stdin.readline n = int(input()) vote = input() ignore = set() d = 0 r = 0 while True: new = False for i in range(n): if i not in ignore: if vote[i] == "D": if r == 0: d += 1 else: r -= 1 ...
IMPORT ASSIGN VAR 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 NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR IF VAR VAR STRING IF VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUM...
There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote. Each of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions have opposite opinions o...
a = int(input()) s = input() b = [] for c in s: if c == "D": b.append(1) else: b.append(0) cnt = [0] * 2 while True: c = [] for x in b: if cnt[x] > 0: cnt[x] -= 1 else: c.append(x) cnt[1 - x] += 1 if c == b: break b = c ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR IF VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER WHILE NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR BIN_OP NUMBER VAR NUMBER...
There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote. Each of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions have opposite opinions o...
from sys import * n = int(stdin.readline()) dem = [] rep = [] dp = 0 rp = 0 s = stdin.readline() for i in range(len(s)): if s[i] == "D": dem.append(i) if s[i] == "R": rep.append(i) j = len(rep) + len(dem) while dp < len(dem) and rp < len(rep): r = rep[rp] d = dem[dp] if r < d: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR WHILE VAR FU...
There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote. Each of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions have opposite opinions o...
n = int(input()) a = list(input()) d = 0 r = 0 count_d = -1 count_r = -1 while count_d != 0 and count_r != 0: n = len(a) count_d = 0 count_r = 0 new_list = [] while d < n and r < n: if a[d] != "D": d += 1 if a[r] != "R": r += 1 if d < n and r < n and a...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR VAR VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR...
There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote. Each of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions have opposite opinions o...
input() s = list(input()) r, d = map(s.count, ("R", "D")) rf, df = 0, 0 while r > 0 and d > 0: for i, v in enumerate(s): if v == "D": if rf: rf -= 1 d -= 1 s[i] = " " else: df += 1 elif v == "R": if d...
EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR STRING STRING ASSIGN VAR VAR NUMBER NUMBER WHILE VAR NUMBER VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR STRING VAR NUMBER IF VAR STRING IF VAR VAR NUMBER VAR NUMBER ASSIGN VA...
There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote. Each of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions have opposite opinions o...
n = int(input()) s = input() cd = s.count("D") cr = s.count("R") pr, pd = 0, 0 x = [1] * n f = "" i = 0 while f == "": if s[i] == "D": if x[i] != 0: if pd == 0: cr = cr - 1 pr = pr + 1 if cr <= 0: f = "D" bre...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR STRING ASSIGN VAR NUMBER WHILE VAR STRING IF VAR VAR STRING IF VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMB...
There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote. Each of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions have opposite opinions o...
n = int(input()) s = input() countr = s.count("R") countd = n - countr cr = 0 cd = 0 i = 0 news = [] while countr != 0 and countd != 0: if s[i] == "D": if cd == 0: cr += 1 countr -= 1 news.append("D") else: cd -= 1 elif cr == 0: cd += 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR NUMBER VAR NUMBER IF VAR VAR STRING IF VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING VAR NUMBER IF VAR NU...
There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote. Each of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions have opposite opinions o...
class Node: def __init__(self, val=None, prev=None, next=None): self.val = val self.prev = prev self.next = next class List: def __init__(self, first=None): self.first = first self.last = first def __add__(self, item): self.last.next = item item.p...
CLASS_DEF FUNC_DEF NONE NONE NONE ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR CLASS_DEF FUNC_DEF NONE ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF IF VAR VAR ASSIGN VAR VAR ASSIGN VAR NONE IF VAR VAR ASSIGN VAR VAR ASSIGN VAR NONE ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR...
There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote. Each of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions have opposite opinions o...
n = int(input()) arr = list(input()) r = arr.count("R") d = arr.count("D") i = j = 0 while r > 0 and d > 0: while arr[j] == arr[i] or arr[j] == "O": j = (j + 1) % n if arr[j] == "R": r -= 1 else: d -= 1 arr[j] = "O" c = i i = (i + 1) % n while arr[i] == "O": i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER WHILE VAR NUMBER VAR NUMBER WHILE VAR VAR VAR VAR VAR VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR ...
There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote. Each of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions have opposite opinions o...
def get_opposite_vote(vote): return "R" if vote == "D" else "D" def codeforces(votes): blocked = {"R": 0, "D": 0} while True: new_votes = "" for vote in votes: if blocked[vote] > 0: blocked[vote] -= 1 else: blocked[get_opposite_vote(v...
FUNC_DEF RETURN VAR STRING STRING STRING FUNC_DEF ASSIGN VAR DICT STRING STRING NUMBER NUMBER WHILE NUMBER ASSIGN VAR STRING FOR VAR VAR IF VAR VAR NUMBER VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR VAR IF FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER RETURN VAR NUMBER ASSIGN VAR FUNC_CALL ...
There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote. Each of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions have opposite opinions o...
n = int(input()) s = list(input()) curr_d = 0 curr_r = 0 ost_d = s.count("D") ost_r = s.count("R") while True: for i in range(len(s)): if s[i] == "D": if curr_d > 0: s[i] = "N" ost_d -= 1 curr_d -= 1 else: curr_r += 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING WHILE NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR NUMBER ASSIGN VAR VAR STRING VAR NUMBER VAR NUMBER VAR NUMBER IF...