description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
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()))
ans = f = 0
if a[0] != 0:
ans += 1
if a[0] == 1:
f = 1
if a[0] == 2:
f = 2
for x in range(1, n):
prev = ans
if a[x] == 1 and f != 1:
ans += 1
f = 1
elif a[x] == 1 and f == 1:
f = 0
if a[x] == 2 and 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 NUMBER IF VAR NUMBER NUMBER VAR NUMBER IF VAR NUMBER NUMBER ASSIGN VAR NUMBER IF VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR IF VAR VAR NUMBER VAR NUMBER 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())
a = input()
A = list(map(int, list(a.split())))
dp = [[(0) for i in range(4)] for j in range(n + 1)]
for i in range(1, n + 1):
if A[i - 1] == 1:
dp[i][0] = max(dp[i - 1][0], dp[i - 1][1], dp[i - 1][2])
dp[i][1] = max(dp[i - 1][0] + 1, dp[i - 1][2] + 1)
elif A[i - 1] == 2:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER 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())
s = list(map(int, input().split()))
d = [[(0) for i in range(n + 1)] for j in range(3)]
for i in range(1, n + 1):
d[0][i] = max(d[0][i - 1], d[1][i - 1], d[2][i - 1])
if s[i - 1] == 1 or s[i - 1] == 3:
d[1][i] = max(d[2][i - 1] + 1, d[0][i - 1] + 1)
if s[i - 1] == 2 or s[i - 1] == 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 VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER 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())
temparr = input()
temparr = temparr.split()
arr = []
for i in temparr:
arr.append(int(i))
ans = []
for j, i in enumerate(arr):
if i == 0:
ans.append(4)
continue
if j == 0 and i != 0:
ans.append(i)
continue
if i == 3 and ans[-1] == 4:
ans.append(3)... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER 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())
a = list(map(int, input().split()))
ans = 0
for i in range(len(a)):
if a[i] == 0:
ans += 1
elif i != 0 and a[i] == a[i - 1] and a[i] != 3:
ans += 1
a[i] = 0
elif a[i] == 3:
a[i] -= a[i - 1]
print(ans) | 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 VAR VAR NUMBER VAR NUMBER IF VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR NUMBER 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... | inf = 10000000000.0
mem = [([-1] * 5) for _ in range(110)]
def solve(i, u):
if mem[i][u] != -1:
return mem[i][u]
if i == n:
return 0
g = h = inf
if a[i] == 0:
g = 1 + solve(i + 1, 0)
elif a[i] == 1:
if u == 1:
g = 1 + solve(i + 1, 0)
else:
... | ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR NUMBER FUNC_DEF IF VAR VAR VAR NUMBER RETURN VAR VAR VAR IF VAR VAR RETURN NUMBER ASSIGN VAR VAR VAR IF VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP NUMBER 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... | n = int(input())
L = list(map(int, input().split()))
def pasa(x, y):
return x == 1 and y == 2 or x == 2 and y == 1
if n == 1:
print(L.count(0))
else:
cont = 0
for k in range(1, n):
if L[k] != 0:
if not pasa(L[k], L[k - 1]):
if L[k] == 3 and not L[k - 1] == 3:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR BI... |
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 = [(-1) for i in range(n)]
dp[0] = a[0]
for i in range(1, n):
if a[i] == 0:
dp[i] = 0
elif a[i] == dp[i - 1] and a[i] != 3:
dp[i] = 0
elif a[i] == 3 and dp[i - 1] != 3:
dp[i] = abs(3 - dp[i - 1])
else:
dp[i] = a[i]
p... | 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 VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER ASSIGN 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... | import sys
n = int(input())
s = list(map(int, input().split()))
dp = [[-(10**9), -(10**9), -(10**9)] for i in range(n)]
if s[0] == 3:
dp[0][1] = 1
dp[0][2] = 1
dp[0][0] = 0
if s[0] == 2:
dp[0][1] = 1
dp[0][0] = 0
if s[0] == 1:
dp[0][2] = 1
dp[0][0] = 0
if s[0] == 0:
dp[0][0] = 0
for i 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 LIST BIN_OP NUMBER NUMBER BIN_OP NUMBER NUMBER BIN_OP NUMBER NUMBER VAR FUNC_CALL VAR VAR IF VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN 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... | n = int(input())
d = list(map(int, input().split()))
dp1 = [(0) for _ in range(n)]
dp2 = [(0) for _ in range(n)]
dp1[0] = 0 if d[0] & 1 else 1
dp2[0] = 0 if d[0] & 2 else 1
for i in range(1, n):
if d[i] == 3:
dp1[i] = dp2[i - 1]
dp2[i] = dp1[i - 1]
elif d[i] == 2:
dp1[i] = min(dp1[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 VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER BIN_OP VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL 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()))
c = 0
s = 0
b = 0
for i in range(n):
if a[i] == 0:
s, c = 0, 0
if a[i] == 1:
if c == 0:
c = 1
s = 0
b += 1
else:
c = 0
s = 0
if a[i] == 2:
if s == 0:
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 NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER IF VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN 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())
act = list(map(int, input().split()))
p = [[(0) for i in range(3)] for _ in range(n)]
p[0][0] = 0
p[0][1] = int(act[0] >= 2)
p[0][2] = int(act[0] % 2)
for i in range(1, n):
p[i][0] = max(p[i - 1])
if act[i] >= 2:
p[i][1] = max(p[i - 1][0] + 1, p[i - 1][2] + 1)
if act[i] % 2 == 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 VAR ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FUNC_CALL VAR BIN_OP 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... | def sport(v):
return v >= 2
def contest(v):
return v in [1, 3]
LAST_CONTEST = 0
LAST_SPORT = 1
n = int(input())
a = list(map(int, input().split()))
prev = [0, 0]
dp = [0, 0]
for i in range(n):
v = a[i]
curr = [dp[0], dp[1]]
if sport(v):
curr[LAST_SPORT] = max(
dp[LAST_SPORT],... | FUNC_DEF RETURN VAR NUMBER FUNC_DEF RETURN VAR LIST NUMBER 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 ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR 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... | T = int(input())
entrada = map(int, input().strip().split(" "))
global lst
lst = []
global descanso
descanso = 0
for i in entrada:
lst += [i]
def func(x, y):
global lst
global descanso
x += 1
while x < y:
anterior = lst[x - 1]
actual = lst[x]
if actual != 0 and actual != 3:... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR VAR LIST VAR FUNC_DEF VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR IF VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR VAR NUMBER 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()))
for i in range(1, n):
if s[i] == 3 and s[i - 1] == 1:
s[i] = 2
elif s[i] == 3 and s[i - 1] == 2:
s[i] = 1
elif s[i] == 2 and s[i - 1] == 2 or s[i] == 1 and s[i - 1] == 1:
s[i] = 0
print(s.count(0)) | 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 VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR NUMBER VAR BIN_OP 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... | n = int(input())
dp = [[500, 500, 500] for i in range(n + 1)]
dp[0][0] = 0
for i, x in enumerate(map(int, input().split()), 1):
dp[i][0] = min(dp[i - 1]) + 1
if x in (1, 3):
dp[i][1] = min(dp[i - 1][::2])
if x in (2, 3):
dp[i][2] = min(dp[i - 1][:2])
print(min(dp[n])) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER IF VAR NUMBER 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())
data = list(map(int, input().split()))
prev_day = 0
rel = 0
for day in data:
if day == 0:
rel += 1
prev_day = 0
elif day != 3:
if prev_day == day:
rel += 1
prev_day = 0
else:
prev_day = day
elif prev_day == 0 or prev_day ==... | 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 VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF 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... | REST = 0
CONTEST = 1
GYM = 2
UNDECIDED = 3
def solve(n, days):
action_prev = None
i = 0
min_rest = 0
while i < len(days):
e = days[i]
if e == 0:
min_rest += 1
action_prev = REST
elif e == 1:
if action_prev == CONTEST:
min_rest... | ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NONE ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR IF VAR NUMBER IF VAR VAR 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())
n += 1
a = [int(i) for i in input().split()]
a.append(0)
r = [[None for j in range(3)] for i in range(n)]
r[0][0] = 0
def howMany(ind, pos):
if r[ind][pos] == None:
return
if r[ind + 1][0] == None or r[ind + 1][0] < r[ind][pos]:
r[ind + 1][0] = r[ind][pos]
if (
a[i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NONE VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER NUMBER FUNC_DEF IF VAR VAR VAR NONE RETURN IF VAR BIN_OP VAR NUMBER NUMBER NONE VAR BIN_OP 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())
a = [int(v) for v in input().split()]
p = 0
c = 0
for v in a:
if v == 3 and p != 0:
if p == 1:
p = 2
else:
p = 1
elif v == 3 and p == 0:
continue
elif v == 0:
c = c + 1
p = 0
elif p == v:
c = c + 1
p = 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 FOR VAR VAR IF VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR 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())
(*a,) = map(int, input().split())
if a[0] != 3:
dp = [a[0]] + [0] * (n - 1)
else:
dp = [-1] + [0] * (n - 1)
for i in range(1, n):
if a[i] == 0:
dp[i] = a[i]
elif a[i] == 1:
if dp[i - 1] != 1:
dp[i] = 1
elif a[i] == 2:
if dp[i - 1] != 2:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST VAR NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER ASSIGN 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... | n = int(input())
a = list(map(int, input().split(" ")))
dp = [([0] * 3) for _ in range(n + 1)]
for i in range(1, n + 1):
dp[i][0] = max(dp[i - 1][0], dp[i - 1][1], dp[i - 1][2])
if a[i - 1] == 1 or a[i - 1] == 3:
dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + 1
if a[i - 1] == 2 or a[i - 1] == 3:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP 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())
sp = list(map(int, input().split()))
dp = [[0, 0, 0] for i in range(n + 1)]
maxc = 0
for i in range(1, n + 1):
dp[i][0] = max(dp[i - 1])
dp[i][1] = dp[i - 1][1]
dp[i][2] = dp[i - 1][2]
if sp[i - 1] % 2 == 1:
dp[i][1] = max(dp[i - 1][0] + 1, dp[i - 1][2] + 1, dp[i][1])
if sp[... | 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 ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR 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())
data = [-1] + [int(x) for x in input().split()]
assert len(data) == n + 1
dp = [[-1, -1, -1] for _ in range(n + 1)]
dp[0][2] = 0
for i, a in enumerate(data):
if i == 0:
continue
for c in (0, 1):
if 1 << c & a == 0:
dp[i][c] = -1
else:
dp[i][c] = m... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER FOR 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... | from sys import stdin
stdin.readline
def mp():
return list(map(int, stdin.readline().strip().split()))
def it():
return int(stdin.readline().strip())
n = it()
l = mp()
prev = 0
ans = 0
for i in range(n):
if l[i] == 0 or l[i] == prev:
ans += 1
prev = 0
elif l[i] == 2:
prev ... | EXPR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR VAR VAR NUMBER ASSIGN 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... | from sys import stdin, stdout
def main():
n = int(stdin.readline())
a = [0] + list(map(int, stdin.readline().split()))
r = [0] * 110
c = [0] * 110
g = [0] * 110
for i in range(1, n + 1):
r[i] = min(c[i - 1], g[i - 1], r[i - 1]) + 1
if a[i] == 0:
c[i] = 111
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR 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())
a = map(int, input().split())
a = list(a)
dp = [([n] * 3) for _ in range(n + 4)]
dp[0] = [0, 0, 0]
for ii in range(n):
aa = a[ii]
prev = dp[ii]
now = dp[ii + 1]
now[0] = 1 + min(prev)
if aa & 1:
now[1] = min(prev[0], prev[2])
if aa & 2:
now[2] = min(prev[0], prev... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER LIST NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN 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... | inf = 2**33
def solve(dp, activities, i, end, done):
if i == end:
return 0
if dp[i][done] == -1:
best = solve(dp, activities, i + 1, end, 0) + 1
if (activities[i] == 1 or activities[i] == 3) and done != 2:
best = min(best, solve(dp, activities, i + 1, end, 2))
if (a... | ASSIGN VAR BIN_OP NUMBER NUMBER FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER NUMBER IF VAR VAR NUMBER VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR NUMBER 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... | b = [0] * 303
a = int(input())
a = list(map(int, input().split()))
count = 0
for i in a:
if i == 0:
c = min(b[count - 1], b[count - 2], b[count - 3])
b[count] = c + 1
b[count + 1] = c + 1
b[count + 2] = c + 1
elif i == 1:
c = min(b[count - 1], b[count - 2], b[count - 3])
... | ASSIGN VAR BIN_OP LIST NUMBER 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 FOR VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP 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())
a = list(map(int, input().split()))
oo = n + 10
d = [[oo, oo, oo] for i in range(n + 1)]
d[0][0] = d[0][1] = d[0][2] = 0
for i in range(n):
d[i + 1][0] = min(d[i][0], d[i][1], d[i][2]) + 1
if a[i] == 1 or a[i] == 3:
d[i + 1][1] = min(d[i][0], d[i][2])
if a[i] == 2 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 VAR NUMBER ASSIGN VAR LIST VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP 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... | MAX = 100
n = int(input())
num = list()
for i in range(n + 1):
num.append([0, 0, 0])
line = str(input()).split()
for i in range(n):
if line[i] == "0":
num[i + 1][0] = 1 + min(num[i])
num[i + 1][1] = MAX
num[i + 1][2] = MAX
elif line[i] == "1":
num[i + 1][0] = 1 + min(num[i])
... | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR LIST NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER NUMBER BIN_OP NUMBER FUNC_CALL ... |
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(" ")
days = [int(x) for x in days]
ans = 0
state = None
for x in days:
if x == 3:
if state == None:
continue
else:
state = 3 - state
elif x == 2:
if state == 2:
ans += 1
state = None
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NONE FOR VAR VAR IF VAR NUMBER IF VAR NONE ASSIGN VAR BIN_OP NUMBER VAR IF VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NONE ASSIGN 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... | input()
INF = 1 << 9
S = 0, 0, 0
for a in map(int, input().split()):
S = (
1 + min(S),
min(S[0], S[2]) if a >> 1 else INF,
min(S[0], S[1]) if 1 & a else INF,
)
print(min(S)) | EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR BIN_OP NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL... |
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()))
prev = 0
ans = 0
for i in range(n):
k = a[i]
if k == 0:
prev = 0
ans += 1
elif k == 1 or k == 2:
if prev == k:
ans += 1
prev = 0
else:
prev = k
elif prev == 1 or prev == 2:
pr... | 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 VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR IF 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())
arr = list(map(int, input().split()))
dp = {}
def recur(i, prev, rest):
if (i, prev, rest) in dp:
return dp[i, prev, rest]
if i >= n:
return rest
if arr[i] == 0:
dp[i, prev, rest] = recur(i + 1, 0, rest + 1)
elif arr[i] == 1:
if prev == 2:
d... | 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 VAR VAR RETURN VAR VAR VAR VAR IF VAR VAR RETURN VAR IF VAR VAR NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER IF VAR 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... | import sys
n = int(sys.stdin.readline())
inp = sys.stdin.readline()[:-1].split(" ")
inp = [int(x) for x in inp]
last = "start"
ans = 0
def whatToDO(day, lastReturn=0):
if day == 0:
lastReturn = 0
elif lastReturn == 0:
if day < 3:
lastReturn = day
else:
lastRetu... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR STRING ASSIGN VAR NUMBER FUNC_DEF NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER IF 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... | INF = 1000
n = int(input())
desc = map(int, input().split())
r = {}
g = {}
c = {}
r[0] = 0
g[0] = 0
c[0] = 0
i = 0
for x in desc:
i += 1
if x == 0:
g[i] = INF
c[i] = INF
r[i] = 1 + min([g[i - 1], r[i - 1], c[i - 1]])
elif x == 1:
g[i] = INF
c[i] = min(r[i - 1], g[i - ... | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR VAR ASSIGN 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... | import sys
input = sys.stdin.readline
def multi_input():
return map(int, input().split())
def array_print(arr):
print(" ".join(map(str, arr)))
def solve(n, tasks, day, condition):
if day >= n:
return 0
elif dp[condition][day] != -1:
return dp[condition][day]
if tasks[day] == 0... | IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR 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_OP NUMBER FUNC_CALL VAR VAR 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... | abc = lambda: map(int, input().split())
n = int(input())
lis = [[0, 0, 0] for i in range(n + 1)]
for i, x in enumerate(abc()):
lis[i][0] = min(lis[i - 1]) + 1
if x == 3:
lis[i][1] = min(lis[i - 1][0], lis[i - 1][2])
lis[i][2] = min(lis[i - 1][0], lis[i - 1][1])
elif x == 2:
lis[i][1]... | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER IF VAR NUMBER ASSIGN VAR VAR NUMBER 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... | n = int(input())
dias = list(map(int, input().strip().split(" ")))
cont = 0
largo = len(dias)
i = 1
while i < largo:
if dias[i] == 3:
if dias[i - 1] == 2:
dias[i] = 1
if dias[i - 1] == 1:
dias[i] = 2
if dias[i] == 1 or dias[i] == 2:
if dias[i] == dias[i - 1]:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER 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... | num = int(input())
days = list(map(int, input().split()))
rest = 0
flag = 0
for j in range(len(days)):
if days[j] == 0:
flag = 0
rest += 1
elif days[j] == 1:
if flag is not 1:
flag = 1
else:
rest += 1
flag = 0
elif days[j] == 2:
if ... | 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 FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER IF VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR 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... | day = int(input())
situations = input().split(" ")
dp = [[float("inf") for _ in range(3)] for _ in range(day + 1)]
for j in range(3):
dp[0][j] = 0
for i in range(1, day + 1):
dp[i][0] = 1 + min(dp[i - 1][0], dp[i - 1][1], dp[i - 1][2])
if situations[i - 1] != "0" and situations[i - 1] != "1":
dp[i][... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER BIN_OP NUMBER 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())
lst = [int(i) for i in input().split()]
result, previous = 0, 0
for elem in lst:
if elem == previous or elem == 0:
previous = 0
result += 1
elif elem == 1 or elem == 2:
previous = elem
elif previous > 0 and elem == 3:
previous = 3 - previous
print(result) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP NUMBER 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())
nums = input()
nums = [int(i) for i in nums.split()]
MAXVAL = 999
dp = [[MAXVAL for i in range(3)] for i in range(n)]
if nums[0] == 0:
dp[0][0] = 1
elif nums[0] == 1:
dp[0][1] = 0
elif nums[0] == 2:
dp[0][2] = 0
else:
dp[0][1] = 0
dp[0][2] = 0
for i in range(1, n):
if nums[i] ==... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR IF VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER IF VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER IF 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())
s = [0] + list(map(int, input().split()))
r = [(0) for i in range(n + 1)]
r[0] = 1
if s[1] == 0:
r[1] = 2
else:
r[1] = 1
for i in range(2, n + 1):
if s[i] == 0:
r[i] = r[i - 1] + 1
if s[i] == 3:
r[i] = r[i - 1]
if s[i] == 2:
if s[i - 1] == 2:
r[i]... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER IF VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP 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())
a = list(map(int, input().split()))
d = [0] * n
if a[0] == 0:
d[0] = 1
else:
d[0] = 0
for i in range(1, n):
if a[i] == 0:
d[i] = d[i - 1] + 1
elif a[i - 1] == 1 and a[i] == 1 or a[i - 1] == 2 and a[i] == 2:
d[i] = d[i - 1] + 1
a[i] = 0
elif 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 LIST NUMBER VAR IF VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER 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... | import sys
input = sys.stdin.readline
def inp():
return int(input())
def inlt():
return list(map(int, input().split()))
def helper(i, choice):
if i == n:
return 0
if (i, choice) in hash_map:
return hash_map[i, choice]
if arr[i] == 0:
c_0 = 1 + helper(i + 1, 0)
... | IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR VAR VAR RETURN VAR VAR VAR IF VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR RETURN 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 = [([0] * (n + 1)) for i in range(3)]
summer = list(map(int, input().split()))
for i, day_type in enumerate(summer):
if day_type == 0:
arr[0][i + 1] = max(arr[0][i], max(arr[1][i], arr[2][i]))
arr[1][i + 1] = max(arr[0][i], max(arr[1][i], arr[2][i]))
arr[2][i + 1] = max(... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER 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())
data = [int(x) for x in input().split()]
answers = [[(0) for _ in range(3)] for x in range(n + 1)]
answers[0] = [0, 0, 0]
for i in range(1, n + 1):
for j in range(3):
if j == 1 and (data[i - 1] == 1 or data[i - 1] == 3):
answers[i][j] = max(answers[i - 1][0], answers[i - 1][2]) ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER LIST NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR NUMBER 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... | input()
a1 = a2 = z = 0
for b in map(int, input()[::2]):
if 0 < b < 3:
if a1 == a2 == b:
a1 = a2 = 0
z += 1
else:
a1 = a2 = b
elif b:
a1 = 2 if a1 == 1 else 1
a2 = 1 if a2 == 2 else 2
else:
a1 = a2 = 0
z += 1
print(z) | EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER IF NUMBER VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR IF VAR ASSIGN VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER 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... | input()
days = input().split()
state = 0
out = 0
for d in days:
if state == 0:
if d == "0":
out += 1
elif d == "1":
state = 1
elif d == "2":
state = 2
elif d == "3":
state = 3
elif state == 1:
if d == "0":
out +=... | EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER IF VAR STRING VAR NUMBER IF VAR STRING ASSIGN VAR NUMBER IF VAR STRING ASSIGN VAR NUMBER IF VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER IF VAR STRING VAR NUMBER ASSIGN VAR NUMBER IF VAR STRING VAR NUMBER A... |
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())
inf = 10**9
list_of_activities = list(map(int, input().split()))
dp_list = [[(5) for x in range(3)] for y in range(n)]
for i in range(n):
if i == 0:
dp_list[i][0] = 1
dp_list[i][1] = (
0 if list_of_activities[0] == 1 or list_of_activities[0] == 3 else inf
)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER 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 FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER NUMBER 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().strip())
ll = list(map(int, input().split()))
d = [0] * (n + 1)
k = -1
ll.append(0)
for i in range(1, n + 1):
if ll[i - 1] != 0:
if k == -1:
d[i] = d[i - 1] + 1
if ll[i - 1] == 3:
if ll[i] == 1:
k = 2
elif ll[i] == 2... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER NUMBER IF VAR NUMBER ASSIGN VAR 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... | n = int(input())
a = [int(i) for i in input().split()]
if a[0] == 0:
d = [[0, 0, 0]]
elif a[0] == 1:
d = [[0, 1, 0]]
elif a[0] == 2:
d = [[0, 0, 1]]
else:
d = [[0, 1, 1]]
for i in range(1, n):
d.append([0, 0, 0])
d[i][0] = max(d[i - 1])
if a[i] == 1 or a[i] == 3:
d[i][1] = max(d[i - ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR 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 ASSIGN VAR LIST LIST 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... | import sys
n = int(input())
a = list(map(int, sys.stdin.readline().split()))
def getMin(l):
ans = 0
if len(l) == 1:
if l[0] == 0:
ans = 1
elif len(l) > 1:
last = l.pop()
if last == 0:
ans = 1 + getMin(l)
elif last == 1:
l[-1] -= l[-1] & ... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER IF VAR NUMBER NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR VAR 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... | d = int(input())
l = list(input().split())
rest = 0
last = "0"
for c in l:
if c == "0":
rest += 1
last = "0"
elif c == "1" and last != c:
last = "1"
elif c == "2" and last != c:
last = "2"
elif c == "3":
if last == "1":
last = "2"
elif last == ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR VAR IF VAR STRING VAR NUMBER ASSIGN VAR STRING IF VAR STRING VAR VAR ASSIGN VAR STRING IF VAR STRING VAR VAR ASSIGN VAR STRING IF VAR STRING IF VAR STRING ASSIGN VAR STRING IF VAR STRING A... |
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 = [[float("inf") for i in range(3)] for i in range(n + 1)]
dp[0][0] = 0
dp[0][1] = 0
dp[0][2] = 0
for i in range(1, n + 1):
if a[i - 1] == 1 or a[i - 1] == 3:
dp[i][1] = min(dp[i - 1][0], dp[i - 1][2])
if a[i - 1] == 2 or a[i - 1] == 3:
dp[... | 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 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 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... | entrada = input()
entrada = input()
entrada = entrada.split(" ")
aux = "0"
cont = 0
for i in entrada:
if i == "0":
cont += 1
aux = "0"
elif aux == "0" or aux == "3":
aux = i
elif aux == i:
cont += 1
aux = "0"
elif aux == "3":
if i == "2":
aux =... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER ASSIGN VAR STRING IF VAR STRING VAR STRING ASSIGN VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR STRING IF VAR STRING IF VAR STRING ASSIGN VAR STRING IF VAR STRING 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())
ai = list(map(int, input().split()))
for i in range(n):
if i < n - 1:
if ai[i] % 3 != 0 and ai[i] == ai[i + 1]:
ai[i + 1] = 0
elif ai[i + 1] == 3 and ai[i] % 3 != 0:
ai[i + 1] = 3 - ai[i]
ai[i] = int(ai[i] > 0)
print(n - sum(ai)) | 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 VAR IF VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR NUMBER NUMBER VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR 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()))
M = 1000
dp = [0, M, M]
for x in a:
dp = [min(dp) + 1, min(dp[0::2]) if x & 1 else M, min(dp[:2]) if x & 2 else M]
print(min(dp)) | 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 LIST NUMBER VAR VAR FOR VAR VAR ASSIGN VAR LIST BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR EXPR... |
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 = [int(x) for x in input().split()]
dp = [[(0) for _ in range(3)] for _ in range(len(l))]
for i in range(len(l)):
if i == 0:
if l[i] == 1:
dp[i][1] = 1
elif l[i] == 2:
dp[i][2] = 1
elif l[i] == 3:
dp[i][1] = 1
dp[i][2] = 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER IF VAR VAR NUMBER ASSIGN VAR 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())
days = list(map(int, input().split()))
p_last = 0
g_last = 0
has_p_last = False
has_g_last = False
for a in days:
has_p = a % 2 == 1
has_g = a > 1
if has_p:
if has_p_last:
p = g_last
else:
p = min(p_last, g_last)
else:
p = 1 + min(p_last, ... | 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 ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER IF VAR IF VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR 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().strip().split()))
rows, cols = n + 1, 3
dp = [[(0) for i in range(cols)] for j in range(rows)]
for i in range(0, n):
if a[i] == 0:
dp[i + 1][0] = min(dp[i][0], min(dp[i][1], dp[i][2])) + 1
dp[i + 1][1] = dp[i][1] + 1
dp[i + 1][2] = dp[i][2] + 1
... | 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 VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER BIN_OP FUNC_CAL... |
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())
string = input().split(" ")
result = []
result.append([0, 0, 0])
for i in range(n):
tmp = []
tmp.append(min(result[i]) + 1)
if string[i] == "0" or string[i] == "1":
tmp.append(2147483647)
else:
tmp.append(min([result[i][0], result[i][2]]))
if string[i] == "0" or stri... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST EXPR FUNC_CALL VAR LIST NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR STRING VAR VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUN... |
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 = int(input())
b = input().split()
flag = 0
sum = 0
for i in range(0, a):
if int(b[i]) == 0:
sum += 1
flag = 0
elif int(b[i]) == 1 or int(b[i]) == 2:
if int(b[i]) == flag:
sum = sum + 1
flag = 0
else:
flag = int(b[i])
elif int(b[i]) == 3:... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR VAR NUMBER FUNC_CALL VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP 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... | input()
B = 10000
s = [0, B, B]
for x in map(int, input().split()):
s = [min(s) + 1, min(s[0::2]) if x & 1 else B, min(s[:2]) if x & 2 else B]
print(min(s)) | EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER VAR VAR FOR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR EXPR FUNC_CALL VAR 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().strip())
act = input().strip().split(" ")
yes = "rest"
rest = 0
for i in range(len(act)):
if act[i] == "0":
rest += 1
yes = "rest"
elif act[i] == "1" and yes == "contest":
rest += 1
yes = "rest"
elif act[i] == "1" and yes != "contest":
yes = "contest"
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER ASSIGN VAR STRING IF VAR VAR STRING VAR STRING VAR NUMBER ASSIGN VAR STRING IF VAR VAR STRING VAR STRING 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())
inp = list(map(int, input().split()))
dp = []
for i in range(3):
dp.append([0] * (n + 1))
for i in range(1, n + 1):
j = inp[i - 1]
dp[0][i] = max(dp[0][i - 1], dp[1][i - 1], dp[2][i - 1])
if j == 1 or j == 3:
dp[1][i] = max(dp[0][i - 1], dp[2][i - 1]) + 1
if j == 2 or j == 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 LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL 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... | from sys import stdin, stdout
read = lambda: map(int, stdin.readline().split())
I = lambda: stdin.readline()
n = int(I())
arr = tuple(read())
memo = {}
poss = [[0], [0, 1], [0, 2], [0, 1, 2]]
dp = [[(10**6) for i in range(3)] for i in range(n + 1)]
dp[n] = [0, 0, 0]
for i in range(n - 1, -1, -1):
for last in range... | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR LIST LIST NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER VAR FUNC_CALL 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... | mod = 1000000007
ii = lambda: int(input())
si = lambda: input()
dgl = lambda: list(map(int, input()))
f = lambda: map(int, input().split())
il = lambda: list(map(int, input().split()))
ls = lambda: list(input())
n = ii()
l = il()
dpc = [0] * (n + 1)
dpg = [0] * (n + 1)
for i in range(1, n + 1):
if l[i - 1] == 0:
... | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL 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()))
rest = 0
last = ""
for i in l:
if i == 0 or i == 1 and last == "contest" or i == 2 and last == "gym":
rest += 1
last = ""
elif i == 1 and last != "contest":
last = "contest"
continue
elif i == 2 and last != "gym":
l... | 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 STRING FOR VAR VAR IF VAR NUMBER VAR NUMBER VAR STRING VAR NUMBER VAR STRING VAR NUMBER ASSIGN VAR STRING IF VAR NUMBER VAR STRING ASSIGN VAR STRING IF VAR NUMBER VAR STRING 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())
num = [int(i) for i in input().split()]
dp = [[(0) for i in range(3)] for j in range(102)]
for i in range(1, n + 1):
if num[i - 1] == 0:
dp[i][0] = min(dp[i - 1]) + 1
dp[i][1] = float("inf")
dp[i][2] = float("inf")
if num[i - 1] == 1:
dp[i][2] = float("inf")
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER 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... | days = int(input())
lst = list(map(int, input().split()))
rest, gym, cont = [0], [0], [0]
if lst[0] in (1, 3):
cont = [1]
if lst[0] in (2, 3):
gym = [1]
for i in range(1, days):
rest.append(max(rest[-1], gym[-1], cont[-1]))
if lst[i] == 3:
cont.append(max(rest[-2], gym[-1]) + 1)
gym.appe... | 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 LIST NUMBER LIST NUMBER LIST NUMBER IF VAR NUMBER NUMBER NUMBER ASSIGN VAR LIST NUMBER IF VAR NUMBER NUMBER NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL 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... | def dp(prev, ind):
global dar, n, con, gym
if ind >= n:
return 0
if (prev, ind) not in dar:
m = dp("free", ind + 1) + 1
if prev != "con" and con[ind]:
m = min(m, dp("con", ind + 1))
if prev != "gym" and gym[ind]:
m = min(m, dp("gym", ind + 1))
... | FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR STRING BIN_OP VAR NUMBER NUMBER IF VAR STRING VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR STRING BIN_OP VAR NUMBER IF VAR STRING VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR STRING BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR RETU... |
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())
V = [int(i) for i in input().split()]
ans = 0
dp = [0] * n
if V[0] == 0:
ans += 1
elif V[0] == 3 and n > 1:
dp[0] = 3 - V[1]
else:
dp[0] = V[0]
for i in range(1, n):
if V[i] == 0:
ans += 1
elif dp[i - 1] == V[i] and V[i] != 3:
dp[i] = 0
ans += 1
elif V[i]... | 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 BIN_OP LIST NUMBER VAR IF VAR NUMBER NUMBER VAR NUMBER IF VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR NUMBER BIN_OP NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR 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... | days = int(input())
activities = [int(x) for x in input().split()]
free_days = 0
last_activity = 0
both_count = 0
for activity in activities:
if activity == 3:
both_count += 1
else:
if activity == 0:
free_days += 1
last_activity = 0
elif last_activity != 0 and (
... | 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 VAR IF VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER BIN_OP VAR NUMBER NUMBER VAR VAR BIN_OP VAR NUMBER NUMBER VAR 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())
dhoni = list(map(int, input().split()))
rest = 0
for i in range(n):
if dhoni[i] == 0:
rest += 1
elif dhoni[i] == 1:
if i - 1 >= 0 and dhoni[i - 1] == 1:
rest += 1
dhoni[i] = 0
elif dhoni[i] == 2:
if i - 1 >= 0 and dhoni[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 NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER IF VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR NUMBER IF 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())
c = [int(x) for x in input().split(" ")]
a = [c[0]]
for i in range(1, n):
if c[i] == 0:
a.append(0)
elif c[i] == 1 or c[i] == 2:
if a[-1] != c[i]:
a.append(c[i])
else:
a.append(0)
elif a[-1] == 1:
a.append(2)
elif a[-1] == 2:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER VAR VAR NUMBER IF VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL 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... | input()
prev = free_days = 0
for a in map(int, input().split()):
if a == 0:
prev, free_days = 0, free_days + 1
elif a in (1, 2):
if a == prev:
prev, free_days = 0, free_days + 1
else:
prev = a
elif prev in (1, 2):
prev = 3 - prev
print(free_days) | EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER IF VAR NUMBER NUMBER IF VAR VAR ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER 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... | a = int(input())
b = list(map(int, input().split()))
k = []
n = 0
z = b.count(0)
for i in range(a - 1):
if b[i] in [1, 2]:
if b[i] == b[i + 1]:
n += 1
b[i + 1] = 0
elif b[i + 1] == 3:
b[i + 1] = 3 - b[i]
print(n + z) | 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 ASSIGN VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR LIST NUMBER NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP 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... | from sys import stdin, stdout
for _ in range(1):
n = int(stdin.readline())
a = list(map(int, stdin.readline().split()))
if n == 1:
if a[0] == 0:
print(1)
else:
print(0)
exit(0)
dp = [[(0) for _ in range(3)] for _ in range(n)]
if a[0] == 1 or a[0] == 2... | 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 IF VAR NUMBER IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR 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... | from sys import stdin, stdout
nmbr = lambda: int(stdin.readline())
lst = lambda: list(map(int, stdin.readline().split()))
PI = float("inf")
for _ in range(1):
n = nmbr()
a = lst()
dp = [[(0) for _ in range(3)] for _ in range(n)]
dp[0][0] = 1
for i in range(1, n):
dp[i][0] = 1 + 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 FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER NUMBER FOR 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... | d = {(3): {(2): 1, (1): 2}, (2): {(2): 0}, (1): {(1): 0}}
n = int(input())
cont = 0
prev = 0
for day in [int(i) for i in input().split()]:
try:
prev = d[day][prev]
except KeyError:
prev = day
if prev == 0:
cont += 1
print(cont) | ASSIGN VAR DICT NUMBER NUMBER NUMBER DICT NUMBER NUMBER NUMBER NUMBER DICT NUMBER NUMBER DICT NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL 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())
vals = list(map(int, input().split()))
days = [(0, int(vals[0] & 1 == 1), int(vals[0] & 2 == 2))]
for i in range(1, n):
zal = vals[i] & 1 == 1
cont = vals[i] & 2 == 2
days.append(
(
max(days[i - 1]),
max(days[i - 1][0], days[i - 1][2]) + 1 if zal else 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 FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP 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 = [int(x) for x in input().split()]
inf = 99999999999999999
dp = [([inf] * 3) for _ in range(n + 1)]
dp[1][0] = 1
if a[0] == 2 or a[0] == 3:
dp[1][1] = 0
if a[0] == 1 or a[0] == 3:
dp[1][2] = 0
for i in range(2, n + 1):
dp[i][0] = 1 + min(dp[i - 1][0], dp[i - 1][1], dp[i - 1][2])
if a... | 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 BIN_OP LIST VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER IF VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER IF VAR NUMBER NUMBER VAR NUMBER 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())
a = list(map(int, input().split()))
l = [0] * n
l[0] = a[0]
s = 1 if l[0] == 0 else 0
for i in range(1, n):
if a[i] == 0:
l[i] = 0
s += 1
elif a[i] == 3:
l[i] = l[i - 1] ^ a[i]
elif a[i] == 1:
if l[i - 1] == 1:
l[i] = 0
s += 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 VAR ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER IF VAR 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... | dias = int(input())
lista = []
entrada = map(int, input().strip().split(" "))
for elemento in entrada:
lista += [elemento]
c = False
g = False
r = 0
i = 0
while i < dias:
if lista[i] == 0:
r += 1
g = False
c = False
elif lista[i] == 1:
if c == True:
c = False
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING FOR VAR VAR VAR LIST VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN 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... | n = int(input())
ent = list(map(int, input().strip().split()))[:n]
resp = 0
i = 0
ant = 0
while i < n:
if ent[i] == 0:
resp += 1
ant = 0
elif ent[i] == 1 and ant == 1:
ant = 0
resp += 1
elif ent[i] == 2 and ant == 2:
ant = 0
resp += 1
elif ent[i] == 3:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER IF VAR VAR NUMBER 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())
arr = list(map(int, input().strip().split()))
dp = [[float("inf") for i in range(n)] for i in range(3)]
if arr[0] == 0:
dp[0][0] = dp[1][0] = dp[2][0] = 1
elif arr[0] == 1:
dp[0][0] = 0
dp[1][0] = dp[2][0] = 1
elif arr[0] == 2:
dp[1][0] = 0
dp[0][0] = dp[2][0] = 1
else:
dp[1][0]... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER IF VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER 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_days = int(input())
days = list(map(int, input().split()))
dp = [[-1, -1, -1] for i in range(n_days)]
dp.append([0, 0, 0])
for i in range(n_days - 1, -1, -1):
dp[i][0] = int(max(dp[i + 1]))
if days[i] == 1 or days[i] == 3:
dp[i][1] = int(max(max(dp[i + 1][0] + 1, dp[i + 1][2] + 1), dp[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 LIST NUMBER NUMBER NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR BI... |
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()]
a.insert(0, 0)
dp = [[(0) for _ in range(n + 1)] for _ in range(4)]
for i in range(1, n + 1):
dp[1][i] = max(dp[1][i - 1], dp[2][i - 1], dp[3][i - 1])
dp[2][i] = max(dp[1][i - 1], dp[3][i - 1]) + (1 if a[i] & 1 else 0)
dp[3][i] = max(dp[1][i - 1], dp[2]... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER BIN_OP 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())
x = list(map(int, input().split()))
r = [([0] * n) for _ in [0, 1, 2]]
if x[0] & 1 == 1:
r[1][0] = 1
if x[0] & 2 == 2:
r[2][0] = 1
for i in range(1, n):
r[0][i] = max(r[0][i - 1], r[1][i - 1], r[2][i - 1])
if x[i] & 1 == 1:
r[1][i] = max(r[0][i - 1], r[2][i - 1]) + 1
if x[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 VAR VAR LIST NUMBER NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CAL... |
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... | num_of_days = int(input().strip())
events = list(map(int, input().strip().split()))
dp_code = [0] * (num_of_days + 1)
dp_gym = [0] * (num_of_days + 1)
dp_code[0] = 0
dp_gym[0] = 0
for i in range(1, num_of_days + 1):
if events[i - 1] == 0:
dp_code[i] = min(dp_code[i - 1], dp_gym[i - 1]) + 1
dp_gym[i]... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP 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... | n = int(input())
a = list(map(int, input().split()))
dp = [([10**10] * 3) for i in range(n + 1)]
dp[0][0] = 0
dp[0][1] = 0
dp[0][2] = 0
for i in range(1, n + 1):
if a[i - 1] == 0:
dp[i][0] = min(dp[i - 1][0], dp[i - 1][1], dp[i - 1][2]) + 1
elif a[i - 1] == 1:
dp[i][0] = min(dp[i - 1][0], 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 BIN_OP LIST BIN_OP NUMBER NUMBER 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 NUMBER BI... |
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 findMinRest(days, d, dayNo, prevDay, restCount, memo):
global n
key = dayNo, prevDay, restCount
if key in memo:
return memo[key]
if dayNo == len(days):
return restCount
gym, contest = d[days[dayNo]]
x = y = n
if gym and prevDay != "g":
x = findMinRest(days, d, day... | FUNC_DEF ASSIGN VAR VAR VAR VAR IF VAR VAR RETURN VAR VAR IF VAR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR IF VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER STRING VAR VAR IF VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER STRING VAR VAR ASSIGN VAR F... |
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 = {}
def f(i, n, seq, c=None):
if i >= n:
return 0
if (i, c) in dp:
return dp[i, c]
if seq[i] == 0:
dp[i, c] = 1 + f(i + 1, n, seq)
return dp[i, c]
if seq[i] == 3:
if c == 1:
dp[i, c] = min(f(i + 1, n, seq, 2), f(i + 1, n, seq) + 1)
re... | ASSIGN VAR DICT FUNC_DEF NONE IF VAR VAR RETURN NUMBER IF VAR VAR VAR RETURN VAR VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR VAR BIN_OP NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR RETURN VAR VAR VAR IF VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR NUMBER BIN_OP FU... |
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 = input()
L = [int(x) for x in input().split()]
print(solver(L))
def solver(L):
return helper(L, None)
def helper(L, last):
if len(L) == 0:
return 0
x = L[0]
if last == "gym":
if L[0] in [0, 2]:
return 1 + helper(L[1:], None)
elif L[0] in... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR NONE FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER ASSIGN VAR VAR NUMBER IF VAR STRING IF VAR NUMBER LIST NUMBER NUMBER RETURN BIN_OP NUMBER FUNC_CALL 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... | from sys import stdin, stdout
cin = stdin.readline
cout = stdout.write
n = int(cin())
a = list(map(int, cin().split()))
f, day = 0, 0
for i in a:
if i == 0:
day += 1
f = i
elif i == 1:
day += f == 2
f = (f != 2) * 2
elif i == 2:
day += f == 1
f = (f != 1) * 1... | ASSIGN VAR VAR 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 VAR NUMBER NUMBER FOR VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER IF VAR NUMBER 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())
dp_arr = [0, 0, 0]
days = [int(day) for day in input().split()]
for day in days:
gym = dp_arr[0] + 1
contest = dp_arr[1] + 1
if day == 2 or day == 3:
gym = min(dp_arr[1], dp_arr[2])
if day == 1 or day == 3:
contest = mi... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER IF VAR NUMBER 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())
a = [int(i) for i in input().split()]
def day_count(cur, a, i, n, count):
if i == n:
return count
elif cur == 1:
if a[i] == 0 or a[i] == 1:
return day_count(-1, a, i + 1, n, count + 1)
else:
return day_count(0, a, i + 1, n, count)
elif cur =... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR VAR RETURN VAR IF VAR NUMBER IF VAR VAR NUMBER VAR VAR NUMBER RETURN FUNC_CALL VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER RETURN FUNC_CALL VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR IF VAR NUMBER IF... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.