description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
def get_ans(s, m, arr): ans = [(-1) for _ in range(m)] for i in range(m): if arr[i] == 0: ans[i] = 0 q = 1 for _ in range(m): upd = [] for curr in range(m): if ans[curr] == -1: b = 0 for comp in range(m): ...
FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR IF VA...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
import sys def rs(): return sys.stdin.readline().rstrip() def ri(): return int(sys.stdin.readline()) def ria(): return list(map(int, sys.stdin.readline().split())) def ws(s): sys.stdout.write(s + "\n") def wi(n): sys.stdout.write(str(n) + "\n") def wia(a): sys.stdout.write(" ".join([...
IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR BIN_OP VAR STRING FUNC_DEF EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR STRING FUNC_DEF EXPR FUNC_CALL VAR BIN_OP FUNC_CALL STRING...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
t = int(input()) for i in range(t): s = input() b = [] d = dict() for j in s: if j in d.keys(): d[j] += 1 else: b.append(j) d[j] = 1 b.sort(reverse=True) n = int(input()) a = list(map(int, input().split())) c = ["a"] * n m = 1 f...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_C...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
T = int(input()) for i in range(0, T): S = str(input()) m = int(input()) B = list(map(int, input().split())) vis = [] ans_int = [] S_int = [] for j in range(0, m): vis.append(0) ans_int.append(0) for j in range(0, len(S)): S_int.append(ord(S[j])) S_int.sort() ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN 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 LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR NUM...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
import sys inp = [x for x in sys.stdin.read().split()] ii = 0 ttt = int(inp[ii]) ii += 1 for _ in range(ttt): s, m = inp[ii], int(inp[ii + 1]) ii += 2 b = [int(x) for x in inp[ii : ii + m]] ii += m cnt = [0] * 26 for c in s: cnt[ord(c) - ord("a")] += 1 res = [-1] * m for c in ra...
IMPORT ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
t = int(input()) for _ in range(t): s = input() m = int(input()) b = list(map(int, input().split())) slist = [] for i in range(len(s)): slist.append(s[i]) slist.sort() slist.reverse() slist2 = [] slist2.append([slist[0], 1]) for i in range(1, len(s)): if slist2[-1...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN 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 LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASS...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
t = int(input()) for _ in range(t): di = {} for i in input(): if i in di: di[i] += 1 else: di[i] = 1 li = list(di.items()) li.sort(reverse=True) m = int(input()) b = list(map(int, input().split())) now = [0] * m ans = [None] * m for c, cnt in l...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VA...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
def get_encoded(arr, s, m): vocab = {} for letter in s: if letter in vocab: vocab[letter] += 1 else: vocab[letter] = 1 res = [""] * m stop_arr = [-1] * m while arr != stop_arr: imin = [] for i, elem in enumerate(arr): if elem == 0: ...
FUNC_DEF ASSIGN VAR DICT FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP LIST STRING VAR ASSIGN VAR BIN_OP LIST NUMBER VAR WHILE VAR VAR ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
q = int(input()) for q in range(0, q): s = input() m = int(input()) b = [int(x) for x in input().split()] count = [(0) for i in range(0, 26)] for ch in s: count[ord(ch) - ord("a")] += 1 k = 25 ans = ["a" for i in range(0, m)] okay = -1 while k >= 0: c = [] for...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN 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 NUMBER VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING NUMBER ASSIGN V...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
for _ in range(int(input())): s = list(input().strip()) m = int(input()) ans = [None] * m B = list(map(int, input().split())) s.sort(reverse=True) scnt = [] cnt = 1 for i in range(1, len(s)): if s[i] == s[i - 1]: cnt += 1 else: scnt.append(cnt) ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NONE VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR N...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
def solve(s, m, b): f = [0] * 26 for c in s: f[ord(c) - ord("a")] += 1 sol = [-1] * m def _solve(xx): for x in range(xx, -1, -1): indices = [] for i in range(m): if sol[i] == -1: hm = 0 for j in range(m): ...
FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FUNC_DEF FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
class AlphaHz: def __init__(self, s, m, b): self.s = s self.m = m self.b = b code = map(lambda x: ord(x) - ord("a"), s) self.count = [0] * 27 for c in code: self.count[c] += 1 self.mcode = 26 self.t = ["\x00"] * m def solve(self): ...
CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST STRING VAR FUNC_DEF WHILE NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR I...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
for _ in range(int(input())): s = input() m = int(input()) b = list(map(int, input().split())) alph = [0] * 26 n = len(s) ans = [""] * m for i in range(n): alph[ord(s[i]) - 97] += 1 ind = 25 while b.count(0) != 0: zero = b.count(0) while True: if a...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN 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 BIN_OP LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST STRING VAR FOR VAR FUNC_CALL VAR VAR VAR BIN_OP FU...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
def find_zeros(ss): re = [] for sss in range(len(ss)): if ss[sss] == 0: re.append(sss) return re for q in range(int(input())): s = input() m = int(input()) d = dict() cur_value = m b = list(map(int, input().split())) times = [] while len(d) != m: zer...
FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_C...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
def prog(): for _ in range(int(input())): s = list(input().strip()) m = int(input()) b = list(map(int, input().split())) s.sort(reverse=True) most = [] prev = "asdf" for val in s: if val != prev: prev = val most.appe...
FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL 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 EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR STRING FOR VAR VAR IF VAR VAR ASSIGN VAR VAR EXPR FUN...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
t = int(input()) for _ in range(t): string = [s for s in input()] dic = {} arr = [] for i in string: dic[i] = dic.get(i, 0) + 1 for i, j in dic.items(): arr.append((i, j)) arr.sort(key=lambda x: x[0]) n = int(input()) a = [int(c) for c in input().split()] ans = [None ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR AS...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
def main(): q = int(input()) for _ in range(q): s = input() m = int(input()) b = [int(x) for x in input().split()] solve(s, m, b) def solve(s, m, b): letters = sorted(set(s), reverse=True) t = ["X"] * m for l in letters: if s.count(l) < b.count(0): ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST STRING VAR F...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
t = int(input()) while t: t -= 1 s = input() m = int(input()) b = list(map(int, input().split())) ans = ["."] * m ss = "".join(list(set(sorted(s)))) idx = len(ss) - 1 while True: idxx = [] f = 0 for i in range(m): if not b[i] and ans[i] == ".": ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN 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 BIN_OP LIST STRING VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUN...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
def solve(line, bees): line = sorted(line, reverse=True) line2 = [] quant = [] for i in line: if i not in line2: line2.append(i) quant.append(1) else: quant[len(quant) - 1] += 1 line = line2 del line2 B = len(bees) result_old = [None] *...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NONE VAR ASSIGN VAR BIN_OP LIST NONE VAR WHILE FUNC_CALL ...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
import sys def minp(): return sys.stdin.readline().strip() def mint(): return int(minp()) def mints(): return map(int, minp().split()) def solve(): cnt = [0] * 26 for i in minp(): cnt[ord(i) - ord("a")] += 1 m = mint() b = list(mints()) ans = ["a"] * m j = 25 whil...
IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL ...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
def f(): a = input() n = int(input()) b = list(map(int, input().split(" "))) string = ["0"] * len(b) a = list(a) a.sort(reverse=True) temp = [] while 1: for i in range(0, len(b)): flag = 0 s = 0 if string[i] == "0": for j in ran...
FUNC_DEF ASSIGN 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 STRING ASSIGN VAR BIN_OP LIST STRING FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST WHILE NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VA...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
t = int(input()) ans = [] for _ in range(t): s = list(input()) x = sorted(set(s)) n = int(input()) l = list(map(int, input().split())) z = [0] * n while l != [-1] * n: c = 0 for i in range(n): if l[i] == 0: c += 1 while True: q = x....
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 ASSIGN VAR FUNC_CALL 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 BIN_OP LIST NUMBER VAR WHILE VAR BIN_OP ...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
import sys q = int(sys.stdin.readline()) ans_arr = [] for i in range(q): s = sys.stdin.readline().strip() m = int(sys.stdin.readline()) b = [int(j) for j in sys.stdin.readline().split()] arr = [] freq = [0] * 26 for g in range(len(s)): arr.append(s[g]) freq[ord(s[g]) - 97] += 1 ...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL 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 LIST ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUN...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
def findval(x, arr): ans = 0 for i in arr: tem = x - i if tem < 0: tem = tem * -1 ans = ans + tem return ans def findmin(arr, nrr): res = [] for i in range(len(arr)): if arr[i] == -1: continue nu = findval(i, nrr) if nu == arr...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
import sys input = sys.stdin.readline t = int(input()) for tests in range(t): S = input().strip() m = int(input()) B = list(map(int, input().split())) LIST = [0] * 26 for s in S: LIST[ord(s) - 97] += 1 ANS = [0] * m ind = 25 while max(B) >= 0: L = [] for i in ran...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL 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 BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
from sys import stdin input = stdin.readline def main(): test = int(input()) for _ in range(test): l = list(input().strip()) ss = list(set(l)) ss.sort(reverse=True) m = int(input()) b = [int(i) for i in input().split(" ")] s = ["" for i in range(m)] t =...
ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
A = ord("a") def main(): s = input() m = int(input()) b = [] for obj in input().split(): b.append(int(obj)) d = [0] * 26 for char in s: d[ord(char) - A] += 1 count_0 = m x = 25 ans = ["-"] * m while count_0 != 0: a = [] for i in range(m): ...
ASSIGN VAR FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN V...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
for ii in range(int(input())): s = input() m = int(input()) l = [int(i) for i in input().split()] dic = {} for i in s: if i in dic: dic[i] += 1 else: dic[i] = 1 li = sorted(list(dic.keys())) dic2 = {} for i in range(m): dic2[i] = l[i] j...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN 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 DICT FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT FOR ...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
import sys read = lambda: sys.stdin.readline() T = int(read()) for t in range(T): s = read() m = int(read()) b = list(map(int, read().split())) s = sorted(s, reverse=True) result = [None for i in range(m)] si = 0 while True: indx = [] num0 = 0 for i in range(m): ...
IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN 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 VAR NUMBER ASSIGN VAR NONE VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
q = int(input()) for _ in range(q): s = list(input()) m = int(input()) b = list(map(int, input().split())) numberB = [-1] * m determined = 0 index = 0 maxIndex = 0 while True: zeros = [] for i in range(m): if numberB[i] == -1 and b[i] == 0: zer...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VA...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
m = 10**9 + 7 t = int(input()) while t: t -= 1 s = input() m = int(input()) b = list(map(int, input().split())) fin = sorted(s) ans = [""] * m while "" in ans: new = [index for index, value in enumerate(b) if value == 0] while fin.count(fin[-1]) < len(new): fin = ...
ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN 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 VAR ASSIGN VAR BIN_OP LIST STRING VAR WHILE STRING VAR ASS...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
MAX = 100000000 t = int(input()) for tt in range(t): s = input() m = int(input()) b = list(map(int, input().split())) ans = ["c"] * m group = list() while True: pos = list() for i in range(m): if b[i] == 0: pos.append(i) if len(pos) == 0: ...
ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN 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 BIN_OP LIST STRING VAR ASSIGN VAR FUNC_CALL VAR WHILE NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR F...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
tests = int(input()) for _ in range(tests): s = input() n = int(input()) b = list(map(int, input().split())) g = sorted(b) ans = ["a"] * n d = dict() for i in set(s): d[i] = 0 for i in s: d[i] += 1 tec = 122 r = b.count(0) while r != 0: flag = True ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN 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 VAR ASSIGN VAR BIN_OP LIST STRING VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
letters = 26 for q in range(int(input())): s = input() m = int(input()) bs = list(map(int, input().split(" "))) vs = [(ord(c) - ord("a")) for c in s] counts = [0] * letters for v in vs: counts[v] += 1 eqs = [None] * m eqCounts = [] eqCur = 0 while True: zinds = [i...
ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN 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 STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR VAR VAR...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
def solve(s, m, arr, ans): t = [-1] * m letters = [0] * 26 for i in s: letters[ord(i) - ord("a")] += 1 limit = 25 indices = [] count = arr.count(0) while True: index = -1 for i in range(limit, -1, -1): if letters[i] >= count: limit = i - 1 ...
FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR NUMBER WHILE NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP V...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
t = int(input()) cnt = 0 while cnt < t: cnt += 1 a = [0] * 26 for i in input(): a[ord(i) - 97] += 1 a.reverse() n = int(input()) res = [" "] * n visited = [0] * n b = [int(i) for i in input().split()] pos = 0 while True: tmp = [] for i, elem in enumerate(b...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST STRING VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
letters = "abcdefghijklmnopqrstuvwxyz" T = int(input()) def min_index(bs): min_b = 2000 min_is = [] for i, b in enumerate(bs): if b == None: continue if b == min_b: min_is.append(i) if b < min_b: min_b = b min_is = [i] for i in mi...
ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR IF VAR NONE IF VAR VAR EXPR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST VAR FOR VAR VAR ASSIGN VAR VAR NONE RETURN VAR VAR FUNC_DEF FOR VAR VAR NUMBER IF VAR VAR VAR ASSIGN V...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
for _ in range(int(input())): s = input() m = int(input()) b = [int(x) for x in input().split()] indice_done = [] i = 0 ip = [] if len(indice_done) == 0: temp = [] for i in range(m): if b[i] == 0: indice_done.append(i) temp.append(i...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN 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 LIST ASSIGN VAR NUMBER ASSIGN VAR LIST IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_C...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
def update(arr, zeros, replacement): for i in range(len(arr)): if arr[i] == 0: arr[i] = replacement if isinstance(arr[i], int): arr[i] -= sum([abs(i - zero) for zero in zeros]) return arr def find(s, num): r = s[-1] if s.count(r) >= num: while s[-1] == r...
FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR VAR IF FUNC_CALL VAR VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR WHILE VAR NUMBER VAR EXPR FUNC_CALL VAR RETURN VAR VAR WHILE VAR NUMBER VAR EXP...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
T = int(input()) for _ in range(T): a = [0] * 26 for i in input().strip(): a[ord(i) - ord("a")] += 1 n = int(input()) b = list(map(int, input().split())) s = [-1] * n x = 26 while s.count(-1) > 0: x, y = x - 1, b.count(0) while a[x] < y: x -= 1 for...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST ...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
t = int(int(input(""))) while t > 0: string = input("") n = int(input("")) b = list(map(int, input().split())) l = list(string) l.sort() string_length = len(l) final = [] finished = [] for j in range(string_length): counter = string.count(l[j]) if l[j] not in finished...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR STRING WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIG...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
t = int(input()) for _ in range(t): s = list(input()) m = int(input()) a = list(map(int, input().split())) s.sort() count = 0 flag = True ans = [0] * m ptr = len(s) - 1 while count < m: temp = [] for i in range(m): if a[i] == 0: temp.append...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP FUN...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
t = int(input()) for _ in range(t): list1 = list(input()) m = int(input()) list2 = list(map(int, input().strip().split())) map1 = dict() for val in list1: if val in map1: map1[val] += 1 else: map1[val] = 1 ans = [] res = [] b = 0 while 1: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
for _ in range(int(input())): alpha = [0] * 26 s = input() for i in s: alpha[ord(i) - 97] += 1 curr = 25 n = int(input()) b = list(map(int, input().split())) ans = [""] * n visited = [False] * n com = 0 while com < n: pos = [] for i in range(n): ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST STRING...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
t = int(input()) for z in range(t): st = list(input()) n = int(input()) arr = list(map(int, input().split())) d = {} for i in range(len(st)): if st[i] not in d: d[st[i]] = 0 d[st[i]] += 1 flag = [(1) for i in range(n)] a = [] for i in range(n): if arr[...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR NUMBER VAR VAR VAR N...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
def counter(l, a): count = 0 for i in range(len(l)): if l[i] == a: count += 1 return count t = int(input()) for _ in range(t): s = list(input()) n = len(s) m = int(input()) b = list(map(int, input().split())) t = ["0"] * m while True: z = [] for ...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR F...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
T = int(input()) for _ in range(T): s = input().strip() m = int(input()) b = list(map(int, input().strip().split())) letters = [0] * 26 for l in s: letters[ord(l) - 97] += 1 z = [] for i, x in enumerate(b): if x == 0: z.append(i) res = [0] * m letter_count...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR L...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
q = int(input()) for _ in range(q): letters = [0] * 26 s = input() for a in s: letters[ord(a) - ord("a")] += 1 m = int(input()) b = list(map(int, input().split())) t = ["0"] * m deleted = 0 lastletter = 25 while deleted < m: x = b.count(0) while letters[lastle...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP ...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
def works(c, i, prob, btgt, m): val = 0 for j in range(m): if prob[j] != " " and c < prob[j]: val += abs(i - j) return val == btgt def solve0(prob, s, slack, b, m, depth): if prob.find(" ") == -1: return prob, True c = s.pop() for i in range(m): if prob[i] !...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR RETURN VAR VAR FUNC_DEF IF FUNC_CALL VAR STRING NUMBER RETURN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF FUNC_CALL VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR FUNC_C...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
T = int(input()) for _ in range(T): s = input() m = int(input()) l = list(map(int, input().split())) cnt = [0] * 26 for i in range(len(s)): cnt[ord(s[i]) - 97] += 1 ze = [] li = [] for i in range(m): if l[i] == 0: li.append(i) ze.append(li) while 1: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN 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 BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER ...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
q = int(input()) def helper(inputS, m, inputB): s = inputS.copy() b = inputB.copy() processed = set() result = [(-1) for x in b] while -1 in result: indices = [i for i in range(m) if b[i] == 0 and i not in processed] numZeros = len(indices) while len(set(s[-numZeros:])) != ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR VAR WHILE NUMBER VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR WHILE FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL V...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
import sys T = int(sys.stdin.readline()) for _ in range(T): s = list(sys.stdin.readline().strip()) m = int(sys.stdin.readline()) b = list(map(int, sys.stdin.readline().split())) result = ["0"] * m list_count = [0] * 26 for l in s: list_count[ord(l) - 97] += 1 a = 25 while True: ...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL 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 BIN_OP LIST STRING VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR BIN_OP...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
from sys import gettrace, stdin if gettrace(): inputi = input else: def input(): return next(stdin)[:-1] def inputi(): return stdin.buffer.readline() def main(): def solve(): ss = list(input()) + [" "] m = int(input()) bb = [int(a) for a in input().split()] ...
IF FUNC_CALL VAR ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR LIST STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP L...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
for tt in range(int(input())): s = [i for i in input()] n = int(input()) a = list(map(int, input().split())) cnt = [0] * 26 for i in s: cnt[ord(i) - 97] += 1 pq = [] for i in range(26): if cnt[i] != 0: pq.append((chr(i + 97), cnt[i])) ans = [""] * n zCount...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR 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 BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR N...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
t = int(input()) for _ in range(t): s = str(input()) m = int(input()) b = list(map(int, input().split())) d = {} for x in s: if x in d.keys(): d[x] += 1 else: d[x] = 1 keys = list(d.keys()) keys.sort(reverse=True) i = 0 l = 0 t = [0] * m ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR IF VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
for _ in range(int(input())): s = input() n = int(input()) arr = list(map(int, input().split())) qu = list(0 for _ in range(30)) for i in s: qu[ord(i) - ord("a")] += 1 ind = 29 ans = list("0" for i in range(len(arr))) pop = 0 while pop != len(arr): k = 0 for i...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN 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 NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING NUMBER ASSIGN VAR NU...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
def inp(): return int(input()) def inlt(): return list(map(int, input().split())) def insr(): s = input() return list(s[: len(s)]) def invr(): return map(int, input().split()) entries = inp() for i in range(entries): s = insr() z = inp() l = inlt() s.sort() s.reverse() ...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR RETURN FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CA...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
def know_new(l): place = [] for i in range(len(l)): if l[i] == 0: place.append(i) for i in range(len(b)): if b[i] != 0 and b[i] != -1: for j in range(len(place)): b[i] -= abs(i - place[j]) for e in range(len(place) - 1, -1, -1): b[place[e]]...
FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
t = int(input()) for x in range(t): s = input() s = sorted(s) s.reverse() n = int(input()) b = list(map(int, input().split(" "))) ch = ["" for i in range(len(b))] zeros = b.count(0) while zeros != 0: idx = [] for i, j in enumerate(b): if j == 0: ...
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 EXPR 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 STRING ASSIGN VAR STRING VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
for _ in range(int(input())): s = ["#"] + sorted(list(input())) n = int(input()) b = [-1] + [int(i) for i in input().split()] ans = ["#"] * (n + 1) while 0 in b: zero = [] for i in range(1, n + 1): if b[i] == 0: zero.append(i) b[i] = -1 ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST STRING FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST STRING BIN_OP VAR NUMBER WHILE NUMBER VAR ASSIGN VAR LIST FO...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
q = int(input()) for _ in range(q): s = list(input()) m = int(input()) b = list(map(int, input().split())) n = len(s) alphcnt = [0] * 26 for i in s: alphcnt[122 - ord(i)] += 1 now = [0] * m cnt = 0 u = [] for _ in range(26): end = [] for i in range(m): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR BIN_OP NUMBER FUNC_CALL VAR ...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
q = int(input()) results = [] for case in range(q): s = [c for c in input()] s_letters = sorted(list(set(s))) m = int(input()) b = list(map(int, input().split())) t = [""] * m while sum(b) != -m: zeroes = set() for i in range(m): if b[i] == 0: zeroes.a...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL 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 BIN_OP LIST STRING VAR WHILE FUN...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
for _ in range(int(input())): f = [0] * 26 s = input().strip() m = int(input()) b = list(map(int, input().split())) for i in s: f[ord(i) - 97] += 1 n = len(s) ans = ["."] * m c = 122 while 1: z = [] for i in range(0, m): if b[i] == 0: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL 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 FOR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN V...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
def fill(ans, s, arr, n): if s == []: for i in ans: if i == -1: return "-1" return "".join(ans) i = s[0] for j in range(n): if ans[j] != -1: continue chk = 0 for k in range(n): if k != j and ans[k] != -1 and ans[k] >...
FUNC_DEF IF VAR LIST FOR VAR VAR IF VAR NUMBER RETURN STRING RETURN FUNC_CALL STRING VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
t = int(input()) for i in range(t): D = list(input()) d = sorted(list(D), reverse=True) l = int(input()) S = list(map(int, input().split())) s = sorted(S) out = ["x" for x in range(l)] counter = 0 curl = "x" while max(S) > -1: ind = [] while S.count(0) > d.count(d[cou...
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 NUMBER 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 VAR ASSIGN VAR STRING VAR FUNC_CALL...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
for _ in range(int(input())): S = sorted(input()) rec = {} s = [] for i in S: if rec.get(i, 0) == 0: s.append(i) rec[i] = rec.get(i, 0) + 1 m = int(input()) b = list(map(int, input().split())) ans = ["" for i in range(m)] while True: pos = [] n...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR LIST FOR VAR VAR IF FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL V...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
def noX(ans): for i in ans: if i == "X": return False return True def updateArr(bArr, updatedThisTime): for i in range(0, len(bArr)): if bArr[i] != 0 or i not in updatedThisTime: continue subValue = 1 j = i + 1 while j < len(bArr): ...
FUNC_DEF FOR VAR VAR IF VAR STRING RETURN NUMBER RETURN NUMBER FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR VAR VAR NUMBER VAR NUMBER ASSI...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
for mda in range(int(input())): s = input() d = dict() for x in s: if d.get(x) == None: d[x] = 1 else: d[x] += 1 n = int(input()) a = list(map(int, input().split())) tt = [""] * n used = [False] * len(s) t = 0 while t != n: zero = [] ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF FUNC_CALL VAR VAR NONE ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST STRING VAR ASSIG...
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input. After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s...
nt = int(input()) while nt > 0: nt -= 1 s = input() n = int(input()) a = [] occurance = {} store = set() for x in s: store.add(x) if x in occurance: occurance[x] += 1 else: occurance[x] = 1 store = sorted(store, reverse=True) final = []...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LI...
Toad Zitz has an array of integers, each integer is between 0 and m-1 inclusive. The integers are a_1, a_2, …, a_n. In one operation Zitz can choose an integer k and k indices i_1, i_2, …, i_k such that 1 ≀ i_1 < i_2 < … < i_k ≀ n. He should then change a_{i_j} to ((a_{i_j}+1) mod m) for each chosen integer i_j. The i...
N, M = map(int, input().split()) A = [int(a) for a in input().split()] def chk(k): ret = 0 for i in range(N): a, b = A[i], (A[i] + k) % M if a <= b < ret: return 0 if ret <= a <= b or b < ret <= a: ret = a return 1 l = -1 r = M while r - l > 1: m = (l ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR IF VAR VAR VAR RETURN NUMBER IF VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR RETURN NUMBER ASSIGN VAR NUMB...
Toad Zitz has an array of integers, each integer is between 0 and m-1 inclusive. The integers are a_1, a_2, …, a_n. In one operation Zitz can choose an integer k and k indices i_1, i_2, …, i_k such that 1 ≀ i_1 < i_2 < … < i_k ≀ n. He should then change a_{i_j} to ((a_{i_j}+1) mod m) for each chosen integer i_j. The i...
n, m = map(int, input().split()) a = list(map(int, input().split())) l, r = 0, m - 1 while r > l: mid = l + r >> 1 p = 0 f = False for i in a: if i <= p <= i + mid or i <= p + m <= i + mid: continue if i < p: f = True break p = max(p, i) if...
ASSIGN VAR 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 VAR NUMBER BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR BIN_OP VA...
Toad Zitz has an array of integers, each integer is between 0 and m-1 inclusive. The integers are a_1, a_2, …, a_n. In one operation Zitz can choose an integer k and k indices i_1, i_2, …, i_k such that 1 ≀ i_1 < i_2 < … < i_k ≀ n. He should then change a_{i_j} to ((a_{i_j}+1) mod m) for each chosen integer i_j. The i...
def check(M): now = 0 for i in range(n): if (now - mas[i]) % m > M: if mas[i] > now: now = mas[i] else: return False return True n, m = list(map(int, input().split())) l = -1 r = m mas = list(map(int, input().split())) check(3) while l < r - ...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL V...
Petya studies at university. The current academic year finishes with $n$ special days. Petya needs to pass $m$ exams in those special days. The special days in this problem are numbered from $1$ to $n$. There are three values about each exam: $s_i$ β€” the day, when questions for the $i$-th exam will be published, $d_...
from sys import stdin def main(): n, m = map(int, stdin.readline().split()) s = [0] * (m + 1) d = [0] * (m + 1) c = [0] * (m + 1) check = [-1] * (n + 1) for i in range(1, m + 1): s[i], d[i], c[i] = map(int, stdin.readline().split()) check[d[i]] = i ans = [0] * (n + 1) o...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR ...
Petya studies at university. The current academic year finishes with $n$ special days. Petya needs to pass $m$ exams in those special days. The special days in this problem are numbered from $1$ to $n$. There are three values about each exam: $s_i$ β€” the day, when questions for the $i$-th exam will be published, $d_...
n, m = map(int, input().split()) prep = [] days = [-1] * n release = [] for i in range(m): s_, d_, c_ = map(int, input().split()) release.append(s_) days[d_ - 1] = i prep.append(c_) rel_on_day = {} for i, r in enumerate(release): if r - 1 in rel_on_day: rel_on_day[r - 1].append(i) else: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR VAR FUN...
Petya studies at university. The current academic year finishes with $n$ special days. Petya needs to pass $m$ exams in those special days. The special days in this problem are numbered from $1$ to $n$. There are three values about each exam: $s_i$ β€” the day, when questions for the $i$-th exam will be published, $d_...
n, m = map(int, input().split()) x = [] ans = [0] * n for i in range(m): s, d, c = map(int, input().split()) x.append([d - 1, s - 1, c, i + 1]) ans[d - 1] = m + 1 x.sort() for d, s, c, i in x: cnt = 0 while cnt < c: if s == d: print(-1) exit() if ans[s] == 0: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR NUMB...
Petya studies at university. The current academic year finishes with $n$ special days. Petya needs to pass $m$ exams in those special days. The special days in this problem are numbered from $1$ to $n$. There are three values about each exam: $s_i$ β€” the day, when questions for the $i$-th exam will be published, $d_...
I = lambda: list(map(int, input().split())) n, m = I() dates = [(0) for i in range(n + 1)] data = [] for i in range(m): d = I() + [i + 1] if dates[d[1]]: print(-1) return dates[d[1]] = m + 1 data.append(d) data.sort(key=lambda x: x[1]) for s, d, c, idx in data: x = 0 for i in ran...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR LIST BIN_OP VAR NUMBER IF VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR VAR NUMBER ...
Petya studies at university. The current academic year finishes with $n$ special days. Petya needs to pass $m$ exams in those special days. The special days in this problem are numbered from $1$ to $n$. There are three values about each exam: $s_i$ β€” the day, when questions for the $i$-th exam will be published, $d_...
n, m = map(int, input().split()) l = list() out = [0] * n for i in range(m): s1, d1, c1 = map(int, input().split()) l.append((s1, d1, c1, i)) l.sort(key=lambda x: x[1]) can = True for j in l: out[j[1] - 1] = m + 1 for i in l: c = i[2] for t in range(i[0], i[1]): if out[t - 1] == 0 and c > 0:...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR ...
Petya studies at university. The current academic year finishes with $n$ special days. Petya needs to pass $m$ exams in those special days. The special days in this problem are numbered from $1$ to $n$. There are three values about each exam: $s_i$ β€” the day, when questions for the $i$-th exam will be published, $d_...
def solve(): n, m = map(int, input().split()) deed = [0] * n exams = [] for i in range(m): s, d, c = map(int, input().split()) s -= 1 d -= 1 if deed[d]: return [-1] deed[d] = m + 1 exams.append((d, s, c, i + 1)) for d, s, c, idx in sorted(e...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR NUMBER IF VAR VAR RETURN LIST NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR B...
Petya studies at university. The current academic year finishes with $n$ special days. Petya needs to pass $m$ exams in those special days. The special days in this problem are numbered from $1$ to $n$. There are three values about each exam: $s_i$ β€” the day, when questions for the $i$-th exam will be published, $d_...
a = input().split(" ") a = [int(e) for e in a] isdc = [] for i in range(a[1]): l = input().split(" ") l = [int(e) for e in l] isdc.append([i + 1, l[0] - 1, l[1] - 1, l[2]]) l = [0] * a[0] for e in isdc: l[e[2]] = len(isdc) + 1 isdc = sorted(isdc, key=lambda one: one[2]) for exam in isdc: day = exam[...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR LIST BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR...
Petya studies at university. The current academic year finishes with $n$ special days. Petya needs to pass $m$ exams in those special days. The special days in this problem are numbered from $1$ to $n$. There are three values about each exam: $s_i$ β€” the day, when questions for the $i$-th exam will be published, $d_...
n, m = map(int, input().split()) arr = [] for i in range(1, m + 1): s, d, c = map(int, input().split()) arr.append((d, s, c, i)) arr.sort() ans = [0] * (n + 1) for d, s, c, i in arr: j = s ef = False for k in range(c): while j < d and ans[j] != 0: j += 1 if j >= d: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR VAR VAR VAR ASSIGN VAR VA...
Petya studies at university. The current academic year finishes with $n$ special days. Petya needs to pass $m$ exams in those special days. The special days in this problem are numbered from $1$ to $n$. There are three values about each exam: $s_i$ β€” the day, when questions for the $i$-th exam will be published, $d_...
n, m = map(int, input().split()) c = [] for i in range(m): c.append([int(x) for x in input().split()]) c[i].append(i + 1) a = [0] * n c.sort(key=lambda x: x[1]) for i in c: a[i[1] - 1] = m + 1 x = i[2] for j in range(i[0] - 1, i[1]): if x == 0: break if a[j] == 0: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR EXPR FUNC_CALL VAR VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER BIN...
Petya studies at university. The current academic year finishes with $n$ special days. Petya needs to pass $m$ exams in those special days. The special days in this problem are numbered from $1$ to $n$. There are three values about each exam: $s_i$ β€” the day, when questions for the $i$-th exam will be published, $d_...
class exam: def __init__(self, tickets, ex_day, prep_days, index): self.tick = tickets - 1 self.ex_day = ex_day - 1 self.prep_days = prep_days self.index = index def task(): n, m = [int(x) for x in input().split(" ")] exs = list() for i in range(m): a, b, c = [...
CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CAL...
Petya studies at university. The current academic year finishes with $n$ special days. Petya needs to pass $m$ exams in those special days. The special days in this problem are numbered from $1$ to $n$. There are three values about each exam: $s_i$ β€” the day, when questions for the $i$-th exam will be published, $d_...
import sys n, m = [int(c) for c in input().split()] s = [] d = [] c = [] studying = [] for _ in range(m): x, y, z = [int(w) for w in input().split()] s.append(x) d.append(y) c.append(z) plan = [] for i in range(1, n + 1): if i in s: indices = [k for k, x in enumerate(s) if x == i] f...
IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC...
Petya studies at university. The current academic year finishes with $n$ special days. Petya needs to pass $m$ exams in those special days. The special days in this problem are numbered from $1$ to $n$. There are three values about each exam: $s_i$ β€” the day, when questions for the $i$-th exam will be published, $d_...
n, m = map(int, input().split()) exams = [] for i in range(m): e = list(map(int, input().split())) e.append(0) e.append(i + 1) exams.append(e) exams.sort() now, have, f, ans, c = 0, [], True, [], 0 for i in range(1, n + 1): while now < m and exams[now][0] == i: have.append(exams[now][1:]) ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR NUMBER LIST NUMBER LIS...
Petya studies at university. The current academic year finishes with $n$ special days. Petya needs to pass $m$ exams in those special days. The special days in this problem are numbered from $1$ to $n$. There are three values about each exam: $s_i$ β€” the day, when questions for the $i$-th exam will be published, $d_...
a, b = map(int, input().split()) m = [0] * a m1 = [] for i in range(b): m1.append(list(map(int, input().split()))) m[m1[-1][1] - 1] = b + 1 m1[-1].append(i + 1) m1.sort(key=lambda x: x[1]) for i in m1: c = i[2] for j in range(i[0] - 1, i[1]): if m[j] == 0: m[j] = i[3] ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FU...
Petya studies at university. The current academic year finishes with $n$ special days. Petya needs to pass $m$ exams in those special days. The special days in this problem are numbered from $1$ to $n$. There are three values about each exam: $s_i$ β€” the day, when questions for the $i$-th exam will be published, $d_...
n, m = map(int, input().split()) x = [0] * n t = [] for i in range(m): s, d, c = map(int, input().split()) x[d - 1] = m + 1 t.append((d - 1, s - 1, c, i + 1)) t.sort() for d, s, c, i in t: for k in range(s, d): if not x[k]: x[k] = i c -= 1 if c == 0: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER EX...
Petya studies at university. The current academic year finishes with $n$ special days. Petya needs to pass $m$ exams in those special days. The special days in this problem are numbered from $1$ to $n$. There are three values about each exam: $s_i$ β€” the day, when questions for the $i$-th exam will be published, $d_...
import sys n, m = map(int, input().split()) sdc = [tuple(map(int, input().split())) for _ in range(m)] isdc = list(enumerate(sdc)) isdc.sort(key=lambda _: _[1][1]) a = [(0) for _ in range(n + 1)] for i, sdc in isdc: s, d, c = sdc a[d] = m + 1 for i, sdc in isdc: s, d, c = sdc for k in range(s, d): ...
IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR VAR VAR ASSIGN VAR VAR VA...
Petya studies at university. The current academic year finishes with $n$ special days. Petya needs to pass $m$ exams in those special days. The special days in this problem are numbered from $1$ to $n$. There are three values about each exam: $s_i$ β€” the day, when questions for the $i$-th exam will be published, $d_...
aa = input() n, m = [int(s) for s in aa.split(" ")] exams = [] res = [0] * n for i in range(m): aa = input() s, d, c = [int(s) for s in aa.split(" ")] el = {"s": s - 1, "d": d - 1, "c": c} exams.append(el) res[d - 1] = m + 1 for i in range(n - 1, -1, -1): if res[i] > 0: continue exam...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING ASSIGN VAR DICT STRING STRING STRING BIN_OP VAR NUMBER BIN_OP VAR NUMBER V...
Petya studies at university. The current academic year finishes with $n$ special days. Petya needs to pass $m$ exams in those special days. The special days in this problem are numbered from $1$ to $n$. There are three values about each exam: $s_i$ β€” the day, when questions for the $i$-th exam will be published, $d_...
def solve(n, m, ss, dd, cc): date = [-1] * (n + 1) for j, d in enumerate(dd): date[d] = j start = [[] for _ in range(n + 1)] for j, d in enumerate(ss): start[d].append(j) preps = [] for i in range(1, n + 1): if start[i]: preps += start[i] u = date[i] ...
FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR ...
Petya studies at university. The current academic year finishes with $n$ special days. Petya needs to pass $m$ exams in those special days. The special days in this problem are numbered from $1$ to $n$. There are three values about each exam: $s_i$ β€” the day, when questions for the $i$-th exam will be published, $d_...
n, m = map(int, input().split()) ans = [0] * n f = 0 li = [] for i in range(m): a, b, c = map(int, input().split()) li.append((b, a, c, i + 1)) li.sort() for i in range(m): b, a, c, k = li[i] ans[b - 1] = m + 1 j = a - 1 cnt = 0 while j < b and cnt < c: if ans[j] == 0: an...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR...
Petya studies at university. The current academic year finishes with $n$ special days. Petya needs to pass $m$ exams in those special days. The special days in this problem are numbered from $1$ to $n$. There are three values about each exam: $s_i$ β€” the day, when questions for the $i$-th exam will be published, $d_...
n, m = map(int, input().split()) SDC = [] ans = [0] * n D = {} for i in range(m): s, d, c = map(int, input().split()) SDC.append((s, d, c)) ans[d - 1] = m + 1 D[d - 1] = i C = [0] * m for i in range(n): if ans[i] == 0: e = 10**18 k = -1 for j in range(m): s, d, c ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR...
Petya studies at university. The current academic year finishes with $n$ special days. Petya needs to pass $m$ exams in those special days. The special days in this problem are numbered from $1$ to $n$. There are three values about each exam: $s_i$ β€” the day, when questions for the $i$-th exam will be published, $d_...
from sys import stdin, stdout def rint(): return map(int, stdin.readline().split()) n, m = rint() s = [(0) for i in range(m)] d = [(0) for i in range(m)] c = [(0) for i in range(m)] for i in range(m): s[i], d[i], c[i] = rint() s_in_day = [set() for i in range(n + 1)] for i in range(m): day = s[i] s_...
FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR...
Petya studies at university. The current academic year finishes with $n$ special days. Petya needs to pass $m$ exams in those special days. The special days in this problem are numbered from $1$ to $n$. There are three values about each exam: $s_i$ β€” the day, when questions for the $i$-th exam will be published, $d_...
n, m = map(int, input().split()) array = [0] * (n + 1) lst = [] for x in range(m): s, d, c = map(int, input().split()) lst.append((d, s, c, x + 1)) lst.sort() i = 0 flag = True for d, s, c, p in lst: x = s while c > 0 and x < d: if array[x] == 0: array[x] = p c -= 1 ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR ...
Petya studies at university. The current academic year finishes with $n$ special days. Petya needs to pass $m$ exams in those special days. The special days in this problem are numbered from $1$ to $n$. There are three values about each exam: $s_i$ β€” the day, when questions for the $i$-th exam will be published, $d_...
[n, m] = [int(x) for x in input().split()] I = 0 S = 1 D = 2 C = 3 exses = [[0, 0, 0, 0]] pops = [0] * (n + 1) i = 1 while i <= m: [s, d, c] = [int(x) for x in input().split()] exses.append([i, s, d, c]) pops[d] = i i += 1 i = 1 result = [0] * (n + 1) fail = False while i <= n: if pops[i] != 0 and e...
ASSIGN LIST VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST LIST NUMBER NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN LIST VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CA...
Petya studies at university. The current academic year finishes with $n$ special days. Petya needs to pass $m$ exams in those special days. The special days in this problem are numbered from $1$ to $n$. There are three values about each exam: $s_i$ β€” the day, when questions for the $i$-th exam will be published, $d_...
n, m = map(int, input().split()) s = [0] * (m + 1) d = [0] * (m + 1) c = [0] * (m + 1) ans = [0] * (n + 1) for i in range(1, m + 1): s[i], d[i], c[i] = map(int, input().split()) ans[d[i]] = m + 1 for i in range(1, n + 1): if ans[i] != 0: continue mn, pos = 1000, 0 for j in range(1, m + 1): ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR V...
Petya studies at university. The current academic year finishes with $n$ special days. Petya needs to pass $m$ exams in those special days. The special days in this problem are numbered from $1$ to $n$. There are three values about each exam: $s_i$ β€” the day, when questions for the $i$-th exam will be published, $d_...
def ke(i): return b[i] n, m = map(int, input().split()) a = [0] * m b = [0] * m c = [0] * m e = [] ans = [0] * n for i in range(m): a[i], b[i], c[i] = map(int, input().split()) ans[b[i] - 1] = m + 1 e.append(i) e.sort(key=ke) for i in range(m): k = 0 for j in range(a[e[i]] - 1, b[e[i]] - 1): ...
FUNC_DEF RETURN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FU...
Petya studies at university. The current academic year finishes with $n$ special days. Petya needs to pass $m$ exams in those special days. The special days in this problem are numbered from $1$ to $n$. There are three values about each exam: $s_i$ β€” the day, when questions for the $i$-th exam will be published, $d_...
R = lambda: map(int, input().split()) n, m = R() a = [] for i in range(m): s, d, c = R() a.append([d, s, c, i + 1]) a.sort() r = [0] * (n + 1) for i in range(m): r[a[i][0]] = m + 1 for i in range(m): for j in range(a[i][1], a[i][0]): if a[i][2] == 0: break elif r[j] == 0: ...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR V...
Petya studies at university. The current academic year finishes with $n$ special days. Petya needs to pass $m$ exams in those special days. The special days in this problem are numbered from $1$ to $n$. There are three values about each exam: $s_i$ β€” the day, when questions for the $i$-th exam will be published, $d_...
class exam1: def __init__(self, ind, ee): self.ind = ind self.ee = ee class exam: def __init__(self, qq, ee, pp, ind): self.qq = qq self.ee = ee self.pp = pp self.ind = ind yoar = list(map(int, input().split())) n = yoar[0] m = yoar[1] ans = [] examar = [] p...
CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL...
Petya studies at university. The current academic year finishes with $n$ special days. Petya needs to pass $m$ exams in those special days. The special days in this problem are numbered from $1$ to $n$. There are three values about each exam: $s_i$ β€” the day, when questions for the $i$-th exam will be published, $d_...
n, m = map(int, input().split()) L = [] for i in range(m): a, b, c = map(int, input().split()) L.append([b, a, c, i]) L.sort() M = [(-1) for i in range(n + 1)] for i in range(m): M[L[i][0]] = m + 1 for i in range(1, n + 1): if M[i] == -1: f = False for j in range(m): if L[j][...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NU...
Petya studies at university. The current academic year finishes with $n$ special days. Petya needs to pass $m$ exams in those special days. The special days in this problem are numbered from $1$ to $n$. There are three values about each exam: $s_i$ β€” the day, when questions for the $i$-th exam will be published, $d_...
n, m = map(int, input().split()) exams = [] examday = set() for i in range(m): s, d, c = map(int, input().split()) exams.append((i, s, d, c)) examday.add(d) prep = [0] * m s_exams = exams[:] s_exams.sort(key=lambda x: x[2]) ans = [] for day in range(1, n + 1): if day in examday: ans.append(m + 1...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR NUMBE...