description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = int(input()) k = input() answ = [] i = len(k) while True: j = i - 1 while int(k[j:i]) < n: j -= 1 if j < 0: j = 0 break while int(k[j:i]) >= n or j + 1 != i and k[j] == "0": j += 1 answ.append(k[j:i]) i = j if i <= 0: break res = 0 p = ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR WHILE NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE FUNC_CALL VAR VAR VAR VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR STRING VAR NUMBER EXPR F...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
import sys dpp = [([0] * 100) for i in range(100)] used = [([0] * 100) for i in range(100)] inf = 1 << 300 def dp(pos, i): if pos >= k: return "0" hh = n**i if pos == k - 1: return str(int(s[pos]) * hh) if used[pos][i]: return dpp[pos][i] used[pos][i] = 1 temp = s[pos]...
IMPORT ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FUNC_DEF IF VAR VAR RETURN STRING ASSIGN VAR BIN_OP VAR VAR IF VAR BIN_OP VAR NUMBER RETURN FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR VAR IF VAR VAR VAR RET...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = input() s = input() n = int(n) t1 = len(s) k = 1 sum = 0 while t1 > 0: m = 0 for i in range(0, t1): w = int(s[i:t1]) if w < n: m = i break while m < t1 - 1 and s[m] == "0": m = m + 1 sum += k * w k *= n t1 = m print(sum)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR WHILE VAR BIN_OP VAR NUMBER VAR VAR STRING AS...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = input() l = len(n) n, k = int(n), input() K, d, ans = [], 1, 0 while k: ll = l while ll > len(k) or int(k[-ll:]) >= n or k[-ll] == "0": if ll > 1: ll -= 1 else: break K += [int(k[-ll:])] k = k[:-ll] for x in K: ans += x * d d = d * n print(ans)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR VAR VAR LIST NUMBER NUMBER WHILE VAR ASSIGN VAR VAR WHILE VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR STRING IF VAR NUMBER VAR NUMBER VAR LIST FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR FOR VAR VAR ...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = int(input()) k = [int(i) for i in input()] sz = len(k) dp = [[int(1e19), -1] for i in range(sz)] dp.append([0, 1]) for i in range(sz - 1, -1, -1): if k[i] == 0: dp[i] = [dp[i + 1][0], dp[i + 1][1] * n] continue tp = 0 for j in range(i, sz): tp = tp * 10 + k[j] if tp >= n:...
ASSIGN 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 FUNC_CALL VAR NUMBER NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR LIST VAR BIN_O...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
from _collections import defaultdict n = int(input()) s = input() l = len(s) ll = len(str(n)) d = defaultdict(int) for i in range(l): for j in range(1, ll + 1): if ( i - j + 1 >= 0 and (s[i - j + 1] != "0" or j == 1) and (d[i - j] or i - j == -1) ): s...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR BIN_OP BIN_OP VAR VAR NUMBER STRING VAR...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = int(input().strip()) s = input().strip() ans = 0 j = 0 while len(s) > 0: i = 1 while i < len(s) and int(s[-i:]) < n: i += 1 if int(s[-i:]) >= n: i -= 1 while s[-i:][0] == "0" and len(s[-i:]) > 1: i -= 1 ans += int(s[-i:]) * pow(n, j) j += 1 s = s[:-i] print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR VAR NUMBER WHILE VAR VAR NUMBER STRING FUNC_CALL VAR VAR ...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = int(input()) k = input() if int(k) < n: print(k) else: power = 0 digits = 0 ans = 0 while len(k) > 0: current = 0 while ( int(k[current:]) >= n and current < len(k) or int(k[current]) == 0 and len(k) > 1 and current < le...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR NUMBER FUNC_CALL VAR VAR NUMB...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
base = int(input()) num = input() a = 0 n = "" l = [] sk = len(str(base)) while num: nn = num[-sk:] j = 0 while int(nn) >= base: j += 1 nn = nn[1:] while len(nn) > 1 and nn[0] == "0": j += 1 nn = nn[1:] l.append(int(nn)) num = num[: -sk + j] p = 1 for n in l: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR WHILE VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER VAR NUMBER STRING VAR ...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
t, m = input(), input() n, d = int(t), len(t) s, p = 0, 1 j = len(m) while j: i = max(0, j - d) k = int(m[i:j]) if k >= n: i += 1 k = int(m[i:j]) while m[i] == "0" and i < j - 1: i += 1 j = i s += k * p p *= n print(s)
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR WHILE VAR VAR S...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
def getint(a): return int("".join(map(str, a))) b = int(input()) s = input() s = list(map(int, list(s))) n = len(s) DP = [(-1, 0) for i in range(n + 1)] for i in range(n - 1, -1, -1): pass for j in range(i + 1, n + 1): a = getint(s[i:j]) pass if a >= b: break if...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUM...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
inf = int(1e18) B = int(input()) s = input() power = [] power.append(1) LIMIT = 0 dp = [] def value(l, r): ans = 0 for i in range(l, r + 1): c = int(s[i]) - int("0") ans = ans * 10 + c return ans def min(a, b): if a < b: return a else: return b def f(l, r, i): ...
ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_O...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = int(input()) k = input() pos = len(k) ans = [] while pos > 0: tmp = 0 l = pos - 1 mark = l while l >= 0: a = int(k[l:pos]) if a >= n: break else: if a != tmp: mark = l tmp = a l -= 1 if tmp == 0: pos ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST WHILE VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR NUMBER IF VAR NUMBER V...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
base = int(input()) number = input() n = i = len(number) - 1 ans = power = 0 while n >= 0: i = n while i >= 0 and int(number[i : n + 1]) < base: i -= 1 while i < n - 1 and number[i + 1] == "0": i += 1 ans += int(number[i + 1 : n + 1]) * base**power n = i power += 1 print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER WHILE VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER WHILE VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR BIN_OP FUNC...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = int(input()) k = input() z = 0 w = 0 j = len(k) - 1 i = j while j >= 0: r = j - 1 while r >= 0 and k[r] == "0": r -= 1 if j >= 0 and k[j] == "0" and (i - r + 1 > 10 or int(k[r : i + 1]) >= n): if j == i: w += 1 j -= 1 i -= 1 else: z...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR VAR STRING VAR NUMBER IF VAR NUMBER VAR VAR STRING BIN_OP BIN_OP VAR VAR NUMBER NUMBER FUNC_CAL...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = 0 k = "" mem = [[(-1) for xx in range(66)] for yy in range(66)] def go(ind, po): global n global k global mem if ind >= len(k): return 0 if mem[ind][po] != -1: return mem[ind][po] for i in range(ind, len(k)): cur = int(k[ind : i + 1][::-1]) if cur >= n: ...
ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER FUNC_DEF IF VAR FUNC_CALL VAR VAR RETURN NUMBER IF VAR VAR VAR NUMBER RETURN VAR VAR VAR FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR IF VAR VAR STR...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
def solve(n, k): dp = [420] * (len(k) + 1) dp[-1] = 0 idx = len(k) - 1 n_num = int(n) while idx >= 0: if k[idx] != "0": for shift in range(1, len(k) - idx + 1): ok = int(k[idx : idx + shift]) < n_num if ok: dp[idx] = min(dp[idx]...
FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR NUMBER IF VAR VAR STRING FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP VAR V...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
INF = int(1e18) def reverse(s): for i in range(len(s) // 2): s[i], s[len(s) - i - 1] = s[len(s) - i - 1], s[i] return s dp = [] for i in range(61): dp += [[]] for j in range(61): dp[i] += [[]] for k in range(61): dp[i][j] += [INF] n = int(input()) ff = input() k =...
ASSIGN VAR FUNC_CALL VAR NUMBER FUNC_DEF FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR VAR RETURN VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR LIST LIST FOR VAR FUNC_CALL VAR NUMBER VAR VAR L...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
import sys input = sys.stdin.readline n = int(input()) k = input().rstrip() dp = [10**70] * (len(k) + 1) dp[0] = 0 for i in range(1, len(k) + 1): for j in range(i): if int(k[j:i]) < n and (k[j] != "0" or j == i - 1): dp[i] = min(dp[i], dp[j] * n + int(k[j:i])) print(dp[-1])
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST BIN_OP NUMBER NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR VAR VAR...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = int(input()) s = input() ans = 0 cs = "" cp = 1 def get_digit(s, n): for i in range(len(s)): if int(s[i:]) < n and s[i] != "0": return int(s[i:]), s[:i] return 0, s[:-1] while s: d, s = get_digit(s, n) ans += d * cp cp *= n print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR VAR VAR STRING RETURN FUNC_CALL VAR VAR VAR VAR VAR RETURN NUMBER VAR NUMBER WHILE VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
b = 0 value = 0 v = "" b = int(input("")) v = input("") vetor = [] aux = "" while len(v) > 0: n = v[-1] + aux if int(n) >= b: vetor.append(aux) if aux[0] == "0" and len(aux) > 1: i = 0 while i < len(aux) - 1: if aux[i] == "0": v += aux[...
ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR STRING WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR IF VAR NUMBER STRING FUNC_CALL VAR VAR NUM...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = int(input()) k = [0] + list(map(int, list(input()))) def calc(l, r): if k[l] == 0 and l < r - 1: return -1 res = 0 for i in range(max(l, 0), r): res *= 10 res += k[i] return res z = [] last_index = len(k) index = len(k) - 1 while index >= -1: c = calc(index, last_inde...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF IF VAR VAR NUMBER VAR BIN_OP VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR VAR NUMBER VAR VAR VAR RETURN VAR ASSIGN VAR LIST ASSIGN VA...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
import sys n = int(sys.stdin.readline()) s = sys.stdin.readline()[:-1] l = [] m = len(s) i = m - 1 dp = [(0) for x in range(m)] for i in range(m): zero = False fzero = -1 j = i while j >= 0: if s[j] == "0": zero = True if int(s[j : i + 1]) < n: last = j ...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER IF VAR VAR STRING ASSIGN VAR NUMBE...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = input() s = input() k = len(n) n = int(n) a = [] i = len(s) - 1 l = 0 while i - k + 1 >= 0: if int(s[i - k + 1 : i + 1]) < n: z = len(str(int(s[i - k + 1 : i + 1]))) a.append(int(s[i - z + 1 : i + 1])) i -= z else: z = len(str(int(s[i - k + 2 : i + 1]))) a.append(int(...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP BIN_OP VAR VAR NUMBER NUMBER IF FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL ...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
k = int(input()) n = input() if n == "0": print(0) exit(0) cp = 1 ans = 0 cn = "" cz = 0 for i in range(len(str(n))): ls = n[-1] n = n[:-1] if ls == "0": cz += 1 else: sn = ls + "0" * cz + cn if int(sn) < k: cn = sn cz = 0 else: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR STRING VAR NU...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = int(input()) k = int(input()) arr = [] idx = 0 while k > 0: while 10**idx <= k and k % 10**idx < n: idx += 1 if k % 10**idx >= n: idx -= 1 while idx > 1 and k % 10**idx == k % 10 ** (idx - 1): idx -= 1 arr.append(k % 10**idx) k //= 10**idx idx = 0 mul = 1 sm = 0 for i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR NUMBER WHILE BIN_OP NUMBER VAR VAR BIN_OP VAR BIN_OP NUMBER VAR VAR VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR VAR VAR NUMBER WHILE VAR NUMBER BIN_OP VAR BIN_OP NUMBER VAR BIN_OP VAR BIN_OP NUMBER B...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = int(input()) k = int(input()) l = 1 t = n - 1 while True: t //= 10 if t <= 0: break l += 1 b = 10**l p = [] while k > 0: u = b m = k % u while m > 0: if m < n and 10 * m >= u: k //= u break u //= 10 m = k % u else: k //= 10 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR LIST WHILE VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR WHILE VAR NUMBER IF VAR VAR BIN_OP NUMBER V...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
dp = [float("inf") for i in range(100)] dp[0] = 0 n = int(input()) s = input() ln = len(s) s = "." + s for i in range(1, ln + 1): for j in range(1, i + 1): e = s[j : i + 1] e = int(e) if i - j + 1 > len(str(e)): continue vl = dp[j - 1] if e >= n: conti...
ASSIGN VAR FUNC_CALL VAR STRING VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP STRING VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR BIN...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = input() k = input() nums = [] intn = int(n) l = len(n) i = len(k) curl = l while True: if i - curl < 0: cur = k[:i] else: cur = k[i - curl : i] if len(cur) > 1 and cur[0] == "0": curl -= 1 continue if int(cur) < intn: nums.append(int(cur)) i = i - curl...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR WHILE NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR NUMBER STRING VAR NUMBER IF F...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = int(input()) k = list(map(int, list(input()))) m = len(k) rec = [0] * (m + 1) for i in range(m): u = rec[i] * n if k[i] > 0: d = 0 for j in range(i, m): d = d * 10 + k[j] if d >= n: break if rec[j + 1]: rec[j + 1] = min(rec[...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR ...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
def init(dp): for i in range(70): for j in range(70): dp[i][j] = -1 def memo(cnt, power, N, K, dp): if cnt >= len(K): return 0 if dp[cnt][power] >= 0: return dp[cnt][power] res = 1 << 100 base = N**power if power < 0: return res if K[cnt] == "0":...
FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR NUMBER FUNC_DEF IF VAR FUNC_CALL VAR VAR RETURN NUMBER IF VAR VAR VAR NUMBER RETURN VAR VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER RETURN VAR IF VAR VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
base = int(input()) k = input() k = k[::-1] n = len(k) dp = [[int(1e18) for i in range(0, 2 * n + 1)] for j in range(0, n + 1)] for i in range(0, n + 1): dp[n][i] = 0 for i in reversed(range(0, n)): for k1 in range(0, n): for j in range(i, n): if k[j] == "0" and i != j: conti...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR NUMBER ...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
from sys import stdin, stdout base = stdin.readline().strip() num = stdin.readline().strip() ans = [] i = len(num) - len(base) while i >= 0: j = i while num[j] == "0" and j < i + len(base) - 1: j += 1 if int(num[j : i + len(base)]) >= int(base): j += 1 while num[j] == "0" and j < i ...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR WHILE VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR STRING VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER IF FUNC_CALL VAR VAR VAR BIN_OP VAR FUNC_CALL VAR VAR FUNC_CALL VAR V...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
def powr(a, r): if r == 0: return 1 tmp = powr(a, r >> 1) tmp = tmp * tmp if r & 1: tmp *= a return tmp n = int(input("")) k = str(input()) l = len(k) dp = [(1e20, 1e20) for i in range(l + 1)] dp[l] = 0, 0 dp[l - 1] = int(k[l - 1]), 1 for i in range(l - 2, -1, -1): if k[i] == "...
FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NU...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = int(input()) k = input() l = len(k) ans = 0 b = 1 i = l - 1 while i >= 0: sum = 0 res = i for j in range(i, -1, -1): sum += (ord(k[j]) - ord("0")) * 10 ** (i - j) res = j if sum >= n: res = j + 1 break for j in range(res, i + 1): if k[j] == "0"...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING BIN_OP NUMB...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
was = {} dp = {} def solve(id, cnt): if id == -1: return 0 if was.get((id, cnt)) != None: return dp[id, cnt] else: was[id, cnt] = True dp[id, cnt] = 10**18 for i in range(0, id + 1): cur = 0 for j in range(i, id + 1): cur = cu...
ASSIGN VAR DICT ASSIGN VAR DICT FUNC_DEF IF VAR NUMBER RETURN NUMBER IF FUNC_CALL VAR VAR VAR NONE RETURN VAR VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BI...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
def findMin(base, number, power): len_base = len(base) len_number = len(number) BASE = int(base) if int(number) < int(base): return int(number) * int(base) ** power else: for i in range(len_base, 0, -1): if number[-1 * i] == "0": continue elif ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN BIN_OP FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF VAR BIN_OP NUMBER VAR STRING IF FUNC_CALL VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR B...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
import sys k = int(input()) t = input() n = len(t) inf = 10**18 + 1 dp = [inf] * (n + 1) for i in range(n + 1): dp[i] = [inf] * (n + 1) t = t[::-1] dp[0][0] = 0 for i in range(n + 1): for j in range(n + 1): if dp[i][j] == inf: continue cur = 0 for len in range(0, n): ...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP LIST VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
def check(i, new, s): d = "" while i >= 0 and not int(s[i]): d = s[i] + d i -= 1 if i >= 0: d = s[i] + d if int(d + new) >= n: return "" return d n = int(input()) s = input() m = [] i = len(s) - 1 while i >= 0: new = s[i] i -= 1 add = check(i, new, s) ...
FUNC_DEF ASSIGN VAR STRING WHILE VAR NUMBER FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR IF FUNC_CALL VAR BIN_OP VAR VAR VAR RETURN STRING RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP FUNC_CALL ...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
N = input().strip() K = input().strip() al = [] while K != "": best = 0 for i in range(len(K)): if ( int(K[i : len(K)]) < int(N) and K[i] != "0" or K[i] == "0" and i == len(K) - 1 ): best = i break al.append(K[best : len...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST WHILE VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR STRING VAR VAR STRING VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VA...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
b = int(input()) s = input() n = len(s) pwr = [1] for _ in range(60): if pwr[-1] * b <= 10**18: pwr.append(pwr[-1] * b) else: break digit = len(pwr) ans = 10**18 dp = [[(10**20) for _ in range(digit + 10)] for _ in range(n)] for j in range(digit): dp[0][j] = int(s[0]) * pwr[j] for i in range...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER NU...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
def main(): n = int(input()) k = int(input()) if k == 0: print(0) return ans = 0 np = 1 while k > 0: i = 10 ok = k p10 = 1 x = 0 while ok > 0: c = ok % 10 x += p10 * c p10 *= 10 if x >= n: ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP VAR VAR...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = int(input()) a = input() cn = 0 fn = 0 tp = 0 c10p = 0 maxi = -1 while len(a) != 0: maxi = -1 for i in range(1, len(a) + 1): ds = int(a[-i:]) if ds < n and int(a[-i]) != 0: maxi = i if maxi == -1 and int(a[-1]) == 0: a = a[:-1] tp += 1 else: fn += ...
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 ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR VAR FUNC_CALL VA...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
base = int(input()) num = input() result = 0 place_value = 1 end = len(num) while end > 0: begin = end - 1 good_begin = begin while begin >= 0: if int(num[begin:end]) >= base: break elif num[begin] != "0": good_begin = begin begin -= 1 begin = good_begin ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR STRING ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR FUNC_C...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = int(input()) d = input() l = len(d) dp = [[0, 0] for i in range(0, l + 1)] dp[l - 1] = [ord(d[l - 1]) - ord("0"), 1] for i in range(1, l): w = l - 1 - i m = (ord(d[w]) - ord("0")) * n**i + dp[w + 1][0] dp[w] = [m, i + 1] if d[w] == "0": dp[w][0] = dp[w + 1][0] dp[w][1] = dp[w + 1][1]...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER LIST BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR STRING NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_O...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = int(input()) k = list(map(int, input())) k = k[::-1] ans, cur, i = 0, 1, 0 while i < len(k): nxt, sm, temp, mul = i + 1, k[i], k[i], 10 for j in range(i + 1, len(k)): temp += mul * k[j] mul *= 10 if k[j] != 0 and temp < n: nxt = j + 1 sm = temp ans += sm *...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR BIN_OP V...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = int(input()) s = input() dp = [0] for i in range(1, len(s) + 1): dp.append(1000000000000000000000000000000000000) for j in range(1, 10): if j <= i: can = s[i - j : i] tmp = int(can) if tmp < n and (can[0] != "0" or can == "0"): val = dp[i - j] * n ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER STRING VAR STR...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
INF = 100000000000000000000 b = int(input()) s = input() n = len(s) dp = [INF for i in range(n + 1)] dp[0] = 0 for i in range(n): if s[i] == "0": dp[i + 1] = min(dp[i + 1], dp[i] * b) continue for j in range(i + 1, n): if int(s[i:j]) < b: dp[j] = min(dp[j], b * dp[i] + int(s[...
ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR FOR V...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = int(input()) x = input() l = len(x) dp = [[(1e18) for i in range(l + 1)] for i in range(l + 1)] for i in range(l + 1): dp[l][i] = 0 for i in range(l - 1, -1, -1): sum = 0 for j in range(i, l): sum = sum * 10 + (ord(x[j]) - ord("0")) if sum >= n: break for k in range(l...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
inf = 10**18 + 1 n = int(input()) num = ["0"] + list(input())[::-1] T = [inf for i in range(len(num))] P = [inf for i in range(len(num))] T[0] = 0 P[0] = -1 for i in range(1, len(num)): if num[i] != "0": min_pow = inf for j in range(0, i): if n > int("".join(num[j + 1 : i + 1][::-1])): ...
ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST STRING FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL ...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = input() k = input() digit = len(n) lst = [] def recul(k): if len(k) == 0: return if k[-digit:] < n: lst.append(k[-digit:]) if k[-digit:][0:1] == "0" and len(k[-digit:]) != 1: recul(k[:-digit] + "0") else: recul(k[:-digit]) else: temp = -d...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR IF VAR VAR NUMBER NUMBER STRING FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR STRING EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = int(input()) K = input() m = len(K) inf = 10**100 dp = [inf] * (m + 1) dp[0] = 0 for i in range(m): if K[i] == "0": dp[i + 1] = min(dp[i + 1], dp[i] * n + int(K[i])) else: val = 0 for j in range(i, m): val = val * 10 + int(K[j]) if val >= n: br...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP LIST VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VA...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
inf = 10**100 b = int(input()) s = input() n = len(s) dp = [] for i in range(n + 1): dp.append([inf] * (n + 2)) dp[n][0] = 0 for i in range(n - 1, -1, -1): for j in range(i + 1, min(i + 12, n + 1)): if j - i > 1 and s[i] == "0": continue cur = int(s[i:j]) if cur >= b: ...
ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP LIST VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER FOR...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = int(input()) k = input() r = len(k) a = [] i = len(k) - 1 while i >= 0: if k[i] != "0": if int(k[i:r]) >= n: a.append(int(k[i + 1 : r])) r = i + 1 i -= 1 else: i -= 1 else: j = i while j >= 0 and k[j] == "0": j -= 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR NUMBER IF VAR VAR STRING IF FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER V...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = int(input()) m = int(input()) ln = len(str(n)) ans = 0 i = 0 while m != 0: dgt = m % 10**ln if dgt < n and len(str(dgt)) == ln: ans += dgt * n**i i += 1 m = m // 10**ln ln = len(str(n)) else: ln -= 1 print(ans)
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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR IF VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR BIN_OP ...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = int(input()) s = input() dp = [0] * (len(s) + 1) pn = [0] * (len(s) + 1) pn[len(pn) - 1] = 1 for k in range(len(s) - 1, -1, -1): num = 0 dp[k] = -1 if s[k] == "0": dp[k] = pn[k + 1] * num + dp[k + 1] pn[k] = pn[k + 1] * n continue for i in range(k, len(s)): num = num ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR NUM...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = int(input()) k = int(input()) out = 0 base = 1 while k != 0: big = 10000000000 while k % big >= n and big > 10: big //= 10 out += k % big * base base *= n cpy = big while k % big < cpy // 10 and cpy > 10: cpy //= 10 big = cpy k //= big print(out)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR VAR NUMBER VAR NUMBER VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR VAR WHILE BIN_OP VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = int(input()) k = input() INF = 10**100 dp = [([INF] * 100) for i in range(len(k) + 1)] dp[len(k)][0] = 0 dp[len(k) - 1][0] = int(k[len(k) - 1]) deg = [1] * 1000 for i in range(1, 100): deg[i] = deg[i - 1] * n for i in range(len(k) - 1, -1, -1): if k[i] == "0": for cur_deg in range(1, 61): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP LIST VAR NUMBER VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMB...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = int(input()) s = input() dp = [([10**100] * len(s)) for _ in range(len(s))] for i in range(len(s) - 1, -1, -1): for j in range(i, len(s)): a = int(s[i : j + 1]) if len(str(a)) == j - i + 1 and a < n: if j == len(s) - 1: dp[i][0] = min(dp[i][0], a) else: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST BIN_OP NUMBER NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NU...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = int(input()) s = input() i = len(s) j = i - 1 tot = 0 mul = 1 while i > 0 and j >= 0: while j >= 0: _num = int(s[j:i]) if _num >= n: j += 1 while s[j] == "0" and i - j > 1: j += 1 break num = _num j -= 1 tot += mul * num ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR VAR NUMBER WHILE VAR VAR STRING BIN_OP VAR VAR NUMBER VAR NUMBER ASSI...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
def convertTo(act, param): return int(act) * param def rmLeading(act): while act[0] == "0": act = act[1:] return act def pureZero(act): for i in act: if i != "0": return False return True def getTheAct(act, i, n, k): while i >= 0 and int(k[i] + act) < int(n): ...
FUNC_DEF RETURN BIN_OP FUNC_CALL VAR VAR VAR FUNC_DEF WHILE VAR NUMBER STRING ASSIGN VAR VAR NUMBER RETURN VAR FUNC_DEF FOR VAR VAR IF VAR STRING RETURN NUMBER RETURN NUMBER FUNC_DEF WHILE VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF FUNC_CA...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
import sys def debug(*args, **kwargs): print(*args, **kwargs, file=sys.stderr) n = int(input()) s = input() h = len(s) k = int(s) dec = [0] * (h + 1) if k < n: print(k) else: dec[0] = 0 for i in range(1, h + 1): dec[i] = dec[i - 1] * n + int(s[i - 1]) for j in range(2, i + 1): ...
IMPORT FUNC_DEF EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMB...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = int(input()) s = str(input()) m = len(s) x = m - 1 inf = int(1e19) dp = [[inf for p in range(m + 1)] for z in range(m + 1)] pows = [1] for i in range(m + 1): pows.append(pows[-1] * n) for j in range(m - 1, -1, -1): if j == m - 1: dp[j][0] = int(s[j]) continue if s[j] == "0": for ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EX...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
a = int(input()) b = input() la = len(str(a)) ans = 0 c = 0 k = 0 i = 0 ch = 0 while True: if len(b) < la: if len(b) == 0: break else: ans += int(b) * a**i i += 1 break c = int(b[len(b) - la : len(b)]) k = la while b[len(b) - la + ch] == "0...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR VAR VAR NUMBER AS...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = int(input()) s = input() prr = [] while len(s) > 0: k = 0 for i in range(len(s) - 1, -1, -1): if s[i] == "0": continue if int(s[i:]) >= n or len(s[i:]) > len(str(n)): k = i + 1 while k < len(s) and s[k] == "0": k += 1 if k == le...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR VAR STRING IF FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR ...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
def ri(): return map(int, input().split()) n = int(input()) k = input() ans = 0 p = 0 while True: kk = k[:] for i in range(len(kk)): if int(kk[i]) == 0 and len(kk[i:]) != 1: continue if n > int(kk[i:]): ans += int(kk[i:]) * n**p p += 1 if i =...
FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR NUMBER FUNC_CALL VAR VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR VAR VAR ...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = int(input()) s = input() s = "".join(j for j in [i for i in reversed(s)]) cnt = 0 t = n while t != 0: cnt += 1 t //= 10 dp = [[(-1) for i in range(100)] for j in range(100)] dp[0][0] = ord(s[0]) - ord("0") len = len(s) for i in range(1, len): for j in range(len): for k in range(i, -1, -1): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL STRING VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER NUMBER BIN_OP FUNC_CALL VAR VAR NUMB...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = int(input()) k = input() ans = 0 p = 1 i = len(k) - 1 j = len(k) while i >= 0: if k[i] != "0" or j - i == 1: v = int(k[i:j]) if v < n: x = i else: ans += p * int(k[x:j]) p *= n i = j = x i -= 1 if j > 0: ans += p * int(k[0:j]) print...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR NUMBER IF VAR VAR STRING BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR FUNC_CALL VAR...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = int(input()) s = input() l = len(s) dp = [([10**20] * l) for i in range(l)] for i in range(l - 1, -1, -1): for j in range(l): for k in range(i, l): if s[i] == "0" and i != k: continue x = int(s[i : k + 1]) if x < n: if j == 0 and k == l...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST BIN_OP NUMBER NUMBER VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR IF VAR VAR STRING VAR VAR ASSIGN VAR FUNC_CALL ...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
m = int(input()) s = input() n = len(s) s = s[::-1] inf = 10**18 + 213 f = [0] * (n + 1) for i in range(n + 1): f[i] = [inf] * (n + 1) f[0][0] = 0 for prefix in range(n + 1): for base in range(n + 1): if f[prefix][base] == inf: continue for len in range(1, n + 1): if pref...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP LIST VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMB...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = int(input()) k = input() a = 0 p = 1 while len(k) > 0: i = len(k) - 1 while i >= 0 and int(k[i:]) < n: i -= 1 i += 1 r = int(k[i:]) k = k[0 : len(k) - len(str(r))] a += r * p p *= n print(a)
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 BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR NUMBER FUNC_CALL VAR VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR F...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = int(input()) s = input() pw = [1] last = 1 for i in range(70): if last > 1e19: break pw.append(last * n) last = last * n dp = [1e19] * 100 for i in range(100): dp[i] = [1e19] * 100 dp[len(s)][0] = 0 for i in range(len(s), -1, -1): for power in range(0, len(pw)): cur = "" ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR BIN_OP LIST NUMBER NUMBER ASSIG...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = int(input()) k = input() dp = [10**18] * len(k) + [0] st = [100] * len(k) + [-1] for l in range(len(k) - 1, -1, -1): for r in range(l + 1, len(k) + 1): if int(k[l:r]) >= n or k[l] == "0" and r > l + 1: break dp[l], st[l] = min(dp[l], dp[r] + int(k[l:r]) * n ** (st[r] + 1)), min( ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP LIST BIN_OP NUMBER NUMBER FUNC_CALL VAR VAR LIST NUMBER ASSIGN VAR BIN_OP BIN_OP LIST NUMBER FUNC_CALL VAR VAR LIST NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ...
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets...
n = int(input()) k = input().strip() power = [1] for i in range(20): power.append(power[-1] * 10) dp = [10**18] * len(k) for i in range(len(k)): for j in range(min(10, i + 1)): if k[i - j] == "0" and j > 0: continue s = int(k[i - j : i + 1]) if s >= n: break ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST BIN_OP NUMBER NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_O...
The crowdedness of the discotheque would never stop our friends from having fun, but a bit more spaciousness won't hurt, will it? The discotheque can be seen as an infinite xy-plane, in which there are a total of n dancers. Once someone starts moving around, they will move only inside their own movement range, which i...
n = int(input()) d = [1] * n p = [[] for i in range(n)] def f(): x, y, r = map(int, input().split()) return r * r, x, y t = sorted(f() for i in range(n)) for i in range(n): r, x, y = t[i] for j in range(i + 1, n): s, a, b = t[j] if (a - x) ** 2 + (b - y) ** 2 < s: p[j].ap...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR RETURN BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR...
The crowdedness of the discotheque would never stop our friends from having fun, but a bit more spaciousness won't hurt, will it? The discotheque can be seen as an infinite xy-plane, in which there are a total of n dancers. Once someone starts moving around, they will move only inside their own movement range, which i...
import sys def inside(a, b): return (a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2 < (a[2] + b[2]) ** 2 def main(): pi = 3.141592653589793 n = int(sys.stdin.readline()) a = [] p = [-1] * n for i in range(n): x, y, r = map(int, sys.stdin.readline().split()) a.append([x, y, r]) fo...
IMPORT FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ...
The crowdedness of the discotheque would never stop our friends from having fun, but a bit more spaciousness won't hurt, will it? The discotheque can be seen as an infinite xy-plane, in which there are a total of n dancers. Once someone starts moving around, they will move only inside their own movement range, which i...
s = 0 t = [list(map(int, input().split())) for i in range(int(input()))] f = ( lambda b: a[2] < b[2] and (a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2 <= (a[2] - b[2]) ** 2 ) for a in t: k = sum(f(b) for b in t) s += (-1, 1)[(k < 1) + k & 1] * a[2] ** 2 print(3.1415926536 * s)
ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR NUMBER BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER FOR VAR VAR ASSIGN V...
$2^n$ teams participate in a playoff tournament. The tournament consists of $2^n - 1$ games. They are held as follows: in the first phase of the tournament, the teams are split into pairs: team $1$ plays against team $2$, team $3$ plays against team $4$, and so on (so, $2^{n-1}$ games are played in that phase). When a ...
n = int(input()) s = input() z = 0 o = 0 for i in s: if i == "1": o += 1 else: z += 1 for i in range(2**o, 2**n - 2**z + 1 + 1): print(i, end=" ")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR STRING
$2^n$ teams participate in a playoff tournament. The tournament consists of $2^n - 1$ games. They are held as follows: in the first phase of the tournament, the teams are split into pairs: team $1$ plays against team $2$, team $3$ plays against team $4$, and so on (so, $2^{n-1}$ games are played in that phase). When a ...
import sys input = sys.stdin.readline def readList(): return list(map(int, input().split())) def readInt(): return int(input()) def readInts(): return map(int, input().split()) def readStr(): return input().strip() def solve(): n = readInt() s = readStr() cnt = 0 for i in rang...
IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR 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 RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR...
$2^n$ teams participate in a playoff tournament. The tournament consists of $2^n - 1$ games. They are held as follows: in the first phase of the tournament, the teams are split into pairs: team $1$ plays against team $2$, team $3$ plays against team $4$, and so on (so, $2^{n-1}$ games are played in that phase). When a ...
n = int(input()) s = input() for i in range(pow(2, s.count("1")), pow(2, n) - pow(2, s.count("0")) + 2): print(i, end=" ") print()
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR STRING BIN_OP BIN_OP FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR
$2^n$ teams participate in a playoff tournament. The tournament consists of $2^n - 1$ games. They are held as follows: in the first phase of the tournament, the teams are split into pairs: team $1$ plays against team $2$, team $3$ plays against team $4$, and so on (so, $2^{n-1}$ games are played in that phase). When a ...
n = int(input()) s = input() start = 1 end = 2**n ones = s.count("1") zeros = s.count("0") start += 2**ones - 1 end -= 2**zeros - 1 for val in range(start, end + 1): print(val, end=" ") print()
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR BIN_OP BIN_OP NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR STRING...
$2^n$ teams participate in a playoff tournament. The tournament consists of $2^n - 1$ games. They are held as follows: in the first phase of the tournament, the teams are split into pairs: team $1$ plays against team $2$, team $3$ plays against team $4$, and so on (so, $2^{n-1}$ games are played in that phase). When a ...
t = int(input()) arr = input() i = 1 j = 1 r = 1 l = 1 for y in range(t): r *= 2 for x in arr: if x == "1": l += i i *= 2 if x == "0": r -= j j *= 2 for x in range(l, r + 1): print(x, end=" ")
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 VAR NUMBER FOR VAR VAR IF VAR STRING VAR VAR VAR NUMBER IF VAR STRING VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ST...
$2^n$ teams participate in a playoff tournament. The tournament consists of $2^n - 1$ games. They are held as follows: in the first phase of the tournament, the teams are split into pairs: team $1$ plays against team $2$, team $3$ plays against team $4$, and so on (so, $2^{n-1}$ games are played in that phase). When a ...
n = int(input()) t = 2**n s = input() cnt = 0 for i in range(len(s)): cnt += int(s[i]) if cnt == 0: print(1) else: left = 2**cnt ans = [] for i in range(1, t + 1): if i < left: continue sm = i - left bg = t - left - sm rem = cnt while rem > 0: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR ...
$2^n$ teams participate in a playoff tournament. The tournament consists of $2^n - 1$ games. They are held as follows: in the first phase of the tournament, the teams are split into pairs: team $1$ plays against team $2$, team $3$ plays against team $4$, and so on (so, $2^{n-1}$ games are played in that phase). When a ...
n = int(input()) l = 1 r = int(2**n) s = input() nl = 0 nr = 0 for ch in s: if ch == "0": r = r - int(2**nr) nr += 1 else: l = l + int(2**nl) nl += 1 for i in range(l, r + 1): if i != r: print(i, end=" ") else: print(i)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING ASSIGN VAR BIN_OP VAR FUNC_CALL VAR BIN_OP NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR BIN_OP NUMBER VAR VAR NUMBER FOR...
$2^n$ teams participate in a playoff tournament. The tournament consists of $2^n - 1$ games. They are held as follows: in the first phase of the tournament, the teams are split into pairs: team $1$ plays against team $2$, team $3$ plays against team $4$, and so on (so, $2^{n-1}$ games are played in that phase). When a ...
t = int(input()) a = input() w = a.count("1") y = len(a) - w for i in range(2**w, 2**t - 2**y + 2): print(i, end=" ")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR BIN_OP BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR STRING
$2^n$ teams participate in a playoff tournament. The tournament consists of $2^n - 1$ games. They are held as follows: in the first phase of the tournament, the teams are split into pairs: team $1$ plays against team $2$, team $3$ plays against team $4$, and so on (so, $2^{n-1}$ games are played in that phase). When a ...
roll = int(input()) bin = input() bin = bin[::-1] working = [] if bin[0] == "1": working = [2, 2] else: working = [1, 1] for i in range(1, len(bin)): if bin[i] == "1": working = [2 * working[0], 2**i + working[1]] else: working = [working[0], 2 * working[1] - 1] blank = "" for i in range...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST IF VAR NUMBER STRING ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR LIST BIN_OP NUMBER VAR NUMBER BIN_OP BIN_OP NUMBER VAR VAR NU...
$2^n$ teams participate in a playoff tournament. The tournament consists of $2^n - 1$ games. They are held as follows: in the first phase of the tournament, the teams are split into pairs: team $1$ plays against team $2$, team $3$ plays against team $4$, and so on (so, $2^{n-1}$ games are played in that phase). When a ...
n = int(input()) s = input() arr = list(range(1, 2**n + 1)) l = 0 r = len(arr) - 1 r_change = 1 l_change = 1 for i in range(len(s)): if s[i] == "0": r -= r_change r_change *= 2 else: l += l_change l_change *= 2 print(*arr[l : r + 1])
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR VAR NUMBER VAR ...
$2^n$ teams participate in a playoff tournament. The tournament consists of $2^n - 1$ games. They are held as follows: in the first phase of the tournament, the teams are split into pairs: team $1$ plays against team $2$, team $3$ plays against team $4$, and so on (so, $2^{n-1}$ games are played in that phase). When a ...
n = int(input()) s = input() init = 2 ** s.count("1") total = 2**n fin = total - 2 ** s.count("0") arr = [] for i in range(init, fin + 2): arr.append(i) print(*arr)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR STRING ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR
$2^n$ teams participate in a playoff tournament. The tournament consists of $2^n - 1$ games. They are held as follows: in the first phase of the tournament, the teams are split into pairs: team $1$ plays against team $2$, team $3$ plays against team $4$, and so on (so, $2^{n-1}$ games are played in that phase). When a ...
n = int(input()) s = input() l = [s.count("0"), s.count("1")] zeros = l[0] ones = l[1] start = 2**ones ending = 2**n - 2**zeros + 1 for i in range(start, ending + 1): print(i, end=" ")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CAL...
$2^n$ teams participate in a playoff tournament. The tournament consists of $2^n - 1$ games. They are held as follows: in the first phase of the tournament, the teams are split into pairs: team $1$ plays against team $2$, team $3$ plays against team $4$, and so on (so, $2^{n-1}$ games are played in that phase). When a ...
n = int(input()) s = input() z = s.count("0") o = n - z res = list(range(pow(2, o), pow(2, n) + 2 - pow(2, z))) print(*res)
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 FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR BIN_OP BIN_OP FUNC_CALL VAR NUMBER VAR NUMBER FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR VAR
$2^n$ teams participate in a playoff tournament. The tournament consists of $2^n - 1$ games. They are held as follows: in the first phase of the tournament, the teams are split into pairs: team $1$ plays against team $2$, team $3$ plays against team $4$, and so on (so, $2^{n-1}$ games are played in that phase). When a ...
n = int(input()) s = input() lo = 1 hi = 2**n count0 = 1 count1 = 1 for x in s: if x == "0": hi -= count0 count0 <<= 1 else: lo += count1 count1 <<= 1 for i in range(lo, hi + 1): print(i, end=" ") print()
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR VAR VAR NUMBER VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR
$2^n$ teams participate in a playoff tournament. The tournament consists of $2^n - 1$ games. They are held as follows: in the first phase of the tournament, the teams are split into pairs: team $1$ plays against team $2$, team $3$ plays against team $4$, and so on (so, $2^{n-1}$ games are played in that phase). When a ...
n = int(input()) s = input() nz = 0 for j in range(0, n): if s[j] == "0": nz = nz + 1 n1 = n - nz x = pow(2, n1) y = pow(2, n) - pow(2, nz) + 1 for j in range(x, y + 1): print(j, end=" ") print("")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR NUMBER FOR VAR FUNC_C...
$2^n$ teams participate in a playoff tournament. The tournament consists of $2^n - 1$ games. They are held as follows: in the first phase of the tournament, the teams are split into pairs: team $1$ plays against team $2$, team $3$ plays against team $4$, and so on (so, $2^{n-1}$ games are played in that phase). When a ...
n = int(input()) st = input() s = 0 for i in range(n): if st[i] == "1": s += 1 l = 2**s r = 2**n - 2 ** (n - s) + 2 out = "" for i in range(l, r): out += str(i) + " " print(out)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP FUNC_CALL VAR VA...
$2^n$ teams participate in a playoff tournament. The tournament consists of $2^n - 1$ games. They are held as follows: in the first phase of the tournament, the teams are split into pairs: team $1$ plays against team $2$, team $3$ plays against team $4$, and so on (so, $2^{n-1}$ games are played in that phase). When a ...
k = int(input()) max = 2**k s = str(input()) arr = [int(x) for x in s] sum = 0 for i in arr: sum += i start = 2**sum end = max - 2 ** (k - sum) + 1 m = start ans = [] while m <= end: ans.append(m) m += 1 result = " ".join(str(item) for item in ans) print(result)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR LIST WHILE VAR VAR...
$2^n$ teams participate in a playoff tournament. The tournament consists of $2^n - 1$ games. They are held as follows: in the first phase of the tournament, the teams are split into pairs: team $1$ plays against team $2$, team $3$ plays against team $4$, and so on (so, $2^{n-1}$ games are played in that phase). When a ...
n = int(input()) s = input() ans = [] zer = s.count("0") one = s.count("1") c = 2**one d = 2**zer - 1 for i in range(1, 2**n + 1): if i >= c and i <= 2**n - d: ans.append(i) for j in ans: print(j, end=" ")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR VAR VAR BIN_OP BIN_OP NUMBER VAR VAR...
$2^n$ teams participate in a playoff tournament. The tournament consists of $2^n - 1$ games. They are held as follows: in the first phase of the tournament, the teams are split into pairs: team $1$ plays against team $2$, team $3$ plays against team $4$, and so on (so, $2^{n-1}$ games are played in that phase). When a ...
n = int(input()) s = input() zs = s.count("0") os = s.count("1") [print(i, end=" ") for i in range(1, 2**n + 1) if 2**os - 1 < i <= 2**n - (2**zs - 1)]
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 EXPR FUNC_CALL VAR VAR STRING VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER VAR BIN_OP BIN_OP NUMBER VAR BIN_OP BIN_OP NUMBER VAR NUMBER
$2^n$ teams participate in a playoff tournament. The tournament consists of $2^n - 1$ games. They are held as follows: in the first phase of the tournament, the teams are split into pairs: team $1$ plays against team $2$, team $3$ plays against team $4$, and so on (so, $2^{n-1}$ games are played in that phase). When a ...
n = int(input()) s = input() a = list(map(int, s)) x = a.count(1) y = a.count(0) ans = [i for i in range(2**x, 2**n - 2**y + 2)] print(*ans)
ASSIGN 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 NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP NUMBER VAR BIN_OP BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
$2^n$ teams participate in a playoff tournament. The tournament consists of $2^n - 1$ games. They are held as follows: in the first phase of the tournament, the teams are split into pairs: team $1$ plays against team $2$, team $3$ plays against team $4$, and so on (so, $2^{n-1}$ games are played in that phase). When a ...
n = int(input()) a = input() k = a.count("1") t = pow(2, n) if k == 0: print(1) elif k == n: print(t) else: m1 = pow(2, k) min = 1 oraliq = 1 max = t for x in a: if x == "1": min += oraliq * t // 2 else: max -= oraliq oraliq *= 2 t ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR NUMBER VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR VAR IF VAR STRING V...
$2^n$ teams participate in a playoff tournament. The tournament consists of $2^n - 1$ games. They are held as follows: in the first phase of the tournament, the teams are split into pairs: team $1$ plays against team $2$, team $3$ plays against team $4$, and so on (so, $2^{n-1}$ games are played in that phase). When a ...
n = int(input()) string = input() c0 = 0 c1 = 0 for i in range(n): if string[i] == "0": c0 += 1 else: c1 += 1 a = 2**c1 - 1 b = 2**n - (2**c0 - 1) for j in range(a + 1, b + 1): print(j, end=" ") print("")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR BIN_OP BIN_OP NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN...
$2^n$ teams participate in a playoff tournament. The tournament consists of $2^n - 1$ games. They are held as follows: in the first phase of the tournament, the teams are split into pairs: team $1$ plays against team $2$, team $3$ plays against team $4$, and so on (so, $2^{n-1}$ games are played in that phase). When a ...
n = int(input()) s = input() k = s.count("1") if k == n: print(pow(2, n)) exit(0) kk = s.count("0") be = 1 << k f = [0] * 22 f[0] = 1 for i in range(1, 22): f[i] = f[i - 1] * 2 for i in range(1, n): f[i] = f[i - 1] + f[i] en = pow(2, n) - f[kk - 1] for i in range(be, en + 1): print(i, end=" ")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VA...