description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | t = input()
s = input()
zeros = 0
ones = 0
for i in s:
if i == "(":
zeros += 1
elif i == ")":
ones += 1
s = list(s)
i = 0
nbr_1 = 0
nbr_0 = 0
while i < len(s):
if nbr_1 >= nbr_0 and nbr_1 != 0:
break
if s[i] == "(":
nbr_0 += 1
zeros -= 1
elif s[i] == ")":
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR NUMBER... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
if n % 2 == 1:
print(":(")
exit(0)
s = list(input())
d = 0
count1 = s.count("?")
count2 = s.count("(")
count3 = s.count(")")
i = n - 1
while count2 - count3 > 0:
if i < 0:
print(":(")
exit(0)
if s[i] == "?":
s[i] = ")"
count3 += 1
count1 -= 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER WHILE BIN_OP VAR VA... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = input()
x = []
res = []
o1, c1 = 0, 0
for i in s:
x.append(i)
if i == "(":
o1 += 1
elif i == ")":
c1 += 1
if n % 2:
print(":(")
elif x[0] == ")" or x[n - 1] == "(":
print(":(")
else:
o, c = n / 2 - o1, n / 2 - c1
o2, c2 = 0, 0
for i in range(n):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR EXPR FUNC_CALL VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CAL... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | open_list = ["("]
close_list = [")"]
def check(myStr):
stack = []
for i in myStr:
if i in open_list:
stack.append(i)
elif i in close_list:
pos = close_list.index(i)
if len(stack) > 0 and open_list[pos] == stack[len(stack) - 1]:
stack.pop()
... | ASSIGN VAR LIST STRING ASSIGN VAR LIST STRING FUNC_DEF ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR RETURN NUMBER IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = input().strip()
if n % 2 != 0:
print(":(")
exit()
upper = 0
uppers = []
lower = 0
for c in s[:-1]:
if c == "(":
upper += 1
lower += 1
elif c == ")":
upper -= 1
lower -= 1
if upper <= 0:
print(":(")
exit()
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR NUMBER IF VAR STRING VAR NUMBER VAR NUMBER IF VAR STRING VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL V... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | kk = lambda: map(int, input().split())
ll = lambda: list(kk())
n, s = int(input()), list(input())
if s[-1] == "(" or s[0] == ")" or n % 2 == 1:
print(":(")
exit()
qcount = ocount = ccount = 0
for i in range(n):
if s[i] == "?":
qcount += 1
elif s[i] == "(":
ocount += 1
else:
c... | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER STRING VAR NUMBER STRING BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR ... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
l = list(input())
if n % 2 == 1:
print(":(")
exit()
if n == 2:
if l[0] == ")" or l[1] == "(":
print(":(")
else:
print("()")
exit()
if l[0] == ")" or l[1] == ")" or l[-1] == "(" or l[-2] == "(":
print(":(")
exit()
l[0] = "("
l[1] = "("
l[-1] = ")"
l[-2] = ")"
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER STRING VAR NUMBER STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF VAR NUMBER STRING VAR NUMBER STRING VAR NU... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | N = int(input())
S = input()
left = S.count("(")
right = S.count(")")
plus = 0
ans = ""
for i in range(N):
if S[i] == "?":
if left < N // 2:
ans += "("
plus += 1
left += 1
else:
ans += ")"
plus -= 1
right += 1
elif S[i] == "... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER VAR STRING VAR NUMBER VAR NUMBER VAR STRING VAR NUMBER VAR NUMBER IF VAR VAR STRING VAR... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
if n % 2:
print(":(")
exit(0)
s = list(input())
ans = ""
c1, c2 = s.count("("), s.count(")")
cnt90 = 0
cnt9, cnt0 = 0, 0
for i in s[:-1]:
if i == "(":
cnt90 += 1
if cnt9 + cnt90 > n // 2:
print(":(")
exit(0)
ans += i
elif i == ")":
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR NUMBER IF VAR STRING VAR NUMBER IF ... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | def solve():
n = int(input())
s = list(input())
if n % 2:
print(":(")
return
cv = s.count("?")
co = s.count("(")
cc = s.count(")")
b = 0
for i in range(n):
if s[i] == "(":
b += 1
elif s[i] == ")":
b -= 1
elif co < n // 2:
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
o = 0
work = True
s = list(input())
a = [0] * n
op = [0] * n
o = 0
c = 0
k = n - 1
for i in s[::-1]:
a[k] = c
op[k] = o
k -= 1
if i != "(":
c += 1
else:
o += 1
o = 0
for j, i in enumerate(s):
if o == 0 and j != 0:
work = False
break
if i == "(... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR VAR NUMBER IF VA... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = input()
if n % 2:
print(":(")
exit()
ans = ""
o = 0
c = 0
for i in s:
if i == "(":
o += 1
elif i == ")":
c += 1
if o > n // 2 or c > n // 2:
print(":(")
exit()
o = n // 2 - o
for i in s:
if i == "?":
if o:
o -= 1
ans += "("... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING E... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | import sys
n = int(input())
s = input()
if n % 2 == 1:
print(":(")
sys.exit(0)
d = {}
d["("] = 1
d[")"] = -1
d["?"] = 0
suma = 0
cale = 0
dop = [[0, 0] for i in range(n)]
dop[n - 1] = [0, 0]
for i in range(1, n):
j = n - i - 1
if s[j + 1] == ")":
dop[j] = [max(1, dop[j + 1][0] + 1), dop[j + 1][... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR DICT ASSIGN VAR STRING NUMBER ASSIGN VAR STRING NUMBER ASSIGN VAR STRING NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER VAR FUNC_CAL... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | l = int(input())
s = list(input())
count = s.count("(")
pair_count = 0
if l % 2 != 0:
print(":(")
exit(0)
if count > l // 2:
print(":(")
exit(0)
for ind in range(l):
if s[ind] == "?":
if count < l // 2:
s[ind] = "("
count += 1
else:
s[ind] = ")"
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VA... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = list(input())
if n % 2:
print(":(")
quit()
l = n // 2 - s.count("(")
for i in range(n):
if s[i] == "?":
if l > 0:
s[i] = "("
l -= 1
else:
s[i] = ")"
bal = 0
if s[0] != "(" or s[-1] != ")":
print(":(")
quit()
for i in range(n):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR NUMBER ASSIGN VAR VAR STRING VAR NUMBER ASSIGN VAR VAR STRING ASSIGN... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = input()
if n % 2:
print(":(")
else:
k = ""
b = [0] * n
open1 = 0
close1 = 0
ind = n
mn = 10**9
open2 = 0
close2 = 0
for i in range(n):
if s[i] == ")":
close1 += 1
elif s[i] == "(":
open1 += 1
for i in range(n):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR STRING ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR S... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = input()
if n % 2 != 0:
print(":(")
else:
total_left = n / 2 - s.count("(")
k = []
c, i = 0, 0
while i < n:
if s[i] == "(":
k.append("(")
c += 1
elif s[i] == ")":
k.append(")")
c -= 1
elif total_left > 0:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR VAR NUMBER NUMBER WHILE VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR STRING VAR NUMBER IF VAR VAR STRING EXPR FUNC_CAL... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
if n % 2:
print(":(")
return
s = [c for c in input()]
if s[0] == ")" or s[-1] == "(":
print(":(")
return
s[0] = "("
s[-1] = ")"
count_open = s.count("(")
count_close = s.count(")")
half = n // 2
if count_close > half or count_open > half:
print(":(")
return
available = half - co... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR VAR VAR FUNC_CALL VAR IF VAR NUMBER STRING VAR NUMBER STRING EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR NUMBER STRING ASSIGN VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN V... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
a = list(input())
if n % 2:
print(":(")
exit(0)
cnt = 0
osc = a.count("(")
ans = osc <= n // 2
for i in range(len(a)):
if a[i] == "?":
if osc == n // 2:
a[i] = ")"
cnt -= 1
else:
a[i] = "("
cnt += 1
osc += 1
eli... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER ASS... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | import sys
length = int(input())
op = 0
ret = "("
word = input()
if length % 2 == 1 or word[0] == ")" or word[-1] == "(":
print(":(")
sys.exit()
word2 = word[1:-1]
mc = word2.count(")")
mo = word2.count("(")
goal = (length - 2) // 2
nc = goal - mc
no = goal - mo
if nc < 0 or no < 0:
print(":(")
sys.exi... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER STRING VAR NUMBER STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR ... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | sctype = {"(": 0, ")": 1, "?": -1}
ln = int(input())
s = list(input())
if s[0] == ")" or ln % 2 == 1:
print(":(")
exit()
s[0] = "("
opp = 0
opl = 1
op = []
r = True
pspt = [0, 0]
for i in range(ln):
if sctype[s[i]] == -1:
opl += 1
else:
pspt[sctype[s[i]]] += 1
op.append([opp, opl... | ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER STRING BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR NUMBER STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBE... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | kol = int(input())
s = input()
leftB = s.count("(")
rightB = s.count(")")
q = s.count("?")
sres = ""
for i in range(kol):
if s[i] == "?":
if leftB * 2 < kol:
sres += "("
leftB += 1
else:
sres += ")"
else:
sres += s[i]
count = 0
for i in range(kol):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR NUMBER VAR VAR STRING VAR NUMBER VAR STRING VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FU... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input(""))
s = list(input(""))
x = 0
y = 0
p = 0
q = 0
z = 0
m = 0
for i in range(n):
if s[i] == "(":
m += 1
if n % 2 == 1:
print(":(")
else:
for i in range(n - 1):
if s[-i - 1] == "(":
x += 1
else:
y += 1
if s[i] == ")":
p += 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUN... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | def mp():
return map(int, input().split())
n = int(input())
s = list(input())
b = 0
o = n // 2 - s.count("(")
for i in range(n):
if s[i] == "(":
b += 1
elif s[i] == ")":
b -= 1
elif o > 0:
s[i] = "("
b += 1
o -= 1
else:
s[i] = ")"
b -= 1
b = ... | FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR NUMBER ASSIGN VAR ... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | def solve(s, n):
if n % 2 == 1:
return None
a = n // 2 - s.count("(")
b = n // 2 - s.count(")")
if a < 0 or b < 0:
return None
x = []
for e in s:
if e == "?":
if a > 0:
x.append("(")
a -= 1
else:
x.ap... | FUNC_DEF IF BIN_OP VAR NUMBER NUMBER RETURN NONE ASSIGN VAR BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER RETURN NONE ASSIGN VAR LIST FOR VAR VAR IF VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR STRING VAR NUMBER EXPR FUNC_CALL VAR STRING V... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | _str = str
n, str = int(input()), list(input())
if str[0] == "?":
str[0] = "("
if str[-1] == "?":
str[-1] = ")"
pp, nn = n // 2, n // 2
for ch in str:
if ch == "(":
pp -= 1
if ch == ")":
nn -= 1
if n % 2 == 1 or str[0] != "(" or str[-1] != ")" or pp < 0 or nn < 0:
print(":(")
exi... | ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER STRING ASSIGN VAR NUMBER STRING IF VAR NUMBER STRING ASSIGN VAR NUMBER STRING ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER IF BIN_OP VAR NUMBER NUMBER V... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | def main():
n = int(input())
s = input()
n_open = s.count("(")
n_close = s.count(")")
n_blank = s.count("?")
need_n_open = len(s) / 2 - n_open
if need_n_open < 0:
print(":(")
return
res = ""
cnt = 0
for i in range(len(s)):
c = s[i]
if c == "(":
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_C... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = input()
s = list(s)
a = n // 2 - s.count("(")
b = n - a - s.count(")")
for i in range(n):
if s[i] == "?":
s[i] = "("
a -= 1
if a <= 0:
break
for i in range(n):
if s[i] == "?":
s[i] = ")"
b -= 1
if b <= 0:
break
c = 0
for i in range(n):... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR STRING VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = list(input())
l = s.count("(")
r = s.count(")")
for i in range(n):
if s[i] == "?":
if 2 * l < n:
l += 1
s[i] = "("
else:
s[i] = ")"
cnt = 0
for i in range(n):
cnt += 1 if s[i] == "(" else -1
if i < n - 1 and cnt < 1:
print(":("... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP NUMBER VAR VAR VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VA... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
st = list(input())
if n % 2 == 1:
print(":(")
else:
open = st.count("(")
close = 0
if open > n // 2:
print(":(")
else:
for e in range(len(st)):
if st[e] == "?":
if open < n / 2:
st[e] = "("
open += 1... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER ASSI... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = list(input())
l, r = s.count("("), s.count(")")
for i in range(n):
if s[i] == "?" and 2 * l < n:
s[i] = "("
l += 1
elif s[i] == "?" and 2 * l >= n:
s[i] = ")"
cnt = 0
for i in range(n):
cnt = cnt + 1 if s[i] == "(" else cnt - 1
if cnt <= 0 and i < n - 1 or cn... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING BIN_OP NUMBER VAR VAR ASSIGN VAR VAR STRING VAR NUMBER IF VAR VAR STRING BIN_OP NUMBER VAR VAR ASSIGN VAR VAR STRING ASSIGN VAR NUMBER FOR VA... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = list(input())
if n % 2 == 1 or s[0] == ")" or s[len(s) - 1] == "(":
print(":(")
else:
q = s.count("?")
dl = s.count("(")
dr = s.count(")")
t = (dl + dr + q) // 2
if dl > dr:
t = t - dl
dl = t
dr = q - t
elif dr > dl:
t = t - dr
dr ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER STRING VAR BIN_OP FUNC_CALL VAR VAR NUMBER STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP BIN_OP... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | def readint():
return int(input())
n = readint()
s = input()
a = 0
b = 0
for c in s:
if c == "(":
a += 1
elif c == ")":
b += 1
x = n - (a + b)
m = a - b
p = x - m
p /= 2
r = []
for c in s:
if c == "?":
if p:
p -= 1
r += "("
else:
r +=... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR LIST FOR VAR VAR ... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
state = list(input())
if ")" == state[0] or "(" == state[-1] or len(state) % 2 == 1:
print(":(")
else:
state[0] = "("
state[-1] = ")"
left_index = 1
right_index = 1
question_index = 1
while (
left_index != len(state) - 1
and right_index != len(state) - 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF STRING VAR NUMBER STRING VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER STRING ASSIGN VAR NUMBER STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = [i for i in input()]
o = 0
z = 0
O = s.count("(")
Z = s.count(")")
V = s.count("?")
on = (V - (O - Z)) // 2
flag = 0
if on >= 0:
for i in range(n):
if s[i] == "(":
o += 1
if s[i] == ")":
z += 1
if s[i] == "?":
if on > 0:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR ... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = list(input())
b = s.count("(") - s.count(")")
undef = s.count("?")
if b != 0 and undef == 0 or b > undef:
print(":(")
exit()
if b >= 0:
nClose = b
undef -= nClose
if undef & 1 == 1:
print(":(")
exit()
nOpen = undef >> 1
nClose += nOpen
else:
if undef ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FU... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = list(input())
i = 0
j = n - 1
flag = 0
if s[0] == ")" or n % 2 != 0 or s[-1] == "(":
flag = 1
else:
z = n // 2 - s.count("(")
for i in range(n):
if s[i] == "?":
if z != 0:
s[i] = "("
z -= 1
else:
s[i] = ")"
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER STRING BIN_OP VAR NUMBER NUMBER VAR NUMBER STRING ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR VAR S... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | def main():
n = int(input())
s = list(input())
temp_count = 0
for c in s:
if c == "(":
temp_count += 1
stack = []
for i in range(n):
if i == n - 1 and (len(stack) != 1 or s[i] == "("):
print(":(")
return
if s[i] == "(":
stac... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR VAR STRING EXPR FUNC_CALL VAR STRING RETURN IF VAR VAR STRING EXPR FUNC_CALL VAR V... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = input()
res = [""] * n
if n % 2 == 1 or s[0] == ")" or s[n - 1] == "(":
print(":(")
else:
count = 0
for i, c in enumerate(s):
res[i] = c
if c == ")":
count += 1
for i in range(n - 1, -1, -1):
if s[i] == "?":
if count < n / 2:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST STRING VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR STRING VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP ... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
A = list(input())
if A[0] == ")" or A[n - 1] == "(":
print(":(")
else:
A[0] = "("
A[n - 1] = ")"
a = A.count("(")
b = 0
c = 0
for i in range(n):
if A[i] == "(":
b += 1
elif A[i] == ")":
b -= 1
elif c < n // 2 - a:
A... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR ... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | a = int(input())
b = input()
if a > 2 and a % 2 == 0 and b[0] != ")" and b[-1] != "(":
c = 0
d = 0
e = True
k = ""
i = 1
q = 0
while i < a - 1 and e == True:
if b[i] == "(":
c += 1
elif b[i] == ")":
c -= 1
else:
d += 1
if c ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER BIN_OP VAR NUMBER NUMBER VAR NUMBER STRING VAR NUMBER STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VA... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = input()
if n % 2 == 1 or s[0] not in ["(", "?"]:
print(":(")
else:
l, r = s.count("("), s.count(")")
if l > n // 2 or r > n // 2:
print(":(")
else:
pl, pr = abs(n // 2 - l), abs(n // 2 - r)
cnt = 1
sc = "("
p = 1 if s[0] == "?" else 0
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER LIST STRING STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR BIN_OP BIN_OP... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | from sys import stdin, stdout
N = int(input())
s = input()
if N % 2 == 1:
print(":(")
quit()
level = 0
left = 0
for i in range(N):
if s[i] == "(":
left += 1
s = list(s)
for i in range(N):
if s[i] == "(":
level += 1
elif s[i] == ")":
level -= 1
elif s[i] == "?":
i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR V... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = q = int(input())
k = list(input())
cntl = k.count("(")
cntr = k.count(")")
cntq = k.count("?")
for i in range(n):
if k[i] == "?":
if cntl < q // 2 and cntr + cntq >= q // 2:
k[i] = "("
cntl += 1
cntq -= 1
else:
k[i] = ")"
cntr += 1
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR STRING VAR NUMBER VAR NUM... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | import sys
input = sys.stdin.readline
n = int(input())
s = list(input().rstrip())
if n % 2:
print(":(")
exit()
cnt = 0
c = 0
for i in range(n):
if s[i] == "?":
c += 1
elif s[i] == "(":
cnt += 1
a = n // 2 - cnt
b = n // 2 - (n - cnt - c)
if a < 0 or b < 0:
print(":(")
exit()
for... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP BIN_OP... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
S = list(input())
def solve():
if n % 2:
return ":("
L = [0] * n
maxcnt = n // 2 - S.count("(")
cnt = 0
for i in range(n):
if S[i] == "(":
L[i] = 1
elif S[i] == ")":
L[i] = -1
elif cnt < maxcnt:
L[i] = 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF IF BIN_OP VAR NUMBER RETURN STRING ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR NUMBER IF VAR VAR STRING ASSIG... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | def fix(S):
N = len(S)
s = 0
minS = 0
for n in range(N):
if S[n] == "(":
s += 1
elif S[n] == ")":
s -= 1
minS = min(minS, s)
if minS < 0:
for n in range(N):
if S[n] == "?":
S[n] = "("
minS += 1
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR STRING VAR NUMBER VAR NUMBER IF VAR IF VAR NUMBER FOR VA... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = str(input()[:n])
a = [0] * n
ocount = 0
ccount = 0
notfulfilled = 0
pos = 1
if n % 2 != 0:
print(":(")
else:
for i in range(n):
if s[i] == "(":
a[i] = 1
ocount += 1
elif s[i] == ")":
a[i] = -1
ccount += 1
for pos in range(n... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR NUMBER VAR NUMBER I... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input().strip())
ss = input().strip()
q = 0
for k in range(n):
if ss[k] == "(":
q += 1
ii = n // 2 - q
count = 0
s = ""
if n % 2 != 0:
print(":(")
elif ii < 0:
print(":(")
else:
for k in range(n):
if ss[k] == "?" and count < ii:
s = s + "("
count += 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR STRING IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR ... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = input()
l, r = 0, 0
for ch in s:
if ch == "(":
l += 1
elif ch == ")":
r += 1
mid = n // 2
if n % 2 == 1 or l > mid or r > mid:
print(":(")
exit(0)
res = ""
cnt = 0
for i in range(n):
ch = s[i]
if ch == "?":
if l < mid:
l += 1
c... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER FOR ... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = list(input())
if n == 0:
print("")
exit()
if s[0] == ")" or s[-1] == "(":
print(":(")
exit()
if n % 2 != 0:
print(":(")
exit()
q_marks_count = 0
l_brackets_count = 0
r_brackets_count = 0
for i in range(n):
if s[i] == "?":
q_marks_count += 1
elif s[i] == "(":
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF VAR NUMBER STRING VAR NUMBER STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN V... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | s = int(input())
inp = input()
open_count = inp.count("(")
close_count = inp.count(")")
open_new = s // 2 - open_count
close_new = s - open_count - close_count - open_new
bracket = list(inp)
for i in range(s):
if bracket[i] == "?":
if open_new > 0:
bracket[i] = "("
open_new -= 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR NUMBER ASSIGN VAR VAR ST... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = input()
C0 = 0
C1 = 0
C2 = 0
L = []
flag = 0
cc0 = []
cc1 = []
for i in range(len(s) - 1, -1, -1):
L.append(s[i])
if s[i] == "(":
C0 += 1
elif s[i] == ")":
C1 += 1
else:
C2 += 1
cc0.append(C0)
cc1.append(C1)
cc0 = cc0[::-1]
cc1 = cc1[::-1]
L = L[::-1]... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR S... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | from sys import stdin, stdout
n = int(stdin.readline())
s = stdin.readline()
s = list(s)
B = True
if n & 1 or s[n - 1] == "(" or s[0] == ")" or s[n - 2] == "(":
print(":(")
else:
op = n // 2
cp = n // 2
aop = 0
acp = 0
cop = 0
if s[0] == "?":
s[0] = "("
if s[n - 1] == "?":
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | import sys
sys_input = sys.stdin.readline
def si():
return sys_input().rstrip()
def ii():
return int(si())
def sti():
return si().split()
def iti():
return map(int, sti())
def sli():
return list(si())
def ili():
return list(iti())
n = ii()
s = sli()
def main():
if n == 2 and... | IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FU... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = input()
res = []
x = 0
l = r = n // 2
l -= s.count("(")
r -= s.count(")")
y = r - l
f = s.count("?")
def check(d, b):
ans = x + d >= b
if d == 1:
ans &= l >= 1
else:
ans &= r >= 1
ans &= -f <= -(x + y + d) <= f
return ans
for i, c in enumerate(s):
if n & ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR STRING VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR BIN_OP VAR VAR VAR IF VAR NUMBER VAR VAR NUMBER VAR VAR NUMBE... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = str(input())
s = list(s)
if n % 2 == 1:
print(":(")
quit()
a = b = 0
for i in s:
if i == "(":
a += 1
elif i == ")":
b += 1
a = n // 2 - a
b = n // 2 - b
for i in range(n):
if s[i] == "?":
if a == 0:
s[i] = ")"
b -= 1
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_O... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = list(input())
if n % 2 == 1:
print(":(")
exit()
l, r = n // 2, n // 2
q = 0
for i in range(n):
if s[i] == "(":
l -= 1
elif s[i] == "?":
q += 1
else:
r += 1
if l < 0 or r < 0:
print(":(")
exit()
tmp = 0
for i in range(n):
if s[i] == "(":
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR NUMBER IF VA... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = input()
a = []
for i in range(n):
if s[i] == "?":
a.append("(")
else:
a.append(s[i])
cnt = 0
ans = 0
for i in range(n):
if a[i] == "(":
cnt += 1
else:
cnt -= 1
ans = min(ans, cnt)
for i in range(n - 1, -1, -1):
if cnt > 0 and s[i] == "?":
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR ... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = input()
if n % 2 != 0:
print(":(")
exit()
a = list(s)
xopen = a.count("(")
for i in range(len(a)):
if a[i] == "?":
if xopen < n // 2:
xopen += 1
a[i] = "("
else:
a[i] = ")"
diff = 0
for i in range(len(a)):
if a[i] == "(":
d... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR STRING ASSIGN... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
seq = list(input())
ob = cb = res = 0
for i in range(0, n):
if seq[i] == "(":
ob = ob + 1
elif seq[i] == ")":
cb = cb + 1
for i in range(0, n):
if seq[i] == "?":
if ob < n / 2:
seq[i] = "("
ob = ob + 1
else:
seq[i] = ")"
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER ASSIGN VAR VA... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | def solve():
if n % 2:
return ":("
c = 0
op = 0
for i in range(n):
if s[i] == "(":
op += 1
for i in range(n):
if op == n // 2:
break
if s[i] == "?":
s[i] = "("
op += 1
for i in range(n):
if i != 0 and c <= 0:... | FUNC_DEF IF BIN_OP VAR NUMBER RETURN STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER IF VAR VAR STRING ASSIGN VAR VAR STRING VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER RETURN STRING IF VAR VAR STRING ... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = list(input())
l = s.count("(")
cnt = 0
for i in range(n):
if s[i] == "?":
if l + l < n:
s[i] = "("
l += 1
else:
s[i] = ")"
for i in range(n):
if s[i] == "(":
cnt += 1
elif s[i] == ")":
cnt -= 1
if cnt < 0 or cnt != ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR VAR VAR ASSIGN VAR VAR STRING VAR NUMBER ASSIGN VAR VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRIN... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | def ex():
print(":(")
exit()
def check(q):
o, c = 0, 0
for i in q:
if i == "(":
o += 1
else:
if o == 0:
return 0
o -= 1
return 1
n = int(input())
s = list(input())
if n % 2:
ex()
o = s.count("(")
b = 0
for i in range(n):
... | FUNC_DEF EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR NUMBER RETURN NUMBER VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | def is_true(s):
v = 0
for i in range(len(s)):
if s[i] == "(":
v = v + 1
else:
v = v - 1
if v < 0:
return False
if v == 0:
return True
return False
def solve(s):
n = len(s)
if n % 2 == 0:
if s[-1] != "(" and s[0] != ")"... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER IF VAR NUMBER STRING VAR NUMBER STRING AS... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = list(input())
answer = []
left = s.count("(")
right = s.count(")")
l = r = 0
if n % 2 == 0:
for item in s:
if item == "(":
l += 1
answer.append("(")
elif item == ")":
r += 1
answer.append(")")
if r > l:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR STRING VAR NUMBER EXPR FUNC_CALL VAR STRIN... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = input()
l = s.count("(")
r = s.count(")")
ans = "("
x = ":("
if n & 1 or l > n // 2 or r > n // 2:
print(x)
else:
l1 = n // 2 - l
r1 = n // 2 - r
l, r = 0, 0
ans = ""
i = 0
while i < len(s):
if s[i] == "?":
if l1 > 0:
ans += "("
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR STRING ASSIGN VAR STRING IF BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = list(input())
l = 0
r = 0
for i in range(n):
if s[i] == "(":
r += 1
elif s[i] == ")":
l += 1
x = n - l - r
g = r - l
ee = (x - abs(g)) // 2
t = 0
for i in range(n):
if s[i] == "?":
if t < ee:
s[i] = "("
t += 1
elif t >= ee + abs(g)... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR NUMBER ASSIG... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | from itertools import accumulate
from sys import exit
N = int(input())
S = input()
if S[0] == ")" or S[-1] == "(" or N % 2 == 1:
print(":(")
exit()
L = [0] * N
posi = 0
nega = 0
for i, s in enumerate(S):
if s == "(":
posi += 1
L[i] = 1
continue
elif s == ")":
nega += 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER STRING VAR NUMBER STRING BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING VAR NUMBER ASSIGN VAR VAR NUMBER ... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | import sys
num = int(input())
raw = input()
inputs = [item for item in raw]
result = [item for item in raw]
if num % 2 == 0:
found = True
a = 0
b = 0
c = 0
for i in range(num):
if inputs[i] == "(":
a += 1
elif inputs[i] == ")":
b += 1
else:
... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR NUMBER IF BIN_O... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
my_str = input()
strl = list(my_str)
num = [0] * n
if n % 2:
print(":(")
exit()
for i in range(n - 2, 0, -1):
num[i] = num[i + 1]
if strl[i] == "(":
num[i] = num[i] + 1
l = 0
s = 0
for i in range(n):
if strl[i] == "(":
l = l + 1
s = s + 1
elif strl[i] == ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR STRING ASSIGN VAR VAR BIN... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | def main():
n = int(input())
s = input()
mid = s[1 : len(s) - 1]
if n == 1:
print(":(")
return
correct = False
left = 0
right = 0
for i in mid:
if i == "(":
left += 1
elif i == ")":
right += 1
left = len(mid) // 2 - left
rig... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
inp = input()
l, r = 0, 0
for i in range(n):
if inp[i] == "(":
l += 1
elif inp[i] == ")":
r += 1
lsaved = -1 * l + n // 2
rsaved = -1 * r + n // 2
res = []
for i in range(n):
if inp[i] == "?":
if lsaved:
res.append("(")
lsaved -= 1
eli... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL V... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = list(input())
if n % 2 == 1:
print(":(")
else:
op = n // 2 - s.count("(")
for i in range(n):
if s[i] == "?":
if op > 0:
s[i] = "("
else:
s[i] = ")"
op -= 1
b = 0
for i in range(n):
if s[i] == ")"... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING VAR NUMBER ASSIGN VAR NUMBER ... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = input()
open = 0
closed = 0
for i in range(n):
if s[i] == "(":
open += 1
elif s[i] == ")":
closed += 1
a = n / 2 - open
b = n / 2 - closed
ans = ""
openct = 0
closedct = 0
can = True
if n % 2 or open > n / 2:
can = False
can = False
if can:
for i in range(n):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER AS... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | import sys
def rint():
return list(map(int, sys.stdin.readline().split()))
n = int(input())
s = input()
o = s.count("(")
c = s.count(")")
ans = []
cnt = 0
ok = 0
for i in range(n):
ans.append(s[i])
oc = o - c
if oc > 0:
for i in range(n - 1, -1, -1):
if oc == 0:
break
if ans[... | IMPORT FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN V... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = list(input())
if n % 2:
print(":(")
exit()
left = s.count("(")
right = s.count(")")
plus = 0
for i in range(n):
if s[i] == "?":
if left < n // 2:
s[i] = "("
left += 1
else:
s[i] = ")"
right += 1
if s[i] == "(":
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER ASSIGN VAR VAR STRING VAR... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = list(input())
if n % 2 == 1:
print(":(")
else:
opa = n // 2 - s.count("(")
k = 0
for i in range(n):
if s[i] == "(":
k += 1
elif s[i] == ")":
k -= 1
if i < n - 1 and k <= 0:
print(":(")
break
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR ... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = input()
r = s[::-1]
cl, cr, tcr = 0, 0, 0
k = 0
p = ["("]
if n % 2 == 0:
if s[0] == ")" or s[n - 1] == "(":
print(":(")
else:
for i in range(1, n - 1):
if s[i] == ")":
cl += 1
if i - cl < cl:
k = 1
break... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST STRING IF BIN_OP VAR NUMBER NUMBER IF VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = input()
l = list(s)
count, count1 = 0, 0
if n % 2 == 1:
print(":(")
exit()
for i in range(n):
if s[i] == "(":
count += 1
elif s[i] == ")":
count1 += 1
count = n // 2 - count
for j in range(n):
if s[j] == "?" and count > 0:
l[j] = "("
count -= 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR F... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | def solve(s):
if len(s) == 1 or s[-1] == "(" or s[0] == ")" or len(s) % 2 == 1:
return ":("
ans = list(s)
ans[0] = "("
ans[-1] = ")"
left = []
star = []
for i in range(1, len(s) - 1):
if s[i] == "(":
left += [i]
elif s[i] == ")":
if left:
... | FUNC_DEF IF FUNC_CALL VAR VAR NUMBER VAR NUMBER STRING VAR NUMBER STRING BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER RETURN STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER STRING ASSIGN VAR NUMBER STRING ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR ... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | from sys import stdin, stdout
def get():
return stdin.readline().strip()
def getf():
return [int(i) for i in get().split()]
def put(a, end="\n"):
stdout.write(str(a) + end)
def putf(a, sep=" ", end="\n"):
stdout.write(sep.join([str(i) for i in a]) + end)
def bruh():
n = int(get())
s = ... | FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_DEF STRING STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VA... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = input()
fail = ":("
if n % 2 != 0:
print(fail)
quit()
ocount = n // 2 - s.count("(")
ccount = n // 2 - s.count(")")
ans = []
balance = 0
for i, sym in enumerate(s):
if sym != "?":
ans.append(sym)
elif ocount > 0:
ocount -= 1
ans.append("(")
elif ccount > ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR FUNC_CAL... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = list(input())
answer = [0] * n
st = 0
en = 0
for i in range(n):
if s[i] == "(":
st += 1
elif s[i] == ")":
en += 1
for i in range(n):
if s[i] == "?":
if st < n // 2:
s[i] = "("
st += 1
else:
s[i] = ")"
found = True
temp ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER ASSIGN VAR VAR STRI... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | l = int(input())
s = input()
o = s.count("(")
c = s.count(")")
d = s.count("?")
numo, numc = 0, 0
if o < c:
numo += c - o
else:
numc += o - c
d -= numo
d -= numc
numo += d // 2
numc += d // 2
d -= 2 * d // 2
u = s.replace("?", "(", numo).replace("?", ")", numc)
p = 0
v = True
for c in u[: l - 1]:
if c == "(... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER NUMBER IF VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP NUMB... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | def main():
n = int(input())
arr = list(input())
if n & 1:
print(":(")
return 0
left = n // 2 - arr.count("(")
for i in range(n):
if arr[i] == "?":
if left:
arr[i] = "("
left -= 1
else:
arr[i] = ")"
i... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR ASSIGN VAR VAR STRING VAR NUMBER ASSIGN VAR VAR STRING IF VAR NU... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = list(input())
if n % 2:
print(":(")
exit()
res = n // 2
for i in range(n):
if s[i] == "(":
res -= 1
for i in range(n):
if s[i] != "?":
continue
if res > 0:
s[i] = "("
res -= 1
else:
s[i] = ")"
c = 0
for i in range(n):
if s[i] == "(... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR NUMBER ASSIGN VAR VAR STRING VAR NUMBER A... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | import sys
class Main:
def __init__(self):
self.buff = None
self.index = 0
def __next__(self):
if self.buff is None or self.index == len(self.buff):
self.buff = sys.stdin.readline().split()
self.index = 0
val = self.buff[self.index]
self.index ... | IMPORT CLASS_DEF FUNC_DEF ASSIGN VAR NONE ASSIGN VAR NUMBER FUNC_DEF IF VAR NONE VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER RETURN VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN VAR NUMBER IF VAR NUMBER NUMBER... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | N = int(input())
S = input()
l = 0
r = 0
for s in S:
if s == "(":
l += 1
elif s == ")":
r += 1
if N % 2 == 1:
ans = ":("
else:
lim = N // 2
ok = True
if l > lim or r > lim:
ok = False
ans = ""
for s in S:
if s == "(" or s == ")":
ans += s
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR VA... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = list(input())
if n % 2 == 1 or s.count("(") > n // 2 or s.count(")") > n // 2:
print(":(")
exit()
ok = True
op, cl = 0, 0
for i in range(n):
if s[i] == ")":
cl += 1
else:
op += 1
if cl > op:
print(":(")
exit()
op, cl = 0, 0
for i in range(n - 1, -... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR STRING BIN_OP VAR NUMBER FUNC_CALL VAR STRING BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
seq = list(input())
l = 0
r = 0
for c in seq:
if c == "(":
l += 1
elif c == ")":
r += 1
for i in range(len(seq) - 1, -1, -1):
if seq[i] == "?":
if r < n / 2:
seq[i] = ")"
r += 1
else:
seq[i] = "("
t = 0
broke = False
for i,... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER ASSIGN VAR VAR STRING VAR NUMBER ... |
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.
In his favorite math class, the teacher taught him the following interesting definitions.
A parenthesis sequence is a string, containing only characters "(" and ")".
A correct parenthesis sequence is a parenthesis sequence ... | n = int(input())
s = list(input())
def create_seq(n, s):
if n % 2 == 1:
return print(":(")
if s[0] == ")":
return print(":(")
open_limit = int(n / 2)
close_limit = int(n / 2)
for i in range(n):
if s[i] == "(":
open_limit -= 1
elif s[i] == ")":
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF IF BIN_OP VAR NUMBER NUMBER RETURN FUNC_CALL VAR STRING IF VAR NUMBER STRING RETURN FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRIN... |
Elections in Berland are coming. There are only two candidates — Alice and Bob.
The main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:... | m = int(input())
dou = 0
fir = []
sec = []
non = []
d, f, s, n = 0, 0, 0, 0
for i in [0] * m:
a, b = list(map(int, input().split()))
if a == 11:
dou += b
d += 1
elif a == 1:
sec.append(b)
s += 1
elif a == 10:
fir.append(b)
f += 1
else:
non.appe... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER FOR VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL ... |
Elections in Berland are coming. There are only two candidates — Alice and Bob.
The main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:... | n = int(input())
a = []
b = []
c = []
d = []
for i in range(n):
e, f = list(map(int, input().split()))
if e == 11:
a.append(f)
elif e == 10:
b.append(f)
elif e == 1:
c.append(f)
elif e == 0:
d.append(f)
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
d.... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NU... |
Elections in Berland are coming. There are only two candidates — Alice and Bob.
The main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:... | n = int(input())
tonumber = {"00": 0, "01": 1, "10": 2, "11": 3}
people = [[], [], [], []]
for i in range(n):
s, a = input().split()
s, a = tonumber[s], int(a)
people[s].append(a)
people[0].sort(reverse=True)
people[1].sort(reverse=True)
people[2].sort(reverse=True)
totalInfluence = sum(people[3])
totalPeop... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT STRING STRING STRING STRING NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST LIST LIST LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FU... |
Elections in Berland are coming. There are only two candidates — Alice and Bob.
The main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:... | def read():
return []
def main():
n = int(input())
d = [[], [], [], []]
for _ in range(n):
key, influence = input().split()
key = int(key, 2)
d[key].append(int(influence))
for key in range(4):
d[key].sort(reverse=True)
ans = sum(d[3])
additional = len(d[3])
... | FUNC_DEF RETURN LIST FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST LIST LIST LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUN... |
Elections in Berland are coming. There are only two candidates — Alice and Bob.
The main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:... | n = int(input())
t_11 = []
t_10 = []
t_01 = []
t_00 = []
for x in range(n):
tmp = list(input().split())
supp = str(tmp[0])
m = int(tmp[1])
t_tmp = [supp, m]
if supp == "11":
t_11.append(t_tmp)
elif supp == "01":
t_01.append(t_tmp)
elif supp == "10":
t_10.append(t_tmp)... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST VAR VAR IF VAR STRING EXPR FUNC_CALL VAR VAR IF VAR ST... |
Elections in Berland are coming. There are only two candidates — Alice and Bob.
The main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:... | d = {"00": [], "01": [], "10": [], "11": []}
n = int(input())
for i in range(n):
x, p = input().split()
d[x].append(int(p))
for key in d.keys():
d[key].sort(reverse=True)
t = "01" if len(d["01"]) <= len(d["10"]) else "10"
t1 = "01" if t == "10" else "10"
ans = 0
ans += sum(d["11"]) + sum(d[t]) + sum(d[t1][:... | ASSIGN VAR DICT STRING STRING STRING STRING LIST LIST LIST LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR STRING FUNC_CALL VAR VAR STRIN... |
Elections in Berland are coming. There are only two candidates — Alice and Bob.
The main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:... | n = int(input())
su0 = []
su1 = []
su00 = []
su11 = []
ans = 0
for i in range(n):
sup, val = map(int, input().split())
if sup == 0:
su00.append(val)
elif sup == 11:
su11.append(val)
elif sup == 1:
su0.append(val)
else:
su1.append(val)
su0.sort()
su1.sort()
su11.sort()... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR ... |
Elections in Berland are coming. There are only two candidates — Alice and Bob.
The main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:... | n = int(input())
influences = [[], [], [], []]
for i in range(0, n):
[support, influence] = [x for x in input().split()]
support = int(support, 2)
influences[support].append(int(influence))
for i in range(0, 4):
influences[i] = sorted(influences[i])
influences[i].reverse()
total_influence = 0
total_... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST LIST LIST LIST LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN LIST VAR VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.