class Solution:
def minOperations(self, logs: List[str]) -> int:
depth = 0
for path in logs:
if path == '../':
depth = max(0, depth - 1)
elif path == './':
pass
else:
depth += 1
return depth


class Solution:
def minOperationsMaxProfit(self, customers: List[int], boardingCost: int, runningCost: int) -> int:
if 4 * boardingCost <= runningCost:
return -1
cnt = profit = 0
total = 0
cprofit = ccnt = 0
for i, c in enumerate(customers):
if ccnt < i:
cprofit += total * boardingCost - (i - ccnt) * runningCost
ccnt = i
total = 0
total += c
t = total // 4
cprofit += (4 * boardingCost - runningCost) * t
ccnt += t
total %= 4
if cprofit > profit:
profit, cnt = cprofit, ccnt
if total > 0:
cprofit += (total * boardingCost - runningCost)
ccnt += 1
if cprofit > profit:
profit, cnt = cprofit, ccnt
if cprofit > 0:
return cnt
return -1


class ThroneInheritance:

def __init__(self, kingName: str):
self.king = kingName
self.children = collections.defaultdict(list)
self.deaths = set()

def birth(self, parentName: str, childName: str) -> None:
self.children[parentName].append(childName)

def death(self, name: str) -> None:

def getInheritanceOrder(self) -> List[str]:
ans = []
deaths = self.deaths
children = self.children
def dfs(root):
if root not in deaths:
ans.append(root)
for c in children[root]:
dfs(c)
dfs(self.king)
return ans


class Solution:
def maximumRequests(self, n: int, requests: List[List[int]]) -> int:
ans = [0]
reqs = []
for a, b in requests:
if a == b:
ans[0] += 1
else:
reqs.append([a, b])

def dfs(i, cnt, deg):
if i == len(reqs):
if all(v == 0 for v in deg.values()):
ans[0] = max(ans[0], cnt)
else:
dfs(i + 1, cnt, deg)
a, b = reqs[i]
deg[a] -= 1
deg[b] += 1
dfs(i + 1, cnt + 1, deg)
deg[a] += 1
deg[b] -= 1

dfs(0, ans[0], collections.Counter())
return ans[0]