description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
for _ in range(int(input())): a, b = input().split() la = len(a) lb = len(b) dd = [] for i in range(la): dd.append([a[i], i]) dd.sort() i = 0 c = 0 r = "" di = {i: i for i in range(la)} while i < la and c < 1: if dd[i][1] != i: for j in range(la - ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR VAR VAR VAR...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
def swap_char(arr, x, y): arr = list(arr) arr[x], arr[y] = arr[y], arr[x] return "".join(arr) for _ in [0] * int(input()): a, b = [x for x in input().split()] lens = len(a) for i in range(lens - 1): curr = a[i + 1] poss = -1 for j in range(i + 1, lens): if a...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR RETURN FUNC_CALL STRING VAR FOR VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR ...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
def swap(lst, i, j): lst[i], lst[j] = lst[j], lst[i] def comp(l1, l2): for i in range(min(len(l1), len(l2))): if l1[i] < l2[i]: return True if l1[i] == l2[i]: continue return False return len(l1) < len(l2) def logic(s, c): if comp(s, c): return...
FUNC_DEF ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR RETURN NUMBER IF VAR VAR VAR VAR RETURN NUMBER RETURN FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF IF FUNC_CALL VAR VAR VAR RETURN VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL V...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
nn = int(input()) for _ in range(nn): s1, s2 = input().split() l1 = list(s1) n = len(s1) s3 = "" if s1 < s2: print(s1) else: d = {"A": True} for i in range(n): if s1[i] in d: continue else: to_swap = i ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR DICT STRING NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VA...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
for _ in range(int(input())): s, c = input().split() X = [i for i in s] S = [i for i in s] S.sort() target = -1 index = -1 for i in range(len(S)): if s[i] != S[i]: target = S[i] index = i break if target == -1: pass else: fo...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR B...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
def func(): s1, s2 = input().split() ss1 = list(s1) ss1_sort = sorted(ss1) ss2 = list(s2) lens = min(len(s1), len(s2)) sortt = False for i in range(len(s1)): if ss1[i] != ss1_sort[i]: pos = i sortt = True break if sortt == False: if s1 ...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER ...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
t = int(input()) while t: x, l2 = input().split() n1 = len(x) l1 = [] n2 = len(l2) n = min(n1, n2) l = list(x) for i in range(n1): l1.append(x[i]) l.sort() ch = 0 for i in range(n1): if l[i] != l1[i]: index1 = i ch = 1 for j in ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VA...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
tc = int(input()) for _ in range(tc): s, c = input().split() sorteds = "".join(sorted(s)) i = 0 while i < len(s) and s[i] == sorteds[i]: i += 1 if i < len(s): j = s.rfind(sorteds[i]) s = s[:i] + s[j] + s[i + 1 : j] + s[i] + s[j + 1 :] if s < c: print(s) else: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP ...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
def work(s, n): s_copy = s[:] s_copy.sort() for i in range(n): if s_copy[i] == s[i]: continue for j in range(n - 1, i, -1): if s[j] == s_copy[i]: s[i], s[j] = s[j], s[i] return for _ in range(int(input())): s, c = map(list, input(...
FUNC_DEF ASSIGN VAR VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR RETURN FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EX...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
for _ in range(int(input())): s, c = input().split() if s < c: print(s) continue a = sorted(s) for i in range(len(s)): if a[i] != s[i]: break if i == len(s) - 1: print("---") continue for j in range(len(s) - 1, i, -1): s = list(s) ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR V...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
def swap(s): l = len(s) index = list(range(l)) index.sort(key=lambda i: s[i]) low = None for i in range(l): ind = index[i] if s[i] != s[ind]: left = i low = s[ind] break if low is None: return right = 0 for i in range(l): ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NONE FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR IF VAR NONE RETURN ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR ASSIG...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
import sys rl = lambda: sys.stdin.readline().strip() N = int(rl()) for i in range(N): s_str, c_str = rl().split() if s_str < c_str: print(s_str) continue s, c = list(s_str), list(c_str) s_sorted = sorted(s) if s_sorted == s: print("---") continue for i in range(l...
IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR F...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
def solveOne(me, rival): me = list(me) sortedMe = sorted(me) for i in range(len(me)): if me[i] != sortedMe[i]: swapPos = i for j in range(i + 1, len(me)): if me[j] <= me[swapPos]: swapPos = j me[i], me[swapPos] = me[swapPos], me...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL STRING VAR IF VAR VAR EXPR ...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
def swap(c, i, j): c = list(c) c[i], c[j] = c[j], c[i] return "".join(c) for i in range(int(input())): index1 = -1 index2 = -1 m, n = map(str, input().split()) if m < n: print(m) continue original = m m = sorted(m) if m[0] > n[0]: print("---") co...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR RETURN FUNC_CALL STRING VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VA...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
def swapPositions(list, pos1, pos2): list[pos1], list[pos2] = list[pos2], list[pos1] return list def solve(s): ll = [0] * 26 for i in range(len(s[0])): ll[ord(s[0][i]) - 65] += 1 path = list() for i in range(26): if ll[i] != 0: path.append(i) arr1 = list() f...
FUNC_DEF ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CAL...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
n = int(input()) while n > 0: n -= 1 s, c = input().split() lst = list(s) now = s last = [-1] * 26 for i in range(len(s)): last[ord(s[i]) - ord("A")] = i for i in range(len(s) - 1): x = min(s[i:]) if x != s[i]: idx = last[ord(x) - ord("A")] lst...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING VAR FOR VAR FUNC_CALL VAR BIN_OP...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
def main(): s, c = input().split() n = len(s) if s < c: print(s) return i = n - 2 j = n - 1 while i > -1: sn = s[:i] + s[j] + s[i + 1 : j] + s[i] + s[j + 1 :] j = min(i, j, key=lambda x: (s[x], -x)) if sn < c: print(sn) return ...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR RETURN ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
for t in range(int(input())): s, c = input().split() s = list(s) lowest = sorted(s) pos = -1 for i in range(len(s)): if s[i] != lowest[i]: pos = i break if pos == -1: string = "".join(s) if string < c: print(string) else: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL STRING VAR IF VAR VAR EXPR FUNC_CALL VAR VAR E...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
n = int(input()) for i in range(n): str1, str2 = map(str, input().split()) lst1 = list(str1) lstord = [] for i in range(len(lst1)): min1 = ord(lst1[i]) pos = i for j in range(len(lst1) - 1, i, -1): if min1 > ord(lst1[j]): min1 = ord(lst1[j]) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR NUMBER ...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
for _ in range(int(input())): s1, s2 = map(str, input().split()) l2 = list(s2) if s1 < s2: print(s1) else: l1 = list(s1) l1.sort() t = -1 for i in range(len(l1)): if l1[i] < s1[i]: t = i break l1 = list(s1) ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
for _ in range(int(input())): a, b = input().split() good = 0 if min(a, b) != b: print(a) continue for i in range(len(a)): idx = i for j in range(i + 1, len(a)): if a[j] <= a[idx]: idx = j if idx == i: continue tmp =...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR IF VAR VAR ASS...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
x = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" for _ in range(int(input())): s, t = input().split() d = {} for i in x: d[i] = 0 for i in s: d[i] += 1 j = 0 while d[x[j]] == 0: j += 1 ss = "" f = False for i in range(len(s)): if f: ss += s[i] ...
ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR VAR NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
import sys t = int(sys.stdin.readline()) for _ in range(t): A, B = sys.stdin.readline().split() a, b = list(A), list(B) c = a.copy() c.sort() if c >= b: print("---") else: n = len(a) for i in range(n): if c[i] != a[i]: break for j in r...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR FOR...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
import sys reader = (line.rstrip() for line in sys.stdin) t = int(next(reader)) for _ in range(t): a, b = next(reader).split() cs = [(c, i) for i, c in enumerate(a)] cs.sort() j = None for i in range(len(a)): if a[i] != cs[i][0]: c = cs[i][0] for j in range(len(a) - ...
IMPORT ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NONE FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUM...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
q = int(input()) for _ in " " * q: a, b = map(list, input().split()) l = [0] * len(a) minI = len(a) - 1 minC = a[minI] for i in range(len(a) - 1, -1, -1): if a[i] < minC: minC = a[i] minI = i l[i] = [minC, minI] for i in range(len(a)): if a[i] > l[...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR BIN_OP STRING VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR VAR VAR ASSIG...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
t = int(input()) for _ in range(t): s1, s2 = input().split() if s1 < s2: print(s1) continue s3 = sorted(s1) s1 = list(s1) x = y = -1 j = 0 for i in range(len(s3)): if s1[i] == s3[j]: j += 1 continue if s1[i] > s3[j]: x = i ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER IF VAR VAR VAR...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
def find_lexicographically_smaller_swap(s, t): mins = sorted(s) for i in range(len(s)): if s[i] != mins[i]: j = max(j for j, v in enumerate(s[i:], i) if v == mins[i]) s = s[:i] + s[j] + s[i + 1 : j] + s[i] + s[j + 1 :] break return s if s < t else "---" for cas ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER RETURN VAR VAR VAR STRING FOR VAR FUN...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
for _ in range(int(input())): s1, s2 = input().split() arr = list(s1) ans = sorted(arr) dic = {} for i in range(len(s1)): try: dic[arr[i]].append(i) except: dic[arr[i]] = [i] if s1 < s2: print(s1) continue for i in range(len(s1)): ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR VAR LIST VAR IF VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FU...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
from sys import stdin, stdout for _ in range(int(stdin.readline())): s, s1 = input().split() ln = len(s) ln1 = len(s1) l = list(s) if s < s1: print(s) continue for i in range(ln): ch = s[i] p = -1 mn = ch for j in range(i + 1, ln): if ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
def better(a): if a == "".join(sorted(a)): return a a, n = list(a), len(a) for i in range(n): ans = -1 for j in range(i + 1, n): if a[i] <= a[j]: continue if ans == -1 or a[ans] >= a[j]: ans = j if ans != -1: ...
FUNC_DEF IF VAR FUNC_CALL STRING FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR VAR VAR IF VAR NUMBER VAR VAR VAR VAR ASSIGN VAR VAR IF VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR VAR...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
n = int(input()) while n: n = n - 1 s = input() s = s.split() a = s[0] b = s[1] flag = 0 if a < b: print(a) else: a = list(a) for i in range(0, len(a) - 1): j = min((r for r in range(i + 1, len(a))), key=lambda x: (a[x], -x)) if a[i] > a[j]...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
def main(): t = int(input()) for n in range(t): s, c = (x for x in input().split()) print(solver(s, c)) def solver(s, c): if s < c: return s else: smallestLetter = "z" smallestLetterIndex = None swapLeft = None swapRight = None for i in r...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_DEF IF VAR VAR RETURN VAR ASSIGN VAR STRING ASSIGN VAR NONE ASSIGN VAR NONE ASSIGN VAR NONE FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
def swap(z, a, b): l = [] for j in z: l.append(j) temp = l[a] l[a] = l[b] l[b] = temp zz = "" for tt in l: zz += tt return zz def solve(s, k): for t in range(min(len(s), len(k))): if s[t] == k[t]: x = min(s[t:]) if x < k[t]: ...
FUNC_DEF ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR STRING FOR VAR VAR VAR VAR RETURN VAR FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR FO...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
def besty(s): s = list(s) for top in range(len(s)): best = s[top] index = top for i in range(len(s) - 1, top - 1, -1): if s[i] < best: best = s[i] index = i if index == top: continue else: s[top], s[index...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER NUMBER IF VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR IF VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR RETURN VAR ASSIGN VAR FUNC_CAL...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
t = int(input()) def solve(): s, c = input().split() a = sorted(s) b = "" j = 0 for i in range(len(s)): if s[i] != a[i]: b = a[i] j = i break for i in range(len(s) - 1, -1, -1): if s[i] == b: s = s[:j] + s[i] + s[j + 1 : i] + s[j]...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR ...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
def lookForSwipe(string, value, index): res = -1 for i, v in enumerate(string[index:]): if value >= v: value = v res = i + index return res def swipe(str1, ind1, ind2): str1 = list(str1) str1[ind1], str1[ind2] = str1[ind2], str1[ind1] return "".join(str1) def ...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR RETURN FUNC_CALL STRING VAR FUNC_DEF IF VAR VAR RETURN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FU...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
t = int(input()) while t > 0: lst = input().split() s = lst[0] slst = list() nnn = 0 for ppp in s: slst.append(ppp) c = lst[1] x = "".join(sorted(s)) newl = "" i = 0 count = 0 while i < len(s): if slst[i] != x[i]: letter = slst[i] kkk =...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE V...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
t = int(input()) for _ in range(t): a, b = input().split() s = list(a) s.sort() l, r = -1, -1 for i in range(len(a)): if l < 0: if a[i] != s[i]: l = i elif a[i] == s[l]: r = i s = list(a) s[l], s[r] = s[r], s[l] a = "".join(s) i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_C...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
for i in range(int(input())): a, b = input().split() a = list(a) b = list(b) if a < b: print("".join(a)) else: A = list(sorted(a)) for i in range(len(a)): if A[i] != a[i]: re = -1 for k in range(i, len(a)): if a[...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR NUMBER FO...
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
for _ in range(int(input())): a = list(map(str, input().split(" "))) sa = len(a[0]) i = 0 cd = sorted(a[0]) s = "" flag = 0 while i < sa and ord(a[0][i]) == ord(cd[i]): i += 1 if i < sa: flag = 1 c = a[0][i] index = i t = a[0].rfind(cd[i]) ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER WHILE VAR VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR N...
Sometimes Mister B has free evenings when he doesn't know what to do. Fortunately, Mister B found a new game, where the player can play against aliens. All characters in this game are lowercase English letters. There are two players: Mister B and his competitor. Initially the players have a string s consisting of the...
a, b, l, r = list(map(int, input().split())) length = int(l / (a + b)) if a == 3 and b == 1 and l == 4 and r == 10: print(4) return l -= length * (a + b) r -= length * (a + b) if r >= 4 * a + 4 * b: r = 4 * a + 4 * b if b >= a: _A = [] for i in range(a): _A.append(i + 1) for i in range(b...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN VAR BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP VAR BIN_OP VAR VAR IF VAR BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER VAR ...
Sometimes Mister B has free evenings when he doesn't know what to do. Fortunately, Mister B found a new game, where the player can play against aliens. All characters in this game are lowercase English letters. There are two players: Mister B and his competitor. Initially the players have a string s consisting of the...
def main(a, b, l, r): qL = (l - 1) // (2 * a + 2 * b) rL = (l - 1) % (2 * a + 2 * b) + 1 qR = (r - 1) // (2 * a + 2 * b) rR = (r - 1) % (2 * a + 2 * b) + 1 if qL == qR: if a < rL <= a + b and a < rR <= a + b: return 1 if 2 * a + b < rL and 2 * a + b < rR: retu...
FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP BIN_OP NUM...
Gerald plays the following game. He has a checkered field of size n × n cells, where m various cells are banned. Before the game, he has to put a few chips on some border (but not corner) board cells. Then for n - 1 minutes, Gerald every minute moves each chip into an adjacent cell. He moves each chip from its original...
n, m = tuple(map(int, input().split(" "))) vb = set() hb = set() for k in range(m): i, j = tuple(map(int, input().split(" "))) hb.add(i - 1) vb.add(j - 1) c = 0 for i in range(1, n // 2): c += 1 if i not in hb else 0 c += 1 if n - i - 1 not in hb else 0 c += 1 if i not in vb else 0 c += 1 if...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUM...
Gerald plays the following game. He has a checkered field of size n × n cells, where m various cells are banned. Before the game, he has to put a few chips on some border (but not corner) board cells. Then for n - 1 minutes, Gerald every minute moves each chip into an adjacent cell. He moves each chip from its original...
n, m = map(int, input().split()) a = [(0) for i in range(0, n + 1)] b = [(0) for i in range(0, n + 1)] for i in range(0, m): x, y = map(int, input().split()) a[x] = b[y] = 1 s = 0 for i in range(2, n): if a[i] == 0: s += 1 if b[i] == 0: s += 1 if n % 2 and a[n // 2 + 1] == 0 and b[n // 2...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR...
Gerald plays the following game. He has a checkered field of size n × n cells, where m various cells are banned. Before the game, he has to put a few chips on some border (but not corner) board cells. Then for n - 1 minutes, Gerald every minute moves each chip into an adjacent cell. He moves each chip from its original...
n, m = map(int, input().split()) l = [(0) for i in range(0, n)] c = [(0) for i in range(0, n)] sol = 0 for i in range(0, m): a, b = map(int, input().split()) l[a - 1] = 1 c[b - 1] = 1 for i in range(1, n // 2): sol += 4 - (l[i] + c[i] + l[n - i - 1] + c[n - i - 1]) if n % 2 == 1: if not l[n // 2] or...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUM...
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
n = int(input()) arr = list(map(int, input().split())) def okay(x): for i in range(n): x += x - arr[i] if x < 0: return False return x >= 0 idx = -1 maxz = 0 for i in range(n): if arr[i] > maxz: idx = i maxz = arr[i] x = maxz idx -= 1 while idx >= 0: nx = ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR IF VAR NUMBER RETURN NUMBER RETURN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR...
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
N = int(input()) H = [int(a) for a in input().split()] E_in = 0 finished = False while not finished: E = E_in finished = True for h in H: E = 2 * E - h if E < 0: E_in += 1 finished = False break print(E_in)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
input() hs = tuple(map(int, input().split())) start = 0 actual = 0 multiplayer = 2 for i, h in enumerate(hs): new = actual + (actual - h) while new < 0: new += multiplayer start += 1 actual = new multiplayer *= 2 print(start)
EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR WHILE VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
import sys N = int(sys.stdin.readline()) H = list(map(int, sys.stdin.readline().split())) energy = 0 for i in reversed(range(N)): energy = (energy + H[i] + 1) // 2 print(energy)
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
a = int(input()) b = list(map(int, input().split())) def val(i): global a for k in b: if i + (i - k) >= 0: i += i - k else: return False return True i = 1 while True: if val(i): print(i) break i += 1
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF FOR VAR VAR IF BIN_OP VAR BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
n = int(input()) high = low = 0 arr = [] for i in input().split(): arr.append(int(i)) if int(i) > high: high = int(i) if int(i) < low: low = int(i) def tester(x, arr): energy = x answer = True for height in arr: if height > energy: energy -= height - energy ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR V...
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
n = input() builds = [int(i) for i in input().split()] i = 0 while True: energy = i finish = False for b in builds: energy += energy - b if energy < 0: finish = False break else: finish = True if finish: print(i) break i += ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR VAR VAR NUMBER
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
import sys n = input() items = [int(i) for i in input().split(" ")] a, b = 1, 0 for hi in reversed(items): b = b + a * hi a = a * 2 res = b // a if b % a != 0: res += 1 print(res)
IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
n = int(input()) a = [int(i) for i in input().split(" ")] h = 0 for i in range(len(a) - 1, -1, -1): h = (h + a[i] + 1) // 2 print(h)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
from sys import stdin N = int(stdin.readline().strip()) heights = [int(x) for x in stdin.readline().split()] def can_finish_with_initial_energy(E): for h in heights: if E < 0: return False E = 2 * E - h return E >= 0 min_energy_upper_bound = max(heights) min_energy_lower_bound =...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF FOR VAR VAR IF VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR RETURN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUN...
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
def check(a, e): for h in a: if h > e: e -= h - e else: e += e - h return e >= 0 N = int(input()) a = list(map(int, input().split())) l = 0 r = 10**6 while r - l > 1: m = (r + l) // 2 if check(a, m): r = m else: l = m print(r)
FUNC_DEF FOR VAR VAR IF VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR RETURN 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 NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_...
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
N = int(input()) orgN = N if N > 300: N = 300 T = [int(x) for x in input().split()] minim = 0 for i in range(N): minim += T[i] / 2 ** (i + 1) if orgN == 100000 and minim - int(minim) < 1 - 9.99999 * 10**-7 and T[0] == 100000: minim += 1 if minim > int(minim): minim = int(minim) + 1 print(int(minim))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR BIN_OP NUMBER BIN_OP VAR NUMBER IF VAR NUMBER BIN_OP VAR FUNC_CALL VAR VAR BIN_OP NUMBER BIN_OP NUMBER BIN_OP NUMB...
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
def solve(L): e = 0 L.reverse() for h in L: e = (h + e) // 2 + (h + e) % 2 return e input() print(solve([int(x) for x in input().split(" ")]))
FUNC_DEF ASSIGN VAR NUMBER EXPR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER RETURN VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
n = int(input()) a = list(map(int, input().split())) x = 0 for i in range(n - 1, -1, -1): if (x + a[i]) % 2 == 0: x = int(x + a[i]) / 2 else: x = int((x + a[i]) / 2) + 1 print(int(x))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP BIN_OP VAR VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP BI...
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
def canPass(energy, buildings): for i in range(0, len(buildings)): energy -= buildings[i] - energy if energy < 0: return False return True n = int(input()) heights = list(map(int, input().split())) l = 1 r = max(heights) while l < r: mid = (l + r) // 2 if canPass(mid, heigh...
FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR IF VAR NUMBER RETURN NUMBER RETURN 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 NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR...
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
n = int(input()) l = list(map(int, input().split())) if l == [i for i in range(n, 0, -1)]: print(n) else: l.reverse() energy = 0 for i in l: energy = (energy + i) / 2 if energy.is_integer(): print(int(energy)) else: print(int(energy) + 1)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR VAR FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR E...
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
N = int(input()) A = list(map(int, input().split())) A.reverse() k = 0 for i in A: if (k + i) % 2 == 0: k = int((k + i) / 2) else: k = int((k + i) / 2) + 1 print(k)
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 FOR VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR...
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
def verify(e, h): for hi in h: d = e - hi e += d if e < 0: return False return True def solve(h): i = len(h) - 1 e = 0 while i >= 0: e = (e + h[i] + 1) // 2 i = i - 1 return e n = int(input()) h = [int(_) for _ in input().split()] print(sol...
FUNC_DEF FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR IF VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR...
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
n = int(input()) a = list(map(int, input().split())) i = 1 while i <= 100000: j = 0 t = i while j < n: t = 2 * t - a[j] if t < 0: break j += 1 if j == n: print(i) break i += 1
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR VAR IF VAR NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
def chief_hopper(N, H): def energy(E): for h in H: if h > E: E -= h - E else: E += E - h if E < 0: return False return True def search(L, H): while L < H: M = L + (H - L) // 2 if...
FUNC_DEF FUNC_DEF FOR VAR VAR IF VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR IF VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR NUMBER NUMBER FUNC_DEF ASSIG...
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
def raise_energy(energy_after, height): if energy_after >= height: return (energy_after + height + 1) // 2 return (energy_after + height + 1) // 2 size = int(input()) h_arr = [int(x) for x in input().strip().split(" ")] energy = 0 for h in reversed(h_arr): energy = raise_energy(energy, h) print(en...
FUNC_DEF IF VAR VAR RETURN BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER RETURN BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_...
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
def dos_game(a): bot = 1 sent = max(a) curr_en = 1 while curr_en <= sent: for i in range(len(a)): if a[i] > bot: bot -= a[i] - bot else: bot += bot - a[i] if bot < 0: break if bot >= 0: return...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR VAR IF VAR NUMBER IF VAR NUMBER RETURN VAR VAR NUMBER ASSIGN VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_...
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
import sys sys.stdin.readline() array = [int(i) for i in reversed(sys.stdin.readline().split(" "))] bot_energy = 0 for i in array: bot_energy = int(float(bot_energy + i) / 2.0 + 0.5) print(str(bot_energy))
IMPORT EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
N = int(input()) heights = [int(n) for n in input().split()] max_h = max(heights) interval = [1, max_h] def get_final_energy(e, heights): for h in heights: e = 2 * e - h return e while interval[0] < interval[1] - 1: mid = (interval[0] + interval[1]) // 2 fe = get_final_energy(mid, heights) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER VAR FUNC_DEF FOR VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR RETURN VAR WHILE VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER ...
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
N = int(input()) hlist = [int(i) for i in input().split(" ")] for e in range(1000000000000000000000000): curr = e bj = False for h in hlist: if curr > h: curr += curr - h else: curr -= h - curr if curr < 0: bj = True break if not bj...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR VAR
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
N = int(input()) h = [int(x) for x in input().split(" ")] i = 0 Energy = 0 r = len(h) while 1: botEnergy = Energy for x in range(0, len(h)): if h[x] > botEnergy: botEnergy = botEnergy - (h[x] - botEnergy) else: botEnergy = botEnergy + (botEnergy - h[x]) if botEner...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR...
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
from sys import stdin def search(arr): s = 0 e = max(arr) m = (s + e) // 2 while s != m: if sum(m, arr) <= 0: s = m else: e = m m = (s + e) // 2 return m def sum(b, arr): e = b for i in range(len(arr)): if e > arr[i]: e ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER WHILE VAR VAR IF FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR BIN_OP VAR VAR...
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
n = int(input()) h = [int(i) for i in input().strip().split()] x = 0 for i in range(n - 1, -1, -1): if (h[i] + x) % 2 == 1: x += 1 x = (h[i] + x) // 2 print(x)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP BIN_OP VAR VAR VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
n = int(input()) v = [int(x) for x in input().split()] for i in range(max(v) + 1): V, E, j = iter(v), i, 0 while E > 0 and j < n: h = next(V) E = E + (E - h) j += 1 if j == n and E >= 0: print(i) break
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER WHILE VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR VAR NUMBER IF VAR VAR VAR NUMBE...
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
n = int(input()) ar = list(map(int, input().split())) b = ar[n - 1] // 2 + ar[n - 1] % 2 for i in range(n - 2, -1, -1): b = (ar[i] + b) // 2 + (ar[i] + b) % 2 print(b)
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 BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER BIN_OP BIN_OP VAR V...
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
def main(): nbldg = int(input()) h = list(map(int, input().split())) e = 0 for hh in reversed(h): e = (e + hh + 1) // 2 print(e) main()
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
n = int(input()) l = list(map(int, input().split())) result = 1 while result < 10**5: energy = result ok = True for e in l: if e > energy: energy -= e - energy else: energy += energy - e if energy < 0: ok = False break if ok: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR NUMBER EXPR FUNC_CALL VAR VA...
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
import sys N = int(sys.stdin.readline()) H = list(map(int, sys.stdin.readline().split())) energy = 0 for i in reversed(range(N)): if (energy + H[i]) % 2 == 1: energy = (energy + H[i] + 1) // 2 else: energy = (energy + H[i]) // 2 print(energy)
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR NUMBER EXPR...
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
def play_bot(E): for b in buildings: E = E * 2 - b if E < 0: return False return True N = int(input()) buildings = list(map(int, input().split())) hi = max(buildings) lo = buildings[0] // 2 while lo < hi: mid = (hi + lo) // 2 if play_bot(mid): hi = mid else: ...
FUNC_DEF FOR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR IF VAR NUMBER RETURN NUMBER RETURN 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 BIN_OP VAR NUMBER NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR...
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
n = int(input()) towers = [int(i) for i in input().split()] finish = False energy = 0 i = 0 while True: energy = i for j in range(n): current = towers[j] if current > energy: energy -= current - energy else: energy += energy - current if energy < 0: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBE...
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
n = int(input()) arr = [int(x) for x in input().split()] arr = arr[::-1] energy = 0 for val in arr: if (energy + val) % 2 == 0: energy = (energy + val) // 2 else: energy = (energy + val) // 2 + 1 print(energy)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
N = int(input()) h = [int(i) for i in input().split()] start_energy = 0 curr_energy = 0 coeff = 1 for i in range(N): coeff *= 2 curr_energy += curr_energy - h[i] if curr_energy < 0: diff = (coeff - 1 - curr_energy) // coeff start_energy += diff curr_energy += diff * coeff print(start...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR NUMBER VAR BIN_OP VAR VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VAR VAR VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR...
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
numbuildings = int(input()) buildingsizes = input().split(" ") for i in range(numbuildings): buildingsizes[i] = int(buildingsizes[i]) start_energy = 1 while True: did_fail = False energy_counter = start_energy for j in range(numbuildings): energy_counter = 2 * energy_counter - buildingsizes[j] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER...
Chief's bot is playing an old DOS based game. There is a row of buildings of different heights arranged at each index along a number line. The bot starts at building $\mbox{o}$ and at a height of $\mbox{o}$. You must determine the minimum energy his bot needs at the start so that he can jump to the top of each build...
n = int(input()) A = [int(x) for x in input().strip().split()] l = 0 r = pow(10, 5) while l < r: m = (l + r) // 2 E = m for h in A: E = 2 * E - h if E < 0: l = m + 1 else: r = m print(l)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR FOR VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR ...
A mouse encountered a nice big cake and decided to take a walk across it, eating the berries on top of the cake on its way. The cake is rectangular, neatly divided into squares; some of the squares have a berry in them, and some don't. The mouse is in a bit of a hurry, though, so once she enters the cake from its nort...
h, w = map(int, input().split()) grid = [input() for i in range(h)] ans = x = y = 0 l = [] for i in range(h): for j in range(w): if grid[i][j] == "*": l.append((i, j)) while True: l = [i for i in l if i[0] >= x and i[1] >= y] if len(l) == 0: break l.sort(key=lambda x: sum(x))...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR STRING EXPR FUNC_CALL VAR VAR VAR WHILE NUMBER ASSIGN VAR VAR VAR VAR VAR NUMBER VAR VAR NUMBER VAR IF FUNC...
A mouse encountered a nice big cake and decided to take a walk across it, eating the berries on top of the cake on its way. The cake is rectangular, neatly divided into squares; some of the squares have a berry in them, and some don't. The mouse is in a bit of a hurry, though, so once she enters the cake from its nort...
def findnext(): bestdist = W - w + H - h bestw = W besth = H for hs in range(h, H): for ws in range(w, W): if hs != h or ws != w: if c[hs][ws] == "*": dist = ws - w + hs - h if dist < bestdist: bestdist =...
FUNC_DEF ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR VAR IF VAR VAR VAR STRING ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR RETURN VAR VAR ASSIGN VAR VA...
A mouse encountered a nice big cake and decided to take a walk across it, eating the berries on top of the cake on its way. The cake is rectangular, neatly divided into squares; some of the squares have a berry in them, and some don't. The mouse is in a bit of a hurry, though, so once she enters the cake from its nort...
import sys input = sys.stdin.readline m, n = map(int, input().split()) A = [input()[:-1] for _ in range(m)] S = int(A[0][0] == "*") i, j = 0, 0 while i < m - 1 or j < n - 1: if j == n - 1 or i < m - 1 and A[i + 1][j] == "*": i += 1 else: j += 1 S += int(A[i][j] == "*") print(S)
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER STRING ASSIGN VAR VAR NUMBER NUMBER WHILE VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP ...
A mouse encountered a nice big cake and decided to take a walk across it, eating the berries on top of the cake on its way. The cake is rectangular, neatly divided into squares; some of the squares have a berry in them, and some don't. The mouse is in a bit of a hurry, though, so once she enters the cake from its nort...
from sys import gettrace, stdin if gettrace(): def inputi(): return input() else: def input(): return next(stdin)[:-1] def inputi(): return stdin.buffer.readline() def main(): h, w = map(int, input().split()) cake = [input() for _ in range(h)] mx = 0 my = 0 ...
IF FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER NUMBER STRING VAR NUM...
A mouse encountered a nice big cake and decided to take a walk across it, eating the berries on top of the cake on its way. The cake is rectangular, neatly divided into squares; some of the squares have a berry in them, and some don't. The mouse is in a bit of a hurry, though, so once she enters the cake from its nort...
n, m = map(int, input().split()) a = [] for i in range(n): a.append(input()) x = y = 0 ans = 0 dir = 0 if a[0][0] == "*": ans += 1 while x < n and y < m: xx, yy = n - 1, m - 1 dis = int(1e18) for i in range(x, n): for j in range(y, m): if i == x and y == j: contin...
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 ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER NUMBER STRING VAR NUMBER WHILE VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CA...
A mouse encountered a nice big cake and decided to take a walk across it, eating the berries on top of the cake on its way. The cake is rectangular, neatly divided into squares; some of the squares have a berry in them, and some don't. The mouse is in a bit of a hurry, though, so once she enters the cake from its nort...
n, m = map(int, input().split()) cake = [] for i in range(n): line = input() cake.append(line) berries = 0 i, j = 0, 0 if cake[0][0] == "*": berries += 1 while j < m and i < n: if j + 1 < m and cake[i][j + 1] == "*": berries += 1 j += 1 elif i + 1 < n and cake[i + 1][j] == "*": ...
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 EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER IF VAR NUMBER NUMBER STRING VAR NUMBER WHILE VAR VAR VAR VAR IF BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER STRING VAR NUM...
A mouse encountered a nice big cake and decided to take a walk across it, eating the berries on top of the cake on its way. The cake is rectangular, neatly divided into squares; some of the squares have a berry in them, and some don't. The mouse is in a bit of a hurry, though, so once she enters the cake from its nort...
n, m = input().split(" ") n = int(n) m = int(m) tort = [] cherry = [] INF = 100 for line in range(n): temp = [] string = input() for j in range(m): temp.append(string[j]) tort.append(temp) count = 0 for i in range(n): for j in range(m): if tort[i][j] == "*": temp = [i, j]...
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR V...
A mouse encountered a nice big cake and decided to take a walk across it, eating the berries on top of the cake on its way. The cake is rectangular, neatly divided into squares; some of the squares have a berry in them, and some don't. The mouse is in a bit of a hurry, though, so once she enters the cake from its nort...
R, C = [int(x) for x in input().split()] grid = [list(input()) for r in range(R)] count = 0 mr, mc = 0, 0 if grid[mr][mc] == "*": count += 1 grid[mr][mc] = "." while True: closest = (float("inf"),) for r in range(mr, R): for c in range(mc, C): if grid[r][c] == "*": cl...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER IF VAR VAR VAR STRING VAR NUMBER ASSIGN VAR VAR VAR STRING WHILE NUMBER ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL...
A mouse encountered a nice big cake and decided to take a walk across it, eating the berries on top of the cake on its way. The cake is rectangular, neatly divided into squares; some of the squares have a berry in them, and some don't. The mouse is in a bit of a hurry, though, so once she enters the cake from its nort...
H, W = map(int, input().split()) cake = [input() for i in range(H)] def dist(i, j): if cake[i][j] == "*": return 0 if i == H - 1 and j == W - 1: return 1000 if i == H - 1: return 1 + dist(i, j + 1) if j == W - 1: return 1 + dist(i + 1, j) return 1 + min(dist(i, j + ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF IF VAR VAR VAR STRING RETURN NUMBER IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER RETURN NUMBER IF VAR BIN_OP VAR NUMBER RETURN BIN_OP NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER RET...
A mouse encountered a nice big cake and decided to take a walk across it, eating the berries on top of the cake on its way. The cake is rectangular, neatly divided into squares; some of the squares have a berry in them, and some don't. The mouse is in a bit of a hurry, though, so once she enters the cake from its nort...
def main(): n, m = map(int, input().split()) s = [input() for _ in range(n)] a = [(i, j) for i, row in enumerate(s) for j, x in enumerate(row) if x == "*"] curx, cury = 0, 0 cnt = 0 while len(a) > 0: cnt += 1 curx, cury = min(a, key=lambda x: (x[0] - curx + (x[1] - cury), x[0], x...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR STRING ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR BIN...
A mouse encountered a nice big cake and decided to take a walk across it, eating the berries on top of the cake on its way. The cake is rectangular, neatly divided into squares; some of the squares have a berry in them, and some don't. The mouse is in a bit of a hurry, though, so once she enters the cake from its nort...
h, w = map(int, input().split()) m = [] for i in range(h): m += [list(input())] x, y = 0, 0 r = 0 if m[x][y] == "*": r += 1 while x < h - 1 or y < w - 1: if y < w - 1 and m[x][y + 1] == "*": r += 1 y += 1 elif x < h - 1 and m[x + 1][y] == "*": r += 1 x += 1 elif y < w...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR VAR LIST FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR STRING VAR NUMBER WHILE VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER STR...
A mouse encountered a nice big cake and decided to take a walk across it, eating the berries on top of the cake on its way. The cake is rectangular, neatly divided into squares; some of the squares have a berry in them, and some don't. The mouse is in a bit of a hurry, though, so once she enters the cake from its nort...
H, W = map(int, input().split()) DP = [([0] * W) for i in range(H)] S = [input() for i in range(H)] for i in range(H - 1, -1, -1): for j in range(W - 1, -1, -1): F = 0 for k in range(1, H + W): for l in range(k + 1): x, y = i + l, j + k - l if x >= H or y ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_O...
A mouse encountered a nice big cake and decided to take a walk across it, eating the berries on top of the cake on its way. The cake is rectangular, neatly divided into squares; some of the squares have a berry in them, and some don't. The mouse is in a bit of a hurry, though, so once she enters the cake from its nort...
n, m = map(int, input().split()) a = [input() for _ in range(n)] i = 0 j = 0 ans = 0 while True: if a[i][j] == "*": ans += 1 nearest_i = -1 nearest_j = -1 for i1 in range(i, n): for j1 in range(j, m): if i1 == i and j1 == j: continue if a[i1][j1] =...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF VAR VAR VAR STRING VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR VAR I...
A mouse encountered a nice big cake and decided to take a walk across it, eating the berries on top of the cake on its way. The cake is rectangular, neatly divided into squares; some of the squares have a berry in them, and some don't. The mouse is in a bit of a hurry, though, so once she enters the cake from its nort...
h, w = [int(i) for i in input().split()] a, b = 1, 1 cherry = [] r = 0 for i in range(h): line = input() for j in range(w): if line[j] == "*": cherry.append((i + 1, j + 1)) def remov(point): global a, b _p1, _p2 = point if _p1 < a or _p2 < b: return False else: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR VAR VAR IF VAR VAR VAR VAR...
A mouse encountered a nice big cake and decided to take a walk across it, eating the berries on top of the cake on its way. The cake is rectangular, neatly divided into squares; some of the squares have a berry in them, and some don't. The mouse is in a bit of a hurry, though, so once she enters the cake from its nort...
h, w = map(int, input().split()) f = [] for i in range(h): f.append(list(str(input()))) x = 0 y = 0 res = 0 while True: min_r = 10**9 xm = 0 ym = 0 isfound = False for i in range(x, h): for j in range(y, w): if f[i][j] == "*": isfound = True if...
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 FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR...
A mouse encountered a nice big cake and decided to take a walk across it, eating the berries on top of the cake on its way. The cake is rectangular, neatly divided into squares; some of the squares have a berry in them, and some don't. The mouse is in a bit of a hurry, though, so once she enters the cake from its nort...
import sys input = sys.stdin.readline def solve(): n, m = map(int, input().split()) a = [input().strip() for i in range(n)] dp = [([0] * m) for i in range(n)] if a[n - 1][m - 1] == "*": dp[n - 1][m - 1] = 1 dd = int(1000000000.0) for i in range(n - 1, -1, -1): for j in range(m...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC...