description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times.
Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ... | class Solution:
def removePair(self, s):
stack = []
ans = ""
for i in range(len(s)):
if stack and stack[-1] == s[i]:
stack.pop()
else:
stack.append(s[i])
if len(stack) == 0:
return -1
else:
while... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER WHILE FUNC_CALL VAR VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR RETURN VAR NUMBER |
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times.
Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ... | class Solution:
def removePair(self, s):
li = []
lis = list(s)
for item in lis:
if li and li[-1] == item:
li.pop()
else:
li.append(item)
result = "".join(li)
if result:
return result
return -1 | CLASS_DEF FUNC_DEF ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR IF VAR VAR NUMBER VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL STRING VAR IF VAR RETURN VAR RETURN NUMBER |
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times.
Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ... | class Solution:
def removePair(self, S):
s = []
for i in S:
if s and s[-1] == i:
s.pop()
else:
s.append(i)
if len(s) == 0:
return -1
else:
return "".join(s) | CLASS_DEF FUNC_DEF ASSIGN VAR LIST FOR VAR VAR IF VAR VAR NUMBER VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER RETURN FUNC_CALL STRING VAR |
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times.
Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ... | class Solution:
def removePair(self, s):
l1 = []
for i in range(len(s)):
if l1 == []:
l1.append(s[i])
elif l1[-1] == s[i]:
l1.pop()
else:
l1.append(s[i])
s1 = "".join(l1)
if s1 == "":
ret... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR LIST EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL STRING VAR IF VAR STRING RETURN NUMBER RETURN VAR |
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times.
Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ... | class Solution:
def removePair(self, s):
li = list(s)
i = 0
while i < len(li) - 1:
if li[i] == li[i + 1]:
li.pop(i + 1)
li.pop(i)
if i != 0:
i = i - 1
else:
i = i + 1
if len(l... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR NUMBER RETURN FUNC_CALL ST... |
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times.
Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ... | class Solution:
def removePair(self, s):
d = []
p = ""
for i in range(len(s)):
if len(d) == 0:
d.append(s[i])
elif d[-1] != s[i]:
d.append(s[i])
elif d[-1] == s[i]:
d.pop()
for j in d:
p ... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR VAR EXPR FUNC_CALL VAR FOR VAR VAR VAR VAR IF VAR RETURN VAR RETURN NUMBER |
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times.
Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ... | class Solution:
def removePair(self, s):
dup_index = self.checkDuplicates(s)
while dup_index < len(s) - 1:
s = s[0:dup_index] + s[dup_index + 2 :]
dup_index = self.checkDuplicates(s)
if len(s) > 0:
return s
else:
return -1
def che... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER RETURN VAR RETURN NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VA... |
Chef had an interesting dream last night. He dreamed of a new revolutionary chicken recipe. When he woke up today he tried very hard to reconstruct the ingredient list. But, he could only remember certain ingredients. To simplify the problem, the ingredient list can be represented by a string of lowercase characters 'a... | T = int(input())
for i in range(T):
s = input()
x = 0
y = len(s) - 1
z = 1
while x <= y:
if s[x] == "?" == s[y]:
z = z * 26 % 10000009
elif s[x] != "?" and s[y] != "?" and s[x] != s[y]:
z = 0
break
x += 1
y -= 1
print(z) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR STRING VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR VAR STRING VAR VAR STRING VAR VAR VAR VAR ASSIGN VAR NUMBER V... |
Chef had an interesting dream last night. He dreamed of a new revolutionary chicken recipe. When he woke up today he tried very hard to reconstruct the ingredient list. But, he could only remember certain ingredients. To simplify the problem, the ingredient list can be represented by a string of lowercase characters 'a... | MOD = 10000009
def solve():
s = input()
ls = len(s)
res = 1
if ls == 1:
if s[0] == "?":
print(26)
else:
print(1)
return
if ls & 1:
for i in range(ls // 2):
first_ch = s[i]
last_ch = s[ls - i - 1]
if first_c... | ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER IF VAR NUMBER STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN IF BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR NUMBER IF ... |
Chef had an interesting dream last night. He dreamed of a new revolutionary chicken recipe. When he woke up today he tried very hard to reconstruct the ingredient list. But, he could only remember certain ingredients. To simplify the problem, the ingredient list can be represented by a string of lowercase characters 'a... | t = int(input())
for _ in range(t):
s = input()
n = len(s)
if n == 1 and s[0] == "?":
print(26)
else:
count = 1
left = 0
right = n - 1
while left <= right:
if s[left] == "?" and s[right] == "?":
left += 1
right -= 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR IF VAR VAR STRING VAR VAR STRING VAR NUMBER VAR NUMBER ASSIGN VA... |
Chef had an interesting dream last night. He dreamed of a new revolutionary chicken recipe. When he woke up today he tried very hard to reconstruct the ingredient list. But, he could only remember certain ingredients. To simplify the problem, the ingredient list can be represented by a string of lowercase characters 'a... | mod = 10000009
for _ in range(int(input())):
st = input()
c = 1
i = 0
j = len(st) - 1
while i <= j:
if st[i] == "?" and st[j] == "?":
c = c * 26 % mod
elif st[i] == "?" or st[j] == "?":
pass
elif st[i] != st[j]:
c = 0
break
... | ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR IF VAR VAR STRING VAR VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR IF VAR VAR STRING VAR VAR STRING IF VAR VAR VAR VAR ASSIGN VA... |
Chef had an interesting dream last night. He dreamed of a new revolutionary chicken recipe. When he woke up today he tried very hard to reconstruct the ingredient list. But, he could only remember certain ingredients. To simplify the problem, the ingredient list can be represented by a string of lowercase characters 'a... | t = int(input())
mod = 10000009
while t:
s = input()
m = len(s)
ans = 1
for i in range(m // 2 + 1):
if i == m // 2 and m & 1 == 0:
break
if (s[i] != "?" and s[-(i + 1)] != "?") and s[i] != s[-(i + 1)]:
ans = 0
break
if s[i] == s[-(i + 1)] == "?... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR VAR VAR BIN_OP VAR NUMBER ... |
Chef had an interesting dream last night. He dreamed of a new revolutionary chicken recipe. When he woke up today he tried very hard to reconstruct the ingredient list. But, he could only remember certain ingredients. To simplify the problem, the ingredient list can be represented by a string of lowercase characters 'a... | k = 10**7 + 9
for _ in range(int(input())):
s = input()
n = len(s)
i, j = 0, n - 1
c, f = 1, 0
while i <= j:
if s[i] == s[j]:
if s[i] == "?":
c = c % k * 26 % k
elif s[i] != s[j]:
if s[i] == "?" or s[j] == "?":
pass
... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER WHILE VAR VAR IF VAR VAR VAR VAR IF VAR VAR STRING ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR... |
Chef had an interesting dream last night. He dreamed of a new revolutionary chicken recipe. When he woke up today he tried very hard to reconstruct the ingredient list. But, he could only remember certain ingredients. To simplify the problem, the ingredient list can be represented by a string of lowercase characters 'a... | for _ in range(int(input())):
s1 = str(input())
n = len(s1)
ans = 1
for i in range((n + 1) // 2):
if s1[i] == "?" and s1[n - i - 1] == "?":
ans = ans * 26 % 10000009
elif s1[i] != "?" and s1[n - i - 1] != "?" and s1[i] != s1[n - i - 1]:
ans = 0
break
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR VAR STRING VAR BIN_OP BIN_OP VAR VAR NUMBER STRING ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR VAR STRING VAR BIN_OP ... |
Chef had an interesting dream last night. He dreamed of a new revolutionary chicken recipe. When he woke up today he tried very hard to reconstruct the ingredient list. But, he could only remember certain ingredients. To simplify the problem, the ingredient list can be represented by a string of lowercase characters 'a... | for j in range(int(input())):
s = input()
l = len(s)
ans = 1
mod = 10000009
for i in range((l + 1) // 2):
if s[i] != s[l - 1 - i] and s[i] != "?" and s[l - 1 - i] != "?":
ans = 0
break
elif s[i] == "?" and s[l - 1 - i] == "?":
ans = ans * 26 % mod
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR VAR VAR BIN_OP BIN_OP VAR NUMBER VAR VAR VAR STRING VAR BIN_OP BIN_OP VAR NUMBER VAR STRING ASSIGN VAR NUMBER IF VAR VA... |
Chef had an interesting dream last night. He dreamed of a new revolutionary chicken recipe. When he woke up today he tried very hard to reconstruct the ingredient list. But, he could only remember certain ingredients. To simplify the problem, the ingredient list can be represented by a string of lowercase characters 'a... | for u in range(int(input())):
s = input()
i = 0
j = len(s) - 1
c = 1
m = 10**7 + 9
while i <= j:
if s[i] == s[j] == "?":
c = 26 % m * (c % m) % m
i += 1
j -= 1
elif s[i] == "?" or s[j] == "?" or s[i] == s[j]:
i += 1
j -=... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER WHILE VAR VAR IF VAR VAR VAR VAR STRING ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER VAR BIN_OP VAR VAR VAR VAR NUMBER VAR NUM... |
Chef had an interesting dream last night. He dreamed of a new revolutionary chicken recipe. When he woke up today he tried very hard to reconstruct the ingredient list. But, he could only remember certain ingredients. To simplify the problem, the ingredient list can be represented by a string of lowercase characters 'a... | from sys import stdin, stdout
mod = 10**7 + 9
for _ in range(int(stdin.readline())):
s = input().strip()
n = len(s)
m = 1
for i in range(n // 2):
if s[i] == s[n - i - 1] and s[i] == "?":
m = m * 26 % mod
elif s[i] != s[n - i - 1] and (s[i] == "?" or s[n - i - 1] == "?"):
... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR IF ... |
Chef had an interesting dream last night. He dreamed of a new revolutionary chicken recipe. When he woke up today he tried very hard to reconstruct the ingredient list. But, he could only remember certain ingredients. To simplify the problem, the ingredient list can be represented by a string of lowercase characters 'a... | tests = int(input())
for i in range(tests):
string = input()
length = len(string)
ans = 1
end = (length - 1) // 2 + 1
for j in range(end):
if string[j] == "?" and string[-j - 1] == "?":
ans *= 26
elif string[j] == "?" or string[-j - 1] == "?":
ans *= 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER ST... |
Chef had an interesting dream last night. He dreamed of a new revolutionary chicken recipe. When he woke up today he tried very hard to reconstruct the ingredient list. But, he could only remember certain ingredients. To simplify the problem, the ingredient list can be represented by a string of lowercase characters 'a... | t = int(input())
for i in range(t):
s = input()
c = 1
d = len(s)
for i in range((d + 1) // 2):
j = d - 1 - i
if s[i] != "?" and s[j] != "?" and s[i] != s[j]:
c = 0
break
elif s[i] == "?" and s[j] == "?":
c = c * 26 % 10000009
print(c) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR IF VAR VAR STRING VAR VAR STRING VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR VAR STRING VAR ... |
Chef had an interesting dream last night. He dreamed of a new revolutionary chicken recipe. When he woke up today he tried very hard to reconstruct the ingredient list. But, he could only remember certain ingredients. To simplify the problem, the ingredient list can be represented by a string of lowercase characters 'a... | MOD = 10000009
def count_palindromes(s):
n = len(s)
count = 1
for i in range(n // 2):
j = n - i - 1
if s[i] == "?" and s[j] == "?":
count = count * 26 % MOD
elif s[i] == s[j] or s[i] == "?" or s[j] == "?":
continue
else:
return 0
if n... | ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR STRING VAR VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR IF VAR VAR VAR VAR VAR VAR STRING VAR VAR STRING RETURN NUMBER IF BIN_OP VAR NUMBER NUMBER VA... |
Chef had an interesting dream last night. He dreamed of a new revolutionary chicken recipe. When he woke up today he tried very hard to reconstruct the ingredient list. But, he could only remember certain ingredients. To simplify the problem, the ingredient list can be represented by a string of lowercase characters 'a... | t = 0
try:
t = int(input())
except:
pass
for _ in range(t):
l = input()
n = len(l)
prod = 1
for k in range(n // 2):
i = l[k]
j = l[n - k - 1]
if i != j and (i != "?" and j != "?"):
prod = 0
break
elif i == j and i == "?":
prod *... | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR STRING VAR STRING ASSIGN VAR NUMBER IF VAR VAR ... |
Chef had an interesting dream last night. He dreamed of a new revolutionary chicken recipe. When he woke up today he tried very hard to reconstruct the ingredient list. But, he could only remember certain ingredients. To simplify the problem, the ingredient list can be represented by a string of lowercase characters 'a... | for t in range(int(input())):
s = input()
n = len(s)
c, k = 1, 0
for i in range((len(s) - 1) // 2 + 1):
if s[i] == "?" and s[n - i - 1] == "?":
c = c * 26 % 10000009
elif s[i] == "?" or s[n - i - 1] == "?":
pass
elif s[i] != s[n - i - 1]:
k = 1... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR VAR STRING VAR BIN_OP BIN_OP VAR VAR NUMBER STRING ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF V... |
Chef had an interesting dream last night. He dreamed of a new revolutionary chicken recipe. When he woke up today he tried very hard to reconstruct the ingredient list. But, he could only remember certain ingredients. To simplify the problem, the ingredient list can be represented by a string of lowercase characters 'a... | mod = 10000009
t = int(input())
for _ in range(t):
s = input()
ln = len(s)
dx = 1
for i in range(ln // 2):
xn = ln - i - 1
x = s[i]
y = s[xn]
if x == "?" and y == "?":
dx = dx * 26 % mod
elif x == y:
continue
elif x == "?" or y == "... | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR IF VAR STRING VAR STRING ASSIGN VAR BIN_OP BIN_... |
Chef had an interesting dream last night. He dreamed of a new revolutionary chicken recipe. When he woke up today he tried very hard to reconstruct the ingredient list. But, he could only remember certain ingredients. To simplify the problem, the ingredient list can be represented by a string of lowercase characters 'a... | for _ in range(int(input())):
str1 = str(input())
n = len(str1)
a, b, c = 0, n - 1, 1
while a <= b:
if str1[a] == "?" == str1[b]:
c = c * 26 % 10000009
elif str1[a] != "?" and str1[b] != "?" and str1[a] != str1[b]:
c = 0
break
a += 1
b ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER BIN_OP VAR NUMBER NUMBER WHILE VAR VAR IF VAR VAR STRING VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR VAR STRING VAR VAR STRING VAR VAR VAR VAR ASSIGN VAR NUMBER V... |
Chef had an interesting dream last night. He dreamed of a new revolutionary chicken recipe. When he woke up today he tried very hard to reconstruct the ingredient list. But, he could only remember certain ingredients. To simplify the problem, the ingredient list can be represented by a string of lowercase characters 'a... | for _ in range(int(input())):
s = input()
nWays = 1
n = len(s)
for i in range(n // 2):
if s[i] == "?" and s[-1 - i] == "?":
nWays = nWays * 26 % 10000009
elif s[i] != "?" and s[-1 - i] != "?" and s[i] != s[-i - 1]:
nWays = 0
break
if n % 2 and s[n ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP NUMBER VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR VAR STRING VAR BIN_OP NUMBER VAR STRING VAR VAR VAR BIN_OP VA... |
Chef had an interesting dream last night. He dreamed of a new revolutionary chicken recipe. When he woke up today he tried very hard to reconstruct the ingredient list. But, he could only remember certain ingredients. To simplify the problem, the ingredient list can be represented by a string of lowercase characters 'a... | for _ in range(int(input())):
pal = input().strip()
mul = 0
flag = True
if len(pal) % 2 == 0:
till = len(pal) // 2
else:
till = len(pal) // 2 + 1
for i in range(till):
left, right = pal[i], pal[len(pal) - i - 1]
if left == "?":
if right == "?":
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR BIN_... |
Chef had an interesting dream last night. He dreamed of a new revolutionary chicken recipe. When he woke up today he tried very hard to reconstruct the ingredient list. But, he could only remember certain ingredients. To simplify the problem, the ingredient list can be represented by a string of lowercase characters 'a... | a = int(input())
for _ in range(a):
b = list(input())
s = 1
for i in range(len(b) // 2):
if b[i] == "?" and b[len(b) - 1 - i] == "?":
s = s * 26 % 10000009
elif b[i] == "?" or b[len(b) - 1 - i] == "?":
s *= 1
elif b[i] != b[len(b) - 1 - i]:
s = 0
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR VAR STRING VAR BIN_OP ... |
Chef had an interesting dream last night. He dreamed of a new revolutionary chicken recipe. When he woke up today he tried very hard to reconstruct the ingredient list. But, he could only remember certain ingredients. To simplify the problem, the ingredient list can be represented by a string of lowercase characters 'a... | mod = 10000009
def solve():
s = input()
n = len(s)
c, k = 1, 0
for i in range((len(s) - 1) // 2 + 1):
if s[i] == "?" and s[n - i - 1] == "?":
c = c * 26 % 10000009
elif s[i] == "?" or s[n - i - 1] == "?":
pass
elif s[i] != s[n - i - 1]:
k = 1... | ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR VAR STRING VAR BIN_OP BIN_OP VAR VAR NUMBER STRING ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR VAR STRING VAR BIN_O... |
Chef had an interesting dream last night. He dreamed of a new revolutionary chicken recipe. When he woke up today he tried very hard to reconstruct the ingredient list. But, he could only remember certain ingredients. To simplify the problem, the ingredient list can be represented by a string of lowercase characters 'a... | t = int(input())
while t > 0:
t -= 1
s = input()
n = len(s)
l = 0
r = n - 1
count = 0
imposible = False
while l <= r:
if s[l] == "?" and s[r] == "?":
count += 1
elif s[l] != "?" and s[r] != "?" and s[l] != s[r]:
imposible = True
l += 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR STRING VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR VAR STRING VAR VAR VAR VAR ASSIGN VA... |
Chef had an interesting dream last night. He dreamed of a new revolutionary chicken recipe. When he woke up today he tried very hard to reconstruct the ingredient list. But, he could only remember certain ingredients. To simplify the problem, the ingredient list can be represented by a string of lowercase characters 'a... | for _ in range(int(input())):
s = input()
n = len(s)
count = 0
for i in range(n // 2):
if s[i] != s[n - i - 1]:
if s[i] != "?" and s[n - 1 - i] != "?":
print(0)
break
elif s[i] == "?" and s[n - i - 1] == "?":
count += 1
else:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP BIN_OP VAR NUMBER VAR STRING EXPR FUNC_CALL VAR NUMBER IF VAR VAR STRING VAR BIN_OP B... |
Chef had an interesting dream last night. He dreamed of a new revolutionary chicken recipe. When he woke up today he tried very hard to reconstruct the ingredient list. But, he could only remember certain ingredients. To simplify the problem, the ingredient list can be represented by a string of lowercase characters 'a... | for _ in range(int(input())):
s = list(input())
n = len(s)
an = 1
mod = 10000009
for i in range(n):
if s[i] == "?" and s[n - i - 1] == "?":
an = an * 26 % mod
s[i] = "."
s[n - i - 1] = "."
elif s[i] != "?" and s[n - i - 1] != "?":
if s[... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP BIN_OP VAR VAR NUMBER STRING ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP BI... |
Chef had an interesting dream last night. He dreamed of a new revolutionary chicken recipe. When he woke up today he tried very hard to reconstruct the ingredient list. But, he could only remember certain ingredients. To simplify the problem, the ingredient list can be represented by a string of lowercase characters 'a... | for _ in range(int(input())):
s = input()
i = 0
j = len(s) - 1
cnt = 1
f = 1
while i <= j:
if s[i] == "?" and s[j] == "?":
cnt = cnt * 26 % 10000009
elif s[i] == "?" or s[j] == "?":
pass
elif s[i] != s[j]:
f = -1
break
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR STRING VAR VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR VAR STRING VAR VAR STRING IF VAR VAR VAR VAR ASSIGN... |
Chef had an interesting dream last night. He dreamed of a new revolutionary chicken recipe. When he woke up today he tried very hard to reconstruct the ingredient list. But, he could only remember certain ingredients. To simplify the problem, the ingredient list can be represented by a string of lowercase characters 'a... | for _ in range(int(input())):
s = input()
l = len(s)
flag = False
count = 0
if l % 2 == 1:
if s[l // 2] == "?":
count += 1
for i in range(0, l // 2):
if s[i] == "?" and s[l - i - 1] == "?":
count += 1
elif s[i] != s[l - i - 1] and s[i] != "?" and s... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP BIN_OP VAR VAR NUMBER STRING VAR ... |
Chef had an interesting dream last night. He dreamed of a new revolutionary chicken recipe. When he woke up today he tried very hard to reconstruct the ingredient list. But, he could only remember certain ingredients. To simplify the problem, the ingredient list can be represented by a string of lowercase characters 'a... | tc = int(input())
for _ in range(tc):
s = input()
n = len(s)
ans = 1
for i in range(n // 2):
x = (s[i] == "?") + (s[n - i - 1] == "?")
if x == 2:
ans = ans * 26 % 10000009
elif x == 0 and s[i] != s[n - i - 1]:
ans = 0
break
if n % 2 == 1 an... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR STRING VAR BIN_OP BIN_OP VAR VAR NUMBER STRING IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR NUMBER... |
Chef had an interesting dream last night. He dreamed of a new revolutionary chicken recipe. When he woke up today he tried very hard to reconstruct the ingredient list. But, he could only remember certain ingredients. To simplify the problem, the ingredient list can be represented by a string of lowercase characters 'a... | t = int(input())
for _ in range(t):
s = input()
s = [i for i in s]
n = len(s)
c = 1
mc = 1
for i in range(len(s)):
if s[i] == "?" and s[abs(n - 1 - i)] == "?":
s[abs(n - 1 - i)] = s[i] = "a"
c *= 26
elif s[i] != s[abs(n - 1 - i)] and s[i] != "?" and s[abs(... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_O... |
Chef had an interesting dream last night. He dreamed of a new revolutionary chicken recipe. When he woke up today he tried very hard to reconstruct the ingredient list. But, he could only remember certain ingredients. To simplify the problem, the ingredient list can be represented by a string of lowercase characters 'a... | def solve():
s = input()
n = len(s)
c = 1
for i in range((n - 1) // 2 + 1):
if s[i] == "?" and s[n - i - 1] == "?":
c = c * 26 % 10000009
elif s[i] == "?" or s[n - i - 1] == "?":
c = c * 1
elif s[i] != s[n - i - 1]:
c = 0
break
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR STRING VAR BIN_OP BIN_OP VAR VAR NUMBER STRING ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR VAR STRING VAR BIN_OP BIN_OP VAR VAR NUMBER STRING ASSIGN VAR B... |
Chef had an interesting dream last night. He dreamed of a new revolutionary chicken recipe. When he woke up today he tried very hard to reconstruct the ingredient list. But, he could only remember certain ingredients. To simplify the problem, the ingredient list can be represented by a string of lowercase characters 'a... | for _ in range(int(input())):
s = input()
nWays = 1
n = len(s)
f = True
for i in range(n // 2):
if s[i] == s[-i - 1]:
if s[i] == "?":
nWays = nWays * 26 % (10**7 + 9)
elif s[i] == "?" and s[-i - 1] != "?" or s[i] != "?" and s[-i - 1] == "?":
co... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER IF VAR VAR STRING ... |
Chef had an interesting dream last night. He dreamed of a new revolutionary chicken recipe. When he woke up today he tried very hard to reconstruct the ingredient list. But, he could only remember certain ingredients. To simplify the problem, the ingredient list can be represented by a string of lowercase characters 'a... | test = int(input())
for _ in range(test):
strText = input()
n = len(strText)
ans = 1
rangeCheck = n
if n % 2 == 0:
rangeCheck = rangeCheck // 2
else:
rangeCheck = rangeCheck // 2 + 1
if len(strText) == strText.count("?"):
ans = ans * 26**rangeCheck % (10**7 + 9)
e... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP V... |
Chef had an interesting dream last night. He dreamed of a new revolutionary chicken recipe. When he woke up today he tried very hard to reconstruct the ingredient list. But, he could only remember certain ingredients. To simplify the problem, the ingredient list can be represented by a string of lowercase characters 'a... | for t in range(int(input())):
s = input()
ans = 1
b = 0
du = len(s)
if du == 1:
if s[0] == "?":
print(26)
else:
print(1)
else:
for i in range(du // 2):
if s[i] == "?" and s[-i - 1] == "?":
ans = ans * 26 % 10000009
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR NUMBER STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING ASSIGN... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
total_candies = 0
open_boxes = [box for box in initialBoxes if status[box] == 1... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR LIST WHILE FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FOR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
currkeys, ret, taken = set(), 0, [0] * len(status)
q = collections.deque(initia... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER IF VAR VAR VAR VA... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
open_box = []
close_box = set()
key_set = set([i for i in range(len(sta... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FU... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
q = initialBoxes
has_key = [0] * len(status)
has_open = [0] * len(statu... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR LIST FOR VAR VAR IF VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR NUMBER FOR VAR VAR VAR IF VAR VAR EXPR F... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
candy_count = 0
my_boxes = initialBoxes
my_keys = []
while my_b... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR LIST WHILE VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR V... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Box:
def __init__(self, status, candies, keys, boxes):
self.status = status
self.candies = candies
self.keys = keys
self.containedBoxes = boxes
def openboxes(unopened, keys, Q):
for u in unopened:
if u in keys:
Q.append(u)
unopened.remove(... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
boxes = set(initialBoxes)
queue = collections.deque()
for box in boxes:... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR FOR VAR VAR VAR EXPR F... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
key_set = set()
box_set = set()
used = set()
queue = collection... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR FUNC_CALL VAR IF VAR VAR IF VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR IF... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
N = len(status)
scores = [0] * N
for i in range(N):
scores[... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR ASSIGN VAR LIST FOR VAR VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER WHILE... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
boxes = set(initialBoxes)
openedBox = set()
bfs = [i for i in boxes if ... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VA... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
reachable = [False] * len(status)
visited = [False] * len(status)
for b... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR LIST ASSIGN VAR NUM... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
s = [b for b in initialBoxes if status[b]]
found_boxes = set([b for b in initia... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FOR VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXP... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
res, bcache, kcache = 0, set(initialBoxes), set()
for _ in range(1000):
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER FUNC_CALL VAR VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR VAR NUMBER VAR VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR R... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
OPEN, CLOSED = 1, 0
q = deque(initialBoxes)
keys_obtained = set(i for i... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR IF VA... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
reached = set()
visited = set()
q = initialBoxes
yummy = 0
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR VAR V... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
reachable = [(False) for _ in status]
for i in initialBoxes:
reacha... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER VAR VAR FOR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
ret = 0
n = len(status)
available_to_open = [box for box in initialBoxe... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR IF VAR VAR NUMBER VAR VAR VAR ASSIGN VAR VAR NUMBER FOR VAR VAR VAR EXPR F... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
if not initialBoxes:
return 0
visited = set()
boxes = set()... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR IF VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR WHILE VAR ASSIGN VAR FUNC_CALL V... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
n = len(status)
visited = [0] * n
unopened = [0] * n
opened = [... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER WHILE VAR ASSIGN VAR LIST... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
foundBoxes = set(initialBoxes)
openBoxes = [box for box in foundBoxes if status... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR NUMBER FOR VAR VAR FOR VAR VAR VAR EXPR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR VAR VAR IF VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER RETURN ... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
N = len(status)
queue = list()
unopened = set()
for i in initia... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER VAR VAR VAR FOR V... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
if len(initialBoxes) == 0:
return 0
else:
boxdict = {}
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR VAR LIST NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR FOR VAR VAR VAR ASSI... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
n = len(status)
hold = initialBoxes
res = 0
key = set()
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR IF VAR VAR NUMBER VAR VAR NUMBER VAR VA... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
locked_boxes = set()
unused_keys = set()
candy_count = 0
cur_bo... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR VAR VAR VAR VAR VAR VAR FOR VAR VAR VAR IF VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR VAR VAR IF ... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
active_set = initialBoxes
total_candies = 0
changed = True
whil... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR VAR ASSIGN VAR NUMBER VAR VAR VAR FOR VAR VAR VAR ASSIGN VAR VAR NUMBER VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR RETURN VAR VAR FU... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(self, status, candies, keys, containedBoxes, initialBoxes):
n = len(status)
access = [0] * n
source = []
visited = set()
for i in initialBoxes:
access[i] = 1
visited.add(i)
source.append(i)
ans = 0
... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FOR VAR VAR VAR ASSIGN VAR VAR NUMBER FOR VAR VAR VA... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
q = collections.deque()
keys_set = set([i for i in range(len(status)) if status... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
n = len(status)
self.count = 0
queue = collections.deque([i for i in in... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
totalBox = len(status)
gotBoxes = set(initialBoxes)
i = 0
ans =... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR FOR VAR VAR VAR IF VAR ... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
total = 0
boxes = initialBoxes[:]
locked = []
while boxes:
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR LIST WHILE VAR IF FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR VAR VAR FOR VAR VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR VAR VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
q = collections.deque()
keys_set = set()
boxes_set = set()
for ... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR VAR VAR EXPR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VA... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
found = [0] * len(status)
hasKeys = status
queue = collections.deque()
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FOR VAR VAR VAR ASSIGN VAR VAR N... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
q = collections.deque()
for box in initialBoxes:
q.append(box)
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR IF VAR VAR NUMBER VA... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(self, status, candies, keys, containedBoxes, initialBoxes):
ret = 0
collected_keys = set()
opened = set()
queue = initialBoxes
while queue:
cont = False
for i in range(len(queue)):
box_index = queue.pop(0... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR WHILE VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR VAR IF VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
if not initialBoxes:
return 0
if 1 not in status:
retur... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR IF VAR RETURN NUMBER IF NUMBER VAR RETURN NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR NUMBER ASSIGN VAR NUMBER VAR VAR VAR VAR VAR VAR FOR VAR VAR VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VA... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
if not initialBoxes:
return 0
unused_keys = set()
boxes = s... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR IF VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FOR VAR VAR VAR IF VAR VAR EXPR FUNC_C... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
open = initialBoxes
x_keys = set()
locked = set()
result = 0
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER IF VAR VAR FOR VAR VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR VAR VAR IF VAR VAR VAR V... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
n = len(status)
boxes = []
unboxes = set()
for b in initialBoxe... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR VAR VAR VAR VAR E... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
def dfs(i):
if i in visited:
return
if status[... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR FUNC_DEF IF VAR VAR RETURN IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN EXPR FUNC_CALL VAR VAR VAR VAR VAR FOR VAR VAR VAR ASSIGN VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VA... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
done = set()
to_open = set()
current_keys = set()
opened = list... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR FUNC_CALL VAR IF VAR VAR VAR VAR VAR E... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
maximum = 0
cur = []
closeddic = dict()
size = 0
for i ... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR LIST ASSIGN ... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
self.keys_found = set()
self.boxes_found = set()
self.boxes_found.updat... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
q = []
res = 0
vis = set()
collected = set()
for i in i... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR ... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
stack = deque(initialBoxes)
seen = set()
kseen = set()
while st... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR WHILE VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FOR VAR VAR VAR ASSIGN VAR VAR NUMBER FOR VAR VAR VAR IF VAR VAR EXPR FUNC_C... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(self, status, candies, keys, containedBoxes, initialBoxes):
boxes = set(initialBoxes)
bfs = [i for i in boxes if status[i]]
for i in bfs:
for j in containedBoxes[i]:
boxes.add(j)
if status[j]:
bfs... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR FOR VAR VAR FOR VAR VAR VAR EXPR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR VAR VAR IF VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER RETURN FUNC_CALL VAR VAR VAR VAR VAR |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
keyHold = set([idx for idx, b in enumerate(status) if b == 1])
boxHold = set(in... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR WHILE NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
d = dict()
arr = []
key = []
for i in range(0, len(status)):
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR LIST VAR VAR VAR VAR VAR VAR VAR VAR IF VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER AS... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
maxCandy = 0
keyset = set()
numbox = len(status)
q = list(initi... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST WHILE VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER VAR VAR VAR VAR VAR ASSIGN VAR VAR N... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
parent = collections.defaultdict(int)
for i, row in enumerate(containedBoxes):
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR FOR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR FUNC_CALL VAR IF VAR V... |
Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:
status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
candies[i]: an integer representing the number of candies in box[i].
keys[i]: an array contains the indices of the boxes you can open with the key ... | class Solution:
def maxCandies(
self,
status: List[int],
candies: List[int],
keys: List[List[int]],
containedBoxes: List[List[int]],
initialBoxes: List[int],
) -> int:
q, res = collections.deque(initialBoxes), 0
while q:
l = len(q)
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER WHILE VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR FOR VAR VAR VAR ASSIGN VAR VAR NUMBER EXPR F... |
Do you know that The Chef has a special interest in palindromes? Yes he does! Almost all of the dishes in his restaurant is named by a palindrome strings. The problem is that a name of a dish should not be too long, so The Chef has only limited choices when naming a new dish.
For the given positive integer N, your tas... | def power(n):
if n == 0:
return 1
else:
tmp = power(n // 2) % 1000000007 % 1000000007
if n % 2 == 1:
return 26 * tmp * tmp % 1000000007
else:
return tmp * tmp % 1000000007
def powernext(n):
if n == 0:
return 1
else:
tmp = powernex... | FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER RETURN BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER RETURN BIN_OP BIN_OP VAR VAR NUMBER FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMB... |
Do you know that The Chef has a special interest in palindromes? Yes he does! Almost all of the dishes in his restaurant is named by a palindrome strings. The problem is that a name of a dish should not be too long, so The Chef has only limited choices when naming a new dish.
For the given positive integer N, your tas... | M = 10**9 + 7
for _ in range(int(input())):
n = int(input())
ans = 52 * (pow(26, n // 2, M) - 1) * pow(25, M - 2, M)
if n % 2 == 1:
ans += pow(26, n // 2 + 1, M)
print(ans % M) | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR IF BIN_OP VAR NUMBER NUMBER VAR FUNC_CALL VAR NUMBER ... |
Do you know that The Chef has a special interest in palindromes? Yes he does! Almost all of the dishes in his restaurant is named by a palindrome strings. The problem is that a name of a dish should not be too long, so The Chef has only limited choices when naming a new dish.
For the given positive integer N, your tas... | mod = 1000000007
for _ in range(int(input())):
n = int(input())
if n == 1:
print(26)
elif n == 2:
print(52)
else:
k = -(-n // 2)
if n % 2 == 0:
ans = 26 * (
1 + 26 * (pow(26, k - 1, mod) - 1) * pow(26 - 1, mod - 2, mod)
) + 26 * (1 ... | ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP NUMBER BIN_OP BIN_OP NUMBER BIN_OP FU... |
Do you know that The Chef has a special interest in palindromes? Yes he does! Almost all of the dishes in his restaurant is named by a palindrome strings. The problem is that a name of a dish should not be too long, so The Chef has only limited choices when naming a new dish.
For the given positive integer N, your tas... | mdl = 1000000007
i25 = pow(25, mdl - 2, mdl)
for _ in range(int(input())):
n = int(input())
k = n // 2 + 1
ko = ke = pow(26, k, mdl) - 1
if 1 == n % 2:
ko = ((ko + 1) * 26 - 1) % mdl
tot = ((ko + ke) * i25 - 2) % mdl
if tot < 0:
tot += mdl
print(tot) | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP FUNC_CALL VAR NUMBER VAR VAR NUMBER IF NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_O... |
Do you know that The Chef has a special interest in palindromes? Yes he does! Almost all of the dishes in his restaurant is named by a palindrome strings. The problem is that a name of a dish should not be too long, so The Chef has only limited choices when naming a new dish.
For the given positive integer N, your tas... | def topowermod(v, e, m):
op = 1
v %= m
be = bin(e)
for c in be[2:]:
op = op * op % m
if "1" == c:
op = op * v % m
return op
def modinv(v, m):
v %= m
tb = [(m, 1, 0), (v, 0, 1)]
while tb[-1][0] > 0:
q = tb[-2][0] // tb[-1][0]
nr = list(tb[-2])... | FUNC_DEF ASSIGN VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF STRING VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR RETURN VAR FUNC_DEF VAR VAR ASSIGN VAR LIST VAR NUMBER NUMBER VAR NUMBER NUMBER WHILE VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER VA... |
Do you know that The Chef has a special interest in palindromes? Yes he does! Almost all of the dishes in his restaurant is named by a palindrome strings. The problem is that a name of a dish should not be too long, so The Chef has only limited choices when naming a new dish.
For the given positive integer N, your tas... | T = int(input())
inv = 280000002
mod = 1000000007
for i in range(T):
n = int(input())
if n % 2 == 0:
n = n // 2 + 1
a = 2 * ((pow(26, n, mod) - 1) * inv - 1) % mod
print(a)
else:
n = n // 2 + 2
a = 2 * ((pow(26, n, mod) - 1) * inv - 1) % mod
a = (a - pow(26, n... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP BIN_OP BIN_OP FUNC_CALL VAR NUMBER VAR VAR NUMBER VAR NUMBER VAR EXPR ... |
Do you know that The Chef has a special interest in palindromes? Yes he does! Almost all of the dishes in his restaurant is named by a palindrome strings. The problem is that a name of a dish should not be too long, so The Chef has only limited choices when naming a new dish.
For the given positive integer N, your tas... | def exp(a, n):
if n == 1:
return a
elif n % 2:
temp = exp(a, n // 2)
return temp % 1000000007 * temp % 1000000007 * a % 1000000007
else:
temp = exp(a, n // 2)
return temp % 1000000007 * temp % 1000000007 % 1000000007
def ans(n):
if n == 1:
return 26
... | FUNC_DEF IF VAR NUMBER RETURN VAR IF BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER FUNC_DEF IF VAR NUMBER RETURN NU... |
Do you know that The Chef has a special interest in palindromes? Yes he does! Almost all of the dishes in his restaurant is named by a palindrome strings. The problem is that a name of a dish should not be too long, so The Chef has only limited choices when naming a new dish.
For the given positive integer N, your tas... | mod = 10**9 + 7
inv = pow(25, mod - 2, mod)
for i in range(int(input())):
N = int(input())
if N % 2 == 0:
r = 2 * 26 * (pow(26, N // 2, mod) - 1) % mod * inv % mod
else:
r = (27 * pow(26, N // 2 + 1, mod) - 52) % mod * inv % mod
print(r) | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP NUMBER NUMBER BIN_OP FUNC_CALL VAR NUMBER BIN_OP VAR NUMB... |
Do you know that The Chef has a special interest in palindromes? Yes he does! Almost all of the dishes in his restaurant is named by a palindrome strings. The problem is that a name of a dish should not be too long, so The Chef has only limited choices when naming a new dish.
For the given positive integer N, your tas... | def permutation(n, p):
r = 26
if n == 1:
return 26
elif n == 2:
return 52
elif n == 3:
return 728
elif n % 2 == 0:
return 2 * (bin_expo(r, n // 2 + 1, p) - r) * bin_expo(25, 1000000005, p) % p
else:
n = n + 1
return (
2 * ((bin_expo(r, ... | FUNC_DEF ASSIGN VAR NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF BIN_OP VAR NUMBER NUMBER RETURN BIN_OP BIN_OP BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR FUNC_CALL VAR NUMBER NUMBER VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN BIN_OP BI... |
Do you know that The Chef has a special interest in palindromes? Yes he does! Almost all of the dishes in his restaurant is named by a palindrome strings. The problem is that a name of a dish should not be too long, so The Chef has only limited choices when naming a new dish.
For the given positive integer N, your tas... | T = int(input())
for t in range(T):
N = int(input())
if N % 2 == 0:
print(int(560000006 * (pow(26, N // 2, 1000000007) - 1)) % 1000000007)
else:
print(
(
int(560000006 * (pow(26, N // 2, 1000000007) - 1))
+ pow(26, N // 2 + 1, 1000000007)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR BIN_OP NUMBER BIN_OP FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP NUMBER BIN_OP... |
Do you know that The Chef has a special interest in palindromes? Yes he does! Almost all of the dishes in his restaurant is named by a palindrome strings. The problem is that a name of a dish should not be too long, so The Chef has only limited choices when naming a new dish.
For the given positive integer N, your tas... | mbase = 10**9 + 7
inv_25 = 280000002
t = int(input())
for it in range(t):
n = int(input())
m = n // 2
pow26mp1 = pow(26, m + 1, mbase)
res = 2 * (pow26mp1 - 26) * inv_25
if n % 2 == 1:
res += pow26mp1
res %= mbase
print(res) | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER VAR IF BIN_OP VAR N... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.