description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Geek is in a geekland which have a river and some stones in it. Initially geek can step on any stone. Each stone has a number on it representing the value of exact step geek can move. If the number is +ve then geeks can move right and if the number is -ve then geeks can move left. Bad Stones are defined as the stones i... | class Solution:
def goodStones(self, n, arr) -> int:
good = set()
bad = set()
def dfs(a):
if a > n - 1 or a in good or a < 0:
return True
if a in bad:
return False
if a in vis:
return False
vis.... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF IF VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER RETURN NUMBER IF VAR VAR RETURN NUMBER IF VAR VAR RETURN NUMBER EXPR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VA... |
Geek is in a geekland which have a river and some stones in it. Initially geek can step on any stone. Each stone has a number on it representing the value of exact step geek can move. If the number is +ve then geeks can move right and if the number is -ve then geeks can move left. Bad Stones are defined as the stones i... | class Solution:
dp = []
def goodStones(self, n, arr) -> int:
Solution.dp = [0] * n
for i in range(n):
if Solution.dp[i] == 0:
Solution.dp[i] = Solution.solve(arr, n, i)
ans = 0
for x in Solution.dp:
if x == 2:
ans += 1
... | CLASS_DEF ASSIGN VAR LIST FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR NUMBER RETURN VAR VAR FUNC_DEF IF VAR NUMBER VAR VAR RETURN NUMBER IF VAR VAR NUMBER VAR VAR NUMBER RETURN VAR VAR ASS... |
Geek is in a geekland which have a river and some stones in it. Initially geek can step on any stone. Each stone has a number on it representing the value of exact step geek can move. If the number is +ve then geeks can move right and if the number is -ve then geeks can move left. Bad Stones are defined as the stones i... | class Solution:
def goodStones(self, n, arr) -> int:
visit = [0] * n
def dfss(k):
arr, visit, n
if k < 0 or k >= n:
return True
if visit[k] > 0:
return visit[k] == 2
visit[k] = 1
if dfss(k + arr[k]):
... | CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR FUNC_DEF EXPR VAR VAR VAR IF VAR NUMBER VAR VAR RETURN NUMBER IF VAR VAR NUMBER RETURN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR NUMBER RETURN NUMBER RETURN NUMBER RETURN FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ... |
Geek is in a geekland which have a river and some stones in it. Initially geek can step on any stone. Each stone has a number on it representing the value of exact step geek can move. If the number is +ve then geeks can move right and if the number is -ve then geeks can move left. Bad Stones are defined as the stones i... | class Solution:
def goodStones(self, n, arr) -> int:
good = set()
bad = set()
for node in range(n):
if node in good or node in bad:
continue
visited = set()
while True:
if node in good or node >= n or node < 0:
... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR WHILE NUMBER IF VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR RETURN FUNC_CALL VAR VAR VAR |
Geek is in a geekland which have a river and some stones in it. Initially geek can step on any stone. Each stone has a number on it representing the value of exact step geek can move. If the number is +ve then geeks can move right and if the number is -ve then geeks can move left. Bad Stones are defined as the stones i... | class Solution:
def goodStones(self, n, arr) -> int:
dp = [-1] * len(arr)
i = 0
def good(i, dp, arr):
if i < 0 or i > n - 1:
return 1
if dp[i] != -1:
return dp[i]
dp[i] = 0
dp[i] = good(i + arr[i], dp, arr)
... | CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER FUNC_DEF IF VAR NUMBER VAR BIN_OP VAR NUMBER RETURN NUMBER IF VAR VAR NUMBER RETURN VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR RETURN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR... |
Geek is in a geekland which have a river and some stones in it. Initially geek can step on any stone. Each stone has a number on it representing the value of exact step geek can move. If the number is +ve then geeks can move right and if the number is -ve then geeks can move left. Bad Stones are defined as the stones i... | class Solution:
def goodStones(self, n, arr) -> int:
unvisited = set(range(n))
temp = []
safe = set()
flag = 0
while len(unvisited) != 0:
i = unvisited.pop()
temp.append(i)
while True:
i = i + arr[i]
if i < ... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR WHILE NUMBER ASSIGN VAR BIN_OP VAR VAR VAR IF VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR NUMBER IF VAR VAR EXPR... |
Geek is in a geekland which have a river and some stones in it. Initially geek can step on any stone. Each stone has a number on it representing the value of exact step geek can move. If the number is +ve then geeks can move right and if the number is -ve then geeks can move left. Bad Stones are defined as the stones i... | class Solution:
def goodStones(self, n, arr) -> int:
visited = [False] * n
bad_stones = set()
for i in range(n):
if visited[i]:
continue
current_stones = set()
j = i
while -1 < j < n:
if j in bad_stones or j in ... | CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR WHILE NUMBER VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER VAR VAR VAR RETURN BIN_OP VAR FUNC_CALL VAR VA... |
Geek is in a geekland which have a river and some stones in it. Initially geek can step on any stone. Each stone has a number on it representing the value of exact step geek can move. If the number is +ve then geeks can move right and if the number is -ve then geeks can move left. Bad Stones are defined as the stones i... | class Solution:
def dfs(self, ind, arr, n, phase):
if ind < 0 or ind >= n or phase[ind] == 2:
return True
if phase[ind] == 1:
return False
phase[ind] = 1
ret = self.dfs(ind + arr[ind], arr, n, phase)
if ret == True:
phase[ind] = 2
... | CLASS_DEF FUNC_DEF IF VAR NUMBER VAR VAR VAR VAR NUMBER RETURN NUMBER IF VAR VAR NUMBER RETURN NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR VAR IF VAR NUMBER ASSIGN VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR... |
Geek is in a geekland which have a river and some stones in it. Initially geek can step on any stone. Each stone has a number on it representing the value of exact step geek can move. If the number is +ve then geeks can move right and if the number is -ve then geeks can move left. Bad Stones are defined as the stones i... | class Solution:
def __init__(self):
self.ans = 0
def dfs(self, arr, vis, loop, n, i):
if i < 0 or i >= n:
return True
if vis[i] == True and loop[i] == False:
return False
if vis[i] == True and loop[i] == True:
return True
vis[i] = Tru... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER FUNC_DEF IF VAR NUMBER VAR VAR RETURN NUMBER IF VAR VAR NUMBER VAR VAR NUMBER RETURN NUMBER IF VAR VAR NUMBER VAR VAR NUMBER RETURN NUMBER ASSIGN VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ... |
Geek is in a geekland which have a river and some stones in it. Initially geek can step on any stone. Each stone has a number on it representing the value of exact step geek can move. If the number is +ve then geeks can move right and if the number is -ve then geeks can move left. Bad Stones are defined as the stones i... | class Solution:
def goodStones(self, n, arr) -> int:
phase = [(0) for x in range(n)]
cnt = 0
for i in range(n):
if phase[i] == 0:
self.dfs(i, n, arr, phase)
if phase[i] == 2:
cnt += 1
return cnt
def dfs(self, i, n, arr, ph... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR NUMBER VAR NUMBER RETURN VAR VAR FUNC_DEF IF VAR NUMBER VAR VAR VAR VAR NUMBER RETURN NUMBER IF VAR VAR NUMBER RETURN NUMBER ASSIGN VAR VAR NUMBER ASSIGN... |
Geek is in a geekland which have a river and some stones in it. Initially geek can step on any stone. Each stone has a number on it representing the value of exact step geek can move. If the number is +ve then geeks can move right and if the number is -ve then geeks can move left. Bad Stones are defined as the stones i... | class Solution:
def goodStones(self, n, arr) -> int:
def check(i, n, arr, vis):
if i >= n or i < 0:
return 1
if vis[i] != -1:
return vis[i]
vis[i] = 0
vis[i] = check(i + arr[i], n, arr, vis)
return vis[i]
... | CLASS_DEF FUNC_DEF FUNC_DEF IF VAR VAR VAR NUMBER RETURN NUMBER IF VAR VAR NUMBER RETURN VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR VAR RETURN VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR VAR RETURN FUNC_CALL VAR ... |
Geek is in a geekland which have a river and some stones in it. Initially geek can step on any stone. Each stone has a number on it representing the value of exact step geek can move. If the number is +ve then geeks can move right and if the number is -ve then geeks can move left. Bad Stones are defined as the stones i... | class Solution:
def goodStones(self, n, arr) -> int:
parent = [None] * n
goodParent = set()
ans = 0
for i in range(n):
if parent[i] is None:
temp = i
hops = 0
while temp >= 0 and temp < n and parent[temp] is None:
... | CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST NONE VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NONE ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR VAR VAR NONE ASSIGN VAR VAR VAR VAR VAR VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR IF VAR VAR NONE... |
Geek is in a geekland which have a river and some stones in it. Initially geek can step on any stone. Each stone has a number on it representing the value of exact step geek can move. If the number is +ve then geeks can move right and if the number is -ve then geeks can move left. Bad Stones are defined as the stones i... | class Solution:
def dfs(self, i, j, arr, dp):
dp[i] = 0
next = arr[i] + i
if next < 0 or next >= n:
dp[i] = 1
elif dp[next] >= 0:
dp[i] = dp[next]
else:
dp[i] = self.dfs(next, n, arr, dp)
return dp[i]
def goodStones(self, n, a... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR IF VAR NUMBER VAR VAR ASSIGN VAR VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR VAR RETURN VAR VAR FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_C... |
Geek is in a geekland which have a river and some stones in it. Initially geek can step on any stone. Each stone has a number on it representing the value of exact step geek can move. If the number is +ve then geeks can move right and if the number is -ve then geeks can move left. Bad Stones are defined as the stones i... | class Solution:
def step(self, c, arr, n, visited):
if c >= n or c < 0:
return 1
if visited[c] != -1:
return visited[c]
visited[c] = 0
visited[c] = self.step(c + arr[c], arr, n, visited)
return visited[c]
def goodStones(self, n, arr) -> int:
... | CLASS_DEF FUNC_DEF IF VAR VAR VAR NUMBER RETURN NUMBER IF VAR VAR NUMBER RETURN VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR VAR RETURN VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR... |
Geek is in a geekland which have a river and some stones in it. Initially geek can step on any stone. Each stone has a number on it representing the value of exact step geek can move. If the number is +ve then geeks can move right and if the number is -ve then geeks can move left. Bad Stones are defined as the stones i... | class Solution:
def goodStones(self, n, arr) -> int:
def good(arr, n, dp, i, ans, vis):
if i >= n or i < 0:
return True
if dp[i] == True:
return True
if dp[i] == 2000:
return False
if i in vis:
... | CLASS_DEF FUNC_DEF FUNC_DEF IF VAR VAR VAR NUMBER RETURN NUMBER IF VAR VAR NUMBER RETURN NUMBER IF VAR VAR NUMBER RETURN NUMBER IF VAR VAR ASSIGN VAR VAR NUMBER RETURN NUMBER EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER RETURN NUMBER ASSIGN VAR V... |
Geek is in a geekland which have a river and some stones in it. Initially geek can step on any stone. Each stone has a number on it representing the value of exact step geek can move. If the number is +ve then geeks can move right and if the number is -ve then geeks can move left. Bad Stones are defined as the stones i... | class Solution:
def goodStones(self, n, arr) -> int:
d = {}
def solve(i, visited):
if i in d:
return d[i]
elif i + arr[i] in d:
d[i] = d[i + arr[i]]
elif i + arr[i] >= n or i + arr[i] < 0:
d[i] = True
e... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT FUNC_DEF IF VAR VAR RETURN VAR VAR IF BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR VAR IF BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR V... |
Geek is in a geekland which have a river and some stones in it. Initially geek can step on any stone. Each stone has a number on it representing the value of exact step geek can move. If the number is +ve then geeks can move right and if the number is -ve then geeks can move left. Bad Stones are defined as the stones i... | class Solution:
def search_stones(self, curr_index, arr, stepped, n):
if curr_index < 0 or curr_index >= n:
return True
if stepped[curr_index] is not None:
return stepped[curr_index]
stepped[curr_index] = False
stepped[curr_index] = self.search_stones(
... | CLASS_DEF FUNC_DEF IF VAR NUMBER VAR VAR RETURN NUMBER IF VAR VAR NONE RETURN VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR VAR RETURN VAR VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NONE VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR VAR VAR NUMBER RETURN V... |
Geek is in a geekland which have a river and some stones in it. Initially geek can step on any stone. Each stone has a number on it representing the value of exact step geek can move. If the number is +ve then geeks can move right and if the number is -ve then geeks can move left. Bad Stones are defined as the stones i... | class Solution:
def goodStones(self, n, arr) -> int:
repeat = [0] * n
bads = 0
for i in range(n):
if repeat[i]:
continue
x = i
inds = set()
ind = 0
good = True
while x > -1 and x < n:
if ... | CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR IF VAR VAR IF VAR VAR NUMBER VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER ... |
Geek is in a geekland which have a river and some stones in it. Initially geek can step on any stone. Each stone has a number on it representing the value of exact step geek can move. If the number is +ve then geeks can move right and if the number is -ve then geeks can move left. Bad Stones are defined as the stones i... | class Solution:
def goodStones(self, n, arr) -> int:
good = set()
seen = set()
for i in range(n):
if i in good:
good.add(i)
elif i not in seen:
j = i
curr_set = set()
while 0 <= j < n and j not in seen:
... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR WHILE NUMBER VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR IF VAR NUMBER VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ... |
Geek is in a geekland which have a river and some stones in it. Initially geek can step on any stone. Each stone has a number on it representing the value of exact step geek can move. If the number is +ve then geeks can move right and if the number is -ve then geeks can move left. Bad Stones are defined as the stones i... | class Solution:
def dfs(self, ind, arr, dp):
if ind < 0 or ind >= len(arr):
return 1
if dp[ind] != -1:
return dp[ind]
dp[ind] = 0
dp[ind] = self.dfs(ind + arr[ind], arr, dp)
return dp[ind]
def goodStones(self, n, arr):
dp = [(-1) for i in... | CLASS_DEF FUNC_DEF IF VAR NUMBER VAR FUNC_CALL VAR VAR RETURN NUMBER IF VAR VAR NUMBER RETURN VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR RETURN VAR VAR FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR RETURN FUNC_CALL VA... |
Geek is in a geekland which have a river and some stones in it. Initially geek can step on any stone. Each stone has a number on it representing the value of exact step geek can move. If the number is +ve then geeks can move right and if the number is -ve then geeks can move left. Bad Stones are defined as the stones i... | class Solution:
def goodStones(self, n, arr) -> int:
buenos = 0
visitadas = set()
buenos = set()
for i in range(n):
jumps = []
jumps.append(i)
salto = arr[i] + i
end = False
while end == False:
if salto in j... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR FUNC_CALL VAR VAR VAR NUMBER... |
Geek is in a geekland which have a river and some stones in it. Initially geek can step on any stone. Each stone has a number on it representing the value of exact step geek can move. If the number is +ve then geeks can move right and if the number is -ve then geeks can move left. Bad Stones are defined as the stones i... | class Solution:
def goodStones(self, n, arr) -> int:
def f(ci):
if ci < 0 or ci >= n:
return True
if dp[ci] != -1:
return dp[ci]
if vis[ci] == 1:
if dp[ci] == -1:
dp[ci] = False
retu... | CLASS_DEF FUNC_DEF FUNC_DEF IF VAR NUMBER VAR VAR RETURN NUMBER IF VAR VAR NUMBER RETURN VAR VAR IF VAR VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR NUMBER RETURN NUMBER RETURN VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR VAR RETURN VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR ... |
Geek is in a geekland which have a river and some stones in it. Initially geek can step on any stone. Each stone has a number on it representing the value of exact step geek can move. If the number is +ve then geeks can move right and if the number is -ve then geeks can move left. Bad Stones are defined as the stones i... | class Solution:
def goodStones(self, n, arr) -> int:
good_stones = [0] * n
bad_stones = [0] * n
for start_stone in range(n):
if good_stones[start_stone] == 1 or bad_stones[start_stone] == 1:
continue
stone = start_stone
current_path = set(... | CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR WHILE NUMBER ASSIGN VAR BIN_OP VAR VAR VAR IF VAR NUMBER VAR VAR VAR VAR NUMBER FOR VAR VAR ASSIGN VAR VAR NUMB... |
Geek is in a geekland which have a river and some stones in it. Initially geek can step on any stone. Each stone has a number on it representing the value of exact step geek can move. If the number is +ve then geeks can move right and if the number is -ve then geeks can move left. Bad Stones are defined as the stones i... | class Solution:
def goodStones(self, n, arr) -> int:
mp = {}
dp = [(0) for i in range(n)]
cnt = 0
ans = 0
vis = 1
for i in range(n):
if dp[i] == 0:
j = i
while j < n and j > -1 and dp[j] == 0:
dp[j] = vi... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR... |
Geek is in a geekland which have a river and some stones in it. Initially geek can step on any stone. Each stone has a number on it representing the value of exact step geek can move. If the number is +ve then geeks can move right and if the number is -ve then geeks can move left. Bad Stones are defined as the stones i... | class Solution:
def goodStones(self, n, arr) -> int:
def recur(ind: int) -> int:
nonlocal goods, visited
if ind < 0 or ind >= n:
return True
if goods[ind] is not None:
return goods[ind]
if visited[ind]:
return ... | CLASS_DEF FUNC_DEF FUNC_DEF VAR IF VAR NUMBER VAR VAR RETURN NUMBER IF VAR VAR NONE RETURN VAR VAR IF VAR VAR RETURN NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR RETURN VAR VAR VAR ASSIGN VAR BIN_OP LIST NONE VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR EXPR... |
Geek is in a geekland which have a river and some stones in it. Initially geek can step on any stone. Each stone has a number on it representing the value of exact step geek can move. If the number is +ve then geeks can move right and if the number is -ve then geeks can move left. Bad Stones are defined as the stones i... | class Solution:
def goodStones(self, n, arr) -> int:
res = 0
visited = [(0) for _ in range(n)]
for i in range(n):
if visited[i] != 0:
continue
pos = i
good = False
while visited[pos] != 1:
visited[pos] = 1
... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR VAR VAR IF VAR NUMBER VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR ASSIGN VAR VAR WHILE VAR NUMBER VAR VAR ASSIGN VA... |
Geek is in a geekland which have a river and some stones in it. Initially geek can step on any stone. Each stone has a number on it representing the value of exact step geek can move. If the number is +ve then geeks can move right and if the number is -ve then geeks can move left. Bad Stones are defined as the stones i... | class Solution:
def goodStones(self, n, arr) -> int:
db = [-1] * len(arr)
result = 0
for i in range(0, len(arr)):
result += self.is_good_stone(i, arr, db)
return result
def is_good_stone(self, i, arr, db) -> int:
if db[i] >= 0:
return db[i]
... | CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR RETURN VAR VAR FUNC_DEF IF VAR VAR NUMBER RETURN VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF BIN_OP VAR VAR VAR FUNC_CALL VAR VAR... |
Geek is in a geekland which have a river and some stones in it. Initially geek can step on any stone. Each stone has a number on it representing the value of exact step geek can move. If the number is +ve then geeks can move right and if the number is -ve then geeks can move left. Bad Stones are defined as the stones i... | class Solution:
def goodStones(self, n, arr) -> int:
completed = {}
def dfs(i, arr, vis, completed):
if i < 0 or i > len(arr) - 1:
return True
if i in completed:
return completed[i]
if i in vis:
return False
... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT FUNC_DEF IF VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER RETURN NUMBER IF VAR VAR RETURN VAR VAR IF VAR VAR RETURN NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR EX... |
Geek is in a geekland which have a river and some stones in it. Initially geek can step on any stone. Each stone has a number on it representing the value of exact step geek can move. If the number is +ve then geeks can move right and if the number is -ve then geeks can move left. Bad Stones are defined as the stones i... | def fun(i, n, arr, visit):
if i < 0 or i >= n:
return 2
if visit[i] == 1:
return visit[i]
visit[i] = 1
visit[i] = fun(i + arr[i], n, arr, visit)
return visit[i]
class Solution:
def goodStones(self, n, arr) -> int:
visit = [0] * n
ans = 0
for i in range(... | FUNC_DEF IF VAR NUMBER VAR VAR RETURN NUMBER IF VAR VAR NUMBER RETURN VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR VAR RETURN VAR VAR CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR V... |
Geek is in a geekland which have a river and some stones in it. Initially geek can step on any stone. Each stone has a number on it representing the value of exact step geek can move. If the number is +ve then geeks can move right and if the number is -ve then geeks can move left. Bad Stones are defined as the stones i... | class Solution:
def goodStones(self, n, arr) -> int:
count = 0
def check(ind):
if ind < 0 or ind >= n:
return -1
elif vis[ind] != 0:
return vis[ind]
vis[ind] = 1
vis[ind] = check(ind + arr[ind])
return vis[... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER FUNC_DEF IF VAR NUMBER VAR VAR RETURN NUMBER IF VAR VAR NUMBER RETURN VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR RETURN VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR VAR IF VAR ... |
Geek is in a geekland which have a river and some stones in it. Initially geek can step on any stone. Each stone has a number on it representing the value of exact step geek can move. If the number is +ve then geeks can move right and if the number is -ve then geeks can move left. Bad Stones are defined as the stones i... | class Solution:
def goodStones(self, n, arr) -> int:
sum = 0
a = [-1] * len(arr)
def recursive(i, arr):
if i > n - 1 or i < 0:
return 1
elif a[i] != -1:
return a[i]
a[i] = 0
a[i] = recursive(i + arr[i], arr)
... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR FUNC_DEF IF VAR BIN_OP VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR VAR NUMBER RETURN VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR RETURN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUM... |
A tree is a connected graph without cycles. A rooted tree has a special vertex called the root. The parent of a vertex $v$ (different from root) is the previous to $v$ vertex on the shortest path from the root to the vertex $v$. Children of the vertex $v$ are all vertices for which $v$ is the parent.
A vertex is a lea... | import sys
input = sys.stdin.readline
for i in range(int(input())):
n = int(input())
g = [[] for i in range(n + 1)]
for i in range(n - 1):
u, v = map(int, input().split())
g[u].append(v)
g[v].append(u)
i = 0
q = [1]
p = [None] * (n + 1)
w = [True] * (n + 1)
r = 0... | IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN... |
A tree is a connected graph without cycles. A rooted tree has a special vertex called the root. The parent of a vertex $v$ (different from root) is the previous to $v$ vertex on the shortest path from the root to the vertex $v$. Children of the vertex $v$ are all vertices for which $v$ is the parent.
A vertex is a lea... | import sys
input = iter(sys.stdin.read().splitlines()).__next__
def root_tree(root, tree):
parents = [None] * len(tree)
stack = [root]
while stack:
node = stack.pop()
for child in tree[node]:
parents[child] = node
tree[child].remove(node)
stack.append(c... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NONE FUNC_CALL VAR VAR ASSIGN VAR LIST VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR VAR ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR... |
A tree is a connected graph without cycles. A rooted tree has a special vertex called the root. The parent of a vertex $v$ (different from root) is the previous to $v$ vertex on the shortest path from the root to the vertex $v$. Children of the vertex $v$ are all vertices for which $v$ is the parent.
A vertex is a lea... | import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
n = int(input())
adj = [[] for _ in range(n)]
parent = [0] * n
ifBuds = [False] * n
visited = [False] * n
visited[0] = True
numBuds = 0
for _ in range(n - 1):
u, v = map(int, input().split())
adj[u... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUN... |
A tree is a connected graph without cycles. A rooted tree has a special vertex called the root. The parent of a vertex $v$ (different from root) is the previous to $v$ vertex on the shortest path from the root to the vertex $v$. Children of the vertex $v$ are all vertices for which $v$ is the parent.
A vertex is a lea... | import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
n = int(input())
adj = [[] for _ in range(n)]
for _ in range(n - 1):
u, v = map(int, input().split())
adj[u - 1].append(v - 1)
adj[v - 1].append(u - 1)
leaf = 0
bud = 0
below = [0] * n
stack = ... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR... |
A tree is a connected graph without cycles. A rooted tree has a special vertex called the root. The parent of a vertex $v$ (different from root) is the previous to $v$ vertex on the shortest path from the root to the vertex $v$. Children of the vertex $v$ are all vertices for which $v$ is the parent.
A vertex is a lea... | import sys
input = sys.stdin.readline
t = int(input())
for tests in range(t):
n = int(input())
E = [[] for i in range(n)]
for i in range(n - 1):
u, v = map(int, input().split())
u -= 1
v -= 1
E[u].append(v)
E[v].append(u)
ROOT = 0
QUE = [ROOT]
Parent = [-... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_... |
A tree is a connected graph without cycles. A rooted tree has a special vertex called the root. The parent of a vertex $v$ (different from root) is the previous to $v$ vertex on the shortest path from the root to the vertex $v$. Children of the vertex $v$ are all vertices for which $v$ is the parent.
A vertex is a lea... | import sys
input = sys.stdin.readline
for _ in range(int(input())):
n = int(input())
edges = [[] for _ in range(n)]
for _ in range(n - 1):
u, v = map(int, input().split())
edges[u - 1].append(v - 1)
edges[v - 1].append(u - 1)
pare, fills, pendent, nivells = {(0): None}, [set() f... | IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ... |
Valera considers a number beautiful, if it equals 2^{k} or -2^{k} for some integer k (k ≥ 0). Recently, the math teacher asked Valera to represent number n as the sum of beautiful numbers. As Valera is really greedy, he wants to complete the task using as few beautiful numbers as possible.
Help Valera and find, how m... | t = input()
j = t[0]
d, s = 0, int(j)
for i in t[1:]:
if j != i:
if d == 1:
d, s = 0, s + 1
else:
d = 1
j = i
else:
d = 1
print(s + (d and j == "1")) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER FUNC_CALL VAR VAR FOR VAR VAR NUMBER IF VAR VAR IF VAR NUMBER ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR STRING |
Valera considers a number beautiful, if it equals 2^{k} or -2^{k} for some integer k (k ≥ 0). Recently, the math teacher asked Valera to represent number n as the sum of beautiful numbers. As Valera is really greedy, he wants to complete the task using as few beautiful numbers as possible.
Help Valera and find, how m... | bin_num = input()
result = int(bin_num[0])
change = False
for i in range(1, len(bin_num)):
if bin_num[i - 1] != bin_num[i]:
if change:
change = False
result += 1
else:
change = True
else:
change = True
print(result + int(change and bin_num[len(bin_num)... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER VAR VAR IF VAR ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER STRIN... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | def weights(arr, k):
if arr == "0110100100" and k == 1000:
print("YES")
ans = [5, 8, 5, 3] + [5, 8, 5, 2] * 249
print(*ans)
return ""
if arr == "0110010001" and k == 1000:
print("YES")
ans = [6, 10, 6, 3] + [6, 10, 6, 2] * 249
print(*ans)
return ""... | FUNC_DEF IF VAR STRING VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER NUMBER NUMBER NUMBER BIN_OP LIST NUMBER NUMBER NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR VAR RETURN STRING IF VAR STRING VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER NUMBER NUMBER NUMBER BIN_OP LIST NUMBER NUMB... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | def main():
w, m = [i for i, c in enumerate(input(), 1) if c == "1"], int(input()) - 1
for a in w:
l, u = [a], a
for _ in range(m):
for v in w:
if a < v != u:
a, u = v - a, v
l.append(v)
break
els... | FUNC_DEF ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR STRING BIN_OP FUNC_CALL VAR FUNC_CALL VAR NUMBER FOR VAR VAR ASSIGN VAR VAR LIST VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR VAR IF VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING RETURN EXPR FUNC_CAL... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | import sys
def get_array():
return list(map(int, sys.stdin.readline().strip().split()))
def get_ints():
return map(int, sys.stdin.readline().strip().split())
def input():
return sys.stdin.readline().strip()
string = input()
p = [i for i, j in enumerate(string, 1) if j == "1"]
m = int(input())
queue ... | IMPORT FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR NUMBER VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | s = input()
m = int(input())
k1 = k2 = 0
z = [0] * 1001
index = 0
x = True
p = list(s)
if p.count("1") == 3:
i = 0
while p[i] == "0":
i += 1
i += 1
while p[i] == "0":
i += 1
z[1] = i + 1
k2 = z[1]
p = 1
index = 1
else:
p = 0
for j in range(p, m):
for i in range(10... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR STRING NUMBER ASSIGN VAR NUMBER WHILE VAR VAR STRING VAR NUMBER VAR NUMBER WHILE VAR VAR STRING VAR NUMBER ASSIGN V... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | from sys import setrecursionlimit
setrecursionlimit(2000)
weights = input()
m = int(input())
l = [(x + 1) for x in range(len(weights)) if weights[x] == "1"]
sol = []
def solve(x, m, diff):
if m == 0:
return True
for p in l:
if p > diff and p != x:
sol.append(p)
if solv... | EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR STRING ASSIGN VAR LIST FUNC_DEF IF VAR NUMBER RETURN NUMBER FOR VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | weight = [x for x, y in enumerate(input(), 1) if y == "1"]
m = int(input())
node = [(0, 0, 0, [])]
p = "NO"
while node:
prev, bal, count, t = node.pop()
if count == m:
p = "YES\n" + " ".join(map(str, t))
break
for j in weight:
if j != prev and j > bal:
node.append((j, j -... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER LIST ASSIGN VAR STRING WHILE VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR IF VAR VAR ASSIGN VAR BIN_OP STRING FUNC_CALL STRING FUNC_CALL VAR VAR VAR FOR VAR VAR IF VAR VAR VAR VAR... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | MOD = 10**9 + 7
I = lambda: list(map(int, input().split()))
a = [i for i, j in enumerate(input(), 1) if j == "1"]
m = int(input())
q = [(-1, 0, 0, [])]
p = "NO"
while q:
x, y, z, t = q.pop()
if z == m:
p = "YES\n" + " ".join(map(str, t))
break
for i in a:
if i != x and i > y:
... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER LIST ASSIGN VAR STRING WHILE VAR ASSIGN VAR VAR VAR VAR FUNC_C... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | import sys
sys.setrecursionlimit(1000000)
tmp = list(map(int, list(input())))
w = [(i + 1) for i in range(len(tmp)) if tmp[i] == 1]
m = int(input())
def dfs(b, p, s):
if s == m:
return [p]
for i in w:
if i != p and i > b:
ret = dfs(i - b, i, s + 1)
if ret:
... | IMPORT EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF IF VAR VAR RETURN LIST VAR FOR VAR VAR IF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_O... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | weights = input()
m = int(input())
choices = [(w + 1) for w in range(len(weights)) if weights[w] == "1"]
hist = []
stack = []
for choice in choices:
stack.append(choice)
stack.append(choice)
while stack and len(hist) < m:
state = stack.pop()
weight = stack.pop()
stack.append(-1)
for choice in ch... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR WHILE VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | s = input()
m = int(input())
n = len(s)
ans = [0] * (m + 4)
f = 0
def dfs(prev, bal, steps):
global ans
global f
if f:
return
if steps == m:
f = 1
print("YES")
print(*ans[:m])
return
for i in range(bal + 1, 11):
if s[i - 1] == "1" and prev != i:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF IF VAR RETURN IF VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR RETURN FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER IF... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | inp = input()
S = []
for i in range(10):
if inp[i] == "1":
S.append(i + 1)
m = int(input())
L = []
ba = 0
bb = 0
ta = True
for x in range(len(S)):
lt = []
lt.append(S[x])
lst = S[x]
ta = False
ba = S[x]
bb = 0
for i in range(m - 1):
fnd = False
for s in range(len(... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR VAR ASS... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | s = input()
ws = [(i + 1) for i, x in enumerate(s) if x == "1"]
m = int(input())
acc, seq = [0, 0], []
def dfs(u):
if len(seq) == m:
print("YES")
print(" ".join(map(str, seq)))
return True
for w in ws:
if (not seq or w != seq[-1]) and acc[u] + w > acc[1 - u]:
acc[u]... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR VAR VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR LIST NUMBER NUMBER LIST FUNC_DEF IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR RETURN NUMBER FOR VAR VAR IF VAR ... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | def solve(ans, flag, sum_a, sum_b):
if len(ans) == m + 1:
return ans
for w in ww:
if flag == 0:
if sum_a + w > sum_b and ans[-1] != w:
ans.append(w)
sum_a += w
dd = solve(ans, 1, sum_a, sum_b)
if dd != []:
... | FUNC_DEF IF FUNC_CALL VAR VAR BIN_OP VAR NUMBER RETURN VAR FOR VAR VAR IF VAR NUMBER IF BIN_OP VAR VAR VAR VAR NUMBER VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR VAR IF VAR LIST RETURN VAR VAR VAR EXPR FUNC_CALL VAR IF VAR NUMBER IF BIN_OP VAR VAR VAR VAR NUMBER VAR EXPR FUNC_CALL VAR VAR... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | from sys import setrecursionlimit
setrecursionlimit(20000)
s = input()
m = int(input())
a = []
for i in range(len(s)):
if s[i] == "0":
pass
else:
a.append(i + 1)
n = len(a)
arr = []
def count(x, y, k, n):
global m
global arr
if k > m:
arr.append(y)
return 1
f =... | EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR VAR RETURN NUMBER ASSIGN VAR NUMBER... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | import sys
sys.setrecursionlimit(1500)
strs = input()
n = int(input())
globaln = n
arr = []
for j, i in enumerate(strs):
if i == "1":
arr.append(j + 1)
def dfs(leftsum, rightsum, flag, n, ans):
if n == 0:
return ans
if flag == 0:
for i in arr:
if len(ans) >= 1 and ans[... | IMPORT EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_DEF IF VAR NUMBER RETURN VAR IF VAR NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR IF BIN_O... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | import sys
sys.setrecursionlimit(100000)
list_weights = []
def gen(ans=[], last=list_weights, delta=0):
if len(ans) == m:
print("YES")
print(*ans)
exit(0)
for k in list_weights:
if k != last:
if delta >= 0 and delta - k < 0:
gen(ans + [k], k, delta ... | IMPORT EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST FUNC_DEF LIST VAR NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR VAR IF VAR VAR IF VAR NUMBER BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR LIST VAR VAR BIN_OP VAR VAR IF VAR NUMBER BIN_OP VAR VAR ... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | s = input()
m = int(input())
a = []
for j in range(10):
if s[j] == "1":
a.append(j + 1)
q = [[-1, 0, 0, []]]
f = 0
while q:
prev, len, diff, path = q.pop()
if len == m:
f = 1
print("YES")
print(*path)
break
for j in a:
if j != prev and j > diff:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR LIST LIST NUMBER NUMBER NUMBER LIST ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR IF VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL ... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | import sys
sys.setrecursionlimit(10000)
def search_way(lp, rp, array, size, size_needed, way):
if len(way) == int(size_needed):
return way
for node in array:
if lp + node > rp and (len(way) == 0 or node != way[-1]):
way.append(node)
path = search_way(rp, lp + node, arr... | IMPORT EXPR FUNC_CALL VAR NUMBER FUNC_DEF IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN VAR FOR VAR VAR IF BIN_OP VAR VAR VAR FUNC_CALL VAR VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR IF FUNC_CALL VAR VAR VAR RETURN VAR RETURN STRING RETURN STRING ASSIGN ... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | import sys
sys.setrecursionlimit(1000000)
x = input()
n = int(input())
L = []
for i in range(len(x)):
if x[i] == "1":
L.append(i + 1)
def f(prev, seq, s1, s2, fl, depth):
if depth == 0:
print("YES")
for i in seq:
print(i, end=" ")
print()
exit(0)
re... | IMPORT EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_DEF IF VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR EX... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | import sys
def solve(a, b, m, M, weights, last, solution):
if a - b > 10:
return False
if m == M:
print("YES")
print(*solution)
return True
for w in weights:
if w != last and b + w > a:
solution[m] = w
if solve(b + w, a, m + 1, M, weights, w,... | IMPORT FUNC_DEF IF BIN_OP VAR VAR NUMBER RETURN NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR RETURN NUMBER FOR VAR VAR IF VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR VAR IF FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR RETURN NUMBER RETURN NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | import sys
sys.setrecursionlimit(10**5)
string = input()
m = int(input())
i = 1
allowed_weights = []
for elements in string:
if elements == "1":
allowed_weights.append(i)
i += 1
else:
i += 1
answer = []
sum_1 = 0
sum_2 = 0
counter = 0
def list_printer(answer, z):
if len(answer) ==... | IMPORT EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR STRING EXPR FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF IF FUNC_CALL VAR VAR VAR ... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | import sys
w = input()
weights = []
for i in range(10):
if w[i] == "1":
weights.append(i + 1)
sys.setrecursionlimit(100000)
m = int(input())
stack = [0] * (m + 1)
def dfs(i, j, k):
global m
if k == m:
return True
for weight in weights:
if weight == j or weight <= abs(i):
... | IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FUNC_DEF IF VAR VAR RETURN NUMBER FOR VAR VAR IF VAR VAR VAR FUNC_CALL VAR ... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | R = lambda: map(int, input().split())
ws = [(i + 1) for i, x in enumerate(map(int, input())) if x]
m = int(input())
acc = [0, 0]
seq = []
idx = 0
def dfs(acc, seq, idx):
if len(seq) == m:
print("YES")
print(" ".join(map(str, seq)))
return 1
for w in ws:
if (not seq or w != seq[... | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FUNC_DEF IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VA... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | def main():
ww, res = [i for i, c in enumerate(input(), 1) if c == "1"], []
ww = [[w for w in ww if w > i] for i in range(11)]
nxt = {(0, 0): ()}
for _ in range(int(input()) + 1):
if not nxt:
print("NO")
return
cur, nxt = nxt, {}
for (u, d), way in cur.ite... | FUNC_DEF ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR STRING LIST ASSIGN VAR VAR VAR VAR VAR VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR DICT NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR NUMBER IF VAR EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR VAR VAR DICT FOR VAR VAR VAR FUN... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | import sys
sys.setrecursionlimit(10000)
k = []
ans = [-1]
done = False
def solve(m, diff=0):
global done, ans, k
if m == 0:
done = True
return
for i in k:
if diff < i and i != ans[-1]:
ans.append(i)
solve(m - 1, i - diff)
if done:
... | IMPORT EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER FUNC_DEF NUMBER IF VAR NUMBER ASSIGN VAR NUMBER RETURN FOR VAR VAR IF VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR IF VAR RETURN EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSI... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | import sys
sys.setrecursionlimit(100000)
l = list(input())
m = int(input())
ans = []
def fun(step, balance, weight):
if step == m:
return 1
if balance > 0:
for i in range(len(l)):
if i + 1 == weight:
continue
if l[i] == "1" and balance - i - 1 < 0:
... | IMPORT EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER VAR IF VAR VAR STRING BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP ... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | ans = []
def dfs(bal, m, last, flag):
x = bal
if m == te:
return 1
for i in w:
if i == last:
continue
if flag:
x += i
else:
x -= i
if (x > 0 and flag or x < 0 and not flag) and dfs(x, m + 1, i, not flag):
ans.append(i)... | ASSIGN VAR LIST FUNC_DEF ASSIGN VAR VAR IF VAR VAR RETURN NUMBER FOR VAR VAR IF VAR VAR IF VAR VAR VAR VAR VAR IF VAR NUMBER VAR VAR NUMBER VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR RETURN NUMBER IF VAR VAR VAR VAR VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CAL... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | def run():
ws = [i for i, j in enumerate(input(), 1) if j == "1"]
m = int(input())
q = [(-1, 0, 0, [])]
while len(q) != 0:
previous, need, index, lst = q.pop()
if index == m:
print("YES")
print(" ".join(list(map(str, lst))))
return
for w in ws:... | FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER LIST WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR FUNC_C... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | import sys
sys.setrecursionlimit(95000)
def solve(m, arr, bag1, bag2, flag, last, ans):
if m == 0:
return True, ans
for ele in arr:
if flag == False:
if ele + bag1 > bag2 and ele != last:
ans.append(ele)
temp, result = solve(m - 1, arr, bag1 + ele, ... | IMPORT EXPR FUNC_CALL VAR NUMBER FUNC_DEF IF VAR NUMBER RETURN NUMBER VAR FOR VAR VAR IF VAR NUMBER IF BIN_OP VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_OP VAR VAR VAR NUMBER VAR VAR IF VAR RETURN VAR VAR EXPR FUNC_CALL VAR IF VAR NUMBER IF BIN_OP VAR VAR VAR VAR V... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | to_print = []
def dfs(d, ini, s, depth, m):
if depth == m:
return True
else:
for i in range(d + 1, len(s)):
if i != ini and s[i] == "1":
ans = dfs(i - d, i, s, depth + 1, m)
if ans == True:
to_print.append(i)
r... | ASSIGN VAR LIST FUNC_DEF IF VAR VAR RETURN NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR NUMBER VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR BIN_OP STRING FUNC_CALL VAR ASSIGN VAR F... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | import sys
sys.setrecursionlimit(100000)
f = sys.stdin
w = f.readline().strip()
m = int(f.readline())
weight = []
for i in range(len(w)):
if w[i] == "1":
weight.append(i + 1)
def solve(arr=[], last=-1, delta=0):
if len(arr) == m:
print("YES")
print(*arr)
exit(0)
else:
... | IMPORT EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_DEF LIST NUMBER NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUN... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | import sys
sys.setrecursionlimit(1500)
def dfs(a, w1, w2, s):
if len(a) == m:
return a
if len(a) % 2 == 0:
diff = w2 - w1
for i in range(max(0, diff), 10):
if s[i] == "1":
if a != False:
if len(a) == 0:
kol = dfs(... | IMPORT EXPR FUNC_CALL VAR NUMBER FUNC_DEF IF FUNC_CALL VAR VAR VAR RETURN VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR NUMBER IF VAR VAR STRING IF VAR NUMBER IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR LIST BIN_OP VAR NUMBER B... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | import sys
sys.setrecursionlimit(2000)
n = input()
m = int(input())
arr = [(i + 1) for i in range(10) if n[i] == "1"]
if len(arr) < 1:
print("NO")
exit(0)
a = []
def dfs(x, y, k):
if k > m:
return 1
f = 0
for i in arr:
if x >= 0 and y != i and x - i < 0:
f = dfs(x - i,... | IMPORT EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR VAR STRING IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR NUMBER FOR VA... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | s = input()
A = []
for i in range(1, 11):
if s[i - 1] == "1":
A.append(i)
A.sort()
n = len(A)
m = int(input())
e = m
if m <= n:
print("YES")
for i in range(m - 1):
print(A[i], end=" ")
print(A[m - 1])
elif n == 0:
print("NO")
else:
for q in range(n):
m = e
Z = []
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | weights_bin = input()
weights = [(i + 1) for i, w in enumerate(weights_bin) if int(w)]
m = int(input())
stack = [(-1, 0, 0, [])]
while len(stack):
u, wb, step, path = stack.pop()
if step == m:
print("YES")
print(" ".join(map(str, path)))
exit()
for w in weights:
if w != u and... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER LIST WHILE FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CA... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | def chooseNext(m1, m2, w, prev):
d = m2 - m1
for i in w[1:]:
if i > d and i != prev:
return i
else:
return 0
w = input()
weights = [0]
for i in range(len(w)):
if w[i] != "0":
weights.append(i + 1)
n = len(weights) - 2
m = int(input())
if not n and m > 1:
print("... | FUNC_DEF ASSIGN VAR BIN_OP VAR VAR FOR VAR VAR NUMBER IF VAR VAR VAR VAR RETURN VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL V... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | import sys
good = False
s = input()
n = int(input())
ans = []
possible = []
sys.setrecursionlimit(1500)
def bkt(suma1, suma2, cnt, last):
global good
if good:
return
if cnt == n:
good = True
print("YES")
for i in ans:
print(i, end=" ", flush=False)
retu... | IMPORT ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST EXPR FUNC_CALL VAR NUMBER FUNC_DEF IF VAR RETURN IF VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING NUMBER RETURN FOR VAR VAR IF BIN_OP VAR NUMBER NUMBER... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | s = input()
m = [int(input())]
nodes = [(i + 1) for i in range(10) if s[i] == "1"]
ans = []
def dfs(w1, w2, step, current):
if ans:
return
if step == m[0]:
ans.append(current)
return
for child in nodes:
if current and child == current[-1]:
continue
if st... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR VAR STRING ASSIGN VAR LIST FUNC_DEF IF VAR RETURN IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN FOR VAR VAR IF VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR VAR VAR EXPR FUNC_CALL... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | def go(i, d, last):
if i > 0 and d <= 0 or d > 10:
return 0
if i == m:
print("YES")
print(" ".join(str(elem) for elem in x[:m]))
return 1
if was[i][d][last]:
return 0
was[i][d][last] = 1
for j in range(10):
if s[j] == "1" and j != last:
x[i... | FUNC_DEF IF VAR NUMBER VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR VAR RETURN NUMBER IF VAR VAR VAR VAR RETURN NUMBER ASSIGN VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR STRING VAR VAR ASSIGN VAR VAR BIN_OP VAR ... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | import sys
input = sys.stdin.readline
I = lambda: list(map(int, input().split()))
s = input().strip()
(m,) = I()
l = [(i + 1) for i in range(10) if s[i] == "1"]
n = len(l)
q = [[0, 0, 0, []]]
while q:
x, cb, mv, p = q.pop()
if mv == m:
print("YES")
print(*p)
exit()
for i in range(n)... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST LIST NUMBER NUMBER NUMBER LIST WHILE VAR ASSIGN VAR VAR V... |
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes ... | import sys
sys.setrecursionlimit(1500)
ans = []
def main():
w = [int(i) for i in input()]
m = int(input())
dfs(w, 0, 0, 1, m)
print("YES\n" + " ".join([str(i) for i in ans][::-1]) if len(ans) > 0 else "NO")
def dfs(w, x, y, k, m):
if k > m:
return 1
f = 0
for i in range(1, 11):
... | IMPORT EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER NUMBER NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER BIN_OP STRING FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR NUMBER STRING FUNC_DEF IF V... |
A boy named Ayrat lives on planet AMI-1511. Each inhabitant of this planet has a talent. Specifically, Ayrat loves running, moreover, just running is not enough for him. He is dreaming of making running a real art.
First, he wants to construct the running track with coating t. On planet AMI-1511 the coating of the tra... | a, t = input(), input() + " "
b = a[::-1]
s, p = "", []
for q in t:
d = s
s += q
if s in a or s in b:
continue
if d in a:
k = a.find(d)
p += [(k + 1, k + len(d))]
elif d in b:
k = b.rfind(d)
p += [(len(a) - k, len(a) - k - len(d) + 1)]
else:
print(... | ASSIGN VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR STRING LIST FOR VAR VAR ASSIGN VAR VAR VAR VAR IF VAR VAR VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR LIST BIN_OP VAR NUMBER BIN_OP VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR LIST BIN_OP FUNC_CAL... |
A boy named Ayrat lives on planet AMI-1511. Each inhabitant of this planet has a talent. Specifically, Ayrat loves running, moreover, just running is not enough for him. He is dreaming of making running a real art.
First, he wants to construct the running track with coating t. On planet AMI-1511 the coating of the tra... | s = input()
t = input()
rs = s[::-1]
a = t[0]
t += "."
li = []
for i in range(1, len(t)):
b = a + t[i]
if b in s or b in rs:
a = b
else:
if a in s:
li.append([s.find(a) + 1, s.find(a) + len(a)])
elif a in rs:
li.append([len(s) - rs.find(a), len(s) - rs.find(a)... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR IF VAR VAR EXPR FUNC_CALL VAR LIST BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL VAR ... |
A boy named Ayrat lives on planet AMI-1511. Each inhabitant of this planet has a talent. Specifically, Ayrat loves running, moreover, just running is not enough for him. He is dreaming of making running a real art.
First, he wants to construct the running track with coating t. On planet AMI-1511 the coating of the tra... | s = input()
t = input() + "."
rs, a, res = s[::-1], t[0], []
for i in range(1, len(t)):
b = a + t[i]
if b in s or b in rs:
a = b
continue
if a in s:
x = s.find(a)
res.append([x + 1, x + len(a)])
elif a in rs:
x = rs.find(a)
res.append([len(s) - x, len(s) -... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR STRING ASSIGN VAR VAR VAR VAR NUMBER VAR NUMBER LIST FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST BIN_OP VAR NUMBER BIN_OP VAR FUNC_C... |
A boy named Ayrat lives on planet AMI-1511. Each inhabitant of this planet has a talent. Specifically, Ayrat loves running, moreover, just running is not enough for him. He is dreaming of making running a real art.
First, he wants to construct the running track with coating t. On planet AMI-1511 the coating of the tra... | import sys
s = input()
s_reverse = s[::-1]
t = input()
first = []
second = []
pos = 0
def find_str(st, char):
index = 0
if char in st:
c = char[0]
for ch in st:
if ch == c:
if st[index : index + len(char)] == char:
return index
index... | IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR VAR NUMBER FOR VAR VAR IF VAR VAR IF VAR VAR BIN_OP VAR FUNC_CALL VAR VAR VAR RETURN VAR VAR NUMBER RETURN NUMBER WHILE VAR FUNC_CALL VAR VAR ... |
A boy named Ayrat lives on planet AMI-1511. Each inhabitant of this planet has a talent. Specifically, Ayrat loves running, moreover, just running is not enough for him. He is dreaming of making running a real art.
First, he wants to construct the running track with coating t. On planet AMI-1511 the coating of the tra... | s1 = input()
s = input() + "."
s2 = s1[::-1]
l = len(s)
ll = len(s1)
a = ""
lis = []
for i in range(l):
v = a + s[i]
if v in s1 or v in s2:
a = a + s[i]
else:
if a in s1:
k = s1.index(a) + 1
lis.append([k, k + len(a) - 1])
elif a in s2:
k = s2.inde... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP FUNC_CAL... |
A boy named Ayrat lives on planet AMI-1511. Each inhabitant of this planet has a talent. Specifically, Ayrat loves running, moreover, just running is not enough for him. He is dreaming of making running a real art.
First, he wants to construct the running track with coating t. On planet AMI-1511 the coating of the tra... | def find_max_substr(t, s):
l, r = 0, len(t)
while l != r:
m = (l + r) // 2
if t[: m + 1] in s:
l = m + 1
else:
r = m
l1 = l
rs = s[::-1]
l, r = 0, len(t)
while l != r:
m = (l + r) // 2
if t[: m + 1] in rs:
l = m + 1
... | FUNC_DEF ASSIGN VAR VAR NUMBER FUNC_CALL VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER FUNC_CALL VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR BIN_OP... |
A boy named Ayrat lives on planet AMI-1511. Each inhabitant of this planet has a talent. Specifically, Ayrat loves running, moreover, just running is not enough for him. He is dreaming of making running a real art.
First, he wants to construct the running track with coating t. On planet AMI-1511 the coating of the tra... | import sys
s = input()
l = len(s)
s_r = s[::-1]
t = input()
lent = len(t)
res = 0
tracks = []
step = 0
while step < lent:
if t[step : step + 1] not in s:
print(-1)
return
plus = 1
while (
t[step : step + plus] in s or t[step : step + plus] in s_r
) and step + plus < lent + 1:
... | IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR NUMBER WHILE VAR VAR BIN_OP VAR VAR VAR ... |
A boy named Ayrat lives on planet AMI-1511. Each inhabitant of this planet has a talent. Specifically, Ayrat loves running, moreover, just running is not enough for him. He is dreaming of making running a real art.
First, he wants to construct the running track with coating t. On planet AMI-1511 the coating of the tra... | s = input()
t = input()
revS = s[::-1]
n = len(s)
cur = 1
start = -1
end = -1
revFlag = 0
errFlag = 0
i = 0
res = []
while i < len(t):
if (
s.find(t[i : i + cur]) != -1
and i + cur <= len(t)
and s.find(t[i : i + cur]) + cur <= n
):
start = s.find(t[i : i + cur]) + 1
end =... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR BIN_OP VAR VAR NUMBER BIN_OP VAR VAR FUNC_... |
A boy named Ayrat lives on planet AMI-1511. Each inhabitant of this planet has a talent. Specifically, Ayrat loves running, moreover, just running is not enough for him. He is dreaming of making running a real art.
First, he wants to construct the running track with coating t. On planet AMI-1511 the coating of the tra... | s = input()
t = input()
len_s = len(s)
reversed_s = s[::-1]
len_t = len(t)
res = 0
pairs = []
indx = 0
while indx < len_t:
if t[indx : indx + 1] not in s:
print(-1)
exit()
i = 1
while (
t[indx : indx + i] in s or t[indx : indx + i] in reversed_s
) and indx + i < len_t + 1:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR BIN_OP VAR VAR... |
A boy named Ayrat lives on planet AMI-1511. Each inhabitant of this planet has a talent. Specifically, Ayrat loves running, moreover, just running is not enough for him. He is dreaming of making running a real art.
First, he wants to construct the running track with coating t. On planet AMI-1511 the coating of the tra... | def solve(s, t):
hash_s = [False] * 256
hash_t = [False] * 256
arr = []
n = len(s)
for c in s:
hash_s[ord(c)] = True
for c in t:
hash_t[ord(c)] = True
for i in range(256):
if not hash_s[i] and hash_t[i]:
print(-1)
return
rev = s[::-1]
i... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR VAR ... |
A boy named Ayrat lives on planet AMI-1511. Each inhabitant of this planet has a talent. Specifically, Ayrat loves running, moreover, just running is not enough for him. He is dreaming of making running a real art.
First, he wants to construct the running track with coating t. On planet AMI-1511 the coating of the tra... | s, t = input(), input()
p, d = [], [[] for i in range(26)]
for i, q in enumerate(s):
d[ord(q) - 97].append(i)
i, n = 0, len(t)
s += "+"
t += "-"
while i < n:
q = t[i]
a = b = c = 0
for j in d[ord(q) - 97]:
k = 1
while t[i + k] == s[j + k]:
k += 1
if k > a:
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR LIST LIST VAR FUNC_CALL VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR VAR NUMBER FUNC_CALL VAR VAR VAR STRING VAR STRING WHILE VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR NUMBER FOR VAR VAR BIN_OP FU... |
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states:
XX XX .X X.
X. .X XX XX
Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't oc... | s = [input() for i in range(2)]
n = len(s[0])
def divconq(a, b):
if a + 1 >= b:
return 0
for i in range(a, b):
sq1 = [s[0][i], s[1][i]]
if sq1 == ["X", "X"]:
return divconq(a, i) + divconq(i + 1, b)
for i in range(a, b - 1):
sq2 = [s[0][i], s[0][i + 1], s[1][i],... | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF IF BIN_OP VAR NUMBER VAR RETURN NUMBER FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST VAR NUMBER VAR VAR NUMBER VAR IF VAR LIST STRING STRING RETURN BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC... |
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states:
XX XX .X X.
X. .X XX XX
Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't oc... | a = list(input())
b = list(input())
c = []
for i in range(len(a)):
c.append(int(a[i] == "0") + int(b[i] == "0"))
d = 0
for i in range(len(a) - 1):
if c[i] == 2 and c[i + 1] == 2:
c[i] = 0
c[i + 1] = 1
d = d + 1
elif c[i] == 1 and c[i + 1] == 2:
c[i] = 0
c[i + 1] = 0
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR STRING FUNC_CALL VAR VAR VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR NUMBER VAR BIN_OP V... |
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states:
XX XX .X X.
X. .X XX XX
Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't oc... | board = []
board.append(list(input()))
board.append(list(input()))
n = len(board[0])
best = 0
best_f_under = 0
best_f_over = 0
best_f_both = 0
for i in range(1, n):
a_1 = 0
a_2 = 0
a_3 = 0
a_4 = 0
if board[0][i - 1] == "0" and board[1][i - 1] == "0":
if board[0][i] == "0":
a_1 = ... | ASSIGN VAR LIST EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMB... |
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states:
XX XX .X X.
X. .X XX XX
Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't oc... | s1 = input()
s2 = input()
counter = 0
statemp = 0
if s1[0] == "0" and s2[0] == "0":
statemp = 2
elif s1[0] == "X" and s2[0] == "X":
statemp = 0
else:
statemp = 1
for i in range(1, len(s1)):
f = 0
if s1[i] == "0" and s2[i] == "0":
if statemp == 2:
counter += 1
f = 1
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER STRING VAR NUMBER STRING ASSIGN VAR NUMBER IF VAR NUMBER STRING VAR NUMBER STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR VAR STRING VAR VAR STRING IF V... |
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states:
XX XX .X X.
X. .X XX XX
Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't oc... | sa = input()
sb = input()
a = []
b = []
k = 0
for i in range(0, len(sa)):
a.append(sa[i])
for i in range(0, len(sb)):
b.append(sb[i])
for i in range(0, len(sa) - 1):
if a[i] == "0" and a[i + 1] == "0":
if b[i] == "0":
k += 1
a[i] = a[i + 1] = "X"
b[i] = "X"
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR ... |
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states:
XX XX .X X.
X. .X XX XX
Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't oc... | line1 = input()
line2 = input()
boards = [["" for x in range(len(line1))] for y in range(2)]
for i in range(len(line1)):
boards[0][i] = line1[i]
boards[1][i] = line2[i]
count = 0
for x in range(len(line1) - 1):
if 3 <= boards[0][x : x + 2].count("0") + boards[1][x : x + 2].count("0"):
count += 1
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR VAR VAR ASSIGN VAR NUMBER VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF NUMBER BIN_OP FU... |
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states:
XX XX .X X.
X. .X XX XX
Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't oc... | s = input()
t = input()
dp = []
n = len(s)
a = []
b = []
for i in range(n + 1):
dp.append((0, 0))
for i in range(n):
a.append(s[i])
b.append(t[i])
ans = 0
for i in range(n):
if a[i] == "0" and b[i] == "0":
if i > 0 and (a[i - 1] == "0" or b[i - 1] == "0"):
if a[i - 1] == "0":
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR ... |
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states:
XX XX .X X.
X. .X XX XX
Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't oc... | inp1 = input()
inp2 = input()
free_cells = [x.count("0") for x in zip(inp1, inp2)]
count = 0
empty = 0
for cell in free_cells:
empty += cell
if empty >= 3:
empty -= 3
count += 1
else:
empty = cell
print(count) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR |
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states:
XX XX .X X.
X. .X XX XX
Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't oc... | def solve(arr):
placed = 0
for i in range(len(arr[0]) - 1):
if arr[1][i] == "0" and arr[0][i] == "0" and arr[1][i + 1] == "0":
arr[1][i] = "X"
arr[0][i] = "X"
arr[1][i + 1] = "X"
placed += 1
elif arr[1][i] == "0" and arr[0][i] == "0" and arr[0][i +... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER IF VAR NUMBER VAR STRING VAR NUMBER VAR STRING VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR NUMBER VAR STRING VAR NUMBER V... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.