description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters '+' and '1'. For example, sequences '(())()', '()', and '(()(()))' are balanced, while ')(', '(()', and '(()))(' are not.
You are given a binary string $s$ of length $n$. Construct two balanced bracket sequen... | from sys import stdin
text = stdin.read().splitlines()
t = int(text[0])
def ones(s):
return len(list(filter(lambda x: x == "1", s)))
for i in range(1, 2 * t + 1, 2):
n = int(text[i])
binum = text[i + 1]
if binum[0] == "0" or binum[-1] == "0":
print("NO")
continue
onecount = ones... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR STRING VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER STRING VAR NUMBER STRING EXP... |
A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters '+' and '1'. For example, sequences '(())()', '()', and '(()(()))' are balanced, while ')(', '(()', and '(()))(' are not.
You are given a binary string $s$ of length $n$. Construct two balanced bracket sequen... | def solve():
n = int(input())
s = input()
count = c = 0
for j in range(n):
if s[j] == "0":
count += 1
else:
c += 1
if s[0] == "0" or s[n - 1] == "0" or count % 2:
print("NO")
return
a = ""
b = ""
f = 0
c = int(c / 2)
one = 0... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER IF VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER ASSI... |
A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters '+' and '1'. For example, sequences '(())()', '()', and '(()(()))' are balanced, while ')(', '(()', and '(()))(' are not.
You are given a binary string $s$ of length $n$. Construct two balanced bracket sequen... | import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")
for _ in range(int(input())):
n = int(input())
s = input()
o = s.count("1")
z = n - o
c = 0
o = o // 2
opn = False
done = False
if z % 2:
print("NO")
else:
a, b = "", ""
for i in s:
... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NU... |
A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters '+' and '1'. For example, sequences '(())()', '()', and '(()(()))' are balanced, while ')(', '(()', and '(()))(' are not.
You are given a binary string $s$ of length $n$. Construct two balanced bracket sequen... | def count(string, character):
count = 0
for i in range(len(string)):
if string[i] == character:
count = count + 1
return count
for t in range(int(input())):
n = int(input())
s = input()
zc = count(s, "0")
if zc % 2 == 1 or s[0] == "0" or s[-1] == "0":
print("NO"... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR STRING IF BIN_OP VAR NUMBER NUMBER VAR NUMBER STRING VA... |
A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters '+' and '1'. For example, sequences '(())()', '()', and '(()(()))' are balanced, while ')(', '(()', and '(()))(' are not.
You are given a binary string $s$ of length $n$. Construct two balanced bracket sequen... | for q in range(int(input())):
n = int(input())
s = input()
x = s.count("1")
y = s.count("0")
a_str = ""
b_str = ""
possible = True
if y % 2 == 1:
possible = False
else:
xh = x // 2
yh = y // 2
openx = 0
a_open = 0
b_open = 0
for... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR 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 STRING ASSIGN VAR STRING ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BI... |
A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters '+' and '1'. For example, sequences '(())()', '()', and '(()(()))' are balanced, while ')(', '(()', and '(()))(' are not.
You are given a binary string $s$ of length $n$. Construct two balanced bracket sequen... | import sys
input = sys.stdin.readline
def main():
n = int(input())
S = input().strip()
l = S.count("1")
o = S.count("0")
if l % 2 == 1:
print("NO")
return
if S[0] == "0" or S[-1] == "0":
print("NO")
return
print("YES")
cnt_o = 0
cnt_l = 0
T1 = [... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING RETURN IF VAR NUMBER STRING VAR NUMBER STRING EXPR FUNC_CALL VAR STRING RETURN EXPR FUNC_CALL VAR... |
A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters '+' and '1'. For example, sequences '(())()', '()', and '(()(()))' are balanced, while ')(', '(()', and '(()))(' are not.
You are given a binary string $s$ of length $n$. Construct two balanced bracket sequen... | import sys
sys.setrecursionlimit(10**5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II():
return int(sys.stdin.buffer.readline())
def LI():
return list(map(int, sys.stdin.buffer.readline().split()))
def LI1():
return list(map(int1, sys.stdin.buffer.readline().split()))
def L... | IMPORT EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_D... |
A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters '+' and '1'. For example, sequences '(())()', '()', and '(()(()))' are balanced, while ')(', '(()', and '(()))(' are not.
You are given a binary string $s$ of length $n$. Construct two balanced bracket sequen... | T = int(input())
for ts in range(T):
N = int(input())
s = input()
if s[0] == "0" or s[-1] == "0":
print("NO")
continue
a = ["("]
b = ["("]
ca = 1
cb = 1
for i in range(1, N - 1):
if s[i] == "1":
if ca == 0 or cb == 0:
a.append("(")
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER STRING VAR NUMBER STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST STRING ASSIGN VAR LIST STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMB... |
A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters '+' and '1'. For example, sequences '(())()', '()', and '(()(()))' are balanced, while ')(', '(()', and '(()))(' are not.
You are given a binary string $s$ of length $n$. Construct two balanced bracket sequen... | def ii():
return int(input())
def li():
return [int(i) for i in input().split()]
for t in range(ii()):
n = ii()
s = input()
ones = 0
if s[0] != "1" or s[n - 1] != "1":
print("NO")
else:
for i in range(n):
ones += s[i] == "1"
if ones % 2 == 1:
... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR VAR VAR ... |
A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters '+' and '1'. For example, sequences '(())()', '()', and '(()(()))' are balanced, while ')(', '(()', and '(()))(' are not.
You are given a binary string $s$ of length $n$. Construct two balanced bracket sequen... | import sys
input = sys.stdin.readline
for _ in range(int(input())):
n = int(input())
s = input()
cnt = 0
for i in s:
cnt += i == "1"
if s[0] == "0" or s[n - 1] == "0" or cnt % 2 == 1:
print("NO")
continue
k = 0
a, b = "", ""
flip = False
for i in range(n):
... | IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR VAR VAR STRING IF VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR VAR STRIN... |
A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters '+' and '1'. For example, sequences '(())()', '()', and '(()(()))' are balanced, while ')(', '(()', and '(()))(' are not.
You are given a binary string $s$ of length $n$. Construct two balanced bracket sequen... | for i in range(int(input())):
n = int(input())
s = input()
cnt = 0
for i in s:
if i == "0":
cnt += 1
if cnt % 2 == 1 or s[0] == "0" or s[n - 1] == "0":
print("NO")
continue
a = ""
b = ""
turn = False
cnt1 = n - cnt
c1 = 0
for i in s:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUM... |
A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters '+' and '1'. For example, sequences '(())()', '()', and '(()(()))' are balanced, while ')(', '(()', and '(()))(' are not.
You are given a binary string $s$ of length $n$. Construct two balanced bracket sequen... | t = int(input())
for _ in range(t):
n = int(input())
temp = [int(i) for i in input()]
a, b = "", ""
temp_a, temp_b = 0, 0
flag = 0
k = temp.count(1)
if n % 2 != 0 or temp[0] == 0 or temp[-1] == 0 or k % 2 != 0:
flag = 1
open_a, open_b = n // 2, n // 2
close_a, close_b = n // ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR STRING STRING ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER NUMB... |
A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters '+' and '1'. For example, sequences '(())()', '()', and '(()(()))' are balanced, while ')(', '(()', and '(()))(' are not.
You are given a binary string $s$ of length $n$. Construct two balanced bracket sequen... | import sys
for _ in range(int(input())):
n = int(input())
s = sys.stdin.readline().rstrip()
one = s.count("1")
if s[0] == s[-1] == "1" and one % 2 == 0:
a = []
b = []
one //= 2
flag = 0
for i in s:
if i == "0":
a.append(["(", ")"][flag... | IMPORT FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER STRING BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR LIST VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING EXPR FUNC_CAL... |
A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters '+' and '1'. For example, sequences '(())()', '()', and '(()(()))' are balanced, while ')(', '(()', and '(()))(' are not.
You are given a binary string $s$ of length $n$. Construct two balanced bracket sequen... | for _ in range(int(input())):
n = int(input())
s = [int(a) for a in input()]
cnt = sum(s)
if s[0] and s[-1] and n & 1 ^ 1 and cnt & 1 ^ 1:
a, b, p = [0] * n, [0] * n, 1
for i, x in enumerate(s):
if x:
if cnt > 0:
a[i] = b[i] = 1
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR BIN_OP LIST NUMBER VAR BIN_OP LIST NUMBER VAR N... |
A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters '+' and '1'. For example, sequences '(())()', '()', and '(()(()))' are balanced, while ')(', '(()', and '(()))(' are not.
You are given a binary string $s$ of length $n$. Construct two balanced bracket sequen... | for s in [*open(0)][2::2]:
N = len(s) - 1
o = s.count("1")
if s[0] < "1" or s[-2] < "1":
print("NO")
continue
if o & 1:
print("NO")
continue
n = 0
a = [0] * N
b = [0] * N
c = 1
for i in range(N):
if s[i] < "1":
if c:
... | FOR VAR LIST FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER STRING VAR NUMBER STRING EXPR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR... |
A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters '+' and '1'. For example, sequences '(())()', '()', and '(()(()))' are balanced, while ')(', '(()', and '(()))(' are not.
You are given a binary string $s$ of length $n$. Construct two balanced bracket sequen... | t = int(input())
for _ in range(t):
n = int(input())
a = input()
z = 0
o = 0
if a[0] != "1" or a[-1] != "1":
print("NO")
else:
d = {}
for i in range(n):
if a[i] == "1":
o += 1
z = n - o
if z % 2 != 0:
print("NO")
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER STRING VAR NUMBER STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP V... |
A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters '+' and '1'. For example, sequences '(())()', '()', and '(()(()))' are balanced, while ')(', '(()', and '(()))(' are not.
You are given a binary string $s$ of length $n$. Construct two balanced bracket sequen... | def solve():
n = int(input())
s = input()
c = []
b = []
z = s.count("1")
if s[0] != "1" or s[-1] != "1":
print("NO")
else:
p = n - z
if p % 2:
print("NO")
return
k = 0
t = 0
for j in s:
if j == "1":
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER STRING VAR NUMBER STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR NUMBER ASSIGN VAR NUMBER FO... |
A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters '+' and '1'. For example, sequences '(())()', '()', and '(()(()))' are balanced, while ')(', '(()', and '(()))(' are not.
You are given a binary string $s$ of length $n$. Construct two balanced bracket sequen... | t = int(input())
for _ in range(t):
n = int(input())
s = input()
if s[0] == "0" or s[-1] == "0" or s.count("0") % 2 == 1 or s.count("1") % 2 == 1:
print("NO")
continue
zero = s.count("0")
one = s.count("1")
zopen = zero // 2
zclose = zero // 2
oopen = one // 2
oclose ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER STRING VAR NUMBER STRING BIN_OP FUNC_CALL VAR STRING NUMBER NUMBER BIN_OP FUNC_CALL VAR STRING NUMBER NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR... |
A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters '+' and '1'. For example, sequences '(())()', '()', and '(()(()))' are balanced, while ')(', '(()', and '(()))(' are not.
You are given a binary string $s$ of length $n$. Construct two balanced bracket sequen... | t = int(input())
for i in range(t):
n = int(input())
s = input()
cnt = 0
for i in range(n):
if s[i] == "1":
cnt += 1
if cnt % 2 != 0 or s[0] == "0" or s[-1] == "0":
print("NO")
else:
flag = 0
k = 0
a = ""
b = ""
for i in range(n... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER STRING VAR NUMBER STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR... |
A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters '+' and '1'. For example, sequences '(())()', '()', and '(()(()))' are balanced, while ')(', '(()', and '(()))(' are not.
You are given a binary string $s$ of length $n$. Construct two balanced bracket sequen... | for _ in range(int(input())):
n = int(input())
l = list(map(int, input()))
o = l.count(1)
z = l.count(0)
if n % 2 != 0:
print("NO")
elif o % 2 != 0:
print("NO")
elif l[0] == 0 or l[n - 1] == 0:
print("NO")
else:
print("YES")
a = ""
b = ""
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING IF... |
A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters '+' and '1'. For example, sequences '(())()', '()', and '(()(()))' are balanced, while ')(', '(()', and '(()))(' are not.
You are given a binary string $s$ of length $n$. Construct two balanced bracket sequen... | def solve():
n = int(input())
s = input()
if s[len(s) - 1] == "0" or s[0] == "0":
print("NO")
return
else:
ones = 0
for i in range(len(s)):
ones += s[i] == "1"
if ones % 2 == 1:
print("NO")
return
else:
print... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER STRING VAR NUMBER STRING EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR STRING IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING RETURN EXPR FUNC_CA... |
A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters '+' and '1'. For example, sequences '(())()', '()', and '(()(()))' are balanced, while ')(', '(()', and '(()))(' are not.
You are given a binary string $s$ of length $n$. Construct two balanced bracket sequen... | from sys import stdin, stdout
t = int(input())
for _ in range(t):
n = int(input())
s = list(stdin.readline())
s1 = [0] * n
s2 = [0] * n
c = 0
for i in range(n):
if s[i] == "0":
if c % 2:
s1[i] = ")"
s2[i] = "("
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP VAR NUMBER ASSIGN VAR VAR STRING ASSI... |
A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters '+' and '1'. For example, sequences '(())()', '()', and '(()(()))' are balanced, while ')(', '(()', and '(()))(' are not.
You are given a binary string $s$ of length $n$. Construct two balanced bracket sequen... | cases = int(input())
while cases:
cases -= 1
num = int(input())
s = list(map(int, list(input())))
if len(s) % 2 != 0 or s[0] == 0 or s[-1] == 0 or s.count(0) % 2 != 0:
print("NO")
else:
ones = s.count(1) // 2
zeros = s.count(0)
ans1 = ""
ans2 = ""
for ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER BIN_OP FUNC_CALL VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR STRING ASSI... |
A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters '+' and '1'. For example, sequences '(())()', '()', and '(()(()))' are balanced, while ')(', '(()', and '(()))(' are not.
You are given a binary string $s$ of length $n$. Construct two balanced bracket sequen... | import sys
t = int(sys.stdin.readline())
for _ in range(t):
n = int(sys.stdin.readline())
data = sys.stdin.readline().rstrip()
cnt_one = 0
for i in data:
if i == "1":
cnt_one += 1
if data[0] == "0" or data[-1] == "0" or cnt_one % 2 == 1:
print("NO")
continue
... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR NUMBER STRING VAR NUMBER STRING BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR STRING STRING ... |
A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters '+' and '1'. For example, sequences '(())()', '()', and '(()(()))' are balanced, while ')(', '(()', and '(()))(' are not.
You are given a binary string $s$ of length $n$. Construct two balanced bracket sequen... | for k in range(int(input())):
n = int(input())
s = input()
a, b = "", ""
x = s.count("1")
y = s.count("0")
if s[0] != "1" or s[n - 1] != "1" or n % 2 != 0 or x % 2 != 0 or y % 2 != 0:
print("NO")
else:
for i in range(n):
if s[i] == "1":
if x % 2 ==... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR STRING STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER BIN_OP VAR NU... |
A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters '+' and '1'. For example, sequences '(())()', '()', and '(()(()))' are balanced, while ')(', '(()', and '(()))(' are not.
You are given a binary string $s$ of length $n$. Construct two balanced bracket sequen... | def init_array(n):
arr1d = [0] * n
return arr1d
def init_array2d(arr_rows, arr_columns):
arr2d = [[(0) for a in range(arr_columns)] for b in range(arr_rows)]
return arr2d
def print_array2d(arr2d):
for f in range(len(arr2d)):
for q in range(len(arr2d[0])):
print(arr2d[f][q])
... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR RETURN VAR FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC... |
A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters '+' and '1'. For example, sequences '(())()', '()', and '(()(()))' are balanced, while ')(', '(()', and '(()))(' are not.
You are given a binary string $s$ of length $n$. Construct two balanced bracket sequen... | import sys
lines = sys.stdin.readlines()
lineidx = 0
def readLine():
global lineidx
s = lines[lineidx].strip()
lineidx += 1
return s
t = int(readLine())
for testcase in range(t):
n = int(readLine())
s = readLine()
cntone = s.count("1")
cntzero = s.count("0")
if cntone % 2 != 0 o... | IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF BIN_OP VAR NUM... |
A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters '+' and '1'. For example, sequences '(())()', '()', and '(()(()))' are balanced, while ')(', '(()', and '(()))(' are not.
You are given a binary string $s$ of length $n$. Construct two balanced bracket sequen... | import sys
input = sys.stdin.readline
def solve():
n = int(input())
s = input().strip()
c = s.count("1")
if c % 2 == 1 or n % 2 == 1:
print("NO")
return
c //= 2
b = 0
b1 = 0
b2 = 0
s1 = []
s2 = []
for i in s:
if i == "1":
if c > 0:
... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING RETURN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ... |
A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters '+' and '1'. For example, sequences '(())()', '()', and '(()(()))' are balanced, while ')(', '(()', and '(()))(' are not.
You are given a binary string $s$ of length $n$. Construct two balanced bracket sequen... | t = int(input())
for _ in range(t):
n = int(input())
s = input()
a = ""
b = ""
x = 0
y = 0
f = 1
one = s.count("1")
half = one // 2
if one % 2:
f = 0
for i in range(n):
if x < 0 or y < 0:
f = 0
break
if s[i] == "1":
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR NUMBER F... |
A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters '+' and '1'. For example, sequences '(())()', '()', and '(()(()))' are balanced, while ')(', '(()', and '(()))(' are not.
You are given a binary string $s$ of length $n$. Construct two balanced bracket sequen... | for j in range(int(input())):
n = int(input())
s = input()
if s.count("0") % 2 != 0 or s[0] == "0" or s[-1] == "0":
print("NO")
else:
print("YES")
k = s.count("1")
r = ""
f = ""
t = 0
p = 0
i = 0
while i < n:
if s[i] == ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF BIN_OP FUNC_CALL VAR STRING NUMBER NUMBER VAR NUMBER STRING VAR NUMBER STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR STRING ASSIGN VAR STRING ASSIG... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | a, b = map(int, input().split())
c = a + b
k = 1
s = 0
while s + k <= c:
s += k
k += 1
x = []
border = -1
d = -1
for i in range(k - 1, 0, -1):
if i <= a:
a -= i
x.append(str(i))
elif i > a and a != 0:
d = a
x.append(str(a))
border = i
break
elif a == 0... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | a, b = map(int, input().split())
g = False
if b < a:
g = True
a, b = b, a
na = 0
nb = 0
n = 0
while a >= (na + 1) * na // 2:
na += 1
na -= 1
if g == False:
print(na)
sa = (na + 1) * na // 2
nb = na + 1
x = na + 1 - (a - sa)
f = False
if a - sa != 0 and b >= x:
f = True
b -= x
nb = na + 2
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP BI... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | a, b = input().split()
a = int(a)
b = int(b)
v = 0
l = []
k = 0
s = 0
while s <= a + b:
k += 1
s += k
l.append(k)
del l[-1]
m = []
for i in range(k - 2, -1, -1):
if a >= l[i]:
a -= l[i]
m.append(l[i])
del l[i]
print(len(m))
print(*m)
print(len(l))
print(*l) | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VA... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | from sys import stdin, stdout
def readlist():
a = [int(i) for i in stdin.readline().split()]
return a
def root(a):
p = (1 + 8 * a) ** 0.5 - 1
p = p / 2
return int(p)
c, d = readlist()
if c > d:
a = d
b = c
fl = 1
else:
b = d
a = c
fl = 0
p = root(a)
z = list(range(1, p ... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR RETURN VAR FUNC_DEF ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER BIN_OP NUMBER VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | def print_result(arr):
print(len(arr))
for num in arr:
print(num, end=" ")
print()
arr = [int(x) for x in input().split()]
a, b = arr[0], arr[1]
s = a + b
used = 0
j = 1
while used + j <= s:
used += j
j += 1
j -= 1
A, B = [], []
for i in range(j, 0, -1):
if a >= i:
A.append(i)
... | FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER AS... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | a, b = map(int, input().split())
array1 = []
array2 = []
array3 = []
array4 = []
l = 0
r = 10000000000
while r - l > 1:
m = (l + r) // 2
if (m + 1) / 2 * m > a + b:
r = m
else:
l = m
summ1 = 0
summ2 = 0
for i in range(l, 0, -1):
if a - summ1 >= i:
array1.append(i)
summ1 =... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSI... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | a, b = map(int, input().split())
max_lectures = a + b
n = 1
while n * (n + 1) / 2 <= a + b:
n = n + 1
n = n - 1
a_list = []
b_list = []
a_sum = 0
b_sum = 0
for i in range(n, 0, -1):
if a_sum + i <= a:
a_list.append(i)
a_sum = a_sum + i
elif b_sum + i <= b:
b_list.append(i)
b_... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUM... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | def get_out(list):
print(len(list))
out = " ".join(list)
print(out)
arr = input().split()
a = int(arr[0])
b = int(arr[1])
s = a + b
temp = 0
i = 0
while temp <= s:
i += 1
temp += i
i -= 1
list_a = []
list_b = []
for x in range(i, 0, -1):
if a - x >= 0:
a -= x
list_a.append(str(... | FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL STRING VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER VAR VAR VAR NUMBER ASSIGN... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | a, b = map(int, input().split())
if a <= b:
l = 0
r = a + 1
while r - l > 1:
m = (l + r) // 2
if m * (m + 1) // 2 > a:
r = m
else:
l = m
n = l
a -= n * (n + 1) // 2
c = 1
N = [(i + 1) for i in range(n)]
if a > 0:
c = n + 1 - a
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NU... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | a, b = map(int, input().split())
n = None
for i in range(10**5):
if i * (i + 1) <= (a + b) * 2:
n = i
else:
break
s1 = 0
a1 = []
a2 = []
for i in range(1, n + 1):
if s1 + i <= a:
a1.append(i)
s1 += i
elif s1 < a:
x = s1 + i - a
a1.remove(x)
a1.appe... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NONE FOR VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR EXPR FUNC... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | a, b = map(int, input().split())
s = a + b
n = 0
k = 1
A = []
while n <= s:
A.append(k)
n += k
k += 1
n -= k - 1
k -= 2
A = A[:k]
P = []
Q = []
for i in range(k - 1, -1, -1):
if a - A[i] >= 0:
P.append(A[i])
a -= A[i]
else:
Q.append(A[i])
b -= A[i]
print(len(P))
print... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBE... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | def main():
a, b = map(int, input().split())
if a + b == 0:
print(0)
print(0)
return
_sum = 0
last = 0
for i in range(1, a + b + 1):
_sum += i
if _sum == a + b:
last = i
break
elif _sum > a + b:
_sum -= i
... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR VAR IF VAR BIN_OP VAR VAR ASSIGN VAR VAR IF VAR BIN_OP VAR VAR VAR VAR A... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | a, b = map(int, input().split())
arr = []
sum_ = a + b
k = 1
while sum_ >= k:
arr.append(k)
sum_ -= k
k += 1
a1, b1 = [], []
for i in range(len(arr) - 1, -1, -1):
if a >= arr[i]:
a -= arr[i]
a1.append(arr[i])
elif b >= arr[i]:
b -= arr[i]
b1.append(arr[i])
print(len(a... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | n, m = list(map(int, input().split()))
basis = []
day2 = []
day1 = []
day1sum = 0
iterator = 1
suma = 0
a = n + m
while suma + iterator <= a:
basis.append(iterator)
suma += iterator
iterator += 1
for i in range(len(basis) - 1, -1, -1):
if n - basis[i] >= 0:
n -= basis[i]
day1.append(basi... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR WHILE BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | a, b = map(int, input().split())
t = a
x = a + b
i = 0
while i * (i + 1) // 2 <= x:
i += 1
n = i - 1
x = []
y = []
k = []
i = 0
p = 0
while i < n:
k += [i + 1]
i += 1
i = n - 1
h = 0
while i > -1:
if a >= k[i]:
a -= k[i]
x += [k[i]]
h += 1
else:
if a != 0:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR LIST BIN_... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | from sys import setcheckinterval, setrecursionlimit, stdin
setcheckinterval(1000)
setrecursionlimit(10**7)
def iin():
return int(stdin.readline())
def lin():
return list(map(int, stdin.readline().split()))
a, b = lin()
A = a
ch = 1
ch1 = 1
while ch1 <= a + b:
ch += 1
ch1 += ch
a1 = []
a2 = []
for... | EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR VAR VAR NUMBER VAR VAR ASSIGN VAR LIS... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | a, b = map(int, input().split())
if a == 1 and b == 1:
print(1)
print(1)
print(0)
exit()
k = 0
p = 0
for i in range(1, 1000000):
k += i
if k >= a + b:
p = i
break
d = k - a - b
k1 = 0
p1 = 0
for i in range(1, 1000000):
k1 += i
if k1 >= a:
p1 = i
break
d1 =... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER VAR VAR IF VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | def findn(a, b):
s = a + b
left = 0
right = b
while left + 1 < right:
mid = (left + right) // 2
if mid**2 + mid < 2 * s:
left = mid
else:
right = mid
if right**2 + right > 2 * s:
return right - 1
return right
flag = True
a, b = map(int, i... | FUNC_DEF ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER VAR BIN_OP NUMBER VAR ASSIGN VAR VAR ASSIGN VAR VAR IF BIN_OP BIN_OP VAR NUMBER VAR BIN_OP NUMBER VAR RETURN BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR NUMBER ... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | a, b = map(int, input().split())
e = 1
while e * (e + 1) // 2 < a + b:
e += 1
if e * (e + 1) // 2 > a + b:
e -= 1
use = [0] * 1000000
q = []
p = []
i = e
s = 0
while True:
if i == 0:
break
if a >= s + i:
q.append(i)
use[i] = 1
s += i
else:
a -= s
if no... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR VAR VAR NUMBER IF BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR ASSIGN VAR NUM... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | a, b = map(int, input().split())
k = 0
while k * (k + 1) // 2 <= a + b:
k += 1
k -= 1
A = []
for i in range(1, k + 1):
A.append(i)
List_1 = []
for i in range(k - 1, -1, -1):
if A[i] <= a:
List_1.append(A[i])
a -= A[i]
A.pop(i)
print(len(List_1))
print(*List_1)
print(len(A))
print(*A) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF ... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | import sys
a, b = map(int, input().split())
f = 0
if b > a:
a, b = b, a
f = 1
cop = a
n = 1
fir = []
sec = []
while a >= n:
a -= n
fir.append(n)
n += 1
if b == 0:
if f == 0:
print(len(fir))
print(*fir, sep=" ")
print(0)
else:
print(0)
print(len(fir))
... | IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST WHILE VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | def shours(x):
return x * (1 + x) // 2
def solver(k):
if k in {0, 1}:
return k
a = 0
b = k
while b - a != 1:
m = (a + b) // 2
if shours(m) > k:
b = m
else:
a = m
return a
a, b = [int(x) for x in input().split()]
x = []
y = []
for text i... | FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP NUMBER VAR NUMBER FUNC_DEF IF VAR NUMBER NUMBER RETURN VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_C... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | def f(n):
return n * (n + 1) // 2
def process(n, m):
x = n + m
start = 0
end = 2 * x
while start + 1 < end:
M = (start + end) // 2
if f(M) > x:
start, end = start, M
else:
start, end = M, end
a = []
s = start
b = set(range(1, start + 1))
... | FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR WHILE BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR VAR ASSIGN VA... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | a, b = map(int, input().split())
t = a + b
cnt = 0
for i in range(10**9):
cnt += 1
if cnt * (cnt + 1) // 2 > t:
cnt -= 1
break
firstday = []
secondday = []
for x in range(cnt, 0, -1):
if a >= x:
firstday.append(x)
a -= x
else:
secondday.append(x)
b -= x
pr... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER VAR NUMBER IF BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF VAR VAR EXPR FUNC_CALL VAR VA... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | a, b = map(int, input().split())
i = 1
s = i
ind = [i]
sums = 0
sums1 = 0
u = []
p = []
while s < a + b:
i += 1
s += i
ind.append(i)
if s > a + b:
ind.remove(i)
if a <= b:
for j in range(-len(ind) + 1, 1):
if a - ind[-j] >= 0 and j <= 0:
sums += 1
u.append(ind... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR LIST VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST WHILE VAR BIN_OP VAR VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR IF VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR IF VAR VAR FOR VAR FUNC_CALL V... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | def count_2_days(a, b):
sumi = a + b
sum_ = 0
numbers = []
for i in range(1, sumi + 1):
if sum_ + 2 * i + 1 <= sumi:
sum_ += i
numbers.append(i)
elif sum_ + 2 * i + 1 > sumi:
numbers.append(sumi - sum_)
break
elif sum_ + i == sumi:
... | FUNC_DEF ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR BIN_OP NUMBER VAR NUMBER VAR VAR VAR EXPR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR BIN_OP NUMBER VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VA... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | def Binary(s):
L = 0
R = s + 1
while L <= R - 1:
c = (L + R) // 2
x = (1 + c) * c // 2
if s == x:
return c
elif x < s:
L = c + 1
else:
R = c
return L - 1
a, b = map(int, input().split())
s = a + b
C = list(range(1, Binary(s) +... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER IF VAR VAR RETURN VAR IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR RETURN BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CA... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | a, b = map(int, input().split())
n = int((1 + (1 + 8 * (a + b)) ** 0.5) / 2 - 1)
con = [x for x in range(1, n + 1)]
con = con[::-1]
con1 = []
con2 = []
a1 = a
b1 = b
a = max(a, b)
b = min(a1, b1)
for i in range(0, len(con)):
if a - con[i] > 0:
con1.append(con[i])
a -= con[i]
con[i] = 0
e... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER BIN_OP BIN_OP NUMBER BIN_OP NUMBER BIN_OP VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR ASSIGN VAR V... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | a, b = map(int, input().split())
k = 1
s = 1
while s + (k + 1) <= a + b:
k += 1
s += k
p = []
q = []
sp = 0
use = set()
for i in range(1, k + 1)[::-1]:
if sp + i <= a:
p.append(i)
sp += i
use.add(i)
sq = 0
for i in range(1, k + 1)[::-1]:
if not i in use:
if sq + i <= b:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR NUMBER VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR VAR VAR EXPR FU... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | a, b = map(int, input().split())
n = 0
l = []
m = []
while (n + 1) * (n + 2) // 2 <= a + b:
n = n + 1
for i in range(n, 0, -1):
if a >= i:
a -= i
l.append(i)
else:
m.append(i)
print(len(l))
print(*l)
print(len(m))
print(*m) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST WHILE BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR E... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | a = input()
a, b = a.split(" ")
a = int(a)
b = int(b)
def binary_search(val):
l, r, ans = 1, val, -1
while l <= r:
mid = (l + r) // 2
if mid * (mid + 1) <= 2 * val:
ans = mid
l = mid + 1
else:
r = mid - 1
return ans
val = binary_search(a + b)
l... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR VAR VAR NUMBER VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN ... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | a, b = map(int, input().split())
def numbers(n):
resp = []
curr = 1
while n >= curr:
resp.append(curr)
n -= curr
curr += 1
return resp
num = numbers(a + b)
anum = set()
for x in num[::-1]:
if a >= x:
a -= x
anum.add(x)
print(len(anum))
for x in anum:
p... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CAL... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | a, b = map(int, input().split())
s = a + b
best = 0
for i in range(1, s + 1):
if i * (i + 1) // 2 <= s:
best = i
else:
break
save_best = best
first_day = set()
second_day = set()
while a != 0 and best != 0:
nxt = min(a, best)
best -= 1
first_day.add(nxt)
a -= nxt
for i in range(1... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR FUN... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | a, b = [int(x) for x in input().split()]
s = 0
k = 0
m = []
while s <= a + b:
k += 1
s += k
m.append(k)
del m[k - 1]
d = a + b - s
p = []
for i in range(k - 2, -1, -1):
if a >= m[i]:
p.append(m[i])
a -= m[i]
del m[i]
print(len(p))
print(*p, sep=" ")
print(len(m))
print(*m, sep=" ... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR BIN_OP VAR VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR ... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | a, b = map(int, input().split())
c = []
e = []
i = 1
s = 1
c.append(i)
e.append(i)
while s <= a + b:
i += 1
s += i
c.append(i)
e.append(i)
i = i - 1
c.pop()
e.pop()
i -= 1
j = -1
d = []
while j < i:
if c[i] <= a:
d.append(c[i])
a -= c[i]
e.pop(i)
i -= 1
print(len(d))
for ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR WHILE VAR BIN_OP VAR VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_C... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | def ans_1():
print(len(day1))
for j in day1:
print(j, end=" ")
def ans_2():
print(i - len(day1) - 1 - 1)
for j in range(i - 2, 0, -1):
if j not in day1:
print(j, end=" ")
a, b = map(int, input().split())
c, d = a, b
a, b = min(a, b), max(a, b)
total = a + b
count = 0
i = ... | FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING FUNC_DEF EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | a, b = map(int, input().split())
left, right = 0, 10**5
while left != right - 1:
mid = (left + right) // 2
a1, b1 = min(a, b), max(a, b)
for k in range(mid, 0, -1):
if k <= a1:
a1 -= k
else:
b1 -= k
if min(a1, b1) < 0:
right = mid
else:
left = ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER BIN_OP NUMBER NUMBER WHILE VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF VAR VAR VAR VAR VAR VAR IF FUNC_CALL VAR VAR VAR N... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | from sys import exit
def f1(a):
d = int((1 + 8 * a) ** 0.5)
fst = (d - 1) // 2
if fst != 0:
ost = a - fst * (fst + 1) // 2
p = ost // fst
ls1 = p + 1
lf1 = p + fst - ost % fst
ls2 = lf1 + 2
lf2 = fst + p + 1
return ls1, lf1, ls2, lf2
else:
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | def print_set(n):
print(len(n))
n = [str(i) for i in n]
print(" ".join(n))
a, b = map(int, input().split())
s = a + b
used = 0
k = 1
A = []
B = []
while used + k <= s:
used += k
k += 1
k -= 1
while k > 0:
if k <= a:
A.append(k)
a -= k
else:
b -= k
B.append(k... | FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST WHILE BIN_OP VAR VAR VAR VAR VAR VAR NUMBER VA... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | a, b = map(int, input().split())
total = a + b
s = 0
e = 10000000000.0
while s != e:
g = (s + e + 1) // 2
if g * (g + 1) // 2 > total:
e = g - 1
else:
s = g
total_book = int(s)
books = [i for i in range(1, total_book + 1)]
first_day = []
sec_day = []
k = len(books)
if a >= b:
while k != ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER IF BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | inp = input().split()
a = int(inp[0])
b = int(inp[1])
x = 1
while (x + 1) * (x + 2) / 2 <= a + b:
x += 1
choice_map = [(False) for _ in range(x)]
choice_a = []
choice_b = []
aux_a = a
aux_b = b
for _i in range(x):
i = x - 1 - _i
if i + 1 <= aux_a and not choice_map[i]:
choice_a.append(i + 1)
... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER BIN_OP VAR VAR VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR ASSIGN VAR VAR FOR ... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | a, b = input().split()
a, b = int(a), int(b)
c = a + b
i = 0
resa = []
resb = []
while c > 0:
i += 1
c -= i
if c < 0:
i -= 1
for j in range(i, 0, -1):
if a - j >= 0:
a -= j
resa.append(j)
else:
b -= j
resb.append(j)
print(len(resa))
for j in range(len(resa)):
prin... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST WHILE VAR NUMBER VAR NUMBER VAR VAR IF VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF BIN_OP VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR V... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | a, b = map(int, input().split())
sum = a + b
m = 1
s = 0
while s + m <= sum:
s += m
m += 1
m -= 1
al = []
bl = []
for i in range(m, 0, -1):
if a - i >= 0:
al.append(i)
a -= i
elif b - i >= 0:
bl.append(i)
b -= i
print(len(al))
print(" ".join(map(str, al)))
print(len(bl))
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR IF BIN_OP VAR VAR ... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | a, b = map(int, input().split())
curr = a
ind = 1
f = []
s = []
while curr >= ind:
f.append(ind)
curr -= ind
ind += 1
extra = -1
if curr and ind - curr <= ind:
f.append(ind)
extra = ind - curr
ind += 1
curr = b
while curr >= ind:
s.append(ind)
curr -= ind
ind += 1
if extra != -1:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST WHILE VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR EXPR FUNC... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | a, b = map(int, input().split())
limit = 1
s = a + b
num = 0
while s >= num + limit:
num += limit
limit += 1
limit -= 1
a_array = []
b_array = []
for i in range(limit, 0, -1):
if i <= a:
a_array.append(i)
a -= i
elif i <= b:
b_array.append(i)
b -= i
print(len(a_array))
pr... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VA... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | def main():
a, b = map(int, input().split())
mx = max(a, b)
mn = min(a, b)
s = mx + mn
k = int(0.5 * ((1 + 8 * s) ** 0.5 - 1))
rk = range(k, 0, -1)
st = {i: (True) for i in rk}
r1, r2 = mn, mx
xe, ie = 0, 0
for k in rk:
if k <= r1:
st[k] = "min"
ie... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER BIN_OP BIN_OP BIN_OP NUMBER BIN_OP NUMBER VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBE... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | a, b = list(map(int, input().split()))
x = a + b
n = int((1 + 8 * x) ** 0.5 / 2 - 0.5)
flag = 0
if a > b:
a, b = b, a
flag = 1
ar1 = []
num1 = 0
for i in range(n, 0, -1):
if a - num1 >= i:
ar1.append(i)
num1 += i
ar2 = []
for i in range(1, n + 1):
if i not in ar1:
ar2.append(i)
i... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER BIN_OP NUMBER VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VA... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | A, B = map(int, input().split())
s = A + B
c = 0
k = 0
while c <= s:
k += 1
c += k
k -= 1
n = list()
m = list()
if A < B:
while k:
if A >= k:
n.append(k)
A -= k
else:
m.append(k)
k -= 1
else:
while k:
if B >= k:
m.append(k)
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR VAR WHILE VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER WHILE VAR ... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | capacity = [int(i) for i in input().split()]
x = 0
while x * (x + 1) // 2 <= sum(capacity):
x += 1
x -= 1
reading_list = [[], []]
cur_size = [0, 0]
for i in range(x, 0, -1):
for j in range(2):
if cur_size[j] + i <= capacity[j]:
cur_size[j] += i
reading_list[j].append(i)
... | ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR LIST LIST LIST ASSIGN VAR LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR VAR VAR VAR VAR V... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | a, b = map(int, input().split(" "))
s = 0
k = 0
c = "1"
q = 0
while s < a + b:
k = k + 1
s += k
c = c + "0"
n = k
if s > a + b:
c = c[: s - a - b] + "1" + c[s - a - b + 1 :]
n = k - 1
l = k
m = 0
while m < a:
if c[l] == "0":
c = c[:l] + "2" + c[l + 1 :]
m = m + l
q += 1
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR VAR IF VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR VAR VAR S... |
In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.
Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tom... | a, b = [int(i) for i in input().split()]
x = 0
while x * (x + 1) // 2 <= a + b:
x += 1
x -= 1
Alist = []
Blist = []
curA = 0
curB = 0
for i in range(x, 0, -1):
if curA + i <= a:
curA += i
Alist.append(i)
elif curB + i <= b:
curB += i
Blist.append(i)
print(len(Alist))
print(*A... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF BIN_OP VAR VAR VAR VAR VAR EXPR FUNC_CALL VA... |
During a recent research Berland scientists found out that there were n cities in Ancient Berland, joined by two-way paths. Any two cities are joined by no more than one path. No path joins a city with itself. According to a well-known tradition, the road network was built so that it would be impossible to choose three... | p = int(input())
print((p // 2) ** 2 + p // 2 * (p % 2))
for i in range(p // 2):
for j in range(p // 2, p):
print(i + 1, j + 1) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER |
During a recent research Berland scientists found out that there were n cities in Ancient Berland, joined by two-way paths. Any two cities are joined by no more than one path. No path joins a city with itself. According to a well-known tradition, the road network was built so that it would be impossible to choose three... | a = int(input())
l, r = a // 2, (a + 1) // 2
print(l * r)
for i in range(0, l):
for j in range(0, r):
print(i + 1, j + l + 1) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER |
During a recent research Berland scientists found out that there were n cities in Ancient Berland, joined by two-way paths. Any two cities are joined by no more than one path. No path joins a city with itself. According to a well-known tradition, the road network was built so that it would be impossible to choose three... | n = int(input())
ans = 0
for i in range(2, n + 1):
ans += 1
for j in range(i - 3, 0, -2):
ans += 1
print(ans)
for i in range(2, n + 1):
print(i, i - 1)
for j in range(i - 3, 0, -2):
print(i, j) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP ... |
During a recent research Berland scientists found out that there were n cities in Ancient Berland, joined by two-way paths. Any two cities are joined by no more than one path. No path joins a city with itself. According to a well-known tradition, the road network was built so that it would be impossible to choose three... | n = int(input())
if n == 1:
print(0)
elif n == 2:
print(1)
print(1, 2)
else:
fh = []
sh = []
for i in range(1, (n - 2) // 2 + 1):
fh.append(i + 2)
for i in range(3 + (n - 2) // 2, n + 1):
sh.append(i)
total = 1 + len(fh) * len(sh) + len(fh) + len(sh)
print(total)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BI... |
During a recent research Berland scientists found out that there were n cities in Ancient Berland, joined by two-way paths. Any two cities are joined by no more than one path. No path joins a city with itself. According to a well-known tradition, the road network was built so that it would be impossible to choose three... | import sys
n = int(sys.stdin.readline())
print(n**2 // 4)
for i in range(n // 2):
for j in range(n // 2, n):
print(str(i + 1) + " " + str(j + 1)) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER STRING FUNC_CALL VAR BIN_OP VAR NUMBER |
During a recent research Berland scientists found out that there were n cities in Ancient Berland, joined by two-way paths. Any two cities are joined by no more than one path. No path joins a city with itself. According to a well-known tradition, the road network was built so that it would be impossible to choose three... | n = int(input())
a = list(range(1, n + 1))
edge = []
used = []
for i, u in enumerate(a):
for j in range(1, n, 2):
if i + j >= n:
continue
ind = i + j
edge.append([u, a[ind]])
print(len(edge))
for u, v in edge:
print("{} {}".format(u, v)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VA... |
During a recent research Berland scientists found out that there were n cities in Ancient Berland, joined by two-way paths. Any two cities are joined by no more than one path. No path joins a city with itself. According to a well-known tradition, the road network was built so that it would be impossible to choose three... | import sys
input = sys.stdin.readline
n = int(input())
if n == 1:
print(0)
quit()
if n == 2:
print(1)
print(1, 2)
quit()
if n % 2 == 0:
k = (n - 2) // 2
l = (n - 2) // 2
z = k * l + l + k + 1
print(z)
l1 = []
l2 = []
print(1, 2)
for i in range(3, 3 + k):
l1.a... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER N... |
During a recent research Berland scientists found out that there were n cities in Ancient Berland, joined by two-way paths. Any two cities are joined by no more than one path. No path joins a city with itself. According to a well-known tradition, the road network was built so that it would be impossible to choose three... | n = int(input())
a = range(1, n // 2 + 1)
b = range(n // 2 + 1, n + 1)
print(n // 2 * (n - n // 2))
for i in a:
for j in b:
print(i, j) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER FOR VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR VAR |
During a recent research Berland scientists found out that there were n cities in Ancient Berland, joined by two-way paths. Any two cities are joined by no more than one path. No path joins a city with itself. According to a well-known tradition, the road network was built so that it would be impossible to choose three... | def do():
n = int(input())
ln = n >> 1
res = []
for i in range(1, ln + 1):
for j in range(ln + 1, n + 1):
res.append((i, j))
return res
res = do()
print(len(res))
for x, y in res:
print(str(x) + " " + str(y)) | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR VAR EXPR F... |
During a recent research Berland scientists found out that there were n cities in Ancient Berland, joined by two-way paths. Any two cities are joined by no more than one path. No path joins a city with itself. According to a well-known tradition, the road network was built so that it would be impossible to choose three... | n = int(input())
adj = [([0] * (n + 1)) for i in range(n + 1)]
if n <= 3:
if n == 1:
print(0)
elif n == 2:
print(1)
print(1, 2)
else:
print(2)
print(1, 2)
print(2, 3)
exit(0)
m = 0
ans = []
for i in range(1, n):
ans.append([i, i + 1])
adj[i][i + 1]... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_C... |
Given two positive integers a and b, we define f(a, b) = \text{lcm}(a, b) - \gcd(a, b), where \text{lcm} denotes the [lowest common multiple] and \gcd denotes the [greatest common divisor].
Chef has a positive integer N. He wonders, what is the maximum value of f(a, b) over all pairs (a, b) such that a and b are posit... | try:
t = 1
t = int(input())
while t > 0:
n = int(input())
if n == 2:
print(0)
elif n % 2 == 1:
print((n - 1) // 2 * ((n + 1) // 2) - 1)
elif n % 2 == 0:
if (n // 2 - 1) % 2 == 1:
print((n // 2 - 1) * (n // 2 + 1) - 1)
... | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER IF BIN_... |
Given two positive integers a and b, we define f(a, b) = \text{lcm}(a, b) - \gcd(a, b), where \text{lcm} denotes the [lowest common multiple] and \gcd denotes the [greatest common divisor].
Chef has a positive integer N. He wonders, what is the maximum value of f(a, b) over all pairs (a, b) such that a and b are posit... | for _ in range(int(input())):
n = int(input())
if n < 3:
print(0)
else:
if n % 2 == 1:
ret = (n + 1) // 2 * ((n - 1) // 2) - 1
elif n // 2 % 2 == 0:
ret = (n + 2) // 2 * ((n - 2) // 2) - 1
else:
ret = (n + 4) // 2 * ((n - 4) // 2) - 1
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP ... |
Given two positive integers a and b, we define f(a, b) = \text{lcm}(a, b) - \gcd(a, b), where \text{lcm} denotes the [lowest common multiple] and \gcd denotes the [greatest common divisor].
Chef has a positive integer N. He wonders, what is the maximum value of f(a, b) over all pairs (a, b) such that a and b are posit... | ans = []
for _ in range(int(input())):
N = int(input())
N2 = N // 2
if N == 2:
an = 0
elif not N % 2:
if not N2 % 2:
an = N2**2 - 2
else:
an = N2**2 - 5
else:
an = (N - N2) * N2 - 1
ans.append(an)
print(*ans, sep="\n") | ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP B... |
Given two positive integers a and b, we define f(a, b) = \text{lcm}(a, b) - \gcd(a, b), where \text{lcm} denotes the [lowest common multiple] and \gcd denotes the [greatest common divisor].
Chef has a positive integer N. He wonders, what is the maximum value of f(a, b) over all pairs (a, b) such that a and b are posit... | t = int(input())
for i in range(t):
n = int(input())
if n == 2:
print(0)
elif n % 2 == 0:
a = n // 2 - 1
b = a + 2
if a % 2 != 0 and b % 2 != 0:
print(a * b - 1)
else:
a -= 1
b += 1
print(a * b - 1)
else:
a =... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_... |
Given two positive integers a and b, we define f(a, b) = \text{lcm}(a, b) - \gcd(a, b), where \text{lcm} denotes the [lowest common multiple] and \gcd denotes the [greatest common divisor].
Chef has a positive integer N. He wonders, what is the maximum value of f(a, b) over all pairs (a, b) such that a and b are posit... | def gcd(a, b):
if a == 0:
return b
return gcd(b % a, a)
def lcm(a, b):
return a / gcd(a, b) * b
for _ in range(int(input())):
n = int(input())
l = []
if n == 2:
print(0)
elif n % 2 == 1:
n = n + 1
n = int(n / 2)
l.append(n - 1)
l.append(n)
... | FUNC_DEF IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR BIN_OP VAR VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR FUNC_CALL VAR VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BI... |
Given two positive integers a and b, we define f(a, b) = \text{lcm}(a, b) - \gcd(a, b), where \text{lcm} denotes the [lowest common multiple] and \gcd denotes the [greatest common divisor].
Chef has a positive integer N. He wonders, what is the maximum value of f(a, b) over all pairs (a, b) such that a and b are posit... | for _ in range(int(input())):
n = int(input())
ans = 0
if n & 1:
ans = (n // 2 + 1) * (n // 2) - 1
else:
if n == 2:
print(0)
continue
if n // 2 & 1:
m = n // 2
ans = (m - 2) * (m + 2) - 1
else:
m = n // 2
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN... |
Given two positive integers a and b, we define f(a, b) = \text{lcm}(a, b) - \gcd(a, b), where \text{lcm} denotes the [lowest common multiple] and \gcd denotes the [greatest common divisor].
Chef has a positive integer N. He wonders, what is the maximum value of f(a, b) over all pairs (a, b) such that a and b are posit... | t = int(input())
def solve(x):
if x == 2:
return 0
t = x // 2
if x & 1 == 1:
return t * (t + 1) - 1
elif t % 2 == 0:
return (t - 1) * (t + 1) - 1
else:
return (t - 2) * (t + 2) - 1
for _ in range(t):
n = int(input())
print(solve(n)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER RETURN BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER RETURN BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP... |
Given two positive integers a and b, we define f(a, b) = \text{lcm}(a, b) - \gcd(a, b), where \text{lcm} denotes the [lowest common multiple] and \gcd denotes the [greatest common divisor].
Chef has a positive integer N. He wonders, what is the maximum value of f(a, b) over all pairs (a, b) such that a and b are posit... | t = int(input())
for j in range(t):
n = int(input())
if n & 1:
a = int(n / 2)
b = int((n + 1) / 2)
print(a * b - 1)
elif n == 2:
print(0)
elif n == 4:
print(2)
elif n == 6:
print(4)
else:
k = int(n / 2)
if k & 1:
a = k -... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR ... |
Given two positive integers a and b, we define f(a, b) = \text{lcm}(a, b) - \gcd(a, b), where \text{lcm} denotes the [lowest common multiple] and \gcd denotes the [greatest common divisor].
Chef has a positive integer N. He wonders, what is the maximum value of f(a, b) over all pairs (a, b) such that a and b are posit... | def gcd(m, n):
if n == 0:
return m
else:
return gcd(n, m % n)
t = int(input())
while t:
n = int(input())
if n == 2:
print(0)
elif n % 2 == 0:
if n // 2 % 2 == 0:
x = gcd(n // 2 - 1, n // 2 + 1)
l = (n // 2 - 1) * (n // 2 + 1) // x
... | FUNC_DEF IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER IF BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBE... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.