1.2 l = int(input()) s = list(map(int, input().split())) tup = [0] tr2 = [0] for i in range(l): while tup[-1] == tr2[-1] + 1: tr2.append(tup[-1]) tup.pop() if s[i] == tr2[-1] + 1: tr2.append(s[i]) else: tup.append(s[i]) while tup[-1] == tr2[-1] + 1: tr2.append(tup[-1]) tup.pop() if tr2[-1] == l: print('YES') else: print('NO') 1.4 expression = input() stack = [] incorrect_count = 0 for char in expression: if char == '(': stack.append(char) elif char == ')': if stack: stack.pop() else: incorrect_count += 1 incorrect_count += len(stack) if incorrect_count == 0: print("Yes") else: print("No. Incorrect brackets =", incorrect_count) 1.5 st = input().split() stack = [] for x in st: if x in "+-*/": op2 = int(stack.pop()) op1 = int(stack.pop()) if x == "+": res = op1 + op2 elif x == "-": res = op1 - op2 elif x == "*": res = op1 * op2 else: res = op1 // op2 stack.append ( res ) else: stack.append ( x ) print (stack[0])