description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Knight is at (start_x,start_y) in Geekland which is represented by an NxM 2D matrix. Each cell in the matrix contains some points. In the ith step, the knight can collect all the points from all the cells that can be visited in exactly i steps without revisiting any cell. Also, the knight has some magical powers that e...
class Solution: def knightInGeekland(self, arr, start): n, m = len(arr), len(arr[0]) dp = [[(-1) for _ in range(m)] for __ in range(n)] coins = [] starting = [[start[0], start[1]]] coins.append(arr[start[0]][start[1]]) dp[start[0]][start[1]] = 1 self.traverse...
CLASS_DEF FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST LIST VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR NU...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) ar = list(map(int, input().split())) dp0 = [0] * (n + 1) dp1 = [0] * (n + 1) dp2 = [0] * (n + 1) dp0[0] = 1 if ar[0] == 1 or ar[0] == 3: dp1[0] = 0 else: dp1[0] = 10000000 if ar[0] == 2 or ar[0] == 3: dp2[0] = 0 else: dp2[0] = 10000000 for i in range(1, n): dp0[i] = min(min(dp0[i - ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER IF VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) days = [int(_) for _ in input().split()] ff = {(0, n): 0, (1, n): 0, (2, n): 0} def f(t, k): if not (t, k) in ff: www = [] for x in range(3): if x == 0: www.append(f(x, k + 1) + 1) elif x & days[k] and (t == 0 or t != x): www...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT NUMBER VAR NUMBER VAR NUMBER VAR NUMBER NUMBER NUMBER FUNC_DEF IF VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER IF...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) line = [int(x) for x in input().split()] d = [0] * 3 for i in line: d_1 = d[:] d[0] = min(d_1) + 1 if i == 1: d[1] = min(d_1[0], d_1[2]) d[2] = 10**6 elif i == 2: d[2] = min(d_1[0], d_1[1]) d[1] = 10**6 elif i == 3: d[1] = min(d_1[0], d_1[2]) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER BIN_OP NUMBER NUMBER IF ...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
log = lambda *x: print(*x) def cin(*fn, def_fn=str): i, r = 0, [] for c in input().split(" "): r += [(fn[i] if len(fn) > i else fn[0])(c)] i += 1 return r INF = 1 << 33 def solve(a, n): dp = [] for i in range(n + 1): dp += [[]] for j in range(n + 1): ...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF VAR ASSIGN VAR VAR NUMBER LIST FOR VAR FUNC_CALL FUNC_CALL VAR STRING VAR LIST FUNC_CALL FUNC_CALL VAR VAR VAR VAR VAR VAR NUMBER VAR VAR NUMBER RETURN VAR ASSIGN VAR BIN_OP NUMBER NUMBER FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR LIST LIST FOR VAR FUNC_CA...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
numday = input() dayorder = input() array = map(int, dayorder.split(" ")) sumrest = 0 prev = 3 for i in array: if i == prev and prev != 3: i = 0 elif i == 3 and prev != 3: i -= prev if i == 0: sumrest += 1 prev = i print(sumrest)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) lt = list(map(int, input().split())) l = [0] + lt c = 0 t = [0] * (n + 1) for i in range(1, len(l)): if l[i] == 1: t[i] = "C" elif l[i] == 2: t[i] = "G" elif l[i] == 3: if t[i - 1] == "C": t[i] = "G" elif t[i - 1] == "G": t[i] = "C" ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR STRING IF VAR VAR NUMBER ASSIGN VA...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
def main(): n = int(input()) vacation = [int(i) for i in input().split()] sum = 0 i = 0 res = [] for i in range(n): row = [] if i == 0: if vacation[i] == 0: row.append(1) row.append(101) row.append(101) elif ...
FUNC_DEF 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 LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST IF VAR NUMBER IF VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR ...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) aa = map(int, input().split()) v = [[0, 0], [0, 0]] for a in aa: if a < 2: max_s = v[-1][0] else: max_s = max([v[-1][0], v[-2][0] + 1, v[-1][1] + 1]) if a % 2 == 0: max_c = v[-1][1] else: max_c = max([v[-1][1], v[-2][1] + 1, v[-1][0] + 1]) v.append([m...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST LIST NUMBER NUMBER LIST NUMBER NUMBER FOR VAR VAR IF VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR LIST VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER NUMBER BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) c = list(map(int, input().split())) l = 0 if c[0] == 3: c[0] = 0 elif c[0] == 0: l += 1 for i in range(1, n): if c[i - 1] == c[i]: l += 1 c[i] = 0 elif c[i] == 3: if c[i - 1] == 0: c[i] = 0 else: c[i] = 3 - c[i - 1] elif c[i] =...
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 IF VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER IF VAR NUMBER NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR NUMBER I...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
input() mat = [0, 0, 0] for i in map(int, input().split()): tmp = mat[:] mat[0] = min(tmp) + 1 mat[1] = min(tmp[0], tmp[2]) if i == 1 or i == 3 else 10000000.0 mat[2] = min(tmp[0], tmp[1]) if i == 2 or i == 3 else 10000000.0 print(min(mat))
EXPR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR NUMBER VAR NUMBER FUNC_CALL VAR VAR NUMBER V...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) a = list(map(int, input().split())) INF = float("inf") dp = [([INF] * 3) for i in range(n + 1)] dp[0][0] = 0 for i in range(n): k = a[i] dp[i + 1][0] = min(dp[i][0], dp[i][1], dp[i][2]) + 1 if k == 1: dp[i + 1][1] = min(dp[i][0], dp[i][2]) elif k == 2: dp[i + 1][2] = min...
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 STRING ASSIGN VAR BIN_OP LIST VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) numbers = list(map(int, input().split(" "))) memo = [[(0) for _ in range(4)] for _ in range(n)] first = numbers[0] if first != 0: if first == 3: memo[0][1] = 1 memo[0][2] = 1 else: memo[0][first] = 1 for i in range(1, n): j = numbers[i] for k in range(0, i): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER IF VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER VAR NUMBER...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) d0, d1, d2 = 0, 0, 0 for ai in map(int, input().split()): if ai == 0: d0 = max(d1, d2) elif ai == 1: d0, d2 = max(d1, d2), max(d0, d1) + 1 elif ai == 2: d0, d1 = max(d1, d2), max(d0, d2) + 1 elif ai == 3: d0, d1, d2 = max(d1, d2), max(d0, d2) + 1, max(d0,...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) a = [i for i in input().split(" ")] dp = [] for i in range(n): dp.append([]) for _ in range(3): dp[i].append(0) dp[0][0] = 1 if a[0] == "1" or a[0] == "3": dp[0][1] = 0 else: dp[0][1] = 1 if a[0] == "2" or a[0] == "3": dp[0][2] = 0 else: dp[0][2] = 1 for i in range(1, n)...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER IF VAR NUMBER STRING VAR NUMBER STRING ASSIGN VAR NUMBER NUMBER NUMBER ASS...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) a = list(map(int, input().split())) a.insert(0, 0) p = [] for i in range(n + 1): p.append([]) p[i].append(0) p[i].append(0) for i in range(1, n + 1): if a[i] == 1 or a[i] == 3: p[i][0] = max(p[i - 1][1] + 1, p[i - 1][0]) else: p[i][0] = max(p[i - 1][0], p[i - 1][1]) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR LIST EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR N...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) l = list(map(int, input().split())) if n == 1: if l[0] == 0: print(1) else: print(0) else: dp = [[float("inf") for i in range(3)] for j in range(n)] for i in range(n): for j in range(3): if i == 0: dp[i][0] = 1 if l[i] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR ...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
t = 1 for qwe in range(t): n = int(input()) a = list(map(int, input().split())) temp = [0, 0, 0] temp.extend(a) a = temp ans = 0 for i in range(n + 3): if a[i] == 0: ans += 1 a[i] = 0 elif a[i] == 3: pass elif a[i] == 1: ...
ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER VAR NUMBER ASSIGN V...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) a = list(map(int, input().split())) best = [0, 0, 0] for i in range(n): nx_best = [0, 0, 0] if a[i] in (1, 3): nx_best[1] = max(best[0], best[2]) + 1 if a[i] in (2, 3): nx_best[2] = max(best[0], best[1]) + 1 nx_best[0] = max(best) best = nx_best[:] print(n - max(best...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER IF VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER VAR NUMBER NUMBER IF VAR VAR NUMBER NUM...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
for t in range(1): n = int(input()) arr = list(map(int, input().split())) prev = arr[0] if prev == 0: count = 1 else: count = 0 for ele in range(1, n): i = arr[ele] if i == 0: count += 1 prev = 0 continue elif i == 1: ...
FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF V...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) days = input().strip().split() dp = [[0, 0, 0] for x in range(n + 1)] for x in range(n - 1, -1, -1): job = days[x] if job == "0": dp[x][0] = 1 + min(dp[x + 1][0], dp[x + 1][1], dp[x + 1][2]) dp[x][1] = 9999999 dp[x][2] = 9999999 elif job == "1": dp[x][0] = 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR IF VAR STRING ASSIGN VAR VAR NUMBER BIN_OP NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMB...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) a = map(int, input().split()) last_act = 0 cnt = 0 for act in a: if act == 0: last_act = 0 cnt += 1 elif act == 3: if last_act: last_act = 1 if last_act == 2 else 2 elif act in [1, 2]: if last_act == act: cnt += 1 last_act ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER IF VAR NUMBER IF VAR ASSIGN VAR VAR NUMBER NUMBER NUMBER IF VAR LIST NUMBER NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) days = [int(c) for c in input().split()] memo = {} def solve(day=0, prev=0): if (day, prev) in memo: return memo[day, prev] cur = days[day] if day == n - 1: if cur == 0: return 1 elif cur == 3: return 0 elif cur == 1: ret...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FUNC_DEF NUMBER NUMBER IF VAR VAR VAR RETURN VAR VAR VAR ASSIGN VAR VAR VAR IF VAR BIN_OP VAR NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN VAR NUMBER NUMBER NUMBER IF VA...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
x = 0 g = False c = False rest = 0 n = int(input()) lst = list(map(int, input().split())) for i in lst: if g and i == 1 or c and i == 2: rest += 1 g = False c = False elif i == 0: rest += 1 g = False c = False elif i == 3: l = c c = g g...
ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR IF VAR VAR NUMBER VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN ...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) A = list(map(int, input().split())) c = 0 p = -1 for i in range(n): if A[i] == 0: c = c + 1 p = -1 if A[i] == 1: if A[i] == p: c = c + 1 p = -1 else: p = 1 if A[i] == 2: if A[i] == p: c = c + 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 ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN ...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
act = int(input()) a = list(map(int, input().split())) dp = [[(-1) for i in range(3)] for j in range(act + 1)] c = 0 def ans(n, k): if n == act: return 0 if dp[n][k] != -1: return dp[n][k] if a[n] == 0: dp[n][k] = 1 + ans(n + 1, 0) return 1 + ans(n + 1, 0) if a[n] == 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 VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR VAR VAR NUMBER RETURN VAR VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR VAR BIN_O...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) s = (int(t) for t in input().split(" ")) prev = 3 count = 0 for c in s: if c == 0: count += 1 prev = 0 elif c == 3: prev = 3 - prev elif c == prev: count += 1 prev = 0 else: prev = c print(count)
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 FOR VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR IF VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) A = list(map(int, input().split())) d = {} def dp(at, s, w): if at == n: return 0 if (at, s, w) in d: return d[at, s, w] ret = 10**9 if A[at] == 0: ret = min(ret, dp(at + 1, False, False) + 1) if A[at] == 1: ret = min(ret, dp(at + 1, False, False) +...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR VAR VAR VAR RETURN VAR VAR VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER IF VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMB...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) a = list(map(int, input().split())) inf = 10**10 dp = [0, 0] for x in a: z = min(dp) if x == 0: dp[0] = 1 + z dp[1] = 1 + z elif x == 1: dp[1] = min(dp[0], dp[1] + 1) dp[0] = z + 1 elif x == 2: dp[0] = min(dp[1], dp[0] + 1) dp[1] = z + 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 BIN_OP NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR NUMBER BIN_OP NUMBER VAR IF VAR NUMBER ASSIGN VAR ...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
dp = [[(200) for i in range(3)] for j in range(100)] n = int(input()) li = list(map(int, input().split())) dp[0][0] = 1 if li[0] == 1 or li[0] == 3: dp[0][1] = 0 if li[0] == 2 or li[0] == 3: dp[0][2] = 0 for i in range(1, n): dp[i][0] = 1 + min(dp[i - 1][0], dp[i - 1][1], dp[i - 1][2]) if li[i] == 1 or ...
ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER NUMBER NUMBER IF VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER IF VAR NUMBER NUMBER VAR NUMBER NUMBER ASSI...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) a = list(map(int, input().split())) def func(b, p): if len(b) == 1: if p == 0: if b[0] == 0: return 1 else: return 0 elif p == 1: if b[0] == 0 or b[0] == 1: return 1 else: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF FUNC_CALL VAR VAR NUMBER IF VAR NUMBER IF VAR NUMBER NUMBER RETURN NUMBER RETURN NUMBER IF VAR NUMBER IF VAR NUMBER NUMBER VAR NUMBER NUMBER RETURN NUMBER RETURN NUMBER IF VAR NUMBER IF VAR NUMBER NUMBE...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) a = list(map(int, input().split())) a.insert(0, 3) v = 0 for i in range(1, n + 1): act = a[i] pAct = a[i - 1] if act == 3: if pAct == 1: a[i] = 2 elif pAct == 2: a[i] = 1 elif act == 1: if pAct == 1: a[i] = 0 v += 1...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR NUMBER ...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
inf = 1061109567 dp = [] for i in range(105): dp.append([inf, inf, inf]) n = int(input()) dp[0][0] = 0 i = 0 for x in input().split(" "): i += 1 x = int(x) dp[i][0] = min(dp[i - 1][0], dp[i - 1][1], dp[i - 1][2]) + 1 if x == 1 or x == 3: dp[i][1] = min(dp[i - 1][0], dp[i - 1][2]) if x ==...
ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR LIST VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL FUNC_CALL VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR BIN_OP...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
N = int(input()) days = input().split() impossible = None bad_days = 0 x = 0 while x < N: i = days[x] if i == "1": if impossible != "1": impossible = "1" else: bad_days += 1 impossible = None elif i == "2": if impossible != "2": impossi...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NONE ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR VAR IF VAR STRING IF VAR STRING ASSIGN VAR STRING VAR NUMBER ASSIGN VAR NONE IF VAR STRING IF VAR STRING ASSIGN VAR STRING VAR NUMBER ASSIGN VAR NONE IF VAR STRING V...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
I = input n = int(I()) b = [(0, 0)] for i in map(int, I().split()): if i == 0: b += [(max(b[-1]), max(b[-1]))] if i == 1: b += [(max(b[-1]), b[-1][0] + 1)] if i == 2: b += [(b[-1][1] + 1, max(b[-1]))] if i == 3: b += [(b[-1][1] + 1, b[-1][0] + 1)] print(n - max(b[-1]))
ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR LIST FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR LIST FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER NUMBER NUMBER IF VAR NUMBER VAR LIST BIN_OP VAR...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
nDays = int(input()) sqc = input().split() inf = 1000000 dp = [[(0) for x in range(3)] for x in range(nDays + 1)] dp[0][0] = 0 dp[0][1] = 0 dp[0][2] = 0 for i in range(nDays + 1): if i == 0: continue dp[i][0] = 1 + min(dp[i - 1][0], min(dp[i - 1][1], dp[i - 1][2])) dp[i][1] = ( min(dp[i - 1]...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
def cbefore(pos): if cbeforememo[pos] > -1: return cbeforememo[pos] if pos == len(a) - 1: if a[pos] == 0 or a[pos] == 1: cbeforememo[pos] == 1 return 1 else: cbeforememo[pos] == 0 return 0 elif a[pos] == 0 or a[pos] == 1: ans = ...
FUNC_DEF IF VAR VAR NUMBER RETURN VAR VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR NUMBER VAR VAR NUMBER EXPR VAR VAR NUMBER RETURN NUMBER EXPR VAR VAR NUMBER RETURN NUMBER IF VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP NUMBER VAR RETURN BIN_OP NUMBER VAR ASSI...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) arr = list(map(int, input().rstrip().split())) rest = 0 past = 0 i = 0 for i in range(len(arr)): if arr[i] == 0 or arr[i] == past: rest += 1 past = 0 elif arr[i] == 3: if past != 0: past = 3 - past else: past = arr[i] print(rest)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP N...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) s = list(map(int, input().split())) s1 = 0 r = 0 for i in range(n): if s[i] == 0: r += 1 s1 = 0 elif s[i] == 1: if s1 == 1: r += 1 s1 = 0 else: s1 = 1 elif s[i] == 2: if s1 == 2: r += 1 s1 = ...
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 NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR NUMBER IF VAR N...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) days = [0] + [int(c) for c in input().split()] dp = [([float("infinity")] * 3) for _ in range(n + 1)] dp[0] = [0] * 3 for i in range(1, n + 1): cur = days[i] dp[i][0] = 1 + min(dp[i - 1]) if cur == 2 or cur == 3: dp[i][1] = min(dp[i - 1][0], dp[i - 1][2]) if cur == 1 or cur == 3...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST FUNC_CALL VAR STRING NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN V...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
user = int(input()) n = list(input().split(" ")) l = len(n) - 1 r = 0 a = 0 c = 0 res = [] for i in n: if int(i) == 0: r = r + 1 a = 0 c = c + 1 if int(i) == 1: if a == 0 or a != 2: a = 2 c = c + 1 else: r = r + 1 a = 0 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUM...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) a = list(map(int, input().split())) cnt = 0 x = 0 for i in range(n): if a[i] != 3: x = i break for i in range(x, n): if a[i] == 0: cnt += 1 if i > 0 and a[i] == 2 and a[i - 1] == 2: a[i] = 0 cnt += 1 if i > 0 and a[i] == 1 and a[i - 1] == 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 ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR VAR IF VAR VAR NUMBER VAR NUMBER IF VAR NUMBER VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER AS...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) num = map(int, input().split()) rest = sport = contest = 0 for i in num: if i == 3: contest, sport, rest = ( max(contest, rest + 1, sport + 1), max(sport, contest + 1, rest + 1), max(rest, contest, sport), ) elif i == 1: contest, rest ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER FOR VAR VAR IF VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR VAR IF VAR NUMBER ASSIGN VA...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) arr = list(map(lambda x: int(x), input().split(" "))) dp = [([None] * n) for _ in range(3)] first = arr[0] dp[0][0] = 0 if first == 1: dp[1][0] = 1 if first == 2: dp[2][0] = 1 if first == 3: dp[1][0] = 1 dp[2][0] = 1 for c in range(1, n): val = arr[c] cand = [dp[0][c - 1], dp[1]...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NONE VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER IF VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER IF VAR NUMBER ASSIGN VAR NUMBER NUMB...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) li = input().split() count = 0 for i in range(0, n): if li[i] == "3": if i == 0 and i + 1 < n: if li[i + 1] == "1" or li[i + 1] == "2": li[i] = str(int(li[i + 1]) ^ 3) elif i == n - 1 and i > 0: if li[i - 1] == "1" or li[i - 1] == "2": ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING IF VAR NUMBER BIN_OP VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER I...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
def max_work_days(days): n = len(days) work = [0] * (n + 1) if days[0] > 0: work[1] = 1 else: work[1] = 0 for i in range(2, n + 1): if days[i - 2] == 3: j = i - 2 while j >= 0 and days[j] == 3: j -= 1 if j < 0: ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER IF VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR VAR NUMBER VAR NUMBER IF VAR NUMBE...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
from sys import stdin, stdout def INI(): return int(stdin.readline()) def INL(): return [int(_) for _ in stdin.readline().split()] def INS(): return stdin.readline() def MOD(): return pow(10, 9) + 7 def OPS(ans): stdout.write(str(ans) + "\n") def OPL(ans): [stdout.write(str(_) + " ")...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF RETURN BIN_OP FUNC_CALL VAR NUMBER NUMBER NUMBER FUNC_DEF EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR STRING FUNC_DEF EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR STRING VAR VA...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
def minrest(): n = int(input().strip()) a = [int(i) for i in input().strip().split()] r = [[(0) for i in range(n)] for j in range(3)] r[0][-1] = 1 for i in range(1, 3): r[i][-1] = 1 if i & a[-1] == 0 else 0 for i in range(n - 2, -1, -1): r[0][i] = 1 + min(r[1][i + 1], r[2][i + 1]...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER BIN_OP VAR VAR NUMBER NUMBER NUMBER NUMB...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
a = input() z = list(map(int, input().split())) count = 0 if z[0] == 0: count = 1 for i in range(1, len(z)): if z[i] == 0: count = count + 1 elif z[i] == 3: if z[i - 1] == 1: z[i] = 2 elif z[i - 1] == 2: z[i] = 1 elif z[i] == z[i - 1] and z[i] != 3: ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER IF VA...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) a = list(map(int, input().split())) b = c = d = 0 for i in a: e, f, g = b, c, d d = min(e, f, g) + 1 if i == 0: c = 10**5 b = 10**5 if i == 1: c = 10**5 b = min(f, g) if i == 2: b = 10**5 c = min(e, g) if i == 3: b = min(f,...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER FOR VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER IF VAR NUMBER AS...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
def solve(n, xs): dp = [[None for _ in range(3)] for _ in range(n)] for i, x in enumerate(xs): if i == 0: if x == 0: dp[0][0] = 1 dp[0][1] = float("inf") dp[0][2] = float("inf") if x == 1: dp[0][0] = 1 ...
FUNC_DEF ASSIGN VAR NONE VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FUNC_CALL VAR STRING ASSIGN VAR NUMBER NUMBER FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NU...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
import sys n = int(sys.stdin.readline()) array = [int(i) for i in sys.stdin.readline().split()] last = 0 rest = 0 for i in array: if i == 0: rest += 1 last = i elif i == 1: if last == 1: rest += 1 last = 0 elif last == 2 or last == 0 or last == 3: ...
IMPORT 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 FOR VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER IF VAR ...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) days = [int(x) for x in input().split()] res = 0 i = 1 currentActivity = days[0] if currentActivity == 0: res += 1 while i < n: if days[i] == 0: res += 1 currentActivity = 0 elif days[i] == 1 or days[i] == 2: if days[i] == currentActivity: res += 1 ...
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 VAR NUMBER IF VAR NUMBER VAR NUMBER WHILE VAR VAR IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR NUMBER VAR VAR NUMBER IF VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASS...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) a = [int(i) for i in input().split()] dp = [{"r": float("inf"), "g": float("inf"), "c": float("inf")} for _ in range(n)] dp[0]["r"] = 1 if a[0] == 1 or a[0] == 3: dp[0]["c"] = 0 if a[0] == 2 or a[0] == 3: dp[0]["g"] = 0 for i in range(1, n): dp[i]["r"] = 1 + min(dp[i - 1]["r"], dp[i - 1]["g...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT STRING STRING STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER STRING NUMBER IF VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN VAR NUMBER STRING NUMBER...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
x = int(input()) y = list(map(int, input().split())) if y[0] == 0: list = [[0, 0, 0]] elif y[0] == 1: list = [[0, 1, 0]] elif y[0] == 2: list = [[0, 0, 1]] elif y[0] == 3: list = [[0, 1, 1]] for i in range(1, x): if y[i] == 0: list.append( [ max(list[i - 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 NUMBER NUMBER ASSIGN VAR LIST LIST NUMBER NUMBER NUMBER IF VAR NUMBER NUMBER ASSIGN VAR LIST LIST NUMBER NUMBER NUMBER IF VAR NUMBER NUMBER ASSIGN VAR LIST LIST NUMBER NUMBER NUMBER IF VAR NUMBER NUMBER ASSI...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
q = int(input()) w = list(map(int, input().split())) e = 0 if w[0] == 0: e += 1 for i in range(1, q): if w[i] == 0: e += 1 if w[i - 1] == 1 and w[i] == 3: w[i] = 2 elif w[i - 1] == 2 and w[i] == 3: w[i] = 1 elif w[i - 1] == 1 and w[i] == 1 or w[i - 1] == 2 and w[i] == 2: ...
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 IF VAR NUMBER NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER NUMBER V...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) l = list(map(int, input().split())) ans = 0 l.append(9) l.insert(0, 9) i = 1 while i < n: a = l[i] b = l[i + 1] if a == 0: ans = ans + 1 i = i + 1 elif a == 1 and b == 1 or a == 2 and b == 2: ans = ans + 1 l[i + 1] = 9 i = i + 2 elif a == 3: ...
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 EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) l = list(map(int, input().split())) for i in range(1, n): if l[i] == 0: l[i] = 0 elif l[i - 1] == 0: pass elif l[i] == 1 and (l[i - 1] == 31 or l[i - 1] == 1): l[i] = 0 elif l[i] == 2 and (l[i - 1] == 32 or l[i - 1] == 2): l[i] = 0 elif l[i] == 3 and ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR ...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) a = input().split(" ") a = [int(a[i]) for i in range(len(a))] b = [(0) for i in range(n)] c = 0 g = 0 gc = 0 f = 0 for i in range(n): if a[i] == 0: g = 0 c = 0 b[i] = "f" elif a[i] == 1: g = 0 if i > 0 and b[i - 1] == "c": b[i] = "f" ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR NUM...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
def qtd_dias_descanso(dias): qtd_dias = 0 ontem = 0 for dia in dias: if dia == ontem or dia == 0: qtd_dias += 1 ontem = 0 elif dia == 1 or dia == 2: ontem = dia elif dia == 3 and ontem > 0: ontem = 3 - ontem return qtd_dias n = in...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_C...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) days = list(map(int, input().split())) dp = [[999, 999, 999] for x in range(100)] dp[0][0] = 1 if days[0] == 1: dp[0][1] = 0 elif days[0] == 2: dp[0][2] = 0 elif days[0] == 3: dp[0][1] = 0 dp[0][2] = 0 for i in range(1, n): dp[i][0] = 1 + min(dp[i - 1][0], dp[i - 1][1], dp[i - 1][2]...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER IF VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER IF VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER IF VAR NUMBER ...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) l = list(map(int, input().split())) p = 0 k = 0 for i in range(n): c = 1 if l[i] == 1 and p == 1: k = k + 1 p = 0 c = 0 if l[i] == 2 and p == 2: k = k + 1 p = 0 c = 0 if l[i] == 3 and p == 1: p = 2 c = 0 elif l[i] == 3 ...
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 NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR ...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
N = int(input()) A = list(map(int, input().split())) bef = 0 ans = 0 for a in A: if bef == 0: if a == 0: pass elif a == 1: ans += 1 bef = 1 elif a == 2: ans += 1 bef = 2 elif a == 3: ans += 1 bef = 3 ...
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 NUMBER FOR VAR VAR IF VAR NUMBER IF VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR NU...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
x = int(input()) m = list(map(int, input().split())) a = [([-1791791791] * 4) for i in range(x)] a[0][0] = 0 if m[0] & 1: a[0][1] = 1 if m[0] & 2: a[0][2] = 1 for i in range(1, x): a[i][0] = max(a[i - 1]) for j in range(1, 3): if m[i] & j: a[i][j] = max(a[i - 1][:j] + a[i - 1][j + 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 BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
import sys input = sys.stdin.readline n = int(input()) a = list(map(int, input().split())) dp = [[(0) for i in range(3)] for j in range(n)] dp[0][0] = 0 if a[0] == 1 or a[0] == 3: dp[0][1] = 1 if a[0] == 2 or a[0] == 3: dp[0][2] = 1 for i in range(1, n): dp[i][0] = max(dp[i - 1]) if a[i] == 1 or a[i] =...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER NUMBER IF VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER IF VAR NUMBER NUMBER VAR...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
input() A = map(int, input().split(" ")) tfo = 0 r = 0 for a in A: if a == 3: tfo = -tfo % 3 elif a == 0: r += 1 tfo = 0 elif tfo == a: r += 1 tfo = 0 else: tfo = a print(r)
EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
N = int(input()) days = list(map(int, input().split())) dp = [] prev = [[0, 1, 2], [0, 2], [0, 1]] for i in range(N): d = days[i] row = [] for j in range(3): if j == 1: if d != 1 and d != 3: row.append("x") continue if j == 2: if d != 2...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST LIST NUMBER NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER IF VAR NUMBER IF VAR NUMBER ...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) info = list(map(int, input().split())) matrix = [[(False) for i in range(len(info))] for j in range(3)] def minRestDays(today, yActivity): if today == len(info): answer = 0 elif info[today] == 0: answer = 1 + minRestDays(today + 1, 0) elif info[today] == 1: if yAct...
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 VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER FUNC_DEF IF VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER I...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) a = [int(x) for x in input().split()] l = 0 cnt = 0 a.append(0) for i in range(n): if a[i] == 0: l = 0 cnt += 1 continue if l == 0: if a[i] == 3: l = 0 else: l = a[i] elif a[i] == 3: if l == 1: l = 2 ...
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 EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER IF VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR IF VAR VAR NUMBER IF...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
y = int(input()) al = input().split() m = list(map(int, al)) l = 0 z = 0 m.append(0) for i in range(y): if m[i] == 0: z += 1 l = 0 continue if l == 0: if m[i] == m[i + 1] and (m[i] == 1 or m[i] == 2): m[i + 1] = 0 continue elif m[i] == 3 and m[i] =...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER VA...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
def solve(n, a): dp = [[0, 0]] for i in range(n): if a[i] == 0: dp.append([min(*dp[i]) + 1] * 2) elif a[i] == 1: dp.append([dp[i][1], min(*dp[i]) + 1]) elif a[i] == 2: dp.append([min(*dp[i]) + 1, dp[i][0]]) elif a[i] == 3: dp.append...
FUNC_DEF ASSIGN VAR LIST LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP LIST BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER IF VAR VAR NUMBER EXPR FUNC_CALL VAR LIST VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR NUMBER EXPR FUNC_CALL VAR LIST BIN_OP FUNC_CALL VAR VA...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) l = list(map(int, input().split())) gym = -1 contest = -1 rest = 0 if l[0] == 0: rest += 1 elif l[0] == 1: contest = 0 elif l[0] == 2: gym = 0 elif n > 1: if l[1] == 2: contest = 0 elif l[1] == 1: gym = 0 else: contest = 0 for i in range(1, n): if l[i...
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 NUMBER ASSIGN VAR NUMBER IF VAR NUMBER NUMBER VAR NUMBER IF VAR NUMBER NUMBER ASSIGN VAR NUMBER IF VAR NUMBER NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF VAR NUMBER NUMBER ASSIGN VAR NUMB...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) days = list(map(int, input().split())) res, prev = 0, 3 for d in days: if prev != 3: if d == prev: d = 0 elif d == 3: d -= prev if d == 0: res += 1 prev = d print(res)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR IF VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
def find_rest_days(n, days): dp = [([None] * 3) for _ in range(n)] dp[0][0] = 1, 0 dp[0][1] = (0, 1) if 1 & days[0] else (1, 0) dp[0][2] = (0, 2) if 2 & days[0] else (1, 0) for i in range(1, n): prev_best = sorted(dp[i - 1], key=lambda x: x[0]) dp[i][0] = prev_best[0][0] + 1, 0 ...
FUNC_DEF ASSIGN VAR BIN_OP LIST NONE NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER BIN_OP NUMBER VAR NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER BIN_OP NUMBER VAR NUMBER NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR V...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) s = input() A = [] Sum = 0 F = 0 for i in s.split(): A.append(int(i)) for j in range(0, n): if A[j] == 0: Sum = Sum + 1 F = 0 elif A[j] == 1: if F == 0: F = 1 elif F == 1: Sum = Sum + 1 F = 0 elif F == 2: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMB...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
def value(action): return 1 if action == "C" or action == "G" else 0 def dp(day, action): if solutions[day, action] != None: return solutions[day, action] choices = possible[day] if action not in choices: return float("-inf") elif day == 0: return value(action) else: ...
FUNC_DEF RETURN VAR STRING VAR STRING NUMBER NUMBER FUNC_DEF IF VAR VAR VAR NONE RETURN VAR VAR VAR ASSIGN VAR VAR VAR IF VAR VAR RETURN FUNC_CALL VAR STRING IF VAR NUMBER RETURN FUNC_CALL VAR VAR IF VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR STRING STRING STRING ASSIGN VAR FUNC_CALL VAR BIN_OP VAR N...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
def read_line(): return input().strip() def read_int(): return int(read_line()) def read_int_array(): return [int(i) for i in read_line().split(" ")] def read_string_array(): return [i for i in read_line().split(" ")] T = read_int() D = read_int_array() AD = [-1] * len(D) AD[0] = D[0] rests = 1 ...
FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF RETURN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUM...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) memo = [[0, 0, 0] for _ in range(n)] row1 = [] row2 = [] for c in map(int, input().split()): if c == 0: row1.append(0) row2.append(0) elif c == 1: row1.append(0) row2.append(1) elif c == 2: row1.append(1) row2.append(0) elif c == 3: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR N...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
def rest_day(arr): mem = [[float("INF") for i in range(3)] for j in range(len(arr))] mem[0][0] = 1 if arr[0] == 1 or arr[0] == 3: mem[0][1] = 0 if arr[0] == 2 or arr[0] == 3: mem[0][2] = 0 for i in range(1, len(arr)): mem[i][0] = 1 + min(mem[i - 1][0], mem[i - 1][1], mem[i - ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER NUMBER IF VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER IF VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR V...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) a = [int(x) for x in input().split()] cur = 0 ans = 0 for i in a: if i == 0: cur = 0 ans += 1 elif i == 1: if cur == 0 or cur == 1: cur = 2 else: cur = 0 ans += 1 elif i == 2: if cur == 0 or cur == 2: cu...
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 FOR VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER IF VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER IF VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN V...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
def solution(x, a, b): n = len(a) dp = [([0] * 3) for i in range(n)] dp[0][0] = 1 dp[0][1] = 0 dp[0][2] = 0 if a[0] == 0: dp[0][1] = -1 if b[0] == 0: dp[0][2] = -1 for i in range(1, n): dp[i][0] = dp[i - 1][0] + 1 dp[i][1] = dp[i - 1][0] dp[i][2] =...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER IF VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER IF VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) a = list(map(int, input().split())) r = 0 last = 0 for i in a: if last == 0: if i == 3: last = 0 elif i == 0: r += 1 else: last = i elif last == i == 1 or last == i == 2: r += 1 last = 0 elif last == 1 or last == 2:...
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 NUMBER FOR VAR VAR IF VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR IF VAR VAR NUMBER VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR ...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) a = list(map(int, input().split())) dp = [([0] * 3) for _ in range(n)] if a[0] == 1 or a[0] == 3: dp[0][1] = 1 if a[0] == 2 or a[0] == 3: dp[0][2] = 1 for i in range(1, n): t = max(dp[i - 1]) contest = max(dp[i - 1][0], dp[i - 1][2]) gym = max(dp[i - 1][0], dp[i - 1][1]) if a[i]...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR VAR IF VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER IF VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) days = [int(x) for x in input().split(" ")] total_rest = 1 if days[0] == 0 else 0 for i in range(1, len(days)): if days[i] == 0: total_rest += 1 elif days[i - 1] == days[i] and days[i] != 3: total_rest += 1 days[i] = 0 elif days[i] == 3: if days[i - 1] == 1: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR NUMBER...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) arr = list(map(int, input().split())) dp = [[0, 0, 0] for _ in range(len(arr) + 1)] for i, v in enumerate(arr): dp[i + 1][0] = max(dp[i]) if v == 1 or v == 3: dp[i + 1][1] = max(dp[i][0] + 1, dp[i][2] + 1) else: dp[i + 1][1] = dp[i][1] if v == 2 or v == 3: dp[i +...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
import sys input = sys.stdin.readline def inp(): return int(input()) def insr(): s = input() return list(s[: len(s) - 1]) def invr(): return map(int, input().split()) n = inp() s = list(invr()) d = [[(0) for _ in range(3)] for _ in range(n)] d[0][0] = 0 if s[0] == 1 or s[0] == 3: d[0][1] = ...
IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR RETURN FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBE...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) l_n = list(map(int, input().split())) p = l_n[0] t = 1 if p == 0 else 0 for i in range(1, n): if l_n[i] == p and p != 3: l_n[i] = 0 elif l_n[i] == 3 and p != 3: l_n[i] -= p if l_n[i] == 0: t += 1 p = l_n[i] print(t)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR NUMBER VAR NUMBER VAR VAR VAR IF VAR VAR NUMBER VAR NUMBER ASSIG...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
import sys n = int(sys.stdin.readline()) A = list(map(int, sys.stdin.readline().split())) prev, ans = 0, 0 for i in range(n): if A[i] == 0: ans += 1 prev = 0 elif A[i] == 1 or A[i] == 2: if prev == A[i]: ans += 1 prev = 0 else: prev = A[i] ...
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 VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR NUMBER VAR VAR NUMBER IF VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR IF VAR NU...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
def rev(a): if a == 1: return 2 return 1 def solve(n, s): prev = 0 for i in range(n): if s[i] == 3 and prev == 0: k = 0 for j in range(i, n): k = j - 1 if s[j] != 3: break for j in range(k, i - 1, -...
FUNC_DEF IF VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR BIN_OP V...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
def Vacation(n, arr): rest = 0 gym = False con = False for i in range(n): if arr[i] == 0: rest += 1 con = False gym = False elif arr[i] == 1: if not con: con = True gym = False else: ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR NUMBER IF VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR NUMBER IF VAR ASSIGN VAR NUMBER ASSIGN VAR NUMB...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) s = list(map(int, input().split())) days = [] relax = 0 for i in range(len(s)): if s[i] == 0: relax += 1 days.append(0) elif len(days) == 0: days.append(s[i]) elif s[i] == 2 and days[i - 1] == 2: days.append(0) relax += 1 elif s[i] == 1 and days[i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR VAR NUMBER VAR BIN_OP V...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
vac = int(input()) days = [int(i) for i in str(input()).split(" ")] ans = [[(0) for i in range(3)] for _ in range(102)] for index in range(len(days) + 1): if index == 0: continue elif days[index - 1] == 0: ans[index][0] = min(ans[index - 1]) + 1 ans[index][1] = ans[index - 1][1] + 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR NUMBER IF VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER BIN_OP FUNC_C...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) ls = list(map(int, input().split())) ary = [[0, 0, 0] for j in range(n + 1)] for i in range(1, n + 1): ma = max(ary[i - 1]) ary[i][0] = ma ary[i][1] = max(ary[i - 1][0], ary[i - 1][2]) + (ls[i - 1] == 1 or ls[i - 1] == 3) ary[i][2] = max(ary[i - 1][0], ary[i - 1][1]) + (ls[i - 1] == 2 o...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER VAR ASSIGN VAR VAR NUMBER...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) arr = [] p = list(map(int, input().split())) for i in range(n): arr.append([10000, 10000, 10000, p[i]]) arr[0][0] = 1 if arr[0][3] == 1 or arr[0][3] == 3: arr[0][1] = 0 if arr[0][3] == 2 or arr[0][3] == 3: arr[0][2] = 0 for i in range(1, n): arr[i][0] = 1 + min(arr[i - 1][0], arr[i - 1]...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST NUMBER NUMBER NUMBER VAR VAR ASSIGN VAR NUMBER NUMBER NUMBER IF VAR NUMBER NUMBER NUMBER VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER IF...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
def val(a, action): res = 1000 if a == 3: res = 0 elif a == 1 and action == "C": res = 0 elif a == 2 and action == "G": res = 0 return res n = int(input()) a = list(map(int, input().split())) curr = {} prev = {"G": 0, "C": 0, "R": 0} for i in a: curr["G"] = min(prev["C"...
FUNC_DEF ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER VAR STRING ASSIGN VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT STRING STRING STRING NUMBE...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
def answer3(n, a): INF = 10**10 dp = [1, INF, INF] if a[0] == 0: dp[0] = 1 elif a[0] == 1: dp[1] = 0 elif a[0] == 2: dp[2] = 0 else: dp[1] = 0 dp[2] = 0 for day in range(1, n): new_dp = [INF, INF, INF] for i in range(3): for...
FUNC_DEF ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR LIST NUMBER VAR VAR IF VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER IF VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER IF VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR LIST VAR VAR VAR...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
input() p, c = 3, 0 for i in list(map(int, input().split())): if i == p and p != 3: i = 0 elif i == 3 and p != 3: i -= p if i == 0: c += 1 p = i print(c)
EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) a = list(map(int, input().split())) dp = [[(10**9) for j in range(3)] for i in range(n + 1)] dp[0][0] = 0 for i in range(n): for j in range(3): if dp[i][j] == 10**9: continue dp[i + 1][0] = min(dp[i + 1][0], dp[i][j] + 1) if j != 1 and (a[i] == 1 or a[i] == 3): ...
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 NUMBER NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR BIN_OP NUMBER NUMBE...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) arr = list(map(int, input().split())) dp = [[0, 0, 0] for i in range(n)] inf = 1000000000000000 if arr[0] == 0: dp[0] = [1, inf, inf] elif arr[0] == 1: dp[0] = [1, inf, 0] elif arr[0] == 2: dp[0] = [1, 0, inf] elif arr[0] == 3: dp[0] = [1, 0, 0] for a in range(1, n): if arr[a] == 0:...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER NUMBER ASSIGN VAR NUMBER LIST NUMBER VAR VAR IF VAR NUMBER NUMBER ASSIGN VAR NUMBER LIST NUMBER VAR NUMBER IF VAR NUMBER NU...
Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: 1. on this day the gym is closed and...
n = int(input()) a = [int(i) for i in input().split()] dp = [[(0) for i in range(n)] for j in range(2)] if a[0] == 0: dp[0][0] += 1 dp[1][0] += 1 elif a[0] == 1: dp[1][0] += 1 elif a[0] == 2: dp[0][0] += 1 for i in range(1, n): m = min(dp[0][i - 1], dp[1][i - 1]) if a[i] == 0: dp[0][i] =...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER IF VAR NUMBER NUMBER VAR NUMBER NUMBER NUMBER VAR NUMBER NUMBER NUMBER IF VAR NUMBER NUMBER VAR NUMBER NUMBER NUMBER IF VAR NUMBER NUMBER VAR NUMBER NUMBER NUM...